|
@@ -3,32 +3,36 @@ package com.css.simulation.resource.log.service;
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.pojo.constants.LogConstants;
|
|
import api.common.pojo.constants.LogConstants;
|
|
import api.common.pojo.param.log.LogPageParam;
|
|
import api.common.pojo.param.log.LogPageParam;
|
|
|
|
+import api.common.pojo.param.model.VehiclePageParam;
|
|
import api.common.pojo.param.scene.SystemUserSceneParam;
|
|
import api.common.pojo.param.scene.SystemUserSceneParam;
|
|
import api.common.pojo.po.log.LogLoginPO;
|
|
import api.common.pojo.po.log.LogLoginPO;
|
|
import api.common.pojo.po.log.LogOperationPO;
|
|
import api.common.pojo.po.log.LogOperationPO;
|
|
import api.common.pojo.po.log.LogSystemPO;
|
|
import api.common.pojo.po.log.LogSystemPO;
|
|
import api.common.pojo.po.model.VehicleTempPO;
|
|
import api.common.pojo.po.model.VehicleTempPO;
|
|
import api.common.pojo.po.scene.SystemScenePackagePO;
|
|
import api.common.pojo.po.scene.SystemScenePackagePO;
|
|
-import api.common.pojo.po.scene.SystemUserScenePO;
|
|
|
|
import api.common.pojo.po.system.ClusterPO;
|
|
import api.common.pojo.po.system.ClusterPO;
|
|
import api.common.pojo.po.system.ParameterPO;
|
|
import api.common.pojo.po.system.ParameterPO;
|
|
import api.common.pojo.po.system.UserPO;
|
|
import api.common.pojo.po.system.UserPO;
|
|
|
|
+import api.common.pojo.vo.model.VehicleTempVO;
|
|
import api.common.pojo.vo.scene.UserSceneVO;
|
|
import api.common.pojo.vo.scene.UserSceneVO;
|
|
|
|
+import api.common.pojo.vo.system.UserVO;
|
|
import api.common.util.ObjectUtil;
|
|
import api.common.util.ObjectUtil;
|
|
import api.common.util.StringUtil;
|
|
import api.common.util.StringUtil;
|
|
import api.common.util.TimeUtil;
|
|
import api.common.util.TimeUtil;
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
import com.css.simulation.resource.log.mapper.LogMapper;
|
|
import com.css.simulation.resource.log.mapper.LogMapper;
|
|
|
|
+import com.css.simulation.resource.model.mapper.VehicleTempMapper;
|
|
|
|
+import com.css.simulation.resource.system.mapper.UserMapper;
|
|
import com.css.simulation.resource.system.service.DictService;
|
|
import com.css.simulation.resource.system.service.DictService;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -40,6 +44,12 @@ public class LogService {
|
|
@Autowired
|
|
@Autowired
|
|
DictService dictService;
|
|
DictService dictService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ UserMapper userMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ VehicleTempMapper vehicleTempMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 保存普通操作日志(异步)
|
|
* 保存普通操作日志(异步)
|
|
*/
|
|
*/
|
|
@@ -64,7 +74,15 @@ public class LogService {
|
|
*/
|
|
*/
|
|
public PageInfo<LogOperationPO> getOperationLogPageList(LogPageParam pageParam) {
|
|
public PageInfo<LogOperationPO> getOperationLogPageList(LogPageParam pageParam) {
|
|
PageUtil.setPageInfo(pageParam);
|
|
PageUtil.setPageInfo(pageParam);
|
|
- List<LogOperationPO> list = logMapper.getOperationLogPageList(pageParam);
|
|
|
|
|
|
+ List<LogOperationPO> list = new ArrayList<>();
|
|
|
|
+ String roleCode = AuthUtil.getCurrentUserRoleCode();
|
|
|
|
+ if(DictConstants.ROLE_CODE_UESR.equals(roleCode)){//普通用户
|
|
|
|
+ String currentUserId = AuthUtil.getCurrentUserId();
|
|
|
|
+ pageParam.setContent(currentUserId);//借用该字段传递当前用户id
|
|
|
|
+ list = logMapper.getUserOperationLogPageList(pageParam);
|
|
|
|
+ }else{//管理员
|
|
|
|
+ list = logMapper.getOperationLogPageList(pageParam);
|
|
|
|
+ }
|
|
//字典翻译
|
|
//字典翻译
|
|
Map<String, Map<String, String>> dictMaps = dictService.getDictMapsByTypes(LogConstants.MODULE_TYPE + "," + LogConstants.OPERATION_TYPE);
|
|
Map<String, Map<String, String>> dictMaps = dictService.getDictMapsByTypes(LogConstants.MODULE_TYPE + "," + LogConstants.OPERATION_TYPE);
|
|
list.forEach(po ->{
|
|
list.forEach(po ->{
|
|
@@ -99,7 +117,8 @@ public class LogService {
|
|
String userId = userPO.getId();
|
|
String userId = userPO.getId();
|
|
String username = userPO.getUsername();
|
|
String username = userPO.getUsername();
|
|
if(ObjectUtil.isNull(username)){
|
|
if(ObjectUtil.isNull(username)){
|
|
- username = "XX";
|
|
|
|
|
|
+ UserVO userVO = userMapper.getUserInfo(userId);
|
|
|
|
+ username = userVO.getUsername();
|
|
}
|
|
}
|
|
String content = username + " ( ID: " + userId + " )";
|
|
String content = username + " ( ID: " + userId + " )";
|
|
po.setContent(content);
|
|
po.setContent(content);
|
|
@@ -116,8 +135,14 @@ public class LogService {
|
|
try {
|
|
try {
|
|
LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_VEHICLE, operationType);
|
|
LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_VEHICLE, operationType);
|
|
String vehicleTempId = vehicleTempPO.getId();
|
|
String vehicleTempId = vehicleTempPO.getId();
|
|
- String vehicleName = vehicleTempPO.getVehicleName();
|
|
|
|
- String content = vehicleName + " ( ID: " + vehicleTempId + " )";
|
|
|
|
|
|
+ String modelLabel = vehicleTempPO.getModelLabel();
|
|
|
|
+ if(ObjectUtil.isNull(modelLabel)){
|
|
|
|
+ VehiclePageParam param = new VehiclePageParam();
|
|
|
|
+ param.setId(vehicleTempId);
|
|
|
|
+ VehicleTempVO vehicleTempInfo = vehicleTempMapper.getVehicleTempInfo(param);
|
|
|
|
+ modelLabel = vehicleTempInfo.getModelLabel();
|
|
|
|
+ }
|
|
|
|
+ String content = modelLabel + " ( ID: " + vehicleTempId + " )";
|
|
po.setContent(content);
|
|
po.setContent(content);
|
|
logMapper.insertSystemLog(po);
|
|
logMapper.insertSystemLog(po);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
@@ -159,12 +184,6 @@ public class LogService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 获取系统管理日志对象
|
|
* 获取系统管理日志对象
|
|
*/
|
|
*/
|
|
@@ -180,70 +199,50 @@ public class LogService {
|
|
return po;
|
|
return po;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 记录场景包模块日志
|
|
* 记录场景包模块日志
|
|
*/
|
|
*/
|
|
- public void logScenePackage(String operationType, SystemScenePackagePO systemScenePackagePO,Map map) {
|
|
|
|
- try {
|
|
|
|
- LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_PACKAGE, operationType);
|
|
|
|
- //获取当前登录人姓名
|
|
|
|
- //String userName= AuthUtil.getCurrentUsername();
|
|
|
|
- String content=null;
|
|
|
|
- if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_DELETE)){
|
|
|
|
- content = "删除场景包:"+systemScenePackagePO.getPackageName()+"(ID:"+systemScenePackagePO.getId()+")";
|
|
|
|
- }else if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_UPDATE)){
|
|
|
|
- content = "编辑场景包:"+systemScenePackagePO.getPackageName()+"(ID:"+systemScenePackagePO.getId()+")";
|
|
|
|
- }else if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_INSERT)){
|
|
|
|
- content = "创建场景包:"+systemScenePackagePO.getPackageName()+"(ID:"+systemScenePackagePO.getId()+")";
|
|
|
|
- }else if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_DISTRIBUTION)){
|
|
|
|
- SystemUserSceneParam params=(SystemUserSceneParam)map.get("params");
|
|
|
|
- List<UserSceneVO> userIds= params.getUserIds();
|
|
|
|
- String userCount=null;
|
|
|
|
- for (UserSceneVO vo:userIds) {
|
|
|
|
- if (ObjectUtil.isNull(userCount)){
|
|
|
|
- userCount= vo.getUserName() +"(ID:"+vo.getUserId()+")";
|
|
|
|
- }else{
|
|
|
|
- userCount= userCount+"、"+vo.getUserName() +"(ID:"+vo.getUserId()+")";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- userCount=userCount+")";
|
|
|
|
- content = "分配场景包:"+params.getPackageName()+"(ID:"+params.getPackageId()+")给用户:"+userCount;
|
|
|
|
- }else if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_DISTRIBUTION_DELETE)){
|
|
|
|
- SystemUserSceneParam params=(SystemUserSceneParam)map.get("params");
|
|
|
|
- List<UserSceneVO> userIds= params.getUserIds();
|
|
|
|
- String userCount=null;
|
|
|
|
- for (UserSceneVO vo:userIds) {
|
|
|
|
- if (ObjectUtil.isNull(userCount)){
|
|
|
|
- userCount= vo.getUserName() +"(ID:"+vo.getUserId()+")";
|
|
|
|
- }else{
|
|
|
|
- userCount= userCount+"、"+vo.getUserName() +"(ID:"+vo.getUserId()+")";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- userCount=userCount+")";
|
|
|
|
- content = "分配场景包:"+params.getPackageName()+"(ID:"+params.getPackageId()+")时移除用户:"+userCount;
|
|
|
|
|
|
+ public void logScenePackage(String operationType, SystemScenePackagePO packagePO,SystemUserSceneParam params) {
|
|
|
|
+ try {
|
|
|
|
+ LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_PACKAGE, operationType);
|
|
|
|
+ //获取当前登录人姓名
|
|
|
|
+ String content=null;
|
|
|
|
+ if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_DELETE)){
|
|
|
|
+ content = "删除场景包:"+packagePO.getPackageName()+"(ID:"+packagePO.getId()+")";
|
|
|
|
+ }else if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_UPDATE)){
|
|
|
|
+ content = "编辑场景包:"+packagePO.getPackageName()+"(ID:"+packagePO.getId()+")";
|
|
|
|
+ }else if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_INSERT)){
|
|
|
|
+ content = "创建场景包:"+packagePO.getPackageName()+"(ID:"+packagePO.getId()+")";
|
|
|
|
+ }else if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_DISTRIBUTION)){
|
|
|
|
+ List<UserSceneVO> users = params.getUserIds();
|
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
|
+ for (UserSceneVO vo : users) {
|
|
|
|
+ sb.append("、").append(vo.getUserName()).append("((ID:").append(vo.getUserId()).append(")");
|
|
|
|
+ }
|
|
|
|
+ sb.deleteCharAt(0);
|
|
|
|
+ content = "分配场景包:"+params.getPackageName()+"(ID:"+params.getPackageId()+")给用户:"+sb.toString();
|
|
|
|
+ }else if(operationType.equals(LogConstants.SYS_LOG_PACKAGE_DISTRIBUTION_DELETE)){
|
|
|
|
+ List<UserSceneVO> users= params.getUserIds();
|
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
|
+ for (UserSceneVO vo : users) {
|
|
|
|
+ sb.append("、").append(vo.getUserName()).append("((ID:").append(vo.getUserId()).append(")");
|
|
}
|
|
}
|
|
- System.out.println("记录场景包模块日志:---"+content);
|
|
|
|
- po.setContent(content);
|
|
|
|
- logMapper.insertSystemLog(po);
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ sb.deleteCharAt(0);
|
|
|
|
+ content = "分配场景包:"+params.getPackageName()+"(ID:"+params.getPackageId()+")时移除用户:"+sb.toString();
|
|
}
|
|
}
|
|
|
|
+ po.setContent(content);
|
|
|
|
+ logMapper.insertSystemLog(po);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* 记录场景包分配模块日志
|
|
* 记录场景包分配模块日志
|
|
*/
|
|
*/
|
|
public void logSystemUserSceneByPackageId(String operationType, SystemUserSceneParam param,String packageCount) {
|
|
public void logSystemUserSceneByPackageId(String operationType, SystemUserSceneParam param,String packageCount) {
|
|
try {
|
|
try {
|
|
LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_PACKAGE_GRANT, operationType);
|
|
LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_PACKAGE_GRANT, operationType);
|
|
- /*//获取当前登录人姓名
|
|
|
|
- String userName= AuthUtil.getCurrentUsername();*/
|
|
|
|
- String content=null;
|
|
|
|
- content = param.getUserName()+"(ID"+param.getUserId()+")"+"分配场景包:"+packageCount;
|
|
|
|
-
|
|
|
|
- System.out.println("记录场景包分配模块日志:----"+content);
|
|
|
|
|
|
+ String content = param.getUserName()+"(ID"+param.getUserId()+")"+"分配场景包:"+packageCount;
|
|
po.setContent(content);
|
|
po.setContent(content);
|
|
logMapper.insertSystemLog(po);
|
|
logMapper.insertSystemLog(po);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
@@ -258,10 +257,7 @@ public class LogService {
|
|
try {
|
|
try {
|
|
LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_SCENE, operationType);
|
|
LogSystemPO po = getLogSystemPO(LogConstants.SYS_LOG_SCENE, operationType);
|
|
Map<String,String> mapType= dictService.getDictMapByType(DictConstants.SCENE_TYPE);
|
|
Map<String,String> mapType= dictService.getDictMapByType(DictConstants.SCENE_TYPE);
|
|
- //获取当前登录人姓名
|
|
|
|
- String userName= AuthUtil.getCurrentUsername();
|
|
|
|
- String content=null;
|
|
|
|
- content = "删除"+mapType.get(map.get("type"))+":"+map.get("sceneName")+"(ID:"+map.get("sceneId")+")" ;
|
|
|
|
|
|
+ String content = "删除"+mapType.get(map.get("type"))+":"+map.get("sceneName")+"(ID:"+map.get("sceneId")+")" ;
|
|
po.setContent(content);
|
|
po.setContent(content);
|
|
logMapper.insertSystemLog(po);
|
|
logMapper.insertSystemLog(po);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
@@ -282,4 +278,4 @@ public class LogService {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+}
|