Commit a3a90362 authored by litengwei's avatar litengwei

Merge branch 'develop_dl_plan6' into develop_dl_plan6_temp

# Conflicts: # README.md # amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/utils/DateUtils.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/fegin/IotFeign.java
parents 1b96529e e42c19db
...@@ -7,6 +7,9 @@ import java.text.DateFormat; ...@@ -7,6 +7,9 @@ import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.ParsePosition; import java.text.ParsePosition;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
/** /**
...@@ -86,7 +89,19 @@ public class DateUtils { ...@@ -86,7 +89,19 @@ public class DateUtils {
} }
return returnValue; return returnValue;
} }
/**
* 将字符换转换为日期
* @param date
* @param pattern
* @return
* @throws ParseException
*/
public static Date convertStrToDate(String date, String pattern) throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.parse(date);
}
/** /**
* 获取当前时间任意 * 获取当前时间任意
* @return * @return
...@@ -1015,6 +1030,115 @@ public class DateUtils { ...@@ -1015,6 +1030,115 @@ public class DateUtils {
return now; return now;
} }
public static List<String> getTimeStrListByStartAndEnd(String startTime, String endTime, String pattern) {
try {
List<String> list = new ArrayList<>();
Date startDate = convertStrToDate(startTime, DATE_TIME_PATTERN);
Date endDate = convertStrToDate(endTime, DATE_TIME_PATTERN);
list.add(convertDateToString(startDate, pattern));
Date date = startDate;
while (true) {
date = dateAddMinutes(date, 1);
if (dateCompare(endDate, date) == 1) {
list.add(convertDateToString(date, pattern));
} else {
list.add(convertDateToString(endDate, pattern));
break;
}
}
return list;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
/**
* 获取两个时间段之间的秒数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 秒数
*/
public static Long getDurationSecconds(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).getSeconds();
}
/**
* 获取两个时间段之间的秒数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 秒数
*/
public static Long getDurationSecconds(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).getSeconds();
}
/**
* 获取两个时间段之间的分钟数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 分钟数
*/
public static Long getDurationMinutes(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).toMinutes();
}
/**
* 获取两个时间段之间的分钟数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 分钟数
*/
public static Long getDurationMinutes(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).toMinutes();
}
/**
* 获取两个时间段之间的小时数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 小时
*/
public static Long getDurationHours(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).toHours();
}
/**
* 获取两个时间段之间的小时数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 小时
*/
public static Long getDurationHours(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).toHours();
}
public static Date getBeginDayOfWeek() { public static Date getBeginDayOfWeek() {
Date date = new Date(); Date date = new Date();
if (date == null) { if (date == null) {
......
...@@ -19,19 +19,14 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -19,19 +19,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import static org.typroject.tyboot.core.foundation.utils.DateTimeUtil.ISO8601_DATE_HOUR_MIN_SEC;
/** /**
* *
* 四横八纵应急模块接口 * 四横八纵应急模块接口
...@@ -583,4 +578,42 @@ public class EmergencyController extends AbstractBaseController { ...@@ -583,4 +578,42 @@ public class EmergencyController extends AbstractBaseController {
return CommonResponseUtil.success(iEmergencyService.getStockEquipStatistics()); return CommonResponseUtil.success(iEmergencyService.getStockEquipStatistics());
} }
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpStatusChart")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵启停状态图", notes = "四横八纵-稳压泵启停状态图")
public ResponseModel getPressurePumpStatusChart(@RequestParam String equipmentCode, @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.getPressurePumpStatusChart(equipmentCode, startTime, endTime, bizOrgCode, getAppKey(), getProduct(), getToken()));
}
@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) {
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.getPressurePumpDiagnosticAnalysis(equipmentCode, nameKeys, fieldKey, bizOrgCode, getAppKey(), getProduct(), getToken()));
}
} }
...@@ -323,7 +323,7 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -323,7 +323,7 @@ public class SupervisionConfigureController extends AbstractBaseController {
fourHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), four, 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); oneHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), one, nowStrLong, prefix, suffix, pressurePumpStart);
start = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "true", pressurePumpStart); start = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "true", pressurePumpStart);
stop = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "flase", pressurePumpStart); stop = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "false", pressurePumpStart);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -42,4 +42,6 @@ public interface EquipmentSpecificAlarmLogMapper extends BaseMapper<EquipmentSpe ...@@ -42,4 +42,6 @@ public interface EquipmentSpecificAlarmLogMapper extends BaseMapper<EquipmentSpe
Map<String, Object> alarmEquipLink(String date, String pattern, String cleanFlag); Map<String, Object> alarmEquipLink(String date, String pattern, String cleanFlag);
Map<String, Object> unCleanAlarmEquipLink(String date, String pattern, String cleanFlag); Map<String, Object> unCleanAlarmEquipLink(String date, String pattern, String cleanFlag);
List<EquipmentSpecificAlarmLog> getAlarmLogInfoList(String equipmentCode, String nameKeys, String value, String isCleanTime, String bizOrgCode);
} }
...@@ -240,6 +240,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -240,6 +240,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List<Map<String, Object>> getFirePumpInfoEQ(@Param("list") String[] strings,@Param("bizOrgCode") String bizOrgCode); List<Map<String, Object>> getFirePumpInfoEQ(@Param("list") String[] strings,@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getListByEquipmentCode(@Param("list") String[] strings, @Param("bizOrgCode") String bizOrgCode);
Integer getAllEquipNum(@Param("bizOrgCode") String bizOrgCode); Integer getAllEquipNum(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> normalIndexInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate); List<Map<String, Object>> normalIndexInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate);
......
...@@ -53,4 +53,8 @@ public interface IEmergencyService { ...@@ -53,4 +53,8 @@ public interface IEmergencyService {
List<Map<String, String>> getEquipExpiryList(Integer expiryDayNum); List<Map<String, String>> getEquipExpiryList(Integer expiryDayNum);
Map<String, Integer> getStockEquipStatistics(); Map<String, Integer> getStockEquipStatistics();
Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String bizOrgCode, String appKey, String product, String token);
List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String equipmentCode, String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token);
} }
...@@ -37,4 +37,15 @@ public interface IEquipmentSpecificAlarmLogService extends IService<EquipmentSpe ...@@ -37,4 +37,15 @@ public interface IEquipmentSpecificAlarmLogService extends IService<EquipmentSpe
* @return * @return
*/ */
Map<String, Object> equipAlarmLink(String date); Map<String, Object> equipAlarmLink(String date);
/**
* 获取告警Log未消除信息集合
* @param equipmentCode
* @param nameKey
* @param value
* @param isCleanTime
* @param bizOrgCode
* @return
*/
List<EquipmentSpecificAlarmLog> getAlarmLogInfoList(String equipmentCode, String nameKeys, String value, String isCleanTime, String bizOrgCode);
} }
...@@ -230,6 +230,13 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> { ...@@ -230,6 +230,13 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
List<Map<String, Object>> getListByEquipmentCode(String code,String bizOrgCode); List<Map<String, Object>> getListByEquipmentCode(String code,String bizOrgCode);
List<Map<String, Object>> getFirePumpInfoEQ(String code,String bizOrgCode); List<Map<String, Object>> getFirePumpInfoEQ(String code,String bizOrgCode);
/** /**
* 根据装备分类code获取装备列表,id 升序
* @param code 装备分类逗号隔开
* @return 装备list
*/
List<Map<String, Object>> getListByEquipmentCode(String code, String bizOrgCode);
/**
* 根据装备id获取物联日志 * 根据装备id获取物联日志
* @param iotCode code * @param iotCode code
* @param entity 日志 * @param entity 日志
......
package com.yeejoin.equipmanage.service.impl; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog;
import com.yeejoin.equipmanage.common.enums.IndexStatusEnum; import com.yeejoin.equipmanage.common.enums.IndexStatusEnum;
import com.yeejoin.equipmanage.common.utils.DateUtils; import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil; import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.utils.UnitTransformUtil; import com.yeejoin.equipmanage.common.utils.UnitTransformUtil;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.EmergencyMapper; import com.yeejoin.equipmanage.mapper.EmergencyMapper;
import com.yeejoin.equipmanage.service.IEmergencyService; import com.yeejoin.equipmanage.service.IEmergencyService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import static com.yeejoin.equipmanage.common.utils.DateUtils.getFirstDayOfMonth; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/** /**
* *
...@@ -31,6 +38,18 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -31,6 +38,18 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Autowired @Autowired
private EmergencyMapper emergencyMapper; private EmergencyMapper emergencyMapper;
@Autowired
private IEquipmentSpecificSerivce equipmentSpecificSerivce;
@Autowired
private IEquipmentSpecificAlarmLogService equipmentSpecificAlarmLogService;
@Autowired
private IotFeign iotFeign;
@Value("${equipment.pressurepump.start}")
private String pressurePumpStart;
@Override @Override
public List<Map<String, Object>> getSystemState(String bizOrgCode) { public List<Map<String, Object>> getSystemState(String bizOrgCode) {
List<Map<String, Object>> list = emergencyMapper.getSystemState(bizOrgCode); List<Map<String, Object>> list = emergencyMapper.getSystemState(bizOrgCode);
...@@ -199,4 +218,218 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -199,4 +218,218 @@ public class EmergencyServiceImpl implements IEmergencyService {
return emergencyMapper.getStockEquipStatistics(); return emergencyMapper.getStockEquipStatistics();
} }
@Override
public Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String bizOrgCode, String appKey, String product, String token) {
Map<String, Object> map = new HashMap<>();
List<String> timeList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, "MM-dd HH:mm");
// 获取稳压泵
List<Map<String, Object>> list = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
if (!CollectionUtils.isEmpty(list)) {
List<Map<String, Object>> yData = new ArrayList<>();
list.forEach(x -> {
Map<String, Object> yMap = new HashMap<>();
List<Integer> yList = new ArrayList<>();
String name = x.get("name").toString();
yMap.put("name", name);
Object iotCode = x.get("iotCode");
String prefix = null;
String suffix = null;
if (x.get("iotCode") != null && iotCode.toString().length() > 8) {
prefix = iotCode.toString().substring(0, 8);
suffix = iotCode.toString().substring(8);
ResponseModel responseModel = null;
try {
responseModel = iotFeign.selectListNew(appKey, product, token, prefix, startTime, endTime, null, pressurePumpStart);
} catch (Exception e) {
e.printStackTrace();
}
if (200 == responseModel.getStatus()) {
String json = JSON.toJSONString(responseModel.getResult());
List<Map<String, String>> dataList = (List<Map<String, String>>) JSONArray.parse(json);
if (!CollectionUtils.isEmpty(dataList)) {
Collections.reverse(dataList);
Map<String, List<Map<String, String>>> dataMap = dataList.stream().filter(y -> y.containsKey("createdTime")).collect(Collectors.groupingBy(e -> e.get("createdTime").substring(5, 16).replace("T", " ")));
timeList.forEach(t -> {
List<Map<String, String>> data = dataMap.get(t);
if (!CollectionUtils.isEmpty(data)) {
List<Map<String, String>> yDataList = dataMap.get(t).stream().filter(o -> "true".equals(o.get(pressurePumpStart).toString())).collect(Collectors.toList());
yList.add(CollectionUtils.isEmpty(yDataList) ? 0 : 1);
} else {
yList.add(0);
}
});
} else {
timeList.forEach(t -> {
yList.add(0);
});
}
}
yMap.put("data", yList);
yData.add(yMap);
}
});
map.put("xData", timeList);
map.put("yData", yData);
}
return map;
}
@Override
public List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String equipmentCode, String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token) {
List<Map<String, Object>> list = new ArrayList<>();
// 1. 判断稳压泵整体是否故障
List<EquipmentSpecificAlarmLog> alarmLogList = equipmentSpecificAlarmLogService.getAlarmLogInfoList(equipmentCode, nameKeys, "true", "false", bizOrgCode);
HashMap<String, Object> isFaultMap = new HashMap<>();
isFaultMap.put("key", 1);
isFaultMap.put("code", 1);
isFaultMap.put("name", "稳压泵是否有故障");
isFaultMap.put("value", CollectionUtils.isEmpty(alarmLogList) ? "无" : "有");
isFaultMap.put("unit", "");
list.add(isFaultMap);
// 2. 最近一次启停间隔
HashMap<String, Object> intervalMap = new HashMap<>();
intervalMap.put("key", 2);
intervalMap.put("code", 2);
intervalMap.put("name", "最近一次启动间隔");
intervalMap.put("unit", "分钟");
// 3. 最近一次启动时长
HashMap<String, Object> durationlMap = new HashMap<>();
durationlMap.put("key", 3);
durationlMap.put("code", 3);
durationlMap.put("name", "最近一次启动时长");
durationlMap.put("unit", "分钟");
// 4. 半小时启动
// 5. 2小时启动
String nowStrLong = DateUtils.getNowStrLong();
Date halfHour = DateUtils.dateAddMinutes(null, -30);
Date twoHour = DateUtils.dateAddHours(null, -2);
String half = DateUtils.convertDateToString(halfHour, DateUtils.DATE_TIME_PATTERN);
String two = DateUtils.convertDateToString(twoHour, DateUtils.DATE_TIME_PATTERN);
HashMap<String, Object> pipeMap = new HashMap<>();
pipeMap.put("key", 6);
pipeMap.put("code", 6);
pipeMap.put("name", "管网压力");
pipeMap.put("value", "正常");
pipeMap.put("unit", "");
// 获取稳压泵
List<Map<String, Object>> specificList = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
AtomicInteger halfNum = new AtomicInteger();
AtomicInteger twoNum = new AtomicInteger();
if (!CollectionUtils.isEmpty(specificList)) {
String prefix = null;
for (Map<String, Object> x : specificList) {
Object iotCode = x.get("iotCode");
String suffix = null;
if (x.get("iotCode") != null && iotCode.toString().length() > 8) {
prefix = iotCode.toString().substring(0, 8);
suffix = iotCode.toString().substring(8);
try {
ResponseModel halfResponseModel = iotFeign.selectList(appKey, product, token, half, nowStrLong, prefix, suffix, pressurePumpStart);
ResponseModel twoResponseModel = iotFeign.selectList(appKey, product, token, two, nowStrLong, prefix, suffix, pressurePumpStart);
if (200 == halfResponseModel.getStatus()) {
String json = JSON.toJSONString(halfResponseModel.getResult());
List<Map<String, String>> halfDataList = (List<Map<String, String>>) JSONArray.parse(json);
List<Map<String, String>> halfCollect = halfDataList.stream().filter(o -> "true".equals(o.get(pressurePumpStart).toString())).collect(Collectors.toList());
halfNum.addAndGet(halfCollect.size());
}
if (200 == twoResponseModel.getStatus()) {
String json = JSON.toJSONString(twoResponseModel.getResult());
List<Map<String, String>> twoDataList = (List<Map<String, String>>) JSONArray.parse(json);
List<Map<String, String>> twoCollect = twoDataList.stream().filter(o -> "true".equals(o.get(pressurePumpStart).toString())).collect(Collectors.toList());
twoNum.addAndGet(twoCollect.size());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
ResponseModel intervalResponseModel = iotFeign.selectOne(appKey, product, token, "1", prefix, null, null, pressurePumpStart);
String intervalTime = nowStrLong;
String durationTime = nowStrLong;
if (200 == intervalResponseModel.getStatus()) {
String json = JSON.toJSONString(intervalResponseModel.getResult());
List<Map<String, String>> intervalDataList = (List<Map<String, String>>) JSONArray.parse(json);
if (!CollectionUtils.isEmpty(intervalDataList)) {
String value = intervalDataList.get(0).get(pressurePumpStart);
if ("true".equals(value)) {
ResponseModel stopResponseModel = iotFeign.selectOne(appKey, product, token, "1", prefix, null, "false", pressurePumpStart);
if (200 == stopResponseModel.getStatus()) {
String stopJson = JSON.toJSONString(stopResponseModel.getResult());
List<Map<String, String>> stopDataList = (List<Map<String, String>>) JSONArray.parse(stopJson);
List<Map<String, String>> collect = stopDataList.stream().filter(o -> o.containsKey("createdTime")).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) {
intervalTime = collect.get(0).get("createdTime").substring(0, 19).replace("T", " ");
// 停泵前的前5分钟,判断管网压力状态
try {
String stop5BeforeTime = DateUtils.convertDateToString(DateUtils.dateAddMinutes(DateUtils.convertStrToDate(intervalTime, "yyyy-MM-dd HH:mm:ss"), -5), "yyyy-MM-dd HH:mm:ss");
ResponseModel pipeResponseModel = iotFeign.selectListNew(appKey, product, token, prefix, stop5BeforeTime, intervalTime, null, "FHS_PipePressureDetector_PipePressure");
if (200 == pipeResponseModel.getStatus()) {
String pipeJson = JSON.toJSONString(pipeResponseModel.getResult());
List<Map<String, String>> pipeDataList = (List<Map<String, String>>) JSONArray.parse(pipeJson);
List<Map<String, String>> collect1 = pipeDataList.stream().filter(o -> o.containsKey("FHS_PipePressureDetector_PipePressure")).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect1)) {
int val1 = Integer.parseInt(collect1.get(0).get("FHS_PipePressureDetector_PipePressure"));
int val2 = Integer.parseInt(collect1.get(pipeDataList.size() - 1).get("FHS_PipePressureDetector_PipePressure"));
pipeMap.put("value", (val1 - val2) > 0.05 ? "异常" : "正常");
}
}
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
}
ResponseModel startResponseModel = iotFeign.selectOne(appKey, product, token, "2", prefix, null, "true", pressurePumpStart);
if (200 == startResponseModel.getStatus()) {
String startJson = JSON.toJSONString(startResponseModel.getResult());
List<Map<String, String>> startDataList = (List<Map<String, String>>) JSONArray.parse(startJson);
List<Map<String, String>> collect = startDataList.stream().filter(o -> o.containsKey("createdTime")).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect) && collect.size() > 1) {
durationTime = collect.get(1).get("createdTime").substring(0, 19).replace("T", " ");
}
}
} else {
ResponseModel startResponseModel = iotFeign.selectOne(appKey, product, token, "1", prefix, null, "true", pressurePumpStart);
if (200 == startResponseModel.getStatus()) {
String startJson = JSON.toJSONString(startResponseModel.getResult());
List<Map<String, String>> startDataList = (List<Map<String, String>>) JSONArray.parse(startJson);
List<Map<String, String>> collect = startDataList.stream().filter(o -> o.containsKey("createdTime")).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) {
intervalTime = collect.get(0).get("createdTime").substring(0, 19).replace("T", " ");
durationTime = intervalTime;
}
}
}
}
}
intervalMap.put("value", DateUtils.getDurationMinutes(intervalTime, nowStrLong, "yyyy-MM-dd HH:mm:ss"));
durationlMap.put("value", DateUtils.getDurationMinutes(durationTime, nowStrLong, "yyyy-MM-dd HH:mm:ss"));
} else {
intervalMap.put("value", 0);
durationlMap.put("value", 0);
pipeMap.put("value", "正常");
}
list.add(intervalMap);
list.add(durationlMap);
HashMap<String, Object> halfMap = new HashMap<>();
halfMap.put("key", 4);
halfMap.put("code", 4);
halfMap.put("name", "半小时启动");
halfMap.put("value", halfNum);
halfMap.put("unit", "次");
list.add(halfMap);
HashMap<String, Object> twoMap = new HashMap<>();
twoMap.put("key", 5);
twoMap.put("code", 5);
twoMap.put("name", "2小时启动");
twoMap.put("value", twoNum);
twoMap.put("unit", "次");
list.add(twoMap);
// 6. 管网压力
list.add(pipeMap);
return list;
}
} }
...@@ -66,4 +66,9 @@ public class EquipmentSpecificAlarmLogServiceImpl extends ServiceImpl<EquipmentS ...@@ -66,4 +66,9 @@ public class EquipmentSpecificAlarmLogServiceImpl extends ServiceImpl<EquipmentS
map.put("unCleanAlarmEquipMonthLink", unCleanAlarmEquipMonthLink); map.put("unCleanAlarmEquipMonthLink", unCleanAlarmEquipMonthLink);
return map; return map;
} }
@Override
public List<EquipmentSpecificAlarmLog> getAlarmLogInfoList(String equipmentCode, String nameKeys, String value, String isCleanTime, String bizOrgCode) {
return equipmentSpecificAlarmLogMapper.getAlarmLogInfoList(equipmentCode, nameKeys, value, isCleanTime, bizOrgCode);
}
} }
...@@ -1852,6 +1852,16 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1852,6 +1852,16 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
} }
@Override @Override
public List<Map<String, Object>> getListByEquipmentCode(String code, String bizOrgCode) {
List<Map<String, Object>> list = new ArrayList<>();
if (StringUtil.isNotEmpty(code)) {
String[] strings = code.split(",");
list = equipmentSpecificMapper.getListByEquipmentCode(strings, bizOrgCode);
}
return list;
}
@Override
public List<IotIndexInfoVo> getIndexInfoList(String iotCode, ResponseModel entity, Integer isTrend, String fieldKey) { public List<IotIndexInfoVo> getIndexInfoList(String iotCode, ResponseModel entity, Integer isTrend, String fieldKey) {
List<IotIndexInfoVo> infoVoList = new ArrayList<>(); List<IotIndexInfoVo> infoVoList = new ArrayList<>();
String json = JSON.toJSONString(entity.getResult()); String json = JSON.toJSONString(entity.getResult());
......
...@@ -243,4 +243,34 @@ ...@@ -243,4 +243,34 @@
ORDER BY ORDER BY
ta.`date` ta.`date`
</select> </select>
<select id="getAlarmLogInfoList" resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog">
SELECT
*
FROM
wl_equipment_specific_alarm_log wesal
<where>
<if test="equipmentCode != null and equipmentCode != ''">
AND wesal.equipment_code LIKE CONCAT( #{equipmentCode},'%')
</if>
<if test="nameKeys != null and nameKeys.split(',').length >0">
AND wesal.equipment_specific_index_key IN
<foreach collection="nameKeys.split(',')" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="value != null and value != ''">
AND wesal.equipment_specific_index_value = #{value}
</if>
<if test="isCleanTime != null and isCleanTime = 'false'">
AND wesal.clean_time IS NULL
</if>
<if test="isCleanTime != null and isCleanTime = 'true'">
AND wesal.clean_time IS NOT NULL
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wesal.biz_org_code LIKE CONCAT( #{bizOrgCode},'%')
</if>
</where>
ORDER BY wesal.create_date DESC
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -1744,6 +1744,29 @@ ...@@ -1744,6 +1744,29 @@
</where> </where>
ORDER BY realtiemIotIndexUpdateDate DESC ORDER BY realtiemIotIndexUpdateDate DESC
</select> </select>
<select id="getListByEquipmentCode" resultType="Map">
SELECT
wes.id,
wes.name,
wes.code,
wes.equipment_code equipmentCode,
wes.realtime_iot_index_name realtimeIotIndexName,
wes.realtime_iot_index_key realtimeIotIndexKey,
wes.iot_code iotCode
FROM
wl_equipment_specific wes
<where>
<if test="list != null and list.length > 0">
<foreach collection="list" item="item" index="index" open="(" close=")" separator="OR">
wes.equipment_code LIKE <![CDATA[CONCAT(#{item},'%')]]>
</foreach>
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wes.biz_org_code LIKE concat(#{bizOrgCode}, '%')
</if>
</where>
ORDER BY wes.id
</select>
......
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