111
k94314517
2024-02-01 fc03a64522e6c6e0f47eeb82c8900e1910a0a363
111
已添加2个文件
已修改18个文件
644 ■■■■ 文件已修改
server/company/src/main/java/com/doumee/api/business/AreasController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/business/MemberInsuranceController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/business/SettleClaimsController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/common/PublicController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/common/PublicController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/Constants.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/DateUtil.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/dto/SCSupplementDTO.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/join/MemberInsuranceJoinMapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/ApplyDetail.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/Areas.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/MemberInsurance.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/SettleClaims.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/vo/AreasTree.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java 219 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/ApplyDetailServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/AreasServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java 83 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/MemberInsuranceServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/SettleClaimsServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/business/AreasController.java
@@ -7,6 +7,7 @@
import com.doumee.core.model.PageWrap;
import com.doumee.core.model.PageData;
import com.doumee.dao.business.model.Areas;
import com.doumee.dao.business.vo.AreasTree;
import com.doumee.service.business.AreasService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -74,6 +75,21 @@
        return ApiResponse.success(areasService.findPage(pageWrap));
    }
    @ApiOperation("列表查询")
    @PostMapping("/findList")
    public ApiResponse<List<Areas>> findList (@RequestBody Areas areas) {
        return ApiResponse.success(areasService.findList(areas));
    }
    @ApiOperation("区域树列表")
    @PostMapping("/findTreeList")
    public ApiResponse<List<Areas>> findTreeList () {
        List<Areas> areasList = areasService.findList(new Areas());
        AreasTree treeBuild = new AreasTree(areasList);
        areasList = treeBuild.buildTree();
        return ApiResponse.success(areasList);
    }
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @RequiresPermissions("business:areas:exportExcel")
server/company/src/main/java/com/doumee/api/business/MemberInsuranceController.java
@@ -74,6 +74,13 @@
        return ApiResponse.success(memberInsuranceService.findPage(pageWrap));
    }
    @ApiOperation("列表查询")
    @PostMapping("/findList")
    @RequiresPermissions("business:memberinsurance:query")
    public ApiResponse<List<MemberInsurance>> findList (@RequestBody MemberInsurance memberInsurance) {
        return ApiResponse.success(memberInsuranceService.findList(memberInsurance));
    }
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @RequiresPermissions("business:memberinsurance:exportExcel")
server/company/src/main/java/com/doumee/api/business/SettleClaimsController.java
@@ -102,7 +102,7 @@
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:settleclaims:query")
    public ApiResponse findById(@PathVariable Integer id) {
    public ApiResponse<SettleClaims> findById(@PathVariable Integer id) {
        return ApiResponse.success(settleClaimsService.getSettleClaimsDetail(id));
    }
    @ApiOperation("删除附件")
server/company/src/main/java/com/doumee/api/common/PublicController.java
@@ -129,6 +129,17 @@
                    String tempFileName =  nowDate + "/" + fileName;
                    String key = folder + tempFileName;// æ–‡ä»¶å
                    ALiYunUtil obs = new ALiYunUtil(endpoint,access_id, access_key);
                    int type = 2;
                    if(StringUtils.endsWith(key,".mp4")){
                        type =1;
                    }else if(StringUtils.endsWith(key,".jpg")
                            || StringUtils.endsWith(key,".JPG")
                            || StringUtils.endsWith(key,".png")
                            || StringUtils.endsWith(key,".PNG")
                            || StringUtils.endsWith(key,".jpeg")
                            || StringUtils.endsWith(key,".JPEG")){
                        type =0;
                    }
                    if (obs.uploadOnlineObject(file.getInputStream(),bucketName, key,null)) {
                        // ç§»åŠ¨æˆåŠŸ,返回文件名
                        // sendSuccessMessage(response, resourcePath+key);
@@ -139,6 +150,7 @@
                        fileJSON.put("url", resourcePath + key);
                        fileJSON.put("imgaddr", tempFileName);
                        fileJSON.put("imgname", fileName);
                        fileJSON.put("type", type);
                        fileJSON.put("originname", originname);
                        context.put("data",fileJSON);
                        context.put("message","请求成功");
server/platform/src/main/java/com/doumee/api/common/PublicController.java
@@ -176,6 +176,7 @@
                        type =1;
                    }else if(StringUtils.endsWith(key,".jpg")
                            || StringUtils.endsWith(key,".JPG")
                            || StringUtils.endsWith(key,".png")
                            || StringUtils.endsWith(key,".PNG")
                            || StringUtils.endsWith(key,".jpeg")
                            || StringUtils.endsWith(key,".JPEG")){
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -3,6 +3,7 @@
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.dao.business.model.Solutions;
import com.doumee.dao.business.vo.CountCyclePriceVO;
import io.swagger.models.auth.In;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
@@ -161,6 +162,23 @@
        return age;
    }
    public static CountCyclePriceVO countPriceVO(Date startDate, Solutions solutions){
        CountCyclePriceVO countCyclePriceVO = new CountCyclePriceVO();
        if(solutions.getInsureCycleUnit().equals(Constants.ZERO)){
            countCyclePriceVO.setEndDate(DateUtil.afterDateByType(startDate,0,solutions.getInsureCycle()));
        }else if(solutions.getInsureCycleUnit().equals(Constants.TWO)){
            Integer monthDays = DateUtil.monthDays(startDate);
            Date afterDate = DateUtil.afterDateByType(startDate,0,monthDays);
            countCyclePriceVO.setEndDate(DateUtil.afterDateByType(afterDate,0,-1));
        }else if(solutions.getInsureCycleUnit().equals(Constants.THREE)){
            Date afterDate = DateUtil.afterDateByType(startDate,2,solutions.getInsureCycle());
            countCyclePriceVO.setEndDate(DateUtil.afterDateByType(afterDate,0,-1));
        }
        countCyclePriceVO.setCyclePrice(Constants.countDetailFee(solutions,countCyclePriceVO.getEndDate(),startDate));
        return countCyclePriceVO;
    }
    public static Integer getSexByIdCard(String idCard){
        Pattern pattern = Pattern.compile("\\d{17}[\\d|x]"); // å®šä¹‰èº«ä»½è¯å·ç æ ¼å¼çš„æ­£åˆ™è¡¨è¾¾å¼
        Matcher matcher = pattern.matcher(idCard);
server/service/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -3109,19 +3109,66 @@
    }
    /**
     * æ‹¼æŽ¥æ—¥æœŸæ•°æ®
     * @param date
     * @param optType   1:每日开始 2:每日结束 3:昨日结束
     * @return
     */
    public static Date getMontageDate(Date date ,Integer optType) {
        String strShortDate = DateUtil.dateToString(date,"yyyy-MM-dd");
        if(optType.equals(1)){
            return DateUtil.StringToDate(strShortDate +" 00:00:00");
        }else if(optType.equals(2)){
            return DateUtil.StringToDate(strShortDate +" 23:59:59");
        }else if(optType.equals(3)){
            strShortDate = DateUtil.dateToString(DateUtil.getDateBetween(date,-1),"yyyy-MM-dd");
            return DateUtil.StringToDate(strShortDate +" 23:59:59");
        }else{
            return null;
        }
    }
    public static void main(String[] args) {
//       System.out.println(DateUtil.DateToStr(DateUtil.afterDateByType(
//               DateUtil.stringToDate("2024-02-01","yyyy-MM-dd")
//               ,1,1),"yyyy-MM-dd HH:mm:ss"));
        System.out.println( DateUtil.daysBetweenDates(DateUtil.stringToDate("2024-02-29","yyyy-MM-dd"),
                DateUtil.stringToDate("2024-02-01","yyyy-MM-dd"))
//        System.out.println( DateUtil.daysBetweenDates(DateUtil.stringToDate("2024-02-29","yyyy-MM-dd"),
//                DateUtil.stringToDate("2024-02-01","yyyy-MM-dd"))
//        );
//
//        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(
                DateUtil.getMontageDate(DateUtil.StringToDate("2024-02-29 21:59:59"),1) ,"yyyy-MM-dd HH:mm:ss"
                )
        );
        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(
                        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"));
server/service/src/main/java/com/doumee/dao/business/dto/SCSupplementDTO.java
@@ -20,6 +20,7 @@
    @ApiModelProperty(value = "文件路径")
    private String fileUrl;
    @ApiModelProperty(value = "文件名称")
    private String fileName;
server/service/src/main/java/com/doumee/dao/business/join/MemberInsuranceJoinMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
package com.doumee.dao.business.join;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.doumee.dao.business.model.ApplyDetail;
import com.doumee.dao.business.model.MemberInsurance;
import com.github.yulichang.base.mapper.MPJJoinMapper;
import java.util.List;
/**
 * @author æ±Ÿè¹„蹄
 * @date 2024/01/22 11:55
 */
public interface MemberInsuranceJoinMapper extends MPJJoinMapper<MemberInsurance> {
    void insertBatchSomeColumn(List<MemberInsurance> addList);
}
server/service/src/main/java/com/doumee/dao/business/model/ApplyDetail.java
@@ -110,6 +110,10 @@
    @ExcelColumn(name="保险方案",index =2)
    private String solutionName;
    @ApiModelProperty(value = "方案主键")
    @TableField(exist = false)
    private Integer solutionId;
    @ApiModelProperty(value = "批单号")
    @TableField(exist = false)
    private String validCode;
server/service/src/main/java/com/doumee/dao/business/model/Areas.java
@@ -1,5 +1,6 @@
package com.doumee.dao.business.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.doumee.core.annotation.excel.ExcelColumn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -9,6 +10,7 @@
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.List;
/**
 * çœå¸‚区信息表
@@ -71,4 +73,9 @@
    @ExcelColumn(name="排序码")
    private Integer sortnum;
    @ApiModelProperty(value = "子集数据", example = "1")
    @TableField(exist = false)
    private List<Areas> childAreasList;
}
server/service/src/main/java/com/doumee/dao/business/model/MemberInsurance.java
@@ -1,6 +1,8 @@
package com.doumee.dao.business.model;
import com.doumee.core.annotation.excel.ExcelColumn;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.utils.Constants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
@@ -20,6 +22,59 @@
@ApiModel("员工投保明细记录")
@TableName("`member_insurance`")
public class MemberInsurance {
    public MemberInsurance(){
    }
    //投保申请数据
    public MemberInsurance(ApplyDetail applyDetail, Integer sysUserId){
        this.createDate = new Date();
        this.creator = sysUserId;
        this.isdeleted = Constants.ZERO;
        this.applyId = applyDetail.getApplyId();
        this.memberId = applyDetail.getMemberId();
        this.endTime = applyDetail.getEndTime();
        this.startTime = applyDetail.getStartTime();
        this.idcardNo = applyDetail.getIdcardNo();
        this.solutionId = applyDetail.getSolutionId();
        this.duId = applyDetail.getDuId();
        this.worktypeId = applyDetail.getWorktypeId();
        this.fee = applyDetail.getFee();
        this.sex = applyDetail.getSex();
        this.bdCode = applyDetail.getApplyCode();
        this.solutionName = applyDetail.getSolutionName();
        this.worktypeName = applyDetail.getWorkTypeName();
        this.duName = applyDetail.getDuName();
//        this.relationType = Constants.ZERO;
        this.relationId = applyDetail.getId();
    }
    //加减保申请数据
    public MemberInsurance(ApplyChagneDetail applyChangeDetail, ApplyChange applyChange, Integer sysUserId,Integer applyDetailId){
        this.createDate = new Date();
        this.creator = sysUserId;
        this.isdeleted = Constants.ZERO;
        this.applyId = applyChange.getApplyId();
        this.memberId = applyChangeDetail.getMemberId();
        this.endTime = applyChangeDetail.getEndTime();
        this.startTime = applyChangeDetail.getStartTime();
        this.idcardNo = applyChangeDetail.getIdcardNo();
        this.duId = applyChangeDetail.getDuId();
        this.worktypeId = applyChangeDetail.getWorktypeId();
        this.fee = applyChangeDetail.getFee();
        this.sex = applyChangeDetail.getSex();
        this.bdCode = applyChange.getApplyCode();
        this.pdCode = applyChange.getCode();
        this.solutionName = applyChange.getSolutionsName();
        this.worktypeName = applyChangeDetail.getWorkTypeName();
        this.duName = applyChangeDetail.getDuName();
//        this.relationType = Constants.ONE;
        this.relationId = applyDetailId;
    }
    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "主键", example = "1")
@@ -66,16 +121,21 @@
    @ApiModelProperty(value = "实际保险生效止期")
    @ExcelColumn(name="实际保险生效止期")
    private String endTime;
    private Date endTime;
    @ApiModelProperty(value = "实际保险生效起期")
    @ExcelColumn(name="实际保险生效起期")
    private String startTime;
    private Date startTime;
    @ApiModelProperty(value = "最近操作时间")
    @ExcelColumn(name="最近操作时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date idcardNo;
    @ApiModelProperty(value = "身份证号码")
    @ExcelColumn(name="身份证号码")
    private String idcardNo;
    @ApiModelProperty(value = "方案主键", example = "1")
    @ExcelColumn(name="方案主键")
    private Integer solutionId;
    @ApiModelProperty(value = "派遣单位编码(关联dispatch_unit)", example = "1")
    @ExcelColumn(name="派遣单位编码(关联dispatch_unit)")
@@ -121,4 +181,12 @@
    @ExcelColumn(name="派遣单位名称")
    private String duName;
    @ApiModelProperty(value = "关联明细主键", example = "1")
    @ExcelColumn(name="关联明细主键")
    private Integer relationId;
//    @ApiModelProperty(value = "关联明细类型:0=投保申请;1=加减保/换厂", example = "1")
//    @ExcelColumn(name="关联明细类型:0=投保申请;1=加减保/换厂")
//    private Integer relationType;
}
server/service/src/main/java/com/doumee/dao/business/model/SettleClaims.java
@@ -152,7 +152,7 @@
    @ApiModelProperty(value = "出险地区(关联areas)", example = "1")
    @ExcelColumn(name="出险地区(关联areas)")
    private Integer areaId;
    private String areaId;
    @ApiModelProperty(value = "出险地区名称(省市)")
    @ExcelColumn(name="出险地区名称(省市)")
@@ -222,7 +222,7 @@
    @ApiModelProperty(value = "保险生效起期")
    @TableField(exist = false)
    private Date baoxianStartTime;
    @ApiModelProperty(value = "保险生效起期")
    @ApiModelProperty(value = "保险生效止期")
    @TableField(exist = false)
    private Date baoxianEndTime;
server/service/src/main/java/com/doumee/dao/business/vo/AreasTree.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,90 @@
package com.doumee.dao.business.vo;
import com.dingtalk.api.response.OapiNewretailQueryorginfoResponse;
import com.doumee.core.utils.Constants;
import com.doumee.dao.business.model.Areas;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Rk
 * @create 2023/7/13 10:40
 */
public class AreasTree {
    // ä¿å­˜å‚与构建树形的所有数据(通常数据库查询结果)
    public List<Areas> nodeList = new ArrayList<>();
    /**
     *  æž„造方法
     *  @param nodeList å°†æ•°æ®é›†åˆèµ‹å€¼ç»™nodeList,即所有数据作为所有节点。
     */
    public AreasTree(List<Areas> nodeList){
        this.nodeList = nodeList;
    }
    /**
     *   èŽ·å–éœ€æž„å»ºçš„æ‰€æœ‰æ ¹èŠ‚ç‚¹ï¼ˆé¡¶çº§èŠ‚ç‚¹ï¼‰ "0"
     *   @return æ‰€æœ‰æ ¹èŠ‚ç‚¹List集合
     */
    public List<Areas> getRootNode(){
        // ä¿å­˜æ‰€æœ‰æ ¹èŠ‚ç‚¹ï¼ˆæ‰€æœ‰æ ¹èŠ‚ç‚¹çš„æ•°æ®ï¼‰
        List<Areas> rootNodeList = new ArrayList<>();
        // treeNode:查询出的每一条数据(节点)
        for (Areas treeNode : nodeList){
            // åˆ¤æ–­å½“前节点是否为根节点,此处注意:若parentId类型是String,则要采用equals()方法判断。
            if (treeNode.getType().equals(Constants.ZERO)) {
                rootNodeList.add(treeNode);
            }
        }
        return rootNodeList;
    }
    /**
     *  æ ¹æ®æ¯ä¸€ä¸ªé¡¶çº§èŠ‚ç‚¹ï¼ˆæ ¹èŠ‚ç‚¹ï¼‰è¿›è¡Œæž„å»ºæ ‘å½¢ç»“æž„
     *  @return  æž„建整棵树
     */
    public List<Areas> buildTree(){
        // treeNodes:保存一个顶级节点所构建出来的完整树形
        List<Areas> treeNodes = new ArrayList<Areas>();
        // getRootNode():获取所有的根节点
        for (Areas treeRootNode : getRootNode()) {
            // å°†é¡¶çº§èŠ‚ç‚¹è¿›è¡Œæž„å»ºå­æ ‘
            treeRootNode = buildChildTree(treeRootNode);
            // å®Œæˆä¸€ä¸ªé¡¶çº§èŠ‚ç‚¹æ‰€æž„å»ºçš„æ ‘å½¢ï¼Œå¢žåŠ è¿›æ¥
            treeNodes.add(treeRootNode);
        }
        return treeNodes;
    }
    /**
     *  é€’å½’-----构建子树形结构
     *  @param  pNode æ ¹èŠ‚ç‚¹ï¼ˆé¡¶çº§èŠ‚ç‚¹ï¼‰
     *  @return æ•´æ£µæ ‘
     */
    public Areas buildChildTree(Areas pNode){
        List<Areas> childTree = new ArrayList<Areas>();
        // nodeList:所有节点集合(所有数据)
        for (Areas treeNode : nodeList) {
            // åˆ¤æ–­å½“前节点的父节点ID是否等于根节点的ID,即当前节点为其下的子节点
            if (!Objects.isNull(treeNode.getParentId())&&treeNode.getParentId().equals(pNode.getId())) {
                // å†é€’归进行判断当前节点的情况,调用自身方法
                childTree.add(buildChildTree(treeNode));
            }
        }
        // for循环结束,即节点下没有任何节点,树形构建结束,设置树结果
        pNode.setChildAreasList(childTree);
        return pNode;
    }
}
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -37,6 +37,11 @@
import java.math.BigDecimal;
import java.util.*;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -72,6 +77,9 @@
    @Autowired
    private ApplyDetailJoinMapper applyDetailJoinMapper;
    @Autowired
    private MemberInsuranceJoinMapper memberInsuranceJoinMapper;
    @Autowired
    private MemberMapper memberMapper;
@@ -195,6 +203,7 @@
        ApplyLog log = new ApplyLog(update,applyLogType.getName(), info,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return  1;
    }
@@ -263,9 +272,14 @@
                        .selectAll(ApplyChagneDetail.class)
                        .selectAs(Solutions::getTimeUnit,ApplyChagneDetail::getSolutionTimeUnit)
                        .selectAs(Solutions::getPrice,ApplyChagneDetail::getSolutionPrice)
                        .selectAs(Worktype::getName,ApplyChagneDetail::getWorkTypeName)
                        .selectAs(DispatchUnit::getName,ApplyChagneDetail::getDuName)
                  .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId)
                  .leftJoin(InsuranceApply.class, InsuranceApply::getId, ApplyChange::getApplyId)
                  .leftJoin(Solutions.class, Solutions::getId, InsuranceApply::getSolutionId)
                  .leftJoin(Solutions.class, Solutions::getId, ApplyChange::getSolutionsId)
                    .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getWorktypeId)
                    .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyChagneDetail::getDuId)
                  .eq(ApplyChagneDetail::getApplyChangeId,update.getId())
                  .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO) );
        if(detailList ==null || detailList.size()==0){
@@ -281,14 +295,53 @@
            if(oldModel == null  ){
                throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,用户【"+detail.getMemberName()+"】原保单信息有误,当前申请不支持减保处理!");
            }
            Date endDate = oldModel.getEndTime();
            //当前日期大于批单日期 éœ€è¦å›žæ»šæ•°æ®å®žé™…数据
            Boolean flag = DateUtil.getMontageDate(new Date(),2).compareTo(DateUtil.getMontageDate(update.getStartTime(),2))>0;
            //换厂后历史记录的费用 fee
            Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(update.getStartTime(),2),DateUtil.getMontageDate(oldModel.getStartTime(),1)) + 1;
            BigDecimal oldFee = this.getApplyPrice(update.getApplyId(),days);
            BigDecimal fee = oldModel.getFee();
            BigDecimal oldCurrentFee = oldModel.getCurrentFee();
            applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                    .set(ApplyDetail::getEditor,update.getEditor())
                    .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
                    .set(ApplyDetail::getDuId,detail.getDuId())
                    .set(ApplyDetail::getEditDate,update.getEditDate())
                    .set(ApplyDetail::getEndTime,DateUtil.getMontageDate(update.getStartTime(),2))
                    .set(ApplyDetail::getFee,oldFee)
                    .set(flag,ApplyDetail::getCurrentFee,oldFee)
                    .eq(ApplyDetail::getId,oldModel.getApplyId())
            );
            //修改 å‘˜å·¥æŠ•保明细记录 åŽ†å²æ•°æ®
            memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
                    .set(MemberInsurance::getEndTime,update.getApplyStartTime())
                            .set(MemberInsurance::getFee,oldFee)
                    .eq(MemberInsurance::getRelationId,oldModel.getId())
            );
            ApplyDetail applyDetail = new ApplyDetail();
            applyDetail.setApplyId(oldModel.getApplyId());
            applyDetail.setCreateDate(new Date());
            applyDetail.setCreator(update.getEditor());
            applyDetail.setMemberId(oldModel.getMemberId());
            applyDetail.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(),1));
            applyDetail.setEndTime(endDate);
            applyDetail.setDuId(detail.getDuId());
            applyDetail.setWorktypeId(detail.getWorktypeId());
            applyDetail.setIdcardNo(oldModel.getIdcardNo());
            applyDetail.setFee(fee.subtract(oldFee));
            if(flag){
                applyDetail.setCurrentFee(oldCurrentFee.multiply(oldFee));
            }else{
                applyDetail.setCurrentFee(BigDecimal.ZERO);
            }
            applyDetail.setSex(oldModel.getSex());
            applyDetail.setMemberName(oldModel.getMemberName());
            applyDetail.setFromId(detail.getId());
            applyDetailJoinMapper.insert(applyDetail);
            MemberInsurance memberInsurance = new MemberInsurance(applyDetail,update.getId());
            memberInsuranceJoinMapper.insert(memberInsurance);
        }
    }
    /**
@@ -301,9 +354,14 @@
                        .selectAll(ApplyChagneDetail.class)
                        .selectAs(Solutions::getTimeUnit,ApplyChagneDetail::getSolutionTimeUnit)
                        .selectAs(Solutions::getPrice,ApplyChagneDetail::getSolutionPrice)
                        .selectAs(Worktype::getName, ApplyChagneDetail::getWorkTypeName)
                        .selectAs(DispatchUnit::getName, ApplyChagneDetail::getDuName)
                  .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId)
                  .leftJoin(InsuranceApply.class, InsuranceApply::getId, ApplyChange::getApplyId)
                  .leftJoin(Solutions.class, Solutions::getId, InsuranceApply::getSolutionId)
                        .leftJoin(Solutions.class, Solutions::getId, ApplyChange::getSolutionsId)
                        .leftJoin(Worktype.class, Worktype::getId, ApplyChagneDetail::getWorktypeId)
                        .leftJoin(DispatchUnit.class, DispatchUnit::getId, ApplyChagneDetail::getDuId)
                  .eq(ApplyChagneDetail::getApplyChangeId,update.getId())
                  .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO) );
        if(detailList ==null || detailList.size()==0){
@@ -313,6 +371,25 @@
        List<Integer> reduceMembers = new ArrayList<>();
        BigDecimal totalFee = new BigDecimal(0);
        BigDecimal currentFee = new BigDecimal(0);
        //投保记录 åŠ ä¿æ•°æ®åŠ å…¥æ–°æ•°æ®  å‡ä¿æ•°æ® ä¿®æ”¹è€æ•°æ®
        List<MemberInsurance> memberInsuranceList = new ArrayList<>();
        //加保业务 ä½¿ç”¨çš„加保金额
        ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_add = new ApplyChangeCyclePriceDTO();
        applyChangeCyclePriceDTO_add.setApplyId(update.getApplyId());
        applyChangeCyclePriceDTO_add.setValidTime(DateUtil.getMontageDate(update.getStartTime(), 1));
        //加保 æ·»åŠ çš„é‡‘é¢
        CountCyclePriceVO countCyclePriceVO_add = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_add);
        //减保业务 ä½¿ç”¨çš„减保金额
        ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_reduce = new ApplyChangeCyclePriceDTO();
        applyChangeCyclePriceDTO_reduce.setApplyId(update.getApplyId());
        applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(update.getStartTime(), 3));
        //减保 éœ€è¦å‡å°‘的金额
        CountCyclePriceVO countCyclePriceVO_reduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
        for(ApplyChagneDetail detail : detailList){
            if(Constants.equalsInteger(detail.getType(),Constants.ZERO)){
@@ -333,12 +410,22 @@
                add.setFee(new BigDecimal(0));
//                add.setFee(Constants.countDetailFee(detail.getSolutionTimeUnit(),detail.getSolutionPrice(), add.getStartTime(),add.getEndTime()));
                if(DateUtil.daysBetweenDates(add.getStartTime(),new Date() )>=0){
                    add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
                    add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
                    add.setFee(countCyclePriceVO_add.getCyclePrice());
                    if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(add.getStartTime(), 2), new Date()) >= 0) {
                        Integer days = DateUtil.daysBetweenDates(new Date(), DateUtil.getMontageDate(add.getStartTime(), 2)) + 1;
                    //如果已产生费用,计算已产生费用
                    add.setCurrentFee(Constants.countDetailFee(detail.getSolutionTimeUnit(),detail.getSolutionPrice(), add.getStartTime(),new Date()));
                        add.setCurrentFee(this.getApplyPrice(update.getApplyId(), days));
                }
                addList.add(add);
//                addList.add(add);
                    applyDetailJoinMapper.insert(add);
                totalFee.add(add.getFee());
                currentFee.add(add.getCurrentFee());
                    MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId());
                    memberInsuranceList.add(memberInsurance);
            }else{
                //减保操作
                //查询员工是在主单下 æ˜¯å¦å­˜åœ¨ç”Ÿæ•ˆä¸­çš„æ•°æ®
@@ -350,15 +437,26 @@
                if(oldModel == null || oldModel.getStartTime()==null || oldModel.getStartTime().getTime() > update.getApplyStartTime().getTime()){
                    throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,用户【"+detail.getMemberName()+"】原保单信息有误,当前申请不支持减保处理!");
                }
                BigDecimal updateFee = (Constants.countDetailFee(detail.getSolutionTimeUnit(),detail.getSolutionPrice(), oldModel.getStartTime(),update.getApplyStartTime()));
                BigDecimal updateCurrentFee = new BigDecimal(0);
                    //退保需要退回的费用
                    BigDecimal updateFee = countCyclePriceVO_reduce.getCyclePrice().multiply(new BigDecimal(-1));
                    BigDecimal updateCurrentFee = oldModel.getFee().subtract(updateFee);
//                BigDecimal updateCurrentFee = new BigDecimal(0);
//                if(DateUtil.daysBetweenDates(update.getApplyStartTime(),new Date() )>0){
//                    //如果生效时间 æ˜¯ä»Šå¤©ä¹‹å‰ï¼Œé€€å›žå·²äº§ç”Ÿè´¹ç”¨ï¼Œè®¡ç®—已产生费用(总费用-已产生费用)
//                    updateCurrentFee = updateFee.subtract(oldModel.getCurrentFee());
//                }
//                    BigDecimal updateFee = (Constants.countDetailFee(detail.getSolutionTimeUnit(), detail.getSolutionPrice(), oldModel.getStartTime(), update.getApplyStartTime()));
//                    BigDecimal updateCurrentFee = new BigDecimal(0);
                if(DateUtil.daysBetweenDates(update.getApplyStartTime(),new Date() )>0){
                    //如果生效时间 æ˜¯ä»Šå¤©ä¹‹å‰ï¼Œé€€å›žå·²äº§ç”Ÿè´¹ç”¨ï¼Œè®¡ç®—已产生费用(总费用-已产生费用)
                    updateCurrentFee = updateFee.subtract(Constants.formatBigdecimal(oldModel.getCurrentFee()));
                }
                applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                        .setSql(" fee = ifnull(fee,0)+"+updateFee)
                        .setSql(" current_fee = "+updateFee)
                            .setSql(" current_fee = " + updateCurrentFee)
                            .set(ApplyDetail::getEndTime, update.getApplyStartTime())
                        .set(ApplyDetail::getEditor,update.getEditor())
                        .set(ApplyDetail::getEditDate,update.getEditDate())
                        .eq(ApplyDetail::getId,oldModel.getApplyId())
@@ -366,10 +464,19 @@
                totalFee.add(updateFee);
                currentFee.add(updateCurrentFee);
                    //修改 å‘˜å·¥æŠ•保明细记录 åŽ†å²æ•°æ®
                    memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
                            .setSql(" fee = ifnull(fee,0)+" + updateFee)
                            .set(MemberInsurance::getEndTime, update.getApplyStartTime())
                            .eq(MemberInsurance::getRelationId, oldModel.getId())
                    );
            }
        }
        if(addList!=null && addList.size()>0){
            applyDetailJoinMapper.insertBatchSomeColumn(addList);
            if (memberInsuranceList != null && memberInsuranceList.size() > 0) {
//            applyDetailJoinMapper.insertBatchSomeColumn(addList);
                memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
        }
        if(totalFee.compareTo(new BigDecimal(0)) != 0){
            //如果保单金额发生编码,更新总保单金额
@@ -383,6 +490,7 @@
        }
        }
    }
    /**
@@ -565,11 +673,13 @@
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
        }
        applyChange.setEditDate(new Date());
        applyChange.setEditor(loginUserInfo.getId());
        applyChange.setStatus(Constants.ZERO);
        BigDecimal fee = BigDecimal.ZERO;
        //删除历史数据
        applyChagneDetailJoinMapper.delete(new QueryWrapper<ApplyChagneDetail>().lambda().eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
        this.dealApplyChangeData(applyChange,insuranceApply,companySolution,solutions,loginUserInfo,fee);
        applyChange.setFee(fee);
        applyChangeMapper.updateById(applyChange);
@@ -605,13 +715,20 @@
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "数据异常:保险方案下未查询到工种信息");
        }
        ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO = new ApplyChangeCyclePriceDTO();
        applyChangeCyclePriceDTO.setApplyId(insuranceApply.getId());
        //加保数据
        List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList();
        if (CollectionUtils.isNotEmpty(addDetailList)) {
            if(companySolution.getCanAdd().equals(Constants.ZERO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该企业分配保险方案无法进行加保");
            }
            this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo);
            //加保明细数据 è®¡ç®—金额  æ ¹æ®æ‰¹å•æ—¶é—´ è®¡ç®—
            applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(insuranceApply.getStartTime(),1));
            CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
            BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
            this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo,detailFee);
            fee = addDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add);
        }
@@ -622,7 +739,11 @@
            if(companySolution.getCanReduce().equals(Constants.ZERO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该企业分配保险方案无法进行减保");
            }
            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo);
            //减保明细数据 è®¡ç®—金额  æ ¹æ®æ‰¹å•æ—¶é—´ å‰ä¸€å¤© è®¡ç®—
            applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(insuranceApply.getStartTime(),3));
            CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
            BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo,detailFee);
            fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
        }
@@ -663,7 +784,7 @@
     * @param delDetailList
     * @param loginUserInfo
     */
    public void delChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> delDetailList,InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo){
    public void delChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> delDetailList,InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal detailFee){
        for (ApplyChagneDetail applyChagneDetail : delDetailList) {
            if (Objects.isNull(applyChagneDetail.getMemberId())) {
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失");
@@ -699,17 +820,10 @@
            applyChagneDetail.setApplyChangeId(applyChange.getId());
            applyChagneDetail.setType(Constants.ONE);
            System.out.println(DateUtil.dateToString(applyDetail.getEndTime(),"yyyy-MM-dd"));
            System.out.println(DateUtil.dateToString(applyDetail.getStartTime(),"yyyy-MM-dd"));
            System.out.println(DateUtil.dateToString(applyChange.getValidTime(),"yyyy-MM-dd"));
            applyChagneDetail.setStartTime(DateUtil.getMontageDate(applyDetail.getStartTime(),1));
            applyChagneDetail.setEndTime(DateUtil.getMontageDate(applyChange.getStartTime(),3));
            BigDecimal sumFee = Constants.countDetailFee(solutions, applyDetail.getEndTime(),applyDetail.getStartTime());
            BigDecimal useFee = Constants.countDetailFee(solutions, applyChange.getValidTime(),applyDetail.getStartTime());
            applyChagneDetail.setFee(
                    Constants.countDetailFee(solutions, applyDetail.getEndTime(),applyDetail.getStartTime())
                            .subtract(Constants.countDetailFee(solutions,applyChange.getValidTime(), applyDetail.getStartTime())).multiply(new BigDecimal(-1))
            );
            applyChagneDetail.setFee( detailFee.multiply(new BigDecimal(-1)));
            applyChagneDetailJoinMapper.insert(applyChagneDetail);
        }
    }
@@ -724,7 +838,7 @@
     * @param duSolutionList
     * @param loginUserInfo
     */
    public void addChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> addDetailList,List<DuWorktype> duWorktypeList,List<DuSolution> duSolutionList,InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo){
    public void addChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> addDetailList,List<DuWorktype> duWorktypeList,List<DuSolution> duSolutionList,InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal detailFee){
        for (ApplyChagneDetail applyChagneDetail : addDetailList) {
            if (    Objects.isNull(applyChagneDetail.getDuId())
                    || Objects.isNull(applyChagneDetail.getWorktypeId())
@@ -732,7 +846,6 @@
            ) {
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失");
            }
            Member member = new Member();
            if(Objects.isNull(applyChagneDetail.getMemberId())){
@@ -805,10 +918,10 @@
            applyChagneDetail.setCreator(loginUserInfo.getId());
            applyChagneDetail.setIsdeleted(Constants.ZERO);
            applyChagneDetail.setApplyChangeId(applyChange.getId());
            applyChagneDetail.setStartTime(DateUtil.getMontageDate(applyChange.getStartTime(),1));
            applyChagneDetail.setEndTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2));
            applyChagneDetail.setType(Constants.ZERO);
            applyChagneDetail.setFee(
                    Constants.countDetailFee(solutions,insuranceApply.getEndTime(),applyChange.getValidTime())
            );
            applyChagneDetail.setFee(detailFee);
            applyChagneDetailJoinMapper.insert(applyChagneDetail);
        }
    }
@@ -1328,6 +1441,11 @@
    }
    /**
     * åŠ å‡ä¿ç”³è¯·æ—¶ æŸ¥è¯¢åŠ å‡é‡‘é¢
     * @param applyChangeCyclePriceDTO
     * @return
     */
    @Override
    public CountCyclePriceVO getChangeCountCyclePriceVO(ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO){
        if(Objects.isNull(applyChangeCyclePriceDTO)
@@ -1335,7 +1453,6 @@
            || Objects.isNull(applyChangeCyclePriceDTO.getValidTime())){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChangeCyclePriceDTO.getApplyId());
        if(Objects.isNull(insuranceApply)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保单");
@@ -1344,13 +1461,47 @@
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        CountCyclePriceVO countCyclePriceVO = new CountCyclePriceVO();
        countCyclePriceVO.setCyclePrice(Constants.countDetailFee(solutions,insuranceApply.getEndTime(),applyChangeCyclePriceDTO.getValidTime()));
        return countCyclePriceVO;
        //根据批单日期 å’Œ ç»“束日期 è®¡ç®—金额
        //验证批单日期是否在当前日期后 ä¸” åœ¨ä¿å•结束日期前 ç”³è¯·æ—¶é—´å¿…须处于保单的时间范围内
        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChangeCyclePriceDTO.getValidTime()) >= Constants.ZERO
                && DateUtil.compareDate( applyChangeCyclePriceDTO.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
        }
        //总天数
        Integer sumDays = DateUtil.daysBetweenDates(insuranceApply.getEndTime(),insuranceApply.getStartTime()) + 1;
        //加减保 åˆ°ç»“束的天数
        Integer optDays = DateUtil.daysBetweenDates(insuranceApply.getEndTime(),applyChangeCyclePriceDTO.getValidTime()) + 1;
        CountCyclePriceVO countCyclePriceVO = Constants.countPriceVO(insuranceApply.getStartTime(),solutions);
        //总金额
        BigDecimal sumPrice = countCyclePriceVO.getCyclePrice();
        CountCyclePriceVO returnCountCyclePriceVO = new CountCyclePriceVO();
        //加减保金额
        returnCountCyclePriceVO.setCyclePrice(sumPrice.divide(new BigDecimal(sumDays),2, RoundingMode.HALF_UP).multiply(new BigDecimal(optDays)));
        return returnCountCyclePriceVO;
    }
    /**
     * è®¡ç®—保单下  X天 å¤šå°‘费用
     * @param applyId
     * @param optDays
     * @return
     */
    public BigDecimal getApplyPrice(Integer applyId,Integer optDays){
        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyId);
        if(Objects.isNull(insuranceApply)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保单");
        }
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        //总天数
        Integer sumDays = DateUtil.daysBetweenDates(insuranceApply.getEndTime(),insuranceApply.getStartTime()) + 1;
        CountCyclePriceVO countCyclePriceVO = Constants.countPriceVO(insuranceApply.getStartTime(),solutions);
        //总金额
        BigDecimal sumPrice = countCyclePriceVO.getCyclePrice();;
        return sumPrice.divide(new BigDecimal(sumDays),2, RoundingMode.HALF_UP).multiply(new BigDecimal(optDays));
    }
}
server/service/src/main/java/com/doumee/service/business/impl/ApplyDetailServiceImpl.java
@@ -250,6 +250,7 @@
        queryWrapper.selectAll(ApplyDetail.class);
        queryWrapper.selectAs(DispatchUnit::getName,ApplyDetail::getDuName);
        queryWrapper.selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode);
        queryWrapper.selectAs(Solutions::getId,ApplyDetail::getSolutionId);
        queryWrapper.selectAs(Solutions::getName,ApplyDetail::getSolutionName);
        queryWrapper.selectAs(Worktype::getName,ApplyDetail::getWorkTypeName);
        queryWrapper.selectAs(Member::getIdcardNo,ApplyDetail::getIdcardNo);
server/service/src/main/java/com/doumee/service/business/impl/AreasServiceImpl.java
@@ -81,6 +81,7 @@
    @Override
    public List<Areas> findList(Areas areas) {
        QueryWrapper<Areas> wrapper = new QueryWrapper<>(areas);
        wrapper.select("id , name , code , type , parent_id");
        return areasMapper.selectList(wrapper);
    }
  
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -15,10 +15,7 @@
import com.doumee.dao.business.dto.CountCyclePriceDTO;
import com.doumee.dao.business.dto.InsuranceApplyOptDTO;
import com.doumee.dao.business.dto.InsuranceApplyQueryDTO;
import com.doumee.dao.business.join.ApplyDetailJoinMapper;
import com.doumee.dao.business.join.ApplyLogJoinMapper;
import com.doumee.dao.business.join.DuSolutionJoinMapper;
import com.doumee.dao.business.join.InsuranceApplyJoinMapper;
import com.doumee.dao.business.join.*;
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.CountCyclePriceVO;
import com.doumee.dao.system.model.SystemUser;
@@ -64,6 +61,8 @@
    private InsuranceApplyJoinMapper insuranceApplyJoinMapper;
    @Autowired
    private CompanyMapper companyMapper;
    @Autowired
    private MemberInsuranceJoinMapper memberInsuranceJoinMapper;
    @Autowired
    private ApplyDetailMapper applyDetailMapper;
@@ -182,6 +181,36 @@
        }
        ApplyLog log = new ApplyLog(update,applyLogType.getName(), info,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        //存储员工信息投保记录
        //查询单据明细记录
        MPJLambdaWrapper<ApplyDetail> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(ApplyDetail.class);
        queryWrapper.selectAs(DispatchUnit::getName,ApplyDetail::getDuName);
        queryWrapper.selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode);
        queryWrapper.selectAs(Solutions::getId,ApplyDetail::getSolutionId);
        queryWrapper.selectAs(Solutions::getName,ApplyDetail::getSolutionName);
        queryWrapper.selectAs(Worktype::getName,ApplyDetail::getWorkTypeName);
        queryWrapper.selectAs(Member::getIdcardNo,ApplyDetail::getIdcardNo);
        queryWrapper.selectAs(Member::getName,ApplyDetail::getMemberName);
        queryWrapper.leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyDetail::getDuId);
        queryWrapper.leftJoin(Worktype.class,Worktype::getId,ApplyDetail::getWorktypeId);
        queryWrapper.leftJoin(Member.class,Member::getId,ApplyDetail::getMemberId);
        queryWrapper.leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId);
        queryWrapper.leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId);
        queryWrapper.eq(ApplyDetail::getApplyId,insuranceApply.getId());
        List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,queryWrapper);
        if(CollectionUtils.isNotEmpty(applyDetailList)){
            List<MemberInsurance> memberInsuranceList = new ArrayList<>();
            for (ApplyDetail applyDetail:applyDetailList) {
                MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId());
                memberInsuranceList.add(memberInsurance);
            }
            memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
        }
        return  1;
    }
@@ -599,6 +628,7 @@
        info = info.replace("${param}", update.getCheckInfo());
        ApplyLog log = new ApplyLog(update,applyLogType.getName(),info,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return  1;
    }
@@ -633,14 +663,22 @@
        insuranceApply.setCompanyId(loginUserInfo.getCompanyId());
        insuranceApply.setCheckInfo(insuranceApplyStatus.getName());
        insuranceApply.setStartTime(insuranceApply.getApplyStartTime());
        insuranceApply.setEndTime(insuranceApply.getApplyEndTime());
        insuranceApply.setCheckDate(new Date());
        insuranceApply.setCurrentFee(BigDecimal.ZERO);
        insuranceApply.setCheckUserId(loginUserInfo.getId());
        insuranceApply.setStatus(insuranceApplyStatus.getKey());
        CountCyclePriceDTO countCyclePriceDTO = new CountCyclePriceDTO();
        countCyclePriceDTO.setSolutionsId(insuranceApply.getSolutionId());
        countCyclePriceDTO.setStartDate(insuranceApply.getStartTime());
        CountCyclePriceVO  countCyclePriceVO = this.getCountCyclePriceVO(countCyclePriceDTO);
        insuranceApply.setApplyEndTime(countCyclePriceVO.getEndDate());
        insuranceApply.setEndTime(countCyclePriceVO.getEndDate());
        insuranceApplyMapper.insert(insuranceApply);
        //处理下级数据
        this.dealApplyDetailData(insuranceApply,applyDetailList,loginUserInfo);
        this.dealApplyDetailData(insuranceApply,applyDetailList,loginUserInfo,countCyclePriceVO);
        InsuranceApply updBean = new InsuranceApply();
        updBean.setId(insuranceApply.getId());
        updBean.setFee(applyDetailList.stream().map(ApplyDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
@@ -692,14 +730,21 @@
        insuranceApply.setCompanyId(loginUserInfo.getCompanyId());
        insuranceApply.setCheckInfo(insuranceApplyStatus.getName());
        insuranceApply.setStartTime(insuranceApply.getApplyStartTime());
        insuranceApply.setEndTime(insuranceApply.getApplyEndTime());
        insuranceApply.setCheckDate(new Date());
        insuranceApply.setCurrentFee(BigDecimal.ZERO);
        insuranceApply.setCheckUserId(loginUserInfo.getId());
        insuranceApply.setStatus(insuranceApplyStatus.getKey());
        CountCyclePriceDTO countCyclePriceDTO = new CountCyclePriceDTO();
        countCyclePriceDTO.setSolutionsId(insuranceApply.getSolutionId());
        countCyclePriceDTO.setStartDate(insuranceApply.getStartTime());
        CountCyclePriceVO  countCyclePriceVO = this.getCountCyclePriceVO(countCyclePriceDTO);
        insuranceApply.setApplyEndTime(countCyclePriceVO.getEndDate());
        insuranceApply.setEndTime(countCyclePriceVO.getEndDate());
        applyDetailMapper.delete(new QueryWrapper<ApplyDetail>().lambda().eq(ApplyDetail::getApplyId,insuranceApply.getId()));
        //处理下级数据
        this.dealApplyDetailData(insuranceApply,applyDetailList,loginUserInfo);
        this.dealApplyDetailData(insuranceApply,applyDetailList,loginUserInfo,countCyclePriceVO);
        insuranceApply.setFee(applyDetailList.stream().map(ApplyDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
        insuranceApplyMapper.updateById(insuranceApply);
        //存储日志数据
@@ -709,7 +754,7 @@
    public void dealApplyDetailData(InsuranceApply insuranceApply,List<ApplyDetail> applyDetailList,LoginUserInfo loginUserInfo){
    public void dealApplyDetailData(InsuranceApply insuranceApply,List<ApplyDetail> applyDetailList,LoginUserInfo loginUserInfo,CountCyclePriceVO  countCyclePriceVO){
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到方案信息");
@@ -796,7 +841,7 @@
                applyDetail.setMemberId(member.getId());
                applyDetail.setIdcardNo(member.getIdcardNo());
                applyDetail.setSex(member.getSex());
                applyDetail.setFee(Constants.countDetailFee(solutions,insuranceApply.getApplyEndTime(),insuranceApply.getApplyStartTime()));
                applyDetail.setFee(countCyclePriceVO.getCyclePrice());
                //验证派遣单位信息是否存在
                if(duSolutionList.stream().filter(d->d.getDispatchUnitId().equals(applyDetail.getDuId())).collect(Collectors.toList()).size()<=Constants.ZERO){
                    throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工派遣单位未查询到!");
@@ -1306,6 +1351,8 @@
    @Override
    public CountCyclePriceVO getCountCyclePriceVO(CountCyclePriceDTO countCyclePriceDTO){
        if(Objects.isNull(countCyclePriceDTO)
@@ -1318,20 +1365,10 @@
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        CountCyclePriceVO countCyclePriceVO = new CountCyclePriceVO();
        if(solutions.getInsureCycleUnit().equals(Constants.ZERO)){
            countCyclePriceVO.setEndDate(DateUtil.afterDateByType(countCyclePriceDTO.getStartDate(),0,solutions.getInsureCycle()));
        }else if(solutions.getInsureCycleUnit().equals(Constants.TWO)){
            Integer monthDays = DateUtil.monthDays(countCyclePriceDTO.getStartDate());
            Date afterDate = DateUtil.afterDateByType(countCyclePriceDTO.getStartDate(),0,monthDays);
            countCyclePriceVO.setEndDate(DateUtil.afterDateByType(afterDate,0,-1));
        }else if(solutions.getInsureCycleUnit().equals(Constants.THREE)){
            Date afterDate = DateUtil.afterDateByType(countCyclePriceDTO.getStartDate(),2,solutions.getInsureCycle());
            countCyclePriceVO.setEndDate(DateUtil.afterDateByType(afterDate,0,-1));
        return Constants.countPriceVO(countCyclePriceDTO.getStartDate(),solutions);
        }
        countCyclePriceVO.setCyclePrice(Constants.countDetailFee(solutions,countCyclePriceVO.getEndDate(),countCyclePriceDTO.getStartDate()));
        return countCyclePriceVO;
    }
server/service/src/main/java/com/doumee/service/business/impl/MemberInsuranceServiceImpl.java
@@ -83,6 +83,7 @@
    public List<MemberInsurance> findList(MemberInsurance memberInsurance) {
        memberInsurance.setIsdeleted(Constants.ZERO);
        QueryWrapper<MemberInsurance> wrapper = new QueryWrapper<>(memberInsurance);
        wrapper.orderByDesc("CREATE_DATE");
        return memberInsuranceMapper.selectList(wrapper);
    }
  
@@ -129,10 +130,6 @@
        if (pageWrap.getModel().getStartTime() != null) {
            queryWrapper.lambda().eq(MemberInsurance::getStartTime, pageWrap.getModel().getStartTime());
        }
        if (pageWrap.getModel().getIdcardNo() != null) {
            queryWrapper.lambda().ge(MemberInsurance::getIdcardNo, Utils.Date.getStart(pageWrap.getModel().getIdcardNo()));
            queryWrapper.lambda().le(MemberInsurance::getIdcardNo, Utils.Date.getEnd(pageWrap.getModel().getIdcardNo()));
        }
        if (pageWrap.getModel().getDuId() != null) {
            queryWrapper.lambda().eq(MemberInsurance::getDuId, pageWrap.getModel().getDuId());
        }
@@ -176,6 +173,8 @@
        return PageData.from(memberInsuranceMapper.selectPage(page, queryWrapper));
    }
    @Override
    public long count(MemberInsurance memberInsurance) {
        QueryWrapper<MemberInsurance> wrapper = new QueryWrapper<>(memberInsurance);
server/service/src/main/java/com/doumee/service/business/impl/SettleClaimsServiceImpl.java
@@ -358,6 +358,8 @@
        }
        settleClaims.setCreateDate(new Date());
        settleClaims.setIsdeleted(Constants.ZERO);
        settleClaims.setCompanyId(loginUserInfo.getCompanyId());
        settleClaims.setStatus(Constants.SettleClaimsStatus.WAIT_ACCEPTANCE.getKey());
        settleClaims.setCreator(loginUserInfo.getId());
        settleClaims.setCheckUserId(loginUserInfo.getId());
        settleClaimsMapper.insert(settleClaims);
@@ -368,6 +370,7 @@
                Multifile multifile = reportVideo.get(i);
                if(Objects.isNull(multifile.getFileurl())
                        || Objects.isNull(multifile.getType())
                        || StringUtils.isBlank(multifile.getName())
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件内容异常");
                }
@@ -551,8 +554,8 @@
        if(!oldSettleClaims.getSolutionId().equals(settleClaims.getSolutionId())){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"无法修改方案信息");
        }
        if(!(oldSettleClaims.getStatus().equals(Constants.SettleClaimsStatus.WAIT_ACCEPTANCE)
                || oldSettleClaims.getStatus().equals(Constants.SettleClaimsStatus.CONFIRM_INFORMATION))){
        if(!(oldSettleClaims.getStatus().equals(Constants.SettleClaimsStatus.WAIT_ACCEPTANCE.getKey())
                || oldSettleClaims.getStatus().equals(Constants.SettleClaimsStatus.CONFIRM_INFORMATION.getKey()))){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前状态无法进行该操作");
        }
        oldSettleClaims.setEditor(loginUserInfo.getId());
@@ -589,8 +592,8 @@
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非企业员工无法进行该操作");
        }
        SettleClaims settleClaims  = settleClaimsMapper.selectById(scSupplementDTO.getId());
        if(!(settleClaims.getStatus().equals(Constants.SettleClaimsStatus.WAIT_ACCEPTANCE)
                || settleClaims.getStatus().equals(Constants.SettleClaimsStatus.CONFIRM_INFORMATION))){
        if(!(settleClaims.getStatus().equals(Constants.SettleClaimsStatus.WAIT_ACCEPTANCE.getKey())
                || settleClaims.getStatus().equals(Constants.SettleClaimsStatus.CONFIRM_INFORMATION.getKey()))){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前状态无法进行该操作");
        }
        settleClaims.setEditor(loginUserInfo.getId());
@@ -612,21 +615,18 @@
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(Objects.isNull(scSupplementDTO)
                || Objects.isNull(scSupplementDTO.getId())
                || Objects.isNull(scSupplementDTO.getSupplement())
                || Objects.isNull(scSupplementDTO.getObjType())
                || Objects.isNull(scSupplementDTO.getFileUrl())
                || Objects.isNull(scSupplementDTO.getFileType())
                || scSupplementDTO.getObjType().equals(Constants.ZERO)
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        SettleClaims settleClaims  = settleClaimsMapper.selectById(scSupplementDTO.getId());
        if(!(settleClaims.getStatus().equals(Constants.SettleClaimsStatus.WAIT_ACCEPTANCE)
                || settleClaims.getStatus().equals(Constants.SettleClaimsStatus.CONFIRM_INFORMATION))){
        if(!(settleClaims.getStatus().equals(Constants.SettleClaimsStatus.WAIT_ACCEPTANCE.getKey())
                || settleClaims.getStatus().equals(Constants.SettleClaimsStatus.CONFIRM_INFORMATION.getKey()))){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前状态无法进行该操作");
        }
        Multifile multifile = new Multifile();
        if(loginUserInfo.getType().equals(Constants.ONE)){
            multifile.setCompanyId(loginUserInfo.getCompanyId());
@@ -634,7 +634,9 @@
        multifile.setCreator(loginUserInfo.getId());
        multifile.setCreateDate(new Date());
        multifile.setIsdeleted(Constants.ZERO);
        multifile.setObjType(scSupplementDTO.getObjType());
        multifile.setObjId(scSupplementDTO.getId());
        multifile.setFileurl(scSupplementDTO.getFileUrl());
        multifile.setName(scSupplementDTO.getFileUrl().substring(scSupplementDTO.getFileUrl().lastIndexOf("/") + 1));
        multifile.setType(scSupplementDTO.getFileType());
        multifileJoinMapper.insert(multifile);