demand: 新增轨迹预警定时任务,定时扫描轨迹异常的运单,并通知相关责任人 tms-扫描管理-发件扫描-扫描可勾选轨迹已结束,用于人工确认运单轨迹结束 tms-扫描管理-扫描记录查询-查询条件增加'轨迹状态‘,查询返回增加'轨迹状态‘

This commit is contained in:
aike 2026-01-15 10:08:19 +08:00
parent 8abd08492f
commit ce2faad031
7 changed files with 58 additions and 44 deletions

View File

@ -48,6 +48,8 @@ public class EmisTmsScanRecord extends BaseEntity
private String orderSn;
/* 扫描类型: 收发到派签 */
private String scanType;
/* 判断轨迹是否结束 1:是 0:否,默认为0 */
private String blLastTrack;
/* 上下一站点 */
@DataAuditField(fieldComment = "上/下一站名称")
private String preOrNextStation;

View File

@ -42,6 +42,7 @@ public enum EmisBizErrorType {
SCAN_HAS_SIGN("E604","已签收"),
SCAN_HAS_PACK("E605","已组包"),
SCAN_NO_ALLOW("E606","不允许操作"),
SCAN_CONFIRM_LAST_TRACK("E607","不允许手动完成轨迹"),
BILL_LOCK("E901", "已锁定"),

View File

@ -25,6 +25,8 @@ public class ScanInfo implements Serializable {
private String scanType;
private Integer opType;
private String dataFrom;
/* 判断轨迹是否结束 1:是 0:否,默认为0 */
private String blLastTrack;
private List<Map<String,Object>> scanData;

View File

@ -3246,15 +3246,17 @@ public class EmisBaseService {
/**
* 改变运单状态
*
* @param billCode
* @param waybillStatus
* @param blLastTrack
* @return
*/
public int changeWaybillStatus(String billCode,String waybillStatus){
public int changeWaybillStatus(String billCode, String waybillStatus, String blLastTrack){
EmisWaybill emisWaybill = new EmisWaybill();
emisWaybill.setBillCode(billCode);
emisWaybill.setWaybillStatus(waybillStatus);
if("50".equals(waybillStatus)){
if ("1".equals(blLastTrack) || "50".equals(waybillStatus)) {
emisWaybill.setBlSign("1");
}
return emisWaybillMapper.changeWaybillStatusByBillCode(emisWaybill);

View File

@ -19,7 +19,6 @@ import com.alibaba.fastjson.JSON;
import com.xdadan.erp.common.core.domain.entity.SysUser;
import com.xdadan.erp.common.utils.DateUtils;
import com.xdadan.erp.common.utils.DictUtils;
import com.xdadan.erp.common.utils.ServletUtils;
import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.domain.enumtype.*;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
@ -29,14 +28,12 @@ import com.xdadan.erp.emis.domain.vo.scan.ScanResult;
import com.xdadan.erp.emis.domain.vo.scan.ScanResultItem;
import com.xdadan.erp.emis.mapper.*;
import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.utils.Kd100Helper;
import com.xdadan.erp.emis.utils.WaybillHelper;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.service.IEmisTmsScanRecordService;
import org.springframework.transaction.annotation.Transactional;
@ -451,11 +448,13 @@ public class EmisTmsScanRecordServiceImpl extends EmisBaseService implements IEm
/**
* 扫描操作
*
* @param scanType
* @param scanDataItem
* @param blLastTrack
* @return
*/
public List<ScanResultItem> doScan(String scanType,Map<String,Object> scanDataItem,String scanManCode,String scanSiteCode) {
public List<ScanResultItem> doScan(String scanType, Map<String,Object> scanDataItem, String scanManCode, String scanSiteCode, String blLastTrack) {
List<ScanResultItem> itemList = new ArrayList<>();
@ -682,6 +681,16 @@ public class EmisTmsScanRecordServiceImpl extends EmisBaseService implements IEm
EmisWaybill emisWaybill = getWaybillByBillCode(mainBillCode);
if ("1".equals(blLastTrack)) {
if (!"2".equals(emisWaybill.getCustomsClear())) {
scanResultItem.setResult("fail");
scanResultItem.setMessage(emisWaybill.getBillCode() + "清关方式不为自提清关,无法手动完成轨迹");
scanResultItem.setErrorCode(EmisBizErrorType.SCAN_CONFIRM_LAST_TRACK.errorCode);
itemList.add(scanResultItem);
return itemList;
}
emisTmsScanRecord.setBlLastTrack(blLastTrack);
}
// 填充运单基础数据
emisTmsScanRecord.setMainBillCode(emisWaybill.getBillCode());
@ -717,7 +726,7 @@ public class EmisTmsScanRecordServiceImpl extends EmisBaseService implements IEm
// 修改主运单状态
this.changeWaybillStatus(mainBillCode, scanType);
this.changeWaybillStatus(mainBillCode, scanType, blLastTrack);
scanResultItem.setResult("success");
scanResultItem.setErrorCode(EmisBizErrorType.SUCCESS.errorCode);
scanResultItem.setMessage("操作成功");
@ -2606,7 +2615,7 @@ public class EmisTmsScanRecordServiceImpl extends EmisBaseService implements IEm
List<ScanResultItem> resultList = new ArrayList<>();
if(scanInfo.getOpType()==2){
for (Map<String,Object> item: scanInfo.getScanData()) {
List<ScanResultItem> itemCheckList=doScan(scanInfo.getScanType(),item,scanManCode,scanSiteCode);
List<ScanResultItem> itemCheckList=doScan(scanInfo.getScanType(),item,scanManCode,scanSiteCode,scanInfo.getBlLastTrack());
resultList.addAll(itemCheckList);
}
}

View File

@ -14,7 +14,6 @@ package com.xdadan.erp.emis.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.beust.jcommander.internal.Lists;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.data.PictureType;
@ -24,11 +23,7 @@ package com.xdadan.erp.emis.service.impl;
import com.xdadan.erp.common.config.PayConfig;
import com.xdadan.erp.common.core.domain.entity.SysUser;
import com.xdadan.erp.common.core.redis.RedissonService;
import com.xdadan.erp.common.utils.BarcodeUtils;
import com.xdadan.erp.common.utils.DateUtils;
import com.xdadan.erp.common.utils.DictUtils;
import com.xdadan.erp.common.utils.SecurityUtils;
import com.xdadan.erp.common.utils.NoticeUtils;
import com.xdadan.erp.common.utils.*;
import com.xdadan.erp.common.utils.file.FileUploadUtils;
import com.xdadan.erp.common.utils.idgen.UUID;
import com.xdadan.erp.emis.domain.*;
@ -36,8 +31,6 @@ import com.xdadan.erp.emis.domain.enumtype.*;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
import com.xdadan.erp.emis.domain.vo.WaybillOrder;
import com.xdadan.erp.emis.domain.vo.scan.ScanInfo;
import com.xdadan.erp.emis.mapper.EmisSalesmenRelMapper;
import com.xdadan.erp.emis.domain.EmisSalesmenRel;
import com.xdadan.erp.emis.mapper.*;
import com.xdadan.erp.emis.service.*;
import com.xdadan.erp.emis.service.print.IXddTplPrint;
@ -74,8 +67,8 @@ import com.xdadan.erp.emis.service.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* 运单列表Service业务层处理
@ -6263,9 +6256,10 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
}
// 销售支持(可能为逗号分隔)
if (!StringUtils.isEmpty(waybill.getSalesSupport())) {
String[] supports = waybill.getSalesSupport().split("[,,]");
// 销售支持
EmisWaybillOther waybillOther = waybill.getWaybillOther();
if (waybillOther != null && !StringUtils.isEmpty(waybillOther.getSalesSupport())) {
String[] supports = waybillOther.getSalesSupport().split("[,,]");
for (String support : supports) {
if (!StringUtils.isEmpty(support)) {
notifyEmpCodes.add(support.trim());
@ -6277,18 +6271,18 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
continue;
}
String empCodeStr = String.join(",", notifyEmpCodes);
String billCode = waybill.getBillCode();
String timeStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now);
String title = "轨迹异常:运单【" + billCode + "】停留超过3天_" + timeStr;
String content = title;
String url = "/d24/waybillManagement/WaybillList?billCode=" + billCode;
String url = "/d24/waybillManagement/SendWaybillList?billCode=" + billCode;
notifyEmpCodes.forEach(empCode -> {
try {
NoticeUtils.outSendNoticeToInner(title, content, url, empCodeStr, 3);
NoticeUtils.outSendNoticeToInner(title, content, url, empCode, 3);
} catch (Exception ex) {
log.error("autoTraceWarning: send notice error, billCode={}, empCodes={}", billCode, empCodeStr, ex);
log.error("autoTraceWarning: send notice error, billCode={}, empCode={}", billCode, empCode, ex);
}
});
} catch (Exception ex) {
log.error("autoTraceWarning: handle waybill error, billCode={}", waybill.getBillCode(), ex);
}
@ -6512,7 +6506,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
int startIndex = remark.indexOf("T7080");
if (startIndex != -1) {
String subStr = remark.substring(startIndex);
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("T7080\\d+");
Pattern pattern = Pattern.compile("T7080\\d+");
java.util.regex.Matcher matcher = pattern.matcher(subStr);
if (matcher.find()) {
return matcher.group();

View File

@ -11,6 +11,7 @@
<result property="blSubBill" column="bl_sub_bill" />
<result property="orderSn" column="order_sn" />
<result property="scanType" column="scan_type" />
<result property="blLastTrack" column="bl_last_track" />
<result property="preOrNextStation" column="pre_or_next_station" />
<result property="preOrNextStationCode" column="pre_or_next_station_code" />
<result property="preOrNextStationPhone" column="pre_or_next_station_phone" />
@ -230,7 +231,7 @@
<!-- 获取订单最后一条扫描记录 -->
<select id="selectLastRecordBaseInfoByBillCode" parameterType="string" resultMap="BaseEmisTmsScanRecordResult">
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, bl_last_track, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
from emis_tms_scan_record a
where del_flag='0' and a.main_bill_code = #{billCode}
order by create_time desc limit 1
@ -239,7 +240,7 @@
<!-- 获取订单最后一条扫描记录 -->
<select id="selectNormalLastScanRecord" parameterType="string" resultMap="BaseEmisTmsScanRecordResult">
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, bl_last_track, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
from emis_tms_scan_record a
where del_flag='0' and a.main_bill_code = #{billCode} and scan_type in('10','20','30','40','50')
order by create_time desc limit 1
@ -272,12 +273,12 @@
<sql id="selectEmisTmsScanRecordVo">
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site from emis_tms_scan_record
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, bl_last_track, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site from emis_tms_scan_record
</sql>
<select id="selectEmisTmsScanRecordList" parameterType="EmisTmsScanRecord" resultMap="EmisTmsScanRecordResult">
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, bl_last_track, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
from emis_tms_scan_record a
<where>
@ -412,7 +413,7 @@
<select id="selectMonitorScanRecordList" parameterType="EmisTmsScanRecord" resultMap="EmisTmsScanRecordResult">
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, bl_last_track, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
from emis_tms_scan_record a
<where>
del_flag='0'
@ -527,7 +528,7 @@
<select id="selectEmisTmsScanRecordById" parameterType="Long" resultMap="EmisTmsScanRecordResult">
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
select id, bill_code, main_bill_code, bl_sub_bill, order_sn, scan_type, bl_last_track, pre_or_next_station, pre_or_next_station_code, pre_or_next_station_phone, pre_or_next_man_code, pre_or_next_man_phone, scan_date, scan_man_code, scan_man_phone, scan_man, pre_or_next_man, scan_site, scan_site_code, scan_site_phone, scan_weight, weight, dest_site_code, dest_code, dispatch_or_send_man, dispatch_or_send_man_code, dispatch_or_send_man_phone, sign_date, sign_man, sign_site, sign_site_code, record_man, record_man_code, record_man_phone, record_site_code, car_no, bag_no, truck_man, truck_code, data_from, pic_url, public_trace_info, inner_trace_info, rel_id, status, del_flag, create_by, create_time, update_by, update_time, remark, update_site, create_site
from emis_tms_scan_record a
where a.id = #{id}
</select>
@ -541,6 +542,7 @@
<if test="blSubBill != null and blSubBill != ''">bl_sub_bill,</if>
<if test="orderSn != null and orderSn != ''">order_sn,</if>
<if test="scanType != null and scanType != ''">scan_type,</if>
<if test="blLastTrack != null and blLastTrack != ''">bl_last_track,</if>
<if test="preOrNextStation != null and preOrNextStation != ''">pre_or_next_station,</if>
<if test="preOrNextStationCode != null and preOrNextStationCode != ''">pre_or_next_station_code,</if>
<if test="preOrNextStationPhone != null and preOrNextStationPhone != ''">pre_or_next_station_phone,</if>
@ -595,6 +597,7 @@
<if test="blSubBill != null and blSubBill != ''">#{blSubBill},</if>
<if test="orderSn != null and orderSn != ''">#{orderSn},</if>
<if test="scanType != null and scanType != ''">#{scanType},</if>
<if test="blLastTrack != null and blLastTrack != ''">#{blLastTrack},</if>
<if test="preOrNextStation != null and preOrNextStation != ''">#{preOrNextStation},</if>
<if test="preOrNextStationCode != null and preOrNextStationCode != ''">#{preOrNextStationCode},</if>
<if test="preOrNextStationPhone != null and preOrNextStationPhone != ''">#{preOrNextStationPhone},</if>
@ -652,6 +655,7 @@
<if test="blSubBill != null and blSubBill != ''">bl_sub_bill = #{blSubBill},</if>
<if test="orderSn != null and orderSn != ''">order_sn = #{orderSn},</if>
<if test="scanType != null and scanType != ''">scan_type = #{scanType},</if>
<if test="blLastTrack != null and blLastTrack != ''">bl_last_track = #{blLastTrack},</if>
<if test="preOrNextStation != null and preOrNextStation != ''">pre_or_next_station = #{preOrNextStation},</if>
<if test="preOrNextStationCode != null and preOrNextStationCode != ''">pre_or_next_station_code = #{preOrNextStationCode},</if>
<if test="preOrNextStationPhone != null and preOrNextStationPhone != ''">pre_or_next_station_phone = #{preOrNextStationPhone},</if>