潘志宝
2025-02-25 b3674cefbeb8ffaf49f96d0c8fe7a6694ed86eec
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java
@@ -3,6 +3,7 @@
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;
@@ -55,7 +56,7 @@
     * @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");
@@ -72,7 +73,7 @@
            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) {
@@ -87,12 +88,7 @@
            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
@@ -157,18 +153,19 @@
     * @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);
@@ -178,7 +175,7 @@
            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) {
@@ -193,7 +190,7 @@
            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
@@ -247,6 +244,7 @@
        }
        return result;
    }
    /**
     * 构造IAILMDK.run()方法的newModelBean参数
     *