Commit 01893647 authored by mcb's avatar mcb

Merge branch 'dmp_dev' of http://gitlab.ioubuy.cn/yaobenzhang/jz-dmp-service into dmp_dev

parents cc0d2675 5f24ed50
package com.jz.common.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.common.utils.web.SessionUtils;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowExecution;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowPro;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
......@@ -19,11 +20,16 @@ import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.common.utils.web.SessionUtils;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowExecution;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowPro;
import com.jz.dmp.modules.model.DmpMember;
import com.jz.dmp.modules.model.DmpRole;
import com.jz.dmp.modules.model.SSOUserInfo;
/**
* azkaban ajax api 工具类
......@@ -36,6 +42,9 @@ public class AzkabanApiUtils2 {
private String azkabanServerUrl;
private String userName;
private String password;
@Autowired
RedisTemplate<String,SSOUserInfo> redisTemplate;
public AzkabanApiUtils2(String azkabanServerUrl, String userName, String password) {
this(azkabanServerUrl);
......@@ -93,11 +102,42 @@ public class AzkabanApiUtils2 {
throw new RuntimeException("登陆失败");
}*/
String sessionId = SessionUtils.getSession().getId(); //"dcfc608c-c58a-45b7-adc7-9902b652496e";
//String sessionId = "f70d53fa-55da-4688-8d00-64350e4fb8ea";
//String sessionId = "f0d06f4a-874c-4dfc-8959-101b6add6bf5";
//通过redis方式登录Azkaban
String redisKey = "spring:sessions:sessions:"+sessionId;
SSOUserInfo ssoUserInfo = redisTemplate.opsForValue().get(redisKey);
if (ssoUserInfo==null) {
redisTemplate.opsForValue().set(redisKey, getSSOuserInfo());
}
System.err.println("----sessionId="+sessionId);
return sessionId; //SessionUtils.getSession().getId();
}
/**
* @Title: getSSOuserInfo
* @Description: TODO(生成azkaban登录需要保存的实体)
* @param @return 参数
* @return SSOUserInfo 返回类型
* @throws
*/
private SSOUserInfo getSSOuserInfo(){
Map<String,String> rolePermissMap =new HashMap<>();
DmpMember dmpMember = SessionUtils.getSecurityUser();
List<DmpRole> memberProjectRoles = dmpMember.getMemberProjectRoleList();
for (DmpRole role : memberProjectRoles) {
rolePermissMap.put(role.getRoleType(), role.getRemark());
}
SSOUserInfo ssoUserInfo = new SSOUserInfo();
ssoUserInfo.setUserName(dmpMember.getUsername());
ssoUserInfo.setAzkabanRoleRefPermissions(rolePermissMap);
return ssoUserInfo;
}
/**
* 创建azkaban项目名
......
package com.jz.common.utils;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
public class CommonUtils {
private static final Logger logger = LoggerFactory.getLogger(CommonUtils.class);
/**
* UUID随机数
......@@ -36,5 +44,62 @@ public class CommonUtils {
String uuid = UUID.randomUUID().toString().toUpperCase().replaceAll("-", "");
return uuid;
}
/**
* @param <T>
* @Title: objArrangeTree
* @Description: TODO(将所有的资源整理成树形结构)
* @param @param dmpPermissions
* @param @return
* @param @throws Exception 参数
* @return List<DmpPermission> 返回类型
* @throws
*/
public static <T> List<T> objArrangeTree(Object parentCode, List<T> objs, String parentCodeFiledName, String codeFieldName, String childrenFieldName) throws Exception {
Map<Object, List<T>> dictMap = objs.stream().collect(Collectors.groupingBy(x->{
try {
return ReflectAssistUtils.getFieldValueByFieldName(parentCodeFiledName, x);
} catch (Exception e) {
e.printStackTrace();
logger.error("树形结构封装异常【{}】", e);
}
return "";
}));
List<T> tList = dictMap.get(parentCode);// 获取顶层资源
if (!CollectionUtils.isEmpty(tList)) {
for (T t : tList) {
t = arrangeChildren(t, dictMap, codeFieldName, childrenFieldName);
}
}
return tList;
}
/**
* @Title: arrangeChildren
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param permission
* @param @param dictMap
* @param @return
* @param @throws Exception 参数
* @return DmpPermission 返回类型
* @throws
*/
private static <T> T arrangeChildren(T t, Map<Object, List<T>> dictMap, String codeFieldName, String childrenFieldName)throws Exception{
Object code = ReflectAssistUtils.getFieldValueByFieldName(codeFieldName, t);
List<T> children = dictMap.get(code);
if (!CollectionUtils.isEmpty(children)) {
for (T child : children) {
child = arrangeChildren(child, dictMap, codeFieldName, childrenFieldName);
}
ReflectAssistUtils.setFieldValueByFieldName(childrenFieldName, t, children);
}
return t;
}
}
package com.jz.common.utils;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import com.jz.dmp.modules.controller.bean.DmpNavigationTreeDto;
/**
* @ClassName: ReflectAssistUtils
* @Description: TODO(反射辅助工具类)
* @author ybz
* @date 2021年1月26日
*
*/
public class ReflectAssistUtils {
/**
* @Title: getFieldValueByFieldName
* @Description: TODO(根据属性名称获取属性值)
* @param @param fieldName
* @param @param cls
* @param @return
* @param @throws Exception 参数
* @return Field 返回类型
* @throws
*/
public static Object getFieldValueByFieldName(String fieldName, Object obj)throws Exception{
Class<?> cls = obj.getClass();
String getMethodName = "get"+fieldName.substring(0, 1).toUpperCase()+fieldName.substring(1);
Method getMethod = cls.getMethod(getMethodName);
return getMethod.invoke(obj);
}
/**
* @param <T>
* @Title: setFieldValueByFieldName
* @Description: TODO(设置属性值)
* @param @param fieldName
* @param @param cls
* @param @param fieldVaule
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
public static <T> void setFieldValueByFieldName(String fieldName, Object obj, T fieldVaule)throws Exception{
Class<?> cls = obj.getClass();
String setMethodName = "set"+fieldName.substring(0, 1).toUpperCase()+fieldName.substring(1);
Class<?> fieldValueClass = fieldVaule.getClass();
if (fieldVaule instanceof ArrayList) {
fieldValueClass = List.class;
}
Method setMethod = cls.getMethod(setMethodName, fieldValueClass);
setMethod.invoke(obj, fieldVaule);
}
public static void main(String[] args) {
try {
DmpNavigationTreeDto dmpNavigationTreeDto = new DmpNavigationTreeDto();
List<DmpNavigationTreeDto> list = new ArrayList<DmpNavigationTreeDto>();
setFieldValueByFieldName("children", dmpNavigationTreeDto, list);
System.out.println(getFieldValueByFieldName("children", dmpNavigationTreeDto));
} catch (Exception e) {
e.printStackTrace();
}
}
}
......@@ -122,6 +122,7 @@ public class SFTPUtils {
* @param remoteFileDirPath 要上传到的远程文件路径
*/
public void singleUploadFile(String localFileDirPath,String uploadFileName,String remoteFileDirPath) {
String pathTeString = "C:\\opt\\dmp\\dmp_web\\35\\705\\execArgs\\";
//本地文件绝对路径
String localFileAbsolutePath = localFileDirPath+uploadFileName;
String remoteFileAbsolutePath = remoteFileDirPath+"/"+uploadFileName;
......@@ -129,7 +130,8 @@ public class SFTPUtils {
createRemoteDirs(remoteFileDirPath);
try {
sftp.put(localFileAbsolutePath, remoteFileAbsolutePath,ChannelSftp.OVERWRITE);
//sftp.put(localFileAbsolutePath, remoteFileAbsolutePath,ChannelSftp.OVERWRITE);
sftp.put(pathTeString+uploadFileName, remoteFileAbsolutePath,ChannelSftp.OVERWRITE);
sftp.chmod(Integer.parseInt("775",8), remoteFileAbsolutePath);
LOGGER.info("上传"+localFileAbsolutePath+" 到 "+remoteFileAbsolutePath+" 成功");
} catch (SftpException e) {
......
......@@ -159,5 +159,4 @@ public class DmpNavigationTreeController {
return baseBeanResponse;
}
}
\ No newline at end of file
package com.jz.dmp.modules.controller.bean;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.BeanUtils;
......@@ -56,6 +58,8 @@ public class MyDmpDevelopTaskConverter {
flowPro.setPublishedToProjectId(dmpDevelopTask.getProjectId().longValue());
//dmp里生成的任务id
flowPro.setTaskId(dmpDevelopTask.getId().longValue());
//dmp生成树ID
flowPro.setTreeId(dmpDevelopTask.getTreeId().longValue());
//是否带版本号进行节点变更查询?
//检查节点名称要用到的参数?
......@@ -71,5 +75,21 @@ public class MyDmpDevelopTaskConverter {
return flowPro;
}
/**
* @Title: scriptToFlowProJson
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param script
* @param @return 参数
* @return String 返回类型
* @throws
*/
private String scriptToFlowProJson(String script) {
Map<String, Object> map = new HashMap<String, Object>();
JSONObject jsonObject = JSONObject.parseObject(script);
map.put("flowPro", jsonObject);
return JSONObject.toJSONString(map);
}
}
......@@ -2,6 +2,7 @@ package com.jz.dmp.modules.controller.projconfig.bean;
import com.jz.dmp.modules.model.DmpProjectConfigInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**项目配置表Dto
* @author ybz
......@@ -9,5 +10,21 @@ import io.swagger.annotations.ApiModel;
*/
@ApiModel(value = "项目配置表Dto", description = "项目配置表Dto")
public class DmpProjectConfigInfoDto extends DmpProjectConfigInfo {
/**
*
*/
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "公共配置")
private DmpPublicConfigInfoDto dmpPublicConfigInfoDto;
public DmpPublicConfigInfoDto getDmpPublicConfigInfoDto() {
return dmpPublicConfigInfoDto;
}
public void setDmpPublicConfigInfoDto(DmpPublicConfigInfoDto dmpPublicConfigInfoDto) {
this.dmpPublicConfigInfoDto = dmpPublicConfigInfoDto;
}
}
......@@ -154,6 +154,30 @@ public class DmpPublicConfigInfoRequest extends BasePageBean {
*/
@ApiModelProperty(value = "元数据服务web地址")
private String atlasMonitorUrl;
/**
* 远程连接默认SERVER地址
*/
@ApiModelProperty(value = "远程连接默认SERVER地址")
private String shellCmdServer;
/**
* 远程连接默认用户
*/
@ApiModelProperty(value = "远程连接默认用户")
private String shellCmdUser;
/**
* 远程连接默认用户密码
*/
@ApiModelProperty(value = "远程连接默认用户密码")
private String shellCmdPassword;
/**
* 上传配置的SFTP端口
*/
@ApiModelProperty(value = "上传配置的SFTP端口")
private Integer shellSftpPort;
/**
* 备注
......@@ -394,6 +418,34 @@ public class DmpPublicConfigInfoRequest extends BasePageBean {
public void setAtlasMonitorUrl(String atlasMonitorUrl) {
this.atlasMonitorUrl = atlasMonitorUrl;
}
public void setShellCmdServer(String shellCmdServer) {
this.shellCmdServer = shellCmdServer;
}
public String getShellCmdUser() {
return shellCmdUser;
}
public void setShellCmdUser(String shellCmdUser) {
this.shellCmdUser = shellCmdUser;
}
public String getShellCmdPassword() {
return shellCmdPassword;
}
public void setShellCmdPassword(String shellCmdPassword) {
this.shellCmdPassword = shellCmdPassword;
}
public Integer getShellSftpPort() {
return shellSftpPort;
}
public void setShellSftpPort(Integer shellSftpPort) {
this.shellSftpPort = shellSftpPort;
}
public String getRemark() {
return remark;
......
......@@ -88,7 +88,7 @@ public class DmpNavigationTree implements Serializable {
* 父节点ID
*/
@ApiModelProperty(value = "父节点ID")
private Integer parentId;
public Integer parentId;
public Integer getId() {
......
......@@ -163,6 +163,30 @@ public class DmpPublicConfigInfo implements Serializable{
*/
@ApiModelProperty(value = "元数据服务web地址")
private String atlasMonitorUrl;
/**
* 远程连接默认SERVER地址
*/
@ApiModelProperty(value = "远程连接默认SERVER地址")
private String shellCmdServer;
/**
* 远程连接默认用户
*/
@ApiModelProperty(value = "远程连接默认用户")
private String shellCmdUser;
/**
* 远程连接默认用户密码
*/
@ApiModelProperty(value = "远程连接默认用户密码")
private String shellCmdPassword;
/**
* 上传配置的SFTP端口
*/
@ApiModelProperty(value = "上传配置的SFTP端口")
private Integer shellSftpPort;
/**
* 备注
......@@ -396,6 +420,38 @@ public class DmpPublicConfigInfo implements Serializable{
public void setAtlasMonitorUrl(String atlasMonitorUrl) {
this.atlasMonitorUrl = atlasMonitorUrl;
}
public String getShellCmdServer() {
return shellCmdServer;
}
public void setShellCmdServer(String shellCmdServer) {
this.shellCmdServer = shellCmdServer;
}
public String getShellCmdUser() {
return shellCmdUser;
}
public void setShellCmdUser(String shellCmdUser) {
this.shellCmdUser = shellCmdUser;
}
public String getShellCmdPassword() {
return shellCmdPassword;
}
public void setShellCmdPassword(String shellCmdPassword) {
this.shellCmdPassword = shellCmdPassword;
}
public Integer getShellSftpPort() {
return shellSftpPort;
}
public void setShellSftpPort(Integer shellSftpPort) {
this.shellSftpPort = shellSftpPort;
}
public String getRemark() {
return remark;
......
package com.jz.dmp.modules.model;
import java.io.Serializable;
import java.util.Map;
public class SSOUserInfo implements Serializable {
//用户名
private String userName;
//用户角色对应的用户信息
private Map<String,String> azkabanRoleRefPermissions;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Map<String, String> getAzkabanRoleRefPermissions() {
return azkabanRoleRefPermissions;
}
public void setAzkabanRoleRefPermissions(Map<String, String> azkabanRoleRefPermissions) {
this.azkabanRoleRefPermissions = azkabanRoleRefPermissions;
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ import org.springframework.util.StringUtils;
import com.jz.common.bean.BaseBeanResponse;
import com.jz.common.constant.StatuConstant;
import com.jz.common.persistence.BaseService;
import com.jz.common.utils.CommonUtils;
import com.jz.dmp.modules.controller.bean.DmpNavigationTreeDto;
import com.jz.dmp.modules.controller.bean.DmpNavigationTreeRequest;
import com.jz.dmp.modules.controller.bean.MyDmpNavigationTreeConverter;
......@@ -169,7 +170,7 @@ public class DmpNavigationTreeServiceImpl extends BaseService implements DmpNavi
if (dmpNavigationTreeRequest.getParentId()!=null){
dtos = dmpArrangeTree(dmpNavigationTreeRequest.getParentId(), dtos);
}
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("查询成功");
baseBeanResponse.setDatas(dtos);
......
......@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jz.common.bean.BaseBeanResponse;
import com.jz.common.bean.BaseResponse;
import com.jz.common.constant.StatuConstant;
import com.jz.common.utils.FlowParseTool;
......@@ -16,6 +17,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowPro;
import com.jz.dmp.modules.controller.projconfig.bean.DmpProjectConfigInfoDto;
import com.jz.dmp.modules.dao.DmpProjectDao;
import com.jz.dmp.modules.dao.DmpWorkFlowSubmitDetailsDao;
import com.jz.dmp.modules.dao.projconfig.DmpProjectConfigInfoMapper;
import com.jz.dmp.modules.model.DmpProject;
import com.jz.dmp.modules.model.DmpProjectSystemInfo;
import com.jz.dmp.modules.model.DmpWorkFlowSubmitDetails;
......@@ -24,6 +26,7 @@ import com.jz.dmp.modules.service.DmpNavigationTreeService;
import com.jz.dmp.modules.service.DmpProjectService;
import com.jz.dmp.modules.service.DmpWorkFlowSubmitDetailsService;
import com.jz.dmp.modules.service.FlowService;
import com.jz.dmp.modules.service.projconfig.DmpProjectConfigInfoService;
/**
* @ClassName: FlowServiceImpl
......@@ -51,6 +54,9 @@ public class FlowServiceImpl implements FlowService {
@Autowired
private DmpWorkFlowSubmitDetailsDao dmpWorkFlowSubmitDetailsDao;
@Autowired
private DmpProjectConfigInfoService dmpProjectConfigInfoService;
/**
*工作流发布
......@@ -63,9 +69,12 @@ public class FlowServiceImpl implements FlowService {
flowPro.setCheckVerion(true);
Long publishedToProjectId = flowPro.getPublishedToProjectId();
DmpProject publishToProject = dmpProjectDao.get(publishedToProjectId);
DmpProjectSystemInfo publishToProjectSystemInfo = dmpProjectService.getProjectSystemInfo(publishedToProjectId);
//DmpProjectConfigInfoDto dmpProjectConfigInfoDto =
//DmpProjectSystemInfo publishToProjectSystemInfo = dmpProjectService.getProjectSystemInfo(publishedToProjectId);
BaseBeanResponse<DmpProjectConfigInfoDto> baseBeanResponse = dmpProjectConfigInfoService.findByProjectId(publishedToProjectId.intValue(), null);
DmpProjectConfigInfoDto dmpProjectConfigInfoDto = baseBeanResponse.getData();
try {
/*
FlowParseTool flowParseTool = new FlowParseTool(flowPro,
publishToProject,
publishToProjectSystemInfo,
......@@ -73,6 +82,15 @@ public class FlowServiceImpl implements FlowService {
dmpNavigationTreeService,
dmpWorkFlowSubmitDetailsService
);
*/
FlowParseTool flowParseTool = new FlowParseTool(flowPro,
publishToProject,
dmpProjectConfigInfoDto,
dmpDevelopTaskService,
dmpNavigationTreeService,
dmpWorkFlowSubmitDetailsService
);
//保存发布信息
List<FlowNodeChangeInfo> flowNodeChangeList = flowParseTool.getChangedNodes();
......
......@@ -29,6 +29,8 @@ import com.jz.dmp.modules.controller.projconfig.bean.DmpProjectConfigInfoBatch;
import com.jz.dmp.modules.controller.projconfig.bean.DmpProjectConfigInfoDto;
import com.jz.dmp.modules.controller.projconfig.bean.DmpProjectConfigInfoRequest;
import com.jz.dmp.modules.controller.projconfig.bean.DmpProjectEngineParamDto;
import com.jz.dmp.modules.controller.projconfig.bean.DmpPublicConfigInfoDto;
import com.jz.dmp.modules.controller.projconfig.bean.DmpPublicConfigInfoRequest;
import com.jz.dmp.modules.dao.projconfig.DmpProjectConfigEngineMapper;
import com.jz.dmp.modules.dao.projconfig.DmpProjectConfigInfoMapper;
import com.jz.dmp.modules.dao.projconfig.DmpProjectEngineParamMapper;
......@@ -36,6 +38,7 @@ import com.jz.dmp.modules.model.DmpProjectConfigEngine;
import com.jz.dmp.modules.model.DmpProjectConfigInfo;
import com.jz.dmp.modules.model.DmpProjectEngineParam;
import com.jz.dmp.modules.service.projconfig.DmpProjectConfigInfoService;
import com.jz.dmp.modules.service.projconfig.DmpPublicConfigInfoService;
/**
* 项目配置表服务的实现?
......@@ -54,6 +57,9 @@ public class DmpProjectConfigInfoServiceImpl extends BaseService implements DmpP
private DmpProjectConfigEngineMapper dmpProjectConfigEngineMapper;
@Autowired
private DmpProjectEngineParamMapper dmpProjectEngineParamMapper;
@Autowired
private DmpPublicConfigInfoService dmpPublicConfigInfoService;
/*
* (non-Javadoc)
......@@ -668,6 +674,13 @@ public class DmpProjectConfigInfoServiceImpl extends BaseService implements DmpP
if (!CollectionUtils.isEmpty(list)) {
dto = list.get(0);
//设置公共属性
DmpPublicConfigInfoRequest request = new DmpPublicConfigInfoRequest();
BaseBeanResponse<DmpPublicConfigInfoDto> configInfoBeanResponse = dmpPublicConfigInfoService.findList(request, null);
List<DmpPublicConfigInfoDto> configInfoDtos = configInfoBeanResponse.getDatas();
if (!CollectionUtils.isEmpty(configInfoDtos)) {
dto.setDmpPublicConfigInfoDto(configInfoDtos.get(0));
}
}
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
......
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