| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.iail.model.IAILModel; |
| | | import com.iailab.module.model.mdk.vo.StAdjustDeviationDTO; |
| | | import com.iailab.module.model.enums.CommonConstant; |
| | | import com.iailab.module.model.common.enums.OutResultType; |
| | | import com.iailab.module.model.common.exception.ModelResultErrorException; |
| | |
| | | * @throws ModelInvokeException |
| | | */ |
| | | @Override |
| | | public synchronized PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName,String itemNo) throws ModelInvokeException { |
| | | public PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel, String itemName, String itemNo) throws ModelInvokeException { |
| | | PredictResultVO result = new PredictResultVO(); |
| | | if (predictModel == null) { |
| | | throw new ModelInvokeException("modelEntity is null"); |
| | |
| | | HashMap<String, Object> settings = getPredictSettingsByModelId(modelId); |
| | | // 校验setting必须有pyFile,否则可能导致程序崩溃 |
| | | if (!settings.containsKey(MdkConstant.PY_FILE_KEY)) { |
| | | throw new RuntimeException("模型设置参数缺少必要信息【" + MdkConstant.PY_FILE_KEY + "】,请重新上传模型!"); |
| | | throw new RuntimeException("模型设置参数缺少必要信息【" + MdkConstant.PY_FILE_KEY + "】,请重新上传模型!"); |
| | | } |
| | | |
| | | if (settings == null) { |
| | |
| | | param2Values[portLength] = newModelBean.getDataMap().get("models"); |
| | | param2Values[portLength + 1] = settings; |
| | | |
| | | log.info("####################### 预测模型 "+ "【itemId:" + predictModel.getItemid() + ",itemName:" + itemName + ",itemNo:" + itemNo + "】 ##########################"); |
| | | // JSONObject jsonObjNewModelBean = new JSONObject(); |
| | | // jsonObjNewModelBean.put("newModelBean", newModelBean); |
| | | // log.info(String.valueOf(jsonObjNewModelBean)); |
| | | // JSONObject jsonObjParam2Values = new JSONObject(); |
| | | // jsonObjParam2Values.put("param2Values", param2Values); |
| | | log.info("####################### 预测模型 " + "【itemId:" + predictModel.getItemid() + ",itemName:" + itemName + ",itemNo:" + itemNo + "】 ##########################"); |
| | | log.info("参数: " + JSON.toJSONString(param2Values)); |
| | | |
| | | //IAILMDK.run |
| | |
| | | * @param predictModel |
| | | * @param itemName |
| | | * @param itemNo |
| | | * @param deviationList |
| | | * @return |
| | | * @throws ModelInvokeException |
| | | */ |
| | | @Override |
| | | public synchronized PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName,String itemNo, double[][] deviation) throws ModelInvokeException { |
| | | public PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel, String itemName, String itemNo, List<StAdjustDeviationDTO> deviationList) throws ModelInvokeException { |
| | | PredictResultVO result = new PredictResultVO(); |
| | | if (predictModel == null) { |
| | | throw new ModelInvokeException("modelEntity is null"); |
| | | } |
| | | String modelId = predictModel.getId(); |
| | | try { |
| | | List<SampleData> sampleDataList = sampleConstructor.constructSample(TypeA.Predict.name(), modelId, predictTime, itemName, new HashMap<>()); |
| | | List<SampleData> sampleDataList = sampleConstructor.constructSample(TypeA.Predict.name(), modelId, predictTime, itemName, new HashMap<>(), deviationList); |
| | | String modelPath = predictModel.getModelpath(); |
| | | if (modelPath == null) { |
| | | log.info("模型路径不存在,modelId=" + modelId); |
| | |
| | | HashMap<String, Object> settings = getPredictSettingsByModelId(modelId); |
| | | // 校验setting必须有pyFile,否则可能导致程序崩溃 |
| | | if (!settings.containsKey(MdkConstant.PY_FILE_KEY)) { |
| | | throw new RuntimeException("模型设置参数缺少必要信息【" + MdkConstant.PY_FILE_KEY + "】,请重新上传模型!"); |
| | | throw new RuntimeException("模型设置参数缺少必要信息【" + MdkConstant.PY_FILE_KEY + "】,请重新上传模型!"); |
| | | } |
| | | |
| | | if (settings == null) { |
| | |
| | | param2Values[portLength] = newModelBean.getDataMap().get("models"); |
| | | param2Values[portLength + 1] = settings; |
| | | |
| | | log.info("####################### 模拟调整 "+ "【itemId:" + predictModel.getItemid() + ",itemName:" + itemName + ",itemNo:" + itemNo + "】 ##########################"); |
| | | log.info("####################### 模拟调整 " + "【itemId:" + predictModel.getItemid() + ",itemName:" + itemName + ",itemNo:" + itemNo + "】 ##########################"); |
| | | log.info("参数: " + JSON.toJSONString(param2Values)); |
| | | |
| | | //IAILMDK.run |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 构造IAILMDK.run()方法的newModelBean参数 |
| | | * |