Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/dev/20200426_2nd' into dev/20200426_2nd

zhoutg 5 gadi atpakaļ
vecāks
revīzija
c633b438aa

+ 70 - 0
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -698,4 +698,74 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         res.put("details", msgMap);
         return res;
     }
+
+    /**
+     *
+     * @param behospitalPageVO
+     * @return
+     */
+    public IPage<BehospitalInfoDTO> pagePerson(BehospitalPageVO behospitalPageVO) {
+        //入参验证
+        //入院时间
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateStart()) {
+            behospitalPageVO.setBehosDateStart(DateUtil.getFirstTimeOfDay(behospitalPageVO.getBehosDateStart()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateEnd()) {
+            behospitalPageVO.setBehosDateEnd(DateUtil.getLastTimeOfDay(behospitalPageVO.getBehosDateEnd()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateStart() && null != behospitalPageVO.getBehosDateEnd()) {
+            if (DateUtil.after(behospitalPageVO.getBehosDateStart(), behospitalPageVO.getBehosDateEnd())) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "入院时间的开始时间必须小于结束时间!");
+            }
+        }
+        //出院时间
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateStart()) {
+            behospitalPageVO.setLeaveHosDateStart(DateUtil.getFirstTimeOfDay(behospitalPageVO.getLeaveHosDateStart()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateEnd()) {
+            behospitalPageVO.setLeaveHosDateEnd(DateUtil.getLastTimeOfDay(behospitalPageVO.getLeaveHosDateEnd()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateStart() && null != behospitalPageVO.getLeaveHosDateEnd()) {
+            if (DateUtil.after(behospitalPageVO.getLeaveHosDateStart(), behospitalPageVO.getLeaveHosDateEnd())) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "出院时间的开始时间必须小于结束时间!");
+            }
+        }
+        behospitalPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+        behospitalPageVO.setUserId(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
+        IPage<BehospitalInfoDTO> res = getPageByPerson(behospitalPageVO);
+        return res;
+    }
+
+    public IPage<BehospitalInfoDTO> pageDept(BehospitalPageVO behospitalPageVO) {
+        //入参验证
+        //入院时间
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateStart()) {
+            behospitalPageVO.setBehosDateStart(DateUtil.getFirstTimeOfDay(behospitalPageVO.getBehosDateStart()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateEnd()) {
+            behospitalPageVO.setBehosDateEnd(DateUtil.getLastTimeOfDay(behospitalPageVO.getBehosDateEnd()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateStart() && null != behospitalPageVO.getBehosDateEnd()) {
+            if (DateUtil.after(behospitalPageVO.getBehosDateStart(), behospitalPageVO.getBehosDateEnd())) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "入院时间的开始时间必须小于结束时间!");
+            }
+        }
+        //出院时间
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateStart()) {
+            behospitalPageVO.setLeaveHosDateStart(DateUtil.getFirstTimeOfDay(behospitalPageVO.getLeaveHosDateStart()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateEnd()) {
+            behospitalPageVO.setLeaveHosDateEnd(DateUtil.getLastTimeOfDay(behospitalPageVO.getLeaveHosDateEnd()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateStart() && null != behospitalPageVO.getLeaveHosDateEnd()) {
+            if (DateUtil.after(behospitalPageVO.getLeaveHosDateStart(), behospitalPageVO.getLeaveHosDateEnd())) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "出院时间的开始时间必须小于结束时间!");
+            }
+        }
+        behospitalPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+        behospitalPageVO.setUserId(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
+        IPage<BehospitalInfoDTO> res = getPageByDept(behospitalPageVO);
+        return res;
+    }
+
 }

+ 4 - 0
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -68,4 +68,8 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
 
 
     public List<BehospitalInfo> getNoGrade();
+
+    IPage<BehospitalInfoDTO> getPageByDept(BehospitalPageVO behospitalPageVO);
+
+    IPage<BehospitalInfoDTO> getPageByPerson(BehospitalPageVO behospitalPageVO);
 }

+ 3 - 0
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -68,4 +68,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
 
 
     public List<BehospitalInfo> getNoGrade();
+
+    IPage<BehospitalInfoDTO> getPageByDept(BehospitalPageVO behospitalPageVO);
+    IPage<BehospitalInfoDTO> getPageByPerson(BehospitalPageVO behospitalPageVO);
 }

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

@@ -95,4 +95,13 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     public List<BehospitalInfo> getNoGrade() {
         return baseMapper.getNoGrade();
     }
+
+    @Override
+    public IPage<BehospitalInfoDTO> getPageByDept(BehospitalPageVO behospitalPageVO){
+        return baseMapper.getPageByDept(behospitalPageVO);
+    }
+    @Override
+    public IPage<BehospitalInfoDTO> getPageByPerson(BehospitalPageVO behospitalPageVO) {
+        return baseMapper.getPageByPerson(behospitalPageVO);
+    }
 }

+ 3 - 1
src/main/java/com/diagbot/vo/BehospitalPageVO.java

@@ -69,11 +69,13 @@ public class BehospitalPageVO extends Page implements Serializable {
     /**
      * 住院科室名称
      */
-    private String behDeptName;
+    private Long deptId;
 
     /**
      * 医生姓名
      */
     private String doctorName;
 
+    @ApiModelProperty(hidden = true)
+    private Long userId;
 }

+ 2 - 2
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -147,7 +147,7 @@ public class BehospitalInfoController {
     @PostMapping("/page_dept")
     @SysLogger("page_dept")
     public RespDTO<IPage<BehospitalInfoDTO>> pageDept(@RequestBody BehospitalPageVO behospitalPageVO) {
-        IPage<BehospitalInfoDTO> data = behospitalInfoFacade.pageFac(behospitalPageVO);
+        IPage<BehospitalInfoDTO> data = behospitalInfoFacade.pageDept(behospitalPageVO);
         return RespDTO.onSuc(data);
     }
 
@@ -161,7 +161,7 @@ public class BehospitalInfoController {
     @PostMapping("/page_person")
     @SysLogger("page_person")
     public RespDTO<IPage<BehospitalInfoDTO>> pagePerson(@RequestBody BehospitalPageVO behospitalPageVO) {
-        IPage<BehospitalInfoDTO> data = behospitalInfoFacade.pageFac(behospitalPageVO);
+        IPage<BehospitalInfoDTO> data = behospitalInfoFacade.pagePerson(behospitalPageVO);
         return RespDTO.onSuc(data);
     }
 }

+ 2 - 0
src/main/resources/mapper/BasDeptInfoMapper.xml

@@ -32,6 +32,7 @@
         <if test="inputStr !=null and inputStr != ''">
             AND (UPPER(t.spell) LIKE CONCAT('%', UPPER(TRIM(#{inputStr})),'%') OR UPPER(t.dept_name) LIKE CONCAT('%', UPPER(TRIM(#{inputStr})),'%'));
         </if>
+        ORDER BY t.dept_name ASC
     </select>
 
     <select id="getListUser" resultType="com.diagbot.dto.BasDeptInfoDTO"
@@ -52,5 +53,6 @@
         <if test="inputStr !=null and inputStr != ''">
             AND (UPPER(t.spell) LIKE CONCAT('%', UPPER(TRIM(#{inputStr})),'%') OR UPPER(t.dept_name) LIKE CONCAT('%', UPPER(TRIM(#{inputStr})),'%'));
         </if>
+        ORDER BY t.dept_name ASC
     </select>
 </mapper>

+ 130 - 3
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -40,11 +40,11 @@
             on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
         ) t
         where t.is_deleted = 'N'
-        <if test="behDeptName != null and behDeptName != ''">
-            and t.beh_dept_name like CONCAT('%',#{behDeptName},'%')
+        <if test="deptId != null and deptId != ''">
+            and t.beh_dept_id = #{deptId}
         </if>
         <if test="doctorName != null and doctorName != ''">
-            and t.doctor_name like CONCAT('%',#{doctorName},'%')
+            and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
         </if>
         <if test="name != null and name != ''">
             and t.name like CONCAT('%',#{name},'%')
@@ -319,4 +319,131 @@
             AND a.behospital_code = b.behospital_code
             )
     </select>
+    <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
+        SELECT
+        *
+        FROM
+        (     SELECT
+        a.*,
+        IFNULL(b.level, '未评分') AS `level`,
+        b.grade_type,
+        b.score_res,
+        b.gmt_create AS grade_time,
+        c.age
+        FROM
+        med_behospital_info a
+        JOIN sys_user_dept d
+        ON a.hospital_id = d.hospital_id
+        AND a.beh_dept_id = d.dept_id
+        LEFT JOIN med_qcresult_info b
+        ON a.behospital_code = b.behospital_code
+        AND b.is_deleted = 'N'
+        LEFT JOIN med_home_page c
+        ON a.behospital_code = c.behospital_code
+        AND c.is_deleted = 'N'
+        WHERE d.is_deleted = 'N'
+        AND d.user_id = #{userId}
+        ) t
+        where t.is_deleted = 'N'
+        <if test="deptId != null and deptId != ''">
+            and t.beh_dept_id = #{deptId}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
+        </if>
+        <if test="name != null and name != ''">
+            and t.name like CONCAT('%',#{name},'%')
+        </if>
+        <if test="fileCode != null and fileCode != ''">
+            and t.file_code like CONCAT('%',#{fileCode},'%')
+        </if>
+        <if test="hospitalId != null">
+            and t.hospital_id = #{hospitalId}
+        </if>
+        <if test="behospitalCode != null and behospitalCode != ''">
+            and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
+        </if>
+        <if test="behosDateStart != null">
+            <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
+        </if>
+        <if test="behosDateEnd != null">
+            <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
+        </if>
+        <if test="leaveHosDateStart != null">
+            <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
+        </if>
+        <if test="leaveHosDateEnd != null">
+            <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
+        </if>
+        <if test="level != null and level != ''">
+            and t.level = #{level}
+        </if>
+        order by t.behospital_date desc
+    </select>
+    <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
+        select * from (SELECT
+        a.*,
+        IFNULL(b.level, '未评分') AS `level`,
+        b.grade_type,
+        b.score_res,
+        b.gmt_create AS grade_time,
+        c.age
+        FROM
+        med_behospital_info a
+        JOIN
+        (SELECT
+        u.id,
+        u.linkman AS linkman,
+        uh.hospital_id
+        FROM
+        sys_user u
+        JOIN sys_user_hospital uh
+        ON u.id = uh.user_id
+        WHERE u.is_deleted = "N"
+        AND u.id = #{userId}
+        AND uh.hospital_id = #{hospitalId}) u1
+        ON a.hospital_id = u1.hospital_id
+        LEFT JOIN med_qcresult_info b
+        ON a.behospital_code = b.behospital_code
+        AND b.is_deleted = 'N'
+        LEFT JOIN med_home_page c
+        ON a.behospital_code = c.behospital_code
+        AND c.is_deleted = 'N'
+        WHERE CONCAT(
+        IFNULL(a.doctor_name, ''),
+        IFNULL(a.beh_doctor_name, ''),
+        IFNULL(a.director_doctor_name, '')
+        ) LIKE CONCAT('%', u1.linkman, '%')
+        ) t
+        where t.is_deleted = 'N'
+        <if test="deptId != null and deptId != ''">
+            and t.beh_dept_id = #{deptId}
+        </if>
+        <if test="name != null and name != ''">
+            and t.name like CONCAT('%',#{name},'%')
+        </if>
+        <if test="fileCode != null and fileCode != ''">
+            and t.file_code like CONCAT('%',#{fileCode},'%')
+        </if>
+        <if test="behospitalCode != null and behospitalCode != ''">
+            and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
+        </if>
+        <if test="behosDateStart != null">
+            <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
+        </if>
+        <if test="behosDateEnd != null">
+            <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
+        </if>
+        <if test="leaveHosDateStart != null">
+            <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
+        </if>
+        <if test="leaveHosDateEnd != null">
+            <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
+        </if>
+        <if test="level != null and level != ''">
+            and t.level = #{level}
+        </if>
+        order by t.behospital_date desc
+    </select>
+
 </mapper>