diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java index 2fef5395..b4dca5b0 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java @@ -492,7 +492,7 @@ public class ConsignmachiningIn extends PluginBaseEntity { //查询业务流程 //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 String processName = "委外加工"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName, pkCorp); + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); return bdBusitypeEntity; } @@ -563,7 +563,6 @@ public class ConsignmachiningIn extends PluginBaseEntity { return null; } - /** * 匹配U8C采购订单明细行 * 通过O采购入库单明细行,得到采购订单明细行,最后查找到U8C采购订单明细行 @@ -613,7 +612,7 @@ public class ConsignmachiningIn extends PluginBaseEntity { /** * 2024年8月25日 15:12:22 - * 推送U8C委外订单 + * 推送U8C委外入库单 * * @param param 原数据json * @author liuyang diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInReturn.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInReturn.java index f161677c..b5306313 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInReturn.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInReturn.java @@ -1,739 +1,469 @@ -//package com.hzya.frame.plugin.lets.plugin.outsourc; -// -//import cn.hutool.core.date.DateUtil; -//import cn.hutool.core.lang.Assert; -//import cn.hutool.core.util.StrUtil; -//import cn.hutool.http.HttpRequest; -//import com.alibaba.fastjson.JSON; -//import com.alibaba.fastjson.JSONObject; -//import com.hzya.frame.base.PluginBaseEntity; -//import com.hzya.frame.beanutil.BeanUtil; -//import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; -//import com.hzya.frame.plugin.lets.dao.*; -//import com.hzya.frame.plugin.lets.entity.*; -//import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; -//import com.hzya.frame.plugin.lets.u8cdto.*; -//import com.hzya.frame.plugin.lets.util.*; -//import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderData; -//import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderDetails; -//import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderHeader; -//import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrder; -//import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderDetails; -//import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderHeader; -//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.stock.StockinOrderSearchResponse; -//import com.hzya.frame.web.entity.JsonResultEntity; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -// -//import java.math.BigDecimal; -//import java.util.*; -// -///** -// * O采退出库 -> U8C红字委外入库单 -// * -// * @Author:liuyang -// * @Package:com.hzya.frame.plugin.lets.plugin.outsourc -// * @Project:kangarooDataCenterV3 -// * @name:ConsignmachiningIn -// * @Date:2024年8月26日 15:34:34 -// * @Filename:ConsignmachiningIn -// */ -//public class ConsignmachiningInReturn extends PluginBaseEntity { -// -// Logger logger = LoggerFactory.getLogger(ConsignmachiningInReturn.class); -// -// @Autowired -// private QueryBdBusitypeUtil queryBdBusitypeUtil; -// -// @Autowired -// private IBdCorpDao iBdCorpDao; -// -// @Autowired -// private IBdInvmandocDao iBdInvmandocDao; -// -// @Autowired -// private IBdCalbodyDao iBdCalbodyDao; -// -// @Autowired -// private RdclUtil rdclUtil; -// -// @Autowired -// private OfsStandardUtil ofsStandardUtil; -// -// @Autowired -// private IBdCumandocDao iBdCumandocDao; -// -// @Autowired -// private IBdCubasdocDao iBdCubasdocDao; -// -// @Autowired -// private IBdPurorgDao iBdPurorgDao; -// -// @Autowired -// private OnlyImplementProxyOrderUtil onlyImplementProxyOrder; -// -// @Autowired -// private IScOrderDao iScOrderDao; -// -// @Autowired -// private IScOrderBDao iScOrderBDao; -// -// @Autowired -// private IBdStordocDao iBdStordocDao; -// -// @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.outsourc.ConsignmachiningInReturn"; -// } -// -// @Override -// public String getPluginName() { -// return "OFS采退出库单生成U8C红字委外订单"; -// } -// -// @Override -// public String getPluginLabel() { -// return "OFS采退出库单生成U8C红字委外订单"; -// } -// -// @Override -// public String getPluginType() { -// return "3"; -// } -// -// @Override -// public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { -// return null; -// } -// -// /** -// * 根据单号查询 -// * -// * @author liuyang -// */ -// public void startImplement(String startTime, String endTime) { -// String threadNameStrStart = StrUtil.format("开始(委外采退)OFS采退出库单生成U8红字C委外订单 开始时间:{} 结束时间:{}", startTime, endTime); -// logger.info(threadNameStrStart); -// -// Thread thread = new Thread(new Runnable() { -// @Override -// public void run() { -// try { -// //OFS采退出库 -// List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); -// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); -// queryOfsSoSaleOutVo.setClosedAt_start(startTime); -// queryOfsSoSaleOutVo.setClosedAt_end(endTime); -// queryOfsSoSaleOutVo.setClientCode("LETS"); -// queryOfsSoSaleOutVo.setPageNo(1L); -// queryOfsSoSaleOutVo.setPageSize(50L); -// queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE_RETURN"); -// queryOfsSoSaleOutVo.setStatus(900L); -// ofsStandardUtil.queryOfsSaleOrder(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.shipment.search"); -// logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); -// if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { -// getSet(returnGoodHeaderDetailsDataDtoArrayList); -// } else { -// logger.info("没有查询到任何数据!不需要发起同步逻辑!!"); -// } -// } catch (Exception e) { -// logger.error("startImplement方法抛出异常", e); -// } -// } -// }, threadNameStrStart); -// thread.start(); -// try { -// thread.join(); -// } catch (Exception e) { -// logger.error("thread.join()异常", e); -// } -// String threadNameStrEnd = StrUtil.format("结束(委外采退)OFS采退出库单生成U8红字C委外订单 开始时间:{} 结束时间:{}", startTime, endTime); -// logger.info(threadNameStrEnd); -// } -// -// /** -// * 根据单号查询 -// * -// * @author liuyang -// */ -// public void startImplement(String code) { -// String threadNameStrStart = StrUtil.format("开始(委外采退)OFS采退出库单生成U8红字C委外订单 OFS采购入库单号:{}", code); -// logger.info(threadNameStrStart); -// -// Thread thread = new Thread(new Runnable() { -// @Override -// public void run() { -// try { -// List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); -// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); -// queryOfsSoSaleOutVo.setClientCode("LETS"); -// queryOfsSoSaleOutVo.setPageNo(1L); -// queryOfsSoSaleOutVo.setPageSize(50L); -// queryOfsSoSaleOutVo.setCode(code); -// queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE_RETURN"); -// queryOfsSoSaleOutVo.setStatus(900L); -// ofsStandardUtil.queryOfsSaleOrder(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.shipment.search"); -// logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); -// if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { -// getSet(returnGoodHeaderDetailsDataDtoArrayList); -// } else { -// logger.info("没有查询到任何数据!不需要发起同步逻辑!!"); -// } -// } catch (Exception e) { -// logger.error("startImplement方法抛出异常", e); -// } -// } -// }, threadNameStrStart); -// thread.start(); -// try { -// thread.join(); -// } catch (Exception e) { -// logger.error("thread.join()异常", e); -// } -// String threadNameStrEnd = StrUtil.format("结束(委外采退)OFS采退出库单生成U8红字C委外订单 OFS采购入库单号:{}", code); -// logger.info(threadNameStrEnd); -// } -// -// /** -// * 环境预配置 -// * -// * @param returnGoodHeaderDetailsDataDtoArrayList 采退出库单 -// * @author liuyang -// */ -// private void getSet(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { -// //过滤成功的数据 -// List headerDetailsDtos = filterData(returnGoodHeaderDetailsDataDtoArrayList); -// //执行推送主逻辑 -// implement(headerDetailsDtos); -// } -// -// /** -// * 过滤掉成功的数据 -// * -// * @author liuyang -// */ -// private List filterData(List returnGoodHeaderDetailsDataDtoArrayList) { -// List headerDetailsDtoList1 = new ArrayList<>(); -// if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { -// //TODO 出库单明细主键,需要O返回,目前没有,已经提需求 -// headerDetailsDtoList1.addAll(returnGoodHeaderDetailsDataDtoArrayList); -// } -// return headerDetailsDtoList1; -// } -// -// /** -// * 执行主逻辑 -// * -// * @author liuyang -// */ -// private void implement(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { -// if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { -// try { -// // 查询基本档案 -// List returnOrderHeaderDtos = queryBasicArchives(returnGoodHeaderDetailsDataDtoArrayList); -// // 查询采购收发类别 -// BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("105"); -// -// if (returnOrderHeaderDtos != null && returnOrderHeaderDtos.size() > 0) { -// for (int i = 0; i < returnOrderHeaderDtos.size(); i++) { -// ReturnOrderHeaderDto returnOrderHeaderDto = returnOrderHeaderDtos.get(i); -// List details = returnOrderHeaderDto.getDetails(); -// -// String generateBusinessDate = createGenerateBusinessDate(returnOrderHeaderDto); //生成业务日期 -// PurchaseReturnOrder purchaseReturnOrder = returnOrderHeaderDto.getPurchaseReturnOrder();//OFS采退订单 -// ScOrderEntity scOrderEntity = returnOrderHeaderDto.getScOrderEntity();//U8C委外订单 -// BdCorpEntity bdCorpEntity = returnOrderHeaderDto.getBdCorpEntity();//公司 -// BdCalbodyEntity bdCalbodyEntity = returnOrderHeaderDto.getBdCalbodyEntity();//库存组织 -// BdStordocEntity bdStordocEntity = returnOrderHeaderDto.getBdStordocEntity();//仓库 -// -// // 代理委外入库业务流程 -// BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(bdCorpEntity.getPkCorp()); -// -// //委外入库表头 -// ConsignmachiningInHeadDto poOrderParentDto = new ConsignmachiningInHeadDto(); -// poOrderParentDto.setPk_corp(bdCorpEntity.getPkCorp()); -// poOrderParentDto.setCoperatorid("0001A110000000000U3D"); -// poOrderParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc()); -// poOrderParentDto.setPk_calbody(bdCalbodyEntity.getPkCalbody()); -// poOrderParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype()); -// poOrderParentDto.setCdispatcherid(bdRdclEntity.getPkRdcl());//收发类别 -// poOrderParentDto.setDbilldate(generateBusinessDate);//入库日期 -// -// //委外入库表头明细行 -// List consignmachiningInBodyDtoArrayList = new ArrayList<>(); -// for (int j = 0; j < details.size(); j++) { -// DetailsDto detailsDto = details.get(j); -// //匹配U8C采购订单明细行 -// ScOrderBEntity u8cPoOrderDetail = findOfsPoOrderDetailAndU8cPoOrderDetail(stockinB, ofsPoOrderData, scOrderBEntityList); -// //通过O采购订单入库单明细行,联查OFS采购订单明细行 -// OfsPoOrderDetails ofsPoOrderDetailRowTraget = findOfsPoOrderDetailRowTraget(stockinB, ofsPoOrderData); -// //查询存货管理档案 +package com.hzya.frame.plugin.lets.plugin.outsourc; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.beanutil.BeanUtil; +import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; +import com.hzya.frame.plugin.lets.dao.*; +import com.hzya.frame.plugin.lets.entity.*; +import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; +import com.hzya.frame.plugin.lets.u8cdto.*; +import com.hzya.frame.plugin.lets.util.*; +import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderData; +import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderDetails; +import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderHeader; +import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrder; +import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderDetails; +import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderHeader; +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.stock.StockinOrderSearchResponse; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.math.BigDecimal; +import java.util.*; + +/** + * O采退出库 -> (关联之前正向的委外订单)U8C红字委外入库单 + * + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.plugin.outsourc + * @Project:kangarooDataCenterV3 + * @name:ConsignmachiningIn + * @Date:2024年8月26日 15:34:34 + * @Filename:ConsignmachiningIn + */ +public class ConsignmachiningInReturn extends PluginBaseEntity { + + Logger logger = LoggerFactory.getLogger(ConsignmachiningInReturn.class); + + @Autowired + private QueryBdBusitypeUtil queryBdBusitypeUtil; + + @Autowired + private IBdCorpDao iBdCorpDao; + + @Autowired + private IBdInvmandocDao iBdInvmandocDao; + + @Autowired + private IBdCalbodyDao iBdCalbodyDao; + + @Autowired + private RdclUtil rdclUtil; + + @Autowired + private OfsStandardUtil ofsStandardUtil; + + @Autowired + private IBdCumandocDao iBdCumandocDao; + + @Autowired + private IBdCubasdocDao iBdCubasdocDao; + + @Autowired + private IBdPurorgDao iBdPurorgDao; + + @Autowired + private OnlyImplementProxyOrderUtil onlyImplementProxyOrder; + + @Autowired + private IScOrderDao iScOrderDao; + + @Autowired + private IScOrderBDao iScOrderBDao; + + @Autowired + private IBdStordocDao iBdStordocDao; + + @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.outsourc.ConsignmachiningInReturn"; + } + + @Override + public String getPluginName() { + return "OFS采退出库单生成U8C红字委外订单(关联原委外订单)"; + } + + @Override + public String getPluginLabel() { + return "OFS采退出库单生成U8C红字委外订单(关联原委外订单)"; + } + + @Override + public String getPluginType() { + return "3"; + } + + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { + return null; + } + + /** + * 根据时间范围查询 + * + * @author liuyang + */ + public void startImplementByTime(String startTime, String endTime) { + long startMillis = System.currentTimeMillis(); + String threadNameStrStart = StrUtil.format("开始(委外采退)OFS采退出库单生成U8红字C委外订单 开始时间:{} 结束时间:{}", startTime, endTime); + logger.info(threadNameStrStart); + + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + //OFS采退出库 + List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); + QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); + queryOfsSoSaleOutVo.setClosedAt_start(startTime); + queryOfsSoSaleOutVo.setClosedAt_end(endTime); + queryOfsSoSaleOutVo.setClientCode("LETS"); + queryOfsSoSaleOutVo.setPageNo(1L); + queryOfsSoSaleOutVo.setPageSize(50L); + queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE_RETURN"); + queryOfsSoSaleOutVo.setStatus(900L); + ofsStandardUtil.queryOfsSaleOrder(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.shipment.search"); + logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); + if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { + getSet(returnGoodHeaderDetailsDataDtoArrayList); + } else { + logger.info("没有查询到任何数据!不需要发起同步逻辑!!"); + } + } catch (Exception e) { + logger.error("startImplement方法抛出异常", e); + } + } + }, threadNameStrStart); + thread.start(); + try { + thread.join(); + } catch (Exception e) { + logger.error("thread.join()异常", e); + } + long endMillis = System.currentTimeMillis(); + String threadNameStrEnd = StrUtil.format("结束(委外采退)OFS采退出库单生成U8红字C委外订单 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); + logger.info(threadNameStrEnd); + } + + /** + * 根据单号查询 + * + * @author liuyang + */ + public void startImplement(String code) { + long startMillis = System.currentTimeMillis(); + String threadNameStrStart = StrUtil.format("开始(委外采退)OFS采退出库单生成U8红字C委外订单 OFS采购入库单号:{}", code); + logger.info(threadNameStrStart); + + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); + QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); + queryOfsSoSaleOutVo.setClientCode("LETS"); + queryOfsSoSaleOutVo.setPageNo(1L); + queryOfsSoSaleOutVo.setPageSize(50L); + queryOfsSoSaleOutVo.setCode(code); + queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE_RETURN"); + queryOfsSoSaleOutVo.setStatus(900L); + ofsStandardUtil.queryOfsSaleOrder(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.shipment.search"); + logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); + if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { + getSet(returnGoodHeaderDetailsDataDtoArrayList); + } else { + logger.info("没有查询到任何数据!不需要发起同步逻辑!!"); + } + } catch (Exception e) { + logger.error("startImplement方法抛出异常", e); + } + } + }, threadNameStrStart); + thread.start(); + try { + thread.join(); + } catch (Exception e) { + logger.error("thread.join()异常", e); + } + long endMillis = System.currentTimeMillis(); + String threadNameStrEnd = StrUtil.format("结束(委外采退)OFS采退出库单生成U8红字C委外订单 OFS采购入库单号:{} 耗时:{}", code, (endMillis - startMillis)); + logger.info(threadNameStrEnd); + } + + /** + * 环境预配置 + * + * @param returnGoodHeaderDetailsDataDtoArrayList 采退出库单 + * @author liuyang + */ + private void getSet(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { + //过滤成功的数据 + List headerDetailsDtos = filterData(returnGoodHeaderDetailsDataDtoArrayList); + //执行推送主逻辑 + implement(headerDetailsDtos); + } + + /** + * 过滤掉成功的数据 + * + * @author liuyang + */ + private List filterData(List returnGoodHeaderDetailsDataDtoArrayList) { + List headerDetailsDtoList1 = new ArrayList<>(); + if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { + //TODO 出库单明细主键,需要O返回,目前没有,已经提需求 + headerDetailsDtoList1.addAll(returnGoodHeaderDetailsDataDtoArrayList); + } + return headerDetailsDtoList1; + } + + /** + * 执行主逻辑 + * + * @author liuyang + */ + private void implement(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { + if (returnGoodHeaderDetailsDataDtoArrayList != null) { + logger.info("查询到的采退出库单数量(委外退货业务):{}", returnGoodHeaderDetailsDataDtoArrayList.size()); + } + if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { + try { + //OFS转换U8C档案 + List returnOrderHeaderDtos = queryBasicArchives(returnGoodHeaderDetailsDataDtoArrayList); + //查询采购收发类别 + BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("105"); + //代理委外入库业务流程 + BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); + + if (returnOrderHeaderDtos != null && returnOrderHeaderDtos.size() > 0) { + for (int i = 0; i < returnOrderHeaderDtos.size(); i++) { + ReturnOrderHeaderDto returnOrderHeaderDto = returnOrderHeaderDtos.get(i); + List details = returnOrderHeaderDto.getDetails(); + + String generateBusinessDate = createGenerateBusinessDate(returnOrderHeaderDto); //生成业务日期 + PurchaseReturnOrder purchaseReturnOrder = returnOrderHeaderDto.getPurchaseReturnOrder();//OFS采退订单 + ScOrderEntity scOrderEntity = returnOrderHeaderDto.getScOrderEntity();//U8C委外订单 + List scOrderBEntityList = returnOrderHeaderDto.getScOrderBEntityList();//U8C委外订单明细行 + BdCorpEntity bdCorpEntity = returnOrderHeaderDto.getBdCorpEntity();//公司 + BdCalbodyEntity bdCalbodyEntity = returnOrderHeaderDto.getBdCalbodyEntity();//库存组织 + BdStordocEntity bdStordocEntity = returnOrderHeaderDto.getBdStordocEntity();//仓库 + OfsPoOrderData ofsPoOrder = returnOrderHeaderDto.getOfsPoOrder();//OFS原正向的采购订单 + + //委外入库表头 + ConsignmachiningInHeadDto poOrderParentDto = new ConsignmachiningInHeadDto(); + poOrderParentDto.setPk_corp(bdCorpEntity.getPkCorp()); + poOrderParentDto.setCoperatorid("0001A110000000000U3D"); + poOrderParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc()); + poOrderParentDto.setPk_calbody(bdCalbodyEntity.getPkCalbody()); + poOrderParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype()); + poOrderParentDto.setCdispatcherid(bdRdclEntity.getPkRdcl());//收发类别 + poOrderParentDto.setDbilldate(generateBusinessDate);//入库日期 + poOrderParentDto.setFreplenishflag(true);//是否退货 + + //委外入库表头明细行 + List consignmachiningInBodyDtoArrayList = new ArrayList<>(); + for (int j = 0; j < details.size(); j++) { + DetailsDto detailsDto = details.get(j); + //匹配U8C采购订单明细行 + ScOrderBEntity u8cPoOrderDetail = findOfsPoOrderDetailAndU8cPoOrderDetail(detailsDto, purchaseReturnOrder, ofsPoOrder, scOrderBEntityList); + //通过O采退出库库单明细行,联查OFS采退订单明细行 + PurchaseReturnOrderDetails ofsPoOrderDetailRowTraget = findOfsPoOrderDetailRowTraget(detailsDto, purchaseReturnOrder); + //查询存货管理档案 // BdInvmandocEntity bdInvmandocEntity = queryInventoryMan(stockinB, bdCorpEntity.getPkCorp()); -// -// //计算含税单价 -// BigDecimal noriginalcurprice = null; -// String receivedQty = stockinB.getReceivedQty();//实收数量 -// String fulfillAmount = ofsPoOrderDetailRowTraget.getFulfillAmount();//实收累计总金额 -// try { -// noriginalcurprice = new BigDecimal(fulfillAmount).divide(new BigDecimal(receivedQty), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); -// } catch (Exception e) { -// logger.error("计算采购入库单原币含税单价失败", e); -// Assert.state(false, "计算采购入库单原币含税单价失败 原因:{}", e.getMessage()); -// } -// -// ConsignmachiningInBodyDto consignmachiningInBodyDto = new ConsignmachiningInBodyDto(); -// consignmachiningInBodyDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货 -// //TODO 测试 -// consignmachiningInBodyDto.setNinnum("1"); -//// consignmachiningInBodyDto.setNinnum(new BigDecimal(stockinB.getReceivedQty()).stripTrailingZeros().toPlainString());//实收数量 -// consignmachiningInBodyDto.setNprice(noriginalcurprice.stripTrailingZeros().toPlainString());//单价(含税单价) -// consignmachiningInBodyDto.setCsourcetype("61");//来源单据类型 -// consignmachiningInBodyDto.setVsourcerowno(u8cPoOrderDetail.getCrowno());//来源单据行号 -// consignmachiningInBodyDto.setVsourcebillcode(scOrderEntity.getVordercode());//来源单据号 -// consignmachiningInBodyDto.setWriteofftype("按备料发料核销");//核销方式 -// consignmachiningInBodyDtoArrayList.add(consignmachiningInBodyDto); -// } -// -// List consignmachiningInHeadBodyDtoArrayList = new ArrayList<>(); -// -// ConsignmachiningInHeadBodyDto consignmachiningInHeadBodyDto = new ConsignmachiningInHeadBodyDto(); -// consignmachiningInHeadBodyDto.setParentvo(poOrderParentDto); -// consignmachiningInHeadBodyDto.setChildrenvo(consignmachiningInBodyDtoArrayList); -// consignmachiningInHeadBodyDtoArrayList.add(consignmachiningInHeadBodyDto); -// -// Map> stringStringMap = new HashMap<>(); -// stringStringMap.put("GeneralBillVO", consignmachiningInHeadBodyDtoArrayList); -// //TODO 2024年8月26日 14:41:46 委外入库核销方式传不了!已经提交总部 -// //TODO 2024年8月26日 14:42:19 无法超委外订单数量入库!已经提交给总部 -// IcGeneralHResultDto icGeneralHResultDto = sendU8cConsignmachiningIn(JSON.toJSONString(stringStringMap)); -// -// String cgeneralhid = null; -// String vbillcode = null; -// IcGeneralHResultHeadDto parentvo = icGeneralHResultDto.getParentvo(); -// List childrenvo = icGeneralHResultDto.getChildrenvo(); -// if (parentvo != null) { -// cgeneralhid = parentvo.getCgeneralhid(); -// } -// if (childrenvo != null) { -// vbillcode = parentvo.getVbillcode(); -// } -// logger.info("推送U8C委外入库成功!委外入库单主键:{} 委外入库单编码:{}", cgeneralhid, vbillcode); -// } -// } else { -// logger.info("poOrderSonDto.size为0!"); -// } -// } catch (Exception e) { -// logger.error("implement方法抛出异常", e); -// } -// } -// } -// -// /** -// * 档案转换(OFS->U8C) -// * 2024年8月23日 12:02:47 和妮姐沟通,单据流程U8C成品委外订单 -> 备料计划 -> U8C委外发料(核销) -// * -// * @author liuyang -// */ -// private List queryBasicArchives(List returnGoodHeaderDetailsDataDtoList) { -// List consignmachiningInSonDtoArrayList = new ArrayList<>(); -// -// if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { -// try { -// for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) { -// HeaderDetailsDto headerDetailsDto = returnGoodHeaderDetailsDataDtoList.get(i); -// HeaderDto header = headerDetailsDto.getHeader(); -// List details = headerDetailsDto.getDetails(); -// -// //2024年8月27日 17:14:47 查询OFS采退订单 -// PurchaseReturnOrder purchaseReturnOrder = queryPurchaseReturnOrder(header.getRefOrderCode()); -// Assert.notNull(purchaseReturnOrder, "无法查询到采退订单 refOrderCode:{}", header.getRefOrderCode()); -// PurchaseReturnOrderHeader ofsWithdrawalHead = purchaseReturnOrder.getHeader(); -// List ofsWithdrawalDetails = purchaseReturnOrder.getDetails(); -// -// //如果该O采购订单对应的类型为:委外加工,则继续代码逻辑,否则就跳过代码逻辑 -// boolean checkResult = onlyImplementProxyOrder.onlyImplementProxyOrder(purchaseReturnOrder, "WWJG"); -// if (!checkResult) { -// continue; -// } -// -// //2024年8月27日 17:14:51 查询U8C委外订单,如果这一步报错,后续的逻辑就没有必要执行了 + BdInvmandocEntity bdInvmandocEntity = null; + + //计算含税单价 + BigDecimal noriginalcurprice = null; + String receivedQty = detailsDto.getShipQty();//实收数量 + String fulfillAmount = ofsPoOrderDetailRowTraget.getFulfillAmount();//实收累计总金额 + try { + noriginalcurprice = new BigDecimal(fulfillAmount).divide(new BigDecimal(receivedQty), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); + } catch (Exception e) { + logger.error("计算采退出库单原币含税单价失败", e); + Assert.state(false, "计算采退出库单原币含税单价失败 原因:{}", e.getMessage()); + } + + ConsignmachiningInBodyDto consignmachiningInBodyDto = new ConsignmachiningInBodyDto(); + consignmachiningInBodyDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货主键 + consignmachiningInBodyDto.setNinnum("-" + new BigDecimal(receivedQty).stripTrailingZeros().toPlainString());//实收数量 + consignmachiningInBodyDto.setNprice(noriginalcurprice.stripTrailingZeros().toPlainString());//单价(含税单价) + consignmachiningInBodyDto.setCsourcetype("61");//来源单据类型 + consignmachiningInBodyDto.setVsourcerowno(u8cPoOrderDetail.getCrowno());//来源单据行号 + consignmachiningInBodyDto.setVsourcebillcode(scOrderEntity.getVordercode());//来源单据号 +// consignmachiningInBodyDto.setWriteofftype("按备料发料核销");//核销方式,和妮姐已经确认,不用传递 + consignmachiningInBodyDto.setDbizdate(generateBusinessDate);// 入库日期 + consignmachiningInBodyDtoArrayList.add(consignmachiningInBodyDto); + } + + List consignmachiningInHeadBodyDtoArrayList = new ArrayList<>(); + ConsignmachiningInHeadBodyDto consignmachiningInHeadBodyDto = new ConsignmachiningInHeadBodyDto(); + consignmachiningInHeadBodyDto.setParentvo(poOrderParentDto); + consignmachiningInHeadBodyDto.setChildrenvo(consignmachiningInBodyDtoArrayList); + consignmachiningInHeadBodyDtoArrayList.add(consignmachiningInHeadBodyDto); + + Map> stringStringMap = new HashMap<>(); + stringStringMap.put("GeneralBillVO", consignmachiningInHeadBodyDtoArrayList); + //2024年8月26日 14:41:46 委外入库核销方式传不了!已经提交总部,2024年8月30日 14:05:25 已经解决,和妮姐确认不用填写 + //TODO 2024年8月26日 14:42:19 无法超委外订单数量入库!已经提交给总部 + IcGeneralHResultDto icGeneralHResultDto = sendU8cConsignmachiningIn(JSON.toJSONString(stringStringMap)); + + String cgeneralhid = null; + String vbillcode = null; + IcGeneralHResultHeadDto parentvo = icGeneralHResultDto.getParentvo(); + List childrenvo = icGeneralHResultDto.getChildrenvo(); + if (parentvo != null) { + cgeneralhid = parentvo.getCgeneralhid(); + vbillcode = parentvo.getVbillcode(); + } + logger.info("推送U8C红字委外入库成功!委外入库单主键:{} 委外入库单编码:{} 公司名称:{}", cgeneralhid, vbillcode, bdCorpEntity.getUnitname()); + } + } else { + logger.info("poOrderSonDto.size为0!"); + } + } catch (Exception e) { + logger.error("implement方法抛出异常", e); + } + } + } + + /** + * 档案转换(OFS->U8C) + * 2024年8月23日 12:02:47 和妮姐沟通,单据流程U8C成品委外订单 -> 备料计划 -> U8C委外发料(核销) + * + * @author liuyang + */ + private List queryBasicArchives(List returnGoodHeaderDetailsDataDtoList) throws Exception { + List consignmachiningInSonDtoArrayList = new ArrayList<>(); + + if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { + try { + for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) { + HeaderDetailsDto headerDetailsDto = returnGoodHeaderDetailsDataDtoList.get(i); + HeaderDto header = headerDetailsDto.getHeader(); + List details = headerDetailsDto.getDetails(); + + //2024年8月27日 17:14:47 查询OFS采退订单 + PurchaseReturnOrder purchaseReturnOrder = queryPurchaseReturnOrder(header.getRefOrderCode()); + Assert.notNull(purchaseReturnOrder, "无法查询到采退订单 refOrderCode:{}", header.getRefOrderCode()); + PurchaseReturnOrderHeader ofsWithdrawalHead = purchaseReturnOrder.getHeader(); + List ofsWithdrawalDetails = purchaseReturnOrder.getDetails(); + + //如果该O采购订单对应的类型为:委外加工,则继续代码逻辑,否则就跳过代码逻辑 + boolean checkResult = onlyImplementProxyOrder.onlyImplementProxyOrder(purchaseReturnOrder, "WWJG"); + if (!checkResult) { + continue; + } + + //2024年8月30日 13:28:46 查询原委外订单(取的是钉钉推送到U8C的委外订单),查询逻辑:OFS采退出库单 -> OFS采退订单 -> OFS采购订单 + OfsPoOrderData ofsPoOrder = queryOfsPoOrder(purchaseReturnOrder); + + //2024年8月30日 13:35:16 根据OFS采购订单,查询OFS委外订单 + ScOrderEntity scOrderEntity = queryScOrder(ofsPoOrder.getHeader().getId()); + + //2024年8月27日 17:14:51 查询U8C委外订单,如果这一步报错,后续的逻辑就没有必要执行了 // String ofsId = ofsWithdrawalHead.getId(); // Assert.notNull(ofsId, "通过接口查询到OFS采退订单,但是没有采退订单主键(id),业务逻辑无法完成"); // ScOrderEntity scOrderEntity = queryScOrder(ofsId); -// -// //2024年8月27日 17:14:57 根据U8C委外订单id,查询U8C委外订单表体明细行 -// List scOrderBEntityList = queryScOrderDetail(scOrderEntity.getCorderid()); -// -// //2024年8月27日 17:15:02 委外入库公司,取委外订单上的公司,已经和妮姐确认,没有必要通过O的公司转换,因为不存在跨组织的问题 -// Assert.notNull(scOrderEntity.getPkCorp(), "O表头公司不能为空"); -// BdCorpEntity bdCorpEntity = new BdCorpEntity(); -// bdCorpEntity.setDr(0); -// bdCorpEntity.setDataSourceCode("lets_u8c"); -// bdCorpEntity.setPkCorp(scOrderEntity.getPkCorp()); -// List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); -// if (bdCorpEntityList.size() == 0) { -// Assert.state(false, "根据委外订单公司主键:{},无法匹配到委外入库单", scOrderEntity.getPkCorp()); -// } else if (bdCorpEntityList.size() >= 2) { -// Assert.state(false, "根据委外订单公司主键:{},匹配到{}个委外入库单", scOrderEntity.getPkCorp(), bdCorpEntityList.size()); -// } -// -// // 2024年8月27日 17:15:09 收货库存组织,应该是通过收货公司查询得出收货库存组织,目前收货公司和采购公司保持一致,那么就以采购公司带出!这个逻辑已经和佳妮确认 -// BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); -// bdCalbodyEntity.setDr(0); -// bdCalbodyEntity.setDataSourceCode("lets_u8c"); -// bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); -// List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); -// if (bdCalbodyEntities.size() == 0) { -// Assert.state(false, "根据U8C采购公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); -// } else if (bdCalbodyEntities.size() >= 2) { -// Assert.state(false, "根据U8C采购公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); -// } -// -// //入库仓库 -// String facilityCode = header.getFacilityCode(); -// Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); -// BdStordocEntity bdStordocEntity = new BdStordocEntity(); -// bdStordocEntity.setDr(0L); -// bdStordocEntity.setDataSourceCode("lets_u8c"); -// bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); -// bdStordocEntity.setStorcode(facilityCode); -// List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); -// if (bdStordocEntityList.size() == 0) { -// Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,无法匹配到U8C仓库", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); -// } else if (bdStordocEntityList.size() >= 2) { -// Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,匹配到U8C仓库多个", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); -// } -// -// ReturnOrderHeaderDto returnOrderHeaderDto = new ReturnOrderHeaderDto(); -// returnOrderHeaderDto.setPurchaseReturnOrder(purchaseReturnOrder); -// returnOrderHeaderDto.setScOrderEntity(scOrderEntity); -// returnOrderHeaderDto.setScOrderBEntityList(scOrderBEntityList); -// returnOrderHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); -// returnOrderHeaderDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); -// returnOrderHeaderDto.setBdStordocEntity(bdStordocEntityList.get(0)); -// returnOrderHeaderDto.setDetails(details); -// -// BeanUtil.copyPropertiesV2(header, returnOrderHeaderDto); -// consignmachiningInSonDtoArrayList.add(returnOrderHeaderDto); -// } -// //成功 -// } catch (Exception e) { -// logger.error("委外入库OFS档案转换", e); -// //失败 -// } -// } else { -// logger.info("queryBasicArchives对应returnGoodHeaderDetailsDataDtoList.size为0"); -// } -// return consignmachiningInSonDtoArrayList; -// } -// -// /** -// * 查询委外订单表头对象 -// * -// * @author liuyang -// */ -//// private ScOrderEntity queryScOrder(String ofsPoOrderId) { -//// Assert.notNull(ofsPoOrderId, "ofsPoOrderId不能为空!"); -//// Assert.state(!"".equals(ofsPoOrderId.trim()), "ofsPoOrderId不能为空"); -//// -//// ScOrderEntity scOrderEntity = new ScOrderEntity(); -//// scOrderEntity.setVdef20(ofsPoOrderId); -//// scOrderEntity.setDr("0"); -//// scOrderEntity.setDataSourceCode("lets_u8c"); -//// List scOrderEntityList = iScOrderDao.query(scOrderEntity); -//// if (scOrderEntityList == null || scOrderEntityList.size() == 0) { -//// Assert.state(false, "根据O采购订单主键:{}(u委外订单自定义项20存储O采购订单主键),无法匹配到U8C委外订单", ofsPoOrderId); -//// } else if (scOrderEntityList.size() >= 2) { -//// Assert.state(false, "根据O采购订单主键:{}(u委外订单自定义项20存储O采购订单主键),匹配到{}个U8C委外订单", ofsPoOrderId, scOrderEntityList.size()); -//// } -//// return scOrderEntityList.get(0); -//// } -// -// /** -// * 2024年8月25日 14:11:31 查询U8C委外订单明细 -// * -// * @param corderid 委外订单表头主键 -// * @author liuyang -// */ -//// private List queryScOrderDetail(String corderid) throws Exception { -//// Assert.notNull(corderid, "委外订单表头主键不能为空!"); -//// Assert.state(!"".equals(corderid), "委外订单表头主键不能为空!"); -//// -//// ScOrderBEntity scOrderBEntity = new ScOrderBEntity(); -//// scOrderBEntity.setCorderid(corderid); -//// scOrderBEntity.setDr("0"); -//// scOrderBEntity.setDataSourceCode("lets_u8c"); -//// List scOrderBEntityList = iScOrderBDao.query(scOrderBEntity); -//// if (scOrderBEntityList == null || scOrderBEntityList.size() == 0) { -//// //2024年8月25日 14:16:31 这个验证非常要必要,单据如果没有表体没有行,是很可疑的 -//// Assert.state(false, "根据U8C委外订单主键({})无法查询到委外订单表体明细行!", corderid); -//// } -//// return scOrderBEntityList; -//// } -// -// /** -// * 匹配U8C采购订单明细行 -// * 通过O采购入库单明细行,得到采购订单明细行,最后查找到U8C采购订单明细行 -// * -// * @param stockinB OFS采购入库单明细行 -// * @param ofsPoOrderData OFS采购订单 -// * @param scOrderBEntityList U8C委外订单明细行 -// * @author liuyang -// */ -//// private ScOrderBEntity findOfsPoOrderDetailAndU8cPoOrderDetail(StockinOrderSearchResponse.StockinOrder.StockinB stockinB, OfsPoOrderData ofsPoOrderData, List scOrderBEntityList) { -//// Assert.notNull(stockinB, "stockinB不能为空"); -//// Assert.notNull(ofsPoOrderData, "ofsPoOrderData不能为空"); -//// Assert.notNull(scOrderBEntityList, "scOrderBEntityList删除不能为空"); -//// -////// OfsPoOrderHeader header = ofsPoOrderData.getHeader(); -//// List details = ofsPoOrderData.getDetails(); -//// -//// //查找采购订单明细行 -//// OfsPoOrderDetails tarGetOfsPoOrderDetails = null; -//// for (int i = 0; i < details.size(); i++) { -//// OfsPoOrderDetails ofsPoOrderDetails = details.get(i); -//// if (ofsPoOrderDetails.getId().equals(stockinB.getRefOrderDetailId())) { -//// tarGetOfsPoOrderDetails = ofsPoOrderDetails; -//// } -//// } -//// Assert.notNull(tarGetOfsPoOrderDetails, "无法匹配到采购订单明细行! 目标主键:{}", stockinB.getRefOrderDetailId()); -//// -//// //根据采购订单明细行主键,查找U8C采购订单明细行 -//// for (int i = 0; i < scOrderBEntityList.size(); i++) { -//// ScOrderBEntity scOrderBEntity = scOrderBEntityList.get(i); -//// Assert.notNull(scOrderBEntity.getVdef20(), "委外订单明细行v20不能为空(明细行v20存储O采购订单明细行主键)!"); -//// Assert.state(!"".equals(scOrderBEntity.getVdef20()), "委外订单明细行v20不能为空(明细行v20存储O采购订单明细行主键)!"); -//// if (tarGetOfsPoOrderDetails.getId().equals(scOrderBEntity.getVdef20())) { -//// return scOrderBEntity; -//// } -//// } -//// Assert.state(false, "通过U8C采购订单明细行主键层层匹配到U8C采购明细失败!"); -//// return null; -//// } -// -// -// /** -// * 匹配U8C采购订单明细行 -// * 通过O采购入库单明细行,得到采购订单明细行,最后查找到U8C采购订单明细行 -// * -// * @param stockinB OFS采购入库单明细行 -// * @param ofsPoOrderData OFS采购订单 -// * @author liuyang -// */ -//// private OfsPoOrderDetails findOfsPoOrderDetailRowTraget(StockinOrderSearchResponse.StockinOrder.StockinB stockinB, OfsPoOrderData ofsPoOrderData) { -//// Assert.notNull(stockinB, "stockinB不能为空"); -//// Assert.notNull(ofsPoOrderData, "ofsPoOrderData不能为空"); -//// -//// List details = ofsPoOrderData.getDetails(); -//// for (int i = 0; i < details.size(); i++) { -//// OfsPoOrderDetails ofsPoOrderDetails = details.get(i); -//// if (ofsPoOrderDetails.getId().equals(stockinB.getRefOrderDetailId())) { -//// return ofsPoOrderDetails; -//// } -//// } -//// Assert.state(false, "通过OFS采购入库单,无法匹配到OFS采购订单明细行! 目标主键:{}", stockinB.getRefOrderDetailId()); -//// return null; -//// } -// -// /** -// * 查询存货管理档案 -// * -// * @param pkCorp 发货公司主键 -// * @param detailsDto 采购入库单明细行 -// * @author liuyang -// */ -// private BdInvmandocEntity queryInventoryMan(DetailsDto detailsDto, String pkCorp) throws Exception { -// Assert.notNull(detailsDto, "sonDetailsDto不能为空"); -// Assert.notNull(detailsDto.getSkuCode(), "O存货商家编码不能为空"); -// Assert.notNull(pkCorp, "发货公司主键不能为空"); -// -// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); -// bdInvmandocEntity.setInvcode(detailsDto.getSkuCode()); -// bdInvmandocEntity.setPkCorp(pkCorp); -// List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); -// if (bdInvmandocEntity2.size() == 0) { -// Assert.state(false, "根据O商家编码:{} U8C发货公司主键:{}没有查询到存货管理档案", detailsDto.getSkuCode(), pkCorp); -// } else if (bdInvmandocEntity2.size() >= 2) { -// Assert.state(false, "根据O商家编码:{} U8C发货公司主键:{}没有查询到存货管理档案", detailsDto.getSkuCode(), pkCorp); -// } -// return bdInvmandocEntity2.get(0); -// } -// -// /** -// * 2024年8月25日 15:12:22 -// * 推送U8C委外订单 -// * -// * @param param 原数据json -// * @author liuyang -// */ -// public IcGeneralHResultDto sendU8cScorder(String param) throws Exception { -// long startLong = System.currentTimeMillis(); -// logger.info("U8C委外订单推送开始,推送参数:" + param + ",U8C_URL:" + ProfilesActiveConstant.U8C_URL); -// String result = HttpRequest.post(ProfilesActiveConstant.U8C_URL).header("appId", "800037")//头信息,多个头信息多次调用此方法即可 -// .header("usercode", "admin").header("password", "21232f297a57a5a743894a0e4a801fc3").header("system", "lz").header("trantype", "PK").header("apiCode", "8000370037")//头信息,多个头信息多次调用此方法即可 -// .header("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可 -// .header("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可 -// .body(param)//表单内容 -// .timeout(20000)//超时,毫秒 -// .execute().body(); -// logger.info("U8C委外订单推送结束,返回参数:" + result); -// long endLong = System.currentTimeMillis(); -// logger.info("U8C委外订单推送耗时:" + (endLong - startLong)); -// -// if (result == null) { -// result = ""; -// } -// -// JSONObject jsonObject = JSON.parseObject(result); -// result = String.valueOf(jsonObject.get("attribute")); -// -// boolean isSuccess = false; -// IcGeneralHResultDto icGeneralHResultDto = null; -// if (result != null && !"".equals(result)) { -// ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class); -// if ("success".equals(reusltStrDto.getStatus())) { -// icGeneralHResultDto = resultDataHandle(reusltStrDto.getData()); -// isSuccess = true; -// } -// } -// if (!isSuccess) { -// Assert.state(false, "O采购入库业务推送U8C委外订单失败 接口返回结果:{}", result); -// } -// return icGeneralHResultDto; -// } -// -// /** -// * 返回结果解析处理,在确认了success后调用 -// * -// * @author liuyang -// */ -// private IcGeneralHResultDto resultDataHandle(String resultData) { -// try { -// if (resultData != null && !"".equals(resultData)) { -// if (resultData.contains("[")) { -// resultData = resultData.substring(1, resultData.length() - 1); -// } -// return JSON.parseObject(resultData, IcGeneralHResultDto.class); -// } -// } catch (Exception e) { -// logger.error("resultDataHandle方法解析返回参数失败的错误", e); -// //如果解析失败,记录原因,但是不能影响结果的记录 -// } -// return null; -// } -// -// /** -// * 查询采退订单 -// * -// * @param code 采退订单号 -// * @author liuyang -// */ -// private PurchaseReturnOrder queryPurchaseReturnOrder(String code) throws Exception { -// List headerDetailsDtoList = new ArrayList<>(); -// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); -// queryOfsSoSaleOutVo.setCode(code); -// queryOfsSoSaleOutVo.setClientCode("LETS"); -// queryOfsSoSaleOutVo.setPageNo(1L); -// queryOfsSoSaleOutVo.setPageSize(50L); -// ofsStandardUtil.queryPurchaseReturnOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L, "ofs.purchaseReturnOrder.search"); -// if (headerDetailsDtoList.size() > 0) { -// return headerDetailsDtoList.get(0); -// } -// Assert.state(false, "根据OFS采购订单号:{}无法查询到OFS采购订单信息", code); -// return null; -// } -// -// /** -// * 2024年8月20日 15:46:10 -// * 生成业务日期,以发货时间作为业务日期 -// * -// * @author liuyang -// */ -// private String createGenerateBusinessDate(ReturnOrderHeaderDto returnOrderHeaderDto) throws Exception { -// if (returnOrderHeaderDto != null && returnOrderHeaderDto.getShipAt() != null) { -// String shipAt = returnOrderHeaderDto.getShipAt(); -// String businessFormat = null; -// try { -// Date dbill = DateUtil.parse(shipAt); -// businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); -// } catch (Exception e) { -// logger.error("业务日期生成失败!", e); -// } -// return businessFormat; -// } else { -// logger.error("生成采退出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(returnOrderHeaderDto)); -// Assert.state(false, "生成采退出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(returnOrderHeaderDto)); -// return null; -// } -// } -// -// /** -// * 2024年8月7日 14:58:34 -// * 查询税目档案 -// * -// * @author liuyang -// */ -// private BdTaxitemsEntity queryBdTaxitems(String invcode) { -// Assert.notNull(invcode, "存货编码不能为空"); -// BdTaxitemsEntity bdTaxitemsEntity = TocOrderBasicArchivesCacheUtil.stringBdTaxitemsEntityHashMap.get(invcode); -// Assert.notNull(bdTaxitemsEntity, "根据存货编码({}),无法匹配到税率!", invcode); -// return bdTaxitemsEntity; -// } -// -// /** -// * 2024年8月20日 16:42:14 -// * 查找对应的采购订单明细行 -// * 2024年8月20日 17:42:15 -// * 应该通过明细行主键匹配,但是只能根据sku匹配目前的实现逻辑 -// * 查找OFS采购订单明细行,主要是为了带出实付金额,通过实付金额/实收数量=含税单价 -// * -// * @param ofsPoOrderDataDetails OFS采退订单明细行所有对象 -// * @param detailsDto OFS采退入库单明细行对象 -// * @author liuyang -// */ -// private PurchaseReturnOrderDetails findOfsPoOrderDetail(List ofsPoOrderDataDetails, DetailsDto detailsDto) { -// if (ofsPoOrderDataDetails != null && ofsPoOrderDataDetails.size() > 0 && detailsDto != null) { -// for (int i = 0; i < ofsPoOrderDataDetails.size(); i++) { -// Assert.notNull(ofsPoOrderDataDetails.get(i).getId(), "采退订单明细行主键不能为空!"); -// -// Assert.notNull(detailsDto.getRefOrderDetailId(), "采退出库单明细行对应的关联采退订单的明细行主键不能为空!"); -// if (ofsPoOrderDataDetails.get(i).getId().equals(detailsDto.getRefOrderDetailId())) { -// return ofsPoOrderDataDetails.get(0); -// } -// } -// } else { -// logger.error("findOfsPoOrderDetail方法对应的ofsPoOrderDataDetails不能为空!否则业务目标无法完成!"); -// } -// Assert.state(false, "无法匹配到采退订单明细行,业务逻辑无法完成!"); -// return null; -// } -// -// /** -// * 查询委外订单表头对象 -// * -// * @param ofsPoOrderId OFS采退订单主键 -// * @author liuyang -// */ + + //2024年8月27日 17:14:57 根据U8C委外订单id,查询U8C委外订单表体明细行 + List scOrderBEntityList = queryScOrderDetail(scOrderEntity.getCorderid()); + + //2024年8月27日 17:15:02 委外入库公司,取委外订单上的公司,已经和妮姐确认,没有必要通过O的公司转换,因为不存在跨组织的问题 + Assert.notNull(scOrderEntity.getPkCorp(), "O表头公司不能为空"); + BdCorpEntity bdCorpEntity = new BdCorpEntity(); + bdCorpEntity.setDr(0); + bdCorpEntity.setDataSourceCode("lets_u8c"); + bdCorpEntity.setPkCorp(scOrderEntity.getPkCorp()); + List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); + if (bdCorpEntityList.size() == 0) { + Assert.state(false, "根据委外订单公司主键:{},无法匹配到委外入库单", scOrderEntity.getPkCorp()); + } else if (bdCorpEntityList.size() >= 2) { + Assert.state(false, "根据委外订单公司主键:{},匹配到{}个委外入库单", scOrderEntity.getPkCorp(), bdCorpEntityList.size()); + } + + // 2024年8月27日 17:15:09 收货库存组织,应该是通过收货公司查询得出收货库存组织,目前收货公司和采购公司保持一致,那么就以采购公司带出!这个逻辑已经和佳妮确认 + BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); + bdCalbodyEntity.setDr(0); + bdCalbodyEntity.setDataSourceCode("lets_u8c"); + bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); + if (bdCalbodyEntities.size() == 0) { + Assert.state(false, "根据U8C采购公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); + } else if (bdCalbodyEntities.size() >= 2) { + Assert.state(false, "根据U8C采购公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); + } + + //入库仓库 + String facilityCode = header.getFacilityCode(); + Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); + BdStordocEntity bdStordocEntity = new BdStordocEntity(); + bdStordocEntity.setDr(0L); + bdStordocEntity.setDataSourceCode("lets_u8c"); + bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); + bdStordocEntity.setStorcode(facilityCode); + List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); + if (bdStordocEntityList.size() == 0) { + Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,无法匹配到U8C仓库", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); + } else if (bdStordocEntityList.size() >= 2) { + Assert.state(false, "根据O仓库编码+U8C收货库存组织主键,匹配到U8C仓库多个", facilityCode, bdCalbodyEntities.get(0).getPkCalbody()); + } + + ReturnOrderHeaderDto returnOrderHeaderDto = new ReturnOrderHeaderDto(); + returnOrderHeaderDto.setPurchaseReturnOrder(purchaseReturnOrder); + returnOrderHeaderDto.setScOrderEntity(scOrderEntity); + returnOrderHeaderDto.setScOrderBEntityList(scOrderBEntityList); + returnOrderHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); + returnOrderHeaderDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); + returnOrderHeaderDto.setBdStordocEntity(bdStordocEntityList.get(0)); + returnOrderHeaderDto.setDetails(details); + returnOrderHeaderDto.setOfsPoOrder(ofsPoOrder); + + BeanUtil.copyPropertiesV2(header, returnOrderHeaderDto); + consignmachiningInSonDtoArrayList.add(returnOrderHeaderDto); + } + //成功 + } catch (Exception e) { + logger.error("委外入库OFS档案转换", e); + //失败 + } + } else { + logger.info("queryBasicArchives对应returnGoodHeaderDetailsDataDtoList.size为0"); + } + return consignmachiningInSonDtoArrayList; + } + + /** + * 查询委外订单表头对象 + * + * @author liuyang + */ // private ScOrderEntity queryScOrder(String ofsPoOrderId) { -// Assert.notNull(ofsPoOrderId, "OFS采退订单主键不能为空!"); -// Assert.state(!"".equals(ofsPoOrderId.trim()), "OFS采退订单主键不能为空!"); +// Assert.notNull(ofsPoOrderId, "ofsPoOrderId不能为空!"); +// Assert.state(!"".equals(ofsPoOrderId.trim()), "ofsPoOrderId不能为空"); // // ScOrderEntity scOrderEntity = new ScOrderEntity(); -// scOrderEntity.setVdef17(ProfilesActiveConstant.sourceSystem1); // scOrderEntity.setVdef20(ofsPoOrderId); // scOrderEntity.setDr("0"); // scOrderEntity.setDataSourceCode("lets_u8c"); @@ -745,13 +475,13 @@ // } // return scOrderEntityList.get(0); // } -// -// /** -// * 2024年8月25日 14:11:31 查询U8C委外订单明细 -// * -// * @param corderid 委外订单表头主键 -// * @author liuyang -// */ + + /** + * 2024年8月25日 14:11:31 查询U8C委外订单明细 + * + * @param corderid 委外订单表头主键 + * @author liuyang + */ // private List queryScOrderDetail(String corderid) throws Exception { // Assert.notNull(corderid, "委外订单表头主键不能为空!"); // Assert.state(!"".equals(corderid), "委外订单表头主键不能为空!"); @@ -767,33 +497,16 @@ // } // return scOrderBEntityList; // } -// -// /** -// * 2024年8月6日 10:59:03 查询U8C业务流程 -// * -// * @param pkCorp 公司主键 -// * @author liuyang -// */ -// private BdBusitypeEntity u8cOperationFlow(String pkCorp) throws Exception { -// Assert.notNull(pkCorp, "公司主键不能为空!"); -// Assert.state(!"".equals(pkCorp.trim()), "公司主键不能为空!"); -// //查询业务流程 -// //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 -// String processName = "委外加工"; -// BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName, pkCorp); -// Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); -// return bdBusitypeEntity; -// } -// -// /** -// * 匹配U8C采购订单明细行 -// * 通过O采购入库单明细行,得到采购订单明细行,最后查找到U8C采购订单明细行 -// * -// * @param stockinB OFS采购入库单明细行 -// * @param ofsPoOrderData OFS采购订单 -// * @param scOrderBEntityList U8C委外订单明细行 -// * @author liuyang -// */ + + /** + * 匹配U8C采购订单明细行 + * 通过O采购入库单明细行,得到采购订单明细行,最后查找到U8C采购订单明细行 + * + * @param stockinB OFS采购入库单明细行 + * @param ofsPoOrderData OFS采购订单 + * @param scOrderBEntityList U8C委外订单明细行 + * @author liuyang + */ // private ScOrderBEntity findOfsPoOrderDetailAndU8cPoOrderDetail(StockinOrderSearchResponse.StockinOrder.StockinB stockinB, OfsPoOrderData ofsPoOrderData, List scOrderBEntityList) { // Assert.notNull(stockinB, "stockinB不能为空"); // Assert.notNull(ofsPoOrderData, "ofsPoOrderData不能为空"); @@ -824,4 +537,402 @@ // Assert.state(false, "通过U8C采购订单明细行主键层层匹配到U8C采购明细失败!"); // return null; // } -//} + + + /** + * 匹配U8C采购订单明细行 + * 通过O采购入库单明细行,得到采购订单明细行,最后查找到U8C采购订单明细行 + * + * @param stockinB OFS采购入库单明细行 + * @param ofsPoOrderData OFS采购订单 + * @author liuyang + */ +// private OfsPoOrderDetails findOfsPoOrderDetailRowTraget(StockinOrderSearchResponse.StockinOrder.StockinB stockinB, OfsPoOrderData ofsPoOrderData) { +// Assert.notNull(stockinB, "stockinB不能为空"); +// Assert.notNull(ofsPoOrderData, "ofsPoOrderData不能为空"); +// +// List details = ofsPoOrderData.getDetails(); +// for (int i = 0; i < details.size(); i++) { +// OfsPoOrderDetails ofsPoOrderDetails = details.get(i); +// if (ofsPoOrderDetails.getId().equals(stockinB.getRefOrderDetailId())) { +// return ofsPoOrderDetails; +// } +// } +// Assert.state(false, "通过OFS采购入库单,无法匹配到OFS采购订单明细行! 目标主键:{}", stockinB.getRefOrderDetailId()); +// return null; +// } + + /** + * 查询存货管理档案 + * + * @param pkCorp 发货公司主键 + * @param detailsDto 采购入库单明细行 + * @author liuyang + */ + private BdInvmandocEntity queryInventoryMan(DetailsDto detailsDto, String pkCorp) throws Exception { + Assert.notNull(detailsDto, "sonDetailsDto不能为空"); + Assert.notNull(detailsDto.getSkuCode(), "O存货商家编码不能为空"); + Assert.notNull(pkCorp, "发货公司主键不能为空"); + + BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); + bdInvmandocEntity.setInvcode(detailsDto.getSkuCode()); + bdInvmandocEntity.setPkCorp(pkCorp); + List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); + if (bdInvmandocEntity2.size() == 0) { + Assert.state(false, "根据O商家编码:{} U8C发货公司主键:{}没有查询到存货管理档案", detailsDto.getSkuCode(), pkCorp); + } else if (bdInvmandocEntity2.size() >= 2) { + Assert.state(false, "根据O商家编码:{} U8C发货公司主键:{}没有查询到存货管理档案", detailsDto.getSkuCode(), pkCorp); + } + return bdInvmandocEntity2.get(0); + } + + /** + * 2024年8月25日 15:12:22 + * 推送U8C委外订单 + * + * @param param 原数据json + * @author liuyang + */ + public IcGeneralHResultDto sendU8cScorder(String param) throws Exception { + long startLong = System.currentTimeMillis(); + logger.info("U8C委外订单推送开始,推送参数:" + param + ",U8C_URL:" + ProfilesActiveConstant.U8C_URL); + String result = HttpRequest.post(ProfilesActiveConstant.U8C_URL).header("appId", "800037")//头信息,多个头信息多次调用此方法即可 + .header("usercode", "admin").header("password", "21232f297a57a5a743894a0e4a801fc3").header("system", "lz").header("trantype", "PK").header("apiCode", "8000370037")//头信息,多个头信息多次调用此方法即可 + .header("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可 + .header("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可 + .body(param)//表单内容 + .timeout(20000)//超时,毫秒 + .execute().body(); + logger.info("U8C委外订单推送结束,返回参数:" + result); + long endLong = System.currentTimeMillis(); + logger.info("U8C委外订单推送耗时:" + (endLong - startLong)); + + if (result == null) { + result = ""; + } + + JSONObject jsonObject = JSON.parseObject(result); + result = String.valueOf(jsonObject.get("attribute")); + + boolean isSuccess = false; + IcGeneralHResultDto icGeneralHResultDto = null; + if (result != null && !"".equals(result)) { + ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class); + if ("success".equals(reusltStrDto.getStatus())) { + icGeneralHResultDto = resultDataHandle(reusltStrDto.getData()); + isSuccess = true; + } + } + if (!isSuccess) { + Assert.state(false, "O采购入库业务推送U8C委外订单失败 接口返回结果:{}", result); + } + return icGeneralHResultDto; + } + + /** + * 返回结果解析处理,在确认了success后调用 + * + * @author liuyang + */ + private IcGeneralHResultDto resultDataHandle(String resultData) { + try { + if (resultData != null && !"".equals(resultData)) { + if (resultData.contains("[")) { + resultData = resultData.substring(1, resultData.length() - 1); + } + return JSON.parseObject(resultData, IcGeneralHResultDto.class); + } + } catch (Exception e) { + logger.error("resultDataHandle方法解析返回参数失败的错误", e); + //如果解析失败,记录原因,但是不能影响结果的记录 + } + return null; + } + + /** + * 查询采退订单 + * + * @param code 采退订单号 + * @author liuyang + */ + private PurchaseReturnOrder queryPurchaseReturnOrder(String code) throws Exception { + List headerDetailsDtoList = new ArrayList<>(); + QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); + queryOfsSoSaleOutVo.setCode(code); + queryOfsSoSaleOutVo.setClientCode("LETS"); + queryOfsSoSaleOutVo.setPageNo(1L); + queryOfsSoSaleOutVo.setPageSize(50L); + ofsStandardUtil.queryPurchaseReturnOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L, "ofs.purchaseReturnOrder.search"); + if (headerDetailsDtoList.size() > 0) { + return headerDetailsDtoList.get(0); + } + Assert.state(false, "根据OFS采购订单号:{}无法查询到OFS采购订单信息", code); + return null; + } + + /** + * 2024年8月20日 15:46:10 + * 生成业务日期,以发货时间作为业务日期 + * + * @author liuyang + */ + private String createGenerateBusinessDate(ReturnOrderHeaderDto returnOrderHeaderDto) throws Exception { + if (returnOrderHeaderDto != null && returnOrderHeaderDto.getShipAt() != null) { + String shipAt = returnOrderHeaderDto.getShipAt(); + String businessFormat = null; + try { + Date dbill = DateUtil.parse(shipAt); + businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); + } catch (Exception e) { + logger.error("业务日期生成失败!", e); + } + return businessFormat; + } else { + logger.error("生成采退出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(returnOrderHeaderDto)); + Assert.state(false, "生成采退出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(returnOrderHeaderDto)); + return null; + } + } + + /** + * 2024年8月7日 14:58:34 + * 查询税目档案 + * + * @author liuyang + */ + private BdTaxitemsEntity queryBdTaxitems(String invcode) { + Assert.notNull(invcode, "存货编码不能为空"); + BdTaxitemsEntity bdTaxitemsEntity = TocOrderBasicArchivesCacheUtil.stringBdTaxitemsEntityHashMap.get(invcode); + Assert.notNull(bdTaxitemsEntity, "根据存货编码({}),无法匹配到税率!", invcode); + return bdTaxitemsEntity; + } + + /** + * 2024年8月20日 16:42:14 + * 查找对应的采购订单明细行 + * 2024年8月20日 17:42:15 + * 应该通过明细行主键匹配,但是只能根据sku匹配目前的实现逻辑 + * 查找OFS采购订单明细行,主要是为了带出实付金额,通过实付金额/实收数量=含税单价 + * + * @param ofsPoOrderDataDetails OFS采退订单明细行所有对象 + * @param detailsDto OFS采退入库单明细行对象 + * @author liuyang + */ + private PurchaseReturnOrderDetails findOfsPoOrderDetail(List ofsPoOrderDataDetails, DetailsDto detailsDto) { + if (ofsPoOrderDataDetails != null && ofsPoOrderDataDetails.size() > 0 && detailsDto != null) { + for (int i = 0; i < ofsPoOrderDataDetails.size(); i++) { + Assert.notNull(ofsPoOrderDataDetails.get(i).getId(), "采退订单明细行主键不能为空!"); + + Assert.notNull(detailsDto.getRefOrderDetailId(), "采退出库单明细行对应的关联采退订单的明细行主键不能为空!"); + if (ofsPoOrderDataDetails.get(i).getId().equals(detailsDto.getRefOrderDetailId())) { + return ofsPoOrderDataDetails.get(0); + } + } + } else { + logger.error("findOfsPoOrderDetail方法对应的ofsPoOrderDataDetails不能为空!否则业务目标无法完成!"); + } + Assert.state(false, "无法匹配到采退订单明细行,业务逻辑无法完成!"); + return null; + } + + /** + * 查询委外订单表头对象 + * + * @param ofsPoOrderId OFS采退订单主键 + * @author liuyang + */ + private ScOrderEntity queryScOrder(String ofsPoOrderId) { + Assert.notNull(ofsPoOrderId, "OFS采退订单主键不能为空!"); + Assert.state(!"".equals(ofsPoOrderId.trim()), "OFS采退订单主键不能为空!"); + + ScOrderEntity scOrderEntity = new ScOrderEntity(); + scOrderEntity.setVdef17(ProfilesActiveConstant.sourceSystem1); + scOrderEntity.setVdef20(ofsPoOrderId); + scOrderEntity.setDr("0"); + scOrderEntity.setDataSourceCode("lets_u8c"); + List scOrderEntityList = iScOrderDao.query(scOrderEntity); + if (scOrderEntityList == null || scOrderEntityList.size() == 0) { + Assert.state(false, "根据O采购订单主键:{}(u委外订单自定义项20存储O采购订单主键),无法匹配到U8C委外订单", ofsPoOrderId); + } else if (scOrderEntityList.size() >= 2) { + Assert.state(false, "根据O采购订单主键:{}(u委外订单自定义项20存储O采购订单主键),匹配到{}个U8C委外订单", ofsPoOrderId, scOrderEntityList.size()); + } + return scOrderEntityList.get(0); + } + + /** + * 2024年8月25日 14:11:31 查询U8C委外订单明细 + * + * @param corderid 委外订单表头主键 + * @author liuyang + */ + private List queryScOrderDetail(String corderid) throws Exception { + Assert.notNull(corderid, "委外订单表头主键不能为空!"); + Assert.state(!"".equals(corderid), "委外订单表头主键不能为空!"); + + ScOrderBEntity scOrderBEntity = new ScOrderBEntity(); + scOrderBEntity.setCorderid(corderid); + scOrderBEntity.setDr("0"); + scOrderBEntity.setDataSourceCode("lets_u8c"); + List scOrderBEntityList = iScOrderBDao.query(scOrderBEntity); + if (scOrderBEntityList == null || scOrderBEntityList.size() == 0) { + //2024年8月25日 14:16:31 这个验证非常要必要,单据如果没有表体没有行,是很可疑的 + Assert.state(false, "根据U8C委外订单主键({})无法查询到委外订单表体明细行!", corderid); + } + return scOrderBEntityList; + } + + /** + * 2024年8月6日 10:59:03 查询U8C业务流程 + * + * @author liuyang + */ + private BdBusitypeEntity u8cOperationFlow() throws Exception { +// Assert.notNull(pkCorp, "公司主键不能为空!"); +// Assert.state(!"".equals(pkCorp.trim()), "公司主键不能为空!"); + //查询业务流程 + //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 + String processName = "委外加工"; + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); + Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); + return bdBusitypeEntity; + } + + /** + * 匹配U8C采购订单明细行 + * 通过O采退出库单明细行,匹配到O采退订单明细行,再匹配到O采购订单明细行,最后匹配到U8C采购订单明细行 + * + * @param detailsDto OFS采退出库单明细行 + * @param purchaseReturnOrder O采退订单 + * @param ofsPoOrderData O采购订单 + * @param scOrderBEntityList U8C委外订单明细行 + * @author liuyang + */ + private ScOrderBEntity findOfsPoOrderDetailAndU8cPoOrderDetail(DetailsDto detailsDto, PurchaseReturnOrder purchaseReturnOrder, OfsPoOrderData ofsPoOrderData, List scOrderBEntityList) throws Exception { + Assert.notNull(detailsDto, "detailsDto不能为空!"); + Assert.notNull(purchaseReturnOrder, "purchaseReturnOrder不能为空!"); + Assert.notNull(ofsPoOrderData, "ofsPoOrderData不能为空!"); + Assert.notNull(scOrderBEntityList, "scOrderBEntityList删除不能为空!"); + + //通过O采退出库单明细行,匹配到O采退订单明细行 + PurchaseReturnOrderDetails targetPurchaseReturnOrderDetails = null; + List details = purchaseReturnOrder.getDetails(); + for (int i = 0; i < details.size(); i++) { + PurchaseReturnOrderDetails purchaseReturnOrderDetails = details.get(i); + if (detailsDto.getRefOrderDetailId().equals(purchaseReturnOrderDetails.getId())) { + targetPurchaseReturnOrderDetails = purchaseReturnOrderDetails; + } + } + Assert.notNull(targetPurchaseReturnOrderDetails, "通过O采退出库单明细行关联主键,无法匹配到O采退订单明细行!", detailsDto.getRefOrderDetailId()); + + //通过O采退订单明细行,再匹配到O采购订单明细行 + OfsPoOrderDetails targetOfsPoOrderDetails = null; + List details1 = ofsPoOrderData.getDetails(); + for (int i = 0; i < details1.size(); i++) { + OfsPoOrderDetails ofsPoOrderDetails = details1.get(i); + if (ofsPoOrderDetails.getId().equals(targetPurchaseReturnOrderDetails.getSourceLineNum())) { + targetOfsPoOrderDetails = ofsPoOrderDetails; + } + } + Assert.notNull(targetOfsPoOrderDetails, "通过O采退订单明细行的sourceLineNum,无法匹配采退订单明细的id,匹配失败!", targetPurchaseReturnOrderDetails.getSourceLineNum()); + + //通过O采购订单明细行,匹配到U8C委外订单明细行 + for (int i = 0; i < scOrderBEntityList.size(); i++) { + ScOrderBEntity scOrderBEntity = scOrderBEntityList.get(i); + if (targetOfsPoOrderDetails.getId().equals(scOrderBEntity.getVdef20())) { + return scOrderBEntity; + } + } + Assert.state(false, "通过O采购订单明细行:{},无法匹配到U8C委外订单明细行!", targetOfsPoOrderDetails.getId()); + return null; + } + + /** + * 根据采退订单,关联查询到OFS采购订单 + * + * @author liuyang + */ + private OfsPoOrderData queryOfsPoOrder(PurchaseReturnOrder purchaseReturnOrder) throws Exception { + Assert.notNull(purchaseReturnOrder, "purchaseReturnOrder不能为空"); + PurchaseReturnOrderHeader header = purchaseReturnOrder.getHeader(); + List details = purchaseReturnOrder.getDetails(); + + String refOrderCode = header.getRefOrderCode(); + OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(refOrderCode); + Assert.notNull(ofsPoOrderData, "根据编码:{}无法查询到OFS采购订单", refOrderCode); + OfsPoOrderHeader header1 = ofsPoOrderData.getHeader(); + List details1 = ofsPoOrderData.getDetails(); + if (header1 == null) { + Assert.state(false, "根据编码:{}查询到的OFS采购订单,没有表头对象", refOrderCode); + } + if (details1 == null) { + Assert.state(false, "根据编码:{}查询到的OFS采购订单,没有明细对象", refOrderCode); + } + return ofsPoOrderData; + } + + /** + * 2024年8月30日 14:09:26 + * 推送U8C入库单 + * + * @param param 原数据json + * @author liuyang + */ + public IcGeneralHResultDto sendU8cConsignmachiningIn(String param) throws Exception { + long startLong = System.currentTimeMillis(); + logger.info("U8C委外入库推送开始,推送参数:" + param + ",U8C_URL:" + ProfilesActiveConstant.U8C_URL); + String result = HttpRequest.post(ProfilesActiveConstant.U8C_URL).header("appId", "800037")//头信息,多个头信息多次调用此方法即可 + .header("usercode", "admin").header("password", "21232f297a57a5a743894a0e4a801fc3").header("system", "lz").header("trantype", "PK").header("apiCode", "8000370056")//头信息,多个头信息多次调用此方法即可 + .header("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可 + .header("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可 + .body(param)//表单内容 + .timeout(20000)//超时,毫秒 + .execute().body(); + logger.info("U8C委外入库推送结束,返回参数:" + result); + long endLong = System.currentTimeMillis(); + logger.info("U8C委外入库推送耗时:" + (endLong - startLong)); + + if (result == null) { + result = ""; + } + + JSONObject jsonObject = JSON.parseObject(result); + result = String.valueOf(jsonObject.get("attribute")); + + boolean isSuccess = false; + IcGeneralHResultDto icGeneralHResultDto = null; + if (result != null && !"".equals(result)) { + ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class); + if ("success".equals(reusltStrDto.getStatus())) { + icGeneralHResultDto = resultDataHandle(reusltStrDto.getData()); + isSuccess = true; + } + } + if (!isSuccess) { + Assert.state(false, "O采购入库业务推送U8C委外入库失败 接口返回结果:{}", result); + } + return icGeneralHResultDto; + } + + /** + * 匹配U8C采购订单明细行 + * 通过O采购入库单明细行,得到采购订单明细行,最后查找到U8C采购订单明细行 + * + * @param detailsDto OFS采退出库单明细行 + * @param purchaseReturnOrder OFS采退订单 + * @author liuyang + */ + private PurchaseReturnOrderDetails findOfsPoOrderDetailRowTraget(DetailsDto detailsDto, PurchaseReturnOrder purchaseReturnOrder) { + Assert.notNull(detailsDto, "detailsDto不能为空"); + Assert.notNull(purchaseReturnOrder, "purchaseReturnOrder不能为空"); + + List details = purchaseReturnOrder.getDetails(); + for (int i = 0; i < details.size(); i++) { + PurchaseReturnOrderDetails purchaseReturnOrderDetails = details.get(i); + if (purchaseReturnOrderDetails.getId().equals(detailsDto.getRefOrderDetailId())) { + return purchaseReturnOrderDetails; + } + } + Assert.state(false, "通过OFS采退出库单,无法匹配到OFS采退订单明细行! 目标主键:{}", detailsDto.getRefOrderDetailId()); + return null; + } +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseReturn.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseReturn.java index 56bd3f96..eeb7a1c5 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseReturn.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseReturn.java @@ -560,7 +560,7 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { //查询业务流程 //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 String processName = "代理品牌采购"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName, null); + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); return bdBusitypeEntity; } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehous.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehous.java index d0c41eb3..3ca19558 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehous.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehous.java @@ -551,7 +551,7 @@ public class ProxyPurchaseWarehous extends PluginBaseEntity { //查询业务流程 //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 String processName = "代理品牌采购"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName, null); + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); return bdBusitypeEntity; } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java index 20853d5f..6935a805 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java @@ -155,6 +155,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { * @author liuyang */ public void startImplementByStockTime(String startTime, String endTime) { + long startMillis = System.currentTimeMillis(); String threadNameStr = StrUtil.format("OFS销售出库(TOB)同步U8C销售订单开始 同步日期:{} 汇总维度:{}", startTime, endTime); logger.info(threadNameStr); @@ -198,7 +199,8 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { } catch (Exception e) { logger.error("thread.join()异常", e); } - String threadNameEnd = StrUtil.format("OFS销售出库(TOB)同步U8C销售订单结束 同步日期:{} 汇总维度:{}", startTime, endTime); + long endMillis = System.currentTimeMillis(); + String threadNameEnd = StrUtil.format("OFS销售出库(TOB)同步U8C销售订单结束 同步日期:{} 汇总维度:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); logger.info(threadNameEnd); } @@ -208,7 +210,8 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { * @author liuyang */ public void startImplementByTranTime(String startTime, String endTime) { - String threadNameStrStart = StrUtil.format("OFS销售出库(TOB交易成功)同步U8C销售发票 开始 开始时间:{} 结束时间:{}", startTime, endTime); + long startMillis = System.currentTimeMillis(); + String threadNameStrStart = StrUtil.format("OFS销售出库(TOB交易成功)同步U8C销售发票开始 开始时间:{} 结束时间:{}", startTime, endTime); logger.info(threadNameStrStart); Thread thread = new Thread(new Runnable() { @@ -252,7 +255,8 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { } catch (Exception e) { logger.error("thread.join()异常", e); } - String threadNameStrEnd = StrUtil.format("OFS销售出库(TOB交易成功)同步U8C销售发票 结束 开始时间:{} 结束时间:{}", startTime, endTime); + long endMillis = System.currentTimeMillis(); + String threadNameStrEnd = StrUtil.format("OFS销售出库(TOB交易成功)同步U8C销售发票结束 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); logger.info(threadNameStrEnd); } @@ -262,7 +266,8 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { * @author liuyang */ public void startImplementByCode(String code) { - String threadNameStrStart = StrUtil.format("OFS销售出库(TOB)同步U8C销售订单 出库单单号:{}", code); + long startMillis = System.currentTimeMillis(); + String threadNameStrStart = StrUtil.format("OFS销售出库(TOB)同步U8C销售订单开始 出库单单号:{}", code); logger.info(threadNameStrStart); Thread thread = new Thread(new Runnable() { @@ -276,6 +281,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); queryOfsSoSaleOutVo.setClientCode("LETS"); queryOfsSoSaleOutVo.setInternalInstructionType("SALES"); + //2024年8月30日 10:41:55 如果按编码查询,是否应该考虑仅查询已发货的数据? queryOfsSoSaleOutVo.setStatus(900L); queryOfsSoSaleOutVo.setPageNo(1L); queryOfsSoSaleOutVo.setPageSize(50L); @@ -299,7 +305,8 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { } catch (Exception e) { logger.error("thread.join()异常", e); } - String threadNameStrEnd = StrUtil.format("OFS销售出库(TOB)同步U8C销售订单 出库单单号:{}", code); + long endMillis = System.currentTimeMillis(); + String threadNameStrEnd = StrUtil.format("OFS销售出库(TOB)同步U8C销售订单结束 出库单单号:{} 耗时:{}", code, (endMillis - startMillis)); logger.info(threadNameStrEnd); } @@ -567,6 +574,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { // saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 + //TODO 2024年8月30日 10:52:55 抛出异常pk_defxxx长度不够的问题,已经提交给总部 // saleorderRequestChildrenDto.setVdef19(header.getCode());//原单单号 saleorderRequestChildrenDto.setVdef20(detailsDto.getId());//原单明细主键 saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); @@ -599,7 +607,6 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { * @author liuyang */ private String createGenerateBusinessDate(OrderOutTobHeaderDto orderOutTobHeaderDto) { - orderOutTobHeaderDto.getHeader().setShipAt("2024-08-22"); if (orderOutTobHeaderDto != null && orderOutTobHeaderDto.getHeader() != null && orderOutTobHeaderDto.getHeader().getShipAt() != null) { HeaderDto header = orderOutTobHeaderDto.getHeader(); String shipAt = header.getShipAt(); @@ -609,7 +616,9 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); } catch (Exception e) { logger.error("业务日期生成失败", e); + Assert.state(false, "业务日期生成失败,抛出异常:" + e.getMessage()); } + logger.info("TOB库存同步业务,生成的业务日期:{}", businessFormat); return businessFormat; } else { logger.error("生成出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(orderOutTobHeaderDto)); @@ -634,7 +643,9 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); } catch (Exception e) { logger.error("tradeSuccessAt业务日期生成失败", e); + Assert.state(false, "业务日期生成失败,抛出异常:" + e.getMessage()); } + logger.info("TOB销售发票业务,生成的的业务日期为:{}", businessFormat); return businessFormat; } else { logger.error("生成发票业务日期失败,或者tradeSuccessAt为空! json:{}", JSON.toJSON(orderOutTobHeaderDto)); @@ -649,8 +660,10 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { * @author liuyang */ private List queryBasicArchives(List headerDetailsDtoList) { + if (headerDetailsDtoList != null) { + logger.info("库存同步:需要把OFS档案转换为U8C档案的O数据条数:{}", headerDetailsDtoList.size()); + } List orderOutTobHeaderDtoArrayList = new ArrayList<>(); - if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { try { for (int i = 0; i < headerDetailsDtoList.size(); i++) { @@ -882,7 +895,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { //查询业务流程 //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 String processName = "TOB销售"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName, null); + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); return bdBusitypeEntity; } @@ -1309,10 +1322,10 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { BeanUtil.copyPropertiesV2(header, orderOutTobHeaderDto); orderOutTobHeaderDtoArrayList.add(orderOutTobHeaderDto); } - //成功 + //成功,记录到日志表 } catch (Exception e) { logger.error("OFS销售出库单关联查询U8C档案失败", e); - //失败 + //失败,记录到日子表 } } else { logger.info("queryBasicArchives方法对应的headerDetailsDtoList.size为0"); @@ -1330,11 +1343,11 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { logger.info("TOB销售业务交易成功同步:{}行需要进行数据转换", headerDetailsDtoList.size()); } if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { - //查询基本档案 + //转换基本档案 List orderOutTobHeaderDtos = queryBasicArchivesSaleinvoice(headerDetailsDtoList); //查询U8C业务流程 BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); - // 查询销售收发类别 + //查询销售收发类别 BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("201"); logger.info("TOB销售业务交易成功同步,档案转换成功对应的数量:{}行需要进行数据转换", orderOutTobHeaderDtos.size()); @@ -1378,6 +1391,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { //U8C销售订单执行情况明细表 List extIntegrationTaskLivingDetailsQueryVos = orderOutTobHeaderDto.getExtIntegrationTaskLivingDetailsQueryVos(); + //销售发票表头 SalesInvoiceHeadDto salesInvoiceHeadDto = new SalesInvoiceHeadDto(); salesInvoiceHeadDto.setCbiztype(bdBusitypeEntity.getPkBusitype()); salesInvoiceHeadDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody()); @@ -1393,7 +1407,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { salesInvoiceHeadDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位 salesInvoiceHeadDto.setCreceipttype("32");//单据类型 salesInvoiceHeadDto.setDmakedate(successfulTradeDate);//制单日期 - salesInvoiceHeadDto.setNdiscountrate("100"); + salesInvoiceHeadDto.setNdiscountrate("100");//整单折扣 salesInvoiceHeadDto.setDapprovedate(successfulTradeDate);//审批日期 salesInvoiceHeadDto.setVdef17(ProfilesActiveConstant.sourceSystem1); salesInvoiceHeadDto.setVdef19(header.getCode()); @@ -1424,6 +1438,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { noriginalcurtaxprice = new BigDecimal(detailsDto.getTotalPayAmount()).divide(new BigDecimal(detailsDto.getShipQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); } catch (Exception e) { logger.error("含税单价金额计算失败!", e); + Assert.state(false, "含税单价金额计算失败 原因:{}", e.getMessage()); } Boolean isblargessflag = false; diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java index ea514b8b..f55292a3 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java @@ -767,7 +767,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //查询业务流程 //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 String processName = "TOC销售"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName, null); + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); return bdBusitypeEntity; } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java index 2e2ffaea..86c09932 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java @@ -17,6 +17,7 @@ import com.hzya.frame.plugin.lets.ofs.dao.ITocofsReturngoodsDetailedDao; import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsEntity; import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; +import com.hzya.frame.plugin.lets.queryvo.ExtIntegrationTaskLivingDetailsQueryVo; import com.hzya.frame.plugin.lets.queryvo.StartAndEndVo; import com.hzya.frame.plugin.lets.resultvo.CalculateDateVo; import com.hzya.frame.plugin.lets.u8cdto.*; @@ -137,6 +138,12 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { @Autowired private OffsetTimeTime offsetTimeTime; + @Autowired + private IIcGeneralHDao iIcGeneralHDao; + + @Autowired + private IIcGeneralBDao iIcGeneralBDao; + @Autowired private OfsStandardUtil ofsStandardUtil; @@ -146,12 +153,16 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { @Autowired private ISoSaleDao iSoSaleDao; + @Autowired + private ISoSaleorderBDao iSoSaleorderBDao; + /** * 库存同步,按指定时间拉取 * * @author liuyang */ public void startImplementByStockTime(String startTime, String endTime) { + long startMillis = System.currentTimeMillis(); String threadNameStrStart = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{}", startTime, endTime); logger.info(threadNameStrStart); @@ -192,7 +203,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { } catch (Exception e) { logger.error("thread.join()异常", e); } - String threadNameStrEnd = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{}", startTime, endTime); + long endMillis = System.currentTimeMillis(); + String threadNameStrEnd = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); logger.info(threadNameStrEnd); } @@ -201,7 +213,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { * * @author liuyang */ - public void startImplement(String code) { + public void startImplementByCode(String code) { + long startMillis = System.currentTimeMillis(); String threadNameStrStart = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 售后入库单号:{}", code); logger.info(threadNameStrStart); @@ -242,7 +255,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { } catch (Exception e) { logger.error("thread.join()异常", e); } - String threadNameStrEnd = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 售后入库单号:{}", code); + long endMillis = System.currentTimeMillis(); + String threadNameStrEnd = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 售后入库单号:{} 耗时:{}", code, (endMillis - startMillis)); logger.info(threadNameStrEnd); } @@ -478,6 +492,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 + saleorderRequestChildrenDto.setVdef20(stockinB.getId());//原单明细主键 saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); } //记录成功 @@ -730,7 +745,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); List details = stockinOrder.getDetails(); - //查询售后订单 + //查询OFS售后订单 SaleOrderMessageDto saleOrderMessageDto = null; try { saleOrderMessageDto = afterSalesOrderUtil.queryAfterSalesOrder(header); @@ -747,6 +762,63 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); + //2024年8月30日 10:57:29 查询对应的U8C销售订单,注意要把编码和主键一起查询,O主键导入到U8C中,对于U8C来说可能会重复 + SoSaleEntity soSaleEntity = new SoSaleEntity(); + soSaleEntity.setDr(0L); + soSaleEntity.setDataSourceCode("lets_u8c"); + soSaleEntity.setVdef19(header.getCode()); + soSaleEntity.setVdef20(header.getId()); + List soSaleEntityList = iSoSaleDao.query(soSaleEntity); + if (soSaleEntityList == null || soSaleEntityList.size() == 0) { + Assert.state(false, "根据O售后入库单主键:{} 单号:{} 无法匹配到U8C销售订单(传到U8C可能失败了!)", header.getId(), header.getCode()); + } + //TODO 测试 +// else if (soSaleEntityList.size() >= 2) { +// Assert.state(false, "根据O出库单主键:{} 单号:{} 匹配到{}个U8C销售订单", header.getId(), header.getCode(), soSaleEntityList.size()); +// } + + //查询销售订单明细行表体 + SoSaleorderBEntity soSaleorderBEntity = new SoSaleorderBEntity(); + soSaleorderBEntity.setDr(0L); + soSaleorderBEntity.setCsaleid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + soSaleorderBEntity.setDataSourceCode("lets_u8c"); + List soSaleorderBEntityList = iSoSaleorderBDao.query(soSaleorderBEntity); + if (soSaleorderBEntityList == null || soSaleorderBEntityList.size() == 0) { + Assert.state(false, "根据O销售订单主键:{},无法匹配到U8C销售订单明细行(传到U8C可能失败了!)", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + } else if (soSaleorderBEntityList.size() >= 2) { + Assert.state(false, "根据O销售订单主键:{},无法匹配到U8C销售订单明细行(传到U8C可能失败了!)", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + } + + //查询U8C销售订单对应的销售出库单表头 + IcGeneralHEntity icGeneralHEntity = new IcGeneralHEntity(); + icGeneralHEntity.setCsourcebillhid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + icGeneralHEntity.setDr(0); + icGeneralHEntity.setDataSourceCode("lets_u8c"); + List icGeneralHEntityList = iIcGeneralHDao.query(icGeneralHEntity); + if (icGeneralHEntityList == null || icGeneralHEntityList.size() == 0) { + Assert.state(false, "根据U8C销售订单表头id:{},无法查询到销售出库单", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + } else if (icGeneralHEntityList.size() >= 2) { + Assert.state(false, "根据U8C销售订单表头id:{},查询到{}个销售出库单", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid(), icGeneralHEntityList.size()); + } + + //查询U8C销售订单对应的销售出库单表体 + IcGeneralBEntity icGeneralBEntity = new IcGeneralBEntity(); + icGeneralBEntity.setCsourcebillhid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + icGeneralBEntity.setDr(0); + icGeneralBEntity.setDataSourceCode("lets_u8c"); + List icGeneralBEntityList = iIcGeneralBDao.query(icGeneralBEntity); + if (icGeneralBEntityList == null || icGeneralBEntityList.size() == 0) { + Assert.state(false, "根据U8C销售订单表头id:{},无法查询到销售出库单明细行", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + } + + //2024年8月30日 11:09:32 查询U8C销售订单执行情况明细表,主要是带出U8C销售订单表体的自定义项 + SoSaleorderBEntity soSaleorderBEntity1 = new SoSaleorderBEntity(); + soSaleorderBEntity1.setCsaleid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + List extIntegrationTaskLivingDetailsQueryVos = iSoSaleorderBDao.queryErrorDetailsId(soSaleorderBEntity1); + if (extIntegrationTaskLivingDetailsQueryVos == null || extIntegrationTaskLivingDetailsQueryVos.size() == 0) { + Assert.state(false, "根据销售订单主键:{},无法匹配到销售订单执行情况明细"); + } + // 销售公司、发货公司 String companyCode = header.getCompanyCode(); Assert.notNull(companyCode, "O表头公司不能为空"); @@ -871,17 +943,17 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { } //2024年8月28日 11:01:07 查询对应的U8C销售订单 - SoSaleEntity soSaleEntity = new SoSaleEntity(); - soSaleEntity.setDr(0L); - soSaleEntity.setDataSourceCode("lets_u8c"); - soSaleEntity.setVdef19(header.getCode()); - soSaleEntity.setVdef20(header.getId()); - List soSaleEntityList = iSoSaleDao.query(soSaleEntity); - if (soSaleEntityList == null || soSaleEntityList.size() == 0) { - Assert.state(false, "根据O出库单主键:{} 单号:{} 无法匹配到U8C销售订单(传到U8C可能失败了!)", header.getId(), header.getCode()); - } else if (soSaleEntityList.size() >= 2) { - Assert.state(false, "根据O出库单主键:{} 单号:{} 匹配到{}个U8C销售订单", header.getId(), header.getCode(), soSaleEntityList.size()); - } +// SoSaleEntity soSaleEntity = new SoSaleEntity(); +// soSaleEntity.setDr(0L); +// soSaleEntity.setDataSourceCode("lets_u8c"); +// soSaleEntity.setVdef19(header.getCode()); +// soSaleEntity.setVdef20(header.getId()); +// List soSaleEntityList = iSoSaleDao.query(soSaleEntity); +// if (soSaleEntityList == null || soSaleEntityList.size() == 0) { +// Assert.state(false, "根据O出库单主键:{} 单号:{} 无法匹配到U8C销售订单(传到U8C可能失败了!)", header.getId(), header.getCode()); +// } else if (soSaleEntityList.size() >= 2) { +// Assert.state(false, "根据O出库单主键:{} 单号:{} 匹配到{}个U8C销售订单", header.getId(), header.getCode(), soSaleEntityList.size()); +// } OrderToBHeaderDto orderOutTobHeaderDto = new OrderToBHeaderDto(); orderOutTobHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); @@ -896,16 +968,21 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0)); orderOutTobHeaderDto.setSaleOrderMessageDto(saleOrderMessageDto); orderOutTobHeaderDto.setSoSaleEntity(soSaleEntityList.get(0)); + orderOutTobHeaderDto.setIcGeneralHEntity(icGeneralHEntityList.get(0)); + orderOutTobHeaderDto.setIcGeneralBEntityList(icGeneralBEntityList); + orderOutTobHeaderDto.setSoSaleorderBEntityList(soSaleorderBEntityList); + orderOutTobHeaderDto.setExtIntegrationTaskLivingDetailsQueryVos(extIntegrationTaskLivingDetailsQueryVos); orderOutTobHeaderDto.setHeader(header); orderOutTobHeaderDto.setDetails(details); + BeanUtil.copyPropertiesV2(header, orderOutTobHeaderDto); orderToBHeaderDtoArrayList.add(orderOutTobHeaderDto); } - //成功 + //成功,记录到日志表 } catch (Exception e) { logger.error("OFS销售出库单关联查询U8C档案失败", e); - //失败 + //失败,记录到日志表 } } else { logger.info("queryBasicArchives方法对应的returnGoodHeaderDetailsDataDtoList.size为0"); @@ -968,7 +1045,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { //查询业务流程 //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 String processName = "TOB销售"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName, null); + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); return bdBusitypeEntity; } @@ -1098,6 +1175,27 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { return null; } + /** + * 返回结果解析处理,在确认了success后调用 + * + * @author liuyang + */ + private SaleinvoiceDto resultDataHandleV2(String resultData) { + try { + if (resultData != null && !"".equals(resultData)) { + if (resultData.contains("[")) { + resultData = resultData.substring(1, resultData.length() - 1); + } + return JSON.parseObject(resultData, SaleinvoiceDto.class); + } + } catch (Exception e) { +// e.printStackTrace(); + logger.error("解析返回参数失败的错误", e); + //如果解析失败,记录原因,但是不能影响结果的记录 + } + return null; + } + /** * 填充主表主键、业务日期、业务类型 * 2024年8月15日 17:31:54 @@ -1122,13 +1220,15 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { } if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { try { - // 查询基本档案 + //转换基本档案 List orderToBHeaderDtos = queryBasicArchivesTran(returnGoodHeaderDetailsDataDtoList); - // 查询U8C业务流程 + //查询U8C业务流程 BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); - // 查询销售收发类别 + //查询销售收发类别 BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("201"); + logger.info("TOB销售业务退货到账成功同步,档案转换成功对应的数量:{}行需要进行数据转换", orderToBHeaderDtos.size()); + logger.info("TOB销售发票业务流程编码:{}", bdBusitypeEntity.getBusicode()); for (int i = 0; i < orderToBHeaderDtos.size(); i++) { OrderToBHeaderDto orderOutTobHeaderDto = orderToBHeaderDtos.get(i); StockinOrderSearchResponse.StockinOrder.StockinH header = orderOutTobHeaderDto.getHeader(); @@ -1138,7 +1238,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { BdCorpEntity bdCorpEntity = orderOutTobHeaderDto.getBdCorpEntity(); //发货库存组织 BdCalbodyEntity bdCalbodyEntity = orderOutTobHeaderDto.getBdCalbodyEntity(); - //入库参数 + //入库仓库 BdStordocEntity bdStordocEntity = orderOutTobHeaderDto.getBdStordocEntity(); //销售组织 BdSalestruEntity bdSalestruEntity = orderOutTobHeaderDto.getBdSalestruEntity(); @@ -1158,9 +1258,18 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { BdDefdocEntity shopArchives = orderOutTobHeaderDto.getShopArchives(); //U8C销售订单 SoSaleEntity soSaleEntity = orderOutTobHeaderDto.getSoSaleEntity(); - //OFS售后订单 + //U8C销售订单明细行 + List soSaleorderBEntityList = orderOutTobHeaderDto.getSoSaleorderBEntityList(); + //U8C销售出库单 + IcGeneralHEntity icGeneralHEntity = orderOutTobHeaderDto.getIcGeneralHEntity(); + //U8C销售出库单明细行 + List icGeneralBEntityList = orderOutTobHeaderDto.getIcGeneralBEntityList(); + //U8C销售订单执行情况明细表 + List extIntegrationTaskLivingDetailsQueryVos = orderOutTobHeaderDto.getExtIntegrationTaskLivingDetailsQueryVos(); + //售后订单 SaleOrderMessageDto saleOrderMessageDto = orderOutTobHeaderDto.getSaleOrderMessageDto(); + //红字销售发票表头 SalesInvoiceHeadDto salesInvoiceHeadDto = new SalesInvoiceHeadDto(); salesInvoiceHeadDto.setCbiztype(bdBusitypeEntity.getPkBusitype()); salesInvoiceHeadDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody()); @@ -1170,9 +1279,23 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { salesInvoiceHeadDto.setPk_corp(bdCorpEntity.getPkCorp()); salesInvoiceHeadDto.setDbilldate(successfulTradeDate); salesInvoiceHeadDto.setFinvoicetype("1");//不传默认为1 + salesInvoiceHeadDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门 + salesInvoiceHeadDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库 + salesInvoiceHeadDto.setCdispatcherid(bdRdclEntity.getPkRdcl());//收发类别 + salesInvoiceHeadDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位 + salesInvoiceHeadDto.setCreceipttype("32");//单据类型 + salesInvoiceHeadDto.setDmakedate(successfulTradeDate);//制单日期 + salesInvoiceHeadDto.setNdiscountrate("100");//整单折扣 + salesInvoiceHeadDto.setDapprovedate(successfulTradeDate);//审批日期 salesInvoiceHeadDto.setVdef17(ProfilesActiveConstant.sourceSystem1); salesInvoiceHeadDto.setVdef19(header.getCode()); salesInvoiceHeadDto.setVdef20(header.getId()); + //平台 + salesInvoiceHeadDto.setPk_defdoc2(platformArchives.getPkDefdoc()); + salesInvoiceHeadDto.setVdef2(platformArchives.getDocname()); + //店铺 + salesInvoiceHeadDto.setPk_defdoc1(shopArchives.getPkDefdoc()); + salesInvoiceHeadDto.setVdef1(shopArchives.getDocname()); List salesInvoiceBodyDtoList = new ArrayList<>(); for (int j = 0; j < details.size(); j++) { @@ -1183,14 +1306,19 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { BdInvbasdocEntity bdInvbasdocEntity = queryStockBasicArchives(bdInvmandocEntity.getPkInvmandoc(), deliverGoodsCorp.getPkCorp()); //根据存货基础档案编码,查询当前存货的税率 BdTaxitemsEntity bdTaxitemsEntity1 = queryBdTaxitems(bdInvbasdocEntity.getInvcode()); - //对应的售后入库单,主要是取这个价格 + //2024年8月30日 11:20:08 查找对应的售后订单的明细行,主要取价格 DetailsDto afterSalesOrder = findAfterSalesOrder(stockinB, saleOrderMessageDto); + //查找来源单据,销售发票的来源单据为销售出库单 + IcGeneralBEntity sourceDocuments = findSourceDocuments(header, stockinB, soSaleorderBEntityList, icGeneralBEntityList, extIntegrationTaskLivingDetailsQueryVos); + //查找来源销售订单明细行 + SoSaleorderBEntity sourceDocumentsV2 = findSourceDocumentsV2(header, stockinB, soSaleorderBEntityList, extIntegrationTaskLivingDetailsQueryVos); BigDecimal noriginalcurtaxprice = null;//含税单价 try { noriginalcurtaxprice = new BigDecimal(afterSalesOrder.getTotalAmount()).divide(new BigDecimal(stockinB.getReceivedQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); } catch (Exception e) { logger.error("含税单价金额计算失败!", e); + Assert.state(false, "含税单价金额计算失败 原因:{}", e.getMessage()); } Boolean isblargessflag = false; @@ -1206,6 +1334,12 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { salesInvoiceBodyDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 salesInvoiceBodyDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 salesInvoiceBodyDto.setBlargessflag(isblargessflag); + salesInvoiceBodyDto.setCoriginalbillcode(soSaleEntity.getVreceiptcode());//源头单据号 + salesInvoiceBodyDto.setCsourcebillbodyid(sourceDocumentsV2.getCorderBid());//源头单据明细行主键 (数据字典上是来源单据明细行主键,实际上是源头) + salesInvoiceBodyDto.setCsourcebillid(soSaleEntity.getCsaleid());//源头单据主表主键(数据字典上是来源单据主表主键,实际上是源头) + salesInvoiceBodyDto.setCupsourcebillbodyid(sourceDocuments.getCgeneralbid());//上层来源明细行主键 + salesInvoiceBodyDto.setCupsourcebillcode(icGeneralHEntity.getVbillcode());//直接来源单据号 + salesInvoiceBodyDto.setCupsourcebillid(icGeneralHEntity.getCgeneralhid());//来源主表主键 salesInvoiceBodyDtoList.add(salesInvoiceBodyDto); } SalesInvoiceDto salesInvoiceDto = new SalesInvoiceDto(); @@ -1219,8 +1353,13 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { stringListMap.put("billvos", salesInvoiceDtoList); //推送到U8C生成销售发票 - SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap)); + SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap)); //成功 + if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) { + SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo(); + List childrenvo = saleinvoiceDto.getChildrenvo(); + logger.info("TOB销售发票(红字)生成成功 编码:{} 发票公司:{}", parentvo.getVreceiptcode(), parentvo.getPk_corp()); + } } } catch (Exception e) { logger.error("TOB外层转换逻辑抛出异常", e); @@ -1255,12 +1394,12 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { } /** - * 2024年8月28日 11:57:58 + * 2024年8月30日 11:29:24 * 推送U8C销售发票 * * @author liuyang */ - public SoSaleResultRootDto sendU8CTOCSoSaleinvoiceB(String param) throws Exception { + public SaleinvoiceDto sendU8CTOCSoSaleinvoiceB(String param) throws Exception { long startLong = System.currentTimeMillis(); logger.info("TOB销售发票推送开始,推送参数:" + param + ",U8C_URL:" + ProfilesActiveConstant.U8C_URL); String result = HttpRequest.post(ProfilesActiveConstant.U8C_URL).header("appId", "800037")//头信息,多个头信息多次调用此方法即可 @@ -1270,7 +1409,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { .body(param)//表单内容 .timeout(20000)//超时,毫秒 .execute().body(); - logger.info("TOB销售发票结束,返回参数:" + result); + //2024年8月29日 17:56:50 如果http请求超时,则会抛给上层方法,上层方法会完成异常的捕捉 + logger.info("TOB销售发票推送结束,返回参数:" + result); long endLong = System.currentTimeMillis(); logger.info("TOB销售发票接口请求耗时:" + (endLong - startLong)); @@ -1278,11 +1418,11 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { result = String.valueOf(jsonObject.get("attribute")); boolean isSuccess = false; - SoSaleResultRootDto soSaleResultRootDto = null; + SaleinvoiceDto soSaleResultRootDto = null; if (result != null && !"".equals(result)) { ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class); if ("success".equals(reusltStrDto.getStatus())) { - soSaleResultRootDto = resultDataHandle(reusltStrDto.getData()); + soSaleResultRootDto = resultDataHandleV2(reusltStrDto.getData()); isSuccess = true; } } @@ -1323,4 +1463,84 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { Assert.state(false, "通过售后入库单号({})无法匹配到售后订单", stockinB.getId()); return null; } + + /** + * 查找来源单据,销售发票的来源单据为销售出库单,生成TOB销售订单时,明细行传O的明细行主键,查找逻辑 + * O明细行主键 -> 定位到U8C销售订单明细行 -> 销售出库单明细行 + * + * @param header O表头明细行 + * @param stockinB O明细行 + * @param soSaleorderBEntityList U8C销售订单明细集合 + * @param icGeneralBEntityList U8C销售出库单明细集合 + * @param extIntegrationTaskLivingDetailsQueryVos U8C销售订单执行情况明细表 + * @author liuyang + */ + private IcGeneralBEntity findSourceDocuments(StockinOrderSearchResponse.StockinOrder.StockinH header, StockinOrderSearchResponse.StockinOrder.StockinB stockinB, List soSaleorderBEntityList, List icGeneralBEntityList, List extIntegrationTaskLivingDetailsQueryVos) { + Assert.notNull(header, "header不能为空"); + Assert.notNull(stockinB, "detailsDto不能为空"); + Assert.notNull(soSaleorderBEntityList, "soSaleorderBEntityList不能为空"); + Assert.notNull(icGeneralBEntityList, "icGeneralBEntityList不能为空"); + Assert.notNull(extIntegrationTaskLivingDetailsQueryVos, "extIntegrationTaskLivingDetailsQueryVos不能为空"); + + ExtIntegrationTaskLivingDetailsQueryVo targetExtIntegrationTaskLivingDetailsQueryVo = null; + for (int i = 0; i < extIntegrationTaskLivingDetailsQueryVos.size(); i++) { + ExtIntegrationTaskLivingDetailsQueryVo extIntegrationTaskLivingDetailsQueryVo = extIntegrationTaskLivingDetailsQueryVos.get(i); + if (extIntegrationTaskLivingDetailsQueryVo.getVdef20().equals(stockinB.getId())) { + targetExtIntegrationTaskLivingDetailsQueryVo = extIntegrationTaskLivingDetailsQueryVo; + } + } + Assert.notNull(targetExtIntegrationTaskLivingDetailsQueryVo, "无法匹配到销售订单执行情况明细行,O明细行主键", stockinB.getId()); + + SoSaleorderBEntity targetSoSaleorderBEntity = null; + for (int i = 0; i < soSaleorderBEntityList.size(); i++) { + SoSaleorderBEntity soSaleorderBEntity = soSaleorderBEntityList.get(i); + if (targetExtIntegrationTaskLivingDetailsQueryVo.getCsale_bid().equals(soSaleorderBEntity.getCorderBid())) { + targetSoSaleorderBEntity = soSaleorderBEntity; + } + } + Assert.notNull(targetSoSaleorderBEntity, "根据O出库单明细主键:{},无法匹配到U8C销售订单明细行"); + + for (int i = 0; i < icGeneralBEntityList.size(); i++) { + IcGeneralBEntity icGeneralBEntity = icGeneralBEntityList.get(i); + if (icGeneralBEntity.getCsourcebillbid().equals(targetSoSaleorderBEntity.getCorderBid())) { + return icGeneralBEntity; + } + } + Assert.state(false, "根据销售订单明细行主键:{} 无法匹配到销售出库单明细行", targetSoSaleorderBEntity.getCorderBid()); + return null; + } + + /** + * 查找销售订单明细行 + * + * @param header O表头明细行 + * @param stockinB O明细行 + * @param soSaleorderBEntityList U8C销售订单明细集合 + * @author liuyang + */ + private SoSaleorderBEntity findSourceDocumentsV2(StockinOrderSearchResponse.StockinOrder.StockinH header, StockinOrderSearchResponse.StockinOrder.StockinB stockinB, List soSaleorderBEntityList, List extIntegrationTaskLivingDetailsQueryVos) { + Assert.notNull(header, "header不能为空"); + Assert.notNull(stockinB, "stockinB不能为空"); + Assert.notNull(soSaleorderBEntityList, "soSaleorderBEntityList不能为空"); + Assert.notNull(extIntegrationTaskLivingDetailsQueryVos, "extIntegrationTaskLivingDetailsQueryVos不能为空!"); + + ExtIntegrationTaskLivingDetailsQueryVo targetExtIntegrationTaskLivingDetailsQueryVo = null; + for (int i = 0; i < extIntegrationTaskLivingDetailsQueryVos.size(); i++) { + ExtIntegrationTaskLivingDetailsQueryVo extIntegrationTaskLivingDetailsQueryVo = extIntegrationTaskLivingDetailsQueryVos.get(i); + if (extIntegrationTaskLivingDetailsQueryVo.getVdef20().equals(stockinB.getId())) { + targetExtIntegrationTaskLivingDetailsQueryVo = extIntegrationTaskLivingDetailsQueryVo; + } + } + Assert.notNull(targetExtIntegrationTaskLivingDetailsQueryVo, "无法匹配到销售订单执行情况明细行,O明细行主键", stockinB.getId()); + + SoSaleorderBEntity targetSoSaleorderBEntity = null; + for (int i = 0; i < soSaleorderBEntityList.size(); i++) { + SoSaleorderBEntity soSaleorderBEntity = soSaleorderBEntityList.get(i); + if (targetExtIntegrationTaskLivingDetailsQueryVo.getCsale_bid().equals(soSaleorderBEntity.getCorderBid())) { + targetSoSaleorderBEntity = soSaleorderBEntity; + } + } + Assert.notNull(targetSoSaleorderBEntity, "根据O出库单明细主键:{},无法匹配到U8C销售订单明细行"); + return targetSoSaleorderBEntity; + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java index f844774a..27752ab1 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java @@ -766,7 +766,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //查询业务流程 //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 String processName = "TOC销售"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName, null); + BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); return bdBusitypeEntity; } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ConsignmachiningInBodyDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ConsignmachiningInBodyDto.java index a23c1324..f9576749 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ConsignmachiningInBodyDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ConsignmachiningInBodyDto.java @@ -19,4 +19,5 @@ public class ConsignmachiningInBodyDto { private String vsourcerowno; private String vsourcebillcode; private String writeofftype;//核销方式 + private String dbizdate; } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ConsignmachiningInHeadDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ConsignmachiningInHeadDto.java index 35a9cab4..4e14cd47 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ConsignmachiningInHeadDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ConsignmachiningInHeadDto.java @@ -19,4 +19,5 @@ public class ConsignmachiningInHeadDto { private String cbiztype; private String cdispatcherid; private String dbilldate; + private Boolean freplenishflag; } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/OrderToBHeaderDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/OrderToBHeaderDto.java index bbd92c63..7718920a 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/OrderToBHeaderDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/OrderToBHeaderDto.java @@ -1,6 +1,7 @@ package com.hzya.frame.plugin.lets.u8cdto; import com.hzya.frame.plugin.lets.entity.*; +import com.hzya.frame.plugin.lets.queryvo.ExtIntegrationTaskLivingDetailsQueryVo; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto; import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto; @@ -20,7 +21,7 @@ import java.util.List; * @Filename:OrderToBHeaderDto */ @Data -public class OrderToBHeaderDto { +public class OrderToBHeaderDto extends StockinOrderSearchResponse.StockinOrder.StockinH { /** * 表头公司(销售公司)、视为发货公司 @@ -102,4 +103,24 @@ public class OrderToBHeaderDto { * U8C销售订单 */ private SoSaleEntity soSaleEntity; + + /** + * U8C销售出库单表头 + */ + private IcGeneralHEntity icGeneralHEntity; + + /** + * U8C销售出库单明细行 + */ + private List icGeneralBEntityList; + + /** + * U8C销售订单明细行 + */ + private List soSaleorderBEntityList; + + /** + * 执行情况自定义项 + */ + private List extIntegrationTaskLivingDetailsQueryVos; } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ReturnOrderHeaderDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ReturnOrderHeaderDto.java index 7923c8f5..ec6ffbf6 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ReturnOrderHeaderDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ReturnOrderHeaderDto.java @@ -1,6 +1,7 @@ package com.hzya.frame.plugin.lets.u8cdto; import com.hzya.frame.plugin.lets.entity.*; +import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderData; import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrder; import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderDetails; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto; @@ -53,4 +54,9 @@ public class ReturnOrderHeaderDto extends HeaderDto { * OFS采退出库单明细行 */ private List details; + + /** + * 查询OFS原正向的采购订单 + */ + private OfsPoOrderData ofsPoOrder; } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/QueryBdBusitypeUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/QueryBdBusitypeUtil.java index 7dec95f1..e2ffe3dd 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/QueryBdBusitypeUtil.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/QueryBdBusitypeUtil.java @@ -24,19 +24,22 @@ public class QueryBdBusitypeUtil { @Autowired private IBdBusitypeDao iBdBusitypeDao; - public BdBusitypeEntity queryBdBusitype(String businame, String pkCorp) { + public BdBusitypeEntity queryBdBusitype(String businame) { + String pkGroup = "0001"; //查询业务流程 BdBusitypeEntity bdBusitypeEntity = new BdBusitypeEntity(); bdBusitypeEntity.setDataSourceCode("lets_u8c"); bdBusitypeEntity.setBusiname(businame); //2024年8月26日 11:03:06 和浪哥沟通取pkCorp为4个@的业务流程! - bdBusitypeEntity.setPkCorp(pkCorp); + //2024年8月30日 13:49:54 @@@@为U8C预设的业务流程,和妮姐沟通后,所有流程,取集团对应的业务流程 +// bdBusitypeEntity.setPkCorp(pkCorp); + bdBusitypeEntity.setPkCorp(pkGroup); bdBusitypeEntity.setDr(0); List bdBusitypeEntityList = iBdBusitypeDao.query(bdBusitypeEntity); if (bdBusitypeEntityList.size() == 0) { - Assert.state(false, "没有查询到业务流程,业务流程名称:{}", bdBusitypeEntity.getBusiname()); + Assert.state(false, "没有查询到业务流程,业务流程名称:{} 公司主键:{}", bdBusitypeEntity.getBusiname(), pkGroup); } else if (bdBusitypeEntityList.size() > 1) { - Assert.state(false, "查询到多个业务流程,业务流程名称:{}", bdBusitypeEntity.getBusiname()); + Assert.state(false, "查询到多个业务流程,业务流程名称:{} 公司主键:{}", bdBusitypeEntity.getBusiname(), pkGroup); } return bdBusitypeEntityList.get(0); } diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToBTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToBTest.java index cc072f2a..8de339d8 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToBTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToBTest.java @@ -29,7 +29,7 @@ public class SoSaleReturnPluginInitializerToBTest { public void startImplement() { try { // soSaleReturnPluginInitializerToB.startImplement(null, null); - soSaleReturnPluginInitializerToB.startImplement("LETS-RE2024081900000001"); +// soSaleReturnPluginInitializerToB.startImplement("LETS-RE2024081900000001"); } catch (Exception e) { e.printStackTrace(); }