|
@@ -16,6 +16,7 @@ import com.management.platform.service.impl.WxCorpInfoServiceImpl;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import net.sourceforge.tess4j.ITessAPI;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.assertj.core.util.Lists;
|
|
@@ -52,6 +53,15 @@ import java.util.stream.Collectors;
|
|
|
@RequestMapping("/task")
|
|
|
@Slf4j
|
|
|
public class TaskController {
|
|
|
+ //任务状态,0-进行中 1-已完成 2-已撤销 3-待第一审核人审核 4-待第二审核人审核 5-第一审校人驳回 6-第二审校人驳回
|
|
|
+ public static final Integer STATUS_DOING = 0;
|
|
|
+ public static final Integer STATUS_FINISH = 1;
|
|
|
+ public static final Integer STATUS_CANCEL = 2;
|
|
|
+ public static final Integer STATUS_FIRST_CHECK = 3;
|
|
|
+ public static final Integer STATUS_SECOND_CHECK = 4;
|
|
|
+ public static final Integer STATUS_FIRST_REJECT = 5;
|
|
|
+ public static final Integer STATUS_SECOND_REJECT = 6;
|
|
|
+
|
|
|
@Resource
|
|
|
private HttpServletRequest request;
|
|
|
@Resource
|
|
@@ -83,6 +93,8 @@ public class TaskController {
|
|
|
@Resource
|
|
|
private TaskMapper taskMapper;
|
|
|
@Resource
|
|
|
+ private TaskTypeService taskTypeService;
|
|
|
+ @Resource
|
|
|
private TaskExecutorMapper taskExecutorMapper;
|
|
|
@Resource
|
|
|
private ParticipationMapper participationMapper;
|
|
@@ -137,6 +149,10 @@ public class TaskController {
|
|
|
public static HashMap<String, Integer> corpddJobCenter = new HashMap();
|
|
|
@Autowired
|
|
|
private ProjectCategoryMapper projectCategoryMapper;
|
|
|
+ @Autowired
|
|
|
+ private ReportExtraDegreeMapper reportExtraDegreeMapper;
|
|
|
+ @Autowired
|
|
|
+ private TaskTypeMapper taskTypeMapper;
|
|
|
|
|
|
@PostMapping("/sendMsgToChargers")
|
|
|
public HttpRespMsg sendMsgToChargers(
|
|
@@ -171,7 +187,7 @@ public class TaskController {
|
|
|
|
|
|
@RequestMapping("/save")
|
|
|
@Transactional
|
|
|
- public HttpRespMsg save(Task task, @RequestParam(required = false, defaultValue = "false") boolean auditPass) throws Exception {
|
|
|
+ public HttpRespMsg save(Task task) throws Exception {
|
|
|
String userId = request.getHeader("Token");
|
|
|
String executorListStr = task.getExecutorListStr();
|
|
|
|
|
@@ -180,30 +196,35 @@ public class TaskController {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
int isInsert=0;
|
|
|
- int isUpdate=0;
|
|
|
+ boolean shouldResetAuditStatus = false;
|
|
|
+ List<TaskType> typeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", user.getCompanyId()));
|
|
|
+ TaskType taskType = typeList.stream().filter(t->t.getId()==task.getTaskPlanType()).findAny().orElse(null);
|
|
|
+ if (taskType == null){
|
|
|
+ msg.setError("任务类型不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
Project project = projectMapper.selectById(task.getProjectId());
|
|
|
- String inchargerId = project.getInchargerId();
|
|
|
- if (StringUtils.isEmpty(inchargerId)) {
|
|
|
+ String inchargerId = project != null ? project.getInchargerId() : null;
|
|
|
+ if (taskType.getNeedAudit() && project != null && StringUtils.isEmpty(inchargerId)) {
|
|
|
msg.setError("请先设置项目经理");
|
|
|
return msg;
|
|
|
}
|
|
|
+
|
|
|
//新建的任务,需要设置创建人,创建时间
|
|
|
if (task.getId() == null) {
|
|
|
+ //检查权限,只有项目的LA才能创建
|
|
|
+ boolean isLA = projectLeaderMapper.selectCount(new LambdaQueryWrapper<ProjectLeader>().eq(ProjectLeader::getProjectId, task.getProjectId()).eq(ProjectLeader::getLeaderId, userId)) > 0;
|
|
|
isInsert=1;
|
|
|
task.setCreateDate(LocalDate.now());
|
|
|
task.setCreaterId(userId);
|
|
|
task.setCreaterName(user.getName());
|
|
|
task.setCreatorColor(user.getColor());
|
|
|
task.setCompanyId(user.getCompanyId());
|
|
|
- if (task.getIsTaskPlan()==1){
|
|
|
- task.setTaskPlan(1);
|
|
|
- task.setTaskStatus(3);
|
|
|
- //状态是请假 直接变成任务
|
|
|
- if (task.getTaskPlanType()==3){
|
|
|
- task.setIsTaskPlan(0);
|
|
|
- task.setTaskStatus(0);
|
|
|
- task.setTaskPlan(1);
|
|
|
- }
|
|
|
+ //无需审核,直接通过
|
|
|
+ if (!taskType.getNeedAudit()){
|
|
|
+ task.setTaskStatus(STATUS_DOING);
|
|
|
+ } else {
|
|
|
+ task.setTaskStatus(STATUS_FIRST_CHECK);
|
|
|
}
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(executorListStr)) {
|
|
@@ -214,15 +235,18 @@ public class TaskController {
|
|
|
User exeUser = allUsers.stream().filter(al->al.getId().equals(ex.getExecutorId())).findFirst().get();
|
|
|
ex.setExecutorName(exeUser.getName());
|
|
|
ex.setExecutorColor(exeUser.getColor());
|
|
|
- ex.setFirstAuditorId(inchargerId);
|
|
|
- //设置第二负责人,员工部门主要负责人
|
|
|
- if (exeUser.getDepartmentId() != null && exeUser.getDepartmentId() > 0) {
|
|
|
- Department byId = departmentService.getById(exeUser.getDepartmentId());
|
|
|
- String managerId = byId.getManagerId();
|
|
|
- if (!StringUtils.isEmpty(managerId)) {
|
|
|
- ex.setSecondAuditorId(managerId);
|
|
|
- } else {
|
|
|
- msg.setError("请设置["+byId.getDepartmentName()+"]部门主要负责人");
|
|
|
+ //对于需要审核的任务,设置审核人
|
|
|
+ if (taskType.getNeedAudit()){
|
|
|
+ ex.setFirstAuditorId(inchargerId);
|
|
|
+ //设置第二负责人,员工部门主要负责人
|
|
|
+ if (exeUser.getDepartmentId() != null && exeUser.getDepartmentId() > 0) {
|
|
|
+ Department byId = departmentService.getById(exeUser.getDepartmentId());
|
|
|
+ String managerId = byId.getManagerId();
|
|
|
+ if (!StringUtils.isEmpty(managerId)) {
|
|
|
+ ex.setSecondAuditorId(managerId);
|
|
|
+ } else {
|
|
|
+ msg.setError("请设置["+byId.getDepartmentName()+"]部门主要负责人");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -333,8 +357,15 @@ public class TaskController {
|
|
|
needRecalculateProgress = true;
|
|
|
}
|
|
|
} else {
|
|
|
- //更新的情况,需要对比是否修改了任务标题,更新子任务的parentTname
|
|
|
Task oldTask = taskService.getById(task.getId());
|
|
|
+ if (taskType.getNeedAudit()) {
|
|
|
+ if (oldTask.getTaskStatus() == STATUS_CANCEL || oldTask.getTaskStatus() == STATUS_FIRST_REJECT || oldTask.getTaskStatus() == STATUS_SECOND_REJECT) {
|
|
|
+ //重新提交
|
|
|
+ task.setTaskStatus(STATUS_FIRST_CHECK);
|
|
|
+ shouldResetAuditStatus = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //更新的情况,需要对比是否修改了任务标题,更新子任务的parentTname
|
|
|
if (!oldTask.getName().equals(task.getName())) {
|
|
|
Task sample = new Task();
|
|
|
sample.setParentTname(task.getName());
|
|
@@ -366,14 +397,19 @@ public class TaskController {
|
|
|
taskExecutorService.removeByIds(ids);
|
|
|
}
|
|
|
if (task.getExecutorList().size() > 0) {
|
|
|
- task.getExecutorList().forEach(exe->exe.setTaskId(task.getId()));
|
|
|
+ List<TaskExecutor> exeList = task.getExecutorList();
|
|
|
+ exeList.forEach(exe->exe.setTaskId(task.getId()));
|
|
|
+ if (shouldResetAuditStatus) {
|
|
|
+ //重置审核状态为待第一审核人审核
|
|
|
+ exeList.forEach(exe->exe.setAuditStatus(STATUS_FIRST_CHECK));
|
|
|
+ }
|
|
|
//之前就存在的执行人数据
|
|
|
- List<TaskExecutor> oldHas = task.getExecutorList().stream().filter(t -> t.getId() != null).collect(Collectors.toList());
|
|
|
- taskExecutorService.saveOrUpdateBatch(task.getExecutorList());
|
|
|
+ List<TaskExecutor> oldHas = exeList.stream().filter(t -> t.getId() != null).collect(Collectors.toList());
|
|
|
+ taskExecutorService.saveOrUpdateBatch(exeList);
|
|
|
//新增的执行人
|
|
|
- msgRecepientList = task.getExecutorList().stream().filter(newT->!StringUtils.isEmpty(newT.getExecutorId()) && !oldExeList.stream().anyMatch(old->newT.getExecutorId().equals(old.getExecutorId())))
|
|
|
+ msgRecepientList = exeList.stream().filter(newT->!StringUtils.isEmpty(newT.getExecutorId()) && !oldExeList.stream().anyMatch(old->newT.getExecutorId().equals(old.getExecutorId())))
|
|
|
.map(TaskExecutor::getExecutorId).collect(Collectors.toList());
|
|
|
- List<TaskExecutor> newAddExecutor = task.getExecutorList().stream().filter(newT -> !StringUtils.isEmpty(newT.getExecutorId()) && !oldExeList.stream().anyMatch(old -> newT.getExecutorId().equals(old.getExecutorId()))).collect(Collectors.toList());
|
|
|
+ List<TaskExecutor> newAddExecutor = exeList.stream().filter(newT -> !StringUtils.isEmpty(newT.getExecutorId()) && !oldExeList.stream().anyMatch(old -> newT.getExecutorId().equals(old.getExecutorId()))).collect(Collectors.toList());
|
|
|
if(newAddExecutor.size()>0){
|
|
|
newAddExecutor=newAddExecutor.stream().filter(n->n.getExecutorId()!=null).collect(Collectors.toList());
|
|
|
if((wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1)||(dingding!=null&&dingding.getContactNeedTranslate()==1)){
|
|
@@ -408,7 +444,6 @@ public class TaskController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
if(task.getStartDate()==null){
|
|
|
taskMapper.updateStartDate(task.getId());
|
|
@@ -422,40 +457,9 @@ public class TaskController {
|
|
|
if ((oldTask.getTaskType() == 1 && task.getTaskType() != 1) || (oldTask.getTaskType() != 1 && task.getTaskType() == 1)) {
|
|
|
needRecalculateProgress = true;
|
|
|
}
|
|
|
- // 未驳回之前 第一审核人 修改工作计划
|
|
|
- if (task.getIsTaskPlan()==1
|
|
|
- && auditPass
|
|
|
- &&task.getTaskStatus()==3){
|
|
|
- isUpdate=1;
|
|
|
- task.setTaskStatus(4);//待第二审核人审核
|
|
|
- } else if (task.getIsTaskPlan() == 1
|
|
|
- && auditPass
|
|
|
- &&task.getTaskStatus()==4) {
|
|
|
- isUpdate=2;
|
|
|
- task.setTaskStatus(0);//变化为进行中
|
|
|
- task.setIsTaskPlan(0);//不再是计划
|
|
|
- }
|
|
|
- // 驳回后,小组长对计划进行修改
|
|
|
- if (task.getIsTaskPlan()==1
|
|
|
- &&(task.getTaskStatus()==5||task.getTaskStatus()==6)
|
|
|
- && auditPass //小组长保存并提交
|
|
|
- ){
|
|
|
- isUpdate=3;
|
|
|
- task.setTaskStatus(3);//待第一审核人审核
|
|
|
- }
|
|
|
- // 撤回后,对计划进行修改
|
|
|
- if (task.getIsTaskPlan()==1 && (task.getTaskStatus()==2) && auditPass) {
|
|
|
- if (user.getId().equals(project.getInchargerId())) {
|
|
|
- task.setTaskStatus(4);//待第二审核人审核
|
|
|
- isUpdate=5;
|
|
|
- }
|
|
|
- else {
|
|
|
- task.setTaskStatus(3);//待第一审核人审核
|
|
|
- isUpdate=4;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
- if (task.getIsTaskPlan()==1) {
|
|
|
+ if (taskType.getNeedAudit()) {
|
|
|
if (!task.getExecutorList().isEmpty()) {
|
|
|
List<User> userManagers = userMapper.selectList(new QueryWrapper<User>()
|
|
|
.eq("role_name", "区域经理&PM").eq("company_id",user.getCompanyId()));
|
|
@@ -467,11 +471,12 @@ public class TaskController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
boolean saved = taskService.saveOrUpdate(task);
|
|
|
//新增成功,给第一审核人发送信息提醒
|
|
|
if (saved&&isInsert==1){
|
|
|
- if (task.getIsTaskPlan()==1){
|
|
|
+ if (taskType.getNeedAudit()){
|
|
|
//给第一审核人发送信息提醒
|
|
|
msgRecepientList=new ArrayList<>();
|
|
|
log.info("添加工作计划,给第一审核人发送信息提醒");
|
|
@@ -484,59 +489,18 @@ public class TaskController {
|
|
|
information.setTime(LocalDateTime.now());
|
|
|
informationService.save(information);
|
|
|
}
|
|
|
- } else if (saved && isUpdate > 0) {
|
|
|
+ } else if (saved && shouldResetAuditStatus) {
|
|
|
msgRecepientList=new ArrayList<>();
|
|
|
- //第一审核人修改后, 变成待第二审核人审核
|
|
|
- if (isUpdate==1||isUpdate==5){
|
|
|
- for (TaskExecutor taskExecutor : task.getExecutorList()) {
|
|
|
- //给第二审核人发消息
|
|
|
- Information information = new Information();
|
|
|
- information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
|
|
|
- information.setTaskId(task.getId());
|
|
|
- information.setType(11);
|
|
|
- information.setUserId(taskExecutor.getSecondAuditorId());
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
- informationService.save(information);
|
|
|
- }
|
|
|
-
|
|
|
- }else if(isUpdate==2||isUpdate==6){
|
|
|
- List<TaskExecutor> taskExecutorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().eq("task_id", task.getId()));
|
|
|
- if(CollectionUtils.isNotEmpty(taskExecutorList)){
|
|
|
- for (TaskExecutor taskExecutor : taskExecutorList) {
|
|
|
- //给任务的执行人发送信息提醒
|
|
|
- User owner = userMapper.selectById(taskExecutor.getExecutorId());
|
|
|
- Information information = new Information();
|
|
|
- information.setMsg("您有新的任务");
|
|
|
- information.setContent(taskExecutor.getProjectId()==null?null:(""+taskExecutor.getProjectId()));
|
|
|
- information.setType(1);
|
|
|
- information.setUserId(owner.getId());
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
- informationService.save(information);
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (isUpdate==3) {
|
|
|
- //给第一审核人发送信息提醒
|
|
|
- log.info("驳回后小组长修改,给第一审核人发送信息提醒");
|
|
|
- User owner = userMapper.selectById(inchargerId);
|
|
|
- Information information = new Information();
|
|
|
- information.setType(11);
|
|
|
- information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
|
|
|
- information.setTaskId(task.getId());
|
|
|
- information.setUserId(owner.getId());
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
- informationService.save(information);
|
|
|
- } else if (isUpdate==4) {
|
|
|
- //给第一审核人发送信息提醒
|
|
|
- log.info("撤销后小组长修改,给第一审核人发送信息提醒");
|
|
|
- User owner = userMapper.selectById(inchargerId);
|
|
|
- Information information = new Information();
|
|
|
- information.setType(11);
|
|
|
- information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
|
|
|
- information.setTaskId(task.getId());
|
|
|
- information.setUserId(owner.getId());
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
- informationService.save(information);
|
|
|
- }
|
|
|
+ //给第一审核人发送信息提醒
|
|
|
+ log.info("撤销/驳回后小组长修改,给第一审核人发送信息提醒");
|
|
|
+ User owner = userMapper.selectById(inchargerId);
|
|
|
+ Information information = new Information();
|
|
|
+ information.setType(11);
|
|
|
+ information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
|
|
|
+ information.setTaskId(task.getId());
|
|
|
+ information.setUserId(owner.getId());
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
+ informationService.save(information);
|
|
|
}
|
|
|
if (task.getExecutorId() == null) {
|
|
|
//清空执行人
|
|
@@ -564,9 +528,9 @@ public class TaskController {
|
|
|
taskCommentMapper.insert(comment);
|
|
|
|
|
|
//需要重新计算项目进度
|
|
|
- if (needRecalculateProgress) {
|
|
|
- updateProjectProgress(task.getProjectId());
|
|
|
- }
|
|
|
+// if (needRecalculateProgress) {
|
|
|
+// updateProjectProgress(task.getProjectId());
|
|
|
+// }
|
|
|
if (msgRecepientList.size() > 0) {
|
|
|
//发消息通知执行人, 带项目id
|
|
|
msgRecepientList.forEach(msgRecepient->{
|
|
@@ -585,19 +549,6 @@ public class TaskController {
|
|
|
}
|
|
|
companyDingdingService.sendNewTaskMsg(dingding, recpUserList.stream().map(User::getDingdingUserid).collect(Collectors.joining(",")),
|
|
|
task.getName(), endStr);
|
|
|
- } else if (recpUserList.get(0).getCorpwxUserid() != null) {
|
|
|
- String corpUid = recpUserList.stream().map(User::getCorpwxUserid).distinct().collect(Collectors.joining("|"));
|
|
|
- JSONObject json = new JSONObject();
|
|
|
- JSONArray dataJson = new JSONArray();
|
|
|
- JSONObject jsonObj = new JSONObject();
|
|
|
- jsonObj.put("key", "任务内容");
|
|
|
- jsonObj.put("value", task.getName());
|
|
|
- dataJson.add(jsonObj);
|
|
|
- json.put("template_id", "tty9TkCAAAovv416zsWtn0e06CJ635HA");
|
|
|
- json.put("url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=task#wechat_redirect");
|
|
|
- json.put("content_item", dataJson);
|
|
|
- //todo:发送消息提醒任务
|
|
|
- wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo, corpUid, json);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -650,20 +601,20 @@ public class TaskController {
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
- private void updateProjectProgress(Integer projectId) {
|
|
|
- //只有里程碑才更新项目进度, 非已撤销状态的
|
|
|
- List<Task> all = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", projectId).ne("task_status", 2).eq("task_type",1),null,null);
|
|
|
- Project project = new Project();
|
|
|
- project.setId(projectId);
|
|
|
- if (all.size() > 0) {
|
|
|
- long running = all.stream().filter(a -> a.getTaskStatus() == 1).count();
|
|
|
- int progress = ((int) running) * 100 / all.size();
|
|
|
- project.setProgress(progress);
|
|
|
- } else {
|
|
|
- project.setProgress(0);
|
|
|
- }
|
|
|
- projectService.updateById(project);
|
|
|
- }
|
|
|
+// private void updateProjectProgress(Integer projectId) {
|
|
|
+// //只有里程碑才更新项目进度, 非已撤销状态的
|
|
|
+// List<Task> all = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", projectId).ne("task_status", 2).eq("task_type",1),null,null);
|
|
|
+// Project project = new Project();
|
|
|
+// project.setId(projectId);
|
|
|
+// if (all.size() > 0) {
|
|
|
+// long running = all.stream().filter(a -> a.getTaskStatus() == 1).count();
|
|
|
+// int progress = ((int) running) * 100 / all.size();
|
|
|
+// project.setProgress(progress);
|
|
|
+// } else {
|
|
|
+// project.setProgress(0);
|
|
|
+// }
|
|
|
+// projectService.updateById(project);
|
|
|
+// }
|
|
|
|
|
|
@RequestMapping("/finish")
|
|
|
public HttpRespMsg finish(Task task,String personLiableIds,String reason) {
|
|
@@ -790,10 +741,10 @@ public class TaskController {
|
|
|
}
|
|
|
|
|
|
//如果是里程碑,需要更新项目完成度
|
|
|
- if (curTask.getTaskType() == 1) {
|
|
|
- Integer projectId = curTask.getProjectId();
|
|
|
- updateProjectProgress(projectId);
|
|
|
- }
|
|
|
+// if (curTask.getTaskType() == 1) {
|
|
|
+// Integer projectId = curTask.getProjectId();
|
|
|
+// updateProjectProgress(projectId);
|
|
|
+// }
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
@@ -897,7 +848,6 @@ public class TaskController {
|
|
|
//已超期的任务,未完成的任务
|
|
|
queryWrapper.lt("end_date", LocalDate.now()).eq("task_status", 0);
|
|
|
}
|
|
|
- queryWrapper.eq("is_task_plan",0);
|
|
|
List<Task> list = taskService.simpleList(queryWrapper,start,size);
|
|
|
int total = taskMapper.selectCount(queryWrapper);
|
|
|
//没有权限只能看到自己创建的,负责的和待分配的任务
|
|
@@ -1028,7 +978,6 @@ public class TaskController {
|
|
|
String userId = request.getHeader("Token");
|
|
|
User user = userMapper.selectById(userId);
|
|
|
Task t = taskService.getById(id);
|
|
|
- List<SapProjectService> serviceList = sapProjectServiceService.list(new LambdaQueryWrapper<SapProjectService>().eq(SapProjectService::getCompanyId, user.getCompanyId()));
|
|
|
if (t == null) {
|
|
|
//msg.setError("该任务已不存在");
|
|
|
msg.setError(MessageUtils.message("Stages.noExist"));
|
|
@@ -1061,47 +1010,50 @@ public class TaskController {
|
|
|
userList = userMapper.selectList(new QueryWrapper<User>().select("id, name, phone, job_number, department_id, is_active").eq("company_id", user.getCompanyId()).eq("is_active", 1));
|
|
|
}
|
|
|
t.setUserList(userList);
|
|
|
- if (t.getTaskPlanType()==null||t.getTaskPlanType()!=3) {
|
|
|
- //查询项目负责人id以及所属任务分组负责人id
|
|
|
- Project project = projectService.getOne(new QueryWrapper<Project>().eq("id", t.getProjectId()));
|
|
|
- TaskGroup group = taskGroupService.getOne(new QueryWrapper<TaskGroup>().eq("id", t.getGroupId()));
|
|
|
- t.setProjectInchargerId(project.getInchargerId() == null ? "" : project.getInchargerId());
|
|
|
- t.setGroupInchargerId(group.getInchargerId() == null ? "" : group.getInchargerId());
|
|
|
- //判断当前用户是否有权限创建任务: 有权限的包括管理全部项目,项目创建人,项目PM, 分组负责人,分组参与人
|
|
|
- List<SysRichFunction> manageAllProjects = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "管理全部项目");
|
|
|
- boolean canAddTask = false;
|
|
|
- Integer companyId = user.getCompanyId();
|
|
|
- TaskAddCtrl taskAddCtrl = taskAddCtrlMapper.selectById(companyId);
|
|
|
- if (taskAddCtrl == null) {
|
|
|
- //没有的话,默认生成一个
|
|
|
- taskAddCtrl = new TaskAddCtrl();
|
|
|
- taskAddCtrl.setCompanyId(companyId);
|
|
|
- taskAddCtrl.setCtrlType(1);//0-普通项目参与人不可添加任务,1-项目参与人可添加,2-仅分组参与人可添加
|
|
|
- taskAddCtrlMapper.insert(taskAddCtrl);
|
|
|
- }
|
|
|
- if (manageAllProjects.size() > 0 || userId.equals(project.getCreatorId()) || userId.equals(project.getInchargerId())) {
|
|
|
- canAddTask = true;
|
|
|
+ String associateDegrees = "";
|
|
|
+ String names = "";
|
|
|
+ Project project = projectService.getById(t.getProjectId());
|
|
|
+ associateDegrees = project.getAssociateDegrees();
|
|
|
+ names = project.getAssociateDegreeNames();
|
|
|
+ List<HashMap> degreeList = new ArrayList<>();
|
|
|
+ if (!StringUtils.isEmpty(associateDegrees)) {
|
|
|
+ String[] idArray = associateDegrees.split("\\,");
|
|
|
+ String[] n = names.split("\\,");
|
|
|
+ for (int i=0;i<idArray.length; i++) {
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("id", Integer.parseInt(idArray[i]));
|
|
|
+ map.put("name", n[i]);
|
|
|
+ degreeList.add(map);
|
|
|
}
|
|
|
- if (!canAddTask) {
|
|
|
- //进一步判断是否是分组的负责人,参与人
|
|
|
- if (userId.equals(group.getInchargerId())) {
|
|
|
- canAddTask = true;
|
|
|
- }
|
|
|
- if (!canAddTask) {
|
|
|
- Integer ctrlType = taskAddCtrl.getCtrlType();
|
|
|
- if (ctrlType == 1) {
|
|
|
- canAddTask = true;
|
|
|
- } else if (ctrlType == 2) {
|
|
|
- //分组参与人可以创建任务
|
|
|
- int count = groupParticipatorMapper.selectCount(new QueryWrapper<GroupParticipator>().eq("user_id", userId).eq("group_id", group.getId()));
|
|
|
- if (count > 0) {
|
|
|
- canAddTask = true;
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ t.setDegreeList(degreeList);
|
|
|
+
|
|
|
+ //判断任务是否处于可编辑状态,以及当前人员是否有编辑权限
|
|
|
+ List<TaskType> taskTypeList = taskTypeService.list(new QueryWrapper<TaskType>().eq("company_id", user.getCompanyId()));
|
|
|
+ Optional<TaskType> taskType = taskTypeList.stream().filter(t1 -> t1.getId().equals(t.getTaskPlanType())).findFirst();
|
|
|
+ Boolean needAudit = taskType.get().getNeedAudit();
|
|
|
+ //判断是否是LA
|
|
|
+ boolean isLA = projectLeaderMapper.selectCount(new LambdaQueryWrapper<ProjectLeader>().eq(ProjectLeader::getProjectId, t.getProjectId()).eq(ProjectLeader::getLeaderId, userId)) > 0;
|
|
|
+ if (needAudit) {
|
|
|
+ //不同状态下对应不同的人员可以修改
|
|
|
+ if (isLA && (t.getTaskStatus() == STATUS_CANCEL || t.getTaskStatus() == STATUS_FIRST_REJECT || t.getTaskStatus() == STATUS_SECOND_REJECT)) {
|
|
|
+ t.setCanEditTask(true);
|
|
|
+ } else if (t.getTaskStatus() == STATUS_FIRST_CHECK && project.getInchargerId().equals(userId)) {
|
|
|
+ t.setCanEditTask(true);
|
|
|
+ } else if (t.getTaskStatus() == STATUS_SECOND_CHECK) {
|
|
|
+ //检查第二审核人
|
|
|
+ boolean isSecondAuditor = executorList.stream().anyMatch(e->e.getSecondAuditorId().equals(userId));
|
|
|
+ if (isSecondAuditor) {
|
|
|
+ t.setCanEditTask(true);
|
|
|
}
|
|
|
}
|
|
|
- t.setCanAddTask(canAddTask);
|
|
|
+ } else {
|
|
|
+ //无需审核,LA随时可以修改
|
|
|
+ if (isLA) {
|
|
|
+ t.setCanEditTask(true);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
msg.data = t;
|
|
|
return msg;
|
|
|
}
|
|
@@ -1180,23 +1132,23 @@ public class TaskController {
|
|
|
* 任务状态,0-进行中 1-已完成 2-已撤销 3-待第一审核人审核 4-待第二审核人审核 5-第一审核人驳回 6-第二审核人驳回
|
|
|
*/
|
|
|
//待第一审核人审核
|
|
|
- if (task.getTaskStatus()==3&&task.getIsTaskPlan()==1){
|
|
|
+ if (task.getTaskStatus()==3){
|
|
|
msg.setError("当前计划已处于一级审核状态,小组长不能删除");
|
|
|
return msg;
|
|
|
- }else if(task.getTaskStatus()==4&&task.getIsTaskPlan()==1){
|
|
|
+ }else if(task.getTaskStatus()==4){
|
|
|
msg.setError("当前计划已处于二级审核状态,小组长不能删除");
|
|
|
return msg;
|
|
|
- }else if(task.getTaskStatus()==0&&task.getIsTaskPlan()==0){
|
|
|
+ }else if(task.getTaskStatus()==0){
|
|
|
msg.setError("当前计划已审核通过,小组长不能删除");
|
|
|
return msg;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (project.getInchargerId()!=null&&project.getInchargerId().equals(user.getId())){
|
|
|
- if(task.getTaskStatus()==4&&task.getIsTaskPlan()==1){
|
|
|
+ if(task.getTaskStatus()==4){
|
|
|
msg.setError("当前计划已处于二级审核状态,项目经理不能删除");
|
|
|
return msg;
|
|
|
- }else if(task.getTaskStatus()==0&&task.getIsTaskPlan()==0){
|
|
|
+ }else if(task.getTaskStatus()==0){
|
|
|
msg.setError("当前计划已审核通过,项目经理不能删除");
|
|
|
return msg;
|
|
|
}
|
|
@@ -1204,7 +1156,7 @@ public class TaskController {
|
|
|
|
|
|
List<TaskExecutor> executorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().eq("task_id", id));
|
|
|
for (TaskExecutor executor : executorList) {
|
|
|
- if (task.getTaskStatus()==3&&task.getIsTaskPlan()==1 && user.getId().equals(executor.getSecondAuditorId())) {
|
|
|
+ if (task.getTaskStatus()==3 && user.getId().equals(executor.getSecondAuditorId())) {
|
|
|
msg.setError("当前计划已处于一级审核状态,区域经理不能删除");
|
|
|
return msg;
|
|
|
}
|
|
@@ -1237,9 +1189,9 @@ public class TaskController {
|
|
|
|
|
|
|
|
|
//删除里程碑,需要重新计算项目进度
|
|
|
- if (task.getTaskType() == 1) {
|
|
|
- updateProjectProgress(task.getProjectId());
|
|
|
- }
|
|
|
+// if (task.getTaskType() == 1) {
|
|
|
+// updateProjectProgress(task.getProjectId());
|
|
|
+// }
|
|
|
return new HttpRespMsg();
|
|
|
}
|
|
|
|
|
@@ -1505,19 +1457,32 @@ public class TaskController {
|
|
|
QueryWrapper<Task> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
//任务状态
|
|
|
- queryWrapper.eq("task_status", status).eq("task.company_id", companyId);
|
|
|
+ queryWrapper.eq("task.company_id", companyId);
|
|
|
+ if (viewId == 0 || viewId == 1 || viewId == 2) {
|
|
|
+ if (status == 1 || status == 0) {
|
|
|
+ queryWrapper.eq("task.task_status", status);
|
|
|
+ } else if (status == 2) {
|
|
|
+ //待审核,包括第一个和第二审核人待审核
|
|
|
+ queryWrapper.and(i -> i.eq("task.task_status", 3).or().eq("task.task_status", 4));
|
|
|
+ } else if (status == 3) {
|
|
|
+ //已驳回,包括第一个和第二审核人驳回,5,6
|
|
|
+ queryWrapper.and(i -> i.eq("task.task_status", 5).or().eq("task.task_status", 6));
|
|
|
+ } else if (status == 4) {
|
|
|
+ //撤回状态的
|
|
|
+ queryWrapper.eq("task.task_status", 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (viewId == 1) {
|
|
|
//我执行的任务
|
|
|
- queryWrapper.like("executor_id", userId);
|
|
|
+ queryWrapper.like("task.executor_id", userId);
|
|
|
} else if (viewId == 2) {
|
|
|
//我创建的任务
|
|
|
- queryWrapper.eq("creater_id", userId);
|
|
|
+ queryWrapper.eq("task.creater_id", userId);
|
|
|
} else if (viewId == 3) {
|
|
|
- //我审核的
|
|
|
-
|
|
|
+ //我审核的,忽略状态,只查询待审核的任务
|
|
|
}
|
|
|
if(type!=null){
|
|
|
- queryWrapper.eq("task_type",type);
|
|
|
+ queryWrapper.eq("task_plan_type",type);
|
|
|
}
|
|
|
if(dateType!=null){
|
|
|
switch (dateType){
|
|
@@ -1551,8 +1516,7 @@ public class TaskController {
|
|
|
if(pageIndex!=null&&pageSize!=null){
|
|
|
pageStart = (pageIndex - 1) * pageSize;
|
|
|
}
|
|
|
- //美莱德 任务计划状态是1
|
|
|
- queryWrapper.ne("is_task_plan",1);
|
|
|
+ List<TaskType> taskTypeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", companyId));
|
|
|
List<TaskWithAuditor> list;
|
|
|
if (viewId == 3) {
|
|
|
list = taskMapper.getMyAuditTaskList(queryWrapper,pageStart, pageSize,userId);
|
|
@@ -1572,8 +1536,9 @@ public class TaskController {
|
|
|
if (first.isPresent()) {
|
|
|
l.setProjectInchargerId(first.get().getInchargerId());
|
|
|
}
|
|
|
+ taskTypeList.stream().filter(t->t.getId().equals(l.getTaskPlanType())).findFirst().ifPresent(t->l.setTaskPlanTypeName(t.getName()));
|
|
|
});
|
|
|
- int total = taskMapper.selectCount(queryWrapper);
|
|
|
+ int total = viewId == 3?taskMapper.getMyAuditTaskCount(queryWrapper,userId):taskMapper.selectCount(queryWrapper);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("records", list);
|
|
|
map.put("total", total);
|
|
@@ -1581,6 +1546,21 @@ public class TaskController {
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取待审核的数量
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/getMyAuditCount")
|
|
|
+ public HttpRespMsg getMyAuditCount() {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ String userId = request.getHeader("Token");
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ Integer count = taskMapper.getMyAuditTaskCount(new QueryWrapper<Task>().eq("task.company_id", companyId), userId);
|
|
|
+ msg.data = count;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
private List<Integer> getBranchDepartment(Integer departmentId, List<Department> departmentList) {
|
|
|
List<Integer> list = new ArrayList<>();
|
|
|
list.add(departmentId);
|
|
@@ -1790,8 +1770,13 @@ public class TaskController {
|
|
|
//工作计划的通过或者驳回
|
|
|
//通过 type=true ,驳回 type=false
|
|
|
@RequestMapping("/taskPlanPassOrReject")
|
|
|
- public HttpRespMsg taskPlanPassOrReject(Integer taskId, boolean type){
|
|
|
- return taskService.taskPlanPassOrReject(taskId,type,request);
|
|
|
+ public HttpRespMsg taskPlanPassOrReject(Integer taskId, boolean type, String reason){
|
|
|
+ return taskService.taskPlanPassOrReject(taskId,type,reason,request);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/cancelByManager")
|
|
|
+ public HttpRespMsg cancelByManager(Integer id){
|
|
|
+ return taskService.cancelByManager(id,request);
|
|
|
}
|
|
|
|
|
|
|