From deb3baf0fb04c3a9f5b0d4b5bd9fb3237908d576 Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期一, 19 二月 2024 18:38:12 +0800 Subject: [PATCH] 111 --- server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java | 81 ++++++++++++++++++++++++++++++++++------ 1 files changed, 69 insertions(+), 12 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 97467cd..75e4954 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 @@ -7,10 +7,7 @@ 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.*; @@ -26,6 +23,7 @@ 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; @@ -52,8 +50,13 @@ 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);//宸ョ鏁版嵁鏈夋晥鎬ф楠岋紝鍘婚櫎绌虹櫧琛屾暟鎹� @@ -85,7 +88,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()) @@ -154,6 +157,7 @@ } @Override + @Transactional(rollbackFor = {BusinessException.class,Exception.class}) public void updateById(Solutions solutions) { LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); Solutions model = findById(solutions.getId()); @@ -168,6 +172,18 @@ 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(); @@ -184,6 +200,8 @@ .lambda() .eq(SolutionWorktype::getSolutionId,solutions.getId()) ); + + solutionsMapper.update(null,new UpdateWrapper<Solutions>() .lambda() .ne(Solutions::getId,newModel.getId()) @@ -194,6 +212,23 @@ ); //澶勭悊宸ョ淇℃伅锛屾柊澧炴渶鏂扮殑锛屽悓鏃朵骇鐢熷巻鍙茬増鏈� 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 @@ -411,13 +446,14 @@ @Override - public List<Solutions> findListForCompany() { + 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::getSolutionBaseId,Solutions::getId) + .leftJoin(CompanySolution.class,CompanySolution::getSolutionId,Solutions::getId) .eq(Solutions::getIsdeleted,Constants.ZERO) - .eq(Solutions::getDataType,Constants.TWO) + .eq(Solutions::getStatus,Constants.ZERO) + .eq(Solutions::getDataType,dataType) .eq(CompanySolution::getIsdeleted,Constants.ZERO) .eq(CompanySolution::getCompanyId,user.getCompanyId()) .orderByAsc(Solutions::getSortnum) @@ -425,10 +461,31 @@ 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 -- Gitblit v1.9.3