Browse Source

太阳能板 取消定时任务

develop
王兴琳 3 months ago
parent
commit
720df95250
  1. 78
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  2. 1
      zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java
  3. 2
      zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java

78
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -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++) {
JSONObject function = new JSONObject();
function.put("functionId", UniversalEnum.A.getValue() + (i + UniversalEnum.ONE.getNumber()));
function.put("params", new JSONObject());
functions.add(function);
}
// 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_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);
}
}

1
zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

@ -264,7 +264,6 @@ public class WeatherForecastController extends BaseController {
//判断返回data是否不为0 不为0则将数据进行返回 为0则获取redis中的缓存进行返回
if (jsonArray.size() != UniversalEnum.ZERO.getNumber()) {
redisCache.deleteObject("twentyFourHourWeather");
redisCache.setCacheObject("twentyFourHourWeather", jsonArray);
}
}

2
zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java

@ -223,7 +223,7 @@ public class OperationLogAspect {
Objects.equals(functionId, UniversalEnum.FIFTY_TWO.getValue()) ||
Objects.equals(functionId, UniversalEnum.THREE_D.getValue()) ||
Objects.equals(functionId, UniversalEnum.THREE_C.getValue())) {
break;
return;
}

Loading…
Cancel
Save