lihong 2 years ago
parent
commit
ddb4ae3872

+ 10 - 3
src/main/java/cn/hnthyy/thmz/controller/mz/MzyReqrecController.java

@@ -16,6 +16,7 @@ import cn.hnthyy.thmz.service.his.mz.*;
 import cn.hnthyy.thmz.service.his.zd.ZdChequeTypeService;
 import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.thmz.TransactionService;
+import cn.hnthyy.thmz.service.thmz.UserDeptRelationService;
 import cn.hnthyy.thmz.service.thmz.WindowsService;
 import cn.hnthyy.thmz.vo.MzyReqrecVo;
 import cn.hnthyy.thmz.vo.PageViewVo;
@@ -55,6 +56,8 @@ public class MzyReqrecController {
     private TransactionService transactionService;
     @Autowired
     private ZdChequeTypeService zdChequeTypeService;
+    @Autowired
+    private UserDeptRelationService userDeptRelationService;
 
     /**
      * 保存挂号信息
@@ -862,13 +865,17 @@ public class MzyReqrecController {
             Integer count = null;
             if (Constants.EMERGENCY_WARD_CODE.equals(deptCode)) {
                 beforeDate = DateUtil.getDateFromNow(-3);
-                count = mzyReqrecService.queryValidMzyReqrec(patientId, null, deptCode, beforeDate);
+                count = mzyReqrecService.queryValidMzyReqrec(patientId, null, deptCode, beforeDate,null);
             } else {
                 beforeDate = DateUtil.getDateFromNow(-1);
                 if(Constants.JY_EXEC_CODE.equals(deptCode)){
-                    count = mzyReqrecService.queryValidMzyReqrec(patientId, tokenUser.getUserIdCode(), null, beforeDate);
+                    count = mzyReqrecService.queryValidMzyReqrec(patientId, tokenUser.getUserIdCode(), null, beforeDate,null);
                 }else {
-                    count = mzyReqrecService.queryValidMzyReqrec(patientId, null, deptCode, beforeDate);
+                    count = mzyReqrecService.queryValidMzyReqrec(patientId, tokenUser.getUserIdCode(), null, beforeDate,null);
+                    if(count <=0 ){
+                        List<String> deptNos = userDeptRelationService.queryAllByUserIdCode(tokenUser.getUserIdCode());
+                        count = mzyReqrecService.queryValidMzyReqrec(patientId, null, null, beforeDate,deptNos);
+                    }
                 }
             }
             if (count == null) {

+ 13 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzyReqrecMapper.java

@@ -184,9 +184,21 @@ public interface MzyReqrecMapper {
             "</when>",
             "<when test='deptCode!=null'>",
             " and (visit_dept = #{deptCode} or unit_code = #{deptCode})",
+            "</when>",
+            "<when test='deptCodes!=null and deptCodes.size >0 '>",
+            " and (" ,
+                    " visit_dept in " ,
+            "<foreach item='item' index='index' collection='deptCodes' open='(' separator=',' close=')'>",
+            "#{item}",
+            "</foreach>",
+                    " or unit_code in " ,
+            "<foreach item='item' index='index' collection='deptCodes' open='(' separator=',' close=')'>",
+            "#{item}",
+            "</foreach>",
+                            ")",
             "</when>",
              "</script>"})
-    Integer selectValidMzyReqrec(@Param("patientId")String patientId,@Param("doctorCode")String doctorCode,@Param("deptCode")String deptCode,@Param("befoDate")Date befoDate);
+    Integer selectValidMzyReqrec(@Param("patientId")String patientId,@Param("doctorCode")String doctorCode,@Param("deptCode")String deptCode,@Param("befoDate")Date befoDate,@Param("deptCodes")List<String> deptCodes);
 
     /**
      * 查询所有退号信息

+ 2 - 2
src/main/java/cn/hnthyy/thmz/mapper/thmz/ClinicMapper.java

@@ -84,7 +84,7 @@ public interface ClinicMapper {
             "<foreach item='item' index='index' collection='deptCodes' open='(' separator=',' close=')'>" +
             "#{item}" +
             "</foreach>" +
-            " ) or doctor_code = #{doctorCode})" +
+            " and jz_flag=1) or doctor_code = #{doctorCode})" +
             "</when>" +
             "<otherwise>" +
             "<when test='doctorCode!=null'>" +
@@ -159,7 +159,7 @@ public interface ClinicMapper {
             "<foreach item='item' index='index' collection='deptCodes' open='(' separator=',' close=')'>" +
             "#{item}" +
             "</foreach>" +
-            " ) or doctor_code = #{doctorCode})" +
+            " and jz_flag=1) or doctor_code = #{doctorCode})" +
             "</when>" +
             "<otherwise>" +
             "<when test='doctorCode!=null'>" +

+ 1 - 1
src/main/java/cn/hnthyy/thmz/service/his/mz/MzyReqrecService.java

@@ -190,7 +190,7 @@ public interface MzyReqrecService {
      * @param befoDate   急诊科看三天内  其他科室一天内
      * @return
      */
-    Integer queryValidMzyReqrec(String patientId, String doctorCode, String deptCode, Date befoDate);
+    Integer queryValidMzyReqrec(String patientId, String doctorCode, String deptCode, Date befoDate,List<String> deptCodes);
 
 
     /**

+ 2 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzyReqrecServiceImpl.java

@@ -382,8 +382,8 @@ public class MzyReqrecServiceImpl implements MzyReqrecService {
     }
 
     @Override
-    public Integer queryValidMzyReqrec(String patientId, String doctorCode, String deptCode, Date befoDate) {
-        return mzyReqrecMapper.selectValidMzyReqrec(patientId, doctorCode, deptCode, befoDate);
+    public Integer queryValidMzyReqrec(String patientId, String doctorCode, String deptCode, Date befoDate,List<String> deptCodes) {
+        return mzyReqrecMapper.selectValidMzyReqrec(patientId, doctorCode, deptCode, befoDate,deptCodes);
     }
 
     @Override