| | |
| | | } |
| | | |
| | | //æå¨åæ¥ |
| | | export const syncSearch = (data) => { |
| | | export const syncSearch = (params) => { |
| | | return request({ |
| | | url: '/api/ubcs-code/dockingManagement/searchItemDataForERP', |
| | | method: 'post', |
| | | data |
| | | params |
| | | }) |
| | | } |
| | |
| | | |
| | | 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 |
| | | }) |
| | | } |
| | |
| | | watch:{ |
| | | visible:{ |
| | | handler(newval,oldval){ |
| | | console.log('newval',newval) |
| | | // console.log('newval',newval) |
| | | } |
| | | } |
| | | }, |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-dialog |
| | | title="æå¡æ´æ°jarå
导å
¥" |
| | | :visible.sync="dialogVisible" |
| | | append-to-body |
| | | > |
| | | <Divider text="æ´æ°æç¤º" left="30px"></Divider> |
| | | <ul> |
| | | <li> |
| | | 1.ä¸ä¼ jaræä»¶æ¶è¯·ç¡®å®jaræä»¶åç§°æ£ç¡®ï¼æå¥½ç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> |
| | |
| | | search: true, |
| | | searchLabelWidth: 45, |
| | | searchSpan: 4, |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥ç¼å·", |
| | | trigger: "blur", |
| | | }] |
| | | }, |
| | | { |
| | | label: "åç§°", |
| | |
| | | search: true, |
| | | searchLabelWidth: 45, |
| | | searchSpan: 4, |
| | | // rules: [{ |
| | | // required: true, |
| | | // message: "åç§°", |
| | | // trigger: "blur", |
| | | // }] |
| | | }, |
| | | { |
| | | label: "æºå¼", |
| | |
| | | search: true, |
| | | searchLabelWidth: 45, |
| | | searchSpan: 4, |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥æºå¼", |
| | | trigger: "blur", |
| | | }] |
| | | }, |
| | | { |
| | | label: "è¿ä¹è¯", |
| | |
| | | search: true, |
| | | searchLabelWidth: 60, |
| | | searchSpan: 4, |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥è¿ä¹è¯", |
| | | trigger: "blur", |
| | | }] |
| | | }, |
| | | { |
| | | label: "ç¶æ", |
| | |
| | | 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' |
| | | // å°å·¥å
·å½æ°æ·»å å°å
¨å± |
| | |
| | | Vue.component('ThemeImport', ThemeImport) |
| | | Vue.component('maxSerialnumDialog', maxSerialnumDialog) |
| | | Vue.component('VciDockingSearch', VciDockingSearch) |
| | | Vue.component('uploadServiceJarDialog', uploadServiceJarDialog) |
| | | |
| | | // å è½½ç¸å
³urlå°å |
| | | Object.keys(urls).forEach(key => { |
| | |
| | | getadd, |
| | | getupdata, |
| | | getremove, |
| | | combination |
| | | } from "@/api/system/passwords"; |
| | | import {mapGetters} from "vuex"; |
| | | |
| | |
| | | <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}" |
| | |
| | | <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() { |
| | |
| | | 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: "请è¾å
¥æå¡jaråæ¾çè·¯å¾", |
| | | trigger: "blur" |
| | | }] |
| | | },{ |
| | | label: "æ¥å¿æä»¶åæ¾ä½ç½®", |
| | | prop: "logPath", |
| | | labelWidth: 140, |
| | | hide: true, |
| | | disabled: true, |
| | | rules: [{ |
| | | required: false, |
| | | message: "请è¾å
¥æå¡jaråæ¾çè·¯å¾", |
| | | 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); |
| | | // å°æ¶é´è½¬æ¢ä¸ºæ¬å°æ¶é´ |
| | |
| | | this.data.push(element) |
| | | }); |
| | | } |
| | | this.loading = false; |
| | | //console.log(res.data.data); |
| | | }); |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | // æ§å¶ç¤ºä¾åç§°æ¯å¦å¯è¾å
¥ |
| | | 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 |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | } |
| | | } |
| | |
| | | * æ¯å¦æåç |
| | | */ |
| | | private boolean success ; |
| | | |
| | | /** |
| | | * å
³é®å±æ§æ ¡éªè§åçä¿¡æ¯ |
| | | */ |
| | |
| | | * å
³é®å±æ§æ ¡éªåï¼éå¤çè¡å· |
| | | */ |
| | | private Set<String> keyAttrRepeatRowIndexList = new HashSet<>(); |
| | | |
| | | /*** |
| | | * å
³é®å±æ§ç¸åç屿§oidä¸å
¶éå¤çæ°æ®oid |
| | | */ |
| | | private Map<String,List<String>> keyAttrOkOidTORepeatOidMap=new HashMap<>(); |
| | | |
| | | /*** |
| | | * æ ¹æ®å
³é®çææ¥è¯¢çéå¤çæ°æ®å¯¹è±¡ |
| | | */ |
| | | private Map<String, List<BaseModel>> indexTODataMap=new HashMap<>(); |
| | | |
| | | /*** |
| | | * æ ¹æ®å
³é®çææ¥è¯¢çéå¤çæ°æ®å¯¹è±¡ |
| | | */ |
| | |
| | | <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> |
| | |
| | | package com.vci.ubcs.deploy.entity; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * è¿ç¨é¨ç½²è½å¤æ§è¡çå½ä»¤ |
| | |
| | | * @date 2024/1/7 21:37 |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class CmdConfig { |
| | | |
| | | /** |
| | | * å¯å¨ |
| | | */ |
| | | private String startCmd; |
| | | |
| | | /** |
| | | * éå¯ |
| | | */ |
| | | private String restartCmd; |
| | | |
| | | /** |
| | | * 忢 |
| | | */ |
| | | private String stopCmd; |
| | | |
| | | } |
| | |
| | | private String logPath; |
| | | |
| | | /** |
| | | * å½ä»¤é
ç½® |
| | | * å¯å¨ |
| | | */ |
| | | private CmdConfig cmdCofig; |
| | | private String startCmd; |
| | | |
| | | /** |
| | | * éå¯ |
| | | */ |
| | | private String restartCmd; |
| | | |
| | | /** |
| | | * 忢 |
| | | */ |
| | | private String stopCmd; |
| | | |
| | | /** |
| | | * æä»¶å¤ä»½è·¯å¾ |
| | | */ |
| | | private String fileBack; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 æä¸¾å¯¹è±¡ï¼ä¸å卿¶åè¿ånull |
| | | */ |
| | | public static CmdConfigEnum forValue(String value) { |
| | | for (CmdConfigEnum wenum : CmdConfigEnum.values()) { |
| | | if (wenum.getValue().equalsIgnoreCase(value)) { |
| | | return wenum; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | <version>3.0.1.RELEASE</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-test</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | 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.*; |
| | |
| | | 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 ä¸å¡ç±»åçåç§°ï¼ä¼èªå¨åæå°å |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | /** |
| | | * å°è£
è¿ä¹è¯æ¥è¯¢è§å屿§çæ¥è¯¢è¯å¥ |
| | | * @param value å½åçå¼ |
| | | * @param keyRuleVO 屿§çç¼å· |
| | | * @param attrId |
| | | * @param conditionMap æ¥è¯¢æ¡ä»¶ |
| | | */ |
| | | @Override |
| | | public void wrapperSynonymAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO, String attrId, Map<String, String> conditionMap) { |
| | | // mapæé æè·¯ï¼1ãå
宿æ£åæ¿æ¢sqlå¼ |
| | | // 2ãå宿ååæ¿æ¢sqlå¼ |
| | | |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæä¸¾çå
容 |
| | | * |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ï¼éè¦å
å«å±æ§ |
| | |
| | | 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; |
| | |
| | | } |
| | | } |
| | | /** |
| | | * æ ¡éªå
³é®å±æ§ |
| | | * æ ¡éªå
³é®å±æ§ï¼åè¿ä¹è¯æ¥è¯¢è§å |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @param templateVO 模æ¿çå
容ï¼å¿
é¡»å
嫿¨¡æ¿å±æ§ |
| | | * @param cboList æ¹éçæ°æ® |
| | |
| | | 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ï¼å±æ§idï¼valueè¿ä¹è¯æ¥è¯¢è§åå表 |
| | | codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps); |
| | | } |
| | | |
| | | boolean trimAll =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); |
| | | //å
¨é¨å»ç©ºçä¼å
级大äºå»ç©º |
| | |
| | | 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()); |
| | |
| | | value = ""; |
| | | } |
| | | value= value.replace(REQUIRED_CHAR,SPECIAL_CHAR); |
| | | // å
³é®å±æ§æ¥è¯¢æ¡ä»¶mapè·å |
| | | engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); |
| | | // è¿ä¹è¯æ¥è¯¢è§åæ¡ä»¶mapè·å |
| | | //engineService.wrapperSynonymAttrConditionMap(value); |
| | | }); |
| | | |
| | | if (!CollectionUtils.isEmpty(keyAttrMap)) { |
| | | // æ·»å ä¸åä¸å
³é®å±æ§æ ¡éªçåç±»oid夿 |
| | | if(Func.isNotBlank(isParticipateCheckOids)){ |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åè¿ä¹è¯æ¥è¯¢åå¨ç¸åçè¡å· |
| | | * @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 模æ¿ä¸å±æ§åç§°åè±æçæ å° |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private List<ClientBusinessObject> ChangeMapTOClientBusinessObjects(List<Map<String,String>> oldDataMap){ |
| | | List<ClientBusinessObject> clientBusinessObjectList=new ArrayList<>(); |
| | | DefaultAttrAssimtUtil.mapToLowerCase(oldDataMap,true); |
| | |
| | | //ååºFileçä¸äºå¸¸ç¨æä½ |
| | | public class util { |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * éåæå®ç®å½ä¸ï¼å
æ¬å
¶åç®å½ï¼çæææä»¶ï¼å¹¶å é¤ä»¥ lastUpdated ç»å°¾çæä»¶ |
| | | * @param dir ç®å½çä½ç½® path |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @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 æ´æ°çjarææä»¶å¤¹ |
| | | * @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); |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | */ |
| | | public interface IDeployAppsService extends IService<DeployApps> { |
| | | |
| | | /** |
| | | * è·åæ£å¨è¿è¡çæå¡ç¸å
³ä¿¡æ¯ |
| | | * @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; |
| | | |
| | | } |
| | |
| | | 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; |
| | | |
| | | // éè¿æå¡æ³¨åä¸å¿è·åç½å
³ç端å£å· |
| | | /** |
| | | * éè¿æå¡æ³¨åä¸å¿è·åç½å
³ç端å£å· |
| | | */ |
| | | @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 { |
| | |
| | | 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); |
| | | // åºä¸æªé
ç½®ï¼ç´æ¥è¿åæ£å¨è¿è¡çæå¡ä¿¡æ¯ |
| | | 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); |
| | | // æ£æ¥æä»¶ç±»åï¼å¦ææ¯å缩æä»¶åè§£å缩 |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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); |
| | |
| | | } |
| | | return "8080"; |
| | | } |
| | | |
| | | |
| | | } |