| | |
| | | resp.setScheduleTime(reqDTO.getScheduleTime()); |
| | | try { |
| | | log.info("调度计算开始: " + System.currentTimeMillis()); |
| | | log.info("reqDTO=" + JSON.toJSONString(reqDTO)); |
| | | ScheduleResultVO scheduleResult = scheduleModelHandler.doSchedule(reqDTO.getScheduleCode(), reqDTO.getScheduleTime(), |
| | | reqDTO.getDynamicDataLength(), reqDTO.getDynamicSettings()); |
| | | resp.setStatusCode(scheduleResult.getResultCode()); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | protected SampleInfo getColumnInfo(String modelId, Date predictTime) { |
| | | protected SampleInfo getColumnInfo(String modelId, Date predictTime, Map<Integer, Integer> dynamicDataLength) { |
| | | SampleInfo sampleInfo = new SampleInfo(); |
| | | List<ColumnItemPort> resultList = new ArrayList<>(); |
| | | List<ColumnItem> columnItemList = new ArrayList<>(); |
| | |
| | | //设置当前端口号,初始值为最小端口(查询结果按端口号从小到达排列) |
| | | int curPortOrder = modelInputParamEntityList.get(0).getModelparamportorder(); |
| | | //设置当前查询数据长度,初始值为最小端口数据长度 |
| | | int curDataLength = modelInputParamEntityList.get(0).getDatalength(); |
| | | int curDataLength = super.getDataLength(dynamicDataLength, curPortOrder, modelInputParamEntityList.get(0).getDatalength()); |
| | | // 统一获取测点的信息 |
| | | Set<String> pointIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.DATAPOINT)).map(MmModelParamEntity::getModelparamid).collect(Collectors.toSet()); |
| | | List<ApiPointDTO> points = dataPointApi.getInfoByIds(pointIds); |
| | |
| | | for (MmModelParamEntity entry : modelInputParamEntityList) { |
| | | columnInfo.setParamType(entry.getModelparamtype()); |
| | | columnInfo.setParamId(entry.getModelparamid()); |
| | | columnInfo.setDataLength(entry.getDatalength()); |
| | | columnInfo.setDataLength(super.getDataLength(dynamicDataLength, entry.getModelparamportorder(), entry.getDatalength())); |
| | | columnInfo.setModelParamOrder(entry.getModelparamorder()); |
| | | columnInfo.setModelParamPortOrder(entry.getModelparamportorder()); |
| | | columnInfo.setStartTime(getStartTime(columnInfo, predictTime,pointMap,planMap)); |
| | |
| | | @Autowired |
| | | private SampleFactory sampleFactory; |
| | | |
| | | public List<SampleData> constructSample(String typeA, String modelId, Date runTime,String itemName, Map<Integer, Integer> dynamicDataLength) throws ModelInvokeException { |
| | | public List<SampleData> constructSample(String typeA, String modelId, Date runTime,String itemName, |
| | | Map<Integer, Integer> dynamicDataLength) throws ModelInvokeException { |
| | | try { |
| | | SampleInfoConstructor sampleInfoConstructor = sampleFactory.createSampleInfo(typeA, modelId); |
| | | SampleInfo sampleInfo = sampleInfoConstructor.prepareSampleInfo(modelId, runTime); |
| | | if (!CollectionUtils.isEmpty(dynamicDataLength) && sampleInfo.getColumnInfo() != null) { |
| | | for(ColumnItemPort columnInfo : sampleInfo.getColumnInfo()) { |
| | | if (!dynamicDataLength.containsKey(columnInfo.getPortOrder())) { |
| | | continue; |
| | | } |
| | | columnInfo.setDataLength(dynamicDataLength.get(columnInfo.getPortOrder())); |
| | | columnInfo.getColumnItemList().forEach(columnItem -> { |
| | | columnItem.setDataLength(columnInfo.getDataLength()); |
| | | }); |
| | | } |
| | | } |
| | | SampleInfo sampleInfo = sampleInfoConstructor.prepareSampleInfo(modelId, runTime, dynamicDataLength); |
| | | SampleDataConstructor sampleDataConstructor = sampleFactory.createSampleData(typeA); |
| | | return sampleDataConstructor.prepareSampleData(sampleInfo); |
| | | } catch (Exception e) { |
| | |
| | | import com.iailab.module.model.mdk.sample.dto.ColumnItem; |
| | | import com.iailab.module.model.mdk.sample.dto.SampleInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | |
| | | * @param predictTime |
| | | * @return |
| | | */ |
| | | protected SampleInfo prepareSampleInfo(String modelId, Date predictTime) { |
| | | protected SampleInfo prepareSampleInfo(String modelId, Date predictTime, Map<Integer, Integer> dynamicDataLength) { |
| | | //样本的列信息 |
| | | return getColumnInfo(modelId, predictTime); |
| | | return getColumnInfo(modelId, predictTime, dynamicDataLength); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param predictTime |
| | | * @return |
| | | */ |
| | | protected abstract SampleInfo getColumnInfo(String modelId, Date predictTime); |
| | | protected abstract SampleInfo getColumnInfo(String modelId, Date predictTime, Map<Integer, Integer> dynamicDataLength); |
| | | |
| | | /** |
| | | * 样本的采样周期 |
| | |
| | | calendar.add(Calendar.SECOND, timeLength * granularity); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | protected int getDataLength(Map<Integer, Integer> dynamicDataLength, Integer port, Integer dataLength) { |
| | | if (CollectionUtils.isEmpty(dynamicDataLength)) { |
| | | return dataLength; |
| | | } |
| | | if (dynamicDataLength.containsKey(port)) { |
| | | return dynamicDataLength.get(port); |
| | | } |
| | | return dataLength; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | protected SampleInfo getColumnInfo(String modelId, Date predictTime) { |
| | | protected SampleInfo getColumnInfo(String modelId, Date predictTime, Map<Integer, Integer> dynamicDataLength) { |
| | | SampleInfo sampleInfo = new SampleInfo(); |
| | | List<ColumnItemPort> resultList = new ArrayList<>(); |
| | | List<ColumnItem> columnItemList = new ArrayList<>(); |
| | |
| | | //设置当前端口号,初始值为最小端口(查询结果按端口号从小到达排列) |
| | | int curPortOrder = modelInputParamEntityList.get(0).getModelparamportorder(); |
| | | //设置当前查询数据长度,初始值为最小端口数据长度 |
| | | int curDataLength = modelInputParamEntityList.get(0).getDatalength(); |
| | | int curDataLength = super.getDataLength(dynamicDataLength, curPortOrder, modelInputParamEntityList.get(0).getDatalength()); |
| | | // 统一获取测点的信息 |
| | | Set<String> pointIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.DATAPOINT)).map(StScheduleModelParamEntity::getModelparamid).collect(Collectors.toSet()); |
| | | List<ApiPointDTO> points = dataPointApi.getInfoByIds(pointIds); |
| | |
| | | for (StScheduleModelParamEntity entry : modelInputParamEntityList) { |
| | | columnInfo.setParamType(entry.getModelparamtype()); |
| | | columnInfo.setParamId(entry.getModelparamid()); |
| | | columnInfo.setDataLength(entry.getDatalength()); |
| | | columnInfo.setDataLength(super.getDataLength(dynamicDataLength, entry.getModelparamportorder(), entry.getDatalength())); |
| | | columnInfo.setModelParamOrder(entry.getModelparamorder()); |
| | | columnInfo.setModelParamPortOrder(entry.getModelparamportorder()); |
| | | columnInfo.setStartTime(getStartTime(columnInfo, predictTime,pointMap,planMap)); |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | } |