丽知:存货分类修改

This commit is contained in:
zhengyf 2024-08-24 23:15:52 +08:00
parent 685157ee4c
commit ca95709867
7 changed files with 403 additions and 107 deletions

View File

@ -28,8 +28,11 @@ public class OverallConstant {
private static void loadPublic() { private static void loadPublic() {
//存货分类 //存货分类
prodOverPublic.put("bdinvclSaveCode", "8000370025");//存货分类新增
prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货分类新增 prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货分类新增
prodOverPublic.put("bdinvclUpdateCode", "8000370026");//存货分类修改
prodOverPublic.put("bdinvclUpdate", "/u8cloud/api/uapbd/bdinvcl/update");//存货分类修改 prodOverPublic.put("bdinvclUpdate", "/u8cloud/api/uapbd/bdinvcl/update");//存货分类修改
prodOverPublic.put("bdinvclDeleteCode", "8000370027");//存货分类删除
prodOverPublic.put("bdinvclDelete", "/u8cloud/api/uapbd/bdinvcl/delete");//存货分类删除 prodOverPublic.put("bdinvclDelete", "/u8cloud/api/uapbd/bdinvcl/delete");//存货分类删除
//存货基本档案 //存货基本档案
prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货基本档案新增 prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货基本档案新增

View File

@ -41,6 +41,7 @@ public class BdInvclEntity extends BaseEntity {
private String pk_corp; private String pk_corp;
/** 存货分类主键 */ /** 存货分类主键 */
private String pkInvcl; private String pkInvcl;
private String pk_invcl;
/** 封存标志 */ /** 封存标志 */
private String sealdate; private String sealdate;
/** 时间戳 */ /** 时间戳 */

View File

@ -14,6 +14,9 @@ public class QueryOfsSKUClassRequestVO {
/** 组织 */ /** 组织 */
private String clientCode; private String clientCode;
private String lastUpdated_start;
private String lastUpdated_end;
private String companyCode; private String companyCode;
private String cInvCCode; private String cInvCCode;
private String status; private String status;

View File

@ -9,11 +9,17 @@ import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity; import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.lets.constant.OverallConstant; 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.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.entity.BdInvclEntity;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSKUClassRequestVO; 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.u8cdto.ReusltStrDto;
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.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.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.basics.ReturnMessageBasics;
@ -43,6 +49,11 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
/**
* 丽知OFS货品档案分类--->U8C货品档案分类(XX-XXX-XXXX)
* 传递时需要区分上下级需要先XX 在XXXXX 最后XXXXXXXXX
* 分组匹配查询
*/
public class SKUClassPluginInitializer extends PluginBaseEntity { public class SKUClassPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(SKUClassPluginInitializer.class); Logger logger = LoggerFactory.getLogger(SKUClassPluginInitializer.class);
@ -82,20 +93,57 @@ public class SKUClassPluginInitializer extends PluginBaseEntity {
@Autowired @Autowired
private PushDataByU8cUtil pushDataByU8cUtil; private PushDataByU8cUtil pushDataByU8cUtil;
@Autowired @Autowired
private PushU8CByApiCode pushU8CByApiCode;
@Autowired
private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao; private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao;
@Autowired @Autowired
private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil; private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil;
@Autowired @Autowired
private OfsUnifiedService ofsUnifiedService; private OfsUnifiedService ofsUnifiedService;
@Autowired
private IBdInvclDao bdInvclDao;
@Override @Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { 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; return null;
} }
/** /**
* 默认推送 * 全量拉取ofs对比u8c
*/ */
public void start() { public void start() {
try { try {
@ -107,13 +155,15 @@ public class SKUClassPluginInitializer extends PluginBaseEntity {
String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"); String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss");
QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO = new QueryOfsSKUClassRequestVO(); QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO = new QueryOfsSKUClassRequestVO();
// queryOfsSKUClassRequestVO.setCreated_start(start); queryOfsSKUClassRequestVO.setLastUpdated_start(startTimeStr);
// queryOfsSKUClassRequestVO.setCreated_end(end); queryOfsSKUClassRequestVO.setLastUpdated_end(endTimeStr);
queryOfsSKUClassRequestVO.setClientCode("LETS");
queryOfsSKUClassRequestVO.setPageNo(1);
queryOfsSKUClassRequestVO.setPageSize(500);
List<OFSSKUClassSearchResponse.SKUClass> skuClasses = querySkuClass(queryOfsSKUClassRequestVO); List<OFSSKUClassSearchResponse.SKUClass> skuClasses = querySkuClass(queryOfsSKUClassRequestVO);
System.out.println(skuClasses);
//过滤日志
List<OFSSKUClassSearchResponse.SKUClass> filterSKUClasss = filterData(skuClasses);
//推送
implement(filterSKUClasss);
} catch (Exception e) { } catch (Exception e) {
@ -126,7 +176,16 @@ public class SKUClassPluginInitializer extends PluginBaseEntity {
*/ */
public void start(String className) { public void start(String className) {
try { try {
implement(); QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO = new QueryOfsSKUClassRequestVO();
queryOfsSKUClassRequestVO.setCInvCCode(className);
List<OFSSKUClassSearchResponse.SKUClass> skuClasses = querySkuClass(queryOfsSKUClassRequestVO);
//过滤日志
List<OFSSKUClassSearchResponse.SKUClass> filterGoodsClass = filterData(skuClasses);
//推送
implement(filterGoodsClass);
} catch (Exception e) { } catch (Exception e) {
logger.error("丽知OFS货品档案分类--->U8C货品档案分类,start(String className)方法报错:", e); logger.error("丽知OFS货品档案分类--->U8C货品档案分类,start(String className)方法报错:", e);
} }
@ -141,115 +200,293 @@ public class SKUClassPluginInitializer extends PluginBaseEntity {
Date business_end = DateUtil.parse(endTime); Date business_end = DateUtil.parse(endTime);
String start = DateUtil.format(business_start, "yyyy-MM-dd") + " 00:00:00"; String start = DateUtil.format(business_start, "yyyy-MM-dd") + " 00:00:00";
String end = DateUtil.format(business_end, "yyyy-MM-dd") + " 23:59:59"; String end = DateUtil.format(business_end, "yyyy-MM-dd") + " 23:59:59";
QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO = new QueryOfsSKUClassRequestVO(); QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO = new QueryOfsSKUClassRequestVO();
queryOfsSKUClassRequestVO.setCreated_start(start); queryOfsSKUClassRequestVO.setLastUpdated_start(start);
queryOfsSKUClassRequestVO.setCreated_end(end); queryOfsSKUClassRequestVO.setLastUpdated_end(end);
queryOfsSKUClassRequestVO.setClientCode("LETS"); List<OFSSKUClassSearchResponse.SKUClass> skuClasses = querySkuClass(queryOfsSKUClassRequestVO);
queryOfsSKUClassRequestVO.setPageNo(1); //过滤日志
queryOfsSKUClassRequestVO.setPageSize(500); List<OFSSKUClassSearchResponse.SKUClass> filterGoodsClass = filterData(skuClasses);
querySkuClass(queryOfsSKUClassRequestVO);
//推送
implement(filterGoodsClass);
} catch (Exception e) { } catch (Exception e) {
logger.error("丽知OFS货品档案分类--->U8C货品档案分类,start(String startTime, String endTime)方法报错:", e); logger.error("丽知OFS货品档案分类--->U8C货品档案分类,start(String startTime, String endTime)方法报错:", e);
} }
} }
public void filterGoodsClass() { public List<OFSSKUClassSearchResponse.SKUClass> filterData(List<OFSSKUClassSearchResponse.SKUClass> skuClasses) {
return; List<OFSSKUClassSearchResponse.SKUClass> 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<IntegrationTaskLivingDetailsEntity> integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity);
if (integrationTaskLivingDetailsEntities == null || integrationTaskLivingDetailsEntities.size() == 0) {
isExis = false;
}
if (!isExis) {
filterSKUClasss.add(skuClass);
}
}
return filterSKUClasss;
} }
/** /**
* U8C分类规则 XX-XXX-XX自动截断 * U8C分类规则 XX-XXX-XX自动截断
* eg * eg
* 一级AA * 一级AA
* 二级AA001,自动识别为AA的下级 * 二级AA001,自动识别为AA的下级 的001
* 三级AA00101自动识别为AA001的下级 * 三级AA0010001自动识别为AA001的下级 的0001
*/ */
public void implement() { public void implement(List<OFSSKUClassSearchResponse.SKUClass> filterSKUClasss) {
String mapStr=null;
//生成业务日期 String businessFormat=null;
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对象格式化为字符串
for (OFSSKUClassSearchResponse.SKUClass skuClass : filterSKUClasss) {
businessFormat=skuClass.getLastUpdated();
List<BdInvclEntity> bdInvclEntities = new ArrayList<>(); List<BdInvclEntity> 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<BdInvclEntity> bdInvclEntityList = bdInvclDao.query(bdInvclEntity);
BdInvclEntity bdInvclEntity = new BdInvclEntity(); BdInvclEntity bdInvcl = new BdInvclEntity();
if (bdInvclEntityList.size() == 0) {
//分类编码-invclasscode bdInvclEntity.setForinvname(null);
invclasscode = "AA004"; bdInvclEntity.setInvclasscode(skuClass.getCInvCCode());
bdInvclEntity.setInvclasscode(invclasscode); bdInvclEntity.setInvclassname(skuClass.getCInvCName());
List<BdInvclEntity> bdInvclEntityList1 = bdInvclDao.query(bdInvclEntity);
//分类名称-invclassname System.out.println(bdInvclEntityList1);
invclassname = "分类名称AA004"; if (bdInvclEntityList1.size()==1) {
//修改
bdInvclEntity.setInvclassname(invclassname); url = OverallConstant.getOverAllValue("bdinvclUpdateCode");
//公司编码-pk_corp bdInvclEntity.setPk_invcl(bdInvclEntityList1.get(0).getPkInvcl());
String pk_corp = "1001"; }else if (bdInvclEntityList1.size()==0) {
bdInvclEntity.setPk_corp(pk_corp); //新增
//分类级别-invclasslevel url = OverallConstant.getOverAllValue("bdinvclSaveCode");
bdInvclEntities.add(bdInvclEntity); }
} else if (bdInvclEntityList.size() == 1) {
String jsonStr = JSONUtil.toJsonStr(bdInvclEntities); //修改
url = OverallConstant.getOverAllValue("bdinvclUpdateCode");
Map<String, Object> map = new HashMap<>(); bdInvclEntity.setPk_invcl(bdInvclEntityList.get(0).getPkInvcl());
map.put("invcl", jsonStr); } else {
mapStr = JSONUtil.toJsonStr(map); Assert.state(false, "");
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;
} }
//组装数据
//分类编码-invclasscode
bdInvclEntity.setInvclasscode(skuClass.getCInvCCode());
//分类名称-invclassname
bdInvclEntity.setInvclassname(skuClass.getCInvCName());
//公司编码-pk_corp
bdInvclEntity.setPk_corp("0001");
//外文名 forinvnameofs存货分类id
bdInvclEntity.setForinvname(skuId);
//推送
bdInvclEntities.add(bdInvclEntity);
String jsonStr = JSONUtil.toJsonStr(bdInvclEntities);
Map<String, Object> 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<BdInvclEntity> bdInvclEntities = queryU8CAllInvcl();
// //将pk_corp=0001下的所有分类分为123级
// List<BdInvclEntity> u8cLevel1 = new ArrayList<>();//length==2
// List<BdInvclEntity> u8cLevel2 = new ArrayList<>();//length==5
// List<BdInvclEntity> u8cLevel3 = new ArrayList<>();//length==9
// for (BdInvclEntity bdInvclEntity : bdInvclEntities) {
// switch (bdInvclEntity.getInvclasscode().length()) {
// case 2: System.out.println("U8C1级分类" + bdInvclEntity.getInvclasscode()); u8cLevel1.add(bdInvclEntity); break;
// case 5: System.out.println("U8C2级分类" + bdInvclEntity.getInvclasscode()); u8cLevel2.add(bdInvclEntity); break;
// case 9: System.out.println("U8C3级分类" + bdInvclEntity.getInvclasscode()); u8cLevel3.add(bdInvclEntity); break;
// }
// }
//
// List<OFSSKUClassSearchResponse.SKUClass> ofsLevel1 = new ArrayList<>();//length==2
// List<OFSSKUClassSearchResponse.SKUClass> ofsLevel2 = new ArrayList<>();//length==5
// List<OFSSKUClassSearchResponse.SKUClass> ofsLevel3 = new ArrayList<>();//length==9
// for (OFSSKUClassSearchResponse.SKUClass ofsSKUClass : filterSKUClasss) {
// switch (ofsSKUClass.getCInvCCode().length()) {
// case 2: System.out.println("OFS1级分类" + ofsSKUClass.getCInvCCode()); ofsLevel1.add(ofsSKUClass); break;
// case 5: System.out.println("OFS2级分类" + ofsSKUClass.getCInvCCode()); ofsLevel2.add(ofsSKUClass); break;
// case 9: System.out.println("OFS3级分类" + 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<BdInvclEntity> 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<String, Object> 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<OFSSKUClassSearchResponse.SKUClass> ofsLevel,List<BdInvclEntity> u8cLevel){
} }
@ -257,19 +494,63 @@ public class SKUClassPluginInitializer extends PluginBaseEntity {
* OFS存货分类查询 * OFS存货分类查询
*/ */
public List<OFSSKUClassSearchResponse.SKUClass> querySkuClass(QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO) throws Exception { public List<OFSSKUClassSearchResponse.SKUClass> querySkuClass(QueryOfsSKUClassRequestVO queryOfsSKUClassRequestVO) throws Exception {
int pageNo = 1;
int pageSize = 500;
List<OFSSKUClassSearchResponse.SKUClass> all = new ArrayList<>();
InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto();
interfaceParamDto.setApi("ofs.inventory.class.search"); interfaceParamDto.setApi("ofs.inventory.class.search");
queryOfsSKUClassRequestVO.setClientCode("LETS"); queryOfsSKUClassRequestVO.setClientCode("LETS");
queryOfsSKUClassRequestVO.setPageNo(pageNo);
queryOfsSKUClassRequestVO.setPageSize(pageSize);
interfaceParamDto.setData(JSON.toJSONString(queryOfsSKUClassRequestVO)); interfaceParamDto.setData(JSON.toJSONString(queryOfsSKUClassRequestVO));
OFSSKUClassSearchResponse ofsskuClassSearchResponse =(OFSSKUClassSearchResponse) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto); OFSSKUClassSearchResponse ofsskuClassSearchResponse = (OFSSKUClassSearchResponse) ofsUnifiedService.unifiedByU8CApi(interfaceParamDto);
System.out.println(ofsskuClassSearchResponse);
List<OFSSKUClassSearchResponse.SKUClass> data = ofsskuClassSearchResponse.getData(); all.addAll(ofsskuClassSearchResponse.getData());
if(data==null||data.size()==0){
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 null;
} }
return all;
return data;
} }
/**
* 查询u8c中pk_corp=0001下的所有分类(集团)
*/
public List<BdInvclEntity> queryU8CAllInvcl() {
BdInvclEntity bdInvclEntity = new BdInvclEntity();
bdInvclEntity.setDr(0);
bdInvclEntity.setPkCorp("0001");
bdInvclEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvclEntity> 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;
}
} }

View File

@ -40,7 +40,11 @@ public class BaseTest {
} }
@Test @Test
public void t21(){ 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");
} }

View File

@ -82,11 +82,16 @@ public class TransferTest {
} }
@Test @Test
public void t41(){ public void t41(){
adjustOutPluginInitializer.start("LETS-SH2024080900000001"); adjustOutPluginInitializer.start("LETS-SH2024082200000008");
} }
@Test @Test
public void t42(){ public void t42(){
adjustOutPluginInitializer.start("2024-08-08","2024-08-13"); adjustOutPluginInitializer.start("2024-08-08","2024-08-13");
} }
@Test
public void t43() throws Exception {
adjustOutPluginInitializer.queryOfsAdjustOrders("LETS-AH2024082200000001");
}
} }

View File

@ -3,7 +3,6 @@ package com.hzya.frame.ttxofs.dto.ofsBaseSearch;
import com.hzya.frame.ttxofs.basics.ReturnMessageBasics; import com.hzya.frame.ttxofs.basics.ReturnMessageBasics;
import lombok.Data; import lombok.Data;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -18,9 +17,9 @@ public class OFSSKUClassSearchResponse extends ReturnMessageBasics {
private String clientCode; private String clientCode;
private String cInvCCode; private String cInvCCode;
private String cInvCName; private String cInvCName;
private Date created; private String created;
private String createdBy; private String createdBy;
private Date lastUpdated; private String lastUpdated;
private String lastUpdatedBy; private String lastUpdatedBy;
} }