Commit bc61b69b authored by chenzhao's avatar chenzhao

Merge branch 'develop_dl_plan6_temp' of…

Merge branch 'develop_dl_plan6_temp' of http://39.98.45.134:8090/moa/amos-boot-biz into develop_dl_plan6_temp
parents 86e64509 4f8f69be
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 { ...@@ -26,6 +26,7 @@ public class DateUtils {
public static final String YEAR_PATTERN = "yyyy"; public static final String YEAR_PATTERN = "yyyy";
public static final String MINUTE_ONLY_PATTERN = "mm"; public static final String MINUTE_ONLY_PATTERN = "mm";
public static final String HOUR_ONLY_PATTERN = "HH"; 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_PATTERN = "MM-dd HH";
public static final String MONTH_DAY_HOUR_MINUTE_PATTERN = "MM-dd HH:mm"; public static final String MONTH_DAY_HOUR_MINUTE_PATTERN = "MM-dd HH:mm";
public static final String DATE_PATTERN_NUM = "yyyyMMdd"; public static final String DATE_PATTERN_NUM = "yyyyMMdd";
...@@ -911,10 +912,12 @@ public class DateUtils { ...@@ -911,10 +912,12 @@ public class DateUtils {
while (true) { while (true) {
if (MONTH_DAY_HOUR_PATTERN.equals(pattern)) { if (MONTH_DAY_HOUR_PATTERN.equals(pattern)) {
date = dateAddMinutes(date, 60); date = dateAddMinutes(date, 60);
} else if (DATE_PATTERN.equals(pattern) || MONTH_DAY_PATTERN.equals(pattern)) {
date = dateAddDays(date, 1);
} else { } else {
date = dateAddMinutes(date, 1); date = dateAddMinutes(date, 1);
} }
if (dateCompare(endDate, date) == 1) { if (dateCompare(endDate, date) >= 0) {
list.add(convertDateToString(date, pattern)); list.add(convertDateToString(date, pattern));
} else { } else {
break; break;
...@@ -1012,4 +1015,33 @@ public class DateUtils { ...@@ -1012,4 +1015,33 @@ public class DateUtils {
final LocalDateTime end = LocalDateTime.parse(sdf.format(endTime), DateTimeFormatter.ofPattern(pattern)); final LocalDateTime end = LocalDateTime.parse(sdf.format(endTime), DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).toHours(); 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 { ...@@ -54,14 +54,11 @@ public class WordConverterUtils {
FileItem item = factory.createItem("textField", "text/plain", true, file.getName()); FileItem item = factory.createItem("textField", "text/plain", true, file.getName());
int bytesRead = 0; int bytesRead = 0;
byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192];
try { try (FileInputStream fis = new FileInputStream(file);
FileInputStream fis = new FileInputStream(file); OutputStream os = item.getOutputStream();) {
OutputStream os = item.getOutputStream();
while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) { while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead); os.write(buffer, 0, bytesRead);
} }
os.close();
fis.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); 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; ...@@ -24,7 +24,7 @@ import java.util.Date;
@Accessors(chain = true) @Accessors(chain = true)
@TableName("wl_stock_detail") @TableName("wl_stock_detail")
@ApiModel(value = "StockDetail对象", description = "库存明细") @ApiModel(value = "StockDetail对象", description = "库存明细")
public class StockDetail extends BaseEntity implements Cloneable { public class StockDetail extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -90,14 +90,4 @@ public class StockDetail extends BaseEntity implements Cloneable { ...@@ -90,14 +90,4 @@ public class StockDetail extends BaseEntity implements Cloneable {
@ApiModelProperty(value = "位置信息") @ApiModelProperty(value = "位置信息")
private String area; 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; ...@@ -13,17 +13,18 @@ import java.util.Map;
public enum PressurePumpAnalysisEnum { public enum PressurePumpAnalysisEnum {
PRESSURE_PUMP_FAULT("1", "1", "稳压泵是否故障", "无", ""), PRESSURE_PUMP_FAULT("1", "1", "稳压泵是否故障", "无", ""),
PRESSURE_PUMP_INTERVAL("2", "2", "最近一次启停间隔", "0", "分钟"), PRESSURE_PUMP_INTERVAL("2", "2", "最近一次启停间隔", 0, "分钟"),
PRESSURE_PUMP_DURATION("3", "3", "最近一次启动时长", "0", "分钟"), PRESSURE_PUMP_DURATION("3", "3", "最近一次启动时长", 0, "分钟"),
PRESSURE_PUMP_HALF("4", "4", "半小时启动", "0", "次"), PRESSURE_PUMP_HALF("4", "4", "半小时启动", 0, "次"),
PRESSURE_PUMP_TWO("5", "5", "2小时启动", "0", "次"), // PRESSURE_PUMP_TWO("5", "5", "2小时启动", 0, "次"),
PRESSURE_PUMP_DAY_AVG("5", "5", "近3日平均启动", 0, "次"),
PRESSURE_PUMP_PIPE("6", "6", "管网压力", "正常", ""); PRESSURE_PUMP_PIPE("6", "6", "管网压力", "正常", "");
private final String key; private String key;
private final String code; private String code;
private final String name; private String name;
private final Object value; private Object value;
private final String unit; private String unit;
PressurePumpAnalysisEnum(String key, String code, String name, Object value, String unit) { PressurePumpAnalysisEnum(String key, String code, String name, Object value, String unit) {
this.key = key; this.key = key;
...@@ -37,22 +38,42 @@ public enum PressurePumpAnalysisEnum { ...@@ -37,22 +38,42 @@ public enum PressurePumpAnalysisEnum {
return key; return key;
} }
public void setKey(String key) {
this.key = key;
}
public String getCode() { public String getCode() {
return code; return code;
} }
public void setCode(String code) {
this.code = code;
}
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) {
this.name = name;
}
public Object getValue() { public Object getValue() {
return value; return value;
} }
public void setValue(Object value) {
this.value = value;
}
public String getUnit() { public String getUnit() {
return unit; return unit;
} }
public void setUnit(String unit) {
this.unit = unit;
}
public static List<Map<String, Object>> getList(){ public static List<Map<String, Object>> getList(){
PressurePumpAnalysisEnum[] values = PressurePumpAnalysisEnum.values(); PressurePumpAnalysisEnum[] values = PressurePumpAnalysisEnum.values();
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
......
...@@ -13,18 +13,23 @@ public enum PressurePumpRelateEnum { ...@@ -13,18 +13,23 @@ public enum PressurePumpRelateEnum {
ONE_HOUR_MINUTE("60", "60分钟"), ONE_HOUR_MINUTE("60", "60分钟"),
IOT_INDEX_VALUE_TRUE("true", "物联指标值:true"), IOT_INDEX_VALUE_TRUE("true", "物联指标值:true"),
IOT_INDEX_VALUE_FALSE("false", "物联指标值:false"), IOT_INDEX_VALUE_FALSE("false", "物联指标值:false"),
ONE_TIME("1", "物联指标最近1条数据"),
HALF_HOUR("0.5", "半小时"), HALF_HOUR("0.5", "半小时"),
ONE_HOUR("1.0", "1小时"), ONE_HOUR("1.0", "1小时"),
TWO_HOUR("2.0", "2小时"), TWO_HOUR("2.0", "2小时"),
FOUR_HOUR("4.0", "4小时"), FOUR_HOUR("4.0", "4小时"),
DAY_AVG("-3", "今日累计启停次数,取前3天平均值"),
CRON_BEFORE_DAY("-1", "昨天定时任务"),
START_FIVE("5", "稳压泵启动5分钟"), 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", "稳压泵启泵前分钟数"), PRESSURE_PUMP_START_BEFORE_MINUTE("-5", "稳压泵启泵前分钟数"),
PIPE_PRESSURE_NORMAL_STATUS("正常", "稳压泵管网压力正常状态"), PIPE_PRESSURE_NORMAL_STATUS("正常", "稳压泵管网压力正常状态"),
PIPE_PRESSURE_ABNORMAL_STATUS("异常", "稳压泵管网压力异常状态"), PIPE_PRESSURE_ABNORMAL_STATUS("异常", "稳压泵管网压力异常状态"),
START("1", "稳压泵启动"), START("1", "启动"),
STOP("0", "稳压泵停止"), STOP("0", "停止"),
RESET("2", "复位"),
CREATED_TIME("createdTime", "物联采集信号创建时间属性"), CREATED_TIME("createdTime", "物联采集信号创建时间属性"),
BIZ_ORG_TYPE_COMPANY("COMPANY", "bizOrgType之公司"),
UN_CLEAN_TIME("false", "未消除"); UN_CLEAN_TIME("false", "未消除");
private final String value; private final String value;
......
...@@ -23,12 +23,8 @@ import java.awt.image.BufferedImage; ...@@ -23,12 +23,8 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Base64;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.*;
import java.util.Set;
/** /**
* @author lisong * @author lisong
...@@ -76,6 +72,14 @@ public class ChartsUtils { ...@@ -76,6 +72,14 @@ public class ChartsUtils {
fis.close(); fis.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
return fileBytes; return fileBytes;
} }
......
package com.yeejoin.equipmanage.common.utils; package com.yeejoin.equipmanage.common.utils;
import java.io.File; import org.apache.poi.hssf.usermodel.*;
import java.io.FileInputStream; import org.apache.poi.ss.usermodel.*;
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.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFCell; import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow; import org.apache.poi.xssf.streaming.SXSSFRow;
...@@ -36,6 +9,12 @@ import org.apache.poi.xssf.streaming.SXSSFSheet; ...@@ -36,6 +9,12 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; 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 ...@@ -105,22 +84,16 @@ public class ExcelUtil
} }
return workbook; return workbook;
} }
public static void createXSSFExcel(String path, String fileName, List<String> headers, List<List<String>> dataList) { public static void createXSSFExcel(String path, String fileName, List<String> headers, List<List<String>> dataList) {
try { File file = new File(path + "\\" + fileName);
File file = new File(path); if (!file.isDirectory()) {
if (!file.isDirectory()) { file.mkdirs();
file.mkdirs(); }
} try (FileInputStream inputStream = new FileInputStream(file);
FileOutputStream out = new FileOutputStream(file);
file = new File(path + "\\" + fileName); XSSFWorkbook workbook = file.exists() ? new XSSFWorkbook(inputStream) : new XSSFWorkbook();
XSSFWorkbook workbook; SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(workbook, 2000)) {
if (!file.exists()) {
workbook = new XSSFWorkbook();
} else {
workbook = new XSSFWorkbook(new FileInputStream(file));
}
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(workbook, 2000);
int sheetNum = sxssfWorkbook.getNumberOfSheets(); int sheetNum = sxssfWorkbook.getNumberOfSheets();
if (sheetNum == 0) { if (sheetNum == 0) {
sxssfWorkbook.createSheet(); sxssfWorkbook.createSheet();
...@@ -150,16 +123,13 @@ public class ExcelUtil ...@@ -150,16 +123,13 @@ public class ExcelUtil
} }
fillExcelContent(sheet, sheet.getLastRowNum(), dataList); fillExcelContent(sheet, sheet.getLastRowNum(), dataList);
} }
FileOutputStream out = new FileOutputStream(file);
sxssfWorkbook.write(out); sxssfWorkbook.write(out);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void fillExcelContent(SXSSFSheet sheet, int lastRowNum, List<List<String>> dataList) { public static void fillExcelContent(SXSSFSheet sheet, int lastRowNum, List<List<String>> dataList) {
for (int i = 0; i < dataList.size(); i++) { for (int i = 0; i < dataList.size(); i++) {
SXSSFRow row = sheet.createRow(lastRowNum + i + 1); SXSSFRow row = sheet.createRow(lastRowNum + i + 1);
...@@ -217,14 +187,14 @@ public class ExcelUtil ...@@ -217,14 +187,14 @@ public class ExcelUtil
public static void exportXlSXExcel( public static void exportXlSXExcel(
HttpServletResponse response, File file, String fileName) 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"); String name = new String(fileName.getBytes("UTF-8"), "ISO8859_1");
OutputStream output = response.getOutputStream(); output = response.getOutputStream();
response.setHeader("Content-disposition", response.setHeader("Content-disposition",
"attachment; filename=" + name); "attachment; filename=" + name);
response.setContentType("application/vnd.ms-excel;charset=utf-8"); response.setContentType("application/vnd.ms-excel;charset=utf-8");
FileInputStream inputStream = new FileInputStream(file);
int b = 0; int b = 0;
byte[] buffer = new byte[1024*10]; byte[] buffer = new byte[1024*10];
while (b != -1){ while (b != -1){
...@@ -232,14 +202,21 @@ public class ExcelUtil ...@@ -232,14 +202,21 @@ public class ExcelUtil
if (-1 != b) { if (-1 != b) {
output.write(buffer, 0, b); output.write(buffer, 0, b);
} }
} }
inputStream.close();
output.flush(); output.flush();
output.close(); output.close();
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (output != null) {
output.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
...@@ -517,11 +494,17 @@ public class ExcelUtil ...@@ -517,11 +494,17 @@ public class ExcelUtil
cell.setCellStyle(style2); cell.setCellStyle(style2);
} }
} }
return workbook;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} finally {
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
return workbook;
} }
/** /**
......
...@@ -31,10 +31,19 @@ public class FileUtil { ...@@ -31,10 +31,19 @@ public class FileUtil {
if (!targetFile.exists()) { if (!targetFile.exists()) {
targetFile.mkdirs(); targetFile.mkdirs();
} }
FileOutputStream out = new FileOutputStream(filePath + fileName); FileOutputStream out = null;
out.write(file); try {
out.flush(); out = new FileOutputStream(filePath + fileName);
out.close(); 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 { ...@@ -34,8 +34,9 @@ public class TikaUtils {
public static String fileToTxt(File file) { public static String fileToTxt(File file) {
Parser parser = new AutoDetectParser(); Parser parser = new AutoDetectParser();
InputStream inputStream = null;
try { try {
InputStream inputStream = new FileInputStream(file); inputStream = new FileInputStream(file);
DefaultHandler handler = new BodyContentHandler(); DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext(); ParseContext parseContext = new ParseContext();
...@@ -49,6 +50,14 @@ public class TikaUtils { ...@@ -49,6 +50,14 @@ public class TikaUtils {
return handler.toString(); return handler.toString();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != inputStream) {
inputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return null; return null;
} }
...@@ -73,7 +82,7 @@ public class TikaUtils { ...@@ -73,7 +82,7 @@ public class TikaUtils {
} }
return null; return "";
} }
......
...@@ -202,6 +202,12 @@ public class WordTemplateUtils { ...@@ -202,6 +202,12 @@ public class WordTemplateUtils {
in.close(); in.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
BASE64Encoder encoder = new BASE64Encoder(); BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data); 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 { ...@@ -10,33 +10,14 @@ public class ImageText implements AbstractText {
public void createTxt(String inputFile, String outputFile) throws Exception { public void createTxt(String inputFile, String outputFile) throws Exception {
File file = new File(inputFile); File file = new File(inputFile);
String baseName = FilenameUtils.getBaseName(inputFile); String baseName = FilenameUtils.getBaseName(inputFile);
InputStream is = null; try (InputStream is = new FileInputStream(file);
OutputStream os = null; OutputStream os = new FileOutputStream(outputFile.substring(0, outputFile.length() - baseName.length() - 1) + ".txt")) {
try {
is = new FileInputStream(file);
os = new FileOutputStream(
outputFile.substring(0, outputFile.length() - baseName.length() - 1) + ".txt");
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int result = -1; int result = -1;
while (-1 != (result = is.read(buffer))) { while (-1 != (result = is.read(buffer))) {
os.write(buffer, 0, result); 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.*; ...@@ -18,6 +18,7 @@ import java.io.*;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.Channel; import java.nio.channels.Channel;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.Iterator; import java.util.Iterator;
import java.util.TreeSet; import java.util.TreeSet;
...@@ -39,11 +40,8 @@ public class FileHelper { ...@@ -39,11 +40,8 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isExcel2003(File file) { public static boolean isExcel2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
Workbook wb = null; Workbook wb = WorkbookFactory.create(is);) {
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
if (wb instanceof XSSFWorkbook) { if (wb instanceof XSSFWorkbook) {
return false; return false;
} else if (wb instanceof HSSFWorkbook) { } else if (wb instanceof HSSFWorkbook) {
...@@ -51,17 +49,6 @@ public class FileHelper { ...@@ -51,17 +49,6 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -71,39 +58,19 @@ public class FileHelper { ...@@ -71,39 +58,19 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isWord2003(File file) { public static boolean isWord2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
try { HWPFDocument hwpfDocument = new HWPFDocument(is);) {
is = new FileInputStream(file);
new HWPFDocument(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
public static boolean isWord2007(File file) { public static boolean isWord2007(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
try { XWPFDocument xwpfDocument = new XWPFDocument(is)) {
is = new FileInputStream(file);
new XWPFDocument(is).close();
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -113,24 +80,10 @@ public class FileHelper { ...@@ -113,24 +80,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isPpt2003(File file) { public static boolean isPpt2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
HSLFSlideShow ppt = null; HSLFSlideShow ppt = new HSLFSlideShow(is)) {
try {
is = new FileInputStream(file);
ppt = new HSLFSlideShow(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != ppt) {
ppt.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -141,13 +94,10 @@ public class FileHelper { ...@@ -141,13 +94,10 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path) { public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content); buffer.append(content);
...@@ -156,19 +106,7 @@ public class FileHelper { ...@@ -156,19 +106,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
} }
return buffer; return buffer;
} }
...@@ -181,13 +119,10 @@ public class FileHelper { ...@@ -181,13 +119,10 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path, String split) { public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content).append(split); buffer.append(content).append(split);
...@@ -196,19 +131,7 @@ public class FileHelper { ...@@ -196,19 +131,7 @@ public class FileHelper {
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
} }
return buffer; return buffer;
} }
...@@ -219,28 +142,15 @@ public class FileHelper { ...@@ -219,28 +142,15 @@ public class FileHelper {
* @param path 写入内容的文件路径 * @param path 写入内容的文件路径
*/ */
public static void writeFile(String content, String path) { public static void writeFile(String content, String path) {
OutputStream fos = null; File file = new File(path);
BufferedWriter bw = null; try (OutputStream fos = new FileOutputStream(file);
try { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8));) {
File file = new File(path);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content); bw.write(content);
} catch (FileNotFoundException fnfe) { } catch (IOException fnfe) {
fnfe.printStackTrace(); 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 { ...@@ -330,11 +240,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException { public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile); File htmFile = new File(inputFile);
// 以GB2312读取文件 // 以GB2312读取文件
BufferedReader br = null; try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = null; BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
String result = null; String result = null;
while (null != (result = br.readLine())) { while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) { if (!"".equals(result.trim())) {
...@@ -343,20 +250,7 @@ public class FileHelper { ...@@ -343,20 +250,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
} }
} }
/** /**
......
...@@ -34,18 +34,12 @@ public class TikaUtils { ...@@ -34,18 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) { public static String fileToTxt(File file) {
Parser parser = new AutoDetectParser(); Parser parser = new AutoDetectParser();
try { try (InputStream inputStream = new FileInputStream(file);) {
InputStream inputStream = new FileInputStream(file);
DefaultHandler handler = new BodyContentHandler(); DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext(); ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser); parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext); parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString(); return handler.toString();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -58,21 +52,13 @@ public class TikaUtils { ...@@ -58,21 +52,13 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler(); ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser(); AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
InputStream stream = null; try (InputStream stream = new FileInputStream(new File(fileName));) {
try {
stream = new FileInputStream(new File(fileName));
parser.parse(stream, handler, metadata); parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html"); FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html"); FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
} }
return null; return null;
} }
......
package com.yeejoin.precontrol.common.service.impl; package com.yeejoin.precontrol.common.service.impl;
import com.yeejoin.precontrol.common.service.PdfService; import com.yeejoin.precontrol.common.service.PdfService;
import com.yeejoin.precontrol.common.utils.ExtendedIOUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import sun.misc.BASE64Decoder; import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder; import sun.misc.BASE64Encoder;
...@@ -17,22 +16,16 @@ public class PdfServiceImpl implements PdfService { ...@@ -17,22 +16,16 @@ public class PdfServiceImpl implements PdfService {
@Override @Override
public void base64StringToPdf(String base64Content, String filePath) { public void base64StringToPdf(String base64Content, String filePath) {
BASE64Decoder decoder = new BASE64Decoder(); BASE64Decoder decoder = new BASE64Decoder();
BufferedInputStream bis = null; File file = new File(filePath);
FileOutputStream fos = null; try (ByteArrayInputStream byteInputStream = new ByteArrayInputStream(decoder.decodeBuffer(base64Content));
BufferedOutputStream bos = null; BufferedInputStream bis = new BufferedInputStream(byteInputStream);
FileOutputStream fos = new FileOutputStream(file);
try { BufferedOutputStream bos = new BufferedOutputStream(fos);
byte[] bytes = decoder.decodeBuffer(base64Content); ) {
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes);
bis = new BufferedInputStream(byteInputStream);
File file = new File(filePath);
File path = file.getParentFile(); File path = file.getParentFile();
if (!path.exists()) { if (!path.exists()) {
path.mkdirs(); path.mkdirs();
} }
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int length = bis.read(buffer); int length = bis.read(buffer);
while (length != -1) { while (length != -1) {
...@@ -42,26 +35,16 @@ public class PdfServiceImpl implements PdfService { ...@@ -42,26 +35,16 @@ public class PdfServiceImpl implements PdfService {
bos.flush(); bos.flush();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
ExtendedIOUtils.closeQuietly(bis);
ExtendedIOUtils.closeQuietly(fos);
ExtendedIOUtils.closeQuietly(bos);
} }
} }
@Override @Override
public String pdfToBase64(File file) { public String pdfToBase64(File file) {
BASE64Encoder encoder = new BASE64Encoder(); BASE64Encoder encoder = new BASE64Encoder();
FileInputStream fin = null; try (FileInputStream fin = new FileInputStream(file);
BufferedInputStream bin = null; BufferedInputStream bin = new BufferedInputStream(fin);
ByteArrayOutputStream baos = null; ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bout = null; BufferedOutputStream bout = new BufferedOutputStream(baos);) {
try {
fin = new FileInputStream(file);
bin = new BufferedInputStream(fin);
baos = new ByteArrayOutputStream();
bout = new BufferedOutputStream(baos);
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int len = bin.read(buffer); int len = bin.read(buffer);
while (len != -1) { while (len != -1) {
...@@ -72,18 +55,8 @@ public class PdfServiceImpl implements PdfService { ...@@ -72,18 +55,8 @@ public class PdfServiceImpl implements PdfService {
bout.flush(); bout.flush();
byte[] bytes = baos.toByteArray(); byte[] bytes = baos.toByteArray();
return encoder.encodeBuffer(bytes).trim(); return encoder.encodeBuffer(bytes).trim();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
fin.close();
bin.close();
bout.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
return null; return null;
} }
......
...@@ -20,6 +20,7 @@ import java.util.Optional; ...@@ -20,6 +20,7 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -837,9 +838,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -837,9 +838,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
public static List<String> getContent(String filePath) { public static List<String> getContent(String filePath) {
// 读取文件 // 读取文件
List<String> lineLists = null; List<String> lineLists = null;
try { try (Stream<String> lines = Files.lines(Paths.get(filePath), Charset.defaultCharset());) {
lineLists = Files.lines(Paths.get(filePath), Charset.defaultCharset()) lineLists = lines.flatMap(line -> Arrays.stream(line.split("\n"))).collect(Collectors.toList());
.flatMap(line -> Arrays.stream(line.split("\n"))).collect(Collectors.toList());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -32,6 +32,7 @@ import java.net.URLEncoder; ...@@ -32,6 +32,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.Channel; import java.nio.channels.Channel;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
...@@ -52,11 +53,8 @@ public class FileHelper { ...@@ -52,11 +53,8 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isExcel2003(File file) { public static boolean isExcel2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
Workbook wb = null; Workbook wb = WorkbookFactory.create(is);) {
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
if (wb instanceof XSSFWorkbook) { if (wb instanceof XSSFWorkbook) {
return false; return false;
} else if (wb instanceof HSSFWorkbook) { } else if (wb instanceof HSSFWorkbook) {
...@@ -64,17 +62,6 @@ public class FileHelper { ...@@ -64,17 +62,6 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -84,20 +71,10 @@ public class FileHelper { ...@@ -84,20 +71,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isWord2003(File file) { public static boolean isWord2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
try { HWPFDocument hwpfDocument = new HWPFDocument(is);) {
is = new FileInputStream(file);
new HWPFDocument(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -126,24 +103,10 @@ public class FileHelper { ...@@ -126,24 +103,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isPPT2003(File file) { public static boolean isPPT2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
HSLFSlideShow ppt = null; HSLFSlideShow ppt = new HSLFSlideShow(is);) {
try {
is = new FileInputStream(file);
ppt = new HSLFSlideShow(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != ppt) {
ppt.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -154,13 +117,10 @@ public class FileHelper { ...@@ -154,13 +117,10 @@ public class FileHelper {
*/ */
public static StringBuffer readLocalFile(String path) { public static StringBuffer readLocalFile(String path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is)); ) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content); buffer.append(content);
...@@ -169,17 +129,6 @@ public class FileHelper { ...@@ -169,17 +129,6 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
} }
return buffer; return buffer;
} }
...@@ -193,13 +142,10 @@ public class FileHelper { ...@@ -193,13 +142,10 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path, String split) { public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content).append(split); buffer.append(content).append(split);
...@@ -208,17 +154,6 @@ public class FileHelper { ...@@ -208,17 +154,6 @@ public class FileHelper {
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
} }
return buffer; return buffer;
} }
...@@ -230,28 +165,17 @@ public class FileHelper { ...@@ -230,28 +165,17 @@ public class FileHelper {
* @param path 写入内容的文件路径 * @param path 写入内容的文件路径
*/ */
public static void writeFile(String content, String path) { public static void writeFile(String content, String path) {
OutputStream fos = null; File file = new File(path);
BufferedWriter bw = null; try (OutputStream fos = new FileOutputStream(file);
try { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8)); ) {
File file = new File(path);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content); bw.write(content);
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
fnfe.printStackTrace(); fnfe.printStackTrace();
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
} }
} }
...@@ -335,11 +259,8 @@ public class FileHelper { ...@@ -335,11 +259,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException { public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile); File htmFile = new File(inputFile);
// 以GB2312读取文件 // 以GB2312读取文件
BufferedReader br = null; try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = null; BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
String result = null; String result = null;
while (null != (result = br.readLine())) { while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) { if (!"".equals(result.trim())) {
...@@ -348,16 +269,6 @@ public class FileHelper { ...@@ -348,16 +269,6 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
} }
} }
...@@ -1095,13 +1006,10 @@ public class FileHelper { ...@@ -1095,13 +1006,10 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path) { public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content); buffer.append(content);
...@@ -1110,19 +1018,7 @@ public class FileHelper { ...@@ -1110,19 +1018,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
} }
return buffer; return buffer;
} }
} }
...@@ -26,14 +26,16 @@ public class FileUtil { ...@@ -26,14 +26,16 @@ public class FileUtil {
* @return * @return
*/ */
public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception { public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception {
File targetFile = new File(filePath); try (FileOutputStream out = new FileOutputStream(filePath + fileName);) {
if (!targetFile.exists()) { File targetFile = new File(filePath);
targetFile.mkdirs(); 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 { ...@@ -25,29 +25,21 @@ public class HttpRequest {
conn.setConnectTimeout(30 * 1000); conn.setConnectTimeout(30 * 1000);
//防止屏蔽程序抓取而返回403错误 //防止屏蔽程序抓取而返回403错误
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); 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); File saveDir = new File(savePath);
if (!saveDir.exists()) { if (!saveDir.exists()) {
saveDir.mkdir(); saveDir.mkdir();
} }
File file = new File(saveDir + File.separator + fileName); File file = new File(saveDir + File.separator + fileName);
FileOutputStream fos = new FileOutputStream(file); try (FileOutputStream fos = new FileOutputStream(file);
fos.write(getData); //得到输入流
if (fos != null) { InputStream inputStream = conn.getInputStream();) {
fos.close(); //获取自己数组
} byte[] getData = readInputStream(inputStream);
if (inputStream != null) { fos.write(getData);
inputStream.close(); } catch (IOException e) {
e.printStackTrace();
} }
System.out.println("info:" + url + " download success");
return file; return file;
} }
......
...@@ -164,43 +164,42 @@ public class HttpUtils { ...@@ -164,43 +164,42 @@ public class HttpUtils {
NoSuchAlgorithmException, KeyStoreException, KeyManagementException { NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
Assert.hasText(url, "url invalid"); Assert.hasText(url, "url invalid");
String result; String result;
CloseableHttpClient httpClient; // 创建一个SSL信任所有证书的httpClient对象
if (url.startsWith(HTTPS)) { try ( CloseableHttpClient httpClient = url.startsWith(HTTPS) ? HttpUtils.createSslInsecureClient() : HttpClients.createDefault();) {
// 创建一个SSL信任所有证书的httpClient对象 CloseableHttpResponse response = null;
httpClient = HttpUtils.createSslInsecureClient(); HttpPost httpPost = getHttpPost(url);
} else { if (GlobalCache.header != null) {
httpClient = HttpClients.createDefault(); for (String key : GlobalCache.header.keySet()) {
} String value = GlobalCache.header.get(key);
CloseableHttpResponse response = null; httpPost.setHeader(key, value);
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"));
httpPost.setHeader("Http-Authorization", GlobalCache.paramMap.get("token")); if (GlobalCache.header.get("Content-Type") != null) {
if (GlobalCache.header.get("Content-Type") != null) { String contentType = GlobalCache.header.get("Content-Type");
String contentType = GlobalCache.header.get("Content-Type"); if ("application/x-www-form-urlencoded".equals(contentType)) {
if ("application/x-www-form-urlencoded".equals(contentType)) { JSONObject jsonObject = JSONObject.parseObject(jsonParams);
JSONObject jsonObject = JSONObject.parseObject(jsonParams); List<NameValuePair> params = new ArrayList<>();
List<NameValuePair> params = new ArrayList<>(); //循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理 if (jsonObject != null) {
if (jsonObject != null) { for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) { params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
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))); httpPost.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
} }
} else { return baseRequest(httpClient, httpPost);
httpPost.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING))); } catch (IOException e) {
e.printStackTrace();
} }
return baseRequest(httpClient, httpPost); return new ResponeVo();
} }
/** /**
...@@ -239,44 +238,43 @@ public class HttpUtils { ...@@ -239,44 +238,43 @@ public class HttpUtils {
public static ResponeVo put(String url, String jsonParams) throws IOException, NoSuchAlgorithmException, public static ResponeVo put(String url, String jsonParams) throws IOException, NoSuchAlgorithmException,
KeyStoreException, KeyManagementException { KeyStoreException, KeyManagementException {
log.info("----->调用请求 url:" + url + " ---->json参数:" + jsonParams); log.info("----->调用请求 url:" + url + " ---->json参数:" + jsonParams);
CloseableHttpClient httpClient = null;
String content; String content;
if (url.startsWith(HTTPS)) { // 创建一个SSL信任所有证书的httpClient对象
// 创建一个SSL信任所有证书的httpClient对象 try ( CloseableHttpClient httpClient = url.startsWith(HTTPS) ? HttpUtils.createSslInsecureClient() : HttpClients.createDefault();) {
httpClient = HttpUtils.createSslInsecureClient(); CloseableHttpResponse response = null;
} else { HttpPut httpPut = new HttpPut(url);
httpClient = HttpClients.createDefault(); if (GlobalCache.header != null) {
} for (String key : GlobalCache.header.keySet()) {
CloseableHttpResponse response = null; String value = GlobalCache.header.get(key);
HttpPut httpPut = new HttpPut(url); httpPut.setHeader(key, value);
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"));
httpPut.setHeader("Http-Authorization", GlobalCache.paramMap.get("token")); if (GlobalCache.header.get("Content-Type") != null) {
if (GlobalCache.header.get("Content-Type") != null) { String contentType = GlobalCache.header.get("Content-Type");
String contentType = GlobalCache.header.get("Content-Type"); if ("application/x-www-form-urlencoded".equals(contentType)) {
if ("application/x-www-form-urlencoded".equals(contentType)) { JSONObject jsonObject = JSONObject.parseObject(jsonParams);
JSONObject jsonObject = JSONObject.parseObject(jsonParams); List<NameValuePair> params = new ArrayList<>();
List<NameValuePair> params = new ArrayList<>(); //循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理 if (jsonObject != null) {
if (jsonObject != null) { for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) { params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
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)) { return baseRequest(httpClient, httpPut);
httpPut.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING))); } catch (IOException e) {
} e.printStackTrace();
} else {
log.error("请求头为空");
} }
return baseRequest(httpClient, httpPut); return new ResponeVo();
} }
/** /**
...@@ -434,16 +432,12 @@ public class HttpUtils { ...@@ -434,16 +432,12 @@ public class HttpUtils {
} }
public static void inputStreamToFile(InputStream ins, File file) { public static void inputStreamToFile(InputStream ins, File file) {
OutputStream os = null; try (OutputStream os = new FileOutputStream(file);) {
try {
os = new FileOutputStream(file);
int bytesRead = 0; int bytesRead = 0;
byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192];
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead); os.write(buffer, 0, bytesRead);
} }
os.close();
ins.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -33,18 +33,12 @@ public class TikaUtils { ...@@ -33,18 +33,12 @@ public class TikaUtils {
public static String fileToTxt(File file) { public static String fileToTxt(File file) {
Parser parser = new AutoDetectParser(); Parser parser = new AutoDetectParser();
try { try (InputStream inputStream = new FileInputStream(file);) {
InputStream inputStream = new FileInputStream(file);
DefaultHandler handler = new BodyContentHandler(); DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext(); ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser); parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext); parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString(); return handler.toString();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -57,16 +51,12 @@ public class TikaUtils { ...@@ -57,16 +51,12 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler(); ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser(); AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
InputStream stream = null; try (InputStream stream = new FileInputStream(new File(fileName))) {
try {
stream = new FileInputStream(new File(fileName));
parser.parse(stream, handler, metadata); parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html"); FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html"); FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
} }
return null; return null;
} }
......
...@@ -71,6 +71,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -71,6 +71,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -1132,21 +1133,18 @@ public class CommandController extends BaseController { ...@@ -1132,21 +1133,18 @@ public class CommandController extends BaseController {
} }
File htmlFile = new File(htmlFileName); File htmlFile = new File(htmlFileName);
WordConverterUtils.wordToHtml(fileName, htmlFileName, imagePathStr, readUrl, remoteSecurityService, product, appKey, token); WordConverterUtils.wordToHtml(fileName, htmlFileName, imagePathStr, readUrl, remoteSecurityService, product, appKey, token);
FileInputStream fis = new FileInputStream(htmlFile); try (FileInputStream fis = new FileInputStream(htmlFile);
// response.setContentType("multipart/form-data"); ServletOutputStream out = response.getOutputStream();) {
// response.setCharacterEncoding("UTF-8"); int b = 0;
// response.setContentType("text/html"); byte[] buffer = new byte[1024];
ServletOutputStream out; while ((b = fis.read(buffer)) != -1) {
out = response.getOutputStream(); // 4.写到输出流(out)中
int b = 0; out.write(buffer, 0, b);
byte[] buffer = new byte[1024]; }
while ((b = fis.read(buffer)) != -1) { out.flush();
// 4.写到输出流(out)中 } catch (IOException e) {
out.write(buffer, 0, b); e.printStackTrace();
} }
fis.close();
out.flush();
out.close();
return ResponseHelper.buildResponse(""); return ResponseHelper.buildResponse("");
} else { } else {
return null; return null;
......
...@@ -1278,6 +1278,15 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -1278,6 +1278,15 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
orgUsr.setAmosOrgId(user.getUserId()); orgUsr.setAmosOrgId(user.getUserId());
} }
saveOrgUsr(orgUsr, oldOrgUsr); saveOrgUsr(orgUsr, oldOrgUsr);
// 保存消防人员表数据
QueryWrapper<Firefighters> firefightersQueryWrapper = new QueryWrapper<>();
firefightersQueryWrapper.eq("orgUsrId", id);
Firefighters fire = firefightersService.getOne(firefightersQueryWrapper);
if(!ObjectUtils.isEmpty(fire)) {
fire.setName(orgUsr.getBizOrgName());
firefightersService.updateById(fire);
}
// 保存动态表单数据 // 保存动态表单数据
updateDynamicFormInstance(orgUsr.getSequenceNbr(), orgPersonDto.getDynamicFormValue()); updateDynamicFormInstance(orgUsr.getSequenceNbr(), orgPersonDto.getDynamicFormValue());
if (orgUsr.getBizOrgCode() != null) { if (orgUsr.getBizOrgCode() != null) {
......
package com.yeejoin.equipmanage.controller; package com.yeejoin.equipmanage.controller;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.dto.OrgMenuDto; 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.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto; 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 com.yeejoin.equipmanage.fegin.JcsFeign;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
...@@ -25,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -25,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; 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.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
...@@ -419,4 +429,14 @@ public class BuildingController extends AbstractBaseController { ...@@ -419,4 +429,14 @@ public class BuildingController extends AbstractBaseController {
return buildService.getBuildingTreeInMyOrgCodeList(reginParams.getPersonIdentity().getBizOrgCode()); 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 { ...@@ -48,7 +48,7 @@ public class ConfirmAlarmController extends AbstractBaseController {
@GetMapping(value = "/getDetailsById") @GetMapping(value = "/getDetailsById")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据id,type查询确警页面相关数据") @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); return iConfirmAlarmService.getDetailsById(alamId, equipId, type, area);
} }
......
...@@ -578,7 +578,7 @@ public class EmergencyController extends AbstractBaseController { ...@@ -578,7 +578,7 @@ public class EmergencyController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpStatusChart") @GetMapping(value = "/getPressurePumpStatusChart")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵启停状态图", notes = "四横八纵-稳压泵启停状态图") @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) { @RequestParam(required = false) String bizOrgCode) {
if(StringUtils.isEmpty(bizOrgCode)) { if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
...@@ -590,15 +590,14 @@ public class EmergencyController extends AbstractBaseController { ...@@ -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 @PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpDiagnosticAnalysis") @GetMapping(value = "/getPressurePumpDiagnosticAnalysis")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵诊断分析", notes = "四横八纵-稳压泵诊断分析") @ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵诊断分析", notes = "四横八纵-稳压泵诊断分析")
public ResponseModel getPressurePumpDiagnosticAnalysis(@RequestParam String equipmentCode, @RequestParam(required = false) String nameKeys, public ResponseModel getPressurePumpDiagnosticAnalysis(@RequestParam(required = false) String bizOrgCode) {
@RequestParam(required = false) String fieldKey, @RequestParam(required = false) String bizOrgCode) {
if(StringUtils.isEmpty(bizOrgCode)) { if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity(); ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
...@@ -609,7 +608,34 @@ public class EmergencyController extends AbstractBaseController { ...@@ -609,7 +608,34 @@ 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() {
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDay());
} }
@PersonIdentify @PersonIdentify
......
...@@ -377,7 +377,7 @@ public class EquipmentSpecificController extends AbstractBaseController { ...@@ -377,7 +377,7 @@ public class EquipmentSpecificController extends AbstractBaseController {
@GetMapping(value = "/{buildingId}/list") @GetMapping(value = "/{buildingId}/list")
@ApiOperation(httpMethod = "GET", value = "查询指定建筑下的装备列表", notes = "查询指定建筑下的装备列表") @ApiOperation(httpMethod = "GET", value = "查询指定建筑下的装备列表", notes = "查询指定建筑下的装备列表")
public List<EquiplistSpecificBySystemVO> getListByWarehouseStructureId( @PathVariable Long buildingId){ public List<EquiplistSpecificBySystemVO> getListByWarehouseStructureId( @PathVariable Long buildingId){
return equipmentSpecificMapper.getListByWarehouseStructureId(buildingId); return equipmentSpecificMapper.getListByWarehouseStructureId(buildingId, null);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
......
...@@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
public interface ConfirmAlarmMapper extends BaseMapper<EquipmentSpecificAlarm> { 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); int confirmAlam(EquipmentSpecificAlarmLog ent);
......
...@@ -228,7 +228,13 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -228,7 +228,13 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
Equipment getEquipmentBySpecificId(@Param("specificId") Long specificId); 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(); List<Map<String,String>> getStationInfo();
......
...@@ -216,4 +216,11 @@ public interface FormInstanceMapper extends BaseMapper<FormInstance> { ...@@ -216,4 +216,11 @@ public interface FormInstanceMapper extends BaseMapper<FormInstance> {
int updateFormFieldValue(@Param("id") Long id, @Param("name") String name, @Param("value") String value); int updateFormFieldValue(@Param("id") Long id, @Param("name") String name, @Param("value") String value);
Long queryVideoCountByBizOrgCode(@Param("bizOrgCode") String bizOrgCode); Long queryVideoCountByBizOrgCode(@Param("bizOrgCode") String bizOrgCode);
/**
* 建筑导入-导入楼层或房间 根据编码查询父级建筑id
* @param code
* @return
*/
String selectParentBuildId(@Param("code") String code);
} }
package com.yeejoin.equipmanage.mapper; package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.entity.OrgUsr; import com.yeejoin.equipmanage.common.entity.OrgUsr;
import java.util.List; import java.util.List;
import java.util.Map;
public interface OrgUsrMapper extends BaseMapper<OrgUsr> { public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
...@@ -11,4 +13,5 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -11,4 +13,5 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<OrgUsr> getCompanyTree(); List<OrgUsr> getCompanyTree();
List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map);
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.service; ...@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; 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.boot.biz.common.dto.OrgMenuDto;
import com.yeejoin.amos.feign.morphic.model.ResourceDTO; import com.yeejoin.amos.feign.morphic.model.ResourceDTO;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel; import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
...@@ -17,6 +18,7 @@ import com.yeejoin.equipmanage.common.entity.vo.PointTreeVo; ...@@ -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.BuildingTreeAndEquipVO;
import com.yeejoin.equipmanage.common.vo.BuildingTreeVo; import com.yeejoin.equipmanage.common.vo.BuildingTreeVo;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
...@@ -351,4 +353,10 @@ public interface IBuilldService extends IService<Building> { ...@@ -351,4 +353,10 @@ public interface IBuilldService extends IService<Building> {
List<OrgMenuDto> companyTreeByUserAndType(); List<OrgMenuDto> companyTreeByUserAndType();
List<BuildingTreeVo> treeByName(String bizOrgCode, String name); 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> { ...@@ -17,7 +17,7 @@ public interface IConfirmAlarmService extends IService<EquipmentSpecificAlarm> {
/** /**
* 根据id查询确警页面相关数据 * 根据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); Map<String ,Integer> videoList(List<String> list);
......
package com.yeejoin.equipmanage.service; package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -54,9 +55,20 @@ public interface IEmergencyService { ...@@ -54,9 +55,20 @@ public interface IEmergencyService {
Map<String, Integer> getStockEquipStatistics(); 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); 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();
/**
* 稳压泵启动统计
* @param startTime
* @param endTime
* @param bizOrgCode
* @return
*/
Map<String, Object> getPressurePumpStartStatistics(String startTime, String endTime, String bizOrgCode);
} }
package com.yeejoin.equipmanage.service; package com.yeejoin.equipmanage.service;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.vo.IotDataVO; import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -17,18 +19,20 @@ public interface IPressurePumpService { ...@@ -17,18 +19,20 @@ public interface IPressurePumpService {
* redis缓存物联采集数据,内部读取JSON配置指定有效期 * redis缓存物联采集数据,内部读取JSON配置指定有效期
* *
* @param iotDatalist * @param iotDatalist
* @param topic * @param iotCode
*/ */
void saveDataToRedis(List<IotDataVO> iotDatalist, String topic); void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode);
/** /**
* 根据nameKey,模糊查询所有的redis缓存数据 * 根据nameKey,模糊查询所有的redis缓存数据
*
* @param infoCode * @param infoCode
* @param nameKey * @param nameKey
* @param iotCode * @param iotCode
* @param bizOrgCode
* @return * @return
*/ */
List<IotDataVO> getDataToRedis(String infoCode, String nameKey, String iotCode); List<IotDataVO> getDataToRedis(String infoCode, String nameKey, String iotCode, String bizOrgCode);
/** /**
* 获取指标配置JSON信息集合 * 获取指标配置JSON信息集合
...@@ -38,39 +42,41 @@ public interface IPressurePumpService { ...@@ -38,39 +42,41 @@ public interface IPressurePumpService {
/** /**
* 获取所有稳压泵最近一次启停间隔,min * 获取所有稳压泵最近一次启停间隔,min
* @param redisDataList *
* @param iotDataList * @param dataList
* @param dataListFilterTrue
* @param dataListFilterFalse
* @param nowStrLong * @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 hour
* @param dataList
* @param dateNow * @param dateNow
*/ */
int getAllPressurePumpStartFrequency(double hour, Date dateNow); int getAllPressurePumpStartFrequency(double hour, List<IotDataVO> dataList, Date dateNow);
/** /**
* 获取稳压泵最近一次启停时长,min * 获取稳压泵最近一次启停时长,min
* @param redisDataList *
* @param iotDataList * @param dataList
* @param dataListFilterTrue
* @param dataListFilterFalse
* @param nowStrLong * @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 分钟,管网压力差绝对值 * 获取稳压泵指定启泵前 minutes 分钟,管网压力差绝对值
* @param redisDataList * @param dataList
* @param redisDataPipeList * @param dataPipeList
* @param iotDataList
* @param iotDataPipeList
* @param nowStrLong
* @param minutes * @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 * 根据指标,获取物联top数据,influxdb
...@@ -84,13 +90,15 @@ public interface IPressurePumpService { ...@@ -84,13 +90,15 @@ public interface IPressurePumpService {
/** /**
* 根据时间范围,获取redis指定指标或指定指标设备的缓存数据 * 根据时间范围,获取redis指定指标或指定指标设备的缓存数据
*
* @param infoCode * @param infoCode
* @param nameKey * @param nameKey
* @param iotCode * @param iotCode
* @param startDate * @param startDate
* @param endDate * @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物联数据集合 * 根据时间范围获取iot物联数据集合
...@@ -103,4 +111,71 @@ public interface IPressurePumpService { ...@@ -103,4 +111,71 @@ public interface IPressurePumpService {
*/ */
List<Map<String, String>> getIotCommonListData(String startTime, String endTime, String prefix, String suffix, String key, String fieldKey); 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);
/**
* 获取OrgUsr信息
* @param map
* @return
*/
List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map);
} }
...@@ -21,4 +21,6 @@ public interface ISupervisionVideoService extends IService<SupervisionVideo> { ...@@ -21,4 +21,6 @@ public interface ISupervisionVideoService extends IService<SupervisionVideo> {
List<String> queryVideoAllId(String bizOrgCode); List<String> queryVideoAllId(String bizOrgCode);
Page<Map<String, Object>> queryPumpInfo(Page page, String bizOrgCode); Page<Map<String, Object>> queryPumpInfo(Page page, String bizOrgCode);
List<Map<String, Object>> selectPressureDetails(String bizOrgCode);
} }
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto; import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto;
...@@ -14,16 +16,23 @@ import com.yeejoin.equipmanage.common.utils.DateUtils; ...@@ -14,16 +16,23 @@ import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.mapper.AnalysisReportLogMapper; import com.yeejoin.equipmanage.mapper.AnalysisReportLogMapper;
import com.yeejoin.equipmanage.mapper.AnalysisReportMonthMapper; import com.yeejoin.equipmanage.mapper.AnalysisReportMonthMapper;
import com.yeejoin.equipmanage.mapper.AnalysisReportSummaryMapper; import com.yeejoin.equipmanage.mapper.AnalysisReportSummaryMapper;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.IAnalysisReportLogService; import com.yeejoin.equipmanage.service.IAnalysisReportLogService;
import com.yeejoin.equipmanage.service.IFireFightingSystemService; import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import com.yeejoin.equipmanage.service.IUploadFileService; import com.yeejoin.equipmanage.service.IUploadFileService;
import liquibase.pro.packaged.A; import liquibase.pro.packaged.A;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 报告流水表 服务实现类 * 报告流水表 服务实现类
...@@ -48,6 +57,12 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM ...@@ -48,6 +57,12 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
@Autowired @Autowired
IUploadFileService iUploadFileService; IUploadFileService iUploadFileService;
@Autowired
FireFightingSystemMapper fireFightingSystemMapper;
@Value("classpath:/json/systemIndex.json")
private Resource systemIndex;
@Override @Override
public IPage<AnalysisReportLog> listPage(Page page, AnalysisReportLog analysisReportLog) { public IPage<AnalysisReportLog> listPage(Page page, AnalysisReportLog analysisReportLog) {
...@@ -74,15 +89,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM ...@@ -74,15 +89,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
this.saveAnalysisReportLog(reportEnum, beginDate, endDate); this.saveAnalysisReportLog(reportEnum, beginDate, endDate);
// 创建月分析统计报告数据 // 创建月分析统计报告数据
// 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔 // 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔
List<FireFightingSystemEntity> fightingSystemEntityList = fireFightingSystemService.getBaseMapper().selectList( List<Map<String, Object>> list = fireFightingSystemMapper.selectSystemByBizOrgCode(null);
new LambdaQueryWrapper<FireFightingSystemEntity>()
.isNotNull(FireFightingSystemEntity::getAnalysisIndexKey));
// 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary // 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary
String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN); String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN);
String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN); String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN);
fightingSystemEntityList.forEach(f -> { String json = null;
analysisReportMonthMapper.insertSystemMonthData(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId()); try {
analysisReportSummaryMapper.insertSystemMonthSummaryData(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId()); 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 ...@@ -93,15 +120,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
this.saveAnalysisReportLog(reportEnum, beginDate, endDate); this.saveAnalysisReportLog(reportEnum, beginDate, endDate);
// 创建月分析统计报告数据 // 创建月分析统计报告数据
// 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔 // 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔
List<FireFightingSystemEntity> fightingSystemEntityList = fireFightingSystemService.getBaseMapper().selectList( List<Map<String, Object>> list = fireFightingSystemMapper.selectSystemByBizOrgCode(null);
new LambdaQueryWrapper<FireFightingSystemEntity>()
.isNotNull(FireFightingSystemEntity::getAnalysisIndexKey));
// 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary // 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary
String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN); String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN);
String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN); String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN);
fightingSystemEntityList.forEach(f -> { String json = null;
analysisReportMonthMapper.insertSystemMonthDataTest(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId(),now,num); try {
analysisReportSummaryMapper.insertSystemMonthSummaryDataTest(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId(),now,num); 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; ...@@ -8,6 +8,7 @@ import com.yeejoin.equipmanage.common.vo.SpeedAndTimeList;
import com.yeejoin.equipmanage.service.ICarLonAndLatDataService; import com.yeejoin.equipmanage.service.ICarLonAndLatDataService;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
...@@ -28,30 +29,37 @@ public class CarLonAndLatDataServiceImpl implements ICarLonAndLatDataService { ...@@ -28,30 +29,37 @@ public class CarLonAndLatDataServiceImpl implements ICarLonAndLatDataService {
@Override @Override
public List<LonAndLatEntityVo> listCarLonAndLat() throws Exception { public List<LonAndLatEntityVo> listCarLonAndLat() throws Exception {
Resource resource = new ClassPathResource("car-history-track-data.xml"); Resource resource = new ClassPathResource("car-history-track-data.xml");
BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream())); try (InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());
StringBuffer buffer = new StringBuffer(); BufferedReader br = new BufferedReader(inputStreamReader);) {
String line = ""; StringBuffer buffer = new StringBuffer();
while((line = br.readLine())!=null) String line = "";
{ while((line = br.readLine())!=null)
buffer.append(line); {
buffer.append(line);
}
LonAndLatList list = (LonAndLatList) XmlBuilder.xmlStrToObject(LonAndLatList.class, buffer.toString());
return list.getDataList();
} catch (Exception e) {
e.printStackTrace();
} }
br.close(); return new ArrayList<>();
LonAndLatList list = (LonAndLatList) XmlBuilder.xmlStrToObject(LonAndLatList.class, buffer.toString());
return list.getDataList();
} }
@Override @Override
public List<SpeedAndTimeEntityVo> listCarSpeedAndGround() throws Exception { public List<SpeedAndTimeEntityVo> listCarSpeedAndGround() throws Exception {
Resource resource = new ClassPathResource("car-history-trend-data.xml"); Resource resource = new ClassPathResource("car-history-trend-data.xml");
BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream())); try (InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());
StringBuffer buffer = new StringBuffer(); BufferedReader br = new BufferedReader(inputStreamReader);) {
String line = ""; StringBuffer buffer = new StringBuffer();
while((line = br.readLine())!=null) String line = "";
{ while ((line = br.readLine()) != null) {
buffer.append(line); buffer.append(line);
}
SpeedAndTimeList list = (SpeedAndTimeList) XmlBuilder.xmlStrToObject(SpeedAndTimeList.class, buffer.toString());
return list.getDataList();
} catch (Exception e) {
e.printStackTrace();
} }
br.close(); return new ArrayList<>();
SpeedAndTimeList list = (SpeedAndTimeList) XmlBuilder.xmlStrToObject(SpeedAndTimeList.class, buffer.toString());
return list.getDataList();
} }
} }
...@@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
import org.gavaghan.geodesy.Ellipsoid; import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator; import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GlobalCoordinates; import org.gavaghan.geodesy.GlobalCoordinates;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
...@@ -486,12 +487,13 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -486,12 +487,13 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
stockDetailMapper.updateById(stockDetail); stockDetailMapper.updateById(stockDetail);
addStockDetailId(stockDetail.getId()); addStockDetailId(stockDetail.getId());
StockDetail stockDetail_clone = stockDetail.clone(); StockDetail stockDetailClone = new StockDetail();
stockDetail_clone.setId(null); BeanUtils.copyProperties(stockDetail, stockDetailClone);
stockDetail_clone.setAmount(lossCount); stockDetailClone.setId(null);
stockDetail_clone.setStatus(EquipStatusEnum.LOSS.getCode().toString()); stockDetailClone.setAmount(lossCount);
stockDetailMapper.insert(stockDetail_clone); stockDetailClone.setStatus(EquipStatusEnum.LOSS.getCode().toString());
addStockDetailId(stockDetail_clone.getId()); stockDetailMapper.insert(stockDetailClone);
addStockDetailId(stockDetailClone.getId());
Stock stock = stockMapper.selectById(stockDetail.getStockId()); Stock stock = stockMapper.selectById(stockDetail.getStockId());
stock.setAmount(stock.getAmount() - lossCount); stock.setAmount(stock.getAmount() - lossCount);
stockMapper.updateById(stock); stockMapper.updateById(stock);
...@@ -501,10 +503,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -501,10 +503,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
// 损耗清单详情 // 损耗清单详情
WastageBillDetail detail = new WastageBillDetail(); WastageBillDetail detail = new WastageBillDetail();
detail.setAmount(BigDecimal.valueOf(lossCount)); detail.setAmount(BigDecimal.valueOf(lossCount));
detail.setStockDetailId(stockDetail_clone.getId()); detail.setStockDetailId(stockDetailClone.getId());
detail.setWastageBillId(bill.getId()); detail.setWastageBillId(bill.getId());
wastageBillDetailMapper.insert(detail); wastageBillDetailMapper.insert(detail);
journalMapper.insert(createJournal(ex, stockDetail_clone.getId(), lossCount)); journalMapper.insert(createJournal(ex, stockDetailClone.getId(), lossCount));
return 0d; return 0d;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -604,7 +606,7 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -604,7 +606,7 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
List<SystemDic> listd = systemDicMapper.selectByMap(columnMap); List<SystemDic> listd = systemDicMapper.selectByMap(columnMap);
p.setLossStateId(listd.get(0).getId()); 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 ...@@ -624,21 +626,21 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
stockDetailMapper.updateById(detail); stockDetailMapper.updateById(detail);
params.addStockDetailId(r.getStockDetailId()); params.addStockDetailId(r.getStockDetailId());
StockDetail detail_onCar = null; StockDetail detailOnCar = new StockDetail();
BeanUtils.copyProperties(detail, detailOnCar);
// 新增车载记录 // 新增车载记录
detail_onCar = detail.clone(); // detail_onCar = detail.clone();
detail_onCar.setId(null); detailOnCar.setId(null);
detail_onCar.setAmount(r.getAmount()); detailOnCar.setAmount(r.getAmount());
detail_onCar.setStatus(EquipStatusEnum.ONCAR.getCode().toString()); detailOnCar.setStatus(EquipStatusEnum.ONCAR.getCode().toString());
stockDetailMapper.insert(detail_onCar); stockDetailMapper.insert(detailOnCar);
params.addStockDetailId(detail_onCar.getId()); 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) { } catch (Exception e) {
......
...@@ -133,11 +133,11 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ ...@@ -133,11 +133,11 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
private SourceSceneMapper sourceSceneMapper; private SourceSceneMapper sourceSceneMapper;
@Override @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"; final String videoType = "video";
Map<String, Object> res = new HashMap<>(); Map<String, Object> res = new HashMap<>();
if (videoType.equals(type)) { if (videoType.equals(type)) {
List<AlamVideoVO> video = videoMapper.getVideoBySpeId(equipId); List<AlamVideoVO> video = videoMapper.getVideoBySpeId(Long.valueOf(equipId));
video.forEach(action -> { video.forEach(action -> {
action.setVedioFormat(vedioFormat); action.setVedioFormat(vedioFormat);
action.setUrl(videoService.getVideoUrl(action.getName(), action.getPresetPosition(), action.getUrl(), action.getCode())); action.setUrl(videoService.getVideoUrl(action.getName(), action.getPresetPosition(), action.getUrl(), action.getCode()));
...@@ -153,7 +153,7 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ ...@@ -153,7 +153,7 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
} }
List<AlamVideoVO> videoBySpeId; List<AlamVideoVO> videoBySpeId;
if (specificAlarm == null) { if (specificAlarm == null) {
videoBySpeId = videoMapper.getVideoBySpeId(equipId); videoBySpeId = videoMapper.getVideoBySpeId(Long.valueOf(equipId));
} else { } else {
videoBySpeId = videoMapper.getVideoBySpeId(specificAlarm.getEquipmentSpecificId()); videoBySpeId = videoMapper.getVideoBySpeId(specificAlarm.getEquipmentSpecificId());
} }
...@@ -449,7 +449,7 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ ...@@ -449,7 +449,7 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
// Token serverToken = remoteSecurityService.getServerToken(); // Token serverToken = remoteSecurityService.getServerToken();
IotSystemAlarmRo confirmAlamVo = new IotSystemAlarmRo(); IotSystemAlarmRo confirmAlamVo = new IotSystemAlarmRo();
confirmAlamVo.setId(ent.getId()); confirmAlamVo.setId(ent.getId());
ent = confirmAlarmMapper.getDetailsById(ent.getId(), null); ent = confirmAlarmMapper.getDetailsById(String.valueOf(ent.getId()), null);
EquipmentSpecific equipmentSpecific = equipmentSpecificSerivce.getById(ent.getEquipmentSpecificId()); EquipmentSpecific equipmentSpecific = equipmentSpecificSerivce.getById(ent.getEquipmentSpecificId());
List<FormInstance> formInstances = new ArrayList<>(); List<FormInstance> formInstances = new ArrayList<>();
......
...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil; import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.MessageModel; import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFireAlarm; import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFireAlarm;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto; import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
...@@ -592,7 +593,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec ...@@ -592,7 +593,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
} }
private List<AlarmDataVO> getProcessInfo(Long id) { 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<>(); List<AlarmDataVO> lists = new ArrayList<>();
AlarmDataVO v1 = new AlarmDataVO(); AlarmDataVO v1 = new AlarmDataVO();
...@@ -905,9 +906,10 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec ...@@ -905,9 +906,10 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
// Map<String, String> ext = new HashMap<>(); // Map<String, String> ext = new HashMap<>();
// ext.put("isRead", "1"); // ext.put("isRead", "1");
// model.setExtras(ext); // model.setExtras(ext);
Token token = remoteSecurityService.getServerToken(); // Token token = remoteSecurityService.getServerToken();
// systemctlFeign.create(token.getAppKey(), token.getProduct(), token.getToke(), model); // systemctlFeign.create(token.getAppKey(), token.getProduct(), token.getToke(), model);
systemctlFeign.updateIsRead(Long.valueOf(messageId)); // systemctlFeign.updateIsRead(Long.valueOf(messageId));
// Systemctl.messageClient.updateIsRead(Long.valueOf(messageId));
mqttSendGateway.sendToMqtt("pressurePump", "1"); mqttSendGateway.sendToMqtt("pressurePump", "1");
return i; return i;
} }
......
...@@ -408,16 +408,14 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService { ...@@ -408,16 +408,14 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService {
public static byte[] file2byte(File file) public static byte[] file2byte(File file)
{ {
try { try (FileInputStream in =new FileInputStream(file);) {
FileInputStream in =new FileInputStream(file);
//当文件没有结束时,每次读取一个字节显示 //当文件没有结束时,每次读取一个字节显示
byte[] data=new byte[in.available()]; byte[] data = new byte[in.available()];
in.read(data); in.read(data);
in.close();
return data; return data;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return new byte[0];
} }
} }
......
...@@ -280,16 +280,14 @@ public class FireAutoSysManageReportServiceImpl implements IFireAutoSysManageRep ...@@ -280,16 +280,14 @@ public class FireAutoSysManageReportServiceImpl implements IFireAutoSysManageRep
} }
public static byte[] file2byte(File file) { public static byte[] file2byte(File file) {
try { try (FileInputStream in = new FileInputStream(file);) {
FileInputStream in = new FileInputStream(file);
//当文件没有结束时,每次读取一个字节显示 //当文件没有结束时,每次读取一个字节显示
byte[] data = new byte[in.available()]; byte[] data = new byte[in.available()];
in.read(data); in.read(data);
in.close();
return data; return data;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return new byte[0];
} }
} }
} }
...@@ -1072,7 +1072,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -1072,7 +1072,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
public Map<String, Object> integrationPageSysData(String systemCode, Boolean isUpdate) { public Map<String, Object> integrationPageSysData(String systemCode, Boolean isUpdate) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
if (!StringUtil.isNotEmpty(SystemTypeEnum.getEnum(systemCode))) { if (!StringUtil.isNotEmpty(SystemTypeEnum.getEnum(systemCode))) {
return null; return Collections.emptyMap();
} }
Map<String, Object> data; Map<String, Object> data;
if (isUpdate) { if (isUpdate) {
...@@ -1088,7 +1088,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -1088,7 +1088,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
if (!ObjectUtils.isEmpty(data)) { if (!ObjectUtils.isEmpty(data)) {
mqttSendGateway.sendToMqtt(String.format("%s%s", "INTEGRATE_TOPIC/", systemCode), JSON.toJSONString(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) { public Map<String, Object> saveIntegrationPageSysData(String systemCode) {
...@@ -1682,11 +1682,9 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -1682,11 +1682,9 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
} }
private static byte[] file2byte(File file) { private static byte[] file2byte(File file) {
try { try (FileInputStream in = new FileInputStream(file);) {
FileInputStream in = new FileInputStream(file);
byte[] data = new byte[in.available()]; byte[] data = new byte[in.available()];
in.read(data); in.read(data);
in.close();
return data; return data;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -316,9 +316,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -316,9 +316,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
log.info(String.format("发送eqm转kafka消息失败:%s", e.getMessage())); log.info(String.format("发送eqm转kafka消息失败:%s", e.getMessage()));
} }
// redis缓存指定指标、指定时长物联数据
pressurePumpService.saveDataToRedis(iotDatalist, topic);
if (!StringUtils.isEmpty(traceId)) { if (!StringUtils.isEmpty(traceId)) {
String finalTraceId = traceId; String finalTraceId = traceId;
List<IotDataVO> collect = iotDatalist.stream().map(x -> { List<IotDataVO> collect = iotDatalist.stream().map(x -> {
...@@ -339,7 +336,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -339,7 +336,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
*/ */
public void realTimeDateProcessing(TopicEntityVo topicEntity, List<IotDataVO> iotDatalist,EquipmentSpecificVo vo) { public void realTimeDateProcessing(TopicEntityVo topicEntity, List<IotDataVO> iotDatalist,EquipmentSpecificVo vo) {
String iotCode = topicEntity.getIotCode(); String iotCode = topicEntity.getIotCode();
if (EquipAndCarEnum.equip.type.equals(topicEntity.getType())) { if (EquipAndCarEnum.equip.type.equals(topicEntity.getType())) {
List<EquipmentSpecificIndex> indexList = equipmentSpecificIndexService List<EquipmentSpecificIndex> indexList = equipmentSpecificIndexService
.getEquipmentSpeIndexBySpeIotCode(iotCode); .getEquipmentSpeIndexBySpeIotCode(iotCode);
...@@ -347,6 +343,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -347,6 +343,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
return; return;
} }
equipRealTimeDate(iotDatalist, indexList, topicEntity,vo); equipRealTimeDate(iotDatalist, indexList, topicEntity,vo);
String bizOrgCode = indexList.get(0).getBizOrgCode();
// redis缓存指定指标、指定时长物联数据
pressurePumpService.saveDataToRedis(iotDatalist, iotCode, bizOrgCode);
} else { } else {
List<CarProperty> carProperties = carPropertyService.getCarPropListByIotCode(iotCode); List<CarProperty> carProperties = carPropertyService.getCarPropListByIotCode(iotCode);
if (ObjectUtils.isEmpty(carProperties)) { if (ObjectUtils.isEmpty(carProperties)) {
...@@ -354,7 +353,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -354,7 +353,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} }
carRealTimeDate(iotDatalist, carProperties,topicEntity); carRealTimeDate(iotDatalist, carProperties,topicEntity);
} }
} }
/** /**
...@@ -1522,7 +1520,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1522,7 +1520,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
EquipmentSpecificIndex data = getPressurePumpDateByType(indexKey,valueEnum, topicEntity, equipmentSpeIndexList, pressurePumpEnum); EquipmentSpecificIndex data = getPressurePumpDateByType(indexKey,valueEnum, topicEntity, equipmentSpeIndexList, pressurePumpEnum);
Date newDate = new Date(); Date newDate = new Date();
// 2. 校验 // 2. 校验
if (!ObjectUtils.isEmpty(data)) { if (!ObjectUtils.isEmpty(data.getUpdateDate())) {
checkValueByDate(data, newDate, pressurePumpEnum); checkValueByDate(data, newDate, pressurePumpEnum);
} }
}); });
...@@ -1532,7 +1530,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1532,7 +1530,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private EquipmentSpecificIndex getPressurePumpDateByType(String indexKey, PressurePumpValueEnum valueEnum, TopicEntityVo topicEntity, List<EquipmentSpecificIndex> equipmentSpeIndexList, PressurePumpEnum pressurePumpEnum) { private EquipmentSpecificIndex getPressurePumpDateByType(String indexKey, PressurePumpValueEnum valueEnum, TopicEntityVo topicEntity, List<EquipmentSpecificIndex> equipmentSpeIndexList, PressurePumpEnum pressurePumpEnum) {
String iotCode = topicEntity.getIotCode(); String iotCode = topicEntity.getIotCode();
EquipmentSpecificIndex equipmentSpecificIndex = null; EquipmentSpecificIndex equipmentSpecificIndex = new EquipmentSpecificIndex();
String prefix = null; String prefix = null;
String suffix = null; String suffix = null;
if (iotCode.length() > 8) { if (iotCode.length() > 8) {
...@@ -1549,7 +1547,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1549,7 +1547,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
StringUtil.isNotEmpty(e.getValue()) && e.getIotCode().equals(iotCode) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) StringUtil.isNotEmpty(e.getValue()) && e.getIotCode().equals(iotCode) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(lastStop)) { if (!CollectionUtils.isEmpty(lastStop)) {
getIotDate(equipmentSpecificIndex, lastStop, prefix, suffix , "false"); equipmentSpecificIndex = getIotDate(equipmentSpecificIndex, lastStop, prefix, suffix , "false");
} }
break; break;
case LAST_START: case LAST_START:
...@@ -1563,7 +1561,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1563,7 +1561,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
StringUtil.isNotEmpty(e.getValue()) && e.getIotCode().equals(iotCode) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) StringUtil.isNotEmpty(e.getValue()) && e.getIotCode().equals(iotCode) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(lastStart)) { if (!CollectionUtils.isEmpty(lastStart)) {
getIotDate(equipmentSpecificIndex, lastStart, prefix, suffix, "true"); equipmentSpecificIndex = getIotDate(equipmentSpecificIndex, lastStart, prefix, suffix, "true");
} }
break; break;
case LATELY_STOP: case LATELY_STOP:
...@@ -1571,7 +1569,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1571,7 +1569,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
StringUtil.isNotEmpty(e.getValue()) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) StringUtil.isNotEmpty(e.getValue()) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(latelyStop)) { if (!CollectionUtils.isEmpty(latelyStop)) {
getIotDate(equipmentSpecificIndex, latelyStop, prefix, null, "false"); equipmentSpecificIndex = getIotDate(equipmentSpecificIndex, latelyStop, prefix, null, "false");
} }
break; break;
case LATELY_START: case LATELY_START:
...@@ -1579,7 +1577,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1579,7 +1577,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
StringUtil.isNotEmpty(e.getValue()) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) StringUtil.isNotEmpty(e.getValue()) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(latelyStart)) { if (!CollectionUtils.isEmpty(latelyStart)) {
getIotDate(equipmentSpecificIndex, latelyStart, prefix, null, "true"); equipmentSpecificIndex = getIotDate(equipmentSpecificIndex, latelyStart, prefix, null, "true");
} }
break; break;
case PUMP_START_TIME: case PUMP_START_TIME:
...@@ -1592,7 +1590,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1592,7 +1590,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} }
private void getIotDate(EquipmentSpecificIndex equipmentSpecificIndex, List<EquipmentSpecificIndex> listData, String prefix, String suffix, String flag) { private EquipmentSpecificIndex getIotDate(EquipmentSpecificIndex equipmentSpecificIndex, List<EquipmentSpecificIndex> listData, String prefix, String suffix, String flag) {
ResponseModel start = iotFeign.selectOne(remoteSecurityService.getServerToken().getAppKey(), remoteSecurityService.getServerToken().getProduct(), remoteSecurityService.getServerToken().getToke(), "1", prefix, suffix, flag, pressurePumpStart); ResponseModel start = iotFeign.selectOne(remoteSecurityService.getServerToken().getAppKey(), remoteSecurityService.getServerToken().getProduct(), remoteSecurityService.getServerToken().getToke(), "1", prefix, suffix, flag, pressurePumpStart);
if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) { if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) {
String json1 = JSON.toJSONString(start.getResult()); String json1 = JSON.toJSONString(start.getResult());
...@@ -1602,8 +1600,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1602,8 +1600,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
String startTime = collect.get(0).get("time").substring(0, 19).replace("T", " "); String startTime = collect.get(0).get("time").substring(0, 19).replace("T", " ");
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8); Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8);
listData.get(0).setUpdateDate(startDate); listData.get(0).setUpdateDate(startDate);
equipmentSpecificIndex = listData.get(0); BeanUtils.copyProperties(listData.get(0),equipmentSpecificIndex);
} }
return equipmentSpecificIndex;
} }
private void checkValueByDate(EquipmentSpecificIndex data, Date newDate, PressurePumpEnum pressurePumpEnum) { private void checkValueByDate(EquipmentSpecificIndex data, Date newDate, PressurePumpEnum pressurePumpEnum) {
......
...@@ -7,10 +7,12 @@ import java.io.FileOutputStream; ...@@ -7,10 +7,12 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -150,9 +152,9 @@ public class FileController extends AbstractBaseController { ...@@ -150,9 +152,9 @@ public class FileController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/download/**", method = RequestMethod.GET) @RequestMapping(value = "/download/**", method = RequestMethod.GET)
public void download(HttpServletResponse response, HttpServletRequest request) throws Exception { public void download(HttpServletResponse response, HttpServletRequest request) throws Exception {
try { try (FileInputStream inputStream = new FileInputStream(fileUploadDir + request.getServletPath().substring(15));
String path = request.getServletPath().substring(15); ServletOutputStream outputStream = response.getOutputStream();) {
IOUtils.copy(new FileInputStream(fileUploadDir + path), response.getOutputStream()); IOUtils.copy(inputStream, outputStream);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
ResponseUtils.renderText(response, "File not exists!"); ResponseUtils.renderText(response, "File not exists!");
...@@ -253,12 +255,9 @@ public class FileController extends AbstractBaseController { ...@@ -253,12 +255,9 @@ public class FileController extends AbstractBaseController {
} }
String htmlContent = (String) processData.get("html"); String htmlContent = (String) processData.get("html");
try { try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), StandardCharsets.UTF_8));) {
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), "UTF-8"));
writer.write(htmlContent); writer.write(htmlContent);
writer.flush(); writer.flush();
writer.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -51,8 +51,6 @@ public class PlanVisual3dController extends AbstractBaseController { ...@@ -51,8 +51,6 @@ public class PlanVisual3dController extends AbstractBaseController {
@Autowired @Autowired
HttpServletResponse response; HttpServletResponse response;
@Autowired
HttpServletRequest request;
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "预案应用树", notes = "预案应用树") @ApiOperation(value = "预案应用树", notes = "预案应用树")
...@@ -76,7 +74,7 @@ public class PlanVisual3dController extends AbstractBaseController { ...@@ -76,7 +74,7 @@ public class PlanVisual3dController extends AbstractBaseController {
if (testPlan != null) { if (testPlan != null) {
String path = testPlan.getFilePath(); String path = testPlan.getFilePath();
if (path != null && !"".equals(path)) { if (path != null && !"".equals(path)) {
try { try (InputStream fis = new BufferedInputStream(new FileInputStream(fileUploadDir + path));) {
// path是指欲下载的文件的路径。 // path是指欲下载的文件的路径。
File file = new File(fileUploadDir + path); File file = new File(fileUploadDir + path);
if (file.exists()) { if (file.exists()) {
...@@ -84,12 +82,9 @@ public class PlanVisual3dController extends AbstractBaseController { ...@@ -84,12 +82,9 @@ public class PlanVisual3dController extends AbstractBaseController {
String filename = file.getName(); String filename = file.getName();
// 取得文件的后缀名。 // 取得文件的后缀名。
String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase(); String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase();
// 以流的形式下载文件。 // 以流的形式下载文件。
InputStream fis = new BufferedInputStream(new FileInputStream(fileUploadDir + path));
byte[] buffer = new byte[fis.available()]; byte[] buffer = new byte[fis.available()];
fis.read(buffer); fis.read(buffer);
fis.close();
// 清空response // 清空response
// response.reset(); // response.reset();
// 设置response的Header // 设置response的Header
......
...@@ -883,7 +883,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -883,7 +883,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
public void run() { public void run() {
boolean isRunning = true; boolean isRunning = true;
int k = 0;
while (isRunning) { while (isRunning) {
k++;
isRunning = k < Integer.MAX_VALUE;
AlarmParam deviceData = null; AlarmParam deviceData = null;
try { try {
deviceData = blockingQueue.take(); deviceData = blockingQueue.take();
......
...@@ -83,11 +83,8 @@ public class FileHelper { ...@@ -83,11 +83,8 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isExcel2003(File file) { public static boolean isExcel2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
Workbook wb = null; Workbook wb = WorkbookFactory.create(is);) {
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
if (wb instanceof XSSFWorkbook) { if (wb instanceof XSSFWorkbook) {
return false; return false;
} else if (wb instanceof HSSFWorkbook) { } else if (wb instanceof HSSFWorkbook) {
...@@ -95,17 +92,6 @@ public class FileHelper { ...@@ -95,17 +92,6 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -187,13 +173,10 @@ public class FileHelper { ...@@ -187,13 +173,10 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path) { public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content); buffer.append(content);
...@@ -202,19 +185,7 @@ public class FileHelper { ...@@ -202,19 +185,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
} }
return buffer; return buffer;
} }
...@@ -227,13 +198,10 @@ public class FileHelper { ...@@ -227,13 +198,10 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path, String split) { public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content).append(split); buffer.append(content).append(split);
...@@ -242,19 +210,7 @@ public class FileHelper { ...@@ -242,19 +210,7 @@ public class FileHelper {
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
} }
return buffer; return buffer;
} }
...@@ -265,28 +221,15 @@ public class FileHelper { ...@@ -265,28 +221,15 @@ public class FileHelper {
* @param path 写入内容的文件路径 * @param path 写入内容的文件路径
*/ */
public static void writeFile(String content, String path) { public static void writeFile(String content, String path) {
OutputStream fos = null; File file = new File(path);
BufferedWriter bw = null; try (OutputStream fos = new FileOutputStream(file);
try { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8));) {
File file = new File(path);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content); bw.write(content);
} catch (FileNotFoundException fnfe) { } catch (IOException fnfe) {
fnfe.printStackTrace(); 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 { ...@@ -375,11 +318,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException { public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile); File htmFile = new File(inputFile);
// 以GB2312读取文件 // 以GB2312读取文件
BufferedReader br = null; try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = null; BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
String result = null; String result = null;
while (null != (result = br.readLine())) { while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) { if (!"".equals(result.trim())) {
...@@ -388,20 +328,7 @@ public class FileHelper { ...@@ -388,20 +328,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
} }
} }
/** /**
...@@ -1192,34 +1119,25 @@ public class FileHelper { ...@@ -1192,34 +1119,25 @@ public class FileHelper {
*/ */
public static void getExcel(String url, String fileName, HttpServletResponse response, HttpServletRequest request) { public static void getExcel(String url, String fileName, HttpServletResponse response, HttpServletRequest request) {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
try { try {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "attachment; filename=\"" response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName + ".xls") + "\""); + encodeChineseDownloadFileName(request, fileName + ".xls") + "\"");
// response.setHeader("Content-Disposition", "attachment;filename=" } catch (UnsupportedEncodingException e) {
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名 e.printStackTrace();
}
//通过文件路径获得File对象 try (//通过文件路径获得File对象
File file = new File(url); FileInputStream in = new FileInputStream(new File(url));
//3.通过response获取OutputStream对象(out)
FileInputStream in = new FileInputStream(file); OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0; int b = 0;
byte[] buffer = new byte[2048]; byte[] buffer = new byte[2048];
while ((b = in.read(buffer)) != -1) { while ((b = in.read(buffer)) != -1) {
out.write(buffer, 0, b); //4.写到输出流(out)中 out.write(buffer, 0, b); //4.写到输出流(out)中
} }
in.close();
out.flush(); out.flush();
out.close();
} catch (IOException e) { } catch (IOException e) {
log.error("下载Excel模板异常", e); log.error("下载Excel模板异常", e);
} }
......
...@@ -75,20 +75,20 @@ public class FileUtils { ...@@ -75,20 +75,20 @@ public class FileUtils {
* @return * @return
*/ */
public static String fileToZip(List<String> list, String fileName, String ipUrl) { 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; String path = System.getProperty("java.io.tmpdir") + fileName;
File zipFile = new File(path);
zipFile.deleteOnExit();
try { try {
File zipFile = new File(path);
zipFile.deleteOnExit();
zipFile.createNewFile(); zipFile.createNewFile();
} catch (IOException e) {
fos = new FileOutputStream(zipFile); e.printStackTrace();
zos = new ZipOutputStream(new BufferedOutputStream(fos)); }
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]; byte[] bufs = new byte[1024 * 10];
for (String a : list) { for (String a : list) {
fis = getInputStreamFromURL(ipUrl + a); fis = getInputStreamFromURL(ipUrl + a);
...@@ -105,9 +105,6 @@ public class FileUtils { ...@@ -105,9 +105,6 @@ public class FileUtils {
} }
} }
System.out.println("压缩成功"); System.out.println("压缩成功");
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -116,12 +113,11 @@ public class FileUtils { ...@@ -116,12 +113,11 @@ public class FileUtils {
if (null != bis) { if (null != bis) {
bis.close(); bis.close();
} }
if (null != zos) { if (null != fis) {
zos.close(); fis.close();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e);
} }
} }
return path; return path;
......
...@@ -98,7 +98,11 @@ public class RsDataQueue { ...@@ -98,7 +98,11 @@ public class RsDataQueue {
private Runnable task_runnable = new Runnable() { private Runnable task_runnable = new Runnable() {
@Override @Override
public void run() { public void run() {
while (true) { int k = 0;
boolean b = true;
while (b) {
k++;
b = k < Integer.MAX_VALUE;
try { try {
FmeaMessage fmeaMessage = blockingQueue.take(); FmeaMessage fmeaMessage = blockingQueue.take();
if (riskSourceService != null) { if (riskSourceService != null) {
......
...@@ -21,7 +21,7 @@ public class AmosThreadPool { ...@@ -21,7 +21,7 @@ public class AmosThreadPool {
/** /**
* 单例 * 单例
*/ */
private static AmosThreadPool instance; private static volatile AmosThreadPool instance;
/** /**
* 执行服务 * 执行服务
......
...@@ -26,10 +26,12 @@ public class FileUtil { ...@@ -26,10 +26,12 @@ public class FileUtil {
if (!targetFile.exists()) { if (!targetFile.exists()) {
targetFile.mkdirs(); targetFile.mkdirs();
} }
FileOutputStream out = new FileOutputStream(filePath + fileName); try (FileOutputStream out = new FileOutputStream(filePath + fileName);) {
out.write(file); out.write(file);
out.flush(); out.flush();
out.close(); } catch (IOException e) {
e.printStackTrace();
}
} }
/** /**
......
...@@ -34,9 +34,9 @@ public class SocketClient { ...@@ -34,9 +34,9 @@ public class SocketClient {
public void processUdp(int port, int type) throws SocketException { public void processUdp(int port, int type) throws SocketException {
if (type < 0) type = 0; if (type < 0) type = 0;
if (type >= testFilePath.length) type -= 1; if (type >= testFilePath.length) type -= 1;
DatagramSocket datagramSocket = new DatagramSocket();
try { try (DatagramSocket datagramSocket = new DatagramSocket();
FileInputStream fis = new FileInputStream(new File("C:\\Users\\DELL\\Desktop\\ffmpeg-4.4-full_build-shared\\bin\\out.pcm")); FileInputStream fis = new FileInputStream(new File("C:\\Users\\DELL\\Desktop\\ffmpeg-4.4-full_build-shared\\bin\\out.pcm"));) {
byte[] b = new byte[1280]; byte[] b = new byte[1280];
int len; int len;
while ((len = fis.read(b)) > 0) { while ((len = fis.read(b)) > 0) {
...@@ -57,11 +57,10 @@ public class SocketClient { ...@@ -57,11 +57,10 @@ public class SocketClient {
if (type < 0) type = 0; if (type < 0) type = 0;
if (type >= testFilePath.length) type -= 1; if (type >= testFilePath.length) type -= 1;
Socket socket = new Socket(); try (Socket socket = new Socket();
try { FileInputStream fis = new FileInputStream(new File(testFilePath[type]));) {
socket.connect(new InetSocketAddress(InetAddress.getLocalHost().getHostAddress(), port)); socket.connect(new InetSocketAddress(InetAddress.getLocalHost().getHostAddress(), port));
OutputStream outputStream = socket.getOutputStream(); OutputStream outputStream = socket.getOutputStream();
FileInputStream fis = new FileInputStream(new File(testFilePath[type]));
byte[] b = new byte[4096]; byte[] b = new byte[4096];
int len; int len;
while ((len = fis.read(b)) > 0) { while ((len = fis.read(b)) > 0) {
......
...@@ -125,7 +125,9 @@ public class SpeechTranscriberDemo { ...@@ -125,7 +125,9 @@ public class SpeechTranscriberDemo {
public void process(String filepath) { public void process(String filepath) {
SpeechTranscriber transcriber = null; 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 = new SpeechTranscriber(client, getTranscriberListener());
transcriber.setAppKey("89KKwpGXXN37Pn1G"); transcriber.setAppKey("89KKwpGXXN37Pn1G");
...@@ -164,12 +166,9 @@ public class SpeechTranscriberDemo { ...@@ -164,12 +166,9 @@ public class SpeechTranscriberDemo {
//此方法将以上参数设置序列化为JSON发送给服务端,并等待服务端确认。 //此方法将以上参数设置序列化为JSON发送给服务端,并等待服务端确认。
transcriber.start(); transcriber.start();
File file = new File(filepath);
FileInputStream fis = new FileInputStream(file);
byte[] b = new byte[320]; byte[] b = new byte[320];
int len; int len;
DatagramSocket datagramSocket = new DatagramSocket();
while ((len = fis.read(b)) > 0) { while ((len = fis.read(b)) > 0) {
// logger.info("send data pack length: " + len); // logger.info("send data pack length: " + len);
datagramSocket.send(new DatagramPacket(b, b.length, InetAddress.getLocalHost(), 25000)); datagramSocket.send(new DatagramPacket(b, b.length, InetAddress.getLocalHost(), 25000));
......
...@@ -108,9 +108,8 @@ public class SignController extends BaseController { ...@@ -108,9 +108,8 @@ public class SignController extends BaseController {
signDto.setPersonPhotos(personImg.get(0).getValue()); signDto.setPersonPhotos(personImg.get(0).getValue());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
return ResponseHelper.buildResponse(signDto);
} }
return ResponseHelper.buildResponse(signDto);
} }
......
...@@ -17,7 +17,7 @@ public class TriggerKeyQueue { ...@@ -17,7 +17,7 @@ public class TriggerKeyQueue {
/** /**
* 单例 * 单例
*/ */
private static TriggerKeyQueue instance; private static volatile TriggerKeyQueue instance;
/** /**
* 队列 * 队列
......
...@@ -60,6 +60,7 @@ import java.net.URLEncoder; ...@@ -60,6 +60,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.Channel; import java.nio.channels.Channel;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -121,20 +122,10 @@ public class FileHelper { ...@@ -121,20 +122,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isWord2003(File file) { public static boolean isWord2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
try { HWPFDocument hwpfDocument = new HWPFDocument(is);) {
is = new FileInputStream(file);
new HWPFDocument(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -164,24 +155,10 @@ public class FileHelper { ...@@ -164,24 +155,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isPPT2003(File file) { public static boolean isPPT2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
HSLFSlideShow ppt = null; HSLFSlideShow ppt = new HSLFSlideShow(is);) {
try {
is = new FileInputStream(file);
ppt = new HSLFSlideShow(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != ppt) {
ppt.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -193,13 +170,10 @@ public class FileHelper { ...@@ -193,13 +170,10 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path) { public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content); buffer.append(content);
...@@ -208,19 +182,7 @@ public class FileHelper { ...@@ -208,19 +182,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
} }
return buffer; return buffer;
} }
...@@ -232,13 +194,10 @@ public class FileHelper { ...@@ -232,13 +194,10 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path, String split) { public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; try (InputStream is = new FileInputStream(file);
try { BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
File file = new File(path);
if (file.exists()) { if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content).append(split); buffer.append(content).append(split);
...@@ -247,19 +206,7 @@ public class FileHelper { ...@@ -247,19 +206,7 @@ public class FileHelper {
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
} }
return buffer; return buffer;
} }
...@@ -269,28 +216,17 @@ public class FileHelper { ...@@ -269,28 +216,17 @@ public class FileHelper {
* @param path 写入内容的文件路径 * @param path 写入内容的文件路径
*/ */
public static void writeFile(String content, String path) { public static void writeFile(String content, String path) {
OutputStream fos = null; File file = new File(path);
BufferedWriter bw = null; try (OutputStream fos = new FileOutputStream(file);
try { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8)); ) {
File file = new File(path);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content); bw.write(content);
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
fnfe.printStackTrace(); fnfe.printStackTrace();
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
} }
} }
...@@ -379,11 +315,8 @@ public class FileHelper { ...@@ -379,11 +315,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException { public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile); File htmFile = new File(inputFile);
// 以GB2312读取文件 // 以GB2312读取文件
BufferedReader br = null; try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = null; BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
String result = null; String result = null;
while (null != (result = br.readLine())) { while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) { if (!"".equals(result.trim())) {
...@@ -392,17 +325,6 @@ public class FileHelper { ...@@ -392,17 +325,6 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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 ...@@ -1198,35 +1120,24 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws * @throws
*/ */
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){ public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
try { response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型 try {
response.setContentType("multipart/form-data"); response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
//2.设置文件头:最后一个参数是设置下载文件名 } catch (UnsupportedEncodingException e) {
response.setHeader("Content-disposition", "attachment; filename=\"" e.printStackTrace();
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\""); }
// response.setHeader("Content-Disposition", "attachment;filename=" try (FileInputStream in = new FileInputStream(new File(url));
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名 //3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
//通过文件路径获得File对象
File file = new File(url);
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0; int b = 0;
byte[] buffer = new byte[2048]; byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){ while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中 out.write(buffer,0,b); //4.写到输出流(out)中
} }
in.close();
out.flush(); out.flush();
out.close();
} catch (IOException e) { } catch (IOException e) {
log.error("下载Excel模板异常", e); log.error("下载Excel模板异常", e);
} }
......
...@@ -34,18 +34,12 @@ public class TikaUtils { ...@@ -34,18 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) { public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser(); org.apache.tika.parser.Parser parser = new AutoDetectParser();
try { try (InputStream inputStream = new FileInputStream(file);) {
InputStream inputStream = new FileInputStream(file);
DefaultHandler handler = new BodyContentHandler(); DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext(); ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser); parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext); parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString(); return handler.toString();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -58,22 +52,16 @@ public class TikaUtils { ...@@ -58,22 +52,16 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler(); ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser(); AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
InputStream stream = null;
try { 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); parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html"); FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html"); FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
} }
return "";
return null;
} }
......
package com.yeejoin.amos.latentdanger.core.threadpool; package com.yeejoin.amos.latentdanger.core.threadpool;
import com.yeejoin.amos.latentdanger.business.constants.Constants; import com.yeejoin.amos.latentdanger.business.constants.Constants;
import com.yeejoin.amos.latentdanger.business.trigger.TriggerKeyQueue;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -20,7 +21,7 @@ public class AmosThreadPool { ...@@ -20,7 +21,7 @@ public class AmosThreadPool {
/** /**
* 单例 * 单例
*/ */
private static AmosThreadPool instance; private static volatile AmosThreadPool instance;
/** /**
* 执行服务 * 执行服务
......
...@@ -17,7 +17,7 @@ public class TriggerKeyQueue { ...@@ -17,7 +17,7 @@ public class TriggerKeyQueue {
/** /**
* 单例 * 单例
*/ */
private static TriggerKeyQueue instance; private static volatile TriggerKeyQueue instance;
/** /**
* 队列 * 队列
......
...@@ -40,6 +40,7 @@ import java.net.URLEncoder; ...@@ -40,6 +40,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.Channel; import java.nio.channels.Channel;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
...@@ -64,11 +65,8 @@ public class FileHelper { ...@@ -64,11 +65,8 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isExcel2003(File file) { public static boolean isExcel2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
Workbook wb = null; Workbook wb = WorkbookFactory.create(is);) {
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
if (wb instanceof XSSFWorkbook) { if (wb instanceof XSSFWorkbook) {
return false; return false;
} else if (wb instanceof HSSFWorkbook) { } else if (wb instanceof HSSFWorkbook) {
...@@ -76,17 +74,6 @@ public class FileHelper { ...@@ -76,17 +74,6 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -97,20 +84,10 @@ public class FileHelper { ...@@ -97,20 +84,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isWord2003(File file) { public static boolean isWord2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
try { HWPFDocument hwpfDocument = new HWPFDocument(is);) {
is = new FileInputStream(file);
new HWPFDocument(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -169,34 +146,19 @@ public class FileHelper { ...@@ -169,34 +146,19 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path) { public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; if (file.exists()) {
try { try (InputStream is = new FileInputStream(file);
File file = new File(path); BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content); buffer.append(content);
content = br.readLine(); content = br.readLine();
} }
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
return buffer; return buffer;
} }
...@@ -208,34 +170,19 @@ public class FileHelper { ...@@ -208,34 +170,19 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path, String split) { public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; if (file.exists()) {
try { try (InputStream is = new FileInputStream(file);
File file = new File(path); BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content).append(split); buffer.append(content).append(split);
content = br.readLine(); content = br.readLine();
} }
} } catch (Exception exception) {
} catch (Exception exception) { exception.printStackTrace();
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
} }
} }
return buffer; return buffer;
} }
...@@ -245,28 +192,15 @@ public class FileHelper { ...@@ -245,28 +192,15 @@ public class FileHelper {
* @param path 写入内容的文件路径 * @param path 写入内容的文件路径
*/ */
public static void writeFile(String content, String path) { public static void writeFile(String content, String path) {
OutputStream fos = null; File file = new File(path);
BufferedWriter bw = null; try (OutputStream fos = new FileOutputStream(file);
try { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
File file = new File(path);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content); bw.write(content);
} catch (FileNotFoundException fnfe) { } catch (IOException fnfe) {
fnfe.printStackTrace(); 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 { ...@@ -355,11 +289,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException { public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile); File htmFile = new File(inputFile);
// 以GB2312读取文件 // 以GB2312读取文件
BufferedReader br = null; try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = null; BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
String result = null; String result = null;
while (null != (result = br.readLine())) { while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) { if (!"".equals(result.trim())) {
...@@ -368,20 +299,7 @@ public class FileHelper { ...@@ -368,20 +299,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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 ...@@ -1254,38 +1172,31 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws * @throws
*/ */
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){ public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
//通过文件路径获得File对象
try { File file = new File(url);
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型 response.setContentType("multipart/form-data");
response.setContentType("multipart/form-data"); //2.设置文件头:最后一个参数是设置下载文件名
try {
//2.设置文件头:最后一个参数是设置下载文件名 response.setHeader("Content-disposition", "attachment; filename=\""
response.setHeader("Content-disposition", "attachment; filename=\"" + encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
+ 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=" // response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名 // + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//3.通过response获取OutputStream对象(out)
//通过文件路径获得File对象 int b = 0;
File file = new File(url); byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
FileInputStream in = new FileInputStream(file); out.write(buffer,0,b); //4.写到输出流(out)中
//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);
} }
out.flush();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
} }
/** /**
......
...@@ -34,17 +34,12 @@ public class TikaUtils { ...@@ -34,17 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) { public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser(); org.apache.tika.parser.Parser parser = new AutoDetectParser();
try { try (InputStream inputStream = new FileInputStream(file);) {
InputStream inputStream = new FileInputStream(file);
DefaultHandler handler = new BodyContentHandler(); DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext(); ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser); parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext); parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close(); inputStream.close();
return handler.toString(); return handler.toString();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -20,7 +20,7 @@ public class AmosThreadPool { ...@@ -20,7 +20,7 @@ public class AmosThreadPool {
/** /**
* 单例 * 单例
*/ */
private static AmosThreadPool instance; private static volatile AmosThreadPool instance;
/** /**
* 执行服务 * 执行服务
......
...@@ -43,9 +43,7 @@ public class HomeController extends AbstractBaseController{ ...@@ -43,9 +43,7 @@ public class HomeController extends AbstractBaseController{
private IPlanTaskService planTaskService ; private IPlanTaskService planTaskService ;
/*@Autowired /*@Autowired
private IUserService userService;*/ private IUserService userService;*/
@Autowired
private RemoteSecurityService remoteSecurityService;
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "首页数据", notes = "首页数据") @ApiOperation(value = "首页数据", notes = "首页数据")
@GetMapping(value="/overviewData") @GetMapping(value="/overviewData")
......
...@@ -51,9 +51,7 @@ public class SafetyController extends AbstractBaseController{ ...@@ -51,9 +51,7 @@ public class SafetyController extends AbstractBaseController{
/*@Autowired /*@Autowired
private AmosBankFeign pointService;*/ private AmosBankFeign pointService;*/
@Autowired
private RemoteSecurityService remoteSecurityService;
/** /**
* 保存登陆用户选择公司信息 * 保存登陆用户选择公司信息
*/ */
......
...@@ -110,8 +110,7 @@ public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implement ...@@ -110,8 +110,7 @@ public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implement
@Autowired @Autowired
private IRoutePointItemDao iRoutePointItemDao; private IRoutePointItemDao iRoutePointItemDao;
@Autowired
private RemoteSecurityService remoteSecurityService;
@Override @Override
@Transactional @Transactional
......
...@@ -17,7 +17,7 @@ public class TriggerKeyQueue { ...@@ -17,7 +17,7 @@ public class TriggerKeyQueue {
/** /**
* 单例 * 单例
*/ */
private static TriggerKeyQueue instance; private static volatile TriggerKeyQueue instance;
/** /**
* 队列 * 队列
......
...@@ -41,6 +41,7 @@ import java.net.URLEncoder; ...@@ -41,6 +41,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.Channel; import java.nio.channels.Channel;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
...@@ -98,20 +99,10 @@ public class FileHelper { ...@@ -98,20 +99,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isWord2003(File file) { public static boolean isWord2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
try { HWPFDocument hwpfDocument = new HWPFDocument(is);) {
is = new FileInputStream(file);
new HWPFDocument(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -141,24 +132,10 @@ public class FileHelper { ...@@ -141,24 +132,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isPPT2003(File file) { public static boolean isPPT2003(File file) {
InputStream is = null; try ( InputStream is = new FileInputStream(file);
HSLFSlideShow ppt = null; HSLFSlideShow ppt = new HSLFSlideShow(is);) {
try {
is = new FileInputStream(file);
ppt = new HSLFSlideShow(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != ppt) {
ppt.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -170,34 +147,19 @@ public class FileHelper { ...@@ -170,34 +147,19 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path) { public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; if (file.exists()) {
try { try (InputStream is = new FileInputStream(file);
File file = new File(path); BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content); buffer.append(content);
content = br.readLine(); content = br.readLine();
} }
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
return buffer; return buffer;
} }
...@@ -209,34 +171,20 @@ public class FileHelper { ...@@ -209,34 +171,20 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path, String split) { public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; if (file.exists()) {
try { try (InputStream is = new FileInputStream(file);
File file = new File(path); BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content).append(split); buffer.append(content).append(split);
content = br.readLine(); content = br.readLine();
} }
}
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
} }
} }
return buffer; return buffer;
} }
...@@ -246,28 +194,15 @@ public class FileHelper { ...@@ -246,28 +194,15 @@ public class FileHelper {
* @param path 写入内容的文件路径 * @param path 写入内容的文件路径
*/ */
public static void writeFile(String content, String path) { public static void writeFile(String content, String path) {
OutputStream fos = null; File file = new File(path);
BufferedWriter bw = null; try (OutputStream fos = new FileOutputStream(file);
try { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
File file = new File(path);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content); bw.write(content);
} catch (FileNotFoundException fnfe) { } catch (IOException fnfe) {
fnfe.printStackTrace(); 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 { ...@@ -356,11 +291,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException { public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile); File htmFile = new File(inputFile);
// 以GB2312读取文件 // 以GB2312读取文件
BufferedReader br = null; try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = null; BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
String result = null; String result = null;
while (null != (result = br.readLine())) { while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) { if (!"".equals(result.trim())) {
...@@ -369,20 +301,7 @@ public class FileHelper { ...@@ -369,20 +301,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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 ...@@ -1258,35 +1177,28 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws * @throws
*/ */
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){ public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
//通过文件路径获得File对象
try { File file = new File(url);
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型 response.setContentType("multipart/form-data");
response.setContentType("multipart/form-data"); //2.设置文件头:最后一个参数是设置下载文件名
try {
//2.设置文件头:最后一个参数是设置下载文件名 response.setHeader("Content-disposition", "attachment; filename=\""
response.setHeader("Content-disposition", "attachment; filename=\"" + encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
+ 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=" // response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名 // + 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) //3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0; int b = 0;
byte[] buffer = new byte[2048]; byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){ while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中 out.write(buffer,0,b); //4.写到输出流(out)中
} }
in.close();
out.flush(); out.flush();
out.close();
} catch (IOException e) { } catch (IOException e) {
log.error("下载Excel模板异常", e); log.error("下载Excel模板异常", e);
} }
......
...@@ -34,8 +34,7 @@ public class TikaUtils { ...@@ -34,8 +34,7 @@ public class TikaUtils {
public static String fileToTxt(File file) { public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser(); org.apache.tika.parser.Parser parser = new AutoDetectParser();
try { try (InputStream inputStream = new FileInputStream(file);) {
InputStream inputStream = new FileInputStream(file);
DefaultHandler handler = new BodyContentHandler(); DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext(); ParseContext parseContext = new ParseContext();
...@@ -45,7 +44,6 @@ public class TikaUtils { ...@@ -45,7 +44,6 @@ public class TikaUtils {
* for (String string : metadata.names()) { * for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); } * System.out.println(string+":"+metadata.get(string)); }
*/ */
inputStream.close();
return handler.toString(); return handler.toString();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -58,21 +56,15 @@ public class TikaUtils { ...@@ -58,21 +56,15 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler(); ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser(); AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
InputStream stream = null; try (InputStream stream = new FileInputStream(new File(fileName))) {
try {
stream = new FileInputStream(new File(fileName));
parser.parse(stream, handler, metadata); parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html"); FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html"); FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
} }
return null; return null;
} }
......
package com.yeejoin.amos.patrol.core.threadpool; package com.yeejoin.amos.patrol.core.threadpool;
import com.yeejoin.amos.patrol.business.constants.XJConstant; import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.trigger.TriggerKeyQueue;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -20,7 +21,7 @@ public class AmosThreadPool { ...@@ -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; ...@@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -209,14 +210,10 @@ public class FileController { ...@@ -209,14 +210,10 @@ public class FileController {
} else { } else {
processData = DocUtil.processDocx(data); processData = DocUtil.processDocx(data);
} }
String htmlContent = (String) processData.get("html"); String htmlContent = (String) processData.get("html");
try { try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), StandardCharsets.UTF_8));) {
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), "UTF-8"));
writer.write(htmlContent); writer.write(htmlContent);
writer.flush(); writer.flush();
writer.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -17,7 +17,7 @@ public class TriggerKeyQueue { ...@@ -17,7 +17,7 @@ public class TriggerKeyQueue {
/** /**
* 单例 * 单例
*/ */
private static TriggerKeyQueue instance; private static volatile TriggerKeyQueue instance;
/** /**
* 队列 * 队列
......
...@@ -39,6 +39,7 @@ import java.net.URLEncoder; ...@@ -39,6 +39,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.Channel; import java.nio.channels.Channel;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
...@@ -63,11 +64,8 @@ public class FileHelper { ...@@ -63,11 +64,8 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isExcel2003(File file) { public static boolean isExcel2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
Workbook wb = null; Workbook wb = WorkbookFactory.create(is);) {
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
if (wb instanceof XSSFWorkbook) { if (wb instanceof XSSFWorkbook) {
return false; return false;
} else if (wb instanceof HSSFWorkbook) { } else if (wb instanceof HSSFWorkbook) {
...@@ -75,17 +73,6 @@ public class FileHelper { ...@@ -75,17 +73,6 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -96,20 +83,10 @@ public class FileHelper { ...@@ -96,20 +83,10 @@ public class FileHelper {
* @return * @return
*/ */
public static boolean isWord2003(File file) { public static boolean isWord2003(File file) {
InputStream is = null; try (InputStream is = new FileInputStream(file);
try { HWPFDocument hwpfDocument = new HWPFDocument(is);) {
is = new FileInputStream(file);
new HWPFDocument(is);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return true; return true;
} }
...@@ -168,34 +145,19 @@ public class FileHelper { ...@@ -168,34 +145,19 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path) { public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; if (file.exists()) {
try { try (InputStream is = new FileInputStream(file);
File file = new File(path); BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content); buffer.append(content);
content = br.readLine(); content = br.readLine();
} }
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
return buffer; return buffer;
} }
...@@ -207,34 +169,19 @@ public class FileHelper { ...@@ -207,34 +169,19 @@ public class FileHelper {
*/ */
public static StringBuffer readFile(String path, String split) { public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
InputStream is = null; File file = new File(path);
BufferedReader br = null; if (file.exists()) {
try { try (InputStream is = new FileInputStream(file);
File file = new File(path); BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
String content = br.readLine(); String content = br.readLine();
while (null != content) { while (null != content) {
buffer.append(content).append(split); buffer.append(content).append(split);
content = br.readLine(); content = br.readLine();
} }
} } catch (Exception exception) {
} catch (Exception exception) { exception.printStackTrace();
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
} }
} }
return buffer; return buffer;
} }
...@@ -244,28 +191,15 @@ public class FileHelper { ...@@ -244,28 +191,15 @@ public class FileHelper {
* @param path 写入内容的文件路径 * @param path 写入内容的文件路径
*/ */
public static void writeFile(String content, String path) { public static void writeFile(String content, String path) {
OutputStream fos = null; File file = new File(path);
BufferedWriter bw = null; try (OutputStream fos = new FileOutputStream(file);
try { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
File file = new File(path);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content); bw.write(content);
} catch (FileNotFoundException fnfe) { } catch (IOException fnfe) {
fnfe.printStackTrace(); 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 { ...@@ -354,11 +288,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException { public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile); File htmFile = new File(inputFile);
// 以GB2312读取文件 // 以GB2312读取文件
BufferedReader br = null; try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = null; BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
String result = null; String result = null;
while (null != (result = br.readLine())) { while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) { if (!"".equals(result.trim())) {
...@@ -367,20 +298,7 @@ public class FileHelper { ...@@ -367,20 +298,7 @@ public class FileHelper {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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 ...@@ -1253,38 +1171,31 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws * @throws
*/ */
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){ public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
//通过文件路径获得File对象
try { File file = new File(url);
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型 response.setContentType("multipart/form-data");
response.setContentType("multipart/form-data"); //2.设置文件头:最后一个参数是设置下载文件名
try {
//2.设置文件头:最后一个参数是设置下载文件名 response.setHeader("Content-disposition", "attachment; filename=\""
response.setHeader("Content-disposition", "attachment; filename=\"" + encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
+ 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=" // response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名 // + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//3.通过response获取OutputStream对象(out)
//通过文件路径获得File对象 int b = 0;
File file = new File(url); byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
FileInputStream in = new FileInputStream(file); out.write(buffer,0,b); //4.写到输出流(out)中
//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);
} }
out.flush();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
} }
/** /**
......
...@@ -34,17 +34,12 @@ public class TikaUtils { ...@@ -34,17 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) { public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser(); org.apache.tika.parser.Parser parser = new AutoDetectParser();
try { try(InputStream inputStream = new FileInputStream(file);) {
InputStream inputStream = new FileInputStream(file);
DefaultHandler handler = new BodyContentHandler(); DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext(); ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser); parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext); parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close(); inputStream.close();
return handler.toString(); return handler.toString();
} catch (Exception e) { } catch (Exception e) {
...@@ -58,21 +53,14 @@ public class TikaUtils { ...@@ -58,21 +53,14 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler(); ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser(); AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
InputStream stream = null; try ( InputStream stream = new FileInputStream(new File(fileName));) {
try {
stream = new FileInputStream(new File(fileName));
parser.parse(stream, handler, metadata); parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html"); FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html"); FileHelper.parse(outPutFile + ".html");
return null; return null;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
} }
return null; return null;
} }
......
...@@ -20,7 +20,7 @@ public class AmosThreadPool { ...@@ -20,7 +20,7 @@ public class AmosThreadPool {
/** /**
* 单例 * 单例
*/ */
private static AmosThreadPool instance; private static volatile AmosThreadPool instance;
/** /**
* 执行服务 * 执行服务
......
...@@ -109,6 +109,8 @@ isSendIot=false ...@@ -109,6 +109,8 @@ isSendIot=false
equipment.scrap.day=30 equipment.scrap.day=30
#提醒时间 #提醒时间
equipment.scrap.cron=0 0 9 * * ? equipment.scrap.cron=0 0 9 * * ?
#?????????????
equipment.pressurepump.start.cron=0 0 0 * * ?
# 稳压泵启动信号 # 稳压泵启动信号
equipment.pressurepump.start=FHS_PressurePump_Start equipment.pressurepump.start=FHS_PressurePump_Start
......
...@@ -3,8 +3,12 @@ ...@@ -3,8 +3,12 @@
"name": "稳压泵", "name": "稳压泵",
"code": "PressurePump", "code": "PressurePump",
"nameKey": "FHS_PressurePump_Start,FHS_PipePressureDetector_PipePressure", "nameKey": "FHS_PressurePump_Start,FHS_PipePressureDetector_PipePressure",
"faultNameKey": "FHS_PressurePump_Fault,FHS_PressurePump_RunFault,FHS_PressurePump_OverLoadFault",
"expire": 14400, "expire": 14400,
"countExpire": 1209600,
"equipmentCode": "92010800KAL44", "equipmentCode": "92010800KAL44",
"top": "100" "pipePressureEquipmentCode": "92011000T5Q44",
"top": "100",
"countRedisKey": "Count"
} }
] ]
\ No newline at end of file
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
IF IF
((( (((
SELECT SELECT
count( `eqlog`.`equipment_specific_id` ) count( `wesa`.`equipment_specific_id` )
FROM FROM
`wl_equipment_specific_alarm_log` `eqlog` `wl_equipment_specific_alarm` `wesa`
WHERE WHERE
( 0 <![CDATA[<>]]> find_in_set( `fs`.`id`, `eqlog`.`system_ids` ) ( 0 <![CDATA[<>]]> find_in_set( `fs`.`id`, `wesa`.`system_ids` )
AND `eqlog`.`status` = 1 AND `eqlog`.clean_time IS NULL)) > 0 AND `wesa`.`status` = 1)) > 0
), ),
'异常', '异常',
'正常' '正常'
......
...@@ -1513,11 +1513,15 @@ ...@@ -1513,11 +1513,15 @@
select select
count(1) count(1)
from from
wl_equipment_specific_index wl_equipment_specific_index wesi
LEFT JOIN wl_equipment_specific wes on wesi.equipment_specific_id = wes.id
where where
equipment_index_key in ('FHS_PressurePump_Start', 'FHS_PressurePump_Stop') wesi.equipment_index_key in ('FHS_PressurePump_Start', 'FHS_PressurePump_Stop')
and update_date >= and update_date >=
#{startTime} and #{endTime} >= update_date #{startTime} and #{endTime} >= update_date
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
</if>
) as allNum, ) as allNum,
( (
select select
...@@ -1526,8 +1530,13 @@ ...@@ -1526,8 +1530,13 @@
count(1) count(1)
from from
wl_equipment_detail wed wl_equipment_detail wed
LEFT JOIN wl_equipment_specific wes on wes.equipment_detail_id = wed.id
where where
wed.code like '92010800%' ) as allEqu) as allEqu, wed.code like '92010800%'
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
</if>
) as allEqu) as allEqu,
( (
select select
'稳压泵平均打压频次' as name) as name, '稳压泵平均打压频次' as name) as name,
...@@ -1537,11 +1546,15 @@ ...@@ -1537,11 +1546,15 @@
select select
count(1) count(1)
from from
wl_equipment_specific_index wl_equipment_specific_index wesi
LEFT JOIN wl_equipment_specific wes on wesi.equipment_specific_id = wes.id
where where
equipment_index_key in ('FHS_PressurePump_Start') wesi.equipment_index_key in ('FHS_PressurePump_Start')
and update_date >= and wesi.update_date >=
#{startTime} and #{endTime} >= update_date #{startTime} and #{endTime} >= update_date
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
</if>
) as startNum) as startNum ) as startNum) as startNum
</select> </select>
......
...@@ -499,11 +499,12 @@ ...@@ -499,11 +499,12 @@
si.update_date, si.update_date,
si.equipment_index_key, si.equipment_index_key,
si.equipment_specific_name, si.equipment_specific_name,
es.position location, CONCAT_WS('-', es.position, wled.area) AS location, /*告警列表拼接详细地址*/
es.`iot_code` AS iotCode es.`iot_code` AS iotCode
FROM FROM
wl_equipment_specific_index si wl_equipment_specific_index si
LEFT JOIN wl_equipment_specific es ON si.equipment_specific_id = es.id LEFT JOIN wl_equipment_specific es ON si.equipment_specific_id = es.id
LEFT JOIN wl_equipment_detail wled ON es.equipment_detail_id = wled.id
<where> <where>
<if test="list != null and list.size > 0 and type = 'id'"> <if test="list != null and list.size > 0 and type = 'id'">
si.equipment_index_key IN si.equipment_index_key IN
......
...@@ -1645,6 +1645,10 @@ ...@@ -1645,6 +1645,10 @@
LEFT JOIN wl_equipment AS wle ON spe.equipment_code = wle.code LEFT JOIN wl_equipment AS wle ON spe.equipment_code = wle.code
LEFT JOIN wl_equipment_category AS wlec ON wlec.id = wle.category_id LEFT JOIN wl_equipment_category AS wlec ON wlec.id = wle.category_id
WHERE det.amount > 0 and spe.warehouse_structure_id = #{floorId} WHERE det.amount > 0 and spe.warehouse_structure_id = #{floorId}
<if test="isIot != null and isIot != ''">
and wle.is_iot = #{isIot}
</if>
</select> </select>
<select id="getStationInfo" resultType="Map"> <select id="getStationInfo" resultType="Map">
...@@ -1729,7 +1733,8 @@ ...@@ -1729,7 +1733,8 @@
wes.realtime_iot_es_index_id realtimeIotSpecificIndexId, wes.realtime_iot_es_index_id realtimeIotSpecificIndexId,
wes.realtime_iot_index_update_date realtiemIotIndexUpdateDate, wes.realtime_iot_index_update_date realtiemIotIndexUpdateDate,
wes.realtime_iot_index_id realtimeIotIndexId, wes.realtime_iot_index_id realtimeIotIndexId,
wes.iot_code iotCode wes.iot_code iotCode,
wes.biz_org_code bizOrgCode
FROM FROM
wl_equipment_specific wes wl_equipment_specific wes
<where> <where>
...@@ -1859,7 +1864,17 @@ ...@@ -1859,7 +1864,17 @@
( (
0 <![CDATA[<>]]> find_in_set(`fs`.`id`, `s`.`system_id`) 0 <![CDATA[<>]]> find_in_set(`fs`.`id`, `s`.`system_id`)
) )
) AS `fightSysName` ) AS `fightSysName`,
(
SELECT
charge_person_name
FROM
`f_fire_fighting_system` `fs`
WHERE
(
0 <![CDATA[<>]]> find_in_set(`fs`.`id`, `s`.`system_id`)
)
) AS `chargePersonName`
FROM FROM
`wl_equipment_specific_index` `si` `wl_equipment_specific_index` `si`
JOIN `wl_equipment_specific` `s` JOIN `wl_equipment_specific` `s`
......
...@@ -729,7 +729,7 @@ ...@@ -729,7 +729,7 @@
LEFT JOIN wl_equipment_specific_alarm wlesa ON wlesa.id = wlesal.equipment_specific_alarm_id LEFT JOIN wl_equipment_specific_alarm wlesa ON wlesa.id = wlesal.equipment_specific_alarm_id
<where> <where>
<if test="systemId!=null"> <if test="systemId!=null">
and find_in_set(#{systemId},wlesal.system_ids) and 0 <![CDATA[<>]]> find_in_set(#{systemId},wlesal.system_ids)
</if> </if>
<if test="sourceId!=null"> <if test="sourceId!=null">
and (wlesal.build_id=#{sourceId} and (wlesal.build_id=#{sourceId}
...@@ -1917,7 +1917,7 @@ ...@@ -1917,7 +1917,7 @@
CONCAT('01#',wles.qr_code) fullqrCode, CONCAT('01#',wles.qr_code) fullqrCode,
wled.standard, wled.standard,
wle.img, wle.img,
wled.NAME equipmentName, wles.name equipmentName,
concat_ws('-',wlws.full_name,wled.area) as full_name, concat_ws('-',wlws.full_name,wled.area) as full_name,
wlws.name as belongBuildName, wlws.name as belongBuildName,
wlun.NAME unitName, wlun.NAME unitName,
...@@ -1944,7 +1944,7 @@ ...@@ -1944,7 +1944,7 @@
wles.biz_org_code as bizOrgCode, wles.biz_org_code as bizOrgCode,
wles.biz_org_name as bizOrgName wles.biz_org_name as bizOrgName
FROM FROM
(select id,qr_code,code ,iot_code ,biz_org_code,team_id ,biz_org_name,create_date ,equipment_detail_id ,system_id from wl_equipment_specific) wles (select id,name,qr_code,code ,iot_code ,biz_org_code,team_id ,biz_org_name,create_date ,equipment_detail_id ,system_id from wl_equipment_specific) wles
LEFT JOIN (select id,amount,status,equipment_specific_id,warehouse_structure_id from wl_stock_detail ) wlsd on wlsd.equipment_specific_id = wles.id LEFT JOIN (select id,amount,status,equipment_specific_id,warehouse_structure_id from wl_stock_detail ) wlsd on wlsd.equipment_specific_id = wles.id
LEFT JOIN wl_warehouse_structure wlws on wlsd.warehouse_structure_id = wlws.id LEFT JOIN wl_warehouse_structure wlws on wlsd.warehouse_structure_id = wlws.id
LEFT JOIN (select id,standard ,name ,area ,code, equipment_id ,manufacturer_id,is_import from wl_equipment_detail) wled on wles.equipment_detail_id = wled.id LEFT JOIN (select id,standard ,name ,area ,code, equipment_id ,manufacturer_id,is_import from wl_equipment_detail) wled on wles.equipment_detail_id = wled.id
...@@ -2832,41 +2832,19 @@ ...@@ -2832,41 +2832,19 @@
</select> </select>
<select id="queryPressureNowSignalBySpecificId" resultType="java.util.Map"> <select id="queryPressureNowSignalBySpecificId" resultType="java.util.Map">
( SELECT
DATE_FORMAT( i.update_date, '%Y-%m-%d %H:%i:%S' ) update_date,
i.equipment_index_name,
`value`
FROM
wl_equipment_specific_index i
WHERE
i.equipment_specific_id = #{id,jdbcType=VARCHAR}
AND
VALUE = "true"
AND i.equipment_index_key NOT IN ( 'FHS_PressurePump_Start', 'FHS_PressurePump_Stop' )
ORDER BY
i.update_date DESC
LIMIT 1
) UNION
(
SELECT SELECT
DATE_FORMAT( i.update_date, '%Y-%m-%d %H:%i:%S' ) update_date, DATE_FORMAT( i.update_date, '%Y-%m-%d %H:%i:%S' ) update_date,
i.equipment_index_name, i.equipment_index_name,
VALUE `value`
FROM FROM
wl_equipment_specific_index i wl_equipment_specific_index i
WHERE WHERE
i.equipment_specific_id = #{id,jdbcType=VARCHAR} i.equipment_specific_id = #{id,jdbcType=VARCHAR}
AND AND
VALUE VALUE in ("true","false")
<![CDATA[<>]]> ''
AND
VALUE
IS NOT NULL
AND i.equipment_index_key = 'FHS_PressurePump_Start'
)
ORDER BY ORDER BY
update_date DESC i.update_date DESC
LIMIT 1 LIMIT 1
</select> </select>
<select id="getPressurePumpInfo3Small" resultType="java.util.Map"> <select id="getPressurePumpInfo3Small" resultType="java.util.Map">
...@@ -3890,7 +3868,11 @@ ...@@ -3890,7 +3868,11 @@
FROM `f_fire_fighting_system` ffs FROM `f_fire_fighting_system` ffs
LEFT JOIN wl_equipment_category wec LEFT JOIN wl_equipment_category wec
on ffs.system_type = wec.id on ffs.system_type = wec.id
WHERE biz_org_code like concat(#{bizOrgCode},'%') <where>
<if test="bizOrgCode != null and bizOrgCode != ''">
biz_org_code like concat(#{bizOrgCode},'%')
</if>
</where>
order by ffs.sort order by ffs.sort
</select> </select>
<select id="selectAlarmList" resultType="java.util.Map"> <select id="selectAlarmList" resultType="java.util.Map">
...@@ -5272,8 +5254,6 @@ ...@@ -5272,8 +5254,6 @@
FROM FROM
`wl_equipment_specific_alarm_log` `wl_equipment_specific_alarm_log`
WHERE WHERE
`wl_equipment_specific_alarm_log`.`status` = 1
AND
0 <![CDATA[<>]]> find_in_set(`fs`.`id`, `wl_equipment_specific_alarm_log`.`system_ids`) 0 <![CDATA[<>]]> find_in_set(`fs`.`id`, `wl_equipment_specific_alarm_log`.`system_ids`)
<if test="startDate!=null"> <if test="startDate!=null">
AND DATE_FORMAT(`wl_equipment_specific_alarm_log`.update_date,'%y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{startDate},'%y-%m-%d') AND DATE_FORMAT(`wl_equipment_specific_alarm_log`.update_date,'%y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{startDate},'%y-%m-%d')
...@@ -5626,6 +5606,7 @@ ...@@ -5626,6 +5606,7 @@
AND fs.system_type_code = #{systemCode} AND fs.system_type_code = #{systemCode}
</if> </if>
GROUP BY det.`code` GROUP BY det.`code`
ORDER BY status
</select> </select>
<select id="getFireSystemEquipStatusList" resultType="java.util.Map"> <select id="getFireSystemEquipStatusList" resultType="java.util.Map">
...@@ -5637,6 +5618,7 @@ ...@@ -5637,6 +5618,7 @@
wle.shbz_img shbzImg, wle.shbz_img shbzImg,
ei.is_alarm AS type, ei.is_alarm AS type,
IFNULL( spe.realtime_iot_index_value, '--' ) AS realtimeValue, IFNULL( spe.realtime_iot_index_value, '--' ) AS realtimeValue,
CASE when ei.is_alarm = 1 and spe.realtime_iot_index_value = 'true' then 1 else 0 END as orderNo,
IFNULL( ws.full_name, '--' ) AS fullName, IFNULL( ws.full_name, '--' ) AS fullName,
IFNULL( spe.realtime_iot_index_update_date, '--' ) AS updateDate IFNULL( spe.realtime_iot_index_update_date, '--' ) AS updateDate
FROM FROM
...@@ -5661,7 +5643,7 @@ ...@@ -5661,7 +5643,7 @@
</foreach> </foreach>
</if> </if>
GROUP BY spe.id GROUP BY spe.id
ORDER BY spe.id ORDER BY orderNo desc
</select> </select>
<select id="selectPressureDetails" resultType="java.util.Map"> <select id="selectPressureDetails" resultType="java.util.Map">
......
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