Search in sources :

Example 46 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class SysSettingController method importExcel.

/**
 * 导入excel
 */
@Before(Tx.class)
public void importExcel() {
    UploadFile uploadFile = getFile();
    if (uploadFile == null) {
        renderFail("上传文件不可为空");
        return;
    }
    if (!FilenameUtils.getExtension(uploadFile.getFileName()).equals("xls")) {
        FileUtils.deleteFile(uploadFile.getFile());
        renderFail("上传文件后缀必须是xls");
        return;
    }
    List<SysSetting> list;
    try {
        ImportParams params = new ImportParams();
        params.setTitleRows(1);
        params.setHeadRows(1);
        list = ExcelImportUtil.importExcel(uploadFile.getFile(), SysSetting.class, params);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        FileUtils.deleteFile(uploadFile.getFile());
        renderFail("模板文件格式错误");
        return;
    }
    for (SysSetting sysSetting : list) {
        sysSetting.setId(IdUtils.id()).setUpdater(WebUtils.getSessionUsername(this)).setUpdateTime(new Date()).save();
    }
    FileUtils.deleteFile(uploadFile.getFile());
    refreshSetting();
    renderSuccess(IMPORT_SUCCESS);
}
Also used : UploadFile(com.jfinal.upload.UploadFile) SysSetting(com.github.qinyou.system.model.SysSetting) ImportParams(cn.afterturn.easypoi.excel.entity.ImportParams) Date(java.util.Date) Before(com.jfinal.aop.Before)

Example 47 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class MyApplyController method deleteApply.

// 流程实例删除(仅运行结束实例、物理删除)
@Before(IdRequired.class)
public void deleteApply() {
    HistoricProcessInstance instance = ActivitiUtils.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(// 流程实例id
    get("id")).finished().singleResult();
    if (instance == null) {
        renderFail("已结束流程实例 不存在");
        return;
    }
    ActivitiUtils.getHistoryService().deleteHistoricProcessInstance(instance.getId());
    renderSuccess("删除流程 成功");
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Before(com.jfinal.aop.Before)

Example 48 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class MyApplyController method cancelApply.

// 流程实例取消 (仅未结束的流程、填充的作废原因)
@Before(IdRequired.class)
public void cancelApply() {
    HistoricProcessInstance instance = ActivitiUtils.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(// 流程实例id
    get("id")).unfinished().singleResult();
    if (instance == null) {
        renderFail("进行中流程实例 不存在");
        return;
    }
    ActivitiUtils.getRuntimeService().deleteProcessInstance(instance.getId(), ActConst.DEL_USER_CANCEL);
    renderSuccess("取消流程 成功");
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Before(com.jfinal.aop.Before)

Example 49 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class SysNoticeTypeController method addTypeRoleAction.

/**
 * 增加 关联关系
 */
@Before(Tx.class)
public void addTypeRoleAction() {
    String roleIds = getPara("roleIds");
    String sysNoticeTypeId = getPara("sysNoticeTypeId");
    SysNoticeTypeSysRole sysNTRoleOld;
    for (String roleId : roleIds.split(",")) {
        sysNTRoleOld = SysNoticeTypeSysRole.dao.findByIds(sysNoticeTypeId, roleId);
        if (sysNTRoleOld != null) {
            continue;
        }
        SysNoticeTypeSysRole sysNTRole = new SysNoticeTypeSysRole();
        sysNTRole.setSysNoticeTypeId(sysNoticeTypeId).setSysRoleId(roleId).setCreater(WebUtils.getSessionUsername(this)).setCreateTime(new Date()).save();
    }
    renderSuccess("关联角色成功");
}
Also used : SysNoticeTypeSysRole(com.github.qinyou.system.model.SysNoticeTypeSysRole) Date(java.util.Date) Before(com.jfinal.aop.Before)

Example 50 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class MyTaskController method adjustApply.

// 调整申请表单
@Before(Tx.class)
public void adjustApply() {
    String taskId = get("taskId");
    if (StringUtils.isEmpty(taskId)) {
        renderFail("参数缺失");
        return;
    }
    TaskService service = ActivitiUtils.getTaskService();
    Task task = service.createTaskQuery().taskId(taskId).singleResult();
    if (task == null) {
        renderFail("参数错误");
        return;
    }
    String taskDefinitionKey = task.getTaskDefinitionKey();
    if (!ActConst.ADJUST_APPLY_TASK_KEY.equals(taskDefinitionKey)) {
        renderFail("当前节点禁止调整申请");
        return;
    }
    String applyFormData = get("applyFormData");
    // 设置流程实例 变量值
    service.setVariable(taskId, ActConst.APPLY_FORM_DATA, applyFormData);
    renderSuccess("调整申请成功");
}
Also used : Task(org.activiti.engine.task.Task) TaskService(org.activiti.engine.TaskService) Before(com.jfinal.aop.Before)

Aggregations

Before (com.jfinal.aop.Before)53 Date (java.util.Date)11 ActiveRecordException (com.jfinal.plugin.activerecord.ActiveRecordException)5 Record (com.jfinal.plugin.activerecord.Record)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 ToolString (com.hxkj.common.util.ToolString)4 ExportParams (cn.afterturn.easypoi.excel.entity.ExportParams)3 ExcelRdException (com.fruit.manage.util.excelRd.ExcelRdException)3 ActFormTpl (com.github.qinyou.process.model.ActFormTpl)3 SysOplog (com.hxkj.system.model.SysOplog)3 SysUser (com.hxkj.system.model.SysUser)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 RepositoryService (org.activiti.engine.RepositoryService)3 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)3 Model (org.activiti.engine.repository.Model)3 DateTime (org.joda.time.DateTime)3