From 1f59f96dace205eede8949b046081fe4afd16572 Mon Sep 17 00:00:00 2001 From: "youHong.ai" <774495953@qq.com> Date: Tue, 13 Dec 2022 15:30:18 +0800 Subject: [PATCH] =?UTF-8?q?apa=E7=AD=89=E7=BA=A7=E5=B8=A6=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../youhong.ai/pcn/workflow_code_block.js | 4 +- src/main/java/aiyh/utils/Util.java | 2 +- .../controller/ApaLevelByScoreController.java | 38 +++++++++++++++++++ .../mapper/ApaLevelByScoreMapper.java | 28 ++++++++++++++ .../service/ApaLevelByScoreService.java | 34 +++++++++++++++++ .../config/service/DealWithMapping.java | 2 +- .../java/youhong/ai/pcn/TestOrganization.java | 13 +++++++ 7 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/controller/ApaLevelByScoreController.java create mode 100644 src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/mapper/ApaLevelByScoreMapper.java create mode 100644 src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/service/ApaLevelByScoreService.java diff --git a/javascript/youhong.ai/pcn/workflow_code_block.js b/javascript/youhong.ai/pcn/workflow_code_block.js index 928b1ee..290ce16 100644 --- a/javascript/youhong.ai/pcn/workflow_code_block.js +++ b/javascript/youhong.ai/pcn/workflow_code_block.js @@ -219,7 +219,10 @@ window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {}, } } }) +/* ******************* apa流程通过apa分数字段带出level字段eng ******************* */ + +/* ******************* apa流程通过apa分数字段带出level字段 ******************* */ $(() => { let config = { scoreFiled: "", @@ -228,5 +231,4 @@ $(() => { window.workflowCus.getLevelByScore(config) }) - /* ******************* apa流程通过apa分数字段带出level字段eng ******************* */ diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index d015f2b..12fb320 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -3466,7 +3466,7 @@ public class Util extends weaver.general.Util { // "((#(\\{|sql\\{))?([():/\\-$#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?"; String pattern = "&?(?([#.\\w\\u4E00-\\u9FA5]+))=" + "(?(`([^`]*)`|" + - "((#(\\{|sql\\{))?([():/\\-$#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?"; + "((#(\\{|sql\\{))?([():/\\-$_*#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?"; Pattern compile = Pattern.compile(pattern); Matcher matcher = compile.matcher(paramStr); Map pathParamMap = new HashMap<>(8); diff --git a/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/controller/ApaLevelByScoreController.java b/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/controller/ApaLevelByScoreController.java new file mode 100644 index 0000000..5476d7c --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/controller/ApaLevelByScoreController.java @@ -0,0 +1,38 @@ +package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.youhong.ai.pcn.workflow.doworkflowtomodel.service.ApaLevelByScoreService; +import org.apache.log4j.Logger; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; + +/** + *

通过apa分数获取apalevel

+ * + *

create: 2022-12-13 10:37

+ * + * @author youHong.ai + */ + +@Path("ayh/workflow/apa") +public class ApaLevelByScoreController { + + private final Logger log = Util.getLogger(); + private final ApaLevelByScoreService service = new ApaLevelByScoreService(); + + @Path("/level") + @GET + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String getLevelByScore(@QueryParam("score") Double score) { + try { + Integer level = service.getLevelByScore(score); + return ApiResult.success(level); + } catch (Exception e) { + log.error("get level error \n" + Util.getErrString(e)); + return ApiResult.error("get level error " + e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/mapper/ApaLevelByScoreMapper.java b/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/mapper/ApaLevelByScoreMapper.java new file mode 100644 index 0000000..f011991 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/mapper/ApaLevelByScoreMapper.java @@ -0,0 +1,28 @@ +package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.mapper; + +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +/** + *

+ * + *

create: 2022-12-13 10:42

+ * + * @author youHong.ai + */ + +@SqlMapper +public interface ApaLevelByScoreMapper { + + /** + *

通过apa分数查询对应的分数等级

+ * 2022/12/13 10:47 + * ************************************************************ + * + * @param score 分数 + * @return Integer 当前分数对应的等级 + * @author youHong.ai ****************************************** + */ + @Select("select level1 from uf_APAlevel where #{score} between zdf and zgf") + Integer selectLevelByScore(Double score); +} diff --git a/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/service/ApaLevelByScoreService.java b/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/service/ApaLevelByScoreService.java new file mode 100644 index 0000000..8302ceb --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/workflow/doworkflowtomodel/service/ApaLevelByScoreService.java @@ -0,0 +1,34 @@ +package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.service; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.api.youhong.ai.pcn.workflow.doworkflowtomodel.mapper.ApaLevelByScoreMapper; + +/** + *

+ * + *

create: 2022-12-13 10:40

+ * + * @author youHong.ai + */ + +public class ApaLevelByScoreService { + private final ApaLevelByScoreMapper mapper = Util.getMapper(ApaLevelByScoreMapper.class); + + /** + *

根据分数查询等级

+ * 2022/12/13 10:55 + * ************************************************************ + * + * @param score 分数 + * @return Integer 等级 + * @author youHong.ai ****************************************** + */ + public Integer getLevelByScore(Double score) { + Integer level = mapper.selectLevelByScore(score); + if (level < -1) { + throw new CustomerException("query level error, score is [" + score + ""); + } + return level; + } +} diff --git a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java index 14c5946..d64a447 100644 --- a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java +++ b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java @@ -1378,7 +1378,7 @@ public class DealWithMapping extends ToolUtil { // 最终通过反射调用weaver.aiyh_jitu.pushdata.service.GetAssignProcessorProcessorImpl类,将参数传递给这个类, 使用``包裹的字符串会被解析为一个字符串 String pattern = "&?(?([#.\\w\\u4E00-\\u9FA5]+))=" + "(?((`([^`]*)`)|" + - "((#(\\{|sql\\{))?([():/\\-$#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?"; + "((#(\\{|sql\\{))?([():/\\-$_#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?"; Pattern compile = Pattern.compile(pattern); Matcher matcher = compile.matcher(paramStr); while (matcher.find()) { diff --git a/src/test/java/youhong/ai/pcn/TestOrganization.java b/src/test/java/youhong/ai/pcn/TestOrganization.java index cae7065..3c6f640 100644 --- a/src/test/java/youhong/ai/pcn/TestOrganization.java +++ b/src/test/java/youhong/ai/pcn/TestOrganization.java @@ -124,6 +124,19 @@ public class TestOrganization extends BaseTest { //String paramValue = matcher.group("value"); //System.out.println(paramValue); //} + String pattern = "&?(?([#.\\w\\u4E00-\\u9FA5]+))=" + + "(?((`([^`]*)`)|" + + "((#(\\{|sql\\{))?([():/\\-$_#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?"; + Pattern compile = Pattern.compile(pattern); + Matcher matcher = compile.matcher(testStr); + while (matcher.find()) { + String key = matcher.group("key"); + String paramValue = matcher.group("value"); + System.out.println(key); + System.out.println(paramValue); + if (paramValue != null && paramValue.startsWith("`") && paramValue.endsWith("`")) { + } + } }