|
|
@ -1,8 +1,10 @@ |
|
|
|
package com.zc.business.interfaces; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept; |
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser; |
|
|
|
import com.ruoyi.common.utils.SecurityUtils; |
|
|
@ -108,7 +110,7 @@ public class OperationLogAspect { |
|
|
|
IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class); |
|
|
|
|
|
|
|
try { |
|
|
|
DcOperLog dcOperLog = new DcOperLog(); |
|
|
|
DcOperLog operLog = new DcOperLog(); |
|
|
|
String operUrl = operationLog.operUrl(); |
|
|
|
LoginUser loginUser; |
|
|
|
try { |
|
|
@ -127,7 +129,7 @@ public class OperationLogAspect { |
|
|
|
request = null; |
|
|
|
} |
|
|
|
|
|
|
|
//Object proceed = joinPoint.proceed(pointArgs);
|
|
|
|
AjaxResult proceed = (AjaxResult) joinPoint.proceed(pointArgs); |
|
|
|
//String jsonResultString = "";
|
|
|
|
//JSONArray jsonArray = (JSONArray) proceed;
|
|
|
|
//for (Object o : jsonArray) {
|
|
|
@ -147,108 +149,196 @@ public class OperationLogAspect { |
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
String date = df.format(new Date()); |
|
|
|
String sta = ""; |
|
|
|
if (Objects.equals(state, "0")) { |
|
|
|
dcOperLog.setStatus(0); |
|
|
|
sta = "成功"; |
|
|
|
if (Objects.equals(state, "0")&&Objects.equals(String.valueOf(proceed.get("code")), "200")) { |
|
|
|
//if (Objects.equals(String.valueOf(proceed.get("code")), "200")) {
|
|
|
|
operLog.setStatus(0); |
|
|
|
sta = "成功"; |
|
|
|
//} else {
|
|
|
|
// operLog.setStatus(1);
|
|
|
|
// sta = "失败";
|
|
|
|
//}
|
|
|
|
} else { |
|
|
|
dcOperLog.setStatus(1); |
|
|
|
operLog.setStatus(1); |
|
|
|
sta = "失败"; |
|
|
|
} |
|
|
|
if (operUrl.contains("batchFunctions")) { |
|
|
|
if (loginUser != null) { |
|
|
|
SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId()); |
|
|
|
|
|
|
|
dcOperLog.setOperName(loginUser.getUsername()); |
|
|
|
dcOperLog.setDeptName(sysDept.getDeptName()); |
|
|
|
dcOperLog.setOperLocation(loginUser.getLoginLocation()); |
|
|
|
dcOperLog.setOperType("2"); |
|
|
|
} else { |
|
|
|
dcOperLog.setOperType("1"); |
|
|
|
} |
|
|
|
dcOperLog.setOperIp(IpUtils.getIpAddr(request)); |
|
|
|
dcOperLog.setOperTime(new Date()); |
|
|
|
|
|
|
|
ArrayList<String> deviceIds = new ArrayList<>(); |
|
|
|
ArrayList<String> deviceNames = new ArrayList<>(); |
|
|
|
//ArrayList<String> functionIds = new ArrayList<>();
|
|
|
|
String deviceType = ""; |
|
|
|
StringBuilder remark = new StringBuilder("在" + date + "调用"); |
|
|
|
if (operUrl.contains("batchFunctions")) { |
|
|
|
//批量调用
|
|
|
|
|
|
|
|
HashMap<String, ArrayList<JSONObject>> pointArg = (HashMap<String, ArrayList<JSONObject>>) pointArgs[0]; |
|
|
|
ArrayList<JSONObject> devices = pointArg.get("devices"); |
|
|
|
ArrayList<JSONObject> functions = pointArg.get("functions"); |
|
|
|
//if (loginUser != null) {
|
|
|
|
// SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId());
|
|
|
|
//
|
|
|
|
// dcOperLog.setOperName(loginUser.getUsername());
|
|
|
|
// dcOperLog.setDeptName(sysDept.getDeptName());
|
|
|
|
// dcOperLog.setOperLocation(loginUser.getLoginLocation());
|
|
|
|
// dcOperLog.setOperType("2");
|
|
|
|
//} else {
|
|
|
|
// dcOperLog.setOperType("1");
|
|
|
|
//}
|
|
|
|
//dcOperLog.setOperIp(IpUtils.getIpAddr(request));
|
|
|
|
//dcOperLog.setOperTime(new Date());
|
|
|
|
|
|
|
|
JSONObject pointArg = (JSONObject) pointArgs[0]; |
|
|
|
JSONArray devices = pointArg.getJSONArray("devices"); |
|
|
|
JSONArray functions = pointArg.getJSONArray("functions"); |
|
|
|
|
|
|
|
//ArrayList<String> deviceIds = new ArrayList<>();
|
|
|
|
//ArrayList<String> functionIds = new ArrayList<>();
|
|
|
|
String deviceType = ""; |
|
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
|
|
|
|
|
JSONObject device = (JSONObject) JSON.toJSON(devices.get(i)); |
|
|
|
|
|
|
|
for (Object dev : devices) { |
|
|
|
JSONObject device = (JSONObject) JSON.toJSON(dev); |
|
|
|
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
lambdaQueryWrapper.eq(DcDevice::getId, device.get("id")); |
|
|
|
List<DcDevice> list = dcDeviceService.list(lambdaQueryWrapper); |
|
|
|
if (list.size() > 0) { |
|
|
|
DcDevice dcDevice = list.get(0); |
|
|
|
dcOperLog.setDcDeviceId(String.valueOf(dcDevice.getId())); |
|
|
|
dcOperLog.setDcDeviceName(dcDevice.getDeviceName()); |
|
|
|
DcDevice dcDevice = dcDeviceService.getById(device.getString("id")); |
|
|
|
|
|
|
|
if (!Objects.isNull(dcDevice)) { |
|
|
|
Long deviceId = dcDevice.getId(); |
|
|
|
String deviceName = dcDevice.getDeviceName(); |
|
|
|
|
|
|
|
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")); |
|
|
|
String functionId = function.getString("functionId"); |
|
|
|
//functionIds.add(functionId);
|
|
|
|
String hashMap = Objects.equals(deviceType, "5") ?"发布语音广播":String.valueOf(((HashMap<String, Object>) (DEVICEFUNCTIONNAME.get(deviceType))).get(functionId)); |
|
|
|
dcOperLog.setJsonResult("设备" + dcDevice.getDeviceName() + "在" + date + "调用了" + hashMap + "功能并且调用" + sta + "了"); |
|
|
|
dcOperLogService.addDcOperLog(dcOperLog); |
|
|
|
|
|
|
|
deviceIds.add(String.valueOf(deviceId)); |
|
|
|
deviceNames.add(deviceName); |
|
|
|
|
|
|
|
remark.append(deviceName).append("的"); |
|
|
|
|
|
|
|
for (int i1 = 0; i1 < functions.size(); i1++) { |
|
|
|
|
|
|
|
JSONObject function = (JSONObject) JSON.toJSON(functions.get(i1)); |
|
|
|
|
|
|
|
String hashMap = Objects.equals(deviceType, "5") ? |
|
|
|
"发布语音广播" : |
|
|
|
String.valueOf( |
|
|
|
((HashMap<String, Object>) (DEVICEFUNCTIONNAME.get(deviceType))) |
|
|
|
.get(function.getString("functionId"))); |
|
|
|
|
|
|
|
remark.append("调用").append(hashMap).append("功能").append(sta); |
|
|
|
|
|
|
|
if (i1 < functions.size() - 1) { |
|
|
|
remark.append("、"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (i < (devices.size() - 1)) { |
|
|
|
remark.append(","); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//String jsonResult1 = "设备在" + date + "调用" + sta + "ID为" + deviceIds + "的设备功能标识为" + functionIds + "的方法";
|
|
|
|
//System.out.println(jsonResult1);
|
|
|
|
//System.out.println(deviceIds.toString());
|
|
|
|
//System.out.println(functionIds.toString());
|
|
|
|
//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);
|
|
|
|
|
|
|
|
|
|
|
|
if (loginUser != null) { |
|
|
|
SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId()); |
|
|
|
|
|
|
|
operLog.setOperName(loginUser.getUsername()); |
|
|
|
operLog.setDeptName(sysDept.getDeptName()); |
|
|
|
operLog.setOperLocation(loginUser.getLoginLocation()); |
|
|
|
operLog.setOperType("2"); |
|
|
|
} else { |
|
|
|
operLog.setOperType("1"); |
|
|
|
} |
|
|
|
operLog.setOperParam((Arrays.toString(pointArgs))); |
|
|
|
operLog.setDcDeviceId(deviceIds.toString()); |
|
|
|
operLog.setDcDeviceName(deviceNames.toString()); |
|
|
|
operLog.setOperIp(IpUtils.getIpAddr(request)); |
|
|
|
operLog.setOperTime(new Date()); |
|
|
|
operLog.setDcDeviceType(deviceType); |
|
|
|
operLog.setRemark(remark.toString()); |
|
|
|
operLog.setJsonResult(String.valueOf(proceed)); |
|
|
|
dcOperLogService.addDcOperLog(operLog); |
|
|
|
|
|
|
|
|
|
|
|
} else if (operUrl.contains("functions")) { |
|
|
|
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
lambdaQueryWrapper.eq(DcDevice::getIotDeviceId, pointArgs[0]); |
|
|
|
List<DcDevice> list = dcDeviceService.list(lambdaQueryWrapper); |
|
|
|
if (list.size() > 0) { |
|
|
|
DcDevice dcDevice = list.get(0); |
|
|
|
dcOperLog.setDcDeviceId(String.valueOf(dcDevice.getId())); |
|
|
|
dcOperLog.setDcDeviceName(dcDevice.getDeviceName()); |
|
|
|
dcOperLog.setDcDeviceType(dcDevice.getDeviceType()); |
|
|
|
DcDevice dcDevice = dcDeviceService.getById(Long.valueOf(String.valueOf(pointArgs[0]))); |
|
|
|
if (!Objects.isNull(dcDevice)) { |
|
|
|
|
|
|
|
Long deviceId = dcDevice.getId(); |
|
|
|
String deviceName = dcDevice.getDeviceName(); |
|
|
|
|
|
|
|
deviceType = dcDevice.getDeviceType(); |
|
|
|
|
|
|
|
deviceIds.add(String.valueOf(deviceId)); |
|
|
|
deviceNames.add(deviceName); |
|
|
|
|
|
|
|
String functionId = String.valueOf(pointArgs[1]); |
|
|
|
String hashMap = Objects.equals(deviceType, "5") ? "发布语音广播" : String.valueOf(((HashMap<String, Object>) (DEVICEFUNCTIONNAME.get(deviceType))).get(functionId)); |
|
|
|
|
|
|
|
remark.append(deviceName).append("的").append(hashMap).append("功能并且调用").append(sta).append("了"); |
|
|
|
|
|
|
|
|
|
|
|
if (loginUser != null) { |
|
|
|
SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId()); |
|
|
|
|
|
|
|
dcOperLog.setOperName(loginUser.getUsername()); |
|
|
|
dcOperLog.setDeptName(sysDept.getDeptName()); |
|
|
|
dcOperLog.setOperLocation(loginUser.getLoginLocation()); |
|
|
|
dcOperLog.setOperType("0"); |
|
|
|
operLog.setOperName(loginUser.getUsername()); |
|
|
|
operLog.setDeptName(sysDept.getDeptName()); |
|
|
|
operLog.setOperLocation(loginUser.getLoginLocation()); |
|
|
|
operLog.setOperType("2"); |
|
|
|
} else { |
|
|
|
dcOperLog.setOperType("1"); |
|
|
|
operLog.setOperType("1"); |
|
|
|
} |
|
|
|
dcOperLog.setOperIp(IpUtils.getIpAddr(request)); |
|
|
|
dcOperLog.setOperParam(Arrays.toString(pointArgs)); |
|
|
|
dcOperLog.setJsonResult(dcDevice.getDeviceName() + "设备在" + date + "调用" + sta + "ID为" + dcDevice.getId() + "的设备功能标识为" + pointArgs[1].toString() + "的方法"); |
|
|
|
dcOperLog.setOperTime(new Date()); |
|
|
|
dcOperLogService.addDcOperLog(dcOperLog); |
|
|
|
operLog.setOperParam((Arrays.toString(pointArgs))); |
|
|
|
operLog.setDcDeviceId(deviceIds.toString()); |
|
|
|
operLog.setDcDeviceName(deviceNames.toString()); |
|
|
|
operLog.setOperIp(IpUtils.getIpAddr(request)); |
|
|
|
operLog.setOperTime(new Date()); |
|
|
|
operLog.setDcDeviceType(deviceType); |
|
|
|
operLog.setJsonResult(remark.toString()); |
|
|
|
dcOperLogService.addDcOperLog(operLog); |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
////DcDevice dcDevice = list.get(0);
|
|
|
|
//operLog.setDcDeviceId(String.valueOf(dcDevice.getId()));
|
|
|
|
//operLog.setDcDeviceName(dcDevice.getDeviceName());
|
|
|
|
//deviceType = dcDevice.getDeviceType();
|
|
|
|
//operLog.setDcDeviceType(deviceType);
|
|
|
|
//if (loginUser != null) {
|
|
|
|
// SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId());
|
|
|
|
//
|
|
|
|
// dcOperLog.setOperName(loginUser.getUsername());
|
|
|
|
// dcOperLog.setDeptName(sysDept.getDeptName());
|
|
|
|
// dcOperLog.setOperLocation(loginUser.getLoginLocation());
|
|
|
|
// dcOperLog.setOperType("0");
|
|
|
|
//} else {
|
|
|
|
// dcOperLog.setOperType("1");
|
|
|
|
//}
|
|
|
|
//dcOperLog.setOperIp(IpUtils.getIpAddr(request));
|
|
|
|
//dcOperLog.setOperParam(Arrays.toString(pointArgs));
|
|
|
|
//dcOperLog.setJsonResult("设备" + dcDevice.getDeviceName() + "在" + date + "调用了" + hashMap + "功能并且调用" + sta + "了");
|
|
|
|
////dcOperLog.setJsonResult(dcDevice.getDeviceName() + "设备在" + date + "调用" + sta + "ID为" + dcDevice.getId() + "的设备功能标识为" + pointArgs[1].toString() + "的方法");
|
|
|
|
//dcOperLog.setOperTime(new Date());
|
|
|
|
//dcOperLogService.addDcOperLog(dcOperLog);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//String remark = "设备在" + date + "调用" + sta + "ID为" + deviceIds + "的设备功能标识为" + functionIds + "的方法";
|
|
|
|
//System.out.println(remark);
|
|
|
|
//System.out.println(deviceIds.toString());
|
|
|
|
//System.out.println(functionIds.toString());
|
|
|
|
//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(remark);
|
|
|
|
//if (Objects.equals(state, "0")) {
|
|
|
|
// operLog.setStatus(0);
|
|
|
|
//} else {
|
|
|
|
// operLog.setStatus(1);
|
|
|
|
//}
|
|
|
|
//dcOperLogService.addDcOperLog(operLog);
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|