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;
}
/**
......
......@@ -10,12 +10,10 @@ import org.apache.commons.io.FileUtils;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hssf.usermodel.DVConstraint;
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
......@@ -34,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;
......@@ -87,20 +86,11 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
} catch (Exception e) {
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is)) {
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -129,24 +119,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;
}
......@@ -157,34 +133,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;
}
......@@ -197,34 +158,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;
}
......@@ -235,28 +181,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);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
File file = new File(path);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.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());
}
}
}
......@@ -346,11 +279,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())) {
......@@ -359,20 +289,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
/**
......@@ -1259,34 +1176,31 @@ public class FileHelper {
*/
public static void getExcel(String url, String fileName, HttpServletResponse response, HttpServletRequest request) {
try {
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
//2.设置文件头:最后一个参数是设置下载文件名
try {
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);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//通过文件路径获得File对象
File file = new File(url);
try (FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream())) {
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
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);
}
......
......@@ -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)
......
......@@ -5,15 +5,15 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog;
import com.yeejoin.equipmanage.common.enums.IndexStatusEnum;
import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.service.IEmergencyService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmService;
import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import com.yeejoin.equipmanage.service.ISupervisionVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
......@@ -257,214 +257,6 @@ public class SupervisionConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(equipmentSpecificAlarmService.alarmTrend(bizOrgCode));
}
// @PersonIdentify
// @TycloudOperation(ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "概览稳压泵信息")
// @GetMapping("/getPressurePumpInfo")
// public ResponseModel getPressurePumpInfo(CommonPageable commonPageable, @RequestParam(required = false) String bizOrgCode) {
// if (commonPageable.getPageNumber() == 0) {
// commonPageable.setPageNumber(1);
// }
// if (ObjectUtils.isEmpty(bizOrgCode)) {
// ReginParams reginParams = getSelectedOrgInfo();
// ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
// if (!ValidationUtil.isEmpty(personIdentity)) {
// bizOrgCode = personIdentity.getBizOrgCode();
// if (bizOrgCode == null) {
// return CommonResponseUtil.success(null);
// }
// }
// }
// Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
// Page<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null);
// List<Long> startTimeList = new ArrayList();
// List<Long> stopTimeList = new ArrayList();
// String prefix = null;
// for (Map<String, Object> item : pressurePumpInfo.getRecords()) {
// item.put("monthStartNum", 0);
// item.put("halfHourStartNum", 0);
// item.put("twoHourStartNum", 0);
// item.put("fourHourStartNum", 0);
// item.put("update_time", "--");
// item.put("equipment_index_name", "--");
// String suffix = null;
// String iotCode = item.get("iot_code").toString();
// if (iotCode.length() > 8) {
// prefix = iotCode.substring(0, 8);
// suffix = iotCode.substring(8);
// } else {
// throw new BadRequest("装备物联编码错误,请确认!");
// }
//
// String nowStrLong = DateUtils.getNowStrLong();
// Date mounthDate = null;
// try {
// mounthDate = DateUtils.getCurrentMonthStartTime(new Date());
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// Date halfHour = DateUtils.dateAddMinutes(null, -30);
// Date twoHour = DateUtils.dateAddHours(null, -2);
// Date fourHour = DateUtils.dateAddHours(null, -4);
// Date oneHour = DateUtils.dateAddHours(null, -1);
// String startDateStr = DateUtils.convertDateToString(mounthDate, DateUtils.DATE_TIME_PATTERN);
// String half = DateUtils.convertDateToString(halfHour, DateUtils.DATE_TIME_PATTERN);
// String two = DateUtils.convertDateToString(twoHour, DateUtils.DATE_TIME_PATTERN);
// String four = DateUtils.convertDateToString(fourHour, DateUtils.DATE_TIME_PATTERN);
// String one = DateUtils.convertDateToString(oneHour, DateUtils.DATE_TIME_PATTERN);
// ResponseModel mounthEntity = null;
// ResponseModel halfHourEntity = null;
// ResponseModel twoHourEntity = null;
// ResponseModel fourHourEntity = null;
// ResponseModel oneHourEntity = null;
// ResponseModel start = null;
// ResponseModel stop = null;
// try {
// mounthEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startDateStr, nowStrLong, prefix, suffix, pressurePumpStart);
// halfHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), half, nowStrLong, prefix, suffix, pressurePumpStart);
// twoHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), two, nowStrLong, prefix, suffix, pressurePumpStart);
// fourHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), four, nowStrLong, prefix, suffix, pressurePumpStart);
// oneHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), one, nowStrLong, prefix, suffix, pressurePumpStart);
// start = iotFeign.topSingleField("1", prefix, suffix, "true", pressurePumpStart);
// stop = iotFeign.topSingleField("1", prefix, suffix, "false", pressurePumpStart);
// } catch (Exception e) {
// e.printStackTrace();
// }
// if (200 == mounthEntity.getStatus()) {
// String json1 = JSON.toJSONString(mounthEntity.getResult());
// List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
// List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey(pressurePumpStart) && t.get(pressurePumpStart).equals("true"))).collect(Collectors.toList());
// int num = collect.size();
// item.put("monthStartNum", num);
// }
// if (200 == halfHourEntity.getStatus()) {
// String json1 = JSON.toJSONString(halfHourEntity.getResult());
// List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
// List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey(pressurePumpStart) && t.get(pressurePumpStart).equals("true"))).collect(Collectors.toList());
// int num = collect.size();
// item.put("halfHourStartNum", num);
// }
// if (200 == twoHourEntity.getStatus()) {
// String json1 = JSON.toJSONString(twoHourEntity.getResult());
// List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
// List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey(pressurePumpStart) && t.get(pressurePumpStart).equals("true"))).collect(Collectors.toList());
// int num = collect.size();
// item.put("twoHourStartNum", num);
// }
// if (200 == fourHourEntity.getStatus()) {
// String json1 = JSON.toJSONString(fourHourEntity.getResult());
// List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
// List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey(pressurePumpStart) && t.get(pressurePumpStart).equals("true"))).collect(Collectors.toList());
// int num = collect.size();
// item.put("fourHourStartNum", num);
// }
// if (200 == oneHourEntity.getStatus()) {
// String json1 = JSON.toJSONString(oneHourEntity.getResult());
// List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
// List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey(pressurePumpStart) && t.get(pressurePumpStart).equals("true"))).collect(Collectors.toList());
// int num = collect.size();
// item.put("oneHourStartNum", num);
// }
// if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) {
// String json1 = JSON.toJSONString(start.getResult());
// List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
// List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
// item.put("start", collect.get(0).get("time"));
// }
// if (200 == stop.getStatus() && !ObjectUtils.isEmpty(stop.getResult())) {
// String json1 = JSON.toJSONString(stop.getResult());
// List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
// List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
// item.put("stop", collect.get(0).get("time"));
// }
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// long nowDateTime = new Date().getTime();//当前时间戳
// boolean time = true;
// String startTime = null;
// String stopTime = null;
// Long start_time = 0L;
// Long stop_time = 0L;
// Date startDate = null;
// Date stopDate = null;
// if (!ObjectUtils.isEmpty(item.get("start"))) {
// startTime = item.get("start").toString().substring(0, 19).replace("T", " ");
// startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8);
// startTimeList.add(startDate.getTime());
// start_time = startDate.getTime();
// item.put("startTime", startDate);
// } else {
// item.put("startTime", 0);
// }
// if (!ObjectUtils.isEmpty(item.get("stop"))) {
// stopTime = item.get("stop").toString().substring(0, 19).replace("T", " ");
// stopDate = DateUtils.dateAddHours(DateUtils.longStr2Date(stopTime), +8);
// stopTimeList.add(stopDate.getTime());
// stop_time = stopDate.getTime();
// item.put("stopTime", stopDate);
// } else {
// item.put("stopTime", 0);
// }
// Map<String, Object> stateMap = fireFightingSystemMapper.queryPressureNowSignalBySpecificId((Long) item.get("id"));
// Long update_date = 0L;
// if (!ObjectUtils.isEmpty(stateMap)) {
// try {
// String time1 = stateMap.get("update_date").toString().replace("T", " ");
// update_date = sdf.parse(time1).getTime();
// } catch (ParseException e) {
// throw new RuntimeException(e);
// }
// }
// if (start_time - stop_time > 0) {
// long res = nowDateTime - start_time;
// long diffMinute = res / 1000 / 60;
// if (diffMinute > 5) {
// time = false;
// }
// item.put("upTime", diffMinute);
// item.put("equipment_index_name", update_date - start_time > 0 ? stateMap.get("equipment_index_name") : "启动");
// item.put("update_time", update_date - start_time > 0 ? stateMap.get("update_date") : startDate);
// } else if (start_time - stop_time < 0) {
// item.put("equipment_index_name", update_date - stop_time > 0 ? stateMap.get("equipment_index_name") : "停止");
// item.put("update_time", update_date - stop_time > 0 ? stateMap.get("update_date") : stopDate);
// } else {
// item.put("equipment_index_name", ObjectUtils.isEmpty(stateMap) ? "无信号" : stateMap.get("equipment_index_name"));
// item.put("update_time", ObjectUtils.isEmpty(stateMap) ? false : stateMap.get("update_date"));
// }
// item.put("stateDesc", Integer.parseInt(String.valueOf(item.get("isAlarm"))) == 0 && time ? "正常" : "异常");
// if ("正常".equals(item.get("stateDesc").toString())) {
// item.put("sort", 0);
// } else {
// item.put("sort", 1);
// }
// }
//// List<Long> startCollect = startTimeList.stream().sorted(Comparator.reverseOrder()).limit(1).collect(Collectors.toList());
//// List<Long> stopCollect = stopTimeList.stream().sorted(Comparator.reverseOrder()).limit(1).collect(Collectors.toList());
//// long res = 0L;
//// if (startCollect.size() > 0 && stopCollect.size() > 0) {
//// res = Math.abs(startCollect.get(0) - stopCollect.get(0));
//// }
//// long diffMinute = 0L;
//// diffMinute = res / 1000 / 60;
//// long finalDiffMinute = diffMinute;
//
// double finalDiffMinute = emergencyService.getPressurePumpIntervalTime(prefix, getAppKey(), getProduct(), getToken());
// pressurePumpInfo.getRecords().stream(
// ).map(item -> {
// item.put("startAndStopInterval", finalDiffMinute);
// if (finalDiffMinute > 5) {
// item.put("generalState", "异常");
// } else {
// item.put("generalState", "正常");
// }
// item.put("nameKey", pressurePumpStart);
// return item;
// }).collect(Collectors.toList());
// List<Map<String, Object>> records = pressurePumpInfo.getRecords();
// records.sort((t1, t2) -> t2.get("sort").toString().compareTo(t1.get("sort").toString()));
// pressurePumpInfo.setRecords(records);
// return CommonResponseUtil.success(pressurePumpInfo);
// }
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "概览稳压泵信息")
......@@ -484,7 +276,7 @@ public class SupervisionConfigureController extends AbstractBaseController {
}
}
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
Page<Map<String ,Object>> pressurePumpInfo = supervisionVideoService.queryPumpInfo(page,bizOrgCode);
Page<Map<String, Object>> pressurePumpInfo = supervisionVideoService.queryPumpInfo(page, bizOrgCode);
return CommonResponseUtil.success(pressurePumpInfo);
}
......@@ -637,64 +429,8 @@ public class SupervisionConfigureController extends AbstractBaseController {
}
}
}
List<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.selectAllPressurePumpInfo(bizOrgCode);
pressurePumpInfo.stream().map(item -> {
String prefix = null;
String suffix = null;
String iotCode = item.get("iot_code").toString();
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
ResponseModel start = null;
ResponseModel stop = null;
try {
start = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "true", pressurePumpStart);
stop = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "flase", pressurePumpStart);
} catch (Exception e) {
e.printStackTrace();
}
if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) {
String json1 = JSON.toJSONString(start.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
if (collect.size() > 0) {
String startTime = collect.get(0).get("time").substring(0, 19).replace("T", " ");
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8);
item.put("startTime", startDate);
} else {
item.put("startTime", "");
}
}
if (200 == stop.getStatus() && !ObjectUtils.isEmpty(stop.getResult())) {
String json1 = JSON.toJSONString(stop.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
if (collect.size() > 0) {
String stopTime = collect.get(0).get("time").substring(0, 19).replace("T", " ");
Date stopDate = DateUtils.dateAddHours(DateUtils.longStr2Date(stopTime), +8);
item.put("stopTime", stopDate);
} else {
item.put("stopTime", "");
}
}
return item;
}).collect(Collectors.toList());
return CommonResponseUtil.success(pressurePumpInfo);
// ReginParams reginParams = getSelectedOrgInfo();
// ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
// if (!ValidationUtil.isEmpty(personIdentity)) {
// bizOrgCode = personIdentity.getBizOrgCode();
// if (bizOrgCode == null) {
// return CommonResponseUtil.success(null);
// }
// }
// List<Map<String, Object>> pressurePumps = fireFightingSystemMapper.selectPressureDetails(bizOrgCode);
// return CommonResponseUtil.success(pressurePumps);
List<Map<String, Object>> list = supervisionVideoService.selectPressureDetails(bizOrgCode);
return CommonResponseUtil.success(list);
}
......@@ -702,7 +438,10 @@ public class SupervisionConfigureController extends AbstractBaseController {
@RequestMapping(value = "/selectPipePressureDetail", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "管网压力详情", produces = "application/json;charset=UTF-8", notes = "管网压力详情")
public ResponseModel selectPipePressureDetail(@RequestParam(value = "equipmentSpecificId") String equipmentSpecificId) {
public ResponseModel selectPipePressureDetail(@RequestParam(value = "equipmentSpecificId") String equipmentSpecificId,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime
) {
if (!StringUtil.isNotEmpty(equipmentSpecificId)) {
return CommonResponseUtil.success();
}
......@@ -728,11 +467,9 @@ public class SupervisionConfigureController extends AbstractBaseController {
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
String now = LocalDateTimeUtils.getNow();
ResponseModel mounthEntity = null;
try {
mounthEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), now.substring(0, 10) + " 00:00:00", now.substring(0, 10) + " 23:59:59", prefix, suffix, "FHS_PipePressureDetector_PipePressure");
mounthEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startTime, endTime, prefix, suffix, "FHS_PipePressureDetector_PipePressure");
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -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()));
}
});
}
......
package com.yeejoin.equipmanage.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
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.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.morphic.Morphic;
import com.yeejoin.amos.feign.morphic.model.ResourceDTO;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.equipmanage.common.dto.BuildingImportDto;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.BuildIsRiskDTO;
......@@ -44,6 +49,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.CommonUtil;
......@@ -51,6 +57,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -1527,7 +1534,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
//// String videoPointInScene = sourceScene.getVideoInScene() != null ? sourceScene.getVideoInScene() : "";
//1.查询楼层下的所有装备list
List<EquiplistSpecificBySystemVO> equipmentSpecifics = equipmentSpecificMapper.getListByWarehouseStructureId(floorId);
List<EquiplistSpecificBySystemVO> equipmentSpecifics = equipmentSpecificMapper.getListByWarehouseStructureId(floorId, IsIotEnum.isIot.getStatus());
equipmentSpecifics.forEach(e -> {
//已经标记则为已绑定
......@@ -1650,4 +1657,195 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
allListVo.forEach(s -> s.setAbsolutePosition(absolutePositionMap.get(s.getId())));
return allListVo;
}
@Override
@Transactional
public void importBuilding(MultipartFile file, ReginParams reginParams) {
// 机构信息
String companyCode = null;
String orgCode = null;
String companyName = null;
String dutyUser = null;
if (!ObjectUtils.isEmpty(reginParams) && !ObjectUtils.isEmpty(reginParams.getPersonIdentity())) {
if (!ObjectUtils.isEmpty(reginParams.getPersonIdentity().getBizOrgCode())) {
companyCode = reginParams.getPersonIdentity().getBizOrgCode();
companyName = reginParams.getPersonIdentity().getCompanyName();
}
if (!ObjectUtils.isEmpty(reginParams.getCompany()) && !ObjectUtils.isEmpty(reginParams.getCompany().getOrgCode())) {
orgCode = reginParams.getCompany().getOrgCode();
}
}
if (!ObjectUtils.isEmpty(reginParams.getUserModel()) || !ObjectUtils.isEmpty(reginParams.getUserModel().getSequenceNbr())) {
dutyUser = String.valueOf(reginParams.getUserModel().getSequenceNbr());
}
try {
ExcelReader reader = EasyExcel.read(file.getInputStream()).build();
List<BuildingImportDto> importList = ExcelUtil.readExcel(reader, BuildingImportDto.class, 0);
if (!ObjectUtils.isEmpty(importList)) {
// 获取所有建筑信息
List<BuildingImportDto> buildList = importList.stream().filter(item -> item.getDataType().equals("建筑@building")).collect(Collectors.toList());
// 建筑信息入库
importBuildMessage(buildList, orgCode, companyName, companyCode, dutyUser);
// 获取所有楼层信息
List<BuildingImportDto> floorList = importList.stream().filter(item -> item.getDataType().equals("楼层@floor")).collect(Collectors.toList());
// 楼层信息入库
importFloorMessage(floorList, orgCode, companyName, companyCode, dutyUser);
// 获取房间信息
List<BuildingImportDto> roomList = importList.stream().filter(item -> item.getDataType().equals("房间@room")).collect(Collectors.toList());
// 房间信息入库
importRoomMessage(roomList, orgCode, companyName, companyCode, dutyUser);
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
private void importBuildMessage(List<BuildingImportDto> collect, String orgCode, String bizOrgName, String bizOrgCode, String dutyUser) {
// 处理建筑数据、入库
collect.forEach(item -> {
HashMap<String, Object> buildingData = new HashMap<>();
// 建筑默认父级id 为顶级id
buildingData.put("parentId", 0);
// 建筑类型
String groupCode = null;
if (!ObjectUtils.isEmpty(item.getBuildingType())) {
if (item.getBuildingType().contains("@")) {
String[] certificates = item.getBuildingType().split("@");
groupCode = certificates[1];
}
}
// 建筑类别
String buildType = null;
if (!ObjectUtils.isEmpty(item.getBuildingCategory())) {
if (item.getBuildingType().contains("@")) {
String[] certificates = item.getBuildingCategory().split("@");
buildType = certificates[1];
buildingData.put("buildType", buildType);
}
}
// 建造日期
if (!ObjectUtils.isEmpty(item.getBuildDate())) {
buildingData.put("buildDate", item.getBuildDate());
}
// 公共字段处理
publicData(item, buildingData, bizOrgCode, bizOrgName, dutyUser);
// 保存建筑信息
saveForm(groupCode, orgCode, buildingData, null);
});
}
private void importFloorMessage(List<BuildingImportDto> collect, String orgCode, String bizOrgName, String bizOrgCode, String dutyUser) {
// 处理楼层数据、入库
collect.forEach(item -> {
HashMap<String, Object> buildingData = new HashMap<>();
// 楼层所在建筑父级id
if (!ObjectUtils.isEmpty(item.getInWhichBuild())) {
String parentBuildId = formInstanceMapper.selectParentBuildId(item.getInWhichBuild());
buildingData.put("inwhichBuild", parentBuildId);
buildingData.put("parentId", parentBuildId);
}
// 数据类型
String groupCode = null;
if (!ObjectUtils.isEmpty(item.getBuildingType())) {
if (item.getBuildingType().contains("@")) {
String[] certificates = item.getBuildingType().split("@");
groupCode = certificates[1];
}
}
// 公共字段处理
publicData(item, buildingData, bizOrgCode, bizOrgName, dutyUser);
// 保存楼层信息
saveForm(groupCode, orgCode, buildingData, null);
});
}
private void importRoomMessage(List<BuildingImportDto> collect, String orgCode, String bizOrgName, String bizOrgCode, String dutyUser) {
// 处理房间数据、入库
collect.forEach(item -> {
HashMap<String, Object> buildingData = new HashMap<>();
// 房间所在建筑父级id
if (!ObjectUtils.isEmpty(item.getInWhichBuild())) {
String parentBuildId = formInstanceMapper.selectParentBuildId(item.getInWhichBuild());
buildingData.put("inwhichBuild", parentBuildId);
buildingData.put("parentId", parentBuildId);
}
// 数据类型
String groupCode = null;
if (!ObjectUtils.isEmpty(item.getBuildingType())) {
if (item.getBuildingType().contains("@")) {
String[] certificates = item.getBuildingType().split("@");
groupCode = certificates[1];
}
}
// 操作人员持证数
if (!ObjectUtils.isEmpty(item.getLicensesNumber())) {
buildingData.put("certificatesPersonNum", item.getLicensesNumber());
}
// 安装位置
if (!ObjectUtils.isEmpty(item.getLocationDescription())) {
buildingData.put("installLoc", item.getLocationDescription());
}
// 维保单位
if (!ObjectUtils.isEmpty(item.getMaintenanceCompany())) {
buildingData.put("maintenanceUnit", item.getMaintenanceCompany());
}
// 每班人数
if (!ObjectUtils.isEmpty(item.getPersonNumber())) {
buildingData.put("personNum", item.getPersonNumber());
}
// 火灾预案
if (!ObjectUtils.isEmpty(item.getFirePlan())) {
buildingData.put("hasFirePlan", item.getFirePlan().equals("有") ? "true" : "false");
}
// 每班人数
if (!ObjectUtils.isEmpty(item.getPutDate())) {
buildingData.put("useDate", item.getPutDate());
}
// 每班人数
if (!ObjectUtils.isEmpty(item.getProtectedObjects())) {
buildingData.put("protectedObjects", item.getProtectedObjects());
}
// 公共字段处理
publicData(item, buildingData, bizOrgCode, bizOrgName, dutyUser);
// 保存楼层信息
saveForm(groupCode, orgCode, buildingData, null);
});
}
private void publicData(BuildingImportDto item, HashMap<String, Object> buildingData, String bizOrgCode, String bizOrgName, String dutyUser) {
// 编码
if (!ObjectUtils.isEmpty(item.getCode())) {
buildingData.put("code", item.getCode());
}
// 责任人
if (!ObjectUtils.isEmpty(dutyUser)) {
buildingData.put("dutyUser", dutyUser);
}
// 房间名称
if (!ObjectUtils.isEmpty(item.getBuildName())) {
buildingData.put("name", item.getBuildName());
}
// 房间地址
if (!ObjectUtils.isEmpty(item.getBuildingAddress())) {
buildingData.put("address", item.getBuildingAddress());
}
// 添加同步风险区域操作 默认false
if (!ObjectUtils.isEmpty(item.getBuildName())) {
buildingData.put("isRisk", "false");
}
// 机构编码
if (!ObjectUtils.isEmpty(bizOrgCode)) {
buildingData.put("bizOrgCode", bizOrgCode);
}
// 机构名称
if (!ObjectUtils.isEmpty(bizOrgName)) {
buildingData.put("bizOrgName", bizOrgName);
}
}
}
......@@ -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<>();
......
package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog;
import com.yeejoin.equipmanage.common.enums.IndexStatusEnum;
import com.yeejoin.equipmanage.common.enums.PressurePumpAnalysisEnum;
......@@ -11,7 +10,7 @@ import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.utils.UnitTransformUtil;
import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import com.yeejoin.equipmanage.mapper.EmergencyMapper;
import com.yeejoin.equipmanage.service.IEmergencyService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService;
......@@ -19,19 +18,22 @@ import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
import com.yeejoin.equipmanage.service.IPressurePumpService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.util.ObjectUtils;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
*
* 四横八纵应急模块接口服务类
*
*/
@Service
@Slf4j
......@@ -48,7 +50,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
private IEquipmentSpecificAlarmLogService equipmentSpecificAlarmLogService;
@Autowired
private IotFeign iotFeign;
private SupervisionVideoServiceImpl supervisionVideoService;
@Autowired
private IPressurePumpService pressurePumpService;
......@@ -59,6 +61,9 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Value("${equipment.pressurepump.pipepressure}")
private String pressurePumpPipePressure;
@Value("${equipment.pressurepump.start.cron}")
private String pumpYesterdayStart;
@Override
public List<Map<String, Object>> getSystemState(String bizOrgCode) {
List<Map<String, Object>> list = emergencyMapper.getSystemState(bizOrgCode);
......@@ -105,7 +110,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Override
public Page<Map<String, Object>> emergencyMaterialsDetails(Page<Map<String, Object>> page, String bizOrgCode) {
return emergencyMapper.selectEmergencyMaterialsDetails(page , bizOrgCode);
return emergencyMapper.selectEmergencyMaterialsDetails(page, bizOrgCode);
}
@Override
......@@ -157,7 +162,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
public List<Map<String, Object>> selectAlarmAnalysisCount(String systemType, String startDate, String endDate) {
List<String> strings = emergencyMapper.selectSystemCodes(systemType);
if (!CollectionUtils.isEmpty(strings)) {
return emergencyMapper.selectAlarmAnalysisCount( startDate, endDate,strings);
return emergencyMapper.selectAlarmAnalysisCount(startDate, endDate, strings);
}
return null;
......@@ -228,75 +233,124 @@ public class EmergencyServiceImpl implements IEmergencyService {
}
@Override
public List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token) {
List<Map<String , Object>> list = PressurePumpAnalysisEnum.getList();
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
if (!CollectionUtils.isEmpty(infoList)) {
Map map = infoList.get(0);
String equipmentCode = map.get("equipmentCode").toString();
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List<IotDataVO> redisDataList = pressurePumpService.getDataToRedis(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpStart, null);
List<IotDataVO> redisDataPipeList = pressurePumpService.getDataToRedis(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpPipePressure, null);
String nowStrLong = DateUtils.getDateNowString();
Date dateNow = DateUtils.getDateNow();
// 1. 判断稳压泵整体是否故障
List<EquipmentSpecificAlarmLog> alarmLogList = equipmentSpecificAlarmLogService.getAlarmLogInfoList(equipmentCode, nameKeys, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), PressurePumpRelateEnum.UN_CLEAN_TIME.getValue(), bizOrgCode);
list.get(0).put("value", CollectionUtils.isEmpty(alarmLogList) ? PressurePumpRelateEnum.NOT_FAULT.getValue() : PressurePumpRelateEnum.FAULT.getValue());
long interval = 0;
long duration = 0;
double pressureDiff = 0.0;
if (!CollectionUtils.isEmpty(redisDataList)) {
public List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String bizOrgCode) {
try {
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
if (!CollectionUtils.isEmpty(infoList)) {
Map map = infoList.get(0);
String equipmentCode = map.get("equipmentCode").toString();
String pipePressureEquipmentCode = map.get("pipePressureEquipmentCode").toString();
String faultNameKey = map.get("faultNameKey").toString();
String top = map.get("top").toString();
String countRedisKey = map.get("countRedisKey").toString();
long countExpire = Long.parseLong(map.get("countExpire").toString());
// 1. 判断稳压泵整体是否故障
List<EquipmentSpecificAlarmLog> alarmLogList = equipmentSpecificAlarmLogService.getAlarmLogInfoList(equipmentCode, faultNameKey, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), PressurePumpRelateEnum.UN_CLEAN_TIME.getValue(), bizOrgCode);
PressurePumpAnalysisEnum.PRESSURE_PUMP_FAULT.setValue(CollectionUtils.isEmpty(alarmLogList) ? PressurePumpRelateEnum.NOT_FAULT.getValue() : PressurePumpRelateEnum.FAULT.getValue());
// 获取稳压泵数据,redis没有,从iot取
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null);
List<IotDataVO> dataList = dataMap.get("dataList");
List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue");
List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse");
Map<String, List<IotDataVO>> dataPipMap = pressurePumpService.getDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pipePressureEquipmentCode, top, pressurePumpPipePressure, bizOrgCode, null);
List<IotDataVO> dataPipeList = dataPipMap.get("dataList");
String nowStrLong = DateUtils.getDateNowString();
Date dateNow = DateUtils.getDateNow();
// 2. 最近一次启停间隔
interval = pressurePumpService.getAllPressurePumpStartStopInterval(redisDataList, null, nowStrLong, bizOrgCode);
long interval = pressurePumpService.getAllPressurePumpStartStopInterval(dataList, dataListFilterTrue, dataListFilterFalse, nowStrLong);
PressurePumpAnalysisEnum.PRESSURE_PUMP_INTERVAL.setValue(interval);
// 3. 最近一次启动时长
duration = pressurePumpService.getAllPressurePumpStartStopDuration(redisDataList, null, nowStrLong, bizOrgCode);
long duration = pressurePumpService.getAllPressurePumpStartStopDuration(dataList, dataListFilterTrue, dataListFilterFalse, nowStrLong);
PressurePumpAnalysisEnum.PRESSURE_PUMP_DURATION.setValue(duration);
// 4. 半小时启动
int halfFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.HALF_HOUR.getValue()), dataListFilterTrue, dateNow);
PressurePumpAnalysisEnum.PRESSURE_PUMP_HALF.setValue(halfFrequency);
// 5. 今日启动次数,前3天启动次数的均值
// 获取稳压泵数据,redis没有,从iot取
Date startDate = DateUtils.dateAddDays(dateNow, Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue()));
String startTime = String.join(" ", DateUtils.dateFormat(startDate, DateUtils.DATE_PATTERN), "00:00:00");
String endTime = String.join(" ", DateUtils.dateFormat(dateNow, DateUtils.DATE_PATTERN), "00:00:00");
Map<String, List<PressurePumpCountVo>> dayAvgDataMap = pressurePumpService.getDateRangeCountList(pumpInfoList, startTime,endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, countExpire, bizOrgCode);
AtomicInteger dayAvgFrequency = new AtomicInteger();
if (!CollectionUtils.isEmpty(dayAvgDataMap)) {
for (List<PressurePumpCountVo> voList : dayAvgDataMap.values()) {
if (!CollectionUtils.isEmpty(voList)) {
voList.forEach(x -> dayAvgFrequency.addAndGet(x.getValue()));
}
}
}
DecimalFormat df = new DecimalFormat("0.0");
int dayAvgCount = dayAvgFrequency.get();
String dayAvgStartNum = dayAvgCount == 0 ? "0" : df.format(dayAvgCount / (double) Math.abs(Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue())));
PressurePumpAnalysisEnum.PRESSURE_PUMP_DAY_AVG.setValue(dayAvgStartNum);
// 6. 管网压力状态
pressureDiff = pressurePumpService.getAllPressurePumpPipePressureDiff(redisDataList, redisDataPipeList, null, null, nowStrLong, PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue());
} else {
String top = map.get("top").toString();
// 通过 equipmentCode 获取装备
double pressureDiff = pressurePumpService.getAllPressurePumpPipePressureDiff(dataList, dataPipeList, PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue());
PressurePumpAnalysisEnum.PRESSURE_PUMP_PIPE.setValue(pressureDiff > Double.parseDouble(PressurePumpRelateEnum.PIPE_PRESSURE_DIFF.getValue()) ? PressurePumpRelateEnum.PIPE_PRESSURE_ABNORMAL_STATUS.getValue() : PressurePumpRelateEnum.PIPE_PRESSURE_NORMAL_STATUS.getValue());
}
} catch (ParseException e) {
log.error("getPressurePumpDiagnosticAnalysis-->获取稳压泵诊断与分析失败:{}", e.getMessage());
}
return PressurePumpAnalysisEnum.getList();
}
@Override
public Map<String, Object> getPressurePumpStartStatistics(String startTime, String endTime, String bizOrgCode) {
Map<String, Object> map = new LinkedHashMap<>();
if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime) && StringUtils.isNotBlank(bizOrgCode)) {
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
if (!CollectionUtils.isEmpty(infoList)) {
Map infoMap = infoList.get(0);
String equipmentCode = infoMap.get("equipmentCode").toString();
String countRedisKey = infoMap.get("countRedisKey").toString();
long countExpire = Long.parseLong(infoMap.get("countExpire").toString());
// 获取所有稳压泵信息
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
// 从redis获取日期范围数据,没有从iot获取。redis存储数据并返回
Map<String, List<PressurePumpCountVo>> dateRangeCountMap = pressurePumpService.getDateRangeCountList(pumpInfoList, startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, countExpire, bizOrgCode);
if (!CollectionUtils.isEmpty(pumpInfoList)) {
String iotCode = pumpInfoList.get(0).get("iotCode").toString();
if (StringUtil.isNotEmpty(iotCode)) {
String prefix = iotCode.substring(0, 8);
// 获取物联稳压泵启动 top 数据
List<Map<String, String>> iotDataList = pressurePumpService.getIotTopSingleField(top, prefix, null,null, pressurePumpStart);
// 获取物联稳压泵管网压力 top 数据
List<Map<String, String>> iotDataPipeList = pressurePumpService.getIotTopSingleField(top, prefix, null,null, pressurePumpPipePressure);
// 2. 最近一次启停间隔
interval = pressurePumpService.getAllPressurePumpStartStopInterval(null, iotDataList, nowStrLong, bizOrgCode);
// 3. 最近一次启动时长
duration = pressurePumpService.getAllPressurePumpStartStopDuration(null, iotDataList, nowStrLong, bizOrgCode);
// 6. 管网压力状态
pressureDiff = pressurePumpService.getAllPressurePumpPipePressureDiff(null, null, iotDataList, iotDataPipeList, nowStrLong, PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue());
List<String> timeList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, DateUtils.DATE_PATTERN);
List<Map<String, Object>> yDataList = new ArrayList<>();
for (Map<String, Object> pumpMap : pumpInfoList) {
Object iotCode = pumpMap.get("iotCode");
Map<String, Object> dataMap = new HashMap<>();
List<Integer> dataList = new ArrayList<>();
for (String time : timeList) {
if (!ObjectUtils.isEmpty(iotCode) && !CollectionUtils.isEmpty(dateRangeCountMap)) {
String iotCodeStr = iotCode.toString();
List<PressurePumpCountVo> countVoList = dateRangeCountMap.get(iotCodeStr);
Map<String, List<PressurePumpCountVo>> collect = countVoList.stream().collect(Collectors.groupingBy(PressurePumpCountVo::getTime));
List<PressurePumpCountVo> data = collect.get(time);
dataList.add(CollectionUtils.isEmpty(data) ? 0 : data.get(0).getValue());
} else {
dataList.add(0);
}
}
dataMap.put("name", pumpMap.get("name"));
dataMap.put("data", dataList);
yDataList.add(dataMap);
}
List<String> collect = timeList.stream().map(x -> x.substring(5)).collect(Collectors.toList());
map.put("xData", collect);
map.put("yData", yDataList);
}
}
// 2. 最近一次启停间隔
list.get(1).put("value", interval);
// 3. 最近一次启动时长
list.get(2).put("value", duration);
// 4. 半小时启动
int halfFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.HALF_HOUR.getValue()), dateNow);
list.get(3).put("value", halfFrequency);
// 5. 2小时启动
int twoFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.TWO_HOUR.getValue()), dateNow);
list.get(4).put("value", twoFrequency);
// 6. 管网压力状态
list.get(5).put("value", pressureDiff > Double.parseDouble(PressurePumpRelateEnum.PIPE_PRESSURE_DIFF.getValue()) ? PressurePumpRelateEnum.PIPE_PRESSURE_ABNORMAL_STATUS.getValue() : PressurePumpRelateEnum.PIPE_PRESSURE_NORMAL_STATUS.getValue());
}
return list;
return map;
}
@Override
public Map<String, Object> getPressurePumpStatusChart(String startTime, String endTime, String bizOrgCode, String appKey, String product, String token) {
public Map<String, Object> getPressurePumpStatusChart(String startTime, String endTime, String bizOrgCode) {
Map<String, Object> map = new LinkedHashMap<>();
try {
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
if (!CollectionUtils.isEmpty(infoList)) {
Date dateNow = DateUtils.getDateNow();
String dateNowString = DateUtils.getDateNowString();
Map infoMap = infoList.get(0);
String equipmentCode = infoMap.get("equipmentCode").toString();
// 获取稳压泵
......@@ -313,13 +367,12 @@ public class EmergencyServiceImpl implements IEmergencyService {
if (iotCode != null) {
// 判断开始时间,是否在redis缓存有效期之内,是,redis获取数据,否则,iot获取数据
int expire = Integer.parseInt(infoMap.get("expire").toString()) * -1;
Date dateNow = DateUtils.getDateNow();
Date beforeDate = DateUtils.dateAddSeconds(dateNow, expire);
Date startDate = DateUtils.convertStrToDate(startTime, DateUtils.DATE_TIME_PATTERN);
Date endDate = DateUtils.convertStrToDate(endTime, DateUtils.DATE_TIME_PATTERN);
if (DateUtils.dateCompare(startDate, beforeDate) >= 0) {
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List<IotDataVO> redisDataList = pressurePumpService.getDataToRedisByDateBetween(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpStart, iotCode.toString(), startDate, endDate);
List<IotDataVO> redisDataList = pressurePumpService.getDataToRedisByDateBetween(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpStart, iotCode.toString(), startDate, endDate, bizOrgCode);
if (!CollectionUtils.isEmpty(redisDataList)) {
List<Map<String, String>> dataList = new ArrayList<>();
redisDataList.forEach(y -> {
......@@ -341,11 +394,11 @@ public class EmergencyServiceImpl implements IEmergencyService {
}
}
}
timeSet.add(dateNowString);
// 数据时间排序
List<String> sortTimeList = new ArrayList<>(timeSet);
Collections.sort(sortTimeList);
// 数据时间截取,MM-dd HH:mm
// List<String> sortTimeCollectList = sortTimeList.stream().map(x -> DateUtils.dateFormat(DateUtils.convertStrToDate(x, DateUtils.DATE_TIME_PATTERN),DateUtils.MONTH_DAY_HOUR_MINUTE_PATTERN)).collect(Collectors.toList());
List<String> sortTimeCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 3)).collect(Collectors.toList());
// 数据时间截取,MM-dd HH
List<String> sortTimeTmpCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 6)).collect(Collectors.toList());
......@@ -373,14 +426,15 @@ public class EmergencyServiceImpl implements IEmergencyService {
Collections.reverse(dataList);
Map<String, List<Map<String, String>>> dataMap = dataList.stream().filter(y -> y.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue())).collect(Collectors.groupingBy(e -> e.get("createdTime").substring(5, 16)));
List<Map<String, String>> yDataList = null;
String flag = null;
for (String t : timeList) {
List<Map<String, String>> data = dataMap.get(t);
if (!CollectionUtils.isEmpty(data)) {
yDataList = data.stream().filter(o -> PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(o.get(pressurePumpStart))).collect(Collectors.toList());
String flag = data.get(data.size() - 1).get(pressurePumpStart);
yList.add(!CollectionUtils.isEmpty(yDataList) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()) : PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(flag) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()): Integer.parseInt(PressurePumpRelateEnum.STOP.getValue()));
flag = data.get(data.size() - 1).get(pressurePumpStart);
yList.add(!CollectionUtils.isEmpty(yDataList) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()) : PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(flag) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()) : Integer.parseInt(PressurePumpRelateEnum.STOP.getValue()));
} else {
yList.add(Integer.parseInt(PressurePumpRelateEnum.STOP.getValue()));
yList.add(StringUtils.isNotBlank(flag) && PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(flag) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()) : Integer.parseInt(PressurePumpRelateEnum.STOP.getValue()));
}
}
} else {
......@@ -404,7 +458,63 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Override
public Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus) {
public Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page, String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus) {
return emergencyMapper.alarmList(page, bizOrgCode, types, emergencyLevels, name, cleanStatus, handleStatus);
}
//稳压泵定时向缓存中存昨日启动次数任务
@Scheduled(cron = "${equipment.pressurepump.start.cron}")
private void stationDoubleReport() {
System.out.println("开始定时存储昨日稳压泵启动次数,定时时间为:" + pumpYesterdayStart);
getPressurePumpDay();
}
@Override
public Map<String, List<PressurePumpCountVo>> getPressurePumpDay() {
Map<String, List<PressurePumpCountVo>> dataMap = new HashMap<>();
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
if (!CollectionUtils.isEmpty(infoList)) {
try {
Date dateNow = DateUtils.convertStrToDate(DateUtils.getDateNowString(), DateUtils.DATE_PATTERN);
Date beforeDate = DateUtils.dateAddDays(dateNow, Integer.parseInt(PressurePumpRelateEnum.CRON_BEFORE_DAY.getValue()));
// iot获取数据,返回并存储redis
String startTime = DateUtils.convertDateToString(beforeDate, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(dateNow, DateUtils.DATE_TIME_PATTERN);
Map infoMap = infoList.get(0);
String equipmentCode = infoMap.get("equipmentCode").toString();
String countRedisKey = infoMap.get("countRedisKey").toString();
long countExpire = Long.parseLong(infoMap.get("countExpire").toString());
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, null);
if (!CollectionUtils.isEmpty(pumpInfoList)){
Map<String, String> params = new HashMap<>();
for (Map<String, Object> map : pumpInfoList) {
// iot获取数据,返回并存储redis
Object iotCode = map.get("iotCode");
Object orgCode = map.get("bizOrgCode");
String bizOrgCode = ObjectUtils.isEmpty(orgCode) ? "" : orgCode.toString();
if (!ObjectUtils.isEmpty(iotCode) && !ObjectUtils.isEmpty(bizOrgCode)) {
// 获取公司顶级bizOrgCode
params.put("bizOrgType", PressurePumpRelateEnum.BIZ_ORG_TYPE_COMPANY.getValue());
params.put("bizOrgCode", bizOrgCode);
List<OrgUsrDto> orgUsrDtoList = pressurePumpService.getOrgUsrDtoInfo(params);
if (!CollectionUtils.isEmpty(orgUsrDtoList)) {
bizOrgCode = orgUsrDtoList.get(0).getBizOrgCode();
if (StringUtils.isNotBlank(bizOrgCode)) {
String iotCodeStr = iotCode.toString();
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(0, 8);
String suffix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(8);
List<PressurePumpCountVo> dataList = pressurePumpService.getIotCountData(startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), pressurePumpStart, countExpire, bizOrgCode);
dataMap.put(iotCodeStr, dataList);
}
}
}
}
}
} catch (ParseException e) {
log.error("redis存稳压泵昨天启动次数失败:{}", e.getMessage());
}
}
return dataMap;
}
}
......@@ -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) {
......
......@@ -2,12 +2,14 @@ package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.OrgUsrMapper;
import com.yeejoin.equipmanage.service.IPressurePumpService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -18,9 +20,13 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.*;
......@@ -36,6 +42,9 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
@Autowired
private RedisUtils redisUtils;
@Autowired
private OrgUsrMapper orgUsrMapper;
@Value("classpath:/json/nameKeyInfo.json")
private Resource nameKeyInfo;
......@@ -47,36 +56,42 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
@Override
@Async
public void saveDataToRedis(List<IotDataVO> iotDatalist, String topic) {
String pressurePumpValue = PressurePumpRelateEnum.PRESSURE_PUMP.getValue();
// 获取配置JSON信息集合
List<Map> list = getNameKeyInfoList(pressurePumpValue);
if (CollectionUtils.isNotEmpty(list)) {
Map map = list.get(0);
String nameKey = map.get("nameKey").toString();
int expire = Integer.parseInt(map.get("expire").toString());
String nowString = DateUtils.getDateNowString();
long timeMillis = System.currentTimeMillis();
for (IotDataVO vo : iotDatalist) {
String key = vo.getKey();
if (nameKey.contains(vo.getKey())) {
vo.setCreatedTime(nowString);
String[] split = topic.split("/");
topic = split.length > 2 ? String.join("", split[0], split[1]) : "";
redisUtils.set(String.join(":", pressurePumpValue, key, topic, String.valueOf(timeMillis)), JSONObject.toJSONString(vo), expire);
public void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode) {
// 获取公司顶级bizOrgCode
Map<String, String> params = new HashMap<>();
params.put("bizOrgType", PressurePumpRelateEnum.BIZ_ORG_TYPE_COMPANY.getValue());
params.put("bizOrgCode", bizOrgCode);
List<OrgUsrDto> orgUsrDtoList = getOrgUsrDtoInfo(params);
if (CollectionUtils.isNotEmpty(orgUsrDtoList)) {
bizOrgCode = orgUsrDtoList.get(0).getBizOrgCode();
if (StringUtils.isNotBlank(bizOrgCode)) {
String pressurePumpValue = PressurePumpRelateEnum.PRESSURE_PUMP.getValue();
// 获取配置JSON信息集合
List<Map> list = getNameKeyInfoList(pressurePumpValue);
if (CollectionUtils.isNotEmpty(list) && StringUtils.isNotBlank(iotCode) && StringUtils.isNotBlank(bizOrgCode)) {
Map map = list.get(0);
String nameKey = map.get("nameKey").toString();
int expire = Integer.parseInt(map.get("expire").toString());
String nowString = DateUtils.getDateNowString();
long timeMillis = System.currentTimeMillis();
for (IotDataVO vo : iotDatalist) {
String key = vo.getKey();
if (nameKey.contains(vo.getKey())) {
vo.setCreatedTime(nowString);
redisUtils.set(String.join(":", pressurePumpValue, bizOrgCode, key, iotCode, String.valueOf(timeMillis)), JSON.toJSONString(vo), expire);
}
}
}
}
}
}
@Override
public List<IotDataVO> getDataToRedis(String infoCode, String nameKey, String iotCode) {
public List<IotDataVO> getDataToRedis(String infoCode, String nameKey, String iotCode, String bizOrgCode) {
List<IotDataVO> list = new ArrayList<>();
Set<String> keys = redisUtils.getKeys(String.join(":", infoCode, nameKey, StringUtils.isNotEmpty(iotCode) ? iotCode : ""));
Set<String> keys = redisUtils.getKeys(String.join(":", infoCode, bizOrgCode, nameKey, StringUtils.isNotEmpty(iotCode) ? iotCode : ""));
if (CollectionUtils.isNotEmpty(keys)) {
keys.forEach(x -> {
list.add(JSON.parseObject(redisUtils.get(x).toString(), IotDataVO.class));
});
keys.forEach(x -> list.add(JSON.parseObject(redisUtils.get(x).toString(), IotDataVO.class)));
// 时间倒序排序
list.sort((t1, t2) -> t2.getCreatedTime().compareTo(t1.getCreatedTime()));
}
......@@ -84,9 +99,9 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
@Override
public List<IotDataVO> getDataToRedisByDateBetween(String infoCode, String nameKey, String iotCode, Date startDate, Date endDate) {
public List<IotDataVO> getDataToRedisByDateBetween(String infoCode, String nameKey, String iotCode, Date startDate, Date endDate, String bizOrgCode) {
List<IotDataVO> list = new ArrayList<>();
Set<String> keys = redisUtils.getKeys(String.join(":", infoCode, nameKey, StringUtils.isNotEmpty(iotCode) ? iotCode : ""));
Set<String> keys = redisUtils.getKeys(String.join(":", infoCode, bizOrgCode, nameKey, StringUtils.isNotEmpty(iotCode) ? iotCode : ""));
if (CollectionUtils.isNotEmpty(keys)) {
keys.forEach(x -> {
String[] split = x.split(":");
......@@ -106,6 +121,29 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return list;
}
public List<PressurePumpCountVo> getCountDataToRedisByDateBetween(String infoCode, String countRedisKey, String nameKey, String iotCode, Date startDate, Date endDate, String bizOrgCode) {
List<PressurePumpCountVo> list = new ArrayList<>();
Set<String> keys = redisUtils.getKeys(String.join(":", infoCode, bizOrgCode, countRedisKey, nameKey, StringUtils.isNotEmpty(iotCode) ? iotCode : ""));
if (CollectionUtils.isNotEmpty(keys)) {
keys.forEach(x -> {
String[] split = x.split(":");
String time = split.length > 0 ? (split[split.length - 1]) : "";
try {
Date date = DateUtils.convertStrToDate(time, DateUtils.DATE_PATTERN);
// 结束日期不包含今天,获取3天前数据
if (DateUtils.dateCompare(date, startDate) >= 0 && DateUtils.dateCompare(endDate, date) > 0) {
list.add(JSON.parseObject(redisUtils.get(x).toString(), PressurePumpCountVo.class));
}
} catch (ParseException e) {
log.error("getDataToRedisByDateBetween-->字符串转日期失败:{}", e.getMessage());
}
});
// 时间升序排序
list.sort(Comparator.comparing(PressurePumpCountVo::getTime));
}
return list;
}
@Override
public List<Map> getNameKeyInfoList(String code) {
String json = null;
......@@ -114,7 +152,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
} catch (IOException e) {
log.error("获取指标JSON配置信息失败:{}", e.getMessage());
}
List<Map> list = JSONObject.parseArray(json, Map.class);
List<Map> list = JSON.parseArray(json, Map.class);
if (CollectionUtils.isNotEmpty(list)) {
return list.stream().filter(x -> code.equals(x.get("code"))).collect(Collectors.toList());
}
......@@ -122,157 +160,199 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
@Override
public long getAllPressurePumpStartStopInterval(List<IotDataVO> redisDataList, List<Map<String, String>> iotDataList, String nowStrLong, String bizOrgCode) {
public long getAllPressurePumpStartStopInterval(List<IotDataVO> dataList, List<IotDataVO> dataListFilterTrue, List<IotDataVO> dataListFilterFalse, String nowStrLong) {
String intervalTime1 = nowStrLong;
String intervalTime2 = nowStrLong;
if (CollectionUtils.isNotEmpty(redisDataList)) {
IotDataVO iotDataVO = redisDataList.get(0);
String value = iotDataVO.getValue().toString();
String createdTime = iotDataVO.getCreatedTime();
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
intervalTime1 = createdTime;
if (CollectionUtils.isNotEmpty(falseDataList)) {
// 获取最新的停止时间
intervalTime2 = falseDataList.get(0).getCreatedTime();
}
} else {
List<IotDataVO> trueDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新的启动时间
intervalTime1 = trueDataList.get(0).getCreatedTime();
// 获取大于启动信号,且最近停止信号的时间
String finalIntervalTime = intervalTime1;
List<IotDataVO> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalIntervalTime, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(timeList)) {
intervalTime2 = timeList.get(timeList.size() - 1).getCreatedTime();
}
}
}
} else if (CollectionUtils.isNotEmpty(iotDataList)) {
// redis缓存为空,从iot获取top条数据,top来源 nameKeyInfo.json 配置
return getAllPressurePumpStartStopIntervalByIot(iotDataList, nowStrLong);
if (!ObjectUtils.isEmpty(dataListFilterTrue) && dataListFilterTrue.size() > 1) {
//获取启动列表中
intervalTime1 = dataListFilterTrue.get(0).getCreatedTime();
intervalTime2 = dataListFilterTrue.get(1).getCreatedTime();
}
// 结果向上取整
double ceil = Math.ceil(Math.abs(DateUtils.getDurationSeconds(intervalTime1, intervalTime2, DateUtils.DATE_TIME_PATTERN)) * 1.0 / Double.parseDouble(PressurePumpRelateEnum.ONE_HOUR_MINUTE.getValue()));
return new Double(ceil).longValue();
}
public long getAllPressurePumpStartStopIntervalByIot(List<Map<String, String>> iotDataList, String nowStrLong) {
String intervalTime1 = nowStrLong;
String intervalTime2 = nowStrLong;
if (CollectionUtils.isNotEmpty(iotDataList)) {
String value = iotDataList.get(0).get(pressurePumpStart);
String createdTime = iotDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
List<Map<String, String>> falseDataList = getIotDataFilterList(iotDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
List<Map<String, String>> trueDataList = getIotDataFilterList(iotDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
intervalTime1 = createdTime;
if (CollectionUtils.isNotEmpty(falseDataList)) {
intervalTime2 = falseDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
}
} else {
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新的启动时间
intervalTime1 = trueDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String finalIntervalTime = intervalTime1;
List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalIntervalTime, x.get(PressurePumpRelateEnum.CREATED_TIME.getValue()), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(timeList)) {
intervalTime2 = timeList.get(timeList.size() - 1).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
@Override
public List<IotDataVO> getDataListFilter(List<IotDataVO> dataList, String value) {
return dataList.stream().filter(x -> x.getValue() != null && StringUtils.isNotBlank(x.getCreatedTime()) && value.equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
}
@Override
public Map<String, List<IotDataVO>> getDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String equipmentCode, String top, String nameKey, String bizOrgCode, String iotCode) {
Map<String, List<IotDataVO>> map = new HashMap<>();
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List<IotDataVO> dataList = getDataToRedis(infoCode, nameKey, iotCode, bizOrgCode);
// 过滤指定值数据
List<IotDataVO> dataListFilterTrue = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
List<IotDataVO> dataListFilterFalse = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
//获取iot的数据
if (pressurePumpPipePressure.equalsIgnoreCase(nameKey)) {
if (ObjectUtils.isEmpty(dataList) || dataList.size() < 2) {
dataList = getIotData(pumpInfoList, top, nameKey);
}
} else {
if (ObjectUtils.isEmpty(dataList) || ObjectUtils.isEmpty(dataListFilterTrue) || ObjectUtils.isEmpty(dataListFilterFalse)) {
dataList = getIotData(pumpInfoList, top, nameKey);
dataListFilterTrue = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
dataListFilterFalse = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
}
}
map.put("dataList", dataList);
map.put("dataListFilterTrue", dataListFilterTrue);
map.put("dataListFilterFalse", dataListFilterFalse);
return map;
}
private List<IotDataVO> getIotData(List<Map<String, Object>> pumpInfoList, String top, String nameKey) {
List<IotDataVO> dataList = new ArrayList<>();
// 通过 equipmentCode 获取装备
if (!ObjectUtils.isEmpty(pumpInfoList)) {
String iotCode = pumpInfoList.get(0).get("iotCode").toString();
if (iotCode.length() > 8) {
String prefix = iotCode.substring(0, 8);
List<Map<String, String>> iotDataList = getIotTopSingleField(top, prefix, null, null, nameKey);
//将iot的List<Map<String, String>>转化为List<IotDataVO>类型
iotDataList.forEach(e -> {
try {
IotDataVO iotDataVO = (IotDataVO) mapToObject(e, IotDataVO.class, nameKey);
dataList.add(iotDataVO);
} catch (Exception el) {
throw new BadRequest("IOT数据类型转换失败");
}
}
});
}
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
// 结果向上取整
double ceil = Math.ceil(Math.abs(DateUtils.getDurationSeconds(intervalTime1, intervalTime2, DateUtils.DATE_TIME_PATTERN)) * 1.0 / Double.parseDouble(PressurePumpRelateEnum.ONE_HOUR_MINUTE.getValue()));
return new Double(ceil).longValue();
return dataList;
}
private List<IotDataVO> getRedisDataFilterList(List<IotDataVO> redisDataList, String value) {
return redisDataList.stream().filter(x -> value.equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
/**
* map 转化为对象
*
* @param map 需要转化的参数
* @param aClass 要转化成的对象
* @return 转化成功的对象
* @throws IllegalAccessException 非法访问异常
* @throws InstantiationException 实例化异常
*/
@Override
public Object mapToObject(Map<String, String> map, Class<?> aClass, String indexKey) throws IllegalAccessException, InstantiationException {
if (map.isEmpty()) {
return null;
}
Object o = aClass.newInstance();
Field[] declaredFields = o.getClass().getDeclaredFields();
for (Field field : declaredFields) {
int modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers)) {
continue;
}
// (此处如果不设置 无法获取对象的私有属性)
field.setAccessible(true);
if ("key".equals(field.getName())) {
field.set(o, indexKey);
} else if ("value".equals(field.getName())) {
field.set(o, map.get(indexKey));
} else {
field.set(o, map.get(field.getName()));
}
}
return o;
}
private List<Map<String, String>> getIotDataFilterList(List<Map<String, String>> iotDataList, String value) {
return iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && value.equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
@Override
public 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) {
Map<String, List<PressurePumpCountVo>> dataMap = new HashMap<>();
try {
if (CollectionUtils.isNotEmpty(pumpInfoList)) {
for (Map<String, Object> map : pumpInfoList) {
// iot获取数据,返回并存储redis
Object iotCode = map.get("iotCode");
if (!ObjectUtils.isEmpty(iotCode)) {
String iotCodeStr = iotCode.toString();
Date startDate = DateUtils.convertStrToDate(startTime, DateUtils.DATE_PATTERN);
Date endDate = DateUtils.convertStrToDate(endTime, DateUtils.DATE_PATTERN);
List<PressurePumpCountVo> dataList = getCountDataToRedisByDateBetween(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, nameKey, iotCodeStr, startDate, endDate, bizOrgCode);
Long days = DateUtils.getDurationDays(startTime, endTime, DateUtils.DATE_TIME_PATTERN);
if (CollectionUtils.isEmpty(dataList) || (CollectionUtils.isNotEmpty(dataList) && dataList.size() < days)) {
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(0, 8);
String suffix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(8);
dataList = getIotCountData(startTime, endTime, infoCode, countRedisKey, prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), nameKey, countExpire, bizOrgCode);
}
dataMap.put(iotCodeStr, dataList);
}
}
}
} catch (ParseException e) {
log.error("获取稳压泵范围启动统计失败:{}", e.getMessage());
}
return dataMap;
}
private List<IotDataVO> getRedisDataFilterList(List<IotDataVO> redisDataList, String value, Date beforeDate) {
if (beforeDate != null) {
return redisDataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.getCreatedTime()), beforeDate) >= 0 && value.equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
@Override
public List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String countRedisKey, String prefix, String suffix, String key, String fieldKey, long expire, String bizOrgCode) {
List<Map<String, String>> dataMapList = getIotCommonListData(startTime, endTime, prefix, suffix, key, fieldKey);
if (CollectionUtils.isNotEmpty(dataMapList) && StringUtils.isNotBlank(key)) {
Map<String, List<Map<String, String>>> dataMap = dataMapList.stream().filter(y -> y.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && y.get(fieldKey) != null && key.equalsIgnoreCase(y.get(fieldKey))).collect(Collectors.groupingBy(e -> e.get(PressurePumpRelateEnum.CREATED_TIME.getValue()).substring(0, 10)));
if (!dataMap.isEmpty()) {
List<PressurePumpCountVo> dataList = new ArrayList<>();
String iotCode = String.join("", StringUtils.isNotEmpty(prefix) ? prefix : "", StringUtils.isNotEmpty(suffix) ? suffix : "");
for (String time : dataMap.keySet()) {
PressurePumpCountVo countVo = new PressurePumpCountVo();
countVo.setTime(time);
countVo.setValue(dataMap.get(time).size());
// 获取的数据存储到redis
String topic = String.join(":", infoCode, bizOrgCode, countRedisKey, fieldKey, iotCode, time);
countVo.setIotCode(topic);
redisUtils.set(topic, JSON.toJSONString(countVo), expire);
dataList.add(countVo);
}
return dataList;
}
}
return redisDataList.stream().filter(x -> value.equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
return Collections.emptyList();
}
private List<Map<String, String>> getIotDataFilterList(List<Map<String, String>> iotDataList, String value, Date beforeDate) {
private List<IotDataVO> getDataListFilter(List<IotDataVO> dataList, Date beforeDate) {
if (beforeDate != null) {
return iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && DateUtils.dateCompare(DateUtils.longStr2Date(x.get(PressurePumpRelateEnum.CREATED_TIME.getValue())), beforeDate) >= 0 && value.equalsIgnoreCase(x.get(pressurePumpPipePressure))).collect(Collectors.toList());
return dataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.getCreatedTime()), beforeDate) >= 0).collect(Collectors.toList());
}
return iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && value.equalsIgnoreCase(x.get(pressurePumpPipePressure))).collect(Collectors.toList());
return dataList;
}
@Override
public int getAllPressurePumpStartFrequency(double hour, Date dateNow) {
List<IotDataVO> list = getDataToRedis(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpStart, null);
if (CollectionUtils.isNotEmpty(list)) {
public int getAllPressurePumpStartFrequency(double hour, List<IotDataVO> dataList, Date dateNow) {
if (CollectionUtils.isNotEmpty(dataList)) {
Date beforeDate = DateUtils.dateAddMinutes(dateNow, (int) (hour * Integer.parseInt(PressurePumpRelateEnum.ONE_HOUR_MINUTE.getValue()) * -1));
List<IotDataVO> collect = list.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.getCreatedTime()), beforeDate) >= 0 && PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
List<IotDataVO> collect = dataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.getCreatedTime()), beforeDate) >= 0).collect(Collectors.toList());
return collect.size();
}
return 0;
}
@Override
public long getAllPressurePumpStartStopDuration(List<IotDataVO> redisDataList, List<Map<String, String>> iotDataList, String nowStrLong, String bizOrgCode) {
public long getAllPressurePumpStartStopDuration(List<IotDataVO> dataList, List<IotDataVO> dataListFilterTrue, List<IotDataVO> dataListFilterFalse, String nowStrLong) {
String durationTime = nowStrLong;
if (CollectionUtils.isNotEmpty(redisDataList)) {
IotDataVO iotDataVO = redisDataList.get(0);
if (CollectionUtils.isNotEmpty(dataList)) {
IotDataVO iotDataVO = dataList.get(0);
String value = iotDataVO.getValue().toString();
String createdTime = iotDataVO.getCreatedTime();
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
durationTime = createdTime;
} else {
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
List<IotDataVO> trueDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
if (CollectionUtils.isNotEmpty(dataListFilterFalse) && CollectionUtils.isNotEmpty(dataListFilterTrue)) {
// 获取最新启动时间
durationTime = trueDataList.get(0).getCreatedTime();
durationTime = dataListFilterTrue.get(0).getCreatedTime();
// 获取大于启动信号,且最近停止信号的时间
String finalDurationTime = durationTime;
List<IotDataVO> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalDurationTime, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
List<IotDataVO> timeList = dataListFilterFalse.stream().filter(x -> DateUtils.getDurationSeconds(finalDurationTime, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(timeList)) {
nowStrLong = timeList.get(timeList.size() - 1).getCreatedTime();
}
}
}
} else if (CollectionUtils.isNotEmpty(iotDataList)) {
return getAllPressurePumpStartStopDurationByIot(iotDataList, nowStrLong);
}
// 结果向上取整
double ceil = Math.ceil(Math.abs(DateUtils.getDurationSeconds(durationTime, nowStrLong, DateUtils.DATE_TIME_PATTERN)) * 1.0 / Double.parseDouble(PressurePumpRelateEnum.ONE_HOUR_MINUTE.getValue()));
return new Double(ceil).longValue();
}
public long getAllPressurePumpStartStopDurationByIot(List<Map<String, String>> iotDataList, String nowStrLong) {
String durationTime = nowStrLong;
if (CollectionUtils.isNotEmpty(iotDataList)) {
String value = iotDataList.get(0).get(pressurePumpStart);
List<Map<String, String>> falseDataList = getIotDataFilterList(iotDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
List<Map<String, String>> trueDataList = getIotDataFilterList(iotDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
durationTime = iotDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
} else {
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新启动时间
durationTime = trueDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String finalDurationTime = durationTime;
List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalDurationTime, x.get(PressurePumpRelateEnum.CREATED_TIME.getValue()), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(timeList)) {
nowStrLong = timeList.get(timeList.size() - 1).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
}
}
}
}
// 结果向上取整
double ceil = Math.ceil(Math.abs(DateUtils.getDurationSeconds(durationTime, nowStrLong, DateUtils.DATE_TIME_PATTERN)) * 1.0 / Double.parseDouble(PressurePumpRelateEnum.ONE_HOUR_MINUTE.getValue()));
......@@ -280,47 +360,26 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
@Override
public double getAllPressurePumpPipePressureDiff(List<IotDataVO> redisDataList, List<IotDataVO> redisDataPipeList, List<Map<String, String>> iotDataList, List<Map<String, String>> iotDataPipeList, String nowStrLong, String minutes) {
if (CollectionUtils.isNotEmpty(redisDataList) && CollectionUtils.isNotEmpty(redisDataPipeList)) {
IotDataVO iotDataVO = redisDataList.get(0);
public double getAllPressurePumpPipePressureDiff(List<IotDataVO> dataList, List<IotDataVO> dataPipeList, String minutes) {
if (CollectionUtils.isNotEmpty(dataList) && CollectionUtils.isNotEmpty(dataPipeList)) {
IotDataVO iotDataVO = dataList.get(0);
String value = iotDataVO.getValue().toString();
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
List<IotDataVO> falseDataList = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList)) {
String createdTime = falseDataList.get(0).getCreatedTime();
try {
Date stop5BeforeDate = DateUtils.dateAddMinutes(DateUtils.convertStrToDate(createdTime, DateUtils.DATE_TIME_PATTERN), Integer.parseInt(minutes));
// 获取指定之前时间,指定值数据
List<IotDataVO> dataFilterList = getRedisDataFilterList(redisDataPipeList, value, stop5BeforeDate);
List<IotDataVO> dataFilterList = getDataListFilter(dataPipeList, stop5BeforeDate);
if (CollectionUtils.isNotEmpty(dataFilterList)) {
double val1 = Double.parseDouble(redisDataPipeList.get(0).getValue().toString());
double val2 = Double.parseDouble(dataFilterList.get(dataFilterList.size() - 1).getValue().toString());
return Math.abs(val1 - val2);
}
} catch (ParseException e) {
log.error("获取所有稳压泵管网压力差失败:{}", e.getMessage());
}
}
}
}
return getAllPressurePumpPipePressureDiffByIot(iotDataList, iotDataPipeList);
}
private double getAllPressurePumpPipePressureDiffByIot(List<Map<String, String>> iotDataList, List<Map<String, String>> iotDataPipeList) {
if (CollectionUtils.isNotEmpty(iotDataList) && CollectionUtils.isNotEmpty(iotDataPipeList)) {
String value = iotDataList.get(0).get(pressurePumpStart);
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
List<Map<String, String>> falseDataList = getIotDataFilterList(iotDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList)) {
String createdTime = falseDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
try {
Date stop5BeforeDate = DateUtils.dateAddMinutes(DateUtils.convertStrToDate(createdTime, DateUtils.DATE_TIME_PATTERN), Integer.parseInt(PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue()));
// 获取指定之前时间,指定值数据
List<Map<String, String>> dataFilterList = getIotDataFilterList(iotDataPipeList, value, stop5BeforeDate);
if (CollectionUtils.isNotEmpty(dataFilterList)) {
double val1 = Double.parseDouble(iotDataPipeList.get(0).get(pressurePumpPipePressure));
double val2 = Double.parseDouble(dataFilterList.get(dataFilterList.size() - 1).get(pressurePumpPipePressure));
return Math.abs(val1 - val2);
Object value1 = dataPipeList.get(0).getValue();
Object value2 = dataPipeList.get(dataFilterList.size() - 1).getValue();
if (!ObjectUtils.isEmpty(value1) && !ObjectUtils.isEmpty(value2)) {
double val1 = Double.parseDouble(value1.toString());
double val2 = Double.parseDouble(value2.toString());
return Math.abs(val1 - val2);
}
}
} catch (ParseException e) {
log.error("获取所有稳压泵管网压力差失败:{}", e.getMessage());
......@@ -351,4 +410,8 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return Collections.emptyList();
}
public List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map) {
return orgUsrMapper.getOrgUsrDtoInfo(map);
}
}
......@@ -8,8 +8,10 @@ import com.yeejoin.equipmanage.common.entity.vo.AlamVideoVO;
import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.mapper.SupervisionVideoMapper;
import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
import com.yeejoin.equipmanage.service.IPressurePumpService;
import com.yeejoin.equipmanage.service.ISupervisionVideoService;
import com.yeejoin.equipmanage.service.IVideoService;
......@@ -21,10 +23,11 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
......@@ -41,6 +44,10 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap
private IVideoService videoService;
@Autowired
private IPressurePumpService pressurePumpService;
@Autowired
private IEquipmentSpecificSerivce equipmentSpecificSerivce;
@Autowired
private FireFightingSystemMapper fireFightingSystemMapper;
......@@ -82,99 +89,176 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap
@Override
public Page<Map<String, Object>> queryPumpInfo(Page page, String bizOrgCode) {
Date dateNow = DateUtils.getDateNow();
String nowStrLong = DateUtils.getNowStrLong();
Long interval = 0L;
//全部稳压泵半小时、一小时、两小时、四小时启动次数
int halfHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.HALF_HOUR.getValue()), dateNow);
int oneHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.ONE_HOUR.getValue()), dateNow);
int twoHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.TWO_HOUR.getValue()), dateNow);
int fourHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.FOUR_HOUR.getValue()), dateNow);
Page<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null);
String prefix = null;
for (Map<String, Object> item : pressurePumpInfo.getRecords()) {
String suffix = null;
String iotCode = item.get("iot_code").toString();
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
Date mounthDate = null;
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
Page<Map<String, Object>> pressurePumpInfo = new Page<>();
if (!CollectionUtils.isEmpty(infoList)) {
Map map = infoList.get(0);
String equipmentCode = map.get("equipmentCode").toString();
String top = map.get("top").toString();
String countRedisKey = map.get("countRedisKey").toString();
long countExpire = Long.parseLong(map.get("countExpire").toString());
Date dateNow = DateUtils.getDateNow();
String nowStrLong = DateUtils.getNowStrLong();
// 获取稳压泵数据,redis没有,从iot取
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null);
List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue");
List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse");
Long interval = 0L;
//全部稳压泵半小时、一小时、两小时、四小时启动次数
int halfHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.HALF_HOUR.getValue()), dataListFilterTrue, dateNow);
int oneHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.ONE_HOUR.getValue()), dataListFilterTrue, dateNow);
int twoHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.TWO_HOUR.getValue()), dataListFilterTrue, dateNow);
int fourHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.FOUR_HOUR.getValue()), dataListFilterTrue, dateNow);
// 近3天启动平均值,四合五入
AtomicInteger dayAvgFrequency = new AtomicInteger();
try {
mounthDate = DateUtils.getCurrentMonthStartTime(new Date());
} catch (Exception e) {
throw new RuntimeException(e);
Date startDate = com.yeejoin.amos.boot.biz.common.utils.DateUtils.dateAddDays(dateNow, Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue()));
String startTime = String.join(" ", com.yeejoin.amos.boot.biz.common.utils.DateUtils.dateFormat(startDate, com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_PATTERN), "00:00:00");
String endTime = String.join(" ", com.yeejoin.amos.boot.biz.common.utils.DateUtils.dateFormat(dateNow, com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_PATTERN), "00:00:00");
Map<String, List<PressurePumpCountVo>> dayAvgDataMap = pressurePumpService.getDateRangeCountList(pumpInfoList, startTime,endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, countExpire, bizOrgCode);
if (!CollectionUtils.isEmpty(dayAvgDataMap)) {
for (List<PressurePumpCountVo> voList : dayAvgDataMap.values()) {
if (!CollectionUtils.isEmpty(voList)) {
voList.forEach(x -> dayAvgFrequency.addAndGet(x.getValue()));
}
}
}
} catch (ParseException e) {
log.error("近3天平均启动次数获取失败-->dayAvgFrequency:{}", e.getMessage());
}
String startDateStr = DateUtils.convertDateToString(mounthDate, DateUtils.DATE_TIME_PATTERN);
//稳压泵本月累计启动统计
List<Map<String, String>> mounthEntity =
pressurePumpService.getIotCommonListData(startDateStr, nowStrLong, prefix, suffix, (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue()), pressurePumpStart);
item.put("monthStartNum", ObjectUtils.isEmpty(mounthEntity) ? 0 : mounthEntity.size());
item.put("halfHourStartNum", halfHourStartNum);
item.put("oneHourStartNum", oneHourStartNum);
item.put("twoHourStartNum", twoHourStartNum);
item.put("fourHourStartNum", fourHourStartNum);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long nowDateTime = new Date().getTime();//当前时间戳
boolean time = true;
//获取最近的一个触发物联指标的时间
Map<String, String> stateMap = fireFightingSystemMapper.queryPressureNowSignalBySpecificId((Long) item.get("id"));
Long update_date = 0L;
if (!ObjectUtils.isEmpty(stateMap)) {
DecimalFormat df = new DecimalFormat("0.0");
int dayAvgCount = dayAvgFrequency.get();
String dayAvgStartNum = dayAvgCount == 0 ? "0" : df.format(dayAvgCount / (double) Math.abs(Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue())));
pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null);
String prefix = null;
for (Map<String, Object> item : pressurePumpInfo.getRecords()) {
String suffix = null;
String iotCode = item.get("iot_code").toString();
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
Date mounthDate = null;
try {
//如果当前指标为启动,并且指标值为true,计算启动时长
if(PressurePumpRelateEnum.START.getDesc().contains(stateMap.get("equipment_index_name")) && PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue().contains(stateMap.get("equipment_index_name"))){
update_date = sdf.parse(stateMap.get("update_date")).getTime();
long res = nowDateTime - update_date;
long diffMinute = res / 1000 / 60;
if (diffMinute > Long.valueOf(PressurePumpRelateEnum.START_FIVE.getValue())) {
time = false;
mounthDate = DateUtils.getCurrentMonthStartTime(new Date());
} catch (Exception e) {
throw new RuntimeException(e);
}
String startDateStr = DateUtils.convertDateToString(mounthDate, DateUtils.DATE_TIME_PATTERN);
//稳压泵本月累计启动统计
List<Map<String, String>> mounthEntity =
pressurePumpService.getIotCommonListData(startDateStr, nowStrLong, prefix, suffix, (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue()), pressurePumpStart);
item.put("monthStartNum", ObjectUtils.isEmpty(mounthEntity) ? 0 : mounthEntity.size());
item.put("halfHourStartNum", halfHourStartNum);
item.put("oneHourStartNum", oneHourStartNum);
item.put("twoHourStartNum", twoHourStartNum);
item.put("fourHourStartNum", fourHourStartNum);
item.put("dayAvgStartNum", dayAvgStartNum);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long nowDateTime = new Date().getTime();//当前时间戳
boolean time = true;
//获取最近的一个触发物联指标的时间
Map<String, String> stateMap = fireFightingSystemMapper.queryPressureNowSignalBySpecificId((Long) item.get("id"));
Long update_date = 0L;
if (!ObjectUtils.isEmpty(stateMap)) {
try {
//如果当前指标为启动,并且指标值为true,计算启动时长
if(PressurePumpRelateEnum.START.getDesc().contains(stateMap.get("equipment_index_name")) && PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().contains(stateMap.get("value"))){
update_date = sdf.parse(stateMap.get("update_date")).getTime();
long res = nowDateTime - update_date;
long diffMinute = res / 1000 / 60;
if (diffMinute > Long.valueOf(PressurePumpRelateEnum.START_FIVE.getValue())) {
time = false;
}
}
if(PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue().contains(stateMap.get("value"))){
if(PressurePumpRelateEnum.START.getDesc().contains(stateMap.get("equipment_index_name"))){
item.put("equipment_index_name", PressurePumpRelateEnum.STOP.getDesc());
} else {
item.put("equipment_index_name", PressurePumpRelateEnum.RESET.getDesc());
}
} else {
item.put("equipment_index_name", stateMap.get("equipment_index_name"));
}
item.put("update_time", stateMap.get("update_date"));
} catch (ParseException e) {
throw new BadRequest("稳压泵最新指标时间转换失败!");
}
item.put("equipment_index_name", stateMap.get("equipment_index_name"));
item.put("update_time", stateMap.get("update_date"));
} catch (ParseException e) {
throw new BadRequest("稳压泵最新指标时间转换失败!");
} else {
item.put("equipment_index_name", "无信号");
item.put("update_time", false);
}
} else {
item.put("equipment_index_name", "无信号");
item.put("update_time", false);
//稳压泵当前状态 无告警并且启动时长小于5分钟为正常
item.put("stateDesc", Integer.parseInt(String.valueOf(item.get("isAlarm"))) == 0 && time ? PressurePumpRelateEnum.PIPE_PRESSURE_NORMAL_STATUS.getValue() : PressurePumpRelateEnum.PIPE_PRESSURE_ABNORMAL_STATUS.getValue());
}
//稳压泵当前状态 无告警并且启动时长小于5分钟为正常
item.put("stateDesc", Integer.parseInt(String.valueOf(item.get("isAlarm"))) == 0 && time ? PressurePumpRelateEnum.PIPE_PRESSURE_NORMAL_STATUS.getValue() : PressurePumpRelateEnum.PIPE_PRESSURE_ABNORMAL_STATUS.getValue());
}
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
if (!CollectionUtils.isEmpty(infoList)) {
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List<IotDataVO> redisDataList = pressurePumpService.getDataToRedis(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpStart, null);
if(!CollectionUtils.isEmpty(redisDataList)){
//从redis中获取最近一次启停间隔
interval = pressurePumpService.getAllPressurePumpStartStopInterval(redisDataList, null, nowStrLong, bizOrgCode);
} else {
List<IotDataVO> DataList = pressurePumpService.getDataToRedis(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpStart, null, bizOrgCode);
if(CollectionUtils.isEmpty(DataList)){
//从influxdb中获取最近一次启停间隔
String top = infoList.get(0).get("top").toString();
List<Map<String, String>> iotDataList = pressurePumpService.getIotTopSingleField(top, prefix, null, null, pressurePumpStart);
interval = pressurePumpService.getAllPressurePumpStartStopInterval(null, iotDataList, nowStrLong, bizOrgCode);
iotDataList.forEach(e -> {
try {
IotDataVO iotDataVO = (IotDataVO) pressurePumpService.mapToObject(e, IotDataVO.class, pressurePumpStart);
DataList.add(iotDataVO);
} catch (Exception el) {
throw new RuntimeException();
}
});
}
interval =pressurePumpService.getAllPressurePumpStartStopInterval(DataList, dataListFilterTrue, dataListFilterFalse, nowStrLong);
double finalDiffMinute = (double) interval;
pressurePumpInfo.getRecords().stream(
).map(item -> {
item.put("startAndStopInterval", finalDiffMinute);
if (finalDiffMinute <= Long.valueOf(PressurePumpRelateEnum.START_FIVE.getValue())) {
item.put("generalState", PressurePumpRelateEnum.PIPE_PRESSURE_ABNORMAL_STATUS.getValue());
} else {
item.put("generalState", PressurePumpRelateEnum.PIPE_PRESSURE_NORMAL_STATUS.getValue());
}
item.put("nameKey", pressurePumpStart);
return item;
}).collect(Collectors.toList());
List<Map<String, Object>> records = pressurePumpInfo.getRecords();
records.sort((t1, t2) -> t1.get("stateDesc").toString().compareTo(t2.get("stateDesc").toString()));
pressurePumpInfo.setRecords(records);
}
double finalDiffMinute = (double) interval;
pressurePumpInfo.getRecords().stream(
).map(item -> {
item.put("startAndStopInterval", finalDiffMinute);
if (finalDiffMinute > Long.valueOf(PressurePumpRelateEnum.START_FIVE.getValue())) {
item.put("generalState", PressurePumpRelateEnum.PIPE_PRESSURE_ABNORMAL_STATUS.getValue());
return pressurePumpInfo;
}
@Override
public List<Map<String, Object>> selectPressureDetails(String bizOrgCode) {
List<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.selectAllPressurePumpInfo(bizOrgCode);
pressurePumpInfo.stream().map(item -> {
String prefix = null;
String suffix = null;
String iotCode = item.get("iot_code").toString();
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
//通过iot最近一次的启动和停止时间
List<Map<String, String>> trueData = pressurePumpService.getIotTopSingleField(PressurePumpRelateEnum.ONE_TIME.getValue(), prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), pressurePumpStart);
List<Map<String, String>> falseData = pressurePumpService.getIotTopSingleField(PressurePumpRelateEnum.ONE_TIME.getValue(), prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue(), pressurePumpStart);
if(!ObjectUtils.isEmpty(trueData)){
item.put("startTime", trueData.get(0).get("createdTime"));
} else {
item.put("generalState", PressurePumpRelateEnum.PIPE_PRESSURE_NORMAL_STATUS.getValue());
item.put("startTime", "");
}
if(!ObjectUtils.isEmpty(falseData)){
item.put("stopTime", falseData.get(0).get("createdTime"));
} else {
item.put("stopTime", "");
}
item.put("nameKey", pressurePumpStart);
return item;
}).collect(Collectors.toList());
List<Map<String, Object>> records = pressurePumpInfo.getRecords();
records.sort((t1, t2) -> t1.get("stateDesc").toString().compareTo(t2.get("stateDesc").toString()));
pressurePumpInfo.setRecords(records);
return pressurePumpInfo;
}
}
......@@ -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">
......
......@@ -650,4 +650,7 @@ AND field_name =#{name}
<select id="queryVideoCountByBizOrgCode" resultType="java.lang.Long">
select count(1) from wl_video where biz_org_code like concat(#{bizOrgCode}, '%')
</select>
<select id="selectParentBuildId" resultType="java.lang.String">
SELECT instance_id FROM `wl_form_instance` f where f.field_name = 'code' and f.field_value = #{code}
</select>
</mapper>
......@@ -53,4 +53,19 @@
)
)
</select>
<select id="getOrgUsrDtoInfo" resultType="com.yeejoin.equipmanage.common.dto.OrgUsrDto">
SELECT
biz_org_code bizOrgCode,
biz_org_name bizOrgName
FROM
cb_org_usr
<where>
<if test="bizOrgType != null and bizOrgType != ''">
biz_org_type = #{bizOrgType}
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND locate( #{bizOrgCode}, biz_org_code ) > 0
</if>
</where>
</select>
</mapper>
......@@ -193,19 +193,12 @@ public class WordPowerUtils {
if (!file.exists()) {
return "";
}
InputStream in = null;
byte[] data = null;
try {
in = new FileInputStream(file);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
try {
try (InputStream in = new FileInputStream(file)) {
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
......
......@@ -334,15 +334,13 @@ public class CheckResultImpl extends ServiceImpl<CheckResultMapper, CheckResult>
* @return
*/
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();
return null;
return new byte[0];
}
}
......
......@@ -16,16 +16,18 @@ public class AmosThreadPool {
*/
private static final Logger log = LoggerFactory.getLogger(AmosThreadPool.class);
/**
* 单例
*/
private static AmosThreadPool instance;
/**
* 执行服务
*/
private static ExecutorService executorService;
/**
* 单例
*/
private static volatile AmosThreadPool instance;
/**
* 获取单例
*
......
......@@ -22,6 +22,8 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import net.sf.json.JSONObject;
import static com.alibaba.fastjson.JSON.parseArray;
@Slf4j
@Component
public class EmqMessageService extends EmqxListener {
......@@ -55,7 +57,7 @@ public class EmqMessageService extends EmqxListener {
e.printStackTrace();
}
list = com.alibaba.fastjson.JSONObject.parseArray(json, Map.class);
list = parseArray(json, Map.class);
String[] split = topics.split(",");
Arrays.stream(split).forEach(e-> {
......@@ -78,7 +80,11 @@ public class EmqMessageService extends EmqxListener {
Runnable task_runnable = new Runnable() {
public void run() {
while (true) {
int k = 0;
boolean b = true;
while (b) {
k++;
b = k < Integer.MAX_VALUE;
try {
JSONObject messageResult = blockingQueue.take();
JSONObject result = messageResult.getJSONObject("result");
......@@ -89,6 +95,7 @@ public class EmqMessageService extends EmqxListener {
}
});
} catch (Exception e) {
Thread.currentThread().interrupt();
log.info("发送kafka消息失败 ====> message: {}", e.getMessage());
}
}
......
......@@ -66,7 +66,11 @@ public class AppSpeechTranscriber {
DatagramPacket datagramPacket = new DatagramPacket(b, b.length);
logger.warn("serverSocket已启动,地址:" + localIpAddress
+ "监听端口:" + serverSocket.getLocalPort() + " 等待语音融合系统推送数据...");
while (true) {
int k = 0;
boolean b1 = true;
while (b1) {
k++;
b1 = k < Integer.MAX_VALUE;
serverSocket.receive(datagramPacket);
if (transcriber == null) {
logger.warn("收到第一个数据包:" + b.length + " 开始进行语音翻译");
......
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