新增车辆三检的三检历史记录列表
This commit is contained in:
@@ -111,3 +111,45 @@ ADD COLUMN reject_reason varchar(500) NULL COMMENT '审核不通过原因';
|
||||
|
||||
- 详情接口、列表接口、导出接口会返回 `rejectReason` 字段。
|
||||
- 审核驳回通知优先展示 `rejectReason`,没有时才回退展示 `auditResult`。
|
||||
|
||||
## 6. 三检历史记录接口
|
||||
|
||||
### 6.1 新增字段
|
||||
|
||||
- `inspectNo`:三检记录编号,规则为 `SJ + 三检创建日期(yyyyMMdd) + 车牌号后3位 + 4位随机数`
|
||||
- `inspectLocation`:检查地点,出车前、行车中、收车后三个阶段都支持保存
|
||||
|
||||
### 6.2 历史列表接口
|
||||
|
||||
- 路径:`GET /securityManagement/vehicleThreeInspect/history/list`
|
||||
- 说明:按 `inspectId` 聚合查询一轮三检历史记录,支持分页
|
||||
|
||||
返回核心字段:
|
||||
|
||||
- `inspectId`:三检流程ID
|
||||
- `inspectNo`:三检记录编号
|
||||
- `plateNumber`:车牌号
|
||||
- `inspectorName`:检查人
|
||||
- `startTime`:检查开始时间(出车提交时间)
|
||||
- `endTime`:检查结束时间(收车提交时间)
|
||||
- `auditorName`:审核人
|
||||
- `outInspectLocation`:出车前检查地点
|
||||
- `drivingInspectLocation`:行车中检查地点
|
||||
- `backInspectLocation`:收车后检查地点
|
||||
- `outCheck` / `drivingCheck` / `backCheck`:三个阶段详情
|
||||
|
||||
### 6.3 历史详情接口
|
||||
|
||||
- 路径:`GET /securityManagement/vehicleThreeInspect/history/{inspectId}`
|
||||
- 说明:返回指定 `inspectId` 下三个阶段的车辆三检详情
|
||||
|
||||
### 6.4 数据库脚本
|
||||
|
||||
新增脚本:
|
||||
|
||||
- `sql/alter_hot_vehicle_three_inspect_history_fields_20260601.sql`
|
||||
|
||||
脚本内容包含:
|
||||
|
||||
- 为 `hot_vehicle_three_inspect` 增加 `inspect_no`、`inspect_location` 字段
|
||||
- 对历史数据回填 `inspect_no`
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
ALTER TABLE hot_vehicle_three_inspect
|
||||
ADD COLUMN inspect_no varchar(32) NULL COMMENT '三检记录编号',
|
||||
ADD COLUMN inspect_location varchar(255) NULL COMMENT '检查地点';
|
||||
|
||||
UPDATE hot_vehicle_three_inspect t
|
||||
LEFT JOIN hot_vehicle v ON v.id = t.vehicle_id
|
||||
SET t.inspect_no = CONCAT(
|
||||
'SJ',
|
||||
DATE_FORMAT(COALESCE(t.inspect_time, t.create_time), '%Y%m%d'),
|
||||
RIGHT(COALESCE(v.plate_number, '000'), 3),
|
||||
LPAD(MOD(COALESCE(t.inspect_id, t.id), 10000), 4, '0')
|
||||
)
|
||||
WHERE (t.inspect_no IS NULL OR t.inspect_no = '')
|
||||
AND t.is_deleted = 0;
|
||||
@@ -223,4 +223,24 @@ public class HotVehicleThreeInspectController extends BaseController {
|
||||
public TableDataInfo<HotVehicleThreeInspectSummaryVo> listSummary(HotVehicleThreeInspectBo bo, PageQuery pageQuery) {
|
||||
return hotVehicleThreeInspectService.querySummaryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询车辆三检历史记录列表
|
||||
*/
|
||||
@GetMapping("/history/list")
|
||||
@Operation(summary = "分页查询车辆三检历史记录列表")
|
||||
public TableDataInfo<HotVehicleThreeInspectSummaryVo> listHistory(HotVehicleThreeInspectBo bo, PageQuery pageQuery) {
|
||||
return hotVehicleThreeInspectService.queryHistoryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询车辆三检历史记录详情
|
||||
*/
|
||||
@GetMapping("/history/{inspectId}")
|
||||
@Operation(summary = "查询车辆三检历史记录详情")
|
||||
public R<HotVehicleThreeInspectSummaryVo> getHistoryDetail(@NotNull(message = "三检流程ID不能为空")
|
||||
@Parameter(name = "inspectId", description = "三检流程ID", required = true, example = "1")
|
||||
@PathVariable Long inspectId) {
|
||||
return R.ok(hotVehicleThreeInspectService.queryHistoryDetail(inspectId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,21 @@ public class HotVehicleThreeInspect extends BaseEntity {
|
||||
*/
|
||||
private Long inspectId;
|
||||
|
||||
/**
|
||||
* 三检记录编号
|
||||
*/
|
||||
private String inspectNo;
|
||||
|
||||
/**
|
||||
* 检查时间
|
||||
*/
|
||||
private Date inspectTime;
|
||||
|
||||
/**
|
||||
* 检查地点
|
||||
*/
|
||||
private String inspectLocation;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
|
||||
@@ -63,12 +63,22 @@ public class HotVehicleThreeInspectBo extends BaseEntity {
|
||||
*/
|
||||
private Long inspectId;
|
||||
|
||||
/**
|
||||
* 三检记录编号
|
||||
*/
|
||||
private String inspectNo;
|
||||
|
||||
/**
|
||||
* 检查时间
|
||||
*/
|
||||
@NotNull(message = "检查时间不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Date inspectTime;
|
||||
|
||||
/**
|
||||
* 检查地点
|
||||
*/
|
||||
private String inspectLocation;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
|
||||
@@ -13,50 +13,48 @@ public class HotVehicleThreeInspectPrintVo {
|
||||
*/
|
||||
private Long inspectId;
|
||||
|
||||
/**
|
||||
* 三检记录编号
|
||||
*/
|
||||
private String inspectNo;
|
||||
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
private String plateNumber;
|
||||
|
||||
// --- 出车前 Phase 1 ---
|
||||
/**
|
||||
* 出车前-检查时间
|
||||
* 检查人
|
||||
*/
|
||||
private String startPhaseTime;
|
||||
/**
|
||||
* 出车前-状态
|
||||
*/
|
||||
private String startPhaseStatus;
|
||||
/**
|
||||
* 出车前-隐患
|
||||
*/
|
||||
private String startPhaseHiddenDanger;
|
||||
private String inspectorName;
|
||||
|
||||
// --- 行车中 Phase 2 ---
|
||||
/**
|
||||
* 行车中-检查时间
|
||||
* 审核人
|
||||
*/
|
||||
private String runningPhaseTime;
|
||||
/**
|
||||
* 行车中-状态
|
||||
*/
|
||||
private String runningPhaseStatus;
|
||||
/**
|
||||
* 行车中-隐患
|
||||
*/
|
||||
private String runningPhaseHiddenDanger;
|
||||
private String auditorName;
|
||||
|
||||
// --- 收车后 Phase 3 ---
|
||||
/**
|
||||
* 收车后-检查时间
|
||||
* 检查开始时间
|
||||
*/
|
||||
private String endPhaseTime;
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 收车后-状态
|
||||
* 检查结束时间
|
||||
*/
|
||||
private String endPhaseStatus;
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 收车后-隐患
|
||||
* 出车前检查地点
|
||||
*/
|
||||
private String endPhaseHiddenDanger;
|
||||
private String outInspectLocation;
|
||||
|
||||
/**
|
||||
* 行车中检查地点
|
||||
*/
|
||||
private String drivingInspectLocation;
|
||||
|
||||
/**
|
||||
* 收车后检查地点
|
||||
*/
|
||||
private String backInspectLocation;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ public class HotVehicleThreeInspectSummaryVo implements Serializable {
|
||||
*/
|
||||
private Long inspectId;
|
||||
|
||||
/**
|
||||
* 三检记录编号
|
||||
*/
|
||||
private String inspectNo;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@@ -48,6 +53,16 @@ public class HotVehicleThreeInspectSummaryVo implements Serializable {
|
||||
*/
|
||||
private String driverName;
|
||||
|
||||
/**
|
||||
* 检查人
|
||||
*/
|
||||
private String inspectorName;
|
||||
|
||||
/**
|
||||
* 审核人
|
||||
*/
|
||||
private String auditorName;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@@ -83,6 +98,21 @@ public class HotVehicleThreeInspectSummaryVo implements Serializable {
|
||||
*/
|
||||
private Boolean auditCompleted;
|
||||
|
||||
/**
|
||||
* 出车前检查地点
|
||||
*/
|
||||
private String outInspectLocation;
|
||||
|
||||
/**
|
||||
* 行车中检查地点
|
||||
*/
|
||||
private String drivingInspectLocation;
|
||||
|
||||
/**
|
||||
* 收车后检查地点
|
||||
*/
|
||||
private String backInspectLocation;
|
||||
|
||||
/**
|
||||
* 出车检查
|
||||
*/
|
||||
|
||||
@@ -66,12 +66,24 @@ public class HotVehicleThreeInspectVo implements Serializable {
|
||||
*/
|
||||
private Long inspectId;
|
||||
|
||||
/**
|
||||
* 三检记录编号
|
||||
*/
|
||||
@ExcelProperty(value = "三检记录编号")
|
||||
private String inspectNo;
|
||||
|
||||
/**
|
||||
* 检查时间
|
||||
*/
|
||||
@ExcelProperty(value = "检查时间")
|
||||
private Date inspectTime;
|
||||
|
||||
/**
|
||||
* 检查地点
|
||||
*/
|
||||
@ExcelProperty(value = "检查地点")
|
||||
private String inspectLocation;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
|
||||
@@ -57,6 +57,14 @@ public interface HotVehicleThreeInspectMapper extends BaseMapperPlus<HotVehicleT
|
||||
@Param("bo") HotVehicleThreeInspectBo bo
|
||||
);
|
||||
|
||||
/**
|
||||
* 按流程ID查询车辆三检聚合详情
|
||||
*
|
||||
* @param inspectId 流程ID
|
||||
* @return 聚合详情
|
||||
*/
|
||||
HotVehicleThreeInspectSummaryVo querySummaryByInspectId(@Param("inspectId") Long inspectId);
|
||||
|
||||
/**
|
||||
* 按流程ID集合查询三检明细
|
||||
*
|
||||
|
||||
@@ -82,6 +82,23 @@ public interface IHotVehicleThreeInspectService {
|
||||
*/
|
||||
TableDataInfo<HotVehicleThreeInspectSummaryVo> querySummaryPageList(HotVehicleThreeInspectBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询车辆三检历史记录分页列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 历史记录分页列表
|
||||
*/
|
||||
TableDataInfo<HotVehicleThreeInspectSummaryVo> queryHistoryPageList(HotVehicleThreeInspectBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 按三检流程ID查询历史详情
|
||||
*
|
||||
* @param inspectId 三检流程ID
|
||||
* @return 历史详情
|
||||
*/
|
||||
HotVehicleThreeInspectSummaryVo queryHistoryDetail(Long inspectId);
|
||||
|
||||
/**
|
||||
* 查询符合条件的车辆三检列表
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hotwj.platform.config.vehicleThreeInspect.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -40,12 +41,14 @@ import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Collections;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* 车辆三检Service业务层处理
|
||||
@@ -208,35 +211,28 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
@Override
|
||||
public TableDataInfo<HotVehicleThreeInspectSummaryVo> querySummaryPageList(HotVehicleThreeInspectBo bo, PageQuery pageQuery) {
|
||||
Page<HotVehicleThreeInspectSummaryVo> result = baseMapper.querySummaryPageList(pageQuery.build(), bo);
|
||||
List<HotVehicleThreeInspectSummaryVo> summaryList = result.getRecords();
|
||||
if (summaryList == null || summaryList.isEmpty()) {
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
enrichSummaryList(result.getRecords());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
List<Long> inspectIds = summaryList.stream()
|
||||
.map(HotVehicleThreeInspectSummaryVo::getInspectId)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
if (inspectIds.isEmpty()) {
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
@Override
|
||||
public TableDataInfo<HotVehicleThreeInspectSummaryVo> queryHistoryPageList(HotVehicleThreeInspectBo bo, PageQuery pageQuery) {
|
||||
return querySummaryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
List<HotVehicleThreeInspectVo> detailList = baseMapper.querySummaryDetailList(inspectIds);
|
||||
@Override
|
||||
public HotVehicleThreeInspectSummaryVo queryHistoryDetail(Long inspectId) {
|
||||
HotVehicleThreeInspectSummaryVo summary = baseMapper.querySummaryByInspectId(inspectId);
|
||||
if (summary == null) {
|
||||
throw new ServiceException("车辆三检历史记录不存在");
|
||||
}
|
||||
List<HotVehicleThreeInspectVo> detailList = baseMapper.querySummaryDetailList(Collections.singletonList(inspectId));
|
||||
fillTaskId(detailList);
|
||||
|
||||
Map<Long, HotVehicleThreeInspectSummaryVo> summaryMap = new HashMap<>(summaryList.size());
|
||||
for (HotVehicleThreeInspectSummaryVo summary : summaryList) {
|
||||
summaryMap.put(summary.getInspectId(), summary);
|
||||
}
|
||||
|
||||
for (HotVehicleThreeInspectVo detail : detailList) {
|
||||
HotVehicleThreeInspectSummaryVo summary = summaryMap.get(detail.getInspectId());
|
||||
if (summary == null) {
|
||||
continue;
|
||||
}
|
||||
attachPhaseDetail(summary, detail);
|
||||
}
|
||||
return TableDataInfo.build(result);
|
||||
refreshSummary(summary);
|
||||
return summary;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,20 +251,33 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
if (summary == null || detail == null || detail.getInspectPhase() == null) {
|
||||
return;
|
||||
}
|
||||
if (detail.getInspectPhase() == 1L) {
|
||||
if (StringUtils.isBlank(summary.getInspectNo()) && StringUtils.isNotBlank(detail.getInspectNo())) {
|
||||
summary.setInspectNo(detail.getInspectNo());
|
||||
}
|
||||
if (StringUtils.isBlank(summary.getInspectorName()) && StringUtils.isNotBlank(detail.getDriverName())) {
|
||||
summary.setInspectorName(detail.getDriverName());
|
||||
}
|
||||
if (StringUtils.isBlank(summary.getAuditorName()) && StringUtils.isNotBlank(detail.getAuditorName())) {
|
||||
summary.setAuditorName(detail.getAuditorName());
|
||||
}
|
||||
Long inspectPhase = detail.getInspectPhase();
|
||||
if (Objects.equals(inspectPhase, 1L)) {
|
||||
if (summary.getOutCheck() == null) {
|
||||
summary.setOutCheck(detail);
|
||||
summary.setOutInspectLocation(detail.getInspectLocation());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (detail.getInspectPhase() == 2L) {
|
||||
if (Objects.equals(inspectPhase, 2L)) {
|
||||
if (summary.getDrivingCheck() == null) {
|
||||
summary.setDrivingCheck(detail);
|
||||
summary.setDrivingInspectLocation(detail.getInspectLocation());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (detail.getInspectPhase() == 3L && summary.getBackCheck() == null) {
|
||||
if (Objects.equals(inspectPhase, 3L) && summary.getBackCheck() == null) {
|
||||
summary.setBackCheck(detail);
|
||||
summary.setBackInspectLocation(detail.getInspectLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,6 +329,8 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
lqw.eq(bo.getInspectPhase() != null, HotVehicleThreeInspect::getInspectPhase, bo.getInspectPhase());
|
||||
lqw.eq(bo.getInspectTime() != null, HotVehicleThreeInspect::getInspectTime, bo.getInspectTime());
|
||||
lqw.eq(bo.getInspectId() != null, HotVehicleThreeInspect::getInspectId, bo.getInspectId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getInspectNo()), HotVehicleThreeInspect::getInspectNo, bo.getInspectNo());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getInspectLocation()), HotVehicleThreeInspect::getInspectLocation, bo.getInspectLocation());
|
||||
lqw.eq(bo.getAuditorId() != null, HotVehicleThreeInspect::getAuditorId, bo.getAuditorId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getAuditorName()), HotVehicleThreeInspect::getAuditorName, bo.getAuditorName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getInspectResultJson()), HotVehicleThreeInspect::getInspectResultJson, bo.getInspectResultJson());
|
||||
@@ -337,6 +348,8 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(HotVehicleThreeInspectBo bo) {
|
||||
normalizeInspectLocation(bo);
|
||||
prepareInspectIdentity(bo);
|
||||
validateAttachImgUrlRequiredWhenAbnormal(bo);
|
||||
HotVehicleThreeInspect add = MapstructUtils.convert(bo, HotVehicleThreeInspect.class);
|
||||
validEntityBeforeSave(add);
|
||||
@@ -401,6 +414,7 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
patchNewRoundInspectIdentity(add, bo);
|
||||
bo.setId(add.getId());
|
||||
|
||||
// 开启车辆三检的流程
|
||||
@@ -542,6 +556,7 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(HotVehicleThreeInspectBo bo) {
|
||||
normalizeInspectLocation(bo);
|
||||
validateAttachImgUrlRequiredWhenAbnormal(bo);
|
||||
HotVehicleThreeInspect update = MapstructUtils.convert(bo, HotVehicleThreeInspect.class);
|
||||
validEntityBeforeSave(update);
|
||||
@@ -798,4 +813,156 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
}
|
||||
|
||||
private void enrichSummaryList(List<HotVehicleThreeInspectSummaryVo> summaryList) {
|
||||
if (summaryList == null || summaryList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Long> inspectIds = summaryList.stream()
|
||||
.map(HotVehicleThreeInspectSummaryVo::getInspectId)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
if (inspectIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<HotVehicleThreeInspectVo> detailList = baseMapper.querySummaryDetailList(inspectIds);
|
||||
fillTaskId(detailList);
|
||||
|
||||
Map<Long, HotVehicleThreeInspectSummaryVo> summaryMap = new HashMap<>(summaryList.size());
|
||||
for (HotVehicleThreeInspectSummaryVo summary : summaryList) {
|
||||
summaryMap.put(summary.getInspectId(), summary);
|
||||
}
|
||||
|
||||
for (HotVehicleThreeInspectVo detail : detailList) {
|
||||
HotVehicleThreeInspectSummaryVo summary = summaryMap.get(detail.getInspectId());
|
||||
if (summary == null) {
|
||||
continue;
|
||||
}
|
||||
attachPhaseDetail(summary, detail);
|
||||
}
|
||||
|
||||
for (HotVehicleThreeInspectSummaryVo summary : summaryList) {
|
||||
refreshSummary(summary);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshSummary(HotVehicleThreeInspectSummaryVo summary) {
|
||||
if (summary == null) {
|
||||
return;
|
||||
}
|
||||
if (summary.getOutCheck() != null) {
|
||||
summary.setStartTime(summary.getOutCheck().getInspectTime());
|
||||
if (StringUtils.isBlank(summary.getInspectNo())) {
|
||||
summary.setInspectNo(summary.getOutCheck().getInspectNo());
|
||||
}
|
||||
}
|
||||
if (summary.getBackCheck() != null) {
|
||||
summary.setEndTime(summary.getBackCheck().getInspectTime());
|
||||
}
|
||||
if (StringUtils.isBlank(summary.getInspectorName())) {
|
||||
summary.setInspectorName(summary.getDriverName());
|
||||
}
|
||||
summary.setInspectTime(buildInspectTimeRange(summary.getStartTime(), summary.getEndTime()));
|
||||
}
|
||||
|
||||
private String buildInspectTimeRange(Date startTime, Date endTime) {
|
||||
if (startTime == null && endTime == null) {
|
||||
return null;
|
||||
}
|
||||
if (startTime == null) {
|
||||
return DateUtil.formatDateTime(endTime);
|
||||
}
|
||||
if (endTime == null || Objects.equals(startTime, endTime)) {
|
||||
return DateUtil.formatDateTime(startTime);
|
||||
}
|
||||
return DateUtil.formatDateTime(startTime) + " ~ " + DateUtil.formatDateTime(endTime);
|
||||
}
|
||||
|
||||
private void normalizeInspectLocation(HotVehicleThreeInspectBo bo) {
|
||||
if (bo == null) {
|
||||
return;
|
||||
}
|
||||
bo.setInspectLocation(StringUtils.trimToNull(bo.getInspectLocation()));
|
||||
}
|
||||
|
||||
private void prepareInspectIdentity(HotVehicleThreeInspectBo bo) {
|
||||
if (bo == null || bo.getVehicleId() == null || bo.getInspectPhase() == null) {
|
||||
return;
|
||||
}
|
||||
HotVehicleThreeInspect latestInspect = selectLatestInspect(bo.getVehicleId());
|
||||
if (Objects.equals(bo.getInspectPhase(), 1L)) {
|
||||
if (StringUtils.isBlank(bo.getInspectNo())) {
|
||||
bo.setInspectNo(generateInspectNo(bo.getInspectTime(), bo.getVehicleId()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (latestInspect == null) {
|
||||
return;
|
||||
}
|
||||
if (bo.getInspectId() == null) {
|
||||
bo.setInspectId(latestInspect.getInspectId() != null ? latestInspect.getInspectId() : latestInspect.getId());
|
||||
}
|
||||
if (StringUtils.isBlank(bo.getInspectNo())) {
|
||||
bo.setInspectNo(latestInspect.getInspectNo());
|
||||
}
|
||||
}
|
||||
|
||||
private void patchNewRoundInspectIdentity(HotVehicleThreeInspect add, HotVehicleThreeInspectBo bo) {
|
||||
if (add == null || !Objects.equals(add.getInspectPhase(), 1L)) {
|
||||
return;
|
||||
}
|
||||
boolean changed = false;
|
||||
if (add.getInspectId() == null) {
|
||||
add.setInspectId(add.getId());
|
||||
changed = true;
|
||||
}
|
||||
if (StringUtils.isBlank(add.getInspectNo())) {
|
||||
add.setInspectNo(generateInspectNo(add.getInspectTime(), add.getVehicleId()));
|
||||
changed = true;
|
||||
}
|
||||
if (!changed) {
|
||||
return;
|
||||
}
|
||||
baseMapper.updateById(add);
|
||||
bo.setInspectId(add.getInspectId());
|
||||
bo.setInspectNo(add.getInspectNo());
|
||||
}
|
||||
|
||||
private String generateInspectNo(Date inspectTime, Long vehicleId) {
|
||||
Date recordDate = inspectTime == null ? new Date() : inspectTime;
|
||||
String dateText = DateUtil.format(recordDate, "yyyyMMdd");
|
||||
String plateSuffix = resolvePlateSuffix(vehicleId);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
String candidate = "SJ" + dateText + plateSuffix + randomFourDigits();
|
||||
Long count = baseMapper.selectCount(
|
||||
Wrappers.<HotVehicleThreeInspect>lambdaQuery()
|
||||
.eq(HotVehicleThreeInspect::getInspectNo, candidate)
|
||||
);
|
||||
if (count == null || count == 0L) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return "SJ" + dateText + plateSuffix + String.format("%04d", System.currentTimeMillis() % 10000);
|
||||
}
|
||||
|
||||
private String resolvePlateSuffix(Long vehicleId) {
|
||||
if (vehicleId == null) {
|
||||
return "000";
|
||||
}
|
||||
HotVehicle vehicle = hotVehicleMapper.selectById(String.valueOf(vehicleId));
|
||||
String plateNumber = vehicle == null ? null : StringUtils.trimToNull(vehicle.getPlateNumber());
|
||||
if (plateNumber == null) {
|
||||
return "000";
|
||||
}
|
||||
String normalized = plateNumber.replace(" ", "");
|
||||
if (normalized.length() <= 3) {
|
||||
return normalized;
|
||||
}
|
||||
return normalized.substring(normalized.length() - 3);
|
||||
}
|
||||
|
||||
private String randomFourDigits() {
|
||||
return String.format("%04d", ThreadLocalRandom.current().nextInt(1000, 10000));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
resultType="com.hotwj.platform.config.vehicleThreeInspect.domain.vo.HotVehicleThreeInspectProcessVo">
|
||||
SELECT
|
||||
t.inspect_id AS inspectId,
|
||||
MAX(t.inspect_no) AS inspectNo,
|
||||
MAX(t.company_id) AS companyId,
|
||||
MAX(t.vehicle_id) AS vehicleId,
|
||||
MAX(v.plate_number) AS plateNumber,
|
||||
MAX(t.driver_name) AS driverName,
|
||||
MAX(t.driver_name) AS inspectorName,
|
||||
MAX(t.auditor_name) AS auditorName,
|
||||
MIN(t.inspect_time) AS startTime,
|
||||
MAX(t.inspect_time) AS endTime,
|
||||
CASE
|
||||
@@ -74,6 +77,9 @@
|
||||
<if test="bo.inspectId != null">
|
||||
AND t.inspect_id = #{bo.inspectId}
|
||||
</if>
|
||||
<if test="bo.inspectNo != null and bo.inspectNo != ''">
|
||||
AND t.inspect_no = #{bo.inspectNo}
|
||||
</if>
|
||||
<if test="bo.params != null and bo.params.beginTime != null and bo.params.beginTime != '' and bo.params.endTime != null and bo.params.endTime != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
@@ -110,11 +116,14 @@
|
||||
resultType="com.hotwj.platform.config.vehicleThreeInspect.domain.vo.HotVehicleThreeInspectSummaryVo">
|
||||
SELECT
|
||||
t.inspect_id AS inspectId,
|
||||
MAX(t.inspect_no) AS inspectNo,
|
||||
MAX(t.company_id) AS companyId,
|
||||
MAX(t.vehicle_id) AS vehicleId,
|
||||
MAX(v.plate_number) AS plateNumber,
|
||||
MAX(t.driver_id) AS driverId,
|
||||
MAX(t.driver_name) AS driverName,
|
||||
MAX(t.driver_name) AS inspectorName,
|
||||
MAX(t.auditor_name) AS auditorName,
|
||||
MIN(IFNULL(t.inspect_time, t.create_time)) AS startTime,
|
||||
MAX(IFNULL(t.inspect_time, t.create_time)) AS endTime,
|
||||
CASE
|
||||
@@ -164,6 +173,9 @@
|
||||
<if test="bo.inspectId != null">
|
||||
AND t.inspect_id = #{bo.inspectId}
|
||||
</if>
|
||||
<if test="bo.inspectNo != null and bo.inspectNo != ''">
|
||||
AND t.inspect_no = #{bo.inspectNo}
|
||||
</if>
|
||||
<if test="bo.params != null and bo.params.beginTime != null and bo.params.beginTime != '' and bo.params.endTime != null and bo.params.endTime != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
@@ -196,21 +208,67 @@
|
||||
ORDER BY IFNULL(MAX(t.inspect_time), MAX(t.create_time)) DESC, MAX(t.create_time) DESC
|
||||
</select>
|
||||
|
||||
<select id="querySummaryByInspectId"
|
||||
resultType="com.hotwj.platform.config.vehicleThreeInspect.domain.vo.HotVehicleThreeInspectSummaryVo">
|
||||
SELECT
|
||||
t.inspect_id AS inspectId,
|
||||
MAX(t.inspect_no) AS inspectNo,
|
||||
MAX(t.company_id) AS companyId,
|
||||
MAX(t.vehicle_id) AS vehicleId,
|
||||
MAX(v.plate_number) AS plateNumber,
|
||||
MAX(t.driver_id) AS driverId,
|
||||
MAX(t.driver_name) AS driverName,
|
||||
MAX(t.driver_name) AS inspectorName,
|
||||
MAX(t.auditor_name) AS auditorName,
|
||||
MIN(IFNULL(t.inspect_time, t.create_time)) AS startTime,
|
||||
MAX(IFNULL(t.inspect_time, t.create_time)) AS endTime,
|
||||
CASE
|
||||
WHEN MIN(IFNULL(t.inspect_time, t.create_time)) = MAX(IFNULL(t.inspect_time, t.create_time))
|
||||
THEN DATE_FORMAT(MIN(IFNULL(t.inspect_time, t.create_time)), '%Y-%m-%d %H:%i:%s')
|
||||
ELSE CONCAT(
|
||||
DATE_FORMAT(MIN(IFNULL(t.inspect_time, t.create_time)), '%Y-%m-%d %H:%i:%s'),
|
||||
' ~ ',
|
||||
DATE_FORMAT(MAX(IFNULL(t.inspect_time, t.create_time)), '%Y-%m-%d %H:%i:%s')
|
||||
)
|
||||
END AS inspectTime,
|
||||
CASE
|
||||
WHEN SUM(CASE WHEN t.inspect_phase = 3 THEN 1 ELSE 0 END) > 0 THEN '已完成'
|
||||
ELSE '未完成'
|
||||
END AS completeStatus,
|
||||
CASE
|
||||
WHEN SUM(CASE WHEN t.inspect_phase = 3 THEN 1 ELSE 0 END) > 0 THEN 1
|
||||
ELSE 0
|
||||
END AS completed,
|
||||
CASE
|
||||
WHEN COUNT(DISTINCT CASE WHEN t.flow_status = 'APPROVED' THEN t.inspect_phase END) = 3
|
||||
THEN '已完成审核'
|
||||
ELSE '未审核'
|
||||
END AS auditCompleteStatus,
|
||||
CASE
|
||||
WHEN COUNT(DISTINCT CASE WHEN t.flow_status = 'APPROVED' THEN t.inspect_phase END) = 3
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS auditCompleted
|
||||
FROM hot_vehicle_three_inspect t
|
||||
LEFT JOIN hot_vehicle v ON t.vehicle_id = v.id
|
||||
WHERE t.is_deleted = 0
|
||||
AND t.inspect_id = #{inspectId}
|
||||
GROUP BY t.inspect_id
|
||||
</select>
|
||||
|
||||
<select id="selectPrintList"
|
||||
resultType="com.hotwj.platform.config.vehicleThreeInspect.domain.vo.HotVehicleThreeInspectPrintVo">
|
||||
WITH base AS (
|
||||
SELECT
|
||||
t1.inspect_id,
|
||||
t1.inspect_phase,
|
||||
CASE
|
||||
WHEN t1.flow_status IN ('APPROVED', 'REJECTED') THEN '已完结'
|
||||
WHEN t1.flow_status = 'SUBMITTED' THEN '待审核'
|
||||
ELSE t1.flow_status
|
||||
END as flow_status,
|
||||
t1.inspect_no,
|
||||
t1.create_time,
|
||||
v.plate_number,
|
||||
DATE_FORMAT(t1.inspect_time, '%Y-%m-%d %H:%i') as inspect_time_str,
|
||||
IF(t1.has_hidden_danger = 1, '是', '否') as hidden_danger_str
|
||||
t1.driver_name,
|
||||
t1.auditor_name,
|
||||
t1.inspect_phase,
|
||||
t1.inspect_location,
|
||||
IFNULL(t1.inspect_time, t1.create_time) AS inspect_time
|
||||
FROM hot_vehicle_three_inspect t1
|
||||
LEFT JOIN hot_vehicle v ON t1.vehicle_id = v.id
|
||||
WHERE t1.is_deleted = 0
|
||||
@@ -247,19 +305,15 @@
|
||||
</if>
|
||||
)
|
||||
SELECT
|
||||
MAX(inspect_no) as inspectNo,
|
||||
MAX(plate_number) as plateNumber,
|
||||
|
||||
MAX(IF(inspect_phase = 1, inspect_time_str, NULL)) as startPhaseTime,
|
||||
MAX(IF(inspect_phase = 1, flow_status, NULL)) as startPhaseStatus,
|
||||
MAX(IF(inspect_phase = 1, hidden_danger_str, NULL)) as startPhaseHiddenDanger,
|
||||
|
||||
MAX(IF(inspect_phase = 2, inspect_time_str, NULL)) as runningPhaseTime,
|
||||
MAX(IF(inspect_phase = 2, flow_status, NULL)) as runningPhaseStatus,
|
||||
MAX(IF(inspect_phase = 2, hidden_danger_str, NULL)) as runningPhaseHiddenDanger,
|
||||
|
||||
MAX(IF(inspect_phase = 3, inspect_time_str, NULL)) as endPhaseTime,
|
||||
MAX(IF(inspect_phase = 3, flow_status, NULL)) as endPhaseStatus,
|
||||
MAX(IF(inspect_phase = 3, hidden_danger_str, NULL)) as endPhaseHiddenDanger
|
||||
MAX(driver_name) as inspectorName,
|
||||
MAX(auditor_name) as auditorName,
|
||||
DATE_FORMAT(MIN(IF(inspect_phase = 1, inspect_time, NULL)), '%Y-%m-%d %H:%i') as startTime,
|
||||
DATE_FORMAT(MAX(IF(inspect_phase = 3, inspect_time, NULL)), '%Y-%m-%d %H:%i') as endTime,
|
||||
MAX(IF(inspect_phase = 1, inspect_location, NULL)) as outInspectLocation,
|
||||
MAX(IF(inspect_phase = 2, inspect_location, NULL)) as drivingInspectLocation,
|
||||
MAX(IF(inspect_phase = 3, inspect_location, NULL)) as backInspectLocation
|
||||
FROM base
|
||||
GROUP BY inspect_id
|
||||
ORDER BY MAX(create_time) DESC
|
||||
@@ -275,7 +329,9 @@
|
||||
t.driver_name,
|
||||
t.inspect_phase,
|
||||
t.inspect_id,
|
||||
t.inspect_no,
|
||||
t.inspect_time,
|
||||
t.inspect_location,
|
||||
t.auditor_id,
|
||||
t.auditor_name,
|
||||
t.inspect_result_json,
|
||||
|
||||
@@ -30,50 +30,31 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th rowspan="2" width="40">序号</th>
|
||||
<th rowspan="2" width="80">车辆</th>
|
||||
|
||||
<th colspan="3" class="group-border-left">出车检查</th>
|
||||
<th colspan="3" class="group-border-left">行车检查</th>
|
||||
<th colspan="3" class="group-border-left">收车检查</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<!-- 出车前 -->
|
||||
<th class="group-border-left" width="80">检查时间</th>
|
||||
<th width="50">状态</th>
|
||||
<th width="50">隐患</th>
|
||||
|
||||
<!-- 行车中 -->
|
||||
<th class="group-border-left" width="80">检查时间</th>
|
||||
<th width="50">状态</th>
|
||||
<th width="50">隐患</th>
|
||||
|
||||
<!-- 收车后 -->
|
||||
<th class="group-border-left" width="80">检查时间</th>
|
||||
<th width="50">状态</th>
|
||||
<th width="50">收车隐患</th>
|
||||
<th width="40">序号</th>
|
||||
<th width="140">三检记录编号</th>
|
||||
<th width="80">车牌号</th>
|
||||
<th width="70">检查人</th>
|
||||
<th width="90">开始时间</th>
|
||||
<th width="90">结束时间</th>
|
||||
<th width="90">出车前地点</th>
|
||||
<th width="90">行车中地点</th>
|
||||
<th width="90">收车后地点</th>
|
||||
<th width="70">审核人</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
#foreach($item in $list)
|
||||
<tr>
|
||||
<td>$foreach.count</td>
|
||||
<td>$!item.inspectNo</td>
|
||||
<td>$!item.plateNumber</td>
|
||||
|
||||
<!-- 出车前 -->
|
||||
<td class="group-border-left">$!item.startPhaseTime</td>
|
||||
<td>$!item.startPhaseStatus</td>
|
||||
<td>$!item.startPhaseHiddenDanger</td>
|
||||
|
||||
<!-- 行车中 -->
|
||||
<td class="group-border-left">$!item.runningPhaseTime</td>
|
||||
<td>$!item.runningPhaseStatus</td>
|
||||
<td>$!item.runningPhaseHiddenDanger</td>
|
||||
|
||||
<!-- 收车后 -->
|
||||
<td class="group-border-left">$!item.endPhaseTime</td>
|
||||
<td>$!item.endPhaseStatus</td>
|
||||
<td>$!item.endPhaseHiddenDanger</td>
|
||||
<td>$!item.inspectorName</td>
|
||||
<td>$!item.startTime</td>
|
||||
<td>$!item.endTime</td>
|
||||
<td>$!item.outInspectLocation</td>
|
||||
<td>$!item.drivingInspectLocation</td>
|
||||
<td>$!item.backInspectLocation</td>
|
||||
<td>$!item.auditorName</td>
|
||||
</tr>
|
||||
#end
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user