From 747a4a421dc8c1faf1c768aaac0fc7abc258e2c0 Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期一, 02 三月 2026 11:15:22 +0800
Subject: [PATCH] 巡检配置,起止时间修改
---
fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java | 108 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 99 insertions(+), 9 deletions(-)
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java
index f36b989..5a95626 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java
@@ -1,5 +1,7 @@
package com.fzzy.igds.utils;
+import com.fzzy.igds.camera.data.ydqly.YdQlyNode;
+import com.fzzy.igds.constant.GrainFrequence;
import com.ruoyi.common.config.FrameworkConfig;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.ShiroUtils;
@@ -22,6 +24,7 @@
private static final AtomicLong sequence = new AtomicLong(0);
private static String lastTimestamp = "";
+
//鍏ㄥ眬鐢ㄦ埛瀹炴椂鍧愬湪閮ㄩ棬
public static Map<String, String> contextUserDept = new HashMap<>();
@@ -31,12 +34,36 @@
public static Map<String, String> contextSnCompanyIdMap = new HashMap<>();
/**
+ * 娴佸獟浣撹妭鐐逛娇鐢�
+ */
+ public static List<YdQlyNode> nodeList = null;
+
+ /**
* 鐢熸垚椤哄簭ID锛氬勾鏈堟棩鏃跺垎绉掓绉�(17浣�) + 搴忓垪鍙�(4浣�) = 21浣�
+ */
+ public static String generateId() {
+ String pattern = "yyyyMMddHHmmssSSS";
+ return generateId(null, pattern);
+ }
+
+ /**
+ * 鐢熸垚鍗曟嵁缂栫爜锛� (鏍煎紡: yyyyMMddHHmmss + 4浣嶉殢鏈烘暟)
+ * @param prefix
+ * @return
+ */
+ public static String generateOrderId(String prefix) {
+ String pattern = "yyyyMMddHHmmss";
+ return generateId(prefix, pattern);
+ }
+
+ /**
+ *
*
* @return
*/
- public static String generateId() {
- String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
+ private static String generateId(String prefix, String pattern) {
+ if (null == pattern) pattern = "yyyyMMddHHmmss";
+ String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern(pattern));
long seq;
synchronized (ContextUtil.class) {
if (currentTimestamp.equals(lastTimestamp)) {
@@ -44,12 +71,14 @@
} else {
sequence.set(0);
seq = 0;
-
lastTimestamp = currentTimestamp;
}
}
- return String.format("%s%04d", currentTimestamp, seq);
+
+ if (null == prefix) return String.format("%s%02d", currentTimestamp, seq);
+ return prefix + "_" + String.format("%s%02d", currentTimestamp, seq);
}
+
public static String UUID() {
return UUID.randomUUID().toString().replaceAll("-", "");
@@ -63,13 +92,18 @@
public static String getCompanyId() {
SysUser user = ShiroUtils.getSysUser();
- if(null != user) return user.getCompanyId();
+ if (null != user) return user.getCompanyId();
return FrameworkConfig.getCompanyId();
}
public static String getLoginUserName() {
SysUser user = ShiroUtils.getSysUser();
return null == user ? "绯荤粺" : user.getUserName();
+ }
+
+ public static String getLoginName() {
+ SysUser user = ShiroUtils.getSysUser();
+ return null == user ? "sys" : user.getLoginName();
}
public static SysUser getLoginUser() {
@@ -113,16 +147,16 @@
Integer index5 = 100001;
Integer index = 0;
String orderId = "001";
- if(StringUtils.isNotEmpty(oldOrderId)){
+ if (StringUtils.isNotEmpty(oldOrderId)) {
index = Integer.valueOf(oldOrderId);
}
- if(3 == num){
+ if (3 == num) {
orderId = ((index3 + index) + "").substring(1);
}
- if(4 == num){
+ if (4 == num) {
orderId = ((index4 + index) + "").substring(1);
}
- if(5 == num){
+ if (5 == num) {
orderId = ((index5 + index) + "").substring(1);
}
return orderId;
@@ -147,4 +181,60 @@
public static String getCompanyIdBySn(String sn) {
return contextSnCompanyIdMap.get(sn);
}
+
+ public static String getTimeId() {
+ return DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
+ }
+
+ public static String getTimeId(int start, int end) {
+ return DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + RandomUtils.nextInt(start, end);
+ }
+
+
+ /**
+ * 濡傛灉鐢ㄦ埛鏄簱鍖虹敤鎴凤紝鍒ゆ柇鏄惁鏁版嵁鍏徃绾у埆
+ *
+ * @param userDeptId 褰撳墠鐢ㄦ埛閮ㄩ棬ID
+ * @return 濡傛灉閮ㄩ棬ID澶т簬闀垮害7璇存槑鏄簱鍖猴紝鍚﹀垯灏辨槸鍏徃绾у埆
+ */
+ public static boolean isDepotUser(String userDeptId) {
+ if(StringUtils.isBlank(userDeptId)) return false;
+ return userDeptId.length() > 7;
+ }
+
+
+ /**
+ * 鏍规嵁绯荤粺閰嶇疆鐨勬壒娆¢鐜囪幏鍙栨壒娆$紪鍙�
+ *
+ * @param freq
+ * @return
+ */
+ public static String getBatchIdByFireq(String freq) {
+ // 涓�澶╀竴娆�
+ if (GrainFrequence.FREQ_02.getCode().equals(freq)) {
+ return DateFormatUtils.format(new Date(), "yyyyMMdd") + "1801";
+ }
+
+ // 涓�澶╀袱娆�
+ if (GrainFrequence.FREQ_03.getCode().equals(freq)) {
+ String hour = DateFormatUtils.format(new Date(), "HH");
+ if (Integer.valueOf(hour) >= 0 && Integer.valueOf(hour) <= 12) {
+ return DateFormatUtils.format(new Date(), "yyyyMMdd") + "1301";
+ } else {
+ return DateFormatUtils.format(new Date(), "yyyyMMdd") + "1802";
+ }
+ }
+ return getDefaultBatchId();
+ }
+
+ public static String getDefaultBatchId() {
+ return DateFormatUtils.format(new Date(), "yyyyMMddHHmm");
+ }
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 10; i++){
+ String id = generateId();
+ System.out.println(id);
+ }
+ }
}
--
Gitblit v1.9.3