feat(credit): 添加被执行人历史功能模块
- 在CreditJudgmentDebtor实体中增加historyId和historyName字段用于关联历史数据 - 新增CreditJudgmentDebtorHistory实体类用于存储被执行人历史记录 - 创建CreditJudgmentDebtorHistoryController提供完整的CRUD和批量导入导出接口 - 实现CreditJudgmentDebtorHistoryService及其实现类处理业务逻辑 - 添加CreditJudgmentDebtorHistoryMapper及XML映射文件支持数据库操作 - 新增CreditJudgmentDebtorHistoryParam和CreditJudgmentDebtorHistoryImportParam参数类 - 修改CreditJudgmentDebtorMapper.xml添加与历史表的关联查询 - 更新CreditUserMapper.xml在关键词搜索中加入历史被执行人名称匹配
This commit is contained in:
@@ -0,0 +1,549 @@
|
||||
package com.gxwebsoft.credit.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.credit.entity.CreditJudgmentDebtorHistory;
|
||||
import com.gxwebsoft.credit.param.CreditJudgmentDebtorHistoryImportParam;
|
||||
import com.gxwebsoft.credit.param.CreditJudgmentDebtorHistoryParam;
|
||||
import com.gxwebsoft.credit.service.CreditJudgmentDebtorHistoryService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* 被执行人控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-01-12 08:10:44
|
||||
*/
|
||||
@Tag(name = "被执行人管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/credit/credit-judgment-debtor-history")
|
||||
public class CreditJudgmentDebtorHistoryController extends BaseController {
|
||||
@Resource
|
||||
private CreditJudgmentDebtorHistoryService creditJudgmentDebtorHistoryService;
|
||||
|
||||
@Operation(summary = "分页查询被执行人")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<CreditJudgmentDebtorHistory>> page(CreditJudgmentDebtorHistoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(creditJudgmentDebtorHistoryService.pageRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询全部被执行人")
|
||||
@GetMapping()
|
||||
public ApiResult<List<CreditJudgmentDebtorHistory>> list(CreditJudgmentDebtorHistoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(creditJudgmentDebtorHistoryService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询被执行人")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<CreditJudgmentDebtorHistory> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(creditJudgmentDebtorHistoryService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditJudgmentDebtorHistory:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加被执行人")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody CreditJudgmentDebtorHistory creditJudgmentDebtorHistory) {
|
||||
if (creditJudgmentDebtorHistoryService.save(creditJudgmentDebtorHistory)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditJudgmentDebtorHistory:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改被执行人")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody CreditJudgmentDebtorHistory creditJudgmentDebtorHistory) {
|
||||
if (creditJudgmentDebtorHistoryService.updateById(creditJudgmentDebtorHistory)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditJudgmentDebtorHistory:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除被执行人")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (creditJudgmentDebtorHistoryService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditJudgmentDebtorHistory:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加被执行人")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<CreditJudgmentDebtorHistory> list) {
|
||||
if (creditJudgmentDebtorHistoryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditJudgmentDebtorHistory:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改被执行人")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<CreditJudgmentDebtorHistory> batchParam) {
|
||||
if (batchParam.update(creditJudgmentDebtorHistoryService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditJudgmentDebtorHistory:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除被执行人")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (creditJudgmentDebtorHistoryService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导入被执行人历史
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('credit:creditJudgmentDebtorHistory:save')")
|
||||
@Operation(summary = "批量导入被执行人历史")
|
||||
@PostMapping("/import")
|
||||
public ApiResult<List<String>> importBatch(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "companyId", required = false) Integer companyId) {
|
||||
try {
|
||||
User loginUser = getLoginUser();
|
||||
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
|
||||
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
|
||||
|
||||
ImportOutcome outcome;
|
||||
if (isZip(file)) {
|
||||
outcome = importFromZip(file, currentUserId, currentTenantId, companyId);
|
||||
} else {
|
||||
outcome = importFromExcel(file, safeFileLabel(file.getOriginalFilename()), currentUserId, currentTenantId, companyId, false);
|
||||
}
|
||||
|
||||
if (!outcome.anyDataRead) {
|
||||
return fail("未读取到数据,请确认模板表头与示例格式一致", null);
|
||||
}
|
||||
if (outcome.errorMessages.isEmpty()) {
|
||||
return success("成功导入" + outcome.successCount + "条数据", null);
|
||||
}
|
||||
return success("导入完成,成功" + outcome.successCount + "条,失败" + outcome.errorMessages.size() + "条", outcome.errorMessages);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return fail("导入失败:" + e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载被执行人历史导入模板
|
||||
*/
|
||||
@Operation(summary = "下载被执行人历史导入模板")
|
||||
@GetMapping("/import/template")
|
||||
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||
List<CreditJudgmentDebtorHistoryImportParam> templateList = new ArrayList<>();
|
||||
|
||||
CreditJudgmentDebtorHistoryImportParam example = new CreditJudgmentDebtorHistoryImportParam();
|
||||
example.setCaseNumber("(2024)示例案号");
|
||||
example.setName("某某公司");
|
||||
example.setCode("1234567890");
|
||||
example.setOccurrenceTime("2024-01-10");
|
||||
example.setAmount("100000");
|
||||
example.setDataStatus("已公开");
|
||||
example.setComments("备注信息");
|
||||
templateList.add(example);
|
||||
|
||||
Workbook workbook = ExcelImportSupport.buildTemplate("被执行人历史导入模板", "历史被执行人", CreditJudgmentDebtorHistoryImportParam.class, templateList);
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=credit_judgment_debtor_history_import_template.xlsx");
|
||||
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
private boolean isEmptyImportRow(CreditJudgmentDebtorHistoryImportParam param) {
|
||||
if (param == null) {
|
||||
return true;
|
||||
}
|
||||
if (isImportHeaderRow(param)) {
|
||||
return true;
|
||||
}
|
||||
return ImportHelper.isBlank(param.getCaseNumber())
|
||||
&& ImportHelper.isBlank(param.getName())
|
||||
&& ImportHelper.isBlank(param.getName1())
|
||||
&& ImportHelper.isBlank(param.getCode());
|
||||
}
|
||||
|
||||
private boolean isImportHeaderRow(CreditJudgmentDebtorHistoryImportParam param) {
|
||||
return isHeaderValue(param.getName(), "序号")
|
||||
|| isHeaderValue(param.getName1(), "序号")
|
||||
|| isHeaderValue(param.getCaseNumber(), "案号")
|
||||
|| isHeaderValue(param.getName(), "被执行人名称")
|
||||
|| isHeaderValue(param.getName1(), "被执行人")
|
||||
|| isHeaderValue(param.getCode(), "证件号/组织机构代码")
|
||||
|| isHeaderValue(param.getOccurrenceTime(), "立案日期")
|
||||
|| isHeaderValue(param.getCourtName(), "法院")
|
||||
|| isHeaderValue(param.getAmount(), "执行标的(元)")
|
||||
|| isHeaderValue(param.getDataStatus(), "数据状态");
|
||||
}
|
||||
|
||||
private static boolean isHeaderValue(String value, String headerText) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
return headerText.equals(value.trim());
|
||||
}
|
||||
|
||||
private CreditJudgmentDebtorHistory convertImportParamToEntity(CreditJudgmentDebtorHistoryImportParam param) {
|
||||
CreditJudgmentDebtorHistory entity = new CreditJudgmentDebtorHistory();
|
||||
|
||||
entity.setCaseNumber(param.getCaseNumber());
|
||||
entity.setName1(param.getName1());
|
||||
String debtorName = ImportHelper.isBlank(param.getName()) ? param.getName1() : param.getName();
|
||||
entity.setName(debtorName);
|
||||
entity.setCode(param.getCode());
|
||||
entity.setOccurrenceTime(param.getOccurrenceTime());
|
||||
entity.setAmount(param.getAmount());
|
||||
entity.setCourtName(param.getCourtName());
|
||||
entity.setDataStatus(param.getDataStatus());
|
||||
entity.setComments(param.getComments());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private static class ImportOutcome {
|
||||
private final boolean anyDataRead;
|
||||
private final int successCount;
|
||||
private final List<String> errorMessages;
|
||||
|
||||
private ImportOutcome(boolean anyDataRead, int successCount, List<String> errorMessages) {
|
||||
this.anyDataRead = anyDataRead;
|
||||
this.successCount = successCount;
|
||||
this.errorMessages = errorMessages;
|
||||
}
|
||||
}
|
||||
|
||||
private ImportOutcome importFromExcel(MultipartFile excelFile, String fileLabel, Integer currentUserId, Integer currentTenantId, Integer companyId, boolean strictHistorySheet) throws Exception {
|
||||
List<String> errorMessages = new ArrayList<>();
|
||||
int successCount = 0;
|
||||
|
||||
ExcelImportSupport.ImportResult<CreditJudgmentDebtorHistoryImportParam> importResult = readHistoryImport(excelFile, strictHistorySheet);
|
||||
List<CreditJudgmentDebtorHistoryImportParam> list = importResult.getData();
|
||||
int usedTitleRows = importResult.getTitleRows();
|
||||
int usedHeadRows = importResult.getHeadRows();
|
||||
int usedSheetIndex = importResult.getSheetIndex();
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return new ImportOutcome(false, 0, errorMessages);
|
||||
}
|
||||
|
||||
Map<String, String> urlByCaseNumber = ExcelImportSupport.readHyperlinksByHeaderKey(excelFile, usedSheetIndex, usedTitleRows, usedHeadRows, "案号");
|
||||
Map<String, String> urlByName = ExcelImportSupport.readHyperlinksByHeaderKey(excelFile, usedSheetIndex, usedTitleRows, usedHeadRows, "被执行人名称");
|
||||
Map<String, String> urlByName1 = ExcelImportSupport.readHyperlinksByHeaderKey(excelFile, usedSheetIndex, usedTitleRows, usedHeadRows, "被执行人");
|
||||
|
||||
String prefix = ImportHelper.isBlank(fileLabel) ? "" : "【" + fileLabel + "】";
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
CreditJudgmentDebtorHistoryImportParam param = list.get(i);
|
||||
try {
|
||||
CreditJudgmentDebtorHistory item = convertImportParamToEntity(param);
|
||||
String link = null;
|
||||
if (!ImportHelper.isBlank(item.getCaseNumber())) {
|
||||
link = urlByCaseNumber.get(item.getCaseNumber().trim());
|
||||
}
|
||||
if ((link == null || link.isEmpty()) && !ImportHelper.isBlank(item.getName())) {
|
||||
link = urlByName.get(item.getName().trim());
|
||||
}
|
||||
if ((link == null || link.isEmpty()) && !ImportHelper.isBlank(item.getName1())) {
|
||||
link = urlByName1.get(item.getName1().trim());
|
||||
}
|
||||
if (link != null && !link.isEmpty()) {
|
||||
item.setUrl(link);
|
||||
}
|
||||
|
||||
if (item.getCompanyId() == null && companyId != null) {
|
||||
item.setCompanyId(companyId);
|
||||
}
|
||||
if (item.getUserId() == null && currentUserId != null) {
|
||||
item.setUserId(currentUserId);
|
||||
}
|
||||
if (item.getTenantId() == null && currentTenantId != null) {
|
||||
item.setTenantId(currentTenantId);
|
||||
}
|
||||
if (item.getType() == null) {
|
||||
item.setType(0);
|
||||
}
|
||||
if (item.getStatus() == null) {
|
||||
item.setStatus(0);
|
||||
}
|
||||
if (item.getRecommend() == null) {
|
||||
item.setRecommend(0);
|
||||
}
|
||||
if (item.getDeleted() == null) {
|
||||
item.setDeleted(0);
|
||||
}
|
||||
|
||||
int excelRowNumber = i + 1 + usedTitleRows + usedHeadRows;
|
||||
if (ImportHelper.isBlank(item.getCaseNumber())) {
|
||||
errorMessages.add(prefix + "第" + excelRowNumber + "行:案号不能为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean saved = creditJudgmentDebtorHistoryService.save(item);
|
||||
if (!saved) {
|
||||
CreditJudgmentDebtorHistory existing = creditJudgmentDebtorHistoryService.lambdaQuery()
|
||||
.eq(CreditJudgmentDebtorHistory::getCaseNumber, item.getCaseNumber())
|
||||
.one();
|
||||
if (existing != null) {
|
||||
item.setId(existing.getId());
|
||||
if (creditJudgmentDebtorHistoryService.updateById(item)) {
|
||||
successCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
successCount++;
|
||||
continue;
|
||||
}
|
||||
errorMessages.add(prefix + "第" + excelRowNumber + "行:保存失败");
|
||||
} catch (Exception e) {
|
||||
int excelRowNumber = i + 1 + usedTitleRows + usedHeadRows;
|
||||
errorMessages.add(prefix + "第" + excelRowNumber + "行:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new ImportOutcome(true, successCount, errorMessages);
|
||||
}
|
||||
|
||||
private ImportOutcome importFromZip(MultipartFile zipFile, Integer currentUserId, Integer currentTenantId, Integer companyId) throws Exception {
|
||||
try {
|
||||
return importFromZip(zipFile, currentUserId, currentTenantId, companyId, StandardCharsets.UTF_8);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return importFromZip(zipFile, currentUserId, currentTenantId, companyId, Charset.forName("GBK"));
|
||||
}
|
||||
}
|
||||
|
||||
private ImportOutcome importFromZip(MultipartFile zipFile, Integer currentUserId, Integer currentTenantId, Integer companyId, Charset charset) throws Exception {
|
||||
List<String> errorMessages = new ArrayList<>();
|
||||
int successCount = 0;
|
||||
boolean anyDataRead = false;
|
||||
|
||||
try (InputStream is = zipFile.getInputStream(); ZipInputStream zis = new ZipInputStream(is, charset)) {
|
||||
ZipEntry entry;
|
||||
while ((entry = zis.getNextEntry()) != null) {
|
||||
if (entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
String entryName = entry.getName();
|
||||
if (!isExcelFileName(entryName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
byte[] bytes = readAllBytes(zis);
|
||||
String entryFileName = safeFileLabel(entryName);
|
||||
MultipartFile excelFile = new InMemoryMultipartFile(entryFileName, bytes);
|
||||
|
||||
try {
|
||||
ImportOutcome outcome = importFromExcel(excelFile, entryFileName, currentUserId, currentTenantId, companyId, true);
|
||||
if (outcome.anyDataRead) {
|
||||
anyDataRead = true;
|
||||
successCount += outcome.successCount;
|
||||
errorMessages.addAll(outcome.errorMessages);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorMessages.add("【" + entryFileName + "】解析失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ImportOutcome(anyDataRead, successCount, errorMessages);
|
||||
}
|
||||
|
||||
private static boolean isZip(MultipartFile file) {
|
||||
String filename = file != null ? file.getOriginalFilename() : null;
|
||||
if (filename == null) {
|
||||
return false;
|
||||
}
|
||||
return filename.toLowerCase(Locale.ROOT).endsWith(".zip");
|
||||
}
|
||||
|
||||
private ExcelImportSupport.ImportResult<CreditJudgmentDebtorHistoryImportParam> readHistoryImport(MultipartFile excelFile, boolean strictHistorySheet) throws Exception {
|
||||
int namedSheetIndex = ExcelImportSupport.findSheetIndex(excelFile, "历史被执行人");
|
||||
if (namedSheetIndex >= 0) {
|
||||
ExcelImportSupport.ImportResult<CreditJudgmentDebtorHistoryImportParam> namedSheetResult = ExcelImportSupport.readBest(
|
||||
excelFile,
|
||||
CreditJudgmentDebtorHistoryImportParam.class,
|
||||
this::isEmptyImportRow,
|
||||
this::isScoreImportRow,
|
||||
namedSheetIndex
|
||||
);
|
||||
if (!CollectionUtils.isEmpty(namedSheetResult.getData())) {
|
||||
return namedSheetResult;
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> historySheetIndices = findHistorySheetIndices(excelFile);
|
||||
for (Integer sheetIndex : historySheetIndices) {
|
||||
if (sheetIndex != null && sheetIndex == namedSheetIndex) {
|
||||
continue;
|
||||
}
|
||||
ExcelImportSupport.ImportResult<CreditJudgmentDebtorHistoryImportParam> sheetResult = ExcelImportSupport.readBest(
|
||||
excelFile,
|
||||
CreditJudgmentDebtorHistoryImportParam.class,
|
||||
this::isEmptyImportRow,
|
||||
this::isScoreImportRow,
|
||||
sheetIndex
|
||||
);
|
||||
if (!CollectionUtils.isEmpty(sheetResult.getData())) {
|
||||
return sheetResult;
|
||||
}
|
||||
}
|
||||
if (strictHistorySheet) {
|
||||
return new ExcelImportSupport.ImportResult<>(new ArrayList<>(), 0, 0);
|
||||
}
|
||||
return ExcelImportSupport.readAnySheetBest(excelFile, CreditJudgmentDebtorHistoryImportParam.class, this::isEmptyImportRow, this::isScoreImportRow);
|
||||
}
|
||||
|
||||
private boolean isScoreImportRow(CreditJudgmentDebtorHistoryImportParam param) {
|
||||
if (param == null) {
|
||||
return false;
|
||||
}
|
||||
if (isImportHeaderRow(param)) {
|
||||
return false;
|
||||
}
|
||||
return !ImportHelper.isBlank(param.getCaseNumber());
|
||||
}
|
||||
|
||||
private List<Integer> findHistorySheetIndices(MultipartFile excelFile) throws Exception {
|
||||
List<Integer> indices = new ArrayList<>();
|
||||
try (InputStream is = excelFile.getInputStream(); Workbook workbook = WorkbookFactory.create(is)) {
|
||||
int sheetCount = workbook.getNumberOfSheets();
|
||||
for (int i = 0; i < sheetCount; i++) {
|
||||
String sheetName = workbook.getSheetName(i);
|
||||
if (isHistorySheetName(sheetName)) {
|
||||
indices.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return indices;
|
||||
}
|
||||
|
||||
private static boolean isHistorySheetName(String sheetName) {
|
||||
if (sheetName == null) {
|
||||
return false;
|
||||
}
|
||||
String normalized = sheetName.replace(" ", "").trim();
|
||||
return normalized.contains("被执行人") && normalized.contains("历史") && !normalized.contains("失信");
|
||||
}
|
||||
|
||||
private static boolean isExcelFileName(String name) {
|
||||
if (name == null) {
|
||||
return false;
|
||||
}
|
||||
String lower = name.toLowerCase(Locale.ROOT);
|
||||
return lower.endsWith(".xlsx") || lower.endsWith(".xls") || lower.endsWith(".xlsm");
|
||||
}
|
||||
|
||||
private static String safeFileLabel(String name) {
|
||||
if (ImportHelper.isBlank(name)) {
|
||||
return "";
|
||||
}
|
||||
int lastSlash = name.lastIndexOf('/');
|
||||
if (lastSlash >= 0 && lastSlash + 1 < name.length()) {
|
||||
return name.substring(lastSlash + 1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private static byte[] readAllBytes(InputStream inputStream) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[8192];
|
||||
int read;
|
||||
while ((read = inputStream.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, read);
|
||||
}
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
private static class InMemoryMultipartFile implements MultipartFile {
|
||||
private final String originalFilename;
|
||||
private final byte[] bytes;
|
||||
|
||||
private InMemoryMultipartFile(String originalFilename, byte[] bytes) {
|
||||
this.originalFilename = originalFilename;
|
||||
this.bytes = bytes != null ? bytes : new byte[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return originalFilename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return originalFilename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return bytes.length == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return bytes.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new java.io.ByteArrayInputStream(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(java.io.File dest) throws IOException {
|
||||
Files.write(dest.toPath(), bytes);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 被执行人
|
||||
@@ -94,4 +95,13 @@ public class CreditJudgmentDebtor implements Serializable {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "历史被执行人ID")
|
||||
@TableField(exist = false)
|
||||
private Integer historyId;
|
||||
|
||||
@Schema(description = "历史被执行人名称")
|
||||
@TableField(exist = false)
|
||||
private String historyName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.gxwebsoft.credit.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 被执行人
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-01-12 08:10:43
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(name = "CreditJudgmentDebtorHistory对象", description = "被执行人")
|
||||
public class CreditJudgmentDebtorHistory implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Schema(description = "被执行人名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "被执行人")
|
||||
private String name1;
|
||||
|
||||
@Schema(description = "证件号/组织机构代码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "链接")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "是否多企业")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "立案日期")
|
||||
private String occurrenceTime;
|
||||
|
||||
@Schema(description = "执行标的(元)")
|
||||
private String amount;
|
||||
|
||||
@Schema(description = "法院")
|
||||
private String courtName;
|
||||
|
||||
@Schema(description = "数据状态")
|
||||
private String dataStatus;
|
||||
|
||||
@Schema(description = "企业ID")
|
||||
private Integer companyId;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "是否推荐")
|
||||
private Integer recommend;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.credit.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.credit.entity.CreditJudgmentDebtorHistory;
|
||||
import com.gxwebsoft.credit.param.CreditJudgmentDebtorHistoryParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 被执行人Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-01-12 08:10:43
|
||||
*/
|
||||
public interface CreditJudgmentDebtorHistoryMapper extends BaseMapper<CreditJudgmentDebtorHistory> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<CreditJudgmentDebtorHistory>
|
||||
*/
|
||||
List<CreditJudgmentDebtorHistory> selectPageRel(@Param("page") IPage<CreditJudgmentDebtorHistory> page,
|
||||
@Param("param") CreditJudgmentDebtorHistoryParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<CreditJudgmentDebtorHistory> selectListRel(@Param("param") CreditJudgmentDebtorHistoryParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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.gxwebsoft.credit.mapper.CreditJudgmentDebtorHistoryMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM credit_judgment_debtor_history a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.caseNumber != null">
|
||||
AND a.case_number LIKE CONCAT('%', #{param.caseNumber}, '%')
|
||||
</if>
|
||||
<if test="param.name != null">
|
||||
AND a.name LIKE CONCAT('%', #{param.name}, '%')
|
||||
</if>
|
||||
<if test="param.name1 != null">
|
||||
AND a.name1 LIKE CONCAT('%', #{param.name1}, '%')
|
||||
</if>
|
||||
<if test="param.code != null">
|
||||
AND a.code LIKE CONCAT('%', #{param.code}, '%')
|
||||
</if>
|
||||
<if test="param.url != null">
|
||||
AND a.url LIKE CONCAT('%', #{param.url}, '%')
|
||||
</if>
|
||||
<if test="param.type != null">
|
||||
AND a.type = #{param.type}
|
||||
</if>
|
||||
<if test="param.occurrenceTime != null">
|
||||
AND a.occurrence_time LIKE CONCAT('%', #{param.occurrenceTime}, '%')
|
||||
</if>
|
||||
<if test="param.amount != null">
|
||||
AND a.amount LIKE CONCAT('%', #{param.amount}, '%')
|
||||
</if>
|
||||
<if test="param.courtName != null">
|
||||
AND a.court_name LIKE CONCAT('%', #{param.courtName}, '%')
|
||||
</if>
|
||||
<if test="param.dataStatus != null">
|
||||
AND a.data_status LIKE CONCAT('%', #{param.dataStatus}, '%')
|
||||
</if>
|
||||
<if test="param.companyId != null">
|
||||
AND a.company_id = #{param.companyId}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.recommend != null">
|
||||
AND a.recommend = #{param.recommend}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.credit.entity.CreditJudgmentDebtorHistory">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.credit.entity.CreditJudgmentDebtorHistory">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, b.name AS companyName
|
||||
SELECT a.*, b.name AS companyName, c.id as historyId, c.name as historyName
|
||||
FROM credit_judgment_debtor a
|
||||
LEFT JOIN credit_company b ON a.company_id = b.id
|
||||
LEFT JOIN credit_judgment_debtor_history c ON a.case_number = c.case_number
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
AND (a.name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.procurement_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.winning_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR b.name = #{param.keywords}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.credit.param;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 被执行人历史导入参数
|
||||
*/
|
||||
@Data
|
||||
public class CreditJudgmentDebtorHistoryImportParam implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Excel(name = "被执行人名称")
|
||||
private String name;
|
||||
|
||||
@Excel(name = "被执行人")
|
||||
private String name1;
|
||||
|
||||
@Excel(name = "证件号/组织机构代码")
|
||||
private String code;
|
||||
|
||||
@Excel(name = "立案日期")
|
||||
private String occurrenceTime;
|
||||
|
||||
@Excel(name = "执行标的(元)")
|
||||
private String amount;
|
||||
|
||||
@Excel(name = "法院")
|
||||
private String courtName;
|
||||
|
||||
@Excel(name = "数据状态")
|
||||
private String dataStatus;
|
||||
|
||||
@Excel(name = "备注")
|
||||
private String comments;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.gxwebsoft.credit.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 被执行人查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-01-12 08:10:43
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "CreditJudgmentDebtorHistoryParam对象", description = "被执行人查询参数")
|
||||
public class CreditJudgmentDebtorHistoryParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Schema(description = "被执行人名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "被执行人")
|
||||
private String name1;
|
||||
|
||||
@Schema(description = "证件号/组织机构代码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "链接")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "是否多企业")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "立案日期")
|
||||
private String occurrenceTime;
|
||||
|
||||
@Schema(description = "执行标的(元)")
|
||||
private String amount;
|
||||
|
||||
@Schema(description = "法院")
|
||||
private String courtName;
|
||||
|
||||
@Schema(description = "数据状态")
|
||||
private String dataStatus;
|
||||
|
||||
@Schema(description = "企业ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer companyId;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "是否推荐")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer recommend;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.credit.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.credit.entity.CreditJudgmentDebtorHistory;
|
||||
import com.gxwebsoft.credit.param.CreditJudgmentDebtorHistoryParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 被执行人Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-01-12 08:10:43
|
||||
*/
|
||||
public interface CreditJudgmentDebtorHistoryService extends IService<CreditJudgmentDebtorHistory> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<CreditJudgmentDebtorHistory>
|
||||
*/
|
||||
PageResult<CreditJudgmentDebtorHistory> pageRel(CreditJudgmentDebtorHistoryParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<CreditJudgmentDebtorHistory>
|
||||
*/
|
||||
List<CreditJudgmentDebtorHistory> listRel(CreditJudgmentDebtorHistoryParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return CreditJudgmentDebtorHistory
|
||||
*/
|
||||
CreditJudgmentDebtorHistory getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.credit.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.credit.entity.CreditJudgmentDebtorHistory;
|
||||
import com.gxwebsoft.credit.mapper.CreditJudgmentDebtorHistoryMapper;
|
||||
import com.gxwebsoft.credit.param.CreditJudgmentDebtorHistoryParam;
|
||||
import com.gxwebsoft.credit.service.CreditJudgmentDebtorHistoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 被执行人Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-01-12 08:10:43
|
||||
*/
|
||||
@Service
|
||||
public class CreditJudgmentDebtorHistoryServiceImpl extends ServiceImpl<CreditJudgmentDebtorHistoryMapper, CreditJudgmentDebtorHistory> implements CreditJudgmentDebtorHistoryService {
|
||||
|
||||
@Override
|
||||
public PageResult<CreditJudgmentDebtorHistory> pageRel(CreditJudgmentDebtorHistoryParam param) {
|
||||
PageParam<CreditJudgmentDebtorHistory, CreditJudgmentDebtorHistoryParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<CreditJudgmentDebtorHistory> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CreditJudgmentDebtorHistory> listRel(CreditJudgmentDebtorHistoryParam param) {
|
||||
List<CreditJudgmentDebtorHistory> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<CreditJudgmentDebtorHistory, CreditJudgmentDebtorHistoryParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreditJudgmentDebtorHistory getByIdRel(Integer id) {
|
||||
CreditJudgmentDebtorHistoryParam param = new CreditJudgmentDebtorHistoryParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user