Browse Source

优化设备调用记录内容

develop
zhaoxianglong 8 months ago
parent
commit
a4f435273d
  1. 84
      zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java

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

@ -139,21 +139,21 @@ public class OperationLogAspect {
}
SimpleDateFormat df = new SimpleDateFormat(UniversalEnum.TIME_FORMAT_ALL.getValue());
String date = df.format(new Date());
String sta = UniversalEnum.EMPTY_STRING.getValue();
//SimpleDateFormat df = new SimpleDateFormat(UniversalEnum.TIME_FORMAT_ALL.getValue());
//String date = df.format(new Date());
//String sta = UniversalEnum.EMPTY_STRING.getValue();
if (Objects.equals(state, UniversalEnum.ZERO.getValue()) && Objects.equals(String.valueOf(((AjaxResult) jsonResult).get("code")), UniversalEnum.TWO_HUNDRED.getValue()) && !Objects.equals(String.valueOf(((AjaxResult) jsonResult).get("msg")), UniversalEnum.FIVE_HUNDRED.getValue())) {
operLog.setStatus(UniversalEnum.ZERO.getNumber());
sta = UniversalEnum.SUCCESSFUL.getValue();
//sta = UniversalEnum.SUCCESSFUL.getValue();
} else {
operLog.setStatus(UniversalEnum.ONE.getNumber());
sta = UniversalEnum.LOSE.getValue();
//sta = UniversalEnum.LOSE.getValue();
}
ArrayList<String> deviceIds = new ArrayList<>();
ArrayList<String> deviceNames = new ArrayList<>();
String deviceType = UniversalEnum.EMPTY_STRING.getValue();
StringBuilder remark = new StringBuilder("在" + date + UniversalEnum.INVOKE.getValue());
StringBuilder remark = new StringBuilder();
if (operUrl.contains(UniversalEnum.BATCH_FUNCTIONS.getValue())) {
//批量调用
JSONObject pointArg = null;
@ -162,7 +162,7 @@ public class OperationLogAspect {
} else {
pointArg = (JSONObject) JSON.toJSON(pointArgs[UniversalEnum.ZERO.getNumber()]);
}
String contentDetails = UniversalEnum.EMPTY_STRING.getValue();
//String contentDetails = UniversalEnum.EMPTY_STRING.getValue();
JSONArray devices = pointArg.getJSONArray("devices");
JSONArray functions = pointArg.getJSONArray("functions");
@ -185,42 +185,59 @@ public class OperationLogAspect {
deviceIds.add(String.valueOf(deviceId));
deviceNames.add(deviceName);
remark.append(deviceName).append("的");
//remark.append(deviceName);
for (int i1 = UniversalEnum.ZERO.getNumber(); i1 < functions.size(); i1++) {
JSONObject function = (JSONObject) JSON.toJSON(functions.get(i1));
String functionId = function.getString("functionId");
if (Objects.equals(functionId, UniversalEnum.A_ONE.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_TWO.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_THREE.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_FOUR.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_FIVE.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_SIX.getValue()) ||
Objects.equals(functionId, UniversalEnum.ASKMD.getValue()) ||
Objects.equals(functionId, UniversalEnum.ASKTM.getValue()) ||
Objects.equals(functionId, UniversalEnum.ASKDF.getValue()) ||
Objects.equals(functionId, UniversalEnum.FIFTY_TWO.getValue()) ||
Objects.equals(functionId, UniversalEnum.THREE_D.getValue()) ||
Objects.equals(functionId, UniversalEnum.THREE_C.getValue())) {
return;
}
String hashMap = Objects.equals(deviceType, UniversalEnum.FIVE.getValue()) ?
UniversalEnum.RELEASE_VOICE_BROADCAST.getValue() :
String.valueOf(
((HashMap<String, Object>) (DEVICEFUNCTIONNAME.get(deviceType)))
.get(function.getString("functionId")) == null ?
.get(functionId) == null ?
UniversalEnum.UNKNOWN_METHOD.getValue() :
((HashMap<String, Object>) (DEVICEFUNCTIONNAME.get(deviceType)))
.get(function.getString("functionId")));
.get(functionId));
remark.append(UniversalEnum.INVOKE.getValue()).append(hashMap).append(UniversalEnum.FEATURE.getValue()).append(sta);
remark.append(deviceName).append(UniversalEnum.INVOKE.getValue()).append(hashMap).append(UniversalEnum.FEATURE.getValue());
if (i1 < functions.size() - UniversalEnum.ONE.getNumber()) {
remark.append(UniversalEnum.SEMICOLON.getValue());
}
if (Objects.equals(function.getString("functionId"), UniversalEnum.THIRTEEN.getValue()) && Objects.equals(deviceType, UniversalEnum.TWO.getValue())) {
JSONArray parameters = function.getJSONObject("params").getJSONArray("parameters");
List<String> content = parameters.stream().map(item -> ((JSONObject) item).getString("CONTENT")).collect(Collectors.toList());
contentDetails = content.toString().replace(UniversalEnum.LEFT_CENTER_BRACKET.getValue(), UniversalEnum.EMPTY_STRING.getValue()).replace(UniversalEnum.CLOSE_CENTER_BRACKET.getValue(), UniversalEnum.EMPTY_STRING.getValue());
}
if (Objects.equals(deviceType, UniversalEnum.FIVE.getValue())) {
contentDetails = function.getJSONObject("params").getString("text");
}
//if (Objects.equals(function.getString("functionId"), UniversalEnum.THIRTEEN.getValue()) && Objects.equals(deviceType, UniversalEnum.TWO.getValue())) {
// JSONArray parameters = function.getJSONObject("params").getJSONArray("parameters");
// List<String> content = parameters.stream().map(item -> ((JSONObject) item).getString("CONTENT")).collect(Collectors.toList());
// contentDetails = content.toString().replace(UniversalEnum.LEFT_CENTER_BRACKET.getValue(), UniversalEnum.EMPTY_STRING.getValue()).replace(UniversalEnum.CLOSE_CENTER_BRACKET.getValue(), UniversalEnum.EMPTY_STRING.getValue());
//}
//
//
//if (Objects.equals(deviceType, UniversalEnum.FIVE.getValue())) {
// contentDetails = function.getJSONObject("params").getString("text");
//}
}
if (i < (devices.size() - UniversalEnum.ONE.getNumber())) {
remark.append(UniversalEnum.COMMA.getValue());
remark.append(UniversalEnum.SEMICOLON.getValue());
}
}
@ -240,8 +257,11 @@ public class OperationLogAspect {
operLog.setOperType(UniversalEnum.ONE.getValue());
}
saveOperLog(jsonResult, operLog, pointArgs, request, deviceIds, deviceNames, deviceType, remark);
//if (Objects.equals(deviceType, UniversalEnum.FIFTEEN.getValue())) {
// return;
//}
saveOperLog(jsonResult, operLog, pointArgs, request, deviceIds, deviceNames, deviceType, remark);
if ((Objects.equals(deviceType, UniversalEnum.TWO.getValue()) || Objects.equals(deviceType, UniversalEnum.FIVE.getValue())) && Objects.nonNull(operLog.getId())) {
@ -294,9 +314,25 @@ public class OperationLogAspect {
deviceNames.add(deviceName);
String functionId = String.valueOf(pointArgs[UniversalEnum.ONE.getNumber()]);
if (Objects.equals(functionId, UniversalEnum.A_ONE.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_TWO.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_THREE.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_FOUR.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_FIVE.getValue()) ||
Objects.equals(functionId, UniversalEnum.A_SIX.getValue()) ||
Objects.equals(functionId, UniversalEnum.ASKMD.getValue()) ||
Objects.equals(functionId, UniversalEnum.ASKTM.getValue()) ||
Objects.equals(functionId, UniversalEnum.ASKDF.getValue()) ||
Objects.equals(functionId, UniversalEnum.FIFTY_TWO.getValue()) ||
Objects.equals(functionId, UniversalEnum.THREE_D.getValue()) ||
Objects.equals(functionId, UniversalEnum.THREE_C.getValue())) {
return;
}
String hashMap = Objects.equals(deviceType, UniversalEnum.FIVE.getValue()) ? UniversalEnum.RELEASE_VOICE_BROADCAST.getValue() : String.valueOf(((HashMap<String, Object>) (DEVICEFUNCTIONNAME.get(deviceType))).get(functionId));
remark.append(deviceName).append("的").append(hashMap).append("功能并且调用").append(sta).append("了");
remark.append(deviceName).append(UniversalEnum.INVOKE.getValue()).append(hashMap).append(UniversalEnum.FEATURE.getValue());
if (loginUser != null) {
SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId());

Loading…
Cancel
Save