新增自定义档案

This commit is contained in:
sx 2024-08-21 11:19:08 +08:00
parent 209bb100b0
commit af2fc7195b
7 changed files with 270 additions and 37 deletions

View File

@ -56,6 +56,7 @@ public class OverallConstant {
prodOverPublic.put("custdocAssign", "/u8cloud/api/uapbd/custdoc/assign");//客商档案分配 prodOverPublic.put("custdocAssign", "/u8cloud/api/uapbd/custdoc/assign");//客商档案分配
prodOverPublic.put("custmandocSave", "/u8cloud/api/uapbd/custmandoc/insert");//客商档案新增 prodOverPublic.put("custmandocSave", "/u8cloud/api/uapbd/custmandoc/insert");//客商档案新增
prodOverPublic.put("bdcorpQuery", "/u8cloud/api/uapbd/bdcorp/query");//公司档案查询 prodOverPublic.put("bdcorpQuery", "/u8cloud/api/uapbd/bdcorp/query");//公司档案查询
prodOverPublic.put("bddefdoclistsave", "/u8cloud/api/uapbd/bddefdoclist/insert");//公司档案查询
} }

View File

@ -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.queryvo.CustdocRequestVo;
import com.hzya.frame.plugin.lets.resultvo.CbdocResultVo; 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.CustdocEntityDto;
import com.hzya.frame.plugin.lets.u8cdto.DefdocRequestVo;
import com.hzya.frame.plugin.lets.util.PushDataByU8cUtil; import com.hzya.frame.plugin.lets.util.PushDataByU8cUtil;
import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil; import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao; import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; 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.InterfaceParamByU8CApiDto;
import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopDto;
import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopReturnMessageDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopReturnMessageDto;
import com.hzya.frame.ttxofs.service.OfsUnifiedService; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -127,7 +124,9 @@ public class ShopPluginInitializer extends PluginBaseEntity {
shopEntity.setPageNo("1"); shopEntity.setPageNo("1");
List<OfsShopDto> list = queryfromofs(shopEntity); List<OfsShopDto> list = queryfromofs(shopEntity);
List<OfsShopDto> shopEntities = filterShopEntity(list); List<OfsShopDto> shopEntities = filterShopEntity(list);
implement(shopEntities); implementcustdoc(shopEntities);
List<OfsShopDto> list1 = filterShopEntityDef(list);
implementdef(list1);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -154,10 +153,12 @@ public class ShopPluginInitializer extends PluginBaseEntity {
shopEntity.setClientCode("LETS"); shopEntity.setClientCode("LETS");
List<OfsShopDto> list = queryfromofs(shopEntity); List<OfsShopDto> list = queryfromofs(shopEntity);
//过滤数据 List<OfsShopDto> shopEntities = filterShopEntity(list);
List<OfsShopDto> ofsShopDtoList = filterShopEntity(list); //同步到客商档案
//同步u8c implementcustdoc(shopEntities);
implement(ofsShopDtoList); List<OfsShopDto> list1 = filterShopEntityDef(list);
//同步到自定义档案
implementdef(list1);
} catch (Exception e) { } catch (Exception e) {
logger.error("丽知OFS货品档案分类--->U8C货品档案分类,startImplement()方法报错:", e); logger.error("丽知OFS货品档案分类--->U8C货品档案分类,startImplement()方法报错:", e);
@ -177,17 +178,28 @@ public class ShopPluginInitializer extends PluginBaseEntity {
List<OfsShopDto> list = queryfromofs(shopEntity); List<OfsShopDto> list = queryfromofs(shopEntity);
//过滤数据 //过滤数据
List<OfsShopDto> shopEntities = filterShopEntity(list); List<OfsShopDto> shopEntities = filterShopEntity(list);
//执行 //同步到客商档案
implement(shopEntities); implementcustdoc(shopEntities);
List<OfsShopDto> list1 = filterShopEntityDef(list);
//同步到自定义档案
implementdef(list1);
} catch (Exception e) { } catch (Exception e) {
logger.error("丽知OFS店铺档案--->U8C客商档案,startImplement(String code)方法报错:", e); logger.error("丽知OFS店铺档案--->U8C客商档案,startImplement(String code)方法报错:", e);
} }
} }
@Transactional
public void implement(List<OfsShopDto> shopEntityList){ public void implement(List<OfsShopDto> shopEntityList){
Assert.notNull(shopEntityList, "shopEntityList不能为空"); Assert.notNull(shopEntityList, "shopEntityList不能为空");
//同步到客商档案
implementcustdoc(shopEntityList);
//同步到自定义档案
implementdef(shopEntityList);
}
public void implementcustdoc(List<OfsShopDto> shopEntityList) {
Assert.notNull(shopEntityList, "shopEntityList不能为空");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(System.currentTimeMillis()); Date date = new Date(System.currentTimeMillis());
@ -200,9 +212,10 @@ public class ShopPluginInitializer extends PluginBaseEntity {
CustdocRequestVo custdocRequestVo = new CustdocRequestVo(); CustdocRequestVo custdocRequestVo = new CustdocRequestVo();
parentvo.setCustname(shopEntity.getName()); parentvo.setCustname(shopEntity.getName());
parentvo.setCustshortname(shopEntity.getName()); parentvo.setCustshortname(shopEntity.getName());
//业务编码
parentvo.setDef1(shopEntity.getBizCode()); parentvo.setDef1(shopEntity.getBizCode());
//备注 TODO
parentvo.setMemo("");
custdocRequestVo.setParentvo(parentvo); custdocRequestVo.setParentvo(parentvo);
//同步u8c //同步u8c
HashMap<String, Object> param = new HashMap<>(); HashMap<String, Object> param = new HashMap<>();
@ -256,8 +269,71 @@ public class ShopPluginInitializer extends PluginBaseEntity {
logger.error("丽知OFS店铺档案--->U8C客商档案,implement()方法报错:", e); logger.error("丽知OFS店铺档案--->U8C客商档案,implement()方法报错:", e);
} }
} }
}
public void implementdef(List<OfsShopDto> 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<OfsShopDto> filterShopEntity(List<OfsShopDto> list) { public List<OfsShopDto> filterShopEntity(List<OfsShopDto> list) {
@ -287,6 +363,33 @@ public class ShopPluginInitializer extends PluginBaseEntity {
} }
public List<OfsShopDto> filterShopEntityDef(List<OfsShopDto> list) {
Assert.notNull(list, "不能为空!");
List<OfsShopDto> 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<IntegrationTaskLivingDetailsEntity> integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity);
if (integrationTaskLivingDetailsEntities == null || integrationTaskLivingDetailsEntities.size() == 0) {
isExis = false;
}
if (!isExis) {
shopEntityList.add(ofsShopDto);
}
}
}
}
return shopEntityList;
}
public List<OfsShopDto> queryfromofs(OfsShopDto shopEntity) { public List<OfsShopDto> queryfromofs(OfsShopDto shopEntity) {
InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto();
interfaceParamDto.setApi("ofs.store.search"); interfaceParamDto.setApi("ofs.store.search");

View File

@ -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.constant.ProfilesActiveConstant;
import com.hzya.frame.plugin.lets.queryvo.BankVo;
import com.hzya.frame.plugin.lets.queryvo.CustdocRequestVo; import com.hzya.frame.plugin.lets.queryvo.CustdocRequestVo;
import com.hzya.frame.plugin.lets.resultvo.CbdocResultVo; import com.hzya.frame.plugin.lets.resultvo.CbdocResultVo;
@ -195,6 +195,7 @@ public class SupplierPluginInitializer extends PluginBaseEntity {
String businessFormat = sdf.format(date); String businessFormat = sdf.format(date);
for (OfsSupplierDto supplierEntity : shopEntityList) { for (OfsSupplierDto supplierEntity : shopEntityList) {
CustdocEntityDto parentvo = new CustdocEntityDto(); CustdocEntityDto parentvo = new CustdocEntityDto();
BankVo bankVo = new BankVo();
CustdocRequestVo CustdocEntityDto = new CustdocRequestVo(); CustdocRequestVo CustdocEntityDto = new CustdocRequestVo();
try { try {
//T 设置parentvo //T 设置parentvo
@ -205,6 +206,8 @@ public class SupplierPluginInitializer extends PluginBaseEntity {
parentvo.setDef1(supplierEntity.getBizCode()); parentvo.setDef1(supplierEntity.getBizCode());
CustdocEntityDto.setParentvo(parentvo); CustdocEntityDto.setParentvo(parentvo);
bankVo.setAccount(supplierEntity.getBankAccount());
CustdocEntityDto.setBanks(new ArrayList<BankVo>() {{add(bankVo);}});
// 同步u8c // 同步u8c
HashMap<String, Object> param = new HashMap<>(); HashMap<String, Object> param = new HashMap<>();
param.put("cbdocvo", CustdocEntityDto); param.put("cbdocvo", CustdocEntityDto);

View File

@ -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<DefdocRequestVo> children;
private DefdocParentVo parentvo;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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.OfsShopDto;
import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopReturnMessageDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsShopReturnMessageDto;
import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsSupplierDto; import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsSupplierDto;
import com.hzya.frame.ttxofs.dto.ofsBaseSearch.OfsSupplierReturnMessageDto;
import com.hzya.frame.ttxofs.service.OfsUnifiedService; import com.hzya.frame.ttxofs.service.OfsUnifiedService;
import org.checkerframework.checker.units.qual.C; import org.checkerframework.checker.units.qual.C;
import org.junit.Test; import org.junit.Test;
@ -84,27 +85,27 @@ public class ShopTest {
// List<OfsShopDto> data = unified.getData(); // List<OfsShopDto> data = unified.getData();
// System.out.println("data = " + data); // System.out.println("data = " + data);
//
OfsSupplierDto shopEntity = new OfsSupplierDto(); // OfsSupplierDto shopEntity = new OfsSupplierDto();
// shopEntity.setLastUpdated_start("2021-08-01 00:00:00"); //// shopEntity.setLastUpdated_start("2021-08-01 00:00:00");
shopEntity.setPageNo("1"); // shopEntity.setPageNo("1");
shopEntity.setClientCode("LETS"); // shopEntity.setClientCode("LETS");
shopEntity.setCompanyCode("LETS"); // shopEntity.setCompanyCode("LETS");
shopEntity.setBizCode("983"); // shopEntity.setBizCode("983");
Date currentDate = new Date(); // Date currentDate = new Date();
// shopEntity.setLastUpdated_start("2023-07-27 16:06:57"); //// shopEntity.setLastUpdated_start("2023-07-27 16:06:57");
// shopEntity.setLastUpdated_end("2023-07-28 16:06:57"); //// shopEntity.setLastUpdated_end("2023-07-28 16:06:57");
InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); // InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto();
interfaceParamDto.setApi("ofs.vendor.search"); // interfaceParamDto.setApi("ofs.vendor.search");
interfaceParamDto.setData(JSON.toJSONString(shopEntity)); // interfaceParamDto.setData(JSON.toJSONString(shopEntity));
OfsShopReturnMessageDto unified = null; // OfsShopReturnMessageDto unified = null;
try { // try {
unified = (OfsShopReturnMessageDto) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); // unified = (OfsShopReturnMessageDto) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto);
} catch (Exception e) { // } catch (Exception e) {
throw new RuntimeException(e); // throw new RuntimeException(e);
} // }
List<OfsShopDto> data = unified.getData(); // List<OfsShopDto> data = unified.getData();
System.out.println("data = " + data); // System.out.println("data = " + data);
// SupplierEntity supplierEntity = new SupplierEntity(); // SupplierEntity supplierEntity = new SupplierEntity();
@ -169,5 +170,52 @@ public class ShopTest {
// custmandocPluginInitializer.implement(list); // custmandocPluginInitializer.implement(list);
// custdocAutoAllotPluginInitializer.start(); // 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<OfsShopDto> 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<OfsSupplierDto> data = unified.getData();
// supplierPluginInitializer.implement(data);
} }
} }