| | |
| | | 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; |
| | |
| | | offer(NewsLevel.ERROR, format, arguments); |
| | | } |
| | | |
| | | 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(); |
| | |
| | | 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 { |