提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.point.service.impl; |
H |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
5 |
import com.iailab.module.data.api.dto.ApiPointValueQueryDTO; |
|
6 |
import com.iailab.module.data.point.dao.DaPointValueDao; |
|
7 |
import com.iailab.module.data.point.entity.DaPointValueEntity; |
|
8 |
import com.iailab.module.data.point.service.DaPointValueService; |
|
9 |
import org.apache.commons.lang3.ObjectUtils; |
|
10 |
import org.springframework.stereotype.Service; |
|
11 |
|
|
12 |
import java.math.BigDecimal; |
|
13 |
import java.util.*; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author PanZhibao |
|
17 |
* @Description |
|
18 |
* @createTime 2024年05月12日 |
|
19 |
*/ |
|
20 |
@Service |
|
21 |
public class DaPointValueServiceImpl extends BaseServiceImpl<DaPointValueDao, DaPointValueEntity> implements DaPointValueService { |
|
22 |
|
|
23 |
private String VALUE = "value"; |
|
24 |
|
|
25 |
private String TIME = "time"; |
|
26 |
|
|
27 |
@Override |
|
28 |
public void add(DaPointValueEntity entity) { |
|
29 |
entity.setId(UUID.randomUUID().toString()); |
|
30 |
baseDao.insert(entity); |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
public Map<String, List<Map<String, Object>>> getHistoryList(ApiPointValueQueryDTO queryDto) { |
|
35 |
Map<String, List<Map<String, Object>>> map = new HashMap<>(); |
|
36 |
List<DaPointValueEntity> daPointValueEntities; |
|
37 |
for(int i=0;i<queryDto.getPointNos().size();i++){ |
|
38 |
QueryWrapper<DaPointValueEntity> queryWrapper = new QueryWrapper<DaPointValueEntity>() |
|
39 |
.eq("point_no", queryDto.getPointNos().get(i)) |
|
40 |
.ge("data_time", queryDto.getStart()) |
|
41 |
.le("data_time", queryDto.getEnd()) |
|
42 |
.orderByAsc("data_time"); |
|
43 |
daPointValueEntities = baseDao.selectList(queryWrapper); |
|
44 |
List<Map<String, Object>> list = new ArrayList<>(); |
|
45 |
if(ObjectUtils.isNotEmpty(daPointValueEntities)) { |
|
46 |
daPointValueEntities.stream().forEach(daPointValueEntity -> { |
|
47 |
Map<String, Object> dataMap = new HashMap<>(); |
|
48 |
BigDecimal dataValue = daPointValueEntity.getDataValue(); |
|
49 |
Date dataTime = daPointValueEntity.getDataTime(); |
|
50 |
dataMap.put(VALUE, dataValue); |
|
51 |
dataMap.put(TIME, dataTime); |
|
52 |
list.add(dataMap); |
|
53 |
}); |
|
54 |
} |
|
55 |
map.put(queryDto.getPointNos().get(i),list); |
|
56 |
} |
|
57 |
return map; |
|
58 |
} |
|
59 |
} |