From e74241a0043eed1b6ce3dd022095fa5d5b700382 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 03 四月 2024 18:04:36 +0800
Subject: [PATCH] git ch
---
server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java | 183 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 161 insertions(+), 22 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 2992c58..2b7c1ed 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,10 +8,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,13 +24,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瀹炵幇
@@ -43,6 +39,10 @@
public class SolutionsServiceImpl implements SolutionsService {
@Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+ @Autowired
+ private MultifileMapper multifileMapper;
+ @Autowired
private SolutionsMapper solutionsMapper;
@Autowired
private SolutionsJoinMapper solutionsJoinMapper;
@@ -52,11 +52,25 @@
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);//宸ョ鏁版嵁鏈夋晥鎬ф楠岋紝鍘婚櫎绌虹櫧琛屾暟鎹�
+
+
+ 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(),"淇濋櫓鏂规鍚嶇О宸插瓨鍦�");
+ }
solutions.setIsdeleted(Constants.ZERO);
solutions.setCreator(user.getId());
@@ -75,6 +89,22 @@
solutionsMapper.insert(newModel);
dealWorkType(solutions,newModel,solutions.getWorktypeIdList(),true);
+ if(Constants.equalsObject(solutions.getType(),Constants.ONE) ){
+ 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.setObjId(newModel.getId());
+ multifileMapper.insert(file);
+ }
return solutions.getId();
}
@@ -85,7 +115,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 +184,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,11 +194,30 @@
}
//鏁版嵁鏈夋晥鎬ф牎楠�
initCreateParam(solutions);
-
+ 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();
@@ -184,6 +234,28 @@
.lambda()
.eq(SolutionWorktype::getSolutionId,solutions.getId())
);
+ if(Constants.equalsObject(solutions.getType(),Constants.ONE) ){
+ if (solutions.getFanganFile()!=null && StringUtils.isNotBlank(solutions.getFanganFile().getFileurl())){
+ 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);
+ }
+ }
+
solutionsMapper.update(null,new UpdateWrapper<Solutions>()
.lambda()
.ne(Solutions::getId,newModel.getId())
@@ -192,8 +264,25 @@
.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
@@ -235,7 +324,9 @@
MPJLambdaWrapper<Solutions> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(Solutions.class);
queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName);
+ queryWrapper.selectAs(Company::getName,Solutions::getShopName);
queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId);
+ queryWrapper.leftJoin(Company.class,Company::getId,Solutions::getShopId);
queryWrapper.eq(Solutions::getId,id);
Solutions model = solutionsJoinMapper.selectJoinOne(Solutions.class,queryWrapper);
if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
@@ -250,6 +341,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;
}
@@ -261,11 +362,18 @@
@Override
public List<Solutions> findList(Solutions solutions) {
+ LoginUserInfo user = (LoginUserInfo)SecurityUtils.getSubject().getPrincipal();
solutions.setIsdeleted(Constants.ZERO);
+ solutions.setStatus(Constants.ZERO);
if(solutions.getDataType() == null){
solutions.setDataType(Constants.TWO);
}
+ if(Constants.equalsObject(user.getType(),Constants.TWO)){
+ //濡傛灉鏄垹闄�
+ solutions.setShopId(user.getCompanyId());
+ }
QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions);
+
return solutionsMapper.selectList(wrapper);
}
@@ -279,8 +387,13 @@
Utils.MP.blankToNull(pageWrap.getModel());
queryWrapper.selectAll(Solutions.class);
queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName);
+ queryWrapper.selectAs(Company::getName,Solutions::getShopName);
queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId);
-
+ queryWrapper.leftJoin(Company.class,Company::getId,Solutions::getShopId);
+ LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ if(user.getType().equals(Constants.ONE)){
+ queryWrapper.exists(("select 1 from company_solution b where b.isdeleted=0 and b.company_id="+user.getCompanyId()+" and b.SOLUTION_BASE_ID = t.id"));
+ }
if (pageWrap.getModel().getId() != null) {
queryWrapper.eq(Solutions::getId, pageWrap.getModel().getId());
}
@@ -358,9 +471,7 @@
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());
}
@@ -412,24 +523,52 @@
@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)
+ .leftJoin(Company.class,Company::getId,CompanySolution::getCompanyId)
+ .leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId)
.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())
+ .eq(Company::getIsdeleted,Constants.ZERO)
+ .eq(Company::getStatus,Constants.ZERO)
+ .eq(Insurance::getIsdeleted,Constants.ZERO)
+ .eq(Insurance::getStatus,Constants.ZERO)
.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
--
Gitblit v1.9.3