From 156e136377680ac2dd5ad89735b7273db6f6d1d5 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期六, 24 二月 2024 20:27:02 +0800 Subject: [PATCH] 远程部署功能完善 --- Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/vo/DeployAppsVO.java | 1 Source/UBCS-WEB/src/views/system/PasswordManagement/passwords.vue | 1 Source/UBCS/ubcs-service/ubcs-code/src/test/java/util.java | 3 Source/UBCS-WEB/src/api/GetItem.js | 4 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/HttpUtils.java | 2 Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/DeployApps.java | 19 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/CodeImportResultVO.java | 4 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/DockingManagementController.java | 1 Source/UBCS-WEB/src/components/service-deploy/uploadServiceJarDialog.vue | 154 +++++++ Source/UBCS-WEB/src/const/code/codeSynonym.js | 20 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java | 97 ++++ Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java | 1 Source/UBCS/ubcs-service/ubcs-code/pom.xml | 4 Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/enumpack/CmdConfigEnum.java | 136 ++++++ Source/UBCS-WEB/src/api/system/deploy.js | 33 + Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/CmdConfig.java | 13 Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/controller/DeployAppsController.java | 80 +++ Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java | 10 Source/UBCS-WEB/src/components/Theme/ThemeImport.vue | 2 Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/impl/DeployAppsServiceImpl.java | 314 ++++++++++++++ Source/UBCS-WEB/src/views/system/deploy.vue | 272 ++++++++++-- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java | 14 Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/IDeployAppsService.java | 48 ++ Source/UBCS-WEB/src/main.js | 2 Source/UBCS/ubcs-service-api/ubcs-deploy-api/pom.xml | 6 25 files changed, 1,141 insertions(+), 100 deletions(-) diff --git a/Source/UBCS-WEB/src/api/GetItem.js b/Source/UBCS-WEB/src/api/GetItem.js index 64778a7..f2455f8 100644 --- a/Source/UBCS-WEB/src/api/GetItem.js +++ b/Source/UBCS-WEB/src/api/GetItem.js @@ -138,10 +138,10 @@ } //鎵嬪姩鍚屾 -export const syncSearch = (data) => { +export const syncSearch = (params) => { return request({ url: '/api/ubcs-code/dockingManagement/searchItemDataForERP', method: 'post', - data + params }) } diff --git a/Source/UBCS-WEB/src/api/system/deploy.js b/Source/UBCS-WEB/src/api/system/deploy.js index 3c7ca90..204464d 100644 --- a/Source/UBCS-WEB/src/api/system/deploy.js +++ b/Source/UBCS-WEB/src/api/system/deploy.js @@ -2,10 +2,39 @@ export const getApplications = () => { return request({ - // headers: {'Accept': 'application/json'}, - // url: '/api/ubcs-admin/applications', url: '/api/ubcs-deploy/deploy/applications', method: 'get', }) } +export const saveOrGetServiceConfInfo = (row) => { + return request({ + url: '/api/ubcs-deploy/deploy/saveOrGetServiceConfInfo', + method: 'post', + data: row + }) +} + +export const saveOrUpdateServiceInfo = (row) => { + return request({ + url: '/api/ubcs-deploy/deploy/saveOrUpdateServiceInfo', + method: 'post', + data: row + }) +} + +export const addSave = (row) => { + return request({ + url: '/api/ubcs-deploy/deploy/addSave', + method: 'post', + data: row + }) +} + +export const executeCmd = (row) => { + return request({ + url: '/api/ubcs-deploy/deploy/cmdExecute', + method: 'post', + data: row + }) +} \ No newline at end of file diff --git a/Source/UBCS-WEB/src/components/Theme/ThemeImport.vue b/Source/UBCS-WEB/src/components/Theme/ThemeImport.vue index 5ea996a..ab91a1c 100644 --- a/Source/UBCS-WEB/src/components/Theme/ThemeImport.vue +++ b/Source/UBCS-WEB/src/components/Theme/ThemeImport.vue @@ -68,7 +68,7 @@ watch:{ visible:{ handler(newval,oldval){ - console.log('newval',newval) + // console.log('newval',newval) } } }, diff --git a/Source/UBCS-WEB/src/components/service-deploy/uploadServiceJarDialog.vue b/Source/UBCS-WEB/src/components/service-deploy/uploadServiceJarDialog.vue new file mode 100644 index 0000000..e9718ef --- /dev/null +++ b/Source/UBCS-WEB/src/components/service-deploy/uploadServiceJarDialog.vue @@ -0,0 +1,154 @@ +<template> + <el-dialog + title="鏈嶅姟鏇存柊jar鍖呭鍏�" + :visible.sync="dialogVisible" + append-to-body + > + <Divider text="鏇存柊鎻愮ず" left="30px"></Divider> + <ul> + <li> + 1.涓婁紶jar鏂囦欢鏃惰纭畾jar鏂囦欢鍚嶇О姝g‘锛屾墦濂界殑jar鍖咃紝<span style="font-weight: bold;color: red;">璇峰嬁闅忎究鏇存敼jar鏂囦欢鍚嶅拰鏂囦欢鍚庣紑鍚�</span>銆� + </li> + <li> + 2.涓婁紶澶氫釜鏂囦欢鏃惰鍘嬬缉鎴�<span style="font-weight: bold;color: red;">.zip</span>鍐嶄笂浼犮�� + </li> + <li> + 3.涓婁紶鎴愬姛涔嬪悗浼氳嚜鍔ㄩ噸鍚寚瀹氭湇鍔★紝骞朵笖璇ョ晫闈腑浼氭殏鏃舵棤娉曟煡璇㈠埌璇ユ湇鍔′俊鎭紝璇风◢绛�1~2鍒嗛挓鍐嶆煡鐪嬮獙璇佽鏈嶅姟鏄惁鏇存柊鎴愬姛銆� + </li> + </ul> + <Divider text="鏂囦欢锛岄�夋嫨鏂囦欢鍚庝細鑷姩涓婁紶" left="30px"></Divider> + <el-upload + ref="uploadFiles" + action="/api/ubcs-deploy/deploy/importUpdateServiceJar" + :on-success="onSuccess" + :multiple="true" + :on-error="onError" + :headers="uploadHeaders" + :show-file-list="false" + :before-upload="beforeUpload" + :on-change="uploadChange" + :directory="true" + :data="{'serverName':serverName}" + name="files" + class="upload-demo"> + <el-button size="small" type="primary" style="margin: 15px 10px 15px 35px" @click="handleAddFolder('file')">娴忚鏂囦欢</el-button> + <!-- <el-button size="small" type="primary" @click="handleAddFolder('dir')">娴忚鏂囦欢澶�</el-button> --> + </el-upload> + <template #footer> + <el-button size="small" @click="dialogVisible = false">鍏抽棴</el-button> + </template> + </el-dialog> + </template> + +<script> +import {downloadErrorFile} from '@/api/template/templateAttr' +import {getToken} from "@/util/auth"; +import func from "@/util/func"; +export default { + name: "uploadServiceJarDialog", + props: { + visible: { + type: Boolean, + default: false, + }, + serverName: { + type: String, + default: false, + }, + }, + data(){ + return{ + flga:true, + pageLoading: null, + downloadLoading: false, + } + }, + watch:{ + visible:{ + handler(newval,oldval){ + // console.log('newval',newval) + } + } + }, + computed:{ + uploadHeaders() { + return { + "Blade-Auth": "bearer " + getToken(), + }; + }, + dialogVisible: { + get() { + return this.visible; + }, + set(val) { + this.$emit("update:visible", val); + }, + }, + }, + methods:{ + //鏂囦欢涓婁紶鍓� + async beforeUpload(file) { + // console.log(file); + // console.log(this.serviceName); + this.pageLoading = this.$loading({ + lock: true, + text: "鏂囦欢涓婁紶涓�", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)", + }); + return true; + }, + // 鏂囦欢涓婁紶鎴愬姛 + onSuccess(resbonse){ + if (Object.keys(resbonse.data).length === 0) { + this.$message.success( "涓婚搴撳垎绫诲鍏ユ垚鍔燂紒"); + this.dialogVisible = false; + return; + } + if (resbonse.data.fileOid) { + const fileName = resbonse.data.filePath.split("/").pop(); + this.$message.error("璇蜂笅杞介敊璇俊鎭枃浠惰繘琛屾煡鐪嬶紒"); + downloadErrorFile({ uuid: resbonse.data.fileOid }).then((res) => { + func.downloadFileByBlobHandler(res); + }); + } + }, + //鏂囦欢涓婁紶澶辫触 + onError(res){ + this.pageLoading.close(); + }, + //鏂囦欢鐘舵�佹敼鍙� + uploadChange(file){ + if (file.status === "success" || file.status === "error") { + this.pageLoading.close(); + } + }, + // 鐐瑰嚮鏂囦欢澶硅矾寰勪笂浼犳寜閽� + // handleAddFolder (type) { + // if(type==='file'){ + // this.$nextTick(() => { + // this.$refs.uploadFiles.$children[0].$refs.input.webkitdirectory = false; + // }) + // }else{ + // this.$nextTick(() => { + // this.$refs.uploadFiles.$children[0].$refs.input.webkitdirectory = true; + // }) + // } + // }, + + } +} +</script> + +<style scoped lang="scss"> +ul { + color: rgb(188, 188, 188); + margin: 20px 0 20px 0; + padding: 0 0 0 30px; + list-style: none; + li { + margin-bottom: 5px; + font-size: 13px; + } +} +</style> diff --git a/Source/UBCS-WEB/src/const/code/codeSynonym.js b/Source/UBCS-WEB/src/const/code/codeSynonym.js index 9d90982..cf06ff8 100644 --- a/Source/UBCS-WEB/src/const/code/codeSynonym.js +++ b/Source/UBCS-WEB/src/const/code/codeSynonym.js @@ -21,6 +21,11 @@ search: true, searchLabelWidth: 45, searchSpan: 4, + rules: [{ + required: true, + message: "璇疯緭鍏ョ紪鍙�", + trigger: "blur", + }] }, { label: "鍚嶇О", @@ -29,6 +34,11 @@ search: true, searchLabelWidth: 45, searchSpan: 4, + // rules: [{ + // required: true, + // message: "鍚嶇О", + // trigger: "blur", + // }] }, { label: "婧愬��", @@ -37,6 +47,11 @@ search: true, searchLabelWidth: 45, searchSpan: 4, + rules: [{ + required: true, + message: "璇疯緭鍏ユ簮鍊�", + trigger: "blur", + }] }, { label: "杩戜箟璇�", @@ -45,6 +60,11 @@ search: true, searchLabelWidth: 60, searchSpan: 4, + rules: [{ + required: true, + message: "璇疯緭鍏ヨ繎涔夎瘝", + trigger: "blur", + }] }, { label: "鐘舵��", diff --git a/Source/UBCS-WEB/src/main.js b/Source/UBCS-WEB/src/main.js index d476b04..e18c7c8 100644 --- a/Source/UBCS-WEB/src/main.js +++ b/Source/UBCS-WEB/src/main.js @@ -60,6 +60,7 @@ import businesswork from "@/components/work/BusinessWork" import MasterTransfer from "@/components/Master/MasterTransfer"; import ThemeImport from "@/components/Theme/ThemeImport"; +import uploadServiceJarDialog from "@/components/service-deploy/uploadServiceJarDialog"; import maxSerialnumDialog from '@/components/code-dialog-page/maxSerialnumDialog' import VciDockingSearch from '@/components/dockingSearch/VciDockingSearch' // 灏嗗伐鍏峰嚱鏁版坊鍔犲埌鍏ㄥ眬 @@ -128,6 +129,7 @@ Vue.component('ThemeImport', ThemeImport) Vue.component('maxSerialnumDialog', maxSerialnumDialog) Vue.component('VciDockingSearch', VciDockingSearch) +Vue.component('uploadServiceJarDialog', uploadServiceJarDialog) // 鍔犺浇鐩稿叧url鍦板潃 Object.keys(urls).forEach(key => { diff --git a/Source/UBCS-WEB/src/views/system/PasswordManagement/passwords.vue b/Source/UBCS-WEB/src/views/system/PasswordManagement/passwords.vue index f850c83..15aed07 100644 --- a/Source/UBCS-WEB/src/views/system/PasswordManagement/passwords.vue +++ b/Source/UBCS-WEB/src/views/system/PasswordManagement/passwords.vue @@ -37,7 +37,6 @@ getadd, getupdata, getremove, - combination } from "@/api/system/passwords"; import {mapGetters} from "vuex"; diff --git a/Source/UBCS-WEB/src/views/system/deploy.vue b/Source/UBCS-WEB/src/views/system/deploy.vue index 2271e3b..cac5509 100644 --- a/Source/UBCS-WEB/src/views/system/deploy.vue +++ b/Source/UBCS-WEB/src/views/system/deploy.vue @@ -1,28 +1,40 @@ <template> <basic-container> <avue-crud :option="option" - :table-loading="loading" - :data="data" - :page.sync="page" - :permission="permissionList" - :before-open="beforeOpen" - v-model="form" - ref="crud" - :cell-style="cellStyle" - :row-style="rowStyle" - @on-load="onLoad"> - <template slot-scope="scope" slot="menu"> + :table-loading="loading" + :data="data" + :page.sync="page" + :permission="permissionList" + :before-open="beforeOpen" + v-model="form" + ref="crud" + :cell-style="cellStyle" + :row-style="rowStyle" + @row-update="rowUpdate" + @row-save="addServiceInfo" + @on-load="onLoad"> + <template slot="menu" slot-scope="{ row, index }"> <el-button type="text" - icon="el-icon-upload" - size="small" - v-if="permissionList.upload" - @click="handleDownload(scope.row)">涓� 浼� + icon="el-icon-upload" + size="small" + v-if="permissionList.upload" + @click.native="importServiceJar(row)">涓� 浼� </el-button> <el-button type="text" - icon="el-icon-refresh" - size="small" - v-if="permissionList.restart" - @click="test">閲� 鍚� + :disabled="row.name === 'ubcs-deploy'" + :icon="row.status === 'UP' ? 'el-icon-refresh':'el-icon-video-play'" + size="small" + v-if="permissionList.restart" + @click="cmdExecute(row)"> + {{ row.status === 'UP' ? '閲� 鍚�': '鍚� 鍔�' }} + </el-button> + <el-button type="text" + v-if="permissionList.editBtn" + icon="el-icon-edit" + size="small" + @click="handleEdit(row, index)" + > + 缂栬緫 </el-button> </template> <template slot-scope="{row}" @@ -34,56 +46,21 @@ <el-tag>{{`${row.serviceNum}`}}</el-tag> </template> </avue-crud> + <uploadServiceJarDialog :serverName="serviceName" :visible.sync="uploadDialogVisible"></uploadServiceJarDialog> </basic-container> </template> <script> -import { getApplications } from "@/api/system/deploy"; -import moment from 'moment'; +import { getApplications,saveOrGetServiceConfInfo,saveOrUpdateServiceInfo,addSave,executeCmd } from "@/api/system/deploy"; +import moment from "moment"; export default { data() { return { - option: { - columnBtn:false, - height: 'auto', - calcHeight: 30, - tip: false, - searchShow: false, - border: true, - index: true, - viewBtn: false, - addBtn: false, - editBtn: false, - delBtn: false, - selection: true, - refreshBtn: false, - dialogClickModal: false, - column: [ - { - label: "瀹炰緥鍚嶇О", - prop: "name", - sortable: true, - }, - { - label: "杩愯鐘舵��", - prop: "status", - }, - { - label: "鍚姩鏃堕棿", - prop: "statusTimestamp", - }, - { - label: "绔彛鍙�", - prop: "port", - }, - { - label: "瀹炰緥鏁伴噺", - prop: "serviceNum", - width: 120, - }, - ] - }, data: [], + uploadDialogVisible: false, + loading: true, + isDisabled: true, + serviceName: "", } }, created() { @@ -94,16 +71,124 @@ return { upload: true, restart: true, - // viewBtn: this.vaildData(this.permission, true), + editBtn: true,// this.vaildData(this.permission, true), + addBtn: true, }; + }, + option(){ + return { + columnBtn:false, + height: 'auto', + calcHeight: 30, + tip: false, + searchShow: false, + border: true, + index: true, + viewBtn: false, + addBtn: true, + editBtn: false, + delBtn: false, + selection: true, + refreshBtn: false, + dialogClickModal: false, + column: [ + { + label: "瀹炰緥鍚嶇О", + prop: "name", + sortable: true, + display: false, + }, { + label: "杩愯鐘舵��", + prop: "status", + display: false, + }, { + label: "鍚姩鏃堕棿", + prop: "statusTimestamp", + sortable: true, + display: false, + }, { + label: "绔彛鍙�", + prop: "port", + display: false, + }, { + label: "瀹炰緥鏁伴噺", + prop: "serviceNum", + width: 120, + display: false, + }, + + { + label: "瀹炰緥鍚嶇О", + prop: "serverName", + labelWidth: 140, + hide: true, + disabled: this.isDisabled, + },{ + label: "鏈嶅姟jar瀛樻斁鐨勮矾寰�", + prop: "serverPath", + labelWidth: 140, + hide: true, + rules: [{ + required: true, + message: "璇疯緭鍏ユ湇鍔ar瀛樻斁鐨勮矾寰�", + trigger: "blur" + }] + },{ + label: "鏃ュ織鏂囦欢瀛樻斁浣嶇疆", + prop: "logPath", + labelWidth: 140, + hide: true, + disabled: true, + rules: [{ + required: false, + message: "璇疯緭鍏ユ湇鍔ar瀛樻斁鐨勮矾寰�", + trigger: "blur" + }] + },{ + label: "鏂囦欢澶囦唤璺緞", + prop: "fileBack", + labelWidth: 140, + hide: true, + rules: [{ + required: false, + message: "璇疯緭鍏ユ枃浠跺浠借矾寰�", + trigger: "blur" + }] + }, + ], + group: [ + { + icon: 'el-icon-info', + label: '鍩虹鍛戒护閰嶇疆', + collapse: true, + labelWidth: 140, + prop: 'cmdCofig', + column: [ + { + label: '寮�濮嬪懡浠�', + prop: 'startCmd', + }, { + label: '閲嶅惎鍛戒护', + prop: 'restartCmd', + }, { + label: '鍋滄鍛戒护', + prop: 'stopCmd', + }, + ] + }, + ] + } }, }, methods: { onLoad(){ + this.loading = true; getApplications().then(res=>{ let serviceData = res.data.data; if(serviceData.length>0){ + // 鍏堟竻绌� + this.data = []; serviceData.forEach(element => { //console.log("element",element); // 灏嗘椂闂磋浆鎹负鏈湴鏃堕棿 @@ -114,6 +199,7 @@ this.data.push(element) }); } + this.loading = false; //console.log(res.data.data); }); }, @@ -142,6 +228,68 @@ } } }, + // 鎺у埗绀轰緥鍚嶇О鏄惁鍙緭鍏� + beforeOpen(done, type) { + // console.log(type) + if(type === "edit"){ + this.isDisabled = true; + }else { + this.isDisabled = false; + } + done(); + }, + // 鍏抽棴寮圭獥 + /** 瀵煎叆 */ + importServiceJar(row) { + // console.log(row); + this.serviceName = row.name; + this.uploadDialogVisible = true; + }, + // 鏂板 + addServiceInfo(row, done, loading){ + addSave(row).then(() => { + this.onLoad(); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + done(); + }, error => { + window.console.log(error); + loading(); + }); + }, + // 缂栬緫 + handleEdit(row) { + saveOrGetServiceConfInfo(row).then(res=>{ + // console.log(res.data.data); + // 璇锋眰鍚庣鎺ュ彛锛岃幏鍙栧埌璇ユ湇鍔$殑鍩虹閰嶇疆淇℃伅 + this.$refs.crud.rowEdit(res.data.data, row.$index); + }) + }, + // 淇敼 + rowUpdate(row, index, done) { + saveOrUpdateServiceInfo(row).then(() => { + this.onLoad() + this.$message({ + type: "success", + message: "淇敼鎴愬姛!" + }); + done() + }).catch(res => { + }) + }, + // 鍛戒护鎵ц + cmdExecute(row){ + // console.log(row); + executeCmd(row).then(res => { + this.onLoad() + this.$message({ + type: "success", + message: res.data.msg + }); + }); + }, } } diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/CodeImportResultVO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/CodeImportResultVO.java index 4fe6901..4a40baf 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/CodeImportResultVO.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/CodeImportResultVO.java @@ -21,6 +21,7 @@ * 鏄惁鎴愬姛鐨� */ private boolean success ; + /** * 鍏抽敭灞炴�ф牎楠岃鍒欑殑淇℃伅 */ @@ -30,14 +31,17 @@ * 鍏抽敭灞炴�ф牎楠屽悗锛岄噸澶嶇殑琛屽彿 */ private Set<String> keyAttrRepeatRowIndexList = new HashSet<>(); + /*** * 鍏抽敭灞炴�х浉鍚岀殑灞炴�id涓庡叾閲嶅鐨勬暟鎹畂id */ private Map<String,List<String>> keyAttrOkOidTORepeatOidMap=new HashMap<>(); + /*** * 鏍规嵁鍏抽敭鐔熸倝鏌ヨ鐨勯噸澶嶇殑鏁版嵁瀵硅薄 */ private Map<String, List<BaseModel>> indexTODataMap=new HashMap<>(); + /*** * 鏍规嵁鍏抽敭鐔熸倝鏌ヨ鐨勯噸澶嶇殑鏁版嵁瀵硅薄 */ diff --git a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/pom.xml b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/pom.xml index 81d7eb2..5be7d5e 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/pom.xml +++ b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/pom.xml @@ -21,6 +21,12 @@ <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> </dependency> + <dependency> + <groupId>com.vci.ubcs</groupId> + <artifactId>ubcs-util-api</artifactId> + <version>3.0.1.RELEASE</version> + <scope>compile</scope> + </dependency> </dependencies> </project> diff --git a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/CmdConfig.java b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/CmdConfig.java index 60cc7ae..edeaa98 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/CmdConfig.java +++ b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/CmdConfig.java @@ -1,6 +1,8 @@ package com.vci.ubcs.deploy.entity; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; /** * 杩滅▼閮ㄧ讲鑳藉鎵ц鐨勫懡浠� @@ -8,12 +10,23 @@ * @date 2024/1/7 21:37 */ @Data +@NoArgsConstructor +@AllArgsConstructor public class CmdConfig { + /** + * 鍚姩 + */ private String startCmd; + /** + * 閲嶅惎 + */ private String restartCmd; + /** + * 鍋滄 + */ private String stopCmd; } diff --git a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/DeployApps.java b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/DeployApps.java index 460d1d6..1ab8a62 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/DeployApps.java +++ b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/entity/DeployApps.java @@ -39,8 +39,23 @@ private String logPath; /** - * 鍛戒护閰嶇疆 + * 鍚姩 */ - private CmdConfig cmdCofig; + private String startCmd; + + /** + * 閲嶅惎 + */ + private String restartCmd; + + /** + * 鍋滄 + */ + private String stopCmd; + + /** + * 鏂囦欢澶囦唤璺緞 + */ + private String fileBack; } diff --git a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/enumpack/CmdConfigEnum.java b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/enumpack/CmdConfigEnum.java new file mode 100644 index 0000000..38f5b05 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/enumpack/CmdConfigEnum.java @@ -0,0 +1,136 @@ +package com.vci.ubcs.deploy.enumpack; + + +import com.vci.ubcs.starter.annotation.VciEnum; +import com.vci.ubcs.starter.web.constant.MdmEnumIdConstant; +import com.vci.ubcs.starter.web.enumpck.BaseEnum; + +/** + * 鍚仠鍛戒护閰嶇疆鏋氫妇 + * @author ludc + * @date 2024/2/20 8:59 + */ +@VciEnum(name = MdmEnumIdConstant.CODE_SEC_TYPE,text = "鍚仠鍛戒护閰嶇疆鏋氫妇",description = "") +public enum CmdConfigEnum implements BaseEnum { + + /** + * 鍚姩 + */ + START_CMD("systemctl start ","鍚姩"), + + /** + * 鍋滄 + */ + STOP_CMD("systemctl stop ","鍋滄"), + + /** + * 閲嶅惎 + */ + RESTART_CMD("systemctl restart ","閲嶅惎") + ; + + /** + * 鏋氫妇鐨勫�� + */ + private String value; + + /** + * 鏋氫妇鏄剧ず鏂囨湰 + */ + private String text; + + /** + * 鑾峰彇鏋氫妇鍊� + * + * @return 鏋氫妇鍊� + */ + @Override + public String getValue() { + return value; + } + + /** + * 璁剧疆鏋氫妇鍊� + * + * @param value 鏋氫妇鍊� + */ + public void setValue(String value) { + this.value = value; + } + + /** + * 鑾峰彇鏋氫妇鏄剧ず鏂囨湰 + * + * @return 鏄剧ず鏂囨湰 + */ + @Override + public String getText() { + return text; + } + + /** + * 璁剧疆鏄剧ず鏂囨湰 + * + * @param text 鏄剧ず鏂囨湰 + */ + public void setText(String text) { + this.text = text; + } + + /** + * 鏋勯�犲嚱鏁� + * + * @param value 鍊� + * @param text 鏄剧ず鏂囨湰 + */ + private CmdConfigEnum(String value, String text) { + this.value = value; + this.text = text; + } + + /** + * 鏍规嵁鍚嶇О鑾峰彇瀵瑰簲鐨勬灇涓惧�� + * + * @param text 鍚嶇О + * @return 鏋氫妇鍊� + */ + public static String getValueByText(String text) { + for (CmdConfigEnum wenum : CmdConfigEnum.values()) { + if (wenum.getText().equalsIgnoreCase(text)) { + return wenum.getValue(); + } + } + return ""; + } + + /** + * 鏍规嵁鏋氫妇鍊艰幏鍙栧悕绉� + * + * @param value 鏋氫妇鍊� + * @return 鍚嶇О + */ + public static String getTextByValue(String value) { + for (CmdConfigEnum wenum : CmdConfigEnum.values()) { + if (wenum.getValue().equalsIgnoreCase(value)) { + return wenum.getText(); + } + } + return ""; + } + + /** + * 鏍规嵁鏋氫妇鍊艰幏鍙栨灇涓惧璞� + * + * @param value 鏋氫妇鍊� + * @return 鏋氫妇瀵硅薄锛屼笉瀛樺湪鏃跺�欒繑鍥瀗ull + */ + public static CmdConfigEnum forValue(String value) { + for (CmdConfigEnum wenum : CmdConfigEnum.values()) { + if (wenum.getValue().equalsIgnoreCase(value)) { + return wenum; + } + } + return null; + } + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/vo/DeployAppsVO.java b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/vo/DeployAppsVO.java index f802790..bed3f78 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/vo/DeployAppsVO.java +++ b/Source/UBCS/ubcs-service-api/ubcs-deploy-api/src/main/java/com/vci/ubcs/deploy/vo/DeployAppsVO.java @@ -1,5 +1,6 @@ package com.vci.ubcs.deploy.vo; +import com.vci.ubcs.deploy.entity.CmdConfig; import com.vci.ubcs.deploy.entity.DeployApps; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/HttpUtils.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/HttpUtils.java index 6c2c407..98b3042 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/HttpUtils.java +++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/HttpUtils.java @@ -1,5 +1,7 @@ package com.vci.ubcs.starter.util; +import com.alibaba.fastjson.JSON; +import org.springblade.core.tool.utils.WebUtil; import org.springframework.http.*; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; diff --git a/Source/UBCS/ubcs-service/ubcs-code/pom.xml b/Source/UBCS/ubcs-service/ubcs-code/pom.xml index 698c2fe..aed5804 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/pom.xml +++ b/Source/UBCS/ubcs-service/ubcs-code/pom.xml @@ -153,10 +153,6 @@ <version>3.0.1.RELEASE</version> <scope>compile</scope> </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - </dependency> </dependencies> <build> diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/DockingManagementController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/DockingManagementController.java index 121128e..30b4b15 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/DockingManagementController.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/DockingManagementController.java @@ -22,6 +22,7 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; import org.springframework.beans.factory.annotation.Value; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java index f8e46aa..f4ad154 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java @@ -96,6 +96,16 @@ boolean trimAll, Map<String, String> conditionMap); /** + * 灏佽杩戜箟璇嶆煡璇㈣鍒欏睘鎬х殑鏌ヨ璇彞 + * @param value 褰撳墠鐨勫�� + * @param keyRuleVO 灞炴�х殑缂栧彿 + * @param attrId + * @param conditionMap 鏌ヨ鏉′欢 + */ + void wrapperSynonymAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO, String attrId, + Map<String, String> conditionMap); + + /** * 鍒濆鍖栦笟鍔$被鍨� * --鍒涘缓浜洪粯璁や负褰撳墠鐢ㄦ埛锛屽鏋滈渶瑕佷慨鏀癸紝鍙互鍦ㄨ幏鍙栧悗鑷澶勭悊 * @param btmName 涓氬姟绫诲瀷鐨勫悕绉帮紝浼氳嚜鍔ㄥ彉鎴愬皬鍐� diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java index 38befce..fcb7bbe 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java @@ -75,6 +75,7 @@ import javax.servlet.http.HttpServletRequest; import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.MessageContext; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicReference; diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java index 5942281..2965981 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java @@ -1288,6 +1288,20 @@ } /** + * 灏佽杩戜箟璇嶆煡璇㈣鍒欏睘鎬х殑鏌ヨ璇彞 + * @param value 褰撳墠鐨勫�� + * @param keyRuleVO 灞炴�х殑缂栧彿 + * @param attrId + * @param conditionMap 鏌ヨ鏉′欢 + */ + @Override + public void wrapperSynonymAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO, String attrId, Map<String, String> conditionMap) { + // map鏋勯�犳�濊矾锛�1銆佸厛瀹屾垚姝e悜鏇挎崲sql鍊� + // 2銆佸啀瀹屾垚鍙嶅悜鏇挎崲sql鍊� + + } + + /** * 鏍¢獙鏋氫妇鐨勫唴瀹� * * @param templateVO 妯℃澘鐨勬樉绀哄璞★紝闇�瑕佸寘鍚睘鎬� diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java index 2881a32..b967ab5 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java @@ -68,6 +68,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import javax.xml.bind.ValidationEvent; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; @@ -4381,7 +4382,7 @@ } } /** - * 鏍¢獙鍏抽敭灞炴�� + * 鏍¢獙鍏抽敭灞炴�э紝鍜岃繎涔夎瘝鏌ヨ瑙勫垯 * @param classifyFullInfo 鍒嗙被鐨勫叏閮ㄤ俊鎭� * @param templateVO 妯℃澘鐨勫唴瀹癸紝蹇呴』鍖呭惈妯℃澘灞炴�� * @param cboList 鎵归噺鐨勬暟鎹� @@ -4396,13 +4397,13 @@ Map<String/**灞炴�х殑缂栧彿**/, CodeClassifyTemplateAttrVO> keyAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); // TODO:2024-02-01 鍏堣幏鍙栭厤缃簡杩戜箟璇嶆煡璇㈣鍒欑殑灞炴�э紝涓嶅悓浜庡叧閿睘鎬э紝璁剧疆浜嗚繎涔夎瘝鏌ヨ瑙勫垯鐨勫睘鎬у彲鑳芥槸澶氭潯涓嶅悓鐨勮繎涔夎瘝鏌ヨ瑙勫垯 -// Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); - //鏈夐厤缃繎涔夎瘝鏌ヨ瑙勫垯灞炴�� -// Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>(); -// if(!sysonymAttrMaps.isEmpty()){ -// // 鏌ヨ杩戜箟璇嶈鍒� -// codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps); -// } + Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); + // 鏈夐厤缃繎涔夎瘝鏌ヨ瑙勫垯灞炴�� + Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>(); + if(!sysonymAttrMaps.isEmpty()){ + // 鏌ヨ杩戜箟璇嶈鍒欙紝瀛樺偍鏂瑰紡key锛氬睘鎬d锛寁alue杩戜箟璇嶆煡璇㈣鍒欏垪琛� + codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps); + } boolean trimAll =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); //鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖ @@ -4415,7 +4416,12 @@ resultVO.setKeyAttrRuleInfo(String.format(keyRuleVO ==null?"":"鏌ヨ瑙勫垯锛氬幓闄ょ┖鏍�--{0},蹇界暐澶у皬鍐�--{1},蹇界暐鍏ㄥ崐瑙�--{2},蹇界暐鍏ㄩ儴绌烘牸--{3}", new String[]{trim?"鏄�":"鍚�",ignoreCase?"鏄�":"鍚�",ignoreWidth?"鏄�":"鍚�",trimAll?"鏄�":"鍚�"})); //resultVO.setSelfRepeatRowIndexList(getSelfRepeatRowIndex(keyAttrMap,cboList,keyRuleVO)); + + // 鍏堝湪琛ㄦ牸涓煡璇㈠叧閿睘鎬ч噸澶嶇殑鍒� getSelfRepeatRowIndex(keyAttrMap,cboList,keyRuleVO,resultVO); + // 鍐嶅湪琛ㄦ牸涓煡璇㈣繎涔夎瘝鏌ヨ瑙勫垯鐨勫垪 + //getSelfRepeatSysnomRowIndex(sysonymAttrMaps,cboList,codeSynonymMaps,resultVO); + if(!CollectionUtils.isEmpty(resultVO.getSelfRepeatRowIndexList())){ //鎴戜滑绉婚櫎鏈韩閲嶅鐨勬暟鎹� cboList = cboList.stream().filter(s->!resultVO.getSelfRepeatRowIndexList().contains(s.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); @@ -4440,8 +4446,12 @@ value = ""; } value= value.replace(REQUIRED_CHAR,SPECIAL_CHAR); + // 鍏抽敭灞炴�ф煡璇㈡潯浠秏ap鑾峰彇 engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); + // 杩戜箟璇嶆煡璇㈣鍒欐潯浠秏ap鑾峰彇 + //engineService.wrapperSynonymAttrConditionMap(value); }); + if (!CollectionUtils.isEmpty(keyAttrMap)) { // 娣诲姞涓嶅弬涓庡叧閿睘鎬ф牎楠岀殑鍒嗙被oid鍒ゆ柇 if(Func.isNotBlank(isParticipateCheckOids)){ @@ -4616,6 +4626,7 @@ String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); String oid=cbo.getOid(); StringBuilder sb = new StringBuilder(); + // 鍏抽敭灞炴�ч噸澶嶆牎楠屽�煎鐞� for (int i = 0; i < attrVOList.size(); i++) { CodeClassifyTemplateAttrVO attrVO = attrVOList.get(i); String attrId = attrVO.getId().toLowerCase(Locale.ROOT); @@ -4662,6 +4673,75 @@ } /** + * 鑾峰彇杩戜箟璇嶆煡璇㈠瓨鍦ㄧ浉鍚岀殑琛屽彿 + * @param sysonymAttr + * @param dataList + * @param CodeSynonymMaps + * @param resultVO + */ + private void getSelfRepeatSysnomRowIndex(Map<String/**灞炴�х殑缂栧彿**/, CodeClassifyTemplateAttrVO> sysonymAttr, + List<ClientBusinessObject> dataList, Map<String, List<CodeSynonym>> CodeSynonymMaps,CodeImportResultVO resultVO) { + Set<String> selfRepeatRowIndexList = new CopyOnWriteArraySet<>(); + Map<String,List<String>> keyAttrOkOidTORepeatOidMap=new HashMap<>(); + //蹇呴』灏嗗睘鎬ф寜鐓ч『搴忔帓搴忓ソ + List<CodeClassifyTemplateAttrVO> attrVOList = sysonymAttr.values().stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList()); + Map<String/**琛屽彿**/,String/**鍏抽敭灞炴�х殑缁勫悎鍐呭**/> rowIndexKeyStringMap = new HashMap<>(); + Map<String/**鍏抽敭灞炴�х殑缁勫悎鍐呭**/,String/**绗竴涓叧閿睘鎬х殑鏁版嵁oid**/> okOidKeyStringMap = new HashMap<>(); + dataList.parallelStream().forEach(cbo-> { + String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); + String oid = cbo.getOid(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrVOList.size(); i++) { + CodeClassifyTemplateAttrVO attrVO = attrVOList.get(i); + String attrId = attrVO.getId().toLowerCase(Locale.ROOT); + String value = cbo.getAttributeValue(attrId); + List<CodeSynonym> codeSynonyms = CodeSynonymMaps.get(attrId); + // 瀵硅繎涔夎瘝鏌ヨ鍊艰繘琛岃浆鎹� + value = synonymConversion(codeSynonyms,value); + // 濡傛灉codeSynonyms鏄涓氨闇�瑕佽�冭檻缁勫悎闂 + sb.append(value).append("${sys}"); + } + String keyString = sb.toString(); + if(rowIndexKeyStringMap.containsValue(keyString) && StringUtils.isNotBlank(keyString)){ + selfRepeatRowIndexList.add(rowIndex); + String okOid=okOidKeyStringMap.getOrDefault(keyString,""); + if(StringUtils.isNotBlank(okOid)){ + List<String>newOidList=new ArrayList<>(); + newOidList.add(oid); + if(keyAttrOkOidTORepeatOidMap.containsKey(okOid)){ + List<String> oldOidList = keyAttrOkOidTORepeatOidMap.get(okOid); + newOidList.addAll(oldOidList); + } + keyAttrOkOidTORepeatOidMap.put(okOid,newOidList); + } + }else { + okOidKeyStringMap.put(sb.toString(),oid); + rowIndexKeyStringMap.put(rowIndex, sb.toString()); + } + }); + //鍥犱负鍙槸鍏抽敭灞炴�ч噸澶嶏紝鎵�浠ユ垜浠笉鑳介噸澶嶇殑澶氭潯閫変竴鏉℃潵鎶ラ敊 + resultVO.setKeyAttrRepeatRowIndexList(selfRepeatRowIndexList); + resultVO.setKeyAttrOkOidTORepeatOidMap(keyAttrOkOidTORepeatOidMap); + } + + /** + * 杩戜箟璇嶄笌婧愬�肩浉浜掕浆鎹� + * @param codeSynonyms + * @param value + * @return + */ + private String synonymConversion(List<CodeSynonym> codeSynonyms,String value){ + // 鍙湁涓�鏉¤繎涔夎瘝鏌ヨ瑙勫垯鏃� + if(codeSynonyms.isEmpty() || codeSynonyms.size() == 1){ + return value.replace(codeSynonyms.get(0).getSourceValue(),codeSynonyms.get(0).getSynonymValue()); + } + // 杩戜箟璇嶈鍒欏彲鑳藉嚭鐜扮殑鎯呭喌鏄竴涓簮鍊煎搴斿涓繎涔夎瘝锛岃�屽弽鏌ユ椂鍚屾牱浼氬嚭鐜颁竴涓繎涔夎瘝瀵瑰簲澶氫釜婧愬�� +// codeSynonyms.stream().map() + + return value; + } + + /** * excel鐨勬爣棰樹笂鑾峰彇瀛楁鎵�鍦ㄧ殑浣嶇疆 * @param titleRowData 鏍囬鐨勫唴瀹� * @param attrNameIdMap 妯℃澘涓睘鎬у悕绉板拰鑻辨枃鐨勬槧灏� @@ -4686,6 +4766,7 @@ } } } + private List<ClientBusinessObject> ChangeMapTOClientBusinessObjects(List<Map<String,String>> oldDataMap){ List<ClientBusinessObject> clientBusinessObjectList=new ArrayList<>(); DefaultAttrAssimtUtil.mapToLowerCase(oldDataMap,true); diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/test/java/util.java b/Source/UBCS/ubcs-service/ubcs-code/src/test/java/util.java index b112e8a..5aa1d20 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/test/java/util.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/test/java/util.java @@ -11,9 +11,6 @@ //鍒楀嚭File鐨勪竴浜涘父鐢ㄦ搷浣� public class util { - - - /** * 閬嶅巻鎸囧畾鐩綍涓嬶紙鍖呮嫭鍏跺瓙鐩綍锛夌殑鎵�鏈夋枃浠讹紝骞跺垹闄や互 lastUpdated 缁撳熬鐨勬枃浠� * @param dir 鐩綍鐨勪綅缃� path diff --git a/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/controller/DeployAppsController.java b/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/controller/DeployAppsController.java index 738ed1b..133fd58 100644 --- a/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/controller/DeployAppsController.java +++ b/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/controller/DeployAppsController.java @@ -4,17 +4,24 @@ import com.vci.ubcs.deploy.entity.DeployApps; import com.vci.ubcs.deploy.service.IDeployAppsService; import com.vci.ubcs.deploy.vo.DeployAppsVO; +import com.vci.ubcs.starter.util.LocalFileUtil; +import com.vci.ubcs.starter.web.util.ControllerUtil; +import com.vci.ubcs.starter.web.util.LangBaseUtil; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.http.auth.AuthenticationException; import org.springblade.core.tenant.annotation.NonDS; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springblade.core.tool.utils.Func; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; import javax.servlet.ServletRequest; +import java.io.File; import java.util.List; /** @@ -24,17 +31,82 @@ */ @NonDS @RestController -@AllArgsConstructor +@RequiredArgsConstructor @RequestMapping("/deploy") @ApiIgnore @Api(value = "搴旂敤绠$悊", tags = "鎺ュ彛") +@Slf4j public class DeployAppsController { private final IDeployAppsService deployAppsService; + /** + * 鑾峰彇鏈嶅姟杩愯鍒楄〃 + * @param servletRequest + * @return + * @throws ServiceException + */ @GetMapping("/applications") public R<List<DeployAppsVO>> getApplications(ServletRequest servletRequest) throws ServiceException { return R.data(deployAppsService.getApplications(servletRequest)); } + /** + * 鑾峰彇鏈嶅姟閰嶇疆淇℃伅 + * @param deployAppsVO + * @return + * @throws ServiceException + */ + @PostMapping("/saveOrGetServiceConfInfo") + public R<DeployApps> saveOrGetServiceConfInfo(@RequestBody DeployAppsVO deployAppsVO) throws ServiceException { + return R.data(deployAppsService.saveOrGetServiceConfInfo(deployAppsVO)); + } + + /** + * 鏂板鎴栬幏鍙栨湇鍔¢粯璁ら厤缃俊鎭� + * @param deployAppsVO + * @return + * @throws ServiceException + */ + @PostMapping("/saveOrUpdateServiceInfo") + public R saveOrUpdateDefault(@RequestBody DeployAppsVO deployAppsVO) throws ServiceException { + return R.status(deployAppsService.saveOrUpdateServiceInfo(deployAppsVO)); + } + + /** + * 娣诲姞鏈嶅姟淇℃伅 + * @param deployApps + * @return + * @throws ServiceException + */ + @PostMapping("/addSave") + public R addSave(@RequestBody DeployApps deployApps) throws ServiceException { + return R.status(deployAppsService.addSave(deployApps)); + } + + /** + * 鏈嶅姟鏇存柊鍖� + * @param files 鏇存柊鐨刯ar鎴栨枃浠跺す + * @param serverName 鏈嶅姟鍚嶇О + * @return + * @throws ServiceException + */ + @PostMapping("/importUpdateServiceJar") + public R importClassify(@RequestParam("files") MultipartFile[] files,@RequestParam String serverName) throws ServiceException { + if(Func.isBlank(serverName)){ + return R.fail("Mandatory parameter service name not found!"); + } + return deployAppsService.importClassify(files,serverName); + } + + /** + * 鎵ц鍛戒护 + * @param deployAppsVO + * @return + */ + @PostMapping("/cmdExecute") + public R cmdExecute(@RequestBody DeployAppsVO deployAppsVO) throws ServiceException { + return deployAppsService.cmdExecute(deployAppsVO); + } + } diff --git a/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/IDeployAppsService.java b/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/IDeployAppsService.java index 7bb3df5..cfa7375 100644 --- a/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/IDeployAppsService.java +++ b/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/IDeployAppsService.java @@ -5,6 +5,9 @@ import com.vci.ubcs.deploy.entity.DeployApps; import com.vci.ubcs.deploy.vo.DeployAppsVO; import org.apache.http.auth.AuthenticationException; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletRequest; import java.util.List; @@ -15,6 +18,51 @@ */ public interface IDeployAppsService extends IService<DeployApps> { + /** + * 鑾峰彇姝e湪杩愯鐨勬湇鍔$浉鍏充俊鎭� + * @param servletRequest + * @return + * @throws ServiceException + */ List<DeployAppsVO> getApplications(ServletRequest servletRequest) throws ServiceException; + /** + * 鏍规嵁鏈嶅姟鍚嶇О鑾峰彇鎴栨湇鍔¢厤缃俊鎭� + * @param deployAppsVO + * @return + * @throws ServiceException + */ + DeployApps saveOrGetServiceConfInfo(DeployAppsVO deployAppsVO) throws ServiceException; + + /** + * 淇敼鎴栦繚瀛� + * @param deployAppsVO + * @return + * @throws ServiceException + */ + boolean saveOrUpdateServiceInfo(DeployAppsVO deployAppsVO) throws ServiceException; + + /** + * 鏂板鏈嶅姟淇℃伅 + * @param deployApps + * @return + * @throws ServiceException + */ + boolean addSave(DeployApps deployApps) throws ServiceException; + + /** + * 鏇存柊鏂囦欢涓婁紶 + * @param files + * @param serverName + * @return + */ + R importClassify(MultipartFile[] files, String serverName) throws ServiceException; + + /** + * 鎵ц鍛戒护 + * @param deployAppsVO + * @return + */ + R cmdExecute(DeployAppsVO deployAppsVO)throws ServiceException; + } diff --git a/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/impl/DeployAppsServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/impl/DeployAppsServiceImpl.java index 6913f3f..a641db4 100644 --- a/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/impl/DeployAppsServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/service/impl/DeployAppsServiceImpl.java @@ -5,45 +5,98 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.shaded.com.google.protobuf.ServiceException; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import com.vci.ubcs.deploy.entity.CmdConfig; import com.vci.ubcs.deploy.entity.DeployApps; -import com.vci.ubcs.deploy.entity.Instance; +import com.vci.ubcs.deploy.enumpack.CmdConfigEnum; import com.vci.ubcs.deploy.mapper.DeployAppsMapper; import com.vci.ubcs.deploy.service.IDeployAppsService; import com.vci.ubcs.deploy.vo.DeployAppsVO; import com.vci.ubcs.starter.util.HttpUtils; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.UrlUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.context.EnvironmentAware; +import org.springframework.core.env.Environment; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; +import java.io.*; import java.net.URL; -import java.util.ArrayList; -import java.util.List; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; /** * @author ludc * @date 2024/1/7 19:54 */ @Service -public class DeployAppsServiceImpl extends ServiceImpl<DeployAppsMapper, DeployApps> implements IDeployAppsService { +@RequiredArgsConstructor +@Slf4j +public class DeployAppsServiceImpl extends ServiceImpl<DeployAppsMapper, DeployApps> implements IDeployAppsService, EnvironmentAware { - @Autowired - private DeployAppsMapper deployAppsMapper; + private final DeployAppsMapper deployAppsMapper; @Value("${password-free.pwd-free-addr:localhost}") private String pwdFreeAddr; - // 閫氳繃鏈嶅姟娉ㄥ唽涓績鑾峰彇缃戝叧鐨勭鍙e彿 + /** + * 閫氳繃鏈嶅姟娉ㄥ唽涓績鑾峰彇缃戝叧鐨勭鍙e彿 + */ @Autowired private DiscoveryClient discoveryClient; + + /** + * 鍚勪釜鏈嶅姟瀛樻斁鐨勭殑鐖惰矾寰� + */ + @Value("${local-log.parent-path:/data1/ubcs/ubcs-server}") + private String PARENTPATH; + + /** + * 鏃ュ織鏂囦欢鐨勫叿浣撲綅缃� + */ + @Value("${local-log.log-path:/target/log}") + private String LOGPATH; + + /** + * 鏍规嵁鎿嶄綔绯荤粺鐢熸垚鍒嗛殧绗� + */ + private String SEPARATOR = "/"; + + /** + * 鏍规嵁褰撳墠杩愯鐨勭幆澧冿紝瀵归厤缃殑鏃ュ織璺緞鏍煎紡杩涜璋冩暣 + * @param environment + */ + @Override + public void setEnvironment(Environment environment) { + String os = environment.getProperty("os.name").toLowerCase(); + if (!os.contains("win")) { + this.SEPARATOR = "/"; + }else{ + this.SEPARATOR = "\\"; + } + } @Override public List<DeployAppsVO> getApplications(ServletRequest servletRequest) throws ServiceException { @@ -80,12 +133,252 @@ deployAppsVO.setStatusTimestamp(jsonObject.get("statusTimestamp").toString()); deployAppsVOList.add(deployAppsVO); } - } }catch (Exception e){ throw new ServiceException("璋冪敤ubcs-admin鑾峰彇鏈嶅姟淇℃伅澶辫触锛屽師鍥狅細"+e.getMessage()); } + // 鍐嶆煡璇㈠簱涓凡缁忓瓨鍦ㄧ殑鏈嶅姟閰嶇疆淇℃伅锛岃繘琛屾槸鍚﹀凡缁忓惎鍔ㄧ殑鍒ゆ柇 + List<DeployApps> deployApps = deployAppsMapper.selectList(null); + // 搴撲腑鏈厤缃紝鐩存帴杩斿洖姝e湪杩愯鐨勬湇鍔′俊鎭� + if(deployApps.isEmpty()){ + return deployAppsVOList; + } + // 绛涢�夊嚭涓嶅湪杩愯鐨勫苟鐢熸垚榛樿鐨勬湇鍔′俊鎭� + List<DeployAppsVO> deployAppsVOS1 = deployApps.stream() + .filter(deployApp -> deployAppsVOList.stream() + .noneMatch(deployAppVO -> deployApp.getServerName().equals(deployAppVO.getName()) && + deployApp.getServerName().equals(deployAppVO.getName()))) + .map(deployApp -> { + DeployAppsVO deployAppsVO2 = new DeployAppsVO(deployApp.getServerName(), "DOWN", "", "", 0); + if(deployApp.getServerName().equals("web")){ + deployAppsVO2.setStatus("UP"); + deployAppsVO2.setPort("8080"); + deployAppsVO2.setServiceNum(1); + } + return deployAppsVO2; + }) + .collect(Collectors.toList()); + deployAppsVOList.addAll(deployAppsVOS1); return deployAppsVOList; + } + + @Override + public DeployApps saveOrGetServiceConfInfo(DeployAppsVO deployAppsVO) throws ServiceException { + if(deployAppsVO.getName().isEmpty()){ + throw new ServiceException("缂哄皯蹇呬紶鍙傛暟name"); + } + DeployApps deployApps = deployAppsMapper.selectOne(Wrappers.<DeployApps>query().lambda().eq(DeployApps::getServerName, deployAppsVO.getName())); + if(Func.isNotEmpty(deployApps)){ + return deployApps; + } + // 鏈粠搴撲腑鏌ヨ鍒帮紝闇�瑕佺敓鎴愭湇鍔′俊鎭繚瀛橀粯璁や俊鎭埌搴撲腑 + DeployApps defaultDeployApps = new DeployApps(); + defaultDeployApps.setLogPath(PARENTPATH + "\\" + deployAppsVO.getName().replace("-","_") + LOGPATH); + defaultDeployApps.setServerName(deployAppsVO.getName()); + defaultDeployApps.setStartCmd(CmdConfigEnum.START_CMD.getValue() + deployAppsVO.getName()); + defaultDeployApps.setStopCmd(CmdConfigEnum.STOP_CMD.getValue() + deployAppsVO.getName()); + defaultDeployApps.setRestartCmd(CmdConfigEnum.RESTART_CMD.getValue() + deployAppsVO.getName()); + defaultDeployApps.setServerPath(PARENTPATH + "\\" + deployAppsVO.getName().replace("-","_")); + int eft = deployAppsMapper.insert(defaultDeployApps); + if (!SqlHelper.retBool(eft)) { + throw new ServiceException("鐢熸垚榛樿鏈嶅姟淇℃伅鍒板簱涓椂澶辫触锛�"); + } + return defaultDeployApps; + } + + /** + * 淇敼鎴栦繚瀛� + * @param deployAppsVO + * @return + * @throws ServiceException + */ + @Override + public boolean saveOrUpdateServiceInfo(DeployAppsVO deployAppsVO) throws ServiceException { + boolean b = this.saveOrUpdate(deployAppsVO); + return b; + } + + /** + * 鏂板鏈嶅姟淇℃伅 + * @param deployApps + * @return + * @throws ServiceException + */ + @Override + public boolean addSave(DeployApps deployApps) throws ServiceException { + if (Func.isBlank(deployApps.getServerName()) || Func.isBlank(deployApps.getServerPath())) { + throw new ServiceException("蹇呬紶鍙傛暟[鏈嶅姟鍚嶇О锛屾湇鍔″瓨鏀捐矾寰刔涓嶈兘涓虹┖"); + } + return SqlHelper.retBool(deployAppsMapper.insert(deployApps)); + } + + /** + * 鏇存柊鏂囦欢涓婁紶 + * @param files + * @param serverName + * @return + */ + @Override + public R importClassify(MultipartFile[] files, String serverName) throws ServiceException { + // 鏍规嵁鏈嶅姟鍚嶆煡鐪嬪埌鏈嶅姟鐩稿叧淇℃伅 + List<DeployApps> deployAppsDB = deployAppsMapper.selectList(Wrappers.<DeployApps>query().lambda().eq(DeployApps::getServerName, serverName)); + if(deployAppsDB.isEmpty()){ + return R.fail("No configuration information related to "+ serverName +" service found"); + } + // 閬嶅巻MultipartFile鏁扮粍锛岄�愪釜澶勭悊鏂囦欢 + try { + for (MultipartFile file : files) { + // 閰嶇疆浜嗗浠芥枃浠惰矾寰勶紝鍏堝浠藉啀鏇挎崲 + if(Func.isNotEmpty(deployAppsDB.get(0).getFileBack())){ + File backFile = new File(deployAppsDB.get(0).getFileBack()); + // 璺緞涓嶅瓨鍦ㄥ氨鍒涘缓 + if (!backFile.exists()) { + backFile.mkdirs(); + } + String backName = ""; + String fileType = "file"; + // 鏄帇缂╂枃浠�,鍥犱负鍙細瀛樺湪涓ょ鎯呭喌锛屾枃浠跺悕鏄帇缂╂枃浠讹紝鎴栬�呮枃浠讹紙.jar绫诲瀷鐨勬枃浠讹級 + if (file.getContentType().equals("application/zip") || file.getContentType().equals("application/x-zip-compressed")) { + backName = file.getOriginalFilename().replace(".zip","_"+Func.formatDate(new Date())); + fileType = "zip"; + }else{ + backName = file.getOriginalFilename().replace(".","_"+Func.formatDate(new Date())+"."); + fileType = "file"; + } + File source = new File(deployAppsDB.get(0).getServerPath() + this.SEPARATOR + file.getOriginalFilename().replace(".zip", "")); + File destination = new File(deployAppsDB.get(0).getFileBack() + this.SEPARATOR + backName); + copyFolder(source, destination); + } + Path filePath = Paths.get(deployAppsDB.get(0).getServerPath(), file.getOriginalFilename()); + Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING); + // 妫�鏌ユ枃浠剁被鍨嬶紝濡傛灉鏄帇缂╂枃浠跺垯瑙e帇缂� + if (file.getContentType().equals("application/zip") || file.getContentType().equals("application/x-zip-compressed")) { + //sourcePath鍘嬬缉鍖呮枃浠惰矾寰� + try (ZipFile zipFile = new ZipFile(new File(deployAppsDB.get(0).getServerPath()+ this.SEPARATOR +file.getOriginalFilename()))) { + Enumeration enumeration = zipFile.entries(); + while (enumeration.hasMoreElements()) { + //渚濇鑾峰彇鍘嬬缉鍖呭唴鐨勬枃浠跺疄浣撳璞� + ZipEntry entry = (ZipEntry) enumeration.nextElement(); + String name = entry.getName(); + if (entry.isDirectory()) { + continue; + } + try (BufferedInputStream inputStream = new BufferedInputStream(zipFile.getInputStream(entry))) { + // 闇�瑕佸垽鏂枃浠舵墍鍦ㄧ殑鐩綍鏄惁瀛樺湪锛屽鐞嗗帇缂╁寘閲岄潰鏈夋枃浠跺す鐨勬儏鍐� + String outName = deployAppsDB.get(0).getServerPath() + this.SEPARATOR + name; + File outFile = new File(outName); + File tempFile = new File(outName.substring(0, outName.lastIndexOf("/"))); + if (!tempFile.exists()) { + tempFile.mkdirs(); + } + try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outFile))) { + int len; + byte[] buffer = new byte[1024]; + while ((len = inputStream.read(buffer)) > 0) { + outputStream.write(buffer, 0, len); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + File file1 = new File(deployAppsDB.get(0).getServerPath() + SEPARATOR + file.getOriginalFilename()); + // 鍘嬬缉鏂囦欢涓婁紶鎴愬姛涔嬪悗锛屽垹闄よВ鍘嬫枃浠� + file1.delete(); + } + } + String output = excute(deployAppsDB.get(0),"UP"); + return R.success(output.toString()); + } catch (IOException e) { + e.printStackTrace(); + log.error(e.getMessage()); + return R.fail("Failed to upload files"); + } + + } + + /** + * 鎵ц鍛戒护 + * @param deployAppsVO + * @return + */ + @Override + public R cmdExecute(DeployAppsVO deployAppsVO) throws ServiceException { + String excuteRes = ""; + try { + List<DeployApps> deployAppsDB = deployAppsMapper.selectList(Wrappers.<DeployApps>query().lambda().eq(DeployApps::getServerName, deployAppsVO.getName())); + if(deployAppsDB.isEmpty()){ + return R.fail("鍛戒护鎵ц鍑洪敊锛屽簱涓湭鎵惧埌"+ deployAppsVO.getName() +"鏈嶅姟鐩稿叧閰嶇疆锛�" ); + } + excuteRes = excute(deployAppsDB.get(0),deployAppsVO.getStatus()); + return R.success("鍛戒护鎵ц缁撴潫锛�"+excuteRes); + }catch (Exception e){ + throw new ServiceException(e.getMessage()); + } + } + + /** + * 鎵ц鍛戒护 + * @param deployApps + * @return + * @throws ServiceException + */ + private String excute(DeployApps deployApps,String type) throws ServiceException { + // 澶勭悊涓婁紶鏂囦欢鐨勯�昏緫 + StringBuilder output = new StringBuilder(); + try { + String cmd = ""; + if(type.equalsIgnoreCase("UP")){ + cmd = deployApps.getRestartCmd(); + }else { + cmd = deployApps.getStartCmd(); + } + if(Func.isEmpty(cmd)){ + return "The executed command is empty"; + } + // 鎵цLinux鍛戒护 + Process process = Runtime.getRuntime().exec(cmd); + // 璇诲彇鍛戒护鎵ц缁撴灉 + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + output.append(line).append("\n"); + } + // 绛夊緟鍛戒护鎵ц瀹屾垚 + int exitCode = process.waitFor(); + log.info("鍛戒护鎵ц缁撴灉锛�" + output.toString()); + return output.toString(); + }catch (IOException | InterruptedException e){ + e.printStackTrace(); + log.error("鍛戒护鎵ц鍑洪敊锛屽師鍥狅細" + e.getMessage()); + throw new ServiceException("Command execution failed"+e.getMessage()); + } + } + + /** + * 鏂囦欢澶囦唤鎿嶄綔 + * @param source 婧愭枃浠� + * @param destination 鏂囦欢澶囦唤璺緞 + * @throws IOException + */ + private void copyFolder(File source, File destination) throws IOException { + // 鏂囦欢瀛樺湪鎵嶉渶瑕佸浠� + if(source.exists()){ + if (source.isDirectory()) { + if (!destination.exists()) { + destination.mkdir(); + } + String[] files = source.list(); + for (String file : files) { + File srcFile = new File(source, file); + File destFile = new File(destination, file); + copyFolder(srcFile, destFile); + } + } else { + Files.copy(source.toPath(), destination.toPath()); + } + } } /** @@ -93,7 +386,7 @@ * @param serviceId * @return */ - public String getGatewayPort(String serviceId) { + private String getGatewayPort(String serviceId) { List<ServiceInstance> instances = discoveryClient.getInstances(serviceId); if (!instances.isEmpty()) { ServiceInstance gatewayInstance = instances.get(0); @@ -101,6 +394,5 @@ } return "8080"; } - } -- Gitblit v1.9.3