package com.iailab.module.model.mcs.pre.service.impl;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.framework.common.service.impl.BaseServiceImpl;
|
import com.iailab.framework.common.util.date.DateUtils;
|
import com.iailab.module.model.mcs.pre.dao.MmItemResultJsonDao;
|
import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity;
|
import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.CollectionUtils;
|
|
import java.util.ArrayList;
|
import java.util.Calendar;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年11月14日
|
*/
|
@Service
|
public class MmItemResultJsonServiceImpl extends BaseServiceImpl<MmItemResultJsonDao, MmItemResultJsonEntity>
|
implements MmItemResultJsonService {
|
|
@Override
|
public List<Object[]> getData(String outputId, Date predictTime, String timeFormat) {
|
List<Object[]> result = new ArrayList<>();
|
QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>();
|
wrapper.eq("outputid", outputId)
|
.eq("predicttime", DateUtils.format(predictTime,timeFormat));
|
MmItemResultJsonEntity data = baseDao.selectOne(wrapper);
|
if (data == null || StringUtils.isBlank(data.getJsonvalue())) {
|
return result;
|
}
|
List<Double> valueList = JSONArray.parseArray(data.getJsonvalue(), Double.class);
|
if (CollectionUtils.isEmpty(valueList)) {
|
return result;
|
}
|
Calendar calendar = Calendar.getInstance();
|
calendar.setTime(predictTime);
|
valueList.forEach(value -> {
|
Object[] dv = {DateUtils.format(calendar.getTime(), timeFormat), value};
|
calendar.add(Calendar.MINUTE, 1);
|
result.add(dv);
|
});
|
return result;
|
}
|
}
|