demand: 计算时效bug修复

committer: heyu
This commit is contained in:
aike 2025-09-05 10:17:57 +08:00
parent 44a4e4dee7
commit e2329974b0
2 changed files with 18 additions and 15 deletions

View File

@ -1460,7 +1460,7 @@ public class EmisWaybillController extends EmisBaseController
// 23:59:59未签收,且在emis_waybill_problem_info表内的所有运单信息
// 重新计算并更新预估到达时间
String beginDate = "2025-08-01 00:00:00";
String endDate = "2025-09-03 23:59:59";
String endDate = "2025-09-05 23:59:59";
// 构建查询条件
EmisWaybill queryWaybill = new EmisWaybill();

View File

@ -4104,20 +4104,22 @@ public class EmisBaseService {
/**
* 计算预估到达时间,根据产品时效来计算
* @param sendDate 开单时间
*
* @param sendDate 开单时间
* @param prodCode
* @param receiveCountry
* @param sendCountry
* @return
*/
public Date getEstimateDate(Date sendDate,String prodCode,String receiveCountry,String sendCountry,Integer otherAddDay) {
public Date getEstimateDate(Date sendDate, String prodCode, String receiveCountry, String sendCountry,
Integer otherAddDay) {
Date estDate = null;
if(otherAddDay==null){
otherAddDay=0;
if (otherAddDay == null) {
otherAddDay = 0;
}
// 发件时间+1天,从下一天的0点开始算
sendDate = DateUtils.addDays(sendDate,1);
sendDate = DateUtils.addDays(sendDate, 1);
// 初始化0点时间
Calendar calendar = Calendar.getInstance();
@ -4127,35 +4129,36 @@ public class EmisBaseService {
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date startDate=calendar.getTime();
Date startDate = calendar.getTime();
// 获取产品最大时效
EmisTransProduct emisTransProduct = getTransProductByCode(prodCode);
// 预估到达时间 startData+最大时效
Date endDate = DateUtils.addDays(startDate, emisTransProduct.getMaxAging()+otherAddDay-1);
Date endDate = DateUtils.addDays(startDate, emisTransProduct.getMaxAging() + otherAddDay - 1);
// 计算周末
int weekDays = computeWeekDays(startDate,endDate,true);
int weekDays = computeWeekDays(startDate, endDate, true);
// 计算不计较时效的时间
int notCaclDays=emisNotCalcAgingMapper.getNotCalcAgingDays(
int notCaclDays = emisNotCalcAgingMapper.getNotCalcAgingDays(
receiveCountry,
sendCountry,
startDate,
endDate);
// 1+1+ 5+0-1+2+0
int totalDays=(emisTransProduct.getMaxAging()+otherAddDay-1)+weekDays+notCaclDays;
log.info("计算预估到达时间:[maxAging="+emisTransProduct.getMaxAging()+",weekDays="+weekDays+",notCaclDays="+notCaclDays);
// 1+1+ 5+0-1+2+0
int totalDays = (emisTransProduct.getMaxAging() + otherAddDay - 1) + weekDays + notCaclDays;
log.info("计算预估到达时间:[maxAging=" + emisTransProduct.getMaxAging() + ",weekDays=" + weekDays + ",notCaclDays="
+ notCaclDays);
// 预估达到时间
Date estimateDate = DateUtils.addDays(startDate, totalDays);
// 判断预估到达时间是否为周末,如果是周末则往后加一天
// 判断预估到达时间是否为周日,如果是周日则往后加一天
Calendar cal = Calendar.getInstance();
cal.setTime(estimateDate);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) {
if (dayOfWeek == Calendar.SUNDAY) {
estimateDate = DateUtils.addDays(estimateDate, 1);
}