Browse Source

优化小科室新增

hsh 4 months ago
parent
commit
575ec9c598

+ 3 - 0
src/main/java/thyyxxk/webserver/dao/his/dictionary/BedDeptDictDao.java

@@ -195,6 +195,9 @@ public interface BedDeptDictDao {
     @Select(" select * from zd_dept_all where dept_id = #{deptId}  ")
     Map<String, Object> selectSmallDeptByCode(@Param("deptId") Integer deptId);
 
+    @Select(" select * from zd_dept_all where dept = #{dept} and small_dept = #{smallDept}  ")
+    int selectSmallDeptByDept(@Param("dept") String dept, @Param("smallDept") String smallDept);
+
     @Update("<script>" +
             "update zd_dept_all " +
             "<trim prefix=\"set\" suffixOverrides=\",\">" +

+ 4 - 0
src/main/java/thyyxxk/webserver/service/dictionary/BedDeptDictService.java

@@ -233,6 +233,10 @@ public class BedDeptDictService {
 
         Map<String, Object> resultMap = new HashMap<>();
         Map<String, Object> small = dao.selectSmallDeptByCode(deptId);
+        int nn = dao.selectSmallDeptByDept(dept, smallDept);
+        if(null == small && nn > 0){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "存在相同的大科室-小科室关系,不能新增!");
+        }
         int num;
         try{
             if(null != small){