新增征信维护查询与接口
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
package com.ruoyi.info.collection.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.page.PageDomain;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.core.page.TableSupport;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.info.collection.domain.dto.CcdiCreditInfoQueryDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CreditInfoListVO;
|
||||||
|
import com.ruoyi.info.collection.service.ICcdiCreditInfoService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 征信维护 Controller
|
||||||
|
*/
|
||||||
|
@Tag(name = "征信维护")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ccdi/creditInfo")
|
||||||
|
public class CcdiCreditInfoController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICcdiCreditInfoService creditInfoService;
|
||||||
|
|
||||||
|
@Operation(summary = "上传征信 HTML")
|
||||||
|
@PreAuthorize("@ss.hasPermi('ccdi:creditInfo:upload')")
|
||||||
|
@Log(title = "征信维护", businessType = BusinessType.IMPORT)
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public AjaxResult upload(@RequestParam("files") MultipartFile[] files) {
|
||||||
|
return AjaxResult.success("上传成功", creditInfoService.upload(Arrays.asList(files)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询征信维护列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('ccdi:creditInfo:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(CcdiCreditInfoQueryDTO queryDTO) {
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
Page<CreditInfoListVO> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||||
|
Page<CreditInfoListVO> result = creditInfoService.selectCreditInfoPage(page, queryDTO);
|
||||||
|
return getDataTable(result.getRecords(), result.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询征信维护详情")
|
||||||
|
@PreAuthorize("@ss.hasPermi('ccdi:creditInfo:query')")
|
||||||
|
@GetMapping("/{personId}")
|
||||||
|
public AjaxResult detail(@PathVariable String personId) {
|
||||||
|
return success(creditInfoService.selectDetailByPersonId(personId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除征信维护数据")
|
||||||
|
@PreAuthorize("@ss.hasPermi('ccdi:creditInfo:remove')")
|
||||||
|
@Log(title = "征信维护", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{personId}")
|
||||||
|
public AjaxResult remove(@PathVariable String personId) {
|
||||||
|
return toAjax(creditInfoService.deleteByPersonId(personId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import com.ruoyi.info.collection.domain.CcdiDebtsInfo;
|
|||||||
import com.ruoyi.info.collection.domain.dto.CcdiCreditInfoQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiCreditInfoQueryDTO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CreditInfoDetailVO;
|
import com.ruoyi.info.collection.domain.vo.CreditInfoDetailVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CreditInfoListVO;
|
import com.ruoyi.info.collection.domain.vo.CreditInfoListVO;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CreditInfoNegativeVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CreditInfoUploadFailureVO;
|
import com.ruoyi.info.collection.domain.vo.CreditInfoUploadFailureVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CreditInfoUploadResultVO;
|
import com.ruoyi.info.collection.domain.vo.CreditInfoUploadResultVO;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiBaseStaffMapper;
|
import com.ruoyi.info.collection.mapper.CcdiBaseStaffMapper;
|
||||||
@@ -96,7 +97,28 @@ public class CcdiCreditInfoServiceImpl implements ICcdiCreditInfoService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CreditInfoDetailVO selectDetailByPersonId(String personId) {
|
public CreditInfoDetailVO selectDetailByPersonId(String personId) {
|
||||||
return queryMapper.selectCreditInfoDetailByPersonId(personId);
|
CreditInfoListVO summary = queryMapper.selectCreditInfoSummaryByPersonId(personId);
|
||||||
|
CcdiCreditNegativeInfo negative = negativeInfoMapper.selectByPersonId(personId);
|
||||||
|
List<CcdiDebtsInfo> debts = debtsInfoMapper.selectByPersonId(personId);
|
||||||
|
if (summary == null && negative == null && (debts == null || debts.isEmpty())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreditInfoDetailVO detail = new CreditInfoDetailVO();
|
||||||
|
detail.setPersonId(personId);
|
||||||
|
detail.setIdCard(summary != null && !isBlank(summary.getIdCard()) ? summary.getIdCard() : personId);
|
||||||
|
if (summary != null) {
|
||||||
|
detail.setPersonName(summary.getName());
|
||||||
|
}
|
||||||
|
if (isBlank(detail.getPersonName()) && negative != null) {
|
||||||
|
detail.setPersonName(negative.getPersonName());
|
||||||
|
}
|
||||||
|
if (isBlank(detail.getPersonName()) && debts != null && !debts.isEmpty()) {
|
||||||
|
detail.setPersonName(debts.get(0).getPersonName());
|
||||||
|
}
|
||||||
|
detail.setNegativeInfo(toNegativeVO(negative));
|
||||||
|
detail.setDebtList(debts == null ? List.of() : debts);
|
||||||
|
return detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -242,6 +264,23 @@ public class CcdiCreditInfoServiceImpl implements ICcdiCreditInfoService {
|
|||||||
return text == null || text.trim().isEmpty();
|
return text == null || text.trim().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CreditInfoNegativeVO toNegativeVO(CcdiCreditNegativeInfo negative) {
|
||||||
|
if (negative == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CreditInfoNegativeVO negativeVO = new CreditInfoNegativeVO();
|
||||||
|
negativeVO.setPersonId(negative.getPersonId());
|
||||||
|
negativeVO.setPersonName(negative.getPersonName());
|
||||||
|
negativeVO.setQueryDate(negative.getQueryDate());
|
||||||
|
negativeVO.setCivilCnt(negative.getCivilCnt());
|
||||||
|
negativeVO.setEnforceCnt(negative.getEnforceCnt());
|
||||||
|
negativeVO.setAdmCnt(negative.getAdmCnt());
|
||||||
|
negativeVO.setCivilLmt(negative.getCivilLmt());
|
||||||
|
negativeVO.setEnforceLmt(negative.getEnforceLmt());
|
||||||
|
negativeVO.setAdmLmt(negative.getAdmLmt());
|
||||||
|
return negativeVO;
|
||||||
|
}
|
||||||
|
|
||||||
private String currentUserName() {
|
private String currentUserName() {
|
||||||
try {
|
try {
|
||||||
return SecurityUtils.getUsername();
|
return SecurityUtils.getUsername();
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.info.collection.mapper.CcdiCreditInfoQueryMapper">
|
||||||
|
|
||||||
|
<select id="selectCreditInfoPage" resultType="com.ruoyi.info.collection.domain.vo.CreditInfoListVO">
|
||||||
|
SELECT
|
||||||
|
s.staff_id,
|
||||||
|
s.name,
|
||||||
|
s.id_card,
|
||||||
|
d.dept_name,
|
||||||
|
debt_agg.query_date,
|
||||||
|
IFNULL(debt_agg.debt_count, 0) AS debt_count,
|
||||||
|
IFNULL(debt_agg.debt_total_amount, 0) AS debt_total_amount,
|
||||||
|
IFNULL(neg.civil_cnt, 0) AS civil_cnt,
|
||||||
|
IFNULL(neg.enforce_cnt, 0) AS enforce_cnt,
|
||||||
|
IFNULL(neg.adm_cnt, 0) AS adm_cnt
|
||||||
|
FROM ccdi_base_staff s
|
||||||
|
LEFT JOIN sys_dept d ON s.dept_id = d.dept_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
person_id,
|
||||||
|
MAX(query_date) AS query_date,
|
||||||
|
COUNT(*) AS debt_count,
|
||||||
|
SUM(debt_total_amount) AS debt_total_amount
|
||||||
|
FROM ccdi_debts_info
|
||||||
|
GROUP BY person_id
|
||||||
|
) debt_agg ON debt_agg.person_id = s.id_card
|
||||||
|
LEFT JOIN ccdi_credit_negative_info neg ON neg.person_id = s.id_card
|
||||||
|
<where>
|
||||||
|
<if test="query != null and query.name != null and query.name != ''">
|
||||||
|
AND s.name LIKE CONCAT('%', #{query.name}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="query != null and query.staffId != null and query.staffId != ''">
|
||||||
|
AND CAST(s.staff_id AS CHAR) = #{query.staffId}
|
||||||
|
</if>
|
||||||
|
<if test="query != null and query.idCard != null and query.idCard != ''">
|
||||||
|
AND s.id_card LIKE CONCAT('%', #{query.idCard}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="query != null and query.maintained == '1'">
|
||||||
|
AND (debt_agg.person_id IS NOT NULL OR neg.person_id IS NOT NULL)
|
||||||
|
</if>
|
||||||
|
<if test="query != null and query.maintained == '0'">
|
||||||
|
AND debt_agg.person_id IS NULL
|
||||||
|
AND neg.person_id IS NULL
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY debt_agg.query_date DESC, s.staff_id DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCreditInfoSummaryByPersonId" resultType="com.ruoyi.info.collection.domain.vo.CreditInfoListVO">
|
||||||
|
SELECT
|
||||||
|
s.staff_id,
|
||||||
|
s.name,
|
||||||
|
s.id_card,
|
||||||
|
d.dept_name,
|
||||||
|
debt_agg.query_date,
|
||||||
|
IFNULL(debt_agg.debt_count, 0) AS debt_count,
|
||||||
|
IFNULL(debt_agg.debt_total_amount, 0) AS debt_total_amount,
|
||||||
|
IFNULL(neg.civil_cnt, 0) AS civil_cnt,
|
||||||
|
IFNULL(neg.enforce_cnt, 0) AS enforce_cnt,
|
||||||
|
IFNULL(neg.adm_cnt, 0) AS adm_cnt
|
||||||
|
FROM ccdi_base_staff s
|
||||||
|
LEFT JOIN sys_dept d ON s.dept_id = d.dept_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
person_id,
|
||||||
|
MAX(query_date) AS query_date,
|
||||||
|
COUNT(*) AS debt_count,
|
||||||
|
SUM(debt_total_amount) AS debt_total_amount
|
||||||
|
FROM ccdi_debts_info
|
||||||
|
GROUP BY person_id
|
||||||
|
) debt_agg ON debt_agg.person_id = s.id_card
|
||||||
|
LEFT JOIN ccdi_credit_negative_info neg ON neg.person_id = s.id_card
|
||||||
|
WHERE s.id_card = #{personId}
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectLatestQueryDate" resultType="java.time.LocalDate">
|
||||||
|
SELECT MAX(query_date)
|
||||||
|
FROM ccdi_debts_info
|
||||||
|
WHERE person_id = #{personId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.info.collection.mapper.CcdiCreditNegativeInfoMapper">
|
||||||
|
|
||||||
|
<resultMap id="CcdiCreditNegativeInfoResultMap" type="com.ruoyi.info.collection.domain.CcdiCreditNegativeInfo">
|
||||||
|
<id property="negativeId" column="negative_id"/>
|
||||||
|
<result property="personId" column="person_id"/>
|
||||||
|
<result property="personName" column="person_name"/>
|
||||||
|
<result property="queryDate" column="query_date"/>
|
||||||
|
<result property="civilCnt" column="civil_cnt"/>
|
||||||
|
<result property="enforceCnt" column="enforce_cnt"/>
|
||||||
|
<result property="admCnt" column="adm_cnt"/>
|
||||||
|
<result property="civilLmt" column="civil_lmt"/>
|
||||||
|
<result property="enforceLmt" column="enforce_lmt"/>
|
||||||
|
<result property="admLmt" column="adm_lmt"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectByPersonId" resultMap="CcdiCreditNegativeInfoResultMap">
|
||||||
|
SELECT
|
||||||
|
negative_id, person_id, person_name, query_date, civil_cnt, enforce_cnt, adm_cnt,
|
||||||
|
civil_lmt, enforce_lmt, adm_lmt, create_by, create_time, update_by, update_time
|
||||||
|
FROM ccdi_credit_negative_info
|
||||||
|
WHERE person_id = #{personId}
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteByPersonId">
|
||||||
|
DELETE FROM ccdi_credit_negative_info
|
||||||
|
WHERE person_id = #{personId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.info.collection.mapper.CcdiDebtsInfoMapper">
|
||||||
|
|
||||||
|
<resultMap id="CcdiDebtsInfoResultMap" type="com.ruoyi.info.collection.domain.CcdiDebtsInfo">
|
||||||
|
<id property="debtId" column="debt_id"/>
|
||||||
|
<result property="personId" column="person_id"/>
|
||||||
|
<result property="personName" column="person_name"/>
|
||||||
|
<result property="queryDate" column="query_date"/>
|
||||||
|
<result property="debtMainType" column="debt_main_type"/>
|
||||||
|
<result property="debtSubType" column="debt_sub_type"/>
|
||||||
|
<result property="creditorType" column="creditor_type"/>
|
||||||
|
<result property="debtName" column="debt_name"/>
|
||||||
|
<result property="principalBalance" column="principal_balance"/>
|
||||||
|
<result property="debtTotalAmount" column="debt_total_amount"/>
|
||||||
|
<result property="debtStatus" column="debt_status"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectByPersonId" resultMap="CcdiDebtsInfoResultMap">
|
||||||
|
SELECT
|
||||||
|
debt_id, person_id, person_name, query_date, debt_main_type, debt_sub_type, creditor_type,
|
||||||
|
debt_name, principal_balance, debt_total_amount, debt_status, create_by, create_time, update_by, update_time
|
||||||
|
FROM ccdi_debts_info
|
||||||
|
WHERE person_id = #{personId}
|
||||||
|
ORDER BY debt_id ASC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteByPersonId">
|
||||||
|
DELETE FROM ccdi_debts_info
|
||||||
|
WHERE person_id = #{personId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="insertBatch">
|
||||||
|
INSERT INTO ccdi_debts_info
|
||||||
|
(person_id, person_name, query_date, debt_main_type, debt_sub_type, creditor_type,
|
||||||
|
debt_name, principal_balance, debt_total_amount, debt_status, create_by, create_time, update_by, update_time)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.personId}, #{item.personName}, #{item.queryDate}, #{item.debtMainType}, #{item.debtSubType}, #{item.creditorType},
|
||||||
|
#{item.debtName}, #{item.principalBalance}, #{item.debtTotalAmount}, #{item.debtStatus}, #{item.createBy}, NOW(), #{item.updateBy}, NOW())
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.ruoyi.info.collection.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.info.collection.domain.dto.CcdiCreditInfoQueryDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CreditInfoListVO;
|
||||||
|
import com.ruoyi.info.collection.service.ICcdiCreditInfoService;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class CcdiCreditInfoControllerTest {
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private CcdiCreditInfoController controller;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private ICcdiCreditInfoService service;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void list_shouldDelegateWithPageRequest() {
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
|
request.addParameter("pageNum", "1");
|
||||||
|
request.addParameter("pageSize", "10");
|
||||||
|
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
||||||
|
when(service.selectCreditInfoPage(any(), any())).thenReturn(new Page<CreditInfoListVO>(1, 10, 0));
|
||||||
|
|
||||||
|
TableDataInfo result = controller.list(new CcdiCreditInfoQueryDTO());
|
||||||
|
|
||||||
|
assertEquals(0L, result.getTotal());
|
||||||
|
RequestContextHolder.resetRequestAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void remove_shouldCallDeleteByPersonId() {
|
||||||
|
when(service.deleteByPersonId("330101199001010011")).thenReturn(1);
|
||||||
|
|
||||||
|
AjaxResult result = controller.remove("330101199001010011");
|
||||||
|
|
||||||
|
assertEquals(200, result.get("code"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user