Commit ad7f2c82 authored by 鲁鸿波's avatar 鲁鸿波

所有作业3天未完成的,需要重新发起申请。

危险作业到交底环节后按固定时间判断是否超时,超时自动取消
parent 3954a3b7
......@@ -436,4 +436,63 @@ COMMENT ON COLUMN t_train_examination_manage_retake.pass_score IS '及格分数'
ALTER TABLE t_hazard_disclosure ADD guardian_signature varchar(255) NULL;
COMMENT ON COLUMN t_hazard_disclosure.guardian_signature IS '监护人签字';
\ No newline at end of file
COMMENT ON COLUMN t_hazard_disclosure.guardian_signature IS '监护人签字';
#20251205上线需求
ALTER TABLE t_hazard_work_plan ADD hazard_license_pass_time datetime;
COMMENT ON COLUMN t_hazard_work_plan.hazard_license_pass_time IS '安全许可证通过时间';
ALTER TABLE t_hazard_work_plan ADD is_fully_invested varchar(50);
COMMENT ON COLUMN t_hazard_work_plan.is_fully_invested IS '是否满仓(1:是,2:否)';
ALTER TABLE t_hazard_work_plan ADD is_full varchar(50);
COMMENT ON COLUMN t_hazard_work_plan.is_full IS '是否7~9人(1:是,2:否)';
INSERT INTO "t_sys_dict_type" ("dict_id", "dict_name", "dict_type", "is_sys", "status", "create_by", "create_date", "update_by", "update_date", "remarks", "parent_id", "parent_ids", "tree_sort", "cascaded") VALUES ('1', '危险作业超时检测是否可以执行', 'plan_expired', '1', '0', NULL, '2025-11-28 15:30:11', NULL, '2025-11-28 15:30:11', NULL, NULL, NULL, NULL, '0');
INSERT INTO t_sys_dict_data" ("dict_data_id", "dict_id", "dict_key", "dict_value", "tree_sort", "status", "create_by", "create_date", "update_by", "update_date", "remarks", "parent_id", "parent_ids") VALUES ('4', '1', '1', '可以执行', '0', '0', NULL, '2025-11-28 15:31:44', NULL, '2025-11-28 15:31:44', NULL, '0', '0,');
添加表t_hazard_work_plan_expired_log
-- public.t_hazard_work_plan_expired_log definition
-- Drop table
-- DROP TABLE public.t_hazard_work_plan_expired_log;
CREATE TABLE public.t_hazard_work_plan_expired_log (
id varchar(64) NOT NULL,
plan_id varchar(64) NULL, -- 作业id
code varchar(30) NULL, -- 作业编码
work_type varchar(50) NULL, -- 作业类型
danger_level varchar(50) NULL, -- 作业级别
expired_reason varchar(200) NULL, -- 超时原因(三天内未完成,安全许可申请审批通过后未在规定时间内完成)
before_expiration varchar(100) NULL, -- 关闭前状态
hazard_license_pass_time sys."datetime" NULL, -- 安全许可申请通过时间
actual_duration_hours numeric(10, 2) NULL, -- 实际持续小时数
plan_create_date sys."timestamp" NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 作业创建时间
status varchar(1) NULL DEFAULT '0'::varchar,
create_by varchar(64) NULL,
create_date "timestamp" NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_by varchar(64) NULL,
update_date "timestamp" NOT NULL DEFAULT CURRENT_TIMESTAMP,
remarks varchar(100) NULL
);
COMMENT ON TABLE public.t_hazard_work_plan_expired_log IS '危险作业-超时自动关闭记录表';
-- Column comments
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.plan_id IS '作业id';
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.code IS '作业编码';
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.work_type IS '作业类型';
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.danger_level IS '作业级别';
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.expired_reason IS '超时原因(三天内未完成,安全许可申请审批通过后未在规定时间内完成)';
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.before_expiration IS '关闭前状态';
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.hazard_license_pass_time IS '安全许可申请通过时间';
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.actual_duration_hours IS '实际持续小时数';
COMMENT ON COLUMN public.t_hazard_work_plan_expired_log.plan_create_date IS '作业创建时间';
package com.testor.common.util;
import com.testor.module.hazard.model.domain.THazardWorkPlan;
import java.util.HashMap;
import java.util.Map;
......@@ -14,7 +16,8 @@ public class DangerousOperationValidator {
IN_WAREHOUSE("进仓作业"),
OUT_WAREHOUSE("出仓作业"),
FLAG_WAREHOUSE("平仓作业"),
IN_OUT_WAREHOUSE("进出仓作业");
IN_OUT_WAREHOUSE("进出仓作业"),
CIRCULATION_FUMIGATION("环流熏蒸作业");
private final String name;
OperationType(String name) {
......@@ -93,6 +96,12 @@ public class DangerousOperationValidator {
// 其他等级不设置限制
TIME_LIMITS.put(OperationType.FUMIGATION, fumigationMap);
// 环流熏蒸
Map<DangerLevel, Integer> circulationFumigationMap = new HashMap<>();
circulationFumigationMap.put(DangerLevel.HIGH, 7 * 24);
// 其他等级不设置限制
TIME_LIMITS.put(OperationType.CIRCULATION_FUMIGATION, circulationFumigationMap);
// 进仓
Map<DangerLevel, Integer> inWarehouseMap = new HashMap<>();
inWarehouseMap.put(DangerLevel.HIGH, 12);
......@@ -122,7 +131,7 @@ public class DangerousOperationValidator {
TIME_LIMITS.put(OperationType.IN_OUT_WAREHOUSE, inOutWarehouseMap);
}
public static String validateOperation(String workTypeDictValue, String workLevelDictValue, double actualHours) {
public static String validateOperation(String workTypeDictValue, String workLevelDictValue, double actualHours, THazardWorkPlan plan) {
// 转换为枚举类型
OperationType type = OperationType.fromDictValue(workTypeDictValue);
DangerLevel level = DangerLevel.fromDictValue(workLevelDictValue);
......@@ -138,8 +147,8 @@ public class DangerousOperationValidator {
return "在安全时间内";
}
// 获取具体等级的时间限制
Integer timeLimit = levelMap.get(level);
// 特殊处理:进出仓、进仓、出仓作业的较大危险级别
Integer timeLimit = getAdjustedTimeLimit(type, level, plan);
// 如果没有找到该等级的限制,返回安全
if (timeLimit == null) {
......@@ -156,4 +165,59 @@ public class DangerousOperationValidator {
return "在安全时间内";
}
/**
* 获取调整后的时间限制(处理特殊情况)
*/
private static Integer getAdjustedTimeLimit(OperationType type, DangerLevel level, THazardWorkPlan plan) {
// 获取默认的时间限制
Map<DangerLevel, Integer> levelMap = TIME_LIMITS.get(type);
if (levelMap == null) {
return null;
}
Integer timeLimit = levelMap.get(level);
if (timeLimit == null) {
return null;
}
//如果是非北良的熏蒸作业高度为1小时,如果是北良的为7天
if (level == DangerLevel.HIGH){
}
// 特殊规则:进出仓、进仓、出仓作业的较大危险级别
if (level == DangerLevel.MEDIUM &&
(type == OperationType.IN_OUT_WAREHOUSE ||
type == OperationType.IN_WAREHOUSE ||
type == OperationType.OUT_WAREHOUSE ||
type == OperationType.FLAG_WAREHOUSE)) {
// 检查是否满足特殊条件:isFullyInvested为1或者isFull为1
boolean isSpecialCondition = isSpecialConditionMet(plan);
if (isSpecialCondition) {
// 满足条件:时间限制为24小时
timeLimit = 24;
} else {
// 不满足条件:时间限制为72小时
timeLimit = 72;
}
}
return timeLimit;
}
/**
* 检查是否满足特殊条件:isFullyInvested为1或者isFull为1
*/
private static boolean isSpecialConditionMet(THazardWorkPlan plan) {
if (plan == null) {
return false;
}
String isEscalated = plan.getIsEscalated();
String isFull = plan.getIsFull();
return "1".equals(isEscalated) || "1".equals(isFull);
}
}
\ No newline at end of file
......@@ -306,7 +306,7 @@ public class THazardWorkPlanController extends SuperController
}
}
@ApiOperation(value = "危险作业计划时间是否合规", notes = "危险作业计划时间是否合规")
/*@ApiOperation(value = "危险作业计划时间是否合规", notes = "危险作业计划时间是否合规")
@GetMapping(value = "/validateOperation")
public BaseResponse validateOperation(String workType, String workLevel, String scheduledStartTime,String scheduledEndTime) throws BusinessException {
BaseResponse<BizGeneralResponse> baseResponse = new BaseResponse<>();
......@@ -314,7 +314,7 @@ public class THazardWorkPlanController extends SuperController
baseResponse.setMsg(result);
return baseResponse;
}
}*/
@ApiOperation(value = "任务转签", notes = "任务转签")
@GetMapping(value = "/transferTask")
......
package com.testor.module.hazard.controller;
import com.testor.module.hazard.model.domain.THazardWorkPlan;
import com.testor.module.hazard.model.domain.THazardWorkPlanExpiredLog;
import com.testor.module.hazard.service.THazardWorkPlanExpiredLogService;
import com.tongtech.tfw.backend.common.biz.models.BaseResponse;
import com.tongtech.tfw.backend.core.helper.ObjectHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/hazard/expiredLog")
@Api(value = "THazardWorkPlanExpiredLog", tags = "危险作业计划过期日志")
@Slf4j
public class THazardWorkPlanExpiredLogController {
@Autowired
private THazardWorkPlanExpiredLogService hazardWorkPlanExpiredLogService;
@ApiOperation(value = "危险作业计划自动过期", notes = "危险作业计划自动过期")
@GetMapping(value = "/refreshSwitch")
public BaseResponse refreshSwitch() {
BaseResponse baseResponse=new BaseResponse<>();
hazardWorkPlanExpiredLogService.refreshSwitch();
baseResponse.setData(true);
baseResponse.setMsg("操作成功");
return baseResponse;
}
@ApiOperation(value = "危险作业三天内未完成自动过期", notes = "危险作业三天内未完成自动过期")
@GetMapping(value = "/refreshSwitch1")
public BaseResponse refreshSwitch1() {
BaseResponse baseResponse=new BaseResponse<>();
hazardWorkPlanExpiredLogService.refreshSwitch1();
baseResponse.setData(true);
baseResponse.setMsg("操作成功");
return baseResponse;
}
@ApiOperation(value = "根据计划id查询过期日志", notes = "根据计划id查询过期日志")
@GetMapping(value = "/selectByPlanId")
public BaseResponse<THazardWorkPlanExpiredLog> selectByPlanId(@RequestParam String planId) {
BaseResponse<THazardWorkPlanExpiredLog> baseResponse=new BaseResponse<>();
THazardWorkPlanExpiredLog hazardWorkPlanExpiredLog= hazardWorkPlanExpiredLogService.selectByPlanId(planId);
baseResponse.setData(hazardWorkPlanExpiredLog);
return baseResponse;
}
}
......@@ -10,6 +10,8 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
/**
* 危险作业计划Mapper接口
*
......@@ -29,4 +31,17 @@ public interface THazardWorkPlanDao extends SuperDao<THazardWorkPlan>
@Select("SELECT * FROM t_hazard_work_plan WHERE code = #{code} and status = 0")
THazardWorkPlan selectByCode(@Param("code") String code);
/**
* 查询所有危险作业已安全许可申请审批通过后未完成的作业
* @return
*/
List<THazardWorkPlan> selectHazardLicensePassTime();
/**
* 查询所有危险作业未完成的作业
* @return
*/
List<THazardWorkPlan> selectNotCompleteList();
}
package com.testor.module.hazard.dao;
import com.testor.module.hazard.model.domain.THazardWorkPlan;
import com.tongtech.tfw.backend.common.models.supers.SuperDao;
import com.testor.module.hazard.model.domain.THazardWorkPlanExpiredLog;
public interface THazardWorkPlanExpiredLogDao extends SuperDao<THazardWorkPlanExpiredLog>{
}
......@@ -309,6 +309,24 @@ public class THazardWorkPlan extends SuperModel
@TableField("guardian_signature")
private String guardianSignature;
@ApiModelProperty(value = "安全许可证通过时间")
@TableField("hazard_license_pass_time")
private Date hazardLicensePassTime;
/**
* 是否满仓(1:是,2:否)
*/
@ApiModelProperty(value = "是否满仓(1:是,2:否)")
@TableField("is_fully_invested")
private String isFullyInvested;
/**
* 是否7~9人(1:是,2:否)
*/
@ApiModelProperty(value = "是否7~9人(1:是,2:否)")
@TableField("is_full")
private String isFull;
@ApiModelProperty(value = "当前流程环节")
@TableField(exist = false)
private String currentTaskName;
......
package com.testor.module.hazard.model.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tongtech.tfw.backend.common.models.supers.SuperModel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* 危险作业-超时自动关闭记录表对象 t_hazard_work_plan_expired_log
*
* @author testor-framework
* @date 2025-01-XX
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_hazard_work_plan_expired_log")
@ApiModel(value = "THazardWorkPlanExpiredLog对象", description = "危险作业-超时自动关闭记录表")
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class THazardWorkPlanExpiredLog extends SuperModel
{
private static final long serialVersionUID = 1L;
/** id */
@ApiModelProperty(value = "id")
@TableId("id")
private String id;
/** 作业id */
@ApiModelProperty(value = "作业id")
@TableField("plan_id")
private String planId;
/** 作业编码 */
@ApiModelProperty(value = "作业编码")
@TableField("code")
private String code;
/** 作业类型 */
@ApiModelProperty(value = "作业类型")
@TableField("work_type")
private String workType;
/** 危险等级 */
@ApiModelProperty(value = "危险等级")
@TableField("danger_level")
private String dangerLevel;
/** 超时原因 */
@ApiModelProperty(value = "超时原因")
@TableField("expired_reason")
private String expiredReason;
/** 关闭前状态 */
@ApiModelProperty(value = "关闭前状态")
@TableField("before_expiration")
private String beforeExpiration;
/** 安全许可申请通过时间 */
@ApiModelProperty(value = "安全许可申请通过时间")
@TableField("hazard_license_pass_time")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date hazardLicensePassTime;
/** 实际持续小时数 */
@ApiModelProperty(value = "实际持续小时数")
@TableField("actual_duration_hours")
private BigDecimal actualDurationHours;
/** 作业创建时间 */
@ApiModelProperty(value = "作业创建时间")
@TableField("plan_create_date")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date planCreateDate;
// 常量定义
public static final String ID = "id";
public static final String PLAN_ID = "plan_id";
public static final String CODE = "code";
public static final String WORK_TYPE = "work_type";
public static final String DANGER_LEVEL = "danger_level";
public static final String EXPIRED_REASON = "expired_reason";
public static final String BEFORE_EXPIRATION = "before_expiration";
public static final String HAZARD_LICENSE_PASS_TIME = "hazard_license_pass_time";
public static final String ACTUAL_DURATION_HOURS = "actual_duration_hours";
public static final String PLAN_CREATE_DATE = "plan_create_date";
}
\ No newline at end of file
......@@ -62,7 +62,9 @@ public enum WorkPlanStatusEnum {
IN_PROGRESS("10", "进行中"),
TO_BE_CLOSED("11", "待安全许可证关闭");
TO_BE_CLOSED("11", "待安全许可证关闭"),
TIMEOUT_CANCELED("12", "已超时自动取消");
private final String value; // 状态值
private final String description; // 状态描述
......
package com.testor.module.hazard.service;
import com.testor.module.hazard.model.domain.THazardWorkPlan;
import com.testor.module.hazard.model.domain.THazardWorkPlanExpiredLog;
import com.tongtech.tfw.backend.common.models.supers.SuperService;
public interface THazardWorkPlanExpiredLogService extends SuperService<THazardWorkPlanExpiredLog> {
/**
* 危险作业计划自动过期
*/
public void refreshSwitch();
/**
* 危险作业三天内未完成自动过期
*/
public void refreshSwitch1();
/**
* 根据计划id查询过期日志
* @param planId
* @return
*/
public THazardWorkPlanExpiredLog selectByPlanId(String planId);
}
......@@ -100,7 +100,7 @@ public interface THazardWorkPlanService extends SuperService<THazardWorkPlan> {
* @param scheduledEndTime 计划结束时间
* @return
*/
String validateOperation(String workType, String workLevel, String scheduledStartTime,String scheduledEndTime);
//String validateOperation(String workType, String workLevel, String scheduledStartTime,String scheduledEndTime);
/**
* 任务转签
......
......@@ -627,6 +627,7 @@ public class THazardWorkPlanServiceImpl extends SuperServiceImpl<THazardWorkPlan
THazardWorkPlan updWorkPlan = new THazardWorkPlan();
updWorkPlan.setId(id);
updWorkPlan.setHazardLicensePassTime(new Date());
this.updateById(updWorkPlan);
}
......@@ -885,9 +886,9 @@ public class THazardWorkPlanServiceImpl extends SuperServiceImpl<THazardWorkPlan
return null;
}
@Override
/*@Override
public String validateOperation(String workType, String workLevel, String scheduledStartTime, String scheduledEndTime) {
/*中粮/北良规则如下
*//*中粮/北良规则如下
动火作业高度危险: 8小时内
动火作业较大危险: 12小时内
动火作业一般危险: 72小时内
......@@ -899,7 +900,7 @@ public class THazardWorkPlanServiceImpl extends SuperServiceImpl<THazardWorkPlan
熏蒸作业高度: 7天内
进出仓高度危险作业: 12小时内
进出仓较大危险作业: 24小时内
进出仓一般危险作业: 72小时内*/
进出仓一般危险作业: 72小时内*//*
SysDictData workTypeDictData = sysDictDataService.getDictDataById(workType);
SysDictData workLevelDictData = sysDictDataService.getDictDataById(workLevel);
String result = "在安全时间内";
......@@ -912,7 +913,7 @@ public class THazardWorkPlanServiceImpl extends SuperServiceImpl<THazardWorkPlan
);
}
return result;
}
}*/
// 添加时区支持
......
......@@ -33,6 +33,9 @@
<id column="cancel_opinion" property="cancelOpinion"/>
<id column="revoke_opinion" property="revokeOpinion"/>
<id column="guardian_signature" property="guardianSignature"/>
<id column="hazard_license_pass_time" property="hazardLicensePassTime"/>
<id column="is_fully_invested" property="isFullyInvested"/>
<id column="is_full" property="isFull"/>
</resultMap>
<select id="selectToDoList" resultType="com.tongtech.tfw.workflow.apis.task.model.dto.TodoTask">
SELECT DISTINCT
......@@ -79,4 +82,17 @@
</if>
ORDER BY task.CREATE_TIME_ desc
</select>
<select id="selectHazardLicensePassTime" resultType="com.testor.module.hazard.model.domain.THazardWorkPlan">
select * from t_hazard_work_plan
where status ='0' and hazard_license_pass_time is not null
and work_status in('4','8','9','10')
</select>
<select id="selectNotCompleteList" resultType="com.testor.module.hazard.model.domain.THazardWorkPlan">
select * from t_hazard_work_plan
where status ='0'
and work_status not in('0','5','6','12')
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.testor.module.hazard.dao.THazardWorkPlanExpiredLogDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.testor.module.hazard.model.domain.THazardWorkPlanExpiredLog">
<id column="id" property="id"/>
<result column="plan_id" property="planId"/>
<result column="code" property="code"/>
<result column="work_type" property="workType"/>
<result column="danger_level" property="dangerLevel"/>
<result column="expired_reason" property="expiredReason"/>
<result column="before_expiration" property="beforeExpiration"/>
<result column="hazard_license_pass_time" property="hazardLicensePassTime"/>
<result column="actual_duration_hours" property="actualDurationHours"/>
<result column="plan_create_date" property="planCreateDate"/>
<!-- SuperModel 的字段 -->
<result column="status" property="status"/>
<result column="create_by" property="createBy"/>
<result column="create_date" property="createDate"/>
<result column="update_by" property="updateBy"/>
<result column="update_date" property="updateDate"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, plan_id, code, work_type, danger_level, expired_reason, before_expiration,
hazard_license_pass_time, actual_duration_hours, allowed_duration_hours,
plan_create_date, expired_time, remark, status, create_by, create_date, update_by, update_date
</sql>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment