提交 | 用户 | 时间
|
45520a
|
1 |
package com.iailab.module.model.mdk.sample; |
D |
2 |
|
75a848
|
3 |
import com.iailab.module.data.api.ind.IndItemApi; |
D |
4 |
import com.iailab.module.data.api.ind.dto.ApiIndItemDTO; |
8bf553
|
5 |
import com.iailab.module.data.api.plan.PlanItemApi; |
D |
6 |
import com.iailab.module.data.api.plan.dto.ApiPlanItemDTO; |
07890e
|
7 |
import com.iailab.module.data.api.point.DataPointApi; |
D |
8 |
import com.iailab.module.data.api.point.dto.ApiPointDTO; |
75a848
|
9 |
import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity; |
45520a
|
10 |
import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity; |
D |
11 |
import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService; |
07890e
|
12 |
import com.iailab.module.model.mdk.common.enums.ModelParamType; |
45520a
|
13 |
import com.iailab.module.model.mdk.sample.dto.ColumnItem; |
D |
14 |
import com.iailab.module.model.mdk.sample.dto.ColumnItemPort; |
50084d
|
15 |
import com.iailab.module.model.mdk.sample.dto.SampleInfo; |
45520a
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
D |
17 |
import org.springframework.stereotype.Component; |
|
18 |
import org.springframework.util.CollectionUtils; |
|
19 |
|
50084d
|
20 |
import java.util.*; |
07890e
|
21 |
import java.util.function.Function; |
D |
22 |
import java.util.stream.Collectors; |
45520a
|
23 |
|
D |
24 |
@Component |
|
25 |
public class ScheduleSampleInfoConstructor extends SampleInfoConstructor { |
|
26 |
|
|
27 |
@Autowired |
|
28 |
private StScheduleModelParamService stScheduleModelParamService; |
07890e
|
29 |
|
D |
30 |
@Autowired |
|
31 |
private DataPointApi dataPointApi; |
8bf553
|
32 |
|
D |
33 |
@Autowired |
|
34 |
private PlanItemApi planItemApi; |
75a848
|
35 |
|
D |
36 |
@Autowired |
|
37 |
private IndItemApi indItemApi; |
45520a
|
38 |
|
D |
39 |
@Override |
|
40 |
protected Integer getSampleColumn(String modelId) { |
|
41 |
return null; |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
bab433
|
45 |
protected SampleInfo getColumnInfo(String modelId, Date predictTime, Map<Integer, Integer> dynamicDataLength) { |
50084d
|
46 |
SampleInfo sampleInfo = new SampleInfo(); |
45520a
|
47 |
List<ColumnItemPort> resultList = new ArrayList<>(); |
D |
48 |
List<ColumnItem> columnItemList = new ArrayList<>(); |
|
49 |
ColumnItem columnInfo = new ColumnItem(); |
|
50 |
ColumnItemPort curPort = new ColumnItemPort(); //当前端口 |
|
51 |
List<StScheduleModelParamEntity> modelInputParamEntityList = stScheduleModelParamService.getByModelidFromCache(modelId); |
|
52 |
if (CollectionUtils.isEmpty(modelInputParamEntityList)) { |
|
53 |
return null; |
|
54 |
} |
|
55 |
//设置当前端口号,初始值为最小端口(查询结果按端口号从小到达排列) |
|
56 |
int curPortOrder = modelInputParamEntityList.get(0).getModelparamportorder(); |
|
57 |
//设置当前查询数据长度,初始值为最小端口数据长度 |
bab433
|
58 |
int curDataLength = super.getDataLength(dynamicDataLength, curPortOrder, modelInputParamEntityList.get(0).getDatalength()); |
07890e
|
59 |
// 统一获取测点的信息 |
50084d
|
60 |
Set<String> pointIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.DATAPOINT)).map(StScheduleModelParamEntity::getModelparamid).collect(Collectors.toSet()); |
07890e
|
61 |
List<ApiPointDTO> points = dataPointApi.getInfoByIds(pointIds); |
D |
62 |
Map<String, ApiPointDTO> pointMap = points.stream().collect(Collectors.toMap(ApiPointDTO::getId, Function.identity())); |
8bf553
|
63 |
// 统一获取计划数据的信息 |
D |
64 |
Set<String> planIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.PLAN)).map(StScheduleModelParamEntity::getModelparamid).collect(Collectors.toSet()); |
|
65 |
List<ApiPlanItemDTO> plans = planItemApi.getInfoByIds(planIds); |
f853b0
|
66 |
Map<String, ApiPlanItemDTO> planMap = plans.stream().collect(Collectors.toMap(ApiPlanItemDTO::getId, Function.identity(), (e1, e2) -> e1)); |
75a848
|
67 |
// 统一获取指标数据的信息 |
1ab119
|
68 |
Set<String> indIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.IND) || ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.IND_ASCII)).map(StScheduleModelParamEntity::getModelparamid).collect(Collectors.toSet()); |
75a848
|
69 |
List<ApiIndItemDTO> inds = indItemApi.getInfoByIds(indIds); |
D |
70 |
Map<String, ApiIndItemDTO> indMap = inds.stream().collect(Collectors.toMap(ApiIndItemDTO::getId, Function.identity(), (e1, e2) -> e1)); |
07890e
|
71 |
|
45520a
|
72 |
for (StScheduleModelParamEntity entry : modelInputParamEntityList) { |
D |
73 |
columnInfo.setParamType(entry.getModelparamtype()); |
|
74 |
columnInfo.setParamId(entry.getModelparamid()); |
bab433
|
75 |
columnInfo.setDataLength(super.getDataLength(dynamicDataLength, entry.getModelparamportorder(), entry.getDatalength())); |
45520a
|
76 |
columnInfo.setModelParamOrder(entry.getModelparamorder()); |
D |
77 |
columnInfo.setModelParamPortOrder(entry.getModelparamportorder()); |
75a848
|
78 |
columnInfo.setGranularity(super.getGranularity(columnInfo, pointMap, planMap,indMap)); |
e691b9
|
79 |
columnInfo.setStartTime(getStartTime(columnInfo, predictTime)); |
D |
80 |
columnInfo.setEndTime(getEndTime(columnInfo, predictTime)); |
45520a
|
81 |
|
D |
82 |
//对每一个爪进行数据项归并 |
f853b0
|
83 |
if (curPortOrder != entry.getModelparamportorder()) { |
45520a
|
84 |
//当数据项端口号不为当前端口号时,封装上一个端口类,操作下一个端口类 |
D |
85 |
curPort.setColumnItemList(columnItemList); |
|
86 |
curPort.setDataLength(curDataLength); |
|
87 |
curPort.setPortOrder(curPortOrder); |
|
88 |
resultList.add(curPort); |
|
89 |
curPort = new ColumnItemPort(); //对象重新初始化,防止引用拷贝导致数据覆盖 |
|
90 |
//封装上一个端口类后更新当前的各个参数 |
|
91 |
columnItemList = new ArrayList<>(); |
4d7e3b
|
92 |
curDataLength = super.getDataLength(dynamicDataLength, entry.getModelparamportorder(), entry.getDatalength()); |
45520a
|
93 |
curPortOrder = entry.getModelparamportorder(); |
D |
94 |
} |
|
95 |
columnItemList.add(columnInfo); |
|
96 |
columnInfo = new ColumnItem(); //对象重新初始化,防止引用拷贝导致数据覆盖 |
|
97 |
} |
|
98 |
//当迭代到最后一个项的时候,封装最后一个端口的信息 |
|
99 |
curPort.setColumnItemList(columnItemList); |
|
100 |
curPort.setDataLength(curDataLength); |
|
101 |
curPort.setPortOrder(curPortOrder); |
|
102 |
resultList.add(curPort); |
50084d
|
103 |
sampleInfo.setColumnInfo(resultList); |
D |
104 |
sampleInfo.setPointMap(pointMap); |
8bf553
|
105 |
sampleInfo.setPlanMap(planMap); |
75a848
|
106 |
sampleInfo.setIndMap(indMap); |
50084d
|
107 |
return sampleInfo; |
45520a
|
108 |
} |
D |
109 |
|
|
110 |
@Override |
|
111 |
protected Integer getSampleCycle(String modelId) { |
|
112 |
return null; |
|
113 |
} |
bab433
|
114 |
|
潘 |
115 |
|
45520a
|
116 |
} |