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 6bfc5495..f3850dac 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 @@ -56,6 +56,7 @@ public class OverallConstant { prodOverPublic.put("custdocAssign", "/u8cloud/api/uapbd/custdoc/assign");//客商档案分配 prodOverPublic.put("custmandocSave", "/u8cloud/api/uapbd/custmandoc/insert");//客商档案新增 prodOverPublic.put("bdcorpQuery", "/u8cloud/api/uapbd/bdcorp/query");//公司档案查询 + prodOverPublic.put("bddefdoclistsave", "/u8cloud/api/uapbd/bddefdoclist/insert");//公司档案查询 } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/ShopPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/ShopPluginInitializer.java index cff6274c..5233da91 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/ShopPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/ShopPluginInitializer.java @@ -11,15 +11,13 @@ import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; import com.hzya.frame.plugin.lets.queryvo.CustdocRequestVo; import com.hzya.frame.plugin.lets.resultvo.CbdocResultVo; -import com.hzya.frame.plugin.lets.resultvo.ShopReturnMessageDto; import com.hzya.frame.plugin.lets.u8cdto.CustdocEntityDto; +import com.hzya.frame.plugin.lets.u8cdto.DefdocRequestVo; import com.hzya.frame.plugin.lets.util.PushDataByU8cUtil; import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil; import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao; import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; -import com.hzya.frame.ttxofs.basics.ReturnMessageBasics; import com.hzya.frame.ttxofs.dto.InterfaceParamByU8CApiDto; -import com.hzya.frame.ttxofs.dto.InterfaceParamDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopReturnMessageDto; import com.hzya.frame.ttxofs.service.OfsUnifiedService; @@ -27,7 +25,6 @@ import com.hzya.frame.web.entity.JsonResultEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -127,7 +124,9 @@ public class ShopPluginInitializer extends PluginBaseEntity { shopEntity.setPageNo("1"); List list = queryfromofs(shopEntity); List shopEntities = filterShopEntity(list); - implement(shopEntities); + implementcustdoc(shopEntities); + List list1 = filterShopEntityDef(list); + implementdef(list1); } catch (Exception e) { e.printStackTrace(); @@ -154,10 +153,12 @@ public class ShopPluginInitializer extends PluginBaseEntity { shopEntity.setClientCode("LETS"); List list = queryfromofs(shopEntity); - //过滤数据 - List ofsShopDtoList = filterShopEntity(list); - //同步u8c - implement(ofsShopDtoList); + List shopEntities = filterShopEntity(list); + //同步到客商档案 + implementcustdoc(shopEntities); + List list1 = filterShopEntityDef(list); + //同步到自定义档案 + implementdef(list1); } catch (Exception e) { logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,startImplement()方法报错:", e); @@ -177,16 +178,27 @@ public class ShopPluginInitializer extends PluginBaseEntity { List list = queryfromofs(shopEntity); //过滤数据 List shopEntities = filterShopEntity(list); - //执行 - implement(shopEntities); + //同步到客商档案 + implementcustdoc(shopEntities); + List list1 = filterShopEntityDef(list); + //同步到自定义档案 + implementdef(list1); } catch (Exception e) { logger.error("丽知:OFS店铺档案--->U8C客商档案,startImplement(String code)方法报错:", e); } } - @Transactional - public void implement(List shopEntityList) { + public void implement(List shopEntityList){ + Assert.notNull(shopEntityList, "shopEntityList不能为空"); + //同步到客商档案 + implementcustdoc(shopEntityList); + //同步到自定义档案 + implementdef(shopEntityList); + } + + + public void implementcustdoc(List shopEntityList) { Assert.notNull(shopEntityList, "shopEntityList不能为空"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -200,9 +212,10 @@ public class ShopPluginInitializer extends PluginBaseEntity { CustdocRequestVo custdocRequestVo = new CustdocRequestVo(); parentvo.setCustname(shopEntity.getName()); parentvo.setCustshortname(shopEntity.getName()); - + //业务编码 parentvo.setDef1(shopEntity.getBizCode()); - + //备注 TODO + parentvo.setMemo(""); custdocRequestVo.setParentvo(parentvo); //同步u8c HashMap param = new HashMap<>(); @@ -256,8 +269,71 @@ public class ShopPluginInitializer extends PluginBaseEntity { logger.error("丽知:OFS店铺档案--->U8C客商档案,implement()方法报错:", e); } } + } + public void implementdef(List shopEntityList) { + Assert.notNull(shopEntityList, "shopEntityList不能为空"); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(System.currentTimeMillis()); + String businessFormat = sdf.format(date); + for (OfsShopDto shopEntity : shopEntityList) { + + try { + + DefdocRequestVo defdocRequestVo = new DefdocRequestVo(); + defdocRequestVo.setDoccode(shopEntity.getBizCode()); + defdocRequestVo.setDocname(shopEntity.getName()); + //同步u8c + String jsonString = JSONObject.toJSONString(defdocRequestVo); + String response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("bddefdoclistsave"), jsonString); + System.out.println(response); + if (response != null) { + CbdocResultVo cbdocResultVo = JSONObject.parseObject(response, CbdocResultVo.class); + String taskNumber = null; + boolean isSuccess = false; + if ("success".equals(cbdocResultVo.getStatus())) { + isSuccess = true; + taskNumber = cbdocResultVo.getTaskNumber(); + String data = cbdocResultVo.getData(); + } + + if (!isSuccess) { + Assert.state(false, "同步到U8C失败,原因:{} 接口入参:{} {}", JSON.toJSONString(cbdocResultVo), JSON.toJSONString(OverallConstant.getOverAllValue("custdocSave")), JSON.toJSONString(cbdocResultVo)); + } + // 根据返回结果记录日志 + //成功 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); + integrationTaskLivingDetailsEntity.setRootAppNewData(jsonString); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(JSON.toJSONString(cbdocResultVo)); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); + integrationTaskLivingDetailsEntity.setRootAppPk("def"+shopEntity.getBizCode()); + integrationTaskLivingDetailsEntity.setRootAppBill(shopEntity.getName()); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); +// CbdocResultVo cbdocResultVo1 = JSONObject.parseObject(response, CbdocResultVo.class); +// String errormsg = cbdocResultVo1.getErrormsg(); + } + + } catch (Exception e) { + e.printStackTrace(); + String ErrMessage = e.getMessage(); + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(JSONObject.toJSONString(shopEntity)); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); + integrationTaskLivingDetailsEntity.setRootAppPk("def"+shopEntity.getBizCode()); + integrationTaskLivingDetailsEntity.setRootAppBill(shopEntity.getName()); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); + logger.error("丽知:OFS店铺档案--->自定义档案,implement()方法报错:", e); + } + } } public List filterShopEntity(List list) { @@ -287,6 +363,33 @@ public class ShopPluginInitializer extends PluginBaseEntity { } + + public List filterShopEntityDef(List list) { + Assert.notNull(list, "不能为空!"); + List shopEntityList = new ArrayList<>(); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + OfsShopDto ofsShopDto = list.get(i); + + if (ofsShopDto.getBizCode() != null && !"".equals(ofsShopDto.getBizCode().trim())) { + boolean isExis = true; + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setRootAppPk("def"+ofsShopDto.getBizCode()); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + List integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity); + if (integrationTaskLivingDetailsEntities == null || integrationTaskLivingDetailsEntities.size() == 0) { + isExis = false; + } + if (!isExis) { + shopEntityList.add(ofsShopDto); + } + } + } + } + return shopEntityList; + } + public List queryfromofs(OfsShopDto shopEntity) { InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); interfaceParamDto.setApi("ofs.store.search"); diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/SupplierPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/SupplierPluginInitializer.java index e4f4185d..ca8537aa 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/SupplierPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/SupplierPluginInitializer.java @@ -10,7 +10,7 @@ import com.hzya.frame.plugin.lets.constant.OverallConstant; import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; - +import com.hzya.frame.plugin.lets.queryvo.BankVo; import com.hzya.frame.plugin.lets.queryvo.CustdocRequestVo; import com.hzya.frame.plugin.lets.resultvo.CbdocResultVo; @@ -195,6 +195,7 @@ public class SupplierPluginInitializer extends PluginBaseEntity { String businessFormat = sdf.format(date); for (OfsSupplierDto supplierEntity : shopEntityList) { CustdocEntityDto parentvo = new CustdocEntityDto(); + BankVo bankVo = new BankVo(); CustdocRequestVo CustdocEntityDto = new CustdocRequestVo(); try { //T 设置parentvo @@ -205,6 +206,8 @@ public class SupplierPluginInitializer extends PluginBaseEntity { parentvo.setDef1(supplierEntity.getBizCode()); CustdocEntityDto.setParentvo(parentvo); + bankVo.setAccount(supplierEntity.getBankAccount()); + CustdocEntityDto.setBanks(new ArrayList() {{add(bankVo);}}); // 同步u8c HashMap param = new HashMap<>(); param.put("cbdocvo", CustdocEntityDto); diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocListRequestVo.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocListRequestVo.java new file mode 100644 index 00000000..a334624c --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocListRequestVo.java @@ -0,0 +1,20 @@ +package com.hzya.frame.plugin.lets.u8cdto; + +import lombok.Data; + +import java.util.List; + +/** + * @Author sx + * @Date 2024/8/21 10:39 + * @PackageName:com.hzya.frame.plugin.lets.u8cdto + * @ClassName: DefListRequestVo + * @Description: 档案内容实体_返回 + */ +@Data +public class DefdocListRequestVo { + + private List children; + private DefdocParentVo parentvo; + +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocParentVo.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocParentVo.java new file mode 100644 index 00000000..dd2ab6f3 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocParentVo.java @@ -0,0 +1,26 @@ +package com.hzya.frame.plugin.lets.u8cdto; + +/** + * @Author sx + * @Date 2024/8/21 10:39 + * @PackageName:com.hzya.frame.plugin.lets.u8cdto + * @ClassName: DefDocParentVo + * @Description: + */ +public class DefdocParentVo { + private String docislevflag; + + private String doclistcode; + + private String doclistname; + + private String doclistsystype; + + private String dr; + + private String iscorpcanchg; + + private String pk_defdoclist; + + private String ts; +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocRequestVo.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocRequestVo.java new file mode 100644 index 00000000..2d175a9d --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/DefdocRequestVo.java @@ -0,0 +1,32 @@ +package com.hzya.frame.plugin.lets.u8cdto; + +import lombok.Data; + +/** + * @Author sx + * @Date 2024/8/21 10:29 + * @PackageName:com.hzya.frame.plugin.lets.u8cdto + * @ClassName: DefdocRequestVo + * @Description: 自定义档案内容 + */ +@Data +public class DefdocRequestVo { + private String doccode; + + private String docname; + + private String docsystype; + private String dr; + private String memo; + + private String pk_corp; + private String pk_defdoc; + + private String pk_defdoc1; + + private String pk_defdoclist; + private String sealflag; + + private String shortname; + private String ts; +} diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/ShopTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/ShopTest.java index 09424f42..705d33b5 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/ShopTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/ShopTest.java @@ -18,6 +18,7 @@ import com.hzya.frame.ttxofs.dto.InterfaceParamDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopReturnMessageDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsSupplierDto; +import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsSupplierReturnMessageDto; import com.hzya.frame.ttxofs.service.OfsUnifiedService; import org.checkerframework.checker.units.qual.C; import org.junit.Test; @@ -84,27 +85,27 @@ public class ShopTest { // List data = unified.getData(); // System.out.println("data = " + data); - - OfsSupplierDto shopEntity = new OfsSupplierDto(); -// shopEntity.setLastUpdated_start("2021-08-01 00:00:00"); - shopEntity.setPageNo("1"); - shopEntity.setClientCode("LETS"); - shopEntity.setCompanyCode("LETS"); - shopEntity.setBizCode("983"); - Date currentDate = new Date(); -// shopEntity.setLastUpdated_start("2023-07-27 16:06:57"); -// shopEntity.setLastUpdated_end("2023-07-28 16:06:57"); - InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); - interfaceParamDto.setApi("ofs.vendor.search"); - interfaceParamDto.setData(JSON.toJSONString(shopEntity)); - OfsShopReturnMessageDto unified = null; - try { - unified = (OfsShopReturnMessageDto) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); - } catch (Exception e) { - throw new RuntimeException(e); - } - List data = unified.getData(); - System.out.println("data = " + data); +// +// OfsSupplierDto shopEntity = new OfsSupplierDto(); +//// shopEntity.setLastUpdated_start("2021-08-01 00:00:00"); +// shopEntity.setPageNo("1"); +// shopEntity.setClientCode("LETS"); +// shopEntity.setCompanyCode("LETS"); +// shopEntity.setBizCode("983"); +// Date currentDate = new Date(); +//// shopEntity.setLastUpdated_start("2023-07-27 16:06:57"); +//// shopEntity.setLastUpdated_end("2023-07-28 16:06:57"); +// InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); +// interfaceParamDto.setApi("ofs.vendor.search"); +// interfaceParamDto.setData(JSON.toJSONString(shopEntity)); +// OfsShopReturnMessageDto unified = null; +// try { +// unified = (OfsShopReturnMessageDto) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// List data = unified.getData(); +// System.out.println("data = " + data); // SupplierEntity supplierEntity = new SupplierEntity(); @@ -169,5 +170,52 @@ public class ShopTest { // custmandocPluginInitializer.implement(list); // custdocAutoAllotPluginInitializer.start(); + + +// OfsShopDto shopEntity = new OfsShopDto(); +//// shopEntity.setLastUpdated_start("2021-08-01 00:00:00"); +// shopEntity.setPageNo("1"); +// shopEntity.setPageSize("500"); +// shopEntity.setClientCode("LETS"); +// shopEntity.setBizCode("test123"); +// Date currentDate = new Date(); +// Date startTime = DateUtil.offset(currentDate, DateField.MINUTE, -10); +// Date endTime = DateUtil.offset(currentDate, DateField.MINUTE, -2); +// String startTimeStr = DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"); +// String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"); +// shopEntity.setLastUpdated_start("2024-03-10 16:06:57"); +// shopEntity.setLastUpdated_end("2024-03-12 16:06:57"); +// shopEntity.setBizCode("test123"); +// InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); +// interfaceParamDto.setApi("ofs.store.search"); +// interfaceParamDto.setData(JSON.toJSONString(shopEntity)); +// OfsShopReturnMessageDto unified = null; +// try { +// unified = (OfsShopReturnMessageDto) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// List data = unified.getData(); +// shopPluginInitializer.implement(data); +// + OfsSupplierDto shopEntity = new OfsSupplierDto(); +// shopEntity.setLastUpdated_start("2021-08-01 00:00:00"); + shopEntity.setPageNo("1"); + shopEntity.setClientCode("LETS"); + shopEntity.setCompanyCode("LETS"); +// shopEntity.setBizCode("test1234"); + InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); + interfaceParamDto.setApi("ofs.vendor.search"); + interfaceParamDto.setData(JSON.toJSONString(shopEntity)); + OfsSupplierReturnMessageDto unified = null; + try { + unified = (OfsSupplierReturnMessageDto) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); + } catch (Exception e) { + throw new RuntimeException(e); + } + List data = unified.getData(); + +// supplierPluginInitializer.implement(data); + } }