From 49864198306482dc8c28a519ba7291cfe3a6f562 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 01 四月 2024 15:56:32 +0800
Subject: [PATCH] git ch
---
server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java | 125 ++++++++++++++++++++++++++++++++---------
1 files changed, 98 insertions(+), 27 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
index 04b339c..e9de07d 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
@@ -10,15 +10,14 @@
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.Utils;
-import com.doumee.dao.business.CompanyMapper;
-import com.doumee.dao.business.MultifileMapper;
-import com.doumee.dao.business.SolutionsMapper;
-import com.doumee.dao.business.UnionApplyMapper;
+import com.doumee.dao.business.*;
import com.doumee.dao.business.dto.*;
import com.doumee.dao.business.join.ApplyDetailJoinMapper;
+import com.doumee.dao.business.join.ApplyLogJoinMapper;
import com.doumee.dao.business.join.InsuranceApplyJoinMapper;
import com.doumee.dao.business.join.UnionApplyJoinMapper;
import com.doumee.dao.business.model.*;
+import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.SmsEmailService;
import com.doumee.service.business.UnionApplyService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -80,6 +79,10 @@
@Autowired
private SmsEmailService smsEmailService;
+ @Autowired
+ private ApplyLogMapper applyLogMapper;
+ @Autowired
+ private ApplyLogJoinMapper applyLogJoinMapper;
@Value("${debug_model}")
private boolean debugModel;
@@ -147,13 +150,18 @@
MPJLambdaWrapper<UnionApply> queryWrapper = new MPJLambdaWrapper<>();
Utils.MP.blankToNull(pageWrap.getModel());
queryWrapper.selectAll(UnionApply.class);
+ queryWrapper.selectAs(Solutions::getName,UnionApply::getSolutionName);
+ queryWrapper.select("(select count(b.id) from apply_detail b where b.isdeleted=0 and b.union_apply_id=t.id) as insureNum ");
queryWrapper.leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId);
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
- if(user.getType().equals(Constants.TWO)){
- queryWrapper.eq(UnionApply::getCompanyId, pageWrap.getModel().getCompanyId());
+ if(Constants.equalsInteger(user.getType(),Constants.TWO)){
+ queryWrapper.eq(UnionApply::getCompanyId, user.getCompanyId());
}
if (pageWrap.getModel().getId() != null) {
queryWrapper.eq(UnionApply::getId, pageWrap.getModel().getId());
+ }
+ if (pageWrap.getModel().getSolutionId() != null) {
+ queryWrapper.eq(UnionApply::getSolutionId, pageWrap.getModel().getSolutionId());
}
if (pageWrap.getModel().getCreator() != null) {
queryWrapper.eq(UnionApply::getCreator, pageWrap.getModel().getCreator());
@@ -219,14 +227,18 @@
}
if (pageWrap.getModel().getSignApplyNo() != null) {
queryWrapper.eq(UnionApply::getSignApplyNo, pageWrap.getModel().getSignApplyNo());
- }
- for(PageWrap.SortData sortData: pageWrap.getSorts()) {
- if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
- queryWrapper.orderByDesc(sortData.getProperty());
- } else {
- queryWrapper.orderByAsc(sortData.getProperty());
+ }if(pageWrap.getSorts().size() == 0){
+ queryWrapper.orderByDesc(UnionApply::getCreateDate );
+ }else {
+ for(PageWrap.SortData sortData: pageWrap.getSorts()) {
+ if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
+ queryWrapper.orderByDesc(sortData.getProperty());
+ } else {
+ queryWrapper.orderByAsc(sortData.getProperty());
+ }
}
}
+
PageData<UnionApply> pageData = PageData.from(unionApplyJoinMapper.selectJoinPage(page,UnionApply.class, queryWrapper));
return pageData;
}
@@ -266,6 +278,21 @@
unionApply.setServiceDays(DateUtil.daysBetweenDates(new Date(),unionApply.getStartTime())+1);
}
}
+
+ //鏌ヨ鎿嶄綔璁板綍
+ List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class,
+ new MPJLambdaWrapper<ApplyLog>()
+ .selectAll(ApplyLog.class)
+ .selectAs(SystemUser::getRealname,ApplyLog::getCreatorName)
+ .selectAs(Company::getName,ApplyLog::getCompanyName)
+ .selectAs(SystemUser::getType,ApplyLog::getCreatorType)
+ .leftJoin(SystemUser.class,SystemUser::getId,ApplyLog::getCreator)
+ .leftJoin(Company.class,Company::getId,SystemUser::getCompanyId)
+ .in(ApplyLog::getObjType,Constants.ApplyLogType.getTypeList(Constants.THREE))
+ .eq(ApplyLog::getApplyId,unionApply.getId())
+ .orderByAsc(ApplyLog::getCreateDate)
+ );
+ unionApply.setApplyLogList(applyLogList);
return unionApply;
}
@@ -273,6 +300,7 @@
@Override
+ @Transactional(rollbackFor ={BusinessException.class,Exception.class} )
public Integer merge(SaveUnionApplyDTO saveUnionApplyDTO){
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
if(!user.getType().equals(Constants.TWO)){
@@ -280,16 +308,27 @@
}
if(Objects.isNull(saveUnionApplyDTO)
|| Objects.isNull(saveUnionApplyDTO.getApplyIds())
+ || saveUnionApplyDTO.getApplyIds().size() == 0
|| Objects.isNull(saveUnionApplyDTO.getStartDate())
|| Objects.isNull(saveUnionApplyDTO.getEndDate())
+ || saveUnionApplyDTO.getStartDate().getTime()>saveUnionApplyDTO.getEndDate().getTime()
|| Objects.isNull(saveUnionApplyDTO.getBaseSolutionId())
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
+ Solutions solutions = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().
+ eq(Solutions::getType,Constants.ONE)
+ .eq(Solutions::getIsdeleted,Constants.ZERO)
+ .eq(Solutions::getDataType,Constants.ZERO)
+ .eq(Solutions::getBaseId,saveUnionApplyDTO.getBaseSolutionId()));
+ //鏌ヨ鏂规鏁版嵁
+ if(solutions == null){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝鏂规淇℃伅鏈夎锛岃鍒锋柊椤甸潰閲嶈瘯");
+ }
List<InsuranceApply> insuranceApplyList = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class,
new MPJLambdaWrapper<InsuranceApply>()
.selectAll(InsuranceApply.class)
- .selectAs(InsuranceApply::getSolutionBaseId,Solutions::getBaseId)
+ .selectAs(Solutions::getBaseId,InsuranceApply::getSolutionBaseId)
.leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
.eq(InsuranceApply::getIsdeleted, Constants.ZERO)
.eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_BUSINESS_CHECK_PASS.getKey())
@@ -312,11 +351,19 @@
unionApply.setStatus(Constants.UnionApplyStatus.MERGE.getKey());
unionApply.setCheckUserId(user.getId());
unionApply.setCurrentFee(BigDecimal.ZERO);
+ unionApply.setIsdeleted(Constants.ZERO);
+ unionApply.setSolutionId(solutions.getId());
Integer maxDays = DateUtil.calculateBetween(saveUnionApplyDTO.getStartDate(),saveUnionApplyDTO.getEndDate(),0);
- List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().select(ApplyDetail::getPrice)
- .in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds()));
- unionApply.setFee(applyDetailList.stream().map(i->i.getPrice().multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add));
+
+ List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().select(ApplyDetail::getId,ApplyDetail::getPrice)
+ .in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds())
+ .eq(ApplyDetail::getIsdeleted,Constants.ZERO));
+ if(applyDetailList.size()==0){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝瀛樺湪濮旀墭鎶曚繚鐢宠璁板綍淇℃伅鏈夎锛岃杩斿洖鏌ョ湅鐢宠浜哄憳鏄惁涓虹┖锛�");
+ }
+ unionApply.setFee(applyDetailList.stream().map(i->Constants.formatBigdecimal(i.getPrice()).multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add));
+
unionApplyMapper.insert(unionApply);
insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda()
@@ -330,6 +377,13 @@
.set(ApplyDetail::getUnionApplyId,unionApply.getId())
.in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds()));
+
+
+ Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_UPLOAD;
+ ApplyLog log = new ApplyLog(unionApply,applyLogType.getName(), null
+ ,unionApply.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionApply));
+ applyLogMapper.insert(log);
+
return unionApply.getId();
}
@@ -337,16 +391,19 @@
/**
* 鍙栨秷淇濆崟鍚堝苟
- * @param id
+ * @param closeDTO
*/
@Override
@Transactional(rollbackFor = {Exception.class,BusinessException.class})
- public void cancelMerge(Integer id){
+ public void cancelMerge(CloseDTO closeDTO){
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
if(!user.getType().equals(Constants.TWO)){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
}
- UnionApply unionApply = unionApplyMapper.selectById(id);
+ if(Objects.isNull(closeDTO)||Objects.isNull(closeDTO.getId())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ UnionApply unionApply = unionApplyMapper.selectById(closeDTO.getId());
if(Objects.isNull(unionApply)||!Constants.equalsInteger(unionApply.getIsdeleted(),Constants.ZERO)){
throw new BusinessException(ResponseStatus.DATA_EMPTY);
}
@@ -382,6 +439,16 @@
.set(UnionApply::getStatus,Constants.UnionApplyStatus.CLOSE.getKey())
.eq(UnionApply::getId,unionApply.getId())
);
+
+
+ Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_CLOSE;
+ String info =applyLogType.getInfo();
+ info = info.replace("${param}", closeDTO.getReason());
+ ApplyLog log = new ApplyLog(unionApply,applyLogType.getName(), info
+ ,unionApply.getId(),applyLogType.getKey(),null, null);
+ applyLogMapper.insert(log);
+
+ applyLogMapper.insert(log);
}
@@ -464,16 +531,11 @@
multifile.setFileurl(uploadMultifileDTO.getFileurl());
multifile.setName(uploadMultifileDTO.getName());
multifileMapper.insert(multifile);
-
-
-
-
}
/**
* 鍚堝苟鍗� - 鎶曚繚鐢宠绛剧讲
- * @param id
* @return
*/
@Override
@@ -679,10 +741,19 @@
multifile.setName(unionApplyBXDDTO.getFileName());
multifileMapper.insert(multifile);
}
+
+ Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_UPLOAD_TBD;
+ String info = "";
+ if(Objects.nonNull(unionApplyBXDDTO.getStartTime())&&Objects.nonNull(unionApplyBXDDTO.getEndTime())){
+ info =applyLogType.getInfo();
+ info = info.replace("${param1}",DateUtil.getPlusTime2(unionApplyBXDDTO.getStartTime()));
+ info = info.replace("${param2}",DateUtil.getPlusTime2(unionApplyBXDDTO.getEndTime()));
+ }
+ ApplyLog log = new ApplyLog(unionApply,applyLogType.getName(), info
+ ,unionApply.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionApply));
+ applyLogMapper.insert(log);
+
}
-
-
-
}
--
Gitblit v1.9.3