提交 8ca75dac 编写于 作者: sq3536's avatar sq3536

modify

上级 95377a32
.app-form-json{
.btn-secondary {
color: black;
background-color: transparent;
border-color: transparent;
}
.form-control {
display: block;
height: calc(1.4em + 0.75rem + 2px);
padding: 0.375rem 0.75rem;
font-size: 13px;
font-weight: 400;
line-height: 1;
}
h3, .h3 {
font-size: 14px;
font-weight: 700;
margin-top: 5px;
}
.row{
> div {
> div{
display: flex;
}
}
}
.nav{
display: block;
> li{
border-radius: 5px;
padding: 5px;
cursor: pointer;
>
a:hover{
text-decoration: none;
}
}
.active{
background-color:#357AB3;
>
a{
color: #fff;
}
a:hover{
color: #fff;
}
}
}
.control-label{
min-width: 100px;
display: inline-block;
}
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue/dist/bootstrap-vue.css";
import CodeListService from "@/codelist/codelist-service";
import AppFormJson from './app-form-json.vue';
import "./app-form-json-da-chart.less";
@Component({
......@@ -17,19 +16,19 @@ import "./app-form-json-da-chart.less";
}
})
export default class AppFormJsonDaChart extends AppFormJson {
export default class AppFormJsonDaReport extends AppFormJson {
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public async getSchema(): Promise<any>{
let _schema = {
"title": "表头配置",
"title": "图表配置",
"type": "array",
"format": "tabs",
"required": ["headerName"],
"items": {
"$ref": "#/definitions/columnDefs"
},
"default":{headerName:"名称"},
"default":{headerName:"指标名称"},
"definitions": {
"columnDefs": {
"id" : "arr_columnDefs",
......@@ -40,13 +39,8 @@ export default class AppFormJsonDaChart extends AppFormJson {
"properties": {
"headerName": {
"type": "string",
"title": "列头",
"default": "列名称",
},
"width": {
"type": "integer",
"title": "宽度",
"default": "50",
"title": "指标自定义名称",
"default": "指标名称",
},
"entity": {
"type": "string",
......@@ -68,7 +62,7 @@ export default class AppFormJsonDaChart extends AppFormJson {
"links": [
{
"rel": "查看",
"href": "javascript:window.showdetail('dametric-edit-view',{'dametric':'{{self}}'})"// "/dstweb/index.html#/common_index/analyse_dametriceditview/srfkey={{self}}"
"href": "javascript:window.showdetail('dametric-edit-view',{'dametric':'{{self}}'})"
}
],
options: {
......@@ -80,16 +74,6 @@ export default class AppFormJsonDaChart extends AppFormJson {
"enumSource":[{"source":[...[{metric_name:"--",metric_id:""}]],
"p0":"entity12" ,"url":'/dabuilds/${p0}/dametrics/fetchdefault',
"title": "{{item.metric_name}}", "value": "{{item.metric_id}}"}]
},
"children": {
"type": "array",
"format": "tabs",
"required": ["headerName","entity","field"],
"title": "下级",
"items": {
"$ref": "#/definitions/columnDefs"
},
"default":{headerName:"列名称"}
}
}
}
......@@ -98,11 +82,14 @@ export default class AppFormJsonDaChart extends AppFormJson {
let _eset: Array<any> = [];
try{
const res = await this.codeListService.getItems("CLModel",{},{"n_systemid_eq":"tyyw2plus"});
let cond={};
const localdata = window.localStorage.getItem('localdata');
if(localdata) cond={"n_systemid_eq":localdata["dstsystemid"]};
const res = await this.codeListService.getItems("CLModel",{},cond);
_eset.push(...res);
}catch(er){
}catch(er){}
}
if (_eset) {
let _items = [...[{text:"--",id:""}],..._eset];
let sourceobj={"source":_items,"title": "{{item.text}}", "value": "{{item.id}}"};
......
<script lang='tsx'>
import { Component, Vue, Prop, Model, Watch } from "vue-property-decorator";
import { VNode, CreateElement } from "vue";
import { interval, Subject, Subscription } from "rxjs";
import { Http,Util } from '@/utils';
import JSONEditor from "@json-editor/json-editor";
import BootstrapVue from "bootstrap-vue";
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue/dist/bootstrap-vue.css";
import CodeListService from "@/codelist/codelist-service";
import AppFormJson from './app-form-json.vue';
@Component({
components: {
}
})
export default class AppFormJsonDaChart extends AppFormJson {
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public async getSchema(): Promise<any>{
let _schema = {
"title": "表头配置",
"type": "array",
"format": "tabs",
"required": ["headerName"],
"items": {
"$ref": "#/definitions/columnDefs"
},
"default":{headerName:"列名称"},
"definitions": {
"columnDefs": {
"id" : "arr_columnDefs",
"type": "object",
"title": "展现",
"headerTemplate": "{{ self.headerName }}",
"required": ["headerName","entity","field"],
"properties": {
"headerName": {
"type": "string",
"title": "列头",
"default": "列名称",
},
"width": {
"type": "integer",
"title": "宽度",
"default": "50",
},
"entity": {
"type": "string",
"title": "模型",
options: {
select2_options: {
width: 200,
value: ''
}
},
enumSource: []
},
"field":{
"type": "selectnew",
"title": "属性",
"watch": {
"entity12": "arr_columnDefs.entity" ,
},
"links": [
{
"rel": "查看",
"href": "javascript:window.showdetail('dametric-edit-view',{'dametric':'{{self}}'})"
}
],
options: {
select2_options: {
width: 350,
value: ''
}
},
"enumSource":[{"source":[...[{metric_name:"--",metric_id:""}]],
"p0":"entity12" ,"url":'/dabuilds/${p0}/dametrics/fetchdefault',
"title": "{{item.metric_name}}", "value": "{{item.metric_id}}"}]
},
"children": {
"type": "array",
"format": "tabs",
"required": ["headerName","entity","field"],
"title": "下级",
"items": {
"$ref": "#/definitions/columnDefs"
},
"default":{headerName:"列名称"}
}
}
}
}
};
let _eset: Array<any> = [];
try{
let cond={};
const localdata = window.localStorage.getItem('localdata');
if(localdata) cond={"n_systemid_eq":localdata["dstsystemid"]};
const res = await this.codeListService.getItems("CLModel",{},cond);
_eset.push(...res);
}catch(er){}
if (_eset) {
let _items = [...[{text:"--",id:""}],..._eset];
let sourceobj={"source":_items,"title": "{{item.text}}", "value": "{{item.id}}"};
_schema.definitions.columnDefs.properties.entity.enumSource=[sourceobj];
}
// let _fset: Array<any> = [];
// try{
// const res = await this.codeListService.getItems("CLMetric");
// _fset.push(...res);
// }catch(er){
// }
// if (_fset) {
// let _items = [...[{text:"--",id:""}],..._fset];
// let sourceobj={"source":_items,"filterText":"entity12","title": "{{item.text}}", "value": "{{item.id}}"};
// _schema.definitions.columnDefs.properties.field.enumSource=[sourceobj];
// }
return _schema;
}
}
</script>
\ No newline at end of file
<script lang='tsx'>
import { Component, Vue, Prop, Model, Watch } from "vue-property-decorator";
import { VNode, CreateElement } from "vue";
import { interval, Subject, Subscription } from "rxjs";
import { Http,Util } from '@/utils';
import JSONEditor from "@json-editor/json-editor";
import BootstrapVue from "bootstrap-vue";
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue/dist/bootstrap-vue.css";
import CodeListService from "@/codelist/codelist-service";
import AppFormJson from './app-form-json.vue';
@Component({
components: {
}
})
export default class AppFormJsonFieldSet extends AppFormJson {
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public async getSchema(): Promise<any>{
let _schema = {
"title": "表头配置",
"type": "array",
"format": "tabs",
"required": ["headerName"],
"items": {
"$ref": "#/definitions/columnDefs"
},
"default":{headerName:"列名称"},
"definitions": {
"columnDefs": {
"id" : "arr_columnDefs",
"type": "object",
"title": "展现",
"headerTemplate": "{{ self.headerName }}",
"required": ["headerName","entity","field"],
"properties": {
"headerName": {
"type": "string",
"title": "列头",
"default": "列名称",
},
"width": {
"type": "integer",
"title": "宽度",
"default": "50",
},
"entity": {
"type": "string",
"title": "模型",
options: {
select2_options: {
width: 200,
value: ''
}
},
enumSource: []
},
"field":{
"type": "selectnew",
"title": "属性",
"watch": {
"entity12": "arr_columnDefs.entity" ,
},
"links": [
{
"rel": "查看",
"href": "javascript:window.showdetail('dametric-edit-view',{'dametric':'{{self}}'})"
}
],
options: {
select2_options: {
width: 350,
value: ''
}
},
"enumSource":[{"source":[...[{metric_name:"--",metric_id:""}]],
"p0":"entity12" ,"url":'/dabuilds/${p0}/dametrics/fetchdefault',
"title": "{{item.metric_name}}", "value": "{{item.metric_id}}"}]
},
"children": {
"type": "array",
"format": "tabs",
"required": ["headerName","entity","field"],
"title": "下级",
"items": {
"$ref": "#/definitions/columnDefs"
},
"default":{headerName:"列名称"}
}
}
}
}
};
let _eset: Array<any> = [];
try{
let cond={};
const localdata = window.localStorage.getItem('localdata');
if(localdata) cond={"n_systemid_eq":localdata["dstsystemid"]};
const res = await this.codeListService.getItems("CLModel",{},cond);
_eset.push(...res);
}catch(er){}
if (_eset) {
let _items = [...[{text:"--",id:""}],..._eset];
let sourceobj={"source":_items,"title": "{{item.text}}", "value": "{{item.id}}"};
_schema.definitions.columnDefs.properties.entity.enumSource=[sourceobj];
}
// let _fset: Array<any> = [];
// try{
// const res = await this.codeListService.getItems("CLMetric");
// _fset.push(...res);
// }catch(er){
// }
// if (_fset) {
// let _items = [...[{text:"--",id:""}],..._fset];
// let sourceobj={"source":_items,"filterText":"entity12","title": "{{item.text}}", "value": "{{item.id}}"};
// _schema.definitions.columnDefs.properties.field.enumSource=[sourceobj];
// }
return _schema;
}
}
</script>
\ No newline at end of file
<template>
<div class="app-form-json">
<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="CurrentVal">
<div :id='id' :innerHTML="id"></div>
<el-input type="hidden" :rows="2" placeholder="请输入内容" v-model="CurrentVal">
</el-input>
<div id='editor_holder_json'></div>
</div>
</template>
<script lang="ts">
......@@ -14,7 +15,7 @@ import JSONEditor from "@json-editor/json-editor";
import BootstrapVue from "bootstrap-vue";
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue/dist/bootstrap-vue.css";
import "select2/dist/js/select2.js";
import "./select2.js";
import "select2/dist/css/select2.min.css"
import 'jquery/dist/jquery.min.js'
import $ from 'jquery'
......@@ -33,6 +34,35 @@ JSONEditor.defaults.resolvers.unshift(schema => {
});
JSONEditor.defaults.editors.selectnew = JSONEditor.defaults.editors.select.extend({
remoteCached : {},
getRemoteItems: function(url){
var self = this
if(self.remoteCached[url])
return self.remoteCached[url];
const token = window.localStorage.getItem('token');
var new_items = [];
$.ajax({
url: url,
headers: {
"Authorization":"Bearer "+token//此处放置请求到的用户token
},
type: 'get',
contentType: 'application/json',
dataType: 'text',
async: false, // 同步
success: function (result) {
var resObj = JSON.parse(result);
resObj.forEach((item: any)=>{
new_items.push(item);
});
self.remoteCached[url]=new_items;
},
error: function (result) {
}
});
return new_items;
},
onWatchedFieldChange: function() {
var self = this, vars, j;
......@@ -72,68 +102,40 @@ JSONEditor.defaults.editors.selectnew = JSONEditor.defaults.editors.select.exte
items = new_items;
}
if(this.enumSource[i].codelist)
{
var codelist=this.enumSource[i].codelist;
if(codelist&&items.length<=1)
{
var new_items = [];
Http.getInstance().get(url,{},false)
.then((response: any) => {
if(response.status === 200 && response.data) {
response.data.forEach((item: any)=>{
new_items.push(item);
});
}
}).catch((error: any) => {
console.log(error)
})
new_items.unshift(JSON.parse(JSON.stringify(items[0])));
items = new_items;
}
}
if(this.enumSource[i].url)
{
var url=this.enumSource[i].url;
var p0=vars[this.enumSource[i].p0];
var p1=vars[this.enumSource[i].p1];
var p2=vars[this.enumSource[i].p2];
var p3=vars[this.enumSource[i].p3];
if(p0)
url=url.replace('${p0}',p0);
if(p1)
url=url.replace('${p1}',p1);
if(p2)
url=url.replace('${p2}',p2);
if(p3)
url=url.replace('${p3}',p3);
var new_items = [];
if(p0)
var localdata;
if(url.indexOf("${localdata.")>0)
{
const token = window.localStorage.getItem('token');
$.ajax({
url: url,
headers: {
"Authorization":"Bearer "+token//此处放置请求到的用户token
},
type: 'get',
contentType: 'application/json',
dataType: 'text',
async: false, // 同步
success: function (result) {
var resObj = JSON.parse(result);
resObj.forEach((item: any)=>{
new_items.push(item);
});
new_items.unshift(JSON.parse(JSON.stringify(items[0])));
items = new_items;
},
error: function (result) {
localdata = window.localStorage.getItem('localdata');
if(localdata)
{
url=url.replace('${localdata.dstsystemid}',localdata["dstsystemid"]);
}
});
}
var new_items = [];
if(url.indexOf("${")<0)
{
var firstObj = (JSON.parse(JSON.stringify(items[0])));
items = JSON.parse(JSON.stringify(this.getRemoteItems(url)));
items.unshift(firstObj);
console.log(items);
}
else
......@@ -224,24 +226,24 @@ JSONEditor.defaults.editors.selectnew = JSONEditor.defaults.editors.select.exte
this.setupSelect2();
}
// {
// var vars;
// if(this.header_template) {
// vars = $extend(this.getWatchedFieldValues(),{
// key: this.key,
// i: this.key,
// i0: (this.key*1),
// i1: (this.key*1+1),
// title: this.getTitle()
// });
// var header_text = this.header_template(vars);
// if(header_text !== this.header_text) {
// this.header_text = header_text;
// this.updateHeaderText();
// this.notify();
// //this.fireChangeHeaderEvent();
// }
// }
var vars;
if(this.header_template) {
vars = $.extend(this.getWatchedFieldValues(),{
key: this.key,
i: this.key,
i0: (this.key*1),
i1: (this.key*1+1),
title: this.getTitle()
});
var header_text = this.header_template(vars);
if(header_text !== this.header_text) {
this.header_text = header_text;
this.updateHeaderText();
this.notify();
//this.fireChangeHeaderEvent();
}
}
if(this.link_watchers.length) {
vars = this.getWatchedFieldValues();
for(var i=0; i<this.link_watchers.length; i++) {
......@@ -400,6 +402,9 @@ JSONEditor.defaults.editors.link = JSONEditor.defaults.editors.string.extend({
@Component({})
export default class AppFormJson extends Vue {
/**
* 双向绑定值
*
......@@ -504,6 +509,8 @@ export default class AppFormJson extends Vue {
*/
public editor: any;
public id: any = this.$util.createUUID();
public async getSchema(): Promise<any>{
if(this.schema)
......@@ -542,7 +549,7 @@ export default class AppFormJson extends Vue {
*/
public async renderJsoneditor() {
var _this = this;
var element = document.getElementById("editor_holder_json");
var element = document.getElementById(_this.id);
if (this.editor) {
this.editor.destroy();
}
......
此差异已折叠。
......@@ -106,7 +106,7 @@ export default class AppTreeselectRefreshview extends Vue {
* @memberof AppTreeselectRefreshview
*/
public initHandle() {
let url: any = "/lite/sysapps";
let url: any = "/dst/sysapps";
this.$http
.get(url)
.then((response: any) => {
......
......@@ -2,6 +2,9 @@ import AvueComponent from './components/avue-component/avue-component.vue'
import AppAvueCrud from './components/app-avue-crud/app-avue-crud.vue'
import AppFormJson from './components/app-form-json/app-form-json.vue'
import AppFormJsonDaChart from './components/app-form-json/app-form-json-da-chart.vue'
import AppFormJsonDaReport from './components/app-form-json/app-form-json-da-report.vue'
import AppFormJsonLogic from './components/app-form-json/app-form-json-logic.vue'
import AppFormJsonFieldSet from './components/app-form-json/app-form-json-field-set.vue'
import AppTreeselectRefreshview from './components/app-treeselect-refreshview/app-treeselect-refreshview.vue'
import 'jquery/dist/jquery.min.js'
import $ from 'jquery'
......@@ -14,5 +17,8 @@ export const UserComponent = {
v.component('app-treeselect-refreshview', AppTreeselectRefreshview);
v.component('app-form-json', AppFormJson);
v.component('app-form-json-da-chart', AppFormJsonDaChart);
v.component('app-form-json-da-report', AppFormJsonDaReport);
v.component('app-form-json-logic', AppFormJsonLogic);
v.component('app-form-json-field-set', AppFormJsonFieldSet);
}
};
\ No newline at end of file
package cn.ibizlab.core.dict.extensions.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Option
{
private String id;
private Object value;
private String label;
private List<Option> children;
private String iconClass;
private String filter;
private Boolean disabled;
@JsonIgnore
@JSONField(serialize = false)
private String parent;
private Map<String,Object> extension;
}
package cn.ibizlab.core.extensions.mapper;
import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DbEntityMapper extends BaseMapper<EntityObj>{
List<EntityObj> search(@Param("sql") String sql, @Param("ew") Wrapper<EntityObj> wrapper);
}
\ No newline at end of file
package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.lite.domain.DstDataSource;
import cn.ibizlab.core.lite.extensions.domain.Setting;
import cn.ibizlab.core.lite.extensions.domain.SysModel;
import cn.ibizlab.core.lite.service.impl.DstDataSourceServiceImpl;
import cn.ibizlab.util.domain.LiquibaseProp;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.creator.DataSourceCreator;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.lite.domain.DstDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary;
import java.util.*;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.ibizlab.core.lite.extensions.util.LiteStorage.parseDatasource;
/**
* 实体[数据源] 自定义服务对象
......@@ -23,13 +43,99 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
/**
* [BuildDS:buildDS] 行为扩展
* @param et
* @param dstDataSource
* @return
*/
@Override
@Transactional
public DstDataSource buildDS(DstDataSource et) {
return super.buildDS(et);
public DstDataSource buildDS(DstDataSource dstDataSource) {
if(!(StringUtils.isEmpty(dstDataSource.getDsCfg())))
{
synchronized (lock)
{
if (check.containsKey(dstDataSource.getDsName()))
return super.buildDS(dstDataSource);
DataSourceProperty dataSourceProperty = new DataSourceProperty();
DynamicRoutingDataSource ds = dataSource;
List<Setting> settings = JSONArray.parseArray(dstDataSource.getDsCfg(), Setting.class);
for (Setting setting : settings)
{
if (setting.getProperty().equalsIgnoreCase("driver-class-name"))
dataSourceProperty.setDriverClassName(setting.getValue());
else if (setting.getProperty().equalsIgnoreCase("username"))
dataSourceProperty.setUsername(setting.getValue());
else if (setting.getProperty().equalsIgnoreCase("password"))
dataSourceProperty.setPassword(setting.getValue());
else if (setting.getProperty().equalsIgnoreCase("url"))
dataSourceProperty.setUrl(setting.getValue());
else if (setting.getProperty().equalsIgnoreCase("defaultSchema"))
dataSourceProperty.setSchema(setting.getValue());
}
dataSourceProperty.getDruid().setFilters("stat,log4j2");
DataSource dataSource = druidDataSourceCreator.createDataSource(dataSourceProperty);
ds.addDataSource(dstDataSource.getDsName(), dataSource);
check.put(dstDataSource.getDsName(), 1);
}
}
return super.buildDS(dstDataSource);
}
@Autowired
@Lazy
private DynamicRoutingDataSource dataSource;
@Autowired
@Lazy
private DataSourceCreator druidDataSourceCreator;
private HashMap<String,Integer> check=new HashMap<>();
private Object lock=new Object();
public void initDataSource(String dsName)
{
synchronized (lock)
{
if (check.containsKey(dsName))
return;
}
DstDataSource dstDataSource=this.getOne(Wrappers.<DstDataSource>lambdaQuery().eq(DstDataSource::getDsId,dsName).or().eq(DstDataSource::getDsName,dsName),false);
if(dstDataSource!=null)
{
dstDataSource.setDsName(dsName);
buildDS(dstDataSource);
}
}
@Override
public boolean update(DstDataSource et) {
if(!super.update(et))
return false;
synchronized (lock)
{
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
if (check.containsKey(et.getDsId()))
{
ds.removeDataSource(et.getDsId());
check.remove(et.getDsId());
}
if (check.containsKey(et.getDsName()))
{
ds.removeDataSource(et.getDsName());
check.remove(et.getDsName());
}
}
buildDS(et);
return true;
}
}
......@@ -8,7 +8,12 @@ import java.math.BigInteger;
import java.util.HashMap;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import cn.ibizlab.core.lite.domain.handlers.DstAppTypeHandler;
import cn.ibizlab.core.lite.extensions.domain.SysModel;
import cn.ibizlab.core.lite.extensions.domain.SysStructure;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
......@@ -18,8 +23,6 @@ import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.enums.DupCheck;
import java.io.Serializable;
import lombok.*;
import org.springframework.data.annotation.Transient;
......@@ -38,7 +41,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
@TableName(value = "IBZPSSYSTEM", resultMap = "DstSystemResultMap")
@TableName(value = "IBZPSSYSTEM",resultMap = "DstSystemResultMap")
public class DstSystem extends EntityMP implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -46,8 +49,8 @@ public class DstSystem extends EntityMP implements Serializable {
/**
* 系统标识
*/
@DEField(isKeyField = true)
@TableId(value = "pssystemid", type = IdType.ASSIGN_UUID)
@DEField(isKeyField=true)
@TableId(value= "pssystemid",type=IdType.ASSIGN_UUID)
@JSONField(name = "pssystemid")
@JsonProperty("pssystemid")
private String pssystemid;
......@@ -61,10 +64,19 @@ public class DstSystem extends EntityMP implements Serializable {
/**
* 结构
*/
@TableField(value = "sysstructure")
@TableField(value = "sysstructure",typeHandler = JacksonTypeHandler.class)
@JSONField(name = "sysstructure")
@JsonProperty("sysstructure")
private String sysstructure;
private SysStructure sysstructure;
/**
* 结构
*/
@TableField(value = "apps",typeHandler = DstAppTypeHandler.class)
@JSONField(name = "apps")
@JsonProperty("apps")
private List<DstApp> apps;
/**
* 校验
*/
......@@ -85,48 +97,44 @@ public class DstSystem extends EntityMP implements Serializable {
/**
* 设置 [系统名称]
*/
public void setPssystemname(String pssystemname) {
this.pssystemname = pssystemname;
this.modify("pssystemname", pssystemname);
public void setPssystemname(String pssystemname){
this.pssystemname = pssystemname ;
this.modify("pssystemname",pssystemname);
}
/**
* 设置 [结构]
*/
public void setSysstructure(String sysstructure) {
this.sysstructure = sysstructure;
this.modify("sysstructure", sysstructure);
public void setSysstructure(SysStructure sysstructure){
this.sysstructure = sysstructure ;
this.modify("sysstructure",sysstructure);
}
/**
* 设置 [校验]
* 设置 [APPS]
*/
public void setMd5check(String md5check) {
this.md5check = md5check;
this.modify("md5check", md5check);
public void setApps(List<DstApp> apps){
this.apps = apps ;
this.modify("apps",apps);
}
/**
* 设置 [排序]
* 设置 [校验]
*/
public void setShoworder(Integer showorder) {
this.showorder = showorder;
this.modify("showorder", showorder);
public void setMd5check(String md5check){
this.md5check = md5check ;
this.modify("md5check",md5check);
}
/**
* 复制当前对象数据到目标对象(粘贴重置)
* @param targetEntity 目标数据对象
* @param bIncEmpty 是否包括空值
* @param <T>
* @return
* 设置 [排序]
*/
@Override
public <T> T copyTo(T targetEntity, boolean bIncEmpty) {
this.reset("pssystemid");
return super.copyTo(targetEntity, bIncEmpty);
public void setShoworder(Integer showorder){
this.showorder = showorder ;
this.modify("showorder",showorder);
}
}
package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
public class DataObj<K,V> extends ConcurrentHashMap<K,V> {
public String getRowKey()
{
return this.getStringValue("_ROWKEY","");
}
public <T> T setRowKey(String rowKey)
{
return this.set("_ROWKEY",(V)rowKey);
}
public Timestamp getTimestamp()
{
return getTimestampBegin("_TIMESTAMP");
}
public <T> T setTimestamp(Timestamp timestamp)
{
return this.set("_TIMESTAMP",(V) DataObject.getTimestampValue(timestamp, DataObject.getBeginDate()));
}
public <T> T set(String key, V value)
{
this.put((K)key.toUpperCase(),value);
return (T)this;
}
@Override
public V get(Object key) {
if(key==null)
return null;
V objValue=super.get(key);
if(objValue==null)
objValue=super.get(key.toString().toUpperCase());
if(objValue==null)
objValue=super.get(key.toString().toLowerCase());
return objValue;
}
public JSONObject getJSONObjectValue(String strParamName) {
return getJSONObjectValue(strParamName,new JSONObject());
}
public JSONObject getJSONObjectValue(String strParamName, JSONObject jDefault) {
return DataObject.getJSONObjectValue(this.get(strParamName),jDefault);
}
public List<String> getListValue( String strParamName) {
return DataObject.getListValue(strParamName);
}
public JSONArray getJSONArrayValue( String strParamName) {
return getJSONArrayValue(strParamName,new JSONArray());
}
public JSONArray getJSONArrayValue( String strParamName, JSONArray jDefault) {
return DataObject.getJSONArrayValue(this.get(strParamName),jDefault);
}
public Integer getIntegerValue(String objValue) {
return getIntegerValue(objValue, Integer.MIN_VALUE);
}
public int getIntegerValue( String strParamName, int nDefault) {
return DataObject.getIntegerValue(this.get(strParamName),nDefault);
}
public Float getFloatValue(String objValue) {
return this.getFloatValue(objValue,-9999f);
}
public Float getFloatValue( String strParamName, float fDefault) {
return DataObject.getFloatValue(this.get(strParamName),fDefault);
}
public BigDecimal getBigDecimalValue(String objValue) {
return this.getBigDecimalValue(objValue,BigDecimal.valueOf(-9999));
}
public BigDecimal getBigDecimalValue( String strParamName, BigDecimal fDefault) {
return DataObject.getBigDecimalValue(this.get(strParamName),fDefault);
}
public Long getLongValue( String strParamName) {
return this.getLongValue(strParamName,Long.MIN_VALUE);
}
public Long getLongValue( String strParamName, long nDefault) {
return DataObject.getLongValue(this.get(strParamName),nDefault);
}
public String getStringValue(String objValue) {
return getStringValue(objValue, "");
}
public String getStringValue( String strParamName, String strDefault) {
return DataObject.getStringValue(this.get(strParamName),strDefault);
}
public byte[] getBinaryValue(String objValue) {
return getBinaryValue(objValue, null);
}
public byte[] getBinaryValue(String strParamName, byte[] def) {
return DataObject.getBinaryValue(this.get(strParamName),def);
}
public Timestamp getTimestampBegin( String strParamName) {
return getTimestampValue(strParamName, DataObject.getBeginDate());
}
public Timestamp getTimestampEnd( String strParamName) {
Object objValue = this.get(strParamName);
if (objValue == null) {
return DataObject.getEndDate();
}
try {
Timestamp t= DataObject.getTimestampValue(objValue, DataObject.getEndDate());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String time = df.format(t);
Calendar cl=Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
cl.setTime(Timestamp.valueOf(time+" 23:59:59"));
return new Timestamp(cl.getTime().getTime());
} catch (Exception ex) {
return DataObject.getEndDate();
}
}
public Timestamp getTimestampValue( String strParamName, Timestamp dtDefault) {
Object objValue = this.get(strParamName);
if (objValue == null || objValue.equals("")) {
return dtDefault;
}
try {
return DataObject.getTimestampValue(objValue,null);
} catch (Exception ex) {
return dtDefault;
}
}
public <T> T copyTo(T targetEntity, boolean bIncEmpty){
if(targetEntity instanceof EntityBase){
for(K field : this.keySet()){
Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
((EntityBase)targetEntity).set((String)field,value);
}
}
}
else if(targetEntity instanceof DTOBase){
for(K field : this.keySet()){
Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
((DTOBase)targetEntity).set(((String)field).toLowerCase(),value);
}
}
}
else if(targetEntity instanceof EntityObj){
for(K field : this.keySet()){
Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
((EntityObj) targetEntity).set((String)field,value);
}
}
}
else if(targetEntity instanceof ModelObj){
for(K field : this.keySet()){
Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
((ModelObj) targetEntity).set((String)field,value);
}
}
}
else if(targetEntity instanceof DataObj){
for(K field : this.keySet()){
Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
((DataObj) targetEntity).set((String)field,value);
}
}
}
else if(targetEntity instanceof Map){
for(K field : this.keySet()){
Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
((Map) targetEntity).put(field,value);
}
}
}
return targetEntity;
}
}
package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.core.lite.domain.MetaDataSet;
import cn.ibizlab.core.lite.domain.MetaEntity;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
public class EntityModel {
public String getEntityId() {
return getEntity().getEntityId();
}
public String getCodeName() {
return getEntity().getCodeName();
}
public String getEntityName() {
return getEntity().getEntityName();
}
public String getTableName() {
return getEntity().getTableName();
}
public String getLogicName() {
return getEntity().getLogicName();
}
public String getSystemId() {
return getEntity().getSystemId();
}
private MetaEntity entity;
private List<MetaDataSet> dataSets;
private List<FieldModel> fields;
private List<RelationshipModel> references;
private List<RelationshipModel> nesteds;
@JsonIgnore
@JSONField(serialize = false)
private Map<String,FieldModel> fieldMap = null;
@JsonIgnore
@JSONField(serialize = false)
public Map<String,FieldModel> getFieldMap()
{
if(fields!=null&&fieldMap==null)
{
fieldMap=new LinkedHashMap<>();
fields.forEach(field->{
fieldMap.put(field.getColumnName(),field);
fieldMap.put(field.getCodeName(),field);
});
}
return fieldMap;
}
@JsonIgnore
@JSONField(serialize = false)
private FieldModel lastModifyField;
@JsonIgnore
@JSONField(serialize = false)
public FieldModel getLastModifyField() {
if(fields!=null&&lastModifyField==null)
for(FieldModel fieldModel:fields)
if(fieldModel.isLastModifyField())
{
lastModifyField=fieldModel;
return lastModifyField;
}
return lastModifyField;
}
@JsonIgnore
@JSONField(serialize = false)
private boolean isLogicValid=true;
@JsonIgnore
@JSONField(serialize = false)
private FieldModel logicValidField;
@JsonIgnore
@JSONField(serialize = false)
public FieldModel getLogicValidField() {
if(isLogicValid&&logicValidField==null) {
if (fields != null) {
for (FieldModel fieldModel : fields) {
if (fieldModel.isLogicValidField()) {
logicValidField = fieldModel;
return logicValidField;
}
}
}
isLogicValid = false;
}
return logicValidField;
}
@JsonIgnore
@JSONField(serialize = false)
private String logicVal;
@JsonIgnore
@JSONField(serialize = false)
public String getLogicVal()
{
if(StringUtils.isEmpty(logicVal))
logicVal=this.getExtParams("logicval");
if(StringUtils.isEmpty(logicVal))
logicVal="1";
return logicVal;
}
@JsonIgnore
@JSONField(serialize = false)
private String logicDelVal;
@JsonIgnore
@JSONField(serialize = false)
public String getLogicDelVal()
{
if(StringUtils.isEmpty(logicVal))
logicDelVal=this.getExtParams("logicdelval");
if(StringUtils.isEmpty(logicDelVal))
logicDelVal="0";
return logicDelVal;
}
@JsonIgnore
@JSONField(serialize = false)
private FieldModel keyField;
@JsonIgnore
@JSONField(serialize = false)
public FieldModel getKeyField() {
if(fields!=null&&keyField==null)
for(FieldModel fieldModel:fields)
if(fieldModel.isKeyField()) {
keyField=fieldModel;
return keyField;
}
return keyField;
}
@JsonIgnore
@JSONField(serialize = false)
private List<FieldModel> unionKeyFields;
@JsonIgnore
@JSONField(serialize = false)
public List<FieldModel> getUnionKeyFields() {
if(fields!=null&&unionKeyFields==null) {
unionKeyFields = new ArrayList<>();
for (FieldModel fieldModel : fields)
if (fieldModel.isUnionKeyField())
unionKeyFields.add(fieldModel);
}
return unionKeyFields;
}
public FieldModel getField(String name)
{
if(StringUtils.isEmpty(name))
return null;
if(fields==null)
return null;
if(getFieldMap()!=null)
return getFieldMap().get(name);
return null;
}
public String getSqlSegment(String dataSet)
{
if("BASE".equalsIgnoreCase(dataSet))
{
String columnSet="";
for(FieldModel fieldModel:fields)
{
String columnExp=fieldModel.getColumnExp();
if(StringUtils.isEmpty(columnExp))
continue;
if(fieldModel.isPhysicalField())
continue;
if(!StringUtils.isEmpty(columnSet)){
columnSet=columnSet+",";
}
columnSet=columnSet+columnExp;
}
if(!StringUtils.isEmpty(columnSet)){
columnSet=columnSet+",";
}
columnSet=columnSet+"t.*";
return "select "+columnSet+" from "+this.getTableName()+" t ";
}
else if("CORE".equalsIgnoreCase(dataSet))
{
String columnSet=this.getKeyField().getColumnExp();
for(FieldModel fieldModel:this.getUnionKeyFields())
{
String columnExp=fieldModel.getColumnExp();
if(StringUtils.isEmpty(columnExp))
continue;
columnSet = columnSet + "," + columnExp;
}
return "select "+columnSet+" from "+this.getTableName()+" ";
}
else
{
if(dataSets!=null)
for (MetaDataSet metaDataSet:dataSets)
if(metaDataSet.getCodeName().equalsIgnoreCase(dataSet)&&(!StringUtils.isEmpty(metaDataSet.getDsCode())))
return "select t1.* from ("+metaDataSet.getDsCode()+") t1";
}
return "";
}
public String getDsName()
{
String dsName=this.getEntity().getDsName();
if(StringUtils.isEmpty(dsName))
{
dsName=this.getSystemId()+"-master";
}
return dsName;
}
public String getExtParams(String key)
{
if(!(StringUtils.isEmpty(this.getEntity().getExtParams())))
{
List<Setting> settings=JSONArray.parseArray(this.getEntity().getExtParams(),Setting.class);
for(Setting setting:settings)
{
if(key.equals(setting.getValue()))
{
return setting.getValue();
}
}
}
return null;
}
}
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 com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.util.StringUtils;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
public class EntityObj extends DataObj<String,Object> {
@JsonIgnore
@JSONField(serialize = false)
public EntityModel getEntityModel()
{
return getProperty().getEntityModel();
}
@JsonIgnore
@JSONField(serialize = false)
public DataModel getDataModel() {
return getProperty().getOwnerDataModel();
}
@JsonIgnore
@JSONField(serialize = false)
private Property property;
@JsonIgnore
@JSONField(serialize = false)
public Property getProperty() {
return property;
}
@JsonIgnore
@JSONField(serialize = false)
public EntityObj setProperty(Property property) {
if(property!=null) {
if(!StringUtils.isEmpty(property.getSystem()))
this.setDstSystemId(property.getSystem());
if(!StringUtils.isEmpty(property.getPropertyEntity()))
this.setMetaEntityName(property.getPropertyEntity());
if(!StringUtils.isEmpty(property.getPropertyName()))
this.setPropertyName(property.getPropertyName());
}
this.property = property;
return this;
}
@JsonIgnore
@JSONField(serialize = false)
public String getPropertyName()
{
return this.getStringValue("_PROPERTYNAME","");
}
@JsonIgnore
@JSONField(serialize = false)
public EntityObj setPropertyName(String propertyName)
{
return this.set("_PROPERTYNAME",propertyName);
}
@JsonIgnore
@JSONField(serialize = false)
public String getMetaEntityName()
{
return this.getStringValue("_METAENTITYNAME","");
}
@JsonIgnore
@JSONField(serialize = false)
public EntityObj setMetaEntityName(String metaEntityName)
{
return this.set("_METAENTITYNAME",metaEntityName);
}
@JsonIgnore
@JSONField(serialize = false)
public String getDstSystemId()
{
return this.getStringValue("_DSTSYSTEMID","");
}
@JsonIgnore
@JSONField(serialize = false)
public EntityObj setDstSystemId(String dstSystemId)
{
return this.set("_DSTSYSTEMID",dstSystemId);
}
@Override
public EntityObj set(String key, Object value)
{
return super.set(key,value);
}
@JsonIgnore
@JSONField(serialize = false)
private ModelObj modelObj;
@JsonIgnore
@JSONField(serialize = false)
public ModelObj getModelObj() {
return modelObj;
}
@JsonIgnore
@JSONField(serialize = false)
public EntityObj setModelObj(ModelObj modelObj) {
this.modelObj = modelObj;
return this;
}
@Override
public String getRowKey()
{
String rowKey=super.getRowKey();
if(StringUtils.isEmpty(rowKey))
{
rowKey=this.getStringValue(this.getEntityModel().getKeyField().getColumnName());
this.setRowKey(rowKey);
}
return rowKey;
}
@JsonIgnore
@JSONField(serialize = false)
@Override
public Timestamp getTimestamp() {
Timestamp lastModify=super.getTimestamp();
if(lastModify.equals(DataObject.getBeginDate())&&this.getEntityModel().getLastModifyField()!=null)
{
lastModify=this.getTimestampBegin(this.getEntityModel().getLastModifyField().getColumnName());
this.setTimestamp(lastModify);
}
return super.getTimestamp();
}
public void findModel(List<ModelObj> modelObjs)
{
HashMap<String, ModelObj> tmps=new HashMap<String, ModelObj>();
modelObjs.forEach(obj->tmps.put(obj.getRowKey(),obj));
this.getProperty().getPropertyMappings().forEach(mapping->{
String selfVal=this.getStringValue(mapping.getSelfPropertyColumn());
modelObjs.forEach(modelObj->{
String parentVal=modelObj.getEntity(mapping.getJoinPropertyEntity()).getStringValue(mapping.getJoinPropertyColumn());
if((StringUtils.isEmpty(parentVal))||(!parentVal.equals(selfVal)))
tmps.remove(modelObj.getRowKey());
});
});
if(tmps.size()>0)
{
tmps.values().forEach(obj->{
EntityObj copy=this.copyTo(new EntityObj(),true).setProperty(this.getProperty());
obj.setEntity(this.getProperty().getPropertyName(),copy);
});
}
}
}
package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.core.lite.domain.MetaField;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.util.StringUtils;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
public class FieldModel {
private String columnName;
private String codeName;
private String unionName;
private String showName;
private String comment;
private MetaField field;
private RelationshipModel reference;
@JsonIgnore
@JSONField(serialize = false)
public String getColumnExp()
{
if(1==field.getPhysicalField())
{
return columnName+" as \""+columnName.toUpperCase()+"\"";
}
else if(!StringUtils.isEmpty(field.getExpression()))
{
return field.getExpression()+" as \""+columnName.toUpperCase()+"\"";
}
return "";
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isPhysicalField()
{
return 1==this.getField().getPhysicalField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isKeyField()
{
return 1==this.getField().getKeyField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isLogicValidField()
{
return "LOGICVALID".equals(this.getField().getPredefined());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isLastModifyField()
{
return "UPDATEDATE".equals(this.getField().getPredefined());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isUnionKeyField()
{
return !StringUtils.isEmpty(this.getField().getUnionKey());
}
}
package cn.ibizlab.core.lite.extensions.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
public class Lookup {
private String mainEntityName;
private String fieldName;
private String refCodeName;
private String refEntityName;
private String refFieldName;
}
package cn.ibizlab.core.lite.extensions.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
/**
* 实体[实体]
*/
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
public class MetaEntityModel{
/**
* 标识
*/
@JSONField(name = "entity_id")
@JsonProperty("entity_id")
private String entityId;
/**
* 实体名
*/
@JSONField(name = "entity_name")
@JsonProperty("entity_name")
private String entityName;
/**
* 逻辑名称
*/
@JSONField(name = "logic_name")
@JsonProperty("logic_name")
private String logicName;
/**
* 代码名称
*/
@JSONField(name = "code_name")
@JsonProperty("code_name")
private String codeName;
/**
* 表名称
*/
@JSONField(name = "table_name")
@JsonProperty("table_name")
private String tableName;
/**
* 系统标识
*/
@JSONField(name = "system_id")
@JsonProperty("system_id")
private String systemId;
/**
* 系统
*/
@JSONField(name = "system_name")
@JsonProperty("system_name")
private String systemName;
/**
* 数据源标识
*/
@JSONField(name = "ds_id")
@JsonProperty("ds_id")
private String dsId;
/**
* 数据源
*/
@JSONField(name = "ds_name")
@JsonProperty("ds_name")
private String dsName;
/**
* 模块标识
*/
@JSONField(name = "module_id")
@JsonProperty("module_id")
private String moduleId;
/**
* 模块
*/
@JSONField(name = "module_name")
@JsonProperty("module_name")
private String moduleName;
/**
* 数据集
*/
private List<cn.ibizlab.core.lite.domain.MetaDataSet> dataSets;
/**
* 属性
*/
private List<cn.ibizlab.core.lite.domain.MetaField> fields;
/**
* 实体关系
*/
private List<cn.ibizlab.core.lite.domain.MetaRelationship> parentEntitys;
/**
* 实体关系
*/
private List<cn.ibizlab.core.lite.domain.MetaRelationship> subEntitys;
}
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 com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.util.StringUtils;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ModelObj extends DataObj<String,Object> {
@JsonIgnore
@JSONField(serialize = false)
private DataModel dataModel;
@JsonIgnore
@JSONField(serialize = false)
public DataModel getDataModel() {
return dataModel;
}
@JsonIgnore
@JSONField(serialize = false)
public ModelObj setDataModel(DataModel dataModel) {
if(dataModel!=null) {
if (!StringUtils.isEmpty(dataModel.getDataModelId()))
this.setDataModelId(dataModel.getDataModelId());
}
this.dataModel = dataModel;
return this;
}
@JsonIgnore
@JSONField(serialize = false)
public String getDataModelId()
{
return this.getStringValue("_DATAMODELID","");
}
@JsonIgnore
@JSONField(serialize = false)
public ModelObj setDataModelId(String dataModelId)
{
return this.set("_DATAMODELID",dataModelId);
}
@JsonIgnore
@JSONField(serialize = false)
private ModelObj parent;
@JsonIgnore
@JSONField(serialize = false)
public ModelObj getParent() {
return parent;
}
@JsonIgnore
@JSONField(serialize = false)
public ModelObj setParent(ModelObj parent) {
this.parent = parent;
if(parent!=null)
parent.getNested(this.getDataModel().getDataModelName(),false).add(this);
return this;
}
public EntityObj getEntity(String name)
{
return getEntity(name,true);
}
public EntityObj getEntity(String name,boolean recursion)
{
Object obj=this.get(name);
if(obj!=null&&obj instanceof EntityObj)
return (EntityObj) obj;
Property property=this.getDataModel().getObjectProperty(name);
if(property!=null) {
return new EntityObj().setProperty(property).setRowKey(this.getRowKey());
}
if(recursion)
{
property=this.getDataModel().findObjectProperty(name,"UP");
if(property!=null){
int layerDiff=this.getDataModel().getLayerNo()-property.getLayerNo();
ModelObj parentObj=this;
for(int i=0;i<layerDiff;i++)
parentObj=parentObj.getParent();
return parentObj.getEntity(name,false);
}
}
return new EntityObj().setDstSystemId(this.getDataModel().getFactPorperty().getSystem()).setMetaEntityName(name).setRowKey(this.getRowKey());
}
public ModelObj setEntity(String name, EntityObj entityObj)
{
if(entityObj!=null)
{
if(entityObj.getModelObj()==null)
entityObj.setModelObj(this);
this.set(name, entityObj);
}
return this;
}
public ModelObj setFactEntity(EntityObj entityObj)
{
this.setEntity(this.getDataModel().getFactPorperty().getPropertyName(),entityObj);
return this;
}
@JsonIgnore
@JSONField(serialize = false)
public EntityObj getFactEntity()
{
return this.getEntity(this.getDataModel().getFactPorperty().getPropertyName(),false);
}
public NestedArray getNested(String name)
{
return getNested(name,true);
}
public NestedArray getNested(String name,boolean recursion)
{
Object list=this.get(name);
if(list!=null&&list instanceof NestedArray)
{
NestedArray nestedArray=(NestedArray) list;
if(nestedArray.getParent()==null)
nestedArray.setParent(this);
return nestedArray;
}
DataModel model=this.getDataModel().getNestedDataModel(name);
if(model!=null)
{
NestedArray array = new NestedArray().setParent(this);
this.set(model.getDataModelName(),array);
return array;
}
if(recursion)
{
model=this.getDataModel().findDataModel(name,"DOWN");
if(model!=null)
{
List<String> steps=new ArrayList<>();
DataModel tmpModel=model;
while (tmpModel.getParentDataModel()!=null&&!tmpModel.getParentDataModel().getDataModelName().equalsIgnoreCase(this.getDataModel().getDataModelName()))
{
tmpModel=model.getParentDataModel();
steps.add(0,tmpModel.getDataModelName());
}
steps.add(model.getDataModelName());
if(steps.size()>1)
{
NestedArray subarry=this.getNested(steps.get(0),false);
if(subarry.size()>0)
{
for(int i=1;i<steps.size();i++)
{
subarry=subarry.getSubNested(steps.get(i));
if(subarry.size()==0)
return new NestedArray().setParent(this);
}
return subarry;
}
}
}
}
return new NestedArray().setParent(this);
}
@Override
public Object get(Object key) {
if(key==null)
return null;
if(key.toString().indexOf(".")>0)
{
String[] epair=key.toString().split("[.]");
if(epair.length>=2)
{
String name=epair[0];
String column=epair[1];
return this.getEntity(name).get(column);
}
}
return super.get(key);
}
@Override
public ModelObj set(String key, Object value)
{
return super.set(key,value);
}
@Override
public String getRowKey()
{
String rowKey=super.getRowKey();
if(StringUtils.isEmpty(rowKey))
{
rowKey=this.getFactEntity().getRowKey();
this.setRowKey(rowKey);
}
return rowKey;
}
@JsonIgnore
@JSONField(serialize = false)
@Override
public Timestamp getTimestamp()
{
Timestamp last = DataObject.getBeginDate();
for(Object sub:this.values())
{
if(sub == null)
continue;
else if(sub instanceof EntityObj)
{
if(((EntityObj)sub).getTimestamp().getTime()>last.getTime())
last=((EntityObj)sub).getTimestamp();
}
else if(sub instanceof NestedArray)
{
if(((NestedArray)sub).getTimestamp().getTime()>last.getTime())
last=((NestedArray)sub).getTimestamp();
}
}
this.setTimestamp(last);
return last;
}
public ModelObj findParent(List<ModelObj> uplayerObjs)
{
if(uplayerObjs.size()==1)
{
this.setParent(uplayerObjs.iterator().next());
return this;
}
HashMap<String, ModelObj> tmps=new HashMap<String, ModelObj>();
uplayerObjs.forEach(obj->tmps.put(obj.getRowKey(),obj));
this.getDataModel().getLayerMappings().forEach(layerMapping->{
String selfVal=this.getFactEntity().getStringValue(layerMapping.getSelfPropertyColumn());
uplayerObjs.forEach(parent->{
String parentVal=parent.getFactEntity().getStringValue(layerMapping.getParentPropertyColumn());
if((StringUtils.isEmpty(parentVal))||(!parentVal.equals(selfVal)))
tmps.remove(parent.getRowKey());
});
});
if(tmps.size()==1)
{
this.setParent(tmps.values().iterator().next());
}
return this;
}
}
package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.sql.Timestamp;
import java.util.ArrayList;
public class NestedArray extends ArrayList<ModelObj> {
@JsonIgnore
@JSONField(serialize = false)
private DataModel dataModel;
@JsonIgnore
@JSONField(serialize = false)
public DataModel getDataModel() {
return dataModel;
}
@JsonIgnore
@JSONField(serialize = false)
private ModelObj parent;
@JsonIgnore
@JSONField(serialize = false)
public ModelObj getParent() {
return parent;
}
@JsonIgnore
@JSONField(serialize = false)
public NestedArray setParent(ModelObj parent) {
this.parent = parent;
if(parent!=null&&this.getDataModel()==null)
this.dataModel=(parent.getDataModel());
return this;
}
public NestedArray getSubNested(String name)
{
NestedArray rt=new NestedArray();
for(ModelObj modelObj:this)
{
NestedArray list=modelObj.getNested(name,false);
if(list!=null)
rt.addAll(list);
}
return rt;
}
@JsonIgnore
@JSONField(serialize = false)
public Timestamp getTimestamp()
{
Timestamp last = DataObject.getBeginDate();
for(ModelObj sub:this)
if(sub.getTimestamp().getTime()>last.getTime())
last=sub.getTimestamp();
return last;
}
}
package cn.ibizlab.core.lite.extensions.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PermissionNode
{
private String id;
private String label;
private String systemid;
private List<PermissionNode> children = new ArrayList<>();
private String fullName;
private PermissionType type;
public PermissionNode setUniKey(String systemid, String id)
{
this.systemid=systemid;
this.id=systemid+"-"+id;
return this;
}
public List<PermissionNode> getChildren()
{
if(children == null)
children = new ArrayList<>();
return children;
}
}
package cn.ibizlab.core.lite.extensions.domain;
public enum PermissionType
{
OPPRIV,UNIRES,APPMENU
}
package cn.ibizlab.core.lite.extensions.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
public class RelationshipModel {
private String codeName;
private String entityName;
private String entityCodeName;
private String entityLogicName;
private String systemId;
private String dataSourceName;
private String tableName;
private String entityId;
}
package cn.ibizlab.core.lite.extensions.domain;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class Setting {
private String property;
private String value;
}
package cn.ibizlab.core.lite.extensions.domain.Structure;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class AppNode
{
private String appid;
private String appname;
@JsonProperty("appmenu")
@JSONField(name = "appmenu")
private List<MenuNode> appmenus;
}
package cn.ibizlab.core.lite.extensions.domain.Structure;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class EntityNode
{
private String dename;
private String delogicname;
@JsonProperty("sysmoudle")
@JSONField(name = "sysmoudle")
private FuncItem moudle;
@JsonProperty("dedataset")
@JSONField(name = "dedataset")
private List<FuncItem> dataSets;
@JsonProperty("deaction")
@JSONField(name = "deaction")
private List<FuncItem> actions;
@JsonProperty("datascope")
@JSONField(name = "datascope")
private List<FuncItem> scopes;
}
package cn.ibizlab.core.lite.extensions.domain.Structure;
import lombok.Data;
import java.util.List;
@Data
public class FuncItem
{
private String id;
private String name;
private String type;
private List<FuncItem> items;
}
package cn.ibizlab.core.lite.extensions.domain.Structure;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class MenuNode
{
private String menuid;
private String menuname;
@JsonProperty("menuitem")
@JSONField(name = "menuitem")
private List<FuncItem> menuitems;
}
package cn.ibizlab.core.lite.extensions.domain.Structure;
import lombok.Data;
@Data
public class UniResNode
{
private String unirescode;
private String uniresname;
}
package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.core.lite.domain.MetaEntity;
import cn.ibizlab.core.lite.domain.MetaField;
import cn.ibizlab.core.lite.domain.MetaRelationship;
import lombok.Data;
import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.*;
@Data
public class SysModel {
private String systemid;
private String systemname;
private List<MetaEntityModel> entities;
/**
* 获取实体属性
* @return
*/
public Set<MetaField> getField(){
Set<MetaField> fields=new HashSet<>();
this.entities.forEach(entityNode->{
List<MetaField> deField=entityNode.getFields();
MetaEntity metaEntity = new MetaEntity();
metaEntity.setSystemId(entityNode.getSystemId());
metaEntity.setEntityName(entityNode.getEntityName());
metaEntity.setCodeName(entityNode.getCodeName());
if(!ObjectUtils.isEmpty(deField)){
for(int i=0;i<deField.size();i++)
{
MetaField field=deField.get(i);
if(field.getShowOrder()==null)
field.setShowOrder(1000+i);
String refDEId="";
String refFieldId="";
String curDEId=DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,entityNode.getEntityName()).getBytes());
Object refDEName=field.get("ref_de");
String refFieldName=field.getRefFieldName();
Object relationCodeName=field.get("relation_codename");
Object relationName=field.get("relation_name");
field.setEntityId(curDEId);
field.setEntity(metaEntity);
if( !ObjectUtils.isEmpty(refDEName) && !ObjectUtils.isEmpty(refFieldName)){
refDEId=DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,refDEName).getBytes());
refFieldId=DigestUtils.md5DigestAsHex(String.format("%s||%s" ,refDEId,refFieldName).getBytes());
field.setRefFieldId(refFieldId);
MetaField reffield = new MetaField();
reffield.setFieldId(refFieldId);
reffield.setFieldName(refFieldName);
field.setReffield(reffield);
}
if(!ObjectUtils.isEmpty(curDEId) && !ObjectUtils.isEmpty(refDEId) && !ObjectUtils.isEmpty(relationCodeName)&& !ObjectUtils.isEmpty(relationName)){
field.setRelationId(DigestUtils.md5DigestAsHex(String.format("%s||%s||%s" ,refDEId,curDEId,relationCodeName).getBytes()));
MetaRelationship ship=new MetaRelationship();
ship.setName(relationName.toString());
ship.setRefEntityName(refDEName.toString());
ship.setCodeName(relationCodeName.toString());
field.setRelation(ship);
}
}
fields.addAll(deField);
}
}
);
return fields;
}
/**
* 获取实体关系
* @return
*/
public Collection<MetaRelationship> getRelation(){
Map<String, MetaRelationship> relations =new HashMap<>();
this.entities.forEach(entityNode->{
List<MetaRelationship> parentRelation= entityNode.getParentEntitys();
List<MetaRelationship> subRelation= entityNode.getSubEntitys();
if(!ObjectUtils.isEmpty(parentRelation)){
addToRelations(relations,parentRelation);
}
if(!ObjectUtils.isEmpty(subRelation)){
addToRelations(relations,subRelation);
}
});
return relations.values();
}
private void addToRelations(Map<String, MetaRelationship> relations, List<MetaRelationship> entityRelations){
entityRelations.forEach(entityRelation->{
entityRelation.setEntityId(DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,entityRelation.getEntityName()).getBytes()));
entityRelation.setRefEntityId(DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,entityRelation.getRefEntityName()).getBytes()));
String relationId = entityRelation.getId();
if( !StringUtils.isEmpty(relationId) && !relations.containsKey(relationId)){
relations.put(relationId,entityRelation);
}
});
}
}
package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.core.lite.domain.DstApp;
import cn.ibizlab.core.lite.extensions.domain.Structure.AppNode;
import cn.ibizlab.core.lite.extensions.domain.Structure.EntityNode;
import cn.ibizlab.core.lite.extensions.domain.Structure.FuncItem;
import cn.ibizlab.core.lite.extensions.domain.Structure.UniResNode;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Data
public class SysStructure
{
private String systemid;
@JsonIgnore
private String systemname;
private List<EntityNode> entities;
@JsonProperty("unires")
@JSONField(name = "unires")
private List<UniResNode> uniResIds;
@JsonProperty("appmenus")
@JSONField(name = "appmenus")
private List<AppNode> apps;
public PermissionNode getPermissionTree(PermissionType type)
{
PermissionNode root = PermissionNode.builder().id(systemid).label(systemname).systemid(systemid).build();
switch (type)
{
case OPPRIV:
Map<String, PermissionNode> moudlemap = new LinkedHashMap<>();
PermissionNode emptyMoudle = PermissionNode.builder().label("未分类模块").build().setUniKey(systemid,"Ungroup");
for(EntityNode node:this.entities) {
PermissionNode moudle = null;
if(node.getMoudle()!=null ) {
if (moudlemap.containsKey(systemid+"-"+node.getMoudle().getId()))
moudle = moudlemap.get(systemid+"-"+node.getMoudle().getId());
else {
moudle = PermissionNode.builder()
.label(node.getMoudle().getName()).build()
.setUniKey(systemid,node.getMoudle().getId());
moudlemap.put(moudle.getId(),moudle);
}
}
else {
moudle = emptyMoudle;
moudlemap.put("Ungroup",moudle);
}
PermissionNode enode = PermissionNode.builder()
.label(node.getDelogicname()).build()
.setUniKey(systemid,node.getDename());
moudle.getChildren().add(enode);
if(node.getDataSets()!=null)
node.getDataSets().forEach(dataset->{
String datasetname=dataset.getName();
if(datasetname.toUpperCase().equals("DEFAULT"))
datasetname="";
datasetname="查询"+datasetname+"数据";
String fullname = systemid+"/操作能力/"+enode.getLabel()+"/"+datasetname;
PermissionNode dataSetNode = PermissionNode.builder()
.label(datasetname).type(PermissionType.OPPRIV).fullName(fullname).build()
.setUniKey(systemid,node.getDename()+"-search"+dataset.getId()+"-all");
enode.getChildren().add(dataSetNode);
});
if(node.getActions()!=null) {
node.getActions().forEach(action -> {
String actionname = action.getName();
if (action.getId().toUpperCase().equals("CREATE"))
actionname = "新建";
else if (action.getId().toUpperCase().equals("UPDATE"))
actionname = "修改";
else if (action.getId().toUpperCase().equals("REMOVE"))
actionname = "删除";
else if (action.getId().toUpperCase().equals("SAVE"))
actionname = "保存";
else if (action.getId().toUpperCase().equals("GET"))
actionname = "查看";
else if (action.getId().toUpperCase().equals("CHECKKEY") || action.getId().toUpperCase().equals("GETDRAFT") || action.getId().toUpperCase().indexOf("BATCH") > 0)
return;
if (node.getScopes() == null || node.getScopes().size() <= 1) {
String fullname = systemid+"/操作能力/"+enode.getLabel()+"/"+actionname+"任意数据";
enode.getChildren().add(
PermissionNode.builder()
.label(actionname).type(PermissionType.OPPRIV)
.fullName(fullname).build()
.setUniKey(systemid, node.getDename() + "-" + action.getId() + "-all"));
}
else {
PermissionNode actionNode = PermissionNode.builder()
.label(actionname).build()
.setUniKey(systemid, enode.getId() + "-" + action.getId());
final String preFullname = systemid+"/操作能力/"+enode.getLabel()+"/"+actionname;
node.getScopes().forEach(scope -> {
String scopename = scope.getName();
if (scope.getId().equals("all"))
scopename = "任意数据";
else if (scope.getId().equals("createman")) {
if (action.getId().toUpperCase().equals("CREATE"))
return;
scopename = "本人创建的数据";
}
else if (scope.getId().equals("curorg"))
scopename = "本单位的数据";
else if (scope.getId().equals("curorgdept"))
scopename = "本部门的数据";
else if (scope.getId().equals("sorg"))
scopename = "本单位及下辖全部单位数据";
else if (scope.getId().equals("curorgdept"))
scopename = "本部门及下辖部门的数据";
else
return;
actionNode.getChildren().add(
PermissionNode.builder()
.label(scopename).type(PermissionType.OPPRIV)
.fullName(preFullname+scopename).build()
.setUniKey(systemid, node.getDename() + "-" + action.getId() + "-" + scope.getId()));
});
enode.getChildren().add(actionNode);
}
});
}
}
moudlemap.values().forEach(moudle->root.getChildren().add(moudle));
break;
case UNIRES:
if(this.getUniResIds()!=null)
{
this.getUniResIds().forEach(uniRes->{
root.getChildren().add(PermissionNode.builder()
.label(uniRes.getUniresname()).type(PermissionType.UNIRES)
.fullName(systemid+"/自定义资源/"+uniRes.getUniresname()).build()
.setUniKey(systemid, uniRes.getUnirescode()));
});
}
break;
case APPMENU:
if(this.getApps()!=null)
{
this.getApps().forEach(app->{
if(app.getAppmenus()!=null)
{
app.getAppmenus().forEach(appmenu->{
PermissionNode appMenuNode = PermissionNode.builder()
.label("应用-"+app.getAppname()+"菜单-"+appmenu.getMenuname()).build()
.setUniKey(systemid, app.getAppid()+"-"+appmenu.getMenuid());
if(appmenu.getMenuitems()!=null)
{
appmenu.getMenuitems().forEach(item->{
appMenuNode.getChildren().add(loopMenuItem(app.getAppid(),appmenu.getMenuid(),systemid+"/菜单/"+app.getAppname()+appmenu.getMenuname(),item));
});
}
root.getChildren().add(appMenuNode);
});
}
});
}
break;
}
return root;
}
private PermissionNode loopMenuItem(String appId, String menuId, String fullName, FuncItem item)
{
fullName=fullName+"/"+item.getName();
PermissionNode itemNode = PermissionNode.builder().label(item.getName()).fullName(fullName).type(PermissionType.APPMENU).build().setUniKey(systemid,appId+"-"+menuId+"-"+item.getId());
if(item.getItems()!=null)
{
final String fname=fullName;
item.getItems().forEach(sub->{
itemNode.getChildren().add(loopMenuItem(appId,menuId,fname,sub));
});
}
return itemNode;
}
public List<DstApp> getSysApps(boolean web) {
List<DstApp> apps=new ArrayList<>();
if (this.getApps() == null)
return apps;
this.getApps().forEach(app-> {
DstApp sysApp = DstApp.builder()
.label(app.getAppname()).systemid(systemid).id(systemid.toLowerCase()+"-"+app.getAppid().toLowerCase()).build();
apps.add(sysApp);
});
return apps;
}
}
package cn.ibizlab.core.lite.extensions.filter;
import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import cn.ibizlab.util.filter.QueryWrapperContext;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
/**
* 关系型数据实体[MetaEntity] 查询条件对象
*/
@Slf4j
@Data
public class DbEntitySearchContext extends QueryWrapperContext<EntityObj> {
}
package cn.ibizlab.core.lite.extensions.mapping;
import cn.ibizlab.core.lite.domain.MetaEntity;
import cn.ibizlab.core.lite.extensions.domain.MetaEntityModel;
import cn.ibizlab.util.domain.MappingBase;
import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
@Mapper(componentModel = "spring", uses = {},implementationName="metaEntityModelMapping",
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface MetaEntityMapping extends MappingBase<MetaEntityModel, MetaEntity> {
}
package cn.ibizlab.core.lite.extensions.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class LayerMapping {
@JsonIgnore
@JSONField(serialize = false)
private DataModel selfDataModel;
@JsonIgnore
@JSONField(serialize = false)
public String getSelfPropertyName()
{
if(this.getSelfDataModel()!=null)
{
Property property=this.getSelfDataModel().getFactPorperty();
if(property!=null)
return property.getPropertyName();
}
return "";
}
@JsonIgnore
@JSONField(serialize = false)
public String getSelfPropertyEntity()
{
if(this.getSelfDataModel()!=null)
{
Property property=this.getSelfDataModel().getFactPorperty();
if(property!=null)
return property.getPropertyEntity();
}
return "";
}
@JSONField(ordinal = 1)
private String selfPropertyColumn;
@JsonIgnore
@JSONField(serialize = false)
public DataModel getParentDataModel()
{
if(this.getSelfDataModel()!=null)
return this.getSelfDataModel().getParentDataModel();
return null;
}
@JsonIgnore
@JSONField(serialize = false)
public String getParentPropertyName()
{
if(this.getParentDataModel()!=null)
{
Property property=this.getParentDataModel().getFactPorperty();
if(property!=null)
return property.getPropertyName();
}
return "";
}
@JsonIgnore
@JSONField(serialize = false)
public String getParentPropertyEntity()
{
if(this.getParentDataModel()!=null)
{
Property property=this.getParentDataModel().getObjectProperty(this.getParentPropertyName());
if(property!=null)
return property.getPropertyEntity();
}
return "";
}
@JSONField(ordinal = 2)
private String parentPropertyColumn;
@Override
public String toString() {
return "LayerMapping{" +
"selfPropertyName='" + getSelfPropertyName() + '\'' +
", selfPropertyEntity='" + getSelfPropertyEntity() + '\'' +
", selfPropertyColumn='" + getSelfPropertyColumn() + '\'' +
", parentPropertyName='" + getParentPropertyName() + '\'' +
", parentPropertyEntity='" + getParentPropertyEntity() + '\'' +
", parentPropertyColumn='" + getParentPropertyColumn() + '\'' +
"}\r\n";
}
}
package cn.ibizlab.core.lite.extensions.model;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class Model {
@JSONField(ordinal = 1)
private String id;
@JSONField(ordinal = 2)
private String name;
@JSONField(ordinal = 3)
private String system;
@JSONField(ordinal = 4)
private String factEntity;
@JSONField(ordinal = 5)
private DataModel model;
public static void main(String[] arg)
{
String jsonstr="{\"dataModelName\":\"T_TYYW_XJ_YSGS_AJ\",\"objectProperties\":[{\"propertyName\":\"T_TYYW_XJ_YSGS_AJ\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_XJ_YSGS_AJ\",\"propertyMappings\":[]},{\"propertyName\":\"T_TYYW_GG_AQZY\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_GG_AQZY\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_AJ\",\"joinPropertyColumn\":\"BMSAH\"}]},{\"propertyName\":\"AJ_YX_AJ\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"AJ_YX_AJ\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_AJ\",\"joinPropertyColumn\":\"BMSAH\"}]},{\"propertyName\":\"T_TYYW_GG_ZCHDJD\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_GG_ZCHDJD\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_AJ\",\"joinPropertyColumn\":\"BMSAH\"}]},{\"propertyName\":\"T_TYYW_GG_SPHDJD\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_GG_SPHDJD\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_AJ\",\"joinPropertyColumn\":\"BMSAH\"}]},{\"propertyName\":\"T_TYYW_GG_ZSCQQK\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_GG_ZSCQQK\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_AJ\",\"joinPropertyColumn\":\"BMSAH\"}]}],\"nestedDataModels\":[{\"dataModelName\":\"T_TYYW_XJ_YSGS_XYR\",\"objectProperties\":[{\"propertyName\":\"T_TYYW_XJ_YSGS_XYR\",\"system\":\"tyywplus\",\"propertyEntity\":\"T_TYYW_XJ_YSGS_XYR\",\"propertyMappings\":[]},{\"propertyName\":\"T_TYYW_GG_ZRRSJLS\",\"system\":\"tyywplus\",\"propertyEntity\":\"T_TYYW_GG_ZRRSJLS\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_XYR\",\"joinPropertyColumn\":\"BMSAH\"},{\"selfPropertyColumn\":\"ZRRBM\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_XYR\",\"joinPropertyColumn\":\"ZRRBM\"}]}],\"nestedDataModels\":[{\"dataModelName\":\"T_TYYW_GG_QZCSQK\",\"objectProperties\":[{\"propertyName\":\"T_TYYW_GG_QZCSQK\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_GG_QZCSQK\",\"propertyMappings\":[]}],\"nestedDataModels\":[],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"},{\"selfPropertyColumn\":\"ZRRBM\",\"parentPropertyColumn\":\"ZRRBM\"}]},{\"dataModelName\":\"T_TYYW_GG_LZCSQK\",\"objectProperties\":[{\"propertyName\":\"T_TYYW_GG_LZCSQK\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_GG_LZCSQK\",\"propertyMappings\":[]}],\"nestedDataModels\":[],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"},{\"selfPropertyColumn\":\"ZRRBM\",\"parentPropertyColumn\":\"ZRRBM\"}]}],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]},{\"dataModelName\":\"AJ_YX_SLRZ\",\"objectProperties\":[{\"propertyName\":\"AJ_YX_SLRZ\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"AJ_YX_SLRZ\",\"propertyMappings\":[]}],\"nestedDataModels\":[],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]},{\"dataModelName\":\"T_TYYW_GG_XSYJQK\",\"objectProperties\":[{\"propertyName\":\"T_TYYW_GG_XSYJQK\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_GG_XSYJQK\",\"propertyMappings\":[]}],\"nestedDataModels\":[],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]},{\"dataModelName\":\"T_TYYW_GG_JCJYQK\",\"objectProperties\":[{\"propertyName\":\"T_TYYW_GG_JCJYQK\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"T_TYYW_GG_JCJYQK\",\"propertyMappings\":[]}],\"nestedDataModels\":[],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}],\"layerMappings\":[]}";
JSONObject jo= JSON.parseObject(jsonstr);
DataModel model=JSONObject.toJavaObject(jo, DataModel.class);
System.out.println(JSONObject.toJSONString(model));
}
}
package cn.ibizlab.core.lite.extensions.model;
import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.ModelObj;
import cn.ibizlab.core.lite.extensions.util.LiteStorage;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class Property {
@JsonIgnore
@JSONField(serialize = false)
private DataModel ownerDataModel;
@JsonIgnore
@JSONField(serialize = false)
public DataModel getRootDataModel()
{
return this.getOwnerDataModel().getRootDataModel();
}
@JsonIgnore
@JSONField(serialize = false)
public Property getRootFactPorperty()
{
return this.getOwnerDataModel().getRootFactPorperty();
}
@JsonIgnore
@JSONField(serialize = false)
public Property getFactPorperty()
{
return this.getOwnerDataModel().getFactPorperty();
}
@JsonIgnore
@JSONField(serialize = false)
public int getLayerNo()
{
return this.getOwnerDataModel().getLayerNo();
}
@JSONField(ordinal = 1)
private String propertyName;
@JSONField(ordinal = 2)
private String system;
@JSONField(ordinal = 3)
private String propertyEntity;
@JSONField(ordinal = 4)
private LinkedHashSet<PropertyMapping> propertyMappings = new LinkedHashSet<>();
public void setPropertyMappings(LinkedHashSet<PropertyMapping> propertyMappings)
{
if(propertyMappings!=null)
{
propertyMappings.forEach(propertyMapping -> propertyMapping.setSelfProperty(this));
this.propertyMappings=propertyMappings;
}
}
@Override
public String toString() {
return "Property{" +
"propertyName='" + getPropertyName() + '\'' +
", system='" + getSystem() + '\'' +
", propertyEntity='" + getPropertyEntity() + '\'' +
", propertyMappings=" + getPropertyMappings() +
"}\r\n";
}
@JsonIgnore
@JSONField(serialize = false)
private EntityModel entityModel;
@JsonIgnore
@JSONField(serialize = false)
public synchronized EntityModel getEntityModel()
{
if(entityModel==null)
entityModel= LiteStorage.getLiteModelService().getProxyEntityModel(this.getSystem(),this.getPropertyEntity());
return entityModel;
}
public String lookup(List<ModelObj> modelObjList)
{
String sql="";
Set<String> conds= new LinkedHashSet<>();
if(propertyMappings.size()>0)
{
for(PropertyMapping mapping:propertyMappings){
if (!StringUtils.isEmpty(sql))
sql += ",";
sql += mapping.getSelfPropertyColumn();
}
for(ModelObj modelObj:modelObjList)
{
String condItem="";
for(PropertyMapping mapping:propertyMappings)
{
Object val=modelObj.getEntity(mapping.getJoinPropertyEntity()).get(mapping.getJoinPropertyColumn());
if(val instanceof String)
val="'"+val.toString()+"'";
if (!StringUtils.isEmpty(condItem))
condItem += ",";
condItem += val;
}
conds.add("("+condItem+")");
}
}
String cond="";
for(String val:conds)
{
if(!StringUtils.isEmpty(cond))
cond += ",";
cond += val;
}
return "("+sql+") in ("+cond+")";
}
}
package cn.ibizlab.core.lite.extensions.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class PropertyMapping {
@JsonIgnore
@JSONField(serialize = false)
private Property selfProperty;
@JsonIgnore
@JSONField(serialize = false)
public DataModel getSelfDataModel()
{
if(this.getSelfProperty()!=null)
return this.getSelfProperty().getOwnerDataModel();
return null;
}
@JsonIgnore
@JSONField(serialize = false)
public String getSelfPropertyName()
{
if(this.getSelfProperty()!=null)
return this.getSelfProperty().getPropertyName();
return "";
}
@JsonIgnore
@JSONField(serialize = false)
public String getSelfPropertyEntity()
{
if(this.getSelfProperty()!=null)
return this.getSelfProperty().getPropertyEntity();
return "";
}
@JSONField(ordinal = 1)
private String selfPropertyColumn;
@JSONField(ordinal = 2)
private String joinPropertyName;
public String getJoinPropertyName()
{
if(StringUtils.isEmpty(joinPropertyName))
{
Property property=this.getSelfDataModel().getFactPorperty();
if(property!=null)
return property.getPropertyName();
}
return joinPropertyName;
}
@JsonIgnore
@JSONField(serialize = false)
public String getJoinPropertyEntity()
{
if(this.getSelfDataModel()!=null)
{
Property property=this.getSelfDataModel().getObjectProperty(this.getJoinPropertyName());
if(property!=null)
return property.getPropertyEntity();
}
return "";
}
@JSONField(ordinal = 3)
private String joinPropertyColumn;
@Override
public String toString() {
return "PropertyMapping{" +
"selfPropertyName='" + getSelfPropertyName() + '\'' +
", selfPropertyEntity='" + getSelfPropertyEntity() + '\'' +
", selfPropertyColumn='" + getSelfPropertyColumn() + '\'' +
", joinPropertyName='" + getJoinPropertyName() + '\'' +
", joinPropertyEntity='" + getJoinPropertyEntity() + '\'' +
", joinPropertyColumn='" + getJoinPropertyColumn() + '\'' +
"}\r\n";
}
}
package cn.ibizlab.core.lite.extensions.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.ObjectUtils;
import java.util.LinkedHashSet;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class TmpModel {
@JSONField(ordinal = 3)
private String id;
@JSONField(ordinal = 1)
private String factEntity;
@JSONField(ordinal = 2)
private String factEntityName;
@JSONField(ordinal = 4)
private LinkedHashSet<String> tables;
@JSONField(ordinal = 5)
private LinkedHashSet<ReleationModel> releations = new LinkedHashSet<>();
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public static class ReleationModel
{
@JSONField(ordinal = 1)
private String entity;
@JSONField(ordinal = 3)
private String entityName;
@JSONField(ordinal = 2)
private String refEntity;
@JSONField(ordinal = 4)
private String refEntityName;
@JSONField(ordinal = 5)
private LinkedHashSet<LookupModel> lookups;
}
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public static class LookupModel
{
@JSONField(ordinal = 1)
private String field;
@JSONField(ordinal = 2)
private String refField;
}
@JsonIgnore
@JSONField(serialize = false)
public DataModel getDataModels()
{
DataModel dataModel=new DataModel();
dataModel.setDataModelName(this.getFactEntity());
Property property = new Property();
property.setOwnerDataModel(dataModel);
property.setPropertyEntity(this.getFactEntity());
property.setPropertyName(this.getFactEntity());
property.setSystem("tyyw2plus");
tables.remove(this.getFactEntity());
dataModel.getObjectProperties().add(property);
getPropertyByEntity(dataModel).forEach(item -> dataModel.getObjectProperties().add(item));
dataModel.setNestedDataModels(getDataModelsByParent(dataModel));
return dataModel;
}
public LinkedHashSet<DataModel> getDataModelsByParent(DataModel parentEntity)
{
LinkedHashSet<DataModel> list = new LinkedHashSet<>();
this.getReleations().forEach(releationModel -> {
if(releationModel.getRefEntity().equalsIgnoreCase(parentEntity.getDataModelName()))
{
DataModel dataModel=new DataModel();
dataModel.setDataModelName(releationModel.getEntity());
LinkedHashSet<LayerMapping> layerMappings = new LinkedHashSet<>();
releationModel.getLookups().forEach(lookupModel -> {
LayerMapping layerMapping = new LayerMapping();
layerMapping.setSelfPropertyColumn(lookupModel.getField());
layerMapping.setParentPropertyColumn(lookupModel.getRefField());
layerMappings.add(layerMapping);
});
Property property = new Property();
property.setOwnerDataModel(dataModel);
property.setPropertyEntity(releationModel.getEntity());
property.setPropertyName(releationModel.getEntity());
property.setSystem("tyyw2plus");
tables.remove(releationModel.getEntity());
dataModel.getObjectProperties().add(property);
dataModel.setLayerMappings(layerMappings);
dataModel.setParentDataModel(parentEntity);
getPropertyByEntity(dataModel).forEach(item -> dataModel.getObjectProperties().add(item));
LinkedHashSet<DataModel> nestedDataModels = getDataModelsByParent(dataModel);
if(!ObjectUtils.isEmpty(nestedDataModels))
dataModel.setNestedDataModels(nestedDataModels);
list.add(dataModel);
}
});
return list;
}
public LinkedHashSet<Property> getPropertyByEntity(DataModel dataModel)
{
LinkedHashSet<Property> list = new LinkedHashSet<>();
this.getReleations().forEach(releationModel -> {
if (releationModel.getEntity().equalsIgnoreCase(dataModel.getFactPorperty().getPropertyEntity())) {
if(dataModel.getParentDataModel()!=null&&dataModel.getParentDataModel().getDataModelName().equalsIgnoreCase(releationModel.getRefEntity()))
return;
Property property = new Property();
property.setOwnerDataModel(dataModel);
property.setPropertyEntity(releationModel.getRefEntity());
property.setPropertyName(releationModel.getRefEntity());
property.setSystem("tyyw2plus");
tables.remove(releationModel.getRefEntity());
releationModel.getLookups().forEach(lookupModel -> {
PropertyMapping propertyMapping = new PropertyMapping();
propertyMapping.setSelfPropertyColumn(lookupModel.getRefField());
propertyMapping.setSelfProperty(property);
propertyMapping.setJoinPropertyColumn(lookupModel.getField());
propertyMapping.setJoinPropertyName(releationModel.getEntity());
property.getPropertyMappings().add(propertyMapping);
});
dataModel.getObjectProperties().add(property);
}
});
return list;
}
}
package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import cn.ibizlab.core.lite.extensions.domain.ModelObj;
import cn.ibizlab.util.filter.QueryFilter;
import java.sql.Timestamp;
import java.util.List;
public interface CommonEntityService {
List<EntityObj> selectBase(EntityModel entityModel, QueryFilter filter);
List<EntityObj> selectCore(EntityModel entityModel, QueryFilter filter);
List<EntityObj> search(String dataSet, EntityModel entityModel, QueryFilter filter);
List<EntityObj> search(String dsName, String sql, QueryFilter filter);
List<ModelObj> getModelObjs(String metaModelId, Timestamp lastModify);
ModelObj getModelObjs(String metaModelId, Object factKey);
ModelObj getModelObjs(String metaModelId, Object... factUniKey);
List<ModelObj> getModelObjs(String metaModelId, List<EntityObj> kEntityObjs);
}
package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.extensions.mapper.DbEntityMapper;
import cn.ibizlab.core.extensions.service.DstDataSourceExService;
import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import cn.ibizlab.core.lite.extensions.domain.FieldModel;
import cn.ibizlab.core.lite.extensions.domain.ModelObj;
import cn.ibizlab.core.lite.extensions.filter.DbEntitySearchContext;
import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.core.lite.extensions.model.Property;
import cn.ibizlab.core.lite.service.IMetaModelService;
import cn.ibizlab.util.filter.QueryFilter;
import com.alibaba.fastjson.JSON;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Service
@Primary
@Slf4j
public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> implements CommonEntityService{
@Autowired
private DstDataSourceExService dstDataSourceService;
@Override
public List<EntityObj> selectBase(EntityModel entityModel, QueryFilter filter) {
return search("BASE",entityModel,filter);
}
@Override
public List<EntityObj> selectCore(EntityModel entityModel, QueryFilter filter) {
return search("CORE",entityModel,filter);
}
@Override
public List<EntityObj> search(String dataSet, EntityModel entityModel, QueryFilter filter) {
String sql=entityModel.getSqlSegment(dataSet);
if(StringUtils.isEmpty(sql))
return new ArrayList<>();
else
return search(entityModel.getDsName(),sql,filter);
}
@Override
public List<EntityObj> search(String dsName, String sql, QueryFilter filter) {
try
{
dstDataSourceService.initDataSource(dsName);
DynamicDataSourceContextHolder.push(dsName);
DbEntitySearchContext context=new DbEntitySearchContext();
context.setFilter(filter);
QueryWrapper qw=context.getSelectCond();
if(!StringUtils.isEmpty(filter.getCustSqlSegment()))
qw.apply(filter.getCustSqlSegment());
return baseMapper.search(sql,qw);
}
catch(Exception ex)
{
log.error("详细错误信息:" + ex.getMessage() + ", 执行sql:" + sql);
return null;
}
finally
{
DynamicDataSourceContextHolder.poll();
}
}
@Autowired
private IMetaModelService metaModelService;
@Autowired
private LiteModelService liteModelService;
@Override
public List<ModelObj> getModelObjs(String metaModelId, Timestamp lastModify)
{
DataModel dataModel= JSON.toJavaObject(JSON.parseObject(metaModelService.get(metaModelId).getConfig()), DataModel.class);
EntityModel entityModel=dataModel.getFactEntityModel();
FieldModel lastModifyField=entityModel.getLastModifyField();
QueryFilter filter=new QueryFilter();
if(lastModifyField!=null)
filter.ge(lastModifyField.getColumnName(), lastModify);
List<EntityObj> kEntityObjs=this.selectCore(entityModel, filter);
return getModelObjs(dataModel,kEntityObjs);
}
@Override
public ModelObj getModelObjs(String metaModelId, Object factKey)
{
DataModel dataModel= JSON.toJavaObject(JSON.parseObject(metaModelService.get(metaModelId).getConfig()), DataModel.class);
List<EntityObj> kEntityObjs = new ArrayList<>();
kEntityObjs.add(new EntityObj().set(dataModel.getFactEntityModel().getKeyField().getColumnName(),factKey));
List<ModelObj> list = getModelObjs(dataModel,kEntityObjs);
if(list.size()>0)
return list.get(0);
return null;
}
@Override
public ModelObj getModelObjs(String metaModelId, Object... factUniKey)
{
DataModel dataModel= JSON.toJavaObject(JSON.parseObject(metaModelService.get(metaModelId).getConfig()), DataModel.class);
List<EntityObj> kEntityObjs = new ArrayList<>();
EntityObj entityObj = new EntityObj();
List<FieldModel> uniKeys = dataModel.getFactEntityModel().getUnionKeyFields();
for(int i=0;i<uniKeys.size();i++)
entityObj.set(uniKeys.get(i).getColumnName(),factUniKey[i]);
kEntityObjs.add(entityObj);
List<ModelObj> list = getModelObjs(dataModel,kEntityObjs);
if(list.size()>0)
return list.get(0);
return null;
}
@Override
public List<ModelObj> getModelObjs(String metaModelId, List<EntityObj> kEntityObjs)
{
DataModel dataModel= JSON.toJavaObject(JSON.parseObject(metaModelService.get(metaModelId).getConfig()), DataModel.class);
return getModelObjs(dataModel,kEntityObjs);
}
public List<ModelObj> getModelObjs(DataModel dataModel, List<EntityObj> kEntityObjs)
{
EntityModel entityModel=dataModel.getFactEntityModel();
List<ModelObj> rt=new ArrayList<>();
List<EntityObj> factEntityList = this.selectBase(entityModel, QueryFilter.createQuery().cust(dataModel.lookup(kEntityObjs)));
factEntityList.forEach(entityObj->
rt.add(new ModelObj().setDataModel(dataModel).setFactEntity(entityObj.setProperty(dataModel.getFactPorperty()))));
fillEntityObj(dataModel,rt);
dataModel.getNestedDataModels().forEach(subModel->
this.getModelObjs(subModel, factEntityList).forEach(subObj->subObj.findParent(rt)));
rt.forEach(modelObj -> modelObj.getTimestamp());
return rt;
}
public void fillEntityObj(DataModel dataModel, List<ModelObj> modelObjs)
{
if(dataModel.getObjectProperties().size()>1)
{
for(Property property:dataModel.getObjectProperties())
{
if(property.getPropertyName().equals(dataModel.getFactPorperty().getPropertyName()))
continue;
EntityModel entityModel=property.getEntityModel();
List<EntityObj> entityObjs = this.selectBase(entityModel, QueryFilter.createQuery().cust(property.lookup(modelObjs)));
entityObjs.forEach(entityObj -> {
entityObj.setProperty(property);
entityObj.findModel(modelObjs);
});
}
}
}
}
package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.lite.domain.DstApp;
import cn.ibizlab.core.lite.domain.DstSystem;
import cn.ibizlab.core.lite.extensions.domain.PermissionType;
import cn.ibizlab.core.lite.filter.DstAppSearchContext;
import cn.ibizlab.core.lite.service.IDstSystemService;
import cn.ibizlab.core.lite.service.impl.DstAppServiceImpl;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.service.IBZConfigService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.*;
@Primary
@Service
public class DstAppService extends DstAppServiceImpl
{
@Autowired
private IDstSystemService sysPSSystemService;
@Autowired
private LiteModelService liteModelService;
@Override
public DstApp get(String key)
{
String systemId=key.split("-")[0];
DstSystem sysPSSystem=sysPSSystemService.getById(systemId);
if(sysPSSystem!=null&&sysPSSystem.getApps()!=null)
{
for(DstApp app:sysPSSystem.getApps())
{
if(app.getId().equals(key))
return app;
}
}
return null;
}
@Override
public boolean save(DstApp et)
{
if(StringUtils.isEmpty(et.getSystemid())||StringUtils.isEmpty(et.getId()))
throw new BadRequestAlertException("应用参数缺失","DstApp",et.getId());
DstSystem sysPSSystem=sysPSSystemService.getById(et.getSystemid());
if(sysPSSystem!=null&&sysPSSystem.getApps()!=null)
{
boolean bchange=false;
for(DstApp app:sysPSSystem.getApps())
{
if(app.getId().equals(et.getId()))
{
CachedBeanCopier.copy(et,app);
bchange=true;
break;
}
}
sysPSSystem.set("ignoreSyncPermission",true);
if(bchange) {
sysPSSystemService.update(sysPSSystem);
liteModelService.resetApps();
}
}
return true;
}
@Override
public boolean update(DstApp et)
{
return this.save(et);
}
@Override
public boolean create(DstApp et)
{
return this.save(et);
}
@Override
public Page<DstApp> searchDefault(DstAppSearchContext context)
{
context.setSize(Integer.MAX_VALUE);
List<DstApp> content = new ArrayList<>();
LinkedHashMap<String,DstApp> map = liteModelService.getApps();
map.values().forEach(sysApp -> {
if(!StringUtils.isEmpty(context.getN_pssystemid_eq())) {
if(!sysApp.getSystemid().equals(context.getN_pssystemid_eq()))
return;
}
if(!StringUtils.isEmpty(context.getN_appname_like())) {
if(sysApp.getLabel().indexOf(context.getN_appname_like())<0 &&
sysApp.getFullname().indexOf(context.getN_appname_like())<0)
return;
}
if(!StringUtils.isEmpty(context.getN_apptype_eq())) {
if(context.getN_apptype_eq().equalsIgnoreCase(sysApp.getType()))
return;
}
content.add(sysApp);
});
return new PageImpl<DstApp>(content,context.getPageable(),content.size());
}
@Override
public List<DstApp> selectBySystemid(String pssystemid) {
DstSystem system = sysPSSystemService.getById(pssystemid);
if (system.getSysstructure() == null)
{
return new ArrayList<>();
}
if (system.getApps() == null)
{
return system.getSysstructure().getSysApps(true);
}
return new ArrayList<>();
}
}
package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.lite.domain.*;
import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.FieldModel;
import cn.ibizlab.core.lite.extensions.domain.RelationshipModel;
import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.core.lite.extensions.util.LiteStorage;
import cn.ibizlab.core.lite.filter.MetaEntitySearchContext;
import cn.ibizlab.core.lite.filter.MetaFieldSearchContext;
import cn.ibizlab.core.lite.service.*;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import javax.annotation.PostConstruct;
import java.sql.Wrapper;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Service
public class LiteModelService {
@PostConstruct
public void init(){
LiteStorage.setLiteModelService(this);
}
@Autowired
@Lazy
private IMetaEntityService metaEntityService;
public IMetaEntityService getMetaEntityService()
{
return metaEntityService;
}
@Autowired
@Lazy
private IMetaFieldService metaFieldService;
@Autowired
@Lazy
private IMetaRelationshipService metaRelationshipService;
@Autowired
@Lazy
private IDstDataSourceService dstDataSourceService;
@Autowired
@Lazy
private IMetaDataSetService metaDataSetService;
@Autowired
@Lazy
private LiteModelService proxyService;
public List<EntityModel> getEntityModel(String systemId)
{
List<EntityModel> list = new ArrayList<>();
metaEntityService.list(Wrappers.<MetaEntity>lambdaQuery().eq(MetaEntity::getSystemId,systemId).orderByAsc(MetaEntity::getEntityName)).forEach(entity -> {
EntityModel entityModel = new EntityModel();
entityModel.setEntity(entity);
list.add(entityModel);
});
return list;
}
public EntityModel getProxyEntityModel(String systemId, String name)
{
return proxyService.getEntityModel(systemId,name);
}
@Cacheable( value="entitymodel",key = "'row:'+#p0+'.'+#p1")
public EntityModel getEntityModel(String systemId, String name)
{
MetaEntity entity = LiteStorage.getMetaEntity(String.format("%1$s.%2$s",systemId,name));
EntityModel entityModel = new EntityModel();
entityModel.setEntity(entity);
entityModel.setDataSets(metaDataSetService.selectByEntityId(entity.getEntityId()));
Map<String, RelationshipModel> parentSet = new LinkedHashMap();
List<RelationshipModel> references = new ArrayList<>();
metaRelationshipService.selectByEntityId(entity.getEntityId()).forEach(item->
{
RelationshipModel model = new RelationshipModel();
MetaEntity parentEntity = LiteStorage.getMetaEntity(item.getRefEntityId());
if(parentEntity!=null){
model.setCodeName(item.getCodeName());
model.setDataSourceName(parentEntity.getDsName());
model.setEntityCodeName(parentEntity.getCodeName());
model.setEntityId(parentEntity.getEntityId());
model.setEntityLogicName(parentEntity.getLogicName());
model.setEntityName(parentEntity.getEntityName());
model.setSystemId(parentEntity.getSystemId());
model.setTableName(parentEntity.getTableName());
parentSet.put(item.getId(),model);
references.add(model);
}
});
entityModel.setReferences(references);
List<RelationshipModel> nesteds = new ArrayList<>();
metaRelationshipService.selectByRefEntityId(entity.getEntityId()).forEach(item->
{
RelationshipModel model = new RelationshipModel();
MetaEntity subEntity = LiteStorage.getMetaEntity(item.getEntityId());
if(subEntity!=null){
model.setCodeName(StringUtils.isEmpty(item.getNestedName())?item.getCodeName()+"_"+item.getEntityName():item.getNestedName());
model.setDataSourceName(subEntity.getDsName());
model.setEntityCodeName(subEntity.getCodeName());
model.setEntityId(subEntity.getEntityId());
model.setEntityLogicName(subEntity.getLogicName());
model.setEntityName(subEntity.getEntityName());
model.setSystemId(subEntity.getSystemId());
model.setTableName(subEntity.getTableName());
nesteds.add(model);
}
});
entityModel.setNesteds(nesteds);
List<FieldModel> fields = new ArrayList<>();
MetaFieldSearchContext searchContext = new MetaFieldSearchContext();
searchContext.setN_entityid_eq(entity.getEntityId());
searchContext.getSelectCond().orderByAsc("showorder");
searchContext.setSize(Integer.MAX_VALUE);
metaFieldService.searchDefault(searchContext).getContent().forEach(item->
{
FieldModel model = new FieldModel();
model.setField(item);
model.setCodeName(item.getCodeName());
model.setColumnName(item.getFieldName());
model.setComment(item.getFieldLogicName());
model.setShowName(item.getFieldShowName());
model.setUnionName(item.getFieldUniName());
if((!StringUtils.isEmpty(item.getRelationId()))&&(parentSet.containsKey(item.getRelationId())))
model.setReference(parentSet.get(item.getRelationId()));
fields.add(model);
});
entityModel.setFields(fields);
return entityModel;
}
@CacheEvict( value="entitymodel",key = "'row:'+#p0+'.'+#p1")
public void resetEntityModel(String systemId, String name)
{
LiteStorage.resetMetaEntity(String.format("%1$s.%2$s",systemId,name));
}
public void initMetaEntity()
{
metaEntityService.list().forEach(metaEntity -> {
LiteStorage.putMetaEntity(metaEntity);
});
}
@Autowired
@Lazy
private IMetaModelService metaModelService;
public DataModel getDataModel(String dataModelId)
{
return JSON.toJavaObject(JSON.parseObject(metaModelService.get(dataModelId).getConfig()),DataModel.class);
}
public DataModel getDataModel(String rootDataModelId,String subDataModelName)
{
DataModel dataModel=getDataModel(rootDataModelId);
if(StringUtils.isEmpty(subDataModelName))
return dataModel;
return dataModel.findDataModel(subDataModelName,"ALL");
}
@Autowired
@Lazy
private IDstSystemService dstSystemService;
@Cacheable( value="syspssystem",key = "'row:all-dst-apps'")
public LinkedHashMap<String, DstApp> getApps() {
LinkedHashMap<String,DstApp> appNode=new LinkedHashMap<>();
dstSystemService.list().forEach(system -> {
if (system.getSysstructure() == null)
{
return;
}
if (system.getApps() == null)
{
system.setApps(system.getSysstructure().getSysApps(true));
dstSystemService.update(system);
}
system.getApps().forEach(app-> {
appNode.put(app.getId(),app);
});
});
return appNode;
}
@Caching( evict = {
@CacheEvict( value="syspssystem",key = "'row:all-apps'"),
@CacheEvict( value="syspssystem",key = "'row:all-dst-apps'"),
@CacheEvict( value="syspssystem",key = "'row:all-dst-sys-apps'")
})
public void resetApps()
{
}
@Cacheable( value="syspssystem",key = "'row:sys-dst-sys-apps'")
public List<DstSystem> getSysApp()
{
List<DstSystem> list = new ArrayList<>();
dstSystemService.list().forEach(system -> {
if (system.getSysstructure() == null)
{
return;
}
if (system.getApps() == null)
{
system.setApps(system.getSysstructure().getSysApps(true));
}
system.setSysstructure(null);
list.add(system);
});
return list;
}
}
package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import cn.ibizlab.core.lite.extensions.domain.ModelObj;
import cn.ibizlab.util.filter.QueryFilter;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.List;
@Service
public class MongoEntityService implements CommonEntityService{
@Override
public List<EntityObj> selectBase(EntityModel entityModel, QueryFilter filter) {
return null;
}
@Override
public List<EntityObj> selectCore(EntityModel entityModel, QueryFilter filter) {
return null;
}
@Override
public List<EntityObj> search(String dataSet, EntityModel entityModel, QueryFilter filter) {
return null;
}
@Override
public List<EntityObj> search(String dsName, String sql, QueryFilter filter) {
return null;
}
@Override
public List<ModelObj> getModelObjs(String metaModelId, Timestamp lastModify) {
return null;
}
@Override
public ModelObj getModelObjs(String metaModelId, Object factKey) {
return null;
}
@Override
public ModelObj getModelObjs(String metaModelId, Object... factUniKey) {
return null;
}
@Override
public List<ModelObj> getModelObjs(String metaModelId, List<EntityObj> kEntityObjs) {
return null;
}
}
package cn.ibizlab.core.lite.extensions.util;
import cn.ibizlab.core.lite.domain.MetaEntity;
import cn.ibizlab.core.lite.extensions.service.LiteModelService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import java.util.HashMap;
import java.util.Map;
public class LiteStorage {
private static Map<String, MetaEntity> metaEntityStorage= new HashMap<String, MetaEntity>();
private static Object entityLock=new Object();
public static Map<String, MetaEntity> putMetaEntity(MetaEntity metaEntity)
{
synchronized (entityLock)
{
metaEntityStorage.put(metaEntity.getEntityId(),metaEntity);
metaEntityStorage.put(String.format("%1$s.%2$s",metaEntity.getSystemId(),metaEntity.getEntityName()),metaEntity);
metaEntityStorage.put(String.format("%1$s.%2$s",metaEntity.getSystemId(),metaEntity.getCodeName()),metaEntity);
return metaEntityStorage;
}
}
private static LiteModelService service;
public static void setLiteModelService(LiteModelService service)
{
if(LiteStorage.service==null)
LiteStorage.service=service;
}
public static LiteModelService getLiteModelService()
{
return service;
}
public static MetaEntity getMetaEntity(String name)
{
synchronized (entityLock)
{
if(metaEntityStorage.containsKey(name))
return metaEntityStorage.get(name);
else if(name.contains(".")) {
String[] args=name.split("[.]");
String systemId=args[0];
String code=args[1];
MetaEntity metaEntity = service.getMetaEntityService().getOne(Wrappers.<MetaEntity>lambdaQuery().and(
wrapper ->
wrapper.eq(MetaEntity::getSystemId,systemId)).and(
wrapper ->
wrapper.eq(MetaEntity::getEntityName,code).or().eq(MetaEntity::getCodeName,code))
,false);
if(metaEntity!=null) {
metaEntityStorage.put(metaEntity.getEntityId(),metaEntity);
metaEntityStorage.put(String.format("%1$s.%2$s",metaEntity.getSystemId(),metaEntity.getEntityName()),metaEntity);
metaEntityStorage.put(String.format("%1$s.%2$s",metaEntity.getSystemId(),metaEntity.getCodeName()),metaEntity);
return metaEntity;
}
}
else {
MetaEntity metaEntity = service.getMetaEntityService().getById(name);
if(metaEntity!=null) {
metaEntityStorage.put(metaEntity.getEntityId(),metaEntity);
metaEntityStorage.put(String.format("%1$s.%2$s",metaEntity.getSystemId(),metaEntity.getEntityName()),metaEntity);
metaEntityStorage.put(String.format("%1$s.%2$s",metaEntity.getSystemId(),metaEntity.getCodeName()),metaEntity);
return metaEntity;
}
}
}
return null;
}
public static void resetMetaEntity(String name)
{
MetaEntity metaEntity = getMetaEntity(name);
if(metaEntity!=null)
{
synchronized (entityLock)
{
metaEntityStorage.remove(metaEntity.getEntityId());
metaEntityStorage.remove(String.format("%1$s.%2$s",metaEntity.getSystemId(),metaEntity.getEntityName()));
metaEntityStorage.remove(String.format("%1$s.%2$s",metaEntity.getSystemId(),metaEntity.getCodeName()));
}
}
}
public static Map parseDatasource (String json) {
JSONArray tableData = JSONArray.parseArray(json);
Map map = new HashMap();
for (int i = 0; i < tableData.size(); i++) {
JSONObject jsonObject = tableData.getJSONObject(i);
map.put(jsonObject.get("param"), jsonObject.get("value"));
}
return map;
}
}
<?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="cn.ibizlab.core.extensions.mapper.DbEntityMapper">
<!--数据集合[Default]-->
<select id="search" parameterType="cn.ibizlab.core.lite.extensions.filter.DbEntitySearchContext" resultType="cn.ibizlab.core.lite.extensions.domain.EntityObj">
${sql}
<where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
</mapper>
......@@ -7,18 +7,12 @@
<select id="selectById" resultMap="DstSystemResultMap" databaseId="mysql">
<![CDATA[select t1.* from (SELECT t1.`APPS`, t1.`MD5CHECK`, t1.`PSSYSTEMID`, t1.`PSSYSTEMNAME`, t1.`SHOWORDER`, t1.`SYSSTRUCTURE` FROM `IBZPSSYSTEM` t1 ) t1 where pssystemid=#{id}]]>
</select>
<select id="selectById" resultMap="DstSystemResultMap" databaseId="oracle">
<![CDATA[select t1.* from (SELECT t1.APPS, t1.MD5CHECK, t1.PSSYSTEMID, t1.PSSYSTEMNAME, t1.SHOWORDER, t1.SYSSTRUCTURE FROM IBZPSSYSTEM t1 ) t1 where pssystemid=#{id}]]>
</select>
<select id="selectById" resultMap="DstSystemResultMap" databaseId="postgresql">
<![CDATA[select t1.* from (SELECT t1.APPS, t1.MD5CHECK, t1.PSSYSTEMID, t1.PSSYSTEMNAME, t1.SHOWORDER, t1.SYSSTRUCTURE FROM IBZPSSYSTEM t1 ) t1 where pssystemid=#{id}]]>
</select>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="DstSystemResultMap" type="cn.ibizlab.core.lite.domain.DstSystem" autoMapping="true">
<id property="pssystemid" column="pssystemid" /><!--主键字段映射-->
<result column="sysstructure" jdbcType="VARCHAR" property="sysstructure" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" />
<result property="apps" column="apps" typeHandler="cn.ibizlab.core.lite.domain.handlers.DstAppTypeHandler" />
</resultMap>
......@@ -36,29 +30,22 @@
<![CDATA[ SELECT t1.`MD5CHECK`, t1.`PSSYSTEMID`, t1.`PSSYSTEMNAME`, t1.`SHOWORDER`, t1.`SYSSTRUCTURE` FROM `IBZPSSYSTEM` t1
]]>
</sql>
<!--数据查询[Default]-->
<sql id="Default" databaseId="oracle">
<![CDATA[ SELECT t1.MD5CHECK, t1.PSSYSTEMID, t1.PSSYSTEMNAME, t1.SHOWORDER, t1.SYSSTRUCTURE FROM IBZPSSYSTEM t1
]]>
</sql>
<!--数据查询[Default]-->
<sql id="Default" databaseId="postgresql">
<![CDATA[ SELECT t1.MD5CHECK, t1.PSSYSTEMID, t1.PSSYSTEMNAME, t1.SHOWORDER, t1.SYSSTRUCTURE FROM IBZPSSYSTEM t1
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="mysql">
<![CDATA[ SELECT t1.`APPS`, t1.`MD5CHECK`, t1.`PSSYSTEMID`, t1.`PSSYSTEMNAME`, t1.`SHOWORDER`, t1.`SYSSTRUCTURE` FROM `IBZPSSYSTEM` t1
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="oracle">
<![CDATA[ SELECT t1.APPS, t1.MD5CHECK, t1.PSSYSTEMID, t1.PSSYSTEMNAME, t1.SHOWORDER, t1.SYSSTRUCTURE FROM IBZPSSYSTEM t1
<!--数据查询[Default]-->
<sql id="Default" databaseId="oracle">
<![CDATA[ SELECT t1.PSSYSTEMID, t1.PSSYSTEMNAME, t1.SYSSTRUCTURE, t1.APPS, t1.MD5CHECK, t1.SHOWORDER FROM IBZPSSYSTEM t1
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="postgresql">
<![CDATA[ SELECT t1.APPS, t1.MD5CHECK, t1.PSSYSTEMID, t1.PSSYSTEMNAME, t1.SHOWORDER, t1.SYSSTRUCTURE FROM IBZPSSYSTEM t1
<!--数据查询[Default]-->
<sql id="Default" databaseId="postgresql">
<![CDATA[ SELECT t1.PSSYSTEMID, t1.PSSYSTEMNAME, t1.SYSSTRUCTURE, t1.APPS, t1.MD5CHECK, t1.SHOWORDER FROM IBZPSSYSTEM t1
]]>
</sql>
</mapper>
......
......@@ -8,11 +8,11 @@ import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import java.math.BigDecimal;
import cn.ibizlab.core.lite.extensions.domain.SysModel;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.alibaba.fastjson.annotation.JSONField;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
......@@ -54,7 +54,7 @@ public class DstSystemDTO extends DTOBase implements Serializable {
@JSONField(name = "sysstructure")
@JsonProperty("sysstructure")
@Size(min = 0, max = 1048576, message = "内容长度必须小于等于[1048576]")
private String sysstructure;
private SysModel sysstructure;
/**
* 属性 [MD5CHECK]
......@@ -85,7 +85,7 @@ public class DstSystemDTO extends DTOBase implements Serializable {
/**
* 设置 [SYSSTRUCTURE]
*/
public void setSysstructure(String sysstructure){
public void setSysstructure(SysModel sysstructure){
this.sysstructure = sysstructure ;
this.modify("sysstructure",sysstructure);
}
......
package cn.ibizlab.api.rest.extensions;
import cn.ibizlab.core.dict.extensions.vo.Option;
import cn.ibizlab.core.lite.domain.DstSystem;
import 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.core.lite.extensions.service.DbEntityService;
import cn.ibizlab.core.lite.extensions.service.LiteModelService;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Api(tags = {"接口" })
@RestController("api-litecore")
@RequestMapping("")
public class DstCoreResource {
@Autowired
private LiteModelService liteModelService;
@Autowired
private DbEntityService dbEntityService;
@RequestMapping(method = RequestMethod.GET, value = "/dst/test/{modelid}")
public ResponseEntity<List<ModelObj>> getstr(@PathVariable(name="modelid",required = false) String modelid)
{
if(StringUtils.isEmpty(modelid))
modelid="dataModelff8080816a8b510c016a8c2f18b10001";
List<ModelObj> list=dbEntityService.getModelObjs(modelid, DataObject.getBeginDate());
return ResponseEntity.ok(list);
}
@RequestMapping(method = RequestMethod.GET, value = {"/dst/datamodels/{modelid}","/dst/datamodels/{modelid}/name/{modelname}"})
public ResponseEntity<DataModel> getDataModel(@PathVariable(name="modelid",required = false) String modelid,
@PathVariable(name="modelname",required = false) String modelname)
{
return ResponseEntity.ok(liteModelService.getDataModel(modelid,modelname));
}
@RequestMapping(method = RequestMethod.GET, value = {"/dst/datamodels/{modelid}/submodels","/dst/datamodels/{modelid}/name/{modelname}/submodels"})
public ResponseEntity<List<Option>> getDataModelSubModels(@PathVariable(name="modelid",required = false) String modelid,
@PathVariable(name="modelname",required = false) String modelname)
{
List<Option> list = new ArrayList<>();
liteModelService.getDataModel(modelid,modelname).getSubDataModel().forEach(dataModel -> list.add(new Option().setId(dataModel.getDataModelName()).setLabel(dataModel.getFactPorperty().getPropertyName())));
return ResponseEntity.ok(list);
}
@RequestMapping(method = RequestMethod.GET, value = {"/dst/datamodels/{modelid}/propertys","/dst/datamodels/{modelid}/name/{modelname}/propertys"})
public ResponseEntity<List<Option>> getDataModelParentProperty(@PathVariable(name="modelid",required = false) String modelid,
@PathVariable(name="modelname",required = false) String modelname)
{
List<Option> list = new ArrayList<>();
liteModelService.getDataModel(modelid,modelname).getParentProperty().forEach(property -> {
Option option = new Option().setId(property.getPropertyName()).setLabel(property.getEntityModel().getLogicName()+"["+property.getPropertyName()+"]");
list.add(option);
});
return ResponseEntity.ok(list);
}
@RequestMapping(method = RequestMethod.GET, value = {"/dst/datamodels/{modelid}/propertys/{propertyname}/fields","/dst/datamodels/{modelid}/name/{modelname}/propertys/{propertyname}/fields"})
public ResponseEntity<List<Option>> getDataModelParentField(@PathVariable(name="modelid",required = false) String modelid,
@PathVariable(name="modelname",required = false) String modelname,
@PathVariable(name="propertyname",required = false) String propertyname)
{
List<Option> list = new ArrayList<>();
Property property=liteModelService.getDataModel(modelid,modelname).findObjectProperty(propertyname,"UP");
property.getEntityModel().getFields().forEach(field -> {
Option option = new Option().setId(property.getPropertyName()+"."+field.getColumnName()).setLabel(field.getComment()+"["+field.getColumnName()+"]");
list.add(option);
});
return ResponseEntity.ok(list);
}
@RequestMapping(method = RequestMethod.GET, value = "/dst/{system}/entitys")
public ResponseEntity<List<EntityModel>> getEntityModel(@PathVariable("system") String system) {
return ResponseEntity.status(HttpStatus.OK).body(liteModelService.getEntityModel(system));
}
@RequestMapping(method = RequestMethod.GET, value = "/dst/{system}/entitys/{entity}")
public ResponseEntity<EntityModel> getEntityModel(@PathVariable("system") String system, @PathVariable("entity") String entity) {
return ResponseEntity.status(HttpStatus.OK).body(liteModelService.getEntityModel(system,entity));
}
@RequestMapping(method = RequestMethod.GET, value = "/dst/{system}/entitys/{entity}/fields")
public ResponseEntity<List<FieldModel>> getEntityModelFields(@PathVariable("system") String system, @PathVariable("entity") String entity) {
return ResponseEntity.status(HttpStatus.OK).body(liteModelService.getEntityModel(system,entity).getFields());
}
@RequestMapping(method = RequestMethod.GET, value = "/dst/{system}/entitys/{entity}/references")
public ResponseEntity<List<RelationshipModel>> getEntityModelReferences(@PathVariable("system") String system, @PathVariable("entity") String entity) {
return ResponseEntity.status(HttpStatus.OK).body(liteModelService.getEntityModel(system,entity).getReferences());
}
@RequestMapping(method = RequestMethod.GET, value = "/dst/{system}/entitys/{entity}/nesteds")
public ResponseEntity<List<RelationshipModel>> getEntityModelNesteds(@PathVariable("system") String system, @PathVariable("entity") String entity) {
return ResponseEntity.status(HttpStatus.OK).body(liteModelService.getEntityModel(system,entity).getNesteds());
}
@RequestMapping(method = RequestMethod.GET, value = "/dst/sysapps")
public ResponseEntity<List<DstSystem>> getSysApps() {
return ResponseEntity.status(HttpStatus.OK).body(liteModelService.getSysApp());
}
}
......@@ -124,6 +124,22 @@ public class QueryFilter {
}
@JsonIgnore
@Transient
private String custSqlSegment;
public QueryFilter cust(String custSqlSegment)
{
this.custSqlSegment=custSqlSegment;
return this;
}
@JsonIgnore
@Transient
public String getCustSqlSegment()
{
return this.custSqlSegment;
}
@Override
public String toString() {
return "QueryFilter{" +
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册