Quellcode durchsuchen

修改新增或编辑时候对接口地址的写入

刘桐 vor 2 Wochen
Ursprung
Commit
cdd9609cf2

+ 25 - 0
xvji-admin/pom.xml

@@ -87,6 +87,31 @@
             <version>3.5.3.1</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- Spring Boot测试依赖 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope> <!-- 仅在测试环境生效 -->
+            <exclusions>
+                <!-- 排除冲突的依赖-->
+                <exclusion>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 58 - 14
xvji-admin/src/main/java/com/xvji/web/controller/PredictTaskController.java

@@ -96,7 +96,8 @@ public class PredictTaskController {
             if (dataAcquisition != null) {
                 Boolean isEnable = parseEnableValue(dataAcquisition.get("isEnable"), "数据获取");
                 String type = (String) dataAcquisition.get("componentType");
-                Component component = createComponent(taskId, type, dataAcquisition, isEnable);
+                String url = "http://ds3:10001/mysql_to_mongo";
+                Component component = createComponent(taskId, type, dataAcquisition, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -109,7 +110,8 @@ public class PredictTaskController {
             if (dataCleaning != null) {
                 Boolean isEnable = parseEnableValue(dataCleaning.get("isEnable"), "数据处理");
                 String type = (String) dataCleaning.get("componentType");
-                Component component = createComponent(taskId, type, dataCleaning, isEnable);
+                String url = "http://ds3:10013/pre_process";
+                Component component = createComponent(taskId, type, dataCleaning, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -122,7 +124,13 @@ public class PredictTaskController {
             if (powerRationing != null) {
                 Boolean isEnable = parseEnableValue(powerRationing.get("isEnable"), "限电清洗");
                 String type = (String) powerRationing.get("componentType");
-                Component component = createComponent(taskId, type, powerRationing, isEnable);
+                String url = "";
+                if ("限电清洗-光伏".equals(type)){
+                    url = "http://ds3:10008/processing_limit_power_by_statistics_light";
+                }else if ("限电清洗-风电".equals(type)){
+                    url = "http://ds3:10009/processing_limit_power_by_statistics_wind";
+                }
+                Component component = createComponent(taskId, type, powerRationing, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -135,7 +143,19 @@ public class PredictTaskController {
             if (model != null) {
                 Boolean isEnable = parseEnableValue(model.get("isEnable"), "模型");
                 String type = (String) model.get("componentType");
-                Component component = createComponent(taskId, type, model, isEnable);
+                String url = "";
+                if ("光伏物理模型".equals(type)){
+                    url = "http://ds3:10014/model_prediction_photovoltaic_physical";
+                }else if ("风电物理模型".equals(type)){
+                    url = "http://ds3:10014/model_prediction_wind_physical";
+                }else if ("Holtwinters模型".equals(type)){
+                    url = "http://ds3:10007/model_prediction_holtwinters";
+                }else if ("LSTM-预测".equals(type)){
+                    url = "http://ds3:10004/tf_lstm_predict";
+                }else if ("机器学习模型-预测".equals(type)){
+                    url = "http://ds3:10006/model_prediction_ml";
+                }
+                Component component = createComponent(taskId, type, model, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -148,7 +168,8 @@ public class PredictTaskController {
             if (postProcessing != null) {
                 Boolean isEnable = parseEnableValue(postProcessing.get("isEnable"), "后处理");
                 String type = (String) postProcessing.get("componentType");
-                Component component = createComponent(taskId, type, postProcessing, isEnable);
+                String url = "http://ds3:10013/post_process";
+                Component component = createComponent(taskId, type, postProcessing, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -161,7 +182,8 @@ public class PredictTaskController {
             if (analysisReport != null) {
                 Boolean isEnable = parseEnableValue(analysisReport.get("isEnable"), "分析报告");
                 String type = (String) analysisReport.get("componentType");
-                Component component = createComponent(taskId, type, analysisReport, isEnable);
+                String url = "http://ds1:10099/analysis_report_small";
+                Component component = createComponent(taskId, type, analysisReport, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -322,7 +344,8 @@ public class PredictTaskController {
             if (dataAcquisition != null) {
                 Boolean isEnable = parseEnableValue(dataAcquisition.get("isEnable"), "数据获取");
                 String type = (String) dataAcquisition.get("componentType");
-                Component component = createComponent(pTaskId, type, dataAcquisition, isEnable);
+                String url = "http://ds3:10001/mysql_to_mongo";
+                Component component = createComponent(pTaskId, type, dataAcquisition, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -335,7 +358,8 @@ public class PredictTaskController {
             if (dataCleaning != null) {
                 Boolean isEnable = parseEnableValue(dataCleaning.get("isEnable"), "数据处理");
                 String type = (String) dataCleaning.get("componentType");
-                Component component = createComponent(pTaskId, type, dataCleaning, isEnable);
+                String url = "http://ds3:10013/pre_process";
+                Component component = createComponent(pTaskId, type, dataCleaning, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -348,7 +372,13 @@ public class PredictTaskController {
             if (powerRationing != null) {
                 Boolean isEnable = parseEnableValue(powerRationing.get("isEnable"), "限电清洗");
                 String type = (String) powerRationing.get("componentType");
-                Component component = createComponent(pTaskId, type, powerRationing, isEnable);
+                String url = "";
+                if ("限电清洗-光伏".equals(type)){
+                    url = "http://ds3:10008/processing_limit_power_by_statistics_light";
+                }else if ("限电清洗-风电".equals(type)){
+                    url = "http://ds3:10009/processing_limit_power_by_statistics_wind";
+                }
+                Component component = createComponent(pTaskId, type, powerRationing, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -361,7 +391,19 @@ public class PredictTaskController {
             if (model != null) {
                 Boolean isEnable = parseEnableValue(model.get("isEnable"), "模型");
                 String type = (String) model.get("componentType");
-                Component component = createComponent(pTaskId, type, model, isEnable);
+                String url = "";
+                if ("光伏物理模型".equals(type)){
+                    url = "http://ds3:10014/model_prediction_photovoltaic_physical";
+                }else if ("风电物理模型".equals(type)){
+                    url = "http://ds3:10014/model_prediction_wind_physical";
+                }else if ("Holtwinters模型".equals(type)){
+                    url = "http://ds3:10007/model_prediction_holtwinters";
+                }else if ("LSTM-预测".equals(type)){
+                    url = "http://ds3:10004/tf_lstm_predict";
+                }else if ("机器学习模型-预测".equals(type)){
+                    url = "http://ds3:10006/model_prediction_ml";
+                }
+                Component component = createComponent(pTaskId, type, model, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -374,7 +416,8 @@ public class PredictTaskController {
             if (postProcessing != null) {
                 Boolean isEnable = parseEnableValue(postProcessing.get("isEnable"), "后处理");
                 String type = (String) postProcessing.get("componentType");
-                Component component = createComponent(pTaskId, type, postProcessing, isEnable);
+                String url = "http://ds3:10013/post_process";
+                Component component = createComponent(pTaskId, type, postProcessing, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -387,7 +430,8 @@ public class PredictTaskController {
             if (analysisReport != null) {
                 Boolean isEnable = parseEnableValue(analysisReport.get("isEnable"), "分析报告");
                 String type = (String) analysisReport.get("componentType");
-                Component component = createComponent(pTaskId, type, analysisReport, isEnable);
+                String url = "http://ds1:10099/analysis_report_small";
+                Component component = createComponent(pTaskId, type, analysisReport, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -417,14 +461,14 @@ public class PredictTaskController {
     /**
      * 辅助方法:创建组件对象
      */
-    private Component createComponent(Long taskId, String componentType, Map<String, Object> config, Boolean isEnable) {
+    private Component createComponent(Long taskId, String componentType, Map<String, Object> config, Boolean isEnable , String url) {
         Component component = new Component();
         component.setTaskId(taskId);         // 关联当前预测任务 ID
         component.setTaskType(1);            // 1-预测任务(固定标识)
         component.setComponentType(componentType);
         component.setParamsMap((Map<String, Object>) config.get("params"));
         component.setIsEnable(isEnable);     // 使用解析后的enable值
-        component.setInterfaceUrl((String) config.get("interfaceUrl"));
+        component.setInterfaceUrl(url); // 接口地址
 
         return component;
     }

+ 68 - 16
xvji-admin/src/main/java/com/xvji/web/controller/TrainTaskController.java

@@ -101,7 +101,8 @@ public class TrainTaskController {
             if (dataAcquisition != null) {
                 Boolean isEnable = parseEnableValue(dataAcquisition.get("isEnable"), "数据获取");
                 String type = (String) dataAcquisition.get("componentType");
-                Component component = createComponent(taskId, type, dataAcquisition, isEnable);
+                String url = "http://ds3:10001/mysql_to_mongo";
+                Component component = createComponent(taskId, type, dataAcquisition, isEnable ,url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -114,7 +115,8 @@ public class TrainTaskController {
             if (dataCleaning != null) {
                 Boolean isEnable = parseEnableValue(dataCleaning.get("isEnable"), "数据处理");
                 String type = (String) dataCleaning.get("componentType");
-                Component component = createComponent(taskId, type, dataCleaning, isEnable);
+                String url = "http://ds3:10013/pre_process";
+                Component component = createComponent(taskId, type, dataCleaning, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -127,7 +129,13 @@ public class TrainTaskController {
             if (powerRationing != null) {
                 Boolean isEnable = parseEnableValue(powerRationing.get("isEnable"), "限电清洗");
                 String type = (String) powerRationing.get("componentType");
-                Component component = createComponent(taskId, type, powerRationing, isEnable);
+                String url = "";
+                if ("限电清洗-光伏".equals(type)){
+                    url = "http://ds3:10008/processing_limit_power_by_statistics_light";
+                }else if ("限电清洗-风电".equals(type)){
+                    url = "http://ds3:10009/processing_limit_power_by_statistics_wind";
+                }
+                Component component = createComponent(taskId, type, powerRationing, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -140,7 +148,19 @@ public class TrainTaskController {
             if (model != null) {
                 Boolean modelIsEnable = parseEnableValue(model.get("isEnable"), "模型");
                 String modelType = (String) model.get("componentType");
-                Component modelComponent = createComponent(taskId, modelType, model, modelIsEnable);
+                String url = "";
+                if ("光伏物理模型".equals(modelType)){
+                    url = "http://ds3:10014/model_prediction_photovoltaic_physical";
+                }else if ("风电物理模型".equals(modelType)){
+                    url = "http://ds3:10014/model_prediction_wind_physical";
+                }else if ("Holtwinters模型".equals(modelType)){
+                    url = "http://ds3:10007/model_prediction_holtwinters";
+                }else if ("LSTM-训练".equals(modelType)){
+                    url = "http://ds3:10003/tf_lstm_training";
+                }else if ("机器学习模型-训练".equals(modelType)){
+                    url = "http://ds3:10005/model_training_ml";
+                }
+                Component modelComponent = createComponent(taskId, modelType, model, modelIsEnable,url);
                 if (componentService.save(modelComponent)) {
                     componentIds.add(modelComponent.getComponentId());
 
@@ -150,7 +170,8 @@ public class TrainTaskController {
                         if (modelTest != null) {
                             Boolean testIsEnable = parseEnableValue(modelTest.get("isEnable"), "模型测试");
                             String testType = (String) modelTest.get("componentType");
-                            Component testComponent = createComponent(taskId, testType, modelTest, testIsEnable);
+                            //暂无测试模型接口
+                            Component testComponent = createComponent(taskId, testType, modelTest, testIsEnable , url);
                             if (componentService.save(testComponent)) {
                                 componentIds.add(testComponent.getComponentId());
                             } else {
@@ -168,7 +189,8 @@ public class TrainTaskController {
             if (postProcessing != null) {
                 Boolean isEnable = parseEnableValue(postProcessing.get("isEnable"), "后处理");
                 String type = (String) postProcessing.get("componentType");
-                Component component = createComponent(taskId, type, postProcessing, isEnable);
+                String url = "http://ds3:10013/post_process";
+                Component component = createComponent(taskId, type, postProcessing, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -181,7 +203,8 @@ public class TrainTaskController {
             if (analysisReport != null) {
                 Boolean isEnable = parseEnableValue(analysisReport.get("isEnable"), "分析报告");
                 String type = (String) analysisReport.get("componentType");
-                Component component = createComponent(taskId, type, analysisReport, isEnable);
+                String url = "http://ds1:10099/analysis_report_small";
+                Component component = createComponent(taskId, type, analysisReport, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -342,7 +365,8 @@ public class TrainTaskController {
             if (dataAcquisition != null) {
                 Boolean isEnable = parseEnableValue(dataAcquisition.get("isEnable"), "数据获取");
                 String type = (String) dataAcquisition.get("componentType");
-                Component component = createComponent(tTaskId, type, dataAcquisition, isEnable);
+                String url = "http://ds3:10001/mysql_to_mongo";
+                Component component = createComponent(tTaskId, type, dataAcquisition, isEnable ,url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -355,7 +379,8 @@ public class TrainTaskController {
             if (dataCleaning != null) {
                 Boolean isEnable = parseEnableValue(dataCleaning.get("isEnable"), "数据处理");
                 String type = (String) dataCleaning.get("componentType");
-                Component component = createComponent(tTaskId, type, dataCleaning, isEnable);
+                String url = "http://ds3:10013/pre_process";
+                Component component = createComponent(tTaskId, type, dataCleaning, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -368,7 +393,13 @@ public class TrainTaskController {
             if (powerRationing != null) {
                 Boolean isEnable = parseEnableValue(powerRationing.get("isEnable"), "限电清洗");
                 String type = (String) powerRationing.get("componentType");
-                Component component = createComponent(tTaskId, type, powerRationing, isEnable);
+                String url = "";
+                if ("限电清洗-光伏".equals(type)){
+                    url = "http://ds3:10008/processing_limit_power_by_statistics_light";
+                }else if ("限电清洗-风电".equals(type)){
+                    url = "http://ds3:10009/processing_limit_power_by_statistics_wind";
+                }
+                Component component = createComponent(tTaskId, type, powerRationing, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -381,7 +412,19 @@ public class TrainTaskController {
             if (model != null) {
                 Boolean modelIsEnable = parseEnableValue(model.get("isEnable"), "模型");
                 String modelType = (String) model.get("componentType");
-                Component modelComponent = createComponent(tTaskId, modelType, model, modelIsEnable);
+                String url = "";
+                if ("光伏物理模型".equals(modelType)){
+                    url = "http://ds3:10014/model_prediction_photovoltaic_physical";
+                }else if ("风电物理模型".equals(modelType)){
+                    url = "http://ds3:10014/model_prediction_wind_physical";
+                }else if ("Holtwinters模型".equals(modelType)){
+                    url = "http://ds3:10007/model_prediction_holtwinters";
+                }else if ("LSTM-训练".equals(modelType)){
+                    url = "http://ds3:10003/tf_lstm_training";
+                }else if ("机器学习模型-训练".equals(modelType)){
+                    url = "http://ds3:10005/model_training_ml";
+                }
+                Component modelComponent = createComponent(tTaskId, modelType, model, modelIsEnable,url);
                 if (componentService.save(modelComponent)) {
                     componentIds.add(modelComponent.getComponentId());
 
@@ -391,7 +434,8 @@ public class TrainTaskController {
                         if (modelTest != null) {
                             Boolean testIsEnable = parseEnableValue(modelTest.get("isEnable"), "模型测试");
                             String testType = (String) modelTest.get("componentType");
-                            Component testComponent = createComponent(tTaskId, testType, modelTest, testIsEnable);
+                            //暂无测试模型接口
+                            Component testComponent = createComponent(tTaskId, testType, modelTest, testIsEnable , url);
                             if (componentService.save(testComponent)) {
                                 componentIds.add(testComponent.getComponentId());
                             } else {
@@ -409,7 +453,11 @@ public class TrainTaskController {
             if (postProcessing != null) {
                 Boolean isEnable = parseEnableValue(postProcessing.get("isEnable"), "后处理");
                 String type = (String) postProcessing.get("componentType");
-                Component component = createComponent(tTaskId, type, postProcessing, isEnable);
+                String url = "";
+                if ("后处理".equals(type)){
+                    url = "http://ds3:10013/post_process";
+                }
+                Component component = createComponent(tTaskId, type, postProcessing, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -422,7 +470,11 @@ public class TrainTaskController {
             if (analysisReport != null) {
                 Boolean isEnable = parseEnableValue(analysisReport.get("isEnable"), "分析报告");
                 String type = (String) analysisReport.get("componentType");
-                Component component = createComponent(tTaskId, type, analysisReport, isEnable);
+                String url = "";
+                if ("分析报告".equals(type)){
+                    url = "http://ds1:10099/analysis_report_small";
+                }
+                Component component = createComponent(tTaskId, type, analysisReport, isEnable , url);
                 if (componentService.save(component)) {
                     componentIds.add(component.getComponentId());
                 } else {
@@ -451,14 +503,14 @@ public class TrainTaskController {
     /**
      * 使用解析后的isEnable,删除错误强转
      */
-    private Component createComponent(Long taskId, String componentType, Map<String, Object> config, Boolean isEnable) {
+    private Component createComponent(Long taskId, String componentType, Map<String, Object> config, Boolean isEnable , String url) {
         Component component = new Component();
         component.setTaskId(taskId);
         component.setTaskType(0); // 训练任务固定标识
         component.setComponentType(componentType);
         component.setParamsMap((Map<String, Object>) config.get("params")); // 组件参数
         component.setIsEnable(isEnable); // 仅使用解析后的isEnable值,无强转
-        component.setInterfaceUrl((String) config.get("interfaceUrl")); // 接口地址
+        component.setInterfaceUrl(url); // 接口地址
         return component;
     }