32 changed files with 944 additions and 79 deletions
@ -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;//图片字节流
|
||||
|
||||
} |
@ -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 = "梦天"; |
||||
|
||||
} |
@ -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;//签收时间
|
||||
|
||||
|
||||
} |
@ -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<>(); |
||||
|
||||
} |
@ -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;//图片地址
|
||||
|
||||
} |
@ -0,0 +1,6 @@
|
||||
package com.logpm.factory.comfac.service; |
||||
|
||||
|
||||
public interface IFactoryCommonService { |
||||
|
||||
} |
@ -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 { |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -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; |
||||
} |
||||
|
||||
|
||||
} |
@ -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> { |
||||
} |
@ -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> |
@ -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> { |
||||
} |
@ -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); |
||||
} |
||||
|
@ -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> { |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -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> { |
||||
} |
@ -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("处理签收数据完成"); |
||||
} |
||||
|
||||
} |
||||
|
@ -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 { |
||||
} |
@ -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 { |
||||
} |
@ -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()); |
||||
} |
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue