andy 1 жил өмнө
parent
commit
ea456e8d80

+ 19 - 5
src/main/java/com/scbfkj/uni/service/ControlService.java

@@ -109,11 +109,25 @@ public class ControlService {
     }
 
     private static void updateServiceState(String serviceId, String state) throws Exception {
-        DataBase.update(Config.getCenterConnectionStr(), "insert into  servicestate(serviceid,starttime,containercode,runstate) values (?,?,?,?)",
-                serviceId,
-                DataFormatUtil.toString(LocalDateTime.now()),
-                Config.getContainerCode(),
-                state);
+        if (Objects.equals(state, "1")) {
+
+            List<Map<String, Object>> mapList = DataBase.query(Config.getCenterConnectionStr(), "select runstate from servicestate where serviceid=? and containercode=?", serviceId, Config.getContainerCode());
+            if (mapList.isEmpty()) {
+
+                DataBase.update(Config.getCenterConnectionStr(), "insert into  servicestate(serviceid,starttime,containercode,runstate) values (?,?,?,'1')",
+                        serviceId,
+                        DataFormatUtil.toString(LocalDateTime.now()),
+                        Config.getContainerCode());
+            } else {
+                DataBase.update(Config.getCenterConnectionStr(), "update servicestate set starttime=?,runstate='1' where serviceid=? and containercode=?",
+                        DataFormatUtil.toString(LocalDateTime.now()),
+                        serviceId, Config.getContainerCode());
+            }
+        } else {
+            DataBase.update(Config.getCenterConnectionStr(), "update servicestate set stoptime=?,runstate='0' where serviceid=? and containercode=?",
+                    DataFormatUtil.toString(LocalDateTime.now()),
+                    serviceId, Config.getContainerCode());
+        }
     }
 
     /**

+ 2 - 1
src/main/java/com/scbfkj/uni/service/SecurityService.java

@@ -182,8 +182,9 @@ public class SecurityService {
 
             Map<String, Object> data = new HashMap<>();
             data.put("verifyCodeImage", base64Code);
-            if (debug)
+            if (Config.isDebug()) {
                 data.put("code", code);
+            }
             return UniReturnUtil.success(data);
         }
         return UniReturnUtil.fail("没有配置验证码规则");

+ 7 - 5
src/main/java/com/scbfkj/uni/system/ScheduleUtil.java

@@ -56,15 +56,17 @@ public class ScheduleUtil {
             taskType = "0";
         }
         Trigger trigger;
-//        定时
-        if (Objects.equals(taskType.toString(), "1")) {
+//        轮询
+        if (Objects.equals(taskType.toString(), "2")) {
             trigger = new CronTrigger(cronExpress.toString());
-//            轮询
-        } else if (Objects.equals(taskType.toString(), "2")) {
+//            定时
+        } else if (Objects.equals(taskType.toString(), "1")) {
             Object frequency = serviceInfo.getOrDefault("frequency", "0");
             trigger = new PeriodicTrigger(Duration.ofMillis(Long.parseLong(frequency.toString())));
-        } else {
+        } else if (Objects.equals(taskType.toString(), "0")) {
             System.out.println("服务任务类型:" + taskType + ",服务ID: " + serviceId);
+            return true;
+        } else {
             throw new RuntimeException("任务类型不支持  定时任务支持:1:定时任务,2:轮询任务");
         }