This commit is contained in:
linfso 2025-07-10 11:44:01 +08:00
commit 547f1be88f
8 changed files with 144 additions and 45 deletions

View File

@ -11,8 +11,10 @@
package com.xdadan.erp.emis.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xdadan.erp.common.annotation.audit.DataAuditField;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xdadan.erp.common.annotation.Excel;
@ -48,6 +50,8 @@ public class EmisTmsSiteBatch extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date batchDate;
/* 供应商代码 */
@TableField
@DataAuditField(fieldComment = "供应商编码")
private String supplierCode;
/* 供应商名称 */
private String supplierName;
@ -56,24 +60,36 @@ public class EmisTmsSiteBatch extends BaseEntity
/* 所属产品 */
private String productType;
/* 批次类型 1-网点组批次 2-总部组批 */
@TableField
@DataAuditField(fieldComment = "批次类型")
private String batchType;
/* 运输方式: 空运 陆运 海运 */
@TableField
@DataAuditField(fieldComment = "运输方式")
private String transType;
/* 起始网点 */
@TableField
@DataAuditField(fieldComment = "起始网点")
private String startSiteCode;
/* 发件国家 */
private String sendCountry;
/* 下一网点 */
@TableField
@DataAuditField(fieldComment = "下一网点")
private String nextSiteCode;
/* 航空单号 */
private String airBilllNo;
/* 预计出发时间 */
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
@TableField
@DataAuditField(fieldComment = "预计出发时间")
private Date etd;
/* 预计到达时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date eta;
/* 车牌号 */
@TableField
@DataAuditField(fieldComment = "运输号")
private String carNo;
/* 船次号 */
private String shipNo;
@ -86,8 +102,12 @@ public class EmisTmsSiteBatch extends BaseEntity
/* 目的国家名称 */
private String destCountryName;
/* 运输重量 */
@TableField
@DataAuditField(fieldComment = "运输重量")
private BigDecimal transWeight;
/* 包裹数 */
@TableField
@DataAuditField(fieldComment = "包裹数")
private Integer packNum;
/* 总票数 */
private Integer totalParcelQty;

View File

@ -11,8 +11,10 @@
package com.xdadan.erp.emis.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xdadan.erp.common.annotation.audit.DataAuditField;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xdadan.erp.common.annotation.Excel;
@ -39,6 +41,8 @@ public class EmisTmsSiteBatchDtl extends BaseEntity
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/* 运单号 */
@TableField
@DataAuditField(fieldComment = "组批次运单号")
private String billCode;
/* 批次代码 */
private String batchNo;

View File

@ -126,4 +126,12 @@ public class EmisTmsSiteBatchMiss extends BaseEntity {
/* 是否问题件 1-是 0-否 */
private String blIsQuestion;
private String virtualRemark;
private Integer problemType;
/* 目的地网点代码 */
private String dispatchUnderlingSiteCode;
// 目的地网点名称
@TableField(exist = false)
@DataAuditField(fieldComment = "目的网点名称")
private String dispatchUnderlingSiteName;
}

View File

@ -2,6 +2,7 @@ package com.xdadan.erp.emis.mapper;
import java.util.List;
import com.xdadan.erp.emis.domain.EmisTmsSiteBatchMiss;
import com.xdadan.erp.emis.domain.EmisWaybill;
import org.apache.ibatis.annotations.Param;
/**
@ -85,4 +86,11 @@ public interface EmisTmsSiteBatchMissMapper {
* @param billCodes
*/
void deleteByBillCodes(@Param("billCodes") List<String> billCodes);
void deleteReally(String lineCode);
/**
* 根据运单号批量查询TMS漏组批次信息
*/
List<EmisWaybill> selectByBillCodes(@Param("billCodes") List<String> billCodes);
}

View File

@ -73,16 +73,54 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
log.info("Selecting TMS site batch miss list with params: {}", emisTmsSiteBatchMiss);
List<EmisTmsSiteBatchMiss> list = null;
// 如果单号不为空,则去除其他参数
if(!StringUtils.isEmpty(emisTmsSiteBatchMiss.getBillCode())){
if (!StringUtils.isEmpty(emisTmsSiteBatchMiss.getBillCode())) {
emisTmsSiteBatchMiss.setBillCode(WaybillHelper.formatQueryValue(emisTmsSiteBatchMiss.getBillCode()));
String[] billCodeSortList = emisTmsSiteBatchMiss.getBillCode().split(",");
if(billCodeSortList.length>1){
emisTmsSiteBatchMiss.getParams().put("billCodeSortList",Arrays.asList(billCodeSortList));
if (billCodeSortList.length > 1) {
emisTmsSiteBatchMiss.getParams().put("billCodeSortList", Arrays.asList(billCodeSortList));
}
list = emisTmsSiteBatchMissMapper.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
}else{
} else {
list = emisTmsSiteBatchMissMapper.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
}
// // 收集所有virtualRemark中的单号
// Set<String> relatedBillCodes = new HashSet<>();
// for (EmisTmsSiteBatchMiss miss : list) {
// String virtualRemark = miss.getVirtualRemark();
// if (virtualRemark != null && !virtualRemark.trim().isEmpty()) {
// String[] codes = virtualRemark.split(",");
// for (String code : codes) {
// relatedBillCodes.add(code.trim());
// }
// }
// }
// if (CollectionUtil.isEmpty(relatedBillCodes)) {
// return list;
// }
// // 批量查找相关单号
// List<EmisWaybill> relatedList = relatedBillCodes.isEmpty() ? Collections.emptyList()
// : emisTmsSiteBatchMissMapper.selectByBillCodes(new ArrayList<>(relatedBillCodes));
// Map<String, EmisWaybill> relatedMap = relatedList.stream()
// .collect(Collectors.toMap(EmisWaybill::getBillCode, Function.identity(), (a, b) -> a));
// // 过滤逻辑
// list = list.stream()
// .filter(wb -> {
// String virtualRemark = wb.getVirtualRemark();
// if (virtualRemark == null || virtualRemark.trim().isEmpty()) {
// return true;
// }
// String[] relatedNos = virtualRemark.split(",");
// for (String no : relatedNos) {
// EmisWaybill related = relatedMap.get(no.trim());
// if (related != null && Integer.valueOf(173).equals(related.getProblemType())) {
// return false;
// }
// }
// return true;
// })
// .collect(Collectors.toList());
return list;
}
@ -146,7 +184,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
@Override
public void autoScanSiteBatch(String lineCode) {
try {
emisTmsSiteBatchMissMapper.deleteAll(lineCode);
emisTmsSiteBatchMissMapper.deleteReally(lineCode);
long startTime = System.currentTimeMillis();
int pageSize = 1000;
int offset = 0;
@ -190,7 +228,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
try {
List<EmisWaybill> waybills = future.get();
allWaybills.addAll(waybills);
// totalProcessed += waybills.size();
totalProcessed += waybills.size();
} catch (Exception e) {
log.error("Error getting waybill results", e);
}
@ -199,34 +237,35 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
// 关闭线程池
executorService.shutdown();
// 构建运单号到EmisWaybill的映射
Map<String, EmisWaybill> waybillMap = allWaybills.stream()
.collect(Collectors.toMap(EmisWaybill::getBillCode, Function.identity(), (a, b) -> a));
allWaybills = allWaybills.stream()
.filter(wb -> {
String virtualRemark = wb.getVirtualRemark();
if (StringUtils.isBlank(virtualRemark)) {
return true;
}
// 解析virtualRemark中的运单号
String[] relatedNos = virtualRemark.split(",");
for (String no : relatedNos) {
EmisWaybill related = waybillMap.get(no.trim());
if (related != null && Objects.equals(related.getProblemType(), 173)) {
return false; // 只要有一个关联运单problemType=173,则过滤掉
}
}
return true;
})
.collect(Collectors.toList());
allWaybills = allWaybills.stream()
.filter(wb -> !Objects.equals(wb.getProblemType(), 170))
.filter(wb -> !Objects.equals(wb.getSiteBatchStatus(), "1"))
.collect(Collectors.toList());
totalProcessed = allWaybills.size();
// // 构建运单号到EmisWaybill的映射
// Map<String, EmisWaybill> waybillMap = allWaybills.stream()
// .collect(Collectors.toMap(EmisWaybill::getBillCode, Function.identity(), (a,
// b) -> a));
//
// allWaybills = allWaybills.stream()
// .filter(wb -> {
// String virtualRemark = wb.getVirtualRemark();
// if (StringUtils.isBlank(virtualRemark)) {
// return true;
// }
// // 解析virtualRemark中的运单号
// String[] relatedNos = virtualRemark.split(",");
// for (String no : relatedNos) {
// EmisWaybill related = waybillMap.get(no.trim());
// if (related != null && Objects.equals(related.getProblemType(), 173)) {
// return false; // 只要有一个关联运单problemType=173,则过滤掉
// }
// }
// return true;
// })
// .collect(Collectors.toList());
//
// allWaybills = allWaybills.stream()
// .filter(wb -> !Objects.equals(wb.getProblemType(), 170))
//// .filter(wb -> !Objects.equals(wb.getSiteBatchStatus(), "1"))
// .collect(Collectors.toList());
//
// totalProcessed = allWaybills.size();
// 按1000条数据分组处理
List<List<EmisWaybill>> batches = new ArrayList<>();

View File

@ -44,16 +44,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="waybillRemark" column="waybill_remark"/>
<result property="feeRemark" column="fee_remark"/>
<result property="missType" column="miss_type"/>
<result property="virtualRemark" column="virtual_remark" />
<result property="problemType" column="problem_type" />
<result property="dispatchUnderlingSiteCode" column="dispatch_underling_site_code" />
<result property="dispatchUnderlingSiteName" column="dispatch_underling_site_name" />
</resultMap>
<sql id="selectEmisTmsSiteBatchMissVo">
select
m.id, m.bill_code, m.miss_reason, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.del_flag,
m.id, m.bill_code, m.miss_reason, m.create_time, m.update_time, m.remark, m.del_flag,
m.line_code, m.product_type, m.start_site_code, m.next_site_code, m.supplier_code, m.start_date, m.end_date,m.miss_type,
w.send_site_code, s1.site_name as send_site_name,s2.site_name as start_site_name,s3.site_name as next_site_name, w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as destination_name,w.bl_is_question,
w.send_site_code, s1.site_name as send_site_name,s2.site_name as start_site_name,s3.site_name as next_site_name, w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as dispatch_underling_site_name,w.bl_is_question,
l.line_name as line_name,
w.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date,
w.product_type,
w.product_type,w.problem_type,w.virtual_remark,w.dispatch_underling_site_code,
w.payment_type, w.parcel_qty, w.bill_weight, w.total_volume, w.volume_weight,
w.settlement_weight, w.freight, w.remark as waybill_remark, w.fee_remark, m.manager, k.trans_manager,
(SELECT GROUP_CONCAT(s.name)
@ -71,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join emis_site s3 on m.next_site_code=s3.site_code and s3.del_flag=0
left join emis_country c1 on w.send_country=c1.code and c1.del_flag='0'
left join emis_country c2 on w.receive_country=c2.code and c2.del_flag='0'
left join emis_destination n on w.destination_code=n.dest_code and n.del_flag='0'
left join emis_destination n on w.dispatch_underling_site_code=n.dest_code and n.del_flag='0'
left join emis_trans_line k on w.trans_line_type=k.line_code and k.del_flag='0'
left join emis_trans_plan_rule r on m.trans_plan_rule_id=r.id and r.del_flag='0'
left join emis_trans_line l on m.line_code=l.line_code and l.del_flag='0'
@ -137,10 +141,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
w.trans_line_type as line_code, w.product_type, w.start_site_code, w.next_site_code,
null as supplier_code, null as start_date, null as end_date, '0' as miss_type,
w.send_site_code, s1.site_name as send_site_name,
w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as destination_name, w.bl_is_question,
w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as dispatch_underling_site_name, w.bl_is_question,
l.line_name as line_name,
w.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date,
w.product_type,
w.payment_type, w.parcel_qty, w.bill_weight, w.total_volume, w.volume_weight,
w.settlement_weight, w.freight, w.remark as waybill_remark, w.fee_remark,
null as manager, null as trans_manager,
@ -159,7 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
inner join emis_waybill w on b.bill_code = w.bill_code and w.del_flag='0'
left join emis_site s1 on w.send_site_code=s1.site_code and s1.del_flag=0
left join emis_country c1 on w.send_country=c1.code and c1.del_flag=0
left join emis_destination n on w.destination_code=n.dest_code and n.del_flag=0
left join emis_destination n on w.dispatch_underling_site_code=n.dest_code and n.del_flag=0
left join emis_trans_line l on w.trans_line_type=l.line_code and l.del_flag=0
left join emis_country c2 on w.receive_country=c2.code and c2.del_flag=0
<where>
@ -358,6 +361,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</update>
<delete id="deleteReally">
delete from emis_tms_site_batch_miss
<if test="lineCode != null and lineCode != ''">
where line_code = #{lineCode}
</if>
</delete>
<update id="deleteByBillCodes">
update emis_tms_site_batch_miss set del_flag = '1'
where bill_code in
@ -408,4 +418,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
HAVING COUNT(*) = #{count}
)
</select>
<select id="selectByBillCodes" resultMap="com.xdadan.erp.emis.mapper.EmisWaybillMapper.EmisWaybillResult">
select a.id, a.bill_code,a.trans_line_type,
a.product_type,a.start_site_code,a.send_site_code,a.problem_type,a.virtual_remark
from emis_waybill a
where bill_code in
<foreach collection="billCodes" item="billCode" open="(" separator="," close=")">
#{billCode}
</foreach>
</select>
</mapper>

View File

@ -3814,17 +3814,18 @@
<select id="selectWaybillListBySiteBatchStatus" resultMap="EmisWaybillResult">
select a.id, a.bill_code,a.trans_line_type,
a.product_type,a.start_site_code,a.send_site_code,a.problem_type,a.virtual_remark,b.site_batch_status
a.product_type,a.start_site_code,a.send_site_code,a.problem_type,a.virtual_remark
from emis_waybill a
left join emis_waybill_batch_status b on a.bill_code = b.bill_code
and (b.site_batch_status is null or b.site_batch_status != '1')
where a.del_flag = '0'
-- and (b.site_batch_status is null or b.site_batch_status != '1')
<if test="lineCode != null and lineCode != ''">
and a.trans_line_type = #{lineCode}
</if>
and DATE_FORMAT(a.send_date, '%Y-%m-%d') <![CDATA[ >= ]]> '2025-01-01'
and DATE_FORMAT(a.send_date, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 7 DAY), '%Y-%m-%d')
and (a.problem_type is null or a.problem_type != 151)
and (a.problem_type is null or a.problem_type not in (151,170))
and ((a.virtual_remark is null or a.virtual_remark = '' or a.virtual_remark = ' ')or a.receive_country != '0095')
and a.order_status not in ('0','2')
order by a.create_time desc
limit #{offset}, #{pageSize}

View File

@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<insert id="batchInsertEmisWaybillBatchStatus" parameterType="java.util.List">
insert into emis_waybill_batch_status (
insert ignore into emis_waybill_batch_status (
bill_code, site_batch_status, remark,
create_by, create_time, update_by, update_time
) values