From d23ec80f678b2a6060548c652f5ff7ffa6aba1fc Mon Sep 17 00:00:00 2001 From: bayuzhen Date: Thu, 29 Aug 2024 14:26:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=AE=A1=E8=AE=A1=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9B=B8=E5=85=B3=E5=AD=97=E6=AE=B5=E4=B8=8E=E8=BF=90?= =?UTF-8?q?=E6=8E=A7=E7=B3=BB=E7=BB=9F=E6=97=A5=E5=BF=97=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bocloud/sms/service/LogServiceImpl.java | 85 ++++++++++++++++++- 1 file changed, 81 insertions(+), 4 deletions(-) diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/LogServiceImpl.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/LogServiceImpl.java index ac7de35..1feb6dd 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/LogServiceImpl.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/LogServiceImpl.java @@ -51,12 +51,12 @@ public class LogServiceImpl implements LogService { @Autowired private KafkaTemplate kafkaTemplate; - @Value("${log.push.systemNumber:0}") - private String systemNumber; // 日志推送系统编号 - @Value("${log.push.systemNameCn:0}") - private String systemNameCn; // 日志推送系统名称 @Value("${log.push.topic:YK_USER_LOG_TOPIC}") private String topic; // 日志推送主题名称 + @Value("${log.push.systemNumber:0101070000010005}") + private String systemNumber; // 日志推送系统编号 + @Value("${log.push.systemNameCn:云管平台}") + private String systemNameCn; // 日志推送系统名称 @Value("${log.push.enable:false}") private Boolean enable; // 日志推送开关 @Value("${spring.cloud.zookeeper.discovery.instance-host:127.0.0.1}") @@ -214,10 +214,16 @@ public class LogServiceImpl implements LogService { if (userMap.containsKey(accessLog.getUserId())) { kafkaLog.setSubjectName(userMap.get(accessLog.getUserId())); } + String logType = convertLogType(accessLog); + kafkaLog.setLogType(logType); kafkaLog.setSystemNumber(systemNumber); kafkaLog.setSystemNameCn(systemNameCn); kafkaLog.setSystemAddress(host); kafkaLog.setMessage(accessLog.getAction()); + String objectType = convertObjectType(accessLog); + kafkaLog.setObjectType(objectType); + String operation = convertOperation(accessLog); + kafkaLog.setOperation(operation); kafkaLog.setSubjectAddress(accessLog.getRequestIp()); kafkaLog.setStartTime(simpleFormat.format(accessLog.getGmtCreate())); String outcome = "0"; @@ -234,4 +240,75 @@ public class LogServiceImpl implements LogService { } + + private String convertOperation(AccessLog accessLog) { + // 参考系统操作日志标准V20240528 文档 + switch (accessLog.getAction()) { + case "主页配置列表展示": + return "101"; + case "订单数量统计": + case "获取平台信息": + case "获取服务列表": + case "获取网段列表": + case "根据code查询服务类型": + case "作业模板列表": + case "同步云供应商数据": + case "获取主机资源列表": + case "作业实例列表": + return "105"; + case "恢复快照": + return "109"; + case "资源池分组": + case "云主机用户分配": + case "更新系统配置": + return "403"; + case "订单分析概览": + return "410"; + default: + return "5"; + } + } + + private String convertObjectType(AccessLog accessLog) { + // 参考系统操作日志标准V20240528 文档 + switch (accessLog.getTarget()) { + case "系统配置管理": + case "运营分析管理": + case "首页概览数据": + return "1"; + case "云服务管理": + return "2"; + case "云供应商": + case "主机资源": + return "4"; + case "作业实例管理": + case "流程实例": + case "作业模板管理": + case "作业场景管理": + return "10"; + case "云主机管理": + return "12"; + case "权限管理": + return "14"; + default: + return "5"; + } + } + + private String convertLogType(AccessLog accessLog) { + // 登录, 登出 + if (accessLog.getTarget().equals("登录管理") && accessLog.getAction().equals("用户登录系统")) { + return "2"; + } + if (accessLog.getTarget().equals("登录管理") && accessLog.getAction().equals("用户退出系统")) { + return "3"; + } + if (accessLog.getCatalog().equals("Manager")) { + return "1"; + } + if (accessLog.getCatalog().equals("User")) { + return "4"; + } + return "5"; + } }