From cdd6551b190b981b807a3b95e9635c559ccc769d Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期一, 19 五月 2025 09:45:07 +0800 Subject: [PATCH] git ch --- server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java | 438 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 400 insertions(+), 38 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java index 8b982d8..e435028 100644 --- a/server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java +++ b/server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java @@ -1,5 +1,6 @@ package com.doumee.service.business.impl; +import com.doumee.biz.system.SystemDictDataBiz; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.model.LoginUserInfo; @@ -7,13 +8,12 @@ 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.dao.system.model.SystemUser; +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; @@ -25,13 +25,11 @@ 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; -import java.util.Date; -import java.util.List; -import java.util.Objects; -import java.util.UUID; +import java.util.*; /** * 淇濋櫓鏂规淇℃伅琛⊿ervice瀹炵幇 @@ -42,6 +40,10 @@ public class SolutionsServiceImpl implements SolutionsService { @Autowired + private SystemDictDataBiz systemDictDataBiz; + @Autowired + private MultifileMapper multifileMapper; + @Autowired private SolutionsMapper solutionsMapper; @Autowired private SolutionsJoinMapper solutionsJoinMapper; @@ -51,18 +53,56 @@ private SolutionWorktypeJoinMapper solutionWorktypeJoinMapper; @Autowired private InsuranceMapper insuranceMapper; + @Autowired + private CompanySolutionMapper companySolutionMapper; + @Autowired + private DuSolutionMapper duSolutionMapper; + @Autowired + private SolutionsBaseMapper solutionsBaseMapper; + @Autowired + private InsuranceApplyMapper insuranceApplyMapper; @Override + @Transactional(rollbackFor = {BusinessException.class,Exception.class}) public Integer create(Solutions solutions) { LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); initCreateParam(solutions);//宸ョ鏁版嵁鏈夋晥鎬ф楠岋紝鍘婚櫎绌虹櫧琛屾暟鎹� - + if(solutionsMapper.selectCount(new QueryWrapper<Solutions>().lambda() + .eq(Solutions::getName,solutions.getName()) + .eq(Solutions::getIsdeleted,Constants.ZERO) + .eq(Solutions::getDataType,Constants.ZERO) + )>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"淇濋櫓鏂规鍚嶇О宸插瓨鍦�"); + } + SolutionsBase solutionsBase = solutionsBaseMapper.selectById(solutions.getParentId()); + if(Objects.isNull(solutionsBase)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌涓绘柟妗堟暟鎹�!"); + } + solutions.setInsuranceId(solutionsBase.getInsuranceId()); + solutions.setCanAdd(solutionsBase.getCanAdd()); + solutions.setCanReduce(solutionsBase.getCanReduce()); + solutions.setCanChangeUnit(solutionsBase.getCanChangeUnit()); + solutions.setAddValidDays(solutionsBase.getAddValidDays()); + solutions.setDelValidDays(solutionsBase.getDelValidDays()); + solutions.setMinAge(solutionsBase.getMinAge()); + solutions.setMaxAge(solutionsBase.getMaxAge()); + solutions.setSpecialInfo(solutionsBase.getSpecialInfo()); + solutions.setSpecialAgreement(solutionsBase.getSpecialAgreement()); + solutions.setOrtherInfo(solutionsBase.getOrtherInfo()); + solutions.setValidType(solutionsBase.getValidType()); + solutions.setValidTypeNum(solutionsBase.getValidTypeNum()); solutions.setIsdeleted(Constants.ZERO); solutions.setCreator(user.getId()); solutions.setCreateDate(new Date()); solutions.setVersion(UUID.randomUUID().toString());//鐗堟湰鍙� solutions.setDataType(Constants.ZERO); solutions.setStatus(Constants.ZERO); + solutions.setCorrectWarnTime(solutionsBase.getCorrectWarnTime()); + solutions.setDelOnlyReplace(solutionsBase.getDelOnlyReplace()); + //2024骞�6鏈�17鏃�15:56:18 浠呮敮鎸佹浛鎹㈡ā寮忎笅锛屾壒澧炴棩鏈� 绛変簬 鎵瑰噺鏃ユ湡 + if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){ + solutions.setAddValidDays(solutions.getDelValidDays()); + } solutionsMapper.insert(solutions);//鍩虹鐗堟湰 //濡傛灉鏈夊伐绉嶏紝鍒欎骇鐢熶竴涓柊鐨勬湁鏁堝巻鍙茬増鏈� ~ @@ -73,8 +113,54 @@ newModel.setDataType(Constants.TWO); solutionsMapper.insert(newModel); - dealWorkType(solutions,newModel,solutions.getWorktypeIdList(),true); + List<SolutionWorktype> worktypes = solutionWorktypeJoinMapper.selectList( + new QueryWrapper<SolutionWorktype>().lambda() + .eq(SolutionWorktype::getSolutionId,solutionsBase.getId()) + .eq(SolutionWorktype::getType,Constants.ONE) + .eq(SolutionWorktype::getIsdeleted,Constants.ZERO) + ); + + dealWorkType(solutions,newModel,worktypes); + + if (solutions.getFanganFile()==null || StringUtils.isBlank(solutions.getFanganFile().getFileurl())){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇蜂笂浼犳柟妗堢‘璁や功锛�"); + } + Multifile file = solutions.getFanganFile(); + file.setIsdeleted(Constants.ZERO); + file.setCreateDate(new Date()); + file.setCreator(user.getId()); + file.setObjId(solutions.getId()); + file.setObjType(Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey()); + file.setType(Constants.formatIntegerNum(file.getType())); + multifileMapper.insert(file); + file.setId(null); + file.setObjId(newModel.getId()); + multifileMapper.insert(file); return solutions.getId(); + } + + private void dealWorkType(Solutions solutions, Solutions newModel, List<SolutionWorktype> worktypes) { + + int num =0; + for(SolutionWorktype type : worktypes) { + //鍩虹鐗堟湰 + SolutionWorktype w = new SolutionWorktype(); + w.setSolutionId(solutions.getId()); + w.setIsdeleted(Constants.ZERO); + w.setCreator(newModel.getCreator()); + w.setCreateDate(solutions.getCreateDate()); + w.setWorktypeId(type.getWorktypeId()); + w.setStatus(Constants.ZERO); + w.setType(Constants.ZERO); + w.setSortnum(num++); + solutionWorktypeJoinMapper.insert(w); + + //鍘嗗彶鐗堟湰鐨勫伐绉嶄俊鎭� + SolutionWorktype newType = new SolutionWorktype(); + BeanUtils.copyProperties(w, newType); + newType.setSolutionId(newModel.getId()); + solutionWorktypeJoinMapper.insert(newType); + } } private void dealWorkType(Solutions solutions, Solutions newModel, List<Integer> worktypeIdList, boolean b) { @@ -84,7 +170,7 @@ 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()) @@ -112,22 +198,23 @@ newType.setSolutionId(newModel.getId()); solutionWorktypeJoinMapper.insert(newType); } - } private void initCreateParam(Solutions solutions) { if(StringUtils.isBlank(solutions.getName()) - ||solutions.getInsuranceId()==null - ||solutions.getWorktypeIdList()==null - ||solutions.getWorktypeIdList().size()==0 - ||Constants.formatIntegerNum(solutions.getMaxAge()) < 0 - ||Constants.formatIntegerNum(solutions.getMinAge()) < 0 + ||Objects.isNull(solutions.getParentId()) + ||Objects.isNull(solutions.getType()) + ||Objects.isNull(solutions.getRetrial()) + ||Objects.isNull(solutions.getFanganFile()) // ||Constants.formatIntegerNum(solutions.getPriceCycleUnit()) < 0 ||Constants.formatIntegerNum(solutions.getInsureCycle()) < 0 ||Constants.formatIntegerNum(solutions.getInsureCycleUnit()) < 0 - || solutions.getMinAge() >solutions.getMaxAge() || Constants.formatBigdecimal(solutions.getPrice()).compareTo(new BigDecimal(0)) !=1 ){ + throw new BusinessException(ResponseStatus.BAD_REQUEST); + } + //濮旀墭鎶曚繚鍔犵鏂瑰紡 + if(Constants.equalsInteger(solutions.getType(),Constants.ONE) && ( Objects.isNull(solutions.getSignType()) || Objects.isNull(solutions.getShopId()))){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } @@ -135,7 +222,22 @@ @Override public void deleteById(Integer id) { - solutionsMapper.deleteById(id); + //鏌ヨ鏄惁宸插瓨鍦ㄤ娇鐢ㄤ腑鐨勪繚鍗� + if(insuranceApplyMapper.selectCount(new QueryWrapper<InsuranceApply>().lambda() + .apply(" solution_id in ( select id from solutions where BASE_ID = "+id+" or id = "+id+" )" ) + .notIn(InsuranceApply::getStatus + ,Constants.InsuranceApplyStatus.PLATFORM_RETURN.getKey() + ,Constants.InsuranceApplyStatus.CLOSE.getKey() + ,Constants.InsuranceApplyStatus.WTB_CLOSED.getKey() + ) + )>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪宸叉姇淇濈殑淇濆崟鏁版嵁,鏃犳硶杩涜鍒犻櫎"); + }; + solutionsMapper.update(null,new UpdateWrapper<Solutions>() + .lambda() + .set(Solutions::getIsdeleted,Constants.ONE) + .and(i->i.eq(Solutions::getId,id).or().eq(Solutions::getBaseId,id)) + ); } @Override @@ -153,6 +255,7 @@ } @Override + @Transactional(rollbackFor = {BusinessException.class,Exception.class}) public void updateById(Solutions solutions) { LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); Solutions model = findById(solutions.getId()); @@ -163,10 +266,43 @@ //鏁版嵁鏈夋晥鎬ф牎楠� initCreateParam(solutions); + //鏌ヨ鏄惁宸插瓨鍦ㄤ娇鐢ㄤ腑鐨勪繚鍗� + if(insuranceApplyMapper.selectCount(new QueryWrapper<InsuranceApply>().lambda() + .apply(" solution_id in ( select id from solutions where BASE_ID = "+solutions.getId()+" or id = "+solutions.getId()+" )" ) + .notIn(InsuranceApply::getStatus + ,Constants.InsuranceApplyStatus.PLATFORM_RETURN.getKey() + ,Constants.InsuranceApplyStatus.CLOSE.getKey() + ,Constants.InsuranceApplyStatus.WTB_CLOSED.getKey() + ) + )>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪宸叉姇淇濈殑淇濆崟鏁版嵁,鏃犳硶杩涜淇敼"); + }; + + solutions.setType(null);//涓嶆敮鎸佷慨鏀规姇淇濇柟妗� + if(solutionsMapper.selectCount(new QueryWrapper<Solutions>().lambda() + .eq(Solutions::getName,solutions.getName()) + .eq(Solutions::getIsdeleted,Constants.ZERO) + .eq(Solutions::getDataType,Constants.ZERO) + .ne(Solutions::getId,solutions.getId()) + )>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"淇濋櫓鏂规鍚嶇О宸插瓨鍦�"); + } solutions.setEditor(user.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(); @@ -178,20 +314,70 @@ newModel.setDataType(Constants.TWO); solutionsMapper.insert(newModel); - //鍒犻櫎鎵�鏈夊伐绉嶆暟鎹� - solutionWorktypeJoinMapper.delete(new UpdateWrapper<SolutionWorktype>() - .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); + + if (solutions.getFanganFile()==null || StringUtils.isBlank(solutions.getFanganFile().getFileurl())){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇蜂笂浼犳柟妗堢‘璁や功锛�"); + } + multifileMapper.update(null,new UpdateWrapper<Multifile>().lambda() + .set(Multifile::getIsdeleted,Constants.ONE) + .set(Multifile::getEditDate,solutions.getEditDate()) + .set(Multifile::getEditor,solutions.getEditor()) + .eq(Multifile::getObjId,solutions.getId()) + .eq(Multifile::getIsdeleted,Constants.ZERO) + .eq(Multifile::getObjType,Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey())); + Multifile file = solutions.getFanganFile(); + file.setIsdeleted(Constants.ZERO); + file.setCreateDate(solutions.getEditDate()); + file.setCreator(solutions.getEditor()); + file.setObjId(solutions.getId()); + file.setObjType(Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey()); + file.setType(Constants.formatIntegerNum(file.getType())); + multifileMapper.insert(file); + file.setObjId(newModel.getId()); + multifileMapper.insert(file); + + //鍒犻櫎鎵�鏈夊伐绉嶆暟鎹� + solutionWorktypeJoinMapper.delete(new UpdateWrapper<SolutionWorktype>() + .lambda() + .eq(SolutionWorktype::getSolutionId,solutions.getId()) + ); + + List<SolutionWorktype> worktypes = solutionWorktypeJoinMapper.selectList( + new QueryWrapper<SolutionWorktype>().lambda() + .eq(SolutionWorktype::getSolutionId,solutions.getParentId()) + .eq(SolutionWorktype::getType,Constants.ONE) + .eq(SolutionWorktype::getIsdeleted,Constants.ZERO) + ); + + dealWorkType(solutions,newModel,worktypes); + + //鏇存柊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 @@ -233,7 +419,12 @@ MPJLambdaWrapper<Solutions> queryWrapper = new MPJLambdaWrapper<>(); queryWrapper.selectAll(Solutions.class); queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName); + queryWrapper.selectAs(Company::getName,Solutions::getShopName); + queryWrapper.selectAs(SolutionsBase::getName,Solutions::getSolutionBaseName); queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId); + queryWrapper.leftJoin(Company.class,Company::getId,Solutions::getShopId); + queryWrapper.leftJoin(SolutionsBase.class,SolutionsBase::getId,Solutions::getParentId); + queryWrapper.eq(Solutions::getId,id); Solutions model = solutionsJoinMapper.selectJoinOne(Solutions.class,queryWrapper); if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){ @@ -248,6 +439,16 @@ wrapper.orderByAsc(SolutionWorktype::getSortnum); List<SolutionWorktype> worktypeList = solutionWorktypeJoinMapper.selectJoinList(SolutionWorktype.class,wrapper); model.setWorktypeList(worktypeList); + Multifile f = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda() + .eq(Multifile::getObjId,model.getId()) + .eq(Multifile::getObjType,Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey()) + .eq(Multifile::getIsdeleted,Constants.ZERO) + .last("limit 1")); + if(f!=null && StringUtils.isNotBlank(f.getFileurl())){ + String url = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode()+f.getFileurl(); + f.setFileurlFull(url); + model.setFanganFile(f);//鏂规纭涔� + } return model; } @@ -259,29 +460,69 @@ @Override public List<Solutions> findList(Solutions solutions) { + LoginUserInfo user = (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); solutions.setIsdeleted(Constants.ZERO); - solutions.setDataType(Constants.TWO); + solutions.setStatus(Objects.nonNull(solutions.getStatus())?solutions.getStatus():null); + if(solutions.getDataType() == null){ + solutions.setDataType(Constants.TWO); + } QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions); + if(Constants.equalsObject(user.getType(),Constants.TWO)){ + //濡傛灉鏄垹闄� +// wrapper.lambda().exists("select c.id from company_solution c left join solutions d on c.solution_id=d.id where c.isdeleted=0 and d.base_id=solutions.base_id and c.shop_id="+user.getCompanyId());//璁剧疆鏃犳晥璁块棶 + wrapper.apply("((solutions.type=0 and exists(select cs.id from company_solution cs left join solutions s on cs.solution_id=s.id " + + " where cs.isdeleted=0 and cs.SIGN_STATUS = 1 and s.base_id=solutions.base_id and cs.shop_id="+user.getCompanyId()+")) or (" + + "solutions.type=1 and solutions.shop_id="+user.getCompanyId()+"))") ; + } return solutionsMapper.selectList(wrapper); } @Override public PageData<Solutions> findPage(PageWrap<Solutions> pageWrap) { + + LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); IPage<Solutions> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); 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(user.getType().equals(Constants.ONE)){ + queryWrapper.selectAll(Solutions.class); + queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName); + queryWrapper.selectAs(Company::getName,Solutions::getShopName); + queryWrapper.selectAs(SolutionsBase::getName,Solutions::getSolutionBaseName); + queryWrapper.selectAs(CompanySolution::getSignDate,Solutions::getSignDate); + queryWrapper.selectAs(CompanySolution::getSignStatus,Solutions::getSignStatus); + queryWrapper.selectAs(CompanySolution::getFileSignUrl,Solutions::getFileSignUrl); + queryWrapper.selectAs(CompanySolution::getId,Solutions::getCompanySolutionId); + queryWrapper.selectAs(SystemUser::getRealname,Solutions::getSignUserName); + queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId); + queryWrapper.leftJoin(Company.class,Company::getId,Solutions::getShopId); + queryWrapper.leftJoin(SolutionsBase.class,SolutionsBase::getId,Solutions::getParentId); + queryWrapper.leftJoin(CompanySolution.class,CompanySolution::getSolutionBaseId,Solutions::getId); + queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,CompanySolution::getSignUserId); + queryWrapper.eq(CompanySolution::getCompanyId,user.getCompanyId()); + queryWrapper.eq(CompanySolution::getIsdeleted,Constants.ZERO); + }else{ + queryWrapper.selectAll(Solutions.class); + queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName); + queryWrapper.selectAs(Company::getName,Solutions::getShopName); + queryWrapper.selectAs(SolutionsBase::getName,Solutions::getSolutionBaseName); + queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId); + queryWrapper.leftJoin(Company.class,Company::getId,Solutions::getShopId); + queryWrapper.leftJoin(SolutionsBase.class,SolutionsBase::getId,Solutions::getParentId); + + } if (pageWrap.getModel().getId() != null) { queryWrapper.eq(Solutions::getId, pageWrap.getModel().getId()); } if (pageWrap.getModel().getCreator() != null) { queryWrapper.eq(Solutions::getCreator, pageWrap.getModel().getCreator()); + } + if (pageWrap.getModel().getSignStatus() != null) { + queryWrapper.eq(CompanySolution::getSignStatus, pageWrap.getModel().getSignStatus()); } if (pageWrap.getModel().getCreateDate() != null) { queryWrapper.ge(Solutions::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); @@ -354,9 +595,10 @@ 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().getParentId() != null) { + queryWrapper.eq(Solutions::getParentId, pageWrap.getModel().getParentId()); } + if (pageWrap.getModel().getVersion() != null) { queryWrapper.eq(Solutions::getVersion, pageWrap.getModel().getVersion()); } @@ -366,14 +608,23 @@ if (pageWrap.getModel().getBaseId() != null) { queryWrapper.eq(Solutions::getBaseId, pageWrap.getModel().getBaseId()); } - for(PageWrap.SortData sortData: pageWrap.getSorts()) { - if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { - queryWrapper.orderByDesc(sortData.getProperty()); - } else { - queryWrapper.orderByAsc(sortData.getProperty()); + queryWrapper.orderByDesc(Solutions::getCreateDate); +// for(PageWrap.SortData sortData: pageWrap.getSorts()) { +// if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { +// queryWrapper.orderByDesc(sortData.getProperty()); +// } else { +// queryWrapper.orderByAsc(sortData.getProperty()); +// } +// } + String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ + systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode(); + PageData<Solutions> pageData = PageData.from(solutionsJoinMapper.selectJoinPage(page,Solutions.class, queryWrapper)); + for (Solutions solutions:pageData.getRecords()) { + if(StringUtils.isNotBlank(solutions.getFileSignUrl())){ + solutions.setFileSignUrl(path +solutions.getFileSignUrl()); } } - PageData<Solutions> pageData = PageData.from(solutionsJoinMapper.selectJoinPage(page,Solutions.class, queryWrapper)); + return pageData; } @Override @@ -405,6 +656,104 @@ 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) + .leftJoin(Company.class,Company::getId,CompanySolution::getCompanyId) + .leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId) + .leftJoin(SolutionsBase.class,SolutionsBase::getId,Solutions::getParentId) + .eq(Solutions::getIsdeleted,Constants.ZERO) + .eq(Solutions::getStatus,Constants.ZERO) + .eq(Solutions::getDataType,dataType) + .eq(CompanySolution::getIsdeleted,Constants.ZERO) + .eq(CompanySolution::getCompanyId,user.getCompanyId()) + .eq(Company::getIsdeleted,Constants.ZERO) + .eq(Company::getStatus,Constants.ZERO) + .eq(Insurance::getIsdeleted,Constants.ZERO) + .eq(Insurance::getStatus,Constants.ZERO) + .eq(SolutionsBase::getStatus,Constants.ZERO) + .eq(SolutionsBase::getIsdeleted,Constants.ZERO) + .orderByDesc(Solutions::getCreateDate) + ); + return solutionsList; + } + + /** + * 鏌ヨ浼佷笟宸茬缃茬殑鏂规淇℃伅 + * @param dataType + * @param companyId + * @return + */ + @Override + public List<Solutions> findListByCompanyId(Integer dataType,Integer companyId) { + 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) +// .leftJoin(Company.class,Company::getId,CompanySolution::getCompanyId) +// .leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId) +// .leftJoin(SolutionsBase.class,SolutionsBase::getId,Solutions::getParentId) +// .eq(Solutions::getIsdeleted,Constants.ZERO) +// .eq(Solutions::getStatus,Constants.ZERO) +// .eq(Solutions::getDataType,dataType) +// .eq(CompanySolution::getIsdeleted,Constants.ZERO) +// .eq(Company::getIsdeleted,Constants.ZERO) +// .eq(Company::getStatus,Constants.ZERO) +// .eq(Insurance::getIsdeleted,Constants.ZERO) +// .eq(Insurance::getStatus,Constants.ZERO) +// .eq(SolutionsBase::getStatus,Constants.ZERO) +// .eq(SolutionsBase::getIsdeleted,Constants.ZERO) +// .eq(CompanySolution::getCompanyId,companyId) +// .eq(CompanySolution::getSignStatus,Constants.ONE) +// .orderByDesc(Solutions::getCreateDate) +// ); + + 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,companyId) + .eq(CompanySolution::getSignStatus,Constants.ONE) + .orderByDesc(Solutions::getCreateDate) + ); + 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); @@ -412,5 +761,18 @@ } + @Override + public BigDecimal testSolutionAddMoney(Integer id, BigDecimal fee, Date start,Date end,Date newDate,Date newEndTime){ + return Constants.addFee(solutionsMapper.selectById(id),fee,start,end,newDate,newEndTime); + } + @Override + public BigDecimal testSolutionReduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date reduceStartTime,Date reduceEndTime){ + return Constants.reduceFee(solutionsMapper.selectById(id),fee,start,end,reduceStartTime,reduceEndTime); + } + + @Override + public BigDecimal testSolutionProduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date produceStart){ + return Constants.produceFee(solutionsMapper.selectById(id),fee,start,end,produceStart); + } } -- Gitblit v1.9.3