From 15e2256ab5ce7c4955b6efc8da3dae1460fad15f Mon Sep 17 00:00:00 2001 From: wenjy Date: Tue, 30 Nov 2021 18:16:56 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/web/controller/api/AddTestData.java | 96 +++++++++++++++++++ .../controller/api/JfpgAnalyzeController.java | 47 +++++++++ 2 files changed, 143 insertions(+) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AddTestData.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/JfpgAnalyzeController.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AddTestData.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AddTestData.java new file mode 100644 index 0000000..0b354ee --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AddTestData.java @@ -0,0 +1,96 @@ +package com.ruoyi.web.controller.api; + +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.system.domain.ScadaEmsElectricloss; +import com.ruoyi.system.service.IScadaEmsElectriclossService; +import com.ruoyi.web.controller.tool.UUIDTool; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 创建测试数据 + * @author WenJY + * @date 2021年11月30日 17:20 + */ +@Controller +@RequestMapping("/api/JfpgAnalyze") +public class AddTestData { + + @Autowired + private IScadaEmsElectriclossService scadaEmsElectriclossService; + + @GetMapping("/info") + public boolean analyze(){ + try{ + Date date = new Date(); + List ds = test(date); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for (Date d : ds) { + + Random r = new Random(1); + ScadaEmsElectricloss scadaEmsElectricloss = new ScadaEmsElectricloss(); + scadaEmsElectricloss.setMonitorId("77"); + scadaEmsElectricloss.setUuid(UUIDTool.generate()); + scadaEmsElectricloss.setZxyg(Convert.toBigDecimal(ds.indexOf(d))); + scadaEmsElectricloss.setCollectTime(d); + scadaEmsElectriclossService.insertScadaEmsElectricloss(scadaEmsElectricloss); + + ScadaEmsElectricloss scadaEmsElectricloss2 = new ScadaEmsElectricloss(); + scadaEmsElectricloss2.setMonitorId("76"); + scadaEmsElectricloss2.setUuid(UUIDTool.generate()); + scadaEmsElectricloss2.setZxyg(Convert.toBigDecimal(ds.indexOf(d))); + scadaEmsElectricloss2.setCollectTime(d); + scadaEmsElectriclossService.insertScadaEmsElectricloss(scadaEmsElectricloss2); + + System.out.println(sdf.format(d)); + } + }catch (Exception e) { + return false; + } + return true; + } + + static List test(Date date) { + Date start = dayStartDate(date);//转换为天的起始date + Date nextDayDate = nextDay(start);//下一天的date + + List result = new ArrayList(); + while (start.compareTo(nextDayDate) < 0) { + result.add(start); + //日期加5分钟 + start = addFiveMin(start, 5); + } + + return result; + } + + private static Date addFiveMin(Date start, int offset) { + Calendar c = Calendar.getInstance(); + c.setTime(start); + c.add(Calendar.MINUTE, offset); + return c.getTime(); + } + + private static Date nextDay(Date start) { + Calendar c = Calendar.getInstance(); + c.setTime(start); + c.add(Calendar.DATE, 1); + return c.getTime(); + } + + private static Date dayStartDate(Date date) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + return c.getTime(); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/JfpgAnalyzeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/JfpgAnalyzeController.java new file mode 100644 index 0000000..c881078 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/JfpgAnalyzeController.java @@ -0,0 +1,47 @@ +package com.ruoyi.web.controller.api; + +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.system.domain.BaseJfpgInfo; +import com.ruoyi.system.domain.ScadaEmsElectricloss; +import com.ruoyi.system.service.IBaseJfpgInfoService; +import com.ruoyi.system.service.IScadaEmsElectriclossService; +import com.ruoyi.web.controller.tool.UUIDTool; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @author WenJY + * @date 2021年11月30日 16:52 + */ +@Controller +@RequestMapping("/api/JfpgAnalyze") +public class JfpgAnalyzeController { + + @Autowired + private IBaseJfpgInfoService baseJfpgInfoService; + + @Autowired + private IScadaEmsElectriclossService scadaEmsElectriclossService; + + public String Analyze(){ + + List jfpgInfoList = baseJfpgInfoService.selectBaseJfpgInfoList(new BaseJfpgInfo(1L)); + List scadaEmsElectriclossList = scadaEmsElectriclossService.selectScadaEmsElectriclossList(new ScadaEmsElectricloss()); + + // 尖 + + // 峰 + + // 平 + + // 谷 + + return ""; + } + +}