Forráskód Böngészése

优化项目录入的查询。

xiaochan 3 éve
szülő
commit
7da0010a10

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>10.0.6</version>
+    <version>10.0.7</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 2 - 1
src/main/java/thyyxxk/webserver/controller/yibao/XiangMuLuRuController.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.controller.yibao;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.entity.ResultVo;
@@ -28,7 +29,7 @@ public class XiangMuLuRuController {
     }
 
     @PostMapping("/getHuanZheFeiYong")
-    public ResultVo<List<ZyDetailCharge>> getHuanZheFeiYong(@RequestBody ZyDetailCharge param) {
+    public ResultVo<Page<ZyDetailCharge>> getHuanZheFeiYong(@RequestBody ZyDetailCharge param) {
         return service.getHuanZheFeiYong(param);
     }
 

+ 55 - 131
src/main/java/thyyxxk/webserver/dao/his/yibao/XiangMuLuRuDao.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.dao.his.yibao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.*;
 import thyyxxk.webserver.entity.datamodify.FeiYongLeiXin;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
@@ -56,19 +57,29 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "and charge_code_mx = #{chargeCode} " +
             "</if>" +
             "<if test=\"startTime != null and startTime!= '' \">" +
-            "and convert(varchar(100),a.charge_date,23) = #{startTime} " +
+            "and a.charge_date &gt;= #{startTime} and a.charge_date &lt;= #{endTime} " +
             "</if>" +
             "<if test=\"dept != null and dept != '' \"> " +
             "and a.exec_unit=#{dept}   " +
             "</if>" +
+            "<if test=\"orderNo != 2 and orderNo != 1 \">" +
+            "and a.order_no = #{orderNo} " +
+            "</if>" +
+            "<if test=\"orderNo !=2 and orderNo == 1\">" +
+            "and len(a.order_no) &gt;2 " +
+            "</if>" +
+            "order by a.charge_date ${riQiPaiXu}" +
             "</script>")
-    List<ZyDetailCharge> huanZheYaoPinFeiYong(@Param("inpatientNo") String inpatientNo,
+    Page<ZyDetailCharge> huanZheYaoPinFeiYong(Page<ZyDetailCharge> page,
+                                              @Param("inpatientNo") String inpatientNo,
                                               @Param("admissTimes") Integer admissTimes,
                                               @Param("chargeCode") String chargeCode,
                                               @Param("infantFlag") int infantFlag,
                                               @Param("startTime") String startTime,
+                                              @Param("endTime") String endTime,
                                               @Param("orderNo") BigDecimal orderNo,
-                                              @Param("dept") String dept);
+                                              @Param("dept") String dept,
+                                              @Param("riQiPaiXu") String riQiPaiXu);
 
 
     @Select("<script>" +
@@ -108,150 +119,63 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "and charge_code_mx = #{chargeCode} " +
             "</if>" +
             "<if test=\"startTime != null and startTime!= '' \">" +
-            "and convert(varchar(100),a.charge_date,23) = #{startTime} " +
+            "and a.charge_date &gt;= #{startTime} and a.charge_date &lt;= #{endTime} " +
             "</if>" +
             "<if test=\"dept != null and dept != '' \"> " +
-            "and a.exec_unit=#{dept}   " +
+            "and a.exec_unit = #{dept}   " +
             "</if>" +
+            "<if test=\"orderNo != 2 and orderNo != 1 \">" +
+            "and a.order_no = #{orderNo} " +
+            "</if>" +
+            "<if test=\"orderNo !=2 and orderNo == 1\">" +
+            "and len(a.order_no) &gt;2 " +
+            "</if>" +
+            "order by a.charge_date ${riQiPaiXu}" +
             "</script>")
-    List<ZyDetailCharge> huanZheXiangMuFeiYong(@Param("inpatientNo") String inpatientNo,
+    Page<ZyDetailCharge> huanZheXiangMuFeiYong(Page<ZyDetailCharge> page,
+                                               @Param("inpatientNo") String inpatientNo,
                                                @Param("admissTimes") Integer admissTimes,
                                                @Param("chargeCode") String chargeCode,
                                                @Param("infantFlag") int infantFlag,
                                                @Param("startTime") String startTime,
+                                               @Param("endTime") String endTime,
                                                @Param("orderNo") BigDecimal orderNo,
-                                               @Param("dept") String dept);
+                                               @Param("dept") String dept,
+                                               @Param("riQiPaiXu") String riQiPaiXu);
+
 
-    /**
-     * 获取患者的费用
-     *
-     * @param inpatientNo 住院号
-     * @param admissTimes 住院次数
-     * @param chargeCode  项目编码
-     * @return 返回患者的费用信息
-     */
     @Select("<script>" +
-            "select * from (" +
-            "SELECT a.admiss_times, " +
-            "       a.inpatient_no, " +
-            "       a.ledger_sn, " +
-            "       a.detail_sn," +
-            "       a.charge_date, " +
-            "       a.op_id_code, " +
-            "       d.name op_name," +
-            "       a.charge_code, " +
-            "       a.charge_fee, " +
-            "       a.charge_status  , " +
-            "       bill_item_code= b.bill_item_zy," +
-            "       bill_item_name=(select name from zy_bill_item where code = b.bill_item_zy), " +
-            "       charge_name=b.name, " +
-            "       spec=b.charge_unit, " +
-            "       a.charge_code_mx, " +
-            "       a.serial, " +
-            "       price=0.0000, " +
-            "       charge_amount=a.charge_amount, " +
-            "       exec_dept=(select name from zd_unit_code where code = a.exec_unit), " +
-            "       dept_code = (select name from zd_unit_code where code = a.ward_code) , " +
-            "       self_flag=isnull(a.self_flag,0), " +
-            "       suppress_flag=a.suppress_flag, " +
-            "       group_no='00', " +
-            "       separate_flag=a.separate_flag, " +
-            "       ope_flag=a.ope_flag, " +
-            "       drugname=c.name," +
-            "       a.ori_detail_sn " +
-            "FROM zy_detail_charge a  ,zd_charge_item b,yp_zd_dict c,a_employee_mi d " +
-            "where    a.inpatient_no=#{inpatientNo} and " +
-            "        a.admiss_times=#{admissTimes} and " +
-            "<if test=\"chargeCode !=null and chargeCode != '' \">" +
-            " a.charge_code_mx = #{chargeCode} and" +
-            "</if>" +
-            "<if test=\"dept != null and dept != '' \"> " +
-            "  a.exec_unit=#{dept} and  " +
+            "SELECT count(*) " +
+            "       FROM zy_detail_charge a " +
+            "       where    a.inpatient_no= #{inpatientNo} and   " +
+            "       a.admiss_times= #{admissTimes} and   " +
+            "       a.infant_flag = #{infantFlag}  and trans_flag_yb !=2   " +
+            "       AND a.charge_code ${isLike} 'BILL%' and a.ledger_sn &gt;0  " +
+            "<if test=\"chargeCode != null and chargeCode != '' \">" +
+            "and charge_code_mx = #{chargeCode} " +
             "</if>" +
-            "        a.charge_code=b.code and " +
-            "<if test=\"startTime != null and startTime!= '' \">" +
-            " convert(varchar(100),a.charge_date,23) = #{startTime} and " +
-            "</if>" +
-            "<if test=\"orderNo !=null\">" +
-            "<choose>" +
-            "<when test=\"orderNo == 1\">" +
-            " len(a.order_no) &gt; 2 and " +
-            "</when>" +
-            "<when test=\"orderNo == 4\">" +
-            " a.order_no != 6 and " +
-            "</when>" +
-            "<otherwise>" +
-            " a.order_no = #{orderNo} and " +
-            "</otherwise>" +
-            "</choose>" +
-            "</if>" +
-            "        a.serial=c.serial and a.charge_code like 'BILL%' and " +
-            "        c.code= a.charge_code_mx  and a.ledger_sn &gt; 0 and " +
-            "        a.infant_flag = #{infantFlag} and d.code = a.op_id_code and trans_flag_yb !=2 " +
-            "union " +
-            "SELECT a.admiss_times, " +
-            "       a.inpatient_no, " +
-            "       a.ledger_sn, " +
-            "       a.detail_sn, " +
-            "       a.charge_date, " +
-            "       a.op_id_code, " +
-            "       c.name op_name," +
-            "       a.charge_code, " +
-            "       a.charge_fee, " +
-            "       a.charge_status  , " +
-            "       bill_item_code = b.bill_item_zy," +
-            "       bill_item_name=(select name from zy_bill_item where code = b.bill_item_zy), " +
-            "       charge_name=b.name, " +
-            "       spec=b.charge_unit, " +
-            "       a.charge_code_mx, " +
-            "       a.serial, " +
-            "       price=0.0000, " +
-            "       charge_amount=a.charge_amount, " +
-            "       exec_dept=(select name from zd_unit_code where code = a.exec_unit), " +
-            "       dept_code = (select name from zd_unit_code  where code = a.ward_code) , " +
-            "       self_flag=a.self_flag, " +
-            "       suppress_flag=a.suppress_flag, " +
-            "       group_no='00', " +
-            "       separate_flag=a.separate_flag, " +
-            "       ope_flag=a.ope_flag, " +
-            "       drugname=b.name," +
-            "       a.ori_detail_sn " +
-            "FROM zy_detail_charge a  ,zd_charge_item b , a_employee_mi c " +
-            "where    a.inpatient_no= #{inpatientNo} and " +
-            "        a.admiss_times= #{admissTimes} and " +
-            "<if test=\"chargeCode !=null and chargeCode != '' \">" +
-            " a.charge_code_mx = #{chargeCode} and" +
-            "</if>" +
-            "        a.charge_code=b.code and " +
             "<if test=\"startTime != null and startTime!= '' \">" +
-            " convert(varchar(100),a.charge_date,23) = #{startTime} and " +
+            "and a.charge_date &gt;= #{startTime} and a.charge_date &lt;= #{endTime} " +
             "</if>" +
             "<if test=\"dept != null and dept != '' \"> " +
-            "  a.exec_unit=#{dept} and  " +
-            "</if>" +
-            "<if test=\"orderNo !=null\">" +
-            "<choose>" +
-            "<when test=\"orderNo == 1\">" +
-            " len(a.order_no) &gt; 2 and " +
-            "</when>" +
-            "<when test=\"orderNo == 4\">" +
-            " a.order_no != 6 and " +
-            "</when>" +
-            "<otherwise>" +
-            " a.order_no = #{orderNo} and " +
-            "</otherwise>" +
-            "</choose>" +
-            "</if>" +
-            "a.infant_flag = #{infantFlag} and c.code = a.op_id_code and trans_flag_yb !=2 AND a.charge_code not like 'BILL%' " +
-            "and a.ledger_sn &gt; 0  ) temp" +
+            "and a.exec_unit = #{dept}   " +
+            "</if>" +
+            "<if test=\"orderNo != 2 and orderNo != 1 \">" +
+            "and a.order_no = #{orderNo} " +
+            "</if>" +
+            "<if test=\"orderNo !=2 and orderNo == 1\">" +
+            "and len(a.order_no) &gt;2 " +
+            "</if>" +
             "</script>")
-    List<ZyDetailCharge> getHuanZheFeiYong(@Param("inpatientNo") String inpatientNo,
-                                           @Param("admissTimes") Integer admissTimes,
-                                           @Param("chargeCode") String chargeCode,
-                                           @Param("infantFlag") int infantFlag,
-                                           @Param("startTime") String startTime,
-                                           @Param("orderNo") BigDecimal orderNo,
-                                           @Param("dept") String dept);
+    long huanZheFeiYongCount(@Param("inpatientNo") String inpatientNo,
+                             @Param("admissTimes") Integer admissTimes,
+                             @Param("chargeCode") String chargeCode,
+                             @Param("infantFlag") int infantFlag,
+                             @Param("startTime") String startTime,
+                             @Param("endTime") String endTime,
+                             @Param("orderNo") BigDecimal orderNo,
+                             @Param("dept") String dept,
+                             @Param("isLike") String isLike);
 
 
     @Select("select detail_sn,ori_detail_sn from zy_detail_charge where inpatient_no=#{inpatientNo} and admiss_times = #{admissTimes} " +

+ 23 - 0
src/main/java/thyyxxk/webserver/entity/datamodify/ZyDetailCharge.java

@@ -3,6 +3,7 @@ package thyyxxk.webserver.entity.datamodify;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -23,6 +24,7 @@ import java.util.List;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @ApiModel(value = "ZyDetailCharge对象", description = "")
+@JsonInclude(JsonInclude.Include.NON_NULL)
 public class ZyDetailCharge implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -33,6 +35,8 @@ public class ZyDetailCharge implements Serializable {
     private Integer admissTimes;
 
     private String startTime;
+    private String endTime;
+    private String riQiPaiXu;
 
     private String chargeCodeName;
 
@@ -121,6 +125,9 @@ public class ZyDetailCharge implements Serializable {
     @TableField(exist = false)
     private long currentPage;
 
+    @TableField(exist = false)
+    private Integer feiYongLeiXingCode;
+
     private String billItemCode;
 
     private String chargeName;
@@ -268,5 +275,21 @@ public class ZyDetailCharge implements Serializable {
      */
     private Integer tuiFeiFlag;
 
+    public String getRiQiPaiXu() {
+        if (riQiPaiXu == null) {
+            return "DESC";
+        } else {
+            return riQiPaiXu;
+        }
+    }
+
+    public BigDecimal getOrderNo() {
+        if (this.orderNo == null) {
+            return new BigDecimal(0);
+        } else {
+            return orderNo;
+        }
+    }
+
 
 }

+ 18 - 16
src/main/java/thyyxxk/webserver/service/yibao/XiangMuLuRuService.java

@@ -2,6 +2,7 @@ package thyyxxk.webserver.service.yibao;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.ListUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,30 +54,31 @@ public class XiangMuLuRuService {
      * @param param 查询条件
      * @return 返回患者费用
      */
-    public ResultVo<List<ZyDetailCharge>> getHuanZheFeiYong(ZyDetailCharge param) {
+    public ResultVo<Page<ZyDetailCharge>> getHuanZheFeiYong(ZyDetailCharge param) {
         if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号或住院次数为空<br/>๑乛◡乛๑");
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号或住院次数为空 <br/>๑乛◡乛๑");
         }
-        log.info("查询患者费用==》住院号{},住院次数:{},项目名称:{},录入日期:{},费用类型:{},科室:{}", param.getInpatientNo(), param.getAdmissTimes(),
-                param.getChargeCode(), param.getStartTime(), param.getOrderNo(), param.getDept());
+        log.info("查询患者费用==》住院号{},住院次数:{},项目名称:{},费用类型:{},科室:{}", param.getInpatientNo(), param.getAdmissTimes(),
+                param.getChargeCode(), param.getOrderNo(), param.getDept());
         int infantFlag = 0;
         // 如果是婴儿的话那么就需要截取 字符串了 在通过婴儿标识来判断
         if (param.getInpatientNo().contains("$")) {
             param.setInpatientNo(param.getInpatientNo().split("\\$")[0]);
             infantFlag = 1;
         }
-        List<ZyDetailCharge> list = null;
-        if (param.getOrderNo().compareTo(new BigDecimal(2)) == 0) {
-            list = dao.huanZheXiangMuFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
-                    param.getStartTime(), param.getOrderNo(), param.getDept());
-        } else if (param.getOrderNo().compareTo(new BigDecimal(5)) == 0) {
-            list = dao.huanZheYaoPinFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
-                    param.getStartTime(), param.getOrderNo(), param.getDept());
+        Page<ZyDetailCharge> page = new Page<>(param.getCurrentPage(), param.getPageSize(), false);
+        if (param.getFeiYongLeiXingCode() == 0) {
+            dao.huanZheXiangMuFeiYong(page, param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
+                    param.getStartTime(), param.getEndTime(), param.getOrderNo(), param.getDept(), param.getRiQiPaiXu());
+            page.setTotal(dao.huanZheFeiYongCount(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
+                    param.getStartTime(), param.getEndTime(), param.getOrderNo(), param.getDept(), "not like"));
         } else {
-            list = dao.getHuanZheFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
-                    param.getStartTime(), param.getOrderNo(), param.getDept());
+            dao.huanZheYaoPinFeiYong(page, param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
+                    param.getStartTime(), param.getEndTime(), param.getOrderNo(), param.getDept(), param.getRiQiPaiXu());
+            page.setTotal(dao.huanZheFeiYongCount(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
+                    param.getStartTime(), param.getEndTime(), param.getOrderNo(), param.getDept(), "like"));
         }
-        if (list.isEmpty()) {
+        if (page.getTotal() == 0) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到符合费用。");
         }
         List<ZyDetailCharge> tuiFeiList = dao.tuiFeiList(param.getInpatientNo(), param.getAdmissTimes(), infantFlag);
@@ -85,7 +87,7 @@ public class XiangMuLuRuService {
             for (ZyDetailCharge zyDetailCharge : tuiFeiList) {
                 map.put(zyDetailCharge.getOriDetailSn(), zyDetailCharge.getDetailSn());
             }
-            for (ZyDetailCharge zyDetailCharge : list) {
+            for (ZyDetailCharge zyDetailCharge : page.getRecords()) {
                 // 判断 退费的数据
                 if (map.containsKey(zyDetailCharge.getDetailSn())) {
                     zyDetailCharge.setTuiFeiFlag(1);
@@ -95,7 +97,7 @@ public class XiangMuLuRuService {
                 }
             }
         }
-        return ResultVoUtil.success(list);
+        return ResultVoUtil.success(page);
     }
 
     /**