浏览代码

支持子科室领药

lighter 2 年之前
父节点
当前提交
d3f08d425d

+ 8 - 3
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyiji/MedicineManagementDao.java

@@ -9,14 +9,19 @@ import java.util.List;
 
 @Mapper
 public interface MedicineManagementDao {
+
+    @Select("select rtrim(code) from zd_unit_code where parent_code=#{code} ")
+    List<String> selectChildDepartments(String code);
+
     @Select("select b.code as chargeCode,sum(a.amount) as amount,sum(a.charge_fee) as chargeFee, " +
             "max(b.pack_retprice) as price,max(a.exec_unit) as execUnit,b.serial as serialNo, " +
             "max(a.group_no) as groupNo,max(a.page_no) as pageNo,max(b.name) as drugName, " +
             "max(b.specification) as spec,max(a.confirm_flag) as confirmFlag,max(b.drug_flag) as drugFlag " +
             "from zy_drug a with(nolock),yp_zd_dict b with(nolock) " +
             "where isnull(a.page_no,0)=0 and charge_date>=#{start} and charge_date<=#{end} " +
-            "and isnull(confirm_flag,'0')='0' and a.group_no='73' and a.exec_unit=#{dept} and a.charge_code=b.code " +
-            "and isnull(a.serial,'01')=b.serial group by b.code,b.serial having sum(a.amount)!=0")
+            "and isnull(confirm_flag,'0')='0' and a.group_no='73' and a.exec_unit in (${dept}) " +
+            "and a.charge_code=b.code and isnull(a.serial,'01')=b.serial " +
+            "group by b.code,b.serial having sum(a.amount)!=0")
     List<MedicinePage> selectMedicinePages(FetchMedicines params);
 
     @Select("select b.code as chargeCode,rtrim(c.name) as patName,rtrim(c.inpatient_no) as patNo,sum(a.amount) as amount, " +
@@ -24,7 +29,7 @@ public interface MedicineManagementDao {
             "b.serial as serialNo,max(a.group_no) as groupNo,max(a.page_no) as pageNo,max(b.name) as drugName, " +
             "max(b.specification) as spec,max(a.confirm_flag) as confirmFlag,max(b.drug_flag) as drugFlag " +
             "from zy_drug a with(nolock),yp_zd_dict b with(nolock),zy_actpatient c with(nolock) " +
-            "where charge_date>=#{start} and charge_date<=#{end} and a.group_no='73' and a.exec_unit=#{dept} " +
+            "where charge_date>=#{start} and charge_date<=#{end} and a.group_no='73' and a.exec_unit in (${dept}) " +
             "and a.charge_code=b.code and a.inpatient_no=c.inpatient_no and isnull(a.serial,'01')=b.serial " +
             "group by b.code,b.serial,c.inpatient_no,c.name,a.charge_date having sum(a.amount)!=0")
     List<MedicinePage> selectUsedMedicines(FetchMedicines params);

+ 13 - 0
src/main/java/thyyxxk/webserver/service/zhuyuanyiji/MedicineManagementService.java

@@ -31,6 +31,7 @@ public class MedicineManagementService {
 
     public ResultVo<List<MedicinePage>> fetchMedicinePages(FetchMedicines params) {
         transformDateToDatetime(params);
+        buildChildDepartments(params);
         List<MedicinePage> list = dao.selectMedicinePages(params);
         if (list.isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
@@ -40,6 +41,7 @@ public class MedicineManagementService {
 
     public ResultVo<List<MedicinePage>> fetchUsedMedicines(FetchMedicines params) {
         transformDateToDatetime(params);
+        buildChildDepartments(params);
         List<MedicinePage> list = dao.selectUsedMedicines(params);
         if (list.isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
@@ -96,4 +98,15 @@ public class MedicineManagementService {
         params.setStart(params.getStart() + " 00:00:00.000");
         params.setEnd(params.getEnd() + " 23:59:59.999");
     }
+
+    private void buildChildDepartments(FetchMedicines params) {
+        String dept = params.getDept();
+        List<String> children = dao.selectChildDepartments(dept);
+        StringBuilder builder = new StringBuilder();
+        builder.append("'").append(dept).append("'");
+        for (String child : children) {
+            builder.append(",'").append(child).append("'");
+        }
+        params.setDept(builder.toString());
+    }
 }