浏览代码

药品和检查检验菜单树后台开发

hurugang 4 年之前
父节点
当前提交
be430bbfbe

+ 276 - 0
src/main/java/cn/hnthyy/thmz/controller/mz/YpZdClassController.java

@@ -0,0 +1,276 @@
+package cn.hnthyy.thmz.controller.mz;
+
+import cn.hnthyy.thmz.comment.UserLoginToken;
+import cn.hnthyy.thmz.entity.his.mz.YpZdClass;
+import cn.hnthyy.thmz.service.his.mz.*;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+@Slf4j
+@RestController
+public class YpZdClassController {
+    @Autowired
+    private YpZdClassService ypZdClassService;
+
+    /**
+     * 查询所有药品、检验、检查的分类
+     *
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/getYpZdClasses", method = {RequestMethod.GET})
+    public Map<String, Object> getYpZdClasses() {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            List<YpZdClass> ypZdClasses = ypZdClassService.queryYpZdClasses();
+            List<Map<String, Object>> treeList = null;
+            if (ypZdClasses == null || ypZdClasses.size() == 0) {
+                log.info("未查询到药品分类");
+            } else {
+                treeList = getYpZdClassTreeList(ypZdClasses);
+            }
+
+            List<Map<String, Object>> jyZdClasses = ypZdClassService.queryJyZdClasses();
+            List<Map<String, Object>> jyTreeList = null;
+            if (ypZdClasses == null || ypZdClasses.size() == 0) {
+                log.info("未查询到检验分类");
+            } else {
+                jyTreeList = getJyZdClassTreeList(jyZdClasses);
+            }
+
+            List<Map<String, Object>> jcZdClasses = ypZdClassService.queryJcZdClasses();
+            List<Map<String, Object>> jcTreeList = null;
+            if (jcZdClasses == null || jcZdClasses.size() == 0) {
+                log.info("未查询到检查分类");
+            } else {
+                jcTreeList = getJcZdClassTreeList(jcZdClasses);
+            }
+            List<Map<String, Object>> fullTree = new ArrayList<>();
+            if(treeList!=null){
+                Map<String, Object> parentMap = new HashMap<>();
+                fullTree.add(parentMap);
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                parentMap.put("isParent", true);
+                parentMap.put("id", 1);
+                parentMap.put("name", "西成药");
+                parentMap.put("children", treeList);
+            }
+            if(jyTreeList!=null){
+                Map<String, Object> parentMap = new HashMap<>();
+                fullTree.add(parentMap);
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                parentMap.put("isParent", true);
+                parentMap.put("id", 2);
+                parentMap.put("name", "检验项目");
+                parentMap.put("children", jyTreeList);
+            }
+            if(jcTreeList!=null){
+                Map<String, Object> parentMap = new HashMap<>();
+                fullTree.add(parentMap);
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                parentMap.put("isParent", true);
+                parentMap.put("id", 3);
+                parentMap.put("name", "检查项目");
+                parentMap.put("children", jcTreeList);
+            }
+            resultMap.put("code", 0);
+            resultMap.put("message", "查询所有的分类成功");
+            resultMap.put("data", fullTree);
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("查询所有药品、检验、检查的分类失败,错误信息{}", e.getMessage());
+            resultMap.put("code", -1);
+            resultMap.put("message", "查询所有药品、检验、检查的分类失败,错误原因【" + e.getMessage() + "】");
+            return resultMap;
+        }
+    }
+
+    /**
+     * 获取药品字典树
+     *
+     * @param ypZdClasses
+     * @return
+     */
+    private List<Map<String, Object>> getYpZdClassTreeList(List<YpZdClass> ypZdClasses) {
+        List<Map<String, Object>> treeList = new ArrayList<>();
+        //当前一级父节点
+        Map<String, Object> grandParentMap = null;
+        //当前二级父节点
+        Map<String, Object> parentMap = null;
+        for (YpZdClass ypZdClass : ypZdClasses) {
+            if (ypZdClass.getCode().endsWith("0000")) {
+                grandParentMap = new HashMap<>();
+                treeList.add(grandParentMap);
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                grandParentMap.put("isParent", false);
+                grandParentMap.put("id", ypZdClass.getCode());
+                grandParentMap.put("name", ypZdClass.getName());
+            } else if (ypZdClass.getCode().endsWith("00")) {
+                //此时已经有子节点,设置成父节点
+                grandParentMap.put("isParent", true);
+                Map<String, Object> temMap = new HashMap<>();
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                temMap.put("isParent", false);
+                temMap.put("id", ypZdClass.getCode());
+                temMap.put("name", ypZdClass.getName());
+                List<Map<String, Object>> children = (List<Map<String, Object>>) grandParentMap.get("children");
+                if (children == null) {
+                    children = new ArrayList<>();
+                    grandParentMap.put("children", children);
+                }
+                children.add(temMap);
+                parentMap = temMap;
+            } else {
+                parentMap.put("isParent", true);
+                Map<String, Object> temMap = new HashMap<>();
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                temMap.put("isParent", false);
+                temMap.put("id", ypZdClass.getCode());
+                temMap.put("name", ypZdClass.getName());
+                List<Map<String, Object>> children = (List<Map<String, Object>>) parentMap.get("children");
+                if (children == null) {
+                    children = new ArrayList<>();
+                    parentMap.put("children", children);
+                }
+                children.add(temMap);
+            }
+        }
+        return treeList;
+    }
+
+
+    /**
+     * 获取所有检验分类字典树
+     *
+     * @param jyZdClasses
+     * @return
+     */
+    private List<Map<String, Object>> getJyZdClassTreeList(List<Map<String, Object>> jyZdClasses) {
+        List<Map<String, Object>> treeList = new ArrayList<>();
+        //父节点
+        Map<String, Object> parentMap = null;
+        //上一条数据的父编码
+        String prevDlCode = null;
+        for (Map<String, Object> jyZdClass : jyZdClasses) {
+            String xlCode = (String) jyZdClass.get("xl_code");
+            if(StringUtils.isBlank(xlCode)){
+                continue;
+            }
+            String dlCode = (String) jyZdClass.get("dl_code");
+            String dlName = (String) jyZdClass.get("dl_name");
+            String xlName = (String) jyZdClass.get("xl_name");
+            if(prevDlCode==null || !prevDlCode.equals(dlCode)){
+                parentMap = new HashMap<>();
+                treeList.add(parentMap);
+                parentMap.put("isParent", true);
+                parentMap.put("id", dlCode);
+                parentMap.put("name", dlName);
+                List<Map<String, Object>> children = new ArrayList<>();
+                parentMap.put("children", children);
+                Map<String, Object> temMap = new HashMap<>();
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                temMap.put("isParent", false);
+                temMap.put("id", xlCode);
+                temMap.put("name", xlName);
+                children.add(temMap);
+            }else {
+                List<Map<String, Object>> children = (List<Map<String, Object>>) parentMap.get("children");
+                Map<String, Object> temMap = new HashMap<>();
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                temMap.put("isParent", false);
+                temMap.put("id", xlCode);
+                temMap.put("name", xlName);
+                children.add(temMap);
+            }
+            prevDlCode=dlCode;
+        }
+        return treeList;
+    }
+
+    /**
+     * 获取所有检查分类字典树
+     *
+     * @param jyZcClasses
+     * @return
+     */
+    private List<Map<String, Object>> getJcZdClassTreeList(List<Map<String, Object>> jyZcClasses) {
+        List<Map<String, Object>> treeList = new ArrayList<>();
+        //当前一级父节点
+        Map<String, Object> grandParentMap = null;
+        //当前二级父节点
+        Map<String, Object> parentMap = null;
+        //当前数据的祖父编码
+        String currentGrandParentDlCode = null;
+        //当前数据的父编码
+        String currentParentDlCode = null;
+        for (Map<String, Object> jcZdClass : jyZcClasses) {
+            String dlCode = (String) jcZdClass.get("dl_code");
+            if(StringUtils.isBlank(dlCode)){
+                continue;
+            }
+            String dlName = (String) jcZdClass.get("dl_name");
+            String xlCode = (String) jcZdClass.get("xl_code");
+            String xlName = (String) jcZdClass.get("xl_name");
+            //父编码是2位数 说明是一级树
+            if(dlCode.length()==2){
+                grandParentMap = new HashMap<>();
+                treeList.add(grandParentMap);
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                grandParentMap.put("isParent", false);
+                grandParentMap.put("id", dlCode);
+                grandParentMap.put("name", dlName);
+                currentGrandParentDlCode=dlCode;
+                if(StringUtils.isNotBlank(xlCode)){
+                    grandParentMap.put("isParent", true);
+                    List<Map<String, Object>> children = new ArrayList<>();
+                    grandParentMap.put("children", children);
+                    Map<String, Object> temMap = new HashMap<>();
+                    //初始化时不知道自己有子节点,所以设置为非父节点
+                    temMap.put("isParent", false);
+                    temMap.put("id", xlCode);
+                    temMap.put("name", xlName);
+                    children.add(temMap);
+                }
+                //以当前的祖父节点的编码做为编码起始,说明示二级菜单
+            }else if(dlCode.startsWith(currentGrandParentDlCode)){
+                //此时已经有子节点,设置成父节点
+                grandParentMap.put("isParent", true);
+                List<Map<String, Object>> children = (List<Map<String, Object>>) grandParentMap.get("children");
+                if (children == null) {
+                    children = new ArrayList<>();
+                    grandParentMap.put("children", children);
+                }
+                if(parentMap==null || !currentParentDlCode.equals(dlCode)){
+                    parentMap=new HashMap<>();
+                    //初始化时不知道自己有子节点,所以设置为非父节点
+                    parentMap.put("isParent", false);
+                    parentMap.put("id", dlCode);
+                    parentMap.put("name", dlName.substring(dlName.indexOf(" ")+1));
+                    children.add(parentMap);
+                    currentParentDlCode=dlCode;
+                }
+                if(StringUtils.isNotBlank(xlCode)){
+                    parentMap.put("isParent", true);
+                    List<Map<String, Object>> grandchildren = (List<Map<String, Object>>) parentMap.get("children");
+                    if (grandchildren == null) {
+                        grandchildren = new ArrayList<>();
+                        parentMap.put("children", grandchildren);
+                    }
+                    parentMap.put("children", grandchildren);
+                    Map<String, Object> temMap = new HashMap<>();
+                    //初始化时不知道自己有子节点,所以设置为非父节点
+                    temMap.put("isParent", false);
+                    temMap.put("id", xlCode);
+                    temMap.put("name", xlName);
+                    grandchildren.add(temMap);
+                }
+            }
+        }
+        return treeList;
+    }
+}

+ 42 - 0
src/main/java/cn/hnthyy/thmz/entity/his/mz/YpZdClass.java

@@ -0,0 +1,42 @@
+package cn.hnthyy.thmz.entity.his.mz;
+
+import java.io.Serializable;
+import lombok.Data;
+
+/**
+ * @Description  药品分类
+ * @Author  胡如刚
+ * @Date 2021-07-30 
+ */
+
+@Data
+public class YpZdClass  implements Serializable {
+
+	private static final long serialVersionUID =  5766220213025010405L;
+
+	/**
+	 * code
+	 */
+	private String code;
+
+	/**
+	 * name
+	 */
+	private String name;
+
+	/**
+	 * pyCode
+	 */
+	private String pyCode;
+
+	/**
+	 * dCode
+	 */
+	private String wbCode;
+
+	/**
+	 * delFlag
+	 */
+	private String delFlag;
+
+}

+ 36 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/YpZdClassMapper.java

@@ -0,0 +1,36 @@
+package cn.hnthyy.thmz.mapper.his.mz;
+
+import cn.hnthyy.thmz.entity.his.mz.YpZdClass;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
+
+public interface YpZdClassMapper {
+    /**
+     * 查询所有的药品分类
+     *
+     * @return
+     */
+    @Select("  SELECT py_code,d_code wb_code,code,name FROM yp_zd_class where isnull(del_flag,'0')='0'  order by code")
+    List<YpZdClass> selectYpZdClasses();
+
+    /**
+     * 查询所有检验分类
+     *
+     * @return
+     */
+    @Select("SELECT dl_code=a.code,dl_name=a.name,xl_code=b.code,xl_name=b.name FROM jy_zd_class  a,jy_zd_item b  where  a.code*=b.class and isnull(b.del_flag,'') <> '1'  order  by a.code ")
+    List<Map<String, Object>> selectJyZdClasses();
+
+
+    /**
+     * 查询所有检查分类
+     *
+     * @return
+     */
+    @Select("SELECT dl_code=a.code+b.bw_code,dl_name=rtrim(a.name)+' '+ltrim(c.name),xl_code=b.code,xl_name=b.name FROM jc_zd_class a,jc_zd_item b,ysh_zd_part_code c " +
+            "where a.code*=b.class and isnull(b.del_flag,'') <> '1' and b.bw_code=c.code union SELECT dl_code=a.code,dl_name=rtrim(a.name),xl_code=b.code,xl_name=b.name FROM jc_zd_class " +
+            " a,jc_zd_item b where a.code*=b.class and isnull(b.del_flag,'') <> '1' and (b.bw_code is null or b.bw_code='')")
+    List<Map<String, Object>> selectJcZdClasses();
+}

+ 28 - 0
src/main/java/cn/hnthyy/thmz/service/his/mz/YpZdClassService.java

@@ -0,0 +1,28 @@
+package cn.hnthyy.thmz.service.his.mz;
+
+import cn.hnthyy.thmz.entity.his.mz.YpZdClass;
+
+import java.util.List;
+import java.util.Map;
+
+public interface YpZdClassService {
+    /**
+     * 查询所有的药品分类
+     * @return
+     */
+    List<YpZdClass> queryYpZdClasses();
+
+
+    /**
+     * 查询所有检验分类
+     * @return
+     */
+    List<Map<String,Object>> queryJyZdClasses();
+
+
+    /**
+     * 查询所有检查分类
+     * @return
+     */
+    List<Map<String,Object>> queryJcZdClasses();
+}

+ 31 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/YpZdClassServiceImpl.java

@@ -0,0 +1,31 @@
+package cn.hnthyy.thmz.service.impl.his.mz;
+
+import cn.hnthyy.thmz.entity.his.mz.YpZdClass;
+import cn.hnthyy.thmz.mapper.his.mz.YpZdClassMapper;
+import cn.hnthyy.thmz.service.his.mz.YpZdClassService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class YpZdClassServiceImpl implements YpZdClassService {
+    @SuppressWarnings("all")
+    @Autowired
+    private YpZdClassMapper ypZdClassMapper;
+    @Override
+    public List<YpZdClass> queryYpZdClasses() {
+        return ypZdClassMapper.selectYpZdClasses();
+    }
+
+    @Override
+    public List<Map<String, Object>> queryJyZdClasses() {
+        return ypZdClassMapper.selectJyZdClasses();
+    }
+
+    @Override
+    public List<Map<String, Object>> queryJcZdClasses() {
+        return ypZdClassMapper.selectJcZdClasses();
+    }
+}

+ 1 - 1
src/main/resources/static/js/mz/clinic.js

@@ -2097,7 +2097,7 @@ function initRecommendList() {
     settings.height = 320;
     var diagnoseWebuiPopover = $('#diagnose').webuiPopover('destroy').webuiPopover(settings);
     //西药弹窗
-    settings.width = 980;
+    settings.width = 680;
     settings.closeable = false;
     settings.content = '<div id="westernMedicinePopoverContent"><table id="tb_table_western_medicine"></table></div>';
     var westernMedicineWebuiPopover = $('#western_medicine_name').webuiPopover('destroy').webuiPopover(settings);

+ 2 - 0
src/main/resources/templates/mz/clinic.html

@@ -3,6 +3,7 @@
 <link rel="stylesheet" href="/thmz/css/iCheck/blue.css">
 <link rel="stylesheet" href="/thmz/css/custom.min.css">
 <link rel="stylesheet" href="/thmz/css/jquery.webui-popover.min.css">
+<link rel="stylesheet" href="/thmz/zTree_v3/css/zTreeStyle/zTreeStyle.css"/>
 <link rel="stylesheet" href="/thmz/css/registration.css">
 <script src="/thmz/js/dependent/bootstrap-select.js"></script>
 <script src="/thmz/js/dependent/daterangepicker.js"></script>
@@ -11,6 +12,7 @@
 <script src="/thmz/js/dependent/jquery.smartWizard.js"></script>
 <script src="/thmz/js/dependent/validator.js"></script>
 <script src="/thmz/js/common/map-util.js"></script>
+<script src="/thmz/zTree_v3/js/jquery.ztree.all.js"></script>
 <script src="/thmz/js/mz/clinic.js"></script>
 <title>就诊</title>
 <style>