Commit adbb2fe5 authored by sml's avatar sml

冲突解决

parent 2fe69a17
......@@ -16,7 +16,12 @@ public interface DmpDevelopTaskDao {
Map getDmpTaskAndTreeInfo(String taskId) throws Exception;
int deleteTaskByTaskId(String taskId) throws Exception;
/**
* 批量删除离线任务
*
* @author Bellamy
*/
int deleteTaskByTaskId(Map params) throws Exception;
int deleteNavigationTreeByTreeId(String treeId) throws Exception;
......@@ -45,5 +50,16 @@ public interface DmpDevelopTaskDao {
* @throws Exception
*/
public List<DmpDevelopTask> findList(Map<String, Object> param)throws Exception;
/**
* @Title: get
* @Description: TODO(主键获取对象)
* @param @param id
* @param @return
* @param @throws Exception 参数
* @return DmpDevelopTask 返回类型
* @throws
*/
public DmpDevelopTask get(Long id)throws Exception;
}
package com.jz.dmp.modules.service.impl;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import com.jcraft.jsch.MAC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.agent.service.DmpDsAgentService;
import com.jz.common.bean.BaseBeanResponse;
import com.jz.common.bean.BaseResponse;
import com.jz.common.constant.CommConstant;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.constant.StatuConstant;
import com.jz.common.enums.ModuleLogEnum;
import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService;
import com.jz.common.utils.DateUtils;
import com.jz.common.utils.GZIPUtils;
import com.jz.common.utils.JsonMapper;
import com.jz.common.utils.StringUtils;
import com.jz.common.utils.web.XmlUtils;
import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.azkaban.dao.ExecutionFlowsMapper;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListDto;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowPro;
import com.jz.dmp.modules.controller.bean.DmpDevelopTaskDto;
import com.jz.dmp.modules.controller.bean.DmpDevelopTaskRequest;
import com.jz.dmp.modules.controller.bean.MyDmpDevelopTaskConverter;
import com.jz.dmp.modules.controller.bean.MyDmpDevelopTaskHistoryConverter;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListDto;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListReq;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListReq;
import com.jz.dmp.modules.dao.DmpDevelopTaskDao;
import com.jz.dmp.modules.dao.DmpNavigationTreeDao;
import com.jz.dmp.modules.dao.DmpProjectDao;
import com.jz.dmp.modules.dao.DmpSyncingDatasourceTypeDao;
import com.jz.dmp.modules.model.DmpAgentDatasourceInfo;
import com.jz.dmp.modules.model.DmpDevelopTask;
import com.jz.dmp.modules.model.DmpDevelopTaskHistory;
import com.jz.dmp.modules.model.DmpModuleOperateLog;
import com.jz.dmp.modules.model.DmpNavigationTree;
import com.jz.dmp.modules.model.DmpProjectSystemInfo;
import com.jz.dmp.modules.model.DmpSyncingDatasource;
import com.jz.dmp.modules.model.DmpSyncingDatasourceType;
import com.jz.dmp.modules.service.DmpDevelopTaskHistoryService;
import com.jz.dmp.modules.service.DmpDevelopTaskService;
import com.jz.dmp.modules.service.DmpModuleOperateLogService;
import com.jz.dmp.modules.service.DmpSyncingDatasourceService;
import com.jz.dmp.modules.service.FlowService;
import com.jz.dmp.modules.service.OfflineSynchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.regex.Pattern;
import static com.jz.common.utils.DateUtils.getYesterdayStr;
/**
* 任务开发(DmpDevelopTask)表服务实现类
......@@ -65,7 +75,7 @@ import static com.jz.common.utils.DateUtils.getYesterdayStr;
*/
@Service("dmpDevelopTaskService")
@Transactional
public class DmpDevelopTaskServiceImpl implements DmpDevelopTaskService {
public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelopTaskService {
private static Logger logger = LoggerFactory.getLogger(OfflineSynchServiceImpl.class);
......@@ -89,6 +99,21 @@ public class DmpDevelopTaskServiceImpl implements DmpDevelopTaskService {
@Autowired
private ExecutionFlowsMapper executionFlowsMapper;
@Autowired
private DmpModuleOperateLogService dmpModuleOperateLogService;
@Autowired
private DmpNavigationTreeDao dmpNavigationTreeDao;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private FlowService flowService;
@Autowired
private DmpDevelopTaskHistoryService dmpDevelopTaskHistoryService;
/**
* 添加保存dmp数据(包含校验数据)
......@@ -765,7 +790,7 @@ public class DmpDevelopTaskServiceImpl implements DmpDevelopTaskService {
//判断是否为整数 是整数返回true,否则返回false
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
if (pattern.matcher(req.getTreeIdOrName().trim()).matches()) {
req.setTreeId(req.getTreeIdOrName()); //id
req.setTaskId(req.getTreeIdOrName()); //id
req.setTreeIdOrName(null);
} else {
req.setTreeIdOrName(req.getTreeIdOrName().trim());//节点名称
......@@ -919,6 +944,12 @@ public class DmpDevelopTaskServiceImpl implements DmpDevelopTaskService {
if (!StringUtils.isEmpty(dmpDevelopTaskRequest.getTargetTableName())) {
param.put("targetTableName", dmpDevelopTaskRequest.getTargetTableName());
}
//项目ID
if (dmpDevelopTaskRequest.getProjectId() != null) {
param.put("projectId", dmpDevelopTaskRequest.getProjectId());
}
//未删除数据
param.put("dataStatus", "1");
PageHelper.startPage(dmpDevelopTaskRequest.getPageNum(), dmpDevelopTaskRequest.getPageSize());
List<DmpDevelopTask> list = dmpDevelopTaskDao.findList(param);
......@@ -1014,4 +1045,172 @@ public class DmpDevelopTaskServiceImpl implements DmpDevelopTaskService {
}
return pageInfoResponse;
}
/**
*根据treeId取得最新版提交的同步脚本文件名(不含后缀)及版本信息
*/
@Override
public String getConfigFileNameNotSuffix4Published(Long treeId) throws Exception {
DmpModuleOperateLog log = getLastVersion4SubmitSyncInfo(treeId.intValue());
String fileName = XmlUtils.getPropertyValue(log.getOperateLog(), "name");
return fileName + "@" + log.getRemark();
}
private DmpModuleOperateLog getLastVersion4SubmitSyncInfo(Integer treeId)throws Exception {
DmpModuleOperateLog o = null;
try {
o = dmpModuleOperateLogService.getLastOperateLog(treeId, ModuleLogEnum.VERSION_SYNC_XML);
// #######经与宏涛确认忽略历史数据,跳过初始化。
/*if (null == o) {
// 未找到历史版本,考虑到历史离线同步数据存在无版本记录的情况,初始化版本信息
DmpTaskSchedule po = new DmpTaskSchedule();
po.setTreeId(task.getTreeId());
po.setProjectId(task.getProjectId());
String xmlContent = convert2SyncXmlContent(po);
o = dmpModuleOperateLogService.writeSubmitXmlVersion(task.getTreeId(), xmlContent);
}*/
if (null == o || !StringUtils.hasLength(o.getRemark())) {
throw new Exception("未找到历史版本信息");
}
} catch (Exception e) {
logger.error("获取离线同步xml文件名及版本信息异常:" + e.getMessage(), e);
}
return o;
}
/*
* (non-Javadoc)
*
* @see
* com.ycxc.vmts.service.DmpDevelopTaskService#add(com.ycxc.vmts.entity.DmpDevelopTask,
* javax.servlet.http.HttpServletRequest)
*/
@Override
@Transactional(rollbackFor = Exception.class)
public BaseBeanResponse<DmpDevelopTask> add(DmpDevelopTask dmpDevelopTask, HttpServletRequest httpRequest) throws Exception {
BaseBeanResponse<DmpDevelopTask> baseBeanResponse = new BaseBeanResponse<>();
//参数校验
String taskName = dmpDevelopTask.getName();
if (StringUtils.isEmpty(taskName)) {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("工作流名称不能为空");
return baseBeanResponse;
}
//添加树叶子节点
DmpNavigationTree tree = new DmpNavigationTree();
tree.setName(taskName);
tree.setParentId(dmpDevelopTask.getParentId());
tree.setProjectId(dmpDevelopTask.getProjectId());
tree.setCategory(CommConstant.TREE_DEVELOP_TASK);
tree.setType("W");
tree.setIsLevel("1");
tree.setIsEnable("1");
tree.setDataStatus("1");
tree.setTreeSort(dmpNavigationTreeDao.getMaxSortById(tree));
int cnt = dmpNavigationTreeDao.countTreeByName(tree);
if (cnt > 0) {
baseBeanResponse.setCode(StatuConstant.CODE_DATA_EXISTED);
baseBeanResponse.setMessage("当前项目已存在同名的工作流名称");
return baseBeanResponse;
}
dmpNavigationTreeDao.insert(tree);
//将新增任务保存到数据库
dmpDevelopTask.setTaskType("1");
dmpDevelopTask.setType("W");
dmpDevelopTask.setIsSubmit("0");
dmpDevelopTask.setScheduleType("2");
dmpDevelopTask.setDataStatus("1");
dmpDevelopTask.setTreeId(tree.getId().intValue());
int revision = 1;
ObjectNode flowHeaderNode = objectMapper.createObjectNode();
flowHeaderNode.put("name", dmpDevelopTask.getName() );
flowHeaderNode.put("description", dmpDevelopTask.getTaskDesc());
flowHeaderNode.put("revision", revision);
dmpDevelopTask.setFlowHeader(flowHeaderNode.toString());
ObjectNode scriptNode = objectMapper.createObjectNode();
scriptNode.put("id", "canvas");
scriptNode.put("resourceId", "canvas");
ObjectNode stencilSetNode = objectMapper.createObjectNode();
stencilSetNode.put("namespace","http://b3mn.org/stencilset/bpmn2.0#");
scriptNode.put("stencilset", stencilSetNode);
byte[] data = null;
try {
data = scriptNode.toString().getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
dmpDevelopTask.setData(data);
// 创建人
dmpDevelopTask.setCreateUserId(Optional.ofNullable(getHttpRequestUserId(httpRequest)).orElse(0).toString());
// 创建时间
dmpDevelopTask.setCreateTime(new Date());
dmpDevelopTaskDao.insert(dmpDevelopTask);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("新增成功");
baseBeanResponse.setData(dmpDevelopTask);
return baseBeanResponse;
}
/**
*任务流保存及提交
*/
@Override
public BaseResponse flowSubmit(DmpDevelopTask dmpDevelopTask, HttpServletRequest httpRequest)
throws Exception {
BaseResponse baseResponse = new BaseResponse();
FlowPro flowPro = MyDmpDevelopTaskConverter.INSTANCE().task2flowpro(dmpDevelopTask);
//参数校验
Long treeId = flowPro.getTreeId();
if (treeId==null) {
baseResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseResponse.setMessage("treeId不能为空");
return baseResponse;
}
DmpNavigationTree dmpNavigationTree = dmpNavigationTreeDao.queryById(treeId.intValue());
Long projectId = Long.parseLong(dmpNavigationTree.getProjectId().toString());
flowPro.setPublishedToProjectId(projectId);
BaseResponse baseResponsePublish = flowService.publishFlow(flowPro);
if (StatuConstant.SUCCESS_CODE.equals(baseResponsePublish.getCode())) {
flowPro.setIsSubmit("1");
//保存流程数据
DmpDevelopTask queryDmpDevelopTask = dmpDevelopTaskDao.get(treeId);
DmpDevelopTask updateDevelopTask = new DmpDevelopTask();
updateDevelopTask.setId(queryDmpDevelopTask.getId());
try {
updateDevelopTask.setFlowJson(flowPro.getFlowJson());
updateDevelopTask.setData(GZIPUtils.gzipString(flowPro.getFlowJson(), "utf-8"));
} catch (IOException e) {
e.printStackTrace();
}
updateDevelopTask.setIsSubmit(flowPro.getIsSubmit());
updateDevelopTask.setIsGziped(1);
dmpDevelopTaskDao.update(updateDevelopTask);
DmpDevelopTaskHistory dmpDevelopTaskHistory = MyDmpDevelopTaskHistoryConverter.INSTANCE().task2history(updateDevelopTask);
//保存版本为版本数据
dmpDevelopTaskHistoryService.add(dmpDevelopTaskHistory, httpRequest);
}
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage("工作流程保存发布成功");
return baseResponse;
}
}
\ No newline at end of file
......@@ -37,13 +37,22 @@
t1.TREE_ID as treeId
from dmp_develop_task t1
left join dmp_navigation_tree t2 on t1.TREE_ID=t2.ID
where 1=1 and t1.id = #{taskId}
where 1=1 and t1.data_status ='1' and t1.id = #{taskId}
</select>
<!--根据主键删除任务-->
<delete id="deleteTaskByTaskId" parameterType="string">
delete from dmp_develop_task where id = #{taskId}
</delete>
<update id="deleteTaskByTaskId" parameterType="java.util.Map">
update dmp_develop_task
<trim prefix="SET" suffixOverrides=",">
<if test="dataStatus != null">
data_status = #{dataStatus},
</if>
</trim>
where id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<!--根据主键删除资源树-->
<delete id="deleteNavigationTreeByTreeId" parameterType="string">
......@@ -142,14 +151,15 @@
ID, datasource_id, TASK_TYPE, TYPE, SCHEDULE_TYPE, IS_SUBMIT, TASK_DESC, SCRIPT, DATA_STATUS
, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, TREE_ID, CHK_RESULT, SYNC_RESULT, CHK_TIME, SYNC_TIME, FLOW_HEADER, FLOW_JSON, VERSION, IS_GZIPED
from dmp_develop_task
where TREE_ID = #{treeId}
where data_status ='1' and TREE_ID = #{treeId}
</select>
<!--数据运维-数据开发任务列表分页查询-->
<select id="queryDevTaskListPage" resultType="com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto"
parameterType="com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListReq">
select
t1.id as taskId,
t1.id as treeId,
t2.id as taskId,
t1.name as taskName,
t1.type,
t1.create_user_id as createUserId,
......@@ -158,32 +168,36 @@
t3.real_name as userName
from
dmp_navigation_tree t1
left join dmp_develop_task t2 on t2.TREE_ID=t1.ID
left join dmp_develop_task t2 on t2.TREE_ID=t1.ID and t2.data_status ='1'
left join dmp_member t3 on t1.create_user_id=t3.user_id
where 1=1 and t1.type='01'
and t1.project_id = #{projectId}
<if test="treeId != null and treeId != ''"> and t1.id =#{treeId} </if>
<if test="taskId != null and taskId != ''"> and t2.id =#{taskId} </if>
<if test="treeIdOrName != null and treeIdOrName != ''"> and t1.name like concat('%',#{treeIdOrName},'%') </if>
<if test="taskType != null and taskType!= ''"> and t1.type=#{taskType} </if>
</select>
<select id="findList" resultMap="DmpDevelopTaskResultMap">
SELECT
<include refid="FIND_ALL_COLUMN" />
FROM dmp_develop_task WHERE 1=1
<if test="taskType != null">AND task_type = #{taskType}</if>
<if test="type != null">AND type = #{type}</if>
<if test="scheduleType != null">AND schedule_type = #{scheduleType}</if>
<if test="isSubmit != null">AND is_submit = #{isSubmit}</if>
<if test="taskDesc != null">AND task_desc = #{taskDesc}</if>
<if test="script != null">AND script = #{script, jdbcType=BLOB,
task.id,task.task_type,task.type,task.schedule_type,task.is_submit,task.task_desc,task.script,task.data_status,task.create_user_id,task.create_time,
task.update_user_id,task.update_time,task.tree_id,task.flow_header,
task.flow_json, task.version,task.is_gziped
FROM dmp_develop_task task left join dmp_navigation_tree tree ON task.tree_id=tree.id
WHERE 1=1
<if test="taskType != null">AND task.task_type = #{taskType}</if>
<if test="type != null">AND task.type = #{type}</if>
<if test="scheduleType != null">AND task.schedule_type = #{scheduleType}</if>
<if test="isSubmit != null">AND task.is_submit = #{isSubmit}</if>
<if test="taskDesc != null">AND task.task_desc = #{taskDesc}</if>
<if test="script != null">AND task.script = #{script, jdbcType=BLOB,
typeHandler=com.jz.common.persistence.CBTHandler}</if>
<if test="dataStatus != null">AND data_status = #{dataStatus}</if>
<if test="treeId != null">AND tree_id = #{treeId}</if>
<if test="flowHeader != null">AND flow_header = #{flowHeader}</if>
<if test="flowJson != null">AND flow_json = #{flowJson}</if>
<if test="version != null">AND version = #{version}</if>
<if test="gziped != null">AND is_gziped = #{gziped}</if>
<if test="dataStatus != null">AND task.data_status = #{dataStatus}</if>
<if test="treeId != null">AND task.tree_id = #{treeId}</if>
<if test="flowHeader != null">AND task.flow_header = #{flowHeader}</if>
<if test="flowJson != null">AND task.flow_json = #{flowJson}</if>
<if test="version != null">AND task.version = #{version}</if>
<if test="gziped != null">AND task.is_gziped = #{gziped}</if>
<if test="projectId != null">AND tree.project_id = #{projectId}</if>
</select>
<select id="queryTaskTreeInfo" resultType="com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto">
......@@ -193,7 +207,7 @@
(case when t1.type='01' then '离线同步' when t1.type='02' then '实时同步' when t1.type='03' then '数据开发' end) as type
from
dmp_navigation_tree t1
left join dmp_develop_task t2 on t2.TREE_ID=t1.ID
left join dmp_develop_task t2 on t2.TREE_ID=t1.ID and t2.data_status ='1'
left join dmp_member t3 on t1.create_user_id=t3.user_id
where 1=1 and t1.type='01'
and t1.project_id = #{projectId}
......@@ -201,5 +215,10 @@
<if test="taskName != null and taskName != ''"> and t1.name like concat('%',#{taskName},'%') </if>
<if test="taskType != null and taskType!= ''"> and t1.type=#{taskType} </if>
</select>
<!-- 主键获取对象 -->
<select id="get" parameterType="java.lang.Long" resultMap="DmpDevelopTaskResultMap">
SELECT <include refid="FIND_ALL_COLUMN" /> FROM dmp_develop_task WHERE tree_id = #{id}
</select>
</mapper>
\ 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