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;
/**
*
* @param hwMonitorUnits
@ -51,7 +52,9 @@ public class HwMonitorPlatformController extends BaseController {
* @throws
* */
@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);
return getDataTable(list);
@ -113,6 +116,7 @@ public class HwMonitorPlatformController extends BaseController {
}
/**
*
* 1-
* */
@GetMapping("/monitorPercentage")
public TableDataInfo monitorPercentage(){
@ -181,11 +185,11 @@ public class HwMonitorPlatformController extends BaseController {
* */
@PostMapping("/selectMonitorUnitSub")
//ok
public HwMonitorUnit selectMonitorUnitSub(Long monitorUnitId){
public AjaxResult selectMonitorUnitSub(Long monitorUnitId){
HwMonitorUnit hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId);
return hwMonitorUnits;
return AjaxResult.success(monitorUnitId);
}
/**
* 2. 线
@ -194,9 +198,10 @@ public class HwMonitorPlatformController extends BaseController {
* @param sceneId id
* */
@PostMapping("/getDeviceOperations")
public int[] selectTdengine(String beginTime,String endTime,Long sceneId){
int ints[] = hwMonitorUnitService.selectTdengine(beginTime,endTime,sceneId);
return ints;
public R<Map<Object, Integer>> selectTdengine(String beginTime,String endTime,Long sceneId){
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");}
return getDataTable(hwScenes);
}
/**
*
* alarminfo
* */
}

@ -38,6 +38,11 @@ public interface IHwMonitorUnitService
* */
public List<HwMonitorUnit> selectLimitSubMonitorUnit();
/**
*
* */
/**
@ -72,7 +77,7 @@ public interface IHwMonitorUnitService
* tdengine
*
* @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
// 加一个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();
Map<String, Object> params = queryDeviceStatus.getParams();
DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA);
System.out.println(ofPattern);
LocalDate parse = LocalDate.parse(beginTime, ofPattern);
long begintime = parse.atStartOfDay().toInstant(ZoneOffset.of("+8")).toEpochMilli();
@ -232,18 +233,27 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
int sum = 0;
int values[] = new int[10];
Map<Object,Integer> valuesMap = new HashMap<>();
//todo 使用id(以解决)
//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);
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getDeviceType()==1) {
values[i]=hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId());
Set<Long> longs = deviceStatusMap.keySet();
for (Object key:longs){
List<DeviceStatus> deviceStatuses = deviceStatusMap.get(key);
for (int i=0;i<deviceStatuses.size();i++){
if (deviceStatuses.get(i).getDeviceType()==1){
sum=sum+hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId());
}
else {
values[i] = hwDeviceMapper.selectSumDeviceFlagNot0();
sum = sum+1;
}
valuesMap.put(key,sum);
}
return values;
}
return valuesMap;
//设备类型==网关 根据releated_device_id = 网关设备设备id查询个数
//网关子设备数+非网关设备数getDeviceType()=1
@ -270,14 +280,18 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> returnList = new ArrayList<>();
List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList());
List<HwMonitorUnit> treeList = new ArrayList<>();
for (HwMonitorUnit hwMonitorUnit:hwMonitorUnits){
if (!tempList.contains(hwMonitorUnit.getParentId()))
recursionFn(hwMonitorUnits,hwMonitorUnit);
returnList.add(hwMonitorUnit);
}
return returnList;
for (int i = 0; i < returnList.size(); i++){
if (returnList.get(i).getParentId()==null){
treeList.add(returnList.get(i));
}
}
return treeList;
}
private void recursionFn(List<HwMonitorUnit> list, HwMonitorUnit t)
{

@ -120,7 +120,7 @@ where device_status = '1'GROUP BY scene_id
where parent_id = #{monitorUnitId}
</select>
<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>
<!-- 查询该监控单元是否为最小单元-->

Loading…
Cancel
Save