|
@@ -1,10 +1,12 @@
|
|
|
package com.dayou.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.dayou.entity.BusinessProductionChoiceLog;
|
|
|
-import com.dayou.entity.OrderFund;
|
|
|
-import com.dayou.service.IBusinessProductionChoiceLogService;
|
|
|
-import com.dayou.service.IOrderFundService;
|
|
|
+import com.dayou.entity.*;
|
|
|
+import com.dayou.enums.GlobalConfigEnum;
|
|
|
+import com.dayou.enums.MainBusinessEnum;
|
|
|
+import com.dayou.service.*;
|
|
|
import com.dayou.utils.LoginContext;
|
|
|
import com.dayou.vo.AssetsRepertoryVo;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@@ -12,15 +14,11 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.dayou.common.BaseEntity;
|
|
|
import com.dayou.dto.*;
|
|
|
-import com.dayou.entity.Assets;
|
|
|
-import com.dayou.entity.BusinessNumber;
|
|
|
import com.dayou.exception.ErrorCode;
|
|
|
import com.dayou.mapper.AssetsEvaluationTargetMapper;
|
|
|
import com.dayou.mapper.AssetsMapper;
|
|
|
import com.dayou.mapper.AssetsProductionMapper;
|
|
|
-import com.dayou.service.IAssetsService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.dayou.service.IBusinessNumberService;
|
|
|
import com.dayou.service.workflow.IWorkFlowService;
|
|
|
import com.dayou.vo.AssetsBusinessMember;
|
|
|
import com.dayou.vo.AssetsOrderFundInvoiceVO;
|
|
@@ -32,12 +30,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.dayou.common.Constants.BY_TURNS;
|
|
|
import static com.dayou.enums.MainBusinessEnum.ASSET_BUSINESS;
|
|
|
import static com.dayou.enums.ProductionEnum.*;
|
|
|
|
|
@@ -73,6 +71,12 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
@Autowired
|
|
|
private IBusinessProductionChoiceLogService choiceLogService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGlobalConfigService globalConfigService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISortedDepartmentService sortedDepartmentService;
|
|
|
+
|
|
|
/**
|
|
|
* 条件查询资产任务列表
|
|
|
*
|
|
@@ -166,6 +170,11 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
public WorkNodeCommit add(Assets assets) {
|
|
|
//获取项目编号
|
|
|
assets.setOrderId(businessNumberService.takeOrderNumber());
|
|
|
+ // 判断分单类型
|
|
|
+ if (BY_TURNS.equals(assets.getAllotType())){
|
|
|
+ //获取轮单部门
|
|
|
+ assets.setDepartmentId(getAllotDepartmentId());
|
|
|
+ }
|
|
|
//新增订单信息
|
|
|
this.save(assets);
|
|
|
//新增订单收款信息
|
|
@@ -230,26 +239,60 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
|
|
|
// 取号时更新产品选择记录状态
|
|
|
List<BusinessProductionChoiceLog> choiceLogList = new ArrayList<>();
|
|
|
+ // 循环取号的评估对象id集合
|
|
|
for (Long targetId : dto.getTargetIdList()){
|
|
|
+ // 获取每一个取号评估对象的产品选择记录(同一个评估对象不可能同时存在两条状态为未取号的产品选择记录)
|
|
|
BusinessProductionChoiceLog choiceLog = choiceLogService.getOne(new LambdaQueryWrapper<BusinessProductionChoiceLog>()
|
|
|
.eq(BusinessProductionChoiceLog::getTargetId, targetId)
|
|
|
.eq(BusinessProductionChoiceLog::getBusinessType, "ASSET_BUSINESS")
|
|
|
.eq(BusinessProductionChoiceLog::getBusinessId, dto.getBusinessId())
|
|
|
.eq(BusinessProductionChoiceLog::getTakeNoStatus, 0));
|
|
|
+ // 已取号的评估对象产品选择记录取号状态改为true
|
|
|
choiceLog.setTakeNoStatus(true);
|
|
|
+ // 获取后将选择记录状态改为true并添加集合用于后续批量更新
|
|
|
choiceLogList.add(choiceLog);
|
|
|
}
|
|
|
- choiceLogService.updateBatchById(choiceLogList);
|
|
|
+
|
|
|
+ // 获取产品选择记录的相关信息,并设置到dto(同一流程的所有评估对象只能选择同一种产品类型,所以此处直接下标获取)
|
|
|
dto.setPrintCount(choiceLogList.get(0).getPrintCount());
|
|
|
dto.setProductionType(choiceLogList.get(0).getProductionType());
|
|
|
String productionNo = genProductionNo(dto);
|
|
|
- //产品添加产品号
|
|
|
- assetsProductionMapper.updateProductionNo(dto.getBusinessId(), dto.getProductionType(), productionNo);
|
|
|
- //如果还有未取号评估对象,再添加一份同类型产品
|
|
|
+
|
|
|
+ //产品信息更新添加产品号
|
|
|
+ assetsProductionMapper.updateProductionNo(choiceLogList.get(0).getProductionId(), dto.getBusinessId(), dto.getProductionType(), productionNo);
|
|
|
+
|
|
|
+ //如果还有未取号评估对象
|
|
|
if (dto.getHasNotTakeNumTargetSelect()) {
|
|
|
- assetsProductionMapper.copyProductionInfo(dto.getBusinessId(), dto.getProductionType(), dto.getPrintCount());
|
|
|
+ // 有未取号对象,添加一份同类型产品
|
|
|
+ AssetsProduction copyProductionInfo = new AssetsProduction();
|
|
|
+ copyProductionInfo.setBusinessId(dto.getBusinessId());
|
|
|
+ copyProductionInfo.setProductionType(dto.getProductionType());
|
|
|
+ copyProductionInfo.setPrintCount(dto.getPrintCount());
|
|
|
+ assetsProductionMapper.copyProductionInfo(copyProductionInfo);
|
|
|
+ // 获取未取号的评估对象id
|
|
|
+ List<Long> unTakeNoTargetIdList = targetIdListDifference(dto.getAllTargetIdList(), dto.getTargetIdList());
|
|
|
+
|
|
|
+ // 将未取号对象的产品选择记录对应的产品id更新
|
|
|
+ if (ObjectUtil.isNotNull(unTakeNoTargetIdList) && ObjectUtil.isNotEmpty(unTakeNoTargetIdList)){
|
|
|
+ for (Long targetId : unTakeNoTargetIdList){
|
|
|
+ // 获取每一个未评估对象的产品选择记录(同一个评估对象不可能同时存在两条状态为未取号的产品选择记录)
|
|
|
+ BusinessProductionChoiceLog choiceLog = choiceLogService.getOne(new LambdaQueryWrapper<BusinessProductionChoiceLog>()
|
|
|
+ .eq(BusinessProductionChoiceLog::getTargetId, targetId)
|
|
|
+ .eq(BusinessProductionChoiceLog::getBusinessType, "ASSET_BUSINESS")
|
|
|
+ .eq(BusinessProductionChoiceLog::getBusinessId, dto.getBusinessId())
|
|
|
+ .eq(BusinessProductionChoiceLog::getTakeNoStatus, 0));
|
|
|
+ // 将未取号的评估对象对应的产品选择记录的产品id改为新的
|
|
|
+ choiceLog.setProductionId(copyProductionInfo.getId());
|
|
|
+ // 获取后将选择记录对应的产品id改为前面新添加的产品信息
|
|
|
+ choiceLogList.add(choiceLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- //评估对象添加产品号
|
|
|
+
|
|
|
+ // 批量更新产品选择记录
|
|
|
+ choiceLogService.updateBatchById(choiceLogList);
|
|
|
+
|
|
|
+ //评估对象信息更新添加产品号
|
|
|
for (Long id : dto.getTargetIdList()) {
|
|
|
//判断取号的产品类型
|
|
|
if (dto.getProductionType().equals(STATEMENT.getCode())){ //意见书
|
|
@@ -282,7 +325,7 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
//获取资产产品取号信息
|
|
|
BusinessNumber businessNumber = assetsMapper.getBusinessNum(takeAssetsProductionNoDTO.getProductionType() + "_NUMBER", ASSET_BUSINESS.getCode(), nowYear);
|
|
|
|
|
|
- //获取当前资产业务评估对象已经生成的产品号集合
|
|
|
+ //获取当前资产业务流程的评估对象已经生成的产品号集合
|
|
|
List<String> productionNoList = null;
|
|
|
//判断取号的产品类型
|
|
|
if (takeAssetsProductionNoDTO.getProductionType().equals(STATEMENT.getCode())){ //意见书
|
|
@@ -351,7 +394,6 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
}
|
|
|
|
|
|
//判断取号产品类型
|
|
|
-
|
|
|
if (takeAssetsProductionNoDTO.getProductionType().equals(STATEMENT.getCode())) { //取号产品为意见书
|
|
|
productionNo = "川友预报字" + productionNo;
|
|
|
} else if (takeAssetsProductionNoDTO.getProductionType().equals(REPORT.getCode())) { //取号产品为评估报告
|
|
@@ -435,6 +477,22 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取未取号的资产评估对象id
|
|
|
+ * @param allTargetIdList 本次资产流程的所有评估对象
|
|
|
+ * @param takeNoTargetIdList 本次资产流程的取号评估对象
|
|
|
+ * @return List<Long>
|
|
|
+ */
|
|
|
+ public List<Long> targetIdListDifference(List<Long> allTargetIdList, List<Long> takeNoTargetIdList){
|
|
|
+ // 将取号评估对象集合转换为Set,以便快速查找
|
|
|
+ Set<Long> takeNoTargetIdSet = new HashSet<>(takeNoTargetIdList);
|
|
|
+
|
|
|
+ // 使用Stream API找出只在allTargetIdList中但不在takeNoTargetIdSet中的元素
|
|
|
+ return allTargetIdList.stream()
|
|
|
+ .filter(value -> !takeNoTargetIdSet.contains(value))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取资产项目所有参与人
|
|
|
* @param assetsBusinessMembersDTO 查询dto
|
|
|
* @return List<AssetsBusinessMembers>
|
|
@@ -477,4 +535,35 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
|
|
|
return assetsBusinessMemberList;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取资产轮单部门id
|
|
|
+ *
|
|
|
+ * @return Long
|
|
|
+ */
|
|
|
+ private synchronized Long getAllotDepartmentId(){
|
|
|
+
|
|
|
+ List<SortedDepartment> departments = sortedDepartmentService.list(new LambdaQueryWrapper<SortedDepartment>().eq(SortedDepartment::getBusinessType, MainBusinessEnum.ASSET_BUSINESS.getCode()));
|
|
|
+
|
|
|
+ if (CollectionUtil.isEmpty(departments)){
|
|
|
+ ErrorCode.throwBusinessException(ErrorCode.SORTED_DEPARTMENT_NOT_EXISTS, MainBusinessEnum.ASSET_BUSINESS.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ GlobalConfig currentSorted = globalConfigService.getGlobalConfig(GlobalConfigEnum.DEPARTMENT_TURNS.name(), GlobalConfigEnum.DepartmentTurns.ASSET_BUSINESS.name());
|
|
|
+
|
|
|
+ Integer currentSortedIndex = Integer.valueOf(StrUtil.isBlank(currentSorted.getValue())?"0":currentSorted.getValue());
|
|
|
+
|
|
|
+ List<Integer> indexes = departments.stream().map(SortedDepartment::getSortedIndex).sorted(Integer::compareTo).collect(Collectors.toList());
|
|
|
+ for (int i=0;i<indexes.size();i++){
|
|
|
+ if (currentSortedIndex.equals(indexes.get(i))){
|
|
|
+ Integer waitingIndex = indexes.get((i + 1) % indexes.size());
|
|
|
+ currentSorted.setValue(String.valueOf(waitingIndex));
|
|
|
+ globalConfigService.update(currentSorted);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return departments.stream().filter(d -> d.getSortedIndex().equals(currentSortedIndex)).findFirst().get().getDepartmentId();
|
|
|
+ }
|
|
|
}
|