From f054be33670be699a4c271b4d0a0167d777bbd8c Mon Sep 17 00:00:00 2001 From: linfso Date: Mon, 29 Apr 2024 00:08:11 +0800 Subject: [PATCH] md --- .../xdadan/erp/emis/domain/EmisWaybill.java | 10 +- .../emis/mapper/EmisNotCalcAgingMapper.java | 6 + .../erp/emis/service/EmisBaseService.java | 166 ++++++++++++++++++ .../service/impl/EmisWaybillServiceImpl.java | 74 +++++++- .../mapper/EmisNotCalcAgingMapper.xml | 4 + .../resources/mapper/EmisWaybillMapper.xml | 51 ++++-- 6 files changed, 285 insertions(+), 26 deletions(-) create mode 100644 emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisWaybill.java b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisWaybill.java index 364f7d9d7..51ef2523d 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisWaybill.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisWaybill.java @@ -45,9 +45,9 @@ public class EmisWaybill extends BaseEntity private String billCode; /* 子单号,逗号隔开 */ private String billCodeSub; - /* 订单状态 未接单、已转单、未指派、已指派订单、已揽收、订单取消 */ + /* 订单状态 字典 */ private String orderStatus; - /* 运单状态 已揽收 ,已发件,已到件,已派件,已签收 ,异常回退 */ + /* 运单状态 字典 */ private String waybillStatus; /* 订单类型 0-预报订单 1-正式订单 */ private String orderType; @@ -120,7 +120,7 @@ public class EmisWaybill extends BaseEntity private String sendPcd; /* 支付方式 : 现金或月结 */ private String paymentType; - /* 计费方式 01-按重量 02-按体积 03-一口价 */ + /* 计费方式 1-按重量 2-按体积 3-一口价 */ private String calcFeeType; /* 支付月结编号 */ private String custNo; @@ -317,8 +317,12 @@ public class EmisWaybill extends BaseEntity private String operateEmployeeCode; /* 是否问题件 1-是 0-否 */ private String blIsQuestion; + /* 问题件类型 */ + private String problemType; /* 问题件原因 */ private String problemCause; + /* 问题件延期天数 */ + private Integer problemDelayDays; /* 是否给寄件人发短信 */ private String blMessage; /* 是否给收件人发短信 */ diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisNotCalcAgingMapper.java b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisNotCalcAgingMapper.java index a7732d37c..fdcd1c70d 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisNotCalcAgingMapper.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisNotCalcAgingMapper.java @@ -10,9 +10,12 @@ */ package com.xdadan.erp.emis.mapper; +import java.util.Date; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xdadan.erp.emis.domain.EmisNotCalcAging; +import org.apache.ibatis.annotations.Param; + /** * @ClassName EmisNotCalcAgingMapper * @Description

不计时效维护 Mapper 接口

@@ -67,4 +70,7 @@ public interface EmisNotCalcAgingMapper extends BaseMapper * @return 结果 */ public int deleteEmisNotCalcAgingByIds(Long[] ids); + + + public int getNotCalcAgingDays(@Param("recieveCountry") String destCountry,@Param("sendCountry") String sendCountry, @Param("startDate") Date startDate, @Param("startDate") Date endDate ); } 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 new file mode 100644 index 000000000..48451c19c --- /dev/null +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java @@ -0,0 +1,166 @@ + /** + * @Project: emis + * @Title: EmisWaybillServiceImpl.java + * @author linfso + * @date 2024-02-29 08:15:14 + * @Copyright: ShangHai Duta 2022 All rights reserved. + * @version v1.0 + * @Description:

运单列表 实体类

+ */ + +package com.xdadan.erp.emis.service; + + import cn.hutool.core.collection.CollectionUtil; + import cn.hutool.core.lang.Snowflake; + import cn.hutool.core.util.IdUtil; + import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; + import com.xdadan.erp.common.utils.DateUtils; + import com.xdadan.erp.common.utils.SecurityUtils; + import com.xdadan.erp.emis.domain.*; + import com.xdadan.erp.emis.domain.vo.WaybillOrder; + import com.xdadan.erp.emis.mapper.EmisNotCalcAgingMapper; + import com.xdadan.erp.emis.mapper.EmisTransLineMapper; + import com.xdadan.erp.emis.mapper.EmisTransProductMapper; + import com.xdadan.erp.emis.mapper.EmisWaybillMapper; + import com.xdadan.erp.emis.service.IEmisWaybillAttachmentService; + import com.xdadan.erp.emis.service.IEmisWaybillCargoService; + import com.xdadan.erp.emis.service.IEmisWaybillFeeitemService; + import com.xdadan.erp.emis.service.IEmisWaybillService; + import com.xdadan.erp.emis.utils.WaybillHelper; + import lombok.extern.slf4j.Slf4j; + import org.apache.commons.lang3.StringUtils; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + import org.springframework.transaction.annotation.Transactional; + import org.springframework.util.CollectionUtils; + + import java.text.SimpleDateFormat; + import java.util.ArrayList; + import java.util.Calendar; + import java.util.Date; + import java.util.List; + + /** + * 运单列表Service业务层处理 + * + * @author linfso + * @date 2024-02-29 08:15:14 + */ +@Service +@Slf4j +public class EmisBaseService { + @Autowired + protected EmisWaybillMapper emisWaybillMapper; + + @Autowired + protected IEmisWaybillFeeitemService emisWaybillFeeitemMapper; + + @Autowired + protected IEmisWaybillCargoService emisWaybillCargoMapper; + + @Autowired + protected IEmisWaybillAttachmentService emisWaybillAttachmentMapper; + + @Autowired + protected EmisTransLineMapper emisTransLineMapper; + + @Autowired + protected EmisTransProductMapper emisTransProductMapper; + + @Autowired + private EmisNotCalcAgingMapper emisNotCalcAgingMapper; + + + public EmisTransLine getTransLineByCode(String code) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("line_code", code); + return emisTransLineMapper.selectOne(queryWrapper); + } + + public EmisTransProduct getTransProductByCode(String code) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("prod_code", code); + return emisTransProductMapper.selectOne(queryWrapper); + } + + + /** + * 计算预估到达时间 + * @param emisWaybill + * @return + */ + /** + * + * @param startDate + * @param prodCode + * @param receiveCountry + * @param sendCountry + * @return + */ + public Date getEstimateDate(Date startDate,String prodCode,String receiveCountry,String sendCountry) { + Date estDate = null; + +// EmisWaybill emisWaybill +// Date startDate = emisWaybill.getSendDate(); + // 获取产品最大时效 + EmisTransProduct emisTransProduct = getTransProductByCode(prodCode); + + // 预估到达时间 startData+最大时效 + Date endDate = DateUtils.addDays(startDate, emisTransProduct.getMaxAging()); + + // 计算周末 + int weekDays = computeWeekDays(startDate,endDate,true); + + // 计算不计较时效的时间 + int notCaclDays=emisNotCalcAgingMapper.getNotCalcAgingDays(receiveCountry,sendCountry,startDate,endDate); + + int totalDays=emisTransProduct.getMaxAging()+weekDays+notCaclDays; + log.info("计算预估到达时间:[maxAging="+emisTransProduct.getMaxAging()+",weekDays="+weekDays+",notCaclDays="+notCaclDays); + // 预估达到时间 + estDate = DateUtils.addDays(startDate, totalDays); + + return estDate; + + } + + public static int computeWeekDays(Date t1,Date t2,boolean isSingleDayoff){ + Calendar cal1 = Calendar.getInstance(); + Calendar cal2 = Calendar.getInstance(); + + cal1.setTime(t1); + cal2.setTime(t2); + + //确定一个 大日期 + if(cal1.compareTo(cal2) > 0){ + Calendar temp = cal1; + cal1 = cal2; + cal2 = temp; + temp = null; + } + int weekDays = 0; + while(cal1.compareTo(cal2)<=0){ + + if(cal1.get( + Calendar.DAY_OF_WEEK)==Calendar.SUNDAY + || ( cal1.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY && !isSingleDayoff) + ){ + weekDays++; + } + cal1.add(Calendar.DAY_OF_YEAR,1); + } + return weekDays; + } + + 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())); + + System.out.println(startDate); + System.out.println(endDate); + + System.out.println(weekDays); + } + + } \ No newline at end of file diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java index 380b519c8..ac851e89b 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java @@ -20,18 +20,19 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Singleton; import cn.hutool.core.lang.Snowflake; import cn.hutool.core.util.IdUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.xdadan.erp.common.utils.DBUtil; +import com.xdadan.erp.common.utils.DateUtils; import com.xdadan.erp.common.utils.SecurityUtils; -import com.xdadan.erp.emis.domain.EmisWaybillAttachment; -import com.xdadan.erp.emis.domain.EmisWaybillCargo; -import com.xdadan.erp.emis.domain.EmisWaybillFeeitem; +import com.xdadan.erp.emis.domain.*; import com.xdadan.erp.emis.domain.vo.*; +import com.xdadan.erp.emis.mapper.EmisTransLineMapper; import com.xdadan.erp.emis.service.*; import com.xdadan.erp.emis.utils.WaybillHelper; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.xdadan.erp.emis.domain.EmisWaybill; import com.xdadan.erp.emis.mapper.EmisWaybillMapper; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -42,8 +43,10 @@ import org.springframework.util.CollectionUtils; * @author linfso * @date 2024-02-29 08:15:14 */ + @Service -public class EmisWaybillServiceImpl implements IEmisWaybillService +@Slf4j +public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWaybillService { @Autowired private EmisWaybillMapper emisWaybillMapper; @@ -59,6 +62,9 @@ public class EmisWaybillServiceImpl implements IEmisWaybillService @Autowired private IEmisWaybillAttachmentService emisWaybillAttachmentMapper; + @Autowired + private EmisTransLineMapper emisTransLineMapper; + /** * 精准查询 查询运单列表 by billCode @@ -254,6 +260,49 @@ public class EmisWaybillServiceImpl implements IEmisWaybillService emisWaybillSave.setDispatchSiteCode(emisWaybillSave.getDispatchUnderlingSiteCode()); + emisWaybillSave.setOrderStatus("0"); + emisWaybillSave.setWaybillStatus("0"); + + emisWaybillSave.setOrderType("1"); + + // 获取泡重比 + EmisTransLine emisTransLine = getTransLineByCode(emisWaybillSave.getTransLineType()); + emisWaybillSave.setMeterType(emisTransLine.getMeterRate()); + + // 时效 + EmisTransProduct emisTransProduct = getTransProductByCode(emisWaybillSave.getProductType()); + emisWaybillSave.setTimeType(emisTransProduct.getAgingDesc()); + + if(emisWaybillSave.getSendDate()==null){ + emisWaybillSave.setSendDate(new Date()); + } + Date estDate = getEstimateDate(emisWaybillSave.getSendDate(),emisWaybillSave.getProductType(),emisWaybillSave.getSendCountry(),emisWaybillSave.getReceiveCountry()); + + // 预计到达时间 + log.info("预估到达时间==>"+ DateUtils.dateTime(estDate)); + emisWaybillSave.setEstimateDate(estDate); + + // 子单号 + if("1".equals(emisWaybillSave.getBlGenSubbill()) ){ + // 子单号拼接 + StringBuilder sb = new StringBuilder(); + for(int i=0;i + + + + + bill_code = #{billCode} + + + + + + - - - - - @@ -489,7 +495,9 @@ salesmen, operate_employee_code, bl_is_question, + problem_type, problem_cause, + problem_delay_days, bl_message, bl_accept_message, bl_gen_subbill, @@ -647,7 +655,9 @@ #{salesmen}, #{operateEmployeeCode}, #{blIsQuestion}, + #{problemType}, #{problemCause}, + #{problemDelayDays}, #{blMessage}, #{blAcceptMessage}, #{blGenSubbill}, @@ -672,7 +682,12 @@ update emis_waybill + order_sn = #{orderSn}, + cust_order_id = #{custOrderId}, + bill_code = #{billCode}, bill_code_sub = #{billCodeSub}, + order_status = #{orderStatus}, + waybill_status = #{waybillStatus}, order_type = #{orderType}, order_date = #{orderDate}, user_id = #{userId}, @@ -803,7 +818,9 @@ salesmen = #{salesmen}, operate_employee_code = #{operateEmployeeCode}, bl_is_question = #{blIsQuestion}, + problem_type = #{problemType}, problem_cause = #{problemCause}, + problem_delay_days = #{problemDelayDays}, bl_message = #{blMessage}, bl_accept_message = #{blAcceptMessage}, bl_gen_subbill = #{blGenSubbill}, @@ -827,11 +844,11 @@ - delete from emis_waybill where id = #{id} + update emis_waybill set del_flag='1' where id = #{id} - delete from emis_waybill where id in + update emis_waybill set del_flag='1 where id in #{id}