|
@@ -1,12 +1,24 @@
|
|
|
package com.ruoyi.web.controller.rc;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
-import com.ruoyi.rc.domain.TMeeting;
|
|
|
+import com.ruoyi.rc.domain.*;
|
|
|
+import com.ruoyi.rc.service.ITProgressService;
|
|
|
+import com.ruoyi.rc.service.ITQuestionnaireService;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
+import org.activiti.engine.ProcessEngine;
|
|
|
+import org.activiti.engine.ProcessEngines;
|
|
|
+import org.activiti.engine.RuntimeService;
|
|
|
+import org.activiti.engine.TaskService;
|
|
|
+import org.activiti.engine.impl.identity.Authentication;
|
|
|
+import org.activiti.engine.runtime.ProcessInstance;
|
|
|
+import org.activiti.engine.task.Task;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -21,7 +33,6 @@ import com.ruoyi.common.annotation.Log;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
-import com.ruoyi.rc.domain.TOpenItem;
|
|
|
import com.ruoyi.rc.service.ITOpenItemService;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
@@ -42,6 +53,119 @@ public class TOpenItemController extends BaseController
|
|
|
@Autowired
|
|
|
private ISysDeptService deptService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RuntimeService runtimeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TaskService taskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITQuestionnaireService tQuestionnaireService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 流程处理
|
|
|
+ */
|
|
|
+ @PutMapping("/handle")
|
|
|
+ public AjaxResult handle(@RequestBody DevTask devTask) {
|
|
|
+ TOpenItem openItem = devTask.getOpenItem();
|
|
|
+ TQuestionnaire questionnaire = tQuestionnaireService.selectTQuestionnaireById(openItem.getQuestionnaireId());
|
|
|
+ String taskId = devTask.getTaskId();
|
|
|
+ String taskName = devTask.getTaskName();
|
|
|
+ String condition = devTask.getCondition();
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("condition", condition);
|
|
|
+ String comment = "";
|
|
|
+ if (taskName.equals("提交申请")) {
|
|
|
+ // 进度审批状态修改为2-待审核
|
|
|
+ openItem.setStatus("2");
|
|
|
+ comment = "重新提交";
|
|
|
+ } else if (taskName.equals("审核")) {
|
|
|
+ if ("1".equals(condition)) {
|
|
|
+ // 进度审批状态修改为4-已通过
|
|
|
+ openItem.setStatus("4");
|
|
|
+ comment = "通过";
|
|
|
+ } else {
|
|
|
+ // 进度审批状态修改为3-未通过
|
|
|
+ openItem.setStatus("3");
|
|
|
+ comment = "驳回";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 使用任务id,获取任务对象,获取流程实例id
|
|
|
+ Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
|
+ //利用任务对象,获取流程实例id
|
|
|
+ String processInstancesId = task.getProcessInstanceId();
|
|
|
+ ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
|
|
|
+ TaskService taskService = processEngine.getTaskService();
|
|
|
+ //认领任务
|
|
|
+ processEngine.getTaskService()
|
|
|
+ .claim(taskId, getUserId().toString());
|
|
|
+ taskService.addComment(taskId, processInstancesId, comment);
|
|
|
+ taskService.complete(taskId, param);
|
|
|
+// // 标记taskId、TaskName
|
|
|
+// List<Task> list = processEngine.getTaskService()//获取任务service
|
|
|
+// .createTaskQuery()//创建查询对象
|
|
|
+// .taskCandidateOrAssigned(questionnaire.getReviewer()+"").list();
|
|
|
+// for (Task t : list) {
|
|
|
+// if (openItem.getProcessId().equals(t.getProcessInstanceId())) {
|
|
|
+// openItem.setTaskId(t.getId());
|
|
|
+// openItem.setTaskName(t.getName());
|
|
|
+// }
|
|
|
+// }
|
|
|
+ // 更新数据
|
|
|
+ tOpenItemService.updateTOpenItem(openItem);
|
|
|
+ String year = questionnaire.getYear();
|
|
|
+ if (StringUtils.isNotEmpty(year) && !"".equals(year) && year.length() > 4) {
|
|
|
+ questionnaire.setYear(year.substring(0, year.indexOf("-")));
|
|
|
+ }
|
|
|
+ tQuestionnaireService.updateTQuestionnaire(questionnaire);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交申请
|
|
|
+ */
|
|
|
+ @PutMapping("/apply")
|
|
|
+ public AjaxResult apply(@RequestBody TOpenItem tOpenItem) {
|
|
|
+ // 当前登录用户id
|
|
|
+ String userId = getUserId().toString();
|
|
|
+
|
|
|
+ // 开始流程
|
|
|
+ Authentication.setAuthenticatedUserId(userId);
|
|
|
+ Map<String, Object> variables = new HashMap<>();
|
|
|
+ variables.put("personInCharge", tOpenItem.getPersonInCharge());
|
|
|
+ variables.put("reviewer", tOpenItem.getReviewer());
|
|
|
+ long businessKey = tOpenItem.getId();
|
|
|
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("openitemProcess", String.valueOf(businessKey), variables);
|
|
|
+
|
|
|
+ // 提交申请
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("condition", "1");
|
|
|
+ ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
|
|
|
+ TaskService taskService = processEngine.getTaskService();
|
|
|
+ List<Task> list = taskService.createTaskQuery().taskCandidateOrAssigned(userId).list();
|
|
|
+ String taskId = null;
|
|
|
+ String processInstanceId = null;
|
|
|
+ for (Task task : list) {
|
|
|
+ processInstanceId = task.getProcessInstanceId();
|
|
|
+ if (processInstanceId.equals(pi.getProcessInstanceId())) {
|
|
|
+ taskId = task.getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ processEngine.getTaskService().claim(taskId, getUserId().toString());
|
|
|
+ taskService.addComment(taskId, processInstanceId, "无");
|
|
|
+ taskService.complete(taskId, param);
|
|
|
+
|
|
|
+ tOpenItem.setProcessId(pi.getProcessInstanceId());
|
|
|
+ tOpenItem.setApNo(DateUtils.dateTimeNow() + userId);
|
|
|
+ // 进度审批状态修改为2-待审核
|
|
|
+ tOpenItem.setStatus("2");
|
|
|
+
|
|
|
+ tOpenItemService.updateTOpenItem(tOpenItem);
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询开项列表
|
|
|
*/
|
|
@@ -102,7 +226,9 @@ public class TOpenItemController extends BaseController
|
|
|
public AjaxResult add(@RequestBody TOpenItem tOpenItem)
|
|
|
{
|
|
|
tOpenItem.setDeptId(getLoginUser().getDeptId().toString());
|
|
|
- return toAjax(tOpenItemService.insertTOpenItem(tOpenItem));
|
|
|
+ int i = tOpenItemService.insertTOpenItem(tOpenItem);
|
|
|
+ this.apply(tOpenItem);
|
|
|
+ return toAjax(i);
|
|
|
}
|
|
|
|
|
|
/**
|