From ca957098678acb01b6540efb8784d3d60047958b Mon Sep 17 00:00:00 2001 From: zhengyf Date: Sat, 24 Aug 2024 23:15:52 +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=88=86=E7=B1=BB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/lets/constant/OverallConstant.java | 3 + .../plugin/lets/entity/BdInvclEntity.java | 1 + .../lets/ofsvo/QueryOfsSKUClassRequestVO.java | 3 + .../base/SKUClassPluginInitializer.java | 485 ++++++++++++++---- .../plugin/lets/plugin/base/BaseTest.java | 6 +- .../lets/plugin/transfer/TransferTest.java | 7 +- .../OFSSKUClassSearchResponse.java | 5 +- 7 files changed, 403 insertions(+), 107 deletions(-) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java index cdee559e..062b801e 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java @@ -28,8 +28,11 @@ public class OverallConstant { private static void loadPublic() { //存货分类 + prodOverPublic.put("bdinvclSaveCode", "8000370025");//存货分类新增 prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货分类新增 + prodOverPublic.put("bdinvclUpdateCode", "8000370026");//存货分类修改 prodOverPublic.put("bdinvclUpdate", "/u8cloud/api/uapbd/bdinvcl/update");//存货分类修改 + prodOverPublic.put("bdinvclDeleteCode", "8000370027");//存货分类删除 prodOverPublic.put("bdinvclDelete", "/u8cloud/api/uapbd/bdinvcl/delete");//存货分类删除 //存货基本档案 prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货基本档案新增 diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdInvclEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdInvclEntity.java index 48612dc6..53357da7 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdInvclEntity.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdInvclEntity.java @@ -41,6 +41,7 @@ public class BdInvclEntity extends BaseEntity { private String pk_corp; /** 存货分类主键 */ private String pkInvcl; + private String pk_invcl; /** 封存标志 */ private String sealdate; /** 时间戳 */ diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSKUClassRequestVO.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSKUClassRequestVO.java index 658215a0..5dc3aced 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSKUClassRequestVO.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSKUClassRequestVO.java @@ -14,6 +14,9 @@ public class QueryOfsSKUClassRequestVO { /** 组织 */ private String clientCode; + private String lastUpdated_start; + private String lastUpdated_end; + private String companyCode; private String cInvCCode; private String status; diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/SKUClassPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/SKUClassPluginInitializer.java index ca9bb2fb..0c594dce 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/SKUClassPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/SKUClassPluginInitializer.java @@ -9,11 +9,17 @@ import com.alibaba.fastjson.JSONObject; import com.hzya.frame.base.PluginBaseEntity; import com.hzya.frame.plugin.lets.constant.OverallConstant; import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; +import com.hzya.frame.plugin.lets.dao.IBdInvclDao; +import com.hzya.frame.plugin.lets.dao.impl.BdInvclDaoImpl; import com.hzya.frame.plugin.lets.entity.BdInvclEntity; import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSKUClassRequestVO; +import com.hzya.frame.plugin.lets.u8cdto.GeneralBillVO_4IDto; 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.ttxofs.basics.ReturnMessageBasics; @@ -43,6 +49,11 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.locks.ReentrantLock; +/** + * 丽知:OFS货品档案分类--->U8C货品档案分类(XX-XXX-XXXX) + * 传递时需要区分上下级,需要先XX 在XXXXX 最后XXXXXXXXX + * 分组匹配查询。 + */ public class SKUClassPluginInitializer extends PluginBaseEntity { Logger logger = LoggerFactory.getLogger(SKUClassPluginInitializer.class); @@ -82,20 +93,57 @@ public class SKUClassPluginInitializer extends PluginBaseEntity { @Autowired private PushDataByU8cUtil pushDataByU8cUtil; @Autowired + private PushU8CByApiCode pushU8CByApiCode; + @Autowired private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao; @Autowired private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil; @Autowired private OfsUnifiedService ofsUnifiedService; + @Autowired + private IBdInvclDao bdInvclDao; + @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { + try { + logger.info("调用:" + getPluginName() + "-插件"); + String prod = "prod"; + String param = String.valueOf(requestJson.get("param")); + if (requestJson != null && ProfilesActiveConstant.TYPE_DATE.equals(requestJson.get("type"))) { + //按日期 + if (param != null && !"".equals(param)) { + String[] split = param.split("/"); + if (!(split.length == 2)) { + Assert.state(false, "时间格式传递不正确"); + } + Assert.notNull(split[0], "开始时间不能为空"); + Assert.notNull(split[1], "结束时间不能为空"); + start(split[0], split[1]); + } + } else if (requestJson != null && ProfilesActiveConstant.TYPE_VBILLCODE.equals(requestJson.get("type"))) { + //按单号 + if (param != null && !"".equals(param)) { + start(param); + } + } else if (ProfilesActiveConstant.TYPE_DETAIL_ERROR.equals(requestJson.get("type"))) { + String integrationTaskLivingDetails = (String) requestJson.get("integration_task_living_details_id"); + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = saveOrUpdateBusinessLogUtil.queryIntegrationTaskLivingDetailsEntity(integrationTaskLivingDetails); + start(integrationTaskLivingDetailsEntity.getRootAppPk()); + } else if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(prod)) { + //默认 + start(); + } + } catch (Exception e) { + e.printStackTrace(); + logger.error("executeBusiness方法抛出异常", e); + } return null; } /** - * 默认推送 + * 全量拉取。ofs对比u8c, */ public void start() { try { @@ -107,13 +155,15 @@ public class SKUClassPluginInitializer extends PluginBaseEntity { String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"); QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO = new QueryOfsSKUClassRequestVO(); -// queryOfsSKUClassRequestVO.setCreated_start(start); -// queryOfsSKUClassRequestVO.setCreated_end(end); - queryOfsSKUClassRequestVO.setClientCode("LETS"); - queryOfsSKUClassRequestVO.setPageNo(1); - queryOfsSKUClassRequestVO.setPageSize(500); + queryOfsSKUClassRequestVO.setLastUpdated_start(startTimeStr); + queryOfsSKUClassRequestVO.setLastUpdated_end(endTimeStr); List skuClasses = querySkuClass(queryOfsSKUClassRequestVO); - System.out.println(skuClasses); + + //过滤日志 + List filterSKUClasss = filterData(skuClasses); + + //推送 + implement(filterSKUClasss); } catch (Exception e) { @@ -126,7 +176,16 @@ public class SKUClassPluginInitializer extends PluginBaseEntity { */ public void start(String className) { try { - implement(); + QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO = new QueryOfsSKUClassRequestVO(); + queryOfsSKUClassRequestVO.setCInvCCode(className); + List skuClasses = querySkuClass(queryOfsSKUClassRequestVO); + + //过滤日志 + List filterGoodsClass = filterData(skuClasses); + + //推送 + implement(filterGoodsClass); + } catch (Exception e) { logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,start(String className)方法报错:", e); } @@ -141,115 +200,293 @@ public class SKUClassPluginInitializer extends PluginBaseEntity { Date business_end = DateUtil.parse(endTime); String start = DateUtil.format(business_start, "yyyy-MM-dd") + " 00:00:00"; String end = DateUtil.format(business_end, "yyyy-MM-dd") + " 23:59:59"; - - QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO = new QueryOfsSKUClassRequestVO(); - queryOfsSKUClassRequestVO.setCreated_start(start); - queryOfsSKUClassRequestVO.setCreated_end(end); - queryOfsSKUClassRequestVO.setClientCode("LETS"); - queryOfsSKUClassRequestVO.setPageNo(1); - queryOfsSKUClassRequestVO.setPageSize(500); - querySkuClass(queryOfsSKUClassRequestVO); + queryOfsSKUClassRequestVO.setLastUpdated_start(start); + queryOfsSKUClassRequestVO.setLastUpdated_end(end); + List skuClasses = querySkuClass(queryOfsSKUClassRequestVO); + //过滤日志 + List filterGoodsClass = filterData(skuClasses); + + //推送 + implement(filterGoodsClass); } catch (Exception e) { logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,start(String startTime, String endTime)方法报错:", e); } } - public void filterGoodsClass() { - return; + public List filterData(List skuClasses) { + List filterSKUClasss = new ArrayList<>(); + for (OFSSKUClassSearchResponse.SKUClass skuClass : skuClasses) { + String rootAppPk = skuClass.getCInvCCode()+"_"+skuClass.getLastUpdated(); + 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) { + filterSKUClasss.add(skuClass); + } + } + return filterSKUClasss; } /** * U8C分类规则 XX-XXX-XX,自动截断 * eg: - * 一级:AA - * 二级:AA001,自动识别为AA的下级 - * 三级:AA00101自动识别为AA001的下级 + * 一级:AA + * 二级:AA001,自动识别为AA的下级 的001 + * 三级:AA0010001自动识别为AA001的下级 的0001 */ - public void implement() { - - //生成业务日期 - String businessFormat = ""; - String mapStr=""; - - - String invclasscode=null; - String invclassname=null; - try { - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 定义日期格式 - Date date = new Date(System.currentTimeMillis()); // 创建Date对象 - businessFormat = sdf.format(date); // 将Date对象格式化为字符串 - - - + public void implement(List filterSKUClasss) { + String mapStr=null; + String businessFormat=null; + for (OFSSKUClassSearchResponse.SKUClass skuClass : filterSKUClasss) { + businessFormat=skuClass.getLastUpdated(); List bdInvclEntities = new ArrayList<>(); + try { + String url = null; + System.out.println(skuClass); + String skuId = skuClass.getId(); + //查询该id再u8c是否有数据,没有则是新增,有则是修改 + BdInvclEntity bdInvclEntity = new BdInvclEntity(); + bdInvclEntity.setDr(0); + bdInvclEntity.setForinvname(skuId); + bdInvclEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); + List bdInvclEntityList = bdInvclDao.query(bdInvclEntity); - BdInvclEntity bdInvclEntity = new BdInvclEntity(); - - //分类编码-invclasscode - invclasscode = "AA004"; - bdInvclEntity.setInvclasscode(invclasscode); - - //分类名称-invclassname - invclassname = "分类名称:AA004"; - - bdInvclEntity.setInvclassname(invclassname); - //公司编码-pk_corp - String pk_corp = "1001"; - bdInvclEntity.setPk_corp(pk_corp); - //分类级别-invclasslevel - bdInvclEntities.add(bdInvclEntity); - - String jsonStr = JSONUtil.toJsonStr(bdInvclEntities); - - Map map = new HashMap<>(); - map.put("invcl", jsonStr); - mapStr = JSONUtil.toJsonStr(map); - - String response = pushDataByU8cUtil.pushU8CByPK(OverallConstant.getOverAllValue("bdinvclSave"), mapStr); - System.out.println(response); - boolean isSuccess = false; - if (response != null && !"".equals(response)) { - ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class); - if ("success".equals(reusltStrDto.getStatus())) { - isSuccess = true; + BdInvclEntity bdInvcl = new BdInvclEntity(); + if (bdInvclEntityList.size() == 0) { + bdInvclEntity.setForinvname(null); + bdInvclEntity.setInvclasscode(skuClass.getCInvCCode()); + bdInvclEntity.setInvclassname(skuClass.getCInvCName()); + List bdInvclEntityList1 = bdInvclDao.query(bdInvclEntity); + System.out.println(bdInvclEntityList1); + if (bdInvclEntityList1.size()==1) { + //修改 + url = OverallConstant.getOverAllValue("bdinvclUpdateCode"); + bdInvclEntity.setPk_invcl(bdInvclEntityList1.get(0).getPkInvcl()); + }else if (bdInvclEntityList1.size()==0) { + //新增 + url = OverallConstant.getOverAllValue("bdinvclSaveCode"); + } + } else if (bdInvclEntityList.size() == 1) { + //修改 + url = OverallConstant.getOverAllValue("bdinvclUpdateCode"); + bdInvclEntity.setPk_invcl(bdInvclEntityList.get(0).getPkInvcl()); + } else { + Assert.state(false, ""); } + + //组装数据 + //分类编码-invclasscode + bdInvclEntity.setInvclasscode(skuClass.getCInvCCode()); + //分类名称-invclassname + bdInvclEntity.setInvclassname(skuClass.getCInvCName()); + //公司编码-pk_corp + bdInvclEntity.setPk_corp("0001"); + //外文名 forinvname(ofs存货分类id) + bdInvclEntity.setForinvname(skuId); + + //推送 + bdInvclEntities.add(bdInvclEntity); + String jsonStr = JSONUtil.toJsonStr(bdInvclEntities); + Map map = new HashMap<>(); + map.put("invcl", jsonStr); + mapStr = JSONUtil.toJsonStr(map); + ZTResult ztResult = pushU8CByApiCode.pushByCode(url, mapStr); + //两层判断,一层中台转发,一层u8c返回 + if ("false".equals(ztResult.getFlag())) { + //转发失败 + Assert.state(false, "丽知:OFS货品档案分类--->U8C货品档案分类.中台转发失败,失败原因:{}", ztResult.getAttribute().getErrormsg()); + } + Attribute attribute = ztResult.getAttribute(); + System.out.println(attribute); + + boolean isSuccess = false; + String invclasscode = ""; + if ("success".equals(attribute.getStatus())) { + isSuccess = true; + String data = attribute.getData(); + BdInvclEntity resBdInvclEntity = resultDataHandle(data); + System.out.println(resBdInvclEntity); + invclasscode = resBdInvclEntity.getInvclasscode(); + } + if (!isSuccess) { + Assert.state(false, "丽知:OFS货品档案分类--->U8C货品档案分类 失败 接口返回结果:{} 接口入参:{}", attribute.getErrormsg(), mapStr); + } + //成功 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); + integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData()); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); + integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode+"_"+businessFormat); + integrationTaskLivingDetailsEntity.setRootAppBill(invclasscode); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); + }catch (Exception e){ + e.printStackTrace(); + logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,implement()方法报错:", e); + //失败 + String ErrMessage = e.getMessage(); + + //失败 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); + integrationTaskLivingDetailsEntity.setRootAppPk(skuClass.getCInvCCode()+"_"+businessFormat); + integrationTaskLivingDetailsEntity.setRootAppBill(skuClass.getCInvCCode()); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); } - if (!isSuccess) { - Assert.state(false, "推送U8C-->丽知:OFS货品档案分类--->U8C货品档案分类失败 接口返回结果:{} 接口入参:{}", response, jsonStr); - } - //成功 - IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); - integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); - integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); - integrationTaskLivingDetailsEntity.setNewTransmitInfo(response); - integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); - integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); - integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode); - integrationTaskLivingDetailsEntity.setRootAppBill(invclassname); - integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); - saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); - } catch (Exception e) { - e.printStackTrace(); - logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,implement()方法报错:", e); - //失败 - String ErrMessage = e.getMessage(); - IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); - integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); - integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); - integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); - integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); - integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); - integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode); - integrationTaskLivingDetailsEntity.setRootAppBill(invclassname); - integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); - saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); } + } +// +// //查询pk_corp=0001下的所有分类 +// List bdInvclEntities = queryU8CAllInvcl(); +// //将pk_corp=0001下的所有分类分为123级 +// List u8cLevel1 = new ArrayList<>();//length==2 +// List u8cLevel2 = new ArrayList<>();//length==5 +// List u8cLevel3 = new ArrayList<>();//length==9 +// for (BdInvclEntity bdInvclEntity : bdInvclEntities) { +// switch (bdInvclEntity.getInvclasscode().length()) { +// case 2: System.out.println("U8C:1级分类:" + bdInvclEntity.getInvclasscode()); u8cLevel1.add(bdInvclEntity); break; +// case 5: System.out.println("U8C:2级分类:" + bdInvclEntity.getInvclasscode()); u8cLevel2.add(bdInvclEntity); break; +// case 9: System.out.println("U8C:3级分类:" + bdInvclEntity.getInvclasscode()); u8cLevel3.add(bdInvclEntity); break; +// } +// } +// +// List ofsLevel1 = new ArrayList<>();//length==2 +// List ofsLevel2 = new ArrayList<>();//length==5 +// List ofsLevel3 = new ArrayList<>();//length==9 +// for (OFSSKUClassSearchResponse.SKUClass ofsSKUClass : filterSKUClasss) { +// switch (ofsSKUClass.getCInvCCode().length()) { +// case 2: System.out.println("OFS:1级分类:" + ofsSKUClass.getCInvCCode()); ofsLevel1.add(ofsSKUClass); break; +// case 5: System.out.println("OFS:2级分类:" + ofsSKUClass.getCInvCCode()); ofsLevel2.add(ofsSKUClass); break; +// case 9: System.out.println("OFS:3级分类:" + ofsSKUClass.getCInvCCode()); ofsLevel3.add(ofsSKUClass); break; +// } +// } +// System.out.println(1111); +// +// +// //分三次推送,按顺序123 +// if(ofsLevel1!=null&&ofsLevel1.size()>0){ +// specificImplement(ofsLevel1,u8cLevel1); +// } +// if(ofsLevel2!=null&&ofsLevel2.size()>0){ +// specificImplement(ofsLevel2,u8cLevel2); +// } +// if(ofsLevel3!=null&&ofsLevel3.size()>0){ +// specificImplement(ofsLevel3,u8cLevel3); +// } + + +// //生成业务日期 +// String businessFormat = ""; +// String mapStr=""; +// +// +// String invclasscode=null; +// String invclassname=null; +// try { +// +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 定义日期格式 +// Date date = new Date(System.currentTimeMillis()); // 创建Date对象 +// businessFormat = sdf.format(date); // 将Date对象格式化为字符串 +// +// +// +// +// List bdInvclEntities = new ArrayList<>(); +// +// BdInvclEntity bdInvclEntity = new BdInvclEntity(); +// +// //分类编码-invclasscode +// invclasscode = "AA004"; +// bdInvclEntity.setInvclasscode(invclasscode); +// +// //分类名称-invclassname +// invclassname = "分类名称:AA004"; +// +// bdInvclEntity.setInvclassname(invclassname); +// //公司编码-pk_corp +// String pk_corp = "1001"; +// bdInvclEntity.setPk_corp(pk_corp); +// //分类级别-invclasslevel +// bdInvclEntities.add(bdInvclEntity); +// +// String jsonStr = JSONUtil.toJsonStr(bdInvclEntities); +// +// Map map = new HashMap<>(); +// map.put("invcl", jsonStr); +// mapStr = JSONUtil.toJsonStr(map); +// +// String response = pushDataByU8cUtil.pushU8CByPK(OverallConstant.getOverAllValue("bdinvclSave"), mapStr); +// System.out.println(response); +// boolean isSuccess = false; +// if (response != null && !"".equals(response)) { +// ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class); +// if ("success".equals(reusltStrDto.getStatus())) { +// isSuccess = true; +// } +// } +// if (!isSuccess) { +// Assert.state(false, "推送U8C-->丽知:OFS货品档案分类--->U8C货品档案分类失败 接口返回结果:{} 接口入参:{}", response, jsonStr); +// } +// //成功 +// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); +// integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); +// integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); +// integrationTaskLivingDetailsEntity.setNewTransmitInfo(response); +// integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); +// integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); +// integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode); +// integrationTaskLivingDetailsEntity.setRootAppBill(invclassname); +// integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); +// saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); +// +// +// } catch (Exception e) { +// e.printStackTrace(); +// logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,implement()方法报错:", e); +// //失败 +// String ErrMessage = e.getMessage(); +// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); +// integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); +// integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); +// integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); +// integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); +// integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); +// integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode); +// integrationTaskLivingDetailsEntity.setRootAppBill(invclassname); +// integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); +// saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); +// } +// } + + /** + * 具体推送,支持新增,删除,修改 + * 根据编码和名称对应 + * ofs的id传U8C的forinvname + * + * @param ofsLevel OFS中的存货分类 + * @param u8cLevel U8C中的存货分类 + */ + public void specificImplement(List ofsLevel,List u8cLevel){ + + } @@ -257,19 +494,63 @@ public class SKUClassPluginInitializer extends PluginBaseEntity { * OFS存货分类查询 */ public List querySkuClass(QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO) throws Exception { + + int pageNo = 1; + int pageSize = 500; + + List all = new ArrayList<>(); + InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); interfaceParamDto.setApi("ofs.inventory.class.search"); queryOfsSKUClassRequestVO.setClientCode("LETS"); + queryOfsSKUClassRequestVO.setPageNo(pageNo); + queryOfsSKUClassRequestVO.setPageSize(pageSize); interfaceParamDto.setData(JSON.toJSONString(queryOfsSKUClassRequestVO)); - OFSSKUClassSearchResponse ofsskuClassSearchResponse =(OFSSKUClassSearchResponse) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); - System.out.println(ofsskuClassSearchResponse); - List data = ofsskuClassSearchResponse.getData(); - if(data==null||data.size()==0){ + OFSSKUClassSearchResponse ofsskuClassSearchResponse = (OFSSKUClassSearchResponse) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); + + all.addAll(ofsskuClassSearchResponse.getData()); + + int count = ofsskuClassSearchResponse.getData().size(); + while (count >= pageSize) {//>=500,可能还有下一页。 + //还有下一页 + pageNo++; + queryOfsSKUClassRequestVO.setPageNo(pageNo); + interfaceParamDto.setData(JSON.toJSONString(queryOfsSKUClassRequestVO)); + OFSSKUClassSearchResponse ofsskuClassSearchResponse1 = (OFSSKUClassSearchResponse) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); + all.addAll(ofsskuClassSearchResponse1.getData()); + count = ofsskuClassSearchResponse1.getData().size(); + } + if (all == null || all.size() == 0) { return null; } - - return data; + return all; } + /** + * 查询u8c中pk_corp=0001下的所有分类(集团) + */ + public List queryU8CAllInvcl() { + BdInvclEntity bdInvclEntity = new BdInvclEntity(); + bdInvclEntity.setDr(0); + bdInvclEntity.setPkCorp("0001"); + bdInvclEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); + List bdInvclEntityList = bdInvclDao.query(bdInvclEntity); + return bdInvclEntityList; + } + private BdInvclEntity resultDataHandle(String resultData) { + try { + if (resultData != null && !"".equals(resultData)) { + if (resultData.contains("[")) { + resultData = resultData.substring(1, resultData.length() - 1); + } + return JSON.parseObject(resultData, BdInvclEntity.class); + } + } catch (Exception e) { + e.printStackTrace(); + logger.error("解析返回参数失败的错误", e); + //如果解析失败,记录原因,但是不能影响结果的记录 + } + return null; + } } diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/BaseTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/BaseTest.java index 29628233..7951dc9b 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/BaseTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/BaseTest.java @@ -40,7 +40,11 @@ public class BaseTest { } @Test public void t21(){ - skuClassPluginInitializer.start("2024-08-15","2024-08-16"); + skuClassPluginInitializer.start("ZN001"); + } + @Test + public void t22(){ + skuClassPluginInitializer.start("2024-08-23","2024-08-25"); } 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 6ec4aa37..b32b3917 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 @@ -82,11 +82,16 @@ public class TransferTest { } @Test public void t41(){ - adjustOutPluginInitializer.start("LETS-SH2024080900000001"); + adjustOutPluginInitializer.start("LETS-SH2024082200000008"); } @Test public void t42(){ adjustOutPluginInitializer.start("2024-08-08","2024-08-13"); } + @Test + public void t43() throws Exception { + adjustOutPluginInitializer.queryOfsAdjustOrders("LETS-AH2024082200000001"); + } + } diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofsBaseSearch/OFSSKUClassSearchResponse.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofsBaseSearch/OFSSKUClassSearchResponse.java index 15d09ec0..6d2da8c2 100644 --- a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofsBaseSearch/OFSSKUClassSearchResponse.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofsBaseSearch/OFSSKUClassSearchResponse.java @@ -3,7 +3,6 @@ package com.hzya.frame.ttxofs.dto.ofsBaseSearch; import com.hzya.frame.ttxofs.basics.ReturnMessageBasics; import lombok.Data; -import java.util.Date; import java.util.List; /** @@ -18,9 +17,9 @@ public class OFSSKUClassSearchResponse extends ReturnMessageBasics { private String clientCode; private String cInvCCode; private String cInvCName; - private Date created; + private String created; private String createdBy; - private Date lastUpdated; + private String lastUpdated; private String lastUpdatedBy; }