Browse Source

修复物计算1111

2025年7月14日16:33:01
qingyuan_dev_new
lishuai 6 months ago
parent
commit
b5a0f2ed3c
  1. 14
      modules/calculation/src/main/java/com/thing/calculation/handler/CalcExecuteHandler.java
  2. 14
      modules/calculation/src/main/java/com/thing/calculation/service/impl/CalcLogServiceImpl.java

14
modules/calculation/src/main/java/com/thing/calculation/handler/CalcExecuteHandler.java

@ -1,6 +1,7 @@
package com.thing.calculation.handler; package com.thing.calculation.handler;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.google.common.collect.Lists;
import com.thing.calculation.dto.CalcTargetConfigDTO; import com.thing.calculation.dto.CalcTargetConfigDTO;
import com.thing.calculation.dto.ExecuteCalcRequest; import com.thing.calculation.dto.ExecuteCalcRequest;
import com.thing.calculation.dto.LogSourceInfoValue; import com.thing.calculation.dto.LogSourceInfoValue;
@ -83,7 +84,7 @@ public class CalcExecuteHandler {
return; return;
} }
// 算出结果后批量推送 // 算出结果后批量推送
List<QueueProto.DataProto> protoList = new ArrayList<>();
// List<QueueProto.DataProto> protoList = new ArrayList<>();
// 遍历计算日志 // 遍历计算日志
for (CalcLogEntity log : logs) { for (CalcLogEntity log : logs) {
try { try {
@ -110,16 +111,17 @@ public class CalcExecuteHandler {
.setTs(log.getTime()) .setTs(log.getTime())
.setVal(log.getResult()) .setVal(log.getResult())
.build(); .build();
protoList.add(
QueueProto.DataProto.newBuilder().setTskvProto(tsKvProto).build());
// 批量推送
publisher.publishEvent(
new QueueConsumerEvent(Topics.V1_TSKV_HISTORY.getValue(), Lists.newArrayList(QueueProto.DataProto.newBuilder().setTskvProto(tsKvProto).build())));
// protoList.add(
// );
}catch (Exception e){ }catch (Exception e){
//计算异常 //计算异常
log.setStatus(CalcStatus.CALCULATE_EXCEPTION.getCode()); log.setStatus(CalcStatus.CALCULATE_EXCEPTION.getCode());
} }
} }
// 批量推送
publisher.publishEvent(
new QueueConsumerEvent(Topics.V1_TSKV_HISTORY.getValue(), protoList));
// 批量更新状态 // 批量更新状态
calcLogService.batchUpdate(logs); calcLogService.batchUpdate(logs);
} }

14
modules/calculation/src/main/java/com/thing/calculation/service/impl/CalcLogServiceImpl.java

@ -145,7 +145,7 @@ public class CalcLogServiceImpl extends BaseServiceImpl<CalcLogMapper, CalcLogEn
if (CollectionUtils.isEmpty(configIds)) { if (CollectionUtils.isEmpty(configIds)) {
return Collections.emptyList(); return Collections.emptyList();
} }
return mapper.selectListByQuery(
/* return mapper.selectListByQuery(
QueryWrapper.create() QueryWrapper.create()
.in(CalcLogEntity::getCalcTargetConfigId, configIds) .in(CalcLogEntity::getCalcTargetConfigId, configIds)
.ge(CalcLogEntity::getTime, startTs, Objects.nonNull(startTs)) .ge(CalcLogEntity::getTime, startTs, Objects.nonNull(startTs))
@ -155,7 +155,17 @@ public class CalcLogServiceImpl extends BaseServiceImpl<CalcLogMapper, CalcLogEn
.or(CALC_LOG_ENTITY .or(CALC_LOG_ENTITY
.STATUS .STATUS
.ne(CalcStatus.CALCULATE_EXCEPTION.getCode()) .ne(CalcStatus.CALCULATE_EXCEPTION.getCode())
.and(CALC_LOG_ENTITY.CALC_COUNT.le(MAX_CALC_COUNT))));
.and(CALC_LOG_ENTITY.CALC_COUNT.le(MAX_CALC_COUNT))));*/
List<CalcLogEntity> calcLogEntities = mapper.selectListByQuery(QueryWrapper.create()
.in(CalcLogEntity::getCalcTargetConfigId, configIds)
.ge(CalcLogEntity::getTime, startTs, Objects.nonNull(startTs))
.le(CalcLogEntity::getTime, endTs, Objects.nonNull(endTs))
// .eq(CalcLogEntity::getStatus, CalcStatus.UN_CALCULATED.getCode())
.ne(CalcLogEntity::getStatus, CalcStatus.CALCULATED.getCode())
.le(CalcLogEntity::getCalcCount,MAX_CALC_COUNT).orderBy(CalcLogEntity::getTime).asc());
return calcLogEntities;
} }
@Override @Override

Loading…
Cancel
Save