demand: 新增定时任务扫描记录表,定时扫描任务优化
committer: heyu
This commit is contained in:
parent
c5dee14a0f
commit
61bcf29a97
@ -0,0 +1,39 @@
|
|||||||
|
package com.xdadan.erp.emis.domain;
|
||||||
|
|
||||||
|
import com.xdadan.erp.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TMS漏组批次扫描记录对象
|
||||||
|
*
|
||||||
|
* @author heyu
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EmisTmsSiteBatchMissRecord extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键ID */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 总处理数量 */
|
||||||
|
private Integer totalProcessed;
|
||||||
|
|
||||||
|
/** 成功数量 */
|
||||||
|
private Integer successCount;
|
||||||
|
|
||||||
|
/** 失败数量 */
|
||||||
|
private Integer failCount;
|
||||||
|
|
||||||
|
/** 处理耗时(毫秒) */
|
||||||
|
private Long processTime;
|
||||||
|
|
||||||
|
/** 批次状态记录数 */
|
||||||
|
private Integer totalBatchStatusRecords;
|
||||||
|
|
||||||
|
/** 漏组记录数 */
|
||||||
|
private Integer totalMissRecords;
|
||||||
|
|
||||||
|
/** 失败运单号列表 */
|
||||||
|
private String failedBillCodes;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.xdadan.erp.emis.mapper;
|
||||||
|
|
||||||
|
import com.xdadan.erp.emis.domain.EmisTmsSiteBatchMissRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TMS漏组批次扫描记录Mapper接口
|
||||||
|
*
|
||||||
|
* @author Claude
|
||||||
|
*/
|
||||||
|
public interface EmisTmsSiteBatchMissRecordMapper {
|
||||||
|
/**
|
||||||
|
* 新增TMS漏组批次扫描记录
|
||||||
|
*
|
||||||
|
* @param record 漏组批次扫描记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertEmisTmsSiteBatchMissRecord(EmisTmsSiteBatchMissRecord record);
|
||||||
|
}
|
||||||
@ -14,6 +14,7 @@ import com.xdadan.erp.emis.service.EmisBaseService;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.xdadan.erp.emis.service.IEmisTmsSiteBatchMissService;
|
import com.xdadan.erp.emis.service.IEmisTmsSiteBatchMissService;
|
||||||
|
|
||||||
@ -44,6 +45,9 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EmisTmsSiteBatchMapper emisTmsSiteBatchMapper;
|
private EmisTmsSiteBatchMapper emisTmsSiteBatchMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmisTmsSiteBatchMissRecordMapper emisTmsSiteBatchMissRecordMapper;
|
||||||
|
|
||||||
private int totalBatchStatusRecords = 0;
|
private int totalBatchStatusRecords = 0;
|
||||||
private int totalMissRecords = 0;
|
private int totalMissRecords = 0;
|
||||||
|
|
||||||
@ -119,6 +123,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
|||||||
return emisTmsSiteBatchMissMapper.deleteEmisTmsSiteBatchMissById(id);
|
return emisTmsSiteBatchMissMapper.deleteEmisTmsSiteBatchMissById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public void autoScanSiteBatch() {
|
public void autoScanSiteBatch() {
|
||||||
try {
|
try {
|
||||||
@ -222,9 +227,14 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
|||||||
executorService.shutdown();
|
executorService.shutdown();
|
||||||
|
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
|
long processTime = endTime - startTime;
|
||||||
|
|
||||||
|
// 保存扫描记录
|
||||||
|
saveRecord(totalProcessed, successCount, failCount, processTime, failedBillCodes);
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
"Auto scan completed. Total processed: {}, Success: {}, Failed: {}, Time taken: {}ms, Batch status records: {}, Miss records: {}",
|
"Auto scan completed. Total processed: {}, Success: {}, Failed: {}, Time taken: {}ms, Batch status records: {}, Miss records: {}",
|
||||||
totalProcessed, successCount, failCount, (endTime - startTime),
|
totalProcessed, successCount, failCount, processTime,
|
||||||
totalBatchStatusRecords, totalMissRecords);
|
totalBatchStatusRecords, totalMissRecords);
|
||||||
if (CollectionUtil.isNotEmpty(failedBillCodes)) {
|
if (CollectionUtil.isNotEmpty(failedBillCodes)) {
|
||||||
log.warn("Failed bill codes: {}", failedBillCodes);
|
log.warn("Failed bill codes: {}", failedBillCodes);
|
||||||
@ -234,6 +244,23 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveRecord(int totalProcessed, int successCount, int failCount, long processTime, List<String> failedBillCodes) {
|
||||||
|
EmisTmsSiteBatchMissRecord record = new EmisTmsSiteBatchMissRecord();
|
||||||
|
record.setTotalProcessed(totalProcessed);
|
||||||
|
record.setSuccessCount(successCount);
|
||||||
|
record.setFailCount(failCount);
|
||||||
|
record.setProcessTime(processTime);
|
||||||
|
record.setTotalBatchStatusRecords(totalBatchStatusRecords);
|
||||||
|
record.setTotalMissRecords(totalMissRecords);
|
||||||
|
record.setFailedBillCodes(
|
||||||
|
CollectionUtil.isNotEmpty(failedBillCodes) ? String.join(",", failedBillCodes) : "");
|
||||||
|
record.setCreateBy("system");
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
record.setCreateSite("88888");
|
||||||
|
|
||||||
|
emisTmsSiteBatchMissRecordMapper.insertEmisTmsSiteBatchMissRecord(record);
|
||||||
|
}
|
||||||
|
|
||||||
private static class ProcessResult {
|
private static class ProcessResult {
|
||||||
private final int successCount;
|
private final int successCount;
|
||||||
private final int failCount;
|
private final int failCount;
|
||||||
@ -368,6 +395,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
|||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
batchStatus.setCreateBy("system");
|
batchStatus.setCreateBy("system");
|
||||||
batchStatus.setCreateTime(now);
|
batchStatus.setCreateTime(now);
|
||||||
|
batchStatus.setCreateSite("88888");
|
||||||
batchStatusList.add(batchStatus);
|
batchStatusList.add(batchStatus);
|
||||||
}
|
}
|
||||||
successCount++;
|
successCount++;
|
||||||
@ -395,6 +423,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
|||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
miss.setCreateBy("system");
|
miss.setCreateBy("system");
|
||||||
miss.setCreateTime(now);
|
miss.setCreateTime(now);
|
||||||
|
miss.setCreateSite("88888");
|
||||||
return miss;
|
return miss;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +519,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
|||||||
if (!isMatched) {
|
if (!isMatched) {
|
||||||
// 创建漏组记录
|
// 创建漏组记录
|
||||||
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
|
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
|
||||||
miss.setMissReason(String.format("组批次有遗漏/错误,请根据推荐路线排查,推荐路线: %s-%s-%s",
|
miss.setMissReason(String.format("组批次有遗漏/错误,请根据推荐路线排查: %s-%s-%s",
|
||||||
rule.getStartSiteName(),
|
rule.getStartSiteName(),
|
||||||
rule.getNextSiteName(),
|
rule.getNextSiteName(),
|
||||||
rule.getSupplierName()));
|
rule.getSupplierName()));
|
||||||
@ -518,7 +547,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
|||||||
|
|
||||||
if (!hasMatchedChild) {
|
if (!hasMatchedChild) {
|
||||||
// 如果所有子节点都不匹配,为每个子节点创建漏组记录
|
// 如果所有子节点都不匹配,为每个子节点创建漏组记录
|
||||||
StringBuilder missReason = new StringBuilder("组批次有遗漏/错误,请根据推荐路线排查,推荐路线: ");
|
StringBuilder missReason = new StringBuilder("组批次有遗漏/错误,请根据推荐路线排查: ");
|
||||||
for (int i = 0; i < childrens.size(); i++) {
|
for (int i = 0; i < childrens.size(); i++) {
|
||||||
EmisTransPlanRule childRule = childrens.get(i);
|
EmisTransPlanRule childRule = childrens.get(i);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
|||||||
@ -484,7 +484,7 @@
|
|||||||
|
|
||||||
<!-- 根据运单号列表查询组批次信息 -->
|
<!-- 根据运单号列表查询组批次信息 -->
|
||||||
<select id="selectEmisTmsSiteBatchListByBillCodes" resultMap="EmisTmsSiteBatchDtlResult">
|
<select id="selectEmisTmsSiteBatchListByBillCodes" resultMap="EmisTmsSiteBatchDtlResult">
|
||||||
select distinct b.*
|
select distinct b.id, b.batch_no, b.supplier_code, b.trans_line_type, b.product_type, b.trans_type, b.start_site_code, b.next_site_code, b.etd
|
||||||
from emis_tms_site_batch b
|
from emis_tms_site_batch b
|
||||||
inner join emis_tms_site_batch_dtl d on b.batch_no = d.batch_no
|
inner join emis_tms_site_batch_dtl d on b.batch_no = d.batch_no
|
||||||
where d.bill_code in
|
where d.bill_code in
|
||||||
|
|||||||
@ -3166,39 +3166,11 @@
|
|||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="selectWaybillListBySiteBatchStatus" resultMap="EmisWaybillResult">
|
<select id="selectWaybillListBySiteBatchStatus" resultMap="EmisWaybillResult">
|
||||||
select a.id,a.order_sn, a.cust_order_id, a.bill_code, a.order_status, a.waybill_status,
|
select a.id, a.bill_code,a.trans_line_type, a.product_type
|
||||||
a.order_type, a.order_date, a.user_id, a.customer_code, a.customer_name, a.open_id, a.receive_name,
|
|
||||||
a.receive_company, a.receive_mobile, a.receive_tel, a.receive_country, a.receive_province, a.receive_city,
|
|
||||||
a.receive_county, a.receive_town, a.receive_address, a.receive_postcode, a.receive_pcd, a.send_name, a.send_company,
|
|
||||||
a.send_mobile, a.send_tel, a.send_country, a.send_province, a.send_city, a.send_county, a.send_town, a.send_address,
|
|
||||||
a.send_postcode, a.send_pcd, a.payment_type, a.calc_fee_type, a.cust_no, a.cust_name, a.trans_line_type, a.product_type,
|
|
||||||
a.time_type, a.meter_type, a.carry_type, a.customs_clear, a.customs_eclaration, a.estimate_date, a.pack_type, a.dispatch_method,
|
|
||||||
a.pickup_method, a.pick_start_date, a.pick_finish_date, a.pick_fail_reason, a.into_warehouse_code,
|
|
||||||
a.into_warehouse_name, a.into_warehouse_address, a.into_warehouse_contact, a.into_warehouse_phone,
|
|
||||||
a.into_warehouse_bill_code, a.warehouse_in_no, a.customer_delivery_begin_time, a.customer_delivery_end_time,
|
|
||||||
a.goods_type, a.goods_info, a.goods_pics, a.bl_prepare_in_freight, a.prepare_in_est_fee,
|
|
||||||
a.prepare_in_real_fee, a.prepare_in_express, a.prepare_in_bill_code, a.prepare_in_remark,
|
|
||||||
a.prepare_in_supplier, a.total_weight, a.total_volume, a.parcel_qty, a.bill_weight, a.volume_weight, a.currency,
|
|
||||||
a.settlement_weight, a.scan_weight, a.fee_weight, a.freight, a.real_payment_type, a.real_fee, a.bl_special_quote,
|
|
||||||
a.bl_over_long, a.bl_bill, a.bl_bill_text, a.bl_over_weight, a.over_weight_number, a.fee_remark, a.third_code,
|
|
||||||
a.real_value, a.bl_insure, a.insure_value, a.insure_value_currency, a.insure_fee_currency, a.insure_fee, a.insure_remark,
|
|
||||||
a.insure_site_code, a.insure_date, a.bl_print, a.print_man_code, a.print_site, a.print_date, a.print_count, a.bl_disp_fd,
|
|
||||||
a.transfer_code, a.transfer_billcode, a.disp_fd_date, a.disp_fd_reason, a.current_site_code, a.next_site_code, a.last_site_code,
|
|
||||||
a.register_site_code, a.register_date, a.register_man_code, a.take_piece_employee_code, a.send_site_code, a.send_center_code,
|
|
||||||
a.send_date, a.dispatch_man_code, a.dispatch_date, a.dispatch_site_code, a.produce_bill_date, a.produce_bill_site_code,
|
|
||||||
a.produce_bill_man_code, a.destination_code, a.destination_province, a.destination_city, a.destination_county,
|
|
||||||
a.dispatch_underling_site_code, a.destination_center_code, a.market_man_code, a.payee, a.salesmen, a.operate_employee_code,
|
|
||||||
a.bl_is_question, a.problem_type, a.problem_cause, a.problem_delay_days, a.bl_message, a.bl_accept_message, a.bl_gen_subbill,
|
|
||||||
a.bl_sign, a.sign_man, a.sign_man_code, a.sign_site_code, a.sign_date, a.bill_pic_send_rmk, a.bill_pic_dispatch_rmk, a.timezone_offset,
|
|
||||||
a.payment_status, a.payment_date, a.payment_remark, a.order_remark, a.data_from, a.bl_special_goods,a.ext_info,
|
|
||||||
a.remark, a.del_flag, a.create_by,
|
|
||||||
a.create_time, a.update_by, a.update_time, a.create_site, a.update_site,
|
|
||||||
a.cod_fee_desc, a.lading_bill_code, a.company_code, a.departure_port, a.destination_port, a.box_quantity
|
|
||||||
from emis_waybill a
|
from emis_waybill a
|
||||||
left join emis_waybill_batch_status b on a.bill_code = b.bill_code
|
left join emis_waybill_batch_status b on a.bill_code = b.bill_code
|
||||||
where a.bl_sign = '1'
|
where a.bl_sign = '1'
|
||||||
and a.del_flag = '0'
|
and a.del_flag = '0'
|
||||||
-- and a.bill_code="T7080300290222"
|
|
||||||
and (b.site_batch_status is null or b.site_batch_status != '1')
|
and (b.site_batch_status is null or b.site_batch_status != '1')
|
||||||
order by a.create_time desc
|
order by a.create_time desc
|
||||||
limit #{offset}, #{pageSize}
|
limit #{offset}, #{pageSize}
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
<?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.xdadan.erp.emis.mapper.EmisTmsSiteBatchMissRecordMapper">
|
||||||
|
|
||||||
|
<resultMap type="EmisTmsSiteBatchMissRecord" id="EmisTmsSiteBatchMissRecordResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="totalProcessed" column="total_processed"/>
|
||||||
|
<result property="successCount" column="success_count"/>
|
||||||
|
<result property="failCount" column="fail_count"/>
|
||||||
|
<result property="processTime" column="process_time"/>
|
||||||
|
<result property="totalBatchStatusRecords" column="total_batch_status_records"/>
|
||||||
|
<result property="totalMissRecords" column="total_miss_records"/>
|
||||||
|
<result property="failedBillCodes" column="failed_bill_codes"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="createSite" column="create_site"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<insert id="insertEmisTmsSiteBatchMissRecord" parameterType="EmisTmsSiteBatchMissRecord">
|
||||||
|
insert into emis_tms_site_batch_miss_record (
|
||||||
|
total_processed,
|
||||||
|
success_count,
|
||||||
|
fail_count,
|
||||||
|
process_time,
|
||||||
|
total_batch_status_records,
|
||||||
|
total_miss_records,
|
||||||
|
failed_bill_codes,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
create_site
|
||||||
|
) values (
|
||||||
|
#{totalProcessed},
|
||||||
|
#{successCount},
|
||||||
|
#{failCount},
|
||||||
|
#{processTime},
|
||||||
|
#{totalBatchStatusRecords},
|
||||||
|
#{totalMissRecords},
|
||||||
|
#{failedBillCodes},
|
||||||
|
#{createBy},
|
||||||
|
#{createTime},
|
||||||
|
#{createSite}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user