From fe318d1d277d5c78c155861c30c7ab378ead4903 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Fri, 26 Apr 2024 21:24:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AE=A1=E6=8E=A7=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=AD=98=E5=82=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interfaces/OperationLogAspect.java | 100 ++++++++++++++++-- .../service/impl/DcOperLogServiceImpl.java | 5 +- 2 files changed, 97 insertions(+), 8 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java b/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java index 5117f35e..f65f09f2 100644 --- a/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java +++ b/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java @@ -27,6 +27,68 @@ import java.util.*; @Component public class OperationLogAspect { + + private final static Map DEVICEFUNCTIONNAME = new HashMap() {{ + put("1", new HashMap() {{ + }}); + put("2", new HashMap() {{ + put("11", "文件名发送"); + put("13", "文件发送"); + put("1B", "指定当前需要播放的清单"); + }}); + put("3", new HashMap() {{ + }}); + put("4", new HashMap() {{ + }}); + put("5", new HashMap() {{ + put("", "发布语音广播"); + }}); + put("6", new HashMap() {{ + }}); + put("7", new HashMap() {{ + }}); + put("8", new HashMap() {{ + put("01", "通信连接检查"); + put("0b", "配置装置参数"); + put("0d", "读取装置参数"); + put("0f", "读取装置状态数据"); + }}); + put("9", new HashMap() {{ + }}); + put("10", new HashMap() {{ + put("SETMD", "模式设定命令"); + put("ASKMD", "模式查询命令"); + put("SETTM", "工作时间设定命令"); + put("ASKTM", "工作时间查询命令"); + put("SETDF", "自定义模式设置"); + put("ASKDF", "自定义模式查询命令"); + }}); + put("11", new HashMap() {{ + }}); + put("12", new HashMap() {{ + put("51", "设备控制模式"); + put("52", "读取设备控制模式"); + put("30", "设置自动控制模式工作状态"); + put("3D", "读取自动控制模式工作状态"); + put("3C", "读取当前设备工作状态"); + }}); + put("13", new HashMap() {{ + }}); + put("14", new HashMap() {{ + }}); + put("15", new HashMap() {{ + put("A1", "查询数据"); + put("A2", "查询数据"); + put("A3", "查询数据"); + put("A4", "查询数据"); + put("A5", "查询数据"); + put("A6", "查询数据"); + }}); + put("16", new HashMap() {{ + }}); + }}; + + @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> pointArg = (HashMap>) pointArgs[0]; ArrayList devices = pointArg.get("devices"); ArrayList functions = pointArg.get("functions"); - //StringBuilder deviceIds = new StringBuilder(); - //StringBuilder functionIds = new StringBuilder(); + + //ArrayList deviceIds = new ArrayList<>(); - ArrayList functionIds = new ArrayList<>(); + //ArrayList functionIds = new ArrayList<>(); + String deviceType = ""; + + for (Object dev : devices) { JSONObject device = (JSONObject) JSON.toJSON(dev); LambdaQueryWrapper 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) (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 lambdaQueryWrapper = new LambdaQueryWrapper<>(); diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java index 53bf6320..96362b29 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java @@ -52,7 +52,10 @@ public class DcOperLogServiceImpl extends ServiceImpl