diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/adjust/AdjustInZZPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/adjust/AdjustInZZPluginInitializer.java index cbd45c7c..41366eab 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/adjust/AdjustInZZPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/adjust/AdjustInZZPluginInitializer.java @@ -11,9 +11,7 @@ import com.hzya.frame.plugin.lets.constant.OverallConstant; import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; import com.hzya.frame.plugin.lets.dao.IBdRdclDao; import com.hzya.frame.plugin.lets.dao.IBdSetpartDao; -import com.hzya.frame.plugin.lets.entity.BdInvbasdocEntity; -import com.hzya.frame.plugin.lets.entity.BdInvmandocEntity; -import com.hzya.frame.plugin.lets.entity.BdSetpartEntity; +import com.hzya.frame.plugin.lets.entity.*; import com.hzya.frame.plugin.lets.ofsvo.QueryOfsAdjustOrderRequestVO; import com.hzya.frame.plugin.lets.ofsvo.QueryOfsStockinOrderRequestVO; import com.hzya.frame.plugin.lets.u8cdto.GeneralBillVO_4ADto; @@ -44,6 +42,7 @@ import java.util.concurrent.locks.ReentrantLock; /** * OFS调整入库(组装入库)--->U8C组装订单 + * 使用code模式太麻烦了,转n手,使用pk模式 * */ @@ -240,6 +239,7 @@ public class AdjustInZZPluginInitializer extends PluginBaseEntity { /** * 过滤成功日志,收发类别非0106 组装入库 的过滤 + * //订单号+sku过滤 * * @return */ @@ -253,17 +253,26 @@ public class AdjustInZZPluginInitializer extends PluginBaseEntity { if(!"0106".equals(ofsAdjustOrders.get(0).getHeader().getU8ReceiptType())){ continue; } - String rootAppPk = header.getCode(); - boolean isExis = true; - IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); - integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk); - integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); - integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); - List integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity); - if (integrationTaskLivingDetailsEntities == null || integrationTaskLivingDetailsEntities.size() == 0) { - isExis = false; + List filterStockinB=new ArrayList<>(); + for (StockinOrderSearchResponse.StockinOrder.StockinB detail : stockinOrder.getDetails()) { + String rootAppPk = header.getCode()+"_"+detail.getSkuCode(); + boolean isExis = true; + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + List integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity); + if (integrationTaskLivingDetailsEntities == null || integrationTaskLivingDetailsEntities.size() == 0) { + isExis = false; + }if (!isExis) { + filterStockinB.add(detail); + } + } - if (!isExis) { + if (filterStockinB.size() == 0) {//该单全被过滤 + continue; + }else if(filterStockinB.size() != 0){ + stockinOrder.setDetails(filterStockinB); filterStockinOrders.add(stockinOrder); } } @@ -292,88 +301,154 @@ public class AdjustInZZPluginInitializer extends PluginBaseEntity { SpecialbillVO.Parentvo parentvo = new SpecialbillVO.Parentvo(); //pk_corp 公司 - parentvo.setPk_corp(ofsHeader.getCompanyCode()); + BdCorpEntity bdCorpEntity = queryU8CEntityUtil.queryBdCorpByUnitCode(ofsHeader.getCompanyCode()); + Assert.notNull(bdCorpEntity,"根据公司编码:{},未查询到公司主键,请检查U8C公司档案",ofsHeader.getCompanyCode()); + parentvo.setPk_corp(bdCorpEntity.getPkCorp()); //dbilldate 单据日期 format = ofsHeader.getCreated(); parentvo.setDbilldate(StringUtils.substring(format, 0, 10)); //coperatorid 制单人 - parentvo.setCoperatorid("tbadmin"); + parentvo.setCoperatorid(OverallConstant.getOverAllValue("u8cApiZdrPK")); //cinwarehouseid 入库仓库(审批,3.6及上版本支持) - parentvo.setCinwarehouseid(ofsHeader.getFacilityCode()); + BdStordocEntity bdStordocEntity = queryU8CEntityUtil.queryBdStordocByCode(ofsHeader.getFacilityCode()); + Assert.notNull(bdStordocEntity,"根据仓库编码:{},未查询到公司主键,请检查U8C公司档案",ofsHeader.getCompanyCode()); + parentvo.setCinwarehouseid(bdStordocEntity.getPkStordoc()); + //vnote 备注 parentvo.setVnote(ofsHeader.getNote()); + //vuserdef15,,组装单标识 + parentvo.setVuserdef15("ZZ"); + //vuserdef17,来源系统 + parentvo.setVuserdef17(ProfilesActiveConstant.sourceSystem1); + //vuserdef19,ofs调整单单号 + parentvo.setVuserdef19(ofsHeader.getCode()); + //vuserdef20,ofs调整单id + parentvo.setVuserdef20(ofsHeader.getId()); - queryBdSetPart(null,null); //子表 List childrenvo =new ArrayList<>(); - SpecialbillVO.Childrenvo children = new SpecialbillVO.Childrenvo(); + int indexNum=0;//主数量(套件数量) + int i=1;//行号 + //////////套件,每个成套件变成一张组装单, + for (StockinOrderSearchResponse.StockinOrder.StockinB detail : stockinOrder.getDetails()) { + try { + BdInvmandocEntity bdInvmandocEntity = queryBdInvmandocBySkuCodeAndPkcorp(detail.getSkuCode(), bdCorpEntity.getPkCorp()); + SpecialbillVO.Childrenvo children = new SpecialbillVO.Childrenvo(); + //行号 + children.setCrowno(i++ + "0"); + //fbillrowflag 类型(0:成套件,1:配件) + children.setFbillrowflag("0"); + //cinventoryid 存货(存货管理档案) + children.setCinventoryid(bdInvmandocEntity.getPkInvmandoc()); + //dshldtransnum 数量 + children.setDshldtransnum(detail.getRequestQty()); + //cwarehouseid 仓库 + children.setCwarehouseid(bdStordocEntity.getPkStordoc()); - ///////////////////////////////////////////////////////////////////////////////////////////// + //套件数量 + indexNum = Integer.parseInt(detail.getRequestQty()); + childrenvo.add(children); + //配件 + List bdSetpartEntities = queryBdSetPart(bdInvmandocEntity.getPkInvmandoc()); + for (BdSetpartEntity bdSetpartEntity : bdSetpartEntities) { + SpecialbillVO.Childrenvo children1 = new SpecialbillVO.Childrenvo(); + //行号 + children1.setCrowno(i++ + "0"); + //fbillrowflag 类型(0:成套件,1:配件) + children1.setFbillrowflag("1"); + //cinventoryid 存货(存货管理档案) + children1.setCinventoryid(bdSetpartEntity.getPkInvmandocpart()); + //dshldtransnum 数量 套件数*配料表数 + children1.setDshldtransnum(String.valueOf(indexNum*Integer.parseInt(bdSetpartEntity.getChildsnum()))); + //cwarehouseid 仓库 + children1.setCwarehouseid(bdStordocEntity.getPkStordoc()); + childrenvo.add(children1); + } + specialbillVO.setParentvo(parentvo); + specialbillVO.setChildrenvo(childrenvo); + System.out.println(specialbillVO); + mapStr="{\"specialbillvo\": ["+JSONUtil.toJsonStr(specialbillVO)+"]}"; + System.out.println(mapStr); - String dataJson = JSONUtil.toJsonStr(specialbillVO); - mapStr = "{\"specialbillvo\":[" + dataJson + "]}"; + //推送 + ZTResult ztResult = pushU8CByApiCode.pushByPK(OverallConstant.getOverAllValue("special4lSaveCode"), mapStr); + //两层判断,一层中台转发,一层u8c返回 + if ("false".equals(ztResult.getFlag())) { + //转发失败 + response = JSONUtil.toJsonStr(ztResult.getAttribute()); + Assert.state(false, "丽知:OFS调整入库(组装入库)--->U8C组装订单,中台转发失败,失败原因:{}", ztResult.getAttribute()); + } + Attribute attribute = ztResult.getAttribute(); + System.out.println(attribute); + boolean isSuccess = false; + String vbillcode = ""; + String cSpecialHId = ""; + if ("success".equals(attribute.getStatus())) { + isSuccess = true; + String data = attribute.getData(); + SpecialbillVO resSpecialbillVO = resultDataHandle(data); + System.out.println(resSpecialbillVO); + vbillcode = resSpecialbillVO.getParentvo().getVbillcode(); + cSpecialHId = resSpecialbillVO.getParentvo().getCspecialhid(); + } + if (!isSuccess) { + Assert.state(false, "推送U8C--> 丽知:OFS调整入库(组装入库)--->U8C组装订单 失败 接口返回结果:{} 接口入参:{}", response, mapStr); + } - //推送 -// ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("special4lSaveCode"), mapStr); -// -// //两层判断,一层中台转发,一层u8c返回 -// if ("false".equals(ztResult.getFlag())) { -// //转发失败 -// response = JSONUtil.toJsonStr(ztResult.getAttribute()); -// Assert.state(false, "丽知:OFS调整入库(组装入库)--->U8C组装订单.中台转发失败,失败原因:{}", ztResult.getAttribute()); -// } -// Attribute attribute = ztResult.getAttribute(); -// System.out.println(attribute); -// -// boolean isSuccess = false; -// String vbillcode = ""; -// if ("success".equals(attribute.getStatus())) { -// isSuccess = true; -// String data = attribute.getData(); -// GeneralBillVO_4ADto resGeneralBillVO = resultDataHandle(data); -// System.out.println(resGeneralBillVO); -// vbillcode = resGeneralBillVO.getParentvo().getVbillcode(); -// } -// if (!isSuccess) { -// Assert.state(false, "推送U8C--> 丽知:OFS调整入库(组装入库)--->U8C组装订单 失败 接口返回结果:{} 接口入参:{}", response, mapStr); -// } + //成功 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); + integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(response); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(format); + integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode+"_"+detail.getSkuCode()); + integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode); + integrationTaskLivingDetailsEntity.setNewSystemNumber(vbillcode); + integrationTaskLivingDetailsEntity.setNewSystemPrimary(cSpecialHId); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); - //成功 -// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); -// integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); -// integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); -// integrationTaskLivingDetailsEntity.setNewTransmitInfo(response); -// integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); -// integrationTaskLivingDetailsEntity.setBusinessDate(format); -// integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode); -// integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode); -// integrationTaskLivingDetailsEntity.setRootAppBill(vbillcode); -// integrationTaskLivingDetailsEntity.setDef1(vbillcode); -// integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); -// saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); + }catch (Exception e){//内层catch + e.printStackTrace(); + logger.error("推送U8C,丽知:OFS调整入库(组装入库)--->U8C组装订单失败,失败原因:" + e); + //失败 + ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class); + String ErrMessage = "推送U8C,丽知:OFS调整入库(组装入库)--->U8C组装订单失败,失败原因:" + reusltStrDto.getErrormsg(); + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(format); + integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode+"_"+detail.getSkuCode()); + integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); - } catch (Exception e) { + } + } + } catch (Exception e) {//外层catch 多个物料,多条记录 e.printStackTrace(); -// logger.error("推送U8C,丽知:OFS调整入库(组装入库)--->U8C组装订单失败,失败原因:" + e); -// -// ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class); -// -// String ErrMessage = "推送U8C,丽知:OFS调整入库(组装入库)--->U8C组装订单失败,失败原因:" + reusltStrDto.getErrormsg(); -// //失败 -// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); -// integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); -// integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); -// integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); -// integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); -// integrationTaskLivingDetailsEntity.setBusinessDate(format); -// integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode); -// integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode); -// integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); -// saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); + logger.error("推送U8C,丽知:OFS调整入库(组装入库)--->U8C组装订单失败,失败原因:" + e); + String ErrMessage = "推送U8C,丽知:OFS调整入库(组装入库)--->U8C组装订单失败,失败原因:" + e.getMessage(); + //失败 + for (StockinOrderSearchResponse.StockinOrder.StockinB detail : stockinOrder.getDetails()) { + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(format); + integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode+"_"+detail.getSkuCode()); + integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); + } } } } @@ -414,13 +489,13 @@ public class AdjustInZZPluginInitializer extends PluginBaseEntity { } - private GeneralBillVO_4ADto resultDataHandle(String resultData) { + private SpecialbillVO resultDataHandle(String resultData) { try { if (resultData != null && !"".equals(resultData)) { if (resultData.contains("[")) { resultData = resultData.substring(1, resultData.length() - 1); } - return JSON.parseObject(resultData, GeneralBillVO_4ADto.class); + return JSON.parseObject(resultData, SpecialbillVO.class); } } catch (Exception e) { e.printStackTrace(); @@ -452,12 +527,9 @@ public class AdjustInZZPluginInitializer extends PluginBaseEntity { /** - * 查询成套件信息,因为是调整入库,只有套件信息 - * @param skuCode ofs sku编码 - * @param pkCorp 公司编码 - * 套件 存货管理档案的主键 + * 根据存货编码+公司主键查询查询货品管理档案 */ - public void queryBdSetPart(String skuCode,String pkCorp){ + public BdInvmandocEntity queryBdInvmandocBySkuCodeAndPkcorp(String skuCode,String pkCorp){ //查询存货基本档案 BdInvbasdocEntity bdInvbasdocEntity = queryU8CEntityUtil.queryBdInvbasdocByCode(skuCode); @@ -470,15 +542,25 @@ public class AdjustInZZPluginInitializer extends PluginBaseEntity { if (bdInvmandocEntity == null) { Assert.state(false,"根据存货编码:{},存货基本档案主键:{},公司编码:{},查询存货管理档案失败,请检查是否分配。",skuCode,bdInvbasdocEntity.getPkInvbasdoc(),pkCorp); } + return bdInvmandocEntity; + } + + /** + * 查询成套件信息,因为是调整入库,只有套件信息 + * @param pkinvmandoc 套件存货管理档案 + * 套件 存货管理档案的主键 + * @return 配件的 存货管理档案 + */ + public List queryBdSetPart(String pkinvmandoc){ //查询配件信息 BdSetpartEntity bdSetpartEntity = new BdSetpartEntity(); - bdSetpartEntity.setPkInvmandocpart(bdInvmandocEntity.getPkInvmandoc()); + bdSetpartEntity.setPkInvmandocset(pkinvmandoc); bdSetpartEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); List query = bdSetpartDao.query(bdSetpartEntity); if(query.size()==0){ Assert.state(false,"OFS调整入库(组装),查询"); } - - + return query; } + } diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/transfer/TransferTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/transfer/TransferTest.java index 606ea887..b707cb52 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/transfer/TransferTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/transfer/TransferTest.java @@ -2,6 +2,7 @@ package com.hzya.frame.plugin.lets.plugin.transfer; import com.hzya.frame.WebappApplication; import com.hzya.frame.plugin.lets.plugin.adjust.AdjustInPluginInitializer; +import com.hzya.frame.plugin.lets.plugin.adjust.AdjustInZZPluginInitializer; import com.hzya.frame.plugin.lets.plugin.adjust.AdjustOutPluginInitializer; import org.junit.Test; import org.junit.runner.RunWith; @@ -23,6 +24,8 @@ public class TransferTest { private AdjustInPluginInitializer adjustInPluginInitializer; @Autowired private AdjustOutPluginInitializer adjustOutPluginInitializer; + @Autowired + private AdjustInZZPluginInitializer adjustInZZPluginInitializerm; ////////////////////////////////////////////////////////////////////////////////////调拨订单 // @Test @@ -99,4 +102,11 @@ public class TransferTest { adjustOutPluginInitializer.queryOfsAdjustOrders("LETS-AH2024082200000001"); } + ////////////////////////////////////////////////////////////////////////////////////组装单 + @Test + public void t50(){ + adjustInZZPluginInitializerm.start("LETS-RE2024091200000002"); + } + ////////////////////////////////////////////////////////////////////////////////////组装单 + }