Quellcode durchsuchen

Merge branch 'dev-1.1.4' of https://172.16.32.165/hurugang/thmz_system into dev-1.1.4

hurugang vor 3 Jahren
Ursprung
Commit
ed3144fd31

+ 14 - 0
src/main/java/cn/hnthyy/thmz/controller/NavigationController.java

@@ -1327,4 +1327,18 @@ public class NavigationController {
         }
         return "yk/drug_out_statistics";
     }
+
+    /**
+     * 药品使用量统计分析
+     *
+     * @return
+     */
+    @RequestMapping("/drug-use-quantity-count")
+    public String drugUseQuantityCount(HttpServletRequest httpServletRequest) throws Exception {
+        List<String> urls = getRoleUrls(httpServletRequest);
+        if (!urls.contains("/thmz/drug-use-quantity-count")) {
+            throw new Exception("您没有此模块的权限,请联系管理员开通!");
+        }
+        return "yk/drug_use_quantity_count";
+    }
 }

+ 29 - 0
src/main/java/cn/hnthyy/thmz/controller/yk/YpBaseController.java

@@ -87,4 +87,33 @@ public class YpBaseController {
             return resultMap;
         }
     }
+
+    /**
+     * 统计药库的门诊住院药品使用量排序
+     *
+     * @param map
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/getDrugUseQuantitySort", method = {RequestMethod.POST})
+    public Map<String, Object> getDrugUseQuantitySort(@RequestBody Map<String,Object> map) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (map == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "查询记录信息失败,参数为空");
+                return resultMap;
+            }
+            List<Map<String, Object>> list = ypBaseService.queryDrugUseQuantitySort(map);
+            resultMap.put("data", list);
+            resultMap.put("code", 0);
+            resultMap.put("message", "查询记录信息成功");
+            return resultMap;
+        } catch (Exception e) {
+            log.error("系统异常,错误信息{}", e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "查询记录信息失败");
+            return resultMap;
+        }
+    }
 }

+ 0 - 2
src/main/java/cn/hnthyy/thmz/controller/yk/YpZdSupplyController.java

@@ -1,7 +1,6 @@
 package cn.hnthyy.thmz.controller.yk;
 
 
-import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.his.yp.YpZdSupply;
 import cn.hnthyy.thmz.service.his.yp.YpZdSupplyService;
 import lombok.extern.slf4j.Slf4j;
@@ -33,7 +32,6 @@ public class YpZdSupplyController {
      *
      * @return
      */
-    @UserLoginToken
     @RequestMapping(value = "/getYpZdSupplyBySearchText", method = {RequestMethod.GET})
     public Map<String, Object> getYpZdSupplyBySearchText(@RequestParam("searchText") String searchText) {
         Map<String, Object> resultMap = new HashMap<>();

+ 104 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpBaseMapper.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 药库库存持久化类
@@ -159,4 +160,107 @@ public interface YpBaseMapper {
             "</where>",
             "</script>"})
     int updateYpBase(YpBase ypBase);
+
+    /**
+     * 统计药库的门诊住院药品使用量
+     * @param map
+     * @return
+     */
+    @Select("<script>"+
+            "select code,serial,max(name)name,max(specification)specification,max(retprice)retprice,sum(quantity) quantity,sum(price) price,max(pack_size)packSize,max(manu_code)manuCode from (\n" +
+            "  select a.code,a.serial,max(a.name)name,max(a.specification)specification,max(a.retprice)retprice,sum(c.quantity) quantity,sum(c.quantity*c.unit_price) price,\n" +
+            "  max(a.pack_size) pack_size,max(a.manu_code)manu_code" +
+            "  from mz_charge_detail c WITH(NOLOCK),\n" +
+            "  view_yp_zd_dict a WITH(NOLOCK)\n" +
+            "  where  c.charge_date<![CDATA[>=]]> #{beginDate} and c.charge_date<![CDATA[<=]]> #{endDate} and c.confirm_flag='1' and\n" +
+            "  isnull(a.del_flag,0)<![CDATA[<>]]>1 and isnull(a.visible_flag,0)<![CDATA[<>]]>1 and a.group_no=#{groupNo} and c.charge_item_code=a.code\n" +
+            "  group by a.code,a.serial\n" +
+            "  union all\n" +
+            "  select a.code,a.serial,max(a.name)name,max(a.specification)specification,max(a.retprice)retprice,sum(c.charge_amount) quantity,sum(c.charge_fee) price,\n" +
+            "  max(a.pack_size) pack_size,max(a.manu_code)manu_code" +
+            "  from zy_detail_charge c,\n" +
+            "  view_yp_zd_dict a\n" +
+            "  where  c.charge_date<![CDATA[>=]]> #{beginDate} and c.charge_date<![CDATA[<=]]> #{endDate} and\n" +
+            "  isnull(a.del_flag,0)<![CDATA[<>]]>1 and isnull(a.visible_flag,0)<![CDATA[<>]]>1 and a.group_no=#{groupNo} and c.charge_code_mx=a.code\n" +
+            "  group by  a.code,a.serial) aa\n" +
+            "group by code,serial" +
+            "</script>")
+    List<Map<String,Object>> selectDrugUseQuantityCount(Map map);
+
+    /**
+     * 查询药库的门诊住院未使用药品数据
+     * @param map
+     * @return
+     */
+    @Select("<script>"+
+            "SELECT a.code,\n" +
+            "       a.name,\n" +
+            "       a.retprice as price,\n" +
+            "       a.specification,\n" +
+            "       a.manu_code as manuCode,\n" +
+            "       a.stock_amount as quantity\n" +
+            "FROM view_yp_zd_dict a\n" +
+            "WHERE ( a.code not in (select charge_item_code from yp_mz_fytj where confirm_time<![CDATA[>=]]> #{beginDate} and confirm_time<![CDATA[<=]]> #{endDate} group by charge_item_code) and bill_item_mz in ('010','011'))  AND\n" +
+            "      ( a.code not in (select charge_code from yp_zy_patient where confirm_time<![CDATA[>=]]> #{beginDate} and confirm_time<![CDATA[<=]]> #{endDate} group by charge_code )and bill_item_zy in('001','028')  )\n" +
+            "         and isnull(a.del_flag,0)<![CDATA[<>]]>1 and isnull(a.visible_flag,0)<![CDATA[<>]]>1 and a.group_no=#{groupNo} order by a.stock_amount desc" +
+            "</script>")
+    List<Map<String,Object>> selectDrugUnusedCount(Map map);
+
+    /**
+     * 查询药品出库排名
+     * @param map
+     * @return
+     */
+    @Select("<script>"+
+            "SELECT distinct\n" +
+            "  yp_out_detl.dept_code,\n" +
+            "  yp_out_detl.draw_no,\n" +
+            "  yp_zd_dict.name,\n" +
+            "  yp_zd_dict.specification,\n" +
+            "  yp_out_detl.pack_retprice,\n" +
+            "  sum(yp_out_detl.out_amt) as out_amt,\n" +
+            "  yp_out_detl.dept_code,\n" +
+            "  yp_zd_dict.pack_size,\n" +
+            "  yp_out_detl.buy_price,\n" +
+            "  yp_zd_dict.code,\n" +
+            "  yp_zd_dict.serial,\n" +
+            "  yp_out_detl.out_type,\n" +
+            "  yp_zd_dict.class_code,\n" +
+            "  (yp_zd_dict.drug_kind) as drug_kind,\n" +
+            "  sum(yp_out_detl.buy_price*yp_out_detl.out_amt) as grje,\n" +
+            "  sum(yp_out_detl.pack_retprice*yp_out_detl.out_amt) as lsje\n" +
+            "FROM yp_out_detl,\n" +
+            "     yp_zd_dict,\n" +
+            "     yp_in_detl\n" +
+            "WHERE\n" +
+            "  ( yp_out_detl.charge_code = yp_zd_dict.code ) and\n" +
+            "  ( yp_zd_dict.serial = yp_out_detl.serial ) and\n" +
+            "  ( yp_out_detl.in_draw_no = yp_in_detl.in_docu_no) and\n" +
+            "  ( yp_out_detl.in_seri = yp_in_detl.in_seri) and\n" +
+            "  (out_date <![CDATA[>=]]> #{beginDate} and out_date<![CDATA[<=]]> #{endDate}) \n" +
+            "<when test='classCode != null'>" +
+            " and class_code= #{classCode}" +
+            "</when>" +
+            "<when test='deptCode != null'>" +
+            " and dept_code= #{deptCode}" +
+            "</when>" +
+            "<when test='drugKind != null'>" +
+            " and drug_kind= #{drugKind}" +
+            "</when>" +
+            " group by\n" +
+            "         yp_out_detl.draw_no,\n" +
+            "         yp_zd_dict.name ,\n" +
+            "         yp_zd_dict.specification,\n" +
+            "         yp_out_detl.pack_retprice,\n" +
+            "         yp_out_detl.dept_code,\n" +
+            "         yp_zd_dict.pack_size,\n" +
+            "         yp_out_detl.buy_price,\n" +
+            "         yp_zd_dict.code,\n" +
+            "         yp_zd_dict.serial,\n" +
+            "         yp_out_detl.out_type,\n" +
+            "         yp_zd_dict.class_code,\n" +
+            "         yp_zd_dict.drug_kind\n" +
+            "order by yp_out_detl.out_amt DESC" +
+            "</script>")
+    List<Map<String,Object>> selectDrugOutDetlSort(Map map);
 }

+ 7 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpZdUnitMapper.java

@@ -13,4 +13,11 @@ public interface YpZdUnitMapper {
      */
     @Select("select code,name,py_code from yp_zd_unit where isnull(del_flag,0) =0")
     List<YpZdUnit> selectYpZdUnitAll();
+
+    /**
+     * 查询药品单位
+     * @return
+     */
+    @Select("select name from yp_zd_unit where code = #{code}")
+    String selectNameByCode(String code);
 }

+ 8 - 0
src/main/java/cn/hnthyy/thmz/service/his/yp/YpBaseService.java

@@ -5,6 +5,7 @@ import cn.hnthyy.thmz.entity.his.yp.YpBase;
 import cn.hnthyy.thmz.vo.YpZdDictVo;
 
 import java.util.List;
+import java.util.Map;
 
 public interface YpBaseService {
 
@@ -48,4 +49,11 @@ public interface YpBaseService {
      * @return
      */
     int updateYpBase(YpBase ypBase);
+
+    /**
+     * 统计药库的门诊住院药品使用量排序
+     * @param map
+     * @return
+     */
+    List<Map<String,Object>> queryDrugUseQuantitySort(Map map);
 }

+ 78 - 5
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpBaseServiceImpl.java

@@ -1,9 +1,16 @@
 package cn.hnthyy.thmz.service.impl.his.yp;
 
+import cn.hnthyy.thmz.entity.his.mz.YpZdClass;
 import cn.hnthyy.thmz.entity.his.yp.YpBase;
 import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
+import cn.hnthyy.thmz.entity.his.yp.YpZdDrugKind;
+import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
+import cn.hnthyy.thmz.mapper.his.mz.YpZdClassMapper;
 import cn.hnthyy.thmz.mapper.his.yp.YpBaseMapper;
 import cn.hnthyy.thmz.mapper.his.yp.YpZdDictMapper;
+import cn.hnthyy.thmz.mapper.his.yp.YpZdDrugKindMapper;
+import cn.hnthyy.thmz.mapper.his.yp.YpZdUnitMapper;
+import cn.hnthyy.thmz.mapper.his.zd.ZdUnitCodeMapper;
 import cn.hnthyy.thmz.service.his.yp.YpBaseService;
 import cn.hnthyy.thmz.service.his.yp.YpZdManufactoryService;
 import cn.hnthyy.thmz.vo.YpZdDictVo;
@@ -13,7 +20,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @description:
@@ -31,10 +40,22 @@ public class YpBaseServiceImpl implements YpBaseService {
     @SuppressWarnings("all")
     @Autowired
     YpZdManufactoryService ypZdManufactoryService;
+    @SuppressWarnings("all")
+    @Autowired
+    YpZdClassMapper ypZdClassMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    YpZdUnitMapper ypZdUnitMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    ZdUnitCodeMapper zdUnitCodeMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    YpZdDrugKindMapper ypZdDrugKindMapper;
 
     @Override
     public Double queryStockAmount(String chargeCode, String serial, String groupNo) {
-        return ypBaseMapper.selectStockAmount(chargeCode,serial,groupNo);
+        return ypBaseMapper.selectStockAmount(chargeCode, serial, groupNo);
     }
 
     @Override
@@ -45,12 +66,12 @@ public class YpBaseServiceImpl implements YpBaseService {
     @Override
     public List<YpZdDictVo> queryYpZdBaseByLike(YpZdDictVo ypZdDictVo) {
         YpBase ypBase = new YpBase();
-        BeanUtils.copyProperties(ypZdDictVo,ypBase);
+        BeanUtils.copyProperties(ypZdDictVo, ypBase);
         List<YpBase> ypBases = ypBaseMapper.selectYpBaseByLike(ypZdDictVo.getSearchText().toUpperCase(), ypBase);
-        List<YpZdDictVo> ypZdDictVos= new ArrayList<>();
+        List<YpZdDictVo> ypZdDictVos = new ArrayList<>();
         ypBases.stream().forEach(yp -> {
             YpZdDictVo vo = new YpZdDictVo();
-            BeanUtils.copyProperties(yp,vo);
+            BeanUtils.copyProperties(yp, vo);
             YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(yp.getChargeCode(), yp.getSerial());
             vo.setPzwh(ypZdDict.getPzwh());
             vo.setManuCode(ypZdDict.getManuCode());
@@ -62,7 +83,7 @@ public class YpBaseServiceImpl implements YpBaseService {
             vo.setName(ypZdDict.getName());
             vo.setJbFlag(ypZdDict.getJbFlag());
             vo.setDelFlag(ypZdDict.getDelFlag());
-            if(StringUtils.isNotBlank(ypZdDict.getManuCode())){
+            if (StringUtils.isNotBlank(ypZdDict.getManuCode())) {
                 String manufactoryName = ypZdManufactoryService.queryYpZdManufactoryByCode(ypZdDict.getManuCode());
                 vo.setManufactoryName(manufactoryName);//生产厂家
             }
@@ -80,4 +101,56 @@ public class YpBaseServiceImpl implements YpBaseService {
     public int updateYpBase(YpBase ypBase) {
         return ypBaseMapper.updateYpBase(ypBase);
     }
+
+    @Override
+    public List<Map<String, Object>> queryDrugUseQuantitySort(Map map) {
+        List<Map<String, Object>> list;
+        String flag = map.get("flag").toString();
+        if (flag.equals("0")) {
+            list = ypBaseMapper.selectDrugUseQuantityCount(map);
+        } else if(flag.equals("1")){
+            list = ypBaseMapper.selectDrugUnusedCount(map);
+        }else {
+            list = ypBaseMapper.selectDrugOutDetlSort(map);
+        }
+        for (int i = 0; i < list.size(); i++) {
+            Map<String, Object> mapMax = list.get(i);
+            String manuName="";
+            if(null != mapMax.get("manuCode")){
+                manuName = ypZdManufactoryService.queryYpZdManufactoryByCode(mapMax.get("manuCode").toString());
+            }
+            mapMax.put("manuName", manuName);
+            if (flag.equals("0")) {
+                for (int j = 0; j < list.size(); j++) {
+                    Map<String, Object> mapMin = list.get(j);
+                    if (mapMax.get("serial").toString().equals("99") && mapMax.get("code").equals(mapMin.get("code")) && mapMin.get("serial").toString().equals("01")) {
+                        double packSize = Double.parseDouble(mapMax.get("packSize").toString());
+                        double quantity = Double.parseDouble(mapMin.get("quantity").toString());
+                        mapMax.put("quantity", Double.parseDouble(mapMax.get("quantity").toString()) + (packSize / quantity));
+                        list.remove(j);
+                        i--;
+                        break;
+                    }
+                }
+            }
+            if (flag.equals("2")) {
+                YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(mapMax.get("code").toString(), mapMax.get("serial").toString());
+                mapMax.put("name",ypZdDict.getName());
+                mapMax.put("specification",ypZdDict.getSpecification());
+                List<YpZdClass> ypZdClasses = ypZdClassMapper.selectYpZdClassesByCode(ypZdDict.getClassCode());
+                if(ypZdClasses.size() >0 ){
+                    mapMax.put("class_name",ypZdClasses.get(0).getName());
+                }
+                mapMax.put("unit_name",ypZdUnitMapper.selectNameByCode(ypZdDict.getPackUnit()));
+                ZdUnitCode dept = zdUnitCodeMapper.selectByCode(mapMax.get("dept_code").toString());
+                mapMax.put("dept_name",dept.getName());
+                YpZdDrugKind drugKind = ypZdDrugKindMapper.selectYpZdDrugKind(mapMax.get("drug_kind").toString());
+                mapMax.put("kind_name",drugKind.getName());
+            }
+        }
+        if (map.get("flag").toString().equals("0")) {
+            list.sort(Comparator.comparing(o -> -1 * Double.valueOf(o.get("quantity").toString())));
+        }
+        return list;
+    }
 }

+ 1 - 1
src/main/resources/static/js/yk/drug_sales_return.js

@@ -673,7 +673,7 @@ function initRecordTable() {
 }
 
 function recordTableQueryParams(params) {
-    let rePortRangeArr = getRePortRangeArr();
+    let rePortRangeArr = getRePortRangeArrTime();
     let temp = {
         inDocuNo: $("#inDocuNoTkSearch").val() === '' ? null : $("#inDocuNoTkSearch").val(),
         inType: 1,

+ 201 - 0
src/main/resources/static/js/yk/drug_use_quantity_count.js

@@ -0,0 +1,201 @@
+//@ sourceURL=drug_use_quantity_count.js
+var LODOP; //声明为全局变量
+var groupYk = window.localStorage["groupYk"];
+$(function () {
+    if (groupYk == null) {
+        return errorMesageSimaple('药库参数未设置,请在发药参数设置中设置');
+    }
+    init_daterangepicker();
+    $('#reportrange span').html(moment().subtract(1, 'month').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
+    setTimeout(function () {
+        getLodop();
+    }, 800);
+    initDynamicSelect("queryYpZdClasses", "classCode");
+    initDynamicSelect("queryYpZdDrugKindAll", "drugKind");
+    initDynamicSelect("allUnitCode", 'deptCode');
+    initForm(0);
+    $("#out_detl_table").hide();
+    $(".selectpicker").selectpicker({
+        dropuAuto: false
+    });
+    //初始化页面上面的按钮事件
+    $("#btn_search").click(function (t) {
+        $('.sjh').remove();
+        getRecordData();
+    });
+    $('#btn_clean').click(function () {
+        cleanParams();
+    });
+    $("#btn_daily").click(function (t) {
+        print();
+    });
+    $("#btn_excel").click(function (t) {
+        let statisticalMethod = $("#statisticalMethod").val();
+        let id = "";
+        if (statisticalMethod === "0" || statisticalMethod === "1") {
+            id = 'use_table';
+        } else {
+            id = 'out_detl_table';
+        }
+        $("#" + id).table2excel({
+            exclude: ".exclHide",
+            filename: $("#" + id + " .title").html() + "(" + getRePortRangeArr()[0] + ").xls"
+        })
+    });
+    $("#statisticalMethod").change(function (t, d, e) {
+        let statisticalMethod = $("#statisticalMethod").val();
+        if (statisticalMethod == 0) {
+            $(".title").html('药品使用量统计');
+            $(".sl").html('数量');
+            initForm(0)
+        } else if (statisticalMethod == 1) {
+            $(".title").html('未使用药品统计');
+            $(".sl").html('库存');
+            initForm(0)
+        } else {
+            initForm(1)
+        }
+        $('.sjh').remove();
+        $(".dateRange").html($('#reportrange span').html());
+        $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
+    });
+});
+
+
+/**
+ * 获取汇总药品统计报表
+ */
+function getRecordData() {
+    let statisticalMethod = $('#statisticalMethod').val();
+    let data = {
+        'beginDate': getRePortRangeArrTime()[0],
+        'endDate': getRePortRangeArrTime()[1],
+        'flag': statisticalMethod,
+        'groupNo': groupYk,
+        'deptCode': isEmpty($('#deptCode').val()) ? null : $('#deptCode').val()[0],
+        'drugKind': isEmpty($('#drugKind').val()) ? null : $('#drugKind').val()[0],
+        'classCode': isEmpty($('#classCode').val()) ? null : $('#classCode').val()[0]
+    };
+    $('#YWaitDialog').css('top', $('.xtd').offset().top);
+    $('#YWaitDialog').show();
+    $(".dateRange").html($('#reportrange span').html());
+    $(".groupName").html(getGroupName(groupYk));
+    $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
+    request({
+        url: '/getDrugUseQuantitySort',
+        method: 'POST',
+        data: JSON.stringify(data)
+    }).then((res) => {
+        console.log(res);
+        let html = '';
+        let totalPackRetpriceSum = 0;
+        let totalBuyPriceSum = 0;
+        let totalAmount = 0;
+        for (var i = 0; i < res.data.length; i++) {
+            let data = res.data[i];
+            let packRetpriceSum = isEmpty(data.price) ? 0 : keepTwoDecimal(data.price);
+            if (statisticalMethod == 2) {
+                packRetpriceSum = isEmpty(data.lsje) ? 0 : keepTwoDecimal(data.lsje);
+                let buyPriceSum = isEmpty(data.grje) ? 0 : keepTwoDecimal(data.grje);
+                html += '<tr class="sjh">';
+                html += '<td class="xtd" style="text-align: center;">' + (i + 1) + '</td>';
+                html += '<td class="xtd" style="text-align: left;">' + data.name + '</td>';
+                html += '<td class="xtd" style="text-align: left;">' + data.kind_name + '</td>';
+                html += '<td class="xtd" style="text-align: left;">' + data.class_name + '</td>';
+                html += '<td class="xtd" style="text-align: center;">' + data.specification + '</td>';
+                html += '<td class="xtd" style="text-align: right;">' + packRetpriceSum + '</td>';
+                html += '<td class="xtd" style="text-align: right;">' + buyPriceSum + '</td>';
+                html += '<td class="xtd" style="text-align: center;">' + data.out_amt + '</td>';
+                html += '<td class="xtd" style="text-align: center;">' + data.dept_name + '</td>';
+                html += '</tr>';
+                totalPackRetpriceSum += packRetpriceSum;
+                totalBuyPriceSum += buyPriceSum;
+            } else {
+                html += '<tr class="sjh">';
+                html += '<td class="xtd" style="text-align: center;">' + (i + 1) + '</td>';
+                html += '<td class="xtd" style="text-align: center;">' + data.code + '</td>';
+                html += '<td class="xtd" style="text-align: left;">' + data.name + '</td>';
+                html += '<td class="xtd" style="text-align: center;">' + data.specification + '</td>';
+                html += '<td class="xtd" style="text-align: right;">' + packRetpriceSum + '</td>';
+                html += '<td class="xtd" style="text-align: center;">' + keepTwoDecimal(data.quantity) + '</td>';
+                html += '<td class="xtd" style="text-align: right;">' + keepTwoDecimal(data.quantity * packRetpriceSum) + '</td>';
+                html += '<td class="xtd" style="text-align: left;">' + data.manuName + '</td>';
+                html += '</tr>';
+                totalPackRetpriceSum += packRetpriceSum;
+                totalAmount += data.quantity;
+            }
+        }
+        if (statisticalMethod == 0) {
+            html += '<tr class="sjh">';
+            html += '<td colspan="5" style="text-align: center;font-weight: 700;">合计</td>';
+            html += '<td style="text-align: left;font-weight: 700;">' + totalAmount + '</td>';
+            html += '<td colspan="3" style="text-align: left;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum) + '</td>';
+            html += '</tr>';
+        } else if (statisticalMethod == 2) {
+            html += '<tr class="sjh">';
+            html += '<td colspan="5" style="text-align: center;font-weight: 700;">合计</td>';
+            html += '<td style="text-align: left;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum) + '</td>';
+            html += '<td colspan="3" style="text-align: left;font-weight: 700;">' + keepTwoDecimal(totalBuyPriceSum) + '</td>';
+            html += '</tr>';
+        }
+        if (statisticalMethod == 2) {
+            $("#out_detl_table").append(html);
+        } else {
+            $("#use_table").append(html);
+        }
+        successMesage(res);
+        $('#YWaitDialog').hide();
+    }, err => {
+        $('#YWaitDialog').hide();
+    });
+}
+
+/**
+ * 清空查询条件
+ */
+function cleanParams() {
+    $("#statisticalMethod").val(0);
+    $("select").selectpicker('refresh');
+    $('#reportrange span').html(moment().subtract(1, 'month').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
+    $('.sjh').remove();
+}
+
+/**
+ * 打印报表
+ */
+function print() {
+    setDefaultPrint();
+    LODOP = getLodop();
+    LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
+    LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "药品使用情况统计表");
+    LODOP.ADD_PRINT_TEXT('288mm', '100mm', '40mm', '40mm', '第#页/共&页');
+    //设置默认打印机
+    LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
+    LODOP.SET_PRINT_STYLE("FontSize", 10); //字体大小
+    LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
+    var strStyle = "<style>table,td,th {border-width: 1px;" +
+        "border-style: solid;border-collapse: collapse;table-layout:fixed;word-wrap:break-word;font-size: 14px}</style>";
+    LODOP.ADD_PRINT_HTM("2mm", "4mm", "RightMargin:4mm", "BottomMargin:15mm", strStyle + document.getElementById("report_table_1").innerHTML);
+    LODOP.PRINT();
+    //LODOP.PREVIEW();
+}
+
+function initForm(flag) {
+    if (flag == 0) {
+        $("#classCode").val(null);
+        $("#drugKind").val(null);
+        $("#deptCode").val(null);
+        $("#classCode").attr("disabled", "disabled");
+        $("#drugKind").attr("disabled", "disabled");
+        $("#deptCode").attr("disabled", "disabled");
+        $("#use_table").show();
+        $("#out_detl_table").hide();
+    } else {
+        $("#classCode").attr("disabled", false);
+        $("#drugKind").attr("disabled", false);
+        $("#deptCode").attr("disabled", false);
+        $("#use_table").hide();
+        $("#out_detl_table").show();
+    }
+    $("select").selectpicker('refresh');
+}

+ 169 - 0
src/main/resources/templates/yk/drug_use_quantity_count.html

@@ -0,0 +1,169 @@
+<link rel="stylesheet" href="/thmz/css/bootstrap/css/bootstrap-select.css"/>
+<link rel="stylesheet" href="/thmz/css/bootstrap/css/daterangepicker.css"/>
+<link rel="stylesheet" href="/thmz/css/custom.min.css">
+<link rel="stylesheet" href="/thmz/css/toll_administration.css">
+<link rel="stylesheet" href="/thmz/css/jquery.webui-popover.min.css">
+<script src="/thmz/js/dependent/bootstrap-select.js"></script>
+<script src="/thmz/js/dependent/daterangepicker.js"></script>
+<script src="/thmz/js/common/date-util.js"></script>
+<script src="/thmz/js/dependent/jquery.webui-popover.min.js"></script>
+<script src="/thmz/js/common/pharmacy-com.js"></script>
+<script src="/thmz/js/yk/drug_use_quantity_count.js"></script>
+<script src="/thmz/js/dependent/jquery.table2excel.min.js"></script>
+<script src="/thmz/js/dependent/LodopFuncs.js"></script>
+<title>药品使用量统计分析</title>
+<!-- 打印的样式-->
+<style media="print">
+    @page {
+        size: auto;
+        margin: 0mm;
+    }
+</style>
+<div class="row" style="height: calc(100% - 00px);">
+    <div class="col-md-12 col-sm-12 col-xs-12" style="height: 100%">
+        <div class="x_panel" style="height: 100%">
+            <div class="panel-body">
+                <form id="formSearch" class="form-horizontal" autocomplete="off">
+                    <div class="form-group col-md-12 col-sm-12 col-xs-12">
+                        <div class="col-md-2 col-sm-2 col-xs-12 item">
+                            <label class="control-label col-md-4 col-sm-4 col-xs-12"
+                                   for="classCode">药性</label>
+                            <div class="col-md-8 col-sm-8 col-xs-12">
+                                <select class="form-control selectpicker show-tick" title="请选择" data-live-search="true"  multiple data-max-options="1"
+                                        id="classCode" name="classCode">
+                                </select>
+                            </div>
+                        </div>
+                        <div class="col-md-2 col-sm-2 col-xs-12 item">
+                            <label class="control-label col-md-4 col-sm-4 col-xs-12" for="drugKind">药品类别
+                            </label>
+                            <div class="col-md-8 col-sm-8 col-xs-12">
+                                <select class="form-control selectpicker show-tick" data-live-search="true" title="请选择"
+                                        multiple
+                                        data-max-options="1"
+                                        id="drugKind">
+                                </select>
+                            </div>
+                        </div>
+                        <div class="col-md-2 col-sm-2 col-xs-12">
+                            <label class="control-label col-md-4 col-sm-4 col-xs-12" for="deptCode">科室
+                            </label>
+                            <div class="col-md-8 col-sm-8 col-xs-12">
+                                <select class="form-control selectpicker show-tick" data-live-search="true" title="请选择"
+                                        multiple
+                                        data-max-options="1"
+                                        id="deptCode">
+                                </select>
+                            </div>
+                        </div>
+                        <div class="col-md-2 col-sm-2 col-xs-12">
+                            <label class="control-label col-md-5 col-sm-5 col-xs-12"
+                                   for="statisticalMethod">统计方式</label>
+                            <div class="col-md-7 col-sm-7 col-xs-12">
+                                <select class="form-control selectpicker show-tick" title="请选择"
+                                        id="statisticalMethod">
+                                    <option value="0" selected>使用情况统计</option>
+                                    <option value="1">未使用药品统计</option>
+                                    <option value="2">出库科室药品统计</option>
+                                </select>
+                            </div>
+                        </div>
+                        <label class="control-label col-md-1 col-sm-1 col-xs-12" for="reportrange"
+                               style="width: 105px;">
+                            日期范围
+                        </label>
+                        <div class="col-md-3 col-sm-3 col-xs-12 " style="width: 325px;">
+                            <div id="reportrange" class="pull-left"
+                                 style="background: #fff; cursor: pointer; padding: 6.5px 10px; border: 1px solid #ccc">
+                                <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
+                                <span>December 30, 2014 - January 28, 2015</span> <b class="caret"></b>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="form-group col-md-12 col-sm-12 col-xs-12">
+                        <div class="col-md-1 col-sm-1 col-xs-12"></div>
+                        <button type="button" id="btn_search" class="btn btn-primary"
+                                title="查询"><i class="glyphicon glyphicon-search"></i>
+                        </button>
+                        <button type="button"  id="btn_clean" class="btn btn-primary"
+                                title="重置"><i class="fa fa-rotate-left"></i>
+                        </button>
+                        <button type="button" id="btn_daily" class="btn btn-primary"
+                                title="打印"><i class="fa fa-print"></i>
+                        </button>
+                        <button id="btn_excel" class="btn btn-primary"
+                           title="导出Excel"><i class="fa fa-file-excel-o"></i>
+                        </button>
+                    </div>
+                </form>
+            </div>
+            <div id="report_table"
+                 style="width:920px;height: calc(100% - 160px);margin:0 auto;border: 1px solid #337ab7;font-size: 14px;padding: 40px 10px 40px 10px;overflow: scroll">
+                <div id="report_table_1">
+                    <table id="use_table" class="table table-striped table-bordered" style="margin-top: 0px;border: 0px;">
+                        <tr style="font-weight: 700;background-color: #EBEBE4">
+                            <td colspan="8" style="font-size: 21px;text-align: center;border: transparent !important;"><span class="title">药品使用量统计</span><br>&nbsp;</td>
+                        </tr>
+                        <tr style="font-weight: 700;background-color: #EBEBE4">
+                            <td colspan="3" style="text-align: left;border: transparent !important;">统计日期:<span class="dateRange"></span></td>
+                            <td colspan="2" style="text-align: right;border: transparent !important;">库房名称:<span class="groupName"></span></td>
+                            <td colspan="3" style="text-align: right;border: transparent !important;">打印日期:<span class="printDate"></span></td>
+                        </tr>
+                        <tr>
+                            <td class="xtd " style="text-align: center;width: 50px;">序号</td>
+                            <td class="xtd" style="text-align: center;width: 80px;">编码</td>
+                            <td class="xtd" style="text-align: center;width: 150px;">药品名称</td>
+                            <td class="xtd" style="text-align: center;width: 100px;">药品规格</td>
+                            <td class="xtd" style="text-align: center;width: 100px;">零售价</td>
+                            <td class="xtd sl" style="text-align: center;width: 80px;">数量</td>
+                            <td class="xtd" style="text-align: center;width: 100px;">总金额</td>
+                            <td class="xtd" style="text-align: center;width: 150px;">生产厂家</td>
+                        </tr>
+                    </table>
+                    <table id="out_detl_table" class="table table-striped table-bordered" style="margin-top: 0px;border: 0px;">
+                        <tr style="font-weight: 700;background-color: #EBEBE4">
+                            <td colspan="9" style="font-size: 21px;text-align: center;border: transparent !important;"><span class="title">出库科室药品排名</span><br>&nbsp;</td>
+                        </tr>
+                        <tr style="font-weight: 700;background-color: #EBEBE4">
+                            <td colspan="3" style="text-align: left;border: transparent !important;">统计日期:<span class="dateRange"></span></td>
+                            <td colspan="2" style="text-align: right;border: transparent !important;">库房名称:<span class="groupName"></span></td>
+                            <td colspan="4" style="text-align: right;border: transparent !important;">打印日期:<span class="printDate"></span></td>
+                        </tr>
+                        <tr>
+                            <td class="xtd" style="text-align: center;width: 50px;">序号</td>
+                            <td class="xtd" style="text-align: center;width: 150px;">药品名称</td>
+                            <td class="xtd" style="text-align: center;width: 80px;">大类</td>
+                            <td class="xtd" style="text-align: center;width: 140px;">药性</td>
+                            <td class="xtd" style="text-align: center;width: 100px;">药品规格</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">零售价</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">购入价</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">出库量</td>
+                            <td class="xtd" style="text-align: center;width: 80px;">科室</td>
+                        </tr>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<!--加载中提示开始-->
+<div id="YWaitDialog"
+     style="
+    position: absolute;
+    margin: auto;
+    display: none;
+    top: 0px;
+    left: 0px;
+    right: 0px;
+    bottom: 0px;
+    height: 60px;
+    width: 300px;">
+    <p style="text-align: center; vertical-align: central;">
+        请等待,正在查询数据<i class="fa fa-spinner fa-spin fa-2x fa-fw"></i>
+    </p>
+</div>
+<!--加载中提示结尾-->
+<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
+    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
+</object>
+