提交 | 用户 | 时间
|
b368e6
|
1 |
package com.iailab.module.model.mcs.pre.service.impl; |
潘 |
2 |
|
|
3 |
import com.alibaba.fastjson.JSONArray; |
|
4 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
5 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
977edc
|
6 |
import com.iailab.framework.common.util.date.DateUtils; |
b368e6
|
7 |
import com.iailab.module.model.mcs.pre.dao.MmItemResultJsonDao; |
潘 |
8 |
import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; |
|
9 |
import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService; |
|
10 |
import org.apache.commons.lang3.StringUtils; |
|
11 |
import org.springframework.stereotype.Service; |
91343d
|
12 |
import org.springframework.util.CollectionUtils; |
b368e6
|
13 |
|
ca56f2
|
14 |
import java.math.BigDecimal; |
1c9291
|
15 |
import java.util.*; |
b368e6
|
16 |
|
潘 |
17 |
/** |
|
18 |
* @author PanZhibao |
|
19 |
* @Description |
|
20 |
* @createTime 2024年11月14日 |
|
21 |
*/ |
|
22 |
@Service |
|
23 |
public class MmItemResultJsonServiceImpl extends BaseServiceImpl<MmItemResultJsonDao, MmItemResultJsonEntity> |
|
24 |
implements MmItemResultJsonService { |
|
25 |
|
|
26 |
@Override |
977edc
|
27 |
public List<Object[]> getData(String outputId, Date predictTime, String timeFormat) { |
b368e6
|
28 |
List<Object[]> result = new ArrayList<>(); |
潘 |
29 |
QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>(); |
|
30 |
wrapper.eq("outputid", outputId) |
c73c87
|
31 |
.eq("predicttime", DateUtils.format(predictTime,timeFormat)); |
b368e6
|
32 |
MmItemResultJsonEntity data = baseDao.selectOne(wrapper); |
潘 |
33 |
if (data == null || StringUtils.isBlank(data.getJsonvalue())) { |
|
34 |
return result; |
|
35 |
} |
91343d
|
36 |
List<Double> valueList = JSONArray.parseArray(data.getJsonvalue(), Double.class); |
潘 |
37 |
if (CollectionUtils.isEmpty(valueList)) { |
|
38 |
return result; |
|
39 |
} |
|
40 |
Calendar calendar = Calendar.getInstance(); |
|
41 |
calendar.setTime(predictTime); |
|
42 |
valueList.forEach(value -> { |
977edc
|
43 |
Object[] dv = {DateUtils.format(calendar.getTime(), timeFormat), value}; |
91343d
|
44 |
calendar.add(Calendar.MINUTE, 1); |
潘 |
45 |
result.add(dv); |
b368e6
|
46 |
}); |
潘 |
47 |
return result; |
|
48 |
} |
c4b37d
|
49 |
|
D |
50 |
@Override |
ca56f2
|
51 |
public List<Object[]> getData(String outputId, Date predictTime, String timeFormat, int scale) { |
潘 |
52 |
List<Object[]> result = new ArrayList<>(); |
|
53 |
QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>(); |
|
54 |
wrapper.eq("outputid", outputId) |
|
55 |
.eq("predicttime", DateUtils.format(predictTime,timeFormat)); |
|
56 |
MmItemResultJsonEntity data = baseDao.selectOne(wrapper); |
|
57 |
if (data == null || StringUtils.isBlank(data.getJsonvalue())) { |
|
58 |
return result; |
|
59 |
} |
|
60 |
List<Double> valueList = JSONArray.parseArray(data.getJsonvalue(), Double.class); |
|
61 |
if (CollectionUtils.isEmpty(valueList)) { |
|
62 |
return result; |
|
63 |
} |
|
64 |
Calendar calendar = Calendar.getInstance(); |
|
65 |
calendar.setTime(predictTime); |
|
66 |
valueList.forEach(value -> { |
|
67 |
Object[] dv = {DateUtils.format(calendar.getTime(), timeFormat), new BigDecimal(value).setScale(scale, BigDecimal.ROUND_HALF_UP)}; |
|
68 |
calendar.add(Calendar.MINUTE, 1); |
|
69 |
result.add(dv); |
|
70 |
}); |
|
71 |
return result; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
807efb
|
75 |
public void insert(List<MmItemResultJsonEntity> resultJsonList) { |
D |
76 |
baseDao.insertBatch(resultJsonList); |
|
77 |
} |
1c9291
|
78 |
|
L |
79 |
@Override |
|
80 |
public void cleanResultJson(Map<String, Date> tMap) { |
|
81 |
baseDao.cleanResultJson(tMap); |
|
82 |
} |
b368e6
|
83 |
} |