1.1.3 监控单元Controller修改

dev
zhouhy 1 year ago
parent 7a3fd5ee04
commit 7f13f3c0e7

@ -44,6 +44,7 @@ public class HwMonitorPlatformController extends BaseController {
private IHwElectronicFenceService hwElectronicFenceService; private IHwElectronicFenceService hwElectronicFenceService;
/** /**
* *
* @param hwMonitorUnits * @param hwMonitorUnits
@ -51,7 +52,7 @@ public class HwMonitorPlatformController extends BaseController {
* @throws * @throws
* */ * */
@GetMapping("/treeList") @GetMapping("/treeList")
public TableDataInfo treeList(List<HwMonitorUnit> hwMonitorUnits){ public TableDataInfo treeList(@RequestBody List<HwMonitorUnit> hwMonitorUnits){
List<HwMonitorUnit> list = hwMonitorUnitService.selectTreeList(hwMonitorUnits); List<HwMonitorUnit> list = hwMonitorUnitService.selectTreeList(hwMonitorUnits);
return getDataTable(list); return getDataTable(list);
@ -113,6 +114,7 @@ public class HwMonitorPlatformController extends BaseController {
} }
/** /**
* *
* 1-
* */ * */
@GetMapping("/monitorPercentage") @GetMapping("/monitorPercentage")
public TableDataInfo monitorPercentage(){ public TableDataInfo monitorPercentage(){
@ -181,11 +183,11 @@ public class HwMonitorPlatformController extends BaseController {
* */ * */
@PostMapping("/selectMonitorUnitSub") @PostMapping("/selectMonitorUnitSub")
//ok //ok
public HwMonitorUnit selectMonitorUnitSub(Long monitorUnitId){ public AjaxResult selectMonitorUnitSub(Long monitorUnitId){
HwMonitorUnit hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId); HwMonitorUnit hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId);
return hwMonitorUnits; return AjaxResult.success(monitorUnitId);
} }
/** /**
* 2. 线 * 2. 线
@ -194,9 +196,10 @@ public class HwMonitorPlatformController extends BaseController {
* @param sceneId id * @param sceneId id
* */ * */
@PostMapping("/getDeviceOperations") @PostMapping("/getDeviceOperations")
public int[] selectTdengine(String beginTime,String endTime,Long sceneId){ public R<Map<Object, Integer>> selectTdengine(String beginTime,String endTime,Long sceneId){
int ints[] = hwMonitorUnitService.selectTdengine(beginTime,endTime,sceneId);
return ints; Map<Object, Integer> objectIntegerMap = hwMonitorUnitService.selectTdengine(beginTime, endTime, sceneId);
return R.ok(objectIntegerMap);
} }
/** /**
* *
@ -222,4 +225,9 @@ public class HwMonitorPlatformController extends BaseController {
hwScenes.get(0).setDefaultFlag("1");} hwScenes.get(0).setDefaultFlag("1");}
return getDataTable(hwScenes); return getDataTable(hwScenes);
} }
/**
*
* alarminfo
* */
} }

@ -38,6 +38,11 @@ public interface IHwMonitorUnitService
* */ * */
public List<HwMonitorUnit> selectLimitSubMonitorUnit(); public List<HwMonitorUnit> selectLimitSubMonitorUnit();
/**
*
* */
/** /**
@ -72,7 +77,7 @@ public interface IHwMonitorUnitService
* tdengine * tdengine
* *
* @return*/ * @return*/
public int[] selectTdengine(String beginTime, String endTime, Long sceneId); public Map<Object, Integer> selectTdengine(String beginTime, String endTime, Long sceneId);
/** /**
* *
* *

@ -211,11 +211,12 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
@Override @Override
// 加一个begintime参数endtime参数 stream时间戳 从开始时间0点开始结束时间23.59.59结束 // 加一个begintime参数endtime参数 stream时间戳 从开始时间0点开始结束时间23.59.59结束
public int[] selectTdengine(String beginTime, String endTime, Long sceneId) { public Map<Object, Integer> selectTdengine(String beginTime, String endTime, Long sceneId) {
DeviceStatus queryDeviceStatus = new DeviceStatus(); DeviceStatus queryDeviceStatus = new DeviceStatus();
Map<String, Object> params = queryDeviceStatus.getParams(); Map<String, Object> params = queryDeviceStatus.getParams();
DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA);
System.out.println(ofPattern);
LocalDate parse = LocalDate.parse(beginTime, ofPattern); LocalDate parse = LocalDate.parse(beginTime, ofPattern);
long begintime = parse.atStartOfDay().toInstant(ZoneOffset.of("+8")).toEpochMilli(); long begintime = parse.atStartOfDay().toInstant(ZoneOffset.of("+8")).toEpochMilli();
@ -232,18 +233,27 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
int sum = 0; int sum = 0;
int values[] = new int[10]; int values[] = new int[10];
Map<Object,Integer> valuesMap = new HashMap<>();
//todo 使用id(以解决) //todo 使用id(以解决)
//map key时间戳value List<DeviceStatus> 对象 //map key时间戳value List<DeviceStatus> 对象
R<?> r = remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
Map<Long, List<DeviceStatus>> deviceStatusMap = (Map<Long, List<DeviceStatus>>) r.getData();
List<DeviceStatus> list = (List<DeviceStatus>) remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus); List<DeviceStatus> list = (List<DeviceStatus>) remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
for (int i = 0; i < list.size(); i++) { Set<Long> longs = deviceStatusMap.keySet();
if (list.get(i).getDeviceType()==1) { for (Object key:longs){
values[i]=hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId()); List<DeviceStatus> deviceStatuses = deviceStatusMap.get(key);
} for (int i=0;i<deviceStatuses.size();i++){
else { if (deviceStatuses.get(i).getDeviceType()==1){
values[i] = hwDeviceMapper.selectSumDeviceFlagNot0(); sum=sum+hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId());
}
else {
sum = sum+1;
}
valuesMap.put(key,sum);
} }
} }
return values;
return valuesMap;
//设备类型==网关 根据releated_device_id = 网关设备设备id查询个数 //设备类型==网关 根据releated_device_id = 网关设备设备id查询个数
//网关子设备数+非网关设备数getDeviceType()=1 //网关子设备数+非网关设备数getDeviceType()=1

@ -120,7 +120,7 @@ where device_status = '1'GROUP BY scene_id
where parent_id = #{monitorUnitId} where parent_id = #{monitorUnitId}
</select> </select>
<select id="selectReleatedDeviceIdNums" parameterType="Long" resultType="Integer"> <select id="selectReleatedDeviceIdNums" parameterType="Long" resultType="Integer">
select count(*) from hw_device where device_id = #{deviceId} select count(*) from hw_device where releated_device_id = #{deviceId}
</select> </select>
<!-- 查询该监控单元是否为最小单元--> <!-- 查询该监控单元是否为最小单元-->

Loading…
Cancel
Save