change - 测试
parent
d8241177f8
commit
15e2256ab5
@ -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<Date> 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<Date> test(Date date) {
|
||||
Date start = dayStartDate(date);//转换为天的起始date
|
||||
Date nextDayDate = nextDay(start);//下一天的date
|
||||
|
||||
List<Date> result = new ArrayList<Date>();
|
||||
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();
|
||||
}
|
||||
}
|
@ -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<BaseJfpgInfo> jfpgInfoList = baseJfpgInfoService.selectBaseJfpgInfoList(new BaseJfpgInfo(1L));
|
||||
List<ScadaEmsElectricloss> scadaEmsElectriclossList = scadaEmsElectriclossService.selectScadaEmsElectriclossList(new ScadaEmsElectricloss());
|
||||
|
||||
// 尖
|
||||
|
||||
// 峰
|
||||
|
||||
// 平
|
||||
|
||||
// 谷
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue