| | |
| | | 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.Utils; |
| | | import com.doumee.dao.business.SolutionsBaseMapper; |
| | | import com.doumee.dao.business.model.SolutionsBase; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.SolutionWorktypeJoinMapper; |
| | | import com.doumee.dao.business.join.SolutionsBaseJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.service.business.SolutionsBaseService; |
| | | 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.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 保险方案信息表Service实现 |
| | |
| | | @Autowired |
| | | private SolutionsBaseMapper solutionsBaseMapper; |
| | | |
| | | @Autowired |
| | | private SolutionsBaseJoinMapper solutionsBaseJoinMapper; |
| | | |
| | | @Autowired |
| | | private InsuranceMapper insuranceMapper; |
| | | |
| | | @Autowired |
| | | private SolutionWorktypeJoinMapper solutionWorktypeJoinMapper; |
| | | |
| | | @Autowired |
| | | private WorktypeMapper worktypeMapper; |
| | | |
| | | @Autowired |
| | | private CompanySolutionMapper companySolutionMapper; |
| | | |
| | | @Autowired |
| | | private DuSolutionMapper duSolutionMapper; |
| | | |
| | | @Autowired |
| | | private SolutionsMapper solutionsMapper; |
| | | |
| | | @Autowired |
| | | private InsuranceApplyMapper insuranceApplyMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public Integer create(SolutionsBase solutionsBase) { |
| | | solutionsBaseMapper.insert(solutionsBase); |
| | | LoginUserInfo user= (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | initCreateParam(solutionsBase); |
| | | if(solutionsBaseMapper.selectCount(new QueryWrapper<SolutionsBase>().lambda() |
| | | .eq(SolutionsBase::getName,solutionsBase.getName()) |
| | | .eq(SolutionsBase::getIsdeleted,Constants.ZERO) |
| | | .eq(SolutionsBase::getDataType,Constants.ZERO) |
| | | )>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"保险主方案名称已存在"); |
| | | } |
| | | |
| | | |
| | | solutionsBase.setCreateDate(new Date()); |
| | | solutionsBase.setCreator(user.getId()); |
| | | solutionsBase.setEditDate(new Date()); |
| | | solutionsBase.setEditor(user.getId()); |
| | | solutionsBase.setIsdeleted(Constants.ZERO); |
| | | solutionsBase.setStatus(Constants.ZERO); |
| | | solutionsBase.setVersion(UUID.randomUUID().toString());//版本号 |
| | | solutionsBase.setDataType(Constants.ZERO); |
| | | |
| | | //2024年6月17日15:56:18 仅支持替换模式下,批增配置日期 等于 批减配置日期 |
| | | if(Constants.equalsInteger(solutionsBase.getDelOnlyReplace(),Constants.ONE)){ |
| | | solutionsBase.setAddValidDays(solutionsBase.getDelValidDays()); |
| | | } |
| | | solutionsBaseMapper.insert(solutionsBase); //基础版本 |
| | | |
| | | //如果有工种,则产生一个新的有效历史版本 ~ |
| | | SolutionsBase newModel = new SolutionsBase(); |
| | | BeanUtils.copyProperties(solutionsBase,newModel); |
| | | newModel.setId(null); |
| | | newModel.setBaseId(solutionsBase.getId()); |
| | | newModel.setDataType(Constants.TWO); |
| | | solutionsBaseMapper.insert(newModel); |
| | | |
| | | dealWorkTypeInsurance(solutionsBase,newModel,solutionsBase.getWorktypeIdList()); |
| | | |
| | | return solutionsBase.getId(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private void dealWorkTypeInsurance(SolutionsBase solutionsBase, SolutionsBase newModel, List<Integer> worktypeIdList) { |
| | | Insurance model = insuranceMapper.selectById(solutionsBase.getInsuranceId()); |
| | | if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) |
| | | || !Constants.equalsInteger(model.getDataType(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该保险公司信息不存在,请尝试刷新页面重试~" ); |
| | | } |
| | | if( !Constants.equalsInteger(model.getStatus(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该保险公司已被禁用,请尝试刷新页面重试~" ); |
| | | } |
| | | List<Worktype> worktypeList = worktypeMapper.selectList(new QueryWrapper<Worktype>().lambda() |
| | | .eq(Worktype::getInsuranceId,solutionsBase.getInsuranceId()) |
| | | .eq(Worktype::getIsdeleted,Constants.ZERO) |
| | | .in(Worktype::getId,worktypeIdList)); |
| | | if(worktypeList==null ||worktypeIdList.size()==0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,工种信息选择有误,请尝试刷新页面重试~" ); |
| | | } |
| | | int num =0; |
| | | for(Worktype type : worktypeList) { |
| | | //基础版本 |
| | | SolutionWorktype w = new SolutionWorktype(); |
| | | w.setSolutionId(solutionsBase.getId()); |
| | | w.setIsdeleted(Constants.ZERO); |
| | | w.setCreator(newModel.getCreator()); |
| | | w.setCreateDate(solutionsBase.getCreateDate()); |
| | | w.setWorktypeId(type.getId()); |
| | | w.setStatus(Constants.ZERO); |
| | | w.setSortnum(num++); |
| | | w.setType(Constants.ONE); |
| | | solutionWorktypeJoinMapper.insert(w); |
| | | |
| | | //历史版本的工种信息 |
| | | SolutionWorktype newType = new SolutionWorktype(); |
| | | BeanUtils.copyProperties(w, newType); |
| | | newType.setId(null); |
| | | newType.setSolutionId(newModel.getId()); |
| | | solutionWorktypeJoinMapper.insert(newType); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | private void initCreateParam(SolutionsBase solutionsBase) { |
| | | if(StringUtils.isBlank(solutionsBase.getName())|| |
| | | StringUtils.isBlank(solutionsBase.getCompanyName()) |
| | | || Objects.isNull(solutionsBase.getValidType()) |
| | | // || Objects.isNull(solutionsBase.getCanAdd()) |
| | | // || Objects.isNull(solutionsBase.getCanReduce()) |
| | | // || Objects.isNull(solutionsBase.getCanChangeUnit()) |
| | | // || Objects.isNull(solutionsBase.getDelOnlyReplace()) |
| | | || Objects.isNull(solutionsBase.getAddValidDays()) |
| | | || Objects.isNull(solutionsBase.getDelValidDays()) |
| | | || Objects.isNull(solutionsBase.getInsuranceId()) |
| | | // || Objects.isNull(solutionsBase.getRiskDelayStatus()) |
| | | // || Objects.isNull(solutionsBase.getRiskDelayTime()) |
| | | // || Objects.isNull(solutionsBase.getRiskDelayUnit()) |
| | | // || Objects.isNull(solutionsBase.getRiskNewUserStatus()) |
| | | // || Objects.isNull(solutionsBase.getRiskNewUserTime()) |
| | | // || Objects.isNull(solutionsBase.getRiskNewUserUnit()) |
| | | |
| | | ||solutionsBase.getInsuranceId()==null |
| | | || Constants.formatIntegerNum(solutionsBase.getMaxAge()) < 0 |
| | | ||Constants.formatIntegerNum(solutionsBase.getMinAge()) < 0 |
| | | ||Constants.formatIntegerNum( solutionsBase.getMinAge()) >Constants.formatIntegerNum(solutionsBase.getMaxAge()) |
| | | || com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(solutionsBase.getWorktypeIdList()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if(Constants.equalsInteger(solutionsBase.getValidType(),Constants.ZERO) && Objects.isNull(solutionsBase.getValidTypeNum())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveSolutionsRisk(SolutionsBase solutionsBase){ |
| | | if( Objects.isNull(solutionsBase) |
| | | || Objects.isNull(solutionsBase.getId()) |
| | | ||Objects.isNull(solutionsBase.getRiskDelayStatus()) |
| | | || Objects.isNull(solutionsBase.getRiskDelayTime()) |
| | | || Objects.isNull(solutionsBase.getRiskDelayUnit()) |
| | | || Objects.isNull(solutionsBase.getRiskNewUserStatus()) |
| | | || Objects.isNull(solutionsBase.getRiskNewUserTime()) |
| | | || Objects.isNull(solutionsBase.getRiskNewUserUnit())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | SolutionsBase model = solutionsBaseMapper.selectById(solutionsBase.getId()); |
| | | if(Objects.isNull(model)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | solutionsBaseMapper.update(new UpdateWrapper<SolutionsBase>().lambda() |
| | | .set(SolutionsBase::getEditDate,new Date()) |
| | | .set(SolutionsBase::getRiskDelayStatus,solutionsBase.getRiskDelayStatus()) |
| | | .set(SolutionsBase::getRiskDelayTime,solutionsBase.getRiskDelayTime()) |
| | | .set(SolutionsBase::getRiskDelayUnit,solutionsBase.getRiskDelayUnit()) |
| | | .set(SolutionsBase::getRiskNewUserStatus,solutionsBase.getRiskNewUserStatus()) |
| | | .set(SolutionsBase::getRiskNewUserTime,solutionsBase.getRiskNewUserTime()) |
| | | .set(SolutionsBase::getRiskNewUserUnit,solutionsBase.getRiskNewUserUnit()) |
| | | .eq(SolutionsBase::getId,solutionsBase.getId()) |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | | SolutionsBase solutionsBase = solutionsBaseMapper.selectById(id); |
| | | if (!Objects.isNull(solutionsBase)){ |
| | | //查询主方案下所有启用版本数据中 是否存在 子方案 |
| | | if(solutionsMapper.selectCount(new QueryWrapper<Solutions>() |
| | | .lambda() |
| | | .eq(Solutions::getDataType,Constants.ZERO) |
| | | .eq(Solutions::getIsdeleted,Constants.ZERO) |
| | | .eq(Solutions::getParentId,id) |
| | | )>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"["+solutionsBase.getName()+"]下存在子方案,无法进行删除"); |
| | | }; |
| | | } |
| | | solutionsBaseMapper.deleteById(id); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void deleteByIdInBatch(List<Integer> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | for (Integer id:ids) { |
| | | this.deleteById(id); |
| | | } |
| | | solutionsBaseMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void updateById(SolutionsBase solutionsBase) { |
| | | LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); |
| | | SolutionsBase model = findById(solutionsBase.getId()); |
| | | if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) |
| | | || !Constants.equalsInteger(model.getDataType(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY ); |
| | | } |
| | | //数据有效性校验 |
| | | initCreateParam(solutionsBase); |
| | | //查询是否已存在使用中的保单 |
| | | if(insuranceApplyMapper.selectCount(new QueryWrapper<InsuranceApply>().lambda() |
| | | .apply(" solution_id in ( select s.ID from solutions s where s.PARENT_ID in ( select id from solutions_base where BASE_ID = "+solutionsBase.getId()+" or id = "+solutionsBase.getId()+" ) )" ) |
| | | .notIn(InsuranceApply::getStatus |
| | | ,Constants.InsuranceApplyStatus.PLATFORM_RETURN |
| | | ,Constants.InsuranceApplyStatus.CLOSE |
| | | ,Constants.InsuranceApplyStatus.WTB_CLOSED |
| | | ) |
| | | )>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"存在已投保的保单数据,无法进行修改"); |
| | | }; |
| | | |
| | | if(solutionsBaseMapper.selectCount(new QueryWrapper<SolutionsBase>().lambda() |
| | | .eq(SolutionsBase::getName,solutionsBase.getName()) |
| | | .eq(SolutionsBase::getIsdeleted,Constants.ZERO) |
| | | .eq(SolutionsBase::getDataType,Constants.ZERO) |
| | | .ne(SolutionsBase::getId,solutionsBase.getId()) |
| | | )>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"保险主方案名称已存在"); |
| | | } |
| | | |
| | | solutionsBase.setEditor(user.getId()); |
| | | solutionsBase.setVersion(UUID.randomUUID().toString()); |
| | | solutionsBase.setEditDate(new Date()); |
| | | |
| | | //2024年6月17日15:56:18 仅支持替换模式下,批增日期 等于 批减日期 |
| | | if(Constants.equalsInteger(solutionsBase.getDelOnlyReplace(),Constants.ONE)){ |
| | | solutionsBase.setAddValidDays(solutionsBase.getDelValidDays()); |
| | | } |
| | | solutionsBaseMapper.updateById(solutionsBase); |
| | | |
| | | SolutionsBase oldVersion = solutionsBaseMapper.selectOne(new QueryWrapper<SolutionsBase>() |
| | | .lambda() |
| | | .eq(SolutionsBase::getBaseId,solutionsBase.getId()) |
| | | .eq(SolutionsBase::getDataType,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | |
| | | if(Objects.isNull(oldVersion)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到历史版本数据"); |
| | | } |
| | | |
| | | //如果修改,则产生一个新的历史版本 ~ |
| | | SolutionsBase newModel = new SolutionsBase(); |
| | | BeanUtils.copyProperties( findById(solutionsBase.getId()),newModel); |
| | | newModel.setId(null); |
| | | newModel.setVersion(solutionsBase.getVersion()); |
| | | newModel.setCreateDate(new Date()); |
| | | newModel.setBaseId(solutionsBase.getId()); |
| | | newModel.setDataType(Constants.TWO); |
| | | solutionsBaseMapper.insert(newModel); |
| | | |
| | | //删除父方案下所有工种数据 |
| | | solutionWorktypeJoinMapper.delete(new UpdateWrapper<SolutionWorktype>() |
| | | .lambda() |
| | | .eq(SolutionWorktype::getSolutionId,solutionsBase.getId()) |
| | | .eq(SolutionWorktype::getType,Constants.ONE) |
| | | ); |
| | | //删除父方案下所有子方案的工种数据 |
| | | solutionWorktypeJoinMapper.delete(new UpdateWrapper<SolutionWorktype>() |
| | | .lambda() |
| | | .eq(SolutionWorktype::getType,Constants.ZERO) |
| | | .apply(" SOLUTION_ID in ( select s.id from solutions s where s.PARENT_ID = "+solutionsBase.getId()+" ) ") |
| | | ); |
| | | |
| | | dealWorkTypeInsurance(solutionsBase,newModel,solutionsBase.getWorktypeIdList()); |
| | | |
| | | solutionsBaseMapper.update(null,new UpdateWrapper<SolutionsBase>() |
| | | .lambda() |
| | | .ne(SolutionsBase::getId,newModel.getId()) |
| | | .eq(SolutionsBase::getBaseId,solutionsBase.getId()) |
| | | .eq(SolutionsBase::getDataType,Constants.TWO) |
| | | .set(SolutionsBase::getDataType,Constants.ONE) |
| | | ); |
| | | |
| | | //更新company_solution 使用新版本的数据 |
| | | companySolutionMapper.update(null, |
| | | new UpdateWrapper<CompanySolution>() |
| | | .lambda() |
| | | .eq(CompanySolution::getStatus,Constants.ZERO) |
| | | .set(CompanySolution::getSolutionId,newModel.getId()) |
| | | .eq(CompanySolution::getSolutionBaseId,solutionsBase.getId()) |
| | | ); |
| | | |
| | | //更新 du_solution 使用新版本的数据 |
| | | duSolutionMapper.update(null, |
| | | new UpdateWrapper<DuSolution>() |
| | | .lambda() |
| | | .eq(DuSolution::getIsdeleted, Constants.ZERO) |
| | | .eq(DuSolution::getStatus, Constants.ONE) |
| | | .set(DuSolution::getSolutionId,newModel.getId()) |
| | | .eq(DuSolution::getSolutionId,oldVersion.getId())); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void updateByIdInBatch(List<SolutionsBase> solutionsBases) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void updateStatus(SolutionsBase solutionsBase){ |
| | | if(solutionsBase.getId() == null || solutionsBase.getStatus()==null || solutionsBase.getStatus()<0||solutionsBase.getStatus()>1){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST ); |
| | | } |
| | | SolutionsBase model = findById(solutionsBase.getId()); |
| | | if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) |
| | | || !Constants.equalsInteger(model.getDataType(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY ); |
| | | } |
| | | if(Constants.equalsInteger(model.getStatus(),solutionsBase.getStatus())){ |
| | | //如果状态不发生改变,直接返回 |
| | | return; |
| | | } |
| | | LoginUserInfo user= (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | //同时更新基表和历史版本所有数据状态 |
| | | solutionsBaseMapper.update(null,new UpdateWrapper<SolutionsBase>() |
| | | .lambda() |
| | | .and(m -> m.eq(SolutionsBase::getId,model.getId()).or().eq(SolutionsBase::getBaseId,model.getId())) |
| | | .eq(SolutionsBase::getIsdeleted,Constants.ZERO) |
| | | .set(SolutionsBase::getEditDate,new Date()) |
| | | .set(SolutionsBase::getEditor,user.getId()) |
| | | .set(SolutionsBase::getStatus,solutionsBase.getStatus()) |
| | | ); |
| | | |
| | | //如果是禁用,则修改方案子表的全部数据为禁用 |
| | | if(Constants.equalsInteger(solutionsBase.getStatus(),Constants.ONE)){ |
| | | solutionsMapper.update(null,new UpdateWrapper<Solutions>() |
| | | .lambda() |
| | | .set(Solutions::getStatus,solutionsBase.getStatus()) |
| | | .set(Solutions::getEditDate,new Date()) |
| | | .set(Solutions::getEditor,user.getId()) |
| | | .eq(Solutions::getParentId,solutionsBase.getId()) |
| | | ); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public SolutionsBase findById(Integer id) { |
| | | return solutionsBaseMapper.selectById(id); |
| | | MPJLambdaWrapper<SolutionsBase> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(SolutionsBase.class); |
| | | queryWrapper.selectAs(Insurance::getName,SolutionsBase::getInsuranceName); |
| | | queryWrapper.selectAs(Company::getName,SolutionsBase::getShopName); |
| | | queryWrapper.leftJoin(Insurance.class,Insurance::getId,SolutionsBase::getInsuranceId); |
| | | queryWrapper.leftJoin(Company.class,Company::getId,SolutionsBase::getShopId); |
| | | queryWrapper.eq(SolutionsBase::getId,id); |
| | | SolutionsBase model = solutionsBaseJoinMapper.selectJoinOne(SolutionsBase.class,queryWrapper); |
| | | if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY ); |
| | | } |
| | | MPJLambdaWrapper<SolutionWorktype> wrapper = new MPJLambdaWrapper<>(); |
| | | wrapper.selectAll(SolutionWorktype.class); |
| | | wrapper.selectAs(Worktype::getName,SolutionWorktype::getWorktypeName); |
| | | wrapper.leftJoin(Worktype.class,Worktype::getId,SolutionWorktype::getWorktypeId); |
| | | wrapper.eq(SolutionWorktype::getSolutionId,id); |
| | | wrapper.eq(SolutionWorktype::getType,Constants.ONE); |
| | | wrapper.eq(SolutionWorktype::getIsdeleted,Constants.ZERO); |
| | | wrapper.orderByAsc(SolutionWorktype::getSortnum); |
| | | List<SolutionWorktype> worktypeList = solutionWorktypeJoinMapper.selectJoinList(SolutionWorktype.class,wrapper); |
| | | model.setWorktypeList(worktypeList); |
| | | return model; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public List<SolutionsBase> findList(SolutionsBase solutionsBase) { |
| | | QueryWrapper<SolutionsBase> wrapper = new QueryWrapper<>(solutionsBase); |
| | | QueryWrapper<SolutionsBase> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().select(SolutionsBase::getId,SolutionsBase::getName); |
| | | wrapper.lambda().eq(SolutionsBase::getDataType,Constants.ZERO); |
| | | wrapper.lambda().eq(SolutionsBase::getIsdeleted,Constants.ZERO); |
| | | return solutionsBaseMapper.selectList(wrapper); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageData<SolutionsBase> findPage(PageWrap<SolutionsBase> pageWrap) { |
| | | IPage<SolutionsBase> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<SolutionsBase> queryWrapper = new QueryWrapper<>(); |
| | | MPJLambdaWrapper<SolutionsBase> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getId, pageWrap.getModel().getId()); |
| | | } |
| | | if (pageWrap.getModel().getCreator() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getCreator, pageWrap.getModel().getCreator()); |
| | | } |
| | | if (pageWrap.getModel().getCreateDate() != null) { |
| | | queryWrapper.lambda().ge(SolutionsBase::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); |
| | | queryWrapper.lambda().le(SolutionsBase::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); |
| | | } |
| | | if (pageWrap.getModel().getEditor() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getEditor, pageWrap.getModel().getEditor()); |
| | | } |
| | | if (pageWrap.getModel().getEditDate() != null) { |
| | | queryWrapper.lambda().ge(SolutionsBase::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); |
| | | queryWrapper.lambda().le(SolutionsBase::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); |
| | | } |
| | | if (pageWrap.getModel().getIsdeleted() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | } |
| | | queryWrapper.selectAll(SolutionsBase.class); |
| | | queryWrapper.selectAs(Insurance::getName,SolutionsBase::getInsuranceName); |
| | | queryWrapper.selectAs(Company::getName,SolutionsBase::getShopName); |
| | | queryWrapper.leftJoin(Insurance.class,Insurance::getId,SolutionsBase::getInsuranceId); |
| | | queryWrapper.leftJoin(Company.class,Company::getId,SolutionsBase::getShopId); |
| | | //只查询未删除的数据 |
| | | queryWrapper.eq(SolutionsBase::getIsdeleted,Constants.ZERO); |
| | | //只查询基础版本数据 |
| | | queryWrapper.eq(SolutionsBase::getDataType,Constants.ZERO); |
| | | if (pageWrap.getModel().getName() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getName, pageWrap.getModel().getName()); |
| | | queryWrapper.like(SolutionsBase::getName, pageWrap.getModel().getName()); |
| | | } |
| | | if (pageWrap.getModel().getRemark() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getRemark, pageWrap.getModel().getRemark()); |
| | | } |
| | | if (pageWrap.getModel().getStatus() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getStatus, pageWrap.getModel().getStatus()); |
| | | } |
| | | if (pageWrap.getModel().getSortnum() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getSortnum, pageWrap.getModel().getSortnum()); |
| | | } |
| | | if (pageWrap.getModel().getInsuranceId() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getInsuranceId, pageWrap.getModel().getInsuranceId()); |
| | | } |
| | | if (pageWrap.getModel().getValidType() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getValidType, pageWrap.getModel().getValidType()); |
| | | } |
| | | if (pageWrap.getModel().getMinAge() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getMinAge, pageWrap.getModel().getMinAge()); |
| | | } |
| | | if (pageWrap.getModel().getMaxAge() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getMaxAge, pageWrap.getModel().getMaxAge()); |
| | | } |
| | | if (pageWrap.getModel().getSingleWorktype() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getSingleWorktype, pageWrap.getModel().getSingleWorktype()); |
| | | } |
| | | if (pageWrap.getModel().getSpecialAgreement() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getSpecialAgreement, pageWrap.getModel().getSpecialAgreement()); |
| | | } |
| | | if (pageWrap.getModel().getSpecialInfo() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getSpecialInfo, pageWrap.getModel().getSpecialInfo()); |
| | | } |
| | | if (pageWrap.getModel().getOrtherInfo() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getOrtherInfo, pageWrap.getModel().getOrtherInfo()); |
| | | } |
| | | if (pageWrap.getModel().getVersion() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getVersion, pageWrap.getModel().getVersion()); |
| | | } |
| | | if (pageWrap.getModel().getDataType() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getDataType, pageWrap.getModel().getDataType()); |
| | | } |
| | | if (pageWrap.getModel().getBaseId() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getBaseId, pageWrap.getModel().getBaseId()); |
| | | } |
| | | if (pageWrap.getModel().getSignKeyword() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getSignKeyword, pageWrap.getModel().getSignKeyword()); |
| | | } |
| | | if (pageWrap.getModel().getValidTypeNum() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getValidTypeNum, pageWrap.getModel().getValidTypeNum()); |
| | | } |
| | | if (pageWrap.getModel().getShopId() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getShopId, pageWrap.getModel().getShopId()); |
| | | } |
| | | if (pageWrap.getModel().getAddValidDays() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getAddValidDays, pageWrap.getModel().getAddValidDays()); |
| | | } |
| | | if (pageWrap.getModel().getDelValidDays() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getDelValidDays, pageWrap.getModel().getDelValidDays()); |
| | | } |
| | | if (pageWrap.getModel().getCanAdd() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getCanAdd, pageWrap.getModel().getCanAdd()); |
| | | } |
| | | if (pageWrap.getModel().getCanReduce() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getCanReduce, pageWrap.getModel().getCanReduce()); |
| | | } |
| | | if (pageWrap.getModel().getCanChangeUnit() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getCanChangeUnit, pageWrap.getModel().getCanChangeUnit()); |
| | | } |
| | | if (pageWrap.getModel().getDelOnlyReplace() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getDelOnlyReplace, pageWrap.getModel().getDelOnlyReplace()); |
| | | } |
| | | if (pageWrap.getModel().getCompanyName() != null) { |
| | | queryWrapper.lambda().eq(SolutionsBase::getCompanyName, pageWrap.getModel().getCompanyName()); |
| | | } |
| | | |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | return PageData.from(solutionsBaseMapper.selectPage(page, queryWrapper)); |
| | | IPage<SolutionsBase> iPageData = solutionsBaseJoinMapper.selectJoinPage(page,SolutionsBase.class,queryWrapper); |
| | | return PageData.from(iPageData); |
| | | } |
| | | |
| | | @Override |
| | |
| | | QueryWrapper<SolutionsBase> wrapper = new QueryWrapper<>(solutionsBase); |
| | | return solutionsBaseMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void createSolutionBase(Integer solutionId){ |
| | | List<Solutions> solutionsList = solutionsMapper.selectList(new QueryWrapper<Solutions>().lambda() |
| | | .eq(Objects.nonNull(solutionId),Solutions::getId,solutionId) |
| | | .isNull(Solutions::getParentId).eq(Solutions::getDataType,Constants.ZERO).eq(Solutions::getIsdeleted,Constants.ZERO)); |
| | | for (Solutions solutions: solutionsList) { |
| | | SolutionsBase solutionsBase = new SolutionsBase(); |
| | | solutionsBase.setCreator(solutions.getCreator()); |
| | | solutionsBase.setCreateDate(new Date()); |
| | | solutionsBase.setIsdeleted(Constants.ZERO); |
| | | solutionsBase.setName(solutions.getName()); |
| | | solutionsBase.setStatus(solutions.getStatus()); |
| | | solutionsBase.setSortnum(Constants.ZERO); |
| | | solutionsBase.setInsuranceId(solutions.getInsuranceId()); |
| | | solutionsBase.setValidType(solutions.getValidType()); |
| | | solutionsBase.setMinAge(solutions.getMinAge()); |
| | | solutionsBase.setMaxAge(solutions.getMaxAge()); |
| | | solutionsBase.setSingleWorktype(solutions.getSingleWorktype()); |
| | | solutionsBase.setSpecialInfo(solutions.getSpecialInfo()); |
| | | solutionsBase.setSpecialAgreement(solutions.getSpecialAgreement()); |
| | | solutionsBase.setOrtherInfo(solutions.getOrtherInfo()); |
| | | solutionsBase.setDataType(Constants.ZERO); |
| | | solutionsBase.setValidTypeNum(solutions.getValidTypeNum()); |
| | | solutionsBase.setShopId(solutions.getShopId()); |
| | | solutionsBase.setAddValidDays(solutions.getAddValidDays()); |
| | | solutionsBase.setDelValidDays(solutions.getDelValidDays()); |
| | | solutionsBase.setCanAdd(solutions.getCanAdd()); |
| | | solutionsBase.setCanReduce(solutions.getCanReduce()); |
| | | solutionsBase.setCanChangeUnit(solutions.getCanChangeUnit()); |
| | | solutionsBase.setDelOnlyReplace(solutions.getDelOnlyReplace()); |
| | | solutionsBase.setCompanyName(solutions.getCompanyName()); |
| | | solutionsBase.setCompanyName(solutions.getCompanyName()); |
| | | solutionsBase.setCorrectWarnTime("18:30"); |
| | | solutionsBaseMapper.insert(solutionsBase); |
| | | |
| | | |
| | | //如果有工种,则产生一个新的有效历史版本 ~ |
| | | SolutionsBase newModel = new SolutionsBase(); |
| | | BeanUtils.copyProperties(solutionsBase,newModel); |
| | | newModel.setId(null); |
| | | newModel.setBaseId(solutionsBase.getId()); |
| | | newModel.setDataType(Constants.TWO); |
| | | solutionsBaseMapper.insert(newModel); |
| | | |
| | | List<SolutionWorktype> solutionWorktypeList = solutionWorktypeJoinMapper.selectList(new QueryWrapper<SolutionWorktype>().lambda().eq(SolutionWorktype::getType,Constants.ZERO).eq(SolutionWorktype::getSolutionId,solutions.getId())); |
| | | |
| | | Integer num = 1; |
| | | for(SolutionWorktype solutionWorktype : solutionWorktypeList) { |
| | | //基础版本 |
| | | SolutionWorktype w = new SolutionWorktype(); |
| | | w.setSolutionId(solutionsBase.getId()); |
| | | w.setIsdeleted(Constants.ZERO); |
| | | w.setCreator(newModel.getCreator()); |
| | | w.setCreateDate(solutionsBase.getCreateDate()); |
| | | w.setStatus(Constants.ZERO); |
| | | w.setSortnum(num++); |
| | | w.setWorktypeId(solutionWorktype.getWorktypeId()); |
| | | w.setType(Constants.ONE); |
| | | solutionWorktypeJoinMapper.insert(w); |
| | | |
| | | //历史版本的工种信息 |
| | | SolutionWorktype newType = new SolutionWorktype(); |
| | | BeanUtils.copyProperties(w, newType); |
| | | newType.setSolutionId(newModel.getId()); |
| | | solutionWorktypeJoinMapper.insert(newType); |
| | | } |
| | | |
| | | solutionsMapper.update(null,new UpdateWrapper<Solutions>().lambda().set(Solutions::getParentId,solutionsBase.getId()) |
| | | .and(i->i.eq(Solutions::getId,solutions.getId()).or().eq(Solutions::getBaseId,solutions.getId())) |
| | | ); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |