Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
attendance-performance-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
attendance-performance-platform
Commits
7ce4ec3b
Commit
7ce4ec3b
authored
Jul 18, 2023
by
周亚武
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
钉钉相关接口
parent
249f1a96
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
9 deletions
+96
-9
attendance-performance-manager/src/main/java/com/mortals/xhx/module/attendance/dingmsg/EventEntity.java
...om/mortals/xhx/module/attendance/dingmsg/EventEntity.java
+44
-0
attendance-performance-manager/src/main/java/com/mortals/xhx/module/attendance/dingmsg/api/DingMessageController.java
.../module/attendance/dingmsg/api/DingMessageController.java
+13
-9
attendance-performance-manager/src/main/java/com/mortals/xhx/module/dingding/personal/service/IDingPersonService.java
.../module/dingding/personal/service/IDingPersonService.java
+7
-0
attendance-performance-manager/src/main/java/com/mortals/xhx/module/dingding/personal/service/impl/DingPersonServiceImpl.java
...dingding/personal/service/impl/DingPersonServiceImpl.java
+32
-0
No files found.
attendance-performance-manager/src/main/java/com/mortals/xhx/module/attendance/dingmsg/EventEntity.java
0 → 100644
View file @
7ce4ec3b
package
com.mortals.xhx.module.attendance.dingmsg
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author ZYW
* @date 2023-07-18 15:05
*/
@NoArgsConstructor
@Data
public
class
EventEntity
{
@JsonProperty
(
"processInstanceId"
)
private
String
processInstanceId
;
//审批实例id。
@JsonProperty
(
"finishTime"
)
private
Long
finishTime
;
//结束审批实例时间。时间戳,单位毫秒。
@JsonProperty
(
"corpId"
)
private
String
corpId
;
//审批实例对应的企业corpId。
@JsonProperty
(
"EventType"
)
private
String
eventType
;
//事件类型。
@JsonProperty
(
"businessId"
)
private
String
businessId
;
@JsonProperty
(
"title"
)
private
String
title
;
//实例标题。
@JsonProperty
(
"type"
)
private
String
type
;
//finish:审批正常结束(同意或拒绝)terminate:审批终止(发起人撤销审批单)
@JsonProperty
(
"url"
)
private
String
url
;
//审批实例url,可在钉钉内跳转到审批页面。
@JsonProperty
(
"result"
)
private
String
result
;
//正常结束时result为agree,拒绝时result为refuse,审批终止时没这个值。
@JsonProperty
(
"createTime"
)
private
Long
createTime
;
//创建审批实例时间。时间戳,单位毫秒。
@JsonProperty
(
"processCode"
)
private
String
processCode
;
//审批模板的唯一码。
@JsonProperty
(
"bizCategoryId"
)
private
String
bizCategoryId
;
@JsonProperty
(
"staffId"
)
private
String
staffId
;
//发起审批实例的员工userId。
@JsonProperty
(
"remark"
)
private
String
remark
;
//remark表示操作时写的评论内容。
}
attendance-performance-manager/src/main/java/com/mortals/xhx/module/attendance/dingmsg/api/DingMessageController.java
View file @
7ce4ec3b
...
@@ -7,13 +7,16 @@ import com.dingtalk.api.DingTalkClient;
...
@@ -7,13 +7,16 @@ import com.dingtalk.api.DingTalkClient;
import
com.dingtalk.api.request.OapiGettokenRequest
;
import
com.dingtalk.api.request.OapiGettokenRequest
;
import
com.dingtalk.api.response.OapiGettokenResponse
;
import
com.dingtalk.api.response.OapiGettokenResponse
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.xhx.common.pdu.ApiRespPdu
;
import
com.mortals.xhx.common.pdu.ApiRespPdu
;
import
com.mortals.xhx.module.attendance.dingmsg.DingCallbackCrypto
;
import
com.mortals.xhx.module.attendance.dingmsg.DingCallbackCrypto
;
import
com.mortals.xhx.module.attendance.dingmsg.dingmsgreq.DingResponsMeassageReq
;
import
com.mortals.xhx.module.attendance.dingmsg.dingmsgreq.DingResponsMeassageReq
;
import
com.mortals.xhx.module.attendance.dingmsg.dingmsgreq.EncryptReq
;
import
com.mortals.xhx.module.attendance.dingmsg.dingmsgreq.EncryptReq
;
import
com.mortals.xhx.module.dingding.personal.service.IDingPersonService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -33,6 +36,9 @@ import java.util.Map;
...
@@ -33,6 +36,9 @@ import java.util.Map;
@Slf4j
@Slf4j
public
class
DingMessageController
{
public
class
DingMessageController
{
@Autowired
private
IDingPersonService
dingPersonService
;
/**
/**
* appKey
* appKey
*/
*/
...
@@ -62,22 +68,16 @@ public class DingMessageController {
...
@@ -62,22 +68,16 @@ public class DingMessageController {
@RequestParam
(
value
=
"nonce"
,
required
=
false
)
String
nonce
,
@RequestParam
(
value
=
"nonce"
,
required
=
false
)
String
nonce
,
@RequestBody
(
required
=
false
)
JSONObject
json
)
{
@RequestBody
(
required
=
false
)
JSONObject
json
)
{
try
{
try
{
// 1. 从http请求中获取加解密参数
// 从http请求中获取加解密参数
// 2. 使用加解密类型
// Constant.OWNER_KEY 说明:
// 1、开发者后台配置的订阅事件为应用级事件推送,此时OWNER_KEY为应用的APP_KEY。
// 2、调用订阅事件接口订阅的事件为企业级事件推送,
// 此时OWNER_KEY为:企业的appkey(企业内部应用)或SUITE_KEY(三方应用)
DingCallbackCrypto
callbackCrypto
=
new
DingCallbackCrypto
(
token
,
aesKey
,
appKey
);
DingCallbackCrypto
callbackCrypto
=
new
DingCallbackCrypto
(
token
,
aesKey
,
appKey
);
String
encryptMsg
=
json
.
getString
(
"encrypt"
);
String
encryptMsg
=
json
.
getString
(
"encrypt"
);
String
decryptMsg
=
callbackCrypto
.
getDecryptMsg
(
msg_signature
,
timeStamp
,
nonce
,
encryptMsg
);
String
decryptMsg
=
callbackCrypto
.
getDecryptMsg
(
msg_signature
,
timeStamp
,
nonce
,
encryptMsg
);
//
3.
反序列化回调事件json数据
// 反序列化回调事件json数据
JSONObject
eventJson
=
JSON
.
parseObject
(
decryptMsg
);
JSONObject
eventJson
=
JSON
.
parseObject
(
decryptMsg
);
String
eventType
=
eventJson
.
getString
(
"EventType"
);
String
eventType
=
eventJson
.
getString
(
"EventType"
);
//
4.
根据EventType分类处理
// 根据EventType分类处理
if
(
"check_url"
.
equals
(
eventType
))
{
if
(
"check_url"
.
equals
(
eventType
))
{
// 测试回调url的正确性
// 测试回调url的正确性
log
.
info
(
"测试回调url的正确性"
);
log
.
info
(
"测试回调url的正确性"
);
...
@@ -87,6 +87,10 @@ public class DingMessageController {
...
@@ -87,6 +87,10 @@ public class DingMessageController {
// 存入数据库
// 存入数据库
log
.
info
(
"发生了:"
+
eventType
+
"事件"
);
log
.
info
(
"发生了:"
+
eventType
+
"事件"
);
log
.
info
(
"返回处理参数:"
+
eventJson
.
toJSONString
()
);
log
.
info
(
"返回处理参数:"
+
eventJson
.
toJSONString
()
);
if
(
eventJson
.
getString
(
"processInstanceId"
)
!=
null
){
Rest
<
String
>
rest
=
dingPersonService
.
getOaRecordsById
(
eventJson
.
getString
(
"processInstanceId"
));
log
.
info
(
"审批详情:"
+
rest
.
toString
()
);
}
}
}
else
{
else
{
// 添加其他已注册的
// 添加其他已注册的
...
...
attendance-performance-manager/src/main/java/com/mortals/xhx/module/dingding/personal/service/IDingPersonService.java
View file @
7ce4ec3b
...
@@ -41,5 +41,12 @@ public interface IDingPersonService extends IDingTalkService {
...
@@ -41,5 +41,12 @@ public interface IDingPersonService extends IDingTalkService {
*/
*/
Rest
<
String
>
sendWorkMsg
(
WorkMsgReq
workMsgReq
);
Rest
<
String
>
sendWorkMsg
(
WorkMsgReq
workMsgReq
);
/**
* 审批详情
* @param processInstanceId 审批实例ID。
* @return
*/
Rest
<
String
>
getOaRecordsById
(
String
processInstanceId
);
}
}
attendance-performance-manager/src/main/java/com/mortals/xhx/module/dingding/personal/service/impl/DingPersonServiceImpl.java
View file @
7ce4ec3b
package
com.mortals.xhx.module.dingding.personal.service.impl
;
package
com.mortals.xhx.module.dingding.personal.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse
;
import
com.aliyun.tea.TeaException
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request
;
import
com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request
;
import
com.dingtalk.api.request.OapiV2UserGetbymobileRequest
;
import
com.dingtalk.api.request.OapiV2UserGetbymobileRequest
;
...
@@ -14,6 +16,7 @@ import com.mortals.xhx.module.dingding.personal.model.req.workmsg.WorkMsgReq;
...
@@ -14,6 +16,7 @@ import com.mortals.xhx.module.dingding.personal.model.req.workmsg.WorkMsgReq;
import
com.mortals.xhx.module.dingding.personal.service.IDingPersonService
;
import
com.mortals.xhx.module.dingding.personal.service.IDingPersonService
;
import
com.taobao.api.ApiException
;
import
com.taobao.api.ApiException
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.logging.Log
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -98,5 +101,34 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
...
@@ -98,5 +101,34 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
}
}
}
}
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
public
static
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
createClient
()
throws
Exception
{
com
.
aliyun
.
teaopenapi
.
models
.
Config
config
=
new
com
.
aliyun
.
teaopenapi
.
models
.
Config
();
config
.
protocol
=
"https"
;
config
.
regionId
=
"central"
;
return
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
(
config
);
}
@Override
public
Rest
<
String
>
getOaRecordsById
(
String
processInstanceId
)
{
try
{
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetProcessInstanceHeaders
getProcessInstanceHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetProcessInstanceHeaders
();
getProcessInstanceHeaders
.
xAcsDingtalkAccessToken
=
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetProcessInstanceRequest
getProcessInstanceRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetProcessInstanceRequest
()
.
setProcessInstanceId
(
processInstanceId
);
GetProcessInstanceResponse
rsp
=
client
.
getProcessInstanceWithOptions
(
getProcessInstanceRequest
,
getProcessInstanceHeaders
,
new
com
.
aliyun
.
teautil
.
models
.
RuntimeOptions
());
log
.
info
(
"根据用户查询审批详情:"
,
rsp
.
getBody
());
return
Rest
.
ok
(
"成功"
,
rsp
.
getBody
().
getResult
().
toString
());
}
catch
(
Exception
e
)
{
log
.
info
(
"根据用户查询审批详情失败"
,
e
);
return
Rest
.
fail
(
e
.
getMessage
());
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment