Merge remote-tracking branch 'origin/lets' into lets

This commit is contained in:
liuy 2024-09-10 15:02:36 +08:00
commit c03dd59dcd
16 changed files with 565 additions and 309 deletions

View File

@ -26,6 +26,7 @@ public class ProfilesActiveConstant {
public static final String TYPE_OTHER = "other";
public static final String U8C_URL = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface";
//public static final String U8C_URL = "http://ufidahz.com.cn:9067/kangarooDataCenterV3/entranceController/externalCallInterface";
public static final String OFS_URL_TEST = "http://39.98.58.229/api/edi/ofs/in";
public static final String SUPPLIER = "'1','3'";

View File

@ -18,12 +18,12 @@ public class IcGeneralBDaoImpl extends MybatisGenericDao<IcGeneralBEntity, Strin
@Override
public List<IcGeneralBEntity> queryByCgeneralhid(String cgeneralhid) {
return query("com.hzya.frame.plugin.lets.entity.IcGeneralBEntity.queryByCgeneralhid",cgeneralhid);
return query("com.hzya.frame.plugin.lets.dao.impl.IcGeneralBDaoImpl.queryByCgeneralhid",cgeneralhid);
}
@Override
@DS(ProfilesActiveConstant.LETS_DATE_SOURCE)
@Override
public List<IcGeneralBEntity> queryAndCinvbasCode(String cgeneralhid) {
return (List<IcGeneralBEntity>)selectList("com.hzya.frame.plugin.lets.entity.IcGeneralBEntity.queryAndCinvbasCode",cgeneralhid);
return (List<IcGeneralBEntity>)selectList("com.hzya.frame.plugin.lets.dao.impl.IcGeneralBDaoImpl.queryAndCinvbasCode",cgeneralhid);
}
}

View File

@ -103,6 +103,35 @@ public class BdCubasdocEntity extends BaseEntity {
*/
private String end_createtime;
/**
* modifytime开始时间
*/
private String modifytime_start_time;
/**
* modifytime结束时间
*/
private String modifytime_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 getStart_createtime() {
return start_createtime;
}

View File

@ -229,6 +229,9 @@
<if test="start_createtime!=null and start_createtime!=''"> and createtime >= #{start_createtime}</if>
<if test="end_createtime!=null and end_createtime!=''">and createtime &lt;= #{end_createtime}</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>
</trim>
<if test=" sort == ''.toString() "> order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>

View File

@ -113,6 +113,17 @@ public class BdInvbasdocEntity extends BaseEntity {
*/
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;
}
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() {
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_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>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

View File

@ -1,12 +1,16 @@
package com.hzya.frame.plugin.lets.plugin.base;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import com.alibaba.fastjson.JSON;
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.IBdCubasdocDao;
import com.hzya.frame.plugin.lets.entity.BdCorpEntity;
import com.hzya.frame.plugin.lets.entity.BdCubasdocEntity;
import com.hzya.frame.plugin.lets.entity.BdInvbasdocEntity;
import com.hzya.frame.plugin.lets.queryvo.CustDocAssginVo;
import com.hzya.frame.plugin.lets.queryvo.CustdocRequestVo;
@ -14,6 +18,9 @@ import com.hzya.frame.plugin.lets.resultvo.CbdocResultVo;
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.dto.ofsBaseSearch.OfsShopDto;
@ -74,10 +81,13 @@ public class CustdocAutoAllotPluginInitializer extends PluginBaseEntity {
private PushDataByU8cUtil pushDataByU8cUtil;
@Autowired
private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil;
@Autowired
private PushU8CByApiCode pushU8CByApiCode;
@Autowired
private IBdCubasdocDao bdCubasdocDao;
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
start();
return null;
}
@ -87,9 +97,27 @@ public class CustdocAutoAllotPluginInitializer extends PluginBaseEntity {
*/
public void start() {
try {
//获取当前时间
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");
//查询要分配的客商
List<CustdocRequestVo> list = queryCustDoc();
List<CustdocRequestVo> requestVoList = filterShopEntity(list);
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
bdCubasdocEntity.setModifytime_start_time(startTimeStr);
bdCubasdocEntity.setModifytime_end_time(endTimeStr);
List<BdCubasdocEntity> list = bdCubasdocDao.query(bdCubasdocEntity);
if (list == null || list.isEmpty()) {
return;
}
List<BdCubasdocEntity> requestVoList = filterShopEntity(list);
if (requestVoList == null || requestVoList.isEmpty()) {
return;
}
//推送自动分配
implement(requestVoList);
@ -99,13 +127,72 @@ public class CustdocAutoAllotPluginInitializer extends PluginBaseEntity {
}
/**
* 按客商基本档案code
*/
public void start(String code) {
try {
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdInvbasdocEntity.setPkInvbasdoc(invcode);
bdCubasdocEntity.setCustcode(code);
bdCubasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdCubasdocEntity> query = bdCubasdocDao.query(bdCubasdocEntity);
if (query.size() == 0) {
Assert.state(false, "U8C->客商基本档案自动分配全公司,客商基本档案编码:{},不存在。", code);
}
//过滤日志
List<BdCubasdocEntity> list = filterShopEntity(query);
if (list.size() == 0 || list == null) {
Assert.state(false, "U8C->客商基本档案自动分配全公司,客商基本档案编码:{},已被分配,请检查。", code);
}
//推送自动分配
implement(list);
} catch (Exception e) {
logger.error("丽知U8C->客商基本档案自动分配全公司,start(String pkInvbasdoc)方法报错:", e);
}
}
/**
* 按时间区间
*/
public void start(String startTime, String endTime) {
try {
Date business_start = DateUtil.parse(startTime);
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";
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setModifytime_start_time(start);
bdCubasdocEntity.setModifytime_end_time(end);
bdCubasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdCubasdocEntity> query = bdCubasdocDao.query(bdCubasdocEntity);
if (query.size() == 0) {
Assert.state(false, "U8C->客商基本档案自动分配全公司,按日期:{} - {},未查到客商基本档案。", startTime, endTime);
}
//过滤日志
List<BdCubasdocEntity> list = filterShopEntity(query);
if (list.size() == 0 || list == null) {
Assert.state(false, "U8C->客商基本档案自动分配全公司,按日期:{} - {},已被分配,请检查。", startTime, endTime);
}
//推送自动分配
implement(list);
} catch (Exception e) {
logger.error("丽知U8C->客商基本档案自动分配全公司,start(String startTime, String endTime)方法报错:", e);
}
}
/**
* 查询客商基本档案
*
* @return
*/
private List<CustdocRequestVo> queryCustDoc() {
List<CustdocRequestVo> custdocRequestVos = null;
List<CustdocRequestVo> list = null;
try {
String data = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("custdocQuery"), "{}");
CbdocResultVo cbdocResultVo = JSONObject.parseObject(data, CbdocResultVo.class);
@ -113,38 +200,27 @@ public class CustdocAutoAllotPluginInitializer extends PluginBaseEntity {
Map map = JSONObject.parseObject(datastring, Map.class);
Object o = map.get("datas");
String jsonString = JSONObject.toJSONString(o);
List<CustdocRequestVo> list = JSONObject.parseArray(jsonString, CustdocRequestVo.class);
// custdocRequestVos = filterData(list);
custdocRequestVos = filterShopEntity(list);
list = JSONObject.parseArray(jsonString, CustdocRequestVo.class);
// custdocRequestVos = filterShopEntity(list);
} catch (Exception e) {
logger.error("丽知U8C->客商基本档案自动分配全公司,查询客商基本档案失败", e);
}
return custdocRequestVos;
}
private List<CustdocRequestVo> filterData(List<CustdocRequestVo> list) {
List<CustdocRequestVo> filterlist = new ArrayList<>();
for (CustdocRequestVo requestVo : list) {
//o转为
if ("N".equals(requestVo.getParentvo().getDef10())) {
filterlist.add(requestVo);
}
}
return filterlist;
return list;
}
//过滤已经分配的
public List<CustdocRequestVo> filterShopEntity(List<CustdocRequestVo> list) {
public List<BdCubasdocEntity> filterShopEntity(List<BdCubasdocEntity> list) {
Assert.notNull(list, "不能为空!");
List<CustdocRequestVo> shopEntityList = new ArrayList<>();
List<BdCubasdocEntity> shopEntityList = new ArrayList<>();
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
CustdocRequestVo requestVo = list.get(i);
if (requestVo.getParentvo().getCustcode() != null && !"".equals(requestVo.getParentvo().getCustcode().trim())) {
BdCubasdocEntity requestVo = list.get(i);
String custcode = requestVo.getCustcode();
if (custcode != null && !"".equals(custcode)) {
boolean isExis = true;
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setRootAppPk(requestVo.getParentvo().getCustcode());
integrationTaskLivingDetailsEntity.setRootAppPk(custcode);
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
List<IntegrationTaskLivingDetailsEntity> integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity);
@ -164,26 +240,27 @@ public class CustdocAutoAllotPluginInitializer extends PluginBaseEntity {
/**
* U8C->客商基本档案自动分配全公司
*/
public void implement(List<CustdocRequestVo> list) {
public void implement(List<BdCubasdocEntity> list) {
for (CustdocRequestVo custdocRequestVo : list) {
for (BdCubasdocEntity bdCubasdocEntity : list) {
String assginjsonString = "";
String custcode = custdocRequestVo.getParentvo().getCustcode();
String createtime = custdocRequestVo.getParentvo().getCreatetime();
// String custprop = custdocRequestVo.getParentvo().getCustprop();
String custcode = bdCubasdocEntity.getCustcode();
String createtime = bdCubasdocEntity.getCreatetime();
try {
ArrayList<CustDocAssginVo> assginvolist = new ArrayList<>();
List<BdCorpEntity> bdCorpEntities = null;
//查询公司档案
try {
String corpresponse = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("bdcorpQuery"), "{}");
CbdocResultVo cbdocResultVo = JSONObject.parseObject(corpresponse, CbdocResultVo.class);
if (!"success".equals(cbdocResultVo.getStatus())) {
// String corpresponse = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("bdcorpQuery"), "{}");
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("bdcorpQueryCode"), "{}");
// CbdocResultVo cbdocResultVo = JSONObject.parseObject(corpresponse, CbdocResultVo.class);
Attribute attribute = ztResult.getAttribute();
if (!"success".equals(attribute.getStatus())) {
Assert.state(false, "查询公司档案失败");
}
String datastring = cbdocResultVo.getData();
Map map = JSONObject.parseObject(datastring, Map.class);
String data = attribute.getData();
Map map = JSONObject.parseObject(data, Map.class);
Object o = map.get("datas");
bdCorpEntities = JSONObject.parseArray(JSON.toJSONString(o), BdCorpEntity.class);
@ -201,35 +278,31 @@ public class CustdocAutoAllotPluginInitializer extends PluginBaseEntity {
assginvolist.add(custDocAssginVo);
}
// CustDocAssginVo custDocAssginVo = new CustDocAssginVo();
// custDocAssginVo.setPk_cubasdoc(pkCubasdoc);
//// custDocAssginVo.setAssignallcorps("Y");
// custDocAssginVo.setCustprop("2");
// custDocAssginVo.setPk_corp();
// assginvolist.add(custDocAssginVo);
HashMap<String, List> map = new HashMap<>();
map.put("custbasvo", assginvolist);
assginjsonString = JSONObject.toJSONString(map);
String response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("custdocAssign"), assginjsonString);
System.out.println(response);
// String response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("custdocAssign"), assginjsonString);
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("custdocAssignCode"), assginjsonString);
Attribute attribute = ztResult.getAttribute();
if ("false".equals(ztResult.getFlag())) {
//转发失败
Assert.state(false, "丽知U8C客商档案分配中台转发失败,失败原因:{}", attribute.getErrormsg());
}
boolean isSuccess = false;
if (response != null && !"".equals(response)) {
ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class);
if ("success".equals(reusltStrDto.getStatus())) {
isSuccess = true;
//分配成功去更新状态
// updateDoc(custdocRequestVo);
}
if ("success".equals(attribute.getStatus())) {
isSuccess = true;
// ReusltStrDto reusltStrDto = JSON.parseObject(attribute.getData(), ReusltStrDto.class);
}
if (!isSuccess) {
Assert.state(false, "推送U8C--> U8C->客商基本档案自动分配全公司 失败 接口返回结果:{} 接口入参:{}", response, assginjsonString);
Assert.state(false, "推送U8C--> U8C->客商基本档案自动分配全公司 失败 接口返回结果:{} 接口入参:{}", attribute.getErrormsg(), assginjsonString);
}
//成功
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setRootAppNewData(assginjsonString);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(response);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData());
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(createtime);
integrationTaskLivingDetailsEntity.setRootAppPk(custcode);
@ -306,7 +379,6 @@ public class CustdocAutoAllotPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
}
}
}

View File

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

View File

@ -473,6 +473,7 @@ public class SKUPluginInitializer extends PluginBaseEntity {
InterfaceParamByU8CApiDto interfaceParamDto = new InterfaceParamByU8CApiDto();
interfaceParamDto.setApi("ofs.sku.search");
queryOfsSKURequestVO.setClientCode("LETS");
queryOfsSKURequestVO.setStatus("1");
queryOfsSKURequestVO.setPageNo(String.valueOf(pageNo));
queryOfsSKURequestVO.setPageSize(String.valueOf(pageSize));
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.ReusltStrDto;
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.pushData.Attribute;
import com.hzya.frame.plugin.lets.util.pushData.PushU8CByApiCode;
@ -36,6 +37,7 @@ import java.util.stream.Collectors;
/**
* OFS->U8C货品档案 封存解封
* add by zyd 20240902
* 不过滤状态根据状态判断
*/
public class SKUSealPluginInitializer extends PluginBaseEntity {
@ -87,6 +89,8 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
@Autowired
private IBdInvbasdocDao bdInvbasdocDao;
@Autowired
private QueryU8CEntityUtil queryU8CEntityUtil;
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
@ -142,19 +146,14 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
queryOfsSKURequestVO.setLastUpdated_start(startTimeStr);
queryOfsSKURequestVO.setLastUpdated_end(endTimeStr);
List<OFSSKUSearchResponse.OFSSKU> ofsskuList = queryOfsSKUs(queryOfsSKURequestVO);
if(ofsskuList.size()==0){
return;
if (ofsskuList.size() == 0) {
return;
}
// //分组排序,
// List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList);
//
// //过滤日志
// List<OFSSKUSearchResponse.OFSSKU> filterSkus = filterData(sortSkuList);
// if(filterSkus.size()==0){
// return;
// }
// //具体实现
// implement(filterSkus);
//找到最后修改时间的进行过滤
//查询物料的所有公司根据物料分组
//推送
} catch (Exception e) {
@ -163,10 +162,7 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
}
/**
* 按sku名称
* 存在 编码相同名称不一样的情况
* 先根据code分组在根据修改时间倒排
* 按修改时间倒排取最新的修改时间
* 按sku名称没有过滤状态
*/
public void start(String goodsCode) {
String[] split = goodsCode.split("_");
@ -174,19 +170,19 @@ public class SKUSealPluginInitializer 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]);
}
//分组排序,
List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList);
//过滤日志
//找到最后修改时间的进行过滤
List<OFSSKUSearchResponse.OFSSKU> sortSkuList = groupAndSort(ofsskuList);
List<OFSSKUSearchResponse.OFSSKU> filterSkus = filterData(sortSkuList);
if(filterSkus.size()==0){
Assert.state(false, "根据OFS SKU主档编码{},已被推送成功,请勿重新推送。", split[0]);
}
//具体实现
implement(filterSkus);
//查到每个code下所有的公司并且分组得到一个map
Map<String, List<OFSSKUSearchResponse.OFSSKU>> skuMap = getSkuMap(filterSkus);
//循环map实现
sealImplement(skuMap);
} catch (Exception e) {
logger.error("丽知OFS货品档案--->U8C货品档案封存、取消封存,start(String goodsName)方法报错:", e);
@ -208,8 +204,8 @@ public class SKUSealPluginInitializer 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);
@ -231,13 +227,14 @@ public class SKUSealPluginInitializer 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);
@ -255,90 +252,83 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
return filterSkus;
}
/**
* 推送
* 注意
* 可能一家公司封存则则取消分配这家公司的存货管理档案
* sealflag 封存标志
*
* @param skuMap
*/
public void implement(List<OFSSKUSearchResponse.OFSSKU> filterSkus){
for (OFSSKUSearchResponse.OFSSKU sku : filterSkus) {
String PkInvbasdoc= "";
String url = "";
public void sealImplement(Map<String, List<OFSSKUSearchResponse.OFSSKU>> skuMap) {
skuMap.forEach((k, v) -> {
String mapStr = "";
String format = sku.getLastUpdated();
String format = "";
String response = "";
String ofsCode = "";
OFSSKUSearchResponse.OFSSKU sku=null;
try {
InvBasDocVO invbasdoc = new InvBasDocVO();
//主表
InvBasDocVO.Parent parentvo = new InvBasDocVO.Parent();
//查询是否存在返回pkInvbasdoc,如果有则是修改null则为新增
//查询该id再u8c是否有数据没有则是新增有则是修改 存货基本档案def2-ofs主键
PkInvbasdoc=queryInvbasDocIsExist(sku);
if (PkInvbasdoc != null) {
//修改
parentvo.setPk_invbasdoc(PkInvbasdoc);
url=OverallConstant.getOverAllValue("bdinvclUpdateCode");
} else if (PkInvbasdoc == null) {
//新增
url=OverallConstant.getOverAllValue("bdinvclSaveCode");
//kcode
//vskuList
String pk_invbasdoc = null;
String url = null;
boolean isSeal = false;
for (OFSSKUSearchResponse.OFSSKU ofssku : v) {
if ("1".equals(ofssku.getStatus())) {//status 0禁用 1启用
isSeal = true;
break;
}
}
//isSeal=false为全公司禁用所以封存
//isSeal=true可能不只一家启用所以解封先查询如果没有封存则不处理
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());
//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 + "}";
//推送
mapStr = "{\"pk_invbasdoc\":" + pk_invbasdoc + "}";
ZTResult ztResult = pushU8CByApiCode.pushByCode(url, mapStr);
//两层判断,一层中台转发,一层u8c返回
Attribute attribute = ztResult.getAttribute();
if ("false".equals(ztResult.getFlag())) {
//转发失败
response=JSONUtil.toJsonStr(ztResult.getAttribute());
Assert.state(false, "丽知:OFS货品档案--->U8C货品档案封存、取消封存中台转发失败,失败原因:{}", ztResult.getAttribute());
response = JSONUtil.toJsonStr(ztResult.getAttribute());
Assert.state(false, "丽知U8C货品档案封存、取消封存中台转发失败,失败原因:{}", ztResult.getAttribute());
}
Attribute attribute = ztResult.getAttribute();
boolean isSuccess = false;
String invbascode = "";
if ("success".equals(attribute.getStatus())) {
isSuccess = true;
String data = attribute.getData();
InvBasDocVO resInvBasDocVO = resultDataHandle(data);
invbascode = resInvBasDocVO.getParentvo().getInvcode();
System.out.println(data);
}
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.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
@ -346,18 +336,18 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData());
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(sku.getCode()+"_"+sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppBill(sku.getCode());
integrationTaskLivingDetailsEntity.setRootAppPk(k + "_" + sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppBill(k);
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
integrationTaskLivingDetailsEntity.setDef1(sku.getId());
integrationTaskLivingDetailsEntity.setNewSystemNumber(k);
integrationTaskLivingDetailsEntity.setNewSystemPrimary(sku.getId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
}catch (Exception e){
} catch (Exception e) {
//失败
e.printStackTrace();
logger.error("推送U8C丽知OFS货品档案--->U8C货品档案封存、取消封存失败失败原因" + e);
//失败
ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class);
String ErrMessage = "推送U8C丽知OFS货品档案--->U8C货品档案(封存、取消封存)失败,失败原因:" + reusltStrDto.getErrormsg();
String ErrMessage = "推送U8C货品档案(封存、取消封存)失败,失败原因:" + reusltStrDto.getErrormsg();
//失败
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N);
@ -365,88 +355,101 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage);
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(sku.getCode()+"_"+sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppBill(sku.getCode());
integrationTaskLivingDetailsEntity.setRootAppPk(k+"_"+sku.getLastUpdated());
integrationTaskLivingDetailsEntity.setRootAppBill(k);
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
integrationTaskLivingDetailsEntity.setDef1(sku.getId());
integrationTaskLivingDetailsEntity.setNewSystemNumber(k);
integrationTaskLivingDetailsEntity.setNewSystemPrimary(sku.getId());
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.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;
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));
collectMapByCode.forEach((k,v)->{
collectMapByCode.forEach((k, v) -> {
//降序排序 (从新到旧),根据最后修改时间倒排
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));//只取最后修改的一个
}
});
return sortSkus;
}
/**
* 封存存货基本档案
*/
public void sealImplement(String code){
}
/**
* 查询OFS SKU档案
@ -485,6 +488,27 @@ public class SKUSealPluginInitializer extends PluginBaseEntity {
}
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) {
try {
if (resultData != null && !"".equals(resultData)) {

View File

@ -3,6 +3,7 @@ package com.hzya.frame.plugin.lets.plugin.base;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
@ -15,6 +16,9 @@ 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.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.dto.InterfaceParamByU8CApiDto;
@ -91,6 +95,9 @@ public class ShopPluginInitializer extends PluginBaseEntity {
@Autowired
private OfsUnifiedService ofsUnifiedService;
@Autowired
private PushU8CByApiCode pushU8CByApiCode;
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
@ -116,7 +123,7 @@ public class ShopPluginInitializer extends PluginBaseEntity {
String integration_task_living_details_id = (String) requestJson.get("integration_task_living_details_id");
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = saveOrUpdateBusinessLogUtil.queryIntegrationTaskLivingDetailsEntity(integration_task_living_details_id);
startImplement(integrationTaskLivingDetailsEntity.getRootAppPk());
} else if(ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(prod)){
} else if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(prod)) {
startImplement();
}
return null;
@ -144,7 +151,7 @@ public class ShopPluginInitializer extends PluginBaseEntity {
implementdef(list1);
} catch (Exception e) {
e.printStackTrace();
logger.error("丽知OFS店铺档案--->U8C客商档案,start()方法报错:", e);
}
}
@ -213,49 +220,64 @@ public class ShopPluginInitializer extends PluginBaseEntity {
Date date = new Date(System.currentTimeMillis());
String businessFormat = sdf.format(date);
for (OfsShopDto shopEntity : shopEntityList) {
String response = "";
try {
CustdocEntityDto parentvo = new CustdocEntityDto();
CustdocRequestVo custdocRequestVo = new CustdocRequestVo();
parentvo.setCustname(shopEntity.getName());
parentvo.setCustshortname(shopEntity.getName());
// parentvo.setPk_corp("0001");
//
// parentvo.setPk_areacl("A");
//业务编码
parentvo.setDef1(shopEntity.getBizCode());
custdocRequestVo.setParentvo(parentvo);
//同步u8c
ArrayList<CustdocRequestVo> list = new ArrayList<>();
list.add(custdocRequestVo);
HashMap<String, Object> param = new HashMap<>();
param.put("cbdocvo", custdocRequestVo);
String jsonString = JSONObject.toJSONString(param);
String response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("custdocSave"), 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(custdocRequestVo));
}
// 根据返回结果记录日志
//成功
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(shopEntity.getBizCode());
integrationTaskLivingDetailsEntity.setRootAppBill(shopEntity.getName());
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
param.put("cbdocvo", list);
String jsonString = JSONObject.toJSONString(param);
// response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("custdocSave"), jsonString);
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("custdocSaveCode"), jsonString);
Attribute attribute = ztResult.getAttribute();
if ("false".equals(ztResult.getFlag())) {
//转发失败
response = JSONUtil.toJsonStr(ztResult.getAttribute());
Assert.state(false, "丽知OFS店铺档案--->U8C客商档案中台转发失败,失败原因:{}", ztResult.getAttribute());
}
String taskNumber = null;
boolean isSuccess = false;
if ("success".equals(attribute.getStatus())) {
isSuccess = true;
// CbdocResultVo cbdocResultVo = JSONObject.parseObject(attribute.getData(), CbdocResultVo.class);
// taskNumber = cbdocResultVo.getTaskNumber();
// String data = attribute.getData();
}
if (!isSuccess) {
Assert.state(false, "同步到U8C失败原因{} 接口入参:{}", attribute.getErrormsg(), jsonString);
}
// 根据返回结果记录日志
//成功
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setRootAppNewData(jsonString);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData());
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat);
integrationTaskLivingDetailsEntity.setRootAppPk(shopEntity.getBizCode());
integrationTaskLivingDetailsEntity.setRootAppBill(shopEntity.getName());
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
} catch (Exception e) {
logger.error("丽知OFS店铺档案--->U8C客商档案,implement()方法报错:", e);
String ErrMessage = e.getMessage();
@ -282,7 +304,7 @@ public class ShopPluginInitializer extends PluginBaseEntity {
Date date = new Date(System.currentTimeMillis());
String businessFormat = sdf.format(date);
for (OfsShopDto shopEntity : shopEntityList) {
String response = "";
try {
DefdocRequestVo defdocRequestVo = new DefdocRequestVo();
@ -300,37 +322,43 @@ public class ShopPluginInitializer extends PluginBaseEntity {
//同步u8c
String jsonString = JSONObject.toJSONString(map);
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("defdoc" + shopEntity.getBizCode());
integrationTaskLivingDetailsEntity.setRootAppBill(shopEntity.getName());
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
// CbdocResultVo cbdocResultVo1 = JSONObject.parseObject(response, CbdocResultVo.class);
// String errormsg = cbdocResultVo1.getErrormsg();
// String response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("bddefdoclistsaveCode"), jsonString);
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("bddefdoclistsaveCode"), jsonString);
Attribute attribute = ztResult.getAttribute();
if ("false".equals(ztResult.getFlag())) {
//转发失败
response = JSONUtil.toJsonStr(ztResult.getAttribute());
Assert.state(false, "丽知OFS店铺档案--->U8C自定义档案中台转发失败,失败原因:{}", ztResult.getAttribute());
}
String taskNumber = null;
boolean isSuccess = false;
if ("success".equals(attribute.getStatus())) {
isSuccess = true;
// String string = attribute.getData();
// CbdocResultVo cbdocResultVo = JSONObject.parseObject(string, CbdocResultVo.class);
// taskNumber = cbdocResultVo.getTaskNumber();
// String data = cbdocResultVo.getData();
}
if (!isSuccess) {
Assert.state(false, "同步到U8C失败原因{} 接口入参:{}", attribute.getErrormsg(), jsonString);
}
// 根据返回结果记录日志
//成功
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setRootAppNewData(jsonString);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData());
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat);
integrationTaskLivingDetailsEntity.setRootAppPk("defdoc" + shopEntity.getBizCode());
integrationTaskLivingDetailsEntity.setRootAppBill(shopEntity.getName());
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
} catch (Exception e) {
logger.error("丽知OFS店铺档案--->自定义档案,implement()方法报错:", e);
String ErrMessage = e.getMessage();

View File

@ -17,6 +17,9 @@ import com.hzya.frame.plugin.lets.resultvo.CbdocResultVo;
import com.hzya.frame.plugin.lets.u8cdto.CustdocEntityDto;
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.dto.InterfaceParamByU8CApiDto;
@ -50,6 +53,8 @@ public class SupplierPluginInitializer extends PluginBaseEntity {
@Autowired
private OfsUnifiedService ofsUnifiedService;
@Autowired
private PushU8CByApiCode pushU8CByApiCode;
@Override
public void initialize() {
@ -117,7 +122,7 @@ public class SupplierPluginInitializer extends PluginBaseEntity {
String integration_task_living_details_id = (String) requestJson.get("integration_task_living_details_id");
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = saveOrUpdateBusinessLogUtil.queryIntegrationTaskLivingDetailsEntity(integration_task_living_details_id);
startImplement(integrationTaskLivingDetailsEntity.getRootAppPk());
} else if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(prod)){
} else if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(prod)) {
startImplement();
}
return null;
@ -212,8 +217,7 @@ public class SupplierPluginInitializer extends PluginBaseEntity {
BankVo bankVo = new BankVo();
CustdocRequestVo CustdocEntityDto = new CustdocRequestVo();
try {
//T 设置parentvo
// parentvo.setPk_areacl("");
//设置parentvo
parentvo.setCustname(supplierEntity.getName());
parentvo.setCustshortname(supplierEntity.getName());
@ -226,34 +230,43 @@ public class SupplierPluginInitializer extends PluginBaseEntity {
param.put("cbdocvo", CustdocEntityDto);
String jsonString = JSONObject.toJSONString(param);
String response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("custdocSave"), jsonString);
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(CustdocEntityDto));
}
// 根据返回结果记录日志
//成功
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(supplierEntity.getBizCode());
integrationTaskLivingDetailsEntity.setRootAppBill(supplierEntity.getName());
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
// String response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("custdocSave"), jsonString);
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("custdocSaveCode"), jsonString);
//两层判断,一层中台转发,一层u8c返回
Attribute attribute = ztResult.getAttribute();
if ("false".equals(ztResult.getFlag())) {
//转发失败
Assert.state(false, "丽知OFS供应商档案分类--->U8C客商档案分类.中台转发失败,失败原因:{}", attribute.getErrormsg());
}
String taskNumber = null;
boolean isSuccess = false;
if ("success".equals(attribute.getStatus())) {
isSuccess = true;
// CbdocResultVo cbdocResultVo = JSONObject.parseObject(attribute.getData(), CbdocResultVo.class);
// taskNumber = cbdocResultVo.getTaskNumber();
// String data = cbdocResultVo.getData();
}
if (!isSuccess) {
Assert.state(false, "推送U8C原因{} 接口入参:{}", attribute.getErrormsg(), jsonString);
}
// 根据返回结果记录日志
//成功
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setRootAppNewData(jsonString);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(attribute.getData());
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat);
integrationTaskLivingDetailsEntity.setRootAppPk(supplierEntity.getBizCode());
integrationTaskLivingDetailsEntity.setRootAppBill(supplierEntity.getName());
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
} catch (Exception e) {
logger.error("丽知OFS供应商档案--->U8C客商档案,implement()方法报错:", e);
String ErrMessage = e.getMessage();

View File

@ -26,6 +26,7 @@ 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.stringutil.StringUtil;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
@ -189,12 +190,13 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
Assert.state(false, "丽知OFS调拨出库订单[出库完成]--->U8C调拨订单自动生成调拨出库单保存签字未查询到调拨出库单{}", stockoutNo);
}
//过滤成功日志
List<StockoutOrderSearchResponse.StockoutOrder> filterTransferOutOrders = filterData(transferOutOrder);
if (filterTransferOutOrders.size() == 0) {
Assert.state(false, "丽知OFS调拨出库订单[出库完成]--->U8C调拨订单自动生成调拨出库单保存签字该调拨出库单{},已被推送成功,请勿重新推送", stockoutNo);
}
// List<StockoutOrderSearchResponse.StockoutOrder> filterTransferOutOrders = filterData(transferOutOrder);
// if (filterTransferOutOrders.size() == 0) {
// Assert.state(false, "丽知OFS调拨出库订单[出库完成]--->U8C调拨订单自动生成调拨出库单保存签字该调拨出库单{},已被推送成功,请勿重新推送", stockoutNo);
// }
//推送U8C
implement(filterTransferOutOrders);
// implement(filterTransferOutOrders);
implement(transferOutOrder);
} catch (Exception e) {
logger.error("丽知OFS调拨出库订单--->U8C调拨订单自动生成调拨出库单保存签字,start(String goodsName)方法报错:", e);
@ -226,6 +228,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
Assert.state(false, "丽知OFS调拨出库订单--->U8C调拨订单自动生成调拨出库单保存签字根据日期期间[开始时间]-[结束时间]{}-{},该调期调拨出库单[出库完成]已被推送成功,请勿重新推送", startTime, endTime);
}
//推送U8C
// implement(transferOutOrder);
implement(filterTransferOutOrders);
} catch (Exception e) {
logger.error("丽知OFS调拨出库订单--->U8C调拨订单自动生成调拨出库单保存签字,start(String startTime, String endTime)方法报错:", e);
@ -289,7 +292,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
String created = stockoutH.getCreated();
format = created;
//dbilldate 单据日期
parentvo.setDbilldate(format);
parentvo.setDbilldate(format.substring(0,10));
//dauditdate 审批日期
parentvo.setDauditdate(format);
//coperatorid 制单人
@ -344,13 +347,20 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
//ofs行id
children.setPk_defdoc20(ofsDetail.getId());
//nprice 单价取上一次结账的单价
//nprice 单价取上一次结账的单价 nmny金额 nnotaxmny无税金额 nnotaxprice 无税单价
IaMonthledgerEntity iaMonthledgerEntity = queryIaMonthledger(ofsDetail, ofsTranseferOrder.getHeader().getCompanyCode());
System.out.println(iaMonthledgerEntity);
if(iaMonthledgerEntity==null){
children.setNprice("0");
// children.setNprice("0");
children.setNmny("0");
}else {
// children.setNprice(iaMonthledgerEntity.getNabprice());
children.setNmny(iaMonthledgerEntity.getNabprice());
}
children.setNprice(iaMonthledgerEntity.getNabprice());
//ntaxrate 税率
children.setNtaxrate("13");
}
billVO.setParentvo(parentvo);
@ -369,12 +379,14 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
System.out.println(attribute);
boolean isSuccess = false;
String vbillcode = "";
String cbillid = "";
if ("success".equals(attribute.getStatus())) {
isSuccess = true;
String data = attribute.getData();
BillVO resBillVO = resultDataHandle(data);
System.out.println(resBillVO);
vbillcode = resBillVO.getParentvo().getVcode();
cbillid = resBillVO.getParentvo().getCbillid();
}
if (!isSuccess) {
Assert.state(false, "推送U8C--> 丽知OFS调整出库--->U8C其它出库 失败 接口返回结果:{} 接口入参:{}", response, mapStr);
@ -389,7 +401,8 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode);
integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode);
integrationTaskLivingDetailsEntity.setDef1(vbillcode);//u8c调拨订单号
integrationTaskLivingDetailsEntity.setNewSystemNumber(vbillcode);//u8c调拨订单号
integrationTaskLivingDetailsEntity.setNewSystemPrimary(cbillid);//u8c调拨订单号
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);

View File

@ -21,44 +21,72 @@ public class QueryU8CEntityUtil {
////////////////////////////////////////////////////////////////////////////////////////公司
@Autowired
private IBdCorpDao iBdCorpDao;
/** 根据公司编码UNITCode查询公司 */
public BdCorpEntity queryBdCorpByUnitCode(String unitCode){
/**
* 根据公司编码UNITCode查询公司
*/
public BdCorpEntity queryBdCorpByUnitCode(String unitCode) {
BdCorpEntity entity = new BdCorpEntity();
entity.setUnitcode(unitCode);
entity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdCorpEntity> query = iBdCorpDao.query(entity);
return query.get(0);
if (query.size() >= 1) {
return query.get(0);
} else {
return null;
}
}
/** 根据公司主键pk_corp查询公司 */
public BdCorpEntity queryBdCorpByPkCorp(String pkCorp){
/**
* 根据公司主键pk_corp查询公司
*/
public BdCorpEntity queryBdCorpByPkCorp(String pkCorp) {
BdCorpEntity entity = new BdCorpEntity();
entity.setPkCorp(pkCorp);
entity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdCorpEntity> query = iBdCorpDao.query(entity);
return query.get(0);
if (query.size() >= 1) {
return query.get(0);
} else {
return null;
}
}
////////////////////////////////////////////////////////////////////////////////////////公司
////////////////////////////////////////////////////////////////////////////////////////存货基本档案
@Autowired
private IBdInvbasdocDao iBdInvbasdocDao;
/** 根据存货编码查询存货基本档案 */
public BdInvbasdocEntity queryBdInvbasdocByCode(String invcode){
/**
* 根据存货编码查询存货基本档案
*/
public BdInvbasdocEntity queryBdInvbasdocByCode(String invcode) {
BdInvbasdocEntity entity = new BdInvbasdocEntity();
entity.setInvcode(invcode);
entity.setDr(0L);
entity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> query = iBdInvbasdocDao.query(entity);
return query.get(0);
if (query.size() >= 1) {
return query.get(0);
} else {
return null;
}
}
/** 根据存货基本档案主键查询存货基本档案 */
public BdInvbasdocEntity queryBdInvbasdocByPkInvbasdoc(String pkInvbasdoc){
/**
* 根据存货基本档案主键查询存货基本档案
*/
public BdInvbasdocEntity queryBdInvbasdocByPkInvbasdoc(String pkInvbasdoc) {
BdInvbasdocEntity entity = new BdInvbasdocEntity();
entity.setPkInvbasdoc(pkInvbasdoc);
entity.setDr(0L);
entity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> query = iBdInvbasdocDao.query(entity);
return query.get(0);
if (query.size() >= 1) {
return query.get(0);
} else {
return null;
}
}
////////////////////////////////////////////////////////////////////////////////////////存货基本档案
@ -66,8 +94,10 @@ public class QueryU8CEntityUtil {
@Autowired
private IBdInvmandocDao iBdInvmandocDao;
/** 根据存货基本档案主键+公司主键查询存货管理档案 */
public BdInvmandocEntity queryBdInvmandocByPkInvbasdocAndPkCorp(String pkInvbasdoc,String pkCorp){
/**
* 根据存货基本档案主键+公司主键查询存货管理档案
*/
public BdInvmandocEntity queryBdInvmandocByPkInvbasdocAndPkCorp(String pkInvbasdoc, String pkCorp) {
BdInvmandocEntity entity = new BdInvmandocEntity();
entity.setPkCorp(pkCorp);
entity.setPkInvbasdoc(pkInvbasdoc);

View File

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

View File

@ -40,7 +40,7 @@ public class TransferTest {
@Test
public void t10(){
transferOutPluginInitializer.start("LETS-SH2024082800000001");
transferOutPluginInitializer.start("LETS-SH2024090400000005");
}
@Test
@ -59,7 +59,7 @@ public class TransferTest {
}
@Test
public void t21(){
transferInPluginInitializer.start("LETS-RE2024082700000003");
transferInPluginInitializer.start("LETS-RE2024090400000004");
}
@ -86,7 +86,7 @@ public class TransferTest {
}
@Test
public void t41(){
adjustOutPluginInitializer.start("LETS-SH2024082700000001");
adjustOutPluginInitializer.start("LETS-SH2024090400000005");
}
@Test
public void t42(){