server/service/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -2995,6 +2995,21 @@ return calendar.getTime(); } /** * 获取指定日期的下个月第一天 * @param date * @return */ public static Date getNextMonthFirst(Date date){ Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.MONTH, 1); // 将日历的月份增加1 calendar.set(Calendar.DAY_OF_MONTH, 1); // 设置为下个月的第一天 return calendar.getTime(); } public static String afterDateToStr(Integer days){ Date date = new Date(); @@ -3142,38 +3157,56 @@ // System.out.println(DateUtil.calculateBetween(DateUtil.StringToDate("2024-02-29 23:59:59"),DateUtil.StringToDate("2024-02-01 00:00:00"),0)); System.out.println( DateUtil.DateToStr( // System.out.println( // DateUtil.DateToStr( // // DateUtil.getMontageDate(DateUtil.StringToDate("2024-02-29 21:59:59"),1) ,"yyyy-MM-dd HH:mm:ss" // ) // ); // // // // System.out.println( // // DateUtil.DateToStr( // // DateUtil.getMontageDate(DateUtil.StringToDate("2024-02-29 21:59:59"),2) ,"yyyy-MM-dd HH:mm:ss" // ) // // ); // // System.out.println( // // DateUtil.DateToStr( // // DateUtil.getMontageDate(DateUtil.StringToDate("2024-02-29 21:59:59"),3) ,"yyyy-MM-dd HH:mm:ss" // ) DateUtil.getMontageDate(DateUtil.StringToDate("2024-02-29 21:59:59"),1) ,"yyyy-MM-dd HH:mm:ss" ) ); System.out.println( DateUtil.DateToStr( DateUtil.getMontageDate(DateUtil.StringToDate("2024-02-29 21:59:59"),2) ,"yyyy-MM-dd HH:mm:ss" ) ); System.out.println( DateUtil.DateToStr( DateUtil.getMontageDate(DateUtil.StringToDate("2024-02-29 21:59:59"),3) ,"yyyy-MM-dd HH:mm:ss" ) ); // ); // // Calendar calo = Calendar.getInstance(); // Calendar caln = Calendar.getInstance(); // ,"yyyy-MM-dd HH:mm:ss" // caln.setTime(DateUtil.StringToDate("2024-02-29 23:59:59")); // calo.setTime(DateUtil.StringToDate("2024-02-01 00:00:00")); // System.out.println( DateUtil.calculateDaysBetweenDates(calo,caln)); System.out.println( DateUtil.DateToStr( DateUtil.getNextMonthFirst(new Date()) ,"yyyy-MM-dd HH:mm:ss") ); System.out.println( DateUtil.DateToStr( DateUtil.getNextMonthFirst( DateUtil.StringToDate("2024-12-29 21:59:59") ) ,"yyyy-MM-dd HH:mm:ss") ); } server/service/src/main/java/com/doumee/dao/business/model/ApplyChagneDetail.java
@@ -99,6 +99,11 @@ @ExcelColumn(name="原工种编码") private Integer oldWorktypeId; @ApiModelProperty(value = "单价(每日)", example = "1") private BigDecimal price; @ApiModelProperty(value = "员工名称") @TableField(exist = false) private String memberName; server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -1096,6 +1096,8 @@ if (applyChange.getValidTime().compareTo(applyDetail.getEndTime()) > 0) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】保单保障日期至:【" + applyDetail.getEndTime() + "】无法通过本次申请"); } applyChagneDetail.setPrice(applyDetail.getPrice()); applyChagneDetail.setCreateDate(new Date()); applyChagneDetail.setCreator(loginUserInfo.getId()); applyChagneDetail.setIsdeleted(Constants.ZERO); @@ -1149,6 +1151,13 @@ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + applyChagneDetail.getMemberName() + "】存在日期冲突的数据"); } ApplyDetail applyDetail = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>() .lambda() .eq(ApplyDetail::getApplyId,applyChange.getApplyId()).last("limit 1")); if(Objects.isNull(applyDetail)){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "保单中未存在明细记录"); } applyChagneDetail.setPrice(applyDetail.getPrice()); applyChagneDetail.setCreateDate(new Date()); applyChagneDetail.setCreator(loginUserInfo.getId()); applyChagneDetail.setIsdeleted(Constants.ZERO); @@ -1318,6 +1327,7 @@ && applyChagneDetail.getOldWorktypeId().equals(applyChagneDetail.getWorktypeId())){ throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "换厂人员【" + applyChagneDetail.getMemberName() + "】换厂数据相同!"); } applyChagneDetail.setPrice(applyDetail.getPrice()); applyChagneDetail.setCreateDate(new Date()); applyChagneDetail.setCreator(loginUserInfo.getId()); applyChagneDetail.setIsdeleted(Constants.ZERO); server/service/src/main/java/com/doumee/service/business/impl/DuWorktypeServiceImpl.java
@@ -7,9 +7,11 @@ import com.doumee.core.utils.Constants; import com.doumee.core.utils.Utils; import com.doumee.dao.business.DispatchUnitMapper; import com.doumee.dao.business.DuSolutionMapper; import com.doumee.dao.business.DuWorktypeMapper; import com.doumee.dao.business.WorktypeMapper; import com.doumee.dao.business.model.DispatchUnit; import com.doumee.dao.business.model.DuSolution; import com.doumee.dao.business.model.DuWorktype; import com.doumee.dao.business.model.Worktype; import com.doumee.service.business.DuWorktypeService; @@ -41,6 +43,9 @@ @Autowired private DispatchUnitMapper dispatchUnitMapper; @Autowired private DuSolutionMapper duSolutionMapper; @Override public Integer create(DuWorktype duWorktype) { duWorktypeMapper.insert(duWorktype); @@ -61,7 +66,11 @@ throw new BusinessException(ResponseStatus.DATA_EMPTY); } duWorktypeMapper.deleteById(id); if(duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>().lambda() .eq(DuWorktype::getDispatchUnitId,dispatchUnit.getId()) .eq(DuWorktype::getDuSolutionId,dbDuWorkType.getDuSolutionId()))<=0){ duSolutionMapper.deleteById(dbDuWorkType.getDuSolutionId()); } if(duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>().lambda() .eq(DuWorktype::getDispatchUnitId,dispatchUnit.getId()) .eq(DuWorktype::getStatus,Constants.ZERO) server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -1532,6 +1532,17 @@ if(!(solutions.getIsdeleted().equals(Constants.ZERO)||solutions.getStatus().equals(Constants.ZERO))){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"方案信息已被禁用"); } if(solutions.getValidType().equals(Constants.ZERO)){ if(DateUtil.getMontageDate( DateUtil.addDaysToDate(new Date(),solutions.getValidType()),0).getTime()>insuranceApply.getApplyStartTime().getTime()){ throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"保单生效起期错误"); } }else{ if(DateUtil.getNextMonthFirst(new Date()).getTime()>insuranceApply.getApplyStartTime().getTime()){ throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"保单生效起期错误"); } } List<ApplyDetail> applyDetailList = insuranceApply.getApplyDetailList(); //判断是否存在重复信息 List<String> idCardList = applyDetailList.stream().map(i->i.getIdcardNo()).collect(Collectors.toList()); @@ -2452,7 +2463,8 @@ MPJLambdaWrapper<ApplyDetail> lambdaWrapper = new MPJLambdaWrapper<ApplyDetail>(); lambdaWrapper.select(ApplyDetail::getId) .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId) .and(i->i.eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()).or().eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey())) .and(i->i.eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()) .or().eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey())) .eq(InsuranceApply::getCompanyId,loginUserInfo.getCompanyId()) .apply(" now() between t.START_TIME and t.END_TIME "); server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java
@@ -234,8 +234,9 @@ .lambda() .eq(SolutionWorktype::getSolutionId,solutions.getId()) ); if(Constants.equalsObject(solutions.getType(),Constants.ONE) ){ if(Constants.equalsObject(model.getType(),Constants.ONE) ){ if (solutions.getFanganFile()!=null && StringUtils.isNotBlank(solutions.getFanganFile().getFileurl())){ multifileMapper.update(null,new UpdateWrapper<Multifile>().lambda() .set(Multifile::getIsdeleted,Constants.ONE) .set(Multifile::getEditDate,solutions.getEditDate()) @@ -243,6 +244,7 @@ .eq(Multifile::getObjId,solutions.getId()) .eq(Multifile::getIsdeleted,Constants.ZERO) .eq(Multifile::getObjType,Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey())); Multifile file = solutions.getFanganFile(); file.setIsdeleted(Constants.ZERO); file.setCreateDate(solutions.getEditDate()); server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
@@ -32,6 +32,7 @@ import com.github.xiaoymin.knife4j.core.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -737,6 +738,7 @@ List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda() .select(ApplyDetail::getId,ApplyDetail::getApplyId,ApplyDetail::getPrice) .in(ApplyDetail::getUnionApplyId,unionApply.getId())); unionApplyBXDDTO.setEndTime(DateUtil.getMontageDate(unionApplyBXDDTO.getEndTime(),2)); //总天数 Integer maxDays = DateUtil.calculateBetween(unionApplyBXDDTO.getStartTime(),unionApplyBXDDTO.getEndTime(),0); //实际已经产生费用的天数 @@ -760,12 +762,14 @@ } BigDecimal price = Constants.formatBigdecimal(applyDetails.get(Constants.ZERO).getPrice()); Optional<UnionApplyBXDDetailDTO> unionApplyBXDDDetailTO= unionApplyBXDDetailDTOList.stream().filter( m->m.getApplyId().equals(insuranceApply.getId())).findFirst(); if(unionApplyBXDDDetailTO.isPresent()){ UnionApplyBXDDetailDTO unionApplyBXDDetailDTO = unionApplyBXDDDetailTO.get(); price = Constants.formatBigdecimal(price).add(Constants.formatBigdecimal(unionApplyBXDDetailDTO.getServerMoney())); BigDecimal dayServerMoney = unionApplyBXDDetailDTO.getServerMoney().divide(new BigDecimal(maxDays),2, RoundingMode.HALF_UP); price = Constants.formatBigdecimal(price).add(Constants.formatBigdecimal(dayServerMoney)); //上传保单信息 if(StringUtils.isNotBlank(unionApplyBXDDetailDTO.getFileUrl())){ Multifile multifile = new Multifile(); @@ -793,7 +797,8 @@ //生成投保记录 if(CollectionUtils.isNotEmpty(applyDetailList)){ List<MemberInsurance> memberInsuranceList = new ArrayList<>(); for (ApplyDetail applyDetail:applyDetailList) { for (ApplyDetail applyDetail:applyDetailList.stream() .filter(m->Constants.equalsInteger(m.getApplyId(),(insuranceApply.getId()))).collect(Collectors.toList())) { applyDetail.setPrice(price); applyDetail.setFee(price.multiply(new BigDecimal(maxDays))); MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId()); server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
@@ -1,6 +1,7 @@ package com.doumee.service.business.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.api.R; import com.doumee.biz.system.SystemDictDataBiz; import com.doumee.core.annotation.excel.ExcelExporter; import com.doumee.core.constants.ResponseStatus; @@ -154,7 +155,7 @@ .selectAs(Company::getName,UnionChange::getShopName) .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 0 )",UnionChange::getAddNum) .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 1 )",UnionChange::getDelNum) .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 2 )",UnionChange::getChangeNum).select("( select ifnull(sum(ac.FEE),0) from apply_change ac where t.id = ac.UNION_CHANGE_ID )",UnionChange::getFee) .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 2 )",UnionChange::getChangeNum) .leftJoin(UnionApply.class,UnionApply::getId,UnionChange::getUnionApplyId) .leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId) .leftJoin(Company.class,Company::getId,UnionChange::getShopId) @@ -163,6 +164,23 @@ ); if(!Objects.isNull(unionChange)){ //查询加减保明细数据 List<ApplyChagneDetail> applyChangeList = applyChagneDetailJoinMapper .selectList(new QueryWrapper<ApplyChagneDetail>() .lambda() .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO) .ne(ApplyChagneDetail::getType,Constants.TWO) .eq(ApplyChagneDetail::getUnionChangeId,unionChange.getId())); BigDecimal fee = BigDecimal.ZERO; for (ApplyChagneDetail applyChagneDetail:applyChangeList) { Integer maxDays = DateUtil.calculateBetween(unionChange.getApplyStartTime(),applyChagneDetail.getEndTime(),0); if(applyChagneDetail.getType().equals(Constants.ZERO)){ fee = fee.add(new BigDecimal(maxDays).multiply(applyChagneDetail.getPrice())); }else{ fee = fee.subtract(new BigDecimal(maxDays).multiply(applyChagneDetail.getPrice())); } } unionChange.setFee(fee); //查询操作记录 List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class, new MPJLambdaWrapper<ApplyLog>() @@ -355,7 +373,7 @@ unionChange.setShopId(user.getCompanyId()); unionChange.setIsdeleted(Constants.ZERO); unionChange.setUnionApplyId(saveUnionChangeDTO.getUnionApplyId()); unionChange.setApplyStartTime(saveUnionChangeDTO.getApplyDate()); unionChange.setApplyStartTime(DateUtil.getMontageDate(saveUnionChangeDTO.getApplyDate(),1)); unionChange.setType(saveUnionChangeDTO.getBusinessType()); unionChange.setStatus(Constants.UnionChangeStatus.MERGE.getKey()); unionChangeMapper.insert(unionChange); @@ -673,6 +691,9 @@ .set(UnionChange::getStatus,Constants.UnionChangeStatus.FINISH.getKey()) .set(UnionChange::getEditDate,new Date()) .set(UnionChange::getEditor,user.getId()) .set(UnionChange::getValidTime,unionChangeBXDDTO.getApplyDate()) .set(UnionChange::getApplyStartTime,unionChangeBXDDTO.getApplyDate()) .set(UnionChange::getCode,unionChangeBXDDTO.getCode()) .eq(UnionChange::getId,unionChangeBXDDTO.getId()) ); @@ -681,6 +702,10 @@ ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), null ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange)); applyLogMapper.insert(log); if(true){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } } @@ -690,24 +715,17 @@ BigDecimal totalFee = BigDecimal.ZERO; BigDecimal currentFee = BigDecimal.ZERO; //查询最后记录 获取对应单价 ApplyDetail applyDetail = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda().eq(ApplyDetail::getApplyId,applyChange.getApplyId()).last(" limit 1 ")); if(Objects.isNull(applyDetail)){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到保单明细数据"); } //获取单价 BigDecimal price = applyDetail.getPrice(); for (ApplyChagneDetail detail:applyChagneDetailList) { Member member = memberMapper.selectById(detail.getMemberId()); if(Objects.isNull(member)){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据"); } if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) { this.addChangeDetailData(applyChange,detail,price,currentFee,totalFee); this.addChangeDetailData(applyChange,detail,detail.getPrice(),currentFee,totalFee); }else if(Constants.equalsInteger(detail.getType(),Constants.ONE)){ this.reduceChangeDetailData(applyChange,detail,applyDetail,price,currentFee,totalFee); this.reduceChangeDetailData(applyChange,detail,currentFee,totalFee); }else{ this.otherChangeDetailData(applyChange,detail,applyDetail,price); this.otherChangeDetailData(applyChange,detail); } } @@ -752,11 +770,12 @@ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + detail.getMemberName() + "】存在日期冲突的数据"); } //总天数 Integer countDays = DateUtil.daysBetweenDates(DateUtil.getMontageDate(detail.getEndTime(), 2), applyChange.getApplyStartTime()); Integer countDays = DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(detail.getEndTime(), 2),0); //加保 ApplyDetail add = new ApplyDetail(); if(new Date().compareTo(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))>=0){ Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2), applyChange.getApplyStartTime()) + 1; Integer days = DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(new Date(), 2),0); //如果已已产生费用,计算已已产生费用 add.setCurrentFee(new BigDecimal(days).multiply(price)); }else{ @@ -776,7 +795,6 @@ add.setSex(Constants.getSexByIdCard(detail.getIdcardNo())); add.setMemberName(detail.getMemberName()); add.setDuId(detail.getDuId()); add.setStartTime(applyChange.getApplyStartTime()); add.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1)); add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2)); add.setFee(new BigDecimal(countDays).multiply(price)); @@ -803,13 +821,10 @@ * 减保数据处理 * @param applyChange * @param detail * @param applyDetail * @param price * @param currentFee * @param totalFee */ public void reduceChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,ApplyDetail applyDetail ,BigDecimal price,BigDecimal currentFee,BigDecimal totalFee){ public void reduceChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,BigDecimal currentFee,BigDecimal totalFee){ //查询员工是在主单下 是否存在生效中的数据 ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda() .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) @@ -824,15 +839,16 @@ BigDecimal pullFee = BigDecimal.ZERO; //减保减少的金额 BigDecimal reduceFee = BigDecimal.ZERO; if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2),applyChange.getApplyStartTime()) > 0) { if (DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(new Date(), 2),0) > 0) { //计算多扣金额 Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2), applyChange.getApplyStartTime()) + 1; pullFee = new BigDecimal(days).multiply(price).multiply(new BigDecimal(-1)); Integer days = DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(new Date(), 2),0); pullFee = new BigDecimal(days).multiply(detail.getPrice()).multiply(new BigDecimal(-1)); } //计算投保明细应减少的天数 Integer reduceDays = DateUtil.daysBetweenDates(DateUtil.getMontageDate(applyDetail.getEndTime(), 2), applyChange.getApplyStartTime()) + 1; Integer reduceDays = DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(oldModel.getEndTime(), 2),0); if(reduceDays>0){ reduceFee = new BigDecimal(reduceDays).multiply(price).multiply(new BigDecimal(-1)); reduceFee = new BigDecimal(reduceDays).multiply(detail.getPrice()).multiply(new BigDecimal(-1)); } applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda() .setSql(" fee = ifnull(fee,0)+" + reduceFee) @@ -862,7 +878,7 @@ ); } public void otherChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,ApplyDetail applyDetail,BigDecimal price){ public void otherChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail){ //实际批单生效日期 Date applyStartTime = DateUtil.getMontageDate(applyChange.getApplyStartTime(),1); @@ -894,8 +910,8 @@ //当前日期大于批单日期 需要回滚数据实际数据 Boolean flag = DateUtil.getMontageDate(new Date(),2).compareTo(DateUtil.getMontageDate(applyStartTime,2))>0; //换厂后历史记录的费用 fee Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(applyStartTime,3),DateUtil.getMontageDate(oldModel.getStartTime(),1))+1; BigDecimal oldFee = new BigDecimal(days).multiply(price); Integer days = DateUtil.calculateBetween(DateUtil.getMontageDate(applyStartTime,3),DateUtil.getMontageDate(oldModel.getStartTime(),1),0); BigDecimal oldFee = new BigDecimal(days).multiply(detail.getPrice()); BigDecimal fee = oldModel.getFee(); BigDecimal oldCurrentFee = oldModel.getCurrentFee(); @@ -940,7 +956,7 @@ add.setFromId(detail.getId()); applyDetailJoinMapper.insert(add); MemberInsurance memberInsurance = new MemberInsurance(applyDetail,applyChange.getId()); MemberInsurance memberInsurance = new MemberInsurance(oldModel,applyChange.getId()); memberInsurance.setSolutionId(detail.getSolutionId()); memberInsurance.setWorktypeName(detail.getWorkTypeName()); memberInsurance.setDuName(detail.getDuName());