Browse Source

标签维护

zhoutg 6 years ago
parent
commit
8319d8db1c

+ 158 - 0
icssman-service/src/main/java/com/diagbot/entity/wrapper/QuestionWrapper.java

@@ -0,0 +1,158 @@
+package com.diagbot.entity.wrapper;
+
+import com.diagbot.entity.QuestionDetail;
+import com.diagbot.entity.QuestionMapping;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 标签基础表
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2018-12-03
+ */
+
+@Getter
+@Setter
+public class QuestionWrapper implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 标签名
+     */
+    private String tagName;
+
+    /**
+     * 内容
+     */
+    private String name;
+
+    /**
+     * 性别(1:男 2:女 3:通用)
+     */
+    private Integer sexType;
+
+    /**
+     * 最小年龄
+     */
+    private Integer ageBegin;
+
+    /**
+     * 最大年龄
+     */
+    private Integer ageEnd;
+
+    /**
+     * 标签标识(1:单项单列,例如: 程度,咳出通畅度  2:单项多列,例如:杂音,添加症状 3:横铺单标签形式,例如:血压 4:横铺多标签形式,例如:咳嗽 5:竖铺组合项,例如:有无治疗 6:组合项多列 既往史 7:化验)
+     */
+    private String tagType;
+
+    /**
+     * 控件类型(0:无类型,默认值 1:下拉单选 2:下拉多选 3:纯文本 4:待定 5:待定 6:文本框 7:数字键盘文本框 99:联合推送)
+     */
+    private Integer controlType;
+
+    /**
+     * 类型(1:症状 3:其他史 4:查体,5:化验 6:辅检 7:诊断)
+     */
+    private Integer type;
+
+    /**
+     * 子类型,(0:项目,1:描述)
+     */
+    private Integer subType;
+
+    /**
+     * 前置内容
+     */
+    private String labelPrefix;
+
+    /**
+     * 后置内容
+     */
+    private String labelSuffix;
+
+    /**
+     * 最小值
+     */
+    private BigDecimal minValue;
+
+    /**
+     * 最大值
+     */
+    private BigDecimal maxValue;
+
+    /**
+     * 判断类型(0:本身异常;1:本身正常;2:数字范围;3:计算公式;9:无需判断)
+     */
+    private String judgeType;
+
+    /**
+     * 文本生成规则(0:点选顺序,例如初为 1:从上到下,从左到右,例如查体杂音 2:从左到右,从上到下,例如伴/无)
+     */
+    private Integer textGenerate;
+
+    /**
+     * 是否复制 (0:不复制,1:复制)
+     */
+    private String copyType;
+
+    /**
+     * 是否显示+ (0:不显示 1:显示),+功能等于复制
+     */
+    private Integer showAdd;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 明细
+     */
+    private List<QuestionDetail> questionDetails = new ArrayList<>();
+
+    /**
+     * 映射表
+     */
+    private List<QuestionMapping> questionMappings = new ArrayList<>();
+}

+ 61 - 0
icssman-service/src/main/java/com/diagbot/facade/QuestionInfoFacade.java

@@ -3,11 +3,16 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.QuestionIndexDTO;
 import com.diagbot.entity.QuestionInfo;
+import com.diagbot.entity.wrapper.QuestionWrapper;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.QuestionInfoServiceImpl;
+import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.util.UserUtils;
+import com.diagbot.vo.QuestionSaveVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -31,6 +36,62 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
     @Autowired
     ModuleDetailFacade moduleDetailFacade;
 
+
+    /**
+     * 标签保存
+     *
+     * @param questionSaveVO
+     */
+    public void saveOrUpdate(QuestionSaveVO questionSaveVO) {
+
+//        String person = UserUtils.getCurrentPrincipleID(); //TODO person
+        String person = "default";
+        QuestionWrapper questionWrapper = questionSaveVO.getQuestionWrapper();
+        //1、主表信息
+        QuestionInfo questionInfo = new QuestionInfo();
+        String saveOrUpdate = "save"; //新增或修改的标识
+        if(questionWrapper.getId() != null) {
+            QueryWrapper queryWrapper = new QueryWrapper();
+            queryWrapper.eq("id", questionWrapper.getId());
+            queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
+            questionInfo = getOne(queryWrapper);
+            if(questionInfo == null) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                        "标签不存在");
+            }
+            saveOrUpdate = "update";
+        }
+        BeanUtil.copyProperties(questionWrapper, questionInfo);
+        //标签type、tagName唯一
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("tag_name", questionInfo.getTagName());
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
+        queryWrapper.eq("type", questionInfo.getType());
+        queryWrapper.ne("id", questionInfo.getId() == null ? 0 : questionInfo.getId());
+        List<QuestionInfo> questionInfoList = this.list(queryWrapper);
+        if(questionInfoList.size() > 0) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "标签名已存在");
+        }
+        if("save".equals(saveOrUpdate)) {
+            questionInfo.setCreator(person); //创建人
+            questionInfo.setGmtCreate(DateUtil.now());//创建时间
+        } else {
+            questionInfo.setGmtModified(DateUtil.now());//修改时间
+            questionInfo.setModifier(person);//修改人
+        }
+        this.saveOrUpdate(questionInfo);
+
+
+        //明细信息
+
+        //映射信息
+
+        //同义词信息
+
+    }
+
+
     /**
      * 根据id删除标签
      *

+ 123 - 0
icssman-service/src/main/java/com/diagbot/service/QuestionInfoService.java

@@ -3,6 +3,8 @@ package com.diagbot.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.entity.QuestionInfo;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -16,6 +18,9 @@ import java.util.Map;
  */
 public interface QuestionInfoService extends IService<QuestionInfo> {
 
+
+    public static int[] arr = {0, 0};
+
     /**
      * 根据id删除标签
      *
@@ -33,4 +38,122 @@ public interface QuestionInfoService extends IService<QuestionInfo> {
      */
     public List<QuestionInfo> index(Map map);
 
+
+    public static void main(String[] args) {
+        TreeNode tree = new TreeNode();
+//        for(int i = 0; i < 10; i++) {
+//            insert(tree, (int)(Math.random()*100));
+//        }
+        insert(tree, 80);
+        insert(tree, 40);
+        insert(tree, 20);
+        insert(tree, 50);
+        insert(tree, 60);
+        insert(tree, 59);
+        insert(tree, 100);
+        insert(tree, 110);
+        insert(tree, 120);
+        insert(tree, 130);
+        insert(tree, 140);
+        insert(tree, 150);
+
+        System.out.println(tree.toString());
+        List<Integer> list = new ArrayList<>();
+        sort(tree, list);
+        System.out.println(list.toString());
+        deep(tree, arr);
+        System.out.println(Arrays.toString(arr));
+    }
+
+    public static void insert(TreeNode tree, int data) {
+        if(tree == null) {
+            tree = new TreeNode(data);
+            return ;
+        }
+        if(tree.getData() == null) {
+            tree.setData(data);
+            return ;
+        }
+        if(tree.getData() > data) {
+            if(tree.getLeft() == null) {
+                tree.setLeft(new TreeNode(data));
+                return ;
+            }
+            insert(tree.getLeft(), data);
+        } else {
+            if(tree.getRight() == null) {
+                tree.setRight(new TreeNode(data));
+                return ;
+            }
+            insert(tree.getRight(), data);
+        }
+    }
+
+
+    public static void sort(TreeNode tree, List<Integer> list) {
+        if(tree != null) {
+            sort(tree.getLeft(), list);
+            list.add(tree.getData());
+            sort(tree.getRight(), list);
+        }
+    }
+
+    public static void deep(TreeNode tree, int[] arr) {
+        ++arr[1];
+        if(tree != null) {
+            if(arr[1]> arr[0]) {
+                ++arr[0];
+            }
+            deep(tree.getLeft(), arr);
+            --arr[1];
+            deep(tree.getRight(), arr);
+            --arr[1];
+        }
+    }
 }
+
+
+
+class TreeNode {
+    private Integer data;
+    private TreeNode left;
+    private TreeNode right;
+
+    public TreeNode() {
+    }
+
+    public TreeNode(Integer data) {
+        this.data = data;
+    }
+
+    public Integer getData() {
+        return data;
+    }
+
+    public void setData(Integer data) {
+        this.data = data;
+    }
+
+    public TreeNode getLeft() {
+        return left;
+    }
+
+    public void setLeft(TreeNode left) {
+        this.left = left;
+    }
+
+    public TreeNode getRight() {
+        return right;
+    }
+
+    public void setRight(TreeNode right) {
+        this.right = right;
+    }
+
+    @Override
+    public String toString() {
+        return "TreeNode{" +
+                "data=" + data +
+                '}';
+    }
+}

+ 18 - 0
icssman-service/src/main/java/com/diagbot/vo/QuestionSaveVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import com.diagbot.entity.wrapper.QuestionWrapper;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description: 标签保存入参
+ * @Author: ztg
+ * @Date: 2018/10/24 16:11
+ */
+@Getter
+@Setter
+public class QuestionSaveVO {
+
+    private QuestionWrapper questionWrapper; //标签相关
+    //TODO 同义词
+}

+ 3 - 2
icssman-service/src/main/java/com/diagbot/web/QuestionInfoController.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.QuestionIndexDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.QuestionInfo;
 import com.diagbot.facade.QuestionInfoFacade;
+import com.diagbot.vo.QuestionSaveVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,8 +40,8 @@ public class QuestionInfoController {
     @PostMapping("/saveOrUpdate")
     @SysLogger("saveOrUpdate")
     @Transactional
-    public RespDTO<Boolean> saveOrUpdate() {
-
+    public RespDTO<Boolean> saveOrUpdate(@RequestBody QuestionSaveVO questionSaveVO) {
+        questionInfoFacade.saveOrUpdate(questionSaveVO);
         return RespDTO.onSuc(true);
     }