Commit b1bdcfd0 authored by 赵啸非's avatar 赵啸非

添加客户端资源部署

parent 24e0834c
......@@ -24,7 +24,7 @@
"jsencrypt": "3.0.0-rc.1",
"json-bigint": "^0.3.0",
"muse-ui": "^3.0.2",
"nprogress": "0.2.0",
"nprogress": "^0.2.0",
"quill": "1.3.7",
"screenfull": "5.0.2",
"sockjs-client": "^1.5.1",
......
......@@ -3,6 +3,9 @@ import Router from 'vue-router'
import Store from './store'
import Layout from './views/Layout.vue'
import fileNotFound from './views/errors/fileNotFound.vue'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
NProgress.configure({ showSpinner: false })
Vue.use(Router);
......@@ -49,6 +52,7 @@ const router = new Router({
...restBuilder('device/alarm/info', 'device/alarm/info'),//设备告警信息
...restBuilder('device/module', 'device/module'),//设备模块使用率
...restBuilder('device/module/use', 'device/module/use'),//设备模块使用率
...restBuilder('device/module/distribute', 'device/module/distribute'),//设备前端模块部署
...restBuilder('device/log', 'device/log'),//
......@@ -128,6 +132,7 @@ function ssoCheck(to, from, next) {
router.afterEach(() => {
document.body.scrollTop = 0
document.documentElement.scrollTop = 0
NProgress.done()
})
// 路由鉴权
......@@ -135,6 +140,7 @@ router.beforeEach((to, from, next) => {
// if (ssoCheck(to, from, next)) { //sso鉴权检查
// return
// }
NProgress.start()
if (to.matched.some(record => record.meta.requiresAuth)) {
if (Store.state.isLogin) {
next();
......
......@@ -42,6 +42,9 @@ export default {
<style lang="less">
.page {
min-height: calc(100vh - 100px);
width: 100%;
position: relative;
background: #fff;
padding: var(--padding-top) 5px 5px 5px;
......
......@@ -421,7 +421,7 @@ public class MenuEntity extends BaseEntityLong{
this.name = null;
this.url = null;
this.parentId = null;
this.orderId = null;
this.orderId = 0;
this.status = 1;
this.linkType = 0;
this.groupId = 1;
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 是否部署(0.否,1.是)枚举类
*
* @author zxfei
*/
public enum DistributeEnum {
(0, "否"),
(1, "是");
private Integer value;
private String desc;
DistributeEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static DistributeEnum getByValue(Integer value) {
for (DistributeEnum distributeEnum : DistributeEnum.values()) {
if (distributeEnum.getValue() == value) {
return distributeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (DistributeEnum item : DistributeEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
public enum ImageReEnum {
RE_1920X1080(0, "1920x1080"),
RE_1080X1920(1, "1080x1920"),
RE_1280X1280(2, "1280x1280");
private Integer value;
private String desc;
ImageReEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static ImageReEnum getByValue(Integer value) {
for (ImageReEnum distributeEnum : ImageReEnum.values()) {
if (distributeEnum.getValue() == value) {
return distributeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (ImageReEnum item : ImageReEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
......@@ -112,6 +112,6 @@ public final class Constant {
*/
public static final String PATH_SITETREE = "site/siteTree";
public static final String DISTRIBUTE_PATH = "distribute_path";
}
package com.mortals.xhx.module.device.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
import java.util.List;
/**
* 设备前端模块部署Dao
* 设备前端模块部署 DAO接口
*
* @author zxfei
* @date 2022-08-02
*/
public interface DeviceModuleDistributeDao extends ICRUDDao<DeviceModuleDistributeEntity,Long>{
}
package com.mortals.xhx.module.device.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.device.dao.DeviceModuleDistributeDao;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 设备前端模块部署DaoImpl DAO接口
*
* @author zxfei
* @date 2022-08-02
*/
@Repository("deviceModuleDistributeDao")
public class DeviceModuleDistributeDaoImpl extends BaseCRUDDaoMybatis<DeviceModuleDistributeEntity,Long> implements DeviceModuleDistributeDao {
}
package com.mortals.xhx.module.device.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.vo.DeviceModuleDistributeVo;
/**
* 设备前端模块部署实体对象
*
* @author zxfei
* @date 2022-08-02
*/
public class DeviceModuleDistributeEntity extends DeviceModuleDistributeVo {
private static final long serialVersionUID = 1L;
/**
* 产品Id
*/
private Long productId;
/**
* 产品编码
*/
private String productCode;
/**
* 产品名称
*/
private String productName;
/**
* 分辨率
*/
private String imageResolution;
/**
* 分辨率值
*/
@Excel(name = "分辨率值")
private String imageResolutionValue;
/**
* 文件相对路径地址
*/
@Excel(name = "文件相对路径地址")
private String filePath;
/**
* 文件部署路径地址
*/
@Excel(name = "文件部署路径地址")
private String distributeFilePath;
/**
* 版本号
*/
@Excel(name = "版本号")
private String version;
/**
* 是否部署(0.否,1.是)
*/
@Excel(name = "是否部署", readConverterExp = "0=否,1=是")
private Integer distribute;
public DeviceModuleDistributeEntity(){}
/**
* 获取 产品Id
* @return Long
*/
public Long getProductId(){
return productId;
}
/**
* 设置 产品Id
* @param productId
*/
public void setProductId(Long productId){
this.productId = productId;
}
/**
* 获取 产品编码
* @return String
*/
public String getProductCode(){
return productCode;
}
/**
* 设置 产品编码
* @param productCode
*/
public void setProductCode(String productCode){
this.productCode = productCode;
}
/**
* 获取 产品名称
* @return String
*/
public String getProductName(){
return productName;
}
/**
* 设置 产品名称
* @param productName
*/
public void setProductName(String productName){
this.productName = productName;
}
/**
* 获取 分辨率
* @return String
*/
public String getImageResolution(){
return imageResolution;
}
/**
* 设置 分辨率
* @param imageResolution
*/
public void setImageResolution(String imageResolution){
this.imageResolution = imageResolution;
}
/**
* 获取 分辨率值
* @return String
*/
public String getImageResolutionValue(){
return imageResolutionValue;
}
/**
* 设置 分辨率值
* @param imageResolutionValue
*/
public void setImageResolutionValue(String imageResolutionValue){
this.imageResolutionValue = imageResolutionValue;
}
/**
* 获取 文件相对路径地址
* @return String
*/
public String getFilePath(){
return filePath;
}
/**
* 设置 文件相对路径地址
* @param filePath
*/
public void setFilePath(String filePath){
this.filePath = filePath;
}
/**
* 获取 文件部署路径地址
* @return String
*/
public String getDistributeFilePath(){
return distributeFilePath;
}
/**
* 设置 文件部署路径地址
* @param distributeFilePath
*/
public void setDistributeFilePath(String distributeFilePath){
this.distributeFilePath = distributeFilePath;
}
/**
* 获取 版本号
* @return String
*/
public String getVersion(){
return version;
}
/**
* 设置 版本号
* @param version
*/
public void setVersion(String version){
this.version = version;
}
/**
* 获取 是否部署(0.否,1.是)
* @return Integer
*/
public Integer getDistribute(){
return distribute;
}
/**
* 设置 是否部署(0.否,1.是)
* @param distribute
*/
public void setDistribute(Integer distribute){
this.distribute = distribute;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof DeviceModuleDistributeEntity) {
DeviceModuleDistributeEntity tmp = (DeviceModuleDistributeEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",productId:").append(getProductId());
sb.append(",productCode:").append(getProductCode());
sb.append(",productName:").append(getProductName());
sb.append(",imageResolution:").append(getImageResolution());
sb.append(",imageResolutionValue:").append(getImageResolutionValue());
sb.append(",filePath:").append(getFilePath());
sb.append(",distributeFilePath:").append(getDistributeFilePath());
sb.append(",version:").append(getVersion());
sb.append(",distribute:").append(getDistribute());
return sb.toString();
}
public void initAttrValue(){
this.productId = null;
this.productCode = "";
this.productName = "";
this.imageResolution = "";
this.imageResolutionValue = "";
this.filePath = "";
this.distributeFilePath = "";
this.version = "";
this.distribute = 0;
}
}
\ No newline at end of file
package com.mortals.xhx.module.device.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 设备前端模块部署视图对象
*
* @author zxfei
* @date 2022-08-02
*/
public class DeviceModuleDistributeVo extends BaseEntityLong {
}
\ No newline at end of file
package com.mortals.xhx.module.device.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
/**
* DeviceModuleDistributeService
*
* 设备前端模块部署 service接口
*
* @author zxfei
* @date 2022-08-02
*/
public interface DeviceModuleDistributeService extends ICRUDService<DeviceModuleDistributeEntity,Long>{
void active(DeviceModuleDistributeEntity distributeEntity, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.device.service.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ZipUtil;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.common.code.ImageReEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.device.dao.DeviceModuleDistributeDao;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
import com.mortals.xhx.module.device.service.DeviceModuleDistributeService;
import java.io.File;
import java.util.Date;
import java.util.zip.ZipEntry;
/**
* DeviceModuleDistributeService
* 设备前端模块部署 service实现
*
* @author zxfei
* @date 2022-08-02
*/
@Service("deviceModuleDistributeService")
public class DeviceModuleDistributeServiceImpl extends AbstractCRUDServiceImpl<DeviceModuleDistributeDao, DeviceModuleDistributeEntity, Long> implements DeviceModuleDistributeService {
@Autowired
private ProductService productService;
@Override
protected void saveBefore(DeviceModuleDistributeEntity entity, Context context) throws AppException {
ProductEntity productEntity = productService.get(entity.getProductId(), context);
entity.setProductCode(productEntity.getProductCode());
entity.setProductName(productEntity.getProductName());
super.saveBefore(entity, context);
}
@Override
public void active(DeviceModuleDistributeEntity distributeEntity, Context context) {
//判断文件是否存在
if (FileUtil.isEmpty(new File(distributeEntity.getFilePath()))) {
throw new AppException("部署文件不存在!");
}
if (!FileUtil.getSuffix(distributeEntity.getFilePath()).equals("zip")) {
throw new AppException("部署只支持zip文件!");
}
//部署路径是否存在 如果不存在 创建目录,
String path = GlobalSysInfo.getParamValue(Constant.DISTRIBUTE_PATH, "/home/publish/device-new-manager-ui/homeDeviceUrl");
String code = distributeEntity.getProductCode();
String imageRe = distributeEntity.getImageResolutionValue();
String disPath = "/" + path + "/" + code + "/" + imageRe;
//判断目标目录是否存在 如果存在 这删除
if (FileUtil.isDirectory(disPath)) {
FileUtil.del(disPath);
}
ZipUtil.unzip(distributeEntity.getFilePath(), disPath);
//更新
distributeEntity.setDistributeFilePath(disPath);
distributeEntity.setDistribute(YesNoEnum.YES.getValue());
distributeEntity.setUpdateTime(new Date());
this.update(distributeEntity, context);
}
}
\ No newline at end of file
package com.mortals.xhx.module.device.web;
import com.mortals.framework.common.Rest;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.ImageReEnum;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
import com.mortals.xhx.module.device.service.DeviceModuleDistributeService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 设备前端模块部署
*
* @author zxfei
* @date 2022-08-02
*/
@RestController
@RequestMapping("device/module/distribute")
public class DeviceModuleDistributeController extends BaseCRUDJsonBodyMappingController<DeviceModuleDistributeService,DeviceModuleDistributeEntity,Long> {
@Autowired
private ParamService paramService;
@Autowired
private ProductService productService;
public DeviceModuleDistributeController(){
super.setModuleDesc( "设备前端模块部署");
}
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "distribute", paramService.getParamBySecondOrganize("DeviceModuleDistribute","distribute"));
this.addDict(model, "productId", productService.find(new ProductEntity()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getProductName())));
this.addDict(model, "imageResolution", ImageReEnum.getEnumMap());
super.init(model, context);
}
/**
* 部署
*/
@PostMapping(value = "active")
public Rest<Void> deviceActive(@RequestBody DeviceModuleDistributeEntity moduleDistributeEntity) {
String busiDesc = this.getModuleDesc() + "设备模块部署";
Rest<Void> rest = Rest.ok(busiDesc + " 【成功】");
try {
this.service.active(moduleDistributeEntity, getContext());
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error("设备模块部署", e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment