From 0b1597963209137dcb2bf998102230ac552e9c33 Mon Sep 17 00:00:00 2001 From: Jiale Date: Mon, 23 Jun 2025 09:17:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor(alert):=20=E4=BC=98=E5=8C=96=20EXA?= =?UTF-8?q?=20=E6=9C=8D=E5=8A=A1=20IP=20=E5=B9=B6=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E6=A8=A1=E5=9E=8B=E8=AE=BE=E7=BD=AE=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 EXA 服务 IP 地址为47.98.32.148 - 修正报警模型设置的默认条件为 "1==1" - 优化 EXAUtils 类中的方法,提高代码可读性和维护性 - 更新 ModelController 中的请求参数注解 - 调整 ModelServiceImpl 中的模型训练逻辑 -为 ModelTestParam 类添加 JSON别名注解 - 修正 TrainParam 类中的字段名称和类型 --- .../admin/model/ModelController.java | 2 +- .../admin/model/model/ModelInfo.java | 2 +- .../module/alert/param/ModelTestParam.java | 7 ++++ .../yudao/module/alert/param/TrainParam.java | 7 ++-- .../service/model/impl/ModelServiceImpl.java | 12 +++--- .../yudao/module/alert/utils/EXAUtils.java | 37 +++++++++---------- .../src/main/resources/application-local.yaml | 2 +- 7 files changed, 37 insertions(+), 32 deletions(-) diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/ModelController.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/ModelController.java index 8fe0eb2..e9f2999 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/ModelController.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/ModelController.java @@ -63,7 +63,7 @@ public class ModelController { } @PostMapping("/test") - public CommonResult getTestData(ModelTestParam param) { + public CommonResult getTestData(@RequestBody ModelTestParam param) { ModelTestData modelTestData = modelService.getModelTestData(param); return CommonResult.success(modelTestData); } diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/model/ModelInfo.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/model/ModelInfo.java index 8e0e826..6d5453a 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/model/ModelInfo.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/model/ModelInfo.java @@ -115,7 +115,7 @@ public class ModelInfo { private String alarmCondition; public static AlarmModelSet defaultInit() { - return new AlarmModelSet("全工况运行", "1=1"); + return new AlarmModelSet("全工况运行", "1==1"); } } diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/param/ModelTestParam.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/param/ModelTestParam.java index 52d3481..88c5329 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/param/ModelTestParam.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/param/ModelTestParam.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.alert.param; +import com.fasterxml.jackson.annotation.JsonAlias; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Data; @@ -12,7 +13,11 @@ import java.util.List; @NoArgsConstructor public class ModelTestParam { @JsonProperty("Test_Data") + @JsonAlias("Test_Data") private TestData testData; + + @JsonProperty("Model_id") + @JsonAlias("Model_id") private Integer modelId; private String version; @@ -24,8 +29,10 @@ public class ModelTestParam { private String points; private Integer interval; @JsonProperty("AddBias") + @JsonAlias("AddBias") private List addBias; @JsonProperty("AddBias_Time") + @JsonAlias("AddBias_Time") private String addBiasTime; } } diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/param/TrainParam.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/param/TrainParam.java index fc7ddaa..6878137 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/param/TrainParam.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/param/TrainParam.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.alert.param; -import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonAlias; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; @@ -21,16 +20,17 @@ public class TrainParam { @JsonProperty("Hyper_para") private HyperPara hyperPara; private String type; - private String condition; + private String conditon; @JsonAlias("smote_config") @JsonProperty("smote_config") - private String smoteConfig; + private List smoteConfig; private Boolean smote; private String targetPoint; + @Data public static class Smote { private String pointId; @@ -55,5 +55,6 @@ public class TrainParam { private String dead; private String limit; private String uplow; + private Integer interval; } } diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/impl/ModelServiceImpl.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/impl/ModelServiceImpl.java index 04e5bcb..961a9b7 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/impl/ModelServiceImpl.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/impl/ModelServiceImpl.java @@ -28,10 +28,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestBody; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -119,6 +116,7 @@ public class ModelServiceImpl implements ModelService { info.setName(model.getModelName()); info.setDescription(model.getDescription()); info.setRate(model.getRate()); + info.setTrainTime(new ArrayList<>()); modelCfg.setModelInfo(JsonUtils.toJsonString(info)); modelCfgService.updateById(modelCfg); return modelId; @@ -143,14 +141,14 @@ public class ModelServiceImpl implements ModelService { @Override public TrainInfo trainModel(TrainParam param) { - String trainBody = HttpUtils.post(algorithmHost + "/api/get_smote_data", null, JsonUtils.toJsonString(param)); + String trainBody = HttpUtils.post(algorithmHost + "/api/test/ClearTrain", null, JsonUtils.toJsonString(param)); if (trainBody.contains("error_msg")) { throw new RuntimeException("模型训练异常:" + JsonUtils.parseObject(trainBody, new TypeReference>() { }).get("error_msg")); } - return JsonUtils.parseObject(trainBody, new TypeReference>() { - }).get(0); + return JsonUtils.parseObject(trainBody, new TypeReference() { + }); } diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/utils/EXAUtils.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/utils/EXAUtils.java index 39940c3..73dba72 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/utils/EXAUtils.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/utils/EXAUtils.java @@ -1,6 +1,9 @@ package cn.iocoder.yudao.module.alert.utils; -import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.*; +import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.EXAHistoryReqVO; +import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.EXAHttp; +import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.EXAPageReqVO; +import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.Point; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.google.gson.Gson; @@ -11,14 +14,11 @@ import org.apache.http.client.fluent.Request; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; import org.apache.http.client.utils.URIBuilder; import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.springframework.beans.factory.annotation.Value; import java.io.IOException; import java.lang.reflect.Type; @@ -31,19 +31,18 @@ import java.util.List; public class EXAUtils { - /** * 根据分页条件和测点名称测点描述模糊查询 * * @param reqVO 传入对象,页数、页数量、查询条件 * @return exa列表 */ - public List getPointInfo(String EXA_IP,EXAPageReqVO reqVO) throws URISyntaxException, IOException { + public List getPointInfo(String EXA_IP, EXAPageReqVO reqVO) throws URISyntaxException, IOException { // PageResult result = new PageResult<>(); List exaListAll = new ArrayList(); try { // 目标 RPC 服务的 URL - String url = "http://"+EXA_IP+":9000/exawebapi/exaitem/getitems"; + String url = "http://" + EXA_IP + ":9000/exawebapi/exaitem/getitems"; //创建HttpClient对象 CloseableHttpClient httpClient = HttpClients.createDefault(); /* @@ -104,11 +103,11 @@ public class EXAUtils { * @return exa列表 */ - public List getNowData(String EXA_IP,String itemNames) throws URISyntaxException, IOException { + public List getNowData(String EXA_IP, String itemNames) throws URISyntaxException, IOException { List result = new ArrayList<>(); try { // 目标 RPC 服务的 URL - String url = "http://"+EXA_IP+":9000/exawebapi/exanow/getfloatvaluebatch"; + String url = "http://" + EXA_IP + ":9000/exawebapi/exanow/getfloatvaluebatch"; //创建HttpClient对象 CloseableHttpClient httpClient = HttpClients.createDefault(); /* @@ -154,12 +153,12 @@ public class EXAUtils { * @param exaHistoryReqVo 传入对象,点号、开始时间、结束时间 * @return exa列表 */ - public List> getHistory(String EXA_IP,EXAHistoryReqVO exaHistoryReqVo) { + public List> getHistory(String EXA_IP, EXAHistoryReqVO exaHistoryReqVo) { List> result = new ArrayList<>(); try { // 目标 RPC 服务的 URL // String url = "http://"+EXA_IP+":9000/exawebapi/exatime/GetRawValueArrayFloat"; - String url = "http://"+EXA_IP+":9000/exawebapi/exatime/GetSamplingValueArrayFloat"; + String url = "http://" + EXA_IP + ":9000/exawebapi/exatime/GetSamplingValueArrayFloat"; //创建HttpClient对象 @@ -173,7 +172,7 @@ public class EXAUtils { uriBuilder.addParameter("ItemName", exaHistoryReqVo.getItemName()); uriBuilder.addParameter("StartingTime", exaHistoryReqVo.getStartTime()); uriBuilder.addParameter("TerminalTime", exaHistoryReqVo.getEndTime()); - uriBuilder.addParameter("SamplingPeriod", String.valueOf(1000*exaHistoryReqVo.getInterval())); + uriBuilder.addParameter("SamplingPeriod", String.valueOf(1000 * exaHistoryReqVo.getInterval())); //创建请求对象 @@ -208,7 +207,7 @@ public class EXAUtils { return result; } - public List>> getHistorys(String EXA_IP,EXAHistoryReqVO exaHistoryReqVo) { + public List>> getHistorys(String EXA_IP, EXAHistoryReqVO exaHistoryReqVo) { List>> results = new ArrayList<>(); try { @@ -217,7 +216,7 @@ public class EXAUtils { pointName.forEach(entity -> { List> result = new ArrayList<>(); exaHistoryReqVo.setItemName(entity); - result = getHistory(EXA_IP,exaHistoryReqVo); + result = getHistory(EXA_IP, exaHistoryReqVo); results.add(result); }); } catch (Exception e) { @@ -227,8 +226,8 @@ public class EXAUtils { } //写入点号 - public String setPoint(String EXA_IP,Point point) throws IOException { - String requestPathAddItem = "http://"+EXA_IP+":9000/exawebapi/exaitem/AddItem"; + public String setPoint(String EXA_IP, Point point) throws IOException { + String requestPathAddItem = "http://" + EXA_IP + ":9000/exawebapi/exaitem/AddItem"; String param = JSON.toJSONString(point); String result = Request.Post(requestPathAddItem) .addHeader("Content-type", "application/json") @@ -245,7 +244,7 @@ public class EXAUtils { List result = new ArrayList<>(); try { // 目标 RPC 服务的 URL - String url = "http://"+EXA_IP+":9000/exawebapi/exagroup/getgroups"; + String url = "http://" + EXA_IP + ":9000/exawebapi/exagroup/getgroups"; //创建HttpClient对象 CloseableHttpClient httpClient = HttpClients.createDefault(); /* @@ -288,8 +287,8 @@ public class EXAUtils { return result; } - public String deletePoint(String EXA_IP,String ItemName){ - String requestPathDeleteItem ="http://"+EXA_IP+":9000/exawebapi/exaitem/DeleteItem?ItemName="+ItemName; + public String deletePoint(String EXA_IP, String ItemName) { + String requestPathDeleteItem = "http://" + EXA_IP + ":9000/exawebapi/exaitem/DeleteItem?ItemName=" + ItemName; // 创建HttpClient try (CloseableHttpClient httpClient = HttpClients.createDefault()) { // 创建HttpDelete请求 diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 3680358..ffff885 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -271,7 +271,7 @@ pf4j: # pluginsDir: /tmp/ pluginsDir: ../plugins EXA: - ip: 120.26.116.243 + ip: 47.98.32.148 point: head: XN. algorithm: -- 2.30.2 From e12db17bb85b85b938bcda5d86ef7be3292ef0d7 Mon Sep 17 00:00:00 2001 From: Jiale Date: Fri, 11 Jul 2025 18:57:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(module-alert):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E4=B8=8B=E6=9E=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ModelController 中添加 bottomModel 方法处理模型下架请求 - 在 ModelService 接口中定义 bottomModel 方法 - 实现在 ModelServiceImpl 中的 bottomModel 方法逻辑 - 新增 ModelVersion 实体类用于保存模型版本信息 - 创建 ModelVersionMapper 及其 XML 文件进行数据库操作 - 新增 ModelVersionService 接口及其实现类 - 优化 Point 类中的 limit 字段类型 --- .../admin/model/ModelController.java | 5 ++ .../controller/admin/model/model/Point.java | 2 +- .../module/alert/dao/domain/ModelVersion.java | 72 +++++++++++++++++++ .../alert/dao/mapper/ModelVersionMapper.java | 18 +++++ .../dao/service/ModelVersionService.java | 13 ++++ .../service/impl/ModelVersionServiceImpl.java | 22 ++++++ .../alert/service/model/ModelService.java | 2 + .../service/model/impl/ModelServiceImpl.java | 32 ++++++++- .../resources/mapper/ModelVersionMapper.xml | 48 +++++++++++++ 9 files changed, 210 insertions(+), 4 deletions(-) create mode 100644 yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/domain/ModelVersion.java create mode 100644 yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/mapper/ModelVersionMapper.java create mode 100644 yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/service/ModelVersionService.java create mode 100644 yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/service/impl/ModelVersionServiceImpl.java create mode 100644 yudao-module-alert/yudao-module-alert-biz/src/main/resources/mapper/ModelVersionMapper.xml diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/ModelController.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/ModelController.java index e9f2999..ea241a0 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/ModelController.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/ModelController.java @@ -67,4 +67,9 @@ public class ModelController { ModelTestData modelTestData = modelService.getModelTestData(param); return CommonResult.success(modelTestData); } + + @PostMapping("/bottom/{id}") + public CommonResult bottomModel(@PathVariable Integer id) { + return CommonResult.success(modelService.bottomModel(id)); + } } diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/model/Point.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/model/Point.java index 29d9695..5d360f9 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/model/Point.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/controller/admin/model/model/Point.java @@ -24,7 +24,7 @@ public class Point { @JsonProperty("Upper") private BigDecimal Upper; private Boolean dead; - private String limit; + private Boolean limit; private Boolean lock; /** * 残差下限 diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/domain/ModelVersion.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/domain/ModelVersion.java new file mode 100644 index 0000000..f54eeda --- /dev/null +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/domain/ModelVersion.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.alert.dao.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * @TableName model_version + */ +@TableName(value ="model_version") +@Data +public class ModelVersion implements Serializable { + private Integer id; + + private Integer modelId; + + private Integer algorithmId; + + private String modelName; + + private String createName; + + private String modelInfo; + + private Integer status; + + private Integer visible; + + private String conditionInfo; + + private Integer trash; + + private String assessRes; + + private Integer needToAssess; + + private Double score; + + private String clearOrNot; + + private Integer effNumber; + + private Integer needToClean; + + private String origAssessRes; + + private Double loadCover; + + private String coverOutput; + + private String version; + + private String conditionName; + + private Integer isOnline; + + private String creator; + + private Date createTime; + + private String updater; + + private Date updateTime; + + private Boolean deleted; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/mapper/ModelVersionMapper.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/mapper/ModelVersionMapper.java new file mode 100644 index 0000000..e71e457 --- /dev/null +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/mapper/ModelVersionMapper.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.alert.dao.mapper; + +import cn.iocoder.yudao.module.alert.dao.domain.ModelVersion; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author 陈小黑 +* @description 针对表【model_version】的数据库操作Mapper +* @createDate 2025-07-10 16:23:38 +* @Entity cn.iocoder.yudao.module.alert.dao.domain.ModelVersion +*/ +public interface ModelVersionMapper extends BaseMapper { + +} + + + + diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/service/ModelVersionService.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/service/ModelVersionService.java new file mode 100644 index 0000000..246ed07 --- /dev/null +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/service/ModelVersionService.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.alert.dao.service; + +import cn.iocoder.yudao.module.alert.dao.domain.ModelVersion; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author 陈小黑 +* @description 针对表【model_version】的数据库操作Service +* @createDate 2025-07-10 16:23:38 +*/ +public interface ModelVersionService extends IService { + +} diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/service/impl/ModelVersionServiceImpl.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/service/impl/ModelVersionServiceImpl.java new file mode 100644 index 0000000..2805d0a --- /dev/null +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/dao/service/impl/ModelVersionServiceImpl.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.alert.dao.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.iocoder.yudao.module.alert.dao.domain.ModelVersion; +import cn.iocoder.yudao.module.alert.dao.service.ModelVersionService; +import cn.iocoder.yudao.module.alert.dao.mapper.ModelVersionMapper; +import org.springframework.stereotype.Service; + +/** +* @author 陈小黑 +* @description 针对表【model_version】的数据库操作Service实现 +* @createDate 2025-07-10 16:23:38 +*/ +@Service +public class ModelVersionServiceImpl extends ServiceImpl + implements ModelVersionService{ + +} + + + + diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/ModelService.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/ModelService.java index 6bd1cce..4375a91 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/ModelService.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/ModelService.java @@ -48,4 +48,6 @@ public interface ModelService { TrainInfo trainModel(TrainParam param); ModelTestData getModelTestData(ModelTestParam param); + + ModelInfoVO bottomModel(Integer id); } diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/impl/ModelServiceImpl.java b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/impl/ModelServiceImpl.java index 961a9b7..2ba6a97 100644 --- a/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/impl/ModelServiceImpl.java +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/java/cn/iocoder/yudao/module/alert/service/model/impl/ModelServiceImpl.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.alert.service.model.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import cn.iocoder.yudao.framework.common.util.http.HttpUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; @@ -12,21 +13,24 @@ import cn.iocoder.yudao.module.alert.common.enums.ModelVisible; import cn.iocoder.yudao.module.alert.controller.admin.model.model.ModelInfo; import cn.iocoder.yudao.module.alert.controller.admin.model.vo.*; import cn.iocoder.yudao.module.alert.dao.domain.ModelCfg; +import cn.iocoder.yudao.module.alert.dao.domain.ModelVersion; import cn.iocoder.yudao.module.alert.dao.domain.SystemCfg; import cn.iocoder.yudao.module.alert.dao.service.ModelCfgService; +import cn.iocoder.yudao.module.alert.dao.service.ModelVersionService; import cn.iocoder.yudao.module.alert.dao.service.SystemCfgService; import cn.iocoder.yudao.module.alert.param.ModelTestParam; import cn.iocoder.yudao.module.alert.param.TrainParam; import cn.iocoder.yudao.module.alert.service.model.ModelService; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fasterxml.jackson.core.type.TypeReference; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestBody; import java.util.*; import java.util.stream.Collectors; @@ -44,6 +48,8 @@ public class ModelServiceImpl implements ModelService { private final SystemCfgService systemCfgService; + private final ModelVersionService modelVersionService; + @Value("${algorithm.host}") private String algorithmHost; @@ -147,16 +153,36 @@ public class ModelServiceImpl implements ModelService { new TypeReference>() { }).get("error_msg")); } - return JsonUtils.parseObject(trainBody, new TypeReference() { + return JsonUtils.parseObject(trainBody, new TypeReference<>() { }); } - @Override public ModelTestData getModelTestData(ModelTestParam param) { String result = HttpUtils.post(algorithmHost + "/api/test/Test", null, JsonUtils.toJsonString(param)) .replace("NaN", "-1").replace("Infinity", "1"); return JsonUtils.parseObject(result, ModelTestData.class); } + + @Override + @Transactional(rollbackFor = Exception.class) + public ModelInfoVO bottomModel(Integer id) { + ModelCfg modelCfg = modelCfgService.getById(id); + ModelInfoVO modelInfo = JSON.parseObject(modelCfg.getModelInfo(), ModelInfoVO.class); + modelInfo.setBtmState(ModelStatus.FINISH.desc); + modelInfo.setVersion("v-" + DateUtil.now()); + modelInfo.setModifier(SecurityFrameworkUtils.getLoginUserNickname()); + modelInfo.setModifiedTime(new Date()); + modelCfg.setModelInfo(JSON.toJSONString(modelInfo)); + modelCfg.setUpdateTime(new Date()); + modelCfg.setStatus(ModelStatus.FINISH.code); + modelCfgService.updateById(modelCfg); + + ModelVersion modelVersion = BeanUtil.copyProperties(modelCfg, ModelVersion.class); + modelVersion.setId(null); + modelVersion.setModelId(id); + modelVersionService.save(modelVersion); + return modelInfo; + } } diff --git a/yudao-module-alert/yudao-module-alert-biz/src/main/resources/mapper/ModelVersionMapper.xml b/yudao-module-alert/yudao-module-alert-biz/src/main/resources/mapper/ModelVersionMapper.xml new file mode 100644 index 0000000..943e0f8 --- /dev/null +++ b/yudao-module-alert/yudao-module-alert-biz/src/main/resources/mapper/ModelVersionMapper.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id,model_id,algorithm_id, + model_name,create_name,model_info, + status,visible,condition_info, + trash,assess_res,need_to_assess, + score,clear_or_not,eff_number, + need_to_clean,orig_assess_res,load_cover, + cover_output,version,condition_name, + is_online,creator,create_time, + updater,update_time,deleted + + -- 2.30.2 From 6bd751170dfe263bb82d7f35b39eaae6685bb374 Mon Sep 17 00:00:00 2001 From: chenjiale Date: Tue, 23 Sep 2025 15:51:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?```=20fix(config):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?=E7=9A=84IP=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将application-local.yaml文件中的EXA.ip和point.algorithm.host 配置项的IP地址从旧地址更新为新地址120.26.116.243``` --- yudao-server/src/main/resources/application-local.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index ae5cf1f..01bd48e 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -273,8 +273,8 @@ pf4j: # pluginsDir: /tmp/ pluginsDir: ../plugins EXA: - ip: 120.27.236.75 + ip: 120.26.116.243 point: head: XN. algorithm: - host: 47.98.32.148:8082 \ No newline at end of file + host: 120.26.116.243:8082 \ No newline at end of file -- 2.30.2