Browse Source

正则规则保存

wangfeng 4 năm trước cách đây
mục cha
commit
72e1793cef

+ 32 - 0
src/main/java/com/diagbot/facade/SysRegularConfigFacade.java

@@ -8,12 +8,16 @@ import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.entity.SysRegularConfig;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.RegularConfigEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.model.entity.Allergy;
 import com.diagbot.model.entity.AllergyMedicine;
 import com.diagbot.model.label.PastLabel;
 import com.diagbot.service.impl.SysRegularConfigServiceImpl;
 import com.diagbot.util.ListUtil;
 import com.diagbot.vo.RegularConfigDataVO;
+import com.diagbot.vo.RegularConfigSaveVO;
+import org.neo4j.driver.summary.Plan;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -144,4 +148,32 @@ public class SysRegularConfigFacade extends SysRegularConfigServiceImpl {
         wordCrfDTO.setLis(lisData);
         return wordCrfDTO;
     }
+
+    public boolean saverRegularConfigDatas(RegularConfigSaveVO regularConfigSaveVO) {
+        boolean res = false;
+        List<String> name = regularConfigSaveVO.getName();
+        for (String str:name) {
+            int countTow = this.count(new QueryWrapper<SysRegularConfig>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq(str != null, "rules_name", str)
+                    .eq(regularConfigSaveVO.getRulesTepy() != null, "rules_tepy", regularConfigSaveVO.getRulesTepy()));
+            if (countTow > 0) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, str+"该方案编码已存在");
+            }else {
+                SysRegularConfig regularConfig = new SysRegularConfig();
+                regularConfig.setRulesName(str);
+                regularConfig.setRulesTepy(regularConfigSaveVO.getRulesTepy());
+                String rulesValue = "";
+                if(regularConfigSaveVO.getRulesTepy().equals(RegularConfigEnum.allergy.getKey())){
+                    int num = str.length();
+                    rulesValue = "[\\、"+str+"过敏]{"+(num+3)+"}|[无"+str+"过敏]{"+(num+3)+"}|[否认"+str+"过敏]{"+(num+4)+"}¥["+str+"过敏]{"+(num+2)+"}";
+                }else if(regularConfigSaveVO.getRulesTepy().equals(RegularConfigEnum.lis.getKey())){
+                    rulesValue ="("+str+")\\s*[(\\-|\\+)?\\d+(\\.\\d+)?$]+";
+                }
+                regularConfig.setRulesValue(rulesValue);
+                res = save(regularConfig);
+            }
+        }
+    return res;
+    }
 }

+ 18 - 0
src/main/java/com/diagbot/vo/RegularConfigSaveVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2020-12-03 14:57
+ */
+@Setter
+@Getter
+public class RegularConfigSaveVO {
+    private List<String> name;
+    private Integer rulesTepy;
+}

+ 11 - 0
src/main/java/com/diagbot/web/SysRegularConfigController.java

@@ -5,9 +5,11 @@ import com.diagbot.dto.RegularValueDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.SysRegularConfigFacade;
 import com.diagbot.vo.RegularConfigDataVO;
+import com.diagbot.vo.RegularConfigSaveVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -42,4 +44,13 @@ public class SysRegularConfigController {
         return RespDTO.onSuc(data);
     }
 
+    @ApiOperation(value = "保存相应正则数据",
+            notes = "保存相应正则数据")
+    @PostMapping("/saverRegularConfigData")
+    @Transactional
+    public RespDTO<Boolean> saverRegularConfigData(@Valid @RequestBody RegularConfigSaveVO regularConfigSaveVO) {
+        boolean res = sysRegularConfigFacade.saverRegularConfigDatas(regularConfigSaveVO);
+        return RespDTO.onSuc(res);
+    }
+
 }