|
|
|
@ -50,9 +50,6 @@ import static cn.hutool.core.date.DatePattern.NORM_TIME_PATTERN;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* His run data service impl.
|
|
|
|
|
*
|
|
|
|
|
* @author chen.ma
|
|
|
|
|
* @date 2021/12/10 21:28
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@AllArgsConstructor
|
|
|
|
@ -69,7 +66,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
|
|
|
|
|
long startTime = dateTime.getTime();
|
|
|
|
|
|
|
|
|
|
List<HisRunDataInfo> hisRunDataInfos = this.lambdaQuery()
|
|
|
|
|
.eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId())
|
|
|
|
|
.eq(HisRunDataInfo::getItemId, reqDTO.getItemId())
|
|
|
|
@ -78,7 +74,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
.between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime())
|
|
|
|
|
.orderByAsc(HisRunDataInfo::getTimestamp)
|
|
|
|
|
.list();
|
|
|
|
|
|
|
|
|
|
return BeanUtil.convert(hisRunDataInfos, MonitorRespDTO.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -87,7 +82,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
|
|
|
|
|
long startTime = dateTime.getTime();
|
|
|
|
|
|
|
|
|
|
List<HisRunDataInfo> hisRunDataInfos = this.lambdaQuery()
|
|
|
|
|
.eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId())
|
|
|
|
|
.eq(HisRunDataInfo::getItemId, reqDTO.getItemId())
|
|
|
|
@ -96,7 +90,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
.between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime())
|
|
|
|
|
.orderByAsc(HisRunDataInfo::getTimestamp)
|
|
|
|
|
.list();
|
|
|
|
|
|
|
|
|
|
List<String> times = Lists.newArrayList();
|
|
|
|
|
List<Long> poolSizeList = Lists.newArrayList();
|
|
|
|
|
List<Long> activeSizeList = Lists.newArrayList();
|
|
|
|
@ -106,7 +99,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
List<Long> rejectCountList = Lists.newArrayList();
|
|
|
|
|
List<Long> queueRemainingCapacityList = Lists.newArrayList();
|
|
|
|
|
List<Long> currentLoadList = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
long countTemp = 0L;
|
|
|
|
|
AtomicBoolean firstFlag = new AtomicBoolean(Boolean.TRUE);
|
|
|
|
|
for (HisRunDataInfo each : hisRunDataInfos) {
|
|
|
|
@ -119,20 +111,17 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
queueRemainingCapacityList.add(each.getQueueRemainingCapacity());
|
|
|
|
|
currentLoadList.add(each.getCurrentLoad());
|
|
|
|
|
queueCapacityList.add(each.getQueueCapacity());
|
|
|
|
|
|
|
|
|
|
if (firstFlag.get()) {
|
|
|
|
|
completedTaskCountList.add(0L);
|
|
|
|
|
firstFlag.set(Boolean.FALSE);
|
|
|
|
|
countTemp = each.getCompletedTaskCount();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long completedTaskCount = each.getCompletedTaskCount();
|
|
|
|
|
long countTask = completedTaskCount - countTemp;
|
|
|
|
|
completedTaskCountList.add(countTask);
|
|
|
|
|
countTemp = each.getCompletedTaskCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new MonitorActiveRespDTO(times, poolSizeList, activeSizeList, queueSizeList, completedTaskCountList, rejectCountList, queueRemainingCapacityList, currentLoadList, queueCapacityList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -141,7 +130,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
|
|
|
|
|
long startTime = dateTime.getTime();
|
|
|
|
|
|
|
|
|
|
HisRunDataInfo hisRunDataInfo = this.lambdaQuery()
|
|
|
|
|
.eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId())
|
|
|
|
|
.eq(HisRunDataInfo::getItemId, reqDTO.getItemId())
|
|
|
|
@ -151,7 +139,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
.between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime())
|
|
|
|
|
.last("LIMIT 1")
|
|
|
|
|
.one();
|
|
|
|
|
|
|
|
|
|
return BeanUtil.convert(hisRunDataInfo, MonitorRespDTO.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -160,19 +147,15 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
public void save(Message message) {
|
|
|
|
|
List<RuntimeMessage> runtimeMessages = message.getMessages();
|
|
|
|
|
List<HisRunDataInfo> hisRunDataInfos = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
runtimeMessages.forEach(each -> {
|
|
|
|
|
HisRunDataInfo hisRunDataInfo = BeanUtil.convert(each, HisRunDataInfo.class);
|
|
|
|
|
String[] parseKey = GroupKey.parseKey(each.getGroupKey());
|
|
|
|
|
|
|
|
|
|
hisRunDataInfo.setTpId(parseKey[0]);
|
|
|
|
|
hisRunDataInfo.setItemId(parseKey[1]);
|
|
|
|
|
hisRunDataInfo.setTenantId(parseKey[2]);
|
|
|
|
|
hisRunDataInfo.setInstanceId(parseKey[3]);
|
|
|
|
|
|
|
|
|
|
hisRunDataInfos.add(hisRunDataInfo);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.saveBatch(hisRunDataInfos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -189,5 +172,4 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
|
|
|
|
|
}
|
|
|
|
|
return Results.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|