Browse Source

feat(all): 增加老系统作业数据推送志邦工厂

1 关闭志邦新系统暂存单推送
2 增加老系统作业推送志邦接口
dist.1.3.0
zhaoqiaobo 8 months ago
parent
commit
2154e588d7
  1. 5
      blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java
  2. 33
      blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/vo/PushData.java
  3. 16
      blade-service-api/logpm-factory-data-zbom-api/pom.xml
  4. 30
      blade-service-api/logpm-factory-data-zbom-api/src/main/java/com/logpm/factorydata/zbom/feign/IFactoryDataZbomClient.java
  5. 1
      blade-service-api/pom.xml
  6. 1
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java
  7. 1
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/FactoryOrderListener.java
  8. 1
      blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/FactoryOrderListener.java
  9. 1
      blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mq/FactoryOrderListener.java
  10. 5
      blade-service/logpm-factory-data/logpm-factory-data-zbom/pom.xml
  11. 50
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/controller/OrderController.java
  12. 26
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/feign/FactoryDataZbomClient.java
  13. 213
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/mq/ZbomFactoryOrderListener.java
  14. 2
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/service/FactoryLogService.java
  15. 5
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/service/IReceiptService.java
  16. 83
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/service/impl/FactoryLogServiceImpl.java
  17. 245
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/service/impl/ReceiptServiceImpl.java
  18. 5
      blade-service/logpm-factory/pom.xml
  19. 3
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java
  20. 4
      blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java
  21. 4
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java
  22. 37
      blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/controller/ZbFactoryDataController.java
  23. 2
      blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/service/IZbFactoryDataService.java
  24. 9
      blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/service/impl/ZbFactoryDataServiceImpl.java
  25. 44
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java

5
blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java

@ -16,11 +16,14 @@ import java.util.concurrent.ConcurrentHashMap;
public class FactoryDataUtil {
static Map<String, String> factorys = new ConcurrentHashMap();
private FactoryDataUtil(){
private FactoryDataUtil() {
}
static {
factorys.put(BrandEnums.ZB.getValue(), FactoryDataConstants.Mq.RoutingKeys.ZBOM_NODE_DATA_PUSH);
factorys.put(BrandEnums.LINSY.getValue(), FactoryDataConstants.Mq.RoutingKeys.LINSY_NODE_DATA_PUSH);
}

33
blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/vo/PushData.java

@ -0,0 +1,33 @@
package com.logpm.factorydata.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.logpm.factorydata.enums.BrandEnums;
import com.logpm.factorydata.enums.SignForStatusEnums;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springblade.common.constant.WorkNodeEnums;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 提送数据
*
* @author zhaoqiaobo
* @create 2024-03-18 0:45
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PushData implements Serializable {
/**
* 包件
*/
private String packageCode;
}

16
blade-service-api/logpm-factory-data-zbom-api/pom.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>blade-service-api</artifactId><groupId>org.springblade</groupId><version>3.2.0.RELEASE</version></parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.logpm</groupId>
<artifactId>logpm-factory-data-zbom-api</artifactId>
<version>${bladex.project.version}</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>

30
blade-service-api/logpm-factory-data-zbom-api/src/main/java/com/logpm/factorydata/zbom/feign/IFactoryDataZbomClient.java

@ -0,0 +1,30 @@
package com.logpm.factorydata.zbom.feign;
import org.springblade.common.constant.ModuleNameConstant;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author zhaoqiaobo
* @create 2024-03-16 15:04
*/
@FeignClient(value = ModuleNameConstant.LOGPM_FACTORY_DATA_ZBOM_NAME)
public interface IFactoryDataZbomClient {
String API_PREFIX = "/client/factoryDataZbom";
String ORDER = API_PREFIX + "/order";
/**
* 保存志邦的订单数据
*
* @param data
* @return org.springblade.core.tool.api.R<java.lang.String>
* @author zqb 2024/5/25
**/
@PostMapping(ORDER)
R<String> order(@RequestBody String data);
}

1
blade-service-api/pom.xml

@ -44,6 +44,7 @@
<module>logpm-factory-data-base-api</module>
<!-- 商家转化模块 -->
<module>logpm-business-conversion-api</module>
<module>logpm-factory-data-zbom-api</module>
</modules>
<dependencies>

1
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java

@ -33,7 +33,6 @@ import org.springblade.common.constant.HttpConstants;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.common.model.IDict;
import org.springblade.core.tool.api.R;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;

1
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/FactoryOrderListener.java

@ -52,7 +52,6 @@ import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

1
blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/FactoryOrderListener.java

@ -39,7 +39,6 @@ import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

1
blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mq/FactoryOrderListener.java

@ -41,7 +41,6 @@ import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

5
blade-service/logpm-factory-data/logpm-factory-data-zbom/pom.xml

@ -68,6 +68,11 @@
<version>3.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.logpm</groupId>
<artifactId>logpm-factory-data-zbom-api</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
</dependencies>
<build>

50
blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/controller/OrderController.java

@ -89,60 +89,12 @@ public class OrderController {
String corpId = request.getHeader("corpId");
zbReceiptDTO.setCorpId(corpId);
// 1 上传数据到 minio 获取到地址
String url = uploadFile(JSONUtil.toJsonStr(zbReceiptDTO));
// 2 保存地址到数据库
FactoryLogEntity logEntity = new FactoryLogEntity();
logEntity.setType(1);
logEntity.setSaxStatus(SaxStatusEnums.NOMAL.getCode());
logEntity.setLogUrl(url);
factoryLogService.save(logEntity);
factoryLogService.orderData(zbReceiptDTO);
// 3 将消息发送给 mq,解析保存
SendMsg build = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER)
.routingKey(FactoryDataConstants.Mq.RoutingKeys.ZBOM_FACTORY_ORDER)
.message(JSONUtil.toJsonStr(logEntity)).build();
factoryDataClient.sendMessage(build);
return ZbResp.success("成功");
}
private String uploadFile(String body) {
//文本内容和保存为本地文件 并上传
String logPath = FileLogsUtil.saveFileLogs(body);
log.info(">>> 文件路径 {}", logPath);
MultipartFile multi = getMultipartFile(logPath);
//上传到服务器
R r = ossClient.fileUpload(multi, "zb-order-logs");
if (r.isSuccess()) {
BladeFile data = (BladeFile) r.getData();
// 删除本地文件
FileUtil.del(logPath);
return data.getLink();
}
return null;
}
@NotNull
private MultipartFile getMultipartFile(String logPath) {
File file = new File(logPath);
// File 转 MultipartFile
FileItem item = new DiskFileItemFactory().createItem("file"
, MediaType.MULTIPART_FORM_DATA_VALUE
, true
, file.getName());
try (
InputStream input = Files.newInputStream(file.toPath());
OutputStream os = item.getOutputStream()) {
// 流转移
IOUtils.copy(input, os);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid file: " + e, e);
}
return new CommonsMultipartFile(item);
}
}

26
blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/feign/FactoryDataZbomClient.java

@ -0,0 +1,26 @@
package com.logpm.factorydata.zbom.feign;
import cn.hutool.json.JSONUtil;
import com.logpm.factorydata.zbom.service.FactoryLogService;
import com.logpm.factorydata.zbom.vo.ZBReceiptDTO;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.RestController;
/**
* @author zhaoqiaobo
* @create 2024-05-25
*/
@RestController
@AllArgsConstructor
public class FactoryDataZbomClient implements IFactoryDataZbomClient {
private final FactoryLogService factoryLogService;
@Override
public R<String> order(String data) {
factoryLogService.orderData(JSONUtil.toBean(data, ZBReceiptDTO.class));
return R.success("成功");
}
}

213
blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/mq/ZbomFactoryOrderListener.java

@ -10,8 +10,6 @@ import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -50,7 +48,6 @@ import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -81,10 +78,6 @@ public class ZbomFactoryOrderListener {
private final IReceiptService receiptService;
private final IPackageInfoService packageInfoService;
private final IOrderPackageService orderPackageService;
private final BladeRedis bladeRedis;
private final ZbCategoryContrastMapper zbCategoryContrastMapper;
private final IFactoryDataBaseClient baseClient;
private final IFactoryDataClient factoryDataClient;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FactoryDataConstants.Mq.Queues.ZBOM_FACTORY_ORDER),
@ -148,8 +141,8 @@ public class ZbomFactoryOrderListener {
}
}
ZbReceiptEntity zbReceiptEntity = new ZbReceiptEntity();
zbReceiptEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
BeanUtil.copyProperties(zbReceiptDTO, zbReceiptEntity);
zbReceiptEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
// 保存订单数据
receiptService.save(zbReceiptEntity);
if (CollUtil.isNotEmpty(details)) {
@ -192,208 +185,8 @@ public class ZbomFactoryOrderListener {
// 保存物料数据
packageInfoService.saveBatch(packageInfoEntities);
}
// 处理暂存单
buildAdvance(zbReceiptDTO, packageCode);
}
@LogpmAsync("asyncExecutor")
public void buildAdvance(ZBReceiptDTO zbReceiptDTO, Set packageCode) {
// 新起线程构建暂存单发送mq
Long startWarehouseId = null;
String startWarehouseName = null;
String tenantId = null;
// 获取工厂基地绑定的始发仓信息
R<FactoryWarehouseBindVO> warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(zbReceiptDTO.getSenderName(), zbReceiptDTO.getSenderName());
if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) {
FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData();
if (ObjectUtil.isNotNull(data)) {
startWarehouseId = data.getWarehouseId();
startWarehouseName = data.getWarehouseName();
tenantId = data.getTenantId();
}
}
Map<String, List<OrderPackageDTO>> advanceMap = new HashMap<>();
List<OrderPackageDTO> details = zbReceiptDTO.getDetails();
// 入库单号 + 订单自编号 + 发车单号 一个暂存单
for (OrderPackageDTO detail : details) {
if (packageCode.contains(detail.getPackageCode())) {
log.info(" 接收志邦数据:包条码 {} 已存在数据库中,不生成暂存单。", detail.getPackageCode());
continue;
}
String taskCode = zbReceiptDTO.getTaskCode();
String departCode = zbReceiptDTO.getDepartCode();
String platformOrderCode = detail.getPlatformOrderCode();
String advanceKey = taskCode + departCode + platformOrderCode;
if (advanceMap.containsKey(advanceKey)) {
advanceMap.get(advanceKey).add(detail);
} else {
ArrayList<OrderPackageDTO> orderPackageDTOS = new ArrayList<>();
orderPackageDTOS.add(detail);
advanceMap.put(advanceKey, orderPackageDTOS);
}
}
// 组装暂存单数据
List<JSONObject> advances = new ArrayList<>();
for (Map.Entry<String, List<OrderPackageDTO>> stringListEntry : advanceMap.entrySet()) {
List<OrderPackageDTO> value = stringListEntry.getValue();
TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity();
advanceEntity.setTenantId(tenantId);
advanceEntity.setStatus(0);
advanceEntity.setIsDeleted(0);
advanceEntity.setHasPackage(CollUtil.isNotEmpty(zbReceiptDTO.getDetails()) ? 1 : 0);
advanceEntity.setOrderType(zbReceiptDTO.getOrderType());
advanceEntity.setBrand(zbReceiptDTO.getSenderName());
advanceEntity.setSiteName("");
advanceEntity.setArea("");
advanceEntity.setTotalNum(CollUtil.isNotEmpty(value) ? value.size() : 0);
advanceEntity.setPackName("");
advanceEntity.setPackCode("");
advanceEntity.setWarehouseId(startWarehouseId);
advanceEntity.setWarehouseName(startWarehouseName);
advanceEntity.setIsGcp(0);
advanceEntity.setCarrierName(zbReceiptDTO.getVendorName());
advanceEntity.setSystemType("线上");
advanceEntity.setMatingType("1");
advanceEntity.setSenderName(zbReceiptDTO.getSenderName());
advanceEntity.setSenderPhone(zbReceiptDTO.getSenderTel());
advanceEntity.setSenderAddress(zbReceiptDTO.getSenderAddress());
advanceEntity.setWaybillStatus("0");
advanceEntity.setWaybillNo("");
advanceEntity.setTrainNumber(zbReceiptDTO.getDepartCode());
advanceEntity.setFreezeStatus("0");
advanceEntity.setSenderFactory(zbReceiptDTO.getSenderName());
List<JSONObject> packageList = new ArrayList<>();
for (OrderPackageDTO orderPackageDTO : value) {
advanceEntity.setOrderCode(orderPackageDTO.getPlatformOrderCode());
advanceEntity.setDealerCode(orderPackageDTO.getCustomerCode());
advanceEntity.setDealerName(orderPackageDTO.getCustomerName());
advanceEntity.setStoreCode(orderPackageDTO.getCustomerCode());
advanceEntity.setStoreName(orderPackageDTO.getCustomerName());
advanceEntity.setServiceNum(orderPackageDTO.getRelationOrderCode());
advanceEntity.setCustomerName(orderPackageDTO.getReceiverName());
advanceEntity.setCustomerPhone(orderPackageDTO.getReceiverMobile());
advanceEntity.setCustomerAddress(orderPackageDTO.getReceiverAddress());
// 根据志邦的一流单标识赋值
advanceEntity.setLegacyStatus("0");
if (ObjectUtil.equal(orderPackageDTO.getLegacyFlag(), "Y")) {
advanceEntity.setLegacyStatus("1");
}
// 封装包件
TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity();
advanceDetailEntity.setWarehouseId(startWarehouseId);
advanceDetailEntity.setWarehouseName(startWarehouseName);
advanceDetailEntity.setOrderCode(orderPackageDTO.getPlatformOrderCode());
advanceDetailEntity.setBrand(zbReceiptDTO.getSenderName());
advanceDetailEntity.setSystemType("线上");
advanceDetailEntity.setFirstPackName(orderPackageDTO.getPackageTypeName());
advanceDetailEntity.setFirstPackCode(orderPackageDTO.getPackageType());
// 获取映射志邦映射品类信息
ZbCategoryContrastEntity zbCategoryContrastEntity = buildZbCategoryContrastEntityCache(orderPackageDTO.getPackageClass());
if (zbCategoryContrastEntity != null) {
advanceDetailEntity.setSecondPackName(zbCategoryContrastEntity.getSecondName());//二级品类名称
advanceDetailEntity.setSecondPackCode(zbCategoryContrastEntity.getSecondCode());//二级品类
advanceDetailEntity.setThirdPackName(zbCategoryContrastEntity.getThirdName());//三级品类名称
advanceDetailEntity.setThirdPackCode(zbCategoryContrastEntity.getThirdCode());//三级品类
} else {
advanceDetailEntity.setSecondPackName(StringUtil.isBlank(orderPackageDTO.getPackageClass()) ? "" : orderPackageDTO.getPackageClass());//二级品类名称
advanceDetailEntity.setSecondPackCode("");//二级品类
advanceDetailEntity.setThirdPackName(StringUtil.isBlank(orderPackageDTO.getPackageClass()) ? "" : orderPackageDTO.getPackageClass());//三级品类名称
advanceDetailEntity.setThirdPackCode("");//三级品类
}
advanceDetailEntity.setSiteName("");
advanceDetailEntity.setSiteCode("");
String planQty = orderPackageDTO.getPlanQty();
advanceDetailEntity.setQuantity((StrUtil.isNotBlank(planQty) && NumberUtil.isNumber(planQty)) ? Convert.toInt(planQty) : 0);
advanceDetailEntity.setOrderPackageCode(orderPackageDTO.getPackageCode());
advanceDetailEntity.setTrainNumber(zbReceiptDTO.getDepartCode());
advanceDetailEntity.setServiceNum(orderPackageDTO.getRelationOrderCode());
advanceDetailEntity.setWaybillNo("");
advanceDetailEntity.setPackageStatus("0");
advanceDetailEntity.setWeight(StrUtil.isNotBlank(orderPackageDTO.getTotalGrossWeight()) ? new BigDecimal(orderPackageDTO.getTotalGrossWeight()) : BigDecimal.ZERO);
advanceDetailEntity.setVolume(StrUtil.isNotBlank(orderPackageDTO.getTotalVolume()) ? new BigDecimal(orderPackageDTO.getTotalVolume()) : BigDecimal.ZERO);
// advanceDetailEntity.setChargeType(0);
advanceDetailEntity.setSupple("");
advanceDetailEntity.setManifest("");
advanceDetailEntity.setReturnNum("");
advanceDetailEntity.setSendDateStr(DateUtil.formatLocalDateTime(LocalDateTime.now()));
advanceDetailEntity.setCarNumber("");
advanceDetailEntity.setGoodsMan("");
advanceDetailEntity.setTenantId(tenantId);
advanceDetailEntity.setStatus(0);
advanceDetailEntity.setIsDeleted(0);
List<JSONObject> itemJsons = new ArrayList<>();
List<PackageInfoDTO> items = orderPackageDTO.getItems();
for (PackageInfoDTO item : items) {
TrunklineDetailProductEntity detailProductEntity = new TrunklineDetailProductEntity();
detailProductEntity.setTenantId(tenantId);
detailProductEntity.setWarehouseId(startWarehouseId);
detailProductEntity.setWarehouseName(startWarehouseName);
detailProductEntity.setUnitNo(orderPackageDTO.getPackageCode());
detailProductEntity.setProductCode(item.getItemCode());
detailProductEntity.setProductName(item.getItemName());
detailProductEntity.setQuantity(item.getPlanQty());
detailProductEntity.setStatus(0);
detailProductEntity.setIsDeleted(0);
itemJsons.add(JSONUtil.parseObj(detailProductEntity));
}
JSONObject entries = JSONUtil.parseObj(advanceDetailEntity);
entries.set("items", itemJsons);
packageList.add(entries);
}
// 转成json对象,然后将包件明细放到detail中
JSONObject entries = JSONUtil.parseObj(advanceEntity);
entries.set("details", JSONUtil.toJsonStr(packageList));
advances.add(entries);
}
// 将组装好的暂存单发送到 MQ ,由暂存单服务统一消费SendMsg.
if (CollUtil.isNotEmpty(advances)) {
for (JSONObject advance : advances) {
SendMsg sendMsg = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.ADVANCE_ORDER)
.routingKey(FactoryDataConstants.Mq.RoutingKeys.ADVANCE_ORDER).message(JSONUtil.toJsonStr(advance)).build();
factoryDataClient.sendMessage(sendMsg);
}
}
}
private ZbCategoryContrastEntity buildZbCategoryContrastEntityCache(String packageClass) {
if (StringUtil.isBlank(packageClass)) {
return null;
}
if (containsChinese(packageClass)) {
return null;
}
String key = TenantNum.HUITONGCODE + ":" + ZbCategoryContrastEntity.class.getName() + ":" + packageClass;
ZbCategoryContrastEntity zbCategoryContrastEntity = bladeRedis.get(key);
if (zbCategoryContrastEntity == null) {
QueryWrapper<ZbCategoryContrastEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("source_code", packageClass);
queryWrapper.eq("status", "1");
zbCategoryContrastEntity = zbCategoryContrastMapper.selectOne(queryWrapper);
if (!Objects.isNull(zbCategoryContrastEntity)) {
// 缓存起来
bladeRedis.setEx(key, zbCategoryContrastEntity, 3600 * 24L);
}
}
return zbCategoryContrastEntity;
}
/**
* 验证参数中是否包含中文
*
* @param str 匹配参数
* @return true 包含中文 false 不包含中文
*/
private boolean containsChinese(String str) {
Pattern pattern = Pattern.compile(PatternConstant.REGEX_CHINESE);
Matcher matcher = pattern.matcher(str);
return matcher.find();
// 处理暂存单 TODO 暂时关闭推送新系统暂存单
// receiptService.buildAdvance(zbReceiptDTO, packageCode);
}
}

2
blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/service/FactoryLogService.java

@ -1,6 +1,7 @@
package com.logpm.factorydata.zbom.service;
import com.logpm.factorydata.zbom.entity.FactoryLogEntity;
import com.logpm.factorydata.zbom.vo.ZBReceiptDTO;
import org.springblade.core.mp.base.BaseService;
/**
@ -11,4 +12,5 @@ import org.springblade.core.mp.base.BaseService;
**/
public interface FactoryLogService extends BaseService<FactoryLogEntity> {
void orderData(ZBReceiptDTO zbReceiptDTO);
}

5
blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/service/IReceiptService.java

@ -17,8 +17,11 @@
package com.logpm.factorydata.zbom.service;
import com.logpm.factorydata.zbom.entity.ZbReceiptEntity;
import com.logpm.factorydata.zbom.vo.ZBReceiptDTO;
import org.springblade.core.mp.base.BaseService;
import java.util.Set;
/**
* 志邦入库单 服务类
*
@ -27,4 +30,6 @@ import org.springblade.core.mp.base.BaseService;
*/
public interface IReceiptService extends BaseService<ZbReceiptEntity> {
void buildAdvance(ZBReceiptDTO zbReceiptDTO, Set<String> packageCode);
}

83
blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/service/impl/FactoryLogServiceImpl.java

@ -1,12 +1,35 @@
package com.logpm.factorydata.zbom.service.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONUtil;
import com.logpm.factorydata.enums.SaxStatusEnums;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.vo.SendMsg;
import com.logpm.factorydata.zbom.entity.FactoryLogEntity;
import com.logpm.factorydata.zbom.mapper.FactoryLogMapper;
import com.logpm.factorydata.zbom.service.FactoryLogService;
import com.logpm.factorydata.zbom.vo.ZBReceiptDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.common.utils.FileLogsUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R;
import org.springblade.resource.feign.IOssClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
/**
* 工厂订单日志 业务实现类
@ -19,4 +42,64 @@ import org.springframework.stereotype.Service;
@AllArgsConstructor
public class FactoryLogServiceImpl extends BaseServiceImpl<FactoryLogMapper, FactoryLogEntity> implements FactoryLogService {
private final IFactoryDataClient factoryDataClient;
private final IOssClient ossClient;
@Override
public void orderData(ZBReceiptDTO zbReceiptDTO) {
// 1 上传数据到 minio 获取到地址
String url = uploadFile(JSONUtil.toJsonStr(zbReceiptDTO));
// 2 保存地址到数据库
FactoryLogEntity logEntity = new FactoryLogEntity();
logEntity.setType(1);
logEntity.setSaxStatus(SaxStatusEnums.NOMAL.getCode());
logEntity.setLogUrl(url);
this.save(logEntity);
// 3 将消息发送给 mq,解析保存
SendMsg build = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER)
.routingKey(FactoryDataConstants.Mq.RoutingKeys.ZBOM_FACTORY_ORDER)
.message(JSONUtil.toJsonStr(logEntity)).build();
factoryDataClient.sendMessage(build);
}
private String uploadFile(String body) {
//文本内容和保存为本地文件 并上传
String logPath = FileLogsUtil.saveFileLogs(body);
log.info(">>> 文件路径 {}", logPath);
MultipartFile multi = getMultipartFile(logPath);
//上传到服务器
R r = ossClient.fileUpload(multi, "zb-order-logs");
if (r.isSuccess()) {
BladeFile data = (BladeFile) r.getData();
// 删除本地文件
FileUtil.del(logPath);
return data.getLink();
}
return null;
}
@NotNull
private MultipartFile getMultipartFile(String logPath) {
File file = new File(logPath);
// File 转 MultipartFile
FileItem item = new DiskFileItemFactory().createItem("file"
, MediaType.MULTIPART_FORM_DATA_VALUE
, true
, file.getName());
try (
InputStream input = Files.newInputStream(file.toPath());
OutputStream os = item.getOutputStream()) {
// 流转移
IOUtils.copy(input, os);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid file: " + e, e);
}
return new CommonsMultipartFile(item);
}
}

245
blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/service/impl/ReceiptServiceImpl.java

@ -16,14 +16,54 @@
*/
package com.logpm.factorydata.zbom.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.factorydata.base.feign.IFactoryDataBaseClient;
import com.logpm.factorydata.base.vo.FactoryWarehouseBindVO;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.vo.SendMsg;
import com.logpm.factorydata.zbom.entity.ZbCategoryContrastEntity;
import com.logpm.factorydata.zbom.entity.ZbReceiptEntity;
import com.logpm.factorydata.zbom.mapper.ReceiptMapper;
import com.logpm.factorydata.zbom.mapper.ZbCategoryContrastMapper;
import com.logpm.factorydata.zbom.service.IReceiptService;
import com.logpm.factorydata.zbom.vo.OrderPackageDTO;
import com.logpm.factorydata.zbom.vo.PackageInfoDTO;
import com.logpm.factorydata.zbom.vo.ZBReceiptDTO;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import com.logpm.trunkline.entity.TrunklineDetailProductEntity;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.annotations.LogpmAsync;
import org.springblade.common.constant.HttpConstants;
import org.springblade.common.constant.PatternConstant;
import org.springblade.common.constant.TenantNum;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 志邦入库单 服务实现类
*
@ -35,4 +75,209 @@ import org.springframework.stereotype.Service;
@AllArgsConstructor
public class ReceiptServiceImpl extends BaseServiceImpl<ReceiptMapper, ZbReceiptEntity> implements IReceiptService {
private final BladeRedis bladeRedis;
private final ZbCategoryContrastMapper zbCategoryContrastMapper;
private final IFactoryDataBaseClient baseClient;
private final IFactoryDataClient factoryDataClient;
@Override
@LogpmAsync("asyncExecutor")
public void buildAdvance(ZBReceiptDTO zbReceiptDTO, Set packageCode) {
// 新起线程构建暂存单发送mq
Long startWarehouseId = null;
String startWarehouseName = null;
String tenantId = null;
// 获取工厂基地绑定的始发仓信息
R<FactoryWarehouseBindVO> warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(zbReceiptDTO.getSenderName(), zbReceiptDTO.getSenderName());
if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) {
FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData();
if (ObjectUtil.isNotNull(data)) {
startWarehouseId = data.getWarehouseId();
startWarehouseName = data.getWarehouseName();
tenantId = data.getTenantId();
}
}
Map<String, List<OrderPackageDTO>> advanceMap = new HashMap<>();
List<OrderPackageDTO> details = zbReceiptDTO.getDetails();
// 入库单号 + 订单自编号 + 发车单号 一个暂存单
for (OrderPackageDTO detail : details) {
if (packageCode.contains(detail.getPackageCode())) {
log.info(" 接收志邦数据:包条码 {} 已存在数据库中,不生成暂存单。", detail.getPackageCode());
continue;
}
String taskCode = zbReceiptDTO.getTaskCode();
String departCode = zbReceiptDTO.getDepartCode();
String platformOrderCode = detail.getPlatformOrderCode();
String advanceKey = taskCode + departCode + platformOrderCode;
if (advanceMap.containsKey(advanceKey)) {
advanceMap.get(advanceKey).add(detail);
} else {
ArrayList<OrderPackageDTO> orderPackageDTOS = new ArrayList<>();
orderPackageDTOS.add(detail);
advanceMap.put(advanceKey, orderPackageDTOS);
}
}
// 组装暂存单数据
List<JSONObject> advances = new ArrayList<>();
for (Map.Entry<String, List<OrderPackageDTO>> stringListEntry : advanceMap.entrySet()) {
List<OrderPackageDTO> value = stringListEntry.getValue();
TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity();
advanceEntity.setTenantId(tenantId);
advanceEntity.setStatus(0);
advanceEntity.setIsDeleted(0);
advanceEntity.setHasPackage(CollUtil.isNotEmpty(zbReceiptDTO.getDetails()) ? 1 : 0);
advanceEntity.setOrderType(zbReceiptDTO.getOrderType());
advanceEntity.setBrand(zbReceiptDTO.getSenderName());
advanceEntity.setSiteName("");
advanceEntity.setArea("");
advanceEntity.setTotalNum(CollUtil.isNotEmpty(value) ? value.size() : 0);
advanceEntity.setPackName("");
advanceEntity.setPackCode("");
advanceEntity.setWarehouseId(startWarehouseId);
advanceEntity.setWarehouseName(startWarehouseName);
advanceEntity.setIsGcp(0);
advanceEntity.setCarrierName(zbReceiptDTO.getVendorName());
advanceEntity.setSystemType("线上");
advanceEntity.setMatingType("1");
advanceEntity.setSenderName(zbReceiptDTO.getSenderName());
advanceEntity.setSenderPhone(zbReceiptDTO.getSenderTel());
advanceEntity.setSenderAddress(zbReceiptDTO.getSenderAddress());
advanceEntity.setWaybillStatus("0");
advanceEntity.setWaybillNo("");
advanceEntity.setTrainNumber(zbReceiptDTO.getDepartCode());
advanceEntity.setFreezeStatus("0");
advanceEntity.setSenderFactory(zbReceiptDTO.getSenderName());
List<JSONObject> packageList = new ArrayList<>();
for (OrderPackageDTO orderPackageDTO : value) {
advanceEntity.setOrderCode(orderPackageDTO.getPlatformOrderCode());
advanceEntity.setDealerCode(orderPackageDTO.getCustomerCode());
advanceEntity.setDealerName(orderPackageDTO.getCustomerName());
advanceEntity.setStoreCode(orderPackageDTO.getCustomerCode());
advanceEntity.setStoreName(orderPackageDTO.getCustomerName());
advanceEntity.setServiceNum(orderPackageDTO.getRelationOrderCode());
advanceEntity.setCustomerName(orderPackageDTO.getReceiverName());
advanceEntity.setCustomerPhone(orderPackageDTO.getReceiverMobile());
advanceEntity.setCustomerAddress(orderPackageDTO.getReceiverAddress());
// 根据志邦的一流单标识赋值
advanceEntity.setLegacyStatus("0");
if (ObjectUtil.equal(orderPackageDTO.getLegacyFlag(), "Y")) {
advanceEntity.setLegacyStatus("1");
}
// 封装包件
TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity();
advanceDetailEntity.setWarehouseId(startWarehouseId);
advanceDetailEntity.setWarehouseName(startWarehouseName);
advanceDetailEntity.setOrderCode(orderPackageDTO.getPlatformOrderCode());
advanceDetailEntity.setBrand(zbReceiptDTO.getSenderName());
advanceDetailEntity.setSystemType("线上");
advanceDetailEntity.setFirstPackName(orderPackageDTO.getPackageTypeName());
advanceDetailEntity.setFirstPackCode(orderPackageDTO.getPackageType());
// 获取映射志邦映射品类信息
ZbCategoryContrastEntity zbCategoryContrastEntity = buildZbCategoryContrastEntityCache(orderPackageDTO.getPackageClass());
if (zbCategoryContrastEntity != null) {
advanceDetailEntity.setSecondPackName(zbCategoryContrastEntity.getSecondName());//二级品类名称
advanceDetailEntity.setSecondPackCode(zbCategoryContrastEntity.getSecondCode());//二级品类
advanceDetailEntity.setThirdPackName(zbCategoryContrastEntity.getThirdName());//三级品类名称
advanceDetailEntity.setThirdPackCode(zbCategoryContrastEntity.getThirdCode());//三级品类
} else {
advanceDetailEntity.setSecondPackName(StringUtil.isBlank(orderPackageDTO.getPackageClass()) ? "" : orderPackageDTO.getPackageClass());//二级品类名称
advanceDetailEntity.setSecondPackCode("");//二级品类
advanceDetailEntity.setThirdPackName(StringUtil.isBlank(orderPackageDTO.getPackageClass()) ? "" : orderPackageDTO.getPackageClass());//三级品类名称
advanceDetailEntity.setThirdPackCode("");//三级品类
}
advanceDetailEntity.setSiteName("");
advanceDetailEntity.setSiteCode("");
String planQty = orderPackageDTO.getPlanQty();
advanceDetailEntity.setQuantity((StrUtil.isNotBlank(planQty) && NumberUtil.isNumber(planQty)) ? Convert.toInt(planQty) : 0);
advanceDetailEntity.setOrderPackageCode(orderPackageDTO.getPackageCode());
advanceDetailEntity.setTrainNumber(zbReceiptDTO.getDepartCode());
advanceDetailEntity.setServiceNum(orderPackageDTO.getRelationOrderCode());
advanceDetailEntity.setWaybillNo("");
advanceDetailEntity.setPackageStatus("0");
advanceDetailEntity.setWeight(StrUtil.isNotBlank(orderPackageDTO.getTotalGrossWeight()) ? new BigDecimal(orderPackageDTO.getTotalGrossWeight()) : BigDecimal.ZERO);
advanceDetailEntity.setVolume(StrUtil.isNotBlank(orderPackageDTO.getTotalVolume()) ? new BigDecimal(orderPackageDTO.getTotalVolume()) : BigDecimal.ZERO);
// advanceDetailEntity.setChargeType(0);
advanceDetailEntity.setSupple("");
advanceDetailEntity.setManifest("");
advanceDetailEntity.setReturnNum("");
advanceDetailEntity.setSendDateStr(DateUtil.formatLocalDateTime(LocalDateTime.now()));
advanceDetailEntity.setCarNumber("");
advanceDetailEntity.setGoodsMan("");
advanceDetailEntity.setTenantId(tenantId);
advanceDetailEntity.setStatus(0);
advanceDetailEntity.setIsDeleted(0);
List<JSONObject> itemJsons = new ArrayList<>();
List<PackageInfoDTO> items = orderPackageDTO.getItems();
for (PackageInfoDTO item : items) {
TrunklineDetailProductEntity detailProductEntity = new TrunklineDetailProductEntity();
detailProductEntity.setTenantId(tenantId);
detailProductEntity.setWarehouseId(startWarehouseId);
detailProductEntity.setWarehouseName(startWarehouseName);
detailProductEntity.setUnitNo(orderPackageDTO.getPackageCode());
detailProductEntity.setProductCode(item.getItemCode());
detailProductEntity.setProductName(item.getItemName());
detailProductEntity.setQuantity(item.getPlanQty());
detailProductEntity.setStatus(0);
detailProductEntity.setIsDeleted(0);
itemJsons.add(JSONUtil.parseObj(detailProductEntity));
}
JSONObject entries = JSONUtil.parseObj(advanceDetailEntity);
entries.set("items", itemJsons);
packageList.add(entries);
}
// 转成json对象,然后将包件明细放到detail中
JSONObject entries = JSONUtil.parseObj(advanceEntity);
entries.set("details", JSONUtil.toJsonStr(packageList));
advances.add(entries);
}
// 将组装好的暂存单发送到 MQ ,由暂存单服务统一消费SendMsg.
if (CollUtil.isNotEmpty(advances)) {
for (JSONObject advance : advances) {
SendMsg sendMsg = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.ADVANCE_ORDER)
.routingKey(FactoryDataConstants.Mq.RoutingKeys.ADVANCE_ORDER).message(JSONUtil.toJsonStr(advance)).build();
factoryDataClient.sendMessage(sendMsg);
}
}
}
private ZbCategoryContrastEntity buildZbCategoryContrastEntityCache(String packageClass) {
if (StringUtil.isBlank(packageClass)) {
return null;
}
if (containsChinese(packageClass)) {
return null;
}
String key = TenantNum.HUITONGCODE + ":" + ZbCategoryContrastEntity.class.getName() + ":" + packageClass;
ZbCategoryContrastEntity zbCategoryContrastEntity = bladeRedis.get(key);
if (zbCategoryContrastEntity == null) {
QueryWrapper<ZbCategoryContrastEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("source_code", packageClass);
queryWrapper.eq("status", "1");
zbCategoryContrastEntity = zbCategoryContrastMapper.selectOne(queryWrapper);
if (!Objects.isNull(zbCategoryContrastEntity)) {
// 缓存起来
bladeRedis.setEx(key, zbCategoryContrastEntity, 3600 * 24L);
}
}
return zbCategoryContrastEntity;
}
/**
* 验证参数中是否包含中文
*
* @param str 匹配参数
* @return true 包含中文 false 不包含中文
*/
private boolean containsChinese(String str) {
Pattern pattern = Pattern.compile(PatternConstant.REGEX_CHINESE);
Matcher matcher = pattern.matcher(str);
return matcher.find();
}
}

5
blade-service/logpm-factory/pom.xml

@ -129,6 +129,11 @@
<artifactId>logpm-factory-data-api</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.logpm</groupId>
<artifactId>logpm-factory-data-zbom-api</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
</dependencies>

3
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java

@ -64,7 +64,6 @@ import lombok.extern.log4j.Log4j2;
import org.jetbrains.annotations.Nullable;
import org.springblade.common.annotations.LogpmAsync;
import org.springblade.common.constant.HttpConstants;
import org.springblade.common.constant.PackagesTypeEnum;
import org.springblade.common.constant.PatternConstant;
import org.springblade.common.constant.TenantNum;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
@ -72,9 +71,7 @@ import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.sql.Timestamp;

4
blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java

@ -36,8 +36,8 @@ public class InterceptorAdapterConfig implements WebMvcConfigurer {
excludePathPatterns("/factory/oupai/**").
excludePathPatterns("/factory/zb/**")
.excludePathPatterns("/factory/common/**").order(2);
interceptorRegistry.addInterceptor(new ZbFactoryAccountsInterceptor(zbFactoryProperties))
.addPathPatterns("/factory/zb/**").order(3);
// interceptorRegistry.addInterceptor(new ZbFactoryAccountsInterceptor(zbFactoryProperties))
// .addPathPatterns("/factory/zb/**").order(3);
interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis,environment,redisLockClient)).addPathPatterns("/**").order(1);
}

4
blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java

@ -4,8 +4,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -18,7 +16,6 @@ import com.logpm.factory.snm.entity.StaorderPackagesEntity;
import com.logpm.factory.snm.entity.StationOrderEntity;
import com.logpm.factory.snm.entity.StationlinenumEntity;
import com.logpm.factory.snm.service.*;
import com.logpm.factory.zb.vo.PackageInfoVO;
import com.logpm.factorydata.base.feign.IFactoryDataBaseClient;
import com.logpm.factorydata.base.vo.FactoryWarehouseBindVO;
import com.logpm.factorydata.enums.BrandEnums;
@ -43,7 +40,6 @@ import org.springblade.common.constant.PackagesTypeEnum;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.common.utils.CommonUtil;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

37
blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/controller/ZbFactoryDataController.java

@ -21,13 +21,16 @@ import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R;
import org.springblade.resource.feign.IOssClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
@ -35,6 +38,7 @@ import java.util.Objects;
/**
* 志邦工厂数据推送
*
* @author pref
* @data 2023-02-21
*/
@ -55,6 +59,7 @@ public class ZbFactoryDataController {
private final IOssClient ossClient;
/**
* 工厂数据推送接口
*/
@ -62,15 +67,15 @@ public class ZbFactoryDataController {
@PostMapping("/data")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "工厂数据推送", notes = "传入factoryOrderDTO")
public ZbResp data(@RequestBody ZBReceiptDTO zbReceiptDTO, HttpServletRequest request) {
public ZbResp data(@RequestBody ZBReceiptDTO zbReceiptDTO, HttpServletRequest request) {
log.info("############zbReceiptDTO: {}",zbReceiptDTO);
log.info("############zbReceiptDTO: {}", zbReceiptDTO);
String corpId = request.getHeader("corpId");
zbReceiptDTO.setCorpId(corpId);
String method = request.getParameter("method");
if(!"entry.order.create".equals(method)){
log.warn("############data: 暂不支持该功能 method={}",method);
if (!"entry.order.create".equals(method)) {
log.warn("############data: 暂不支持该功能 method={}", method);
return ZbResp.fail("暂不支持该功能");
}
@ -99,12 +104,12 @@ public class ZbFactoryDataController {
// //判断数据是否已存入
Long orderId = null;
try{
try {
orderId = zbFactoryDataService.saveData(zbReceiptDTO);
// orderStatusLog.setStatus(0);
zbFactoryLogEntity.setSaxStatus(1);
}catch (Exception e){
log.error("############data: 保存数据失败",e);
} catch (Exception e) {
log.error("############data: 保存数据失败", e);
//修改保存数据的状态
// orderStatusLog.setStatus(2);
zbFactoryLogEntity.setSaxStatus(2);
@ -113,9 +118,15 @@ public class ZbFactoryDataController {
zbFactoryLogService.saveOrUpdate(zbFactoryLogEntity);
//开启异步线程处理数据
if(!Objects.isNull(orderId)){
if (!Objects.isNull(orderId)) {
syncDataService.handlerZbDataToHt(orderId);
}
// 推送数据到新系统
try {
zbFactoryDataService.saveDataNew(zbReceiptDTO);
} catch (Exception e) {
log.error("志邦数据传新系统失败");
}
return ZbResp.success("成功");
}
@ -126,7 +137,7 @@ public class ZbFactoryDataController {
MultipartFile multi = getMultipartFile(logPath);
//上传到服务器
R r = ossClient.fileUpload(multi,"zb-logs");
R r = ossClient.fileUpload(multi, "zb-logs");
if (r.isSuccess()) {
BladeFile data = (BladeFile) r.getData();
return data.getLink();
@ -147,8 +158,8 @@ public class ZbFactoryDataController {
, true
, file.getName());
try (
InputStream input = Files.newInputStream(file.toPath());
OutputStream os = item.getOutputStream()) {
InputStream input = Files.newInputStream(file.toPath());
OutputStream os = item.getOutputStream()) {
// 流转移
IOUtils.copy(input, os);
} catch (Exception e) {

2
blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/service/IZbFactoryDataService.java

@ -16,4 +16,6 @@ public interface IZbFactoryDataService {
R handleStatusData(OrderStatusDTO orderStatusDTO);
void saveDataNew(ZBReceiptDTO zbReceiptDTO);
}

9
blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/service/impl/ZbFactoryDataServiceImpl.java

@ -17,12 +17,14 @@ import com.logpm.factory.zb.entity.ZbPackageInfoEntity;
import com.logpm.factory.zb.entity.ZbReceiptEntity;
import com.logpm.factory.zb.service.*;
import com.logpm.factory.zb.untils.QmSignUntil;
import com.logpm.factorydata.zbom.feign.IFactoryDataZbomClient;
import com.logpm.oldproject.entity.AdvanceDetailEntity;
import com.logpm.oldproject.feign.IAdvanceClient;
import com.logpm.oldproject.feign.IAdvanceDetailClient;
import com.logpm.oldproject.feign.IOrderDetailClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.annotations.LogpmAsync;
import org.springblade.common.utils.CommonUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
@ -46,6 +48,7 @@ public class ZbFactoryDataServiceImpl implements IZbFactoryDataService {
private final IPackageInfoService packageInfoService;
private final ZbFactoryProperties zbFactoryProperties;
private final IZbOrderLogService zbOrderLogService;
private final IFactoryDataZbomClient zbomClient;
@Override
public Long saveData(ZBReceiptDTO zbReceiptDTO) {
@ -218,6 +221,12 @@ public class ZbFactoryDataServiceImpl implements IZbFactoryDataService {
}
}
@Override
@LogpmAsync("asyncExecutor")
public void saveDataNew(ZBReceiptDTO zbReceiptDTO) {
zbomClient.order(JSONObject.toJSONString(zbReceiptDTO));
}
private String getZbUrl(String url, Map<String, String> params, String sign) {
String[] keys = params.keySet().toArray(new String[0]);

44
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java

@ -1,16 +1,25 @@
package com.logpm.trunkline.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.factorydata.enums.BrandEnums;
import com.logpm.factorydata.util.FactoryDataMessageSender;
import com.logpm.factorydata.vo.NodePushMsg;
import com.logpm.factorydata.vo.PushData;
import com.logpm.trunkline.bean.Resp;
import com.logpm.trunkline.dto.InComingDTO;
import com.logpm.trunkline.dto.OrderStatusDTO;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineBillladingPackageEntity;
import com.logpm.trunkline.service.*;
import com.logpm.trunkline.service.IInComingService;
import com.logpm.trunkline.service.IPackageTrackLogAsyncService;
import com.logpm.trunkline.service.ITrunklineAdvanceDetailService;
import com.logpm.trunkline.service.ITrunklineAdvanceService;
import com.logpm.trunkline.service.ITrunklineBillladingPackageServicie;
import com.logpm.trunkline.vo.TrunklineAdvanceVO;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import com.logpm.warehouse.feign.IWarehouseTrayTypeClient;
@ -26,7 +35,13 @@ import org.springblade.core.tool.utils.StringUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Service
@ -41,6 +56,7 @@ public class InComingServiceImpl implements IInComingService {
private final IPackageTrackLogAsyncService packageTrackLogAsyncService;
// private final DynamicDataSourceProvider dynamicDataSourceProvider;
private final RabbitTemplate rabbitTemplate;
private final FactoryDataMessageSender factoryDataMessageSender;
@Override
@ -145,6 +161,16 @@ public class InComingServiceImpl implements IInComingService {
Map<String, Object> map = new HashMap<>();
map.put("messageData", JSONUtil.toJsonStr(orderStatusDTO));
rabbitTemplate.convertAndSend(RabbitConstant.HWY_ORDER_STATUS_EXCHANGE, RabbitConstant.HWY_ORDER_STATUS_ROUTING, map);
NodePushMsg nodePushMsg = NodePushMsg.builder()
.operator(AuthUtil.getNickName())
.operatorTime(new Date())
.address("在【"+ warehouseName +"】入库")
.brand(BrandEnums.getByValue(advanceDetailEntity.getBrand()))
.node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY)
.content(Arrays.asList(PushData.builder().packageCode(packageCode).build()))
.build();
factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg);
} catch (Exception e) {
log.error("入库推送失败:{}", e);
}
@ -215,6 +241,20 @@ public class InComingServiceImpl implements IInComingService {
//存入日志
packageTrackLogAsyncService.addPackageTrackLog(tenantId, userId, deptId, nickName, orderPackageCodes, warehouseId, warehouseName, WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY.getCode(), "包件" + IncomingTypeEnum.getValue(incomingType));
total = total + detailList.size();
if(CollUtil.isNotEmpty(detailList)){
for (TrunklineAdvanceDetailEntity advanceDetailEntity : detailList) {
NodePushMsg nodePushMsg = NodePushMsg.builder()
.operator(AuthUtil.getNickName())
.operatorTime(new Date())
.address("在【"+ warehouseName +"】入库")
.brand(BrandEnums.getByValue(advanceDetailEntity.getBrand()))
.node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY)
.content(Arrays.asList(PushData.builder().packageCode(advanceDetailEntity.getOrderPackageCode()).build()))
.build();
factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg);
}
}
}
// DynamicDataSourceContextHolder.clear();

Loading…
Cancel
Save