From a321983610284b954ac356b22377ff03932b77c8 Mon Sep 17 00:00:00 2001 From: liuy <37787198+LiuyCodes@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:55:08 +0800 Subject: [PATCH] =?UTF-8?q?commit=20message:```=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95=E5=8C=B9=E9=85=8D=E4=B8=8E?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在销售订单匹配流程中,启用更有效的订单查询逻辑,并对异常情况进行增强处理。移除不必要的注释,并清理可能导致主键长度异常的代码。此外,引入新的时间参数验证步骤,以确保处理时间范围的有效性。 ``` --- .../sales/SoSaleOutPluginInitializerToB.java | 72 +-- .../SoSaleReturnPluginInitializerToB.java | 3 + .../SoSaleReturnPluginInitializerToC.java | 416 +++++++++++++++--- .../plugin/lets/resultvo/CacheTocMapVoV2.java | 31 ++ .../lets/u8cdto/GoodsRertunSonDetailsDto.java | 15 + .../util/TocReturnBasicArchivesCacheUtil.java | 158 ++++--- .../SoSaleOutPluginInitializerToBTest.java | 6 + .../SoSaleReturnPluginInitializerToCTest.java | 8 +- 8 files changed, 541 insertions(+), 168 deletions(-) create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/lets/resultvo/CacheTocMapVoV2.java diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java index c30e379a..39c931e8 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java @@ -805,8 +805,8 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { // saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 - //TODO 2024年8月30日 10:52:55 抛出异常pk_defxxx长度不够的问题,已经提交给总部 -// saleorderRequestChildrenDto.setVdef19(header.getCode());//原单单号 + //2024年8月30日 10:52:55 抛出异常pk_defxxx长度不够的问题,已经提交给总部 + saleorderRequestChildrenDto.setVdef19(header.getCode());//原单单号 saleorderRequestChildrenDto.setVdef20(detailsDto.getId());//原单明细主键 saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); } @@ -2445,40 +2445,40 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { * * @param headerDetailsDtoList OFS销售出库单 */ - private List queryOfsOrder(List headerDetailsDtoList) throws Exception { - List allHeaderDetailsDtoArrayList = new ArrayList<>(); - try { - if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100); - for (int i = 0; i < splitListByCount.size(); i++) { - List headerDetailsDtos = splitListByCount.get(i); - - StringBuffer stringBuffer = new StringBuffer(); - if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) { - for (int j = 0; j < headerDetailsDtos.size(); j++) { - HeaderDetailsDto headerDetailsDto = headerDetailsDtos.get(j); - HeaderDto header = headerDetailsDto.getHeader(); -// List details = headerDetailsDto.getDetails(); -// stringBuffer.append("'"); - stringBuffer.append(header.getRefOrderCode()); -// stringBuffer.append("'"); - stringBuffer.append(","); - } - } - String substring = stringBuffer.substring(0, stringBuffer.length()); - - List headerDetailsDtoArrayList = new ArrayList<>(); - QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setCode(substring); - ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); - allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList); - } - } - } catch (Exception e) { - logger.error("queryOfsOrder方法抛出异常", e); - } - return allHeaderDetailsDtoArrayList; - } +// private List queryOfsOrder(List headerDetailsDtoList) throws Exception { +// List allHeaderDetailsDtoArrayList = new ArrayList<>(); +// try { +// if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { +// List> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100); +// for (int i = 0; i < splitListByCount.size(); i++) { +// List headerDetailsDtos = splitListByCount.get(i); +// +// StringBuffer stringBuffer = new StringBuffer(); +// if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) { +// for (int j = 0; j < headerDetailsDtos.size(); j++) { +// HeaderDetailsDto headerDetailsDto = headerDetailsDtos.get(j); +// HeaderDto header = headerDetailsDto.getHeader(); +//// List details = headerDetailsDto.getDetails(); +//// stringBuffer.append("'"); +// stringBuffer.append(header.getRefOrderCode()); +//// stringBuffer.append("'"); +// stringBuffer.append(","); +// } +// } +// String substring = stringBuffer.substring(0, stringBuffer.length()); +// +// List headerDetailsDtoArrayList = new ArrayList<>(); +// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); +// queryOfsSoSaleOutVo.setCode(substring); +// ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); +// allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList); +// } +// } +// } catch (Exception e) { +// logger.error("queryOfsOrder方法抛出异常", e); +// } +// return allHeaderDetailsDtoArrayList; +// } /** * 代码匹配销售订单 diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java index a77c1bd2..c3028643 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java @@ -272,6 +272,9 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { @Override public void run() { try { + Assert.notNull(startTime, "startTime不能为空"); + Assert.notNull(endTime, "end不能为空"); + //生成一个时间范围 // StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime(); //2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性 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 d67d0a05..ae03d59e 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 @@ -17,6 +17,7 @@ import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity; import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; +import com.hzya.frame.plugin.lets.resultvo.CacheTocMapVoV2; import com.hzya.frame.plugin.lets.resultvo.CalculateDateVo; import com.hzya.frame.plugin.lets.u8cdto.*; import com.hzya.frame.plugin.lets.util.*; @@ -29,6 +30,7 @@ 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.JsonResultEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -118,26 +120,30 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { private RdclUtil rdclUtil; /** - * 按指定时间拉取 + * 根据指定时间范围拉群 * * @author liuyang */ - public void startImplement(String dateStr, String summaryOrderNumber) { - String threadNameStr = StrUtil.format("OFS销售出库(TOC)同步U8C销售订单 同步日期:{} 汇总维度:{}", dateStr, summaryOrderNumber); - logger.info(threadNameStr); + public void startImplementStockByTime(String startTime, String endTime) { + long startMillis = System.currentTimeMillis(); + String threadNameStrStart = StrUtil.format("开始-OFS销售出库(TOC)同步U8C销售订单 开始时间:{} 结束时间:{}", startTime, endTime); + logger.info(threadNameStrStart); Thread thread = new Thread(new Runnable() { @Override public void run() { LOCK.lock(); try { + Assert.notNull(startTime, "开始时间不能为空"); + Assert.notNull(endTime, "结束时间不能为空"); + String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); - CalculateDateVo calculateDateVo = DateStrUtil.calculateCalculateEntireDayPeriod(dateStr); +// CalculateDateVo calculateDateVo = DateStrUtil.calculateCalculateEntireDayPeriod(dateStr); List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setCreated_start(calculateDateVo.getStart_time()); - queryOfsSoSaleOutVo.setCreated_end(calculateDateVo.getEnd_time()); + queryOfsSoSaleOutVo.setCreated_start(startTime); + queryOfsSoSaleOutVo.setCreated_end(endTime); queryOfsSoSaleOutVo.setClientCode("LETS"); queryOfsSoSaleOutVo.setInternalInstructionType("SALES"); //2024年8月22日 14:02:13 已经和O确认,这个字段取消传递! @@ -149,38 +155,43 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); // queryOfsSoSaleOutVo.setCode("LETS-RE2024071600000001"); ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search"); - logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); + logger.info("TOC退货数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - getSet(returnGoodHeaderDetailsDataDtoArrayList); + getSetStock(returnGoodHeaderDetailsDataDtoArrayList); } else { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { logger.error("startImplement方法抛出异常", e); } finally { - try { - tocReturnBasicArchivesCacheUtil.clearCache(); - } catch (Exception e) { - logger.info("清理档案缓存失败", e); - } +// try { +// tocReturnBasicArchivesCacheUtil.clearCache(); +// } catch (Exception e) { +// logger.info("清理档案缓存失败", e); +// } LOCK.unlock(); } } - }, threadNameStr); + }, threadNameStrStart); thread.start(); try { thread.join(); } catch (Exception e) { logger.error("thread.join()异常", e); } + long endMillis = System.currentTimeMillis(); + String threadNameStrEnd = StrUtil.format("结束-OFS销售出库(TOC)同步U8C销售订单 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); + logger.info(threadNameStrEnd); } /** * 按指定时间拉取 * + * @param code 编码 + * @param sceneType 场景类型 * @author liuyang */ - public void startImplement(String code) { + public void startImplementByCode(String code, String sceneType) { String threadNameStr = StrUtil.format("OFS销售出库(TOC)同步U8C销售订单 同步单据号:{}", code); logger.info(threadNameStr); @@ -204,18 +215,18 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoList, 1L, "ofs.receipt.search"); logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoList.size()); if (returnGoodHeaderDetailsDataDtoList.size() > 0) { - getSet(returnGoodHeaderDetailsDataDtoList); + getSetStock(returnGoodHeaderDetailsDataDtoList); } else { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { logger.error("startImplement方法抛出异常", e); } finally { - try { - tocReturnBasicArchivesCacheUtil.clearCache(); - } catch (Exception e) { - logger.info("清理档案缓存失败", e); - } +// try { +// tocReturnBasicArchivesCacheUtil.clearCache(); +// } catch (Exception e) { +// logger.info("清理档案缓存失败", e); +// } LOCK.unlock(); } } @@ -228,18 +239,87 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { } } + /** + * 库存同步,按指定时间拉取 + * + * @author liuyang + */ + public void startImplementByTradeTime(String startTime, String endTime) { + long startMillis = System.currentTimeMillis(); + String threadNameStrStart = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{}", startTime, endTime); + logger.info(threadNameStrStart); + + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + 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"); +// queryOfsSoSaleOutVo.setCode("LETS-RE2024081900000001"); + ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search"); + logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); + if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { + getSetTran(returnGoodHeaderDetailsDataDtoArrayList); + } else { + logger.info("没有查询到任何数据!不需要同步"); + } + } catch (Exception e) { + logger.error("startImplement方法抛出异常", e); + } + } + }, threadNameStrStart); + thread.start(); + try { + thread.join(); + } catch (Exception e) { + logger.error("thread.join()异常", e); + } + long endMillis = System.currentTimeMillis(); + String threadNameStrEnd = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); + logger.info(threadNameStrEnd); + } + /** * 预备执行逻辑 * * @author liuyang */ - private void getSet(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { + private void getSetStock(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { //保存到mysql batchInsert(returnGoodHeaderDetailsDataDtoArrayList); //过滤成功的数据 - List stockinOrderList = filterData(returnGoodHeaderDetailsDataDtoArrayList); + List stockinOrderList = filterDataStock(returnGoodHeaderDetailsDataDtoArrayList); //执行推送主逻辑 - implement(stockinOrderList); + implementStock(stockinOrderList); + } + + /** + * 预备执行逻辑 + * + * @author liuyang + */ + private void getSetTran(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { + //保存到mysql + batchInsert(returnGoodHeaderDetailsDataDtoArrayList); + //过滤成功的数据 + List stockinOrderList = filterDataStock(returnGoodHeaderDetailsDataDtoArrayList); + //执行推送主逻辑 + implementTran(stockinOrderList); } /** @@ -247,7 +327,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private List filterData(List returnGoodHeaderDetailsDataDtoArrayList) { + private List filterDataStock(List returnGoodHeaderDetailsDataDtoArrayList) { List headerDetailsDtoList1 = new ArrayList<>(); if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { //TODO 出库单明细主键,需要O返回,目前没有,已经提需求 @@ -360,17 +440,17 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { // } /** - * 代码同步逻辑 + * 库存同步,代码同步逻辑 * * @param returnGoodHeaderDetailsDataDtoList1 查询得到的O售后入库单对象 * @author liuyang */ - private void implement(List returnGoodHeaderDetailsDataDtoList1) throws Exception { + private void implementStock(List returnGoodHeaderDetailsDataDtoList1) throws Exception { logger.info("TOC退货业务:{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size()); if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { try { // 查询基本档案 - List goodsRertunSonDetailsDtos = queryBasicArchives(returnGoodHeaderDetailsDataDtoList1); + List goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1); // 分组汇总 Map> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos); // 查询U8C业务流程 @@ -401,7 +481,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { BdRdclEntity bdRdclEntity = oldValue.get(0).getBdRdclEntity();//U8C收发类别 try { - checkArchives(oldValue.get(0)); +// checkArchives(oldValue.get(0)); //生成业务日期 String generateBusinessDate = createGenerateBusinessDate(header); @@ -446,11 +526,173 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //把汇总好的出库单明细行合并成一行 GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue); //存货管理档案:取发货公司的存货管理档案 - BdInvmandocEntity bdInvmandocEntity = queryInventoryMan(goodsRertunSonDetailsDto, bdCalbodyEntity.getPkCorp()); + BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); //存货基础档案 - BdInvbasdocEntity bdInvbasdocEntity = queryStockBasicArchives(bdInvmandocEntity.getPkInvmandoc(), deliverGoodsCorp.getPkCorp()); + BdInvbasdocEntity bdInvbasdocEntity = oldValue.get(0).getBdInvbasdocEntity(); //根据存货基础档案编码,查询当前存货的税率 - BdTaxitemsEntity bdTaxitemsEntity1 = queryBdTaxitems(bdInvbasdocEntity.getInvcode()); + BdTaxitemsEntity bdTaxitemsEntity1 = oldValue.get(0).getBdTaxitemsEntity(); + + String tax = "0." + new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString(); + BigDecimal noriginalcurprice = null;//无税单价 + BigDecimal noriginalcurmny = null;//无税金额 + BigDecimal noriginalcurtaxprice = null;//含税单价 + BigDecimal noriginalcursummny = null;//价税合计 + BigDecimal noriginalcurtaxmny = null;//税额=价税合计-无税金额 + try { + noriginalcurtaxprice = goodsRertunSonDetailsDto.getGroupTotalPayAmount().divide(goodsRertunSonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); + noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); + noriginalcurmny = noriginalcurprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcursummny = noriginalcurtaxprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcurtaxmny = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP); + } catch (Exception e) { + logger.error("TOC金额计算错误", e); + Assert.state(false, "U8C红字销售订单,金额计算错误,原因:{}", e.getMessage()); + } + + //判断是否为赠品 + Boolean isblargessflag = false; + if (noriginalcursummny.longValue() == 0) { + isblargessflag = true; + } + + SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto(); + saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品 + saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 + saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 + saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 + saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种 + saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id + saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 + saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期 + saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);// 要求收货日期 + saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率 + saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣 + saleorderRequestChildrenDto.setNnumber("-" + goodsRertunSonDetailsDto.getGroupShipQty().stripTrailingZeros().toPlainString());//数量 + saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额 + saleorderRequestChildrenDto.setNoriginalcurmny("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额 +// saleorderRequestChildrenDto.setNoriginalcurnetprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税净价 +// saleorderRequestChildrenDto.setNoriginalcurprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税单价 + saleorderRequestChildrenDto.setNoriginalcursummny("-" + noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计 + saleorderRequestChildrenDto.setNoriginalcurtaxmny("-" + noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额 + saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 + saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 + saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 + saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); + + //销售订单单据推送到u8c + List saleorderRequestDtoList = new ArrayList<>(); + saleorderRequestDtoList.add(saleorderRequestDto); + Map> stringStringMap = new HashMap<>(); + stringStringMap.put("saleorder", saleorderRequestDtoList); + SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); + logger.info("TOC销售订单编号:{} 销售公司:{}", soSaleResultRootDto.getParentvo().getVreceiptcode(), soSaleResultRootDto.getParentvo().getPk_corp()); + //记录成功 + } catch (Exception e) { + logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e); + //记录失败 + } + } + } else { + //2024年8月6日 11:28:54此处不记录失败,不认为是错误 + logger.info("summaryDimensionMap变量或者bdBusitypeEntity变量为空,因此主要的推送逻辑不会被执行!"); + } + } catch (Exception e) { + logger.error("外层转换逻辑抛出异常", e); + // 记录失败 + } + } + } + + /** + * 到账成功:代码同步逻辑 + * + * @param returnGoodHeaderDetailsDataDtoList1 查询得到的O售后入库单对象 + * @author liuyang + */ + private void implementTran(List returnGoodHeaderDetailsDataDtoList1) throws Exception { + logger.info("TOC退货业务:{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size()); + if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { + try { + // 查询基本档案 + List goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1); + // 分组汇总 + Map> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos); + // 查询U8C业务流程 + BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2(); + + if (bdBusitypeEntity != null && summaryDimensionMap != null) { + Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry> entry = iterator.next(); + String keyGroup = entry.getKey(); + List oldValue = entry.getValue(); + + StockinOrderSearchResponse.StockinOrder.StockinH header = oldValue.get(0).getHeader(); + BdCorpEntity bdCorpEntity = oldValue.get(0).getBdCorpEntity();//表头销售公司 + BdCorpEntity deliverGoodsCorp = oldValue.get(0).getDeliverGoodsCorp();//发货公司 + BdCalbodyEntity bdCalbodyEntity = oldValue.get(0).getBdCalbodyEntity();//发货仓库组织 + BdStordocEntity bdStordocEntity = oldValue.get(0).getBdStordocEntity();//发货仓库 + BdCalbodyEntity bdCalbodyEntity1 = oldValue.get(0).getBdCalbodyEntity1();//收货库存组织 + BdStordocEntity bdStordocEntity1 = oldValue.get(0).getBdStordocEntity1();//收货仓库 + BdSalestruEntity bdSalestruEntity = oldValue.get(0).getBdSalestruEntity();//销售组织 + BdDeptdocEntity bdDeptdocEntity = oldValue.get(0).getBdDeptdocEntity();//业务部门 + BdCumandocEntity bdCumandocEntity = oldValue.get(0).getBdCumandocEntity();//客商管理档案 + BdCubasdocEntity bdCubasdocEntity = oldValue.get(0).getBdCubasdocEntity();//客商基本档案 + BdDefdocEntity platformArchives = oldValue.get(0).getPlatformArchives();//U8C平台档案 + BdDefdocEntity shopArchives = oldValue.get(0).getShopArchives();//U8C店铺档案 + BdRdclEntity bdRdclEntity = oldValue.get(0).getBdRdclEntity();//U8C收发类别 + + try { +// checkArchives(oldValue.get(0)); + //生成业务日期 + String generateBusinessDate = createGenerateBusinessDate(header); + + SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto(); + SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto(); + saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期 + saleorderRequestParentDto.setBretinvflag("Y");//退货标记 + saleorderRequestParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype());//业务流程 + saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织 + saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位 + saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门 + saleorderRequestParentDto.setCemployeeid(null);//业务员 + saleorderRequestParentDto.setCoperatorid(OverallConstant.getOverAllValue("u8cApiZdrPK"));//制单人 + saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位 + saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位 + saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织 + saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库 + saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期 + saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣 + saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id + //汇总单号=汇总维度 + saleorderRequestParentDto.setVdef18(keyGroup); + //平台 + saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc()); + saleorderRequestParentDto.setVdef2(platformArchives.getDocname()); + saleorderRequestParentDto.setVdef17(ProfilesActiveConstant.sourceSystem1);//来源系统 + + //收发类别 + saleorderRequestParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl()); + saleorderRequestParentDto.setVdef3(bdRdclEntity.getRdname()); + + //2024年8月8日 17:17:58 店铺档案自定义项1,先不传,后续维护好之后再传! + //店铺 + saleorderRequestParentDto.setPk_defdoc1(shopArchives.getPkDefdoc()); + saleorderRequestParentDto.setVdef1(shopArchives.getDocname()); + + saleorderRequestDto.setParentvo(saleorderRequestParentDto); + + List saleorderRequestChildrenDtoList = new ArrayList<>(); + saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList); + + //把汇总好的出库单明细行合并成一行 + GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue); + //存货管理档案:取发货公司的存货管理档案 + BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); + //存货基础档案 + BdInvbasdocEntity bdInvbasdocEntity = oldValue.get(0).getBdInvbasdocEntity(); + //根据存货基础档案编码,查询当前存货的税率 + BdTaxitemsEntity bdTaxitemsEntity1 = oldValue.get(0).getBdTaxitemsEntity(); String tax = "0." + new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString(); BigDecimal noriginalcurprice = null;//无税单价 @@ -555,13 +797,13 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单对象 * @author liuyang */ - private List queryBasicArchives(List returnGoodHeaderDetailsDataDtoList1) { + private List queryBasicArchivesStock(List returnGoodHeaderDetailsDataDtoList1) { List sonDetailsDtoList = new ArrayList<>(); if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { try { //初始化档案缓存 - tocReturnBasicArchivesCacheUtil.initCache(); + CacheTocMapVoV2 cacheTocMapVoV2 = tocReturnBasicArchivesCacheUtil.initCache(); //查询OFS售后入库单对应的售后订单 List rerturnGoodsOrderSearchData = queryBatchAfterSalesOrder(returnGoodHeaderDetailsDataDtoList1); findAfterSalesOrder(rerturnGoodsOrderSearchData, returnGoodHeaderDetailsDataDtoList1); @@ -587,17 +829,17 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { if (header1.getSubOrderType() == null || "".equals(header1.getSubOrderType())) { header1.setSubOrderType("SALES"); } - BdRdclEntity bdRdclEntity = TocReturnBasicArchivesCacheUtil.stringBdRdclEntityHashMap.get(header1.getSubOrderType()); + BdRdclEntity bdRdclEntity = cacheTocMapVoV2.getStringBdRdclEntityMap().get(header1.getSubOrderType()); Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header1.getSubOrderType()); //表头公司:通过名称匹配U8C公司 // String corpName = "上海丽知品牌管理有限公司"; Assert.notNull(header.getCompanyCode(), "O货主编码不能为空"); - BdCorpEntity bdCorpEntity = TocReturnBasicArchivesCacheUtil.stringBdCorpEntityMap.get(header.getCompanyCode()); + BdCorpEntity bdCorpEntity = cacheTocMapVoV2.getStringBdCorpEntityMap().get(header.getCompanyCode()); Assert.notNull(bdCorpEntity, "根据O公司编码(货主编码)({})没有匹配到U8C公司档案", header.getCompanyCode()); //发货库存组织 - BdCalbodyEntity bdCalbodyEntity = TocReturnBasicArchivesCacheUtil.stringBdCalbodyEntityMap.get(bdCorpEntity.getPkCorp()); + BdCalbodyEntity bdCalbodyEntity = cacheTocMapVoV2.getStringBdCalbodyEntityMap().get(bdCorpEntity.getPkCorp()); Assert.notNull(bdCalbodyEntity, "根据公司主键没有查询到发货库存组织 公司主键:{}", bdCorpEntity.getPkCorp()); //发货公司,暂时把O表头公司作为发货公司,正常情况下需要把O库存地点对于的公司作为发货公司 @@ -606,7 +848,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //2024年8月5日 15:06:38 仓库O与U两边仓库编码是一致的,和妮姐确认过了 String facilityCode = header.getFacilityCode(); Assert.notNull(facilityCode, "O仓库编码不能为空"); - BdStordocEntity bdStordocEntity = TocReturnBasicArchivesCacheUtil.stringBdStordocEntityMap.get(facilityCode + bdCalbodyEntity.getPkCalbody()); + BdStordocEntity bdStordocEntity = cacheTocMapVoV2.getStringBdStordocEntityMap().get(facilityCode + bdCalbodyEntity.getPkCalbody()); Assert.notNull(bdStordocEntity, "没有匹配到发货仓库 发货库存组织主键:{} O库存地点编码:{}", facilityCode, bdCalbodyEntity.getPkCalbody()); //2024年8月5日 15:25:07 收货库存组织、收货仓库、默认和发货库存组织、发货仓库一致,已经和佳妮确认 @@ -614,41 +856,54 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //收货仓库:通过收货库存组织+仓库编码,确定收货仓库 //销售组织2024年8月5日 15:33:40 和妮姐确认,销售组织和表头公司,作为一对一的关系, - BdSalestruEntity bdSalestruEntity = TocReturnBasicArchivesCacheUtil.stringBdSalestruEntityMap.get(bdCorpEntity.getUnitname()); + BdSalestruEntity bdSalestruEntity = cacheTocMapVoV2.getStringBdSalestruEntityMap().get(bdCorpEntity.getUnitname()); Assert.notNull(bdSalestruEntity, "无匹配到销售组织 表头公司名称:{}", bdCorpEntity.getUnitname()); //业务部门:暂定的部门名称:其他,2024年8月5日 15:39:42 已经和妮姐确认 - BdDeptdocEntity bdDeptdocEntity = TocReturnBasicArchivesCacheUtil.stringBdDeptdocEntityMap.get(bdCorpEntity.getPkCorp()); + BdDeptdocEntity bdDeptdocEntity = cacheTocMapVoV2.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:其他 对应公司名称:{}", bdCorpEntity.getPkCorp()); //客商基本档案 - //TODO 2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1,O没有店铺信息查询接口,因此无法通过出库单的店铺编码,查询到O店铺档案对应的业务编码,接口上线之后需要补充这一部分逻辑 - String custName = "天猫intoyou旗舰店-自营"; - BdCubasdocEntity bdCubasdocEntity = TocReturnBasicArchivesCacheUtil.stringBdCubasdocEntityHashMap.get(custName); - Assert.notNull(bdCubasdocEntity, "无法匹配到客户档案 客商名称:{}", custName); + //2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1,O没有店铺信息查询接口,因此无法通过出库单的店铺编码,查询到O店铺档案对应的业务编码,接口上线之后需要补充这一部分逻辑 +// String custName = "天猫intoyou旗舰店-自营"; + String storeCode = header.getStoreCode(); + Assert.notNull(storeCode, "O店铺编码不能为空,没有办法完成业务逻辑!"); + Assert.state(!"".equals(storeCode.trim()), "O店铺编码不能为空,没有办法完成业务逻辑!"); + BdCubasdocEntity bdCubasdocEntity = cacheTocMapVoV2.getStringBdCubasdocEntityMap().get(storeCode); + Assert.notNull(bdCubasdocEntity, "无法匹配到客户档案 客商名称:{}", storeCode); //客商管理档案:2024年8月5日 15:41:54 TOC店铺名称查询U8C客商档案,已经和妮姐确认 //2024年8月5日 15:49:49 先根据O店铺编码,得到店铺档案信息,取到名称,通过U8C接口查询出来 //目前O店铺信息查询接口还没有,等待开发,所以我这里先写所一个名字 - BdCumandocEntity bdCumandocEntity = TocReturnBasicArchivesCacheUtil.stringBdCumandocEntityMap.get(bdCubasdocEntity.getPkCubasdoc() + bdCorpEntity.getPkCorp()); + BdCumandocEntity bdCumandocEntity = cacheTocMapVoV2.getStringBdCumandocEntityMap().get(bdCubasdocEntity.getPkCubasdoc() + bdCorpEntity.getPkCorp()); Assert.notNull(bdCumandocEntity, "无法匹配到客商档案 店铺名称:{}", "天猫intoyou旗舰店-自营"); //查找平台 String sourcePlatformCode = header.getSourcePlatformCode(); Assert.notNull(sourcePlatformCode, "O平台编码不能为空!"); - BdDefdocEntity bdDefdocEntity = TocReturnBasicArchivesCacheUtil.stringBdDefdocEntityHashMap.get(sourcePlatformCode); + BdDefdocEntity bdDefdocEntity = cacheTocMapVoV2.getStringBdDefdocEntityMap().get(sourcePlatformCode); Assert.notNull(bdDefdocEntity, "根据O平台编码({})无法匹配到U8C平台档案", header.getSourcePlatformCode()); //查找店铺 - String storeCode = header.getStoreCode(); - Assert.notNull(storeCode, "O店铺编码不能为空!"); - BdDefdocEntity bdDefdocEntity1 = TocReturnBasicArchivesCacheUtil.shopDefdocEntityHashMap.get(storeCode); +// String storeCode2 = header.getStoreCode(); +// Assert.notNull(storeCode2, "O店铺编码不能为空!"); + BdDefdocEntity bdDefdocEntity1 = cacheTocMapVoV2.getStringBdDefdocEntityMap1().get(storeCode); Assert.notNull(bdDefdocEntity1, "根据O店铺编码({})无法匹配到U8C店铺档案", storeCode); //字段拷贝 for (int j = 0; j < details.size(); j++) { StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); + //存货管理档案,是发货公司的存货档案 + BdInvmandocEntity bdInvmandocEntity = cacheTocMapVoV2.getStringBdInvmandocEntityMap().get(stockinB.getSkuCode() + bdCorpEntity.getPkCorp()); + Assert.notNull(bdInvmandocEntity, "无法匹配到存货管理档案 货品sku:{} 公司:{}", stockinB.getSkuCode(), bdCorpEntity.getPkCorp()); + //存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity = cacheTocMapVoV2.getStringBdInvbasdocEntityMap().get(bdInvmandocEntity.getPkInvmandoc() + bdCorpEntity.getPkCorp()); + Assert.notNull(bdInvbasdocEntity, "无法匹配到存货基本档案 存货管理主键:{} 公司:{}", bdInvmandocEntity.getPkInvmandoc(), bdCorpEntity.getPkCorp()); + //存货税率 + BdTaxitemsEntity bdTaxitemsEntity = cacheTocMapVoV2.getStringBdTaxitemsEntityMap().get(bdInvmandocEntity.getInvcode()); + Assert.notNull(bdTaxitemsEntity, "无法匹配到存货税率 存货编码:{}", bdInvmandocEntity.getInvcode()); + //2024年8月6日 10:16:22 通过O出库单的表头,查询得出U8C档案,放在表体的原因是方便分组汇总 //下一个步骤的分组汇总,是通过表体明细完成的 GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = new GoodsRertunSonDetailsDto(); @@ -666,6 +921,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { goodsRertunSonDetailsDto.setPlatformArchives(bdDefdocEntity); goodsRertunSonDetailsDto.setBdRdclEntity(bdRdclEntity); goodsRertunSonDetailsDto.setShopArchives(bdDefdocEntity1); + goodsRertunSonDetailsDto.setBdInvmandocEntity(bdInvmandocEntity); + goodsRertunSonDetailsDto.setBdInvbasdocEntity(bdInvbasdocEntity); + goodsRertunSonDetailsDto.setBdTaxitemsEntity(bdTaxitemsEntity); BeanUtil.copyPropertiesV2(stockinB, goodsRertunSonDetailsDto); sonDetailsDtoList.add(goodsRertunSonDetailsDto); @@ -820,6 +1078,20 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { return bdBusitypeEntity; } + /** + * 2024年8月6日 10:59:03 查询U8C业务流程 + * + * @author liuyang + */ + private BdBusitypeEntity u8cOperationFlowV2() throws Exception { + //查询业务流程 + //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 + String processName = "TOC售后完成"; + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); + Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); + return bdBusitypeEntity; + } + /** * 检查参数是否为空 * 2024年8月6日 11:40:19 保险的做法,最好还是验证一下 @@ -846,15 +1118,15 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * @param goodsRertunSonDetailsDto 出库单存货明细行 * @author liuyang */ - private BdInvmandocEntity queryInventoryMan(GoodsRertunSonDetailsDto goodsRertunSonDetailsDto, String pkCorp) { - Assert.notNull(goodsRertunSonDetailsDto, "sonDetailsDto不能为空"); - Assert.notNull(goodsRertunSonDetailsDto.getSkuCode(), "O存货商家编码不能为空"); - Assert.notNull(pkCorp, "发货公司主键不能为空"); - - BdInvmandocEntity bdInvmandocEntity = TocReturnBasicArchivesCacheUtil.stringBdInvmandocEntityMap.get(goodsRertunSonDetailsDto.getSkuCode() + pkCorp); - Assert.notNull(bdInvmandocEntity, "无法匹配到存货管理档案 存货商家编码:{} 存货发货公司:{}", goodsRertunSonDetailsDto.getSkuCode(), pkCorp); - return bdInvmandocEntity; - } +// private BdInvmandocEntity queryInventoryMan(GoodsRertunSonDetailsDto goodsRertunSonDetailsDto, String pkCorp) { +// Assert.notNull(goodsRertunSonDetailsDto, "sonDetailsDto不能为空"); +// Assert.notNull(goodsRertunSonDetailsDto.getSkuCode(), "O存货商家编码不能为空"); +// Assert.notNull(pkCorp, "发货公司主键不能为空"); +// +// BdInvmandocEntity bdInvmandocEntity = TocReturnBasicArchivesCacheUtil.stringBdInvmandocEntityMap.get(goodsRertunSonDetailsDto.getSkuCode() + pkCorp); +// Assert.notNull(bdInvmandocEntity, "无法匹配到存货管理档案 存货商家编码:{} 存货发货公司:{}", goodsRertunSonDetailsDto.getSkuCode(), pkCorp); +// return bdInvmandocEntity; +// } /** * 合并明细行 @@ -902,13 +1174,13 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private BdInvbasdocEntity queryStockBasicArchives(String pkInvmandoc, String pkCorp) { - Assert.notNull(pkInvmandoc, "存货管理档案不能为空"); - Assert.notNull(pkCorp, "公司档案不能为空"); - BdInvbasdocEntity bdInvbasdocEntity = TocReturnBasicArchivesCacheUtil.stringBdInvbasdocEntityHashMap.get(pkInvmandoc + pkCorp); - Assert.notNull(bdInvbasdocEntity, "根据公司主键:{} 和存货管理档案主键:{} 没有查询到存货基本档案", pkCorp, pkInvmandoc); - return bdInvbasdocEntity; - } +// private BdInvbasdocEntity queryStockBasicArchives(String pkInvmandoc, String pkCorp) { +// Assert.notNull(pkInvmandoc, "存货管理档案不能为空"); +// Assert.notNull(pkCorp, "公司档案不能为空"); +// BdInvbasdocEntity bdInvbasdocEntity = TocReturnBasicArchivesCacheUtil.stringBdInvbasdocEntityHashMap.get(pkInvmandoc + pkCorp); +// Assert.notNull(bdInvbasdocEntity, "根据公司主键:{} 和存货管理档案主键:{} 没有查询到存货基本档案", pkCorp, pkInvmandoc); +// return bdInvbasdocEntity; +// } /** * 2024年8月7日 14:58:34 @@ -916,12 +1188,12 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private BdTaxitemsEntity queryBdTaxitems(String invcode) { - Assert.notNull(invcode, "存货编码不能为空"); - BdTaxitemsEntity bdTaxitemsEntity = TocReturnBasicArchivesCacheUtil.stringBdTaxitemsEntityHashMap.get(invcode); - Assert.notNull(bdTaxitemsEntity, "根据存货编码({}),无法匹配到税率!", invcode); - return bdTaxitemsEntity; - } +// private BdTaxitemsEntity queryBdTaxitems(String invcode) { +// Assert.notNull(invcode, "存货编码不能为空"); +// BdTaxitemsEntity bdTaxitemsEntity = TocReturnBasicArchivesCacheUtil.stringBdTaxitemsEntityHashMap.get(invcode); +// Assert.notNull(bdTaxitemsEntity, "根据存货编码({}),无法匹配到税率!", invcode); +// return bdTaxitemsEntity; +// } /** * 2024年8月8日 10:54:48 diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/resultvo/CacheTocMapVoV2.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/resultvo/CacheTocMapVoV2.java new file mode 100644 index 00000000..933e7802 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/resultvo/CacheTocMapVoV2.java @@ -0,0 +1,31 @@ +package com.hzya.frame.plugin.lets.resultvo; + +import com.hzya.frame.plugin.lets.entity.*; +import lombok.Data; + +import java.util.Map; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.resultvo + * @Project:kangarooDataCenterV3 + * @name:CacheMapVo + * @Date:2024/9/4 13:35 + * @Filename:CacheMapVo + */ +@Data +public class CacheTocMapVoV2 { + private Map stringBdCorpEntityMap; + private Map stringBdStordocEntityMap; + private Map stringBdCalbodyEntityMap; + private Map stringBdSalestruEntityMap; + private Map stringBdDeptdocEntityMap; + private Map stringBdCubasdocEntityMap; + private Map stringBdCumandocEntityMap; + private Map stringBdInvmandocEntityMap; + private Map stringBdInvbasdocEntityMap; + private Map stringBdTaxitemsEntityMap; + private Map stringBdDefdocEntityMap;//平台 + private Map stringBdDefdocEntityMap1;//店铺 + private Map stringBdRdclEntityMap; +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/GoodsRertunSonDetailsDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/GoodsRertunSonDetailsDto.java index f78aff0c..37e8d399 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/GoodsRertunSonDetailsDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/GoodsRertunSonDetailsDto.java @@ -104,4 +104,19 @@ public class GoodsRertunSonDetailsDto extends StockinOrderSearchResponse.Stockin * OFS收发类别 */ private BdRdclEntity bdRdclEntity; + + /** + * 存货管理档案 + */ + private BdInvmandocEntity bdInvmandocEntity; + + /** + * 存货基本档案 + */ + private BdInvbasdocEntity bdInvbasdocEntity; + + /** + * 存货税率 + */ + private BdTaxitemsEntity bdTaxitemsEntity; } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocReturnBasicArchivesCacheUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocReturnBasicArchivesCacheUtil.java index 383c1f47..2987f6b2 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocReturnBasicArchivesCacheUtil.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocReturnBasicArchivesCacheUtil.java @@ -2,6 +2,7 @@ package com.hzya.frame.plugin.lets.util; import com.hzya.frame.plugin.lets.dao.*; import com.hzya.frame.plugin.lets.entity.*; +import com.hzya.frame.plugin.lets.resultvo.CacheTocMapVoV2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -58,13 +59,14 @@ public class TocReturnBasicArchivesCacheUtil { @Autowired private IBdRdclDao iBdRdclDao; +// public static Map stringBdCorpEntityMap = new HashMap<>(); + /** * 初始化公司档案-表头公司 * 2024年7月31日 11:16:23 */ - public static Map stringBdCorpEntityMap = new HashMap<>(); - - private void initShop() throws Exception { + private Map initShop() throws Exception { + Map stringBdCorpEntityMap = new HashMap<>(); BdCorpEntity bdCorpEntity = new BdCorpEntity(); bdCorpEntity.setDr(0); bdCorpEntity.setDataSourceCode("lets_u8c"); @@ -75,16 +77,18 @@ public class TocReturnBasicArchivesCacheUtil { stringBdCorpEntityMap.put(bdCorpEntity1.getUnitcode(), bdCorpEntity1); } } + return stringBdCorpEntityMap; } + // public static Map stringBdStordocEntityMap = new HashMap<>(); + /** * 初始化发货仓库 * 2024年7月31日 11:16:27 * 202403011513:仓库根据仓库编码+库存组织编码去查询,之前是仓库编码+公司主键,和李佳妮确认好了 */ - public static Map stringBdStordocEntityMap = new HashMap<>(); - - private void initBdStordoc() throws Exception { + private Map initBdStordoc() throws Exception { + Map stringBdStordocEntityMap = new HashMap<>(); BdStordocEntity bdStordocEntity = new BdStordocEntity(); bdStordocEntity.setDr(0L); bdStordocEntity.setDataSourceCode("lets_u8c"); @@ -95,14 +99,15 @@ public class TocReturnBasicArchivesCacheUtil { stringBdStordocEntityMap.put(bdStordocEntity1.getStorcode() + bdStordocEntity1.getPkCalbody(), bdStordocEntity1); } } + return stringBdStordocEntityMap; } /** * 2024年7月31日 11:09:12 查询发货库存组织 */ - public static Map stringBdCalbodyEntityMap = new HashMap<>(); - - private void initBdCalbody() throws Exception { +// public static Map stringBdCalbodyEntityMap = new HashMap<>(); + private Map initBdCalbody() throws Exception { + Map stringBdCalbodyEntityMap = new HashMap<>(); BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); bdCalbodyEntity.setDr(0); bdCalbodyEntity.setDataSourceCode("lets_u8c"); @@ -113,14 +118,15 @@ public class TocReturnBasicArchivesCacheUtil { stringBdCalbodyEntityMap.put(bdCalbodyEntity1.getPkCorp(), bdCalbodyEntity1); } } + return stringBdCalbodyEntityMap; } /** * 初始化销售组织 */ - public static Map stringBdSalestruEntityMap = new HashMap<>(); - - private void initBdSalestru() throws Exception { +// public static Map stringBdSalestruEntityMap = new HashMap<>(); + private Map initBdSalestru() throws Exception { + Map stringBdSalestruEntityMap = new HashMap<>(); BdSalestruEntity bdSalestruEntity = new BdSalestruEntity(); bdSalestruEntity.setDr(0); bdSalestruEntity.setDataSourceCode("lets_u8c"); @@ -131,6 +137,7 @@ public class TocReturnBasicArchivesCacheUtil { stringBdSalestruEntityMap.put(bdSalestruEntity1.getVsalestruname(), bdSalestruEntity1); } } + return stringBdSalestruEntityMap; } /** @@ -138,9 +145,10 @@ public class TocReturnBasicArchivesCacheUtil { * * @author liuyang */ - public static Map stringBdDeptdocEntityMap = new HashMap<>(); +// public static Map stringBdDeptdocEntityMap = new HashMap<>(); + private Map initDept() { + Map stringBdDeptdocEntityMap = new HashMap<>(); - private void initDept() { BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); bdDeptdocEntity.setDataSourceCode("lets_u8c"); bdDeptdocEntity.setDr(0); @@ -152,6 +160,7 @@ public class TocReturnBasicArchivesCacheUtil { stringBdDeptdocEntityMap.put(bdDeptdocEntity1.getPkCorp(), bdDeptdocEntity1); } } + return stringBdDeptdocEntityMap; } /** @@ -159,9 +168,10 @@ public class TocReturnBasicArchivesCacheUtil { * * @author liuyang */ - public static Map stringBdCubasdocEntityHashMap = new HashMap<>(); +// public static Map stringBdCubasdocEntityHashMap = new HashMap<>(); + private Map initBdCubasdoc() { + Map stringBdCubasdocEntityHashMap = new HashMap<>(); - private void initBdCubasdoc() { BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); bdCubasdocEntity.setDataSourceCode("lets_u8c"); bdCubasdocEntity.setDr(0L); @@ -172,6 +182,7 @@ public class TocReturnBasicArchivesCacheUtil { stringBdCubasdocEntityHashMap.put(bdCubasdocEntity1.getCustname(), bdCubasdocEntity1); } } + return stringBdCubasdocEntityHashMap; } /** @@ -179,9 +190,10 @@ public class TocReturnBasicArchivesCacheUtil { * * @author liuyang */ - public static Map stringBdCumandocEntityMap = new HashMap<>(); +// public static Map stringBdCumandocEntityMap = new HashMap<>(); + private Map initBdCumandoc() { + Map stringBdCumandocEntityMap = new HashMap<>(); - private void initBdCumandoc() { BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); bdCumandocEntity1.setDataSourceCode("lets_u8c"); bdCumandocEntity1.setDr(0L); @@ -193,14 +205,16 @@ public class TocReturnBasicArchivesCacheUtil { stringBdCumandocEntityMap.put(bdCumandocEntity.getPkCubasdoc() + bdCumandocEntity.getPkCorp(), bdCumandocEntity); } } + return stringBdCumandocEntityMap; } /** * 初始化存货管理档案 */ - public static Map stringBdInvmandocEntityMap = new HashMap<>(); +// public static Map stringBdInvmandocEntityMap = new HashMap<>(); + private Map initInventoryFile() throws Exception { + Map stringBdInvmandocEntityMap = new HashMap<>(); - private void initInventoryFile() throws Exception { BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); // bdInvmandocEntity.setInvcode(copyRowDetailsListVo.getSpec_no()); // bdInvmandocEntity.setPkCorp(shippingCompanyBdCorpEntity.getPkCorp()); @@ -212,15 +226,17 @@ public class TocReturnBasicArchivesCacheUtil { stringBdInvmandocEntityMap.put(bdInvmandocEntity1.getInvcode() + bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1); } } + return stringBdInvmandocEntityMap; } /** * 初始化存货基本档案 * 2024年8月7日 10:57:55 */ - public static Map stringBdInvbasdocEntityHashMap = new HashMap<>(); +// public static Map stringBdInvbasdocEntityHashMap = new HashMap<>(); + private Map initBasicInventoryFile() throws Exception { + Map stringBdInvbasdocEntityHashMap = new HashMap<>(); - private void initBasicInventoryFile() throws Exception { BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); // bdInvbasdocEntity.setPk_invmandoc(bdInvmandocEntity1.getPkInvmandoc()); // bdInvbasdocEntity.setPk_corp(shippingCompanyBdCorpEntity.getPkCorp()); @@ -231,6 +247,7 @@ public class TocReturnBasicArchivesCacheUtil { stringBdInvbasdocEntityHashMap.put(bdInvbasdocEntity1.getPk_invmandoc() + bdInvbasdocEntity1.getPk_corp_man(), bdInvbasdocEntity1); } } + return stringBdInvbasdocEntityHashMap; } /** @@ -239,9 +256,10 @@ public class TocReturnBasicArchivesCacheUtil { * * @author liuyang */ - public static Map stringBdTaxitemsEntityHashMap = new HashMap<>(); +// public static Map stringBdTaxitemsEntityHashMap = new HashMap<>(); + private Map initBdTaxitemsEntity() throws Exception { + Map stringBdTaxitemsEntityHashMap = new HashMap<>(); - private void initBdTaxitemsEntity() throws Exception { BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); if (bdTaxitemsEntityList != null && bdTaxitemsEntityList.size() > 0) { @@ -250,6 +268,7 @@ public class TocReturnBasicArchivesCacheUtil { stringBdTaxitemsEntityHashMap.put(bdTaxitemsEntity1.getInvcode(), bdTaxitemsEntity1); } } + return stringBdTaxitemsEntityHashMap; } /** @@ -257,9 +276,10 @@ public class TocReturnBasicArchivesCacheUtil { * * @author liuyang */ - public static Map stringBdDefdocEntityHashMap = new HashMap<>(); +// public static Map stringBdDefdocEntityHashMap = new HashMap<>(); + private Map initSourcePlatform() { + Map stringBdDefdocEntityHashMap = new HashMap<>(); - private void initSourcePlatform() { BdDefdocEntity bdDefdocEntity = new BdDefdocEntity(); bdDefdocEntity.setPkDefdoclist("0001A210000000000JUD"); bdDefdocEntity.setDr(0); @@ -271,14 +291,16 @@ public class TocReturnBasicArchivesCacheUtil { stringBdDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode(), bdDefdocEntity1); } } + return stringBdDefdocEntityHashMap; } /** * 2024年8月14日 15:17:48 缓存U8C店铺自定义档案逻辑 */ - public static Map shopDefdocEntityHashMap = new HashMap<>(); +// public static Map shopDefdocEntityHashMap = new HashMap<>(); + private Map initShopDiy() { + Map shopDefdocEntityHashMap = new HashMap<>(); - private void initShopDiy() { BdDefdocEntity bdDefdocEntity = new BdDefdocEntity(); bdDefdocEntity.setPkDefdoclist("0001A210000000000XZX"); bdDefdocEntity.setDr(0); @@ -290,14 +312,17 @@ public class TocReturnBasicArchivesCacheUtil { shopDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode(), bdDefdocEntity1); } } + return shopDefdocEntityHashMap; } - public static Map stringBdRdclEntityHashMap = new HashMap<>(); +// public static Map stringBdRdclEntityHashMap = new HashMap<>(); /** * 初始化收发类别 */ private Map initBdRdcl() { + Map stringBdRdclEntityHashMap = new HashMap<>(); + BdRdclEntity bdRdclEntity = new BdRdclEntity(); bdRdclEntity.setDr(0); bdRdclEntity.setDataSourceCode("lets_u8c"); @@ -316,42 +341,57 @@ public class TocReturnBasicArchivesCacheUtil { * * @author liuyang */ - public void clearCache() throws Exception { - stringBdCorpEntityMap.clear(); - stringBdStordocEntityMap.clear(); - stringBdCalbodyEntityMap.clear(); - stringBdSalestruEntityMap.clear(); - stringBdDeptdocEntityMap.clear(); - stringBdCumandocEntityMap.clear(); - stringBdInvmandocEntityMap.clear(); - stringBdInvbasdocEntityHashMap.clear(); - stringBdTaxitemsEntityHashMap.clear(); - stringBdCubasdocEntityHashMap.clear(); - stringBdDefdocEntityHashMap.clear(); - shopDefdocEntityHashMap.clear(); - stringBdRdclEntityHashMap.clear(); - } +// public void clearCache() throws Exception { +// stringBdCorpEntityMap.clear(); +// stringBdStordocEntityMap.clear(); +// stringBdCalbodyEntityMap.clear(); +// stringBdSalestruEntityMap.clear(); +// stringBdDeptdocEntityMap.clear(); +// stringBdCumandocEntityMap.clear(); +// stringBdInvmandocEntityMap.clear(); +// stringBdInvbasdocEntityHashMap.clear(); +// stringBdTaxitemsEntityHashMap.clear(); +// stringBdCubasdocEntityHashMap.clear(); +// stringBdDefdocEntityHashMap.clear(); +// shopDefdocEntityHashMap.clear(); +// stringBdRdclEntityHashMap.clear(); +// } /** * 初始化缓存 * * @author liuyang */ - public void initCache() throws Exception { - clearCache(); + public CacheTocMapVoV2 initCache() throws Exception { +// clearCache(); + Map stringBdCorpEntityMap = initShop(); + Map stringBdStordocEntityMap = initBdStordoc(); + Map stringBdCalbodyEntityMap = initBdCalbody(); + Map stringBdSalestruEntityMap = initBdSalestru(); + Map stringBdDeptdocEntityMap = initDept(); + Map stringBdCubasdocEntityMap = initBdCubasdoc(); + Map stringBdCumandocEntityMap = initBdCumandoc(); + Map stringBdInvmandocEntityMap = initInventoryFile(); + Map stringBdInvbasdocEntityMap = initBasicInventoryFile(); + Map stringBdTaxitemsEntityMap = initBdTaxitemsEntity(); + Map stringBdDefdocEntityMap = initSourcePlatform(); + Map stringBdDefdocEntityMap1 = initShopDiy(); + Map stringBdRdclEntityMap = initBdRdcl(); - initShop(); - initBdStordoc(); - initBdCalbody(); - initBdSalestru(); - initDept(); - initBdCumandoc(); - initInventoryFile(); - initBasicInventoryFile(); - initBdTaxitemsEntity(); - initBdCubasdoc(); - initSourcePlatform(); - initShopDiy(); - initBdRdcl(); + CacheTocMapVoV2 cacheTocMapVoV2 = new CacheTocMapVoV2(); + cacheTocMapVoV2.setStringBdCorpEntityMap(stringBdCorpEntityMap); + cacheTocMapVoV2.setStringBdStordocEntityMap(stringBdStordocEntityMap); + cacheTocMapVoV2.setStringBdCalbodyEntityMap(stringBdCalbodyEntityMap); + cacheTocMapVoV2.setStringBdSalestruEntityMap(stringBdSalestruEntityMap); + cacheTocMapVoV2.setStringBdDeptdocEntityMap(stringBdDeptdocEntityMap); + cacheTocMapVoV2.setStringBdCubasdocEntityMap(stringBdCubasdocEntityMap); + cacheTocMapVoV2.setStringBdCumandocEntityMap(stringBdCumandocEntityMap); + cacheTocMapVoV2.setStringBdInvmandocEntityMap(stringBdInvmandocEntityMap); + cacheTocMapVoV2.setStringBdInvbasdocEntityMap(stringBdInvbasdocEntityMap); + cacheTocMapVoV2.setStringBdTaxitemsEntityMap(stringBdTaxitemsEntityMap); + cacheTocMapVoV2.setStringBdDefdocEntityMap(stringBdDefdocEntityMap); + cacheTocMapVoV2.setStringBdDefdocEntityMap1(stringBdDefdocEntityMap1); + cacheTocMapVoV2.setStringBdRdclEntityMap(stringBdRdclEntityMap); + return cacheTocMapVoV2; } } \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java index ceeed767..2cba58cf 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java @@ -59,5 +59,11 @@ public class SoSaleOutPluginInitializerToBTest { // } catch (Exception e) { // e.printStackTrace(); // } + + try{ + soSaleOutPluginInitializerToB.startImplementByTranTime("2024-09-12 14:04:00","2024-09-12 14:12:00"); + }catch (Exception e){ + e.printStackTrace(); + } } } \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToCTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToCTest.java index a506b7b7..98313087 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToCTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToCTest.java @@ -24,6 +24,12 @@ public class SoSaleReturnPluginInitializerToCTest { @Test public void startImplement() { - soSaleReturnPluginInitializerToC.startImplement(null, null); +// soSaleReturnPluginInitializerToC.startImplement(null, null); + try { + String code = "LETS-RE2022080200000036"; + soSaleReturnPluginInitializerToC.startImplementByCode(code, null); + } catch (Exception e) { + e.printStackTrace(); + } } } \ No newline at end of file