Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
9e321361
Commit
9e321361
authored
Feb 02, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加批量激活设备
parent
b9f4de57
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
17 deletions
+52
-17
device-manager-ui/admin/src/views/app/publish/dialogshow.vue
device-manager-ui/admin/src/views/app/publish/dialogshow.vue
+7
-7
device-manager/src/main/java/com/mortals/xhx/module/app/service/impl/AppPublishServiceImpl.java
...ls/xhx/module/app/service/impl/AppPublishServiceImpl.java
+45
-10
No files found.
device-manager-ui/admin/src/views/app/publish/dialogshow.vue
View file @
9e321361
...
@@ -3,13 +3,13 @@
...
@@ -3,13 +3,13 @@
<el-dialog
:title=
"title"
:visible.sync=
"open"
width=
"90%"
append-to-body
>
<el-dialog
:title=
"title"
:visible.sync=
"open"
width=
"90%"
append-to-body
>
<el-form
ref=
"form"
:model=
"form"
:rules=
"rules"
label-width=
"120px"
>
<el-form
ref=
"form"
:model=
"form"
:rules=
"rules"
label-width=
"120px"
>
<el-row>
<el-row>
<Field
label=
"应用编码"
prop=
"appCode"
v-model=
"form.appCode"
type=
"textarea"
placeholder=
"请输入应用编码"
/>
<Field
label=
"应用名称"
prop=
"appName"
v-model=
"form.appName"
type=
"textarea"
placeholder=
"请输入应用名称
"
/>
<Field
label=
"应用名称"
:span=
"20"
prop=
"appName"
type=
"select"
:enumData=
"dict.appPublish"
v-model=
"form.appName"
placeholder=
"请选择应用
"
/>
<Field
label=
"文件路径地址"
><fileUpload
v-model=
"form.filePath"
prePath=
"/file/uploadfile"
/></Field>
<Field
label=
"文件部署路径地址"
><fileUpload
v-model=
"form.distributeFilePath"
prePath=
"/file/uploadfile"
/></Field>
<Field
label=
"应用类型"
prop=
"appType"
v-model=
"form.appType"
type=
"select"
:enumData=
"dict.appType"
placeholder=
"请选择应用类型"
/
>
<Field
:span=
"20"
label=
"文件路径地址"
><fileUpload
v-model=
"form.filePath"
prePath=
"/file/uploadfile"
/></Field
>
<Field
label=
"
是否部署"
prop=
"distribute"
v-model=
"form.distribute"
type=
"select"
:enumData=
"dict.distribute"
placeholder=
"请选择是否部署
"
/>
<Field
label=
"
应用类型"
:span=
"20"
prop=
"appType"
v-model=
"form.appType"
type=
"select"
:enumData=
"dict.appType"
placeholder=
"请选择应用类型
"
/>
<Field
label=
"版本
"
prop=
"version"
v-model=
"form.version"
type=
"textarea"
placeholder=
"请输入版本
"
/>
<Field
label=
"版本
号"
:span=
"20"
prop=
"version"
type=
"num"
v-model=
"form.version"
placeholder=
"请输入版本号
"
/>
</el-row>
</el-row>
...
...
device-manager/src/main/java/com/mortals/xhx/module/app/service/impl/AppPublishServiceImpl.java
View file @
9e321361
...
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ZipUtil;
...
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ZipUtil;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.common.code.AppTypeEnum
;
import
com.mortals.xhx.common.code.AppTypeEnum
;
import
com.mortals.xhx.module.app.dao.AppPublishDao
;
import
com.mortals.xhx.module.app.dao.AppPublishDao
;
...
@@ -16,6 +17,7 @@ import org.springframework.stereotype.Service;
...
@@ -16,6 +17,7 @@ import org.springframework.stereotype.Service;
import
java.io.File
;
import
java.io.File
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.util.Map
;
/**
/**
* AppPublishService
* AppPublishService
...
@@ -30,10 +32,13 @@ public class AppPublishServiceImpl extends AbstractCRUDServiceImpl<AppPublishDao
...
@@ -30,10 +32,13 @@ public class AppPublishServiceImpl extends AbstractCRUDServiceImpl<AppPublishDao
@Autowired
@Autowired
private
UploadService
uploadService
;
private
UploadService
uploadService
;
@Autowired
private
ParamService
paramService
;
@Override
@Override
protected
void
saveBefore
(
AppPublishEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
saveBefore
(
AppPublishEntity
entity
,
Context
context
)
throws
AppException
{
String
targetPath
=
"/home/mortals/apps/"
;
String
targetPath
=
"/home/mortals/apps/"
;
String
fileNewName
=
entity
.
getAppCode
()+
"-"
+
entity
.
getVersion
();
String
fileNewName
=
entity
.
getAppCode
()
+
"-"
+
entity
.
getVersion
();
//将zip包移动到指定目录 并更改名称
//将zip包移动到指定目录 并更改名称
String
realFilePath
=
uploadService
.
getFilePath
(
entity
.
getFilePath
());
String
realFilePath
=
uploadService
.
getFilePath
(
entity
.
getFilePath
());
...
@@ -44,28 +49,58 @@ public class AppPublishServiceImpl extends AbstractCRUDServiceImpl<AppPublishDao
...
@@ -44,28 +49,58 @@ public class AppPublishServiceImpl extends AbstractCRUDServiceImpl<AppPublishDao
throw
new
AppException
(
"部署只支持zip文件!"
);
throw
new
AppException
(
"部署只支持zip文件!"
);
}
}
//移动文件并重命名
//移动文件并重命名
FileUtil
.
move
(
new
File
(
realFilePath
),
new
File
(
targetPath
+
fileNewName
),
true
);
FileUtil
.
move
(
new
File
(
realFilePath
),
new
File
(
targetPath
+
fileNewName
),
true
);
Map
<
String
,
String
>
appPublish
=
paramService
.
getParamByFirstOrganize
(
"appPublish"
);
String
appCode
=
appPublish
.
get
(
entity
.
getAppName
());
entity
.
setAppCode
(
appCode
);
super
.
saveBefore
(
entity
,
context
);
super
.
saveBefore
(
entity
,
context
);
}
}
@Override
protected
void
updateBefore
(
AppPublishEntity
entity
,
Context
context
)
throws
AppException
{
super
.
updateBefore
(
entity
,
context
);
AppPublishEntity
appPublishEntity
=
this
.
get
(
entity
.
getId
());
if
(
entity
.
getFilePath
().
equals
(
appPublishEntity
.
getFilePath
()))
{
String
targetPath
=
"/home/mortals/apps/"
;
String
fileNewName
=
entity
.
getAppCode
()
+
"-"
+
entity
.
getVersion
();
//将zip包移动到指定目录 并更改名称
String
realFilePath
=
uploadService
.
getFilePath
(
entity
.
getFilePath
());
if
(
FileUtil
.
isEmpty
(
new
File
(
realFilePath
)))
{
throw
new
AppException
(
"部署文件不存在!"
);
}
if
(!
FileUtil
.
getSuffix
(
entity
.
getFilePath
()).
equals
(
"zip"
))
{
throw
new
AppException
(
"部署只支持zip文件!"
);
}
//移动文件并重命名
FileUtil
.
move
(
new
File
(
realFilePath
),
new
File
(
targetPath
+
fileNewName
),
true
);
Map
<
String
,
String
>
appPublish
=
paramService
.
getParamByFirstOrganize
(
"appPublish"
);
String
appCode
=
appPublish
.
get
(
entity
.
getAppName
());
entity
.
setAppCode
(
appCode
);
}
}
@Override
@Override
public
void
active
(
AppPublishEntity
appPublishEntity
,
Context
context
)
{
public
void
active
(
AppPublishEntity
appPublishEntity
,
Context
context
)
{
if
(
AppTypeEnum
.
前端
.
getValue
()==
appPublishEntity
.
getAppType
())
{
if
(
AppTypeEnum
.
前端
.
getValue
()
==
appPublishEntity
.
getAppType
())
{
String
targetFilePath
=
uploadService
.
getFilePath
(
appPublishEntity
.
getFilePath
());
String
targetFilePath
=
uploadService
.
getFilePath
(
appPublishEntity
.
getFilePath
());
String
disPath
=
"/home/publish/"
+
appPublishEntity
.
getAppCode
();
String
disPath
=
"/home/publish/"
+
appPublishEntity
.
getAppCode
();
boolean
directory
=
FileUtil
.
isDirectory
(
new
File
(
disPath
));
boolean
directory
=
FileUtil
.
isDirectory
(
new
File
(
disPath
));
if
(
directory
)
{
if
(
directory
)
{
FileUtil
.
del
(
new
File
(
disPath
));
FileUtil
.
del
(
new
File
(
disPath
));
}
}
String
fileEncode
=
"UTF-8"
;
String
fileEncode
=
"UTF-8"
;
try
{
try
{
fileEncode
=
EncodeUtil
.
getEncode
(
targetFilePath
,
true
);
fileEncode
=
EncodeUtil
.
getEncode
(
targetFilePath
,
true
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"异常"
,
e
);
log
.
error
(
"异常"
,
e
);
}
}
ZipUtil
.
unzip
(
targetFilePath
,
disPath
,
Charset
.
forName
(
fileEncode
));
ZipUtil
.
unzip
(
targetFilePath
,
disPath
,
Charset
.
forName
(
fileEncode
));
}
else
{
}
else
{
//后端部署 执行sh 脚本程序部署
//后端部署 执行sh 脚本程序部署
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment