Commit f7186567 authored by KeYong's avatar KeYong

拓补图功能

parent 7d756585
......@@ -135,4 +135,12 @@ public class EquipmentSpecific extends BaseEntity {
* 存放位置冗余字段
*/
private Long warehouseStructureId;
@ApiModelProperty(value = "告警状态")
@TableField(exist = false)
private Integer status;
@ApiModelProperty(value = "系统名称")
@TableField(exist = false)
private String systemName;
}
......@@ -125,6 +125,10 @@ public class EquipmentSpecificAlarmLog extends BaseEntity {
@TableField("equipment_index_id")
private Long equipmentIndexId;
@ApiModelProperty(value = "报警状态1报警0恢复")
@TableField("status")
private Integer status;
@ApiModelProperty(value = "画布id")
@TableField(exist = false)
private Long sceneId;
......
......@@ -109,6 +109,16 @@ public class CommonPageInfoParam extends CommonPageable {
*/
private List<String> buildIds;
private String status;
public void setStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
public void setWarehouseStructureName(String warehouseStructureName) {
this.warehouseStructureName = warehouseStructureName;
}
......
......@@ -55,6 +55,8 @@ public class CommonPageParamUtil {
param.setBuildId(toString(queryRequests.get(i).getValue()));
} else if("buildIds".equals(name)){
param.setBuildIds((List<String>)queryRequests.get(i).getValue());
} else if("status".equals(name)){
param.setStatus(toString(queryRequests.get(i).getValue()));
}
}
if(commonPageable !=null){
......
package com.yeejoin.equipmanage.common.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @author keyong
* @title: TopographyAlarmVo
* <pre>
* @description: TODO
* </pre>
* @date 2021/12/29 18:57
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TopographyAlarmVo {
private Date createDate;
private String fireEquipmentSpecificIndexName;
private String fireEquipmentName;
private String warehouseStructureName;
private String equipmentName;
private String handleStatus;
private String handleType;
private String alarmType;
private String alarmContent;
private String status;
}
package com.yeejoin.equipmanage.common.vo;
import lombok.Data;
/**
* @author keyong
* @title: IotDataVO
* <pre>
* @description: 物联系统发送的增量数据封装VO
* </pre>
* @date 2021/1/7 17:44
*/
@Data
public class TopographyIotDataVO {
private String name;
private Object value;
private String unit;
}
package com.yeejoin.equipmanage.common.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author keyong
* @title: TopographyAlarmVo
* <pre>
* @description: TODO
* </pre>
* @date 2021/12/29 18:57
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TopographyIotVo {
private Date time;
private List<TopographyIotDataVO> list;
}
package com.yeejoin.equipmanage.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
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.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.entity.EquProperty;
import com.yeejoin.equipmanage.common.entity.EquipmentDetail;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecific;
import com.yeejoin.equipmanage.common.entity.StockDetail;
import com.yeejoin.equipmanage.common.entity.WarehouseStructure;
import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.TopographyNodeDetailDTO;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentDetailDownloadVO;
import com.yeejoin.equipmanage.common.enums.ExcelEnums;
import com.yeejoin.equipmanage.common.utils.ExcelUtils;
......@@ -51,18 +17,30 @@ import com.yeejoin.equipmanage.fegin.JcsFeign;
import com.yeejoin.equipmanage.mapper.EquipmentDetailMapper;
import com.yeejoin.equipmanage.mapper.ManufacturerInfoMapper;
import com.yeejoin.equipmanage.mapper.StockDetailMapper;
import com.yeejoin.equipmanage.service.IEquipmentDetailService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificIndexSerivce;
import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
import com.yeejoin.equipmanage.service.IExcelService;
import com.yeejoin.equipmanage.service.IStockService;
import com.yeejoin.equipmanage.service.ISyncDataService;
import com.yeejoin.equipmanage.service.IWarehouseStructureService;
import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.service.impl.TopographyNodeDetailService;
import com.yeejoin.equipmanage.utils.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author wujiang
......@@ -219,11 +197,11 @@ public class EquipmentDetailController extends AbstractBaseController {
}
/***
*
* 修改
* **/
@RequestMapping(value = "equipment/updateById", method = RequestMethod.PUT)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "修改", notes = "修改")
......
package com.yeejoin.equipmanage.controller;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.TopographyLineDTO;
import com.yeejoin.equipmanage.common.entity.dto.TopographyNodeDTO;
import com.yeejoin.equipmanage.common.entity.dto.TopographyNodeDetailDTO;
import com.yeejoin.equipmanage.common.entity.dto.TopographyTreeDTO;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentIndexVO;
import com.yeejoin.equipmanage.common.enums.TopoNodeTypeEnum;
import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.common.vo.*;
import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.service.impl.TopographyNodeDetailService;
import com.yeejoin.equipmanage.service.impl.TopographyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* <p>
......@@ -43,14 +51,48 @@ import io.swagger.annotations.ApiParam;
@RestController
@Api(tags = "网络拓扑Api")
@RequestMapping(value = "/topography")
public class TopographyController
{
public class TopographyController extends AbstractBaseController {
private final Logger logger = LogManager.getLogger(TopographyController.class);
@Autowired
private TopographyService topographyService;
@Autowired
private TopographyNodeDetailService topographyNodeDetailService;
@Autowired
IEquipmentSpecificAlarmService equipmentSpecificAlarmService;
@Autowired
IEquipmentDetailService iEquipmentDetailService;
@Autowired
EquipmentDetailMapper equipmentDetailMapper;
@Autowired
private StockDetailMapper stockDetailMapper;
@Autowired
IStockService iStockService;
@Autowired
IEquipmentSpecificSerivce equipmentSpecificService;
@Autowired
IEquipmentSpecificAlarmLogService equipmentSpecificAlarmLogService;
@Autowired
EquipmentSpecificAlarmMapper equipmentSpecificAlarmMapper;
@Autowired
private RestTemplate restTemplate;
@Autowired
FireFightingSystemMapper fireFightingSystemMapper;
@Autowired
IEquipmentSpecificAlarmService iEquipmentSpecificAlarmService;
@Autowired
IEquipmentIndexService equipmentIndexService;
@Autowired
EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Autowired
IEquipmentService iEquipmentService;
@Value("${iot.vehicle.track}")
private String iotServerName;
// /**
// * 拓扑图-树
// *
......@@ -191,7 +233,7 @@ public class TopographyController
/**
* 网络拓扑图-树
*
* @param type 节点类型
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -206,18 +248,18 @@ public class TopographyController
/**
* 网络拓扑图
*
* @param type 节点类型
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "网络拓扑图", notes = "拓扑图")
@RequestMapping(value = "/webNodes/{treeid}", method = RequestMethod.GET)
public ResponseModel<Map<String,Object>> webNodes(@ApiParam(value = "树id", required = false) @PathVariable String treeid) {
public ResponseModel<Map<String, Object>> webNodes(@ApiParam(value = "树id", required = false) @PathVariable String treeid) {
//获取当前登录人的公司code
List<TopographyNodeDTO> nodes = topographyService.getNodes(treeid, TopoNodeTypeEnum.网络拓扑图.getType());
List<TopographyLineDTO> links = topographyService.getLinks(treeid, TopoNodeTypeEnum.网络拓扑图.getType());
Map<String,Object> results = new HashMap<>();
Map<String, Object> results = new HashMap<>();
results.put("nodeData", nodes);
results.put("linkData", links);
return ResponseHelper.buildResponse(results);
......@@ -253,7 +295,7 @@ public class TopographyController
/**
* 保存网络拓扑图
*
* @param type 节点类型
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -269,7 +311,7 @@ public class TopographyController
/**
* 节点详情
*
* @param type 节点类型
* @param
* @return
*/
@SuppressWarnings("rawtypes")
......@@ -448,4 +490,291 @@ public class TopographyController
// return CommonResponseUtil.success();
// }
/***
*
* 根拓补节点id查询详情
*
* **/
@RequestMapping(value = "/equipment/detail", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "根据节点id查询详情", notes = "根据节点id查询详情")
public EquipmentDate selectEquipmentDateById(@RequestParam(required = false) String id) {
TopographyNodeDetailDTO detailDTO = topographyNodeDetailService.queryByNodeid(id);
if (null == id || null == detailDTO || !StringUtil.isNotEmpty(detailDTO.getEqpId())) {
throw new RuntimeException("节点信息错误或此节点下未绑定装备!");
}
String eqpId = detailDTO.getEqpId();
EquipmentDate equipmentDate = new EquipmentDate();
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId);
QueryWrapper<EquipmentSpecificAlarm> wrapper = new QueryWrapper<>();
wrapper.eq("equipment_specific_id", eqpId);
wrapper.orderByDesc("create_date");
List<EquipmentSpecificAlarm> list = equipmentSpecificAlarmService.getBaseMapper().selectList(wrapper);
EquipmentSpecificAlarm alarm;
if (0 > list.size()) {
alarm = list.get(0);
equipmentSpecific.setStatus(alarm.getStatus());
} else {
equipmentSpecific.setStatus(0);
}
equipmentSpecific.setFullqrCode("01#" + equipmentSpecific.getQrCode());
String sysName = this.getSystemNameBySpeId(equipmentSpecific);
equipmentSpecific.setSystemName(sysName);
EquipmentDetail equipmentDetail = iEquipmentDetailService.getOneById(equipmentSpecific.getEquipmentDetailId());
StockDetail stockDetail = null;
//消防装备默认分支
List<StockDetail> stockDetails = stockDetailMapper.selectList(new LambdaQueryWrapper<StockDetail>().eq(StockDetail::getEquipmentSpecificId, eqpId));
if (!stockDetails.isEmpty()) {
stockDetail = stockDetails.get(0);
equipmentSpecific.setStockDetail(stockDetail);
}
if (stockDetail != null) {
equipmentSpecific.setStock(iStockService.getById(stockDetail.getStockId()));
}
equipmentDate.setEquipmentDetail(equipmentDetail);
equipmentDate.setEquipmentSpecific(equipmentSpecific);
return equipmentDate;
}
public String getSystemNameBySpeId(EquipmentSpecific equipmentSpecific) {
List<FireFightingSystemEntity> sys = new ArrayList<>();
String[] ids;
String sysIds = equipmentSpecific.getSystemId();
if (StringUtil.isNotEmpty(sysIds)) {
if (-1 != sysIds.indexOf(",")) {
ids = sysIds.split(",");
sys = fireFightingSystemMapper.getFightingSysByIds(ids);
} else {
FireFightingSystemEntity entity = fireFightingSystemMapper.selectById(Long.valueOf(sysIds));
sys.add(entity);
}
}
StringBuilder sb = new StringBuilder();
sys.forEach(x -> {
if (0 < sb.length()) {
sb.append(",");
}
sb.append(x.getName());
});
return sb.toString();
}
/***
*
* 根拓补节点id查询告警信息(未恢复或者所有)
*
* **/
@RequestMapping(value = "/equipment/alarm", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "根据节点id查询告警信息", notes = "根据节点id查询告警信息")
public ResponseModel getAlarmInfo(@RequestParam(required = false) String id, @RequestParam(required = false) int status,
@RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate,
CommonPageable commonPageable) {
TopographyNodeDetailDTO detailDTO = topographyNodeDetailService.queryByNodeid(id);
if (null == id || null == detailDTO || !StringUtil.isNotEmpty(detailDTO.getEqpId())) {
throw new RuntimeException("节点信息错误或此节点下未绑定装备!");
}
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(detailDTO.getEqpId());
List<CommonRequest> queryRequests = new ArrayList<>();
CommonRequest request = new CommonRequest();
request.setName("beginDate");
request.setValue(StringUtil.isNotEmpty(beginDate) ? StringUtils.trimToNull(beginDate).substring(0, 10) + " 00:00:00" : null);
queryRequests.add(request);
CommonRequest request1 = new CommonRequest();
request1.setName("endDate");
request1.setValue(StringUtil.isNotEmpty(endDate) ? StringUtils.trimToNull(endDate).substring(0, 10) + " 23:59:59" : null);
queryRequests.add(request1);
CommonRequest request2 = new CommonRequest();
request2.setName("id");
request2.setValue(StringUtil.isNotEmpty(String.valueOf(equipmentSpecific.getId())) ? StringUtils.trimToNull(String.valueOf(equipmentSpecific.getId())) : null);
queryRequests.add(request2);
CommonRequest request3 = new CommonRequest();
request3.setName("status");
request3.setValue(StringUtil.isNotEmpty(status) ? StringUtils.trimToNull(String.valueOf(status)) : null);
queryRequests.add(request3);
CommonPageInfoParam param = CommonPageParamUtil.fillCommonPageInfoParam(queryRequests, commonPageable);
Page<TopographyAlarmVo> list = iEquipmentSpecificAlarmService.listAlarmsPageForTopography(param);
return CommonResponseUtil.success(list);
}
/**
* 根拓补节点id查询当前节点最新物联信息
**/
@RequestMapping(value = "/equipment/iot/info", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "根据节点id查询当前物联信息", notes = "根据节点id查询当前物联信息")
public Map<String, Object> getEquipmentIotInfo(@RequestParam(required = false) String id) {
TopographyNodeDetailDTO detailDTO = topographyNodeDetailService.queryByNodeid(id);
if (null == id || null == detailDTO || !StringUtil.isNotEmpty(detailDTO.getEqpId())) {
throw new RuntimeException("节点信息错误或此节点下未绑定装备!");
}
String eqpId = detailDTO.getEqpId();
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId);
EquipmentDetail equipmentDetail = iEquipmentDetailService.getById(equipmentSpecific.getEquipmentDetailId());
Long equipmentId = equipmentDetail.getEquipmentId();
HashMap<String, List> map = new HashMap<>();
ConcurrentHashMap map1 = new ConcurrentHashMap();
List<String> list = equipmentIndexService.getGruopName(equipmentId);
list.forEach(x -> {
QueryWrapper<EquipmentIndex> wrapper = new QueryWrapper<>();
wrapper.eq("equipment_id", equipmentId);
wrapper.eq("group_name", x);
wrapper.orderByAsc("sort_num");
List<EquProperty> properList = new ArrayList<>();
equipmentIndexService.list(wrapper).forEach(y -> {
EquProperty equProperty = new EquProperty();
equProperty.setEquipmentIndexId(y.getId());
equProperty.setIsIot(y.getIsIot());
equProperty.setPerfQuotaName(y.getPerfQuotaName());
equProperty.setEquipmentIndexName(y.getPerfQuotaName());
equProperty.setGroupName(y.getGroupName());
equProperty.setValue(y.getPerfValue());
equProperty.setUnitName(y.getUnitName());
equProperty.setEquipmentIndexKey(y.getPerfQuotaDefinitionId());
properList.add(equProperty);
});
map.put(x, properList);
});
QueryWrapper<EquipmentIndex> wrappernull = new QueryWrapper<>();
wrappernull.isNull("group_name").or().eq("group_name", " ");
wrappernull.eq("equipment_id", equipmentId);
wrappernull.orderByAsc("sort_num");
List<EquProperty> properList = new ArrayList<>();
equipmentIndexService.list(wrappernull).forEach(y -> {
EquProperty equProperty = new EquProperty();
equProperty.setEquipmentIndexId(y.getId());
equProperty.setPerfQuotaName(y.getPerfQuotaName());
equProperty.setEquipmentIndexName(y.getPerfQuotaName());
equProperty.setIsIot(y.getIsIot());
equProperty.setGroupName(y.getGroupName());
equProperty.setValue(y.getPerfValue());
equProperty.setUnitName(y.getUnitName());
equProperty.setEquipmentIndexKey(y.getPerfQuotaDefinitionId());
properList.add(equProperty);
});
properList.forEach(e -> {
List<EquipmentIndexVO> equipmentIndexList = equipmentSpecificIndexMapper.getEquipIndexByIndexId(e.getEquipmentIndexId(), equipmentSpecific.getId());
if (equipmentIndexList.size() > 0) {
if (StringUtil.isNotEmpty(equipmentIndexList.get(0).getValue())) {
e.setValue(equipmentIndexList.get(0).getValue());
} else {
e.setValue("");
}
} else {
e.setValue("");
}
});
//判断map中是否有key为’其他‘的数据,提取单独处理
List<EquProperty> otherProperList = map.get("其他");
if (otherProperList != null && otherProperList.size() > 0) {
otherProperList.addAll(properList);
map.put("其他", otherProperList);
} else {
map.put("其他", properList);
}
Equipment byId = iEquipmentService.getById(equipmentId);
Map<String, Object> re = new HashMap<>();
re.put("res", map);
// re.put("pre", byId.getPrefQuota()); // 非核心参数此处不需要
return re;
}
/***
*
* 根拓补节点id查询当前节点物联数据记录
*
* **/
@RequestMapping(value = "/equipment/info", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "根据节点id查询当前节点物联数据记录", notes = "根据节点id查询当前节点物联数据记录")
public ResponseModel getEquipmentIotInfo(@RequestParam(required = false) String id, @RequestParam(required = false) String beginDate,
@RequestParam(required = false) String endDate) {
TopographyNodeDetailDTO detailDTO = topographyNodeDetailService.queryByNodeid(id);
if (null == id || null == detailDTO || !StringUtil.isNotEmpty(detailDTO.getEqpId())) {
throw new RuntimeException("节点信息错误或此节点下未绑定装备!");
}
String eqpId = detailDTO.getEqpId();
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId);
String iotCode = equipmentSpecific.getIotCode();
String prefix = null;
String suffix = null;
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
return CommonResponseUtil.failure("装备物联编码错误,请确认!");
}
LonAndLatEntityVo lonAndLatEntityVo = new LonAndLatEntityVo();
String url = iotServerName;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Content-Type", "application/json");
headers.set("product", getProduct());
headers.set("token", getToken());
headers.set("appKey", getAppKey());
HttpEntity httpEntity = new HttpEntity<>(lonAndLatEntityVo, headers);
ResponseEntity<FeignClientResult> feignClientResult = null;
try {
feignClientResult = restTemplate.exchange("http://" + url
+ "/iot/v1/livedata/list?timeStart=" + beginDate + "&timeEnd=" + endDate + "&productKey=" + prefix + "&deviceName=" + suffix,
HttpMethod.GET, httpEntity, FeignClientResult.class);
} catch (Exception e) {
e.printStackTrace();
}
if (null != feignClientResult && feignClientResult.getBody().getStatus() == 200) {
List<TopographyIotVo> list = new ArrayList<>();
if (null != feignClientResult.getBody().getResult()) {
String json = JSON.toJSONString(feignClientResult.getBody().getResult());
JSONObject jsonObject = JSONObject.parseObject(json);
Iterator it = jsonObject.entrySet().iterator();
List<IotDataVO> iotDatalist = new ArrayList<IotDataVO>();
while (it.hasNext()) {
IotDataVO iotDataVO = new IotDataVO();
Map.Entry<String, Object> entry = (Map.Entry<String, Object>) it.next();
if (!"name".equals(entry.getKey()) || !"deviceName".equals(entry.getKey()) || !"time".equals(entry.getKey())) {
iotDataVO.setKey(entry.getKey());
iotDataVO.setValue(entry.getValue());
}
iotDatalist.add(iotDataVO);
}
List<EquipmentSpecificIndex> indexes = equipmentSpecificIndexMapper.getEquipmentSpeIndexByIotCode(iotCode);
if (0 <indexes.size()) {
iotDatalist.forEach(iotDataVO -> {
TopographyIotVo iotVo = new TopographyIotVo();
List<TopographyIotDataVO> lists = new ArrayList<TopographyIotDataVO>();
indexes.forEach(x -> {
iotVo.setTime(x.getUpdateDate());
if (x.getNameKey().equals(iotDataVO.getKey())) {
TopographyIotDataVO dataVO = new TopographyIotDataVO();
dataVO.setName(x.getIndexName());
dataVO.setValue(x.getValue());
dataVO.setUnit(x.getIndexUnitName());
lists.add(dataVO);
}
});
iotVo.setList(lists);
list.add(iotVo);
});
}
}
return CommonResponseUtil.success(list);
} else {
logger.error("注:iotCode为 (" + iotCode + ") 的装备不存在于物联系统中!");
return CommonResponseUtil.success();
}
}
public static Map<String, String> mapStringToMap(String str) {
str = str.substring(1, str.length() - 1);
String[] strs = str.split(",");
Map<String, String> map = new HashMap<String, String>();
for (String string : strs) {
String key = string.split("=")[0];
String value = string.split("=")[1];
map.put(key, value);
}
return map;
}
}
......@@ -185,4 +185,5 @@ public interface EquipmentSpecificAlarmMapper extends BaseMapper<EquipmentSpecif
* @return
*/
List<EquipmentSpecificAlarm> getEquipListBySpecific(@Param("status") Boolean status, @Param("equipmentSpecificId") Long equipmentSpecificId);
}
......@@ -46,6 +46,8 @@ public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecif
*/
List<EquipmentSpecificIndex> getEquipmentSpeIndexByIotCode(String iotCode);
List<EquipmentSpecificIndex> getEquipmentSpeIndexDataByIotCode(String iotCode);
/**
* 通过设备id查询
*
......
......@@ -10,6 +10,7 @@ import com.yeejoin.equipmanage.common.utils.CommonPageInfoParam;
import com.yeejoin.equipmanage.common.vo.AlarmDataVO;
import com.yeejoin.equipmanage.common.vo.AlarmEquipMockDataVO;
import com.yeejoin.equipmanage.common.vo.AlarmListDataVO;
import com.yeejoin.equipmanage.common.vo.TopographyAlarmVo;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
......@@ -42,6 +43,9 @@ public interface IEquipmentSpecificAlarmService extends IService<EquipmentSpecif
org.springframework.data.domain.Page<AlarmListDataVO> listAlarmsPage(CommonPageInfoParam param);
org.springframework.data.domain.Page<TopographyAlarmVo> listAlarmsPageForTopography(CommonPageInfoParam param);
Map<String, Object> getSpecificInfoById(Long id);
Map<String, Object> getSpecificInfoByCode(String code);
......
......@@ -12,9 +12,11 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpServletResponse;
import com.yeejoin.equipmanage.common.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageImpl;
......@@ -43,10 +45,6 @@ import com.yeejoin.equipmanage.common.enums.EquipmentDataEnum;
import com.yeejoin.equipmanage.common.utils.CommonPageInfoParam;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.AlarmDataVO;
import com.yeejoin.equipmanage.common.vo.AlarmEquipMockDataVO;
import com.yeejoin.equipmanage.common.vo.AlarmListDataVO;
import com.yeejoin.equipmanage.common.vo.EquipmentAlarmDownloadVO;
import com.yeejoin.equipmanage.mapper.ConfirmAlarmMapper;
import com.yeejoin.equipmanage.mapper.EquipmentSpecificAlarmLogMapper;
import com.yeejoin.equipmanage.mapper.EquipmentSpecificAlarmMapper;
......@@ -223,6 +221,39 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
}
@Override
public org.springframework.data.domain.Page<TopographyAlarmVo> listAlarmsPageForTopography(CommonPageInfoParam param) {
Page page = new Page(param.getPageNumber(), param.getPageSize());
Page<Map<String, Object>> mybatisResult = this.baseMapper.pageAlarmsInfo(page, param);
List<TopographyAlarmVo> res = new ArrayList<>();
if (mybatisResult.getSize() > 0) {
mybatisResult.getRecords().forEach(x -> {
TopographyAlarmVo dataVO = new TopographyAlarmVo();
try {
dataVO.setCreateDate(DateUtils.dateParse(String.valueOf(x.get("createDate")),DateUtils.DATE_TIME_T_PATTERN));
} catch (ParseException e) {
e.printStackTrace();
}
dataVO.setFireEquipmentSpecificIndexName(String.valueOf(x.get("fireEquipmentSpecificIndexName")));
dataVO.setFireEquipmentName(String.valueOf(x.get("fireEquipmentName")));
dataVO.setWarehouseStructureName(String.valueOf(x.get("warehouseStructureName")));
dataVO.setEquipmentName(null == x.get("equipmentName") ? null : String.valueOf(x.get("equipmentName")));
dataVO.setHandleStatus(String.valueOf(x.get("handleStatus")));
dataVO.setStatus(String.valueOf(x.get("status")));
Object type = x.get("type");
if (AlarmTypeEnum.HZGJ.getCode().equals(type) || AlarmTypeEnum.GZGJ.getCode().equals(type)
|| AlarmTypeEnum.PB.getCode().equals(type)) {
dataVO.setAlarmType(AlarmTypeEnum.getTypeByCode(String.valueOf(type)));
}
dataVO.setAlarmContent(x.get("fireEquipmentName") + dataVO.getAlarmType());
dataVO.setHandleType(null == x.get("handleType") ? null : String.valueOf(x.get("handleType")));
res.add(dataVO);
});
}
param.setPageNumber(param.getPageNumber() - 1);
return new PageImpl<>(res, param, mybatisResult.getTotal());
}
@Override
public Map<String, Object> getSpecificInfoById(Long id) {
Map<String, Object> map = new HashMap<>();
EquipmentSpecificAlarmLog alarm = equipmentSpecificAlarmLogMapper.selectById(id);
......
......@@ -875,6 +875,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpecificAlarmLog.setAlarmReason(equipmentSpecificAlarm.getAlamReason());
equipmentSpecificAlarmLog.setEquipmentSpecificCode(equipmentSpecificAlarm.getCode());
equipmentSpecificAlarmLog.setBuildId(equipmentSpecificAlarm.getBuildId());
equipmentSpecificAlarmLog.setStatus(equipmentSpecificAlarm.getStatus());
equipmentSpecificAlarmLogService.save(equipmentSpecificAlarmLog);
// 同步告警消息给平台
if (amosSwitch) {
......
......@@ -2037,4 +2037,16 @@
</sql>
</changeSet>
<changeSet author="keyong" id="1640205688-1">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_equipment_specific_alarm_log" columnName="status"/>
</not>
</preConditions>
<comment>wl_equipment_specific_alarm_log add column status</comment>
<sql>
alter table `wl_equipment_specific_alarm_log` add column `status` bit(1) COLLATE utf8mb4_general_ci NOT NULL DEFAULT b'1' COMMENT '报警状态:1报警0恢复';
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -111,6 +111,7 @@
<select id="getEquipListBySpecific" resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarm">
<![CDATA[
SELECT
*
FROM
......@@ -120,6 +121,7 @@
AND equipment_specific_id = #{equipmentSpecificId}
ORDER BY
create_date DESC
]]>
</select>
......@@ -207,7 +209,8 @@
LEFT JOIN wl_equipment we ON wled.equipment_id = we.id
) d
<where>
<if test="param.warehouseStructureName != null and param.warehouseStructureName != ''">and d.warehouseStructureName like
<if test="param.warehouseStructureName != null and param.warehouseStructureName != ''">and
d.warehouseStructureName like
concat(concat("%",#{param.warehouseStructureName}),"%")
</if>
<if test="param.equipCode != null and param.equipCode != ''">AND d.fireEquipmentCode like
......@@ -219,15 +222,19 @@
<if test="param.alarmType == 'FIREALARM'">AND d.type = #{param.alarmType}</if>
<if test="param.orgCode != null and param.orgCode != ''">AND d.org_code = #{param.orgCode}</if>
<if test="param.type != null and param.type != ''">AND d.type = #{param.type}</if>
<if test="param.handleStatus != null and param.handleStatus != '' and param.handleStatus == 1">AND d.handleStatus = '已处理' </if>
<if test="param.handleStatus != null and param.handleStatus != '' and param.handleStatus == 2">AND d.handleStatus = '未处理' </if>
<if test="param.handleStatus != null and param.handleStatus != '' and param.handleStatus == 1">AND
d.handleStatus = '已处理'
</if>
<if test="param.handleStatus != null and param.handleStatus != '' and param.handleStatus == 2">AND
d.handleStatus = '未处理'
</if>
<if test="param.system != null and param.system != ''">
AND find_in_set(#{param.system},d.systemId)
</if>
<if test="param.buildIds!=null">
AND d.buildId IN
<foreach item="item" collection="param.buildIds" separator=","
open="(" close=")" index=""> #{item}
open="(" close=")" index="">#{item}
</foreach>
</if>
</where>
......@@ -266,7 +273,7 @@
<if test="alarmType == 'FIREALARM'">AND d.type = #{alarmType}</if>
</where>
</select>
<select id="pageAlarmsInfo" resultType="java.util.HashMap">
<select id="pageAlarmsInfo" resultType="Map">
SELECT
d.*
FROM
......@@ -302,7 +309,7 @@
wlesal.equipment_specific_index_value
END AS fireEquipmentPointValue,
wlesa.frequency AS frequency,
wlesa.status AS status,
wlesal.status AS status,
wlesal.type AS type,
wlesal.create_date AS createDate,
wlesal.build_id AS buildId,
......@@ -323,7 +330,8 @@
LEFT JOIN wl_equipment_specific_alarm wlesa ON wlesa.id = wlesal.equipment_specific_alarm_id) d
WHERE 1=1
AND d.fireEquipmentName IS NOT NULL
<if test="param.warehouseStructureName != null and param.warehouseStructureName != ''">and d.warehouseStructureName like
<if test="param.warehouseStructureName != null and param.warehouseStructureName != ''">and
d.warehouseStructureName like
concat(concat("%",#{param.warehouseStructureName}),"%")
</if>
<if test="param.equipCode != null and param.equipCode != ''">AND d.fireEquipmentCode like
......@@ -345,8 +353,11 @@
</if>
<if test="param.buildId != null and param.buildId != ''">
and (d.buildId=#{param.buildId}
or find_in_set(d.fireEquipmentId,(SELECT s.point_in_scene FROM `wl_source_scene` s where s.source_id = #{param.buildId})))
or find_in_set(d.fireEquipmentId,(SELECT s.point_in_scene FROM `wl_source_scene` s where s.source_id =
#{param.buildId})))
</if>
<if test="param.id!=null and param.id!=''">AND d.fireEquipmentId = #{param.id}</if>
<if test="param.status!=null and param.status!=3">AND d.status = #{param.status}</if>
ORDER BY d.createDate DESC
</select>
<select id="getAlarmList" resultType="java.util.HashMap">
......@@ -735,11 +746,13 @@
AND wlesal.create_date LIKE CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d' ), '%' )
</if>
<if test='dto.createDate != null and dto.createDate == "7"'>
AND wlesal.create_date BETWEEN CONCAT( DATE_ADD( DATE_FORMAT( NOW( ), '%Y-%m-%d ' ), INTERVAL - 7 DAY ), '00:00:00' )
AND wlesal.create_date BETWEEN CONCAT( DATE_ADD( DATE_FORMAT( NOW( ), '%Y-%m-%d ' ), INTERVAL - 7 DAY ),
'00:00:00' )
AND CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d ' ), '%', '23:59:59' )
</if>
<if test='dto.createDate != null and dto.createDate == "30"'>
AND wlesal.create_date BETWEEN CONCAT( DATE_ADD( DATE_FORMAT( NOW( ), '%Y-%m-%d ' ), INTERVAL - 30 DAY ), '00:00:00' )
AND wlesal.create_date BETWEEN CONCAT( DATE_ADD( DATE_FORMAT( NOW( ), '%Y-%m-%d ' ), INTERVAL - 30 DAY
), '00:00:00' )
AND CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d ' ), '%', '23:59:59' )
</if>
<if test="dto.createDate != null and dto.createDate.length() > 7">
......@@ -885,22 +898,26 @@
</if>
<if test='dto.createDate != null and dto.createDate == "3"'>
AND wlesal.create_date &gt;= subdate(curdate(),date_format(curdate(),'%w')-1) and wlesal.create_date &lt;= subdate(curdate(),date_format(curdate(),'%w')-7) <!--本周-->
AND wlesal.create_date &gt;= subdate(curdate(),date_format(curdate(),'%w')-1) and wlesal.create_date
&lt;= subdate(curdate(),date_format(curdate(),'%w')-7) <!--本周-->
</if>
<if test='dto.createDate != null and dto.createDate == "4"'>
AND wlesal.create_date &gt;= subdate(curdate(),date_format(curdate(),'%w')+6) and wlesal.create_date &lt;= subdate(curdate(),date_format(curdate(),'%w')-0)<!--上周-->
AND wlesal.create_date &gt;= subdate(curdate(),date_format(curdate(),'%w')+6) and wlesal.create_date
&lt;= subdate(curdate(),date_format(curdate(),'%w')-0)<!--上周-->
</if>
<if test='dto.createDate != null and dto.createDate == "5"'>
AND date_format(wlesa.create_date,'%y-%m')=date_format(curdate(),'%y-%m')<!--本月-->
</if>
<if test='dto.createDate != null and dto.createDate == "6"'>
AND date_format(wlesa.create_date,'%y-%m')=date_format(date_sub(curdate(), interval 1 month),'%y-%m') <!--上月-->
AND date_format(wlesa.create_date,'%y-%m')=date_format(date_sub(curdate(), interval 1
month),'%y-%m') <!--上月-->
</if>
<if test='dto.startDate != null and dto.endDate != null '>
AND DATE_FORMAT(wlesa.create_date, '%Y-%m-%d ' ) between DATE_FORMAT(#{dto.startDate}, '%Y-%m-%d ' ) and DATE_FORMAT(#{dto.endDate}, '%Y-%m-%d ' )
AND DATE_FORMAT(wlesa.create_date, '%Y-%m-%d ' ) between DATE_FORMAT(#{dto.startDate}, '%Y-%m-%d ' ) and
DATE_FORMAT(#{dto.endDate}, '%Y-%m-%d ' )
</if>
<if test="dto.isFirm == 'yes'">
......@@ -945,7 +962,8 @@
b.eqname fireEquipmentName,
b.qrcode fireEquipmentCode,
b.eqimg eqimg,
IFNULL(( select DISTINCT wl_equipment_specific_alarm.`status` from wl_equipment_specific_alarm where wl_equipment_specific_alarm.`status`=1 and wl_equipment_specific_alarm.equipment_detail_id=b.eqid ), 0) `status`
IFNULL(( select DISTINCT wl_equipment_specific_alarm.`status` from wl_equipment_specific_alarm where
wl_equipment_specific_alarm.`status`=1 and wl_equipment_specific_alarm.equipment_detail_id=b.eqid ), 0) `status`
from
(select
wl_warehouse_structure.full_name address,
......@@ -956,7 +974,8 @@
wl_equipment_specific.system_id
from wl_equipment_detail
LEFT JOIN wl_equipment_specific ON wl_equipment_specific.equipment_detail_id = wl_equipment_detail.id
LEFT JOIN (select DISTINCT wl_equipment_index.equipment_id from wl_equipment_index where wl_equipment_index.is_iot=1) b on b.equipment_id=wl_equipment_detail.equipment_id
LEFT JOIN (select DISTINCT wl_equipment_index.equipment_id from wl_equipment_index where
wl_equipment_index.is_iot=1) b on b.equipment_id=wl_equipment_detail.equipment_id
LEFT JOIN wl_stock_detail on wl_equipment_detail.id =wl_stock_detail.equipment_detail_id
LEFT JOIN wl_warehouse_structure on wl_stock_detail.warehouse_structure_id = wl_warehouse_structure.id
)b
......@@ -1023,7 +1042,8 @@
count(wl_equipment_specific_alarm.id) num
from wl_equipment_specific_alarm where wl_equipment_specific_alarm.`status`=1
<if test="tyep == 'yes'">
and wl_equipment_specific_alarm.confirm_type <![CDATA[<>]]> '' AND wl_equipment_specific_alarm.confirm_type IS NOT NULL
and wl_equipment_specific_alarm.confirm_type <![CDATA[<>]]> '' AND wl_equipment_specific_alarm.confirm_type
IS NOT NULL
</if>
<if test="tyep == 'no'">
and wl_equipment_specific_alarm.confirm_type is null
......
......@@ -78,7 +78,8 @@
wes.org_code AS orgCode,
wei.type_code AS typeCode,
wei.name AS indexName,
wei.unit AS indexUnitName
wei.unit AS indexUnitName,
wesi.update_date AS updateDate
FROM
wl_equipment_specific_index AS wesi
LEFT JOIN wl_equipment_specific AS wes ON wes.id = wesi.equipment_specific_id
......@@ -86,6 +87,30 @@
WHERE
wes.iot_code = #{iotCode}
</select>
<select id="getEquipmentSpeIndexDataByIotCode"
resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex">
SELECT
wesi.id AS id,
wei.name_key AS nameKey,
IFNULL(si.value_label, si.`value`) AS 'value',
wesi.equipment_specific_id AS equipmentSpecificId,
wesi.equipment_index_id AS equipmentIndexId,
wes.org_code AS code,
wes.iot_code AS iotCode,
wes.org_code AS orgCode,
wei.type_code AS typeCode,
wei.name AS indexName,
wei.unit AS indexUnitName,
wei.value_enum AS valueEnum
FROM
wl_equipment_specific_index AS wesi
LEFT JOIN wl_equipment_specific AS wes ON wes.id = wesi.equipment_specific_id
LEFT JOIN wl_equipment_index AS wei ON wei.id = wesi.equipment_index_id
WHERE
wes.iot_code = #{iotCode}
</select>
<select id="getEquipmentSpeIndexByEquipmentSecificId"
resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex">
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