浏览代码

药单情况查询

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

+ 10 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyiji/MedicineManagementController.java

@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.medicaltechnology.AsidePage;
 import thyyxxk.webserver.entity.medicaltechnology.FetchMedicines;
 import thyyxxk.webserver.entity.medicaltechnology.MedicinePage;
 import thyyxxk.webserver.entity.medicaltechnology.PoisonousAnesthetics;
@@ -42,4 +43,13 @@ public class MedicineManagementController {
         return service.fetchPoisonousAnesthetics(params);
     }
 
+    @PostMapping("/fetchSubmittedPageNos")
+    public ResultVo<List<AsidePage>> fetchSubmittedPageNos(@RequestBody @Validated FetchMedicines params) {
+        return service.fetchSubmittedPageNos(params);
+    }
+
+    @PostMapping("/fetchMedicinePageDetail")
+    public ResultVo<List<MedicinePage>> fetchMedicinePageDetail(@RequestBody AsidePage params) {
+        return service.fetchMedicinePageDetail(params);
+    }
 }

+ 16 - 6
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyiji/MedicineManagementDao.java

@@ -1,6 +1,9 @@
 package thyyxxk.webserver.dao.his.zhuyuanyiji;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
 import org.apache.ibatis.annotations.*;
+import thyyxxk.webserver.entity.medicaltechnology.AsidePage;
 import thyyxxk.webserver.entity.medicaltechnology.FetchMedicines;
 import thyyxxk.webserver.entity.medicaltechnology.MedicinePage;
 import thyyxxk.webserver.entity.medicaltechnology.PoisonousAnesthetics;
@@ -17,12 +20,8 @@ public interface MedicineManagementDao {
             "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 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);
+            "from zy_drug a with(nolock),yp_zd_dict b with(nolock) ${ew.customSqlSegment}")
+    List<MedicinePage> selectMedicinePages(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
 
     @Select("select b.code as chargeCode,rtrim(c.name) as patName,rtrim(c.inpatient_no) as patNo,sum(a.amount) as amount, " +
             "sum(a.charge_fee) as chargeFee,max(b.pack_retprice) as price,max(a.exec_unit) as execUnit,a.charge_date, " +
@@ -66,5 +65,16 @@ public interface MedicineManagementDao {
             "(select name,specification2,code,drug_flag from yp_zd_dict where drug_flag>0 group by code,name,specification2,drug_flag) b " +
             "where a.charge_date>=#{start} and a.charge_date<=#{end} and a.warn_dept!='1070000' and a.charge_item_code=b.code")
     List<PoisonousAnesthetics> selectPoisonousAnesthetics(FetchMedicines params);
+
+    @Select("select page_no,confirmDate=max(confirm_date),confirmId=max(confirm_id),exec_unit, " +
+            "confirmFlag=max(isnull(confirm_flag_new,0)) from zy_drug ${ew.customSqlSegment} " )
+    List<AsidePage> selectSubmittedPageNos(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
+
+    @Select("select chargeCode=b.code,amount=sum(a.amount),chargeFee=sum(a.charge_fee), " +
+            "amountFy=sum(case when confirm_flag='1' then a.amount else 0 end), " +
+            "price=max(a.retprice),pageNo=max(a.page_no),drugName=max(b.name), " +
+            "spec=max(b.specification),confirmFlag=max(a.confirm_flag_new), " +
+            "confirmDate=max(confirm_date) from zy_drug a,yp_zd_dict b ${ew.customSqlSegment}")
+    List<MedicinePage> fetchMedicinePageDetail(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
 }
 

+ 14 - 0
src/main/java/thyyxxk/webserver/entity/medicaltechnology/AsidePage.java

@@ -0,0 +1,14 @@
+package thyyxxk.webserver.entity.medicaltechnology;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class AsidePage {
+    private Integer pageNo;
+    private Date confirmDate;
+    private String execUnit;
+    private String confirmId;
+    private String confirmFlag;
+}

+ 3 - 1
src/main/java/thyyxxk/webserver/entity/medicaltechnology/MedicinePage.java

@@ -14,12 +14,14 @@ public class MedicinePage {
     private String groupNo;
     private String spec;
     private BigDecimal amount;
+    private BigDecimal amountFy;
     private BigDecimal chargeFee;
     private BigDecimal price;
     private String pageNo;
     private String confirmFlag;
     private String drugFlag;
-    private Date ChargeDate;
+    private Date chargeDate;
+    private Date confirmDate;
     private String patNo;
     private String patName;
     private String tjFlag = "1";

+ 6 - 3
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -311,16 +311,19 @@ public class PublicServer {
         return new ArrayList<>();
     }
 
+    public Set<String> getChildDeptByUserCode() {
+        return getChildDeptByUserCode(true);
+    }
+
     /**
      * 获取医生的子科室 和 兼职科室 以及兼职下面的子科室
      *
      * @return 返回科室
      */
-    public Set<String> getChildDeptByUserCode() {
+    public Set<String> getChildDeptByUserCode(boolean needPartTimeDept) {
         UserInfo userInfo = redisLikeService.getUserInfoByToken();
         Set<String> list = new HashSet<>();
-
-        if (ListUtil.notBlank(userInfo.getPartTimeDept())) {
+        if (needPartTimeDept && ListUtil.notBlank(userInfo.getPartTimeDept())) {
             list.addAll(userInfo.getPartTimeDept());
         }
         list.add(userInfo.getDeptCode());

+ 57 - 11
src/main/java/thyyxxk/webserver/service/zhuyuanyiji/MedicineManagementService.java

@@ -1,15 +1,18 @@
 package thyyxxk.webserver.service.zhuyuanyiji;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.zhuyuanyiji.MedicineManagementDao;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.medicaltechnology.AsidePage;
 import thyyxxk.webserver.entity.medicaltechnology.FetchMedicines;
 import thyyxxk.webserver.entity.medicaltechnology.MedicinePage;
 import thyyxxk.webserver.entity.medicaltechnology.PoisonousAnesthetics;
 import thyyxxk.webserver.service.PublicServer;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.StringUtil;
 import thyyxxk.webserver.utils.TokenUtil;
@@ -22,17 +25,18 @@ import java.util.*;
 public class MedicineManagementService {
     private final MedicineManagementDao dao;
     private final PublicServer publicService;
+    private final RedisLikeService redis;
 
     @Autowired
-    public MedicineManagementService(MedicineManagementDao dao, PublicServer publicService) {
+    public MedicineManagementService(MedicineManagementDao dao, PublicServer publicService, RedisLikeService redis) {
         this.dao = dao;
         this.publicService = publicService;
+        this.redis = redis;
     }
 
     public ResultVo<List<MedicinePage>> fetchMedicinePages(FetchMedicines params) {
         transformDateToDatetime(params);
-        buildChildDepartments(params);
-        List<MedicinePage> list = dao.selectMedicinePages(params);
+        List<MedicinePage> list = dao.selectMedicinePages(buildFetchPageNoQw(params));
         if (list.isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
@@ -49,18 +53,31 @@ public class MedicineManagementService {
         return ResultVoUtil.success(list);
     }
 
-    public ResultVo<List<MedicinePage>> submitMedicinePages(FetchMedicines newMedicinePage) {
-        if (StringUtil.isBlank(newMedicinePage.getChargeCodes())) {
+    public ResultVo<List<MedicinePage>> submitMedicinePages(FetchMedicines params) {
+        if (StringUtil.isBlank(params.getChargeCodes())) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "请勾选需要提交的药品。");
         }
         int pageNo = publicService.getTheDrugListNo();
         dao.deleteExistTargetPageNo(pageNo);
-        transformDateToDatetime(newMedicinePage);
-        newMedicinePage.setPageNo(pageNo);
-        dao.insertNewPageNo(newMedicinePage);
-        dao.submitMedicinePages(newMedicinePage);
-        log.info("【操作员:{}】提交药品单:{}", TokenUtil.getTokenUserId(), newMedicinePage);
-        return ResultVoUtil.success(dao.selectMedicinePages(newMedicinePage));
+        transformDateToDatetime(params);
+        params.setPageNo(pageNo);
+        dao.insertNewPageNo(params);
+        dao.submitMedicinePages(params);
+        log.info("【操作员:{}】提交药品单:{}", TokenUtil.getTokenUserId(), params);
+        return ResultVoUtil.success(dao.selectMedicinePages(buildFetchPageNoQw(params)));
+    }
+
+    private QueryWrapper<?> buildFetchPageNoQw(FetchMedicines params) {
+        QueryWrapper<?> qw = new QueryWrapper<>();
+        qw.ge("charge_date", params.getStart())
+                .le("charge_date", params.getEnd())
+                .eq("isnull(a.page_no,0)", "0")
+                .eq("isnull(confirm_flag,'0')", "0")
+                .eq("a.group_no", "73")
+                .apply(" a.charge_code=b.code and isnull(a.serial,'01')=b.serial")
+                .in("exec_unit", publicService.getChildDeptByUserCode(false))
+                .groupBy("b.code,b.serial having sum(a.amount)!=0");
+        return qw;
     }
 
     public ResultVo<Map<String, Object>> fetchPoisonousAnesthetics(FetchMedicines params) {
@@ -94,6 +111,35 @@ public class MedicineManagementService {
         return ResultVoUtil.success(map);
     }
 
+    public ResultVo<List<AsidePage>> fetchSubmittedPageNos(FetchMedicines params) {
+        transformDateToDatetime(params);
+        QueryWrapper<?> qw = new QueryWrapper<>();
+        qw.ge("charge_date", params.getStart())
+                .le("charge_date", params.getEnd())
+                .gt("page_no", 0).eq("group_no", "73")
+                .in("exec_unit", publicService.getChildDeptByUserCode(false))
+                .groupBy("page_no,exec_unit");
+        if (null != params.getPageNo()) {
+            qw.eq("page_no", params.getPageNo());
+        }
+        List<AsidePage> list = dao.selectSubmittedPageNos(qw);
+        if (list.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        list.forEach(item -> item.setConfirmId(redis.getEmployeeName(item.getConfirmId())));
+        return ResultVoUtil.success(list);
+    }
+
+    public ResultVo<List<MedicinePage>> fetchMedicinePageDetail(AsidePage params) {
+        QueryWrapper<?> qw = new QueryWrapper<>();
+        qw.eq("a.page_no", params.getPageNo())
+                .eq("a.group_no", "73")
+                .eq("a.exec_unit", params.getExecUnit())
+                .apply("a.charge_code=b.code and isnull(a.serial,'01')=b.serial")
+                .groupBy("b.code,b.serial having sum(a.amount)!=0");
+        return ResultVoUtil.success(dao.fetchMedicinePageDetail(qw));
+    }
+
     private void transformDateToDatetime(FetchMedicines params) {
         params.setStart(params.getStart() + " 00:00:00.000");
         params.setEnd(params.getEnd() + " 23:59:59.999");