From 1164b9c9ea7e4c58cc872394649aebf012c45bdd Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Mon, 28 Aug 2023 17:14:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8F=B0=E7=AB=99=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=9F=A5=E8=AF=A2=E6=9C=89=E6=95=88=E7=8E=87?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9Eused=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/CalculateDataRateThread.java | 1 + .../modules/mapper/CalCulStationInfoMapper.java | 4 ++++ .../modules/mapper/xml/calCulStationInfoMapper.xml | 4 ++++ .../modules/service/ICalCulStationDataService.java | 2 ++ .../service/impl/CalCulStationInfoServiceImpl.java | 14 ++++++++++++++ 5 files changed, 25 insertions(+) diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateDataRateThread.java b/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateDataRateThread.java index 662fae54..e831dd38 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateDataRateThread.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateDataRateThread.java @@ -61,6 +61,7 @@ public class CalculateDataRateThread implements Runnable{ calculateDataRate.setParameter(mRateparam); //根据台站编码 查询 台站信息 StationInfo stationInfo = calCulStationDataService.getStationInfo(originalstationsinfo.getStationCode()); + stationInfo.setUsed(calCulStationDataService.getUsed(Integer.valueOf(stationInfo.getId()))); //赋值台站信息 calculateDataRate.setMStationId(stationInfo.getId()); calculateDataRate.setMStationCode(stationInfo.getStationCode()); diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/CalCulStationInfoMapper.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/CalCulStationInfoMapper.java index 508da7b0..cf730183 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/CalCulStationInfoMapper.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/CalCulStationInfoMapper.java @@ -4,6 +4,8 @@ import org.apache.ibatis.annotations.Param; import org.jeecg.modules.entity.data.ProvisionData; import org.jeecg.modules.entity.data.StationInfo; +import java.util.List; + public interface CalCulStationInfoMapper { StationInfo getStationInfo(@Param("stationCode") String stationCode); @@ -62,4 +64,6 @@ public interface CalCulStationInfoMapper { ProvisionData findSphdMetSohProvisionParticulate(@Param("SPHD_NUM") String SPHD_NUM, @Param("MET_NUM") String MET_NUM, @Param("curDateTime") String curDateTime, @Param("pretime") String pretime, @Param("sphdMetSoh") String sphdMetSoh, @Param("stationId") String stationId); + List getUsed(Integer stationId); + } diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/xml/calCulStationInfoMapper.xml b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/xml/calCulStationInfoMapper.xml index 678504e9..52081c98 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/xml/calCulStationInfoMapper.xml +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/xml/calCulStationInfoMapper.xml @@ -395,4 +395,8 @@ + + \ No newline at end of file diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/ICalCulStationDataService.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/ICalCulStationDataService.java index b00184da..ac504a1f 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/ICalCulStationDataService.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/ICalCulStationDataService.java @@ -61,4 +61,6 @@ public interface ICalCulStationDataService { ProvisionData findSphdMetSohProvisionParticulate(String SPHD_NUM, String MET_NUM, String curDateTime, String pretime, String sphdMetSoh,String stationId); + String getUsed(Integer stationId); + } diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/CalCulStationInfoServiceImpl.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/CalCulStationInfoServiceImpl.java index 2db7a7da..cdade4d4 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/CalCulStationInfoServiceImpl.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/CalCulStationInfoServiceImpl.java @@ -1,12 +1,18 @@ package org.jeecg.modules.service.impl; import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import org.jeecg.modules.entity.data.ProvisionData; import org.jeecg.modules.entity.data.StationInfo; import org.jeecg.modules.mapper.CalCulStationInfoMapper; import org.jeecg.modules.service.ICalCulStationDataService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Objects; @Service("calCulStationDataService") @DS("ora") @@ -440,5 +446,13 @@ public class CalCulStationInfoServiceImpl implements ICalCulStationDataService { return sphdMetSohProvision; } + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public String getUsed(Integer stationId){ + List detectorIds = calCulStationInfoMapper.getUsed(stationId); + String result = CollectionUtils.isNotEmpty(detectorIds) ? "YES" : "NO"; + return result; + } + } From 68d113f0ab84847042ff7f71dd7a198c8d76f35a Mon Sep 17 00:00:00 2001 From: nieziyan Date: Tue, 29 Aug 2023 09:12:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat=EF=BC=9A=E8=B0=B1=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/constant/Prompt.java | 4 +-- .../base/comparator/FileComparator.java | 34 +++++++++++++++++++ .../org/jeecg/modules/base/dto/FileDto.java | 7 +--- .../service/impl/SpectrumFileServiceImpl.java | 7 +++- 4 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/comparator/FileComparator.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/Prompt.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/Prompt.java index d09954b2..b37d9ca5 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/Prompt.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/Prompt.java @@ -21,7 +21,7 @@ public interface Prompt { String DATA_NOT_EXITS = "The Query Data Does Not Exist!"; - String DATA_IS_EMPTY = "The Query Data IS Empty!"; + String DATA_IS_EMPTY = "The Query Data Is Empty!"; String FTP_ERR = "FTP Connection Failed!"; @@ -41,7 +41,7 @@ public interface Prompt { String UPLOAD_ERR = "File Upload Failure!"; - String FILE_NAME_REPEAT = "File With The Same Name Appears, Stop Uploading!"; + String FILE_IS_EMPTY = "The List Of Files You Uploaded Is Empty!"; String NEED_TIME = "The Start Time Or End Time Cannot Be Empty!"; } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/comparator/FileComparator.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/comparator/FileComparator.java new file mode 100644 index 00000000..28626188 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/comparator/FileComparator.java @@ -0,0 +1,34 @@ +package org.jeecg.modules.base.comparator; + +import cn.hutool.core.util.StrUtil; +import org.jeecg.modules.base.dto.FileDto; +import java.util.Comparator; + +public class FileComparator implements Comparator { + + private String field; + private String order; + + public FileComparator(String field, String order) { + this.field = field; + this.order = order; + } + + @Override + public int compare(FileDto file1, FileDto file2) { + if (StrUtil.equals(order,"asc")) { + if (StrUtil.equals(field,"name")) { + return file1.getName().compareTo(file2.getName()); + } else if (StrUtil.equals(field,"updateDate")) { + return file1.getUpdateDate().compareTo(file2.getUpdateDate()); + } + } else if (StrUtil.equals(order,"desc")) { + if (StrUtil.equals(field,"name")) { + return file2.getName().compareTo(file1.getName()); + } else if (StrUtil.equals(field,"updateDate")) { + return file2.getUpdateDate().compareTo(file1.getUpdateDate()); + } + } + return 0; + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/FileDto.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/FileDto.java index dde51d38..adc9e4cf 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/FileDto.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/FileDto.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; import java.util.Date; @Data -public class FileDto implements Comparable{ +public class FileDto{ private String name; @@ -16,9 +16,4 @@ public class FileDto implements Comparable{ @JsonFormat(pattern = DateConstant.DATE_TIME,timezone = DateConstant.TIME_ZONE) private Date updateDate; - - @Override - public int compareTo(@NotNull FileDto o) { - return this.name.compareTo(o.getName()); - } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java index 21bdfd28..9b50cad2 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java @@ -16,6 +16,7 @@ import org.jeecg.common.constant.enums.FileTypeEnum; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.FTPUtil; import org.jeecg.common.util.PageUtil; +import org.jeecg.modules.base.comparator.FileComparator; import org.jeecg.modules.base.dto.FileDto; import org.jeecg.modules.base.vo.FileVo; import org.jeecg.modules.service.ISpectrumFileService; @@ -70,6 +71,8 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { } fileList.add(oneFile); } + if (CollUtil.isEmpty(fileList)) + return Result.error(Prompt.FILE_IS_EMPTY); ftpClient = ftpUtil.LoginFTP(); if (ObjectUtil.isNull(ftpClient)) return Result.error(Prompt.FTP_ERR); @@ -139,7 +142,9 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { fileDto.setSize(formatSize(size)); fileDtos.add(fileDto); } - Collections.sort(fileDtos); + String field = fileVo.getField(); + String order = fileVo.getOrder(); + fileDtos.sort(new FileComparator(field, order)); List records = PageUtil.page(pageNo, pageSize, fileDtos); page.setRecords(records).setTotal(fileDtos.size()); return Result.OK(page);