|
@ -32,7 +32,7 @@ import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Api(tags="设备状态") |
|
|
@Api(tags = "设备状态") |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/system/status") |
|
|
@RequestMapping("/system/status") |
|
|
public class StatusController extends BaseController { |
|
|
public class StatusController extends BaseController { |
|
@ -50,14 +50,16 @@ public class StatusController extends BaseController { |
|
|
|
|
|
|
|
|
//设备列表
|
|
|
//设备列表
|
|
|
@ApiOperation("设备状态列表按时间和类型") |
|
|
@ApiOperation("设备状态列表按时间和类型") |
|
|
@GetMapping ("/tablist") |
|
|
@GetMapping("/tablist") |
|
|
public TableDataInfo getTabList(Status status) |
|
|
public TableDataInfo getTabList(Status status) { |
|
|
{ |
|
|
if (status.getDeviceName() != null) { |
|
|
if (status.getDeviceName()!=null) { |
|
|
status.setDeviceName(status.getDeviceName().replaceAll(UniversalEnum.BLANK_SPACE.getValue(), UniversalEnum.PLUS_SIGN.getValue())); |
|
|
status.setDeviceName(status.getDeviceName().replaceAll(UniversalEnum.BLANK_SPACE.getValue(),UniversalEnum.PLUS_SIGN.getValue())); |
|
|
|
|
|
} |
|
|
} |
|
|
startPage(); |
|
|
startPage(); |
|
|
status.setTypes(status.getType().split(UniversalEnum.COMMA.getValue())); |
|
|
String type = status.getType(); |
|
|
|
|
|
if (type != null) { |
|
|
|
|
|
status.setTypes(type.split(UniversalEnum.COMMA.getValue())); |
|
|
|
|
|
} |
|
|
List<Status> listStatus = statusService.listStatusByTypes(status); |
|
|
List<Status> listStatus = statusService.listStatusByTypes(status); |
|
|
return getDataTable(listStatus); |
|
|
return getDataTable(listStatus); |
|
|
} |
|
|
} |
|
@ -69,12 +71,14 @@ public class StatusController extends BaseController { |
|
|
@ApiOperation("设备状态导出") |
|
|
@ApiOperation("设备状态导出") |
|
|
@Log(title = "【设备状态导出】", businessType = BusinessType.EXPORT) |
|
|
@Log(title = "【设备状态导出】", businessType = BusinessType.EXPORT) |
|
|
@PostMapping("/export") |
|
|
@PostMapping("/export") |
|
|
public void export(HttpServletResponse response, Status status) |
|
|
public void export(HttpServletResponse response, Status status) { |
|
|
{ |
|
|
if (status.getDeviceName() != null) { |
|
|
if (status.getDeviceName()!=null) { |
|
|
status.setDeviceName(status.getDeviceName().replaceAll(UniversalEnum.BLANK_SPACE.getValue(), UniversalEnum.PLUS_SIGN.getValue())); |
|
|
status.setDeviceName(status.getDeviceName().replaceAll(UniversalEnum.BLANK_SPACE.getValue(),UniversalEnum.PLUS_SIGN.getValue())); |
|
|
} |
|
|
|
|
|
String type = status.getType(); |
|
|
|
|
|
if (type != null) { |
|
|
|
|
|
status.setTypes(type.split(UniversalEnum.COMMA.getValue())); |
|
|
} |
|
|
} |
|
|
status.setTypes(status.getType().split(UniversalEnum.COMMA.getValue())); |
|
|
|
|
|
List<Status> listStatus = statusService.export(status); |
|
|
List<Status> listStatus = statusService.export(status); |
|
|
ExcelUtil<Status> util = new ExcelUtil<>(Status.class); |
|
|
ExcelUtil<Status> util = new ExcelUtil<>(Status.class); |
|
|
util.exportExcel(response, listStatus, UniversalEnum.DEVICE_STATUS_LIST.getValue()); |
|
|
util.exportExcel(response, listStatus, UniversalEnum.DEVICE_STATUS_LIST.getValue()); |
|
@ -84,26 +88,33 @@ public class StatusController extends BaseController { |
|
|
@ApiOperation("设备状态柱状图按时间和类型") |
|
|
@ApiOperation("设备状态柱状图按时间和类型") |
|
|
@GetMapping("/list") |
|
|
@GetMapping("/list") |
|
|
public AjaxResult getStatusList(Status status) { |
|
|
public AjaxResult getStatusList(Status status) { |
|
|
if (status.getDeviceName()!=null) { |
|
|
if (status.getDeviceName() != null) { |
|
|
status.setDeviceName(status.getDeviceName().replaceAll(UniversalEnum.BLANK_SPACE.getValue(),UniversalEnum.PLUS_SIGN.getValue())); |
|
|
status.setDeviceName(status.getDeviceName().replaceAll(UniversalEnum.BLANK_SPACE.getValue(), UniversalEnum.PLUS_SIGN.getValue())); |
|
|
} |
|
|
} |
|
|
LocalDateTime todayStart = status.getStartTime().truncatedTo(ChronoUnit.DAYS); |
|
|
LocalDateTime todayStart = status.getStartTime().truncatedTo(ChronoUnit.DAYS); |
|
|
LocalDateTime currentTime = status.getTime().truncatedTo(ChronoUnit.DAYS).plusDays(UniversalEnum.ONE.getNumber()); |
|
|
LocalDateTime currentTime = status.getTime().truncatedTo(ChronoUnit.DAYS).plusDays(UniversalEnum.ONE.getNumber()); |
|
|
status.setStartTime(todayStart); |
|
|
status.setStartTime(todayStart); |
|
|
status.setTime(currentTime); |
|
|
status.setTime(currentTime); |
|
|
String[] types = status.getType().split(UniversalEnum.COMMA.getValue()); |
|
|
String statusType = status.getType(); |
|
|
status.setTypes(types); |
|
|
String[] types = null; |
|
|
|
|
|
if (statusType != null) { |
|
|
|
|
|
|
|
|
|
|
|
types = statusType.split(UniversalEnum.COMMA.getValue()); |
|
|
|
|
|
status.setTypes(types); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Map<String, Map<String, String>> maps = new HashMap<>(); |
|
|
Map<String, Map<String, String>> maps = new HashMap<>(); |
|
|
List<Status> statuses = statusService.getStatusList(status); |
|
|
List<Status> statuses = statusService.getStatusList(status); |
|
|
|
|
|
|
|
|
for (String type : types) { |
|
|
if (types != null) { |
|
|
Map<String, String> collect = statuses.stream().filter(item -> Objects.equals(item.getType(), type)) |
|
|
for (String type : types) { |
|
|
.collect(Collectors.toMap( |
|
|
Map<String, String> collect = statuses.stream().filter(item -> Objects.equals(item.getType(), type)) |
|
|
item -> item.getTime().getYear() + UniversalEnum.SHORT_BAR.getValue() + item.getTime().getMonthValue() + UniversalEnum.SHORT_BAR.getValue() + item.getTime().getDayOfMonth(), |
|
|
.collect(Collectors.toMap( |
|
|
Status::getSuccessRate |
|
|
item -> item.getTime().getYear() + UniversalEnum.SHORT_BAR.getValue() + item.getTime().getMonthValue() + UniversalEnum.SHORT_BAR.getValue() + item.getTime().getDayOfMonth(), |
|
|
)); |
|
|
Status::getSuccessRate |
|
|
maps.put(type, collect); |
|
|
)); |
|
|
|
|
|
maps.put(type, collect); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return AjaxResult.success(maps); |
|
|
return AjaxResult.success(maps); |
|
|
} |
|
|
} |
|
@ -111,10 +122,9 @@ public class StatusController extends BaseController { |
|
|
|
|
|
|
|
|
//按时间划分设备柱状图
|
|
|
//按时间划分设备柱状图
|
|
|
@ApiOperation("更新缓存规则") |
|
|
@ApiOperation("更新缓存规则") |
|
|
@GetMapping ("/rule") |
|
|
@GetMapping("/rule") |
|
|
public AjaxResult setRule(String rule) |
|
|
public AjaxResult setRule(String rule) { |
|
|
{ |
|
|
redisCache.setCacheObject(ORDERRULE, rule); |
|
|
redisCache.setCacheObject(ORDERRULE,rule); |
|
|
|
|
|
return AjaxResult.success(); |
|
|
return AjaxResult.success(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -158,9 +168,8 @@ public class StatusController extends BaseController { |
|
|
|
|
|
|
|
|
//按类型划分设备
|
|
|
//按类型划分设备
|
|
|
@ApiOperation("设备状态列表按类型") |
|
|
@ApiOperation("设备状态列表按类型") |
|
|
@GetMapping ("/type") |
|
|
@GetMapping("/type") |
|
|
public AjaxResult getTypeList() |
|
|
public AjaxResult getTypeList() { |
|
|
{ |
|
|
|
|
|
//DcDevice dcDevice = new DcDevice();
|
|
|
//DcDevice dcDevice = new DcDevice();
|
|
|
//dcDevice.setUseState(1);
|
|
|
//dcDevice.setUseState(1);
|
|
|
//List<DcDevice> dcDeviceList = dcDeviceService.numberOfDevicesByType(dcDevice);
|
|
|
//List<DcDevice> dcDeviceList = dcDeviceService.numberOfDevicesByType(dcDevice);
|
|
@ -352,32 +361,32 @@ public class StatusController extends BaseController { |
|
|
//
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
//}
|
|
|
Map<Object, Object> maps=new HashMap<>(); |
|
|
Map<Object, Object> maps = new HashMap<>(); |
|
|
double lostRate = lastEntry.stream() |
|
|
double lostRate = lastEntry.stream() |
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace(UniversalEnum.PER_CENT.getValue(), UniversalEnum.EMPTY_STRING.getValue()))) // 去掉%,并转换为double
|
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace(UniversalEnum.PER_CENT.getValue(), UniversalEnum.EMPTY_STRING.getValue()))) // 去掉%,并转换为double
|
|
|
.average().getAsDouble(); |
|
|
.average().getAsDouble(); |
|
|
double sucessRate = lastEntry.stream() |
|
|
double sucessRate = lastEntry.stream() |
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace(UniversalEnum.PER_CENT.getValue(), UniversalEnum.EMPTY_STRING.getValue()))) // 去掉%,并转换为double
|
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace(UniversalEnum.PER_CENT.getValue(), UniversalEnum.EMPTY_STRING.getValue()))) // 去掉%,并转换为double
|
|
|
.average().getAsDouble(); |
|
|
.average().getAsDouble(); |
|
|
String failRate=String.format("%.2f", (UniversalEnum.ONE_HUNDRED.getNumber()-sucessRate))+UniversalEnum.PER_CENT.getValue(); |
|
|
String failRate = String.format("%.2f", (UniversalEnum.ONE_HUNDRED.getNumber() - sucessRate)) + UniversalEnum.PER_CENT.getValue(); |
|
|
//丢包率
|
|
|
//丢包率
|
|
|
maps.put("lostRate",String.format("%.2f", lostRate)+UniversalEnum.PER_CENT.getValue()); |
|
|
maps.put("lostRate", String.format("%.2f", lostRate) + UniversalEnum.PER_CENT.getValue()); |
|
|
//在线率
|
|
|
//在线率
|
|
|
maps.put("sucessRate",String.format("%.2f", sucessRate)+UniversalEnum.PER_CENT.getValue()); |
|
|
maps.put("sucessRate", String.format("%.2f", sucessRate) + UniversalEnum.PER_CENT.getValue()); |
|
|
//离线率
|
|
|
//离线率
|
|
|
maps.put("failRate",failRate); |
|
|
maps.put("failRate", failRate); |
|
|
List<DcDevice> list = dcDeviceService.list(); |
|
|
List<DcDevice> list = dcDeviceService.list(); |
|
|
//已使用数量
|
|
|
//已使用数量
|
|
|
maps.put("sumUseState",String.valueOf(lastEntry.size())); |
|
|
maps.put("sumUseState", String.valueOf(lastEntry.size())); |
|
|
//总数
|
|
|
//总数
|
|
|
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<>(); |
|
|
Map<Object, Object> ruleMap = new HashMap<>(); |
|
|
String orderRule=redisCache.getCacheObject(ORDERRULE); |
|
|
String orderRule = redisCache.getCacheObject(ORDERRULE); |
|
|
if(StringUtil.isNotEmpty(orderRule)){ |
|
|
if (StringUtil.isNotEmpty(orderRule)) { |
|
|
ruleMap.put("rule",orderRule); |
|
|
ruleMap.put("rule", orderRule); |
|
|
subMap.put("排序规则",ruleMap); |
|
|
subMap.put("排序规则", ruleMap); |
|
|
}else{ |
|
|
} else { |
|
|
String[] rules = {UniversalEnum.ALL_EQUIPMENT.getValue(), |
|
|
String[] rules = {UniversalEnum.ALL_EQUIPMENT.getValue(), |
|
|
UniversalEnum.HD_NETWORK_GUN_TYPE_FIXED_CAMERA.getValue(), |
|
|
UniversalEnum.HD_NETWORK_GUN_TYPE_FIXED_CAMERA.getValue(), |
|
|
UniversalEnum.HD_NETWORK_SPHERICAL_CAMERA.getValue(), |
|
|
UniversalEnum.HD_NETWORK_SPHERICAL_CAMERA.getValue(), |
|
@ -400,9 +409,9 @@ public class StatusController extends BaseController { |
|
|
UniversalEnum.SOLAR_PANEL.getValue(), |
|
|
UniversalEnum.SOLAR_PANEL.getValue(), |
|
|
UniversalEnum.REMOTE_COMPUTER.getValue() |
|
|
UniversalEnum.REMOTE_COMPUTER.getValue() |
|
|
}; |
|
|
}; |
|
|
orderRule= Arrays.toString(rules).replace(UniversalEnum.LEFT_CENTER_BRACKET.getValue(),UniversalEnum.EMPTY_STRING.getValue()).replace(UniversalEnum.CLOSE_CENTER_BRACKET.getValue(),UniversalEnum.EMPTY_STRING.getValue()).replace(UniversalEnum.BLANK_SPACE.getValue(),UniversalEnum.EMPTY_STRING.getValue()); |
|
|
orderRule = Arrays.toString(rules).replace(UniversalEnum.LEFT_CENTER_BRACKET.getValue(), UniversalEnum.EMPTY_STRING.getValue()).replace(UniversalEnum.CLOSE_CENTER_BRACKET.getValue(), UniversalEnum.EMPTY_STRING.getValue()).replace(UniversalEnum.BLANK_SPACE.getValue(), UniversalEnum.EMPTY_STRING.getValue()); |
|
|
ruleMap.put("rule",orderRule); |
|
|
ruleMap.put("rule", orderRule); |
|
|
subMap.put("排序规则",ruleMap); |
|
|
subMap.put("排序规则", ruleMap); |
|
|
} |
|
|
} |
|
|
return AjaxResult.success(subMap); |
|
|
return AjaxResult.success(subMap); |
|
|
} |
|
|
} |
|
|