Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
zhao-meiyu 10 months ago
parent
commit
5434041b0b
  1. 23
      zc-business/src/main/java/com/zc/business/controller/BroadcastController.java
  2. 12
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  3. 2
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  4. 7
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

23
zc-business/src/main/java/com/zc/business/controller/BroadcastController.java

@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -30,6 +31,8 @@ import static com.ruoyi.common.constant.Constants.HTTP;
@RequestMapping("/broadcast")
public class BroadcastController extends BaseController {
private static int numberOfReconnections = 1;
@Resource
private RedisCache redisCache;
private static final String ID = "admin";
@ -52,6 +55,7 @@ public class BroadcastController extends BaseController {
public AjaxResult logIn(@PathVariable String event, HashMap<String, Object> returnParameters) {
Object accessToken = returnParameters.get("accessToken");
System.out.println(accessToken);
System.out.println("广播回调事件函数");
//todo
@ -65,12 +69,13 @@ public class BroadcastController extends BaseController {
@PostMapping(value = "/broadcastFunctionCall")
public JSONObject nearCamListDistance(@RequestBody JSONObject params) throws HttpException, IOException {
JSONObject jsonResult = null;
OkHttp okHttp = new OkHttp();
OkHttp okHttp = new OkHttp(1);
RequestParams requestParams = new RequestParams(params);
String tokenRoadTestBroadcastPlatform = redisCache.getCacheObject(TOKENKEY);
if (tokenRoadTestBroadcastPlatform == null) {
tokenRoadTestBroadcastPlatform = getToken();
}
try {
Response response // 请求响应
= okHttp
.headers(new HashMap<>())
@ -80,6 +85,18 @@ public class BroadcastController extends BaseController {
if (response.body() != null) {
jsonResult = JSONObject.parseObject(response.body().string());
}
} catch (SocketTimeoutException e) {
if (numberOfReconnections >3){
numberOfReconnections += 1;
getToken();
return nearCamListDistance(params);
}else {
jsonResult = new JSONObject();
jsonResult.put("code","400");
jsonResult.put("msg","语音广播连接错误");
return jsonResult;
}
}
return jsonResult;
}
@ -97,10 +114,8 @@ public class BroadcastController extends BaseController {
.data(requestParams) // 请求参数
.post(); // 请求方法
if (response.body() != null) {
//accessToken
String accessToken = JSONObject.parseObject(response.body().string()).getString("accessToken");
//RedisCache redisCache = new RedisCache();
redisCache.setCacheObject(TOKENKEY, accessToken, 100, TimeUnit.MINUTES);
redisCache.setCacheObject(TOKENKEY, accessToken, 5, TimeUnit.MINUTES);
return accessToken;
}
return null;

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

@ -58,6 +58,18 @@ public class DcDeviceController extends BaseController {
return getDataTable(dcDeviceService.pageDevice(dcDevice));
}
/**
* 统计异常设备
*
* @return 查询结果
*/
@ApiOperation("统计异常设备")
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("abnormalDevice")
public AjaxResult statisticalAnomalyDevice() {
return AjaxResult.success(dcDeviceService.statisticalAnomalyDevice());
}
/**
* 无分页查询设备列表
*

2
zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java

@ -72,4 +72,6 @@ public interface IDcDeviceService extends IService<DcDevice> {
DcDevice getDevice(String id);
DcStakeMark exampleQueryTheAssociatedPileNumber(DcDevice dcDevice);
Long statisticalAnomalyDevice();
}

7
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

@ -288,5 +288,12 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
}
return new DcStakeMark();
}
@Override
public Long statisticalAnomalyDevice() {
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcDevice::getDeviceState, 0).or().isNull(DcDevice::getDeviceState);
return (long) list(lambdaQueryWrapper).size();
}
}

Loading…
Cancel
Save