Commit 28fa08bb authored by 赵啸非's avatar 赵啸非

添加批量激活设备

parent a39d92e1
......@@ -45,6 +45,19 @@ export default {
});
},
distribute(row) {
this.$post("/product/publish", row)
.then((res) => {
if (res.code == 1) {
this.$message.success("应用发布成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
},
// beforeRouteEnter(to, from, next) {next(vm => {
// // 通过 `vm` 访问组件实例
......@@ -91,6 +104,16 @@ export default {
onView={this.toView}
onDel={this.toDel}
/>
<el-button
size="mini"
type="text"
icon="el-icon-open"
onClick={() => {
this.distribute(row);
}}
>
发布
</el-button>
<span> </span>
<el-button
size="mini"
......
......@@ -97,6 +97,7 @@
afterSubmit(data) {
this.open = false;
this.reset()
this.$emit("ok");
},
......
......@@ -131,9 +131,9 @@ public class AppPublishServiceImpl extends AbstractCRUDServiceImpl<AppPublishDao
ZipUtil.unzip(targetFilePath, disPath, Charset.forName(fileEncode));
String scriptPath = "/home/temp/" + appPublishEntity.getAppCode() + "/deploy.sh";
// RuntimeUtil.exec("chmod 755 "+scriptPath);
ProcessBuilder sh = new ProcessBuilder("sh",scriptPath);
ProcessBuilder sh = new ProcessBuilder("sh", scriptPath);
File file = new File("/home/temp/" + appPublishEntity.getAppCode() + "/deploy.sh");
asynExeLocalComand(null, sh);
asynExeLocalComand(file, sh);
}
this.update(appPublishEntity, context);
......@@ -141,8 +141,6 @@ public class AppPublishServiceImpl extends AbstractCRUDServiceImpl<AppPublishDao
}
public void asynExeLocalComand(File file, ProcessBuilder pb) throws IOException {
// 不使用Runtime.getRuntime().exec(command)的方式,因为无法设置以下特性
// Java执行本地命令是启用一个子进程处理,默认情况下子进程与父进程I/O通过管道相连(默认ProcessBuilder.Redirect.PIPE)
......
......@@ -14,4 +14,7 @@ public interface ProductService extends ICRUDService<ProductEntity,Long>{
void upGrade(Long productId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.product.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
/**
* ProductVersionService
*
......@@ -11,4 +14,6 @@ import com.mortals.xhx.module.product.model.ProductVersionEntity;
*/
public interface ProductVersionService extends ICRUDService<ProductVersionEntity,Long>{
void appPublish(ProductVersionEntity productVersionEntity, Context context);
}
\ No newline at end of file
......@@ -65,21 +65,23 @@ public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVe
}
}
/*
@Override
protected void saveAfter(ProductVersionEntity entity, Context context) throws AppException {
//推送消息
pushUpgradMsg(entity, context);
super.saveAfter(entity, context);
pushUpgradMsg(entity, context);
}
@Override
protected void updateAfter(ProductVersionEntity entity, Context context) throws AppException {
pushUpgradMsg(entity, context);
super.updateAfter(entity, context);
pushUpgradMsg(entity, context);
}
*/
private void pushUpgradMsg(ProductVersionEntity entity, Context context) {
......@@ -112,4 +114,9 @@ public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVe
}
}
}
@Override
public void appPublish(ProductVersionEntity productVersionEntity, Context context) {
pushUpgradMsg(productVersionEntity, context);
}
}
\ No newline at end of file
package com.mortals.xhx.module.product.web;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
import com.mortals.xhx.module.product.model.ProductVersionQuery;
import com.mortals.xhx.module.product.service.ProductService;
import com.mortals.xhx.module.product.service.ProductVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
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.product.model.ProductVersionEntity;
import com.mortals.xhx.module.product.service.ProductVersionService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.*;
import java.util.Date;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 产品客户端版本
......@@ -54,7 +48,6 @@ public class ProductVersionController extends BaseCRUDJsonBodyMappingController<
@Override
protected void saveBefore(ProductVersionEntity entity, Map<String, Object> model, Context context) throws AppException {
ProductVersionEntity productVersionEntity = this.service.selectOne(new ProductVersionQuery().productId(entity.getProductId()).version(entity.getVersion()));
if(!ObjectUtils.isEmpty(productVersionEntity)){
entity.setId(productVersionEntity.getId());
......@@ -63,4 +56,26 @@ public class ProductVersionController extends BaseCRUDJsonBodyMappingController<
}
super.saveBefore(entity, model, context);
}
/**
* 发布
*/
@PostMapping(value = "publish")
public Rest<Void> producePublish(@RequestBody ProductVersionEntity productVersionEntity) {
String busiDesc = this.getModuleDesc() + "应用发布";
Rest<Void> rest = Rest.ok(busiDesc + " 【成功】");
try {
ProductVersionEntity entity = this.service.get(productVersionEntity.getId());
if(ObjectUtils.isEmpty(entity)){
throw new AppException("应用不存在!");
}
this.service.appPublish(productVersionEntity, 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