activity7 获取流程列表及部署列表

    /**
     * @Des: 获取流程定义列表
     * @Author: liut
     * @Date: 2020/11/23 15:50
     */
    @GetMapping("/getDefinitions")
    public AjaxResponse getDefinitions(){
        try {
            List<HashMap<String,Object>> listMap = new ArrayList<>();
            List<ProcessDefinition> list =
                    repositoryService.createProcessDefinitionQuery().list();
            for (ProcessDefinition pd : list) {
                HashMap<String, Object> hashMap = new HashMap<>();
                hashMap.put("processDefinitionID", pd.getId());
                hashMap.put("name", pd.getName());
                hashMap.put("key", pd.getKey());
                hashMap.put("resourceName", pd.getResourceName());
                hashMap.put("deploymentID", pd.getDeploymentId());
                hashMap.put("version", pd.getVersion());
                listMap.add(hashMap);
            }
            return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.SUCCESS.getCode(),GlobalConfig.ResponseCode.SUCCESS.getDes(),listMap);
        }catch (Exception e){
            return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.ERROR.getCode(),"获取流程定义失败",
                    e.toString());
        }
    }

    /**
     * @Des: 获取流程定义XML
     * @Author: liut 
     * @Date: 2020/11/23 16:33
     */
    @GetMapping("/getDefinitionXML")
    public void getDefinitionXML(HttpServletResponse response,
                                         @RequestParam("deploymentId") String deploymentId,
                                         @RequestParam("resourceName") String resourceName){
        try {
            InputStream inputStream = repositoryService.getResourceAsStream(deploymentId, resourceName);
            int count = inputStream.available();
            byte[] bytes = new byte[count];
            response.setContentType("text/xml");
            ServletOutputStream outputStream = response.getOutputStream();
            while (inputStream.read(bytes) != -1){
                outputStream.write(bytes);
            }
            inputStream.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * @Des: 获取部署列表
     * @Author: liut
     * @Date: 2020/11/23 16:43
     */
    @GetMapping("/getDeployments")
    public AjaxResponse getDeployments(){
        List<HashMap<String,Object>> listMap = new ArrayList<>();
        List<Deployment> list = repositoryService.createDeploymentQuery().list();
        for (Deployment dep : list) {
            HashMap<String, Object> map = new HashMap<>();
            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put("id", dep.getId());
            hashMap.put("name", dep.getName());
            hashMap.put("deploymentTime", dep.getDeploymentTime());
            listMap.add(map);
        }
        return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.SUCCESS.getCode(),
                GlobalConfig.ResponseCode.SUCCESS.getDes(),listMap);
    }

    /**
     * @Des: 删除流程定义
     * @Author: liut
     * @Date: 2020/11/23 15:50
     */
    @GetMapping("/delDefinition")
    public AjaxResponse delDefinition(@RequestParam("depID") String deploymentID,
                                      @RequestParam("pdID") String pdID){
        try {
            activitiMapper.DeleteFormData(pdID);
            repositoryService.deleteDeployment(deploymentID,true);
            return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.SUCCESS.getCode(),"删除成功",null);
        }catch (Exception e){
            return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.ERROR.getCode(),"删除失败",
                    e.toString());
        }
    }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值