950 lines
40 KiB
Java
950 lines
40 KiB
Java
package com.sa.zentao.service.impl;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.sa.zentao.conf.LoginRiskUser;
|
|
import com.sa.zentao.conf.RiskUserThreadLocal;
|
|
import com.sa.zentao.dao.*;
|
|
import com.sa.zentao.entity.*;
|
|
import com.sa.zentao.enums.*;
|
|
import com.sa.zentao.mapper.ZtTaskMapper;
|
|
import com.sa.zentao.qo.KanbanQo;
|
|
import com.sa.zentao.qo.ZtProjectQo;
|
|
import com.sa.zentao.service.*;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.sa.zentao.utils.BeanCopyUtil;
|
|
import com.sa.zentao.utils.DateUtils;
|
|
import com.sa.zentao.utils.KanBanConstant;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* <p>
|
|
* 服务实现类
|
|
* </p>
|
|
*
|
|
* @author gqb
|
|
* @since 2024-06-25
|
|
*/
|
|
@Service
|
|
public class ZtTaskServiceImpl extends ServiceImpl<ZtTaskMapper, ZtTask> implements IZtTaskService {
|
|
|
|
|
|
@Autowired
|
|
private IZtActionService actionService;
|
|
|
|
@Autowired
|
|
private IZtKanbanlaneService kanbanlaneService;
|
|
|
|
|
|
@Autowired
|
|
private IZtProjectService ztProjectService;
|
|
|
|
@Autowired
|
|
private IZtProjectproductService projectproductService;
|
|
|
|
@Autowired
|
|
private IZtStoryService storyService;
|
|
|
|
@Autowired
|
|
private IZtStoryFeedbackService storyFeedbackService;
|
|
|
|
@Autowired
|
|
private IZtUserService userService;
|
|
|
|
@Autowired
|
|
private IZtEffortService effortService;
|
|
|
|
@Autowired
|
|
private IZtProductService productService;
|
|
|
|
@Autowired
|
|
private IZtExecutionprojectService executionprojectService;
|
|
|
|
|
|
@Override
|
|
public PageInfo<ZtTaskDTO> taskPageList(ZtProjectQo qo) {
|
|
Page<ZtTaskDTO> page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
|
|
qo.setUserName(RiskUserThreadLocal.get().getName());
|
|
List<ZtTaskDTO> list = this.baseMapper.taskPageList(qo);
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
List<String> userIds = list.stream().map(o -> o.getFinishedby()).collect(Collectors.toList());
|
|
userIds.addAll(list.stream().map(o -> o.getAssignedTo()).collect(Collectors.toList()));
|
|
Map<String, ZtUser> userMap = this.userService.userMapByIds(null);
|
|
|
|
for (ZtTaskDTO task : list) {
|
|
ZtUser ztUser = userMap.get(task.getFinishedby());
|
|
if (ztUser != null) {
|
|
task.setFinishedbyName(ztUser.getNickname());
|
|
}
|
|
ztUser = userMap.get(task.getAssignedTo());
|
|
if (ztUser != null) {
|
|
task.setAssignedToName(ztUser.getNickname());
|
|
}
|
|
|
|
if (task.getDeadline() != null) {
|
|
task.setDeadline(DateUtils.getDayLast(task.getDeadline()));
|
|
}
|
|
}
|
|
|
|
}
|
|
return new PageInfo<ZtTaskDTO>(list);
|
|
}
|
|
|
|
@Override
|
|
public void assignedTo(ZtTaskDTO dto) {
|
|
|
|
ZtTask ztTask = this.baseMapper.selectById(dto.getId());
|
|
if (ztTask == null) {
|
|
throw new BusinessException("未查询到数据");
|
|
}
|
|
ztTask.setAssignedTo(dto.getAssignedTo());
|
|
ztTask.setLasteditedby(RiskUserThreadLocal.get().getName());
|
|
ztTask.setLastediteddate(new Date());
|
|
this.baseMapper.updateById(ztTask);
|
|
|
|
|
|
ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject()));
|
|
|
|
|
|
actionService.addAction(ActionType.RW, ActionStatus.FP, ztTask.getId()
|
|
, projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), null, dto.getAssignedTo());
|
|
}
|
|
|
|
@Override
|
|
@Transactional
|
|
public void batchApproval(ZtTaskDTO dto) {
|
|
List<Integer> idList = dto.getIdList();
|
|
|
|
if (CollectionUtils.isEmpty(idList)) {
|
|
throw new BusinessException("请检查");
|
|
}
|
|
List<ZtTask> ztTasks = this.listByIds(idList);
|
|
List<ZtTask> reviewingList = ztTasks.stream().filter(o -> !"reviewing".equals(o.getStatus())).collect(Collectors.toList());
|
|
if (!CollectionUtils.isEmpty(reviewingList)) {
|
|
throw new BusinessException(reviewingList.get(0).getName() + "当前状态无法评审");
|
|
}
|
|
List<ZtTask> tList = reviewingList.stream().filter(o -> !RiskUserThreadLocal.get().getName().equals(o.getReviewingUser())).collect(Collectors.toList());
|
|
if (!CollectionUtils.isEmpty(tList)) {
|
|
throw new BusinessException(tList.get(0).getName() + "当前评审人错误");
|
|
}
|
|
for (ZtTask t : ztTasks) {
|
|
ZtTaskDTO ztTaskDTO = new ZtTaskDTO();
|
|
ztTaskDTO.setApprovalStatus(dto.getApprovalStatus());
|
|
ztTaskDTO.setApprovalRemark(dto.getApprovalRemark());
|
|
BeanUtils.copyProperties(t,ztTaskDTO);
|
|
this.approval(ztTaskDTO);
|
|
//
|
|
// if (dto.getApprovalStatus() == 1) {
|
|
// t.setStatus("wait");
|
|
// } else {
|
|
// t.setStatus("closed");
|
|
// }
|
|
//
|
|
// t.setApprovalRemark(dto.getApprovalRemark());
|
|
// t.setLastediteddate(new Date());
|
|
// t.setLasteditedby(RiskUserThreadLocal.get().getName());
|
|
// this.baseMapper.updateById(t);
|
|
//
|
|
//
|
|
// ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, t.getProject()));
|
|
//
|
|
//
|
|
// if (dto.getApprovalStatus() == 1) {
|
|
// actionService.addAction(ActionType.RW, ActionStatus.PSTG, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(),
|
|
// RiskUserThreadLocal.get().getName(), dto.getApprovalRemark(), null);
|
|
// } else if (dto.getApprovalStatus() == 2) {
|
|
// actionService.addAction(ActionType.RW, ActionStatus.PSBTG, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(),
|
|
// RiskUserThreadLocal.get().getName(), dto.getApprovalRemark(), null);
|
|
// }
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public List<ZtTaskDTO> myTaskList(ZtProjectQo qo) {
|
|
List<ZtTask> closed = this.baseMapper.selectList(new QueryWrapper<ZtTask>().lambda()
|
|
.ne(ZtTask::getStatus, "closed").eq(ZtTask::getOpenedby, RiskUserThreadLocal.get().getName())
|
|
.or().eq(ZtTask::getAssignedTo, RiskUserThreadLocal.get().getName())
|
|
.orderByDesc(ZtTask::getDeadline)
|
|
.orderByDesc(ZtTask::getId)
|
|
);
|
|
if (CollectionUtils.isEmpty(closed)) {
|
|
return new ArrayList<>();
|
|
}
|
|
|
|
return BeanCopyUtil.copyListProperties(closed, ZtTaskDTO::new);
|
|
}
|
|
|
|
|
|
@Override
|
|
public void addRemark(ZtTaskDTO dto) {
|
|
ZtTask task = this.baseMapper.selectById(dto.getId());
|
|
|
|
Integer productId = null;
|
|
Integer projectId = null;
|
|
Integer execution = null;
|
|
if (task.getStory() != null && task.getStory() != 0) {
|
|
|
|
execution = task.getExecution();
|
|
projectId = task.getProject();
|
|
if (task.getStory() != null && task.getStory() != 0) {
|
|
ZtStory story = this.storyService.getById(task.getStory());
|
|
if (story != null) {
|
|
productId = story.getProduct();
|
|
}
|
|
}
|
|
}
|
|
|
|
actionService.addAction(ActionType.RW, ActionStatus.TJBZ, dto.getId(), productId == null ? "" : productId + "", projectId, task.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), dto.getRemark(), "");
|
|
}
|
|
|
|
@Override
|
|
public ZtTaskDTO getTaskById(Integer id) {
|
|
ZtTask ztTask = this.baseMapper.selectById(id);
|
|
if (ztTask == null) {
|
|
throw new BusinessException("未查询到数据");
|
|
}
|
|
Map<String, ZtUser> userMap = this.userService.userMapByIds(null);
|
|
|
|
ZtTaskDTO dto = new ZtTaskDTO();
|
|
BeanUtils.copyProperties(ztTask, dto);
|
|
if (ztTask.getExecution() != null && ztTask.getExecution() != 0) {
|
|
ZtProject project = this.ztProjectService.getById(ztTask.getExecution());
|
|
dto.setImplementId(project.getId());
|
|
dto.setImplementName(project.getName());
|
|
}
|
|
if (dto.getDeadline() != null) {
|
|
dto.setDeadline(DateUtils.getDayLast(ztTask.getDeadline()));
|
|
}
|
|
ZtUser ztUser = userMap.get(ztTask.getAssignedTo());
|
|
if (ztUser != null) {
|
|
dto.setAssignedToName(ztUser.getNickname());
|
|
}
|
|
|
|
return dto;
|
|
}
|
|
|
|
@Override
|
|
public List<ZtTaskDTO> taskListPrd(Integer id) {
|
|
return this.baseMapper.taskListPrd(id);
|
|
}
|
|
|
|
@Override
|
|
public List<ItApproval> itApprovalByUserName(String s, Date firstDayOfMonth, Date lastDayOfMonth) {
|
|
return this.baseMapper.itApprovalByUserName(s, firstDayOfMonth, lastDayOfMonth);
|
|
}
|
|
|
|
|
|
@Override
|
|
public PageInfo<ZtTaskDTO> myTaskPageList(ZtProjectQo qo) {
|
|
|
|
qo.setUserName(RiskUserThreadLocal.get().getName());
|
|
LoginRiskUser loginRiskUser = RiskUserThreadLocal.get();
|
|
//执行ids
|
|
List<Integer> projectAuthList = new ArrayList<>();
|
|
|
|
|
|
//自己有权限的 产品集
|
|
List<Integer> authList = this.ztProjectService.authList();
|
|
|
|
if (!CollectionUtils.isEmpty(authList)) {
|
|
List<ZtProduct> pList = this.productService.list(new QueryWrapper<ZtProduct>().lambda().in(ZtProduct::getProgram, authList));
|
|
//所有的产品
|
|
if (!CollectionUtils.isEmpty(pList)) {
|
|
List<ZtProjectproduct> list = this.projectproductService.list(new QueryWrapper<ZtProjectproduct>().lambda().in(ZtProjectproduct::getProduct, pList.stream().map(o -> o.getId()).collect(Collectors.toList())));
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
List<ZtExecutionproject> projectList = executionprojectService.list(new QueryWrapper<ZtExecutionproject>().lambda().in(ZtExecutionproject::getProject, list.stream().map(o -> o.getProject()).collect(Collectors.toList())));
|
|
projectAuthList = projectList.stream().map(o -> o.getExecution()).collect(Collectors.toList());
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
if (CollectionUtils.isEmpty(projectAuthList)) {
|
|
return new PageInfo<ZtTaskDTO>();
|
|
}
|
|
Page<ZtTaskDTO> page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
|
|
qo.setProjectIds(projectAuthList);
|
|
|
|
if (!StringUtils.isEmpty(qo.getIds())) {
|
|
String[] split = qo.getIds().split(",");
|
|
qo.setObjIds(new ArrayList<>(Arrays.asList(split)));
|
|
}
|
|
if (!StringUtils.isEmpty(qo.getProductName())) {
|
|
List<ZtProduct> pList = this.productService.selectProductByName(qo.getProductName());
|
|
if (!CollectionUtils.isEmpty(pList)) {
|
|
List<ZtProjectproduct> list = this.projectproductService.list(new QueryWrapper<ZtProjectproduct>()
|
|
.lambda().in(ZtProjectproduct::getProduct, pList.stream().map(o -> o.getId()).collect(Collectors.toList())));
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
return new PageInfo<>();
|
|
} else {
|
|
qo.setProjectList(list.stream().map(o -> o.getProject()).collect(Collectors.toList()));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
List<ZtTaskDTO> list = this.baseMapper.taskPageList(qo);
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
List<String> userIds = list.stream().map(o -> o.getFinishedby()).collect(Collectors.toList());
|
|
userIds.addAll(list.stream().map(o -> o.getAssignedTo()).collect(Collectors.toList()));
|
|
Map<String, ZtUser> userMap = this.userService.userMapByIds(null);
|
|
|
|
for (ZtTaskDTO task : list) {
|
|
ZtUser ztUser = userMap.get(task.getFinishedby());
|
|
if (ztUser != null) {
|
|
task.setFinishedbyName(ztUser.getNickname());
|
|
}
|
|
ztUser = userMap.get(task.getAssignedTo());
|
|
if (ztUser != null) {
|
|
task.setAssignedToName(ztUser.getNickname());
|
|
}
|
|
if (task.getDeadline() != null) {
|
|
task.setDeadline(DateUtils.getDayLast(task.getDeadline()));
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
return new PageInfo<ZtTaskDTO>(list);
|
|
}
|
|
|
|
|
|
@Autowired
|
|
private IZtProjectstoryService projectstoryService;
|
|
|
|
@Autowired
|
|
private IZtFileService fileService;
|
|
|
|
@Override
|
|
@Transactional
|
|
public void addTask(ZtTaskDTO dto) {
|
|
ZtTask ztTask = new ZtTask();
|
|
BeanUtils.copyProperties(dto, ztTask);
|
|
ztTask.setOpenedby(RiskUserThreadLocal.get().getName());
|
|
ztTask.setOpeneddate(new Date());
|
|
ztTask.setEstimate(dto.getLeft());
|
|
|
|
|
|
//getExecution()执行
|
|
//项目
|
|
Integer story = ztTask.getStory();
|
|
if (story != null && story != 0) {
|
|
ZtStory ztStory = this.storyService.getById(story);
|
|
ztStory.setTaskCount(ztStory.getTaskCount() + 1);
|
|
this.storyService.updateById(ztStory);
|
|
List<ZtProjectstory> list = projectstoryService.list(new QueryWrapper<ZtProjectstory>().lambda().eq(ZtProjectstory::getStory, story)
|
|
.ne(ZtProjectstory::getProject, 0)
|
|
);
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
ztTask.setProject(list.get(0).getProject());
|
|
} else {
|
|
List<ZtExecutionproject> execList = this.executionprojectService.list(new QueryWrapper<ZtExecutionproject>().lambda().eq(ZtExecutionproject::getExecution, ztTask.getExecution()));
|
|
ztTask.setProject(execList.get(0).getExecution());
|
|
}
|
|
} else {
|
|
Integer execution = dto.getExecution();
|
|
//迭代
|
|
ZtExecutionproject executionproject = this.executionprojectService.getOne(new QueryWrapper<ZtExecutionproject>().lambda().eq(ZtExecutionproject::getExecution, execution));
|
|
|
|
Integer project = executionproject.getProject();
|
|
|
|
ZtProjectproduct projectproduct = this.projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, project));
|
|
ztTask.setProduct(projectproduct.getProduct());
|
|
ztTask.setProject(project);
|
|
}
|
|
//如果是开发人员 需要评审
|
|
UserType userType = RiskUserThreadLocal.get().getUserType();
|
|
|
|
if (dto.getDraftFlag() != null && dto.getDraftFlag() == 1) {
|
|
ztTask.setStatus("draft");
|
|
} else {
|
|
if (userType == UserType.KFZ) {
|
|
ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution());
|
|
ztTask.setStatus("reviewing");
|
|
ztTask.setReviewingUser(ztProject.getPm());
|
|
} else {
|
|
ztTask.setStatus("wait");
|
|
ztTask.setReviewingUser(null);
|
|
}
|
|
}
|
|
|
|
if (ztTask.getDeadline() != null) {
|
|
ztTask.setDeadlineTime(ztTask.getDeadline().getTime() / 1000);
|
|
}
|
|
Integer project = ztTask.getProject();
|
|
ZtProjectproduct ztProjectproduct = this.projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda()
|
|
.eq(ZtProjectproduct::getProject, project));
|
|
if (ztProjectproduct != null) {
|
|
ztTask.setProduct(ztProjectproduct.getProduct());
|
|
}
|
|
if(dto.getFinishedFlag()==null||dto.getFinishedFlag()==0){
|
|
//不完成任务
|
|
}else{
|
|
//完成修补数据
|
|
ztTask.setRealstarted(new Date(ztTask.getApplyDate().getTime()-ztTask.getUseTime()
|
|
.multiply(BigDecimal.valueOf(60*60*1000)).longValue()));
|
|
ztTask.setEstStarted(ztTask.getRealstarted());
|
|
ztTask.setDeadline(new Date(DateUtils.getDayEndDate(ztTask.getApplyDate()).getTime()-1000*60*5));
|
|
ztTask.setEstimate(ztTask.getUseTime().floatValue());
|
|
ztTask.setLeft(ztTask.getUseTime().floatValue());
|
|
}
|
|
|
|
this.baseMapper.insert(ztTask);
|
|
|
|
fileService.updateFile(dto.getFiles(), ztTask.getId(), FileTypes.task);
|
|
if (ztTask.getExecution() != null && ztTask.getExecution() != 0) {
|
|
kanbanlaneService.addTask(dto.getExecution(), Arrays.asList(ztTask));
|
|
}
|
|
|
|
ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject()));
|
|
|
|
|
|
actionService.addAction(ActionType.RW, ActionStatus.XJ, ztTask.getId()
|
|
, projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(),"", null);
|
|
|
|
|
|
if(dto.getFinishedFlag()!=null&&dto.getFinishedFlag()==1){
|
|
//如果选了完成并且不需要审核那么直接完成
|
|
if((userType==UserType.XMGLY||userType==UserType.GSGC)&&!ztTask.getStatus().equals("draft")){
|
|
dto.setId(ztTask.getId());
|
|
dto.setConsumed(ztTask.getUseTime().floatValue());
|
|
dto.setLeft(ztTask.getUseTime().floatValue());
|
|
this.startTask(dto);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
@Transactional
|
|
public void modifyTask(ZtTaskDTO dto) {
|
|
ZtTask ztTask = this.baseMapper.selectById(dto.getId());
|
|
if (ztTask == null) {
|
|
throw new BusinessException("未查询到数据");
|
|
}
|
|
// if(!Arrays.asList("draft","reviewing").contains(ztTask.getStatus())){
|
|
// throw new BusinessException("当前无法编辑");
|
|
// }
|
|
String desc = ztTask.getDesc();
|
|
String status = ztTask.getStatus();
|
|
BeanUtils.copyProperties(dto, ztTask, "left", "consumed");
|
|
ztTask.setEstimate(dto.getEstimate());
|
|
//剩余
|
|
ztTask.setLeft(BigDecimal.valueOf(dto.getEstimate()).subtract(BigDecimal.valueOf(ztTask.getConsumed())).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
|
|
ztTask.setLastediteddate(new Date());
|
|
ztTask.setLasteditedby(RiskUserThreadLocal.get().getName());
|
|
if (ztTask.getDeadline() != null) {
|
|
ztTask.setDeadlineTime(ztTask.getDeadline().getTime() / 1000);
|
|
}
|
|
UserType userType = RiskUserThreadLocal.get().getUserType();
|
|
if (dto.getDraftFlag() != null && dto.getDraftFlag() == 1) {
|
|
ztTask.setStatus("draft");
|
|
}else{
|
|
if(status.equals("draft")){
|
|
//如果是开发人员 需要评审
|
|
|
|
if (userType == UserType.KFZ) {
|
|
ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution());
|
|
ztTask.setStatus("reviewing");
|
|
ztTask.setReviewingUser(ztProject.getPm());
|
|
} else {
|
|
ztTask.setStatus("wait");
|
|
ztTask.setReviewingUser(null);
|
|
}
|
|
}else if ((userType==UserType.XMGLY||userType==UserType.GSGC) &&status.equals("wait")){
|
|
ztTask.setStatus("wait");
|
|
}else{
|
|
ztTask.setStatus("reviewing");
|
|
ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution());
|
|
ztTask.setReviewingUser(ztProject.getPm());
|
|
ztTask.setApprovalResult(0);
|
|
}
|
|
|
|
}
|
|
if(dto.getFinishedFlag()==null||dto.getFinishedFlag()==0){
|
|
//不完成任务
|
|
}else{
|
|
//完成修补数据
|
|
ztTask.setRealstarted(new Date(ztTask.getApplyDate().getTime()-ztTask.getUseTime()
|
|
.multiply(BigDecimal.valueOf(60*60*1000)).longValue()));
|
|
ztTask.setEstStarted(ztTask.getRealstarted());
|
|
ztTask.setDeadline(new Date(DateUtils.getDayEndDate(ztTask.getApplyDate()).getTime()-1000*60*5));
|
|
ztTask.setEstimate(ztTask.getUseTime().floatValue());
|
|
ztTask.setLeft(ztTask.getUseTime().floatValue());
|
|
}
|
|
|
|
this.baseMapper.updateById(ztTask);
|
|
|
|
fileService.updateFile(dto.getFiles(), ztTask.getId(), FileTypes.task);
|
|
|
|
Integer storyId = ztTask.getStory();
|
|
if (storyId != null && storyId != 0) {
|
|
ZtStory story = this.storyService.getById(storyId);
|
|
actionService.addAction(ActionType.RW, ActionStatus.BJ, ztTask.getId(), story.getProduct() == null ? "" : story.getProduct().toString(), ztTask.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), (!StringUtils.isEmpty(desc) && !desc.equals(dto.getDesc())) ? dto.getDesc() : null, null);
|
|
if (!StringUtils.isEmpty(dto.getRemark())) {
|
|
actionService.addAction(ActionType.RW, ActionStatus.TJBZ, ztTask.getId(), story.getProduct() == null ? "" : story.getProduct().toString(), ztTask.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), dto.getRemark(), null);
|
|
}
|
|
} else {
|
|
actionService.addAction(ActionType.RW, ActionStatus.BJ, ztTask.getId(), "", ztTask.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), (!StringUtils.isEmpty(desc) && !desc.equals(dto.getDesc())) ? dto.getDesc() : null, null);
|
|
if (!StringUtils.isEmpty(dto.getRemark())) {
|
|
actionService.addAction(ActionType.RW, ActionStatus.TJBZ, ztTask.getId(), "", ztTask.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), dto.getRemark(), null);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
@Transactional
|
|
public void startTask(ZtTaskDTO dto) {
|
|
|
|
if (dto.getLeft() < dto.getConsumed()) {
|
|
throw new BusinessException("工时填写错误");
|
|
}
|
|
ZtTask ztTask = this.baseMapper.selectById(dto.getId());
|
|
String status = ztTask.getStatus();
|
|
if (!"wait".equalsIgnoreCase(ztTask.getStatus())) {
|
|
throw new BusinessException("未查询到数据");
|
|
}
|
|
ztTask.setAssignedTo(dto.getAssignedTo());
|
|
ztTask.setRealstarted(new Date());
|
|
if (dto.getFinishedFlag() == 0) {
|
|
ztTask.setStatus("doing");
|
|
} else {
|
|
ztTask.setStatus("done");
|
|
ztTask.setFinishedby(RiskUserThreadLocal.get().getName());
|
|
ztTask.setFinishedDate(new Date());
|
|
}
|
|
|
|
ztTask.setLasteditedby(RiskUserThreadLocal.get().getName());
|
|
ztTask.setLastediteddate(new Date());
|
|
ztTask.setConsumed(dto.getConsumed());
|
|
ztTask.setLeft(dto.getLeft() - dto.getConsumed());
|
|
this.baseMapper.updateById(ztTask);
|
|
if(ztTask.getFeedback()!=null&&ztTask.getFeedback()!=0){
|
|
if("doing".equals(ztTask.getStatus())){
|
|
this.storyFeedbackService.feedbackStart(ztTask.getFeedback());
|
|
}else{
|
|
this.storyFeedbackService.feedbackFinished(ztTask.getFeedback());
|
|
}
|
|
|
|
}
|
|
if (dto.getConsumed() > 0) {
|
|
ZtEffortDTO e = new ZtEffortDTO();
|
|
BeanUtils.copyProperties(ztTask, e);
|
|
e.setWork(dto.getRemark());
|
|
e.setObjectid(ztTask.getId());
|
|
this.effortService.add(e);
|
|
}
|
|
|
|
//添加action
|
|
ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda()
|
|
.eq(ZtProjectproduct::getProject, ztTask.getProject()));
|
|
|
|
actionService.addAction(ActionType.RW, ActionStatus.KS, dto.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), dto.getRemark(), null);
|
|
|
|
if (ztTask.getExecution() != null && ztTask.getExecution() != 0) {
|
|
if (StringUtils.isEmpty(dto.getTabType())) {
|
|
KanbanQo qo = new KanbanQo();
|
|
qo.setStatusType("wait");
|
|
qo.setTabType("task");
|
|
qo.setId(dto.getId());
|
|
//查
|
|
ZtKanbancell ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "wait", ztTask.getExecution());
|
|
|
|
qo.setFromId(ztKanbanlane.getColumn());
|
|
//查
|
|
if (dto.getFinishedFlag() == 0) {
|
|
ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developing", ztTask.getExecution());
|
|
|
|
} else {
|
|
ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developed", ztTask.getExecution());
|
|
|
|
}
|
|
qo.setToId(ztKanbanlane.getColumn());
|
|
kanbanlaneService.changeStatus(qo);
|
|
} else {
|
|
KanbanQo qo = new KanbanQo();
|
|
qo.setStatusType(dto.getStatusType());
|
|
qo.setTabType(dto.getTabType());
|
|
qo.setId(dto.getId());
|
|
qo.setFromId(dto.getFromId());
|
|
qo.setToId(dto.getToId());
|
|
kanbanlaneService.changeStatus(qo);
|
|
}
|
|
}
|
|
if ("devel".equals(ztTask.getType())) {
|
|
//处理需求
|
|
|
|
if ("done".equals(ztTask.getStatus())) {
|
|
this.storyService.finishStory(ztTask.getStory(),null);
|
|
} else if ("doing".equals(ztTask.getStatus())) {
|
|
this.storyService.startStory(ztTask.getStory());
|
|
}
|
|
}
|
|
if ("test".equals(ztTask.getType())) {
|
|
//处理需求
|
|
if ("done".equals(ztTask.getStatus())) {
|
|
this.storyService.testedStory(ztTask.getStory(),null);
|
|
} else if ("doing".equals(ztTask.getStatus())) {
|
|
this.storyService.testingStory(ztTask.getStory());
|
|
}
|
|
|
|
}
|
|
|
|
|
|
Integer execution = ztTask.getExecution();
|
|
ZtProject project = this.ztProjectService.getById(execution);
|
|
if (project != null && "wait".equalsIgnoreCase(project.getStatus())) {
|
|
project.setStatus("doing");
|
|
this.ztProjectService.updateById(project);
|
|
}
|
|
if (dto.getFinishedFlag() == 1) {
|
|
String type = ztTask.getType();
|
|
if (ztTask.getStory() != null && ztTask.getStory() != 0) {
|
|
if ("test".equals(type)) {
|
|
this.storyService.testedStory(ztTask.getStory(),null);
|
|
} else if ("devel".equals(type)) {
|
|
//开发
|
|
this.storyService.finishStory(ztTask.getStory(),null);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
@Transactional
|
|
public void finishTask(ZtTaskDTO dto,String finishBy) {
|
|
ZtTask ztTask = this.baseMapper.selectById(dto.getId());
|
|
if ("done".equalsIgnoreCase(ztTask.getStatus())) {
|
|
throw new BusinessException("未查询到数据");
|
|
}
|
|
ztTask.setConsumed(dto.getConsumed() + ztTask.getConsumed());
|
|
ztTask.setLeft(ztTask.getEstimate() - ztTask.getConsumed());
|
|
ztTask.setStatus("done");
|
|
if(ztTask.getFinishedFlag()!=null&&ztTask.getFinishedFlag()==1){
|
|
ztTask.setFinishedby(ztTask.getAssignedTo());
|
|
}else{
|
|
ztTask.setFinishedby(RiskUserThreadLocal.get().getName());
|
|
}
|
|
|
|
ztTask.setFinishedDate(new Date());
|
|
ztTask.setLasteditedby(RiskUserThreadLocal.get().getName());
|
|
ztTask.setLastediteddate(new Date());
|
|
this.baseMapper.updateById(ztTask);
|
|
|
|
ZtEffortDTO e = new ZtEffortDTO();
|
|
BeanUtils.copyProperties(ztTask, e);
|
|
e.setObjectid(ztTask.getId());
|
|
e.setLeft(0F);
|
|
e.setConsumed(dto.getConsumed());
|
|
e.setAccount(StringUtils.isEmpty(finishBy)?RiskUserThreadLocal.get().getName():finishBy);
|
|
this.effortService.add(e);
|
|
|
|
//添加action
|
|
ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject()));
|
|
actionService.addAction(ActionType.RW, ActionStatus.WC, dto.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), ztTask.getExecution(),
|
|
StringUtils.isEmpty(finishBy)?RiskUserThreadLocal.get().getName():finishBy, dto.getRemark(), null);
|
|
if (ztTask.getExecution() != null && ztTask.getExecution() != 0) {
|
|
if (StringUtils.isEmpty(dto.getTabType())) {
|
|
// KanbanQo qo = new KanbanQo();
|
|
// qo.setStatusType("developed");
|
|
// qo.setTabType("task");
|
|
// qo.setId(dto.getId());
|
|
// //查
|
|
// ZtKanbancell ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developing", ztTask.getExecution());
|
|
//
|
|
// qo.setFromId(ztKanbanlane.getColumn());
|
|
// //查
|
|
// ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developed", ztTask.getExecution());
|
|
// qo.setToId(ztKanbanlane.getColumn());
|
|
kanbanlaneService.changeStatus(ztTask.getExecution(),ztTask.getId(),"task","developed");
|
|
} else {
|
|
KanbanQo qo = new KanbanQo();
|
|
qo.setStatusType(dto.getStatusType());
|
|
qo.setTabType(dto.getTabType());
|
|
qo.setId(dto.getId());
|
|
qo.setFromId(dto.getFromId());
|
|
qo.setToId(dto.getToId());
|
|
kanbanlaneService.changeStatus(qo);
|
|
}
|
|
}
|
|
// devel 开发 request 需求 test
|
|
//如果有一个开发任务进行中,并且所有的测试任务还没有开始,需求的研发阶段为“研发中”
|
|
//如果所有的开发任务已经完成,并且所有的测试任务还没有开始,则为“研发完毕"
|
|
//如果有一个测试任务进行中,则视为“测试中”
|
|
//如果所有的测试任务已经结束,但还有一些开发任务没有结束,则视为"测试中"
|
|
//如果所有的测试任务已经结束,并且所有的开发任务已经结束,则视为"测试完毕"
|
|
// pause 暂停 cancel取消 closed 关闭 done 完成 wait reviewing待评审 doing
|
|
// devel 开发 request 需求 test
|
|
String type = ztTask.getType();
|
|
if (ztTask.getStory() != null && ztTask.getStory() != 0) {
|
|
if ("test".equals(type)) {
|
|
this.storyService.testedStory(ztTask.getStory(),finishBy);
|
|
} else if ("devel".equals(type)) {
|
|
//开发
|
|
this.storyService.finishStory(ztTask.getStory(),finishBy);
|
|
}
|
|
}
|
|
if(ztTask.getFeedback()!=null&&ztTask.getFeedback()!=0){
|
|
this.storyFeedbackService.feedbackFinished(ztTask.getFeedback());
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
@Transactional
|
|
public void closeTask(ZtTaskDTO dto) {
|
|
ZtTask ztTask = this.baseMapper.selectById(dto.getId());
|
|
String status = ztTask.getStatus();
|
|
if ("closed".equalsIgnoreCase(ztTask.getStatus())) {
|
|
throw new BusinessException("未查询到数据");
|
|
}
|
|
ztTask.setLeft(0f);
|
|
ztTask.setStatus("closed");
|
|
ztTask.setLasteditedby(RiskUserThreadLocal.get().getName());
|
|
ztTask.setLastediteddate(new Date());
|
|
this.baseMapper.updateById(ztTask);
|
|
ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject()));
|
|
|
|
//添加action
|
|
actionService.addAction(ActionType.RW, ActionStatus.QX, dto.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), ztTask.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), dto.getDesc(), null);
|
|
if (ztTask.getExecution() != null && ztTask.getExecution() != 0) {
|
|
if (StringUtils.isEmpty(dto.getTabType())) {
|
|
kanbanlaneService.changeStatus(ztTask.getExecution(), ztTask.getId(), "task", "closed");
|
|
} else {
|
|
KanbanQo qo = new KanbanQo();
|
|
qo.setStatusType(dto.getStatusType());
|
|
qo.setTabType(dto.getTabType());
|
|
qo.setId(dto.getId());
|
|
qo.setFromId(dto.getFromId());
|
|
qo.setToId(dto.getToId());
|
|
kanbanlaneService.changeStatus(qo);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
@Transactional
|
|
public void cancelTask(ZtTaskDTO dto) {
|
|
ZtTask ztTask = this.baseMapper.selectById(dto.getId());
|
|
String status = ztTask.getStatus();
|
|
if ("cancel".equalsIgnoreCase(ztTask.getStatus())) {
|
|
throw new BusinessException("未查询到数据");
|
|
}
|
|
if("done".equals(status)||"closed".equals(status)){
|
|
throw new BusinessException("当前状态无法取消");
|
|
}
|
|
ztTask.setLeft(0f);
|
|
ztTask.setStatus("cancel");
|
|
ztTask.setLasteditedby(RiskUserThreadLocal.get().getName());
|
|
ztTask.setLastediteddate(new Date());
|
|
this.baseMapper.updateById(ztTask);
|
|
ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject()));
|
|
|
|
//添加action
|
|
actionService.addAction(ActionType.RW, ActionStatus.QX, dto.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), ztTask.getProject(), ztTask.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), dto.getDesc(), null);
|
|
|
|
if (ztTask.getExecution() != null && ztTask.getExecution() != 0) {
|
|
if (StringUtils.isEmpty(dto.getTabType())) {
|
|
|
|
kanbanlaneService.changeStatus(ztTask.getExecution(),ztTask.getId(),"task","canceled");
|
|
} else {
|
|
KanbanQo qo = new KanbanQo();
|
|
qo.setStatusType(dto.getStatusType());
|
|
qo.setTabType(dto.getTabType());
|
|
qo.setId(dto.getId());
|
|
qo.setFromId(dto.getFromId());
|
|
qo.setToId(dto.getToId());
|
|
kanbanlaneService.changeStatus(qo);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@Transactional
|
|
public void batchAddTask(ZtTaskDTO dto) {
|
|
if (CollectionUtils.isEmpty(dto.getList())) {
|
|
throw new BusinessException("请检查数据");
|
|
}
|
|
long count = dto.getList().stream().filter(o -> StringUtils.isEmpty(o.getName())).count();
|
|
if (count > 0) {
|
|
throw new BusinessException("请检查数据");
|
|
}
|
|
|
|
|
|
Integer storyId = dto.getList().get(0).getStory();
|
|
ZtProjectstory projectstory = projectstoryService.getOne(new QueryWrapper<ZtProjectstory>().lambda().eq(ZtProjectstory::getStory, storyId)
|
|
.eq(ZtProjectstory::getType, ProjectTypeEnums.project.getValue())
|
|
);
|
|
|
|
// //如果是开发人员 需要评审
|
|
UserType userType = RiskUserThreadLocal.get().getUserType();
|
|
|
|
List<ZtTaskDTO> list = dto.getList();
|
|
List<ZtTask> saveList = new ArrayList();
|
|
for (ZtTaskDTO d : list) {
|
|
if (d.getEstimate() == null) {
|
|
throw new BusinessException("请检查工时");
|
|
}
|
|
ZtTask ztTask = new ZtTask();
|
|
|
|
BeanUtils.copyProperties(d, ztTask);
|
|
ztTask.setProject(projectstory.getProject());
|
|
ztTask.setOpenedby(RiskUserThreadLocal.get().getName());
|
|
ztTask.setOpeneddate(new Date());
|
|
if (userType == UserType.KFZ) {
|
|
ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution());
|
|
ztTask.setStatus("reviewing");
|
|
ztTask.setReviewingUser(ztProject.getPm());
|
|
} else {
|
|
ztTask.setStatus("wait");
|
|
ztTask.setReviewingUser(null);
|
|
}
|
|
ztTask.setLeft(ztTask.getEstimate());
|
|
ztTask.setConsumed(0f);
|
|
if (ztTask.getDeadline() != null) {
|
|
ztTask.setDeadlineTime(ztTask.getDeadline().getTime() / 1000);
|
|
}
|
|
Integer project = ztTask.getProject();
|
|
ZtProjectproduct ztProjectproduct = this.projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda()
|
|
.eq(ZtProjectproduct::getProject, project));
|
|
if (ztProjectproduct != null) {
|
|
ztTask.setProduct(ztProjectproduct.getProduct());
|
|
}
|
|
saveList.add(ztTask);
|
|
}
|
|
|
|
|
|
this.saveBatch(saveList);
|
|
|
|
kanbanlaneService.addTask(list.get(0).getExecution(), saveList);
|
|
ZtStory story = storyService.getById(list.get(0).getStory());
|
|
ZtProjectstory projectStory = this.projectstoryService.getOne(new QueryWrapper<ZtProjectstory>().lambda().eq(ZtProjectstory::getStory, story.getId()).eq(ZtProjectstory::getType, ProjectTypeEnums.project.getValue()));
|
|
|
|
for (ZtTask t : saveList) {
|
|
|
|
ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, projectStory.getProject()));
|
|
|
|
actionService.addAction(ActionType.RW, ActionStatus.XJ, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), "", null);
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
@Transactional
|
|
public void approval(ZtTaskDTO dto) {
|
|
|
|
|
|
LoginRiskUser loginRiskUser = RiskUserThreadLocal.get();
|
|
if(loginRiskUser==null){
|
|
throw new BusinessException("请登录");
|
|
}
|
|
String account = loginRiskUser.getName();
|
|
|
|
|
|
|
|
|
|
ZtTask t = this.baseMapper.selectById(dto.getId());
|
|
|
|
if (!t.getStatus().equals("reviewing")) {
|
|
throw new BusinessException("未查询到数据");
|
|
}
|
|
if(!account.equals(t.getReviewingUser())){
|
|
throw new BusinessException("当前无法评审");
|
|
}
|
|
if (dto.getApprovalStatus() == 1) {
|
|
t.setStatus("wait");
|
|
//完成任务
|
|
|
|
|
|
} else {
|
|
t.setApprovalResult(1);
|
|
t.setStatus("draft");
|
|
}
|
|
|
|
t.setApprovalRemark(dto.getApprovalRemark());
|
|
t.setLastediteddate(new Date());
|
|
t.setLasteditedby(RiskUserThreadLocal.get().getName());
|
|
|
|
ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper<ZtProjectproduct>().lambda().eq(ZtProjectproduct::getProject, t.getProject()));
|
|
|
|
if (dto.getApprovalStatus() == 1) {
|
|
actionService.addAction(ActionType.RW, ActionStatus.PSTG, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), dto.getApprovalRemark(), null);
|
|
} else {
|
|
actionService.addAction(ActionType.RW, ActionStatus.PSBTG, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(),
|
|
RiskUserThreadLocal.get().getName(), dto.getApprovalRemark(), null);
|
|
}
|
|
this.baseMapper.updateById(t);
|
|
if (dto.getApprovalStatus() == 1) {
|
|
if(t.getFinishedFlag()!=null&&t.getFinishedFlag()==1){
|
|
dto.setConsumed(t.getEstimate());
|
|
dto.setRealstarted(t.getRealstarted());
|
|
dto.setFinishedDate(t.getFinishedDate());
|
|
this.finishTask(dto,t.getAssignedTo());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
public List<ZtTaskDTO> taskListByExecution(ZtTaskDTO dto) {
|
|
LambdaQueryWrapper<ZtTask> eq = new QueryWrapper<ZtTask>().lambda();
|
|
|
|
if (dto.getExecution() != null) {
|
|
eq.eq(ZtTask::getExecution, dto.getExecution());
|
|
}
|
|
|
|
|
|
if (dto.getStory() != null) {
|
|
eq.eq(ZtTask::getStory, dto.getStory());
|
|
}
|
|
List<ZtTask> ztTasks = this.baseMapper.selectList(eq);
|
|
if (CollectionUtils.isEmpty(ztTasks)) {
|
|
return new ArrayList<>();
|
|
} else {
|
|
return BeanCopyUtil.copyListProperties(ztTasks, ZtTaskDTO::new);
|
|
}
|
|
}
|
|
|
|
|
|
}
|