1、新增货物类型模块

2、新增导入失败,导出excel功能
This commit is contained in:
2026-07-27 11:50:23 +08:00
parent fd98744b46
commit f0b515c2e0
88 changed files with 1791 additions and 215 deletions

View File

@@ -126,9 +126,12 @@ public class AccidentRecordController extends BladeController {
@PostMapping("/import-accident-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入事故记录", description = "传入excel")
public R importAccidentRecord(MultipartFile file) {
AccidentRecordImporter accidentRecordImporter = new AccidentRecordImporter(accidentRecordService);
ExcelUtil.save(file, accidentRecordImporter, AccidentRecordExcel.class);
public R importAccidentRecord(MultipartFile file, HttpServletResponse response) {
List<AccidentRecordExcel> failureList = accidentRecordService.importAccidentRecord(ExcelUtil.read(file, AccidentRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "事故记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, AccidentRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -111,9 +111,12 @@ public class AnnualInspectionRecordController extends BladeController {
@PostMapping("/import-annual-inspection-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入年检记录", description = "传入excel")
public R importAnnualInspectionRecord(MultipartFile file) {
AnnualInspectionRecordImporter annualInspectionRecordImporter = new AnnualInspectionRecordImporter(annualInspectionRecordService);
ExcelUtil.save(file, annualInspectionRecordImporter, AnnualInspectionRecordExcel.class);
public R importAnnualInspectionRecord(MultipartFile file, HttpServletResponse response) {
List<AnnualInspectionRecordExcel> failureList = annualInspectionRecordService.importAnnualInspectionRecord(ExcelUtil.read(file, AnnualInspectionRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "年检记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, AnnualInspectionRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -137,9 +137,12 @@ public class CreditScoreQuantificationController extends BladeController {
@PostMapping("/import-credit-score-quantification")
@ApiOperationSupport(order = 7)
@Operation(summary = "导入评分量化表", description = "传入excel")
public R importCreditScoreQuantification(MultipartFile file) {
CreditScoreQuantificationImporter importer = new CreditScoreQuantificationImporter(creditScoreQuantificationService);
ExcelUtil.save(file, importer, CreditScoreQuantificationExcel.class);
public R importCreditScoreQuantification(MultipartFile file, HttpServletResponse response) {
List<CreditScoreQuantificationExcel> failureList = creditScoreQuantificationService.importCreditScoreQuantification(ExcelUtil.read(file, CreditScoreQuantificationExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "评分量化表导入失败明细" + DateUtil.time(), "导入失败明细", failureList, CreditScoreQuantificationExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -92,9 +92,12 @@ public class EtcRecordController extends BladeController {
@PostMapping("/import-etc-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入ETC记录", description = "传入excel")
public R importEtcRecord(MultipartFile file) {
EtcRecordImporter etcRecordImporter = new EtcRecordImporter(etcRecordService);
ExcelUtil.save(file, etcRecordImporter, EtcRecordExcel.class);
public R importEtcRecord(MultipartFile file, HttpServletResponse response) {
List<EtcRecordExcel> failureList = etcRecordService.importEtcRecord(ExcelUtil.read(file, EtcRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "ETC记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, EtcRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -127,9 +127,12 @@ public class InsuranceRecordController extends BladeController {
@PostMapping("/import-insurance-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入保险记录", description = "传入excel")
public R importInsuranceRecord(MultipartFile file) {
InsuranceRecordImporter insuranceRecordImporter = new InsuranceRecordImporter(insuranceRecordService);
ExcelUtil.save(file, insuranceRecordImporter, InsuranceRecordExcel.class);
public R importInsuranceRecord(MultipartFile file, HttpServletResponse response) {
List<InsuranceRecordExcel> failureList = insuranceRecordService.importInsuranceRecord(ExcelUtil.read(file, InsuranceRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "保险记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, InsuranceRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -126,9 +126,12 @@ public class MaintenancePlanController extends BladeController {
@PostMapping("/import-maintenance-plan")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入保养记录", description = "传入excel")
public R importMaintenancePlan(MultipartFile file) {
MaintenancePlanImporter maintenancePlanImporter = new MaintenancePlanImporter(maintenancePlanService);
ExcelUtil.save(file, maintenancePlanImporter, MaintenancePlanExcel.class);
public R importMaintenancePlan(MultipartFile file, HttpServletResponse response) {
List<MaintenancePlanExcel> failureList = maintenancePlanService.importMaintenancePlan(ExcelUtil.read(file, MaintenancePlanExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "保养记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, MaintenancePlanExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -126,9 +126,12 @@ public class MaintenanceRecordController extends BladeController {
@PostMapping("/import-maintenance-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入维修记录", description = "传入excel")
public R importMaintenanceRecord(MultipartFile file) {
MaintenanceRecordImporter maintenanceRecordImporter = new MaintenanceRecordImporter(maintenanceRecordService);
ExcelUtil.save(file, maintenanceRecordImporter, MaintenanceRecordExcel.class);
public R importMaintenanceRecord(MultipartFile file, HttpServletResponse response) {
List<MaintenanceRecordExcel> failureList = maintenanceRecordService.importMaintenanceRecord(ExcelUtil.read(file, MaintenanceRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "维修记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, MaintenanceRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -111,9 +111,12 @@ public class MileageRecordController extends BladeController {
@PostMapping("/import-mileage-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入里程记录", description = "传入excel")
public R importMileageRecord(MultipartFile file) {
MileageRecordImporter mileageRecordImporter = new MileageRecordImporter(mileageRecordService);
ExcelUtil.save(file, mileageRecordImporter, MileageRecordExcel.class);
public R importMileageRecord(MultipartFile file, HttpServletResponse response) {
List<MileageRecordExcel> failureList = mileageRecordService.importMileageRecord(ExcelUtil.read(file, MileageRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "里程记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, MileageRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -92,9 +92,12 @@ public class OilElectricRecordController extends BladeController {
@PostMapping("/import-oil-electric-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入油电记录", description = "传入excel")
public R importOilElectricRecord(MultipartFile file) {
OilElectricRecordImporter oilElectricRecordImporter = new OilElectricRecordImporter(oilElectricRecordService);
ExcelUtil.save(file, oilElectricRecordImporter, OilElectricRecordExcel.class);
public R importOilElectricRecord(MultipartFile file, HttpServletResponse response) {
List<OilElectricRecordExcel> failureList = oilElectricRecordService.importOilElectricRecord(ExcelUtil.read(file, OilElectricRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "油电记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, OilElectricRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -92,9 +92,12 @@ public class OtherExpenseRecordController extends BladeController {
@PostMapping("/import-other-expense-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入其他费用记录", description = "传入excel")
public R importOtherExpenseRecord(MultipartFile file) {
OtherExpenseRecordImporter otherExpenseRecordImporter = new OtherExpenseRecordImporter(otherExpenseRecordService);
ExcelUtil.save(file, otherExpenseRecordImporter, OtherExpenseRecordExcel.class);
public R importOtherExpenseRecord(MultipartFile file, HttpServletResponse response) {
List<OtherExpenseRecordExcel> failureList = otherExpenseRecordService.importOtherExpenseRecord(ExcelUtil.read(file, OtherExpenseRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "其他费用记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, OtherExpenseRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -126,9 +126,12 @@ public class TireReplacementRecordController extends BladeController {
@PostMapping("/import-tire-replacement-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入换胎记录", description = "传入excel")
public R importTireReplacementRecord(MultipartFile file) {
TireReplacementRecordImporter tireReplacementRecordImporter = new TireReplacementRecordImporter(tireReplacementRecordService);
ExcelUtil.save(file, tireReplacementRecordImporter, TireReplacementRecordExcel.class);
public R importTireReplacementRecord(MultipartFile file, HttpServletResponse response) {
List<TireReplacementRecordExcel> failureList = tireReplacementRecordService.importTireReplacementRecord(ExcelUtil.read(file, TireReplacementRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "换胎记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, TireReplacementRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -111,9 +111,12 @@ public class TransportChangeRecordController extends BladeController {
@PostMapping("/import-transport-change-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入变更记录", description = "传入excel")
public R importTransportChangeRecord(MultipartFile file) {
TransportChangeRecordImporter transportChangeRecordImporter = new TransportChangeRecordImporter(transportChangeRecordService);
ExcelUtil.save(file, transportChangeRecordImporter, TransportChangeRecordExcel.class);
public R importTransportChangeRecord(MultipartFile file, HttpServletResponse response) {
List<TransportChangeRecordExcel> failureList = transportChangeRecordService.importTransportChangeRecord(ExcelUtil.read(file, TransportChangeRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "变更记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, TransportChangeRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -126,9 +126,12 @@ public class ViolationRecordController extends BladeController {
@PostMapping("/import-violation-record")
@ApiOperationSupport(order = 5)
@Operation(summary = "导入违章记录", description = "传入excel")
public R importViolationRecord(MultipartFile file) {
ViolationRecordImporter violationRecordImporter = new ViolationRecordImporter(violationRecordService);
ExcelUtil.save(file, violationRecordImporter, ViolationRecordExcel.class);
public R importViolationRecord(MultipartFile file, HttpServletResponse response) {
List<ViolationRecordExcel> failureList = violationRecordService.importViolationRecord(ExcelUtil.read(file, ViolationRecordExcel.class));
if (Func.isNotEmpty(failureList)) {
org.springblade.common.excel.ImportFailureExcelUtil.export(response, "违章记录导入失败明细" + DateUtil.time(), "导入失败明细", failureList, ViolationRecordExcel.class);
return null;
}
return R.success("操作成功");
}

View File

@@ -86,7 +86,7 @@ public class AccidentRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -83,7 +83,7 @@ public class AnnualInspectionRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -22,6 +22,7 @@
*/
package org.springblade.transport.excel;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.write.style.ContentRowHeight;
@@ -103,7 +104,7 @@ public class CreditScoreQuantificationExcel implements Serializable {
@ExcelProperty("评估标准说明")
private String ratingStandardDescription;
@ExcelProperty("报错文案")
@ExcelIgnore
private String errorMessage;
}

View File

@@ -58,7 +58,7 @@ public class EtcRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -86,7 +86,7 @@ public class InsuranceRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -100,7 +100,7 @@ public class MaintenancePlanExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -101,7 +101,7 @@ public class MaintenanceRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -81,7 +81,7 @@ public class MileageRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -79,7 +79,7 @@ public class OilElectricRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -52,7 +52,7 @@ public class OtherExpenseRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -79,7 +79,7 @@ public class TireReplacementRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -66,7 +66,7 @@ public class TransportChangeRecordExcel implements Serializable {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -89,7 +89,7 @@ public class ViolationRecordExcel implements Serializable {
@ExcelProperty("处理结果")
private String processResult;
@ExcelProperty("报错文案")
@ExcelProperty
private String errorMessage;
}

View File

@@ -63,7 +63,7 @@ public interface IAccidentRecordService extends BaseService<AccidentRecord> {
*
* @param data 导入数据
*/
void importAccidentRecord(List<AccidentRecordExcel> data);
List<AccidentRecordExcel> importAccidentRecord(List<AccidentRecordExcel> data);
/**
* 导出事故记录

View File

@@ -45,7 +45,7 @@ public interface IAnnualInspectionRecordService extends BaseService<AnnualInspec
boolean submit(AnnualInspectionRecord annualInspectionRecord);
void importAnnualInspectionRecord(List<AnnualInspectionRecordExcel> data);
List<AnnualInspectionRecordExcel> importAnnualInspectionRecord(List<AnnualInspectionRecordExcel> data);
List<AnnualInspectionRecordExcel> exportAnnualInspectionRecord(Wrapper<AnnualInspectionRecord> queryWrapper);

View File

@@ -95,8 +95,9 @@ public interface ICreditScoreQuantificationService extends BaseService<CreditSco
* 导入评分量化表
*
* @param data 导入数据
* @return 导入失败数据
*/
void importCreditScoreQuantification(List<CreditScoreQuantificationExcel> data);
List<CreditScoreQuantificationExcel> importCreditScoreQuantification(List<CreditScoreQuantificationExcel> data);
/**
* 导出评分量化表

View File

@@ -26,7 +26,7 @@ public interface IEtcRecordService extends BaseService<EtcRecord> {
boolean submit(EtcRecord etcRecord);
void importEtcRecord(List<EtcRecordExcel> data);
List<EtcRecordExcel> importEtcRecord(List<EtcRecordExcel> data);
List<EtcRecordExcel> exportEtcRecord(Wrapper<EtcRecord> queryWrapper);

View File

@@ -64,7 +64,7 @@ public interface IInsuranceRecordService extends BaseService<InsuranceRecord> {
*
* @param data 导入数据
*/
void importInsuranceRecord(List<InsuranceRecordExcel> data);
List<InsuranceRecordExcel> importInsuranceRecord(List<InsuranceRecordExcel> data);
/**
* 导出保险记录

View File

@@ -63,7 +63,7 @@ public interface IMaintenancePlanService extends BaseService<MaintenancePlan> {
*
* @param data 导入数据
*/
void importMaintenancePlan(List<MaintenancePlanExcel> data);
List<MaintenancePlanExcel> importMaintenancePlan(List<MaintenancePlanExcel> data);
/**
* 导出保养记录

View File

@@ -63,7 +63,7 @@ public interface IMaintenanceRecordService extends BaseService<MaintenanceRecord
*
* @param data 导入数据
*/
void importMaintenanceRecord(List<MaintenanceRecordExcel> data);
List<MaintenanceRecordExcel> importMaintenanceRecord(List<MaintenanceRecordExcel> data);
/**
* 导出维修记录

View File

@@ -45,7 +45,7 @@ public interface IMileageRecordService extends BaseService<MileageRecord> {
boolean submit(MileageRecord mileageRecord);
void importMileageRecord(List<MileageRecordExcel> data);
List<MileageRecordExcel> importMileageRecord(List<MileageRecordExcel> data);
List<MileageRecordExcel> exportMileageRecord(Wrapper<MileageRecord> queryWrapper);

View File

@@ -26,7 +26,7 @@ public interface IOilElectricRecordService extends BaseService<OilElectricRecord
boolean submit(OilElectricRecord oilElectricRecord);
void importOilElectricRecord(List<OilElectricRecordExcel> data);
List<OilElectricRecordExcel> importOilElectricRecord(List<OilElectricRecordExcel> data);
List<OilElectricRecordExcel> exportOilElectricRecord(Wrapper<OilElectricRecord> queryWrapper);

View File

@@ -26,7 +26,7 @@ public interface IOtherExpenseRecordService extends BaseService<OtherExpenseReco
boolean submit(OtherExpenseRecord otherExpenseRecord);
void importOtherExpenseRecord(List<OtherExpenseRecordExcel> data);
List<OtherExpenseRecordExcel> importOtherExpenseRecord(List<OtherExpenseRecordExcel> data);
List<OtherExpenseRecordExcel> exportOtherExpenseRecord(Wrapper<OtherExpenseRecord> queryWrapper);

View File

@@ -63,7 +63,7 @@ public interface ITireReplacementRecordService extends BaseService<TireReplaceme
*
* @param data 导入数据
*/
void importTireReplacementRecord(List<TireReplacementRecordExcel> data);
List<TireReplacementRecordExcel> importTireReplacementRecord(List<TireReplacementRecordExcel> data);
/**
* 导出换胎记录

View File

@@ -45,7 +45,7 @@ public interface ITransportChangeRecordService extends BaseService<TransportChan
boolean submit(TransportChangeRecord transportChangeRecord);
void importTransportChangeRecord(List<TransportChangeRecordExcel> data);
List<TransportChangeRecordExcel> importTransportChangeRecord(List<TransportChangeRecordExcel> data);
List<TransportChangeRecordExcel> exportTransportChangeRecord(Wrapper<TransportChangeRecord> queryWrapper);

View File

@@ -63,7 +63,7 @@ public interface IViolationRecordService extends BaseService<ViolationRecord> {
*
* @param data 导入数据
*/
void importViolationRecord(List<ViolationRecordExcel> data);
List<ViolationRecordExcel> importViolationRecord(List<ViolationRecordExcel> data);
/**
* 导出违章记录

View File

@@ -77,22 +77,22 @@ public class AccidentRecordServiceImpl extends BaseServiceImpl<AccidentRecordMap
@Override
@Transactional(rollbackFor = Exception.class)
public void importAccidentRecord(List<AccidentRecordExcel> data) {
public List<AccidentRecordExcel> importAccidentRecord(List<AccidentRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<AccidentRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
AccidentRecordExcel excel = data.get(index);
try {
AccidentRecord accidentRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), AccidentRecord.class));
AccidentRecord accidentRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, AccidentRecord.class));
submit(accidentRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -79,24 +79,23 @@ public class AnnualInspectionRecordServiceImpl extends BaseServiceImpl<AnnualIns
@Override
@Transactional(rollbackFor = Exception.class)
public void importAnnualInspectionRecord(List<AnnualInspectionRecordExcel> data) {
public List<AnnualInspectionRecordExcel> importAnnualInspectionRecord(List<AnnualInspectionRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<AnnualInspectionRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
AnnualInspectionRecordExcel excel = data.get(index);
try {
AnnualInspectionRecordExcel excel = data.get(index);
AnnualInspectionRecord annualInspectionRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, AnnualInspectionRecord.class));
fillInspectionContent(annualInspectionRecord, excel.getInspectionContent());
submit(annualInspectionRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -189,7 +189,7 @@ public class CreditScoreQuantificationServiceImpl extends BaseServiceImpl<Credit
@Override
@Transactional(rollbackFor = Exception.class)
public void importCreditScoreQuantification(List<CreditScoreQuantificationExcel> data) {
public List<CreditScoreQuantificationExcel> importCreditScoreQuantification(List<CreditScoreQuantificationExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
@@ -197,19 +197,19 @@ public class CreditScoreQuantificationServiceImpl extends BaseServiceImpl<Credit
.filter(row -> Func.isNotEmpty(trimToNull(row.getTableName())))
.collect(Collectors.groupingBy(row -> trimToEmpty(row.getTableName()), java.util.LinkedHashMap::new, Collectors.toList()));
if (Func.isEmpty(dataMap)) {
throw new ServiceException("评定表名称不能为空");
data.forEach(row -> row.setErrorMessage("评定表名称不能为空"));
return data;
}
List<String> errorList = new ArrayList<>();
List<CreditScoreQuantificationExcel> errorList = new ArrayList<>();
dataMap.forEach((tableName, rows) -> {
try {
submit(buildImportVO(tableName, rows));
} catch (Exception exception) {
errorList.add(tableName + "" + exception.getMessage());
rows.forEach(row -> row.setErrorMessage(tableName + "" + exception.getMessage()));
errorList.addAll(rows);
}
});
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -58,23 +58,23 @@ public class EtcRecordServiceImpl extends BaseServiceImpl<EtcRecordMapper, EtcRe
@Override
@Transactional(rollbackFor = Exception.class)
public void importEtcRecord(List<EtcRecordExcel> data) {
public List<EtcRecordExcel> importEtcRecord(List<EtcRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<EtcRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
EtcRecordExcel excel = data.get(index);
try {
EtcRecord etcRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), EtcRecord.class));
EtcRecord etcRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, EtcRecord.class));
etcRecord.setDataSource("批量导入");
submit(etcRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -80,22 +80,22 @@ public class InsuranceRecordServiceImpl extends BaseServiceImpl<InsuranceRecordM
@Override
@Transactional(rollbackFor = Exception.class)
public void importInsuranceRecord(List<InsuranceRecordExcel> data) {
public List<InsuranceRecordExcel> importInsuranceRecord(List<InsuranceRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<InsuranceRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
InsuranceRecordExcel excel = data.get(index);
try {
InsuranceRecord insuranceRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), InsuranceRecord.class));
InsuranceRecord insuranceRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, InsuranceRecord.class));
submit(insuranceRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -73,22 +73,22 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanM
@Override
@Transactional(rollbackFor = Exception.class)
public void importMaintenancePlan(List<MaintenancePlanExcel> data) {
public List<MaintenancePlanExcel> importMaintenancePlan(List<MaintenancePlanExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<MaintenancePlanExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
MaintenancePlanExcel excel = data.get(index);
try {
MaintenancePlan maintenancePlan = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), MaintenancePlan.class));
MaintenancePlan maintenancePlan = Objects.requireNonNull(BeanUtil.copyProperties(excel, MaintenancePlan.class));
submit(maintenancePlan);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -75,22 +75,22 @@ public class MaintenanceRecordServiceImpl extends BaseServiceImpl<MaintenanceRec
@Override
@Transactional(rollbackFor = Exception.class)
public void importMaintenanceRecord(List<MaintenanceRecordExcel> data) {
public List<MaintenanceRecordExcel> importMaintenanceRecord(List<MaintenanceRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<MaintenanceRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
MaintenanceRecordExcel excel = data.get(index);
try {
MaintenanceRecord maintenanceRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), MaintenanceRecord.class));
MaintenanceRecord maintenanceRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, MaintenanceRecord.class));
submit(maintenanceRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -78,22 +78,22 @@ public class MileageRecordServiceImpl extends BaseServiceImpl<MileageRecordMappe
@Override
@Transactional(rollbackFor = Exception.class)
public void importMileageRecord(List<MileageRecordExcel> data) {
public List<MileageRecordExcel> importMileageRecord(List<MileageRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<MileageRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
MileageRecordExcel excel = data.get(index);
try {
MileageRecord mileageRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), MileageRecord.class));
MileageRecord mileageRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, MileageRecord.class));
submit(mileageRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -67,23 +67,23 @@ public class OilElectricRecordServiceImpl extends BaseServiceImpl<OilElectricRec
@Override
@Transactional(rollbackFor = Exception.class)
public void importOilElectricRecord(List<OilElectricRecordExcel> data) {
public List<OilElectricRecordExcel> importOilElectricRecord(List<OilElectricRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<OilElectricRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
OilElectricRecordExcel excel = data.get(index);
try {
OilElectricRecord oilElectricRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), OilElectricRecord.class));
OilElectricRecord oilElectricRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, OilElectricRecord.class));
oilElectricRecord.setDataSource(defaultDataSource(oilElectricRecord.getDataSource()));
submit(oilElectricRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -61,23 +61,23 @@ public class OtherExpenseRecordServiceImpl extends BaseServiceImpl<OtherExpenseR
@Override
@Transactional(rollbackFor = Exception.class)
public void importOtherExpenseRecord(List<OtherExpenseRecordExcel> data) {
public List<OtherExpenseRecordExcel> importOtherExpenseRecord(List<OtherExpenseRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<OtherExpenseRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
OtherExpenseRecordExcel excel = data.get(index);
try {
OtherExpenseRecord otherExpenseRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), OtherExpenseRecord.class));
OtherExpenseRecord otherExpenseRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, OtherExpenseRecord.class));
otherExpenseRecord.setDataSource("批量导入");
submit(otherExpenseRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -75,22 +75,22 @@ public class TireReplacementRecordServiceImpl extends BaseServiceImpl<TireReplac
@Override
@Transactional(rollbackFor = Exception.class)
public void importTireReplacementRecord(List<TireReplacementRecordExcel> data) {
public List<TireReplacementRecordExcel> importTireReplacementRecord(List<TireReplacementRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<TireReplacementRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
TireReplacementRecordExcel excel = data.get(index);
try {
TireReplacementRecord tireReplacementRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), TireReplacementRecord.class));
TireReplacementRecord tireReplacementRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, TireReplacementRecord.class));
submit(tireReplacementRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -78,22 +78,22 @@ public class TransportChangeRecordServiceImpl extends BaseServiceImpl<TransportC
@Override
@Transactional(rollbackFor = Exception.class)
public void importTransportChangeRecord(List<TransportChangeRecordExcel> data) {
public List<TransportChangeRecordExcel> importTransportChangeRecord(List<TransportChangeRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<TransportChangeRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
TransportChangeRecordExcel excel = data.get(index);
try {
TransportChangeRecord transportChangeRecord = Objects.requireNonNull(BeanUtil.copyProperties(data.get(index), TransportChangeRecord.class));
TransportChangeRecord transportChangeRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, TransportChangeRecord.class));
submit(transportChangeRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override

View File

@@ -82,24 +82,23 @@ public class ViolationRecordServiceImpl extends BaseServiceImpl<ViolationRecordM
@Override
@Transactional(rollbackFor = Exception.class)
public void importViolationRecord(List<ViolationRecordExcel> data) {
public List<ViolationRecordExcel> importViolationRecord(List<ViolationRecordExcel> data) {
if (Func.isEmpty(data)) {
throw new ServiceException("导入数据不能为空");
}
List<String> errorList = new ArrayList<>();
List<ViolationRecordExcel> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
ViolationRecordExcel excel = data.get(index);
try {
ViolationRecordExcel excel = data.get(index);
ViolationRecord violationRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, ViolationRecord.class));
fillViolationContent(violationRecord, excel.getViolationContent());
submit(violationRecord);
} catch (Exception exception) {
errorList.add("" + (index + 2) + "行:" + exception.getMessage());
excel.setErrorMessage("" + (index + 2) + "行:" + exception.getMessage());
errorList.add(excel);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
return errorList;
}
@Override