diff --git a/04.系统编码/Backend/pom.xml b/04.系统编码/Backend/pom.xml index 51e8f7f..ccc2040 100644 --- a/04.系统编码/Backend/pom.xml +++ b/04.系统编码/Backend/pom.xml @@ -107,6 +107,35 @@ RELEASE compile + + + + commons-net + commons-net + 3.6 + + + + + + + + + + com.opencsv + opencsv + 4.4 + + + cn.hutool + hutool-all + 5.8.5 + + + + + + diff --git a/04.系统编码/Backend/src/main/java/com/userinformation/backend/service/QualityCompareService.java b/04.系统编码/Backend/src/main/java/com/userinformation/backend/service/QualityCompareService.java index cd88e79..d9ff5c6 100644 --- a/04.系统编码/Backend/src/main/java/com/userinformation/backend/service/QualityCompareService.java +++ b/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 readContent(String filepath, String filename){ + FTPClient ftpClient = FtpUtil.connection(ftpHost, ftpUsername, ftpPassword,ftpPort); + List fileContent = FtpUtil.getFtpFileContentByCsvType(filename, filepath, ftpClient); + FtpUtil.disconnection(ftpClient); + return fileContent; + } + private List read(String var, String locate, LocalDateTime tempTime, LocalDateTime startTime, List data, int readCount, String fileSuffix, List 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 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 lines = Files.readAllLines(Paths.get(filepath)); +// List lines = Files.readAllLines(Paths.get(filepath)); // 将文件数据进行反转,从最后一行开始读取 - Collections.reverse(lines); + Collections.reverse(fileContent); int addCount = 0; - for(String line : lines){ - List rows = Arrays.asList(line.split(SEPARATOR)); + for(String[] line : fileContent){ + List 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); } diff --git a/04.系统编码/Backend/src/main/java/com/userinformation/backend/util/FtpUtil.java b/04.系统编码/Backend/src/main/java/com/userinformation/backend/util/FtpUtil.java new file mode 100644 index 0000000..c41e8d9 --- /dev/null +++ b/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 getFtpFileContentByCsvType(String fileName, String filePath, FTPClient ftpClient){ + List 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; + } + + /** + * 将一个IO流解析,转化数组形式的集合 + * + * @param in 文件inputStream流 + */ + @SneakyThrows + public List readCsv(InputStream in) { + List 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(); + } + +} diff --git a/04.系统编码/Backend/src/main/resources/application.yml b/04.系统编码/Backend/src/main/resources/application.yml index 060c77b..f9998a7 100644 --- a/04.系统编码/Backend/src/main/resources/application.yml +++ b/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 diff --git a/04.系统编码/Frontend/src/components/Login.vue b/04.系统编码/Frontend/src/components/Login.vue index 729afab..400eb58 100644 --- a/04.系统编码/Frontend/src/components/Login.vue +++ b/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") } }) } diff --git a/04.系统编码/Frontend/src/components/Shared/Header.vue b/04.系统编码/Frontend/src/components/Shared/Header.vue index a90042d..ee4f427 100644 --- a/04.系统编码/Frontend/src/components/Shared/Header.vue +++ b/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) => { diff --git a/04.系统编码/Frontend/src/components/SynergyEvaluation.vue b/04.系统编码/Frontend/src/components/SynergyEvaluation.vue index 3ef51a8..4fe2978 100644 --- a/04.系统编码/Frontend/src/components/SynergyEvaluation.vue +++ b/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", diff --git a/04.系统编码/Frontend/src/model/heat-map-drawer.ts b/04.系统编码/Frontend/src/model/heat-map-drawer.ts index 2e67815..b0b8015 100644 --- a/04.系统编码/Frontend/src/model/heat-map-drawer.ts +++ b/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(); diff --git a/04.系统编码/Frontend/src/uilts/Config.ts b/04.系统编码/Frontend/src/uilts/Config.ts index a5b6d4e..f4145f2 100644 --- a/04.系统编码/Frontend/src/uilts/Config.ts +++ b/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"; }