diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSoSaleOutVo.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSoSaleOutVo.java index 44b5db1b..590f06b9 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSoSaleOutVo.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSoSaleOutVo.java @@ -40,22 +40,20 @@ public class QueryOfsSoSaleOutVo { private String closedAt_end; private String storeCode; - + //审核开始 + private String auditAt_start; + //审核结束 + private String auditAt_end; //交易成功时间开始 private String tradeSuccessAt_start; - //交易成功时间结束 private String tradeSuccessAt_end; - //交易成功状态 private String sourceOrderStatus; - //退款成功时间 private String refundedAt_start; - //退款成功时间 private String refundedAt_end; - //退款成功状态 private String refundStatus; } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java index 8a4c80c3..a7a7501d 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java @@ -161,10 +161,10 @@ public class ConsignmachiningIn extends PluginBaseEntity { } } } catch (Exception e) { - logger.error("executeBusiness方法异常", e); + logger.error("executeBusiness-方法异常", e); } long endMillis = System.currentTimeMillis(); - logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis)); + logger.info("executeBusiness-方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis)); return null; } @@ -199,7 +199,7 @@ public class ConsignmachiningIn extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplement-方法抛出异常", e); } } }, threadNameStrStart); @@ -244,7 +244,7 @@ public class ConsignmachiningIn extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplement-方法抛出异常", e); } } }, threadNameStrStart); diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInReturn.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInReturn.java index 12a14091..865c1288 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInReturn.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInReturn.java @@ -157,7 +157,7 @@ public class ConsignmachiningInReturn extends PluginBaseEntity { } } } catch (Exception e) { - logger.error("executeBusiness方法异常", e); + logger.error("executeBusiness-方法异常", e); } long endMillis = System.currentTimeMillis(); logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis)); diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseReturn.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseReturn.java index 5266e332..2b40fefa 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseReturn.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseReturn.java @@ -160,7 +160,7 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { } } } catch (Exception e) { - logger.error("executeBusiness方法异常", e); + logger.error("executeBusiness-方法异常", e); } long endMillis = System.currentTimeMillis(); logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis)); diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousOrder.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousOrder.java index 7d3f6de5..37dc2da6 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousOrder.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousOrder.java @@ -154,7 +154,7 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity { } } } catch (Exception e) { - logger.error("executeBusiness方法异常", e); + logger.error("executeBusiness-方法抛出异常", e); } long endMillis = System.currentTimeMillis(); logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis)); @@ -164,6 +164,8 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity { /** * 根据时间范围查询 * + * @param startTime 开始时间 + * @param endTime 结束时间 * @author liuyang */ public void startImplementByTime(String startTime, String endTime) { @@ -175,11 +177,13 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity { @Override public void run() { try { + Assert.notNull(startTime, "startTime不能为空"); + Assert.notNull(endTime, "endTime不能为空"); + //不需要采购订单对应的状态放在接口里查询,和杨运确认过,如果采购订单在订单池,那么不会有审核时间,除了订单池+订单关闭状态,其他状态都可以理解为审批状态 List allOfsPoOrderList = new ArrayList<>(); - //TODO 测试,这个查询条件是假的,目前O还没有根据审批时间范围+审批状态查询的接口 QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setClosedAt_start(startTime); - queryOfsSoSaleOutVo.setClosedAt_end(endTime); + queryOfsSoSaleOutVo.setAuditAt_start(startTime); + queryOfsSoSaleOutVo.setAuditAt_end(endTime); queryOfsSoSaleOutVo.setClientCode("LETS"); queryOfsSoSaleOutVo.setPageNo(1L); queryOfsSoSaleOutVo.setStatus(900L); @@ -191,7 +195,7 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementByTime-方法抛出异常", e); } } }, threadNameStrStart); @@ -220,6 +224,7 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity { @Override public void run() { try { + Assert.notNull(code, "code不能为空!"); List allOfsPoOrderList = new ArrayList<>(); QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); queryOfsSoSaleOutVo.setClientCode("LETS"); @@ -235,7 +240,7 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementByCode-方法抛出异常", e); } } }, threadNameStrStart); diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousWarehouse.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousWarehouse.java index d4a201ee..97bf9ab8 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousWarehouse.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousWarehouse.java @@ -195,7 +195,7 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementByTime-方法抛出异常", e); } } }, threadNameStrStart); @@ -240,7 +240,7 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplement-方法抛出异常", e); } } }, threadNameStrStart); 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 f01a38f2..d23ab528 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 @@ -137,7 +137,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { } } } catch (Exception e) { - logger.error("executeBusiness方法异常", e); + logger.error("executeBusiness-方法异常", e); } long endMillis = System.currentTimeMillis(); logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis)); @@ -206,6 +206,10 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { private static final String VNOTETYPE = "SALE"; + private static final Object PUSH_LOCK1 = new Object(); + + private static final Object PUSH_LOCK2 = new Object(); + /** * 库存同步,按指定时间拉取 * @@ -246,7 +250,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplementByStockTime方法抛出异常", e); + logger.error("startImplementByStockTime-方法抛出异常", e); } } }, threadNameStr); @@ -301,7 +305,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplementByTranTime方法抛出异常", e); + logger.error("startImplementByTranTime-方法抛出异常", e); } } }, threadNameStrStart); @@ -824,29 +828,31 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { List saleorderRequestDtoList = new ArrayList<>(); saleorderRequestDtoList.add(saleorderRequestDto); - Boolean aBoolean = checkTobOrder(header.getId(), header.getCode()); - if (aBoolean) { - logger.error("经过SQL查询判断,在U8C销售订单已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId()); - } else { - logger.error("经过SQL查询判断,在U8C销售订单不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId()); - 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) { - SoSaleResultHeadDto parentvo = soSaleResultRootDto.getParentvo(); - List childrenvo = soSaleResultRootDto.getChildrenvo(); + synchronized (PUSH_LOCK1) { + Boolean aBoolean = checkTobOrder(header.getId(), header.getCode()); + if (aBoolean) { + logger.error("经过SQL查询判断,在U8C销售订单已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId()); + } else { + logger.error("经过SQL查询判断,在U8C销售订单不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId()); + 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) { + SoSaleResultHeadDto parentvo = soSaleResultRootDto.getParentvo(); + List childrenvo = soSaleResultRootDto.getChildrenvo(); - vreceiptcode = parentvo.getVreceiptcode(); - pk_corp = parentvo.getPk_corp(); - csaleid = parentvo.getCsaleid(); + vreceiptcode = parentvo.getVreceiptcode(); + pk_corp = parentvo.getPk_corp(); + csaleid = parentvo.getCsaleid(); + } + logger.info("TOB销售订单编号:{} 主键:{} 公司:{}", vreceiptcode, csaleid, pk_corp); + //记录成功 + updateSuccessOrFail2(details, "Y", "success", vreceiptcode, csaleid); } - logger.info("TOB销售订单编号:{} 主键:{} 公司:{}", vreceiptcode, csaleid, pk_corp); - //记录成功 - updateSuccessOrFail2(details, "Y", "success", vreceiptcode, csaleid); } } catch (Exception e) { logger.error("推送TOB销售订单失败", e); @@ -957,22 +963,30 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { Assert.state(false, "查询销售订单错误,失败原因:{}", e.getMessage()); } + List headerDetailsDtoList1 = saleOrderMessageDto.getData(); + if (headerDetailsDtoList1 == null || headerDetailsDtoList1.size() == 0) { + Assert.state(false, "根据OFS销售订单编码:{},无法查询到对应的档案信息!", header.getRefOrderCode()); + } + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = headerDetailsDtoList1.get(0); + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header2 = headerDetailsDto1.getHeader(); + List details1 = headerDetailsDto1.getDetails(); + if (saleOrderMessageDto == null) { Assert.state(false, "没有匹配到售后订单,系统业务无法完成"); } - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); - String memberId = header1.getMemberId(); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); + String memberId = header2.getMemberId(); //测试 // memberId = "hzz"; Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); //如果没有O单据名称,则默认为「销售」 - if (header1.getSubOrderType() == null || "".equals(header1.getSubOrderType().trim())) { - header1.setSubOrderType("SALES"); + if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType().trim())) { + header2.setSubOrderType("SALES"); } //查询对应的收发类别 - BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject(header1.getSubOrderType()); + BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject(header2.getSubOrderType()); Assert.notNull(bdRdclEntity, "根据收发类别编码:{} 无法匹配到U8C收发类别"); // 销售公司、发货公司 @@ -1032,17 +1046,37 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { //业务部门 //2024年8月14日 10:38:37 已经和佳妮确认 - String deptName = "业务部门"; - BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); - bdDeptdocEntity.setDataSourceCode("lets_u8c"); - bdDeptdocEntity.setDr(0); - bdDeptdocEntity.setDeptname(deptName); - bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); - if (bdDeptdocEntityList.size() == 0) { - Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); - } else if (bdDeptdocEntityList.size() >= 2) { - Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + List bdDeptdocEntityList = null; + if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) { + //如果O销售订单字段不存在,默认用U8C业务部门 + logger.info("OFS销售订单号:{} 不存在部门字段!", header2.getCode()); + String deptName = "业务部门"; + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptname(deptName); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "默认部门:根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "默认部门:根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + } + } else { + //如果部门存在,则用O指定的部门字段 + logger.info("OFS销售订单号:{} 存在部门字段:{}!", header2.getCode(), header2.getDepartmentType()); + String departmentTypeCode = header2.getDepartmentType().trim(); + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptcode(departmentTypeCode); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "指定部门:根据部门编码:{} 公司id:{},无法匹配到U8C销售组织", header2.getDepartmentType(), bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "指定部门:根据部门编码:{} 公司id:{},匹配到U8C销售组织{}个", header2.getDepartmentType(), bdCorpEntityList.get(0).getPkCorp()); + } } //客商基本档案 @@ -1421,10 +1455,17 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { logger.error("查询销售订单错误,失败原因:{}", e.getMessage()); Assert.state(false, "查询销售订单错误,失败原因:{}", e.getMessage()); } + List headerDetailsDtoList1 = saleOrderMessageDto.getData(); + if (headerDetailsDtoList1 == null || headerDetailsDtoList1.size() == 0) { + Assert.state(false, "无法查询到OFS销售订单 OFS销售订单编码:{}", header.getRefOrderCode()); + } + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = headerDetailsDtoList1.get(0); + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header2 = headerDetailsDto1.getHeader(); + List details1 = headerDetailsDto1.getDetails(); + if (saleOrderMessageDto == null) { Assert.state(false, "根据单号:{},没有匹配到销售订单,系统业务无法完成", header.getRefOrderCode()); } - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); String memberId = header1.getMemberId(); // 测试 @@ -1554,17 +1595,36 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { //业务部门 //2024年8月14日 10:38:37 已经和佳妮确认 - String deptName = "其他部门"; - BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); - bdDeptdocEntity.setDataSourceCode("lets_u8c"); - bdDeptdocEntity.setDr(0); - bdDeptdocEntity.setDeptname(deptName); - bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); - if (bdDeptdocEntityList.size() == 0) { - Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); - } else if (bdDeptdocEntityList.size() >= 2) { - Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + List bdDeptdocEntityList = null; + if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) { + logger.info("OFS销售订单号:{} 不存在部门字段!", header2.getCode()); + String deptName = "业务部门"; + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptname(deptName); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "默认部门:根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "默认部门:根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + } + } else { + //如果部门存在,则用O指定的部门字段 + logger.info("OFS销售订单号:{} 存在部门字段:{}!", header2.getCode(), header2.getDepartmentType()); + String departmentTypeCode = header2.getDepartmentType().trim(); + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptcode(departmentTypeCode); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "指定部门:根据部门编码:{} 公司id:{},无法匹配到U8C销售组织", header2.getDepartmentType(), bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "指定部门:根据部门编码:{} 公司id:{},匹配到U8C销售组织{}个", header2.getDepartmentType(), bdCorpEntityList.get(0).getPkCorp()); + } } //客商基本档案 @@ -1846,26 +1906,28 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { stringListMap.put("billvos", salesInvoiceDtoList); //推送到U8C之前,再次验证,在U8C是否已经存在 - Boolean aBoolean = checkTobSalesInvoice(header.getId(), header.getCode()); - if (aBoolean) { - logger.error("经过SQL查询判断,在U8C销售发票中已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId()); - } else { - logger.error("经过SQL查询判断,在U8C销售发票中不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId()); - SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap)); - //成功 - String vreceiptcode = null; - String csaleid = null; - String pk_corp = null; - if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) { - SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo(); - List childrenvo = saleinvoiceDto.getChildrenvo(); - vreceiptcode = parentvo.getVreceiptcode(); - csaleid = parentvo.getCsaleid(); - pk_corp = parentvo.getPk_corp(); + synchronized (PUSH_LOCK2) { + Boolean aBoolean = checkTobSalesInvoice(header.getId(), header.getCode()); + if (aBoolean) { + logger.error("经过SQL查询判断,在U8C销售发票中已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId()); + } else { + logger.error("经过SQL查询判断,在U8C销售发票中不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId()); + SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap)); + //成功 + String vreceiptcode = null; + String csaleid = null; + String pk_corp = null; + if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) { + SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo(); + List childrenvo = saleinvoiceDto.getChildrenvo(); + vreceiptcode = parentvo.getVreceiptcode(); + csaleid = parentvo.getCsaleid(); + pk_corp = parentvo.getPk_corp(); + } + logger.info("TOB销售发票生成成功 编码:{} 主键:{} 发票公司:{}", vreceiptcode, csaleid, pk_corp); + //记录成功 + updateSuccessOrFail3(details, "Y", "success", vreceiptcode, csaleid); } - logger.info("TOB销售发票生成成功 编码:{} 主键:{} 发票公司:{}", vreceiptcode, csaleid, pk_corp); - //记录成功 - updateSuccessOrFail3(details, "Y", "success", vreceiptcode, csaleid); } } catch (Exception e) { logger.error("TOB的销售发票传输失败,抛出异常", e); 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 78fb8e12..c1e3ed09 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 @@ -276,7 +276,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementStockByCode-方法抛出异常", e); } finally { // try { // basicArchivesCacheUtil.clearCache(); @@ -343,7 +343,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { logger.info("TOC没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementTranByTime-方法抛出异常", e); } finally { // try { // basicArchivesCacheUtil.clearCache(); @@ -990,9 +990,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //查询对应的OFS销售订单 List headerDetailsDtos = queryOfsOrder(headerDetailsDtoList); findMatchingOfsOrder(headerDetailsDtos, headerDetailsDtoList); - //TOC金额分摊 - - + for (int i = 0; i < headerDetailsDtoList.size(); i++) { HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i); HeaderDto header = headerDetailsDto.getHeader(); @@ -1016,7 +1014,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //表头公司:通过名称匹配U8C公司 // String corpName = "上海丽知品牌管理有限公司"; String companyCode = header.getCompanyCode(); - //TODO 测试 + //测试 // companyCode = "SHLZ"; Assert.notNull(companyCode, "O出库单表头货主不能为空!"); BdCorpEntity bdCorpEntity = cacheTocMapVo.getStringBdCorpEntityMap().get(companyCode); @@ -1043,9 +1041,20 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { BdSalestruEntity bdSalestruEntity = cacheTocMapVo.getStringBdSalestruEntityMap().get(bdCorpEntity.getUnitname()); Assert.notNull(bdSalestruEntity, "无匹配到销售组织 表头公司名称:{}", bdCorpEntity.getUnitname()); - //业务部门:暂定的部门名称:其他,2024年8月5日 15:39:42 已经和妮姐确认 - BdDeptdocEntity bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); - Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:其他 对应公司名称:{}", bdCorpEntity.getPkCorp()); + //业务部门:暂定的部门名称:业务部门,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); + } //客商基本档案 // 2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1,O没有店铺信息查询接口,因此无法通过出库单的店铺编码,查询到O店铺档案对应的业务编码,接口上线之后需要补充这一部分逻辑 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 7cd7d00e..97d1b6a1 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 @@ -26,7 +26,7 @@ import com.hzya.frame.plugin.lets.u8cdto.*; import com.hzya.frame.plugin.lets.util.*; import com.hzya.frame.split.SplitListByCountUtil; import com.hzya.frame.ttxofs.dto.InterfaceParamDto; -import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto; import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto; import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto; import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto; @@ -97,6 +97,10 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { return "3"; } + private static final Object PUSH_LOCK1 = new Object(); + + private static final Object PUSH_LOCK2 = new Object(); + @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { long startMillis = System.currentTimeMillis(); @@ -250,7 +254,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementByStockTime-方法抛出异常", e); } } }, threadNameStrStart); @@ -306,7 +310,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementByTradeTime-方法抛出异常", e); } } }, threadNameStrStart); @@ -364,7 +368,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementByCode-方法抛出异常", e); } } }, threadNameStrStart); @@ -818,27 +822,29 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { List saleorderRequestDtoList = new ArrayList<>(); saleorderRequestDtoList.add(saleorderRequestDto); - Boolean aBoolean = checkTobOrder(header.getId(), header.getCode()); - if (!aBoolean) { - logger.error("经过SQL查询判断,在U8C(红字)销售订单不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId()); - Map> stringStringMap = new HashMap<>(); - stringStringMap.put("saleorder", saleorderRequestDtoList); - SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); - String vreceiptcode = null; - String csaleid = null; - String pk_corp = null; - if (soSaleResultRootDto != null) { - SoSaleResultHeadDto parentvo = soSaleResultRootDto.getParentvo(); - List childrenvo = soSaleResultRootDto.getChildrenvo(); - vreceiptcode = parentvo.getVreceiptcode(); - csaleid = parentvo.getCsaleid(); - pk_corp = parentvo.getPk_corp(); + synchronized (PUSH_LOCK1) { + Boolean aBoolean = checkTobOrder(header.getId(), header.getCode()); + if (!aBoolean) { + logger.error("经过SQL查询判断,在U8C(红字)销售订单不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId()); + Map> stringStringMap = new HashMap<>(); + stringStringMap.put("saleorder", saleorderRequestDtoList); + SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); + String vreceiptcode = null; + String csaleid = null; + String pk_corp = null; + if (soSaleResultRootDto != null) { + SoSaleResultHeadDto parentvo = soSaleResultRootDto.getParentvo(); + List childrenvo = soSaleResultRootDto.getChildrenvo(); + vreceiptcode = parentvo.getVreceiptcode(); + csaleid = parentvo.getCsaleid(); + pk_corp = parentvo.getPk_corp(); + } + logger.info("TOB红字销售订单编号:{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp); + //记录成功 + updateSuccessOrFail1(details, "Y", "success", vreceiptcode, csaleid); + } else { + logger.error("经过SQL查询判断,在U8C(红字)销售订单存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId()); } - logger.info("TOB红字销售订单编号:{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp); - //记录成功 - updateSuccessOrFail1(details, "Y", "success", vreceiptcode, csaleid); - } else { - logger.error("经过SQL查询判断,在U8C(红字)销售订单存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId()); } } catch (Exception e) { logger.error("TOB售后收入推送U8C失败", e); @@ -900,11 +906,11 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { List details = stockinOrder.getDetails(); try { - //查询售后订单 + //查询OFS售后订单 RerturnGoodsOrderSearchData ofsRertunOrder = afterSalesOrderUtil.getOfsRertunOrder(header.getRefOrderCode()); Assert.notNull(ofsRertunOrder, "无法查询到OFS售后订单 编码:{}", header.getRefOrderCode()); - //查询销售订单 + //查询OFS销售订单 SaleOrderMessageDto saleOrderMessageDto = null; try { saleOrderMessageDto = afterSalesOrderUtil.getOfsOrder(ofsRertunOrder.getHeader().getRefOrderCode()); @@ -912,13 +918,20 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { logger.error("查询出售后订单错误,失败原因:{}", e.getMessage()); Assert.state(false, "查询出售后订单错误,失败原因:{}", e.getMessage()); } + List headerDetailsDtoList = saleOrderMessageDto.getData(); + if (headerDetailsDtoList == null || headerDetailsDtoList.size() == 0) { + Assert.state(false, "无法查询到OFS销售订单,查询路径:OFS销售出库单 -> OFS售后订单 -> OFS销售订单 OFS售后订单:{}", ofsRertunOrder.getHeader().getCode()); + } + HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(0); + HeaderDto header2 = headerDetailsDto.getHeader(); + List details1 = headerDetailsDto.getDetails(); if (saleOrderMessageDto == null) { Assert.state(false, "没有匹配到售后订单,系统业务无法完成"); } HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); String memberId = header1.getMemberId(); - //TODO 会员id + //会员id // memberId = "GYS00002"; Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); @@ -932,7 +945,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { // 销售公司、发货公司 String companyCode = header.getCompanyCode(); - //TODO 测试 + //测试 // companyCode = "SHLZ"; Assert.notNull(companyCode, "O表头公司不能为空"); BdCorpEntity bdCorpEntity = new BdCorpEntity(); @@ -988,17 +1001,35 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { //业务部门 //2024年8月14日 10:38:37 已经和佳妮确认 - String deptName = "业务部门"; - BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); - bdDeptdocEntity.setDataSourceCode("lets_u8c"); - bdDeptdocEntity.setDr(0); - bdDeptdocEntity.setDeptname(deptName); - bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); - if (bdDeptdocEntityList.size() == 0) { - Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); - } else if (bdDeptdocEntityList.size() >= 2) { - Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + List bdDeptdocEntityList = null; + if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) { + logger.info("OFS销售订单号:{} 不存在部门字段!", header2.getCode()); + String deptName = "业务部门"; + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptname(deptName); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "默认部门:根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "默认部门:根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + } + } else { + logger.info("OFS销售订单号:{} 存在部门字段:{}!", header2.getCode(), header2.getDepartmentType()); + String departmentType = header2.getDepartmentType(); + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptcode(departmentType); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "指定部门:根据部门编码:{} 公司id:{},无法匹配到U8C销售组织", header2.getDepartmentType(), bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "指定部门:根据部门编码:{} 公司id:{},匹配到U8C销售组织{}个", header2.getDepartmentType(), bdCorpEntityList.get(0).getPkCorp()); + } } //客商基本档案 @@ -1136,13 +1167,20 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { logger.error("查询出售后订单错误,失败原因:{}", e.getMessage()); Assert.state(false, "查询出售后订单错误,失败原因:{}", e.getMessage()); } + List headerDetailsDtoList = saleOrderMessageDto.getData(); + if (headerDetailsDtoList == null || headerDetailsDtoList.size() == 0) { + Assert.state(false, "无法匹配到OFS销售订单 售后订单号:{}", ofsRertunOrder.getHeader().getCode()); + } + HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(0); + HeaderDto header2 = headerDetailsDto.getHeader(); + List details1 = headerDetailsDto.getDetails(); if (saleOrderMessageDto == null) { Assert.state(false, "没有匹配到售后订单,系统业务无法完成"); } HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); String memberId = header1.getMemberId(); - //TODO 测试 + //测试 // memberId = "GYS00002"; Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); @@ -1212,7 +1250,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { // 销售公司、发货公司 String companyCode = header.getCompanyCode(); - //TODO 测试 + //测试 // companyCode = "SHLZ"; Assert.notNull(companyCode, "O表头公司不能为空"); BdCorpEntity bdCorpEntity = new BdCorpEntity(); @@ -1268,17 +1306,35 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { //业务部门 //2024年8月14日 10:38:37 已经和佳妮确认 - String deptName = "其他部门"; - BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); - bdDeptdocEntity.setDataSourceCode("lets_u8c"); - bdDeptdocEntity.setDr(0); - bdDeptdocEntity.setDeptname(deptName); - bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); - if (bdDeptdocEntityList.size() == 0) { - Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); - } else if (bdDeptdocEntityList.size() >= 2) { - Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + List bdDeptdocEntityList = null; + if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) { + logger.info("OFS销售订单号:{} 不存在部门字段!", header2.getCode()); + String deptName = "业务部门"; + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptname(deptName); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + } + } else { + logger.info("OFS销售订单号:{} 存在部门字段:{}!", header2.getCode(), header2.getDepartmentType()); + String departmentType = header2.getDepartmentType(); + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptcode(departmentType); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "指定部门:根据部门编码:{} 公司id:{},无法匹配到U8C销售组织", header2.getDepartmentType(), bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "指定部门:根据部门编码:{} 公司id:{},匹配到U8C销售组织{}个", header2.getDepartmentType(), bdCorpEntityList.get(0).getPkCorp()); + } } //客商基本档案 @@ -1788,25 +1844,27 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { stringListMap.put("billvos", salesInvoiceDtoList); //推送到U8C生成销售发票 - Boolean aBoolean = checkTobSalesInvoice(header.getId(), header.getCode()); - if (!aBoolean) { - logger.error("经过SQL查询判断,在U8C红字销售发票中不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId()); - SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap)); - String vreceiptcode = null; - String csaleid = null; - String pk_corp = null; - if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) { - SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo(); - List childrenvo = saleinvoiceDto.getChildrenvo(); - vreceiptcode = parentvo.getVreceiptcode(); - csaleid = parentvo.getCsaleid(); - pk_corp = parentvo.getPk_corp(); + synchronized (PUSH_LOCK2) { + Boolean aBoolean = checkTobSalesInvoice(header.getId(), header.getCode()); + if (!aBoolean) { + logger.error("经过SQL查询判断,在U8C红字销售发票中不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId()); + SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap)); + String vreceiptcode = null; + String csaleid = null; + String pk_corp = null; + if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) { + SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo(); + List childrenvo = saleinvoiceDto.getChildrenvo(); + vreceiptcode = parentvo.getVreceiptcode(); + csaleid = parentvo.getCsaleid(); + pk_corp = parentvo.getPk_corp(); + } + logger.info("TOB销售发票(红字)生成成功 编码:{} 主键:{} 发票公司:{}", vreceiptcode, csaleid, pk_corp); + //记录成功 + updateSuccessOrFail2(details, "Y", "success", vreceiptcode, csaleid); + } else { + logger.error("经过SQL查询判断,在U8C红字销售发票中已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId()); } - logger.info("TOB销售发票(红字)生成成功 编码:{} 主键:{} 发票公司:{}", vreceiptcode, csaleid, pk_corp); - //记录成功 - updateSuccessOrFail2(details, "Y", "success", vreceiptcode, csaleid); - } else { - logger.error("经过SQL查询判断,在U8C红字销售发票中已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId()); } } catch (Exception e) { logger.error("TOB售后到账完成推送U8C抛出异常", 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 a5816982..6069b8bd 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 @@ -207,7 +207,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementStockByTime-方法抛出异常", e); } finally { // try { // tocReturnBasicArchivesCacheUtil.clearCache(); @@ -273,7 +273,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementByCode-方法抛出异常", e); } finally { // try { // tocReturnBasicArchivesCacheUtil.clearCache(); @@ -335,7 +335,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { logger.info("没有查询到任何数据!不需要同步"); } } catch (Exception e) { - logger.error("startImplement方法抛出异常", e); + logger.error("startImplementByTradeTime-方法抛出异常", e); } } }, threadNameStrStart); @@ -1033,8 +1033,8 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //表头公司:通过名称匹配U8C公司 // String corpName = "上海丽知品牌管理有限公司"; - //TODO 测试SHOF - header.setCompanyCode("SHOF"); + //测试SHOF +// header.setCompanyCode("SHOF"); Assert.notNull(header.getCompanyCode(), "O货主编码不能为空"); BdCorpEntity bdCorpEntity = cacheTocMapVoV2.getStringBdCorpEntityMap().get(header.getCompanyCode()); Assert.notNull(bdCorpEntity, "根据O公司编码(货主编码)({})没有匹配到U8C公司档案", header.getCompanyCode()); @@ -1061,8 +1061,17 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { Assert.notNull(bdSalestruEntity, "无匹配到销售组织 表头公司名称:{}", bdCorpEntity.getUnitname()); //业务部门:暂定的部门名称:其他,2024年8月5日 15:39:42 已经和妮姐确认 - BdDeptdocEntity bdDeptdocEntity = cacheTocMapVoV2.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); - Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:其他 对应公司名称:{}", bdCorpEntity.getPkCorp()); + BdDeptdocEntity bdDeptdocEntity = null; + if (header1.getDepartmentType() == null || "".equals(header1.getDepartmentType().trim())) { + //默认业务部门 + logger.info("OFS销售订单号:{} 不存在部门字段!", header1.getCode()); + bdDeptdocEntity = cacheTocMapVoV2.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); + Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:其他 对应公司名称:{}", bdCorpEntity.getPkCorp()); + } else { + logger.info("OFS销售订单号:{} 存在部门字段:{}!", header1.getCode(), header1.getDepartmentType()); + String deptCode = header1.getDepartmentType().trim(); + bdDeptdocEntity = cacheTocMapVoV2.getStringBdDeptdocEntityMapByDeptCode().get(deptCode); + } //客商基本档案 //2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1,O没有店铺信息查询接口,因此无法通过出库单的店铺编码,查询到O店铺档案对应的业务编码,接口上线之后需要补充这一部分逻辑 diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/resultvo/CacheTocMapVo.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/resultvo/CacheTocMapVo.java index b2392229..0d7efb9d 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/resultvo/CacheTocMapVo.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/resultvo/CacheTocMapVo.java @@ -20,6 +20,7 @@ public class CacheTocMapVo { private Map stringBdCalbodyEntityMap; private Map stringBdSalestruEntityMap; private Map stringBdDeptdocEntityMap; + private Map stringBdDeptdocEntityMapByDeptCode; private Map stringBdCumandocEntityMap; private Map stringBdInvmandocEntityMap; private Map stringBdInvbasdocEntityMap; 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 index 933e7802..2c8e4820 100644 --- 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 @@ -20,6 +20,7 @@ public class CacheTocMapVoV2 { private Map stringBdCalbodyEntityMap; private Map stringBdSalestruEntityMap; private Map stringBdDeptdocEntityMap; + private Map stringBdDeptdocEntityMapByDeptCode; private Map stringBdCubasdocEntityMap; private Map stringBdCumandocEntityMap; private Map stringBdInvmandocEntityMap; 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 7ece065d..77fa9b9b 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 @@ -161,21 +161,38 @@ public class TocOrderBasicArchivesCacheUtil { * @author liuyang */ // public static Map stringBdDeptdocEntityMap = new HashMap<>(); - private Map initDept() { - Map stringBdDeptdocEntityMap = new HashMap<>(); + private List> initDept() { + List> bddeptdocEntityList = new ArrayList<>(); + Map stringBdDeptdocEntityMap1 = new HashMap<>(); + Map stringBdDeptdocEntityMap2 = new HashMap<>(); + bddeptdocEntityList.add(stringBdDeptdocEntityMap1); + bddeptdocEntityList.add(stringBdDeptdocEntityMap2); + + String deptName = "业务部门"; BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); bdDeptdocEntity.setDataSourceCode("lets_u8c"); bdDeptdocEntity.setDr(0); - bdDeptdocEntity.setDeptname("业务部门"); + bdDeptdocEntity.setDeptname(deptName); List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); if (bdDeptdocEntityList != null && bdDeptdocEntityList.size() > 0) { for (int i = 0; i < bdDeptdocEntityList.size(); i++) { BdDeptdocEntity bdDeptdocEntity1 = bdDeptdocEntityList.get(i); - stringBdDeptdocEntityMap.put(bdDeptdocEntity1.getPkCorp(), bdDeptdocEntity1); + stringBdDeptdocEntityMap1.put(bdDeptdocEntity1.getPkCorp(), bdDeptdocEntity1); } } - return stringBdDeptdocEntityMap; + + BdDeptdocEntity bdDeptdocEntity2 = new BdDeptdocEntity(); + bdDeptdocEntity2.setDataSourceCode("lets_u8c"); + bdDeptdocEntity2.setDr(0); + List bdDeptdocEntityList2 = iBdDeptdocDao.query(bdDeptdocEntity2); + if (bdDeptdocEntityList2 != null && bdDeptdocEntityList2.size() > 0) { + for (int i = 0; i < bdDeptdocEntityList2.size(); i++) { + BdDeptdocEntity bdDeptdocEntity1 = bdDeptdocEntityList2.get(i); + stringBdDeptdocEntityMap2.put(bdDeptdocEntity1.getDeptcode(), bdDeptdocEntity1); + } + } + return bddeptdocEntityList; } /** @@ -525,7 +542,7 @@ public class TocOrderBasicArchivesCacheUtil { Map stringBdStordocEntityMap = initBdStordoc(); Map stringBdCalbodyEntityMap = initBdCalbody(); Map stringBdSalestruEntityMap = initBdSalestru(); - Map stringBdDeptdocEntityMap = initDept(); + List> maps = initDept(); Map stringBdCumandocEntityMap = initBdCumandocV2(headerDtoList); Map stringBdInvmandocEntityMap = initInventoryFileV2(detailsDtos); Map stringBdInvbasdocEntityMap = initBasicInventoryFileV2(detailsDtos); @@ -542,7 +559,8 @@ public class TocOrderBasicArchivesCacheUtil { cacheTocMapVo.setStringBdStordocEntityMap(stringBdStordocEntityMap); cacheTocMapVo.setStringBdCalbodyEntityMap(stringBdCalbodyEntityMap); cacheTocMapVo.setStringBdSalestruEntityMap(stringBdSalestruEntityMap); - cacheTocMapVo.setStringBdDeptdocEntityMap(stringBdDeptdocEntityMap); + cacheTocMapVo.setStringBdDeptdocEntityMap(maps.get(0)); + cacheTocMapVo.setStringBdDeptdocEntityMapByDeptCode(maps.get(1)); cacheTocMapVo.setStringBdCumandocEntityMap(stringBdCumandocEntityMap); cacheTocMapVo.setStringBdInvmandocEntityMap(stringBdInvmandocEntityMap); cacheTocMapVo.setStringBdInvbasdocEntityMap(stringBdInvbasdocEntityMap); 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 7ddec782..8e004cb6 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 @@ -154,21 +154,38 @@ public class TocReturnBasicArchivesCacheUtil { * @author liuyang */ // public static Map stringBdDeptdocEntityMap = new HashMap<>(); - private Map initDept() { - Map stringBdDeptdocEntityMap = new HashMap<>(); + private List> initDept() { + List> bddeptdocEntityList = new ArrayList<>(); + Map stringBdDeptdocEntityMap1 = new HashMap<>(); + Map stringBdDeptdocEntityMap2 = new HashMap<>(); + bddeptdocEntityList.add(stringBdDeptdocEntityMap1); + bddeptdocEntityList.add(stringBdDeptdocEntityMap2); + + String deptName = "业务部门"; BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); bdDeptdocEntity.setDataSourceCode("lets_u8c"); bdDeptdocEntity.setDr(0); - bdDeptdocEntity.setDeptname("业务部门"); + bdDeptdocEntity.setDeptname(deptName); List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); if (bdDeptdocEntityList != null && bdDeptdocEntityList.size() > 0) { for (int i = 0; i < bdDeptdocEntityList.size(); i++) { BdDeptdocEntity bdDeptdocEntity1 = bdDeptdocEntityList.get(i); - stringBdDeptdocEntityMap.put(bdDeptdocEntity1.getPkCorp(), bdDeptdocEntity1); + stringBdDeptdocEntityMap1.put(bdDeptdocEntity1.getPkCorp(), bdDeptdocEntity1); } } - return stringBdDeptdocEntityMap; + + BdDeptdocEntity bdDeptdocEntity2 = new BdDeptdocEntity(); + bdDeptdocEntity2.setDataSourceCode("lets_u8c"); + bdDeptdocEntity2.setDr(0); + List bdDeptdocEntityList2 = iBdDeptdocDao.query(bdDeptdocEntity2); + if (bdDeptdocEntityList2 != null && bdDeptdocEntityList2.size() > 0) { + for (int i = 0; i < bdDeptdocEntityList2.size(); i++) { + BdDeptdocEntity bdDeptdocEntity1 = bdDeptdocEntityList2.get(i); + stringBdDeptdocEntityMap2.put(bdDeptdocEntity1.getDeptcode(), bdDeptdocEntity1); + } + } + return bddeptdocEntityList; } /** @@ -517,7 +534,7 @@ public class TocReturnBasicArchivesCacheUtil { Map stringBdStordocEntityMap = initBdStordoc(); Map stringBdCalbodyEntityMap = initBdCalbody(); Map stringBdSalestruEntityMap = initBdSalestru(); - Map stringBdDeptdocEntityMap = initDept(); + List> maps = initDept(); Map stringBdCubasdocEntityMap = initBdCubasdocV2(stockinHList); Map stringBdCumandocEntityMap = initBdCumandocV2(stockinHList); Map stringBdInvmandocEntityMap = initInventoryFileV2(stockinBList); @@ -532,7 +549,8 @@ public class TocReturnBasicArchivesCacheUtil { cacheTocMapVoV2.setStringBdStordocEntityMap(stringBdStordocEntityMap); cacheTocMapVoV2.setStringBdCalbodyEntityMap(stringBdCalbodyEntityMap); cacheTocMapVoV2.setStringBdSalestruEntityMap(stringBdSalestruEntityMap); - cacheTocMapVoV2.setStringBdDeptdocEntityMap(stringBdDeptdocEntityMap); + cacheTocMapVoV2.setStringBdDeptdocEntityMap(maps.get(0)); + cacheTocMapVoV2.setStringBdDeptdocEntityMapByDeptCode(maps.get(1)); cacheTocMapVoV2.setStringBdCubasdocEntityMap(stringBdCubasdocEntityMap); cacheTocMapVoV2.setStringBdCumandocEntityMap(stringBdCumandocEntityMap); cacheTocMapVoV2.setStringBdInvmandocEntityMap(stringBdInvmandocEntityMap); diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/HeaderDto.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/HeaderDto.java index 3d288987..48783013 100755 --- a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/HeaderDto.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/HeaderDto.java @@ -116,4 +116,7 @@ public class HeaderDto { //支付优惠 private String payDiscounts; + + //部门字段 + private String departmentType; } \ No newline at end of file