Commit 9cc0c1a6 authored by lisong's avatar lisong

任务表添加instanceId,roleIds字段

parent 15d89fed
......@@ -6,7 +6,8 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum CompanyExamineEnum {
企业审核("企业审核","未审核","已审核");
企业审核("企业审核","未审核","已审核"),
部门审核("部门审核","未审核","已审核");
String name;
String no;
......
......@@ -13,7 +13,9 @@ public enum TaskTypeEnum {
已办("true","已办"),
项目立项("project","项目立项"),
质量问题("problem","质量问题"),
项目结项("overProject","项目结项");
项目结项("overProject","项目结项"),
项目资料补充("projectResource","项目资料补充");
String key;
String name;
......
......@@ -62,6 +62,8 @@ public class Task extends BaseEntity {
@TableField(exist = false)
private String image;
private String roleIds;
private String instanceId;
......
......@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.ugp.api.entity.Task;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 监检任务表 Mapper 接口
......@@ -14,6 +17,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TaskMapper extends BaseMapper<Task> {
IPage getTask(IPage page,Integer type,Long unitId);
IPage getTask(IPage page, Integer type, Long unitId, @Param("list")List<String> roleIds);
}
......@@ -24,6 +24,12 @@
<if test="type != null ">
and tk.status =#{type}
</if>
<if test="list != null">
AND
<foreach collection ='list' item='role' index='index' open="(" close= ")" separator="or">
tk.role_ids like concat ('%', #{role} ,'%')
</foreach>
</if>
ORDER BY tk.rec_date DESC
</select>
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.module.ugp.api.Enum.ProjectInitiationEnum;
......@@ -16,6 +17,8 @@ import com.yeejoin.amos.boot.module.ugp.biz.framework.BusinessIdentify;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.OrgServiceImpl;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.TaskServiceImpl;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.runtime.regexp.joni.EncodingHelper;
......@@ -164,7 +167,14 @@ public class TaskController {
@ApiOperation(httpMethod = "GET", value = "获取当前登录人的所有任务列表", notes = "获取当前登录人的所有任务列表")
@BusinessIdentify
public ResponseModel<IPage<Task>> getTaskList(@RequestParam(value = "status",required = false) String type,Long current,Long size){
Long unitId = orgService.getReginParams().getBusinessInfo().getCompanySequenceNbr();
ReginParams reginParams = orgService.getReginParams();
Long unitId = reginParams.getBusinessInfo().getCompanySequenceNbr();
Long amosBizCode = reginParams.getBusinessInfo().getAmosBizCode();
List<RoleModel> roleModels = reginParams.getUserModel().getOrgRoles().get(amosBizCode);
ArrayList<String> roleIds = new ArrayList<>();
roleModels.forEach(item ->{
roleIds.add(String.valueOf(item.getSequenceNbr()));
});
IPage<Task> page = new Page(current,size);
// LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(Task::getUnitId,unitId);
......@@ -181,7 +191,7 @@ public class TaskController {
}
}
page = taskMapper.getTask(page, status, unitId);
page = taskMapper.getTask(page, status, unitId, roleIds);
List<Task> list = page.getRecords();
for(Task task : list){
if(task.getStatus() == 1){
......
......@@ -161,7 +161,7 @@ public class ProblemInitiationServiceImpl {
//更新任务表的状态 已办
taskType = getUnitId(unitIds, objectd);
taskService.saveOrUpdateTask(objectd.getStatus(), true, taskType, new Date(), object.getLong("sequenceNbr"), TaskTypeEnum.质量问题.getKey(), unitIds,null);
taskService.saveOrUpdateTask(objectd.getStatus(), true, taskType, new Date(), object.getLong("sequenceNbr"), TaskTypeEnum.质量问题.getKey(), unitIds,null, instanceId);
//更新problem中的status字段,表示当前流程下一个执行的任务
qualityProblemService.updateById(objectd);
......@@ -171,7 +171,7 @@ public class ProblemInitiationServiceImpl {
unitIds = new ArrayList<>();
taskType = getUnitId(unitIds, objectd);
taskService.saveOrUpdateTask(objectd.getStatus(), false, taskType, new Date(), object.getLong("sequenceNbr"), TaskTypeEnum.质量问题.getKey(), unitIds,null);
taskService.saveOrUpdateTask(objectd.getStatus(), false, taskType, new Date(), object.getLong("sequenceNbr"), TaskTypeEnum.质量问题.getKey(), unitIds,null, instanceId);
} catch (Exception e) {
e.printStackTrace();
System.out.println("任务完成失败:"+e.getMessage());
......
......@@ -302,7 +302,7 @@ public class ProjectInitiationServiceImpl extends BaseService<ProjectInitiationD
if(ProjectInitiationEnum.设计开工资料提交.getName().equals(project.getStatus()) || ProjectInitiationEnum.安装开工资料提交.getName().equals(project.getStatus())){
project.setStatus(ProjectInitiationEnum.提交资料.getName());
}
taskService.saveOrUpdateTask(project.getStatus(), true, taskType, new Date(), project.getSequenceNbr(), TaskTypeEnum.项目立项.getKey(), unitIds,extendId);
taskService.saveOrUpdateTask(project.getStatus(), true, taskType, new Date(), project.getSequenceNbr(), TaskTypeEnum.项目立项.getKey(), unitIds,extendId, instanceId);
//更新project种的status字段,更新关系表中的state字段,表示当前流程下一个执行的任务
boolean bool = updateFlowStatus(instanceId);
......@@ -315,7 +315,7 @@ public class ProjectInitiationServiceImpl extends BaseService<ProjectInitiationD
}
unitIds = new ArrayList<>();
taskType = getUnitId(unitIds, project, superviseRule);
taskService.saveOrUpdateTask(project.getStatus(), false, taskType, new Date(), project.getSequenceNbr(), TaskTypeEnum.项目立项.getKey(), unitIds, extendId);
taskService.saveOrUpdateTask(project.getStatus(), false, taskType, new Date(), project.getSequenceNbr(), TaskTypeEnum.项目立项.getKey(), unitIds, extendId, instanceId);
}
} catch (Exception e) {
e.printStackTrace();
......@@ -377,6 +377,17 @@ public class ProjectInitiationServiceImpl extends BaseService<ProjectInitiationD
unitIds.add(project.getTestingUnitId());
taskType = TaskTypeEnum.流程.getKey();
}
if (project.getStatus().contains(ProjectInitiationEnum.设计资料审核.getName()) || project.getStatus().contains(ProjectInitiationEnum.设计资料审批.getName())){
unitIds.add(project.getDesignUnitId());
taskType = TaskTypeEnum.流程.getKey();
}
if (project.getStatus().contains(ProjectInitiationEnum.安装资料审核.getName()) || project.getStatus().contains(ProjectInitiationEnum.安装资料审批.getName())){
unitIds.add(project.getInstallationUnitId());
taskType = TaskTypeEnum.流程.getKey();
}
return taskType;
}
......@@ -673,7 +684,7 @@ public class ProjectInitiationServiceImpl extends BaseService<ProjectInitiationD
SuperviseRule superviseRule = superviseRuleService.getOne(wrapperSR);
//更新任务表的状态 已办
taskType = getUnitId(unitIds, project, superviseRule);
taskService.saveOrUpdateTask(project.getStatus(), true, taskType, new Date(), project.getSequenceNbr(), TaskTypeEnum.项目结项.getKey(), unitIds,null);
taskService.saveOrUpdateTask(project.getStatus(), true, taskType, new Date(), project.getSequenceNbr(), TaskTypeEnum.项目结项.getKey(), unitIds,null, overProjectDto.getInstanceId());
//更新project种的status字段,表示当前流程下一个执行的任务
Project projectNext = updateProjectFlowStatusReturnObject(overProjectDto.getInstanceId());
......@@ -681,7 +692,7 @@ public class ProjectInitiationServiceImpl extends BaseService<ProjectInitiationD
//新增任务表的状态 待办
unitIds = new ArrayList<>();
taskType = getUnitId(unitIds, projectNext, superviseRule);
taskService.saveOrUpdateTask(projectNext.getStatus(), false, taskType, new Date(), projectNext.getSequenceNbr(), TaskTypeEnum.项目结项.getKey(), unitIds,extendId);
taskService.saveOrUpdateTask(projectNext.getStatus(), false, taskType, new Date(), projectNext.getSequenceNbr(), TaskTypeEnum.项目结项.getKey(), unitIds,extendId, overProjectDto.getInstanceId());
}
} catch (Exception e) {
e.printStackTrace();
......@@ -822,6 +833,12 @@ public class ProjectInitiationServiceImpl extends BaseService<ProjectInitiationD
});
projectResourceService.saveOrUpdateBatch(projectResources);
Project project = projectService.getBaseMapper().selectById(projectResources.get(0).getProjectId());
if ("资源确认".equals(auditStatusName)){
taskService.saveTaskMessage(project.getSequenceNbr(), project.getTestingUnitId(), instanceId, auditStatusName);
}else {
taskService.saveTaskMessage(project.getSequenceNbr(), project.getInstallationUnitId(), instanceId, auditStatusName);
}
}
......
package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.ugp.api.Enum.*;
import com.yeejoin.amos.boot.module.ugp.api.dto.TaskDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.*;
import com.yeejoin.amos.boot.module.ugp.api.mapper.TaskMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.TzUgpPathMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.TaskService;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -52,7 +60,7 @@ public class TaskServiceImpl extends BaseService<TaskDto, Task, TaskMapper> impl
* @Param sequenceNbr 项目/问题处置的sequenceNbr
* @return
*/
public void saveOrUpdateTask(String InitiationStatus, boolean status, String taskType, Date sendTime, Long sourceId, String type, List<Long> unitIds,Long extendId) {
public void saveOrUpdateTask(String InitiationStatus, boolean status, String taskType, Date sendTime, Long sourceId, String type, List<Long> unitIds,Long extendId, String instanceId) {
if (!ValidationUtil.isEmpty(unitIds)) {
for (Long unitId : unitIds) {
Task task = new Task();
......@@ -77,6 +85,24 @@ public class TaskServiceImpl extends BaseService<TaskDto, Task, TaskMapper> impl
}
}
if (InitiationStatus.contains(ProjectInitiationEnum.设计资料审核.getName()) || InitiationStatus.contains(ProjectInitiationEnum.设计资料审批.getName())){
// 部门内资料审核
if (status){
taskStatus = CompanyExamineEnum.部门审核.getYes();
}else {
taskStatus = CompanyExamineEnum.部门审核.getNo();
}
}
if (InitiationStatus.contains(ProjectInitiationEnum.安装资料审核.getName()) || InitiationStatus.contains(ProjectInitiationEnum.安装资料审批.getName())){
// 部门内资料审核
if (status){
taskStatus = CompanyExamineEnum.部门审核.getYes();
}else {
taskStatus = CompanyExamineEnum.部门审核.getNo();
}
}
if (ValidationUtil.isEmpty(title)) {
//不是问题处置流程,企业注册任务
title = CompanyExamineEnum.企业审核.getName();
......@@ -132,9 +158,80 @@ public class TaskServiceImpl extends BaseService<TaskDto, Task, TaskMapper> impl
task.setStatusLabel(TaskTypeEnum.待办.getName());
}
task.setContent(title + ", " + taskStatus);
task.setInstanceId(instanceId);
List<String> roleList = getRoleList(instanceId);
if (!ObjectUtils.isEmpty(roleList)) {
String join = String.join(",", roleList);
task.setRoleIds(join);
}
this.saveOrUpdate(task);
}
}
}
public void saveTaskMessage(Long sourceId, Long unitId, String instanceId, String title) {
updateStatusTask(instanceId);
if (!"流程结束!".equals(title)) {
Task task = new Task();
task.setSourceId(sourceId);
task.setUnitId(unitId);
task.setContent("");
task.setStatus(0);
task.setStatusLabel(TaskTypeEnum.待办.getName());
task.setTaskType(TaskTypeEnum.流程.getKey());
task.setTaskTypeLabel(TaskTypeEnum.流程.getName());
task.setInstanceId(instanceId);
task.setSendTime(DateUtils.getDateNow());
task.setType(TaskTypeEnum.项目资料补充.getKey());
task.setTitle(title);
task.setContent(title + ", 待审批");
List<String> roleList = getRoleList(instanceId);
if (!ObjectUtils.isEmpty(roleList)) {
String join = String.join(",", roleList);
task.setRoleIds(join);
}
this.save(task);
}
}
public List<String> getRoleList(String instanceId) {
ArrayList<String> roleIds = new ArrayList<>();
try {
AjaxResult ajaxResult = Workflow.taskClient.getTask(instanceId);
JSONObject data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
if (!ObjectUtils.isEmpty(data)) {
AjaxResult taskGroupName = Workflow.taskClient.getTaskGroupName(String.valueOf(data.get("id")));
if (!ObjectUtils.isEmpty(taskGroupName)) {
JSONArray data2 = JSON.parseArray(JSON.toJSONString(taskGroupName.get("data")));
if (!ObjectUtils.isEmpty(data2)) {
data2.forEach(item -> {
Map item1 = (Map) item;
roleIds.add(String.valueOf(item1.get("groupId")));
});
}
}
}
} catch (Exception e) {
log.error("当前流程下一节点为空");
}
return roleIds;
}
private void updateStatusTask(String instanceId) {
LambdaQueryWrapper<Task> lambda = new QueryWrapper<Task>().lambda();
lambda.eq(Task::getInstanceId, instanceId);
lambda.eq(Task::getStatus, 0);
List<Task> tasks = this.getBaseMapper().selectList(lambda);
if (!ObjectUtils.isEmpty(tasks)) {
tasks.forEach(item -> {
item.setStatus(1);
item.setStatusLabel(TaskTypeEnum.已办.getName());
item.setContent(item.getTitle() + ", 已完成");
});
this.saveOrUpdateBatch(tasks);
}
}
}
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