package com.iailab.module.data.point.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.module.data.api.dto.ApiPointValueQueryDTO; import com.iailab.module.data.point.dao.DaPointValueDao; import com.iailab.module.data.point.entity.DaPointValueEntity; import com.iailab.module.data.point.service.DaPointValueService; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.*; /** * @author PanZhibao * @Description * @createTime 2024年05月12日 */ @Service public class DaPointValueServiceImpl extends BaseServiceImpl implements DaPointValueService { private String VALUE = "value"; private String TIME = "time"; @Override public void add(DaPointValueEntity entity) { entity.setId(UUID.randomUUID().toString()); baseDao.insert(entity); } @Override public Map>> getHistoryList(ApiPointValueQueryDTO queryDto) { Map>> map = new HashMap<>(); List daPointValueEntities; for(int i=0;i queryWrapper = new QueryWrapper() .eq("point_no", queryDto.getPointNos().get(i)) .ge("data_time", queryDto.getStart()) .le("data_time", queryDto.getEnd()) .orderByAsc("data_time"); daPointValueEntities = baseDao.selectList(queryWrapper); List> list = new ArrayList<>(); if(ObjectUtils.isNotEmpty(daPointValueEntities)) { daPointValueEntities.stream().forEach(daPointValueEntity -> { Map dataMap = new HashMap<>(); BigDecimal dataValue = daPointValueEntity.getDataValue(); Date dataTime = daPointValueEntity.getDataTime(); dataMap.put(VALUE, dataValue); dataMap.put(TIME, dataTime); list.add(dataMap); }); } map.put(queryDto.getPointNos().get(i),list); } return map; } }