|
@@ -5,6 +5,7 @@ import com.ruoyi.common.core.web.controller.BaseController;
|
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
|
import com.ruoyi.common.security.utils.DictUtils;
|
|
import com.ruoyi.common.security.utils.DictUtils;
|
|
|
|
|
+import com.sooka.sponest.construction.api.vo.DeviceEventAlarmVO;
|
|
|
import com.sooka.sponest.construction.api.vo.DeviceListVO;
|
|
import com.sooka.sponest.construction.api.vo.DeviceListVO;
|
|
|
import com.sooka.sponest.construction.api.vo.DeviceSummaryVO;
|
|
import com.sooka.sponest.construction.api.vo.DeviceSummaryVO;
|
|
|
import com.sooka.sponest.construction.api.vo.DeviceTypeVO;
|
|
import com.sooka.sponest.construction.api.vo.DeviceTypeVO;
|
|
@@ -12,6 +13,9 @@ import com.sooka.sponest.construction.bridge.domain.BridgeDevice;
|
|
|
import com.sooka.sponest.construction.bridge.service.IBridgeDeviceService;
|
|
import com.sooka.sponest.construction.bridge.service.IBridgeDeviceService;
|
|
|
import com.sooka.sponest.construction.drainage.domain.DrainageDeviceBaseInfoData;
|
|
import com.sooka.sponest.construction.drainage.domain.DrainageDeviceBaseInfoData;
|
|
|
import com.sooka.sponest.construction.drainage.service.IDrainageDeviceBaseInfoDataService;
|
|
import com.sooka.sponest.construction.drainage.service.IDrainageDeviceBaseInfoDataService;
|
|
|
|
|
+import com.sooka.sponest.construction.event.domain.BO.EventSubjectBO;
|
|
|
|
|
+import com.sooka.sponest.construction.event.domain.VO.EventSubjectQueryVO;
|
|
|
|
|
+import com.sooka.sponest.construction.event.service.EventSubjectService;
|
|
|
import com.sooka.sponest.construction.gas.domain.GasDeviceBaseInfoData;
|
|
import com.sooka.sponest.construction.gas.domain.GasDeviceBaseInfoData;
|
|
|
import com.sooka.sponest.construction.gas.service.IGasDeviceBaseInfoDataService;
|
|
import com.sooka.sponest.construction.gas.service.IGasDeviceBaseInfoDataService;
|
|
|
import com.sooka.sponest.construction.heating.domain.HeatingDevice;
|
|
import com.sooka.sponest.construction.heating.domain.HeatingDevice;
|
|
@@ -22,11 +26,14 @@ import com.sooka.sponest.construction.waterSupply.domain.WaterSupplyDeviceBaseIn
|
|
|
import com.sooka.sponest.construction.waterSupply.service.IWaterSupplyDeviceBaseInfoService;
|
|
import com.sooka.sponest.construction.waterSupply.service.IWaterSupplyDeviceBaseInfoService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+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.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.function.BiFunction;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@RestController
|
|
@RestController
|
|
@@ -51,6 +58,9 @@ public class PlatformDeviceApi extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IUtilityTunnelDeviceService utilityTunnelDeviceService;
|
|
private IUtilityTunnelDeviceService utilityTunnelDeviceService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private EventSubjectService eventSubjectService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 设备汇总接口
|
|
* 设备汇总接口
|
|
|
*/
|
|
*/
|
|
@@ -58,6 +68,15 @@ public class PlatformDeviceApi extends BaseController {
|
|
|
public AjaxResult getDeviceSummary(@RequestParam(value = "industry", required = true) int industry) {
|
|
public AjaxResult getDeviceSummary(@RequestParam(value = "industry", required = true) int industry) {
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
+ // 行业名称映射
|
|
|
|
|
+ Map<Integer, String> industryNameMap = new HashMap<>();
|
|
|
|
|
+ industryNameMap.put(1, "燃气");
|
|
|
|
|
+ industryNameMap.put(2, "排水");
|
|
|
|
|
+ industryNameMap.put(3, "供热");
|
|
|
|
|
+ industryNameMap.put(4, "桥梁");
|
|
|
|
|
+ industryNameMap.put(5, "供水");
|
|
|
|
|
+ industryNameMap.put(6, "管廊");
|
|
|
|
|
+
|
|
|
Map<Integer, Supplier<List<DeviceSummaryVO>>> serviceMap = new HashMap<>();
|
|
Map<Integer, Supplier<List<DeviceSummaryVO>>> serviceMap = new HashMap<>();
|
|
|
serviceMap.put(1, () -> this.gasDeviceBaseInfoDataService.getDeviceSummary());
|
|
serviceMap.put(1, () -> this.gasDeviceBaseInfoDataService.getDeviceSummary());
|
|
|
serviceMap.put(2, () -> this.drainageDeviceBaseInfoDataService.getDeviceSummary());
|
|
serviceMap.put(2, () -> this.drainageDeviceBaseInfoDataService.getDeviceSummary());
|
|
@@ -68,8 +87,16 @@ public class PlatformDeviceApi extends BaseController {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
if (serviceMap.containsKey(industry)) {
|
|
if (serviceMap.containsKey(industry)) {
|
|
|
|
|
+ // 查询指定行业的真实数据
|
|
|
List<DeviceSummaryVO> tempList = serviceMap.get(industry).get();
|
|
List<DeviceSummaryVO> tempList = serviceMap.get(industry).get();
|
|
|
deviceSummaryVO2List(tempList, list);
|
|
deviceSummaryVO2List(tempList, list);
|
|
|
|
|
+ // 为其他行业添加零值数据
|
|
|
|
|
+ for (Map.Entry<Integer, String> entry : industryNameMap.entrySet()) {
|
|
|
|
|
+ if (!entry.getKey().equals(industry)) {
|
|
|
|
|
+ Map<String, Object> zeroMap = createZeroDeviceSummary(entry.getValue());
|
|
|
|
|
+ list.add(zeroMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
// 默认查询所有行业
|
|
// 默认查询所有行业
|
|
|
for (Supplier<List<DeviceSummaryVO>> supplier : serviceMap.values()) {
|
|
for (Supplier<List<DeviceSummaryVO>> supplier : serviceMap.values()) {
|
|
@@ -81,7 +108,6 @@ public class PlatformDeviceApi extends BaseController {
|
|
|
log.error("获取设备汇总信息异常: ", e);
|
|
log.error("获取设备汇总信息异常: ", e);
|
|
|
return AjaxResult.error("系统异常,请稍后再试");
|
|
return AjaxResult.error("系统异常,请稍后再试");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return AjaxResult.success(list);
|
|
return AjaxResult.success(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -107,6 +133,22 @@ public class PlatformDeviceApi extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 创建零值设备汇总数据
|
|
|
|
|
+ * @param industryName 行业名称
|
|
|
|
|
+ * @return 包含零值数据的Map
|
|
|
|
|
+ */
|
|
|
|
|
+ private Map<String, Object> createZeroDeviceSummary(String industryName) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("industryName", industryName);
|
|
|
|
|
+ map.put("deviceTotal", "0");
|
|
|
|
|
+ map.put("onlineCount", "0");
|
|
|
|
|
+ map.put("offlineCount", "0");
|
|
|
|
|
+ map.put("onlinePercent", "0%");
|
|
|
|
|
+ map.put("offlinePercent", "0%");
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 设备类型接口
|
|
* 设备类型接口
|
|
|
*/
|
|
*/
|
|
|
@RequestMapping("/getDeviceType")
|
|
@RequestMapping("/getDeviceType")
|
|
@@ -189,115 +231,451 @@ public class PlatformDeviceApi extends BaseController {
|
|
|
@RequestMapping("/getDeviceList")
|
|
@RequestMapping("/getDeviceList")
|
|
|
public TableDataInfo getDeviceList(@RequestParam(value = "industry", required = true) int industry) {
|
|
public TableDataInfo getDeviceList(@RequestParam(value = "industry", required = true) int industry) {
|
|
|
List<DeviceListVO> list = new ArrayList<>();
|
|
List<DeviceListVO> list = new ArrayList<>();
|
|
|
|
|
+
|
|
|
switch(industry) {
|
|
switch(industry) {
|
|
|
case 1:
|
|
case 1:
|
|
|
- List<GasDeviceBaseInfoData> gasDeviceBaseInfoDataList = this.gasDeviceBaseInfoDataService.selectGasDeviceBaseInfoDataList(new GasDeviceBaseInfoData());
|
|
|
|
|
- for(GasDeviceBaseInfoData gasDeviceBaseInfoData : gasDeviceBaseInfoDataList) {
|
|
|
|
|
- DeviceListVO deviceListVO = new DeviceListVO();
|
|
|
|
|
- deviceListVO.setIndustryName("燃气");
|
|
|
|
|
- deviceListVO.setDeviceName(gasDeviceBaseInfoData.getDeviceName());
|
|
|
|
|
- deviceListVO.setLongitude(gasDeviceBaseInfoData.getLng());
|
|
|
|
|
- deviceListVO.setLatitude(gasDeviceBaseInfoData.getLat());
|
|
|
|
|
- if(gasDeviceBaseInfoData.getOnlineStatus().equals("1")) {
|
|
|
|
|
- deviceListVO.setOnlineStatus("在线");
|
|
|
|
|
- } else {
|
|
|
|
|
- deviceListVO.setOnlineStatus("离线");
|
|
|
|
|
- }
|
|
|
|
|
- list.add(deviceListVO);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ list = getGasDeviceList();
|
|
|
break;
|
|
break;
|
|
|
case 2:
|
|
case 2:
|
|
|
- List<DrainageDeviceBaseInfoData> drainageDeviceBaseInfoDataList = this.drainageDeviceBaseInfoDataService.selectDrainageDeviceBaseInfoDataList(new DrainageDeviceBaseInfoData());
|
|
|
|
|
- for(DrainageDeviceBaseInfoData drainageDeviceBaseInfoData : drainageDeviceBaseInfoDataList) {
|
|
|
|
|
- DeviceListVO deviceListVO = new DeviceListVO();
|
|
|
|
|
- deviceListVO.setIndustryName("排水");
|
|
|
|
|
- deviceListVO.setDeviceName(drainageDeviceBaseInfoData.getDeviceName());
|
|
|
|
|
- deviceListVO.setLongitude(drainageDeviceBaseInfoData.getLongitude());
|
|
|
|
|
- deviceListVO.setLatitude(drainageDeviceBaseInfoData.getLatitude());
|
|
|
|
|
- if (drainageDeviceBaseInfoData.getOnlineStatus().equals("1")) {
|
|
|
|
|
- deviceListVO.setOnlineStatus("在线");
|
|
|
|
|
- } else {
|
|
|
|
|
- deviceListVO.setOnlineStatus("离线");
|
|
|
|
|
- }
|
|
|
|
|
- list.add(deviceListVO);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ list = getDrainageDeviceList();
|
|
|
break;
|
|
break;
|
|
|
case 3:
|
|
case 3:
|
|
|
- List<HeatingDevice> heatingDeviceList = this.heatingDeviceService.selectDeviceList(new HeatingDevice());
|
|
|
|
|
- for(HeatingDevice heatingDevice : heatingDeviceList) {
|
|
|
|
|
- DeviceListVO deviceListVO = new DeviceListVO();
|
|
|
|
|
- deviceListVO.setIndustryName("供热");
|
|
|
|
|
- deviceListVO.setDeviceName(heatingDevice.getDeviceName());
|
|
|
|
|
- deviceListVO.setLongitude(heatingDevice.getLongitude());
|
|
|
|
|
- deviceListVO.setLatitude(heatingDevice.getLatitude());
|
|
|
|
|
- if (heatingDevice.getOnlineStatus().equals("1")) {
|
|
|
|
|
- deviceListVO.setOnlineStatus("在线");
|
|
|
|
|
- } else {
|
|
|
|
|
- deviceListVO.setOnlineStatus("离线");
|
|
|
|
|
- }
|
|
|
|
|
- list.add(deviceListVO);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ list = getHeatingDeviceList();
|
|
|
break;
|
|
break;
|
|
|
case 4:
|
|
case 4:
|
|
|
- List<BridgeDevice> bridgeDeviceList = this.bridgeDeviceService.selectDeviceList(new BridgeDevice());
|
|
|
|
|
- for(BridgeDevice bridgeDevice : bridgeDeviceList) {
|
|
|
|
|
- DeviceListVO deviceListVO = new DeviceListVO();
|
|
|
|
|
- deviceListVO.setIndustryName("桥梁");
|
|
|
|
|
- deviceListVO.setDeviceName(bridgeDevice.getDeviceName());
|
|
|
|
|
- deviceListVO.setLongitude(bridgeDevice.getLongitude());
|
|
|
|
|
- deviceListVO.setLatitude(bridgeDevice.getLatitude());
|
|
|
|
|
- if (bridgeDevice.getOnlineStatus().equals("1")) {
|
|
|
|
|
- deviceListVO.setOnlineStatus("在线");
|
|
|
|
|
- } else {
|
|
|
|
|
- deviceListVO.setOnlineStatus("离线");
|
|
|
|
|
- }
|
|
|
|
|
- list.add(deviceListVO);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ list = getBridgeDeviceList();
|
|
|
break;
|
|
break;
|
|
|
case 5:
|
|
case 5:
|
|
|
- List<WaterSupplyDeviceBaseInfo> waterSupplyDeviceBaseInfoList = this.waterSupplyDeviceBaseInfoService.selectWaterSupplyDeviceBaseInfoList(new WaterSupplyDeviceBaseInfo());
|
|
|
|
|
- for(WaterSupplyDeviceBaseInfo waterSupplyDeviceBaseInfo : waterSupplyDeviceBaseInfoList) {
|
|
|
|
|
- DeviceListVO deviceListVO = new DeviceListVO();
|
|
|
|
|
- deviceListVO.setIndustryName("供水");
|
|
|
|
|
- deviceListVO.setDeviceName(waterSupplyDeviceBaseInfo.getDeviceName());
|
|
|
|
|
- deviceListVO.setLongitude(waterSupplyDeviceBaseInfo.getLng());
|
|
|
|
|
- deviceListVO.setLatitude(waterSupplyDeviceBaseInfo.getLat());
|
|
|
|
|
- if (waterSupplyDeviceBaseInfo.getOnlineStatus().equals("1")) {
|
|
|
|
|
- deviceListVO.setOnlineStatus("在线");
|
|
|
|
|
- } else {
|
|
|
|
|
- deviceListVO.setOnlineStatus("离线");
|
|
|
|
|
- }
|
|
|
|
|
- list.add(deviceListVO);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ list = getWaterSupplyDeviceList();
|
|
|
break;
|
|
break;
|
|
|
case 6:
|
|
case 6:
|
|
|
- List<UtilityTunnelDevice> utilityTunnelDeviceList = this.utilityTunnelDeviceService.selectDeviceList(new UtilityTunnelDevice());
|
|
|
|
|
- for(UtilityTunnelDevice utilityTunnelDevice : utilityTunnelDeviceList) {
|
|
|
|
|
- DeviceListVO deviceListVO = new DeviceListVO();
|
|
|
|
|
- deviceListVO.setIndustryName("管廊");
|
|
|
|
|
- deviceListVO.setDeviceName(utilityTunnelDevice.getDeviceName());
|
|
|
|
|
- deviceListVO.setLongitude(utilityTunnelDevice.getLongitude());
|
|
|
|
|
- deviceListVO.setLatitude(utilityTunnelDevice.getLatitude());
|
|
|
|
|
- if (utilityTunnelDevice.getOnlineStatus().equals("1")) {
|
|
|
|
|
- deviceListVO.setOnlineStatus("在线");
|
|
|
|
|
- } else {
|
|
|
|
|
- deviceListVO.setOnlineStatus("离线");
|
|
|
|
|
- }
|
|
|
|
|
- list.add(deviceListVO);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ list = getUtilityTunnelDeviceList();
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 获取燃气设备列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<DeviceListVO> getGasDeviceList() {
|
|
|
|
|
+ List<GasDeviceBaseInfoData> dataList = gasDeviceBaseInfoDataService.selectGasDeviceBaseInfoDataList(new GasDeviceBaseInfoData());
|
|
|
|
|
+ return dataList.stream()
|
|
|
|
|
+ .map(device -> createDeviceListVO("燃气", device.getDeviceName(),
|
|
|
|
|
+ device.getLng(), device.getLat(), device.getOnlineStatus()))
|
|
|
|
|
+ .collect(java.util.stream.Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取排水设备列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<DeviceListVO> getDrainageDeviceList() {
|
|
|
|
|
+ List<DrainageDeviceBaseInfoData> dataList = drainageDeviceBaseInfoDataService.selectDrainageDeviceBaseInfoDataList(new DrainageDeviceBaseInfoData());
|
|
|
|
|
+ return dataList.stream()
|
|
|
|
|
+ .map(device -> createDeviceListVO("排水", device.getDeviceName(),
|
|
|
|
|
+ device.getLongitude(), device.getLatitude(), device.getOnlineStatus()))
|
|
|
|
|
+ .collect(java.util.stream.Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取供热设备列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<DeviceListVO> getHeatingDeviceList() {
|
|
|
|
|
+ List<HeatingDevice> dataList = heatingDeviceService.selectDeviceList(new HeatingDevice());
|
|
|
|
|
+ return dataList.stream()
|
|
|
|
|
+ .map(device -> createDeviceListVO("供热", device.getDeviceName(),
|
|
|
|
|
+ device.getLongitude(), device.getLatitude(), device.getOnlineStatus()))
|
|
|
|
|
+ .collect(java.util.stream.Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取桥梁设备列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<DeviceListVO> getBridgeDeviceList() {
|
|
|
|
|
+ List<BridgeDevice> dataList = bridgeDeviceService.selectDeviceList(new BridgeDevice());
|
|
|
|
|
+ return dataList.stream()
|
|
|
|
|
+ .map(device -> createDeviceListVO("桥梁", device.getDeviceName(),
|
|
|
|
|
+ device.getLongitude(), device.getLatitude(), device.getOnlineStatus()))
|
|
|
|
|
+ .collect(java.util.stream.Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取供水设备列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<DeviceListVO> getWaterSupplyDeviceList() {
|
|
|
|
|
+ List<WaterSupplyDeviceBaseInfo> dataList = waterSupplyDeviceBaseInfoService.selectWaterSupplyDeviceBaseInfoList(new WaterSupplyDeviceBaseInfo());
|
|
|
|
|
+ return dataList.stream()
|
|
|
|
|
+ .map(device -> createDeviceListVO("供水", device.getDeviceName(),
|
|
|
|
|
+ device.getLng(), device.getLat(), device.getOnlineStatus()))
|
|
|
|
|
+ .collect(java.util.stream.Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取管廊设备列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<DeviceListVO> getUtilityTunnelDeviceList() {
|
|
|
|
|
+ List<UtilityTunnelDevice> dataList = utilityTunnelDeviceService.selectDeviceList(new UtilityTunnelDevice());
|
|
|
|
|
+ return dataList.stream()
|
|
|
|
|
+ .map(device -> createDeviceListVO("管廊", device.getDeviceName(),
|
|
|
|
|
+ device.getLongitude(), device.getLatitude(), device.getOnlineStatus()))
|
|
|
|
|
+ .collect(java.util.stream.Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 创建设备列表VO对象
|
|
|
|
|
+ * @param industryName 行业名称
|
|
|
|
|
+ * @param deviceName 设备名称
|
|
|
|
|
+ * @param longitude 经度
|
|
|
|
|
+ * @param latitude 纬度
|
|
|
|
|
+ * @param onlineStatus 在线状态
|
|
|
|
|
+ * @return DeviceListVO对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private DeviceListVO createDeviceListVO(String industryName, String deviceName,
|
|
|
|
|
+ String longitude, String latitude, String onlineStatus) {
|
|
|
|
|
+ DeviceListVO vo = new DeviceListVO();
|
|
|
|
|
+ vo.setIndustryName(industryName);
|
|
|
|
|
+ vo.setDeviceName(deviceName);
|
|
|
|
|
+ vo.setLongitude(longitude);
|
|
|
|
|
+ vo.setLatitude(latitude);
|
|
|
|
|
+ vo.setOnlineStatus("1".equals(onlineStatus) ? "在线" : "离线");
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 设备运行状态接口
|
|
* 设备运行状态接口
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 设备报警接口
|
|
* 设备报警接口
|
|
|
*/
|
|
*/
|
|
|
|
|
+ @RequestMapping("/deviceAlarm")
|
|
|
|
|
+ public AjaxResult deviceAlarm(@RequestParam(value = "timegran", required = true) int timegran,
|
|
|
|
|
+ @RequestParam(value = "industry", required = true) int industry) {
|
|
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
|
+ // 定义行业信息映射
|
|
|
|
|
+ Map<Integer, IndustryInfo> industryMap = new HashMap<>();
|
|
|
|
|
+ industryMap.put(1, new IndustryInfo("燃气", "gas_device_type", gasDeviceBaseInfoDataService::getDeviceEventAlarmList));
|
|
|
|
|
+ industryMap.put(2, new IndustryInfo("排水", "drainage_device_type", drainageDeviceBaseInfoDataService::getDeviceEventAlarmList));
|
|
|
|
|
+ industryMap.put(3, new IndustryInfo("供热", "heating_device_type", heatingDeviceService::getDeviceEventAlarmList));
|
|
|
|
|
+ industryMap.put(4, new IndustryInfo("桥梁", "bridge_device_type", bridgeDeviceService::getDeviceEventAlarmList));
|
|
|
|
|
+ industryMap.put(5, new IndustryInfo("供水", "water_device_type", waterSupplyDeviceBaseInfoService::getDeviceEventAlarmList));
|
|
|
|
|
+ industryMap.put(6, new IndustryInfo("管廊", "utilitytunnel_device_type", utilityTunnelDeviceService::getDeviceEventAlarmList));
|
|
|
|
|
+ if (!industryMap.containsKey(industry)) {
|
|
|
|
|
+ return AjaxResult.success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ IndustryInfo info = industryMap.get(industry);
|
|
|
|
|
+ try {
|
|
|
|
|
+ switch (timegran) {
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ // 按照周统计
|
|
|
|
|
+ processWeeklyData(info, result);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ // 按照月统计
|
|
|
|
|
+ processMonthlyData(info, result);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ // 按照季统计
|
|
|
|
|
+ processQuarterlyData(info, result);
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ // 按照年统计
|
|
|
|
|
+ processYearlyData(info, result);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("获取设备报警信息异常: industry={}, timegran={}", industry, timegran, e);
|
|
|
|
|
+ return AjaxResult.error("系统异常,请稍后再试");
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success(result);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 行业信息封装类
|
|
|
|
|
+ */
|
|
|
|
|
+ private static class IndustryInfo {
|
|
|
|
|
+ private final String industryName;
|
|
|
|
|
+ private final String dictType;
|
|
|
|
|
+ private final BiFunction<String, String, List<DeviceEventAlarmVO>> dataFetcher;
|
|
|
|
|
+ public IndustryInfo(String industryName, String dictType,
|
|
|
|
|
+ BiFunction<String, String, List<DeviceEventAlarmVO>> dataFetcher) {
|
|
|
|
|
+ this.industryName = industryName;
|
|
|
|
|
+ this.dictType = dictType;
|
|
|
|
|
+ this.dataFetcher = dataFetcher;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理周统计数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private void processWeeklyData(IndustryInfo info, List<Map<String, Object>> result) {
|
|
|
|
|
+ List<Map<String, String>> list = getOneWeekDatesInfo();
|
|
|
|
|
+ for (Map<String, String> map : list) {
|
|
|
|
|
+ List<DeviceEventAlarmVO> tempList = info.dataFetcher.apply(map.get("date"), map.get("date"));
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("industryName", info.industryName);
|
|
|
|
|
+ item.put("date", map.get("date"));
|
|
|
|
|
+ item.put("dayOfWeek", map.get("dayOfWeek"));
|
|
|
|
|
+ List<DeviceEventAlarmVO> resultList = buildResultList(tempList, info.dictType);
|
|
|
|
|
+ item.put("dataList", resultList);
|
|
|
|
|
+ result.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理月统计数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private void processMonthlyData(IndustryInfo info, List<Map<String, Object>> result) {
|
|
|
|
|
+ List<String> mdlist = getCurrentMonthDates();
|
|
|
|
|
+ for (String date : mdlist) {
|
|
|
|
|
+ List<DeviceEventAlarmVO> tempList = info.dataFetcher.apply(date, date);
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("industryName", info.industryName);
|
|
|
|
|
+ item.put("date", date);
|
|
|
|
|
+ List<DeviceEventAlarmVO> resultList = buildResultList(tempList, info.dictType);
|
|
|
|
|
+ item.put("dataList", resultList);
|
|
|
|
|
+ result.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理季度统计数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private void processQuarterlyData(IndustryInfo info, List<Map<String, Object>> result) {
|
|
|
|
|
+ List<Map<String, String>> yqlist = getPreviousFourQuarters();
|
|
|
|
|
+ for (Map<String, String> map : yqlist) {
|
|
|
|
|
+ List<DeviceEventAlarmVO> tempList = info.dataFetcher.apply(map.get("startDate"), map.get("endDate"));
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("industryName", info.industryName);
|
|
|
|
|
+ item.put("name", map.get("name"));
|
|
|
|
|
+ List<DeviceEventAlarmVO> resultList = buildResultList(tempList, info.dictType);
|
|
|
|
|
+ item.put("dataList", resultList);
|
|
|
|
|
+ result.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理年度统计数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private void processYearlyData(IndustryInfo info, List<Map<String, Object>> result) {
|
|
|
|
|
+ List<Map<String, String>> ymlist = getCurrentYearMonths();
|
|
|
|
|
+ for (Map<String, String> map : ymlist) {
|
|
|
|
|
+ List<DeviceEventAlarmVO> tempList = info.dataFetcher.apply(map.get("startDate"), map.get("endDate"));
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("industryName", info.industryName);
|
|
|
|
|
+ item.put("name", map.get("name"));
|
|
|
|
|
+ List<DeviceEventAlarmVO> resultList = buildResultList(tempList, info.dictType);
|
|
|
|
|
+ item.put("dataList", resultList);
|
|
|
|
|
+ result.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建结果列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<DeviceEventAlarmVO> buildResultList(List<DeviceEventAlarmVO> sourceList, String dictType) {
|
|
|
|
|
+ List<DeviceEventAlarmVO> resultList = new ArrayList<>();
|
|
|
|
|
+ if (sourceList != null) {
|
|
|
|
|
+ for (DeviceEventAlarmVO vo : sourceList) {
|
|
|
|
|
+ DeviceEventAlarmVO resultVO = new DeviceEventAlarmVO();
|
|
|
|
|
+ resultVO.setDeviceType(DictUtils.getDictDataByValue(dictType, vo.getDeviceType()));
|
|
|
|
|
+ resultVO.setTypeCount(vo.getTypeCount());
|
|
|
|
|
+ resultList.add(resultVO);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return resultList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据当前日期返回向前推一周的每一天日期和星期几
|
|
|
|
|
+ * @return 包含一周内每天日期和星期信息的List
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<Map<String, String>> getOneWeekDatesInfo() {
|
|
|
|
|
+ List<Map<String, String>> result = new ArrayList<>();
|
|
|
|
|
+ // 获取当前日期
|
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
|
+ // 向前推一周
|
|
|
|
|
+ calendar.add(Calendar.WEEK_OF_YEAR, -1);
|
|
|
|
|
+ // 格式化日期
|
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ // 星期数组
|
|
|
|
|
+ String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
|
|
|
|
|
+ // 循环7天,获取一周内的每一天
|
|
|
|
|
+ for (int i = 0; i < 8; i++) {
|
|
|
|
|
+ Map<String, String> dayInfo = new HashMap<>();
|
|
|
|
|
+ // 获取当前日期字符串
|
|
|
|
|
+ String dateStr = dateFormat.format(calendar.getTime());
|
|
|
|
|
+ // 获取星期几
|
|
|
|
|
+ int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
|
|
|
|
+ String dayOfWeekStr = weekDays[dayOfWeek];
|
|
|
|
|
+ dayInfo.put("date", dateStr);
|
|
|
|
|
+ dayInfo.put("dayOfWeek", dayOfWeekStr);
|
|
|
|
|
+ result.add(dayInfo);
|
|
|
|
|
+ // 日期加一天
|
|
|
|
|
+ calendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据当前日期返回当月每一天的日期列表
|
|
|
|
|
+ * @return 包含当月每天日期的List
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<String> getCurrentMonthDates() {
|
|
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
|
|
+ // 获取当前日期
|
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
|
+ // 设置为当前月的第一天
|
|
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
+ // 格式化日期
|
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ // 获取当前月的最大天数
|
|
|
|
|
+ int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
|
|
|
+ // 循环添加当月每一天
|
|
|
|
|
+ for (int i = 1; i <= maxDay; i++) {
|
|
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, i);
|
|
|
|
|
+ result.add(dateFormat.format(calendar.getTime()));
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据当前日期向前推出四个季度,返回每个季度的名称和开始结束日期
|
|
|
|
|
+ * @return 包含四个季度信息的List
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<Map<String, String>> getPreviousFourQuarters() {
|
|
|
|
|
+ List<Map<String, String>> result = new ArrayList<>();
|
|
|
|
|
+ // 获取当前日期
|
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
|
+ // 格式化日期
|
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ // 季度名称数组
|
|
|
|
|
+ String[] quarterNames = {"春季", "夏季", "秋季", "冬季"};
|
|
|
|
|
+ // 计算当前季度
|
|
|
|
|
+ int currentMonth = calendar.get(Calendar.MONTH) + 1; // 月份从0开始,需要+1
|
|
|
|
|
+ int currentQuarter = (currentMonth - 1) / 3 + 1;
|
|
|
|
|
+ // 获取当前年份
|
|
|
|
|
+ int currentYear = calendar.get(Calendar.YEAR);
|
|
|
|
|
+ // 向前推四个季度
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) {
|
|
|
|
|
+ Map<String, String> quarterInfo = new HashMap<>();
|
|
|
|
|
+ // 计算目标季度和年份
|
|
|
|
|
+ int targetQuarter = currentQuarter - i;
|
|
|
|
|
+ int targetYear = currentYear;
|
|
|
|
|
+ // 处理跨年情况
|
|
|
|
|
+ while (targetQuarter <= 0) {
|
|
|
|
|
+ targetQuarter += 4;
|
|
|
|
|
+ targetYear--;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 确保季度在1-4范围内
|
|
|
|
|
+ if (targetQuarter > 4) {
|
|
|
|
|
+ targetQuarter -= 4;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 设置季度名称
|
|
|
|
|
+ String quarterName = quarterNames[targetQuarter - 1];
|
|
|
|
|
+ // 计算季度开始月份和结束月份
|
|
|
|
|
+ int startMonth = (targetQuarter - 1) * 3 + 1; // 季度开始月份
|
|
|
|
|
+ int endMonth = targetQuarter * 3; // 季度结束月份
|
|
|
|
|
+ // 设置季度开始日期 (季度第一个月的第一天)
|
|
|
|
|
+ Calendar startCalendar = Calendar.getInstance();
|
|
|
|
|
+ startCalendar.set(targetYear, startMonth - 1, 1); // 月份从0开始计算
|
|
|
|
|
+ String startDate = dateFormat.format(startCalendar.getTime());
|
|
|
|
|
+ // 设置季度结束日期 (季度最后一个月的最后一天)
|
|
|
|
|
+ Calendar endCalendar = Calendar.getInstance();
|
|
|
|
|
+ endCalendar.set(targetYear, endMonth - 1, 1);
|
|
|
|
|
+ endCalendar.set(Calendar.DAY_OF_MONTH, endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
|
|
+ String endDate = dateFormat.format(endCalendar.getTime());
|
|
|
|
|
+ quarterInfo.put("name", quarterName);
|
|
|
|
|
+ quarterInfo.put("startDate", startDate);
|
|
|
|
|
+ quarterInfo.put("endDate", endDate);
|
|
|
|
|
+ result.add(quarterInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据当前日期返回本年度12个月的名称和每个月的开始日期和结束日期
|
|
|
|
|
+ * @return 包含12个月信息的List
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<Map<String, String>> getCurrentYearMonths() {
|
|
|
|
|
+ List<Map<String, String>> result = new ArrayList<>();
|
|
|
|
|
+ // 获取当前日期
|
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
|
+ // 获取当前年份
|
|
|
|
|
+ int currentYear = calendar.get(Calendar.YEAR);
|
|
|
|
|
+ // 格式化日期
|
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ // 循环处理12个月
|
|
|
|
|
+ for (int month = 1; month <= 12; month++) {
|
|
|
|
|
+ Map<String, String> monthInfo = new HashMap<>();
|
|
|
|
|
+ // 设置月份名称
|
|
|
|
|
+ String monthName = month + "月";
|
|
|
|
|
+ // 设置月开始日期 (月份的第一天)
|
|
|
|
|
+ Calendar startCalendar = Calendar.getInstance();
|
|
|
|
|
+ startCalendar.set(currentYear, month - 1, 1); // 月份从0开始计算
|
|
|
|
|
+ String startDate = dateFormat.format(startCalendar.getTime());
|
|
|
|
|
+ // 设置月结束日期 (月份的最后一天)
|
|
|
|
|
+ Calendar endCalendar = Calendar.getInstance();
|
|
|
|
|
+ endCalendar.set(currentYear, month - 1, 1);
|
|
|
|
|
+ endCalendar.set(Calendar.DAY_OF_MONTH, endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
|
|
+ String endDate = dateFormat.format(endCalendar.getTime());
|
|
|
|
|
+ monthInfo.put("name", monthName);
|
|
|
|
|
+ monthInfo.put("startDate", startDate);
|
|
|
|
|
+ monthInfo.put("endDate", endDate);
|
|
|
|
|
+ result.add(monthInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取告警设备列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/getDeviceEventList")
|
|
|
|
|
+ public TableDataInfo getDeviceEventList(@RequestParam(value = "industry", required = true) int industry,
|
|
|
|
|
+ @RequestParam(value = "eventTitle", required = false) String eventTitle,
|
|
|
|
|
+ @RequestParam(value = "createTimeRange", required = false) String createTimeRange) {
|
|
|
|
|
+ EventSubjectQueryVO queryVO = new EventSubjectQueryVO();
|
|
|
|
|
+ if(eventTitle != null && !"".equals(eventTitle)) {
|
|
|
|
|
+ queryVO.setEventTitle(eventTitle);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(createTimeRange != null && !"".equals(createTimeRange)) {
|
|
|
|
|
+ List<String> createTimeRangeList = new ArrayList<>();
|
|
|
|
|
+ createTimeRangeList.add(createTimeRange+" 00:00:00");
|
|
|
|
|
+ createTimeRangeList.add(createTimeRange+" 23:59:59");
|
|
|
|
|
+ queryVO.setCreateTimeRange(createTimeRangeList);
|
|
|
|
|
+ }
|
|
|
|
|
+ switch (industry) {
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ // 燃气
|
|
|
|
|
+ queryVO.setEventTypeCode("23");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ // 排水
|
|
|
|
|
+ queryVO.setEventTypeCode("6");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ // 供热
|
|
|
|
|
+ queryVO.setEventTypeCode("5");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ // 桥梁
|
|
|
|
|
+ queryVO.setEventTypeCode("null");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 5:
|
|
|
|
|
+ // 供水
|
|
|
|
|
+ queryVO.setEventTypeCode("8");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 6:
|
|
|
|
|
+ // 管廊
|
|
|
|
|
+ queryVO.setEventTypeCode("7");
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ queryVO.setEventTypeCode("");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<EventSubjectBO> result = this.eventSubjectService.getTotalEventList(queryVO);
|
|
|
|
|
+ return getDataTable(result);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|