demand: tms-运单管理-新增批量修改运单接口-批量修复历史数据预计送达时间计算不准确的运单。
committer: heyu
This commit is contained in:
parent
5460b3b071
commit
64b2bb2ae2
@ -14,6 +14,7 @@ package com.xdadan.erp.web.emis;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
@ -34,6 +35,7 @@ import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.stat.ScanStatInfoDtl;
|
||||
import com.xdadan.erp.emis.domain.vo.*;
|
||||
import com.xdadan.erp.emis.mapper.EmisWaybillMapper;
|
||||
import com.xdadan.erp.emis.mapper.EmisWaybillProblemInfoMapper;
|
||||
import com.xdadan.erp.emis.service.*;
|
||||
import com.xdadan.erp.emis.service.print.IXddTplPrint;
|
||||
import com.xdadan.erp.emis.service.print.cpcl.CvtTplToCpcl;
|
||||
@ -105,6 +107,9 @@ public class EmisWaybillController extends EmisBaseController
|
||||
@Autowired
|
||||
private EmisWaybillMapper emisWaybillMapper;
|
||||
|
||||
@Autowired
|
||||
private EmisWaybillProblemInfoMapper emisWaybillProblemInfoMapper;
|
||||
|
||||
|
||||
@GetMapping(value = "/checkWaybillIsExists")
|
||||
public AjaxResult checkWaybillIsExists(String billCode){
|
||||
@ -1476,17 +1481,35 @@ public class EmisWaybillController extends EmisBaseController
|
||||
List<JSONObject> successList = new ArrayList<>();
|
||||
List<JSONObject> failList = new ArrayList<>();
|
||||
|
||||
// 批量查询所有运单的延迟天数
|
||||
List<String> billCodes = waybillList.stream()
|
||||
.map(EmisWaybill::getBillCode)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Map<String, Object>> delayDaysList = emisWaybillProblemInfoMapper
|
||||
.selectWaybillTotalDelayDays(billCodes);
|
||||
Map<String, Integer> billCodeToDelayDaysMap = new HashMap<>();
|
||||
|
||||
for (Map<String, Object> delayInfo : delayDaysList) {
|
||||
String billCode = (String) delayInfo.get("billCode");
|
||||
Integer totalDelayDays = ((Number) delayInfo.get("totalDelayDays")).intValue();
|
||||
billCodeToDelayDaysMap.put(billCode, totalDelayDays);
|
||||
}
|
||||
|
||||
for (EmisWaybill waybill : waybillList) {
|
||||
try {
|
||||
// 获取该运单的总延迟天数
|
||||
Integer otherAddDay = billCodeToDelayDaysMap.getOrDefault(waybill.getBillCode(), 0);
|
||||
|
||||
// 重新计算预估到达时间
|
||||
Date newEstimateDate = emisBaseService.getEstimateDate(
|
||||
waybill.getSendDate(),
|
||||
waybill.getProductType(),
|
||||
waybill.getSendCountry(),
|
||||
waybill.getReceiveCountry(),
|
||||
0);
|
||||
otherAddDay);
|
||||
|
||||
// 只更新estimateDate字段
|
||||
// 只更新estimateDate字段
|
||||
EmisWaybill updateWaybill = new EmisWaybill();
|
||||
updateWaybill.setId(waybill.getId());
|
||||
updateWaybill.setEstimateDate(newEstimateDate);
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
/**
|
||||
/**
|
||||
* @Project: emis
|
||||
* @Title: EmisWaybillProblemInfoMapper.java
|
||||
* @author linfso
|
||||
* @date 2024-03-01 08:55:01
|
||||
* @Copyright: ShangHai Doitinfo 2022 All rights reserved.
|
||||
* @version v1.0
|
||||
* @version v1.0
|
||||
* @Description: <p> 问题件 Mapper 接口 </p>
|
||||
* <span style='color:red'> Warning : This file is generate by ai tools,don't edit!!! </span>
|
||||
*/
|
||||
package com.xdadan.erp.emis.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xdadan.erp.emis.domain.EmisWaybillProblemInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -26,7 +28,7 @@ public interface EmisWaybillProblemInfoMapper extends BaseMapper<EmisWaybillProb
|
||||
/**
|
||||
* 主键查询
|
||||
* @param id
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public EmisWaybillProblemInfo selectEmisWaybillProblemInfoById(Long id);
|
||||
|
||||
@ -43,31 +45,31 @@ public interface EmisWaybillProblemInfoMapper extends BaseMapper<EmisWaybillProb
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param emisWaybillProblemInfo
|
||||
*
|
||||
* @param emisWaybillProblemInfo
|
||||
* @return 集合
|
||||
*/
|
||||
public List<EmisWaybillProblemInfo> selectEmisWaybillProblemInfoList(EmisWaybillProblemInfo emisWaybillProblemInfo);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* 新增
|
||||
*
|
||||
* @param emisWaybillProblemInfo
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public int insertEmisWaybillProblemInfo(EmisWaybillProblemInfo emisWaybillProblemInfo);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param emisWaybillProblemInfo
|
||||
* @return
|
||||
*
|
||||
* @param emisWaybillProblemInfo
|
||||
* @return
|
||||
*/
|
||||
public int updateEmisWaybillProblemInfo(EmisWaybillProblemInfo emisWaybillProblemInfo);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 结果
|
||||
*/
|
||||
@ -75,7 +77,7 @@ public interface EmisWaybillProblemInfoMapper extends BaseMapper<EmisWaybillProb
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
@ -103,4 +105,12 @@ public interface EmisWaybillProblemInfoMapper extends BaseMapper<EmisWaybillProb
|
||||
* @return
|
||||
*/
|
||||
List<EmisWaybillProblemInfo> selectEmisWaybillProblemInfoByBillCodes(@Param("billCodes") List<String> billCodes);
|
||||
|
||||
/**
|
||||
* 根据运单号列表统计每个运单的总延迟天数
|
||||
*
|
||||
* @param billCodes 运单号列表
|
||||
* @return 运单号与总延迟天数的映射
|
||||
*/
|
||||
List<Map<String, Object>> selectWaybillTotalDelayDays(@Param("billCodes") List<String> billCodes);
|
||||
}
|
||||
|
||||
@ -2707,11 +2707,27 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
|
||||
|
||||
// 查询运单的延迟天数
|
||||
Integer otherAddDay = 0;
|
||||
if (!StringUtils.isEmpty(emisWaybillSave.getBillCode())) {
|
||||
List<String> billCodes = Arrays.asList(emisWaybillSave.getBillCode());
|
||||
List<Map<String, Object>> delayDaysList = emisWaybillProblemInfoMapper
|
||||
.selectWaybillTotalDelayDays(billCodes);
|
||||
if (!delayDaysList.isEmpty()) {
|
||||
Map<String, Object> delayInfo = delayDaysList.get(0);
|
||||
otherAddDay = ((Number) delayInfo.get("totalDelayDays")).intValue();
|
||||
}
|
||||
}
|
||||
|
||||
// 开单当天不算时效
|
||||
Date estDate = getEstimateDate(
|
||||
emisWaybillSave.getSendDate(),emisWaybillSave.getProductType(),
|
||||
emisWaybillSave.getSendDate(), emisWaybillSave.getProductType(),
|
||||
emisWaybillSave.getSendCountry(),
|
||||
emisWaybillSave.getReceiveCountry(),0);
|
||||
emisWaybillSave.getReceiveCountry(), otherAddDay);
|
||||
|
||||
// 预计到达时间
|
||||
log.info("预估到达时间==>" + DateUtils.dateTime(estDate));
|
||||
emisWaybillSave.setEstimateDate(estDate);
|
||||
|
||||
// 预计到达时间
|
||||
log.info("预估到达时间==>"+ DateUtils.dateTime(estDate));
|
||||
|
||||
@ -279,4 +279,19 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 根据运单号列表统计每个运单的总延迟天数 -->
|
||||
<select id="selectWaybillTotalDelayDays" parameterType="list" resultType="map">
|
||||
SELECT
|
||||
wpi.bill_code as billCode,
|
||||
COALESCE(SUM(pt.delay_day), 0) as totalDelayDays
|
||||
FROM emis_waybill_problem_info wpi
|
||||
LEFT JOIN emis_problem_type pt ON wpi.problem_type = pt.id AND pt.del_flag = '0'
|
||||
WHERE wpi.del_flag = '0'
|
||||
AND wpi.bill_code IN
|
||||
<foreach item="billCode" collection="billCodes" open="(" separator="," close=")">
|
||||
#{billCode}
|
||||
</foreach>
|
||||
GROUP BY wpi.bill_code
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user