change - 告警单元样式修改,一次显示六种类型,告警趋势样式修改,没有数据时日期依然显示,数据显示0

main
wenjy 3 years ago
parent 76516f4b37
commit 973923a652

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.dto.*;
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.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -34,11 +36,9 @@ public class IndexController {
@Autowired private IBaseSensorInfoService baseSensorInfoService;
@Autowired
private IBaseAlarmModuleService baseAlarmModuleService;
@Autowired private IBaseAlarmModuleService baseAlarmModuleService;
@Autowired
private IRecordAlarmService recordAlarmService;
@Autowired private IRecordAlarmService recordAlarmService;
@GetMapping()
public String index() {
@ -315,23 +315,28 @@ public class IndexController {
/**
*
*
* @author WenJY
* @date 2022/3/27 14:52
* @return java.lang.String
*/
@GetMapping("/getAlarmAmount")
@ResponseBody
public String getAlarmAmount(){
public String getAlarmAmount() {
List<String> info = new ArrayList<>();
List<RecordAlarm> recordAlarms = recordAlarmService.selectRecordAlarmList(new RecordAlarm());
if(recordAlarms.size() > 0){
int size = recordAlarms.stream().filter(x -> x.getDisposeFlag() == 0L).collect(Collectors.toList()).size();
if (recordAlarms.size() > 0) {
int size =
recordAlarms.stream()
.filter(x -> x.getDisposeFlag() == 0L)
.collect(Collectors.toList())
.size();
info.add(size+"");
info.add(recordAlarms.size()+"");
info.add(size + "");
info.add(recordAlarms.size() + "");
}else{
} else {
info.add("--");
info.add("--");
}
@ -354,10 +359,12 @@ public class IndexController {
List<Integer> data = new ArrayList<>();
List<BaseAlarmModuleDto> baseAlarmModuleDtos = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule());
List<BaseAlarmModuleDto> baseAlarmModuleDtos =
baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule());
if(baseAlarmModuleDtos.size()>0){
baseAlarmModuleDtos.forEach(x->{
if (baseAlarmModuleDtos.size() > 0) {
baseAlarmModuleDtos.forEach(
x -> {
yAxis.add(x.getAlarmmoduleText());
data.add(Convert.toInt(x.getAlarmModuleAmount()));
@ -384,28 +391,87 @@ public class IndexController {
List<Integer> data = new ArrayList<>();
List<String> dayByMonth = getSevenDate();
List<RecordAlarmDto> recordAlarmDtos = recordAlarmService.selectAlarmTrendList("");
if(recordAlarmDtos.size()>0){
recordAlarmDtos.forEach(x->{
xAxis.add(x.getCollectTime());
data.add(Convert.toInt(x.getAlarmValue()));
dayByMonth.forEach(
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;
}
/**
*
* @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;
}
list.add(aDate);
}
return list;
}
}
@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.yAxis = yAxis;
this.data = data;

@ -6,12 +6,12 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://121.36.58.109:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Haiwei123456
# url: jdbc:mysql://localhost:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://121.36.58.109:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: root
# password: Haiwei123456
url: jdbc:mysql://localhost:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: root
# 从库数据源
slave:
# 从数据源开关/默认关闭

@ -188,7 +188,7 @@ function barChats(datas, id) {
show: false, //是否显示滑动条,不影响使用
type: "slider", // 这个 dataZoom 组件是 slider 型 dataZoom 组件
startValue: 0, // 从头开始。
endValue: 4, // 一次性展示5个。
endValue: 5, // 一次性展示6个。
},
],
xAxis: {
@ -314,7 +314,7 @@ function barChats(datas, id) {
//自动滚动
this.timeOut = setInterval(() => {
if (options.dataZoom[0].endValue == datas.data.length) {
options.dataZoom[0].endValue = 4;
options.dataZoom[0].endValue = 5;
options.dataZoom[0].startValue = 0;
} else {
options.dataZoom[0].endValue = options.dataZoom[0].endValue + 1;
@ -507,7 +507,7 @@ function lineCharts(datas, id) {
grid: {
left: 10,
top: 30,
right: 10,
right: 20,
bottom: 2,
containLabel: true,
},

Loading…
Cancel
Save