提交 0dfd3257 authored 作者: 刘海泉's avatar 刘海泉

Merge remote-tracking branch 'origin/dev' into dev

package com.clx.performance.param.mq.linewarn;
import com.clx.performance.enums.linewarn.LineWarnConfigEnum;
import lombok.*;
import java.util.Arrays;
import java.util.Optional;
/**
* @Author: aiqingguo
* @Description: 通知
* @Date: 2023-10-19 15:45:25
* @Version: 1.0
*/
@Setter
@Getter
@ToString
@NoArgsConstructor
public class LineWarnLineReportMqParam {
private Integer sendSystemAddressId;
private Integer receiveSystemAddressId;
private Integer reportType; //1线路异常 2拥堵预警
@Getter
@AllArgsConstructor
public enum ReportType {
LINE(1, "线路异常"),
JAM(2, "拥堵预警"),
;
private final Integer code;
private final String msg;
public static Optional<ReportType> getByCode(int code) {
return Arrays.stream(values()).filter(e -> e.code == code).findFirst();
}
public static String getMsgByCode(int code) {
return getByCode(code).map(ReportType::getMsg).orElse(null);
}
}
}
...@@ -84,4 +84,16 @@ public class RabbitLineWarnConfig { ...@@ -84,4 +84,16 @@ public class RabbitLineWarnConfig {
return BindingBuilder.bind(lineWarnNoticeQueue()).to(lineWarnDefaultExchange()).with(RabbitKeyLineWarnConstants.LINE_WARN_NOTICE_ROUTING_KEY); return BindingBuilder.bind(lineWarnNoticeQueue()).to(lineWarnDefaultExchange()).with(RabbitKeyLineWarnConstants.LINE_WARN_NOTICE_ROUTING_KEY);
} }
/**
* 线路上报
*/
@Bean
public Queue lineWarnLineReportQueue() {
return new Queue(RabbitKeyLineWarnConstants.LINE_WARN_LINE_REPORT_QUEUE);
}
@Bean
public Binding lineWarnLineReportQueueBinding() {
return BindingBuilder.bind(lineWarnNoticeQueue()).to(lineWarnDefaultExchange()).with(RabbitKeyLineWarnConstants.LINE_WARN_LINE_REPORT_ROUTING_KEY);
}
} }
...@@ -51,4 +51,10 @@ public class RabbitKeyLineWarnConstants { ...@@ -51,4 +51,10 @@ public class RabbitKeyLineWarnConstants {
public static final String LINE_WARN_NOTICE_QUEUE = PREFIX +"lineWarn.notice"+QUEUE; public static final String LINE_WARN_NOTICE_QUEUE = PREFIX +"lineWarn.notice"+QUEUE;
public static final String LINE_WARN_NOTICE_ROUTING_KEY = PREFIX +"lineWarn.notice"+QUEUE_ROUTING_KEY; public static final String LINE_WARN_NOTICE_ROUTING_KEY = PREFIX +"lineWarn.notice"+QUEUE_ROUTING_KEY;
/**
* 线路上报
*/
public static final String LINE_WARN_LINE_REPORT_QUEUE = PREFIX +"lineWarn.lineReport"+QUEUE;
public static final String LINE_WARN_LINE_REPORT_ROUTING_KEY = PREFIX +"lineWarn.lineReport"+QUEUE_ROUTING_KEY;
} }
...@@ -15,6 +15,8 @@ public class LineWarnCommonInfoDTO { ...@@ -15,6 +15,8 @@ public class LineWarnCommonInfoDTO {
String orderGoodsNo; //货单编号 String orderGoodsNo; //货单编号
private int taskCount; //任务数量
private int loadTimeAvg; //平均装车时间(min) private int loadTimeAvg; //平均装车时间(min)
private int unloadTimeAvg; //平均卸车时间(min) private int unloadTimeAvg; //平均卸车时间(min)
......
package com.clx.performance.service.impl.linewarn;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.linewarn.LineWarnJamWarnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class LineWarnJamWarnServiceImpl implements LineWarnJamWarnService {
@Override
public void jamWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) {
}
}
package com.clx.performance.service.impl.linewarn;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.linewarn.LineWarnLineWarnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class LineWarnLineWarnServiceImpl implements LineWarnLineWarnService {
@Override
public void lineWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) {
}
}
...@@ -34,7 +34,7 @@ public class LineWarnLoadWarnServiceImpl implements LineWarnLoadWarnService { ...@@ -34,7 +34,7 @@ public class LineWarnLoadWarnServiceImpl implements LineWarnLoadWarnService {
@Override @Override
public void loadWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) { public void loadWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) {
int unloadTimeAvg = 0; int unloadTimeAvg = lineWarnCommonInfo.getUnloadTimeAvg();
Integer arriveReceiveExpectTime = lineWarnCommonInfo.getArriveReceiveExpectTime(); Integer arriveReceiveExpectTime = lineWarnCommonInfo.getArriveReceiveExpectTime();
long totalTime = Duration.between(lineWarnCommonInfo.getPendingOrderTime(), long totalTime = Duration.between(lineWarnCommonInfo.getPendingOrderTime(),
......
...@@ -13,10 +13,7 @@ import com.clx.performance.model.linewarn.LineWarnOrderGoods; ...@@ -13,10 +13,7 @@ import com.clx.performance.model.linewarn.LineWarnOrderGoods;
import com.clx.performance.param.mq.linewarn.LineWarnLineWarnMqParam; import com.clx.performance.param.mq.linewarn.LineWarnLineWarnMqParam;
import com.clx.performance.param.mq.linewarn.LineWarnNoticeMqParam; import com.clx.performance.param.mq.linewarn.LineWarnNoticeMqParam;
import com.clx.performance.param.mq.linewarn.LineWarnOrderGoodsAddMqParam; import com.clx.performance.param.mq.linewarn.LineWarnOrderGoodsAddMqParam;
import com.clx.performance.service.linewarn.LineWarnLoadWarnService; import com.clx.performance.service.linewarn.*;
import com.clx.performance.service.linewarn.LineWarnMqHandlerService;
import com.clx.performance.service.linewarn.LineWarnTakeWarnService;
import com.clx.performance.service.linewarn.LineWarnUnloadWarnService;
import com.clx.performance.utils.LocalDateTimeUtils; import com.clx.performance.utils.LocalDateTimeUtils;
import com.clx.performance.utils.gd.GdUtils; import com.clx.performance.utils.gd.GdUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -30,6 +27,10 @@ import java.time.LocalDateTime; ...@@ -30,6 +27,10 @@ import java.time.LocalDateTime;
@Service @Service
public class LineWarnMqHandlerServiceImpl implements LineWarnMqHandlerService { public class LineWarnMqHandlerServiceImpl implements LineWarnMqHandlerService {
// 缺省装卸车时间
private static final int DEFAULT_LOAD_UNLOAD_TIME = 60;
private static final int DEFAULT_LOAD_UNLOAD_DAY = 7;
@Autowired @Autowired
private OrderGoodsDao orderGoodsDao; private OrderGoodsDao orderGoodsDao;
@Autowired @Autowired
...@@ -47,6 +48,14 @@ public class LineWarnMqHandlerServiceImpl implements LineWarnMqHandlerService { ...@@ -47,6 +48,14 @@ public class LineWarnMqHandlerServiceImpl implements LineWarnMqHandlerService {
@Autowired @Autowired
private LineWarnLoadWarnService lineWarnLoadWarnService; private LineWarnLoadWarnService lineWarnLoadWarnService;
@Autowired @Autowired
private LineWarnJamWarnService lineWarnJamWarnService;
@Autowired
private LineWarnWeatherWarnService lineWarnWeatherWarnService;
@Autowired
private LineWarnOrderChildWarnService lineWarnOrderChildWarnService;
@Autowired
private LineWarnLineWarnService lineWarnLineWarnService;
@Autowired
private OrderChildDao orderChildDao; private OrderChildDao orderChildDao;
...@@ -83,9 +92,18 @@ public class LineWarnMqHandlerServiceImpl implements LineWarnMqHandlerService { ...@@ -83,9 +92,18 @@ public class LineWarnMqHandlerServiceImpl implements LineWarnMqHandlerService {
lineWarnCommonInfo.setPendingOrderTime(lineWarnOrderGoods.getPendingOrderTime()); lineWarnCommonInfo.setPendingOrderTime(lineWarnOrderGoods.getPendingOrderTime());
lineWarnCommonInfo.setArriveReceiveExpectTime(lineWarnOrderGoods.getArriveReceiveExpectTime()); lineWarnCommonInfo.setArriveReceiveExpectTime(lineWarnOrderGoods.getArriveReceiveExpectTime());
Integer time = orderChildDao.loadTimeAvg(orderGoods.getSendAddressId(), orderGoods.getReceiveAddressId(), lineWarnCommonInfo.setTaskCount(orderGoods.getNeedTruckNum());
// 装卸车时间
Integer loadTimeAvg = orderChildDao.loadTimeAvg(orderGoods.getSendAddressId(), orderGoods.getReceiveAddressId(),
orderGoods.getSendSystemAddressId(), orderGoods.getReceiveSystemAddressId(),
LocalDateTimeUtils.formatTime(LocalDateTime.now().minusDays(DEFAULT_LOAD_UNLOAD_DAY)));
Integer unloadTimeAvg = orderChildDao.loadTimeAvg(orderGoods.getSendAddressId(), orderGoods.getReceiveAddressId(),
orderGoods.getSendSystemAddressId(), orderGoods.getReceiveSystemAddressId(), orderGoods.getSendSystemAddressId(), orderGoods.getReceiveSystemAddressId(),
LocalDateTimeUtils.formatTime(LocalDateTime.now().minusDays(7))); LocalDateTimeUtils.formatTime(LocalDateTime.now().minusDays(DEFAULT_LOAD_UNLOAD_DAY)));
lineWarnCommonInfo.setLoadTimeAvg(loadTimeAvg!=null? loadTimeAvg:DEFAULT_LOAD_UNLOAD_TIME);
lineWarnCommonInfo.setUnloadTimeAvg(unloadTimeAvg!=null? unloadTimeAvg:DEFAULT_LOAD_UNLOAD_TIME);
log.info("线路预警, lineWarnCommonInfo:{}", lineWarnCommonInfo);
// 接单预警 // 接单预警
try { try {
...@@ -107,6 +125,34 @@ public class LineWarnMqHandlerServiceImpl implements LineWarnMqHandlerService { ...@@ -107,6 +125,34 @@ public class LineWarnMqHandlerServiceImpl implements LineWarnMqHandlerService {
}catch (Exception e){ }catch (Exception e){
log.info("卸车预警异常,msg:{}", e.getMessage()); log.info("卸车预警异常,msg:{}", e.getMessage());
} }
// 拥堵预警
try{
lineWarnJamWarnService.jamWarn(orderGoods, lineWarnCommonInfo);
}catch (Exception e){
log.info("拥堵预警异常,msg:{}", e.getMessage());
}
// 天气预警
try{
lineWarnWeatherWarnService.weatherWarn(orderGoods, lineWarnCommonInfo);
}catch (Exception e){
log.info("天气预警异常,msg:{}", e.getMessage());
}
// 运单异常
try{
lineWarnOrderChildWarnService.orderChildWarn(orderGoods, lineWarnCommonInfo);
}catch (Exception e){
log.info("运单异常异常,msg:{}", e.getMessage());
}
// 线路异常
try{
lineWarnLineWarnService.lineWarn(orderGoods, lineWarnCommonInfo);
}catch (Exception e){
log.info("运单异常异常,msg:{}", e.getMessage());
}
} }
@Override @Override
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.clx.performance.common.MqDelay; import com.clx.performance.common.MqDelay;
import com.clx.performance.common.MqWrapper; import com.clx.performance.common.MqWrapper;
import com.clx.performance.constant.RabbitKeyLineWarnConstants; import com.clx.performance.constant.RabbitKeyLineWarnConstants;
import com.clx.performance.param.mq.linewarn.LineWarnLineReportMqParam;
import com.clx.performance.param.mq.linewarn.LineWarnLineWarnMqParam; import com.clx.performance.param.mq.linewarn.LineWarnLineWarnMqParam;
import com.clx.performance.param.mq.linewarn.LineWarnNoticeMqParam; import com.clx.performance.param.mq.linewarn.LineWarnNoticeMqParam;
import com.clx.performance.param.mq.linewarn.LineWarnOrderGoodsAddMqParam; import com.clx.performance.param.mq.linewarn.LineWarnOrderGoodsAddMqParam;
...@@ -55,4 +56,17 @@ public class LineWarnMqServiceImpl implements LineWarnMqService { ...@@ -55,4 +56,17 @@ public class LineWarnMqServiceImpl implements LineWarnMqService {
rabbitTemplate.send(RabbitKeyLineWarnConstants.DEFAULT_EXCHANGE, RabbitKeyLineWarnConstants.DEFAULT_DELAY_ROUTING_KEY, message); rabbitTemplate.send(RabbitKeyLineWarnConstants.DEFAULT_EXCHANGE, RabbitKeyLineWarnConstants.DEFAULT_DELAY_ROUTING_KEY, message);
} }
@Override
public void lineReport(Integer sendSystemAddressId, Integer receiveSystemAddressId, Integer reportType) {
LineWarnLineReportMqParam mq = new LineWarnLineReportMqParam();
mq.setSendSystemAddressId(sendSystemAddressId);
mq.setReceiveSystemAddressId(receiveSystemAddressId);
mq.setReportType(reportType);
MqDelay delay = new MqDelay<>(RabbitKeyLineWarnConstants.DEFAULT_EXCHANGE, RabbitKeyLineWarnConstants.LINE_WARN_LINE_REPORT_ROUTING_KEY, new MqWrapper<>(mq));
Message message = MessageBuilder.withBody(JSON.toJSONString(new MqWrapper<>(delay)).getBytes()).build();
message.getMessageProperties().setExpiration("5000");
rabbitTemplate.send(RabbitKeyLineWarnConstants.DEFAULT_EXCHANGE, RabbitKeyLineWarnConstants.DEFAULT_DELAY_ROUTING_KEY, message);
}
} }
package com.clx.performance.service.impl.linewarn;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.linewarn.LineWarnOrderChildWarnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class LineWarnOrderChildWarnServiceImpl implements LineWarnOrderChildWarnService {
@Override
public void orderChildWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) {
}
}
...@@ -23,7 +23,8 @@ import java.util.Objects; ...@@ -23,7 +23,8 @@ import java.util.Objects;
@Slf4j @Slf4j
@Service @Service
public class LineWarnTakeWarnServiceImpl implements LineWarnTakeWarnService { public class LineWarnTakeWarnServiceImpl implements LineWarnTakeWarnService {
// 默认时间
private static final int DEFAULT_TIME = 60;
@Autowired @Autowired
private LineWarnConfigDao lineWarnConfigDao; private LineWarnConfigDao lineWarnConfigDao;
@Autowired @Autowired
...@@ -34,13 +35,13 @@ public class LineWarnTakeWarnServiceImpl implements LineWarnTakeWarnService { ...@@ -34,13 +35,13 @@ public class LineWarnTakeWarnServiceImpl implements LineWarnTakeWarnService {
@Override @Override
public void takeWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) { public void takeWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) {
int loadTimeAvg = 0; int loadTimeAvg = lineWarnCommonInfo.getLoadTimeAvg();
int unloadTimeAvg = 0; int unloadTimeAvg = lineWarnCommonInfo.getUnloadTimeAvg();
Integer arriveReceiveExpectTime = lineWarnCommonInfo.getArriveReceiveExpectTime(); Integer arriveReceiveExpectTime = lineWarnCommonInfo.getArriveReceiveExpectTime();
long totalTime = Duration.between(lineWarnCommonInfo.getPendingOrderTime(), long totalTime = Duration.between(lineWarnCommonInfo.getPendingOrderTime(),
lineWarnCommonInfo.getTransportEndTime()).toMinutes(); lineWarnCommonInfo.getTransportEndTime()).toMinutes();
int needTime = 60+loadTimeAvg+unloadTimeAvg+arriveReceiveExpectTime; int needTime = DEFAULT_TIME+loadTimeAvg+unloadTimeAvg+arriveReceiveExpectTime;
// 接单最长时间 // 接单最长时间
long difTime = totalTime - needTime; long difTime = totalTime - needTime;
......
package com.clx.performance.service.impl.linewarn;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.linewarn.LineWarnWeatherWarnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnService {
@Override
public void weatherWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) {
}
}
package com.clx.performance.service.linewarn;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.model.OrderGoods;
public interface LineWarnJamWarnService {
void jamWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo);
}
package com.clx.performance.service.linewarn;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.model.OrderGoods;
public interface LineWarnLineWarnService {
void lineWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo);
}
...@@ -7,4 +7,6 @@ public interface LineWarnMqService { ...@@ -7,4 +7,6 @@ public interface LineWarnMqService {
void lineWarn(String childNo); void lineWarn(String childNo);
void lineWarnNotice(Integer infoId); void lineWarnNotice(Integer infoId);
void lineReport(Integer sendSystemAddressId, Integer receiveSystemAddressId, Integer reportType);
} }
package com.clx.performance.service.linewarn;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.model.OrderGoods;
public interface LineWarnOrderChildWarnService {
void orderChildWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo);
}
package com.clx.performance.service.linewarn;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.model.OrderGoods;
public interface LineWarnWeatherWarnService {
void weatherWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论