feat: 隐患排查补查功能
This commit is contained in:
@@ -131,7 +131,7 @@ public class HotHiddenDangerInspectionController extends BaseController {
|
|||||||
@GetMapping("/hidden-danger-plans/page")
|
@GetMapping("/hidden-danger-plans/page")
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "移动端分页查询隐患排查计划列表",
|
summary = "移动端分页查询隐患排查计划列表",
|
||||||
description = "权限说明:驾驶员仅可查看本人及所属车辆当月全部计划和历史未做计划;管理员可查看企业当月全部计划和历史未做计划。"
|
description = "权限说明:驾驶员仅可查看当前处于原始周期或补查周期内、且属于本人及所属车辆的计划;管理员可查看企业内当前处于有效时间范围的计划。"
|
||||||
)
|
)
|
||||||
public TableDataInfo<HotHiddenDangerInspectionVo> hiddenDangerPlanPage(
|
public TableDataInfo<HotHiddenDangerInspectionVo> hiddenDangerPlanPage(
|
||||||
@RequestParam(value = "keyword", required = false) String keyword,
|
@RequestParam(value = "keyword", required = false) String keyword,
|
||||||
|
|||||||
@@ -80,6 +80,16 @@ public class HotHiddenDangerInspection extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Date checkDate;
|
private Date checkDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否补查期间处理:0否 1是
|
||||||
|
*/
|
||||||
|
private Long isRecheckProcessed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查处理时间
|
||||||
|
*/
|
||||||
|
private Date recheckProcessedTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评估人id
|
* 评估人id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -86,6 +86,16 @@ public class HotHiddenDangerInspectionBo extends BaseEntity {
|
|||||||
// @NotNull(message = "排查日期不能为空", groups = {AddGroup.class, EditGroup.class})
|
// @NotNull(message = "排查日期不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private Date checkDate;
|
private Date checkDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否补查期间处理:0否 1是
|
||||||
|
*/
|
||||||
|
private Long isRecheckProcessed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查处理时间
|
||||||
|
*/
|
||||||
|
private Date recheckProcessedTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评估人id
|
* 评估人id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -94,6 +94,18 @@ public class HotHiddenDangerInspectionVo implements Serializable {
|
|||||||
@ExcelProperty(value = "排查日期")
|
@ExcelProperty(value = "排查日期")
|
||||||
private Date checkDate;
|
private Date checkDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否补查期间处理:0否 1是
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "是否补查期间处理")
|
||||||
|
private Long isRecheckProcessed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查处理时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "补查处理时间")
|
||||||
|
private Date recheckProcessedTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评估人id
|
* 评估人id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,6 +24,5 @@ public interface HotHiddenDangerInspectionMapper extends BaseMapperPlus<HotHidde
|
|||||||
@Param("driverId") String driverId,
|
@Param("driverId") String driverId,
|
||||||
@Param("vehicleId") String vehicleId,
|
@Param("vehicleId") String vehicleId,
|
||||||
@Param("planId") Long planId,
|
@Param("planId") Long planId,
|
||||||
@Param("keyword") String keyword,
|
@Param("keyword") String keyword);
|
||||||
@Param("currentMonth") String currentMonth);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ import com.hotwj.platform.securityManagement.hiddenDangerInspection.domain.vo.Ho
|
|||||||
import com.hotwj.platform.securityManagement.hiddenDangerInspection.domain.vo.HotHiddenDangerInspectionVo;
|
import com.hotwj.platform.securityManagement.hiddenDangerInspection.domain.vo.HotHiddenDangerInspectionVo;
|
||||||
import com.hotwj.platform.securityManagement.hiddenDangerInspection.mapper.HotHiddenDangerInspectionAuditHistoryMapper;
|
import com.hotwj.platform.securityManagement.hiddenDangerInspection.mapper.HotHiddenDangerInspectionAuditHistoryMapper;
|
||||||
import com.hotwj.platform.securityManagement.hiddenDangerInspection.mapper.HotHiddenDangerInspectionMapper;
|
import com.hotwj.platform.securityManagement.hiddenDangerInspection.mapper.HotHiddenDangerInspectionMapper;
|
||||||
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.HotHiddenDangerPlan;
|
||||||
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.mapper.HotHiddenDangerPlanMapper;
|
||||||
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.service.HiddenDangerPlanTimeWindowHelper;
|
||||||
import com.hotwj.platform.securityManagement.hiddenDangerInspection.service.IHotHiddenDangerInspectionService;
|
import com.hotwj.platform.securityManagement.hiddenDangerInspection.service.IHotHiddenDangerInspectionService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -29,7 +32,6 @@ import org.dromara.common.satoken.utils.LoginHelper;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.YearMonth;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -52,6 +54,8 @@ public class HotHiddenDangerInspectionServiceImpl implements IHotHiddenDangerIns
|
|||||||
private final ISysFlowService flowService;
|
private final ISysFlowService flowService;
|
||||||
private final IHotSystemNotificationService notificationService;
|
private final IHotSystemNotificationService notificationService;
|
||||||
private final SignatureVerifyService signatureVerifyService;
|
private final SignatureVerifyService signatureVerifyService;
|
||||||
|
private final HotHiddenDangerPlanMapper planMapper;
|
||||||
|
private final HiddenDangerPlanTimeWindowHelper timeWindowHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询隐患排查-排查项目
|
* 查询隐患排查-排查项目
|
||||||
@@ -101,7 +105,6 @@ public class HotHiddenDangerInspectionServiceImpl implements IHotHiddenDangerIns
|
|||||||
driverId = driver.getId();
|
driverId = driver.getId();
|
||||||
vehicleId = driver.getVehicleId();
|
vehicleId = driver.getVehicleId();
|
||||||
}
|
}
|
||||||
String currentMonth = YearMonth.now().toString();
|
|
||||||
Page<HotHiddenDangerInspectionVo> page = pageQuery.build();
|
Page<HotHiddenDangerInspectionVo> page = pageQuery.build();
|
||||||
List<HotHiddenDangerInspectionVo> rows = baseMapper.selectMobilePlanPage(
|
List<HotHiddenDangerInspectionVo> rows = baseMapper.selectMobilePlanPage(
|
||||||
page,
|
page,
|
||||||
@@ -110,8 +113,7 @@ public class HotHiddenDangerInspectionServiceImpl implements IHotHiddenDangerIns
|
|||||||
driverId,
|
driverId,
|
||||||
vehicleId,
|
vehicleId,
|
||||||
planId,
|
planId,
|
||||||
StringUtils.trimToNull(keyword),
|
StringUtils.trimToNull(keyword)
|
||||||
currentMonth
|
|
||||||
);
|
);
|
||||||
page.setRecords(rows);
|
page.setRecords(rows);
|
||||||
fillFlowExtras(rows);
|
fillFlowExtras(rows);
|
||||||
@@ -210,8 +212,14 @@ public class HotHiddenDangerInspectionServiceImpl implements IHotHiddenDangerIns
|
|||||||
if (original == null) {
|
if (original == null) {
|
||||||
throw new ServiceException("排查记录不存在");
|
throw new ServiceException("排查记录不存在");
|
||||||
}
|
}
|
||||||
|
HotHiddenDangerPlan plan = getPlanByInspectionOrThrow(original);
|
||||||
|
Date now = new Date();
|
||||||
|
if (!timeWindowHelper.canProcess(now, plan)) {
|
||||||
|
throw new ServiceException("当前计划未处于可处理时间范围内");
|
||||||
|
}
|
||||||
HotHiddenDangerInspection update = MapstructUtils.convert(bo, HotHiddenDangerInspection.class);
|
HotHiddenDangerInspection update = MapstructUtils.convert(bo, HotHiddenDangerInspection.class);
|
||||||
validEntityBeforeSave(update);
|
validEntityBeforeSave(update);
|
||||||
|
markRecheckProcessIfNeeded(update, original, plan, now);
|
||||||
String signImgUrl = bo.getSignImgUrl();
|
String signImgUrl = bo.getSignImgUrl();
|
||||||
if (DriverLoginContextHelper.isDriverPort() && StringUtils.isNotBlank(signImgUrl)) {
|
if (DriverLoginContextHelper.isDriverPort() && StringUtils.isNotBlank(signImgUrl)) {
|
||||||
String checkerName = bo.getCheckerName();
|
String checkerName = bo.getCheckerName();
|
||||||
@@ -275,6 +283,25 @@ public class HotHiddenDangerInspectionServiceImpl implements IHotHiddenDangerIns
|
|||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 标记是否需要补查处理
|
||||||
|
*/
|
||||||
|
private void markRecheckProcessIfNeeded(HotHiddenDangerInspection update,
|
||||||
|
HotHiddenDangerInspection original,
|
||||||
|
HotHiddenDangerPlan plan,
|
||||||
|
Date now) {
|
||||||
|
if (update == null || original == null || plan == null || now == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!timeWindowHelper.isInRecheckWindow(now, plan)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Long.valueOf(1L).equals(original.getIsRecheckProcessed())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
update.setIsRecheckProcessed(1L);
|
||||||
|
update.setRecheckProcessedTime(now);
|
||||||
|
}
|
||||||
|
|
||||||
private Long parseSignatureOssId(String signImgUrl) {
|
private Long parseSignatureOssId(String signImgUrl) {
|
||||||
String first = signImgUrl.split(",")[0].trim();
|
String first = signImgUrl.split(",")[0].trim();
|
||||||
@@ -539,6 +566,22 @@ public class HotHiddenDangerInspectionServiceImpl implements IHotHiddenDangerIns
|
|||||||
vo.setTaskId(taskId);
|
vo.setTaskId(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HotHiddenDangerPlan getPlanByInspectionOrThrow(HotHiddenDangerInspection inspection) {
|
||||||
|
if (inspection == null || inspection.getPlanId() == null) {
|
||||||
|
throw new ServiceException("排查计划不存在");
|
||||||
|
}
|
||||||
|
HotHiddenDangerPlan plan = planMapper.selectOne(
|
||||||
|
Wrappers.<HotHiddenDangerPlan>lambdaQuery()
|
||||||
|
.eq(HotHiddenDangerPlan::getId, inspection.getPlanId())
|
||||||
|
.eq(HotHiddenDangerPlan::getIsDeleted, 0L)
|
||||||
|
.last("LIMIT 1")
|
||||||
|
);
|
||||||
|
if (plan == null) {
|
||||||
|
throw new ServiceException("排查计划不存在");
|
||||||
|
}
|
||||||
|
return plan;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.hotwj.platform.securityManagement.hiddenDangerPlan.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.bo.HotHiddenDangerPlanBo;
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.bo.HotHiddenDangerPlanBo;
|
||||||
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.bo.HotHiddenDangerPlanRecheckBo;
|
||||||
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.bo.HotHiddenDangerPlanRecheckCloseBo;
|
||||||
import com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.vo.HotHiddenDangerPlanVo;
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.vo.HotHiddenDangerPlanVo;
|
||||||
import com.hotwj.platform.securityManagement.hiddenDangerPlan.service.IHotHiddenDangerPlanService;
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.service.IHotHiddenDangerPlanService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -130,6 +132,39 @@ public class HotHiddenDangerPlanController extends BaseController {
|
|||||||
return toAjax(hotHiddenDangerPlanService.updateByBo(bo));
|
return toAjax(hotHiddenDangerPlanService.updateByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启补查
|
||||||
|
*/
|
||||||
|
@Log(title = "隐患排查补查", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping("/recheck/open")
|
||||||
|
@Operation(summary = "开启隐患排查补查")
|
||||||
|
public R<Void> openRecheck(@Validated @RequestBody HotHiddenDangerPlanRecheckBo bo) {
|
||||||
|
return toAjax(hotHiddenDangerPlanService.openRecheck(bo.getPlanId(), bo.getRecheckStartTime(), bo.getRecheckEndTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改补查
|
||||||
|
*/
|
||||||
|
@Log(title = "隐患排查补查", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping("/recheck/update")
|
||||||
|
@Operation(summary = "修改隐患排查补查")
|
||||||
|
public R<Void> updateRecheck(@Validated @RequestBody HotHiddenDangerPlanRecheckBo bo) {
|
||||||
|
return toAjax(hotHiddenDangerPlanService.updateRecheck(bo.getPlanId(), bo.getRecheckStartTime(), bo.getRecheckEndTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭补查
|
||||||
|
*/
|
||||||
|
@Log(title = "隐患排查补查", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping("/recheck/close")
|
||||||
|
@Operation(summary = "关闭隐患排查补查")
|
||||||
|
public R<Void> closeRecheck(@Validated @RequestBody HotHiddenDangerPlanRecheckCloseBo bo) {
|
||||||
|
return toAjax(hotHiddenDangerPlanService.closeRecheck(bo.getPlanId()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除隐患排查
|
* 删除隐患排查
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -60,6 +60,21 @@ public class HotHiddenDangerPlan extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Date endDate;
|
private Date endDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启补查:0否 1是
|
||||||
|
*/
|
||||||
|
private Long isRecheck;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查开始时间
|
||||||
|
*/
|
||||||
|
private Date recheckStartTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查结束时间
|
||||||
|
*/
|
||||||
|
private Date recheckEndTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进度 0=待处理 1=审核中 2=评估 3=治理 4=复查 5=完结
|
* 进度 0=待处理 1=审核中 2=评估 3=治理 4=复查 5=完结
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -63,6 +63,21 @@ public class HotHiddenDangerPlanBo extends BaseEntity {
|
|||||||
@NotNull(message = "结束日期不能为空", groups = {AddGroup.class, EditGroup.class})
|
@NotNull(message = "结束日期不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private Date endDate;
|
private Date endDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启补查:0否 1是
|
||||||
|
*/
|
||||||
|
private Long isRecheck;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查开始时间
|
||||||
|
*/
|
||||||
|
private Date recheckStartTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查结束时间
|
||||||
|
*/
|
||||||
|
private Date recheckEndTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进度 0=待处理 1=审核中 2=评估 3=治理 4=复查 5=完结
|
* 进度 0=待处理 1=审核中 2=评估 3=治理 4=复查 5=完结
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.bo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐患排查补查开启/修改请求对象
|
||||||
|
*
|
||||||
|
* @author shihongwei
|
||||||
|
* @date 2026-06-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class HotHiddenDangerPlanRecheckBo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划ID
|
||||||
|
*/
|
||||||
|
@NotNull(message = "计划ID不能为空")
|
||||||
|
private Long planId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查开始时间
|
||||||
|
*/
|
||||||
|
@NotNull(message = "补查开始时间不能为空")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date recheckStartTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查结束时间
|
||||||
|
*/
|
||||||
|
@NotNull(message = "补查结束时间不能为空")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date recheckEndTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.bo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐患排查补查关闭请求对象
|
||||||
|
*
|
||||||
|
* @author shihongwei
|
||||||
|
* @date 2026-06-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class HotHiddenDangerPlanRecheckCloseBo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划ID
|
||||||
|
*/
|
||||||
|
@NotNull(message = "计划ID不能为空")
|
||||||
|
private Long planId;
|
||||||
|
}
|
||||||
@@ -67,6 +67,24 @@ public class HotHiddenDangerPlanVo implements Serializable {
|
|||||||
@ExcelProperty(value = "结束日期")
|
@ExcelProperty(value = "结束日期")
|
||||||
private Date endDate;
|
private Date endDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启补查:0否 1是
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "是否开启补查")
|
||||||
|
private Long isRecheck;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查开始时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "补查开始时间")
|
||||||
|
private Date recheckStartTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补查结束时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "补查结束时间")
|
||||||
|
private Date recheckEndTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进度 0=待处理 1=审核中 2=评估 3=治理 4=复查 5=完结
|
* 进度 0=待处理 1=审核中 2=评估 3=治理 4=复查 5=完结
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.hotwj.platform.securityManagement.hiddenDangerPlan.service;
|
||||||
|
|
||||||
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.domain.HotHiddenDangerPlan;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐患排查计划时间窗口判定
|
||||||
|
*
|
||||||
|
* @author shihongwei
|
||||||
|
* @date 2026-06-03
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class HiddenDangerPlanTimeWindowHelper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否在原始时间窗口内
|
||||||
|
*/
|
||||||
|
public boolean isInOriginalWindow(Date now, HotHiddenDangerPlan plan) {
|
||||||
|
if (now == null || plan == null || plan.getStartDate() == null || plan.getEndDate() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !now.before(plan.getStartDate()) && !now.after(plan.getEndDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否在补查时间窗口内
|
||||||
|
*/
|
||||||
|
public boolean isInRecheckWindow(Date now, HotHiddenDangerPlan plan) {
|
||||||
|
if (now == null || plan == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Long.valueOf(1L).equals(plan.getIsRecheck())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (plan.getRecheckStartTime() == null || plan.getRecheckEndTime() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !now.before(plan.getRecheckStartTime()) && !now.after(plan.getRecheckEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否在有效时间窗口内
|
||||||
|
*/
|
||||||
|
public boolean isInEffectiveWindow(Date now, HotHiddenDangerPlan plan) {
|
||||||
|
return isInOriginalWindow(now, plan) || isInRecheckWindow(now, plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否可以在有效时间窗口内处理
|
||||||
|
*/
|
||||||
|
public boolean canProcess(Date now, HotHiddenDangerPlan plan) {
|
||||||
|
return isInEffectiveWindow(now, plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否应该在司机端展示
|
||||||
|
*/
|
||||||
|
public boolean shouldDisplayToDriver(Date now, HotHiddenDangerPlan plan) {
|
||||||
|
return isInEffectiveWindow(now, plan);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,6 +69,34 @@ public interface IHotHiddenDangerPlanService {
|
|||||||
*/
|
*/
|
||||||
void generatePlan(Long companyId);
|
void generatePlan(Long companyId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启补查
|
||||||
|
*
|
||||||
|
* @param planId 计划ID
|
||||||
|
* @param recheckStartTime 补查开始时间
|
||||||
|
* @param recheckEndTime 补查结束时间
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
Boolean openRecheck(Long planId, java.util.Date recheckStartTime, java.util.Date recheckEndTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改补查
|
||||||
|
*
|
||||||
|
* @param planId 计划ID
|
||||||
|
* @param recheckStartTime 补查开始时间
|
||||||
|
* @param recheckEndTime 补查结束时间
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
Boolean updateRecheck(Long planId, java.util.Date recheckStartTime, java.util.Date recheckEndTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭补查
|
||||||
|
*
|
||||||
|
* @param planId 计划ID
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
Boolean closeRecheck(Long planId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验并批量删除隐患排查信息
|
* 校验并批量删除隐患排查信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.hotwj.platform.config.hiddenDangerCheckConfig.service.IHotHiddenDange
|
|||||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverBo;
|
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverBo;
|
||||||
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverVo;
|
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverVo;
|
||||||
import com.hotwj.platform.driverManagement.driver.service.IHotDriverService;
|
import com.hotwj.platform.driverManagement.driver.service.IHotDriverService;
|
||||||
|
import com.hotwj.platform.common.helper.DriverLoginContextHelper;
|
||||||
import com.hotwj.platform.noticeManagerment.systemNotification.domain.bo.HotSystemNotificationGroupBo;
|
import com.hotwj.platform.noticeManagerment.systemNotification.domain.bo.HotSystemNotificationGroupBo;
|
||||||
import com.hotwj.platform.noticeManagerment.systemNotification.service.IHotSystemNotificationService;
|
import com.hotwj.platform.noticeManagerment.systemNotification.service.IHotSystemNotificationService;
|
||||||
import com.hotwj.platform.resourceManagement.company.domain.vo.SysCompanyVo;
|
import com.hotwj.platform.resourceManagement.company.domain.vo.SysCompanyVo;
|
||||||
@@ -33,6 +34,7 @@ import com.hotwj.platform.securityManagement.hiddenDangerPlan.mapper.HotHiddenDa
|
|||||||
import com.hotwj.platform.securityManagement.hiddenDangerPlan.service.IHotHiddenDangerPlanService;
|
import com.hotwj.platform.securityManagement.hiddenDangerPlan.service.IHotHiddenDangerPlanService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
@@ -43,6 +45,7 @@ import java.time.LocalDate;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.IsoFields;
|
import java.time.temporal.IsoFields;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -183,6 +186,45 @@ public class HotHiddenDangerPlanServiceImpl implements IHotHiddenDangerPlanServi
|
|||||||
processCompanyPlan(companyConfig, checkConfigsMap);
|
processCompanyPlan(companyConfig, checkConfigsMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean openRecheck(Long planId, Date recheckStartTime, Date recheckEndTime) {
|
||||||
|
HotHiddenDangerPlan plan = getPlanOrThrow(planId);
|
||||||
|
validateRecheckTime(recheckStartTime, recheckEndTime);
|
||||||
|
return baseMapper.update(
|
||||||
|
null,
|
||||||
|
Wrappers.<HotHiddenDangerPlan>lambdaUpdate()
|
||||||
|
.eq(HotHiddenDangerPlan::getId, plan.getId())
|
||||||
|
.set(HotHiddenDangerPlan::getIsRecheck, 1L)
|
||||||
|
.set(HotHiddenDangerPlan::getRecheckStartTime, recheckStartTime)
|
||||||
|
.set(HotHiddenDangerPlan::getRecheckEndTime, recheckEndTime)
|
||||||
|
) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateRecheck(Long planId, Date recheckStartTime, Date recheckEndTime) {
|
||||||
|
HotHiddenDangerPlan plan = getPlanOrThrow(planId);
|
||||||
|
validateRecheckTime(recheckStartTime, recheckEndTime);
|
||||||
|
return baseMapper.update(
|
||||||
|
null,
|
||||||
|
Wrappers.<HotHiddenDangerPlan>lambdaUpdate()
|
||||||
|
.eq(HotHiddenDangerPlan::getId, plan.getId())
|
||||||
|
.set(HotHiddenDangerPlan::getIsRecheck, 1L)
|
||||||
|
.set(HotHiddenDangerPlan::getRecheckStartTime, recheckStartTime)
|
||||||
|
.set(HotHiddenDangerPlan::getRecheckEndTime, recheckEndTime)
|
||||||
|
) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean closeRecheck(Long planId) {
|
||||||
|
HotHiddenDangerPlan plan = getPlanOrThrow(planId);
|
||||||
|
return baseMapper.update(
|
||||||
|
null,
|
||||||
|
Wrappers.<HotHiddenDangerPlan>lambdaUpdate()
|
||||||
|
.eq(HotHiddenDangerPlan::getId, plan.getId())
|
||||||
|
.set(HotHiddenDangerPlan::getIsRecheck, 0L)
|
||||||
|
) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理单个公司的排查计划
|
* 处理单个公司的排查计划
|
||||||
*/
|
*/
|
||||||
@@ -511,7 +553,6 @@ public class HotHiddenDangerPlanServiceImpl implements IHotHiddenDangerPlanServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<HotHiddenDangerPlan> buildQueryWrapper(HotHiddenDangerPlanBo bo) {
|
private LambdaQueryWrapper<HotHiddenDangerPlan> buildQueryWrapper(HotHiddenDangerPlanBo bo) {
|
||||||
Map<String, Object> params = bo.getParams();
|
|
||||||
LambdaQueryWrapper<HotHiddenDangerPlan> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<HotHiddenDangerPlan> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.orderByDesc(HotHiddenDangerPlan::getCreateTime);
|
lqw.orderByDesc(HotHiddenDangerPlan::getCreateTime);
|
||||||
lqw.eq(bo.getCompanyId() != null, HotHiddenDangerPlan::getCompanyId, bo.getCompanyId());
|
lqw.eq(bo.getCompanyId() != null, HotHiddenDangerPlan::getCompanyId, bo.getCompanyId());
|
||||||
@@ -519,11 +560,32 @@ public class HotHiddenDangerPlanServiceImpl implements IHotHiddenDangerPlanServi
|
|||||||
lqw.like(StringUtils.isNotBlank(bo.getPlanName()), HotHiddenDangerPlan::getPlanName, bo.getPlanName());
|
lqw.like(StringUtils.isNotBlank(bo.getPlanName()), HotHiddenDangerPlan::getPlanName, bo.getPlanName());
|
||||||
lqw.eq(bo.getStartDate() != null, HotHiddenDangerPlan::getStartDate, bo.getStartDate());
|
lqw.eq(bo.getStartDate() != null, HotHiddenDangerPlan::getStartDate, bo.getStartDate());
|
||||||
lqw.eq(bo.getEndDate() != null, HotHiddenDangerPlan::getEndDate, bo.getEndDate());
|
lqw.eq(bo.getEndDate() != null, HotHiddenDangerPlan::getEndDate, bo.getEndDate());
|
||||||
|
lqw.eq(bo.getIsRecheck() != null, HotHiddenDangerPlan::getIsRecheck, bo.getIsRecheck());
|
||||||
lqw.eq(bo.getProgress() != null, HotHiddenDangerPlan::getProgress, bo.getProgress());
|
lqw.eq(bo.getProgress() != null, HotHiddenDangerPlan::getProgress, bo.getProgress());
|
||||||
lqw.eq(bo.getIsDeleted() != null, HotHiddenDangerPlan::getIsDeleted, bo.getIsDeleted());
|
lqw.eq(bo.getIsDeleted() != null, HotHiddenDangerPlan::getIsDeleted, bo.getIsDeleted());
|
||||||
|
if (shouldLimitToEffectiveWindow()) {
|
||||||
|
Date now = new Date();
|
||||||
|
lqw.and(wrapper -> wrapper
|
||||||
|
.and(original -> original
|
||||||
|
.le(HotHiddenDangerPlan::getStartDate, now)
|
||||||
|
.ge(HotHiddenDangerPlan::getEndDate, now))
|
||||||
|
.or(recheck -> recheck
|
||||||
|
.eq(HotHiddenDangerPlan::getIsRecheck, 1L)
|
||||||
|
.le(HotHiddenDangerPlan::getRecheckStartTime, now)
|
||||||
|
.ge(HotHiddenDangerPlan::getRecheckEndTime, now))
|
||||||
|
);
|
||||||
|
}
|
||||||
return lqw;
|
return lqw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldLimitToEffectiveWindow() {
|
||||||
|
try {
|
||||||
|
return DriverLoginContextHelper.isDriverPort();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增隐患排查
|
* 新增隐患排查
|
||||||
*
|
*
|
||||||
@@ -626,6 +688,34 @@ public class HotHiddenDangerPlanServiceImpl implements IHotHiddenDangerPlanServi
|
|||||||
//TODO 做一些数据校验,如唯一约束
|
//TODO 做一些数据校验,如唯一约束
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HotHiddenDangerPlan getPlanOrThrow(Long planId) {
|
||||||
|
if (planId == null) {
|
||||||
|
throw new ServiceException("计划ID不能为空");
|
||||||
|
}
|
||||||
|
HotHiddenDangerPlan plan = baseMapper.selectOne(
|
||||||
|
Wrappers.<HotHiddenDangerPlan>lambdaQuery()
|
||||||
|
.eq(HotHiddenDangerPlan::getId, planId)
|
||||||
|
.eq(HotHiddenDangerPlan::getIsDeleted, 0L)
|
||||||
|
.last("LIMIT 1")
|
||||||
|
);
|
||||||
|
if (plan == null) {
|
||||||
|
throw new ServiceException("排查计划不存在");
|
||||||
|
}
|
||||||
|
return plan;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateRecheckTime(Date recheckStartTime, Date recheckEndTime) {
|
||||||
|
if (recheckStartTime == null) {
|
||||||
|
throw new ServiceException("补查开始时间不能为空");
|
||||||
|
}
|
||||||
|
if (recheckEndTime == null) {
|
||||||
|
throw new ServiceException("补查结束时间不能为空");
|
||||||
|
}
|
||||||
|
if (!recheckEndTime.after(recheckStartTime)) {
|
||||||
|
throw new ServiceException("补查结束时间必须晚于补查开始时间");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验并批量删除隐患排查信息
|
* 校验并批量删除隐患排查信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7,77 +7,80 @@
|
|||||||
<!-- status: 进度状态 无异常:1=特处理、2=审核中、3=完结 有异常:4=特处理、5=审核中、6=评估、7=治理、8=复查、9=完结-->
|
<!-- status: 进度状态 无异常:1=特处理、2=审核中、3=完结 有异常:4=特处理、5=审核中、6=评估、7=治理、8=复查、9=完结-->
|
||||||
<select id="selectMobilePlanPage"
|
<select id="selectMobilePlanPage"
|
||||||
resultType="com.hotwj.platform.securityManagement.hiddenDangerInspection.domain.vo.HotHiddenDangerInspectionVo">
|
resultType="com.hotwj.platform.securityManagement.hiddenDangerInspection.domain.vo.HotHiddenDangerInspectionVo">
|
||||||
SELECT * FROM (
|
|
||||||
SELECT
|
SELECT
|
||||||
i.*,
|
p.id AS id,
|
||||||
p.plan_name AS planName,
|
p.company_id AS companyId,
|
||||||
p.start_date AS planStartDate,
|
p.id AS planId,
|
||||||
p.end_date AS planEndDate,
|
p.inspect_name AS projectName,
|
||||||
CASE
|
p.plan_name AS planName,
|
||||||
WHEN (i.status IS NULL OR i.status = 1 OR i.status = 2) THEN 1
|
p.start_date AS planStartDate,
|
||||||
ELSE 3
|
p.end_date AS planEndDate,
|
||||||
END AS todoSortGroup,
|
CASE
|
||||||
CASE
|
WHEN SUM(CASE WHEN i.status IS NULL OR i.status = 1 OR i.status = 2 THEN 1 ELSE 0 END) > 0 THEN 1
|
||||||
WHEN (i.status IS NULL OR i.status = 1 OR i.status = 2) THEN '当月未做'
|
ELSE 3
|
||||||
ELSE '已完成'
|
END AS status,
|
||||||
END AS todoSortLabel
|
CASE
|
||||||
FROM hot_hidden_danger_inspection i
|
WHEN SUM(CASE WHEN i.status IS NULL OR i.status = 1 OR i.status = 2 THEN 1 ELSE 0 END) > 0 THEN 1
|
||||||
LEFT JOIN hot_hidden_danger_plan p
|
ELSE 2
|
||||||
ON p.id = i.plan_id
|
END AS todoSortGroup,
|
||||||
AND p.is_deleted = 0
|
CASE
|
||||||
WHERE i.is_deleted = 0
|
WHEN SUM(CASE WHEN i.status IS NULL OR i.status = 1 OR i.status = 2 THEN 1 ELSE 0 END) > 0 THEN '未做'
|
||||||
AND i.company_id = #{companyId}
|
ELSE '已完成'
|
||||||
AND DATE_FORMAT(COALESCE(p.start_date, i.create_time), '%Y-%m') = #{currentMonth}
|
END AS todoSortLabel
|
||||||
<if test="planId != null">
|
FROM hot_hidden_danger_plan p
|
||||||
AND i.plan_id = #{planId}
|
LEFT JOIN hot_hidden_danger_inspection i
|
||||||
</if>
|
ON i.plan_id = p.id
|
||||||
<if test="isAdmin == false">
|
AND i.is_deleted = 0
|
||||||
AND (
|
<if test="isAdmin == false">
|
||||||
(i.project_type = 3 AND i.project_id = #{driverId})
|
AND (
|
||||||
<if test="vehicleId != null and vehicleId != ''">
|
(i.project_type = 3 AND i.project_id = #{driverId})
|
||||||
OR (i.project_type = 2 AND i.project_id = #{vehicleId})
|
<if test="vehicleId != null and vehicleId != ''">
|
||||||
|
OR (i.project_type = 2 AND i.project_id = #{vehicleId})
|
||||||
|
</if>
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
|
WHERE p.is_deleted = 0
|
||||||
|
AND p.company_id = #{companyId}
|
||||||
|
AND (
|
||||||
|
(NOW() BETWEEN p.start_date AND p.end_date)
|
||||||
|
OR (
|
||||||
|
p.is_recheck = 1
|
||||||
|
AND NOW() BETWEEN p.recheck_start_time AND p.recheck_end_time
|
||||||
|
)
|
||||||
|
)
|
||||||
|
<if test="planId != null">
|
||||||
|
AND p.id = #{planId}
|
||||||
|
</if>
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM hot_hidden_danger_inspection i2
|
||||||
|
WHERE i2.plan_id = p.id
|
||||||
|
AND i2.is_deleted = 0
|
||||||
|
<if test="isAdmin == false">
|
||||||
|
AND (
|
||||||
|
(i2.project_type = 3 AND i2.project_id = #{driverId})
|
||||||
|
<if test="vehicleId != null and vehicleId != ''">
|
||||||
|
OR (i2.project_type = 2 AND i2.project_id = #{vehicleId})
|
||||||
|
</if>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
)
|
||||||
|
<if test="keyword != null and keyword != ''">
|
||||||
|
AND (
|
||||||
|
p.plan_name LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
OR p.inspect_name LIKE CONCAT('%', #{keyword}, '%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="keyword != null and keyword != ''">
|
GROUP BY
|
||||||
AND i.project_name LIKE CONCAT('%', #{keyword}, '%')
|
p.id,
|
||||||
</if>
|
p.company_id,
|
||||||
|
p.inspect_name,
|
||||||
UNION ALL
|
p.plan_name,
|
||||||
|
p.start_date,
|
||||||
SELECT
|
p.end_date
|
||||||
i.*,
|
|
||||||
p.plan_name AS planName,
|
|
||||||
p.start_date AS planStartDate,
|
|
||||||
p.end_date AS planEndDate,
|
|
||||||
2 AS todoSortGroup,
|
|
||||||
'未做' AS todoSortLabel
|
|
||||||
FROM hot_hidden_danger_inspection i
|
|
||||||
LEFT JOIN hot_hidden_danger_plan p
|
|
||||||
ON p.id = i.plan_id
|
|
||||||
AND p.is_deleted = 0
|
|
||||||
WHERE i.is_deleted = 0
|
|
||||||
AND i.company_id = #{companyId}
|
|
||||||
AND DATE_FORMAT(COALESCE(p.start_date, i.create_time), '%Y-%m') != #{currentMonth}
|
|
||||||
AND (i.status IS NULL OR i.status = 1 OR i.status = 2)
|
|
||||||
<if test="planId != null">
|
|
||||||
AND i.plan_id = #{planId}
|
|
||||||
</if>
|
|
||||||
<if test="isAdmin == false">
|
|
||||||
AND (
|
|
||||||
(i.project_type = 3 AND i.project_id = #{driverId})
|
|
||||||
<if test="vehicleId != null and vehicleId != ''">
|
|
||||||
OR (i.project_type = 2 AND i.project_id = #{vehicleId})
|
|
||||||
</if>
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<if test="keyword != null and keyword != ''">
|
|
||||||
AND i.project_name LIKE CONCAT('%', #{keyword}, '%')
|
|
||||||
</if>
|
|
||||||
) t
|
|
||||||
ORDER BY
|
ORDER BY
|
||||||
t.todoSortGroup ASC,
|
todoSortGroup ASC,
|
||||||
COALESCE(t.planEndDate, t.planStartDate, t.create_time) ASC,
|
COALESCE(p.end_date, p.start_date, MAX(i.create_time)) ASC,
|
||||||
t.id DESC
|
p.id DESC
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
p.plan_name,
|
p.plan_name,
|
||||||
p.start_date,
|
p.start_date,
|
||||||
p.end_date,
|
p.end_date,
|
||||||
|
p.is_recheck,
|
||||||
|
p.recheck_start_time,
|
||||||
|
p.recheck_end_time,
|
||||||
p.progress,
|
p.progress,
|
||||||
p.remark,
|
p.remark,
|
||||||
p.is_deleted,
|
p.is_deleted,
|
||||||
|
|||||||
Reference in New Issue
Block a user