Browse Source

add: 故障、视频同步接口

zhongwei
haungxing 2 months ago
parent
commit
77d5e2a158
  1. 58
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultMatchVO.java
  2. 37
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpFaultMatchController.java
  3. 16
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpFaultMatchService.java
  4. 99
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFaultMatchServiceImpl.java
  5. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java
  6. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.java
  7. 33
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.xml
  8. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java
  9. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

58
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultMatchVO.java

@ -0,0 +1,58 @@
package com.hnac.hzims.fdp.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.utils.Func;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/09/23 14:35
*/
@Data
@EqualsAndHashCode
public class FdpFaultMatchVO implements Serializable {
@JSONField(name = "item_id")
private String itemId;
@JSONField(name = "item_name")
private String itemName;
@JSONField(name = "ord")
private String ord;
@JSONField(name = "station_id")
private String stationId;
@JSONField(name = "station_name")
private String stationName;
@JSONField(name = "device_name")
private String deviceName;
@JSONField(name = "fault_name")
private String faultName;
@JSONField(name = "is_root")
private Integer isRoot;
private Integer display;
@JSONField(name = "device_fault_name")
private String deviceFaultName;
public void setItemName() {
this.itemId = String.format("%s %s", this.deviceName, this.faultName);
}
public void setDeviceFaultName() {
if(Func.isNotEmpty(this.ord)) {
this.deviceFaultName = String.format("%s %s", this.ord, this.faultName);
} else {
this.deviceFaultName = String.format("%s %s", this.deviceName, this.faultName);
}
}
}

37
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpFaultMatchController.java

@ -0,0 +1,37 @@
package com.hnac.hzims.fdp.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.fdp.service.IFdpFaultMatchService;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/09/23 19:11
*/
@RestController
@AllArgsConstructor
@RequestMapping("/fdp/faultMatch")
@Api(value = "故障匹配数据接口管理",tags = "故障匹配数据接口管理")
public class FdpFaultMatchController {
private final IFdpFaultMatchService fdpFaultMatchService;
@GetMapping("/getFdpFaultMatchList")
@ApiOperation("获取故障匹配数据列表")
@ApiOperationSupport(order = 1)
@ApiInterface
public R<List<JSONObject>> getFdpFaultMatchList() {
return R.data(fdpFaultMatchService.getFdpFaultMatchList());
}
}

16
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpFaultMatchService.java

@ -0,0 +1,16 @@
package com.hnac.hzims.fdp.service;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.fdp.vo.FdpFaultMatchVO;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/09/23 16:14
*/
public interface IFdpFaultMatchService {
List<JSONObject> getFdpFaultMatchList();
}

99
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFaultMatchServiceImpl.java

@ -0,0 +1,99 @@
package com.hnac.hzims.fdp.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.collect.Lists;
import com.hnac.hzims.fdp.service.IFdpFaultMatchService;
import com.hnac.hzims.fdp.util.HttpRequestUtil;
import com.hnac.hzims.fdp.vo.FdpFaultMatchVO;
import lombok.RequiredArgsConstructor;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/09/23 16:15
*/
@Service
@RequiredArgsConstructor
public class FdpFaultMatchServiceImpl implements IFdpFaultMatchService {
@Value("${url.getStations}")
public String stationDataPath;
@Value("${url.getFaultAndMonitor}")
public String faultDataPath;
@Override
public List<JSONObject> getFdpFaultMatchList() {
List<FdpFaultMatchVO> matchVOList = Lists.newArrayList();
// 获取站点列表
String result = HttpRequestUtil.postCall(null, stationDataPath, "POST");
if (StringUtil.isNotBlank(result)) {
JSONObject resultObject = JSONObject.parseObject(result);
JSONArray dataArray = Optional.ofNullable(resultObject.getString("data")).map(JSONArray::parseArray).orElse(null);
if(Func.isNotEmpty(dataArray)) {
dataArray.forEach(jsonObject -> {
JSONObject station = JSONObject.parseObject(jsonObject.toString());
String stationId = station.getString("ID");
String stationName = station.getString("NAME");
List<FdpFaultMatchVO> faultMatchVOList = this.getFdpFaultListByStation(stationId,stationName);
if(Func.isNotEmpty(faultMatchVOList)) {
matchVOList.addAll(faultMatchVOList);
}
});
}
}
// 根据站点获取故障列表
return matchVOList.stream().map(vo -> JSON.toJSONString(vo, SerializerFeature.WriteMapNullValue)).map(JSONObject::parseObject).collect(Collectors.toList());
}
/**
* 根据站点获取故障列表
* @param stationId 站点ID
* @param stationName 站点名称
* @return List<FdpFaultMatchVO>
*/
private List<FdpFaultMatchVO> getFdpFaultListByStation(String stationId, String stationName) {
if (StringUtil.isNotBlank(stationId)) {
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("stationId", stationId);
String result = HttpRequestUtil.postCall(paramMap, faultDataPath, "POST");
if (StringUtil.isNotBlank(result)) {
JSONObject resultObject = JSONObject.parseObject(result);
JSONArray dataArray = Optional.ofNullable(resultObject.getString("data"))
.map(JSONObject::parseObject)
.map(data -> data.getString("faults"))
.map(JSONArray::parseArray).orElse(null);
if (Func.isNotEmpty(dataArray)) {
return dataArray.stream().map(jsonObject -> {
FdpFaultMatchVO matchVO = new FdpFaultMatchVO();
JSONObject fault = JSONObject.parseObject(jsonObject.toString());
matchVO.setItemId(fault.getString("ID"));
matchVO.setOrd(fault.getString("ORD"));
matchVO.setStationId(stationId);
matchVO.setStationName(stationName);
matchVO.setFaultName(fault.getString("NAME"));
matchVO.setDeviceName(fault.getString("DEVICE_NAME"));
matchVO.setIsRoot(fault.getInteger("IS_ROOT"));
matchVO.setDisplay(fault.getInteger("DISPLAY"));
matchVO.setDeviceFaultName();
matchVO.setItemName();
return matchVO;
}).collect(Collectors.toList());
}
}
}
return null;
}
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java

@ -26,6 +26,7 @@ import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzims.operational.station.vo.StationVideoTypeVO;
import com.hnac.hzims.operational.station.vo.VideoMonitorVO;
import com.hnac.hzims.operational.station.wrapper.StationVideoTypeWrapper;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -390,7 +391,8 @@ public class StationVideoTypeController extends BladeController {
@GetMapping ("/listAll")
@ApiOperationSupport(order = 200)
@ApiOperation(value = "获取所有站点视频")
public R<List<StationVideoTypeVO>> listAll() {
@ApiInterface
public R<List<Map<String,String>>> listAll() {
return R.data(stationVideoTypeService.listAll());
}
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.java

@ -16,6 +16,7 @@ import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.sql.Wrapper;
import java.util.List;
import java.util.Map;
/**
* @author hx
@ -45,5 +46,5 @@ public interface StationVideoTypeMapper extends UserDataScopeBaseMapper<StationV
@UserDataAuth
List<StationEntity> getAgencyStationsByVideo(@Param("type") String type);
List<StationVideoTypeVO> listAll();
List<Map<String,String>> listAll();
}

33
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.xml

@ -72,34 +72,15 @@
order by hs.sort
</select>
<select id="listAll" resultType="com.hnac.hzims.operational.station.vo.StationVideoTypeVO">
<select id="listAll" resultType="java.util.Map">
SELECT
hsvt.id,
hsvt.name,
hsvt.station_id,
hsvt.dept_id,
hsvt.is_hikvideo,
hsvt.address,
hsvt.type,
hsvt.live_source_address,
hsvt.point_code,
hsvt.tenant_id,
hsvt.create_time,
hsvt.update_time,
hsvt.create_user,
hsvt.update_user,
hsvt.is_deleted,
hsvt.status,
hsvt.create_dept,
hsvt.video_host,
hsvt.app_key,
hsvt.app_secret,
hsvt.sort,
hsvt.video_type,
hsvt.platform_id,
hs.`name` AS stationName
hsvt.`id` AS item_id,
hsvt.`name` AS video_name,
hsvt.station_id AS station_id,
hs.`name` AS station_name,
concat(hs.`code`, ' ', hs.`name`) AS item_name
FROM `hzims_station_video_type` hsvt
LEFT JOIN hzims_station hs ON hsvt.station_id = hs.`code`
LEFT JOIN hzims_station hs ON hsvt.station_id = hs.`code`
WHERE
hsvt.is_deleted = 0
AND hs.is_deleted = 0

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java

@ -80,6 +80,6 @@ public interface IStationVideoTypeService extends IService<StationVideoTypeEntit
List<StationVideoTypeEntity> getVideoByPointCodes(String pointCodes);
List<StationVideoTypeVO> listAll();
List<Map<String,String>> listAll();
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

@ -368,7 +368,7 @@ public class StationVideoTypeServiceImpl extends ServiceImpl<StationVideoTypeMap
}
@Override
public List<StationVideoTypeVO> listAll() {
public List<Map<String,String>> listAll() {
return baseMapper.listAll();
}
}

Loading…
Cancel
Save