Просмотр исходного кода

开班两小时内OP160、OP165 做首检锁机

hbx 2 дней назад
Родитель
Сommit
afb6b9310c

+ 13 - 5
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -1127,13 +1127,20 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 		// 生成首次检查记录
 		String gjoprnos = Global.getConfig("mes.oprno.important");
 		Boolean checkFirstRet = false;
-		if(!StringUtils.isEmpty(gjoprnos) && gjoprnos.contains(oldOprno)){
+		// OP160/OP165 属于首检工位组,工位号可能带 A/B/C 后缀,需要按组判断
+		boolean firstCheckStation = CommonUitl.isFirstCheckOprno(oldOprno, lineSn);
+		String firstCheckOprno = firstCheckStation
+				? CommonUitl.normalizeFirstCheckOprno(oldOprno, lineSn)
+				: oldOprno;
+		boolean importantStation = !StringUtils.isEmpty(gjoprnos)
+				&& (CommonUitl.matchOprnos(gjoprnos, oldOprno) || CommonUitl.matchOprnos(gjoprnos, oprno));
+		if(firstCheckStation || importantStation){
 			// 检查当前工件是否是首件
-			checkFirstRet = checkFirstProduct(sn,oldOprno,lineSn);
+			checkFirstRet = checkFirstProduct(sn, firstCheckOprno, lineSn);
 			if(checkFirstRet){
 				MesProductCheckFirst mesProductCheckFirst = new MesProductCheckFirst();
 				mesProductCheckFirst.setSn(sn);
-				mesProductCheckFirst.setOprno(oldOprno);
+				mesProductCheckFirst.setOprno(firstCheckOprno);
 				mesProductCheckFirst.setLineSn(lineSn);
 				mesProductCheckFirst.setType("1"); // 开班首件
 				mesProductCheckFirst.setLineSn(lineSn);
@@ -1273,10 +1280,11 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 			return false; // 没有设置班次,返回false
 		}
 
-		// 检查当前班次是否已生成首件检查
+		// 检查当前班次是否已生成首件检查(首检工位按组匹配,兼容带 A/B/C 后缀的工位)
 		MesProductCheckFirst mesProductCheckFirst = new MesProductCheckFirst();
 		mesProductCheckFirst.setLineSn(lineSn);
-		mesProductCheckFirst.setOprno(oprno);
+		mesProductCheckFirst.setType("1");
+		mesProductCheckFirst.getSqlMap().getWhere().and("a.oprno", QueryType.RIGHT_LIKE, oprno);
 		mesProductCheckFirst.getSqlMap().getWhere().and("a.update_date", QueryType.GTE, mesShiftDataResp.getStart());
 		mesProductCheckFirst.getSqlMap().getWhere().and("a.update_date", QueryType.LT, mesShiftDataResp.getEnd());
 		List<MesProductCheckFirst> lists = mesProductCheckFirstService.findList(mesProductCheckFirst);

+ 54 - 0
src/main/java/com/jeesite/modules/mes/util/CommonUitl.java

@@ -574,6 +574,60 @@ public class CommonUitl {
     }
 
     /**
+     * 需要做开班首检的工位组。
+     * 支持产线级配置 mes.first.check.oprnos.{产线小写},其次读取 mes.first.check.oprnos。
+     * CZ060 未配置时默认 OP160、OP165(检漏二序、水道检漏一序)。
+     */
+    public static String getFirstCheckOprnos(String lineSn){
+        String cfg = "";
+        if(!StringUtils.isEmpty(lineSn)){
+            cfg = Global.getConfig("mes.first.check.oprnos." + lineSn.trim().toLowerCase());
+        }
+        if(StringUtils.isEmpty(cfg)){
+            cfg = Global.getConfig("mes.first.check.oprnos");
+        }
+        if(StringUtils.isEmpty(cfg) && "CZ060".equalsIgnoreCase(lineSn == null ? "" : lineSn.trim())){
+            cfg = "OP160,OP165";
+        }
+        return cfg == null ? "" : cfg.trim();
+    }
+
+    /**
+     * 判断工位是否属于首检工位组。
+     * 工位码会先按 formatOprno 归一(OP160A -> OP160),因此 OP160A/OP160C 等都算 OP160 组。
+     */
+    public static boolean isFirstCheckOprno(String oprno, String lineSn){
+        if(StringUtils.isEmpty(oprno)){
+            return false;
+        }
+        String formatted = formatOprno(oprno.trim());
+        for(String s : getFirstCheckOprnos(lineSn).split(",")){
+            String group = s.trim();
+            if(!group.isEmpty() && (formatted.equals(group) || formatted.startsWith(group))){
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 返回工位所属的首检工位组;不属于首检工位时返回归一后的工位号。
+     */
+    public static String normalizeFirstCheckOprno(String oprno, String lineSn){
+        if(StringUtils.isEmpty(oprno)){
+            return oprno;
+        }
+        String formatted = formatOprno(oprno.trim());
+        for(String s : getFirstCheckOprnos(lineSn).split(",")){
+            String group = s.trim();
+            if(!group.isEmpty() && (formatted.equals(group) || formatted.startsWith(group))){
+                return group;
+            }
+        }
+        return formatted;
+    }
+
+    /**
      * 表单形式post请求
      *
      * @paramurl 请求地址

+ 53 - 12
src/main/java/com/jeesite/modules/mes/web/MesProductCheckFirstController.java

@@ -1,5 +1,6 @@
 package com.jeesite.modules.mes.web;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.Resource;
@@ -16,6 +17,7 @@ import com.jeesite.modules.mes.entity.MesProductRecord;
 import com.jeesite.modules.mes.resp.CommonResp;
 import com.jeesite.modules.mes.service.MesLineProcessService;
 import com.jeesite.modules.mes.service.MesProductRecordService;
+import com.jeesite.modules.mes.util.CommonUitl;
 import com.jeesite.modules.utils.DateLocalUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -294,22 +296,18 @@ public class MesProductCheckFirstController extends BaseController {
 				mesProductRecordService.update(mesProductRecord1);
 			}
 
-			MesLineProcess mesLineProcess = new MesLineProcess();
-			mesLineProcess.setLineSn(mesProductCheckFirst1.getLineSn());
-			mesLineProcess.setOprno(mesProductCheckFirst1.getOprno());
-			MesLineProcess mesLineProcess2 = mesLineProcessService.findInfo(mesLineProcess);
-			if(!ObjectUtils.isEmpty(mesLineProcess2)){
+			// 首检工位可能带 A/B/C 后缀,按工位组一起停机
+			for (MesLineProcess mesLineProcess2 : findFirstCheckProcesses(mesProductCheckFirst1)) {
 				mesLineProcess2.setStop(2);
 				mesLineProcessService.update(mesLineProcess2);
 			}
 		}else if(("OK").equals(mesProductCheckFirst.getResult())){
-			MesLineProcess mesLineProcess = new MesLineProcess();
-			mesLineProcess.setOprno(mesProductCheckFirst1.getOprno());
-			mesLineProcess.setLineSn(mesProductCheckFirst1.getLineSn());
-			MesLineProcess mesLineProcess2 = mesLineProcessService.findInfo(mesLineProcess);
-			if(!ObjectUtils.isEmpty(mesLineProcess2) && mesLineProcess2.getStop() == 3){ // 超时停机的,检查合格后恢复生产
-				mesLineProcess2.setStop(0);
-				mesLineProcessService.update(mesLineProcess2);
+			// 首检合格后,解除本工位/工位组的超时停机
+			for (MesLineProcess mesLineProcess2 : findFirstCheckProcesses(mesProductCheckFirst1)) {
+				if(mesLineProcess2.getStop() != null && mesLineProcess2.getStop() == 3){
+					mesLineProcess2.setStop(0);
+					mesLineProcessService.update(mesLineProcess2);
+				}
 			}
 		}
 		mesProductCheckFirst.setState("1");
@@ -317,4 +315,47 @@ public class MesProductCheckFirstController extends BaseController {
 
 		return renderResult(Global.TRUE, "操作成功");
 	}
+
+	/**
+	 * 查询首检记录对应的工位。
+	 * 首检工位(OP160/OP165)按工位组返回父工位及所有 A/B/C 子工位,保证锁机/解锁完整。
+	 */
+	private List<MesLineProcess> findFirstCheckProcesses(MesProductCheckFirst checkFirst) {
+		List<MesLineProcess> result = new ArrayList<>();
+		String lineSn = checkFirst.getLineSn();
+		String oprno = checkFirst.getOprno();
+
+		MesLineProcess query = new MesLineProcess();
+		query.setLineSn(lineSn);
+		query.setStatus("0");
+		List<MesLineProcess> processes = mesLineProcessService.findList(query);
+		if (processes != null) {
+			if (CommonUitl.isFirstCheckOprno(oprno, lineSn)) {
+				String group = CommonUitl.normalizeFirstCheckOprno(oprno, lineSn);
+				for (MesLineProcess process : processes) {
+					if (group.equals(CommonUitl.normalizeFirstCheckOprno(process.getOprno(), lineSn))) {
+						result.add(process);
+					}
+				}
+			} else {
+				for (MesLineProcess process : processes) {
+					if (oprno.equals(process.getOprno())) {
+						result.add(process);
+					}
+				}
+			}
+		}
+
+		// 兼容未配置状态或历史数据的情况
+		if (result.isEmpty()) {
+			MesLineProcess exact = new MesLineProcess();
+			exact.setLineSn(lineSn);
+			exact.setOprno(oprno);
+			MesLineProcess process = mesLineProcessService.findInfo(exact);
+			if (process != null) {
+				result.add(process);
+			}
+		}
+		return result;
+	}
 }

+ 23 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -1386,6 +1386,12 @@ public class MesProductRecordController extends BaseController {
 			return ret;
 		}
 
+		// OP160/OP165 首检工位即使未开启防呆,也必须遵守首检超时锁机
+		if(isFirstCheckTimeoutLocked(mesLineProcess1, oldOprno, lineSn)){
+			ret = bs+"CS";
+			return ret;
+		}
+
 		oprno = CommonUitl.formatOprno(oprno);
 		if(mesLineProcess1.getQuality().equals("0") && mesLineProcess1.getRepeat().equals("1")){ // 不防呆且可以重复工作
 			ret = bs+"UD";
@@ -1525,6 +1531,17 @@ public class MesProductRecordController extends BaseController {
 		return ret;
 	}
 
+	/**
+	 * 首检超时锁机判断。
+	 * 只拦截配置的首检工位组(CZ060 默认 OP160/OP165),且仅在 stop=3 时生效。
+	 */
+	private boolean isFirstCheckTimeoutLocked(MesLineProcess process, String oprno, String lineSn){
+		return process != null
+				&& process.getStop() != null
+				&& process.getStop() == 3
+				&& CommonUitl.isFirstCheckOprno(oprno, lineSn);
+	}
+
 	// 检查质量逻辑代码 新版
 	private String checkQualityResultXz(String oprno,String sn,String lineSn,String userCode,String isRepair){
 
@@ -1596,6 +1613,12 @@ public class MesProductRecordController extends BaseController {
 			return ret;
 		}
 
+		// OP160/OP165 首检工位即使未开启防呆,也必须遵守首检超时锁机
+		if(isFirstCheckTimeoutLocked(mesLineProcess1, oldOprno, lineSn)){
+			ret = bs+"CS";
+			return ret;
+		}
+
 		oprno = CommonUitl.formatOprno(oprno);
 		if(isRepair.equals("0")){
 			if(mesLineProcess1.getQuality().equals("0") && mesLineProcess1.getRepeat().equals("1")){ // 不防呆且可以重复工作

+ 240 - 42
src/main/java/com/jeesite/modules/scheduling/DeviceCheckFirstScheduling.java

@@ -5,76 +5,274 @@ import com.jeesite.common.lang.StringUtils;
 import com.jeesite.common.mybatis.mapper.query.QueryType;
 import com.jeesite.modules.mes.entity.MesLineProcess;
 import com.jeesite.modules.mes.entity.MesProductCheckFirst;
-import com.jeesite.modules.mes.entity.MesShift;
+import com.jeesite.modules.mes.entity.MesProductRecord;
 import com.jeesite.modules.mes.resp.MesShiftDataResp;
 import com.jeesite.modules.mes.service.MesLineProcessService;
 import com.jeesite.modules.mes.service.MesProductCheckFirstService;
+import com.jeesite.modules.mes.service.MesProductRecordService;
 import com.jeesite.modules.mes.service.MesShiftService;
 import com.jeesite.modules.mes.util.CommonUitl;
-import org.apache.poi.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
+/**
+ * 开班首检超时锁机任务。
+ *
+ * 规则:开班 2 小时内未完成首检的工位锁机(mes_line_process.stop=3),
+ * 首检合格后由首检提交接口或本任务自动解除锁机。
+ * 默认对 CZ060 的 OP160、OP165 生效,可通过
+ * mes.first.check.oprnos / mes.first.check.oprnos.{产线小写} 配置。
+ */
 @Configuration
 @EnableScheduling
-public class DeviceCheckFirstScheduling {//检查首件检查是否超时未检查
+public class DeviceCheckFirstScheduling {
+
+    private static final Logger logger = LoggerFactory.getLogger(DeviceCheckFirstScheduling.class);
+
+    /** 首检超时时间:开班后 2 小时 */
+    private static final long FIRST_CHECK_TIMEOUT_MILLIS = 2L * 60 * 60 * 1000;
+
+    /** 首件超时停机状态 */
+    private static final int STOP_FIRST_CHECK_TIMEOUT = 3;
+
+    private static final String DATE_PATTERN = "yyyy-MM-dd HH:mm";
+
     @Autowired
     private MesShiftService mesShiftService;
+
     @Autowired
     private MesLineProcessService mesLineProcessService;
 
     @Autowired
     private MesProductCheckFirstService mesProductCheckFirstService;
+
+    @Autowired
+    private MesProductRecordService mesProductRecordService;
+
     // 每分钟执行一次
-//    @Scheduled(cron = "0 * * * * ?")  // cron 表达式
+    @Scheduled(cron = "0 * * * * ?")
     public void checkDevices() {
-        String check = Global.getConfig("mes.first.check.timeout");
-        if(check.equals("1")){
-            // 定义日期时间格式
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
-            LocalDateTime now = LocalDateTime.now();
-            System.out.println("now:"+now.format(formatter));
-            // 将字符串转换为 LocalDateTime
-            LocalDateTime dateTime = LocalDateTime.parse(now.format(formatter), formatter);
-            // 减少两个小时
-            LocalDateTime twoHoursLater = dateTime.minusHours(2);
-            // 格式化输出
-            String endDate = twoHoursLater.format(formatter);
-            System.out.println("limit:"+endDate);
-
-            String startDate = "2025-10-01 08:00";
-
-            //超过开班两小时,并且状态为未检查的首件检查记录
-            MesProductCheckFirst mesProductCheckFirst = new MesProductCheckFirst();
-            mesProductCheckFirst.setState("0");
-            mesProductCheckFirst.setType("1"); // 开班首件检查
-            mesProductCheckFirst.getSqlMap().getWhere().and("a.create_date", QueryType.GT,startDate);
-            mesProductCheckFirst.getSqlMap().getWhere().and("a.create_date", QueryType.LT,endDate);
-            List<MesProductCheckFirst> list = mesProductCheckFirstService.findList(mesProductCheckFirst);
-            if (list.size() > 0){
-                for (MesProductCheckFirst dtl : list) {
-                    MesLineProcess mesLineProcess1 = new MesLineProcess();
-                    mesLineProcess1.setLineSn(dtl.getLineSn());
-                    mesLineProcess1.getSqlMap().getWhere().and("a.oprno",QueryType.EQ,dtl.getOprno());
-                    List<MesLineProcess> mesLineProcesses = mesLineProcessService.findList(mesLineProcess1);
-                    if (mesLineProcesses.size() > 0){
-                        for (MesLineProcess lineProcess : mesLineProcesses) {
-                            //修改工位状态为首件检超时未处理
-                            if(lineProcess.getStop() != 3){
-                                lineProcess.setStop(3);
-                                mesLineProcessService.update(lineProcess);
-                            }
+        String check = Global.getConfig("mes.first.check.timeout", "1");
+        if (check == null || !"1".equals(check.trim())) {
+            return;
+        }
+
+        MesShiftDataResp currentShift = mesShiftService.getCurShift();
+        if (currentShift == null || StringUtils.isBlank(currentShift.getStart())) {
+            return;
+        }
+
+        Date shiftStart = parseDate(currentShift.getStart());
+        Date shiftEnd = parseDate(currentShift.getEnd());
+        if (shiftStart == null || shiftEnd == null) {
+            logger.warn("首检锁机任务:班次时间格式不正确,start={}, end={}",
+                    currentShift.getStart(), currentShift.getEnd());
+            return;
+        }
+
+        Date now = new Date();
+        boolean timeoutReached = now.getTime() >= shiftStart.getTime() + FIRST_CHECK_TIMEOUT_MILLIS;
+
+        // 一次性取出所有启用中的工位,再按产线、首检工位组归类,避免逐工位查询数据库
+        MesLineProcess processQuery = new MesLineProcess();
+        processQuery.setStatus("0");
+        List<MesLineProcess> allProcesses = mesLineProcessService.findList(processQuery);
+        Map<String, List<MesLineProcess>> lineMap = new LinkedHashMap<>();
+        for (MesLineProcess process : allProcesses) {
+            if (StringUtils.isBlank(process.getLineSn()) || StringUtils.isBlank(process.getOprno())) {
+                continue;
+            }
+            lineMap.computeIfAbsent(process.getLineSn(), k -> new ArrayList<>()).add(process);
+        }
+
+        for (Map.Entry<String, List<MesLineProcess>> entry : lineMap.entrySet()) {
+            String lineSn = entry.getKey();
+            String groups = CommonUitl.getFirstCheckOprnos(lineSn);
+            if (StringUtils.isBlank(groups)) {
+                continue;
+            }
+            for (String rawGroup : groups.split(",")) {
+                String group = rawGroup.trim();
+                if (group.isEmpty()) {
+                    continue;
+                }
+
+                List<MesLineProcess> groupProcesses = new ArrayList<>();
+                for (MesLineProcess process : entry.getValue()) {
+                    String normalized = CommonUitl.normalizeFirstCheckOprno(process.getOprno(), lineSn);
+                    if (group.equals(normalized)) {
+                        groupProcesses.add(process);
+                    }
+                }
+                if (groupProcesses.isEmpty()) {
+                    continue;
+                }
+
+                List<MesProductCheckFirst> records = findFirstCheckRecords(lineSn, group, shiftStart, shiftEnd);
+                boolean completed = false;
+                boolean completedOk = false;
+                for (MesProductCheckFirst record : records) {
+                    if ("1".equals(record.getState())) {
+                        completed = true;
+                        if ("OK".equalsIgnoreCase(record.getResult())) {
+                            completedOk = true;
                         }
                     }
                 }
+
+                if (!timeoutReached) {
+                    // 新班次开始后的 2 小时缓冲期内,清掉上一班遗留的超时锁机
+                    unlockTimeout(groupProcesses, lineSn, group);
+                    continue;
+                }
+
+                if (completedOk) {
+                    // 首检合格,恢复生产
+                    unlockTimeout(groupProcesses, lineSn, group);
+                    continue;
+                }
+
+                if (completed) {
+                    // 首检已做但不合格,保留不合格停机状态(stop=1/2),不再改成超时停机
+                    continue;
+                }
+
+                // 2 小时内没有完成首检:先补一条待检记录,方便操作员做首检,再锁机
+                if (records.isEmpty()) {
+                    createPendingFirstCheck(lineSn, group, shiftStart, shiftEnd);
+                }
+                lockTimeout(groupProcesses, lineSn, group);
+            }
+        }
+    }
+
+    /**
+     * 查询当前班次、当前产线、当前首检工位组的首检记录。
+     * oprno 可能带 A/B/C 后缀,这里按工位组统一过滤。
+     */
+    private List<MesProductCheckFirst> findFirstCheckRecords(String lineSn, String group,
+                                                             Date shiftStart, Date shiftEnd) {
+        MesProductCheckFirst query = new MesProductCheckFirst();
+        query.setLineSn(lineSn);
+        query.setType("1");
+        query.getSqlMap().getWhere().and("a.create_date", QueryType.GTE, shiftStart);
+        query.getSqlMap().getWhere().and("a.create_date", QueryType.LT, shiftEnd);
+        List<MesProductCheckFirst> list = mesProductCheckFirstService.findList(query);
+
+        List<MesProductCheckFirst> result = new ArrayList<>();
+        if (list == null) {
+            return result;
+        }
+        for (MesProductCheckFirst record : list) {
+            String normalized = CommonUitl.normalizeFirstCheckOprno(record.getOprno(), lineSn);
+            if (group.equals(normalized)) {
+                result.add(record);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 超时且没有任何首检记录时,取本班次该工位组的第一件产品生成待检记录。
+     * 若本班次还没有产品经过该工位,则只锁机,不生成无工件码的记录。
+     */
+    private void createPendingFirstCheck(String lineSn, String group, Date shiftStart, Date shiftEnd) {
+        MesProductRecord query = new MesProductRecord();
+        query.getSqlMap().getWhere().and("a.line_sn", QueryType.EQ, lineSn);
+        query.getSqlMap().getWhere().and("a.oprno", QueryType.RIGHT_LIKE, group);
+        query.getSqlMap().getWhere().and("a.create_date", QueryType.GTE, shiftStart);
+        query.getSqlMap().getWhere().and("a.create_date", QueryType.LT, shiftEnd);
+        query.getSqlMap().getOrder().setOrderBy("a.create_date ASC");
+        List<MesProductRecord> records = mesProductRecordService.findList(query);
+        if (records == null || records.isEmpty()) {
+            logger.info("首检锁机:产线 {} 工位 {} 本班次暂无产品记录,仅锁机不补首检记录", lineSn, group);
+            return;
+        }
+
+        // 优先取已经产生实际结果的首件,避免取到仅占位的 UDF 记录
+        MesProductRecord firstProduct = null;
+        for (MesProductRecord record : records) {
+            if (StringUtils.isBlank(record.getSn())) {
+                continue;
+            }
+            if ("OK".equalsIgnoreCase(record.getContent()) || "NG".equalsIgnoreCase(record.getContent())) {
+                firstProduct = record;
+                break;
+            }
+        }
+        if (firstProduct == null) {
+            for (MesProductRecord record : records) {
+                if (StringUtils.isNotBlank(record.getSn())) {
+                    firstProduct = record;
+                    break;
+                }
+            }
+        }
+        if (firstProduct == null) {
+            return;
+        }
+
+        MesProductCheckFirst checkFirst = new MesProductCheckFirst();
+        checkFirst.setSn(firstProduct.getSn());
+        checkFirst.setOprno(group);
+        checkFirst.setLineSn(lineSn);
+        checkFirst.setType("1");
+        checkFirst.setState("0");
+        checkFirst.setCreateBy("system");
+        checkFirst.setUpdateBy("system");
+        mesProductCheckFirstService.save(checkFirst);
+        logger.info("首检超时:产线 {} 工位 {} 已补建首检记录,sn={}", lineSn, group, firstProduct.getSn());
+    }
+
+    /**
+     * 设置超时停机。已有其他停机原因(首检 NG、设备报警)时不覆盖。
+     */
+    private void lockTimeout(List<MesLineProcess> processes, String lineSn, String group) {
+        for (MesLineProcess process : processes) {
+            Integer stop = process.getStop();
+            if (stop == null || stop == 0 || Objects.equals(stop, STOP_FIRST_CHECK_TIMEOUT)) {
+                if (!Objects.equals(stop, STOP_FIRST_CHECK_TIMEOUT)) {
+                    process.setStop(STOP_FIRST_CHECK_TIMEOUT);
+                    mesLineProcessService.update(process);
+                    logger.info("首检超时锁机:产线 {} 工位 {} stop=3", lineSn, process.getOprno());
+                }
+            }
+        }
+    }
+
+    /**
+     * 解除本任务设置的超时停机,不影响其它停机原因。
+     */
+    private void unlockTimeout(List<MesLineProcess> processes, String lineSn, String group) {
+        for (MesLineProcess process : processes) {
+            if (Objects.equals(process.getStop(), STOP_FIRST_CHECK_TIMEOUT)) {
+                process.setStop(0);
+                mesLineProcessService.update(process);
+                logger.info("首检完成解锁:产线 {} 工位 {} stop=3 -> 0", lineSn, process.getOprno());
             }
         }
+    }
 
+    private Date parseDate(String value) {
+        if (StringUtils.isBlank(value)) {
+            return null;
+        }
+        try {
+            return new SimpleDateFormat(DATE_PATTERN).parse(value);
+        } catch (Exception e) {
+            return null;
+        }
     }
 }