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