Commit 2debb3ba authored by 赵啸非's avatar 赵啸非

添加钉钉对接流程代码

parent 2b9f34ca
......@@ -165,7 +165,7 @@
<profiles.sms.apiId>ADsUXLrS81vZDU95</profiles.sms.apiId>
<profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain>
<profiles.dingtalk.oaScheme>https</profiles.dingtalk.oaScheme>
<profiles.dingtalk.oaUrl>oapi.dingtalk.com</profiles.dingtalk.oaUrl>
<profiles.dingtalk.oaUrl></profiles.dingtalk.oaUrl>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.appKey>dingvbzaw1176pbzo1zx</profiles.dingtalk.appKey>
<profiles.dingtalk.appSecret>jmKqKPDLR3BxdZT_QNX4pm6zDdtbaLI3PtsFymQ6tUle-uKUgmxtr_a6ys3b8v3Y</profiles.dingtalk.appSecret>
......
......@@ -9,9 +9,21 @@ import java.util.Map;
* @description: 组件枚举类
**/
public enum ProcessInstanceEnum {
请假("PROC-2E5C0DFF-3615-4409-A614-A2011FED5D38", "请假"),
/* 请假("PROC-2E5C0DFF-3615-4409-A614-A2011FED5D38", "请假"),
外出("PROC-56D3ADEE-45A4-47BC-931A-2A0DC067DE32", "外出"),
出差("PROC-578CBDDF-B768-496D-9918-44A3F1D9CAE7", "出差");
出差("PROC-578CBDDF-B768-496D-9918-44A3F1D9CAE7", "出差"),*/
邛崃大厅人员请假("PROC-E1A4A56A-0EA7-43FE-A073-52E2B9C53E58", "邛崃大厅人员请假"),
邛崃大厅人员因公外出("PROC-034CE8B1-ED6D-492F-AC2C-61BAC5C0B4B9", "邛崃大厅人员因公外出"),
邛崃大厅人员补卡申请("PROC-16D29417-3049-4EB8-9710-9D39F9EDD1BD", "邛崃大厅人员补卡申请"),
/*
邛崃机关人员补卡申请("PROC-DDBEBB18-4FFC-486A-8E97-BAD7911BB9F2", "邛崃机关人员补卡申请"),
邛崃机关人员请假("PROC-7C84DFC5-579E-4500-9159-F38642E7238C", "邛崃机关人员请假"),
邛崃机关人员因公外出("PROC-6B46D143-4A05-4E9B-9C99-E0BD75A29003", "机关人员因公外出"),*/
;
private String value;
private String desc;
......
......@@ -82,7 +82,7 @@ public class StartedService implements IApplicationStartedService {
AttendanceLeaveRecordQuery query = new AttendanceLeaveRecordQuery();
query.setStartTimeStart(hikEntity.getAttendanceDateStart());
query.setEndTimeEnd(hikEntity.getAttendanceDateEnd());
// if (between > 120) return;
query.setStaffId(hikEntity.getStaffId());
new Thread(()->{
attendanceLeaveRecordService.syncLeaveRecord(query, null);
......@@ -105,18 +105,19 @@ public class StartedService implements IApplicationStartedService {
//deptService.syncDeptByDingTalk(null);
//staffService.syncPersonsByDingTalk(null);
/* String attendStart = "2025-02-01 00:00:00";
String attendStart = "2025-03-05";
String attendEnd = "2025-02-26 23:59:59";
String attendEnd = "2025-03-25";
AttendanceRecordHikQuery hikQuery = new AttendanceRecordHikQuery();
hikQuery.setAttendanceDateStart(attendStart);
hikQuery.setAttendanceDateEnd(attendEnd);
hikQuery.setStaffId(8L);
checkDingDingEvent(DateUtil.parseDateTime(attendStart), DateUtil.parseDateTime(attendEnd), hikQuery);
checkDingDingEvent(DateUtil.parseDate(attendStart), DateUtil.parseDate(attendEnd), hikQuery);
*/
// groupService.syncGroupByDingTalk();
//获取排班信息
......
......@@ -74,9 +74,9 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
} else if (AttendSourceTypeEnum.钉钉.getValue().equals(sourceType)) {
//钉钉
log.info("同步钉钉部门");
deptService.syncDeptByDingTalk(null);
//deptService.syncDeptByDingTalk(null);
//同步钉钉人员
staffService.syncPersonsByDingTalk(null);
//staffService.syncPersonsByDingTalk(null);
log.info("同步钉钉usreId");
syncDingDingLocalUserIds();
log.info("钉钉直连同步人员信息");
......
......@@ -738,7 +738,7 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
pageInfo.setPrePageResult(50);
List<String> userLists = staffService.find(new StaffQuery()).stream().map(i -> i.getWorkNum()).collect(Collectors.toList());
List<List<String>> partition = Lists.partition(userLists, 10);
List<List<String>> partition = Lists.partition(userLists, 20);
for (List<String> userList : partition) {
hikQuery.setAttendanceDateStart(DateUtil.parseDate(hikQuery.getAttendanceDateStart()).toString());
hikQuery.setAttendanceDateEnd(DateUtil.parseDate(hikQuery.getAttendanceDateEnd()).toString());
......
......@@ -30,6 +30,7 @@ import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService;
import com.taobao.api.ApiException;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -183,7 +184,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
// config.protocol = "http";
config.protocol = oaScheme;
config.regionId = "central";
config.endpoint = oaUrl;
// config.endpoint = oaUrl;
return config;
}
......@@ -215,16 +216,19 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
HashMap<String, String> map = new HashMap<>();
listProcessInstanceIdsHeaders.setCommonHeaders(map);
// log.info("oaUrl===>{}",oaUrl);
if (!ObjectUtils.isEmpty(oaUrl)) {
/* if (!ObjectUtils.isEmpty(oaUrl)) {
listProcessInstanceIdsHeaders.getCommonHeaders().put("host", oaUrl);
}
}*/
// listProcessInstanceIdsHeaders.getCommonHeaders().put("host", "172.15.28.113:8919");
com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsRequest listProcessInstanceIdsRequest = new ListProcessInstanceIdsRequest()
.setProcessCode(processCode)
.setStartTime(startTime)
.setEndTime(endTime)
.setNextToken(nextToken)
/* .setStartTime(startTime)
.setEndTime(endTime)
.setNextToken(nextToken)*/
.setStartTime(1742732000000L)
.setEndTime(1742918399000L)
.setNextToken(0L)
.setMaxResults(maxResults)
.setStatuses(Arrays.asList("COMPLETED"))
.setUserIds(java.util.Arrays.asList(userIds));
......@@ -232,14 +236,16 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
RuntimeOptions runtimeOptions = new RuntimeOptions();
runtimeOptions.setReadTimeout(60000);
runtimeOptions.setConnectTimeout(60000);
log.info("获取审批实例id列表请求参数:{}", JSON.toJSONString(listProcessInstanceIdsRequest));
ListProcessInstanceIdsResponse rsp = client.listProcessInstanceIdsWithOptions(listProcessInstanceIdsRequest, listProcessInstanceIdsHeaders, runtimeOptions);
if (!ObjectUtils.isEmpty(rsp.getBody()) &&
!ObjectUtils.isEmpty(rsp.getBody().getSuccess())&&
!ObjectUtils.isEmpty(rsp.getBody().getSuccess()) &&
rsp.getBody().getSuccess()) {
log.info("获取审批实例id列表成功->" + JSONObject.toJSONString(rsp.getBody().getResult()));
return Rest.ok(rsp.getBody().getResult());
} else {
// log.info("获取审批实例id列表失败->" + JSONObject.toJSONString(rsp));
// log.info("获取审批实例id列表失败->" + JSONObject.toJSONString(rsp));
return Rest.fail("查询失败:" + rsp.getBody().getSuccess());
}
} catch (Exception _err) {
......@@ -1048,4 +1054,63 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
}
}
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);
}
@SneakyThrows
public static void main(String[] args) {
com.aliyun.dingtalkworkflow_1_0.Client client = DingPersonServiceImpl.createClient();
com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsHeaders listProcessInstanceIdsHeaders = new com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsHeaders();
listProcessInstanceIdsHeaders.xAcsDingtalkAccessToken = "eae43460e6e83c10a643b361ba51eb1e";
com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsRequest listProcessInstanceIdsRequest = new com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsRequest()
.setProcessCode("PROC-E1A4A56A-0EA7-43FE-A073-52E2B9C53E58")
.setStartTime(1742732000000L)
.setEndTime(1742918399000L)
.setNextToken(0L)
.setMaxResults(10L)
.setUserIds(java.util.Arrays.asList(
"2850145256728859107"
)).setStatuses(java.util.Arrays.asList(
"COMPLETED"
));
;
try {
ListProcessInstanceIdsResponse response = client.listProcessInstanceIdsWithOptions(listProcessInstanceIdsRequest, listProcessInstanceIdsHeaders, new RuntimeOptions());
log.info("response: " + JSON.toJSONString(response));
//client = new com.aliyun.dingtalkworkflow_1_0.Client(setConfig());
com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders getProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders();
getProcessInstanceHeaders.xAcsDingtalkAccessToken = "eae43460e6e83c10a643b361ba51eb1e";
HashMap<String, String> map = new HashMap<>();
getProcessInstanceHeaders.setCommonHeaders(map);
com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest getProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest()
.setProcessInstanceId("ihHvEymxSbWVoK2YD3nAOw02121742817228");
log.info("processInstanceId:{}", "ihHvEymxSbWVoK2YD3nAOw02121742817228");
GetProcessInstanceResponse rsp = client.getProcessInstanceWithOptions(getProcessInstanceRequest, getProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
log.info("rsp: " + JSON.toJSONString(rsp));
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment