丽知:存货基本档案默认成套件为true

This commit is contained in:
zhengyf 2024-09-03 16:25:27 +08:00
parent 6ffaffa70d
commit 235d5cb1e9
1 changed files with 46 additions and 44 deletions

View File

@ -150,7 +150,7 @@ public class SKUPluginInitializer extends PluginBaseEntity {
queryOfsSKURequestVO.setLastUpdated_start(startTimeStr);
queryOfsSKURequestVO.setLastUpdated_end(endTimeStr);
List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO);
if (ofsskuList.size() == 0) {
if(ofsskuList.size()==0){
return;
}
//分组排序,
@ -158,7 +158,7 @@ public class SKUPluginInitializer extends PluginBaseEntity {
//过滤日志
List<OFSSKUSearchResponse.OFSSKU> filterSkus = filterData(sortSkuList);
if (filterSkus.size() == 0) {
if(filterSkus.size()==0){
return;
}
//具体实现
@ -182,7 +182,7 @@ public class SKUPluginInitializer extends PluginBaseEntity {
QueryOfsSKURequestVO queryOfsSKURequestVO = new QueryOfsSKURequestVO();
queryOfsSKURequestVO.setCode(split[0]);
List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO);
if (ofsskuList.size() == 0) {
if(ofsskuList.size()==0){
Assert.state(false, "根据OFS SKU主档编码{}未查询到SKU主档请检查入参或者OFS SKU主档。", split[0]);
}
//分组排序,
@ -190,7 +190,7 @@ public class SKUPluginInitializer extends PluginBaseEntity {
//过滤日志
List<OFSSKUSearchResponse.OFSSKU> filterSkus = filterData(sortSkuList);
if (filterSkus.size() == 0) {
if(filterSkus.size()==0){
Assert.state(false, "根据OFS SKU主档编码{},已被推送成功,请勿重新推送。", split[0]);
}
//具体实现
@ -216,16 +216,16 @@ public class SKUPluginInitializer extends PluginBaseEntity {
queryOfsSKURequestVO.setLastUpdated_start(start);
queryOfsSKURequestVO.setLastUpdated_end(end);
List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO);
if (ofsskuList.size() == 0) {
Assert.state(false, "根据期间:{} - {} 内未查询到OFS系统中SKU主档信息请检查。");
if(ofsskuList.size()==0){
Assert.state(false,"根据期间:{} - {} 内未查询到OFS系统中SKU主档信息请检查。");
}
//分组排序,
List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList);
//过滤日志
List<OFSSKUSearchResponse.OFSSKU> filterSkus = filterData(sortSkuList);
if (filterSkus.size() == 0) {
Assert.state(false, "根据期间:{} - {} 内询到OFS系统中SKU主档信息已全部推送请勿重新推送。");
if(filterSkus.size()==0){
Assert.state(false,"根据期间:{} - {} 内询到OFS系统中SKU主档信息已全部推送请勿重新推送。");
}
//具体实现
implement(filterSkus);
@ -239,14 +239,13 @@ public class SKUPluginInitializer extends PluginBaseEntity {
* 过滤成功日志
* rootAppPk
* [code]_[lastUpdated]
*
* @param ofsskuList
* @return
*/
public List<OFSSKUSearchResponse.OFSSKU> filterData(List<OFSSKUSearchResponse.OFSSKU> ofsskuList) {
public List<OFSSKUSearchResponse.OFSSKU> filterData(List<OFSSKUSearchResponse.OFSSKU> ofsskuList){
List<OFSSKUSearchResponse.OFSSKU> filterSkus = new ArrayList<>();
for (OFSSKUSearchResponse.OFSSKU ofssku : ofsskuList) {
String rootAppPk = ofssku.getCode() + "_" + ofssku.getLastUpdated();
String rootAppPk = ofssku.getCode()+"_"+ofssku.getLastUpdated();
boolean isExis = true;
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
@ -269,10 +268,10 @@ public class SKUPluginInitializer extends PluginBaseEntity {
* 注意
* 可能一家公司封存则则取消分配这家公司的存货管理档案
*/
public void implement(List<OFSSKUSearchResponse.OFSSKU> filterSkus) {
public void implement(List<OFSSKUSearchResponse.OFSSKU> filterSkus){
for (OFSSKUSearchResponse.OFSSKU sku : filterSkus) {
String PkInvbasdoc = "";
String PkInvbasdoc= "";
String url = "";
String mapStr = "";
String format = sku.getLastUpdated();
@ -285,14 +284,14 @@ public class SKUPluginInitializer extends PluginBaseEntity {
//查询是否存在返回pkInvbasdoc,如果有则是修改null则为新增
//查询该id再u8c是否有数据没有则是新增有则是修改 存货基本档案def2-ofs主键
PkInvbasdoc = queryInvbasDocIsExist(sku);
PkInvbasdoc=queryInvbasDocIsExist(sku);
if (PkInvbasdoc != null) {
//修改
parentvo.setPk_invbasdoc(PkInvbasdoc);
url = OverallConstant.getOverAllValue("bdinvclUpdateCode");
url=OverallConstant.getOverAllValue("bdinvclUpdateCode");
} else if (PkInvbasdoc == null) {
//新增
url = OverallConstant.getOverAllValue("bdinvclSaveCode");
url=OverallConstant.getOverAllValue("bdinvclSaveCode");
}
//def2 ofs id
@ -323,17 +322,20 @@ public class SKUPluginInitializer extends PluginBaseEntity {
//memo 备注
parentvo.setMemo(sku.getRemark());
//setpartsflag 成套件默认都是true
parentvo.setSetpartsflag("true");
invbasdoc.setParentvo(parentvo);
//子表,暂时没有要传的值
String jsonStr = JSONUtil.toJsonStr(invbasdoc);
mapStr = "{\"invbasdoc\":" + jsonStr + "}";
mapStr= "{\"invbasdoc\":" + jsonStr + "}";
ZTResult ztResult = pushU8CByApiCode.pushByCode(url, mapStr);
//两层判断,一层中台转发,一层u8c返回
Attribute attribute = ztResult.getAttribute();
if ("false".equals(ztResult.getFlag())) {
//转发失败
response = JSONUtil.toJsonStr(ztResult.getAttribute());
response=JSONUtil.toJsonStr(ztResult.getAttribute());
Assert.state(false, "丽知OFS货品档案--->U8C货品档案中台转发失败,失败原因:{}", ztResult.getAttribute());
}
boolean isSuccess = false;
@ -355,13 +357,13 @@ public class SKUPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData());
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(sku.getCode() + "_" + sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppPk(sku.getCode()+"_"+sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppBill(sku.getCode());
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
integrationTaskLivingDetailsEntity.setDef1(sku.getId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
} catch (Exception e) {
}catch (Exception e){
e.printStackTrace();
logger.error("推送U8C丽知OFS货品档案--->U8C货品档案失败失败原因" + e);
//失败
@ -374,7 +376,7 @@ public class SKUPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage);
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(sku.getCode() + "_" + sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppPk(sku.getCode()+"_"+sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppBill(sku.getCode());
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
integrationTaskLivingDetailsEntity.setDef1(sku.getId());
@ -385,64 +387,65 @@ public class SKUPluginInitializer extends PluginBaseEntity {
}
}
public String queryInvbasDocIsExist(OFSSKUSearchResponse.OFSSKU sku) {
String PkInvbasdoc = "";
public String queryInvbasDocIsExist(OFSSKUSearchResponse.OFSSKU sku){
String PkInvbasdoc="";
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
bdInvbasdocEntity.setDr(0L);
bdInvbasdocEntity.setDef2(sku.getId());
bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> bdInvbasdocEntityList = bdInvbasdocDao.query(bdInvbasdocEntity);//根据ofs id
if (bdInvbasdocEntityList.size() == 0) {
if(bdInvbasdocEntityList.size()==0){
bdInvbasdocEntity.setDef2(null);
bdInvbasdocEntity.setInvcode(sku.getCode());
bdInvbasdocEntity.setInvname(sku.getName());
List<BdInvbasdocEntity> bdInvbasdocEntityList1 = bdInvbasdocDao.query(bdInvbasdocEntity);//根据编码+名称
if (bdInvbasdocEntityList1.size() == 0) {
if(bdInvbasdocEntityList1.size()==0){
bdInvbasdocEntity.setInvname(null);
List<BdInvbasdocEntity> bdInvbasdocEntityList2 = bdInvbasdocDao.query(bdInvbasdocEntity);//进查询编码
if (bdInvbasdocEntityList2.size() == 0) {//编码不存在
return null;
} else if (bdInvbasdocEntityList2.size() == 1) {//编码存在
PkInvbasdoc = bdInvbasdocEntityList2.get(0).getPkInvbasdoc();//主键
PkInvbasdoc=bdInvbasdocEntityList2.get(0).getPkInvbasdoc();//主键
}
} else if (bdInvbasdocEntityList1.size() == 1) {
}else if(bdInvbasdocEntityList1.size()==1){
//修改
PkInvbasdoc = bdInvbasdocEntityList1.get(0).getPkInvbasdoc();//主键
PkInvbasdoc=bdInvbasdocEntityList1.get(0).getPkInvbasdoc();//主键
}
} else if (bdInvbasdocEntityList.size() == 1) {
}else if(bdInvbasdocEntityList.size()==1){
//修改
PkInvbasdoc = bdInvbasdocEntityList.get(0).getPkInvbasdoc();//主键
} else {
PkInvbasdoc=bdInvbasdocEntityList.get(0).getPkInvbasdoc();//主键
}else {
//异常,存在多个
Assert.state(false, "SKU主档编码{}id{}。U8C存货基本档案def2OFS中SKU主档id存在多个请检查。", sku.getCode(), sku.getId());
Assert.state(false,"SKU主档编码{}id{}。U8C存货基本档案def2OFS中SKU主档id存在多个请检查。",sku.getCode(),sku.getId());
}
return PkInvbasdoc;
}
/**
* 按code分组并按lastUpdated排序
*
* @param ofsskuList
* @return
*/
public List<OFSSKUSearchResponse.OFSSKU> groupAndSort(List<OFSSKUSearchResponse.OFSSKU> ofsskuList) {
List<OFSSKUSearchResponse.OFSSKU> sortSkus = new ArrayList<>();
public List<OFSSKUSearchResponse.OFSSKU> groupAndSort(List<OFSSKUSearchResponse.OFSSKU> ofsskuList){
List<OFSSKUSearchResponse.OFSSKU> sortSkus=new ArrayList<>();
//根据code进行分组
Map<String, List<OFSSKUSearchResponse.OFSSKU>> collectMapByCode = ofsskuList.stream().collect(Collectors.groupingBy(OFSSKUSearchResponse.OFSSKU::getCode));
Map<String, List<OFSSKUSearchResponse.OFSSKU>> collectMapByCode =
ofsskuList.stream().collect(Collectors.groupingBy(OFSSKUSearchResponse.OFSSKU::getCode));
collectMapByCode.forEach((k, v) -> {
collectMapByCode.forEach((k,v)->{
//降序排序 (从新到旧),根据最后修改时间倒排
List<OFSSKUSearchResponse.OFSSKU> sorted = v.stream().sorted(Comparator.comparing(OFSSKUSearchResponse.OFSSKU::getLastUpdated).reversed()).collect(Collectors.toList());
List<OFSSKUSearchResponse.OFSSKU> sorted =
v.stream().sorted(Comparator.comparing(OFSSKUSearchResponse.OFSSKU::getLastUpdated).reversed()).collect(Collectors.toList());
//排除status==0的
for (int i = 0; i < sorted.size(); i++) {
if ("0".equals(sorted.get(i).getStatus())) {
if("0".equals(sorted.get(i).getStatus())){
sorted.remove(i);
}
}
if (sorted.size() != 0) {
if(sorted.size()!=0){
sortSkus.add(sorted.get(0));//只取最后修改的一个
}
});
@ -452,7 +455,7 @@ public class SKUPluginInitializer extends PluginBaseEntity {
/**
* 封存存货基本档案
*/
public void sealImplement(String code) {
public void sealImplement(String code){
}
@ -493,7 +496,6 @@ public class SKUPluginInitializer extends PluginBaseEntity {
}
return all;
}
private InvBasDocVO resultDataHandle(String resultData) {
try {
if (resultData != null && !"".equals(resultData)) {