|
@@ -7,10 +7,13 @@ import com.ruoyi.common.core.domain.R;
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
import com.ruoyi.common.log.annotation.Log;
|
|
import com.ruoyi.common.log.annotation.Log;
|
|
import com.ruoyi.common.log.enums.BusinessType;
|
|
import com.ruoyi.common.log.enums.BusinessType;
|
|
|
|
+import com.sooka.sponest.monitor.camera.domain.CentermonitorTRecorder;
|
|
import com.sooka.sponest.monitor.camera.mapper.CentermonitorTCameraMapper;
|
|
import com.sooka.sponest.monitor.camera.mapper.CentermonitorTCameraMapper;
|
|
|
|
+import com.sooka.sponest.monitor.camera.mapper.CentermonitorTRecorderMapper;
|
|
import com.sooka.sponest.monitor.dahua.domain.CentermonitorTMonitoringEquipmentPositionDO;
|
|
import com.sooka.sponest.monitor.dahua.domain.CentermonitorTMonitoringEquipmentPositionDO;
|
|
import com.sooka.sponest.monitor.dahua.mapper.CentermonitorTMonitoringEquipmentPositionMapper;
|
|
import com.sooka.sponest.monitor.dahua.mapper.CentermonitorTMonitoringEquipmentPositionMapper;
|
|
import com.sooka.sponest.monitor.dahua.service.DahuaService;
|
|
import com.sooka.sponest.monitor.dahua.service.DahuaService;
|
|
|
|
+import com.sooka.sponest.monitor.dahua.utils.DeviceMonitorManager;
|
|
import com.sooka.sponest.monitor.dahua.utils.HttpEnum;
|
|
import com.sooka.sponest.monitor.dahua.utils.HttpEnum;
|
|
import com.sooka.sponest.monitor.dahua.utils.HttpTestUtils;
|
|
import com.sooka.sponest.monitor.dahua.utils.HttpTestUtils;
|
|
import com.sooka.sponest.monitor.remoteapi.service.lawenforcement.RemoteLawenforcementBaseService;
|
|
import com.sooka.sponest.monitor.remoteapi.service.lawenforcement.RemoteLawenforcementBaseService;
|
|
@@ -18,11 +21,14 @@ import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.text.ParseException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -47,18 +53,22 @@ public class EquipmentStatusTaskController {
|
|
private CentermonitorTCameraMapper centermonitorTCameraMapper;
|
|
private CentermonitorTCameraMapper centermonitorTCameraMapper;
|
|
@Resource
|
|
@Resource
|
|
private RemoteLawenforcementBaseService remoteLawenforcementBaseService;
|
|
private RemoteLawenforcementBaseService remoteLawenforcementBaseService;
|
|
- @Value("${sooka.dahua_interface_server.loginIp}")
|
|
|
|
- private String loginIp;
|
|
|
|
- @Value("${sooka.dahua_interface_server.loginPort}")
|
|
|
|
- private String loginPort;
|
|
|
|
- @Value("${sooka.dahua_interface_server.userName}")
|
|
|
|
- private String userName;
|
|
|
|
- @Value("${sooka.dahua_interface_server.userPwd}")
|
|
|
|
- private String userPwd;
|
|
|
|
-// private String loginIp = "10.53.0.35";
|
|
|
|
-// private String loginPort = "7901";
|
|
|
|
-// private String userName = "system";
|
|
|
|
-// private String userPwd = "Admin123";
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private CentermonitorTRecorderMapper centermonitorTRecorderMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DeviceMonitorManager deviceMonitorManager;
|
|
|
|
+ // @Value("${sooka.dahua_interface_server.loginIp}")
|
|
|
|
+// private String loginIp;
|
|
|
|
+// @Value("${sooka.dahua_interface_server.loginPort}")
|
|
|
|
+// private String loginPort;
|
|
|
|
+// @Value("${sooka.dahua_interface_server.userName}")
|
|
|
|
+// private String userName;
|
|
|
|
+// @Value("${sooka.dahua_interface_server.userPwd}")
|
|
|
|
+// private String userPwd;
|
|
|
|
+ private String loginIp = "10.53.0.35";
|
|
|
|
+ private String loginPort = "7901";
|
|
|
|
+ private String userName = "system";
|
|
|
|
+ private String userPwd = "Admin123";
|
|
//按组织获取设备详细信息
|
|
//按组织获取设备详细信息
|
|
public static final String ACTION = "/videoService/devicesManager/devicesInfo";
|
|
public static final String ACTION = "/videoService/devicesManager/devicesInfo";
|
|
private List<String> orgCodes = Arrays.asList("11033445593778368", "11248668755298496");
|
|
private List<String> orgCodes = Arrays.asList("11033445593778368", "11248668755298496");
|
|
@@ -67,7 +77,7 @@ public class EquipmentStatusTaskController {
|
|
@Resource
|
|
@Resource
|
|
CentermonitorTMonitoringEquipmentPositionMapper centermonitorTMonitoringEquipmentPositionMapper;
|
|
CentermonitorTMonitoringEquipmentPositionMapper centermonitorTMonitoringEquipmentPositionMapper;
|
|
|
|
|
|
-// @Scheduled(cron = "0/5 * * * * ?")
|
|
|
|
|
|
+ // @Scheduled(cron = "0/5 * * * * ?")
|
|
@Log(title = "对接大华根据组织获取执法记录仪、单兵设备在线状态定时任务", businessType = BusinessType.OTHER)
|
|
@Log(title = "对接大华根据组织获取执法记录仪、单兵设备在线状态定时任务", businessType = BusinessType.OTHER)
|
|
@ApiOperation(value = "对接大华根据组织获取执法记录仪、单兵设备在线状态定时任务", notes = "对接大华根据组织获取执法记录仪、单兵设备在线状态定时任务")
|
|
@ApiOperation(value = "对接大华根据组织获取执法记录仪、单兵设备在线状态定时任务", notes = "对接大华根据组织获取执法记录仪、单兵设备在线状态定时任务")
|
|
@RequestMapping(value = "/getLongPollingPositionMsg", method = GET)
|
|
@RequestMapping(value = "/getLongPollingPositionMsg", method = GET)
|
|
@@ -146,27 +156,111 @@ public class EquipmentStatusTaskController {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//向执法中心推送设备状态
|
|
//向执法中心推送设备状态
|
|
- R result = remoteLawenforcementBaseService.deviceOpenOrClose(arr);
|
|
|
|
- if (result.getCode() != 200) {
|
|
|
|
- log.info("向执法中心推送设备状态失败:{}", result.getMsg());
|
|
|
|
- }
|
|
|
|
|
|
+// R result = remoteLawenforcementBaseService.deviceOpenOrClose(arr);
|
|
|
|
+// if (result.getCode() != 200) {
|
|
|
|
+// log.info("向执法中心推送设备状态失败:{}", result.getMsg());
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ //误操作开机,导致设备状态非正常使用,进行告警处理
|
|
|
|
+ saveOrUpdateRecorderStatus(arr);
|
|
|
|
+
|
|
//更新执法仪在离线状态
|
|
//更新执法仪在离线状态
|
|
- centermonitorTCameraMapper.updateBatchLawEnforcementInstrumentState(arr);
|
|
|
|
|
|
+// centermonitorTCameraMapper.updateBatchLawEnforcementInstrumentState(arr);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //保存或更新执法记录仪开关机记录
|
|
|
|
+ private void saveOrUpdateRecorderStatus(List<Map<String, Object>> arr) {
|
|
|
|
+ for (Map<String, Object> var : arr) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ String deviceCode = var.get("code").toString();
|
|
|
|
+ map.put("cameraCode", deviceCode);
|
|
|
|
+ //设备状态,”0” : 不在线 “1” : 在线,保存入库和执法仪状态数值同步
|
|
|
|
+ map.put("status", var.get("status").equals("1") ? "0" : "1");
|
|
|
|
+ if (deviceCode.equals("11151730914298053")) {
|
|
|
|
+ System.out.println("设备是否在线:" + (var.get("status").equals("1") ? "在线" : "离线"));
|
|
|
|
+ System.out.println("设备在离线时间:" + deviceMonitorManager.formatStatusTime(var));
|
|
|
|
+ }
|
|
|
|
+ if (var.get("status").equals("0")) {
|
|
|
|
+ map.put("onlineTime", null);
|
|
|
|
+ map.put("offlineTime", deviceMonitorManager.formatStatusTime(var));
|
|
|
|
+ } else {
|
|
|
|
+ map.put("onlineTime", deviceMonitorManager.formatStatusTime(var));
|
|
|
|
+ map.put("offlineTime", null);
|
|
|
|
+
|
|
|
|
+ // 设备上线时,如果还没有监控任务,则启动新任务
|
|
|
|
+ if (!deviceMonitorManager.hasMonitoringTask(deviceCode)) {
|
|
|
|
+ try {
|
|
|
|
+ deviceMonitorManager.startDeviceMonitoringIfAbsent(deviceCode, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(deviceMonitorManager.formatStatusTime(var)));
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ log.error("日期格式转换异常", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ CentermonitorTRecorder centermonitorTRecorder = centermonitorTRecorderMapper.selectCentermonitorTRecorder(var.get("code").toString());
|
|
|
|
+ if (ObjectUtils.isEmpty(centermonitorTRecorder)) {
|
|
|
|
+ centermonitorTRecorderMapper.insertCentermonitorTRecorderBatch(map);
|
|
|
|
+ } else {
|
|
|
|
+ centermonitorTRecorderMapper.updateCentermonitorTRecorderBatch(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (var.get("status").equals("0")) {
|
|
|
|
+ deviceMonitorManager.stopDeviceMonitoring(deviceCode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *获取记录仪位置数据
|
|
|
|
|
|
+ * 执法记录仪设备开机
|
|
|
|
+ *
|
|
|
|
+ * @param cameraCode 摄像头编码
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/equipStartup/{cameraCode}", method = GET)
|
|
|
|
+ public void equipStartup(@PathVariable("cameraCode") String cameraCode) {
|
|
|
|
+ JSONObject json = deviceMonitorManager.getJsonObject(cameraCode, "1");
|
|
|
|
+ if (ObjectUtils.isEmpty(json)) {
|
|
|
|
+ log.info("获取设备信息失败,请检查设备编码:{}", cameraCode);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ deviceMonitorManager.stopDeviceMonitoring(json.get("code").toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 执法记录仪设备关机
|
|
|
|
+ *
|
|
|
|
+ * @param cameraCode 摄像头编码
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/equipShutdown/{cameraCode}", method = GET)
|
|
|
|
+ public void equipShutdown(@PathVariable("cameraCode") String cameraCode) {
|
|
|
|
+ //根据通道编码(摄像头编码)获取大华设备info信息
|
|
|
|
+ JSONObject json = deviceMonitorManager.getJsonObject(cameraCode, "1");
|
|
|
|
+
|
|
|
|
+ //传来关机信号,如果设备未关机,则添加告警定时任务
|
|
|
|
+ //设备状态,”0” : 不在线 “1” : 在线
|
|
|
|
+ if (!json.get("status").equals("0")) {
|
|
|
|
+ //传递关机信号,状态为0,则添加告警定时任务
|
|
|
|
+ deviceMonitorManager.startShutdownMonitoring(json.get("code").toString(), "0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取记录仪位置数据
|
|
*/
|
|
*/
|
|
@PostMapping("putDahuaRecorderLocation")
|
|
@PostMapping("putDahuaRecorderLocation")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
- public AjaxResult insertLocationListToday(@RequestBody CentermonitorTMonitoringEquipmentPositionDO centermonitorTMonitoringEquipmentPositionDO) {
|
|
|
|
|
|
+ public AjaxResult insertLocationListToday(@RequestBody CentermonitorTMonitoringEquipmentPositionDO
|
|
|
|
+ centermonitorTMonitoringEquipmentPositionDO) {
|
|
try {
|
|
try {
|
|
dahuaService.insertEquipmentPosition(centermonitorTMonitoringEquipmentPositionDO);
|
|
dahuaService.insertEquipmentPosition(centermonitorTMonitoringEquipmentPositionDO);
|
|
//更新执法记录仪经纬度
|
|
//更新执法记录仪经纬度
|
|
- log.info("获取记录仪位置数据:{}",centermonitorTMonitoringEquipmentPositionDO);
|
|
|
|
- centermonitorTMonitoringEquipmentPositionMapper.updateLongitudeAndLatitudeByCameraCode(centermonitorTMonitoringEquipmentPositionDO.getGpsX(),centermonitorTMonitoringEquipmentPositionDO.getGpsY(),centermonitorTMonitoringEquipmentPositionDO.getChannelCode());
|
|
|
|
|
|
+ log.info("获取记录仪位置数据:{}", centermonitorTMonitoringEquipmentPositionDO);
|
|
|
|
+ centermonitorTMonitoringEquipmentPositionMapper.updateLongitudeAndLatitudeByCameraCode(centermonitorTMonitoringEquipmentPositionDO.getGpsX(), centermonitorTMonitoringEquipmentPositionDO.getGpsY(), centermonitorTMonitoringEquipmentPositionDO.getChannelCode());
|
|
return AjaxResult.success();
|
|
return AjaxResult.success();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|