Explorar o código

添加定时任务

wukai hai 1 ano
pai
achega
21e74d3e3b

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinCalcDay.java

@@ -235,7 +235,7 @@ public class TwinCalcDay extends BaseEntity {
     public void convert(TwinCalc2hr calc2hr) {
         BeanUtils.copyProperties(calc2hr, this);
         this.time = calc2hr.getDataDate();
-        this.kwh = this.kwhA.add(this.kwhB);
+//        this.kwh = this.kwhA.add(this.kwhB);
         this.weight = this.weightA.add(this.weightB);
         this.length = this.lengthA.add(this.lengthB);
         this.efficiencyA = Tools.calcPercent(this.openTimeA, this.closeTimeA);

+ 4 - 11
ruoyi-admin/src/main/java/com/ruoyi/biz/domain/WeekData.java

@@ -7,7 +7,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.util.Random;
 
 /**
@@ -64,20 +63,14 @@ public class WeekData {
         BeanUtils.copyProperties(day, this);
         this.setTime(DateUtils.parseDateToStr(day.getTime()));
 
-        this.efficiency = BigDecimal.valueOf(new Random().nextInt(2000) / 100f + 80f).setScale(2, RoundingMode.HALF_UP);
-        this.aEfficiency = BigDecimal.valueOf(new Random().nextInt(2000) / 100f + 80f).setScale(2, RoundingMode.HALF_UP);
-        this.bEfficiency = BigDecimal.valueOf(new Random().nextInt(2000) / 100f + 80f).setScale(2, RoundingMode.HALF_UP);
+        this.aEfficiency = day.getEfficiencyA();
+        this.bEfficiency = day.getEfficiencyB();
 
         this.aWeight = day.getWeightA();
         this.bWeight = day.getWeightB();
 
-        float al = new Random().nextInt(50000) / 100f + 500f;
-        float bl = new Random().nextInt(50000) / 100f + 500f;
-        float tl = al + bl;
-
-        this.kwh = BigDecimal.valueOf(tl).setScale(2, RoundingMode.HALF_UP);
-        this.aKwh = BigDecimal.valueOf(al).setScale(2, RoundingMode.HALF_UP);
-        this.bKwh = BigDecimal.valueOf(bl).setScale(2, RoundingMode.HALF_UP);
+        this.aKwh = day.getKwhA();
+        this.bKwh = day.getKwhB();
     }
 
 }

+ 29 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/task/TwinTask.java

@@ -0,0 +1,29 @@
+package com.ruoyi.biz.task;
+
+import com.ruoyi.biz.service.ITaskService;
+import com.ruoyi.biz.service.ITwinCalcDayService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+/**
+ * 定时任务调度测试
+ *
+ * @author ruoyi
+ */
+@Component("twinTask")
+public class TwinTask {
+    @Resource
+    private ITaskService taskService;
+    @Resource
+    private ITwinCalcDayService dayService;
+
+
+    public void last() {
+        taskService.calcLastPeriod();
+    }
+
+    public void day() {
+        dayService.calcYesterday();
+    }
+}

+ 6 - 7
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -4,11 +4,10 @@ import java.util.Locale;
 
 /**
  * 通用常量信息
- * 
+ *
  * @author ruoyi
  */
-public class Constants
-{
+public class Constants {
     /**
      * UTF-8 字符集
      */
@@ -112,11 +111,11 @@ public class Constants
     /**
      * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
      */
-    public static final String[] JOB_WHITELIST_STR = { "com.ruoyi.quartz.task" };
+    public static final String[] JOB_WHITELIST_STR = {"com.ruoyi.quartz.task", "com.ruoyi.biz.task"};
 
     /**
      * 定时任务违规的字符
      */
-    public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
-            "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config", "com.ruoyi.generator" };
-}
+    public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
+            "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config", "com.ruoyi.generator"};
+}