提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mdk.predict.impl; |
潘 |
2 |
|
|
3 |
import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity; |
|
4 |
import com.iailab.module.model.mcs.pre.service.MmPredictModelService; |
|
5 |
import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException; |
|
6 |
import com.iailab.module.model.mdk.common.exceptions.ModelInvokeException; |
|
7 |
import com.iailab.module.model.mdk.predict.PredictItemHandler; |
|
8 |
import com.iailab.module.model.mdk.predict.PredictModelHandler; |
|
9 |
import com.iailab.module.model.mdk.vo.ItemVO; |
|
10 |
import com.iailab.module.model.mdk.vo.PredictResultVO; |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
import org.springframework.stereotype.Component; |
|
13 |
|
|
14 |
import java.text.MessageFormat; |
|
15 |
import java.util.Date; |
07890e
|
16 |
import java.util.Map; |
7fd198
|
17 |
|
潘 |
18 |
/** |
|
19 |
* @author PanZhibao |
|
20 |
* @Description |
|
21 |
* @createTime 2024年09月01日 |
|
22 |
*/ |
|
23 |
@Component |
|
24 |
public class PredictItemNormalHandlerImpl implements PredictItemHandler { |
|
25 |
|
|
26 |
@Autowired |
|
27 |
private MmPredictModelService mmPredictModelService; |
|
28 |
|
|
29 |
@Autowired |
|
30 |
private PredictModelHandler predictModelHandler; |
|
31 |
|
4f1717
|
32 |
/** |
潘 |
33 |
* NormalItem预测 |
|
34 |
* |
|
35 |
* @param predictTime |
|
36 |
* @param predictItemDto |
|
37 |
* @return |
|
38 |
* @throws ItemInvokeException |
|
39 |
*/ |
7fd198
|
40 |
@Override |
07890e
|
41 |
public PredictResultVO predict(Date predictTime, ItemVO predictItemDto, Map<String, double[]> predictValueMap) throws ItemInvokeException { |
7fd198
|
42 |
PredictResultVO predictResult = new PredictResultVO(); |
4f1717
|
43 |
String itemId = predictItemDto.getId(); |
7fd198
|
44 |
try { |
373ab1
|
45 |
MmPredictModelEntity predictModel = mmPredictModelService.getActiveModelByItemId(itemId); |
潘 |
46 |
if (predictModel == null) { |
7fd198
|
47 |
throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}", |
潘 |
48 |
ModelInvokeException.errorGetModelEntity, itemId)); |
|
49 |
} |
6957a3
|
50 |
predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName()); |
b82ba2
|
51 |
predictResult.setPredictId(itemId); |
7fd198
|
52 |
} catch (Exception ex) { |
潘 |
53 |
throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}", |
|
54 |
ItemInvokeException.errorItemFailed, itemId)); |
|
55 |
} |
4f1717
|
56 |
return predictResult; |
7fd198
|
57 |
} |
潘 |
58 |
} |