Commit 438fe4ee authored by litengwei's avatar litengwei

Merge remote-tracking branch 'origin/develop_dl_plan6_temp' into develop_dl_plan6_temp

parents 9b5c0778 717a6d44
sonarqube-check-amos-boot-biz-temp:
image: maven:3.6.3-jdk-11
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
MAVEN_CLI_OPTS: "-s /root/.m2/settings.xml"
MAVEN_OPTS: "-Dmaven.repo.local=/root/.m2/repository"
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
- .m2/repository
script:
- mvn $MAVEN_CLI_OPTS verify sonar:sonar -Dsonar.projectKey=moa_amos-boot-biz_AYZ4D-RdsWVV_jQK869u $MAVEN_OPTS
allow_failure: true
only:
- main
\ No newline at end of file
......@@ -26,6 +26,7 @@ public class DateUtils {
public static final String YEAR_PATTERN = "yyyy";
public static final String MINUTE_ONLY_PATTERN = "mm";
public static final String HOUR_ONLY_PATTERN = "HH";
public static final String MONTH_DAY_PATTERN = "MM-dd";
public static final String MONTH_DAY_HOUR_PATTERN = "MM-dd HH";
public static final String MONTH_DAY_HOUR_MINUTE_PATTERN = "MM-dd HH:mm";
public static final String DATE_PATTERN_NUM = "yyyyMMdd";
......@@ -911,6 +912,8 @@ public class DateUtils {
while (true) {
if (MONTH_DAY_HOUR_PATTERN.equals(pattern)) {
date = dateAddMinutes(date, 60);
} else if (DATE_PATTERN.equals(pattern) || MONTH_DAY_PATTERN.equals(pattern)) {
date = dateAddDays(date, 1);
} else {
date = dateAddMinutes(date, 1);
}
......@@ -1012,4 +1015,33 @@ public class DateUtils {
final LocalDateTime end = LocalDateTime.parse(sdf.format(endTime), DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).toHours();
}
/**
* 获取两个时间段之间的天数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 天数
*/
public static Long getDurationDays(String startTime, String endTime, String pattern) {
final LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).toDays();
}
/**
* 获取两个时间段之间的天数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 天数
*/
public static Long getDurationDays(Date startTime, Date endTime, String pattern) {
final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
final LocalDateTime start = LocalDateTime.parse(sdf.format(startTime), DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(sdf.format(endTime), DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).toDays();
}
}
......@@ -54,14 +54,11 @@ public class WordConverterUtils {
FileItem item = factory.createItem("textField", "text/plain", true, file.getName());
int bytesRead = 0;
byte[] buffer = new byte[8192];
try {
FileInputStream fis = new FileInputStream(file);
OutputStream os = item.getOutputStream();
try (FileInputStream fis = new FileInputStream(file);
OutputStream os = item.getOutputStream();) {
while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
......
package com.yeejoin.equipmanage.common.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
@Data
public class BuildingImportDto {
@ColumnWidth(40)
@ExcelProperty(value = "数据类型", index = 0)
private String dataType;
@ColumnWidth(25)
@ExcelProperty(value = "建筑类型", index = 1)
private String buildingType;
@ColumnWidth(25)
@ExcelProperty(value = "编号", index = 2)
private String code;
@ColumnWidth(25)
@ExcelProperty(value = "建筑类别", index = 3)
private String buildingCategory;
@ColumnWidth(25)
@ExcelProperty(value = "建筑地址", index = 4)
private String buildingAddress;
@ColumnWidth(25)
@ExcelProperty(value = "建筑名称", index = 5)
private String buildName;
@ColumnWidth(25)
@ExcelProperty(value = "所在建筑", index = 6)
private String inWhichBuild;
@ColumnWidth(25)
@ExcelProperty(value = "建造日期", index = 7)
private String buildDate;
@ColumnWidth(25)
@ExcelProperty(value = "保护对象", index = 8)
private String protectedObjects;
@ColumnWidth(25)
@ExcelProperty(value = "责任人", index = 9)
private String dutyUser;
@ColumnWidth(25)
@ExcelProperty(value = "投用日期", index = 10)
private String putDate;
@ColumnWidth(25)
@ExcelProperty(value = "维保单位", index = 11)
private String maintenanceCompany;
@ColumnWidth(25)
@ExcelProperty(value = "每班人数", index = 12)
private String personNumber;
@ColumnWidth(25)
@ExcelProperty(value = "安装位置描述", index = 13)
private String locationDescription;
@ColumnWidth(25)
@ExcelProperty(value = "火灾预案(有、无)", index = 14)
private String firePlan;
@ColumnWidth(25)
@ExcelProperty(value = "消防控制室操作人员持证数", index = 15)
private String licensesNumber;
}
......@@ -24,7 +24,7 @@ import java.util.Date;
@Accessors(chain = true)
@TableName("wl_stock_detail")
@ApiModel(value = "StockDetail对象", description = "库存明细")
public class StockDetail extends BaseEntity implements Cloneable {
public class StockDetail extends BaseEntity {
private static final long serialVersionUID = 1L;
......@@ -90,14 +90,4 @@ public class StockDetail extends BaseEntity implements Cloneable {
@ApiModelProperty(value = "位置信息")
private String area;
@Override
public StockDetail clone() {
try {
return (StockDetail) super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return null;
}
}
package com.yeejoin.equipmanage.common.enums;
/**
* 是否物联设备
*/
public enum IsIotEnum {
isIot("物联设备", 1),
notIot("非物联设备", 0);
private final String description;
private final int status;
IsIotEnum(String description, int status) {
this.description = description;
this.status = status;
}
public String getDescription() {
return description;
}
public int getStatus() {
return status;
}
}
......@@ -13,17 +13,18 @@ import java.util.Map;
public enum PressurePumpAnalysisEnum {
PRESSURE_PUMP_FAULT("1", "1", "稳压泵是否故障", "无", ""),
PRESSURE_PUMP_INTERVAL("2", "2", "最近一次启停间隔", "0", "分钟"),
PRESSURE_PUMP_DURATION("3", "3", "最近一次启动时长", "0", "分钟"),
PRESSURE_PUMP_HALF("4", "4", "半小时启动", "0", "次"),
PRESSURE_PUMP_TWO("5", "5", "2小时启动", "0", "次"),
PRESSURE_PUMP_INTERVAL("2", "2", "最近一次启停间隔", 0, "分钟"),
PRESSURE_PUMP_DURATION("3", "3", "最近一次启动时长", 0, "分钟"),
PRESSURE_PUMP_HALF("4", "4", "半小时启动", 0, "次"),
// PRESSURE_PUMP_TWO("5", "5", "2小时启动", 0, "次"),
PRESSURE_PUMP_DAY_AVG("5", "5", "近3日平均启动", 0, "次"),
PRESSURE_PUMP_PIPE("6", "6", "管网压力", "正常", "");
private final String key;
private final String code;
private final String name;
private final Object value;
private final String unit;
private String key;
private String code;
private String name;
private Object value;
private String unit;
PressurePumpAnalysisEnum(String key, String code, String name, Object value, String unit) {
this.key = key;
......@@ -37,22 +38,42 @@ public enum PressurePumpAnalysisEnum {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public static List<Map<String, Object>> getList(){
PressurePumpAnalysisEnum[] values = PressurePumpAnalysisEnum.values();
List<Map<String, Object>> list = new ArrayList<>();
......
......@@ -13,17 +13,21 @@ public enum PressurePumpRelateEnum {
ONE_HOUR_MINUTE("60", "60分钟"),
IOT_INDEX_VALUE_TRUE("true", "物联指标值:true"),
IOT_INDEX_VALUE_FALSE("false", "物联指标值:false"),
ONE_TIME("1", "物联指标最近1条数据"),
HALF_HOUR("0.5", "半小时"),
ONE_HOUR("1.0", "1小时"),
TWO_HOUR("2.0", "2小时"),
FOUR_HOUR("4.0", "4小时"),
DAY_AVG("-3", "今日累计启停次数,取前3天平均值"),
CRON_BEFORE_DAY("-1", "昨天定时任务"),
START_FIVE("5", "稳压泵启动5分钟"),
PIPE_PRESSURE_DIFF("0.5", "管网压力差判定标准,> 0.05Mpa 异常, <= 0.05 正常"),
PIPE_PRESSURE_DIFF("0.05", "管网压力差判定标准,> 0.05Mpa 异常, <= 0.05 正常"),
PRESSURE_PUMP_START_BEFORE_MINUTE("-5", "稳压泵启泵前分钟数"),
PIPE_PRESSURE_NORMAL_STATUS("正常", "稳压泵管网压力正常状态"),
PIPE_PRESSURE_ABNORMAL_STATUS("异常", "稳压泵管网压力异常状态"),
START("1", "稳压泵启动"),
STOP("0", "稳压泵停止"),
START("1", "启动"),
STOP("0", "停止"),
RESET("2", "复位"),
CREATED_TIME("createdTime", "物联采集信号创建时间属性"),
UN_CLEAN_TIME("false", "未消除");
......
......@@ -23,12 +23,8 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Base64;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**
* @author lisong
......@@ -76,6 +72,14 @@ public class ChartsUtils {
fis.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return fileBytes;
}
......
package com.yeejoin.equipmanage.common.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
......@@ -36,6 +9,12 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
*
......@@ -105,22 +84,16 @@ public class ExcelUtil
}
return workbook;
}
public static void createXSSFExcel(String path, String fileName, List<String> headers, List<List<String>> dataList) {
try {
File file = new File(path);
if (!file.isDirectory()) {
file.mkdirs();
}
file = new File(path + "\\" + fileName);
XSSFWorkbook workbook;
if (!file.exists()) {
workbook = new XSSFWorkbook();
} else {
workbook = new XSSFWorkbook(new FileInputStream(file));
}
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(workbook, 2000);
File file = new File(path + "\\" + fileName);
if (!file.isDirectory()) {
file.mkdirs();
}
try (FileInputStream inputStream = new FileInputStream(file);
FileOutputStream out = new FileOutputStream(file);
XSSFWorkbook workbook = file.exists() ? new XSSFWorkbook(inputStream) : new XSSFWorkbook();
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(workbook, 2000)) {
int sheetNum = sxssfWorkbook.getNumberOfSheets();
if (sheetNum == 0) {
sxssfWorkbook.createSheet();
......@@ -150,16 +123,13 @@ public class ExcelUtil
}
fillExcelContent(sheet, sheet.getLastRowNum(), dataList);
}
FileOutputStream out = new FileOutputStream(file);
sxssfWorkbook.write(out);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void fillExcelContent(SXSSFSheet sheet, int lastRowNum, List<List<String>> dataList) {
for (int i = 0; i < dataList.size(); i++) {
SXSSFRow row = sheet.createRow(lastRowNum + i + 1);
......@@ -217,14 +187,14 @@ public class ExcelUtil
public static void exportXlSXExcel(
HttpServletResponse response, File file, String fileName)
{
try
OutputStream output = null;
try (FileInputStream inputStream = new FileInputStream(file))
{
String name = new String(fileName.getBytes("UTF-8"), "ISO8859_1");
OutputStream output = response.getOutputStream();
output = response.getOutputStream();
response.setHeader("Content-disposition",
"attachment; filename=" + name);
response.setContentType("application/vnd.ms-excel;charset=utf-8");
FileInputStream inputStream = new FileInputStream(file);
int b = 0;
byte[] buffer = new byte[1024*10];
while (b != -1){
......@@ -232,14 +202,21 @@ public class ExcelUtil
if (-1 != b) {
output.write(buffer, 0, b);
}
}
inputStream.close();
}
output.flush();
output.close();
}
catch (IOException e)
{
e.printStackTrace();
} finally {
try {
if (output != null) {
output.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -517,11 +494,17 @@ public class ExcelUtil
cell.setCellStyle(style2);
}
}
return workbook;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return workbook;
}
/**
......
......@@ -31,10 +31,19 @@ public class FileUtil {
if (!targetFile.exists()) {
targetFile.mkdirs();
}
FileOutputStream out = new FileOutputStream(filePath + fileName);
out.write(file);
out.flush();
out.close();
FileOutputStream out = null;
try {
out = new FileOutputStream(filePath + fileName);
out.write(file);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != out) {
out.close();
}
}
}
/**
......
......@@ -34,8 +34,9 @@ public class TikaUtils {
public static String fileToTxt(File file) {
Parser parser = new AutoDetectParser();
InputStream inputStream = null;
try {
InputStream inputStream = new FileInputStream(file);
inputStream = new FileInputStream(file);
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
......@@ -49,6 +50,14 @@ public class TikaUtils {
return handler.toString();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != inputStream) {
inputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
......@@ -73,7 +82,7 @@ public class TikaUtils {
}
return null;
return "";
}
......
......@@ -202,6 +202,12 @@ public class WordTemplateUtils {
in.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
......
package com.yeejoin.equipmanage.common.vo;
import lombok.Data;
/**
* @author Gao Jianqiang
* @title: PressurePumpCountVo
* <pre>
* @description: 稳压泵统计 Vo
* </pre>
* @date 2023/2/22 16:15
*/
@Data
public class PressurePumpCountVo {
private Integer value;
private String time;
private String iotCode;
}
......@@ -10,33 +10,14 @@ public class ImageText implements AbstractText {
public void createTxt(String inputFile, String outputFile) throws Exception {
File file = new File(inputFile);
String baseName = FilenameUtils.getBaseName(inputFile);
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(file);
os = new FileOutputStream(
outputFile.substring(0, outputFile.length() - baseName.length() - 1) + ".txt");
try (InputStream is = new FileInputStream(file);
OutputStream os = new FileOutputStream(outputFile.substring(0, outputFile.length() - baseName.length() - 1) + ".txt")) {
byte[] buffer = new byte[1024];
int result = -1;
while (-1 != (result = is.read(buffer))) {
os.write(buffer, 0, result);
}
} finally {
try {
if (null != is) {
is.close();
}
if (null != os) {
os.close();
}
} catch (Exception exce) {
System.err.println(exce.getMessage());
}
}
}
}
......@@ -18,6 +18,7 @@ import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.TreeSet;
......@@ -39,11 +40,8 @@ public class FileHelper {
* @return
*/
public static boolean isExcel2003(File file) {
InputStream is = null;
Workbook wb = null;
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
try (InputStream is = new FileInputStream(file);
Workbook wb = WorkbookFactory.create(is);) {
if (wb instanceof XSSFWorkbook) {
return false;
} else if (wb instanceof HSSFWorkbook) {
......@@ -51,17 +49,6 @@ public class FileHelper {
}
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -71,39 +58,19 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
public static boolean isWord2007(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new XWPFDocument(is).close();
try (InputStream is = new FileInputStream(file);
XWPFDocument xwpfDocument = new XWPFDocument(is)) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -113,24 +80,10 @@ public class FileHelper {
* @return
*/
public static boolean isPpt2003(File file) {
InputStream is = null;
HSLFSlideShow ppt = null;
try {
is = new FileInputStream(file);
ppt = new HSLFSlideShow(is);
try (InputStream is = new FileInputStream(file);
HSLFSlideShow ppt = new HSLFSlideShow(is)) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != ppt) {
ppt.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -141,13 +94,10 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content);
......@@ -156,19 +106,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -181,13 +119,10 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
......@@ -196,19 +131,7 @@ public class FileHelper {
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
}
return buffer;
}
......@@ -219,28 +142,15 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8));) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
} catch (IOException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -330,11 +240,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -343,20 +250,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
/**
......
......@@ -34,18 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) {
Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try (InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
e.printStackTrace();
......@@ -58,21 +52,13 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
InputStream stream = null;
try {
stream = new FileInputStream(new File(fileName));
try (InputStream stream = new FileInputStream(new File(fileName));) {
parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return null;
}
......
package com.yeejoin.precontrol.common.service.impl;
import com.yeejoin.precontrol.common.service.PdfService;
import com.yeejoin.precontrol.common.utils.ExtendedIOUtils;
import org.springframework.stereotype.Service;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
......@@ -17,22 +16,16 @@ public class PdfServiceImpl implements PdfService {
@Override
public void base64StringToPdf(String base64Content, String filePath) {
BASE64Decoder decoder = new BASE64Decoder();
BufferedInputStream bis = null;
FileOutputStream fos = null;
BufferedOutputStream bos = null;
try {
byte[] bytes = decoder.decodeBuffer(base64Content);
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes);
bis = new BufferedInputStream(byteInputStream);
File file = new File(filePath);
File file = new File(filePath);
try (ByteArrayInputStream byteInputStream = new ByteArrayInputStream(decoder.decodeBuffer(base64Content));
BufferedInputStream bis = new BufferedInputStream(byteInputStream);
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
) {
File path = file.getParentFile();
if (!path.exists()) {
path.mkdirs();
}
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
byte[] buffer = new byte[1024];
int length = bis.read(buffer);
while (length != -1) {
......@@ -42,26 +35,16 @@ public class PdfServiceImpl implements PdfService {
bos.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
ExtendedIOUtils.closeQuietly(bis);
ExtendedIOUtils.closeQuietly(fos);
ExtendedIOUtils.closeQuietly(bos);
}
}
@Override
public String pdfToBase64(File file) {
BASE64Encoder encoder = new BASE64Encoder();
FileInputStream fin = null;
BufferedInputStream bin = null;
ByteArrayOutputStream baos = null;
BufferedOutputStream bout = null;
try {
fin = new FileInputStream(file);
bin = new BufferedInputStream(fin);
baos = new ByteArrayOutputStream();
bout = new BufferedOutputStream(baos);
try (FileInputStream fin = new FileInputStream(file);
BufferedInputStream bin = new BufferedInputStream(fin);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bout = new BufferedOutputStream(baos);) {
byte[] buffer = new byte[1024];
int len = bin.read(buffer);
while (len != -1) {
......@@ -72,18 +55,8 @@ public class PdfServiceImpl implements PdfService {
bout.flush();
byte[] bytes = baos.toByteArray();
return encoder.encodeBuffer(bytes).trim();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fin.close();
bin.close();
bout.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
......
......@@ -20,6 +20,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -837,9 +838,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
public static List<String> getContent(String filePath) {
// 读取文件
List<String> lineLists = null;
try {
lineLists = Files.lines(Paths.get(filePath), Charset.defaultCharset())
.flatMap(line -> Arrays.stream(line.split("\n"))).collect(Collectors.toList());
try (Stream<String> lines = Files.lines(Paths.get(filePath), Charset.defaultCharset());) {
lineLists = lines.flatMap(line -> Arrays.stream(line.split("\n"))).collect(Collectors.toList());
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -32,6 +32,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -52,11 +53,8 @@ public class FileHelper {
* @return
*/
public static boolean isExcel2003(File file) {
InputStream is = null;
Workbook wb = null;
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
try (InputStream is = new FileInputStream(file);
Workbook wb = WorkbookFactory.create(is);) {
if (wb instanceof XSSFWorkbook) {
return false;
} else if (wb instanceof HSSFWorkbook) {
......@@ -64,17 +62,6 @@ public class FileHelper {
}
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -84,20 +71,10 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -126,24 +103,10 @@ public class FileHelper {
* @return
*/
public static boolean isPPT2003(File file) {
InputStream is = null;
HSLFSlideShow ppt = null;
try {
is = new FileInputStream(file);
ppt = new HSLFSlideShow(is);
try (InputStream is = new FileInputStream(file);
HSLFSlideShow ppt = new HSLFSlideShow(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != ppt) {
ppt.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -154,13 +117,10 @@ public class FileHelper {
*/
public static StringBuffer readLocalFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is)); ) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content);
......@@ -169,17 +129,6 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -193,13 +142,10 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
......@@ -208,17 +154,6 @@ public class FileHelper {
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
}
return buffer;
}
......@@ -230,28 +165,17 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8)); ) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -335,11 +259,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -348,16 +269,6 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
......@@ -1095,13 +1006,10 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content);
......@@ -1110,19 +1018,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
}
......@@ -26,14 +26,16 @@ public class FileUtil {
* @return
*/
public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception {
File targetFile = new File(filePath);
if (!targetFile.exists()) {
targetFile.mkdirs();
try (FileOutputStream out = new FileOutputStream(filePath + fileName);) {
File targetFile = new File(filePath);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
out.write(file);
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
FileOutputStream out = new FileOutputStream(filePath + fileName);
out.write(file);
out.flush();
out.close();
}
/**
......
......@@ -25,29 +25,21 @@ public class HttpRequest {
conn.setConnectTimeout(30 * 1000);
//防止屏蔽程序抓取而返回403错误
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//得到输入流
InputStream inputStream = conn.getInputStream();
//获取自己数组
byte[] getData = readInputStream(inputStream);
//文件保存位置
File saveDir = new File(savePath);
if (!saveDir.exists()) {
saveDir.mkdir();
}
File file = new File(saveDir + File.separator + fileName);
FileOutputStream fos = new FileOutputStream(file);
fos.write(getData);
if (fos != null) {
fos.close();
}
if (inputStream != null) {
inputStream.close();
try (FileOutputStream fos = new FileOutputStream(file);
//得到输入流
InputStream inputStream = conn.getInputStream();) {
//获取自己数组
byte[] getData = readInputStream(inputStream);
fos.write(getData);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("info:" + url + " download success");
return file;
}
......
......@@ -164,43 +164,42 @@ public class HttpUtils {
NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
Assert.hasText(url, "url invalid");
String result;
CloseableHttpClient httpClient;
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtils.createSslInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = null;
HttpPost httpPost = getHttpPost(url);
if (GlobalCache.header != null) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpPost.setHeader(key, value);
// 创建一个SSL信任所有证书的httpClient对象
try ( CloseableHttpClient httpClient = url.startsWith(HTTPS) ? HttpUtils.createSslInsecureClient() : HttpClients.createDefault();) {
CloseableHttpResponse response = null;
HttpPost httpPost = getHttpPost(url);
if (GlobalCache.header != null) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpPost.setHeader(key, value);
}
}
}
//加入全局请求令牌权限
httpPost.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
if (GlobalCache.header.get("Content-Type") != null) {
String contentType = GlobalCache.header.get("Content-Type");
if ("application/x-www-form-urlencoded".equals(contentType)) {
JSONObject jsonObject = JSONObject.parseObject(jsonParams);
List<NameValuePair> params = new ArrayList<>();
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
if (jsonObject != null) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
//加入全局请求令牌权限
httpPost.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
if (GlobalCache.header.get("Content-Type") != null) {
String contentType = GlobalCache.header.get("Content-Type");
if ("application/x-www-form-urlencoded".equals(contentType)) {
JSONObject jsonObject = JSONObject.parseObject(jsonParams);
List<NameValuePair> params = new ArrayList<>();
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
if (jsonObject != null) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
}
httpPost.setEntity(new UrlEncodedFormEntity(params, DEFAULT_ENCODING));
}
httpPost.setEntity(new UrlEncodedFormEntity(params, DEFAULT_ENCODING));
}
}
if ("application/json;charset=UTF-8".equals(contentType)) {
if ("application/json;charset=UTF-8".equals(contentType)) {
httpPost.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
}
} else {
httpPost.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
}
} else {
httpPost.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
return baseRequest(httpClient, httpPost);
} catch (IOException e) {
e.printStackTrace();
}
return baseRequest(httpClient, httpPost);
return new ResponeVo();
}
/**
......@@ -239,44 +238,43 @@ public class HttpUtils {
public static ResponeVo put(String url, String jsonParams) throws IOException, NoSuchAlgorithmException,
KeyStoreException, KeyManagementException {
log.info("----->调用请求 url:" + url + " ---->json参数:" + jsonParams);
CloseableHttpClient httpClient = null;
String content;
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtils.createSslInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = null;
HttpPut httpPut = new HttpPut(url);
if (GlobalCache.header != null) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpPut.setHeader(key, value);
// 创建一个SSL信任所有证书的httpClient对象
try ( CloseableHttpClient httpClient = url.startsWith(HTTPS) ? HttpUtils.createSslInsecureClient() : HttpClients.createDefault();) {
CloseableHttpResponse response = null;
HttpPut httpPut = new HttpPut(url);
if (GlobalCache.header != null) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpPut.setHeader(key, value);
}
}
}
//加入全局请求令牌权限
httpPut.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
if (GlobalCache.header.get("Content-Type") != null) {
String contentType = GlobalCache.header.get("Content-Type");
if ("application/x-www-form-urlencoded".equals(contentType)) {
JSONObject jsonObject = JSONObject.parseObject(jsonParams);
List<NameValuePair> params = new ArrayList<>();
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
if (jsonObject != null) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
//加入全局请求令牌权限
httpPut.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
if (GlobalCache.header.get("Content-Type") != null) {
String contentType = GlobalCache.header.get("Content-Type");
if ("application/x-www-form-urlencoded".equals(contentType)) {
JSONObject jsonObject = JSONObject.parseObject(jsonParams);
List<NameValuePair> params = new ArrayList<>();
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
if (jsonObject != null) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
}
httpPut.setEntity(new UrlEncodedFormEntity(params, DEFAULT_ENCODING));
}
httpPut.setEntity(new UrlEncodedFormEntity(params, DEFAULT_ENCODING));
}
if ("application/json;charset=UTF-8".equals(contentType)) {
httpPut.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
}
} else {
log.error("请求头为空");
}
if ("application/json;charset=UTF-8".equals(contentType)) {
httpPut.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
}
} else {
log.error("请求头为空");
return baseRequest(httpClient, httpPut);
} catch (IOException e) {
e.printStackTrace();
}
return baseRequest(httpClient, httpPut);
return new ResponeVo();
}
/**
......@@ -434,16 +432,12 @@ public class HttpUtils {
}
public static void inputStreamToFile(InputStream ins, File file) {
OutputStream os = null;
try {
os = new FileOutputStream(file);
try (OutputStream os = new FileOutputStream(file);) {
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
ins.close();
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -33,18 +33,12 @@ public class TikaUtils {
public static String fileToTxt(File file) {
Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try (InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
e.printStackTrace();
......@@ -57,16 +51,12 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
InputStream stream = null;
try {
stream = new FileInputStream(new File(fileName));
try (InputStream stream = new FileInputStream(new File(fileName))) {
parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return null;
}
......
......@@ -71,6 +71,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
......@@ -1132,21 +1133,18 @@ public class CommandController extends BaseController {
}
File htmlFile = new File(htmlFileName);
WordConverterUtils.wordToHtml(fileName, htmlFileName, imagePathStr, readUrl, remoteSecurityService, product, appKey, token);
FileInputStream fis = new FileInputStream(htmlFile);
// response.setContentType("multipart/form-data");
// response.setCharacterEncoding("UTF-8");
// response.setContentType("text/html");
ServletOutputStream out;
out = response.getOutputStream();
int b = 0;
byte[] buffer = new byte[1024];
while ((b = fis.read(buffer)) != -1) {
// 4.写到输出流(out)中
out.write(buffer, 0, b);
try (FileInputStream fis = new FileInputStream(htmlFile);
ServletOutputStream out = response.getOutputStream();) {
int b = 0;
byte[] buffer = new byte[1024];
while ((b = fis.read(buffer)) != -1) {
// 4.写到输出流(out)中
out.write(buffer, 0, b);
}
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
fis.close();
out.flush();
out.close();
return ResponseHelper.buildResponse("");
} else {
return null;
......
package com.yeejoin.equipmanage.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.dto.OrgMenuDto;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.fegin.JcsFeign;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.ObjectUtils;
......@@ -25,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -419,4 +429,14 @@ public class BuildingController extends AbstractBaseController {
return buildService.getBuildingTreeInMyOrgCodeList(reginParams.getPersonIdentity().getBizOrgCode());
}
@PersonIdentify
@PostMapping(value = "/upload")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "建筑导入(实施导数据使用)", notes = "建筑导入")
public void upload(MultipartFile file) {
ReginParams reginParams = getSelectedOrgInfo();
buildService.importBuilding(file, reginParams);
}
}
......@@ -48,7 +48,7 @@ public class ConfirmAlarmController extends AbstractBaseController {
@GetMapping(value = "/getDetailsById")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据id,type查询确警页面相关数据")
public Map<String, Object> getDetailsById(@RequestParam Long alamId, @RequestParam(required = false) Long equipId, @RequestParam(required = false) String type, @RequestParam String area) {
public Map<String, Object> getDetailsById(@RequestParam String alamId, @RequestParam(required = false) String equipId, @RequestParam(required = false) String type, @RequestParam String area) {
return iConfirmAlarmService.getDetailsById(alamId, equipId, type, area);
}
......
......@@ -578,7 +578,7 @@ public class EmergencyController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpStatusChart")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵启停状态图", notes = "四横八纵-稳压泵启停状态图")
public ResponseModel getPressurePumpStatusChart(@RequestParam String equipmentCode, @RequestParam String startTime, @RequestParam String endTime,
public ResponseModel getPressurePumpStatusChart(@RequestParam String startTime, @RequestParam String endTime,
@RequestParam(required = false) String bizOrgCode) {
if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
......@@ -590,15 +590,14 @@ public class EmergencyController extends AbstractBaseController {
}
}
}
return CommonResponseUtil.success(iEmergencyService.getPressurePumpStatusChart(startTime, endTime, bizOrgCode, getAppKey(), getProduct(), getToken()));
return CommonResponseUtil.success(iEmergencyService.getPressurePumpStatusChart(startTime, endTime, bizOrgCode));
}
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpDiagnosticAnalysis")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵诊断分析", notes = "四横八纵-稳压泵诊断分析")
public ResponseModel getPressurePumpDiagnosticAnalysis(@RequestParam String equipmentCode, @RequestParam(required = false) String nameKeys,
@RequestParam(required = false) String fieldKey, @RequestParam(required = false) String bizOrgCode) {
public ResponseModel getPressurePumpDiagnosticAnalysis(@RequestParam(required = false) String bizOrgCode) {
if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
......@@ -609,7 +608,44 @@ public class EmergencyController extends AbstractBaseController {
}
}
}
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDiagnosticAnalysis(nameKeys, fieldKey, bizOrgCode, getAppKey(), getProduct(), getToken()));
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDiagnosticAnalysis(bizOrgCode));
}
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpStartStatistics")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵启动统计", notes = "四横八纵-稳压泵启动统计")
public ResponseModel getPressurePumpStartStatistics(@RequestParam String startTime, @RequestParam String endTime,
@RequestParam(required = false) String bizOrgCode) {
if (StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getBizOrgCode();
if (bizOrgCode == null) {
return CommonResponseUtil.success(Collections.EMPTY_MAP);
}
}
}
return CommonResponseUtil.success(iEmergencyService.getPressurePumpStartStatistics(startTime, endTime, bizOrgCode));
}
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpDay")
@ApiOperation(httpMethod = "GET", value = "手动-存储昨日稳压泵启动次数", notes = "手动-存储昨日稳压泵启动次数")
public ResponseModel getPressurePumpDay(@RequestParam(required = false) String bizOrgCode) {
if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getBizOrgCode();
if (bizOrgCode == null) {
return CommonResponseUtil.success(Collections.EMPTY_LIST);
}
}
}
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDay(bizOrgCode));
}
@PersonIdentify
......
......@@ -377,7 +377,7 @@ public class EquipmentSpecificController extends AbstractBaseController {
@GetMapping(value = "/{buildingId}/list")
@ApiOperation(httpMethod = "GET", value = "查询指定建筑下的装备列表", notes = "查询指定建筑下的装备列表")
public List<EquiplistSpecificBySystemVO> getListByWarehouseStructureId( @PathVariable Long buildingId){
return equipmentSpecificMapper.getListByWarehouseStructureId(buildingId);
return equipmentSpecificMapper.getListByWarehouseStructureId(buildingId, null);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
public interface ConfirmAlarmMapper extends BaseMapper<EquipmentSpecificAlarm> {
EquipmentSpecificAlarmLog getDetailsById(@Param("id") Long id, @Param("equipId")Long equipId);
EquipmentSpecificAlarmLog getDetailsById(@Param("id") String id, @Param("equipId")String equipId);
int confirmAlam(EquipmentSpecificAlarmLog ent);
......
......@@ -228,7 +228,13 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
Equipment getEquipmentBySpecificId(@Param("specificId") Long specificId);
List<EquiplistSpecificBySystemVO> getListByWarehouseStructureId(Long floorId);
/**
*
* @param floorId 建筑id
* @param isIot 是否物联设备
* @return
*/
List<EquiplistSpecificBySystemVO> getListByWarehouseStructureId(Long floorId, Integer isIot);
List<Map<String,String>> getStationInfo();
......
......@@ -216,4 +216,11 @@ public interface FormInstanceMapper extends BaseMapper<FormInstance> {
int updateFormFieldValue(@Param("id") Long id, @Param("name") String name, @Param("value") String value);
Long queryVideoCountByBizOrgCode(@Param("bizOrgCode") String bizOrgCode);
/**
* 建筑导入-导入楼层或房间 根据编码查询父级建筑id
* @param code
* @return
*/
String selectParentBuildId(@Param("code") String code);
}
......@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.dto.OrgMenuDto;
import com.yeejoin.amos.feign.morphic.model.ResourceDTO;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
......@@ -17,6 +18,7 @@ import com.yeejoin.equipmanage.common.entity.vo.PointTreeVo;
import com.yeejoin.equipmanage.common.vo.BuildingTreeAndEquipVO;
import com.yeejoin.equipmanage.common.vo.BuildingTreeVo;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.LinkedHashMap;
import java.util.List;
......@@ -351,4 +353,10 @@ public interface IBuilldService extends IService<Building> {
List<OrgMenuDto> companyTreeByUserAndType();
List<BuildingTreeVo> treeByName(String bizOrgCode, String name);
/**
* 导入建筑信息
* @param file
*/
void importBuilding(MultipartFile file, ReginParams reginParams);
}
......@@ -17,7 +17,7 @@ public interface IConfirmAlarmService extends IService<EquipmentSpecificAlarm> {
/**
* 根据id查询确警页面相关数据
*/
Map<String ,Object> getDetailsById( Long alamId, Long equipId , String type, String area);
Map<String ,Object> getDetailsById(String alamId, String equipId , String type, String area);
Map<String ,Integer> videoList(List<String> list);
......
package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import java.util.List;
import java.util.Map;
......@@ -54,9 +55,20 @@ public interface IEmergencyService {
Map<String, Integer> getStockEquipStatistics();
Map<String, Object> getPressurePumpStatusChart(String startTime, String endTime, String bizOrgCode, String appKey, String product, String token);
Map<String, Object> getPressurePumpStatusChart(String startTime, String endTime, String bizOrgCode);
List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token);
List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String bizOrgCode);
Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus);
Map<String, List<PressurePumpCountVo>> getPressurePumpDay(String bizOrgCode);
/**
* 稳压泵启动统计
* @param startTime
* @param endTime
* @param bizOrgCode
* @return
*/
Map<String, Object> getPressurePumpStartStatistics(String startTime, String endTime, String bizOrgCode);
}
package com.yeejoin.equipmanage.service;
import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import java.util.Date;
import java.util.List;
......@@ -17,18 +18,21 @@ public interface IPressurePumpService {
* redis缓存物联采集数据,内部读取JSON配置指定有效期
*
* @param iotDatalist
* @param topic
* @param iotCode
* @param bizOrgCode
*/
void saveDataToRedis(List<IotDataVO> iotDatalist, String topic);
void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode);
/**
* 根据nameKey,模糊查询所有的redis缓存数据
*
* @param infoCode
* @param nameKey
* @param iotCode
* @param bizOrgCode
* @return
*/
List<IotDataVO> getDataToRedis(String infoCode, String nameKey, String iotCode);
List<IotDataVO> getDataToRedis(String infoCode, String nameKey, String iotCode, String bizOrgCode);
/**
* 获取指标配置JSON信息集合
......@@ -38,39 +42,41 @@ public interface IPressurePumpService {
/**
* 获取所有稳压泵最近一次启停间隔,min
* @param redisDataList
* @param iotDataList
*
* @param dataList
* @param dataListFilterTrue
* @param dataListFilterFalse
* @param nowStrLong
* @param bizOrgCode
*/
long getAllPressurePumpStartStopInterval(List<IotDataVO> redisDataList, List<Map<String, String>> iotDataList, String nowStrLong, String bizOrgCode);
long getAllPressurePumpStartStopInterval(List<IotDataVO> dataList, List<IotDataVO> dataListFilterTrue, List<IotDataVO> dataListFilterFalse, String nowStrLong);
/**
* 获取稳压泵一定时间内启动频率或次数
*
* @param hour
* @param dataList
* @param dateNow
*/
int getAllPressurePumpStartFrequency(double hour, Date dateNow);
int getAllPressurePumpStartFrequency(double hour, List<IotDataVO> dataList, Date dateNow);
/**
* 获取稳压泵最近一次启停时长,min
* @param redisDataList
* @param iotDataList
*
* @param dataList
* @param dataListFilterTrue
* @param dataListFilterFalse
* @param nowStrLong
* @param bizOrgCode
*/
long getAllPressurePumpStartStopDuration(List<IotDataVO> redisDataList, List<Map<String, String>> iotDataList, String nowStrLong, String bizOrgCode);
long getAllPressurePumpStartStopDuration(List<IotDataVO> dataList, List<IotDataVO> dataListFilterTrue, List<IotDataVO> dataListFilterFalse, String nowStrLong);
/**
* 获取稳压泵指定启泵前 minutes 分钟,管网压力差绝对值
* @param redisDataList
* @param redisDataPipeList
* @param iotDataList
* @param iotDataPipeList
* @param nowStrLong
* @param dataList
* @param dataPipeList
* @param minutes
* @return
*/
double getAllPressurePumpPipePressureDiff(List<IotDataVO> redisDataList, List<IotDataVO> redisDataPipeList, List<Map<String, String>> iotDataList, List<Map<String, String>> iotDataPipeList, String nowStrLong, String minutes);
double getAllPressurePumpPipePressureDiff(List<IotDataVO> dataList, List<IotDataVO> dataPipeList, String minutes);
/**
* 根据指标,获取物联top数据,influxdb
......@@ -84,13 +90,15 @@ public interface IPressurePumpService {
/**
* 根据时间范围,获取redis指定指标或指定指标设备的缓存数据
*
* @param infoCode
* @param nameKey
* @param iotCode
* @param startDate
* @param endDate
* @param bizOrgCode
*/
List<IotDataVO> getDataToRedisByDateBetween(String infoCode, String nameKey, String iotCode, Date startDate, Date endDate);
List<IotDataVO> getDataToRedisByDateBetween(String infoCode, String nameKey, String iotCode, Date startDate, Date endDate, String bizOrgCode);
/**
* 根据时间范围获取iot物联数据集合
......@@ -103,4 +111,64 @@ public interface IPressurePumpService {
*/
List<Map<String, String>> getIotCommonListData(String startTime, String endTime, String prefix, String suffix, String key, String fieldKey);
/**
* 数据根据指定值过滤
* @param dataList
* @param value
*/
List<IotDataVO> getDataListFilter(List<IotDataVO> dataList, String value);
/**
* 获取稳压泵数据,redis没有,从iot取
*
* @param pumpInfoList
* @param infoCode
* @param equipmentCode
* @param top
* @param nameKey
* @param bizOrgCode
* @param iotCode
* @return
*/
Map<String, List<IotDataVO>> getDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String equipmentCode, String top, String nameKey, String bizOrgCode, String iotCode);
/**
* map 转化为对象
* @param map
* @param aClass
* @return
*/
Object mapToObject(Map<String,String> map,Class<?> aClass, String indexKey) throws IllegalAccessException, InstantiationException;
/**
* 获取iot指标统计数据
*
* @param startTime
* @param endTime
* @param infoCode
* @param countRedisKey
* @param prefix
* @param suffix
* @param key
* @param fieldKey
* @param expire
* @param bizOrgCode
* @return
*/
List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String countRedisKey, String prefix, String suffix, String key, String fieldKey, long expire, String bizOrgCode);
/**
* 获取稳压泵时间范围统计数据
* @param pumpInfoList
* @param startTime
* @param endTime
* @param infoCode
* @param countRedisKey
* @param equipmentCode
* @param nameKey
* @param countExpire
* @param bizOrgCode
* @return
*/
Map<String, List<PressurePumpCountVo>> getDateRangeCountList(List<Map<String, Object>> pumpInfoList, String startTime, String endTime, String infoCode, String countRedisKey, String equipmentCode, String nameKey, long countExpire, String bizOrgCode);
}
......@@ -21,4 +21,6 @@ public interface ISupervisionVideoService extends IService<SupervisionVideo> {
List<String> queryVideoAllId(String bizOrgCode);
Page<Map<String, Object>> queryPumpInfo(Page page, String bizOrgCode);
List<Map<String, Object>> selectPressureDetails(String bizOrgCode);
}
package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto;
......@@ -14,16 +16,23 @@ import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.mapper.AnalysisReportLogMapper;
import com.yeejoin.equipmanage.mapper.AnalysisReportMonthMapper;
import com.yeejoin.equipmanage.mapper.AnalysisReportSummaryMapper;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.IAnalysisReportLogService;
import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import com.yeejoin.equipmanage.service.IUploadFileService;
import liquibase.pro.packaged.A;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
/**
* 报告流水表 服务实现类
......@@ -48,6 +57,12 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
@Autowired
IUploadFileService iUploadFileService;
@Autowired
FireFightingSystemMapper fireFightingSystemMapper;
@Value("classpath:/json/systemIndex.json")
private Resource systemIndex;
@Override
public IPage<AnalysisReportLog> listPage(Page page, AnalysisReportLog analysisReportLog) {
......@@ -74,15 +89,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
this.saveAnalysisReportLog(reportEnum, beginDate, endDate);
// 创建月分析统计报告数据
// 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔
List<FireFightingSystemEntity> fightingSystemEntityList = fireFightingSystemService.getBaseMapper().selectList(
new LambdaQueryWrapper<FireFightingSystemEntity>()
.isNotNull(FireFightingSystemEntity::getAnalysisIndexKey));
List<Map<String, Object>> list = fireFightingSystemMapper.selectSystemByBizOrgCode(null);
// 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary
String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN);
String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN);
fightingSystemEntityList.forEach(f -> {
analysisReportMonthMapper.insertSystemMonthData(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId());
analysisReportSummaryMapper.insertSystemMonthSummaryData(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId());
String json = null;
try {
json = IOUtils.toString(systemIndex.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
// 获取系统对应指标配置信息
List<Map> indicatorConfiguration = JSONObject.parseArray(json, Map.class);
list.forEach(f -> {
// 具体系统对应指标
List<Map> collect = indicatorConfiguration.stream().
filter(index -> index.get("code").equals(String.valueOf(f.get("typeCode")))).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
String indicator = String.valueOf(collect.get(0).get("index"));
analysisReportMonthMapper.insertSystemMonthData(new ArrayList<>(Arrays.asList(indicator.split(","))), beginDateStr, endDateStr, Long.valueOf(f.get("id").toString()));
analysisReportSummaryMapper.insertSystemMonthSummaryData(new ArrayList<>(Arrays.asList(indicator.split(","))), beginDateStr, endDateStr, Long.valueOf(f.get("id").toString()));
}
});
}
......@@ -93,15 +120,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
this.saveAnalysisReportLog(reportEnum, beginDate, endDate);
// 创建月分析统计报告数据
// 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔
List<FireFightingSystemEntity> fightingSystemEntityList = fireFightingSystemService.getBaseMapper().selectList(
new LambdaQueryWrapper<FireFightingSystemEntity>()
.isNotNull(FireFightingSystemEntity::getAnalysisIndexKey));
List<Map<String, Object>> list = fireFightingSystemMapper.selectSystemByBizOrgCode(null);
// 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary
String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN);
String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN);
fightingSystemEntityList.forEach(f -> {
analysisReportMonthMapper.insertSystemMonthDataTest(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId(),now,num);
analysisReportSummaryMapper.insertSystemMonthSummaryDataTest(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId(),now,num);
String json = null;
try {
json = IOUtils.toString(systemIndex.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
// 获取系统对应指标配置信息
List<Map> indicatorConfiguration = JSONObject.parseArray(json, Map.class);
list.forEach(f -> {
// 具体系统对应指标
List<Map> collect = indicatorConfiguration.stream().
filter(index -> index.get("code").equals(String.valueOf(f.get("typeCode")))).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
String indicator = String.valueOf(collect.get(0).get("index"));
analysisReportMonthMapper.insertSystemMonthData(new ArrayList<>(Arrays.asList(indicator.split(","))), beginDateStr, endDateStr, Long.valueOf(f.get("id").toString()));
analysisReportSummaryMapper.insertSystemMonthSummaryData(new ArrayList<>(Arrays.asList(indicator.split(","))), beginDateStr, endDateStr, Long.valueOf(f.get("id").toString()));
}
});
}
......
......@@ -8,6 +8,7 @@ import com.yeejoin.equipmanage.common.vo.SpeedAndTimeList;
import com.yeejoin.equipmanage.service.ICarLonAndLatDataService;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
......@@ -28,30 +29,37 @@ public class CarLonAndLatDataServiceImpl implements ICarLonAndLatDataService {
@Override
public List<LonAndLatEntityVo> listCarLonAndLat() throws Exception {
Resource resource = new ClassPathResource("car-history-track-data.xml");
BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()));
StringBuffer buffer = new StringBuffer();
String line = "";
while((line = br.readLine())!=null)
{
buffer.append(line);
try (InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());
BufferedReader br = new BufferedReader(inputStreamReader);) {
StringBuffer buffer = new StringBuffer();
String line = "";
while((line = br.readLine())!=null)
{
buffer.append(line);
}
LonAndLatList list = (LonAndLatList) XmlBuilder.xmlStrToObject(LonAndLatList.class, buffer.toString());
return list.getDataList();
} catch (Exception e) {
e.printStackTrace();
}
br.close();
LonAndLatList list = (LonAndLatList) XmlBuilder.xmlStrToObject(LonAndLatList.class, buffer.toString());
return list.getDataList();
return new ArrayList<>();
}
@Override
public List<SpeedAndTimeEntityVo> listCarSpeedAndGround() throws Exception {
Resource resource = new ClassPathResource("car-history-trend-data.xml");
BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()));
StringBuffer buffer = new StringBuffer();
String line = "";
while((line = br.readLine())!=null)
{
buffer.append(line);
try (InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());
BufferedReader br = new BufferedReader(inputStreamReader);) {
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = br.readLine()) != null) {
buffer.append(line);
}
SpeedAndTimeList list = (SpeedAndTimeList) XmlBuilder.xmlStrToObject(SpeedAndTimeList.class, buffer.toString());
return list.getDataList();
} catch (Exception e) {
e.printStackTrace();
}
br.close();
SpeedAndTimeList list = (SpeedAndTimeList) XmlBuilder.xmlStrToObject(SpeedAndTimeList.class, buffer.toString());
return list.getDataList();
return new ArrayList<>();
}
}
......@@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
......@@ -486,12 +487,13 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
stockDetailMapper.updateById(stockDetail);
addStockDetailId(stockDetail.getId());
StockDetail stockDetail_clone = stockDetail.clone();
stockDetail_clone.setId(null);
stockDetail_clone.setAmount(lossCount);
stockDetail_clone.setStatus(EquipStatusEnum.LOSS.getCode().toString());
stockDetailMapper.insert(stockDetail_clone);
addStockDetailId(stockDetail_clone.getId());
StockDetail stockDetailClone = new StockDetail();
BeanUtils.copyProperties(stockDetail, stockDetailClone);
stockDetailClone.setId(null);
stockDetailClone.setAmount(lossCount);
stockDetailClone.setStatus(EquipStatusEnum.LOSS.getCode().toString());
stockDetailMapper.insert(stockDetailClone);
addStockDetailId(stockDetailClone.getId());
Stock stock = stockMapper.selectById(stockDetail.getStockId());
stock.setAmount(stock.getAmount() - lossCount);
stockMapper.updateById(stock);
......@@ -501,10 +503,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
// 损耗清单详情
WastageBillDetail detail = new WastageBillDetail();
detail.setAmount(BigDecimal.valueOf(lossCount));
detail.setStockDetailId(stockDetail_clone.getId());
detail.setStockDetailId(stockDetailClone.getId());
detail.setWastageBillId(bill.getId());
wastageBillDetailMapper.insert(detail);
journalMapper.insert(createJournal(ex, stockDetail_clone.getId(), lossCount));
journalMapper.insert(createJournal(ex, stockDetailClone.getId(), lossCount));
return 0d;
} catch (Exception e) {
e.printStackTrace();
......@@ -604,7 +606,7 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
List<SystemDic> listd = systemDicMapper.selectByMap(columnMap);
p.setLossStateId(listd.get(0).getId());
});
lossHandlers.add(p -> this.loss(p));
lossHandlers.add(this::loss);
// 同步搜索
/*
......@@ -624,21 +626,21 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
stockDetailMapper.updateById(detail);
params.addStockDetailId(r.getStockDetailId());
StockDetail detail_onCar = null;
StockDetail detailOnCar = new StockDetail();
BeanUtils.copyProperties(detail, detailOnCar);
// 新增车载记录
detail_onCar = detail.clone();
detail_onCar.setId(null);
detail_onCar.setAmount(r.getAmount());
detail_onCar.setStatus(EquipStatusEnum.ONCAR.getCode().toString());
stockDetailMapper.insert(detail_onCar);
params.addStockDetailId(detail_onCar.getId());
// detail_onCar = detail.clone();
detailOnCar.setId(null);
detailOnCar.setAmount(r.getAmount());
detailOnCar.setStatus(EquipStatusEnum.ONCAR.getCode().toString());
stockDetailMapper.insert(detailOnCar);
params.addStockDetailId(detailOnCar.getId());
// 装车
extinguishantOnCarMapper.insert(params.create(r, detail_onCar));
extinguishantOnCarMapper.insert(params.create(r, detailOnCar));
// 流水
journalMapper.insert(params.createJournal(r, detail_onCar.getId()));
journalMapper.insert(params.createJournal(r, detailOnCar.getId()));
});
} catch (Exception e) {
......
......@@ -133,11 +133,11 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
private SourceSceneMapper sourceSceneMapper;
@Override
public Map<String, Object> getDetailsById(Long alarmId, Long equipId, String type, String area) {
public Map<String, Object> getDetailsById(String alarmId, String equipId, String type, String area) {
final String videoType = "video";
Map<String, Object> res = new HashMap<>();
if (videoType.equals(type)) {
List<AlamVideoVO> video = videoMapper.getVideoBySpeId(equipId);
List<AlamVideoVO> video = videoMapper.getVideoBySpeId(Long.valueOf(equipId));
video.forEach(action -> {
action.setVedioFormat(vedioFormat);
action.setUrl(videoService.getVideoUrl(action.getName(), action.getPresetPosition(), action.getUrl(), action.getCode()));
......@@ -153,7 +153,7 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
}
List<AlamVideoVO> videoBySpeId;
if (specificAlarm == null) {
videoBySpeId = videoMapper.getVideoBySpeId(equipId);
videoBySpeId = videoMapper.getVideoBySpeId(Long.valueOf(equipId));
} else {
videoBySpeId = videoMapper.getVideoBySpeId(specificAlarm.getEquipmentSpecificId());
}
......@@ -449,7 +449,7 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
// Token serverToken = remoteSecurityService.getServerToken();
IotSystemAlarmRo confirmAlamVo = new IotSystemAlarmRo();
confirmAlamVo.setId(ent.getId());
ent = confirmAlarmMapper.getDetailsById(ent.getId(), null);
ent = confirmAlarmMapper.getDetailsById(String.valueOf(ent.getId()), null);
EquipmentSpecific equipmentSpecific = equipmentSpecificSerivce.getById(ent.getEquipmentSpecificId());
List<FormInstance> formInstances = new ArrayList<>();
......
......@@ -592,7 +592,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
}
private List<AlarmDataVO> getProcessInfo(Long id) {
EquipmentSpecificAlarmLog alam = confirmAlarmMapper.getDetailsById(id, null);
EquipmentSpecificAlarmLog alam = confirmAlarmMapper.getDetailsById(String.valueOf(id), null);
List<AlarmDataVO> lists = new ArrayList<>();
AlarmDataVO v1 = new AlarmDataVO();
......
......@@ -408,16 +408,14 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService {
public static byte[] file2byte(File file)
{
try {
FileInputStream in =new FileInputStream(file);
try (FileInputStream in =new FileInputStream(file);) {
//当文件没有结束时,每次读取一个字节显示
byte[] data=new byte[in.available()];
byte[] data = new byte[in.available()];
in.read(data);
in.close();
return data;
} catch (Exception e) {
e.printStackTrace();
return null;
return new byte[0];
}
}
......
......@@ -280,16 +280,14 @@ public class FireAutoSysManageReportServiceImpl implements IFireAutoSysManageRep
}
public static byte[] file2byte(File file) {
try {
FileInputStream in = new FileInputStream(file);
try (FileInputStream in = new FileInputStream(file);) {
//当文件没有结束时,每次读取一个字节显示
byte[] data = new byte[in.available()];
in.read(data);
in.close();
return data;
} catch (Exception e) {
e.printStackTrace();
return null;
return new byte[0];
}
}
}
......@@ -1072,7 +1072,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
public Map<String, Object> integrationPageSysData(String systemCode, Boolean isUpdate) {
// TODO Auto-generated method stub
if (!StringUtil.isNotEmpty(SystemTypeEnum.getEnum(systemCode))) {
return null;
return Collections.emptyMap();
}
Map<String, Object> data;
if (isUpdate) {
......@@ -1088,7 +1088,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
if (!ObjectUtils.isEmpty(data)) {
mqttSendGateway.sendToMqtt(String.format("%s%s", "INTEGRATE_TOPIC/", systemCode), JSON.toJSONString(data));
}
return null;
return Collections.emptyMap();
}
public Map<String, Object> saveIntegrationPageSysData(String systemCode) {
......@@ -1682,11 +1682,9 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
private static byte[] file2byte(File file) {
try {
FileInputStream in = new FileInputStream(file);
try (FileInputStream in = new FileInputStream(file);) {
byte[] data = new byte[in.available()];
in.read(data);
in.close();
return data;
} catch (Exception e) {
e.printStackTrace();
......
......@@ -316,9 +316,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
log.info(String.format("发送eqm转kafka消息失败:%s", e.getMessage()));
}
// redis缓存指定指标、指定时长物联数据
pressurePumpService.saveDataToRedis(iotDatalist, topic);
if (!StringUtils.isEmpty(traceId)) {
String finalTraceId = traceId;
List<IotDataVO> collect = iotDatalist.stream().map(x -> {
......@@ -339,7 +336,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
*/
public void realTimeDateProcessing(TopicEntityVo topicEntity, List<IotDataVO> iotDatalist,EquipmentSpecificVo vo) {
String iotCode = topicEntity.getIotCode();
if (EquipAndCarEnum.equip.type.equals(topicEntity.getType())) {
List<EquipmentSpecificIndex> indexList = equipmentSpecificIndexService
.getEquipmentSpeIndexBySpeIotCode(iotCode);
......@@ -347,6 +343,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
return;
}
equipRealTimeDate(iotDatalist, indexList, topicEntity,vo);
String bizOrgCode = indexList.get(0).getBizOrgCode();
// redis缓存指定指标、指定时长物联数据
pressurePumpService.saveDataToRedis(iotDatalist, iotCode, bizOrgCode);
} else {
List<CarProperty> carProperties = carPropertyService.getCarPropListByIotCode(iotCode);
if (ObjectUtils.isEmpty(carProperties)) {
......@@ -354,7 +353,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
}
carRealTimeDate(iotDatalist, carProperties,topicEntity);
}
}
/**
......
......@@ -7,10 +7,12 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -150,9 +152,9 @@ public class FileController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/download/**", method = RequestMethod.GET)
public void download(HttpServletResponse response, HttpServletRequest request) throws Exception {
try {
String path = request.getServletPath().substring(15);
IOUtils.copy(new FileInputStream(fileUploadDir + path), response.getOutputStream());
try (FileInputStream inputStream = new FileInputStream(fileUploadDir + request.getServletPath().substring(15));
ServletOutputStream outputStream = response.getOutputStream();) {
IOUtils.copy(inputStream, outputStream);
} catch (Exception e) {
e.printStackTrace();
ResponseUtils.renderText(response, "File not exists!");
......@@ -253,12 +255,9 @@ public class FileController extends AbstractBaseController {
}
String htmlContent = (String) processData.get("html");
try {
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), "UTF-8"));
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), StandardCharsets.UTF_8));) {
writer.write(htmlContent);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -51,8 +51,6 @@ public class PlanVisual3dController extends AbstractBaseController {
@Autowired
HttpServletResponse response;
@Autowired
HttpServletRequest request;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "预案应用树", notes = "预案应用树")
......@@ -76,7 +74,7 @@ public class PlanVisual3dController extends AbstractBaseController {
if (testPlan != null) {
String path = testPlan.getFilePath();
if (path != null && !"".equals(path)) {
try {
try (InputStream fis = new BufferedInputStream(new FileInputStream(fileUploadDir + path));) {
// path是指欲下载的文件的路径。
File file = new File(fileUploadDir + path);
if (file.exists()) {
......@@ -84,12 +82,9 @@ public class PlanVisual3dController extends AbstractBaseController {
String filename = file.getName();
// 取得文件的后缀名。
String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase();
// 以流的形式下载文件。
InputStream fis = new BufferedInputStream(new FileInputStream(fileUploadDir + path));
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
fis.close();
// 清空response
// response.reset();
// 设置response的Header
......
......@@ -883,7 +883,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public void run() {
boolean isRunning = true;
int k = 0;
while (isRunning) {
k++;
isRunning = k < Integer.MAX_VALUE;
AlarmParam deviceData = null;
try {
deviceData = blockingQueue.take();
......
......@@ -83,11 +83,8 @@ public class FileHelper {
* @return
*/
public static boolean isExcel2003(File file) {
InputStream is = null;
Workbook wb = null;
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
try (InputStream is = new FileInputStream(file);
Workbook wb = WorkbookFactory.create(is);) {
if (wb instanceof XSSFWorkbook) {
return false;
} else if (wb instanceof HSSFWorkbook) {
......@@ -95,17 +92,6 @@ public class FileHelper {
}
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -187,13 +173,10 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content);
......@@ -202,19 +185,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -227,13 +198,10 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
......@@ -242,19 +210,7 @@ public class FileHelper {
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
}
return buffer;
}
......@@ -265,28 +221,15 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8));) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
} catch (IOException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -375,11 +318,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -388,20 +328,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
/**
......@@ -1192,34 +1119,25 @@ public class FileHelper {
*/
public static void getExcel(String url, String fileName, HttpServletResponse response, HttpServletRequest request) {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
try {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName + ".xls") + "\"");
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//通过文件路径获得File对象
File file = new File(url);
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try (//通过文件路径获得File对象
FileInputStream in = new FileInputStream(new File(url));
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
int b = 0;
byte[] buffer = new byte[2048];
while ((b = in.read(buffer)) != -1) {
out.write(buffer, 0, b); //4.写到输出流(out)中
}
in.close();
out.flush();
out.close();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
......
......@@ -75,20 +75,20 @@ public class FileUtils {
* @return
*/
public static String fileToZip(List<String> list, String fileName, String ipUrl) {
InputStream fis = null;
BufferedInputStream bis = null;
FileOutputStream fos = null;
ZipOutputStream zos = null;
// 临时目录
String path = System.getProperty("java.io.tmpdir") + fileName;
File zipFile = new File(path);
zipFile.deleteOnExit();
try {
File zipFile = new File(path);
zipFile.deleteOnExit();
zipFile.createNewFile();
fos = new FileOutputStream(zipFile);
zos = new ZipOutputStream(new BufferedOutputStream(fos));
} catch (IOException e) {
e.printStackTrace();
}
InputStream fis = null;
BufferedInputStream bis = null;
try (
FileOutputStream fos = new FileOutputStream(zipFile);
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));) {
byte[] bufs = new byte[1024 * 10];
for (String a : list) {
fis = getInputStreamFromURL(ipUrl + a);
......@@ -105,9 +105,6 @@ public class FileUtils {
}
}
System.out.println("压缩成功");
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
......@@ -116,12 +113,11 @@ public class FileUtils {
if (null != bis) {
bis.close();
}
if (null != zos) {
zos.close();
if (null != fis) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
return path;
......
......@@ -98,7 +98,11 @@ public class RsDataQueue {
private Runnable task_runnable = new Runnable() {
@Override
public void run() {
while (true) {
int k = 0;
boolean b = true;
while (b) {
k++;
b = k < Integer.MAX_VALUE;
try {
FmeaMessage fmeaMessage = blockingQueue.take();
if (riskSourceService != null) {
......
......@@ -21,7 +21,7 @@ public class AmosThreadPool {
/**
* 单例
*/
private static AmosThreadPool instance;
private static volatile AmosThreadPool instance;
/**
* 执行服务
......
......@@ -26,10 +26,12 @@ public class FileUtil {
if (!targetFile.exists()) {
targetFile.mkdirs();
}
FileOutputStream out = new FileOutputStream(filePath + fileName);
out.write(file);
out.flush();
out.close();
try (FileOutputStream out = new FileOutputStream(filePath + fileName);) {
out.write(file);
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
......
......@@ -34,9 +34,9 @@ public class SocketClient {
public void processUdp(int port, int type) throws SocketException {
if (type < 0) type = 0;
if (type >= testFilePath.length) type -= 1;
DatagramSocket datagramSocket = new DatagramSocket();
try {
FileInputStream fis = new FileInputStream(new File("C:\\Users\\DELL\\Desktop\\ffmpeg-4.4-full_build-shared\\bin\\out.pcm"));
try (DatagramSocket datagramSocket = new DatagramSocket();
FileInputStream fis = new FileInputStream(new File("C:\\Users\\DELL\\Desktop\\ffmpeg-4.4-full_build-shared\\bin\\out.pcm"));) {
byte[] b = new byte[1280];
int len;
while ((len = fis.read(b)) > 0) {
......@@ -57,11 +57,10 @@ public class SocketClient {
if (type < 0) type = 0;
if (type >= testFilePath.length) type -= 1;
Socket socket = new Socket();
try {
try (Socket socket = new Socket();
FileInputStream fis = new FileInputStream(new File(testFilePath[type]));) {
socket.connect(new InetSocketAddress(InetAddress.getLocalHost().getHostAddress(), port));
OutputStream outputStream = socket.getOutputStream();
FileInputStream fis = new FileInputStream(new File(testFilePath[type]));
byte[] b = new byte[4096];
int len;
while ((len = fis.read(b)) > 0) {
......
......@@ -125,7 +125,9 @@ public class SpeechTranscriberDemo {
public void process(String filepath) {
SpeechTranscriber transcriber = null;
try {
File file = new File(filepath);
try (FileInputStream fis = new FileInputStream(file);
DatagramSocket datagramSocket = new DatagramSocket();) {
//创建实例、建立连接。
transcriber = new SpeechTranscriber(client, getTranscriberListener());
transcriber.setAppKey("89KKwpGXXN37Pn1G");
......@@ -164,12 +166,9 @@ public class SpeechTranscriberDemo {
//此方法将以上参数设置序列化为JSON发送给服务端,并等待服务端确认。
transcriber.start();
File file = new File(filepath);
FileInputStream fis = new FileInputStream(file);
byte[] b = new byte[320];
int len;
DatagramSocket datagramSocket = new DatagramSocket();
while ((len = fis.read(b)) > 0) {
// logger.info("send data pack length: " + len);
datagramSocket.send(new DatagramPacket(b, b.length, InetAddress.getLocalHost(), 25000));
......
......@@ -108,9 +108,8 @@ public class SignController extends BaseController {
signDto.setPersonPhotos(personImg.get(0).getValue());
} catch (Exception e) {
e.printStackTrace();
} finally {
return ResponseHelper.buildResponse(signDto);
}
return ResponseHelper.buildResponse(signDto);
}
......
......@@ -17,7 +17,7 @@ public class TriggerKeyQueue {
/**
* 单例
*/
private static TriggerKeyQueue instance;
private static volatile TriggerKeyQueue instance;
/**
* 队列
......
......@@ -60,6 +60,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -121,20 +122,10 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -164,24 +155,10 @@ public class FileHelper {
* @return
*/
public static boolean isPPT2003(File file) {
InputStream is = null;
HSLFSlideShow ppt = null;
try {
is = new FileInputStream(file);
ppt = new HSLFSlideShow(is);
try (InputStream is = new FileInputStream(file);
HSLFSlideShow ppt = new HSLFSlideShow(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != ppt) {
ppt.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -193,13 +170,10 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content);
......@@ -208,19 +182,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -232,13 +194,10 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
File file = new File(path);
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
......@@ -247,19 +206,7 @@ public class FileHelper {
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
}
return buffer;
}
......@@ -269,28 +216,17 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8)); ) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -379,11 +315,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -392,17 +325,6 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
......@@ -1198,35 +1120,24 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws
*/
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
try {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//通过文件路径获得File对象
File file = new File(url);
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
try {
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try (FileInputStream in = new FileInputStream(new File(url));
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
int b = 0;
byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中
}
in.close();
out.flush();
out.close();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
......
......@@ -34,18 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try (InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
e.printStackTrace();
......@@ -58,22 +52,16 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
InputStream stream = null;
try {
stream = new FileInputStream(new File(fileName));
InputStream stream = new FileInputStream(new File(fileName));
InputStream stream2 = new FileInputStream(new File(fileName));
parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return null;
return "";
}
......
package com.yeejoin.amos.latentdanger.core.threadpool;
import com.yeejoin.amos.latentdanger.business.constants.Constants;
import com.yeejoin.amos.latentdanger.business.trigger.TriggerKeyQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -20,7 +21,7 @@ public class AmosThreadPool {
/**
* 单例
*/
private static AmosThreadPool instance;
private static volatile AmosThreadPool instance;
/**
* 执行服务
......
......@@ -9,6 +9,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.yeejoin.amos.maintenance.business.dao.repository.IPointInputItemDao;
import com.yeejoin.amos.maintenance.core.framework.PersonIdentify;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
......@@ -73,6 +74,8 @@ public class InputItemController extends AbstractBaseController {
IInputItemService inputItemService;
@Autowired
IInputItemDao inputItemDao;
@Autowired
IPointInputItemDao iPointInputItemDao;
/**
* 新增巡检项
......@@ -155,6 +158,10 @@ public class InputItemController extends AbstractBaseController {
if (ObjectUtils.isEmpty(itemIDs)) {
return CommonResponseUtil.failure("请选择要删除的检查项");
}
//查询该巡查项是否已有巡查点绑定 有就返回
if (iPointInputItemDao.selectByITemId(itemIDs) > 0) {
return CommonResponseUtil.failure("该巡检项已绑定,请先删除巡检设备的巡检项");
}
String[] ids = itemIDs.split(",");
inputItemService.batchDelInputItem(ids);
return CommonResponseUtil.success();
......
......@@ -25,6 +25,9 @@ public interface IPointInputItemDao extends BaseDao<PointInputItem, Long> {
@Query(value = "SELECT * FROM p_point_inputitem WHERE point_id = ?1 AND input_item_id = ?2", nativeQuery = true)
PointInputItem getPointInputItem(Long pointId, Long inputItemId);
@Query(value = "SELECT count(*) FROM p_point_inputitem WHERE input_item_id IN(?1) ", nativeQuery = true)
int selectByITemId(String inputItemIds);
@Modifying
@Transactional
@Query(value = "DELETE FROM p_point_inputitem WHERE point_id = (?1) AND input_item_id IN (?2)", nativeQuery = true)
......
......@@ -17,7 +17,7 @@ public class TriggerKeyQueue {
/**
* 单例
*/
private static TriggerKeyQueue instance;
private static volatile TriggerKeyQueue instance;
/**
* 队列
......
......@@ -40,6 +40,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -64,11 +65,8 @@ public class FileHelper {
* @return
*/
public static boolean isExcel2003(File file) {
InputStream is = null;
Workbook wb = null;
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
try (InputStream is = new FileInputStream(file);
Workbook wb = WorkbookFactory.create(is);) {
if (wb instanceof XSSFWorkbook) {
return false;
} else if (wb instanceof HSSFWorkbook) {
......@@ -76,17 +74,6 @@ public class FileHelper {
}
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -97,20 +84,10 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -169,34 +146,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
File file = new File(path);
if (file.exists()) {
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content);
content = br.readLine();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -208,34 +170,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
File file = new File(path);
if (file.exists()) {
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
content = br.readLine();
}
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
}
}
return buffer;
}
......@@ -245,28 +192,15 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
} catch (IOException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -355,11 +289,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -368,20 +299,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
/**
......@@ -1254,38 +1172,31 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws
*/
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
try {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
//通过文件路径获得File对象
File file = new File(url);
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
try {
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try ( FileInputStream in = new FileInputStream(file);
OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//通过文件路径获得File对象
File file = new File(url);
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0;
byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中
}
in.close();
out.flush();
out.close();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
//3.通过response获取OutputStream对象(out)
int b = 0;
byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中
}
out.flush();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
}
/**
......
......@@ -34,17 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try (InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
......
......@@ -20,7 +20,7 @@ public class AmosThreadPool {
/**
* 单例
*/
private static AmosThreadPool instance;
private static volatile AmosThreadPool instance;
/**
* 执行服务
......
......@@ -17,7 +17,7 @@ public class TriggerKeyQueue {
/**
* 单例
*/
private static TriggerKeyQueue instance;
private static volatile TriggerKeyQueue instance;
/**
* 队列
......
......@@ -41,6 +41,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -98,20 +99,10 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -141,24 +132,10 @@ public class FileHelper {
* @return
*/
public static boolean isPPT2003(File file) {
InputStream is = null;
HSLFSlideShow ppt = null;
try {
is = new FileInputStream(file);
ppt = new HSLFSlideShow(is);
try ( InputStream is = new FileInputStream(file);
HSLFSlideShow ppt = new HSLFSlideShow(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != ppt) {
ppt.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -170,34 +147,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
File file = new File(path);
if (file.exists()) {
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content);
content = br.readLine();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -209,34 +171,20 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
File file = new File(path);
if (file.exists()) {
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
content = br.readLine();
}
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
}
}
return buffer;
}
......@@ -246,28 +194,15 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
} catch (IOException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -356,11 +291,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -369,20 +301,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
/**
......@@ -1258,35 +1177,28 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws
*/
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
try {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
//通过文件路径获得File对象
File file = new File(url);
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
try {
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try ( FileInputStream in = new FileInputStream(file);
OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//通过文件路径获得File对象
File file = new File(url);
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0;
byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中
}
in.close();
out.flush();
out.close();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
......
......@@ -34,8 +34,7 @@ public class TikaUtils {
public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try (InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
......@@ -45,7 +44,6 @@ public class TikaUtils {
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
e.printStackTrace();
......@@ -58,21 +56,15 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
InputStream stream = null;
try {
stream = new FileInputStream(new File(fileName));
try (InputStream stream = new FileInputStream(new File(fileName))) {
parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return null;
}
......
package com.yeejoin.amos.patrol.core.threadpool;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.trigger.TriggerKeyQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -20,7 +21,7 @@ public class AmosThreadPool {
/**
* 单例
*/
private static AmosThreadPool instance;
private static volatile AmosThreadPool instance;
/**
* 执行服务
......
......@@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -209,14 +210,10 @@ public class FileController {
} else {
processData = DocUtil.processDocx(data);
}
String htmlContent = (String) processData.get("html");
try {
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), "UTF-8"));
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), StandardCharsets.UTF_8));) {
writer.write(htmlContent);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -17,7 +17,7 @@ public class TriggerKeyQueue {
/**
* 单例
*/
private static TriggerKeyQueue instance;
private static volatile TriggerKeyQueue instance;
/**
* 队列
......
......@@ -39,6 +39,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -63,11 +64,8 @@ public class FileHelper {
* @return
*/
public static boolean isExcel2003(File file) {
InputStream is = null;
Workbook wb = null;
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
try (InputStream is = new FileInputStream(file);
Workbook wb = WorkbookFactory.create(is);) {
if (wb instanceof XSSFWorkbook) {
return false;
} else if (wb instanceof HSSFWorkbook) {
......@@ -75,17 +73,6 @@ public class FileHelper {
}
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -96,20 +83,10 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -168,34 +145,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
File file = new File(path);
if (file.exists()) {
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content);
content = br.readLine();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -207,34 +169,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
File file = new File(path);
if (file.exists()) {
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
content = br.readLine();
}
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
}
}
return buffer;
}
......@@ -244,28 +191,15 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
} catch (IOException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -354,11 +288,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -367,20 +298,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
/**
......@@ -1253,38 +1171,31 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws
*/
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
try {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
//通过文件路径获得File对象
File file = new File(url);
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
try {
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try ( FileInputStream in = new FileInputStream(file);
OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//通过文件路径获得File对象
File file = new File(url);
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0;
byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中
}
in.close();
out.flush();
out.close();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
//3.通过response获取OutputStream对象(out)
int b = 0;
byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中
}
out.flush();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
}
/**
......
......@@ -34,17 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try(InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
......@@ -58,21 +53,14 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
InputStream stream = null;
try {
stream = new FileInputStream(new File(fileName));
try ( InputStream stream = new FileInputStream(new File(fileName));) {
parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return null;
}
......
......@@ -20,7 +20,7 @@ public class AmosThreadPool {
/**
* 单例
*/
private static AmosThreadPool instance;
private static volatile AmosThreadPool instance;
/**
* 执行服务
......
......@@ -23,12 +23,8 @@ eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone=http://${spring.security.user.name}:${spring.security.user.password}@172.16.10.215:10001/eureka/
spring.security.user.name=admin
spring.security.user.password=a1234560
#security config
#security.password=a1234560
#security.loginId=fas_system
security.productApp=STUDIO_APP_MOBILE
#security.productWeb=STUDIO_APP_WEB
#security.appKeyApp=studio_normalapp_3056965
amos.system.user.user-name=fas_system
......@@ -113,13 +109,14 @@ isSendIot=false
equipment.scrap.day=30
#提醒时间
equipment.scrap.cron=0 0 9 * * ?
#?????????????
equipment.pressurepump.start.cron=0 0 0 * * ?
# 稳压泵启动信号
equipment.pressurepump.start=FHS_PressurePump_Start
# 稳压泵管网压力信号
equipment.pressurepump.pipepressure=FHS_PipePressureDetector_PipePressure
# 站端标识
state.code=GW190301
......
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://172.16.11.20:3306/autosys_business_v3.0.0.2?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username= root
spring.datasource.password= root_123
spring.datasource.url = jdbc:mysql://172.16.10.215:3307/dl_business_v3.0.1.3?useUnicode=true&allowMultiQueries=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.minimum-idle= 3
spring.datasource.hikari.maximum-pool-size= 30
spring.datasource.hikari.auto-commit= true
spring.datasource.hikari.idle-timeout= 10000
spring.datasource.hikari.idle-timeout= 500000
spring.datasource.hikari.max-lifetime= 1800000
spring.datasource.hikari.connection-timeout= 30000
spring.datasource.hikari.connection-timeout= 60000
spring.datasource.hikari.connection-test-query= SELECT 1
eureka.instance.hostname= 172.16.11.20
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone: http://${eureka.instance.hostname}:10001/eureka/
#security config
#security.password=a1234560
#security.loginId=fas_system
# \u6587\u4EF6\u670D\u52A1\u5668\u5730\u5740
fileserver_domain=http://172.16.10.215:9000/
#eureka.instance.ip-address= 172.16.3.135
eureka.instance.hostname= 172.16.10.215
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone=http://${spring.security.user.name}:${spring.security.user.password}@172.16.10.215:10001/eureka/
spring.security.user.name=admin
spring.security.user.password=a1234560
security.productApp=STUDIO_APP_MOBILE
#security.productWeb=STUDIO_APP_WEB
#security.appKeyApp=studio_normalapp_3056965
amos.system.user.user-name=fas_system
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3056965
amos.system.user.product=STUDIO_APP_WEB
#redis
spring.redis.database=1
spring.redis.host=172.16.11.20
spring.redis.host=172.16.10.215
spring.redis.port=6379
spring.redis.password=1234560
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
spring.redis.expire.time=30000
## emqx
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.11.33:1883
emqx.broker=tcp://172.16.10.215:1883
emqx.user-name=admin
emqx.password=public
mqtt.scene.host=mqtt://172.16.11.33:8083/mqtt
mqtt.scene.host=mqtt://172.16.10.215:8083/mqtt
mqtt.client.product.id=mqtt
mqtt.topic=topic_mqtt
spring.mqtt.completionTimeout=3000
#定时任务
##物联报表定时任务
jobs.month.cron = 0 50 0 1 * ?
jobs.day.cron = 0 5 0 * * ?
jobs.week.cron = 0 25 0 ? * 1
jobs.day.cron.old = 0 25 0 * * ?
#数据同步开关
systemctl.sync.switch=false
#数据JCS开关
......@@ -71,9 +82,49 @@ param.system.online.date = 2019-02-12
# 视频转码服务开关 hls(关)/flv(开),默认关闭,数字换流站使用时开启
window.vedioFormat = hls
window.vedioFormat.video = flv
# 航天视频服务地址
param.htvideo.url="";
param.htvideo.url=http://192.168.4.174:9001;
# 南瑞视频转码服务地址
param.nrvideo.url="";
param.nrvideo.url=http://198.87.103.158:8001;
#南瑞视频平台通过视频id获取flv格式视频播放地址
param.nrflvbyvoideoid.url=http://192.168.4.159:10010/api/media/live
# 预案消防炮、消防泵设备维度类型
equipment.plan.monitor=92030200,92032200
equipment.plan.pump=92010600,92030600,92130400,92140200,92150300
# 机场使用特殊配置iotCode前缀,装备、车辆及导入使用到
# 机场使用
#iot.code.prefix.have.used=20210003,20210004,20210005
# 电力使用
iot.code.prefix.have.used=
#装备服务在接收到站端iot推送的装备数据后进行influxdb存库
#1.在装备接口消息处向influxdb/{productKey}/{deviceName} 消息地址推送数据,iot负责存库
#2.配置文件添加配置项开关,默认为关闭,该功能只使用于中心及系统
#是否向iot推送消息
isSendIot=false
#报废前30日 发起提醒
equipment.scrap.day=30
#提醒时间
equipment.scrap.cron=0 0 9 * * ?
# 稳压泵启动信号
equipment.pressurepump.start=FHS_PressurePump_Start
# 稳压泵管网压力信号
equipment.pressurepump.pipepressure=FHS_PipePressureDetector_PipePressure
# 站端标识
state.code=GW190301
state.name=\u9526\u5c4f\u6362\u6d41\u7ad9
#用于总部系统与站端系统逻辑区分,站端写zd总部默认为空
system.type=zd
# 是否开启遥测数据上报
is.open.telemetering=false
# 水池液位相关信号
water.level.indexKey=FHS_FirePoolDevice_WaterLevel,FHS_LevelDetector_WaterLevel,FHS_WirelessliquidDetector_WaterLevel,CAFS_FoamTank_FoamTankLevel,CAFS_WaterTank_WaterTankLevel
\ No newline at end of file
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://172.16.10.66:3306/safety-business-3.0.1?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username= root
spring.datasource.password= root_123
spring.datasource.url = jdbc:mysql://172.16.10.215:3307/dl_business_v3.0.1.3?useUnicode=true&allowMultiQueries=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.minimum-idle= 3
spring.datasource.hikari.maximum-pool-size= 30
spring.datasource.hikari.auto-commit= true
spring.datasource.hikari.idle-timeout= 10000
spring.datasource.hikari.idle-timeout= 500000
spring.datasource.hikari.max-lifetime= 1800000
spring.datasource.hikari.connection-timeout= 30000
spring.datasource.hikari.connection-timeout= 60000
spring.datasource.hikari.connection-test-query= SELECT 1
fdfs.so-timeout=1501
fdfs.connect-timeout=601
fdfs.thumb-image.height=200
fdfs.thumb-image.width=200
fdfs.tracker-list[0]=39.98.246.31:22122
eureka.instance.hostname= 172.16.10.72
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone: http://${eureka.instance.hostname}:10001/eureka/
# \u6587\u4EF6\u670D\u52A1\u5668\u5730\u5740
fileserver_domain=http://172.16.10.215:9000/
#eureka.instance.ip-address= 172.16.3.135
eureka.instance.hostname= 172.16.10.215
#security config
#security.password=a1234560
#security.loginId=fas_system
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone=http://${spring.security.user.name}:${spring.security.user.password}@172.16.10.215:10001/eureka/
spring.security.user.name=admin
spring.security.user.password=a1234560
security.productApp=STUDIO_APP_MOBILE
#security.productWeb=STUDIO_APP_WEB
#security.appKeyApp=studio_normalapp_3056965
amos.system.user.user-name=fas_system
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3157169
amos.system.user.app-key=studio_normalapp_3056965
amos.system.user.product=STUDIO_APP_WEB
#redis
spring.redis.database=0
spring.redis.host=172.16.10.85
spring.redis.database=1
spring.redis.host=172.16.10.215
spring.redis.port=6379
spring.redis.password=amos2019Redis
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
spring.redis.expire.time=30000
mqtt.scene.host=mqtt://172.16.10.85:8083/mqtt
## emqx
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.215:1883
emqx.user-name=admin
emqx.password=public
mqtt.scene.host=mqtt://172.16.10.215:8083/mqtt
mqtt.client.product.id=mqtt
mqtt.topic=topic_mqtt
spring.mqtt.completionTimeout=3000
## emqx
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.85:1883
emqx.user-name=super
emqx.password=a123456
#定时任务
##物联报表定时任务
jobs.month.cron = 0 50 0 1 * ?
jobs.day.cron = 0 5 0 * * ?
jobs.week.cron = 0 25 0 ? * 1
jobs.day.cron.old = 0 25 0 * * ?
#数据同步开关
systemctl.sync.switch=false
#数据JCS开关
systemctl.jcs.switch=true
systemctl.jcs.switch=false
#平台数据开关
systemctl.amos.switch=true
isSendApp=true
systemctl.amos.switch=false
isSendApp=false
#报表数据地址
equip.report.url=/fire-fighting-system/ureport/preview?_u=file:
......@@ -78,9 +82,49 @@ param.system.online.date = 2019-02-12
# 视频转码服务开关 hls(关)/flv(开),默认关闭,数字换流站使用时开启
window.vedioFormat = hls
window.vedioFormat.video = flv
# 航天视频服务地址
param.htvideo.url="";
param.htvideo.url=http://192.168.4.174:9001;
# 南瑞视频转码服务地址
param.nrvideo.url="";
param.nrvideo.url=http://198.87.103.158:8001;
#南瑞视频平台通过视频id获取flv格式视频播放地址
param.nrflvbyvoideoid.url=http://192.168.4.159:10010/api/media/live
# 预案消防炮、消防泵设备维度类型
equipment.plan.monitor=92030200,92032200
equipment.plan.pump=92010600,92030600,92130400,92140200,92150300
# 机场使用特殊配置iotCode前缀,装备、车辆及导入使用到
# 机场使用
#iot.code.prefix.have.used=20210003,20210004,20210005
# 电力使用
iot.code.prefix.have.used=
#装备服务在接收到站端iot推送的装备数据后进行influxdb存库
#1.在装备接口消息处向influxdb/{productKey}/{deviceName} 消息地址推送数据,iot负责存库
#2.配置文件添加配置项开关,默认为关闭,该功能只使用于中心及系统
#是否向iot推送消息
isSendIot=false
#报废前30日 发起提醒
equipment.scrap.day=30
#提醒时间
equipment.scrap.cron=0 0 9 * * ?
# 稳压泵启动信号
equipment.pressurepump.start=FHS_PressurePump_Start
# 稳压泵管网压力信号
equipment.pressurepump.pipepressure=FHS_PipePressureDetector_PipePressure
# 站端标识
state.code=GW190301
state.name=\u9526\u5c4f\u6362\u6d41\u7ad9
#用于总部系统与站端系统逻辑区分,站端写zd总部默认为空
system.type=zd
# 是否开启遥测数据上报
is.open.telemetering=false
# 水池液位相关信号
water.level.indexKey=FHS_FirePoolDevice_WaterLevel,FHS_LevelDetector_WaterLevel,FHS_WirelessliquidDetector_WaterLevel,CAFS_FoamTank_FoamTankLevel,CAFS_WaterTank_WaterTankLevel
\ No newline at end of file
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://172.16.11.20:3306/autosys_business_v3.0.0.2?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username= root
spring.datasource.password= root_123
spring.datasource.url = jdbc:mysql://172.16.10.215:3307/dl_business_v3.0.1.3?useUnicode=true&allowMultiQueries=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.minimum-idle= 3
spring.datasource.hikari.maximum-pool-size= 30
spring.datasource.hikari.auto-commit= true
spring.datasource.hikari.idle-timeout= 10000
spring.datasource.hikari.idle-timeout= 500000
spring.datasource.hikari.max-lifetime= 1800000
spring.datasource.hikari.connection-timeout= 30000
spring.datasource.hikari.connection-timeout= 60000
spring.datasource.hikari.connection-test-query= SELECT 1
eureka.instance.hostname= 172.16.11.20
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone: http://${eureka.instance.hostname}:10001/eureka/
#security config
#security.password=a1234560
#security.loginId=fas_system
# \u6587\u4EF6\u670D\u52A1\u5668\u5730\u5740
fileserver_domain=http://172.16.10.215:9000/
#eureka.instance.ip-address= 172.16.3.135
eureka.instance.hostname= 172.16.10.215
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone=http://${spring.security.user.name}:${spring.security.user.password}@172.16.10.215:10001/eureka/
spring.security.user.name=admin
spring.security.user.password=a1234560
security.productApp=STUDIO_APP_MOBILE
#security.productWeb=STUDIO_APP_WEB
#security.appKeyApp=studio_normalapp_3056965
amos.system.user.user-name=fas_system
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3056965
amos.system.user.product=STUDIO_APP_WEB
#redis
spring.redis.database=1
spring.redis.host=172.16.11.20
spring.redis.host=172.16.10.215
spring.redis.port=6379
spring.redis.password=1234560
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
spring.redis.expire.time=30000
## emqx
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.11.33:1883
emqx.broker=tcp://172.16.10.215:1883
emqx.user-name=admin
emqx.password=public
mqtt.scene.host=mqtt://172.16.11.33:8083/mqtt
mqtt.scene.host=mqtt://172.16.10.215:8083/mqtt
mqtt.client.product.id=mqtt
mqtt.topic=topic_mqtt
spring.mqtt.completionTimeout=3000
#定时任务
##物联报表定时任务
jobs.month.cron = 0 50 0 1 * ?
jobs.day.cron = 0 5 0 * * ?
jobs.week.cron = 0 25 0 ? * 1
jobs.day.cron.old = 0 25 0 * * ?
#数据同步开关
systemctl.sync.switch=false
#数据JCS开关
systemctl.jcs.switch=false
#平台数据开关
systemctl.amos.switch=false
isSendApp=false
#报表数据地址
equip.report.url=/fire-fighting-system/ureport/preview?_u=file:
......@@ -70,9 +82,49 @@ param.system.online.date = 2019-02-12
# 视频转码服务开关 hls(关)/flv(开),默认关闭,数字换流站使用时开启
window.vedioFormat = hls
window.vedioFormat.video = flv
# 航天视频服务地址
param.htvideo.url="";
param.htvideo.url=http://192.168.4.174:9001;
# 南瑞视频转码服务地址
param.nrvideo.url="";
param.nrvideo.url=http://198.87.103.158:8001;
#南瑞视频平台通过视频id获取flv格式视频播放地址
param.nrflvbyvoideoid.url=http://192.168.4.159:10010/api/media/live
# 预案消防炮、消防泵设备维度类型
equipment.plan.monitor=92030200,92032200
equipment.plan.pump=92010600,92030600,92130400,92140200,92150300
# 机场使用特殊配置iotCode前缀,装备、车辆及导入使用到
# 机场使用
#iot.code.prefix.have.used=20210003,20210004,20210005
# 电力使用
iot.code.prefix.have.used=
#装备服务在接收到站端iot推送的装备数据后进行influxdb存库
#1.在装备接口消息处向influxdb/{productKey}/{deviceName} 消息地址推送数据,iot负责存库
#2.配置文件添加配置项开关,默认为关闭,该功能只使用于中心及系统
#是否向iot推送消息
isSendIot=false
#报废前30日 发起提醒
equipment.scrap.day=30
#提醒时间
equipment.scrap.cron=0 0 9 * * ?
# 稳压泵启动信号
equipment.pressurepump.start=FHS_PressurePump_Start
# 稳压泵管网压力信号
equipment.pressurepump.pipepressure=FHS_PipePressureDetector_PipePressure
# 站端标识
state.code=GW190301
state.name=\u9526\u5c4f\u6362\u6d41\u7ad9
#用于总部系统与站端系统逻辑区分,站端写zd总部默认为空
system.type=zd
# 是否开启遥测数据上报
is.open.telemetering=false
# 水池液位相关信号
water.level.indexKey=FHS_FirePoolDevice_WaterLevel,FHS_LevelDetector_WaterLevel,FHS_WirelessliquidDetector_WaterLevel,CAFS_FoamTank_FoamTankLevel,CAFS_WaterTank_WaterTankLevel
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment