|
|
@ -122,8 +122,59 @@ public class DcDeviceController extends BaseController { |
|
|
|
@ApiOperation("无分页根据设备桩号查询设备列表") |
|
|
|
//@PreAuthorize("@ss.hasPermi('iot:device:query')")
|
|
|
|
@PostMapping("pileNumberQuery") |
|
|
|
public AjaxResult devicePileNumberQueryDevice(@RequestBody Map<String, Object> parameter) { |
|
|
|
return AjaxResult.success(dcDeviceService.devicePileNumberQueryDevice(parameter)); |
|
|
|
public AjaxResult devicePileNumberQueryDevice(@RequestBody Map<String, Object> parameter) throws HttpException, IOException, InterruptedException { |
|
|
|
List<DcDevice> dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter); |
|
|
|
String deviceType = String.valueOf(parameter.get("deviceType")); |
|
|
|
if (deviceType.equals("15")){ |
|
|
|
AjaxResult ajaxResult = ConfluenceAreaEarlyWarningDeviceBatteryLowWarning(); |
|
|
|
Object data = ajaxResult.get("data"); |
|
|
|
if (data instanceof List) { |
|
|
|
List<Map<String, Object>> dataList = (List<Map<String, Object>>) data; |
|
|
|
for (Map<String, Object> entry : dataList) { |
|
|
|
String functionId = (String) entry.get("functionId"); |
|
|
|
String device = (String) entry.get("device"); |
|
|
|
System.out.println("device:"+device); |
|
|
|
System.out.println("functionId:"+functionId); |
|
|
|
Object result = entry.get("result"); |
|
|
|
if (result instanceof Map) { |
|
|
|
Map<String, Object> resultMap = (Map<String, Object>) result; |
|
|
|
Integer resultCode = (Integer) resultMap.get("code"); |
|
|
|
if (resultCode==200){ |
|
|
|
Object innerData = resultMap.get("data"); |
|
|
|
if (innerData instanceof List) { |
|
|
|
List<Map<String, Object>> innerDataList = (List<Map<String, Object>>) innerData; |
|
|
|
for (Map<String, Object> innerEntry : innerDataList) { |
|
|
|
Integer innerCode = (Integer) innerEntry.get("code"); |
|
|
|
System.out.println("Inner Code: " + innerCode); |
|
|
|
if (innerCode==200){ |
|
|
|
for (DcDevice dcDevice : dcDevices) { |
|
|
|
if (String.valueOf(dcDevice.getId()).equals(device)){ |
|
|
|
dcDevice.setDeviceState("1"); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
for (DcDevice dcDevice : dcDevices) { |
|
|
|
if (String.valueOf(dcDevice.getId()).equals(device)){ |
|
|
|
dcDevice.setDeviceState("0"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
for (DcDevice dcDevice : dcDevices) { |
|
|
|
if (String.valueOf(dcDevice.getId()).equals(device)){ |
|
|
|
dcDevice.setDeviceState("0"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return AjaxResult.success(dcDevices); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1080,8 +1131,8 @@ public class DcDeviceController extends BaseController { |
|
|
|
/*** |
|
|
|
* 太阳能板设备定时任务 |
|
|
|
*/ |
|
|
|
@Scheduled(cron = "0 0/5 * * * ?") |
|
|
|
public void ConfluenceAreaEarlyWarningDeviceBatteryLowWarning() throws HttpException, IOException, InterruptedException { |
|
|
|
//@Scheduled(cron = "0 0/5 * * * ?")
|
|
|
|
public AjaxResult ConfluenceAreaEarlyWarningDeviceBatteryLowWarning() throws HttpException, IOException, InterruptedException { |
|
|
|
DcDevice dcDevice = new DcDevice(); |
|
|
|
dcDevice.setDeviceType(UniversalEnum.FIFTEEN.getValue()); |
|
|
|
List<DcDevice> dcDeviceList = dcDeviceService.listDevice(dcDevice); |
|
|
@ -1098,16 +1149,21 @@ public class DcDeviceController extends BaseController { |
|
|
|
} |
|
|
|
} |
|
|
|
ArrayList functions = new ArrayList(); |
|
|
|
for (int i = UniversalEnum.ZERO.getNumber(); i < UniversalEnum.SIX.getNumber(); i++) { |
|
|
|
// for (int i = UniversalEnum.ZERO.getNumber(); i < UniversalEnum.SIX.getNumber(); i++) {
|
|
|
|
// JSONObject function = new JSONObject();
|
|
|
|
// function.put("functionId", UniversalEnum.A.getValue() + (i + UniversalEnum.ONE.getNumber()));
|
|
|
|
// function.put("params", new JSONObject());
|
|
|
|
// functions.add(function);
|
|
|
|
// }
|
|
|
|
|
|
|
|
JSONObject function = new JSONObject(); |
|
|
|
function.put("functionId", UniversalEnum.A.getValue() + (i + UniversalEnum.ONE.getNumber())); |
|
|
|
function.put("functionId", UniversalEnum.A_ONE.getValue()); |
|
|
|
function.put("params", new JSONObject()); |
|
|
|
functions.add(function); |
|
|
|
} |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("devices", devices); |
|
|
|
jsonObject.put("functions", functions); |
|
|
|
batchInvokedFunction(jsonObject); |
|
|
|
return batchInvokedFunction(jsonObject); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|