|
|
@ -20,6 +20,7 @@ import com.thing.common.core.web.response.Result; |
|
|
import com.thing.common.data.tskv.TsKvDTO; |
|
|
import com.thing.common.data.tskv.TsKvDTO; |
|
|
import com.thing.common.tskv.event.TsKvEvent; |
|
|
import com.thing.common.tskv.event.TsKvEvent; |
|
|
import com.thing.common.tskv.service.TsKvService; |
|
|
import com.thing.common.tskv.service.TsKvService; |
|
|
|
|
|
import com.thing.common.tskv.service.tskv.TsKvBaseService; |
|
|
import com.thing.queue.util.Topics; |
|
|
import com.thing.queue.util.Topics; |
|
|
import jakarta.annotation.Resource; |
|
|
import jakarta.annotation.Resource; |
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
@ -35,7 +36,6 @@ import java.math.BigDecimal; |
|
|
import java.text.DecimalFormat; |
|
|
import java.text.DecimalFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @author zhenghh. 2022-09-15 |
|
|
* @author zhenghh. 2022-09-15 |
|
|
@ -48,6 +48,9 @@ public class TsKvHandleServiceImpl implements TsKvHandleService { |
|
|
private TsKvService tsKvService; |
|
|
private TsKvService tsKvService; |
|
|
@Resource |
|
|
@Resource |
|
|
private ApplicationEventPublisher publisher; |
|
|
private ApplicationEventPublisher publisher; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private TsKvBaseService tsKvBaseService; |
|
|
/** |
|
|
/** |
|
|
* 分页查询 |
|
|
* 分页查询 |
|
|
* |
|
|
* |
|
|
@ -72,6 +75,41 @@ public class TsKvHandleServiceImpl implements TsKvHandleService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<TsKvDTO> list(Map<String, Object> params) { |
|
|
|
|
|
List<String> thingCodeList = MapUtil.get(params, "thingCodeList", List.class); |
|
|
|
|
|
List<String> atterList = MapUtil.get(params, "thingAttrList", List.class); |
|
|
|
|
|
Long startTime = MapUtil.getLong(params, "beginTime"); |
|
|
|
|
|
Long endTime = MapUtil.getLong(params, "endTime"); |
|
|
|
|
|
if (StringUtils.isNotBlank((String) params.get("beginTime"))) { |
|
|
|
|
|
List<TsKvDTO> list = tsKvService.findOriginalTsKvByCodesAndAttrs(thingCodeList, atterList, startTime, endTime, Boolean.FALSE); |
|
|
|
|
|
if(!CollectionUtils.isEmpty(list)) { |
|
|
|
|
|
return list.stream().filter(s-> |
|
|
|
|
|
!s.getAttrKey().endsWith("am") |
|
|
|
|
|
&& !s.getAttrKey().endsWith("hh") |
|
|
|
|
|
&& !s.getAttrKey().endsWith("dd") |
|
|
|
|
|
&& !s.getAttrKey().endsWith("mm") |
|
|
|
|
|
&& !s.getAttrKey().endsWith("yy")).toList(); |
|
|
|
|
|
} |
|
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
|
} else { |
|
|
|
|
|
Map<String, Collection<String>> queryMap = new HashMap<>(); |
|
|
|
|
|
if (thingCodeList != null) { |
|
|
|
|
|
thingCodeList.forEach(temp -> queryMap.put(temp, atterList)); |
|
|
|
|
|
} |
|
|
|
|
|
List<TsKvDTO> list = tsKvService.findOriginalTsKvByMultiMap(queryMap, startTime, endTime, Boolean.FALSE); |
|
|
|
|
|
if(!CollectionUtils.isEmpty(list)) { |
|
|
|
|
|
return list.stream().filter(s-> |
|
|
|
|
|
!s.getAttrKey().endsWith("am") |
|
|
|
|
|
&& !s.getAttrKey().endsWith("hh") |
|
|
|
|
|
&& !s.getAttrKey().endsWith("dd") |
|
|
|
|
|
&& !s.getAttrKey().endsWith("mm") |
|
|
|
|
|
&& !s.getAttrKey().endsWith("yy")).toList(); |
|
|
|
|
|
} |
|
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public CacheTsKvDTO get(String thingCode, String key, Long ts) { |
|
|
public CacheTsKvDTO get(String thingCode, String key, Long ts) { |
|
|
List<TsKvDTO> tsKvByCodeAndAttr = tsKvService.findTsKvByCodeAndAttr(thingCode, key, ts, ts, false); |
|
|
List<TsKvDTO> tsKvByCodeAndAttr = tsKvService.findTsKvByCodeAndAttr(thingCode, key, ts, ts, false); |
|
|
|