提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mdk.sample; |
潘 |
2 |
|
50084d
|
3 |
import com.iailab.module.model.mdk.common.exceptions.ModelInvokeException; |
6c2ff1
|
4 |
import com.iailab.module.model.mdk.sample.dto.ColumnItemPort; |
7fd198
|
5 |
import com.iailab.module.model.mdk.sample.dto.SampleData; |
潘 |
6 |
import com.iailab.module.model.mdk.sample.dto.SampleInfo; |
efdc38
|
7 |
import lombok.extern.slf4j.Slf4j; |
7fd198
|
8 |
import org.springframework.beans.factory.annotation.Autowired; |
潘 |
9 |
import org.springframework.stereotype.Component; |
6c2ff1
|
10 |
import org.springframework.util.CollectionUtils; |
7fd198
|
11 |
|
潘 |
12 |
import java.text.MessageFormat; |
|
13 |
import java.util.Date; |
|
14 |
import java.util.List; |
6c2ff1
|
15 |
import java.util.Map; |
7fd198
|
16 |
|
潘 |
17 |
/** |
|
18 |
* 样本构造 |
|
19 |
* |
|
20 |
* @author PanZhibao |
|
21 |
* @Description |
|
22 |
* @createTime 2024年09月03日 |
|
23 |
*/ |
efdc38
|
24 |
@Slf4j |
7fd198
|
25 |
@Component |
潘 |
26 |
public class SampleConstructor { |
|
27 |
|
|
28 |
@Autowired |
|
29 |
private SampleFactory sampleFactory; |
|
30 |
|
6c2ff1
|
31 |
public List<SampleData> constructSample(String typeA, String modelId, Date runTime,String itemName, Map<Integer, Integer> dynamicDataLength) throws ModelInvokeException { |
7fd198
|
32 |
try { |
潘 |
33 |
SampleInfoConstructor sampleInfoConstructor = sampleFactory.createSampleInfo(typeA, modelId); |
|
34 |
SampleInfo sampleInfo = sampleInfoConstructor.prepareSampleInfo(modelId, runTime); |
6c2ff1
|
35 |
if (!CollectionUtils.isEmpty(dynamicDataLength) && sampleInfo.getColumnInfo() != null) { |
潘 |
36 |
for(ColumnItemPort columnInfo : sampleInfo.getColumnInfo()) { |
|
37 |
if (!dynamicDataLength.containsKey(columnInfo.getPortOrder())) { |
|
38 |
continue; |
|
39 |
} |
|
40 |
columnInfo.setDataLength(dynamicDataLength.get(columnInfo.getPortOrder())); |
|
41 |
columnInfo.getColumnItemList().forEach(columnItem -> { |
|
42 |
columnItem.setDataLength(columnInfo.getDataLength()); |
|
43 |
}); |
|
44 |
} |
|
45 |
} |
eca625
|
46 |
SampleDataConstructor sampleDataConstructor = sampleFactory.createSampleData(typeA); |
7fd198
|
47 |
return sampleDataConstructor.prepareSampleData(sampleInfo); |
潘 |
48 |
} catch (Exception e) { |
c9dd12
|
49 |
e.printStackTrace(); |
efdc38
|
50 |
log.error("获取模型的算法参数异常",e); |
50084d
|
51 |
throw new ModelInvokeException(MessageFormat.format("{0},Name:{1}", |
D |
52 |
ModelInvokeException.errorGetModelArithParam, itemName)); |
7fd198
|
53 |
} |
潘 |
54 |
|
|
55 |
|
|
56 |
} |
|
57 |
} |