新增客户号查询并回填客户信息

This commit is contained in:
wkc
2026-04-29 14:13:27 +08:00
parent a90ab42be6
commit 3180c33500
13 changed files with 474 additions and 22 deletions

View File

@@ -15,6 +15,7 @@ import com.ruoyi.loanpricing.domain.entity.LoanPricingWorkflow;
import com.ruoyi.loanpricing.domain.vo.LoanPricingWorkflowListVO;
import com.ruoyi.loanpricing.domain.vo.LoanPricingWorkflowVO;
import com.ruoyi.loanpricing.service.ILoanPricingWorkflowService;
import com.ruoyi.loanpricing.service.LoanPricingCustomerMapService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -38,6 +39,9 @@ public class LoanPricingWorkflowController extends BaseController
@Autowired
private ILoanPricingWorkflowService loanPricingWorkflowService;
@Autowired
private LoanPricingCustomerMapService customerMapService;
/**
* 发起个人客户利率定价流程
*/
@@ -61,6 +65,26 @@ public class LoanPricingWorkflowController extends BaseController
return success(result);
}
/**
* 查询个人客户号映射
*/
@Operation(summary = "查询个人客户号映射")
@GetMapping("/customer-map/personal")
public AjaxResult queryPersonalCustomerMap(@RequestParam("custId") String custId)
{
return success(customerMapService.queryPersonal(custId));
}
/**
* 查询企业客户号映射
*/
@Operation(summary = "查询企业客户号映射")
@GetMapping("/customer-map/corporate")
public AjaxResult queryCorporateCustomerMap(@RequestParam("custId") String custId)
{
return success(customerMapService.queryCorporate(custId));
}
/**
* 查询利率定价流程列表
*/

View File

@@ -6,15 +6,22 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.loanpricing.domain.dto.ModelInvokeDTO;
import com.ruoyi.loanpricing.domain.vo.CustomerMapRecordVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.io.InputStream;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
/**
@@ -40,6 +47,22 @@ public class LoanRatePricingMockController extends BaseController {
return new AjaxResult(10000, "success", loadJsonFromResource("data/corp_output.json"));
}
@Anonymous
@Operation(summary = "模拟个人客户号映射查询")
@GetMapping("/customer-map/personal")
public AjaxResult queryPersonalCustomerMap(@RequestParam("cust_id") String custId)
{
return success(randomCustomerMapRecords(custId, "个人客户"));
}
@Anonymous
@Operation(summary = "模拟企业客户号映射查询")
@GetMapping("/customer-map/corporate")
public AjaxResult queryCorporateCustomerMap(@RequestParam("cust_id") String custId)
{
return success(randomCustomerMapRecords(custId, "企业客户"));
}
private ObjectNode loadJsonFromResource(String resourcePath){
ClassPathResource classPathResource = new ClassPathResource(resourcePath);
try (InputStream inputStream = classPathResource.getInputStream();){
@@ -51,5 +74,28 @@ public class LoanRatePricingMockController extends BaseController {
}
}
private List<CustomerMapRecordVO> randomCustomerMapRecords(String custId, String namePrefix)
{
String normalizedCustId = StringUtils.trimWhitespace(custId);
if (!StringUtils.hasText(normalizedCustId))
{
throw new ServiceException("客户号不能为空");
}
int count = ThreadLocalRandom.current().nextInt(1, 4);
List<CustomerMapRecordVO> records = new ArrayList<>();
for (int i = 1; i <= count; i++)
{
CustomerMapRecordVO record = new CustomerMapRecordVO();
record.setCustId(normalizedCustId);
record.setCustIsn(String.valueOf(81000000000L + ThreadLocalRandom.current().nextInt(1000000)));
record.setCustName(namePrefix + i);
record.setFaithDay(String.valueOf(ThreadLocalRandom.current().nextInt(1, 365)));
record.setBalanceAvg(String.valueOf(ThreadLocalRandom.current().nextInt(10000, 900000)));
record.setLoanCountHis(String.valueOf(ThreadLocalRandom.current().nextInt(0, 10)));
record.setLastLoanDate(LocalDate.now().minusDays(ThreadLocalRandom.current().nextInt(1, 800)).toString());
records.add(record);
}
return records;
}
}

View File

@@ -0,0 +1,35 @@
package com.ruoyi.loanpricing.domain.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.Data;
/**
* 客户号与客户内码映射记录。
*/
@Data
public class CustomerMapRecordVO implements Serializable
{
private static final long serialVersionUID = 1L;
@JsonProperty("cust_id")
private String custId;
@JsonProperty("cust_isn")
private String custIsn;
@JsonProperty("cust_name")
private String custName;
@JsonProperty("faith_day")
private String faithDay;
@JsonProperty("balance_avg")
private String balanceAvg;
@JsonProperty("loan_count_his")
private String loanCountHis;
@JsonProperty("last_loan_date")
private String lastLoanDate;
}

View File

@@ -0,0 +1,89 @@
package com.ruoyi.loanpricing.service;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.loanpricing.domain.vo.CustomerMapRecordVO;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
/**
* 客户号与客户内码映射查询服务。
*/
@Service
public class LoanPricingCustomerMapService
{
private final RestTemplate restTemplate;
@Value("${customer-map.personal-url}")
private String personalUrl;
@Value("${customer-map.corporate-url}")
private String corporateUrl;
public LoanPricingCustomerMapService()
{
this(new RestTemplate());
}
LoanPricingCustomerMapService(RestTemplate restTemplate)
{
this.restTemplate = restTemplate;
}
LoanPricingCustomerMapService(RestTemplate restTemplate, String personalUrl, String corporateUrl)
{
this.restTemplate = restTemplate;
this.personalUrl = personalUrl;
this.corporateUrl = corporateUrl;
}
public List<CustomerMapRecordVO> queryPersonal(String custId)
{
return query(personalUrl, custId);
}
public List<CustomerMapRecordVO> queryCorporate(String custId)
{
return query(corporateUrl, custId);
}
private List<CustomerMapRecordVO> query(String url, String custId)
{
String normalizedCustId = StringUtils.trimWhitespace(custId);
if (!StringUtils.hasText(normalizedCustId))
{
throw new ServiceException("客户号不能为空");
}
URI uri = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("cust_id", normalizedCustId)
.build()
.encode()
.toUri();
CustomerMapResponse response = restTemplate.getForObject(uri, CustomerMapResponse.class);
if (response == null)
{
throw new ServiceException("客户号映射接口无返回");
}
if (response.getCode() != null && response.getCode() != 200)
{
throw new ServiceException(StringUtils.hasText(response.getMsg()) ? response.getMsg() : "客户号映射查询失败");
}
return response.getData() == null ? Collections.emptyList() : response.getData();
}
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
static class CustomerMapResponse
{
private Integer code;
private String msg;
private List<CustomerMapRecordVO> data;
}
}