demand: TMS系统 - 客户管理 - 现金客户额度 - 超期已用额度 与运单明细单号运费不一致;
committer: heyu
This commit is contained in:
parent
eeefc44f86
commit
413aefda36
@ -2845,7 +2845,13 @@ public class EmisBaseService {
|
||||
}
|
||||
|
||||
if (StringUtil.isNotBlank(waybill.getVirtualRemark())) {
|
||||
remark = remark + " " + "该运单为主单,对应虚拟单为" + waybill.getVirtualRemark();
|
||||
// 取每个虚拟单号的后六位,用逗号拼接
|
||||
String[] codes = waybill.getVirtualRemark().split(",");
|
||||
String shortCodes = Arrays.stream(codes)
|
||||
.filter(s -> s != null && s.length() >= 6)
|
||||
.map(s -> s.substring(s.length() - 6))
|
||||
.collect(Collectors.joining(","));
|
||||
remark = remark + " " + "该运单为主单,对应虚拟单为" + shortCodes;
|
||||
}
|
||||
// if (StringUtil.isNotBlank(waybill.getMasterBillCode())) {
|
||||
// remark = remark + " " + "该运单为虚拟单,对应主单为" + waybill.getMasterBillCode();
|
||||
@ -4787,10 +4793,10 @@ public class EmisBaseService {
|
||||
}
|
||||
updateMasterWaybill(emisWaybillSave,emisWaybillOld);
|
||||
// 做问题件录入
|
||||
scanProblemInfo(emisWaybillSave);
|
||||
scanProblemInfo(emisWaybillSave,emisWaybillOld);
|
||||
}
|
||||
|
||||
public void scanProblemInfo(EmisWaybill emisWaybillSave) {
|
||||
public void scanProblemInfo(EmisWaybill emisWaybillSave, EmisWaybill emisWaybillOld) {
|
||||
String dispatchOrSendManCode = "";
|
||||
if ("1".equals(emisWaybillSave.getPickupMethod())) {
|
||||
dispatchOrSendManCode = emisWaybillSave.getOperateEmployeeCode();
|
||||
@ -4812,7 +4818,11 @@ public class EmisBaseService {
|
||||
scanDatePromItem.put("remark", "返货虚拟面单");
|
||||
}
|
||||
scanDatePromItem.put("notifySite", emisWaybillSave.getSendSiteCode());
|
||||
scanDatePromItem.put("scanDate", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, emisWaybillSave.getSendDate()));
|
||||
if (null == emisWaybillOld) {
|
||||
scanDatePromItem.put("scanDate", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, emisWaybillSave.getSendDate()));
|
||||
} else {
|
||||
scanDatePromItem.put("scanDate", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getNowDate()));
|
||||
}
|
||||
scanDatePromItem.put("scanWeight", "0.0");
|
||||
scanDataPromList.add(scanDatePromItem);
|
||||
scanInfoProm.setScanData(scanDataPromList);
|
||||
@ -4839,45 +4849,54 @@ public class EmisBaseService {
|
||||
emisWaybillMapper.updateEmisWaybill(emisWaybill);
|
||||
}
|
||||
|
||||
public EmisWaybill checkVirtualParam(EmisWaybill emisWaybillSave, EmisWaybill emisWaybillOld) throws EmisBizError {
|
||||
if (StringUtil.isBlank(emisWaybillSave.getMasterBillCode())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "主单号不能为空");
|
||||
}
|
||||
if (!"002".equals(emisWaybillSave.getTransLineType()) && !"012".equals(emisWaybillSave.getTransLineType())
|
||||
&& !"014".equals(emisWaybillSave.getTransLineType())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "虚拟单只支持线路为缅甸快递/缅甸快递进口/柬埔寨快递进口");
|
||||
}
|
||||
EmisWaybill masterWaybill = emisWaybillMapper
|
||||
.selectEmisWaybillByBillCode(emisWaybillSave.getMasterBillCode());
|
||||
if (Objects.isNull(masterWaybill)) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "主单号不存在");
|
||||
}
|
||||
if (!emisWaybillSave.getReceiveCountry().equals(masterWaybill.getReceiveCountry())
|
||||
|| !emisWaybillSave.getTransLineType().equals(masterWaybill.getTransLineType())
|
||||
|| !emisWaybillSave.getProductType().equals(masterWaybill.getProductType())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "主单和虚拟单线路不一致");
|
||||
}
|
||||
if ("1".equals(masterWaybill.getBlVirtual())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "虚拟单不能作为主单");
|
||||
}
|
||||
if (!emisWaybillSave.getMasterBillCode().equals(emisWaybillOld.getMasterBillCode())) {
|
||||
String virtualRemark = masterWaybill.getVirtualRemark() == null ? "" : masterWaybill.getVirtualRemark();
|
||||
long count = Arrays.stream(virtualRemark.split(","))
|
||||
.filter(s -> s != null && !s.trim().isEmpty())
|
||||
.count();
|
||||
if (count >= masterWaybill.getParcelQty()) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
emisWaybillSave.getMasterBillCode() + "最多只能绑定" + masterWaybill.getParcelQty() + "个虚拟单");
|
||||
}
|
||||
}
|
||||
public EmisWaybill checkVirtualParam(EmisWaybill emisWaybillSave, EmisWaybill emisWaybillOld) throws EmisBizError {
|
||||
if (StringUtil.isBlank(emisWaybillSave.getMasterBillCode())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "主单号不能为空");
|
||||
}
|
||||
if(StringUtil.isNotBlank(emisWaybillOld.getVirtualRemark())){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "主单不能改虚拟单");
|
||||
}
|
||||
if (emisWaybillSave.getParcelQty() != 1) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "虚拟单件数只能为1");
|
||||
}
|
||||
if (emisWaybillSave.getMasterBillCode().equals(emisWaybillSave.getBillCode())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "运单号主单号不能相同");
|
||||
}
|
||||
if (!"002".equals(emisWaybillSave.getTransLineType()) && !"012".equals(emisWaybillSave.getTransLineType())
|
||||
&& !"014".equals(emisWaybillSave.getTransLineType())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "虚拟单只支持线路为缅甸快递/缅甸快递进口/柬埔寨快递进口");
|
||||
}
|
||||
EmisWaybill masterWaybill = emisWaybillMapper
|
||||
.selectMasterWaybillByBillCode(emisWaybillSave.getMasterBillCode());
|
||||
if (Objects.isNull(masterWaybill)) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "主单号不存在");
|
||||
}
|
||||
if (!emisWaybillSave.getReceiveCountry().equals(masterWaybill.getReceiveCountry())
|
||||
|| !emisWaybillSave.getTransLineType().equals(masterWaybill.getTransLineType())
|
||||
|| !emisWaybillSave.getProductType().equals(masterWaybill.getProductType())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "主单和虚拟单线路不一致");
|
||||
}
|
||||
if ("1".equals(masterWaybill.getBlVirtual())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "虚拟单不能作为主单");
|
||||
}
|
||||
if (!emisWaybillSave.getMasterBillCode().equals(emisWaybillOld.getMasterBillCode())) {
|
||||
String virtualRemark = masterWaybill.getVirtualRemark() == null ? "" : masterWaybill.getVirtualRemark();
|
||||
long count = Arrays.stream(virtualRemark.split(","))
|
||||
.filter(s -> s != null && !s.trim().isEmpty())
|
||||
.count();
|
||||
if (count >= masterWaybill.getParcelQty()) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
emisWaybillSave.getMasterBillCode() + "最多只能绑定" + masterWaybill.getParcelQty() + "个虚拟单");
|
||||
}
|
||||
}
|
||||
|
||||
List<EmisTmsSiteBatch> batchList = emisTmsSiteBatchMapper.selectEmisTmsSiteBatchListByBillCodes(
|
||||
Lists.newArrayList(Collections.singleton(emisWaybillSave.getMasterBillCode())));
|
||||
if (CollectionUtil.isNotEmpty(batchList)) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "该单号已经录入批次,请先在组批次中剔除该运单");
|
||||
}
|
||||
return masterWaybill;
|
||||
}
|
||||
List<EmisTmsSiteBatch> batchList = emisTmsSiteBatchMapper.selectEmisTmsSiteBatchListByBillCodes(
|
||||
Lists.newArrayList(Collections.singleton(emisWaybillSave.getMasterBillCode())));
|
||||
if (CollectionUtil.isNotEmpty(batchList)) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "该单号已经录入批次,请先在组批次中剔除该运单");
|
||||
}
|
||||
return masterWaybill;
|
||||
}
|
||||
|
||||
public void handleVirtualForUpdate(EmisWaybill emisWaybillSave, EmisWaybill emisWaybillOld) throws EmisBizError {
|
||||
if (!StringUtils.isEmpty(emisWaybillSave.getBlVirtual()) && "1".equals(emisWaybillSave.getBlVirtual())) {
|
||||
|
||||
@ -3236,7 +3236,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
// 问题件逻辑
|
||||
if ("1".equals(emisWaybillSave.getBlVirtual())) {
|
||||
scanProblemInfo(emisWaybillSave);
|
||||
scanProblemInfo(emisWaybillSave, null);
|
||||
}
|
||||
|
||||
// 运单立即重新出账
|
||||
@ -5895,7 +5895,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
if (StringUtils.isNotEmpty(remark)) {
|
||||
String masterBillCode = extractMasterBillCode(remark);
|
||||
if (StringUtil.isBlank(masterBillCode)) {
|
||||
masterBillCode=extractMasterBillCode(waybill.getFeeRemark());
|
||||
masterBillCode = extractMasterBillCode(waybill.getFeeRemark());
|
||||
}
|
||||
if (StringUtil.isBlank(masterBillCode)) {
|
||||
failedBillCodes.add(waybill.getBillCode());
|
||||
@ -5918,30 +5918,55 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
}
|
||||
}
|
||||
|
||||
handleProblem(failedBillCodes, filterForProblemCodes, failedBills,successCount,failCount);
|
||||
// 修正:handleProblem返回统计结果
|
||||
ProblemHandleResult problemResult = handleProblem(failedBillCodes, filterForProblemCodes, failedBills,
|
||||
successCount, failCount);
|
||||
if (problemResult != null) {
|
||||
successCount = problemResult.successCount;
|
||||
failCount = problemResult.failCount;
|
||||
filterForProblemCodes = problemResult.filterForProblemCodes;
|
||||
}
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
long processTime = endTime - startTime;
|
||||
|
||||
log.debug("处理完成,总处理数:{},成功数:{},失败数:{},耗时:{}ms",
|
||||
totalProcessed, successCount, failCount, processTime);
|
||||
log.debug("处理完成,总处理数:{},成功数:{},失败数:{},耗时:{}ms", totalProcessed, successCount, failCount, processTime);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(failedBillCodes)) {
|
||||
log.debug("Failed bill codes: {}", failedBillCodes);
|
||||
log.debug("Failed bill codes ({}): {}", failedBillCodes.size(), failedBillCodes);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(filterForProblemCodes)) {
|
||||
log.debug("Failed for problemCodes: {}", filterForProblemCodes);
|
||||
log.debug("Failed for problemCodes ({}): {}", filterForProblemCodes.size(), filterForProblemCodes);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error in autoScanSiteBatch", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleProblem(List<String> failedBillCodes, List<String> filterForProblemCodes, List<EmisWaybill> failedBills, int successCount, int failCount) {
|
||||
List<EmisWaybillProblemInfo> emisWaybillProblemInfos = emisWaybillProblemInfoMapper.selectEmisWaybillProblemInfoByBillCodes(failedBillCodes);
|
||||
if(emisWaybillProblemInfos==null){
|
||||
// 新增内部类用于返回统计结果
|
||||
private static class ProblemHandleResult {
|
||||
int successCount;
|
||||
int failCount;
|
||||
List<String> filterForProblemCodes;
|
||||
|
||||
ProblemHandleResult(int successCount, int failCount, List<String> filterForProblemCodes) {
|
||||
this.successCount = successCount;
|
||||
this.failCount = failCount;
|
||||
this.filterForProblemCodes = filterForProblemCodes;
|
||||
}
|
||||
}
|
||||
|
||||
// 修改handleProblem返回统计结果
|
||||
private ProblemHandleResult handleProblem(List<String> failedBillCodes, List<String> filterForProblemCodes,
|
||||
List<EmisWaybill> failedBills, int successCount, int failCount) {
|
||||
if (CollectionUtil.isEmpty(failedBillCodes)) {
|
||||
return new ProblemHandleResult(successCount, failCount, filterForProblemCodes);
|
||||
}
|
||||
List<EmisWaybillProblemInfo> emisWaybillProblemInfos = emisWaybillProblemInfoMapper
|
||||
.selectEmisWaybillProblemInfoByBillCodes(failedBillCodes);
|
||||
if (emisWaybillProblemInfos == null) {
|
||||
log.error("emisWaybillProblemInfos is null");
|
||||
return;
|
||||
return new ProblemHandleResult(successCount, failCount, filterForProblemCodes);
|
||||
}
|
||||
for (EmisWaybillProblemInfo emisWaybillProblemInfo : emisWaybillProblemInfos) {
|
||||
try {
|
||||
@ -5955,7 +5980,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
filterForProblemCodes.add(emisWaybillProblemInfo.getBillCode());
|
||||
continue;
|
||||
}
|
||||
List<EmisWaybill> fiterBills = failedBills.stream().filter(i -> i.getBillCode().equals(emisWaybillProblemInfo.getBillCode())).collect(Collectors.toList());
|
||||
List<EmisWaybill> fiterBills = failedBills.stream()
|
||||
.filter(i -> i.getBillCode().equals(emisWaybillProblemInfo.getBillCode()))
|
||||
.collect(Collectors.toList());
|
||||
EmisWaybill waybill = new EmisWaybill();
|
||||
waybill.setMasterBillCode(masterBillCode);
|
||||
waybill.setId(fiterBills.get(0).getId());
|
||||
@ -5968,8 +5995,8 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
log.error("处理问题件失败,运单号:{},错误:{}", emisWaybillProblemInfo.getBillCode(), e.getMessage());
|
||||
filterForProblemCodes.add(emisWaybillProblemInfo.getBillCode());
|
||||
}
|
||||
|
||||
}
|
||||
return new ProblemHandleResult(successCount, failCount, filterForProblemCodes);
|
||||
}
|
||||
|
||||
private void updateWaybill(EmisWaybill virtualWaybill) {
|
||||
@ -5977,15 +6004,14 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
.selectMasterWaybillByBillCode(virtualWaybill.getMasterBillCode());
|
||||
String virtualRemark = masterWaybill.getVirtualRemark();
|
||||
String virtualBillCode = virtualWaybill.getBillCode();
|
||||
String virtualBillCodeLastSix = virtualBillCode.substring(virtualBillCode.length() - 6);
|
||||
if (StringUtil.isNotBlank(virtualRemark)) {
|
||||
Set<String> virtualBillSet = new LinkedHashSet<>();
|
||||
String[] codes = virtualRemark.split(",");
|
||||
virtualBillSet.addAll(Arrays.asList(codes));
|
||||
virtualBillSet.add(virtualBillCodeLastSix);
|
||||
virtualBillSet.add(virtualBillCode);
|
||||
virtualRemark = String.join(",", virtualBillSet);
|
||||
} else {
|
||||
virtualRemark = virtualBillCodeLastSix;
|
||||
virtualRemark = virtualBillCode;
|
||||
}
|
||||
EmisWaybill updateMasterWaybill = new EmisWaybill();
|
||||
updateMasterWaybill.setVirtualRemark(virtualRemark);
|
||||
@ -6016,7 +6042,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
}
|
||||
|
||||
// 新规则:查找主单相关关键词后的内容,直到最后一位数字为止,且不能包含汉字
|
||||
String[] keywords = {"主单为", "主单是", "主单位", "主单号", "主单","真实单号"};
|
||||
String[] keywords = { "主单为", "主单是", "主单位", "主单号", "主单", "真实单号" };
|
||||
for (String keyword : keywords) {
|
||||
int idx = remark.indexOf(keyword);
|
||||
if (idx != -1) {
|
||||
|
||||
@ -503,9 +503,9 @@
|
||||
<!--根据运单号获取运单信息 or FIND_IN_SET(#{billCode},bill_code_sub)-->
|
||||
<select id="selectMasterWaybillByBillCode" parameterType="String" resultMap="EmisWaybillResult">
|
||||
select
|
||||
id,virtual_remark FROM emis_waybill
|
||||
a.* FROM emis_waybill a
|
||||
<where>
|
||||
bill_code = #{billCode}
|
||||
a.bill_code = #{billCode}
|
||||
</where>
|
||||
limit 1
|
||||
</select>
|
||||
@ -584,6 +584,8 @@
|
||||
<if test="billCode != null and billCode != ''">
|
||||
and a.bill_code like concat('%', #{billCode}, '%')
|
||||
</if>
|
||||
and a.order_status != '0'
|
||||
and a.order_status != '2'
|
||||
<!-- <if test="params.privSiteCode != null and params.privSiteCode != '88888'">-->
|
||||
<!-- and (-->
|
||||
<!-- a.send_site_code=#{params.privSiteCode}-->
|
||||
@ -3794,8 +3796,8 @@
|
||||
from emis_waybill a
|
||||
where a.del_flag = '0' and
|
||||
a.problem_type in (173,170)
|
||||
and master_bill_code is null
|
||||
-- and a.bill_code ='7080300044761'
|
||||
and (master_bill_code is null or master_bill_code='')
|
||||
-- and a.bill_code ='T708030039025903'
|
||||
order by a.create_time desc
|
||||
limit #{offset}, #{pageSize}
|
||||
</select>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user