zhaops před 3 roky
rodič
revize
5f6dde0882

+ 1 - 0
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -61,6 +61,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/tran/mappingConfig/deleteRecord").permitAll()
                 .antMatchers("/tran/mappingConfig/deleteRecords").permitAll()
                 //.antMatchers("/tran/hospitalInfo/saveRecord").permitAll()
+                .antMatchers("/tran/log/pageList").permitAll()
                 .antMatchers("/tran/hospitalInfo/getHospitalInfo").permitAll()
                 .antMatchers("/tran/hospitalInfo/getAllHospitalInfo").permitAll()
                 .antMatchers("/tran/hospitalInfo/getAllEnableHospitalInfo").permitAll()

+ 1 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -104,6 +104,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/tran/mappingConfig/deleteRecord", request)
                 || matchers("/tran/mappingConfig/deleteRecords", request)
                 //|| matchers("/tran/hospitalInfo/saveRecord", request)
+                || matchers("/tran/log/pageList", request)
                 || matchers("/tran/hospitalInfo/getHospitalInfo", request)
                 || matchers("/tran/hospitalInfo/getAllHospitalInfo", request)
                 || matchers("/tran/hospitalInfo/getAllEnableHospitalInfo", request)

+ 62 - 2
src/main/java/com/diagbot/entity/TranLog.java

@@ -2,6 +2,8 @@ package com.diagbot.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -12,7 +14,7 @@ import java.util.Date;
  * </p>
  *
  * @author zhoutg
- * @since 2021-10-20
+ * @since 2021-10-22
  */
 public class TranLog implements Serializable {
 
@@ -49,6 +51,26 @@ public class TranLog implements Serializable {
      */
     private String modifier;
 
+    /**
+     * 病人唯一标识(病人id、病历号等)
+     */
+    private String patientId;
+
+    /**
+     * 医院id
+     */
+    private Long hospitalId;
+
+    /**
+     * 子医院编码
+     */
+    private String subHospitalCode;
+
+    /**
+     * 子医院名称
+     */
+    private String subHospitalName;
+
     /**
      * 场景名称
      */
@@ -67,11 +89,13 @@ public class TranLog implements Serializable {
     /**
      * 请求时间
      */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
     private Date gmtReq;
 
     /**
      * 响应时间
      */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
     private Date gmtResp;
 
     /**
@@ -132,6 +156,38 @@ public class TranLog implements Serializable {
         this.modifier = modifier;
     }
 
+    public String getPatientId() {
+        return patientId;
+    }
+
+    public void setPatientId(String patientId) {
+        this.patientId = patientId;
+    }
+
+    public Long getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Long hosptialId) {
+        this.hospitalId = hosptialId;
+    }
+
+    public String getSubHospitalCode() {
+        return subHospitalCode;
+    }
+
+    public void setSubHospitalCode(String subHospitalCode) {
+        this.subHospitalCode = subHospitalCode;
+    }
+
+    public String getSubHospitalName() {
+        return subHospitalName;
+    }
+
+    public void setSubHospitalName(String subHospitalName) {
+        this.subHospitalName = subHospitalName;
+    }
+
     public String getSceneName() {
         return sceneName;
     }
@@ -197,6 +253,10 @@ public class TranLog implements Serializable {
                 ", gmtModified=" + gmtModified +
                 ", creator=" + creator +
                 ", modifier=" + modifier +
+                ", patientId=" + patientId +
+                ", hospitalId=" + hospitalId +
+                ", subHospitalCode=" + subHospitalCode +
+                ", subHospitalName=" + subHospitalName +
                 ", sceneName=" + sceneName +
                 ", params=" + params +
                 ", result=" + result +
@@ -206,4 +266,4 @@ public class TranLog implements Serializable {
                 ", successFlag=" + successFlag +
                 "}";
     }
-}
+}

+ 34 - 1
src/main/java/com/diagbot/facade/TranLogFacade.java

@@ -1,6 +1,13 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.entity.TranLog;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.TranLogServiceImpl;
+import com.diagbot.util.SysUserUtils;
+import com.diagbot.vo.TranLogPageVO;
+import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.stereotype.Component;
 
 /**
@@ -10,4 +17,30 @@ import org.springframework.stereotype.Component;
  */
 @Component
 public class TranLogFacade extends TranLogServiceImpl {
-}
+    public IPage<TranLog> pageList(TranLogPageVO tranLogPageVO) {
+        String hospitalId = SysUserUtils.getCurrentHospitalID();
+        tranLogPageVO.setHospitalId(Long.valueOf(hospitalId));
+        if (tranLogPageVO.getStartGmtReq() != null && tranLogPageVO.getEndGmtReq() == null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入完整时间区间");
+        }
+        if (tranLogPageVO.getStartGmtReq() == null && tranLogPageVO.getEndGmtReq() != null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入完整时间区间");
+        }
+        if (tranLogPageVO.getStartGmtResp() != null && tranLogPageVO.getEndGmtResp() == null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入完整时间区间");
+        }
+        if (tranLogPageVO.getStartGmtResp() == null && tranLogPageVO.getEndGmtResp() != null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入完整时间区间");
+        }
+
+        if (tranLogPageVO.getEndGmtReq() != null) {
+            DateUtils.addMilliseconds(tranLogPageVO.getEndGmtReq(), 1);
+        }
+        if (tranLogPageVO.getEndGmtResp() != null) {
+            DateUtils.addMilliseconds(tranLogPageVO.getEndGmtResp(), 1);
+        }
+
+        IPage<TranLog> page = super.getPage(tranLogPageVO);
+        return page;
+    }
+}

+ 4 - 1
src/main/java/com/diagbot/mapper/TranLogMapper.java

@@ -1,7 +1,10 @@
 package com.diagbot.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.entity.TranLog;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.vo.TranLogPageVO;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -12,5 +15,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @since 2021-10-20
  */
 public interface TranLogMapper extends BaseMapper<TranLog> {
-
+    IPage<TranLog> getPage(@Param("tranLogPageVO") TranLogPageVO tranLogPageVO);
 }

+ 4 - 1
src/main/java/com/diagbot/service/TranLogService.java

@@ -1,7 +1,10 @@
 package com.diagbot.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.entity.TranLog;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.vo.TranLogPageVO;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -12,5 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2021-10-20
  */
 public interface TranLogService extends IService<TranLog> {
-
+    IPage<TranLog> getPage(@Param("tranLogPageVO") TranLogPageVO tranLogPageVO);
 }

+ 7 - 1
src/main/java/com/diagbot/service/impl/TranLogServiceImpl.java

@@ -1,9 +1,12 @@
 package com.diagbot.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.entity.TranLog;
 import com.diagbot.mapper.TranLogMapper;
 import com.diagbot.service.TranLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.vo.TranLogPageVO;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
 /**
@@ -16,5 +19,8 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class TranLogServiceImpl extends ServiceImpl<TranLogMapper, TranLog> implements TranLogService {
-
+    @Override
+    public IPage<TranLog> getPage(@Param("tranLogPageVO") TranLogPageVO tranLogPageVO) {
+        return baseMapper.getPage(tranLogPageVO);
+    }
 }

+ 31 - 0
src/main/java/com/diagbot/vo/TranLogPageVO.java

@@ -0,0 +1,31 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/10/25 9:57
+ */
+@Data
+public class TranLogPageVO extends Page {
+    @ApiModelProperty(hidden = true)
+    private Long hospitalId;
+    private String patientId;
+    private String sceneName;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
+    private Date startGmtReq;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
+    private Date endGmtReq;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
+    private Date startGmtResp;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
+    private Date endGmtResp;
+    private Integer successFlag;
+    private String subHospitalName;
+}

+ 47 - 0
src/main/java/com/diagbot/web/TranLogController.java

@@ -0,0 +1,47 @@
+package com.diagbot.web;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.TranLog;
+import com.diagbot.facade.TranLogFacade;
+import com.diagbot.vo.TranLogPageVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+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 javax.validation.Valid;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/10/25 11:23
+ */
+@RestController
+@RequestMapping("/tran/log")
+@Api(value = "对接日志记录相关API", tags = { "对接日志记录相关API" })
+@SuppressWarnings("unchecked")
+public class TranLogController {
+    @Autowired
+    private TranLogFacade tranLogFacade;
+
+    @ApiOperation(value = "调用记录[by:zhaops]",
+            notes = "patientId:病人标识<br>" +
+                    "sceneName:服务名<br>" +
+                    "startGmtReq:接收时间(起始区间),格式【yyyy-MM-dd HH:mm:ss.SSS】<br>" +
+                    "endGmtReq:接收时间(结束区间),格式【yyyy-MM-dd HH:mm:ss.SSS】<br>" +
+                    "startGmtResp:响应时间(起始区间),格式【yyyy-MM-dd HH:mm:ss.SSS】<br>" +
+                    "endGmtResp:响应时间(结束区间),格式【yyyy-MM-dd HH:mm:ss.SSS】<br>" +
+                    "successFlag:状态 1:成功,0:失败<br>" +
+                    "subHospitalName:院区<br>")
+    @PostMapping("/pageList")
+    @SysLogger("pageList")
+    public RespDTO<IPage<TranLog>> pageList(@Valid @RequestBody TranLogPageVO tranLogPageVO) {
+        IPage<TranLog> data = tranLogFacade.pageList(tranLogPageVO);
+        return RespDTO.onSuc(data);
+    }
+}

+ 37 - 0
src/main/resources/mapper/TranLogMapper.xml

@@ -10,6 +10,10 @@
         <result column="gmt_modified" property="gmtModified" />
         <result column="creator" property="creator" />
         <result column="modifier" property="modifier" />
+        <result column="patient_id" property="patientId" />
+        <result column="hospital_id" property="hospitalId" />
+        <result column="sub_hospital_code" property="subHospitalCode" />
+        <result column="sub_hospital_name" property="subHospitalName" />
         <result column="scene_name" property="sceneName" />
         <result column="params" property="params" />
         <result column="result" property="result" />
@@ -19,4 +23,37 @@
         <result column="success_flag" property="successFlag" />
     </resultMap>
 
+    <select id="getPage" resultType="com.diagbot.entity.TranLog">
+        SELECT
+        *
+        FROM
+        tran_log a
+        WHERE
+        a.is_deleted = 'N'
+        <if test="tranLogPageVO.hospitalId != null">
+            AND a.hospital_id = #{tranLogPageVO.hospitalId}
+        </if>
+        <if test="tranLogPageVO.patientId != null and tranLogPageVO.patientId != ''">
+            AND a.patient_id LIKE CONCAT( '%', #{tranLogPageVO.patientId}, '%' )
+        </if>
+        <if test="tranLogPageVO.sceneName != null and tranLogPageVO.sceneName != ''">
+            AND a.scene_name LIKE CONCAT( '%', #{tranLogPageVO.sceneName}, '%' )
+        </if>
+        <if test="tranLogPageVO.subHospitalName != null and tranLogPageVO.subHospitalName != ''">
+            AND a.sub_hospital_name LIKE CONCAT( '%', #{tranLogPageVO.subHospitalName}, '%' )
+        </if>
+        <if test="tranLogPageVO.startGmtReq != null and tranLogPageVO.endGmtReq != null">
+            AND DATE_FORMAT( a.gmt_req, '%Y-%m-%d %T.%f' ) BETWEEN  DATE_FORMAT(#{tranLogPageVO.startGmtReq}, '%Y-%m-%d %T.%f' )
+            AND DATE_FORMAT(#{tranLogPageVO.endGmtReq}, '%Y-%m-%d %T.%f' )
+        </if>
+        <if test="tranLogPageVO.startGmtResp != null and tranLogPageVO.endGmtResp != null">
+            AND DATE_FORMAT( a.gmt_resp, '%Y-%m-%d %T.%f' ) BETWEEN DATE_FORMAT(#{tranLogPageVO.startGmtResp}, '%Y-%m-%d %T.%f' )
+            AND DATE_FORMAT(#{tranLogPageVO.endGmtResp}, '%Y-%m-%d %T.%f' )
+        </if>
+        <if test="tranLogPageVO.successFlag != null">
+            AND a.success_flag = #{tranLogPageVO.successFlag}
+        </if>
+        ORDER BY
+        a.gmt_modified
+    </select>
 </mapper>