新增钉钉官方流程
This commit is contained in:
parent
7782a17c7c
commit
b2408eb50a
|
@ -34,7 +34,7 @@ import java.util.Map;
|
|||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/dingTalk")
|
||||
public class DingTalkCallBackController {
|
||||
public class CallBackController {
|
||||
|
||||
@Autowired
|
||||
private DingtalkCallBackServiceImpl dingtalkCallBackService;
|
|
@ -0,0 +1,142 @@
|
|||
package com.snow.web.controller.dingtalk;
|
||||
|
||||
import com.dingtalk.api.response.OapiProcessListbyuseridResponse;
|
||||
import com.dingtalk.api.response.OapiProcessTemplateManageGetResponse;
|
||||
import com.dingtalk.api.response.OapiProcessinstanceGetResponse;
|
||||
import com.snow.common.core.controller.BaseController;
|
||||
import com.snow.common.core.domain.AjaxResult;
|
||||
import com.snow.common.core.page.PageDomain;
|
||||
import com.snow.common.core.page.PageModel;
|
||||
import com.snow.common.core.page.TableDataInfo;
|
||||
import com.snow.common.core.page.TableSupport;
|
||||
import com.snow.dingtalk.model.FlowExecuteTaskRequest;
|
||||
import com.snow.dingtalk.model.FlowTerminateProcessInstanceRequest;
|
||||
import com.snow.dingtalk.service.impl.DingOfficialFlowServiceImpl;
|
||||
import com.snow.framework.util.ShiroUtils;
|
||||
import com.snow.system.domain.SysUser;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: snow
|
||||
* @description
|
||||
* @author: 没用的阿吉
|
||||
* @create: 2021-03-17 14:07
|
||||
**/
|
||||
@Controller
|
||||
@RequestMapping("/ding/officialFlow")
|
||||
public class OfficialFlowController extends BaseController {
|
||||
|
||||
private String prefix = "ding/flow";
|
||||
|
||||
@Autowired
|
||||
private DingOfficialFlowServiceImpl dingOfficialFlowService;
|
||||
|
||||
/**
|
||||
* 跳转钉钉官方流程模板
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("ding:officialFlow:getTemplateManageList")
|
||||
@GetMapping("/toProcessTemplateManage")
|
||||
public String toProcessTemplateManage(ModelMap mmap){
|
||||
|
||||
return prefix+"/templateManage";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取钉钉官方流程模板
|
||||
*/
|
||||
@RequiresPermissions("ding:officialFlow:getTemplateManageList")
|
||||
@PostMapping("/getProcessTemplateManageList")
|
||||
@ResponseBody
|
||||
public TableDataInfo getProcessTemplateManageList()
|
||||
{
|
||||
SysUser sysUser = ShiroUtils.getSysUser();
|
||||
List<OapiProcessTemplateManageGetResponse.ProcessSimpleVO> processTemplateManage = dingOfficialFlowService.getProcessTemplateManage(sysUser.getDingUserId());
|
||||
return pageBySubList(processTemplateManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转
|
||||
* @param mmap
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("ding:officialFlow:getProcessListByUserId")
|
||||
@GetMapping("/toProcessListByUserId")
|
||||
public String toProcessListByUserId(ModelMap mmap){
|
||||
|
||||
return prefix+"/myDingTask";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的审批流程
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("ding:officialFlow:getProcessListByUserId")
|
||||
@PostMapping("/getProcessListByUserId")
|
||||
@ResponseBody
|
||||
public TableDataInfo getProcessListByUserId(){
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
SysUser sysUser = ShiroUtils.getSysUser();
|
||||
OapiProcessListbyuseridResponse.HomePageProcessTemplateVo processListByUserId = dingOfficialFlowService.getProcessListByUserId(sysUser.getDingUserId());
|
||||
return pageBySubList(processListByUserId.getProcessList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行流程实例
|
||||
* @param flowExecuteTaskRequest
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("ding:officialFlow:executeProcess")
|
||||
@PostMapping("/executeProcessInstance")
|
||||
@ResponseBody
|
||||
public AjaxResult executeProcessInstance(FlowExecuteTaskRequest flowExecuteTaskRequest){
|
||||
SysUser sysUser = ShiroUtils.getSysUser();
|
||||
flowExecuteTaskRequest.setActionerUserid(sysUser.getDingUserId());
|
||||
Boolean aBoolean = dingOfficialFlowService.executeProcessInstance(flowExecuteTaskRequest);
|
||||
return AjaxResult.success(aBoolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程详情
|
||||
* @param processInstanceId
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("ding:officialFlow:getProcessDetail")
|
||||
@GetMapping("/getProcessInstanceDetail")
|
||||
public String getProcessInstanceDetail(String processInstanceId,ModelMap mmap){
|
||||
|
||||
OapiProcessinstanceGetResponse.ProcessInstanceTopVo processInstanceDetail = dingOfficialFlowService.getProcessInstanceDetail(processInstanceId);
|
||||
|
||||
//获取表单值
|
||||
List<OapiProcessinstanceGetResponse.FormComponentValueVo> formComponentValues = processInstanceDetail.getFormComponentValues();
|
||||
mmap.put("formComponentValues",formComponentValues);
|
||||
|
||||
mmap.put("processInstanceDetail",processInstanceDetail);
|
||||
return prefix+"/checkDetail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 终止流程
|
||||
* @param flowTerminateProcessInstanceRequest
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("ding:officialFlow:terminateProcess")
|
||||
@PostMapping("/terminateProcessInstance")
|
||||
@ResponseBody
|
||||
public AjaxResult terminateProcessInstance(FlowTerminateProcessInstanceRequest flowTerminateProcessInstanceRequest){
|
||||
SysUser sysUser = ShiroUtils.getSysUser();
|
||||
flowTerminateProcessInstanceRequest.setOperatingUserid(sysUser.getDingUserId());
|
||||
Boolean aBoolean = dingOfficialFlowService.terminateProcessInstance(flowTerminateProcessInstanceRequest);
|
||||
return AjaxResult.success(aBoolean);
|
||||
}
|
||||
|
||||
}
|
|
@ -303,6 +303,27 @@ var table = {
|
|||
return _text;
|
||||
}
|
||||
},
|
||||
changeDateFormat:function(value){
|
||||
var myDate = new Date(value);
|
||||
//获取当前年
|
||||
var year=myDate.getFullYear();
|
||||
//获取当前月
|
||||
var month=myDate.getMonth()+1;
|
||||
month = month < 10 ? "0"+month : month;
|
||||
//获取当前日
|
||||
var date=myDate.getDate();
|
||||
date = date < 10 ? "0"+date : date;
|
||||
//获取当前小时数(0-23)
|
||||
var h=myDate.getHours();
|
||||
h = h < 10 ? "0"+h : h;
|
||||
//获取当前分钟数(0-59)
|
||||
var m=myDate.getMinutes();
|
||||
m = m < 10 ? "0"+m : m;
|
||||
var s=myDate.getSeconds();
|
||||
s = s < 10 ? "0"+s : s;
|
||||
var time =year+'-'+month+"-"+date+" "+h+":"+m+":"+s;
|
||||
return time;
|
||||
},
|
||||
// 下拉按钮切换
|
||||
dropdownToggle: function (value) {
|
||||
var actions = [];
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet" />
|
||||
<link th:href="@{/css/font-awesome.min.css}" rel="stylesheet" />
|
||||
<!-- bootstrap-table 表格插件样式 -->
|
||||
<link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/animate.css}" rel="stylesheet" />
|
||||
<link th:href="@{/css/style.css}" rel="stylesheet" />
|
||||
<link th:href="@{/ruoyi/css/ry-ui.css}" rel="stylesheet" />
|
||||
<th:block th:include="include :: bootstrap-fileinput-css"/>
|
||||
</head>
|
||||
<body class="white-bg" >
|
||||
<form class="form-horizontal m-t" id="signupForm">
|
||||
<!--<input class="form-control" type="hidden" name="taskId" th:value="*{taskId}"/>
|
||||
<input class="form-control" type="hidden" id="processInstanceId" name="processInstanceId" th:value="*{processInstanceId}"/>
|
||||
<input class="form-control" type="hidden" name="businessKey" th:value="${appFrom.resignNo}"/>-->
|
||||
<!--<input name="id" th:value="${appFrom.id}" type="hidden">-->
|
||||
<br/>
|
||||
<h2 class="form-header h2" >离职审批信息</h2>
|
||||
<div class="row" th:each="form,iterStat : ${formComponentValues}">
|
||||
<div class="col-xs-6 col-sm-8 col-md-offset-1">
|
||||
<label th:text="${form.name}"></label>
|
||||
<span th:text="${form.value}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<th:block th:include="include :: approvalpage" />
|
||||
</form>
|
||||
<th:block th:include="include :: footer" />
|
||||
<th:block th:include="include :: bootstrap-fileinput-js"/>
|
||||
<script th:inline="javascript">
|
||||
$(function () {
|
||||
var processInstanceId= $("#processInstanceId").val();
|
||||
var url ="/modeler/getProcessDiagram?processInstanceId="+processInstanceId;
|
||||
$(".imgcode").attr("src", url);
|
||||
});
|
||||
var files=new Array();
|
||||
$(".file-upload").each(function (i) {
|
||||
var val = $("input[name='" + this.id + "']").val();
|
||||
$(this).fileinput({
|
||||
'uploadUrl': '/common/upload',
|
||||
initialPreviewAsData: true,
|
||||
allowedFileExtensions: ['jpg', 'gif', 'png',".docx","doc","ppt","pptx","xls","xlsx","vsd","rtf","wps","pdf","txt"],//接收的文件后缀
|
||||
initialPreview: [val],
|
||||
maxFileCount: 1,
|
||||
autoReplace: true
|
||||
}).on('fileuploaded', function (event, data, previewId, index) {
|
||||
files.push({"key": data.response.fileKey,"name": data.response.fileName, "url":data.response.url});
|
||||
// $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
|
||||
}).on('fileremoved', function (event, id, index) {
|
||||
$("input[name='" + event.currentTarget.id + "']").val('')
|
||||
})
|
||||
$(this).fileinput('_initFileActions');
|
||||
});
|
||||
|
||||
<!--提交审核结果-->
|
||||
function submitCheckHandler() {
|
||||
if ($.validate.form()) {
|
||||
var data = $("#signupForm").serializeArray();
|
||||
for(var i=0;i<data.length;i++){
|
||||
if(data[i].name=='comment'&&(data[i].value==''||data[i].value==null)){
|
||||
$.modal.alertError("请填写审批意见");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(files!=null||files!=''){
|
||||
for(var i=0;i<files.length;i++){
|
||||
data.push({"name": "files["+i+"].key", "value":files[i].key});
|
||||
data.push({"name": "files["+i+"].name", "value":files[i].name});
|
||||
data.push({"name": "files["+i+"].url", "value":files[i].url});
|
||||
}
|
||||
}
|
||||
console.log(data);
|
||||
$.operate.saveTab("/flow/finishTask", data);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,124 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<th:block th:include="include :: header('我发起的流程')" />
|
||||
<th:block th:include="include :: select2-css" />
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="formId">
|
||||
<div class="select-list">
|
||||
<div class="row">
|
||||
<ul>
|
||||
<li>
|
||||
<label>流程名称:</label>
|
||||
<input type="text" name="processDefinitionName"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>单号:</label>
|
||||
<input type="text" name="businessKey"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<th:block th:include="include :: select2-js" />
|
||||
<script th:inline="javascript">
|
||||
var prefixFlow ="/ding/officialFlow";
|
||||
var todoList = [[${@permission.hasPermi('flow:get:todoList')}]];
|
||||
var transferTask = [[${@permission.hasPermi('flow:process:transferTask')}]];
|
||||
var delegateTask = [[${@permission.hasPermi('flow:process:delegateTask')}]];
|
||||
$(function() {
|
||||
var options = {
|
||||
id: "bootstrap-table",
|
||||
formId:"formId",
|
||||
url: prefixFlow + "/getProcessListByUserId",
|
||||
striped: true,
|
||||
showToggle: false,
|
||||
loadingFontSize:20,
|
||||
showRefresh: false, // 是否显示刷新按钮
|
||||
showColumns: false, // 是否显示隐藏某列下拉框
|
||||
showToggle: false,
|
||||
showSearch: false, // 是否显示检索信息
|
||||
modalName: "我的待办",
|
||||
columns: [{
|
||||
title: '序号',
|
||||
formatter: function (value, row, index) {
|
||||
return index+1;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'taskId',
|
||||
title: 'taskId',
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '流程名称'
|
||||
},
|
||||
{
|
||||
field: 'processCode',
|
||||
title: '单号'
|
||||
|
||||
},
|
||||
{
|
||||
field: 'iconUrl',
|
||||
title: '图标',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.imageView(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'url',
|
||||
title: '流程发起人'
|
||||
},
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-warning btn-xs ' + delegateTask + '" href="javascript:void(0)" onclick="selectDelegateTaskUser(\''+row.taskId+'\')"><i class="fa fa-wifi"></i>委派</a> ');
|
||||
actions.push('<a class="btn btn-primary btn-xs ' + transferTask + '" href="javascript:void(0)" onclick="selectTransferTaskUser(\''+row.taskId+'\')"><i class="fa fa-tasks"></i>转办</a> ');
|
||||
actions.push('<a class="btn btn-success btn-xs ' + todoList + '" href="javascript:void(0)" onclick="cancelTask(\''+row.taskId+'\')"><i class="fa fa-edit"></i>处理</a> ');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
function cancelTask(taskId) {
|
||||
var preViewUrl=prefixFlow+'/toFinishTask?taskId='+taskId;
|
||||
$.modal.openTab("审批", preViewUrl);
|
||||
}
|
||||
|
||||
function selectDelegateTaskUser(taskId) {
|
||||
var url = prefixFlow + '/selectUser?taskId='+taskId+'&flag=0';
|
||||
$.modal.open("选择委派用户", url);
|
||||
}
|
||||
|
||||
function selectTransferTaskUser(taskId) {
|
||||
var url = prefixFlow + '/selectUser?taskId='+taskId+'&flag=1';
|
||||
$.modal.open("选择转办用户", url);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,116 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<th:block th:include="include :: header('离职审批单列表')" />
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="formId">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:resign:add">
|
||||
<i class="fa fa-plus"></i> 添加
|
||||
</a>
|
||||
<!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:resign:edit">
|
||||
<i class="fa fa-edit"></i> 修改
|
||||
</a>-->
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:resign:remove">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:resign:export">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var editFlag = [[${@permission.hasPermi('system:resign:edit')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('system:resign:remove')}]];
|
||||
var detailFlag = [[${@permission.hasPermi('system:resign:detail')}]];
|
||||
var resignTypeDatas = [[${@dict.getType('sys_resign_type')}]];
|
||||
var processStatusDatas = [[${@dict.getType('process_status')}]];
|
||||
var prefix ="/ding/officialFlow";
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
url: prefix + "/getProcessTemplateManageList",
|
||||
modalName: "钉钉流程模板",
|
||||
columns: [{
|
||||
checkbox: false
|
||||
},
|
||||
{
|
||||
field: 'iconUrl',
|
||||
title: '图标',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.imageView(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'processCode',
|
||||
title: '模板编号',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.tooltip(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'flowTitle',
|
||||
title: '模版名称'
|
||||
},
|
||||
|
||||
{
|
||||
field: 'isNewProcess',
|
||||
title: '是否新模版',
|
||||
formatter: function(value, row, index) {
|
||||
if(value){
|
||||
return '是';
|
||||
}else {
|
||||
return '否';
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
field: 'gmtModified',
|
||||
title: '修改时间',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.changeDateFormat(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
/*if(row.processStatus!=0) {
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="printPur(\'' + row.id + '\')"><i class="fa fa-print"></i>打印</a> ');
|
||||
}*/
|
||||
actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-eye"></i>详情</a> ');
|
||||
|
||||
if(row.processStatus==0) {
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>发起审批</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
|
||||
}
|
||||
|
||||
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -132,6 +132,41 @@ public class BaseController
|
|||
rspData.setPageSize(list.getPageSize());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用subList方法进行分页
|
||||
* @param list 分页数据
|
||||
*/
|
||||
public TableDataInfo pageBySubList(List list) {
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Integer pageIndex = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
int totalCount = list.size();
|
||||
int pageCount = 0;
|
||||
List<String> subList;
|
||||
int m = totalCount % pageSize;
|
||||
if (m > 0) {
|
||||
pageCount = totalCount / pageSize + 1;
|
||||
} else {
|
||||
pageCount = totalCount / pageSize;
|
||||
}
|
||||
if (m == 0) {
|
||||
subList = list.subList((pageIndex - 1) * pageSize, pageSize * (pageIndex));
|
||||
} else {
|
||||
if (pageIndex == pageCount) {
|
||||
subList = list.subList((pageIndex - 1) * pageSize, totalCount);
|
||||
} else {
|
||||
subList = list.subList((pageIndex - 1) * pageSize, pageSize * (pageIndex));
|
||||
}
|
||||
}
|
||||
rspData.setCode(0);
|
||||
rspData.setRows(subList);
|
||||
rspData.setTotal(totalCount);
|
||||
rspData.setPageIndex(pageIndex);
|
||||
rspData.setPageSize(pageSize);
|
||||
return rspData;
|
||||
}
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
|
|
|
@ -102,4 +102,34 @@ public class BaseConstantUrl {
|
|||
* 删除公告
|
||||
*/
|
||||
public static final String BLACKBOARD_DELETE="https://oapi.dingtalk.com/topapi/blackboard/delete";
|
||||
|
||||
|
||||
/**********************************************************
|
||||
* 钉钉官方流程
|
||||
* *********************************************************/
|
||||
|
||||
/**
|
||||
* 获取当前企业所有可管理的模版
|
||||
*/
|
||||
public static final String GET_PROCESS_TEMPLATE_MANAGE="https://oapi.dingtalk.com/topapi/process/template/manage/get";
|
||||
|
||||
/**
|
||||
* 执行流程
|
||||
*/
|
||||
public static final String EXECUTE_PROCESSINSTANCE="https://oapi.dingtalk.com/topapi/process/instance/execute";
|
||||
|
||||
/**
|
||||
* 获取审批实例详情
|
||||
*/
|
||||
public static final String GET_PROCESSINSTANCE="https://oapi.dingtalk.com/topapi/processinstance/get";
|
||||
|
||||
/**
|
||||
* 终止流程
|
||||
*/
|
||||
public static final String TERMINATE_PROCESSINSTANCE="https://oapi.dingtalk.com/topapi/process/instance/terminate";
|
||||
|
||||
/**
|
||||
* 分页获取指定用户可见的审批表单列表
|
||||
*/
|
||||
public static final String GET_PROCESSLIST_USERID="https://oapi.dingtalk.com/topapi/process/listbyuserid";
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import com.snow.common.utils.StringUtils;
|
|||
import com.snow.common.utils.spring.SpringUtils;
|
||||
import com.snow.system.domain.SysOperLog;
|
||||
import com.snow.system.service.impl.SysConfigServiceImpl;
|
||||
import com.snow.system.service.impl.SysDingtalkSyncLogServiceImpl;
|
||||
import com.snow.system.service.impl.SysOperLogServiceImpl;
|
||||
import com.taobao.api.ApiException;
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
package com.snow.dingtalk.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: snow
|
||||
* @description
|
||||
* @author: 没用的阿吉
|
||||
* @create: 2021-03-17 13:09
|
||||
**/
|
||||
@Data
|
||||
public class FlowExecuteTaskRequest implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -5629974602089296152L;
|
||||
|
||||
/**
|
||||
* 操作人userid,
|
||||
*/
|
||||
private String actionerUserid;
|
||||
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
private File file;
|
||||
|
||||
/**
|
||||
*流程实例id
|
||||
*/
|
||||
private String processInstanceId;
|
||||
|
||||
/**
|
||||
* 操作评论,可为空。
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 审批操作,取值。
|
||||
*
|
||||
* agree:同意
|
||||
*
|
||||
* refuse:拒绝
|
||||
*/
|
||||
private String result;
|
||||
|
||||
/**
|
||||
* 任务节点id
|
||||
*/
|
||||
private Long taskId;
|
||||
|
||||
|
||||
@Data
|
||||
public static class File {
|
||||
|
||||
|
||||
/**
|
||||
* 附件列表。
|
||||
*/
|
||||
private List<Attachment> attachments;
|
||||
|
||||
/**
|
||||
* 图片URL地址
|
||||
*/
|
||||
private List<String> photos;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Attachment {
|
||||
|
||||
|
||||
private String fileId;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String fileSize;
|
||||
|
||||
private String fileType;
|
||||
|
||||
private String spaceId;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.snow.dingtalk.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @program: snow
|
||||
* @description 终止流程实体
|
||||
* @author: 没用的阿吉
|
||||
* @create: 2021-03-17 13:34
|
||||
**/
|
||||
@Data
|
||||
public class FlowTerminateProcessInstanceRequest implements Serializable {
|
||||
private static final long serialVersionUID = -7143220394052511824L;
|
||||
|
||||
/**
|
||||
*是否通过系统操作:
|
||||
*
|
||||
* true:由系统直接终止
|
||||
*
|
||||
* false:由指定的操作者终止
|
||||
*/
|
||||
private Boolean isSystem;
|
||||
|
||||
/**
|
||||
* 操作人的userid。
|
||||
*
|
||||
* 当is_system为false时,该参数必传。
|
||||
*/
|
||||
private String operatingUserid;
|
||||
|
||||
@NotBlank(message = "流程实例id不能为空")
|
||||
private String processInstanceId;
|
||||
|
||||
/**
|
||||
* 终止说明
|
||||
*/
|
||||
private String remark;
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.snow.dingtalk.service;
|
||||
|
||||
import com.dingtalk.api.response.OapiProcessListbyuseridResponse;
|
||||
import com.dingtalk.api.response.OapiProcessTemplateManageGetResponse;
|
||||
import com.dingtalk.api.response.OapiProcessinstanceGetResponse;
|
||||
import com.snow.common.core.page.PageDomain;
|
||||
import com.snow.common.core.page.PageModel;
|
||||
import com.snow.dingtalk.model.FlowExecuteTaskRequest;
|
||||
import com.snow.dingtalk.model.FlowTerminateProcessInstanceRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: snow
|
||||
* @description 钉钉官方工作流
|
||||
* @author: 没用的阿吉
|
||||
* @create: 2021-03-17 10:23
|
||||
**/
|
||||
public interface DingOfficialFlowService {
|
||||
|
||||
/**
|
||||
* 获取当前企业所有可管理的模版
|
||||
* @param userId
|
||||
*/
|
||||
List<OapiProcessTemplateManageGetResponse.ProcessSimpleVO> getProcessTemplateManage(String userId);
|
||||
|
||||
/**
|
||||
* 获取指定用户可见的审批表单列表
|
||||
* @return
|
||||
*/
|
||||
OapiProcessListbyuseridResponse.HomePageProcessTemplateVo getProcessListByUserId( String userId);
|
||||
|
||||
|
||||
/**
|
||||
* 执行审批操作带附件
|
||||
* @param flowExecuteTaskRequest
|
||||
* @return
|
||||
*/
|
||||
Boolean executeProcessInstance(FlowExecuteTaskRequest flowExecuteTaskRequest);
|
||||
|
||||
// void addProcessInstanceComment();
|
||||
|
||||
/**
|
||||
* 获取审批实例详情
|
||||
* @param processInstanceId
|
||||
* @return
|
||||
*/
|
||||
OapiProcessinstanceGetResponse.ProcessInstanceTopVo getProcessInstanceDetail(String processInstanceId);
|
||||
|
||||
|
||||
/**
|
||||
* 终止流程
|
||||
* @param flowTerminateProcessInstanceRequest
|
||||
* @return
|
||||
*/
|
||||
Boolean terminateProcessInstance(FlowTerminateProcessInstanceRequest flowTerminateProcessInstanceRequest);
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
package com.snow.dingtalk.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.*;
|
||||
import com.dingtalk.api.response.*;
|
||||
import com.snow.common.core.page.PageDomain;
|
||||
import com.snow.common.core.page.PageModel;
|
||||
import com.snow.common.exception.SyncDataException;
|
||||
import com.snow.common.utils.StringUtils;
|
||||
import com.snow.common.utils.bean.BeanUtils;
|
||||
import com.snow.dingtalk.common.BaseConstantUrl;
|
||||
import com.snow.dingtalk.common.BaseService;
|
||||
import com.snow.dingtalk.model.FlowExecuteTaskRequest;
|
||||
import com.snow.dingtalk.model.FlowTerminateProcessInstanceRequest;
|
||||
import com.snow.dingtalk.service.DingOfficialFlowService;
|
||||
import com.taobao.api.ApiException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: snow
|
||||
* @description 钉钉官方工作流服务
|
||||
* @author: 没用的阿吉
|
||||
* @create: 2021-03-17 10:24
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DingOfficialFlowServiceImpl extends BaseService implements DingOfficialFlowService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<OapiProcessTemplateManageGetResponse.ProcessSimpleVO> getProcessTemplateManage(String userId) {
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.GET_PROCESS_TEMPLATE_MANAGE);
|
||||
OapiProcessTemplateManageGetRequest req = new OapiProcessTemplateManageGetRequest();
|
||||
req.setUserid(userId);
|
||||
try {
|
||||
OapiProcessTemplateManageGetResponse response = client.execute(req, getDingTalkToken());
|
||||
if (response.getErrcode() != 0) {
|
||||
throw new SyncDataException(JSON.toJSONString(req), response.getErrmsg());
|
||||
}
|
||||
return response.getResult();
|
||||
} catch (ApiException e) {
|
||||
log.error("获取当前企业所有可管理的模版getProcessTemplateManage异常:{}", e.getMessage());
|
||||
throw new SyncDataException(JSON.toJSONString(req), e.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OapiProcessListbyuseridResponse.HomePageProcessTemplateVo getProcessListByUserId( String userId) {
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.GET_PROCESSLIST_USERID);
|
||||
OapiProcessListbyuseridRequest req = new OapiProcessListbyuseridRequest();
|
||||
req.setUserid(userId);
|
||||
req.setOffset(0L);
|
||||
req.setSize(100L);
|
||||
try {
|
||||
OapiProcessListbyuseridResponse response = client.execute(req, getDingTalkToken());
|
||||
if (response.getErrcode() != 0) {
|
||||
throw new SyncDataException(JSON.toJSONString(req), response.getErrmsg());
|
||||
}
|
||||
return response.getResult();
|
||||
} catch (ApiException e) {
|
||||
log.error("获取指定用户可见的审批表单列表getProcessListByUserId异常:{}", e.getMessage());
|
||||
throw new SyncDataException(JSON.toJSONString(req), e.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean executeProcessInstance(FlowExecuteTaskRequest flowExecuteTaskRequest) {
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.EXECUTE_PROCESSINSTANCE);
|
||||
OapiProcessinstanceExecuteV2Request req = new OapiProcessinstanceExecuteV2Request();
|
||||
OapiProcessinstanceExecuteV2Request.ExecuteTaskRequest executeTaskRequest = new OapiProcessinstanceExecuteV2Request.ExecuteTaskRequest();
|
||||
executeTaskRequest.setProcessInstanceId(flowExecuteTaskRequest.getProcessInstanceId());
|
||||
executeTaskRequest.setActionerUserid(flowExecuteTaskRequest.getActionerUserid());
|
||||
executeTaskRequest.setTaskId(flowExecuteTaskRequest.getTaskId());
|
||||
executeTaskRequest.setRemark(flowExecuteTaskRequest.getRemark());
|
||||
executeTaskRequest.setResult(flowExecuteTaskRequest.getResult());
|
||||
if(StringUtils.isNotNull(flowExecuteTaskRequest.getFile())){
|
||||
OapiProcessinstanceExecuteV2Request.File file=new OapiProcessinstanceExecuteV2Request.File();
|
||||
if(StringUtils.isNotNull(flowExecuteTaskRequest.getFile().getAttachments())){
|
||||
List<OapiProcessinstanceExecuteV2Request.Attachment> attachments = BeanUtils.transformList(flowExecuteTaskRequest.getFile().getAttachments(), OapiProcessinstanceExecuteV2Request.Attachment.class);
|
||||
file.setAttachments(attachments);
|
||||
}
|
||||
file.setPhotos(flowExecuteTaskRequest.getFile().getPhotos());
|
||||
executeTaskRequest.setFile(file);
|
||||
}
|
||||
req.setRequest(executeTaskRequest);
|
||||
try {
|
||||
OapiProcessinstanceExecuteV2Response response = client.execute(req, getDingTalkToken());
|
||||
if (response.getErrcode() != 0) {
|
||||
throw new SyncDataException(JSON.toJSONString(req), response.getErrmsg());
|
||||
}
|
||||
return response.getResult();
|
||||
} catch (ApiException e) {
|
||||
log.error("执行审批操作带附件executeProcessInstance异常:{}", e.getMessage());
|
||||
throw new SyncDataException(JSON.toJSONString(req), e.getErrMsg());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void addProcessInstanceComment() {
|
||||
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public OapiProcessinstanceGetResponse.ProcessInstanceTopVo getProcessInstanceDetail(String processInstanceId) {
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.GET_PROCESSINSTANCE);
|
||||
OapiProcessinstanceGetRequest req = new OapiProcessinstanceGetRequest();
|
||||
req.setProcessInstanceId(processInstanceId);
|
||||
try {
|
||||
OapiProcessinstanceGetResponse response = client.execute(req, getDingTalkToken());
|
||||
if (response.getErrcode() != 0) {
|
||||
throw new SyncDataException(JSON.toJSONString(req), response.getErrmsg());
|
||||
}
|
||||
return response.getProcessInstance();
|
||||
} catch (ApiException e) {
|
||||
log.error("获取审批实例详情getProcessInstanceDetail异常:{}", e.getMessage());
|
||||
throw new SyncDataException(JSON.toJSONString(req), e.getErrMsg());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean terminateProcessInstance(FlowTerminateProcessInstanceRequest flowTerminateProcessInstanceRequest) {
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.TERMINATE_PROCESSINSTANCE);
|
||||
OapiProcessInstanceTerminateRequest req = new OapiProcessInstanceTerminateRequest();
|
||||
OapiProcessInstanceTerminateRequest.TerminateProcessInstanceRequestV2 processInstanceRequestV2 = new OapiProcessInstanceTerminateRequest.TerminateProcessInstanceRequestV2();
|
||||
processInstanceRequestV2.setProcessInstanceId(flowTerminateProcessInstanceRequest.getProcessInstanceId());
|
||||
processInstanceRequestV2.setIsSystem(flowTerminateProcessInstanceRequest.getIsSystem());
|
||||
processInstanceRequestV2.setRemark(flowTerminateProcessInstanceRequest.getRemark());
|
||||
processInstanceRequestV2.setOperatingUserid(flowTerminateProcessInstanceRequest.getOperatingUserid());
|
||||
req.setRequest(processInstanceRequestV2);
|
||||
|
||||
try {
|
||||
OapiProcessInstanceTerminateResponse response = client.execute(req, getDingTalkToken());
|
||||
if (response.getErrcode() != 0) {
|
||||
throw new SyncDataException(JSON.toJSONString(req), response.getErrmsg());
|
||||
}
|
||||
return response.getSuccess();
|
||||
} catch (ApiException e) {
|
||||
log.error("终止流程terminateProcessInstance异常:{}", e.getMessage());
|
||||
throw new SyncDataException(JSON.toJSONString(req), e.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue