From 3e9d43f33733c099e1dfa4f1aad945fea44c6212 Mon Sep 17 00:00:00 2001
From: liuy <37787198+LiuyCodes@users.noreply.github.com>
Date: Thu, 26 Dec 2024 14:55:49 +0800
Subject: [PATCH] =?UTF-8?q?feat(plugin):=20=E6=96=B0=E5=A2=9E=20TOC?=
=?UTF-8?q?=E9=80=80=E8=B4=A7=E4=B8=9A=E5=8A=A1=E5=A4=84=E7=90=86=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在 TocofsReturngoodsDetailedEntity 和 TocofsReturngoodsEntity 中添加新的查询条件字段
- 实现根据不同推送场景类型查询和处理 TOC 退货数据的方法
-优化库存同步和交易同步的逻辑,支持多种推送场景
- 新增 queryTocofsReturngoodsDetailed 方法查询底表数据并转换为 StockinOrder 对象
---
.../TocofsReturngoodsDetailedEntity.java | 16 +
.../TocofsReturngoodsDetailedEntity.xml | 12 +
.../ofs/entity/TocofsReturngoodsEntity.java | 13 +-
.../ofs/entity/TocofsReturngoodsEntity.xml | 1 +
.../sales/SoSaleOutPluginInitializerToC.java | 2 +-
.../SoSaleReturnPluginInitializerToC.java | 311 ++++++++++++------
.../SoSaleOutPluginInitializerToCTest.java | 4 +-
7 files changed, 254 insertions(+), 105 deletions(-)
diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsDetailedEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsDetailedEntity.java
index e8b7836a..a0712055 100644
--- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsDetailedEntity.java
+++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsDetailedEntity.java
@@ -384,5 +384,21 @@ public class TocofsReturngoodsDetailedEntity extends BaseEntity {
* 补充的查询条件
*/
private String ids;
+ /**
+ * 入库日期-范围开始
+ */
+ private String businessDateStart;
+ /**
+ * 入库日期-范围结束
+ */
+ private String businessDateEnd;
+ /**
+ * 到账完成日期-开始 refundedAt
+ */
+ private String refundedAtStart;
+ /**
+ * 到账完成日期-结束 refundedAt
+ */
+ private String refundedAtEnd;
}
diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsDetailedEntity.xml b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsDetailedEntity.xml
index d19c124c..4f777f23 100644
--- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsDetailedEntity.xml
+++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsDetailedEntity.xml
@@ -299,6 +299,18 @@
and id in (${ids})
+
+ and businessDate >= #{businessDateStart}
+
+
+ and businessDate <= #{businessDateEnd}
+
+
+ and refundedAt >= #{refundedAtStart}
+
+
+ and refundedAt <= #{refunderAtEnd}
+
-- and sts='Y'
diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsEntity.java
index 6a350e46..267ad861 100644
--- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsEntity.java
+++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsEntity.java
@@ -3,6 +3,8 @@ package com.hzya.frame.plugin.lets.ofs.entity;
import com.hzya.frame.web.entity.BaseEntity;
import lombok.Data;
+import java.util.List;
+
/**
* OFS售后入库单(TocofsReturngoods)实体类
*
@@ -134,5 +136,14 @@ public class TocofsReturngoodsEntity extends BaseEntity {
* 2024-12-26 10:38:00
*/
private String modified;
-}
+ /**
+ * 多个id批量查询
+ */
+ private String ids;
+
+ /**
+ * O售后入库单明细行
+ */
+ private List tocofsReturngoodsDetailedEntityList;
+}
\ No newline at end of file
diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsEntity.xml b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsEntity.xml
index 9b9752c6..6f554ffc 100644
--- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsEntity.xml
+++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsReturngoodsEntity.xml
@@ -180,6 +180,7 @@
and refundedAt = #{refundedat}
and refundStatus = #{refundstatus}
and modified = #{modified}
+ and id in (${ids})
-- and sts='Y'
diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java
index d1b6155b..96137bfe 100644
--- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java
+++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java
@@ -4026,7 +4026,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
List tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
Set mainTableIdSet = tocofsSaleoutDetailedEntityList1.stream().map(TocofsSaleoutDetailedEntity::getMaintableid).collect(Collectors.toSet());
String mainTableIds = mainTableIdSet.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
- //查询对应的O销售订单
+ //查询对应的O销售出库单表头
TocofsSaleoutEntity tocofsSaleoutEntity = new TocofsSaleoutEntity();
tocofsSaleoutEntity.setIds(mainTableIds);
List tocofsSaleoutEntityList = iTocofsSaleoutDao.query(tocofsSaleoutEntity);
diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java
index a188d903..6ae50630 100644
--- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java
+++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java
@@ -32,7 +32,6 @@ import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchDe
import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchHeader;
import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse;
import com.hzya.frame.ttxofs.service.OfsUnifiedService;
-import com.hzya.frame.u8c.ax.entity.Ass;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
@@ -124,6 +123,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
try {
String param = String.valueOf(requestJson.get("param"));
String sceneType = String.valueOf(requestJson.get("sceneType"));//sceneType:stock、tran
+ String pushScenarioType = String.valueOf(requestJson.get("pushScenarioType"));
if (ProfilesActiveConstant.TYPE_VBILLCODE.equals(requestJson.get("type"))) {
//按单号
if (param != null && !"".equals(param)) {
@@ -133,15 +133,15 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
//前台页面功能日期推送,或者接口调用也行
String craeteDateStr = computingTime(param);
if (craeteDateStr != null && !"".equals(craeteDateStr)) {
- splitDateAndPush(craeteDateStr, sceneType);
+ splitDateAndPush(craeteDateStr, sceneType, pushScenarioType);
}
} else {
if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(PROD_FILED)) {
//默认被定时器执行,每天晚上凌晨0点5分
//暂定先同步TOC销售库存、再推送TOC销售确认收入
List startAndEndVos = calculateCalculateEntireDayPeriod(null);
- startImplementStockByTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time());
- startImplementByTradeTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time());
+ startImplementStockByTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time(), "0");
+ startImplementByTradeTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time(), "0");
}
}
} catch (Exception e) {
@@ -206,7 +206,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
*
* @author liuyang
*/
- public void startImplementStockByTime(String startTime, String endTime) throws Exception {
+ public void startImplementStockByTime(String startTime, String endTime, String pushScenarioType) throws Exception {
try {
long startMillis = System.currentTimeMillis();
String threadNameStrStart = StrUtil.format("开始-OFS销售出库(TOC)同步U8C销售订单 开始时间:{} 结束时间:{}", startTime, endTime);
@@ -214,25 +214,34 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
Assert.notNull(startTime, "开始时间不能为空");
Assert.notNull(endTime, "结束时间不能为空");
-
- String tocShop = shopTobOrToCUtil.getCommaShop("TOC");
+ Assert.notNull(pushScenarioType, "pushScenarioType不能为空");
// CalculateDateVo calculateDateVo = DateStrUtil.calculateCalculateEntireDayPeriod(dateStr);
-
List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>();
- QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
- queryOfsSoSaleOutVo.setClosedAt_start(startTime);
- queryOfsSoSaleOutVo.setClosedAt_end(endTime);
- queryOfsSoSaleOutVo.setClientCode("LETS");
+ if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
+ String tocShop = shopTobOrToCUtil.getCommaShop("TOC");
+ QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
+ queryOfsSoSaleOutVo.setClosedAt_start(startTime);
+ queryOfsSoSaleOutVo.setClosedAt_end(endTime);
+ queryOfsSoSaleOutVo.setClientCode("LETS");
// queryOfsSoSaleOutVo.setInternalInstructionType("SALES");
- //2024年8月22日 14:02:13 已经和O确认,这个字段取消传递!
+ //2024年8月22日 14:02:13 已经和O确认,这个字段取消传递!
// queryOfsSoSaleOutVo.setCompanyCode("SHLZ");
- queryOfsSoSaleOutVo.setStatus(900L);
- queryOfsSoSaleOutVo.setPageNo(1L);
- queryOfsSoSaleOutVo.setPageSize(50L);
- queryOfsSoSaleOutVo.setStoreCode(tocShop);
- queryOfsSoSaleOutVo.setInternalInstructionType("RETURN");
+ queryOfsSoSaleOutVo.setStatus(900L);
+ queryOfsSoSaleOutVo.setPageNo(1L);
+ queryOfsSoSaleOutVo.setPageSize(50L);
+ queryOfsSoSaleOutVo.setStoreCode(tocShop);
+ queryOfsSoSaleOutVo.setInternalInstructionType("RETURN");
// queryOfsSoSaleOutVo.setCode("LETS-RE2024071600000001");
- ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
+ ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
+ } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) {
+ TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity();
+ tocofsReturngoodsDetailedEntity.setBusinessDateStart(startTime);
+ tocofsReturngoodsDetailedEntity.setBusinessDateEnd(endTime);
+ tocofsReturngoodsDetailedEntity.setBusinesstype("TOC_RETURN");
+ returnGoodHeaderDetailsDataDtoArrayList = queryTocofsReturngoodsDetailed(tocofsReturngoodsDetailedEntity);
+ } else {
+ Assert.state(false, "未知的场景类型!");
+ }
logger.info("TOC退货数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size());
if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
returnGoodHeaderDetailsDataDtoArrayList.removeIf(new Predicate() {
@@ -247,11 +256,10 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
return false;
}
});
- getSetStock(returnGoodHeaderDetailsDataDtoArrayList);
+ getSetStock(returnGoodHeaderDetailsDataDtoArrayList, pushScenarioType);
} else {
logger.info("没有查询到任何数据!不需要同步");
}
-
long endMillis = System.currentTimeMillis();
String threadNameStrEnd = StrUtil.format("结束-OFS销售出库(TOC)同步U8C销售订单 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis));
logger.info(threadNameStrEnd);
@@ -302,9 +310,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
}
});
if (sceneType.equals("stock")) {
- getSetStock(returnGoodHeaderDetailsDataDtoList);
+ getSetStock(returnGoodHeaderDetailsDataDtoList, "2");
} else if (sceneType.equals("tran")) {
- getSetTran(returnGoodHeaderDetailsDataDtoList);
+ getSetTran(returnGoodHeaderDetailsDataDtoList, "2");
}
} else {
logger.info("没有查询到任何数据!不需要同步");
@@ -320,7 +328,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
*
* @author liuyang
*/
- public void startImplementByTradeTime(String startTime, String endTime) throws Exception {
+ public void startImplementByTradeTime(String startTime, String endTime, String pushScenarioType) throws Exception {
try {
long startMillis = System.currentTimeMillis();
String threadNameStrStart = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{}", startTime, endTime);
@@ -328,24 +336,33 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
Assert.notNull(startTime, "startTime不能为空");
Assert.notNull(endTime, "endTime不能为空");
- //生成一个时间范围
-// StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime();
- //2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性
- String tocShop = shopTobOrToCUtil.getCommaShop("TOC");
-
List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>();
- QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
- queryOfsSoSaleOutVo.setRefundedAt_start(startTime);
- queryOfsSoSaleOutVo.setRefundedAt_end(endTime);
- queryOfsSoSaleOutVo.setClientCode("LETS");
- queryOfsSoSaleOutVo.setPageNo(1L);
- queryOfsSoSaleOutVo.setPageSize(50L);
- queryOfsSoSaleOutVo.setStoreCode(tocShop);
- queryOfsSoSaleOutVo.setInternalInstructionType("RETURN");
- queryOfsSoSaleOutVo.setRefundStatus("900");
+
+ if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
+ //生成一个时间范围
+// StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime();
+ //2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性
+ String tocShop = shopTobOrToCUtil.getCommaShop("TOC");
+ QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
+ queryOfsSoSaleOutVo.setRefundedAt_start(startTime);
+ queryOfsSoSaleOutVo.setRefundedAt_end(endTime);
+ queryOfsSoSaleOutVo.setClientCode("LETS");
+ queryOfsSoSaleOutVo.setPageNo(1L);
+ queryOfsSoSaleOutVo.setPageSize(50L);
+ queryOfsSoSaleOutVo.setStoreCode(tocShop);
+ queryOfsSoSaleOutVo.setInternalInstructionType("RETURN");
+ queryOfsSoSaleOutVo.setRefundStatus("900");
// queryOfsSoSaleOutVo.setCode("LETS-RE2024081900000001");
- ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
- logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size());
+ ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
+ } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) {
+ TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity();
+ tocofsReturngoodsDetailedEntity.setRefundedAtStart(startTime);
+ tocofsReturngoodsDetailedEntity.setRefundedAtEnd(endTime);
+ tocofsReturngoodsDetailedEntity.setBusinesstype("TOC_RETURN");
+ returnGoodHeaderDetailsDataDtoArrayList = queryTocofsReturngoodsDetailed(tocofsReturngoodsDetailedEntity);
+ } else {
+ Assert.state(false, "未知的场景类型!");
+ } logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size());
if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
returnGoodHeaderDetailsDataDtoArrayList.removeIf(new Predicate() {
@Override
@@ -359,7 +376,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
return false;
}
});
- getSetTran(returnGoodHeaderDetailsDataDtoArrayList);
+ getSetTran(returnGoodHeaderDetailsDataDtoArrayList, pushScenarioType);
} else {
logger.info("没有查询到任何数据!不需要同步");
}
@@ -377,15 +394,17 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
*
* @author liuyang
*/
- private void getSetStock(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
+ private void getSetStock(List returnGoodHeaderDetailsDataDtoArrayList, String pushScenarioType) throws Exception {
LOCK1.lock();
try {
//过滤成功的数据
List stockinOrderList = filterDataStock(returnGoodHeaderDetailsDataDtoArrayList);
//保存到mysql
- batchInsert(stockinOrderList);
+ if (!ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) {
+ batchInsert(stockinOrderList);
+ }
//执行推送主逻辑
- implementStock(stockinOrderList);
+ implementStock(stockinOrderList, pushScenarioType);
} catch (Exception e) {
logger.error("TOC退货-库存:getSetStock方法抛出异常", e);
} finally {
@@ -398,15 +417,17 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
*
* @author liuyang
*/
- private void getSetTran(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
+ private void getSetTran(List returnGoodHeaderDetailsDataDtoArrayList, String pushScenarioType) throws Exception {
LOCK2.lock();
try {
//过滤成功的数据
List stockinOrderList = filterDataTran(returnGoodHeaderDetailsDataDtoArrayList);
//保存到mysql
- batchInsert(stockinOrderList);
+ if (!ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) {
+ batchInsert(stockinOrderList);
+ }
//执行推送主逻辑
- implementTran(stockinOrderList);
+ implementTran(stockinOrderList, pushScenarioType);
} catch (Exception e) {
logger.error("TOC退货-确认收入:getSetTran方法抛出异常", e);
} finally {
@@ -641,9 +662,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
* 库存同步,代码同步逻辑
*
* @param returnGoodHeaderDetailsDataDtoList1 查询得到的O售后入库单对象
+ * @param pushScenarioType 推送阶段场景
* @author liuyang
*/
- private void implementStock(List returnGoodHeaderDetailsDataDtoList1) throws Exception {
+ private void implementStock(List returnGoodHeaderDetailsDataDtoList1, String pushScenarioType) throws Exception {
+ Assert.notNull(pushScenarioType, "pushScenarioType不能为空");
if (returnGoodHeaderDetailsDataDtoList1 != null) {
logger.info("TOC退货业务:{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size());
}
@@ -875,31 +898,36 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity);
}
}
-
- //销售订单单据推送到u8c
-// List saleorderRequestDtoList = new ArrayList<>();
-// saleorderRequestDtoList.add(saleorderRequestDto);
-// Map> stringStringMap = new HashMap<>();
-// stringStringMap.put("saleorder", saleorderRequestDtoList);
-// SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
- String vreceiptcode = null;
- String pk_corp = null;
- String csaleid = null;
-// if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) {
-// vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode();
-// pk_corp = soSaleResultRootDto.getParentvo().getPk_corp();
-// csaleid = soSaleResultRootDto.getParentvo().getCsaleid();
-// }
-// logger.info("TOC销售订单编号:{} 主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp);
- // TODO 临时方案
- vreceiptcode = "暂存";
- csaleid = "暂存";
- updateSuccessOrFail1(oldValue, "S", "暂存", vreceiptcode, csaleid);
- //记录成功
-// updateSuccessOrFail1(oldValue, "Y", "success", vreceiptcode, csaleid);
+ if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
+ //推送u8c
+ List saleorderRequestDtoList = new ArrayList<>();
+ saleorderRequestDtoList.add(saleorderRequestDto);
+ Map> stringStringMap = new HashMap<>();
+ stringStringMap.put("saleorder", saleorderRequestDtoList);
+ SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
+ String vreceiptcode = null;
+ String pk_corp = null;
+ String csaleid = null;
+ if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) {
+ vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode();
+ pk_corp = soSaleResultRootDto.getParentvo().getPk_corp();
+ csaleid = soSaleResultRootDto.getParentvo().getCsaleid();
+ }
+ logger.info("TOC销售订单编号:{} 主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp);
+ updateSuccessOrFail1(oldValue, "Y", "success", vreceiptcode, csaleid);
+ } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) {
+ //选择暂存等待下次发起
+ String vreceiptcode = "暂存";
+ String csaleid = "暂存";
+ String newstate = "S";
+ String newTransmitInfo = "暂存";
+ updateSuccessOrFail1(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid);
+ } else {
+ Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType);
+ }
} catch (Exception e) {
- logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
//记录失败
+ logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
String message = e.getMessage();
if (message == null) {
message = "未知错误";
@@ -913,7 +941,6 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
}
} catch (Exception e) {
logger.error("外层转换逻辑抛出异常", e);
- // 记录失败
}
}
}
@@ -924,7 +951,8 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
* @param returnGoodHeaderDetailsDataDtoList1 查询得到的O售后入库单对象
* @author liuyang
*/
- private void implementTran(List returnGoodHeaderDetailsDataDtoList1) throws Exception {
+ private void implementTran(List returnGoodHeaderDetailsDataDtoList1, String pushScenarioType) throws Exception {
+ Assert.notNull(pushScenarioType, "pushScenarioType不能为空");
if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) {
logger.info("TOC退货业务:{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size());
@@ -1155,28 +1183,33 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
}
}
- //销售订单单据推送到u8c
-// List saleorderRequestDtoList = new ArrayList<>();
-// saleorderRequestDtoList.add(saleorderRequestDto);
-// Map> stringStringMap = new HashMap<>();
-// stringStringMap.put("saleorder", saleorderRequestDtoList);
-// SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
-
- String vreceiptcode = null;
- String pk_corp = null;
- String csaleid = null;
-// if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) {
-// vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode();
-// pk_corp = soSaleResultRootDto.getParentvo().getPk_corp();
-// csaleid = soSaleResultRootDto.getParentvo().getCsaleid();
-// }
-// logger.info("TOC销售订单编号:{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp);
- // TODO 临时方案
- vreceiptcode = "暂存";
- csaleid = "暂存";
- //记录成功
- updateSuccessOrFail2(oldValue, "S", "暂存", vreceiptcode, csaleid);
-// updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid);
+ if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
+ //推送U8C
+ List saleorderRequestDtoList = new ArrayList<>();
+ saleorderRequestDtoList.add(saleorderRequestDto);
+ Map> stringStringMap = new HashMap<>();
+ stringStringMap.put("saleorder", saleorderRequestDtoList);
+ SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
+ String vreceiptcode = null;
+ String pk_corp = null;
+ String csaleid = null;
+ if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) {
+ vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode();
+ pk_corp = soSaleResultRootDto.getParentvo().getPk_corp();
+ csaleid = soSaleResultRootDto.getParentvo().getCsaleid();
+ }
+ logger.info("TOC销售订单编号:{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp);
+ updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid);
+ } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) {
+ //不推送U8C,单据暂存
+ String vreceiptcode = "暂存";
+ String csaleid = "暂存";
+ String newstate = "S";
+ String newTransmitInfo = "暂存";
+ updateSuccessOrFail2(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid);
+ } else {
+ Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType);
+ }
} catch (Exception e) {
logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
//记录失败
@@ -1193,7 +1226,6 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
}
} catch (Exception e) {
logger.error("外层转换逻辑抛出异常", e);
- // 记录失败
}
}
}
@@ -2540,7 +2572,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
*
* @author liuyang
*/
- public void splitDateAndPush(String param, String sceneType) throws Exception {
+ public void splitDateAndPush(String param, String sceneType, String pushScenarioType) throws Exception {
try {
Assert.notNull(param, "param不能为空!");
Assert.state(!"".equals(param), "param不能为空!");
@@ -2548,6 +2580,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
Assert.notNull(sceneType, "sceneType不能为空!");
Assert.state(!"".equals(sceneType), "sceneType不能为空!");
+ Assert.notNull(pushScenarioType, "pushScenarioType不能为空!");
+ Assert.state(!"".equals(pushScenarioType), "pushScenarioType不能为空!");
+
if (param.contains("*")) {
String[] params = param.split("\\*");
if (params.length > 0) {
@@ -2556,9 +2591,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
String[] split = indexStr.split(",");
logger.info("splitDateAndPush方法正在执行主要的逻辑 开始时间:{} 结束时间:{}", split[0], split[1]);
if (sceneType.equals(STOCK)) {
- startImplementStockByTime(split[0], split[1]);
+ startImplementStockByTime(split[0], split[1], pushScenarioType);
} else if (sceneType.equals(TRAN)) {
- startImplementByTradeTime(split[0], split[1]);
+ startImplementByTradeTime(split[0], split[1], pushScenarioType);
}
}
}
@@ -2566,9 +2601,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
String[] split = param.split(",");
logger.info("splitDateAndPush方法正在执行主要的逻辑 开始时间:{} 结束时间:{}", split[0], split[1]);
if (sceneType.equals(STOCK)) {
- startImplementStockByTime(split[0], split[1]);
+ startImplementStockByTime(split[0], split[1], pushScenarioType);
} else if (sceneType.equals(TRAN)) {
- startImplementByTradeTime(split[0], split[1]);
+ startImplementByTradeTime(split[0], split[1], pushScenarioType);
}
}
} catch (Exception e) {
@@ -3014,4 +3049,78 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
calculationFormulaStr.append(format);
return amountOfMoney.stripTrailingZeros().toPlainString();
}
+
+ /**
+ * 查询OFS底表的O售后入库单数据
+ *
+ * @author liuyang
+ */
+ public List queryTocofsReturngoodsDetailed(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity) throws Exception {
+ Assert.notNull(tocofsReturngoodsDetailedEntity, "tocofsReturngoodsDetailedEntity不能为空");
+
+ //底表O售后入库单表头对象
+ List allTocofsReturngoodsEntityList = new ArrayList<>();
+ //底表O售后入库单明细行
+ List tocofsReturngoodsDetailedEntityList = iTocofsReturngoodsDetailedDao.query(tocofsReturngoodsDetailedEntity);
+
+ if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0) {
+ List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityList, 1000);
+ for (int i = 0; i < splitListByCount.size(); i++) {
+ List tocofsReturngoodsDetailedEntityList1 = splitListByCount.get(i);
+ Set mainTableIdSet = tocofsReturngoodsDetailedEntityList1.stream().map(TocofsReturngoodsDetailedEntity::getMaintableid).collect(Collectors.toSet());
+ String mainTableIds = mainTableIdSet.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
+ //查询对应的O售后入库单表头
+ TocofsReturngoodsEntity tocofsReturngoodsEntity = new TocofsReturngoodsEntity();
+ tocofsReturngoodsEntity.setIds(mainTableIds);
+ List tocofsReturngoodsEntityList = iTocofsReturngoodsDao.query(tocofsReturngoodsEntity);
+ allTocofsReturngoodsEntityList.addAll(tocofsReturngoodsEntityList);
+ }
+ }
+
+ //通过「O售后入库单表头」匹配「O售后入库单明细」
+ if (allTocofsReturngoodsEntityList.size() > 0) {
+ for (int i = 0; i < allTocofsReturngoodsEntityList.size(); i++) {
+ TocofsReturngoodsEntity tocofsReturngoodsEntity = allTocofsReturngoodsEntityList.get(i);
+ List tocofsReturngoodsDetailedEntityList1 = new ArrayList<>();
+ for (int j = 0; j < tocofsReturngoodsDetailedEntityList.size(); j++) {
+ TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity1 = tocofsReturngoodsDetailedEntityList.get(j);
+ if (tocofsReturngoodsDetailedEntity.getMaintableid().equals(tocofsReturngoodsEntity.getId())) {
+ tocofsReturngoodsDetailedEntityList1.add(tocofsReturngoodsDetailedEntity1);
+ }
+ }
+ tocofsReturngoodsEntity.setTocofsReturngoodsDetailedEntityList(tocofsReturngoodsDetailedEntityList1);
+ }
+ }
+
+ //转换为OFS售后入库单对象
+ List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>();
+ if (allTocofsReturngoodsEntityList.size() > 0) {
+ for (int i = 0; i < allTocofsReturngoodsEntityList.size(); i++) {
+
+ StockinOrderSearchResponse.StockinOrder stockinOrder = new StockinOrderSearchResponse.StockinOrder();
+ returnGoodHeaderDetailsDataDtoArrayList.add(stockinOrder);
+
+ //处理表头
+ TocofsReturngoodsEntity tocofsReturngoodsEntity = allTocofsReturngoodsEntityList.get(i);
+ StockinOrderSearchResponse.StockinOrder.StockinH stockinH = new StockinOrderSearchResponse.StockinOrder.StockinH();
+ stockinH.setId(tocofsReturngoodsEntity.getId());
+ BeanUtil.copyPropertiesV2(tocofsReturngoodsEntity, stockinH);
+ stockinOrder.setHeader(stockinH);
+
+ //处理明细行
+ List tocofsReturngoodsDetailedEntityList1 = tocofsReturngoodsEntity.getTocofsReturngoodsDetailedEntityList();
+ List stockinB = new ArrayList<>();
+ stockinOrder.setDetails(stockinB);
+ for (int j = 0; j < tocofsReturngoodsDetailedEntityList1.size(); j++) {
+ TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity1 = tocofsReturngoodsDetailedEntityList1.get(j);
+
+ StockinOrderSearchResponse.StockinOrder.StockinB stockinB1 = new StockinOrderSearchResponse.StockinOrder.StockinB();
+ BeanUtil.copyPropertiesV2(tocofsReturngoodsDetailedEntity1, stockinB1);
+ stockinB1.setId(tocofsReturngoodsDetailedEntity1.getId());
+ stockinB.add(stockinB1);
+ }
+ }
+ }
+ return returnGoodHeaderDetailsDataDtoArrayList;
+ }
}
\ No newline at end of file
diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java
index b949e445..00f26b79 100644
--- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java
+++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java
@@ -118,7 +118,7 @@ class SoSaleOutPluginInitializerToCTest {
// soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran");
// String aaa = "LETS-SH2024102800021196";
-// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-12-06 09:25:39", "2024-12-06 09:25:39");
+ soSaleOutPluginInitializerToC.startImplementTranByTime("2024-11-13 11:30:41", "2024-11-13 11:30:41", "0");
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-12-24 21:53:57", "2024-12-24 21:53:57", "2");
} catch (Exception e) {
@@ -129,7 +129,7 @@ class SoSaleOutPluginInitializerToCTest {
try {
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110200030366", "stock");
- soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024121200024676", "tran");
+// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024121200024676", "tran");
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024111700013756", "tran");
} catch (Exception e) {