Browse Source

优化日志分析。

lighter 3 years ago
parent
commit
35332f2f5b

+ 7 - 6
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SiLogController.java

@@ -1,16 +1,13 @@
 package thyyxxk.webserver.controller.medicalinsurance;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.log.FetchLog;
 import thyyxxk.webserver.entity.medicalinsurance.log.SiLog;
 import thyyxxk.webserver.service.medicalinsurance.SiLogService;
 
-import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/siLog")
@@ -23,8 +20,12 @@ public class SiLogController {
     }
 
     @PostMapping("/selectSiLogs")
-    public ResultVo<List<SiLog>> selectSiLogs(@RequestBody FetchLog ftchlg) {
+    public ResultVo<Map<String, Object>> selectSiLogs(@RequestBody FetchLog ftchlg) {
         return service.selectSiLogs(ftchlg);
     }
 
+    @GetMapping("/selectSiLogBody")
+    public ResultVo<SiLog> selectSiLogBody(@RequestParam("msgid") String msgid) {
+        return service.selectSiLogBody(msgid);
+    }
 }

+ 23 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiLogDao.java

@@ -1,9 +1,32 @@
 package thyyxxk.webserver.dao.his.medicalinsurance;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.medicalinsurance.log.FetchLog;
 import thyyxxk.webserver.entity.medicalinsurance.log.SiLog;
 
 @Mapper
 public interface SiLogDao extends BaseMapper<SiLog> {
+
+    @Select("<script>" +
+            "select msgid,infno,insuplc_admdvs,opter,create_datetime,pat_no,times from t_si_log " +
+            "where log_type=#{ftclg.logType} " +
+            "<if test=\"ftclg.infno!=null\">" +
+            "and infno=#{ftclg.infno} " +
+            "</if>" +
+            "<if test=\"ftclg.begntime!=null and ftclg.endtime!=null\">" +
+            "and create_datetime&gt;=#{ftclg.begntime} and create_datetime&lt;#{ftclg.endtime} " +
+            "</if>" +
+            "<if test=\"ftclg.patNo!=null\">" +
+            "and pat_no=#{ftclg.patNo} " +
+            "</if>" +
+            "</script>")
+    IPage<SiLog> selectSiLogs(IPage<SiLog> iPage,
+                              @Param("ftclg") FetchLog ftclg);
+
+    @Select("select rtrim(name) from a_employee_mi where code=#{code}")
+    String selectUserName(@Param("code") String code);
 }

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/log/FetchLog.java

@@ -11,4 +11,6 @@ public class FetchLog {
     private Date begntime;
     private Date endtime;
     private String patNo;
+    private Integer currentPage;
+    private Integer pageSize;
 }

+ 13 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/log/SiLog.java

@@ -5,6 +5,7 @@ import java.util.Date;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -26,6 +27,12 @@ public class SiLog implements Serializable {
 	 */
 	private String infno;
 
+	/**
+	 * 功能号名称
+	 */
+	@TableField(exist = false)
+	private String infname;
+
 	/**
 	 * 参保地医保区划
 	 */
@@ -36,6 +43,12 @@ public class SiLog implements Serializable {
 	 */
 	private String opter;
 
+	/**
+	 * 经办人姓名
+	 */
+	@TableField(exist = false)
+	private String opterName;
+
 	/**
 	 * 交易输入
 	 */

+ 32 - 13
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiLogService.java

@@ -1,38 +1,57 @@
 package thyyxxk.webserver.service.medicalinsurance;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.constants.sidicts.SiFunction;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiLogDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.log.FetchLog;
 import thyyxxk.webserver.entity.medicalinsurance.log.SiLog;
 import thyyxxk.webserver.utils.ResultVoUtil;
-import thyyxxk.webserver.utils.StringUtil;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class SiLogService {
     private final SiLogDao dao;
+    private final Map<String, String> userMap;
 
     @Autowired
     public SiLogService(SiLogDao dao) {
         this.dao = dao;
+        userMap = new HashMap<>();
     }
 
-    public ResultVo<List<SiLog>> selectSiLogs(FetchLog ftchlg) {
-        QueryWrapper<SiLog> wrapper = new QueryWrapper<>();
-        wrapper.eq("log_type", ftchlg.getLogType());
-        if (StringUtil.notBlank(ftchlg.getInfno())) {
-            wrapper.eq("infno", ftchlg.getInfno());
+    public ResultVo<Map<String, Object>> selectSiLogs(FetchLog ftchlg) {
+        IPage<SiLog> iPage = new Page<>(ftchlg.getCurrentPage(), ftchlg.getPageSize());
+        iPage = dao.selectSiLogs(iPage, ftchlg);
+        if (iPage.getTotal() == 0) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
-        if (null != ftchlg.getBegntime() && null != ftchlg.getEndtime()) {
-            wrapper.between("create_datetime", ftchlg.getBegntime(), ftchlg.getEndtime());
+        Map<String, Object> map = new HashMap<>();
+        map.put("total", iPage.getTotal());
+        List<SiLog> list = iPage.getRecords();
+        for (SiLog siLog : list) {
+            siLog.setInfname(SiFunction.getName(siLog.getInfno()));
+            String userid = siLog.getOpter();
+            if (userMap.containsKey(userid)) {
+                siLog.setOpterName(userMap.get(userid));
+            } else {
+                String username = dao.selectUserName(userid);
+                siLog.setOpterName(username);
+                userMap.put(userid, username);
+            }
         }
-        if (StringUtil.notBlank(ftchlg.getPatNo())) {
-            wrapper.eq("pat_no", ftchlg.getPatNo());
-        }
-        return ResultVoUtil.success(dao.selectList(wrapper));
+        map.put("list", list);
+        return ResultVoUtil.success(map);
+    }
+
+    public ResultVo<SiLog> selectSiLogBody(String msgid) {
+        return ResultVoUtil.success(dao.selectById(msgid));
     }
 }