diff --git a/zc-business/src/main/java/com/zc/business/controller/VideoController.java b/zc-business/src/main/java/com/zc/business/controller/VideoController.java index f0b08a96..b323fc53 100644 --- a/zc-business/src/main/java/com/zc/business/controller/VideoController.java +++ b/zc-business/src/main/java/com/zc/business/controller/VideoController.java @@ -3,8 +3,10 @@ package com.zc.business.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.redis.RedisCache; import com.zc.business.domain.DcDevice; import com.zc.business.service.IDcDeviceService; import com.zc.common.core.httpclient.OkHttp; @@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.io.IOException; import java.util.*; +import java.util.concurrent.TimeUnit; import static com.ruoyi.common.constant.Constants.HTTP; @@ -36,6 +39,10 @@ import static com.ruoyi.common.constant.Constants.HTTP; @RequestMapping("/video") public class VideoController extends BaseController { + private static final String ID = "admin"; + private static final String SECRET = "21232f297a57a5a743894a0e4a801fc3"; + private static final String CALLBACKURL = "http://10.0.81.209/broadcast/logIn"; + private final static String TOKENKEY = "tokenRoadTestBroadcastPlatform"; private static final String USERNAME = "jhgskj"; private static final String PASSWORD = "jhgskj@2023"; private static String TOKEN; @@ -47,6 +54,8 @@ public class VideoController extends BaseController { public static final Integer ERROR = 500; + @Resource + private RedisCache redisCache; @Resource private IDcDeviceService iDcDeviceService; @@ -55,8 +64,8 @@ public class VideoController extends BaseController { */ @ApiOperation("查询附近相机") @GetMapping(value = "/nearCamListDistance") - public JSONObject nearCamListDistance(@ApiParam(value = "纬度", name = "devLat",required = true)String devLat, - @ApiParam(value = "经度", name = "devLon",required = true)String devLon) throws HttpException, IOException { + public JSONObject nearCamListDistance(@ApiParam(value = "纬度", name = "devLat", required = true) String devLat, + @ApiParam(value = "经度", name = "devLon", required = true) String devLon) throws HttpException, IOException { JSONObject jsonResult = null; @@ -106,21 +115,21 @@ public class VideoController extends BaseController { */ @Scheduled(cron = "0 0/5 * * * ?") public void updateDeviceState() throws HttpException, IOException { - logger.debug("开始执行:同步数据平台设备的设备状态!!"); + logger.debug("开始执行:同步数据平台视频设备设备的设备状态!!"); JSONObject cameraData = synchronizeCameraData(); if (cameraData.get("code").equals(200)) { - JSONObject data =JSONObject.parseObject(JSONArray.parseArray(cameraData.get("data").toString()).get(0).toString()); - JSONObject dataChildren =JSONObject.parseObject(JSONArray.parseArray(data.get("children").toString()).get(0).toString()); - JSONObject qiLuGaoSu =JSONObject.parseObject(JSONArray.parseArray(dataChildren.get("children").toString()).get(0).toString()); - JSONObject jiHeYunGuan =JSONObject.parseObject(JSONArray.parseArray(qiLuGaoSu.get("children").toString()).get(0).toString()); + JSONObject data = JSONObject.parseObject(JSONArray.parseArray(cameraData.get("data").toString()).get(0).toString()); + JSONObject dataChildren = JSONObject.parseObject(JSONArray.parseArray(data.get("children").toString()).get(0).toString()); + JSONObject qiLuGaoSu = JSONObject.parseObject(JSONArray.parseArray(dataChildren.get("children").toString()).get(0).toString()); + JSONObject jiHeYunGuan = JSONObject.parseObject(JSONArray.parseArray(qiLuGaoSu.get("children").toString()).get(0).toString()); JSONArray jiHeYunGuanG35 = JSONArray.parseArray(jiHeYunGuan.get("children").toString()); List list = new ArrayList<>(); - for (Object json: jiHeYunGuanG35) { + for (Object json : jiHeYunGuanG35) { JSONObject item = JSONObject.parseObject(json.toString()); DcDevice device = new DcDevice(); if (item.get("status").equals("0")) { device.setDeviceState("1"); - }else { + } else { device.setDeviceState("0"); } device.setIotDeviceId(item.get("camId").toString()); @@ -131,6 +140,7 @@ public class VideoController extends BaseController { logger.debug("执行:同步数据平台视频设备的设备状态成功!!"); } + logger.debug("开始执行:同步物联平台设备的设备状态!!"); AjaxResult ajaxResult = synchronizingDeviceStatus(); if (ajaxResult.get("code").equals(200)) { JSONArray data = (JSONArray) ajaxResult.get("data"); @@ -139,28 +149,80 @@ public class VideoController extends BaseController { DcDevice dcDevice = new DcDevice(); JSONObject datum1 = (JSONObject) datum; dcDevice.setIotDeviceId(datum1.getString("id")); - dcDevice.setDeviceState(Objects.equals(datum1.getString("deviceState"), "online") ?"1":"0"); + dcDevice.setDeviceState(Objects.equals(datum1.getString("deviceState"), "online") ? "1" : "0"); dcDevices.add(dcDevice); } iDcDeviceService.batchUpdate(dcDevices); - logger.debug("执行:同步数据平台设备的设备状态成功!!"); + logger.debug("执行:同步物联平台设备的设备状态成功!!"); } + logger.debug("开始执行:同步广播设备的设备状态!!"); + AjaxResult ajaxResultBroadcast = synchronizingBroadcastDeviceStatus(); + if (Objects.equals(String.valueOf(ajaxResultBroadcast.get("retCode")), "0")) { + JSONArray data = (JSONArray) ajaxResultBroadcast.get("termList"); + for (Object datum : data) { + DcDevice dcDevice = new DcDevice(); + JSONObject datum1 = (JSONObject) datum; + dcDevice.setIotDeviceId(datum1.getString("termDN")); + dcDevice.setDeviceState(Objects.equals(datum1.getString("regState"), "online") ? "1" : "0"); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(DcDevice::getIotDeviceId, dcDevice.getIotDeviceId()); + iDcDeviceService.update(dcDevice, queryWrapper); + } + logger.debug("执行:同步广播设备的设备状态成功!!"); + } + } + private AjaxResult synchronizingBroadcastDeviceStatus() throws HttpException, IOException { + OkHttp okHttp = new OkHttp(); + RequestParams requestParams = new RequestParams(); + String tokenRoadTestBroadcastPlatform = redisCache.getCacheObject(TOKENKEY); + if (tokenRoadTestBroadcastPlatform == null) { + tokenRoadTestBroadcastPlatform = getBroadcastToken(); + } + requestParams.put("zoneId", "*6001"); + requestParams.put("termDN", ""); + Response response // 请求响应 + = okHttp + .headers(new HashMap<>()) + .data(requestParams) // 请求参数 + .url("http://10.0.81.106/api/REST-API/queryTerm.do?accessToken=" + tokenRoadTestBroadcastPlatform) // 请求地址 + .post(); // 请求方法 + return JSON.parseObject(response.body().string(), AjaxResult.class); + } + + public String getBroadcastToken() throws HttpException, IOException { + OkHttp okHttp = new OkHttp(); + RequestParams requestParams = new RequestParams(); + requestParams.put("id", ID); + requestParams.put("secret", SECRET); + requestParams.put("callbackUrl", CALLBACKURL); + Response response // 请求响应 + = okHttp + .headers(new HashMap<>()) + .url("http://10.0.81.106/api/REST-API/login.do") // 请求地址 + .data(requestParams) // 请求参数 + .post(); // 请求方法 + if (response.body() != null) { + String accessToken = JSONObject.parseObject(response.body().string()).getString("accessToken"); + redisCache.setCacheObject(TOKENKEY, accessToken, 100, TimeUnit.MINUTES); + return accessToken; + } + return null; } + private AjaxResult synchronizingDeviceStatus() throws HttpException, IOException { OkHttp okHttp = new OkHttp(); Response response // 请求响应 = okHttp - .url(HTTP+"10.0.81.202:8081" + "/api/iot/device/query") // 请求地址 + .url(HTTP + "10.0.81.202:8081" + "/api/iot/device/query") // 请求地址 .get(); // 请求方法 - AjaxResult ajaxResult = JSON.parseObject(response.body().string(), AjaxResult.class); - return ajaxResult; + return JSON.parseObject(response.body().string(), AjaxResult.class); } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java b/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java index 02514610..4295717d 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java @@ -22,40 +22,34 @@ public class DcEventProcess private static final long serialVersionUID = 1L; /** $column.columnComment */ - @ApiModelProperty(value = "流水ID",required = true) - @NotBlank(message = "流水ID不能为空") + @ApiModelProperty(value = "流水ID") private Long id; /** $column.columnComment */ - @ApiModelProperty(value="事件ID",required = true) - @NotBlank(message = "事件ID不能为空") + @ApiModelProperty(value="事件ID") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private String eventId; /** $column.columnComment */ - @ApiModelProperty(value="操作时间",required = true) - @NotBlank(message = "操作时间不能为空") + @ApiModelProperty(value="操作时间") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private Date operationTime; /** $column.columnComment */ - @ApiModelProperty(value="操作人",required = true) - @NotBlank(message = "操作人不能为空") + @ApiModelProperty(value="操作人") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private String operator; /** 1-pc端 2-手机端 */ - @ApiModelProperty(value="来源",required = true) - @NotBlank(message = "来源不能为空") + @ApiModelProperty(value="来源") @Excel(name = "1-pc端 2-手机端") private Integer source; /** 1-节点 2-信息发布 */ - @ApiModelProperty(value="流程类型",required = true) - @NotBlank(message = "流程类型不能为空") + @ApiModelProperty(value="流程类型") @Excel(name = "1-节点 2-信息发布 ") private Integer processType; diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java b/zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java index 7448e3b0..a13c21e7 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java @@ -72,7 +72,7 @@ public class DcEventTrafficControl extends BaseEntity private Long roadId; */ - @ApiModelProperty("原因类型") + @ApiModelProperty("原因类型 3-1 雨3-2 雪3-3 雾3-4 道路积水3-5 道路湿滑3-6 道路结冰3-7 沙尘暴4-1 专项工程施工 4-2 改扩建工程施工4-3 其他施工',") private String causeType; @ApiModelProperty("措施 1-临时关闭2-限行车辆3-限行车道4-限行车道且限行车辆5-间隔放行6-并道行驶 7-限速',") diff --git a/zc-business/src/main/java/com/zc/business/domain/DcStakeMark.java b/zc-business/src/main/java/com/zc/business/domain/DcStakeMark.java index f69b5840..123c57cd 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcStakeMark.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcStakeMark.java @@ -13,8 +13,8 @@ public class DcStakeMark { public static final String UP = "1"; public static final String CENTRE = "2"; public static final String DOWN = "3"; - @ApiModelProperty("ID") - private String id; + @ApiModelProperty("桩号") + private String stakeMark; @ApiModelProperty("经度") private String longitude; @ApiModelProperty("纬度") diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java index 0bc79af1..285cc341 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java @@ -281,7 +281,7 @@ public class DcDeviceServiceImpl extends ServiceImpl i public DcStakeMark exampleQueryTheAssociatedPileNumber(DcDevice dcDevice) { DcStakeMark dcStakeMark = new DcStakeMark(); dcStakeMark.setDirection(dcDevice.getDirection()); - dcStakeMark.setId(dcDevice.getStakeMark()); + dcStakeMark.setStakeMark(dcDevice.getStakeMark()); List dcStakeMarks = dcStakeMarkService.listStakeMark(dcStakeMark); if (dcStakeMarks.size() == 1) { return dcStakeMarks.get(0); diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java index ecaec4dd..3dacb227 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java @@ -29,8 +29,8 @@ public class DcStakeMarkServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); // 设备ID - if (StringUtils.hasText(dcStakeMark.getId())) { - queryWrapper.eq(DcStakeMark::getId, dcStakeMark.getId()); + if (StringUtils.hasText(dcStakeMark.getStakeMark())) { + queryWrapper.eq(DcStakeMark::getStakeMark, dcStakeMark.getStakeMark()); } // 经度 @@ -69,7 +69,7 @@ public class DcStakeMarkServiceImpl extends ServiceImpl @@ -277,7 +277,7 @@ LEFT JOIN (select t2.section_id, count(*) lastNum from dc_event t1 - left join dc_stake_mark t2 on t1.stake_mark = t2.id and t1.direction = t2.direction + left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction where t1.event_type = '1' and t1.direction = #{direction} @@ -298,7 +298,7 @@