Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

lchao 2 gadi atpakaļ
vecāks
revīzija
003094f447

+ 1 - 0
leiSP-framework/src/main/java/com/sooka/framework/config/ShiroConfig.java

@@ -289,6 +289,7 @@ public class ShiroConfig
         filterChainDefinitionMap.put("/logout", "logout");
         // 不需要拦截的访问
         filterChainDefinitionMap.put("/login", "anon,captchaValidate");
+        filterChainDefinitionMap.put("/system/interfaceLog/addLog", "anon,captchaValidate");
         // 注册相关
         filterChainDefinitionMap.put("/register", "anon,captchaValidate");
         // 系统权限列表

+ 72 - 0
mybusiness/src/main/java/com/sooka/system/controller/Guiji_Base_Controller.java

@@ -0,0 +1,72 @@
+package com.sooka.system.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.sooka.common.core.controller.BaseController;
+import com.sooka.common.core.domain.AjaxResult;
+import com.sooka.system.domain.BaseBusinessEntity;
+import com.sooka.system.service.impl.Guiji_Base_Service;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import javax.websocket.server.PathParam;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 远程接口调用日志信息Controller
+ * 
+ * @author zhe
+ * @date 2022-08-20
+ */
+@Controller
+@RequestMapping("/system/interfaceLog")
+public class Guiji_Base_Controller extends BaseController
+{
+
+    @Autowired
+    private Guiji_Base_Service guiji_Base_Service;
+
+    public static Map<String, String> mapStringToMap(String str){
+        str = str.substring(1,str.length()-1);
+        String[] strs = str.split(",");
+        Map map = new HashMap();
+        for (String string : strs){
+            String key = string.split("=")[0];
+            String value = string.split("=")[1];
+            map.put(key, value);
+        }
+        return map;
+    }
+
+    /**
+     * 新增日志信息
+     */
+    @ResponseBody
+    @PostMapping("/addLog")
+    public AjaxResult addLog(@RequestBody String log)
+    {
+        log = log.replace("\\r\\n", "");
+        log = log.replace("\\\"", "\"");
+        log = log.replace("\"{", "{");
+        log = log.replace("}\"", "}");
+        log = log.replace("@type", "_@type");
+        JSONObject jsonObject = JSON.parseObject(log);
+        BaseBusinessEntity baseBusinessEntity = new BaseBusinessEntity();
+        baseBusinessEntity.setInterfaceinfoId(jsonObject.getString("interfaceinfoId"));
+        baseBusinessEntity.setInterfaceinfoName(jsonObject.getString("interfaceinfoName"));
+        baseBusinessEntity.setParam(jsonObject.getString("param"));
+        baseBusinessEntity.setOperationStatus(Long.valueOf(jsonObject.getString("operationStatus")));
+        baseBusinessEntity.setResults(jsonObject.getString("results"));
+        baseBusinessEntity.setExceptionLog(jsonObject.getString("exceptionLog"));
+        try {
+            guiji_Base_Service.addLog(baseBusinessEntity);
+        }catch (Exception e){
+            e.printStackTrace();
+            return AjaxResult.error();
+        }
+        return AjaxResult.success();
+    }
+
+}

+ 40 - 3
mybusiness/src/main/java/com/sooka/system/service/impl/Guiji_Base_Service.java

@@ -71,7 +71,44 @@ public class Guiji_Base_Service {
 
     }
 
-
-
-
+    /**
+     * 远程接口调用日志信息新增日志
+     * 接口调用日志不进行Websocket推送 不需要用户登录
+     */
+    public void addLog(BaseBusinessEntity baseBusinessEntity){
+        HttpServletRequest request = ServletUtils.getRequest();
+        String osAndBrowser[] = HttpUtil.getOsAndBrowserInfo(request).split("---");
+        String os = osAndBrowser[0];
+        String browser = osAndBrowser[1];
+        String ipaddress = HttpUtil.getIPAddress(request);
+        //添加操作日志
+        //SysUser sysUser = userInfoUtil.getLoginUserInfo();
+        TULog tuLog = new TULog();
+        tuLog.setId(UUID.fastUUID().toString());
+        tuLog.setOs(os);
+        tuLog.setBrowser(browser);
+        tuLog.setInterfaceinfoId(baseBusinessEntity.getInterfaceinfoId());
+        tuLog.setInterfaceinfoName(baseBusinessEntity.getInterfaceinfoName());
+        tuLog.setIpaddress(ipaddress);
+        //tuLog.setLoginUser(sysUser.getUserId());
+        //tuLog.setLoginName(sysUser.getLoginName());
+        /** 记录操作状态、请求参数、返回结果、异常记录 lm 20220810 add **/
+        tuLog.setOperationStatus(baseBusinessEntity.getOperationStatus());
+        tuLog.setParam(baseBusinessEntity.getParam());
+        tuLog.setResults(baseBusinessEntity.getResults());
+        tuLog.setExceptionLog(baseBusinessEntity.getExceptionLog());
+        /** 记录操作状态、请求参数、返回结果、异常记录 lm 20220810 add **/
+//        tuLog.setOperationQuantity(new Long(ls.size()));
+        //共享接口
+//        tuLog.setPlatformInterfacetype("platform_interfacetype_1");
+        //归集接口
+//        tuLog.setPlatformInterfacetype("platform_interfacetype_2");
+        String interfaceinfoName = tuLog.getInterfaceinfoName();
+        if(interfaceinfoName != null && !interfaceinfoName.equals("")){
+            String loginName = interfaceinfoName.split("-")[1];//共享-自来水公司-用水量检测 归集-市医药-种植采集数
+            tuLog.setLoginName(loginName);
+            tuLog.setPlatformInterfacetype(baseBusinessEntity.getInterfacetype());
+        }
+        tuLogMapper.insertTULog(tuLog);
+    }
 }

+ 1 - 0
mybusiness/src/main/resources/mapper/system/TUInterfaceinfoMapper.xml

@@ -50,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="callsuccnum != null  and callsuccnum != ''"> and callsuccnum = #{callsuccnum}</if>
             <if test="callfailnum != null  and callfailnum != ''"> and callfailnum = #{callfailnum}</if>
         </where>
+        order by create_time desc
     </select>
 
     <select id="selectTUInterfaceinfoById" parameterType="String" resultMap="TUInterfaceinfoResult">