提交 | 用户 | 时间
|
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; |
|
16 |
|
|
17 |
/** |
|
18 |
* @author PanZhibao |
|
19 |
* @Description |
|
20 |
* @createTime 2024年09月01日 |
|
21 |
*/ |
|
22 |
@Component |
|
23 |
public class PredictItemNormalHandlerImpl implements PredictItemHandler { |
|
24 |
|
|
25 |
@Autowired |
|
26 |
private MmPredictModelService mmPredictModelService; |
|
27 |
|
|
28 |
@Autowired |
|
29 |
private PredictModelHandler predictModelHandler; |
|
30 |
|
4f1717
|
31 |
/** |
潘 |
32 |
* NormalItem预测 |
|
33 |
* |
|
34 |
* @param predictTime |
|
35 |
* @param predictItemDto |
|
36 |
* @return |
|
37 |
* @throws ItemInvokeException |
|
38 |
*/ |
7fd198
|
39 |
@Override |
373ab1
|
40 |
public PredictResultVO predict(Date predictTime, ItemVO predictItemDto) throws ItemInvokeException { |
7fd198
|
41 |
PredictResultVO predictResult = new PredictResultVO(); |
4f1717
|
42 |
String itemId = predictItemDto.getId(); |
7fd198
|
43 |
try { |
373ab1
|
44 |
MmPredictModelEntity predictModel = mmPredictModelService.getActiveModelByItemId(itemId); |
潘 |
45 |
if (predictModel == null) { |
7fd198
|
46 |
throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}", |
潘 |
47 |
ModelInvokeException.errorGetModelEntity, itemId)); |
|
48 |
} |
6957a3
|
49 |
predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName()); |
b82ba2
|
50 |
predictResult.setPredictId(itemId); |
7fd198
|
51 |
} catch (Exception ex) { |
潘 |
52 |
throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}", |
|
53 |
ItemInvokeException.errorItemFailed, itemId)); |
|
54 |
} |
4f1717
|
55 |
return predictResult; |
7fd198
|
56 |
} |
潘 |
57 |
} |