丽知:新增ofs调拨出库单推送u8c调拨订单(流程自动出库)

This commit is contained in:
zhengyf 2024-08-19 18:43:58 +08:00
parent cfb5eef150
commit 49198c1bef
8 changed files with 719 additions and 429 deletions

View File

@ -38,6 +38,7 @@ public class OverallConstant {
prodOverPublic.put("bdinvclUnseal", "/u8cloud/api/uapbd/invbasdoc/unseal");//存货基本档案取消封存
prodOverPublic.put("bdinvclAllot", "/u8cloud/api/uapbd/invbasdoc/assign");//存货基本档案自动分配
//调拨
prodOverPublic.put("approveqzCode", "8000370009");//调拨订单保存即审批
prodOverPublic.put("approveqz", "/u8cloud/api/to/transorder/saveapprove");//调拨订单保存即审批
//其他出入库

View File

@ -2,30 +2,50 @@ package com.hzya.frame.plugin.lets.plugin.transfer;
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;
import com.hzya.frame.plugin.lets.constant.OverallConstant;
import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsStockinOrderRequestVO;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsStockoutOrderRequestVO;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsTransferOrderRequestVO;
import com.hzya.frame.plugin.lets.u8cdto.BillVO;
import com.hzya.frame.plugin.lets.u8cdto.GeneralBillVO_4IDto;
import com.hzya.frame.plugin.lets.u8cdto.ReusltStrDto;
import com.hzya.frame.plugin.lets.util.PushDataByU8cUtil;
import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil;
import com.hzya.frame.plugin.lets.util.pushData.Attribute;
import com.hzya.frame.plugin.lets.util.pushData.PushU8CByApiCode;
import com.hzya.frame.plugin.lets.util.pushData.ZTResult;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
import com.hzya.frame.ttxofs.dto.ofsTransferOrderSearch.OFSTranseferOrderSearchResponse;
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto;
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto;
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto;
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.SaleOutReturnMessageDto;
import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse;
import com.hzya.frame.ttxofs.dto.stock.StockoutOrderSearchResponse;
import com.hzya.frame.ttxofs.service.OfsUnifiedService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
/**
* 丽知OFS调拨出库订单--->U8C调拨出库单保存签字
* 丽知OFS调拨出库订单--->U8C调拨订单自动生成调拨出库单保存签字
*/
public class TransferOutPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(TransferOutPluginInitializer.class);
@ -49,12 +69,12 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
@Override
public String getPluginName() {
return "丽知OFS调拨出库订单--->U8C调拨出库单(保存签字)";
return "丽知OFS调拨出库订单--->U8C调拨订单,自动生成调拨出库单(保存签字)";
}
@Override
public String getPluginLabel() {
return "丽知OFS调拨出库订单--->U8C调拨出库单(保存签字)";
return "丽知OFS调拨出库订单--->U8C调拨订单,自动生成调拨出库单(保存签字)";
}
@Override
@ -67,6 +87,8 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
@Autowired
private PushDataByU8cUtil pushDataByU8cUtil;
@Autowired
private PushU8CByApiCode pushU8CByApiCode;
@Autowired
private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil;
@Autowired
@ -106,28 +128,33 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
} catch (Exception e) {
logger.error("丽知OFS调拨出库订单--->U8C调拨出库单(保存签字),start()方法报错:", e);
logger.error("丽知OFS调拨出库订单--->U8C调拨订单,自动生成调拨出库单(保存签字),start()方法报错:", e);
}
}
/**
* 按单号
*/
public void start(String stockinNo) {
public void start(String stockoutNo) {
try {
QueryOfsStockoutOrderRequestVO queryOfsStockoutOrderRequestVO = new QueryOfsStockoutOrderRequestVO();
queryOfsStockoutOrderRequestVO.setCode(stockinNo);
queryOfsStockoutOrderRequestVO.setCode(stockoutNo);
// queryOfsStockoutOrderRequestVO.setCompanyCode("SHXM");
// queryOfsStockoutOrderRequestVO.setStatus("900");//状态 500待同步 510已同步 700收货中 900入库完成 911作废 100订单池 200暂挂 400待合单 410待出库单出库
queryOfsStockoutOrderRequestVO.setPageNo(1L);
queryOfsStockoutOrderRequestVO.setPageSize(500L);
List<StockoutOrderSearchResponse.StockoutOrder> data = queryOfsStockoutOrder(queryOfsStockoutOrderRequestVO);
System.out.println(data);
List<StockoutOrderSearchResponse.StockoutOrder> transferOutOrder = queryOfsStockoutOrder(queryOfsStockoutOrderRequestVO);
System.out.println(transferOutOrder);
//过滤成功日志
List<StockoutOrderSearchResponse.StockoutOrder> filterTransferOutOrders = filterData(transferOutOrder);
//推送U8C
implement(filterTransferOutOrders);
} catch (Exception e) {
logger.error("丽知OFS调拨出库订单--->U8C调拨出库单保存签字,start(String goodsName)方法报错:", e);
logger.error("丽知OFS调拨出库订单--->U8C调拨订单,自动生成调拨出库单(保存签字),start(String goodsName)方法报错:", e);
}
}
/**
@ -151,22 +178,279 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
System.out.println(data);
} catch (Exception e) {
logger.error("丽知OFS调拨出库订单--->U8C调拨出库单(保存签字),start(String startTime, String endTime)方法报错:", e);
logger.error("丽知OFS调拨出库订单--->U8C调拨订单,自动生成调拨出库单(保存签字),start(String startTime, String endTime)方法报错:", e);
}
}
/**
* 过滤成功日志
*/
public List<StockoutOrderSearchResponse.StockoutOrder> filterData(List<StockoutOrderSearchResponse.StockoutOrder> transferOutOrder) {
List<StockoutOrderSearchResponse.StockoutOrder> filterTransferOutOrders = new ArrayList<>();
for (StockoutOrderSearchResponse.StockoutOrder stockoutOrder : transferOutOrder) {
StockoutOrderSearchResponse.StockoutOrder.StockoutH header = stockoutOrder.getHeader();
String rootAppPk = header.getCode();
boolean isExis = true;
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
List<IntegrationTaskLivingDetailsEntity> integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity);
if (integrationTaskLivingDetailsEntities == null || integrationTaskLivingDetailsEntities.size() == 0) {
isExis = false;
}
if (!isExis) {
filterTransferOutOrders.add(stockoutOrder);
}
}
return filterTransferOutOrders;
}
/**
* ofs调拨出库单推送U8C调拨订单自动生成调拨出库单保存签字
*
* @param filterTransferOutOrders
*/
public void implement(List<StockoutOrderSearchResponse.StockoutOrder> filterTransferOutOrders) {
for (StockoutOrderSearchResponse.StockoutOrder transferOutOrder : filterTransferOutOrders) {
System.out.println(transferOutOrder);
BillVO billVO = new BillVO();
String mapStr = "";
String format = "";
String response = "";
String ofsCode = "";
try {
//主表
StockoutOrderSearchResponse.StockoutOrder.StockoutH stockoutH = transferOutOrder.getHeader();
BillVO.Parentvo parentvo = new BillVO.Parentvo();
ofsCode = stockoutH.getCode();
////////////////////////////////////////////////////////////////////////////////ofs调拨订单
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders = queryOfsTransderOrder(stockoutH.getSourceOrderCode());
if(ofsTranseferOrders==null||ofsTranseferOrders.size()==0||ofsTranseferOrders.size()>1){
Assert.state(false,"根据调拨出库单:{},的来源单据号:{}查询OFS调拨订单为空或不唯一。请检查。",ofsCode,stockoutH.getSourceOrderCode());
}
OFSTranseferOrderSearchResponse.OFSTranseferOrder ofsTranseferOrder = ofsTranseferOrders.get(0);
System.out.println(ofsTranseferOrder);
////////////////////////////////////////////////////////////////////////////////ofs调拨订单
//创建日期
String created = stockoutH.getCreated();
format = created;
//dbilldate 单据日期
parentvo.setDbilldate(format);
//dauditdate 审批日期
parentvo.setDauditdate(format);
//coperatorid 制单人
parentvo.setCoperatorid("tbadmin");
//cbiztypeid 业务流程编码
parentvo.setCbiztypeid("to01");
//coutcbid 调出组织编码 对应OFS->原库存地点公司
parentvo.setCoutcbid(ofsTranseferOrder.getHeader().getCompanyCode());
//coutcorpid 调出公司编码 对应OFS->原库存地点公司
parentvo.setCoutcorpid(ofsTranseferOrder.getHeader().getCompanyCode());
//coutwhid 调出仓库编码 对应OFS->原库存地点
parentvo.setCoutwhid(ofsTranseferOrder.getHeader().getFacilityCode());
//cincbid 调入组织编码 对应OFS->目标库存地点公司
parentvo.setCincbid(ofsTranseferOrder.getHeader().getToCompanyCode());
//cincorpid 调入公司编码 对应OFS->目标库存地点公司
parentvo.setCincorpid(ofsTranseferOrder.getHeader().getToCompanyCode());
//cinwhid 调入仓库编码 对应OFS->目标库存地点
parentvo.setCinwhid(ofsTranseferOrder.getHeader().getToFacilityCode());
//vnote 备注
parentvo.setVnote(ofsTranseferOrder.getHeader().getNotes());
//pk_defdoc19
parentvo.setPk_defdoc19(StringUtils.substring(ofsTranseferOrder.getHeader().getCode(),5));
//子表
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB> ofsDetails = ofsTranseferOrder.getDetails();
List<BillVO.Childrenvo> childrenvo = new ArrayList<>();
for (OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB ofsDetail : ofsDetails) {
System.out.println(ofsDetail);
BillVO.Childrenvo children = new BillVO.Childrenvo();
//表体
//cinvbasid 存货基本档案
children.setCinvbasid(ofsDetail.getSkuCode());
//nnum 数量
children.setNnum(BigDecimal.valueOf(ofsDetail.getShipQty()));
childrenvo.add(children);
}
billVO.setParentvo(parentvo);
billVO.setChildrenvo(childrenvo);
String jsonStr = JSONUtil.toJsonStr(billVO);
mapStr = "{\"billvo\":"+jsonStr+"}";
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("approveqzCode"), mapStr);
System.out.println(ztResult);
//两层判断,一层中台转发,一层u8c返回
if ("false".equals(ztResult.getFlag())) {
//转发失败
Assert.state(false, "丽知OFS调拨出库订单--->U8C调拨订单自动生成调拨出库单保存签字.中台转发失败,失败原因:{}", ztResult.getMsg());
}
Attribute attribute = ztResult.getAttribute();
System.out.println(attribute);
boolean isSuccess = false;
String vbillcode = "";
if ("success".equals(attribute.getStatus())) {
isSuccess = true;
String data = attribute.getData();
BillVO resBillVO = resultDataHandle(data);
System.out.println(resBillVO);
vbillcode = resBillVO.getParentvo().getVcode();
}
if (!isSuccess) {
Assert.state(false, "推送U8C--> 丽知OFS调整出库--->U8C其它出库 失败 接口返回结果:{} 接口入参:{}", response, mapStr);
}
//成功
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(response);
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode);
integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode);
integrationTaskLivingDetailsEntity.setDef1(vbillcode);//u8c调拨订单号
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
} 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();
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N);
integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage);
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode);
integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode);//u8c其他出库单号
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
}
}
}
/**
* ofs调拨出库单查询
*
* @param queryOfsStockoutOrderRequestVO
* @return
* @throws Exception
*/
public List<StockoutOrderSearchResponse.StockoutOrder> queryOfsStockoutOrder(QueryOfsStockoutOrderRequestVO queryOfsStockoutOrderRequestVO) throws Exception {
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
interfaceParamDto.setApi("ofs.shipment.search");
queryOfsStockoutOrderRequestVO.setInternalInstructionType("TRANSFER");//入库单类型 SALES销售 EXCHANGE换货 REISSUE补发RETURN销退 PURCHASE采购 PURCHASE_RETURN采退 TRANSFER调拨 WORK_ORDER加工 OTHER其他 ADJUST调整 EXCHANGE换货
queryOfsStockoutOrderRequestVO.setClientCode("LETS");
interfaceParamDto.setData(JSON.toJSONString(queryOfsStockoutOrderRequestVO));
StockoutOrderSearchResponse stockoutOrderSearchResponse = (StockoutOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto);
SaleOutReturnMessageDto saleOutReturnMessageDto = (SaleOutReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto);
System.out.println(saleOutReturnMessageDto);
StockoutOrderSearchResponse stockoutOrderSearchResponse = SaleOutReturnMessageDto2StockoutOrderSearchResponse(saleOutReturnMessageDto);
System.out.println(stockoutOrderSearchResponse);
if(stockoutOrderSearchResponse.getData()==null||stockoutOrderSearchResponse.getData().size()==0){
if (stockoutOrderSearchResponse.getData() == null || stockoutOrderSearchResponse.getData().size() == 0) {
return null;
}
return stockoutOrderSearchResponse.getData();
}
/**
* 根据调拨订单号查询ofs调拨订单
*
* @param transferNo
* @throws Exception
*/
public List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> queryOfsTransderOrder(String transferNo) throws Exception {
QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO = new QueryOfsTransferOrderRequestVO();
// queryOfsTransferOrderRequestVO.setStatus("100");//状态 100订单池 200待出库 300已出库 400待入库 900已入库 250出库中 450入库中
queryOfsTransferOrderRequestVO.setCode(transferNo);
queryOfsTransferOrderRequestVO.setPageNo(1L);
queryOfsTransferOrderRequestVO.setPageSize(500L);
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
interfaceParamDto.setApi("ofs.transferOrder.search");
queryOfsTransferOrderRequestVO.setClientCode("LETS");
interfaceParamDto.setData(JSON.toJSONString(queryOfsTransferOrderRequestVO));
OFSTranseferOrderSearchResponse ofsTranseferOrderSearchResponse = (OFSTranseferOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto);
System.out.println(ofsTranseferOrderSearchResponse);
if (ofsTranseferOrderSearchResponse.getData().size() == 0) {
return null;
} else {
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> data = ofsTranseferOrderSearchResponse.getData();
return data;
}
}
/**
* 只是命名不一样为了方便区分顾转换为stockout
*
* @param saleOutReturnMessageDto
* @return
*/
public StockoutOrderSearchResponse SaleOutReturnMessageDto2StockoutOrderSearchResponse(SaleOutReturnMessageDto saleOutReturnMessageDto) {
StockoutOrderSearchResponse stockoutOrderSearchResponse = new StockoutOrderSearchResponse();
List<StockoutOrderSearchResponse.StockoutOrder> data = new ArrayList<>();
BeanUtils.copyProperties(saleOutReturnMessageDto, stockoutOrderSearchResponse);
for (HeaderDetailsDto saleOutData : saleOutReturnMessageDto.getData()) {
HeaderDto saleOutHeader = saleOutData.getHeader();
StockoutOrderSearchResponse.StockoutOrder stockoutOrder = new StockoutOrderSearchResponse.StockoutOrder();
StockoutOrderSearchResponse.StockoutOrder.StockoutH stockoutH = new StockoutOrderSearchResponse.StockoutOrder.StockoutH();
List<StockoutOrderSearchResponse.StockoutOrder.StockoutB> stockoutBList = new ArrayList<>();
for (DetailsDto saleOutDetail : saleOutData.getDetails()) {
StockoutOrderSearchResponse.StockoutOrder.StockoutB stockoutB = new StockoutOrderSearchResponse.StockoutOrder.StockoutB();
BeanUtils.copyProperties(saleOutDetail, stockoutB);
stockoutBList.add(stockoutB);
}
//创建时间修改时间创建人修改人赋给表头
StockoutOrderSearchResponse.StockoutOrder.StockoutB stockoutB = stockoutBList.get(0);
stockoutH.setCreated(stockoutB.getCreated());
stockoutH.setCreatedBy(stockoutB.getCreatedBy());
stockoutH.setLastUpdated(stockoutB.getLastUpdated());
stockoutH.setLastUpdatedBy(stockoutB.getLastUpdatedBy());
BeanUtils.copyProperties(saleOutHeader, stockoutH);
stockoutOrder.setHeader(stockoutH);
stockoutOrder.setDetails(stockoutBList);
data.add(stockoutOrder);
}
stockoutOrderSearchResponse.setData(data);
System.out.println(stockoutOrderSearchResponse);
return stockoutOrderSearchResponse;
}
private BillVO resultDataHandle(String resultData) {
try {
if (resultData != null && !"".equals(resultData)) {
if (resultData.contains("[")) {
resultData = resultData.substring(1, resultData.length() - 1);
}
return JSON.parseObject(resultData, BillVO.class);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("解析返回参数失败的错误", e);
//如果解析失败记录原因但是不能影响结果的记录
}
return null;
}
}

View File

@ -1,400 +1,400 @@
package com.hzya.frame.plugin.lets.plugin.transfer;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
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.ofsvo.QueryOfsTransferOrderRequestVO;
import com.hzya.frame.plugin.lets.u8cdto.BillVO;
import com.hzya.frame.plugin.lets.u8cdto.ReusltStrDto;
import com.hzya.frame.plugin.lets.u8cdto.SoSaleResultRootDto;
import com.hzya.frame.plugin.lets.util.PushDataByU8cUtil;
import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.ttxofs.basics.ReturnMessageBasics;
import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
import com.hzya.frame.ttxofs.dto.ofsTransferOrderSearch.OFSTranseferOrderSearchResponse;
import com.hzya.frame.ttxofs.service.OfsUnifiedService;
import com.hzya.frame.ttxofs.util.UrlTransUtil;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
/**
* OFS->U8C调拨订单 新增修改删除
* add by zyd 20240802
*/
public class TransferPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(TransferPluginInitializer.class);
private static final ReentrantLock LOCK = new ReentrantLock(true);
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "com.hzya.frame.plugin.lets.plugin.transfer.TransferPluginInitializer";
}
@Override
public String getPluginName() {
return "丽知OFS调拨订单--->U8C调拨订单(保存及签字)";
}
@Override
public String getPluginLabel() {
return "丽知OFS调拨订单--->U8C调拨订单(保存及签字)";
}
@Override
public String getPluginType() {
return "1";
}
@Autowired
private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao;
@Autowired
private PushDataByU8cUtil pushDataByU8cUtil;
@Autowired
private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil;
@Autowired
private OfsUnifiedService ofsUnifiedService;
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
return null;
}
/**
* 默认推送
*/
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");
QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO = new QueryOfsTransferOrderRequestVO();
queryOfsTransferOrderRequestVO.setCreated_start(startTimeStr);
queryOfsTransferOrderRequestVO.setCreated_end(endTimeStr);
queryOfsTransferOrderRequestVO.setCompanyCode("SHXM");//U8c&ofs对接群:好的我跟技术聊了就按照这个方 式来赋值就按照赋值的货主来查不赋值就查所有的货主数据
// queryOfsTransferOrderRequestVO.setStatus("900");//状态 100订单池 200待出库 300已出库 400待入库 900已入库 250出库中 450入库中
queryOfsTransferOrderRequestVO.setPageNo(1L);
queryOfsTransferOrderRequestVO.setPageSize(50L);
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders = queryOfsTransderOrder(queryOfsTransferOrderRequestVO);
if (ofsTranseferOrders == null || ofsTranseferOrders.size() == 0) {
return;
}
System.out.println(ofsTranseferOrders);
//过滤日志
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders = filterData(ofsTranseferOrders);
if (filterOfsTranseferOrders.size() == 0) {
return;
}
//推送
implement(filterOfsTranseferOrders);
} catch (Exception e) {
logger.error("丽知OFS调拨订单--->U8C调拨订单(保存及签字),start()方法报错:", e);
}
}
/**
* 按调拨订单号
*/
public void start(String transeferNo) {
try {
QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO = new QueryOfsTransferOrderRequestVO();
queryOfsTransferOrderRequestVO.setCompanyCode("SHXM");//U8c&ofs对接群:好的我跟技术聊了就按照这个方式来赋值就按照赋值的货主来查不赋值就查所有的货主数据
// queryOfsTransferOrderRequestVO.setStatus("100");//状态 100订单池 200待出库 300已出库 400待入库 900已入库 250出库中 450入库中
queryOfsTransferOrderRequestVO.setCode(transeferNo);
queryOfsTransferOrderRequestVO.setCreated_start("2024-08-08 00:00:00");
queryOfsTransferOrderRequestVO.setCreated_end("2024-08-12 23:59:59");
queryOfsTransferOrderRequestVO.setPageNo(1L);
queryOfsTransferOrderRequestVO.setPageSize(500L);
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders = queryOfsTransderOrder(queryOfsTransferOrderRequestVO);
if (ofsTranseferOrders == null || ofsTranseferOrders.size() == 0) {
Assert.state(false, "中台查询OFS调拨订单{}不存在请检查OFS调拨订单号。", transeferNo);
}
//过滤日志
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders = filterData(ofsTranseferOrders);
if (filterOfsTranseferOrders.size() == 0) {
Assert.state(false, "中台查询OFS调拨订单{},过滤成功日志时已被过滤,请勿重新推送。", transeferNo);
}
//推送
implement(filterOfsTranseferOrders);
} catch (Exception e) {
logger.error("丽知OFS调拨订单--->U8C调拨订单(保存及签字),start(String transeferNo)方法报错:", 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";
QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO = new QueryOfsTransferOrderRequestVO();
queryOfsTransferOrderRequestVO.setCreated_start(start);
queryOfsTransferOrderRequestVO.setCreated_end(end);
queryOfsTransferOrderRequestVO.setCompanyCode("SHXM");//U8c&ofs对接群:好的我跟技术聊了就按照这个方 式来赋值就按照赋值的货主来查不赋值就查所有的货主数据
// queryOfsTransferOrderRequestVO.setStatus("900");//状态 100订单池 200待出库 300已出库 400待入库 900已入库 250出库中 450入库中
queryOfsTransferOrderRequestVO.setPageNo(1L);
queryOfsTransferOrderRequestVO.setPageSize(50L);
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders = queryOfsTransderOrder(queryOfsTransferOrderRequestVO);
if (ofsTranseferOrders == null || ofsTranseferOrders.size() == 0) {
Assert.state(false, "中台查询OFS调拨订单,按日期:{} - {}未查询OFS调拨订单。", startTime,endTime);
}
//过滤日志
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders = filterData(ofsTranseferOrders);
if (filterOfsTranseferOrders.size() == 0) {
Assert.state(false, "中台查询OFS调拨订单,按日期:{} - {},已被推送,请查询OFS调拨订单。", startTime,endTime);
}
//推送
implement(filterOfsTranseferOrders);
} catch (Exception e) {
logger.error("丽知OFS调拨订单--->U8C调拨订单(保存及签字),start(String startTime, String endTime)方法报错:", e);
}
}
/**
* 过滤成功日志
*
* @param ofsTranseferOrders
* @return
*/
public List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterData(List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders) {
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders = new ArrayList<>();
for (OFSTranseferOrderSearchResponse.OFSTranseferOrder ofsTranseferOrder : ofsTranseferOrders) {
OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferH header = ofsTranseferOrder.getHeader();
//OFS调拨订单号
String rootAppPk = header.getCode();
boolean isExis = true;
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
List<IntegrationTaskLivingDetailsEntity> integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity);
if (integrationTaskLivingDetailsEntities == null || integrationTaskLivingDetailsEntities.size() == 0) {
isExis = false;
}
if (!isExis) {
filterOfsTranseferOrders.add(ofsTranseferOrder);
}
}
return filterOfsTranseferOrders;
}
/**
* 推送u8c调拨订单
*
* @param filterOfsTranseferOrders
*/
public void implement(List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders) {
for (OFSTranseferOrderSearchResponse.OFSTranseferOrder ofsTranseferOrder : filterOfsTranseferOrders) {
BillVO billVO = new BillVO();
String mapStr = "";
String format="";
String response="";
String ofsCode="";
try {
//主表
OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferH ofsHeader = ofsTranseferOrder.getHeader();
BillVO.Parentvo parentvo = new BillVO.Parentvo();
ofsCode=ofsHeader.getCode();
//创建日期
Date created = ofsHeader.getCreated();
format = DateUtil.format(created, "yyyy-MM-dd HH:mm:ss");
//dbilldate 单据日期
parentvo.setDbilldate(format);
//dauditdate 审批日期
parentvo.setDauditdate(format);
//coperatorid 制单人
parentvo.setCoperatorid("tbadmin");
//cbiztypeid 业务流程编码
parentvo.setCbiztypeid("to01");
//coutcbid 调出组织编码 对应OFS->原库存地点公司
parentvo.setCoutcbid(ofsHeader.getCompanyCode());
parentvo.setCoutcbid("SHLZ");
//coutcorpid 调出公司编码 对应OFS->原库存地点公司
parentvo.setCoutcorpid(ofsHeader.getCompanyCode());
parentvo.setCoutcorpid("SHLZ");
//coutwhid 调出仓库编码 对应OFS->原库存地点
parentvo.setCoutwhid(ofsHeader.getFacilityCode());
parentvo.setCoutwhid("01");
//cincbid 调入组织编码 对应OFS->目标库存地点公司
parentvo.setCincbid("SHXM");
//cincorpid 调入公司编码 对应OFS->目标库存地点公司
parentvo.setCincorpid("SHXM");
//cinwhid 调入仓库编码 对应OFS->目标库存地点
parentvo.setCinwhid("01");
//vnote 备注
parentvo.setVnote(ofsHeader.getNotes());
//子表
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB> ofsDetails = ofsTranseferOrder.getDetails();
List<BillVO.Childrenvo> childrenvo = new ArrayList<>();
for (OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB ofsDetail : ofsDetails) {
System.out.println(ofsDetail);
BillVO.Childrenvo children = new BillVO.Childrenvo();
//表体
//cinvbasid 存货基本档案
children.setCinvbasid(ofsDetail.getSkuCode());
children.setCinvbasid("6973391730617");
//nnum 数量
children.setNnum(BigDecimal.valueOf(ofsDetail.getShipQty()));
childrenvo.add(children);
}
billVO.setParentvo(parentvo);
billVO.setChildrenvo(childrenvo);
String jsonStr = JSONUtil.toJsonStr(billVO);
mapStr = "{\"billvo\":"+jsonStr+"}";
response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("approveqz"), mapStr);
System.out.println(response);
boolean isSuccess = false;
String vcode="";
if (response != null && !"".equals(response)) {
ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class);
if ("success".equals(reusltStrDto.getStatus())) {
isSuccess = true;
String data = reusltStrDto.getData();
BillVO billVO1 = resultDataHandle(data);
System.out.println(billVO1);
vcode = billVO1.getParentvo().getVcode();
}
}
if (!isSuccess) {
Assert.state(false, "推送U8C--> 丽知OFS调拨订单--->U8C调拨订单(保存及签字) 失败 接口返回结果:{} 接口入参:{}", response, jsonStr);
}
//成功
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(response);
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode);
integrationTaskLivingDetailsEntity.setRootAppBill(vcode);//u8c调拨订单号
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
} catch (Exception e) {
e.printStackTrace();
logger.error("丽知OFS调拨订单--->U8C调拨订单(保存及签字)失败,失败原因:" + e);
//失败
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N);
integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(response);
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
integrationTaskLivingDetailsEntity.setBusinessDate(format);
integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode);
integrationTaskLivingDetailsEntity.setRootAppBill(null);//u8c调拨订单号
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
}
}
}
/**
* 开始与结束时间必须小于或等于7天
*
* @param queryOfsTransferOrderRequestVO
* @throws Exception
*/
public List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> queryOfsTransderOrder(QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO) throws Exception {
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
interfaceParamDto.setApi("ofs.transferOrder.search");
queryOfsTransferOrderRequestVO.setClientCode("LETS");
interfaceParamDto.setData(JSON.toJSONString(queryOfsTransferOrderRequestVO));
OFSTranseferOrderSearchResponse ofsTranseferOrderSearchResponse = (OFSTranseferOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto);
System.out.println(ofsTranseferOrderSearchResponse);
if (ofsTranseferOrderSearchResponse.getData().size() == 0) {
return null;
} else {
List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> data = ofsTranseferOrderSearchResponse.getData();
return data;
}
}
private BillVO resultDataHandle(String resultData) {
try {
if (resultData != null && !"".equals(resultData)) {
if (resultData.contains("[")) {
resultData = resultData.substring(1, resultData.length() - 1);
}
return JSON.parseObject(resultData, BillVO.class);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("解析返回参数失败的错误", e);
//如果解析失败记录原因但是不能影响结果的记录
}
return null;
}
}
//package com.hzya.frame.plugin.lets.plugin.transfer;
//
//import cn.hutool.core.date.DateField;
//import cn.hutool.core.date.DateUtil;
//import cn.hutool.core.lang.Assert;
//import cn.hutool.json.JSONArray;
//import cn.hutool.json.JSONUtil;
//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.ofsvo.QueryOfsTransferOrderRequestVO;
//import com.hzya.frame.plugin.lets.u8cdto.BillVO;
//import com.hzya.frame.plugin.lets.u8cdto.ReusltStrDto;
//import com.hzya.frame.plugin.lets.u8cdto.SoSaleResultRootDto;
//import com.hzya.frame.plugin.lets.util.PushDataByU8cUtil;
//import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil;
//import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao;
//import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
//import com.hzya.frame.ttxofs.basics.ReturnMessageBasics;
//import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
//import com.hzya.frame.ttxofs.dto.ofsTransferOrderSearch.OFSTranseferOrderSearchResponse;
//import com.hzya.frame.ttxofs.service.OfsUnifiedService;
//import com.hzya.frame.ttxofs.util.UrlTransUtil;
//import com.hzya.frame.web.entity.JsonResultEntity;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.impl.client.HttpClients;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//
//import java.math.BigDecimal;
//import java.util.*;
//import java.util.concurrent.locks.ReentrantLock;
//
///**
// * OFS->U8C调拨订单 新增修改删除
// * add by zyd 20240802
// */
//public class TransferPluginInitializer extends PluginBaseEntity {
//
// Logger logger = LoggerFactory.getLogger(TransferPluginInitializer.class);
//
// private static final ReentrantLock LOCK = new ReentrantLock(true);
//
// @Override
// public void initialize() {
// logger.info(getPluginLabel() + "執行初始化方法initialize()");
// }
//
// @Override
// public void destroy() {
// logger.info(getPluginLabel() + "執行銷毀方法destroy()");
// }
//
// @Override
// public String getPluginId() {
// return "com.hzya.frame.plugin.lets.plugin.transfer.TransferPluginInitializer";
// }
//
// @Override
// public String getPluginName() {
// return "丽知OFS调拨订单--->U8C调拨订单(保存及签字)";
// }
//
// @Override
// public String getPluginLabel() {
// return "丽知OFS调拨订单--->U8C调拨订单(保存及签字)";
// }
//
// @Override
// public String getPluginType() {
// return "1";
// }
//
// @Autowired
// private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao;
// @Autowired
// private PushDataByU8cUtil pushDataByU8cUtil;
// @Autowired
// private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil;
//
// @Autowired
// private OfsUnifiedService ofsUnifiedService;
//
// @Override
// public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
// return null;
// }
//
//
// /**
// * 默认推送
// */
// 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");
//
// QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO = new QueryOfsTransferOrderRequestVO();
// queryOfsTransferOrderRequestVO.setCreated_start(startTimeStr);
// queryOfsTransferOrderRequestVO.setCreated_end(endTimeStr);
// queryOfsTransferOrderRequestVO.setCompanyCode("SHXM");//U8c&ofs对接群:好的我跟技术聊了就按照这个方 式来赋值就按照赋值的货主来查不赋值就查所有的货主数据
//// queryOfsTransferOrderRequestVO.setStatus("900");//状态 100订单池 200待出库 300已出库 400待入库 900已入库 250出库中 450入库中
// queryOfsTransferOrderRequestVO.setPageNo(1L);
// queryOfsTransferOrderRequestVO.setPageSize(50L);
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders = queryOfsTransderOrder(queryOfsTransferOrderRequestVO);
// if (ofsTranseferOrders == null || ofsTranseferOrders.size() == 0) {
// return;
// }
// System.out.println(ofsTranseferOrders);
// //过滤日志
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders = filterData(ofsTranseferOrders);
// if (filterOfsTranseferOrders.size() == 0) {
// return;
// }
//
// //推送
// implement(filterOfsTranseferOrders);
//
//
// } catch (Exception e) {
// logger.error("丽知OFS调拨订单--->U8C调拨订单(保存及签字),start()方法报错:", e);
// }
// }
//
// /**
// * 按调拨订单号
// */
// public void start(String transeferNo) {
// try {
// QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO = new QueryOfsTransferOrderRequestVO();
// queryOfsTransferOrderRequestVO.setCompanyCode("SHXM");//U8c&ofs对接群:好的我跟技术聊了就按照这个方式来赋值就按照赋值的货主来查不赋值就查所有的货主数据
//// queryOfsTransferOrderRequestVO.setStatus("100");//状态 100订单池 200待出库 300已出库 400待入库 900已入库 250出库中 450入库中
// queryOfsTransferOrderRequestVO.setCode(transeferNo);
//
// queryOfsTransferOrderRequestVO.setCreated_start("2024-08-08 00:00:00");
// queryOfsTransferOrderRequestVO.setCreated_end("2024-08-12 23:59:59");
//
// queryOfsTransferOrderRequestVO.setPageNo(1L);
// queryOfsTransferOrderRequestVO.setPageSize(500L);
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders = queryOfsTransderOrder(queryOfsTransferOrderRequestVO);
// if (ofsTranseferOrders == null || ofsTranseferOrders.size() == 0) {
// Assert.state(false, "中台查询OFS调拨订单{}不存在请检查OFS调拨订单号。", transeferNo);
// }
//
// //过滤日志
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders = filterData(ofsTranseferOrders);
// if (filterOfsTranseferOrders.size() == 0) {
// Assert.state(false, "中台查询OFS调拨订单{},过滤成功日志时已被过滤,请勿重新推送。", transeferNo);
// }
//
// //推送
// implement(filterOfsTranseferOrders);
//
// } catch (Exception e) {
// logger.error("丽知OFS调拨订单--->U8C调拨订单(保存及签字),start(String transeferNo)方法报错:", 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";
// QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO = new QueryOfsTransferOrderRequestVO();
// queryOfsTransferOrderRequestVO.setCreated_start(start);
// queryOfsTransferOrderRequestVO.setCreated_end(end);
// queryOfsTransferOrderRequestVO.setCompanyCode("SHXM");//U8c&ofs对接群:好的我跟技术聊了就按照这个方 式来赋值就按照赋值的货主来查不赋值就查所有的货主数据
//// queryOfsTransferOrderRequestVO.setStatus("900");//状态 100订单池 200待出库 300已出库 400待入库 900已入库 250出库中 450入库中
// queryOfsTransferOrderRequestVO.setPageNo(1L);
// queryOfsTransferOrderRequestVO.setPageSize(50L);
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders = queryOfsTransderOrder(queryOfsTransferOrderRequestVO);
// if (ofsTranseferOrders == null || ofsTranseferOrders.size() == 0) {
// Assert.state(false, "中台查询OFS调拨订单,按日期:{} - {}未查询OFS调拨订单。", startTime,endTime);
// }
// //过滤日志
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders = filterData(ofsTranseferOrders);
// if (filterOfsTranseferOrders.size() == 0) {
// Assert.state(false, "中台查询OFS调拨订单,按日期:{} - {},已被推送,请查询OFS调拨订单。", startTime,endTime);
// }
//
// //推送
// implement(filterOfsTranseferOrders);
//
//
// } catch (Exception e) {
// logger.error("丽知OFS调拨订单--->U8C调拨订单(保存及签字),start(String startTime, String endTime)方法报错:", e);
// }
// }
//
//
// /**
// * 过滤成功日志
// *
// * @param ofsTranseferOrders
// * @return
// */
// public List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterData(List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> ofsTranseferOrders) {
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders = new ArrayList<>();
// for (OFSTranseferOrderSearchResponse.OFSTranseferOrder ofsTranseferOrder : ofsTranseferOrders) {
// OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferH header = ofsTranseferOrder.getHeader();
// //OFS调拨订单号
// String rootAppPk = header.getCode();
// boolean isExis = true;
// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
// integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
// integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
// integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
// List<IntegrationTaskLivingDetailsEntity> integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity);
// if (integrationTaskLivingDetailsEntities == null || integrationTaskLivingDetailsEntities.size() == 0) {
// isExis = false;
// }
// if (!isExis) {
// filterOfsTranseferOrders.add(ofsTranseferOrder);
// }
// }
// return filterOfsTranseferOrders;
// }
//
// /**
// * 推送u8c调拨订单
// *
// * @param filterOfsTranseferOrders
// */
// public void implement(List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> filterOfsTranseferOrders) {
// for (OFSTranseferOrderSearchResponse.OFSTranseferOrder ofsTranseferOrder : filterOfsTranseferOrders) {
// BillVO billVO = new BillVO();
//
// String mapStr = "";
// String format="";
// String response="";
// String ofsCode="";
// try {
//
// //主表
// OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferH ofsHeader = ofsTranseferOrder.getHeader();
// BillVO.Parentvo parentvo = new BillVO.Parentvo();
//
// ofsCode=ofsHeader.getCode();
//
// //创建日期
// Date created = ofsHeader.getCreated();
// format = DateUtil.format(created, "yyyy-MM-dd HH:mm:ss");
//
// //dbilldate 单据日期
// parentvo.setDbilldate(format);
// //dauditdate 审批日期
// parentvo.setDauditdate(format);
// //coperatorid 制单人
// parentvo.setCoperatorid("tbadmin");
//
// //cbiztypeid 业务流程编码
// parentvo.setCbiztypeid("to01");
//
// //coutcbid 调出组织编码 对应OFS->原库存地点公司
// parentvo.setCoutcbid(ofsHeader.getCompanyCode());
// parentvo.setCoutcbid("SHLZ");
//
// //coutcorpid 调出公司编码 对应OFS->原库存地点公司
// parentvo.setCoutcorpid(ofsHeader.getCompanyCode());
// parentvo.setCoutcorpid("SHLZ");
//
// //coutwhid 调出仓库编码 对应OFS->原库存地点
// parentvo.setCoutwhid(ofsHeader.getFacilityCode());
// parentvo.setCoutwhid("01");
//
// //cincbid 调入组织编码 对应OFS->目标库存地点公司
// parentvo.setCincbid("SHXM");
//
// //cincorpid 调入公司编码 对应OFS->目标库存地点公司
// parentvo.setCincorpid("SHXM");
//
// //cinwhid 调入仓库编码 对应OFS->目标库存地点
// parentvo.setCinwhid("01");
//
// //vnote 备注
// parentvo.setVnote(ofsHeader.getNotes());
//
//
//
// //子表
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB> ofsDetails = ofsTranseferOrder.getDetails();
// List<BillVO.Childrenvo> childrenvo = new ArrayList<>();
// for (OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB ofsDetail : ofsDetails) {
// System.out.println(ofsDetail);
// BillVO.Childrenvo children = new BillVO.Childrenvo();
// //表体
// //cinvbasid 存货基本档案
// children.setCinvbasid(ofsDetail.getSkuCode());
// children.setCinvbasid("6973391730617");
// //nnum 数量
// children.setNnum(BigDecimal.valueOf(ofsDetail.getShipQty()));
// childrenvo.add(children);
// }
// billVO.setParentvo(parentvo);
// billVO.setChildrenvo(childrenvo);
// String jsonStr = JSONUtil.toJsonStr(billVO);
// mapStr = "{\"billvo\":"+jsonStr+"}";
// response = pushDataByU8cUtil.pushU8CByCode(OverallConstant.getOverAllValue("approveqz"), mapStr);
// System.out.println(response);
// boolean isSuccess = false;
// String vcode="";
// if (response != null && !"".equals(response)) {
// ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class);
// if ("success".equals(reusltStrDto.getStatus())) {
// isSuccess = true;
// String data = reusltStrDto.getData();
// BillVO billVO1 = resultDataHandle(data);
// System.out.println(billVO1);
// vcode = billVO1.getParentvo().getVcode();
// }
// }
// if (!isSuccess) {
// Assert.state(false, "推送U8C--> 丽知OFS调拨订单--->U8C调拨订单(保存及签字) 失败 接口返回结果:{} 接口入参:{}", response, jsonStr);
// }
//
// //成功
// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
// integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y);
// integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr);
// integrationTaskLivingDetailsEntity.setNewTransmitInfo(response);
// integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
// integrationTaskLivingDetailsEntity.setBusinessDate(format);
// integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode);
// integrationTaskLivingDetailsEntity.setRootAppBill(vcode);//u8c调拨订单号
// integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
// saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
//
//
// } catch (Exception e) {
// e.printStackTrace();
// logger.error("丽知OFS调拨订单--->U8C调拨订单(保存及签字)失败,失败原因:" + e);
//
// //失败
// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
// integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N);
// integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr);
// integrationTaskLivingDetailsEntity.setNewTransmitInfo(response);
// integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
// integrationTaskLivingDetailsEntity.setBusinessDate(format);
// integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode);
// integrationTaskLivingDetailsEntity.setRootAppBill(null);//u8c调拨订单号
// integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
// saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
// }
//
// }
//
// }
//
//
// /**
// * 开始与结束时间必须小于或等于7天
// *
// * @param queryOfsTransferOrderRequestVO
// * @throws Exception
// */
// public List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> queryOfsTransderOrder(QueryOfsTransferOrderRequestVO queryOfsTransferOrderRequestVO) throws Exception {
//
// InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
// interfaceParamDto.setApi("ofs.transferOrder.search");
// queryOfsTransferOrderRequestVO.setClientCode("LETS");
// interfaceParamDto.setData(JSON.toJSONString(queryOfsTransferOrderRequestVO));
// OFSTranseferOrderSearchResponse ofsTranseferOrderSearchResponse = (OFSTranseferOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto);
// System.out.println(ofsTranseferOrderSearchResponse);
// if (ofsTranseferOrderSearchResponse.getData().size() == 0) {
// return null;
// } else {
// List<OFSTranseferOrderSearchResponse.OFSTranseferOrder> data = ofsTranseferOrderSearchResponse.getData();
// return data;
// }
// }
// private BillVO resultDataHandle(String resultData) {
// try {
// if (resultData != null && !"".equals(resultData)) {
// if (resultData.contains("[")) {
// resultData = resultData.substring(1, resultData.length() - 1);
// }
// return JSON.parseObject(resultData, BillVO.class);
// }
// } catch (Exception e) {
// e.printStackTrace();
// logger.error("解析返回参数失败的错误", e);
// //如果解析失败记录原因但是不能影响结果的记录
// }
// return null;
// }
//
//}

View File

@ -14,4 +14,6 @@ public class Attribute {
private String status;
private String taskNumber;
private String data;
private String errorcode;
private String errormsg;
}

View File

@ -14,9 +14,9 @@
<bean name="SupplierPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.base.SupplierPluginInitializer"/>
<!--调拨-->
<bean name="transferPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.transfer.TransferPluginInitializer"/>
<bean name="transferInPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.transfer.TransferInPluginInitializer"/>
<!-- <bean name="transferPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.transfer.TransferPluginInitializer"/>-->
<bean name="transferOutPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.transfer.TransferOutPluginInitializer"/>
<bean name="transferInPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.transfer.TransferInPluginInitializer"/>
<!--调整-->
<bean name="adjustInPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.adjust.AdjustInPluginInitializer"/>
<bean name="adjustOutPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.adjust.AdjustOutPluginInitializer"/>

View File

@ -26,7 +26,8 @@ public class BaseTest {
////////////////////////////////////////////////////////////////////////////////////SKU自动分配
@Test
public void t10(){
goodsAutoAllotPluginInitializer.start("0001A210000000000U4C");
// goodsAutoAllotPluginInitializer.start("0001A210000000000U4C");
goodsAutoAllotPluginInitializer.start("SKU001");
}
////////////////////////////////////////////////////////////////////////////////////SKU分类
@Test

View File

@ -12,8 +12,8 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = WebappApplication.class)
public class TransferTest {
@Autowired
private TransferPluginInitializer transferPluginInitializer;
// @Autowired
// private TransferPluginInitializer transferPluginInitializer;
@Autowired
private TransferInPluginInitializer transferInPluginInitializer;
@ -25,14 +25,14 @@ public class TransferTest {
private AdjustOutPluginInitializer adjustOutPluginInitializer;
////////////////////////////////////////////////////////////////////////////////////调拨订单
@Test
public void t00(){
transferPluginInitializer.start();
}
@Test
public void t01(){
transferPluginInitializer.start("LETS-TH2024080800000002");
}
// @Test
// public void t00(){
// transferPluginInitializer.start();
// }
// @Test
// public void t01(){
// transferPluginInitializer.start("LETS-TH2024080800000002");
// }
@ -40,7 +40,7 @@ public class TransferTest {
@Test
public void t10(){
transferOutPluginInitializer.start();
transferOutPluginInitializer.start("LETS-SH2024081400000001");
}
@Test
@ -55,7 +55,7 @@ public class TransferTest {
}
@Test
public void t21(){
transferInPluginInitializer.start("LETS-RE2024080800000002");
transferInPluginInitializer.start("LETS-RE2024081900000002");
}
@ -68,7 +68,7 @@ public class TransferTest {
}
@Test
public void t31(){
adjustInPluginInitializer.start("LETS-AH2024081300000003");
adjustInPluginInitializer.start("LETS-RE2024081900000003");
}
@Test
public void t32(){

View File

@ -24,6 +24,8 @@ public class OFSTranseferOrderSearchResponse extends ReturnMessageBasics {
private String companyCode;
/** 库存地点编码 */
private String facilityCode;
/** 目标货主编码 */
private String toCompanyCode;
/** 目标库存地点编码 */
private String toFacilityCode;
/** 订单编码 */