Merge remote-tracking branch 'origin/master'
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date dataTime; |
| | | private Date t; |
| | | |
| | | private double dataValue; |
| | | private double v; |
| | | } |
| | |
| | | queryDto.setPointNo(item.getPointNo()); |
| | | List<ApiPointValueDTO> list = dataPointApi.queryPointHistoryValue(queryDto); |
| | | List<Object[]> sData = list.stream().map(dataItem -> { |
| | | Object[] valueArray = new Object[]{DateUtils.format(dataItem.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND), |
| | | getFormatValue(item.getDataType(), dataItem.getDataValue())}; |
| | | Object[] valueArray = new Object[]{DateUtils.format(dataItem.getT(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND), |
| | | getFormatValue(item.getDataType(), dataItem.getV())}; |
| | | return valueArray; |
| | | }).collect(Collectors.toList()); |
| | | seriesItem.setData(sData); |
| | |
| | | List<ApiPointValueDTO> pointValueList = new ArrayList<>(); |
| | | for (int i = 0; list.size() - i >= 1; i++) { |
| | | ApiPointValueDTO pointValue = new ApiPointValueDTO(); |
| | | pointValue.setDataValue(Double.parseDouble(list.get(i).get(InfluxDBServiceImpl.VALUE).toString())); |
| | | pointValue.setDataTime(DateUtils.parse(list.get(i).get(InfluxDBServiceImpl.TIME).toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | pointValue.setV(Double.parseDouble(list.get(i).get(InfluxDBServiceImpl.VALUE).toString())); |
| | | pointValue.setT(DateUtils.parse(list.get(i).get(InfluxDBServiceImpl.TIME).toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | pointValueList.add(pointValue); |
| | | } |
| | | return pointValueList; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | |
| | | @GetMapping("/list") |
| | | @Operation(summary = "获取计划项列表", description = "用于【计划项】界面") |
| | | @PreAuthorize("@ss.hasPermission('data:plan-item:query')") |
| | | public CommonResult<List<PlanItemRespVO>> getList(PlanItemPageReqVO reqVO) { |
| | | List<PlanItemEntity> list = planItemService.list(); |
| | | public CommonResult<List<PlanItemRespVO>> getList(@RequestParam Map<String, Object> params) { |
| | | List<PlanItemEntity> list = planItemService.list(params); |
| | | return success(ConvertUtils.sourceToTarget(list, PlanItemRespVO.class)); |
| | | } |
| | | } |
| | |
| | | |
| | | PageResult<PlanItemEntity> page(PlanItemPageReqVO reqVO); |
| | | |
| | | List<PlanItemEntity> list(); |
| | | List<PlanItemEntity> list(Map<String, Object> params); |
| | | |
| | | void create(PlanItemSaveReqVO createReqVO); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<PlanItemEntity> list() { |
| | | public List<PlanItemEntity> list(Map<String, Object> params) { |
| | | QueryWrapper<PlanItemEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq(params.get("status") != null, "status", params.get("status")); |
| | | queryWrapper.orderByDesc("create_time"); |
| | | return baseDao.selectList(queryWrapper); |
| | | } |
| | |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.iailab.module.data.ind.item.vo.IndItemAtomVO; |
| | | import com.iailab.module.data.ind.item.vo.IndItemCalVO; |
| | | import com.iailab.module.data.ind.item.vo.IndItemDerVO; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | |
| | | import com.iailab.module.data.point.vo.DaPointPageReqVO; |
| | | import com.iailab.module.data.point.vo.PointImportExcelVO; |
| | | import com.iailab.module.data.point.vo.PointImportRespVO; |
| | | import com.iailab.module.infra.api.config.ConfigApi; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_EXISTS; |
| | |
| | | private DaPointDao daPointDao; |
| | | |
| | | @Resource |
| | | private ConfigApi configApi; |
| | | |
| | | @Resource |
| | | private ChannelSourceService channelSourceService; |
| | | |
| | | private static Map<String, DaPointDTO> pointIdMap = new ConcurrentHashMap<>(); |
| | | |
| | | private static Map<String, DaPointDTO> pointNoMap = new ConcurrentHashMap<>(); |
| | | |
| | | @Override |
| | | public PageResult<DaPointDTO> queryPage(DaPointPageReqVO reqVO) { |
| | | IPage<DaPointDTO> page = daPointDao.selectPageList(reqVO); |
| | | return new PageResult<DaPointDTO>(page.getRecords(), page.getTotal()); |
| | | return new PageResult<>(page.getRecords(), page.getTotal()); |
| | | } |
| | | |
| | | private void clearCache() { |
| | | pointIdMap.clear(); |
| | | pointNoMap.clear(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public DaPointDTO getSimpleInfoById(String id) { |
| | | return ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class); |
| | | if (pointIdMap.containsKey(id)) { |
| | | return pointIdMap.get(id); |
| | | } |
| | | DaPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class); |
| | | pointIdMap.put(id, dto); |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | |
| | | daPointEntity.setIsEnable(CommonConstant.IS_ENABLE); |
| | | daPointEntity.setCreateTime(new Date()); |
| | | daPointDao.insert(daPointEntity); |
| | | |
| | | // 清空缓存 |
| | | clearCache(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | default: |
| | | break; |
| | | } |
| | | // 清空缓存 |
| | | clearCache(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | daPointDao.deleteBatchIds(Arrays.asList(id)); |
| | | daMeasurePointService.deleteByPoint(id); |
| | | daMathPointService.deleteByPoint(id); |
| | | // 清空缓存 |
| | | clearCache(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public DaPointDTO getByNo(String pointNo) { |
| | | if (pointNoMap.containsKey(pointNo)) { |
| | | return pointNoMap.get(pointNo); |
| | | } |
| | | QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("point_no", pointNo); |
| | | DaPointEntity entity = daPointDao.selectOne(wrapper); |
| | | return ConvertUtils.sourceToTarget(entity, DaPointDTO.class); |
| | | DaPointDTO dto = ConvertUtils.sourceToTarget(entity, DaPointDTO.class); |
| | | pointNoMap.put(pointNo, dto); |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | |
| | | and t1.is_enable = #{params.isEnable} |
| | | </if> |
| | | </where> |
| | | order by t1.create_time desc |
| | | order by t1.create_time desc, t1.point_no desc |
| | | </select> |
| | | |
| | | <select id="getList" resultType="com.iailab.module.data.point.dto.DaPointDTO"> |
| | |
| | | and t1.is_enable = #{isEnable} |
| | | </if> |
| | | </where> |
| | | order by t1.create_time desc |
| | | order by t1.create_time desc, t1.point_no desc |
| | | </select> |
| | | |
| | | <select id="getConstantPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO"> |
| | |
| | | @Schema(description = "查询ID列表") |
| | | private List<String[]> queryIds; |
| | | |
| | | @Schema(description = "输出ID列表") |
| | | private List<String> outIds; |
| | | |
| | | @Schema(description = "预测时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date predictTime; |
| | |
| | | @Schema(description = "预测项名称") |
| | | private String itemName; |
| | | |
| | | @Schema(description = "输出ID") |
| | | private String outId; |
| | | |
| | | @Schema(description = "输出结果") |
| | | private String resultstr; |
| | | |
| | | @Schema(description = "输出结果") |
| | | private String resultName; |
| | | |
| | | @Schema(description = "预测时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date predictTime; |
| | |
| | | ) engine = innodb |
| | | default character set utf8mb4 COMMENT = '预测项模型表'; |
| | | |
| | | create table t_mm_result_table |
| | | ( |
| | | id varchar(36) not null, |
| | | tablename varchar(30), |
| | | primary key (id) |
| | | ) engine = innodb default character set utf8mb4 COMMENT = '预测结果存放表'; |
| | | |
| | | |
| | | create table t_mm_item_result_json |
| | | ( |
| | | id varchar(36) not null, |
| | |
| | | import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.service.*; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; |
| | | import com.iailab.module.model.mdk.vo.ItemVO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | moduleOpt.setId(item.getId()); |
| | | moduleOpt.setLabel(item.getModulename()); |
| | | List<PredictItemTreeDTO> children = new ArrayList<>(); |
| | | Map<String, Object> params = new HashMap<>(2); |
| | | params.put("status", 1); |
| | | params.put("moduleid", item.getId()); |
| | | List<MmPredictItemRespVO> itemList = mmPredictItemService.list(params); |
| | | List<ItemVO> itemList = mmPredictItemService.getByModuleId(item.getId()); |
| | | itemList.forEach(item1 -> { |
| | | PredictItemTreeDTO chd = new PredictItemTreeDTO(); |
| | | chd.setLabel(item1.getItemname()); |
| | | chd.setLabel(item1.getItemName()); |
| | | chd.setId(item1.getId()); |
| | | List<PredictItemTreeDTO> chd1 = new ArrayList<>(); |
| | | List<MmItemOutputEntity> outList = mmItemOutputService.getByItemid(item1.getId()); |
| | | if (!CollectionUtils.isEmpty(outList)) { |
| | | outList.forEach(out -> { |
| | | PredictItemTreeDTO chd2 = new PredictItemTreeDTO(); |
| | | chd2.setId(out.getId()); |
| | | chd2.setLabel(out.getResultstr()); |
| | | chd1.add(chd2); |
| | | }); |
| | | } |
| | | chd.setChildren(chd1); |
| | | children.add(chd); |
| | | }); |
| | | moduleOpt.setChildren(children); |
| | |
| | | @Override |
| | | public PreDataBarLineRespVO getPreDataCharts(PreDataBarLineReqVO reqVO) { |
| | | PreDataBarLineRespVO result = new PreDataBarLineRespVO(); |
| | | List<String[]> queryIds = reqVO.getQueryIds(); |
| | | List<String> outIds = reqVO.getOutIds(); |
| | | List<String> legends = new ArrayList<>(); |
| | | List<PreDataViewRespDTO> dataViewList = new ArrayList<>(); |
| | | if (CollectionUtils.isEmpty(reqVO.getQueryIds())) { |
| | | if (CollectionUtils.isEmpty(outIds)) { |
| | | return result; |
| | | } |
| | | Date predictTime = reqVO.getPredictTime(); |
| | | if (predictTime == null) { |
| | | DmModuleEntity dmModule = dmModuleService.getModuleByItemId(queryIds.get(0)[0]); |
| | | if (dmModule != null) { |
| | | predictTime = dmModule.getPredicttime(); |
| | | MmItemOutputEntity output = mmItemOutputService.getOutPutById(reqVO.getOutIds().get(0)); |
| | | ItemVO predictItem = mmPredictItemService.getItemById(output.getItemid()); |
| | | if (predictItem.getLastTime() != null) { |
| | | predictTime = predictItem.getLastTime(); |
| | | } else { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | |
| | | endTime = calendar.getTime(); |
| | | } |
| | | |
| | | for (int i = 0; i < queryIds.size(); i++) { |
| | | for (int i = 0; i < outIds.size(); i++) { |
| | | PreDataViewRespDTO viewDto = new PreDataViewRespDTO(); |
| | | String itemId = queryIds.get(i)[0]; |
| | | String outKey = queryIds.get(i)[1]; |
| | | MmItemOutputEntity output = mmItemOutputService.getByItemid(itemId, outKey); |
| | | String outId = outIds.get(i); |
| | | MmItemOutputEntity output = mmItemOutputService.getOutPutById(outId); |
| | | if (output == null) { |
| | | continue; |
| | | continue; |
| | | } |
| | | legends.add(output.getResultstr()); |
| | | viewDto.setItemId(output.getItemid()); |
| | | viewDto.setOutId(outId); |
| | | viewDto.setResultstr(output.getResultstr()); |
| | | viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime)); |
| | | viewDto.setPreDataN(mmItemResultService.getData(output.getId(), startTime, endTime)); |
| | | viewDto.setPreDataL(mmItemResultLastPointService.getData(output.getId(), startTime, endTime)); |
| | |
| | | calendar.add(Calendar.HOUR_OF_DAY, 1); |
| | | endTime = calendar.getTime(); |
| | | } |
| | | if (endTime.getTime() <= startTime.getTime()) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 1); |
| | | endTime = calendar.getTime(); |
| | | } |
| | | |
| | | List<String> categories = DateUtils.getTimeScale(startTime, endTime, predictItem.getGranularity()); |
| | | List<String> legend = new ArrayList<>(); |
| | | LinkedHashMap<String, PreDataSampleViewRespDTO> viewMap = new LinkedHashMap<>(); |
| | |
| | | } |
| | | valueDTOS.forEach(item -> { |
| | | Object[] values = new Object[2]; |
| | | values[0] = DateUtils.format(item.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | values[1] = item.getDataValue(); |
| | | values[0] = DateUtils.format(item.getT(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | values[1] = new BigDecimal(item.getV()).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | result.add(values); |
| | | }); |
| | | return result; |
| | |
| | | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.PreDataBarLineReqVO; |
| | | import com.iailab.module.model.api.mcs.dto.PreDataBarLineRespVO; |
| | | import com.iailab.module.model.api.mcs.dto.PreDataItemChartReqVO; |
| | | import com.iailab.module.model.api.mcs.dto.PreDataItemChartRespVO; |
| | | import com.iailab.module.model.api.mcs.dto.*; |
| | | import com.iailab.module.model.common.utils.ApiSecurityUtils; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.annotation.security.PermitAll; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | private McsApi mcsApi; |
| | | |
| | | @PermitAll |
| | | @GetMapping("/predict-item/tree") |
| | | @Operation(summary = "预测项树") |
| | | public CommonResult<List<PredictItemTreeDTO>> getPredictItemTree(HttpServletResponse response, HttpServletRequest |
| | | request) throws Exception { |
| | | apiSecurityUtils.validate(request); |
| | | List<PredictItemTreeDTO> list = mcsApi.getPredictItemTree(); |
| | | return CommonResult.success(list); |
| | | } |
| | | |
| | | @PermitAll |
| | | @PostMapping("/predict-data/charts") |
| | | @Operation(summary = "预测数据图表") |
| | | public CommonResult<PreDataBarLineRespVO> getPreDataCharts(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody PreDataBarLineReqVO reqVO) throws Exception { |
| | | apiSecurityUtils.validate(request); |
| | | PreDataBarLineRespVO respVO = mcsApi.getPreDataCharts(reqVO); |
| | | PreDataBarLineRespVO respVO = new PreDataBarLineRespVO(); |
| | | try { |
| | | respVO = mcsApi.getPreDataCharts(reqVO); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return CommonResult.success(respVO); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | public CommonResult<List<MmPredictItemRespVO>> list(Map<String, Object> params) { |
| | | public CommonResult<List<MmPredictItemRespVO>> list(@RequestParam Map<String, Object> params) { |
| | | List<MmPredictItemRespVO> list = mmPredictItemService.list(params); |
| | | return success(list); |
| | | } |
| | |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.dto.MmItemOutputDTO; |
| | | import com.iailab.module.model.mdk.vo.MmItemOutputVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | public interface MmItemOutputDao extends BaseMapperX<MmItemOutputEntity> { |
| | | |
| | | List<MmItemOutputDTO> queryList(@Param("params") Map<String, Object> params); |
| | | |
| | | List<MmItemOutputVO> getOutPutById(String outputid); |
| | | |
| | | List<MmItemOutputVO> getOutPutByItemId(String itemid); |
| | | |
| | | List<MmItemOutputVO> getOutPutByPointId(String pointid); |
| | | } |
| | |
| | | |
| | | import com.iailab.module.model.mcs.pre.dto.MmItemOutputDTO; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mdk.vo.MmItemOutputVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | List<MmItemOutputDTO> queryList(Map<String, Object> params); |
| | | |
| | | MmItemOutputVO getOutPutById(String outputid); |
| | | MmItemOutputEntity getOutPutById(String outputid); |
| | | |
| | | List<MmItemOutputVO> getOutPutByItemId(String itemid); |
| | | |
| | | List<MmItemOutputVO> getOutPutByPointId(String pointid); |
| | | |
| | | List<MmItemOutputEntity> getByItemid(String itemid); |
| | | List<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity> getByItemid(String itemid); |
| | | |
| | | MmItemOutputEntity getByItemid(String itemid, String resultstr); |
| | | |
| | |
| | | package com.iailab.module.model.mcs.pre.service; |
| | | |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultEntity; |
| | | import com.iailab.module.model.mdk.vo.DataValueVO; |
| | | |
| | | import java.util.Date; |
| | |
| | | * @date 2021年05月28日 10:34 |
| | | */ |
| | | public interface MmItemResultService { |
| | | |
| | | List<MmItemResultEntity> getListByOutputId(String outputid, Map<String, Object> params); |
| | | |
| | | void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime); |
| | | |
| | |
| | | import com.iailab.module.model.mcs.pre.dto.MmItemOutputDTO; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemOutputService; |
| | | import com.iailab.module.model.mdk.vo.MmItemOutputVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | |
| | | @Autowired |
| | | private MmItemOutputDao mmItemOutputDao; |
| | | |
| | | private static Map<String, MmItemOutputEntity> outputMap = new ConcurrentHashMap<>(); |
| | | |
| | | @Override |
| | | public void saveMmItemOutput(List<MmItemOutputEntity> mmItemOutput) { |
| | | mmItemOutputDao.insert(mmItemOutput); |
| | | // 清空缓存 |
| | | outputMap.clear(); |
| | | } |
| | | |
| | | @Override |
| | | public void update(MmItemOutputEntity mmItemOutput) { |
| | | mmItemOutputDao.updateById(mmItemOutput); |
| | | // 清空缓存 |
| | | outputMap.clear(); |
| | | } |
| | | |
| | | public void deleteBatch(String[] itemIds) { |
| | | QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper(); |
| | | queryWrapper.in("itemid", itemIds); |
| | | mmItemOutputDao.delete(queryWrapper); |
| | | // 清空缓存 |
| | | outputMap.clear(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public MmItemOutputVO getOutPutById(String outputid) { |
| | | List<MmItemOutputVO> list = mmItemOutputDao.getOutPutById(outputid); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return null; |
| | | public MmItemOutputEntity getOutPutById(String outputid) { |
| | | if (outputMap.containsKey(outputid)) { |
| | | return outputMap.get(outputid); |
| | | } |
| | | return list.get(0); |
| | | } |
| | | |
| | | @Override |
| | | public List<MmItemOutputVO> getOutPutByItemId(String itemid) { |
| | | return mmItemOutputDao.getOutPutByItemId(itemid); |
| | | } |
| | | |
| | | @Override |
| | | public List<MmItemOutputVO> getOutPutByPointId(String pointid) { |
| | | return mmItemOutputDao.getOutPutByPointId(pointid); |
| | | MmItemOutputEntity entity = mmItemOutputDao.selectById(outputid); |
| | | outputMap.put(outputid, entity); |
| | | return entity; |
| | | } |
| | | } |
| | |
| | | |
| | | @Autowired |
| | | private MmItemResultDao mmItemResultDao; |
| | | |
| | | @Override |
| | | public List<MmItemResultEntity> getListByOutputId(String outputid, Map<String, Object> params) { |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date startDateParam = null; |
| | | try { |
| | | startDateParam = sdf.parse((String)params.get("startTime")); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Date endDateParam = null; |
| | | try { |
| | | endDateParam = sdf.parse((String)params.get("endTime")); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | List<MmItemResultEntity> list = mmItemResultDao.selectList( |
| | | new QueryWrapper<MmItemResultEntity>() |
| | | .eq("outputid", outputid) |
| | | .between("datatime", startDateParam, endDateParam) |
| | | .orderByAsc("datatime") |
| | | ); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime) { |
| | |
| | | list.forEach(item -> { |
| | | Object[] dataItem = new Object[2]; |
| | | dataItem[0] = DateUtils.format(item.getDatatime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | dataItem[1] = item.getDatavalue(); |
| | | dataItem[1] = item.getDatavalue().setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | result.add(dataItem); |
| | | }); |
| | | return result; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | |
| | | @Autowired |
| | | private MmItemTypeDao mmItemTypeDao; |
| | | |
| | | private Map<String, MmItemTypeEntity> typeIdMap = new ConcurrentHashMap<>(); |
| | | |
| | | @Override |
| | | public PageResult<MmItemTypeEntity> page(MmItemTypePageReqVO reqVO) { |
| | |
| | | public void saveItemType(MmItemTypeEntity itemType) { |
| | | itemType.setId(UUID.randomUUID().toString()); |
| | | mmItemTypeDao.insert(itemType); |
| | | typeIdMap.clear(); |
| | | } |
| | | |
| | | @Override |
| | | public void update(MmItemTypeEntity itemType) { |
| | | mmItemTypeDao.updateById(itemType); |
| | | typeIdMap.clear(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteBatch(String[] moduleIds) { |
| | | mmItemTypeDao.deleteBatchIds(Arrays.asList(moduleIds)); |
| | | typeIdMap.clear(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public MmItemTypeEntity getItemTypeByItemId(String itemId) { |
| | | if (typeIdMap.containsKey(itemId)) { |
| | | return typeIdMap.get(itemId); |
| | | } |
| | | List<MmItemTypeEntity> list = mmItemTypeDao.getItemTypeByItemId(itemId); |
| | | if (CollectionUtils.isAnyEmpty(list)) { |
| | | return null; |
| | | } |
| | | typeIdMap.put(itemId, list.get(0)); |
| | | return list.get(0); |
| | | } |
| | | |
| | |
| | | package com.iailab.module.model.mcs.pre.service.impl; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.model.mcs.pre.dao.MmItemTypeDao; |
| | | import com.iailab.module.model.mcs.pre.dao.MmModelArithSettingsDao; |
| | | import com.iailab.module.model.mcs.pre.entity.MmModelArithSettingsEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmModelArithSettingsService; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | @Autowired |
| | | private MmModelArithSettingsDao mmModelArithSettingsDao; |
| | | |
| | | private static Map<String, List<MmModelArithSettingsEntity>> modelIdMap = new ConcurrentHashMap<>(); |
| | | |
| | | @Override |
| | | public void saveList(List<MmModelArithSettingsEntity> list) { |
| | | QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper(); |
| | |
| | | item.setId(UUID.randomUUID().toString()); |
| | | }); |
| | | mmModelArithSettingsDao.insertList(list); |
| | | } |
| | | |
| | | public List<MmModelArithSettingsEntity> getByModelid(String modelid) { |
| | | Map<String, Object> params = new HashMap<>(1); |
| | | params.put("modelid", modelid); |
| | | List<MmModelArithSettingsEntity> list = mmModelArithSettingsDao.getMmModelArithSettings(params); |
| | | |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return list; |
| | | // 清空缓存 |
| | | modelIdMap.clear(); |
| | | } |
| | | |
| | | @Override |
| | | public List<MmModelArithSettingsEntity> getByModelId(String modelId) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | if (modelIdMap.containsKey(modelId)) { |
| | | return modelIdMap.get(modelId); |
| | | } |
| | | Map<String, Object> params = new HashMap<>(1); |
| | | params.put("modelid", modelId); |
| | | return mmModelArithSettingsDao.getMmModelArithSettings(params); |
| | | List<MmModelArithSettingsEntity> list = mmModelArithSettingsDao.getMmModelArithSettings(params); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | list = new ArrayList<>(); |
| | | } |
| | | modelIdMap.put(modelId, list); |
| | | return list; |
| | | } |
| | | } |
| | |
| | | if (itemType != null && ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) { |
| | | MmPredictModelEntity mmPredictModel = mmPredictModelService.getByItemid(id); |
| | | mmPredictItemDto.setMmPredictModel(mmPredictModel); |
| | | mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelid(mmPredictModel.getId())); |
| | | mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelId(mmPredictModel.getId())); |
| | | mmPredictItemDto.setMmModelParamList(mmModelParamService.getByModelid(mmPredictModel.getId())); |
| | | mmPredictItemDto.setMmPredictMergeItem(new MmPredictMergeItemEntity()); |
| | | } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) { |
| | |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | |
| | | @Schema(description = "模型平台 - MmItemOutput Response VO") |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | public class MmItemOutputRespVO { |
| | | public class MmItemOutputRespVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("ID") |
| | |
| | | @ExcelProperty("存放表ID") |
| | | private String resulttableid; |
| | | |
| | | @Schema(description = "输出结果") |
| | | @ExcelProperty("输出结果") |
| | | private String resultstr; |
| | | |
| | | @Schema(description = "数据点名称") |
| | | @ExcelProperty("数据点名称") |
| | | private String tagname; |
| | |
| | | @Schema(description = "排序(默认值1)") |
| | | @ExcelProperty("排序") |
| | | private BigDecimal outputorder; |
| | | |
| | | @Schema(description = "结果名称") |
| | | @ExcelProperty("结果名称") |
| | | private String resultName; |
| | | } |
| | |
| | | package com.iailab.module.model.mdk.factory; |
| | | |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemOutputService; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemTypeService; |
| | | import com.iailab.module.model.mcs.pre.service.MmPredictItemService; |
| | | import com.iailab.module.model.mdk.vo.ItemVO; |
| | | import com.iailab.module.model.mdk.vo.MergeItemVO; |
| | | import com.iailab.module.model.mdk.vo.MmItemOutputVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | private Map<String, MmItemTypeEntity> itemTypeMap = new HashMap<>(); |
| | | private Map<String, MergeItemVO> mergeItemMap = new HashMap<>(); |
| | | private Map<String, ItemVO> itemNoEntityMap = new HashMap<>(); |
| | | private Map<String, List<MmItemOutputVO>> itemOutPutItemMap = new HashMap<>(); |
| | | private Map<String, MmItemOutputVO> itemOutputMap = new HashMap<>(); |
| | | private Map<String, List<MmItemOutputEntity>> itemOutPutItemMap = new HashMap<>(); |
| | | |
| | | @Autowired |
| | | private MmPredictItemService mmPredictItemService; |
| | |
| | | * @param itemId |
| | | * @return |
| | | */ |
| | | public List<MmItemOutputVO> getOutPutByItemId(String itemId) { |
| | | List<MmItemOutputVO> list = mmItemOutputService.getOutPutByItemId(itemId); |
| | | public List<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity> getOutPutByItemId(String itemId) { |
| | | List<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity> list = mmItemOutputService.getByItemid(itemId); |
| | | if (!itemOutPutItemMap.containsKey(itemId)) { |
| | | if (list != null) { |
| | | itemOutPutItemMap.put(itemId, list); |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 5. |
| | | * |
| | | * @param outputId |
| | | * @return |
| | | */ |
| | | public MmItemOutputVO getItemOutPutById(String outputId) { |
| | | if (!itemOutputMap.containsKey(outputId)) { |
| | | MmItemOutputVO itemOutput = mmItemOutputService.getOutPutById(outputId); |
| | | if (itemOutput != null) { |
| | | itemOutputMap.put(outputId, itemOutput); |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | return itemOutputMap.get(outputId); |
| | | } |
| | | |
| | | /** |
| | | * 6.根据预测项ID,获取预测项对应的输出参数的维数 |
| | | * |
| | | * @param itemId |
| | | * @return |
| | | */ |
| | | public Integer getItemOutputCount(String itemId) { |
| | | if (!itemOutPutItemMap.containsKey(itemId)) { |
| | | List<MmItemOutputVO> list = mmItemOutputService.getOutPutByItemId(itemId); |
| | | if (list != null) { |
| | | itemOutPutItemMap.put(itemId, list); |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | | return itemOutPutItemMap.get(itemId).size(); |
| | | } |
| | | |
| | | /** |
| | | * 7.根据预测项ID,获取对应的MmItemTypeEntity实体 |
| | | * |
| | | * @param itemId |
| | | * @return |
| | | */ |
| | | public MmItemTypeEntity getMmItemTypeEntity(String itemId) { |
| | | if (!itemTypeMap.containsKey(itemId)) { |
| | | MmItemTypeEntity MmItemTypeEntity = mmItemTypeService.getItemTypeByItemId(itemId); |
| | | if (MmItemTypeEntity != null) { |
| | | itemTypeMap.put(itemId, MmItemTypeEntity); |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | return itemTypeMap.get(itemId); |
| | | } |
| | | } |
| | |
| | | package com.iailab.module.model.mdk.factory; |
| | | |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemTypeService; |
| | | import com.iailab.module.model.mdk.predict.PredictItemHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private ApplicationContext applicationContext; |
| | | |
| | | @Autowired |
| | | private ItemEntityFactory itemEntityFactory; |
| | | private MmItemTypeService mmItemTypeService; |
| | | |
| | | /** |
| | | * 根据预测项实体创建对应的预测项对象 |
| | |
| | | * @return |
| | | */ |
| | | public PredictItemHandler create(String itemId) { |
| | | MmItemTypeEntity itemTypeEntity = itemEntityFactory.getMmItemTypeEntity(itemId); |
| | | MmItemTypeEntity itemTypeEntity = mmItemTypeService.getItemTypeByItemId(itemId); |
| | | //获取预测项的预测程序的类 |
| | | Object itemObject = null; |
| | | try { |
| | |
| | | import com.iailab.module.model.mcs.pre.service.MmItemResultService; |
| | | import com.iailab.module.model.mdk.factory.ItemEntityFactory; |
| | | import com.iailab.module.model.mdk.vo.DataValueVO; |
| | | import com.iailab.module.model.mdk.vo.MmItemOutputVO; |
| | | import com.iailab.module.model.mdk.vo.PredictResultVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | |
| | | */ |
| | | public Map<String, List<DataValueVO>> convertToPredictData(PredictResultVO predictResult) { |
| | | Map<String, List<DataValueVO>> resultMap = new HashMap<>(); |
| | | List<MmItemOutputVO> itemOutPutList = itemEntityFactory.getOutPutByItemId(predictResult.getPredictId()); |
| | | List<MmItemOutputEntity> itemOutPutList = itemEntityFactory.getOutPutByItemId(predictResult.getPredictId()); |
| | | |
| | | if (!CollectionUtils.isEmpty(predictResult.getPredictList())) { |
| | | resultMap.put(itemOutPutList.get(0).getId(), predictResult.getPredictList()); |
| | | return resultMap; |
| | | } |
| | | Map<MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs(); |
| | | Map<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs(); |
| | | HashMap<String,List<DataValueVO>> predictLists = new HashMap<>(); |
| | | for (Map.Entry<MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) { |
| | | for (Map.Entry<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) { |
| | | Integer rows = entry.getValue().length; |
| | | List<DataValueVO> predictDataList = new ArrayList<>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | |
| | | if (!CollectionUtils.isEmpty(predictResult.getPredictList())) { |
| | | return predictLists; |
| | | } |
| | | Map<MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs(); |
| | | for (Map.Entry<MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) { |
| | | Map<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs(); |
| | | for (Map.Entry<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) { |
| | | Integer rows = entry.getValue().length; |
| | | List<DataValueVO> predictDataList = new ArrayList<>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | |
| | | |
| | | public List<DataValueVO> getPredictValueByItemNo(String itemNo, Date start, Date end) { |
| | | String itemId = itemEntityFactory.getItemByItemNo(itemNo).getId(); |
| | | List<MmItemOutputVO> outputList = itemEntityFactory.getOutPutByItemId(itemId); |
| | | List<MmItemOutputEntity> outputList = itemEntityFactory.getOutPutByItemId(itemId); |
| | | return mmItemResultService.getPredictValue(outputList.get(0).getId(), start, end); |
| | | } |
| | | |
| | | public List<DataValueVO> getPredictValueByItemId(String itemId, Date start, Date end) { |
| | | List<MmItemOutputVO> outputList = itemEntityFactory.getOutPutByItemId(itemId); |
| | | List<MmItemOutputEntity> outputList = itemEntityFactory.getOutPutByItemId(itemId); |
| | | return mmItemResultService.getPredictValue(outputList.get(0).getId(), start, end); |
| | | } |
| | | } |
| | |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointDTO; |
| | | import com.iailab.module.data.enums.DataPointFreqEnum; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mdk.common.enums.ItemPredictStatus; |
| | | import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException; |
| | | import com.iailab.module.model.mdk.factory.ItemEntityFactory; |
| | |
| | | import com.iailab.module.model.mdk.predict.PredictResultHandler; |
| | | import com.iailab.module.model.mdk.vo.DataValueVO; |
| | | import com.iailab.module.model.mdk.vo.ItemVO; |
| | | import com.iailab.module.model.mdk.vo.MmItemOutputVO; |
| | | import com.iailab.module.model.mdk.vo.PredictResultVO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | if (itemNo.length() > 4) { |
| | | Date endTime = predictTime; |
| | | ItemVO itemEntity = itemEntityFactory.getItemByItemNo(itemNo); |
| | | List<MmItemOutputVO> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId()); |
| | | ApiPointDTO pointEntity = dataPointApi.getInfoById(outPutList.get(0).getPointId()); |
| | | List<MmItemOutputEntity> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId()); |
| | | ApiPointDTO pointEntity = dataPointApi.getInfoById(outPutList.get(0).getPointid()); |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(endTime); |
| | |
| | | package com.iailab.module.model.mdk.sample; |
| | | |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemOutputService; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemResultService; |
| | | import com.iailab.module.model.mdk.factory.ItemEntityFactory; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemTypeService; |
| | | import com.iailab.module.model.mdk.common.enums.ModelParamType; |
| | | import com.iailab.module.model.mdk.sample.dto.ColumnItem; |
| | | import com.iailab.module.model.mdk.sample.dto.ColumnItemPort; |
| | | import com.iailab.module.model.mdk.sample.dto.SampleData; |
| | | import com.iailab.module.model.mdk.sample.dto.SampleInfo; |
| | | import com.iailab.module.model.mdk.vo.DataValueVO; |
| | | import com.iailab.module.model.mdk.vo.MmItemOutputVO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 预测样本数据构造 |
| | |
| | | private MmItemResultService mmItemResultService; |
| | | |
| | | @Autowired |
| | | private ItemEntityFactory itemEntityFactory; |
| | | private MmItemTypeService mmItemTypeService; |
| | | |
| | | @Autowired |
| | | private MmItemOutputService mmItemOutputService; |
| | | |
| | | /** |
| | | * alter by zfc 2020.11.24 修改数据样本构造方案:sampleInfo中数据已按爪子进行分类,但爪内数据为无序的, |
| | |
| | | public List<SampleData> prepareSampleData(SampleInfo sampleInfo) { |
| | | List<SampleData> sampleDataList = new ArrayList<>(); |
| | | //对每个爪分别进行计算 |
| | | int deviationIndex = 0; |
| | | for (ColumnItemPort entry : sampleInfo.getColumnInfo()) { |
| | | //先依据爪内数据项的modelParamOrder进行排序——重写comparator匿名函数 |
| | | Collections.sort(entry.getColumnItemList(), new Comparator<ColumnItem>() { |
| | |
| | | } |
| | | } |
| | | |
| | | //找出对应的调整值 |
| | | BigDecimal[] deviationItem = null; |
| | | if (sampleInfo.getDeviation() != null && sampleInfo.getDeviation().length > 0) { |
| | | deviationItem = sampleInfo.getDeviation()[deviationIndex]; |
| | | } |
| | | deviationIndex++; |
| | | |
| | | //对每一项依次进行数据查询,然后将查询出的值赋给matrix对应的位置 |
| | | for (int i = 0; i < entry.getColumnItemList().size(); i++) { |
| | | try { |
| | | List<DataValueVO> dataEntityList = getData(entry.getColumnItemList().get(i)); |
| | | //设置调整值 |
| | | if (deviationItem != null && deviationItem.length > 0) { |
| | | logger.info("设置调整值, i = " + i); |
| | | if (deviationItem[i] != null && deviationItem[i].compareTo(BigDecimal.ZERO) != 0) { |
| | | for (int dataKey = 1; dataKey < dataEntityList.size(); dataKey++) { |
| | | DataValueVO item = dataEntityList.get(dataKey); |
| | | item.setDataValue(item.getDataValue() + deviationItem[i].doubleValue()); |
| | | } |
| | | } |
| | | } |
| | | //补全数据 |
| | | ColumnItem columnItem = entry.getColumnItemList().get(i); |
| | | // dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.getEndTime(), columnItem.granularity); |
| | | dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.endTime, columnItem.paramId,columnItem.getParamType()); |
| | | dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.endTime, |
| | | columnItem.paramId, columnItem.getParamType()); |
| | | |
| | | /** 如果数据取不满,把缺失的数据点放在后面 */ |
| | | if (dataEntityList != null && dataEntityList.size() != 0) { |
| | |
| | | private List<DataValueVO> getData(ColumnItem columnItem) throws Exception { |
| | | List<DataValueVO> dataList = new ArrayList<>(); |
| | | String paramType = columnItem.getParamType(); |
| | | switch (paramType) { |
| | | case "DATAPOINT": |
| | | switch (ModelParamType.getEumByCode(paramType)) { |
| | | case DATAPOINT: |
| | | ApiPointDTO point = dataPointApi.getInfoById(columnItem.getParamId()); |
| | | ApiPointValueQueryDTO queryDto = new ApiPointValueQueryDTO(); |
| | | queryDto.setPointNo(point.getPointNo()); |
| | | queryDto.setStart(columnItem.getStartTime()); |
| | | queryDto.setEnd(columnItem.getEndTime()); |
| | | List<ApiPointValueDTO> pointValueList = dataPointApi.queryPointHistoryValue(queryDto); |
| | | dataList = ConvertUtils.sourceToTarget(pointValueList, DataValueVO.class); |
| | | dataList = pointValueList.stream().map(t -> { |
| | | DataValueVO vo = new DataValueVO(); |
| | | vo.setDataTime(t.getT()); |
| | | vo.setDataValue(t.getV()); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | break; |
| | | case "PREDICTITEM": |
| | | MmItemOutputVO outPut = itemEntityFactory.getItemOutPutById(columnItem.getId()); |
| | | case PREDICTITEM: |
| | | MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(columnItem.getId()); |
| | | dataList = mmItemResultService.getPredictValue(outPut.getId(), |
| | | columnItem.getStartTime(), columnItem.getEndTime()); |
| | | if (dataList == null) { |
| | | throw new Exception("没有预测值"); |
| | | } |
| | | break; |
| | | |
| | | |
| | | default: |
| | | break; |
| | | } |
| | |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | public List<DataValueVO> completionData(int length, List<DataValueVO> dataEntityList, Date startTime, Date endTime, String paramId,String paramType) { |
| | | public List<DataValueVO> completionData(int length, List<DataValueVO> dataEntityList, Date startTime, Date endTime, |
| | | String paramId, String paramType) { |
| | | if (CollectionUtils.isEmpty(dataEntityList) || length == dataEntityList.size()) { |
| | | return dataEntityList; |
| | | }else if (length < dataEntityList.size()){ |
| | | return dataEntityList.subList(dataEntityList.size()-length,dataEntityList.size()); |
| | | } else if (length < dataEntityList.size()) { |
| | | return dataEntityList.subList(dataEntityList.size() - length, dataEntityList.size()); |
| | | } |
| | | |
| | | List<DataValueVO> completionDataEntityList = new ArrayList<>(); |
| | |
| | | // 预测值 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | calendar.set(Calendar.HOUR_OF_DAY,0); |
| | | calendar.set(Calendar.MINUTE,0); |
| | | calendar.set(Calendar.SECOND,0); |
| | | calendar.add(Calendar.DAY_OF_YEAR,1); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | startTime = calendar.getTime(); |
| | | start = startTime.getTime(); |
| | | |
| | | calendar.setTime(endTime); |
| | | calendar.set(Calendar.HOUR_OF_DAY,0); |
| | | calendar.set(Calendar.MINUTE,0); |
| | | calendar.set(Calendar.SECOND,0); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | endTime = calendar.getTime(); |
| | | end = endTime.getTime(); |
| | | |
| | | |
| | | oneMin = 24 * 60 * 60 * 1000; |
| | | mins = ((end - start) / oneMin); |
| | |
| | | // 测点值 |
| | | ApiPointDTO dataPoint = dataPointApi.getInfoById(paramId); |
| | | oneMin = 1000L * DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue(); |
| | | |
| | | // 设置时间偏移量 |
| | | start = start - (start % oneMin) + oneMin; |
| | | end = end - (end % oneMin) + oneMin; |
| | | |
| | | |
| | | mins = ((end - start) / oneMin); |
| | | break; |
| | | case IND: |
| | |
| | | oneMin = 24 * 60 * 60 * 1000; |
| | | Calendar calendar2 = Calendar.getInstance(); |
| | | calendar2.setTime(startTime); |
| | | calendar2.set(Calendar.HOUR_OF_DAY,0); |
| | | calendar2.set(Calendar.MINUTE,0); |
| | | calendar2.set(Calendar.SECOND,0); |
| | | calendar2.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar2.set(Calendar.MINUTE, 0); |
| | | calendar2.set(Calendar.SECOND, 0); |
| | | start = calendar2.getTime().getTime(); |
| | | |
| | | calendar2.setTime(endTime); |
| | | calendar2.set(Calendar.HOUR_OF_DAY,0); |
| | | calendar2.set(Calendar.MINUTE,0); |
| | | calendar2.set(Calendar.SECOND,0); |
| | | calendar2.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar2.set(Calendar.MINUTE, 0); |
| | | calendar2.set(Calendar.SECOND, 0); |
| | | end = calendar2.getTime().getTime(); |
| | | |
| | | |
| | | mins = ((end - start) / oneMin); |
| | | break; |
| | | default: |
| | |
| | | |
| | | //找出缺少项 |
| | | Map<Long, Double> dataMap = new LinkedHashMap<>(); |
| | | for (int i = 0; i < mins; i ++) { |
| | | for (int i = 0; i < mins; i++) { |
| | | Long key = start + oneMin * i; |
| | | Double value = sourceDataMap.get(key); |
| | | dataMap.put(key, value); |
| | |
| | | } else if (item.getValue() == null) { |
| | | item.setValue(lastItem.getValue()); |
| | | } |
| | | k ++; |
| | | k++; |
| | | lastItem = item; |
| | | |
| | | DataValueVO dataEntity = new DataValueVO(); |
| | |
| | | |
| | | <mapper namespace="com.iailab.module.model.mcs.pre.dao.MmItemOutputDao"> |
| | | |
| | | <resultMap id="MmItemOutputVO" type="com.iailab.module.model.mdk.vo.MmItemOutputVO"> |
| | | <result property="id" column="ID"/> |
| | | <result property="itemId" column="ITEMID"/> |
| | | <result property="pointId" column="POINTID"/> |
| | | <result property="resultTableName" column="TABLENAME"/> |
| | | <result property="order" column="OUTPUTORDER"/> |
| | | </resultMap> |
| | | |
| | | <select id="getOutPutById" resultMap="MmItemOutputVO"> |
| | | SELECT t1.id, |
| | | t1.itemid, |
| | | t1.pointid, |
| | | t2.tablename, |
| | | t1.outputorder |
| | | FROM t_mm_item_output t1, |
| | | t_mm_result_table t2 |
| | | WHERE t1.id = #{value} |
| | | AND t1.resulttableid = t2.id |
| | | </select> |
| | | <select id="getOutPutByItemId" resultMap="MmItemOutputVO"> |
| | | SELECT t1.id, |
| | | t1.itemid, |
| | | t1.pointid, |
| | | t2.tablename, |
| | | t1.outputorder |
| | | FROM t_mm_item_output t1, |
| | | t_mm_result_table t2 |
| | | WHERE t1.itemid = #{itemid} |
| | | AND t1.resulttableid = t2.id |
| | | ORDER BY t1.outputorder |
| | | </select> |
| | | <select id="getOutPutByPointId" resultMap="MmItemOutputVO"> |
| | | SELECT t1.id, |
| | | t1.itemid, |
| | | t1.pointid, |
| | | t2.tablename, |
| | | t1.outputorder |
| | | FROM t_mm_item_output t1, |
| | | t_mm_result_table t2 |
| | | WHERE t1.pointid = #{value} |
| | | AND t1.resulttableid = t2.id |
| | | ORDER BY t1.outputorder |
| | | </select> |
| | | </mapper> |