模板接口更改
This commit is contained in:
parent
b891228f40
commit
ee01222893
@ -3,6 +3,7 @@ package cd.casic.ci.api;
|
|||||||
|
|
||||||
import cd.casic.ci.process.dto.req.template.TemplateCreateReq;
|
import cd.casic.ci.process.dto.req.template.TemplateCreateReq;
|
||||||
import cd.casic.ci.process.dto.req.template.TemplateQueryReq;
|
import cd.casic.ci.process.dto.req.template.TemplateQueryReq;
|
||||||
|
import cd.casic.ci.process.dto.req.template.TemplateUpdateReq;
|
||||||
import cd.casic.ci.process.dto.resp.template.TemplateFindResp;
|
import cd.casic.ci.process.dto.resp.template.TemplateFindResp;
|
||||||
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
||||||
import cd.casic.ci.process.process.service.template.TemplateManagerService;
|
import cd.casic.ci.process.process.service.template.TemplateManagerService;
|
||||||
@ -37,6 +38,11 @@ public class TemplateManagerController {
|
|||||||
String templateId = templateManagerService.createTemplateManager(req);
|
String templateId = templateManagerService.createTemplateManager(req);
|
||||||
return CommonResult.success(templateId);
|
return CommonResult.success(templateId);
|
||||||
}
|
}
|
||||||
|
@PostMapping(path="/updateTemplateManager")
|
||||||
|
public CommonResult<String> updateTemplateManager(@RequestBody TemplateUpdateReq req){
|
||||||
|
String templateId = templateManagerService.updateTemplateManager(req);
|
||||||
|
return CommonResult.success(templateId);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping(path="/findTemplatePage")
|
@PostMapping(path="/findTemplatePage")
|
||||||
public CommonResult<PageResult<TemplateFindResp>> findTemplatePage(@RequestBody @NotNull @Valid TemplateQueryReq query){
|
public CommonResult<PageResult<TemplateFindResp>> findTemplatePage(@RequestBody @NotNull @Valid TemplateQueryReq query){
|
||||||
|
@ -85,14 +85,14 @@ public class TemplateStageController {
|
|||||||
stageService.deleteStagesAndTask(taskId);
|
stageService.deleteStagesAndTask(taskId);
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
// /**
|
/**
|
||||||
// * 复制stage节点
|
* 复制stage节点
|
||||||
// * */
|
* */
|
||||||
// @PostMapping(path="/copyStage/{stageId}")
|
@PostMapping(path="/copyStage/{stageId}")
|
||||||
// public CommonResult<Void> copyStage(@NotEmpty@PathVariable String stageId){
|
public CommonResult<Void> copyStage(@NotEmpty@PathVariable String stageId){
|
||||||
// stageService.copyStage(stageId);
|
stageService.copyStage(stageId);
|
||||||
// return CommonResult.success();
|
return CommonResult.success();
|
||||||
// }
|
}
|
||||||
@PostMapping("/deleteFirstStage/{stageId}")
|
@PostMapping("/deleteFirstStage/{stageId}")
|
||||||
public CommonResult<Void> deleteFirstStage(@PathVariable String stageId){
|
public CommonResult<Void> deleteFirstStage(@PathVariable String stageId){
|
||||||
stageService.deleteFirstStage(stageId);
|
stageService.deleteFirstStage(stageId);
|
||||||
|
@ -29,14 +29,14 @@ public class TemplateTasksController {
|
|||||||
public CommonResult<TemplateTasksResp> findOneTasksOrTask(@NotNull @PathVariable String taskId){
|
public CommonResult<TemplateTasksResp> findOneTasksOrTask(@NotNull @PathVariable String taskId){
|
||||||
return CommonResult.success(taskService.getRespById(taskId));
|
return CommonResult.success(taskService.getRespById(taskId));
|
||||||
}
|
}
|
||||||
// /**
|
/**
|
||||||
// * 复制task节点
|
* 复制task节点
|
||||||
// * */
|
* */
|
||||||
// @PostMapping(path="/copyTask/{taskId}")
|
@PostMapping(path="/copyTask/{taskId}")
|
||||||
// public CommonResult<Void> copyTask(@NotEmpty @PathVariable String taskId){
|
public CommonResult<Void> copyTask(@NotEmpty @PathVariable String taskId){
|
||||||
// taskService.copyTask(taskId);
|
taskService.copyTask(taskId);
|
||||||
// return CommonResult.success();
|
return CommonResult.success();
|
||||||
// }
|
}
|
||||||
@PostMapping(path="/updateTask")
|
@PostMapping(path="/updateTask")
|
||||||
public CommonResult<Boolean> updateTask(@RequestBody TemplateTaskUpdateReq req){
|
public CommonResult<Boolean> updateTask(@RequestBody TemplateTaskUpdateReq req){
|
||||||
Boolean b = taskService.updateTask(req);
|
Boolean b = taskService.updateTask(req);
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package cd.casic.ci.process.dto.req.template;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName TemplateCreateReq
|
||||||
|
* @Date: 2025/5/29 10:41
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TemplateUpdateReq {
|
||||||
|
/**
|
||||||
|
* 模板名称
|
||||||
|
*/
|
||||||
|
private String templateName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板分类
|
||||||
|
*/
|
||||||
|
private String templateType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package cd.casic.ci.process.process.converter;
|
package cd.casic.ci.process.process.converter;
|
||||||
|
|
||||||
import cd.casic.ci.process.dto.req.template.TemplateCreateReq;
|
import cd.casic.ci.process.dto.req.template.TemplateCreateReq;
|
||||||
|
import cd.casic.ci.process.dto.req.template.TemplateUpdateReq;
|
||||||
import cd.casic.ci.process.dto.resp.template.TemplateFindResp;
|
import cd.casic.ci.process.dto.resp.template.TemplateFindResp;
|
||||||
import cd.casic.ci.process.dto.resp.template.TemplateStageResp;
|
import cd.casic.ci.process.dto.resp.template.TemplateStageResp;
|
||||||
import cd.casic.ci.process.dto.resp.template.TemplateTasksResp;
|
import cd.casic.ci.process.dto.resp.template.TemplateTasksResp;
|
||||||
@ -29,4 +30,5 @@ public interface TemplateConverter {
|
|||||||
TemplateStageResp stageTemplateToResp(TemplateStage stage);
|
TemplateStageResp stageTemplateToResp(TemplateStage stage);
|
||||||
PipTask templateTaskToTask(TemplateTasksResp resp);
|
PipTask templateTaskToTask(TemplateTasksResp resp);
|
||||||
TemplateManager managerCreateReqToManager(TemplateCreateReq req);
|
TemplateManager managerCreateReqToManager(TemplateCreateReq req);
|
||||||
|
TemplateManager managerUpdateReqToManager(TemplateUpdateReq req);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package cd.casic.ci.process.process.service.template;
|
|||||||
|
|
||||||
import cd.casic.ci.process.dto.req.template.TemplateCreateReq;
|
import cd.casic.ci.process.dto.req.template.TemplateCreateReq;
|
||||||
import cd.casic.ci.process.dto.req.template.TemplateQueryReq;
|
import cd.casic.ci.process.dto.req.template.TemplateQueryReq;
|
||||||
|
import cd.casic.ci.process.dto.req.template.TemplateUpdateReq;
|
||||||
import cd.casic.ci.process.dto.resp.template.TemplateFindResp;
|
import cd.casic.ci.process.dto.resp.template.TemplateFindResp;
|
||||||
import cd.casic.ci.process.process.dataObject.template.TemplateManager;
|
import cd.casic.ci.process.process.dataObject.template.TemplateManager;
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
@ -20,6 +21,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface TemplateManagerService extends IService<TemplateManager> {
|
public interface TemplateManagerService extends IService<TemplateManager> {
|
||||||
String createTemplateManager(TemplateCreateReq req);
|
String createTemplateManager(TemplateCreateReq req);
|
||||||
|
String updateTemplateManager(TemplateUpdateReq req);
|
||||||
|
|
||||||
PageResult<TemplateFindResp> findTemplatePage(@Valid TemplateQueryReq query);
|
PageResult<TemplateFindResp> findTemplatePage(@Valid TemplateQueryReq query);
|
||||||
|
|
||||||
|
@ -40,4 +40,6 @@ public interface TemplateStageService extends IService<TemplateStage> {
|
|||||||
void deleteStagesAndTask(String taskId);
|
void deleteStagesAndTask(String taskId);
|
||||||
|
|
||||||
public void updateStagesTask(TemplateStageUpdateReq stage);
|
public void updateStagesTask(TemplateStageUpdateReq stage);
|
||||||
|
|
||||||
|
public void copyStage(String stageId);
|
||||||
}
|
}
|
||||||
|
@ -21,4 +21,5 @@ public interface TemplateTaskService extends IService<TemplateTask> {
|
|||||||
List<TemplateTask> getTaskByStageIdList(List<String> stageIdList);
|
List<TemplateTask> getTaskByStageIdList(List<String> stageIdList);
|
||||||
TemplateTasksResp getRespById(String taskId);
|
TemplateTasksResp getRespById(String taskId);
|
||||||
public Boolean updateTask(TemplateTaskUpdateReq req);
|
public Boolean updateTask(TemplateTaskUpdateReq req);
|
||||||
|
void copyTask(String taskId);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package cd.casic.ci.process.process.service.template.impl;
|
|||||||
|
|
||||||
import cd.casic.ci.process.dto.req.template.TemplateCreateReq;
|
import cd.casic.ci.process.dto.req.template.TemplateCreateReq;
|
||||||
import cd.casic.ci.process.dto.req.template.TemplateQueryReq;
|
import cd.casic.ci.process.dto.req.template.TemplateQueryReq;
|
||||||
|
import cd.casic.ci.process.dto.req.template.TemplateUpdateReq;
|
||||||
import cd.casic.ci.process.dto.resp.template.TemplateFindResp;
|
import cd.casic.ci.process.dto.resp.template.TemplateFindResp;
|
||||||
import cd.casic.ci.process.dto.resp.template.TemplateStageResp;
|
import cd.casic.ci.process.dto.resp.template.TemplateStageResp;
|
||||||
import cd.casic.ci.process.process.converter.TemplateConverter;
|
import cd.casic.ci.process.process.converter.TemplateConverter;
|
||||||
@ -91,6 +92,12 @@ public class TemplateManagerServiceImpl extends ServiceImpl<TemplateManagerDao,
|
|||||||
templateTaskDao.insert(task);
|
templateTaskDao.insert(task);
|
||||||
return templateManagerId;
|
return templateManagerId;
|
||||||
}
|
}
|
||||||
|
public String updateTemplateManager(TemplateUpdateReq req){
|
||||||
|
TemplateManager templateManager = templateConverter.managerUpdateReqToManager(req);
|
||||||
|
updateById(templateManager);
|
||||||
|
String templateManagerId = templateManager.getId();
|
||||||
|
return templateManagerId;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public PageResult<TemplateFindResp> findTemplatePage(TemplateQueryReq query) {
|
public PageResult<TemplateFindResp> findTemplatePage(TemplateQueryReq query) {
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ import cd.casic.ci.process.dto.resp.template.TemplateStageResp;
|
|||||||
|
|
||||||
import cd.casic.ci.process.process.converter.TemplateStageConverter;
|
import cd.casic.ci.process.process.converter.TemplateStageConverter;
|
||||||
import cd.casic.ci.process.process.dao.template.TemplateStageDao;
|
import cd.casic.ci.process.process.dao.template.TemplateStageDao;
|
||||||
|
import cd.casic.ci.process.process.dataObject.stage.PipStage;
|
||||||
|
import cd.casic.ci.process.process.dataObject.task.PipTask;
|
||||||
import cd.casic.ci.process.process.dataObject.template.TemplateStage;
|
import cd.casic.ci.process.process.dataObject.template.TemplateStage;
|
||||||
import cd.casic.ci.process.process.dataObject.template.TemplateTask;
|
import cd.casic.ci.process.process.dataObject.template.TemplateTask;
|
||||||
import cd.casic.ci.process.process.service.template.TemplateStageService;
|
import cd.casic.ci.process.process.service.template.TemplateStageService;
|
||||||
@ -365,4 +367,52 @@ public class TemplateStageServiceImpl extends ServiceImpl<TemplateStageDao, Temp
|
|||||||
wrapper.eq(TemplateStage::getParentId,stageId);
|
wrapper.eq(TemplateStage::getParentId,stageId);
|
||||||
return stageDao.selectList(wrapper);
|
return stageDao.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void copyStage(String stageId) {
|
||||||
|
// 查询当前stage(阶段下所有)
|
||||||
|
TemplateStage firstStage = getById(stageId);
|
||||||
|
Long loginUserId = WebFrameworkUtils.getLoginUserId();
|
||||||
|
List<TemplateStage> allMainStage = findAllMainStage(firstStage.getTemplateId());
|
||||||
|
List<TemplateStage> updateStageList = new ArrayList<>(allMainStage.size());
|
||||||
|
for (TemplateStage stage : allMainStage) {
|
||||||
|
if (stage.getStageSort()>firstStage.getStageSort()) {
|
||||||
|
stage.setStageSort(stage.getStageSort()+1);
|
||||||
|
updateStageList.add(stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 保存复制后的阶段,除了id和sort其他都一样
|
||||||
|
firstStage.setId(null);
|
||||||
|
firstStage.setStageSort(firstStage.getStageSort()+1);
|
||||||
|
save(firstStage);
|
||||||
|
updateBatchById(updateStageList);
|
||||||
|
// 查询阶段下所有分支
|
||||||
|
List<TemplateStage> secondStageList = findSecondStage(stageId);
|
||||||
|
if (!CollectionUtils.isEmpty(secondStageList)) {
|
||||||
|
List<String> stageIdList = secondStageList.stream().map(TemplateStage::getId).toList();
|
||||||
|
List<TemplateTask> taskList = templateTaskService.getTaskByStageIdList(stageIdList);
|
||||||
|
Map<String, List<TemplateTask>> stageIdMap = taskList.stream().collect(Collectors.groupingBy(TemplateTask::getStageId));
|
||||||
|
for (TemplateStage secondStage : secondStageList) {
|
||||||
|
secondStage.setCreator(String.valueOf(loginUserId));
|
||||||
|
secondStage.setCreateTime(LocalDateTime.now());
|
||||||
|
secondStage.setUpdateTime(LocalDateTime.now());
|
||||||
|
secondStage.setUpdater(String.valueOf(loginUserId));
|
||||||
|
secondStage.setParentId(firstStage.getId());
|
||||||
|
String secondStageId = secondStage.getId();
|
||||||
|
List<TemplateTask> childTask = stageIdMap.get(secondStageId);
|
||||||
|
secondStage.setId(null);
|
||||||
|
save(secondStage);
|
||||||
|
for (TemplateTask pipTask : childTask) {
|
||||||
|
pipTask.setStageId(secondStage.getId());
|
||||||
|
pipTask.setId(null);
|
||||||
|
pipTask.setCreator(String.valueOf(loginUserId));
|
||||||
|
pipTask.setCreateTime(LocalDateTime.now());
|
||||||
|
pipTask.setUpdateTime(LocalDateTime.now());
|
||||||
|
pipTask.setUpdater(String.valueOf(loginUserId));
|
||||||
|
}
|
||||||
|
templateTaskService.saveBatch(childTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -73,4 +75,34 @@ public class TemplateTaskServiceImpl extends ServiceImpl<TemplateTaskDao, Templa
|
|||||||
byId.setUpdateTime(LocalDateTime.now());
|
byId.setUpdateTime(LocalDateTime.now());
|
||||||
return updateById(byId);
|
return updateById(byId);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void copyTask(String taskId) {
|
||||||
|
TemplateTask sourceTask = getById(taskId);
|
||||||
|
if (sourceTask == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String stageId = sourceTask.getStageId();
|
||||||
|
TemplateTask query = new TemplateTask();
|
||||||
|
query.setStageId(stageId);
|
||||||
|
List<TemplateTask> sameLevelTaskList = getTask(query);
|
||||||
|
if (CollectionUtils.isEmpty(sameLevelTaskList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<TemplateTask> updateList = new ArrayList<>(sameLevelTaskList.size());
|
||||||
|
for (TemplateTask pipTask : sameLevelTaskList) {
|
||||||
|
if (!pipTask.getId().equals(sourceTask.getId())) {
|
||||||
|
if (pipTask.getTaskSort()>sourceTask.getTaskSort()) {
|
||||||
|
pipTask.setTaskSort(pipTask.getTaskSort()+1);
|
||||||
|
updateList.add(pipTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sourceTask.setTaskSort(sourceTask.getTaskSort()+1);
|
||||||
|
sourceTask.setId(null);
|
||||||
|
save(sourceTask);
|
||||||
|
if (!CollectionUtils.isEmpty(updateList)) {
|
||||||
|
updateBatchById(updateList);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user