提交 019d0297 编写于 作者: sq3536's avatar sq3536

Merge branch 'master' of http://demo.ibizlab.cn/ibiz4jteam/ibzdst

......@@ -428,6 +428,71 @@ mock.onPost(new RegExp(/^\/dametrics\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((
});
// SyncRule
mock.onPost(new RegExp(/^\/dabuilds\/([a-zA-Z0-9\-\;]{1,35})\/dametrics\/([a-zA-Z0-9\-\;]{1,35})\/syncrule$/)).reply((config: any) => {
console.groupCollapsed("实体:dametric 方法: SyncRule");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['build_id','metric_id'];
const matchArray:any = new RegExp(/^\/dabuilds\/([a-zA-Z0-9\-\;]{1,35})\/dametrics\/([a-zA-Z0-9\-\;]{1,35})\/syncrule$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// SyncRule
mock.onPost(new RegExp(/^\/dametrics\/?([a-zA-Z0-9\-\;]{0,35})\/syncrule$/)).reply((config: any) => {
console.groupCollapsed("实体:dametric 方法: SyncRule");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['metric_id'];
const matchArray:any = new RegExp(/^\/dametrics\/([a-zA-Z0-9\-\;]{1,35})\/syncrule$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.metric_id, tempValue.metric_id));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['metric_id'] == tempValue['metric_id'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// FetchDefault
mock.onGet(new RegExp(/^\/dabuilds\/([a-zA-Z0-9\-\;]{1,35})\/dametrics\/fetchdefault$/)).reply((config: any) => {
console.groupCollapsed("实体:dametric 方法: FetchDefault");
......
......@@ -363,6 +363,7 @@ mock.onPost(new RegExp(/^\/metaentities\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).
});
// Save
mock.onPost(new RegExp(/^\/dstsystems\/([a-zA-Z0-9\-\;]{1,35})\/metaentities\/([a-zA-Z0-9\-\;]{1,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:metaentity 方法: Save");
......@@ -649,3 +650,59 @@ mock.onGet(new RegExp(/^\/metaentities\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((confi
console.groupEnd();
return [status, _items?_items:{}];
});
// GetDefaultModel
mock.onGet(new RegExp(/^\/dstsystems\/([a-zA-Z0-9\-\;]{1,35})\/metaentities\/([a-zA-Z0-9\-\;]{1,35})\/getdefaultmodel$/)).reply((config: any) => {
console.groupCollapsed("实体:metaentity 方法: GetDefaultModel");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['pssystemid','entity_id'];
const matchArray:any = new RegExp(/^\/dstsystems\/([a-zA-Z0-9\-\;]{1,35})\/metaentities\/([a-zA-Z0-9\-\;]{1,35})\/getdefaultmodel$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.entity_id, tempValue.entity_id));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items?_items:{});
console.groupEnd();
console.groupEnd();
return [status, _items?_items:{}];
});
// GetDefaultModel
mock.onGet(new RegExp(/^\/metaentities\/([a-zA-Z0-9\-\;]{1,35})\/getdefaultmodel$/)).reply((config: any) => {
console.groupCollapsed("实体:metaentity 方法: GetDefaultModel");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['entity_id'];
const matchArray:any = new RegExp(/^\/metaentities\/([a-zA-Z0-9\-\;]{1,35})\/getdefaultmodel$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.entity_id, tempValue.entity_id));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items?_items:{});
console.groupEnd();
console.groupEnd();
return [status, _items?_items:{}];
});
......@@ -195,6 +195,44 @@ mock.onGet(new RegExp(/^\/ruleitems\/getdraft$/)).reply((config: any) => {
return [status, {}];
});
// BuildRuleFile
mock.onPost(new RegExp(/^\/ruleitems\/?([a-zA-Z0-9\-\;]{0,35})\/buildrulefile$/)).reply((config: any) => {
console.groupCollapsed("实体:ruleitem 方法: BuildRuleFile");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['rule_id'];
const matchArray:any = new RegExp(/^\/ruleitems\/([a-zA-Z0-9\-\;]{1,35})\/buildrulefile$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.rule_id, tempValue.rule_id));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['rule_id'] == tempValue['rule_id'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// CheckKey
mock.onPost(new RegExp(/^\/ruleitems\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:ruleitem 方法: CheckKey");
......
......@@ -225,6 +225,27 @@ export default class DAMetricServiceBase extends EntityService {
return res;
}
/**
* SyncRule接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DAMetricServiceBase
*/
public async SyncRule(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dabuild && context.dametric){
let masterData:any = {};
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/dabuilds/${context.dabuild}/dametrics/${context.dametric}/syncrule`,data,isloading);
return res;
}
let res:any = Http.getInstance().post(`/dametrics/${context.dametric}/syncrule`,data,isloading);
return res;
}
/**
* FetchDefault接口方法
*
......
......@@ -207,6 +207,26 @@ export default class MetaEntityServiceBase extends EntityService {
return res;
}
/**
* GetDefaultModel接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaEntityServiceBase
*/
public async GetDefaultModel(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dstsystem && context.metaentity){
let res:any = await Http.getInstance().get(`/dstsystems/${context.dstsystem}/metaentities/${context.metaentity}/getdefaultmodel`,isloading);
return res;
}
let res:any = await Http.getInstance().get(`/metaentities/${context.metaentity}/getdefaultmodel`,isloading);
return res;
}
/**
* Save接口方法
*
......
......@@ -139,6 +139,20 @@ export default class RuleItemServiceBase extends EntityService {
return res;
}
/**
* BuildRuleFile接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof RuleItemServiceBase
*/
public async BuildRuleFile(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().post(`/ruleitems/${context.ruleitem}/buildrulefile`,data,isloading);
return res;
}
/**
* CheckKey接口方法
*
......
......@@ -36,6 +36,7 @@ public interface IDAMetricService extends IService<DAMetric> {
boolean checkKey(DAMetric et);
boolean save(DAMetric et);
void saveBatch(List<DAMetric> list);
DAMetric syncRule(DAMetric et);
Page<DAMetric> searchDefault(DAMetricSearchContext context);
List<DAMetric> selectByBuildId(String build_id);
void removeByBuildId(String build_id);
......
......@@ -160,6 +160,13 @@ public class DAMetricServiceImpl extends ServiceImpl<DAMetricMapper, DAMetric> i
saveOrUpdateBatch(list,batchSize);
}
@Override
@Transactional
public DAMetric syncRule(DAMetric et) {
//自定义代码
return et;
}
@Override
public List<DAMetric> selectByBuildId(String build_id) {
......
package cn.ibizlab.core.extensions.domain;
import cn.ibizlab.core.extensions.util.IEntityActionHelper;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class BaseEntityList extends ArrayList<BaseEntity> implements IEntity {
public String KEY;
public String ENTITYNAME;
private BaseField nullFiled=new BaseField();
private BaseEntity root;
public void regesitAttr(String key,BaseEntity val)
{
if(key.equalsIgnoreCase("root")&&root==null)
root=val;
}
@Override
public IEntity $E(String key) {
return new BaseEntity();
}
@Override
public Object get(Object key) {
if(key instanceof Integer)
return super.get((int)key);
BaseFieldList list=new BaseFieldList();
for(BaseEntity item:this)
{
Object val=item.get(key);
if(val instanceof BaseField)
list.add((BaseField)val);
}
if(list.size()==1)
return list.get(0);
else if(list.size()==0)
return nullFiled;
else
return list;
}
@Override
public IField $(String key)
{
if(StringUtils.isEmpty(key))
return nullFiled;
Object obj=this.get(key);
if(obj instanceof IField)
{
IField f= (IField)obj;
if(f.getValue()!=null&&key.indexOf(".")>0)
{
String[] arr=key.split("[.]");
if(arr.length>=2)
{
if((!StringUtils.isEmpty(arr[0]))&&(!StringUtils.isEmpty(arr[1])))
{
f.setEntity(arr[0]);
f.setField(arr[1]);
}
}
}
return f;
}
else
return nullFiled;
}
@Override
public Double $D(String key)
{
IField field=this.$(key);
Object val=field.getValue();
if(field instanceof BaseFieldList)
val=((BaseFieldList) field).get(0);
if(val==null)
return 0d;
else if((val instanceof Integer)||(val instanceof Double)||(val instanceof Long)||(val instanceof BigDecimal)||(val instanceof BigInteger)||(val instanceof Float))
return (double)val;
return 1d;
}
@Override
public boolean IF(String cond)
{
return test(cond);
}
@Override
public boolean test(String cond)
{
{
for(BaseEntity obj:this)
{
obj.setENTITYNAME(this.ENTITYNAME);
if(obj.test(cond))
return true;
}
return false;
}
}
private IEntityActionHelper iEntityActionHelper = null;
@Override
public void setActionHelper(IEntityActionHelper iEntityActionHelper) {
this.iEntityActionHelper = iEntityActionHelper;
}
@Override
public IEntityActionHelper getActionHelper()
{
if (this.iEntityActionHelper == null ) {
return null;
}
return this.iEntityActionHelper;
}
@Override
public List<BaseEntity> selectRow(String dblink,String sql)
{
return (BaseEntityList)this.getActionHelper().select(dblink,sql);
}
}
\ No newline at end of file
package cn.ibizlab.core.extensions.domain;
import cn.ibizlab.util.helper.RuleUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.util.ObjectUtils;
import java.io.BufferedReader;
import java.io.Reader;
import java.math.BigDecimal;
import java.math.BigInteger;
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class BaseField implements IField {
private String field;
private String entity;
private Object value=null;
public void setValue(Object value)
{
if(value instanceof java.sql.Clob)
{
// Clob类型 转String
BufferedReader br =null;
Reader is = null;
try {
String reString = "";
is = ((java.sql.Clob)value).getCharacterStream();
br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
while (s != null) {
sb.append(s);
s = br.readLine();
}
reString = sb.toString();
this.value=reString;
}
catch (Exception ex)
{
}
finally {
try
{
if(br!=null){
br.close();
}
}
catch (Exception ex)
{}
try
{
if(is!=null){
is.close();
}
}
catch (Exception ex)
{}
}
}
else
this.value=value;
}
public Object getValue()
{
return this.value;
}
@Override
public String getCondValue() {
Object val=getValue();
if(ObjectUtils.isEmpty(val))
return "null";
String str="";
if((val instanceof Integer)||(val instanceof Double)||(val instanceof Long)||(val instanceof BigDecimal)||(val instanceof BigInteger)||(val instanceof Float))
str=val.toString();
else
str="'"+val.toString()+"'";
return str;
}
@Override
public Object getFecthValue() {
return getValue();
}
public static BaseField from(Object value)
{
BaseField field=new BaseField();
field.setValue(value);
return field;
}
@Override
public boolean EQ(Object val) {
return RuleUtils.equal(val, this.value);
}
@Override
public boolean NOTEQ(Object val) {
return !RuleUtils.equal(val, this.value);
}
@Override
public boolean GTANDEQ(Object val) {
return RuleUtils.ge(val,this.value);
}
@Override
public boolean GT(Object val) {
return RuleUtils.gt(val, this.value);
}
@Override
public boolean LTANDEQ(Object val) {
return RuleUtils.le(val,this.value);
}
@Override
public boolean LT(Object val) {
return RuleUtils.lt(val,this.value);
}
@Override
public boolean ISNULL(Object val) {
return RuleUtils.isNull(this.value);
}
@Override
public boolean ISNOTNULL(Object val) {
return RuleUtils.isNotNull(this.value);
}
@Override
public boolean LIKE(String val) {
return RuleUtils.matchor(val, this.value);
}
@Override
public boolean LEFTLIKE(String val) {
return RuleUtils.leftmatchor(val, this.value);
}
@Override
public boolean RIGHTLIKE(String val) {
return RuleUtils.rightmatchor(val, this.value);
}
@Override
public boolean IN(String val) {
return RuleUtils.in(val, this.value);
}
@Override
public boolean NOTIN(String val) {
return RuleUtils.notin(val, this.value);
}
@Override
public boolean INC2S(String val) {
return RuleUtils.inc2s(val, this.value);
}
@Override
public boolean NOTINC2S(String val) {
return RuleUtils.notinc2s(val, this.value);
}
@Override
public boolean MATCHES(String val) {
return RuleUtils.matchand(val, this.value);
}
@Override
public String toString()
{
if(ObjectUtils.isEmpty(this.getValue()))
return "";
else
return this.getValue().toString();
}
@Override
public boolean NOTLIKE(String val) {
return !LIKE(val);
}
@Override
public boolean LEFTNOTLIKE(String val) {
return !LEFTLIKE(val);
}
@Override
public boolean RIGHTNOTLIKE(String val) {
return !RIGHTLIKE(val);
}
@Override
public boolean NOTMATCHES(String val) {
return !MATCHES(val);
}
}
\ No newline at end of file
package cn.ibizlab.core.extensions.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Hashtable;
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class BaseFieldList extends ArrayList<BaseField> implements IField {
private String field;
private String entity;
public Object getValue()
{
String rt="";
Hashtable<Object,Integer> setcheck=new Hashtable<Object, Integer>();
if(this.size()==0)
return null;
if(this.size()==1)
return this.get(0).getValue();
Object sObj=null;
for(BaseField obj:this)
{
Object val=obj.getValue();
if(ObjectUtils.isEmpty(val))
continue;
if(setcheck.containsKey(val))
continue;
else
setcheck.put(val,1);
String str=val.toString();
sObj=val;
if(!StringUtils.isEmpty(rt))
rt=rt+",";
rt=rt+str;
}
if(StringUtils.isEmpty(rt))
rt=null;
if(setcheck.size()==1)
return sObj;
return rt;
}
@Override
public String getCondValue() {
String rt="";
Hashtable<Object,Integer> setcheck=new Hashtable<Object, Integer>();
for(BaseField obj:this)
{
Object val=obj.getValue();
if(ObjectUtils.isEmpty(val))
continue;
if(setcheck.containsKey(val))
continue;
else
setcheck.put(val,1);
String str="";
if((val instanceof Integer)||(val instanceof Double)||(val instanceof Long)||(val instanceof BigDecimal)||(val instanceof BigInteger)||(val instanceof Float))
str=val.toString();
else
str="'"+val.toString()+"'";
if(!StringUtils.isEmpty(rt))
rt=rt+",";
rt=rt+str;
}
if(StringUtils.isEmpty(rt))
rt="null";
return rt;
}
@Override
public Object getFecthValue() {
return null;
}
@Override
public boolean EQ(Object val) {
for(BaseField obj:this)
if(obj.EQ(val))
return true;
return false;
}
@Override
public boolean NOTEQ(Object val) {
return !EQ(val);
}
@Override
public boolean GTANDEQ(Object val) {
for(BaseField obj:this)
if(obj.GTANDEQ(val))
return true;
return false;
}
@Override
public boolean GT(Object val) {
for(BaseField obj:this)
if(obj.GT(val))
return true;
return false;
}
@Override
public boolean LTANDEQ(Object val) {
for(BaseField obj:this)
if(obj.LTANDEQ(val))
return true;
return false;
}
@Override
public boolean LT(Object val) {
for(BaseField obj:this)
if(obj.LT(val))
return true;
return false;
}
@Override
public boolean ISNULL(Object val) {
for(BaseField obj:this)
if(obj.ISNULL(val))
return true;
return false;
}
@Override
public boolean ISNOTNULL(Object val) {
return !ISNULL(val);
}
@Override
public boolean LIKE(String val) {
for(BaseField obj:this)
if(obj.LIKE(val))
return true;
return false;
}
@Override
public boolean LEFTLIKE(String val) {
for(BaseField obj:this)
if(obj.LEFTLIKE(val))
return true;
return false;
}
@Override
public boolean RIGHTLIKE(String val) {
for(BaseField obj:this)
if(obj.RIGHTLIKE(val))
return true;
return false;
}
@Override
public boolean IN(String val) {
for(BaseField obj:this)
if(obj.IN(val))
return true;
return false;
}
@Override
public boolean NOTIN(String val) {
return !IN(val);
}
@Override
public boolean INC2S(String val) {
for(BaseField obj:this)
if(obj.INC2S(val))
return true;
return false;
}
@Override
public boolean NOTINC2S(String val) {
return !INC2S(val);
}
@Override
public boolean MATCHES(String val) {
for(BaseField obj:this)
if(obj.MATCHES(val))
return true;
return false;
}
@Override
public String toString()
{
if(ObjectUtils.isEmpty(this.getValue()))
return "";
else
{
String rt="";
for(BaseField obj:this)
{
Object val=obj.getValue();
if(ObjectUtils.isEmpty(val))
continue;
String str=val.toString();
if(!StringUtils.isEmpty(rt))
rt=rt+",";
rt=rt+str;
}
if(StringUtils.isEmpty(rt))
rt="";
return rt;
}
}
@Override
public boolean NOTLIKE(String val) {
return !LIKE(val);
}
@Override
public boolean LEFTNOTLIKE(String val) {
return !LEFTLIKE(val);
}
@Override
public boolean RIGHTNOTLIKE(String val) {
return !RIGHTLIKE(val);
}
@Override
public boolean NOTMATCHES(String val) {
return !MATCHES(val);
}
}
\ No newline at end of file
package cn.ibizlab.core.extensions.domain;
import cn.ibizlab.core.lite.domain.MetaField;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@Data
public class DSTEntityModel implements Serializable {
private String dblink;
private String sqltable;
private String sqlKeyField;
private String getCondition;
private Map<String,DSTLookupModel> lookups;
private List<String > releations;
private List<String > subentity;
private List<MetaField> keyFields;
private List<MetaField> f1nFields;
private List<MetaField> fn1Fields;
private String lastUpdateField;
}
package cn.ibizlab.core.extensions.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class DSTLookupModel implements Serializable {
private String refentity;
private String selectCondition;
private List<String> reffieldsCondition;
private String entity;
private List<String> paramsCondition;
}
package cn.ibizlab.core.extensions.domain;
import cn.ibizlab.core.extensions.util.IEntityActionHelper;
import java.io.Serializable;
import java.util.List;
public interface IEntity extends Serializable {
Object get(Object key);
String getENTITYNAME();
void setENTITYNAME(String name);
void regesitAttr(String key, BaseEntity val);
String getKEY();
void setKEY(String KEY);
IField $(String key);
Double $D(String key);
IEntity $E(String key);
boolean IF(String cond);
boolean test(String cond);
void setActionHelper(IEntityActionHelper iEntityActionHelper);
/**
* 获取操作辅助对象
*
* @return
*/
IEntityActionHelper getActionHelper();
List<BaseEntity> selectRow(String dblink, String sql);
}
package cn.ibizlab.core.extensions.domain;
import java.io.Serializable;
public interface IField extends Serializable {
String getField();
void setField(String field);
String getEntity();
void setEntity(String entity);
Object getValue();
String getCondValue();
Object getFecthValue();
boolean EQ(Object val);
boolean NOTEQ(Object val);
boolean GTANDEQ(Object val);
boolean GT(Object val);
boolean LTANDEQ(Object val);
boolean LT(Object val);
boolean ISNULL(Object val);
boolean ISNOTNULL(Object val);
boolean LIKE(String val);
boolean LEFTLIKE(String val);
boolean RIGHTLIKE(String val);
boolean NOTLIKE(String val);
boolean LEFTNOTLIKE(String val);
boolean RIGHTNOTLIKE(String val);
boolean IN(String val);
boolean NOTIN(String val);
boolean INC2S(String val);
boolean NOTINC2S(String val);
boolean MATCHES(String val);
boolean NOTMATCHES(String val);
}
package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.extensions.domain.BaseEntity;
import cn.ibizlab.core.extensions.domain.IEntity;
import cn.ibizlab.core.extensions.domain.IField;
import cn.ibizlab.core.rule.domain.ExecLog;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 实体[DSTEntity] 服务对象接口
*/
public interface BaseEntityService extends IService<BaseEntity> {
void resetKC(String keyC);
List<BaseEntity> selectRow(String dblink, String sql);
ExecLog processAll(BadRequestAlertException msg);
void saveResult(IEntity param, String RULEID, String RULENAME, String RU_EXECRESULTNAME, String BUSINESSCAT, Integer RETVALUE, Object KEYVALUEFIELD, IField DOMAINSFIELD, IField METRICFIELD, IField TIMEFIELD, IField EXT1FIELD, IField EXT2FIELD);
}
\ No newline at end of file
package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.analysis.service.impl.DAMetricServiceImpl;
import cn.ibizlab.core.rule.domain.RuleItem;
import cn.ibizlab.core.rule.service.IRuleItemService;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.analysis.domain.DAMetric;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary;
import java.util.*;
/**
* 实体[指标] 自定义服务对象
*/
@Slf4j
@Primary
@Service("DAMetricExService")
public class DAMetricExService extends DAMetricServiceImpl {
@Autowired
@Lazy
IRuleItemService ruleService;
@Override
public boolean create(DAMetric et) {
super.create(et);
syncRule(et);
return true;
}
@Override
public boolean update(DAMetric et) {
super.update(et);
syncRule(et);
return true;
}
@Override
protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
/**
* [SyncRule:同步指标到规则] 行为扩展
* @param et
* @return
*/
@Override
@Transactional
public DAMetric syncRule(DAMetric et) {
RuleItem rule =new RuleItem();
rule.setRuleCode(et.getMetricId());
rule.setRuleName(et.getMetricName());
rule.setModelId(et.getModelId());
rule.setModelName(et.getModelName());
rule.setCfg(et.getCfg());
rule.setFieldSet(et.getFieldSet());
rule.setGroup("REP");
rule.setBusinessCat(et.getMetricType());
rule.setMemo(et.getModelName()+"."+et.getMetricName());
ruleService.save(rule);
return super.syncRule(et);
}
}
package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.lite.service.impl.MetaEntityServiceImpl;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.lite.domain.MetaEntity;
import cn.ibizlab.core.lite.extensions.service.LiteModelService;
import cn.ibizlab.core.lite.extensions.util.LiteStorage;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import java.util.*;
/**
* 实体[实体] 自定义服务对象
*/
@Slf4j
@Primary
@Service("MetaEntityExService")
public class MetaEntityExService extends MetaEntityServiceImpl {
@Override
protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
/**
* [GetDefaultModel:GetDefaultModel] 行为扩展
* @param et
* @return
*/
@Override
@Transactional
public MetaEntity getDefaultModel(MetaEntity et) {
return super.getDefaultModel(et);
}
@Autowired
@Lazy
private LiteModelService liteModelService;
@Override
public boolean update(MetaEntity et)
{
if(!super.update(et))
return false;
liteModelService.resetEntityModel(et.getSystemId(), et.getEntityName());
return true;
}
}
package cn.ibizlab.core.extensions.util;
import freemarker.cache.ClassTemplateLoader;
import freemarker.cache.TemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
import java.util.Map;
public class FreeMakerHelper {
private static Log log = LogFactory.getLog(FreeMakerHelper.class);
/**
* 根据ftl生成目标文件
* @param basePackagePath ftl文件目录(classpath相对路径)
* @param templateFileName ftl文件名
* @param param ftl文件所需参数
* @param outputFilePath 目标文件输出路径
* @throws Exception
*/
public static void outputFreeMaker(String basePackagePath,String templateFileName,Map param, File outputFilePath) throws Exception{
log.info("------freemaker正在进行文件输出任务------");
// 第一步:创建一个Configuration对象,直接new一个对象。构造方法的参数就是freemarker对于的版本号。
Configuration configuration = new Configuration(Configuration.getVersion());
// 第二步:设置模板文件所在的路径
TemplateLoader templateLoader= new ClassTemplateLoader(FreeMakerHelper.class,basePackagePath);
configuration.setTemplateLoader(templateLoader);
// 第三步:设置模板文件使用的字符集。一般就是utf-8.
configuration.setDefaultEncoding("utf-8");
// 第四步:加载一个模板,创建一个模板对象。
Template template = configuration.getTemplate(templateFileName);
// 第五步:创建一个模板使用的数据集,可以是pojo也可以是map。一般是Map。
// 第六步:创建一个Writer对象,一般创建一FileWriter对象,指定生成的文件名。
Writer out = new FileWriter(outputFilePath);
// 第七步:调用模板对象的process方法输出文件。
template.process(param, out);
// 第八步:关闭流。
out.close();
log.info("------freemaker已完成文件输出任务------");
}
}
package cn.ibizlab.core.extensions.util;
import cn.ibizlab.core.extensions.domain.BaseEntity;
import cn.ibizlab.core.extensions.domain.DSTEntityModel;
import java.util.List;
public interface IEntityActionHelper {
List<BaseEntity> select(String dblink, String sql);
DSTEntityModel getModel(String etname);
}
......@@ -166,4 +166,9 @@ public class EntityObj extends DataObj<String,Object> {
});
}
}
public boolean isDelete()
{
return false;
}
}
......@@ -3,12 +3,15 @@ package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.core.lite.extensions.model.Property;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.helper.RuleUtils;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
......@@ -269,4 +272,108 @@ public class ModelObj extends DataObj<String,Object> {
return this;
}
public boolean IF(String cond)
{
String[] arr=cond.split("\\s+");
String option="";
String members="";
String exp="";
if(arr.length>=2)
{
members=arr[0];
option=arr[1];
}
Object val=null;
String[] ms=members.split("[.]");
if(ms.length>=2&&(!StringUtils.isEmpty(ms[0])))
{
EntityObj sub=this.getEntity(ms[0]);
if(sub.isDelete())
return false;
if(sub!=null)
{
val=sub.get(ms[1]);
}
}
if(arr.length>=3)
{
exp=arr[2];
if(exp.startsWith("%"))
{
return RuleUtils.test(val, option, execFunc(exp));
}
}
return RuleUtils.test(val,option, exp);
}
private Object execFunc(String exp)
{
exp=exp.replace("%", "").trim();
if(exp.startsWith("DAY("))
{
Calendar calendar = Calendar.getInstance();
String quStr=exp.substring(exp.indexOf("(")+1,exp.indexOf(")"));
quStr=quStr.replace("+","").trim();
int day=0;
if(!StringUtils.isEmpty(quStr)){
day= Integer.parseInt(quStr);
}
calendar.add(Calendar.DATE, day);
return new Timestamp(calendar.getTime().getTime());
}
else if(exp.endsWith(")"))
{
String quStr=exp.substring(exp.indexOf("(")+1,exp.indexOf(")"));
exp = exp.substring(0,exp.indexOf("(")).trim();
quStr=quStr.replace("+","").trim();
Integer day=0;
if(!StringUtils.isEmpty(quStr)){
day= Integer.parseInt(quStr);
}
Object val = this.get(exp);
if(val!=null)
{
if(val instanceof Timestamp)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime((Timestamp)val);
calendar.add(Calendar.DATE, day);
return new Timestamp(calendar.getTime().getTime());
}
else if(val instanceof Integer)
{
return (int)val+day;
}
else if(val instanceof BigDecimal)
{
return ((BigDecimal)val).intValue()+day;
}
}
return val;
}
return null;
}
}
......@@ -34,6 +34,7 @@ public interface IMetaEntityService extends IService<MetaEntity> {
MetaEntity get(String key);
MetaEntity getDraft(MetaEntity et);
boolean checkKey(MetaEntity et);
MetaEntity getDefaultModel(MetaEntity et);
boolean save(MetaEntity et);
void saveBatch(List<MetaEntity> list);
Page<MetaEntity> searchDefault(MetaEntitySearchContext context);
......
......@@ -157,6 +157,13 @@ public class MetaEntityServiceImpl extends ServiceImpl<MetaEntityMapper, MetaEnt
public boolean checkKey(MetaEntity et) {
return (!ObjectUtils.isEmpty(et.getEntityId())) && (!Objects.isNull(this.getById(et.getEntityId())));
}
@Override
@Transactional
public MetaEntity getDefaultModel(MetaEntity et) {
//自定义代码
return et;
}
@Override
@Transactional
public boolean save(MetaEntity et) {
......
......@@ -33,6 +33,7 @@ public interface IRuleItemService extends IService<RuleItem> {
void removeBatch(Collection<String> idList);
RuleItem get(String key);
RuleItem getDraft(RuleItem et);
RuleItem buildRuleFile(RuleItem et);
boolean checkKey(RuleItem et);
RuleItem modelchange(RuleItem et);
boolean save(RuleItem et);
......
......@@ -125,6 +125,13 @@ public class RuleItemServiceImpl extends ServiceImpl<RuleItemMapper, RuleItem> i
return et;
}
@Override
@Transactional
public RuleItem buildRuleFile(RuleItem et) {
//自定义代码
return et;
}
@Override
public boolean checkKey(RuleItem et) {
return (!ObjectUtils.isEmpty(et.getRuleId())) && (!Objects.isNull(this.getById(et.getRuleId())));
......
package com.engineer;
import net.ibizsys.dst.common.domain.BaseEntity;
import net.ibizsys.dst.common.domain.IEntity;
import net.ibizsys.dst.common.service.BaseEntityService;
global BaseEntityService BaseService;
rule "<#if ruleid??>${ruleid}_1</#if>"
salience 100
activation-group "<#if ruleid??>${ruleid}</#if>"
when
item:BaseEntity( <#if rulecond??>${rulecond}</#if> )
<#if (releationcond??)>${releationcond}</#if>
then
BaseService.saveResult(item,"<#if ruleid??>${ruleid}</#if>","<#if rulename??>${rulename}</#if>","<#if memo??>${memo}</#if>","<#if businesscat??>${businesscat}</#if>",1,${keyvaluefield},${domainsfield},${metricfield},${timefield},${ext1field},${ext2field});
end
rule "<#if ruleid??>${ruleid}_d</#if>"
salience 0
activation-group "<#if ruleid??>${ruleid}</#if>"
when
item:BaseEntity( )
<#if (releationcond??)>${releationcond}</#if>
then
BaseService.saveResult(item,"<#if ruleid??>${ruleid}</#if>","<#if rulename??>${rulename}</#if>", null,"<#if businesscat??>${businesscat}</#if>",0,item.KEY,${domainsfield},${metricfield},${timefield},null,null);
end
\ No newline at end of file
......@@ -48,7 +48,7 @@
<!--输出实体[DA_METRIC]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-da_metric-53-3">
<changeSet author="a_A_5d9d78509" id="tab-da_metric-59-3">
<createTable tableName="IBZDAMETRIC">
<column name="DA_METRICID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_DA_METRIC_DA_METRICID"/>
......@@ -226,7 +226,7 @@
<!--输出实体[META_ENTITY]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-meta_entity-12-10">
<changeSet author="a_A_5d9d78509" id="tab-meta_entity-13-10">
<createTable tableName="IBZENTITY">
<column name="ENTITYID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_META_ENTITY_ENTITYID"/>
......@@ -420,7 +420,7 @@
<!--输出实体[RU_ITEM]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-ru_item-59-16">
<changeSet author="a_A_5d9d78509" id="tab-ru_item-68-16">
<createTable tableName="IBZRULE">
<column name="RULEID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_RU_ITEM_RULEID"/>
......@@ -457,7 +457,7 @@
<!--输出实体[DA_BUILD]外键关系 -->
<!--输出实体[DA_CHART]外键关系 -->
<!--输出实体[DA_METRIC]外键关系 -->
<changeSet author="a_A_5d9d78509" id="fk-da_metric-53-17">
<changeSet author="a_A_5d9d78509" id="fk-da_metric-59-17">
<addForeignKeyConstraint baseColumnNames="BUILDID" baseTableName="IBZDAMETRIC" constraintName="DER1N_DA_METRIC_DA_BUILD_BUILD" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="BUILDID" referencedTableName="IBZDABUILD" validate="true"/>
</changeSet>
<!--输出实体[DA_REPORT]外键关系 -->
......
......@@ -32,7 +32,7 @@
"delogicname":"指标",
"sysmoudle":{"id":"ANALYSIS","name":"analysis"},
"dedataset":[{"id":"Default" , "name":"数据集"}],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" },{"id":"SyncRule" , "name":"同步指标到规则" , "type":"USERCUSTOM" }],
"datascope":[{"id":"all","name":"全部数据"}]
}
, {
......@@ -96,7 +96,7 @@
"delogicname":"实体",
"sysmoudle":{"id":"LITE","name":"lite"},
"dedataset":[{"id":"Default" , "name":"数据集"}],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"GetDefaultModel" , "name":"GetDefaultModel" , "type":"USERCUSTOM" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"datascope":[{"id":"all","name":"全部数据"}]
}
, {
......@@ -152,7 +152,7 @@
"delogicname":"规则",
"sysmoudle":{"id":"RULE","name":"rule"},
"dedataset":[{"id":"Default" , "name":"数据集"}],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Modelchange" , "name":"modelchange" , "type":"USERCUSTOM" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"BuildRuleFile" , "name":"生成规则文件" , "type":"USERCUSTOM" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Modelchange" , "name":"modelchange" , "type":"USERCUSTOM" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"datascope":[{"id":"all","name":"全部数据"}]
}
],
......
......@@ -350,6 +350,10 @@
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
</dependencies>
......
......@@ -136,6 +136,17 @@ public class DAMetricResource {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-SyncRule-all')")
@ApiOperation(value = "同步指标到规则", tags = {"指标" }, notes = "同步指标到规则")
@RequestMapping(method = RequestMethod.POST, value = "/dametrics/{dametric_id}/syncrule")
public ResponseEntity<DAMetricDTO> syncRule(@PathVariable("dametric_id") String dametric_id, @RequestBody DAMetricDTO dametricdto) {
DAMetric domain = dametricMapping.toDomain(dametricdto);
domain.setMetricId(dametric_id);
domain = dametricService.syncRule(domain);
dametricdto = dametricMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dametricdto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-searchDefault-all')")
@ApiOperation(value = "获取数据集", tags = {"指标" } ,notes = "获取数据集")
@RequestMapping(method= RequestMethod.GET , value="/dametrics/fetchdefault")
......@@ -266,6 +277,17 @@ public class DAMetricResource {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-SyncRule-all')")
@ApiOperation(value = "根据分析指标", tags = {"指标" }, notes = "根据分析指标")
@RequestMapping(method = RequestMethod.POST, value = "/dabuilds/{dabuild_id}/dametrics/{dametric_id}/syncrule")
public ResponseEntity<DAMetricDTO> syncRuleByDABuild(@PathVariable("dabuild_id") String dabuild_id, @PathVariable("dametric_id") String dametric_id, @RequestBody DAMetricDTO dametricdto) {
DAMetric domain = dametricMapping.toDomain(dametricdto);
domain.setBuildId(dabuild_id);
domain = dametricService.syncRule(domain) ;
dametricdto = dametricMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dametricdto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DAMetric-searchDefault-all')")
@ApiOperation(value = "根据分析获取数据集", tags = {"指标" } ,notes = "根据分析获取数据集")
@RequestMapping(method= RequestMethod.GET , value="/dabuilds/{dabuild_id}/dametrics/fetchdefault")
......
......@@ -121,6 +121,17 @@ public class MetaEntityResource {
return ResponseEntity.status(HttpStatus.OK).body(metaentityService.checkKey(metaentityMapping.toDomain(metaentitydto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-GetDefaultModel-all')")
@ApiOperation(value = "GetDefaultModel", tags = {"实体" }, notes = "GetDefaultModel")
@RequestMapping(method = RequestMethod.GET, value = "/metaentities/{metaentity_id}/getdefaultmodel")
public ResponseEntity<MetaEntityDTO> getDefaultModel(@PathVariable("metaentity_id") String metaentity_id, @RequestBody MetaEntityDTO metaentitydto) {
MetaEntity domain = metaentityMapping.toDomain(metaentitydto);
domain.setEntityId(metaentity_id);
domain = metaentityService.getDefaultModel(domain);
metaentitydto = metaentityMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(metaentitydto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-Save-all')")
@ApiOperation(value = "保存实体", tags = {"实体" }, notes = "保存实体")
@RequestMapping(method = RequestMethod.POST, value = "/metaentities/save")
......@@ -245,6 +256,17 @@ public class MetaEntityResource {
return ResponseEntity.status(HttpStatus.OK).body(metaentityService.checkKey(metaentityMapping.toDomain(metaentitydto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-GetDefaultModel-all')")
@ApiOperation(value = "根据系统实体", tags = {"实体" }, notes = "根据系统实体")
@RequestMapping(method = RequestMethod.GET, value = "/dstsystems/{dstsystem_id}/metaentities/{metaentity_id}/getdefaultmodel")
public ResponseEntity<MetaEntityDTO> getDefaultModelByDstSystem(@PathVariable("dstsystem_id") String dstsystem_id, @PathVariable("metaentity_id") String metaentity_id, @RequestBody MetaEntityDTO metaentitydto) {
MetaEntity domain = metaentityMapping.toDomain(metaentitydto);
domain.setSystemId(dstsystem_id);
domain = metaentityService.getDefaultModel(domain) ;
metaentitydto = metaentityMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(metaentitydto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaEntity-Save-all')")
@ApiOperation(value = "根据系统保存实体", tags = {"实体" }, notes = "根据系统保存实体")
@RequestMapping(method = RequestMethod.POST, value = "/dstsystems/{dstsystem_id}/metaentities/save")
......
......@@ -115,6 +115,17 @@ public class RuleItemResource {
return ResponseEntity.status(HttpStatus.OK).body(ruleitemMapping.toDto(ruleitemService.getDraft(new RuleItem())));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-RuleItem-BuildRuleFile-all')")
@ApiOperation(value = "生成规则文件", tags = {"规则" }, notes = "生成规则文件")
@RequestMapping(method = RequestMethod.POST, value = "/ruleitems/{ruleitem_id}/buildrulefile")
public ResponseEntity<RuleItemDTO> buildRuleFile(@PathVariable("ruleitem_id") String ruleitem_id, @RequestBody RuleItemDTO ruleitemdto) {
RuleItem domain = ruleitemMapping.toDomain(ruleitemdto);
domain.setRuleId(ruleitem_id);
domain = ruleitemService.buildRuleFile(domain);
ruleitemdto = ruleitemMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(ruleitemdto);
}
@ApiOperation(value = "检查规则", tags = {"规则" }, notes = "检查规则")
@RequestMapping(method = RequestMethod.POST, value = "/ruleitems/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody RuleItemDTO ruleitemdto) {
......
......@@ -580,4 +580,56 @@ public class RuleUtils
}
return acts;
}
public static boolean inc2s(String tvs, Object finalObject)
{
if (ObjectUtils.isEmpty(finalObject))
return false;
if(StringUtils.isEmpty(tvs))
return false;
if (finalObject instanceof String)
{
tvs="s:"+tvs;
}
else
return false;
List acts = parseTvs(tvs);
for (Iterator localIterator = acts.iterator(); localIterator.hasNext();)
{
Object act = localIterator.next();
if (equal(c2s(act.toString()),c2s(finalObject.toString())))
return true;
}
return false;
}
public static String c2s(String str)
{
if(str==null)
return null;
if(str.length()<300)
{
str=str.trim();//1234567890()【】〔2018〕
str=str.replace("1","1").replace("2","2").replace("3","3").replace("4","4").
replace("5","5").replace("6","6").replace("7","7")
.replace("8","8").replace("9","9").replace("0","0")
.replace("(","〔").replace(")","〕")
.replace("(","〔").replace(")","〕")
.replace("【","〔").replace("】","〕")
.replace("[","〔").replace("]","〕");
}
return str;
}
public static boolean notinc2s(String tvs, Object finalObject)
{
return (!inc2s(tvs,finalObject));
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册