|
@@ -0,0 +1,349 @@
|
|
|
+package cn.iocoder.yudao.module.as.controller.admin.task;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentspersonmanage.vo.AidingStudentsPersonManageClassPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentspersonmanage.vo.AidingStudentsPersonManageUploadRespVO;
|
|
|
+import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentspersonmanage.AidingStudentsPersonManageDO;
|
|
|
+import cn.iocoder.yudao.module.as.service.aidingstudentspersonmanage.AidingStudentsPersonManageService;
|
|
|
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO;
|
|
|
+import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert;
|
|
|
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
|
|
|
+import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService;
|
|
|
+import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
|
|
+import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
|
|
+import cn.iocoder.yudao.module.as.convert.task.asTaskConvert;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.flowable.engine.history.HistoricProcessInstance;
|
|
|
+import org.flowable.task.api.Task;
|
|
|
+import org.flowable.task.api.history.HistoricTaskInstance;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
|
|
+import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 流程任务实例")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/as/task")
|
|
|
+@Validated
|
|
|
+public class asTaskController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BpmTaskService taskService;
|
|
|
+ @Resource
|
|
|
+ private BpmProcessInstanceService processInstanceService;
|
|
|
+ @Resource
|
|
|
+ private BpmFormService formService;
|
|
|
+ @Resource
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+ @Resource
|
|
|
+ private AidingStudentsPersonManageService aidingStudentsPersonManageService;
|
|
|
+ @GetMapping("/todo-page-aiding")
|
|
|
+ @Operation(summary = "获取 Todo 综测审批待办任务分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:query')")
|
|
|
+ public CommonResult<List<AidingStudentsPersonManageUploadRespVO>> getTaskTodoPageAiding(@Valid BpmTaskPageReqVO pageVO) {
|
|
|
+ //获取班级id
|
|
|
+ Long deptId = adminUserApi.getUser(getLoginUserId()).getDeptId();
|
|
|
+ //获取所属学院id
|
|
|
+ Long collegeId = deptApi.getCollegeId(deptId);
|
|
|
+
|
|
|
+ //获取我的任务中家困任务的列表
|
|
|
+ List<Task> pageResult = taskService.getTaskTodoPageAidingList(getLoginUserId(), pageVO);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(pageResult)) {
|
|
|
+ return success(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据当前任务的idList获取 ,返回关于项目与班级分组的学生材料
|
|
|
+ List<AidingStudentsPersonManageDO> aidingStudentsPersonList =
|
|
|
+ aidingStudentsPersonManageService.getAidingStudentsPersonManageClassPage(
|
|
|
+ convertList(pageResult,Task::getProcessInstanceId),pageVO
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+// //获取任务列表中的家庭经济认定实例,aidingStudentsPersonList
|
|
|
+// List<AidingStudentsPersonManageUploadRespVO> aidingStudentsPersonList =
|
|
|
+// aidingStudentsPersonManageService.getAidingStudentsPersonManageClassPage();
|
|
|
+
|
|
|
+
|
|
|
+ Map<Long, ComprehensiveManageDO> comprehensiveManage =
|
|
|
+ comprehensiveManageService.getManagetMap(convertSet(achievementList, AchievementDO::getManageId));
|
|
|
+
|
|
|
+ Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
|
|
+ convertSet(achievementList, AchievementDO::getUserId));
|
|
|
+ Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
|
|
|
+ convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
|
|
+
|
|
|
+ return success(eveTaskConvert.INSTANCE.buildTodoTaskPageComprehensive(
|
|
|
+ userMap,deptMap,comprehensiveManage,achievementList,deptId));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/list-by-process-instance-id")
|
|
|
+ @Operation(summary = "获得指定流程实例的任务列表", description = "包括完成的、未完成的")
|
|
|
+ @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasAnyPermissions('eve:task:query','eve:achievement:query') || @ss.hasAnyRoles('xgcxueshengguanli')" )
|
|
|
+ public CommonResult<List<BpmTaskRespVO>> getTaskListByProcessInstanceId(
|
|
|
+ @RequestParam("processInstanceId") String processInstanceId) {
|
|
|
+ List<HistoricTaskInstance> taskList = taskService.getTaskListByProcessInstanceId(processInstanceId);
|
|
|
+ if (CollUtil.isEmpty(taskList)) {
|
|
|
+ return success(Collections.emptyList());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 拼接数据
|
|
|
+ HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId);
|
|
|
+ // 获得 User 和 Dept Map
|
|
|
+ Set<Long> userIds = convertSetByFlatMap(taskList, task ->
|
|
|
+ Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner())));
|
|
|
+ userIds.add(NumberUtils.parseLong(processInstance.getStartUserId()));
|
|
|
+ Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
|
|
|
+ Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
|
|
|
+ convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
|
|
+ // 获得 Form Map
|
|
|
+ Map<Long, BpmFormDO> formMap = formService.getFormMap(
|
|
|
+ convertSet(taskList, task -> NumberUtils.parseLong(task.getFormKey())));
|
|
|
+ return success(BpmTaskConvert.INSTANCE.buildTaskListByProcessInstanceId(taskList, processInstance,
|
|
|
+ formMap, userMap, deptMap));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/done-page-comprehensive")
|
|
|
+ @Operation(summary = "获取 Done 综测审批已办任务分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:query')")
|
|
|
+ public CommonResult<List<AchievementRespVO>> getTaskDonePageComprehensive(@Valid BpmTaskPageReqVO pageVO) {
|
|
|
+ List<HistoricTaskInstance> pageResult = taskService.getTaskDonePageComprehensive(getLoginUserId(), pageVO);
|
|
|
+ if (CollUtil.isEmpty(pageResult)) {
|
|
|
+ return success(null);
|
|
|
+ }
|
|
|
+ List<AchievementDO> achievementList = achievementService.selectByProcessInstanceIdsGroupByUser(
|
|
|
+ convertList(pageResult,HistoricTaskInstance::getProcessInstanceId),pageVO);
|
|
|
+
|
|
|
+ // 移除当前元素
|
|
|
+ achievementList.removeIf(achievementDO -> achievementDO.getUserId().equals(getLoginUserId()));
|
|
|
+
|
|
|
+ Map<Long, ComprehensiveManageDO> comprehensiveManage =
|
|
|
+ comprehensiveManageService.getManagetMap(convertSet(achievementList, AchievementDO::getManageId));
|
|
|
+
|
|
|
+
|
|
|
+ Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
|
|
+ convertSet(achievementList, AchievementDO::getUserId));
|
|
|
+ Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
|
|
|
+ convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
|
|
+ return success(asTaskConvert.INSTANCE.buildTaskComprehensive(achievementList, userMap, deptMap,comprehensiveManage));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("done-user-list")
|
|
|
+ @Operation(summary = "获取 Done 综测审批已办任务个人")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:query')")
|
|
|
+ public CommonResult<List<eveTaskRespVO>> getTaskDoneByPeople(@Valid BpmTaskPageReqVO pageVO) {
|
|
|
+
|
|
|
+ Long startUserId = pageVO.getUserId();
|
|
|
+ List<AchievementDO> achievementList
|
|
|
+ = achievementService.getAchievementByPeopleAndManageId(startUserId,pageVO.getManageId());
|
|
|
+
|
|
|
+ Map<String, AchievementDO> achievementDOMap = convertMap(achievementList,AchievementDO::getProcessInstanceId);
|
|
|
+ Collection<String> processInstanceIds = convertSet(achievementList,AchievementDO::getProcessInstanceId);
|
|
|
+
|
|
|
+ List<HistoricTaskInstance> pageResult
|
|
|
+ = taskService.getTaskDoneByPeopleAndProcessInstanceIds(getLoginUserId(), pageVO , processInstanceIds);
|
|
|
+
|
|
|
+ // 使用 Stream API 来处理
|
|
|
+ Map<String, HistoricTaskInstance> latestTasks = pageResult.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ HistoricTaskInstance::getProcessInstanceId,
|
|
|
+ task -> task,
|
|
|
+ (existingTask, newTask) -> newTask.getEndTime().after(existingTask.getEndTime()) ? newTask : existingTask
|
|
|
+ ));
|
|
|
+
|
|
|
+ pageResult.removeIf(task -> !latestTasks.get(task.getProcessInstanceId()).equals(task));
|
|
|
+
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(pageResult)) {
|
|
|
+ return success(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, HistoricProcessInstance> processInstanceMap = processInstanceService.getHistoricProcessInstanceMap(
|
|
|
+ convertSet(pageResult, HistoricTaskInstance::getProcessInstanceId));
|
|
|
+ Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
|
|
+ convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
|
|
|
+
|
|
|
+ return success(eveTaskConvert.INSTANCE.buildTaskDoneByPeople(pageResult, processInstanceMap, userMap,achievementDOMap));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/approve")
|
|
|
+ @Operation(summary = "通过单项综测审批")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:update')")
|
|
|
+ public CommonResult<Boolean> approveTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) {
|
|
|
+ taskService.approveTaskAchievement(getLoginUserId(), reqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/approve-edit")
|
|
|
+ @Operation(summary = "单项审批修改")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:achievement:update')")
|
|
|
+ public CommonResult<Boolean> approveTaskEdit(@Valid @RequestBody BpmTaskApproveReqVO reqVO) {
|
|
|
+ taskService.approveTaskAchievement(getLoginUserId(), reqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/approve-people")
|
|
|
+ @Operation(summary = "整体通过综测审批")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:update')")
|
|
|
+ public CommonResult<Boolean> approveTaskByPeople(@Valid @RequestBody List<BpmTaskApproveReqVO> reqVOList) {
|
|
|
+ taskService.approveTaskAchievementByPeople(getLoginUserId(), reqVOList);
|
|
|
+
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/approve-college-rank")
|
|
|
+ @Operation(summary = "学院针对当前完成互评状态的条目进行审核并发起公示和排名")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:comprehensive-college-manage:update')")
|
|
|
+ @Transactional
|
|
|
+ public CommonResult<Boolean> approveTaskAndRankByCollege(@Valid @RequestBody BpmTaskPageReqVO pageVO) {
|
|
|
+ Long deptId = adminUserApi.getUser(getLoginUserId()).getDeptId();
|
|
|
+ Long collegeId = deptApi.getCollegeId(deptId);
|
|
|
+ DeptRespDTO dept = deptApi.getDept(collegeId);
|
|
|
+ ComprehensiveCollegeManageDO comprehensiveCollegeManage
|
|
|
+ = comprehensiveCollegeManageService.getComprehensiveCollegeManage(pageVO.getManageId(), collegeId);
|
|
|
+
|
|
|
+ if(comprehensiveCollegeManage.getComStatus() != 1){
|
|
|
+ throw exception(ALREADY_PUBLICIZED);
|
|
|
+ }
|
|
|
+ comprehensiveCollegeManage.setComStatus(2);
|
|
|
+ comprehensiveCollegeManageService.updateComprehensiveCollegeManage(
|
|
|
+ BeanUtils.toBean(comprehensiveCollegeManage, ComprehensiveCollegeManageSaveReqVO.class)
|
|
|
+ );
|
|
|
+ List<Task> pageResult = taskService.getTaskTodoPageComprehensive(getLoginUserId(), pageVO);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(pageResult)) {
|
|
|
+ return success(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<AchievementDO> achievementList = achievementService.getAchievementByProcessInstanceIds(
|
|
|
+ convertList(pageResult,Task::getProcessInstanceId),pageVO.getManageId());
|
|
|
+
|
|
|
+ List<BpmTaskApproveReqVO> vpPageResult = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Task respVO : pageResult) {
|
|
|
+ for(AchievementDO achievement : achievementList){
|
|
|
+ if(achievement.getProcessInstanceId().equals(respVO.getProcessInstanceId())){
|
|
|
+ BpmTaskApproveReqVO eveRespVO = BeanUtils.toBean(respVO, BpmTaskApproveReqVO.class);
|
|
|
+ vpPageResult.add(eveRespVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ taskService.approveTaskAchievementByPeople(getLoginUserId(), vpPageResult);
|
|
|
+
|
|
|
+ comprehensiveService.comprehensiveCalculateByCollegeID(
|
|
|
+ collegeId,pageVO.getManageId(),1 , "学院公示"
|
|
|
+ );
|
|
|
+
|
|
|
+ comprehensiveService.comprehensiveRanking(collegeId,dept.getBs(),pageVO.getManageId());
|
|
|
+
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/approve-college")
|
|
|
+ @Operation(summary = "学院确认(即批量通过当前状态为学院公示的审批)")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:comprehensive-college-manage:update')")
|
|
|
+ @Transactional
|
|
|
+ public CommonResult<Boolean> approveTaskByCollege(@Valid BpmTaskPageReqVO pageVO) {
|
|
|
+ List<Task> pageResult = taskService.getTaskTodoPageComprehensive(getLoginUserId(), pageVO);
|
|
|
+ if (CollUtil.isEmpty(pageResult)) {
|
|
|
+ return success(null);
|
|
|
+ }
|
|
|
+ Long deptId = adminUserApi.getUser(SecurityFrameworkUtils.getLoginUserId()).getDeptId();
|
|
|
+ Long collegeId = deptApi.getCollegeId(deptId);
|
|
|
+ ComprehensiveCollegeManageDO comprehensiveCollegeManage
|
|
|
+ = comprehensiveCollegeManageService.getComprehensiveCollegeManage(pageVO.getManageId(), collegeId);
|
|
|
+ if(comprehensiveCollegeManage.getComStatus() != 2){
|
|
|
+ throw exception(PLEASE_START_PUBLICIZED);
|
|
|
+ }
|
|
|
+ comprehensiveCollegeManageService.updateComprehensiveCollegeManage(
|
|
|
+ BeanUtils.toBean(comprehensiveCollegeManage.setComStatus(3), ComprehensiveCollegeManageSaveReqVO.class)
|
|
|
+ );
|
|
|
+ List<AchievementDO> achievementList = achievementService.getAchievementByProcessInstanceIds(
|
|
|
+ convertList(pageResult,Task::getProcessInstanceId),pageVO.getManageId());
|
|
|
+
|
|
|
+ List<BpmTaskApproveReqVO> vpPageResult = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Task respVO : pageResult) {
|
|
|
+ for(AchievementDO achievement : achievementList){
|
|
|
+ if(achievement.getProcessInstanceId().equals(respVO.getProcessInstanceId())){
|
|
|
+ BpmTaskApproveReqVO eveRespVO = BeanUtils.toBean(respVO, BpmTaskApproveReqVO.class);
|
|
|
+ vpPageResult.add(eveRespVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taskService.approveTaskAchievementByPeople(getLoginUserId(), vpPageResult);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/reject-update")
|
|
|
+ @Operation(summary = "不通过任务:驳回到审批人处")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:update')")
|
|
|
+ public CommonResult<Boolean> rejectAchievementTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) {
|
|
|
+ taskService.rejectAchievementTask(getLoginUserId(), reqVO);
|
|
|
+
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/reject-people-update")
|
|
|
+ @Operation(summary = "整体不通过任务:驳回到审批人处")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:update')")
|
|
|
+ public CommonResult<Boolean> rejectAchievementTaskByPeople(@Valid @RequestBody List<BpmTaskApproveReqVO> reqVOList) {
|
|
|
+ taskService.rejectAchievementTaskByPeople(getLoginUserId(), reqVOList);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/reject")
|
|
|
+ @Operation(summary = "不通过任务:直接结束流程")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:update')")
|
|
|
+ public CommonResult<Boolean> rejectTask(@Valid @RequestBody BpmTaskRejectReqVO reqVO) {
|
|
|
+ taskService.rejectTask(getLoginUserId(), reqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/reject-people")
|
|
|
+ @Operation(summary = "整体不通过综测审批:直接结束流程")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:update')")
|
|
|
+ public CommonResult<Boolean> rejectTaskByPeople(@Valid @RequestBody List<BpmTaskRejectReqVO> reqVOList) {
|
|
|
+ taskService.rejectTaskByPeople(getLoginUserId(), reqVOList);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/reject-undo")
|
|
|
+ @Operation(summary = "在下一个人审批前退回审批")
|
|
|
+ @PreAuthorize("@ss.hasPermission('eve:task:update')")
|
|
|
+ public CommonResult<Boolean> rejectUndoTask(@Valid @RequestBody BpmTaskUndoReqVO reqVO) {
|
|
|
+ taskService.UndoTask(getLoginUserId(), reqVO);
|
|
|
+// taskService.rejectTaskByPeople(getLoginUserId(), reqVOList);
|
|
|
+
|
|
|
+// return error(400,"改流程不能修改!");
|
|
|
+
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|