|
@ -1,8 +1,10 @@ |
|
|
package com.zc.business.controller; |
|
|
package com.zc.business.controller; |
|
|
|
|
|
import com.github.pagehelper.util.StringUtil; |
|
|
import com.ruoyi.common.annotation.Log; |
|
|
import com.ruoyi.common.annotation.Log; |
|
|
import com.ruoyi.common.core.controller.BaseController; |
|
|
import com.ruoyi.common.core.controller.BaseController; |
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
|
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.enums.BusinessType; |
|
|
import com.ruoyi.common.enums.BusinessType; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
@ -15,6 +17,7 @@ import io.swagger.annotations.ApiOperation; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.temporal.ChronoUnit; |
|
|
import java.time.temporal.ChronoUnit; |
|
@ -31,6 +34,10 @@ public class StatusController extends BaseController { |
|
|
private StatusService statusService; |
|
|
private StatusService statusService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private DcDeviceServiceImpl dcDeviceService; |
|
|
private DcDeviceServiceImpl dcDeviceService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private RedisCache redisCache; |
|
|
|
|
|
|
|
|
|
|
|
private static final String ORDERRULE = "orderRule";//排序策略key
|
|
|
|
|
|
|
|
|
//设备列表
|
|
|
//设备列表
|
|
|
@ApiOperation("设备状态列表按时间和类型") |
|
|
@ApiOperation("设备状态列表按时间和类型") |
|
@ -95,6 +102,16 @@ public class StatusController extends BaseController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//按时间划分设备柱状图
|
|
|
|
|
|
@ApiOperation("更新缓存规则") |
|
|
|
|
|
@GetMapping ("/rule") |
|
|
|
|
|
public AjaxResult setRule(String rule) |
|
|
|
|
|
{ |
|
|
|
|
|
redisCache.setCacheSetValue(ORDERRULE,rule); |
|
|
|
|
|
return AjaxResult.success(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("根据设备Id查询折线图数据") |
|
|
@ApiOperation("根据设备Id查询折线图数据") |
|
|
@GetMapping("/deviceStatusList/{deviceId}") |
|
|
@GetMapping("/deviceStatusList/{deviceId}") |
|
|
public AjaxResult getDeviceStatusList(@PathVariable Long deviceId) { |
|
|
public AjaxResult getDeviceStatusList(@PathVariable Long deviceId) { |
|
@ -251,11 +268,11 @@ public class StatusController extends BaseController { |
|
|
Integer lastKey = Collections.max(ipMap.keySet()); |
|
|
Integer lastKey = Collections.max(ipMap.keySet()); |
|
|
List<Status> lastEntry = ipMap.get(lastKey); |
|
|
List<Status> lastEntry = ipMap.get(lastKey); |
|
|
Map<String, List<Status>> typeMap = lastEntry.stream().filter(iteam -> iteam.getType() != null).collect(Collectors.groupingBy(Status::getType)); |
|
|
Map<String, List<Status>> typeMap = lastEntry.stream().filter(iteam -> iteam.getType() != null).collect(Collectors.groupingBy(Status::getType)); |
|
|
Map<String, Map<String, String>> subMap = new HashMap<>(); |
|
|
Map<String, Map<Object, Object>> subMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
itemTypeMap.forEach((key, value) -> { |
|
|
itemTypeMap.forEach((key, value) -> { |
|
|
|
|
|
|
|
|
Map<String, String> maps = new HashMap<>(); |
|
|
Map<Object, Object> maps = new HashMap<>(); |
|
|
List<Status> groupItems = typeMap.get(key); |
|
|
List<Status> groupItems = typeMap.get(key); |
|
|
if (groupItems == null) { |
|
|
if (groupItems == null) { |
|
|
//丢包率
|
|
|
//丢包率
|
|
@ -317,7 +334,7 @@ public class StatusController extends BaseController { |
|
|
//
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
//}
|
|
|
Map<String, String> maps=new HashMap<>(); |
|
|
Map<Object, Object> maps=new HashMap<>(); |
|
|
double lostRate = lastEntry.stream() |
|
|
double lostRate = lastEntry.stream() |
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
.average().getAsDouble(); |
|
|
.average().getAsDouble(); |
|
@ -337,7 +354,19 @@ public class StatusController extends BaseController { |
|
|
//总数
|
|
|
//总数
|
|
|
maps.put("sum",String.valueOf(list.size())); |
|
|
maps.put("sum",String.valueOf(list.size())); |
|
|
subMap.put("全部设备",maps); |
|
|
subMap.put("全部设备",maps); |
|
|
|
|
|
// Map<Object, Object> ruleMap=new HashMap<>();
|
|
|
|
|
|
// String orderRule=redisCache.getCacheObject(ORDERRULE);
|
|
|
|
|
|
// if(StringUtil.isNotEmpty(orderRule)){
|
|
|
|
|
|
// ruleMap.put("rule",orderRule);
|
|
|
|
|
|
// subMap.put("排序规则",ruleMap);
|
|
|
|
|
|
// }else{
|
|
|
|
|
|
// String[] rules = {"全部设备","高清网络枪型固定摄像机","高清网络球形摄像机","桥下高清网络球形摄像机","360°全景摄像机","180°全景摄像机",
|
|
|
|
|
|
// "门架式可变信息标志","雨棚可变信息标志","站前悬臂式可变信息标志","气象检测器","路段语音广播系统","护栏碰撞预警系统","毫米波雷达",
|
|
|
|
|
|
// "合流区预警系统","激光疲劳唤醒","一类交通量调查站","智能行车诱导系统"};
|
|
|
|
|
|
// orderRule= Arrays.toString(rules);
|
|
|
|
|
|
// ruleMap.put("rule",orderRule);
|
|
|
|
|
|
// subMap.put("排序规则",ruleMap);
|
|
|
|
|
|
// }
|
|
|
return AjaxResult.success(subMap); |
|
|
return AjaxResult.success(subMap); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|