提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mdk.sample; |
潘 |
2 |
|
|
3 |
import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity; |
91343d
|
4 |
import com.iailab.module.model.mcs.pre.service.MmModelParamService; |
潘 |
5 |
import com.iailab.module.model.mcs.pre.service.MmPredictItemService; |
7fd198
|
6 |
import com.iailab.module.model.mcs.pre.service.MmPredictModelService; |
潘 |
7 |
import com.iailab.module.model.mdk.sample.dto.ColumnItem; |
|
8 |
import com.iailab.module.model.mdk.sample.dto.ColumnItemPort; |
|
9 |
import com.iailab.module.model.mdk.sample.dto.SampleInfo; |
|
10 |
import org.springframework.beans.factory.annotation.Autowired; |
|
11 |
import org.springframework.stereotype.Component; |
|
12 |
import org.springframework.util.CollectionUtils; |
|
13 |
|
|
14 |
import java.util.ArrayList; |
|
15 |
import java.util.Date; |
|
16 |
import java.util.List; |
|
17 |
|
|
18 |
/** |
|
19 |
* @author PanZhibao |
|
20 |
* @Description |
|
21 |
* @createTime 2024年09月03日 |
|
22 |
*/ |
|
23 |
@Component |
|
24 |
public class PredictSampleInfoConstructor extends SampleInfoConstructor { |
|
25 |
|
|
26 |
@Autowired |
|
27 |
private MmPredictModelService mmPredictModelService; |
|
28 |
|
|
29 |
@Autowired |
91343d
|
30 |
private MmModelParamService mmModelParamService; |
7fd198
|
31 |
|
潘 |
32 |
@Autowired |
91343d
|
33 |
private MmPredictItemService mmPredictItemService; |
7fd198
|
34 |
|
潘 |
35 |
@Override |
|
36 |
public SampleInfo prepareSampleInfo(String modelId, Date predictTime) { |
|
37 |
return super.prepareSampleInfo(modelId, predictTime); |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* 返回样本矩阵的列数 |
|
42 |
* |
|
43 |
* @param modelId |
|
44 |
* @return |
|
45 |
*/ |
|
46 |
@Override |
|
47 |
protected Integer getSampleColumn(String modelId) { |
|
48 |
return mmPredictModelService.getSampleLength(modelId).intValue(); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* 返回样本的开始时间 |
|
53 |
* |
|
54 |
* @param columnItem |
|
55 |
* @param predictTime |
|
56 |
* @return |
|
57 |
*/ |
|
58 |
@Override |
|
59 |
protected Date getStartTime(ColumnItem columnItem, Date predictTime) { |
|
60 |
return super.getStartTime(columnItem, predictTime); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* 返回样本的结束时间 |
|
65 |
* |
|
66 |
* @param columnItem |
|
67 |
* @param predictTime |
|
68 |
* @return |
|
69 |
*/ |
|
70 |
@Override |
|
71 |
protected Date getEndTime(ColumnItem columnItem, Date predictTime) { |
|
72 |
return super.getEndTime(columnItem, predictTime); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* 样本的列信息 |
|
77 |
* |
|
78 |
* @param modelId |
|
79 |
* @param predictTime |
|
80 |
* @return |
|
81 |
*/ |
|
82 |
@Override |
|
83 |
protected List<ColumnItemPort> getColumnInfo(String modelId, Date predictTime) { |
|
84 |
List<ColumnItemPort> resultList = new ArrayList<>(); |
|
85 |
List<ColumnItem> columnItemList = new ArrayList<>(); |
|
86 |
ColumnItem columnInfo = new ColumnItem(); |
|
87 |
ColumnItemPort curPort = new ColumnItemPort(); //当前端口 |
91343d
|
88 |
List<MmModelParamEntity> modelInputParamEntityList = mmModelParamService.getByModelidFromCatch(modelId); |
7fd198
|
89 |
if (CollectionUtils.isEmpty(modelInputParamEntityList)) { |
潘 |
90 |
return null; |
|
91 |
} |
|
92 |
//设置当前端口号,初始值为最小端口(查询结果按端口号从小到达排列) |
|
93 |
int curPortOrder = modelInputParamEntityList.get(0).getModelparamportorder(); |
|
94 |
//设置当前查询数据长度,初始值为最小端口数据长度 |
|
95 |
int curDataLength = modelInputParamEntityList.get(0).getDatalength(); |
|
96 |
for (MmModelParamEntity entry : modelInputParamEntityList) { |
|
97 |
columnInfo.setParamType(entry.getModelparamtype()); |
1a2b62
|
98 |
columnInfo.setParamId(entry.getModelparamid()); |
7fd198
|
99 |
columnInfo.setDataLength(entry.getDatalength()); |
潘 |
100 |
columnInfo.setModelParamOrder(entry.getModelparamorder()); |
|
101 |
columnInfo.setModelParamPortOrder(entry.getModelparamportorder()); |
|
102 |
columnInfo.setStartTime(getStartTime(columnInfo, predictTime)); |
|
103 |
columnInfo.setEndTime(getEndTime(columnInfo, predictTime)); |
|
104 |
columnInfo.setGranularity(super.getGranularity(columnInfo)); |
|
105 |
|
|
106 |
//对每一个爪进行数据项归并 |
|
107 |
if (curPortOrder != entry.getModelparamportorder()){ |
|
108 |
//当数据项端口号不为当前端口号时,封装上一个端口类,操作下一个端口类 |
|
109 |
curPort.setColumnItemList(columnItemList); |
|
110 |
curPort.setDataLength(curDataLength); |
|
111 |
curPort.setPortOrder(curPortOrder); |
|
112 |
resultList.add(curPort); |
|
113 |
curPort = new ColumnItemPort(); //对象重新初始化,防止引用拷贝导致数据覆盖 |
|
114 |
//封装上一个端口类后更新当前的各个参数 |
|
115 |
columnItemList = new ArrayList<>(); |
|
116 |
curDataLength = entry.getDatalength(); |
|
117 |
curPortOrder = entry.getModelparamportorder(); |
|
118 |
} |
|
119 |
columnItemList.add(columnInfo); |
|
120 |
columnInfo = new ColumnItem(); //对象重新初始化,防止引用拷贝导致数据覆盖 |
|
121 |
} |
|
122 |
//当迭代到最后一个项的时候,封装最后一个端口的信息 |
|
123 |
curPort.setColumnItemList(columnItemList); |
|
124 |
curPort.setDataLength(curDataLength); |
|
125 |
curPort.setPortOrder(curPortOrder); |
|
126 |
resultList.add(curPort); |
|
127 |
return resultList; |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* 样本的采样周期 |
|
132 |
* |
|
133 |
* @param modelId |
|
134 |
* @return |
|
135 |
*/ |
|
136 |
@Override |
|
137 |
protected Integer getSampleCycle(String modelId) { |
91343d
|
138 |
return mmPredictItemService.getItemById(mmPredictModelService.getInfoFromCatch(modelId).getItemid()).getGranularity(); |
7fd198
|
139 |
} |
潘 |
140 |
|
|
141 |
|
|
142 |
} |