Commit 9fca8e34 authored by lisong's avatar lisong

添加接口

parent 8154a4a9
......@@ -17,6 +17,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
/**
......@@ -141,4 +142,17 @@ public class EmergencyController extends AbstractBaseController {
return iEmergencyService.selectPressureFlow(page, bizOrgCode);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("火灾自动报警系统告警分析")
@GetMapping(value = "/selectAlarmAnalysis")
public List<Map<String, Object>> selectPressureFlow(@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode,
@RequestParam(value = "startDate") String startDate,
@RequestParam(value = "endDate") String endDate) {
if (ObjectUtils.isEmpty(bizOrgCode)){
ReginParams reginParams = getSelectedOrgInfo();
bizOrgCode = reginParams.getPersonIdentity().getBizOrgCode();
}
return iEmergencyService.selectAlarmAnalysis(bizOrgCode, startDate, endDate);
}
}
......@@ -454,4 +454,73 @@ public class SupervisionConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(supervisionVideoService.queryVideoAllId(bizOrgCode));
}
@PersonIdentify
@RequestMapping(value = "/selectPressureMonth", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询对应站下所有视频id", produces = "application/json;charset=UTF-8", notes = "根据id查询视频")
public ResponseModel select1(@RequestParam("bizOrgCode") String bizOrgCode) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String startDay = df.format(new Date());
Calendar calendar = Calendar.getInstance();
calendar.set(Integer.parseInt(startDay.substring(0, 4)), Integer.parseInt(startDay.substring(5, 7)) - 1, 1);
String firstDayOfMonth = new SimpleDateFormat("yyyy-MM-dd ").format(calendar.getTime());
System.out.println("第一天:" + firstDayOfMonth + "00:00:00");
//这里先设置要获取月份的下月的第一天
calendar.set(Integer.parseInt(startDay.substring(0, 4)), Integer.parseInt(startDay.substring(5, 7)), 1);
//这里将日期值减去一天,从而获取到要求的月份最后一天
calendar.add(Calendar.DATE, -1);
String lastDayOfMonth = new SimpleDateFormat("yyyy-MM-dd ").format(calendar.getTime());
System.out.println("最后一天:" + lastDayOfMonth + "23:59:59");
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);
}
}
}
// 稳压泵信息
List<Map<String, Object>> pressurePumps = fireFightingSystemMapper.selectAllPressurePumpInfo(bizOrgCode);
// x轴数据
List<Map<String, Object>> data = fireFightingSystemMapper.selectAllDays();
for (Map<String, Object> pressurePump : pressurePumps) {
String prefix = null;
String suffix = null;
String iotCode = pressurePump.get("iot_code").toString();
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
ResponseModel mounthEntity = null;
try {
mounthEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), firstDayOfMonth + "00:00:00", lastDayOfMonth + "23:59:59", prefix, suffix, null);
} catch (Exception e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(mounthEntity) && "200".equals(String.valueOf(mounthEntity.getStatus()))) {
for (Map<String, Object> item : data) {
HashMap<String, Object> map = new HashMap<>();
map.put("name", pressurePump.get("name"));
String json1 = JSON.toJSONString(mounthEntity.getResult());
List<Map<String, String>> list = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = list.stream().filter(t -> (t.containsKey("time") && t.get("time").substring(0, 10).equals(item.get("date")))).collect(Collectors.toList());
map.put("value", collect.size());
if (item.containsKey("yData")) {
List<Map<String, Object>> yData1 = (List<Map<String, Object>>) item.get("yData");
yData1.add(map);
} else {
ArrayList<Map<String, Object>> maps = new ArrayList<>();
maps.add(map);
item.put("yData", maps);
}
}
}
}
return CommonResponseUtil.success(data);
}
}
......@@ -61,4 +61,6 @@ public interface EmergencyMapper extends BaseMapper{
List<Map<String, Object>> getCAFSWaterTankInfo(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> selectAlarmAnalysis(@Param("bizOrgCode") String bizOrgCode, @Param("startDate")String startDate, @Param("endDate")String endDate);
}
......@@ -637,5 +637,10 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
Map<String, Object> getStationConnectStatus();
List<Map<String, Object>> getStationStatusStatistics();
List<Map<String, Object>> selectAllPressurePumpInfo(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> selectAllDays();
List<Map<String, Object>> getEquip(@Param("id") Long id);
}
......@@ -33,4 +33,6 @@ public interface IEmergencyService {
Page<Map<String, Object>> selectOilDrainage(Page<Map<String, Object>> page, String bizOrgCode, String code);
Page<Map<String, Object>> selectPressureFlow(Page<Map<String, Object>> page, String bizOrgCode);
List<Map<String, Object>> selectAlarmAnalysis(String bizOrgCode, String startDate, String endDate);
}
......@@ -87,4 +87,9 @@ public class EmergencyServiceImpl implements IEmergencyService {
public Page<Map<String, Object>> selectPressureFlow(Page<Map<String, Object>> page, String bizOrgCode) {
return emergencyMapper.selectPressureFlow(page, bizOrgCode);
}
@Override
public List<Map<String, Object>> selectAlarmAnalysis(String bizOrgCode, String startDate, String endDate) {
return emergencyMapper.selectAlarmAnalysis(bizOrgCode, startDate, endDate);
}
}
......@@ -404,5 +404,68 @@
wes.equipment_code LIKE concat( '92010700', '%' ) AND wes.biz_org_code LIKE CONCAT( #{bizOrgCode}, '%' )
) temp
</select>
<select id="selectAlarmAnalysis" resultType="java.util.Map">
SELECT
temp.date,
(
SELECT
COUNT(
DISTINCT (
wespa.equipment_specific_id
)
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'Fault')
AND wespa.create_date LIKE concat(temp.date, '%')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.biz_org_code like concat(#{bizOrgCode}, '%')
) AS faultNum,
(
SELECT
COUNT(
DISTINCT (
wespa.equipment_specific_id
)
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'FireAlarm')
AND wespa.create_date LIKE concat(temp.date, '%')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.biz_org_code like concat(#{bizOrgCode}, '%')
) AS alarmNum,
(
SELECT
COUNT(
DISTINCT (
wespa.equipment_specific_id
)
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'Shield')
AND wespa.create_date LIKE concat(temp.date, '%')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.biz_org_code like concat(#{bizOrgCode}, '%')
) AS shieldNum
FROM
(
SELECT temp.selected_date as date FROM
(SELECT ADDDATE('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date FROM
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t0,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t1,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t2,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t3,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t4)
temp
WHERE selected_date BETWEEN #{startDate} AND #{endDate}
) temp
ORDER BY
temp.date
</select>
</mapper>
......@@ -5508,6 +5508,99 @@
GROUP BY
s.id
</select>
<select id="selectAllPressurePumpInfo" resultType="java.util.Map">
SELECT
ed.`name`,
concat_ws( '-', ws.full_name, ed.area ) area,
es.iot_code,
es.id,
IFNULL( sum( `status` ), 0 ) AS isAlarm
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
LEFT JOIN wl_equipment_specific_alarm esa ON esa.equipment_specific_id = es.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>
GROUP BY
es.id
</select>
<select id="selectAllDays" resultType="java.util.Map">
select temp.date from (
SELECT
date
FROM
(
SELECT
DATE_FORMAT(
DATE_SUB(
last_day(curdate()),
INTERVAL xc - 1 DAY
),
'%Y-%m-%d'
) AS date
FROM
(
SELECT
@xi :=@xi + 1 AS xc
FROM
(
SELECT
1
UNION
SELECT
2
UNION
SELECT
3
UNION
SELECT
4
UNION
SELECT
5
UNION
SELECT
6
) xc1,
(
SELECT
1
UNION
SELECT
2
UNION
SELECT
3
UNION
SELECT
4
UNION
SELECT
5
UNION
SELECT
6
) xc2,
(SELECT @xi := 0) xc0
) xcxc
) x0
WHERE
x0.date >= (
SELECT
date_add(
curdate(),
INTERVAL - DAY (curdate()) + 1 DAY
)
)
)temp
order by temp.date
</select>
<select id="getEquip" resultType="java.util.Map">
......
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