Browse Source

修改预案-设备控制记录存储格式

develop
Mr.Wang 9 months ago
parent
commit
6d31b47e76
  1. 99
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

99
zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

@ -855,6 +855,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
StringBuilder remark = new StringBuilder();
iotDeviceId = device.getIotDeviceId();
HashMap<String, Object> props = new HashMap<>();
// 设备管控记录结果
JSONArray dcOperLog = new JSONArray();
// 构造设备控制记录数据格式
List<HashMap<String, List<Map<String, Object>>>> propsList = new ArrayList<>();
@ -912,6 +914,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
}
remark.append(UniversalEnum.DEVICE_CONTROL_MODE.getValue());
result.put("result", ajaxResult);
dcOperLog.add(result);
resultArray.add(result);
@ -931,6 +934,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
result.put("content", UniversalEnum.RESTORE_LAST_TIME.getValue());
result.put("result", ajaxResult1B);
resultArray.add(result);
dcOperLog.add(result);
if (ajaxResult1B.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
status = UniversalEnum.ZERO.getNumber();
} else {
@ -963,11 +967,12 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
result.put("code",UniversalEnum.FIVE_HUNDRED.getNumber());
result.put("msg",UniversalEnum.OPERATION_FAILURE.getValue());
resultArray.add(result);
dcOperLog.add(result);
status = UniversalEnum.ONE.getNumber();
} else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dcInfoBoardTemplate", foundContent);
status = boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray, functionList);
status = boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray, functionList, dcOperLog);
}
}
@ -993,40 +998,47 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
errorResult.put("deviceName", device.getDeviceName());
errorResult.put("deviceType", deviceType);
errorResult.put("content", UniversalEnum.NO_BROADCAST_CONTENT_IS_MATCHED_PROCEDURE.getValue());
JSONObject resu = new JSONObject();
resu.put("code",UniversalEnum.FIVE_HUNDRED.getNumber());
resu.put("msg","操作失败,检查设备");
errorResult.put("result",resu);
dcOperLog.add(errorResult);
resultArray.add(errorResult);
}
if (StringUtils.isEmpty(foundContent.getString("content"))) {
params.put("text", UniversalEnum.WELCOME_TO_SHANDONG_EXPRESSWAY.getValue());
} else {
params.put("text", foundContent.getString("content"));
}
}else {
if (StringUtils.isEmpty(foundContent.getString("content"))) {
params.put("text", UniversalEnum.WELCOME_TO_SHANDONG_EXPRESSWAY.getValue());
} else {
params.put("text", foundContent.getString("content"));
}
params.put("repeatTimes", UniversalEnum.THREE.getValue());
params.put("functionType", UniversalEnum.START_PA_TTS.getValue());
JSONArray termList = new JSONArray();
termList.add(JSON.parseObject(device.getOtherConfig()));
params.put("termList", termList);
params.put("repeatTimes", UniversalEnum.THREE.getValue());
params.put("functionType", UniversalEnum.START_PA_TTS.getValue());
JSONArray termList = new JSONArray();
termList.add(JSON.parseObject(device.getOtherConfig()));
params.put("termList", termList);
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName", device.getDeviceName());
result.put("deviceType", deviceType);
result.put("content", params.get("text"));
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName", device.getDeviceName());
result.put("deviceType", deviceType);
result.put("content", params.get("text"));
remark.append(UniversalEnum.RELEASE_VOICE_BROADCAST.getValue());
remark.append(UniversalEnum.RELEASE_VOICE_BROADCAST.getValue());
processingDeviceParameters(UniversalEnum.A_ONE.getValue(), functionList, params);
processingDeviceParameters(UniversalEnum.A_ONE.getValue(), functionList, params);
JSONObject returnResult = broadcastController.nearCamListDistance(params);
if (Objects.equals(returnResult.getString("retCode"), UniversalEnum.ZERO.getValue())) {
status = UniversalEnum.ZERO.getNumber();
returnResult.put("code", UniversalEnum.TWO_HUNDRED.getNumber());
} else {
status = UniversalEnum.ONE.getNumber();
returnResult.put("code", UniversalEnum.FIVE_HUNDRED.getNumber());
JSONObject returnResult = broadcastController.nearCamListDistance(params);
if (Objects.equals(returnResult.getString("retCode"), UniversalEnum.ZERO.getValue())) {
status = UniversalEnum.ZERO.getNumber();
returnResult.put("code", UniversalEnum.TWO_HUNDRED.getNumber());
} else {
status = UniversalEnum.ONE.getNumber();
returnResult.put("code", UniversalEnum.FIVE_HUNDRED.getNumber());
}
result.put("result", returnResult);
dcOperLog.add(result);
resultArray.add(result);
}
result.put("result", returnResult);
resultArray.add(result);
} else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING.toString())) {
@ -1046,6 +1058,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
AjaxResult ajaxResultState = dcDeviceController.getAjaxResult(iotDeviceId, UniversalEnum.SETMD.getValue(), map);
resultTime.put("resultState", ajaxResultState);
dcOperLog.add(getDcOperLog(device,ajaxResultState));
// 操作时长
String operationDuration = UniversalEnum.SETTM.getValue() + otherConfig.get("operationDuration").toString();
@ -1059,6 +1072,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
AjaxResult ajaxResult = dcDeviceController.getAjaxResult(iotDeviceId, functionId, propsTime);
resultTime.put("result", ajaxResult);
dcOperLog.add(getDcOperLog(device,ajaxResult));
resultArray.add(resultTime);
if (ajaxResultState.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber()) && ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
@ -1073,7 +1087,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 语音广播恢复操作不存记录
if (!(device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING.toString())
&& operationType.equals(UniversalEnum.TWO.getNumber()))) {
insertEquipmentControlRecordTable(device, propsList, resultArray, status, remark.toString(),eventId);
insertEquipmentControlRecordTable(device, propsList, dcOperLog, status, remark.toString(),eventId);
}
} catch (HttpException | IOException e) {
@ -1105,7 +1119,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
JSONObject otherConfig,
DcDevice device,
JSONArray resultArray,
List<Map<String, Object>> functionList
List<Map<String, Object>> functionList,
JSONArray dcOperLog
) throws HttpException, IOException {
String functionId = UniversalEnum.EMPTY_STRING.getValue();
Integer status = UniversalEnum.ZERO.getNumber();
@ -1119,7 +1134,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
processingDeviceParameters(functionId, functionList, props);
AjaxResult ajaxResult11 = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props);
dcOperLog.add(getDcOperLog(device,ajaxResult11));
// 13功能码执行参数构造
DcInfoBoardTemplate dcInfoBoardTemplate = JSON.parseObject(
JSON.toJSONString(otherConfig.get("dcInfoBoardTemplate")),
@ -1154,6 +1169,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (ajaxResult11.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
// 2:执行13功能码
AjaxResult ajaxResult13 = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props11);
dcOperLog.add(getDcOperLog(device,ajaxResult13));
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName", device.getDeviceName());
@ -1167,6 +1183,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
processingDeviceParameters(functionId, functionList, props1B);
AjaxResult ajaxResult1B = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props1B);
dcOperLog.add(getDcOperLog(device,ajaxResult1B));
if (ajaxResult1B.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
status = UniversalEnum.ZERO.getNumber();
} else {
@ -1175,6 +1192,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
result.put("content", dcInfoBoardTemplate.getContent());
result.put("result", ajaxResult1B);
} else {
dcOperLog.add(getDcOperLog(device,new AjaxResult(UniversalEnum.FIVE_HUNDRED.getNumber(),"操作失败")));
result.put("content", UniversalEnum.PUBLISHING_FAILURE.getValue());
result.put("result", ajaxResult13);
status = UniversalEnum.ONE.getNumber();
@ -1188,11 +1206,24 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
error.put("device",device.getId());
error.put("content",dcInfoBoardTemplate.getContent());
resultArray.add(error);
dcOperLog.add(error);
status = UniversalEnum.ONE.getNumber();
}
return status;
}
/**
* 设备管控记录结果
*/
public JSONObject getDcOperLog(DcDevice device,AjaxResult ajaxResult) {
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName", device.getDeviceName());
result.put("deviceType", device.getDeviceType());
result.put("result", ajaxResult);
return result;
}
/**
* 设备控制记录表插入
*/
@ -1222,11 +1253,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
dcOperLog.setOperIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
dcOperLog.setOperLocation(SecurityUtils.getLoginUser().getLoginLocation());
dcOperLog.setOperParam(JSON.toJSONString(propsList));
List<JSONObject> filterResult = resultList.stream()
.map(o -> JSON.parseObject(o.toString()))
.filter(jsonObject -> jsonObject.getString("device").equals(dcDevice.getId().toString()))
.collect(Collectors.toList());
dcOperLog.setJsonResult(String.valueOf(filterResult));
dcOperLog.setJsonResult(String.valueOf(resultList));
dcOperLog.setStatus(status);
dcOperLog.setOperTime(new Date());
dcOperLog.setRemark(remark);

Loading…
Cancel
Save