| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.ApplyChangeMapper; |
| | | import com.doumee.dao.business.model.ApplyChange; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dto.ApplyChangeOptDTO; |
| | | import com.doumee.dao.business.dto.InsuranceApplyOptDTO; |
| | | import com.doumee.dao.business.join.ApplyChagneDetailJoinMapper; |
| | | import com.doumee.dao.business.join.ApplyChangeJoinMapper; |
| | | import com.doumee.dao.business.join.ApplyDetailJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | 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.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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 加减保换厂申请信息表Service实现 |
| | | * @author 江蹄蹄 |
| | | * @date 2024/01/15 15:07 |
| | | * @date 2024/01/16 10:03 |
| | | */ |
| | | @Service |
| | | public class ApplyChangeServiceImpl implements ApplyChangeService { |
| | |
| | | @Autowired |
| | | private ApplyChangeMapper applyChangeMapper; |
| | | |
| | | @Autowired |
| | | private InsuranceApplyMapper insuranceApplyMapper; |
| | | |
| | | @Autowired |
| | | private ApplyChangeJoinMapper applyChangeJoinMapper; |
| | | |
| | | @Autowired |
| | | private ApplyChagneDetailJoinMapper applyChagneDetailJoinMapper; |
| | | |
| | | @Autowired |
| | | private ApplyDetailJoinMapper applyDetailJoinMapper; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private DuSolutionMapper duSolutionMapper; |
| | | @Autowired |
| | | private DuWorktypeMapper duWorktypeMapper; |
| | | |
| | | @Autowired |
| | | private ApplyLogMapper applyLogMapper; |
| | | |
| | | @Autowired |
| | | private SolutionsMapper solutionsMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public Integer create(ApplyChange applyChange) { |
| | | if (Objects.isNull(applyChange) |
| | | || Objects.isNull(applyChange.getApplyId()) |
| | | || Objects.isNull(applyChange.getValidTime()) |
| | | || Objects.isNull(applyChange.getType()) |
| | | || !(applyChange.getType().equals(Constants.ZERO) || applyChange.getType().equals(Constants.TWO)) |
| | | ) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if (!loginUserInfo.getType().equals(Constants.ONE)) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "用户类型错误:非企业用户无法进行该操作"); |
| | | } |
| | | InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChange.getApplyId()); |
| | | if (Objects.isNull(insuranceApply)) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if (insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())) { |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "保单状态错误"); |
| | | } |
| | | if (DateUtil.compareDate(new Date(), insuranceApply.getEndTime()) >= Constants.ZERO |
| | | ) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "保单已过保,无法进行该操作"); |
| | | } |
| | | Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId()); |
| | | if(Objects.isNull(solutions)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案"); |
| | | } |
| | | //申请时间必须处于保单的时间范围内 |
| | | if (!(DateUtil.compareDate(applyChange.getValidTime(), insuranceApply.getStartTime()) >= Constants.ZERO |
| | | && DateUtil.compareDate(insuranceApply.getEndTime(), applyChange.getValidTime()) >= Constants.ZERO)) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作"); |
| | | } |
| | | applyChange.setCreateDate(new Date()); |
| | | applyChange.setCreator(loginUserInfo.getId()); |
| | | applyChange.setIsdeleted(Constants.ZERO); |
| | | applyChange.setStatus(Constants.ZERO); |
| | | applyChangeMapper.insert(applyChange); |
| | | |
| | | |
| | | List<DuSolution> duSolutionList = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda() |
| | | .eq(DuSolution::getIsdeleted, Constants.ZERO) |
| | | .eq(DuSolution::getStatus, Constants.ONE) |
| | | .eq(DuSolution::getSolutionId, insuranceApply.getSolutionId())); |
| | | if (!CollectionUtils.isNotEmpty(duSolutionList)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "数据异常:保险方案下未查询到派遣单位"); |
| | | } |
| | | |
| | | //查询所有派遣单位下的工种 |
| | | List<Integer> duSolutionIdList = duSolutionList.stream().map(i -> i.getId()).collect(Collectors.toList()); |
| | | List<DuWorktype> duWorktypeList = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda() |
| | | .eq(DuWorktype::getIsdeleted, Constants.ZERO) |
| | | .eq(DuWorktype::getStatus, Constants.ONE) |
| | | .in(DuWorktype::getDuSolutionId, duSolutionIdList)); |
| | | if (!CollectionUtils.isNotEmpty(duWorktypeList)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "数据异常:保险方案下未查询到工种信息"); |
| | | } |
| | | //加保数据 |
| | | List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList(); |
| | | if (CollectionUtils.isNotEmpty(addDetailList)) { |
| | | this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo); |
| | | } |
| | | |
| | | //减保数据 |
| | | List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList(); |
| | | if (CollectionUtils.isNotEmpty(delDetailList)) { |
| | | this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo); |
| | | } |
| | | //换厂业务 |
| | | List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList(); |
| | | if (CollectionUtils.isNotEmpty(changeDetailList)) { |
| | | this.changeDetail(applyChange,changeDetailList,duWorktypeList,duSolutionList,loginUserInfo); |
| | | } |
| | | |
| | | this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null); |
| | | |
| | | |
| | | return applyChange.getId(); |
| | | } |
| | | |
| | | |
| | | public void saveApplyLog(ApplyChange applyChange,Constants.ApplyChangeLogStatus applyChangeLogStatus,String content){ |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | ApplyLog applyLog = new ApplyLog(); |
| | | applyLog.setCreateDate(new Date()); |
| | | applyLog.setCreator(loginUserInfo.getId()); |
| | | applyLog.setIsdeleted(Constants.ZERO); |
| | | applyLog.setApplyId(applyChange.getApplyId()); |
| | | applyLog.setTitle(applyChangeLogStatus.getName()); |
| | | applyLog.setContent(content); |
| | | applyLog.setObjType(applyChangeLogStatus.getKey()); |
| | | applyLog.setObjId(Integer.toString(applyChange.getId())); |
| | | applyLog.setStatus(applyChange.getStatus()); |
| | | applyLogMapper.insert(applyLog); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 减保数据处理 |
| | | * @param applyChange |
| | | * @param delDetailList |
| | | * @param loginUserInfo |
| | | */ |
| | | public void delChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> delDetailList,InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo){ |
| | | for (ApplyChagneDetail applyChagneDetail : delDetailList) { |
| | | if (Objects.isNull(applyChagneDetail.getMemberId())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失"); |
| | | } |
| | | Member member = memberMapper.selectById(applyChagneDetail.getMemberId()); |
| | | if (Objects.isNull(member)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】未查询到系统人员信息"); |
| | | } |
| | | //查询员工是否存在 0待签署 1已签章 的此类业务保数据 同一主单下 |
| | | if (applyChagneDetailJoinMapper.selectJoinCount( |
| | | new MPJLambdaWrapper<ApplyChagneDetail>() |
| | | .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId) |
| | | .eq(ApplyChagneDetail::getMemberId, applyChagneDetail.getMemberId()) |
| | | .in(ApplyChange::getStatus, Constants.ZERO, Constants.ONE) |
| | | ) > Constants.ZERO) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】存在申请中的加减保/换厂单据"); |
| | | } |
| | | //查询员工是在主单下 是否存在生效中的数据 |
| | | List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda() |
| | | .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) |
| | | .eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId()) |
| | | .le(ApplyDetail::getStartTime, "now()") |
| | | .ge(ApplyDetail::getEndTime, "now()")); |
| | | if (applyDetailList.size() > Constants.ONE) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】保单信息异常,存在多条数据"); |
| | | } |
| | | ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO); |
| | | if (applyChange.getValidTime().compareTo(DateUtil.StringToDate(applyDetail.getEndTime())) <= 0) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】保单保障日期至:【" + applyDetail.getEndTime() + "】无法通过本次申请"); |
| | | } |
| | | applyChagneDetail.setCreateDate(new Date()); |
| | | applyChagneDetail.setCreator(loginUserInfo.getId()); |
| | | applyChagneDetail.setIsdeleted(Constants.ZERO); |
| | | applyChagneDetail.setApplyChangeId(applyChange.getId()); |
| | | applyChagneDetail.setType(Constants.ONE); |
| | | applyChagneDetail.setFee( |
| | | Constants.countDetailFee(solutions,DateUtil.stringToDate(applyDetail.getEndTime(),"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(applyDetail.getStartTime(),"yyyy-MM-dd HH:mm:ss")) |
| | | .subtract(Constants.countDetailFee(solutions,applyChange.getValidTime(),DateUtil.stringToDate(applyDetail.getStartTime(),"yyyy-MM-dd HH:mm:ss"))) |
| | | ); |
| | | applyChagneDetailJoinMapper.insert(applyChagneDetail); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 加保数据处理 |
| | | * @param applyChange |
| | | * @param addDetailList |
| | | * @param duWorktypeList |
| | | * @param duSolutionList |
| | | * @param loginUserInfo |
| | | */ |
| | | public void addChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> addDetailList,List<DuWorktype> duWorktypeList,List<DuSolution> duSolutionList,InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo){ |
| | | for (ApplyChagneDetail applyChagneDetail : addDetailList) { |
| | | if (Objects.isNull(applyChagneDetail.getMemberId()) |
| | | || Objects.isNull(applyChagneDetail.getDuId()) |
| | | || Objects.isNull(applyChagneDetail.getWorktypeId()) |
| | | ) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失"); |
| | | } |
| | | Member member = memberMapper.selectById(applyChagneDetail.getMemberId()); |
| | | if (Objects.isNull(member)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】未查询到系统人员信息"); |
| | | } |
| | | //查询员工是否存在 0待签署 1已签章 的此类业务保数据 同一主单下 |
| | | if (applyChagneDetailJoinMapper.selectJoinCount( |
| | | new MPJLambdaWrapper<ApplyChagneDetail>() |
| | | .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId) |
| | | .eq(ApplyChagneDetail::getMemberId, applyChagneDetail.getMemberId()) |
| | | .in(ApplyChange::getStatus, Constants.ZERO, Constants.ONE) |
| | | ) > Constants.ZERO) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】存在申请中的加减保/换厂单据"); |
| | | } |
| | | //查询员工是在主单下 是否存在生效中的数据 |
| | | if (applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>().lambda() |
| | | .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) |
| | | .eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId()) |
| | | .le(ApplyDetail::getStartTime, "now()") |
| | | .ge(ApplyDetail::getEndTime, "now()") |
| | | ) > Constants.ZERO) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】存在保障中的保单信息,无法进行加保"); |
| | | } |
| | | |
| | | //验证派遣单位信息 与工种信息 是否存在 |
| | | if (duSolutionList.stream().filter(d -> d.getDispatchUnitId().equals(applyChagneDetail.getDuId())).collect(Collectors.toList()).size() <= Constants.ZERO) { |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "【" + applyChagneDetail.getMemberName() + "】员工派遣单位未查询到!"); |
| | | } |
| | | if (duWorktypeList.stream().filter(d -> d.getDuSolutionId().equals(applyChagneDetail.getDuId()) && d.getWorkTypeId().equals(applyChagneDetail.getWorktypeId())) |
| | | .collect(Collectors.toList()).size() <= Constants.ZERO) { |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "【" + applyChagneDetail.getMemberName() + "】员工工种信息未查询到!"); |
| | | } |
| | | applyChagneDetail.setCreateDate(new Date()); |
| | | applyChagneDetail.setCreator(loginUserInfo.getId()); |
| | | applyChagneDetail.setIsdeleted(Constants.ZERO); |
| | | applyChagneDetail.setApplyChangeId(applyChange.getId()); |
| | | applyChagneDetail.setType(Constants.ZERO); |
| | | applyChagneDetail.setFee( |
| | | |
| | | Constants.countDetailFee(solutions,insuranceApply.getEndTime(),applyChange.getValidTime()) |
| | | ); |
| | | applyChagneDetailJoinMapper.insert(applyChagneDetail); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 换厂业务 |
| | | * @param applyChange |
| | | * @param duWorktypeList |
| | | * @param duSolutionList |
| | | * @param changeDetailList |
| | | * @param loginUserInfo |
| | | */ |
| | | public void changeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> changeDetailList,List<DuWorktype> duWorktypeList,List<DuSolution> duSolutionList,LoginUserInfo loginUserInfo){ |
| | | for (ApplyChagneDetail applyChagneDetail : changeDetailList) { |
| | | if (Objects.isNull(applyChagneDetail.getMemberId()) |
| | | || Objects.isNull(applyChagneDetail.getOldDuId()) |
| | | || Objects.isNull(applyChagneDetail.getOldWorktypeId()) |
| | | || Objects.isNull(applyChagneDetail.getDuId()) |
| | | || Objects.isNull(applyChagneDetail.getWorktypeId()) |
| | | ) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "换厂人员【" + applyChagneDetail.getMemberName() + "】必填项缺失"); |
| | | } |
| | | Member member = memberMapper.selectById(applyChagneDetail.getMemberId()); |
| | | if (Objects.isNull(member)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "换厂人员【" + applyChagneDetail.getMemberName() + "】未查询到系统人员信息"); |
| | | } |
| | | //查询员工是否存在 0待签署 1已签章 的此类业务保数据 同一主单下 |
| | | if (applyChagneDetailJoinMapper.selectJoinCount( |
| | | new MPJLambdaWrapper<ApplyChagneDetail>() |
| | | .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId) |
| | | .eq(ApplyChagneDetail::getMemberId, applyChagneDetail.getMemberId()) |
| | | .in(ApplyChange::getStatus, Constants.ZERO, Constants.ONE) |
| | | ) > Constants.ZERO) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "换厂人员【" + applyChagneDetail.getMemberName() + "】存在申请中的加减保/换厂单据"); |
| | | } |
| | | //查询员工是在主单下 是否存在生效中的数据 |
| | | List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda() |
| | | .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) |
| | | .eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId()) |
| | | .le(ApplyDetail::getStartTime, "now()") |
| | | .ge(ApplyDetail::getEndTime, "now()")); |
| | | if(applyDetailList.size()>Constants.ONE){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "换厂人员【" + applyChagneDetail.getMemberName() + "】保单信息异常,存在多条数据"); |
| | | } |
| | | ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO); |
| | | if(applyChange.getValidTime().compareTo(DateUtil.StringToDate(applyDetail.getEndTime()))<=0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "换厂人员【" + applyChagneDetail.getMemberName() + "】保单保障日期至:【"+applyDetail.getEndTime()+"】无法通过本次申请"); |
| | | } |
| | | //验证派遣单位信息 与工种信息 是否存在 |
| | | if (duSolutionList.stream().filter(d -> d.getDispatchUnitId().equals(applyChagneDetail.getDuId())).collect(Collectors.toList()).size() <= Constants.ZERO) { |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "换厂人员【" + applyChagneDetail.getMemberName() + "】员工派遣单位未查询到!"); |
| | | } |
| | | if (duWorktypeList.stream().filter(d -> d.getDuSolutionId().equals(applyChagneDetail.getDuId()) && d.getWorkTypeId().equals(applyChagneDetail.getWorktypeId())) |
| | | .collect(Collectors.toList()).size() <= Constants.ZERO) { |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "换厂人员【" + applyChagneDetail.getMemberName() + "】员工工种信息未查询到!"); |
| | | } |
| | | applyChagneDetail.setCreateDate(new Date()); |
| | | applyChagneDetail.setCreator(loginUserInfo.getId()); |
| | | applyChagneDetail.setIsdeleted(Constants.ZERO); |
| | | applyChagneDetail.setApplyChangeId(applyChange.getId()); |
| | | applyChagneDetail.setType(Constants.TWO); |
| | | applyChagneDetailJoinMapper.insert(applyChagneDetail); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | QueryWrapper<ApplyChange> wrapper = new QueryWrapper<>(applyChange); |
| | | return applyChangeMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageData<ApplyChange> findPageForCompany(PageWrap<ApplyChange> pageWrap) { |
| | | IPage<ApplyChange> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<ApplyChange> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | ApplyChange model = pageWrap.getModel() ; |
| | | queryWrapper |
| | | .selectAll(ApplyChange.class) |
| | | .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0 )",ApplyChange::getAddNum) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1 )",ApplyChange::getDelNum) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 2 )",ApplyChange::getChangeNum) |
| | | .select("( select ifnull(sum(ad.FEE),0) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID )",ApplyChange::getChangeMoney) |
| | | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId) |
| | | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) |
| | | .eq(!Objects.isNull(model.getType()),ApplyChange::getType,model.getType()) |
| | | .eq(!Objects.isNull(model.getStatus()),ApplyChange::getStatus,model.getStatus()) |
| | | .eq(!Objects.isNull(model.getCompanyId()),InsuranceApply::getCompanyId,model.getCompanyId()) |
| | | .eq(!Objects.isNull(model.getSolutionsId()),ApplyChange::getSolutionsId,model.getSolutionsId()) |
| | | .ge(StringUtils.isNotBlank(model.getCreateDateS()),ApplyChange::getCreateDate, model.getCreateDateS()+" 00:00:00" ) |
| | | .le(StringUtils.isNotBlank(model.getCreateDateE()),ApplyChange::getCreateDate, model.getCreateDateE()+" 23:59:59" ); |
| | | |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | PageData<ApplyChange> pageData = PageData.from(applyChangeJoinMapper.selectJoinPage(page,ApplyChange.class, queryWrapper)); |
| | | return pageData; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void changeOpt(ApplyChangeOptDTO applyChangeOptDTO){ |
| | | if(Objects.isNull(applyChangeOptDTO) |
| | | ||Objects.isNull(applyChangeOptDTO.getApplyId()) |
| | | ||StringUtils.isBlank(applyChangeOptDTO.getOptIllustration())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | |
| | | ApplyChange applyChange = applyChangeMapper.selectById(applyChangeOptDTO.getApplyId()); |
| | | if(Objects.isNull(applyChange)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到单据数据"); |
| | | } |
| | | InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChange.getApplyId()); |
| | | if(Objects.isNull(insuranceApply)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保单数据"); |
| | | } |
| | | if(applyChange.getIsdeleted().equals(Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"数据已删除,无法进行该操作"); |
| | | } |
| | | Constants.ApplyChangeLogStatus applyChangeLogStatus = Constants.ApplyChangeLogStatus.RETURN_APPLY; |
| | | |
| | | if(applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.RETURN_APPLY.getKey())){ |
| | | //发起退回申请 |
| | | if(loginUserInfo.getType().equals(Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非企业端用户无法进行该操作"); |
| | | } |
| | | if(!applyChange.getStatus().equals(Constants.ApplyChangeStatus.UPLOAD.getKey()) ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态错误无法进行该操作!"); |
| | | } |
| | | }else if(applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.PLATFORM_AGREE.getKey())){ |
| | | applyChangeLogStatus = Constants.ApplyChangeLogStatus.PLATFORM_AGREE; |
| | | //平台同意退回 |
| | | if(loginUserInfo.getType().equals(Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非平台端用户无法进行该操作"); |
| | | } |
| | | if(!applyChange.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态错误无法进行该操作!"); |
| | | } |
| | | }else if(applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.UPLOAD.getKey())){ |
| | | applyChangeLogStatus = Constants.ApplyChangeLogStatus.PLATFORM_UN_AGREE; |
| | | //平台驳回退回 |
| | | if(loginUserInfo.getType().equals(Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非平台端用户无法进行该操作"); |
| | | } |
| | | if(!applyChange.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态错误无法进行该操作!"); |
| | | } |
| | | }else if(applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.CLOSE.getKey())){ |
| | | applyChangeLogStatus = Constants.ApplyChangeLogStatus.CLOSE; |
| | | //企业关闭 |
| | | if(loginUserInfo.getType().equals(Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非企业端用户无法进行该操作"); |
| | | } |
| | | if(!applyChange.getStatus().equals(Constants.ApplyChangeStatus.PLATFORM_AGREE.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态错误无法进行该操作!"); |
| | | } |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST ); |
| | | } |
| | | applyChange.setStatus(applyChangeOptDTO.getOptType()); |
| | | applyChangeMapper.updateById(applyChange); |
| | | // //存储日志数据 |
| | | this.saveApplyLog(applyChange,applyChangeLogStatus,applyChangeOptDTO.getOptIllustration()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public ApplyChange findDetail(Integer id){ |
| | | MPJLambdaWrapper<ApplyChange> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(ApplyChange.class) |
| | | .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode) |
| | | .selectAs(Company::getName,ApplyChange::getCompanyName) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0 )",ApplyChange::getAddNum) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1 )",ApplyChange::getDelNum) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 2 )",ApplyChange::getChangeNum) |
| | | .select("( select ifnull(sum(ad.FEE),0) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID )",ApplyChange::getChangeMoney) |
| | | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId) |
| | | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) |
| | | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) |
| | | .eq(ApplyChange::getId,id); |
| | | ApplyChange applyChange = applyChangeJoinMapper.selectOne(queryWrapper); |
| | | return applyChange; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |