|
@@ -13,11 +13,18 @@ import com.jeeplus.modules.act.service.ActTaskService;
|
|
|
import com.jeeplus.modules.act.utils.ProcessDefCache;
|
|
|
import com.jeeplus.modules.sg.managementcenter.activiti.entity.Construction;
|
|
|
import com.jeeplus.modules.sg.managementcenter.activiti.service.ConstructionService;
|
|
|
+import com.jeeplus.modules.sg.managementcenter.activiti.utils.myActiviUtils;
|
|
|
+import com.jeeplus.modules.sg.managementcenter.project.entity.Project;
|
|
|
+import com.jeeplus.modules.sg.managementcenter.project.service.ProjectService;
|
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
import com.jeeplus.modules.test.activiti.entity.OALeave;
|
|
|
import com.jeeplus.modules.test.activiti.service.OALeaveService;
|
|
|
+import org.activiti.bpmn.model.BpmnModel;
|
|
|
+import org.activiti.bpmn.model.Process;
|
|
|
+import org.activiti.bpmn.model.UserTask;
|
|
|
import org.activiti.engine.*;
|
|
|
import org.activiti.engine.delegate.Expression;
|
|
|
+import org.activiti.engine.history.HistoricTaskInstance;
|
|
|
import org.activiti.engine.impl.RepositoryServiceImpl;
|
|
|
import org.activiti.engine.impl.TaskServiceImpl;
|
|
|
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
|
@@ -28,6 +35,7 @@ import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
|
|
import org.activiti.engine.impl.task.TaskDefinition;
|
|
|
import org.activiti.engine.repository.ProcessDefinition;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
@@ -39,6 +47,7 @@ import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* 施工交底Controller
|
|
|
+ *
|
|
|
* @author
|
|
|
* @version 2019-11-08
|
|
|
*/
|
|
@@ -47,136 +56,138 @@ import java.util.Set;
|
|
|
|
|
|
public class ConstructionController extends BaseController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private ConstructionService constructionService;
|
|
|
- @Autowired
|
|
|
- private ActProcessService actProcessService;
|
|
|
- @Autowired
|
|
|
- private ActTaskService actTaskService;
|
|
|
- @Autowired
|
|
|
- private RuntimeService runtimeService;
|
|
|
-
|
|
|
- @ModelAttribute
|
|
|
- public Construction get(@RequestParam(required=false) String id) {
|
|
|
- Construction entity = null;
|
|
|
- if (StringUtils.isNotBlank(id)){
|
|
|
- entity = constructionService.get(id);
|
|
|
- }
|
|
|
- if (entity == null){
|
|
|
- entity = new Construction();
|
|
|
- }
|
|
|
- return entity;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 查看,增加,编辑请假申请表单页面
|
|
|
- */
|
|
|
- @RequestMapping(value = "form/{mode}")
|
|
|
- public String form(@PathVariable String mode, Construction construction, Model model) {
|
|
|
- String proId = construction.getAct().getProcDefId();
|
|
|
- ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
|
|
|
- TaskService taskService = processEngine.getTaskService();
|
|
|
- //根据assignee(代理人)查询任务
|
|
|
- List<Task> tasks = taskService.createTaskQuery().processDefinitionId(proId).list();
|
|
|
- RepositoryService rs = processEngine.getRepositoryService();
|
|
|
-// List processDefinitions = rs.createProcessDefinitionQuery().list();
|
|
|
- String procDefId = construction.getAct().getProcDefId();
|
|
|
- ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)rs).getProcessDefinition(procDefId);
|
|
|
-// List<ActivityImpl> activitiList = def.getActivities(); //rs是指RepositoryService的实例
|
|
|
- int size = tasks.size();
|
|
|
- for (int i = 0; i < size; i++) {
|
|
|
- Task task = tasks.get(i);
|
|
|
- }
|
|
|
- //首次运行的时候这个没有输出,因为第一次运行的时候扫描act_ru_task的表里面是空的,但第一次运行完成之后里面会添加一条记录,之后每次运行里面都会添加一条记录
|
|
|
- for (Task task : tasks) {
|
|
|
- ActivityImpl activityImpl=def.findActivity(task.getTaskDefinitionKey());
|
|
|
- TaskDefinition taskDef = (TaskDefinition)activityImpl.getProperties().get("taskDefinition");
|
|
|
- Set<Expression> roleCodes = taskDef.getCandidateGroupIdExpressions();//候选组
|
|
|
- System.out.println("taskId:" + task.getId() +
|
|
|
- ",taskName:" + task.getName() +
|
|
|
- ",assignee:" + task.getAssignee() +
|
|
|
- ",createTime:" + task.getCreateTime() +
|
|
|
- ",getTaskLocalVariables:" + task.getProcessVariables()+
|
|
|
- ",roleCodes:"+roleCodes.toString());
|
|
|
- }
|
|
|
- model.addAttribute("construction", construction);
|
|
|
+ @Autowired
|
|
|
+ private ConstructionService constructionService;
|
|
|
+ @Autowired
|
|
|
+ private ActProcessService actProcessService;
|
|
|
+ @Autowired
|
|
|
+ private ActTaskService actTaskService;
|
|
|
+ @Autowired
|
|
|
+ private RuntimeService runtimeService;
|
|
|
+ @Autowired
|
|
|
+ private TaskService taskService;
|
|
|
+ @Autowired
|
|
|
+ private ProjectService projectService;
|
|
|
+
|
|
|
+ @ModelAttribute
|
|
|
+ public Construction get(@RequestParam(required = false) String id) {
|
|
|
+ Construction entity = null;
|
|
|
+ if (StringUtils.isNotBlank(id)) {
|
|
|
+ entity = constructionService.get(id);
|
|
|
+ }
|
|
|
+ if (entity == null) {
|
|
|
+ entity = new Construction();
|
|
|
+ }
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看,增加,编辑请假申请表单页面
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "form/{mode}")
|
|
|
+ public String form(@PathVariable String mode, Construction construction, Model model) {
|
|
|
+ String proId = construction.getAct().getProcDefId();
|
|
|
+ String pInId = construction.getProcInsId();
|
|
|
+ ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
|
|
|
+ RepositoryService rs = processEngine.getRepositoryService();
|
|
|
+ //根据流程定义号获取所有的定义流程
|
|
|
+
|
|
|
+
|
|
|
+ model.addAttribute("construction", construction);
|
|
|
// model.addAttribute("roleCodes");
|
|
|
- if("add".equals(mode) || "edit".equals(mode)){
|
|
|
- return "modules/sg/managementcenter/activiti/constructionForm";
|
|
|
- }else{//audit
|
|
|
- return "modules/sg/managementcenter/activiti/constructionAudit";
|
|
|
- }
|
|
|
-/* String procInstanceId = construction.getAct().getProcDefId();
|
|
|
- ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(procInstanceId);
|
|
|
- List<ActivityImpl> activitiList = def.getActivities();*/
|
|
|
-
|
|
|
-/* for(ActivityImpl act : activitiList) {
|
|
|
- System.out.println("当前任务:"+act.getProperty("name")); //输出某个节点的某种属性
|
|
|
- List<PvmTransition> outTransitions = act.getOutgoingTransitions();//获取从某个节点出来的所有线路
|
|
|
- for(PvmTransition tr:outTransitions){
|
|
|
- PvmActivity ac = tr.getDestination(); //获取线路的终点节点
|
|
|
- System.out.println("下一步任务任务:"+ac.getProperty("name"));
|
|
|
- }*/
|
|
|
-// System.out.println("活动节点:" + act.getProperty("name") + "," + act.getId()+act.getProperty(""));
|
|
|
- /* String excId = task.getExecutionId();
|
|
|
- ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(excId).singleResult();
|
|
|
- String activitiId = execution.getActivityId();*/
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存请假申请
|
|
|
- */
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping(value = "save")
|
|
|
- public AjaxJson save(Construction construction, Model model) throws Exception{
|
|
|
- AjaxJson j = new AjaxJson();
|
|
|
- /**
|
|
|
- * 后台hibernate-validation插件校验
|
|
|
- */
|
|
|
- String errMsg = beanValidator(construction);
|
|
|
- if (StringUtils.isNotBlank(errMsg)){
|
|
|
- j.setSuccess(false);
|
|
|
- j.setMsg(errMsg);
|
|
|
- return j;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 流程审批
|
|
|
- */
|
|
|
- if (StringUtils.isBlank(construction.getId())){
|
|
|
- //新增或编辑表单保存
|
|
|
- constructionService.save(construction);//保存
|
|
|
- String procDefKey = construction.getAct().getProcDefKey();
|
|
|
- // 启动流程
|
|
|
- ProcessDefinition p = actProcessService.getProcessDefinition(construction.getAct().getProcDefId());
|
|
|
- Map<String, Object> vars = Maps.newHashMap();
|
|
|
- vars.put("processer", UserUtils.get(construction.getTuser().getId()).getLoginName());
|
|
|
- String title = construction.getCurrentUser().getName()+"在"+ DateUtils.getDateTime()+"发起"+p.getName();
|
|
|
- actTaskService.startProcessNew(p.getKey(), "xm_construction_clarificaiton", construction.getId(), title,vars);
|
|
|
- j.setMsg("发起流程审批成功!");
|
|
|
- j.getBody().put("targetUrl", "/act/task/process/");
|
|
|
- }else{
|
|
|
- //新增或编辑表单保存
|
|
|
- constructionService.save(construction);//保存
|
|
|
- construction.getAct().setComment(("yes".equals(construction.getAct().getFlag())?"[重新申请] ":"[销毁申请] "));
|
|
|
- // 完成流程任务
|
|
|
- Map<String, Object> vars = Maps.newHashMap();
|
|
|
- vars.put("reapply", "yes".equals(construction.getAct().getFlag())? true : false);
|
|
|
- vars.put("processer", UserUtils.get(construction.getTuser().getId()).getLoginName());
|
|
|
- actTaskService.complete(construction.getAct().getTaskId(), construction.getAct().getProcInsId(), construction.getAct().getComment(), construction.getContent(), vars);
|
|
|
- j.setMsg("提交成功!");
|
|
|
- j.getBody().put("targetUrl", "/act/task/todo/");
|
|
|
- }
|
|
|
- return j;
|
|
|
- }
|
|
|
-
|
|
|
+ if ("add".equals(mode) || "edit".equals(mode)) {
|
|
|
+ return "modules/sg/managementcenter/activiti/constructionForm";
|
|
|
+ } else {//audit(施工单位,项目经理组织交底)
|
|
|
+ List<Task> tasks = taskService.createTaskQuery().processInstanceId(pInId).list();
|
|
|
+ //对流程循环
|
|
|
+ for (Task task : tasks) {
|
|
|
+ //根据流程的定义号获取信息
|
|
|
+ ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) rs).getDeployedProcessDefinition(task.getProcessDefinitionId());
|
|
|
+ //获取流程中所有的节点信息
|
|
|
+ List<ActivityImpl> activitiList = def.getActivities(); //rs是指RepositoryService的实例
|
|
|
+ String excId = task.getExecutionId();
|
|
|
+ ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(excId).singleResult();
|
|
|
+ //获取当前节点id
|
|
|
+ String activitiId = execution.getActivityId();
|
|
|
+ for (ActivityImpl activityImpl : activitiList) {
|
|
|
+ String id = activityImpl.getId();
|
|
|
+ if (activitiId.equals(id)) {
|
|
|
+ System.out.println("当前任务:" + activityImpl.getProperty("name")); //输出某个节点的某种属性
|
|
|
+ List<PvmTransition> outTransitions = activityImpl.getOutgoingTransitions();//获取从某个节点出来的所有线路
|
|
|
+ for (PvmTransition tr : outTransitions) {
|
|
|
+ PvmActivity ac = tr.getDestination();//获取线路的终点节点
|
|
|
+ List<PvmTransition> outgoingTransitions = ac.getOutgoingTransitions();
|
|
|
+ for (PvmTransition tr2 : outgoingTransitions) {
|
|
|
+ PvmActivity ac2 = tr2.getDestination();//获取线路的终点节点
|
|
|
+ ActivityImpl activityImpl2 = def.findActivity(ac2.getId());
|
|
|
+ TaskDefinition taskDef = (TaskDefinition) activityImpl2.getProperties().get("taskDefinition");
|
|
|
+ if (taskDef != null) {
|
|
|
+ Set<Expression> roleCodes = taskDef.getCandidateGroupIdExpressions();//候选组
|
|
|
+ System.out.println("候选组是" + roleCodes.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "modules/sg/managementcenter/activiti/constructionAudit";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存请假申请
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "save")
|
|
|
+ public AjaxJson save(Construction construction, Model model) throws Exception {
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
+ /**
|
|
|
+ * 后台hibernate-validation插件校验
|
|
|
+ */
|
|
|
+ String errMsg = beanValidator(construction);
|
|
|
+ if (StringUtils.isNotBlank(errMsg)) {
|
|
|
+ j.setSuccess(false);
|
|
|
+ j.setMsg(errMsg);
|
|
|
+ return j;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 流程审批
|
|
|
+ */
|
|
|
+ if (StringUtils.isBlank(construction.getId())) {
|
|
|
+ //新增或编辑表单保存
|
|
|
+ constructionService.save(construction);//保存
|
|
|
+ Project project = new Project();
|
|
|
+ project.setStatus("1");
|
|
|
+ project.setRequireName(construction.getProjectName());
|
|
|
+ projectService.updateStatus(project);
|
|
|
+ String procDefKey = construction.getAct().getProcDefKey();
|
|
|
+ // 启动流程
|
|
|
+ ProcessDefinition p = actProcessService.getProcessDefinition(construction.getAct().getProcDefId());
|
|
|
+ Map<String, Object> vars = Maps.newHashMap();
|
|
|
+ vars.put("processer", UserUtils.get(construction.getTuser().getId()).getLoginName());
|
|
|
+ String title = construction.getCurrentUser().getName() + "在" + DateUtils.getDateTime() + "发起" + p.getName();
|
|
|
+ actTaskService.startProcessNew(p.getKey(), "xm_construction_clarificaiton", construction.getId(), title, vars);
|
|
|
+ j.setMsg("发起流程审批成功!");
|
|
|
+ j.getBody().put("targetUrl", "/act/task/process/");
|
|
|
+ } else {
|
|
|
+ //新增或编辑表单保存
|
|
|
+ constructionService.save(construction);//保存
|
|
|
+ construction.getAct().setComment(("yes".equals(construction.getAct().getFlag()) ? "[重新申请] " : "[销毁申请] "));
|
|
|
+ // 完成流程任务
|
|
|
+ Map<String, Object> vars = Maps.newHashMap();
|
|
|
+ vars.put("reapply", "yes".equals(construction.getAct().getFlag()) ? true : false);
|
|
|
+ vars.put("processer", UserUtils.get(construction.getTuser().getId()).getLoginName());
|
|
|
+ actTaskService.complete(construction.getAct().getTaskId(), construction.getAct().getProcInsId(), construction.getAct().getComment(), construction.getContent(), vars);
|
|
|
+ j.setMsg("提交成功!");
|
|
|
+ j.getBody().put("targetUrl", "/act/task/todo/");
|
|
|
+ }
|
|
|
+ return j;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|