diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdRdclEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdRdclEntity.java index 2ffc4e73..5744683b 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdRdclEntity.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdRdclEntity.java @@ -1,6 +1,7 @@ package com.hzya.frame.plugin.lets.entity; import com.hzya.frame.web.entity.BaseEntity; + /** * (BdRdcl)实体类 * @@ -8,17 +9,17 @@ import com.hzya.frame.web.entity.BaseEntity; * @since 2023-12-04 13:49:11 */ public class BdRdclEntity extends BaseEntity { - - private Integer dr; - private Integer iflag; - private String pkCorp; - private String pkFrdcl; - private String pkRdcl; - private String rdcode; - private Integer rdflag; - private String rdname; - private String sealflag; - private String ts; + + private Integer dr; + private Integer iflag; + private String pkCorp; + private String pkFrdcl; + private String pkRdcl; + private String rdcode; + private Integer rdflag; + private String rdname; + private String sealflag; + private String ts; public Integer getDr() { 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 53c62e27..c126ae92 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 @@ -3,6 +3,7 @@ package com.hzya.frame.plugin.lets.plugin.purchase; 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; @@ -11,11 +12,9 @@ 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.PoOrderChildrenDto; -import com.hzya.frame.plugin.lets.u8cdto.PoOrderParentChildrenDto; -import com.hzya.frame.plugin.lets.u8cdto.PoOrderParentDto; -import com.hzya.frame.plugin.lets.u8cdto.PoOrderSonDto; +import com.hzya.frame.plugin.lets.u8cdto.*; import com.hzya.frame.plugin.lets.util.QueryBdBusitypeUtil; +import com.hzya.frame.plugin.lets.util.RdclUtil; import com.hzya.frame.ttxofs.dto.InterfaceParamDto; import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderBean; import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderData; @@ -28,9 +27,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.math.BigDecimal; +import java.util.*; /** * 代理品牌采购退货业务:(代理品牌采购退货)OFS销退出库单生成U8C红字采购订单 @@ -70,6 +68,15 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { @Autowired private IBdInvmandocDao iBdInvmandocDao; + @Autowired + private IBdCalbodyDao iBdCalbodyDao; + + @Autowired + private IBdStordocDao iBdStordocDao; + + @Autowired + private RdclUtil rdclUtil; + @Override public void initialize() { logger.info(getPluginLabel() + "執行初始化方法initialize()"); @@ -110,9 +117,9 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { * * @author liuyang */ - public void startImplement(String code) { - String threadNameStr = StrUtil.format("(代理品牌采购)OFS采购入库单生成U8C采购订单 售后入库单号", code); - logger.info(threadNameStr); + public void startImplement(String startTime, String endTime) { + String threadNameStrStart = StrUtil.format("开始(代理品牌采退)OFS采退出库单生成U8C红字采购订单 开始时间:{} 结束时间:{}", startTime, endTime); + logger.info(threadNameStrStart); Thread thread = new Thread(new Runnable() { @Override @@ -120,11 +127,12 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { try { 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.setCode(code); - queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE_RETURN"); + queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE"); queryOfsSoSaleOutVo.setStatus(900L); queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L); logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); @@ -137,13 +145,58 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { logger.error("startImplement方法抛出异常", e); } } - }, threadNameStr); + }, threadNameStrStart); thread.start(); try { thread.join(); } catch (Exception e) { logger.error("thread.join()异常", e); } + String threadNameStrEnd = StrUtil.format("结束(代理品牌采退)OFS采退出库单生成U8C红字采购订单 开始时间:{} 结束时间:{}", startTime, endTime); + logger.info(threadNameStrEnd); + } + + /** + * 根据单号查询 + * + * @author liuyang + */ + public void startImplement(String code) { + String threadNameStrStart = StrUtil.format("开始(代理品牌采购)OFS采购入库单生成U8C采购订单 售后入库单号:{}", 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"); + queryOfsSoSaleOutVo.setStatus(900L); + queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L); + 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采购入库单生成U8C采购订单 售后入库单号:{}", code); + logger.info(threadNameStrEnd); } /** @@ -159,9 +212,23 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { queryOfsSoSaleOutVo.setPageSize(pageSize); InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); - interfaceParamDto.setApi("ofs.shipment.search"); + interfaceParamDto.setApi("ofs.receipt.search"); interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); - ofsUnifiedService.unified(interfaceParamDto); + StockinOrderSearchResponse rertunGoodsRootBean = (StockinOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto); + if (rertunGoodsRootBean != null) { + if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) { + List stockinOrderList = rertunGoodsRootBean.getData(); + if (stockinOrderList != null && stockinOrderList.size() > 0) { + headerDetailsDtoList.addAll(stockinOrderList); + + //TODO OFS没有提供分页字段,等待开发 + } + } else { + logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); + } + } else { + logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); + } } /** @@ -203,6 +270,8 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { List poOrderSonDtos = queryBasicArchives(returnGoodHeaderDetailsDataDtoList); // 代理品牌采购业务流程 BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); + // 查询采购收发类别 + BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("102"); if (poOrderSonDtos != null && poOrderSonDtos.size() > 0) { for (int i = 0; i < poOrderSonDtos.size(); i++) { @@ -215,8 +284,10 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { BdCorpEntity bdCorpEntity = poOrderSonDto.getBdCorpEntity();//采购公司、收货公司 BdDeptdocEntity bdDeptdocEntity = poOrderSonDto.getBdDeptdocEntity();//采购部门 BdPurorgEntity bdPurorgEntity = poOrderSonDto.getBdPurorgEntity();//采购组织 - BdCubasdocEntity bdCubasdocEntity = poOrderSonDto.getBdCubasdocEntity(); - BdCumandocEntity bdCumandocEntity = poOrderSonDto.getBdCumandocEntity();//客商档案-供应商 + BdCubasdocEntity bdCubasdocEntity = poOrderSonDto.getBdCubasdocEntity();//客商基本档案-供应商 + BdCumandocEntity bdCumandocEntity = poOrderSonDto.getBdCumandocEntity();//客商管理档案-供应商 + BdCalbodyEntity bdCalbodyEntity = poOrderSonDto.getBdCalbodyEntity();//收货库存组织 + BdStordocEntity bdStordocEntity = poOrderSonDto.getBdStordocEntity();//收货仓库 OfsPoOrderData ofsPoOrderData = poOrderSonDto.getOfsPoOrderData();//OFS采购订单 OfsPoOrderHeader ofsPoOrderDataHeader = ofsPoOrderData.getHeader(); @@ -233,42 +304,82 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { poOrderParentDto.setDauditdate(generateBusinessDate);//审批日期 poOrderParentDto.setDorderdate(generateBusinessDate);//订单日期 poOrderParentDto.setDrevisiondate(generateBusinessDate);//修改日期 + //2024年8月21日 13:34:07 对比了手工建单和接口传单,发现接口传单少了这个:是否由销售订单协同生成、补货标志、是否已协同生成销售订单 默认为N + poOrderParentDto.setBsocooptome(false);//是否由销售订单协同生成 + poOrderParentDto.setBisreplenish(false);//补货标志 + poOrderParentDto.setBcooptoso(false);//是否已协同生成销售订单 + poOrderParentDto.setCgiveinvoicevendor(bdCumandocEntity.getPkCumandoc());//发票方id + + poOrderParentDto.setVdef17(ProfilesActiveConstant.sourceSystem1);//来源系统 + poOrderParentDto.setVdef19(poOrderSonDto.getCode());//原单单号 + poOrderParentDto.setVdef20(poOrderSonDto.getId());//原单主键 + + //收发类别 +// poOrderParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl()); +// poOrderParentDto.setVdef3(bdRdclEntity.getRdname()); //采购订单明细行 List poOrderChildrenDtoList = new ArrayList<>(); for (int j = 0; j < details.size(); j++) { StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); + OfsPoOrderDetails ofsPoOrderDetail = findOfsPoOrderDetail(ofsPoOrderDataDetails, stockinB); + + //TODO 测试 + stockinB.setReceivedQty("1"); + ofsPoOrderDetail.setFulfillAmount("10"); //2024年8月20日 16:02:21 已经和妮姐、万万确认,采购公司和收货公司目前是一致的,暂时不用区分取数逻辑 BdInvmandocEntity bdInvmandocEntity = queryInventoryMan(stockinB, bdCorpEntity.getPkCorp()); String receivedQty = stockinB.getReceivedQty();//实收数量 + String fulfillAmount = ofsPoOrderDetail.getFulfillAmount();//实收累计总金额 //原币含税单价 + BigDecimal noriginalcurprice = null; try { -// noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); + 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()); } - PoOrderChildrenDto poOrderChildrenDto = new PoOrderChildrenDto(); poOrderChildrenDto.setCmangid(bdInvmandocEntity.getPkInvmandoc());//存货管理id poOrderChildrenDto.setNordernum(receivedQty);//订货数量 -// poOrderChildrenDto.setNorgtaxprice();//原币含税单价 -// poOrderChildrenDto.setPk_arrvcorp();//收货公司 -// poOrderChildrenDto.setPk_arrvstoorg();//收货库存组织 -// poOrderChildrenDto.setCwarehouseid();//收货仓库 + poOrderChildrenDto.setNorgtaxprice(noriginalcurprice.stripTrailingZeros().toPlainString());//原币含税单价 + poOrderChildrenDto.setPk_arrvcorp(bdCorpEntity.getPkCorp());//收货公司 + poOrderChildrenDto.setPk_arrvstoorg(bdCalbodyEntity.getPkCalbody());//收货库存组织 + poOrderChildrenDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//收货仓库 + poOrderChildrenDto.setPk_reqcorp(bdCorpEntity.getPkCorp());//需求公司 * +// poOrderChildrenDto.setIisreplenish(false);//补货标识 * + poOrderChildrenDto.setCoperator("0001A110000000000U3D");//操作员id +// poOrderChildrenDto.setBreceiveplan(false);//存在到货计划 poOrderChildrenDtoList.add(poOrderChildrenDto); //2024年8月20日 16:00:03 已经和佳妮总确认,计划到货日期,不用进行传递 } + List poOrderParentChildrenDtoList = new ArrayList<>(); PoOrderParentChildrenDto poOrderParentChildrenDto = new PoOrderParentChildrenDto(); poOrderParentChildrenDto.setParentvo(poOrderParentDto); poOrderParentChildrenDto.setChildrenvo(poOrderChildrenDtoList); + poOrderParentChildrenDtoList.add(poOrderParentChildrenDto); + Map> stringStringMap = new HashMap<>(); + stringStringMap.put("puordervo", poOrderParentChildrenDtoList); + PoOrderHeadBodyDto poOrderHeadBodyDto = sendU8CPoOrder(JSON.toJSONString(stringStringMap)); + + String corderid = null; + String vordercode = null; + PoOrderHeadDto parentvo = poOrderHeadBodyDto.getParentvo(); + List childrenvo = poOrderHeadBodyDto.getChildrenvo(); + if (parentvo != null) { + corderid = parentvo.getCorderid(); + } + if (childrenvo != null) { + vordercode = parentvo.getVordercode(); + } + logger.info("推送U8C代理品牌采购订单采购!U8C采购订单主键:{} U8C采购订单编码:{}", corderid, vordercode); } } else { logger.info("poOrderSonDto.size为0!"); @@ -338,6 +449,8 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { //2024年8月20日 14:47:55 丽知商城、OFS 供应商客商档案、传递到U8C的客商, //其中自定义项1作为原系统编码,因此统一传到自定义项一,已经和大家确认好了,没有关系的,放心大胆传吧,宝贝 String shipFromCode = header.getShipFromCode(); + Assert.notNull(shipFromCode, "O供应商编码不能为空,没有办法完成业务逻辑,请配置供应商编码"); + Assert.state(!"".equals(shipFromCode.trim()), "O供应商编码不能为空,没有办法完成业务逻辑,请配置供应商编码!"); BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); bdCubasdocEntity.setDataSourceCode("lets_u8c"); bdCubasdocEntity.setDr(0L); @@ -363,6 +476,33 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); } + // 2024年8月20日 23:51:56 收货库存组织,应该是通过收货公司查询得出收货库存组织,目前收货公司和采购公司保持一致,那么就以采购公司带出!这个逻辑已经和佳妮确认 + 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()); + } + //查询OFS采购订单 OfsPoOrderData ofsPoOrderData = queryOfsPoOrder(header.getRefOrderCode()); @@ -373,8 +513,11 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { poOrderSonDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0)); poOrderSonDto.setBdCumandocEntity(bdCumandocEntityList.get(0)); poOrderSonDto.setOfsPoOrderData(ofsPoOrderData); + poOrderSonDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); + poOrderSonDto.setBdStordocEntity(bdStordocEntityList.get(0)); + poOrderSonDto.setDetails(details); - BeanUtil.copyPropertiesV2(poOrderSonDto, header); + BeanUtil.copyPropertiesV2(header, poOrderSonDto); poOrderSonDtoArrayList.add(poOrderSonDto); } //成功 @@ -409,6 +552,8 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { * @author liuyang */ private String createGenerateBusinessDate(PoOrderSonDto poOrderSonDto) { + //TODO 测试 + poOrderSonDto.setShipAt("2024-08-19"); if (poOrderSonDto != null && poOrderSonDto.getShipAt() != null) { String shipAt = poOrderSonDto.getShipAt(); String businessFormat = null; @@ -492,14 +637,91 @@ public class ProxyPurchaseReturn extends PluginBaseEntity { * 查找对应的采购订单明细行 * 2024年8月20日 17:42:15 * 应该通过明细行主键匹配,但是只能根据sku匹配目前的实现逻辑 + * 查找OFS采购订单明细行,主要是为了带出实付金额,通过实付金额/实收数量=含税单价 * * @param ofsPoOrderDataDetails OFS采购订单明细行所有对象 * @param stockinB OFS采购入库单明细行对象 * @author liuyang */ - private void findOfsPoOrderDetail(List ofsPoOrderDataDetails, StockinOrderSearchResponse.StockinOrder.StockinB stockinB) { + private OfsPoOrderDetails findOfsPoOrderDetail(List ofsPoOrderDataDetails, StockinOrderSearchResponse.StockinOrder.StockinB stockinB) { if (ofsPoOrderDataDetails != null && ofsPoOrderDataDetails.size() > 0 && stockinB != null) { - + // 2024年8月20日 23:33:11 先使用sku验证,然后O接口更新明细id,使用明细id匹配! + // 2024年8月20日 23:36:04 使用sku匹配,在某种角度来说是错误的 + // 2024年8月21日 14:23:02 O接口已经返回明细行主键,根据这个匹配 + for (int i = 0; i < ofsPoOrderDataDetails.size(); i++) { + Assert.notNull(ofsPoOrderDataDetails.get(i).getId(), "采购订单明细行主键不能为空!"); + Assert.notNull(stockinB.getRefOrderDetailId(), "采购入库单明细行对应的关联采购订单的明细行主键不能为空!"); + if (ofsPoOrderDataDetails.get(i).getId().equals(stockinB.getRefOrderDetailId())) { + return ofsPoOrderDataDetails.get(0); + } + } + } else { + logger.error("findOfsPoOrderDetail方法对应的ofsPoOrderDataDetails不能为空!否则业务目标无法完成!"); } + Assert.state(false, "无法匹配到采购订单明细行,业务逻辑无法完成,根据sku编码:{}查找,但是在采购订单中无法匹配!", stockinB.getSkuCode()); + return null; + } + + /** + * 2024年8月20日 23:58:13 + * 推送U8C采购订单 + * + * @author liuyang + */ + public PoOrderHeadBodyDto sendU8CPoOrder(String param) throws Exception { + long startLong = System.currentTimeMillis(); + logger.info("代理品牌采购推送开始,推送参数:" + 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", "8000370004")//头信息,多个头信息多次调用此方法即可 + .header("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可 + .header("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可 + .body(param)//表单内容 + .timeout(20000)//超时,毫秒 + .execute().body(); + logger.info("代理品牌采购推送结束,返回参数:" + result); + long endLong = System.currentTimeMillis(); + logger.info("U8C采购订单接口请求耗时:" + (endLong - startLong)); + + //2024年8月21日 13:17:57 如果结果返回为null,则赋予"",后面的处理逻辑能满足需求 + if (result == null) { + result = ""; + } + + JSONObject jsonObject = JSON.parseObject(result); + result = String.valueOf(jsonObject.get("attribute")); + + boolean isSuccess = false; + PoOrderHeadBodyDto poOrderHeadBodyDto = null; + if (result != null && !"".equals(result)) { + ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class); + if ("success".equals(reusltStrDto.getStatus())) { + poOrderHeadBodyDto = resultDataHandle(reusltStrDto.getData()); + isSuccess = true; + } + } + if (!isSuccess) { + Assert.state(false, "代理品牌采购业务推送U8C采购订单失败 接口返回结果:{}", result); + } + return poOrderHeadBodyDto; + } + + /** + * 返回结果解析处理,在确认了success后调用 + * + * @author liuyang + */ + private PoOrderHeadBodyDto resultDataHandle(String resultData) { + try { + if (resultData != null && !"".equals(resultData)) { + if (resultData.contains("[")) { + resultData = resultData.substring(1, resultData.length() - 1); + } + return JSON.parseObject(resultData, PoOrderHeadBodyDto.class); + } + } catch (Exception e) { + logger.error("resultDataHandle方法解析返回参数失败的错误", e); + //如果解析失败,记录原因,但是不能影响结果的记录 + } + return null; } } \ No newline at end of file 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 464da2e0..87cfa0fc 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 @@ -14,6 +14,7 @@ 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.QueryBdBusitypeUtil; +import com.hzya.frame.plugin.lets.util.RdclUtil; import com.hzya.frame.ttxofs.dto.InterfaceParamDto; import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderBean; import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderData; @@ -73,6 +74,9 @@ public class ProxyPurchaseWarehous extends PluginBaseEntity { @Autowired private IBdStordocDao iBdStordocDao; + @Autowired + private RdclUtil rdclUtil; + @Override public void initialize() { logger.info(getPluginLabel() + "執行初始化方法initialize()"); @@ -114,8 +118,8 @@ public class ProxyPurchaseWarehous extends PluginBaseEntity { * @author liuyang */ public void startImplement(String startTime, String endTime) { - String threadNameStr = StrUtil.format("(代理品牌采购)OFS采购入库单生成U8C采购订单 售后入库单号", startTime, endTime); - logger.info(threadNameStr); + String threadNameStrStart = StrUtil.format("开始(代理品牌采购)OFS采购入库单生成U8C采购订单 开始时间:{} 结束时间:{}", startTime, endTime); + logger.info(threadNameStrStart); Thread thread = new Thread(new Runnable() { @Override @@ -142,13 +146,15 @@ public class ProxyPurchaseWarehous extends PluginBaseEntity { logger.error("startImplement方法抛出异常", e); } } - }, threadNameStr); + }, threadNameStrStart); thread.start(); try { thread.join(); } catch (Exception e) { logger.error("thread.join()异常", e); } + String threadNameStrEnd = StrUtil.format("结束(代理品牌采购)OFS采购入库单生成U8C采购订单 开始时间:{} 结束时间:{}", startTime, endTime); + logger.info(threadNameStrEnd); } /** @@ -263,6 +269,8 @@ public class ProxyPurchaseWarehous extends PluginBaseEntity { List poOrderSonDtos = queryBasicArchives(returnGoodHeaderDetailsDataDtoList); // 代理品牌采购业务流程 BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); + // 查询采购收发类别 + BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("102"); if (poOrderSonDtos != null && poOrderSonDtos.size() > 0) { for (int i = 0; i < poOrderSonDtos.size(); i++) { @@ -305,6 +313,10 @@ public class ProxyPurchaseWarehous extends PluginBaseEntity { poOrderParentDto.setVdef19(poOrderSonDto.getCode());//原单单号 poOrderParentDto.setVdef20(poOrderSonDto.getId());//原单主键 + //收发类别 +// poOrderParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl()); +// poOrderParentDto.setVdef3(bdRdclEntity.getRdname()); + //采购订单明细行 List poOrderChildrenDtoList = new ArrayList<>(); 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 645c0461..8f6e848f 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 @@ -135,6 +135,9 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { @Autowired private ShopTobOrToCUtil shopTobOrToCUtil; + @Autowired + private OfsStandardUtil ofsStandardUtil; + /** * 按指定时间拉取 * @@ -163,7 +166,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { queryOfsSoSaleOutVo.setPageSize(50L); queryOfsSoSaleOutVo.setStoreCode(tobShop); // queryOfsSoSaleOutVo.setCode("LETS-SH2024010200000004"); - queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L); + ofsStandardUtil.queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L, "ofs.shipment.search"); logger.info("数据返回行数:{}", headerDetailsDtoList.size()); if (headerDetailsDtoList.size() > 0) { getSet(headerDetailsDtoList); @@ -208,7 +211,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { queryOfsSoSaleOutVo.setPageSize(50L); queryOfsSoSaleOutVo.setStoreCode(tobShop); queryOfsSoSaleOutVo.setCode(code); - queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L); + ofsStandardUtil.queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L, "ofs.shipment.search"); logger.info("根据根据号拉群:数据返回行数:{}", headerDetailsDtoList.size()); if (headerDetailsDtoList.size() > 0) { getSet(headerDetailsDtoList); @@ -302,40 +305,6 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { } } - /** - * 查询OFS结果集 - * - * @param queryOfsSoSaleOutVo 查询参数 - * @param headerDetailsDtoList 查询结果集 - * @param pageNo 从第pageNo页开始查询 - */ - private void queryOfsSaleOrder(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List headerDetailsDtoList, Long pageNo) throws Exception { - - Long pageSize = 200L; - queryOfsSoSaleOutVo.setPageNo(pageNo); - queryOfsSoSaleOutVo.setPageSize(pageSize); - - InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); - interfaceParamDto.setApi("ofs.shipment.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 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"); @@ -908,7 +877,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { return JSON.parseObject(resultData, SoSaleResultRootDto.class); } } catch (Exception e) { - e.printStackTrace(); +// e.printStackTrace(); logger.error("解析返回参数失败的错误", e); //如果解析失败,记录原因,但是不能影响结果的记录 } 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 9b710ffa..77773bef 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 @@ -18,10 +18,7 @@ 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.ShopTobOrToCUtil; -import com.hzya.frame.plugin.lets.util.TocOrderBasicArchivesCacheUtil; -import com.hzya.frame.plugin.lets.util.DateStrUtil; -import com.hzya.frame.plugin.lets.util.QueryBdBusitypeUtil; +import com.hzya.frame.plugin.lets.util.*; import com.hzya.frame.split.SplitListByCountUtil; import com.hzya.frame.ttxofs.dto.InterfaceParamDto; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto; @@ -108,6 +105,9 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { @Autowired private ShopTobOrToCUtil shopTobOrToCUtil; + @Autowired + private OfsStandardUtil ofsStandardUtil; + /** * 按指定时间拉取 * @@ -136,7 +136,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { queryOfsSoSaleOutVo.setPageSize(50L); queryOfsSoSaleOutVo.setStoreCode(tobShop); // queryOfsSoSaleOutVo.setCode("LETS-SH2024070500000003"); - queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L); + ofsStandardUtil.queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L, "ofs.shipment.search"); logger.info("数据返回行数:{}", headerDetailsDtoList.size()); if (headerDetailsDtoList.size() > 0) { getSet(headerDetailsDtoList); @@ -188,7 +188,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { queryOfsSoSaleOutVo.setPageSize(50L); queryOfsSoSaleOutVo.setStoreCode(tobShop); queryOfsSoSaleOutVo.setCode(code); - queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L); + ofsStandardUtil.queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L, "ofs.shipment.search"); logger.info("数据返回行数:{}", headerDetailsDtoList.size()); if (headerDetailsDtoList.size() > 0) { getSet(headerDetailsDtoList); @@ -296,32 +296,32 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { * @param headerDetailsDtoList 查询结果集 * @param pageNo 从第pageNo页开始查询 */ - private void queryOfsSaleOrder(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List headerDetailsDtoList, Long pageNo) throws Exception { - - Long pageSize = 200L; - queryOfsSoSaleOutVo.setPageNo(pageNo); - queryOfsSoSaleOutVo.setPageSize(pageSize); - - InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); - interfaceParamDto.setApi("ofs.shipment.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 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)); - } - } +// private void queryOfsSaleOrder(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List headerDetailsDtoList, Long pageNo) throws Exception { +// +// Long pageSize = 200L; +// queryOfsSoSaleOutVo.setPageNo(pageNo); +// queryOfsSoSaleOutVo.setPageSize(pageSize); +// +// InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); +// interfaceParamDto.setApi("ofs.shipment.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 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(); 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 e398a93e..8761a379 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 @@ -134,6 +134,9 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { @Autowired private OffsetTimeTime offsetTimeTime; + @Autowired + private OfsStandardUtil ofsStandardUtil; + /** * 按指定时间拉取 * @@ -162,7 +165,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { queryOfsSoSaleOutVo.setStoreCode(tobShop); queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); // queryOfsSoSaleOutVo.setCode("LETS-RE2024081900000001"); - queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L); + ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search"); logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { getSet(returnGoodHeaderDetailsDataDtoArrayList); @@ -210,7 +213,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { queryOfsSoSaleOutVo.setStoreCode(tobShop); queryOfsSoSaleOutVo.setCode(code); queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); - queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L); + ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search"); logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { getSet(returnGoodHeaderDetailsDataDtoArrayList); @@ -309,38 +312,6 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { } } - /** - * 查询OFS售后退货入库单 - * - * @param queryOfsSoSaleOutVo 查询参数 - * @param headerDetailsDtoList 查询结果集 - * @param pageNo 从第pageNo页开始查询 - */ - private void queryOfsReturnGoods(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List 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)); - StockinOrderSearchResponse rertunGoodsRootBean = (StockinOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto); - if (rertunGoodsRootBean != null) { - if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) { - List stockinOrderList = rertunGoodsRootBean.getData(); - if (stockinOrderList != null && stockinOrderList.size() > 0) { - headerDetailsDtoList.addAll(stockinOrderList); - - //TODO OFS没有提供分页字段,等待开发 - } - } else { - logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); - } - } else { - logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); - } - } - /** * 代码同步逻辑 * 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 9a19447e..aec64e02 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 @@ -17,16 +17,14 @@ import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsEntity; 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.ShopTobOrToCUtil; -import com.hzya.frame.plugin.lets.util.TocReturnBasicArchivesCacheUtil; -import com.hzya.frame.plugin.lets.util.DateStrUtil; -import com.hzya.frame.plugin.lets.util.QueryBdBusitypeUtil; +import com.hzya.frame.plugin.lets.util.*; import com.hzya.frame.split.SplitListByCountUtil; import com.hzya.frame.ttxofs.dto.InterfaceParamDto; import com.hzya.frame.ttxofs.dto.returngoodsearch.RertunGoodsRootBean; import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodHeaderDetailsDataDto; import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodSearchDetailsDto; import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodSearchHeaderDto; +import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; import com.hzya.frame.ttxofs.service.OfsUnifiedService; import com.hzya.frame.web.entity.JsonResultEntity; import org.slf4j.Logger; @@ -107,6 +105,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { @Autowired private ShopTobOrToCUtil shopTobOrToCUtil; + @Autowired + private OfsStandardUtil ofsStandardUtil; + /** * 按指定时间拉取 * @@ -124,13 +125,13 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); CalculateDateVo calculateDateVo = DateStrUtil.calculateCalculateEntireDayPeriod(dateStr); - List returnGoodHeaderDetailsDataDtoList = new ArrayList<>(); - + List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); queryOfsSoSaleOutVo.setCreated_start(calculateDateVo.getStart_time()); queryOfsSoSaleOutVo.setCreated_end(calculateDateVo.getEnd_time()); queryOfsSoSaleOutVo.setClientCode("LETS"); queryOfsSoSaleOutVo.setInternalInstructionType("SALES"); + //2024年8月22日 14:02:13 已经和O确认,这个字段取消传递! // queryOfsSoSaleOutVo.setCompanyCode("SHLZ"); queryOfsSoSaleOutVo.setStatus(900L); queryOfsSoSaleOutVo.setPageNo(1L); @@ -138,10 +139,10 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { queryOfsSoSaleOutVo.setStoreCode(tocShop); queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); // queryOfsSoSaleOutVo.setCode("LETS-RE2024071600000001"); - queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoList, 1L); - logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoList.size()); - if (returnGoodHeaderDetailsDataDtoList.size() > 0) { - getSet(returnGoodHeaderDetailsDataDtoList); + ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search"); + logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); + if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { + getSet(returnGoodHeaderDetailsDataDtoArrayList); } else { logger.info("没有查询到任何数据!不需要同步"); } @@ -181,7 +182,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { try { String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); - List returnGoodHeaderDetailsDataDtoList = new ArrayList<>(); + List returnGoodHeaderDetailsDataDtoList = new ArrayList<>(); QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); queryOfsSoSaleOutVo.setClientCode("LETS"); queryOfsSoSaleOutVo.setInternalInstructionType("SALES"); @@ -191,7 +192,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { queryOfsSoSaleOutVo.setStoreCode(tocShop); queryOfsSoSaleOutVo.setCode(code); queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); - queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoList, 1L); + ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoList, 1L, "ofs.receipt.search"); logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoList.size()); if (returnGoodHeaderDetailsDataDtoList.size() > 0) { getSet(returnGoodHeaderDetailsDataDtoList); @@ -223,13 +224,13 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private void getSet(List returnGoodHeaderDetailsDataDtoList) throws Exception { + private void getSet(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { //保存到mysql - batchInsert(returnGoodHeaderDetailsDataDtoList); + batchInsert(returnGoodHeaderDetailsDataDtoArrayList); //过滤成功的数据 - List returnGoodHeaderDetailsDataDtoList1 = filterData(returnGoodHeaderDetailsDataDtoList); + List stockinOrderList = filterData(returnGoodHeaderDetailsDataDtoArrayList); //执行推送主逻辑 - implement(returnGoodHeaderDetailsDataDtoList1); + implement(stockinOrderList); } /** @@ -237,11 +238,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private List filterData(List returnGoodHeaderDetailsDataDtoList) { - List headerDetailsDtoList1 = new ArrayList<>(); - if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { + private List filterData(List returnGoodHeaderDetailsDataDtoArrayList) { + List headerDetailsDtoList1 = new ArrayList<>(); + if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { //TODO 出库单明细主键,需要O返回,目前没有,已经提需求 - headerDetailsDtoList1.addAll(returnGoodHeaderDetailsDataDtoList); + headerDetailsDtoList1.addAll(returnGoodHeaderDetailsDataDtoArrayList); } return headerDetailsDtoList1; } @@ -249,20 +250,20 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { /** * 保存抓取到的数据到mysql底表,如果底表里已经存在,则会忽略 * - * @param returnGoodHeaderDetailsDataDtoList 数据行 + * @param returnGoodHeaderDetailsDataDtoArrayList mysql数据行 */ - private void batchInsert(List returnGoodHeaderDetailsDataDtoList) throws Exception { - if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { - List headerDetailsDtoList1 = new ArrayList<>(); - List headerDetailsDtoList2 = new ArrayList<>(); + private void batchInsert(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { + if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { + List headerDetailsDtoList1 = new ArrayList<>(); + List headerDetailsDtoList2 = new ArrayList<>(); - for (ReturnGoodHeaderDetailsDataDto index : returnGoodHeaderDetailsDataDtoList) { - ReturnGoodSearchHeaderDto header = index.getHeader();// 主表 - List details = index.getDetails();//明细表 + for (StockinOrderSearchResponse.StockinOrder index : returnGoodHeaderDetailsDataDtoArrayList) { + StockinOrderSearchResponse.StockinOrder.StockinH header = index.getHeader();// 主表 + List details = index.getDetails();//明细表 for (int i = 0; i < details.size(); i++) { - ReturnGoodSearchDetailsDto returnGoodSearchDetailsDto = details.get(i); - returnGoodSearchDetailsDto.setReturnGoodSearchHeaderDto(header); + StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(i); + stockinB.setReturnGoodSearchHeaderDto(header); } headerDetailsDtoList1.add(header); @@ -270,10 +271,10 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { } //每250作为一个批次插入主表,根据主键(id)判断是否重复,如果重复的,则不进行插入 - List> lists = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 100); + List> lists = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 100); for (int i = 0; i < lists.size(); i++) { - List returnGoodSearchHeaderDtos = lists.get(i); - List tocofsReturngoodsEntities = copyHeaderDto(returnGoodSearchHeaderDtos); + List stockinHS = lists.get(i); + List tocofsReturngoodsEntities = copyHeaderDto(stockinHS); if (tocofsReturngoodsEntities.size() > 0) { logger.info("插入底表{}个对象(表头)", tocofsReturngoodsEntities.size()); iTocofsReturngoodsDao.entityInsertBatchV2(tocofsReturngoodsEntities); @@ -283,10 +284,10 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { } //插入明细表 - List> lists1 = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 100); + List> lists1 = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 100); for (int i = 0; i < lists1.size(); i++) { - List returnGoodSearchDetailsDtos = lists1.get(i); - List tocofsReturngoodsDetailedEntities = copyDetailsDto(returnGoodSearchDetailsDtos); + List stockinBS = lists1.get(i); + List tocofsReturngoodsDetailedEntities = copyDetailsDto(stockinBS); if (tocofsReturngoodsDetailedEntities.size() > 0) { logger.info("插入底表{}个对象(表体)", tocofsReturngoodsDetailedEntities.size()); iTocofsReturngoodsDetailedDao.entityInsertBatchV2(tocofsReturngoodsDetailedEntities); @@ -304,31 +305,31 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * @param headerDetailsDtoList 查询结果集 * @param pageNo 从第pageNo页开始查询 */ - private void queryOfsReturnGoods(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List 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)); - RertunGoodsRootBean rertunGoodsRootBean = (RertunGoodsRootBean) ofsUnifiedService.unified(interfaceParamDto); - if (rertunGoodsRootBean != null) { - if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) { - List returnGoodHeaderDetailsDataDtoList = rertunGoodsRootBean.getData(); - if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { - headerDetailsDtoList.addAll(returnGoodHeaderDetailsDataDtoList); - - //TODO OFS没有提供分页字段,等待开发 - } - } else { - logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); - } - } else { - logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); - } - } +// private void queryOfsReturnGoods(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List 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)); +// RertunGoodsRootBean rertunGoodsRootBean = (RertunGoodsRootBean) ofsUnifiedService.unified(interfaceParamDto); +// if (rertunGoodsRootBean != null) { +// if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) { +// List returnGoodHeaderDetailsDataDtoList = rertunGoodsRootBean.getData(); +// if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { +// headerDetailsDtoList.addAll(returnGoodHeaderDetailsDataDtoList); +// +// //TODO OFS没有提供分页字段,等待开发 +// } +// } else { +// logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); +// } +// } else { +// logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); +// } +// } // public void queryOfsSaleOrder() throws Exception { // QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); @@ -352,10 +353,10 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { /** * 代码同步逻辑 * - * @param returnGoodHeaderDetailsDataDtoList1 查询得到的O出库单对象 + * @param returnGoodHeaderDetailsDataDtoList1 查询得到的O售后入库单对象 * @author liuyang */ - private void implement(List returnGoodHeaderDetailsDataDtoList1) throws Exception { + private void implement(List returnGoodHeaderDetailsDataDtoList1) throws Exception { if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { try { // 查询基本档案 @@ -372,7 +373,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { String keyGroup = entry.getKey(); List oldValue = entry.getValue(); - ReturnGoodSearchHeaderDto header = oldValue.get(0).getHeader(); + StockinOrderSearchResponse.StockinOrder.StockinH header = oldValue.get(0).getHeader(); BdCorpEntity bdCorpEntity = oldValue.get(0).getBdCorpEntity();//表头销售公司 BdCorpEntity deliverGoodsCorp = oldValue.get(0).getDeliverGoodsCorp();//发货公司 BdCalbodyEntity bdCalbodyEntity = oldValue.get(0).getBdCalbodyEntity();//发货仓库组织 @@ -511,7 +512,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private String createGenerateBusinessDate(ReturnGoodSearchHeaderDto header) { + private String createGenerateBusinessDate(StockinOrderSearchResponse.StockinOrder.StockinH header) { if (header != null && header.getCheckInTo() != null) { //TOC以出库日期作为业务日期 String checkInTo = header.getCheckInTo(); @@ -532,11 +533,12 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { } /** - * 档案转换 + * 档案转换(OFS->U8C) * + * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单对象 * @author liuyang */ - private List queryBasicArchives(List returnGoodHeaderDetailsDataDtoList1) { + private List queryBasicArchives(List returnGoodHeaderDetailsDataDtoList1) { List sonDetailsDtoList = new ArrayList<>(); if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { @@ -545,9 +547,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { tocReturnBasicArchivesCacheUtil.initCache(); for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { - ReturnGoodHeaderDetailsDataDto returnGoodHeaderDetailsDataDto = returnGoodHeaderDetailsDataDtoList1.get(i); - ReturnGoodSearchHeaderDto header = returnGoodHeaderDetailsDataDto.getHeader(); - List details = returnGoodHeaderDetailsDataDto.getDetails(); + StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoList1.get(i); + StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); + List details = stockinOrder.getDetails(); //表头公司:通过名称匹配U8C公司 // String corpName = "上海丽知品牌管理有限公司"; @@ -606,7 +608,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //字段拷贝 for (int j = 0; j < details.size(); j++) { - ReturnGoodSearchDetailsDto returnGoodSearchDetailsDto = details.get(j); + StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); //2024年8月6日 10:16:22 通过O出库单的表头,查询得出U8C档案,放在表体的原因是方便分组汇总 //下一个步骤的分组汇总,是通过表体明细完成的 @@ -624,7 +626,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { goodsRertunSonDetailsDto.setBdCubasdocEntity(bdCubasdocEntity); goodsRertunSonDetailsDto.setPlatformArchives(bdDefdocEntity); - BeanUtil.copyPropertiesV2(returnGoodSearchDetailsDto, goodsRertunSonDetailsDto); + BeanUtil.copyPropertiesV2(stockinB, goodsRertunSonDetailsDto); sonDetailsDtoList.add(goodsRertunSonDetailsDto); } } @@ -640,41 +642,40 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { } /** - * bean copy + * 对象拷贝 bean copy * 2024年8月9日 11:23:57 */ - private List copyHeaderDto(List returnGoodSearchHeaderDtos) { + private List copyHeaderDto(List stockinHS) { List tocofsReturngoodsEntityArrayList = new ArrayList<>(); - if (returnGoodSearchHeaderDtos != null && returnGoodSearchHeaderDtos.size() > 0) { - for (int i = 0; i < returnGoodSearchHeaderDtos.size(); i++) { - ReturnGoodSearchHeaderDto headerDto = returnGoodSearchHeaderDtos.get(i); + if (stockinHS != null && stockinHS.size() > 0) { + for (int i = 0; i < stockinHS.size(); i++) { + StockinOrderSearchResponse.StockinOrder.StockinH stockinH = stockinHS.get(i); TocofsReturngoodsEntity tocofsReturngoodsEntity = new TocofsReturngoodsEntity(); - BeanUtil.copyPropertiesV2(headerDto, tocofsReturngoodsEntity); + BeanUtil.copyPropertiesV2(stockinH, tocofsReturngoodsEntity); tocofsReturngoodsEntityArrayList.add(tocofsReturngoodsEntity); } } else { - logger.info("需要复制{}个bean对象(O表头)", returnGoodSearchHeaderDtos.size()); + logger.info("需要复制{}个bean对象(O表头)", stockinHS.size()); } return tocofsReturngoodsEntityArrayList; } /** - * bean copy + * 对象拷贝 bean copy * 2024年8月9日 11:24:01 */ - private List copyDetailsDto(List headerDetailsDtoList2) { + private List copyDetailsDto(List stockinBS) { List tocofsSaleoutDetailedEntityArrayList = new ArrayList<>(); - if (headerDetailsDtoList2 != null && headerDetailsDtoList2.size() > 0) { - for (int i = 0; i < headerDetailsDtoList2.size(); i++) { - ReturnGoodSearchDetailsDto returnGoodSearchDetailsDto = headerDetailsDtoList2.get(i); + if (stockinBS != null && stockinBS.size() > 0) { + for (int i = 0; i < stockinBS.size(); i++) { + StockinOrderSearchResponse.StockinOrder.StockinB stockinB = stockinBS.get(i); //表头 - ReturnGoodSearchHeaderDto returnGoodSearchHeaderDto = returnGoodSearchDetailsDto.getReturnGoodSearchHeaderDto(); + StockinOrderSearchResponse.StockinOrder.StockinH returnGoodSearchHeaderDto = stockinB.getReturnGoodSearchHeaderDto(); TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); -// tocofsReturngoodsDetailedEntity.setBusinessType("TOC_RETURN"); - BeanUtil.copyPropertiesV2(returnGoodSearchDetailsDto, tocofsReturngoodsDetailedEntity); + BeanUtil.copyPropertiesV2(stockinB, tocofsReturngoodsDetailedEntity); createPrimaryKeyAndBusinessDateAndBusinessType(tocofsReturngoodsDetailedEntity, returnGoodSearchHeaderDto); tocofsSaleoutDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity); } @@ -694,7 +695,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { for (int i = 0; i < goodsRertunSonDetailsDtos.size(); i++) { GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = goodsRertunSonDetailsDtos.get(i); //2024年8月6日 10:35:25表头对象用于带出表头相关的分组汇总信息 - ReturnGoodSearchHeaderDto header = goodsRertunSonDetailsDto.getHeader(); + StockinOrderSearchResponse.StockinOrder.StockinH header = goodsRertunSonDetailsDto.getHeader(); //公司 BdCorpEntity bdCorpEntity = goodsRertunSonDetailsDto.getBdCorpEntity(); @@ -925,8 +926,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { /** * 填充主表主键、业务日期、业务类型 * 2024年8月15日 17:31:54 + * + * @param tocofsReturngoodsDetailedEntity dao明细行对象 + * @param returnGoodSearchHeaderDto OFS售后入库单表头对象 */ - private void createPrimaryKeyAndBusinessDateAndBusinessType(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity, ReturnGoodSearchHeaderDto returnGoodSearchHeaderDto) { + private void createPrimaryKeyAndBusinessDateAndBusinessType(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity, StockinOrderSearchResponse.StockinOrder.StockinH returnGoodSearchHeaderDto) { if (tocofsReturngoodsDetailedEntity != null && returnGoodSearchHeaderDto != null) { tocofsReturngoodsDetailedEntity.setPrimaryKey(tocofsReturngoodsDetailedEntity.getId());//主表主键 tocofsReturngoodsDetailedEntity.setBusinessDate(returnGoodSearchHeaderDto.getCheckInFrom());//业务日期 diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/GoodsRertunSonDetailsDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/GoodsRertunSonDetailsDto.java index ceb512c4..05c735b5 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/GoodsRertunSonDetailsDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/GoodsRertunSonDetailsDto.java @@ -4,6 +4,7 @@ import com.hzya.frame.plugin.lets.entity.*; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto; import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodSearchDetailsDto; import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodSearchHeaderDto; +import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; import lombok.Data; import java.math.BigDecimal; @@ -17,12 +18,12 @@ import java.math.BigDecimal; * @Filename:SonDetailsDto */ @Data -public class GoodsRertunSonDetailsDto extends ReturnGoodSearchDetailsDto { +public class GoodsRertunSonDetailsDto extends StockinOrderSearchResponse.StockinOrder.StockinB { /** * 表头对象 */ - private ReturnGoodSearchHeaderDto header; + private StockinOrderSearchResponse.StockinOrder.StockinH header; /** * 表头公司(销售公司) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java new file mode 100644 index 00000000..5fea364a --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java @@ -0,0 +1,114 @@ +package com.hzya.frame.plugin.lets.util; + +import cn.hutool.core.lang.Assert; +import com.alibaba.fastjson.JSON; +import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; +import com.hzya.frame.ttxofs.dto.InterfaceParamDto; +import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto; +import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.SaleOutReturnMessageDto; +import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; +import com.hzya.frame.ttxofs.service.OfsUnifiedService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * OFS标准接口查询,业务区分类 + * + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.util + * @Project:kangarooDataCenterV3 + * @name:OfsStandardUtil + * @Date:2024/8/22 13:30 + * @Filename:OfsStandardUtil + */ +@Component +public class OfsStandardUtil { + + Logger logger = LoggerFactory.getLogger(OfsStandardUtil.class); + + @Autowired + private OfsUnifiedService ofsUnifiedService; + + /** + * OFS出库单查询 + * + * @param queryOfsSoSaleOutVo 接口查询入参 + * @param headerDetailsDtoList 收集对象 + * @param pageNo 从第几页开始查询 + * @param api api接口名称 + * @author liuyang + */ + public void queryOfsSaleOrder(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List headerDetailsDtoList, Long pageNo, String api) throws Exception { + Assert.notNull(queryOfsSoSaleOutVo, "queryOfsSoSaleOutVo不能为空!"); + Assert.notNull(headerDetailsDtoList, "headerDetailsDtoList不能为空"); + Assert.notNull(pageNo, "pageNo不能为空"); + Assert.notNull(api, "api不能为空"); + + Long pageSize = 200L; + queryOfsSoSaleOutVo.setPageNo(pageNo); + queryOfsSoSaleOutVo.setPageSize(pageSize); + + InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); + interfaceParamDto.setApi(api); + 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 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)); + } + } + + /** + * OFS入库单查询 + * + * @param queryOfsSoSaleOutVo 接口入参 + * @param headerDetailsDtoList 收集对象 + * @param pageNo 从第几页开始查询 + * @param api api接口名称 + * @author liuyang + */ + public void queryOfsReturnGoods(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List headerDetailsDtoList, Long pageNo, String api) throws Exception { + Assert.notNull(queryOfsSoSaleOutVo, "queryOfsSoSaleOutVo不能为空!"); + Assert.notNull(headerDetailsDtoList, "headerDetailsDtoList不能为空"); + Assert.notNull(pageNo, "pageNo不能为空"); + Assert.notNull(api, "api不能为空"); + + Long pageSize = 200L; + queryOfsSoSaleOutVo.setPageNo(pageNo); + queryOfsSoSaleOutVo.setPageSize(pageSize); + + InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); + interfaceParamDto.setApi(api); + interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); + StockinOrderSearchResponse rertunGoodsRootBean = (StockinOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto); + if (rertunGoodsRootBean != null) { + if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) { + List stockinOrderList = rertunGoodsRootBean.getData(); + if (stockinOrderList != null && stockinOrderList.size() > 0) { + headerDetailsDtoList.addAll(stockinOrderList); + + //TODO OFS没有提供分页字段,等待开发 + } + } else { + logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); + } + } else { + logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); + } + } +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/RdclUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/RdclUtil.java new file mode 100644 index 00000000..f0b1f3bd --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/RdclUtil.java @@ -0,0 +1,46 @@ +package com.hzya.frame.plugin.lets.util; + +import cn.hutool.core.lang.Assert; +import com.hzya.frame.plugin.lets.dao.IBdRdclDao; +import com.hzya.frame.plugin.lets.entity.BdRdclEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.util + * @Project:kangarooDataCenterV3 + * @name:RdclUtil + * @Date:2024/8/21 15:10 + * @Filename:RdclUtil + */ +@Component +public class RdclUtil { + + @Autowired + private IBdRdclDao iBdRdclDao; + + /** + * 查询收发类别 + * + * @author liuyang + */ + public BdRdclEntity queryRdClObject(String code) { + Assert.notNull(code, "收发类别编码不能为空"); + Assert.state(!"".equals(code.trim()), "收发类别编码不能为空"); + + BdRdclEntity bdRdclEntity = new BdRdclEntity(); + bdRdclEntity.setDr(0); + bdRdclEntity.setRdcode(code); + bdRdclEntity.setDataSourceCode("lets_u8c"); + List bdRdclEntityList = iBdRdclDao.query(bdRdclEntity); + if (bdRdclEntityList == null || bdRdclEntityList.size() == 0) { + Assert.state(false, "无法查询到U8C收发类别 收发类别编码:{}", code); + } else if (bdRdclEntityList.size() >= 2) { + Assert.state(false, "无询到{}个U8C收发类别,存在歧义 收发类别编码:{}", bdRdclEntityList.size(), code); + } + return bdRdclEntityList.get(0); + } +} diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java index fd3ce6fa..bb3396c1 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java @@ -32,7 +32,7 @@ public class SoSaleOutPluginInitializerToBTest { @Test public void startImplement() { // soSaleOutPluginInitializerToB.startImplement(null, null); - soSaleOutPluginInitializerToB.startImplement("LETS-SH2024010900000008"); + soSaleOutPluginInitializerToB.startImplement("LETS-SH2024082100000005"); // try { // SaleOrderMessageDto ofsOrder = afterSalesOrderUtil.getOfsOrder("LETS-SO2024081600000050"); diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/RdclUtilTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/RdclUtilTest.java new file mode 100644 index 00000000..ddbcfd42 --- /dev/null +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/RdclUtilTest.java @@ -0,0 +1,34 @@ +package com.hzya.frame.plugin.lets.util; + +import com.alibaba.fastjson.JSON; +import com.hzya.frame.WebappApplication; +import com.hzya.frame.plugin.lets.entity.BdRdclEntity; +import org.junit.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.Assert.*; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.util + * @Project:kangarooDataCenterV3 + * @name:RdclUtilTest + * @Date:2024/8/21 15:16 + * @Filename:RdclUtilTest + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WebappApplication.class) +public class RdclUtilTest { + + @Autowired + private RdclUtil rdclUtil; + + @Test + public void queryRdClObject() { + BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("203"); + System.out.println(JSON.toJSONString(bdRdclEntity)); + } +} \ No newline at end of file