From d0a0a105685d28d6d39a53f16003e259513d4571 Mon Sep 17 00:00:00 2001 From: liuy <37787198+LiuyCodes@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:07:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=97=A5=E5=BF=97=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/outsourc/ConsignmachiningIn.java | 72 ++++- .../outsourc/ConsignmachiningInReturn.java | 183 ++++++----- .../plugin/purchase/ProxyPurchaseReturn.java | 61 +++- .../purchase/ProxyPurchaseWarehous.java | 284 ++++++++++-------- 4 files changed, 388 insertions(+), 212 deletions(-) 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 749d1512..dd18be12 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 @@ -466,11 +466,15 @@ public class ConsignmachiningIn extends PluginBaseEntity { List consignmachiningInSonDtoArrayList = new ArrayList<>(); if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { - try { - for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoList.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); + for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) { + StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoList.get(i); + StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); + List details = stockinOrder.getDetails(); + + String generateBusinessDate = null; + try { + //生成业务日期 + generateBusinessDate = createGenerateBusinessDateV2(header); //2024年8月25日 09:54:31 查询OFS采购订单 OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(header.getRefOrderCode()); @@ -605,11 +609,26 @@ public class ConsignmachiningIn extends PluginBaseEntity { BeanUtil.copyPropertiesV2(header, consignmachiningInSonDto); consignmachiningInSonDtoArrayList.add(consignmachiningInSonDto); + //成功,交给下一个业务流程处理环节 + } catch (Exception e) { + logger.error("采购入库单OFS档案转换错误", e); + + String message = e.getMessage(); + if (message == null) { + message = "未知错误"; + } + //失败 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(JSON.toJSONString(stockinOrder));//原始数据json + integrationTaskLivingDetailsEntity.setNewTransmitInfo(JSON.toJSONString(message));//返回结果 + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(generateBusinessDate); + integrationTaskLivingDetailsEntity.setRootAppPk(header.getId()); + integrationTaskLivingDetailsEntity.setRootAppBill(header.getCode()); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); } - //成功 - } catch (Exception e) { - logger.error("委外入库单OFS档案转换错误", e); - //失败 } } else { logger.info("queryBasicArchives对应returnGoodHeaderDetailsDataDtoList.size为0"); @@ -684,10 +703,33 @@ public class ConsignmachiningIn extends PluginBaseEntity { * @author liuyang */ private String createGenerateBusinessDate(ConsignmachiningInSonDto consignmachiningInSonDto) { - //TODO 测试 - consignmachiningInSonDto.setShipAt("2024-08-19"); - if (consignmachiningInSonDto != null && consignmachiningInSonDto.getShipAt() != null) { - String shipAt = consignmachiningInSonDto.getShipAt(); + if (consignmachiningInSonDto != null && consignmachiningInSonDto.getCheckInFrom() != null) { + String checkInFrom = consignmachiningInSonDto.getCheckInFrom(); + + String businessFormat = null; + try { + Date dbill = DateUtil.parse(checkInFrom); + businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); + } catch (Exception e) { + logger.error("业务日期生成失败", e); + } + return businessFormat; + } else { + logger.error("生成采购订单入库日期失败,或者checkInFrom为空! json:{}", JSON.toJSON(consignmachiningInSonDto)); + Assert.state(false, "生成采购订单入库日期失败,或者checkInFrom为空! json:{}", JSON.toJSON(consignmachiningInSonDto)); + return null; + } + } + + /** + * 2024年8月20日 15:46:10 + * 生成业务日期,以发货时间作为业务日期 + * + * @author liuyang + */ + private String createGenerateBusinessDateV2(StockinOrderSearchResponse.StockinOrder.StockinH header) { + if (header != null) { + String shipAt = header.getShipAt(); String businessFormat = null; try { Date dbill = DateUtil.parse(shipAt); @@ -697,8 +739,8 @@ public class ConsignmachiningIn extends PluginBaseEntity { } return businessFormat; } else { - logger.error("生成采购订单入库日期失败,或者shipAt为空! json:{}", JSON.toJSON(consignmachiningInSonDto)); - Assert.state(false, "生成采购订单入库日期失败,或者shipAt为空! json:{}", JSON.toJSON(consignmachiningInSonDto)); + logger.error("生成业务日期失败,或者shipAt为空! json:{}", JSON.toJSON(header)); + Assert.state(false, "生成业务日期失败,或者shipAt为空! json:{}", JSON.toJSON(header)); return null; } } 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 7b616247..fe843156 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 @@ -454,84 +454,107 @@ public class ConsignmachiningInReturn extends PluginBaseEntity { HeaderDto header = headerDetailsDto.getHeader(); List details = headerDetailsDto.getDetails(); - //2024年8月27日 17:14:47 查询OFS采退订单 - PurchaseReturnOrder purchaseReturnOrder = queryPurchaseReturnOrder(header.getRefOrderCode()); - Assert.notNull(purchaseReturnOrder, "无法查询到采退订单 refOrderCode:{}", header.getRefOrderCode()); - PurchaseReturnOrderHeader ofsWithdrawalHead = purchaseReturnOrder.getHeader(); - List ofsWithdrawalDetails = purchaseReturnOrder.getDetails(); + String generateBusinessDate = null; + try { + generateBusinessDate = createGenerateBusinessDatev2(header); - //如果该O采购订单对应的类型为:委外加工,则继续代码逻辑,否则就跳过代码逻辑 - boolean checkResult = onlyImplementProxyOrder.onlyImplementProxyOrder(purchaseReturnOrder, "WWJG"); - if (!checkResult) { - continue; - } + //2024年8月27日 17:14:47 查询OFS采退订单 + PurchaseReturnOrder purchaseReturnOrder = queryPurchaseReturnOrder(header.getRefOrderCode()); + Assert.notNull(purchaseReturnOrder, "无法查询到采退订单 refOrderCode:{}", header.getRefOrderCode()); + PurchaseReturnOrderHeader ofsWithdrawalHead = purchaseReturnOrder.getHeader(); + List ofsWithdrawalDetails = purchaseReturnOrder.getDetails(); - //2024年8月30日 13:28:46 查询原委外订单(取的是钉钉推送到U8C的委外订单),查询逻辑:OFS采退出库单 -> OFS采退订单 -> OFS采购订单 - OfsPoOrderData ofsPoOrder = queryOfsPoOrder(purchaseReturnOrder); + //如果该O采购订单对应的类型为:委外加工,则继续代码逻辑,否则就跳过代码逻辑 + boolean checkResult = onlyImplementProxyOrder.onlyImplementProxyOrder(purchaseReturnOrder, "WWJG"); + if (!checkResult) { + continue; + } - //2024年8月30日 13:35:16 根据OFS采购订单,查询OFS委外订单 - ScOrderEntity scOrderEntity = queryScOrder(ofsPoOrder.getHeader().getId()); + //2024年8月30日 13:28:46 查询原委外订单(取的是钉钉推送到U8C的委外订单),查询逻辑:OFS采退出库单 -> OFS采退订单 -> OFS采购订单 + OfsPoOrderData ofsPoOrder = queryOfsPoOrder(purchaseReturnOrder); - //2024年8月27日 17:14:51 查询U8C委外订单,如果这一步报错,后续的逻辑就没有必要执行了 + //2024年8月30日 13:35:16 根据OFS采购订单,查询OFS委外订单 + ScOrderEntity scOrderEntity = queryScOrder(ofsPoOrder.getHeader().getId()); + + //2024年8月27日 17:14:51 查询U8C委外订单,如果这一步报错,后续的逻辑就没有必要执行了 // String ofsId = ofsWithdrawalHead.getId(); // Assert.notNull(ofsId, "通过接口查询到OFS采退订单,但是没有采退订单主键(id),业务逻辑无法完成"); // ScOrderEntity scOrderEntity = queryScOrder(ofsId); - //2024年8月27日 17:14:57 根据U8C委外订单id,查询U8C委外订单表体明细行 - List scOrderBEntityList = queryScOrderDetail(scOrderEntity.getCorderid()); + //2024年8月27日 17:14:57 根据U8C委外订单id,查询U8C委外订单表体明细行 + List scOrderBEntityList = queryScOrderDetail(scOrderEntity.getCorderid()); - //2024年8月27日 17:15:02 委外入库公司,取委外订单上的公司,已经和妮姐确认,没有必要通过O的公司转换,因为不存在跨组织的问题 - Assert.notNull(scOrderEntity.getPkCorp(), "O表头公司不能为空"); - BdCorpEntity bdCorpEntity = new BdCorpEntity(); - bdCorpEntity.setDr(0); - bdCorpEntity.setDataSourceCode("lets_u8c"); - bdCorpEntity.setPkCorp(scOrderEntity.getPkCorp()); - List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); - if (bdCorpEntityList.size() == 0) { - Assert.state(false, "根据委外订单公司主键:{},无法匹配到委外入库单", scOrderEntity.getPkCorp()); - } else if (bdCorpEntityList.size() >= 2) { - Assert.state(false, "根据委外订单公司主键:{},匹配到{}个委外入库单", scOrderEntity.getPkCorp(), bdCorpEntityList.size()); + //2024年8月27日 17:15:02 委外入库公司,取委外订单上的公司,已经和妮姐确认,没有必要通过O的公司转换,因为不存在跨组织的问题 + Assert.notNull(scOrderEntity.getPkCorp(), "O表头公司不能为空"); + BdCorpEntity bdCorpEntity = new BdCorpEntity(); + bdCorpEntity.setDr(0); + bdCorpEntity.setDataSourceCode("lets_u8c"); + bdCorpEntity.setPkCorp(scOrderEntity.getPkCorp()); + List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); + if (bdCorpEntityList.size() == 0) { + Assert.state(false, "根据委外订单公司主键:{},无法匹配到委外入库单", scOrderEntity.getPkCorp()); + } else if (bdCorpEntityList.size() >= 2) { + Assert.state(false, "根据委外订单公司主键:{},匹配到{}个委外入库单", scOrderEntity.getPkCorp(), bdCorpEntityList.size()); + } + + // 2024年8月27日 17:15:09 收货库存组织,应该是通过收货公司查询得出收货库存组织,目前收货公司和采购公司保持一致,那么就以采购公司带出!这个逻辑已经和佳妮确认 + BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); + bdCalbodyEntity.setDr(0); + bdCalbodyEntity.setDataSourceCode("lets_u8c"); + bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); + if (bdCalbodyEntities.size() == 0) { + Assert.state(false, "根据U8C采购公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); + } else if (bdCalbodyEntities.size() >= 2) { + Assert.state(false, "根据U8C采购公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); + } + + //入库仓库 + String facilityCode = header.getFacilityCode(); + Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); + BdStordocEntity bdStordocEntity = new BdStordocEntity(); + bdStordocEntity.setDr(0L); + bdStordocEntity.setDataSourceCode("lets_u8c"); + bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); + bdStordocEntity.setStorcode(facilityCode); + List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); + if (bdStordocEntityList.size() == 0) { + Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,无法匹配到U8C仓库", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); + } else if (bdStordocEntityList.size() >= 2) { + Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,匹配到U8C仓库多个", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); + } + + ReturnOrderHeaderDto returnOrderHeaderDto = new ReturnOrderHeaderDto(); + returnOrderHeaderDto.setPurchaseReturnOrder(purchaseReturnOrder); + returnOrderHeaderDto.setScOrderEntity(scOrderEntity); + returnOrderHeaderDto.setScOrderBEntityList(scOrderBEntityList); + returnOrderHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); + returnOrderHeaderDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); + returnOrderHeaderDto.setBdStordocEntity(bdStordocEntityList.get(0)); + returnOrderHeaderDto.setDetails(details); + returnOrderHeaderDto.setOfsPoOrder(ofsPoOrder); + + BeanUtil.copyPropertiesV2(header, returnOrderHeaderDto); + consignmachiningInSonDtoArrayList.add(returnOrderHeaderDto); + } catch (Exception e) { + logger.error("采购入库单OFS档案转换错误", e); + + String message = e.getMessage(); + if (message == null) { + message = "未知错误"; + } + //失败 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(JSON.toJSONString(headerDetailsDto));//原始数据json + integrationTaskLivingDetailsEntity.setNewTransmitInfo(JSON.toJSONString(message));//返回结果 + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(generateBusinessDate); + integrationTaskLivingDetailsEntity.setRootAppPk(header.getId()); + integrationTaskLivingDetailsEntity.setRootAppBill(header.getCode()); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); } - - // 2024年8月27日 17:15:09 收货库存组织,应该是通过收货公司查询得出收货库存组织,目前收货公司和采购公司保持一致,那么就以采购公司带出!这个逻辑已经和佳妮确认 - BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); - bdCalbodyEntity.setDr(0); - bdCalbodyEntity.setDataSourceCode("lets_u8c"); - bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); - if (bdCalbodyEntities.size() == 0) { - Assert.state(false, "根据U8C采购公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); - } else if (bdCalbodyEntities.size() >= 2) { - Assert.state(false, "根据U8C采购公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); - } - - //入库仓库 - String facilityCode = header.getFacilityCode(); - Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); - BdStordocEntity bdStordocEntity = new BdStordocEntity(); - bdStordocEntity.setDr(0L); - bdStordocEntity.setDataSourceCode("lets_u8c"); - bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); - bdStordocEntity.setStorcode(facilityCode); - List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); - if (bdStordocEntityList.size() == 0) { - Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,无法匹配到U8C仓库", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); - } else if (bdStordocEntityList.size() >= 2) { - Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,匹配到U8C仓库多个", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); - } - - ReturnOrderHeaderDto returnOrderHeaderDto = new ReturnOrderHeaderDto(); - returnOrderHeaderDto.setPurchaseReturnOrder(purchaseReturnOrder); - returnOrderHeaderDto.setScOrderEntity(scOrderEntity); - returnOrderHeaderDto.setScOrderBEntityList(scOrderBEntityList); - returnOrderHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); - returnOrderHeaderDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); - returnOrderHeaderDto.setBdStordocEntity(bdStordocEntityList.get(0)); - returnOrderHeaderDto.setDetails(details); - returnOrderHeaderDto.setOfsPoOrder(ofsPoOrder); - - BeanUtil.copyPropertiesV2(header, returnOrderHeaderDto); - consignmachiningInSonDtoArrayList.add(returnOrderHeaderDto); } //成功 } catch (Exception e) { @@ -784,6 +807,30 @@ public class ConsignmachiningInReturn extends PluginBaseEntity { } } + /** + * 2024年8月20日 15:46:10 + * 生成业务日期,以发货时间作为业务日期 + * + * @author liuyang + */ + private String createGenerateBusinessDatev2(HeaderDto header) throws Exception { + if (header != null) { + String shipAt = header.getShipAt(); + String businessFormat = null; + try { + Date dbill = DateUtil.parse(shipAt); + businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); + } catch (Exception e) { + logger.error("业务日期生成失败!", e); + } + return businessFormat; + } else { + logger.error("生成采退出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(header)); + Assert.state(false, "生成采退出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(header)); + return null; + } + } + /** * 2024年8月7日 14:58:34 * 查询税目档案 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 6c7d55b5..90dee843 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 @@ -503,11 +503,14 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { List poOrderSonDtoArrayList = new ArrayList<>(); if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { - try { - for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) { - HeaderDetailsDto headerDetailsDto = returnGoodHeaderDetailsDataDtoList.get(i); - HeaderDto header = headerDetailsDto.getHeader(); - List details = headerDetailsDto.getDetails(); + for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) { + HeaderDetailsDto headerDetailsDto = returnGoodHeaderDetailsDataDtoList.get(i); + HeaderDto header = headerDetailsDto.getHeader(); + List details = headerDetailsDto.getDetails(); + + String generateBusinessDate = null; + try { + generateBusinessDate = createGenerateBusinessDate(header); //2024年8月22日 15:30:09 如果purchaseReturnOrder为null,那么在queryPurchaseReturnOrder会抛出异常,此处不需要验证purchaseReturnOrder是否为null PurchaseReturnOrder purchaseReturnOrder = queryPurchaseReturnOrder(header.getRefOrderCode()); @@ -629,11 +632,25 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { BeanUtil.copyPropertiesV2(header, poOrderRerturnSonDto); poOrderSonDtoArrayList.add(poOrderRerturnSonDto); + } catch (Exception e) { + logger.error("档案转换失败", e); + + String message = e.getMessage(); + if (message == null) { + message = "未知错误"; + } + //失败 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(JSON.toJSONString(headerDetailsDto));//原始数据json + integrationTaskLivingDetailsEntity.setNewTransmitInfo(JSON.toJSONString(message));//返回结果 + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(generateBusinessDate); + integrationTaskLivingDetailsEntity.setRootAppPk(header.getId()); + integrationTaskLivingDetailsEntity.setRootAppBill(header.getCode()); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); } - //成功 - } catch (Exception e) { - logger.error("代理品牌采购入库单档案转换失败", e); - //失败 } } else { logger.info("queryBasicArchives对应returnGoodHeaderDetailsDataDtoList.size为0"); @@ -662,8 +679,6 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { * @author liuyang */ private String createGenerateBusinessDate(PoOrderRerturnSonDto poOrderSonDto) { - //TODO 测试 - poOrderSonDto.setShipAt("2024-08-19"); if (poOrderSonDto != null && poOrderSonDto.getShipAt() != null) { String shipAt = poOrderSonDto.getShipAt(); String businessFormat = null; @@ -681,6 +696,30 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { } } + /** + * 2024年8月20日 15:46:10 + * 生成业务日期,以发货时间作为业务日期 + * + * @author liuyang + */ + private String createGenerateBusinessDate(HeaderDto header) { + if (header != null) { + String shipAt = header.getShipAt(); + String businessFormat = null; + try { + Date dbill = DateUtil.parse(shipAt); + businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); + } catch (Exception e) { + logger.error("业务日期生成失败", e); + } + return businessFormat; + } else { + logger.error("生成采退出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(header)); + Assert.state(false, "生成采退出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(header)); + return null; + } + } + /** * 查询存货管理档案 * diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehous.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehous.java index 48ec6fdb..9a838455 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehous.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehous.java @@ -499,125 +499,148 @@ public class ProxyPurchaseWarehous extends PluginBaseEntity { StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); List details = stockinOrder.getDetails(); - //查询OFS采购订单 - OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(header.getRefOrderCode()); - Assert.notNull(ofsPoOrderData, "根据O表头编码{},无法匹配到OFS采购订单", header.getRefOrderCode()); - boolean checkResult = onlyImplementProxyOrder.onlyImplementProxyOrder(ofsPoOrderData, "DLCG"); - if (!checkResult) { - continue; + String generateBusinessDate = null; + try { + generateBusinessDate = createGenerateBusinessDate(stockinOrder); + + //查询OFS采购订单 + OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(header.getRefOrderCode()); + Assert.notNull(ofsPoOrderData, "根据O表头编码{},无法匹配到OFS采购订单", header.getRefOrderCode()); + boolean checkResult = onlyImplementProxyOrder.onlyImplementProxyOrder(ofsPoOrderData, "DLCG"); + if (!checkResult) { + continue; + } + + //采购公司 + String companyCode = header.getCompanyCode(); + Assert.notNull(companyCode, "O表头公司不能为空"); + BdCorpEntity bdCorpEntity = new BdCorpEntity(); + bdCorpEntity.setDr(0); + bdCorpEntity.setDataSourceCode("lets_u8c"); + bdCorpEntity.setUnitcode(companyCode); + List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); + if (bdCorpEntityList.size() == 0) { + Assert.state(false, "根据O货主编码{},无法匹配到U8C销售公司", companyCode); + } else if (bdCorpEntityList.size() >= 2) { + Assert.state(false, "根据O货主编码{},匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size()); + } + + //采购部门:其他 + 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()); + } + + //采购组织 + BdPurorgEntity bdPurorgEntity = new BdPurorgEntity(); + bdPurorgEntity.setDr("0"); + bdPurorgEntity.setDataSourceCode("lets_u8c"); + bdPurorgEntity.setOwnercorp(bdCorpEntityList.get(0).getPkCorp()); + List bdPurorgEntityList = iBdPurorgDao.query(bdPurorgEntity); + if (bdPurorgEntityList.size() == 0) { + Assert.state(false, "根据采购公司主键:{} 无法匹配到采购组织", bdCorpEntityList.get(0).getPkCorp()); + } else if (bdPurorgEntityList.size() >= 2) { + Assert.state(false, "根据采购公司主键:{} 匹配到多个采购组织", bdCorpEntityList.get(0).getPkCorp()); + } + + //客商基本档案(供应商类型) + //2024年8月20日 14:47:55 丽知商城、OFS 供应商客商档案、传递到U8C的客商, + //其中自定义项1作为原系统编码,因此统一传到自定义项一,已经和大家确认好了,没有关系的,放心大胆传吧,宝贝 + String shipFromCode = header.getShipFromCode(); + Assert.notNull(shipFromCode, "O供应商编码不能为空,没有办法完成业务逻辑,请配置供应商编码(采购)"); + Assert.state(!"".equals(shipFromCode.trim()), "O供应商编码不能为空,没有办法完成业务逻辑,请配置供应商编码(采购)!"); + BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); + bdCubasdocEntity.setDataSourceCode("lets_u8c"); + bdCubasdocEntity.setDr(0L); + bdCubasdocEntity.setDef1(shipFromCode); + List bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); + if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) { + Assert.state(false, "根据OFS供应商业务编码{},无法查询到U8C客商档案信息(供应商)", shipFromCode); + } else if (bdCubasdocEntityList.size() >= 2) { + Assert.state(false, "根据OFS供应商业务编码{},查询到多个U8C客商档案信息(供应商)", shipFromCode); + } + + //客商管理档案 + BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); + bdCumandocEntity1.setDataSourceCode("lets_u8c"); + bdCumandocEntity1.setDr(0L); + bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdCumandocEntity1.setCustflags(ProfilesActiveConstant.SUPPLIER); + bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc()); + List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1); + if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) { + Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); + } else if (bdCumandocEntityList.size() >= 2) { + Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); + } + + // 2024年8月20日 23:51:56 收货库存组织,应该是通过收货公司查询得出收货库存组织,目前收货公司和采购公司保持一致,那么就以采购公司带出!这个逻辑已经和佳妮确认 + BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); + bdCalbodyEntity.setDr(0); + bdCalbodyEntity.setDataSourceCode("lets_u8c"); + bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); + if (bdCalbodyEntities.size() == 0) { + Assert.state(false, "根据U8C采购公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); + } else if (bdCalbodyEntities.size() >= 2) { + Assert.state(false, "根据U8C采购公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); + } + + //收货仓库 + String facilityCode = header.getFacilityCode(); + Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); + BdStordocEntity bdStordocEntity = new BdStordocEntity(); + bdStordocEntity.setDr(0L); + bdStordocEntity.setDataSourceCode("lets_u8c"); + bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); + bdStordocEntity.setStorcode(facilityCode); + List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); + if (bdStordocEntityList.size() == 0) { + Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,无法匹配到U8C仓库", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); + } else if (bdStordocEntityList.size() >= 2) { + Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,匹配到U8C仓库多个", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); + } + + PoOrderSonDto poOrderSonDto = new PoOrderSonDto(); + poOrderSonDto.setBdCorpEntity(bdCorpEntityList.get(0)); + poOrderSonDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0)); + poOrderSonDto.setBdPurorgEntity(bdPurorgEntityList.get(0)); + poOrderSonDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0)); + poOrderSonDto.setBdCumandocEntity(bdCumandocEntityList.get(0)); + poOrderSonDto.setOfsPoOrderData(ofsPoOrderData); + poOrderSonDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); + poOrderSonDto.setBdStordocEntity(bdStordocEntityList.get(0)); + poOrderSonDto.setDetails(details); + + BeanUtil.copyPropertiesV2(header, poOrderSonDto); + poOrderSonDtoArrayList.add(poOrderSonDto); + } catch (Exception e) { + logger.error("档案转换失败", e); + + String message = e.getMessage(); + if (message == null) { + message = "未知错误"; + } + //失败 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(JSON.toJSONString(stockinOrder));//原始数据json + integrationTaskLivingDetailsEntity.setNewTransmitInfo(JSON.toJSONString(message));//返回结果 + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(generateBusinessDate); + integrationTaskLivingDetailsEntity.setRootAppPk(header.getId()); + integrationTaskLivingDetailsEntity.setRootAppBill(header.getCode()); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); } - - //采购公司 - String companyCode = header.getCompanyCode(); - Assert.notNull(companyCode, "O表头公司不能为空"); - BdCorpEntity bdCorpEntity = new BdCorpEntity(); - bdCorpEntity.setDr(0); - bdCorpEntity.setDataSourceCode("lets_u8c"); - bdCorpEntity.setUnitcode(companyCode); - List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); - if (bdCorpEntityList.size() == 0) { - Assert.state(false, "根据O货主编码{},无法匹配到U8C销售公司", companyCode); - } else if (bdCorpEntityList.size() >= 2) { - Assert.state(false, "根据O货主编码{},匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size()); - } - - //采购部门:其他 - 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()); - } - - //采购组织 - BdPurorgEntity bdPurorgEntity = new BdPurorgEntity(); - bdPurorgEntity.setDr("0"); - bdPurorgEntity.setDataSourceCode("lets_u8c"); - bdPurorgEntity.setOwnercorp(bdCorpEntityList.get(0).getPkCorp()); - List bdPurorgEntityList = iBdPurorgDao.query(bdPurorgEntity); - if (bdPurorgEntityList.size() == 0) { - Assert.state(false, "根据采购公司主键:{} 无法匹配到采购组织", bdCorpEntityList.get(0).getPkCorp()); - } else if (bdPurorgEntityList.size() >= 2) { - Assert.state(false, "根据采购公司主键:{} 匹配到多个采购组织", bdCorpEntityList.get(0).getPkCorp()); - } - - //客商基本档案(供应商类型) - //2024年8月20日 14:47:55 丽知商城、OFS 供应商客商档案、传递到U8C的客商, - //其中自定义项1作为原系统编码,因此统一传到自定义项一,已经和大家确认好了,没有关系的,放心大胆传吧,宝贝 - String shipFromCode = header.getShipFromCode(); - Assert.notNull(shipFromCode, "O供应商编码不能为空,没有办法完成业务逻辑,请配置供应商编码(采购)"); - Assert.state(!"".equals(shipFromCode.trim()), "O供应商编码不能为空,没有办法完成业务逻辑,请配置供应商编码(采购)!"); - BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); - bdCubasdocEntity.setDataSourceCode("lets_u8c"); - bdCubasdocEntity.setDr(0L); - bdCubasdocEntity.setDef1(shipFromCode); - List bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); - if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) { - Assert.state(false, "根据OFS供应商业务编码{},无法查询到U8C客商档案信息(供应商)", shipFromCode); - } else if (bdCubasdocEntityList.size() >= 2) { - Assert.state(false, "根据OFS供应商业务编码{},查询到多个U8C客商档案信息(供应商)", shipFromCode); - } - - //客商管理档案 - BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); - bdCumandocEntity1.setDataSourceCode("lets_u8c"); - bdCumandocEntity1.setDr(0L); - bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - bdCumandocEntity1.setCustflags(ProfilesActiveConstant.SUPPLIER); - bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc()); - List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1); - if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) { - Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); - } else if (bdCumandocEntityList.size() >= 2) { - Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); - } - - // 2024年8月20日 23:51:56 收货库存组织,应该是通过收货公司查询得出收货库存组织,目前收货公司和采购公司保持一致,那么就以采购公司带出!这个逻辑已经和佳妮确认 - BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); - bdCalbodyEntity.setDr(0); - bdCalbodyEntity.setDataSourceCode("lets_u8c"); - bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); - if (bdCalbodyEntities.size() == 0) { - Assert.state(false, "根据U8C采购公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); - } else if (bdCalbodyEntities.size() >= 2) { - Assert.state(false, "根据U8C采购公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); - } - - //收货仓库 - String facilityCode = header.getFacilityCode(); - Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); - BdStordocEntity bdStordocEntity = new BdStordocEntity(); - bdStordocEntity.setDr(0L); - bdStordocEntity.setDataSourceCode("lets_u8c"); - bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); - bdStordocEntity.setStorcode(facilityCode); - List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); - if (bdStordocEntityList.size() == 0) { - Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,无法匹配到U8C仓库", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); - } else if (bdStordocEntityList.size() >= 2) { - Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,匹配到U8C仓库多个", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); - } - - PoOrderSonDto poOrderSonDto = new PoOrderSonDto(); - poOrderSonDto.setBdCorpEntity(bdCorpEntityList.get(0)); - poOrderSonDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0)); - poOrderSonDto.setBdPurorgEntity(bdPurorgEntityList.get(0)); - poOrderSonDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0)); - poOrderSonDto.setBdCumandocEntity(bdCumandocEntityList.get(0)); - poOrderSonDto.setOfsPoOrderData(ofsPoOrderData); - poOrderSonDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); - poOrderSonDto.setBdStordocEntity(bdStordocEntityList.get(0)); - poOrderSonDto.setDetails(details); - - BeanUtil.copyPropertiesV2(header, poOrderSonDto); - poOrderSonDtoArrayList.add(poOrderSonDto); } //成功 } catch (Exception e) { @@ -668,6 +691,31 @@ public class ProxyPurchaseWarehous extends PluginBaseEntity { } } + /** + * 2024年8月20日 15:46:10 + * 生成业务日期,以发货时间作为业务日期 + * + * @author liuyang + */ + private String createGenerateBusinessDate(StockinOrderSearchResponse.StockinOrder stockinOrder) { + if (stockinOrder != null) { + StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); + String checkInFrom = header.getCheckInFrom(); + String businessFormat = null; + try { + Date dbill = DateUtil.parse(checkInFrom); + businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); + } catch (Exception e) { + logger.error("业务日期生成失败", e); + } + return businessFormat; + } else { + logger.error("生成采购订单入库日期失败,或者shipAt为空! json:{}", JSON.toJSON(stockinOrder)); + Assert.state(false, "生成采购订单入库日期失败,或者shipAt为空! json:{}", JSON.toJSON(stockinOrder)); + return null; + } + } + /** * 查询存货管理档案 *