|
@@ -52,8 +52,6 @@ import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Stack;
|
|
|
-import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
@@ -212,10 +210,10 @@ public class DiagnoseFacade extends DiagnoseServiceImpl {
|
|
|
|
|
|
// 更新主表状态
|
|
|
this.update(new UpdateWrapper<Diagnose>()
|
|
|
- .set("has_question", ListUtil.isNotEmpty(diagnoseQuestionList) ? HasQuestionEnum.HAS_QUESTION.getKey() : HasQuestionEnum.NO_QUESTION.getKey())
|
|
|
+ .set("has_question", param.getFlag())
|
|
|
.eq("id", diagnoseWrapper.getId())
|
|
|
);
|
|
|
- verifyDataDTO.setHasQuestion(ListUtil.isNotEmpty(diagnoseQuestionList) ? HasQuestionEnum.HAS_QUESTION.getKey() : HasQuestionEnum.NO_QUESTION.getKey());
|
|
|
+ verifyDataDTO.setHasQuestion(param.getFlag());
|
|
|
verifyDataDTO.setDisFeature(disFeature);
|
|
|
verifyDataDTO.setDisformula(disformula);
|
|
|
return verifyDataDTO;
|
|
@@ -268,8 +266,7 @@ public class DiagnoseFacade extends DiagnoseServiceImpl {
|
|
|
bean.setModifier(param.getPerson());
|
|
|
bean.setGmtModified(param.getNow());
|
|
|
if (DiagnoseTypeEnum.Confirmed.getKey() == bean.getType() || (DiagnoseTypeEnum.Examination.getKey() == bean.getType() || (DiagnoseTypeEnum.Vigilant.getKey() == bean.getType()))) {
|
|
|
- // 校验公式
|
|
|
- // TODO
|
|
|
+ // 不需要校验公式
|
|
|
} else {
|
|
|
// 校验编码
|
|
|
if (StringUtil.isNotEmpty(bean.getCode())) {
|
|
@@ -458,6 +455,9 @@ public class DiagnoseFacade extends DiagnoseServiceImpl {
|
|
|
}
|
|
|
param.setI(i);
|
|
|
param.setJ(j);
|
|
|
+ if (ListUtil.isNotEmpty(diagnoseQuestionList)) {
|
|
|
+ param.setFlag(HasQuestionEnum.HAS_QUESTION.getKey());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -469,6 +469,7 @@ public class DiagnoseFacade extends DiagnoseServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public void doDisFormula(DiagnoseWrapper diagnoseWrapper, CommonParam param, List<DiagnoseDetail> diagnoseDetailList, List<DiagnoseQuestion> diagnoseQuestionList) {
|
|
|
+ List<String> codeList = diagnoseWrapper.getDisFeature().stream().map(row -> row.getCode()).distinct().collect(Collectors.toList());
|
|
|
int i = param.getI();
|
|
|
int j = param.getJ();
|
|
|
// 遍历诊断公式
|
|
@@ -483,7 +484,13 @@ public class DiagnoseFacade extends DiagnoseServiceImpl {
|
|
|
diagnoseDetail.setDisName(diagnoseWrapper.getDisName());
|
|
|
diagnoseDetail.setOrderNo(++i);
|
|
|
// 校验公式
|
|
|
- // TODO
|
|
|
+ String errMsg = VerifyUtil.verifyFormula(codeList, bean.getFormula());
|
|
|
+ if (StringUtil.isNotEmpty(errMsg)) {
|
|
|
+ diagnoseDetail.setVerifyFormula(errMsg);
|
|
|
+ param.setFlag(HasQuestionEnum.HAS_QUESTION.getKey());
|
|
|
+ } else {
|
|
|
+ diagnoseDetail.setVerifyFormula("");
|
|
|
+ }
|
|
|
diagnoseDetailList.add(diagnoseDetail);
|
|
|
}
|
|
|
param.setI(i);
|
|
@@ -530,7 +537,7 @@ public class DiagnoseFacade extends DiagnoseServiceImpl {
|
|
|
public void updateNeo(DiagnoseWrapper diagnoseWrapper) {
|
|
|
VerifyDataDTO verifyDataDTO = verifyData(diagnoseWrapper);
|
|
|
if (HasQuestionEnum.HAS_QUESTION.getKey() == verifyDataDTO.getHasQuestion()) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "有问题词存在,不能更新图谱");
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "有问题词存在或公式错误,不能更新图谱");
|
|
|
}
|
|
|
// 更新时间
|
|
|
this.update(new UpdateWrapper<Diagnose>()
|
|
@@ -603,129 +610,4 @@ public class DiagnoseFacade extends DiagnoseServiceImpl {
|
|
|
return dq;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- String s = "(1.1/1.2/1.3)任一+(1.4/1.17/1.18)任六+(2.1/2.2/2.3/2.4/2.5/2.6/2.7/2.8/2.9/2.11)任一";
|
|
|
- String s1 = "(1.1)任一+(1.2任二)";
|
|
|
- System.out.println(isMatch(s1));
|
|
|
-
|
|
|
-
|
|
|
-// System.out.println(isMatch(s));
|
|
|
-
|
|
|
- // 待解决,括号是否嵌套,括号内容不能为空
|
|
|
- /**
|
|
|
- * 1、括号成对校验
|
|
|
- * 2、是否出现重复分隔符
|
|
|
- * 3、获取编码并校验
|
|
|
- */
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 校验括号是否嵌套
|
|
|
- * @param s
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static boolean verifyBracketNest(String s) {
|
|
|
- int i = s.indexOf("(");
|
|
|
- while(-1 != i) {
|
|
|
- if(i == 0) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- char ch = s.charAt(i-1);
|
|
|
- if (')' != ch) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- i = s.indexOf("任", i + 1);
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 校验任字前面是否“)”
|
|
|
- * @param s
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static boolean verifyRen(String s) {
|
|
|
- int i = s.indexOf("任");
|
|
|
- while(-1 != i) {
|
|
|
- if(i == 0) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- char ch = s.charAt(i-1);
|
|
|
- if (')' != ch) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- i = s.indexOf("任", i + 1);
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取编码
|
|
|
- * @param s
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static List<String> splitCode(String s) {
|
|
|
- List<String> res = new ArrayList<>();
|
|
|
- String resg1 = "\\(|/|\\)|任一|任二|任三|任四|任五|任六|任七|任八|任九|任十|\\+";
|
|
|
- String[] arr = s.split(resg1);
|
|
|
- for(String str : arr) {
|
|
|
- if (StringUtil.isNotEmpty(str)) {
|
|
|
- res.add(str);
|
|
|
- }
|
|
|
- }
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 括号是否成对匹配
|
|
|
- * @param s
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static boolean isMatch(String s) {
|
|
|
- Stack<Character> sc=new Stack<Character>();
|
|
|
- char[] c=s.toCharArray();
|
|
|
- for (int i = 0; i < c.length; i++) {
|
|
|
- if (c[i]=='(') {
|
|
|
- sc.push(c[i]);
|
|
|
- }
|
|
|
- else if (c[i]==')') {
|
|
|
- if(sc.isEmpty()){
|
|
|
- return false;
|
|
|
- }
|
|
|
- else{
|
|
|
- if (sc.peek()=='(') {
|
|
|
- sc.pop();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (sc.empty()) {
|
|
|
- return true;
|
|
|
- }else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 是否出现重复分隔符
|
|
|
- * @param s
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static boolean isRepeat(String s) {
|
|
|
- String regex = ".*((\\()|(\\))|(\\+)|(//)|(任一)|(任二)|(任三)|(任四)|(任五)|(任六)|(任七)|(任八)|(任九)|(任十)){2,}.*";
|
|
|
- return Pattern.matches(regex, s);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|