提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mdk.predict.impl; |
潘 |
2 |
|
|
3 |
import com.iailab.framework.common.util.collection.CollectionUtils; |
|
4 |
import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity; |
|
5 |
import com.iailab.module.model.mcs.pre.service.MmPredictModelService; |
|
6 |
import com.iailab.module.model.mdk.common.enums.ItemPredictStatus; |
|
7 |
import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException; |
|
8 |
import com.iailab.module.model.mdk.common.exceptions.ModelInvokeException; |
|
9 |
import com.iailab.module.model.mdk.predict.PredictItemHandler; |
|
10 |
import com.iailab.module.model.mdk.predict.PredictModelHandler; |
|
11 |
import com.iailab.module.model.mdk.vo.ItemVO; |
|
12 |
import com.iailab.module.model.mdk.vo.PredictResultVO; |
|
13 |
import org.springframework.beans.factory.annotation.Autowired; |
|
14 |
import org.springframework.stereotype.Component; |
|
15 |
|
|
16 |
import java.sql.Timestamp; |
|
17 |
import java.text.MessageFormat; |
|
18 |
import java.util.ArrayList; |
|
19 |
import java.util.Calendar; |
|
20 |
import java.util.Date; |
|
21 |
import java.util.List; |
|
22 |
|
|
23 |
/** |
|
24 |
* @author PanZhibao |
|
25 |
* @Description |
|
26 |
* @createTime 2024年09月01日 |
|
27 |
*/ |
|
28 |
@Component |
|
29 |
public class PredictItemNormalHandlerImpl implements PredictItemHandler { |
|
30 |
|
|
31 |
@Autowired |
|
32 |
private MmPredictModelService mmPredictModelService; |
|
33 |
|
|
34 |
@Autowired |
|
35 |
private PredictModelHandler predictModelHandler; |
|
36 |
|
4f1717
|
37 |
/** |
潘 |
38 |
* NormalItem预测 |
|
39 |
* |
|
40 |
* @param predictTime |
|
41 |
* @param predictItemDto |
|
42 |
* @return |
|
43 |
* @throws ItemInvokeException |
|
44 |
*/ |
7fd198
|
45 |
@Override |
ead005
|
46 |
public PredictResultVO predict(Date predictTime, ItemVO predictItemDto) throws ItemInvokeException{ |
7fd198
|
47 |
PredictResultVO predictResult = new PredictResultVO(); |
4f1717
|
48 |
String itemId = predictItemDto.getId(); |
潘 |
49 |
predictResult.setPredictId(itemId); |
7fd198
|
50 |
try { |
潘 |
51 |
// 获取预测项模型 |
|
52 |
List<MmPredictModelEntity> predictModelList = mmPredictModelService.getActiveModelByItemId(itemId); |
|
53 |
if (CollectionUtils.isAnyEmpty(predictModelList)) { |
|
54 |
throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}", |
|
55 |
ModelInvokeException.errorGetModelEntity, itemId)); |
|
56 |
} |
4f1717
|
57 |
MmPredictModelEntity predictModel = predictModelList.get(0); |
潘 |
58 |
predictResult = predictModelHandler.predictByModel(predictTime, predictModel); |
7fd198
|
59 |
} catch (Exception ex) { |
潘 |
60 |
ex.printStackTrace(); |
|
61 |
//预测项预测失败的状态 |
|
62 |
throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}", |
|
63 |
ItemInvokeException.errorItemFailed, itemId)); |
|
64 |
} |
4f1717
|
65 |
return predictResult; |
7fd198
|
66 |
} |
潘 |
67 |
} |