"代码更新:确保在flush=false时,重新加载时不会刷新新实体。此修复遵循指定的`flush`参数,以前新实体实例无论`flush`设置如何都会被刷新。现在,EntityClass中的重新加载机制将根据`flush`参数决定是否刷新新实体。
This commit is contained in:
parent
210eebc4e5
commit
27b03a6628
|
@ -0,0 +1,836 @@
|
|||
package com.hzya.frame.plugin.lets.plugin.sales;
|
||||
|
||||
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.entity.*;
|
||||
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDao;
|
||||
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao;
|
||||
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
|
||||
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity;
|
||||
import com.hzya.frame.plugin.lets.ofs.service.ITocofsSaleoutService;
|
||||
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo;
|
||||
import com.hzya.frame.plugin.lets.resultvo.CalculateDateVo;
|
||||
import com.hzya.frame.plugin.lets.u8cdto.*;
|
||||
import com.hzya.frame.plugin.lets.util.BasicArchivesCacheUtil;
|
||||
import com.hzya.frame.plugin.lets.util.DateStrUtil;
|
||||
import com.hzya.frame.plugin.lets.util.QueryBdBusitypeUtil;
|
||||
import com.hzya.frame.split.SplitListByCountUtil;
|
||||
import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.SaleOutReturnMessageDto;
|
||||
import com.hzya.frame.ttxofs.service.OfsUnifiedService;
|
||||
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.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* OFS售后入库单(TOC)生成U8C红字销售订单
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-08-16 15:49:55
|
||||
*/
|
||||
public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(SoSaleReturnPluginInitializerToC.class);
|
||||
|
||||
private static final ReentrantLock LOCK = new ReentrantLock(true);
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "com.hzya.frame.plugin.lets.plugin.sales.SoSaleReturnPluginInitializerToC";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "OFS售后入库单(TOC)生成U8C红字销售订单";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginLabel() {
|
||||
return "OFS售后入库单(TOC)生成U8C红字销售订单";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginType() {
|
||||
return "3";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private OfsUnifiedService ofsUnifiedService;
|
||||
|
||||
@Autowired
|
||||
private BasicArchivesCacheUtil basicArchivesCacheUtil;
|
||||
|
||||
@Autowired
|
||||
private ITocofsSaleoutService iTocofsSaleoutService;
|
||||
|
||||
@Autowired
|
||||
private ITocofsSaleoutDao iTocofsSaleoutDao;
|
||||
|
||||
@Autowired
|
||||
private ITocofsSaleoutDetailedDao iTocofsSaleoutDetailedDao;
|
||||
|
||||
@Autowired
|
||||
private QueryBdBusitypeUtil queryBdBusitypeUtil;
|
||||
|
||||
private static final String NOTHING = "无";
|
||||
|
||||
private static final String ADD = "+";
|
||||
|
||||
/**
|
||||
* 按指定时间拉取
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
public void startImplement(String dateStr, String summaryOrderNumber) {
|
||||
String threadNameStr = StrUtil.format("OFS销售出库(TOC)同步U8C销售订单 同步日期:{} 汇总维度:{}", dateStr, summaryOrderNumber);
|
||||
logger.info(threadNameStr);
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LOCK.lock();
|
||||
try {
|
||||
// TODO 注意过滤TOC店铺
|
||||
CalculateDateVo calculateDateVo = DateStrUtil.calculateCalculateEntireDayPeriod(dateStr);
|
||||
|
||||
List<HeaderDetailsDto> headerDetailsDtoList = new ArrayList<>();
|
||||
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||
queryOfsSoSaleOutVo.setCreated_start("2024-07-16 15:35:35");
|
||||
queryOfsSoSaleOutVo.setCreated_end("2024-07-16 15:35:37");
|
||||
queryOfsSoSaleOutVo.setClientCode("LETS");
|
||||
// queryOfsSoSaleOutVo.setInternalInstructionType("SALES");
|
||||
queryOfsSoSaleOutVo.setCompanyCode("SHLZ");
|
||||
// queryOfsSoSaleOutVo.setStatus(900L);
|
||||
queryOfsSoSaleOutVo.setPageNo(1L);
|
||||
queryOfsSoSaleOutVo.setPageSize(50L);
|
||||
queryOfsSoSaleOutVo.setCode("LETS-RE2024071600000001");
|
||||
queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L);
|
||||
logger.info("数据返回行数:{}", headerDetailsDtoList.size());
|
||||
if (headerDetailsDtoList.size() > 0) {
|
||||
//保存到mysql
|
||||
batchInsert(headerDetailsDtoList);
|
||||
//过滤成功的数据
|
||||
List<HeaderDetailsDto> headerDetailsDtos = filterData(headerDetailsDtoList);
|
||||
//执行推送主逻辑
|
||||
implement(headerDetailsDtos);
|
||||
} else {
|
||||
logger.info("没有查询到任何数据!不需要同步");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("startImplement方法抛出异常", e);
|
||||
} finally {
|
||||
try {
|
||||
basicArchivesCacheUtil.clearCache();
|
||||
} catch (Exception e) {
|
||||
logger.info("清理档案缓存失败", e);
|
||||
}
|
||||
LOCK.unlock();
|
||||
}
|
||||
}
|
||||
}, threadNameStr);
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
} catch (Exception e) {
|
||||
logger.error("thread.join()异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤掉成功的数据
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private List<HeaderDetailsDto> filterData(List<HeaderDetailsDto> headerDetailsDtoList) {
|
||||
List<HeaderDetailsDto> headerDetailsDtoList1 = new ArrayList<>();
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
//TODO 出库单明细主键,需要O返回,目前没有,已经提需求
|
||||
headerDetailsDtoList1.addAll(headerDetailsDtoList);
|
||||
}
|
||||
return headerDetailsDtoList1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存抓取到的数据到mysql底表,如果底表里已经存在,则会忽略
|
||||
*
|
||||
* @param headerDetailsDtoList 数据行
|
||||
*/
|
||||
private void batchInsert(List<HeaderDetailsDto> headerDetailsDtoList) throws Exception {
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
List<HeaderDto> headerDetailsDtoList1 = new ArrayList<>();
|
||||
List<DetailsDto> headerDetailsDtoList2 = new ArrayList<>();
|
||||
|
||||
for (HeaderDetailsDto index : headerDetailsDtoList) {
|
||||
HeaderDto header = index.getHeader();// 主表
|
||||
List<DetailsDto> details = index.getDetails();//明细表
|
||||
|
||||
headerDetailsDtoList1.add(header);
|
||||
headerDetailsDtoList2.addAll(details);
|
||||
}
|
||||
|
||||
//每250作为一个批次插入主表,根据主键(id)判断是否重复,如果重复的,则不进行插入
|
||||
List<List<HeaderDto>> ofssaleorderoutsearchList = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 250);
|
||||
for (int i = 0; i < ofssaleorderoutsearchList.size(); i++) {
|
||||
List<HeaderDto> headerDtoList = ofssaleorderoutsearchList.get(i);
|
||||
List<TocofsSaleoutEntity> tocofsSaleoutEntityList = copyHeaderDto(headerDtoList);
|
||||
if (tocofsSaleoutEntityList.size() > 0) {
|
||||
iTocofsSaleoutDao.entityInsertBatchV2(tocofsSaleoutEntityList);
|
||||
}
|
||||
}
|
||||
|
||||
//插入明细表
|
||||
List<List<DetailsDto>> detailsDtoList = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 250);
|
||||
for (int i = 0; i < detailsDtoList.size(); i++) {
|
||||
List<DetailsDto> detailsDtos = detailsDtoList.get(i);
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities = copyDetailsDto(detailsDtos);
|
||||
if (tocofsSaleoutDetailedEntities.size() > 0) {
|
||||
iTocofsSaleoutDetailedDao.entityInsertBatchV2(tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询OFS结果集
|
||||
*
|
||||
* @param queryOfsSoSaleOutVo 查询参数
|
||||
* @param headerDetailsDtoList 查询结果集
|
||||
* @param pageNo 从第pageNo页开始查询
|
||||
*/
|
||||
private void queryOfsSaleOrder(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List<HeaderDetailsDto> headerDetailsDtoList, Long pageNo) throws Exception {
|
||||
|
||||
Long pageSize = 200L;
|
||||
queryOfsSoSaleOutVo.setPageNo(pageNo);
|
||||
queryOfsSoSaleOutVo.setPageSize(pageSize);
|
||||
|
||||
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
|
||||
interfaceParamDto.setApi("ofs.receipt.search");
|
||||
interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
|
||||
SaleOutReturnMessageDto saleOutReturnMessageDto = (SaleOutReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto);
|
||||
if (saleOutReturnMessageDto != null) {
|
||||
if ("false".equals(saleOutReturnMessageDto.getError()) && "0".equals(saleOutReturnMessageDto.getCode()) && "Success".equals(saleOutReturnMessageDto.getMsg())) {
|
||||
List<HeaderDetailsDto> headerDetailsDtoList1 = saleOutReturnMessageDto.getData();
|
||||
if (headerDetailsDtoList1 != null && headerDetailsDtoList1.size() > 0) {
|
||||
headerDetailsDtoList.addAll(headerDetailsDtoList1);
|
||||
|
||||
//TODO OFS没有提供分页字段
|
||||
}
|
||||
} else {
|
||||
//2024年7月30日 13:47:04 查询失败
|
||||
logger.error("查询失败,失败原因:{}", JSON.toJSON(saleOutReturnMessageDto));
|
||||
}
|
||||
} else {
|
||||
logger.error("returnMessageBasics为空!queryOfsSoSaleOutVo对象结果:{}", JSON.toJSON(queryOfsSoSaleOutVo));
|
||||
}
|
||||
}
|
||||
|
||||
// public void queryOfsSaleOrder() throws Exception {
|
||||
// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||
// queryOfsSoSaleOutVo.setCreated_start("2024-07-05 16:38:00");
|
||||
// queryOfsSoSaleOutVo.setCreated_end("2024-07-05 16:40:30");
|
||||
// queryOfsSoSaleOutVo.setClientCode("LETS");
|
||||
//// queryOfsSoSaleOutVo.setInternalInstructionType("SALES");
|
||||
// queryOfsSoSaleOutVo.setCompanyCode("SHLZ");
|
||||
//// queryOfsSoSaleOutVo.setStatus(900L);
|
||||
// queryOfsSoSaleOutVo.setPageNo(1L);
|
||||
// queryOfsSoSaleOutVo.setPageSize(50L);
|
||||
// queryOfsSoSaleOutVo.setCode("LETS-SH2024070500000003");
|
||||
//
|
||||
// InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
|
||||
// interfaceParamDto.setApi("ofs.shipment.search");
|
||||
// interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
|
||||
// SaleOutReturnMessageDto saleOutReturnMessageDto = (SaleOutReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto);
|
||||
// System.out.println(saleOutReturnMessageDto);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 代码同步逻辑
|
||||
*
|
||||
* @param headerDetailsDtos 查询得到的O出库单对象
|
||||
* @author liuyang
|
||||
*/
|
||||
private void implement(List<HeaderDetailsDto> headerDetailsDtos) throws Exception {
|
||||
if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) {
|
||||
try {
|
||||
// 查询基本档案
|
||||
List<SonDetailsDto> sonDetailsDtoList = queryBasicArchives(headerDetailsDtos);
|
||||
// 分组汇总
|
||||
Map<String, List<SonDetailsDto>> summaryDimensionMap = groupSummary(sonDetailsDtoList);
|
||||
// 查询U8C业务流程
|
||||
BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow();
|
||||
|
||||
if (bdBusitypeEntity != null && summaryDimensionMap != null) {
|
||||
Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, List<SonDetailsDto>> entry = iterator.next();
|
||||
String keyGroup = entry.getKey();
|
||||
List<SonDetailsDto> oldValue = entry.getValue();
|
||||
HeaderDto header = oldValue.get(0).getHeader();
|
||||
BdCorpEntity bdCorpEntity = oldValue.get(0).getBdCorpEntity();//表头销售公司
|
||||
BdCorpEntity deliverGoodsCorp = oldValue.get(0).getDeliverGoodsCorp();//发货公司
|
||||
BdCalbodyEntity bdCalbodyEntity = oldValue.get(0).getBdCalbodyEntity();//发货仓库组织
|
||||
BdStordocEntity bdStordocEntity = oldValue.get(0).getBdStordocEntity();//发货仓库
|
||||
BdCalbodyEntity bdCalbodyEntity1 = oldValue.get(0).getBdCalbodyEntity1();//收货库存组织
|
||||
BdStordocEntity bdStordocEntity1 = oldValue.get(0).getBdStordocEntity1();//收货仓库
|
||||
BdSalestruEntity bdSalestruEntity = oldValue.get(0).getBdSalestruEntity();//销售组织
|
||||
BdDeptdocEntity bdDeptdocEntity = oldValue.get(0).getBdDeptdocEntity();//业务部门
|
||||
BdCumandocEntity bdCumandocEntity = oldValue.get(0).getBdCumandocEntity();//客商管理档案
|
||||
BdCubasdocEntity bdCubasdocEntity = oldValue.get(0).getBdCubasdocEntity();//客商基本档案
|
||||
BdDefdocEntity platformArchives = oldValue.get(0).getPlatformArchives();//U8C平台档案
|
||||
|
||||
try {
|
||||
checkArchives(oldValue.get(0));
|
||||
//生成业务日期
|
||||
String generateBusinessDate = createGenerateBusinessDate(header);
|
||||
|
||||
SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto();
|
||||
SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto();
|
||||
saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期
|
||||
saleorderRequestParentDto.setBretinvflag("N");//退货标记
|
||||
saleorderRequestParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype());//业务流程
|
||||
saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织
|
||||
saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位
|
||||
saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门
|
||||
saleorderRequestParentDto.setCemployeeid(null);//业务员
|
||||
saleorderRequestParentDto.setCoperatorid("0001A110000000000U3D");//制单人
|
||||
saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位
|
||||
saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位
|
||||
saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织
|
||||
saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库
|
||||
saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期
|
||||
saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣
|
||||
saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id
|
||||
|
||||
//汇总单号=汇总维度
|
||||
saleorderRequestParentDto.setVdef18(keyGroup);
|
||||
|
||||
//平台
|
||||
saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc());
|
||||
saleorderRequestParentDto.setVdef2(platformArchives.getDocname());
|
||||
|
||||
//TODO 2024年8月8日 17:17:58 店铺档案自定义项1,先不传,后续维护好之后再传!
|
||||
|
||||
saleorderRequestDto.setParentvo(saleorderRequestParentDto);
|
||||
|
||||
List<SaleorderRequestChildrenDto> saleorderRequestChildrenDtoList = new ArrayList<>();
|
||||
saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList);
|
||||
|
||||
//把汇总好的出库单明细行合并成一行
|
||||
SonDetailsDto sonDetailsDto = groupMergeDetailedRows(oldValue);
|
||||
|
||||
//存货管理档案:取发货公司的存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity = queryInventoryMan(sonDetailsDto, bdCalbodyEntity.getPkCorp());
|
||||
|
||||
//存货基础档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity = queryStockBasicArchives(bdInvmandocEntity.getPkInvmandoc(), deliverGoodsCorp.getPkCorp());
|
||||
|
||||
//根据存货基础档案编码,查询当前存货的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity1 = queryBdTaxitems(bdInvbasdocEntity.getInvcode());
|
||||
|
||||
String tax = "0." + new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString();
|
||||
BigDecimal noriginalcurprice = null;//无税单价
|
||||
BigDecimal noriginalcurmny = null;//无税金额
|
||||
BigDecimal noriginalcurtaxprice = null;//含税单价
|
||||
BigDecimal noriginalcursummny = null;//价税合计
|
||||
BigDecimal noriginalcurtaxmny = null;//税额
|
||||
try {
|
||||
noriginalcurtaxprice = sonDetailsDto.getGroupTotalPayAmount().divide(sonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
||||
noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
||||
noriginalcurmny = noriginalcurprice.multiply(sonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
noriginalcursummny = noriginalcurtaxprice.multiply(sonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
noriginalcurtaxmny = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
} catch (Exception e) {
|
||||
logger.error("TOC金额计算错误", e);
|
||||
Assert.state(false, "金额计算错误,原因:{}" + e.getMessage());
|
||||
}
|
||||
|
||||
//判断是否为赠品
|
||||
String isblargessflag = "N";
|
||||
if (noriginalcursummny.longValue() == 0) {
|
||||
isblargessflag = "Y";
|
||||
}
|
||||
|
||||
SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto();
|
||||
saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品
|
||||
saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织
|
||||
saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库
|
||||
saleorderRequestChildrenDto.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码:这个字段不需要给openapi接口,而是提供给下游方法使用
|
||||
saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司
|
||||
saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种
|
||||
saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id
|
||||
saleorderRequestChildrenDto.setCinventorycode(bdInvbasdocEntity.getInvcode());//存货编码
|
||||
saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位
|
||||
saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期
|
||||
saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);//要求收货日期
|
||||
saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率
|
||||
saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣
|
||||
saleorderRequestChildrenDto.setNnumber(String.valueOf(sonDetailsDto.getGroupShipQty()));//数量
|
||||
saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额
|
||||
saleorderRequestChildrenDto.setNoriginalcurmny(noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额
|
||||
saleorderRequestChildrenDto.setNoriginalcurnetprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税净价
|
||||
saleorderRequestChildrenDto.setNoriginalcurprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税单价
|
||||
saleorderRequestChildrenDto.setNoriginalcursummny(noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计
|
||||
saleorderRequestChildrenDto.setNoriginalcurtaxmny(noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额
|
||||
saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价
|
||||
saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价
|
||||
saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率
|
||||
// saleorderRequestChildrenDto.setCreccalbodyid(bdCalbodyEntity1.getPkCalbody());//收货库存组织:2024年8月7日 16:21:48 和佳妮、道品一起测试,收货库存组织、收货仓库 是不需要传递的
|
||||
// saleorderRequestChildrenDto.setCrecwareid(bdStordocEntity1.getPkStordoc());//收货仓库
|
||||
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
|
||||
|
||||
//销售订单单据推送到u8c
|
||||
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
|
||||
saleorderRequestDtoList.add(saleorderRequestDto);
|
||||
|
||||
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
|
||||
stringStringMap.put("saleorder", saleorderRequestDtoList);
|
||||
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
|
||||
logger.info("销售订单编号:{} 销售公司:{}", soSaleResultRootDto.getParentvo().getVreceiptcode(), soSaleResultRootDto.getParentvo().getPk_corp());
|
||||
//记录成功
|
||||
} catch (Exception e) {
|
||||
logger.error("TOC业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
|
||||
//记录失败
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//2024年8月6日 11:28:54此处不记录失败,不认为是错误
|
||||
logger.info("summaryDimensionMap变量或者bdBusitypeEntity变量为空,因此主要的推送逻辑不会被执行!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("外层转换逻辑抛出异常", e);
|
||||
// 记录失败
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 2024年7月31日 10:34:09
|
||||
* 生成业务日期,以发货时间作为业务日期
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private String createGenerateBusinessDate(HeaderDto header) {
|
||||
if (header != null && header.getShipAt() != null) {
|
||||
//TOC以出库日期作为业务日期
|
||||
String shipAt = header.getShipAt();
|
||||
String businessFormat = null;
|
||||
try {
|
||||
Date dbill = DateUtil.parse(shipAt);
|
||||
businessFormat = DateUtil.format(dbill, "yyyy-MM-dd");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("业务日期转换失败", e);
|
||||
}
|
||||
return businessFormat;
|
||||
} else {
|
||||
logger.error("生成出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(header));
|
||||
Assert.state(false, "生成出库日期失败,或者shipAt为空! json:{}", JSON.toJSON(header));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 档案转换
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private List<SonDetailsDto> queryBasicArchives(List<HeaderDetailsDto> headerDetailsDtoList) {
|
||||
List<SonDetailsDto> sonDetailsDtoList = new ArrayList<>();
|
||||
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
try {
|
||||
//初始化档案缓存
|
||||
basicArchivesCacheUtil.initCache();
|
||||
|
||||
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
|
||||
HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i);
|
||||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<DetailsDto> details = headerDetailsDto.getDetails();
|
||||
|
||||
//表头公司:通过名称匹配U8C公司
|
||||
String corpName = "上海丽知品牌管理有限公司";
|
||||
BdCorpEntity bdCorpEntity = BasicArchivesCacheUtil.stringBdCorpEntityMap.get(corpName);
|
||||
Assert.notNull(bdCorpEntity, "根据公司名称({})没有匹配到U8C公司档案", corpName);
|
||||
|
||||
//发货库存组织
|
||||
BdCalbodyEntity bdCalbodyEntity = BasicArchivesCacheUtil.stringBdCalbodyEntityMap.get(bdCorpEntity.getPkCorp());
|
||||
Assert.notNull(bdCalbodyEntity, "根据公司主键没有查询到发货库存组织 公司主键:{}", bdCorpEntity.getPkCorp());
|
||||
|
||||
//发货公司,暂时把O表头公司作为发货公司,正常情况下需要把O库存地点对于的公司作为发货公司
|
||||
|
||||
//发货仓库
|
||||
//2024年8月5日 15:06:38 仓库O与U两边仓库编码是一致的,和妮姐确认过了
|
||||
String facilityCode = header.getFacilityCode();
|
||||
Assert.notNull(facilityCode, "O仓库编码不能为空");
|
||||
BdStordocEntity bdStordocEntity = BasicArchivesCacheUtil.stringBdStordocEntityMap.get(facilityCode + bdCalbodyEntity.getPkCalbody());
|
||||
Assert.notNull(bdStordocEntity, "没有匹配到发货仓库 发货库存组织主键:{} O库存地点编码:{}", facilityCode, bdCalbodyEntity.getPkCalbody());
|
||||
|
||||
//2024年8月5日 15:25:07 收货库存组织、收货仓库、默认和发货库存组织、发货仓库一致,已经和佳妮确认
|
||||
//收货库存组织:速网来看收货库存组织对应表头工具
|
||||
//收货仓库:通过收货库存组织+仓库编码,确定收货仓库
|
||||
|
||||
//销售组织2024年8月5日 15:33:40 和妮姐确认,销售组织和表头公司,作为一对一的关系,
|
||||
BdSalestruEntity bdSalestruEntity = BasicArchivesCacheUtil.stringBdSalestruEntityMap.get(bdCorpEntity.getUnitname());
|
||||
Assert.notNull(bdSalestruEntity, "无匹配到销售组织 表头公司名称:{}", bdCorpEntity.getUnitname());
|
||||
|
||||
//业务部门:暂定的部门名称:其他,2024年8月5日 15:39:42 已经和妮姐确认
|
||||
BdDeptdocEntity bdDeptdocEntity = BasicArchivesCacheUtil.stringBdDeptdocEntityMap.get(bdCorpEntity.getPkCorp());
|
||||
Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:其他 对应公司名称:{}", bdCorpEntity.getPkCorp());
|
||||
|
||||
//客商基本档案
|
||||
//TODO 2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1,O没有店铺信息查询接口,因此无法通过出库单的店铺编码,查询到O店铺档案对应的业务编码,接口上线之后需要补充这一部分逻辑
|
||||
String custName = "天猫intoyou旗舰店-自营";
|
||||
BdCubasdocEntity bdCubasdocEntity = BasicArchivesCacheUtil.stringBdCubasdocEntityHashMap.get(custName);
|
||||
Assert.notNull(bdCubasdocEntity, "无法匹配到客户档案 客商名称:{}", custName);
|
||||
|
||||
//客商管理档案:2024年8月5日 15:41:54 TOC店铺名称查询U8C客商档案,已经和妮姐确认
|
||||
//2024年8月5日 15:49:49 先根据O店铺编码,得到店铺档案信息,取到名称,通过U8C接口查询出来
|
||||
//目前O店铺信息查询接口还没有,等待开发,所以我这里先写所一个名字
|
||||
BdCumandocEntity bdCumandocEntity = BasicArchivesCacheUtil.stringBdCumandocEntityMap.get(bdCubasdocEntity.getPkCubasdoc() + bdCorpEntity.getPkCorp());
|
||||
Assert.notNull(bdCumandocEntity, "无法匹配到客商档案 店铺名称:{}", "天猫intoyou旗舰店-自营");
|
||||
|
||||
//查找平台
|
||||
BdDefdocEntity bdDefdocEntity = BasicArchivesCacheUtil.stringBdDefdocEntityHashMap.get(header.getSourcePlatformCode());
|
||||
Assert.notNull(bdDefdocEntity, "根据O平台编码({})无法匹配到平台", header.getSourcePlatformCode());
|
||||
|
||||
//字段拷贝
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
DetailsDto detailsDto = details.get(j);
|
||||
|
||||
//2024年8月6日 10:16:22 通过O出库单的表头,查询得出U8C档案,放在表体的原因是方便分组汇总
|
||||
//下一个步骤的分组汇总,是通过表体明细完成的
|
||||
SonDetailsDto sonDetailsDto = new SonDetailsDto();
|
||||
sonDetailsDto.setHeader(header);
|
||||
sonDetailsDto.setBdCorpEntity(bdCorpEntity);
|
||||
sonDetailsDto.setDeliverGoodsCorp(bdCorpEntity);
|
||||
sonDetailsDto.setBdCalbodyEntity(bdCalbodyEntity);
|
||||
sonDetailsDto.setBdStordocEntity(bdStordocEntity);
|
||||
sonDetailsDto.setBdCalbodyEntity1(bdCalbodyEntity);
|
||||
sonDetailsDto.setBdStordocEntity1(bdStordocEntity);
|
||||
sonDetailsDto.setBdSalestruEntity(bdSalestruEntity);
|
||||
sonDetailsDto.setBdDeptdocEntity(bdDeptdocEntity);
|
||||
sonDetailsDto.setBdCumandocEntity(bdCumandocEntity);
|
||||
sonDetailsDto.setBdCubasdocEntity(bdCubasdocEntity);
|
||||
sonDetailsDto.setPlatformArchives(bdDefdocEntity);
|
||||
|
||||
BeanUtil.copyPropertiesV2(detailsDto, sonDetailsDto);
|
||||
sonDetailsDtoList.add(sonDetailsDto);
|
||||
}
|
||||
}
|
||||
//成功
|
||||
} catch (Exception e) {
|
||||
logger.error("OFS销售出库单关联查询U8C档案失败", e);
|
||||
//失败
|
||||
}
|
||||
} else {
|
||||
logger.info("queryBasicArchives方法headerDetailsDtoList.size为0");
|
||||
}
|
||||
return sonDetailsDtoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* bean copy
|
||||
* 2024年7月31日 10:34:09
|
||||
*/
|
||||
private List<TocofsSaleoutEntity> copyHeaderDto(List<HeaderDto> headerDtoList) {
|
||||
List<TocofsSaleoutEntity> tocofsSaleoutEntityList = new ArrayList<>();
|
||||
if (headerDtoList != null && headerDtoList.size() > 0) {
|
||||
for (int i = 0; i < headerDtoList.size(); i++) {
|
||||
HeaderDto headerDto = headerDtoList.get(i);
|
||||
TocofsSaleoutEntity tocofsSaleoutEntity = new TocofsSaleoutEntity();
|
||||
// BeanUtils.copyProperties(headerDto, tocofsSaleoutEntity);
|
||||
BeanUtil.copyPropertiesV2(headerDto, tocofsSaleoutEntity);
|
||||
tocofsSaleoutEntityList.add(tocofsSaleoutEntity);
|
||||
}
|
||||
}
|
||||
return tocofsSaleoutEntityList;
|
||||
}
|
||||
|
||||
/**
|
||||
* bean copy
|
||||
* 2024年8月2日 16:04:11
|
||||
*/
|
||||
private List<TocofsSaleoutDetailedEntity> copyDetailsDto(List<DetailsDto> detailsDtos) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityArrayList = new ArrayList<>();
|
||||
if (detailsDtos != null && detailsDtos.size() > 0) {
|
||||
for (int i = 0; i < detailsDtos.size(); i++) {
|
||||
DetailsDto detailsDto = detailsDtos.get(i);
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
|
||||
// BeanUtils.copyProperties(detailsDto, tocofsSaleoutDetailedEntity);
|
||||
BeanUtil.copyPropertiesV2(detailsDto, tocofsSaleoutDetailedEntity);
|
||||
tocofsSaleoutDetailedEntityArrayList.add(tocofsSaleoutDetailedEntity);
|
||||
}
|
||||
}
|
||||
return tocofsSaleoutDetailedEntityArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组汇总:公司+店铺+仓库+SKU+出库类型,数量合并相加
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private Map<String, List<SonDetailsDto>> groupSummary(List<SonDetailsDto> sonDetailsDtoList) {
|
||||
if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) {
|
||||
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
|
||||
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
|
||||
//2024年8月6日 10:35:25表头对象用于带出表头相关的分组汇总信息
|
||||
HeaderDto header = sonDetailsDto.getHeader();
|
||||
|
||||
//公司
|
||||
BdCorpEntity bdCorpEntity = sonDetailsDto.getBdCorpEntity();
|
||||
//店铺(主要是店铺编码)
|
||||
String storeCode = header.getStoreCode();
|
||||
//仓库
|
||||
String facilityCode = header.getFacilityCode();
|
||||
//SKU
|
||||
String skuCode = sonDetailsDto.getSkuCode();
|
||||
//出库类型
|
||||
String refOrderType = header.getRefOrderType();
|
||||
|
||||
StringBuffer summaryDimensionStr = new StringBuffer();
|
||||
if (bdCorpEntity != null && bdCorpEntity.getPkCorp() != null) {
|
||||
summaryDimensionStr.append(bdCorpEntity.getPkCorp());
|
||||
} else {
|
||||
summaryDimensionStr.append(NOTHING);
|
||||
}
|
||||
summaryDimensionStr.append(ADD);
|
||||
|
||||
if (storeCode != null && !"".equals(storeCode)) {
|
||||
summaryDimensionStr.append(storeCode);
|
||||
} else {
|
||||
summaryDimensionStr.append(NOTHING);
|
||||
}
|
||||
summaryDimensionStr.append(ADD);
|
||||
|
||||
if (facilityCode != null && !"".equals(facilityCode)) {
|
||||
summaryDimensionStr.append(facilityCode);
|
||||
} else {
|
||||
summaryDimensionStr.append(NOTHING);
|
||||
}
|
||||
summaryDimensionStr.append(ADD);
|
||||
|
||||
if (skuCode != null && !"".equals(skuCode)) {
|
||||
summaryDimensionStr.append(skuCode);
|
||||
} else {
|
||||
summaryDimensionStr.append(NOTHING);
|
||||
}
|
||||
summaryDimensionStr.append(ADD);
|
||||
|
||||
if (refOrderType != null && !"".equals(refOrderType)) {
|
||||
summaryDimensionStr.append(refOrderType);
|
||||
} else {
|
||||
summaryDimensionStr.append(NOTHING);
|
||||
}
|
||||
|
||||
sonDetailsDto.setSummaryDimensionStr(summaryDimensionStr.toString());
|
||||
}
|
||||
logger.info("TOC:{}个出库单对象需要汇总", sonDetailsDtoList.size());
|
||||
return sonDetailsDtoList.stream().collect(Collectors.groupingBy(SonDetailsDto::getSummaryDimensionStr));
|
||||
}
|
||||
logger.info("TOC:0个对象需要汇总");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2024年8月6日 10:59:03 查询U8C业务流程
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private BdBusitypeEntity u8cOperationFlow() throws Exception {
|
||||
//查询业务流程
|
||||
//2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供
|
||||
String processName = "TOC销售业务流程";
|
||||
BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName);
|
||||
Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName);
|
||||
return bdBusitypeEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查参数是否为空
|
||||
* 2024年8月6日 11:40:19 保险的做法,最好还是验证一下
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private void checkArchives(SonDetailsDto sonDetailsDto) {
|
||||
Assert.notNull(sonDetailsDto, "sonDetailsDto不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getHeader(), "header对象不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getBdCorpEntity(), "表头公司不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getBdCalbodyEntity(), "发货库存组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getBdStordocEntity(), "发货仓库不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getBdCalbodyEntity1(), "收货库存组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getBdStordocEntity1(), "收货库存不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getBdSalestruEntity(), "销售组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getBdDeptdocEntity(), "业务部门不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getBdCumandocEntity(), "客商档案不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询存货管理档案
|
||||
*
|
||||
* @param pkCorp 发货公司主键
|
||||
* @param sonDetailsDto 出库单存货明细行
|
||||
* @author liuyang
|
||||
*/
|
||||
private BdInvmandocEntity queryInventoryMan(SonDetailsDto sonDetailsDto, String pkCorp) {
|
||||
Assert.notNull(sonDetailsDto, "sonDetailsDto不能为空");
|
||||
Assert.notNull(sonDetailsDto.getSkuCode(), "O存货商家编码不能为空");
|
||||
Assert.notNull(pkCorp, "发货公司主键不能为空");
|
||||
|
||||
BdInvmandocEntity bdInvmandocEntity = BasicArchivesCacheUtil.stringBdInvmandocEntityMap.get(sonDetailsDto.getSkuCode() + pkCorp);
|
||||
Assert.notNull(bdInvmandocEntity, "无法匹配到存货管理档案 存货商家编码:{} 存货发货公司:{}", sonDetailsDto.getSkuCode(), pkCorp);
|
||||
return bdInvmandocEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并明细行
|
||||
* 单价计算公式:sum(实付金额/实发数量) 最后除以条数
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private SonDetailsDto groupMergeDetailedRows(List<SonDetailsDto> sonDetailsDtoList) throws Exception {
|
||||
if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) {
|
||||
BigDecimal groupTotalPayAmount = new BigDecimal("0");
|
||||
BigDecimal groupShipQty = new BigDecimal("0");
|
||||
|
||||
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
|
||||
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
|
||||
|
||||
//实付金额/实发数量
|
||||
Assert.notNull(sonDetailsDto.getTotalPayAmount(), "实付金额不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto));
|
||||
BigDecimal totalPayAmountBigDecimal = new BigDecimal(sonDetailsDto.getTotalPayAmount());
|
||||
BigDecimal shipQtyBigDecimal = new BigDecimal(sonDetailsDto.getShipQty());
|
||||
|
||||
groupTotalPayAmount = groupTotalPayAmount.add(totalPayAmountBigDecimal);
|
||||
groupShipQty = groupShipQty.add(shipQtyBigDecimal);
|
||||
}
|
||||
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0);
|
||||
sonDetailsDto.setGroupShipQty(groupShipQty);
|
||||
sonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount);
|
||||
logger.info("{}个明细行发生了合并!", sonDetailsDtoList.size());
|
||||
return sonDetailsDto;
|
||||
} else {
|
||||
logger.info("sonDetailsDtoList集合是空的!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2024年8月7日 10:25:29
|
||||
* 查询基础档案,根据公司、管理档案主键查询
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private BdInvbasdocEntity queryStockBasicArchives(String pkInvmandoc, String pkCorp) {
|
||||
Assert.notNull(pkInvmandoc, "存货管理档案不能为空");
|
||||
Assert.notNull(pkCorp, "公司档案不能为空");
|
||||
BdInvbasdocEntity bdInvbasdocEntity = BasicArchivesCacheUtil.stringBdInvbasdocEntityHashMap.get(pkInvmandoc + pkCorp);
|
||||
Assert.notNull(bdInvbasdocEntity, "根据公司主键:{} 和存货管理档案主键:{} 没有查询到存货基本档案", pkCorp, pkInvmandoc);
|
||||
return bdInvbasdocEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2024年8月7日 14:58:34
|
||||
* 查询税目档案
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private BdTaxitemsEntity queryBdTaxitems(String invcode) {
|
||||
Assert.notNull(invcode, "存货编码不能为空");
|
||||
BdTaxitemsEntity bdTaxitemsEntity = BasicArchivesCacheUtil.stringBdTaxitemsEntityHashMap.get(invcode);
|
||||
Assert.notNull(bdTaxitemsEntity, "根据存货编码({}),无法匹配到税率!", invcode);
|
||||
return bdTaxitemsEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2024年8月8日 10:54:48
|
||||
* 推送U8C销售订单方法
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
public SoSaleResultRootDto sendU8CTOCOrder(String param) {
|
||||
long startLong = System.currentTimeMillis();
|
||||
logger.info("TOC推送开始,推送参数:" + 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", "8000370006")//头信息,多个头信息多次调用此方法即可
|
||||
.header("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可
|
||||
.header("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可
|
||||
.body(param)//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
logger.info("TOC推送结束,返回参数:" + result);
|
||||
long endLong = System.currentTimeMillis();
|
||||
logger.info("TOC接口请求耗时:" + (endLong - startLong));
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
result = String.valueOf(jsonObject.get("attribute"));
|
||||
|
||||
boolean isSuccess = false;
|
||||
SoSaleResultRootDto soSaleResultRootDto = null;
|
||||
if (result != null && !"".equals(result)) {
|
||||
ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class);
|
||||
if ("success".equals(reusltStrDto.getStatus())) {
|
||||
soSaleResultRootDto = resultDataHandle(reusltStrDto.getData());
|
||||
isSuccess = true;
|
||||
}
|
||||
}
|
||||
if (!isSuccess) {
|
||||
Assert.state(false, "TOC业务O出库单推送U8C销售订单失败 接口返回结果:{}", result);
|
||||
}
|
||||
return soSaleResultRootDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回结果解析处理,在确认了success后调用
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private SoSaleResultRootDto resultDataHandle(String resultData) {
|
||||
try {
|
||||
if (resultData != null && !"".equals(resultData)) {
|
||||
if (resultData.contains("[")) {
|
||||
resultData = resultData.substring(1, resultData.length() - 1);
|
||||
}
|
||||
return JSON.parseObject(resultData, SoSaleResultRootDto.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("解析返回参数失败的错误", e);
|
||||
//如果解析失败,记录原因,但是不能影响结果的记录
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -86,6 +86,19 @@ public class SonDetailsDto extends DetailsDto {
|
|||
*/
|
||||
private BdCorpEntity deliverGoodsCorp;
|
||||
|
||||
/**
|
||||
* U8C平台档案
|
||||
*/
|
||||
private BdDefdocEntity platformArchives;
|
||||
|
||||
public BdDefdocEntity getPlatformArchives() {
|
||||
return platformArchives;
|
||||
}
|
||||
|
||||
public void setPlatformArchives(BdDefdocEntity platformArchives) {
|
||||
this.platformArchives = platformArchives;
|
||||
}
|
||||
|
||||
public BdCorpEntity getDeliverGoodsCorp() {
|
||||
return deliverGoodsCorp;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@ public class BasicArchivesCacheUtil {
|
|||
@Autowired
|
||||
private IBdCubasdocDao iBdCubasdocDao;
|
||||
|
||||
@Autowired
|
||||
private IBdDefdocDao iBdDefdocDao;
|
||||
|
||||
/**
|
||||
* 初始化公司档案-表头公司
|
||||
* 2024年7月31日 11:16:23
|
||||
|
@ -246,6 +249,27 @@ public class BasicArchivesCacheUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存来源平台逻辑
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
public static Map<String, BdDefdocEntity> stringBdDefdocEntityHashMap = new HashMap<>();
|
||||
|
||||
private void initSourcePlatform() {
|
||||
BdDefdocEntity bdDefdocEntity = new BdDefdocEntity();
|
||||
bdDefdocEntity.setPkDefdoclist("0001A210000000000JUD");
|
||||
bdDefdocEntity.setDr(0);
|
||||
bdDefdocEntity.setDataSourceCode("lets_u8c");
|
||||
List<BdDefdocEntity> bdDefdocEntityList = iBdDefdocDao.query(bdDefdocEntity);
|
||||
if (bdDefdocEntityList != null && bdDefdocEntityList.size() > 0) {
|
||||
for (int i = 0; i < bdDefdocEntityList.size(); i++) {
|
||||
BdDefdocEntity bdDefdocEntity1 = bdDefdocEntityList.get(i);
|
||||
stringBdDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode(), bdDefdocEntity1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*
|
||||
|
@ -262,6 +286,7 @@ public class BasicArchivesCacheUtil {
|
|||
stringBdInvbasdocEntityHashMap.clear();
|
||||
stringBdTaxitemsEntityHashMap.clear();
|
||||
stringBdCubasdocEntityHashMap.clear();
|
||||
stringBdDefdocEntityHashMap.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,6 +307,7 @@ public class BasicArchivesCacheUtil {
|
|||
initBasicInventoryFile();
|
||||
initBdTaxitemsEntity();
|
||||
initBdCubasdoc();
|
||||
initSourcePlatform();
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
<beans default-autowire="byName">
|
||||
<!-- 销售业务 -->
|
||||
<bean name="soSaleOutPluginInitializerToC" class="com.hzya.frame.plugin.lets.plugin.sales.SoSaleOutPluginInitializerToC"/>
|
||||
<bean name="soSaleReturnPluginInitializerToC" class="com.hzya.frame.plugin.lets.plugin.sales.SoSaleReturnPluginInitializerToC"/>
|
||||
|
||||
<!--基础档案-->
|
||||
<bean name="goodsPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.base.GoodsPluginInitializer"/>
|
|
@ -0,0 +1,31 @@
|
|||
package com.hzya.frame.plugin.lets.plugin.sales;
|
||||
|
||||
import com.hzya.frame.WebappApplication;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* @Author:liuyang
|
||||
* @Package:com.hzya.frame.plugin.lets.plugin.sales
|
||||
* @Project:kangarooDataCenterV3
|
||||
* @name:SoSaleReturnPluginInitializerToCTest
|
||||
* @Date:2024/8/9 09:56
|
||||
* @Filename:SoSaleReturnPluginInitializerToCTest
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = WebappApplication.class)
|
||||
public class SoSaleReturnPluginInitializerToCTest {
|
||||
|
||||
@Autowired
|
||||
private SoSaleReturnPluginInitializerToC soSaleReturnPluginInitializerToC;
|
||||
|
||||
@Test
|
||||
public void startImplement() {
|
||||
soSaleReturnPluginInitializerToC.startImplement(null, null);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue