Commit bbd308de authored by KeYong's avatar KeYong

提交稳压泵实时数据查询接口

parent fd41e3bb
......@@ -786,4 +786,29 @@ public class SupervisionConfigureController extends AbstractBaseController {
// return format;
}
@PersonIdentify
@RequestMapping(value = "/pressurePump/page", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "稳压泵信号详情分页列表", produces = "application/json;charset=UTF-8", notes = "稳压泵信号详情分页列表")
public ResponseModel getPressurePumpPage(@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode,
@RequestParam(value = "id", required = false) String id,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam(value = "pageNum") String pageNum,
@RequestParam(value = "pageSize") String pageSize) {
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);
}
}
}
Map<String, Object> list = supervisionVideoService.getPressurePumpPage(bizOrgCode, id, startTime, endTime, pageNum, pageSize);
return CommonResponseUtil.success(list);
}
}
......@@ -694,6 +694,8 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
List<Map<String, Object>> selectAllPressurePumpInfo(@Param("bizOrgCode") String bizOrgCode, @Param("id") String id);
List<Map<String, Object>> selectAllPressurePumpInfoByBizOrgCode(@Param("bizOrgCode") String bizOrgCode, @Param("id") String id);
List<Map<String, Object>> selectAllPressureName(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> selectAllDays();
......
......@@ -26,5 +26,7 @@ public interface ISupervisionVideoService extends IService<SupervisionVideo> {
List<Map<String, Object>> selectPressureDetails(String bizOrgCode, String id, String startTime, String endTime);
Map<String, Object> getPressurePumpPage(String bizOrgCode, String id, String startTime, String endTime, String pageNum, String pageSize);
List<Map<String, Object>> selectAllPressureName(String bizOrgCode);
}
......@@ -444,8 +444,13 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
List<EquipmentSpecificIndex> equipmentSpecificIndexList = new ArrayList<>();
List<EquipmentSpecificAlarm> equipmentSpecificAlarms = new ArrayList<>();
List<IndexStateVo> indexStateList = new ArrayList<>();
JSONObject messageObj = JSONObject.parseObject(message);
JSONObject data = messageObj.getJSONObject("data");
if (!ObjectUtils.isEmpty(data)) {
message = JSON.toJSONString(data);
}
StationMessage stationMessage = JSON.parseObject(String.valueOf(message), StationMessage.class);
StationMessage stationMessage = JSON.parseObject(message, StationMessage.class);
log.info("接收到换流站Kafka消息: {}", stationMessage);
String indexAddress = null, value = null, timeStamp = null, quality = null, dataType = null;
if (stationMessage != null) {
......@@ -514,6 +519,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
//es存储数据
eSeqService.saveESEquiplistSpecificBySystemESVO(equipmentSpeIndex, String.valueOf(equipmentSpecificVo.getSystemId()), equipmentSpecificVo.getSystemName());
//更新装备性能指标
log.info("接收到遥信遥测消息更新sepcificIndex表消息对象是: {}", JSON.toJSONString(equipmentSpeIndex));
equipmentSpecificIndexService.updateById(equipmentSpeIndex);
// 更新设备表指标状态
......
......@@ -2,6 +2,9 @@ package com.yeejoin.equipmanage.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
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;
......@@ -11,6 +14,8 @@ 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.common.vo.StationMessage;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.mapper.SupervisionVideoMapper;
import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
......@@ -25,6 +30,7 @@ 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 org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.DecimalFormat;
import java.text.ParseException;
......@@ -33,6 +39,8 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import static org.typroject.tyboot.core.foundation.context.RequestContext.*;
@Slf4j
@Service
......@@ -53,6 +61,9 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap
@Autowired
private FireFightingSystemMapper fireFightingSystemMapper;
@Autowired
private IotFeign iotFeign;
@Value("${equipment.pressurepump.start}")
private String pressurePumpStart;
......@@ -302,6 +313,62 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap
}
}
@Override
public Map<String, Object> getPressurePumpPage(String bizOrgCode, String id, String startTime, String endTime, String pageNum, String pageSize) {
List<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.selectAllPressurePumpInfoByBizOrgCode(bizOrgCode, id);
List<Map<String, String>> resList = new ArrayList<>();
List<Map<String, String>> finalResList = resList;
pressurePumpInfo.stream().forEach(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 entity = null;
try {
entity = iotFeign.selectPage(getAppKey(), getProduct(), getToken(), startTime, endTime, prefix, suffix, pressurePumpStart, 0, 1000);
} catch (Exception e) {
throw new RuntimeException("调用AMOS-API-IOT服务失败,请检查服务是否正常!");
}
if (200 == entity.getStatus() && !ObjectUtils.isEmpty(entity.getResult())) {
String json = JSON.toJSONString(entity.getResult());
JSONObject messageObj = JSONObject.parseObject(json);
JSONArray array = messageObj.getJSONArray("records");
List<Map<String, String>> listObject = (List<Map<String, String>>) JSONArray.parse(JSON.toJSONString(array));
listObject.forEach(x -> {
Map<String, String> map = new HashMap<>();
map.put("id", UUID.randomUUID().toString());
map.put("name", String.valueOf(item.get("name")));
map.put("time", String.valueOf(x.get("time")).substring(0, 19).replace("T", " "));
map.put("value", String.valueOf(x.get(pressurePumpStart)));
finalResList.add(map);
});
}
});
Map<String, Object> resMap = new HashMap<>();
resMap.put("current", Integer.valueOf(pageNum));
resMap.put("pageSize", Integer.valueOf(pageSize));
resMap.put("total", finalResList.size());
if (ObjectUtils.isEmpty(finalResList)) {
resMap.put("pages", 0);
resMap.put("records", new ArrayList<>());
return resMap;
} else {
resList = finalResList.stream().sorted((t1, t2) -> t2.get("time").compareTo(t1.get("time"))).collect(Collectors.toList());
}
int startIndex = (Integer.valueOf(pageNum) - 1) * Integer.valueOf(pageSize);
int endIndex = Math.min(startIndex + Integer.valueOf(pageSize), resList.size());
int pages = (finalResList.size() + Integer.valueOf(pageSize) - 1) / Integer.valueOf(pageSize);
List<Map<String, String>> list = resList.subList(startIndex, endIndex);
resMap.put("pages", pages);
resMap.put("records", list);
return resMap;
}
@Override
public List<Map<String, Object>> selectAllPressureName(String bizOrgCode) {
......
......@@ -5887,6 +5887,29 @@
es.id
</select>
<select id="selectAllPressurePumpInfoByBizOrgCode" resultType="java.util.Map">
SELECT
es.id,
es.`name`,
concat_ws( '-', ws.full_name, ed.area ) area,
es.iot_code
FROM
wl_equipment_specific es
LEFT JOIN wl_equipment_detail ed ON es.equipment_detail_id = ed.id
LEFT JOIN wl_warehouse_structure ws ON ws.id = es.warehouse_structure_id
WHERE
ed.`code` LIKE '92010800%'
AND es.iot_code IS NOT NULL
<if test="bizOrgCode != null and bizOrgCode != ''" >
AND es.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
<if test="id != null and id != ''" >
AND es.id = #{id}
</if>
GROUP BY
es.id
</select>
<select id="selectAllPressureName" resultType="java.util.Map">
SELECT
es.`name`,
......
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