| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.InsuranceMapper; |
| | | import com.doumee.dao.business.SolutionWorktypeMapper; |
| | | import com.doumee.dao.business.SolutionsMapper; |
| | | import com.doumee.dao.business.WorktypeMapper; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.SolutionWorktypeJoinMapper; |
| | | import com.doumee.dao.business.join.SolutionsJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.service.business.CompanyService; |
| | | import com.doumee.service.business.SolutionsService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | private SolutionWorktypeJoinMapper solutionWorktypeJoinMapper; |
| | | @Autowired |
| | | private InsuranceMapper insuranceMapper; |
| | | @Autowired |
| | | private CompanySolutionMapper companySolutionMapper; |
| | | @Autowired |
| | | private DuSolutionMapper duSolutionMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public Integer create(Solutions solutions) { |
| | | LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); |
| | | initCreateParam(solutions);//工种数据有效性检验,去除空白行数据 |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该保险公司信息不存在,请尝试刷新页面重试~" ); |
| | | } |
| | | if( !Constants.equalsInteger(model.getStatus(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该保险公司已被,请尝试刷新页面重试~" ); |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该保险公司已被禁用,请尝试刷新页面重试~" ); |
| | | } |
| | | List<Worktype> worktypeList = worktypeMapper.selectList(new QueryWrapper<Worktype>().lambda() |
| | | .eq(Worktype::getInsuranceId,solutions.getInsuranceId()) |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void updateById(Solutions solutions) { |
| | | LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); |
| | | Solutions model = findById(solutions.getId()); |
| | |
| | | solutions.setVersion(UUID.randomUUID().toString()); |
| | | solutions.setEditDate(new Date()); |
| | | solutionsMapper.updateById(solutions); |
| | | |
| | | Solutions oldVersion = solutionsMapper.selectOne(new QueryWrapper<Solutions>() |
| | | .lambda() |
| | | .eq(Solutions::getBaseId,solutions.getId()) |
| | | .eq(Solutions::getDataType,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | |
| | | |
| | | if(Objects.isNull(oldVersion)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到历史版本数据"); |
| | | } |
| | | |
| | | //如果修改,则产生一个新的历史版本 ~ |
| | | Solutions newModel = new Solutions(); |
| | |
| | | .lambda() |
| | | .eq(SolutionWorktype::getSolutionId,solutions.getId()) |
| | | ); |
| | | |
| | | |
| | | solutionsMapper.update(null,new UpdateWrapper<Solutions>() |
| | | .lambda() |
| | | .ne(Solutions::getId,newModel.getId()) |
| | | .eq(Solutions::getBaseId,solutions.getId()) |
| | | .eq(Solutions::getDataType,Constants.TWO) |
| | | .set(Solutions::getDataType,Constants.ONE) |
| | | .set(StringUtils.isNotBlank(solutions.getSignKeyword()),Solutions::getSignKeyword,solutions.getSignKeyword()) |
| | | ); |
| | | //处理工作信息,新增最新的,同时产生历史版本 |
| | | //处理工种信息,新增最新的,同时产生历史版本 |
| | | dealWorkType(solutions,newModel,solutions.getWorktypeIdList(),false); |
| | | |
| | | //更新company_solution 使用新版本的数据 |
| | | companySolutionMapper.update(null, |
| | | new UpdateWrapper<CompanySolution>() |
| | | .lambda() |
| | | .eq(CompanySolution::getStatus,Constants.ZERO) |
| | | .set(CompanySolution::getSolutionId,newModel.getId()) |
| | | .eq(CompanySolution::getSolutionBaseId,solutions.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 |
| | |
| | | @Override |
| | | public List<Solutions> findList(Solutions solutions) { |
| | | solutions.setIsdeleted(Constants.ZERO); |
| | | solutions.setDataType(Constants.TWO); |
| | | solutions.setStatus(Constants.ZERO); |
| | | if(solutions.getDataType() == null){ |
| | | solutions.setDataType(Constants.TWO); |
| | | } |
| | | QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions); |
| | | return solutionsMapper.selectList(wrapper); |
| | | } |
| | |
| | | if (pageWrap.getModel().getOrtherInfo() != null) { |
| | | queryWrapper.eq(Solutions::getOrtherInfo, pageWrap.getModel().getOrtherInfo()); |
| | | } |
| | | if (pageWrap.getModel().getSolutionBaseId() != null) { |
| | | queryWrapper.eq(Solutions::getSolutionBaseId, pageWrap.getModel().getSolutionBaseId()); |
| | | } |
| | | |
| | | if (pageWrap.getModel().getVersion() != null) { |
| | | queryWrapper.eq(Solutions::getVersion, pageWrap.getModel().getVersion()); |
| | | } |
| | |
| | | } |
| | | } |
| | | PageData<Solutions> pageData = PageData.from(solutionsJoinMapper.selectJoinPage(page,Solutions.class, queryWrapper)); |
| | | |
| | | return pageData; |
| | | } |
| | | @Override |
| | |
| | | return PageData.from(solutionsMapper.selectPage(page, queryWrapper)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Solutions> findListForCompany(Integer dataType) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | List<Solutions> solutionsList = solutionsJoinMapper.selectJoinList(Solutions.class,new MPJLambdaWrapper<Solutions>() |
| | | .selectAll(Solutions.class) |
| | | .leftJoin(CompanySolution.class,CompanySolution::getSolutionId,Solutions::getId) |
| | | .eq(Solutions::getIsdeleted,Constants.ZERO) |
| | | .eq(Solutions::getStatus,Constants.ZERO) |
| | | .eq(Solutions::getDataType,dataType) |
| | | .eq(CompanySolution::getIsdeleted,Constants.ZERO) |
| | | .eq(CompanySolution::getCompanyId,user.getCompanyId()) |
| | | .orderByAsc(Solutions::getSortnum) |
| | | ); |
| | | return solutionsList; |
| | | } |
| | | |
| | | /** |
| | | * 根据历史版本查询当前最新启用版本 |
| | | * @param solutionId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Solutions getNewVersion(Integer solutionId){ |
| | | Solutions solutions = solutionsMapper.selectById(solutionId); |
| | | if(Objects.isNull(solutions)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到历史方案信息"); |
| | | } |
| | | if(solutions.getDataType().equals(Constants.TWO)){ |
| | | return solutions; |
| | | } |
| | | Solutions newVersion = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda() |
| | | .eq(Solutions::getIsdeleted,Constants.ZERO) |
| | | .eq(Solutions::getDataType,Constants.TWO) |
| | | .eq(Solutions::getBaseId,solutions.getBaseId()) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(newVersion)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到最新版本数据"); |
| | | } |
| | | return newVersion; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long count(Solutions solutions) { |
| | | QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions); |