丽知:修改存货基本档案新增、封存。

This commit is contained in:
zhengyf 2024-09-09 18:10:38 +08:00
parent 149b43bdd0
commit 01a7b2a473
6 changed files with 204 additions and 137 deletions

View File

@ -113,6 +113,17 @@ public class BdInvbasdocEntity extends BaseEntity {
*/ */
private String createtime_end_time; private String createtime_end_time;
/**
* createtime开始时间
*/
private String modifytime_start_time;
/**
* createtime结束时间
*/
private String modifytime_end_time;
/** /**
* 管理档案公司主键 * 管理档案公司主键
*/ */
@ -142,6 +153,22 @@ public class BdInvbasdocEntity extends BaseEntity {
this.createtime_end_time = createtime_end_time; this.createtime_end_time = createtime_end_time;
} }
public String getModifytime_start_time() {
return modifytime_start_time;
}
public void setModifytime_start_time(String modifytime_start_time) {
this.modifytime_start_time = modifytime_start_time;
}
public String getModifytime_end_time() {
return modifytime_end_time;
}
public void setModifytime_end_time(String modifytime_end_time) {
this.modifytime_end_time = modifytime_end_time;
}
public String getPk_corp() { public String getPk_corp() {
return pk_corp; return pk_corp;
} }

View File

@ -259,6 +259,10 @@
<if test="createtime_start_time!=null and createtime_start_time!=''">and createtime >= #{createtime_start_time}</if> <if test="createtime_start_time!=null and createtime_start_time!=''">and createtime >= #{createtime_start_time}</if>
<if test="createtime_end_time!=null and createtime_end_time!=''">and createtime &lt;= #{createtime_end_time}</if> <if test="createtime_end_time!=null and createtime_end_time!=''">and createtime &lt;= #{createtime_end_time}</if>
<if test="modifytime_start_time!=null and modifytime_start_time!=''">and ts >= #{modifytime_start_time}</if>
<if test="modifytime_end_time!=null and modifytime_end_time!=''">and ts &lt;= #{modifytime_end_time}</if>
and dr=0
</trim> </trim>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if> <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select> </select>

View File

@ -97,8 +97,8 @@ public class GoodsAutoAllotPluginInitializer extends PluginBaseEntity {
String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"); String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss");
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
bdInvbasdocEntity.setCreatetime_start_time(startTimeStr); bdInvbasdocEntity.setModifytime_start_time(startTimeStr);
bdInvbasdocEntity.setCreatetime_end_time(endTimeStr); bdInvbasdocEntity.setModifytime_end_time(endTimeStr);
bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> bdInvbasdocEntityList = bdInvbasdocDao.query(bdInvbasdocEntity); List<BdInvbasdocEntity> bdInvbasdocEntityList = bdInvbasdocDao.query(bdInvbasdocEntity);
@ -158,8 +158,8 @@ public class GoodsAutoAllotPluginInitializer extends PluginBaseEntity {
String end = DateUtil.format(business_end, "yyyy-MM-dd") + " 23:59:59"; String end = DateUtil.format(business_end, "yyyy-MM-dd") + " 23:59:59";
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
bdInvbasdocEntity.setCreatetime_start_time(start); bdInvbasdocEntity.setModifytime_start_time(start);
bdInvbasdocEntity.setCreatetime_end_time(end); bdInvbasdocEntity.setModifytime_end_time(end);
bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> bdInvbasdocEntityList = bdInvbasdocDao.query(bdInvbasdocEntity); List<BdInvbasdocEntity> bdInvbasdocEntityList = bdInvbasdocDao.query(bdInvbasdocEntity);
if (bdInvbasdocEntityList.size() == 0) { if (bdInvbasdocEntityList.size() == 0) {

View File

@ -473,6 +473,7 @@ public class SKUPluginInitializer extends PluginBaseEntity {
InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto(); InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto();
interfaceParamDto.setApi("ofs.sku.search"); interfaceParamDto.setApi("ofs.sku.search");
queryOfsSKURequestVO.setClientCode("LETS"); queryOfsSKURequestVO.setClientCode("LETS");
queryOfsSKURequestVO.setStatus("1");
queryOfsSKURequestVO.setPageNo(String.valueOf(pageNo)); queryOfsSKURequestVO.setPageNo(String.valueOf(pageNo));
queryOfsSKURequestVO.setPageSize(String.valueOf(pageSize)); queryOfsSKURequestVO.setPageSize(String.valueOf(pageSize));
interfaceParamDto.setData(JSON.toJSONString(queryOfsSKURequestVO)); interfaceParamDto.setData(JSON.toJSONString(queryOfsSKURequestVO));

View File

@ -15,6 +15,7 @@ import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSKURequestVO;
import com.hzya.frame.plugin.lets.u8cdto.InvBasDocVO; import com.hzya.frame.plugin.lets.u8cdto.InvBasDocVO;
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.QueryU8CEntityUtil;
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.Attribute;
import com.hzya.frame.plugin.lets.util.pushData.PushU8CByApiCode; import com.hzya.frame.plugin.lets.util.pushData.PushU8CByApiCode;
@ -36,6 +37,7 @@ import java.util.stream.Collectors;
/** /**
* OFS->U8C货品档案 封存解封 * OFS->U8C货品档案 封存解封
* add by zyd 20240902 * add by zyd 20240902
* 不过滤状态根据状态判断
*/ */
public class SKUSealPluginInitializer extends PluginBaseEntity { public class SKUSealPluginInitializer extends PluginBaseEntity {
@ -87,6 +89,8 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
@Autowired @Autowired
private IBdInvbasdocDao bdInvbasdocDao; private IBdInvbasdocDao bdInvbasdocDao;
@Autowired
private QueryU8CEntityUtil queryU8CEntityUtil;
@Override @Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
@ -142,19 +146,14 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
queryOfsSKURequestVO.setLastUpdated_start(startTimeStr); queryOfsSKURequestVO.setLastUpdated_start(startTimeStr);
queryOfsSKURequestVO.setLastUpdated_end(endTimeStr); queryOfsSKURequestVO.setLastUpdated_end(endTimeStr);
List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO); List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO);
if(ofsskuList.size()==0){ if (ofsskuList.size() == 0) {
return; return;
} }
// //分组排序, //找到最后修改时间的进行过滤
// List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList);
// //查询物料的所有公司根据物料分组
// //过滤日志
// List<OFSSKUSearchResponse.OFSSKU> filterSkus = filterData(sortSkuList); //推送
// if(filterSkus.size()==0){
// return;
// }
// //具体实现
// implement(filterSkus);
} catch (Exception e) { } catch (Exception e) {
@ -163,10 +162,7 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
} }
/** /**
* 按sku名称 * 按sku名称没有过滤状态
* 存在 编码相同名称不一样的情况
* 先根据code分组在根据修改时间倒排
* 按修改时间倒排取最新的修改时间
*/ */
public void start(String goodsCode) { public void start(String goodsCode) {
String[] split = goodsCode.split("_"); String[] split = goodsCode.split("_");
@ -174,19 +170,19 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
QueryOfsSKURequestVO queryOfsSKURequestVO = new QueryOfsSKURequestVO(); QueryOfsSKURequestVO queryOfsSKURequestVO = new QueryOfsSKURequestVO();
queryOfsSKURequestVO.setCode(split[0]); queryOfsSKURequestVO.setCode(split[0]);
List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO); List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO);
if(ofsskuList.size()==0){ if (ofsskuList.size() == 0) {
Assert.state(false, "根据OFS SKU主档编码{}未查询到SKU主档请检查入参或者OFS SKU主档。", split[0]); Assert.state(false, "根据OFS SKU主档编码{}未查询到SKU主档请检查入参或者OFS SKU主档。", split[0]);
} }
//分组排序,
List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList);
//过滤日志 //找到最后修改时间的进行过滤
List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList);
List<OFSSKUSearchResponse.OFSSKU> filterSkus = filterData(sortSkuList); List<OFSSKUSearchResponse.OFSSKU> filterSkus = filterData(sortSkuList);
if(filterSkus.size()==0){
Assert.state(false, "根据OFS SKU主档编码{},已被推送成功,请勿重新推送。", split[0]); //查到每个code下所有的公司并且分组得到一个map
} Map<String, List<OFSSKUSearchResponse.OFSSKU>> skuMap = getSkuMap(filterSkus);
//具体实现
implement(filterSkus); //循环map实现
sealImplement(skuMap);
} catch (Exception e) { } catch (Exception e) {
logger.error("丽知OFS货品档案--->U8C货品档案封存、取消封存,start(String goodsName)方法报错:", e); logger.error("丽知OFS货品档案--->U8C货品档案封存、取消封存,start(String goodsName)方法报错:", e);
@ -208,8 +204,8 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
queryOfsSKURequestVO.setLastUpdated_start(start); queryOfsSKURequestVO.setLastUpdated_start(start);
queryOfsSKURequestVO.setLastUpdated_end(end); queryOfsSKURequestVO.setLastUpdated_end(end);
List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO); List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO);
if(ofsskuList.size()==0){ if (ofsskuList.size() == 0) {
Assert.state(false,"根据期间:{} - {} 内未查询到OFS系统中SKU主档信息请检查。"); Assert.state(false, "根据期间:{} - {} 内未查询到OFS系统中SKU主档信息请检查。");
} }
// //分组排序, // //分组排序,
// List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList); // List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList);
@ -231,13 +227,14 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
* 过滤成功日志 * 过滤成功日志
* rootAppPk * rootAppPk
* [code]_[lastUpdated] * [code]_[lastUpdated]
*
* @param ofsskuList * @param ofsskuList
* @return * @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<>(); List<OFSSKUSearchResponse.OFSSKU> filterSkus = new ArrayList<>();
for (OFSSKUSearchResponse.OFSSKU ofssku : ofsskuList) { for (OFSSKUSearchResponse.OFSSKU ofssku : ofsskuList) {
String rootAppPk = ofssku.getCode()+"_"+ofssku.getLastUpdated(); String rootAppPk = ofssku.getCode() + "_" + ofssku.getLastUpdated();
boolean isExis = true; boolean isExis = true;
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk); integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
@ -255,90 +252,83 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
return filterSkus; return filterSkus;
} }
/** /**
* 推送 * sealflag 封存标志
* 注意 *
* 可能一家公司封存则则取消分配这家公司的存货管理档案 * @param skuMap
*/ */
public void implement(List<OFSSKUSearchResponse.OFSSKU> filterSkus){ public void sealImplement(Map<String, List<OFSSKUSearchResponse.OFSSKU>> skuMap) {
for (OFSSKUSearchResponse.OFSSKU sku : filterSkus) { skuMap.forEach((k, v) -> {
String PkInvbasdoc= "";
String url = "";
String mapStr = ""; String mapStr = "";
String format = sku.getLastUpdated(); String format = "";
String response = ""; String response = "";
String ofsCode = "";
OFSSKUSearchResponse.OFSSKU sku=null;
try { try {
InvBasDocVO invbasdoc = new InvBasDocVO(); //kcode
//主表 //vskuList
InvBasDocVO.Parent parentvo = new InvBasDocVO.Parent(); String pk_invbasdoc = null;
String url = null;
//查询是否存在返回pkInvbasdoc,如果有则是修改null则为新增 boolean isSeal = false;
//查询该id再u8c是否有数据没有则是新增有则是修改 存货基本档案def2-ofs主键 for (OFSSKUSearchResponse.OFSSKU ofssku : v) {
PkInvbasdoc=queryInvbasDocIsExist(sku); if ("1".equals(ofssku.getStatus())) {//status 0禁用 1启用
if (PkInvbasdoc != null) { isSeal = true;
//修改 break;
parentvo.setPk_invbasdoc(PkInvbasdoc); }
url=OverallConstant.getOverAllValue("bdinvclUpdateCode"); }
} else if (PkInvbasdoc == null) { //isSeal=false为全公司禁用所以封存
//新增 //isSeal=true可能不只一家启用所以解封先查询如果没有封存则不处理
url=OverallConstant.getOverAllValue("bdinvclSaveCode"); if (!isSeal) {//isSeal=false为全公司禁用所以封存
//封存
BdInvbasdocEntity bdInvbasdocEntity = queryU8CEntityUtil.queryBdInvbasdocByCode(k);
if (bdInvbasdocEntity == null) {
Assert.state(false, "根据存货编码:{}未查询到U8C存货基本档案。", k);
}
if ("Y".equals(bdInvbasdocEntity.getSealflag())) {
return;
} else if ("N".equals(bdInvbasdocEntity.getSealflag())) {
pk_invbasdoc = bdInvbasdocEntity.getPkInvbasdoc();
url = OverallConstant.getOverAllValue("bdinvclSealCode");
}
}
if (isSeal) {//isSeal=true可能不只一家启用所以解封先查询如果没有封存则不处理
//解封,判断是否封存若已封存则处理反之不处理
BdInvbasdocEntity bdInvbasdocEntity = queryU8CEntityUtil.queryBdInvbasdocByCode(k);
if (bdInvbasdocEntity == null) {
Assert.state(false, "根据存货编码:{}未查询到U8C存货基本档案。", k);
}
if ("N".equals(bdInvbasdocEntity.getSealflag())) {
return;
} else if ("Y".equals(bdInvbasdocEntity.getSealflag())) {
pk_invbasdoc = bdInvbasdocEntity.getPkInvbasdoc();
url = OverallConstant.getOverAllValue("bdinvclUnsealCode");
}
} }
//def2 ofs id //推送
parentvo.setDef2(sku.getId()); mapStr = "{\"pk_invbasdoc\":" + pk_invbasdoc + "}";
//invcode 存货编码
parentvo.setInvcode(sku.getCode());
//invmnecode 助记码
parentvo.setInvmnecode(sku.getCode());
//invname 存货名称
parentvo.setInvname(sku.getName());
//invshortname 存货简称
parentvo.setInvshortname(sku.getName());
//pk_invcl 分类
parentvo.setPk_invcl(sku.getCInvCCode());
//def1 ofs品牌
parentvo.setDef1(sku.getBrandCode());
//pk_measdoc 主计量单位ofs没有单位默认个20240830万万同意
parentvo.setPk_measdoc("EA");
//pk_taxitems 税率 4001 商业13 % ) 13.00000000
parentvo.setPk_taxitems("4001");
//creator 创建人
parentvo.setCreator("tbadmin");
//memo 备注
parentvo.setMemo(sku.getRemark());
invbasdoc.setParentvo(parentvo);
//子表,暂时没有要传的值
String jsonStr = JSONUtil.toJsonStr(invbasdoc);
mapStr= "{\"invbasdoc\":" + jsonStr + "}";
ZTResult ztResult = pushU8CByApiCode.pushByCode(url, mapStr); ZTResult ztResult = pushU8CByApiCode.pushByCode(url, mapStr);
//两层判断,一层中台转发,一层u8c返回
Attribute attribute = ztResult.getAttribute();
if ("false".equals(ztResult.getFlag())) { if ("false".equals(ztResult.getFlag())) {
//转发失败 //转发失败
response=JSONUtil.toJsonStr(ztResult.getAttribute()); response = JSONUtil.toJsonStr(ztResult.getAttribute());
Assert.state(false, "丽知:OFS货品档案--->U8C货品档案封存、取消封存中台转发失败,失败原因:{}", ztResult.getAttribute()); Assert.state(false, "丽知U8C货品档案封存、取消封存中台转发失败,失败原因:{}", ztResult.getAttribute());
} }
Attribute attribute = ztResult.getAttribute();
boolean isSuccess = false; boolean isSuccess = false;
String invbascode = "";
if ("success".equals(attribute.getStatus())) { if ("success".equals(attribute.getStatus())) {
isSuccess = true; isSuccess = true;
String data = attribute.getData(); String data = attribute.getData();
InvBasDocVO resInvBasDocVO = resultDataHandle(data); System.out.println(data);
invbascode = resInvBasDocVO.getParentvo().getInvcode();
} }
if (!isSuccess) { if (!isSuccess) {
Assert.state(false, "丽知OFS货品档案--->U8C货品档案封存、取消封存 失败 接口返回结果:{} 接口入参:{}", attribute.getErrormsg(), mapStr); Assert.state(false, "推送U8C--> 丽知U8C货品档案封存、取消封存 失败 接口返回结果:{} 接口入参:{}", attribute.getErrormsg(), mapStr);
} }
//获取最后修改的对象
List<OFSSKUSearchResponse.OFSSKU> ofsskus = groupAndSort(v);
sku = ofsskus.get(0);
//成功 //成功
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
@ -346,18 +336,18 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData()); integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData());
integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format); integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(sku.getCode()+"_"+sku.getLastUpdated()); integrationTaskLivingDetailsEntity.setRootAppPk(k + "_" + sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppBill(sku.getCode()); integrationTaskLivingDetailsEntity.setRootAppBill(k);
integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
integrationTaskLivingDetailsEntity.setDef1(sku.getId()); integrationTaskLivingDetailsEntity.setNewSystemNumber(k);
integrationTaskLivingDetailsEntity.setNewSystemPrimary(sku.getId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
} catch (Exception e) {
}catch (Exception e){ //失败
e.printStackTrace(); e.printStackTrace();
logger.error("推送U8C丽知OFS货品档案--->U8C货品档案封存、取消封存失败失败原因" + e); logger.error("推送U8C丽知OFS货品档案--->U8C货品档案封存、取消封存失败失败原因" + e);
//失败
ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class); ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class);
String ErrMessage = "推送U8C丽知OFS货品档案--->U8C货品档案(封存、取消封存)失败,失败原因:" + reusltStrDto.getErrormsg(); String ErrMessage = "推送U8C货品档案(封存、取消封存)失败,失败原因:" + reusltStrDto.getErrormsg();
//失败 //失败
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N);
@ -365,88 +355,101 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage);
integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format); integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(sku.getCode()+"_"+sku.getLastUpdated()); integrationTaskLivingDetailsEntity.setRootAppPk(k+"_"+sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppBill(sku.getCode()); integrationTaskLivingDetailsEntity.setRootAppBill(k);
integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
integrationTaskLivingDetailsEntity.setDef1(sku.getId()); integrationTaskLivingDetailsEntity.setNewSystemNumber(k);
integrationTaskLivingDetailsEntity.setNewSystemPrimary(sku.getId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
} }
});
}
} }
public String queryInvbasDocIsExist(OFSSKUSearchResponse.OFSSKU sku){ /**
String PkInvbasdoc=""; * 封存编码不会重复可以根据编码查询主键
* 8000370058 存货基本档案封存
*/
public void seal(OFSSKUSearchResponse.OFSSKU sku) {
BdInvbasdocEntity bdInvbasdocEntity = queryU8CEntityUtil.queryBdInvbasdocByCode(sku.getCode());
}
/**
* 解封编码不会重复可以根据编码查询主键
* 8000370059 存货基本档案取消封存
*/
public void noSeal() {
}
public String queryInvbasDocIsExist(OFSSKUSearchResponse.OFSSKU sku) {
String PkInvbasdoc = "";
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
bdInvbasdocEntity.setDr(0L); bdInvbasdocEntity.setDr(0L);
bdInvbasdocEntity.setDef2(sku.getId()); bdInvbasdocEntity.setDef2(sku.getId());
bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> bdInvbasdocEntityList = bdInvbasdocDao.query(bdInvbasdocEntity);//根据ofs id List<BdInvbasdocEntity> bdInvbasdocEntityList = bdInvbasdocDao.query(bdInvbasdocEntity);//根据ofs id
if(bdInvbasdocEntityList.size()==0){ if (bdInvbasdocEntityList.size() == 0) {
bdInvbasdocEntity.setDef2(null); bdInvbasdocEntity.setDef2(null);
bdInvbasdocEntity.setInvcode(sku.getCode()); bdInvbasdocEntity.setInvcode(sku.getCode());
bdInvbasdocEntity.setInvname(sku.getName()); bdInvbasdocEntity.setInvname(sku.getName());
List<BdInvbasdocEntity> bdInvbasdocEntityList1 = bdInvbasdocDao.query(bdInvbasdocEntity);//根据编码+名称 List<BdInvbasdocEntity> bdInvbasdocEntityList1 = bdInvbasdocDao.query(bdInvbasdocEntity);//根据编码+名称
if(bdInvbasdocEntityList1.size()==0){ if (bdInvbasdocEntityList1.size() == 0) {
bdInvbasdocEntity.setInvname(null); bdInvbasdocEntity.setInvname(null);
List<BdInvbasdocEntity> bdInvbasdocEntityList2 = bdInvbasdocDao.query(bdInvbasdocEntity);//进查询编码 List<BdInvbasdocEntity> bdInvbasdocEntityList2 = bdInvbasdocDao.query(bdInvbasdocEntity);//进查询编码
if (bdInvbasdocEntityList2.size() == 0) {//编码不存在 if (bdInvbasdocEntityList2.size() == 0) {//编码不存在
return null; return null;
} else if (bdInvbasdocEntityList2.size() == 1) {//编码存在 } 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();//主键 PkInvbasdoc = bdInvbasdocEntityList.get(0).getPkInvbasdoc();//主键
}else { } 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; return PkInvbasdoc;
} }
/** /**
* 按code分组并按lastUpdated排序 * 按code分组并按lastUpdated排序
*
* @param ofsskuList * @param ofsskuList
* @return * @return
*/ */
public List<OFSSKUSearchResponse.OFSSKU> groupAndSort(List<OFSSKUSearchResponse.OFSSKU> ofsskuList){ public List<OFSSKUSearchResponse.OFSSKU> groupAndSort(List<OFSSKUSearchResponse.OFSSKU> ofsskuList) {
List<OFSSKUSearchResponse.OFSSKU> sortSkus=new ArrayList<>(); List<OFSSKUSearchResponse.OFSSKU> sortSkus = new ArrayList<>();
//根据code进行分组 //根据code进行分组
Map<String, List<OFSSKUSearchResponse.OFSSKU>> collectMapByCode = Map<String, List<OFSSKUSearchResponse.OFSSKU>> collectMapByCode =
ofsskuList.stream().collect(Collectors.groupingBy(OFSSKUSearchResponse.OFSSKU::getCode)); ofsskuList.stream().collect(Collectors.groupingBy(OFSSKUSearchResponse.OFSSKU::getCode));
collectMapByCode.forEach((k,v)->{ collectMapByCode.forEach((k, v) -> {
//降序排序 (从新到旧),根据最后修改时间倒排 //降序排序 (从新到旧),根据最后修改时间倒排
List<OFSSKUSearchResponse.OFSSKU> sorted = List<OFSSKUSearchResponse.OFSSKU> sorted =
v.stream().sorted(Comparator.comparing(OFSSKUSearchResponse.OFSSKU::getLastUpdated).reversed()).collect(Collectors.toList()); v.stream().sorted(Comparator.comparing(OFSSKUSearchResponse.OFSSKU::getLastUpdated).reversed()).collect(Collectors.toList());
//排除status==0的 //排除status==0的
for (int i = 0; i < sorted.size(); i++) { 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); sorted.remove(i);
} }
} }
if(sorted.size()!=0){ if (sorted.size() != 0) {
sortSkus.add(sorted.get(0));//只取最后修改的一个 sortSkus.add(sorted.get(0));//只取最后修改的一个
} }
}); });
return sortSkus; return sortSkus;
} }
/**
* 封存存货基本档案
*/
public void sealImplement(String code){
}
/** /**
* 查询OFS SKU档案 * 查询OFS SKU档案
@ -485,6 +488,27 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
} }
return all; return all;
} }
/**
* 根据编码获取每个组织下的档案
*
* @param filterSkus list里面的sku均不一样
* @return
*/
public Map<String, List<OFSSKUSearchResponse.OFSSKU>> getSkuMap(List<OFSSKUSearchResponse.OFSSKU> filterSkus) throws Exception {
Map<String, List<OFSSKUSearchResponse.OFSSKU>> map = new HashMap<>();
QueryOfsSKURequestVO queryOfsSKURequestVO = new QueryOfsSKURequestVO();
for (OFSSKUSearchResponse.OFSSKU sku : filterSkus) {
queryOfsSKURequestVO.setCode(sku.getCode());
List<OFSSKUSearchResponse.OFSSKU> ofsskus = queryOfsSKUs(queryOfsSKURequestVO);
map.put(sku.getCode(), ofsskus);
}
return map;
}
private InvBasDocVO resultDataHandle(String resultData) { private InvBasDocVO resultDataHandle(String resultData) {
try { try {
if (resultData != null && !"".equals(resultData)) { if (resultData != null && !"".equals(resultData)) {

View File

@ -14,6 +14,8 @@ public class BaseTest {
@Autowired @Autowired
private SKUPluginInitializer skuPluginInitializer; private SKUPluginInitializer skuPluginInitializer;
@Autowired @Autowired
private SKUSealPluginInitializer skuSealPluginInitializer;
@Autowired
private SKUClassPluginInitializer skuClassPluginInitializer; private SKUClassPluginInitializer skuClassPluginInitializer;
@Autowired @Autowired
private GoodsAutoAllotPluginInitializer goodsAutoAllotPluginInitializer; private GoodsAutoAllotPluginInitializer goodsAutoAllotPluginInitializer;
@ -25,17 +27,26 @@ public class BaseTest {
} }
@Test @Test
public void t01(){ public void t01(){
skuPluginInitializer.start("6971898450656"); skuPluginInitializer.start("6971229882248");
} }
@Test @Test
public void t02(){ public void t02(){
skuPluginInitializer.start("2024-08-28","2024-08-29"); skuPluginInitializer.start("2024-08-28","2024-08-29");
} }
////////////////////////////////////////////////////////////////////////////////////SKU封存给
@Test
public void t31(){
skuSealPluginInitializer.start("6971229882248");
}
////////////////////////////////////////////////////////////////////////////////////SKU自动分配 ////////////////////////////////////////////////////////////////////////////////////SKU自动分配
@Test @Test
public void t10(){ public void t10(){
// goodsAutoAllotPluginInitializer.start("0001A210000000000U4C"); goodsAutoAllotPluginInitializer.start("6973391735469");
goodsAutoAllotPluginInitializer.start("6971229882248"); }
@Test
public void t11(){
goodsAutoAllotPluginInitializer.start("2024-09-09","2024-09-09");
} }
////////////////////////////////////////////////////////////////////////////////////SKU分类 ////////////////////////////////////////////////////////////////////////////////////SKU分类
@Test @Test