fix bug
This commit is contained in:
+2
-2
@@ -48,10 +48,10 @@ public class MileageRecord extends TenantEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "车船类型")
|
||||
@Schema(description = "车辆类型")
|
||||
private String vehicleType;
|
||||
|
||||
@Schema(description = "车牌号/船号")
|
||||
@Schema(description = "车牌号")
|
||||
private String vehicleNo;
|
||||
|
||||
@Schema(description = "上月统计里程")
|
||||
|
||||
+8
-8
@@ -53,13 +53,13 @@ public class PortTerminalExcel implements Serializable {
|
||||
@ExcelIgnore
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("编码")
|
||||
@ExcelProperty("*编码")
|
||||
private String code;
|
||||
|
||||
@ExcelProperty("港口/码头名称")
|
||||
@ExcelProperty("*港口/码头名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("类型")
|
||||
@ExcelProperty("*类型")
|
||||
private String category;
|
||||
|
||||
@ExcelProperty("上级港口")
|
||||
@@ -68,13 +68,13 @@ public class PortTerminalExcel implements Serializable {
|
||||
@ExcelProperty("上级港口编码")
|
||||
private String parentCode;
|
||||
|
||||
@ExcelProperty("国家")
|
||||
@ExcelProperty("*国家")
|
||||
private String country;
|
||||
|
||||
@ExcelProperty("城市")
|
||||
@ExcelProperty("*城市")
|
||||
private String city;
|
||||
|
||||
@ExcelProperty("区县")
|
||||
@ExcelProperty("*区县")
|
||||
private String districtName;
|
||||
|
||||
@ExcelProperty("行政区划编码")
|
||||
@@ -83,11 +83,11 @@ public class PortTerminalExcel implements Serializable {
|
||||
@ExcelProperty("详细地址")
|
||||
private String detailAddress;
|
||||
|
||||
@ExcelProperty("经度")
|
||||
@ExcelProperty("*经度")
|
||||
@NumberFormat("0.000000")
|
||||
private BigDecimal longitude;
|
||||
|
||||
@ExcelProperty("纬度")
|
||||
@ExcelProperty("*纬度")
|
||||
@NumberFormat("0.000000")
|
||||
private BigDecimal latitude;
|
||||
|
||||
|
||||
+13
-5
@@ -392,11 +392,14 @@ public class PortTerminalServiceImpl extends BaseServiceImpl<PortTerminalMapper,
|
||||
portTerminal.setParentId(parent.getId());
|
||||
portTerminal.setParentCode(parent.getCode());
|
||||
portTerminal.setParentName(parent.getName());
|
||||
portTerminal.setCountry(parent.getCountry());
|
||||
portTerminal.setCity(parent.getCity());
|
||||
portTerminal.setDistrictCode(parent.getDistrictCode());
|
||||
portTerminal.setDistrictName(parent.getDistrictName());
|
||||
portTerminal.setRegionCode(parent.getDistrictCode());
|
||||
portTerminal.setCountry(inheritParentValue(parent.getCountry(), portTerminal.getCountry()));
|
||||
portTerminal.setCity(inheritParentValue(parent.getCity(), portTerminal.getCity()));
|
||||
portTerminal.setDistrictCode(inheritParentValue(parent.getDistrictCode(), portTerminal.getDistrictCode()));
|
||||
portTerminal.setDistrictName(inheritParentValue(parent.getDistrictName(), portTerminal.getDistrictName()));
|
||||
portTerminal.setRegionCode(inheritParentValue(parent.getDistrictCode(), portTerminal.getRegionCode()));
|
||||
if (Func.isEmpty(portTerminal.getDistrictCode()) && Func.isNotEmpty(portTerminal.getDistrictName())) {
|
||||
fillRegion(portTerminal);
|
||||
}
|
||||
}
|
||||
|
||||
private void fillRegion(PortTerminal portTerminal) {
|
||||
@@ -560,4 +563,9 @@ public class PortTerminalServiceImpl extends BaseServiceImpl<PortTerminalMapper,
|
||||
return trimValue.isEmpty() ? null : trimValue;
|
||||
}
|
||||
|
||||
private String inheritParentValue(String parentValue, String currentValue) {
|
||||
String normalizedParentValue = trimToNull(parentValue);
|
||||
return normalizedParentValue == null ? currentValue : normalizedParentValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-3
@@ -76,6 +76,7 @@ public class MileageRecordController extends BladeController {
|
||||
private static final int DEFAULT_CURRENT = 1;
|
||||
private static final int DEFAULT_SIZE = 10;
|
||||
private static final int MAX_SIZE = 100;
|
||||
private static final String VEHICLE_TYPE = "车辆";
|
||||
|
||||
private final IMileageRecordService mileageRecordService;
|
||||
|
||||
@@ -83,6 +84,7 @@ public class MileageRecordController extends BladeController {
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入mileageRecord")
|
||||
public R<MileageRecordVO> detail(MileageRecord mileageRecord) {
|
||||
mileageRecord.setVehicleType(VEHICLE_TYPE);
|
||||
MileageRecord detail = mileageRecordService.getOne(Condition.getQueryWrapper(mileageRecord));
|
||||
return R.data(MileageRecordWrapper.build().entityVO(detail));
|
||||
}
|
||||
@@ -91,6 +93,7 @@ public class MileageRecordController extends BladeController {
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入mileageRecord")
|
||||
public R<IPage<MileageRecordVO>> list(MileageRecordVO mileageRecord, Query query) {
|
||||
mileageRecord.setVehicleType(VEHICLE_TYPE);
|
||||
IPage<MileageRecordVO> pages = mileageRecordService.selectMileageRecordPage(Condition.getPage(normalizeQuery(query)), mileageRecord);
|
||||
return R.data(pages);
|
||||
}
|
||||
@@ -158,6 +161,7 @@ public class MileageRecordController extends BladeController {
|
||||
private LambdaQueryWrapper<MileageRecord> buildExportQuery(MileageRecordVO mileageRecord, String ids) {
|
||||
LambdaQueryWrapper<MileageRecord> queryWrapper = Wrappers.<MileageRecord>lambdaQuery()
|
||||
.eq(MileageRecord::getIsDeleted, 0)
|
||||
.eq(MileageRecord::getVehicleType, VEHICLE_TYPE)
|
||||
.orderByDesc(MileageRecord::getCreateTime);
|
||||
if (Func.isNotEmpty(ids)) {
|
||||
queryWrapper.in(MileageRecord::getId, Func.toLongList(ids));
|
||||
@@ -165,9 +169,6 @@ public class MileageRecordController extends BladeController {
|
||||
if (Func.isNotEmpty(mileageRecord.getCreateDept())) {
|
||||
queryWrapper.eq(MileageRecord::getCreateDept, mileageRecord.getCreateDept());
|
||||
}
|
||||
if (Func.isNotEmpty(mileageRecord.getVehicleType())) {
|
||||
queryWrapper.eq(MileageRecord::getVehicleType, mileageRecord.getVehicleType());
|
||||
}
|
||||
if (Func.isNotEmpty(mileageRecord.getVehicleNo())) {
|
||||
queryWrapper.like(MileageRecord::getVehicleNo, mileageRecord.getVehicleNo());
|
||||
}
|
||||
|
||||
+5
-2
@@ -8,6 +8,7 @@ package org.springblade.transport.excel;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.format.DateTimeFormat;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import cn.idev.excel.annotation.write.style.ContentRowHeight;
|
||||
import cn.idev.excel.annotation.write.style.HeadRowHeight;
|
||||
@@ -37,13 +38,15 @@ public class EtcRecordExcel implements Serializable {
|
||||
@ExcelProperty("*车牌号")
|
||||
private String vehicleNo;
|
||||
|
||||
@ExcelProperty("入口时间")
|
||||
@ExcelProperty(value = "入口时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime entryTime;
|
||||
|
||||
@ExcelProperty("*ETC卡号")
|
||||
private String etcCardNo;
|
||||
|
||||
@ExcelProperty("*出口时间")
|
||||
@ExcelProperty(value = "*出口时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime exitTime;
|
||||
|
||||
@ExcelProperty("入口站")
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.transport.excel;
|
||||
|
||||
import cn.idev.excel.converters.Converter;
|
||||
import cn.idev.excel.enums.CellDataTypeEnum;
|
||||
import cn.idev.excel.metadata.GlobalConfiguration;
|
||||
import cn.idev.excel.metadata.data.ReadCellData;
|
||||
import cn.idev.excel.metadata.data.WriteCellData;
|
||||
import cn.idev.excel.metadata.property.ExcelContentProperty;
|
||||
import cn.idev.excel.util.DateUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
||||
/**
|
||||
* 保养记录日期转换器,兼容日期文本、日期时间文本和 Excel 数值日期。
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class MaintenancePlanDateTimeConverter implements Converter<LocalDateTime> {
|
||||
|
||||
private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
|
||||
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
private static final DateTimeFormatter DATE_TIME_MINUTE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT);
|
||||
|
||||
@Override
|
||||
public Class<?> supportJavaTypeKey() {
|
||||
return LocalDateTime.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
if (cellData.getType() == CellDataTypeEnum.NUMBER) {
|
||||
return DateUtils.getLocalDateTime(cellData.getNumberValue().doubleValue(),
|
||||
globalConfiguration.getUse1904windowing());
|
||||
}
|
||||
String value = cellData.getStringValue();
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String normalizedValue = value.trim();
|
||||
try {
|
||||
return LocalDateTime.parse(normalizedValue, DATE_TIME_FORMATTER);
|
||||
} catch (DateTimeParseException ignored) {
|
||||
try {
|
||||
return LocalDateTime.parse(normalizedValue, DATE_TIME_MINUTE_FORMATTER);
|
||||
} catch (DateTimeParseException ignoredMinute) {
|
||||
return LocalDate.parse(normalizedValue, DATE_FORMATTER).atStartOfDay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
String format = contentProperty != null && contentProperty.getDateTimeFormatProperty() != null
|
||||
? contentProperty.getDateTimeFormatProperty().getFormat() : DEFAULT_DATE_FORMAT;
|
||||
return new WriteCellData<>(DateUtils.format(value, format, globalConfiguration.getLocale()));
|
||||
}
|
||||
|
||||
}
|
||||
+5
-2
@@ -27,6 +27,7 @@ package org.springblade.transport.excel;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.format.DateTimeFormat;
|
||||
import cn.idev.excel.annotation.format.NumberFormat;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import cn.idev.excel.annotation.write.style.ContentRowHeight;
|
||||
@@ -63,7 +64,8 @@ public class MaintenancePlanExcel implements Serializable {
|
||||
@ExcelProperty("保养人")
|
||||
private String maintainer;
|
||||
|
||||
@ExcelProperty("*保养时间")
|
||||
@ExcelProperty(value = "*保养时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd")
|
||||
private LocalDateTime maintenanceTime;
|
||||
|
||||
@ExcelProperty("里程/航程数")
|
||||
@@ -88,7 +90,8 @@ public class MaintenancePlanExcel implements Serializable {
|
||||
@ExcelProperty("地址")
|
||||
private String address;
|
||||
|
||||
@ExcelProperty("下次保养时间")
|
||||
@ExcelProperty(value = "下次保养时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd")
|
||||
private LocalDateTime nextMaintenanceTime;
|
||||
|
||||
@ExcelProperty("下次保养里程/航程")
|
||||
|
||||
+4
-4
@@ -64,7 +64,7 @@ public class MaintenanceRecordExcel implements Serializable {
|
||||
@ExcelProperty("维修人")
|
||||
private String maintainer;
|
||||
|
||||
@ExcelProperty("*维修时间")
|
||||
@ExcelProperty(value = "*维修时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd")
|
||||
private LocalDateTime maintenanceTime;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class MaintenanceRecordExcel implements Serializable {
|
||||
@ExcelProperty("地址")
|
||||
private String address;
|
||||
|
||||
@ExcelProperty("出厂时间")
|
||||
@ExcelProperty(value = "出厂时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd")
|
||||
private LocalDateTime factoryTime;
|
||||
|
||||
@@ -95,14 +95,14 @@ public class MaintenanceRecordExcel implements Serializable {
|
||||
@NumberFormat("0.00")
|
||||
private BigDecimal mileage;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
@ExcelProperty(value = "创建时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ExcelProperty("更新人")
|
||||
private String updateUserName;
|
||||
|
||||
@ExcelProperty("更新时间")
|
||||
@ExcelProperty(value = "更新时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
+1
-4
@@ -53,10 +53,7 @@ public class MileageRecordExcel implements Serializable {
|
||||
@ExcelIgnore
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("*车船类型")
|
||||
private String vehicleType;
|
||||
|
||||
@ExcelProperty("*车牌号/船号")
|
||||
@ExcelProperty("*车牌号")
|
||||
private String vehicleNo;
|
||||
|
||||
@ExcelProperty("上月统计里程数")
|
||||
|
||||
+1
-4
@@ -51,10 +51,7 @@ public class MileageRecordExportExcel implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ExcelProperty("车船类型")
|
||||
private String vehicleType;
|
||||
|
||||
@ExcelProperty("车牌号/船号")
|
||||
@ExcelProperty("车牌号")
|
||||
private String vehicleNo;
|
||||
|
||||
@ExcelProperty("上月统计里程数")
|
||||
|
||||
+3
-1
@@ -11,6 +11,7 @@ package org.springblade.transport.excel;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.format.DateTimeFormat;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import cn.idev.excel.annotation.write.style.ContentRowHeight;
|
||||
import cn.idev.excel.annotation.write.style.HeadRowHeight;
|
||||
@@ -40,7 +41,8 @@ public class OilElectricRecordExcel implements Serializable {
|
||||
@ExcelProperty("卡号")
|
||||
private String cardNo;
|
||||
|
||||
@ExcelProperty("*交易时间")
|
||||
@ExcelProperty(value = "*交易时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime transactionTime;
|
||||
|
||||
@ExcelProperty("*车船类型")
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.transport.excel;
|
||||
|
||||
import cn.idev.excel.converters.Converter;
|
||||
import cn.idev.excel.enums.CellDataTypeEnum;
|
||||
import cn.idev.excel.metadata.GlobalConfiguration;
|
||||
import cn.idev.excel.metadata.data.ReadCellData;
|
||||
import cn.idev.excel.metadata.data.WriteCellData;
|
||||
import cn.idev.excel.metadata.property.ExcelContentProperty;
|
||||
import cn.idev.excel.util.DateUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 换胎日期文本转换器,保留非法日期原值并兼容 Excel 数值日期。
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class TireReplacementDateStringConverter implements Converter<String> {
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
|
||||
@Override
|
||||
public Class<?> supportJavaTypeKey() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
if (cellData.getType() == CellDataTypeEnum.NUMBER) {
|
||||
LocalDate date = DateUtils.getLocalDateTime(cellData.getNumberValue().doubleValue(),
|
||||
globalConfiguration.getUse1904windowing()).toLocalDate();
|
||||
return date.format(DATE_FORMATTER);
|
||||
}
|
||||
return cellData.getStringValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
return new WriteCellData<>(value);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-3
@@ -36,7 +36,6 @@ import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 换胎记录 Excel
|
||||
@@ -60,8 +59,8 @@ public class TireReplacementRecordExcel implements Serializable {
|
||||
@ExcelProperty("处理人")
|
||||
private String handler;
|
||||
|
||||
@ExcelProperty("*换胎时间")
|
||||
private LocalDate replacementTime;
|
||||
@ExcelProperty(value = "*换胎时间", converter = TireReplacementDateStringConverter.class)
|
||||
private String replacementTime;
|
||||
|
||||
@ExcelProperty("轮胎品牌")
|
||||
private String tireBrand;
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class ViolationRecordImportExcel implements Serializable {
|
||||
@ExcelProperty("*类型/事项")
|
||||
private String violationTypeOrItem;
|
||||
|
||||
@ExcelProperty("*时间")
|
||||
@ExcelProperty(value = "*时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime violationTime;
|
||||
|
||||
|
||||
+5
-2
@@ -24,6 +24,7 @@ package org.springblade.transport.excel;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.format.DateTimeFormat;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import cn.idev.excel.annotation.write.style.ContentRowHeight;
|
||||
import cn.idev.excel.annotation.write.style.HeadRowHeight;
|
||||
@@ -150,9 +151,11 @@ public class WaybillExcel implements Serializable {
|
||||
private String createUserName;
|
||||
@ExcelProperty("更新人")
|
||||
private String updateUserName;
|
||||
@ExcelProperty("创建时间")
|
||||
@ExcelProperty(value = "创建时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
@ExcelProperty("更新时间")
|
||||
@ExcelProperty(value = "更新时间", converter = MaintenancePlanDateTimeConverter.class)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ExcelIgnore
|
||||
|
||||
+6
@@ -46,6 +46,7 @@ import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 年检记录 服务实现类
|
||||
@@ -64,6 +65,7 @@ public class AnnualInspectionRecordServiceImpl extends BaseServiceImpl<AnnualIns
|
||||
private static final int MONEY_SCALE = 2;
|
||||
private static final String VEHICLE = "车辆";
|
||||
private static final String SHIP = "船舶";
|
||||
private static final Set<String> PASSENGER_TYPE_LEVELS = Set.of("一级", "二级", "其他");
|
||||
|
||||
@Override
|
||||
public IPage<AnnualInspectionRecordVO> selectAnnualInspectionRecordPage(IPage<AnnualInspectionRecordVO> page, AnnualInspectionRecordVO annualInspectionRecord) {
|
||||
@@ -127,6 +129,7 @@ public class AnnualInspectionRecordServiceImpl extends BaseServiceImpl<AnnualIns
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(annualInspectionRecord.getVehicleNo()), "车牌号/船号不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, VEHICLE.equals(annualInspectionRecord.getVehicleType()) && Func.isEmpty(annualInspectionRecord.getVehicleTechnicalLevel()), "车辆技术等级不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, SHIP.equals(annualInspectionRecord.getVehicleType()) && Func.isEmpty(annualInspectionRecord.getShipInspectionType()), "船舶检验类型不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isNotEmpty(annualInspectionRecord.getPassengerTypeLevel()) && !PASSENGER_TYPE_LEVELS.contains(annualInspectionRecord.getPassengerTypeLevel()), "客车类型及等级不正确");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(annualInspectionRecord.getValidUntilDate()), "有效期截止日不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isNotEmpty(annualInspectionRecord.getValidUntilDate()) && Func.isNotEmpty(annualInspectionRecord.getInspectionAssessmentDate()) && !annualInspectionRecord.getValidUntilDate().isAfter(annualInspectionRecord.getInspectionAssessmentDate()), "有效期截止日应大于检测评定日期");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(annualInspectionRecord.getFee()), "费用不能为空");
|
||||
@@ -194,6 +197,9 @@ public class AnnualInspectionRecordServiceImpl extends BaseServiceImpl<AnnualIns
|
||||
if (SHIP.equals(annualInspectionRecord.getVehicleType()) && Func.isEmpty(annualInspectionRecord.getShipInspectionType())) {
|
||||
throw new ServiceException("船舶检验类型不能为空");
|
||||
}
|
||||
if (Func.isNotEmpty(annualInspectionRecord.getPassengerTypeLevel()) && !PASSENGER_TYPE_LEVELS.contains(annualInspectionRecord.getPassengerTypeLevel())) {
|
||||
throw new ServiceException("客车类型及等级不正确");
|
||||
}
|
||||
if (Func.isEmpty(annualInspectionRecord.getValidUntilDate())) {
|
||||
throw new ServiceException("有效期截止日不能为空");
|
||||
}
|
||||
|
||||
+80
-5
@@ -3,16 +3,23 @@ package org.springblade.transport.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.DictBizCache;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
import org.springblade.transport.excel.EquipmentLedgerExcel;
|
||||
import org.springblade.transport.mapper.EquipmentLedgerMapper;
|
||||
import org.springblade.transport.pojo.entity.EquipmentLedger;
|
||||
import org.springblade.transport.pojo.entity.TransportShip;
|
||||
import org.springblade.transport.pojo.entity.TransportVehicle;
|
||||
import org.springblade.transport.pojo.vo.EquipmentLedgerVO;
|
||||
import org.springblade.transport.service.IEquipmentLedgerService;
|
||||
import org.springblade.transport.service.ITransportShipService;
|
||||
import org.springblade.transport.service.ITransportVehicleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -23,6 +30,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设备台账服务实现
|
||||
@@ -30,10 +38,12 @@ import java.util.Set;
|
||||
* @author Chill
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EquipmentLedgerServiceImpl extends BaseServiceImpl<EquipmentLedgerMapper, EquipmentLedger> implements IEquipmentLedgerService {
|
||||
|
||||
private static final String VEHICLE = "车辆";
|
||||
private static final String SHIP = "船舶";
|
||||
private static final String EQUIPMENT_TYPE_DICT_CODE = "equip_type";
|
||||
private static final int VEHICLE_NO_MAX_LENGTH = 30;
|
||||
private static final int EQUIPMENT_CODE_MAX_LENGTH = 12;
|
||||
private static final int EQUIPMENT_NAME_MAX_LENGTH = 100;
|
||||
@@ -42,7 +52,9 @@ public class EquipmentLedgerServiceImpl extends BaseServiceImpl<EquipmentLedgerM
|
||||
private static final int SPECIFICATION_MODEL_MAX_LENGTH = 100;
|
||||
private static final int ORIGINAL_EQUIPMENT_NO_MAX_LENGTH = 100;
|
||||
private static final int REMARK_MAX_LENGTH = 200;
|
||||
private static final int ATTACHMENTS_MAX_LENGTH = 1000;
|
||||
private static final int ATTACHMENTS_MAX_LENGTH = 16000;
|
||||
private final ITransportVehicleService transportVehicleService;
|
||||
private final ITransportShipService transportShipService;
|
||||
|
||||
@Override
|
||||
public IPage<EquipmentLedgerVO> selectEquipmentLedgerPage(IPage<EquipmentLedgerVO> page, EquipmentLedgerVO equipmentLedger) {
|
||||
@@ -72,6 +84,9 @@ public class EquipmentLedgerServiceImpl extends BaseServiceImpl<EquipmentLedgerM
|
||||
List<EquipmentLedgerExcel> errorList = new ArrayList<>();
|
||||
List<EquipmentLedger> equipmentLedgerList = new ArrayList<>();
|
||||
Set<String> importEquipmentCodes = new HashSet<>();
|
||||
Set<String> existingVehicleNos = loadExistingVehicleNos(data);
|
||||
Set<String> existingShipNos = loadExistingShipNos(data);
|
||||
Set<String> equipmentTypeValues = loadEquipmentTypeValues();
|
||||
for (int index = 0; index < data.size(); index++) {
|
||||
EquipmentLedgerExcel excel = data.get(index);
|
||||
try {
|
||||
@@ -80,7 +95,8 @@ public class EquipmentLedgerServiceImpl extends BaseServiceImpl<EquipmentLedgerM
|
||||
if (equipmentLedger.getId() == null && Func.isEmpty(equipmentLedger.getEquipmentCode())) {
|
||||
equipmentLedger.setEquipmentCode(nextEquipmentCode(importEquipmentCodes));
|
||||
}
|
||||
List<String> validationErrors = validateImportEquipmentLedger(equipmentLedger);
|
||||
List<String> validationErrors = validateImportEquipmentLedger(equipmentLedger,
|
||||
existingVehicleNos, existingShipNos, equipmentTypeValues);
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors,
|
||||
!importEquipmentCodes.add(equipmentLedger.getEquipmentCode()), "设备编号在本次导入中重复");
|
||||
if (Func.isNotEmpty(validationErrors)) {
|
||||
@@ -108,12 +124,19 @@ public class EquipmentLedgerServiceImpl extends BaseServiceImpl<EquipmentLedgerM
|
||||
return errorList;
|
||||
}
|
||||
|
||||
private List<String> validateImportEquipmentLedger(EquipmentLedger equipmentLedger) {
|
||||
private List<String> validateImportEquipmentLedger(EquipmentLedger equipmentLedger,
|
||||
Set<String> existingVehicleNos, Set<String> existingShipNos, Set<String> equipmentTypeValues) {
|
||||
List<String> validationErrors = new ArrayList<>();
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, !VEHICLE.equals(equipmentLedger.getVehicleType()) && !SHIP.equals(equipmentLedger.getVehicleType()), "车船类型不正确");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(equipmentLedger.getVehicleNo()), "车牌号/船号不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors,
|
||||
VEHICLE.equals(equipmentLedger.getVehicleType()) && Func.isNotEmpty(equipmentLedger.getVehicleNo()) && !existingVehicleNos.contains(equipmentLedger.getVehicleNo()), "车牌号/船号对应的车辆不存在");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors,
|
||||
SHIP.equals(equipmentLedger.getVehicleType()) && Func.isNotEmpty(equipmentLedger.getVehicleNo()) && !existingShipNos.contains(equipmentLedger.getVehicleNo()), "车牌号/船号对应的船舶不存在");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(equipmentLedger.getEquipmentCode()), "设备编号不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(equipmentLedger.getEquipmentName()), "设备名称不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors,
|
||||
Func.isNotEmpty(equipmentLedger.getEquipmentType()) && !equipmentTypeValues.contains(equipmentLedger.getEquipmentType()), "设备类型不合法");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, equipmentLedger.getOnlineStatus() != 0 && equipmentLedger.getOnlineStatus() != 1, "是否在线不正确");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, equipmentLedger.getVehicleNo(), VEHICLE_NO_MAX_LENGTH, "车牌号/船号不能超过30字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, equipmentLedger.getEquipmentCode(), EQUIPMENT_CODE_MAX_LENGTH, "设备编号格式不正确");
|
||||
@@ -123,10 +146,62 @@ public class EquipmentLedgerServiceImpl extends BaseServiceImpl<EquipmentLedgerM
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, equipmentLedger.getSpecificationModel(), SPECIFICATION_MODEL_MAX_LENGTH, "规格型号不能超过100字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, equipmentLedger.getOriginalEquipmentNo(), ORIGINAL_EQUIPMENT_NO_MAX_LENGTH, "原厂设备号不能超过100字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, equipmentLedger.getRemark(), REMARK_MAX_LENGTH, "备注不能超过200字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, equipmentLedger.getAttachments(), ATTACHMENTS_MAX_LENGTH, "附件不能超过1000字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, equipmentLedger.getAttachments(), ATTACHMENTS_MAX_LENGTH, "附件数据不能超过16000字");
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
private Set<String> loadExistingVehicleNos(List<EquipmentLedgerExcel> data) {
|
||||
Set<String> vehicleNos = data.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> VEHICLE.equals(trimToEmpty(item.getVehicleType())))
|
||||
.map(item -> trimToEmpty(item.getVehicleNo()).toUpperCase())
|
||||
.filter(Func::isNotEmpty)
|
||||
.collect(Collectors.toSet());
|
||||
if (Func.isEmpty(vehicleNos)) {
|
||||
return Set.of();
|
||||
}
|
||||
return transportVehicleService.list(new LambdaQueryWrapper<TransportVehicle>()
|
||||
.select(TransportVehicle::getPlateNo)
|
||||
.in(TransportVehicle::getPlateNo, vehicleNos)).stream()
|
||||
.map(TransportVehicle::getPlateNo)
|
||||
.filter(Objects::nonNull)
|
||||
.map(String::trim)
|
||||
.map(String::toUpperCase)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private Set<String> loadExistingShipNos(List<EquipmentLedgerExcel> data) {
|
||||
Set<String> shipNos = data.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> SHIP.equals(trimToEmpty(item.getVehicleType())))
|
||||
.map(item -> trimToEmpty(item.getVehicleNo()))
|
||||
.filter(Func::isNotEmpty)
|
||||
.collect(Collectors.toSet());
|
||||
if (Func.isEmpty(shipNos)) {
|
||||
return Set.of();
|
||||
}
|
||||
return transportShipService.list(new LambdaQueryWrapper<TransportShip>()
|
||||
.select(TransportShip::getShipIdentifierNo)
|
||||
.in(TransportShip::getShipIdentifierNo, shipNos)).stream()
|
||||
.map(TransportShip::getShipIdentifierNo)
|
||||
.filter(Objects::nonNull)
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private Set<String> loadEquipmentTypeValues() {
|
||||
List<DictBiz> equipmentTypes = DictBizCache.getList(EQUIPMENT_TYPE_DICT_CODE);
|
||||
if (Func.isEmpty(equipmentTypes)) {
|
||||
return Set.of();
|
||||
}
|
||||
return equipmentTypes.stream()
|
||||
.map(DictBiz::getDictValue)
|
||||
.filter(Objects::nonNull)
|
||||
.map(String::trim)
|
||||
.filter(Func::isNotEmpty)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EquipmentLedgerExcel> exportEquipmentLedger(Wrapper<EquipmentLedger> queryWrapper) {
|
||||
return list(queryWrapper).stream()
|
||||
@@ -193,7 +268,7 @@ public class EquipmentLedgerServiceImpl extends BaseServiceImpl<EquipmentLedgerM
|
||||
validateLength(equipmentLedger.getSpecificationModel(), SPECIFICATION_MODEL_MAX_LENGTH, "规格型号不能超过100字");
|
||||
validateLength(equipmentLedger.getOriginalEquipmentNo(), ORIGINAL_EQUIPMENT_NO_MAX_LENGTH, "原厂设备号不能超过100字");
|
||||
validateLength(equipmentLedger.getRemark(), REMARK_MAX_LENGTH, "备注不能超过200字");
|
||||
validateLength(equipmentLedger.getAttachments(), ATTACHMENTS_MAX_LENGTH, "附件不能超过1000字");
|
||||
validateLength(equipmentLedger.getAttachments(), ATTACHMENTS_MAX_LENGTH, "附件数据不能超过16000字");
|
||||
}
|
||||
|
||||
private void validateEquipmentCodeImmutable(EquipmentLedger equipmentLedger) {
|
||||
|
||||
+17
@@ -42,6 +42,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -124,10 +125,18 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanM
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, maintenancePlan.getAddress(), ADDRESS_MAX_LENGTH, "地址不能超过100字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, maintenancePlan.getRemark(), REMARK_MAX_LENGTH, "备注不能超过500字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(maintenancePlan.getMaintenanceTime()), "保养时间不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors,
|
||||
Func.isNotEmpty(maintenancePlan.getMaintenanceTime()) && maintenancePlan.getMaintenanceTime().toLocalDate().isAfter(LocalDate.now()),
|
||||
"保养时间不能超过今天");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(maintenancePlan.getCost()), "费用不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isNotEmpty(maintenancePlan.getCost()) && maintenancePlan.getCost().compareTo(BigDecimal.ZERO) < 0, "费用不能小于0");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isNotEmpty(maintenancePlan.getMileage()) && maintenancePlan.getMileage().compareTo(BigDecimal.ZERO) < 0, "里程/航程数不能小于0");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isNotEmpty(maintenancePlan.getNextMaintenanceMileage()) && maintenancePlan.getNextMaintenanceMileage().compareTo(BigDecimal.ZERO) < 0, "下次保养里程/航程不能小于0");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors,
|
||||
Func.isNotEmpty(maintenancePlan.getMileage())
|
||||
&& Func.isNotEmpty(maintenancePlan.getNextMaintenanceMileage())
|
||||
&& maintenancePlan.getNextMaintenanceMileage().compareTo(maintenancePlan.getMileage()) <= 0,
|
||||
"下次保养里程/航程应大于本次里程/航程数");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isNotEmpty(maintenancePlan.getNextMaintenanceTime()) && Func.isNotEmpty(maintenancePlan.getMaintenanceTime()) && maintenancePlan.getNextMaintenanceTime().isBefore(maintenancePlan.getMaintenanceTime()), "下次保养时间不能早于保养时间");
|
||||
return validationErrors;
|
||||
}
|
||||
@@ -178,12 +187,20 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanM
|
||||
if (Func.isEmpty(maintenancePlan.getMaintenanceTime())) {
|
||||
throw new ServiceException("保养时间不能为空");
|
||||
}
|
||||
if (maintenancePlan.getMaintenanceTime().toLocalDate().isAfter(LocalDate.now())) {
|
||||
throw new ServiceException("保养时间不能超过今天");
|
||||
}
|
||||
if (Func.isEmpty(maintenancePlan.getCost())) {
|
||||
throw new ServiceException("费用不能为空");
|
||||
}
|
||||
validateNonNegative(maintenancePlan.getCost(), "费用不能小于0");
|
||||
validateNonNegative(maintenancePlan.getMileage(), "里程/航程数不能小于0");
|
||||
validateNonNegative(maintenancePlan.getNextMaintenanceMileage(), "下次保养里程/航程不能小于0");
|
||||
if (Func.isNotEmpty(maintenancePlan.getMileage())
|
||||
&& Func.isNotEmpty(maintenancePlan.getNextMaintenanceMileage())
|
||||
&& maintenancePlan.getNextMaintenanceMileage().compareTo(maintenancePlan.getMileage()) <= 0) {
|
||||
throw new ServiceException("下次保养里程/航程应大于本次里程/航程数");
|
||||
}
|
||||
if (Func.isNotEmpty(maintenancePlan.getNextMaintenanceTime()) && maintenancePlan.getNextMaintenanceTime().isBefore(maintenancePlan.getMaintenanceTime())) {
|
||||
throw new ServiceException("下次保养时间不能早于保养时间");
|
||||
}
|
||||
|
||||
+25
-43
@@ -59,7 +59,7 @@ public class MileageRecordServiceImpl extends BaseServiceImpl<MileageRecordMappe
|
||||
private static final int ATTACHMENTS_MAX_LENGTH = 1000;
|
||||
private static final int MILEAGE_SCALE = 2;
|
||||
private static final String VEHICLE_TYPE_VEHICLE = "车辆";
|
||||
private static final String VEHICLE_TYPE_SHIP = "船舶";
|
||||
private static final String MILEAGE_UNIT = "公里";
|
||||
|
||||
@Override
|
||||
public IPage<MileageRecordVO> selectMileageRecordPage(IPage<MileageRecordVO> page, MileageRecordVO mileageRecord) {
|
||||
@@ -118,20 +118,18 @@ public class MileageRecordServiceImpl extends BaseServiceImpl<MileageRecordMappe
|
||||
|
||||
private List<String> validateImportMileageRecord(MileageRecord mileageRecord) {
|
||||
List<String> validationErrors = new ArrayList<>();
|
||||
boolean isShip = VEHICLE_TYPE_SHIP.equals(mileageRecord.getVehicleType());
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, !VEHICLE_TYPE_VEHICLE.equals(mileageRecord.getVehicleType()) && !isShip, "车船类型不正确");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(mileageRecord.getVehicleNo()), isShip ? "船号不能为空" : "车牌号不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, mileageRecord.getVehicleNo(), VEHICLE_NO_MAX_LENGTH, isShip ? "船号不能超过30字" : "车牌号不能超过30字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(mileageRecord.getVehicleNo()), "车牌号不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, mileageRecord.getVehicleNo(), VEHICLE_NO_MAX_LENGTH, "车牌号不能超过30字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, mileageRecord.getRemark(), REMARK_MAX_LENGTH, "备注不能超过200字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, mileageRecord.getAttachments(), ATTACHMENTS_MAX_LENGTH, "附件不能超过1000字");
|
||||
addImportMileageErrors(validationErrors, mileageRecord.getPreviousMonthMileage(), isShip ? "上月统计航程数" : "上月统计里程数");
|
||||
addImportMileageErrors(validationErrors, mileageRecord.getCurrentMonthMileage(), isShip ? "本月统计航程数" : "本月统计里程数");
|
||||
addImportMileageErrors(validationErrors, mileageRecord.getMonthlyMileage(), isShip ? "本月航行航程数" : "本月行驶里程数");
|
||||
addImportMileageErrors(validationErrors, mileageRecord.getTotalMileage(), isShip ? "累计航程数" : "累计行驶里程数");
|
||||
addImportMileageErrors(validationErrors, mileageRecord.getPreviousMonthMileage(), "上月统计里程数");
|
||||
addImportMileageErrors(validationErrors, mileageRecord.getCurrentMonthMileage(), "本月统计里程数");
|
||||
addImportMileageErrors(validationErrors, mileageRecord.getMonthlyMileage(), "本月行驶里程数");
|
||||
addImportMileageErrors(validationErrors, mileageRecord.getTotalMileage(), "累计行驶里程数");
|
||||
if (mileageRecord.getPreviousMonthMileage() != null && mileageRecord.getCurrentMonthMileage() != null && mileageRecord.getMonthlyMileage() != null) {
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, mileageRecord.getCurrentMonthMileage().subtract(mileageRecord.getPreviousMonthMileage()).compareTo(mileageRecord.getMonthlyMileage()) != 0, isShip ? "本月航行航程数应等于本月统计航程数减去上月统计航程数" : "本月行驶里程数应等于本月统计里程数减去上月统计里程数");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, mileageRecord.getCurrentMonthMileage().subtract(mileageRecord.getPreviousMonthMileage()).compareTo(mileageRecord.getMonthlyMileage()) != 0, "本月行驶里程数应等于本月统计里程数减去上月统计里程数");
|
||||
}
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, mileageRecord.getTotalMileage() != null && mileageRecord.getCurrentMonthMileage() != null && mileageRecord.getTotalMileage().compareTo(mileageRecord.getCurrentMonthMileage()) < 0, isShip ? "累计航程数应大于等于本月统计航程数" : "累计行驶里程数应大于等于本月统计里程数");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, mileageRecord.getTotalMileage() != null && mileageRecord.getCurrentMonthMileage() != null && mileageRecord.getTotalMileage().compareTo(mileageRecord.getCurrentMonthMileage()) < 0, "累计行驶里程数应大于等于本月统计里程数");
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
@@ -156,14 +154,9 @@ public class MileageRecordServiceImpl extends BaseServiceImpl<MileageRecordMappe
|
||||
}
|
||||
|
||||
private void prepare(MileageRecord mileageRecord) {
|
||||
mileageRecord.setVehicleType(trimToEmpty(mileageRecord.getVehicleType()));
|
||||
if (Func.isEmpty(mileageRecord.getVehicleType())) {
|
||||
mileageRecord.setVehicleType(VEHICLE_TYPE_VEHICLE);
|
||||
}
|
||||
mileageRecord.setVehicleNo(
|
||||
normalizeVehicleNo(mileageRecord.getVehicleNo(), mileageRecord.getVehicleType())
|
||||
);
|
||||
mileageRecord.setMileageUnit(defaultMileageUnit(mileageRecord.getVehicleType()));
|
||||
mileageRecord.setVehicleType(VEHICLE_TYPE_VEHICLE);
|
||||
mileageRecord.setVehicleNo(normalizeVehicleNo(mileageRecord.getVehicleNo()));
|
||||
mileageRecord.setMileageUnit(MILEAGE_UNIT);
|
||||
mileageRecord.setRemark(trimToNull(mileageRecord.getRemark()));
|
||||
mileageRecord.setAttachments(trimToNull(mileageRecord.getAttachments()));
|
||||
if (mileageRecord.getMonthlyMileage() == null
|
||||
@@ -174,31 +167,25 @@ public class MileageRecordServiceImpl extends BaseServiceImpl<MileageRecordMappe
|
||||
}
|
||||
|
||||
private void validate(MileageRecord mileageRecord) {
|
||||
boolean isShip = VEHICLE_TYPE_SHIP.equals(mileageRecord.getVehicleType());
|
||||
if (!VEHICLE_TYPE_VEHICLE.equals(mileageRecord.getVehicleType()) && !isShip) {
|
||||
throw new ServiceException("车船类型不正确");
|
||||
}
|
||||
if (Func.isEmpty(mileageRecord.getVehicleNo())) {
|
||||
throw new ServiceException(isShip ? "船号不能为空" : "车牌号不能为空");
|
||||
throw new ServiceException("车牌号不能为空");
|
||||
}
|
||||
validateLength(
|
||||
mileageRecord.getVehicleNo(),
|
||||
VEHICLE_NO_MAX_LENGTH,
|
||||
isShip ? "船号不能超过30字" : "车牌号不能超过30字"
|
||||
"车牌号不能超过30字"
|
||||
);
|
||||
validateLength(mileageRecord.getRemark(), REMARK_MAX_LENGTH, "备注不能超过200字");
|
||||
validateLength(mileageRecord.getAttachments(), ATTACHMENTS_MAX_LENGTH, "附件不能超过1000字");
|
||||
validateMileage(mileageRecord.getPreviousMonthMileage(), isShip ? "上月统计航程数" : "上月统计里程数");
|
||||
validateMileage(mileageRecord.getCurrentMonthMileage(), isShip ? "本月统计航程数" : "本月统计里程数");
|
||||
validateMileage(mileageRecord.getMonthlyMileage(), isShip ? "本月航行航程数" : "本月行驶里程数");
|
||||
validateMileage(mileageRecord.getTotalMileage(), isShip ? "累计航程数" : "累计行驶里程数");
|
||||
validateMileage(mileageRecord.getPreviousMonthMileage(), "上月统计里程数");
|
||||
validateMileage(mileageRecord.getCurrentMonthMileage(), "本月统计里程数");
|
||||
validateMileage(mileageRecord.getMonthlyMileage(), "本月行驶里程数");
|
||||
validateMileage(mileageRecord.getTotalMileage(), "累计行驶里程数");
|
||||
validateMonthlyMileageConsistency(mileageRecord);
|
||||
if (mileageRecord.getTotalMileage() != null
|
||||
&& mileageRecord.getCurrentMonthMileage() != null
|
||||
&& mileageRecord.getTotalMileage().compareTo(mileageRecord.getCurrentMonthMileage()) < 0) {
|
||||
throw new ServiceException(
|
||||
isShip ? "累计航程数应大于等于本月统计航程数" : "累计行驶里程数应大于等于本月统计里程数"
|
||||
);
|
||||
throw new ServiceException("累计行驶里程数应大于等于本月统计里程数");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,9 +197,6 @@ public class MileageRecordServiceImpl extends BaseServiceImpl<MileageRecordMappe
|
||||
}
|
||||
BigDecimal calculated = mileageRecord.getCurrentMonthMileage().subtract(mileageRecord.getPreviousMonthMileage());
|
||||
if (calculated.compareTo(mileageRecord.getMonthlyMileage()) != 0) {
|
||||
if (VEHICLE_TYPE_SHIP.equals(mileageRecord.getVehicleType())) {
|
||||
throw new ServiceException("本月航行航程数应等于本月统计航程数减去上月统计航程数");
|
||||
}
|
||||
throw new ServiceException("本月行驶里程数应等于本月统计里程数减去上月统计里程数");
|
||||
}
|
||||
}
|
||||
@@ -222,10 +206,13 @@ public class MileageRecordServiceImpl extends BaseServiceImpl<MileageRecordMappe
|
||||
return;
|
||||
}
|
||||
MileageRecord oldRecord = getById(mileageRecord.getId());
|
||||
if (oldRecord != null && !VEHICLE_TYPE_VEHICLE.equals(oldRecord.getVehicleType())) {
|
||||
throw new ServiceException("仅支持车辆里程记录");
|
||||
}
|
||||
if (oldRecord != null
|
||||
&& Func.isNotEmpty(oldRecord.getVehicleNo())
|
||||
&& !oldRecord.getVehicleNo().equals(mileageRecord.getVehicleNo())) {
|
||||
throw new ServiceException("车牌号/船号保存后不可修改");
|
||||
throw new ServiceException("车牌号保存后不可修改");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,13 +241,8 @@ public class MileageRecordServiceImpl extends BaseServiceImpl<MileageRecordMappe
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
private String defaultMileageUnit(String vehicleType) {
|
||||
return VEHICLE_TYPE_SHIP.equals(vehicleType) ? "海里" : "公里";
|
||||
}
|
||||
|
||||
private String normalizeVehicleNo(String vehicleNo, String vehicleType) {
|
||||
String trimValue = trimToEmpty(vehicleNo);
|
||||
return VEHICLE_TYPE_SHIP.equals(vehicleType) ? trimValue : trimValue.toUpperCase();
|
||||
private String normalizeVehicleNo(String vehicleNo) {
|
||||
return trimToEmpty(vehicleNo).toUpperCase();
|
||||
}
|
||||
|
||||
private String trimToEmpty(String value) {
|
||||
|
||||
+22
-3
@@ -42,6 +42,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -61,6 +64,7 @@ public class TireReplacementRecordServiceImpl extends BaseServiceImpl<TireReplac
|
||||
private static final int REMARK_MAX_LENGTH = 500;
|
||||
private static final int ATTACHMENTS_MAX_LENGTH = 1000;
|
||||
private static final int MONEY_SCALE = 2;
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
|
||||
@Override
|
||||
public IPage<TireReplacementRecordVO> selectTireReplacementRecordPage(IPage<TireReplacementRecordVO> page, TireReplacementRecordVO tireReplacementRecord) {
|
||||
@@ -89,8 +93,10 @@ public class TireReplacementRecordServiceImpl extends BaseServiceImpl<TireReplac
|
||||
TireReplacementRecordExcel excel = data.get(index);
|
||||
try {
|
||||
TireReplacementRecord tireReplacementRecord = Objects.requireNonNull(BeanUtil.copyProperties(excel, TireReplacementRecord.class));
|
||||
List<String> validationErrors = new ArrayList<>();
|
||||
tireReplacementRecord.setReplacementTime(parseImportReplacementTime(excel.getReplacementTime(), validationErrors));
|
||||
prepare(tireReplacementRecord);
|
||||
List<String> validationErrors = validateImportTireReplacementRecord(tireReplacementRecord);
|
||||
validationErrors.addAll(validateImportTireReplacementRecord(tireReplacementRecord, excel.getReplacementTime()));
|
||||
if (Func.isNotEmpty(validationErrors)) {
|
||||
excel.setErrorMessage(org.springblade.common.excel.ImportFailureExcelUtil.formatErrorMessage(validationErrors));
|
||||
errorList.add(excel);
|
||||
@@ -115,10 +121,10 @@ public class TireReplacementRecordServiceImpl extends BaseServiceImpl<TireReplac
|
||||
return errorList;
|
||||
}
|
||||
|
||||
private List<String> validateImportTireReplacementRecord(TireReplacementRecord tireReplacementRecord) {
|
||||
private List<String> validateImportTireReplacementRecord(TireReplacementRecord tireReplacementRecord, String replacementTimeText) {
|
||||
List<String> validationErrors = new ArrayList<>();
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(tireReplacementRecord.getVehicleNo()), "车牌号不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(tireReplacementRecord.getReplacementTime()), "换胎时间不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, trimToNull(replacementTimeText) == null, "换胎时间不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addValidationError(validationErrors, Func.isEmpty(tireReplacementRecord.getReplacementCost()), "换胎费用不能为空");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, tireReplacementRecord.getVehicleNo(), VEHICLE_NO_MAX_LENGTH, "车牌号不能超过30字");
|
||||
org.springblade.common.excel.ImportFailureExcelUtil.addLengthValidationError(validationErrors, tireReplacementRecord.getHandler(), HANDLER_MAX_LENGTH, "处理人不能超过20字");
|
||||
@@ -132,6 +138,19 @@ public class TireReplacementRecordServiceImpl extends BaseServiceImpl<TireReplac
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
private LocalDate parseImportReplacementTime(String value, List<String> validationErrors) {
|
||||
String normalizedValue = trimToNull(value);
|
||||
if (normalizedValue == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return LocalDate.parse(normalizedValue, DATE_FORMATTER);
|
||||
} catch (DateTimeParseException exception) {
|
||||
validationErrors.add("换胎时间格式不正确,请使用yyyy-MM-dd格式并填写有效日期");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TireReplacementRecordExportExcel> exportTireReplacementRecord(Wrapper<TireReplacementRecord> queryWrapper) {
|
||||
return list(queryWrapper).stream().map(tireReplacementRecord -> {
|
||||
|
||||
@@ -13,7 +13,7 @@ CREATE TABLE `blade_equipment_ledger` (
|
||||
`specification_model` varchar(100) DEFAULT NULL COMMENT '规格型号',
|
||||
`original_equipment_no` varchar(100) DEFAULT NULL COMMENT '原厂设备号',
|
||||
`remark` varchar(200) DEFAULT NULL COMMENT '备注',
|
||||
`attachments` varchar(1000) DEFAULT NULL COMMENT '附件',
|
||||
`attachments` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件JSON',
|
||||
`online_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否在线:0否,1是',
|
||||
`create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `blade_equipment_ledger`
|
||||
MODIFY COLUMN `attachments` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件JSON';
|
||||
@@ -6088,7 +6088,7 @@ CREATE TABLE `blade_equipment_ledger` (
|
||||
`specification_model` varchar(100) DEFAULT NULL COMMENT '规格型号',
|
||||
`original_equipment_no` varchar(100) DEFAULT NULL COMMENT '原厂设备号',
|
||||
`remark` varchar(200) DEFAULT NULL COMMENT '备注',
|
||||
`attachments` varchar(1000) DEFAULT NULL COMMENT '附件',
|
||||
`attachments` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件JSON',
|
||||
`online_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否在线:0否,1是',
|
||||
`create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
|
||||
|
||||
Reference in New Issue
Block a user