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 66d811f2..d09954b2 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 @@ -42,4 +42,6 @@ public interface Prompt { String UPLOAD_ERR = "File Upload Failure!"; String FILE_NAME_REPEAT = "File With The Same Name Appears, Stop Uploading!"; + + 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/entity/postgre/AlarmContactGroup.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/AlarmContactGroup.java index 9d8ae658..e8b0fc30 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/AlarmContactGroup.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/AlarmContactGroup.java @@ -6,10 +6,12 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import org.jeecg.common.constant.DateConstant; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.time.LocalDate; +import java.time.LocalDateTime; @Data @TableName(value = "alarm_contact_group") @@ -37,9 +39,9 @@ public class AlarmContactGroup implements Serializable { * 创建时间 */ @TableField(value = "create_time") - @JsonFormat(pattern = "yyyy-MM-dd") - @DateTimeFormat(pattern = "yyyy-MM-dd") - private LocalDate createTime; + @JsonFormat(pattern = DateConstant.DATE_TIME,timezone = DateConstant.TIME_ZONE) + @DateTimeFormat(pattern = DateConstant.DATE_TIME) + private LocalDateTime createTime; /** * 创建人 @@ -51,9 +53,9 @@ public class AlarmContactGroup implements Serializable { * 修改时间 */ @TableField(value = "update_time") - @JsonFormat(pattern = "yyyy-MM-dd") - @DateTimeFormat(pattern = "yyyy-MM-dd") - private LocalDate updateTime; + @JsonFormat(pattern = DateConstant.DATE_TIME,timezone = DateConstant.TIME_ZONE) + @DateTimeFormat(pattern = DateConstant.DATE_TIME) + private LocalDateTime updateTime; /** * 修改人 diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/FileVo.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/FileVo.java new file mode 100644 index 00000000..162e7f1b --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/FileVo.java @@ -0,0 +1,10 @@ +package org.jeecg.modules.base.vo; + +import lombok.Data; +import org.jeecg.common.api.QueryRequest; + +@Data +public class FileVo extends QueryRequest { + + String name; +} diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AlarmContactGroupServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AlarmContactGroupServiceImpl.java index 83f7fd11..2c4eea15 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AlarmContactGroupServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AlarmContactGroupServiceImpl.java @@ -24,6 +24,7 @@ import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -113,7 +114,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl i public Result viewAll(AlarmVo alarmVo) { String startDate = alarmVo.getStartDate(); String endDate = alarmVo.getEndDate(); - boolean startNotBlank = StrUtil.isNotBlank(startDate); - boolean endtNotBlank = StrUtil.isNotBlank(endDate); + boolean startBlank = StrUtil.isBlank(startDate); + boolean endBlank = StrUtil.isBlank(endDate); + boolean blank = startBlank || endBlank; + if (blank)return Result.error(Prompt.NEED_TIME); // 拼接日期为合理的日期+时间范围 alarmVo.setStartDate(startDate + DateConstant.TIME_START); alarmVo.setEndDate(endDate + DateConstant.TIME_END); diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysEmailLogServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysEmailLogServiceImpl.java index 57905676..431daf04 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysEmailLogServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysEmailLogServiceImpl.java @@ -2,10 +2,12 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.DateConstant; +import org.jeecg.common.constant.Prompt; import org.jeecg.modules.base.entity.postgre.SysEmailLog; import org.jeecg.modules.mapper.SysEmailLogMapper; import org.jeecg.modules.service.ISysEmailLogService; @@ -25,7 +27,7 @@ import java.util.stream.IntStream; public class SysEmailLogServiceImpl extends ServiceImpl implements ISysEmailLogService { @Override - public Result totalEmail(String emailId) { + public Result totalEmail(String emailId) { // 当日邮件量 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SysEmailLog::getEmailId,emailId); @@ -58,7 +60,7 @@ public class SysEmailLogServiceImpl extends ServiceImpl todayHour(String emailId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SysEmailLog::getEmailId,emailId); LocalDate today = LocalDate.now(); @@ -84,7 +86,7 @@ public class SysEmailLogServiceImpl extends ServiceImpl todayMin(String emailId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SysEmailLog::getEmailId,emailId); LocalDate today = LocalDate.now(); @@ -115,7 +117,11 @@ public class SysEmailLogServiceImpl extends ServiceImpl analysis(String emailId, String startDate, String endDate) { + boolean startBlank = StrUtil.isBlank(startDate); + boolean endBlank = StrUtil.isBlank(endDate); + boolean blank = startBlank || endBlank; + if (blank)return Result.error(Prompt.NEED_TIME); String startStr = startDate + DateConstant.TIME_START; String endStr = endDate + DateConstant.TIME_END; LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumFileController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumFileController.java index 2c4cba23..2d1243f2 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumFileController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumFileController.java @@ -12,6 +12,7 @@ import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPReply; import org.apache.shiro.SecurityUtils; +import org.apache.xmlbeans.impl.xb.xmlconfig.Extensionconfig; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.DateConstant; @@ -21,6 +22,7 @@ import org.jeecg.common.constant.enums.FileTypeEnum; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.FTPUtil; import org.jeecg.modules.base.dto.FileDto; +import org.jeecg.modules.base.vo.FileVo; import org.jeecg.modules.service.ISpectrumFileService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -43,17 +45,14 @@ public class SpectrumFileController { @PostMapping("upload") @ApiOperation(value = "谱文件上传",notes = "谱文件上传") - public Result upload(@RequestParam MultipartFile file, - @RequestParam String choice){ - return spectrumFileService.upload(file,choice); + public Result upload(@RequestParam MultipartFile file){ + return spectrumFileService.upload(file); } @GetMapping("get") @ApiOperation(value = "用户谱文件列表",notes = "用户谱文件列表") - public Result get(QueryRequest query){ - Integer pageNo = query.getPageNo(); - Integer pageSize = query.getPageSize(); - return spectrumFileService.get(pageNo,pageSize); + public Result get(FileVo fileVo){ + return spectrumFileService.get(fileVo); } public static void unzip(File zipFile, String destDir) throws IOException { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumFileService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumFileService.java index ef76a30e..f6bb43af 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumFileService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumFileService.java @@ -2,12 +2,13 @@ package org.jeecg.modules.service; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.base.vo.FileVo; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; public interface ISpectrumFileService { - Result upload(MultipartFile file,String choice); + Result upload(MultipartFile file); - Result get(Integer pageNo,Integer pageSize); + Result get(FileVo fileVo); } 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 6c08fa3a..21bdfd28 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 @@ -9,6 +9,7 @@ import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.Prompt; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.enums.FileTypeEnum; @@ -16,6 +17,7 @@ import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.FTPUtil; import org.jeecg.common.util.PageUtil; import org.jeecg.modules.base.dto.FileDto; +import org.jeecg.modules.base.vo.FileVo; import org.jeecg.modules.service.ISpectrumFileService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,6 +28,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -36,7 +39,7 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { private FTPUtil ftpUtil; @Override - public Result upload(MultipartFile file, String choice) { + public Result upload(MultipartFile file) { String filename = file.getOriginalFilename(); boolean isZip = filename.endsWith(FileTypeEnum.zip.getType()); if (!isZip) return Result.error(Prompt.FILE_TYPE_ERR); @@ -70,49 +73,14 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { ftpClient = ftpUtil.LoginFTP(); if (ObjectUtil.isNull(ftpClient)) return Result.error(Prompt.FTP_ERR); - // 如果指定目录不存在,直接上传 + // 如果指定目录不存在,创建目录 boolean exist = ftpClient.changeWorkingDirectory(filePath); - if (!exist){ - ftpClient.makeDirectory(filePath); - for (File oneFile : fileList) { - String fullFilePath = filePath + slash + oneFile.getName(); - FileInputStream local = new FileInputStream(oneFile); - ftpClient.storeFile(fullFilePath,local); - } - return Result.OK(Prompt.UPLOAD_SUCC); - } - // 如果指定目录存在,则获取指定目录下所有文件名 - List remoteFileNames = ListUtil.toList(ftpClient.listNames()); - Collection crossFileNames = CollUtil.intersection(fileNames, remoteFileNames); - // 没有重名文件,直接全部导入 - if (CollUtil.isEmpty(crossFileNames)){ - for (File oneFile : fileList) { - String fullFilePath = filePath + slash + oneFile.getName(); - FileInputStream local = new FileInputStream(oneFile); - ftpClient.storeFile(fullFilePath,local); - } - return Result.OK(Prompt.UPLOAD_SUCC); - } - // 有重名文件,根据用户选择进行处理 - if (StrUtil.equals("stop",choice)){ // 1.停止上传 - return Result.error(Prompt.FILE_NAME_REPEAT); - }else if (StrUtil.equals("over",choice)){ // 2.直接覆盖 - for (File oneFile : fileList) { - String fullFilePath = filePath + slash + oneFile.getName(); - FileInputStream local = new FileInputStream(oneFile); - ftpClient.storeFile(fullFilePath,local); - } - }else if (StrUtil.equals("skip",choice)){ // 3.保留原文件 - for (File oneFile : fileList) { - String oneFileName = oneFile.getName(); - if (crossFileNames.contains(oneFileName)) - continue; - String fullFilePath = filePath + slash + oneFileName; - FileInputStream local = new FileInputStream(oneFile); - ftpClient.storeFile(fullFilePath,local); - } - }else { // 默认不上传 - return Result.error(Prompt.FILE_NAME_REPEAT); + if (!exist) ftpClient.makeDirectory(filePath); + // 上传所有文件 + for (File oneFile : fileList) { + String fullFilePath = filePath + slash + oneFile.getName(); + FileInputStream local = new FileInputStream(oneFile); + ftpClient.storeFile(fullFilePath,local); } return Result.OK(Prompt.UPLOAD_SUCC); } catch (IOException e) { @@ -136,7 +104,9 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { } @Override - public Result get(Integer pageNo, Integer pageSize) { + public Result get(FileVo fileVo) { + Integer pageNo = fileVo.getPageNo(); + Integer pageSize = fileVo.getPageSize(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String username = user.getUsername(); String slash = SymbolConstant.SINGLE_SLASH; @@ -151,6 +121,13 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { boolean exist = ftpClient.changeWorkingDirectory(filePath); if (!exist) return Result.OK(page); List ftpFiles = ListUtil.toList(ftpClient.listFiles()); + // 根据文件名进行过滤 + String name = fileVo.getName(); + if (StrUtil.isNotBlank(name)){ + ftpFiles = ftpFiles.stream() + .filter(file -> StrUtil.containsIgnoreCase(file.getName(),name)) + .collect(Collectors.toList()); + } for (FTPFile ftpFile : ftpFiles) { String fileName = ftpFile.getName(); Calendar calendar = ftpFile.getTimestamp(); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java index cdf13ff7..73ab68b2 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java @@ -130,7 +130,7 @@ public class QuartzJobServiceImpl extends ServiceImpl