Browse Source

Merge remote-tracking branch 'origin/pre-production' into pre-production

dev-warehouse
pref_mail@163.com 2 years ago
parent
commit
92484684af
  1. 8
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanFactoryOrder.java
  2. 2
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanOrderStatusLog.java
  3. 12
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanPackageInfo.java
  4. 3
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanPackageList.java
  5. 13
      blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java
  6. 6
      blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderInfoDTO.java
  7. 41
      blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderStatusDTO.java
  8. 9
      blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IAsyncDataService.java
  9. 55
      blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/AsyncDataServiceImpl.java
  10. 134
      blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java

8
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanFactoryOrder.java

@ -28,6 +28,10 @@ public class PanFactoryOrder extends BaseEntity {
@NotEmpty(message = "客户名称不能为空")
private String userName;
@ApiModelProperty(value = "发货单号")
@NotEmpty(message = "发货单号不能为空")
private String deliveryNumber;
@ApiModelProperty(value = "订单来源编码")
@NotEmpty(message = "订单来源编码不能为空")
private String sources;
@ -84,6 +88,10 @@ public class PanFactoryOrder extends BaseEntity {
@ApiModelProperty(value = "总体积")
private BigDecimal totalCapacity;
@ApiModelProperty(value = "工厂ID")
@NotEmpty(message = "工厂ID不能为空")
private String plantId;
@ApiModelProperty(value = "发货工厂名称")
@NotEmpty(message = "发货工厂名称不能为空")
private String sendFactory;

2
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanOrderStatusLog.java

@ -14,4 +14,6 @@ public class PanOrderStatusLog extends BaseEntity {
private String args;
private Integer type;
}

12
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanPackageInfo.java

@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
@Data
@ -18,6 +19,14 @@ public class PanPackageInfo extends BaseEntity {
@ApiModelProperty(value = "订单id")
private Long orderId;
@ApiModelProperty(value = "客户订单号")
@NotEmpty(message = "客户订单号不能为空")
private String orderNo;
@ApiModelProperty(value = "工厂ID")
@NotEmpty(message = "工厂ID不能为空")
private String plantId;
@ApiModelProperty(value = "包件码")
private String unitNo;
@ -54,4 +63,7 @@ public class PanPackageInfo extends BaseEntity {
@ApiModelProperty(value = "三级品类编码")
private String thirdPackCode;
@ApiModelProperty(value = "直发标识")
private String directSignage;
}

3
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanPackageList.java

@ -16,6 +16,9 @@ public class PanPackageList extends BaseEntity {
@ApiModelProperty(value = "包件id")
private Long packageId;
@ApiModelProperty(value = "包件编码")
private String unitNo;
@ApiModelProperty(value = "板件条码")
private String prosBarcode;

13
blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java

@ -23,10 +23,7 @@ import com.logpm.factory.snm.dto.*;
import com.logpm.factory.snm.entity.PanFactoryOrder;
import com.logpm.factory.snm.entity.PanPackageInfo;
import com.logpm.factory.snm.entity.PanPackageList;
import com.logpm.factory.snm.service.IPanFactoryDataService;
import com.logpm.factory.snm.service.IPanFactoryOrderService;
import com.logpm.factory.snm.service.IPanPackageInfoService;
import com.logpm.factory.snm.service.IPanPackageListService;
import com.logpm.factory.snm.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
@ -57,9 +54,8 @@ public class PanFactoryDataController extends BladeController {
private final IPanFactoryOrderService factoryOrderService;
private final IPanPackageInfoService packageInfoService;
private final IPanPackageListService packageListService;
private final IPanFactoryDataService factoryDataService;
private final IAsyncDataService syncDataService;
// @ResponseBody
// @PostMapping("/token")
@ -128,6 +124,9 @@ public class PanFactoryDataController extends BladeController {
packageListService.saveBatch(PanPackagelist);
}
//开启异步线程处理数据
syncDataService.handlerPanDataToHt();
return Resp.successOrderNo(factoryOrder.getOrderNo(),"SUCCESS");
}
@ -139,7 +138,7 @@ public class PanFactoryDataController extends BladeController {
public R sendOrders(@Validated @RequestBody OrderInfoDTO orderInfoDTO) {
log.info("############sendOrders: ");
try{
factoryDataService.handleData(orderInfoDTO);
// factoryDataService.handleData(orderInfoDTO);
}catch (CustomerException e){
log.error(e.message,e);
return R.fail(e.code,e.message);

6
blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderInfoDTO.java

@ -33,8 +33,10 @@ public class OrderInfoDTO {
@NotEmpty(message = "客户订单号不能为空")
private String orderNo;//客户订单号
private String loadingList;//WMS装车清单号
private String plantId;//工厂id
private String deliveryNumber;//发货单号
@NotEmpty(message = "物流单号不能为空")
private String logiBillNo;//物流单号
private String logiBillNo;//物流单号
}

41
blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderStatusDTO.java

@ -17,6 +17,7 @@
package com.logpm.factory.snm.dto;
import lombok.Data;
import org.springblade.core.tool.utils.StringUtil;
import javax.validation.constraints.NotEmpty;
@ -36,6 +37,9 @@ public class OrderStatusDTO {
@NotEmpty(message = "客户订单号不能为空")
private String orderNo;//客户订单号
@NotEmpty(message = "工厂ID不能为空")
private String plantId;//工厂ID
@NotEmpty(message = "物流单号不能为空")
private String logiBillNo;//物流单号
@ -54,4 +58,41 @@ public class OrderStatusDTO {
@NotEmpty(message = "状态")
private String status;//状态
/**
* 验证参数是否都存在
* @return
*/
public boolean verifyData(){
if(StringUtil.isBlank(dispatchNumber)){
return false;
}
if(StringUtil.isBlank(orderNo)){
return false;
}
if(StringUtil.isBlank(plantId)){
return false;
}
if(StringUtil.isBlank(logiBillNo)){
return false;
}
if(StringUtil.isBlank(unitNo)){
return false;
}
if(StringUtil.isBlank(operationTime)){
return false;
}
if(StringUtil.isBlank(currentWarehouse)){
return false;
}
if(StringUtil.isBlank(destinationWarehouse)){
return false;
}
if(StringUtil.isBlank(status)){
return false;
}
return true;
}
}

9
blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IAsyncDataService.java

@ -0,0 +1,9 @@
package com.logpm.factory.snm.service;
public interface IAsyncDataService {
void handlerPanDataToHt();
}

55
blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/AsyncDataServiceImpl.java

@ -0,0 +1,55 @@
package com.logpm.factory.snm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.factory.snm.entity.PanFactoryOrder;
import com.logpm.factory.snm.service.IAsyncDataService;
import com.logpm.factory.snm.service.IPanFactoryOrderService;
import com.logpm.factory.snm.service.IPanPackageInfoService;
import com.logpm.factory.snm.service.IPanPackageListService;
import com.logpm.oldproject.feign.IAdvanceClient;
import com.logpm.oldproject.feign.IAdvanceDetailClient;
import com.logpm.oldproject.feign.IServiceNumClient;
import com.logpm.oldproject.feign.IWarehouseClient;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 异步线程处理
*/
@Log4j2
@Service
@AllArgsConstructor
public class AsyncDataServiceImpl implements IAsyncDataService {
private final IAdvanceClient iAdvanceClient;
private final IAdvanceDetailClient advanceDetailClient;
private final IServiceNumClient serviceNumClient;
private final IWarehouseClient warehouseClient;
private final IPanFactoryOrderService panFactoryOrderService;
private final IPanPackageInfoService panPackageInfoService;
private final IPanPackageListService panPackageListService;
/**
* 处理皮阿诺数据推送到汇通老库
*/
@Override
@Async
public void handlerPanDataToHt() {
log.info("################handlerDataToHt: 处理皮阿诺订单数据到");
//查询需要同步的订单
QueryWrapper<PanFactoryOrder> orderQueryWrapper = new QueryWrapper<>();
orderQueryWrapper.eq("status",1)
.eq("is_deleted",0);
List<PanFactoryOrder> list = panFactoryOrderService.list(orderQueryWrapper);
log.info("#########handlerDataToHt: 待处理的订单数量为{}",list.size());
for (PanFactoryOrder panFactoryOrder:list){
Long id = panFactoryOrder.getId();
log.info("#########handlerDataToHt: 当前处理的订单id={}",id);
}
}
}

134
blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java

@ -10,9 +10,11 @@ import com.logpm.factory.snm.dto.OrderInfoDTO;
import com.logpm.factory.snm.dto.OrderStatusDTO;
import com.logpm.factory.snm.entity.PanFactoryOrder;
import com.logpm.factory.snm.entity.PanOrderStatusLog;
import com.logpm.factory.snm.entity.PanPackageInfo;
import com.logpm.factory.snm.service.IPanFactoryDataService;
import com.logpm.factory.snm.service.IPanFactoryOrderService;
import com.logpm.factory.snm.service.IPanOrderStatusLogService;
import com.logpm.factory.snm.service.IPanPackageInfoService;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -38,6 +40,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
private final PanFactoryProperties panFactoryProperties;
private final IPanOrderStatusLogService panOrderStatusLogService;
private final IPanPackageInfoService panPackageInfoService;
// @Override
// public FactoryTokenVO getToken(String corpId, String appKey, String appSecret) throws NoSuchAlgorithmException {
@ -85,16 +88,62 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
@Transactional(rollbackFor = Exception.class)
@Override
public void handleData(OrderInfoDTO orderInfoDTO) {
//先保存原始请求数据
PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog();
panOrderStatusLog.setArgs(JSONObject.toJSONString(orderInfoDTO));
panOrderStatusLog.setStatus(1);
panOrderStatusLog.setType(1);
panOrderStatusLogService.save(panOrderStatusLog);
//根据客户订单号去查询WMS装车清单号
QueryWrapper<PanFactoryOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_no",orderInfoDTO.getOrderNo());
PanFactoryOrder panFactoryOrder = factoryOrderService.getOne(queryWrapper);
String loadingList = panFactoryOrder.getLoadingList();//装车清单编号
orderInfoDTO.setLoadingList(loadingList);
String plantId = panFactoryOrder.getPlantId();//工厂id
String deliveryNumber = panFactoryOrder.getDeliveryNumber();
orderInfoDTO.setPlantId(plantId);
orderInfoDTO.setDeliveryNumber(deliveryNumber);
//拼接参数
Map<String,Object> map = new HashMap<>();
map.put("payload", JSONObject.toJSONString(orderInfoDTO));
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String s = gson.toJson(map);
//先获取token
// String panToken = getPanToken();
//
//请求参数
logger.info("##############handleData: 推送包件状态请求参数 {}",s);
// //处理逻辑
// //TODO 这里还差那边给到请求接口
// String result = HttpRequest.post(panFactoryProperties.getUrl()+"/hitf/v1/rest/invoke?namespace=HZERO&serverCode=HUITONG_MID_RECEIVE")
// .header("Authorization","Bearer "+panToken)
// .header("Content-Type","application/json")
// .body(s).timeout(5 * 1000)
// .execute().body();
//
// logger.info("##############handleData: 推送包件状态返回参数 {}",result);
//
// //把结果字符串转为json对象
// JSONObject jsonObject = JSONObject.parseObject(result);
// JSONObject payload = jsonObject.getJSONObject("payload");
// if(!Objects.isNull(payload)){
// Integer code = payload.getInteger("code");
// String message = payload.getString("data");
// if(code.equals(1)){
// logger.info("##########handleData: 物流状态传递成功");
// panOrderStatusLog.setStatus(0);
// panOrderStatusLogService.saveOrUpdate(panOrderStatusLog);
// }else{
// throw new CustomerException(400,message);
// }
// }else{
// throw new CustomerException(400,"返回格式有误:"+result);
// }
//推送到皮阿诺系统
String url = "";
// String result = HttpRequest.post(url+"/oauth/oauth/token").form(map).timeout(5 * 1000).execute().body();
}
@ -105,47 +154,62 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog();
panOrderStatusLog.setArgs(JSONObject.toJSONString(orderStatusDTO));
panOrderStatusLog.setStatus(1);
panOrderStatusLog.setType(2);
panOrderStatusLogService.save(panOrderStatusLog);
//通过包件码查询是否是要推送的订单
String unitNo = orderStatusDTO.getUnitNo();//包件码
QueryWrapper<PanPackageInfo> packageInfoQueryWrapper = new QueryWrapper<>();
packageInfoQueryWrapper.eq("unit_no",unitNo);
PanPackageInfo one = panPackageInfoService.getOne(packageInfoQueryWrapper);
if(Objects.isNull(one)){
logger.info("#############handleStatusData: 当前包条码未找到对应数据unitNo={}",unitNo);
throw new CustomerException(400,"未找到包件数据");
}
//判断数据是都已存在
if(!orderStatusDTO.verifyData()){
logger.info("#############handleStatusData: 数据不齐全 orderStatusDTO={}",orderStatusDTO);
throw new CustomerException(400,"数据不齐全");
}
//拼接参数
Map<String,Object> map = new HashMap<>();
// map.put("payload",JSONObject.toJSONString(orderStatusDTO));
// map.put("payload", CommonUtil.formatJson(orderStatusDTO));
map.put("payload", JSONObject.toJSONString(orderStatusDTO));
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String s = gson.toJson(map);
//先获取token
String panToken = getPanToken();
// //先获取token
// String panToken = getPanToken();
//
//请求参数
logger.info("##############handleStatusData: 推送包件状态请求参数 {}",s);
//处理逻辑
String result = HttpRequest.post(panFactoryProperties.getUrl()+"/hitf/v1/rest/invoke?namespace=HZERO&serverCode=OPEN&interfaceCode=HUITONG_RECEIVE")
.header("Authorization","Bearer "+panToken)
.header("Content-Type","application/json")
.body(s).timeout(5 * 1000)
.execute().body();
logger.info("##############handleStatusData: 推送包件状态返回参数 {}",result);
//把结果字符串转为json对象
JSONObject jsonObject = JSONObject.parseObject(result);
JSONObject payload = jsonObject.getJSONObject("payload");
if(!Objects.isNull(payload)){
Integer code = payload.getInteger("code");
String message = payload.getString("data");
if(code.equals(1)){
logger.info("##########handleStatusData: 物流状态传递成功");
panOrderStatusLog.setStatus(0);
panOrderStatusLogService.saveOrUpdate(panOrderStatusLog);
}else{
throw new CustomerException(400,message);
}
}else{
throw new CustomerException(400,"返回格式有误:"+result);
}
// //处理逻辑
// String result = HttpRequest.post(panFactoryProperties.getUrl()+"/hitf/v1/rest/invoke?namespace=HZERO&serverCode=OPEN&interfaceCode=HUITONG_RECEIVE")
// .header("Authorization","Bearer "+panToken)
// .header("Content-Type","application/json")
// .body(s).timeout(5 * 1000)
// .execute().body();
//
// logger.info("##############handleStatusData: 推送包件状态返回参数 {}",result);
//
// //把结果字符串转为json对象
// JSONObject jsonObject = JSONObject.parseObject(result);
// JSONObject payload = jsonObject.getJSONObject("payload");
// if(!Objects.isNull(payload)){
// Integer code = payload.getInteger("code");
// String message = payload.getString("data");
// if(code.equals(1)){
// logger.info("##########handleStatusData: 物流状态传递成功");
// panOrderStatusLog.setStatus(0);
// panOrderStatusLogService.saveOrUpdate(panOrderStatusLog);
// }else{
// throw new CustomerException(400,message);
// }
// }else{
// throw new CustomerException(400,"返回格式有误:"+result);
// }
}

Loading…
Cancel
Save