Commit a3c79af9 by “zcwang”

add: 定时任务执行

parent aa467044
......@@ -6,6 +6,7 @@
*/
package com.netease.mail.yanxuan.change.biz.task;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -17,12 +18,9 @@ import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.netease.mail.yanxuan.change.biz.biz.ChangeFlowBiz;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
import com.netease.mail.yanxuan.change.common.bean.CommonConstants;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.common.enums.ChangeFlowEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeStatusEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowOperationTypeEnum;
import com.netease.mail.yanxuan.change.common.util.DateUtils;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
......@@ -51,20 +49,28 @@ public class AutoSubmit extends IJobHandler {
@Override
public ReturnT<String> execute(String... strings) throws Exception {
log.info("AutoSubmit start");
// 查询今天时间之前的数据
long currentTime = DateUtils.getCurrentTime();
long startTime = DateUtils.getCurrentTime();
List<Long> count = new ArrayList<>();
Long entityId = 0L;
while (true) {
List<ChangeRecord> records = changeFlowService.getByStatusAndTime(entityId, ChangeFlowEnum.CHANGE_FLOW_EXE.getNodeId(),
ChangeFlowEnum.CHANGE_FLOW_CONFIRM.getNodeId(), currentTime);
if (CollectionUtils.isEmpty(records)) {
break;
// 查询今天时间之前的数据
try {
while (true) {
List<ChangeRecord> records = changeFlowService.getByStatusAndTime(entityId, ChangeFlowEnum.CHANGE_FLOW_EXE.getNodeId(),
ChangeFlowEnum.CHANGE_FLOW_CONFIRM.getNodeId(), startTime);
if (CollectionUtils.isEmpty(records)) {
break;
}
records.forEach(this::progressRecord);
List<Long> idList = records.stream().map(ChangeRecord::getId).collect(Collectors.toList());
entityId = idList.stream().max(Long::compare).get();
count.addAll(idList);
}
records.forEach(this::progressRecord);
List<Long> idList = records.stream().map(ChangeRecord::getId).collect(Collectors.toList());
entityId = idList.stream().max(Long::compare).get();
} catch (Exception e) {
log.error("error on AutoSubmit");
}
return null;
log.info(
"AutoSubmit end, count:{}, maxId:{}, usedTime:{}", count.size(), entityId, DateUtils.getCurrentTime() - startTime);
return ReturnT.SUCCESS;
}
private void progressRecord(ChangeRecord changeRecord) {
......
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