Commit e0d7d8e6 authored by xixinzhao's avatar xixinzhao

Merge remote-tracking branch 'origin/develop_dl' into develop_dl

parents 35fa7aee bbd308de
......@@ -125,4 +125,7 @@ public class EquipmentIndex extends BaseEntity {
@TableField(value = "unit")
private String unit;
@TableField(value = "alarm_rule")
private String alarmRule;
}
......@@ -145,9 +145,6 @@ public class EquipmentSpecificIndex extends BaseEntity {
@TableField(exist = false)
private String buildId;
@ApiModelProperty(value = "是否遥测")
@TableField(exist = false)
private Integer isTrend;
@ApiModelProperty(value = "绑定视屏数量")
@TableField(exist = false)
private int num;
......@@ -208,4 +205,12 @@ public class EquipmentSpecificIndex extends BaseEntity {
@ApiModelProperty(value = "网关标识")
@TableField(value = "gateway_id")
private String gatewayId;
@ApiModelProperty(value = "告警规则")
@TableField(value = "alarm_rule")
private String alarmRule;
@ApiModelProperty(value = "是否遥测")
@TableField(value = "is_trend")
private Boolean isTrend;
}
......@@ -90,4 +90,7 @@ public class EquipmentIndexVO {
@ApiModelProperty(value = "装备指标名称")
private String equipmentIndexName;
@ApiModelProperty(value = "告警规则")
private String alarmRule;
}
......@@ -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);
}
......@@ -1585,6 +1585,8 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
equipmentSpecificIndex.setUnit(index.getUnit());
equipmentSpecificIndex.setValueEnum(index.getValueEnum());
equipmentSpecificIndex.setTypeCode(index.getTypeCode());
equipmentSpecificIndex.setIsTrend(index.getIsTrend());
equipmentSpecificIndex.setAlamReason(index.getAlarmRule());
equipmentSpecificIndices.add(equipmentSpecificIndex);
});
}
......@@ -1921,7 +1923,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
iotIndexInfoVo.setType(equipmentSpecificIndex.getTypeName() != null ? equipmentSpecificIndex.getTypeName() : equipmentSpecificIndex.getIndexName());
iotIndexInfoVo.setNumber(deviceName);
if (equipmentSpecificIndex.getIsTrend() == 1) {
if (equipmentSpecificIndex.getIsTrend()) {
BigDecimal val = new BigDecimal(String.valueOf(entry.getValue()));
iotIndexInfoVo.setContent(equipmentSpecificIndex.getIndexName() + (val.setScale(2, BigDecimal.ROUND_HALF_UP)) + equipmentSpecificIndex.getIndexUnitName());
} else {
......
......@@ -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) {
......
......@@ -1174,4 +1174,20 @@
UPDATE `wl_car` wc SET wc.use_type = '自购';
</sql>
</changeSet>
<changeSet author="keyong" id="1694055999">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_equipment_index" columnName="alarm_rule"/>
</not>
</preConditions>
<comment>新增字段 type_code</comment>
<sql>
alter table `wl_equipment_index` add column `alarm_rule` varchar(50) DEFAULT NULL COMMENT '告警规则';
alter table `wl_equipment_specific_index` add column `is_trend` bit(1) DEFAULT b'0' COMMENT '是否支持趋势查看(冗余自wl_equipment_index)';
alter table `wl_equipment_specific_index` add column `alarm_rule` varchar(50) DEFAULT NULL COMMENT '告警规则(冗余自wl_equipment_index)';
UPDATE wl_equipment_specific_index esi SET esi.is_trend = ( SELECT is_trend FROM wl_equipment_index wei WHERE esi.equipment_index_id = wei.id ),
esi.alarm_rule = ( SELECT alarm_rule FROM wl_equipment_index wei WHERE esi.equipment_index_id = wei.id );
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -158,7 +158,8 @@
sort_num,
type,
is_trend,
value_enum
value_enum,
alarm_rule AS alarmRule
from
wl_equipment_index
where id = #{id}
......
......@@ -67,7 +67,8 @@
TRIM(CONCAT_WS(' ',wes.position,sd.description)) AS location,
sd.warehouse_structure_id AS buildId,
wes.biz_org_name AS bizOrgName,
wes.biz_org_code AS bizOrgCode
wes.biz_org_code AS bizOrgCode,
wesi.alarm_rule AS alarmRule
FROM
wl_equipment_specific_index AS wesi
LEFT JOIN wl_equipment_specific AS wes
......
......@@ -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