Bladeren bron

优化批量授权协定发权限的存储过程

guowei 2 jaren geleden
bovenliggende
commit
a648dd13e9
1 gewijzigde bestanden met toevoegingen van 6 en 5 verwijderingen
  1. 6 5
      cbkj_web_api/src/main/resources/sqlRecord/pre_api_v5.15.1.sql

+ 6 - 5
cbkj_web_api/src/main/resources/sqlRecord/pre_api_v5.15.1.sql

@@ -7,6 +7,7 @@ insert into `t_sys_param` (`PAR_ID`, `APP_ID`, `INS_CODE`, `DEPT_ID`, `PAR_CODE`
 
 #2022-03-03 guowei 批量处理从HIS同步过来的协定方权限(使用HIS科室)
 DELIMITER $$
+DROP PROCEDURE IF EXISTS `batch_personal_rule_auth_his`$$
 CREATE
     /*[DEFINER = { user | CURRENT_USER }]*/
     PROCEDURE `batch_personal_rule_auth_his`()
@@ -20,16 +21,16 @@ BEGIN
                       UNION ALL
                       SELECT p.IS_SHARE, d.DEP_ORIGIN_ID DEPT_ID, 1 AS dept_check_all, i.id, p.PERS_PRE_ID
                       FROM t_personal_prescription p
-                               JOIN sys_department d ON d.`DEP_ORIGIN_ID` = p.`DEPT_ID`
-                               JOIN sys_admin_practice e ON e.dep_id = d.`DEP_ORIGIN_ID`
+                               JOIN sys_department d ON d.`DEP_ORIGIN_ID` = p.`DEPT_ID` AND d.`INS_CODE` = p.`INS_CODE` AND d.app_id = p.app_id
+                               JOIN sys_admin_practice e ON e.dep_id = d.`DEP_ORIGIN_ID` AND e.ins_code = d.ins_code AND e.app_id = d.app_id
                                JOIN sys_admin_info i ON i.`id` = e.`admin_id`
                       WHERE p.is_del = '0' AND p.IS_SHARE = '1'
                       UNION ALL
                       SELECT p.IS_SHARE, d.DEP_ORIGIN_ID DEPT_ID, 1 AS dept_check_all, i.id, p.PERS_PRE_ID
                       FROM t_personal_prescription p
-                               JOIN sys_institution s ON s.`INS_CODE` = p.`INS_CODE`
-                               JOIN sys_department d ON d.`INS_CODE` = s.`INS_CODE`
-                               JOIN sys_admin_practice e ON e.dep_id = d.`DEP_ORIGIN_ID`
+                               JOIN sys_institution s ON s.`INS_CODE` = p.`INS_CODE` AND s.app_id = p.app_id
+                               JOIN sys_department d ON d.`INS_CODE` = s.`INS_CODE` AND d.app_id = s.app_id
+                               JOIN sys_admin_practice e ON e.dep_id = d.`DEP_ORIGIN_ID` AND e.ins_code = d.ins_code AND e.app_id = d.app_id
                                JOIN sys_admin_info i ON i.`ID` = e.`admin_id`
                       WHERE p.is_del = '0' AND p.IS_SHARE = '2'
                   ) s