Browse Source

科室药品维护增加药品专用标记

WANGJIALIANG 3 years ago
parent
commit
7678dfe237

+ 0 - 1
src/main/java/cn/hnthyy/thmz/controller/mz/MzPharmacyController.java

@@ -850,7 +850,6 @@ public class MzPharmacyController {
                 mzSendMedicineVo.setComm(mzOrderFrequencyByCode.getComm());
             }
             dispensingSocketService.printSendToMedicine(mzChargeDetail.getPatientId());
-            dispensingSocketService.callNumberSendToMedicine(mzChargeDetail.getPatientId());
             resultMap.put("code", 0);
             resultMap.put("message", "打印成功");
             resultMap.put("data", cfxxList);

+ 8 - 4
src/main/java/cn/hnthyy/thmz/controller/yf/YfYpZdDeptController.java

@@ -55,9 +55,9 @@ public class YfYpZdDeptController {
      * @return
      */
     @UserLoginToken
-    @RequestMapping(value = "/getYpZdDept",method = {RequestMethod.GET,RequestMethod.POST})
-    public Map<String,Object> getYpZdDept(@RequestParam(value = "groupNo") Integer groupNo,@RequestParam(value = "deptCode") String deptCode
-            ,@RequestParam(value = "searchText",required = false) String searchText){
+    @RequestMapping(value = "/getYpZdDeptPage",method = {RequestMethod.GET,RequestMethod.POST})
+    public Map<String,Object> getYpZdDeptPage(@RequestParam(value = "groupNo") Integer groupNo,@RequestParam(value = "deptCode") String deptCode
+            ,@RequestParam(value = "searchText",required = false) String searchText,@RequestParam(value = "page") Integer page,@RequestParam(value = "rows") Integer rows){
         Map<String, Object> resultMap = new HashMap<>();
         try {
             if(StringUtils.isEmpty(groupNo) || StringUtils.isEmpty(deptCode)){
@@ -68,10 +68,14 @@ public class YfYpZdDeptController {
             if(searchText.matches("[a-zA-Z]+")){
                 searchText = searchText.toUpperCase();
             }
-            List<YpZdDept> ypZdDepts = ypZdDeptService.queryYpZdDept(deptCode, groupNo,searchText);
+            List<YpZdDept> ypZdDepts = ypZdDeptService.queryYpZdDeptPage(deptCode, groupNo,searchText,page,rows);
+            int count = ypZdDeptService.queryYpZdDeptCount(groupNo, searchText);
             resultMap.put("code", 0);
             resultMap.put("message", "查询住院科室药品停用信息成功");
             resultMap.put("data", ypZdDepts);
+            resultMap.put("totalPages", Math.ceil((double)count/rows));
+            resultMap.put("page", page);
+            resultMap.put("totalCount", count);
             return resultMap;
         } catch (Exception e) {
             resultMap.put("code", -1);

+ 4 - 0
src/main/java/cn/hnthyy/thmz/entity/his/YpZdDept.java

@@ -27,4 +27,8 @@ public class YpZdDept {
 	 */
 	private String name;
 
+	/**
+	 * 专用标记 1:是
+	 */
+	private String exclusiveUseFlag;
 }

+ 61 - 5
src/main/java/cn/hnthyy/thmz/mapper/his/YpZdDeptMapper.java

@@ -22,25 +22,81 @@ public interface YpZdDeptMapper {
     int insertYpZdDept(YpZdDept ypZdDept);
 
     /**
-     * 查询科室所有药品停用信息
+     * 科室专用药品,其它科室全部停用
+     * @param ypZdDept
+     * @return
+     */
+    @Insert("insert into yp_zd_dept (dept_code,charge_code,use_flag)" +
+            " SELECT  dept_code,#{chargeCode},'1' FROM zy_adtward where dept_code!=#{deptCode}")
+    int insertExclusiveYpZdDept(YpZdDept ypZdDept);
+
+    /**
+     * 分页查询科室药品停用信息
      * @param deptCode
+     * @param groupNo
+     * @param searchText
+     * @param page
+     * @param rows
      * @return
      */
-    @Select("SELECT distinct use_flag=isnull(c.use_flag,'0')," +
+    @Select("<script>" +
+            " select top ${rows} *" +
+            " from (select ROW_NUMBER() over (order by isnull(c.use_flag,'0') desc) as RowNumber," +
+            " use_flag=isnull(c.use_flag,'0')," +
             "                         a.code as charge_code," +
             "                         a.name" +
             " FROM yp_zd_dict  a,yp_base_yf b,yp_zd_dept c" +
             " where a.code=b.charge_code and" +
             "      a.code *=c.charge_code and" +
             "               b.group_no=#{groupNo} and" +
-            "               c.dept_code=#{deptCode} and (py_code like '%${searchText}%' or a.name like '%${searchText}%' or a.code like '%${searchText}%') order by use_flag desc ")
-    List<YpZdDept> selectYpZdDept(@Param("deptCode") String deptCode,@Param("groupNo") Integer groupNo,@Param("searchText") String searchText);
+            "               c.dept_code=#{deptCode} and (py_code like '%${searchText}%' or a.name like '%${searchText}%' or a.code like '%${searchText}%') " +
+            " group by a.code,name,use_flag)AS A WHERE RowNumber >${rows}*${page-1} order by RowNumber asc" +
+            "</script>")
+    List<YpZdDept> selectYpZdDeptPage(@Param("deptCode") String deptCode, @Param("groupNo") Integer groupNo, @Param("searchText") String searchText, @Param("page") Integer page, @Param("rows") Integer rows);
+
+    /**
+     * 查询药房所有药品总数
+     * @param groupNo
+     * @param searchText
+     * @return
+     */
+    @Select("select count(1) from (SELECT distinct" +
+            "                         a.code," +
+            "                         a.name" +
+            " FROM yp_zd_dict  a,yp_base_yf b" +
+            " where a.code=b.charge_code and" +
+            "               b.group_no=#{groupNo}" +
+            "               and (py_code like '%${searchText}%' or a.name like '%${searchText}%' or a.code like '%${searchText}%')) count_tab")
+    int selectYpZdDeptCount(@Param("groupNo") Integer groupNo,@Param("searchText") String searchText);
+
+    /**
+     * 查询药品是否为科室专用
+     * @param deptCode
+     * @return
+     */
+    @Select("<script>" +
+            "select (case" +
+            "        when sum(1)=(SELECT  sum(1) as number FROM zy_adtward)-1" +
+            "        then (select case when sum(1)<![CDATA[>]]>0 then 0 else 1 end from yp_zd_dept where charge_code=#{chargeCode} and dept_code=#{deptCode})" +
+            "        else '0'" +
+            "        end) as exclusive_use_flag" +
+            " from yp_zd_dept  where charge_code = #{chargeCode}" +
+            "</script>")
+    int selectExclusiveYpZdDept(@Param("deptCode") String deptCode,@Param("chargeCode") String chargeCode);
 
     /**
      * 删除科室药品停用信息
      * @param deptCode
      * @return
      */
-    @Delete("delete from yp_zd_dept where dept_code =#{deptCode} and charge_code =#{chargeCode} ")
+    @Delete("<script>" +
+            "delete from yp_zd_dept where 1=1 " +
+            "<when test='deptCode!=null'>"+
+            " and dept_code=#{deptCode,jdbcType=VARCHAR}"+
+            "</when>"+
+            "<when test='chargeCode!=null'>"+
+            " and charge_code=#{chargeCode,jdbcType=VARCHAR}"+
+            "</when>"+
+            "</script> ")
     int deleteYpZdDept(@Param("deptCode") String deptCode, @Param("chargeCode") String chargeCode);
 }

+ 9 - 2
src/main/java/cn/hnthyy/thmz/service/his/YpZdDeptService.java

@@ -19,10 +19,17 @@ public interface YpZdDeptService {
     int modifYpZdDept(YpZdDept ypZdDept);
 
     /**
-     * 查询科室所有药品停用信息
+     * 分页查询科室所有药品停用信息
      * @param deptCode
      * @return
      */
-    List<YpZdDept> queryYpZdDept(String deptCode, Integer groupNo, String searchText);
+    List<YpZdDept> queryYpZdDeptPage(String deptCode, Integer groupNo, String searchText,Integer page,Integer rows);
 
+    /**
+     * 查询药房所有药品总数
+     * @param groupNo
+     * @param searchText
+     * @return
+     */
+    int queryYpZdDeptCount(Integer groupNo,String searchText);
 }

+ 36 - 5
src/main/java/cn/hnthyy/thmz/service/impl/his/YpZdDeptServiceImpl.java

@@ -6,6 +6,9 @@ import cn.hnthyy.thmz.service.his.YpZdDeptService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -16,15 +19,43 @@ public class YpZdDeptServiceImpl implements YpZdDeptService {
     YpZdDeptMapper ypZdDeptMapper;
 
     @Override
+    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     public int modifYpZdDept(YpZdDept ypZdDept) {
-        if(ypZdDept.getUseFlag().equals("0") || StringUtils.isBlank(ypZdDept.getUseFlag())){
-            return ypZdDeptMapper.deleteYpZdDept(ypZdDept.getDeptCode(), ypZdDept.getChargeCode());
+        int i = 0;
+        if(StringUtils.isNotBlank(ypZdDept.getUseFlag())){
+            if(ypZdDept.getUseFlag().equals("0")){
+                i = ypZdDeptMapper.deleteYpZdDept(ypZdDept.getDeptCode(), ypZdDept.getChargeCode());
+            }else if(ypZdDept.getUseFlag().equals("1")){
+                i = ypZdDeptMapper.insertYpZdDept(ypZdDept);
+            }
+        }else if(StringUtils.isNotBlank(ypZdDept.getExclusiveUseFlag())){
+            i = ypZdDeptMapper.deleteYpZdDept(null, ypZdDept.getChargeCode());
+            if(ypZdDept.getExclusiveUseFlag().equals("1")){
+                i = ypZdDeptMapper.insertExclusiveYpZdDept(ypZdDept);
+            }
         }
-        return ypZdDeptMapper.insertYpZdDept(ypZdDept);
+        return i;
     }
 
     @Override
-    public List<YpZdDept> queryYpZdDept(String deptCode, Integer groupNo, String searchText) {
-        return ypZdDeptMapper.selectYpZdDept(deptCode, groupNo, searchText);
+    public List<YpZdDept> queryYpZdDeptPage(String deptCode, Integer groupNo, String searchText,Integer page,Integer rows) {
+        List<YpZdDept> ypZdDepts = ypZdDeptMapper.selectYpZdDeptPage(deptCode, groupNo, searchText,page,rows);
+        for (int i = 0; i < ypZdDepts.size(); i++) {
+            YpZdDept ypZdDept = ypZdDepts.get(i);
+            int exclusiveUseFlag = ypZdDeptMapper.selectExclusiveYpZdDept(deptCode, ypZdDept.getChargeCode());
+            if(exclusiveUseFlag == 1){
+                ypZdDepts.remove(i);
+                ypZdDept.setExclusiveUseFlag("1");
+                ypZdDepts.add(0,ypZdDept);
+            }else{
+                ypZdDept.setExclusiveUseFlag("0");
+            }
+        }
+        return ypZdDepts;
+    }
+
+    @Override
+    public int queryYpZdDeptCount(Integer groupNo, String searchText) {
+        return ypZdDeptMapper.selectYpZdDeptCount(groupNo, searchText);
     }
 }

+ 23 - 15
src/main/resources/static/js/common/socket-com.js

@@ -1,6 +1,7 @@
 //# sourceURL=socket-com.js
 var prescriptionPrintWebsocket = null;
 var lockReconnect = false; //避免ws重复连接
+var lastPatient = '';
 function openSocket(type) {
 //判断当前浏览器是否支持WebSocket
     try {
@@ -112,21 +113,9 @@ function cellNumberMessage(data){
         currentListClear(data);
         pastListClear(data);
         if(data.type == 'JH'){
-            //生成语音
-            $.ajax({
-                type: "GET",
-                url: 'http://webhis.thyy.cn:8706/voice/textToSpeech?text='+"请"+data.name+"到四号窗口取药",
-                contentType: "application/json;charset=UTF-8",
-                dataType: "json",
-                headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
-                success: function (res) {
-                    if (res.code == 200) {
-                        //播放后台生成的叫号语音
-                        var mp3 = new Audio(res.data);
-                        mp3.play();
-                    }
-                }
-            });
+            call(data);
+        }else if(data.type == 'DY' && !(lastPatient == data.patient_id)){
+            call(data);
         }
     } else if (data.type == 'FY') {//来自发药处理后的消息
         //将该用户叫号列表清除
@@ -137,4 +126,23 @@ function cellNumberMessage(data){
         currentListClear(data);
         pastListClear(data);
     }
+}
+
+function call(data) {
+    //生成语音
+    $.ajax({
+        type: "GET",
+        url: 'http://webhis.thyy.cn:8706/voice/textToSpeech?text='+"请"+data.name+"到四号窗口取药",
+        contentType: "application/json;charset=UTF-8",
+        dataType: "json",
+        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+        success: function (res) {
+            if (res.code == 200) {
+                //播放后台生成的叫号语音
+                var mp3 = new Audio(res.data);
+                mp3.play();
+                lastPatient = data.patient_id
+            }
+        }
+    });
 }

+ 9 - 6
src/main/resources/static/js/yf/yf_yp_zd_dept.js

@@ -84,7 +84,7 @@ function initYpZdDept() {
     $("#tb_table_yp").jqGrid({
         datatype: 'json',
         mtype: 'get',
-        url: '/thmz/getYpZdDept',
+        url: '/thmz/getYpZdDeptPage',
         loadBeforeSend: function (jqXHR) {
             jqXHR.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem("token"));
             jqXHR.setRequestHeader("Accept", 'application/json');
@@ -99,21 +99,24 @@ function initYpZdDept() {
         height:  screen.height*0.6,
         viewrecords: true,
         autowidth: true,
-        rowNum: -1,//取消分页
+        rowNum: 20,
+        rowList: [20, 30, 50],
+        pager: 'pager',
         caption: '药品',
         cellEdit: true,
         sortable: true,
-        loadonce:true, //一次加载全部数据到客户端,由客户端进行排序。
         cellsubmit: "remote",
         cellurl: '/thmz/modifYpZdDept',
-        colNames: ['停用标记','药品编号','药品名称'],
+        colNames: ['停用标记','专用标记','药品编号','药品名称'],
         colModel: [
             {name: 'useFlag', index: 'useFlag',align:'center',width:30,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
+            {name: 'exclusiveUseFlag', index: 'exclusiveUseFlag',align:'center',width:30,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
             {name: 'chargeCode', index: 'chargeCode',align:'center',width:30},
             {name: 'name', index: 'name',align:'left',width:100,edittype:'text'}
         ],
         jsonReader: {
-            root: "data", repeatitems: false
+            root: "data", page: "page", total: "totalPages",
+            records: "totalCount", repeatitems: false
         },
         beforeSubmitCell:function(rowid, cellname, value, iRow, iCol){
             let record = $("#tb_table_yp").getRowData(rowid);
@@ -130,8 +133,8 @@ function initYpZdDept() {
                 window.location.href = '/thmz/login/view';
                 return;
             }
+            initYpZdDept();
             if (res.code == 0) {
-                initYpZdDept();
                 successMesage(res);
             }else if (res.code == -1) {
                 errorMesage(res);

+ 1 - 0
src/main/resources/templates/yf/yf_yp_zd_dept.html

@@ -28,6 +28,7 @@
                 </div>
                 <div class="col-md-9 col-sm-9 col-xs-12">
                     <table id="tb_table_yp"></table>
+                    <div id="pager"></div>
                 </div>
             </div>
         </div>