From 0ddce7fb2009333d6592d93b4e690c6382523934 Mon Sep 17 00:00:00 2001
From: wty <419034340@qq.com>
Date: Tue, 11 Oct 2022 14:04:13 +0800
Subject: [PATCH 1/2] ignore mybatisGenerate files
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 196e0b5..da07579 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ xiuosiot-frontend/dist/
xiuosiot-frontend/node_modules/
xiuosiot-backend/src/main/resources/mybatisGenerate/generatormapper/ProtocolProductInfoMapper.java
xiuosiot-backend/src/main/resources/generatorConfig.xml
+xiuosiot-backend/src/main/resources/mybatisGenerate/
From b859391df777d095606842ae6355d2cf7537942a Mon Sep 17 00:00:00 2001
From: wty <419034340@qq.com>
Date: Mon, 24 Oct 2022 16:14:16 +0800
Subject: [PATCH 2/2] add request log and device log for select
---
.gitignore | 2 +
xiuosiot-backend/pom.xml | 7 +
.../xiuos/Interceptor/AroundLogAspect.java | 115 +++++++++++
.../com/aiit/xiuos/Utils/GenerateIdUtil.java | 6 +
.../aiit/xiuos/controller/LogController.java | 51 +++++
.../xiuos/controller/LoginController.java | 2 +-
.../dao/mappers/DeviceLogInfoMapper.java | 29 +++
.../dao/mappers/RequestLogInfoMapper.java | 26 +++
.../com/aiit/xiuos/model/DeviceLogInfo.java | 39 ++++
.../com/aiit/xiuos/model/RequestLogInfo.java | 54 ++++++
.../aiit/xiuos/scheduled/TaskScheduled.java | 41 +++-
.../aiit/xiuos/service/LogInfoService.java | 13 ++
.../impl/RequestLogInfoServiceImpl.java | 39 ++++
.../src/main/resources/application.yml | 7 +-
.../mappers/RequestLogInfoMapper.xml | 179 ++++++++++++++++++
15 files changed, 604 insertions(+), 6 deletions(-)
create mode 100644 xiuosiot-backend/src/main/java/com/aiit/xiuos/Interceptor/AroundLogAspect.java
create mode 100644 xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LogController.java
create mode 100644 xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/DeviceLogInfoMapper.java
create mode 100644 xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/RequestLogInfoMapper.java
create mode 100644 xiuosiot-backend/src/main/java/com/aiit/xiuos/model/DeviceLogInfo.java
create mode 100644 xiuosiot-backend/src/main/java/com/aiit/xiuos/model/RequestLogInfo.java
create mode 100644 xiuosiot-backend/src/main/java/com/aiit/xiuos/service/LogInfoService.java
create mode 100644 xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/RequestLogInfoServiceImpl.java
create mode 100644 xiuosiot-backend/src/main/resources/mappers/RequestLogInfoMapper.xml
diff --git a/.gitignore b/.gitignore
index da07579..48423ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@ xiuosiot-frontend/node_modules/
xiuosiot-backend/src/main/resources/mybatisGenerate/generatormapper/ProtocolProductInfoMapper.java
xiuosiot-backend/src/main/resources/generatorConfig.xml
xiuosiot-backend/src/main/resources/mybatisGenerate/
+*.log
+*.gz
diff --git a/xiuosiot-backend/pom.xml b/xiuosiot-backend/pom.xml
index f2d16df..dd2e03c 100644
--- a/xiuosiot-backend/pom.xml
+++ b/xiuosiot-backend/pom.xml
@@ -95,6 +95,13 @@
true
+
+ org.springframework.boot
+ spring-boot-starter-aop
+ 1.4.1.RELEASE
+
+
+
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/Interceptor/AroundLogAspect.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/Interceptor/AroundLogAspect.java
new file mode 100644
index 0000000..045494f
--- /dev/null
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/Interceptor/AroundLogAspect.java
@@ -0,0 +1,115 @@
+package com.aiit.xiuos.Interceptor;
+
+import com.aiit.xiuos.Utils.Constant;
+import com.aiit.xiuos.Utils.MyUtils;
+import com.aiit.xiuos.Utils.ResultRespons;
+import com.aiit.xiuos.model.RequestLogInfo;
+import com.aiit.xiuos.model.UserInfo;
+import com.aiit.xiuos.service.LogInfoService;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StopWatch;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Map;
+
+@Aspect
+@Slf4j
+@Component
+public class AroundLogAspect {
+ @Autowired
+ LogInfoService requestLogInfoService;
+ public AroundLogAspect(){}
+
+ @Pointcut("execution(* com.aiit.xiuos.controller..*.*(..))")
+ public void normalPointcut() {
+ }
+ @Pointcut("execution(* com.aiit.xiuos.controller.LoginController.*(..))")
+ public void excludePointcut() {
+ }
+
+ @Pointcut("normalPointcut() && !excludePointcut()")
+ public void pointCutMethod() {
+ }
+
+
+ @Around("pointCutMethod()")
+ public Object aroundLog(ProceedingJoinPoint point) throws ParseException {
+
+ RequestLogInfo requestLogInfo =new RequestLogInfo();
+ StopWatch started = new StopWatch();
+ //请求时间
+ requestLogInfo.setRequesttime(MyUtils.getDateTime());
+
+ try {
+ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+ MethodSignature signature = (MethodSignature) point.getSignature();
+ Method method = signature.getMethod();
+ //所属公司
+ UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
+ if(userInfo==null){
+ return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!");
+ }
+ requestLogInfo.setOrg(userInfo.getOrg());
+ //IP
+ String ip = MyUtils.getIp(request);
+ requestLogInfo.setRequestip(ip);
+ //url
+ String url = request.getRequestURI();
+ requestLogInfo.setRequesturl(url);
+ //type
+ String type = request.getMethod();
+ requestLogInfo.setRequesttype(type);
+ //header 根据header名获取header值
+ Map headerMap = new HashMap<>();
+ headerMap.put("accept-encoding",request.getHeader("accept-encoding"));
+ headerMap.put("user-agent",request.getHeader("user-agent"));
+ headerMap.put("connection",request.getHeader("connection"));
+ headerMap.put("content-type",request.getHeader("content-type"));
+ requestLogInfo.setRequestheader(headerMap.toString());
+ //类名
+ String className= point.getTarget().getClass().getName();
+ requestLogInfo.setClassname(className);
+ //方法名
+ String methodName = method.getName();
+ requestLogInfo.setMethodname(methodName);
+ //参数名
+ Parameter[] parameters = method.getParameters();
+
+ requestLogInfo.setRequestparam(parameters[0].getName());
+ //计时开始
+ started.start();
+
+ ResultRespons proceed = (ResultRespons) point.proceed();
+ //计时结束
+ started.stop();
+
+ //请求耗时
+ requestLogInfo.setProcesstime(String.valueOf(started.getTotalTimeMillis()));
+ log.info("processtime:"+started.getTotalTimeMillis());
+ //请求结果
+ requestLogInfo.setRequestresult("resultCoe="+proceed.getCode()+" resultMsg="+proceed.getMessage());
+
+ requestLogInfoService.addLog(requestLogInfo);
+ return proceed;
+ } catch (RuntimeException e) {
+
+ throw e;
+ } catch (Throwable throwable) {
+
+ throw new RuntimeException("系统异常!");
+ }
+ }
+}
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/Utils/GenerateIdUtil.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/Utils/GenerateIdUtil.java
index fbdadc5..d333b1f 100644
--- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/Utils/GenerateIdUtil.java
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/Utils/GenerateIdUtil.java
@@ -17,6 +17,12 @@ public class GenerateIdUtil {
sb.append("-"+user);
return sb.toString();
}
+ public static synchronized String getTimeId(String org,String user){
+
+ String time = new SimpleDateFormat("yyyyMMddHHmmss").format(System.currentTimeMillis());
+
+ return time;
+ }
public static void main(String[] args) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LogController.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LogController.java
new file mode 100644
index 0000000..9825865
--- /dev/null
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LogController.java
@@ -0,0 +1,51 @@
+package com.aiit.xiuos.controller;
+
+import com.aiit.xiuos.Utils.Constant;
+import com.aiit.xiuos.Utils.ResultRespons;
+import com.aiit.xiuos.model.DeviceInfo;
+import com.aiit.xiuos.model.DeviceLogInfo;
+import com.aiit.xiuos.model.RequestLogInfo;
+import com.aiit.xiuos.model.UserInfo;
+import com.aiit.xiuos.service.LogInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@RestController
+@RequestMapping("/log")
+public class LogController {
+ @Autowired
+ LogInfoService requestLogInfoService;
+ @GetMapping("/requestLog")
+ public ResultRespons selectRequestLog(HttpServletRequest request){
+ UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
+ List RequestLogInfo =requestLogInfoService.selectLog(userInfo.getOrg());
+ if(RequestLogInfo!=null&&RequestLogInfo.size()>0)
+ {
+ return new ResultRespons(Constant.SUCCESS_CODE,"查询日志成功!",RequestLogInfo);
+ }else
+ {
+ return new ResultRespons(Constant.ERROR_CODE,"日志不存在");
+ }
+ }
+ @GetMapping("/deviceLog")
+ public ResultRespons selectDeviceLog(HttpServletRequest request){
+ UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
+ List deviceLogInfos =requestLogInfoService.selectDeviceLog(userInfo.getOrg());
+ if(deviceLogInfos!=null&&deviceLogInfos.size()>0)
+ {
+ return new ResultRespons(Constant.SUCCESS_CODE,"查询日志成功!",deviceLogInfos);
+ }else
+ {
+ return new ResultRespons(Constant.ERROR_CODE,"日志不存在");
+ }
+ }
+
+
+
+}
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LoginController.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LoginController.java
index 715383d..d8f6da8 100644
--- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LoginController.java
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LoginController.java
@@ -6,7 +6,6 @@ import com.aiit.xiuos.Utils.ResultRespons;
import com.aiit.xiuos.model.UserInfo;
import com.aiit.xiuos.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@@ -14,6 +13,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@RestController
+
public class LoginController {
@Autowired
private UserInfoService userInfoService;
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/DeviceLogInfoMapper.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/DeviceLogInfoMapper.java
new file mode 100644
index 0000000..bdb25f0
--- /dev/null
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/DeviceLogInfoMapper.java
@@ -0,0 +1,29 @@
+package com.aiit.xiuos.dao.mappers;
+
+import com.aiit.xiuos.model.DeviceLogInfo;
+import java.util.Date;
+import java.util.List;
+
+import com.aiit.xiuos.model.RequestLogInfo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface DeviceLogInfoMapper {
+ int deleteByPrimaryKey(@Param("deviceNo") String deviceNo, @Param("logTime") Date logTime);
+
+ int insert(DeviceLogInfo record);
+
+ int insertSelective(DeviceLogInfo record);
+
+ DeviceLogInfo selectByPrimaryKey(@Param("deviceNo") String deviceNo, @Param("logTime") Date logTime);
+
+ int updateByPrimaryKeySelective(DeviceLogInfo record);
+
+ int updateByPrimaryKey(DeviceLogInfo record);
+
+
+ @Select("select * from device_log_info where org =#{org}")
+ List selectDeviceLog(@Param("org") String org);
+}
\ No newline at end of file
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/RequestLogInfoMapper.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/RequestLogInfoMapper.java
new file mode 100644
index 0000000..a119dac
--- /dev/null
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/RequestLogInfoMapper.java
@@ -0,0 +1,26 @@
+package com.aiit.xiuos.dao.mappers;
+
+import com.aiit.xiuos.model.RequestLogInfo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface RequestLogInfoMapper {
+ int deleteByPrimaryKey(Integer id);
+
+ int insert(RequestLogInfo record);
+
+ int insertSelective(RequestLogInfo record);
+
+ RequestLogInfo selectByPrimaryKey(Integer id);
+
+ int updateByPrimaryKeySelective(RequestLogInfo record);
+
+ int updateByPrimaryKey(RequestLogInfo record);
+
+ @Select("select * from request_log_info where org =#{org}")
+ List selectLog(@Param("org") String org);
+}
\ No newline at end of file
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/DeviceLogInfo.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/DeviceLogInfo.java
new file mode 100644
index 0000000..910e427
--- /dev/null
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/DeviceLogInfo.java
@@ -0,0 +1,39 @@
+package com.aiit.xiuos.model;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Builder;
+import lombok.Data;
+
+@Data
+@Builder
+public class DeviceLogInfo {
+ private String deviceNo;
+ @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ private Date logTime;
+
+ private String deviceType;
+
+ private String threadNo;
+
+ private Integer logLevel;
+
+ private String deviceLog;
+
+ private String org;
+
+ public DeviceLogInfo(String deviceNo, Date logTime, String deviceType, String threadNo, Integer logLevel, String deviceLog, String org) {
+ this.deviceNo = deviceNo;
+ this.logTime = logTime;
+ this.deviceType = deviceType;
+ this.threadNo = threadNo;
+ this.logLevel = logLevel;
+ this.deviceLog = deviceLog;
+ this.org = org;
+ }
+
+ public DeviceLogInfo() {
+ super();
+ }
+}
\ No newline at end of file
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/RequestLogInfo.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/RequestLogInfo.java
new file mode 100644
index 0000000..36fa7ac
--- /dev/null
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/RequestLogInfo.java
@@ -0,0 +1,54 @@
+package com.aiit.xiuos.model;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Builder;
+import lombok.Data;
+
+@Data
+@Builder
+public class RequestLogInfo {
+ private Integer id;
+
+ private String classname;
+
+ private String methodname;
+
+ private String requestparam;
+
+ private String requestip;
+
+ private String requestresult;
+
+ private String requestheader;
+
+ private String requesturl;
+ @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ private Date requesttime;
+
+ private String processtime;
+
+ private String requesttype;
+
+ private String org;
+
+ public RequestLogInfo(Integer id, String classname, String methodname, String requestparam, String requestip, String requestresult, String requestheader, String requesturl, Date requesttime, String processtime, String requesttype, String org) {
+ this.id = id;
+ this.classname = classname;
+ this.methodname = methodname;
+ this.requestparam = requestparam;
+ this.requestip = requestip;
+ this.requestresult = requestresult;
+ this.requestheader = requestheader;
+ this.requesturl = requesturl;
+ this.requesttime = requesttime;
+ this.processtime = processtime;
+ this.requesttype = requesttype;
+ this.org = org;
+ }
+
+ public RequestLogInfo() {
+ super();
+ }
+}
\ No newline at end of file
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/scheduled/TaskScheduled.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/scheduled/TaskScheduled.java
index 92be3c8..d38b9a5 100644
--- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/scheduled/TaskScheduled.java
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/scheduled/TaskScheduled.java
@@ -2,9 +2,12 @@ package com.aiit.xiuos.scheduled;
import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.model.AvgDayData;
+import com.aiit.xiuos.model.DeviceLogInfo;
import com.aiit.xiuos.service.AvgDayDataService;
+import com.aiit.xiuos.service.LogInfoService;
import com.aiit.xiuos.service.impl.AvgDayDataServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -13,14 +16,14 @@ import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
+import java.util.*;
+
@Component
public class TaskScheduled {
@Autowired
AvgDayDataService avgDayDataService;
+ @Autowired
+ LogInfoService deviceLogInfoService;
@Scheduled(cron = "0 0 */1 * * ?")//every hour
public void insertAvgDayData() throws ParseException {
AvgDayData avgDayData =new AvgDayData();
@@ -80,4 +83,34 @@ public class TaskScheduled {
}
+// @Scheduled(cron = "0 0 */1 * * ?")//every hour
+// public void insertDeviceLog() {
+// String []log={"nsh_main: mmcsd_readsingle: offset=1007095",
+// "nsh_main: imxrt_blocksetup: blocklen=512, total transfer=512 (1 blocks)",
+// " nsh_main: imxrt_sendcmd: cmd: 00000451 arg: 000f5df7 regval: 113a0000 mcrval: 80000011",
+// "Idle Task: imxrt_interrupt: IRQSTAT: 0000000b IRQSIGEN 107001c2 enabled: 00000002",
+// "nsh_main: mmcsd_read: startsector: 1289408 nsectors: 1 sectorsize: 512",
+// "nsh_main: mmcsd_readsingle: startblock=1289408",
+// "nsh_main: imxrt_status: cdstatus=01",
+// "nsh_main: mmcsd_readsingle: offset=1289408",
+// "nsh_main: imxrt_blocksetup: blocklen=512, total transfer=512 (1 blocks)",
+// "nsh_main: imxrt_blocksetup: blocklen=512, total transfer=512 (1 blocks)"
+// };
+// Map deviceMap = new HashMap<>();
+// deviceMap.put("A000005","RV400-NPU16T-5G-AR100");
+// deviceMap.put("A000007","M168-LoRa-FM100");
+// deviceMap.put("A000008","M528-A800-5G-HM100");
+// deviceMap.put("A000006","RV400-NPU4T-5G-SR100");
+// deviceMap.put("A000014","RV400-NPU4T-5G-SR100");
+// deviceMap.put("A000011","RV400-NPU16T-5G-AR100");
+// deviceMap.put("A000063","RV400-4G-FR100");
+// deviceMap.put("S01","M168-LoRa-FM100");
+// deviceMap.put("S02","M528-A800-5G-HM100");
+// deviceMap.put("S06","M528-A800-5G-HM100");
+// deviceMap.put("S12","RV400-NPU16T-5G-AR100");
+// deviceMap.put("S09","RV400-NPU4T-5G-SR100");
+//
+// }
+
+
}
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/LogInfoService.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/LogInfoService.java
new file mode 100644
index 0000000..4573aec
--- /dev/null
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/LogInfoService.java
@@ -0,0 +1,13 @@
+package com.aiit.xiuos.service;
+
+import com.aiit.xiuos.model.DeviceLogInfo;
+import com.aiit.xiuos.model.RequestLogInfo;
+
+import java.util.List;
+
+public interface LogInfoService {
+ int addLog(RequestLogInfo requestLogInfo);
+ List selectLog(String org);
+ int addDeviceLog(DeviceLogInfo deviceLogInfo);
+ List selectDeviceLog(String org);
+}
diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/RequestLogInfoServiceImpl.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/RequestLogInfoServiceImpl.java
new file mode 100644
index 0000000..2890cda
--- /dev/null
+++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/RequestLogInfoServiceImpl.java
@@ -0,0 +1,39 @@
+package com.aiit.xiuos.service.impl;
+
+import com.aiit.xiuos.dao.mappers.DeviceLogInfoMapper;
+import com.aiit.xiuos.dao.mappers.RequestLogInfoMapper;
+import com.aiit.xiuos.model.DeviceLogInfo;
+import com.aiit.xiuos.model.RequestLogInfo;
+import com.aiit.xiuos.service.LogInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class RequestLogInfoServiceImpl implements LogInfoService {
+ @Autowired
+ RequestLogInfoMapper requestLogInfoMapper;
+ @Autowired
+ DeviceLogInfoMapper deviceLogInfoMapper;
+ @Override
+ public int addLog(RequestLogInfo requestLogInfo) {
+ return requestLogInfoMapper.insertSelective(requestLogInfo);
+ }
+
+ @Override
+ public List selectLog(String org) {
+
+ return requestLogInfoMapper.selectLog(org);
+ }
+
+ @Override
+ public int addDeviceLog(DeviceLogInfo deviceLogInfo) {
+ return deviceLogInfoMapper.insertSelective(deviceLogInfo);
+ }
+
+ @Override
+ public List selectDeviceLog(String org) {
+ return deviceLogInfoMapper.selectDeviceLog(org);
+ }
+}
diff --git a/xiuosiot-backend/src/main/resources/application.yml b/xiuosiot-backend/src/main/resources/application.yml
index f71c18a..f289b5d 100644
--- a/xiuosiot-backend/src/main/resources/application.yml
+++ b/xiuosiot-backend/src/main/resources/application.yml
@@ -31,7 +31,7 @@ mybatis:
#MQTT Config
mqtt:
#MQTT-服务器连接地
- hostUrl: tcp://localhost:1883
+ hostUrl: tcp://192.168.88.225:1883
#MQTT-连接服务器默认客户端ID
clientId: xiuosiot-client
#MQTT-用户名
@@ -44,3 +44,8 @@ mqtt:
keepalive: 100
#默认主题
default-topic: xiuosiot/#
+
+logging:
+ file:
+ name: xiuosiot.log
+
diff --git a/xiuosiot-backend/src/main/resources/mappers/RequestLogInfoMapper.xml b/xiuosiot-backend/src/main/resources/mappers/RequestLogInfoMapper.xml
new file mode 100644
index 0000000..1406cd6
--- /dev/null
+++ b/xiuosiot-backend/src/main/resources/mappers/RequestLogInfoMapper.xml
@@ -0,0 +1,179 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, classname, methodname, requestparam, requestip, requestresult, requestheader,
+ requesturl, requesttime, processtime, requesttype, org
+
+
+
+ delete from request_log_info
+ where id = #{id,jdbcType=INTEGER}
+
+
+ insert into request_log_info (id, classname, methodname,
+ requestparam, requestip, requestresult,
+ requestheader, requesturl, requesttime,
+ processtime, requesttype, org
+ )
+ values (#{id,jdbcType=INTEGER}, #{classname,jdbcType=VARCHAR}, #{methodname,jdbcType=VARCHAR},
+ #{requestparam,jdbcType=VARCHAR}, #{requestip,jdbcType=VARCHAR}, #{requestresult,jdbcType=VARCHAR},
+ #{requestheader,jdbcType=VARCHAR}, #{requesturl,jdbcType=VARCHAR}, #{requesttime,jdbcType=TIMESTAMP},
+ #{processtime,jdbcType=VARCHAR}, #{requesttype,jdbcType=VARCHAR}, #{org,jdbcType=VARCHAR}
+ )
+
+
+ insert into request_log_info
+
+
+ id,
+
+
+ classname,
+
+
+ methodname,
+
+
+ requestparam,
+
+
+ requestip,
+
+
+ requestresult,
+
+
+ requestheader,
+
+
+ requesturl,
+
+
+ requesttime,
+
+
+ processtime,
+
+
+ requesttype,
+
+
+ org,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{classname,jdbcType=VARCHAR},
+
+
+ #{methodname,jdbcType=VARCHAR},
+
+
+ #{requestparam,jdbcType=VARCHAR},
+
+
+ #{requestip,jdbcType=VARCHAR},
+
+
+ #{requestresult,jdbcType=VARCHAR},
+
+
+ #{requestheader,jdbcType=VARCHAR},
+
+
+ #{requesturl,jdbcType=VARCHAR},
+
+
+ #{requesttime,jdbcType=TIMESTAMP},
+
+
+ #{processtime,jdbcType=VARCHAR},
+
+
+ #{requesttype,jdbcType=VARCHAR},
+
+
+ #{org,jdbcType=VARCHAR},
+
+
+
+
+ update request_log_info
+
+
+ classname = #{classname,jdbcType=VARCHAR},
+
+
+ methodname = #{methodname,jdbcType=VARCHAR},
+
+
+ requestparam = #{requestparam,jdbcType=VARCHAR},
+
+
+ requestip = #{requestip,jdbcType=VARCHAR},
+
+
+ requestresult = #{requestresult,jdbcType=VARCHAR},
+
+
+ requestheader = #{requestheader,jdbcType=VARCHAR},
+
+
+ requesturl = #{requesturl,jdbcType=VARCHAR},
+
+
+ requesttime = #{requesttime,jdbcType=TIMESTAMP},
+
+
+ processtime = #{processtime,jdbcType=VARCHAR},
+
+
+ requesttype = #{requesttype,jdbcType=VARCHAR},
+
+
+ org = #{org,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
+ update request_log_info
+ set classname = #{classname,jdbcType=VARCHAR},
+ methodname = #{methodname,jdbcType=VARCHAR},
+ requestparam = #{requestparam,jdbcType=VARCHAR},
+ requestip = #{requestip,jdbcType=VARCHAR},
+ requestresult = #{requestresult,jdbcType=VARCHAR},
+ requestheader = #{requestheader,jdbcType=VARCHAR},
+ requesturl = #{requesturl,jdbcType=VARCHAR},
+ requesttime = #{requesttime,jdbcType=TIMESTAMP},
+ processtime = #{processtime,jdbcType=VARCHAR},
+ requesttype = #{requesttype,jdbcType=VARCHAR},
+ org = #{org,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file