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

添加产品资源枚举类

parent e730a628
...@@ -2,6 +2,7 @@ package com.mortals.xhx.daemon.task; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.daemon.task;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
...@@ -47,23 +48,29 @@ public class CheckProjectStatusTaskImpl implements ITaskExcuteService { ...@@ -47,23 +48,29 @@ public class CheckProjectStatusTaskImpl implements ITaskExcuteService {
//todo http://192.168.0.250:8848/nacos/v1/ns/catalog/instances?message=true&serviceName=bill-manager&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov //todo http://192.168.0.250:8848/nacos/v1/ns/catalog/instances?message=true&serviceName=bill-manager&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov
String serverUrl = nacosUrl + "/nacos/v1/ns/catalog/instances?message=true&serviceName=" + setupProjectEntity.getProjectCode() + "&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov"; String serverUrl = nacosUrl + "/nacos/v1/ns/catalog/instances?message=true&serviceName=" + setupProjectEntity.getProjectCode() + "&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov";
String resp = HttpUtil.get(serverUrl); String resp = HttpUtil.get(serverUrl);
NacosResponse nacosResponse = JSON.parseObject(resp, new TypeReference<NacosResponse>() {
}); try {
int count = nacosResponse.getCount(); NacosResponse nacosResponse = JSON.parseObject(resp, new TypeReference<NacosResponse>() {
if (count > 0) { });
ListItem item = nacosResponse.getList().get(0); int count = nacosResponse.getCount();
String serviceName = item.getServiceName(); if (count > 0) {
boolean healthy = item.isHealthy(); ListItem item = nacosResponse.getList().get(0);
if (healthy) { boolean healthy = item.isHealthy();
setupProjectEntity.setProjectStatus(ProjectStatusEnum.运行中.getValue()); if (healthy) {
} else { setupProjectEntity.setProjectStatus(ProjectStatusEnum.运行中.getValue());
setupProjectEntity.setProjectStatus(ProjectStatusEnum.停止.getValue()); } else {
setupProjectEntity.setProjectStatus(ProjectStatusEnum.停止.getValue());
}
setupProjectEntity.setUpdateTime(new Date());
setupProjectService.update(setupProjectEntity);
} }
setupProjectEntity.setUpdateTime(new Date());
setupProjectService.update(setupProjectEntity); log.info("服务实例详细查询url:{},返回:{},naocsResponse:{}", serverUrl, resp, JSON.toJSONString(nacosResponse));
} catch (JSONException e) {
log.info("json反序列化异常:{},返回:{}", e.getMessage(), resp);
} }
log.info("服务实例详细查询url:{},返回:{},naocsResponse:{}", serverUrl, resp, JSON.toJSONString(nacosResponse));
} else if (ProjectTypeEnum.前端.getValue() == setupProjectEntity.getProjectType()) { } else if (ProjectTypeEnum.前端.getValue() == setupProjectEntity.getProjectType()) {
//todo 前端 判断路径文件是否存在 如果存在 则代表运行 //todo 前端 判断路径文件是否存在 如果存在 则代表运行
...@@ -75,7 +82,7 @@ public class CheckProjectStatusTaskImpl implements ITaskExcuteService { ...@@ -75,7 +82,7 @@ public class CheckProjectStatusTaskImpl implements ITaskExcuteService {
setupProjectEntity.setProjectStatus(ProjectStatusEnum.运行中.getValue()); setupProjectEntity.setProjectStatus(ProjectStatusEnum.运行中.getValue());
setupProjectEntity.setUpdateTime(new Date()); setupProjectEntity.setUpdateTime(new Date());
setupProjectService.update(setupProjectEntity); setupProjectService.update(setupProjectEntity);
}else{ } else {
setupProjectEntity.setProjectStatus(ProjectStatusEnum.未部署.getValue()); setupProjectEntity.setProjectStatus(ProjectStatusEnum.未部署.getValue());
setupProjectEntity.setUpdateTime(new Date()); setupProjectEntity.setUpdateTime(new Date());
setupProjectService.update(setupProjectEntity); setupProjectService.update(setupProjectEntity);
......
...@@ -186,7 +186,16 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec ...@@ -186,7 +186,16 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
throw new AppException("请上传项目工程文件!"); throw new AppException("请上传项目工程文件!");
} }
InputStream inputStream = FileUtil.getInputStream(file); InputStream inputStream = FileUtil.getInputStream(file);
ZipUtil.unzip(inputStream, destDir, Charset.defaultCharset());
//获取zip的编码
try {
ZipUtil.unzip(inputStream, destDir, Charset.defaultCharset());
}catch (IllegalArgumentException e){
log.error("zip文件编码异常,尝试使用GBK编码,异常:{}",e.getMessage());
ZipUtil.unzip(inputStream, destDir, Charset.forName("GBK"));
}
String publicPath = setupProjectEntity.getProjectPath() + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getValue(); String publicPath = setupProjectEntity.getProjectPath() + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getValue();
File sqlPath = new File(publicPath + "/base.sql"); File sqlPath = new File(publicPath + "/base.sql");
......
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