Search in sources :

Example 6 with ActFormTpl

use of com.github.qinyou.process.model.ActFormTpl in project my_curd by qinyou.

the class MyTaskController method goCompleteForm.

/**
 * 跳转到任务办理界面
 */
public void goCompleteForm() {
    String taskId = get("taskId");
    if (StringUtils.isEmpty(taskId)) {
        renderFail("taskId参数不可为空");
        return;
    }
    Task task = ActivitiUtils.getTaskService().createTaskQuery().taskId(taskId).singleResult();
    if (task == null) {
        log.info("taskId:{} 任务不存在", taskId);
        renderFail("参数错误");
        return;
    }
    // 能否调整表单
    set("adjustAble", task.getTaskDefinitionKey().equalsIgnoreCase(ActConst.ADJUST_APPLY_TASK_KEY));
    set("taskId", task.getId());
    set("taskName", task.getName());
    set("taskKey", task.getTaskDefinitionKey());
    if (StringUtils.notEmpty(task.getDescription())) {
        set("taskDescription", task.getDescription());
    }
    String renderedTaskForm = ActivitiUtils.getRenderedTaskFrom(task);
    // 任务表单
    set("renderedTaskForm", renderedTaskForm);
    String instanceId = task.getProcessInstanceId();
    ProcessInstance instance = ActivitiUtils.getRuntimeProcessInstance(instanceId, true);
    // 实例id
    set("instanceId", instanceId);
    // 实例名称
    set("instanceName", instance.getName());
    // 发起人
    set("initiator", (String) instance.getProcessVariables().get(ActConst.APPLY_USER));
    // 申请表单数据
    set("applyFormData", (String) instance.getProcessVariables().get(ActConst.APPLY_FORM_DATA));
    String formTplId = (String) instance.getProcessVariables().get(ActConst.APPLY_FORM_TPL_ID);
    ActFormTpl formTpl = ActFormTpl.dao.findById(formTplId);
    // 申请表单模板
    set("applyFormTpl", formTpl.getTemplate());
    // 申请表单插件
    set("applyFormTplPlugins", formTpl.getPlugins());
    render("process/myTask_complete.ftl");
}
Also used : Task(org.activiti.engine.task.Task) ActFormTpl(com.github.qinyou.process.model.ActFormTpl) ProcessInstance(org.activiti.engine.runtime.ProcessInstance)

Example 7 with ActFormTpl

use of com.github.qinyou.process.model.ActFormTpl in project my_curd by qinyou.

the class ProcessController method processInstanceDetail.

// 流程详情
@Before(IdRequired.class)
public void processInstanceDetail() {
    // 流程实例 id
    String processInstanceId = get("id");
    HistoricProcessInstance instance = ActivitiUtils.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult();
    // 申请人
    String initiator = (String) instance.getProcessVariables().get(ActConst.APPLY_USER);
    // 发起表单数据
    String applyFormData = (String) instance.getProcessVariables().get(ActConst.APPLY_FORM_DATA);
    // 发起表单模板id
    String formTplId = (String) instance.getProcessVariables().get(ActConst.APPLY_FORM_TPL_ID);
    ActFormTpl formTpl = ActFormTpl.dao.findById(formTplId);
    set("initiator", initiator);
    set("instanceId", processInstanceId);
    set("instanceName", instance.getName());
    set("applyFormData", applyFormData);
    // 表单模板
    set("applyFormTpl", formTpl.getTemplate());
    if (instance.getDeleteReason() != null) {
        // 删除原因(用户取消任务才会存在)
        set("delReason", instance.getDeleteReason());
    }
    if (instance.getEndTime() != null) {
        // 流程结束时间
        set("endTime", instance.getEndTime());
    }
    render("process/processInstance_detail.ftl");
}
Also used : ActFormTpl(com.github.qinyou.process.model.ActFormTpl) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Before(com.jfinal.aop.Before)

Example 8 with ActFormTpl

use of com.github.qinyou.process.model.ActFormTpl in project my_curd by qinyou.

the class ActFormTplController method newModel.

/**
 * 打开新增或者修改弹出框
 */
public void newModel() {
    String id = getPara("id");
    if (StringUtils.notEmpty(id)) {
        ActFormTpl actFormTpl = ActFormTpl.dao.findById(id);
        setAttr("actFormTpl", actFormTpl);
    }
    render("process/actFormTpl_form.ftl");
}
Also used : ActFormTpl(com.github.qinyou.process.model.ActFormTpl)

Example 9 with ActFormTpl

use of com.github.qinyou.process.model.ActFormTpl in project my_curd by qinyou.

the class MyApplyController method newApplyAction.

// 新建申请 action
public void newApplyAction() {
    String processKey = get("processKey");
    String applyFormTplId = get("applyFormTplId");
    String applyFormData = get("applyFormData");
    String applyFormTitle = get("applyFormTitle");
    if (StringUtils.isEmpty(processKey) || StringUtils.isEmpty(applyFormTplId) || StringUtils.isEmpty(applyFormData) || StringUtils.isEmpty(applyFormTitle)) {
        renderFail("参数缺失");
        return;
    }
    // 校验表单有效性
    ActFormTpl actFormTpl = ActFormTpl.dao.findById(applyFormTplId);
    if (actFormTpl == null) {
        renderFail("参数错误");
        return;
    }
    if ("0".equals(actFormTpl.getState())) {
        renderFail("发起失败,该申请单已下线,请关闭页面后重新重新申请!");
        return;
    }
    Authentication.setAuthenticatedUserId(WebUtils.getSessionUsername(this));
    ActivitiUtils.getRuntimeService().createProcessInstanceBuilder().processDefinitionKey(processKey).processInstanceName(applyFormTitle).addVariable(ActConst.APPLY_FORM_DATA, applyFormData).addVariable(ActConst.APPLY_FORM_TPL_ID, applyFormTplId).start();
    renderSuccess("发起成功");
}
Also used : ActFormTpl(com.github.qinyou.process.model.ActFormTpl)

Aggregations

ActFormTpl (com.github.qinyou.process.model.ActFormTpl)9 Before (com.jfinal.aop.Before)3 UploadFile (com.jfinal.upload.UploadFile)2 IOException (java.io.IOException)2 Date (java.util.Date)2 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Task (org.activiti.engine.task.Task)1 DateTime (org.joda.time.DateTime)1