气象数据实体类,状态数据实体类,样品基础数据实体类移到公用模块下
台站运行管理查询树形结构接口内容修改 日志管理增加查询文件夹树形结构后关闭ftp连接 日志管理增加查询文件内容信息后关闭ftp连接 日志管理下载文件接口修改,下载后管理流以及ftp连接 增加静态名称工具类 system模块修改缓存信息方法 system模块新增根据台站id查询探测器信息方法
This commit is contained in:
parent
e43fec651b
commit
7a055994f3
|
@ -1,4 +1,4 @@
|
|||
package org.jeecg.modules.entity;
|
||||
package org.jeecg.modules.base.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
@ -1,4 +1,4 @@
|
|||
package org.jeecg.modules.entity;
|
||||
package org.jeecg.modules.base.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
@ -10,7 +10,7 @@ import java.io.Serializable;
|
|||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName(value = "gards_sample_data")
|
||||
@TableName("GARDS_SAMPLE_DATA")
|
||||
public class GardsSampleData implements Serializable {
|
||||
|
||||
@TableField(value = "SITE_DET_CODE")
|
||||
|
@ -41,28 +41,28 @@ public class GardsSampleData implements Serializable {
|
|||
private String spectralQualifie;
|
||||
|
||||
@TableField(value = "TRANSMIT_DTG")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date transmitDtg;
|
||||
|
||||
@TableField(value = "COLLECT_START")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date collectStart;
|
||||
|
||||
@TableField(value = "COLLECT_STOP")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date collectStop;
|
||||
|
||||
@TableField(value = "ACQUISITION_START")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date acquisitionStart;
|
||||
|
||||
@TableField(value = "ACQUISITION_STOP")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date acquisitionStop;
|
||||
|
||||
@TableField(value = "ACQUISITION_REAL_SEC")
|
||||
|
@ -78,11 +78,13 @@ public class GardsSampleData implements Serializable {
|
|||
private String status;
|
||||
|
||||
@TableField(value = "MODDATE")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date moddate;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String stationName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String detectorsName;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.jeecg.modules.entity;
|
||||
package org.jeecg.modules.base.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
@ -9,6 +9,7 @@ import org.jeecg.common.util.DateUtils;
|
|||
import org.jeecg.common.util.FTPUtil;
|
||||
import org.jeecg.modules.entity.FileInfo;
|
||||
import org.jeecg.modules.entity.LogManage;
|
||||
import org.jeecg.modules.service.ILogManageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -28,122 +29,13 @@ public class LogManageController {
|
|||
|
||||
@Autowired
|
||||
private FTPUtil ftpUtil;
|
||||
@Autowired
|
||||
private ILogManageService logManageService;
|
||||
|
||||
@GetMapping("findFtpFolders")
|
||||
@ApiOperation(value = "查询日志文件夹树形结构", notes = "查询日志文件夹树形结构")
|
||||
public List<LogManage> findFtpFolders(String workPath){
|
||||
List<LogManage> result = new ArrayList<>();
|
||||
try {
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
if(Objects.isNull(ftpClient)){
|
||||
throw new RuntimeException("ftp连接失败!");
|
||||
}
|
||||
//切换工作文件路径
|
||||
ftpClient.changeWorkingDirectory(workPath);
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listDirectories());
|
||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||
int num =1;
|
||||
for (FTPFile ftpFile:ftpFiles) {
|
||||
LogManage logManage = new LogManage();
|
||||
logManage.setName(ftpFile.getName());
|
||||
logManage.setOrderNum(num);
|
||||
logManage.setParentNum(0);
|
||||
logManage.setPath(workPath + "/" + ftpFile.getName());
|
||||
result.add(logManage);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(result)){
|
||||
List<LogManage> list = new LinkedList<>();
|
||||
for (LogManage logManage:result) {
|
||||
list = this.findDirectory(ftpClient, list, logManage.getOrderNum(), workPath + "/" + logManage.getName());
|
||||
ftpClient.changeToParentDirectory();
|
||||
}
|
||||
result.addAll(list);
|
||||
}
|
||||
if (ftpClient != null){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
result = this.LogManageTree(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历查询当前路径下的文件夹信息
|
||||
* @param ftp
|
||||
* @param list
|
||||
* @param filePath 以"/"开始和结束
|
||||
* @return
|
||||
*/
|
||||
public List<LogManage> findDirectory(FTPClient ftp,List<LogManage> list,Integer parentNum,String filePath){
|
||||
try {
|
||||
if (filePath.indexOf("/")>0){
|
||||
List<String> paths = Arrays.asList(filePath.split("/"));
|
||||
for (String path:paths) {
|
||||
ftp.changeWorkingDirectory(path);
|
||||
}
|
||||
}
|
||||
List<FTPFile> ftpFiles = Arrays.asList(ftp.listDirectories());
|
||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||
int num =1;
|
||||
for (FTPFile file : ftpFiles) {
|
||||
if (file.isDirectory()) {
|
||||
LogManage logManage = new LogManage();
|
||||
logManage.setName(file.getName());
|
||||
logManage.setOrderNum(num);
|
||||
logManage.setParentNum(parentNum);
|
||||
logManage.setPath(filePath +"/"+ file.getName());
|
||||
list.add(logManage);
|
||||
num++;
|
||||
// 需要加此判断。否则,ftp默认将‘项目文件所在目录之下的目录(./)’与‘项目文件所在目录向上一级目录下的目录(../)’都纳入递归,这样下去就陷入一个死循环了。需将其过滤掉。
|
||||
if (!".".equals(file.getName()) && !"..".equals(file.getName())) {
|
||||
findDirectory(ftp,list,num,filePath +"/"+ file.getName());
|
||||
ftp.changeToParentDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将当前的文件夹转换成树形结构
|
||||
* @param logManages
|
||||
* @return
|
||||
*/
|
||||
public List<LogManage> LogManageTree(List<LogManage> logManages){
|
||||
if (logManages == null) {
|
||||
return null;
|
||||
}
|
||||
List<LogManage> result = new LinkedList<>();
|
||||
Integer TOP_NODE_ID = 0;
|
||||
logManages.forEach(logManage -> {
|
||||
Integer pid = logManage.getParentNum();
|
||||
if (pid == null || TOP_NODE_ID.equals(pid)) {
|
||||
result.add(logManage);
|
||||
return;
|
||||
}
|
||||
for (LogManage manage : logManages) {
|
||||
Integer id = manage.getOrderNum();
|
||||
if (id != null && id.equals(pid)) {
|
||||
if (manage.getChildren() == null) {
|
||||
manage.initChildren();
|
||||
}
|
||||
logManage.setHashParent(true);
|
||||
manage.getChildren().add(logManage);
|
||||
manage.setHashChild(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
return logManageService.findFtpFolders(workPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,40 +46,7 @@ public class LogManageController {
|
|||
@GetMapping("findFiles")
|
||||
@ApiOperation(value = "查询目录下文件内容", notes = "查询目录下文件内容")
|
||||
public List<FileInfo> findFiles(String path){
|
||||
List<FileInfo> result = new ArrayList<>();
|
||||
try {
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
if (Objects.isNull(ftpClient)){
|
||||
throw new RuntimeException("ftp连接失败!");
|
||||
}
|
||||
List<String> paths = Arrays.asList(path.split("/"));
|
||||
if (CollectionUtils.isNotEmpty(paths)){
|
||||
for (String workPath:paths) {
|
||||
//切换工作文件路径
|
||||
ftpClient.changeWorkingDirectory(workPath);
|
||||
}
|
||||
}
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
|
||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||
for (FTPFile ftpFile:ftpFiles) {
|
||||
if (ftpFile.isFile()){
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.setFileName(ftpFile.getName());
|
||||
fileInfo.setFilePath(path +"/"+ ftpFile.getName());
|
||||
fileInfo.setFileSize(String.format("%.2f", Double.valueOf(Double.valueOf(ftpFile.getSize())/1024)) + "KB");
|
||||
fileInfo.setFileDate(DateUtils.formatDate(ftpFile.getTimestamp(),"yyyy-MM-dd"));
|
||||
result.add(fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ftpClient != null){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
return logManageService.findFiles(path);
|
||||
}
|
||||
|
||||
@PostMapping("downloadFile")
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import org.jeecg.modules.entity.FileInfo;
|
||||
import org.jeecg.modules.entity.LogManage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ILogManageService {
|
||||
|
||||
/**
|
||||
* 查询日志文件夹树形结构
|
||||
* @param workPath
|
||||
* @return
|
||||
*/
|
||||
List<LogManage> findFtpFolders(String workPath);
|
||||
|
||||
/**
|
||||
* 查询目录下文件内容
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
List<FileInfo> findFiles(String path);
|
||||
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.FTPUtil;
|
||||
import org.jeecg.modules.entity.FileInfo;
|
||||
import org.jeecg.modules.entity.LogManage;
|
||||
import org.jeecg.modules.service.ILogManageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@Service("logManageService")
|
||||
public class LogManageServiceImpl implements ILogManageService {
|
||||
|
||||
@Autowired
|
||||
private FTPUtil ftpUtil;
|
||||
|
||||
@Override
|
||||
public List<LogManage> findFtpFolders(String workPath) {
|
||||
List<LogManage> result = new ArrayList<>();
|
||||
try {
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
if(Objects.isNull(ftpClient)){
|
||||
throw new RuntimeException("ftp连接失败!");
|
||||
}
|
||||
//切换工作文件路径
|
||||
ftpClient.changeWorkingDirectory(workPath);
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listDirectories());
|
||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||
int num =1;
|
||||
for (FTPFile ftpFile:ftpFiles) {
|
||||
LogManage logManage = new LogManage();
|
||||
logManage.setName(ftpFile.getName());
|
||||
logManage.setOrderNum(num);
|
||||
logManage.setParentNum(0);
|
||||
logManage.setPath(workPath + "/" + ftpFile.getName());
|
||||
result.add(logManage);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(result)){
|
||||
List<LogManage> list = new LinkedList<>();
|
||||
for (LogManage logManage:result) {
|
||||
list = this.findDirectory(ftpClient, list, logManage.getOrderNum(), workPath + "/" + logManage.getName());
|
||||
ftpClient.changeToParentDirectory();
|
||||
}
|
||||
result.addAll(list);
|
||||
}
|
||||
if (ftpClient != null){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
result = this.LogManageTree(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileInfo> findFiles(String path) {
|
||||
List<FileInfo> result = new ArrayList<>();
|
||||
try {
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
if (Objects.isNull(ftpClient)){
|
||||
throw new RuntimeException("ftp连接失败!");
|
||||
}
|
||||
List<String> paths = Arrays.asList(path.split("/"));
|
||||
if (CollectionUtils.isNotEmpty(paths)){
|
||||
for (String workPath:paths) {
|
||||
//切换工作文件路径
|
||||
ftpClient.changeWorkingDirectory(workPath);
|
||||
}
|
||||
}
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
|
||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||
for (FTPFile ftpFile:ftpFiles) {
|
||||
if (ftpFile.isFile()){
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.setFileName(ftpFile.getName());
|
||||
fileInfo.setFilePath(path +"/"+ ftpFile.getName());
|
||||
fileInfo.setFileSize(String.format("%.2f", Double.valueOf(Double.valueOf(ftpFile.getSize())/1024)) + "KB");
|
||||
fileInfo.setFileDate(DateUtils.formatDate(ftpFile.getTimestamp(),"yyyy-MM-dd"));
|
||||
result.add(fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ftpClient != null){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历查询当前路径下的文件夹信息
|
||||
* @param ftp
|
||||
* @param list
|
||||
* @param filePath 以"/"开始和结束
|
||||
* @return
|
||||
*/
|
||||
public List<LogManage> findDirectory(FTPClient ftp,List<LogManage> list,Integer parentNum,String filePath){
|
||||
try {
|
||||
if (filePath.indexOf("/")>0){
|
||||
List<String> paths = Arrays.asList(filePath.split("/"));
|
||||
for (String path:paths) {
|
||||
ftp.changeWorkingDirectory(path);
|
||||
}
|
||||
}
|
||||
List<FTPFile> ftpFiles = Arrays.asList(ftp.listDirectories());
|
||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||
int num =1;
|
||||
for (FTPFile file : ftpFiles) {
|
||||
if (file.isDirectory()) {
|
||||
LogManage logManage = new LogManage();
|
||||
logManage.setName(file.getName());
|
||||
logManage.setOrderNum(num);
|
||||
logManage.setParentNum(parentNum);
|
||||
logManage.setPath(filePath +"/"+ file.getName());
|
||||
list.add(logManage);
|
||||
num++;
|
||||
// 需要加此判断。否则,ftp默认将‘项目文件所在目录之下的目录(./)’与‘项目文件所在目录向上一级目录下的目录(../)’都纳入递归,这样下去就陷入一个死循环了。需将其过滤掉。
|
||||
if (!".".equals(file.getName()) && !"..".equals(file.getName())) {
|
||||
findDirectory(ftp,list,num,filePath +"/"+ file.getName());
|
||||
ftp.changeToParentDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将当前的文件夹转换成树形结构
|
||||
* @param logManages
|
||||
* @return
|
||||
*/
|
||||
public List<LogManage> LogManageTree(List<LogManage> logManages){
|
||||
if (logManages == null) {
|
||||
return null;
|
||||
}
|
||||
List<LogManage> result = new LinkedList<>();
|
||||
Integer TOP_NODE_ID = 0;
|
||||
logManages.forEach(logManage -> {
|
||||
Integer pid = logManage.getParentNum();
|
||||
if (pid == null || TOP_NODE_ID.equals(pid)) {
|
||||
result.add(logManage);
|
||||
return;
|
||||
}
|
||||
for (LogManage manage : logManages) {
|
||||
Integer id = manage.getOrderNum();
|
||||
if (id != null && id.equals(pid)) {
|
||||
if (manage.getChildren() == null) {
|
||||
manage.initChildren();
|
||||
}
|
||||
logManage.setHashParent(true);
|
||||
manage.getChildren().add(logManage);
|
||||
manage.setHashChild(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,11 @@
|
|||
<artifactId>spatial4j</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
<!-- feign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package org.jeecg.common;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
public class CacheName {
|
||||
|
||||
public static final String cacheTime = "Cache time";
|
||||
|
||||
public static final String scaleInterval = "Scale interval";
|
||||
|
||||
public static final String timelineLength = "Timeline length ";
|
||||
|
||||
public static final String updateIntervalTime = "Update interval time";
|
||||
|
||||
}
|
|
@ -12,6 +12,6 @@ public class StationTree {
|
|||
|
||||
private String code;
|
||||
|
||||
List<GardsStations> children;
|
||||
List<Object> children;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.base.entity.GardsMetData;
|
||||
|
||||
public interface StationMetDataMapper extends BaseMapper<GardsMetData> {
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.base.entity.GardsSampleData;
|
||||
|
||||
public interface StationSampleDataMapper extends BaseMapper<GardsSampleData> {
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.base.entity.GardsSohData;
|
||||
|
||||
public interface StationSohDataMapper extends BaseMapper<GardsSohData> {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?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="org.jeecg.modules.mapper.StationMetDataMapper">
|
||||
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,7 @@
|
|||
<?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="org.jeecg.modules.mapper.StationSampleDataMapper">
|
||||
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,7 @@
|
|||
<?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="org.jeecg.modules.mapper.StationSohDataMapper">
|
||||
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,21 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.GardsDetectors;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@FeignClient(value = "jeecg-system")
|
||||
public interface ICacheTimeService {
|
||||
|
||||
@RequestMapping("/alarmSysUser/findCacheTime")
|
||||
List<Map<String, String>> findCacheTime();
|
||||
|
||||
@RequestMapping("/alarmSysUser/findStationDetectors")
|
||||
Map<String, List<GardsDetectors>> findStationDetectors(List<String> stationIds);
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -8,6 +9,7 @@ import com.spatial4j.core.context.SpatialContext;
|
|||
import com.spatial4j.core.distance.DistanceUtils;
|
||||
import com.spatial4j.core.shape.Rectangle;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.jeecg.common.CacheName;
|
||||
import org.jeecg.common.PointUtil;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
|
@ -15,6 +17,8 @@ import org.jeecg.common.util.RedisUtil;
|
|||
import org.jeecg.modules.entity.Point;
|
||||
import org.jeecg.modules.entity.PointVo;
|
||||
import org.jeecg.modules.entity.StationTree;
|
||||
import org.jeecg.modules.service.ICacheTimeService;
|
||||
import org.jeecg.modules.system.entity.GardsDetectors;
|
||||
import org.jeecg.modules.system.entity.GardsNuclearfacility;
|
||||
import org.jeecg.modules.system.entity.GardsStations;
|
||||
import org.jeecg.modules.entity.StationOperation;
|
||||
|
@ -31,10 +35,12 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("stationOperationService")
|
||||
@DS("ora")
|
||||
@DS("ori")
|
||||
public class StationOperationServiceImpl extends ServiceImpl<StationOperationMapper, StationOperation> implements IStationOperationService {
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private ICacheTimeService cacheTimeService;
|
||||
|
||||
private final SpatialContext spatialContext = SpatialContext.GEO;
|
||||
|
||||
|
@ -53,7 +59,13 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
StationOperation stationOperation = new StationOperation();
|
||||
stationOperation.setStationId(gardsStation.getStationId());
|
||||
stationOperation.setStationName(gardsStation.getStationCode());
|
||||
stationOperation.setStationType("IMS STATION");
|
||||
if (gardsStation.getStationId()<=200){
|
||||
stationOperation.setStationType("IMS STATION(P)");
|
||||
}else if(gardsStation.getStationId()>200 && gardsStation.getStationId()<=300){
|
||||
stationOperation.setStationType("IMS STATION(G)");
|
||||
}else if(gardsStation.getStationId()>300){
|
||||
stationOperation.setStationType("NRL");
|
||||
}
|
||||
stationOperation.setAltitude(Objects.isNull(gardsStation.getElevation())?"":gardsStation.getElevation()+"m");
|
||||
stationOperation.setLon(String.valueOf(gardsStation.getLon()));
|
||||
stationOperation.setLat(String.valueOf(gardsStation.getLat()));
|
||||
|
@ -86,7 +98,7 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
@Override
|
||||
public Result findInfo(String stationId, String type) {
|
||||
Result result = new Result();
|
||||
if (type.equals("IMS STATION")){
|
||||
if (type.equals("IMS STATION(P)") || type.equals("IMS STATION(G)")){
|
||||
HashMap<String, GardsStations> stationInfoMap = (HashMap<String, GardsStations>) redisUtil.get("stationInfoMap");
|
||||
GardsStations stations = stationInfoMap.get(stationId);
|
||||
if (Objects.nonNull(stations)){
|
||||
|
@ -128,20 +140,45 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
}
|
||||
if (CollectionUtils.isNotEmpty(gardsStationsList)){
|
||||
//过滤出所有的台站城市编码
|
||||
List<String> countryCodes = gardsStationsList.stream().map(GardsStations::getCountryCode).distinct().sorted().collect(Collectors.toList());
|
||||
for (String countryCode:countryCodes) {
|
||||
//声明一个数组存储城市编码对应的数组信息
|
||||
List<GardsStations> stationsList = new LinkedList<>();
|
||||
StationTree stationTree = new StationTree();
|
||||
stationTree.setStationId(countryCodes.indexOf(countryCode)+1);
|
||||
stationTree.setCode(countryCode);
|
||||
for (GardsStations stations:gardsStationsList) {
|
||||
if (stations.getCountryCode().equals(countryCode)){
|
||||
stationsList.add(stations);
|
||||
List<Object> countryCodes = gardsStationsList.stream().map(GardsStations::getCountryCode).distinct().sorted().collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(countryCodes)){
|
||||
for (int i=0; i<3; i++){
|
||||
//树形结构子级 用于存储城市及城市下的台站信息
|
||||
List<Object> stationChildTreeList = new LinkedList<>();
|
||||
StationTree stationTree = new StationTree();
|
||||
stationTree.setStationId(i);
|
||||
if (i == 0){
|
||||
stationTree.setCode("Particulate Station");
|
||||
}else if (i == 1){
|
||||
stationTree.setCode("Noble Gas Station");
|
||||
}else if (i == 2){
|
||||
stationTree.setCode("NRL");
|
||||
}
|
||||
for (Object countryCode:countryCodes) {
|
||||
//用于存储城市下对应的台站信息
|
||||
List<Object> stations = new LinkedList<>();
|
||||
String country = String.valueOf(countryCode);
|
||||
//声明一个数组存储城市编码对应的数组信息
|
||||
StationTree stationChildTree = new StationTree();
|
||||
stationChildTree.setStationId(countryCodes.indexOf(countryCode)+1);
|
||||
stationChildTree.setCode(country);
|
||||
List<GardsStations> stationsList = gardsStationsList.stream().filter(station-> station.getCountryCode().equals(countryCode)).collect(Collectors.toList());
|
||||
if (i == 0){
|
||||
stationsList = stationsList.stream().filter(item-> item.getStationId()<=200).collect(Collectors.toList());
|
||||
stations.addAll(stationsList);
|
||||
}else if(i == 1){
|
||||
stationsList = stationsList.stream().filter(item-> item.getStationId()>200 && item.getStationId()<=300).collect(Collectors.toList());
|
||||
stations.addAll(stationsList);
|
||||
}else if(i == 2){
|
||||
stationsList = stationsList.stream().filter(item-> item.getStationId()>300).collect(Collectors.toList());
|
||||
stations.addAll(stationsList);
|
||||
}
|
||||
stationChildTree.setChildren(stations);
|
||||
stationChildTreeList.add(stationChildTree);
|
||||
stationTree.setChildren(stationChildTreeList);
|
||||
}
|
||||
stationTreeList.add(stationTree);
|
||||
}
|
||||
stationTree.setChildren(stationsList);
|
||||
stationTreeList.add(stationTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +271,7 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
}
|
||||
resultList.add(nuclearFacilityPoints);
|
||||
}
|
||||
map.put("GIS", stationsList);
|
||||
map.put("GIS", stationsList.stream().distinct().collect(Collectors.toList()));
|
||||
map.put("table", resultList);
|
||||
}
|
||||
}
|
||||
|
@ -245,18 +282,31 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
|
||||
@Override
|
||||
public Result getDataReceivingStatus(List<String> stationIds) {
|
||||
//获取四项缓存数据的对应内容
|
||||
List<Map<String, String>> cacheList = cacheTimeService.findCacheTime();
|
||||
String cacheTime = "";
|
||||
String scaleInterval = "";
|
||||
String timelineLength = "";
|
||||
String updateIntervalTime = "";
|
||||
for (int i=0; i< cacheList.size(); i++){
|
||||
if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.cacheTime)) ){
|
||||
cacheTime = cacheList.get(i).get(CacheName.cacheTime);
|
||||
}else if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.scaleInterval)) ){
|
||||
scaleInterval = cacheList.get(i).get(CacheName.scaleInterval);
|
||||
}else if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.timelineLength)) ){
|
||||
timelineLength = cacheList.get(i).get(CacheName.timelineLength);
|
||||
}else if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.updateIntervalTime)) ){
|
||||
updateIntervalTime = cacheList.get(i).get(CacheName.updateIntervalTime);
|
||||
}
|
||||
}
|
||||
//遍历台站id
|
||||
if (CollectionUtils.isNotEmpty(stationIds)){
|
||||
//获取当前日期时间
|
||||
//获取当前日期时间 作为结束查询时间
|
||||
LocalDate endDate = LocalDate.now();
|
||||
//将当前日期换算成
|
||||
// endDate.minusDays();
|
||||
|
||||
|
||||
|
||||
//根据台站id
|
||||
|
||||
|
||||
|
||||
//根据缓存日期 得到开始查询时间
|
||||
LocalDate startDate = endDate.minusDays(Integer.valueOf(cacheTime));
|
||||
//根据台站id查询出当前台站下处于运行状态的数据
|
||||
Map<String, List<GardsDetectors>> stationDetectors = cacheTimeService.findStationDetectors(stationIds);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.jeecg.config.valid.InsertGroup;
|
||||
import org.jeecg.config.valid.UpdateGroup;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("GARDS_DETECTORS")
|
||||
public class GardsDetectors implements Serializable {
|
||||
|
||||
@TableField(value = "DETECTOR_ID")
|
||||
private Integer detectorId;
|
||||
|
||||
@TableField(value = "DETECTOR_CODE")
|
||||
private String detectorCode;
|
||||
|
||||
@TableField(value = "LON")
|
||||
private Double lon;
|
||||
|
||||
@TableField(value = "LAT")
|
||||
private Double lat;
|
||||
|
||||
@TableField(value = "TYPE")
|
||||
private String type;
|
||||
|
||||
@TableField(value = "CHANNELS")
|
||||
private Double channels;
|
||||
|
||||
@TableField(value = "RATED_EFFICIENCY")
|
||||
private Double ratedEfficiency;
|
||||
|
||||
@TableField(value = "RATED_RESOLUTION")
|
||||
private Double ratedResolution;
|
||||
|
||||
@TableField(value = "ECAL_RANGE_MAX")
|
||||
private Double ecalRangeMax;
|
||||
|
||||
@TableField(value = "DATE_BEGIN")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date dateBegin;
|
||||
|
||||
@TableField(value = "DATE_END")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date dateEnd;
|
||||
|
||||
@TableField(value = "STATUS")
|
||||
private String status;
|
||||
|
||||
@TableField(value = "DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
@TableField(value = "MODDATE")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date moddate;
|
||||
|
||||
@TableField(value = "STATION_ID")
|
||||
private Integer stationId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String stationName;
|
||||
|
||||
}
|
|
@ -4,9 +4,9 @@ import io.swagger.annotations.Api;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.GardsMetData;
|
||||
import org.jeecg.modules.entity.GardsSampleData;
|
||||
import org.jeecg.modules.entity.GardsSohData;
|
||||
import org.jeecg.modules.base.entity.GardsMetData;
|
||||
import org.jeecg.modules.base.entity.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.GardsSohData;
|
||||
import org.jeecg.modules.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.entity.GardsMetData;
|
||||
import org.jeecg.modules.base.entity.GardsMetData;
|
||||
|
||||
public interface GardsMetDataMapper extends BaseMapper<GardsMetData> {
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.entity.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.GardsSampleData;
|
||||
|
||||
public interface GardsSampleDataMapper extends BaseMapper<GardsSampleData> {
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.entity.GardsSohData;
|
||||
import org.jeecg.modules.base.entity.GardsSohData;
|
||||
|
||||
public interface GardsSohDataMapper extends BaseMapper<GardsSohData> {
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.GardsAnalyses;
|
||||
import org.jeecg.modules.entity.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.GardsSampleData;
|
||||
import org.jeecg.modules.mapper.GardsAnalysesMapper;
|
||||
import org.jeecg.modules.service.IAutoService;
|
||||
import org.jeecg.modules.service.IGardsSampleDataService;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
import org.jeecg.modules.system.entity.SysRole;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserRole;
|
||||
import org.jeecg.modules.system.mapper.SysDictItemMapper;
|
||||
import org.jeecg.modules.system.mapper.SysRoleMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserRoleMapper;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -21,6 +16,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.commons.collections.CollectionUtils.collect;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("alarmSysUser")
|
||||
public class AlarmSysUserController {
|
||||
|
@ -33,6 +30,8 @@ public class AlarmSysUserController {
|
|||
private SysRoleMapper sysRoleMapper;
|
||||
@Resource
|
||||
private SysDictItemMapper sysDictItemMapper;
|
||||
@Resource
|
||||
private GardsDetectorsMapper gardsDetectorsMapper;
|
||||
|
||||
@GetMapping("findUserMap")
|
||||
public Map<String, SysUser> findUserMap(){
|
||||
|
@ -69,23 +68,51 @@ public class AlarmSysUserController {
|
|||
|
||||
|
||||
@RequestMapping("findCacheTime")
|
||||
public void findCacheTime(){
|
||||
public List<Map<String, String>> findCacheTime(){
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
List<SysDictItem> sysDictItems = sysDictItemMapper.selectList(queryWrapper);
|
||||
List<Map<String, String>> result = new LinkedList<>();
|
||||
//获取缓存时间对应的值
|
||||
Map<String, String> cacheTime = sysDictItems.stream().filter(item -> item.getItemText().equals("Cache time"))
|
||||
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
|
||||
List<SysDictItem> cacheTime = sysDictItems.stream().filter(item -> item.getItemText().equals("Cache time")).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(cacheTime)){
|
||||
Map<String, String> cacheTimeMap = cacheTime.stream().collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
|
||||
result.add(cacheTimeMap);
|
||||
}
|
||||
//获取实际分度值
|
||||
Map<String, String> scaleInterval = sysDictItems.stream().filter(item -> item.getItemText().equals("Scale interval"))
|
||||
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
|
||||
List<SysDictItem> scaleInterval = sysDictItems.stream().filter(item -> item.getItemText().equals("Scale interval")).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(scaleInterval)){
|
||||
Map<String, String> scaleIntervalMap = scaleInterval.stream().collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
|
||||
result.add(scaleIntervalMap);
|
||||
}
|
||||
//获取时间线长度
|
||||
Map<String, String> timelineLength = sysDictItems.stream().filter(item -> item.getItemText().equals("Timeline length"))
|
||||
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
|
||||
List<SysDictItem> timelineLength = sysDictItems.stream().filter(item -> item.getItemText().equals("Timeline length")).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(timelineLength)){
|
||||
Map<String, String> timelineLengthMap = timelineLength.stream().collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
|
||||
result.add(timelineLengthMap);
|
||||
}
|
||||
//获取更新间隔时间
|
||||
Map<String, String> updateIntervalTime = sysDictItems.stream().filter(item -> item.getItemText().equals("Update interval time"))
|
||||
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
|
||||
|
||||
List<SysDictItem> updateIntervalTime = sysDictItems.stream().filter(item -> item.getItemText().equals("Update interval time")).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(updateIntervalTime)){
|
||||
Map<String, String> updateIntervalTimeMap = updateIntervalTime.stream().collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
|
||||
result.add(updateIntervalTimeMap);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("findStationDetectors")
|
||||
@DS("ora")
|
||||
public Map<String, List<GardsDetectors>> findStationDetectors(List<String> stationIds){
|
||||
Map<String, List<GardsDetectors>> map = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(stationIds)){
|
||||
LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>();
|
||||
List<GardsDetectors> detectorsList = gardsDetectorsMapper.selectList(queryWrapper);
|
||||
for (String stationId:stationIds) {
|
||||
List<GardsDetectors> detectors = detectorsList.stream().filter(item -> item.getStationId().equals(stationId) && item.getStatus().equals("Operating")).collect(Collectors.toList());
|
||||
map.put(stationId, detectors);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user