✨ 新增异常关联维修记录:维修记录加 exception_id,异常详情内联记录并新增录入接口
This commit is contained in:
+90
@@ -0,0 +1,90 @@
|
|||||||
|
/**
|
||||||
|
* 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.pojo.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常处置 → 录入维修记录请求
|
||||||
|
* <p>
|
||||||
|
* 车牌号与车船类型不接收前端传值:车牌取自异常处置,车船类型固定「车辆」,
|
||||||
|
* 避免维修记录挂到与异常无关的车上。
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "异常处置录入维修记录请求")
|
||||||
|
public class ExceptionMaintenanceRecordRequest implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "异常处置ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "维修时间")
|
||||||
|
private LocalDateTime maintenanceTime;
|
||||||
|
|
||||||
|
@Schema(description = "维修位置")
|
||||||
|
private String location;
|
||||||
|
|
||||||
|
@Schema(description = "维修人")
|
||||||
|
private String maintainer;
|
||||||
|
|
||||||
|
@Schema(description = "维修单位")
|
||||||
|
private String company;
|
||||||
|
|
||||||
|
@Schema(description = "联系方式")
|
||||||
|
private String contact;
|
||||||
|
|
||||||
|
@Schema(description = "更换零件")
|
||||||
|
private String replacedPart;
|
||||||
|
|
||||||
|
@Schema(description = "费用")
|
||||||
|
private BigDecimal cost;
|
||||||
|
|
||||||
|
@Schema(description = "里程数(公里)")
|
||||||
|
private BigDecimal mileage;
|
||||||
|
|
||||||
|
@Schema(description = "出厂时间")
|
||||||
|
private LocalDateTime factoryTime;
|
||||||
|
|
||||||
|
@Schema(description = "详细地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Schema(description = "备注说明")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "附件JSON,[{\"name\":\"...\",\"url\":\"...\"}]")
|
||||||
|
private String attachments;
|
||||||
|
|
||||||
|
}
|
||||||
+6
@@ -61,6 +61,12 @@ public class MaintenanceRecord extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
@Schema(description = "车牌号/船号")
|
@Schema(description = "车牌号/船号")
|
||||||
private String vehicleNo;
|
private String vehicleNo;
|
||||||
|
/**
|
||||||
|
* 关联异常处置ID(小程序录入时写入)
|
||||||
|
*/
|
||||||
|
@Schema(description = "关联异常处置ID(小程序录入时写入)")
|
||||||
|
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||||
|
private Long exceptionId;
|
||||||
/**
|
/**
|
||||||
* 维修人
|
* 维修人
|
||||||
*/
|
*/
|
||||||
|
|||||||
+4
@@ -106,6 +106,10 @@ public class ExceptionDisposalVO extends ExceptionDisposal {
|
|||||||
@Schema(description = "可调整的路线站点,少于两个站时为空")
|
@Schema(description = "可调整的路线站点,少于两个站时为空")
|
||||||
private List<RouteNode> routeNodes;
|
private List<RouteNode> routeNodes;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "关联的维修记录(车辆故障维修异常录入,未录入时为空对象,判定须看 id)")
|
||||||
|
private MaintenanceRecordVO maintenanceRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一个可调整的站点:站序声明、地址、该站的装卸标记与项目名
|
* 一个可调整的站点:站序声明、地址、该站的装卸标记与项目名
|
||||||
*/
|
*/
|
||||||
|
|||||||
+21
@@ -76,4 +76,25 @@ public class MaintenanceRecordVO extends MaintenanceRecord {
|
|||||||
@Schema(description = "更新人姓名")
|
@Schema(description = "更新人姓名")
|
||||||
private String updateUserName;
|
private String updateUserName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联运单号(由 exception_id 关联异常处置带出)
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "关联运单号")
|
||||||
|
private String waybillNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联异常类型(一级)
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "关联异常类型")
|
||||||
|
private String exceptionType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联异常原因(二级)
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "关联异常原因")
|
||||||
|
private String exceptionReason;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -36,6 +36,7 @@ import org.springblade.transport.pojo.dto.ExceptionDisposalFollowRequest;
|
|||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
|
||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalRouteAdjustRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalRouteAdjustRequest;
|
||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
|
||||||
|
import org.springblade.transport.pojo.dto.ExceptionMaintenanceRecordRequest;
|
||||||
import org.springblade.transport.pojo.entity.ExceptionDisposal;
|
import org.springblade.transport.pojo.entity.ExceptionDisposal;
|
||||||
import org.springblade.transport.pojo.vo.ExceptionDisposalVO;
|
import org.springblade.transport.pojo.vo.ExceptionDisposalVO;
|
||||||
import org.springblade.transport.service.IExceptionDisposalService;
|
import org.springblade.transport.service.IExceptionDisposalService;
|
||||||
@@ -140,4 +141,12 @@ public class ExceptionDisposalController extends BladeController {
|
|||||||
return R.success("已调整路线");
|
return R.success("已调整路线");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/maintenance-record")
|
||||||
|
@ApiOperationSupport(order = 11)
|
||||||
|
@Operation(summary = "录入维修记录", description = "车辆故障维修类异常的子流程:写一条关联维修记录并追加跟进记录,不结案;一条异常至多一条;仅需登录态")
|
||||||
|
public R submitMaintenanceRecord(@RequestBody ExceptionMaintenanceRecordRequest request) {
|
||||||
|
exceptionDisposalService.submitMaintenanceRecord(request);
|
||||||
|
return R.success("已保存维修记录");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-32
@@ -14,6 +14,7 @@
|
|||||||
<result column="is_deleted" property="isDeleted"/>
|
<result column="is_deleted" property="isDeleted"/>
|
||||||
<result column="vehicle_type" property="vehicleType"/>
|
<result column="vehicle_type" property="vehicleType"/>
|
||||||
<result column="vehicle_no" property="vehicleNo"/>
|
<result column="vehicle_no" property="vehicleNo"/>
|
||||||
|
<result column="exception_id" property="exceptionId"/>
|
||||||
<result column="maintainer" property="maintainer"/>
|
<result column="maintainer" property="maintainer"/>
|
||||||
<result column="maintenance_time" property="maintenanceTime"/>
|
<result column="maintenance_time" property="maintenanceTime"/>
|
||||||
<result column="location" property="location"/>
|
<result column="location" property="location"/>
|
||||||
@@ -27,55 +28,63 @@
|
|||||||
<result column="mileage_unit" property="mileageUnit"/>
|
<result column="mileage_unit" property="mileageUnit"/>
|
||||||
<result column="attachments" property="attachments"/>
|
<result column="attachments" property="attachments"/>
|
||||||
<result column="remark" property="remark"/>
|
<result column="remark" property="remark"/>
|
||||||
|
<result column="waybill_no" property="waybillNo"/>
|
||||||
|
<result column="exception_type" property="exceptionType"/>
|
||||||
|
<result column="exception_reason" property="exceptionReason"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="selectMaintenanceRecordPage" resultMap="maintenanceRecordResultMap">
|
<select id="selectMaintenanceRecordPage" resultMap="maintenanceRecordResultMap">
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
r.id,
|
||||||
tenant_id,
|
r.tenant_id,
|
||||||
create_user,
|
r.create_user,
|
||||||
create_dept,
|
r.create_dept,
|
||||||
create_time,
|
r.create_time,
|
||||||
update_user,
|
r.update_user,
|
||||||
update_time,
|
r.update_time,
|
||||||
status,
|
r.status,
|
||||||
is_deleted,
|
r.is_deleted,
|
||||||
vehicle_type,
|
r.vehicle_type,
|
||||||
vehicle_no,
|
r.vehicle_no,
|
||||||
maintainer,
|
r.exception_id,
|
||||||
maintenance_time,
|
r.maintainer,
|
||||||
location,
|
r.maintenance_time,
|
||||||
replaced_part,
|
r.location,
|
||||||
cost,
|
r.replaced_part,
|
||||||
company,
|
r.cost,
|
||||||
contact,
|
r.company,
|
||||||
address,
|
r.contact,
|
||||||
factory_time,
|
r.address,
|
||||||
CASE WHEN mileage = -1 THEN NULL WHEN mileage < 0 THEN 0 ELSE mileage END AS mileage,
|
r.factory_time,
|
||||||
mileage_unit,
|
CASE WHEN r.mileage = -1 THEN NULL WHEN r.mileage < 0 THEN 0 ELSE r.mileage END AS mileage,
|
||||||
attachments,
|
r.mileage_unit,
|
||||||
remark
|
r.attachments,
|
||||||
|
r.remark,
|
||||||
|
d.waybill_no,
|
||||||
|
d.exception_type,
|
||||||
|
d.exception_reason
|
||||||
FROM
|
FROM
|
||||||
blade_vehicle_maintenance_record
|
blade_vehicle_maintenance_record r
|
||||||
|
LEFT JOIN blade_exception_disposal d ON d.id = r.exception_id AND d.is_deleted = 0
|
||||||
WHERE
|
WHERE
|
||||||
is_deleted = 0
|
r.is_deleted = 0
|
||||||
<if test="maintenanceRecord.createDept != null">
|
<if test="maintenanceRecord.createDept != null">
|
||||||
AND create_dept = #{maintenanceRecord.createDept}
|
AND r.create_dept = #{maintenanceRecord.createDept}
|
||||||
</if>
|
</if>
|
||||||
<if test="maintenanceRecord.vehicleType != null and maintenanceRecord.vehicleType != ''">
|
<if test="maintenanceRecord.vehicleType != null and maintenanceRecord.vehicleType != ''">
|
||||||
AND vehicle_type = #{maintenanceRecord.vehicleType}
|
AND r.vehicle_type = #{maintenanceRecord.vehicleType}
|
||||||
</if>
|
</if>
|
||||||
<if test="maintenanceRecord.vehicleNo != null and maintenanceRecord.vehicleNo != ''">
|
<if test="maintenanceRecord.vehicleNo != null and maintenanceRecord.vehicleNo != ''">
|
||||||
<bind name="vehicleNoLike" value="'%' + maintenanceRecord.vehicleNo + '%'"/>
|
<bind name="vehicleNoLike" value="'%' + maintenanceRecord.vehicleNo + '%'"/>
|
||||||
AND vehicle_no LIKE #{vehicleNoLike}
|
AND r.vehicle_no LIKE #{vehicleNoLike}
|
||||||
</if>
|
</if>
|
||||||
<if test="maintenanceRecord.createTimeStart != null">
|
<if test="maintenanceRecord.createTimeStart != null">
|
||||||
AND create_time >= #{maintenanceRecord.createTimeStart}
|
AND r.create_time >= #{maintenanceRecord.createTimeStart}
|
||||||
</if>
|
</if>
|
||||||
<if test="maintenanceRecord.createTimeEnd != null">
|
<if test="maintenanceRecord.createTimeEnd != null">
|
||||||
AND create_time <= #{maintenanceRecord.createTimeEnd}
|
AND r.create_time <= #{maintenanceRecord.createTimeEnd}
|
||||||
</if>
|
</if>
|
||||||
ORDER BY create_time DESC
|
ORDER BY r.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
+7
@@ -28,6 +28,7 @@ import org.springblade.transport.pojo.dto.ExceptionDisposalFollowRequest;
|
|||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
|
||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalRouteAdjustRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalRouteAdjustRequest;
|
||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
|
||||||
|
import org.springblade.transport.pojo.dto.ExceptionMaintenanceRecordRequest;
|
||||||
import org.springblade.transport.pojo.entity.ExceptionDisposal;
|
import org.springblade.transport.pojo.entity.ExceptionDisposal;
|
||||||
import org.springblade.transport.pojo.vo.ExceptionDisposalVO;
|
import org.springblade.transport.pojo.vo.ExceptionDisposalVO;
|
||||||
|
|
||||||
@@ -75,4 +76,10 @@ public interface IExceptionDisposalService extends BaseService<ExceptionDisposal
|
|||||||
*/
|
*/
|
||||||
void adjustRoute(ExceptionDisposalRouteAdjustRequest request);
|
void adjustRoute(ExceptionDisposalRouteAdjustRequest request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录入关联维修记录:写一条维修记录并追加一条跟进记录,不结案。
|
||||||
|
* 一条异常至多一条维修记录;已撤销的异常不允许录入。
|
||||||
|
*/
|
||||||
|
void submitMaintenanceRecord(ExceptionMaintenanceRecordRequest request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+87
-1
@@ -41,22 +41,28 @@ import org.springblade.transport.pojo.dto.ExceptionDisposalFollowRequest;
|
|||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
|
||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalRouteAdjustRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalRouteAdjustRequest;
|
||||||
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
|
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
|
||||||
|
import org.springblade.transport.pojo.dto.ExceptionMaintenanceRecordRequest;
|
||||||
import org.springblade.transport.pojo.entity.ExceptionDisposal;
|
import org.springblade.transport.pojo.entity.ExceptionDisposal;
|
||||||
import org.springblade.transport.pojo.entity.ExceptionDisposalFollowRecord;
|
import org.springblade.transport.pojo.entity.ExceptionDisposalFollowRecord;
|
||||||
import org.springblade.transport.pojo.entity.LoadingManage;
|
import org.springblade.transport.pojo.entity.LoadingManage;
|
||||||
|
import org.springblade.transport.pojo.entity.MaintenanceRecord;
|
||||||
import org.springblade.transport.pojo.entity.Waybill;
|
import org.springblade.transport.pojo.entity.Waybill;
|
||||||
import org.springblade.transport.pojo.vo.ExceptionDisposalFollowRecordVO;
|
import org.springblade.transport.pojo.vo.ExceptionDisposalFollowRecordVO;
|
||||||
import org.springblade.transport.pojo.vo.ExceptionDisposalVO;
|
import org.springblade.transport.pojo.vo.ExceptionDisposalVO;
|
||||||
|
import org.springblade.transport.pojo.vo.MaintenanceRecordVO;
|
||||||
import org.springblade.transport.service.IDriverWaybillService;
|
import org.springblade.transport.service.IDriverWaybillService;
|
||||||
import org.springblade.transport.service.IExceptionDisposalService;
|
import org.springblade.transport.service.IExceptionDisposalService;
|
||||||
|
import org.springblade.transport.service.IMaintenanceRecordService;
|
||||||
import org.springblade.transport.service.IWaybillService;
|
import org.springblade.transport.service.IWaybillService;
|
||||||
import org.springblade.transport.support.MpUserDataScopeSupport;
|
import org.springblade.transport.support.MpUserDataScopeSupport;
|
||||||
import org.springblade.transport.support.TransportBusinessSupport;
|
import org.springblade.transport.support.TransportBusinessSupport;
|
||||||
import org.springblade.transport.support.WaybillProcessSupport;
|
import org.springblade.transport.support.WaybillProcessSupport;
|
||||||
|
import org.springframework.dao.DuplicateKeyException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -92,6 +98,12 @@ public class ExceptionDisposalServiceImpl
|
|||||||
/** 拒绝原因长度上限,与上报说明、异常原因同量级,且远小于跟进记录列宽 */
|
/** 拒绝原因长度上限,与上报说明、异常原因同量级,且远小于跟进记录列宽 */
|
||||||
private static final int REJECT_REASON_MAX_LENGTH = 200;
|
private static final int REJECT_REASON_MAX_LENGTH = 200;
|
||||||
|
|
||||||
|
/** 异常子流程录入的维修记录固定为车辆:入口只对「车辆故障维修」类异常开放 */
|
||||||
|
private static final String MAINTENANCE_VEHICLE_TYPE = "车辆";
|
||||||
|
|
||||||
|
/** 维修记录跟进说明前缀;金额必填,维修单位按实际填写拼在后面 */
|
||||||
|
private static final String MAINTENANCE_FOLLOW_PREFIX = "已录入维修记录:费用";
|
||||||
|
|
||||||
/** 路线与任务信息的列宽上限,与 PC 改路线同一口径 */
|
/** 路线与任务信息的列宽上限,与 PC 改路线同一口径 */
|
||||||
private static final int ROUTE_JSON_MAX_LENGTH = 8000;
|
private static final int ROUTE_JSON_MAX_LENGTH = 8000;
|
||||||
private static final int TASK_INFO_JSON_MAX_LENGTH = 8000;
|
private static final int TASK_INFO_JSON_MAX_LENGTH = 8000;
|
||||||
@@ -119,17 +131,20 @@ public class ExceptionDisposalServiceImpl
|
|||||||
private final IDriverWaybillService driverWaybillService;
|
private final IDriverWaybillService driverWaybillService;
|
||||||
private final MpUserDataScopeSupport mpUserDataScopeSupport;
|
private final MpUserDataScopeSupport mpUserDataScopeSupport;
|
||||||
private final LoadingManageMapper loadingManageMapper;
|
private final LoadingManageMapper loadingManageMapper;
|
||||||
|
private final IMaintenanceRecordService maintenanceRecordService;
|
||||||
|
|
||||||
public ExceptionDisposalServiceImpl(ExceptionDisposalFollowRecordMapper followRecordMapper,
|
public ExceptionDisposalServiceImpl(ExceptionDisposalFollowRecordMapper followRecordMapper,
|
||||||
IWaybillService waybillService,
|
IWaybillService waybillService,
|
||||||
IDriverWaybillService driverWaybillService,
|
IDriverWaybillService driverWaybillService,
|
||||||
MpUserDataScopeSupport mpUserDataScopeSupport,
|
MpUserDataScopeSupport mpUserDataScopeSupport,
|
||||||
LoadingManageMapper loadingManageMapper) {
|
LoadingManageMapper loadingManageMapper,
|
||||||
|
IMaintenanceRecordService maintenanceRecordService) {
|
||||||
this.followRecordMapper = followRecordMapper;
|
this.followRecordMapper = followRecordMapper;
|
||||||
this.waybillService = waybillService;
|
this.waybillService = waybillService;
|
||||||
this.driverWaybillService = driverWaybillService;
|
this.driverWaybillService = driverWaybillService;
|
||||||
this.mpUserDataScopeSupport = mpUserDataScopeSupport;
|
this.mpUserDataScopeSupport = mpUserDataScopeSupport;
|
||||||
this.loadingManageMapper = loadingManageMapper;
|
this.loadingManageMapper = loadingManageMapper;
|
||||||
|
this.maintenanceRecordService = maintenanceRecordService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,6 +161,7 @@ public class ExceptionDisposalServiceImpl
|
|||||||
ExceptionDisposalVO vo = convertVO(entity);
|
ExceptionDisposalVO vo = convertVO(entity);
|
||||||
fillRouteNodes(vo, fillRouteAndCargo(vo, entity.getWaybillId()));
|
fillRouteNodes(vo, fillRouteAndCargo(vo, entity.getWaybillId()));
|
||||||
vo.setFollowRecords(followRecords(id));
|
vo.setFollowRecords(followRecords(id));
|
||||||
|
vo.setMaintenanceRecord(maintenanceRecord(id));
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,6 +543,76 @@ public class ExceptionDisposalServiceImpl
|
|||||||
updateById(disposal);
|
updateById(disposal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void submitMaintenanceRecord(ExceptionMaintenanceRecordRequest request) {
|
||||||
|
if (request == null || request.getId() == null) {
|
||||||
|
throw new ServiceException("请选择需要录入维修记录的异常");
|
||||||
|
}
|
||||||
|
ExceptionDisposal disposal = getExisting(request.getId());
|
||||||
|
if (STATUS_REVOKED.equals(disposal.getDisposalStatus())) {
|
||||||
|
throw new ServiceException("已撤销的异常不允许录入维修记录");
|
||||||
|
}
|
||||||
|
if (Func.isBlank(disposal.getVehicleNo())) {
|
||||||
|
throw new ServiceException("异常未记录车牌号,无法录入维修记录");
|
||||||
|
}
|
||||||
|
// 唯一索引占位后无法再插入,先按 exception_id 拦住(含已逻辑删除的记录)
|
||||||
|
long recorded = maintenanceRecordService.count(Wrappers.<MaintenanceRecord>lambdaQuery()
|
||||||
|
.eq(MaintenanceRecord::getExceptionId, disposal.getId()));
|
||||||
|
if (recorded > 0) {
|
||||||
|
throw new ServiceException("该异常已录入维修记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
MaintenanceRecord record = new MaintenanceRecord();
|
||||||
|
record.setExceptionId(disposal.getId());
|
||||||
|
record.setVehicleType(MAINTENANCE_VEHICLE_TYPE);
|
||||||
|
record.setVehicleNo(disposal.getVehicleNo());
|
||||||
|
record.setMaintenanceTime(request.getMaintenanceTime());
|
||||||
|
record.setLocation(request.getLocation());
|
||||||
|
record.setMaintainer(request.getMaintainer());
|
||||||
|
record.setCompany(request.getCompany());
|
||||||
|
record.setContact(request.getContact());
|
||||||
|
record.setReplacedPart(request.getReplacedPart());
|
||||||
|
record.setCost(request.getCost());
|
||||||
|
record.setMileage(request.getMileage());
|
||||||
|
record.setFactoryTime(request.getFactoryTime());
|
||||||
|
record.setAddress(request.getAddress());
|
||||||
|
record.setRemark(request.getRemark());
|
||||||
|
record.setAttachments(request.getAttachments());
|
||||||
|
// 复用维修记录自身的校验与落库(车船类型、车牌、费用、出厂时间等口径与 PC 一致)
|
||||||
|
try {
|
||||||
|
maintenanceRecordService.submit(record);
|
||||||
|
} catch (DuplicateKeyException exception) {
|
||||||
|
// 并发重复提交:前一条尚在事务中、计数看不见,唯一索引是最终防线
|
||||||
|
throw new ServiceException("该异常已录入维修记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
String followContent = maintenanceFollowContent(record.getCost(), record.getCompany());
|
||||||
|
insertFollowRecord(disposal.getId(), followContent);
|
||||||
|
disposal.setLatestFollowContent(followContent);
|
||||||
|
// 录入维修记录不结案:已了结的异常只补记录与最近跟进,不回退状态
|
||||||
|
if (!WaybillProcessSupport.SETTLED_DISPOSAL_STATUSES.contains(disposal.getDisposalStatus())) {
|
||||||
|
disposal.setDisposalStatus(STATUS_PROCESSING);
|
||||||
|
}
|
||||||
|
updateById(disposal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 跟进说明:金额必填,维修单位为空时只写金额 */
|
||||||
|
private String maintenanceFollowContent(BigDecimal cost, String company) {
|
||||||
|
String amount = Func.isEmpty(cost) ? "" : cost.setScale(2, RoundingMode.HALF_UP).toPlainString();
|
||||||
|
String content = MAINTENANCE_FOLLOW_PREFIX + amount + "元";
|
||||||
|
return Func.isBlank(company) ? content : content + ",维修单位" + company.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 异常关联的维修记录:一条异常至多一条,逻辑删除的视为未录入 */
|
||||||
|
private MaintenanceRecordVO maintenanceRecord(Long disposalId) {
|
||||||
|
MaintenanceRecord record = maintenanceRecordService.getOne(Wrappers.<MaintenanceRecord>lambdaQuery()
|
||||||
|
.eq(MaintenanceRecord::getExceptionId, disposalId)
|
||||||
|
.eq(MaintenanceRecord::getIsDeleted, 0)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
return record == null ? null : BeanUtil.copyProperties(record, MaintenanceRecordVO.class);
|
||||||
|
}
|
||||||
|
|
||||||
/** 已了结(已完成 / 已撤销)的异常不允许再次处置 */
|
/** 已了结(已完成 / 已撤销)的异常不允许再次处置 */
|
||||||
private void assertNotSettled(ExceptionDisposal disposal) {
|
private void assertNotSettled(ExceptionDisposal disposal) {
|
||||||
if (WaybillProcessSupport.SETTLED_DISPOSAL_STATUSES.contains(disposal.getDisposalStatus())) {
|
if (WaybillProcessSupport.SETTLED_DISPOSAL_STATUSES.contains(disposal.getDisposalStatus())) {
|
||||||
|
|||||||
+13
@@ -27,6 +27,7 @@ package org.springblade.transport.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springblade.core.log.exception.ServiceException;
|
import org.springblade.core.log.exception.ServiceException;
|
||||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||||
import org.springblade.core.tool.utils.BeanUtil;
|
import org.springblade.core.tool.utils.BeanUtil;
|
||||||
@@ -81,6 +82,18 @@ public class MaintenanceRecordServiceImpl extends BaseServiceImpl<MaintenanceRec
|
|||||||
return saveOrUpdate(maintenanceRecord);
|
return saveOrUpdate(maintenanceRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean deleteLogic(List<Long> ids) {
|
||||||
|
if (Func.isNotEmpty(ids)) {
|
||||||
|
// 唯一索引不因逻辑删除释放:不清空 exception_id,异常侧会永远显示「已录入」却查不到记录
|
||||||
|
update(Wrappers.<MaintenanceRecord>lambdaUpdate()
|
||||||
|
.set(MaintenanceRecord::getExceptionId, null)
|
||||||
|
.in(MaintenanceRecord::getId, ids));
|
||||||
|
}
|
||||||
|
return super.deleteLogic(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<MaintenanceRecordExcel> importMaintenanceRecord(List<MaintenanceRecordExcel> data) {
|
public List<MaintenanceRecordExcel> importMaintenanceRecord(List<MaintenanceRecordExcel> data) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ CREATE TABLE `blade_vehicle_maintenance_record` (
|
|||||||
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
|
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
|
||||||
`vehicle_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '车船类型',
|
`vehicle_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '车船类型',
|
||||||
`vehicle_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '车牌号/船号',
|
`vehicle_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '车牌号/船号',
|
||||||
|
`exception_id` bigint NULL DEFAULT NULL COMMENT '关联异常处置ID(小程序录入时写入)',
|
||||||
`maintainer` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '维修人',
|
`maintainer` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '维修人',
|
||||||
`maintenance_time` datetime NOT NULL COMMENT '维修时间',
|
`maintenance_time` datetime NOT NULL COMMENT '维修时间',
|
||||||
`location` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '维修位置',
|
`location` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '维修位置',
|
||||||
@@ -29,5 +30,6 @@ CREATE TABLE `blade_vehicle_maintenance_record` (
|
|||||||
`is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
|
`is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
INDEX `idx_vehicle_maintenance_record_no`(`vehicle_no`) USING BTREE,
|
INDEX `idx_vehicle_maintenance_record_no`(`vehicle_no`) USING BTREE,
|
||||||
INDEX `idx_vehicle_maintenance_record_time`(`maintenance_time`) USING BTREE
|
INDEX `idx_vehicle_maintenance_record_time`(`maintenance_time`) USING BTREE,
|
||||||
|
UNIQUE INDEX `uk_vehicle_maintenance_record_exception`(`exception_id`) USING BTREE
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '车辆维修记录';
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '车辆维修记录';
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
-- 维修记录关联异常处置
|
||||||
|
-- 日期:2026-10-29
|
||||||
|
-- 小程序调度端在「车辆故障维修」类异常下录入维修记录,记录通过 exception_id 关联该条异常。
|
||||||
|
-- 一条异常至多一条维修记录,故建唯一索引;唯一索引允许多个 NULL,PC 手工录入/导入的记录不受影响。
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
|
||||||
|
DROP PROCEDURE IF EXISTS `upgrade_blade_vehicle_maintenance_record_exception_20261029`$$
|
||||||
|
CREATE PROCEDURE `upgrade_blade_vehicle_maintenance_record_exception_20261029`()
|
||||||
|
BEGIN
|
||||||
|
DECLARE db_name varchar(128);
|
||||||
|
SET db_name = DATABASE();
|
||||||
|
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
|
||||||
|
WHERE table_schema = db_name
|
||||||
|
AND table_name = 'blade_vehicle_maintenance_record'
|
||||||
|
AND column_name = 'exception_id') THEN
|
||||||
|
ALTER TABLE `blade_vehicle_maintenance_record`
|
||||||
|
ADD COLUMN `exception_id` bigint NULL DEFAULT NULL COMMENT '关联异常处置ID(小程序录入时写入)'
|
||||||
|
AFTER `vehicle_no`;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics
|
||||||
|
WHERE table_schema = db_name
|
||||||
|
AND table_name = 'blade_vehicle_maintenance_record'
|
||||||
|
AND index_name = 'uk_vehicle_maintenance_record_exception') THEN
|
||||||
|
ALTER TABLE `blade_vehicle_maintenance_record`
|
||||||
|
ADD UNIQUE INDEX `uk_vehicle_maintenance_record_exception`(`exception_id`) USING BTREE;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
|
||||||
|
CALL `upgrade_blade_vehicle_maintenance_record_exception_20261029`()$$
|
||||||
|
DROP PROCEDURE `upgrade_blade_vehicle_maintenance_record_exception_20261029`$$
|
||||||
|
|
||||||
|
DELIMITER ;
|
||||||
@@ -5620,6 +5620,7 @@ CREATE TABLE `blade_vehicle_maintenance_record` (
|
|||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
||||||
`vehicle_type` varchar(20) NOT NULL COMMENT '车船类型',
|
`vehicle_type` varchar(20) NOT NULL COMMENT '车船类型',
|
||||||
`vehicle_no` varchar(30) NOT NULL COMMENT '车牌号/船号',
|
`vehicle_no` varchar(30) NOT NULL COMMENT '车牌号/船号',
|
||||||
|
`exception_id` bigint(20) DEFAULT NULL COMMENT '关联异常处置ID(小程序录入时写入)',
|
||||||
`maintainer` varchar(20) DEFAULT NULL COMMENT '维修人',
|
`maintainer` varchar(20) DEFAULT NULL COMMENT '维修人',
|
||||||
`maintenance_time` datetime NOT NULL COMMENT '维修时间',
|
`maintenance_time` datetime NOT NULL COMMENT '维修时间',
|
||||||
`location` varchar(100) DEFAULT NULL COMMENT '维修位置',
|
`location` varchar(100) DEFAULT NULL COMMENT '维修位置',
|
||||||
@@ -5642,7 +5643,8 @@ CREATE TABLE `blade_vehicle_maintenance_record` (
|
|||||||
`is_deleted` int(11) DEFAULT '0' COMMENT '是否已删除',
|
`is_deleted` int(11) DEFAULT '0' COMMENT '是否已删除',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
KEY `idx_vehicle_maintenance_record_no` (`vehicle_no`) USING BTREE,
|
KEY `idx_vehicle_maintenance_record_no` (`vehicle_no`) USING BTREE,
|
||||||
KEY `idx_vehicle_maintenance_record_time` (`maintenance_time`) USING BTREE
|
KEY `idx_vehicle_maintenance_record_time` (`maintenance_time`) USING BTREE,
|
||||||
|
UNIQUE KEY `uk_vehicle_maintenance_record_exception` (`exception_id`) USING BTREE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='车辆维修记录';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='车辆维修记录';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user