|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | ||solutions.getWorktypeIdList().size()==0 | 
|---|
|  |  |  | ||Constants.formatIntegerNum(solutions.getMaxAge()) < 0 | 
|---|
|  |  |  | ||Constants.formatIntegerNum(solutions.getMinAge()) < 0 | 
|---|
|  |  |  | ||Constants.formatIntegerNum(solutions.getPriceCycleUnit()) < 0 | 
|---|
|  |  |  | //                ||Constants.formatIntegerNum(solutions.getPriceCycleUnit()) < 0 | 
|---|
|  |  |  | ||Constants.formatIntegerNum(solutions.getInsureCycle()) < 0 | 
|---|
|  |  |  | ||Constants.formatIntegerNum(solutions.getInsureCycleUnit()) < 0 | 
|---|
|  |  |  | || solutions.getMinAge() >solutions.getMaxAge() | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //如果修改,则产生一个新的历史版本 ~ | 
|---|
|  |  |  | Solutions newModel = new Solutions(); | 
|---|
|  |  |  | BeanUtils.copyProperties(model,newModel); | 
|---|
|  |  |  | BeanUtils.copyProperties( findById(solutions.getId()),newModel); | 
|---|
|  |  |  | newModel.setId(null); | 
|---|
|  |  |  | newModel.setVersion(solutions.getVersion()); | 
|---|
|  |  |  | newModel.setCreateDate(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | 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) | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Solutions findById(Integer id) { | 
|---|
|  |  |  | Solutions model = solutionsMapper.selectById(id); | 
|---|
|  |  |  | MPJLambdaWrapper<Solutions> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | queryWrapper.selectAll(Solutions.class); | 
|---|
|  |  |  | queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName); | 
|---|
|  |  |  | queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getId,id); | 
|---|
|  |  |  | Solutions model = solutionsJoinMapper.selectJoinOne(Solutions.class,queryWrapper); | 
|---|
|  |  |  | if(model == null  || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Solutions> findList(Solutions solutions) { | 
|---|
|  |  |  | solutions.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | if(solutions.getDataType() == null){ | 
|---|
|  |  |  | solutions.setDataType(Constants.TWO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions); | 
|---|
|  |  |  | return solutionsMapper.selectList(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<Solutions> findPage(PageWrap<Solutions> pageWrap) { | 
|---|
|  |  |  | IPage<Solutions> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | QueryWrapper<Solutions> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | pageWrap.getModel().setDataType(Constants.ZERO);//只选择基表数据 | 
|---|
|  |  |  | pageWrap.getModel().setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | MPJLambdaWrapper<Solutions> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | queryWrapper.selectAll(Solutions.class); | 
|---|
|  |  |  | queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName); | 
|---|
|  |  |  | queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (pageWrap.getModel().getId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getId, pageWrap.getModel().getId()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getId, pageWrap.getModel().getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreator() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getCreator, pageWrap.getModel().getCreator()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getCreator, pageWrap.getModel().getCreator()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreateDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Solutions::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Solutions::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | queryWrapper.ge(Solutions::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | queryWrapper.le(Solutions::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEditor() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getEditor, pageWrap.getModel().getEditor()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getEditor, pageWrap.getModel().getEditor()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEditDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Solutions::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Solutions::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | queryWrapper.ge(Solutions::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | queryWrapper.le(Solutions::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getIsdeleted() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getName() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().like(Solutions::getName, pageWrap.getModel().getName()); | 
|---|
|  |  |  | queryWrapper.like(Solutions::getName, pageWrap.getModel().getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getRemark() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getRemark, pageWrap.getModel().getRemark()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getRemark, pageWrap.getModel().getRemark()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getStatus() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getStatus, pageWrap.getModel().getStatus()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getStatus, pageWrap.getModel().getStatus()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSortnum() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getSortnum, pageWrap.getModel().getSortnum()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getSortnum, pageWrap.getModel().getSortnum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getInsuranceId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getInsuranceId, pageWrap.getModel().getInsuranceId()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getInsuranceId, pageWrap.getModel().getInsuranceId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getValidType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getValidType, pageWrap.getModel().getValidType()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getValidType, pageWrap.getModel().getValidType()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getType, pageWrap.getModel().getType()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getType, pageWrap.getModel().getType()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getMinAge() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getMinAge, pageWrap.getModel().getMinAge()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getMinAge, pageWrap.getModel().getMinAge()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getMaxAge() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getMaxAge, pageWrap.getModel().getMaxAge()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getMaxAge, pageWrap.getModel().getMaxAge()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPrice() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getPrice, pageWrap.getModel().getPrice()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getPrice, pageWrap.getModel().getPrice()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getTimeUnit() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getTimeUnit, pageWrap.getModel().getTimeUnit()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getTimeUnit, pageWrap.getModel().getTimeUnit()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getInsureCycle() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getInsureCycle, pageWrap.getModel().getInsureCycle()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getInsureCycle, pageWrap.getModel().getInsureCycle()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getInsureCycleUnit() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getInsureCycleUnit, pageWrap.getModel().getInsureCycleUnit()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getInsureCycleUnit, pageWrap.getModel().getInsureCycleUnit()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPriceCycleUnit() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getPriceCycleUnit, pageWrap.getModel().getPriceCycleUnit()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getPriceCycleUnit, pageWrap.getModel().getPriceCycleUnit()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSingleWorktype() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getSingleWorktype, pageWrap.getModel().getSingleWorktype()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getSingleWorktype, pageWrap.getModel().getSingleWorktype()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEmail() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getEmail, pageWrap.getModel().getEmail()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getEmail, pageWrap.getModel().getEmail()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSpecialAgreement() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getSpecialAgreement, pageWrap.getModel().getSpecialAgreement()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getSpecialAgreement, pageWrap.getModel().getSpecialAgreement()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSpecialInfo() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getSpecialInfo, pageWrap.getModel().getSpecialInfo()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getSpecialInfo, pageWrap.getModel().getSpecialInfo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getOrtherInfo() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getOrtherInfo, pageWrap.getModel().getOrtherInfo()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getOrtherInfo, pageWrap.getModel().getOrtherInfo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSolutionBaseId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getSolutionBaseId, pageWrap.getModel().getSolutionBaseId()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getSolutionBaseId, pageWrap.getModel().getSolutionBaseId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getVersion() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getVersion, pageWrap.getModel().getVersion()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getVersion, pageWrap.getModel().getVersion()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getDataType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getDataType, pageWrap.getModel().getDataType()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getDataType, pageWrap.getModel().getDataType()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getBaseId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Solutions::getBaseId, pageWrap.getModel().getBaseId()); | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getBaseId, pageWrap.getModel().getBaseId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(solutionsMapper.selectPage(page, queryWrapper)); | 
|---|
|  |  |  | PageData<Solutions> pageData = PageData.from(solutionsJoinMapper.selectJoinPage(page,Solutions.class, queryWrapper)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return pageData; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<Solutions> findPageCom(PageWrap<Solutions> pageWrap) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return PageData.from(solutionsMapper.selectPage(page, queryWrapper)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Solutions> findListForCompany() { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | List<Solutions> solutionsList = solutionsJoinMapper.selectJoinList(Solutions.class,new MPJLambdaWrapper<Solutions>() | 
|---|
|  |  |  | .selectAll(Solutions.class) | 
|---|
|  |  |  | .leftJoin(CompanySolution.class,CompanySolution::getSolutionBaseId,Solutions::getId) | 
|---|
|  |  |  | .eq(Solutions::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Solutions::getDataType,Constants.TWO) | 
|---|
|  |  |  | .eq(CompanySolution::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(CompanySolution::getCompanyId,user.getCompanyId()) | 
|---|
|  |  |  | .orderByAsc(Solutions::getSortnum) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return solutionsList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public long count(Solutions solutions) { | 
|---|
|  |  |  | QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions); | 
|---|