From 69ebe25d376d6dfdddfd5b7aa0d9ee9e34c6cf9e Mon Sep 17 00:00:00 2001 From: zhengyf Date: Tue, 10 Sep 2024 15:46:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BD=E7=9F=A5=EF=BC=9A=E5=AD=98=E8=B4=A7?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=A1=A3=E6=A1=88=E8=87=AA=E5=8A=A8=E5=88=86?= =?UTF-8?q?=E9=85=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/GoodsAutoAllotPluginInitializer.java | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsAutoAllotPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsAutoAllotPluginInitializer.java index 1f333ea8..2afd0da3 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsAutoAllotPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsAutoAllotPluginInitializer.java @@ -13,9 +13,13 @@ import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; import com.hzya.frame.plugin.lets.dao.IBdInvbasdocDao; import com.hzya.frame.plugin.lets.entity.BdInvbasdocEntity; import com.hzya.frame.plugin.lets.u8cdto.GoodsAutoAllotVO; +import com.hzya.frame.plugin.lets.u8cdto.InvBasDocVO; import com.hzya.frame.plugin.lets.u8cdto.ReusltStrDto; import com.hzya.frame.plugin.lets.util.PushDataByU8cUtil; import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil; +import com.hzya.frame.plugin.lets.util.pushData.Attribute; +import com.hzya.frame.plugin.lets.util.pushData.PushU8CByApiCode; +import com.hzya.frame.plugin.lets.util.pushData.ZTResult; import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao; import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; import com.hzya.frame.u8c.ax.entity.Ass; @@ -76,6 +80,8 @@ public class GoodsAutoAllotPluginInitializer extends PluginBaseEntity { @Autowired private PushDataByU8cUtil pushDataByU8cUtil; @Autowired + private PushU8CByApiCode pushU8CByApiCode; + @Autowired private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil; @Override @@ -124,10 +130,10 @@ public class GoodsAutoAllotPluginInitializer extends PluginBaseEntity { * 按存货基本档案code */ public void start(String invcode) { + String[] split = invcode.split("_"); try { BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); -// bdInvbasdocEntity.setPkInvbasdoc(invcode); - bdInvbasdocEntity.setInvcode(invcode); + bdInvbasdocEntity.setInvcode(split[0]); bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); List bdInvbasdocEntityList = bdInvbasdocDao.query(bdInvbasdocEntity); if (bdInvbasdocEntityList.size() == 0) { @@ -186,7 +192,7 @@ public class GoodsAutoAllotPluginInitializer extends PluginBaseEntity { public List filter(List bdInvbasdocEntityList) { List filterInvbasdocList = new ArrayList<>(); for (BdInvbasdocEntity bdInvbasdocEntity : bdInvbasdocEntityList) { - String rootAppPk = bdInvbasdocEntity.getInvcode(); + String rootAppPk = bdInvbasdocEntity.getInvcode()+"_"+bdInvbasdocEntity.getTs(); boolean isExis = true; IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk); @@ -215,34 +221,37 @@ public class GoodsAutoAllotPluginInitializer extends PluginBaseEntity { String createtime = bdInvbasdocEntity.getCreatetime(); //存货档案主键 - String pkInvbasdoc = bdInvbasdocEntity.getPkInvbasdoc(); + String pkInvbasdoc = bdInvbasdocEntity.getInvcode(); String mapStr = ""; + String response = ""; try { - List goodsAutoAllotVOS = new ArrayList<>(); GoodsAutoAllotVO goodsAutoAllotVO = new GoodsAutoAllotVO(); //存货基本档案主键 goodsAutoAllotVO.setPk_invbasdoc(pkInvbasdoc); - goodsAutoAllotVOS.add(goodsAutoAllotVO); - Map map = new HashMap<>(); - String jsonStr = JSONUtil.toJsonStr(goodsAutoAllotVOS); - map.put("invbasdocvo", jsonStr); - mapStr = JSONUtil.toJsonStr(map); + String jsonStr = JSONUtil.toJsonStr(goodsAutoAllotVO); + mapStr = "{\"invbasdocvo\":["+jsonStr+"]}"; - String response = pushDataByU8cUtil.pushU8CByPK(OverallConstant.getOverAllValue("bdinvclAllot"), mapStr); - System.out.println(response); + ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("bdinvclAllotCode"), mapStr); + //两层判断,一层中台转发,一层u8c返回 + Attribute attribute = ztResult.getAttribute(); + + if ("false".equals(ztResult.getFlag())) { + //转发失败 + response=JSONUtil.toJsonStr(ztResult.getAttribute()); + Assert.state(false, "丽知:U8C->存货基本档案自动分配全公司,中台转发失败,失败原因:{}", ztResult.getAttribute()); + } boolean isSuccess = false; - if (response != null && !"".equals(response)) { - ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class); - if ("success".equals(reusltStrDto.getStatus())) { - isSuccess = true; - } + if ("success".equals(attribute.getStatus())) { + isSuccess = true; + String data = attribute.getData(); + System.out.println(data); } if (!isSuccess) { - Assert.state(false, "推送U8C--> U8C->存货基本档案自动分配全公司 失败 接口返回结果:{} 接口入参:{}", response, jsonStr); + Assert.state(false, "丽知:U8C->存货基本档案自动分配全公司 失败 接口返回结果:{} 接口入参:{}", attribute.getErrormsg(), mapStr); } //成功 @@ -252,7 +261,7 @@ public class GoodsAutoAllotPluginInitializer extends PluginBaseEntity { integrationTaskLivingDetailsEntity.setNewTransmitInfo(response); integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); integrationTaskLivingDetailsEntity.setBusinessDate(createtime); - integrationTaskLivingDetailsEntity.setRootAppPk(pkInvbasdoc); + integrationTaskLivingDetailsEntity.setRootAppPk(pkInvbasdoc+"_"+bdInvbasdocEntity.getTs()); integrationTaskLivingDetailsEntity.setRootAppBill(bdInvbasdocEntity.getInvcode()); integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); @@ -266,7 +275,7 @@ public class GoodsAutoAllotPluginInitializer extends PluginBaseEntity { integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); integrationTaskLivingDetailsEntity.setBusinessDate(createtime); - integrationTaskLivingDetailsEntity.setRootAppPk(pkInvbasdoc); + integrationTaskLivingDetailsEntity.setRootAppPk(pkInvbasdoc+"_"+bdInvbasdocEntity.getTs()); integrationTaskLivingDetailsEntity.setRootAppBill(bdInvbasdocEntity.getInvcode()); integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);