refactor(sales): 重构销售出库和销售退货插件的时间处理逻辑

- 将按小时分割时间的逻辑改为直接使用整天的时间范围
- 优化了 SoSaleOutPluginInitializerToC 和 SoSaleReturnPluginInitializerToC 类中的代码
- 注释掉了原有的按小时循环的代码,简化了逻辑
- 在测试类中添加了 executeBusiness 方法的调用,用于后续的接口测试
This commit is contained in:
liuy 2024-10-27 19:23:57 +08:00
parent ceac1d668a
commit 6b58abc666
4 changed files with 50 additions and 32 deletions

View File

@ -2598,21 +2598,26 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
} }
logger.info("OFS销售出库单同步U8C销售订单目标拉取时间" + calculateYesterdayStr); logger.info("OFS销售出库单同步U8C销售订单目标拉取时间" + calculateYesterdayStr);
for (int i = 0; i <= 23; i++) { StartAndEndVo startAndEndVo = new StartAndEndVo();
String iStr = null; startAndEndVo.setStart_time(calculateYesterdayStr + " 00:00:00");
if (i <= 9) { startAndEndVo.setEnd_time(calculateYesterdayStr + " 23:59:59");
iStr = "0" + i; startAndEnd.add(startAndEndVo);
} else {
iStr = String.valueOf(i);
}
String startTime = calculateYesterdayStr + " " + iStr + ":00:00";
String endTime = calculateYesterdayStr + " " + iStr + ":59:59";
StartAndEndVo startAndEndVo = new StartAndEndVo(); // for (int i = 0; i <= 23; i++) {
startAndEndVo.setStart_time(startTime); // String iStr = null;
startAndEndVo.setEnd_time(endTime); // if (i <= 9) {
startAndEnd.add(startAndEndVo); // iStr = "0" + i;
} // } else {
// iStr = String.valueOf(i);
// }
// String startTime = calculateYesterdayStr + " " + iStr + ":00:00";
// String endTime = calculateYesterdayStr + " " + iStr + ":59:59";
//
// StartAndEndVo startAndEndVo = new StartAndEndVo();
// startAndEndVo.setStart_time(startTime);
// startAndEndVo.setEnd_time(endTime);
// startAndEnd.add(startAndEndVo);
// }
return startAndEnd; return startAndEnd;
} }

View File

@ -142,7 +142,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
} }
}, "执行插件:" + getPluginName()); }, "执行插件:" + getPluginName());
thread.start(); thread.start();
if (requestJson != null && requestJson.get("type") != null && ProfilesActiveConstant.TYPE_DETAIL_ERROR.equals(requestJson.get("type"))) { if (requestJson != null && requestJson.get("type") != null && ProfilesActiveConstant.TYPE_DETAIL_ERROR.equals(requestJson.get("type"))) {
try { try {
thread.join(); thread.join();
@ -2332,21 +2332,26 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
} }
logger.info("OFS销售出库单同步U8C销售订单目标拉取时间" + calculateYesterdayStr); logger.info("OFS销售出库单同步U8C销售订单目标拉取时间" + calculateYesterdayStr);
for (int i = 0; i <= 23; i++) { StartAndEndVo startAndEndVo = new StartAndEndVo();
String iStr = null; startAndEndVo.setStart_time(calculateYesterdayStr + " 00:00:00");
if (i <= 9) { startAndEndVo.setEnd_time(calculateYesterdayStr + " 23:59:59");
iStr = "0" + i; startAndEnd.add(startAndEndVo);
} else {
iStr = String.valueOf(i);
}
String startTime = calculateYesterdayStr + " " + iStr + ":00:00";
String endTime = calculateYesterdayStr + " " + iStr + ":59:59";
StartAndEndVo startAndEndVo = new StartAndEndVo(); // for (int i = 0; i <= 23; i++) {
startAndEndVo.setStart_time(startTime); // String iStr = null;
startAndEndVo.setEnd_time(endTime); // if (i <= 9) {
startAndEnd.add(startAndEndVo); // iStr = "0" + i;
} // } else {
// iStr = String.valueOf(i);
// }
// String startTime = calculateYesterdayStr + " " + iStr + ":00:00";
// String endTime = calculateYesterdayStr + " " + iStr + ":59:59";
//
// StartAndEndVo startAndEndVo = new StartAndEndVo();
// startAndEndVo.setStart_time(startTime);
// startAndEndVo.setEnd_time(endTime);
// startAndEnd.add(startAndEndVo);
// }
return startAndEnd; return startAndEnd;
} }

View File

@ -1,5 +1,6 @@
package com.hzya.frame.plugin.lets.plugin.sales; package com.hzya.frame.plugin.lets.plugin.sales;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.WebappApplication; import com.hzya.frame.WebappApplication;
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao; import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
@ -97,10 +98,13 @@ class SoSaleOutPluginInitializerToCTest {
try { try {
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-18 00:00:00", "2024-10-18 23:59:59"); // soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-18 00:00:00", "2024-10-18 23:59:59");
String code = "LETS-SH2024052100015139"; // String code = "LETS-SH2024052100015139";
soSaleOutPluginInitializerToC.startImplementStockByCode(code, "tran"); // soSaleOutPluginInitializerToC.startImplementStockByCode(code, "tran");
// soSaleOutPluginInitializerToC.startImplementStockByTimeAndTran("2024-10-22 00:00:00", "2024-10-22 23:59:59"); // soSaleOutPluginInitializerToC.startImplementStockByTimeAndTran("2024-10-22 00:00:00", "2024-10-22 23:59:59");
JSONObject jsonObject = new JSONObject();
soSaleOutPluginInitializerToC.executeBusiness(jsonObject);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,5 +1,6 @@
package com.hzya.frame.plugin.lets.plugin.sales; package com.hzya.frame.plugin.lets.plugin.sales;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.WebappApplication; import com.hzya.frame.WebappApplication;
import com.hzya.frame.plugin.lets.queryvo.StartAndEndVo; import com.hzya.frame.plugin.lets.queryvo.StartAndEndVo;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -40,7 +41,10 @@ public class SoSaleReturnPluginInitializerToCTest {
try { try {
soSaleReturnPluginInitializerToC.startImplementStockByTime("2024-10-21 00:00:00", "2024-10-21 23:59:59"); // soSaleReturnPluginInitializerToC.startImplementStockByTime("2024-10-21 00:00:00", "2024-10-21 23:59:59");
JSONObject jsonObject = new JSONObject();
soSaleReturnPluginInitializerToC.executeBusiness(jsonObject);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }