feat(judicial): 增加URL字段并优化Excel导入功能
- 在CreditCaseFiling、CreditCourtSession和CreditMediation实体中新增URL字段 - 实现Excel导入时自动读取案号列的超链接地址并回填到URL字段 - 创建独立的CreditCourtSessionImportParam和CreditMediationImportParam导入参数类 - 将立案时间字段名称统一调整为立案日期 - 优化导入模板生成和空行判断逻辑 - 更新导入参数转换方法,移除冗余字段映射
This commit is contained in:
@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 司法大数据控制器
|
||||
@@ -150,6 +151,7 @@ public class CreditCaseFilingController extends BaseController {
|
||||
List<CreditCaseFilingImportParam> list = importResult.getData();
|
||||
int usedTitleRows = importResult.getTitleRows();
|
||||
int usedHeadRows = importResult.getHeadRows();
|
||||
int usedSheetIndex = importResult.getSheetIndex();
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return fail("未读取到数据,请确认模板表头与示例格式一致", null);
|
||||
@@ -158,6 +160,8 @@ public class CreditCaseFilingController extends BaseController {
|
||||
User loginUser = getLoginUser();
|
||||
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
|
||||
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
|
||||
// easypoi 默认不会读取单元格超链接地址;url 通常挂在“案号”列的超链接中,需要额外读取回填。
|
||||
Map<String, String> urlByCaseNumber = ExcelImportSupport.readHyperlinksByHeaderKey(file, usedSheetIndex, usedTitleRows, usedHeadRows, "案号");
|
||||
|
||||
final int chunkSize = 500;
|
||||
final int mpBatchSize = 500;
|
||||
@@ -168,6 +172,12 @@ public class CreditCaseFilingController extends BaseController {
|
||||
CreditCaseFilingImportParam param = list.get(i);
|
||||
try {
|
||||
CreditCaseFiling item = convertImportParamToEntity(param);
|
||||
if (!ImportHelper.isBlank(item.getCaseNumber())) {
|
||||
String link = urlByCaseNumber.get(item.getCaseNumber().trim());
|
||||
if (link != null && !link.isEmpty()) {
|
||||
item.setUrl(link);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getCompanyId() == null && companyId != null) {
|
||||
item.setCompanyId(companyId);
|
||||
@@ -298,16 +308,11 @@ public class CreditCaseFilingController extends BaseController {
|
||||
List<CreditCaseFilingImportParam> templateList = new ArrayList<>();
|
||||
|
||||
CreditCaseFilingImportParam example = new CreditCaseFilingImportParam();
|
||||
example.setDataType("司法大数据");
|
||||
example.setPlaintiffAppellant("原告示例");
|
||||
example.setAppellee("被告示例");
|
||||
example.setOtherPartiesThirdParty("第三人示例");
|
||||
example.setOccurrenceTime("2024-01-01");
|
||||
example.setCaseNumber("(2024)示例案号");
|
||||
example.setCauseOfAction("案由示例");
|
||||
example.setInvolvedAmount("100000");
|
||||
example.setOtherPartiesThirdParty("当事人示例");
|
||||
example.setCourtName("示例法院");
|
||||
example.setDataStatus("已公开");
|
||||
example.setOccurrenceTime("2024-01-01");
|
||||
example.setComments("备注信息");
|
||||
templateList.add(example);
|
||||
|
||||
@@ -325,24 +330,21 @@ public class CreditCaseFilingController extends BaseController {
|
||||
return true;
|
||||
}
|
||||
return ImportHelper.isBlank(param.getCaseNumber())
|
||||
&& ImportHelper.isBlank(param.getPlaintiffAppellant())
|
||||
&& ImportHelper.isBlank(param.getAppellee())
|
||||
&& ImportHelper.isBlank(param.getCauseOfAction());
|
||||
&& ImportHelper.isBlank(param.getCauseOfAction())
|
||||
&& ImportHelper.isBlank(param.getOtherPartiesThirdParty())
|
||||
&& ImportHelper.isBlank(param.getCourtName())
|
||||
&& ImportHelper.isBlank(param.getOccurrenceTime())
|
||||
&& ImportHelper.isBlank(param.getComments());
|
||||
}
|
||||
|
||||
private CreditCaseFiling convertImportParamToEntity(CreditCaseFilingImportParam param) {
|
||||
CreditCaseFiling entity = new CreditCaseFiling();
|
||||
|
||||
entity.setDataType(param.getDataType());
|
||||
entity.setPlaintiffAppellant(param.getPlaintiffAppellant());
|
||||
entity.setAppellee(param.getAppellee());
|
||||
entity.setOtherPartiesThirdParty(param.getOtherPartiesThirdParty());
|
||||
entity.setOccurrenceTime(param.getOccurrenceTime());
|
||||
entity.setCaseNumber(param.getCaseNumber());
|
||||
entity.setCauseOfAction(param.getCauseOfAction());
|
||||
entity.setInvolvedAmount(param.getInvolvedAmount());
|
||||
entity.setOtherPartiesThirdParty(param.getOtherPartiesThirdParty());
|
||||
entity.setCourtName(param.getCourtName());
|
||||
entity.setDataStatus(param.getDataStatus());
|
||||
entity.setOccurrenceTime(param.getOccurrenceTime());
|
||||
entity.setComments(param.getComments());
|
||||
|
||||
return entity;
|
||||
|
||||
@@ -7,7 +7,7 @@ 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.CreditCourtSession;
|
||||
import com.gxwebsoft.credit.param.CreditJudicialImportParam;
|
||||
import com.gxwebsoft.credit.param.CreditCourtSessionImportParam;
|
||||
import com.gxwebsoft.credit.param.CreditCourtSessionParam;
|
||||
import com.gxwebsoft.credit.service.CreditCourtSessionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -144,9 +144,9 @@ public class CreditCourtSessionController extends BaseController {
|
||||
int successCount = 0;
|
||||
|
||||
try {
|
||||
ExcelImportSupport.ImportResult<CreditJudicialImportParam> importResult = ExcelImportSupport.read(
|
||||
file, CreditJudicialImportParam.class, this::isEmptyImportRow);
|
||||
List<CreditJudicialImportParam> list = importResult.getData();
|
||||
ExcelImportSupport.ImportResult<CreditCourtSessionImportParam> importResult = ExcelImportSupport.read(
|
||||
file, CreditCourtSessionImportParam.class, this::isEmptyImportRow);
|
||||
List<CreditCourtSessionImportParam> list = importResult.getData();
|
||||
int usedTitleRows = importResult.getTitleRows();
|
||||
int usedHeadRows = importResult.getHeadRows();
|
||||
|
||||
@@ -164,7 +164,7 @@ public class CreditCourtSessionController extends BaseController {
|
||||
List<Integer> chunkRowNumbers = new ArrayList<>(chunkSize);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
CreditJudicialImportParam param = list.get(i);
|
||||
CreditCourtSessionImportParam param = list.get(i);
|
||||
try {
|
||||
CreditCourtSession item = convertImportParamToEntity(param);
|
||||
|
||||
@@ -294,23 +294,18 @@ public class CreditCourtSessionController extends BaseController {
|
||||
@Operation(summary = "下载开庭公告司法大数据导入模板")
|
||||
@GetMapping("/import/template")
|
||||
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||
List<CreditJudicialImportParam> templateList = new ArrayList<>();
|
||||
List<CreditCourtSessionImportParam> templateList = new ArrayList<>();
|
||||
|
||||
CreditJudicialImportParam example = new CreditJudicialImportParam();
|
||||
example.setDataType("开庭公告");
|
||||
example.setPlaintiffAppellant("原告示例");
|
||||
example.setAppellee("被告示例");
|
||||
example.setOtherPartiesThirdParty("第三人示例");
|
||||
example.setOccurrenceTime("2024-01-01");
|
||||
CreditCourtSessionImportParam example = new CreditCourtSessionImportParam();
|
||||
example.setOtherPartiesThirdParty("当事人");
|
||||
example.setCaseNumber("(2024)示例案号");
|
||||
example.setCauseOfAction("案由示例");
|
||||
example.setInvolvedAmount("100000");
|
||||
example.setCourtName("示例法院");
|
||||
example.setDataStatus("已公开");
|
||||
example.setOccurrenceTime("2024-01-01");
|
||||
example.setComments("备注信息");
|
||||
templateList.add(example);
|
||||
|
||||
Workbook workbook = ExcelImportSupport.buildTemplate("开庭公告导入模板", "开庭公告", CreditJudicialImportParam.class, templateList);
|
||||
Workbook workbook = ExcelImportSupport.buildTemplate("开庭公告导入模板", "开庭公告", CreditCourtSessionImportParam.class, templateList);
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=credit_court_session_import_template.xlsx");
|
||||
@@ -319,30 +314,23 @@ public class CreditCourtSessionController extends BaseController {
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
private boolean isEmptyImportRow(CreditJudicialImportParam param) {
|
||||
private boolean isEmptyImportRow(CreditCourtSessionImportParam param) {
|
||||
if (param == null) {
|
||||
return true;
|
||||
}
|
||||
return ImportHelper.isBlank(param.getCaseNumber())
|
||||
&& ImportHelper.isBlank(param.getPlaintiffAppellant())
|
||||
&& ImportHelper.isBlank(param.getAppellee())
|
||||
&& ImportHelper.isBlank(param.getCauseOfAction());
|
||||
}
|
||||
|
||||
private CreditCourtSession convertImportParamToEntity(CreditJudicialImportParam param) {
|
||||
private CreditCourtSession convertImportParamToEntity(CreditCourtSessionImportParam param) {
|
||||
CreditCourtSession entity = new CreditCourtSession();
|
||||
|
||||
entity.setDataType(param.getDataType());
|
||||
entity.setPlaintiffAppellant(param.getPlaintiffAppellant());
|
||||
entity.setAppellee(param.getAppellee());
|
||||
entity.setOtherPartiesThirdParty(param.getOtherPartiesThirdParty());
|
||||
entity.setOccurrenceTime(param.getOccurrenceTime());
|
||||
entity.setCaseNumber(param.getCaseNumber());
|
||||
entity.setCauseOfAction(param.getCauseOfAction());
|
||||
entity.setInvolvedAmount(param.getInvolvedAmount());
|
||||
entity.setCourtName(param.getCourtName());
|
||||
entity.setDataStatus(param.getDataStatus());
|
||||
entity.setComments(param.getComments());
|
||||
entity.setOtherPartiesThirdParty(param.getOtherPartiesThirdParty());
|
||||
entity.setOccurrenceTime(param.getOccurrenceTime());
|
||||
entity.setCaseNumber(param.getCaseNumber());
|
||||
entity.setCauseOfAction(param.getCauseOfAction());
|
||||
entity.setCourtName(param.getCourtName());
|
||||
entity.setComments(param.getComments());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ 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.CreditMediation;
|
||||
import com.gxwebsoft.credit.param.CreditJudicialImportParam;
|
||||
import com.gxwebsoft.credit.param.CreditMediationImportParam;
|
||||
import com.gxwebsoft.credit.param.CreditMediationParam;
|
||||
import com.gxwebsoft.credit.service.CreditMediationService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 诉前调解司法大数据控制器
|
||||
@@ -144,11 +145,13 @@ public class CreditMediationController extends BaseController {
|
||||
int successCount = 0;
|
||||
|
||||
try {
|
||||
ExcelImportSupport.ImportResult<CreditJudicialImportParam> importResult = ExcelImportSupport.read(
|
||||
file, CreditJudicialImportParam.class, this::isEmptyImportRow);
|
||||
List<CreditJudicialImportParam> list = importResult.getData();
|
||||
int sheetIndex = ExcelImportSupport.findSheetIndex(file, "诉前调解", 0);
|
||||
ExcelImportSupport.ImportResult<CreditMediationImportParam> importResult = ExcelImportSupport.read(
|
||||
file, CreditMediationImportParam.class, this::isEmptyImportRow, sheetIndex);
|
||||
List<CreditMediationImportParam> list = importResult.getData();
|
||||
int usedTitleRows = importResult.getTitleRows();
|
||||
int usedHeadRows = importResult.getHeadRows();
|
||||
int usedSheetIndex = importResult.getSheetIndex();
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return fail("未读取到数据,请确认模板表头与示例格式一致", null);
|
||||
@@ -157,6 +160,9 @@ public class CreditMediationController extends BaseController {
|
||||
User loginUser = getLoginUser();
|
||||
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
|
||||
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
|
||||
// URL 通常以超链接形式存在于“案号”列里
|
||||
Map<String, String> urlByCaseNumber = ExcelImportSupport.readHyperlinksByHeaderKey(
|
||||
file, usedSheetIndex, usedTitleRows, usedHeadRows, "案号");
|
||||
|
||||
final int chunkSize = 500;
|
||||
final int mpBatchSize = 500;
|
||||
@@ -164,9 +170,15 @@ public class CreditMediationController extends BaseController {
|
||||
List<Integer> chunkRowNumbers = new ArrayList<>(chunkSize);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
CreditJudicialImportParam param = list.get(i);
|
||||
CreditMediationImportParam param = list.get(i);
|
||||
try {
|
||||
CreditMediation item = convertImportParamToEntity(param);
|
||||
if (!ImportHelper.isBlank(item.getCaseNumber())) {
|
||||
String link = urlByCaseNumber.get(item.getCaseNumber().trim());
|
||||
if (link != null && !link.isEmpty()) {
|
||||
item.setUrl(link);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getCompanyId() == null && companyId != null) {
|
||||
item.setCompanyId(companyId);
|
||||
@@ -294,23 +306,18 @@ public class CreditMediationController extends BaseController {
|
||||
@Operation(summary = "下载诉前调解导入模板")
|
||||
@GetMapping("/import/template")
|
||||
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||
List<CreditJudicialImportParam> templateList = new ArrayList<>();
|
||||
List<CreditMediationImportParam> templateList = new ArrayList<>();
|
||||
|
||||
CreditJudicialImportParam example = new CreditJudicialImportParam();
|
||||
example.setDataType("诉前调解");
|
||||
example.setPlaintiffAppellant("原告示例");
|
||||
example.setAppellee("被告示例");
|
||||
example.setOtherPartiesThirdParty("第三人示例");
|
||||
example.setOccurrenceTime("2024-01-01");
|
||||
CreditMediationImportParam example = new CreditMediationImportParam();
|
||||
example.setOtherPartiesThirdParty("当事人");
|
||||
example.setCaseNumber("(2024)示例案号");
|
||||
example.setCauseOfAction("案由示例");
|
||||
example.setInvolvedAmount("100000");
|
||||
example.setCourtName("示例法院");
|
||||
example.setDataStatus("已公开");
|
||||
example.setOccurrenceTime("2024-01-01");
|
||||
example.setComments("备注信息");
|
||||
templateList.add(example);
|
||||
|
||||
Workbook workbook = ExcelImportSupport.buildTemplate("诉前调解导入模板", "诉前调解", CreditJudicialImportParam.class, templateList);
|
||||
Workbook workbook = ExcelImportSupport.buildTemplate("诉前调解导入模板", "诉前调解", CreditMediationImportParam.class, templateList);
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=credit_mediation_import_template.xlsx");
|
||||
@@ -319,29 +326,22 @@ public class CreditMediationController extends BaseController {
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
private boolean isEmptyImportRow(CreditJudicialImportParam param) {
|
||||
private boolean isEmptyImportRow(CreditMediationImportParam param) {
|
||||
if (param == null) {
|
||||
return true;
|
||||
}
|
||||
return ImportHelper.isBlank(param.getCaseNumber())
|
||||
&& ImportHelper.isBlank(param.getPlaintiffAppellant())
|
||||
&& ImportHelper.isBlank(param.getAppellee())
|
||||
&& ImportHelper.isBlank(param.getCauseOfAction());
|
||||
}
|
||||
|
||||
private CreditMediation convertImportParamToEntity(CreditJudicialImportParam param) {
|
||||
private CreditMediation convertImportParamToEntity(CreditMediationImportParam param) {
|
||||
CreditMediation entity = new CreditMediation();
|
||||
|
||||
entity.setDataType(param.getDataType());
|
||||
entity.setPlaintiffAppellant(param.getPlaintiffAppellant());
|
||||
entity.setAppellee(param.getAppellee());
|
||||
entity.setOtherPartiesThirdParty(param.getOtherPartiesThirdParty());
|
||||
entity.setOccurrenceTime(param.getOccurrenceTime());
|
||||
entity.setCaseNumber(param.getCaseNumber());
|
||||
entity.setCauseOfAction(param.getCauseOfAction());
|
||||
entity.setInvolvedAmount(param.getInvolvedAmount());
|
||||
entity.setCourtName(param.getCourtName());
|
||||
entity.setDataStatus(param.getDataStatus());
|
||||
entity.setComments(param.getComments());
|
||||
|
||||
return entity;
|
||||
|
||||
@@ -43,12 +43,15 @@ public class CreditCaseFiling implements Serializable {
|
||||
@Schema(description = "其他当事人/第三人")
|
||||
private String otherPartiesThirdParty;
|
||||
|
||||
@Schema(description = "立案时间")
|
||||
@Schema(description = "立案日期")
|
||||
private String occurrenceTime;
|
||||
|
||||
@Schema(description = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Schema(description = "项目网址")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "案由")
|
||||
private String causeOfAction;
|
||||
|
||||
|
||||
@@ -49,6 +49,9 @@ public class CreditCourtSession implements Serializable {
|
||||
@Schema(description = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Schema(description = "链接地址")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "案由")
|
||||
private String causeOfAction;
|
||||
|
||||
|
||||
@@ -49,6 +49,9 @@ public class CreditMediation implements Serializable {
|
||||
@Schema(description = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Schema(description = "链接地址")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "案由")
|
||||
private String causeOfAction;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class CreditCaseFilingImportParam implements Serializable {
|
||||
@Excel(name = "法院")
|
||||
private String courtName;
|
||||
|
||||
@Excel(name = "立案时间")
|
||||
@Excel(name = "立案日期")
|
||||
private String occurrenceTime;
|
||||
|
||||
@Excel(name = "备注")
|
||||
|
||||
@@ -45,6 +45,9 @@ public class CreditCaseFilingParam extends BaseParam {
|
||||
@Schema(description = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Schema(description = "项目网址")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "案由")
|
||||
private String causeOfAction;
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.gxwebsoft.credit.param;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 司法通用导入参数
|
||||
*/
|
||||
@Data
|
||||
public class CreditCourtSessionImportParam implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Excel(name = "案由")
|
||||
private String causeOfAction;
|
||||
|
||||
@Excel(name = "当事人")
|
||||
private String otherPartiesThirdParty;
|
||||
|
||||
@Excel(name = "法院")
|
||||
private String courtName;
|
||||
|
||||
@Excel(name = "开庭时间")
|
||||
private String occurrenceTime;
|
||||
|
||||
@Excel(name = "备注")
|
||||
private String comments;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.gxwebsoft.credit.param;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 司法通用导入参数
|
||||
*/
|
||||
@Data
|
||||
public class CreditMediationImportParam implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "案号")
|
||||
private String caseNumber;
|
||||
|
||||
@Excel(name = "案由")
|
||||
private String causeOfAction;
|
||||
|
||||
@Excel(name = "当事人")
|
||||
private String otherPartiesThirdParty;
|
||||
|
||||
@Excel(name = "法院")
|
||||
private String courtName;
|
||||
|
||||
@Excel(name = "立案日期")
|
||||
private String occurrenceTime;
|
||||
|
||||
@Excel(name = "备注")
|
||||
private String comments;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user