|
@@ -29,6 +29,7 @@ import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* 钉钉定时任务
|
|
|
+ *
|
|
|
* @author zcj
|
|
|
* @version 0.1
|
|
|
* @date 2020/1/10 2:28 下午
|
|
@@ -74,27 +75,29 @@ public class DingTalkScheduledTask {
|
|
|
* 每个小时定期更新出差申请数据
|
|
|
* 出差申请信息暂时不进行更新
|
|
|
*/
|
|
|
- @Scheduled(fixedDelay = 3600000L,initialDelay = 10000L)
|
|
|
+ @Scheduled(fixedDelay = 3600000L, initialDelay = 10000L)
|
|
|
void updateBusinessTripProcessInstanceIdList() throws ApiException {
|
|
|
updateProcessInstanceIdList(DingTalkConstant.PROCESS_CODE_BUSINESS_TRIP);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 每小时根据出差申请Id跟新出差申请信息。
|
|
|
* 出差申请信息暂时不进行更新
|
|
|
*/
|
|
|
- @Scheduled(fixedDelay = 3600000L,initialDelay = 10000L)
|
|
|
+ @Scheduled(fixedDelay = 3600000L, initialDelay = 10000L)
|
|
|
void updateProcessInstanceList() throws ApiException {
|
|
|
- updateChuanyunAskForLeave(DingTalkConstant.PROCESS_CODE_ASKFORLEAVE);
|
|
|
+ log.info("开始更新请假信息");
|
|
|
+ updateChuanyunAskForLeave(DingTalkConstant.PROCESS_CODE_ASKFORLEAVE);
|
|
|
+ log.info("请假信息更新完毕");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 业务招待申请更新
|
|
|
+ *
|
|
|
* @throws ApiException
|
|
|
*/
|
|
|
- @Scheduled(fixedDelay = 3600000L,initialDelay = 10000L)
|
|
|
+ @Scheduled(fixedDelay = 3600000L, initialDelay = 10000L)
|
|
|
void updateChuanyunBusinessEntertainmentProcessInstanceList() throws ApiException {
|
|
|
updateChuanyunBusinessEntertainment(DingTalkConstant.PROCESS_CODE_BUSINESSENTERTAINMENT);
|
|
|
}
|
|
@@ -102,26 +105,26 @@ public class DingTalkScheduledTask {
|
|
|
/**
|
|
|
* 每个小时定期更新项目实施变更申请数据
|
|
|
*/
|
|
|
- @Scheduled(fixedDelay = 3600000L,initialDelay = 10000L)
|
|
|
+ @Scheduled(fixedDelay = 3600000L, initialDelay = 10000L)
|
|
|
void updateProjectChangeProcessInstanceIdList() throws ApiException {
|
|
|
updateChuanyunProjectChangeProcessInstanceIdList(DingTalkConstant.PROCESS_CODE_PROJECT_CHANGE);
|
|
|
}
|
|
|
|
|
|
|
|
|
private void updateChuanyunBusinessEntertainment(String businessTripProcessCode) throws ApiException {
|
|
|
- var flag=true;
|
|
|
+ var flag = true;
|
|
|
//单个请求
|
|
|
- var oApiProcessInstanceListIdsRequest=new OapiProcessinstanceListidsRequest();
|
|
|
+ var oApiProcessInstanceListIdsRequest = new OapiProcessinstanceListidsRequest();
|
|
|
oApiProcessInstanceListIdsRequest.setProcessCode(businessTripProcessCode);
|
|
|
oApiProcessInstanceListIdsRequest.setStartTime(LocalDateTime.now().minusDays(90).toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
oApiProcessInstanceListIdsRequest.setEndTime(LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
oApiProcessInstanceListIdsRequest.setCursor(0L);
|
|
|
oApiProcessInstanceListIdsRequest.setSize(20L);
|
|
|
- while(flag){
|
|
|
- LocalDateTime start=LocalDateTime.now();
|
|
|
- OapiProcessinstanceListidsResponse oapiProcessinstanceListidsResponse=processInstanceListIdsClient.execute(oApiProcessInstanceListIdsRequest,DingTalkConstant.DING_TALK_TOKEN);
|
|
|
- List<ChuanyunBusinessEntertainmentDO> chuanyunBusinessEntertainmentDOS=new ArrayList<>();
|
|
|
- if(oapiProcessinstanceListidsResponse.getErrcode()!=0){
|
|
|
+ while (flag) {
|
|
|
+ LocalDateTime start = LocalDateTime.now();
|
|
|
+ OapiProcessinstanceListidsResponse oapiProcessinstanceListidsResponse = processInstanceListIdsClient.execute(oApiProcessInstanceListIdsRequest, DingTalkConstant.DING_TALK_TOKEN);
|
|
|
+ List<ChuanyunBusinessEntertainmentDO> chuanyunBusinessEntertainmentDOS = new ArrayList<>();
|
|
|
+ if (oapiProcessinstanceListidsResponse.getErrcode() != 0) {
|
|
|
log.info(oapiProcessinstanceListidsResponse.getErrmsg());
|
|
|
try {
|
|
|
Thread.sleep(5000);
|
|
@@ -131,10 +134,10 @@ public class DingTalkScheduledTask {
|
|
|
continue;
|
|
|
}
|
|
|
//逐个请求
|
|
|
- oapiProcessinstanceListidsResponse.getResult().getList().forEach(resultId->{
|
|
|
- Optional<DingTalkProcessInstance> instance=dingTalkProcessInstanceDao.findById(resultId);
|
|
|
- if(instance.isEmpty()){
|
|
|
- OapiProcessinstanceGetRequest request=new OapiProcessinstanceGetRequest();
|
|
|
+ oapiProcessinstanceListidsResponse.getResult().getList().forEach(resultId -> {
|
|
|
+ Optional<DingTalkProcessInstance> instance = dingTalkProcessInstanceDao.findById(resultId);
|
|
|
+ if (instance.isEmpty()) {
|
|
|
+ OapiProcessinstanceGetRequest request = new OapiProcessinstanceGetRequest();
|
|
|
request.setProcessInstanceId(resultId);
|
|
|
try {
|
|
|
OapiProcessinstanceGetResponse oapiProcessinstanceGetResponse = processInstanceClient.execute(request, DingTalkConstant.DING_TALK_TOKEN);
|
|
@@ -143,7 +146,7 @@ public class DingTalkScheduledTask {
|
|
|
chuanyunBusinessEntertainmentDO.setBusinessId(oapiProcessinstanceGetResponse.getProcessInstance().getBusinessId());
|
|
|
chuanyunBusinessEntertainmentDO.setObjectId(UUID.randomUUID().toString());
|
|
|
ChuanyunBusinessEntertainmentDO oldChuanyunBusinessEntertainmentDO = chuanyunBusinessEntertainmentDao.findByBusinessId(oapiProcessinstanceGetResponse.getProcessInstance().getBusinessId());
|
|
|
- if(oldChuanyunBusinessEntertainmentDO != null ) {
|
|
|
+ if (oldChuanyunBusinessEntertainmentDO != null) {
|
|
|
chuanyunBusinessEntertainmentDao.deleteById(oldChuanyunBusinessEntertainmentDO.getObjectId());
|
|
|
}
|
|
|
chuanyunBusinessEntertainmentDOS.add(chuanyunBusinessEntertainmentDO);
|
|
@@ -155,80 +158,80 @@ public class DingTalkScheduledTask {
|
|
|
|
|
|
//保存id列表和实例列表,如果有更新的内容
|
|
|
chuanyunBusinessEntertainmentDao.saveAll(chuanyunBusinessEntertainmentDOS);
|
|
|
- log.info(businessTripProcessCode+"下一个cursor为"+oapiProcessinstanceListidsResponse.getResult().getNextCursor()+"保存成功"+"耗时"+ ChronoUnit.SECONDS.between(start,LocalDateTime.now())+"秒");
|
|
|
- flag=null!=oapiProcessinstanceListidsResponse.getResult().getNextCursor();
|
|
|
- if (flag){
|
|
|
+ log.info(businessTripProcessCode + "下一个cursor为" + oapiProcessinstanceListidsResponse.getResult().getNextCursor() + "保存成功" + "耗时" + ChronoUnit.SECONDS.between(start, LocalDateTime.now()) + "秒");
|
|
|
+ flag = null != oapiProcessinstanceListidsResponse.getResult().getNextCursor();
|
|
|
+ if (flag) {
|
|
|
oApiProcessInstanceListIdsRequest.setCursor(oapiProcessinstanceListidsResponse.getResult().getNextCursor());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void updateChuanyunAskForLeave(String businessTripProcessCode) throws ApiException {
|
|
|
- var flag=true;
|
|
|
- //单个请求
|
|
|
- var oApiProcessInstanceListIdsRequest=new OapiProcessinstanceListidsRequest();
|
|
|
- oApiProcessInstanceListIdsRequest.setProcessCode(businessTripProcessCode);
|
|
|
- oApiProcessInstanceListIdsRequest.setStartTime(LocalDateTime.now().minusDays(90).toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
- oApiProcessInstanceListIdsRequest.setEndTime(LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
- oApiProcessInstanceListIdsRequest.setCursor(0L);
|
|
|
- oApiProcessInstanceListIdsRequest.setSize(20L);
|
|
|
- while(flag){
|
|
|
- LocalDateTime start=LocalDateTime.now();
|
|
|
- OapiProcessinstanceListidsResponse oapiProcessinstanceListidsResponse=processInstanceListIdsClient.execute(oApiProcessInstanceListIdsRequest,DingTalkConstant.DING_TALK_TOKEN);
|
|
|
- List<ChuanyunAskForLeaveDO> chuanyunAskForLeaveDoList=new ArrayList<>();
|
|
|
- if(oapiProcessinstanceListidsResponse.getErrcode()!=0){
|
|
|
- log.info(oapiProcessinstanceListidsResponse.getErrmsg());
|
|
|
- try {
|
|
|
- Thread.sleep(5000);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- log.error(e.getMessage());
|
|
|
- }
|
|
|
- continue;
|
|
|
+ var flag = true;
|
|
|
+ //单个请求
|
|
|
+ var oApiProcessInstanceListIdsRequest = new OapiProcessinstanceListidsRequest();
|
|
|
+ oApiProcessInstanceListIdsRequest.setProcessCode(businessTripProcessCode);
|
|
|
+ oApiProcessInstanceListIdsRequest.setStartTime(LocalDateTime.now().minusDays(90).toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
+ oApiProcessInstanceListIdsRequest.setEndTime(LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
+ oApiProcessInstanceListIdsRequest.setCursor(0L);
|
|
|
+ oApiProcessInstanceListIdsRequest.setSize(20L);
|
|
|
+ while (flag) {
|
|
|
+ LocalDateTime start = LocalDateTime.now();
|
|
|
+ OapiProcessinstanceListidsResponse oapiProcessinstanceListidsResponse = processInstanceListIdsClient.execute(oApiProcessInstanceListIdsRequest, DingTalkConstant.DING_TALK_TOKEN);
|
|
|
+ List<ChuanyunAskForLeaveDO> chuanyunAskForLeaveDoList = new ArrayList<>();
|
|
|
+ if (oapiProcessinstanceListidsResponse.getErrcode() != 0) {
|
|
|
+ log.info(oapiProcessinstanceListidsResponse.getErrmsg());
|
|
|
+ try {
|
|
|
+ Thread.sleep(5000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
|
- //逐个请求
|
|
|
- oapiProcessinstanceListidsResponse.getResult().getList().forEach(resultId->{
|
|
|
- Optional<DingTalkProcessInstance> instance=dingTalkProcessInstanceDao.findById(resultId);
|
|
|
- if(instance.isEmpty()){
|
|
|
- OapiProcessinstanceGetRequest request=new OapiProcessinstanceGetRequest();
|
|
|
- request.setProcessInstanceId(resultId);
|
|
|
- try {
|
|
|
- OapiProcessinstanceGetResponse oapiProcessinstanceGetResponse = processInstanceClient.execute(request, DingTalkConstant.DING_TALK_TOKEN);
|
|
|
- ChuanyunAskForLeaveDO chuanyunAskForLeaveDo = ChuanyunAskForLeaveDO.fromAskForLeaveDTO(oapiProcessinstanceGetResponse.getProcessInstance());
|
|
|
- List<ChuanyunAskForLeaveDO> existsAskForLeave = chuanyunAskForLeaveDao.findByTitleSQL(chuanyunAskForLeaveDo.getTitle());
|
|
|
- if(existsAskForLeave != null && !existsAskForLeave.isEmpty()) {
|
|
|
- chuanyunAskForLeaveDao.deleteById(existsAskForLeave.get(0).getObjectId());
|
|
|
- }
|
|
|
- chuanyunAskForLeaveDoList.add(chuanyunAskForLeaveDo);
|
|
|
- } catch (ApiException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //逐个请求
|
|
|
+ oapiProcessinstanceListidsResponse.getResult().getList().forEach(resultId -> {
|
|
|
+ Optional<DingTalkProcessInstance> instance = dingTalkProcessInstanceDao.findById(resultId);
|
|
|
+ if (instance.isEmpty()) {
|
|
|
+ OapiProcessinstanceGetRequest request = new OapiProcessinstanceGetRequest();
|
|
|
+ request.setProcessInstanceId(resultId);
|
|
|
+ try {
|
|
|
+ OapiProcessinstanceGetResponse oapiProcessinstanceGetResponse = processInstanceClient.execute(request, DingTalkConstant.DING_TALK_TOKEN);
|
|
|
+ ChuanyunAskForLeaveDO chuanyunAskForLeaveDo = ChuanyunAskForLeaveDO.fromAskForLeaveDTO(oapiProcessinstanceGetResponse.getProcessInstance());
|
|
|
+ List<ChuanyunAskForLeaveDO> existsAskForLeave = chuanyunAskForLeaveDao.findByTitleSQL(chuanyunAskForLeaveDo.getTitle());
|
|
|
+ if (existsAskForLeave != null && !existsAskForLeave.isEmpty()) {
|
|
|
+ chuanyunAskForLeaveDao.deleteById(existsAskForLeave.get(0).getObjectId());
|
|
|
}
|
|
|
+ chuanyunAskForLeaveDoList.add(chuanyunAskForLeaveDo);
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- //保存id列表和实例列表,如果有更新的内容
|
|
|
- chuanyunAskForLeaveDao.saveAll(chuanyunAskForLeaveDoList);
|
|
|
- log.info(businessTripProcessCode+"下一个cursor为"+oapiProcessinstanceListidsResponse.getResult().getNextCursor()+"保存成功"+"耗时"+ ChronoUnit.SECONDS.between(start,LocalDateTime.now())+"秒");
|
|
|
- flag=null!=oapiProcessinstanceListidsResponse.getResult().getNextCursor();
|
|
|
- if (flag){
|
|
|
- oApiProcessInstanceListIdsRequest.setCursor(oapiProcessinstanceListidsResponse.getResult().getNextCursor());
|
|
|
}
|
|
|
+ });
|
|
|
+
|
|
|
+ //保存id列表和实例列表,如果有更新的内容
|
|
|
+ chuanyunAskForLeaveDao.saveAll(chuanyunAskForLeaveDoList);
|
|
|
+ log.info(businessTripProcessCode + "下一个cursor为" + oapiProcessinstanceListidsResponse.getResult().getNextCursor() + "保存成功" + "耗时" + ChronoUnit.SECONDS.between(start, LocalDateTime.now()) + "秒");
|
|
|
+ flag = null != oapiProcessinstanceListidsResponse.getResult().getNextCursor();
|
|
|
+ if (flag) {
|
|
|
+ oApiProcessInstanceListIdsRequest.setCursor(oapiProcessinstanceListidsResponse.getResult().getNextCursor());
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void updateProcessInstanceIdList(String businessTripProcessCode) throws ApiException {
|
|
|
- var flag=true;
|
|
|
+ var flag = true;
|
|
|
//单个请求
|
|
|
- var oApiProcessInstanceListIdsRequest=new OapiProcessinstanceListidsRequest();
|
|
|
+ var oApiProcessInstanceListIdsRequest = new OapiProcessinstanceListidsRequest();
|
|
|
oApiProcessInstanceListIdsRequest.setProcessCode(businessTripProcessCode);
|
|
|
oApiProcessInstanceListIdsRequest.setStartTime(LocalDateTime.now().minusDays(90).toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
oApiProcessInstanceListIdsRequest.setEndTime(LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
oApiProcessInstanceListIdsRequest.setCursor(0L);
|
|
|
oApiProcessInstanceListIdsRequest.setSize(20L);
|
|
|
- while(flag){
|
|
|
- LocalDateTime start=LocalDateTime.now();
|
|
|
- OapiProcessinstanceListidsResponse oapiProcessinstanceListidsResponse=processInstanceListIdsClient.execute(oApiProcessInstanceListIdsRequest,DingTalkConstant.DING_TALK_TOKEN);
|
|
|
- List<DingTalkProcessInstance> dingTalkProcessInstanceList=new ArrayList<>();
|
|
|
- if(oapiProcessinstanceListidsResponse.getErrcode()!=0){
|
|
|
+ while (flag) {
|
|
|
+ LocalDateTime start = LocalDateTime.now();
|
|
|
+ OapiProcessinstanceListidsResponse oapiProcessinstanceListidsResponse = processInstanceListIdsClient.execute(oApiProcessInstanceListIdsRequest, DingTalkConstant.DING_TALK_TOKEN);
|
|
|
+ List<DingTalkProcessInstance> dingTalkProcessInstanceList = new ArrayList<>();
|
|
|
+ if (oapiProcessinstanceListidsResponse.getErrcode() != 0) {
|
|
|
log.info(oapiProcessinstanceListidsResponse.getErrmsg());
|
|
|
try {
|
|
|
Thread.sleep(5000);
|
|
@@ -238,14 +241,14 @@ public class DingTalkScheduledTask {
|
|
|
continue;
|
|
|
}
|
|
|
//逐个请求
|
|
|
- oapiProcessinstanceListidsResponse.getResult().getList().forEach(resultId->{
|
|
|
- Optional<DingTalkProcessInstance> instance=dingTalkProcessInstanceDao.findById(resultId);
|
|
|
- if(instance.isEmpty()){
|
|
|
+ oapiProcessinstanceListidsResponse.getResult().getList().forEach(resultId -> {
|
|
|
+ Optional<DingTalkProcessInstance> instance = dingTalkProcessInstanceDao.findById(resultId);
|
|
|
+ if (instance.isEmpty()) {
|
|
|
//&&instance.get()==null
|
|
|
//淘宝SDK方法
|
|
|
- OapiProcessinstanceGetRequest request=new OapiProcessinstanceGetRequest();
|
|
|
+ OapiProcessinstanceGetRequest request = new OapiProcessinstanceGetRequest();
|
|
|
request.setProcessInstanceId(resultId);
|
|
|
- DingTalkProcessInstance dingTalkProcessInstance=new DingTalkProcessInstance(resultId,businessTripProcessCode);
|
|
|
+ DingTalkProcessInstance dingTalkProcessInstance = new DingTalkProcessInstance(resultId, businessTripProcessCode);
|
|
|
try {
|
|
|
OapiProcessinstanceGetResponse oapiProcessinstanceGetResponse = processInstanceClient.execute(request, DingTalkConstant.DING_TALK_TOKEN);
|
|
|
dingTalkProcessInstance.setProcessInstance(oapiProcessinstanceGetResponse.getProcessInstance());
|
|
@@ -259,28 +262,28 @@ public class DingTalkScheduledTask {
|
|
|
|
|
|
//保存id列表和实例列表
|
|
|
dingTalkProcessInstanceDao.saveAll(dingTalkProcessInstanceList);
|
|
|
- log.info(businessTripProcessCode+"下一个cursor为"+oapiProcessinstanceListidsResponse.getResult().getNextCursor()+"保存成功"+"耗时"+ ChronoUnit.SECONDS.between(start,LocalDateTime.now())+"秒");
|
|
|
- flag=null!=oapiProcessinstanceListidsResponse.getResult().getNextCursor();
|
|
|
- if (flag){
|
|
|
+ log.info(businessTripProcessCode + "下一个cursor为" + oapiProcessinstanceListidsResponse.getResult().getNextCursor() + "保存成功" + "耗时" + ChronoUnit.SECONDS.between(start, LocalDateTime.now()) + "秒");
|
|
|
+ flag = null != oapiProcessinstanceListidsResponse.getResult().getNextCursor();
|
|
|
+ if (flag) {
|
|
|
oApiProcessInstanceListIdsRequest.setCursor(oapiProcessinstanceListidsResponse.getResult().getNextCursor());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void updateChuanyunProjectChangeProcessInstanceIdList(String businessTripProcessCode) throws ApiException {
|
|
|
- var flag=true;
|
|
|
+ var flag = true;
|
|
|
//单个请求
|
|
|
- var oApiProcessInstanceListIdsRequest=new OapiProcessinstanceListidsRequest();
|
|
|
+ var oApiProcessInstanceListIdsRequest = new OapiProcessinstanceListidsRequest();
|
|
|
oApiProcessInstanceListIdsRequest.setProcessCode(businessTripProcessCode);
|
|
|
oApiProcessInstanceListIdsRequest.setStartTime(LocalDateTime.now().minusDays(90).toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
oApiProcessInstanceListIdsRequest.setEndTime(LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli());
|
|
|
oApiProcessInstanceListIdsRequest.setCursor(0L);
|
|
|
oApiProcessInstanceListIdsRequest.setSize(20L);
|
|
|
- while(flag){
|
|
|
- LocalDateTime start=LocalDateTime.now();
|
|
|
- OapiProcessinstanceListidsResponse oapiProcessinstanceListidsResponse=processInstanceListIdsClient.execute(oApiProcessInstanceListIdsRequest,DingTalkConstant.DING_TALK_TOKEN);
|
|
|
- List<ChuanyunProjectChangeDO> chuanyunProjectChangeDOList=new ArrayList<>();
|
|
|
- if(oapiProcessinstanceListidsResponse.getErrcode()!=0){
|
|
|
+ while (flag) {
|
|
|
+ LocalDateTime start = LocalDateTime.now();
|
|
|
+ OapiProcessinstanceListidsResponse oapiProcessinstanceListidsResponse = processInstanceListIdsClient.execute(oApiProcessInstanceListIdsRequest, DingTalkConstant.DING_TALK_TOKEN);
|
|
|
+ List<ChuanyunProjectChangeDO> chuanyunProjectChangeDOList = new ArrayList<>();
|
|
|
+ if (oapiProcessinstanceListidsResponse.getErrcode() != 0) {
|
|
|
log.info(oapiProcessinstanceListidsResponse.getErrmsg());
|
|
|
try {
|
|
|
Thread.sleep(5000);
|
|
@@ -290,18 +293,18 @@ public class DingTalkScheduledTask {
|
|
|
continue;
|
|
|
}
|
|
|
//逐个请求
|
|
|
- oapiProcessinstanceListidsResponse.getResult().getList().forEach(resultId->{
|
|
|
- Optional<DingTalkProcessInstance> instance=dingTalkProcessInstanceDao.findById(resultId);
|
|
|
- if(instance.isEmpty()){
|
|
|
+ oapiProcessinstanceListidsResponse.getResult().getList().forEach(resultId -> {
|
|
|
+ Optional<DingTalkProcessInstance> instance = dingTalkProcessInstanceDao.findById(resultId);
|
|
|
+ if (instance.isEmpty()) {
|
|
|
//&&instance.get()==null
|
|
|
//淘宝SDK方法
|
|
|
- OapiProcessinstanceGetRequest request=new OapiProcessinstanceGetRequest();
|
|
|
+ OapiProcessinstanceGetRequest request = new OapiProcessinstanceGetRequest();
|
|
|
request.setProcessInstanceId(resultId);
|
|
|
try {
|
|
|
OapiProcessinstanceGetResponse oapiProcessinstanceGetResponse = processInstanceClient.execute(request, DingTalkConstant.DING_TALK_TOKEN);
|
|
|
ChuanyunProjectChangeDO chuanyunProjectChangeDO = ChuanyunProjectChangeDO.fromProjectChangeDTO(oapiProcessinstanceGetResponse.getProcessInstance());
|
|
|
- List<ChuanyunProjectChangeDO> existsProjectChange = chuanyunProjectChangeDao.findByTitleSQL(chuanyunProjectChangeDO.getTitle());
|
|
|
- if(existsProjectChange != null && !existsProjectChange.isEmpty()) {
|
|
|
+ List<ChuanyunProjectChangeDO> existsProjectChange = chuanyunProjectChangeDao.findByTitleSQL(chuanyunProjectChangeDO.getTitle());
|
|
|
+ if (existsProjectChange != null && !existsProjectChange.isEmpty()) {
|
|
|
chuanyunProjectChangeDao.deleteById(existsProjectChange.get(0).getObjectId());
|
|
|
}
|
|
|
chuanyunProjectChangeDOList.add(chuanyunProjectChangeDO);
|
|
@@ -313,9 +316,9 @@ public class DingTalkScheduledTask {
|
|
|
|
|
|
//保存id列表和实例列表
|
|
|
chuanyunProjectChangeDao.saveAll(chuanyunProjectChangeDOList);
|
|
|
- log.info(businessTripProcessCode+"下一个cursor为"+oapiProcessinstanceListidsResponse.getResult().getNextCursor()+"保存成功"+"耗时"+ ChronoUnit.SECONDS.between(start,LocalDateTime.now())+"秒");
|
|
|
- flag=null!=oapiProcessinstanceListidsResponse.getResult().getNextCursor();
|
|
|
- if (flag){
|
|
|
+ log.info(businessTripProcessCode + "下一个cursor为" + oapiProcessinstanceListidsResponse.getResult().getNextCursor() + "保存成功" + "耗时" + ChronoUnit.SECONDS.between(start, LocalDateTime.now()) + "秒");
|
|
|
+ flag = null != oapiProcessinstanceListidsResponse.getResult().getNextCursor();
|
|
|
+ if (flag) {
|
|
|
oApiProcessInstanceListIdsRequest.setCursor(oapiProcessinstanceListidsResponse.getResult().getNextCursor());
|
|
|
}
|
|
|
}
|