HAP_工作流后台操作

  • 新建用户(CEO)


    image.png
  • 分配岗位CEO


    image.png
  • 新建表:wht_ora_20796_demo_vacation
CREATE TABLE `wht_ora_20796_demo_vacation` (
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `USER_CODE` varchar(225) NOT NULL COMMENT '用户编码',
  `START_DATE` datetime NOT NULL,
  `NEED_DAYS` decimal(4,1) NOT NULL COMMENT '请假天数',
  `LEAVE_REASON` varchar(255) DEFAULT NULL COMMENT '请假理由',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • 导入工作流文件
    把老师的工号替换成你的工号
    image.png

    image.png

    启动:
    image.png

生成代码:


image.png

复制代码:

复制到
target/core/WEB-INF/view/activiti/demo/vacation_list.html src/main/webapp/WEB-INF/view/ ora20796 /vacation_list.html
target/core/WEB-INF/view/activiti/demo/vacation_view.html src/main/webapp/WEB-INF/view/ ora20796 /vacation_view.html

两个页面都也更改html:


image.png
  • 前方高能(下面继续代码更改)

IOra20796DemoVacationService.java接口

image.png

package wht.ora20796.service;

import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import wht.ora20796.dto.Ora20796DemoVacation;

import java.util.List;

public interface IOra20796DemoVacationService extends IBaseService, ProxySelf{

    public void createVacationInstance(IRequest iRequest, Ora20796DemoVacation ora20796DemoVacation);
    public List selectVacationHistory(IRequest iRequest);
}

Ora20796DemoVacationServiceImpl.java接口实现类
注意点:

image.png

image.png

image.png

package wht.ora20796.service.impl;

import com.hand.hap.activiti.service.IActivitiService;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.activiti.rest.service.api.engine.variable.RestVariable;
import org.activiti.rest.service.api.runtime.process.ProcessInstanceCreateRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import wht.ora20796.dto.Ora20796DemoVacation;
import wht.ora20796.mapper.Ora20796DemoVacationMapper;
import wht.ora20796.service.IOra20796DemoVacationService;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class Ora20796DemoVacationServiceImpl extends BaseServiceImpl implements IOra20796DemoVacationService {

    @Autowired
    private IActivitiService activitiService; //工作流相关Service
    @Autowired
    private Ora20796DemoVacationMapper demoVacationMapper;


    private final String processDefinitionKey = "ORA_20796_VACATION_REQUEST"; //流程标识,通过其启动流程

    //    @Autowired
//    private IDemoVacationService vacationService;
    /*
     * 创建请假流程 将业务表单存放在act_demo_vacation 表将此表单通过businessKey与流程相关。启动此流程
     * DemoVacation为业务表单数据。可根据流程需要将表单数据加入流程变量中,如我们在请假流程审批过程中我们可能
     * 需要请假时间参数对流程逻辑做出相关处理,则可以把其放入流程变量中。
     * */
    @Override
    public void createVacationInstance(IRequest iRequest, Ora20796DemoVacation demoVacation) {
        demoVacation.setUserCode(iRequest.getEmployeeCode());
        Ora20796DemoVacation demo = this.insertSelective(iRequest, demoVacation);
        ProcessInstanceCreateRequest instanceCreateRequest = new ProcessInstanceCreateRequest();
        instanceCreateRequest.setBusinessKey(String.valueOf(demo.getId()));
        instanceCreateRequest.setProcessDefinitionKey(processDefinitionKey);
        //添加流程变量
        List variables = new ArrayList<>();
        RestVariable variable = new RestVariable();
        variable.setName("needDays");
        variable.setType("long");
        variable.setValue(demo.getNeedDays());

        variables.add(variable);
        instanceCreateRequest.setVariables(variables);

        activitiService.startProcess(iRequest, instanceCreateRequest);
    }

    /*
     * 查看历史请假记录(查询单据表)
     * c*/
    @Override
    public List selectVacationHistory(IRequest iRequest) {
        Ora20796DemoVacation demoVacation = new Ora20796DemoVacation();
        demoVacation.setUserCode(iRequest.getEmployeeCode());
        List demoVacations = demoVacationMapper.select(demoVacation);
        return demoVacations;
    }
}

Ora20796DemoVacationController.java控制类
注意点:

  • 更改1
    image.png

    对应vacation_list.html
    image.png
  • 更改2
    image.png

    对应vacation_list.html
    image.png
  • 更改3


    image.png

对应vacation_view.html

image.png

@Autowired
      private IOra20796DemoVacationService service;

      @Autowired
      private IOra20796DemoVacationService vacationService;

      /*
       * 请假流程demo
       * */
      @RequestMapping(value = "/wht/ora/20796/demo/runtime/process-instances/vacation", method = RequestMethod.POST, produces = "application/json")
      //@RequestMapping(value = "/wfl/runtime/process-instances/vacation", method = RequestMethod.POST, produces = "application/json")
      @ResponseBody
      public ResponseData createVacationProcessInstance(@RequestBody Ora20796DemoVacation demoVacation,
                                                        HttpServletRequest httpRequest, HttpServletResponse response) {
          IRequest iRequest = createRequestContext(httpRequest);
          vacationService.createVacationInstance(iRequest, demoVacation);
          return new ResponseData();
      }

      /*
      请假流程通过businessKey获取流程表单
      * */
      @RequestMapping("/wht/ora/20796/demo/history/form/details/vacation/{businessKey}")
     // @RequestMapping("/wfl/history/form/details/vacation/{businessKey}")
      @ResponseBody
      public Ora20796DemoVacation getProcessFrom(HttpServletRequest request, @PathVariable String businessKey) {
          Ora20796DemoVacation demoVacation = new Ora20796DemoVacation();
          demoVacation.setId(Long.parseLong(businessKey));
          Ora20796DemoVacation demo = vacationService.selectByPrimaryKey(createRequestContext(request), demoVacation);
          return demo;
      }

      /*
       * 获取当前用户历史请假记录
       * */
      @ResponseBody
      @RequestMapping("/wht/ora/20796/demo/vacation/work/query")
    //  @RequestMapping("/wfl/vacation/query")
      public ResponseData getVacationHistory(HttpServletRequest request, HttpServletResponse response, Ora20796DemoVacation demoVacation, @RequestParam(defaultValue = DEFAULT_PAGE) int page,
                                             @RequestParam(defaultValue = DEFAULT_PAGE_SIZE) int pagesize) {
          IRequest iRequest = createRequestContext(request);
          List lists = vacationService.selectVacationHistory(iRequest);
          return new ResponseData(lists);
      }

重新打包启动tomcat
添加到功能管理:


image.png

查看:


image.png

bug收集器:

  • 问题1


    image.png

解决:
去到DTO


image.png
  • 问题2:


    image.png

    看不到数据???


    image.png

    image.png
  • 问题3


    image.png

可能原因:1. 你的xml没有改

  1. 你的


    image.png

    没改

  • 问题3


    image.png
Errors while parsing: [Validation set: 'activiti-executable-process' | Problem: 'activiti-exclusive-gateway-condition-on-seq-flow'] : Default sequenceflow has a condition, which is not allowed - [Extra info : processDefinitionId = ORA_20796_VACATION_REQUEST | processDefinitionName = 请假申请 | | id = requestApprovedDecision | | activityName = Request approved? | ] ( line: 27, column: 5) 

解决:


image.png

问题4


image.png

解决:换浏览器,非IE内核,或者其他浏览器(但不要用兼容模式)

你可能感兴趣的:(HAP_工作流后台操作)