|
|
@ -27,6 +27,68 @@ import java.util.*; |
|
|
|
@Component |
|
|
|
public class OperationLogAspect { |
|
|
|
|
|
|
|
|
|
|
|
private final static Map<String, Object> DEVICEFUNCTIONNAME = new HashMap<String, Object>() {{ |
|
|
|
put("1", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("2", new HashMap<String, Object>() {{ |
|
|
|
put("11", "文件名发送"); |
|
|
|
put("13", "文件发送"); |
|
|
|
put("1B", "指定当前需要播放的清单"); |
|
|
|
}}); |
|
|
|
put("3", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("4", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("5", new HashMap<String, Object>() {{ |
|
|
|
put("", "发布语音广播"); |
|
|
|
}}); |
|
|
|
put("6", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("7", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("8", new HashMap<String, Object>() {{ |
|
|
|
put("01", "通信连接检查"); |
|
|
|
put("0b", "配置装置参数"); |
|
|
|
put("0d", "读取装置参数"); |
|
|
|
put("0f", "读取装置状态数据"); |
|
|
|
}}); |
|
|
|
put("9", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("10", new HashMap<String, Object>() {{ |
|
|
|
put("SETMD", "模式设定命令"); |
|
|
|
put("ASKMD", "模式查询命令"); |
|
|
|
put("SETTM", "工作时间设定命令"); |
|
|
|
put("ASKTM", "工作时间查询命令"); |
|
|
|
put("SETDF", "自定义模式设置"); |
|
|
|
put("ASKDF", "自定义模式查询命令"); |
|
|
|
}}); |
|
|
|
put("11", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("12", new HashMap<String, Object>() {{ |
|
|
|
put("51", "设备控制模式"); |
|
|
|
put("52", "读取设备控制模式"); |
|
|
|
put("30", "设置自动控制模式工作状态"); |
|
|
|
put("3D", "读取自动控制模式工作状态"); |
|
|
|
put("3C", "读取当前设备工作状态"); |
|
|
|
}}); |
|
|
|
put("13", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("14", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
put("15", new HashMap<String, Object>() {{ |
|
|
|
put("A1", "查询数据"); |
|
|
|
put("A2", "查询数据"); |
|
|
|
put("A3", "查询数据"); |
|
|
|
put("A4", "查询数据"); |
|
|
|
put("A5", "查询数据"); |
|
|
|
put("A6", "查询数据"); |
|
|
|
}}); |
|
|
|
put("16", new HashMap<String, Object>() {{ |
|
|
|
}}); |
|
|
|
}}; |
|
|
|
|
|
|
|
|
|
|
|
@AfterReturning(pointcut = "@annotation(operationLog)", returning = "jsonResult") |
|
|
|
public void AfterReturning(JoinPoint joinPoint, OperationLog operationLog, Object jsonResult) throws Throwable { |
|
|
|
System.out.println("运行成功"); |
|
|
@ -110,10 +172,13 @@ public class OperationLogAspect { |
|
|
|
HashMap<String, ArrayList<JSONObject>> pointArg = (HashMap<String, ArrayList<JSONObject>>) pointArgs[0]; |
|
|
|
ArrayList<JSONObject> devices = pointArg.get("devices"); |
|
|
|
ArrayList<JSONObject> functions = pointArg.get("functions"); |
|
|
|
//StringBuilder deviceIds = new StringBuilder();
|
|
|
|
//StringBuilder functionIds = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
//ArrayList<String> deviceIds = new ArrayList<>();
|
|
|
|
ArrayList<String> functionIds = new ArrayList<>(); |
|
|
|
//ArrayList<String> functionIds = new ArrayList<>();
|
|
|
|
String deviceType = ""; |
|
|
|
|
|
|
|
|
|
|
|
for (Object dev : devices) { |
|
|
|
JSONObject device = (JSONObject) JSON.toJSON(dev); |
|
|
|
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
@ -123,21 +188,42 @@ public class OperationLogAspect { |
|
|
|
DcDevice dcDevice = list.get(0); |
|
|
|
dcOperLog.setDcDeviceId(String.valueOf(dcDevice.getId())); |
|
|
|
dcOperLog.setDcDeviceName(dcDevice.getDeviceName()); |
|
|
|
dcOperLog.setDcDeviceType(dcDevice.getDeviceType()); |
|
|
|
deviceType = dcDevice.getDeviceType(); |
|
|
|
dcOperLog.setDcDeviceType(deviceType); |
|
|
|
//deviceIds.add(String.valueOf(dcDevice.getId()));
|
|
|
|
for (Object fun : functions) { |
|
|
|
JSONObject function = (JSONObject) JSON.toJSON(fun); |
|
|
|
dcOperLog.setOperParam(function.getString("params")); |
|
|
|
//functionIds.add(function.getString("functionId"));
|
|
|
|
dcOperLog.setJsonResult(dcDevice.getDeviceName() + "设备在" + date + "调用" + sta + "ID为" + dcDevice.getId() + "的设备功能标识为" + function.getString("functionId") + "的方法"); |
|
|
|
String functionId = function.getString("functionId"); |
|
|
|
//functionIds.add(functionId);
|
|
|
|
String hashMap = String.valueOf(((HashMap<String, Object>) (DEVICEFUNCTIONNAME.get(deviceType))).get(functionId)); |
|
|
|
dcOperLog.setJsonResult("设备" + dcDevice.getDeviceName() + "在" + date + "调用了" + hashMap + "功能并且调用" + sta + "了"); |
|
|
|
dcOperLogService.addDcOperLog(dcOperLog); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//String jsonResult1 = "设备在" + date + "调用" + sta + "ID为" + deviceIds + "的设备功能标识为" + functionIds + "的方法";
|
|
|
|
//System.out.println(jsonResult1);
|
|
|
|
//System.out.println(deviceIds.toString());
|
|
|
|
//System.out.println(functionIds.toString());
|
|
|
|
//System.out.println(jsonResult1);
|
|
|
|
//DcOperLog operLog = new DcOperLog();
|
|
|
|
//SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId());
|
|
|
|
//operLog.setOperParam((Arrays.toString(pointArgs)));
|
|
|
|
//operLog.setOperLocation(loginUser.getLoginLocation());
|
|
|
|
//operLog.setOperName(loginUser.getUsername());
|
|
|
|
//operLog.setDeptName(sysDept.getDeptName());
|
|
|
|
//operLog.setDcDeviceId(deviceIds.toString());
|
|
|
|
//operLog.setOperType("2");
|
|
|
|
//operLog.setOperIp(IpUtils.getIpAddr(request));
|
|
|
|
//operLog.setOperTime(new Date());
|
|
|
|
//operLog.setDcDeviceType(deviceType);
|
|
|
|
//operLog.setJsonResult(jsonResult1);
|
|
|
|
//if (Objects.equals(state, "0")) {
|
|
|
|
// operLog.setStatus(0);
|
|
|
|
//} else {
|
|
|
|
// operLog.setStatus(1);
|
|
|
|
//}
|
|
|
|
//dcOperLogService.addDcOperLog(operLog);
|
|
|
|
|
|
|
|
} else if (operUrl.contains("functions")) { |
|
|
|
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|