|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
import com.ruoyi.system.domain.*;
|
|
|
|
import com.ruoyi.system.domain.*;
|
|
|
|
import com.ruoyi.system.domain.dto.*;
|
|
|
|
import com.ruoyi.system.domain.dto.*;
|
|
|
|
import com.ruoyi.system.service.*;
|
|
|
|
import com.ruoyi.system.service.*;
|
|
|
@ -14,8 +15,9 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.util.List;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -34,11 +36,9 @@ public class IndexController {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired private IBaseSensorInfoService baseSensorInfoService;
|
|
|
|
@Autowired private IBaseSensorInfoService baseSensorInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired private IBaseAlarmModuleService baseAlarmModuleService;
|
|
|
|
private IBaseAlarmModuleService baseAlarmModuleService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired private IRecordAlarmService recordAlarmService;
|
|
|
|
private IRecordAlarmService recordAlarmService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping()
|
|
|
|
@GetMapping()
|
|
|
|
public String index() {
|
|
|
|
public String index() {
|
|
|
@ -315,28 +315,33 @@ public class IndexController {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 告警数量统计
|
|
|
|
* 告警数量统计
|
|
|
|
|
|
|
|
*
|
|
|
|
* @author WenJY
|
|
|
|
* @author WenJY
|
|
|
|
* @date 2022/3/27 14:52
|
|
|
|
* @date 2022/3/27 14:52
|
|
|
|
* @return java.lang.String
|
|
|
|
* @return java.lang.String
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GetMapping("/getAlarmAmount")
|
|
|
|
@GetMapping("/getAlarmAmount")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getAlarmAmount(){
|
|
|
|
public String getAlarmAmount() {
|
|
|
|
List<String> info = new ArrayList<>();
|
|
|
|
List<String> info = new ArrayList<>();
|
|
|
|
List<RecordAlarm> recordAlarms = recordAlarmService.selectRecordAlarmList(new RecordAlarm());
|
|
|
|
List<RecordAlarm> recordAlarms = recordAlarmService.selectRecordAlarmList(new RecordAlarm());
|
|
|
|
|
|
|
|
|
|
|
|
if(recordAlarms.size() > 0){
|
|
|
|
if (recordAlarms.size() > 0) {
|
|
|
|
int size = recordAlarms.stream().filter(x -> x.getDisposeFlag() == 0L).collect(Collectors.toList()).size();
|
|
|
|
int size =
|
|
|
|
|
|
|
|
recordAlarms.stream()
|
|
|
|
info.add(size+"");
|
|
|
|
.filter(x -> x.getDisposeFlag() == 0L)
|
|
|
|
info.add(recordAlarms.size()+"");
|
|
|
|
.collect(Collectors.toList())
|
|
|
|
|
|
|
|
.size();
|
|
|
|
}else{
|
|
|
|
|
|
|
|
info.add("--");
|
|
|
|
info.add(size + "");
|
|
|
|
info.add("--");
|
|
|
|
info.add(recordAlarms.size() + "");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
info.add("--");
|
|
|
|
|
|
|
|
info.add("--");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return JSONArray.toJSONString(info);
|
|
|
|
return JSONArray.toJSONString(info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -350,23 +355,25 @@ public class IndexController {
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getAlarmModuleAmount() {
|
|
|
|
public String getAlarmModuleAmount() {
|
|
|
|
|
|
|
|
|
|
|
|
List<String> yAxis = new ArrayList<>();
|
|
|
|
List<String> yAxis = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
List<Integer> data = new ArrayList<>();
|
|
|
|
List<Integer> data = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
List<BaseAlarmModuleDto> baseAlarmModuleDtos = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule());
|
|
|
|
List<BaseAlarmModuleDto> baseAlarmModuleDtos =
|
|
|
|
|
|
|
|
baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule());
|
|
|
|
|
|
|
|
|
|
|
|
if(baseAlarmModuleDtos.size()>0){
|
|
|
|
if (baseAlarmModuleDtos.size() > 0) {
|
|
|
|
baseAlarmModuleDtos.forEach(x->{
|
|
|
|
baseAlarmModuleDtos.forEach(
|
|
|
|
yAxis.add(x.getAlarmmoduleText());
|
|
|
|
x -> {
|
|
|
|
|
|
|
|
yAxis.add(x.getAlarmmoduleText());
|
|
|
|
|
|
|
|
|
|
|
|
data.add(Convert.toInt(x.getAlarmModuleAmount()));
|
|
|
|
data.add(Convert.toInt(x.getAlarmModuleAmount()));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String s = JSONArray.toJSONString(new AlarmJsonBean(null, yAxis, data));
|
|
|
|
String s = JSONArray.toJSONString(new AlarmJsonBean(null, yAxis, data));
|
|
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -380,40 +387,99 @@ public class IndexController {
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getAlarmTrend() {
|
|
|
|
public String getAlarmTrend() {
|
|
|
|
|
|
|
|
|
|
|
|
List<String> xAxis = new ArrayList<>();
|
|
|
|
List<String> xAxis = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
List<Integer> data = new ArrayList<>();
|
|
|
|
List<Integer> data = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
List<RecordAlarmDto> recordAlarmDtos = recordAlarmService.selectAlarmTrendList("");
|
|
|
|
List<String> dayByMonth = getSevenDate();
|
|
|
|
|
|
|
|
|
|
|
|
if(recordAlarmDtos.size()>0){
|
|
|
|
List<RecordAlarmDto> recordAlarmDtos = recordAlarmService.selectAlarmTrendList("");
|
|
|
|
recordAlarmDtos.forEach(x->{
|
|
|
|
|
|
|
|
xAxis.add(x.getCollectTime());
|
|
|
|
dayByMonth.forEach(
|
|
|
|
data.add(Convert.toInt(x.getAlarmValue()));
|
|
|
|
x -> {
|
|
|
|
});
|
|
|
|
List<RecordAlarmDto> collect =
|
|
|
|
}
|
|
|
|
recordAlarmDtos.stream()
|
|
|
|
|
|
|
|
.filter(y -> y.getCollectTime().equals(x))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
xAxis.add(x);
|
|
|
|
|
|
|
|
BigDecimal reduce =
|
|
|
|
|
|
|
|
collect.stream()
|
|
|
|
|
|
|
|
.map(RecordAlarmDto::getAlarmValue)
|
|
|
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
data.add(Convert.toInt(reduce));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String s = JSONArray.toJSONString(new AlarmJsonBean(xAxis, null, data));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取前七天的日期
|
|
|
|
|
|
|
|
* @author WenJY
|
|
|
|
|
|
|
|
* @date 2022/3/31 10:13
|
|
|
|
|
|
|
|
* @return java.util.List<java.lang.String>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static List<String> getSevenDate() {
|
|
|
|
|
|
|
|
List<String> dateList = new ArrayList<>();
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
|
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
|
|
|
Date date = DateUtils.addDays(new Date(), -i);
|
|
|
|
|
|
|
|
String formatDate = sdf.format(date);
|
|
|
|
|
|
|
|
dateList.add(formatDate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dateList.sort((a, b) -> a.compareTo(b.toString()));
|
|
|
|
|
|
|
|
return dateList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String s = JSONArray.toJSONString(new AlarmJsonBean(xAxis, null, data));
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取当月的日期
|
|
|
|
|
|
|
|
* @author WenJY
|
|
|
|
|
|
|
|
* @date 2022/3/31 10:14
|
|
|
|
|
|
|
|
* @return java.util.List<java.lang.String>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static List<String> getDayByMonth() {
|
|
|
|
|
|
|
|
List list = new ArrayList();
|
|
|
|
|
|
|
|
Calendar aCalendar = Calendar.getInstance(Locale.CHINA);
|
|
|
|
|
|
|
|
aCalendar.setTime(new Date());
|
|
|
|
|
|
|
|
int year = aCalendar.get(Calendar.YEAR); // 年份
|
|
|
|
|
|
|
|
int month = aCalendar.get(Calendar.MONTH) + 1; // 月份
|
|
|
|
|
|
|
|
int day = aCalendar.getActualMaximum(Calendar.DATE);
|
|
|
|
|
|
|
|
for (int i = 1; i <= day; i++) {
|
|
|
|
|
|
|
|
String aDate = null;
|
|
|
|
|
|
|
|
if (month < 10 && i < 10) {
|
|
|
|
|
|
|
|
aDate = "0" + month + "-0" + i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (month < 10 && i >= 10) {
|
|
|
|
|
|
|
|
aDate = "0" + month + "-" + i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (month >= 10 && i < 10) {
|
|
|
|
|
|
|
|
aDate = month + "-0" + i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (month >= 10 && i >= 10) {
|
|
|
|
|
|
|
|
aDate = month + "-" + i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
list.add(aDate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
@Data
|
|
|
|
class AlarmJsonBean{
|
|
|
|
class AlarmJsonBean {
|
|
|
|
|
|
|
|
|
|
|
|
public AlarmJsonBean() {
|
|
|
|
public AlarmJsonBean() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AlarmJsonBean(List<String> xAxis,List<String> yAxis, List<Integer> data) {
|
|
|
|
public AlarmJsonBean(List<String> xAxis, List<String> yAxis, List<Integer> data) {
|
|
|
|
this.xAxis = xAxis;
|
|
|
|
this.xAxis = xAxis;
|
|
|
|
this.yAxis = yAxis;
|
|
|
|
this.yAxis = yAxis;
|
|
|
|
this.data = data;
|
|
|
|
this.data = data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> yAxis;
|
|
|
|
private List<String> yAxis;
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> xAxis;
|
|
|
|
private List<String> xAxis;
|
|
|
|
|
|
|
|
|
|
|
|
private List<Integer> data;
|
|
|
|
private List<Integer> data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|