新增流程列表编辑功能

This commit is contained in:
wkc
2026-05-25 16:04:23 +08:00
parent cc6836804e
commit 998f0b3c48
14 changed files with 746 additions and 50 deletions

View File

@@ -69,6 +69,46 @@ public class LoanPricingWorkflowController extends BaseController
return success(result);
}
/**
* 查询利率定价流程编辑数据
*/
@Operation(summary = "查询利率定价流程编辑数据")
@GetMapping("/{serialNum}/edit")
public AjaxResult getEditInfo(
@Parameter(description = "业务方流水号")
@PathVariable("serialNum") String serialNum)
{
return success(loanPricingWorkflowService.selectEditableLoanPricingBySerialNum(serialNum));
}
/**
* 编辑个人客户利率定价流程
*/
@Operation(summary = "编辑个人客户利率定价流程")
@Log(title = "个人客户利率定价流程", businessType = BusinessType.UPDATE)
@PutMapping("/{serialNum}/personal")
public AjaxResult updatePersonal(
@Parameter(description = "业务方流水号")
@PathVariable("serialNum") String serialNum,
@Validated @RequestBody PersonalLoanPricingCreateDTO dto)
{
return success(loanPricingWorkflowService.updatePersonalLoanPricing(serialNum, dto));
}
/**
* 编辑企业客户利率定价流程
*/
@Operation(summary = "编辑企业客户利率定价流程")
@Log(title = "企业客户利率定价流程", businessType = BusinessType.UPDATE)
@PutMapping("/{serialNum}/corporate")
public AjaxResult updateCorporate(
@Parameter(description = "业务方流水号")
@PathVariable("serialNum") String serialNum,
@Validated @RequestBody CorporateLoanPricingCreateDTO dto)
{
return success(loanPricingWorkflowService.updateCorporateLoanPricing(serialNum, dto));
}
/**
* 查询个人客户号映射
*/

View File

@@ -34,6 +34,32 @@ public interface ILoanPricingWorkflowService
*/
public LoanPricingWorkflow createCorporateLoanPricing(CorporateLoanPricingCreateDTO dto);
/**
* 查询利率定价流程编辑数据
*
* @param serialNum 业务方流水号
* @return 编辑用流程数据
*/
public LoanPricingWorkflow selectEditableLoanPricingBySerialNum(String serialNum);
/**
* 编辑个人客户利率定价流程
*
* @param serialNum 业务方流水号
* @param dto 个人客户编辑DTO
* @return 更新后的流程数据
*/
public LoanPricingWorkflow updatePersonalLoanPricing(String serialNum, PersonalLoanPricingCreateDTO dto);
/**
* 编辑企业客户利率定价流程
*
* @param serialNum 业务方流水号
* @param dto 企业客户编辑DTO
* @return 更新后的流程数据
*/
public LoanPricingWorkflow updateCorporateLoanPricing(String serialNum, CorporateLoanPricingCreateDTO dto);
/**
* 查询利率定价流程列表
*

View File

@@ -40,6 +40,14 @@ public class LoanPricingModelService {
private SensitiveFieldCryptoService sensitiveFieldCryptoService;
public void invokeModelAsync(Long workflowId) {
invokeModelAndSave(workflowId, false);
}
public void reinvokeModelAndOverwrite(Long workflowId) {
invokeModelAndSave(workflowId, true);
}
private void invokeModelAndSave(Long workflowId, boolean overwriteModelOutput) {
LoanPricingWorkflow loanPricingWorkflow = loanPricingWorkflowMapper.selectById(workflowId);
if (Objects.isNull(loanPricingWorkflow)){
log.error("未找到对应的流程信息,未调用模型服务");
@@ -68,26 +76,43 @@ public class LoanPricingModelService {
if (loanPricingWorkflow.getCustType().equals("个人")){
// 个人模型
ModelRetailOutputFields modelRetailOutputFields = modelService.invokePersonalModel(modelInvokeDTO);
modelRetailOutputFieldsMapper.insert(modelRetailOutputFields);
if (overwriteModelOutput && Objects.nonNull(loanPricingWorkflow.getModelOutputId()))
{
modelRetailOutputFields.setId(loanPricingWorkflow.getModelOutputId());
modelRetailOutputFieldsMapper.updateById(modelRetailOutputFields);
}
else
{
modelRetailOutputFieldsMapper.insert(modelRetailOutputFields);
}
log.info("个人模型调用成功");
LoanPricingWorkflow workflowToUpdate = new LoanPricingWorkflow();
workflowToUpdate.setId(loanPricingWorkflow.getId());
workflowToUpdate.setModelOutputId(modelRetailOutputFields.getId());
loanPricingWorkflowMapper.updateById(workflowToUpdate);
log.info("更新流程信息成功");
updateWorkflowModelOutputId(loanPricingWorkflow, modelRetailOutputFields.getId());
}else if (loanPricingWorkflow.getCustType().equals("企业")){
// 企业模型
ModelCorpOutputFields modelCorpOutputFields = modelService.invokeCorporateModel(modelInvokeDTO);
modelCorpOutputFieldsMapper.insert(modelCorpOutputFields);
if (overwriteModelOutput && Objects.nonNull(loanPricingWorkflow.getModelOutputId()))
{
modelCorpOutputFields.setId(loanPricingWorkflow.getModelOutputId());
modelCorpOutputFieldsMapper.updateById(modelCorpOutputFields);
}
else
{
modelCorpOutputFieldsMapper.insert(modelCorpOutputFields);
}
log.info("企业模型调用成功");
LoanPricingWorkflow workflowToUpdate = new LoanPricingWorkflow();
workflowToUpdate.setId(loanPricingWorkflow.getId());
workflowToUpdate.setModelOutputId(modelCorpOutputFields.getId());
loanPricingWorkflowMapper.updateById(workflowToUpdate);
log.info("更新流程信息成功");
updateWorkflowModelOutputId(loanPricingWorkflow, modelCorpOutputFields.getId());
}
}
private void updateWorkflowModelOutputId(LoanPricingWorkflow loanPricingWorkflow, Long modelOutputId)
{
LoanPricingWorkflow workflowToUpdate = new LoanPricingWorkflow();
workflowToUpdate.setId(loanPricingWorkflow.getId());
workflowToUpdate.setModelOutputId(modelOutputId);
loanPricingWorkflowMapper.updateById(workflowToUpdate);
log.info("更新流程信息成功");
}
private void normalizePersonalModelInvokeDTO(ModelInvokeDTO modelInvokeDTO)
{
modelInvokeDTO.setBizProof(toZeroOne(modelInvokeDTO.getBizProof()));
@@ -98,6 +123,7 @@ public class LoanPricingModelService {
private void normalizeCorporateModelInvokeDTO(ModelInvokeDTO modelInvokeDTO)
{
modelInvokeDTO.setCollThirdParty(toZeroOne(modelInvokeDTO.getCollThirdParty()));
modelInvokeDTO.setResCover(toZeroOne(modelInvokeDTO.getResCover()));
modelInvokeDTO.setIsGreenLoan(toZeroOne(modelInvokeDTO.getIsGreenLoan()));
modelInvokeDTO.setIsTradeBuildEnt(toZeroOne(modelInvokeDTO.getIsTradeBuildEnt()));
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.loanpricing.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.constant.UserConstants;
@@ -47,6 +48,10 @@ public class LoanPricingWorkflowServiceImpl implements ILoanPricingWorkflowServi
private static final String WORKFLOW_ADMIN_ROLE_KEY = "headAdmin";
private static final String WORKFLOW_BRANCH_ADMIN_ROLE_NAME = "支行管理员";
private static final String WORKFLOW_BRANCH_ADMIN_ROLE_KEY = "branchAdmin";
@Resource
private LoanPricingWorkflowMapper loanPricingWorkflowMapper;
@@ -93,6 +98,7 @@ public class LoanPricingWorkflowServiceImpl implements ILoanPricingWorkflowServi
loanPricingWorkflow.setRunType("1");
}
loanPricingWorkflow.setDeptId(SecurityUtils.getDeptId());
loanPricingWorkflow.setCustName(sensitiveFieldCryptoService.encrypt(loanPricingWorkflow.getCustName()));
loanPricingWorkflow.setIdNum(sensitiveFieldCryptoService.encrypt(loanPricingWorkflow.getIdNum()));
loanPricingWorkflowMapper.insert(loanPricingWorkflow);
@@ -193,6 +199,97 @@ public class LoanPricingWorkflowServiceImpl implements ILoanPricingWorkflowServi
return createLoanPricing(entity);
}
@Override
public LoanPricingWorkflow selectEditableLoanPricingBySerialNum(String serialNum)
{
LoanPricingWorkflow workflow = selectWorkflowBySerialNum(serialNum);
assertCurrentUserIsCreator(workflow);
workflow.setCustName(sensitiveFieldCryptoService.decrypt(workflow.getCustName()));
workflow.setIdNum(sensitiveFieldCryptoService.decrypt(workflow.getIdNum()));
return workflow;
}
@Override
@Transactional(rollbackFor = Exception.class)
public LoanPricingWorkflow updatePersonalLoanPricing(String serialNum, PersonalLoanPricingCreateDTO dto)
{
LoanPricingWorkflow editingWorkflow = LoanPricingConverter.toEntity(dto);
return updateLoanPricing(serialNum, editingWorkflow, "个人");
}
@Override
@Transactional(rollbackFor = Exception.class)
public LoanPricingWorkflow updateCorporateLoanPricing(String serialNum, CorporateLoanPricingCreateDTO dto)
{
LoanPricingWorkflow editingWorkflow = LoanPricingConverter.toEntity(dto);
return updateLoanPricing(serialNum, editingWorkflow, "企业");
}
private LoanPricingWorkflow updateLoanPricing(String serialNum, LoanPricingWorkflow editingWorkflow, String expectedCustType)
{
LoanPricingWorkflow existingWorkflow = selectWorkflowBySerialNum(serialNum);
assertCurrentUserIsCreator(existingWorkflow);
if (!expectedCustType.equals(existingWorkflow.getCustType()))
{
throw new ServiceException("客户类型不匹配,不能编辑该流程");
}
editingWorkflow.setId(existingWorkflow.getId());
editingWorkflow.setSerialNum(existingWorkflow.getSerialNum());
editingWorkflow.setCustType(existingWorkflow.getCustType());
editingWorkflow.setModelOutputId(existingWorkflow.getModelOutputId());
validateBusinessTypeAndHistoryRate(editingWorkflow);
validateCollateralTypeAndCouponRate(editingWorkflow);
String encryptedCustName = sensitiveFieldCryptoService.encrypt(editingWorkflow.getCustName());
String encryptedIdNum = sensitiveFieldCryptoService.encrypt(editingWorkflow.getIdNum());
LambdaUpdateWrapper<LoanPricingWorkflow> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(LoanPricingWorkflow::getId, existingWorkflow.getId())
.set(LoanPricingWorkflow::getCustIsn, editingWorkflow.getCustIsn())
.set(LoanPricingWorkflow::getCustName, encryptedCustName)
.set(LoanPricingWorkflow::getIdType, editingWorkflow.getIdType())
.set(LoanPricingWorkflow::getIdNum, encryptedIdNum)
.set(LoanPricingWorkflow::getGuarType, editingWorkflow.getGuarType())
.set(LoanPricingWorkflow::getApplyAmt, editingWorkflow.getApplyAmt())
.set(LoanPricingWorkflow::getBusinessType, editingWorkflow.getBusinessType())
.set(LoanPricingWorkflow::getLoanRateHistory, editingWorkflow.getLoanRateHistory())
.set(LoanPricingWorkflow::getCouponRate, editingWorkflow.getCouponRate())
.set(LoanPricingWorkflow::getLoanTerm, editingWorkflow.getLoanTerm())
.set(LoanPricingWorkflow::getCollType, editingWorkflow.getCollType())
.set(LoanPricingWorkflow::getCollThirdParty, editingWorkflow.getCollThirdParty())
.set(LoanPricingWorkflow::getLoanLoop, editingWorkflow.getLoanLoop())
.set(LoanPricingWorkflow::getResCover, editingWorkflow.getResCover())
.set(LoanPricingWorkflow::getRepayMethod, editingWorkflow.getRepayMethod())
.set(LoanPricingWorkflow::getIsGreenLoan, editingWorkflow.getIsGreenLoan())
.set(LoanPricingWorkflow::getIsTradeBuildEnt, editingWorkflow.getIsTradeBuildEnt())
.set(LoanPricingWorkflow::getUpdateBy, buildCurrentCreateBy(SecurityUtils.getLoginUser()))
.set(LoanPricingWorkflow::getUpdateTime, new Date());
loanPricingWorkflowMapper.update(null, updateWrapper);
loanPricingModelService.reinvokeModelAndOverwrite(existingWorkflow.getId());
return selectEditableLoanPricingBySerialNum(serialNum);
}
private LoanPricingWorkflow selectWorkflowBySerialNum(String serialNum)
{
LambdaQueryWrapper<LoanPricingWorkflow> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(LoanPricingWorkflow::getSerialNum, serialNum);
LoanPricingWorkflow workflow = loanPricingWorkflowMapper.selectOne(wrapper);
if (workflow == null)
{
throw new ServiceException("记录不存在");
}
return workflow;
}
private void assertCurrentUserIsCreator(LoanPricingWorkflow workflow)
{
String currentCreateBy = buildCurrentCreateBy(SecurityUtils.getLoginUser());
if (!currentCreateBy.equals(workflow.getCreateBy()))
{
throw new ServiceException("只有创建者可以编辑该流程");
}
}
/**
* 查询利率定价流程列表
*
@@ -306,7 +403,15 @@ public class LoanPricingWorkflowServiceImpl implements ILoanPricingWorkflowServi
{
LoanPricingWorkflow scopedQuery = query == null ? new LoanPricingWorkflow() : query;
LoginUser loginUser = SecurityUtils.getLoginUser();
if (!canViewAllWorkflows(loginUser))
if (canViewAllWorkflows(loginUser))
{
return scopedQuery;
}
if (canViewBranchWorkflows(loginUser))
{
scopedQuery.setDataScopeDeptId(loginUser.getDeptId() == null ? -1L : loginUser.getDeptId());
}
else
{
scopedQuery.setDataScopeCreateBy(buildCurrentCreateBy(loginUser));
}
@@ -331,6 +436,19 @@ public class LoanPricingWorkflowServiceImpl implements ILoanPricingWorkflowServi
|| WORKFLOW_ADMIN_ROLE_KEY.equals(role.getRoleKey())));
}
private boolean canViewBranchWorkflows(LoginUser loginUser)
{
List<SysRole> roles = loginUser.getUser().getRoles();
if (roles == null)
{
return false;
}
return roles.stream().anyMatch(role -> role != null
&& UserConstants.ROLE_NORMAL.equals(role.getStatus())
&& (WORKFLOW_BRANCH_ADMIN_ROLE_NAME.equals(role.getRoleName())
|| WORKFLOW_BRANCH_ADMIN_ROLE_KEY.equals(role.getRoleKey())));
}
private String buildCurrentCreateBy(LoginUser loginUser)
{
SysUser user = loginUser.getUser();