潘志宝
2024-09-30 303715d81f0c1cd8b32cd659b7734c01565369a6
Merge branch 'master' of ssh://172.16.8.100:29418/iailab-plat
已修改12个文件
已删除5个文件
已添加7个文件
11535 ■■■■■ 文件已修改
iailab-module-model/.flattened-pom.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-api/.flattened-pom.xml 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/.flattened-pom.xml 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java 178 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/DmModuleDao.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreItemOptionVO.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/DllUtils.java 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/GenUtils.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/Readtxt.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MdkController.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/IAILMDK/common/Environment.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/IAILMDK/utils/AlgsUtils.java 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/IAIL.MDK.Mid.Windows.dll 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/status_code.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/version.xml 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/pre/DmModuleDao.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
logs/log-debug.2024-09-30.log 10518 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/.flattened-pom.xml
对比新文件
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.iailab</groupId>
    <artifactId>iailab-plat</artifactId>
    <version>0.0.1</version>
  </parent>
  <groupId>com.iailab</groupId>
  <artifactId>iailab-module-model</artifactId>
  <version>0.0.1</version>
  <packaging>pom</packaging>
  <modules>
    <module>iailab-module-model-biz</module>
    <module>iailab-module-model-api</module>
  </modules>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
</project>
iailab-module-model/iailab-module-model-api/.flattened-pom.xml
对比新文件
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.iailab</groupId>
    <artifactId>iailab-module-model</artifactId>
    <version>0.0.1</version>
  </parent>
  <groupId>com.iailab</groupId>
  <artifactId>iailab-module-model-api</artifactId>
  <version>0.0.1</version>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-ui</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-openfeign</artifactId>
      <optional>true</optional>
    </dependency>
  </dependencies>
</project>
iailab-module-model/iailab-module-model-biz/.flattened-pom.xml
对比新文件
@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.iailab</groupId>
    <artifactId>iailab-module-model</artifactId>
    <version>0.0.1</version>
  </parent>
  <groupId>com.iailab</groupId>
  <artifactId>iailab-module-model-biz</artifactId>
  <version>0.0.1</version>
  <properties>
    <mdk.version>MDK.taisteel.202308231710</mdk.version>
    <easypoi.version>4.1.0</easypoi.version>
    <commons.io.version>2.11.0</commons.io.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <velocity.version>1.7</velocity.version>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-env</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-module-data-api</artifactId>
      <version>${revision}</version>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-module-infra-api</artifactId>
      <version>${revision}</version>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-module-system-api</artifactId>
      <version>${revision}</version>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-biz-data-permission</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-biz-tenant</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-biz-ip</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-module-model-api</artifactId>
      <version>${revision}</version>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-security</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-mybatis</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-rpc</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-monitor</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-biz-data-permission</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-excel</artifactId>
    </dependency>
    <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    </dependency>
    <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>4.1.1</version>
    </dependency>
    <dependency>
      <groupId>com.iail</groupId>
      <artifactId>IAILMDK</artifactId>
      <version>0.94.9</version>
    </dependency>
    <dependency>
      <groupId>com.iail</groupId>
      <artifactId>MDK</artifactId>
      <version>${mdk.version}</version>
    </dependency>
    <dependency>
      <groupId>cn.afterturn</groupId>
      <artifactId>easypoi-base</artifactId>
      <version>${easypoi.version}</version>
    </dependency>
    <dependency>
      <groupId>cn.afterturn</groupId>
      <artifactId>easypoi-web</artifactId>
      <version>${easypoi.version}</version>
    </dependency>
    <dependency>
      <groupId>cn.afterturn</groupId>
      <artifactId>easypoi-annotation</artifactId>
      <version>${easypoi.version}</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>${commons.io.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.velocity</groupId>
      <artifactId>velocity</artifactId>
      <version>${velocity.version}</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${spring.boot.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <version>1.1.0</version>
        <executions>
          <execution>
            <id>flatten</id>
            <phase>process-resources</phase>
            <goals>
              <goal>flatten</goal>
            </goals>
          </execution>
          <execution>
            <id>flatten.clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <updatePomFile>true</updatePomFile>
          <flattenMode>resolveCiFriendliesOnly</flattenMode>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java
@@ -4,13 +4,10 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.iail.IAILMDK;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import java.io.File;
import java.io.InputStream;
import java.util.Objects;
import java.util.Properties;
@EnableAsync
@@ -25,7 +22,11 @@
            properties.load(in);
            String mdkInitPath = properties.getProperty("mdk-init-path");
            System.out.println("mdkInitPath=" + mdkInitPath);
            System.load(mdkInitPath + File.separator + "IAIL.MDK.Mid.Windows.dll");
            File file = new File(mdkInitPath + File.separator + "IAIL.MDK.Mid.Windows.dll");
            if (!file.exists()) {
                throw new RuntimeException("动态链接库IAIL.MDK.Mid.Windows.dll文件不存在," + file.getAbsolutePath());
            }
            System.load(file.getAbsolutePath());
            Environment env = new Environment();
            env.init();
        } catch (Exception e) {
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java
@@ -3,25 +3,32 @@
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.date.DateUtils;
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.DmModuleEntity;
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity;
import com.iailab.module.model.mcs.pre.service.DmModuleService;
import com.iailab.module.model.mcs.pre.service.MmItemOutputService;
import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
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.mcs.pre.vo.*;
import com.iailab.module.model.mpk.common.utils.IAILModelUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
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;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import static com.iailab.framework.common.pojo.CommonResult.success;
@@ -29,6 +36,7 @@
 * @author PanZhibao
 * @date 2021年04月26日 14:42
 */
@Slf4j
@RestController
@RequestMapping("/model/pre/item")
public class MmPredictItemController {
@@ -42,6 +50,13 @@
    @Autowired
    private MmPredictItemService mmPredictItemService;
    @Autowired
    private DmModuleService dmModuleService;
    @Autowired
    private MmItemOutputService mmItemOutputService;
    private int HOUR_MINS = 60;
    /**
     * 预测项列表
     */
@@ -122,4 +137,155 @@
        result.put("originalFilename", file.getOriginalFilename().replace(CommonConstant.MDK_SUFFIX, ""));
        return success(result);
    }
    @GetMapping("/tree")
    public CommonResult<List<PreItemOptionVO>> itemTree() {
        List<PreItemOptionVO> result = new ArrayList<>();
        List<DmModuleEntity> moduleList = dmModuleService.list(new HashMap<>());
        if (CollectionUtils.isEmpty(moduleList)) {
            return success(result);
        }
        moduleList.forEach(item -> {
            PreItemOptionVO moduleOpt = new PreItemOptionVO();
            moduleOpt.setId(item.getId());
            moduleOpt.setLabel(item.getModulename());
            List<PreItemOptionVO> children = new ArrayList<>();
            Map<String, Object> params = new HashMap<>(2);
            params.put("status", 1);
            params.put("moduleid", item.getId());
            List<MmPredictItemRespVO> itemList = mmPredictItemService.list(params);
            itemList.forEach(item1 -> {
                PreItemOptionVO chd = new PreItemOptionVO();
                chd.setLabel(item1.getItemname());
                chd.setId(item1.getId());
                children.add(chd);
            });
            moduleOpt.setChildren(children);
            result.add(moduleOpt);
        });
        return success(result);
    }
    @GetMapping("/view-charts")
    public CommonResult<PreDataBarLineVO> viewCharts(@RequestParam Map<String, Object> params) {
        PreDataBarLineVO result = new PreDataBarLineVO();
        List<String> legends = new ArrayList<>();
        List<PreDataViewVO> dataViewList = new ArrayList<>();
        if (params.get("itemIds") == null) {
            return success(result);
        }
        List<String> itemIdList = Arrays.asList(params.get("itemIds").toString().split(","));
        Date predictTime;
        if (StringUtils.isBlank((String) params.get("predictTime"))) {
            DmModuleEntity dmModule = dmModuleService.getModuleByItemId(itemIdList.get(0));
            if (dmModule != null) {
                predictTime = dmModule.getPredicttime();
            } else {
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.MILLISECOND, 0);
                calendar.set(Calendar.SECOND, 0);
                predictTime = calendar.getTime();
            }
        } else {
            predictTime = DateUtils.parse(params.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
        }
        Date startTime;
        if (StringUtils.isBlank((String) params.get("startTime"))) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(predictTime);
            calendar.add(Calendar.HOUR_OF_DAY, -1);
            startTime = calendar.getTime();
        } else {
            startTime = DateUtils.parse(params.get("startTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
        }
        Date endTime = null;
        if (StringUtils.isBlank((String) params.get("endTime"))) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(predictTime);
            calendar.add(Calendar.HOUR_OF_DAY, 1);
            endTime = calendar.getTime();
        } else {
            endTime = DateUtils.parse(params.get("endTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
        }
        for (int i = 0; i < itemIdList.size(); i++) {
            PreDataViewVO viewDto = new PreDataViewVO();
            String itemId = itemIdList.get(i);
            MmItemOutputEntity mmItemOutput = mmItemOutputService.getByItemid(itemId);
            MmPredictItemEntity predictItem = mmPredictItemService.getById(itemId);
            if (predictItem == null) {
                log.info("itemId=" + itemId + "; is null");
                continue;
            }
            try {
                viewDto.setItemId(itemId);
                viewDto.setItemName(predictItem.getItemname());
                viewDto.setRealData(mmPredictItemService.getHisData(itemId, startTime, endTime));
//                viewDto.setPreDataN(mmItemResultService.getData(mmItemOutput.getId(), startTime, endTime));
//                viewDto.setPreDataL(mmItemResultLastPointService.getData(mmItemOutput.getId(), startTime, endTime));
//                viewDto.setCurData(mmItemResultJsonService.getData(mmItemOutput.getId(), predictTime));
//                viewDto.setAdjData(scheduleAdjustResultService.getData(itemId, predictTime));
                legends.add(predictItem.getItemname());
                List<Double> values = new ArrayList<>();
                if (!CollectionUtils.isEmpty(viewDto.getRealData())) {
                    List<Double> hisValues = new ArrayList<>();
                    viewDto.getRealData().forEach(item -> {
                        values.add(Double.parseDouble(item[1].toString()));
                        hisValues.add(Double.parseDouble(item[1].toString()));
                    });
                    viewDto.setHisMax(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
                    viewDto.setHisMin(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
                    viewDto.setHisAvg(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
                    viewDto.setHisCumulant(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).sum())
                            .divide(new BigDecimal(HOUR_MINS), 2, BigDecimal.ROUND_HALF_UP));
                }
                if (!CollectionUtils.isEmpty(viewDto.getPreDataN())) {
                    viewDto.getPreDataN().forEach(item -> {
                        values.add(Double.parseDouble(item[1].toString()));
                    });
                }
                if (!CollectionUtils.isEmpty(viewDto.getPreDataL())) {
                    List<Double> preValues = new ArrayList<>();
                    viewDto.getPreDataL().forEach(item -> {
                        values.add(Double.parseDouble(item[1].toString()));
                        preValues.add(Double.parseDouble(item[1].toString()));
                    });
                    viewDto.setPreMax(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
                    viewDto.setPreMin(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
                    viewDto.setPreAvg(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
                }
                if (!CollectionUtils.isEmpty(viewDto.getCurData())) {
                    List<Double> preValues = new ArrayList<>();
                    viewDto.getCurData().forEach(item -> {
                        values.add(Double.parseDouble(item[1].toString()));
                        preValues.add(Double.parseDouble(item[1].toString()));
                    });
                    viewDto.setPreCumulant(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).sum())
                            .divide(new BigDecimal(HOUR_MINS), 2, RoundingMode.HALF_UP));
                }
                if (!CollectionUtils.isEmpty(viewDto.getAdjData())) {
                    viewDto.getAdjData().forEach(item -> {
                        values.add(Double.parseDouble(item[1].toString()));
                    });
                }
                if (!CollectionUtils.isEmpty(values)) {
                    viewDto.setMaxValue(BigDecimal.valueOf(values.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
                    viewDto.setMinValue(BigDecimal.valueOf(values.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
                }
                dataViewList.add(viewDto);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        result.setStartTime(startTime);
        result.setEndTime(endTime);
        result.setPredictTime(predictTime);
        result.setCategories(DateUtils.getTimeScale(startTime, endTime, 60));
        result.setLegend(legends);
        result.setDataViewList(dataViewList);
        return success(result);
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/DmModuleDao.java
@@ -8,6 +8,8 @@
import org.apache.ibatis.annotations.Mapper;
import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
import java.util.List;
/**
 * @author PanZhibao
 * @date 2021年04月23日 8:30
@@ -16,6 +18,8 @@
@Mapper
public interface DmModuleDao extends BaseMapperX<DmModuleEntity> {
    List<DmModuleEntity> getModuleByItemId(String itemId);
    default PageResult<DmModuleEntity> selectPage(DmModulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DmModuleEntity>()
                .likeIfPresent(DmModuleEntity::getModulename, reqVO.getModulename())
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleService.java
@@ -28,4 +28,6 @@
    List<DmModuleEntity> getModuleByModuleType(String moduletype);
    DmModuleEntity info(String id);
    DmModuleEntity getModuleByItemId(String itemId);
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
@@ -8,6 +8,7 @@
import com.iailab.module.model.mdk.vo.ItemVO;
import com.iailab.module.model.mdk.vo.MergeItemVO;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -38,4 +39,8 @@
    void update(MmPredictItemDTO mmPredictItemDTO);
    List<MmPredictItemRespVO> list(Map<String, Object> params);
    MmPredictItemEntity getById(String id);
    List<Object[]> getHisData(String itemId, Date startTime, Date endTime);
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleServiceImpl.java
@@ -10,6 +10,7 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
@@ -40,6 +41,15 @@
        return dmModuleDao.selectById(id);
    }
    @Override
    public DmModuleEntity getModuleByItemId(String itemId) {
        List<DmModuleEntity> list = dmModuleDao.getModuleByItemId(itemId);
        if (CollectionUtils.isEmpty(list)) {
            return null;
        }
        return list.get(0);
    }
    private QueryWrapper<DmModuleEntity> getWrapper(Map<String, Object> params) {
        String modulename = (String) params.get("modulename");
        String moduletype = (String) params.get("moduletype");
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.data.api.point.DataPointApi;
import com.iailab.module.model.mcs.pre.dao.MmPredictItemDao;
import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO;
import com.iailab.module.model.mcs.pre.entity.*;
@@ -58,6 +59,9 @@
    @Autowired
    private MmPredictItemDao mmPredictItemDao;
    @Autowired
    private DataPointApi dataPointApi;
    @Override
    public PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO) {
        IPage<MmPredictItemRespVO> page = mmPredictItemDao.selectPage(reqVO);
@@ -70,6 +74,17 @@
        return mmPredictItemDao.queryList(params);
    }
    @Override
    public MmPredictItemEntity getById(String id) {
        return  mmPredictItemDao.selectById(id);
    }
    @Override
    public List<Object[]> getHisData(String itemId, Date startTime, Date endTime) {
        List<Object[]> result = new ArrayList<>();
        return result;
    }
    @DSTransactional(rollbackFor = Exception.class)
    @Override
    public void add(MmPredictItemDTO mmPredictItemDto) {
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreItemOptionVO.java
对比新文件
@@ -0,0 +1,22 @@
package com.iailab.module.model.mcs.pre.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年07月31日
 */
@Data
public class PreItemOptionVO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String id;
    private String label;
    private List<PreItemOptionVO> children;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/DllUtils.java
对比新文件
@@ -0,0 +1,128 @@
package com.iailab.module.model.mpk.common.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import sun.misc.URLClassPath;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Iterator;
import java.util.Vector;
@Slf4j
public class DllUtils {
    /**
     * @description: 加载dll到指定class下
     * @author: dzd
     * @date: 2024/9/30 14:27
     **/
    public static void loadDll(Class<?> clazz, String dllPath) {
        try {
            Method method = Runtime.class.getDeclaredMethod("load0", Class.class,String.class);
            boolean accessible = method.isAccessible();
            method.setAccessible(true);
            method.invoke(Runtime.getRuntime(), clazz,dllPath);
            method.setAccessible(accessible);
            log.info("成功加载dll:"+ dllPath);
        } catch (Exception e) {
            throw new RuntimeException("加载dll异常",e);
        }
    }
    /**
     * @description: 卸载classLoader下全部dll
     * @author: dzd
     * @date: 2024/9/30 14:31
     **/
    public static synchronized void uploadDll(URLClassLoader classLoader) {
        try {
            Field field = ClassLoader.class.getDeclaredField("nativeLibraries");
            field.setAccessible(true);
            Vector<Object> libs = (Vector<Object>) field.get(classLoader);
            Iterator<Object> it = libs.iterator();
            Object o;
            while (it.hasNext()) {
                o = it.next();
                Method method = o.getClass().getDeclaredMethod("finalize");
                boolean accessible = method.isAccessible();
                method.setAccessible(true);
                method.invoke(o);
                method.setAccessible(accessible);
                Field nameDield = o.getClass().getDeclaredField("name");
                nameDield.setAccessible(true);
                String name = (String) nameDield.get(o);
                log.info("成功卸载dll:" + name);
            }
        } catch (Exception e) {
            throw new RuntimeException("卸载dll异常",e);
        }
    }
    /**
     * @description: 从classLoader中卸载dll,如果dllName传null,则默认删除全部dll
     * @author: dzd
     * @date: 2024/9/30 14:52
     **/
    public static synchronized void uploadDllName(URLClassLoader classLoader,String dllName) {
        try {
            Field field = ClassLoader.class.getDeclaredField("nativeLibraries");
            field.setAccessible(true);
            Vector<Object> libs = (Vector<Object>) field.get(classLoader);
            Iterator<Object> it = libs.iterator();
            Object o;
            while (it.hasNext()) {
                o = it.next();
                Field nameDield = o.getClass().getDeclaredField("name");
                nameDield.setAccessible(true);
                String name = (String) nameDield.get(o);
                // dllName不为null 并且 不等于name,跳出(dllName为null默认全部删除)
                if (StringUtils.isNotEmpty(dllName) && !dllName.equals(name)) {
                    return;
                }
                Method method = o.getClass().getDeclaredMethod("finalize");
                boolean accessible = method.isAccessible();
                method.setAccessible(true);
                method.invoke(o);
                method.setAccessible(accessible);
                log.info("成功卸载dll:" + name);
            }
        } catch (Exception e) {
            throw new RuntimeException("卸载dll异常",e);
        }
    }
    /**
     * @description: 加载jar到特定的URLClassLoader,并返回URLClassLoader
     * @author: dzd
     * @date: 2024/9/30 14:20
     **/
    public static synchronized URLClassLoader loadJar(String jarPath) {
        File jarFile = new File(jarPath);
        if (!jarFile.exists()) {
            throw new RuntimeException("jar沒有找到!");
        } else {
            try {
                URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{jarFile.toURI().toURL()});
                log.info("成功加载jar包:"+ jarFile.getAbsolutePath());
                return urlClassLoader;
            } catch (Exception e) {
                throw new RuntimeException("加载jar异常",e);
            }
        }
    }
    public static synchronized void uploadJar(URLClassLoader urlClassLoader) {
        try {
            urlClassLoader.close();
            log.info("成功卸载jar包。");
        } catch (Exception e) {
            throw new RuntimeException("卸载jar异常",e);
        }
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/GenUtils.java
@@ -59,7 +59,7 @@
            FileUtil.writeUtf8String(writer.toString(),toFile);
            IOUtils.closeQuietly(writer);
        } catch (IOException e) {
            throw new RuntimeException("模板渲染异常");
            throw new RuntimeException("模板渲染异常",e);
        }
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/Readtxt.java
@@ -110,32 +110,36 @@
    }
    public static List<double[][]> readMethodExcel(MultipartFile file) throws IOException {
        Workbook workbook = WorkbookFactory.create(file.getInputStream());
        //获取工作薄里面sheet的个数
        int sheetNum = workbook.getNumberOfSheets();
        List<double[][]> datas = new ArrayList<>(sheetNum - 1);
        //从第二个sheet开始读,第一个为示例
        for (int i = 1; i < sheetNum; i++) {
            Sheet sheet = workbook.getSheetAt(i);
            //获取sheet中有数据的行数
            int rows = sheet.getPhysicalNumberOfRows();
            double[][] doubles2 = new double[rows][];
            for (int j = 0; j < rows; j++) {
                //获取每一行的数据
                Row row = sheet.getRow(j);
                //得到每一行中有效单元格的数据
                short cells = row.getLastCellNum();
                //定义一个doubles数组用来存储读取单元格的数据
                double[] doubles1 = new double[cells];
                //遍历每一个有效的单元格数据
                for (int k = 0; k < cells; k++) {
                    //获取每一个单元格的数据
                    Cell cell = row.getCell(k, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                    doubles1[k] = cell.getNumericCellValue();
        List<double[][]> datas;
        try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) {
            //获取工作薄里面sheet的个数
            int sheetNum = workbook.getNumberOfSheets();
            datas = new ArrayList<>(sheetNum - 1);
            //从第二个sheet开始读,第一个为示例
            for (int i = 1; i < sheetNum; i++) {
                Sheet sheet = workbook.getSheetAt(i);
                //获取sheet中有数据的行数
                int rows = sheet.getPhysicalNumberOfRows();
                double[][] doubles2 = new double[rows][];
                for (int j = 0; j < rows; j++) {
                    //获取每一行的数据
                    Row row = sheet.getRow(j);
                    //得到每一行中有效单元格的数据
                    short cells = row.getLastCellNum();
                    //定义一个doubles数组用来存储读取单元格的数据
                    double[] doubles1 = new double[cells];
                    //遍历每一个有效的单元格数据
                    for (int k = 0; k < cells; k++) {
                        //获取每一个单元格的数据
                        Cell cell = row.getCell(k, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        doubles1[k] = cell.getNumericCellValue();
                    }
                    doubles2[j] = doubles1;
                }
                doubles2[j] = doubles1;
                datas.add(doubles2);
            }
            datas.add(doubles2);
        } catch (Exception e) {
            throw new RuntimeException("解析Excel异常",e);
        }
        return datas;
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MdkController.java
@@ -5,17 +5,17 @@
import com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.module.model.mpk.common.MdkConstant;
import com.iailab.module.model.mpk.common.utils.DllUtils;
import com.iailab.module.model.mpk.common.utils.Readtxt;
import com.iailab.module.model.mpk.dto.MdkDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
@@ -30,6 +30,7 @@
 * @createTime 2024年08月08日
 */
@RestController
@Slf4j
@RequestMapping("/model/mpk/api")
public class MdkController {
    @Value("${mpk.bak-file-path}")
@@ -38,7 +39,8 @@
    @PostMapping("run")
    public CommonResult<String> run(@RequestBody MdkDTO dto) {
        Class<?> clazz;
        URLClassLoader classLoader;
        try {
            File jarFile = new File(mpkBakFilePath + File.separator + MdkConstant.JAR + File.separator + dto.getPyName() + ".jar");
            if (!jarFile.exists()) {
@@ -46,13 +48,16 @@
            }
            File dllFile = new File(mpkBakFilePath + File.separator + MdkConstant.DLL + File.separator + dto.getPyName() + ".dll");
            if (!dllFile.exists()) {
                throw new RuntimeException("dllw文件不存在,请先生成代码。dllPath:" + dllFile.getAbsolutePath());
                throw new RuntimeException("dll文件不存在,请先生成代码。dllPath:" + dllFile.getAbsolutePath());
            }
            // 加载jar包
            loadJar(jarFile.getAbsolutePath());
            // 加载dll
            System.load(dllFile.getAbsolutePath());
            classLoader = DllUtils.loadJar(jarFile.getAbsolutePath());
            // 实现类
            clazz = classLoader.loadClass(dto.getClassName());
            // 加载dll到实现类
            DllUtils.loadDll(clazz,dllFile.getAbsolutePath());
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("加载运行环境失败。");
        }
@@ -92,14 +97,16 @@
                paramsArray[datas.size()] = HashMap.class;
            }
            Class<?> clazz = Class.forName(dto.getClassName());
            Method method = clazz.getMethod(dto.getMethodName(), paramsArray);
            HashMap result = (HashMap)method.invoke(clazz.newInstance(), paramsValueArray);
            HashMap result = (HashMap) clazz.getDeclaredMethod(dto.getMethodName(), paramsArray).invoke(clazz.newInstance(), paramsValueArray);
            return success(JSON.toJSONString(result));
        } catch (Exception ex) {
            ex.printStackTrace();
            return error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"运行异常");
        } finally {
            if (classLoader != null) {
                DllUtils.uploadDll(classLoader);
                DllUtils.uploadJar(classLoader);
            }
            System.gc();
        }
    }
@@ -117,20 +124,5 @@
            }
        }
        return success(result);
    }
    private void loadJar(String jarPath) throws Exception {
        File jarFile = new File(jarPath);
        if (!jarFile.exists()) {
            throw new Exception("jar沒有找到!");
        } else {
            Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
            boolean accessible = method.isAccessible();
            method.setAccessible(true);
            URLClassLoader classLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
            URL url = jarFile.toURI().toURL();
            method.invoke(classLoader, url);
            method.setAccessible(accessible);
        }
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java
@@ -102,7 +102,7 @@
            IOUtils.write(data, response.getOutputStream());
        } catch (Exception e) {
            throw new RuntimeException("代码生成异常");
            throw new RuntimeException("代码生成异常",e);
        }
    }
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java
@@ -36,6 +36,7 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
@@ -191,9 +192,13 @@
        VelocityContext dataContext = new VelocityContext(map);
        //临时文件夹
        File dirPath = new File("D:/DLUT/tmp/");
        dirPath.deleteOnExit();
        dirPath.mkdirs();
        File dirPath = null;
        try {
            dirPath = Files.createTempDirectory("generatorCodeTmp").toFile();
            log.info("生成临时文件夹," + dirPath.getAbsolutePath());
        } catch (IOException e) {
            throw new RuntimeException("创建临时文件夹异常",e);
        }
        List<String> javaFilePaths = new ArrayList<>();
        List<String> cppFilePaths = new ArrayList<>();
@@ -275,7 +280,7 @@
        try {
            FileUtils.deleteDirectory(dirPath);
        } catch (IOException e) {
            throw new RuntimeException("删除临时文件异常");
            throw new RuntimeException("删除临时文件异常",e);
        }
        return bytes;
    }
@@ -291,9 +296,13 @@
//        VelocityContext context = new VelocityContext(map);
        //临时文件夹
        File dirPath = new File("D:/DLUT/tmp/");
        dirPath.deleteOnExit();
        dirPath.mkdirs();
        File dirPath = null;
        try {
            dirPath = Files.createTempDirectory("packageModelTmp").toFile();
            log.info("生成临时文件夹," + dirPath.getAbsolutePath());
        } catch (IOException e) {
            throw new RuntimeException("创建临时文件夹异常",e);
        }
        //设置velocity资源加载器
        Properties prop = new Properties();
@@ -436,7 +445,7 @@
            // 等待命令执行完成
            process.waitFor();
        } catch (Exception e) {
            throw new RuntimeException("执行cmd命令生成dll异常");
            throw new RuntimeException("执行cmd命令生成dll异常",e);
        }
    }
@@ -494,7 +503,7 @@
            process.waitFor();
            return jarSavePath;
        } catch (InterruptedException e) {
            throw new RuntimeException("执行cmd命令打jar包异常");
            throw new RuntimeException("执行cmd命令打jar包异常",e);
        }
    }
@@ -515,7 +524,7 @@
            Process process = RuntimeUtil.exec(sb.toString());
            process.waitFor();
        } catch (InterruptedException e) {
            throw new RuntimeException("执行cmd命令生成class异常");
            throw new RuntimeException("执行cmd命令生成class异常",e);
        }
    }
}
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/IAILMDK/common/Environment.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/IAILMDK/utils/AlgsUtils.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/IAIL.MDK.Mid.Windows.dll
Binary files differ
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/status_code.xml
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/version.xml
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/pre/DmModuleDao.xml
对比新文件
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iailab.module.model.mcs.pre.dao.DmModuleDao">
    <select id="getModuleByItemId" resultType="com.iailab.module.model.mcs.pre.entity.DmModuleEntity">
        select t1.*
        from T_DM_MODULE t1
        left join T_DM_MODULE_ITEM t2 on t2.MODULEID = t1.ID
        where t2.ITEMID = #{value}
    </select>
</mapper>
logs/log-debug.2024-09-30.log
对比新文件
文件太大