|
|
|
@ -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<OFSSKUClassSearchResponse.SKUClass> skuClasses = querySkuClass(queryOfsSKUClassRequestVO);
|
|
|
|
|
System.out.println(skuClasses);
|
|
|
|
|
|
|
|
|
|
//过滤日志
|
|
|
|
|
List<OFSSKUClassSearchResponse.SKUClass> 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<OFSSKUClassSearchResponse.SKUClass> skuClasses = querySkuClass(queryOfsSKUClassRequestVO);
|
|
|
|
|
|
|
|
|
|
//过滤日志
|
|
|
|
|
List<OFSSKUClassSearchResponse.SKUClass> filterGoodsClass = filterData(skuClasses);
|
|
|
|
|
|
|
|
|
|
//推送
|
|
|
|
|
implement(filterGoodsClass);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,start(String className)方法报错:", e);
|
|
|
|
|
}
|
|
|
|
@ -141,135 +200,357 @@ 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<OFSSKUClassSearchResponse.SKUClass> skuClasses = querySkuClass(queryOfsSKUClassRequestVO);
|
|
|
|
|
//过滤日志
|
|
|
|
|
List<OFSSKUClassSearchResponse.SKUClass> filterGoodsClass = filterData(skuClasses);
|
|
|
|
|
|
|
|
|
|
//推送
|
|
|
|
|
implement(filterGoodsClass);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,start(String startTime, String endTime)方法报错:", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void filterGoodsClass() {
|
|
|
|
|
return;
|
|
|
|
|
public List<OFSSKUClassSearchResponse.SKUClass> filterData(List<OFSSKUClassSearchResponse.SKUClass> skuClasses) {
|
|
|
|
|
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,自动截断
|
|
|
|
|
* eg:
|
|
|
|
|
* 一级:AA
|
|
|
|
|
* 二级:AA001,自动识别为AA的下级
|
|
|
|
|
* 三级:AA00101自动识别为AA001的下级
|
|
|
|
|
* 二级: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<OFSSKUClassSearchResponse.SKUClass> filterSKUClasss) {
|
|
|
|
|
String mapStr=null;
|
|
|
|
|
String businessFormat=null;
|
|
|
|
|
|
|
|
|
|
for (OFSSKUClassSearchResponse.SKUClass skuClass : filterSKUClasss) {
|
|
|
|
|
businessFormat=skuClass.getLastUpdated();
|
|
|
|
|
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 bdInvcl = new BdInvclEntity();
|
|
|
|
|
if (bdInvclEntityList.size() == 0) {
|
|
|
|
|
bdInvclEntity.setForinvname(null);
|
|
|
|
|
bdInvclEntity.setInvclasscode(skuClass.getCInvCCode());
|
|
|
|
|
bdInvclEntity.setInvclassname(skuClass.getCInvCName());
|
|
|
|
|
List<BdInvclEntity> 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
|
|
|
|
|
invclasscode = "AA004";
|
|
|
|
|
bdInvclEntity.setInvclasscode(invclasscode);
|
|
|
|
|
|
|
|
|
|
bdInvclEntity.setInvclasscode(skuClass.getCInvCCode());
|
|
|
|
|
//分类名称-invclassname
|
|
|
|
|
invclassname = "分类名称:AA004";
|
|
|
|
|
|
|
|
|
|
bdInvclEntity.setInvclassname(invclassname);
|
|
|
|
|
bdInvclEntity.setInvclassname(skuClass.getCInvCName());
|
|
|
|
|
//公司编码-pk_corp
|
|
|
|
|
String pk_corp = "1001";
|
|
|
|
|
bdInvclEntity.setPk_corp(pk_corp);
|
|
|
|
|
//分类级别-invclasslevel
|
|
|
|
|
bdInvclEntity.setPk_corp("0001");
|
|
|
|
|
//外文名 forinvname(ofs存货分类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);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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, "推送U8C-->丽知:OFS货品档案分类--->U8C货品档案分类失败 接口返回结果:{} 接口入参:{}", response, jsonStr);
|
|
|
|
|
Assert.state(false, "丽知:OFS货品档案分类--->U8C货品档案分类 失败 接口返回结果:{} 接口入参:{}", attribute.getErrormsg(), mapStr);
|
|
|
|
|
}
|
|
|
|
|
//成功
|
|
|
|
|
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
|
|
|
|
|
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setNewTransmitInfo(response);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData());
|
|
|
|
|
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
|
|
|
|
|
integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setRootAppBill(invclassname);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode+"_"+businessFormat);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setRootAppBill(invclasscode);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
|
|
|
|
|
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}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.setRootAppPk(skuClass.getCInvCCode()+"_"+businessFormat);
|
|
|
|
|
integrationTaskLivingDetailsEntity.setRootAppBill(skuClass.getCInvCCode());
|
|
|
|
|
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("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<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("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<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){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* OFS存货分类查询
|
|
|
|
|
*/
|
|
|
|
|
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();
|
|
|
|
|
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<OFSSKUClassSearchResponse.SKUClass> 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<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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|