Commit 23c88d80 authored by lisong's avatar lisong

添加接口

parent d9851bcc
......@@ -3,6 +3,8 @@ package com.yeejoin.equipmanage.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.service.IEmergencyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -14,11 +16,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.typroject.tyboot.core.foundation.utils.DateTimeUtil.ISO8601_DATE_HOUR_MIN_SEC;
/**
*
......@@ -171,4 +178,172 @@ public class EmergencyController extends AbstractBaseController {
return iEmergencyService.selectAlarmAnalysisCount(bizOrgCode, startDate, endDate);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("消防炮灭火系统告警分析-饼图")
@GetMapping(value = "/fireCannonAlarmAnalysisPie")
public List<Map<String, Object>> fireCannonAlarmAnalysisPie(@RequestParam(value = "startDate") String startDate,
@RequestParam(value = "endDate") String endDate,
@RequestParam(value = "systemType") String systemType) {
return iEmergencyService.selectFireCannonAlarmAnalysisPie(startDate, endDate, systemType);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("消防给水系统告警分析-饼图")
@GetMapping(value = "/waterSystemAlarmAnalysisPie")
public List<Map<String, Object>> waterSystemAlarmAnalysisPie(@RequestParam(value = "startDate") String startDate,
@RequestParam(value = "endDate") String endDate,
@RequestParam(value = "systemType") String systemType) {
return iEmergencyService.waterSystemAlarmAnalysisPie(startDate, endDate, systemType);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("消防给水系统告警分析-小图")
@GetMapping(value = "/waterSystemAlarmAnalysis")
public List<Map<String, Object>> waterSystemAlarmAnalysis(@RequestParam(value = "startDate") String startDate,
@RequestParam(value = "endDate") String endDate,
@RequestParam(value = "type") String type,
@RequestParam(value = "systemType") String systemType) {
ArrayList<Map<String, Object>> result = new ArrayList<>();
List<Map<String, Object>> maps = iEmergencyService.waterSystemAlarmAnalysis(startDate, endDate, "0", "", systemType);
if ("week".equals(type)) {
List<Map<String, String>> weeksMapInterval = DateUtils.getWeeksMapInterval(DateUtils.dateToStringMonth(startDate));
for (Map<String, String> week : weeksMapInterval) {
Date weekStart = null;
Date weekEnd = null;
try {
weekStart = DateUtils.dateParse(week.get("weekStart"), DateUtils.DATE_PATTERN);
weekEnd = DateUtils.dateParse(week.get("weekEnd"), DateUtils.DATE_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
}
long startTime = weekStart.getTime();
long endTime = weekEnd.getTime();
HashMap<String, Object> mapData = new HashMap<>();
for (Map<String, Object> map : maps) {
Date check = null;
try {
check = DateUtils.dateParse(String.valueOf(map.get("date")), DateUtils.DATE_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(check) && check.getTime() >= startTime && check.getTime() <= endTime) {
if (!ObjectUtils.isEmpty(mapData)) {
BigDecimal old = new BigDecimal(String.valueOf(mapData.get("controlCabinetAlarmNum")));
BigDecimal add = new BigDecimal(String.valueOf(map.get("controlCabinetAlarmNum")));
BigDecimal now = old.add(add);
mapData.put("controlCabinetAlarmNum", String.valueOf(now));
BigDecimal firePumpsOld = new BigDecimal(String.valueOf(mapData.get("firePumpsAlarmNum")));
BigDecimal firePumpsAdd = new BigDecimal(String.valueOf(map.get("firePumpsAlarmNum")));
BigDecimal firePumpsNow = firePumpsOld.add(firePumpsAdd);
mapData.put("firePumpsAlarmNum", String.valueOf(firePumpsNow));
BigDecimal stabilizedOld = new BigDecimal(String.valueOf(mapData.get("stabilizedPumpAlarmNum")));
BigDecimal stabilizedAdd = new BigDecimal(String.valueOf(map.get("stabilizedPumpAlarmNum")));
BigDecimal stabilizedNow = stabilizedOld.add(stabilizedAdd);
mapData.put("stabilizedPumpAlarmNum", String.valueOf(stabilizedNow));
} else {
mapData.put("name", week.get("name"));
mapData.put("controlCabinetAlarmNum", map.get("controlCabinetAlarmNum"));
mapData.put("firePumpsAlarmNum", map.get("firePumpsAlarmNum"));
mapData.put("stabilizedPumpAlarmNum", map.get("stabilizedPumpAlarmNum"));
}
}
}
result.add(mapData);
}
} else if ("day".equals(type)) {
return maps;
} else if ("month".equals(type)) {
String date = startDate.substring(0, 4) + "-01" + "-01";
return iEmergencyService.waterSystemAlarmAnalysis(startDate, endDate, "1", date, systemType);
}
return result;
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("消防炮系统告警分析-折线图")
@GetMapping(value = "/fireCannonSystemAlarmAnalysis")
public List<Map<String, Object>> fireCannonSystemAlarmAnalysis(@RequestParam(value = "startDate") String startDate,
@RequestParam(value = "endDate") String endDate,
@RequestParam(value = "type") String type,
@RequestParam(value = "systemType") String systemType) {
ArrayList<Map<String, Object>> result = new ArrayList<>();
List<Map<String, Object>> maps = iEmergencyService.fireCannonSystemAlarmAnalysis(startDate, endDate, "0", "", systemType);
if ("week".equals(type)) {
List<Map<String, String>> weeksMapInterval = DateUtils.getWeeksMapInterval(DateUtils.dateToStringMonth(startDate));
for (Map<String, String> week : weeksMapInterval) {
Date weekStart = null;
Date weekEnd = null;
try {
weekStart = DateUtils.dateParse(week.get("weekStart"), DateUtils.DATE_PATTERN);
weekEnd = DateUtils.dateParse(week.get("weekEnd"), DateUtils.DATE_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
}
long startTime = weekStart.getTime();
long endTime = weekEnd.getTime();
HashMap<String, Object> mapData = new HashMap<>();
for (Map<String, Object> map : maps) {
Date check = null;
try {
check = DateUtils.dateParse(String.valueOf(map.get("date")), DateUtils.DATE_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(check) && check.getTime() >= startTime && check.getTime() <= endTime) {
if (!ObjectUtils.isEmpty(mapData)) {
BigDecimal old = new BigDecimal(String.valueOf(mapData.get("powerLossNum")));
BigDecimal add = new BigDecimal(String.valueOf(map.get("powerLossNum")));
BigDecimal now = old.add(add);
mapData.put("powerLossNum", String.valueOf(now));
BigDecimal firePumpsOld = new BigDecimal(String.valueOf(mapData.get("faultNum")));
BigDecimal firePumpsAdd = new BigDecimal(String.valueOf(map.get("faultNum")));
BigDecimal firePumpsNow = firePumpsOld.add(firePumpsAdd);
mapData.put("faultNum", String.valueOf(firePumpsNow));
BigDecimal stabilizedOld = new BigDecimal(String.valueOf(mapData.get("fireAlarmNum")));
BigDecimal stabilizedAdd = new BigDecimal(String.valueOf(map.get("fireAlarmNum")));
BigDecimal stabilizedNow = stabilizedOld.add(stabilizedAdd);
mapData.put("fireAlarmNum", String.valueOf(stabilizedNow));
BigDecimal shieldOld = new BigDecimal(String.valueOf(mapData.get("shieldNum")));
BigDecimal shieldAdd = new BigDecimal(String.valueOf(map.get("shieldNum")));
BigDecimal shieldNow = shieldOld.add(shieldAdd);
mapData.put("shieldNum", String.valueOf(shieldNow));
} else {
mapData.put("name", week.get("name"));
mapData.put("shieldNum", map.get("shieldNum"));
mapData.put("fireAlarmNum", map.get("fireAlarmNum"));
mapData.put("faultNum", map.get("faultNum"));
mapData.put("powerLossNum", map.get("powerLossNum"));
}
}
}
result.add(mapData);
}
} else if ("day".equals(type)) {
return maps;
} else if ("month".equals(type)) {
String date = startDate.substring(0, 4) + "-01" + "-01";
return iEmergencyService.fireCannonSystemAlarmAnalysis(startDate, endDate, "1", date, systemType);
}
return result;
}
}
......@@ -66,4 +66,18 @@ public interface EmergencyMapper extends BaseMapper{
List<Map<String, Object>> selectAlarmAnalysisCount(@Param("bizOrgCode") String bizOrgCode, @Param("startDate")String startDate, @Param("endDate")String endDate);
Map<String, Object> getSystemAndCarCount();
List<String> selectSystemCodes(@Param("systemType") String systemType);
List<Map<String, Object>> selectFireCannonAlarmAnalysisPie(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("list") List<String> codes);
List<Map<String, Object>> waterSystemAlarmAnalysisPie(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("list") List<String> codes);
List<Map<String, Object>> waterSystemAlarmAnalysis(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("dataType")String dataType, @Param("date")String date, @Param("list") List<String> codes);
List<Map<String, Object>> fireCannonSystemAlarmAnalysis(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("dataType")String dataType, @Param("date")String date, @Param("list") List<String> codes);
}
......@@ -39,4 +39,14 @@ public interface IEmergencyService {
List<Map<String, Object>> selectAlarmAnalysisCount(String bizOrgCode, String startDate, String endDate);
Map<String, Object> systemAndCar();
List<Map<String, Object>> selectFireCannonAlarmAnalysisPie(String startDate, String endDate, String systemType);
List<Map<String, Object>> waterSystemAlarmAnalysisPie(String startDate, String endDate, String systemType);
List<Map<String, Object>> waterSystemAlarmAnalysis(String startDate, String endDate, String dataType, String date, String systemType);
List<Map<String, Object>> fireCannonSystemAlarmAnalysis(String startDate, String endDate, String dataType, String date, String systemType);
}
......@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.service.IEmergencyService;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
......@@ -102,4 +103,43 @@ public class EmergencyServiceImpl implements IEmergencyService {
public Map<String, Object> systemAndCar() {
return emergencyMapper.getSystemAndCarCount();
}
@Override
public List<Map<String, Object>> selectFireCannonAlarmAnalysisPie(String startDate, String endDate, String systemType) {
List<String> strings = emergencyMapper.selectSystemCodes(systemType);
if (!CollectionUtils.isEmpty(strings)) {
return emergencyMapper.selectFireCannonAlarmAnalysisPie(startDate, endDate, strings);
}
return null;
}
@Override
public List<Map<String, Object>> waterSystemAlarmAnalysisPie(String startDate, String endDate, String systemType) {
List<String> strings = emergencyMapper.selectSystemCodes(systemType);
if (!CollectionUtils.isEmpty(strings)) {
return emergencyMapper.waterSystemAlarmAnalysisPie(startDate, endDate, strings);
}
return null;
}
@Override
public List<Map<String, Object>> waterSystemAlarmAnalysis(String startDate, String endDate, String dataType, String date, String systemType) {
List<String> strings = emergencyMapper.selectSystemCodes(systemType);
if (!CollectionUtils.isEmpty(strings)) {
return emergencyMapper.waterSystemAlarmAnalysis(startDate, endDate, dataType, date, strings);
}
return null;
}
@Override
public List<Map<String, Object>> fireCannonSystemAlarmAnalysis(String startDate, String endDate, String dataType, String date, String systemType) {
List<String> strings = emergencyMapper.selectSystemCodes(systemType);
if (!CollectionUtils.isEmpty(strings)) {
return emergencyMapper.fireCannonSystemAlarmAnalysis(startDate, endDate, dataType, date, strings);
}
return null;
}
}
......@@ -511,6 +511,428 @@
) AS shieldNum
</select>
<select id="selectSystemCodes" resultType="java.lang.String">
SELECT
fs. code
FROM
f_fire_fighting_system fs
WHERE
fs.system_type_code = #{systemType}
</select>
<select id="selectFireCannonAlarmAnalysisPie" resultType="java.util.Map">
SELECT
(
SELECT
COUNT(
wespa.equipment_specific_id
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'Fault')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.create_date BETWEEN #{startDate}
AND #{endDate}
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS faultNum,
(
SELECT
COUNT(
wespa.equipment_specific_id
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'FireAlarm')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.create_date BETWEEN #{startDate}
AND #{endDate}
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS fireAlarmNum,
(
SELECT
COUNT(
wespa.equipment_specific_id
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'Shield')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.create_date BETWEEN #{startDate}
AND #{endDate}
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS shieldNum,
(
SELECT
COUNT(
wespa.equipment_specific_id
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'PowerLoss')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.create_date BETWEEN #{startDate}
AND #{endDate}
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS lossNum
</select>
<select id="waterSystemAlarmAnalysis" resultType="java.util.Map">
SELECT
temp.date,
(
SELECT
COUNT(1)
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.equipment_id = (SELECT we.id FROM wl_equipment we WHERE we.category_id = (SELECT wec.id FROM wl_equipment_category wec WHERE wec.code = '92010600' ) )
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS firePumpsAlarmNum,
(
SELECT
COUNT(1)
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.equipment_id = (SELECT we.id FROM wl_equipment we WHERE we.category_id = (SELECT wec.id FROM wl_equipment_category wec WHERE wec.code = '92010800' ) )
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS stabilizedPumpAlarmNum,
(
SELECT
COUNT(1)
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.equipment_id = (SELECT we.id FROM wl_equipment we WHERE we.category_id = (SELECT wec.id FROM wl_equipment_category wec WHERE wec.code = '92010500' ) )
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS controlCabinetAlarmNum
FROM
<if test="dataType == 1">
(
SELECT
date_format(
(#{date} - INTERVAL 0 MONTH),
'%Y-%m'
) AS `date`
UNION
(SELECT
date_format(
(#{date} - INTERVAL -1 MONTH),
'%Y-%m'
) AS `date`)
UNION
(SELECT
date_format(
(#{date} - INTERVAL -2 MONTH),
'%Y-%m'
) AS `date`)
UNION
(SELECT
date_format(
(#{date} - INTERVAL -3 MONTH),
'%Y-%m'
) AS `date`)
UNION
(SELECT
date_format(
(#{date} - INTERVAL -4 MONTH),
'%Y-%m'
) AS `date`)
UNION
(SELECT
date_format(
(#{date} - INTERVAL -5 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -6 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -7 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -8 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -9 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -10 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -11 MONTH),
'%Y-%m'
) AS `date`))temp
</if>
<if test="dataType != 1">
(
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
</if>
</select>
<select id="fireCannonSystemAlarmAnalysis" resultType="java.util.Map">
SELECT
temp.date,
(
SELECT
COUNT(1)
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'
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS fireAlarmNum,
(
SELECT
COUNT(1)
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'
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS shieldNum,
(
SELECT
COUNT(1)
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'
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS faultNum,
(
SELECT
COUNT(1)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'PowerLoss ')
AND wespa.create_date LIKE concat(temp.date, '%')
AND wespa.equipment_specific_index_value = 'true'
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS powerLossNum
FROM
<if test="dataType == 1">
(
SELECT
date_format(
(#{date} - INTERVAL 0 MONTH),
'%Y-%m'
) AS `date`
UNION
(SELECT
date_format(
(#{date} - INTERVAL -1 MONTH),
'%Y-%m'
) AS `date`)
UNION
(SELECT
date_format(
(#{date} - INTERVAL -2 MONTH),
'%Y-%m'
) AS `date`)
UNION
(SELECT
date_format(
(#{date} - INTERVAL -3 MONTH),
'%Y-%m'
) AS `date`)
UNION
(SELECT
date_format(
(#{date} - INTERVAL -4 MONTH),
'%Y-%m'
) AS `date`)
UNION
(SELECT
date_format(
(#{date} - INTERVAL -5 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -6 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -7 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -8 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -9 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -10 MONTH),
'%Y-%m'
) AS `date`)UNION
(SELECT
date_format(
(#{date} - INTERVAL -11 MONTH),
'%Y-%m'
) AS `date`))temp
</if>
<if test="dataType != 1">
(
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
</if>
</select>
<select id="waterSystemAlarmAnalysisPie" resultType="java.util.Map">
SELECT
(
SELECT
COUNT(
wespa.equipment_specific_id
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'FireAlarm')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.create_date BETWEEN #{startDate}
AND #{endDate}
AND wespa.equipment_id = (SELECT we.id FROM wl_equipment we WHERE we.category_id = (SELECT wec.id FROM wl_equipment_category wec WHERE wec.code = '92010600' ) )
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS firePumpsAlarmNum,
(
SELECT
COUNT(
wespa.equipment_specific_id
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'FireAlarm')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.create_date BETWEEN #{startDate}
AND #{endDate}
AND wespa.equipment_id = (SELECT we.id FROM wl_equipment we WHERE we.category_id = (SELECT wec.id FROM wl_equipment_category wec WHERE wec.code = '92010800' ) )
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS stabilizedPumpAlarmNum,
(
SELECT
COUNT(
wespa.equipment_specific_id
)
FROM
wl_equipment_specific_alarm_log wespa
WHERE
wespa.equipment_specific_index_key LIKE concat('%', 'Shield')
AND wespa.equipment_specific_index_value = 'true'
AND wespa.create_date BETWEEN #{startDate}
AND #{endDate}
AND wespa.equipment_id = (SELECT we.id FROM wl_equipment we WHERE we.category_id = (SELECT wec.id FROM wl_equipment_category wec WHERE wec.code = '92010500' ) )
<foreach collection="list" open="and (" close=")" item="code" index="index" separator="or">
wespa.system_codes like concat('%',#{code},'%')
</foreach>
) AS controlCabinetAlarmNum
</select>
<select id="getSystemAndCarCount" resultType="java.util.Map">
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