wangzhe 2 years ago
parent
commit
637ad5b8cb

+ 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();
+    }
+
+}

+ 2 - 0
mybusiness/src/main/java/com/sooka/system/service/impl/Guiji_Base_Service.java

@@ -106,6 +106,8 @@ public class Guiji_Base_Service {
         String interfaceinfoName = tuLog.getInterfaceinfoName();
         if(interfaceinfoName != null && !interfaceinfoName.equals("")){
             String interfacetype = interfaceinfoName.split("-")[0];//共享-自来水公司-用水量检测 归集-市医药-种植采集数
+            String loginName = interfaceinfoName.split("-")[1];
+            tuLog.setLoginName(loginName);
             if(interfacetype.equals("共享")){
                 tuLog.setPlatformInterfacetype("platform_interfacetype_1");
             }else if(interfacetype.equals("归集")){

+ 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">