|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.util.IdcardUtil; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.api.R; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.Reflections; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.*; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.ApplyChangeCyclePriceDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.ApplyChangeOptDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.SaveUnionChangeDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.SmsCheckDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.join.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.ChangeDealTypeVO; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.CountCyclePriceVO; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.ApplyChangeService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.doumee.service.business.InsuranceApplyService; | 
|---|
|  |  |  | import com.doumee.service.business.SmsEmailService; | 
|---|
|  |  |  | import com.doumee.service.business.third.SignService; | 
|---|
|  |  |  | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | import org.checkerframework.checker.units.qual.A; | 
|---|
|  |  |  | import org.slf4j.Logger; | 
|---|
|  |  |  | import org.slf4j.LoggerFactory; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | pidanFile.setObjType(Constants.MultiFile.CA_PD_PDF.getKey()); | 
|---|
|  |  |  | pidanFile.setType(Constants.TWO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insertBatchSomeColumn(pidanFileList); | 
|---|
|  |  |  | multifileMapper.insert(pidanFileList); | 
|---|
|  |  |  | update.setApplyId(model.getApplyId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | pidanFile.setObjType(Constants.MultiFile.CA_PD_PDF.getKey()); | 
|---|
|  |  |  | pidanFile.setType(Constants.TWO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insertBatchSomeColumn(param.getPidanFileList()); | 
|---|
|  |  |  | multifileMapper.insert(param.getPidanFileList()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        param.getPidanFile().setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | //        param.getPidanFile().setObjId(update.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (memberInsuranceList != null && memberInsuranceList.size() > 0) { | 
|---|
|  |  |  | memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList); | 
|---|
|  |  |  | memberInsuranceJoinMapper.insert(memberInsuranceList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (totalFee.compareTo(new BigDecimal(0)) != 0) { | 
|---|
|  |  |  | 
|---|
|  |  |  | List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList(); | 
|---|
|  |  |  | //加保数据 | 
|---|
|  |  |  | List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList(); | 
|---|
|  |  |  | //换厂业务 | 
|---|
|  |  |  | List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(delDetailList) | 
|---|
|  |  |  | && CollectionUtils.isEmpty(addDetailList) | 
|---|
|  |  |  | && CollectionUtils.isEmpty(changeDetailList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,未添加人员数据无法进行提交"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (CollectionUtils.isNotEmpty(addDetailList)) { | 
|---|
|  |  |  | if(Objects.isNull(solutions.getCanAdd()) || solutions.getCanAdd().equals(Constants.ZERO)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //换厂业务 | 
|---|
|  |  |  | List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList(); | 
|---|
|  |  |  | if (CollectionUtils.isNotEmpty(changeDetailList)) { | 
|---|
|  |  |  | if(Objects.isNull(solutions.getCanChangeUnit()) || solutions.getCanChangeUnit().equals(Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案无法进行换厂操作"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询员工是在主单下 是否存在生效中的数据 | 
|---|
|  |  |  | List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda() | 
|---|
|  |  |  | .eq(ApplyDetail::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) | 
|---|
|  |  |  | .eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId()) | 
|---|
|  |  |  | //                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1)) | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId,applyChange.getApplyId()) | 
|---|
|  |  |  | .eq(ApplyDetail::getIdcardNo,applyChagneDetail.getIdcardNo()) | 
|---|
|  |  |  | .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1)) | 
|---|
|  |  |  | .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(insuranceApply.getEndTime(),2)) | 
|---|
|  |  |  | .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(insuranceApply.getEndTime(),2)) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + applyChagneDetail.getMemberName() + "】存在日期冲突的数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询员工是在主单下 是否存在生效中的数据 | 
|---|
|  |  |  | List<ApplyDetail>  applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda() | 
|---|
|  |  |  | .eq(ApplyDetail::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) | 
|---|
|  |  |  | .eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId()) | 
|---|
|  |  |  | .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1)) | 
|---|