first commit

This commit is contained in:
“FiboAI”
2021-12-02 18:33:17 +08:00
parent 49016794cc
commit 70fb3743ee
312 changed files with 30833 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
package com.baoying.enginex.executor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableTransactionManagement
@MapperScan("com.baoying.enginex.executor.*.mapper")
@ComponentScan(basePackages = "com.baoying.enginex.executor.**")
public class JarEnginexRunnerApplication {
public static void main(String[] args) {
SpringApplication.run(JarEnginexRunnerApplication.class, args);
}
}

View File

@@ -0,0 +1,119 @@
package com.baoying.enginex.executor.canal;
import com.baoying.enginex.executor.datamanage.mapper.SimpleMapper;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/cache")
public class CacheController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
private SimpleMapper simpleMapper;
@Autowired
private RedisManager redisManager;
@RequestMapping(value = "initCache", method = RequestMethod.GET)
public void initCache() {
logger.info("===================== 缓存初始化开始 =====================");
long start = System.currentTimeMillis();
// 遍历表
for (TableEnum tableEnum : TableEnum.values()) {
String tableName = tableEnum.getTableName();
logger.info("===================== 开始初始化缓存表[{}] =====================", tableName);
String sqlStr = "select * from " + tableName;
Map<String, Object> parameterMap = new HashMap<>();
parameterMap.put("sqlStr", sqlStr);
List<LinkedHashMap<String, Object>> result = simpleMapper.customSelect(parameterMap);
// 遍历行
for (LinkedHashMap<String, Object> map : result) {
row(tableEnum, map);
}
logger.info("===================== 结束初始化缓存表[{}],共[{}]条数据 =====================", tableName, result.size());
}
long end = System.currentTimeMillis();
logger.info("===================== 缓存初始化成功!!耗时:{}ms =====================", (end - start));
}
private void row(TableEnum tableEnum, LinkedHashMap<String, Object> map) {
String tableName = tableEnum.getTableName();
String primaryKey = null;
String foreignKey = null;
if (StringUtils.isNotBlank(tableEnum.getPrimaryId())) {
String primaryId = map.get(tableEnum.getPrimaryId()).toString();
primaryKey = RedisUtils.getPrimaryKey(tableName, primaryId);
}
if (StringUtils.isNotBlank(tableEnum.getForeignId())) {
Object obj = map.get(tableEnum.getForeignId());
if (obj != null && !"".equals(obj.toString())) {
String foreignId = obj.toString();
foreignKey = RedisUtils.getForeignKey(tableName, foreignId);
}
}
if (StringUtils.isNotBlank(primaryKey)) {
// 遍历列
for (String field : map.keySet()) {
String value = map.get(field) == null ? null : map.get(field).toString();
setColumnCache(primaryKey, field, value);
}
}
if (StringUtils.isNotBlank(foreignKey)) {
setForeignKeyCache(primaryKey, foreignKey);
}
// 指标表特殊处理
dealSpecialTable(tableName, map);
}
private void setColumnCache(String primaryKey, String field, String value) {
logger.info("开始主键缓存设置, primaryKey:{}, field:{}, value:{}", primaryKey, field, value);
redisManager.hset(primaryKey, field, value);
logger.info("结束主键缓存设置, primaryKey:{}, field:{}, value:{}", primaryKey, field, value);
}
private void setForeignKeyCache(String primaryKey, String foreignKey) {
logger.info("开始外键缓存设置, primaryKey:{}, foreignKey:{}", primaryKey, foreignKey);
redisManager.sadd(foreignKey, primaryKey);
logger.info("结束外键缓存设置, primaryKey:{}, foreignKey:{}", primaryKey, foreignKey);
}
private void dealSpecialTable(String tableName, LinkedHashMap<String, Object> map) {
if(tableName.equals(TableEnum.T_FIELD.getTableName())){
String fieldEn = "field_en:" + map.get("organ_id") + ":" + map.get("field_en");
String fieldEnKey = RedisUtils.getPrimaryKey(tableName, fieldEn);
String fieldCn = "field_cn:" + map.get("organ_id") + ":" + map.get("field_cn");
String fieldCnKey = RedisUtils.getPrimaryKey(tableName, fieldCn);
for (String field : map.keySet()) {
String value = map.get(field) == null ? null : map.get(field).toString();
setColumnCache(fieldEnKey, field, value);
setColumnCache(fieldCnKey, field, value);
}
}
}
}

View File

@@ -0,0 +1,246 @@
package com.baoying.enginex.executor.canal;
import com.alibaba.otter.canal.client.CanalConnector;
import com.alibaba.otter.canal.client.CanalConnectors;
import com.alibaba.otter.canal.protocol.CanalEntry;
import com.alibaba.otter.canal.protocol.Message;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Optional;
/**
* Canal数据同步
* 实现ApplicationRunner接口springboot启动成功后会执行run方法
*/
@Component
public class CanalClient implements ApplicationRunner {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final static int BATCH_SIZE = 1000;
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Override
public void run(ApplicationArguments args) throws Exception {
if(Constants.switchFlag.OFF.equals(configHolder.getCanalCacheSwitch())){
return;
}
// 创建链接
CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress(configHolder.getCanalHostName(), configHolder.getCanalPort()),
"example", "", "");
try {
//打开连接
connector.connect();
//订阅数据库表,全部表
connector.subscribe(".*\\..*");
//回滚到未进行ack的地方下次fetch的时候可以从最后一个没有ack的地方开始拿
connector.rollback();
while (true) {
logger.info("canal数据同步监听中...");
// 获取指定数量的数据
Message message = connector.getWithoutAck(BATCH_SIZE);
//获取批量ID
long batchId = message.getId();
//获取批量的数量
int size = message.getEntries().size();
//如果没有数据
if (batchId == -1 || size == 0) {
try {
//线程休眠2秒
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
//如果有数据,处理数据
printEntry(message.getEntries());
}
//进行 batch id 的确认。确认之后,小于等于此 batchId 的 Message 都会被确认。
connector.ack(batchId);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
connector.disconnect();
}
}
/**
* 解析binlog获得的实体类信息
*/
private void printEntry(List<CanalEntry.Entry> entrys) {
for (CanalEntry.Entry entry : entrys) {
if (entry.getEntryType() == CanalEntry.EntryType.TRANSACTIONBEGIN || entry.getEntryType() == CanalEntry.EntryType.TRANSACTIONEND) {
//开启/关闭事务的实体类型,跳过
continue;
}
String tableName = entry.getHeader().getTableName();
TableEnum tableEnum = TableEnum.getByTableName(tableName);
if(tableEnum == null){
// 没有在枚举中定义的表,跳过
continue;
}
//RowChange对象包含了一行数据变化的所有特征
//比如isDdl 是否是ddl变更操作 sql 具体的ddl sql beforeColumns afterColumns 变更前后的数据字段等等
CanalEntry.RowChange rowChage;
try {
rowChage = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
} catch (Exception e) {
throw new RuntimeException("ERROR ## parser of eromanga-event has an error , data:" + entry.toString(), e);
}
//获取操作类型insert/update/delete类型
CanalEntry.EventType eventType = rowChage.getEventType();
//打印Header信息
logger.info(String.format("============= binlog[%s:%s] , name[%s,%s] , eventType : %s =============",
entry.getHeader().getLogfileName(), entry.getHeader().getLogfileOffset(),
entry.getHeader().getSchemaName(), entry.getHeader().getTableName(),
eventType));
//判断是否是DDL语句
if (rowChage.getIsDdl()) {
logger.info("============= isDdl: true,sql:" + rowChage.getSql());
}
//获取RowChange对象里的每一行数据
for (CanalEntry.RowData rowData : rowChage.getRowDatasList()) {
//如果是删除语句
if (eventType == CanalEntry.EventType.DELETE) {
row(rowData.getBeforeColumnsList(), tableName);
//如果是新增语句
} else if (eventType == CanalEntry.EventType.INSERT) {
row(rowData.getAfterColumnsList(), tableName);
//如果是更新的语句
} else {
//变更前的数据
// printColumn(rowData.getBeforeColumnsList(), tableName);
//变更后的数据
row(rowData.getAfterColumnsList(), tableName);
}
}
}
}
private void row(List<CanalEntry.Column> columns, String tableName) {
Optional<CanalEntry.Column> keyColumn = columns.stream().filter(item -> item.getIsKey()).findFirst();
if(keyColumn.isPresent()){
// 获取主键id
String id = keyColumn.get().getValue();
// 拼接主键key
String key = RedisUtils.getPrimaryKey(tableName, id);
// 拼接外键key
String foreignKey = null;
// 子表的redis key需要拼接上主表的id
TableEnum tableEnum = TableEnum.getByTableName(tableName);
if(tableEnum != null){
Optional<CanalEntry.Column> foreignKeyColumn = columns.stream().filter(item -> item.getName().equals(tableEnum.getForeignId())).findFirst();
if(foreignKeyColumn.isPresent()){
String foreignKeyValue = foreignKeyColumn.get().getValue();
foreignKey = RedisUtils.getForeignKey(tableName, foreignKeyValue);
}
}
for (CanalEntry.Column column : columns) {
// 更新发生改变的字段缓存
setUpdatedColumnCache(column, key, foreignKey);
}
// 指标表特殊处理
dealSpecialTable(columns, tableName);
}
}
private void setUpdatedColumnCache(CanalEntry.Column column, String key, String foreignKey){
if(column.getUpdated()) {
logger.info("开始主键缓存更新, {}, {}, {}", key, column.getName(), column.getValue());
redisManager.hset(key, column.getName(), column.getValue());
logger.info("结束主键缓存更新, {}, {}, {}", key, column.getName(), column.getValue());
if(foreignKey != null){
logger.info("开始外键缓存更新, {}, {}", key, foreignKey);
redisManager.sadd(foreignKey, key);
logger.info("结束外键缓存更新, {}, {}", key, foreignKey);
}
}
}
private void setAllColumnCache(CanalEntry.Column column, String key){
logger.info("开始主键缓存更新, {}, {}, {}", key, column.getName(), column.getValue());
redisManager.hset(key, column.getName(), column.getValue());
logger.info("结束主键缓存更新, {}, {}, {}", key, column.getName(), column.getValue());
}
private void dealSpecialTable(List<CanalEntry.Column> columns, String tableName){
if(tableName.equals(TableEnum.T_FIELD.getTableName())){
String organ_id = null;
String field_en = null;
String field_cn = null;
for (CanalEntry.Column column : columns) {
String name = column.getName();
switch (name) {
case "organ_id":
organ_id = column.getValue();
break;
case "field_en":
field_en = column.getValue();
break;
case "field_cn":
field_cn = column.getValue();
break;
default:
break;
}
}
String fieldEn = "field_en:" + organ_id + ":" + field_en;
String fieldEnKey = RedisUtils.getPrimaryKey(tableName, fieldEn);
String fieldCn = "field_cn:" + organ_id + ":" + field_cn;
String fieldCnKey = RedisUtils.getPrimaryKey(tableName, fieldCn);
// 如果field_en或field_cn发生变化则对应的key为新生成的需要保存所有字段缓存
Optional<CanalEntry.Column> fieldEnOptional = columns.stream().filter(item -> item.getName().equals("field_en") && item.getUpdated()).findFirst();
Optional<CanalEntry.Column> fieldCnOptional = columns.stream().filter(item -> item.getName().equals("field_cn") && item.getUpdated()).findFirst();
for (CanalEntry.Column column : columns) {
if(fieldEnOptional.isPresent()){
// 更新所有字段缓存
setAllColumnCache(column, fieldEnKey);
} else {
// 更新发生改变的字段缓存
setUpdatedColumnCache(column, fieldEnKey, null);
}
if(fieldCnOptional.isPresent()){
setAllColumnCache(column, fieldCnKey);
} else {
setUpdatedColumnCache(column, fieldCnKey, null);
}
}
}
}
}

View File

@@ -0,0 +1,77 @@
package com.baoying.enginex.executor.canal;
/**
* 缓存数据同步表
*/
public enum TableEnum {
/**
* 引擎
*/
T_ENGINE("t_engine", "id", ""),
T_ENGINE_VERSION("t_engine_version", "version_id", "engine_id"),
T_ENGINE_NODE("t_engine_node", "node_id", "version_id"),
/**
* 指标
*/
T_FIELD("t_field", "id", ""),
T_FIELD_INTERFACE("t_field_interface", "id", ""),
T_FIELD_DATA_SOURCE("t_field_data_source", "id", ""),
/**
* 规则
*/
T_RULE("t_rule", "id", ""),
T_RULE_VERSION("t_rule_version", "id", "rule_id"),
T_RULE_CONDITION("t_rule_condition", "id", "version_id"),
T_RULE_LOOP_GROUP_ACTION("t_rule_loop_group_action", "id", "condition_for_id"),
T_RULE_FIELD("t_rule_field", "id", "rule_id"),
/**
* 策略输出
*/
T_TACTICS_OUTPUT("t_tactics_output", "id", "tactics_id");
private String tableName;
private String primaryId;
private String foreignId;
TableEnum(String tableName, String primaryId, String foreignId) {
this.tableName = tableName;
this.primaryId = primaryId;
this.foreignId = foreignId;
}
public static TableEnum getByTableName(String tableName) {
for (TableEnum tableEnum : TableEnum.values()) {
if (tableName.equals(tableEnum.getTableName())) {
return tableEnum;
}
}
return null;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getPrimaryId() {
return primaryId;
}
public void setPrimaryId(String primaryId) {
this.primaryId = primaryId;
}
public String getForeignId() {
return foreignId;
}
public void setForeignId(String foreignId) {
this.foreignId = foreignId;
}
}

View File

@@ -0,0 +1,17 @@
package com.baoying.enginex.executor.common.basefactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public final class CustomBeanFactory {
public static ApplicationContext getContext() {
final String[] applicationXML = { "applicationContext.xml"};
ApplicationContext context = getSpringContext(applicationXML);
return context;
}
public static ApplicationContext getSpringContext(String[] paths) {
return new ClassPathXmlApplicationContext(paths);
}
}

View File

@@ -0,0 +1,31 @@
package com.baoying.enginex.executor.common.constants;
public class CommonConst {
/**
* 逗号
*/
public static final String SYMBOL_COMMA = ",";
/**
* 单引号
*/
public static final String SYMBOL_SINGLE_QUOTA = "\'";
/**
* 空格
*/
public static final String SYMBOL_BLANK = " ";
/**
* 空字符串
*/
public static final String STRING_EMPTY = "";
/**
* 30分钟(s)
* */
public static final long MINUTE_30 = 1800000;
public static String DROOLS_KSESSION_KEY_PREFIX = "DROOLS_KSESSION#";
}

View File

@@ -0,0 +1,30 @@
package com.baoying.enginex.executor.common.constants;
/**
* 公共变量约定
*/
public class Constants {
// 规则集节点相关常量
public interface ruleNode {
// 互斥组(串行)
int MUTEXGROUP = 1;
// 执行组(并行)
int EXECUTEGROUP = 2;
}
public interface switchFlag {
// 开关打开
String ON = "on";
// 开关关闭
String OFF = "off";
}
public interface fieldName {
// 字段英文名
String fieldEn = "field_en";
//字段中文名
String fieldCn = "field_cn";
}
}

View File

@@ -0,0 +1,10 @@
package com.baoying.enginex.executor.common.constants;
public class ParamTypeConst {
public static final int CONSTANT = 1;
public static final int VARIABLE = 2;
public static final int CUSTOM = 3;
public static final int REGEX = 4;
}

View File

@@ -0,0 +1,60 @@
package com.baoying.enginex.executor.common.ksession;
import com.baoying.enginex.executor.redis.RedisManager;
import org.apache.commons.pool2.BaseKeyedPooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.*;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* kSession工厂类
*/
@Component
public class KSessionFactory extends BaseKeyedPooledObjectFactory<String, StatefulKnowledgeSession> {
@Autowired
private RedisManager redisManager;
@Override
public StatefulKnowledgeSession create(String key) throws Exception {
StatefulKnowledgeSession kSession = null;
try {
String ruleString = redisManager.get(key);
if(ruleString == null){
throw new Exception("create kSession fail, key is "+ key + ", ruleString is null");
}
long start = System.currentTimeMillis();
KnowledgeBuilder kb = KnowledgeBuilderFactory.newKnowledgeBuilder();
kb.add(ResourceFactory.newByteArrayResource(ruleString.getBytes("utf-8")), ResourceType.DRL);
KnowledgeBuilderErrors errors = kb.getErrors();
for (KnowledgeBuilderError error : errors) {
System.out.println(error);
}
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages(kb.getKnowledgePackages());
kSession = kBase.newStatefulKnowledgeSession();
long end = System.currentTimeMillis();
System.out.println("------------------drools kSession创建耗时" + (end - start) + " ----------------------");
} catch (Exception e) {
throw e;
}
return kSession;
}
@Override
public PooledObject<StatefulKnowledgeSession> wrap(StatefulKnowledgeSession kSession) {
return new DefaultPooledObject<StatefulKnowledgeSession>(kSession);
}
public void setRedisManager(RedisManager redisManager) {
this.redisManager = redisManager;
}
}

View File

@@ -0,0 +1,67 @@
package com.baoying.enginex.executor.common.ksession;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.drools.runtime.StatefulKnowledgeSession;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* kSession连接池
*/
@Component
public class KSessionPool implements InitializingBean {
private GenericKeyedObjectPool<String, StatefulKnowledgeSession> pool;
@Autowired
private KSessionFactory kSessionFactory;
/**
* 初始化方法
* @throws Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
initPool();
}
/**
* 初始化连接池
* @return
* @throws Exception
*/
public void initPool() throws Exception {
GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setMaxTotalPerKey(200);
poolConfig.setMaxIdlePerKey(50);
poolConfig.setMinIdlePerKey(5);
poolConfig.setMaxTotal(2000);
this.pool = new GenericKeyedObjectPool(kSessionFactory, poolConfig);
}
/**
* 获取一个连接对象
* @return
* @throws Exception
*/
public StatefulKnowledgeSession borrowObject(String key) throws Exception {
return pool.borrowObject(key);
}
/**
* 归还一个连接对象
* @param ftpClient
*/
public void returnObject(String key, StatefulKnowledgeSession kSession) {
if(kSession != null){
pool.returnObject(key, kSession);
}
}
public void setkSessionFactory(KSessionFactory kSessionFactory) {
this.kSessionFactory = kSessionFactory;
}
}

View File

@@ -0,0 +1,55 @@
package com.baoying.enginex.executor.common.mapper;
import java.util.List;
public abstract interface BaseMapper<IdEntity> {
/**
* @Description: 根据对象删除数据
* @param entity 对象
* @return 是否删除成功
*/
int deleteByExample(IdEntity entity);
/**
* @Description: 根据对象主键ID删除数据
* @param id 对象id编号
* @return 是否删除成功
*/
int deleteByPrimaryKey(Long id);
/**
* @Description: 插入一条新的数据
* @param entity 对象
* @return 是否插入成功
*/
int insertSelective(IdEntity entity);
/**
* @Description: 根据对象主键更新对象信息
* @param entity 对象
* @return 是否修改成功标志
*/
int updateByPrimaryKeySelective(IdEntity entity);
/**
* @Description: 根据对象获取数据条数
* @param entity 对象
* @return 返回行数
*/
int countByExample(IdEntity entity);
/**
* @Description: 根据对象主键ID获取指定数据多个
* @param entity 对象
* @return 对象列表
*/
List<IdEntity> selectByExample(IdEntity entity);
/**
* @Description: 根据对象主键ID获取指定数据单个
* @param id id编号
* @return 返回单个对象
*/
IdEntity selectByPrimaryKey(Long id);
}

View File

@@ -0,0 +1,39 @@
package com.baoying.enginex.executor.common.mapper;
import com.baoying.enginex.executor.common.model.EmailTemplate;
import com.baoying.enginex.executor.common.model.EmailTemplateExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface EmailTemplateMapper {
long countByExample(EmailTemplateExample example);
int deleteByExample(EmailTemplateExample example);
int deleteByPrimaryKey(Integer templateId);
int insert(EmailTemplate record);
int insertSelective(EmailTemplate record);
List<EmailTemplate> selectByExampleWithBLOBs(EmailTemplateExample example);
List<EmailTemplate> selectByExample(EmailTemplateExample example);
EmailTemplate selectByPrimaryKey(Integer templateId);
int updateByExampleSelective(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);
int updateByExampleWithBLOBs(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);
int updateByExample(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);
int updateByPrimaryKeySelective(EmailTemplate record);
int updateByPrimaryKeyWithBLOBs(EmailTemplate record);
int updateByPrimaryKey(EmailTemplate record);
EmailTemplate selectTemplateByNid(String nid);
}

View File

@@ -0,0 +1,345 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.common.mapper.EmailTemplateMapper">
<resultMap id="BaseResultMap" type="com.baoying.enginex.executor.common.model.EmailTemplate">
<constructor>
<idArg column="template_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="subject" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="nid" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="status" javaType="java.lang.Byte" jdbcType="TINYINT" />
<arg column="address" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="use_type" javaType="java.lang.Byte" jdbcType="TINYINT" />
<arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
<arg column="update_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
</constructor>
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.baoying.enginex.executor.common.model.EmailTemplate">
<constructor>
<idArg column="template_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="subject" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="nid" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="status" javaType="java.lang.Byte" jdbcType="TINYINT" />
<arg column="address" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="use_type" javaType="java.lang.Byte" jdbcType="TINYINT" />
<arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
<arg column="update_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
<arg column="content" javaType="java.lang.String" jdbcType="LONGVARCHAR" />
</constructor>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
template_id, subject, nid, status, address, use_type, create_time, update_time
</sql>
<sql id="Blob_Column_List">
content
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.baoying.enginex.executor.common.model.EmailTemplateExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_email_template
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.baoying.enginex.executor.common.model.EmailTemplateExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_email_template
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_email_template
where template_id = #{templateId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from t_email_template
where template_id = #{templateId,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.baoying.enginex.executor.common.model.EmailTemplateExample">
delete from t_email_template
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
insert into t_email_template (template_id, subject, nid,
status, address, use_type,
create_time, update_time, content
)
values (#{templateId,jdbcType=INTEGER}, #{subject,jdbcType=VARCHAR}, #{nid,jdbcType=VARCHAR},
#{status,jdbcType=TINYINT}, #{address,jdbcType=VARCHAR}, #{useType,jdbcType=TINYINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
insert into t_email_template
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="templateId != null">
template_id,
</if>
<if test="subject != null">
subject,
</if>
<if test="nid != null">
nid,
</if>
<if test="status != null">
status,
</if>
<if test="address != null">
address,
</if>
<if test="useType != null">
use_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="templateId != null">
#{templateId,jdbcType=INTEGER},
</if>
<if test="subject != null">
#{subject,jdbcType=VARCHAR},
</if>
<if test="nid != null">
#{nid,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="useType != null">
#{useType,jdbcType=TINYINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.baoying.enginex.executor.common.model.EmailTemplateExample" resultType="java.lang.Long">
select count(*) from t_email_template
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_email_template
<set>
<if test="record.templateId != null">
template_id = #{record.templateId,jdbcType=INTEGER},
</if>
<if test="record.subject != null">
subject = #{record.subject,jdbcType=VARCHAR},
</if>
<if test="record.nid != null">
nid = #{record.nid,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=TINYINT},
</if>
<if test="record.address != null">
address = #{record.address,jdbcType=VARCHAR},
</if>
<if test="record.useType != null">
use_type = #{record.useType,jdbcType=TINYINT},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update t_email_template
set template_id = #{record.templateId,jdbcType=INTEGER},
subject = #{record.subject,jdbcType=VARCHAR},
nid = #{record.nid,jdbcType=VARCHAR},
status = #{record.status,jdbcType=TINYINT},
address = #{record.address,jdbcType=VARCHAR},
use_type = #{record.useType,jdbcType=TINYINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_email_template
set template_id = #{record.templateId,jdbcType=INTEGER},
subject = #{record.subject,jdbcType=VARCHAR},
nid = #{record.nid,jdbcType=VARCHAR},
status = #{record.status,jdbcType=TINYINT},
address = #{record.address,jdbcType=VARCHAR},
use_type = #{record.useType,jdbcType=TINYINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
update t_email_template
<set>
<if test="subject != null">
subject = #{subject,jdbcType=VARCHAR},
</if>
<if test="nid != null">
nid = #{nid,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="useType != null">
use_type = #{useType,jdbcType=TINYINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where template_id = #{templateId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
update t_email_template
set subject = #{subject,jdbcType=VARCHAR},
nid = #{nid,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
address = #{address,jdbcType=VARCHAR},
use_type = #{useType,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
content = #{content,jdbcType=LONGVARCHAR}
where template_id = #{templateId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
update t_email_template
set subject = #{subject,jdbcType=VARCHAR},
nid = #{nid,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
address = #{address,jdbcType=VARCHAR},
use_type = #{useType,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where template_id = #{templateId,jdbcType=INTEGER}
</update>
<select id="selectTemplateByNid" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_email_template
where nid = #{nid}
</select>
</mapper>

View File

@@ -0,0 +1,81 @@
package com.baoying.enginex.executor.common.model;
public class BasePage {
/**
* 当前页数
*/
private int page;
/**
* 每页显示的行数
*/
private int rows;
/**
* 开始行数
*/
private Integer curRow;
/**
* 结束行数
*/
private Integer endRow;
/**
* 总行数
*/
private Integer total;
public BasePage() {
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
/**
* setPagination:(设置当前页面和每页显示行数). <br/>
* @author wz
* @param page 当前页数
* @param rows 每页显示的行数
*/
public void setPagination(int page,int rows){
this.page = page;
this.rows = rows;
this.curRow = (page-1)*rows;
this.endRow = (page)*rows;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getRows() {
return rows;
}
public void setRows(int rows) {
this.rows = rows;
}
public void setCurRow(Integer curRow) {
this.curRow = curRow;
}
public void setEndRow(Integer endRow) {
this.endRow = endRow;
}
}

View File

@@ -0,0 +1,122 @@
package com.baoying.enginex.executor.common.model;
import java.util.Date;
public class EmailTemplate {
private Integer templateId;
private String subject;
private String nid;
private Byte status;
private String address;
private Byte useType;
private Date createTime;
private Date updateTime;
private String content;
public EmailTemplate(Integer templateId, String subject, String nid, Byte status, String address, Byte useType, Date createTime, Date updateTime) {
this.templateId = templateId;
this.subject = subject;
this.nid = nid;
this.status = status;
this.address = address;
this.useType = useType;
this.createTime = createTime;
this.updateTime = updateTime;
}
public EmailTemplate(Integer templateId, String subject, String nid, Byte status, String address, Byte useType, Date createTime, Date updateTime, String content) {
this.templateId = templateId;
this.subject = subject;
this.nid = nid;
this.status = status;
this.address = address;
this.useType = useType;
this.createTime = createTime;
this.updateTime = updateTime;
this.content = content;
}
public EmailTemplate() {
super();
}
public Integer getTemplateId() {
return templateId;
}
public void setTemplateId(Integer templateId) {
this.templateId = templateId;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject == null ? null : subject.trim();
}
public String getNid() {
return nid;
}
public void setNid(String nid) {
this.nid = nid == null ? null : nid.trim();
}
public Byte getStatus() {
return status;
}
public void setStatus(Byte status) {
this.status = status;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public Byte getUseType() {
return useType;
}
public void setUseType(Byte useType) {
this.useType = useType;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
}

View File

@@ -0,0 +1,711 @@
package com.baoying.enginex.executor.common.model;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class EmailTemplateExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public EmailTemplateExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andTemplateIdIsNull() {
addCriterion("template_id is null");
return (Criteria) this;
}
public Criteria andTemplateIdIsNotNull() {
addCriterion("template_id is not null");
return (Criteria) this;
}
public Criteria andTemplateIdEqualTo(Integer value) {
addCriterion("template_id =", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdNotEqualTo(Integer value) {
addCriterion("template_id <>", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdGreaterThan(Integer value) {
addCriterion("template_id >", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdGreaterThanOrEqualTo(Integer value) {
addCriterion("template_id >=", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdLessThan(Integer value) {
addCriterion("template_id <", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdLessThanOrEqualTo(Integer value) {
addCriterion("template_id <=", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdIn(List<Integer> values) {
addCriterion("template_id in", values, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdNotIn(List<Integer> values) {
addCriterion("template_id not in", values, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdBetween(Integer value1, Integer value2) {
addCriterion("template_id between", value1, value2, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdNotBetween(Integer value1, Integer value2) {
addCriterion("template_id not between", value1, value2, "templateId");
return (Criteria) this;
}
public Criteria andSubjectIsNull() {
addCriterion("subject is null");
return (Criteria) this;
}
public Criteria andSubjectIsNotNull() {
addCriterion("subject is not null");
return (Criteria) this;
}
public Criteria andSubjectEqualTo(String value) {
addCriterion("subject =", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotEqualTo(String value) {
addCriterion("subject <>", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectGreaterThan(String value) {
addCriterion("subject >", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectGreaterThanOrEqualTo(String value) {
addCriterion("subject >=", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLessThan(String value) {
addCriterion("subject <", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLessThanOrEqualTo(String value) {
addCriterion("subject <=", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLike(String value) {
addCriterion("subject like", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotLike(String value) {
addCriterion("subject not like", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectIn(List<String> values) {
addCriterion("subject in", values, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotIn(List<String> values) {
addCriterion("subject not in", values, "subject");
return (Criteria) this;
}
public Criteria andSubjectBetween(String value1, String value2) {
addCriterion("subject between", value1, value2, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotBetween(String value1, String value2) {
addCriterion("subject not between", value1, value2, "subject");
return (Criteria) this;
}
public Criteria andNidIsNull() {
addCriterion("nid is null");
return (Criteria) this;
}
public Criteria andNidIsNotNull() {
addCriterion("nid is not null");
return (Criteria) this;
}
public Criteria andNidEqualTo(String value) {
addCriterion("nid =", value, "nid");
return (Criteria) this;
}
public Criteria andNidNotEqualTo(String value) {
addCriterion("nid <>", value, "nid");
return (Criteria) this;
}
public Criteria andNidGreaterThan(String value) {
addCriterion("nid >", value, "nid");
return (Criteria) this;
}
public Criteria andNidGreaterThanOrEqualTo(String value) {
addCriterion("nid >=", value, "nid");
return (Criteria) this;
}
public Criteria andNidLessThan(String value) {
addCriterion("nid <", value, "nid");
return (Criteria) this;
}
public Criteria andNidLessThanOrEqualTo(String value) {
addCriterion("nid <=", value, "nid");
return (Criteria) this;
}
public Criteria andNidLike(String value) {
addCriterion("nid like", value, "nid");
return (Criteria) this;
}
public Criteria andNidNotLike(String value) {
addCriterion("nid not like", value, "nid");
return (Criteria) this;
}
public Criteria andNidIn(List<String> values) {
addCriterion("nid in", values, "nid");
return (Criteria) this;
}
public Criteria andNidNotIn(List<String> values) {
addCriterion("nid not in", values, "nid");
return (Criteria) this;
}
public Criteria andNidBetween(String value1, String value2) {
addCriterion("nid between", value1, value2, "nid");
return (Criteria) this;
}
public Criteria andNidNotBetween(String value1, String value2) {
addCriterion("nid not between", value1, value2, "nid");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("status is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("status is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(Byte value) {
addCriterion("status =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(Byte value) {
addCriterion("status <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(Byte value) {
addCriterion("status >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(Byte value) {
addCriterion("status >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(Byte value) {
addCriterion("status <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(Byte value) {
addCriterion("status <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<Byte> values) {
addCriterion("status in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<Byte> values) {
addCriterion("status not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(Byte value1, Byte value2) {
addCriterion("status between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(Byte value1, Byte value2) {
addCriterion("status not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andAddressIsNull() {
addCriterion("address is null");
return (Criteria) this;
}
public Criteria andAddressIsNotNull() {
addCriterion("address is not null");
return (Criteria) this;
}
public Criteria andAddressEqualTo(String value) {
addCriterion("address =", value, "address");
return (Criteria) this;
}
public Criteria andAddressNotEqualTo(String value) {
addCriterion("address <>", value, "address");
return (Criteria) this;
}
public Criteria andAddressGreaterThan(String value) {
addCriterion("address >", value, "address");
return (Criteria) this;
}
public Criteria andAddressGreaterThanOrEqualTo(String value) {
addCriterion("address >=", value, "address");
return (Criteria) this;
}
public Criteria andAddressLessThan(String value) {
addCriterion("address <", value, "address");
return (Criteria) this;
}
public Criteria andAddressLessThanOrEqualTo(String value) {
addCriterion("address <=", value, "address");
return (Criteria) this;
}
public Criteria andAddressLike(String value) {
addCriterion("address like", value, "address");
return (Criteria) this;
}
public Criteria andAddressNotLike(String value) {
addCriterion("address not like", value, "address");
return (Criteria) this;
}
public Criteria andAddressIn(List<String> values) {
addCriterion("address in", values, "address");
return (Criteria) this;
}
public Criteria andAddressNotIn(List<String> values) {
addCriterion("address not in", values, "address");
return (Criteria) this;
}
public Criteria andAddressBetween(String value1, String value2) {
addCriterion("address between", value1, value2, "address");
return (Criteria) this;
}
public Criteria andAddressNotBetween(String value1, String value2) {
addCriterion("address not between", value1, value2, "address");
return (Criteria) this;
}
public Criteria andUseTypeIsNull() {
addCriterion("use_type is null");
return (Criteria) this;
}
public Criteria andUseTypeIsNotNull() {
addCriterion("use_type is not null");
return (Criteria) this;
}
public Criteria andUseTypeEqualTo(Byte value) {
addCriterion("use_type =", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeNotEqualTo(Byte value) {
addCriterion("use_type <>", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeGreaterThan(Byte value) {
addCriterion("use_type >", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeGreaterThanOrEqualTo(Byte value) {
addCriterion("use_type >=", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeLessThan(Byte value) {
addCriterion("use_type <", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeLessThanOrEqualTo(Byte value) {
addCriterion("use_type <=", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeIn(List<Byte> values) {
addCriterion("use_type in", values, "useType");
return (Criteria) this;
}
public Criteria andUseTypeNotIn(List<Byte> values) {
addCriterion("use_type not in", values, "useType");
return (Criteria) this;
}
public Criteria andUseTypeBetween(Byte value1, Byte value2) {
addCriterion("use_type between", value1, value2, "useType");
return (Criteria) this;
}
public Criteria andUseTypeNotBetween(Byte value1, Byte value2) {
addCriterion("use_type not between", value1, value2, "useType");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@@ -0,0 +1,18 @@
package com.baoying.enginex.executor.common.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
//表达式的参数实体类
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ExpressionParam {
private String fieldEn;//表达式中key字段en
private String operator;//表达式的操作符
private Integer variableType;//表达式中value类型1常量 2变量,3自定义
private String fieldValue;//表达式中对应常量value值或者变量key
private String executionLogic;//执行逻辑
private Integer conditionType;//规则节点的类型1-关系节点2-表达式节点
}

View File

@@ -0,0 +1,15 @@
package com.baoying.enginex.executor.common.session;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class SessionData {
private Long organId; // 组织id
private Long engineId; // 引擎id
private Integer reqType;//请求类型
}

View File

@@ -0,0 +1,20 @@
package com.baoying.enginex.executor.common.session;
import com.alibaba.ttl.TransmittableThreadLocal;
/**
* session管理类
*/
public class SessionManager {
private static TransmittableThreadLocal<SessionData> session = new TransmittableThreadLocal<SessionData>() {
};
public static SessionData getSession() {
return session.get();
}
public static void setSession(SessionData conn) {
session.set(conn);
}
}

View File

@@ -0,0 +1,72 @@
package com.baoying.enginex.executor.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Configuration
@Data
public class ConfigHolder {
//redisConfig
@Value("${redis.host}")
private String redisHost;
@Value("${redis.port}")
private int redisPort;
@Value("${redis.db}")
private int redisDb;
@Value("${redis.password}")
private String redisPwd;
@Value("${redis.pool.maxTotal}")
private int redisMaxTotal;
@Value("${redis.pool.maxIdle}")
private int redisMaxIdle;
@Value("${redis.pool.maxWait}")
private int redisMaxWait;
@Value("${redis.pool.timeout}")
private int redisTimeout;
// 业务逻辑是否使用缓存
@Value("${switch.use.cache}")
private String cacheSwitch;
// canal缓存同步是否开启
@Value("${switch.canal.cache}")
private String canalCacheSwitch;
// canal主机地址
@Value("${canal.hostname}")
private String canalHostName;
// canal端口
@Value("${canal.port}")
private int canalPort;
//jdbcConfig
/*@Value("${jdbc.url}")
private String jdbcUrl;
@Value("${jdbc.driver}")
private String DriverName;
@Value("${pool.maxPoolSize}")
private int maxPoolSize;
@Value("${jdbc.username}")
private String jdbcUserName;
@Value("${jdbc.password}")
private String jdbcPwd;
@Value("${pool.maxWait}")
private int jdbcMaxWait;
@Value("${pool.timeBetweenEvictionRunsMillis}")
private int timeBetweenEvictionRunsMillis;
@Value("${pool.minEvictableIdleTimeMillis}")
private int minEvictableIdleTimeMillis;
@Value("${pool.validationQuery}")
private String validationQuery;
//rabbitconfig
@Value("${rabbitMQ.host}")
private String rabbitHost;
@Value("${rabbitMQ.port}")
private int rabbitPort;
@Value("${rabbitMQ.username}")
private String rabbitUsername;
@Value("${rabbitMQ.password}")
private String rabbitPassword;*/
}

View File

@@ -0,0 +1,46 @@
package com.baoying.enginex.executor.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import javax.annotation.Resource;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
public class ConfigurationContainor {
@Resource
private ConfigHolder configHolder;
@Bean(name = "threadPoolTaskExecutor")
ThreadPoolTaskExecutor threadPoolTaskExecutor(){
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2000);
executor.setMaxPoolSize(10000);
executor.setQueueCapacity(100000);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
return executor;
}
@Bean(name = "jedisPool")
public JedisPool jedisPool(){
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(configHolder.getRedisMaxTotal());
config.setMaxIdle(configHolder.getRedisMaxIdle());
config.setMaxWaitMillis(configHolder.getRedisMaxWait());
config.setTestOnBorrow(true);
// config.setTestOnReturn(true);
JedisPool pool = new JedisPool(config,
configHolder.getRedisHost(),
configHolder.getRedisPort(),
configHolder.getRedisTimeout(),
configHolder.getRedisPwd(),
configHolder.getRedisDb());
return pool;
}
}

View File

@@ -0,0 +1,61 @@
package com.baoying.enginex.executor.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import javax.sql.DataSource;
@Configuration
public class DataSourceConfig {
@Value("${spring.datasource.default.url}")
private String defaultDBUrl;
@Value("${spring.datasource.default.username}")
private String defaultDBUser;
@Value("${spring.datasource.default.password}")
private String defaultDBPassword;
@Value("${spring.datasource.default.driver-class-name}")
private String defaultDBDreiverName;
@Bean
public DruidDataSource druidDataSource(){
DruidDataSource defaultDataSource = new DruidDataSource();
defaultDataSource.setUrl(defaultDBUrl);
defaultDataSource.setUsername(defaultDBUser);
defaultDataSource.setPassword(defaultDBPassword);
defaultDataSource.setDriverClassName(defaultDBDreiverName);
return defaultDataSource;
}
@Bean
public SqlSessionFactory sqlSessionFactory(
@Qualifier("druidDataSource") DataSource druidDataSource)
throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] mapperXmlResource = resolver.getResources("classpath*:com/baoying/enginex/executor/*/mapper/*Mapper.xml");
bean.setDataSource(druidDataSource);
bean.setMapperLocations(mapperXmlResource);
bean.setTypeAliasesPackage("com.baoying.enginex.executor.**.model");
bean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
bean.getObject().getConfiguration().setCacheEnabled(false);
return bean.getObject();
}
@Bean(name = "sqlSessionTemplate")
public SqlSessionTemplate sqlSessionTemplate(
@Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory)
throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
}

View File

@@ -0,0 +1,52 @@
package com.baoying.enginex.executor.config;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.http.client.AsyncClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.AsyncRestTemplate;
import org.springframework.web.client.RestTemplate;
/**
* RestTemplate配置
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(@Qualifier("clientHttpRequestFactory") ClientHttpRequestFactory factory){
return new RestTemplate(factory);
}
@Bean
public AsyncRestTemplate asyncRestTemplate(@Qualifier("asyncClientHttpRequestFactory") AsyncClientHttpRequestFactory factory){
return new AsyncRestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory clientHttpRequestFactory(){
// 创建一个 httpCilent 简单工厂
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// 设置连接超时
factory.setConnectTimeout(15000);
// 设置读取超时
factory.setReadTimeout(5000);
return factory;
}
@Bean
public AsyncClientHttpRequestFactory asyncClientHttpRequestFactory(){
// 创建一个 httpCilent 简单工厂
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// 设置连接超时
// factory.setConnectTimeout(15000);
// 设置读取超时
// factory.setReadTimeout(5000);
//设置异步任务(线程不会重用,每次调用时都会重新启动一个新的线程)
factory.setTaskExecutor(new SimpleAsyncTaskExecutor());
return factory;
}
}

View File

@@ -0,0 +1,57 @@
package com.baoying.enginex.executor.datamanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoying.enginex.executor.datamanage.model.Field;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface FieldMapper extends BaseMapper<Field> {
/**
* findFieldByIds:(找出一批字段id对应的字段列表). <br/>
* @author caowenyu
* @param paramMap 参数集合
* @return 字段列表
*/
public List<Field> findFieldByIdsbyorganId(Map<String, Object> paramMap);
/**
* findByFieldEn:(根据引擎和字段英文名找出引擎所用字段对象). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段对象
*/
public Field findByFieldEnbyorganId(Map<String, Object> paramMap);
/**
* findByFieldCn:(根据字段中文名找出字段对象). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段对象
*/
public Field findByFieldCnbyorganId(Map<String, Object> paramMap);
/**
* findByFieldCn:(按中文名查找通用字段). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段对象
*/
public Field findByFieldCnNoEngineIdbyorganId(Map<String, Object> paramMap);
/**
* findByFieldId:(根据字段Id查找字段对象). <br/>
* @author caowenyu
* @param paramMap 参数集合
* @return 字段对象
*/
public Field findByFieldIdbyorganId(Map<String, Object> paramMap);
List<Field> selectFieldListByIds(@Param("ids") List<Long> ids);
List<Field> selectFieldListByEns(@Param("ens")List<String> ens);
}

View File

@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.FieldMapper">
<cache></cache>
<resultMap type="com.baoying.enginex.executor.datamanage.model.Field" id="fieldMap">
<id column="id" property="id"/>
<result column="field_en" property="fieldEn"/>
<result column="field_cn" property="fieldCn"/>
<result column="field_typeid" property="fieldTypeId"/>
<result column="value_type" property="valueType"/>
<result column="value_scope" property="valueScope"/>
<result column="is_derivative" property="isDerivative"/>
<result column="is_output" property="isOutput"/>
<result column="is_common" property="isCommon"/>
<result column="formula" property="formula"/>
<result column="formula_show" property="formulaShow"/>
<result column="orig_fieldid" property="origFieldId"/>
<result column="used_fieldid" property="usedFieldId"/>
<result column="author" property="author"/>
<result column="nickName" property="nickName"/>
<result column="created" property="created"/>
<result column="field_type" property="fieldType"/>
<result column="engine_id" property="engineId"/>
<result column="engineName" property="engineName"/>
<result column="status" property="status"/>
<result column="fieldRelId" property="fieldRelId"/>
<result column="is_use_sql" property="isUseSql"/>
<result column="data_source_id" property="dataSourceId"/>
<result column="sql_statement" property="sqlStatement"/>
<result column="dict_variable" property="dictVariable"/>
</resultMap>
<select id="findByFieldIdbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en, f.field_cn , f.field_typeid
, f.value_type , f.value_scope, f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid , used_fieldid
, r.engine_id
, p.field_type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = #{organId}
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and f.id = #{id}
</select>
<select id="findFieldByIdsbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, r.engine_id
, f.orig_fieldid
, p.field_type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.sql_variable, f.is_interface, f.interface_id, f.interface_parse_field, f.json_value, f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = #{organId}
<if test="isDerivative != null">
and f.is_derivative = #{isDerivative}
</if>
and f.id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findByFieldEnbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show, f.dict_variable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_en = #{fieldEn}
and r.organ_id = #{organId}
and r.status = 1
</select>
<select id="findByFieldCnbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid, f.dict_variable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_cn = #{fieldCn}
and r.organ_id = #{organId}
and r.status = 1
</select>
<select id="findByFieldCnNoEngineIdbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.orig_fieldid as origFieldId, f.dict_variable as dictVariable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_cn = #{fieldCn}
and r.organ_id = #{organId}
and r.engine_id is null
and r.status = 1
</select>
<select id="selectFieldListByIds" parameterType="list" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid
, p.field_type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.dict_variable
from t_field f,t_field_type p
where f.field_typeid=p.id
and f.id in
<foreach collection="ids" item="id" separator="," open="(" close=")" >
#{id}
</foreach>
</select>
<select id="selectFieldListByEns" parameterType="list" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid
, p.field_type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.dict_variable
from t_field f,t_field_type p
where f.field_typeid=p.id
and f.field_en in
<foreach collection="ens" item="en" separator="," open="(" close=")" >
#{en}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,128 @@
package com.baoying.enginex.executor.datamanage.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.datamanage.model.FieldType;
import java.util.List;
import java.util.Map;
public interface FieldTypeMapper extends BaseMapper<FieldType> {
/**
* getFieldTypeList:(查找用户的字段类型列表). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段类型列表
*/
public List<FieldType> getFieldTypeList(Map<String, Object> paramMap);
/**
* getSubFieldTypeList:(根据传入的字段父类型查找子类型列表). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段类型列表
*/
public List<FieldType> getSubFieldTypeList(Map<String, Object> paramMap);
/**
* findFieldTypeById:(根据传入的字段类型ID查找字段类型名). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段类型列表
*/
public FieldType findFieldTypeById(Map<String, Object> paramMap);
/**
* findTypeIdByParentId:(根据传入的字段类型父ID查找子类型ID). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 子字段类型ID
*/
public String findTypeIdByParentId(Map<String, Object> paramMap);
/**
* findTypeIdByParentId:(根据传入的字段类型类型ID查找父ID). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 子字段类型ID
*/
public String findParentIdByTypeId(Map<String, Object> paramMap);
/**
* findFieldType:(查找用户可用的字段类型列表,通用组织所有,引擎只有自定义). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段类型列表
*/
public List<FieldType> findFieldType(Map<String, Object> paramMap);
/**
* createFieldType:(新增字段类型). <br/>
* @author yuanlinfeng
* @param fieldTypeVo 字段类型实体类
* @return 插入成功
*/
public boolean createFieldType(FieldType fieldTypeVo);
/**
* findIdByFieldType:(新增字段类型). <br/>
* @author yuanlinfeng
* @param paramMap paramMap
* @return 字段类型编号
*/
public long findIdByFieldType(Map<String, Object> paramMap);
/**
* updateFieldType:(更新字段类型名). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean updateFieldType(Map<String, Object> paramMap);
/**
* updateFieldTypeByTypeIds:(更新字段类型为删除状态(-1)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean updateFieldTypeByTypeIds(Map<String, Object> paramMap);
/**
* deleteFieldTypeByTypeIds:(删除字段类型下没有字段的空节点)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean deleteFieldTypeByTypeIds(Map<String, Object> paramMap);
/**
* backFieldTypeByTypeIds:(更新字段类型状态为启用状态(1)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean backFieldTypeByTypeIds(Map<String, Object> paramMap);
/**
* isExists:(查找字段名是否存在). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 存在的记录条数
*/
public int isExists(Map<String, Object> paramMap);
/**
* isExistsDefaultTreeName:(查找默认节点名是否存在). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 存在的记录条数
*/
public int isExistsDefaultTreeName(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.FieldTypeMapper">
<cache></cache>
<resultMap type="fieldType" id="fieldTypeMap">
<id column="id" property="id"/>
<result column="field_type" property="fieldType"/>
<result column="parent_id" property="parentId"/>
<result column="is_common" property="isCommon"/>
<result column="engine_id" property="engineId"/>
</resultMap>
<select id="getFieldTypeList" parameterType="map" resultType="fieldType">
select r.field_typeid as id,t.field_type as fieldType,t.parent_id as parentId,t.is_common as isCommon,#{engineId} as engineId
from t_field_type_user_rel r, t_field_type t
where r.field_typeid = t.id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="isCommon != null">
and t.is_common = #{isCommon}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="parentId == null">
and t.parent_id = 0
</if>
<if test="parentId != null">
and t.parent_id = #{parentId}
</if>
<if test="status != null">
and r.status = #{status}
</if>
order by t.is_common desc,r.created,t.id
</select>
<select id='findIdByFieldType' parameterType="map" resultType="java.lang.Long">
select IFNULL(MAX(t.id),0) as id
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and t.field_type = #{fieldType}
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
<if test="parentId == null">
and t.parent_id = 0
</if>
<if test="parentId != null">
and t.parent_id = #{parentId}
</if>
</select>
<select id='findFieldTypeById' parameterType="java.lang.Integer" resultType="fieldType">
select id, field_type as fieldType, parent_id as parentId
from t_field_type
where id = #{id}
</select>
<select id='findTypeIdByParentId' parameterType="map" resultType="String">
select group_concat(t.id) as id
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.engine_id = #{engineId}
and t.parent_id = #{parentId}
</select>
<select id='findParentIdByTypeId' parameterType="map" resultType="String">
select t.parent_id as parentId
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and t.id = ${fieldTypeId}
</select>
<select id='findFieldType' parameterType="java.lang.Integer" resultType="fieldType">
select t.id, t.field_type as fieldType, t.parent_id as parentId
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
and r.field_typeid not in ( select field_typeid from t_field_type_user_rel where engine_id is null )
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
</select>
<insert id="createFieldType" useGeneratedKeys="true" keyProperty="id" parameterType="fieldType">
insert into t_field_type ( field_type, parent_id, is_common )
values ( #{fieldType}, #{parentId}, #{isCommon} )
</insert>
<update id="updateFieldType" parameterType="map">
update t_field_type
set field_type = #{fieldType}
where id = (select field_typeid
from t_field_type_user_rel
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_typeid = #{id}
)
</update>
<update id="updateFieldTypeByTypeIds" parameterType="map">
update t_field_type_user_rel
set status = -1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = 1
</update>
<update id="deleteFieldTypeByTypeIds" parameterType="map">
delete from t_field_type_user_rel
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and field_typeid not in
( select field_typeid
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
</update>
<update id="backFieldTypeByTypeIds" parameterType="map">
update t_field_type_user_rel
set status = 1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = -1
</update>
<select id="isExists" parameterType="map" resultType="java.lang.Integer">
select count(ft.id)
from t_field_type ft,t_field_type_user_rel r
where ft.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and ft.field_type = #{fieldType}
<if test="Id != null">
and ft.id != #{Id}
</if>
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and ft.parent_id = #{parentId}
</select>
<select id="isExistsDefaultTreeName" parameterType="map" resultType="java.lang.Integer">
select count(ft.id)
from t_field_type ft,t_field_type_user_rel r
where ft.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and ft.field_type = #{fieldType}
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and ft.parent_id = #{parentId}
</select>
</mapper>

View File

@@ -0,0 +1,54 @@
package com.baoying.enginex.executor.datamanage.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.datamanage.model.FieldTypeUser;
import java.util.Map;
public interface FieldTypeUserMapper extends BaseMapper<FieldTypeUser> {
/**
* createFieldTypeUserRel:(新增字段类型). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
*/
public boolean createFieldTypeUserRel(Map<String, Object> paramMap);
/**
* batchBindEngineFieldTypeUserRel:(把一批通用字段类型id中不存在的类型id批量绑定到引擎). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
*/
public boolean batchBindEngineFieldTypeUserRel(Map<String, Object> paramMap);
/**
* deleteFieldTypeUserRel:(取消字段类型). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 删除成功
*/
public boolean deleteFieldTypeUserRel(Map<String, Object> paramMap);
/**
* updateFieldTypeUserRel:(更新字段类型名). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean updateFieldTypeUserRel(Map<String, Object> paramMap);
/**
* findNodeIds:(查找引擎在用的节点集合). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return
*/
public String findNodeIds(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.FieldTypeUserMapper">
<cache></cache>
<resultMap type="fieldTypeUser" id="fieldTypeUserMap">
<id column="id" property="id"/>
<result column="field_typeid" property="fieldTypeId"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="user_id" property="userId"/>
</resultMap>
<insert id="createFieldTypeUserRel" useGeneratedKeys="true" keyProperty="id" parameterType="fieldTypeUser">
insert into t_field_type_user_rel ( field_typeid, organ_id, engine_id, user_id, created )
values ( #{fieldTypeId}, #{organId}, #{engineId}, #{userId}, now() )
</insert>
<insert id="batchBindEngineFieldTypeUserRel" parameterType="map">
insert into t_field_type_user_rel ( field_typeid, organ_id, engine_id, user_id, created )
select field_typeid, organ_id, #{engineId}, #{userId}, now()
from t_field_type_user_rel r
where r.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and field_typeid not in ( select field_typeid from t_field_type_user_rel where engine_id = #{engineId})
and engine_id is null
</insert>
<select id="findNodeIds" parameterType="map" resultType="String">
select group_concat(field_typeid)
from t_field_type_user_rel x
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and exists (select field_typeid
from t_field_type_user_rel y
where x.field_typeid = y.field_typeid
and y.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and y.engine_id is null
)
</select>
<insert id="deleteFieldTypeUserRel" parameterType="map">
delete from t_field_type_user_rel
where
organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_typeid = #{fieldTypeId}
</insert>
<update id="updateFieldTypeUserRel" parameterType="map">
update t_field_type_user_rel
set user_id = #{userId}, created = now()
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_typeid = #{id}
</update>
</mapper>

View File

@@ -0,0 +1,77 @@
package com.baoying.enginex.executor.datamanage.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.datamanage.model.FieldUser;
import java.util.Map;
public interface FieldUserMapper extends BaseMapper<FieldUser> {
/**
* createFieldUserRel:(绑定字段和用户关系). <br/>
* @author yuanlinfeng
* @param fieldUser 用户字段实体类
* @return 插入成功
* */
public boolean createFieldUserRel(FieldUser fieldUserVo);
/**
* batchCreateFieldUserRel:(批量导入字段信息后批量绑定字段和用户关系). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
* */
public boolean batchCreateFieldUserRel(Map<String, Object> paramMap);
/**
* batchBindEngineFieldUserRel:(把一批通用字段id中未绑定的字段id批量绑定到引擎). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
* */
public boolean batchBindEngineFieldUserRel(Map<String, Object> paramMap);
/**
* batchCreateEngineFieldUserRel:(把id、英文名、中文名不重复的组织字段批量绑定到引擎). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
* */
public boolean batchCreateEngineFieldUserRel(Map<String, Object> paramMap);
/**
* updateFieldUserRel:(更新字段). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
* */
public boolean updateFieldUserRel(Map<String, Object> paramMap);
/**
* updateStatus:(单个或批量更新用户字段关系). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
* */
public boolean updateStatus(Map<String, Object> paramMap);
/**
* deleteFieldByIds:(批量修改字段启用状态为删除状态(-1)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新是否成功
*/
public boolean deleteFieldByIds(Map<String, Object> paramMap);
/**
* deleteFieldByIds:(批量修改字段删除状态为启用状态(1)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新是否成功
*/
public boolean backFieldByIds(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.FieldUserMapper">
<cache></cache>
<resultMap type="fieldUser" id="fieldUserMap">
<id column="id" property="id"/>
<result column="field_id" property="fieldId"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="user_id" property="userId"/>
<result column="status" property="status"/>
</resultMap>
<insert id="createFieldUserRel" useGeneratedKeys="true" keyProperty="id" parameterType="fieldUser">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
values (#{fieldId}, #{organId}, #{engineId}, #{userId}, #{status}, now(), now())
</insert>
<insert id="batchCreateFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, #{status}, now(), now()
from t_field t
where t.author = #{author}
and not exists ( select r.field_id from t_field_user_rel r where t.id = r.field_id )
</insert>
<insert id="batchCreateEngineFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, #{status}, now(), now()
from t_field f
where f.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and not exists ( select 1
from ( select f.id,f.field_en,f.field_cn
from t_field f,t_field_user_rel fu
where f.id = fu.field_id
and fu.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and fu.engine_id = ${engineId} )y
where f.field_en = y.field_en or f.field_cn = y.field_cn or f.id = y.id
)
</insert>
<insert id="batchBindEngineFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, 1, now(), now()
from t_field f
where f.id in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and not exists ( select 1
from ( select f.id,f.field_en,f.field_cn
from t_field f,t_field_user_rel fu
where f.id = fu.field_id
and fu.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and fu.engine_id = ${engineId} )y
where f.field_en = y.field_en or f.field_cn = y.field_cn or f.id = y.id
)
</insert>
<update id="updateFieldUserRel" parameterType="map">
update t_field_user_rel
set user_id = #{userId} , updated = now()
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_id = #{Id}
</update>
<update id="updateStatus" parameterType="map">
update t_field_user_rel
set status=#{status}
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null and status!=-1 and status!=0">
and engine_id is null
</if>
and field_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="deleteFieldByIds" parameterType="map">
update t_field_user_rel
set status = -1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_id in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = 1
</update>
<update id="backFieldByIds" parameterType="map">
update t_field_user_rel
set status = 1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = -1
</update>
</mapper>

View File

@@ -0,0 +1,11 @@
package com.baoying.enginex.executor.datamanage.mapper;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public interface SimpleMapper {
List<LinkedHashMap<String, Object>> customSelect(Map<String, Object> paramsMap);
List<LinkedHashMap<String, Object>> test(Map<String, Object> paramsMap);
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.SimpleMapper">
<select id="customSelect" resultType="java.util.LinkedHashMap">
${sqlStr}
</select>
<select id="test" resultType="java.util.LinkedHashMap">
${sqlStr}
</select>
</mapper>

View File

@@ -0,0 +1,236 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
import java.util.Date;
public class CustList extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 以下20个t开头为匿名字段
* */
private String t0;
private String t1;
private String t2;
private String t3;
private String t4;
private String t5;
private String t6;
private String t7;
private String t8;
private String t9;
private String t10;
private String t11;
private String t12;
private String t13;
private String t14;
private String t15;
private String t16;
private String t17;
private String t18;
private String t19;
/**
* 创建人编号
* */
private Long userId;
/**
* 创建人昵称
* */
private String nickName;
/**
* 创建时间
* */
private Date created;
/**
* 检索客户信息是否存在的定制条件
*/
private String checkCol;
/**
* 检索名单库的表名称
*/
private String tableName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getT0() {
return t0;
}
public void setT0(String t0) {
this.t0 = t0;
}
public String getT1() {
return t1;
}
public void setT1(String t1) {
this.t1 = t1;
}
public String getT2() {
return t2;
}
public void setT2(String t2) {
this.t2 = t2;
}
public String getT3() {
return t3;
}
public void setT3(String t3) {
this.t3 = t3;
}
public String getT4() {
return t4;
}
public void setT4(String t4) {
this.t4 = t4;
}
public String getT5() {
return t5;
}
public void setT5(String t5) {
this.t5 = t5;
}
public String getT6() {
return t6;
}
public void setT6(String t6) {
this.t6 = t6;
}
public String getT7() {
return t7;
}
public void setT7(String t7) {
this.t7 = t7;
}
public String getT8() {
return t8;
}
public void setT8(String t8) {
this.t8 = t8;
}
public String getT9() {
return t9;
}
public void setT9(String t9) {
this.t9 = t9;
}
public String getT10() {
return t10;
}
public void setT10(String t10) {
this.t10 = t10;
}
public String getT11() {
return t11;
}
public void setT11(String t11) {
this.t11 = t11;
}
public String getT12() {
return t12;
}
public void setT12(String t12) {
this.t12 = t12;
}
public String getT13() {
return t13;
}
public void setT13(String t13) {
this.t13 = t13;
}
public String getT14() {
return t14;
}
public void setT14(String t14) {
this.t14 = t14;
}
public String getT15() {
return t15;
}
public void setT15(String t15) {
this.t15 = t15;
}
public String getT16() {
return t16;
}
public void setT16(String t16) {
this.t16 = t16;
}
public String getT17() {
return t17;
}
public void setT17(String t17) {
this.t17 = t17;
}
public String getT18() {
return t18;
}
public void setT18(String t18) {
this.t18 = t18;
}
public String getT19() {
return t19;
}
public void setT19(String t19) {
this.t19 = t19;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getCheckCol() {
return checkCol;
}
public void setCheckCol(String checkCol) {
this.checkCol = checkCol;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
public String toString() {
return "CustList [id=" + id + ", t0=" + t0 + ", t1=" + t1 + ", t2=" + t2
+ ", t3=" + t3 + ", t4=" + t4 + ", t5=" + t5 + ", t6=" + t6
+ ", t7=" + t7 + ", t8=" + t8 + ", t9=" + t9 + ", t10=" + t10
+ ", t11=" + t11 + ", t12=" + t12 + ", t13=" + t13 + ", t14="
+ t14 + ", t15=" + t15 + ", t16=" + t16 + ", t17=" + t17
+ ", t18=" + t18 + ", t19=" + t19 + ", userId=" + userId
+ ", nickName=" + nickName + ", created=" + created
+ ", checkCol=" + checkCol + ", tableName=" + tableName + "]";
}
}

View File

@@ -0,0 +1,203 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
@TableName("t_field")
public class Field implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 字段英文名
* */
private String fieldEn;
/**
* 字段中文名
* */
private String fieldCn;
/**
* 字段类型编号
* */
@TableField("field_typeid")
private Long fieldTypeId;
/**
* 字段类型名
* */
@TableField(exist = false)
private String fieldType;
/**
* 字段存值类型
* */
private Integer valueType;
/**
* 字段存值类型中文
* */
@TableField(exist = false)
private String valueTypeName;
/**
* 字段约束范围
* */
private String valueScope;
/**
* 是否衍生字段
* */
private Integer isDerivative;
/**
* 是否衍生字段
* */
@TableField(exist = false)
private String isDerivativeName;
/**
* 是否输出字段
* */
private Integer isOutput;
/**
* 是否输出字段
* */
@TableField(exist = false)
private String isOutputName;
/**
* 是否组织定义的通用字段
* */
private Integer isCommon;
/**
* 衍生字段公式
* */
private String formula;
/**
* 衍生字段公式回显信息
* */
private String formulaShow;
/**
* 衍生字段引用的字段id
* */
@TableField("used_fieldid")
private String usedFieldId;
/**
* 衍生字段引用的原生字段id
* */
@TableField("orig_fieldid")
private String origFieldId;
/**
* 创建人
* */
private Long author;
/**
* 创建人昵称
* */
@TableField(exist = false)
private String nickName;
/**
* 创建时间
* */
private Date created;
/**
* 归属的引擎ID
* */
@TableField(exist = false)
private Long engineId;
/**
* 归属的引擎名称
* */
@TableField(exist = false)
private String engineName;
/**
* 字段状态(启用、停用、删除、未知)
* */
@TableField(exist = false)
private String status;
/**
* 字段条件设置集合
* */
@TableField(exist = false)
private List<FieldCond> fieldCondList;
/**
* 字段用户关系编号
* */
@TableField(exist = false)
private Long fieldRelId;
/**
* 是否使用sql获取指标
*/
private Boolean isUseSql;
/**
* 使用sql获取指标时对应的数据源
*/
private Integer dataSourceId;
/**
* 使用sql获取指标时对应的sql语句
*/
private String sqlStatement;
/**
* sql变量配置
*/
private String sqlVariable;
/**
* 是否使用接口
*/
private Boolean isInterface;
/**
* 接口id
*/
private Integer interfaceId;
/**
* 接口解析指标
*/
private String interfaceParseField;
/**
* json类型对应的json值
*/
private String jsonValue;
/**
* 字典变量例如 日期date
*/
private String dictVariable;
/**
* 该字段归属的组织编号
* */
private Long organId;
}

View File

@@ -0,0 +1,142 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import com.baoying.enginex.executor.datamanage.vo.FieldSubCondVo;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
public class FieldCond extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 条件编号
* */
private Long id;
/**
* 字段编号
* */
private Long fieldId;
/**
* 字段条件值
* */
private String conditionValue;
/**
* 字段条件区域设置json格式
* */
private String content;
/**
* 条件字段编号
* */
private Long condFieldId;
/**
* 条件字段的运算符
* */
private String condFieldOperator;
/**
* 条件字段的条件设置值
* */
private String condFieldValue;
/**
* 条件字段间的逻辑符
* */
private String condFieldLogical;
/**
* 创建时间
* */
private Date created;
private List<FieldSubCondVo> fieldSubCond;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getFieldId() {
return fieldId;
}
public void setFieldId(Long fieldId) {
this.fieldId = fieldId;
}
public String getConditionValue() {
return conditionValue;
}
public void setConditionValue(String conditionValue) {
this.conditionValue = conditionValue;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Long getCondFieldId() {
return condFieldId;
}
public void setCondFieldId(Long condFieldId) {
this.condFieldId = condFieldId;
}
public String getCondFieldOperator() {
return condFieldOperator;
}
public void setCondFieldOperator(String condFieldOperator) {
this.condFieldOperator = condFieldOperator;
}
public String getCondFieldValue() {
return condFieldValue;
}
public void setCondFieldValue(String condFieldValue) {
this.condFieldValue = condFieldValue;
}
public String getCondFieldLogical() {
return condFieldLogical;
}
public void setCondFieldLogical(String condFieldLogical) {
this.condFieldLogical = condFieldLogical;
}
public List<FieldSubCondVo> getFieldSubCond() {
return fieldSubCond;
}
public void setFieldSubCond(List<FieldSubCondVo> fieldSubCond) {
this.fieldSubCond = fieldSubCond;
}
}

View File

@@ -0,0 +1,104 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
public class FieldInter extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Integer id;
/**
* 衍生字段编号
* */
private Integer fieldRelId;
/**
* 公式引用的字段编号
* */
private Integer interFieldId;
/**
* 公式引用的字段用户关系编号
* */
private Integer interFieldRelId;
/**
* 同名字段的顺序
* */
private Integer seq;
/**
* 字段值区间划分
* */
private String interval;
/**
* 对应区间的值定义
* */
private String value;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getFieldRelId() {
return fieldRelId;
}
public void setFieldRelId(Integer fieldRelId) {
this.fieldRelId = fieldRelId;
}
public Integer getInterFieldId() {
return interFieldId;
}
public void setInterFieldId(Integer interFieldId) {
this.interFieldId = interFieldId;
}
public Integer getInterFieldRelId() {
return interFieldRelId;
}
public void setInterFieldRelId(Integer interFieldRelId) {
this.interFieldRelId = interFieldRelId;
}
public Integer getSeq() {
return seq;
}
public void setSeq(Integer seq) {
this.seq = seq;
}
public String getInterval() {
return interval;
}
public void setInterval(String interval) {
this.interval = interval;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@@ -0,0 +1,106 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
public class FieldType extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Integer id;
/**
* 字段类型名
* */
private String fieldType;
/**
* 父节点编号
* */
private Integer parentId;
/**
* 是否组织定义的通用字段类型
* */
private Integer isCommon;
/**
* 字段类型的子类集合
* */
private FieldType[] children;
/**
* 是否为父类
* */
private String isParent = "true";
/**
* 引擎编号
* */
private Integer engineId;
/**
*文件夹图片路径
* */
private String icon;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFieldType() {
return fieldType;
}
public void setFieldType(String fieldType) {
this.fieldType = fieldType;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getIsCommon() {
return isCommon;
}
public void setIsCommon(Integer isCommon) {
this.isCommon = isCommon;
}
public FieldType[] getChildren() {
return children;
}
public void setChildren(FieldType[] children) {
this.children = children;
}
public String getIsParent() {
return isParent;
}
public void setIsParent(String isParent) {
this.isParent = isParent;
}
public Integer getEngineId() {
return engineId;
}
public void setEngineId(Integer engineId) {
this.engineId = engineId;
}
public String getIcon() {
// if(engineId!=null)
// icon = "../../resource/images/authority/folder.png";
// else
icon = "../resource/images/authority/folder.png";
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
}

View File

@@ -0,0 +1,80 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
import java.util.Date;
public class FieldTypeUser extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Integer id;
/**
* 字段类型编号(表主键)
* */
private Integer fieldTypeId;
/**
* 该字段类型归属的组织编号
* */
private Long organId;
/**
* 该字段类型归属的引擎id表主键
* */
private Integer engineId;
/**
* 创建或修改该字段的用户编号
* */
private Long userId;
/**
* 创建时间
* */
private Date created;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getFieldTypeId() {
return fieldTypeId;
}
public void setFieldTypeId(Integer fieldTypeId) {
this.fieldTypeId = fieldTypeId;
}
public Long getOrganId() {
return organId;
}
public void setOrganId(Long organId) {
this.organId = organId;
}
public Integer getEngineId() {
return engineId;
}
public void setEngineId(Integer engineId) {
this.engineId = engineId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
}

View File

@@ -0,0 +1,102 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
import java.util.Date;
public class FieldUser extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 字段编号(表主键)
* */
private Long fieldId;
/**
* 该字段归属的组织编号
* */
private Long organId;
/**
* 该字段归属的引擎id表主键
* */
private Long engineId;
/**
* 创建或修改该字段的用户编号
* */
private Long userId;
/**
* 启用停用删除标志
* */
private int status;
/**
* 创建时间
* */
private Date created;
/**
* 更新时间
* */
private Date updated;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getFieldId() {
return fieldId;
}
public void setFieldId(Long fieldId) {
this.fieldId = fieldId;
}
public Long getOrganId() {
return organId;
}
public void setOrganId(Long organId) {
this.organId = organId;
}
public Long getEngineId() {
return engineId;
}
public void setEngineId(Long engineId) {
this.engineId = engineId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getUpdated() {
return updated;
}
public void setUpdated(Date updated) {
this.updated = updated;
}
}

View File

@@ -0,0 +1,45 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
public class FormulaField extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 字段编号(表主键)
* */
private Long fieldId;
/**
* 公式用到的字段编号(表主键)
* */
private Long formulaFieldId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getFieldId() {
return fieldId;
}
public void setFieldId(Long fieldId) {
this.fieldId = fieldId;
}
public Long getFormulaFieldId() {
return formulaFieldId;
}
public void setFormulaFieldId(Long formulaFieldId) {
this.formulaFieldId = formulaFieldId;
}
}

View File

@@ -0,0 +1,19 @@
package com.baoying.enginex.executor.datamanage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoying.enginex.executor.datamanage.model.Field;
import java.util.List;
public interface FieldService extends IService<Field> {
Field queryById(Long id);
List<Field> findFieldByIdsbyorganId(Long organId, List<Long> ids);
List<Field> selectFieldListByEns(List<String> fieldEnList);
Field findByFieldEnbyorganId(Long organId, String fieldEn);
Field findByFieldCnbyorganId(Long organId, String fieldCn);
}

View File

@@ -0,0 +1,112 @@
package com.baoying.enginex.executor.datamanage.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baoying.enginex.executor.canal.TableEnum;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.common.session.SessionManager;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.datamanage.mapper.FieldMapper;
import com.baoying.enginex.executor.datamanage.model.Field;
import com.baoying.enginex.executor.datamanage.service.FieldService;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class FieldServiceImpl extends ServiceImpl<FieldMapper, Field> implements FieldService {
@Autowired
public FieldMapper fieldMapper;
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Override
public Field queryById(Long id) {
Field field = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, id);
field = redisManager.getByPrimaryKey(key, Field.class);
} else {
field = fieldMapper.selectById(id);
}
return field;
}
@Override
public List<Field> findFieldByIdsbyorganId(Long organId, List<Long> ids) {
List<Field> fieldList = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
List<String> keys = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, ids);
fieldList = redisManager.hgetAllBatchByPrimaryKeys(keys, Field.class);
} else {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("organId", organId);
paramMap.put("Ids", ids);
fieldList = fieldMapper.findFieldByIdsbyorganId(paramMap);
}
return fieldList;
}
@Override
public List<Field> selectFieldListByEns(List<String> fieldEnList) {
List<Field> fieldList = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
Long organId = SessionManager.getSession().getOrganId();
List<String> keys = fieldEnList.stream().map(item -> {
String fieldEnStr = Constants.fieldName.fieldEn + ":" + organId + ":" + item;
String fieldEnKey = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, fieldEnStr);
return fieldEnKey;
}).collect(Collectors.toList());
fieldList = redisManager.hgetAllBatchByPrimaryKeys(keys, Field.class);
} else {
fieldList = fieldMapper.selectFieldListByEns(fieldEnList);
}
return fieldList;
}
@Override
public Field findByFieldEnbyorganId(Long organId, String fieldEn) {
Field field = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String fieldEnStr = Constants.fieldName.fieldEn + ":" + organId + ":" + fieldEn;
String fieldEnKey = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, fieldEnStr);
field = redisManager.getByPrimaryKey(fieldEnKey, Field.class);
// todo 是否需要status = 1判断
} else {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("organId", organId);
paramMap.put("fieldEn", fieldEn);
field = fieldMapper.findByFieldEnbyorganId(paramMap);
}
return field;
}
@Override
public Field findByFieldCnbyorganId(Long organId, String fieldCn) {
Field field = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String fieldCnStr = Constants.fieldName.fieldCn + ":" + organId + ":" + fieldCn;
String fieldCnKey = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, fieldCnStr);
field = redisManager.getByPrimaryKey(fieldCnKey, Field.class);
// todo 是否需要status = 1判断
} else {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("organId", organId);
paramMap.put("fieldCn", fieldCn);
field = fieldMapper.findByFieldCnbyorganId(paramMap);
}
return field;
}
}

View File

@@ -0,0 +1,29 @@
package com.baoying.enginex.executor.datamanage.vo;
import com.baoying.enginex.executor.datamanage.model.Field;
import java.util.List;
public class FieldEnumVo {
private Field field;
private List<String> enums;
public Field getField() {
return field;
}
public void setField(Field field) {
this.field = field;
}
public List<String> getEnums() {
return enums;
}
public void setEnums(List<String> enums) {
this.enums = enums;
}
}

View File

@@ -0,0 +1,150 @@
package com.baoying.enginex.executor.datamanage.vo;
import java.util.Date;
public class FieldExcelVo {
/**
* 主键
* */
private Integer id;
/**
* 字段英文名
* */
private String fieldEn;
/**
* 字段中文名
* */
private String fieldCn;
/**
* 字段类型名称
* */
private String fieldType;
/**
* 字段存值类型
* */
private String valueType;
/**
* 字段约束范围
* */
private String valueScope;
/**
* 是否衍生字段
* */
private String isDerivative;
/**
* 是否输出字段
* */
private String isOutput;
/**
* 衍生字段公式
* */
private String formula;
/**
* 创建人
* */
private String author;
/**
* 创建时间
* */
private Date created;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFieldEn() {
return fieldEn;
}
public void setFieldEn(String fieldEn) {
this.fieldEn = fieldEn;
}
public String getFieldCn() {
return fieldCn;
}
public void setFieldCn(String fieldCn) {
this.fieldCn = fieldCn;
}
public String getFieldType() {
return fieldType;
}
public void setFieldType(String fieldType) {
this.fieldType = fieldType;
}
public String getValueType() {
return valueType;
}
public void setValueType(String valueType) {
this.valueType = valueType;
}
public String getValueScope() {
return valueScope;
}
public void setValueScope(String valueScope) {
this.valueScope = valueScope;
}
public String getIsDerivative() {
return isDerivative;
}
public void setIsDerivative(String isDerivative) {
this.isDerivative = isDerivative;
}
public String getIsOutput() {
return isOutput;
}
public void setIsOutput(String isOutput) {
this.isOutput = isOutput;
}
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
}

View File

@@ -0,0 +1,89 @@
package com.baoying.enginex.executor.datamanage.vo;
import java.io.Serializable;
public class FieldFormulaVo implements Serializable {
private static final long serialVersionUID = 1L;
// [{fvalue: "0",formula: "a",farr: [{fieldCN:"引擎字段1-1",fieldCond:[{"inputOne":"c","inputThree":"5"},{"inputOne":"b","inputThree":"12"}]},{fieldCN:"通用字段2贷前",fieldCond:[{"inputOne":"(30,40]","inputThree":"5"},{"inputOne":"[45,51)","inputThree":"12"}]}]}];
/**
* 衍生字段公式设置对应的值
* */
private String fvalue;
/**
* 衍生字段公式
* */
private String formula;
/**
* 衍生字段公式里字段的条件区域设置
* */
private Integer idx;
/**
* 衍生字段公式里字段的条件区域设置
* */
private String farr;
/**
* 衍生字段公式里条件区域设置的某个字段中文名
* */
private String fieldCN;
/**
* 衍生字段公式里条件区域设置的某个字段的具体设置
* */
private String fieldCond;
public String getFvalue() {
return fvalue;
}
public void setFvalue(String fvalue) {
this.fvalue = fvalue;
}
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
public Integer getIdx() {
return idx;
}
public void setIdx(Integer idx) {
this.idx = idx;
}
public String getFarr() {
return farr;
}
public void setFarr(String farr) {
this.farr = farr;
}
public String getFieldCN() {
return fieldCN;
}
public void setFieldCN(String fieldCN) {
this.fieldCN = fieldCN;
}
public String getFieldCond() {
return fieldCond;
}
public void setFieldCond(String fieldCond) {
this.fieldCond = fieldCond;
}
}

View File

@@ -0,0 +1,108 @@
package com.baoying.enginex.executor.datamanage.vo;
import java.io.Serializable;
public class FieldSubCondVo implements Serializable{
private static final long serialVersionUID = 1L;
//[{"fieldId":"43","operator":"in","fieldValue":"b","logical":"and"}]
/**
* 条件字段编号
* */
private Integer fieldId;
/**
* 条件字段的运算符
* */
private String operator;
/**
* 条件字段的条件设置值
* */
private String fieldValue;
/**
* 条件字段间的逻辑符
* */
private String logical;
/**
* 条件字段的值类型
* */
private Integer valueType;
/**
* 条件字段的取值范围
* */
private String valueScope;
/**
* 条件字段的取值范围拆解后的数组
* */
private String[] values;
/**
* 条件字段的字段名
*/
private String fieldCn;
public Integer getFieldId() {
return fieldId;
}
public void setFieldId(Integer fieldId) {
this.fieldId = fieldId;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
public String getLogical() {
return logical;
}
public void setLogical(String logical) {
this.logical = logical;
}
public Integer getValueType() {
return valueType;
}
public void setValueType(Integer valueType) {
this.valueType = valueType;
}
public String getValueScope() {
return valueScope;
}
public void setValueScope(String valueScope) {
this.valueScope = valueScope;
}
public String[] getValues() {
if(valueType == 3){
values = valueScope.split(",");
}else{
values = new String[]{valueScope};
}
return values;
}
public void setValues(String[] values) {
this.values = values;
}
public String getFieldCn() {
return fieldCn;
}
public void setFieldCn(String fieldCn) {
this.fieldCn = fieldCn;
}
}

View File

@@ -0,0 +1,20 @@
package com.baoying.enginex.executor.engine.consts;
public class EngineConst {
/**
* 版本部署状态
*/
public static final int BOOT_STATE_DEPLOY = 1;
/**
* 版本未部署状态
*/
public static final int BOOT_STATE_UNDEPLOY = 0;
/**
* 决策选项结果集key
*/
public static final String DECISION_COLLECTION_KEY = "formulaList";
}

View File

@@ -0,0 +1,29 @@
package com.baoying.enginex.executor.engine.consts;
public class EngineMsg {
/**
* 部署成功
*/
public static final int STATUS_SUCCESS = 1;
public static final String DEPLOY_SUCCESS = "部署成功!";
public static final String UNDEPLOY_SUCCESS = "当前版本已停用!";
/**
* 部署失败
*/
public static final int STATUS_FAILED = 0;
public static final String DEPLOY_FAILED = "部署失败!";
public static final String UNDEPLOY_FAILED = "停用当前版本失败!";
public static final String DELETE_RUNNING_FAILED = "当前版本正在运行,不能删除!";
public static final String DELETE_VERSION_SUCCESS = "当前版本删除成功!";
public static final String DELETE_VERSION_FAILED = "未知异常,当前版本删除失败!";
}

View File

@@ -0,0 +1,151 @@
package com.baoying.enginex.executor.engine.consts;
public class EngineOperator {
/*---------------------------- 关系运算符 ----------------------------*/
public static final String OPERATOR_AND_RELATION = "&&";
public static final String OPERATOR_OR_RELATION = "||";
public static final String OPERATOR_NOT_RELATION = "!";
public static final String OPERATOR_EQUALS_RELATION = "==";
public static final String OPERATOR_GREATER_RELATION = ">";
public static final String OPERATOR_GREATER_EQUALS_RELATION = ">=";
public static final String OPERATOR_LESS_RELATION = "<";
public static final String OPERATOR_LESS_EQUALS_RELATION = "<=";
public static final String OPERATOR_NOT_EQUALS_RELATION = "!=";
public static final String OPERATOR_AND_STRING_RELATION = "AND";
public static final String OPERATOR_OR_STRING_RELATION = "OR";
/*---------------------------- 数学运算符 ----------------------------*/
public static final String OPERATOR_ADD_MATH = "+";
public static final String OPERATOR_MINUS_MATH = "-";
public static final String OPERATOR_MULITI_MATH = "*";
public static final String OPERATOR_DIVIDE_MATH = "/";
public static final String OPERATOR_MODULU_MATH = "%";
public static final String OPERATOR_ABS_MATH = "abs";
public static final String OPERATOR_ACOS_MATH = "acos";
public static final String OPERATOR_ASIN_MATH = "asin";
public static final String OPERATOR_ATAN_MATH = "atan";
public static final String OPERATOR_ATAN2_MATH = "atan2";
public static final String OPERATOR_AVERAGE_MATH = "avg";
public static final String OPERATOR_CEIL_MATH = "ceil";
public static final String OPERATOR_COS_MATH = "cos";
public static final String OPERATOR_EXP_MATH = "exp";
public static final String OPERATOR_FLOOR_MATH = "floor";
public static final String OPERATOR_IEEE_MATH = "IEEEremainder";
public static final String OPERATOR_LN_MATH = "ln";
public static final String OPERATOR_LOG_MATH = "log";
public static final String OPERATOR_MAX_MATH = "max";
public static final String OPERATOR_MIN_MATH = "min";
public static final String OPERATOR_POW_MATH = "pow";
public static final String OPERATOR_RANDOM_MATH = "random";
public static final String OPERATOR_RINT_MATH = "rint";
public static final String OPERATOR_ROUND_MATH = "round";
public static final String OPERATOR_SIN_MATH = "sin";
public static final String OPERATOR_SQRT_MATH = "sqrt";
public static final String OPERATOR_SUM_MATH = "sum";
public static final String OPERATOR_TAN_MATH = "tan";
public static final String OPERATOR_TODEGREES_MATH = "toDegrees";
public static final String OPERATOR_TORADIANS_MATH = "toRadians";
/*---------------------------- 字符串运算符 ----------------------------*/
public static final String OPERATOR_CHARAT_STRING = "charAt";
public static final String OPERATOR_COMPARE_STRING = "compareTo";
public static final String OPERATOR_CTIC_STRING = "compareToIgnoreCase";
public static final String OPERATOR_CONCAT_STRING = "concat";
public static final String OPERATOR_ENDSWITH_STRING = "endsWith";
public static final String OPERATOR_EIC_STRING = "equalsIgnoreCase";
public static final String OPERATOR_EVAL_STRING = "eval";
public static final String OPERATOR_INDEXOF_STRING = "indexOf";
public static final String OPERATOR_LASTINDEXOF_STRING = "lastIndexOf";
public static final String OPERATOR_LENGTH_STRING = "length";
public static final String OPERATOR_REPLACE_STRING = "replace";
public static final String OPERATOR_STARTSWITH_STRING = "startsWith";
public static final String OPERATOR_SUB_STRING = "substring";
public static final String OPERATOR_TLC_STRING = "toLowerCase";
public static final String OPERATOR_TUC_STRING = "toUpperCase";
public static final String OPERATOR_TRIM_STRING = "trim";
public static final String OPERATOR_CONTAINS_STRING = "contains";
public static final String OPERATOR_UNCONTAINS_STRING = "notContains";
public static final String OPERATOR_EQUALS_STRING = "equals";
public static final String OPERATOR_UNEQUALS_STRING = "notEquals";
/*---------------------------- 符号 ----------------------------*/
public static final String OPERATOR_LEFT_BRACE = "{";
public static final String OPERATOR_RIGHT_BRACE = "}";
public static final String OPERATOR_VARIABLE_LEFT = "#"+OPERATOR_LEFT_BRACE;
public static final String OPERATOR_VARIABLE_RIGHT = "}";
public static final String OPERATOR_LEFT_PARENTHESES = "(";
public static final String OPERATOR_RIGHT_PARENTHESES = ")";
public static final String OPERATOR_LEFT_BRACKET = "[";
public static final String OPERATOR_RIGHT_BRACKET = "]";
}

View File

@@ -0,0 +1,47 @@
package com.baoying.enginex.executor.engine.consts;
public class EnumConst {
public static final String NODE_START = "开始";
public static final String NODE_POLICY = "政策规则";
public static final String NODE_CLASSIFY = "客户分群";
public static final String NODE_SCORECARD = "评分卡";
public static final String NODE_BLACK = "黑名单";
public static final String NODE_WHITE = "白名单";
public static final String NODE_SANDBOX = "沙盒比例";
public static final String NODE_CREDIT_LEVEL = "信用评级";
public static final String NODE_DECISION = "决策选项";
public static final String NODE_QUOTA_CALC = "额度计算";
public static final String NODE_REPORT = "报表分析";
public static final String NODE_CUSTOMIZE = "自定义按钮";
public static final String NODE_COMPLEXRULE = "复杂规则";
public static final String NODE_CHILD_ENGINE = "子引擎";
public static final String NODE_MODEL = "模型";
public static final String DECISION_TABLES = "决策表";
public static final String DECISION_TREE = "决策树";
public static final String NODE_RPC = "远程调用";
public static final String NODE_PARALLEL = "并行";
public static final String NODE_AGGREGATION = "聚合";
public static final String NODE_CHAMPION_CHALLENGE= "冠军挑战";
}

View File

@@ -0,0 +1,119 @@
package com.baoying.enginex.executor.engine.controller;
import com.alibaba.fastjson.JSONObject;
import com.baoying.enginex.executor.engine.model.DecisionReqModel;
import com.baoying.enginex.executor.engine.service.EngineApiService;
import com.baoying.enginex.executor.engine.thread.EngineCallable;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@Controller
@RequestMapping("/QueryString")
public class ApiController {
private static final Logger logger = LoggerFactory.getLogger(ApiController.class);
@Autowired
public EngineApiService engineApiService;
@RequestMapping(value = "/decision", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json;charset=UTF-8")
@ResponseBody
public String decision(String ts, String nonce, String act, String pid, String uid, String sign, String token, String paramJson, String fields) {
logger.info("请求参数--" + "ts:" + ts + ",nonce:" + nonce + ",act:" + act + ",pid:" + pid + ",uid:" + uid + ", sign:" + sign + ",token:" + token + ",paramJson" + paramJson);
Map<String, Object> map = new HashMap<>();
map.put("ts", ts);
map.put("nonce", nonce);
map.put("act", act);
map.put("pid", pid);
map.put("uid", uid);
map.put("token", token);
JSONObject jsonObject = JSONObject.parseObject(paramJson);
if (jsonObject.getInteger("reqType") == 2) {
map.put("version", jsonObject.getInteger("version"));
map.put("subversion", jsonObject.getInteger("subversion"));
}
map.put("reqType", jsonObject.getInteger("reqType"));
map.put("engineId", jsonObject.getLong("engineId"));
map.put("organId", jsonObject.getLong("organId"));
map.put("sign", jsonObject.getString("sign"));
Map<String, Object> requestFields = new HashMap<>();
if(StringUtils.isNotBlank(fields)){
requestFields = JSONObject.parseObject(fields, Map.class);
}
map.put("fields", requestFields);
String result = engineApiService.engineApi(map);
logger.info("uid:" + uid + " 响应参数--" + "result:" + result);
return result;
}
@RequestMapping(value = "/batchDecision", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json;charset=UTF-8")
@ResponseBody
public String batchDecision(HttpServletResponse response, String ts, String nonce, String act, String sign, String token, int reqType, Long engineId, Long organId, String paramJson) {
List<JSONObject> resultList = new ArrayList<>();
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> list = new ArrayList<>();
List<DecisionReqModel> reqModelList = JSONObject.parseArray(paramJson, DecisionReqModel.class);
for (DecisionReqModel reqModel : reqModelList) {
Map<String, Object> map = new HashMap<>();
map.put("ts", ts);
map.put("nonce", nonce);
map.put("act", act);
map.put("token", token);
map.put("reqType", reqType);
map.put("engineId", engineId);
map.put("organId", organId);
map.put("sign", sign);
map.put("pid", reqModel.getPid());
map.put("uid", reqModel.getUid());
Map<String, Object> requestFields = new HashMap<>();
if(reqModel.getFields() != null){
requestFields = JSONObject.parseObject(JSONObject.toJSONString(reqModel.getFields()), Map.class);
}
map.put("fields", requestFields);
list.add(map);
}
List<Future<String>> futureList = new ArrayList<>();
ExecutorService executorService = Executors.newFixedThreadPool(10);
for(Map<String, Object> paramMap : list){
futureList.add(executorService.submit(new EngineCallable(paramMap)));
}
// 获取线程执行结果
for (final Future<String> future : futureList) {
try {
final String str = future.get(5, TimeUnit.MINUTES);
resultList.add(JSONObject.parseObject(str));
} catch (Exception e) {
boolean cancelResult = future.cancel(true);
logger.error("取消结果(" + cancelResult + ")" + e.getMessage(), e);
}
}
String result = JSONObject.toJSONString(resultList);
resultMap.put("result", resultList);
logger.info(" 响应参数--" + "result:" + result);
return result;
}
}

View File

@@ -0,0 +1,70 @@
package com.baoying.enginex.executor.engine.controller;
import com.baoying.enginex.executor.common.session.SessionData;
import com.baoying.enginex.executor.common.session.SessionManager;
import com.baoying.enginex.executor.engine.model.request.DecisionApiBizData;
import com.baoying.enginex.executor.engine.model.request.DecisionApiRequest;
import com.baoying.enginex.executor.engine.service.EngineApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/runner")
public class DecisionController {
private static final Logger logger = LoggerFactory.getLogger(DecisionController.class);
@Autowired
public EngineApiService engineApiService;
@RequestMapping(value = "/decision", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public String decision(@RequestBody DecisionApiRequest apiRequest) {
long start = System.currentTimeMillis();
DecisionApiBizData bizData = apiRequest.getBiz_data();
Map<String, Object> map = new HashMap<>();
map.put("pid", bizData.getBusinessId());
map.put("uid", "");
map.put("reqType", 1);
map.put("engineId", bizData.getEngineId());
map.put("organId", bizData.getOrganId());
SessionData sessionData = new SessionData();
sessionData.setOrganId(bizData.getOrganId());
sessionData.setEngineId(bizData.getEngineId());
sessionData.setReqType(1);
SessionManager.setSession(sessionData);
if(bizData.getFields() != null){
map.put("fields", bizData.getFields());
} else {
map.put("fields", new HashMap<>());
}
String result = engineApiService.engineApi(map);
long end = System.currentTimeMillis();
logger.info("============ 接口调用耗时:{}ms ============", (end -start));
return result;
}
@RequestMapping(value = "/batchExecute", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public List batchExecute(@RequestBody List<DecisionApiRequest> requestList){
List<String> list = new ArrayList<>();
for (DecisionApiRequest apiRequest : requestList) {
String decision = this.decision(apiRequest);
list.add(decision);
}
return list;
}
}

View File

@@ -0,0 +1,23 @@
package com.baoying.enginex.executor.engine.enums;
public enum CallBackTypeEnum {
SYNC(1,"同步"),
ASYNC(2,"异步");
private int code;
private String message;
CallBackTypeEnum(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
}

View File

@@ -0,0 +1,125 @@
package com.baoying.enginex.executor.engine.enums;
import com.baoying.enginex.executor.engine.consts.EnumConst;
public enum NodeTypeEnum {
/**
* 开始节点
*/
START(1, EnumConst.NODE_START),
/**
* 规则节点
*/
POLICY(2,EnumConst.NODE_POLICY),
/**
* 分组节点
*/
CLASSIFY(3, EnumConst.NODE_CLASSIFY),
/**
* 评分卡节点
*/
SCORECARD(4,EnumConst.NODE_SCORECARD),
/**
* 黑名单节点
*/
BLACKLIST(5,EnumConst.NODE_BLACK),
/**
* 白名单节点
*/
WHITELIST(6,EnumConst.NODE_WHITE),
/**
* 沙盒节点
*/
SANDBOX(7,EnumConst.NODE_SANDBOX),
/**
* 信用评级节点
*/
CREDITLEVEL(8,EnumConst.NODE_CREDIT_LEVEL),
/**
* 决策选项节点
*/
DECISION(9,EnumConst.NODE_DECISION),
/**
* 额度计算节点
*/
QUOTACALC(10,EnumConst.NODE_QUOTA_CALC),
/**
* 报表分析节点
*/
REPORT(11,EnumConst.NODE_REPORT),
/**
* 自定义节点
*/
CUSTOMIZE(12,EnumConst.NODE_CUSTOMIZE),
/**
* 复杂规则
*/
NODE_COMPLEXRULE(13,EnumConst.NODE_COMPLEXRULE),
/**
* 子引擎
*/
CHILD_ENGINE(14,EnumConst.NODE_CHILD_ENGINE),
/**
* 模型
*/
MODEL(15,EnumConst.NODE_MODEL),
/**
* 决策表
*/
DECISION_TABLES(16,EnumConst.DECISION_TABLES),
/**
* 决策树
*/
DECISION_TREE(17,EnumConst.DECISION_TREE),
/**
* 远程调用
*/
RPC(18, EnumConst.NODE_RPC),
/**
* 并行节点
*/
PARALLEL(19, EnumConst.NODE_PARALLEL),
/**
* 聚合节点
*/
AGGREGATION(20, EnumConst.NODE_AGGREGATION),
/**
* 冠军挑战节点
*/
CHAMPION_CHALLENGE(21, EnumConst.NODE_CHAMPION_CHALLENGE);
private int value;
private String type;
private NodeTypeEnum(int value, String type)
{
this.value = value;
this.type = type;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static NodeTypeEnum adapad(int value) {
for (NodeTypeEnum nodeTypeEnum : NodeTypeEnum.values()) {
if (nodeTypeEnum.getValue() == value) {
return nodeTypeEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,9 @@
package com.baoying.enginex.executor.engine.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoying.enginex.executor.engine.model.Engine;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface EngineMapper extends BaseMapper<Engine> {
}

View File

@@ -0,0 +1,18 @@
package com.baoying.enginex.executor.engine.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoying.enginex.executor.engine.model.EngineNode;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface EngineNodeMapper extends BaseMapper<EngineNode> {
/**
* 根据版本id获取版本下的所有节点
* @param engineVersionId
* @return
*/
List<EngineNode> getEngineNodeListByVersionId(@Param("engineVersionId") Long engineVersionId);
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.engine.mapper.EngineNodeMapper">
<cache></cache>
<resultMap id="EngineNodeMap" type="engineNode">
<id column="node_id" jdbcType="INTEGER" property="nodeId" />
<result column="version_id" jdbcType="INTEGER" property="versionId" />
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
<result column="node_name" jdbcType="VARCHAR" property="nodeName" />
<result column="node_code" jdbcType="VARCHAR" property="nodeCode" />
<result column="node_order" jdbcType="INTEGER" property="nodeOrder" />
<result column="node_type" jdbcType="INTEGER" property="nodeType" />
<result column="node_x" jdbcType="DECIMAL" property="nodeX" />
<result column="node_y" jdbcType="DECIMAL" property="nodeY" />
<result column="node_json" jdbcType="LONGVARCHAR" property="nodeJson" />
<result column="node_script" jdbcType="LONGVARCHAR" property="nodeScript" />
<result column="next_nodes" jdbcType="LONGVARCHAR" property="nextNodes" />
<result column="params" jdbcType="LONGVARCHAR" property="params" />
<result column="snapshot" jdbcType="LONGVARCHAR" property="snapshot" />
</resultMap>
<sql id="Base_Column_List">
node_id, parent_id, version_id, node_name, node_code, node_order, node_type, node_x, node_y,node_json,node_script,next_nodes,params,snapshot
</sql>
<select id="getEngineNodeListByVersionId" parameterType="long" resultMap="EngineNodeMap">
select <include refid="Base_Column_List"/> from t_engine_node where version_id =#{engineVersionId}
ORDER BY node_order ASC
</select>
</mapper>

View File

@@ -0,0 +1,72 @@
package com.baoying.enginex.executor.engine.mapper;
import com.baoying.enginex.executor.engine.model.EngineResultSet;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface EngineResultSetMapper {
/**
*
* 增加结果集
* @param resultSet 结果集对象
* @return 返回结果
* @see
*/
int insertResultSet(EngineResultSet resultSet);
/**
*
* 查询结果集列表
* @param resultSet 查询对象
* @return 返回结果集
* @see
*/
List<EngineResultSet> getResultSetByList(EngineResultSet resultSet);
/**
* 根据引擎编号和时间段获取结果集数据
* @param map
* @return
*/
List<EngineResultSet> getEngineResultSetBySegment(Map map);
/**
*
* 通过主键编号得到
* @param resultSet 对象
* @return 返回对象
* @see
*/
EngineResultSet getResultSetById(EngineResultSet resultSet);
List<EngineResultSet> getResultSetDetailsById(long resultSetId);
/**
* 查找引擎id的批量测试结果
* yuanlinfeng
* @param resultSetId
* @return
*/
List<EngineResultSet> getBatchTestResultSetByEngineId(Map<String, Object> paramMap);
/**
* 查找引擎批量测试批次号的所有测试结果
* yuanlinfeng
* @param resultSetId
* @return
*/
List<EngineResultSet> getBatchTestResultSetByBatchNo(Map<String, Object> paramMap);
/**
* 更新结果出参
* @param resultSet
*/
void updateResultOutput(EngineResultSet resultSet);
void updateResultById(@Param("resultId") Integer resultId, @Param("rowKeyStr") String rowKeyStr);
}

View File

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.engine.mapper.EngineResultSetMapper">
<resultMap type="engineresultset" id="engineresultsetMap">
<id column="id" property="id"/>
<result column="input" property="input"/>
<result column="create_datetime" property="create_datetime"/>
<result column="result" property="result"/>
<result column="engine_id" property="engine_id"/>
<result column="uuid" property="uuid"/>
<result column="engine_version" property="engine_version"/>
<result column="engine_name" property="engine_name"/>
<result column="engine_code" property="engine_code"/>
<result column="type" property="type"/>
<result column="sub_version" property="subVersion"/>
<result column="scorecardscore" property="scorecardscore"/>
<result column="batch_no" property="batchNo"/>
<result column="datilResult" property="datilResult"/>
<result column="startTime" property="startTime"/>
<result column="costTime" property="costTime"/>
<collection property="resultSetList" column="id" select="selectResultSetList" ofType="resultsetlist" javaType="ArrayList" />
</resultMap>
<resultMap type="resultsetlist" id="resultSetListResult">
<id column="subId" property="id"/>
<result column="subType" property="type"/>
<result column="code" property="code"/>
<result column="name" property="name"/>
<result column="description" property="description"/>
<result column="resultset_id" property="resultsetId"/>
<result column="expression" property="expression"/>
</resultMap>
<select id="selectResultSetList" parameterType="Long" resultType="engineresultset" resultMap="resultSetListResult" >
select
r.id,r.input,r.create_datetime,r.result,r.engine_id,r.uuid,r.engine_version,r.engine_name,r.engine_code,
r.type,r.sub_version,r.scorecardscore,
s.id as subId,s.type as subType,s.code,s.name,s.description,s.resultset_id,s.expression
from t_resultset r join t_resultset_list s on r.id = s.resultset_id where r.id = #{resultSetId} order by r.id asc
</select>
<select id="getResultSetDetailsById" parameterType="Long" resultMap="engineresultsetMap">
select *
from t_resultset
where id = #{resultSetId}
</select>
<!-- 新增引擎并返回ID -->
<insert id="insertResultSet" parameterType="engineresultset" useGeneratedKeys="true" keyProperty="id">
INSERT INTO
t_resultset
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uid != null">
uid,
</if>
<if test="pid != null">
pid,
</if>
<if test="input != null">
input,
</if>
<if test="output != null">
output,
</if>
<if test="result != null">
result,
</if>
<if test="engine_id != null">
engine_id,
</if>
<if test="uuid != null">
uuid,
</if>
<if test="engine_version != null">
engine_version,
</if>
<if test="engine_name != null">
engine_name,
</if>
<if test="engine_code != null">
engine_code,
</if>
<if test="type != null">
type,
</if>
<if test="subVersion != null">
sub_version,
</if>
<if test="scorecardscore != null">
scorecardscore,
</if>
<if test="batchNo != null">
batch_no,
</if>
<if test="datilResult != null">
datilResult,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uid != null">
#{uid},
</if>
<if test="pid != null">
#{pid},
</if>
<if test="input != null">
#{input},
</if>
<if test="output != null">
#{output},
</if>
<if test="result != null">
#{result},
</if>
<if test="engine_id != null">
#{engine_id},
</if>
<if test="uuid != null">
#{uuid},
</if>
<if test="engine_version != null">
#{engine_version},
</if>
<if test="engine_name != null">
#{engine_name},
</if>
<if test="engine_code != null">
#{engine_code},
</if>
<if test="type != null">
#{type},
</if>
<if test="subVersion != null">
#{subVersion},
</if>
<if test="scorecardscore != null">
#{scorecardscore},
</if>
<if test="batchNo != null">
#{batchNo},
</if>
<if test="datilResult != null">
#{datilResult},
</if>
</trim>
</insert>
<select id="getResultSetByList" parameterType="engineresultset" resultMap="engineresultsetMap" >
SELECT
*
FROM
t_engine
where
status>-1 and
organ_id =#{organId}
<if test="startDate != null and startDate !=''">
<![CDATA[ and create_datetime >= #{startDate} ]]>
</if>
<if test="endDate != null and endDate !=''">
<![CDATA[ and create_datetime <= #{endDate} ]]>
</if>
order by create_datetime desc
</select>
<select id="getEngineResultSetBySegment" parameterType="map" resultMap="engineresultsetMap" >
SELECT
*
FROM
t_resultset
where engine_id = #{engineId}
<if test="startDate != null and startDate !=''">
<![CDATA[ and create_datetime >= #{startDate} ]]>
</if>
<if test="endDate != null and endDate !=''">
<![CDATA[ and create_datetime <= #{endDate} ]]>
</if>
order by create_datetime desc
</select>
<select id="getResultSetById" parameterType="engineresultset" resultMap="engineresultsetMap">
select * from t_resultset where id = #{id}
</select>
<select id="getBatchTestResultSetByEngineId" parameterType="map" resultMap="engineresultsetMap">
select batch_no, engine_id, engine_name, startTime, costTime
from(
select rs.batch_no, e.id as engine_id, e.name as engine_name
, min(rs.create_datetime) as startTime
, TIMESTAMPDIFF(second,min(rs.create_datetime),max(rs.create_datetime)) as costTime
from t_resultset rs, t_engine e
where rs.engine_id = e.id
and ( batch_no is not null and batch_no != '' )
and e.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and rs.engine_id = #{engineId}
group by rs.batch_no, e.id, e.name
)x
order by x.startTime desc
</select>
<select id="getBatchTestResultSetByBatchNo" parameterType="map" resultMap="engineresultsetMap">
select rs.*
from t_resultset rs, t_engine e
where rs.engine_id = e.id
and e.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and rs.batch_no = #{batchNo}
</select>
<update id="updateResultOutput" parameterType="engineresultset">
update t_resultset t set t.`output` = #{output} where t.`id` = #{id}
</update>
<update id="updateResultById">
UPDATE t_resultset
set hbase_row_key = #{rowKeyStr}
where id = #{resultId}
</update>
</mapper>

View File

@@ -0,0 +1,27 @@
package com.baoying.enginex.executor.engine.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoying.enginex.executor.engine.model.EngineVersion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface EngineVersionMapper extends BaseMapper<EngineVersion> {
/**
* 获取引擎正在运行中的版本
* @param engineId
* @return
*/
EngineVersion getRunningVersion(@Param("engineId") Long engineId);
/**
* 获取指定版本信息
* @param paramMap
* @return
*/
EngineVersion getTargetEngineVersion(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.engine.mapper.EngineVersionMapper">
<cache></cache>
<resultMap id="EngineVersionMap" type="EngineVersion">
<id column="version_id" jdbcType="INTEGER" property="versionId" />
<result column="engine_id" jdbcType="INTEGER" property="engineId" />
<result column="version" jdbcType="INTEGER" property="version" />
<result column="sub_version" jdbcType="INTEGER" property="subVersion" />
<result column="boot_state" jdbcType="INTEGER" property="bootState" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="layout" jdbcType="INTEGER" property="layout" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="create_time" jdbcType="VARCHAR" property="createTime" />
<result column="latest_user" jdbcType="INTEGER" property="latestUser" />
<result column="latest_time" jdbcType="VARCHAR" property="latestTime" />
<result column="engineName" jdbcType="VARCHAR" property="engineName" />
<result column="description" jdbcType="VARCHAR" property="engineDesc" />
<collection property="engineNodeList" ofType="engineNode" column="version_id" select ="com.baoying.enginex.executor.engine.mapper.EngineNodeMapper.getEngineNodeListByEngineVersionId"></collection>
</resultMap>
<sql id="Base_Column_List">
version_id, engine_id, version, boot_state, status, layout, user_id, create_time,
latest_user, latest_time, sub_version
</sql>
<select id="getTargetEngineVersion" parameterType="java.util.Map" resultType="EngineVersion">
select
<include refid="Base_Column_List" />
from t_engine_version
where engine_id = #{engineId,jdbcType=INTEGER}
and version = #{version,jdbcType=INTEGER}
and sub_version = #{subversion,jdbcType=INTEGER}
order by sub_version desc
limit 1
</select>
<select id="getRunningVersion" parameterType="java.lang.Long" resultType="EngineVersion">
select
<include refid="Base_Column_List" />
from t_engine_version
where engine_id = #{engineId,jdbcType=INTEGER}
and boot_state = 1
</select>
</mapper>

View File

@@ -0,0 +1,42 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Map;
public class ComplexRule {
private Map<String,Object> result;
private String out;
private Map<String, Object> returnResult;
public Map<String, Object> getReturnResult() {
return returnResult;
}
public void setReturnResult(Map<String, Object> returnResult) {
this.returnResult = returnResult;
}
public Map<String, Object> getResult() {
return result;
}
public void setResult(Map<String, Object> result) {
this.result = result;
}
public String getOut() {
return out;
}
public void setOut(String out) {
this.out = out;
}
}

View File

@@ -0,0 +1,62 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Map;
public class DecisionOptions {
private String code;//决策选项code
private String name;//决策选项名称
private Map<String , Object> inFields;//输入字段
private Map<String, Object> outFields;//输出字段
private Integer fType;//输出字段类型
private Long nodId;//节点id
private String fieldScope;
public String getFieldScope() {
return fieldScope;
}
public void setFieldScope(String fieldScope) {
this.fieldScope = fieldScope;
}
public Long getNodId() {
return nodId;
}
public void setNodId(Long nodId) {
this.nodId = nodId;
}
public Integer getfType() {
return fType;
}
public void setfType(Integer fType) {
this.fType = fType;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getInFields() {
return inFields;
}
public void setInFields(Map<String, Object> inFields) {
this.inFields = inFields;
}
public Map<String, Object> getOutFields() {
return outFields;
}
public void setOutFields(Map<String, Object> outFields) {
this.outFields = outFields;
}
}

View File

@@ -0,0 +1,16 @@
package com.baoying.enginex.executor.engine.model;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import java.io.Serializable;
@Data
public class DecisionReqModel implements Serializable {
private static final long serialVersionUID = 1743177499998353115L;
private String pid;
private String uid;
private JSONObject fields;
}

View File

@@ -0,0 +1,90 @@
package com.baoying.enginex.executor.engine.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
@TableName("t_engine")
public class Engine implements Serializable {
private static final long serialVersionUID = -6611916471057697499L;
/**
* 主键id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 引擎编号
*/
private String code;
/**
* 引擎名称
*/
private String name;
/**
* 引擎描述
*/
private String description;
/**
* 引擎状态
*/
private Integer status;
/**
* 创建时间
*/
private Date createDatetime;
/**
* 修改时间
*/
private Date updateDatetime;
/**
* 创建人
*/
private Long creator;
/**
* 修改人
*/
private Long userId;
/**
* 公司编号
*/
private Long organId;
/**
* 调用方式 1同步2异步
*/
private Integer callbackType;
/**
* 回调地址
*/
private String callbackUrl;
/**
* 异常回调地址
*/
private String exceptionCallbackUrl;
/**
* 引擎版本集合
*/
@TableField(exist = false)
private List<EngineVersion> engineVersionList;
}

View File

@@ -0,0 +1,85 @@
package com.baoying.enginex.executor.engine.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("t_engine_node")
public class EngineNode implements Serializable{
private static final long serialVersionUID = -1867357850853531748L;
/**
* 节点编号
*/
@TableId(type = IdType.AUTO)
private Long nodeId;
/**
* 版本编号
*/
private Long versionId;
/**
* 节点名称
*/
private String nodeName;
/**
* 节点code
*/
private String nodeCode;
/**
* 节点顺序
*/
private Integer nodeOrder;
/**
* 节点类型
*/
private Integer nodeType;
/**
* 节点json
*/
private String nodeJson;
/**
* 节点X轴
*/
private double nodeX;
/**
* 节点Y轴
*/
private double nodeY;
/**
* 节点脚本
*/
private String nodeScript;
/**
* 下一节点
*/
private String nextNodes;
/**
* 节点类型,图标等信息
*/
private String params;
/**
* 父节点编号
*/
private String parentId;
/**
* 节点配置快照
*/
private String snapshot;
}

View File

@@ -0,0 +1,252 @@
package com.baoying.enginex.executor.engine.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors
public class EngineResultSet {
private Integer id;
private String uid;
private String pid;
private String input;
private String output;
private Date create_datetime;
private String result;
private Long engine_id;
private Integer engine_version;
private String uuid;
private String engine_name;
private String engine_code;
private Date startDate;
private Date endDate;
private Integer type;
private Integer subVersion;
private String scorecardscore;
private String datilResult;
/**
*决策表结果
*/
private String decisionTablesResult;
/**
*决策树结果
*/
private String decisionTreeResult;
/**
* 批量测试批次号
*/
private String batchNo;
/**
* 批量测试每批测试开始时间
*/
private Date startTime;
/**
* 批量测试每批次花费时间
*/
private String costTime;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getScorecardscore() {
return scorecardscore;
}
public void setScorecardscore(String scorecardscore) {
this.scorecardscore = scorecardscore;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getSubVersion() {
return subVersion;
}
public void setSubVersion(Integer subVersion) {
this.subVersion = subVersion;
}
private List<ResultSetList> resultSetList;
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public String getEngine_name() {
return engine_name;
}
public void setEngine_name(String engine_name) {
this.engine_name = engine_name;
}
public String getEngine_code() {
return engine_code;
}
public void setEngine_code(String engine_code) {
this.engine_code = engine_code;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public Date getCreate_datetime() {
return create_datetime;
}
public void setCreate_datetime(Date create_datetime) {
this.create_datetime = create_datetime;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public Long getEngine_id() {
return engine_id;
}
public void setEngine_id(Long engine_id) {
this.engine_id = engine_id;
}
public Integer getEngine_version() {
return engine_version;
}
public void setEngine_version(Integer engine_version) {
this.engine_version = engine_version;
}
public List<ResultSetList> getResultSetList() {
return resultSetList;
}
public void setResultSetList(List<ResultSetList> resultSetList) {
this.resultSetList = resultSetList;
}
public String getBatchNo() {
return batchNo;
}
public void setBatchNo(String batchNo) {
this.batchNo = batchNo;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public String getCostTime() {
return costTime;
}
public void setCostTime(String costTime) {
this.costTime = costTime;
}
public String getDatilResult() {
return datilResult;
}
public void setDatilResult(String datilResult) {
this.datilResult = datilResult;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
}

View File

@@ -0,0 +1,74 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Map;
public class EngineRule {
private String refused;
private String code ;
private String policyName;
private String desc;
private String Strtus;
private Map<String, String >fields;
public String getStrtus() {
return Strtus;
}
public void setStrtus(String strtus) {
Strtus = strtus;
}
public String getRefused() {
return refused;
}
public void setRefused(String refused) {
this.refused = refused;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getPolicyName() {
return policyName;
}
public void setPolicyName(String policyName) {
this.policyName = policyName;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Map<String, String> getFields() {
return fields;
}
public void setFields(Map<String, String> fields) {
this.fields = fields;
}
}

View File

@@ -0,0 +1,79 @@
package com.baoying.enginex.executor.engine.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@TableName("t_engine_version")
public class EngineVersion implements Serializable {
private static final long serialVersionUID = 2923432053414979455L;
/**
* 版本编号
*/
@TableId(type = IdType.AUTO)
private Long versionId;
/**
* 引擎编号
*/
private Long engineId;
/**
* 版本号
*/
private Integer version;
/**
* 子版本
*/
private Integer subVersion;
/**
* 部署状态
*/
private Integer bootState;
/**
* 版本状态
*/
private Integer status;
/**
* 布局方式
*/
private Integer layout;
/**
* 创建者
*/
private Long userId;
/**
* 创建时间
*/
private String createTime;
/**
* 修改人
*/
private Long latestUser;
/**
* 最后修改时间
*/
private String latestTime;
/**
* 节点集合
* */
@TableField(exist = false)
private List<EngineNode> engineNodeList;
}

View File

@@ -0,0 +1,53 @@
package com.baoying.enginex.executor.engine.model;
import java.io.Serializable;
public class IndexEngineReportVo implements Serializable {
private static final long serialVersionUID = -1274492726714567316L;
private String dayTime;
private String monthTime;
private Integer engineId;
private String engineName;
private Integer useNum;
public String getDayTime() {
return dayTime;
}
public void setDayTime(String dayTime) {
this.dayTime = dayTime;
}
public String getMonthTime() {
return monthTime;
}
public void setMonthTime(String monthTime) {
this.monthTime = monthTime;
}
public Integer getEngineId() {
return engineId;
}
public void setEngineId(Integer engineId) {
this.engineId = engineId;
}
public String getEngineName() {
return engineName;
}
public void setEngineName(String engineName) {
this.engineName = engineName;
}
public Integer getUseNum() {
return useNum;
}
public void setUseNum(Integer useNum) {
this.useNum = useNum;
}
}

View File

@@ -0,0 +1,36 @@
package com.baoying.enginex.executor.engine.model;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class InputParam {
private Map<String ,Object> inputParam;
private List<Result> result;
// 数组中 符合条件的对象属性
private Map<String, Set<String>> outputParam;
public Map<String, Object> getInputParam() {
return inputParam;
}
public void setInputParam(Map<String, Object> inputParam) {
this.inputParam = inputParam;
}
public List<Result> getResult() {
return result;
}
public void setResult(List<Result> result) {
this.result = result;
}
public Map<String, Set<String>> getOutputParam() {
return outputParam;
}
public void setOutputParam(Map<String, Set<String>> outputParam) {
this.outputParam = outputParam;
}
}

View File

@@ -0,0 +1,63 @@
package com.baoying.enginex.executor.engine.model;
import java.io.Serializable;
/**
* 节点与知识库映射关系模型
* @author sunyk
*
*/
public class NodeKnowledge implements Serializable {
private static final long serialVersionUID = -55965399064577379L;
/**
* 主键编号
*/
private Long relId;
/**
* 节点编号
*/
private Long nodeId;
/**
* 知识库信息编号
*/
private Long knowledgeId;
/**
* 知识库类型1规则2评分卡
*/
private Integer knowledgeType;
public Long getRelId() {
return relId;
}
public void setRelId(Long relId) {
this.relId = relId;
}
public Long getNodeId() {
return nodeId;
}
public void setNodeId(Long nodeId) {
this.nodeId = nodeId;
}
public Long getKnowledgeId() {
return knowledgeId;
}
public void setKnowledgeId(Long knowledgeId) {
this.knowledgeId = knowledgeId;
}
public Integer getKnowledgeType() {
return knowledgeType;
}
public void setKnowledgeType(Integer knowledgeType) {
this.knowledgeType = knowledgeType;
}
}

View File

@@ -0,0 +1,63 @@
package com.baoying.enginex.executor.engine.model;
import java.util.List;
import java.util.Map;
public class Result {
private String resultType;//规则1代表加减法2拒绝规则
private Integer id;//规则编号
private String code;//规则code
private String name;
private String value;
private Map<String, Object> map;//评分
private List<EngineRule> list;
public Map<String, Object> getMap() {
return map;
}
public void setMap(Map<String, Object> map) {
this.map = map;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getResultType() {
return resultType;
}
public void setResultType(String resultType) {
this.resultType = resultType;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<EngineRule> getList() {
return list;
}
public void setList(List<EngineRule> list) {
this.list = list;
}
}

View File

@@ -0,0 +1,76 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Date;
public class ResultSetList {
private Long id;
private Integer type;//1.黑名单。2.白名单。3.拒绝规则。4.加减分规则
private String code;
private String name;
private String description;
private String resultsetId;
private String expression;
private Date startDate;
private Date endDate;
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getResultsetId() {
return resultsetId;
}
public void setResultsetId(String resultsetId) {
this.resultsetId = resultsetId;
}
public String getExpression() {
return expression;
}
public void setExpression(String expression) {
this.expression = expression;
}
}

View File

@@ -0,0 +1,53 @@
package com.baoying.enginex.executor.engine.model;
public class Sandbox {
private Integer sandbox;//沙盒组编号
private Integer proportion;//沙盒占用比例
private String nextNode;//下个节点序号
private Integer sum;//分母
private Integer startNumber;//起始值
private Integer endNumberl;//终止值
public Integer getSum() {
return sum;
}
public void setSum(Integer sum) {
this.sum = sum;
}
public Integer getStartNumber() {
return startNumber;
}
public void setStartNumber(Integer startNumber) {
this.startNumber = startNumber;
}
public Integer getEndNumberl() {
return endNumberl;
}
public void setEndNumberl(Integer endNumberl) {
this.endNumberl = endNumberl;
}
public Integer getSandbox() {
return sandbox;
}
public void setSandbox(Integer sandbox) {
this.sandbox = sandbox;
}
public Integer getProportion() {
return proportion;
}
public void setProportion(Integer proportion) {
this.proportion = proportion;
}
public String getNextNode() {
return nextNode;
}
public void setNextNode(String nextNode) {
this.nextNode = nextNode;
}
}

View File

@@ -0,0 +1,49 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Map;
public class ScoreCardEngine {
private String code;//评分卡编号
private String name;//评分卡名称
private String scoreCardName;//评分卡名称
private Map<String , Object> inFields;//评分可用到的字段
private Map<String, Object> outFields;//评分卡
public String getScoreCardName() {
return scoreCardName;
}
public void setScoreCardName(String scoreCardName) {
this.scoreCardName = scoreCardName;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getInFields() {
return inFields;
}
public void setInFields(Map<String, Object> inFields) {
this.inFields = inFields;
}
public Map<String, Object> getOutFields() {
return outFields;
}
public void setOutFields(Map<String, Object> outFields) {
this.outFields = outFields;
}
}

View File

@@ -0,0 +1,37 @@
package com.baoying.enginex.executor.engine.model;
public class TestRule {
private String id;
private String ruleid;
private String param;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRuleid() {
return ruleid;
}
public void setRuleid(String ruleid) {
this.ruleid = ruleid;
}
public String getParam() {
return param;
}
public void setParam(String param) {
this.param = param;
}
}

View File

@@ -0,0 +1,18 @@
package com.baoying.enginex.executor.engine.model.request;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.Map;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class DecisionApiBizData {
private String businessId; // 业务id
private Long organId; // 组织id
private Long engineId; // 引擎id
private Map<String, Object> fields; // 指标字段键值对
}

View File

@@ -0,0 +1,17 @@
package com.baoying.enginex.executor.engine.model.request;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class DecisionApiRequest {
private String tp_code; // 调用方编码
private String timestamp; // 精确到毫秒
private String sign; // 签名
private String biz_enc; // biz_data加密方式0不加密1加密
private DecisionApiBizData biz_data; // 请求的业务数据json格式的字符串
}

View File

@@ -0,0 +1,8 @@
package com.baoying.enginex.executor.engine.service;
import java.util.Map;
public interface EngineApiService {
String engineApi(Map<String, Object> paramJson);
}

View File

@@ -0,0 +1,16 @@
package com.baoying.enginex.executor.engine.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoying.enginex.executor.engine.model.EngineNode;
import java.util.List;
public interface EngineNodeService extends IService<EngineNode> {
/**
* 根据版本id获取版本下的所有节点
* @param versionId
* @return
*/
List<EngineNode> getEngineNodeListByVersionId(Long versionId);
}

View File

@@ -0,0 +1,14 @@
package com.baoying.enginex.executor.engine.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoying.enginex.executor.engine.model.Engine;
public interface EngineService extends IService<Engine> {
/**
* 根据id查询引擎
* @param id
* @return
*/
Engine getEngineById(Long id);
}

View File

@@ -0,0 +1,17 @@
package com.baoying.enginex.executor.engine.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoying.enginex.executor.engine.model.EngineVersion;
public interface EngineVersionService extends IService<EngineVersion> {
EngineVersion getEngineVersionById(Long versionId);
/**
* 获取引擎正在运行中的版本
* @param engineId
* @return
*/
EngineVersion getRunningVersion(Long engineId);
}

View File

@@ -0,0 +1,400 @@
package com.baoying.enginex.executor.engine.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baoying.enginex.executor.engine.enums.NodeTypeEnum;
import com.baoying.enginex.executor.engine.mapper.EngineResultSetMapper;
import com.baoying.enginex.executor.engine.model.Engine;
import com.baoying.enginex.executor.engine.model.EngineNode;
import com.baoying.enginex.executor.engine.model.EngineResultSet;
import com.baoying.enginex.executor.engine.model.EngineVersion;
import com.baoying.enginex.executor.engine.service.EngineApiService;
import com.baoying.enginex.executor.engine.service.EngineNodeService;
import com.baoying.enginex.executor.engine.service.EngineService;
import com.baoying.enginex.executor.engine.service.EngineVersionService;
import com.baoying.enginex.executor.node.service.impl.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.web.client.AsyncRestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
@Service
public class EngineApiServiceImpl implements EngineApiService {
private static final Logger logger = LoggerFactory.getLogger(EngineApiServiceImpl.class);
@Autowired
public EngineService engineService;
@Resource
public EngineVersionService engineVersionService;
@Resource
public EngineNodeService engineNodeService;
@Resource
public EngineResultSetMapper resultSetMapper;
@Autowired
private DecisionOptionsNode decisionOptionsNode;
@Autowired
private RuleSetNode ruleSetNode;
@Autowired
private GroupNode groupNode;
@Autowired
private SandboxProportionNode sandboxProportionNode;
@Autowired
private AsyncRestTemplate asyncRestTemplate;
@Override
public String engineApi(Map<String, Object> paramJson) {
logger.info("请求参数paramJson: {}", JSONObject.toJSONString(paramJson));
JSONObject jsonObject = new JSONObject();
JSONArray resultJson = new JSONArray();
Map<String, Map<String,Object>> featureMaps = new ConcurrentHashMap<>();
//时间差小于等于30分钟并且鉴权成功
if (true){
Long organId = Long.valueOf(paramJson.get("organId").toString());
Long engineId = Long.valueOf(paramJson.get("engineId").toString());
//获取引擎信息
Engine engine = engineService.getEngineById(engineId);
if(engine != null && !engine.getOrganId().equals(organId)){
// todo 校验引擎是否为该组织所属
}
//获取引擎正在运行中的版本
EngineVersion engineVersion = engineVersionService.getRunningVersion(engineId);
if (engineVersion != null) {
//返回引擎下的所有节点集合
List<EngineNode> engineNodeList = engineNodeService.getEngineNodeListByVersionId(engineVersion.getVersionId());
Map<String, EngineNode> engineNodeMap = getEngineNodeListByMap(engineNodeList);
try {
//变量池
Map<String, Object> inputParam = new ConcurrentHashMap<>();
inputParam.putAll(JSONObject.parseObject(JSONObject.toJSONString(paramJson.get("fields")), Map.class));
EngineNode engineNode = engineNodeMap.get("ND_START");
if (null != engineNode && null != engineNode.getNextNodes()) {
//返回输出结果
Map<String, Object> outMap = new ConcurrentHashMap<>();
// 记录执行前全量指标
featureMaps.put("before",inputParam);
//节点执行方法
recursionEngineNode(inputParam, engineNodeMap.get(engineNode.getNextNodes()), engineNodeMap, outMap);
jsonObject.put("status", "0x0000");
jsonObject.put("msg", "执行成功");
if (outMap.containsKey("centens") && outMap.get("centens").equals("true")) {
jsonObject.put("status", "0x0006");
jsonObject.put("msg", "获取数据失败");
jsonObject.put("data", "");
return jsonObject.toString();
}
//记录执行后的全量指标
featureMaps.put("after",inputParam);
paramJson.put("versionId",engineNode.getVersionId());
String json = JSONObject.toJSONString(inputParam);
jsonObject.put("input", JSONObject.parseObject(json));
EngineResultSet resultSet = new EngineResultSet();
resultSet.setEngine_code(engine.getCode());
resultSet.setInput(json);
resultSet.setEngine_id(engine.getId());
resultSet.setEngine_name(engine.getName());
resultSet.setType(2);
resultSet.setSubVersion(engineVersion.getSubVersion());
resultSet.setUid(String.valueOf(paramJson.get("uid")));
resultSet.setPid(String.valueOf(paramJson.get("pid")));
//决策表最终结果
if (outMap.containsKey("decisionTables")){
jsonObject.put("decisionTablesResult", outMap.get("decisionTables").toString());
resultSet.setDecisionTablesResult(outMap.get("decisionTables").toString());
}
//决策树最终结果
if (outMap.containsKey("decisionTree")){
jsonObject.put("decisionTreeResult", outMap.get("decisionTree").toString());
resultSet.setDecisionTreeResult(outMap.get("decisionTree").toString());
}
// 节点终止输出
if (outMap.containsKey("result")) {
resultSet.setResult(outMap.get("result").toString());
//决策选项最终结果
jsonObject.put("result", outMap.get("result").toString());
}
if (outMap.containsKey("blackJson")) {
resultJson.add(new JSONObject().parse(outMap.get("blackJson").toString()));
}
if (outMap.containsKey("whiteJson")) {
resultJson.add(new JSONObject().parse(outMap.get("whiteJson").toString()));
}
if (outMap.containsKey("ruleJson")) {
//规则集节点输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 2);
ruleJson.put("resultJson", outMap.get("ruleJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("scoreJson")) {
//评分卡输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 4);
ruleJson.put("resultJson", outMap.get("scoreJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("decisionJson")) {
//决策选项输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 9);
ruleJson.put("resultJson", outMap.get("decisionJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("childEngineJson")) {
//子引擎节点输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 14);
ruleJson.put("resultJson", outMap.get("childEngineJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("modelJson")) {
//模型节点输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 15);
ruleJson.put("resultJson", outMap.get("modelJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("decisionTablesJson")) {
//决策表输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 16);
ruleJson.put("resultJson", outMap.get("decisionTablesJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("decisionTreeJson")) {
//决策树输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 17);
ruleJson.put("resultJson", outMap.get("decisionTreeJson"));
resultJson.add(ruleJson);
}
jsonObject.put("data", resultJson);
String result = JSONObject.toJSONString(jsonObject);
JSONObject tmpJsonObject = JSONObject.parseObject(result);
tmpJsonObject.remove("input");
resultSet.setOutput(JSONObject.toJSONString(tmpJsonObject));
resultSetMapper.insertResultSet(resultSet);
Integer resultId = resultSet.getId();
// 正常返回结果回调
decisionCallback(engine.getCallbackUrl(), paramJson, result);
}
} catch (Exception e) {
logger.error("接口请求异常", e);
jsonObject.put("status", "0x0005");
jsonObject.put("msg", "执行失败");
jsonObject.put("data", "");
// 异常回调
decisionCallback(engine.getCallbackUrl(), paramJson, "执行失败");
}
} else {
jsonObject.put("status", "0x0004");
jsonObject.put("msg", "请求引擎不存在或尚未部署运行");
jsonObject.put("data", "");
}
} else {
jsonObject.put("status", "0x0001");
jsonObject.put("msg", "鉴权失败,非法调用");
jsonObject.put("data", "");
}
return jsonObject.toString();
}
/**
* 递归执行节点
* @param inputParam
* @param engineNode
* @param engineNodeMap
* @param outMap
*/
private EngineNode recursionEngineNode(Map<String, Object> inputParam, EngineNode engineNode, Map<String, EngineNode> engineNodeMap, Map<String, Object> outMap) {
logger.info("请求参数--" + "inputParam:" + JSONObject.toJSONString(inputParam));
EngineNode resultNode = null; // 结束时返回节点: 串行流程返回null、并行流程返回聚合节点
if(engineNode == null){
return null;
}
// 获取节点所需的指标
getNodeField(engineNode, inputParam);
// 执行节点逻辑
runNode(engineNode, inputParam, outMap);
//用于存储执行过的节点
List<String> executedNodeList = new ArrayList<>();
if(outMap.containsKey("executedNodes")){
executedNodeList =(List<String>) outMap.get("executedNodes");
}
executedNodeList.add(engineNode.getNodeId()+"");
// 更新执行过节点数组
outMap.put("executedNodes",executedNodeList);
// 递归执行下一个节点
if (StringUtils.isNotBlank(engineNode.getNextNodes())) {
// 串行节点执行
EngineNode nextEngineNode = engineNodeMap.get(engineNode.getNextNodes());
//如果输出的map里面有nextNode则说明有分组需要走分组下面的节点
if (outMap.containsKey("nextNode")) {
nextEngineNode = engineNodeMap.get(outMap.get("nextNode"));
outMap.remove("nextNode");
}
if(nextEngineNode!=null&&nextEngineNode.getNodeType() == NodeTypeEnum.AGGREGATION.getValue()){
// 并行节点后面的分支为多线程执行,执行到聚合节点则结束
resultNode = nextEngineNode;
} else {
resultNode = recursionEngineNode(inputParam, nextEngineNode, engineNodeMap, outMap);
}
}
return resultNode;
}
/**
* 获取节点所需的指标
* @param engineNode
* @param inputParam
*/
private void getNodeField(EngineNode engineNode, Map<String, Object> inputParam) {
switch (engineNode.getNodeType()) {
case 2:
//规则
ruleSetNode.getNodeField(engineNode, inputParam);
break;
case 3:
//分组
groupNode.getNodeField(engineNode, inputParam);
break;
case 9:
//决策选项
decisionOptionsNode.getNodeField(engineNode, inputParam);
break;
default:
break;
}
}
/**
* 执行节点逻辑
* @param engineNode
* @param inputParam
* @param outMap
*/
private void runNode(EngineNode engineNode, Map<String, Object> inputParam, Map<String, Object> outMap) {
switch (engineNode.getNodeType()) {
case 2:
//规则
ruleSetNode.runNode(engineNode, inputParam, outMap);
break;
case 3:
//分组
groupNode.runNode(engineNode, inputParam, outMap);
break;
case 7:
//沙盒比例
sandboxProportionNode.runNode(engineNode, inputParam, outMap);
break;
case 9:
//决策选项
decisionOptionsNode.runNode(engineNode, inputParam, outMap);
break;
default:
break;
}
}
/**
* 把引擎节点以序号为key放入map
*
* @param nodelist 引擎节点
* @return map
* @see
*/
private Map<String, EngineNode> getEngineNodeListByMap(List<EngineNode> nodelist) {
Map<String, EngineNode> map = new HashMap<>();
for (int i = 0; i < nodelist.size(); i++) {
map.put(nodelist.get(i).getNodeCode(), nodelist.get(i));
}
return map;
}
/**
* 决策流执行完回调(包括决策流正常返回结果回调、以及异常回调)
* @param url
* @param paramJson
* @param result
*/
private void decisionCallback(String url, Map<String, Object> paramJson, String result){
if(StringUtils.isBlank(url)){
return;
}
Map<String, String> paramMap = new HashMap<>();
paramMap.put("paramJson", JSONObject.toJSONString(paramJson));
paramMap.put("result", result);
// 设置请求头
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
// 封装请求体
JSONObject body = JSONObject.parseObject(JSONObject.toJSONString(paramMap));
// 封装参数和头信息
HttpEntity<JSONObject> httpEntity = new HttpEntity(body, httpHeaders);
ListenableFuture<ResponseEntity<String>> future = asyncRestTemplate.postForEntity(url, httpEntity, String.class);
if(future != null){
future.addCallback(new ListenableFutureCallback<ResponseEntity<String>>() {
@Override
public void onFailure(Throwable throwable) {
logger.info("引擎回调异步调用失败", throwable);
}
@Override
public void onSuccess(ResponseEntity<String> stringResponseEntity) {
String result = stringResponseEntity.getBody();
logger.info("引擎回调异步调用成功result:{}", result);
}
});
}
}
}

View File

@@ -0,0 +1,45 @@
package com.baoying.enginex.executor.engine.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baoying.enginex.executor.canal.TableEnum;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.engine.mapper.EngineNodeMapper;
import com.baoying.enginex.executor.engine.model.EngineNode;
import com.baoying.enginex.executor.engine.service.EngineNodeService;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class EngineNodeServiceImpl extends ServiceImpl<EngineNodeMapper, EngineNode> implements EngineNodeService {
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Autowired
private EngineNodeMapper engineNodeMapper;
@Override
public List<EngineNode> getEngineNodeListByVersionId(Long versionId) {
List<EngineNode> engineNodeList = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getForeignKey(TableEnum.T_ENGINE_NODE, versionId);
engineNodeList = redisManager.getByForeignKey(key, EngineNode.class);
if(engineNodeList != null){
// 按node_order升序排序
engineNodeList = engineNodeList.stream().sorted(Comparator.comparing(EngineNode::getNodeOrder)).collect(Collectors.toList());
}
} else {
engineNodeList = engineNodeMapper.getEngineNodeListByVersionId(versionId);
}
return engineNodeList;
}
}

View File

@@ -0,0 +1,37 @@
package com.baoying.enginex.executor.engine.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baoying.enginex.executor.canal.TableEnum;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.engine.mapper.EngineMapper;
import com.baoying.enginex.executor.engine.model.Engine;
import com.baoying.enginex.executor.engine.service.EngineService;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class EngineServiceImpl extends ServiceImpl<EngineMapper, Engine> implements EngineService {
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Autowired
private EngineMapper engineMapper;
@Override
public Engine getEngineById(Long id) {
Engine engine = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getPrimaryKey(TableEnum.T_ENGINE, id);
engine = redisManager.getByPrimaryKey(key, Engine.class);
} else {
engine = engineMapper.selectById(id);
}
return engine;
}
}

View File

@@ -0,0 +1,56 @@
package com.baoying.enginex.executor.engine.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baoying.enginex.executor.canal.TableEnum;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.engine.mapper.EngineVersionMapper;
import com.baoying.enginex.executor.engine.model.EngineVersion;
import com.baoying.enginex.executor.engine.service.EngineVersionService;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class EngineVersionServiceImpl extends ServiceImpl<EngineVersionMapper, EngineVersion> implements EngineVersionService {
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Autowired
private EngineVersionMapper engineVersionMapper;
@Override
public EngineVersion getEngineVersionById(Long versionId) {
EngineVersion engineVersion = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getPrimaryKey(TableEnum.T_ENGINE_VERSION, versionId);
engineVersion = redisManager.getByPrimaryKey(key, EngineVersion.class);
} else {
engineVersion = engineVersionMapper.selectById(versionId);
}
return engineVersion;
}
@Override
public EngineVersion getRunningVersion(Long engineId) {
EngineVersion engineVersion = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getForeignKey(TableEnum.T_ENGINE_VERSION, engineId);
List<EngineVersion> list = redisManager.getByForeignKey(key, EngineVersion.class);
Optional<EngineVersion> optional = list.stream().filter(item -> item.getBootState() == 1).findFirst();
if(optional.isPresent()){
engineVersion = optional.get();
}
} else {
engineVersion = engineVersionMapper.getRunningVersion(engineId);
}
return engineVersion;
}
}

View File

@@ -0,0 +1,25 @@
package com.baoying.enginex.executor.engine.thread;
import com.baoying.enginex.executor.common.basefactory.CustomBeanFactory;
import com.baoying.enginex.executor.engine.service.EngineApiService;
import org.springframework.context.ApplicationContext;
import java.util.Map;
import java.util.concurrent.Callable;
public class EngineCallable implements Callable<String> {
private Map<String, Object> paramJson;
public EngineCallable(Map<String, Object> paramJson){
this.paramJson = paramJson;
}
@Override
public String call() {
ApplicationContext context = CustomBeanFactory.getContext();
EngineApiService engineApiService = (EngineApiService) context.getBean("engineApiServiceImpl");
String result = engineApiService.engineApi(paramJson);
return result;
}
}

View File

@@ -0,0 +1,36 @@
package com.baoying.enginex.executor.knowledge.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.knowledge.model.KnowledgeTree;
import java.util.List;
import java.util.Map;
public interface KnowledgeTreeMapper extends BaseMapper<KnowledgeTree> {
/**
* getTreeList(根据父节点id和组织id,查询其下的所有子节点)
* @author keke
* @param paramMap 参数集合
* @return 父节点下的所有子节点
* */
public List<KnowledgeTree> getTreeList(Map<String, Object> paramMap);
/**
* batchInsert:(批量新增节点)
* @author keke
* @param k 节点信息集合
* @return
* */
public int batchInsert(List<KnowledgeTree> k);
/**
* getTreeList(根据父节点id和组织id,查询其下的所有子节点,若节点下规则,则过滤掉)
* @author keke
* @param paramMap 参数集合
* @return 父节点下的所有子节点
* */
public List<KnowledgeTree> getTreeDataForEngine(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,244 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.knowledge.mapper.KnowledgeTreeMapper">
<cache></cache>
<resultMap type="knowledgeTree" id="knowledgeTreeMap">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="parent_id" property="parentId"/>
<result column="user_id" property="userId"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="status" property="status"/>
<result column="type" property="type"/>
<result column="tree_type" property="treeType"/>
<result column="created" property="created"/>
<result column="updated" property="updated"/>
</resultMap>
<sql id ="Base_Column">
id,
name,
parent_id,
user_id,
organ_id,
engine_id,
status,
type,
tree_type,
created,
updated
</sql>
<sql id ="Base_Column_1">
k.id,
k.name,
k.parent_id,
k.user_id,
k.organ_id,
k.engine_id,
k.status,
k.type,
k.tree_type,
k.created,
k.updated
</sql>
<select id = "getTreeList" parameterType="Map" resultMap="knowledgeTreeMap">
<if test ="type == 2">
select <include refid="Base_Column"/> from (
</if>
<if test ="type == 2">
select <include refid="Base_Column"/> from t_knowledge_tree
where 1=1
<if test ="parentId != null">
and parent_id = #{parentId}
</if>
<if test ="status != null">
and status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test ="tree_type != null">
and tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and organ_id = #{organId}
and type = 1
and id in (select knowledge_tree_id from t_engine_knowledge_tree_rel td where engine_id = #{engineId})
union
</if>
select
<include refid="Base_Column"/>
from t_knowledge_tree
where 1=1
<if test ="parentId != null">
and parent_id = #{parentId}
</if>
<if test ="status != null">
and status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test ="tree_type != null">
and tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test ="type == 0">
and type = 0
</if>
<if test ="type == 1">
and organ_id = #{organId}
and type = 1
<if test="sort == true">
order by tree_type,id
</if>
</if>
<if test ="type == 2">
and engine_id = #{engineId}
and type = 2
) y
<if test="sort == true">
order by y.tree_type,y.id
</if>
</if>
</select>
<select id = "getTreeDataForEngine" parameterType="Map" resultMap="knowledgeTreeMap">
<if test ="type == 2">
select <include refid="Base_Column"/> from (
</if>
<if test ="type == 2">
select <include refid="Base_Column_1"/> from t_knowledge_tree k
where 1=1
<if test ="parentId != null">
and k.parent_id = #{parentId}
</if>
<if test ="status != null">
and k.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test ="tree_type != null">
and k.tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and k.organ_id = #{organId}
and k.type = 1
and k.id in (select knowledge_tree_id from t_engine_knowledge_tree_rel td where td.engine_id = #{engineId})
and (select count(r.parent_id) from t_rule r where r.parent_id = k.id <if test="complexType != null and complexType == 1"> and r.rule_type=1</if>) &gt; 0
union
</if>
select
<include refid="Base_Column_1"/>
from t_knowledge_tree k
where 1=1
<if test ="parentId != null">
and k.parent_id = #{parentId}
</if>
<if test ="status != null">
and k.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test ="tree_type != null">
and k.tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test ="type == 0">
and k.type = 0
</if>
<if test ="type == 1">
and k.organ_id = #{organId}
and k.type = 1
<if test="sort == true">
order by k.tree_type,k.id
</if>
</if>
<if test ="type == 2">
and k.engine_id = #{engineId}
and k.type = 2
and (select count(r.parent_id) from t_rule r where r.parent_id = k.id <if test="complexType != null and complexType == 1"> and r.rule_type=1</if>) &gt; 0
) y
<if test="sort == true">
order by y.tree_type,y.id
</if>
</if>
</select>
<insert id = "insertSelective" parameterType="knowledgeTree" useGeneratedKeys="true" keyProperty="id">
insert into t_knowledge_tree (name,parent_id,user_id,
<if test ="organId != null">
organ_id,
</if>
<if test ="engineId != null">
engine_id,
</if>
status,type,tree_type,created,updated)
values(#{name},#{parentId},#{userId},
<if test ="organId != null">
#{organId},
</if>
<if test ="engineId != null">
#{engineId},
</if>
#{status},#{type},#{treeType},now(), now())
</insert>
<insert id = "batchInsert" parameterType="java.util.List">
<foreach collection="list" index="index" item="item" separator=";">
insert into t_knowledge_tree (name,parent_id,user_id,
<if test ="item.organId != null">
organ_id,
</if>
<if test ="item.engineId != null">
engine_id,
</if>
status,type,tree_type,created,updated)
values(#{item.name},#{item.parentId},#{item.userId},
<if test ="item.organId != null">
#{item.organId},
</if>
<if test ="item.engineId != null">
#{item.engineId},
</if>
#{item.status},#{item.type},#{item.treeType},now(), now())
</foreach>
</insert>
<update id = "updateByPrimaryKeySelective" parameterType="knowledgeTree" >
update t_knowledge_tree set
<if test ="name != null">
name = #{name},
</if>
<if test ="status != null">
status = #{status},
</if>
<if test ="type != null">
type = #{type},
</if>
<if test ="parentId != null">
parent_id = #{parentId},
</if>
updated = now() where id = #{id}
</update>
<select id = "selectByPrimaryKey" parameterType = "long" resultMap="knowledgeTreeMap">
select <include refid="Base_Column"/> from t_knowledge_tree where id = #{id}
</select>
</mapper>

View File

@@ -0,0 +1,74 @@
package com.baoying.enginex.executor.knowledge.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.engine.model.NodeKnowledge;
import com.baoying.enginex.executor.knowledge.model.Rule;
import com.baoying.enginex.executor.knowledge.model.RuleField;
import java.util.List;
import java.util.Map;
public interface RuleFieldMapper extends BaseMapper<RuleField> {
/**
* getFieldList : (根据规则id,,获取规则下的所有字段)
* @author keke
* @param ruleId 规则id
* @return 规则下的所有字段
* */
public List<RuleField> getFieldList(Long ruleId);
/**
* insertField : (批量新增字段记录)
* @author keke
* @param rlist 字段信息集合
* @return
* */
public int insertField(List<RuleField> ruleFieldlist);
/**
* updateField : (批量修改字段记录)
* @author keke
* @param rlist 字段信息集合
* @return
* */
public boolean updateField(List<RuleField> rlist);
/**
* deleteField : (批量删除字段记录)
* @author keke
* @param rlist 字段信息集合
* @return
* */
public boolean deleteField(List<RuleField> rlist);
/**
* getNodeByList : (根据引擎节点得到所用字段)
* @author wenyu.cao
* @param nodeid 节点编号
* @return 返回字段list
* */
public List<RuleField> getNodeByList(NodeKnowledge knowledge);
public List<RuleField> getNodeByListNew(NodeKnowledge knowledge);
/**
*
* 根据规则得到规则引用字段
* @param nodeKnowledge
* @return
* @see
*/
public List<RuleField> selectNodeByRuleList(NodeKnowledge nodeKnowledge);
public List<RuleField> selectNodeByRuleListNew(NodeKnowledge nodeKnowledge);
/**
*
* 根据规则id得到规则引用字段
* @param paramMap 规则id集合
* @return
* @see
*/
public List<RuleField> selectByRuleList(Map<String, Object> paramMap);
public List<RuleField> selectByRuleListNew(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.knowledge.mapper.RuleFieldMapper">
<cache></cache>
<resultMap type="ruleField" id="ruleFieldMap">
<id column="id" property="id"/>
<result column="logical" property="logical"/>
<result column="operator" property="operator"/>
<result column="field" property="field"/>
<result column="field_value" property="fieldValue"/>
<result column="rule_id" property="ruleId"/>
<result column="field_id" property="fieldId"/>
<result column="fieldEn" property="fieldEn"/>
<result column="valueType" property="valueType"/>
<result column="valueScope" property="valueScope"/>
</resultMap>
<sql id ="Base_Column">
r.id ,
r.logical,
r.operator,
t.field_cn as field,
r.field_value as fieldValue,
r.rule_id as ruleId,
r.field_id as fieldId,
t.field_en as fieldEn,
t.value_type as valueType,
t.value_scope as valueScope
</sql>
<select id = "getFieldList" parameterType = "long" resultType = "ruleField">
select <include refid="Base_Column"/> from t_rule_field r left join t_field t on r.field_id = CONCAT(t.id,'|',t.field_en) where r.rule_id = #{id} order by id
</select>
<insert id = "insertField" parameterType="java.util.List" >
insert into t_rule_field
(logical,operator,field_value,rule_id,field_id)
values
<foreach collection="list" index="index" item="item" separator="," >
(
#{item.logical},
#{item.operator},
#{item.fieldValue},
#{item.ruleId},
TRIM(#{item.fieldId})
)
</foreach>
</insert>
<select id = "selectByPrimaryKey" parameterType = "long" resultType="ruleField">
select <include refid="Base_Column"/> from t_rule_field where id = #{id}
</select>
<update id = "updateField" parameterType="java.util.List" >
<foreach collection="list" index="index" item="item" separator=";" >
update t_rule_field set
<if test ="item.logical != null">
logical = #{item.logical}
</if>
<if test ="item.operator != null">
,operator = #{item.operator}
</if>
<if test ="item.fieldValue != null">
,field_value = #{item.fieldValue}
</if>
<if test ="item.fieldId != null">
,field_id = TRIM(#{item.fieldId})
</if>
where id = #{item.id}
</foreach>
</update>
<delete id="deleteField" parameterType="java.util.List">
<foreach collection="list" index="index" item="item" separator=";" >
delete from t_rule_field where id = #{item.id}
</foreach>
</delete>
<select id = "getNodeByList" parameterType = "nodeKnowledge" resultMap = "ruleFieldMap">
select t_rule_field.`field_id` fieldId from t_rule_field WHERE t_rule_field.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{nodeId}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledgeType} )
</select>
<select id = "selectNodeByRuleList" parameterType = "nodeKnowledge" resultType="ruleField">
select t_rule_field.`field_id` fieldId from t_rule_field WHERE t_rule_field.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{nodeId}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledgeType})
</select>
<!-- 普通规则查询字段 -->
<select id = "selectByRuleList" parameterType="map" resultType="ruleField">
select t_rule_field.`field_id` fieldId from t_rule_field WHERE t_rule_field.rule_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id = "selectNodeByRuleListNew" parameterType = "nodeKnowledge" resultType="ruleField">
select t_rule_condition.`field_id` fieldId from t_rule_condition WHERE t_rule_condition.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{nodeId}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledgeType})
union
select LEFT(t_rule_field.`field_id`,LOCATE("|",t_rule_field.`field_id`)-1) fieldId from t_rule_field WHERE t_rule_field.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{nodeId}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledgeType})
</select>
<select id = "selectByRuleListNew" parameterType="map" resultType="ruleField">
select t_rule_condition.`field_id` fieldId from t_rule_condition WHERE t_rule_condition.rule_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
union
select LEFT(`field_id`,LOCATE("|",`field_id`)-1) fieldId from t_rule_field WHERE t_rule_field.rule_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id = "getNodeByListNew" parameterType = "nodeKnowledge" resultMap = "ruleFieldMap">
select `field_id` fieldId from t_rule_condition WHERE t_rule_condition.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{nodeId}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledgeType} )
union
select LEFT(t_rule_field.`field_id`,LOCATE("|",t_rule_field.`field_id`)-1) fieldId from t_rule_field WHERE t_rule_field.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{nodeId}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledgeType} )
</select>
</mapper>

View File

@@ -0,0 +1,90 @@
package com.baoying.enginex.executor.knowledge.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.engine.model.NodeKnowledge;
import com.baoying.enginex.executor.knowledge.model.Rule;
import java.util.List;
import java.util.Map;
public interface RuleMapper extends BaseMapper<Rule> {
/**
* getRuleList:(获取规则集合)
* @author keke
* @param paramMap 参数集合
* @return 规则集合
* */
public List<Rule> getRuleList(Map<String, Object> paramMap);
/**
* updateRuleStatus:(批量修改规则状态记录)
* @author keke
* @param paramMap 参数集合
* @return
* */
public int updateRuleStatus(Map<String, Object> paramMap);
/**
* getNodeByRuleList : (根据引擎节点得到所用规则)
* @author wenyu.cao
* @param nodeid 节点编号
* @return 返回字段list
* */
public List<Rule> getNodeByRuleList(NodeKnowledge knowledge);
/**
* 根据规则类型查询规则
* @param list 规则编号
* @return
* @see
*/
public List<Rule> selectnodeByInRoleid(List<Long> list);
/**
* 根据父节点id查找,节点下所有规则id的集合
* @param list 规则编号
* @return
* @see
*/
public List<Long> getRuleIdsByParentId(Map<String, Object> param);
/**
* getRuleList:(查找引用了某些字段的规则集合)
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 规则集合
* */
public List<Rule> checkByField(Map<String, Object> paramMap);
/**
* 效验规则名称唯一性
* @param param 参数集合
* @return
* @see
*/
public int countOnlyRuleName(Map<String, Object> param);
/**
* 效验规则代码唯一性
* @param param 参数集合
* @return
* @see
*/
public int countOnlyRuleCode(Map<String, Object> param);
/**
* getFieldIdsByRuleId:(根据规则id,获取规则所用字段id和Key)
* @author keke
* @param idList 规则id集合
* @return
* */
public List<String> getFieldIdsByRuleId(List<Long> idList);
public List<Rule> getRuleListByType(Map<String, Object> paramMap);
public List<Rule> getNodeAddOrSubRulesByNodeId(Long nodeId);
}

View File

@@ -0,0 +1,468 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.knowledge.mapper.RuleMapper">
<cache></cache>
<resultMap type="rule" id="ruleMap">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="code" property="code"/>
<result column="description" property="description"/>
<result column="priority" property="priority"/>
<result column="parent_id" property="parentId"/>
<result column="user_id" property="userId"/>
<result column="author" property="author"/>
<result column="authorName" property="authorName"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="status" property="status"/>
<result column="type" property="type"/>
<result column="is_non" property="isNon"/>
<result column="created" property="created"/>
<result column="updated" property="updated"/>
<result column="rule_type" property="ruleType"/>
<result column="rule_audit" property="ruleAudit"/>
<result column="score" property="score"/>
<result column="last_logical" property="lastLogical"/>
<result column="engineName" property="engineName"/>
<result column="result_field_en" property="resultFieldEn"/>
<result column="hit_field_en" property="hitFieldEn"/>
<collection property="ruleFieldList" ofType="ruleField" column="id" select ="com.baoying.enginex.executor.knowledge.mapper.RuleFieldMapper.getFieldList"></collection>
</resultMap>
<sql id ="Base_Column">
r.id,
r.name,
r.code,
r.description,
r.priority,
r.parent_id as parentId,
r.user_id as userId,
r.author,
u.nick_name as authorName,
r.organ_id as organId,
r.engine_id as engineId,
r.status,
r.rule_audit as ruleAudit,
r.type,
r.score,
r.last_logical as lastLogical,
r.is_non as isNon,
r.created,
r.updated,
r.rule_type,
r.result_field_en,
r.hit_field_en
</sql>
<sql id ="Base_Column_1">
r.id,
r.name,
r.code,
r.description,
r.priority,
r.parent_id as parentId,
r.user_id as userId,
r.author,
u.nick_name as authorName,
r.organ_id as organId,
r.engine_id as engineId,
(CASE r. STATUS
WHEN r.id IN (
SELECT
rule_id
FROM
t_engine_rule_rel td
WHERE
engine_id =#{engineId}
) THEN
1
ELSE
0
END) AS status,
r.rule_audit as ruleAudit,
r.type,
r.score,
r.last_logical as lastLogical,
r.is_non as isNon,
r.created,
r.updated,
r.rule_type
</sql>
<sql id ="Base_Column_2">
r.id,
r.name,
r.code,
r.description,
r.engine_id,
r.priority,
r.parent_id,
r.user_id,
r.author,
r.organ_id,
r.engine_id,
r.status,
r.type,
r.is_non,
r.rule_audit,
r.score,
r.last_logical,
r.created,
r.updated,
r.rule_type
</sql>
<select id = "getRuleList" parameterType="Map" resultMap="ruleMap">
<if test ="type == 2">
select * from (
</if>
select
<include refid="Base_Column"/>
from t_rule r left join t_user u on r.author = u.user_id
where 1=1
<if test ="parentIds != null and parentIds !=''">
and r.parent_id in
<foreach collection="parentIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test ="status != null">
and r.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="key!=null and value!=null">
<choose>
<when test="key=='ruleName'">
and r.name like CONCAT('%',#{value},'%' )
</when>
</choose>
</if>
<if test ="type == 0">
and r.type = 0
</if>
<if test ="type == 1">
and r.organ_id = #{organId}
and r.type = 1
order by updated desc
</if>
<if test ="type == 2">
and r.engine_id = #{engineId}
and r.type = 2
union
select
<choose>
<when test = "engineId!='' and engineId!=null">
<include refid="Base_Column_1"/>
</when>
<otherwise>
<include refid="Base_Column"/>
</otherwise>
</choose> from
t_rule r left join t_user u on r.author = u.user_id
where 1=1
<if test ="parentIds != null and parentIds!=''">
and r.parent_id in
<foreach collection="parentIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test ="status != null">
and r.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and r.organ_id = #{organId}
<if test="key!=null and value!=null">
<choose>
<when test="key=='ruleName'">
and r.name like CONCAT('%',#{value},'%' )
</when>
</choose>
</if>
and r.type = 1
and r.id in (select rule_id from t_engine_rule_rel td where engine_id = #{engineId})
order by updated desc
) y
</if>
</select>
<select id = "getRuleIdsByParentId" parameterType="Map" resultType="long">
select id from t_rule r left join t_user u on r.author = u.user_id
where 1=1 and r.status = 1
<if test ="parentIds != null and parentIds != ''">
and r.parent_id in
<foreach collection="parentIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<insert id = "insertSelective" parameterType="rule" useGeneratedKeys="true" keyProperty="id">
insert into t_rule (
name,
code,
description,
priority,
parent_id,
user_id,
author,
<if test ="content !=null">
content,
</if>
<if test ="organId !=null">
organ_id,
</if>
<if test ="engineId!=null">
engine_id,
</if>
<if test ="ruleAudit!=null">
rule_audit,
</if>
<if test ="score!=null">
score,
</if>
<if test ="lastLogical!=null">
last_logical,
</if>
status,type,is_non,created,updated,rule_type)
values(
#{name},
#{code},
#{description},
#{priority},
#{parentId},
#{userId},
#{author},
<if test ="content !=null">
#{content},
</if>
<if test ="organId !=null">
#{organId},
</if>
<if test ="engineId!=null">
#{engineId},
</if>
<if test ="ruleAudit!=null">
#{ruleAudit},
</if>
<if test ="score!=null">
#{score},
</if>
<if test ="lastLogical!=null">
#{lastLogical},
</if>
#{status},#{type},#{isNon},now(), now(),#{ruleType}
)
</insert>
<update id = "updateByPrimaryKeySelective" parameterType="rule" >
update t_rule set
<if test ="name != null">
name = #{name},
</if>
<if test ="code != null">
code = #{code},
</if>
<if test ="content != null">
content = #{content},
</if>
<if test ="description != null">
description = #{description},
</if>
<if test ="priority != null">
priority = #{priority},
</if>
<if test ="status != null">
status = #{status},
</if>
<if test = "type != null">
type = #{type},
</if>
<if test = "isNon != null">
is_non = #{isNon},
</if>
<if test = "ruleType != null">
rule_type = #{ruleType},
</if>
<if test ="ruleAudit!=null">
rule_audit = #{ruleAudit},
</if>
<if test ="lastLogical!=null">
last_logical = #{lastLogical},
</if>
score = #{score},
updated = now() where id = #{id}
</update>
<update id = "updateRuleStatus" parameterType="Map" >
update t_rule set status = #{status} where id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id = "selectByPrimaryKey" parameterType = "long" resultMap = "ruleMap">
select <include refid = "Base_Column"/> from t_rule r left join t_user u on r.author = u.user_id where r.id = #{id}
</select>
<select id = "selectByInRoleid" resultMap = "ruleMap">
select <include refid = "Base_Column"/> from t_rule
id in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id = "getNodeByRuleList" parameterType = "nodeKnowledge" resultMap = "ruleMap">
select <include refid = "Base_Column"/> from t_rule r WHERE t_rule.id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{id}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledge_type}
</select>
<select id = "selectnodeByInRoleid" resultMap = "ruleMap">
select r.id,
r.name,
r.code,
r.description,
r.priority,
r.parent_id ,
r.user_id ,
r.author,
r.organ_id ,
r.engine_id ,
r.status,
r.rule_audit ,
r.type,
r.score,
r.content,
r.last_logical ,
r.is_non ,
r.created,
r.updated,
r.rule_type,
r.result_field_en,
r.score_field_en
from t_rule r
where r.id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
ORDER BY priority ASC
</select>
<select id = "checkByField" parameterType = "map" resultMap = "ruleMap">
select r.id,r.name,r.engine_id as engineId,e.name as engineName
from (
select id,name,engine_id
from t_rule
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
and status = 1
union all
select r.id,r.name,er.engine_id
from t_engine_rule_rel er left join t_rule r on er.rule_id = r.id
where r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and er.engine_id = #{engineId}
</if>
and r.status = 1
)r left join t_engine e on r.engine_id = e.id
where (exists (select 1 from (select rule_id, left(field_id,LOCATE('|',field_id)-1) as f from t_rule_field) rf
where r.id = rf.rule_id
and rf.f in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
or exists (select 1 from (select rule_id, left(field_id,LOCATE('|',field_id)-1) as f from t_rule_content) rc
where r.id = rc.rule_id
and rc.f in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
)
</select>
<select id="countOnlyRuleName" parameterType = "map" resultType = "int">
select count(name) from t_rule where organ_id = #{organId} and status != -1 and name = TRIM(#{name})
<if test="id !=null and id!=''">
and id != #{id}
</if>
</select>
<select id="countOnlyRuleCode" parameterType = "map" resultType = "int">
select count(code) from t_rule where organ_id = #{organId} and status != -1 and code=TRIM(#{code})
<if test="id !=null and id!=''">
and id != #{id}
</if>
</select>
<select id="getFieldIdsByRuleId" parameterType ="java.util.List" resultType = "string">
select field_id from t_rule_field where rule_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
union
select field_id from t_rule_content where rule_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getRuleListByType" parameterType ="map" resultMap = "ruleMap">
select
<include refid = "Base_Column_2"/>
from t_rule r
where r.parent_id = #{parentId}
<if test="type != 2">
and r.rule_type = #{type}
</if>
<choose>
<when test="ids != null">
and r.id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
or r.engine_id = #{engineId}
</when>
<otherwise>
and r.engine_id = #{engineId}
</otherwise>
</choose>
</select>
<select id = "getNodeAddOrSubRulesByNodeId" parameterType="Long" resultMap="ruleMap">
select
r.id,
r.name,
r.code,
r.description,
r.priority,
r.parent_id as parentId,
r.user_id as userId,
r.author,
r.organ_id as organId,
r.engine_id as engineId,
r.status,
r.rule_audit as ruleAudit,
r.type,
r.score,
r.content,
r.last_logical as lastLogical,
r.is_non as isNon,
r.created,
r.updated,
r.rule_type
from t_node_knowledge_rel n left join t_rule r
on r.id = n.knowledge_id where n.node_id = #{nodeId} and n.knowledge_type = 1
and r.rule_type = 1
</select>
</mapper>

View File

@@ -0,0 +1,41 @@
package com.baoying.enginex.executor.knowledge.model;
import java.io.Serializable;
public class EngineRuleRel implements Serializable{
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 引擎id
* */
private Long engineId;
/**
* 树形目录id
* */
private Long ruleId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getEngineId() {
return engineId;
}
public void setEngineId(Long engineId) {
this.engineId = engineId;
}
}

View File

@@ -0,0 +1,227 @@
package com.baoying.enginex.executor.knowledge.model;
import org.codehaus.jackson.annotate.JsonIgnore;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
public class KnowledgeTree implements Serializable{
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 目录名称
* */
private String name;
/**
* 父节点id
* */
private Long parentId;
/**
* 创建人id
* */
private Long userId;
/**
* 组织id
* */
private Long organId;
/**
* 引擎id
* */
private Long engineId;
/**
* 创建日期
* */
private Date created;
/**
* 目录类型 0 : 系统的目录 1组织的目录 2 引擎的目录
* */
private Integer type;
/**
* 树形分类0规则树 1评分卡的树 2回收站的树
* */
private Integer treeType;
/**
* 状态 0 :停用 1 : 启用,-1删除
* */
private Integer status;
/**
* 修改日期
* */
private Date updated;
/**
* 子类集合
* */
private KnowledgeTree[] children;
/**
* 是否为父类
* */
private String isParent = "true";
/**
*文件夹图片路径
* */
private String icon="";
private String isLastNode="";
private Integer directoryType;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getOrganId() {
return organId;
}
public void setOrganId(Long organId) {
this.organId = organId;
}
public Long getEngineId() {
return engineId;
}
public void setEngineId(Long engineId) {
this.engineId = engineId;
}
@JsonIgnore
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
@JsonIgnore
public Date getUpdated() {
return updated;
}
public void setUpdated(Date updated) {
this.updated = updated;
}
public KnowledgeTree[] getChildren() {
return children;
}
public void setChildren(KnowledgeTree[] children) {
this.children = children;
}
public String getIsParent() {
return isParent;
}
public void setIsParent(String isParent) {
this.isParent = isParent;
}
public Integer getTreeType() {
return treeType;
}
public void setTreeType(Integer treeType) {
this.treeType = treeType;
}
public String getIcon() {
if((int)treeType == 2 || (int)treeType == 3){
icon = "../resource/images/datamanage/cabage.png";
isLastNode ="true";
}else{
icon = "../resource/images/authority/folder.png";
}
return icon;
}
public Integer getDirectoryType() {
return directoryType = type ;
}
public String getIsLastNode() {
if((int)treeType == 2 || (int)treeType == 3){
isLastNode ="true";
}
return isLastNode;
}
@Override
public String toString() {
return "KnowledgeTree [id=" + id + ", name=" + name + ", parentId="
+ parentId + ", userId=" + userId + ", organId=" + organId
+ ", engineId=" + engineId + ", created=" + created + ", type="
+ type + ", treeType=" + treeType + ", status=" + status
+ ", updated=" + updated + ", children="
+ Arrays.toString(children) + ", isParent=" + isParent
+ ", icon=" + icon + ", isLastNode=" + isLastNode
+ ", directoryType=" + directoryType + "]";
}
}

View File

@@ -0,0 +1,48 @@
package com.baoying.enginex.executor.knowledge.model;
import java.io.Serializable;
public class KnowledgeTreeRel implements Serializable{
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 引擎id
* */
private Long engineId;
/**
* 树形目录id
* */
private Long treeId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getEngineId() {
return engineId;
}
public void setEngineId(Long engineId) {
this.engineId = engineId;
}
public Long getTreeId() {
return treeId;
}
public void setTreeId(Long treeId) {
this.treeId = treeId;
}
}

View File

@@ -0,0 +1,411 @@
package com.baoying.enginex.executor.knowledge.model;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
public class Rule implements Serializable,Cloneable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 名称
* */
private String name;
/**
* 代码
* */
private String code;
/**
* 描述
* */
private String description;
/**
* 优先级
* */
private Integer priority;
/**
* 父节点id
* */
private Long parentId;
/**
*修改人id
* */
private Long userId;
/**
*创建人id
* */
private Long author;
/**
*创建人名称
* */
private String authorName;
/**
* 组织id
* */
private Long organId;
/**
* 引擎id
* */
private Long engineId;
/**
* 规则类型 0 : 系统的规则 1组织的规则 2 引擎的规则
* */
private Integer type;
/**
* 逻辑关系"非" 0:不是非 1是非
* */
private Integer isNon;
/**
* 状态 0 :停用 1 : 启用,-1删除
* */
private Integer status;
/**
* 审批规则 5 :通过 2 : 拒绝3人工审批 4简化流程
*/
public int ruleAudit;
/**
* 规则字段集合
* */
private List<RuleField> ruleFieldList;
/**
* 规则内容集合
* */
private List<RuleContent> ruleContentList;
/**
* 创建日期
* */
private Date created;
/**
* 修改日期
* */
private Date updated;
/**
* 规则具体内容
* */
public String content;
/**
* 0硬性拒绝规则1加减分规则
*/
private Integer ruleType;
/**
*得分
*/
private Integer score;
/**
*逻辑关系符,存储条件区域最后一个逻辑符号,值有')'、'))'、'-1'
*/
private String lastLogical;
/**
* 引擎名
* */
private String engineName;
/**
* 规则节点名称
* */
private String engineNodeName;
/**
* 规则节点名称
* */
private Long engineNodeId;
/**
* 区分规则集和规则
* */
private int showType = 0;
public String getScoreFieldEn() {
return scoreFieldEn;
}
public void setScoreFieldEn(String scoreFieldEn) {
this.scoreFieldEn = scoreFieldEn;
}
private String resultFieldEn;//存放结果的字段en
private String scoreFieldEn;//存放是否命中的字段
public String getResultFieldEn() {
return resultFieldEn;
}
public void setResultFieldEn(String resultFieldEn) {
this.resultFieldEn = resultFieldEn;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public int getRuleAudit() {
return ruleAudit;
}
public void setRuleAudit(int ruleAudit) {
this.ruleAudit = ruleAudit;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getPriority() {
return priority;
}
public void setPriority(Integer priority) {
this.priority = priority;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getAuthor() {
return author;
}
public void setAuthor(Long author) {
this.author = author;
}
public String getAuthorName() {
return authorName;
}
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
public Long getOrganId() {
return organId;
}
public void setOrganId(Long organId) {
this.organId = organId;
}
public Long getEngineId() {
return engineId;
}
public void setEngineId(Long engineId) {
this.engineId = engineId;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public List<RuleField> getRuleFieldList() {
return ruleFieldList;
}
public void setRuleFieldList(List<RuleField> ruleFieldList) {
this.ruleFieldList = ruleFieldList;
}
public List<RuleContent> getRuleContentList() {
return ruleContentList;
}
public void setRuleContentList(List<RuleContent> ruleContentList) {
this.ruleContentList = ruleContentList;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getUpdated() {
return updated;
}
public void setUpdated(Date updated) {
this.updated = updated;
}
public Integer getIsNon() {
return isNon;
}
public void setIsNon(Integer isNon) {
this.isNon = isNon;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getRuleType() {
if(ruleAudit == 2) {
ruleType = 0;
}else{
ruleType = 1;
}
return ruleType;
}
public void setRuleType(Integer ruleType) {
this.ruleType = ruleType;
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public String getLastLogical() {
return lastLogical;
}
public void setLastLogical(String lastLogical) {
this.lastLogical = lastLogical;
}
public String getEngineName() {
return engineName;
}
public void setEngineName(String engineName) {
this.engineName = engineName;
}
public String getEngineNodeName() {
return engineNodeName;
}
public void setEngineNodeName(String engineNodeName) {
this.engineNodeName = engineNodeName;
}
public Long getEngineNodeId() {
return engineNodeId;
}
public void setEngineNodeId(Long engineNodeId) {
this.engineNodeId = engineNodeId;
}
public int getShowType() {
return showType;
}
public void setShowType(int showType) {
this.showType = showType;
}
@Override
public Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return super.clone();
}
@Override
public String toString() {
return "Rule [id=" + id + ", name=" + name + ", versionCode=" + code + ", description=" + description + ", priority="
+ priority + ", parentId=" + parentId + ", userId=" + userId + ", author=" + author + ", authorName="
+ authorName + ", organId=" + organId + ", engineId=" + engineId + ", type=" + type + ", isNon=" + isNon
+ ", status=" + status + ", ruleAudit=" + ruleAudit + ", ruleFieldList=" + ruleFieldList
+ ", ruleContentList=" + ruleContentList + ", created=" + created + ", updated=" + updated
+ ", content=" + content + ", ruleType=" + ruleType + ", score=" + score + ", lastLogical="
+ lastLogical + ", engineName=" + engineName + ", engineNodeName=" + engineNodeName + ", engineNodeId="
+ engineNodeId + ", showType=" + showType + "]";
}
}

View File

@@ -0,0 +1,149 @@
package com.baoying.enginex.executor.knowledge.model;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
public class RuleContent implements Serializable{
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 字段名
* */
private String field;
/**
* 字段值
* */
private String fieldValue;
/**
* 字段id
* */
private String fieldId;
/**
* 规则Id
* */
private Long ruleId;
/**
* 关联的字段的英文名称
* */
private String fieldEn;
/**
* 关联的字段的值类型
* */
private Integer valueType;
/**
* 关联的字段的取值范围
* */
private String valueScope;
/**
* 关联的字段的值拆解后的数组
* */
private String[] values;
/**
* 类型1 常量、2 变量
*/
private Integer variableType;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
public String getFieldId() {
return fieldId;
}
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
public Long getRuleId() {
return ruleId;
}
public void setRuleId(Long ruleId) {
this.ruleId = ruleId;
}
public Integer getValueType() {
return valueType;
}
public void setValueType(Integer valueType) {
this.valueType = valueType;
}
public String getValueScope() {
return valueScope;
}
public void setValueScope(String valueScope) {
this.valueScope = valueScope;
}
public String[] getValues() {
if(!StringUtils.isBlank(valueScope)){
if(valueType == 3){
values = valueScope.split(",");
}else{
values = new String[]{valueScope};
}
}else{
values = null;
}
return values;
}
public String getFieldEn() {
return fieldEn;
}
public void setFieldEn(String fieldEn) {
this.fieldEn = fieldEn;
}
public Integer getVariableType() {
return variableType;
}
public void setVariableType(Integer variableType) {
this.variableType = variableType;
}
}

Some files were not shown because too many files have changed in this diff Show More