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