iailab-module-model/iailab-module-model-biz/db/mysql.sql
@@ -11,7 +11,8 @@ update_time datetime default current_timestamp, traintime datetime, primary key (id), UNIQUE INDEX idx_moduletype (moduletype) UNIQUE INDEX uk_modulename (modulename), INDEX idx_moduletype (moduletype) ) engine = innodb default character set utf8mb4 COMMENT = '管网表'; @@ -101,19 +102,20 @@ itemname varchar(50), caltypeid varchar(36), itemtypeid varchar(36), predictlength decimal(5, 0), granularity decimal(5, 0), status decimal(5, 0), isfuse decimal(5, 0), predictphase decimal(5, 0), workchecked decimal(5, 0), unittransfactor decimal(31, 6), create_time datetime default current_timestamp, update_time datetime default current_timestamp, predictlength int, granularity int, status tinyint, isfuse tinyint, predictphase tinyint, workchecked tinyint, unittransfactor decimal(16, 6), create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', saveindex varchar(16), primary key (id), UNIQUE INDEX uk_itemno (itemno) ) engine = innodb default character set utf8mb4 COMMENT = '预测模型结果字符串表'; UNIQUE INDEX uk_itemno (itemno), INDEX uk_itemtypeid (itemtypeid) ) engine = innodb default character set utf8mb4 COMMENT = '预测项表'; create table t_mm_predict_merge_item iailab-module-model/iailab-module-model-biz/doc/c++代码生成.md
对比新文件 @@ -0,0 +1,18 @@ # 系统要求 windows # 安装VS2017专业版 # 环境变量 INCLUDE ``` D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include ``` LIB ``` D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\lib\x64 ``` path ``` D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64 ``` iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java
@@ -16,7 +16,7 @@ @SpringBootApplication public class ModelServiceApplication implements CommandLineRunner { /*static { static { //加载动态链接库 try { Properties properties = new Properties(); @@ -30,26 +30,8 @@ System.out.println("动态链接库IAILMDK初始化失败"); } try { System.out.println("动态加载dll"); String dllDir = Objects.requireNonNull(ModelServiceApplication.class.getClassLoader().getResource("dll")).getPath(); File dir = new File(dllDir); if (dir.exists()) { File[] files = dir.listFiles(); if (files.length > 0) { for (File file : files) { System.out.println("加载:" + file.getAbsolutePath()); System.load(file.getAbsolutePath()); } } } } catch (Exception e) { e.printStackTrace(); System.out.println("动态加载dll失败"); } } */ public static void main(String[] args) { SpringApplication.run(ModelServiceApplication.class, args); iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java
@@ -14,5 +14,5 @@ BigDecimal ZERO_VALUE = new BigDecimal("0"); String HTTP_API_ZXZK_IH = "ZXZK_IH"; String MDK_SUFFIX = ".miail"; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/security/config/SecurityConfiguration.java
@@ -28,6 +28,8 @@ // Spring Boot Actuator 的安全配置 registry.antMatchers("/actuator").anonymous() .antMatchers("/actuator/**").anonymous(); registry.antMatchers("/admin-api/model/pre/item/upload-model").anonymous(); // RPC 服务的安全配置 registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java
@@ -3,24 +3,23 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional; 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.common.enums.CommonConstant; import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO; import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity; import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity; import com.iailab.module.model.mcs.pre.service.MmItemOutputService; import com.iailab.module.model.mcs.pre.service.MmItemTypeService; import com.iailab.module.model.mcs.pre.service.MmPredictItemService; import com.iailab.module.model.mcs.pre.service.MmResultTableService; import com.iailab.module.model.mcs.pre.vo.CountItemtypeVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemPageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; import com.iailab.module.model.mpk.common.utils.IAILModelUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.security.PermitAll; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -32,20 +31,17 @@ * @date 2021年04月26日 14:42 */ @RestController @RequestMapping("/model/pre/predict-item") @RequestMapping("/model/pre/item") public class MmPredictItemController { @Value("${mpk.model-file-path}") private String modelPath; @Autowired private IAILModelUtil iAILModelUtil; @Autowired private MmPredictItemService mmPredictItemService; @Autowired private MmItemTypeService mmItemTypeService; @Autowired private MmItemOutputService mmItemOutputService; @Autowired private MmResultTableService mmResultTableService; /** * 预测项列表 @@ -53,25 +49,13 @@ @GetMapping("/page") @PreAuthorize("@ss.hasPermission('model:pre-item:query')") public CommonResult<PageResult<MmPredictItemRespVO>> page(@Validated MmPredictItemPageReqVO reqVO) { PageResult<MmPredictItemEntity> page = mmPredictItemService.queryPage(reqVO); PageResult<MmPredictItemRespVO> result = BeanUtils.toBean(page, MmPredictItemRespVO.class); for (MmPredictItemRespVO item : result.getList()){ MmItemTypeEntity mmItemTypeEntity = mmItemTypeService.info(item.getItemtypeid()); item.setItemtypename(mmItemTypeEntity== null ? "" :mmItemTypeEntity.getItemtypename()); MmItemOutputEntity mmItemOutputEntity = mmItemOutputService.getByItemid(item.getId()); item.setTagname(mmItemOutputEntity== null ? "" :mmItemOutputEntity.getTagname()); item.setResulttableid(mmItemOutputEntity== null ? "" :mmItemOutputEntity.getResulttableid()); item.setTablename(item == null ? "" : mmResultTableService.info(item.getResulttableid()).getTablename()); } return success(result); PageResult<MmPredictItemRespVO> page = mmPredictItemService.queryPage(reqVO); return success(page); } @GetMapping("/list") public CommonResult<List<MmPredictItemEntity>> list() { List<MmPredictItemEntity> list = mmPredictItemService.list(); return success(list); } @@ -80,7 +64,7 @@ */ @GetMapping("/get/{id}") @PreAuthorize("@ss.hasPermission('model:pre-item:query')") public CommonResult<MmPredictItemDTO> info(@PathVariable("id") String id){ public CommonResult<MmPredictItemDTO> info(@PathVariable("id") String id) { MmPredictItemDTO predictItem = mmPredictItemService.info(id); return success(predictItem); } @@ -90,8 +74,8 @@ */ @PostMapping("/create") @PreAuthorize("@ss.hasPermission('model:pre-item:create')") @DSTransactional(rollbackFor= Exception.class) public CommonResult<Boolean> save(@RequestBody MmPredictItemDTO mmPredictItemDto){ @DSTransactional(rollbackFor = Exception.class) public CommonResult<Boolean> save(@RequestBody MmPredictItemDTO mmPredictItemDto) { mmPredictItemService.add(mmPredictItemDto); return success(true); } @@ -101,8 +85,8 @@ */ @PutMapping("/update") @PreAuthorize("@ss.hasPermission('model:pre-item:update')") @DSTransactional(rollbackFor= Exception.class) public CommonResult<Boolean> update(@RequestBody MmPredictItemDTO mmPredictItemDTO){ @DSTransactional(rollbackFor = Exception.class) public CommonResult<Boolean> update(@RequestBody MmPredictItemDTO mmPredictItemDTO) { mmPredictItemService.update(mmPredictItemDTO); return success(true); } @@ -112,7 +96,7 @@ */ @DeleteMapping("/delete") @PreAuthorize("@ss.hasPermission('model:pre-item:delete')") @DSTransactional(rollbackFor= Exception.class) @DSTransactional(rollbackFor = Exception.class) public CommonResult<Boolean> delete(@RequestParam("id") String id) { mmPredictItemService.deleteBatch(new String[]{id}); return success(true); @@ -122,26 +106,21 @@ * 预测项列表 */ @GetMapping("/count-itemtype") public CommonResult<List<CountItemtypeVO>> countItemtype(@RequestParam Map<String, Object> params){ public CommonResult<List<CountItemtypeVO>> countItemtype(@RequestParam Map<String, Object> params) { List<CountItemtypeVO> list = new ArrayList<>(); return success(list); } // /** // * 数量 // */ // @GetMapping("/count") // public CommonResult<Long> count() { // Long count = mmPredictItemService.count(); // return success(count); // } /** * 上传模型 */ @PostMapping("/uploadModel") public CommonResult<Boolean> uploadModel(@RequestParam("file") MultipartFile file) throws Exception { return success(true); @PermitAll @PostMapping("/upload-model") public CommonResult<Map<String, Object>> uploadModel(@RequestParam("file") MultipartFile file) throws Exception { String uploadDir = modelPath + file.getOriginalFilename(); file.transferTo(new File(uploadDir)); Map<String, Object> result = iAILModelUtil.parseModel(uploadDir); result.put("originalFilename", file.getOriginalFilename().replace(CommonConstant.MDK_SUFFIX, "")); return success(result); } } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictItemDao.java
@@ -1,14 +1,9 @@ package com.iailab.module.model.mcs.pre.dao; import com.baomidou.mybatisplus.core.metadata.IPage; 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.mcs.pre.entity.MmPredictItemEntity; import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity; import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity; import com.iailab.module.model.mcs.pre.vo.DmModulePageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemPageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; import com.iailab.module.model.mdk.vo.ItemVO; @@ -27,16 +22,15 @@ @Mapper public interface MmPredictItemDao extends BaseMapperX<MmPredictItemEntity> { IPage<MmPredictItemRespVO> getPageList(IPage<MmPredictItemEntity> page, @Param("params") MmPredictItemPageReqVO params); List<ItemVO> getByModuleId(Map<String, Object> params); List<ItemVO> getItem(Map<String, Object> params); List<MergeItemVO> getMergeItemByItemId(Map<String, Object> params); default PageResult<MmPredictItemEntity> selectPage(MmPredictItemPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX<MmPredictItemEntity>() .likeIfPresent(MmPredictItemEntity::getItemno, reqVO.getItemno()) .likeIfPresent(MmPredictItemEntity::getItemname, reqVO.getItemname()) .orderByDesc(MmPredictItemEntity::getCreateTime)); default IPage<MmPredictItemRespVO> selectPage(MmPredictItemPageReqVO reqVO) { return getPageList(getPage(reqVO), reqVO); } } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmModelResultstrEntity.java
@@ -12,7 +12,7 @@ * @date 2021年05月07日 16:36 */ @Data @TableName("T_MM_MODEL_RESULTSTR") @TableName("t_mm_model_resultstr") public class MmModelResultstrEntity implements Serializable { private static final long serialVersionUID = 1L; iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmPredictItemEntity.java
@@ -15,7 +15,7 @@ * @date 2021年04月25日 15:05 */ @Data @TableName("T_MM_PREDICT_ITEM") @TableName("t_mm_predict_item") public class MmPredictItemEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -50,37 +50,37 @@ /** * 预测长度 */ private BigDecimal predictlength; private Integer predictlength; /** * 粒度 */ private BigDecimal granularity; private Integer granularity; /** * 是否启用 */ private BigDecimal status; private Integer status; /** * isfuse */ private BigDecimal isfuse; private Integer isfuse; /** * predictphase */ private BigDecimal predictphase; private Integer predictphase; /** * 是否检查 */ private BigDecimal workchecked; private Integer workchecked; /** * unittransfactor */ private BigDecimal unittransfactor; private Integer unittransfactor; /** * 创建时间 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
@@ -4,6 +4,7 @@ import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO; import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity; import com.iailab.module.model.mcs.pre.vo.MmPredictItemPageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; import com.iailab.module.model.mdk.vo.ItemVO; import com.iailab.module.model.mdk.vo.MergeItemVO; @@ -29,7 +30,7 @@ MergeItemVO getMergeItemByItemId(String itemId); PageResult<MmPredictItemEntity> queryPage(MmPredictItemPageReqVO reqVO); PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO); void add(MmPredictItemDTO mmPredictItemDto); iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -1,6 +1,7 @@ package com.iailab.module.model.mcs.pre.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; @@ -12,6 +13,7 @@ import com.iailab.module.model.mcs.pre.service.MmPredictItemService; import com.iailab.module.model.mcs.pre.service.MmSequenceNumService; import com.iailab.module.model.mcs.pre.vo.MmPredictItemPageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; import com.iailab.module.model.mdk.vo.ItemVO; import com.iailab.module.model.mdk.vo.MergeItemVO; import org.apache.commons.lang3.StringUtils; @@ -56,19 +58,11 @@ private MmPredictItemDao mmPredictItemDao; @Override public PageResult<MmPredictItemEntity> queryPage(MmPredictItemPageReqVO reqVO) { return mmPredictItemDao.selectPage(reqVO); public PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO) { IPage<MmPredictItemRespVO> page = mmPredictItemDao.selectPage(reqVO); return new PageResult<MmPredictItemRespVO>(page.getRecords(), page.getTotal()); } // @Override // public void add(MmPredictItemEntity mmPredictItemEntity) { // mmPredictItemDao.insert(mmPredictItemEntity); // } // @Override // public void update(MmPredictItemEntity mmPredictItemEntity) { // mmPredictItemDao.updateById(mmPredictItemEntity); // } @Override public List<MmPredictItemEntity> list() { iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictItemPageReqVO.java
@@ -18,4 +18,7 @@ public class MmPredictItemPageReqVO extends PageParam { private String itemno; private String itemname; private String itemtypeid; private String itemtypename; private String status; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictItemRespVO.java
@@ -40,17 +40,21 @@ @ExcelProperty("类型名称") private String itemtypename; @Schema(description = "预测长度") @ExcelProperty("预测长度") private Integer predictlength; @Schema(description = "粒度") @ExcelProperty("粒度") private BigDecimal granularity; private Integer granularity; @Schema(description = "是否融合") @ExcelProperty("是否融合") private BigDecimal isfuse; private Integer isfuse; @Schema(description = "是否检查") @ExcelProperty("是否检查") private BigDecimal workchecked; private Integer workchecked; @Schema(description = "模块ID") @ExcelProperty("模块ID") @@ -62,7 +66,7 @@ @Schema(description = "是否启用") @ExcelProperty("是否启用") private BigDecimal status; private Integer status; @Schema(description = "类别ID") @ExcelProperty("类别ID") iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/IAILModelUtil.java
对比新文件 @@ -0,0 +1,50 @@ package com.iailab.module.model.mpk.common.utils; import com.iail.IAILMDK; import com.iail.model.IAILModel; import org.springframework.stereotype.Component; import java.io.File; import java.util.HashMap; import java.util.Map; /** * @author PanZhibao * @date 2021年09月08日 15:09 */ @Component public class IAILModelUtil { /** * 解析模型 * * @param uploadDir * @return */ public Map<String, Object> parseModel(String uploadDir) { IAILModel newModelBean = IAILMDK.loadModel(new File(uploadDir)); Map<String, Object> params = new HashMap<>(); params.put("uploadDir", uploadDir); params.put("paramPathList", newModelBean.getParamPathList()); params.put("className", newModelBean.getClassName()); params.put("methodName", newModelBean.getMethodName()); params.put("paramsArray", newModelBean.getParamsArray()); params.put("loadFieldSetList", newModelBean.getLoadFieldSetList()); params.put("paramsCount", getItemInNum(newModelBean.getParamsArray())); params.put("settingConfigMap", newModelBean.getSettingConfigMap()); return params; } private static int getItemInNum(Class<?>[] paramClasses) { if (paramClasses == null) { return 0; } int inNum = 0; for (int i = 0; i < paramClasses.length; i++) { if (paramClasses[i].isArray()) { ++inNum; } } return inNum; } } iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yml
对比新文件 @@ -0,0 +1,53 @@ spring: autoconfigure: exclude: - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure datasource: druid: web-stat-filter: enabled: true stat-view-servlet: enabled: true allow: url-pattern: /druid/* login-username: login-password: filter: stat: enabled: true log-slow-sql: true slow-sql-millis: 100 merge-sql: true wall: config: multi-statement-allow: true dynamic: druid: initial-size: 1 min-idle: 1 max-active: 20 max-wait: 600000 time-between-eviction-runs-millis: 60000 min-evictable-idle-time-millis: 300000 max-evictable-idle-time-millis: 900000 validation-query: SELECT 1 FROM DUAL test-while-idle: true test-on-borrow: false test-on-return: false primary: master datasource: master: #url: jdbc:mysql://127.0.0.1:3306/iailab_expert_tenant_zjgt?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true url: jdbc:mysql://127.0.0.1:3306/iailab_expert_master?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true username: root password: 123456 redis: host: 127.0.0.1 port: 6379 database: 0 # password: 123456 mpk: bakFilePath: D:\DLUT\mpkBakFile model-file-path: D:\DLUT\MDK\Model\miail\ iailab-module-model/iailab-module-model-biz/src/main/resources/iailmdk.properties
@@ -1,4 +1,4 @@ #dev #mdk-init-path = D:\\DLUT\\MDK\\libs\\ #mdk-init-path = D:\\SmartEnergyStudio\\IAILMDK\\libs\\ #prod mdk-init-path = D:\\SmartEnergyStudio\\IAILMDK\\libs\\ iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmPredictItemDao.xml
@@ -22,6 +22,51 @@ <result property="expression" column="EXPRESSION"/> </resultMap> <select id="getPageList" resultType="com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO" parameterType="map"> SELECT TMPI.ID, TMPI.ITEMNO, TMPI.ITEMNAME, TMPI.ITEMTYPEID, TMIT.ITEMTYPENAME, TMPI.PREDICTLENGTH, TMPI.GRANULARITY, TMPI.ISFUSE, TMPI.WORKCHECKED, TDMI.MODULEID, TDMI.ITEMORDER, TMPI.STATUS, TDMI.CATEGORYID, TMIO.POINTID, TMIO.TAGNAME, TMIO.RESULTTABLEID, TMRT.TABLENAME FROM T_MM_PREDICT_ITEM TMPI LEFT JOIN T_MM_ITEM_TYPE TMIT ON TMIT.ID = TMPI.ITEMTYPEID LEFT JOIN T_DM_MODULE_ITEM TDMI ON TDMI.ITEMID = TMPI.ID LEFT JOIN T_MM_ITEM_OUTPUT TMIO ON TMIO.ITEMID = TMPI.ID LEFT JOIN T_MM_RESULT_TABLE TMRT ON TMRT.ID = TMIO.RESULTTABLEID <where> <if test="params.itemno != null and params.itemno != ''"> AND TMPI.ITEMNO LIKE CONCAT('%', #{params.itemno},'%') </if> <if test="params.itemname != null and params.itemname != ''"> AND TMPI.ITEMNAME LIKE CONCAT('%', #{params.itemname},'%') </if> <if test="params.itemtypeid != null and params.itemtypeid != ''"> AND TMPI.ITEMTYPEID = #{params.itemtypeid} </if> <if test="params.itemtypename != null and params.itemtypename != ''"> AND TMIT.ITEMTYPENAME = #{params.itemtypename} </if> <if test="params.status != null and params.status != ''"> AND TMPI.STATUS = #{params.status} </if> </where> ORDER BY TMPI.CREATE_TIME DESC </select> <select id="queryList" resultType="com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO" parameterType="map"> SELECT TMPI.ID,