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 c36b43ca..7702631c 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 @@ -887,7 +887,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { * @author liuyang */ private String createGenerateBusinessDateStock(com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto header) { - //TODO 测试 + //测试 // header.setShipAt("2024-09-14"); if (header != null && header.getShipAt() != null) { //TOC以出库日期作为业务日期 @@ -960,20 +960,20 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { HeaderDto header = headerDetailsDto.getHeader(); List details = headerDetailsDto.getDetails(); try { - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = header.getHeaderDetailsDto(); - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader(); - List details1 = headerDetailsDto1.getDetails(); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = header.getHeaderDetailsDto(); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader(); +// List details1 = headerDetailsDto1.getDetails(); //OFS销售订单 - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto2 = header.getHeaderDetailsDto(); - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header2 = headerDetailsDto2.getHeader(); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto2 = header.getHeaderDetailsDto(); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header2 = headerDetailsDto2.getHeader(); //TOC、TOB业务已经和万确认,如果没有,则默认为「SALES销售」 - if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType())) { - header2.setSubOrderType("SALES"); - } - BdRdclEntity bdRdclEntity = cacheTocMapVo.getStringBdRdclEntityMap().get(header2.getSubOrderType()); - Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header2.getSubOrderType()); +// if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType())) { +// header2.setSubOrderType("SALES"); +// } +// BdRdclEntity bdRdclEntity = cacheTocMapVo.getStringBdRdclEntityMap().get(header2.getSubOrderType()); +// Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header2.getSubOrderType()); //表头公司:通过名称匹配U8C公司 // String corpName = "上海丽知品牌管理有限公司"; @@ -1006,24 +1006,26 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { Assert.notNull(bdSalestruEntity, "无匹配到销售组织 表头公司名称:{}", bdCorpEntity.getUnitname()); //业务部门:暂定的部门名称:业务部门,2024年8月5日 15:39:42 已经和妮姐确认 - BdDeptdocEntity bdDeptdocEntity = null; - if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) { - //默认业务部门 - logger.info("OFS销售订单号:{} 不存在部门字段!", header2.getCode()); - bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); - Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:业务部门 对应公司主键:{}", bdCorpEntity.getPkCorp()); - } else { - //使用O选定的部门字段 - logger.info("OFS销售订单号:{} 存在部门字段:{}!", header2.getCode(), header2.getDepartmentType()); - String deptCode = header2.getDepartmentType().trim(); - bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMapByDeptCode().get(deptCode); - Assert.notNull(bdDeptdocEntity, "无法匹配到U8C部门档案 OFS销售订单-部门编码:{}", deptCode); - } +// BdDeptdocEntity bdDeptdocEntity = null; +// if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) { +// //默认业务部门 +// logger.info("OFS销售订单号:{} 不存在部门字段!", header2.getCode()); +// bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); +// Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:业务部门 对应公司主键:{}", bdCorpEntity.getPkCorp()); +// } else { +// //使用O选定的部门字段 +// logger.info("OFS销售订单号:{} 存在部门字段:{}!", header2.getCode(), header2.getDepartmentType()); +// String deptCode = header2.getDepartmentType().trim(); +// bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMapByDeptCode().get(deptCode); +// Assert.notNull(bdDeptdocEntity, "无法匹配到U8C部门档案 OFS销售订单-部门编码:{}", deptCode); +// } //客商基本档案 // 2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1,O没有店铺信息查询接口,因此无法通过出库单的店铺编码,查询到O店铺档案对应的业务编码,接口上线之后需要补充这一部分逻辑 // String custName = "天猫intoyou旗舰店-自营"; String storeCode = header.getStoreCode(); + //测试 +// storeCode = "dy-off-01"; Assert.notNull(storeCode, "O店铺编码不能为空,没有办法完成业务逻辑!"); Assert.state(!"".equals(storeCode.trim()), "O店铺编码不能为空,没有办法完成业务逻辑!"); BdCubasdocEntity bdCubasdocEntity = cacheTocMapVo.getStringBdCubasdocEntityMap().get(storeCode); @@ -1033,7 +1035,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //2024年8月5日 15:49:49 先根据O店铺编码,得到店铺档案信息,取到名称,通过U8C接口查询出来 //目前O店铺信息查询接口还没有,等待开发,所以我这里先写所一个名字 BdCumandocEntity bdCumandocEntity = cacheTocMapVo.getStringBdCumandocEntityMap().get(bdCubasdocEntity.getPkCubasdoc() + bdCorpEntity.getPkCorp()); - Assert.notNull(bdCumandocEntity, "无法匹配到客商档案 店铺名称:{}", "天猫intoyou旗舰店-自营"); + Assert.notNull(bdCumandocEntity, "无法匹配到客商管理档案 店铺编码:{}", storeCode); //查找平台 BdDefdocEntity bdDefdocEntity = cacheTocMapVo.getStringBdDefdocPlatformEntityMap().get(header.getSourcePlatformCode()); @@ -1047,6 +1049,33 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { for (int j = 0; j < details.size(); j++) { DetailsDto detailsDto = details.get(j); + //OFS销售订单 + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto2 = detailsDto.getHeaderDetailsDto(); + Assert.notNull(headerDetailsDto2, "根据出库单明细行对应的refOrderCode(OFS销售订单号)无法匹配到OFS销售订单", detailsDto.getRefOrderCode()); + + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header2 = headerDetailsDto2.getHeader(); + + //TOC、TOB业务已经和万确认,如果没有,则默认为「SALES销售」 + if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType())) { + header2.setSubOrderType("SALES"); + } + BdRdclEntity bdRdclEntity = cacheTocMapVo.getStringBdRdclEntityMap().get(header2.getSubOrderType()); + Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header2.getSubOrderType()); + + BdDeptdocEntity bdDeptdocEntity = null; + if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) { + //默认业务部门 + logger.info("OFS销售订单号:{} 不存在部门字段!", header2.getCode()); + bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); + Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:业务部门 对应公司主键:{}", bdCorpEntity.getPkCorp()); + } else { + //使用O选定的部门字段 + logger.info("OFS销售订单号:{} 存在部门字段:{}!", header2.getCode(), header2.getDepartmentType()); + String deptCode = header2.getDepartmentType().trim(); + bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMapByDeptCode().get(deptCode); + Assert.notNull(bdDeptdocEntity, "无法匹配到U8C部门档案 OFS销售订单-部门编码:{}", deptCode); + } + //存货基本档案 BdInvbasdocEntity bdInvbasdocEntity = cacheTocMapVo.getStringBdInvbasdocEntityMap().get(detailsDto.getSkuCode()); Assert.notNull(bdInvbasdocEntity, "无法匹配到存货基本档案 存货管理主键:{} 公司:{}", detailsDto.getSkuCode(), bdCorpEntity.getPkCorp()); @@ -1076,7 +1105,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { sonDetailsDto.setBdInvmandocEntity(bdInvmandocEntity); sonDetailsDto.setBdInvbasdocEntity(bdInvbasdocEntity); sonDetailsDto.setBdTaxitemsEntity(bdTaxitemsEntity); - sonDetailsDto.setHeaderDetailsDto(headerDetailsDto1); + sonDetailsDto.setHeaderDetailsDto(detailsDto.getHeaderDetailsDto()); sonDetailsDto.setBdRdclEntity(bdRdclEntity); BeanUtil.copyPropertiesV2(detailsDto, sonDetailsDto); @@ -1335,8 +1364,10 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { for (int i = 0; i < sonDetailsDtoList.size(); i++) { SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i); - //实付金额/实发数量 + //OFS销售订单实付金额:totalPayAmount + //OFS销售出库单实付金额:totalPayAmount + //是一样的字段,目前暂时取销售出库单对应的totalPayAmount Assert.notNull(sonDetailsDto.getTotalPayAmount(), "实付金额不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto)); Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto)); BigDecimal totalPayAmountBigDecimal = new BigDecimal(sonDetailsDto.getTotalPayAmount()); @@ -2215,25 +2246,37 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { for (int i = 0; i < splitListByCount.size(); i++) { List headerDetailsDtos = splitListByCount.get(i); - StringBuffer stringBuffer = new StringBuffer(); + Set refOrderCodeSet = new HashSet<>(); +// 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(); + List details = headerDetailsDto.getDetails(); + for (int k = 0; k < details.size(); k++) { + DetailsDto detailsDto = details.get(k); + //考虑refOrderCode去除重复,提升查询的效率 + // stringBuffer.append("'"); +// stringBuffer.append(detailsDto.getRefOrderCode()); // stringBuffer.append("'"); - stringBuffer.append(header.getRefOrderCode()); -// stringBuffer.append("'"); - stringBuffer.append(","); +// stringBuffer.append(","); + refOrderCodeSet.add(detailsDto.getRefOrderCode()); + } } } - 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); + if (refOrderCodeSet.size() > 0) { + //转换为逗号 + StringJoiner joiner = new StringJoiner(","); + for (String str : refOrderCodeSet) { + joiner.add(str); + } +// String substring = stringBuffer.substring(0, stringBuffer.length()); + List headerDetailsDtoArrayList = new ArrayList<>(); + QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); + queryOfsSoSaleOutVo.setCode(joiner.toString()); + ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); + allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList); + } } } } catch (Exception e) { @@ -2257,15 +2300,28 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { HeaderDto header = headerDetailsDto.getHeader(); List details = headerDetailsDto.getDetails(); - String targetRefOrderCode = header.getRefOrderCode(); - for (int j = 0; j < ofsSaleOrder.size(); j++) { - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = ofsSaleOrder.get(j); - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader(); - List details1 = headerDetailsDto1.getDetails(); - if (header1.getCode().equals(targetRefOrderCode)) { - header.setHeaderDetailsDto(headerDetailsDto1); + for (int j = 0; j < details.size(); j++) { + DetailsDto detailsDto = details.get(j); + String refOrderCode = detailsDto.getRefOrderCode(); + + for (int k = 0; k < ofsSaleOrder.size(); k++) { + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = ofsSaleOrder.get(k); + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader(); +// List details1 = headerDetailsDto1.getDetails(); + if (header1.getCode().equals(refOrderCode)) { + detailsDto.setHeaderDetailsDto(headerDetailsDto1); + } } } +// String targetRefOrderCode = header.getRefOrderCode(); +// for (int j = 0; j < ofsSaleOrder.size(); j++) { +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = ofsSaleOrder.get(j); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader(); +// List details1 = headerDetailsDto1.getDetails(); +// if (header1.getCode().equals(targetRefOrderCode)) { +// header.setHeaderDetailsDto(headerDetailsDto1); +// } +// } } } catch (Exception e) { logger.error("findMatchingOfsOrder方法抛出异常", e); 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 f2d776d4..3195f145 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 @@ -1550,8 +1550,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { for (int j = 0; j < stockinOrderList.size(); j++) { StockinOrderSearchResponse.StockinOrder stockinOrder = stockinOrderList.get(j); StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - +// List details = stockinOrder.getDetails(); idStr.append(header.getRefOrderCode()); idStr.append(","); } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocOrderBasicArchivesCacheUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocOrderBasicArchivesCacheUtil.java index 77fa9b9b..f1267e75 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocOrderBasicArchivesCacheUtil.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocOrderBasicArchivesCacheUtil.java @@ -228,7 +228,8 @@ public class TocOrderBasicArchivesCacheUtil { for (int i = 0; i < splitListByCount.size(); i++) { List headerDtoList1 = splitListByCount.get(i); String codesStr = headerDtoList1.stream().map(HeaderDto::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); - + //测试 +// codesStr = "'dy-off-01'"; BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); bdCubasdocEntity.setDataSourceCode("lets_u8c"); bdCubasdocEntity.setDr(0L); @@ -281,6 +282,8 @@ public class TocOrderBasicArchivesCacheUtil { for (int i = 0; i < splitListByCount.size(); i++) { List headerDtoList1 = splitListByCount.get(i); String codesStr = headerDtoList1.stream().map(HeaderDto::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); + //测试 +// codesStr = "'dy-off-01'"; BdCumandocEntity bdCumandocEntity = new BdCumandocEntity(); bdCumandocEntity.setDataSourceCode("lets_u8c"); 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 0209dbb5..5ae64d33 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 @@ -87,10 +87,14 @@ class SoSaleOutPluginInitializerToCTest { // soSaleOutPluginInitializerToC.startImplementStockByTime("2024-09-24 16:35:43","2024-09-24 16:35:45"); - List headerDetailsDtoArrayList = new ArrayList<>(); - QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setCode("LETS-SO2024092500000018"); - ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); - System.out.println(headerDetailsDtoArrayList.get(0).getHeader().getDepartmentType()); +// List headerDetailsDtoArrayList = new ArrayList<>(); +// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); +// queryOfsSoSaleOutVo.setCode("LETS-SO2024092500000018"); +// ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); +// System.out.println(headerDetailsDtoArrayList.get(0).getHeader().getDepartmentType()); + + + String s = "LETS-SH2024092900000029"; + soSaleOutPluginInitializerToC.startImplementStockByCode(s, "stock"); } } \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/DetailsDto.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/DetailsDto.java index 82ddd9bc..2c83c6f5 100755 --- a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/DetailsDto.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/DetailsDto.java @@ -53,4 +53,8 @@ public class DetailsDto { * (销售)交易成功(TOB发票)是否成功 */ private String newState4; + /** + * OFS销售订单 + */ + private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto; } \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/HeaderDto.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/HeaderDto.java index 101f4038..50fbbfb8 100755 --- a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/HeaderDto.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/HeaderDto.java @@ -78,5 +78,5 @@ public class HeaderDto { // private String subOrderType; //OFS销售订单 - private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto; +// private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto; } \ No newline at end of file