Browse Source

modify some codes

master
xiaowuler 2 years ago
parent
commit
9571ece801
  1. 29
      04.系统编码/Backend/pom.xml
  2. 51
      04.系统编码/Backend/src/main/java/com/userinformation/backend/service/QualityCompareService.java
  3. 118
      04.系统编码/Backend/src/main/java/com/userinformation/backend/util/FtpUtil.java
  4. 10
      04.系统编码/Backend/src/main/resources/application.yml
  5. 5
      04.系统编码/Frontend/src/components/Login.vue
  6. 2
      04.系统编码/Frontend/src/components/Shared/Header.vue
  7. 18
      04.系统编码/Frontend/src/components/SynergyEvaluation.vue
  8. 4
      04.系统编码/Frontend/src/model/heat-map-drawer.ts
  9. 8
      04.系统编码/Frontend/src/uilts/Config.ts

29
04.系统编码/Backend/pom.xml

@ -107,6 +107,35 @@
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- ftp -->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.sourceforge.javacsv</groupId>-->
<!-- <artifactId>javacsv</artifactId>-->
<!-- <version>2.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.5</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>cn.hutool</groupId>-->
<!-- <artifactId>hutool-all</artifactId>-->
<!-- <version>5.8.5</version>-->
<!-- </dependency>-->
</dependencies>
<build>

51
04.系统编码/Backend/src/main/java/com/userinformation/backend/service/QualityCompareService.java

@ -1,5 +1,8 @@
package com.userinformation.backend.service;
import com.userinformation.backend.util.FtpUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.net.ftp.FTPClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -21,12 +24,23 @@ import java.util.stream.Collectors;
* @describe: 质控对比服务层
*/
@Service
@Slf4j
public class QualityCompareService {
@Value("${custom.ftp.host}")
private String ftpHost;
@Value("${custom.ftp.port}")
private Integer ftpPort;
@Value("${custom.ftp.username}")
private String ftpUsername;
@Value("${custom.ftp.password}")
private String ftpPassword;
private static final String EXTINCTION = "MEXT";
private static final String SEPARATOR = ",";
private static final DateTimeFormatter NORMAL_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static final DateTimeFormatter _NORMAL_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy/M/d H:m");
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH");
@ -70,19 +84,32 @@ public class QualityCompareService {
return data.stream().filter(values -> index.getAndIncrement() % 12 != 0).collect(Collectors.toList());
}
private List<String[]> readContent(String filepath, String filename){
FTPClient ftpClient = FtpUtil.connection(ftpHost, ftpUsername, ftpPassword,ftpPort);
List<String[]> fileContent = FtpUtil.getFtpFileContentByCsvType(filename, filepath, ftpClient);
FtpUtil.disconnection(ftpClient);
return fileContent;
}
private List<Float[]> read(String var, String locate, LocalDateTime tempTime, LocalDateTime startTime, List<Float[]> data, int readCount, String fileSuffix, List<Float[]> invalid, int currentLength, int timeLength) throws IOException, IllegalAccessException {
String filepath = String.format("%s/%s/%s/%s-%s.CSV", qualityPath, getFilepathByLocate(locate), fileSuffix, var, tempTime.format(TIME_FORMATTER));
if (Files.notExists(Paths.get(filepath))) {
String filepath = String.format("/%s/%s", getFilepathByLocate(locate), fileSuffix);
String filename = String.format("%s-%s.CSV", var, tempTime.format(TIME_FORMATTER));
List<String[]> fileContent = readContent(filepath, filename);
// filepath = String.format("%s/%s/%s/%s-%s.CSV", qualityPath, getFilepathByLocate(locate), fileSuffix, var, tempTime.format(TIME_FORMATTER));
// if (Files.notExists(Paths.get(filepath))) {
// return addInvalidOrBlackFile(var, locate, tempTime, startTime, data, readCount, fileSuffix, invalid, data.size() / 12, timeLength);
// }
if (Objects.isNull(fileContent)){
return addInvalidOrBlackFile(var, locate, tempTime, startTime, data, readCount, fileSuffix, invalid, data.size() / 12, timeLength);
}
List<String> lines = Files.readAllLines(Paths.get(filepath));
// List<String> lines = Files.readAllLines(Paths.get(filepath));
// 将文件数据进行反转,从最后一行开始读取
Collections.reverse(lines);
Collections.reverse(fileContent);
int addCount = 0;
for(String line : lines){
List<String> rows = Arrays.asList(line.split(SEPARATOR));
for(String[] line : fileContent){
List<String> rows = Arrays.asList(line);
// 相关数据时间转换,以比较,并按照10分钟间隔过滤
LocalDateTime targetTime = LocalDateTime.parse(rows.get(0), NORMAL_TIME_FORMATTER);
if (targetTime.isAfter(tempTime)) {
@ -122,12 +149,18 @@ public class QualityCompareService {
private String getFilepathByLocate(String locate) throws IllegalAccessException {
switch (locate){
// case "pk":
// return "CloudOutPut2_PUKOU/R1W4201224002";
// case "lh":
// return "CloudOutPut1_LIUHE/R1W4201224001";
// case "jn":
// return "CloudOutPut_JIANGNING/R1W4210113003";
case "pk":
return "CloudOutPut2_PUKOU/R1W4201224002";
return "pk/R1W4201224002";
case "lh":
return "CloudOutPut1_LIUHE/R1W4201224001";
return "lh/R1W4201224001";
case "jn":
return "CloudOutPut_JIANGNING/R1W4210113003";
return "jn/R1W4210113003";
default:
throw new IllegalAccessException("未知的站点:" + locate);
}

118
04.系统编码/Backend/src/main/java/com/userinformation/backend/util/FtpUtil.java

@ -0,0 +1,118 @@
package com.userinformation.backend.util;
import cn.hutool.core.text.csv.CsvReadConfig;
import cn.hutool.core.text.csv.CsvReader;
import cn.hutool.core.text.csv.CsvRow;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.SocketException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @version 1.0
* @author: xiaowuler
* @createTime: 2022-11-07 10:43
* @description ftp 工具类
*/
@UtilityClass
@Slf4j
public class FtpUtil {
public FTPClient connection(String ftpHost, String ftpUsername, String ftpPassword, int ftpPort){
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect(ftpHost, ftpPort);
ftpClient.login(ftpUsername, ftpPassword);
if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
log.info("未连接到,用户名或密码错误");
disconnection(ftpClient);
return null;
}
ftpClient.enterLocalPassiveMode();
} catch (SocketException e) {
e.printStackTrace();
log.info("FTP的IP地址可能错误,请正确配置");
} catch (IOException e) {
e.printStackTrace();
log.info("FTP的端口错误,请正确配置");
}
return ftpClient;
}
public boolean isExist(String filename, FTPClient ftpClient) throws IOException {
return ftpClient.listFiles(filename).length > 0;
}
@SneakyThrows
public List<String[]> getFtpFileContentByCsvType(String fileName, String filePath, FTPClient ftpClient){
List<String[]> fileContent = new ArrayList<>();
ftpClient.changeWorkingDirectory(filePath);
// if (!isExist(fileName, ftpClient)){
// return null;
// }
InputStream in = ftpClient.retrieveFileStream(fileName);
if (Objects.isNull(in)){
return null;
}
fileContent.addAll(readCsv(in));
in.close();
ftpClient.completePendingCommand();
return fileContent;
}
/**
* <b>将一个IO流解析转化数组形式的集合<b>
*
* @param in 文件inputStream流
*/
@SneakyThrows
public List<String[]> readCsv(InputStream in) {
List<String[]> csvList = new ArrayList<>();
if (null != in) {
CsvReader reader = new CsvReader(new InputStreamReader(in, "gbk"), CsvReadConfig.defaultConfig());
reader.stream().forEach((CsvRow csvRow) -> {
csvList.add(csvRow.getRawList().stream().toArray(String[]::new));
});
// CsvData
// try {
// // 遍历每一行,若有#注释部分,则不处理,若没有,则加入csvList
// while (reader.readRecord()) {
// if (!reader.getValues()[0].contains("#")){// 清除注释部分
// csvList.add(reader.getValues());
// log.info(Arrays.toString(csvList.get(csvList.size() - 1)));
// }
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
reader.close();
}
return csvList;
}
@SneakyThrows
public void disconnection(FTPClient ftpClient){
if (Objects.isNull(ftpClient) || !ftpClient.isConnected()){
return;
}
ftpClient.disconnect();
}
}

10
04.系统编码/Backend/src/main/resources/application.yml

@ -23,8 +23,18 @@ custom:
# path: D:\下载\可视化平台\product
# parent-url: http://localhost
# quality-path: E:/Memorandum/VPN配置/南京/多曼雷达项目/AllData
# ftp:
# port: 21
# host: 192.168.0.112
# username: xiaowuler@163.com
# password: a7758a58
path: /home/project/NJEnvironmentPlatform/html/product
parent-url: http://10.124.102.10
quality-path: /share/win
ftp:
port: 8063
host: 10.124.102.135
username: lmmjgld
password: xxzx_211@FTP
# path: /home/develop/product
# parent-url: http://rdp.nagr.com.cn

5
04.系统编码/Frontend/src/components/Login.vue

@ -66,6 +66,9 @@ export default {
userPassword: option.inputPassword
};
//
// setStaff('login_staff', guid())
post("user/userLogin",{
data: encrypt(params)
}).then((res :any)=>{
@ -76,7 +79,7 @@ export default {
});
}else {
setStaff('login_staff', guid())
router.push("/MicrowaveRadiation")
router.push("/RamanLidar")
}
})
}

2
04.系统编码/Frontend/src/components/Shared/Header.vue

@ -39,7 +39,7 @@
setup() {
const router = useRouter();
let options = reactive({
currentPath: 'MicrowaveRadiation'
currentPath: 'RamanLidar'
})
const onNavClick = (path) => {

18
04.系统编码/Frontend/src/components/SynergyEvaluation.vue

@ -312,19 +312,19 @@ export default {
timeRange: [
{
time: 'time0130',
dateRange: ['2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2002-2020)']
dateRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2002-2020)']
},
{
time: 'time1030',
dateRange: ['2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
dateRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
},
{
time: 'time1330',
dateRange: ['2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2002-2020)']
dateRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2002-2020)']
},
{
time: 'time2230',
dateRange: ['2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
dateRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
}
],
},
@ -332,31 +332,31 @@ export default {
elementCode: "LAI",
isTimeRange: false,
isDateRange: true,
timeRange: ['2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2002-2020)']
timeRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2002-2020)']
},
{
elementCode: "EVI",
isTimeRange: false,
isDateRange: true,
timeRange: ['2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
timeRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
},
{
elementCode: "NDVI",
isTimeRange: false,
isDateRange: true,
timeRange: ['2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020']
timeRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020']
},
{
elementCode: "Albedo",
isTimeRange: false,
isDateRange: true,
timeRange: ['2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
timeRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
},
{
elementCode: "Evapotranspiration",
isTimeRange: false,
isDateRange: true,
timeRange: ['2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
timeRange: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '多年平均值(2000-2020)']
},
{
elementCode: "landCoverTypes",

4
04.系统编码/Frontend/src/model/heat-map-drawer.ts

@ -261,8 +261,8 @@ export class HeatMapDrawer{
let name = "高度(m)";
this.canvasContext.translate(45, this.height / 2 + this.paddingTop - this.canvasContext.measureText(name).width);
this.canvasContext.rotate(Math.PI * 1.5);
this.canvasContext.font="normal 22px 微软雅黑";
this.canvasContext.fillStyle="#000000";
this.canvasContext.font="normal 20px 微软雅黑";
this.canvasContext.fillStyle="#3A3A3A";
this.canvasContext.fillText(name, 0, 0);
this.canvasContext.restore();

8
04.系统编码/Frontend/src/uilts/Config.ts

@ -2,10 +2,10 @@ import { Moment } from "moment";
import { format } from "./String";
export class Config {
public static url: string = "";
public static parentUrl: string = "http://10.124.102.10:8002/product/picture";
// public static url: string = "http://localhost:8002";
// public static parentUrl: string = "http://112.124.40.88:8999/product/picture";
// public static url: string = "";
// public static parentUrl: string = "http://10.124.102.10:8002/product/picture";
public static url: string = "http://localhost:8002";
public static parentUrl: string = "http://112.124.40.88:8999/product/picture";
// public static parentUrl: string = "http://localhost:8002/product/picture";
// public static parentUrl: string = "http://rdp.nagr.com.cn:8082/product/picture";
}

Loading…
Cancel
Save