|
@@ -47,6 +47,7 @@ import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -120,6 +121,62 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
@Value("${com.changyuntong.env}")
|
|
|
private String ENV;
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询订单是否超时(每分钟执行一次)
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @Scheduled(cron = "0 */1 * * * ?")
|
|
|
+ public void queryOrderTimeout(){
|
|
|
+ //查询所有运输中的订单
|
|
|
+ List<OrderInfo> orderInfoList = this.selectList(new EntityWrapper<OrderInfo>().eq("order_status_key", 13)
|
|
|
+ .eq("delete_flag", "0"));
|
|
|
+ if (CollectionUtils.isNotEmpty(orderInfoList)) {
|
|
|
+ orderInfoList.forEach(orderInfo -> {
|
|
|
+ //获取当前日期
|
|
|
+ Date now = new Date();
|
|
|
+ //查询承运表信息
|
|
|
+ HyCarrierInfo hyCarrierInfo = carrierInfoService.selectOne(new EntityWrapper<HyCarrierInfo>().eq("order_id", orderInfo.getId())
|
|
|
+ .eq("delete_flag", "0"));
|
|
|
+ //获取装车时间和运输时长,计算预计送达时间
|
|
|
+ int min = (int)(hyCarrierInfo.getTransportationDuration() * 60);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(hyCarrierInfo.getLoadingDate());
|
|
|
+ calendar.add(Calendar.MINUTE, min);
|
|
|
+ Date date = calendar.getTime();
|
|
|
+ //当前时间与预计送达时间比较
|
|
|
+ int result = date.compareTo(now);
|
|
|
+ if (result < 0) {
|
|
|
+ //给司机发送消息
|
|
|
+ NewsInfo newsInfo = new NewsInfo();
|
|
|
+ newsInfo.setReCommonId(orderInfo.getCommonId());
|
|
|
+ newsInfo.setBussId(orderInfo.getId());
|
|
|
+ newsInfo.setNewsTitle("超时通知!");
|
|
|
+ newsInfo.setNewsContent("订单编号" + orderInfo.getOrderNo() + "未按时到达,请联系货主说明原因。");
|
|
|
+ newsInfo.setNewsTypeKey("5");
|
|
|
+ newsInfo.setNewsType("超时通知");
|
|
|
+ newsInfoService.addNewsInfo(newsInfo);
|
|
|
+ //给平台发送消息
|
|
|
+ NewsInfo newsInfo1 = new NewsInfo();
|
|
|
+ newsInfo1.setReCommonId("84f62127b7384dcdbaeaddfe460329fc");
|
|
|
+ newsInfo1.setBussId(orderInfo.getId());
|
|
|
+ newsInfo1.setNewsTitle("超时通知!");
|
|
|
+ newsInfo1.setNewsContent("订单编号" + orderInfo.getOrderNo() + "未按时送达。");
|
|
|
+ newsInfo1.setNewsTypeKey("5");
|
|
|
+ newsInfo1.setNewsType("超时通知");
|
|
|
+ newsInfoService.addNewsInfo(newsInfo1);
|
|
|
+ //给货主发送消息
|
|
|
+ NewsInfo newsInfo2 = new NewsInfo();
|
|
|
+ newsInfo2.setReCommonId(orderInfo.getCargoCommonId());
|
|
|
+ newsInfo2.setBussId(orderInfo.getId());
|
|
|
+ newsInfo2.setNewsTitle("超时通知!");
|
|
|
+ newsInfo2.setNewsContent("订单编号" + orderInfo.getOrderNo() + "未按时到达,请联系司机了解原因,或联系客服介入。");
|
|
|
+ newsInfo2.setNewsTypeKey("5");
|
|
|
+ newsInfo2.setNewsType("超时通知");
|
|
|
+ newsInfoService.addNewsInfo(newsInfo2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 司机订单列表
|