Merge remote-tracking branch 'origin/master'

dev
xins 1 year ago
commit d6681b60e1

@ -44,6 +44,7 @@ public class HwMonitorPlatformController extends BaseController {
private IHwElectronicFenceService hwElectronicFenceService; private IHwElectronicFenceService hwElectronicFenceService;
/** /**
* *
* @param hwMonitorUnits * @param hwMonitorUnits
@ -51,7 +52,9 @@ public class HwMonitorPlatformController extends BaseController {
* @throws * @throws
* */ * */
@GetMapping("/treeList") @GetMapping("/treeList")
public TableDataInfo treeList(List<HwMonitorUnit> hwMonitorUnits){ public TableDataInfo treeList(){
HwMonitorUnit hwMonitorUnit = new HwMonitorUnit();
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit);
List<HwMonitorUnit> list = hwMonitorUnitService.selectTreeList(hwMonitorUnits); List<HwMonitorUnit> list = hwMonitorUnitService.selectTreeList(hwMonitorUnits);
return getDataTable(list); return getDataTable(list);
@ -113,6 +116,7 @@ public class HwMonitorPlatformController extends BaseController {
} }
/** /**
* *
* 1-
* */ * */
@GetMapping("/monitorPercentage") @GetMapping("/monitorPercentage")
public TableDataInfo monitorPercentage(){ public TableDataInfo monitorPercentage(){
@ -181,11 +185,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 +198,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 +227,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
@ -270,14 +280,18 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) { public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> returnList = new ArrayList<>(); List<HwMonitorUnit> returnList = new ArrayList<>();
List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList()); List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList());
List<HwMonitorUnit> treeList = new ArrayList<>();
for (HwMonitorUnit hwMonitorUnit:hwMonitorUnits){ for (HwMonitorUnit hwMonitorUnit:hwMonitorUnits){
if (!tempList.contains(hwMonitorUnit.getParentId())) if (!tempList.contains(hwMonitorUnit.getParentId()))
recursionFn(hwMonitorUnits,hwMonitorUnit); recursionFn(hwMonitorUnits,hwMonitorUnit);
returnList.add(hwMonitorUnit); returnList.add(hwMonitorUnit);
} }
for (int i = 0; i < returnList.size(); i++){
return returnList; if (returnList.get(i).getParentId()==null){
treeList.add(returnList.get(i));
}
}
return treeList;
} }
private void recursionFn(List<HwMonitorUnit> list, HwMonitorUnit t) private void recursionFn(List<HwMonitorUnit> list, HwMonitorUnit t)
{ {

@ -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