From fcb71b8fc63f74cd00d3faa76c73f4c5566ee352 Mon Sep 17 00:00:00 2001 From: zc <zc@123> Date: 星期三, 07 五月 2025 23:23:09 +0800 Subject: [PATCH] 解决提升机在本层,而没有锁提升机的问题 --- src/main/java/com/zy/core/News.java | 79 +++++++++++++++++++++++++++++++++------ 1 files changed, 67 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/zy/core/News.java b/src/main/java/com/zy/core/News.java index 3d51fa7..df3a64b 100644 --- a/src/main/java/com/zy/core/News.java +++ b/src/main/java/com/zy/core/News.java @@ -1,12 +1,13 @@ package com.zy.core; +import com.core.common.SpringUtils; +import com.zy.asrs.entity.WrkMast; +import com.zy.asrs.service.WrkMastService; import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Array; import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; /** * news stories for zoneyung @@ -22,7 +23,9 @@ System.out.println(News.print()); } - interface NewsSupport<T> { boolean execute(T t); } + interface NewsSupport<T> { + boolean execute(T t); + } private static final NewsQueue<NewsDomain> NEWS_QUEUE = new NewsQueue<>(NewsDomain.class, 1024); @@ -35,7 +38,10 @@ private int head; private int tail; - { this.head = 0; this.tail = 0; } + { + this.head = 0; + this.tail = 0; + } public NewsQueue(Class<T> cls, int capacity) { this.cls = cls; @@ -49,7 +55,7 @@ } this.reform(); this.arr[this.tail] = t; - this.tail ++; + this.tail++; return true; } @@ -60,7 +66,7 @@ this.reform(); } this.arr[this.tail] = t; - this.tail ++; + this.tail++; return true; } @@ -69,14 +75,14 @@ return null; } T t = this.arr[this.head]; - this.head ++; + this.head++; this.reform(); return t; } private void reform() { for (int i = this.head; i < this.tail; i++) { - this.arr[i-this.head] = this.arr[i]; + this.arr[i - this.head] = this.arr[i]; } this.tail -= this.head; this.head = 0; @@ -111,7 +117,22 @@ offer(NewsLevel.ERROR, format, arguments); } - public static String print() { + public static void taskInfo(Integer wrkNo, String format, Object... arguments) { + info(format, arguments); + offerTask(wrkNo, format, arguments); + } + + public static void taskWarn(Integer wrkNo, String format, Object... arguments) { + warn(format, arguments); + offerTask(wrkNo, format, arguments); + } + + public static void taskError(Integer wrkNo, String format, Object... arguments) { + error(format, arguments); + offerTask(wrkNo, format, arguments); + } + + public static String printStr() { StringBuilder sb = new StringBuilder("["); List<NewsDomain> domains = NEWS_QUEUE.data(); for (int i = 0; i < domains.size(); i++) { @@ -129,18 +150,51 @@ return sb.toString(); } + public static List<Map<String, Object>> print() { + List<Map<String, Object>> res = new ArrayList<>(); + for (NewsDomain datum : NEWS_QUEUE.data()) { + Map<String, Object> map = new HashMap<>(); + map.put("l", datum.level.idx); + map.put("v", datum.content); + map.put("t", datum.date); + res.add(map); + } + return res; + } + + private static boolean offerTask(Integer wrkNo, String msg, Object[] args) { + WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class); + if (wrkMastService == null) { + return false; + } + + WrkMast wrkMast = wrkMastService.selectByWorkNo(wrkNo); + if (wrkMast == null) { + return false; + } + String systemMsg = replace(msg, args); + if (!systemMsg.equals(wrkMast.getSystemMsg())) { + wrkMast.setSystemMsg(systemMsg); + wrkMast.setModiTime(new Date()); + wrkMastService.updateById(wrkMast); + } + return true; + } + private static boolean offer(NewsLevel level, String msg, Object[] args) { return NEWS_QUEUE.offer(new NewsDomain(level, replace(msg, args), (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()))); } - private static String replace(String str, Object[] objs){ + public static String replace(String str, Object[] objs) { if (null == objs || objs.length == 0 || null == str || "".equals(str.trim())) { return str; } else { StringBuilder sb = new StringBuilder(str); for (Object obj : objs) { int idx = sb.indexOf("{}"); - if (idx == -1) { break; } + if (idx == -1) { + break; + } sb.replace(idx, idx + 2, String.valueOf(obj)); } return sb.toString(); @@ -165,6 +219,7 @@ ERROR(3), ; public int idx; + NewsLevel(int idx) { this.idx = idx; } -- Gitblit v1.9.1