Browse Source

Merge branch 'develop' into innerDevelop

gaodm 3 years ago
parent
commit
e2a560bf36

+ 2 - 0
doc/004.20220519科室调用日志统计/cdss_init.sql

@@ -0,0 +1,2 @@
+use `cdss`;
+ALTER TABLE `tran_log` ADD COLUMN `dept_name` VARCHAR(255) NULL COMMENT '部门名称' AFTER `hospital_id`; 

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

@@ -63,6 +63,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 //.antMatchers("/tran/hospitalInfo/saveRecord").permitAll()
                 .antMatchers("/tran/log/pageList").permitAll()
                 .antMatchers("/tran/log/getRecordById").permitAll()
+                .antMatchers("/tran/log/getStatistByDept").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

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

+ 16 - 0
src/main/java/com/diagbot/dto/TranDeptLogDTO.java

@@ -0,0 +1,16 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: wangfeng
+ * @time: 2022-05-19 13:06
+ */
+@Setter
+@Getter
+public class TranDeptLogDTO {
+    private String deptName;
+    private Integer sums;
+}

+ 11 - 0
src/main/java/com/diagbot/entity/TranLog.java

@@ -61,6 +61,9 @@ public class TranLog implements Serializable {
      */
     private Long hospitalId;
 
+
+    private String deptName;
+
     /**
      * 子医院编码
      */
@@ -108,6 +111,14 @@ public class TranLog implements Serializable {
      */
     private Integer successFlag;
 
+    public String getDeptName() {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
     public Long getId() {
         return id;
     }

+ 21 - 0
src/main/java/com/diagbot/facade/TranLogFacade.java

@@ -1,16 +1,20 @@
 package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.TranDeptLogDTO;
 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.IdVO;
+import com.diagbot.vo.StatistByDeptVO;
 import com.diagbot.vo.TranLogPageVO;
 import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+
 /**
  * @Description:
  * @author: gaodm
@@ -47,10 +51,27 @@ public class TranLogFacade extends TranLogServiceImpl {
 
     /**
      * 获取单条记录
+     *
      * @param idVO
      * @return
      */
     public TranLog getRecordById(IdVO idVO) {
         return this.getById(idVO.getId());
     }
+
+    public List<TranDeptLogDTO> getStatistByDeptName(StatistByDeptVO statistByDeptVO) {
+
+        String hospitalId = SysUserUtils.getCurrentHospitalID();
+        statistByDeptVO.setHospitalId(Long.valueOf(hospitalId));
+        if (statistByDeptVO.getStartGmtReq() != null && statistByDeptVO.getEndGmtReq() == null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入完整时间区间");
+        }
+        if (statistByDeptVO.getStartGmtReq() == null && statistByDeptVO.getEndGmtReq() != null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入完整时间区间");
+        }
+        if (statistByDeptVO.getEndGmtReq() != null) {
+            DateUtils.addMinutes(statistByDeptVO.getEndGmtReq(), 1);
+        }
+        return this.getStatisDeptAlls(statistByDeptVO);
+    }
 }

+ 6 - 0
src/main/java/com/diagbot/mapper/TranLogMapper.java

@@ -1,11 +1,15 @@
 package com.diagbot.mapper;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.TranDeptLogDTO;
 import com.diagbot.entity.TranLog;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.vo.StatistByDeptVO;
 import com.diagbot.vo.TranLogPageVO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * <p>
  * 系统日志表 Mapper 接口
@@ -16,4 +20,6 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface TranLogMapper extends BaseMapper<TranLog> {
     IPage<TranLog> getPage(@Param("tranLogPageVO") TranLogPageVO tranLogPageVO);
+
+    List<TranDeptLogDTO> getStatisDeptAlls(StatistByDeptVO statistByDeptVO);
 }

+ 6 - 0
src/main/java/com/diagbot/service/TranLogService.java

@@ -1,11 +1,15 @@
 package com.diagbot.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.TranDeptLogDTO;
 import com.diagbot.entity.TranLog;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.vo.StatistByDeptVO;
 import com.diagbot.vo.TranLogPageVO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * <p>
  * 系统日志表 服务类
@@ -16,4 +20,6 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface TranLogService extends IService<TranLog> {
     IPage<TranLog> getPage(@Param("tranLogPageVO") TranLogPageVO tranLogPageVO);
+
+    List<TranDeptLogDTO> getStatisDeptAlls(StatistByDeptVO statistByDeptVO);
 }

+ 9 - 0
src/main/java/com/diagbot/service/impl/TranLogServiceImpl.java

@@ -1,14 +1,18 @@
 package com.diagbot.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.TranDeptLogDTO;
 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.StatistByDeptVO;
 import com.diagbot.vo.TranLogPageVO;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 系统日志表 服务实现类
@@ -23,4 +27,9 @@ public class TranLogServiceImpl extends ServiceImpl<TranLogMapper, TranLog> impl
     public IPage<TranLog> getPage(@Param("tranLogPageVO") TranLogPageVO tranLogPageVO) {
         return baseMapper.getPage(tranLogPageVO);
     }
+
+    @Override
+    public List<TranDeptLogDTO> getStatisDeptAlls(StatistByDeptVO statistByDeptVO) {
+        return baseMapper.getStatisDeptAlls(statistByDeptVO);
+    }
 }

+ 1 - 0
src/main/java/com/diagbot/util/CdssLogUtil.java

@@ -66,6 +66,7 @@ public class CdssLogUtil {
             if (o instanceof CdssLogBaseVO) {
                 CdssLogBaseVO p = (CdssLogBaseVO) o;
                 tranLog.setPatientId(p.getPatientId());
+                tranLog.setDeptName(p.getDeptName());
                 tranLog.setHospitalId(p.getHospitalId());
                 tranLog.setSubHospitalCode(p.getSubHospitalCode());
                 tranLog.setSubHospitalName(p.getSubHospitalName());

+ 2 - 0
src/main/java/com/diagbot/vo/CdssLogBaseVO.java

@@ -29,6 +29,8 @@ public class CdssLogBaseVO {
      */
     private String subHospitalCode;
 
+    private String deptName;
+
     /**
      * 子医院名称
      */

+ 24 - 0
src/main/java/com/diagbot/vo/StatistByDeptVO.java

@@ -0,0 +1,24 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * @Description:
+ * @author: wangfeng
+ * @time: 2022-05-19 13:05
+ */
+@Setter
+@Getter
+public class StatistByDeptVO {
+    @ApiModelProperty(hidden = true)
+    private Long hospitalId;
+    @ApiModelProperty(hidden = true)
+    private String deptName;
+    private Date startGmtReq;
+    private Date endGmtReq;
+}

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

@@ -16,6 +16,7 @@ import java.util.Date;
 public class TranLogPageVO extends Page {
     @ApiModelProperty(hidden = true)
     private Long hospitalId;
+    private String deptName;
     private String patientId;
     private String sceneName;
     //@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")

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

@@ -3,9 +3,11 @@ package com.diagbot.web;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.TranDeptLogDTO;
 import com.diagbot.entity.TranLog;
 import com.diagbot.facade.TranLogFacade;
 import com.diagbot.vo.IdVO;
+import com.diagbot.vo.StatistByDeptVO;
 import com.diagbot.vo.TranLogPageVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.util.List;
 
 /**
  * @Description:
@@ -34,6 +37,7 @@ public class TranLogController {
     @ApiOperation(value = "调用记录[by:zhaops]",
             notes = "patientId:病人标识<br>" +
                     "sceneName:服务名<br>" +
+                    "deptName:部门名称"+
                     "startGmtReq:接收时间(起始区间),格式【yyyy-MM-dd HH:mm:ss】<br>" +
                     "endGmtReq:接收时间(结束区间),格式【yyyy-MM-dd HH:mm:ss】<br>" +
                     "startGmtResp:响应时间(起始区间),格式【yyyy-MM-dd HH:mm:ss】<br>" +
@@ -56,4 +60,18 @@ public class TranLogController {
         TranLog data = tranLogFacade.getRecordById(idVO);
         return RespDTO.onSuc(data);
     }
+
+    @ApiOperation(value = "根据医院部门查看统计数据[by:wangfeng]",
+            notes = " startGmtReq:接收时间(起始区间),格式【yyyy-MM-dd HH:mm:ss】<br>" +
+                    " endGmtReq:接收时间(结束区间),格式【yyyy-MM-dd HH:mm:ss】<br>")
+    @PostMapping("/getStatistByDept")
+    @SysLogger("getStatistByDept")
+    public RespDTO<List<TranDeptLogDTO>> getStatistByDept(@RequestBody @Valid StatistByDeptVO statistByDeptVO) {
+        List<TranDeptLogDTO> data = tranLogFacade.getStatistByDeptName(statistByDeptVO);
+        return RespDTO.onSuc(data);
+    }
+
+
+
+
 }

+ 43 - 19
src/main/resources/mapper/TranLogMapper.xml

@@ -4,23 +4,23 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.diagbot.entity.TranLog">
-        <id column="id" property="id" />
-        <result column="is_deleted" property="isDeleted" />
-        <result column="gmt_create" property="gmtCreate" />
-        <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" />
-        <result column="gmt_req" property="gmtReq" />
-        <result column="gmt_resp" property="gmtResp" />
-        <result column="exec_time" property="execTime" />
-        <result column="success_flag" property="successFlag" />
+        <id column="id" property="id"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="gmt_create" property="gmtCreate"/>
+        <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"/>
+        <result column="gmt_req" property="gmtReq"/>
+        <result column="gmt_resp" property="gmtResp"/>
+        <result column="exec_time" property="execTime"/>
+        <result column="success_flag" property="successFlag"/>
     </resultMap>
 
     <select id="getPage" resultType="com.diagbot.entity.TranLog">
@@ -33,6 +33,9 @@
         <if test="tranLogPageVO.hospitalId != null">
             AND a.hospital_id = #{tranLogPageVO.hospitalId}
         </if>
+        <if test="tranLogPageVO.deptName != null and tranLogPageVO.deptName !=''">
+            AND a.dept_name LIKE CONCAT( '%', #{tranLogPageVO.deptName}, '%' )
+        </if>
         <if test="tranLogPageVO.patientId != null and tranLogPageVO.patientId != ''">
             AND a.patient_id LIKE CONCAT( '%', #{tranLogPageVO.patientId}, '%' )
         </if>
@@ -43,11 +46,13 @@
             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' ) BETWEEN  DATE_FORMAT(#{tranLogPageVO.startGmtReq}, '%Y-%m-%d %T' )
+            AND DATE_FORMAT( a.gmt_req, '%Y-%m-%d %T' ) BETWEEN DATE_FORMAT(#{tranLogPageVO.startGmtReq}, '%Y-%m-%d %T'
+            )
             AND DATE_FORMAT(#{tranLogPageVO.endGmtReq}, '%Y-%m-%d %T' )
         </if>
         <if test="tranLogPageVO.startGmtResp != null and tranLogPageVO.endGmtResp != null">
-            AND DATE_FORMAT( a.gmt_resp, '%Y-%m-%d %T' ) BETWEEN DATE_FORMAT(#{tranLogPageVO.startGmtResp}, '%Y-%m-%d %T' )
+            AND DATE_FORMAT( a.gmt_resp, '%Y-%m-%d %T' ) BETWEEN DATE_FORMAT(#{tranLogPageVO.startGmtResp}, '%Y-%m-%d
+            %T' )
             AND DATE_FORMAT(#{tranLogPageVO.endGmtResp}, '%Y-%m-%d %T' )
         </if>
         <if test="tranLogPageVO.successFlag != null">
@@ -56,4 +61,23 @@
         ORDER BY
         a.gmt_modified DESC
     </select>
+    <select id="getStatisDeptAlls" resultType="com.diagbot.dto.TranDeptLogDTO">
+        SELECT dept_name as deptName,
+        COUNT(*) as sums
+        FROM tran_log
+        WHERE is_deleted = "N"
+        <if test="hospitalId != null">
+            AND hospital_id = #{hospitalId}
+        </if>
+        <if test="deptName != null and deptName !=''">
+            AND dept_name LIKE CONCAT( '%', #{deptName}, '%' )
+        </if>
+        <if test="startGmtReq != null and endGmtReq != null">
+            AND DATE_FORMAT( gmt_req, '%Y-%m-%d %T' ) BETWEEN DATE_FORMAT(#{startGmtReq}, '%Y-%m-%d %T'
+            )
+            AND DATE_FORMAT(#{endGmtReq}, '%Y-%m-%d %T' )
+        </if>
+        GROUP BY dept_name order by sums desc
+
+    </select>
 </mapper>