houzhongjian
2024-11-08 c40da476c12e0d42d5a9c60607627329b6af8917
Merge remote-tracking branch 'origin/master'
已修改22个文件
已添加1个文件
324 ■■■■ 文件已修改
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataTypeEnum.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IsEnableEnum.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/service/impl/PlanDataSetServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/collection/PlanItemCollector.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/PointImportExcelVO.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/resources/application.yaml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/MdkConstant.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/DllUtils.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MdkController.java 84 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dto/MdkDTO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dto/MethodSettingDTO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java 88 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/template/impl.java.vm 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/template/setup.py.vm 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java
@@ -75,7 +75,6 @@
        String jsonString = JSON.toJSONString(queryParams);
        tagSb.append(jsonString);
        tagSb.append("]");
        log.info("body=====" + tagSb.toString());
        String currentDate = DateUtils.format(new Date(), "yyyyMMddHHmm00");
        String responseStr = HttpRequest.sendPost(httpApi.getUrl() + "/" + currentDate, tagSb.toString());
        JSONObject responseObj = JSON.parseObject(responseStr);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java
@@ -15,6 +15,7 @@
import com.iailab.module.data.channel.tag.vo.TagExportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.IsEnableEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -125,7 +126,7 @@
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<TagImportExcelVO> list = Collections.singletonList(
                TagImportExcelVO.builder().tagName("Tag名称").tagDesc("Tag描述").dataType("String").enabled(1)
                TagImportExcelVO.builder().tagName("Tag名称").tagDesc("Tag描述").dataType("String").enabled(IsEnableEnum.ENABLE.getCode())
                        .build()
        );
        // 输出
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java
@@ -17,6 +17,7 @@
import com.iailab.module.data.channel.tag.vo.TagExportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.IsEnableEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -126,7 +127,7 @@
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<TagImportExcelVO> list = Collections.singletonList(
                TagImportExcelVO.builder().tagName("Tag名称").tagDesc("Tag描述").dataType("String").enabled(1)
                TagImportExcelVO.builder().tagName("Tag名称").tagDesc("Tag描述").dataType("String").enabled(IsEnableEnum.ENABLE.getCode())
                        .build()
        );
        // 输出
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java
@@ -16,6 +16,7 @@
import com.iailab.module.data.channel.modbus.vo.ModBusTagPageReqVO;
import com.iailab.module.data.channel.modbus.vo.ModBusTagRespVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.IsEnableEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -136,7 +137,7 @@
        // 手动创建导出 demo
        List<ModBusTagImportExcelVO> list = Collections.singletonList(
                ModBusTagImportExcelVO.builder().tagName("Tag名称").tagDesc("Tag描述").dataType("String").
                        address("123").format("1").samplingRate(1000).enabled(1)
                        address("123").format("1").samplingRate(1000).enabled(IsEnableEnum.ENABLE.getCode())
                        .build()
        );
        // 输出
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java
@@ -18,6 +18,7 @@
import com.iailab.module.data.channel.opcda.vo.OpcDaTagRespVO;
import com.iailab.module.data.common.enums.DataSourceType;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.IsEnableEnum;
import com.iailab.module.data.common.exception.RRException;
import com.iailab.module.data.common.utils.TagUtils;
import io.swagger.v3.oas.annotations.Operation;
@@ -146,7 +147,7 @@
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<OpcDaTagImportExcelVO> list = Collections.singletonList(
                OpcDaTagImportExcelVO.builder().tagName("Tag名称").dataType("String").enabled(1)
                OpcDaTagImportExcelVO.builder().tagName("Tag名称").dataType("String").enabled(IsEnableEnum.ENABLE.getCode())
                        .build()
        );
        // 输出
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java
@@ -17,6 +17,7 @@
import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagRespVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.IsEnableEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -125,7 +126,7 @@
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<OpcUaTagImportExcelVO> list = Collections.singletonList(
                OpcUaTagImportExcelVO.builder().tagName("Tag名称").dataType("String").address("123").samplingRate(1000).enabled(1)
                OpcUaTagImportExcelVO.builder().tagName("Tag名称").dataType("String").address("123").samplingRate(1000).enabled(IsEnableEnum.ENABLE.getCode())
                        .build()
        );
        // 输出
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataTypeEnum.java
@@ -12,11 +12,12 @@
@AllArgsConstructor
public enum DataTypeEnum {
    INT("int"),
    INT("int","整型"),
    FLOAT("float"),
    FLOAT("float","浮点型"),
    BOOLEAN("boolean");
    BOOLEAN("boolean", "布尔型");
    private String code;
    private String desc;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IsEnableEnum.java
@@ -1,21 +1,20 @@
package com.iailab.module.data.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2023年07月17日 17:41:00
 */
@Getter
@AllArgsConstructor
public enum IsEnableEnum {
    DISABLE(0), // 手动
    ENABLE(1);  //自动
    DISABLE(0, "否"),
    ENABLE(1, "是");
    private Integer value;
    private Integer code;
    private String desc;
    IsEnableEnum(Integer value) {
        this.value = value;
    }
    public Integer value() {
        return this.value;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java
@@ -23,7 +23,7 @@
public class PointCollectTaskNet60 implements ITask {
    private final Logger logger = LoggerFactory.getLogger(getClass());
    private static final String NET = "NET60";
    private static final String NET = "1min";
    @Resource
    private PointCollector pointCollector;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/service/impl/PlanDataSetServiceImpl.java
@@ -1,5 +1,6 @@
package com.iailab.module.data.plan.data.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.BeanUtils;
@@ -30,7 +31,9 @@
    @Override
    public List<PlanDataSetEntity> list(PlanDataSetPageReqVO reqVO) {
        return baseDao.selectList();
        QueryWrapper<PlanDataSetEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        return baseDao.selectList(queryWrapper);
    }
    @Override
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/collection/PlanItemCollector.java
@@ -93,10 +93,12 @@
        StringBuilder whereSql = new StringBuilder();
        String startStr = DateUtils.format(startTime, DateUtils.DATE_NUMBER_PATTERN);
        String endStr = DateUtils.format(endTime, DateUtils.DATE_NUMBER_PATTERN);
        whereSql.append(" plan_t.start_time <= ")
        whereSql.append(" plan_t.start_time <= '")
                .append(endStr)
                .append(" and plan_t.end_time >= ")
                .append(startStr);
                .append("'")
                .append(" and plan_t.end_time >= '")
                .append(startStr)
                .append("'");
        params.put("whereSql", whereSql.toString());
        return params;
    }
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java
@@ -1,6 +1,5 @@
package com.iailab.module.data.point.controller.admin;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageParam;
@@ -8,11 +7,12 @@
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.api.dto.ApiPointValueQueryDTO;
import com.iailab.module.data.channel.common.service.ChannelSourceService;
import com.iailab.module.data.common.enums.DataSourceType;
import com.iailab.module.data.common.enums.DataTypeEnum;
import com.iailab.module.data.common.enums.MeasureValueType;
import com.iailab.module.data.influxdb.service.InfluxDBService;
import com.iailab.module.data.point.common.PointTypeEnum;
import com.iailab.module.data.point.dto.DaPointDTO;
import com.iailab.module.data.point.entity.DaPointEntity;
import com.iailab.module.data.point.service.DaPointService;
import com.iailab.module.data.point.vo.*;
import io.swagger.v3.oas.annotations.Operation;
@@ -34,8 +34,8 @@
import java.text.SimpleDateFormat;
import java.util.*;
import static com.iailab.framework.common.pojo.CommonResult.success;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
@@ -180,14 +180,14 @@
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<PointImportExcelVO> list = Arrays.asList(
                PointImportExcelVO.builder().pointName("测点1").pointType("MEASURE").dataType("float").valueType("SIMULATE")
                PointImportExcelVO.builder().pointName("测点1").pointType(PointTypeEnum.MEASURE_POINT.getCode()).dataType(DataTypeEnum.FLOAT.getCode()).valueType(MeasureValueType.SIMULATE.getCode())
                        .storeType(null).unit("t(非必填)").unittransfactor(new BigDecimal(1)).defaultValue(new BigDecimal(0)).maxValue(new BigDecimal(10000000.000000)).minValue(new BigDecimal(0))
                        .minfreqid("1min").remark("备注(非必填)").sourceType(DataSourceType.HTTP.getCode())
                        .sourceName("").tagNo("SARD1200G00102RC001")
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "测点导入模板.xlsx", "测点列表", PointImportExcelVO.class, list);
        ExcelUtils.write(response, "测点导入模板.xlsx", "测点列表", PointImportExcelVO.class, list,true);
    }
    @PostMapping("/import")
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -23,18 +23,20 @@
import com.iailab.module.data.point.service.DaMeasurePointService;
import com.iailab.module.data.point.service.DaPointService;
import com.iailab.module.data.point.service.DaSequenceNumService;
import com.iailab.module.data.point.vo.*;
import com.iailab.module.data.point.vo.DaPointPageReqVO;
import com.iailab.module.data.point.vo.PointImportExcelVO;
import com.iailab.module.data.point.vo.PointImportRespVO;
import com.iailab.module.infra.api.config.ConfigApi;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.iailab.module.data.enums.ErrorCodeConstants.*;
import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_EXISTS;
import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_IMPORT_LIST_IS_EMPTY;
/**
 * @author lirm
@@ -381,7 +383,7 @@
        Arrays.asList(ids).forEach(item -> {
            DaPointEntity entity = new DaPointEntity();
            entity.setId(item);
            entity.setIsEnable(IsEnableEnum.ENABLE.value());
            entity.setIsEnable(IsEnableEnum.ENABLE.getCode());
            daPointDao.updateById(entity);
        });
    }
@@ -394,7 +396,7 @@
        Arrays.asList(ids).forEach(item -> {
            DaPointEntity entity = new DaPointEntity();
            entity.setId(item);
            entity.setIsEnable(IsEnableEnum.DISABLE.value());
            entity.setIsEnable(IsEnableEnum.DISABLE.getCode());
            daPointDao.updateById(entity);
        });
    }
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/PointImportExcelVO.java
@@ -1,6 +1,9 @@
package com.iailab.module.data.point.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.framework.excel.core.annotations.DictFormat;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.convert.DictConvert;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -26,10 +29,14 @@
    @ExcelProperty("测点名称")
    private String pointName;
    @ExcelProperty("测点类型")
    @ExcelProperty(value = "测点类型", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "data_point_type")
    @DictFormat("data_point_type")
    private String pointType;
    @ExcelProperty("数据类型")
    @ExcelProperty(value = "数据类型", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "point_data_type")
    @DictFormat("point_data_type")
    private String dataType;
    @ExcelProperty("存储类型")
@@ -57,7 +64,9 @@
    @ExcelProperty("备注")
    private String remark;
    @ExcelProperty("数据源类型")
    @ExcelProperty(value = "数据源类型", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "data_source_type")
    @DictFormat("data_source_type")
    private String sourceType;
    @ExcelProperty("数据源名称")
@@ -69,7 +78,9 @@
    @ExcelProperty("平滑尺度")
    private Integer dimension;
    @ExcelProperty("值类型")
    @ExcelProperty(value = "值类型", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "measure_value_type")
    @DictFormat("measure_value_type")
    private String valueType;
    @ExcelProperty("计算公式")
iailab-module-data/iailab-module-data-biz/src/main/resources/application.yaml
@@ -207,6 +207,9 @@
      - t_video_log
      - t_video_camera
      - t_video_image
      - t_plan_data_set
      - t_plan_item_category
      - t_plan_item
  app:
    app-key: data
    app-secret: 85b0df7edc3df3611913df34ed695011
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/MdkConstant.java
@@ -46,4 +46,12 @@
     * 项目发布dll和jar目录
     */
    String PROJECT_PUBLISH = "projectPublish";
    /**
     * setup.py
     */
    String SETUP_PY = "setup.py";
    /**
     * 编译pyd生成文件后缀
     */
    String PYD_SUFFIX = ".cp37-win_amd64.pyd";
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/DllUtils.java
@@ -217,6 +217,9 @@
            throw new RuntimeException("模型文件不能为空!");
        } else {
            URLClassLoader classLoader = DllUtils.getClassLoader(projectId);
            if (null == classLoader) {
                throw new RuntimeException("dll未发布,classLoader为null");
            }
            Class<?> clazz = classLoader.loadClass(model.getClassName());
            Method method = clazz.getMethod(model.getMethodName(), model.getParamsArray());
            return (HashMap)method.invoke(clazz.newInstance(), paramsValueArray);
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MdkController.java
@@ -1,5 +1,7 @@
package com.iailab.module.model.mpk.controller.admin;
import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.FIFOCache;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.iail.utils.RSAUtils;
@@ -11,6 +13,7 @@
import com.iailab.module.model.mpk.common.utils.Readtxt;
import com.iailab.module.model.mpk.dto.MdkDTO;
import com.iailab.module.model.mpk.dto.MdkRunDTO;
import com.iailab.module.model.mpk.dto.MethodSettingDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@@ -24,6 +27,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import static com.iailab.framework.common.pojo.CommonResult.error;
import static com.iailab.framework.common.pojo.CommonResult.success;
@@ -40,6 +44,8 @@
    @Value("${mpk.bak-file-path}")
    private String mpkBakFilePath;
    // 先进先出缓存
    private static FIFOCache<String, String> cache = CacheUtil.newFIFOCache(100);
    /**
     * @description: 模型测试运行
@@ -76,16 +82,19 @@
        System.out.println("runTime=" + System.currentTimeMillis());
        try {
            List<String> datas = dto.getDatas();
            List<String> uuids = dto.getUuids();
            int paramLength = dto.getHasModel() ? datas.size() + 2 : datas.size() + 1;
            int paramLength = dto.getHasModel() ? uuids.size() + 2 : uuids.size() + 1;
            Object[] paramsValueArray = new Object[paramLength];
            Class<?>[] paramsArray = new Class[paramLength];
            try {
                for (int i = 0; i < datas.size(); i++) {
                    String json = datas.get(i);
                    JSONArray jsonArray = JSON.parseArray(json);
                for (int i = 0; i < uuids.size(); i++) {
                    String uuid = uuids.get(i);
                    if (!cache.containsKey(uuid)) {
                        return error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),"请重新导入模型参数");
                    }
                    JSONArray jsonArray = JSON.parseArray(cache.get(uuid));
                    double[][] data = new double[jsonArray.size()][jsonArray.getJSONArray(0).size()];
                    for (int j = 0; j < jsonArray.size(); j++) {
                        for (int k = 0; k < jsonArray.getJSONArray(j).size(); k++) {
@@ -97,17 +106,22 @@
                }
            } catch (Exception e) {
                e.printStackTrace();
                return error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),"参数错误,请检查!");
                return error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),"模型参数错误,请检查!");
            }
            if (dto.getHasModel()) {
                paramsValueArray[datas.size()] = dto.getModel();
                paramsValueArray[datas.size() + 1] = dto.getModelSettings();
                paramsArray[datas.size()] = HashMap.class;
                paramsArray[datas.size() + 1] = HashMap.class;
            }else {
                paramsValueArray[datas.size()] = dto.getModelSettings();
                paramsArray[datas.size()] = HashMap.class;
            try {
                if (dto.getHasModel()) {
                    paramsValueArray[uuids.size()] = dto.getModel();
                    paramsValueArray[uuids.size() + 1] = handleModelSettings(dto.getModelSettings());
                    paramsArray[uuids.size()] = HashMap.class;
                    paramsArray[uuids.size() + 1] = HashMap.class;
                }else {
                    paramsValueArray[uuids.size()] = handleModelSettings(dto.getModelSettings());
                    paramsArray[uuids.size()] = HashMap.class;
                }
            } catch (Exception e) {
                e.printStackTrace();
                return error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),"模型设置错误,请检查!");
            }
            HashMap result = (HashMap) clazz.getDeclaredMethod(dto.getMethodName(), paramsArray).invoke(clazz.newInstance(), paramsValueArray);
@@ -122,6 +136,37 @@
            }
            System.gc();
        }
    }
    private HashMap<String, Object> handleModelSettings(List<MethodSettingDTO> modelSettings) {
        HashMap<String, Object> resultMap = null;
        try {
            resultMap = new HashMap<>(modelSettings.size());
            for (MethodSettingDTO modelSetting : modelSettings) {
                switch (modelSetting.getValueType()) {
                    case "int":
                        resultMap.put(modelSetting.getSettingKey(), Integer.valueOf(modelSetting.getSettingValue()));
                        break;
                    case "string":
                        resultMap.put(modelSetting.getSettingKey(), modelSetting.getSettingValue());
                        break;
                    case "decimal":
                        resultMap.put(modelSetting.getSettingKey(), Double.valueOf(modelSetting.getSettingValue()));
                        break;
                    case "decimalArray":
                        JSONArray jsonArray = JSON.parseArray(modelSetting.getSettingValue());
                        double[] doubles = new double[jsonArray.size()];
                        for (int i = 0; i < jsonArray.size(); i++) {
                            doubles[i] = Double.valueOf(String.valueOf(jsonArray.get(i)));
                        }
                        resultMap.put(modelSetting.getSettingKey(), doubles);
                        break;
                }
            }
        } catch (NumberFormatException e) {
            throw new RuntimeException("模型参数有误,请检查!!!");
        }
        return resultMap;
    }
    /**
@@ -157,13 +202,18 @@
    @PostMapping("/import")
    @Operation(summary = "导入参数")
    public CommonResult<List<String>> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
    public CommonResult<List<HashMap<String,Object>>> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
        List<double[][]> datas = Readtxt.readMethodExcel(file);
        List<String> result = new ArrayList<>();
        List<HashMap<String,Object>> result = new ArrayList<>();
        if (!CollectionUtils.isEmpty(datas)) {
            for (double[][] data : datas) {
                if (data.length > 0) {
                    result.add(JSON.toJSONString(data));
                    HashMap<String,Object> map = new HashMap<>();
                    String uuid = UUID.randomUUID().toString();
                    map.put("uuid",uuid);
                    map.put("data",JSON.toJSONString(data));
                    cache.put(uuid,JSON.toJSONString(data));
                    result.add(map);
                }
            }
        }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dto/MdkDTO.java
@@ -25,7 +25,7 @@
    private HashMap<String, Object> model;
    private HashMap<String, Object> modelSettings;
    private List<MethodSettingDTO> modelSettings;
    private List<String> datas;
    private List<String> uuids;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dto/MethodSettingDTO.java
@@ -61,4 +61,9 @@
    private Integer min;
    private List<SettingSelectDTO> settingSelects;
    /**
     * 参数值
     */
    private String settingValue;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java
@@ -22,7 +22,6 @@
import com.iailab.module.model.mpk.dto.GeneratorCodeHistoryDTO;
import com.iailab.module.model.mpk.dto.ModelMethodDTO;
import com.iailab.module.model.mpk.dto.MpkFileDTO;
import com.iailab.module.model.mpk.dto.ProjectPackageHistoryDTO;
import com.iailab.module.model.mpk.entity.GeneratorCodeHistoryEntity;
import com.iailab.module.model.mpk.entity.MpkFileEntity;
import com.iailab.module.model.mpk.entity.ProjectPackageHistoryEntity;
@@ -246,6 +245,11 @@
        //生成Jni.h文件
        File jniHFile = new File(dirPath.getAbsolutePath() + File.separator + MdkConstant.C + File.separator + entity.getPyName() + "Jni.h");
        GenUtils.drawTemplate("Jni.h.vm", dataContext, jniHFile);
        // 添加python源文件
        String pyFilePath = dirPath.getAbsolutePath() + File.separator + MdkConstant.ALGS + File.separator + entity.getPyModule().replace(".", File.separator) + File.separator + entity.getPyName() + ".pyd";
        FileUtil.mkParentDirs(pyFilePath);
        FileUtil.copy(entity.getFilePath(), pyFilePath, true);
        // 资源文件
        FileUtil.copy(mpkResources + File.separator + "libs", dirPath.getAbsolutePath(), true);
@@ -492,26 +496,86 @@
        Long tenantId = TenantContextHolder.getTenantId();
        // 备份文件 租户隔离
        String mpkTenantBakFilePath = mpkBakFilePath + File.separator + tenantId;
        File dir = new File(mpkTenantBakFilePath);
        if (!dir.exists()) {
            dir.mkdirs();
        File bakDir = new File(mpkTenantBakFilePath);
        if (!bakDir.exists()) {
            bakDir.mkdirs();
        }
        //临时文件夹
        File tempDir = null;
        try {
            tempDir = Files.createTempDirectory("pyFileTmp").toFile();
            log.info("生成临时文件夹," + tempDir.getAbsolutePath());
        } catch (IOException e) {
            throw new RuntimeException("创建临时文件夹异常",e);
        }
        String fileName = file.getOriginalFilename();
        String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
        File saveFile = new File(dir.getAbsolutePath() + File.separator + UUID.randomUUID() + fileSuffix);
        File pydBakFile = new File(bakDir.getAbsolutePath() + File.separator + UUID.randomUUID() + ".pyd");
        saveFile.createNewFile();
        // 保存
        file.transferTo(saveFile);
        String pyName = fileName.substring(0, fileName.lastIndexOf("."));
        try {
            // py文件存入临时文件夹
            File saveFile = new File(tempDir.getAbsolutePath() + File.separator + fileName);
            saveFile.createNewFile();
            file.transferTo(saveFile);
            // 临时文件夹中生成pyd文件
            // 生成setup.py文件
            createSetUpFile(tempDir.getAbsolutePath(),fileName,pyName);
            // 执行cmd命令编译pyd文件
            createPydFile(tempDir.getAbsolutePath());
            // 临时文件夹中pyd文件移到dir下,修改为uuid.pyd
            File pydFile = new File(tempDir.getAbsolutePath() + File.separator + pyName + MdkConstant.PYD_SUFFIX);
            if (!pydFile.exists()) {
                throw new RuntimeException("编译pyd文件失败!");
            }
            log.info("备份pyd文件," + pydBakFile.getAbsolutePath());
            FileUtil.copy(pydFile,pydBakFile,true);
        } catch (Exception e) {
            throw new RuntimeException("编译pyd文件异常");
        } finally {
            if (tempDir.exists()) {
                tempDir.delete();
            }
        }
        Map<String, String> result = new HashMap<>(2);
        result.put("filePath", saveFile.getAbsolutePath());
        result.put("fileName", fileName);
        result.put("filePath", pydBakFile.getAbsolutePath());
        result.put("fileName", pyName);
        return result;
    }
    private void createPydFile(String dir) {
        try {
            String command = "python setup.py build_ext --inplace";
            log.info("执行cmd命令编译pyd:" + command);
            ProcessBuilder builder = new ProcessBuilder("cmd", "/c", command);
            builder.directory(new File(dir));  // 设置工作目录
            builder.redirectErrorStream(true);  // 将错误输出和标准输出合并
            Process process = builder.start();
            // 获取命令输出结果
            InputStream inputStream = process.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "GBK")); // 设置编码为GBK
            String line;
            while ((line = reader.readLine()) != null) {
                log.info(line);
            }
            // 等待命令执行完成
            process.waitFor();
        } catch (Exception e) {
            throw new RuntimeException("执行cmd命令生成dll异常", e);
        }
    }
    private void createSetUpFile(String dir, String pyFileName, String pyName) {
        // 生成setup.py文件
        HashMap<String,Object> map = new HashMap<>();
        map.put("fileName",pyFileName);
        map.put("pyName",pyName);
        GenUtils.drawTemplate("setup.py.vm",map,new File(dir + File.separator + MdkConstant.SETUP_PY));
    }
    @Override
    public CommonResult<String> publish(Map<String, Object> params) {
        String historyId = (String) params.get("historyId");
iailab-module-model/iailab-module-model-biz/src/main/resources/template/impl.java.vm
@@ -18,7 +18,8 @@
    @Override
    public HashMap<String, Object> ${entity.methodName}(#foreach ($column in [1..$entity.dataLength])double data${column}[][], #{end}#{if}($entity.model==1)HashMap<String, Object> models, #{end}HashMap<String, Object> settings) {
#{if}($entity.model==1)
        model = utils.createPredictHashmapplus(models);
        //model = utils.createPredictHashmapplus(models);
        model = models;
#{end}
        if (#{foreach} ($column in [1..$entity.dataLength])#{if}($column==1)data${column} == null || data${column}.length == 0 || data${column}[0].length == 0#{else} || data${column} == null || data${column}.length == 0 || data${column}[0].length == 0#{end}#{end}) {
            result = new HashMap<String, Object>();
iailab-module-model/iailab-module-model-biz/src/main/resources/template/setup.py.vm
对比新文件
@@ -0,0 +1,26 @@
# CMD 窗口运行
# python alg_setup.py build_ext --inplace
from distutils.core import setup, Extension
from Cython.Build import cythonize
import numpy
#import sklearn
setup(
    name='iail_mdk',
    version='1.0',
    author='IAIL',
    author_email='zhouf_2011@mail.dlut.edu.cn',
    ext_modules = cythonize([
        Extension(
            '${pyName}',
            # 算法路径
            sources=['${fileName}'],
            language='c++',
            include_dirs=[numpy.get_include()],
            library_dirs=[],
            libraries=[],
            extra_compile_args=[],
            extra_link_args=[]
            )
        ]
    )
)