Browse Source

Merge branch 'dev' into pre-production

pre-production
zhaoqiaobo 3 days ago
parent
commit
908ea0aa61
  1. 124
      blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/FactoryNodePushEntity.java
  2. 16
      blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/FactoryNodePushMapper.java
  3. 5
      blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/FactoryNodePushMapper.xml
  4. 14
      blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/FactoryNodePushService.java
  5. 50
      blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/FactoryDataServiceImpl.java
  6. 22
      blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/FactoryNodePushServiceImpl.java

124
blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/FactoryNodePushEntity.java

@ -0,0 +1,124 @@
package com.logpm.factorydata.suofeiya.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springblade.core.mp.base.BaseEntity;
/**
* 索菲亚工厂节点数据推送记录表
*
* @Author zqb
* @Date 2024/3/26
**/
@Builder
@Data
@TableName("sfy_factory_node_push")
@ApiModel(value = "索菲亚工厂节点数据推送记录表", description = "索菲亚工厂节点数据推送记录表")
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class FactoryNodePushEntity extends BaseEntity {
/**
* 预留1
*/
@ApiModelProperty(value = "预留1")
private String reserve1;
/**
* 预留2
*/
@ApiModelProperty(value = "预留2")
private String reserve2;
/**
* 预留3
*/
@ApiModelProperty(value = "预留3")
private String reserve3;
/**
* 预留4
*/
@ApiModelProperty(value = "预留4")
private String reserve4;
/**
* 预留5
*/
@ApiModelProperty(value = "预留5")
private String reserve5;
/**
* 订单类型
*/
@ApiModelProperty(value = "订单类型")
private String orderType;
/**
* 操作节点
*/
@ApiModelProperty(value = "操作节点")
private String logisticsStatus;
/**
* 包条码
*/
@ApiModelProperty(value = "包条码")
private String packageCode;
/**
* 发货单号
*/
@ApiModelProperty(value = "发货单号")
private String shipPlanNo;
/**
* 公司
*/
@ApiModelProperty(value = "公司")
private String companyCode;
/**
* 时间戳
*/
@ApiModelProperty(value = "时间戳")
private Long timestamp;
/**
* 加密字符
*/
@ApiModelProperty(value = "加密字符")
private String digest;
/**
* 发送状态
*/
@ApiModelProperty(value = "发送状态(0:成功,-1:失败,1:取消)")
private String sendStatus;
/**
* 加密秘钥
*/
@ApiModelProperty(value = "加密秘钥")
private String appKey;
/**
* url
*/
@ApiModelProperty(value = "url")
private String sendUrl;
/**
* 内容
*/
@ApiModelProperty(value = "内容")
private String content;
/**
* 返回值
*/
@ApiModelProperty(value = "返回值")
private String resultContent;
/**
* 租户
*/
@ApiModelProperty(value = "租户")
private String tenantCode;
/**
* 作业仓库
*/
@ApiModelProperty(value = "作业仓库")
private String warehouse;
}

16
blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/FactoryNodePushMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.suofeiya.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.suofeiya.entity.FactoryNodePushEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 索菲亚工厂节点数据推送记录表 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface FactoryNodePushMapper extends BaseMapper<FactoryNodePushEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/FactoryNodePushMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.suofeiya.mapper.FactoryNodePushMapper">
</mapper>

14
blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/FactoryNodePushService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.suofeiya.service;
import com.logpm.factorydata.suofeiya.entity.FactoryNodePushEntity;
import org.springblade.core.mp.base.BaseService;
/**
* 索菲亚工厂节点数据推送记录表 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface FactoryNodePushService extends BaseService<FactoryNodePushEntity> {
}

50
blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/FactoryDataServiceImpl.java

@ -18,6 +18,7 @@ import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.factorydata.enums.SaxStatusEnums;
import com.logpm.factorydata.suofeiya.entity.DeliveryNoteEntity;
import com.logpm.factorydata.suofeiya.entity.FactoryNodePushEntity;
import com.logpm.factorydata.suofeiya.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.suofeiya.entity.OrderInfoEntity;
import com.logpm.factorydata.suofeiya.entity.PackageInfoEntity;
@ -28,6 +29,7 @@ import com.logpm.factorydata.suofeiya.pros.FactoryDataSuoFeiYaProperties;
import com.logpm.factorydata.suofeiya.pros.OldProperties;
import com.logpm.factorydata.suofeiya.service.DeliveryNoteService;
import com.logpm.factorydata.suofeiya.service.FactoryDataService;
import com.logpm.factorydata.suofeiya.service.FactoryNodePushService;
import com.logpm.factorydata.suofeiya.service.FactoryOrderLogService;
import com.logpm.factorydata.suofeiya.service.OrderInfoService;
import com.logpm.factorydata.suofeiya.service.PackageInfoService;
@ -68,6 +70,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
private final FactoryOrderLogService logService;
private final OldProperties oldProperties;
private final FactoryDataSuoFeiYaProperties dataSuoFeiYaProperties;
private final FactoryNodePushService factoryNodePushService;
@Override
@Transactional(rollbackFor = Exception.class)
@ -198,6 +201,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
// 按订单号和运单号进行分组
if (CollUtil.isNotEmpty(content)) {
for (Map.Entry<String, Set<String>> entry : packageCodeMap.entrySet()) {
FactoryNodePushEntity nodePushEntity = new FactoryNodePushEntity();
String key = entry.getKey();
Set<String> value = entry.getValue();
JSONObject jsons = new JSONObject();
@ -221,11 +225,23 @@ public class FactoryDataServiceImpl implements FactoryDataService {
packages.add(js);
}
}
if (CollUtil.isNotEmpty(packages)) {
String paNo = packages.stream().map(i -> i.getStr("paNo")).collect(Collectors.joining(","));
nodePushEntity.setPackageCode(paNo);
}
jsons.set("packageInfo", new JSONArray(packages));
if(StrUtil.equals(key, "Z")){
if (StrUtil.equals(key, "Z")) {
jsons.set("orderType", key);
nodePushEntity.setOrderType(key);
}
nodePushEntity.setLogisticsStatus(factoryNode.getText());
String jsonStr = JSONUtil.toJsonStr(jsons);
nodePushEntity.setContent(jsonStr);
nodePushEntity.setTenantCode(AuthUtil.getTenantId());
nodePushEntity.setAppKey(appKey);
nodePushEntity.setCompanyCode(companyCode);
nodePushEntity.setTimestamp(time);
nodePushEntity.setWarehouse(entries.getStr("warehouse"));
if (oldProperties.getEnable()) {
try {
log.info("推送节点数据:{}", jsonStr);
@ -238,7 +254,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
}
if (dataSuoFeiYaProperties.getPush().getPushEnable()) {
String paStatusUrl = dataSuoFeiYaProperties.getPush().getPaStatusUrl();
sendFactory(companyCode, jsonStr, time, appKey, paStatusUrl);
sendFactory(companyCode, jsonStr, time, appKey, paStatusUrl, nodePushEntity);
}
}
}
@ -246,6 +262,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
// 推送配送单计划
if (CollUtil.isNotEmpty(content)) {
for (Map.Entry<String, Set<String>> entry : packageCodeMap.entrySet()) {
FactoryNodePushEntity nodePushEntity = new FactoryNodePushEntity();
String key = entry.getKey();
Set<String> value = entry.getValue();
JSONObject jsons = new JSONObject();
@ -262,9 +279,14 @@ public class FactoryDataServiceImpl implements FactoryDataService {
packages.add(pushData.getPackageCode());
}
}
if (CollUtil.isNotEmpty(packages)) {
String paNo = packages.stream().collect(Collectors.joining(","));
nodePushEntity.setPackageCode(paNo);
}
if (StrUtil.isNotEmpty(main)) {
JSONObject jsonObject = JSONUtil.parseObj(main);
jsons.set("shipPlanNo", jsonObject.getStr("trainNumber"));
nodePushEntity.setShipPlanNo(jsonObject.getStr("trainNumber"));
jsons.set("receiver", jsonObject.getStr("receiver"));
jsons.set("receiveAddr", jsonObject.getStr("receiveAddr"));
jsons.set("receiveTel", jsonObject.getStr("receiveTel"));
@ -273,10 +295,18 @@ public class FactoryDataServiceImpl implements FactoryDataService {
jsons.set("paNo", JSONUtil.toJsonStr(packages));
jsons.set("remark", "");
jsons.set("orderExtendFields", new JSONArray());
if(StrUtil.equals(key, "Z")){
if (StrUtil.equals(key, "Z")) {
jsons.set("orderType", key);
nodePushEntity.setOrderType(key);
}
nodePushEntity.setLogisticsStatus(factoryNode.getText());
String jsonStr = JSONUtil.toJsonStr(jsons);
nodePushEntity.setContent(jsonStr);
nodePushEntity.setTenantCode(AuthUtil.getTenantId());
nodePushEntity.setAppKey(appKey);
nodePushEntity.setCompanyCode(companyCode);
nodePushEntity.setTimestamp(time);
nodePushEntity.setWarehouse(entries.getStr("warehouse"));
if (oldProperties.getEnable()) {
try {
log.info("推送节点数据:{}", jsonStr);
@ -289,14 +319,14 @@ public class FactoryDataServiceImpl implements FactoryDataService {
}
if (dataSuoFeiYaProperties.getPush().getPushEnable()) {
String paStatusUrl = dataSuoFeiYaProperties.getPush().getShipPlanUrl();
sendFactory(companyCode, jsonStr, time, appKey, paStatusUrl);
sendFactory(companyCode, jsonStr, time, appKey, paStatusUrl, nodePushEntity);
}
}
}
}
}
private void sendFactory(String companyCode, String jsonStr, Long time, String appKey, String paStatusUrl) {
private void sendFactory(String companyCode, String jsonStr, Long time, String appKey, String paStatusUrl, FactoryNodePushEntity nodePushEntity) {
try {
Map<String, Object> param = new HashMap<>();
param.put("companyCode", companyCode);
@ -306,8 +336,18 @@ public class FactoryDataServiceImpl implements FactoryDataService {
String digest = MD5.create().digestHex(jsonStr + appKey + time);
String encode = Base64.encode(digest);
param.put("digest", encode);
nodePushEntity.setDigest(digest);
nodePushEntity.setSendUrl(dataSuoFeiYaProperties.getPush().getPushHost() + paStatusUrl);
log.info("推送节点数据:{}", JSONUtil.toJsonStr(param));
String post = HttpUtil.post(dataSuoFeiYaProperties.getPush().getPushHost() + paStatusUrl, param);
nodePushEntity.setResultContent(post);
JSONObject entries = JSONUtil.parseObj(post);
if (StrUtil.equals(entries.getStr("result_code"), "0000")) {
nodePushEntity.setSendStatus("0");
} else {
nodePushEntity.setSendStatus("-1");
}
factoryNodePushService.save(nodePushEntity);
log.info("推送结果:{}", post);
} catch (Exception e) {
e.printStackTrace();

22
blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/FactoryNodePushServiceImpl.java

@ -0,0 +1,22 @@
package com.logpm.factorydata.suofeiya.service.impl;
import com.logpm.factorydata.suofeiya.entity.FactoryNodePushEntity;
import com.logpm.factorydata.suofeiya.mapper.FactoryNodePushMapper;
import com.logpm.factorydata.suofeiya.service.FactoryNodePushService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 索菲亚工厂节点数据推送记录表 业务实现类
*
* @Author zqb
* @Date 2024/4/26
**/
@Slf4j
@Service
@AllArgsConstructor
public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushMapper, FactoryNodePushEntity> implements FactoryNodePushService {
}
Loading…
Cancel
Save