提交 22602345 编写于 作者: ibizdev's avatar ibizdev

zoo457790531 发布系统代码 [ibz-dst,应用]

上级 c530d2de
......@@ -233,6 +233,44 @@ mock.onPost(new RegExp(/^\/dabuilds\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).repl
return [status, data];
});
// ExportZip
mock.onPost(new RegExp(/^\/dabuilds\/?([a-zA-Z0-9\-\;]{0,35})\/exportzip$/)).reply((config: any) => {
console.groupCollapsed("实体:dabuild 方法: ExportZip");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['build_id'];
const matchArray:any = new RegExp(/^\/dabuilds\/([a-zA-Z0-9\-\;]{1,35})\/exportzip$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.build_id, tempValue.build_id));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['build_id'] == tempValue['build_id'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Run
mock.onPost(new RegExp(/^\/dabuilds\/?([a-zA-Z0-9\-\;]{0,35})\/run$/)).reply((config: any) => {
console.groupCollapsed("实体:dabuild 方法: Run");
......
......@@ -155,6 +155,34 @@ export default class DABuildServiceBase extends EntityService {
return res;
}
/**
* ExportZip接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DABuildServiceBase
*/
public async ExportZip(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().post(`/dabuilds/${context.dabuild}/exportzip`,data,isloading);
return res;
}
/**
* ExportZipBatch接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DABuildServiceBase
*/
public async ExportZipBatch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
return await Http.getInstance().post(`/dabuild/exportzipbatch`,tempData,isloading);
}
/**
* Run接口方法
*
......
......@@ -14,6 +14,10 @@ services:
memory: 400M
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
volumes:
- "nfs:/app/file"
......
......@@ -20,18 +20,17 @@
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_PATH}/ibzdst.%d{yyyy-MM-dd}.log</FileNamePattern>
<FileNamePattern>${LOG_PATH}/ibzdst.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件最大的大小-->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>100MB</MaxFileSize>
</triggeringPolicy>
</appender>
<!-- 日志输出级别 -->
<root level="INFO">
......
......@@ -34,6 +34,8 @@ public interface IDABuildService extends IService<DABuild> {
DABuild get(String key);
DABuild getDraft(DABuild et);
boolean checkKey(DABuild et);
DABuild exportZip(DABuild et);
boolean exportZipBatch(List<DABuild> etList);
DABuild run(DABuild et);
boolean runBatch(List<DABuild> etList);
boolean save(DABuild et);
......
......@@ -132,6 +132,22 @@ public class DABuildServiceImpl extends ServiceImpl<DABuildMapper, DABuild> impl
public boolean checkKey(DABuild et) {
return (!ObjectUtils.isEmpty(et.getBuildId())) && (!Objects.isNull(this.getById(et.getBuildId())));
}
@Override
@Transactional
public DABuild exportZip(DABuild et) {
//自定义代码
return et;
}
@Override
@Transactional
public boolean exportZipBatch(List<DABuild> etList) {
for(DABuild et : etList) {
exportZip(et);
}
return true;
}
@Override
@Transactional
public DABuild run(DABuild et) {
......
......@@ -21,6 +21,16 @@ public class DABuildExService extends DABuildServiceImpl {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
/**
* [ExportZip:导出Zip] 行为扩展:导出模型的Zip
* @param et
* @return
*/
@Override
@Transactional
public DABuild exportZip(DABuild et) {
return super.exportZip(et);
}
/**
* [Run:运行] 行为扩展
* @param et
......
......@@ -4,7 +4,7 @@
<!--输出实体[DA_BUILD]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-da_build-54-1">
<changeSet author="root" id="tab-da_build-58-1">
<createTable tableName="IBZDABUILD">
<column name="BUILDID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_DA_BUILD_BUILDID"/>
......@@ -32,7 +32,7 @@
<!--输出实体[DA_CHART]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-da_chart-22-2">
<changeSet author="root" id="tab-da_chart-22-2">
<createTable tableName="IBZDACHART">
<column name="CHARTID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_DA_CHART_CHARTID"/>
......@@ -54,7 +54,7 @@
<!--输出实体[DA_METRIC]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-da_metric-59-3">
<changeSet author="root" id="tab-da_metric-59-3">
<createTable tableName="IBZDAMETRIC">
<column name="DA_METRICID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_DA_METRIC_DA_METRICID"/>
......@@ -82,7 +82,7 @@
<!--输出实体[DA_REPORT]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-da_report-24-4">
<changeSet author="root" id="tab-da_report-24-4">
<createTable tableName="IBZDAREPORT">
<column name="REPORTID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_DA_REPORT_REPORTID"/>
......@@ -104,7 +104,7 @@
<!--输出实体[DST_DATASOURCE]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-dst_datasource-6-5">
<changeSet author="root" id="tab-dst_datasource-6-5">
<createTable tableName="IBZDATASOURCE">
<column name="DSID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_DST_DATASOURCE_DSID"/>
......@@ -120,7 +120,7 @@
<!--输出实体[DST_SYSTEM]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-dst_system-5-6">
<changeSet author="root" id="tab-dst_system-5-6">
<createTable tableName="IBZPSSYSTEM">
<column name="PSSYSTEMID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_DST_SYSTEM_PSSYSTEMID"/>
......@@ -140,7 +140,7 @@
<!--输出实体[RU_EXECLOG]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-ru_execlog-31-7">
<changeSet author="root" id="tab-ru_execlog-31-7">
<createTable tableName="IBZRULELOG">
<column name="RU_EXECLOGID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_RU_EXECLOG_RU_EXECLOGID"/>
......@@ -170,7 +170,7 @@
<!--输出实体[RU_EXECRESULT]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-ru_execresult-46-8">
<changeSet author="root" id="tab-ru_execresult-46-8">
<createTable tableName="IBZRULERESULT">
<column name="RU_EXECRESULTID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_RU_EXECRESULT_RU_EXECRESULT"/>
......@@ -210,7 +210,7 @@
<!--输出实体[META_DATASET]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-meta_dataset-2-9">
<changeSet author="root" id="tab-meta_dataset-2-9">
<createTable tableName="IBZDATASET">
<column name="DATASETID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_META_DATASET_DATASETID"/>
......@@ -232,7 +232,7 @@
<!--输出实体[META_ENTITY]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-meta_entity-13-10">
<changeSet author="root" id="tab-meta_entity-13-10">
<createTable tableName="IBZENTITY">
<column name="ENTITYID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_META_ENTITY_ENTITYID"/>
......@@ -264,7 +264,7 @@
<!--输出实体[META_FIELD]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-meta_field-7-11">
<changeSet author="root" id="tab-meta_field-7-11">
<createTable tableName="IBZFIELD">
<column name="FIELDID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_META_FIELD_FIELDID"/>
......@@ -328,7 +328,7 @@
<!--输出实体[META_MODEL]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-meta_model-18-12">
<changeSet author="root" id="tab-meta_model-18-12">
<createTable tableName="IBZMODEL">
<column name="MODELID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_META_MODEL_MODELID"/>
......@@ -354,7 +354,7 @@
<!--输出实体[META_MODULE]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-meta_module-7-13">
<changeSet author="root" id="tab-meta_module-7-13">
<createTable tableName="IBZMODULE">
<column name="MODULEID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_META_MODULE_MODULEID"/>
......@@ -372,7 +372,7 @@
<!--输出实体[META_RELATION]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-meta_relation-6-14">
<changeSet author="root" id="tab-meta_relation-6-14">
<createTable tableName="IBZRELATION">
<column name="RELATIONID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_META_RELATION_RELATIONID"/>
......@@ -404,7 +404,7 @@
<!--输出实体[RU_ENGINE]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-ru_engine-45-15">
<changeSet author="root" id="tab-ru_engine-45-15">
<createTable tableName="IBZRULEENGINE">
<column name="ENGINEID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_RU_ENGINE_ENGINEID"/>
......@@ -432,7 +432,7 @@
<!--输出实体[RU_ITEM]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-ru_item-77-16">
<changeSet author="root" id="tab-ru_item-77-16">
<createTable tableName="IBZRULE">
<column name="RULEID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_RU_ITEM_RULEID"/>
......@@ -469,7 +469,7 @@
<!--输出实体[DA_BUILD]外键关系 -->
<!--输出实体[DA_CHART]外键关系 -->
<!--输出实体[DA_METRIC]外键关系 -->
<changeSet author="a_A_5d9d78509" id="fk-da_metric-59-17">
<changeSet author="root" id="fk-da_metric-59-17">
<addForeignKeyConstraint baseColumnNames="BUILDID" baseTableName="IBZDAMETRIC" constraintName="DER1N_DA_METRIC_DA_BUILD_BUILD" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="BUILDID" referencedTableName="IBZDABUILD" validate="true"/>
</changeSet>
<!--输出实体[DA_REPORT]外键关系 -->
......
......@@ -8,7 +8,7 @@
"delogicname":"分析",
"sysmoudle":{"id":"ANALYSIS","name":"analysis"},
"dedataset":[{"id":"Default" , "name":"数据集"}],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Run" , "name":"运行" , "type":"USERCUSTOM" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"ExportZip" , "name":"导出Zip" , "type":"USERCUSTOM" },{"id":"Run" , "name":"运行" , "type":"USERCUSTOM" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"datascope":[{"id":"all","name":"全部数据"}]
}
, {
......
......@@ -261,6 +261,7 @@
<version>${baomidou-jobs.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
......@@ -344,14 +345,12 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- mp动态数据源 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
......
......@@ -14,6 +14,10 @@ services:
memory: 400M
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
volumes:
- "nfs:/app/file"
......
......@@ -120,6 +120,23 @@ public class DABuildResource {
return ResponseEntity.status(HttpStatus.OK).body(dabuildService.checkKey(dabuildMapping.toDomain(dabuilddto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DABuild-ExportZip-all')")
@ApiOperation(value = "导出Zip", tags = {"分析" }, notes = "导出Zip")
@RequestMapping(method = RequestMethod.POST, value = "/dabuilds/{dabuild_id}/exportzip")
public ResponseEntity<DABuildDTO> exportZip(@PathVariable("dabuild_id") String dabuild_id, @RequestBody DABuildDTO dabuilddto) {
DABuild domain = dabuildMapping.toDomain(dabuilddto);
domain.setBuildId(dabuild_id);
domain = dabuildService.exportZip(domain);
dabuilddto = dabuildMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dabuilddto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DABuild-ExportZip-all')")
@ApiOperation(value = "批量处理[导出Zip]", tags = {"分析" }, notes = "批量处理[导出Zip]")
@RequestMapping(method = RequestMethod.POST, value = "/dabuilds/{dabuild_id}/exportzipbatch")
public ResponseEntity<Boolean> exportZipBatch(@RequestBody List<DABuildDTO> dabuilddtos) {
return ResponseEntity.status(HttpStatus.OK).body(dabuildService.exportZipBatch(dabuildMapping.toDomain(dabuilddtos)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-DABuild-Run-all')")
@ApiOperation(value = "运行", tags = {"分析" }, notes = "运行")
@RequestMapping(method = RequestMethod.POST, value = "/dabuilds/{dabuild_id}/run")
......
......@@ -13,6 +13,7 @@ import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.DigestUtils;
import java.io.InputStream;
import java.util.*;
......@@ -25,72 +26,73 @@ import java.util.*;
@ConditionalOnProperty( name = "ibiz.enablePermissionValid", havingValue = "true")
public class PermissionSyncJob implements ApplicationRunner {
@Autowired
@Lazy
private IBZUAAFeignClient client;
@Value("${ibiz.systemid:ibzdst}")
private String systemId;
@Value("${ibiz.systemname:ibzdst}")
private String systemName;
@Autowired
@Lazy
private IBZUAAFeignClient uaaClient;
@Autowired
@Lazy
IBZLiteFeignClient liteFeignClient;
IBZLiteFeignClient liteClient;
@Autowired
@Lazy
cn.ibizlab.util.client.IBZDictFeignClient dictFeignClient;
cn.ibizlab.util.client.IBZDictFeignClient dictClient;
@Override
public void run(ApplicationArguments args) {
try {
Thread.sleep(10000);
InputStream permission = this.getClass().getResourceAsStream("/permission/systemResource.json"); //获取当前系统所有实体资源能力
String permissionResult = IOUtils.toString(permission,"UTF-8");
JSONObject system= new JSONObject();
system.put("pssystemid",systemId);
system.put("pssystemname",systemName);
system.put("sysstructure",JSONObject.parseObject(permissionResult));
system.put("md5check",DigestUtils.md5DigestAsHex(permissionResult.getBytes()));
if(client.syncSysAuthority(system)) {
log.info("向[UAA]同步系统资源成功");
}else{
log.error("向[UAA]同步系统资源失败");
InputStream permission = this.getClass().getResourceAsStream("/permission/systemResource.json"); //权限资源
if (!ObjectUtils.isEmpty(permission)) {
String strPermission = IOUtils.toString(permission, "UTF-8");
JSONObject system = new JSONObject() {{
put("pssystemid", systemId);
put("pssystemname", systemName);
put("sysstructure", JSONObject.parseObject(strPermission));
put("md5check", DigestUtils.md5DigestAsHex(strPermission.getBytes()));
}};
if (uaaClient.syncSysAuthority(system)) {
log.info("向[uaa]同步系统资源成功");
} else {
log.error("向[uaa]同步系统资源失败");
}
}
catch (Exception ex) {
log.error(String.format("向[UAA]同步系统资源失败,请检查[UAA]服务是否正常! [%s]",ex));
} catch (Exception ex) {
log.error("向[uaa]同步系统资源失败,请检查[uaa]服务是否正常运行! {}", ex.getMessage());
}
try {
InputStream sysModel = this.getClass().getResourceAsStream("/sysmodel/ibzdst.json"); //获取当前系统所有实体资源能力
String strSysModel = IOUtils.toString(sysModel,"UTF-8");
if(liteFeignClient.syncSysModel(JSONObject.parseObject(strSysModel))) {
log.info("向[lite]同步系统模型成功");
}else{
log.error("向[lite]同步系统模型失败");
InputStream model = this.getClass().getResourceAsStream("/sysmodel/ibzdst.json"); //系统模型
if (!ObjectUtils.isEmpty(model)) {
String strModel = IOUtils.toString(model, "UTF-8");
if (liteClient.syncSysModel(JSONObject.parseObject(strModel))) {
log.info("向[lite]同步模型成功");
} else {
log.error("向[lite]同步模型失败");
}
}
catch (Exception ex) {
log.error(String.format("向[lite]同步系统模型失败,请检查[lite]服务是否正常! [%s]",ex));
} catch (Exception ex) {
log.error("向[lite]同步系统模型失败,请检查[lite]服务是否正常运行! {}", ex.getMessage());
}
try {
InputStream runtimeDict = this.getClass().getResourceAsStream("/sysmodel/RuntimeDict.json"); //获取当前系统所有实体资源能力
String strRuntimeDict = IOUtils.toString(runtimeDict,"UTF-8");
if(dictFeignClient.syncRuntimeDict(JSONArray.parseArray(strRuntimeDict))) {
log.info("推送系统预置代码表成功");
}else{
log.error("推送系统预置代码表失败");
InputStream dict = this.getClass().getResourceAsStream("/sysmodel/RuntimeDict.json"); //代码表
if (!ObjectUtils.isEmpty(dict)) {
String strDict = IOUtils.toString(dict, "UTF-8");
if (dictClient.syncRuntimeDict(JSONArray.parseArray(strDict))) {
log.info("向[dict]同步代码表成功");
} else {
log.error("向[dict]同步代码表失败");
}
}
} catch (Exception e) {
log.error("推送系统预置代码表失败");
} catch (Exception ex) {
log.error("向[dict]同步代码表失败,请检查[dict]服务是否正常运行! {}", ex.getMessage());
}
}
}
\ No newline at end of file
......@@ -125,3 +125,4 @@ server:
min-response-size: 10240
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册