Browse Source

1.梦天对接接口大致完成

2.推送数据逻辑优化
test
zhenghaoyu 2 years ago
parent
commit
de7266d3aa
  1. 4
      blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java
  2. 3
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrder.java
  3. 3
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtPackageInfo.java
  4. 13
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/vo/ImagesVO.java
  5. 3
      blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceClient.java
  6. 13
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/constant/FactoryConstant.java
  7. 40
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java
  8. 19
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/dto/ReceiveBodyDTO.java
  9. 26
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/dto/ReceiveInfoDTO.java
  10. 12
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/dto/ReceivePhotoDTO.java
  11. 2
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/IAsyncDataService.java
  12. 6
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/IFactoryCommonService.java
  13. 183
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java
  14. 18
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryCommonServiceImpl.java
  15. 27
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/utils/CommonUntis.java
  16. 3
      blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java
  17. 18
      blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java
  18. 80
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/controller/MtFactoryDataController.java
  19. 7
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtFactoryOrderMapper.java
  20. 20
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtFactoryOrderMapper.xml
  21. 7
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtPackageInfoMapper.java
  22. 11
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/IMtFactoryDataService.java
  23. 11
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/IMtFactoryOrderService.java
  24. 7
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/IMtPackageInfoService.java
  25. 252
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java
  26. 13
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryOrderServiceImpl.java
  27. 13
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtPackageInfoServiceImpl.java
  28. 8
      blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java
  29. 33
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OpenOrderHandler.java
  30. 80
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java
  31. 85
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java
  32. 3
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceMapper.xml

4
blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java

@ -27,5 +27,9 @@ public interface RabbitConstant {
String DEAL_WITH_EXCHANGE = "deal_with_exchange";
String DEAL_WITH_ROUTING = "deal_with_routing";
String RECEIVE_INFO_QUEUE = "receive_info_queue";
String RECEIVE_INFO_EXCHANGE = "receive_info_exchange";
String RECEIVE_INFO_ROUTING = "receive_info_routing";
}

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

@ -78,4 +78,7 @@ public class MtFactoryOrder extends BaseEntity {
@ApiModelProperty(value = "包件数")
private String quantity;
@ApiModelProperty(value = "发货单id")
private Long mainId;
}

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

@ -51,4 +51,7 @@ public class MtPackageInfo extends BaseEntity {
@ApiModelProperty(value = "尺寸")
private String size;
@ApiModelProperty(value = "订单id")
private Long orderId;
}

13
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/vo/ImagesVO.java

@ -0,0 +1,13 @@
package com.logpm.factory.snm.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class ImagesVO implements Serializable {
private String suffix;//后缀
private byte[] imageBytes;//图片字节流
}

3
blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceClient.java

@ -23,6 +23,7 @@ import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@ -75,7 +76,7 @@ public interface IAdvanceClient {
* @return
*/
@GetMapping(API_PREFIX + "/queryDataOne")
AdvanceEntity getQueryDataOne(String orderSelfNum);
AdvanceEntity getQueryDataOne(@RequestParam String orderSelfNum);
}

13
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/constant/FactoryConstant.java

@ -0,0 +1,13 @@
package com.logpm.factory.comfac.constant;
/**
* 工厂名称常量池
*
* @author zhy
*/
public class FactoryConstant {
public static final String PIANO = "皮阿诺";
public static final String MENGT = "梦天";
}

40
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java

@ -2,9 +2,11 @@ package com.logpm.factory.comfac.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.factory.comfac.service.IOrderStatusLogService;
import com.logpm.factory.comfac.dto.OrderInfoDTO;
import com.logpm.factory.comfac.dto.OrderStatusDTO;
import com.logpm.factory.comfac.dto.ReceiveInfoDTO;
import com.logpm.factory.comfac.service.IFactoryCommonService;
import com.logpm.factory.comfac.service.IOrderStatusLogService;
import com.logpm.factory.snm.entity.OrderStatusLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -32,6 +34,7 @@ public class FactoryCommonController {
private final RabbitTemplate rabbitTemplate;
private final IOrderStatusLogService orderStatusLogService;
private final IFactoryCommonService factoryCommonService;
@ResponseBody
@PostMapping("/sendOrders")
@ -107,5 +110,40 @@ public class FactoryCommonController {
}
@ResponseBody
@PostMapping("/sendReceiveInfo")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "订单状态推送", notes = "传入orderInfoDTO")
public R sendReceiveInfo(@RequestBody ReceiveInfoDTO receiveInfoDTO) {
log.info("############sendReceiveInfo: 请求参数{}", receiveInfoDTO);
//处理数据
// R r = factoryCommonService.sendReceiveInfo(receiveInfoDTO);
try{
//先保存原始请求数据
OrderStatusLog orderStatusLog = new OrderStatusLog();
orderStatusLog.setArgs(JSONObject.toJSONString(receiveInfoDTO));
orderStatusLog.setStatus(1);
orderStatusLog.setType(4);
orderStatusLogService.save(orderStatusLog);
Map<String,Object> map=new HashMap<>();
map.put("messageId", CommonUtil.getUUID());
map.put("logId", orderStatusLog.getId());
map.put("messageData",receiveInfoDTO);
map.put("createTime",new Date().getTime());
//将消息携带绑定键值
rabbitTemplate.convertAndSend(RabbitConstant.RECEIVE_INFO_EXCHANGE, RabbitConstant.RECEIVE_INFO_ROUTING, map);
return R.success("调用成功");
}catch (CustomerException e){
log.error(e.message,e);
return R.fail(e.code,e.message);
}catch (Exception e){
log.error("############sendReceiveInfo: 系统异常",e);
return R.fail(500,"############sendReceiveInfo: 系统异常");
}
}
}

19
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/dto/ReceiveBodyDTO.java

@ -0,0 +1,19 @@
package com.logpm.factory.comfac.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class ReceiveBodyDTO implements Serializable {
private String produceOrderCode;//生产单号
private String orderCode;//订单自编码
private String unitNo;//包条码
private String operateDate;//签收时间
}

26
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/dto/ReceiveInfoDTO.java

@ -0,0 +1,26 @@
package com.logpm.factory.comfac.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
public class ReceiveInfoDTO implements Serializable {
private String invoiceOrderCode;//发运单编号
private String sendTaskId;//送货任务ID
private String warehouse;//仓库
private String warehouseCode;//仓库编码
private String receiver;//收货人
private List<ReceiveBodyDTO> receiveBodyList = new ArrayList<>();
private List<ReceivePhotoDTO> receivePhotoList = new ArrayList<>();
}

12
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/dto/ReceivePhotoDTO.java

@ -0,0 +1,12 @@
package com.logpm.factory.comfac.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class ReceivePhotoDTO implements Serializable {
private String url;//图片地址
}

2
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/IAsyncDataService.java

@ -6,4 +6,6 @@ public interface IAsyncDataService {
void handlerPanDataToHt();
void handlerMtDataToHt();
}

6
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/IFactoryCommonService.java

@ -0,0 +1,6 @@
package com.logpm.factory.comfac.service;
public interface IFactoryCommonService {
}

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

@ -2,19 +2,24 @@ package com.logpm.factory.comfac.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.logpm.factory.snm.constant.PanFactoryEnum;
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.comfac.constant.FactoryConstant;
import com.logpm.factory.comfac.service.IAsyncDataService;
import com.logpm.factory.mt.service.IMtFactoryOrderMainService;
import com.logpm.factory.mt.service.IMtFactoryOrderService;
import com.logpm.factory.mt.service.IMtPackageInfoService;
import com.logpm.factory.pan.service.IPanFactoryOrderService;
import com.logpm.factory.pan.service.IPanPackageInfoService;
import com.logpm.factory.pan.service.IPanPackageListService;
import com.logpm.factory.snm.constant.PanFactoryEnum;
import com.logpm.factory.snm.entity.*;
import com.logpm.oldproject.entity.AdvanceDetailEntity;
import com.logpm.oldproject.entity.AdvanceEntity;
import com.logpm.oldproject.entity.DetailProductEntity;
import com.logpm.oldproject.entity.ServiceNumEntity;
import com.logpm.oldproject.feign.*;
import com.logpm.oldproject.feign.IAdvanceClient;
import com.logpm.oldproject.feign.IAdvanceDetailClient;
import com.logpm.oldproject.feign.IDetailProductClient;
import com.logpm.oldproject.feign.IServiceNumClient;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springblade.core.tool.utils.StringUtil;
@ -42,6 +47,10 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
private final IPanPackageInfoService panPackageInfoService;
private final IPanPackageListService panPackageListService;
private final IMtFactoryOrderService mtFactoryOrderService;
private final IMtFactoryOrderMainService mtFactoryOrderMainService;
private final IMtPackageInfoService mtPackageInfoService;
/**
* 处理皮阿诺数据推送到汇通老库
@ -68,7 +77,7 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
advanceEntity.setArea(StringUtil.isBlank(panFactoryOrder.getReceiverArea())?"":panFactoryOrder.getReceiverArea()); // 区域
advanceEntity.setOrderTypeName(""); //订单类型名称 可以为空
advanceEntity.setOrderClassName("工厂"); //订单类型 可以为空
advanceEntity.setType("皮阿诺");
advanceEntity.setType(FactoryConstant.PIANO);
advanceEntity.setTotal(panFactoryOrder.getServiceCount()); //订单总数据
advanceEntity.setMctsTruck(StringUtil.isBlank(panFactoryOrder.getDeliveryNumber())?"":panFactoryOrder.getDeliveryNumber()); //车次
advanceEntity.setMtdsNo("");// MTDS单号 可以为空
@ -133,7 +142,7 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
advanceDetailEntity.setSerialKey("");//序列号 可以为空
advanceDetailEntity.setArea("");//区域
advanceDetailEntity.setOrderSelfNum(panFactoryOrder.getOrderNo());//订单自编号
advanceDetailEntity.setType("皮阿诺");//订单来源
advanceDetailEntity.setType(FactoryConstant.PIANO);//订单来源
advanceDetailEntity.setSystemType("线上");//订单类型
advanceDetailEntity.setOrderNum("");//MSCS单号 可以为空
advanceDetailEntity.setIsOpai(0);//是否干仓配:1=是,0=否
@ -231,4 +240,164 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
serviceNumClient.addServiceNum(serviceNumEntityList);
log.info("##############handlerDataToHt: 处理数据完成");
}
@Override
@Async
public void handlerMtDataToHt() {
log.info("################handlerMtDataToHt: 处理梦天订单数据到");
//查询需要同步的订单
QueryWrapper<MtFactoryOrder> orderQueryWrapper = new QueryWrapper<>();
orderQueryWrapper.eq("status",1)
.eq("is_deleted",0);
List<MtFactoryOrder> mtFactoryOrders = mtFactoryOrderService.list(orderQueryWrapper);
List<ServiceNumEntity> serviceNumEntityList = new ArrayList<>();
log.info("#########handlerMtDataToHt: 待处理的订单数量为{}",mtFactoryOrders.size());
for (MtFactoryOrder mtFactoryOrder:mtFactoryOrders){
Long orderId = mtFactoryOrder.getId();
Long mainId = mtFactoryOrder.getMainId();
MtFactoryOrderMain mtFactoryOrderMain = mtFactoryOrderMainService.getById(mainId);
log.info("#########handlerMtDataToHt: 当前处理的订单id={}",orderId);
//添加订单信息
AdvanceEntity advanceEntity = new AdvanceEntity();
advanceEntity.setOrderSelfNum(StringUtil.isBlank(mtFactoryOrder.getOrderCode())?"":mtFactoryOrder.getOrderCode()); //订单自编号
advanceEntity.setSiteName(""); // 基地 TODO 需要映射
advanceEntity.setArea(""); // 区域
advanceEntity.setOrderTypeName(""); //订单类型名称 可以为空
advanceEntity.setOrderClassName("工厂"); //订单类型 可以为空
advanceEntity.setType(FactoryConstant.MENGT);
advanceEntity.setTotal(Integer.parseInt(mtFactoryOrder.getQuantity())); //订单总数据
advanceEntity.setMctsTruck(""); //车次
advanceEntity.setMtdsNo("");// MTDS单号 可以为空
advanceEntity.setFirstPackName(""); //一级品类
advanceEntity.setFirstPackCode(""); //一级品类
advanceEntity.setDealerName(""); //商场名称
advanceEntity.setDealerCode(StringUtil.isBlank(mtFactoryOrder.getDealerCode())?"":mtFactoryOrder.getDealerCode()); //商场编码
advanceEntity.setDueDate(""); // 交期
advanceEntity.setIsOpai(0); //是否干仓配
advanceEntity.setOrderNum("");//MSCS订单号 可以为空
advanceEntity.setCarrierName("汇通");//承运商 可以为空
advanceEntity.setCustomerName(StringUtil.isBlank(mtFactoryOrder.getCustomName())?"":mtFactoryOrder.getCustomName()); //顾客名称
advanceEntity.setCustomerPhone(StringUtil.isBlank(mtFactoryOrder.getCustomPhone())?"":mtFactoryOrder.getCustomPhone()); // 顾客电话
advanceEntity.setCustomerRoad(StringUtil.isBlank(mtFactoryOrder.getCustomAddress())?"":mtFactoryOrder.getCustomAddress());//顾客地址
advanceEntity.setSystemType("线上"); //订单类型
advanceEntity.setStoreNo(""); //门店编码
advanceEntity.setStoreName(""); //门店名称
advanceEntity.setSerialKey(""); //序列号
advanceEntity.setServiceNum(StringUtil.isBlank(mtFactoryOrderMain.getInvoiceOrderCode())?"":mtFactoryOrderMain.getInvoiceOrderCode()); //服务号
advanceEntity.setMatingCode("");//齐套模式 可以为空
advanceEntity.setContractNum("");//合同号 可以为空
advanceEntity.setLeaveBehind("");//遗留:Y=是,N=否
advanceEntity.setSenderMobile("");//发货人电话 可以为空
advanceEntity.setSenderAddress(""); //发货地址 可以为空
advanceEntity.setSenderName(""); //发货工厂名称 可以为空
advanceEntity.setAdministratorsId(1078);// 导入人
advanceEntity.setCreateTime(LocalDate.now()); //添加时间
advanceEntity.setCarsNum(StringUtil.isBlank(mtFactoryOrderMain.getInvoiceOrderCode())?"":mtFactoryOrderMain.getInvoiceOrderCode()); //派车单--snm 可以为空
advanceEntity.setDeleteTime(0); // 删除时间
advanceEntity.setWaybillNo("");//运单号 可以为空
// Integer id = PanFactoryEnum.getId(panFactoryOrder.getPlantId());
advanceEntity.setWarehouseId(0); //导入人仓库id TODO 需要提供映射
advanceEntity.setWaybillStatus(Byte.parseByte("1"));//开单状态:1=未开单,2=已开单
advanceEntity.setOldId(0);//
advanceEntity.setFreeze(Byte.parseByte("1"));//冻结状态:1=正常,2=冻结
advanceEntity.setDeleteReason("");//删除原因
advanceEntity.setDeleteAdministratorsId(0);//删除用户
Integer advanceId = iAdvanceClient.addAdvanceClient(advanceEntity);
if(advanceId > 0){
//更改订单状态
mtFactoryOrder.setStatus(0);
mtFactoryOrderService.saveOrUpdate(mtFactoryOrder);
}else{
//修改订单状态为失败
mtFactoryOrder.setStatus(2);
mtFactoryOrderService.saveOrUpdate(mtFactoryOrder);
continue;
}
//通过订单id查询对应的包件
QueryWrapper<MtPackageInfo> packageQueryWrapper = new QueryWrapper<>();
packageQueryWrapper.eq("order_id",orderId)
.eq("is_deleted",0);
List<MtPackageInfo> packages = mtPackageInfoService.list(packageQueryWrapper);
for(MtPackageInfo mtPackageInfo:packages){
//添加订单明细
AdvanceDetailEntity advanceDetailEntity = new AdvanceDetailEntity();
advanceDetailEntity.setAdvanceId(advanceId);//预仓id
advanceDetailEntity.setIsPay(Byte.parseByte("0"));//
advanceDetailEntity.setLineID("");//线下订单明细标时 可以为空
advanceDetailEntity.setSerialKey("");//序列号 可以为空
advanceDetailEntity.setArea("");//区域
advanceDetailEntity.setOrderSelfNum(mtFactoryOrder.getOrderCode());//订单自编号
advanceDetailEntity.setType(FactoryConstant.MENGT);//订单来源
advanceDetailEntity.setSystemType("线上");//订单类型
advanceDetailEntity.setOrderNum("");//MSCS单号 可以为空
advanceDetailEntity.setIsOpai(0);//是否干仓配:1=是,0=否
advanceDetailEntity.setMtdsNo("");//MTDS单号 可以为空
advanceDetailEntity.setFirstPackName(StringUtil.isBlank(mtPackageInfo.getBigType())?"":mtPackageInfo.getBigType());//一级品类
advanceDetailEntity.setFirstPackCode(StringUtil.isBlank(mtPackageInfo.getSmallType())?"":mtPackageInfo.getSmallType());//二级品类
advanceDetailEntity.setSiteName("");//基地名称 基地 TODO 需要映射
advanceDetailEntity.setSiteCode("");//基地编码
advanceDetailEntity.setProductCode(StringUtil.isBlank(mtPackageInfo.getPackageType())?"":mtPackageInfo.getPackageType());//货品名称 可以为空
advanceDetailEntity.setSecondPackName("");//二级品类名称
advanceDetailEntity.setSecondPackCode("");//二级品类
advanceDetailEntity.setThirdPackName("");//三级品类名称
advanceDetailEntity.setThirdPackCode("");//三级品类
advanceDetailEntity.setGoodName("");//v产品类型 可以为空
advanceDetailEntity.setIsAddin("Y");//例放:N=正常,Y=例放
advanceDetailEntity.setIsThirdAddin("N");//三级例放:N=正常,Y=例放
advanceDetailEntity.setIsSuppin("N");//补进:N=正常,Y=例放
advanceDetailEntity.setMscsNum("1");//发货数量
advanceDetailEntity.setMtdsNum(0);//销售数量
advanceDetailEntity.setVolume("");//体积
advanceDetailEntity.setUnitNo(StringUtil.isBlank(mtPackageInfo.getPackageCode())?"":mtPackageInfo.getPackageCode());//包条码
advanceDetailEntity.setMctsTruck("");//车次号
advanceDetailEntity.setMctsTruckNo("");//车牌号
advanceDetailEntity.setDate100(null);//基地发货日期
advanceDetailEntity.setDate2("");//预约到厂时间
advanceDetailEntity.setDate3("");//实际到厂时间
advanceDetailEntity.setDate4("");//开始装车时间
advanceDetailEntity.setDate5("");//完成装车时间
advanceDetailEntity.setDate6("");//车辆离厂时间
advanceDetailEntity.setCreateTime(LocalDate.now());//创建时间
advanceDetailEntity.setDeleteTime(0);//删除时间
advanceDetailEntity.setServiceNum("");//服务号
advanceDetailEntity.setAdmin("");//
advanceDetailEntity.setAdministratorsId(0);//导入人
// advanceDetailEntity.setDueDate(0);//交期
advanceDetailEntity.setRemark("");//备注
advanceDetailEntity.setOldId(0);//
Integer detailId = advanceDetailClient.addAdvanceDetail(advanceDetailEntity);
if(detailId > 0){
//修改数据状态
mtPackageInfo.setStatus(0);
mtPackageInfoService.saveOrUpdate(mtPackageInfo);
}else{
mtPackageInfo.setStatus(2);
mtPackageInfoService.saveOrUpdate(mtPackageInfo);
}
}
ServiceNumEntity serviceNum = new ServiceNumEntity();
serviceNum.setServiceNum(StringUtil.isBlank(mtFactoryOrderMain.getInvoiceOrderCode())?"":mtFactoryOrderMain.getInvoiceOrderCode()); //服务号
serviceNum.setTotal("1"); //订单数量
serviceNum.setDetailTotal(Objects.isNull(mtFactoryOrder.getQuantity())?"":mtFactoryOrder.getQuantity()+""); // 包数量
serviceNum.setStoreName(StringUtil.isBlank(mtFactoryOrder.getExclusiveName())?"":mtFactoryOrder.getExclusiveName()); //商场名
serviceNum.setStoreNo(StringUtil.isBlank(mtFactoryOrder.getExclusiveCode())?"":mtFactoryOrder.getExclusiveCode()); // 商场编号
serviceNum.setCustomerName(StringUtil.isBlank(mtFactoryOrder.getCustomName())?"":mtFactoryOrder.getCustomName());//顾客姓名
serviceNum.setCustomerPhone(StringUtil.isBlank(mtFactoryOrder.getCustomPhone())?"":mtFactoryOrder.getCustomPhone()); //顾客电话
serviceNum.setCustomerRoad(StringUtil.isBlank(mtFactoryOrder.getCustomAddress())?"":mtFactoryOrder.getCustomAddress()); //顾客地址
serviceNum.setIsOpai(1); //是否干仓配
serviceNum.setCompleteSet("V"); //齐套标识:Y=齐套,N=未齐套,V=未知
// serviceNum.setCreateTime(LocalDate.now());
serviceNum.setDeleteTime(0);
serviceNumEntityList.add(serviceNum);
}
serviceNumClient.addServiceNum(serviceNumEntityList);
log.info("##############handlerMtDataToHt: 处理数据完成");
}
}

18
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryCommonServiceImpl.java

@ -0,0 +1,18 @@
package com.logpm.factory.comfac.service.impl;
import com.logpm.factory.comfac.service.IFactoryCommonService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@AllArgsConstructor
public class FactoryCommonServiceImpl implements IFactoryCommonService {
}

27
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/utils/CommonUntis.java

@ -0,0 +1,27 @@
package com.logpm.factory.comfac.utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class CommonUntis {
public static byte[] imageUrlToByte(String url) throws IOException {
URL urlImg = new URL(url);
HttpURLConnection httpcon =(HttpURLConnection)urlImg.openConnection();
httpcon.addRequestProperty("User-Agent","Mozilla / 4.76");
InputStream is = httpcon.getInputStream();
//定义字节数组大小
byte[] buffer = new byte[1024];
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
int rc = 0;
while ((rc = is.read(buffer, 0, 100)) > 0) {
swapStream.write(buffer, 0, rc);
}
return buffer;
}
}

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

@ -19,7 +19,6 @@ public class InterceptorAdapterConfig implements WebMvcConfigurer {
InterceptorRegistration registry = interceptorRegistry.addInterceptor(new FactoryAccountsInterceptor(factoryTokenService));
registry.addPathPatterns("/factory/**").
excludePathPatterns("/factory/auth/token")
.excludePathPatterns("/factory/**/sendOrders")
.excludePathPatterns("/factory/**/sendOrderStatus");
.excludePathPatterns("/factory/common/**");
}
}

18
blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java

@ -157,5 +157,23 @@ public class RabbitMqConfiguration {
return BindingBuilder.bind(dealWithQueue).to(dealWithExchange).with(RabbitConstant.DEAL_WITH_ROUTING).noargs();
}
@Bean
public Queue receiveInfoQueue() {
return new Queue(RabbitConstant.RECEIVE_INFO_QUEUE, true);
}
@Bean
public CustomExchange receiveInfoExchange() {
Map<String, Object> args = Maps.newHashMap();
args.put("x-delayed-type", "direct");
return new CustomExchange(RabbitConstant.RECEIVE_INFO_EXCHANGE, "x-delayed-message", true, false, args);
}
@Bean
public Binding receiveInfoBinding(Queue receiveInfoQueue, CustomExchange receiveInfoExchange) {
return BindingBuilder.bind(receiveInfoQueue).to(receiveInfoExchange).with(RabbitConstant.RECEIVE_INFO_ROUTING).noargs();
}
}

80
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/controller/MtFactoryDataController.java

@ -18,15 +18,16 @@ package com.logpm.factory.mt.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.factory.comfac.service.IAsyncDataService;
import com.logpm.factory.comfac.service.IOrderStatusLogService;
import com.logpm.factory.mt.dto.MtFactoryDataDTO;
import com.logpm.factory.snm.bean.Resp;
import com.logpm.factory.snm.entity.OrderStatusLog;
import com.logpm.factory.mt.service.IMtFactoryDataService;
import com.logpm.factory.comfac.service.IOrderStatusLogService;
import com.logpm.factory.snm.entity.OrderStatusLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
@ -50,6 +51,7 @@ public class MtFactoryDataController extends BladeController {
private final IOrderStatusLogService orderStatusLogService;
private final IMtFactoryDataService mtFactoryDataService;
private final IAsyncDataService asyncDataService;
/**
* 工厂数据推送接口
*/
@ -69,56 +71,32 @@ public class MtFactoryDataController extends BladeController {
orderStatusLog.setBrand("梦天");
orderStatusLogService.save(orderStatusLog);
//数据存入数据库
boolean flag = mtFactoryDataService.dealWithData(mtFactoryDataDTO);
try{
//数据存入数据库
R r = mtFactoryDataService.dealWithData(mtFactoryDataDTO);
// //判断数据是否已存入
// String orderNo = factoryOrderDTO.getOrderNo();
// QueryWrapper<PanFactoryOrder> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("order_no",orderNo);
// PanFactoryOrder one = factoryOrderService.getOne(queryWrapper);
// if(!Objects.isNull(one)){
// log.warn("############data: 订单数据已存在 orderNo={}",orderNo);
// return Resp.fail(400,"订单数据已存在");
// }
//
// PanFactoryOrder factoryOrder = new PanFactoryOrder();
// BeanUtil.copyProperties(factoryOrderDTO,factoryOrder);
// factoryOrder.setCorpid(corpId);
// //保存订单数据
// factoryOrderService.save(factoryOrder);
//
// List<PanPackageInfoDTO> packageInfos = factoryOrderDTO.getORDER_ATTRIBUTES();
//
// for (PanPackageInfoDTO dto:packageInfos){
// PanPackageInfo packageInfo = new PanPackageInfo();
// BeanUtil.copyProperties(dto,packageInfo);
// packageInfo.setOrderId(factoryOrder.getId());
// //保存包件信息数据
// //因为需要先保存包件明细需要包件的id
// packageInfoService.save(packageInfo);
//
// //再存入包件明细
// List<PanPackageList> PanPackagelist = new ArrayList<>();
// List<PanPackageListDTO> order_attributes_line = dto.getORDER_ATTRIBUTES_LINE();
// for (PanPackageListDTO panPackageListDTO:order_attributes_line){
// PanPackageList panPackageList = new PanPackageList();
// BeanUtil.copyProperties(panPackageListDTO,panPackageList);
// panPackageList.setPackageId(packageInfo.getId());
// PanPackagelist.add(panPackageList);
// }
// packageListService.saveBatch(PanPackagelist);
// }
//
// //修改保存数据的状态
// panOrderStatusLog.setStatus(0);
// panOrderStatusLogService.saveOrUpdate(panOrderStatusLog);
//
// //开启异步线程处理数据
// syncDataService.handlerPanDataToHt();
int code = r.getCode();
if(code == 200){
orderStatusLog.setStatus(0);
//开启异步线程处理数据
asyncDataService.handlerMtDataToHt();
}else{
orderStatusLog.setStatus(2);
}
orderStatusLogService.saveOrUpdate(orderStatusLog);
return r;
}catch (CustomerException e){
orderStatusLog.setStatus(2);
orderStatusLogService.saveOrUpdate(orderStatusLog);
log.error("#################data: "+e.message);
return R.fail(e.code, e.message);
}catch (Exception e){
orderStatusLog.setStatus(2);
orderStatusLogService.saveOrUpdate(orderStatusLog);
log.error("#################data: 保存数据失败",e);
return R.fail(405, "保存数据失败");
}
return Resp.fail(400,"fail");
}
}

7
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtFactoryOrderMapper.java

@ -0,0 +1,7 @@
package com.logpm.factory.mt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factory.snm.entity.MtFactoryOrder;
public interface MtFactoryOrderMapper extends BaseMapper<MtFactoryOrder> {
}

20
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtFactoryOrderMapper.xml

@ -0,0 +1,20 @@
<?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.factory.mt.mapper.MtFactoryOrderMapper">
<!-- 通用查询映射结果 -->
<!-- <resultMap id="orderLogResultMap" type="com.logpm.factory.snm.entity.FactoryOrder">-->
<!-- <result column="id" property="id"/>-->
<!-- <result column="req_args" property="reqArgs"/>-->
<!-- <result column="res_body" property="resBody"/>-->
<!-- <result column="type" property="type"/>-->
<!-- <result column="create_user" property="createUser"/>-->
<!-- <result column="create_time" property="createTime"/>-->
<!-- <result column="update_user" property="updateUser"/>-->
<!-- <result column="update_time" property="updateTime"/>-->
<!-- <result column="status" property="status"/>-->
<!-- <result column="is_deleted" property="isDeleted"/>-->
<!-- <result column="create_dept" property="createDept"/>-->
<!-- </resultMap>-->
</mapper>

7
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtPackageInfoMapper.java

@ -0,0 +1,7 @@
package com.logpm.factory.mt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factory.snm.entity.MtPackageInfo;
public interface MtPackageInfoMapper extends BaseMapper<MtPackageInfo> {
}

11
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/IMtFactoryDataService.java

@ -1,12 +1,21 @@
package com.logpm.factory.mt.service;
import com.logpm.factory.comfac.dto.OrderInfoDTO;
import com.logpm.factory.comfac.dto.OrderStatusDTO;
import com.logpm.factory.comfac.dto.ReceiveInfoDTO;
import com.logpm.factory.mt.dto.MtFactoryDataDTO;
import org.springblade.core.tool.api.R;
/**
* 工厂推送数据接口
*/
public interface IMtFactoryDataService {
boolean dealWithData(MtFactoryDataDTO mtFactoryDataDTO);
R dealWithData(MtFactoryDataDTO mtFactoryDataDTO);
R handleData(OrderInfoDTO orderInfoDTO);
R handleStatusData(OrderStatusDTO orderStatusDTO);
R sendReceiveInfo(ReceiveInfoDTO receiveInfoDTO);
}

11
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/IMtFactoryOrderService.java

@ -0,0 +1,11 @@
package com.logpm.factory.mt.service;
import com.logpm.factory.snm.entity.MtFactoryOrder;
import org.springblade.core.mp.base.BaseService;
public interface IMtFactoryOrderService extends BaseService<MtFactoryOrder> {
}

7
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/IMtPackageInfoService.java

@ -0,0 +1,7 @@
package com.logpm.factory.mt.service;
import com.logpm.factory.snm.entity.MtPackageInfo;
import org.springblade.core.mp.base.BaseService;
public interface IMtPackageInfoService extends BaseService<MtPackageInfo> {
}

252
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java

@ -1,39 +1,283 @@
package com.logpm.factory.mt.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.alibaba.nacos.shaded.com.google.gson.GsonBuilder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.factory.comfac.dto.OrderInfoDTO;
import com.logpm.factory.comfac.dto.OrderStatusDTO;
import com.logpm.factory.comfac.dto.ReceiveBodyDTO;
import com.logpm.factory.comfac.dto.ReceiveInfoDTO;
import com.logpm.factory.mt.dto.MtFactoryDataDTO;
import com.logpm.factory.snm.entity.MtFactoryOrderMain;
import com.logpm.factory.mt.dto.MtFactoryOrderDTO;
import com.logpm.factory.mt.dto.MtPackageInfoDTO;
import com.logpm.factory.mt.service.IMtFactoryDataService;
import com.logpm.factory.mt.service.IMtFactoryOrderMainService;
import com.logpm.factory.mt.service.IMtFactoryOrderService;
import com.logpm.factory.mt.service.IMtPackageInfoService;
import com.logpm.factory.snm.bean.Resp;
import com.logpm.factory.snm.entity.MtFactoryOrder;
import com.logpm.factory.snm.entity.MtFactoryOrderMain;
import com.logpm.factory.snm.entity.MtPackageInfo;
import com.logpm.oldproject.feign.IAdvanceDetailClient;
import com.logpm.oldproject.feign.IWarehouseClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
import java.util.*;
@Slf4j
@Service
@AllArgsConstructor
public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
private static final Logger logger = LoggerFactory.getLogger(MtFactoryDataServiceImpl.class);
private final IMtFactoryOrderMainService mtFactoryOrderMainService;
private final IMtFactoryOrderService mtFactoryOrderService;
private final IMtPackageInfoService mtPackageInfoService;
private final IAdvanceDetailClient advanceDetailClient;
private final IWarehouseClient warehouseClient;
@Transactional
@Override
public boolean dealWithData(MtFactoryDataDTO mtFactoryDataDTO) {
public R dealWithData(MtFactoryDataDTO mtFactoryDataDTO) {
log.info("#############dealWithData: 处理梦天工厂数据 开始");
String invoiceOrderCode = mtFactoryDataDTO.getInvoiceOrderCode();//发货单编码
//先判断该发货单编码是否已经存在
QueryWrapper<MtFactoryOrderMain> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("invoice_order_code",invoiceOrderCode);
MtFactoryOrderMain mtFactoryOrderMain = mtFactoryOrderMainService.getOne(queryWrapper);
if(!Objects.isNull(mtFactoryOrderMain)){
log.warn("#############dealWithData: 数据已存在 invoiceOrderCode={}",invoiceOrderCode);
return R.fail(405,"发货单已存在");
}
mtFactoryOrderMain = new MtFactoryOrderMain();
BeanUtil.copyProperties(mtFactoryDataDTO,mtFactoryOrderMain);
boolean saveMain = mtFactoryOrderMainService.save(mtFactoryOrderMain);
if(saveMain){
Long mainId = mtFactoryOrderMain.getId();//发货单id
List<MtFactoryOrderDTO> orderList = mtFactoryDataDTO.getOrderList();//所有订单数据
for(MtFactoryOrderDTO mtFactoryOrderDTO:orderList){
String orderCode = mtFactoryOrderDTO.getOrderCode();
MtFactoryOrder mtFactoryOrder = new MtFactoryOrder();
BeanUtil.copyProperties(mtFactoryOrderDTO,mtFactoryOrder);
mtFactoryOrder.setMainId(mainId);
boolean saveOrder = mtFactoryOrderService.save(mtFactoryOrder);
if(saveOrder){
Long orderId = mtFactoryOrder.getId();
List<MtPackageInfoDTO> packageInfos = mtFactoryOrderDTO.getPackageInfos();
List<MtPackageInfo> list = new ArrayList<>();
for(MtPackageInfoDTO mtPackageInfoDTO:packageInfos){
MtPackageInfo mtPackageInfo = new MtPackageInfo();
BeanUtil.copyProperties(mtPackageInfoDTO,mtPackageInfo);
mtPackageInfo.setOrderId(orderId);
list.add(mtPackageInfo);
}
//保存包件信息
boolean b = mtPackageInfoService.saveBatch(list);
if(b){
log.info("#############dealWithData: 保存数据成功");
}else{
log.warn("#############dealWithData: 保存数据失败 orderCode={}",orderCode);
throw new CustomerException(405,"保存数据失败");
}
}else{
log.warn("#############dealWithData: 保存订单失败 orderCode={}",orderCode);
throw new CustomerException(405,"保存订单失败");
}
}
}else{
log.warn("#############dealWithData: 保存发货单失败 invoiceOrderCode={}",invoiceOrderCode);
throw new CustomerException(405,"保存发货单失败");
}
return R.success("接收成功");
}
@Override
public R handleData(OrderInfoDTO orderInfoDTO) {
String orderNo = orderInfoDTO.getOrderNo();//订单自编号
//根据客户订单号去查询WMS装车清单号
QueryWrapper<MtFactoryOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_code",orderNo);
MtFactoryOrder mtFactoryOrder = mtFactoryOrderService.getOne(queryWrapper);
if(Objects.isNull(mtFactoryOrder)){
logger.info("#############handleData: 未找到订单数据 合同自编码orderNo={}",orderNo);
return R.fail(400,"未找到订单数据");
}
//TODO 组装数据
//判断数据是都已存在
if(!orderInfoDTO.verifyData()){
logger.info("#############handleData: 数据不齐全 orderInfoDTO={}",orderInfoDTO);
return R.fail(405,"数据不齐全");
}
//拼接参数
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);
//处理逻辑
String result = HttpRequest.post("URL"+"/hitf/v1/rest/invoke?namespace=HZERO&serverCode=OPEN&interfaceCode=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: 物流状态传递成功");
}else{
return R.fail(405,message);
}
}else{
return R.fail(405,"返回格式有误:"+result);
}
return Resp.success("SUCCESS");
}
@Override
public R handleStatusData(OrderStatusDTO orderStatusDTO) throws CustomerException {
String status = orderStatusDTO.getStatus();
String orderNo = orderStatusDTO.getOrderNo();
if("1".equals(status)||"2".equals(status)||"3".equals(status)||"6".equals(status)||"7".equals(status)||"8".equals(status)||"9".equals(status)){
logger.info("#############handleStatusData: 当前数据的状态不推送 status={}",status);
return Resp.fail(400,"当前数据的状态不推送");
}
//通过包件码查询是否是要推送的订单
String unitNo = orderStatusDTO.getUnitNo();//包件码
String currentWarehouse = orderStatusDTO.getCurrentWarehouse();
QueryWrapper<MtPackageInfo> packageInfoQueryWrapper = new QueryWrapper<>();
packageInfoQueryWrapper.eq("package_code",unitNo);
MtPackageInfo one = mtPackageInfoService.getOne(packageInfoQueryWrapper);
if(Objects.isNull(one)){
logger.info("#############handleStatusData: 当前包条码未找到对应数据unitNo={}",unitNo);
return Resp.fail(400,"未找到包件数据");
}
Long orderId = one.getOrderId();
MtFactoryOrder mtFactoryOrder = mtFactoryOrderService.getById(orderId);
if(Objects.isNull(mtFactoryOrder)){
logger.info("#############handleStatusData: 未找到对应订单orderId={}",orderId);
return Resp.fail(400,"未找到对应订单");
}
Long mainId = mtFactoryOrder.getMainId();
MtFactoryOrderMain mtFactoryOrderMain = mtFactoryOrderMainService.getById(mainId);
if(Objects.isNull(mtFactoryOrderMain)){
logger.info("#############handleStatusData: 未找到对应订单mainId={}",mainId);
return Resp.fail(400,"未找到对应订单");
}
//根据仓库ID查询仓库名字
currentWarehouse = warehouseClient.selectNameById(Integer.parseInt(currentWarehouse));
//拼接参数
Map<String,Object> map = new HashMap<>();
map.put("发运单编号", mtFactoryOrderMain.getInvoiceOrderCode());
map.put("订单编号", orderNo);
map.put("包条码", unitNo);
map.put("操作时间", orderStatusDTO.getOperationTime());
map.put("仓库", currentWarehouse);
map.put("生产单号", mtFactoryOrder.getProduceOrderCode());
map.put("经销商名称", mtFactoryOrder.getDealerName());
map.put("状态", orderStatusDTO.getStatus());
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String s = gson.toJson(map);
//先获取token
String panToken = "getPanToken()";
//请求参数
logger.info("##############handleStatusData: 推送包件状态请求参数 {}",s);
//处理逻辑
String result = HttpRequest.post("URL"+"/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: 物流状态传递成功");
}else{
return Resp.fail(405,message);
}
}else{
return Resp.fail(405,"返回格式有误:"+result);
}
return Resp.success("SUCCESS");
}
return false;
@Override
public R sendReceiveInfo(ReceiveInfoDTO receiveInfoDTO) {
log.info("###########sendReceiveInfo: 处理签收图片数据开始");
List<ReceiveBodyDTO> receiveBodyList = receiveInfoDTO.getReceiveBodyList();
Long mainId = null;
for(ReceiveBodyDTO receiveBodyDTO:receiveBodyList){
String orderCode = receiveBodyDTO.getOrderCode();//订单自编号
QueryWrapper<MtFactoryOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_code",orderCode);
MtFactoryOrder one = mtFactoryOrderService.getOne(queryWrapper);
if(Objects.isNull(one)){
log.warn("################sendReceiveInfo: 订单数据不存在 orderCode={}",orderCode);
return R.fail(400,"订单数据不存在");
}
receiveBodyDTO.setProduceOrderCode(one.getProduceOrderCode());
mainId = one.getMainId();
}
MtFactoryOrderMain mtFactoryOrderMain = mtFactoryOrderMainService.getById(mainId);
if(Objects.isNull(mtFactoryOrderMain)){
log.warn("################sendReceiveInfo: 主订单数据不存在 mainId={}",mainId);
return R.fail(400,"主订单数据不存在");
}
receiveInfoDTO.setInvoiceOrderCode(mtFactoryOrderMain.getInvoiceOrderCode());
receiveInfoDTO.setWarehouse(mtFactoryOrderMain.getCenterWarehouseName());
receiveInfoDTO.setWarehouseCode(mtFactoryOrderMain.getCenterWarehouseCode());
receiveInfoDTO.setReceiveBodyList(receiveBodyList);
//拼装参数 ,推送数据到梦天
return R.success("处理签收数据完成");
}
}

13
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryOrderServiceImpl.java

@ -0,0 +1,13 @@
package com.logpm.factory.mt.service.impl;
import com.logpm.factory.mt.mapper.MtFactoryOrderMapper;
import com.logpm.factory.mt.service.IMtFactoryOrderService;
import com.logpm.factory.snm.entity.MtFactoryOrder;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
@AllArgsConstructor
@Service
public class MtFactoryOrderServiceImpl extends BaseServiceImpl<MtFactoryOrderMapper, MtFactoryOrder> implements IMtFactoryOrderService {
}

13
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtPackageInfoServiceImpl.java

@ -0,0 +1,13 @@
package com.logpm.factory.mt.service.impl;
import com.logpm.factory.mt.mapper.MtPackageInfoMapper;
import com.logpm.factory.mt.service.IMtPackageInfoService;
import com.logpm.factory.snm.entity.MtPackageInfo;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
@AllArgsConstructor
@Service
public class MtPackageInfoServiceImpl extends BaseServiceImpl<MtPackageInfoMapper,MtPackageInfo> implements IMtPackageInfoService {
}

8
blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java

@ -115,13 +115,6 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
@Override
public R handleData(OrderInfoDTO orderInfoDTO) throws CustomerException {
//先保存原始请求数据
OrderStatusLog panOrderStatusLog = new OrderStatusLog();
panOrderStatusLog.setArgs(JSONObject.toJSONString(orderInfoDTO));
panOrderStatusLog.setStatus(1);
panOrderStatusLog.setType(1);
panOrderStatusLogService.save(panOrderStatusLog);
String orderNo = orderInfoDTO.getOrderNo();
//根据客户订单号去查询WMS装车清单号
@ -181,7 +174,6 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
return Resp.success("SUCCESS");
}
@Transactional
@Override
public R handleStatusData(OrderStatusDTO orderStatusDTO) throws CustomerException {

33
blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OpenOrderHandler.java

@ -1,7 +1,11 @@
package com.logpm.factory.receiver;
import com.logpm.factory.comfac.constant.FactoryConstant;
import com.logpm.factory.comfac.dto.OrderInfoDTO;
import com.logpm.factory.mt.service.IMtFactoryDataService;
import com.logpm.factory.pan.service.IPanFactoryDataService;
import com.logpm.oldproject.entity.AdvanceEntity;
import com.logpm.oldproject.feign.IAdvanceClient;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.RabbitConstant;
@ -15,6 +19,7 @@ import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
/**
@ -27,8 +32,13 @@ import java.util.Map;
@Component
public class OpenOrderHandler {
@Autowired
private IAdvanceClient advanceClient;
@Autowired
private IPanFactoryDataService panFactoryDataService;
@Autowired
private IMtFactoryDataService mtFactoryDataService;
private Integer retryCount = 1;
@ -39,8 +49,27 @@ public class OpenOrderHandler {
String msg = new String(message.getBody());
log.info("##################我进入这里了 retryCount={}",retryCount++);
OrderInfoDTO orderInfoDTO = (OrderInfoDTO) map.get("messageData");
String orderNo = orderInfoDTO.getOrderNo();
R r = panFactoryDataService.handleData(orderInfoDTO);
String orderNo = orderInfoDTO.getOrderNo();//订单自编号
//通过订单自编号去查询该条订单是属于哪个工厂
AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderNo);
if(Objects.isNull(advanceEntity)){
log.info("##################openOrderStatusHandler: 未找到对应订单 orderNo={}",orderNo);
channel.basicAck(deliveryTag,true);
}
String type = advanceEntity.getType();//品牌
R r = null;
switch (type){
case FactoryConstant.PIANO:
r = panFactoryDataService.handleData(orderInfoDTO);
break;
// case FactoryConstant.MENGT:
// r = mtFactoryDataService.handleData(orderInfoDTO);
// break;
default:
log.info("##################openOrderStatusHandler: 未知品牌 type={}",type);
channel.basicAck(deliveryTag,true);
}
int code = r.getCode();
if(code == 400 || code == 200){
log.info("##################openOrderStatusHandler: 该条数据不用处理 orderNo={}",orderNo);

80
blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java

@ -0,0 +1,80 @@
package com.logpm.factory.receiver;
import com.logpm.factory.comfac.constant.FactoryConstant;
import com.logpm.factory.comfac.dto.OrderStatusDTO;
import com.logpm.factory.mt.service.IMtFactoryDataService;
import com.logpm.factory.pan.service.IPanFactoryDataService;
import com.logpm.oldproject.entity.AdvanceEntity;
import com.logpm.oldproject.feign.IAdvanceClient;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.RabbitConstant;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.tool.api.R;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
/**
* 直接队列1 处理器
*
* @author yangkai.shen
*/
@Slf4j
@RabbitListener(queues = RabbitConstant.ORDER_STATUS_QUEUE)
@Component
public class OrderStatusHandler {
@Autowired
private IAdvanceClient advanceClient;
@Autowired
private IPanFactoryDataService panFactoryDataService;
@Autowired
private IMtFactoryDataService mtFactoryDataService;
private Integer retryCount = 1;
@RabbitHandler
public void orderStatusHandler(Map map, Message message, Channel channel) throws IOException {
// 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉
final long deliveryTag = message.getMessageProperties().getDeliveryTag();
String msg = new String(message.getBody());
log.info("##################我进入这里了 retryCount={}",retryCount++);
OrderStatusDTO orderStatusDTO = (OrderStatusDTO) map.get("messageData");
String orderNo = orderStatusDTO.getOrderNo();//订单自编号
//通过订单自编号去查询该条订单是属于哪个工厂
AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderNo);
if(Objects.isNull(advanceEntity)){
log.info("##################orderStatusHandler: 未找到对应订单 orderNo={}",orderNo);
channel.basicAck(deliveryTag,true);
}
String type = advanceEntity.getType();//品牌
R r = null;
switch (type){
case FactoryConstant.PIANO:
r = panFactoryDataService.handleStatusData(orderStatusDTO);
break;
case FactoryConstant.MENGT:
r = mtFactoryDataService.handleStatusData(orderStatusDTO);
break;
default:
log.info("##################orderStatusHandler: 未知品牌 type={}",type);
}
int code = r.getCode();
if(code == 400 || code == 200){
log.info("##################orderStatusHandler: 该条数据不用处理 orderNo={}",orderNo);
channel.basicAck(deliveryTag,true);
}else{
throw new CustomerException(code,r.getMsg());
}
}
}

85
blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java

@ -0,0 +1,85 @@
package com.logpm.factory.receiver;
import com.logpm.factory.comfac.constant.FactoryConstant;
import com.logpm.factory.comfac.dto.ReceiveInfoDTO;
import com.logpm.factory.mt.service.IMtFactoryDataService;
import com.logpm.factory.mt.service.IMtFactoryOrderMainService;
import com.logpm.factory.mt.service.IMtFactoryOrderService;
import com.logpm.oldproject.entity.AdvanceEntity;
import com.logpm.oldproject.feign.IAdvanceClient;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.RabbitConstant;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.tool.api.R;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
/**
* 直接队列1 处理器
*
* @author yangkai.shen
*/
@Slf4j
@RabbitListener(queues = RabbitConstant.RECEIVE_INFO_QUEUE)
@Component
public class ReceiveInfoHandler {
@Autowired
private IAdvanceClient advanceClient;
@Autowired
private IMtFactoryDataService mtFactoryDataService;
@Autowired
private IMtFactoryOrderService mtFactoryOrderService;
@Autowired
private IMtFactoryOrderMainService mtFactoryOrderMainService;
private Integer retryCount = 1;
@RabbitHandler
public void receiveInfoHandler(Map map, Message message, Channel channel) throws IOException {
// 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉
final long deliveryTag = message.getMessageProperties().getDeliveryTag();
String msg = new String(message.getBody());
log.info("##################我进入这里了 retryCount={}",retryCount++);
ReceiveInfoDTO receiveInfoDTO = (ReceiveInfoDTO) map.get("messageData");
String orderCode = receiveInfoDTO.getReceiveBodyList().get(0).getOrderCode();
//通过订单自编号去查询该条订单是属于哪个工厂
AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderCode);
if(Objects.isNull(advanceEntity)){
log.info("##################receiveInfoHandler: 未找到对应订单 orderCode={}",orderCode);
channel.basicAck(deliveryTag,true);
}
String type = advanceEntity.getType();//品牌
R r = null;
switch (type){
// case FactoryConstant.PIANO:
// r = panFactoryDataService.handleData(orderInfoDTO);
// break;
case FactoryConstant.MENGT:
r = mtFactoryDataService.sendReceiveInfo(receiveInfoDTO);
break;
default:
log.info("##################receiveInfoHandler: 未知品牌 type={}",type);
channel.basicAck(deliveryTag,true);
}
int code = r.getCode();
if(code == 400 || code == 200){
log.info("##################receiveInfoHandler: 该条数据不用处理 orderNo={}",orderCode);
channel.basicAck(deliveryTag,true);
}else{
throw new CustomerException(code,r.getMsg());
}
}
}

3
blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceMapper.xml

@ -17,8 +17,7 @@
<select id="advanceEntityOne" resultMap="advanceResultMap">
select * from ht_advance
<where>
delete_administrators_id = 0 and
create_time between DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW()
delete_administrators_id = 0
and orderSelfNum = #{orderSelfNum}
</where>
</select>

Loading…
Cancel
Save