From 6f3931c8471cdea8aaf67d32a5e168d64089ffd2 Mon Sep 17 00:00:00 2001 From: linfso Date: Sat, 17 May 2025 11:22:41 +0800 Subject: [PATCH] md --- .../erp/emis/service/EmisBaseService.java | 85 +++++++++++++++---- .../impl/EmisTmsScanRecordServiceImpl.java | 1 + 2 files changed, 69 insertions(+), 17 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java index de8eef86e..b80a184a4 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java @@ -44,6 +44,8 @@ package com.xdadan.erp.emis.service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; + import java.text.ParseException; + import java.text.SimpleDateFormat; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.*; @@ -2338,9 +2340,9 @@ public class EmisBaseService { startDate=currentTime; } - // 开单当天不算时效 - Date newEstDate = getEstimateDate( - startDate,oldEmisWaybill.getProductType(), + // 计算延长时间 + Date newEstDate = getEstimateDateByProm( + startDate, oldEmisWaybill.getSendCountry(), oldEmisWaybill.getReceiveCountry(),emisProblemType.getDelayDay()); @@ -3774,14 +3776,14 @@ public class EmisBaseService { } - /** - * 计算预估到达时间 - * @param sendDate 开单时间 - * @param prodCode - * @param receiveCountry - * @param sendCountry - * @return - */ + /** + * 计算预估到达时间,根据产品时效来计算 + * @param sendDate 开单时间 + * @param prodCode + * @param receiveCountry + * @param sendCountry + * @return + */ public Date getEstimateDate(Date sendDate,String prodCode,String receiveCountry,String sendCountry,Integer otherAddDay) { Date estDate = null; @@ -3817,7 +3819,7 @@ public class EmisBaseService { startDate, endDate); - // 1+1+ + // 1+1+ 5+0-1+2+0 int totalDays=(emisTransProduct.getMaxAging()+otherAddDay-1)+weekDays+notCaclDays; log.info("计算预估到达时间:[maxAging="+emisTransProduct.getMaxAging()+",weekDays="+weekDays+",notCaclDays="+notCaclDays); // 预估达到时间 @@ -3825,6 +3827,53 @@ public class EmisBaseService { } + /** + * 根据问题件时间延长时效 + * @param sendDate 开单时间 + * @param receiveCountry + * @param sendCountry + * @return + */ + public Date getEstimateDateByProm(Date sendDate,String receiveCountry,String sendCountry,Integer otherAddDay) { + Date estDate = null; + + if(otherAddDay==null){ + otherAddDay=0; + } + // 发件时间+1天,从下一天的0点开始算 + sendDate = DateUtils.addDays(sendDate,1); + + // 初始化0点时间 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(sendDate); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MILLISECOND, 0); + + Date startDate=calendar.getTime(); + + // 预估到达时间 startData+最大时效 + Date endDate = DateUtils.addDays(startDate, otherAddDay-1); + + // 计算周末 + int weekDays = computeWeekDays(startDate,endDate,true); + + // 计算不计较时效的时间 + int notCaclDays=emisNotCalcAgingMapper.getNotCalcAgingDays( + receiveCountry, + sendCountry, + startDate, + endDate); + + // 1+1+ 5+0-1+2+0 + int totalDays=(otherAddDay-1)+weekDays+notCaclDays; + log.info("计算预估到达时间:[weekDays="+weekDays+",notCaclDays="+notCaclDays); + // 预估达到时间 + return DateUtils.addDays(startDate, totalDays); + + } + @@ -3995,11 +4044,13 @@ public class EmisBaseService { return copy; } - public static void main(String[] args) { -// Date startDate = new Date(); -// Date endDate = DateUtils.addDays(startDate, 10); -// int weekDays = computeWeekDays(startDate,endDate,true); -//// System.out.println("周末:"+new SimpleDateFormat("yyyy-MM-dd").format(cal1.getTime())); + public static void main(String[] args) throws ParseException { +// Date startDate = new Date("202"); + Date startDate= new SimpleDateFormat("yyyy-MM-dd").parse("2025-05-11"); + Date endDate = DateUtils.addDays(startDate, 5); + int weekDays = computeWeekDays(startDate,endDate,true); + System.out.println(weekDays); +// System.out.println("周末:"+new SimpleDateFormat("yyyy-MM-dd").format(cal1.getTime())); // // System.out.println(startDate); // System.out.println(endDate); diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsScanRecordServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsScanRecordServiceImpl.java index 6f1461fe2..59b480743 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsScanRecordServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsScanRecordServiceImpl.java @@ -2001,6 +2001,7 @@ public class EmisTmsScanRecordServiceImpl extends EmisBaseService implements IEm }else{ waybillProblemInfo.setBlSubBill("0"); } + // 登记问题件并计算延期时间 registerWaybillProblemInfo(waybillProblemInfo); if(waybillProblemInfo.getId()!=null) { emisTmsScanRecord.setRelId(waybillProblemInfo.getId().toString());