diff --git a/.gitignore b/.gitignore index 42e92c5..a1f5db0 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,5 @@ src/test/resources/font src/main/resources/WEB-INF/vm/outFile target/ *.back +src/main/old_src/ diff --git a/javascript/youhong.ai/pcn/workflow_code_block.js b/javascript/youhong.ai/pcn/workflow_code_block.js index 869e200..9212a06 100644 --- a/javascript/youhong.ai/pcn/workflow_code_block.js +++ b/javascript/youhong.ai/pcn/workflow_code_block.js @@ -563,9 +563,11 @@ $(() => { "Content-Type": "application/json" }, complete: (res) => { - if (res && res.code === 200) { - callback(); - } + res.then(r => { + if (r && r.code === 200) { + callback(); + } + }) } }) }); diff --git a/pom.xml b/pom.xml index 365f87d..5b8411e 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,12 @@ ${lombok.version} provided + + + com.drewnoakes + metadata-extractor + ${metadata-extractor.version} + diff --git a/src/main/java/aiyh/utils/entity/FieldViewInfo.java b/src/main/java/aiyh/utils/entity/FieldViewInfo.java index c76e2bb..0240c5f 100644 --- a/src/main/java/aiyh/utils/entity/FieldViewInfo.java +++ b/src/main/java/aiyh/utils/entity/FieldViewInfo.java @@ -6,7 +6,7 @@ import lombok.Setter; import lombok.ToString; /** - *

+ *

流程建模字段信息

* *

create: 2023/2/20 11:01

* diff --git a/src/main/java/aiyh/utils/entity/ModelTableInfo.java b/src/main/java/aiyh/utils/entity/ModelTableInfo.java new file mode 100644 index 0000000..e763cf7 --- /dev/null +++ b/src/main/java/aiyh/utils/entity/ModelTableInfo.java @@ -0,0 +1,28 @@ +package aiyh.utils.entity; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + *

建模表信息

+ * + *

create: 2023/3/14 17:05

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class ModelTableInfo { + /** id */ + @SqlOracleDbFieldAnn("ID") + private String id; + + @SqlOracleDbFieldAnn("INDEX_DESC") + private String indexDesc; + /** 字段表名 */ + @SqlOracleDbFieldAnn("TABLE_NAME") + private String tableName; +} diff --git a/src/main/java/aiyh/utils/entity/SelectValueEntity.java b/src/main/java/aiyh/utils/entity/SelectValueEntity.java index 6411a50..28ba419 100644 --- a/src/main/java/aiyh/utils/entity/SelectValueEntity.java +++ b/src/main/java/aiyh/utils/entity/SelectValueEntity.java @@ -3,7 +3,7 @@ package aiyh.utils.entity; import lombok.Data; /** - *

+ *

下拉框字段信息

*

create 2022/6/10 21:21

* * @author ayh @@ -11,10 +11,10 @@ import lombok.Data; @Data public class SelectValueEntity { - private String id; - private String fieldname; - private String fieldlabel; - private String tablename; - private String selectname; - private Integer selectvalue; + private String id; + private String fieldname; + private String fieldlabel; + private String tablename; + private String selectname; + private Integer selectvalue; } diff --git a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java index 05491b2..6aabc85 100644 --- a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java +++ b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java @@ -86,6 +86,10 @@ public class HttpUtils { } + public void setCredentialsProvider(CredentialsProvider credentialsProvider) { + this.credentialsProvider = credentialsProvider; + } + public HttpUtils(CredentialsProvider credentialsProvider) { this.credentialsProvider = credentialsProvider; } diff --git a/src/main/java/aiyh/utils/mapper/UtilMapper.java b/src/main/java/aiyh/utils/mapper/UtilMapper.java index c35ed85..7382768 100644 --- a/src/main/java/aiyh/utils/mapper/UtilMapper.java +++ b/src/main/java/aiyh/utils/mapper/UtilMapper.java @@ -1,10 +1,7 @@ package aiyh.utils.mapper; import aiyh.utils.annotation.recordset.*; -import aiyh.utils.entity.DocImageInfo; -import aiyh.utils.entity.FieldViewInfo; -import aiyh.utils.entity.SelectValueEntity; -import aiyh.utils.entity.WorkflowNodeConfig; +import aiyh.utils.entity.*; import java.util.List; import java.util.Map; @@ -190,4 +187,14 @@ public interface UtilMapper { " fieldhtmltype field_html_type\n" + "from workflow_field_table_view where id = #{id}") FieldViewInfo selectFieldInfo(Integer id); + + /** + *

查询建模表表信息

+ * + * @param id id + * @return 建模表信息 + */ + + @Select("select id, tablename table_name, indexdesc index_desc from mode_bill_info_view where id = #{id}") + ModelTableInfo selectModelTableInfo(Integer id); } diff --git a/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java b/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java new file mode 100644 index 0000000..0a6303b --- /dev/null +++ b/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java @@ -0,0 +1,38 @@ +package aiyh.utils.recordset; + +import com.alibaba.druid.sql.SQLUtils; +import com.alibaba.druid.sql.parser.ParserException; +import weaver.conn.RecordSet; + +import java.util.Objects; + +/** + *

格式化sql字符串

+ * + *

create: 2023/3/5 11:45

+ * + * @author youHong.ai + */ +public class FormatSqlUtil { + private static String dbType = null; + private static RecordSet recordSet = null; + + public static String formatSql(String sql) { + + if (Objects.isNull(FormatSqlUtil.dbType)) { + if (recordSet == null) { + recordSet = new RecordSet(); + } + FormatSqlUtil.dbType = recordSet.getDBType(); + } + try { + return SQLUtils.format(sql, dbType); + } catch (ParserException e) { + return toSqlString(sql); + } + } + + private static String toSqlString(String sql) { + return sql; + } +} diff --git a/src/main/java/aiyh/utils/recordset/RecordsetUtil.java b/src/main/java/aiyh/utils/recordset/RecordsetUtil.java index f9664c8..1b78fd5 100644 --- a/src/main/java/aiyh/utils/recordset/RecordsetUtil.java +++ b/src/main/java/aiyh/utils/recordset/RecordsetUtil.java @@ -64,12 +64,13 @@ public class RecordsetUtil implements InvocationHandler { SqlHandler sqlHandler = new SqlHandler(); ResultMapper resultMapper = new ResultMapper(); PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args); + String invokeMethod = method.getDeclaringClass().getName() + ":" + method.getName() + " : "; switch (type) { case 1: { if (!handler.getSqlStr().trim().toLowerCase().startsWith("select ")) { throw new CustomerException("The sql statement does not match, the @Select annotation can only execute the select statement, please check whether the sql statement matches!"); } - Util.getLogger(SQL_LOG).info("解析sql===>" + handler); + Util.getLogger(SQL_LOG).info(invokeMethod + handler); if (handler.getArgs().isEmpty()) { rs.executeQuery(handler.getSqlStr()); } else { @@ -81,7 +82,7 @@ public class RecordsetUtil implements InvocationHandler { if (!handler.getSqlStr().trim().toLowerCase().startsWith("update ")) { throw new CustomerException("The sql statement does not match, the @Update annotation can only execute the update statement, please check whether the sql statement matches!"); } - Util.getLogger(SQL_LOG).info(handler.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + handler); Class returnType = method.getReturnType(); boolean b; if (handler.getArgs().isEmpty()) { @@ -107,7 +108,7 @@ public class RecordsetUtil implements InvocationHandler { if (!handler.getSqlStr().trim().toLowerCase().startsWith("insert ")) { throw new CustomerException("The sql statement does not match, the @Insert annotation can only execute the insert statement, please check whether the sql statement matches!"); } - Util.getLogger(SQL_LOG).info(handler.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + handler); Class returnType = method.getReturnType(); boolean b; if (handler.getArgs().isEmpty()) { @@ -126,7 +127,7 @@ public class RecordsetUtil implements InvocationHandler { if (!handler.getSqlStr().trim().toLowerCase().startsWith("delete ")) { throw new CustomerException("The sql statement does not match, the @Delete annotation can only execute the delete statement, please check whether the sql statement matches!"); } - Util.getLogger(SQL_LOG).info(handler.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + handler); Class returnType = method.getReturnType(); boolean b; if (handler.getArgs().isEmpty()) { @@ -144,7 +145,7 @@ public class RecordsetUtil implements InvocationHandler { case 5: { Class returnType = method.getReturnType(); BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args); - Util.getLogger(SQL_LOG).info(batchSqlResult.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + batchSqlResult.toString()); if (batchSqlResult.getBatchList().isEmpty()) { throw new CustomerException("execute batch sql error , batch sql args is empty!"); } @@ -162,7 +163,7 @@ public class RecordsetUtil implements InvocationHandler { case 6: { Class returnType = method.getReturnType(); BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args); - Util.getLogger(SQL_LOG).info(batchSqlResult.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + batchSqlResult.toString()); if (batchSqlResult.getBatchList().isEmpty()) { throw new CustomerException("execute batch sql error , batch sql args is empty!"); } @@ -180,7 +181,7 @@ public class RecordsetUtil implements InvocationHandler { case 7: { Class returnType = method.getReturnType(); BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args); - Util.getLogger(SQL_LOG).info(batchSqlResult.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + batchSqlResult.toString()); if (batchSqlResult.getBatchList().isEmpty()) { throw new CustomerException("execute batch sql error , batch sql args is empty!"); } @@ -304,6 +305,7 @@ public class RecordsetUtil implements InvocationHandler { private Object invokeRsTrans(Object proxy, Method method, Object[] args, String name) { String mapperKey = method.getDeclaringClass().getName(); + String invokeMethod = method.getDeclaringClass().getName() + ":" + method.getName() + " : "; if (!"".equals(name) && null != name) { mapperKey += "." + name; } @@ -323,7 +325,7 @@ public class RecordsetUtil implements InvocationHandler { if (!handler.getSqlStr().trim().toLowerCase().startsWith("select ")) { throw new CustomerException("The sql statement does not match, the @Select annotation can only execute the select statement, please check whether the sql statement matches!"); } - Util.getLogger(SQL_LOG).info("解析sql===>" + handler); + Util.getLogger(SQL_LOG).info(invokeMethod + handler); try { if (handler.getArgs().isEmpty()) { rs.executeQuery(handler.getSqlStr()); @@ -346,7 +348,7 @@ public class RecordsetUtil implements InvocationHandler { if (!handler.getSqlStr().trim().toLowerCase().startsWith("update ")) { throw new CustomerException("The sql statement does not match, the @Update annotation can only execute the update statement, please check whether the sql statement matches!"); } - Util.getLogger(SQL_LOG).info(handler.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + handler); Class returnType = method.getReturnType(); boolean b; try { @@ -382,7 +384,7 @@ public class RecordsetUtil implements InvocationHandler { if (!handler.getSqlStr().trim().toLowerCase().startsWith("insert ")) { throw new CustomerException("The sql statement does not match, the @Insert annotation can only execute the insert statement, please check whether the sql statement matches!"); } - Util.getLogger(SQL_LOG).info(handler.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + handler); Class returnType = method.getReturnType(); boolean b; try { @@ -411,7 +413,7 @@ public class RecordsetUtil implements InvocationHandler { if (!handler.getSqlStr().trim().toLowerCase().startsWith("delete ")) { throw new CustomerException("The sql statement does not match, the @Delete annotation can only execute the delete statement, please check whether the sql statement matches!"); } - Util.getLogger(SQL_LOG).info(handler.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + handler); Class returnType = method.getReturnType(); boolean b; try { @@ -438,7 +440,7 @@ public class RecordsetUtil implements InvocationHandler { Class returnType = method.getReturnType(); boolean custom = batchInsert.custom(); BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args); - Util.getLogger(SQL_LOG).info(batchSqlResult.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + batchSqlResult.toString()); List batchList = batchSqlResult.getBatchList(); if (batchList.isEmpty()) { throw new CustomerException("execute batch sql error , batch sql args is empty!"); @@ -477,7 +479,7 @@ public class RecordsetUtil implements InvocationHandler { Class returnType = method.getReturnType(); boolean custom = batchUpdate.custom(); BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args); - Util.getLogger(SQL_LOG).info(batchSqlResult.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + batchSqlResult.toString()); if (batchSqlResult.getBatchList().isEmpty()) { throw new CustomerException("execute batch sql error , batch sql args is empty!"); } @@ -518,7 +520,7 @@ public class RecordsetUtil implements InvocationHandler { Class returnType = method.getReturnType(); boolean custom = batchDelete.custom(); BatchSqlResultImpl batchSqlResult = sqlHandler.handlerBatch(sql, custom, method, args); - Util.getLogger(SQL_LOG).info(batchSqlResult.toString()); + Util.getLogger(SQL_LOG).info(invokeMethod + batchSqlResult.toString()); if (batchSqlResult.getBatchList().isEmpty()) { throw new CustomerException("execute batch sql error , batch sql args is empty!"); } diff --git a/src/main/java/aiyh/utils/sqlUtil/sqlResult/impl/BatchSqlResultImpl.java b/src/main/java/aiyh/utils/sqlUtil/sqlResult/impl/BatchSqlResultImpl.java index c6c5cc9..cc4e2c1 100644 --- a/src/main/java/aiyh/utils/sqlUtil/sqlResult/impl/BatchSqlResultImpl.java +++ b/src/main/java/aiyh/utils/sqlUtil/sqlResult/impl/BatchSqlResultImpl.java @@ -1,5 +1,7 @@ package aiyh.utils.sqlUtil.sqlResult.impl; +import aiyh.utils.recordset.FormatSqlUtil; + import java.util.List; /** @@ -10,27 +12,27 @@ import java.util.List; public class BatchSqlResultImpl implements aiyh.utils.sqlUtil.sqlResult.SqlResult { - private final String sqlStr; - private final List batchList; - - public BatchSqlResultImpl(String sqlStr, List batchList) { - this.sqlStr = sqlStr; - this.batchList = batchList; - } - - public String getSqlStr() { - return sqlStr; - } - - public List getBatchList() { - return batchList; - } - - @Override - public String toString() { - return "BatchSqlResultImpl{" + - "sqlStr='" + sqlStr + '\'' + - ", batchList=" + batchList + - '}'; - } + private final String sqlStr; + private final List batchList; + + public BatchSqlResultImpl(String sqlStr, List batchList) { + this.sqlStr = sqlStr; + this.batchList = batchList; + } + + public String getSqlStr() { + return sqlStr; + } + + public List getBatchList() { + return batchList; + } + + @Override + public String toString() { + return "BatchSqlResultImpl{" + + "sqlStr='\n" + FormatSqlUtil.formatSql(sqlStr) + "\n'" + + ", batchList=" + batchList + + '}'; + } } diff --git a/src/main/java/aiyh/utils/sqlUtil/sqlResult/impl/PrepSqlResultImpl.java b/src/main/java/aiyh/utils/sqlUtil/sqlResult/impl/PrepSqlResultImpl.java index 4c6e478..5acf3ee 100644 --- a/src/main/java/aiyh/utils/sqlUtil/sqlResult/impl/PrepSqlResultImpl.java +++ b/src/main/java/aiyh/utils/sqlUtil/sqlResult/impl/PrepSqlResultImpl.java @@ -1,5 +1,6 @@ package aiyh.utils.sqlUtil.sqlResult.impl; +import aiyh.utils.recordset.FormatSqlUtil; import aiyh.utils.sqlUtil.sqlResult.SqlResult; import java.util.List; @@ -14,25 +15,25 @@ import java.util.List; public class PrepSqlResultImpl implements SqlResult { private final String sqlStr; private final List args; - + public PrepSqlResultImpl(String sqlStr, List args) { this.sqlStr = sqlStr; this.args = args; } - + public String getSqlStr() { return sqlStr; } - + public List getArgs() { return args; } - - @Override - public String toString() { - return "PrepSqlResultImpl{" + - "sqlStr='" + sqlStr + '\'' + - ", args=" + args + - '}'; - } + + @Override + public String toString() { + return "PrepSqlResultImpl{" + + "sqlStr='\n" + FormatSqlUtil.formatSql(sqlStr) + "\n'" + + ", args=" + args + + '}'; + } } diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandQuanJinSaveAction.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandQuanJinSaveAction.java new file mode 100644 index 0000000..d3b8e29 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandQuanJinSaveAction.java @@ -0,0 +1,40 @@ +package weaver.youhong.ai.yihong.formmode.stagediagram; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import org.apache.log4j.Logger; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.youhong.ai.yihong.formmode.stagediagram.service.ModeExpandSaveService; + +import java.util.HashMap; +import java.util.Map; + +/** + *

保存自定义处理方法

+ * + *

create: 2023-02-06 12:57

+ * + * @author youHong.ai + */ + +public class ModeExpandQuanJinSaveAction extends AbstractModeExpandJavaCodeNew { + + private final Logger log = Util.getLogger(); + + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(8); + ModeExpandSaveService service = new ModeExpandSaveService(); + try { + log.info("自定义接口保存动作参数: " + JSON.toJSONString(param)); + service.updateStageDiagramView(param, + "STAGE_DIAGRAM_AMOUNT_TABLE_QJ", "STAGE_DIAGRAM_PROJECT_ID_FIELD_QJ", + "STAGE_DIAGRAM_AMOUNT_FIELD_QJ", "MAPPING_CONFIG_MARK_QJ"); + } catch (Exception e) { + result.put("errmsg", e.getMessage()); + result.put("flag", "false"); + log.error("建模自定义保存接口错误:" + e.getMessage() + Util.getErrString(e)); + } + return result; + } +} diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandSaveAction.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandSaveAction.java index 9d51a57..a7735e0 100644 --- a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandSaveAction.java +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandSaveAction.java @@ -18,23 +18,23 @@ import java.util.Map; */ public class ModeExpandSaveAction extends AbstractModeExpandJavaCodeNew { - - private final Logger log = Util.getLogger(); - - @Override - public Map doModeExpand(Map param) { - Map result = new HashMap<>(8); - ModeExpandSaveService service = new ModeExpandSaveService(); - try { - log.info("自定义接口保存动作参数: " + JSON.toJSONString(param)); - service.updateStageDiagramView(param, - "STAGE_DIAGRAM_AMOUNT_TABLE", "STAGE_DIAGRAM_PROJECT_ID_FIELD", - "STAGE_DIAGRAM_AMOUNT_FIELD"); - } catch (Exception e) { - result.put("errmsg", e.getMessage()); - result.put("flag", "false"); - log.error("建模自定义保存接口错误:" + e.getMessage() + Util.getErrString(e)); - } - return result; - } + + private final Logger log = Util.getLogger(); + + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(8); + ModeExpandSaveService service = new ModeExpandSaveService(); + try { + log.info("自定义接口保存动作参数: " + JSON.toJSONString(param)); + service.updateStageDiagramView(param, + "STAGE_DIAGRAM_AMOUNT_TABLE", "STAGE_DIAGRAM_PROJECT_ID_FIELD", + "STAGE_DIAGRAM_AMOUNT_FIELD", "MAPPING_CONFIG_MARK"); + } catch (Exception e) { + result.put("errmsg", e.getMessage()); + result.put("flag", "false"); + log.error("建模自定义保存接口错误:" + e.getMessage() + Util.getErrString(e)); + } + return result; + } } diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/mapper/ModeExpandSaveActionMapper.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/mapper/ModeExpandSaveActionMapper.java index 1ca1d46..f41eb0b 100644 --- a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/mapper/ModeExpandSaveActionMapper.java +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/mapper/ModeExpandSaveActionMapper.java @@ -1,11 +1,11 @@ package weaver.youhong.ai.yihong.formmode.stagediagram.mapper; -import aiyh.utils.annotation.recordset.ParamMapper; -import aiyh.utils.annotation.recordset.Select; -import aiyh.utils.annotation.recordset.SqlMapper; -import aiyh.utils.annotation.recordset.Update; +import aiyh.utils.annotation.recordset.*; import weaver.youhong.ai.yihong.formmode.stagediagram.dto.StageNodeInfo; +import weaver.youhong.ai.yihong.formmode.stagediagram.pojo.StageUpdateFieldConfig; +import weaver.youhong.ai.yihong.formmode.stagediagram.pojo.StageUpdateFieldItem; +import java.util.List; import java.util.Map; /** @@ -18,46 +18,117 @@ import java.util.Map; @SqlMapper public interface ModeExpandSaveActionMapper { - - /** - *

查询台账信息

- * - * @param projectId 项目id - * @return 项目台账信息 - */ - @Select("select * from uf_stage_node_info where project_id = #{projectId}") - StageNodeInfo selectStageNodeInfoByProjectId(@ParamMapper("projectId") String projectId); - - /** - *

根据唯一标识查询配置表主表ID

- * - * @param onlyMark 唯一标识 - * @return 主表id - */ - @Select("select id from uf_yh_stage_diagram where only_mark = #{onlyMark}") - Integer selectConfigMainId(@ParamMapper("onlyMark") String onlyMark); - - /** - *

查询配置表明细表信息

- * - * @param formId 表单id - * @return 明细id - */ - // @Select("select * from uf_yh_stage_diagram_dt1 where mainid = #{mainId} and model_table = #{formId]") - // Map selectDetailConfig(@ParamMapper("mainId") Integer mainId, @ParamMapper("formId") String formId); - @Select("select * from uf_yh_stage_diagram_dt1 where model_table = #{formId}") - Map selectDetailConfig(@ParamMapper("formId") String formId); - - @Select("select $t{amountField} from $t{amountTable} where $t{projectIdField} = #{projectId}") - String selectAmountByProjectId(@ParamMapper("projectId") String projectId, - @ParamMapper("projectIdField") String projectIdField, - @ParamMapper("amountTable") String amountTable, - @ParamMapper("amountField") String amountField); - - @Update("update uf_stage_node_info set project_id = #{projectId}, amount = #{amount}, " + - "current_node = #{nodeName} where id = #{dataId}") - boolean updateStageNodeInfo(@ParamMapper("dataId") Integer dataId, - @ParamMapper("projectId") String projectId, - @ParamMapper("nodeName") String nodeName, - @ParamMapper("amount") String amount); + + /** + *

查询台账信息

+ * + * @param projectId 项目id + * @return 项目台账信息 + */ + @Select("select * from uf_stage_node_info where project_id = #{projectId}") + StageNodeInfo selectStageNodeInfoByProjectId(@ParamMapper("projectId") String projectId); + + /** + *

根据唯一标识查询配置表主表ID

+ * + * @param onlyMark 唯一标识 + * @return 主表id + */ + @Select("select id from uf_yh_stage_diagram where only_mark = #{onlyMark}") + Integer selectConfigMainId(@ParamMapper("onlyMark") String onlyMark); + + /** + *

查询配置表明细表信息

+ * + * @param formId 表单id + * @return 明细id + */ + @Select("select * from uf_yh_stage_diagram_dt1 where model_table = #{formId}") + Map selectDetailConfig(@ParamMapper("formId") String formId); + + /** + *

查询金额

+ * + * @param projectId 项目ID + * @param projectIdField 项目id字段 + * @param amountTable 金额表 + * @param amountField 金额字段 + * @return 金额 + */ + @Select("select $t{amountField} from $t{amountTable} where $t{projectIdField} = #{projectId}") + String selectAmountByProjectId(@ParamMapper("projectId") String projectId, + @ParamMapper("projectIdField") String projectIdField, + @ParamMapper("amountTable") String amountTable, + @ParamMapper("amountField") String amountField); + + /** + *

更新阶段信息

+ * + * @param dataId 数据ID + * @param projectId 项目id + * @param nodeName 节点信息 + * @param amount 钱 + * @return 是否成功 + */ + @Update("update uf_stage_node_info set project_id = #{projectId}, amount = #{amount}, " + + "current_node = #{nodeName} where id = #{dataId}") + boolean updateStageNodeInfo(@ParamMapper("dataId") Integer dataId, + @ParamMapper("projectId") String projectId, + @ParamMapper("nodeName") String nodeName, + @ParamMapper("amount") String amount); + + /** + *

查询信息

+ * + * @param onlyMark 唯一标识 + * @return 查询配置结果 + */ + @Select("select * from uf_yh_stage_diagram where only_mark = #{onlyMark}") + @Associations({ + @Association(property = "baseTable", + column = "base_table", + select = "aiyh.utils.mapper.UtilMapper.selectModelTableInfo", + id = @Id(Integer.class)) + }) + @CollectionMappings({ + @CollectionMapping(property = "mappings", + column = "id", + id = @Id(value = Integer.class, methodId = 1)) + }) + StageUpdateFieldConfig selectConfigUpdate(@ParamMapper("onlyMark") String onlyMark); + + + /** + *

查询配置表明细数据

+ * + * @param mainId 主表id + * @return 明细数据 + */ + @CollectionMethod(1) + @Select("select * from uf_yh_stage_diagram_dt2 where mainid = #{mainId}") + @Associations({ + @Association(property = "baseTableFiled", + column = "base_table_filed", + select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo", + id = @Id(Integer.class)) + }) + List selectConfigItem(Integer mainId); + + /** + *

查询自定义sql

+ * + * @param sql 自定义sql + * @return 查询结果 + */ + @Select(custom = true) + Map selectCustomerSql(@SqlString String sql); + + /** + *

更新自定义信息

+ * + * @param sqlString sqlString + * @param projectInfo 项目信息 + */ + @Update(custom = true) + void updateCustomerSql(@SqlString String sqlString, Map projectInfo); } diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/pojo/StageUpdateFieldConfig.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/pojo/StageUpdateFieldConfig.java new file mode 100644 index 0000000..02cb989 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/pojo/StageUpdateFieldConfig.java @@ -0,0 +1,33 @@ +package weaver.youhong.ai.yihong.formmode.stagediagram.pojo; + +import aiyh.utils.entity.ModelTableInfo; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + *

+ * + *

create: 2023/3/14 17:02

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class StageUpdateFieldConfig { + + /** id */ + private Integer id; + + /** 唯一标识 */ + private String onlyMark; + + /** 建模表信息 */ + private ModelTableInfo baseTable; + + /** 配置表明细映射 */ + private List mappings; +} diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/pojo/StageUpdateFieldItem.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/pojo/StageUpdateFieldItem.java new file mode 100644 index 0000000..511648c --- /dev/null +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/pojo/StageUpdateFieldItem.java @@ -0,0 +1,27 @@ +package weaver.youhong.ai.yihong.formmode.stagediagram.pojo; + +import aiyh.utils.entity.FieldViewInfo; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + *

+ * + *

create: 2023/3/14 17:09

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class StageUpdateFieldItem { + + /** id */ + private Integer id; + /** 项目基本信息表字段 */ + private FieldViewInfo baseTableFiled; + + /** 台账字段 */ + private String targetField; +} diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/service/ModeExpandSaveService.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/service/ModeExpandSaveService.java index fcea666..f327ddd 100644 --- a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/service/ModeExpandSaveService.java +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/service/ModeExpandSaveService.java @@ -1,7 +1,7 @@ package weaver.youhong.ai.yihong.formmode.stagediagram.service; import aiyh.utils.Util; -import cn.hutool.core.lang.Assert; +import aiyh.utils.tool.cn.hutool.core.lang.Assert; import com.alibaba.fastjson.JSON; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -9,11 +9,10 @@ import weaver.soa.workflow.request.Property; import weaver.soa.workflow.request.RequestInfo; import weaver.youhong.ai.yihong.formmode.stagediagram.dto.StageNodeInfo; import weaver.youhong.ai.yihong.formmode.stagediagram.mapper.ModeExpandSaveActionMapper; +import weaver.youhong.ai.yihong.formmode.stagediagram.pojo.StageUpdateFieldConfig; +import weaver.youhong.ai.yihong.formmode.stagediagram.pojo.StageUpdateFieldItem; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; /** *

保存自定义处理方法service

@@ -24,86 +23,123 @@ import java.util.Objects; */ public class ModeExpandSaveService { - - private final Logger log = Util.getLogger(); - - private final ModeExpandSaveActionMapper mapper = Util.getMapper(ModeExpandSaveActionMapper.class); - - public void updateStageDiagramView(Map param, - String amountTable, - String projectIdField, - String amountField) { - /* ******************* 查询当前节点对应的projectId ******************* */ - String formId = Util.null2String(param.get("formId")); - Map currentNodeConfig = mapper.selectDetailConfig(formId); - // String stageDiagramProjectFieldName = Util.getCusConfigValue(projectFieldMark); - String stageDiagramProjectFieldName = Util.null2String(currentNodeConfig.get("projectFieldName")); - Assert.notBlank(stageDiagramProjectFieldName, "cna not find projectFieldMark from uf_cus_dev_config! the config can not be null!"); - RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); - Map mainTableValue = getMainTableValue(requestInfo); - String projectId = mainTableValue.get(stageDiagramProjectFieldName); - log.info("主表数据:" + JSON.toJSONString(mainTableValue)); - // 获取当前模块id - /* ******************* 查询台账中对应的project是否存在, 台账中不存在则插入,存在则更新 ******************* */ - StageNodeInfo nodeInfo = mapper.selectStageNodeInfoByProjectId(projectId); - log.info("查询到的nodeINFo数据:" + JSON.toJSONString(nodeInfo)); - if (Objects.isNull(nodeInfo)) { + + private final Logger log = Util.getLogger(); + + private final ModeExpandSaveActionMapper mapper = Util.getMapper(ModeExpandSaveActionMapper.class); + + public void updateStageDiagramView(Map param, + String amountTable, + String projectIdField, + String amountField, + String mappingConfigMark) { + /* ******************* 查询当前节点对应的projectId ******************* */ + String formId = Util.null2String(param.get("formId")); + Map currentNodeConfig = mapper.selectDetailConfig(formId); + String stageDiagramProjectFieldName = Util.null2String(currentNodeConfig.get("projectFieldName")); + Assert.notBlank(stageDiagramProjectFieldName, "cna not find projectFieldMark from uf_cus_dev_config! the config can not be null!"); + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + Map mainTableValue = getMainTableValue(requestInfo); + String projectId = mainTableValue.get(stageDiagramProjectFieldName); + log.info("主表数据:" + JSON.toJSONString(mainTableValue)); + // 获取当前模块id + /* ******************* 查询台账中对应的project是否存在, 台账中不存在则插入,存在则更新 ******************* */ + StageNodeInfo nodeInfo = mapper.selectStageNodeInfoByProjectId(projectId); + log.info("查询到的nodeInFo数据:" + JSON.toJSONString(nodeInfo)); + if (Objects.isNull(nodeInfo)) { // 不存在项目信息在台账中插入项目信息到台账信息中 - Integer dataId = Util.getModeDataId("uf_stage_node_info", 1); - // 查询配置表信息 - // Integer mainId = mapper.selectConfigMainId(Util.getCusConfigValue(onlyMarkCusMark)); - // Map currentNodeConfig = mapper.selectDetailConfig(mainId, formId); - String nodeName = (String) currentNodeConfig.get("nodeName"); - log.info("节点名称: " + nodeName); - String amount = mapper.selectAmountByProjectId(projectId, - Util.getCusConfigValueNullOrEmpty(projectIdField, ""), - Util.getCusConfigValueNullOrEmpty(amountTable, ""), - Util.getCusConfigValueNullOrEmpty(amountField, "")); - - boolean update = mapper.updateStageNodeInfo(dataId, projectId, nodeName, amount); - if (!update) { - Util.deleteModeId("uf_stage_node_info", dataId); - } else { - Util.rebuildModeDataShare(1, Integer.parseInt(Util.getModeIdByTableName("uf_stage_node_info")), - dataId); - } - } else { - // 存在,更新当前项目的节点信息 - Integer dataId = nodeInfo.getId(); - // Integer mainId = mapper.selectConfigMainId(Util.getCusConfigValue(onlyMarkCusMark)); - // Map currentNodeConfig = mapper.selectDetailConfig(mainId, formId); - String nodeName = (String) currentNodeConfig.get("nodeName"); - String amount = mapper.selectAmountByProjectId(projectId, - Util.getCusConfigValueNullOrEmpty(projectIdField, ""), - Util.getCusConfigValueNullOrEmpty(amountTable, ""), - Util.getCusConfigValueNullOrEmpty(amountField, "")); - mapper.updateStageNodeInfo(dataId, projectId, nodeName, amount); - } - } - - - /** - *

获取流程主表数据

- * - * @return 流程主表数据 - */ - protected Map getMainTableValue(RequestInfo requestInfo) { - // 获取主表数据 - Property[] propertyArr = requestInfo.getMainTableInfo().getProperty(); - return getStringMap(propertyArr); - } - - @NotNull - private Map getStringMap(Property[] propertyArr) { - if (null == propertyArr) { - return Collections.emptyMap(); - } - Map mainTable = new HashMap<>(8); - for (Property property : propertyArr) { - String fieldName = property.getName(); - String value = property.getValue(); - mainTable.put(fieldName, value); - } - return mainTable; - } + Integer dataId = Util.getModeDataId("uf_stage_node_info", 1); + // 查询配置表信息 + String nodeName = (String) currentNodeConfig.get("nodeName"); + log.info("节点名称: " + nodeName); + String amount = mapper.selectAmountByProjectId(projectId, + Util.getCusConfigValueNullOrEmpty(projectIdField, ""), + Util.getCusConfigValueNullOrEmpty(amountTable, ""), + Util.getCusConfigValueNullOrEmpty(amountField, "")); + + boolean update = mapper.updateStageNodeInfo(dataId, projectId, nodeName, amount); + if (!update) { + Util.deleteModeId("uf_stage_node_info", dataId); + } else { + Util.rebuildModeDataShare(1, Integer.parseInt(Util.getModeIdByTableName("uf_stage_node_info")), + dataId); + } + } else { + // 存在,更新当前项目的节点信息 + Integer dataId = nodeInfo.getId(); + String nodeName = (String) currentNodeConfig.get("nodeName"); + String amount = mapper.selectAmountByProjectId(projectId, + Util.getCusConfigValueNullOrEmpty(projectIdField, ""), + Util.getCusConfigValueNullOrEmpty(amountTable, ""), + Util.getCusConfigValueNullOrEmpty(amountField, "")); + mapper.updateStageNodeInfo(dataId, projectId, nodeName, amount); + } + /* ******************* 更新其他字段 ******************* */ + String onlyMark = Util.getCusConfigValue(mappingConfigMark); + StageUpdateFieldConfig stageUpdateFieldConfig = mapper.selectConfigUpdate(onlyMark); + if (stageUpdateFieldConfig == null) { + return; + } + List mappings = stageUpdateFieldConfig.getMappings(); + if (mappings == null || mappings.isEmpty()) { + return; + } + StringBuilder selectSql = new StringBuilder(); + selectSql.append("select "); + StringBuilder update = new StringBuilder(); + update.append("update uf_stage_node_info set "); + + for (StageUpdateFieldItem item : mappings) { + selectSql.append(item.getBaseTableFiled().getFieldName()) + .append(","); + update.append(" ") + .append(item.getTargetField().trim()) + .append(" = ") + .append(" #{") + .append(item.getBaseTableFiled().getFieldName()) + .append("},"); + } + selectSql.deleteCharAt(selectSql.length() - 1); + update.deleteCharAt(update.length() - 1); + selectSql.append(" from ") + .append(stageUpdateFieldConfig.getBaseTable().getTableName()) + .append(" where ") + .append(Util.getCusConfigValueNullOrEmpty(projectIdField, "")) + .append(" = '") + .append(projectId.replace("'", "''")) + .append("'"); + Map projectInfo = mapper.selectCustomerSql(selectSql.toString()); + Assert.notEmpty(projectInfo, "query project info empty!"); + update.append(" where project_id = '") + .append(projectId.replace("'", "''")) + .append("'"); + mapper.updateCustomerSql(update.toString(), projectInfo); + + } + + + /** + *

获取流程主表数据

+ * + * @return 流程主表数据 + */ + protected Map getMainTableValue(RequestInfo requestInfo) { + // 获取主表数据 + Property[] propertyArr = requestInfo.getMainTableInfo().getProperty(); + return getStringMap(propertyArr); + } + + @NotNull + private Map getStringMap(Property[] propertyArr) { + if (null == propertyArr) { + return Collections.emptyMap(); + } + Map mainTable = new HashMap<>(8); + for (Property property : propertyArr) { + String fieldName = property.getName(); + String value = property.getValue(); + mainTable.put(fieldName, value); + } + return mainTable; + } } diff --git a/src/main/resources/WEB-INF/prop/prop2map/PatentWall.properties b/src/main/resources/WEB-INF/prop/prop2map/PatentWall.properties new file mode 100644 index 0000000..ef0339e --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/PatentWall.properties @@ -0,0 +1,149 @@ +# ${id}\u8868\u793A\u8BFB\u53D6\u6570\u636E\u5E93\u4E2D\u7684id\uFF0C\u4E0D\u5BF9\u7ED3\u679C\u8F6C\u4E49\uFF0C#{id}\u8868\u793A\u8BFB\u53D6\u6570\u636E\u5E93\u4E2D\u7684id\uFF0C\u5E76\u5C06\u7ED3\u679C\u8FDB\u884C\u8F6C\u4E49\u4F7F\u7528?\u4EE3\u66FF\u540E\u62FC\u63A5\u5230sql\u5B57\u7B26\u4E32\u4E2D +# #sql{select xx from xxx } \u8868\u793A\u67E5\u8BE2SQL\uFF0C\u5C06\u7ED3\u679C\u7684\u7B2C\u4E00\u4E2A\u5B57\u6BB5\u5F53\u505A\u503C +# \u67E5\u8BE2\u7ED3\u679C\u914D\u7F6E +aiyh.patentWall.voMapping.dataResource=uf_zlqzsb +aiyh.patentWall.voMapping.id=${id} +aiyh.patentWall.voMapping.icon=patent.png +aiyh.patentWall.voMapping.activeIcon=patent_active.png +aiyh.patentWall.voMapping.title=#sql{select imagefilename from docimagefile where docid = #{zlzs} } +# labelName labelIndex linkUrl +aiyh.patentWall.voMapping.linkList[0].labelName=\u67E5\u770B\u6587\u6863 +aiyh.patentWall.voMapping.linkList[0].labelIndex=-93792 +aiyh.patentWall.voMapping.linkList[0].linkUrl=/spa/document/index.jsp?id=${zlzs} +aiyh.patentWall.voMapping.linkList[1].labelName=\u8DF3\u8F6C\u6D41\u7A0B +aiyh.patentWall.voMapping.linkList[1].labelIndex=-93793 +aiyh.patentWall.voMapping.linkList[1].linkUrl=/spa/document/index.jsp?id=${zlzs} +#aiyh.patentWall.voMapping.linkUrl=/spa/document/index.jsp?id=${zlzs} +aiyh.patentWall.voMapping.docId=${zlzs} +aiyh.patentWall.voMapping.imageFileId=#sql{select imagefileid from docimagefile where docid = #{zlzs} } + +# \u641C\u7D22\u4FE1\u606F\u914D\u7F6E +# type \u8868\u793A\u641C\u7D22\u6846\u7C7B\u578B\uFF0C1-\u9009\u62E9\u6846\uFF0C2-\u5355\u884C\u6587\u672C\uFF0C3-\u65E5\u671F\uFF0C4-\u5355\u4EBA\u529B\u8D44\u6E90\uFF0C5-\u591A\u4EBA\u529B\u8D44\u6E90\uFF0C6-\u6D41\u7A0B\u8DEF\u5F84\uFF0C7-\u591A\u6D41\u7A0B\u8DEF\u5F84\uFF0C8-\u65E5\u671F\u8303\u56F4 +# name \u6570\u636E\u5E93\u5B57\u6BB5 \u641C\u7D22\u65F6\u9700\u8981\u8FC7\u6EE4\u90A3\u4E2A\u6570\u636E\u5E93\u5B57\u6BB5\u7684\u503C +# labelName \u524D\u7AEF\u9ED8\u8BA4\u663E\u793A\u6587\u5B57\u7684labelName +# labelIndex \u524D\u7AEF\u663E\u793A\u6587\u5B57\u7684labelIndex +# searchType \u641C\u7D22\u7C7B\u578B 1-\u7B49\u4E8E\uFF0C2-\u5927\u4E8E\uFF0C3-\u5C0F\u4E8E\uFF0C4-in\uFF0C5-\u65E5\u671F\u5927\u4E8E\uFF0C6-\u65E5\u671F\u5C0F\u4E8E\uFF0C7-\u65E5\u671F\u7B49\u4E8E,8-\u65E5\u671F\u8303\u56F4 +aiyh.patentWall.search.dataResource=uf_zlqzsb + +aiyh.patentWall.search.inputs[0].type=2 +aiyh.patentWall.search.inputs[0].dbFieldName=zlqr +aiyh.patentWall.search.inputs[0].labelName=\u4E13\u5229\u6743\u4EBA +aiyh.patentWall.search.inputs[0].labelIndex=-95588 +aiyh.patentWall.search.inputs[0].searchType=1 +aiyh.patentWall.search.inputs[0].value= + +aiyh.patentWall.search.inputs[1].type=2 +aiyh.patentWall.search.inputs[1].dbFieldName=fmrsjr +aiyh.patentWall.search.inputs[1].labelName=\u53D1\u660E\u4EBA/\u8BBE\u8BA1\u4EBA +aiyh.patentWall.search.inputs[1].labelIndex=-95589 +aiyh.patentWall.search.inputs[1].searchType=1 +aiyh.patentWall.search.inputs[1].value= + +aiyh.patentWall.search.inputs[2].type=2 +aiyh.patentWall.search.inputs[2].dbFieldName=zlcpmc +aiyh.patentWall.search.inputs[2].labelName=\u4E13\u5229\u4EA7\u54C1\u540D\u79F0 +aiyh.patentWall.search.inputs[2].labelIndex=-95590 +aiyh.patentWall.search.inputs[2].searchType=1 +aiyh.patentWall.search.inputs[2].value= + +aiyh.patentWall.search.inputs[3].type=1 +aiyh.patentWall.search.inputs[3].dbFieldName=zllx +aiyh.patentWall.search.inputs[3].labelName=\u4E13\u5229\u7C7B\u578B +aiyh.patentWall.search.inputs[3].labelIndex=-95591 +aiyh.patentWall.search.inputs[3].searchType=1 +aiyh.patentWall.search.inputs[3].multiple=true +aiyh.patentWall.search.inputs[3].value= + +aiyh.patentWall.search.inputs[4].type=3 +aiyh.patentWall.search.inputs[4].dbFieldName=zlsqrq +aiyh.patentWall.search.inputs[4].labelName=\u4E13\u5229\u7533\u8BF7\u65E5\u671F +aiyh.patentWall.search.inputs[4].labelIndex=-95592 +aiyh.patentWall.search.inputs[4].searchType=1 +aiyh.patentWall.search.inputs[4].value= + +aiyh.patentWall.search.inputs[5].type=1 +aiyh.patentWall.search.inputs[5].dbFieldName=zlzt +aiyh.patentWall.search.inputs[5].labelName=\u4E13\u5229\u72B6\u6001 +aiyh.patentWall.search.inputs[5].labelIndex=-95593 +aiyh.patentWall.search.inputs[5].searchType=1 +aiyh.patentWall.search.inputs[5].value= + +aiyh.patentWall.search.inputs[6].type=1 +aiyh.patentWall.search.inputs[6].dbFieldName=sqlx +aiyh.patentWall.search.inputs[6].labelName=\u6388\u6743\u7C7B\u578B +aiyh.patentWall.search.inputs[6].labelIndex=-95594 +aiyh.patentWall.search.inputs[6].searchType=1 +aiyh.patentWall.search.inputs[6].value= + + +# copyrightWall \u8457\u4F5C\u5899 + +aiyh.copyrightWall.voMapping.dataResource=uf_zlqzsb +aiyh.copyrightWall.voMapping.id=${id} +aiyh.copyrightWall.voMapping.icon=patent.png +aiyh.copyrightWall.voMapping.activeIcon=patent_active.png +aiyh.copyrightWall.voMapping.title=#sql{select imagefilename from docimagefile where docid = #{zlzs} } +# labelName labelIndex linkUrl +aiyh.copyrightWall.voMapping.linkList[0].labelName=\u67E5\u770B\u6587\u6863 +aiyh.copyrightWall.voMapping.linkList[0].labelIndex=-93802 +aiyh.copyrightWall.voMapping.linkList[0].linkUrl=/spa/document/index.jsp?id=${zlzs} +aiyh.copyrightWall.voMapping.linkList[1].labelName=\u8DF3\u8F6C\u6D41\u7A0B +aiyh.copyrightWall.voMapping.linkList[1].labelIndex=-93803 +aiyh.copyrightWall.voMapping.linkList[1].linkUrl=/spa/document/index.jsp?id=${zlzs} +#aiyh.copyrightWall.voMapping.linkUrl=/spa/document/index.jsp?id=${zlzs} +aiyh.copyrightWall.voMapping.docId=${zlzs} +aiyh.copyrightWall.voMapping.imageFileId=#sql{select imagefileid from docimagefile where docid = #{zlzs} } + + + +aiyh.copyrightWall.search.dataResource=uf_zlqzsb + +aiyh.copyrightWall.search.inputs[0].type=2 +aiyh.copyrightWall.search.inputs[0].dbFieldName=zlqr +aiyh.copyrightWall.search.inputs[0].labelName=\u4E13\u5229\u6743\u4EBA +aiyh.copyrightWall.search.inputs[0].labelIndex=-95595 +aiyh.copyrightWall.search.inputs[0].searchType=1 +aiyh.copyrightWall.search.inputs[0].value= + +aiyh.copyrightWall.search.inputs[1].type=2 +aiyh.copyrightWall.search.inputs[1].dbFieldName=fmrsjr +aiyh.copyrightWall.search.inputs[1].labelName=\u53D1\u660E\u4EBA/\u8BBE\u8BA1\u4EBA +aiyh.copyrightWall.search.inputs[1].labelIndex=-95598 +aiyh.copyrightWall.search.inputs[1].searchType=1 +aiyh.copyrightWall.search.inputs[1].value= + +aiyh.copyrightWall.search.inputs[2].type=2 +aiyh.copyrightWall.search.inputs[2].dbFieldName=zlcpmc +aiyh.copyrightWall.search.inputs[2].labelName=\u4E13\u5229\u4EA7\u54C1\u540D\u79F0 +aiyh.copyrightWall.search.inputs[2].labelIndex=-95597 +aiyh.copyrightWall.search.inputs[2].searchType=1 +aiyh.copyrightWall.search.inputs[2].value= + +aiyh.copyrightWall.search.inputs[3].type=1 +aiyh.copyrightWall.search.inputs[3].dbFieldName=zllx +aiyh.copyrightWall.search.inputs[3].labelName=\u4E13\u5229\u7C7B\u578B +aiyh.copyrightWall.search.inputs[3].labelIndex=-95599 +aiyh.copyrightWall.search.inputs[3].searchType=1 +aiyh.copyrightWall.search.inputs[3].multiple=true +aiyh.copyrightWall.search.inputs[3].value= + +aiyh.copyrightWall.search.inputs[4].type=3 +aiyh.copyrightWall.search.inputs[4].dbFieldName=zlsqrq +aiyh.copyrightWall.search.inputs[4].labelName=\u4E13\u5229\u7533\u8BF7\u65E5\u671F +aiyh.copyrightWall.search.inputs[4].labelIndex=-95600 +aiyh.copyrightWall.search.inputs[4].searchType=1 +aiyh.copyrightWall.search.inputs[4].value= + +aiyh.copyrightWall.search.inputs[5].type=1 +aiyh.copyrightWall.search.inputs[5].dbFieldName=zlzt +aiyh.copyrightWall.search.inputs[5].labelName=\u4E13\u5229\u72B6\u6001 +aiyh.copyrightWall.search.inputs[5].labelIndex=-95601 +aiyh.copyrightWall.search.inputs[5].searchType=1 +aiyh.copyrightWall.search.inputs[5].value= + +aiyh.copyrightWall.search.inputs[6].type=1 +aiyh.copyrightWall.search.inputs[6].dbFieldName=sqlx +aiyh.copyrightWall.search.inputs[6].labelName=\u6388\u6743\u7C7B\u578B +aiyh.copyrightWall.search.inputs[6].labelIndex=-95594 +aiyh.copyrightWall.search.inputs[6].searchType=1 +aiyh.copyrightWall.search.inputs[6].value= diff --git a/src/main/resources/WEB-INF/prop/prop2map/classificationWall.properties b/src/main/resources/WEB-INF/prop/prop2map/classificationWall.properties new file mode 100644 index 0000000..cba2e66 --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/classificationWall.properties @@ -0,0 +1,25 @@ +# ${id}\u8868\u793A\u8BFB\u53D6\u6570\u636E\u5E93\u4E2D\u7684id\uFF0C\u4E0D\u5BF9\u7ED3\u679C\u8F6C\u4E49\uFF0C#{id}\u8868\u793A\u8BFB\u53D6\u6570\u636E\u5E93\u4E2D\u7684id\uFF0C\u5E76\u5C06\u7ED3\u679C\u8FDB\u884C\u8F6C\u4E49\u4F7F\u7528?\u4EE3\u66FF\u540E\u62FC\u63A5\u5230sql\u5B57\u7B26\u4E32\u4E2D +# #sql{select xx from xxx } \u8868\u793A\u67E5\u8BE2SQL\uFF0C\u5C06\u7ED3\u679C\u7684\u7B2C\u4E00\u4E2A\u5B57\u6BB5\u5F53\u505A\u503C +# \u67E5\u8BE2\u7ED3\u679C\u914D\u7F6E +aiyh.classificationWall.voMapping.dataResource=uf_zfzy +# \u6DFB\u52A0\u8D44\u6E90\u6309\u94AE\u94FE\u63A5 +aiyh.classificationWall.voMapping.addSourceUrl=http://www.baidu.com +aiyh.classificationWall.voMapping.addSourceLabelIndex=-1000 +aiyh.classificationWall.voMapping.addSourceLabelName=\u6DFB\u52A0\u8D44\u6E90 +# \u6570\u636EID +aiyh.classificationWall.voMapping.id=${id} +# \u56FA\u5B9A\u503C\u56FE\u7247\u540D\u79F0ecode\u56FE\u7247\u540D\u79F0 +aiyh.classificationWall.voMapping.icon=patent.png +aiyh.classificationWall.voMapping.activeIcon=patent_active.png +# \u4E0B\u811A\u663E\u793A\u7684\u6807\u9898 +aiyh.classificationWall.voMapping.title=${mc} +aiyh.classificationWall.voMapping.titleEn=${mc} +# labelName labelIndex linkUrl +aiyh.classificationWall.voMapping.linkList[0].labelName=\u67E5\u770B\u6587\u6863 +aiyh.classificationWall.voMapping.linkList[0].labelIndex=-93792 +aiyh.classificationWall.voMapping.linkList[0].linkUrl=/spa/document/index.jsp?id=${zyxq} +aiyh.classificationWall.voMapping.linkList[1].labelName=\u8DF3\u8F6C\u6D41\u7A0B +aiyh.classificationWall.voMapping.linkList[1].labelIndex=-93793 +aiyh.classificationWall.voMapping.linkList[1].linkUrl=/spa/document/index.jsp?id=${id} +aiyh.classificationWall.voMapping.docId=0 +aiyh.classificationWall.voMapping.imageFileId=0 diff --git a/src/main/resources/WEB-INF/prop/prop2map/cronJobConfig.properties b/src/main/resources/WEB-INF/prop/prop2map/cronJobConfig.properties new file mode 100644 index 0000000..a5d5d91 --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/cronJobConfig.properties @@ -0,0 +1,16 @@ +# \u5047\u671F\u7C7B\u578B\u6620\u5C04\u5173\u7CFB +# its\u5E74\u5047\u6620\u5C04OA\u5176\u4ED6 +holidaySync.its_type.1=9 +# its\u8C03\u4F11\u6620\u5C04OA\u8C03\u4F11\u5047 +holidaySync.its_type.2=10 + + +# \u5047\u671F\u4F7F\u7528\u989D +holidaySync.its_oa_holiday_viw.used_amount=usedamount +holidaySync.its_oa_holiday_viw.total_amount=baseAmount + + + + + + diff --git a/src/main/resources/WEB-INF/prop/prop2map/ftClientSecret.properties b/src/main/resources/WEB-INF/prop/prop2map/ftClientSecret.properties new file mode 100644 index 0000000..7779212 --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/ftClientSecret.properties @@ -0,0 +1,7 @@ +# \u6388\u6743\u7801 +aiyh.client.clientId=100001 +aiyh.client.clientSecret=1099af237ed347b19a992a5e46520241 + +# \u6620\u5C04\u89C4\u5219 +aiyh.sqlMapper.ee_no=#{loginid} +aiyh.sqlMapper.org_code=ford diff --git a/src/main/resources/WEB-INF/prop/prop2map/governmentSourceWall.properties b/src/main/resources/WEB-INF/prop/prop2map/governmentSourceWall.properties new file mode 100644 index 0000000..cba2e66 --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/governmentSourceWall.properties @@ -0,0 +1,25 @@ +# ${id}\u8868\u793A\u8BFB\u53D6\u6570\u636E\u5E93\u4E2D\u7684id\uFF0C\u4E0D\u5BF9\u7ED3\u679C\u8F6C\u4E49\uFF0C#{id}\u8868\u793A\u8BFB\u53D6\u6570\u636E\u5E93\u4E2D\u7684id\uFF0C\u5E76\u5C06\u7ED3\u679C\u8FDB\u884C\u8F6C\u4E49\u4F7F\u7528?\u4EE3\u66FF\u540E\u62FC\u63A5\u5230sql\u5B57\u7B26\u4E32\u4E2D +# #sql{select xx from xxx } \u8868\u793A\u67E5\u8BE2SQL\uFF0C\u5C06\u7ED3\u679C\u7684\u7B2C\u4E00\u4E2A\u5B57\u6BB5\u5F53\u505A\u503C +# \u67E5\u8BE2\u7ED3\u679C\u914D\u7F6E +aiyh.classificationWall.voMapping.dataResource=uf_zfzy +# \u6DFB\u52A0\u8D44\u6E90\u6309\u94AE\u94FE\u63A5 +aiyh.classificationWall.voMapping.addSourceUrl=http://www.baidu.com +aiyh.classificationWall.voMapping.addSourceLabelIndex=-1000 +aiyh.classificationWall.voMapping.addSourceLabelName=\u6DFB\u52A0\u8D44\u6E90 +# \u6570\u636EID +aiyh.classificationWall.voMapping.id=${id} +# \u56FA\u5B9A\u503C\u56FE\u7247\u540D\u79F0ecode\u56FE\u7247\u540D\u79F0 +aiyh.classificationWall.voMapping.icon=patent.png +aiyh.classificationWall.voMapping.activeIcon=patent_active.png +# \u4E0B\u811A\u663E\u793A\u7684\u6807\u9898 +aiyh.classificationWall.voMapping.title=${mc} +aiyh.classificationWall.voMapping.titleEn=${mc} +# labelName labelIndex linkUrl +aiyh.classificationWall.voMapping.linkList[0].labelName=\u67E5\u770B\u6587\u6863 +aiyh.classificationWall.voMapping.linkList[0].labelIndex=-93792 +aiyh.classificationWall.voMapping.linkList[0].linkUrl=/spa/document/index.jsp?id=${zyxq} +aiyh.classificationWall.voMapping.linkList[1].labelName=\u8DF3\u8F6C\u6D41\u7A0B +aiyh.classificationWall.voMapping.linkList[1].labelIndex=-93793 +aiyh.classificationWall.voMapping.linkList[1].linkUrl=/spa/document/index.jsp?id=${id} +aiyh.classificationWall.voMapping.docId=0 +aiyh.classificationWall.voMapping.imageFileId=0 diff --git a/src/main/resources/WEB-INF/prop/prop2map/htmlLabelIndex.properties b/src/main/resources/WEB-INF/prop/prop2map/htmlLabelIndex.properties new file mode 100644 index 0000000..7bff55e --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/htmlLabelIndex.properties @@ -0,0 +1,6 @@ +aiyh.htmlLabel.porsche.FaDDContractController.pushErr.labelIndex=-1 +aiyh.htmlLabel.porsche.FaDDContractController.pushErr.defaultStr=\u90AE\u4EF6\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01 +aiyh.htmlLabel.porsche.FaDDContractController.pushSuccess.labelIndex=-1 +aiyh.htmlLabel.porsche.FaDDContractController.pushSuccess.defaultStr=\u7B7E\u7F72\u90AE\u4EF6\u53D1\u9001\u6210\u529F\uFF01 +attachment_sort.AnnexSortAction.sortErr.labelIndex=-1 +attachment_sort.AnnexSortAction.sortErr.defaultStr=\u6587\u4EF6\u6392\u5E8F\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\uFF01 \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/jt_fadadaAuthenticConfiguration.properties b/src/main/resources/WEB-INF/prop/prop2map/jt_fadadaAuthenticConfiguration.properties new file mode 100644 index 0000000..fadbd00 --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/jt_fadadaAuthenticConfiguration.properties @@ -0,0 +1,29 @@ +# \u8BF7\u6C42\u53C2\u6570\u4FE1\u606F +# request params config +# #{resource_id} replace database hrmresource table's id +# #{field} or ${field} replace database hrmresource and cus_fielddata field value +# #sql{select name from xxx where id = #{resource_id}} while replace execute customer sql to value +# String: Express this value is String; Integer: Express this value is Integer; Boolean: Express this value is Boolean; Double: Express this value is Double +# #{resource_id} \u8868\u793A\u4EBA\u529B\u8D44\u6E90\u8868\u4E2D\u7684id +# #{field} \u8868\u793A\u4EBA\u529B\u8D44\u6E90\u8868\u4E2D\u6216cus_fielddata\u5373\u81EA\u5B9A\u4E49\u4EBA\u5458\u5361\u7247\u5B57\u6BB5\u7684\u503C +# #sql{select name from xx where id = #{xx}} \u8868\u662F\u81EA\u5B9A\u4E49SQL +# String: Integer: Boolean: Double: \u5206\u522B\u8868\u793A\u8FD9\u4E2A\u503C\u7C7B\u578B\u4E3Astring\u3001integer\u3001boolean\u3001double\u7C7B\u578B\u7684\u8BF7\u6C42\u53C2\u6570 +fadada.realNameAuthentication.customerId=String:#{lasyname} +fadada.realNameAuthentication.verifiedWay=Integer:#sql{select id from hrmdeptment where id = #{deptId}} +fadada.realNameAuthentication.pageModify=Boolean: +fadada.realNameAuthentication.isRepeatVerified=Double: +fadada.realNameAuthentication.customerName= +fadada.realNameAuthentication.customerIdentityType= +fadada.realNameAuthentication.customerIdentityNo= +fadada.realNameAuthentication.mobile= +fadada.realNameAuthentication.identityFrontPath= +fadada.realNameAuthentication.notifyUrl= +fadada.realNameAuthentication.returnUrl= +fadada.realNameAuthentication.isSendSms= +fadada.realNameAuthentication.identityBackPath= +fadada.realNameAuthentication.resultType= +fadada.realNameAuthentication.certType= +fadada.realNameAuthentication.applyCert= +fadada.realNameAuthentication.certMode= +fadada.realNameAuthentication.miniProgram= +fadada.realNameAuthentication.mobileDevice= diff --git a/src/main/resources/WEB-INF/prop/prop2map/jt_fadadaRequestConfigInfo.properties b/src/main/resources/WEB-INF/prop/prop2map/jt_fadadaRequestConfigInfo.properties new file mode 100644 index 0000000..1e40251 --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/jt_fadadaRequestConfigInfo.properties @@ -0,0 +1,3 @@ +fadada.baseUrl=http://123.60.67.228:8070/ +fadada.appKey=BLEshmz8xZPyKRAG4aUiSopt +fadada.appId=100000 \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/jt_tokenConfigInfo.properties b/src/main/resources/WEB-INF/prop/prop2map/jt_tokenConfigInfo.properties new file mode 100644 index 0000000..d852f27 --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/jt_tokenConfigInfo.properties @@ -0,0 +1,47 @@ +# \u914D\u7F6E\u89C4\u5219 \u73AF\u5883.\u4E1A\u52A1\u540D\u79F0.\u83B7\u53D6token\u8D26\u53F7\u4FE1\u606F +# configuration environment.Business name.token info +# oa\u53D1\u677F\u6D41\u7A0B\u63A8\u9001 +# product environment +pro.release.userName=oa005 +pro.release.password=123456 +pro.release.systemCode=oa +pro.release.secretKey=5362448sd132d241e5ae27e318qws11d +pro.release.baseUrl=https://jtdcapi.jtexpress.com.cn +pro.release.expiration=24 +# uat test environment +uat.release.userName=oa003 +uat.release.password=JT0725! +uat.release.systemCode=oa +uat.release.secretKey=5362448sd132d241e5ae27e318qws11d +uat.release.baseUrl=https://uat-jtdcapi.jtexpress.com.cn +uat.release.expiration=24 +# jms\u5E72\u7EBF\u63A8\u9001 +# product environment +pro.jms.userName=oa005 +pro.jms.password=123456 +pro.jms.systemCode=oa +pro.jms.secretKey=5362448sd132d241e5ae27e318qws11d +pro.jms.baseUrl=https://jtdcapi.jtexpress.com.cn +pro.jms.expiration=24 +# uat test environment +uat.jms.userName=oa003 +uat.jms.password=JT0725! +uat.jms.systemCode=oa +uat.jms.secretKey=5362448sd132d241e5ae27e318qws11d +uat.jms.baseUrl=https://uat-jtdcapi.jtexpress.com.cn +uat.jms.expiration=24 +# \u9ED8\u8BA4 +# product environment +pro.default.userName=oa005 +pro.default.password=123456 +pro.default.systemCode=oa +pro.default.secretKey=5362448sd132d241e5ae27e318qws11d +pro.default.baseUrl=https://jtdcapi.jtexpress.com.cn +pro.default.expiration=24 +# uat test environment +uat.default.userName=oa003 +uat.default.password=JT0725! +uat.default.systemCode=oa +uat.default.secretKey=5362448sd132d241e5ae27e318qws11d +uat.default.baseUrl=https://uat-jtdcapi.jtexpress.com.cn +uat.default.expiration=24 diff --git a/src/main/resources/WEB-INF/prop/prop2map/wxAccessTokenConfig.properties b/src/main/resources/WEB-INF/prop/prop2map/wxAccessTokenConfig.properties new file mode 100644 index 0000000..e740a9d --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/wxAccessTokenConfig.properties @@ -0,0 +1,18 @@ +# \u4F01\u4E1A\u5FAE\u4FE1\u83B7\u53D6accessToken\u914D\u7F6E\u4FE1\u606F +# \u4F01\u4E1Acorpid +# corpid +wx.corpid=wwe5f751c365f187e7 +# \u901A\u8BAF\u5F55\u7EF4\u62A4\u63A5\u53E3\u51ED\u8BC1 +# wx corpsecret +wx.corpsecret=L_3ml7weLt9qnonRAPsHN8qw2fG0xJQxsUfWSKv0tsA +# \u83B7\u53D6access_token\u5730\u5740 +wx.baseHost=https://qyapi.weixin.qq.com +# ============================= # +# EM7 corpid +# corpid +em.corpid=em049e8906ac5811e9833ffa163ed86778 +# \u901A\u8BAF\u5F55\u7EF4\u62A4\u63A5\u53E3\u51ED\u8BC1 +# wx corpsecret +em.corpsecret=8e5f4d98-8dd0-4657-9025-fb8ace22494b +# \u83B7\u53D6access_token\u5730\u5740 +em.baseHost=http://121.36.197.152:8999 \ No newline at end of file diff --git a/src/test/java/youhong/ai/mymapper/ParseSqlTest.java b/src/test/java/youhong/ai/mymapper/ParseSqlTest.java index a86e47a..5f8c72e 100644 --- a/src/test/java/youhong/ai/mymapper/ParseSqlTest.java +++ b/src/test/java/youhong/ai/mymapper/ParseSqlTest.java @@ -6,7 +6,6 @@ import org.junit.Test; import youhong.ai.mymapper.command.entity.SqlDefinition; import youhong.ai.mymapper.util.ParseSqlUtil; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -52,6 +51,65 @@ public class ParseSqlTest extends BaseTest { @Test public void testLoadClass() { - System.out.println(Arrays.asList("1", "2", "3", "4")); + String sql = "{\n" + + "\t\t@my-when:test=\"\"{\n" + + "\t\t\tid = #{id}\n" + + "\t\t}\n" + + "\t\t@my-when:test=\"\"{\n" + + "\t\t\tid = #{id}\n" + + "\t\t}\n" + + "\t\t@my-when:test=\"\"{\n" + + "\t\t\tid = #{id}\n" + + "\t\t}\n" + + "\t\t@my-when:test=\"\"{\n" + + "\t\t\tid = #{id}\n" + + "\t\t}\n" + + "\t\t@my-otherwise{\n" + + "\t\t\tid = #{id}\n" + + "\t\t}\n" + + "}"; + ParseSqlUtil parseSqlUtil = new ParseSqlUtil(); + System.out.println(JSON.toJSONString(parseSqlUtil.getCommandList(sql))); + } + + + @Test + public void testSqlChoose() { + String sql = "@my-bind:name='likeName':value=''%' + name + '%''{}\n" + + "select * from table @my-where{\n" + + "\t@my-for:collection='list':separator='and'{\n" + + "\t\t${index} = #{item}\t\n" + + "\t}\n" + + "} or @my-choose{\n" + + "\t@my-when:test='selectValue == 1'{\n" + + "\t\tselect_name = #{selectName1}\n" + + "\t}\n" + + "\t@my-when:test='selectValue == 2'{\n" + + "\t\tselect_name = #{selectName2}\n" + + "\t}\n" + + "\t@my-when:test='selectValue == 3'{\n" + + "\t\tselect_name = #{selectName3}\n" + + "\t}\n" + + "\t@my-otherwise{\n" + + "\t\tselect_name like #{likeName}\n" + + "\t}\n" + + "}\n"; + + Map param = new HashMap<>(); + param.put("list", new HashMap() {{ + put("field1", "1"); + put("field2", "2"); + put("field3", "3"); + }}); + + param.put("selectValue", 4); + param.put("selectName1", "name1"); + param.put("selectName2", "name2"); + param.put("selectName3", "name3"); + param.put("selectNameDefault", "default"); + param.put("name", "zhang"); + ParseSqlUtil parseSqlUtil = new ParseSqlUtil(); + SqlDefinition parse = parseSqlUtil.parse(sql, param); + System.out.println(JSON.toJSONString(parse)); } } diff --git a/src/test/java/youhong/ai/mymapper/command/commandImpl/MyBindCommand.java b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyBindCommand.java new file mode 100644 index 0000000..032aa87 --- /dev/null +++ b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyBindCommand.java @@ -0,0 +1,59 @@ +package youhong.ai.mymapper.command.commandImpl; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import youhong.ai.mymapper.command.ISqlCommand; +import youhong.ai.mymapper.command.annotation.SqlCommand; +import youhong.ai.mymapper.command.constant.CommandConsTant; +import youhong.ai.mymapper.command.entity.SqlCommandDefinition; +import youhong.ai.mymapper.command.properties.MyBindProperties; +import youhong.ai.mymapper.util.ParseSqlUtil; +import youhong.ai.mymapper.util.ScriptUtil; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + *

bind指令

+ * + *

create: 2023/3/15 11:58

+ * + * @author youHong.ai + */ +@SqlCommand(CommandConsTant.BIND) +public class MyBindCommand implements ISqlCommand { + @Override + public String execute(SqlCommandDefinition sqlCommandDefinition) { + MyBindProperties properties = (MyBindProperties) sqlCommandDefinition.getProperties(); + String name = properties.getName(); + if (StrUtil.isBlank(name)) { + throw new CustomerException("bind command attribute of name can not be null"); + } + Map tempMap = ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.get(); + if (CollectionUtil.isEmpty(tempMap)) { + Map map = new HashMap<>(); + ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.set(map); + tempMap = map; + } + name = name.trim(); + if (tempMap.containsKey(name)) { + throw new CustomerException(Util.logStr("can not bind variable [{}], [{}] has been declared!", + name, name)); + } + Map param = ParseSqlUtil.PARSE_PARAM_LOCALE.get(); + if (Objects.isNull(param)) { + return null; + } + param.putAll(tempMap); + String valueStr = properties.getValue(); + Object value = null; + if (!StrUtil.isBlank(valueStr)) { + value = ScriptUtil.invokeScript(valueStr.trim(), param); + } + param.put(name, value); + return null; + } +} diff --git a/src/test/java/youhong/ai/mymapper/command/commandImpl/MyChooseCommand.java b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyChooseCommand.java new file mode 100644 index 0000000..85ccc92 --- /dev/null +++ b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyChooseCommand.java @@ -0,0 +1,101 @@ +package youhong.ai.mymapper.command.commandImpl; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import youhong.ai.mymapper.command.CommandExecutor; +import youhong.ai.mymapper.command.ISqlCommand; +import youhong.ai.mymapper.command.annotation.SqlCommand; +import youhong.ai.mymapper.command.constant.CommandConsTant; +import youhong.ai.mymapper.command.entity.MyWhenProperties; +import youhong.ai.mymapper.command.entity.SqlCommandDefinition; +import youhong.ai.mymapper.util.ParseSqlUtil; +import youhong.ai.mymapper.util.ScriptUtil; + +import java.util.*; + +/** + *

choose 指令

+ * + *

create: 2023/3/15 09:24

+ * + * @author youHong.ai + */ +@SqlCommand(CommandConsTant.CHOOSE) +public class MyChooseCommand implements ISqlCommand { + + private final List CHILDREN_LIST = Arrays.asList(CommandConsTant.WHEN, CommandConsTant.OTHERWISE); + + @Override + public String execute(SqlCommandDefinition sqlCommandDefinition) { + ParseSqlUtil parseSqlUtil = new ParseSqlUtil(); + String commandContent = sqlCommandDefinition.getCommandContent(); + List commandList = parseSqlUtil.getCommandList(commandContent); + if (CollectionUtil.isEmpty(commandList)) { + return null; + } + int otherwiseNum = 0; + SqlCommandDefinition otherWiseDefinition = null; + List commandListSort = new ArrayList<>(); + for (SqlCommandDefinition commandDefinition : commandList) { + if (!CHILDREN_LIST.contains(commandDefinition.getCommandType())) { + throw new CustomerException(Util.logStr("The command node of choose can only include {}, not {}", CHILDREN_LIST.toString(), commandDefinition.getCommandType())); + } + if (CommandConsTant.OTHERWISE.equals(commandDefinition.getCommandType())) { + otherwiseNum++; + otherWiseDefinition = commandDefinition; + continue; + } + commandListSort.add(commandDefinition); + } + if (otherwiseNum > 1) { + throw new CustomerException(CommandConsTant.OTHERWISE + " command has and can only have one!"); + } + if (!Objects.isNull(otherWiseDefinition)) { + commandListSort.add(otherWiseDefinition); + } + return extracted(commandListSort); + } + + /** + *

选择执行命令

+ * + * @param commandList 命令列表 + * @return 执行结果 + */ + private String extracted(List commandList) { + SqlCommandDefinition commandDefinition = null; + for (int i = 0; i < commandList.size(); i++) { + SqlCommandDefinition item = commandList.get(i); + String commandType = item.getCommandType(); + if (CommandConsTant.WHEN.equals(commandType)) { + MyWhenProperties properties = (MyWhenProperties) item.getProperties(); + String test = properties.getTest(); + if (StrUtil.isBlank(test)) { + throw new CustomerException("when command attribute of test can not blank!"); + } + Map tempMap = ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.get(); + Map param = ParseSqlUtil.PARSE_PARAM_LOCALE.get(); + if (Objects.isNull(param)) { + return null; + } + if (!Objects.isNull(tempMap)) { + param.putAll(tempMap); + } + boolean flag = (boolean) ScriptUtil.invokeScript(test, param); + if (flag) { + commandDefinition = item; + break; + } + } else { + commandDefinition = item; + } + } + if (Objects.isNull(commandDefinition)) { + return null; + } + CommandExecutor commandExecutor = new CommandExecutor(); + return commandExecutor.executor(commandDefinition); + } +} diff --git a/src/test/java/youhong/ai/mymapper/command/commandImpl/MyForCommand.java b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyForCommand.java index 834dbea..a855ea4 100644 --- a/src/test/java/youhong/ai/mymapper/command/commandImpl/MyForCommand.java +++ b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyForCommand.java @@ -2,6 +2,7 @@ package youhong.ai.mymapper.command.commandImpl; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import org.apache.commons.lang.StringUtils; import weaver.common.util.string.StringUtil; import youhong.ai.mymapper.command.ISqlCommand; @@ -186,22 +187,40 @@ public class MyForCommand implements ISqlCommand { return null; } StringBuilder sqlBuilder = new StringBuilder(); - String open = properties.getOpen(); - String close = properties.getClose(); - String separator = properties.getSeparator(); + String open = properties.getOpen() == null ? "" : properties.getOpen(); + String close = properties.getClose() == null ? "" : properties.getClose(); + String separator = properties.getSeparator() == null ? "" : properties.getSeparator(); sqlBuilder.append(open); int i = 0; + boolean hasTemp = false; for (Map.Entry entry : map.entrySet()) { Map tempParam = new HashMap<>(); tempParam.put(itemName, entry.getValue()); tempParam.put(indexName, entry.getKey()); - ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.set(tempParam); + Map tempParamLocale = ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.get(); + if (CollectionUtil.isEmpty(tempParamLocale)) { + ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.set(tempParam); + } else { + hasTemp = true; + for (Map.Entry tempEntry : tempParamLocale.entrySet()) { + if (tempParam.containsKey(tempEntry.getKey())) { + throw new CustomerException(Util.logStr("The variable of {} has been declared and cannot be declared again", tempEntry.getKey())); + } + } + tempParamLocale.putAll(tempParam); + } String parse = parseSqlUtil.parse(properties.getCommandContent()); - sqlBuilder.append(" ").append(parse); + sqlBuilder.append(" ").append(parse).append(" "); if (i < map.size() - 1) { sqlBuilder.append(separator); } - ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.remove(); + if (!hasTemp) { + ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.remove(); + } else { + for (Map.Entry tempEntry : tempParam.entrySet()) { + tempParamLocale.remove(tempEntry.getKey()); + } + } } sqlBuilder.append(close); return sqlBuilder.toString(); diff --git a/src/test/java/youhong/ai/mymapper/command/commandImpl/MyOtherwiseCommand.java b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyOtherwiseCommand.java new file mode 100644 index 0000000..cfc5b31 --- /dev/null +++ b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyOtherwiseCommand.java @@ -0,0 +1,27 @@ +package youhong.ai.mymapper.command.commandImpl; + +import youhong.ai.mymapper.command.ISqlCommand; +import youhong.ai.mymapper.command.annotation.SqlCommand; +import youhong.ai.mymapper.command.constant.CommandConsTant; +import youhong.ai.mymapper.command.entity.MyOtherwiseProperties; +import youhong.ai.mymapper.command.entity.SqlCommandDefinition; +import youhong.ai.mymapper.util.ParseSqlUtil; + +/** + *

otherwise 指令

+ * + *

create: 2023/3/15 09:24

+ * + * @author youHong.ai + */ + +@SqlCommand(CommandConsTant.OTHERWISE) +public class MyOtherwiseCommand implements ISqlCommand { + + @Override + public String execute(SqlCommandDefinition sqlCommandDefinition) { + MyOtherwiseProperties properties = (MyOtherwiseProperties) sqlCommandDefinition.getProperties(); + ParseSqlUtil parseSqlUtil = new ParseSqlUtil(); + return parseSqlUtil.parse(properties.getCommandContent()); + } +} diff --git a/src/test/java/youhong/ai/mymapper/command/commandImpl/MyWhenCommand.java b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyWhenCommand.java new file mode 100644 index 0000000..ede4577 --- /dev/null +++ b/src/test/java/youhong/ai/mymapper/command/commandImpl/MyWhenCommand.java @@ -0,0 +1,25 @@ +package youhong.ai.mymapper.command.commandImpl; + +import youhong.ai.mymapper.command.ISqlCommand; +import youhong.ai.mymapper.command.annotation.SqlCommand; +import youhong.ai.mymapper.command.constant.CommandConsTant; +import youhong.ai.mymapper.command.entity.MyWhenProperties; +import youhong.ai.mymapper.command.entity.SqlCommandDefinition; +import youhong.ai.mymapper.util.ParseSqlUtil; + +/** + *

when 指令

+ * + *

create: 2023/3/15 09:24

+ * + * @author youHong.ai + */ +@SqlCommand(CommandConsTant.WHEN) +public class MyWhenCommand implements ISqlCommand { + @Override + public String execute(SqlCommandDefinition sqlCommandDefinition) { + MyWhenProperties properties = (MyWhenProperties) sqlCommandDefinition.getProperties(); + ParseSqlUtil parseSqlUtil = new ParseSqlUtil(); + return parseSqlUtil.parse(properties.getCommandContent()); + } +} diff --git a/src/test/java/youhong/ai/mymapper/command/constant/CommandConsTant.java b/src/test/java/youhong/ai/mymapper/command/constant/CommandConsTant.java index 8044b79..27c0979 100644 --- a/src/test/java/youhong/ai/mymapper/command/constant/CommandConsTant.java +++ b/src/test/java/youhong/ai/mymapper/command/constant/CommandConsTant.java @@ -42,5 +42,8 @@ public class CommandConsTant { public static final String IF = "if"; public static final String TRIM = "trim"; - public static final String TEST = "@{"; + public static final String CHOOSE = "choose"; + public static final String WHEN = "when"; + public static final String OTHERWISE = "otherwise"; + public static final String BIND = "bind"; } diff --git a/src/test/java/youhong/ai/mymapper/command/entity/MyChooseProperties.java b/src/test/java/youhong/ai/mymapper/command/entity/MyChooseProperties.java new file mode 100644 index 0000000..df96c0d --- /dev/null +++ b/src/test/java/youhong/ai/mymapper/command/entity/MyChooseProperties.java @@ -0,0 +1,19 @@ +package youhong.ai.mymapper.command.entity; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import youhong.ai.mymapper.command.properties.AbstractCommandProperties; + +/** + *

+ * + *

create: 2023/3/15 10:10

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class MyChooseProperties extends AbstractCommandProperties { +} diff --git a/src/test/java/youhong/ai/mymapper/command/entity/MyOtherwiseProperties.java b/src/test/java/youhong/ai/mymapper/command/entity/MyOtherwiseProperties.java new file mode 100644 index 0000000..7a79bf4 --- /dev/null +++ b/src/test/java/youhong/ai/mymapper/command/entity/MyOtherwiseProperties.java @@ -0,0 +1,19 @@ +package youhong.ai.mymapper.command.entity; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import youhong.ai.mymapper.command.properties.AbstractCommandProperties; + +/** + *

+ * + *

create: 2023/3/15 10:12

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class MyOtherwiseProperties extends AbstractCommandProperties { +} diff --git a/src/test/java/youhong/ai/mymapper/command/entity/MyWhenProperties.java b/src/test/java/youhong/ai/mymapper/command/entity/MyWhenProperties.java new file mode 100644 index 0000000..94f9a30 --- /dev/null +++ b/src/test/java/youhong/ai/mymapper/command/entity/MyWhenProperties.java @@ -0,0 +1,21 @@ +package youhong.ai.mymapper.command.entity; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import youhong.ai.mymapper.command.properties.AbstractCommandProperties; + +/** + *

+ * + *

create: 2023/3/15 10:11

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class MyWhenProperties extends AbstractCommandProperties { + /** 表达式 */ + private String test; +} diff --git a/src/test/java/youhong/ai/mymapper/command/properties/MyBindProperties.java b/src/test/java/youhong/ai/mymapper/command/properties/MyBindProperties.java new file mode 100644 index 0000000..3d6ad7f --- /dev/null +++ b/src/test/java/youhong/ai/mymapper/command/properties/MyBindProperties.java @@ -0,0 +1,25 @@ +package youhong.ai.mymapper.command.properties; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + *

bind指令参数

+ * + *

create: 2023/3/15 12:10

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class MyBindProperties extends AbstractCommandProperties { + + /** 名字 */ + private String name; + + /** 绑定vale */ + private String value; + +} diff --git a/src/test/java/youhong/ai/mymapper/util/AbstractCommandPropertiesFactory.java b/src/test/java/youhong/ai/mymapper/util/AbstractCommandPropertiesFactory.java index f80a92b..dbceee9 100644 --- a/src/test/java/youhong/ai/mymapper/util/AbstractCommandPropertiesFactory.java +++ b/src/test/java/youhong/ai/mymapper/util/AbstractCommandPropertiesFactory.java @@ -2,6 +2,9 @@ package youhong.ai.mymapper.util; import aiyh.utils.annotation.MethodRuleNo; import youhong.ai.mymapper.command.constant.CommandConsTant; +import youhong.ai.mymapper.command.entity.MyChooseProperties; +import youhong.ai.mymapper.command.entity.MyOtherwiseProperties; +import youhong.ai.mymapper.command.entity.MyWhenProperties; import youhong.ai.mymapper.command.properties.*; import java.util.List; @@ -15,9 +18,7 @@ import java.util.List; */ public class AbstractCommandPropertiesFactory { - @MethodRuleNo(name = CommandConsTant.WHERE, desc = "where 指令参数解析") - private AbstractCommandProperties getWhereProperties(List commandItemList) { - AbstractCommandProperties commandProperties = new MyWhereProperties(); + private AbstractCommandProperties setValue(List commandItemList, AbstractCommandProperties commandProperties) { for (int i = 1; i < commandItemList.size(); i++) { String item = commandItemList.get(i); CommandPropUtil.setValueString(commandProperties, item); @@ -25,35 +26,44 @@ public class AbstractCommandPropertiesFactory { return commandProperties; } + @MethodRuleNo(name = CommandConsTant.WHERE, desc = "where 指令参数解析") + private AbstractCommandProperties getWhereProperties(List commandItemList) { + return this.setValue(commandItemList, new MyWhereProperties()); + } + @MethodRuleNo(name = CommandConsTant.FOR, desc = "for 指令参数解析") private AbstractCommandProperties getForProperties(List commandItemList) { - AbstractCommandProperties commandProperties = new MyForProperties(); - for (int i = 1; i < commandItemList.size(); i++) { - String item = commandItemList.get(i); - CommandPropUtil.setValueString(commandProperties, item); - } - return commandProperties; + return this.setValue(commandItemList, new MyForProperties()); } @MethodRuleNo(name = CommandConsTant.IF, desc = "if 指令参数解析") private AbstractCommandProperties getIfProperties(List commandItemList) { - AbstractCommandProperties commandProperties = new MyIfProperties(); - for (int i = 1; i < commandItemList.size(); i++) { - String item = commandItemList.get(i); - CommandPropUtil.setValueString(commandProperties, item); - } - return commandProperties; + return this.setValue(commandItemList, new MyIfProperties()); } - @MethodRuleNo(name = CommandConsTant.TRIM, desc = "tirm 指令参数解析") private AbstractCommandProperties getTrimProperties(List commandItemList) { - AbstractCommandProperties commandProperties = new MyTrimProperties(); - for (int i = 1; i < commandItemList.size(); i++) { - String item = commandItemList.get(i); - CommandPropUtil.setValueString(commandProperties, item); - } - return commandProperties; + return this.setValue(commandItemList, new MyTrimProperties()); } + @MethodRuleNo(name = CommandConsTant.CHOOSE, desc = "choose 指令参数解析") + private AbstractCommandProperties getChooseProperties(List commandItemList) { + return this.setValue(commandItemList, new MyChooseProperties()); + } + + @MethodRuleNo(name = CommandConsTant.WHEN, desc = "when 指令参数解析") + private AbstractCommandProperties getWhenProperties(List commandItemList) { + return this.setValue(commandItemList, new MyWhenProperties()); + } + + @MethodRuleNo(name = CommandConsTant.OTHERWISE, desc = "otherwise 指令参数解析") + private AbstractCommandProperties getOtherwiseProperties(List commandItemList) { + return this.setValue(commandItemList, new MyOtherwiseProperties()); + } + + + @MethodRuleNo(name = CommandConsTant.BIND, desc = "bind 指令参数解析") + private AbstractCommandProperties getBindProperties(List commandItemList) { + return this.setValue(commandItemList, new MyBindProperties()); + } } diff --git a/src/test/java/youhong/ai/mymapper/util/ParseSqlUtil.java b/src/test/java/youhong/ai/mymapper/util/ParseSqlUtil.java index a57a654..8fbd58b 100644 --- a/src/test/java/youhong/ai/mymapper/util/ParseSqlUtil.java +++ b/src/test/java/youhong/ai/mymapper/util/ParseSqlUtil.java @@ -2,6 +2,7 @@ package youhong.ai.mymapper.util; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import youhong.ai.mymapper.command.CommandExecutor; import youhong.ai.mymapper.command.constant.CommandConsTant; import youhong.ai.mymapper.command.entity.CommandContentDefinition; @@ -29,6 +30,13 @@ public class ParseSqlUtil { private final CommandExecutor commandExecutor = new CommandExecutor(); + /** + *

解析sql

+ * + * @param sql 需要解析的sql字符串 + * @param params sql所需要的参数 + * @return 解析后的sql数据 + */ public SqlDefinition parse(String sql, Map params) { if (!Objects.isNull(params)) { PARSE_PARAM_LOCALE.set(params); @@ -46,11 +54,19 @@ public class ParseSqlUtil { sqlDefinition.setArgs(sqlParams); SQL_PARAM_LOCALE.remove(); } + if (!Objects.isNull(PARSE_TEMP_PARAM_LOCALE.get())) { + PARSE_TEMP_PARAM_LOCALE.remove(); + } } - return sqlDefinition; } + /** + *

解析sql或sql片段

+ * + * @param sql sql + * @return 解析后sql + */ public String parse(String sql) { if (Objects.isNull(sql) || sql.isEmpty()) { throw new CustomerException("can not parse sql, sql is empty!"); @@ -64,6 +80,7 @@ public class ParseSqlUtil { for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (CommandConsTant.Skip_CHAR.contains(c)) { + sqlBuilder.append(" "); continue; } if (CommandConsTant.COMMAND_PRE_FIX_MARK == c) { @@ -74,7 +91,9 @@ public class ParseSqlUtil { sqlBuilder.delete(0, sqlBuilder.length()); sqlBuilder.append(tempSql); i += CommandConsTant.COMMAND_PRE_FIX.length + 1; + // 获取sql指令定义信息 SqlCommandDefinition commandDefinition = parseCommand(chars, i); + // 获取解析后的sql String commandContent = commandDefinition.getCommandContent(); sqlBuilder.append(Objects.isNull(commandContent) ? "" : commandContent); i += commandDefinition.getCommandLength(); @@ -92,6 +111,12 @@ public class ParseSqlUtil { return simpleSql(sqlStr); } + /** + *

简化sql,去除回车table键等字符

+ * + * @param sql 需要简化的sql + * @return 简化后的sql + */ public String simpleSql(String sql) { char[] chars = sql.toCharArray(); StringBuilder sqlBuilder = new StringBuilder(); @@ -99,6 +124,7 @@ public class ParseSqlUtil { for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (CommandConsTant.Skip_CHAR.contains(c)) { + sqlBuilder.append(" "); continue; } if (c == '\\') { @@ -128,6 +154,12 @@ public class ParseSqlUtil { return sqlBuilder.toString().trim(); } + /** + *

判断是否含有指令

+ * + * @param chars sql字符串char数组 + * @return 是否含有指令 + */ private boolean hasCommand(char[] chars) { for (int i = 0; i < chars.length; i++) { char c = chars[i]; @@ -138,6 +170,13 @@ public class ParseSqlUtil { return false; } + /** + *

检查是否存属于指令

+ * + * @param chars sql字符串char数组 + * @param index 开始下标 + * @return 是否属于指令 + */ private boolean checkCommand(char[] chars, int index) { if (index + CommandConsTant.COMMAND_PRE_FIX.length + 1 >= chars.length) { return false; @@ -150,13 +189,29 @@ public class ParseSqlUtil { return true; } + /** + *

解析sql指令

+ * + * @param chars sql字符串char数组 + * @param index 指令开始下标 + * @return sql指令定义信息 + */ private SqlCommandDefinition parseCommand(char[] chars, int index) { SqlCommandDefinition commandDefinition = getCommandDefinition(chars, index); + // 值执行器执行解析操作 String executor = commandExecutor.executor(commandDefinition); + // 解析后的sql设置为指令内容 commandDefinition.setCommandContent(executor); return commandDefinition; } + /** + *

获取指令定义信息

+ * + * @param chars sql字符串char数组 + * @param index 指令开始下标 + * @return 指令定义信息 + */ private SqlCommandDefinition getCommandDefinition(char[] chars, int index) { StringBuilder commandSb = new StringBuilder(); boolean isCommand = false; @@ -164,6 +219,7 @@ public class ParseSqlUtil { for (int i = index; i < chars.length; i++) { char c = chars[i]; if (CommandConsTant.Skip_CHAR.contains(c)) { + commandSb.append(" "); continue; } if (c == '\\') { @@ -190,6 +246,13 @@ public class ParseSqlUtil { return CommandUtil.createCommandProperties(command, commandContent); } + /** + *

获取指令内容

+ * + * @param chars sql字符串char数组 + * @param index 指令内容开始下标 + * @return 指令内容信息定义 + */ private CommandContentDefinition getCommandContent(char[] chars, int index) { int commandSyntaxCount = 0; StringBuilder commandContent = new StringBuilder(); @@ -198,6 +261,7 @@ public class ParseSqlUtil { char c = chars[i]; account++; if (CommandConsTant.Skip_CHAR.contains(c)) { + commandContent.append(" "); continue; } if (c == '\\') { @@ -238,6 +302,12 @@ public class ParseSqlUtil { } + /** + *

解析sql占位符,绑定值

+ * + * @param sql sql字符串 + * @return 解析后sql字符串 + */ public String parseStatement(String sql) { char[] chars = sql.toCharArray(); StringBuilder sqlBuilder = new StringBuilder(); @@ -287,6 +357,12 @@ public class ParseSqlUtil { return sqlBuilder.toString(); } + /** + *

获取变量的值,通过变量名

+ * + * @param variable 变量名 + * @return 变量值 + */ private Object getVariableValue(String variable) { variable = variable.trim(); Map tempMap = ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.get(); @@ -298,6 +374,14 @@ public class ParseSqlUtil { return value; } + /** + *

判断是否属于变量占位符

+ * + * @param chars sql字符串char数组 + * @param startIndex 开始下标 + * @param variablePrefix 变量前缀 + * @return 变量名称 + */ private String isVariable(char[] chars, int startIndex, String variablePrefix) { char[] prefix = variablePrefix.toCharArray(); StringBuilder sb = new StringBuilder(); @@ -326,4 +410,36 @@ public class ParseSqlUtil { } return null; } + + + /** + *

获取所有指令

+ * + * @param sql + * @return + */ + public List getCommandList(String sql) { + if (StrUtil.isBlank(sql)) { + return null; + } + List result = new ArrayList<>(); + char[] chars = sql.toCharArray(); + for (int i = 0; i < chars.length; i++) { + char c = chars[i]; + if (CommandConsTant.Skip_CHAR.contains(c)) { + continue; + } + if (CommandConsTant.COMMAND_PRE_FIX_MARK == c) { + boolean isCommand = checkCommand(chars, i); + if (isCommand) { + i += CommandConsTant.COMMAND_PRE_FIX.length + 1; + // 获取sql指令定义信息 + SqlCommandDefinition commandDefinition = getCommandDefinition(chars, i); + result.add(commandDefinition); + i += commandDefinition.getCommandLength(); + } + } + } + return result; + } } diff --git a/src/test/java/youhong/ai/yihong/YiHongTest.java b/src/test/java/youhong/ai/yihong/YiHongTest.java new file mode 100644 index 0000000..4539fa9 --- /dev/null +++ b/src/test/java/youhong/ai/yihong/YiHongTest.java @@ -0,0 +1,26 @@ +package youhong.ai.yihong; + +import aiyh.utils.Util; +import basetest.BaseTest; +import com.alibaba.fastjson.JSON; +import org.junit.Test; +import weaver.youhong.ai.yihong.formmode.stagediagram.mapper.ModeExpandSaveActionMapper; +import weaver.youhong.ai.yihong.formmode.stagediagram.pojo.StageUpdateFieldConfig; + +/** + *

屹宏测试

+ * + *

create: 2023/3/14 18:31

+ * + * @author youHong.ai + */ +public class YiHongTest extends BaseTest { + + + @Test + public void testSelectMapper() { + ModeExpandSaveActionMapper mapper = Util.getMapper(ModeExpandSaveActionMapper.class); + StageUpdateFieldConfig testWrite = mapper.selectConfigUpdate("test_write"); + System.out.println(JSON.toJSONString(testWrite)); + } +}