Commit 7d3ead7c by jinxin

分批次提交续期订单任务

parent 7d4dc912
......@@ -178,6 +178,7 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
*/
List<String> staffIdList = licenceOrderQDTO.getStaffIdList();
List<TabHaobanStaff> staffList = staffService.listStaffWithIds(staffIdList);
logger.info("需要续期的成员idList:{}",JSON.toJSONString(staffList));
List<InvalidUserInfoDTO> invalidUserInfoDTOList = new ArrayList<>();
String jobId = null;
if (CollUtil.isEmpty(staffList)){
......@@ -186,7 +187,6 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
Map<String, TabHaobanStaff> collect = staffList.stream().collect(Collectors.toMap(TabHaobanStaff::getWxUserId, a -> a));
List<AccountListQDTO> userIdList = new ArrayList<>();
List<List<AccountListQDTO>> userIds = new ArrayList<>();
for (int i = 0; i < staffList.size(); i++) {
if (staffList.get(i).getWxUserId() != null){
AccountListQDTO accountListQDTO = new AccountListQDTO();
......@@ -195,16 +195,18 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
accountListQDTO.setUserid(staffList.get(i).getWxUserId());
userIdList.add(accountListQDTO);
}
if ((i+1) % 1000 == 0) {
userIds.add(userIdList);
userIdList.clear();
}
}
if (CollectionUtils.isNotEmpty(userIdList)) {
userIds.add(userIdList);
userIdList.clear();
if (CollUtil.isEmpty(userIdList)){
return ServiceResponse.failure("-9999","续期成员的userId查询为空!");
}
for (List<AccountListQDTO> list : userIds){
//分批次处理 最多1000/次
int limit = 1000;
int size = userIdList.size();
int times = (size / limit + 1);
for (int i = 1; i <= times; i++) {
int from = (i - 1) * limit;
int to = Math.min(i * limit, size);
List<AccountListQDTO> list = userIdList.subList(from, to);
logger.info("续期成员个数{}", list.size());
ServiceResponse<CreateRenewOrderJobDTO> job = qywxOrderApiService.createRenewOrderJob(serviceCorpid, openCorpid, jobId, list);
logger.info("企业微信续期订单接口返回信息:{}",JSON.toJSONString(job));
......@@ -230,9 +232,11 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
}
}else {
logger.info("企业微信创建续期任务接口返回失败");
return ServiceResponse.failure("-9999","企业微信创建续期任务接口返回失败");
return ServiceResponse.failure(job.getCode(),job.getMessage());
}
}
//提交任务订单
orderQDTO.setJobId(jobId);
ServiceResponse<CreateOrderResponseDTO> submitOrderJob = qywxOrderApiService.submitOrderJob(serviceCorpid, openCorpid, orderQDTO);
......
......@@ -349,7 +349,12 @@
and a.expire_time is not null
</if>
</if>
<if test="null != startTime">
and a.expire_time <![CDATA[>=]]> #{startTime}
</if>
<if test="null != endTime">
and a.expire_time <![CDATA[<=]]> #{endTime}
</if>
<if test="departmentIds != null and departmentIds.size() > 0">
and b.department_id IN
<foreach collection="departmentIds" item="id" index="index" open="(" close=")" separator=",">
......
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