|
@@ -4,10 +4,12 @@ import cn.hutool.core.util.ObjectUtil;
|
|
import com.dayou.common.BaseEntity;
|
|
import com.dayou.common.BaseEntity;
|
|
import com.dayou.dto.*;
|
|
import com.dayou.dto.*;
|
|
import com.dayou.entity.Assets;
|
|
import com.dayou.entity.Assets;
|
|
|
|
+import com.dayou.entity.AssetsEvaluationTarget;
|
|
import com.dayou.entity.BusinessNumber;
|
|
import com.dayou.entity.BusinessNumber;
|
|
import com.dayou.exception.ErrorCode;
|
|
import com.dayou.exception.ErrorCode;
|
|
|
|
+import com.dayou.mapper.AssetsEvaluationTargetMapper;
|
|
import com.dayou.mapper.AssetsMapper;
|
|
import com.dayou.mapper.AssetsMapper;
|
|
-import com.dayou.mapper.BusinessNumberMapper;
|
|
|
|
|
|
+import com.dayou.mapper.AssetsProductionMapper;
|
|
import com.dayou.service.IAssetsService;
|
|
import com.dayou.service.IAssetsService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.dayou.service.IBusinessNumberService;
|
|
import com.dayou.service.IBusinessNumberService;
|
|
@@ -18,8 +20,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import static com.dayou.enums.MainBusinessEnum.ASSET_BUSINESS;
|
|
import static com.dayou.enums.MainBusinessEnum.ASSET_BUSINESS;
|
|
import static com.dayou.enums.ProductionEnum.*;
|
|
import static com.dayou.enums.ProductionEnum.*;
|
|
@@ -45,22 +51,27 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
private AssetsMapper assetsMapper;
|
|
private AssetsMapper assetsMapper;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private BusinessNumberMapper businessNumberMapper;
|
|
|
|
|
|
+ private AssetsProductionMapper assetsProductionMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private AssetsEvaluationTargetMapper assetsEvaluationTargetMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 条件查询资产任务列表
|
|
* 条件查询资产任务列表
|
|
- * @param page 分页条件
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页条件
|
|
* @param assetsSelectDTO 查询条件
|
|
* @param assetsSelectDTO 查询条件
|
|
* @return Page<AssetsVO>
|
|
* @return Page<AssetsVO>
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Page<AssetsVO> selectPage(Page page, AssetsSelectDTO assetsSelectDTO){
|
|
|
|
|
|
+ public Page<AssetsVO> selectPage(Page page, AssetsSelectDTO assetsSelectDTO) {
|
|
return assetsMapper.selectPage(page, assetsSelectDTO);
|
|
return assetsMapper.selectPage(page, assetsSelectDTO);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 条件查询我的资产任务订单列表
|
|
* 条件查询我的资产任务订单列表
|
|
- * @param page 分页条件
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页条件
|
|
* @param assetsSelectDTO 查询条件
|
|
* @param assetsSelectDTO 查询条件
|
|
* @return Page<AssetsVO>
|
|
* @return Page<AssetsVO>
|
|
*/
|
|
*/
|
|
@@ -71,6 +82,7 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据业务id获取资产业务详情
|
|
* 根据业务id获取资产业务详情
|
|
|
|
+ *
|
|
* @param id 业务id
|
|
* @param id 业务id
|
|
* @return AssetsVO
|
|
* @return AssetsVO
|
|
*/
|
|
*/
|
|
@@ -83,29 +95,31 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增资产业务订单
|
|
* 新增资产业务订单
|
|
|
|
+ *
|
|
* @param assets 资产订单信息
|
|
* @param assets 资产订单信息
|
|
* @return Boolean
|
|
* @return Boolean
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public WorkNodeCommit add(Assets assets){
|
|
|
|
|
|
+ public WorkNodeCommit add(Assets assets) {
|
|
//获取项目编号
|
|
//获取项目编号
|
|
assets.setOrderId(businessNumberService.takeOrderNumber());
|
|
assets.setOrderId(businessNumberService.takeOrderNumber());
|
|
//新增订单信息
|
|
//新增订单信息
|
|
this.save(assets);
|
|
this.save(assets);
|
|
//发起流程
|
|
//发起流程
|
|
- return workFlowService.openingOrder(ASSET_BUSINESS,assets.getId(),null,assets.getRemark());
|
|
|
|
|
|
+ return workFlowService.openingOrder(ASSET_BUSINESS, assets.getId(), null, assets.getRemark());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改资产业务订单项目负责人与项目成员
|
|
* 修改资产业务订单项目负责人与项目成员
|
|
|
|
+ *
|
|
* @param taskRecordDTO 修改dto
|
|
* @param taskRecordDTO 修改dto
|
|
* @return Boolean
|
|
* @return Boolean
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Boolean updatePrincipalAndMembers(TaskRecordDTO<AssetsPrincipalMembersDTO> taskRecordDTO) {
|
|
public Boolean updatePrincipalAndMembers(TaskRecordDTO<AssetsPrincipalMembersDTO> taskRecordDTO) {
|
|
AssetsPrincipalMembersDTO assetsPrincipalMembersDTO = taskRecordDTO.getTaskData();
|
|
AssetsPrincipalMembersDTO assetsPrincipalMembersDTO = taskRecordDTO.getTaskData();
|
|
- if (ObjectUtil.isNull(assetsPrincipalMembersDTO.getPrincipalId()) && ObjectUtil.isNull(assetsPrincipalMembersDTO.getMembers())){
|
|
|
|
- ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"项目负责人和项目参与人员不能为空。");
|
|
|
|
|
|
+ if (ObjectUtil.isNull(assetsPrincipalMembersDTO.getPrincipalId()) && ObjectUtil.isNull(assetsPrincipalMembersDTO.getMembers())) {
|
|
|
|
+ ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR, "项目负责人和项目参与人员不能为空。");
|
|
}
|
|
}
|
|
return this.update(new LambdaUpdateWrapper<Assets>().set(Assets::getMembers, assetsPrincipalMembersDTO.getMembers()).set(Assets::getPrincipalId, assetsPrincipalMembersDTO.getPrincipalId())
|
|
return this.update(new LambdaUpdateWrapper<Assets>().set(Assets::getMembers, assetsPrincipalMembersDTO.getMembers()).set(Assets::getPrincipalId, assetsPrincipalMembersDTO.getPrincipalId())
|
|
.eq(BaseEntity::getId, assetsPrincipalMembersDTO.getId()));
|
|
.eq(BaseEntity::getId, assetsPrincipalMembersDTO.getId()));
|
|
@@ -113,6 +127,7 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据业务id获取资产业务款项信息
|
|
* 根据业务id获取资产业务款项信息
|
|
|
|
+ *
|
|
* @param id 业务id
|
|
* @param id 业务id
|
|
* @return AssetsOrderFundInvoiceVO
|
|
* @return AssetsOrderFundInvoiceVO
|
|
*/
|
|
*/
|
|
@@ -122,46 +137,183 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Boolean update(Assets assets){
|
|
|
|
- return this.updateById(assets);
|
|
|
|
|
|
+ public Boolean update(Assets assets) {
|
|
|
|
+ return this.updateById(assets);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Boolean delete(Long id){
|
|
|
|
|
|
+ public Boolean delete(Long id) {
|
|
//逻辑删除
|
|
//逻辑删除
|
|
return this.removeById(id);
|
|
return this.removeById(id);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 资产业务产品取号
|
|
* 资产业务产品取号
|
|
- * @param takeAssetsProductionNoDTO 取号dto
|
|
|
|
|
|
+ * 格式示例:川友预报字2024第0101-2号
|
|
|
|
+ *
|
|
|
|
+ * @param dto 取号dto
|
|
* @return String
|
|
* @return String
|
|
*/
|
|
*/
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
- public String takeAssetsProductionNo(TakeAssetsProductionNoDTO takeAssetsProductionNoDTO) {
|
|
|
|
|
|
+ public String takeAssetsProductionNo(TakeAssetsProductionNoDTO dto) {
|
|
|
|
+ String productionNo = genProductionNo(dto);
|
|
|
|
+ //产品添加产品号
|
|
|
|
+ assetsProductionMapper.updateProductionNo(dto.getBusinessId(), dto.getProductionType(), productionNo);
|
|
|
|
+ //如果还有未取号评估对象,再添加一份同类型产品
|
|
|
|
+ if (!dto.getHasNotTakeNumTarget()){
|
|
|
|
+ assetsProductionMapper.copyProductionInfo(dto.getBusinessId(), dto.getProductionType(), dto.getPrintCount());
|
|
|
|
+ }
|
|
|
|
+ //评估对象添加产品号
|
|
|
|
+ for (Long id : dto.getTargetIdList()){
|
|
|
|
+ assetsEvaluationTargetMapper.updateTargetProductionNo(id, productionNo);
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生成资产产品号
|
|
|
|
+ * @param takeAssetsProductionNoDTO 取号dto
|
|
|
|
+ * @return String
|
|
|
|
+ */
|
|
|
|
+ public String genProductionNo(TakeAssetsProductionNoDTO takeAssetsProductionNoDTO) {
|
|
|
|
+ //获取年份
|
|
Calendar calendar = Calendar.getInstance();
|
|
Calendar calendar = Calendar.getInstance();
|
|
int nowYear = calendar.get(Calendar.YEAR);
|
|
int nowYear = calendar.get(Calendar.YEAR);
|
|
- String productionNo = "(" + nowYear +")";;
|
|
|
|
- //取号产品为意见书
|
|
|
|
- if (takeAssetsProductionNoDTO.getProductionType().equals(STATEMENT.getCode())){
|
|
|
|
- //获取取号信息
|
|
|
|
- BusinessNumber businessNumber = assetsMapper.getBusinessNum(STATEMENT.getCode() + "_NUMBER", ASSET_BUSINESS.getCode(), nowYear);
|
|
|
|
|
|
+ String productionNo = "(" + nowYear + ")" + "第";
|
|
|
|
+
|
|
|
|
+ //获取资产产品取号信息
|
|
|
|
+ BusinessNumber businessNumber = assetsMapper.getBusinessNum(takeAssetsProductionNoDTO.getProductionType() + "_NUMBER", ASSET_BUSINESS.getCode(), nowYear);
|
|
|
|
+
|
|
|
|
+ //判断是否有取号信息
|
|
|
|
+ if (ObjectUtil.isNotNull(businessNumber)) { //取号信息不为空组合产品号
|
|
|
|
+ //判断两个进位是否都>9,具有两位数
|
|
|
|
+ if (businessNumber.getMonth() > 9 && businessNumber.getNextNo() > 9) {
|
|
|
|
+ productionNo = productionNo + businessNumber.getMonth() + businessNumber.getNextNo();
|
|
|
|
+ } else {
|
|
|
|
+ //第一进位小于10,前面多加一个0组成两位
|
|
|
|
+ if (businessNumber.getMonth() < 10) {
|
|
|
|
+ productionNo = productionNo + "0" + businessNumber.getMonth() + businessNumber.getNextNo();
|
|
|
|
+ }
|
|
|
|
+ //第二进位小于10,前面多加一个0组成两位
|
|
|
|
+ if (businessNumber.getNextNo() < 10) {
|
|
|
|
+ productionNo = productionNo + businessNumber.getMonth() + "0" + businessNumber.getNextNo();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //设置下一个产品号取号信息
|
|
|
|
+ if (businessNumber.getNextNo() < 99) {
|
|
|
|
+ businessNumber.setNextNo(businessNumber.getNextNo() + 1);
|
|
|
|
+ } else {
|
|
|
|
+ businessNumber.setMonth(businessNumber.getMonth() + 1);
|
|
|
|
+ businessNumber.setNextNo(1);
|
|
|
|
+ }
|
|
|
|
+ //更新取号信息
|
|
|
|
+ assetsMapper.updateBusinessNum(businessNumber);
|
|
|
|
+ } else { //为空插入取号规则信息,并重新获取
|
|
|
|
+ businessNumber = addBusinessNumber(takeAssetsProductionNoDTO.getProductionType() + "_NUMBER", ASSET_BUSINESS.getCode(), nowYear);
|
|
|
|
+ //判断两个进位是否都>9,具有两位数
|
|
|
|
+ if (businessNumber.getMonth() > 9 && businessNumber.getNextNo() > 9) {
|
|
|
|
+ productionNo = productionNo + businessNumber.getMonth() + businessNumber.getNextNo();
|
|
|
|
+ } else {
|
|
|
|
+ //第一进位小于10,前面多加一个0组成两位
|
|
|
|
+ if (businessNumber.getMonth() < 10) {
|
|
|
|
+ productionNo = productionNo + "0" + businessNumber.getMonth() + businessNumber.getNextNo();
|
|
|
|
+ }
|
|
|
|
+ //第二进位小于10,前面多加一个0组成两位
|
|
|
|
+ if (businessNumber.getNextNo() < 10) {
|
|
|
|
+ productionNo = productionNo + businessNumber.getMonth() + "0" + businessNumber.getNextNo();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //设置下一个产品号取号信息
|
|
|
|
+ if (businessNumber.getNextNo() < 99) {
|
|
|
|
+ businessNumber.setNextNo(businessNumber.getNextNo() + 1);
|
|
|
|
+ } else {
|
|
|
|
+ businessNumber.setMonth(businessNumber.getMonth() + 1);
|
|
|
|
+ businessNumber.setNextNo(1);
|
|
|
|
+ }
|
|
|
|
+ //更新取号信息
|
|
|
|
+ assetsMapper.updateBusinessNum(businessNumber);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //判断取号产品类型
|
|
|
|
+ if (takeAssetsProductionNoDTO.getProductionType().equals(STATEMENT.getCode())) { //取号产品为意见书
|
|
productionNo = "川友预报字" + productionNo;
|
|
productionNo = "川友预报字" + productionNo;
|
|
} else if (takeAssetsProductionNoDTO.getProductionType().equals(REPORT.getCode())) { //取号产品为评估报告
|
|
} else if (takeAssetsProductionNoDTO.getProductionType().equals(REPORT.getCode())) { //取号产品为评估报告
|
|
- productionNo = "川友评报字" + productionNo;;
|
|
|
|
|
|
+ productionNo = "川友评报字" + productionNo;
|
|
} else if (takeAssetsProductionNoDTO.getProductionType().equals(CONSULT.getCode())) { //取号产品为咨询报告
|
|
} else if (takeAssetsProductionNoDTO.getProductionType().equals(CONSULT.getCode())) { //取号产品为咨询报告
|
|
- productionNo = "川友咨报字" + productionNo;;
|
|
|
|
- }else if (takeAssetsProductionNoDTO.getProductionType().equals(LETTER.getCode())) { //取号产品为意见函
|
|
|
|
- productionNo = "川友字" + productionNo;;
|
|
|
|
|
|
+ productionNo = "川友咨报字" + productionNo;
|
|
|
|
+ } else if (takeAssetsProductionNoDTO.getProductionType().equals(LETTER.getCode())) { //取号产品为意见函
|
|
|
|
+ productionNo = "川友字" + productionNo;
|
|
|
|
+ } else { //都不是返回null
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 判断有无子号
|
|
|
|
+ if (takeAssetsProductionNoDTO.getSelectAll()) { //true 则选择了全部评估对象,仅主号无子号
|
|
|
|
+ return productionNo + "号";
|
|
|
|
+ } else { //false 选择了部分评估对象,有子号
|
|
|
|
+ return getProductionSecNum(productionNo, takeAssetsProductionNoDTO.getBusinessId(), takeAssetsProductionNoDTO.getProductionType());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取资产产品子号
|
|
|
|
+ *
|
|
|
|
+ * @param businessId 业务id
|
|
|
|
+ * @param productionType 业务类型
|
|
|
|
+ * @return String
|
|
|
|
+ */
|
|
|
|
+ public String getProductionSecNum(String productionNo, Long businessId, String productionType) {
|
|
|
|
+ // 根据资产业务id与产品类型获取产品号集合
|
|
|
|
+ List<String> productionNoList = assetsProductionMapper.getgetProductionNo(businessId, productionType);
|
|
|
|
+ // 判断同一资产业务的同一类型产品是否有生成过子号
|
|
|
|
+ if (ObjectUtil.isNotNull(productionNoList)) { //为null还没有生成过子号,生成第一个
|
|
|
|
+ return productionNo + "-1号";
|
|
|
|
+ } else { //不为null则说明已经生成过子号,找到目前最大的子号并生成下一个子号
|
|
|
|
+ // 初始化最大子号为Integer.MIN_VALUE
|
|
|
|
+ int maxNumber = Integer.MIN_VALUE;
|
|
|
|
+
|
|
|
|
+ // 正则表达式,用于匹配短横线-后面的数字
|
|
|
|
+ Pattern pattern = Pattern.compile("-(\\d+)");
|
|
|
|
+
|
|
|
|
+ // 遍历字符串列表
|
|
|
|
+ for (String str : productionNoList) {
|
|
|
|
+ // 创建匹配器
|
|
|
|
+ Matcher matcher = pattern.matcher(str);
|
|
|
|
+ // 在字符串中查找短横线后面的数字
|
|
|
|
+ while (matcher.find()) {
|
|
|
|
+ // 将找到的子号从字符串转换为整数
|
|
|
|
+ int secNum = Integer.parseInt(matcher.group(1));
|
|
|
|
+ // 更新最大的子号
|
|
|
|
+ if (secNum > maxNumber) {
|
|
|
|
+ maxNumber = secNum;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 将找到的最大子号 + 1, 得到下一个子号
|
|
|
|
+ maxNumber = maxNumber + 1;
|
|
|
|
+ return productionNo + "-" + maxNumber + "号";
|
|
}
|
|
}
|
|
- return productionNo;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public BusinessNumber addBusinessNumber(String takeType, String businessType, Integer year){
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 新增资产取号信息,并返回
|
|
|
|
+ *
|
|
|
|
+ * @param takeType 取号类型(同产品类型)
|
|
|
|
+ * @param businessType 业务类型
|
|
|
|
+ * @param year 年份
|
|
|
|
+ * @return BusinessNumber
|
|
|
|
+ */
|
|
|
|
+ public BusinessNumber addBusinessNumber(String takeType, String businessType, Integer year) {
|
|
BusinessNumber businessNumber = new BusinessNumber();
|
|
BusinessNumber businessNumber = new BusinessNumber();
|
|
businessNumber.setTakeType(takeType);
|
|
businessNumber.setTakeType(takeType);
|
|
businessNumber.setBusinessType(businessType);
|
|
businessNumber.setBusinessType(businessType);
|
|
businessNumber.setYear(year);
|
|
businessNumber.setYear(year);
|
|
- return null;
|
|
|
|
|
|
+ businessNumber.setMonth(1);
|
|
|
|
+ businessNumber.setNextNo(1);
|
|
|
|
+ //新增
|
|
|
|
+ assetsMapper.addBusinessNum(businessNumber);
|
|
|
|
+ //查询
|
|
|
|
+ return assetsMapper.getBusinessNum(takeType, businessType, year);
|
|
}
|
|
}
|
|
}
|
|
}
|