提交 | 用户 | 时间
|
45520a
|
1 |
package com.iailab.module.model.mdk.sample; |
D |
2 |
|
|
3 |
import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity; |
|
4 |
import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService; |
|
5 |
import com.iailab.module.model.mdk.sample.dto.ColumnItem; |
|
6 |
import com.iailab.module.model.mdk.sample.dto.ColumnItemPort; |
|
7 |
import org.springframework.beans.factory.annotation.Autowired; |
|
8 |
import org.springframework.stereotype.Component; |
|
9 |
import org.springframework.util.CollectionUtils; |
|
10 |
|
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.Date; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
@Component |
|
16 |
public class ScheduleSampleInfoConstructor extends SampleInfoConstructor { |
|
17 |
|
|
18 |
@Autowired |
|
19 |
private StScheduleModelParamService stScheduleModelParamService; |
|
20 |
|
|
21 |
@Override |
|
22 |
protected Integer getSampleColumn(String modelId) { |
|
23 |
return null; |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected List<ColumnItemPort> getColumnInfo(String modelId, Date predictTime) { |
|
28 |
List<ColumnItemPort> resultList = new ArrayList<>(); |
|
29 |
List<ColumnItem> columnItemList = new ArrayList<>(); |
|
30 |
ColumnItem columnInfo = new ColumnItem(); |
|
31 |
ColumnItemPort curPort = new ColumnItemPort(); //当前端口 |
|
32 |
List<StScheduleModelParamEntity> modelInputParamEntityList = stScheduleModelParamService.getByModelidFromCache(modelId); |
|
33 |
if (CollectionUtils.isEmpty(modelInputParamEntityList)) { |
|
34 |
return null; |
|
35 |
} |
|
36 |
//设置当前端口号,初始值为最小端口(查询结果按端口号从小到达排列) |
|
37 |
int curPortOrder = modelInputParamEntityList.get(0).getModelparamportorder(); |
|
38 |
//设置当前查询数据长度,初始值为最小端口数据长度 |
|
39 |
int curDataLength = modelInputParamEntityList.get(0).getDatalength(); |
|
40 |
for (StScheduleModelParamEntity entry : modelInputParamEntityList) { |
|
41 |
columnInfo.setParamType(entry.getModelparamtype()); |
|
42 |
columnInfo.setParamId(entry.getModelparamid()); |
|
43 |
columnInfo.setDataLength(entry.getDatalength()); |
|
44 |
columnInfo.setModelParamOrder(entry.getModelparamorder()); |
|
45 |
columnInfo.setModelParamPortOrder(entry.getModelparamportorder()); |
|
46 |
columnInfo.setStartTime(getStartTime(columnInfo, predictTime)); |
|
47 |
columnInfo.setEndTime(getEndTime(columnInfo, predictTime)); |
|
48 |
columnInfo.setGranularity(super.getGranularity(columnInfo)); |
|
49 |
|
|
50 |
//对每一个爪进行数据项归并 |
|
51 |
if (curPortOrder != entry.getModelparamportorder()){ |
|
52 |
//当数据项端口号不为当前端口号时,封装上一个端口类,操作下一个端口类 |
|
53 |
curPort.setColumnItemList(columnItemList); |
|
54 |
curPort.setDataLength(curDataLength); |
|
55 |
curPort.setPortOrder(curPortOrder); |
|
56 |
resultList.add(curPort); |
|
57 |
curPort = new ColumnItemPort(); //对象重新初始化,防止引用拷贝导致数据覆盖 |
|
58 |
//封装上一个端口类后更新当前的各个参数 |
|
59 |
columnItemList = new ArrayList<>(); |
|
60 |
curDataLength = entry.getDatalength(); |
|
61 |
curPortOrder = entry.getModelparamportorder(); |
|
62 |
} |
|
63 |
columnItemList.add(columnInfo); |
|
64 |
columnInfo = new ColumnItem(); //对象重新初始化,防止引用拷贝导致数据覆盖 |
|
65 |
} |
|
66 |
//当迭代到最后一个项的时候,封装最后一个端口的信息 |
|
67 |
curPort.setColumnItemList(columnItemList); |
|
68 |
curPort.setDataLength(curDataLength); |
|
69 |
curPort.setPortOrder(curPortOrder); |
|
70 |
resultList.add(curPort); |
|
71 |
return resultList; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
protected Integer getSampleCycle(String modelId) { |
|
76 |
return null; |
|
77 |
} |
|
78 |
|
|
79 |
} |