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);