提交 | 用户 | 时间
|
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 |
|
潘 |
14 |
import java.util.ArrayList; |
91343d
|
15 |
import java.util.Calendar; |
b368e6
|
16 |
import java.util.Date; |
潘 |
17 |
import java.util.List; |
|
18 |
|
|
19 |
/** |
|
20 |
* @author PanZhibao |
|
21 |
* @Description |
|
22 |
* @createTime 2024年11月14日 |
|
23 |
*/ |
|
24 |
@Service |
|
25 |
public class MmItemResultJsonServiceImpl extends BaseServiceImpl<MmItemResultJsonDao, MmItemResultJsonEntity> |
|
26 |
implements MmItemResultJsonService { |
|
27 |
|
|
28 |
@Override |
977edc
|
29 |
public List<Object[]> getData(String outputId, Date predictTime, String timeFormat) { |
b368e6
|
30 |
List<Object[]> result = new ArrayList<>(); |
潘 |
31 |
QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>(); |
|
32 |
wrapper.eq("outputid", outputId) |
|
33 |
.eq("predicttime", predictTime); |
|
34 |
MmItemResultJsonEntity data = baseDao.selectOne(wrapper); |
|
35 |
if (data == null || StringUtils.isBlank(data.getJsonvalue())) { |
|
36 |
return result; |
|
37 |
} |
91343d
|
38 |
List<Double> valueList = JSONArray.parseArray(data.getJsonvalue(), Double.class); |
潘 |
39 |
if (CollectionUtils.isEmpty(valueList)) { |
|
40 |
return result; |
|
41 |
} |
|
42 |
Calendar calendar = Calendar.getInstance(); |
|
43 |
calendar.setTime(predictTime); |
|
44 |
valueList.forEach(value -> { |
977edc
|
45 |
Object[] dv = {DateUtils.format(calendar.getTime(), timeFormat), value}; |
91343d
|
46 |
calendar.add(Calendar.MINUTE, 1); |
潘 |
47 |
result.add(dv); |
b368e6
|
48 |
}); |
潘 |
49 |
return result; |
|
50 |
} |
|
51 |
} |