提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mdk.predict.impl; |
潘 |
2 |
|
50084d
|
3 |
import com.iailab.module.model.common.exception.ModelResultErrorException; |
7fd198
|
4 |
import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity; |
7f0bcd
|
5 |
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum; |
7fd198
|
6 |
import com.iailab.module.model.mcs.pre.service.MmPredictModelService; |
潘 |
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; |
b3674c
|
13 |
import com.iailab.module.model.mdk.vo.StAdjustDeviationDTO; |
7fd198
|
14 |
import org.springframework.beans.factory.annotation.Autowired; |
潘 |
15 |
import org.springframework.stereotype.Component; |
|
16 |
|
|
17 |
import java.text.MessageFormat; |
|
18 |
import java.util.Date; |
b3674c
|
19 |
import java.util.List; |
07890e
|
20 |
import java.util.Map; |
7fd198
|
21 |
|
潘 |
22 |
/** |
|
23 |
* @author PanZhibao |
|
24 |
* @Description |
|
25 |
* @createTime 2024年09月01日 |
|
26 |
*/ |
|
27 |
@Component |
|
28 |
public class PredictItemNormalHandlerImpl implements PredictItemHandler { |
|
29 |
|
|
30 |
@Autowired |
|
31 |
private MmPredictModelService mmPredictModelService; |
|
32 |
|
|
33 |
@Autowired |
|
34 |
private PredictModelHandler predictModelHandler; |
|
35 |
|
4f1717
|
36 |
/** |
潘 |
37 |
* NormalItem预测 |
|
38 |
* |
|
39 |
* @param predictTime |
|
40 |
* @param predictItemDto |
|
41 |
* @return |
|
42 |
* @throws ItemInvokeException |
|
43 |
*/ |
7fd198
|
44 |
@Override |
50084d
|
45 |
public PredictResultVO predict(Date predictTime, ItemVO predictItemDto, Map<String, double[]> predictValueMap) throws ItemInvokeException,ModelResultErrorException { |
7fd198
|
46 |
PredictResultVO predictResult = new PredictResultVO(); |
4f1717
|
47 |
String itemId = predictItemDto.getId(); |
7fd198
|
48 |
try { |
373ab1
|
49 |
MmPredictModelEntity predictModel = mmPredictModelService.getActiveModelByItemId(itemId); |
潘 |
50 |
if (predictModel == null) { |
7fd198
|
51 |
throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}", |
潘 |
52 |
ModelInvokeException.errorGetModelEntity, itemId)); |
|
53 |
} |
28c2db
|
54 |
predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName(),predictItemDto.getItemNo()); |
b82ba2
|
55 |
predictResult.setPredictId(itemId); |
50084d
|
56 |
} catch (ModelResultErrorException ex) { |
D |
57 |
throw ex; |
7fd198
|
58 |
} catch (Exception ex) { |
潘 |
59 |
throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}", |
|
60 |
ItemInvokeException.errorItemFailed, itemId)); |
|
61 |
} |
4f1717
|
62 |
return predictResult; |
7fd198
|
63 |
} |
b3674c
|
64 |
|
潘 |
65 |
/** |
|
66 |
* NormalItem预测 |
|
67 |
* |
|
68 |
* @param predictTime |
|
69 |
* @param predictItemDto |
|
70 |
* @return |
|
71 |
* @throws ItemInvokeException |
|
72 |
*/ |
|
73 |
@Override |
|
74 |
public PredictResultVO predictAdjust(Date predictTime, ItemVO predictItemDto, List<StAdjustDeviationDTO> deviationList) throws ItemInvokeException,ModelResultErrorException { |
|
75 |
PredictResultVO predictResult = new PredictResultVO(); |
|
76 |
String itemId = predictItemDto.getId(); |
|
77 |
try { |
|
78 |
MmPredictModelEntity predictModel = mmPredictModelService.getActiveModelByItemId(itemId); |
|
79 |
if (predictModel == null) { |
|
80 |
throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}", |
|
81 |
ModelInvokeException.errorGetModelEntity, itemId)); |
|
82 |
} |
|
83 |
predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName(),predictItemDto.getItemNo(), deviationList); |
|
84 |
predictResult.setPredictId(itemId); |
|
85 |
} catch (ModelResultErrorException ex) { |
|
86 |
throw ex; |
|
87 |
} catch (Exception ex) { |
|
88 |
throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}", |
|
89 |
ItemInvokeException.errorItemFailed, itemId)); |
|
90 |
} |
|
91 |
return predictResult; |
|
92 |
} |
7fd198
|
93 |
} |