From f57ea0b337a7682fc350d7afa33c35373460d413 Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Mon, 17 Jun 2024 15:24:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E5=A2=9E=E5=8A=A0=E6=9E=97?= =?UTF-8?q?=E6=B0=8F=E4=B8=8E=E8=80=81=E7=B3=BB=E7=BB=9F=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/vo/FactoryWarehouseBindVO.java | 8 + .../entity/FactoryWarehouseBindEntity.java | 10 ++ .../base/feign/FactoryDataBaseClient.java | 4 +- .../linsy/controller/OrderController.java | 3 +- .../linsy/mq/FactoryOrderListener.java | 11 +- .../linsy/pros/LinsyProperties.java | 15 ++ .../linsy/service/DeliveryNoteService.java | 4 +- .../service/impl/DeliveryNoteServiceImpl.java | 137 +++++++++++++++++- 8 files changed, 181 insertions(+), 11 deletions(-) diff --git a/blade-service-api/logpm-factory-data-base-api/src/main/java/com/logpm/factorydata/base/vo/FactoryWarehouseBindVO.java b/blade-service-api/logpm-factory-data-base-api/src/main/java/com/logpm/factorydata/base/vo/FactoryWarehouseBindVO.java index a9262c920..e7c35ed1e 100644 --- a/blade-service-api/logpm-factory-data-base-api/src/main/java/com/logpm/factorydata/base/vo/FactoryWarehouseBindVO.java +++ b/blade-service-api/logpm-factory-data-base-api/src/main/java/com/logpm/factorydata/base/vo/FactoryWarehouseBindVO.java @@ -21,6 +21,14 @@ public class FactoryWarehouseBindVO implements Serializable { * 仓库名称 */ private String warehouseName; + /** + * 老系统仓库id + */ + private Long oldWarehouseId; + /** + * 老系统仓库名称 + */ + private String oldWarehouseName; /** * 租户id */ diff --git a/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/entity/FactoryWarehouseBindEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/entity/FactoryWarehouseBindEntity.java index 08a601097..9b9c85767 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/entity/FactoryWarehouseBindEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/entity/FactoryWarehouseBindEntity.java @@ -40,6 +40,16 @@ public class FactoryWarehouseBindEntity extends BaseEntity { */ @ApiModelProperty(name = "仓库名称", notes = "") private String warehouseName; + /** + * 老系统仓库id + */ + @ApiModelProperty(name = "老系统仓库id", notes = "") + private Long oldWarehouseId; + /** + * 老系统仓库名称 + */ + @ApiModelProperty(name = "老系统仓库名称", notes = "") + private String oldWarehouseName; /** * 租户id */ diff --git a/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/feign/FactoryDataBaseClient.java b/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/feign/FactoryDataBaseClient.java index 9e2860d06..b9e3c7531 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/feign/FactoryDataBaseClient.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/feign/FactoryDataBaseClient.java @@ -35,7 +35,7 @@ public class FactoryDataBaseClient implements IFactoryDataBaseClient { public R getWarehouseByBrandAndSiteName(String brand, String siteName) { String rediskey = FactoryDatabaseConstants.FACTORY_DATA_BASE_WAREHOUSE_BIND + ":" + brand + "_" + siteName; String obj = bladeRedis.get(rediskey); - if(StrUtil.isNotBlank(obj)){ + if (StrUtil.isNotBlank(obj)) { FactoryWarehouseBindVO redisBindVO = JSONUtil.toBean(obj, FactoryWarehouseBindVO.class); if (ObjectUtil.isNotNull(redisBindVO)) { return R.data(redisBindVO); @@ -51,6 +51,8 @@ public class FactoryDataBaseClient implements IFactoryDataBaseClient { FactoryWarehouseBindVO vo = new FactoryWarehouseBindVO(); vo.setWarehouseName(entity.getWarehouseName()); vo.setWarehouseId(entity.getWarehouseId()); + vo.setOldWarehouseId(entity.getOldWarehouseId()); + vo.setOldWarehouseName(entity.getOldWarehouseName()); vo.setTenantId(entity.getTenantId()); bladeRedis.setEx(rediskey, JSONUtil.toJsonStr(vo), Convert.toLong(60 * 60)); return R.data(vo); diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java index cf6b9426f..9fedd4b2c 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java @@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.factorydata.FactoryDataConstants; import org.springblade.core.tool.api.R; import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -70,7 +71,7 @@ public class OrderController { @PatchMapping @ApiOperationSupport(order = 2) @ApiOperation(value = "取消订单", notes = "取消订单") - public R cancelOrder(@RequestBody CancelOrderVO vo) { + public R cancelOrder(@Validated @RequestBody CancelOrderVO vo) { log.info("取消订单:{} ", JSONUtil.toJsonStr(vo)); Boolean res = deliveryNoteService.cancelOrder(vo); if (res) { diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java index 1aae21e23..1f1d97a93 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java @@ -14,6 +14,7 @@ import com.logpm.factorydata.enums.SaxStatusEnums; import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity; import com.logpm.factorydata.linsy.entity.FactoryOrderLogEntity; import com.logpm.factorydata.linsy.entity.PackageInfoEntity; +import com.logpm.factorydata.linsy.pros.LinsyProperties; import com.logpm.factorydata.linsy.service.DeliveryNoteService; import com.logpm.factorydata.linsy.service.FactoryOrderLogService; import com.logpm.factorydata.linsy.service.PackageInfoService; @@ -47,6 +48,7 @@ public class FactoryOrderListener { private final DeliveryNoteService deliveryNoteService; private final FactoryOrderLogService logService; private final PackageInfoService packageInfoService; + private final LinsyProperties linsyProperties; @RabbitListener(bindings = @QueueBinding( value = @Queue(name = FactoryDataConstants.Mq.Queues.LINSY_FACTORY_ORDER), @@ -114,10 +116,13 @@ public class FactoryOrderListener { logEntity1.setSaxStatus(SaxStatusEnums.SUCCESS.getCode()); logEntity1.setId(logId); logService.saveOrUpdate(logEntity1); - // 结果回传 - // 处理暂存单 - deliveryNoteService.buildAdvance(vo); + if (linsyProperties.getNewAdvance()) { + deliveryNoteService.buildAdvance(vo); + } + if (linsyProperties.getOldAdvance()) { + deliveryNoteService.buildOldAdvance(vo); + } } } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java index 529b44a23..93d9c9dd9 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java @@ -36,5 +36,20 @@ public class LinsyProperties { */ private Integer delayedTime = 30; + /** 生成老系统暂存单 */ + private Boolean oldAdvance = false; + + /** 生成新系统暂存单 */ + private Boolean newAdvance = false; + + /** 老系统host */ + private String oldSystemHost; + + /** 老系统暂存单url */ + private String oldSystemAdvanceUrl; + + /** 老系统取消暂存单url */ + private String oldSystemCancelAdvanceUrl; + } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java index a2f1e0030..8ecc09b0a 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java @@ -5,8 +5,6 @@ import com.logpm.factorydata.linsy.vo.CancelOrderVO; import com.logpm.factorydata.linsy.vo.DeliveryNoteVO; import org.springblade.core.mp.base.BaseService; -import java.util.List; - /** * 索菲亚发货单 服务类 * @@ -19,4 +17,6 @@ public interface DeliveryNoteService extends BaseService { void buildAdvance(DeliveryNoteVO entities); Boolean cancelOrder(CancelOrderVO vo); + + void buildOldAdvance(DeliveryNoteVO vo); } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java index 6ffbc10f7..c9e70281d 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.logpm.factorydata.base.feign.IFactoryDataBaseClient; @@ -12,6 +13,7 @@ import com.logpm.factorydata.enums.BrandEnums; import com.logpm.factorydata.feign.IFactoryDataClient; import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity; import com.logpm.factorydata.linsy.mapper.DeliveryNoteMapper; +import com.logpm.factorydata.linsy.pros.LinsyProperties; import com.logpm.factorydata.linsy.service.DeliveryNoteService; import com.logpm.factorydata.linsy.vo.CancelOrderVO; import com.logpm.factorydata.linsy.vo.DeliveryNoteVO; @@ -33,6 +35,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -49,6 +52,7 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.LINSY.getValue(), vo.getSupplierName()); + if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) { + FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData(); + if (ObjectUtil.isNotNull(data)) { + startWarehouseId = data.getOldWarehouseId(); + startWarehouseName = data.getOldWarehouseName(); + } + } + JSONObject advance = new JSONObject(); + List packages = vo.getPackages(); + // 组装暂存单数据 + advance.set("siteName", vo.getSupplierName()); + advance.set("area", ""); + advance.set("orderTypeName", ""); + advance.set("orderClassName", ""); + advance.set("type", BrandEnums.LINSY.getValue()); + advance.set("total", CollUtil.isNotEmpty(packages) ? packages.size() : 0); + advance.set("mtdsNo", ""); + advance.set("warehouse_id", startWarehouseId); + advance.set("mctsTruck", StrUtil.replace(DateUtil.today(), "-", "")); + advance.set("orderSelfNum", vo.getBillCode()); + advance.set("dealerName", vo.getShopName()); + advance.set("dealerCode", ""); + advance.set("storeName", vo.getShopName()); + advance.set("storeNo", ""); + advance.set("old_id", ""); + advance.set("serialKey", ""); + advance.set("dueDate", ""); + advance.set("delete_reason", ""); + advance.set("delete_administrators_id", ""); + advance.set("matingCode", ""); + advance.set("leaveBehind", "N"); + advance.set("contractNum", ""); + advance.set("orderNum", ""); + advance.set("waybill_no", ""); + advance.set("waybill_status", 1); + advance.set("freeze", 1); + advance.set("cars_num", ""); + advance.set("administrators_id", 1126); + advance.set("carrierName", "汇通"); + advance.set("systemType", "线上"); + advance.set("is_opai", 0); + advance.set("serviceNum", vo.getCustomizedBillCode()); + advance.set("customerName", vo.getReceiverName()); + advance.set("customerPhone", vo.getReceiverTelephone()); + advance.set("customerRoad", vo.getReceiverDetailAddress()); + advance.set("senderName", vo.getSenderName()); + advance.set("senderMobile", vo.getSenderTelephone()); + advance.set("senderAddress", vo.getSenderDetailAddress()); + + List packageList = new ArrayList<>(); + for (PackageInfoVO orderPackageDTO : packages) { + advance.set("firstPackName", orderPackageDTO.getMaterialName()); + advance.set("firstPackCode", orderPackageDTO.getMaterialCode()); + // 封装包件 + JSONObject advanceDetailEntity = new JSONObject(); + advanceDetailEntity.set("orderSelfNum", vo.getBillCode()); + advanceDetailEntity.set("serviceNum", vo.getCustomizedBillCode()); + advanceDetailEntity.set("type", BrandEnums.LINSY.getValue()); + advanceDetailEntity.set("systemType", "线上"); + advanceDetailEntity.set("firstPackName", orderPackageDTO.getMaterialName()); + // 二级品类名称 + advanceDetailEntity.set("secondPackName", orderPackageDTO.getMaterialName()); + // 三级品类名称 + advanceDetailEntity.set("thirdPackName", orderPackageDTO.getMaterialName()); + advanceDetailEntity.set("firstPackCode", orderPackageDTO.getMaterialCode()); + advanceDetailEntity.set("secondPackCode", orderPackageDTO.getMaterialCode()); + advanceDetailEntity.set("thirdPackCode", orderPackageDTO.getMaterialCode()); + advanceDetailEntity.set("siteName", vo.getSupplierName()); + advanceDetailEntity.set("unitNo", orderPackageDTO.getBarcode()); + advanceDetailEntity.set("mctsTruck", StrUtil.replace(DateUtil.today(), "-", "")); + advanceDetailEntity.set("volume", StrUtil.isNotBlank(orderPackageDTO.getVolume()) ? new BigDecimal(orderPackageDTO.getVolume()) : BigDecimal.ZERO); + advanceDetailEntity.set("is_pay", 0); + advanceDetailEntity.set("mtdsNum", 0); + advanceDetailEntity.set("lineID", ""); + advanceDetailEntity.set("mctsTruckNo", ""); + advanceDetailEntity.set("serialKey", ""); + advanceDetailEntity.set("mscsNum", "1"); + advanceDetailEntity.set("isAddin", "N"); + advanceDetailEntity.set("isThirdAddin", "N"); + advanceDetailEntity.set("isSuppin", "N"); + advanceDetailEntity.set("productCode", ""); + advanceDetailEntity.set("goodName", ""); + advanceDetailEntity.set("admin", ""); + advanceDetailEntity.set("siteCode", ""); + advanceDetailEntity.set("area", ""); + advanceDetailEntity.set("date2", ""); + advanceDetailEntity.set("date3", ""); + advanceDetailEntity.set("date4", ""); + advanceDetailEntity.set("date5", ""); + advanceDetailEntity.set("date6", ""); + advanceDetailEntity.set("orderNum", ""); + advanceDetailEntity.set("mtdsNo", ""); + advanceDetailEntity.set("old_id", 0); + advanceDetailEntity.set("remark", ""); + advanceDetailEntity.set("dueDate", ""); + advanceDetailEntity.set("is_opai", 0); + advanceDetailEntity.set("administrators_id", 1126); + advanceDetailEntity.set("date100", new Date()); + JSONObject entries = JSONUtil.parseObj(advanceDetailEntity); + packageList.add(entries); + } + advance.set("details", JSONUtil.toJsonStr(packageList)); + if (ObjectUtil.isAllNotEmpty(linsyProperties.getOldSystemHost(), linsyProperties.getOldSystemAdvanceUrl())) { + log.info("推送老系统暂存单:{}", JSONUtil.toJsonStr(advance)); + String post = HttpUtil.post(linsyProperties.getOldSystemHost() + linsyProperties.getOldSystemAdvanceUrl(), JSONUtil.toJsonStr(advance)); + log.info("推送老系统暂存单结果:{}", post); + } } }