iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictReqDTO.java
@@ -19,7 +19,7 @@ @NotNull(message="预测时间不能为空") private Date predictTime; @Schema(description = "预测模块") @Schema(description = "预测模块(管网类型)") private String moduleType; @Schema(description = "预测项编号") iailab-module-model/iailab-module-model-biz/db/mysql.sql
@@ -630,4 +630,15 @@ PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '模型文件分组' ROW_FORMAT = Dynamic; alter table t_mm_predict_model add column `mpkprojectid` varchar(36) DEFAULT NULL; alter table t_mm_predict_model add column `mpkprojectid` varchar(36) DEFAULT NULL; DROP TABLE IF EXISTS `t_mpk_pack`; CREATE TABLE `t_mpk_pack` ( `id` varchar(36) NOT NULL COMMENT 'id', `pack_name` varchar(50) NOT NULL COMMENT '包名称', `pack_desc` varchar(50) DEFAULT NULL COMMENT '包描述', `model_path` varchar(50) DEFAULT NULL COMMENT '模型路径', `sort` integer DEFAULT NULL COMMENT '排序', PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX uk_pack_name (pack_name) ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'MDK包名管理' ROW_FORMAT = Dynamic; iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/PredictItemFactory.java
@@ -1,6 +1,7 @@ package com.iailab.module.model.mdk.factory; import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity; import com.iailab.module.model.mdk.predict.PredictItemHandler; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -25,16 +26,16 @@ * @param itemId * @return */ public Object create(String itemId) { public PredictItemHandler create(String itemId) { MmItemTypeEntity itemTypeEntity = itemEntityFactory.getMmItemTypeEntity(itemId); //获取预测项的预测程序的类 Object itemObject = null; try { Class clazz = Class.forName(itemTypeEntity.getItemclasstype()); Class<?> clazz = Class.forName(itemTypeEntity.getItemclasstype()); itemObject = applicationContext.getBean(clazz); } catch (Exception e) { log.error("exception message : {}", e.getMessage()); } return itemObject; return (PredictItemHandler) itemObject; } } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictModuleHandler.java
@@ -42,7 +42,7 @@ continue; } try { PredictItemHandler predictItemHandler = (PredictItemHandler)predictItemFactory.create(predictItem.getId()); PredictItemHandler predictItemHandler = predictItemFactory.create(predictItem.getId()); Instant start = Instant.now(); try { predictResult = predictItemHandler.predict(predictTime, predictItem); iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java
@@ -4,6 +4,7 @@ import com.iailab.framework.common.pojo.CommonResult; import com.iailab.module.model.mpk.dto.MpkFileDTO; import com.iailab.module.model.mpk.service.MpkFileService; import com.iailab.module.model.mpk.service.PackService; import io.swagger.v3.oas.annotations.Operation; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -29,6 +30,9 @@ public class MpkFileController { @Autowired private MpkFileService mpkFileService; @Autowired private PackService packService; @GetMapping("page") @Operation(summary = "分页") @@ -66,6 +70,7 @@ dto.setGroupName(dto.getMenuAndGroup().get(1)); } } dto.setPyModule(packService.getModelPath(dto.getClassName())); mpkFileService.save(dto); return CommonResult.success(true); } @@ -86,6 +91,7 @@ dto.setGroupName(dto.getMenuAndGroup().get(1)); } } dto.setPyModule(packService.getModelPath(dto.getClassName())); mpkFileService.update(dto); return CommonResult.success(true); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/PackController.java
对比新文件 @@ -0,0 +1,72 @@ package com.iailab.module.model.mpk.controller.admin; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.model.mpk.entity.PackEntity; import com.iailab.module.model.mpk.service.PackService; import com.iailab.module.model.mpk.vo.PackPageReqVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author PanZhibao * @Description * @createTime 2024年11月05日 */ @Tag(name = "模型服务 - MDK包名管理") @RestController @RequestMapping("/model/mpk/pack") public class PackController { @Autowired private PackService packService; @GetMapping("/page") @Operation(summary = "获得分页") public CommonResult<PageResult<PackEntity>> page(@Valid PackPageReqVO reqVO) { PageResult<PackEntity> page = packService.page(reqVO); return success(BeanUtils.toBean(page, PackEntity.class)); } @GetMapping("/list") @Operation(summary = "获得列表") public CommonResult<List<PackEntity>> list() { List<PackEntity> list = packService.list(); return success(list); } @GetMapping("/get") @Operation(summary = "获得详情") public CommonResult<PackEntity> get(@RequestParam("id") String id) { PackEntity data = packService.get(id); return success(data); } @PostMapping("/create") @Operation(summary = "创建") public CommonResult<Boolean> save(@Valid @RequestBody PackEntity entity) { packService.create(entity); return success(true); } @PutMapping("/update") @Operation(summary = "更新") public CommonResult<Boolean> update(@Valid @RequestBody PackEntity entity) { packService.update(entity); return success(true); } @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { packService.delete(id); return success(true); } } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dao/PackDao.java
对比新文件 @@ -0,0 +1,25 @@ package com.iailab.module.model.mpk.dao; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.mybatis.core.mapper.BaseMapperX; import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; import com.iailab.framework.tenant.core.db.dynamic.TenantDS; import com.iailab.module.model.mpk.entity.PackEntity; import com.iailab.module.model.mpk.vo.PackPageReqVO; import org.apache.ibatis.annotations.Mapper; /** * @author PanZhibao * @Description * @createTime 2024年11月05日 */ @TenantDS @Mapper public interface PackDao extends BaseMapperX<PackEntity> { default PageResult<PackEntity> selectPage(PackPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX<PackEntity>() .likeIfPresent(PackEntity::getPackName, reqVO.getPackName()) .orderByDesc(PackEntity::getSort).orderByAsc(PackEntity::getPackName)); } } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/entity/PackEntity.java
对比新文件 @@ -0,0 +1,44 @@ package com.iailab.module.model.mpk.entity; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; /** * @author PanZhibao * @Description * @createTime 2024年11月05日 */ @Data @TableName("t_mpk_pack") public class PackEntity implements Serializable { private static final long serialVersionUID = 1L; /** * id */ @TableId private String id; /** * 包名称 */ private String packName; /** * 包描述 */ private String packDesc; /** * 模型路径 */ private String modelPath; /** * 排序 */ private Integer sort; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/PackService.java
对比新文件 @@ -0,0 +1,32 @@ package com.iailab.module.model.mpk.service; import com.iailab.framework.common.pojo.PageResult; import com.iailab.module.model.mpk.entity.PackEntity; import com.iailab.module.model.mpk.vo.PackPageReqVO; import java.util.List; import java.util.Map; /** * @author PanZhibao * @Description * @createTime 2024年11月05日 */ public interface PackService { PageResult<PackEntity> page(PackPageReqVO reqVO); List<PackEntity> list(); void create(PackEntity entity); void update(PackEntity entity); PackEntity get(String id); void delete(String id); Map<String, PackEntity> getNameMap(); String getModelPath(String packName); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/PackServiceImpl.java
对比新文件 @@ -0,0 +1,89 @@ package com.iailab.module.model.mpk.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.pojo.PageResult; import com.iailab.module.model.mpk.dao.PackDao; import com.iailab.module.model.mpk.entity.PackEntity; import com.iailab.module.model.mpk.service.PackService; import com.iailab.module.model.mpk.vo.PackPageReqVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; /** * @author PanZhibao * @Description * @createTime 2024年11月05日 */ @Slf4j @Service public class PackServiceImpl implements PackService { @Autowired private PackDao iconDao; @Override public PageResult<PackEntity> page(PackPageReqVO reqVO) { return iconDao.selectPage(reqVO); } @Override public List<PackEntity> list() { QueryWrapper<PackEntity> qw = new QueryWrapper<>(); qw.orderByAsc("sort"); return iconDao.selectList(qw); } @Override public Map<String, PackEntity> getNameMap() { Map<String, PackEntity> map = new HashMap<>(); QueryWrapper<PackEntity> qw = new QueryWrapper<>(); List<PackEntity> list = iconDao.selectList(qw); if (CollectionUtils.isEmpty(list)) { return map; } list.forEach(packEntity -> { map.put(packEntity.getPackName(), packEntity); }); return map; } @Override public String getModelPath(String packName) { QueryWrapper<PackEntity> qw = new QueryWrapper<>(); qw.eq("pack_name", packName); PackEntity packEntity = iconDao.selectOne(qw); if (packEntity == null) { return null; } return packEntity.getModelPath(); } @Override public void create(PackEntity entity) { entity.setId(UUID.randomUUID().toString()); iconDao.insert(entity); } @Override public void update(PackEntity entity) { iconDao.updateById(entity); } @Override public PackEntity get(String id) { return iconDao.selectById(id); } @Override public void delete(String id) { iconDao.deleteById(id); } } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/vo/PackPageReqVO.java
对比新文件 @@ -0,0 +1,28 @@ package com.iailab.module.model.mpk.vo; /** * @author PanZhibao * @Description * @createTime 2024年11月05日 */ import com.iailab.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; /** * @author PanZhibao * @Description * @createTime 2024年09月22日 */ @Schema(description = "模型服务 - MDK包名称分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class PackPageReqVO extends PageParam { @Schema(description = "包名称名称,模糊匹配", example = "") private String packName; }