15 changed files with 315 additions and 75 deletions
@ -0,0 +1,81 @@
|
||||
package com.logpm.factory.jobhandler; |
||||
|
||||
import cn.hutool.core.collection.CollUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import cn.hutool.json.JSONObject; |
||||
import cn.hutool.json.JSONUtil; |
||||
import com.logpm.factory.mt.dto.MtReceiveContentDTO; |
||||
import com.logpm.factory.mt.dto.MtReceiveDTO; |
||||
import com.logpm.factory.mt.dto.MtReceiveImagesDTO; |
||||
import com.logpm.factory.mt.mapper.MtPushDataMapper; |
||||
import com.xxl.job.core.biz.model.ReturnT; |
||||
import com.xxl.job.core.handler.annotation.XxlJob; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.constant.RabbitConstant; |
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author zhaoqiaobo |
||||
* @create 2024-04-02 |
||||
*/ |
||||
@AllArgsConstructor |
||||
@Component |
||||
@Slf4j |
||||
public class MengTianPushDataJob { |
||||
|
||||
private final MtPushDataMapper mtPushDataMapper; |
||||
private final RabbitTemplate rabbitTemplate; |
||||
|
||||
/** |
||||
* 定时扫描梦天手动数据 |
||||
* |
||||
* @param param |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@XxlJob("mengTianCustomPushNodeData") |
||||
public ReturnT<String> pushDataJob(String param) throws Exception { |
||||
|
||||
List<JSONObject> js = this.mtPushDataMapper.customPushNodeData(); |
||||
if (CollUtil.isEmpty(js)) { |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
MtReceiveDTO dto = new MtReceiveDTO(); |
||||
String sendTaskId = js.get(0).getStr("sendTaskId"); |
||||
if (StrUtil.isNotEmpty(sendTaskId)) { |
||||
dto.setSendTaskId(sendTaskId); |
||||
dto.setReceiver(js.get(0).getStr("receiver")); |
||||
// js 按sendTaskId 和 receiver分组
|
||||
List<MtReceiveContentDTO> mtReceiveContentDTOS = js.stream().map(j -> { |
||||
MtReceiveContentDTO contentDTO = new MtReceiveContentDTO(); |
||||
contentDTO.setWaybillNumber(j.getStr("waybillNumber")); |
||||
contentDTO.setUnitNo(j.getStr("unitNo")); |
||||
contentDTO.setOperateDate(j.getStr("operateDate")); |
||||
contentDTO.setWarehouse(j.getStr("warehouse")); |
||||
contentDTO.setWarehouseCode(j.getStr("warehouseCode")); |
||||
contentDTO.setOrderCode(j.getStr("orderCode")); |
||||
contentDTO.setInvoiceOrderCode(j.getStr("invoiceOrderCode")); |
||||
return contentDTO; |
||||
}).collect(Collectors.toList()); |
||||
dto.setReceiveContentList(mtReceiveContentDTOS); |
||||
List<MtReceiveImagesDTO> images = mtPushDataMapper.customPushNodeDataImage(sendTaskId); |
||||
dto.setReceiveImagesList(images); |
||||
Map<String, Object> map = new HashMap<>(); |
||||
String mes = com.alibaba.fastjson.JSONObject.toJSONString(dto); |
||||
map.put("messageData", mes); |
||||
log.info("梦天手动回推签收数据:{}", JSONUtil.toJsonStr(map)); |
||||
rabbitTemplate.convertAndSend(RabbitConstant.MT_BUSINESS_DATA_CLERK_CHECK_2_FACTORY_EXCHANGE, RabbitConstant.MT_BUSINESS_DATA_CLERK_CHECK_2_FACTORY_ROUTING, map); |
||||
mtPushDataMapper.customPushNodeDataSended(sendTaskId); |
||||
} |
||||
|
||||
return ReturnT.SUCCESS; |
||||
} |
||||
|
||||
} |
@ -1,7 +1,17 @@
|
||||
package com.logpm.factory.mt.mapper; |
||||
|
||||
import cn.hutool.json.JSONObject; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.logpm.factory.mt.dto.MtReceiveImagesDTO; |
||||
import com.logpm.factory.mt.entity.MtPushData; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface MtPushDataMapper extends BaseMapper<MtPushData> { |
||||
|
||||
List<JSONObject> customPushNodeData(); |
||||
|
||||
List<MtReceiveImagesDTO> customPushNodeDataImage(String sendTaskId); |
||||
|
||||
void customPushNodeDataSended(String sendTaskId); |
||||
} |
||||
|
@ -1,9 +1,31 @@
|
||||
<?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.MtPushDataMapper"> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<select id="customPushNodeData" resultType="cn.hutool.json.JSONObject"> |
||||
select t1.sendTaskId, |
||||
t1.receiver, |
||||
t1.orderCode, |
||||
t1.unitNo, |
||||
t1.operateDate, |
||||
t1.warehouseCode, |
||||
t1.warehouse, |
||||
t1.invoiceOrderCode, |
||||
t1.waybillNumber |
||||
from mt_custom_push_data_package t1 |
||||
join (select t.sendTaskId |
||||
from mt_custom_push_data_package t |
||||
where t.sendStatus = 0 |
||||
group by t.sendTaskId limit 1) t2 |
||||
on t1.sendTaskId = t2.sendTaskId |
||||
</select> |
||||
<select id="customPushNodeDataImage" resultType="com.logpm.factory.mt.dto.MtReceiveImagesDTO"> |
||||
select image |
||||
from mt_custom_push_data_image |
||||
where sendTaskId = #{sendTaskId} |
||||
</select> |
||||
<update id="customPushNodeDataSended"> |
||||
update mt_custom_push_data_package |
||||
set sendStatus = 1 |
||||
where sendTaskId = #{sendTaskId} |
||||
</update> |
||||
</mapper> |
||||
|
Loading…
Reference in new issue