Commit 84b45ab5 authored by 王晓倩's avatar 王晓倩

大屏标点报警接口

parent 7dbf6501
...@@ -50,8 +50,8 @@ public class TDetectorUserController extends BaseController ...@@ -50,8 +50,8 @@ public class TDetectorUserController extends BaseController
* @return * @return
*/ */
@GetMapping("/detectorUserList") @GetMapping("/detectorUserList")
public AjaxResult detectorUserList(){ public AjaxResult detectorUserList(TDetectorUser tDetectorUser){
return AjaxResult.success(tDetectorUserService.detectorUserList()); return AjaxResult.success(tDetectorUserService.detectorUserList(tDetectorUser));
} }
/** /**
......
package com.zehong.system.mapper; package com.zehong.system.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.zehong.system.domain.TDetectorInfo; import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.domain.TDetectorUser; import com.zehong.system.domain.TDetectorUser;
...@@ -27,15 +28,14 @@ public interface TDetectorUserMapper ...@@ -27,15 +28,14 @@ public interface TDetectorUserMapper
* *
* @return 燃气用户 * @return 燃气用户
*/ */
public List<TDetectorUserVO> countTDetectorUser(TDetectorInfo tDetectorInfo); public List<TDetectorUserVO> countTDetectorUser(TDetectorUser tDetectorUser);
/** /**
* 查询探测器报警用户 * 查询探测器报警用户
* *
* @param tDetectorUser 探测器用户 * @return map
* @return 探测器用户
*/ */
public TDetectorUserVO countTDetectorUserAlarm(TDetectorUser tDetectorUser); public List<Map> getDetectorUserAlarmList();
/** /**
* 泽宏云推送查询燃气用户 * 泽宏云推送查询燃气用户
......
...@@ -5,6 +5,7 @@ import java.util.Map; ...@@ -5,6 +5,7 @@ import java.util.Map;
import com.zehong.system.domain.TDeviceInfo; import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.TDeviceInfoS; import com.zehong.system.domain.TDeviceInfoS;
import com.zehong.system.domain.vo.TDetectorUserVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
/** /**
...@@ -23,6 +24,13 @@ public interface TDeviceInfoMapper ...@@ -23,6 +24,13 @@ public interface TDeviceInfoMapper
*/ */
public TDeviceInfo selectTDeviceInfoById(Long deviceId); public TDeviceInfo selectTDeviceInfoById(Long deviceId);
/**
* 查询设备报警信息
*
* @return map
*/
public List<Map> getDeviceInfoAlarmList();
/** /**
* 查询设备信息列表 * 查询设备信息列表
* *
......
package com.zehong.system.mapper; package com.zehong.system.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.zehong.system.domain.TSiteStationInfo; import com.zehong.system.domain.TSiteStationInfo;
/** /**
...@@ -19,6 +21,13 @@ public interface TSiteStationInfoMapper ...@@ -19,6 +21,13 @@ public interface TSiteStationInfoMapper
*/ */
public TSiteStationInfo selectTSiteStationInfoById(Long siteStationId); public TSiteStationInfo selectTSiteStationInfoById(Long siteStationId);
/**
* 查询场站报警信息
*
* @return map
*/
public List<Map> getSiteStationAlarmList();
/** /**
* 查询场站信息列表 * 查询场站信息列表
* *
......
package com.zehong.system.service; package com.zehong.system.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.zehong.system.domain.TDetectorUser; import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.domain.vo.TDetectorUserVO; import com.zehong.system.domain.vo.TDetectorUserVO;
...@@ -18,14 +20,14 @@ public interface ITDetectorUserService ...@@ -18,14 +20,14 @@ public interface ITDetectorUserService
* *
* @return 探测器用户集合 * @return 探测器用户集合
*/ */
public List<TDetectorUserVO> detectorUserList(); public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser);
/** /**
* 查询探测器报警用户(前台调用) * 查询探测器报警用户(前台调用)
* *
* @return 探测器用户 * @return 探测器用户
*/ */
public List<TDetectorUserVO> getDetectorUserAlarmList(); public List<Map> getDetectorUserAlarmList();
/** /**
* 查询探测器报警用户(后台推送) * 查询探测器报警用户(后台推送)
...@@ -33,7 +35,7 @@ public interface ITDetectorUserService ...@@ -33,7 +35,7 @@ public interface ITDetectorUserService
* @param tDetectorUser 探测器用户 * @param tDetectorUser 探测器用户
* @return 探测器用户 * @return 探测器用户
*/ */
public TDetectorUserVO detectorUserAlarmList(TDetectorUser tDetectorUser); public List<TDetectorUserVO> detectorUserAlarmList(TDetectorUser tDetectorUser);
/** /**
* 泽宏云推送查询燃气用户 * 泽宏云推送查询燃气用户
......
...@@ -2,19 +2,18 @@ package com.zehong.system.service.impl; ...@@ -2,19 +2,18 @@ package com.zehong.system.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.domain.TDetectorReportData;
import com.zehong.system.domain.vo.TDetectorUserVO; import com.zehong.system.domain.vo.TDetectorUserVO;
import com.zehong.system.mapper.TDetectorInfoMapper; import com.zehong.system.mapper.TDetectorInfoMapper;
import com.zehong.system.mapper.TDetectorReportDataMapper; import com.zehong.system.mapper.TDeviceInfoMapper;
import com.zehong.system.mapper.TSiteStationInfoMapper;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TDetectorUserMapper; import com.zehong.system.mapper.TDetectorUserMapper;
import com.zehong.system.domain.TDetectorUser; import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.service.ITDetectorUserService; import com.zehong.system.service.ITDetectorUserService;
import org.springframework.util.StringUtils;
/** /**
* 燃气用户Service业务层处理 * 燃气用户Service业务层处理
...@@ -28,9 +27,9 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService ...@@ -28,9 +27,9 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
@Autowired @Autowired
private TDetectorUserMapper tDetectorUserMapper; private TDetectorUserMapper tDetectorUserMapper;
@Autowired @Autowired
private TDetectorInfoMapper tDetectorInfoMapper; private TDeviceInfoMapper tDeviceInfoMapper;
@Autowired @Autowired
private TDetectorReportDataMapper tDetectorReportDataMapper; private TSiteStationInfoMapper tSiteStationInfoMapper;
/** /**
...@@ -39,10 +38,10 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService ...@@ -39,10 +38,10 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
* @return 探测器用户 * @return 探测器用户
*/ */
@Override @Override
public List<TDetectorUserVO> detectorUserList() public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser)
{ {
List<TDetectorUserVO> list = new ArrayList<>(); List<TDetectorUserVO> list = new ArrayList<>();
List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser(new TDetectorInfo()); List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser(tDetectorUser);
List<Object> initList = new ArrayList<>(); List<Object> initList = new ArrayList<>();
for(TDetectorUserVO user : tDetectorUserList){ for(TDetectorUserVO user : tDetectorUserList){
...@@ -54,14 +53,12 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService ...@@ -54,14 +53,12 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
initList.add(user); initList.add(user);
userVO.setDetectorCountList(initList); userVO.setDetectorCountList(initList);
userVO.setIconType("6"); userVO.setIconType("6");
userVO.setUserStatus("1");
} else { } else {
BeanUtils.copyProperties(user, temp); BeanUtils.copyProperties(user, temp);
List<Object> newList = new ArrayList<>(); List<Object> newList = new ArrayList<>();
newList.add(temp); newList.add(temp);
userVO.setDetectorCountList(newList); userVO.setDetectorCountList(newList);
userVO.setIconType("6"); userVO.setIconType("6");
userVO.setUserStatus("1");
list.add(userVO); list.add(userVO);
} }
} }
...@@ -75,34 +72,32 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService ...@@ -75,34 +72,32 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
* @return 探测器用户 * @return 探测器用户
*/ */
@Override @Override
public List<TDetectorUserVO> getDetectorUserAlarmList() public List<Map> getDetectorUserAlarmList()
{ {
List<TDetectorUserVO> list = new ArrayList<>(); List<Map> list = new ArrayList<>();
TDetectorInfo tDetectorInfo = new TDetectorInfo();
tDetectorInfo.setDetectorStatus("2");
// 查询报警的数据
List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser(tDetectorInfo);
List<Object> initList = new ArrayList<>(); // 查询报警用户
for(TDetectorUserVO user : tDetectorUserList){ List<Map> userList = tDetectorUserMapper.getDetectorUserAlarmList();
TDetectorUserVO userVO = new TDetectorUserVO(); for(Map map : userList){
BeanUtils.copyProperties(user, userVO); map.put("iconType", "6");
list.add(map);
TDetectorUserVO temp = new TDetectorUserVO(); }
if(user.getUserId().equals(temp.getUserId())){ // 查询报警设备
initList.add(user); List<Map> infoList = tDeviceInfoMapper.getDeviceInfoAlarmList();
userVO.setDetectorCountList(initList); for(Map map : infoList){
userVO.setIconType("6"); // deviceType:1阀门井 2调压箱
userVO.setUserStatus("2"); if(map.get("deviceType").equals("1")){
} else { map.put("iconType", "3");
BeanUtils.copyProperties(user, temp); } else if(map.get("deviceType").equals("2")){
List<Object> newList = new ArrayList<>(); map.put("iconType", "2");
newList.add(temp);
userVO.setDetectorCountList(newList);
userVO.setIconType("6");
userVO.setUserStatus("2");
list.add(userVO);
} }
list.add(map);
}
// 查询报警场站
List<Map> stationList = tSiteStationInfoMapper.getSiteStationAlarmList();
for(Map map : stationList){
map.put("iconType", "4");
list.add(map);
} }
return list; return list;
...@@ -115,17 +110,22 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService ...@@ -115,17 +110,22 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
* @return 探测器用户 * @return 探测器用户
*/ */
@Override @Override
public TDetectorUserVO detectorUserAlarmList(TDetectorUser tDetectorUser) public List<TDetectorUserVO> detectorUserAlarmList(TDetectorUser tDetectorUser)
{ {
List<Object> list = new ArrayList<>(); List<TDetectorUserVO> list = new ArrayList<>();
TDetectorUserVO user = tDetectorUserMapper.countTDetectorUserAlarm(tDetectorUser); List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser(tDetectorUser);
TDetectorUserVO userVO = new TDetectorUserVO(); List<Object> initList = new ArrayList<>();
BeanUtils.copyProperties(user, userVO); for(TDetectorUserVO user : tDetectorUserList) {
list.add(user); TDetectorUserVO userVO = new TDetectorUserVO();
userVO.setDetectorCountList(list); BeanUtils.copyProperties(user, userVO);
initList.add(userVO);
userVO.setDetectorCountList(initList);
return userVO; list.add(user);
}
return list;
} }
/** /**
......
...@@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where user_id = #{userId} where user_id = #{userId}
</select> </select>
<select id="countTDetectorUser" resultType="TDetectorUserVO" parameterType="TDetectorInfo"> <select id="countTDetectorUser" resultType="TDetectorUserVO" parameterType="TDetectorUser">
select t1.*, select t1.*,
IFNULL(t2.historyAlarmNum,0) AS historyAlarmNum, IFNULL(t2.historyAlarmNum,0) AS historyAlarmNum,
IFNULL(t2.processingAlarmNum,0) AS processingAlarmNum, IFNULL(t2.processingAlarmNum,0) AS processingAlarmNum,
...@@ -66,8 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -66,8 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.phone AS phone, a.phone AS phone,
a.email AS email, a.email AS email,
CASE a.detector_type CASE a.detector_type
WHEN '1' THEN '家用报警器' WHEN '1' THEN '家用探测器'
WHEN '2' THEN '工业报警器' END AS detectorType, WHEN '2' THEN '工业探测器' END AS detectorType,
COUNT(a.detector_id) AS detectorCount, COUNT(a.detector_id) AS detectorCount,
SUM(CASE a.detector_status WHEN '0' THEN 1 ELSE 0 END) AS onLineNum, SUM(CASE a.detector_status WHEN '0' THEN 1 ELSE 0 END) AS onLineNum,
SUM(CASE a.detector_status WHEN '1' THEN 1 ELSE 0 END) AS offLineNum SUM(CASE a.detector_status WHEN '1' THEN 1 ELSE 0 END) AS offLineNum
...@@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a2.* from t_detector_info a1 a2.* from t_detector_info a1
right join t_detector_user a2 on a1.user_id = a2.user_id right join t_detector_user a2 on a1.user_id = a2.user_id
<where> a1.is_del = '0' and a2.is_del = '0' <where> a1.is_del = '0' and a2.is_del = '0'
<if test="detectorStatus != null and detectorStatus != ''"> and a1.detector_status = #{detectorStatus}</if> <if test="userId != null and userId != ''"> and a2.user_id = #{userId}</if>
</where>) a </where>) a
group by a.user_id,a.detector_type group by a.user_id,a.detector_type
...@@ -92,59 +92,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -92,59 +92,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join t_detector_info b2 on b1.detector_code = b2.detector_code left join t_detector_info b2 on b1.detector_code = b2.detector_code
right join t_detector_user b3 on b2.user_id = b3.user_id right join t_detector_user b3 on b2.user_id = b3.user_id
<where> b2.is_del = '0' and b3.is_del = '0' <where> b2.is_del = '0' and b3.is_del = '0'
<if test="detectorStatus != null and detectorStatus != ''"> and b2.detector_status = #{detectorStatus}</if> <if test="userId != null and userId != ''"> and b3.user_id = #{userId}</if>
</where>) b </where>) b
group by b.user_id,b.detector_type group by b.user_id,b.detector_type
) t2 on t2.userId = t1.userId ) t2 on t2.userId = t1.userId
</select> </select>
<select id="countTDetectorUserAlarm" resultType="TDetectorUserVO" parameterType="TDetectorUser"> <select id="getDetectorUserAlarmList" resultType="Map">
select t1.*, select a2.user_id as userId
IFNULL(t2.historyAlarmNum,0) AS historyAlarmNum, from t_detector_info a1
IFNULL(t2.processingAlarmNum,0) AS processingAlarmNum, right join t_detector_user a2 on a1.user_id = a2.user_id
IFNULL(t2.cancelAlarmNum,0) AS cancelAlarmNum where a1.is_del = '0' and a2.is_del = '0' and a1.detector_status = '2'
from(
select a.user_id AS userId,
a.detector_id AS detectorId,
a.detector_status AS detectorStatus,
a.nick_name AS nickName,
a.user_type AS userType,
a.address AS address,
a.longitude AS longitude,
a.latitude AS latitude,
a.linkman AS linkman,
a.phone AS phone,
a.email AS email,
CASE a.detector_type
WHEN '1' THEN '家用报警器'
WHEN '2' THEN '工业报警器' END AS detectorType,
COUNT(a.detector_id) AS detectorCount,
SUM(CASE a.detector_status WHEN '0' THEN 1 ELSE 0 END) AS onLineNum,
SUM(CASE a.detector_status WHEN '1' THEN 1 ELSE 0 END) AS offLineNum
from(select a1.detector_id,
a1.detector_type,
a1.detector_status,
a2.* from t_detector_info a1
right join t_detector_user a2 on a1.user_id = a2.user_id
where a1.is_del = '0' and a2.is_del = '0' and a2.user_id = #{userId}) a
group by a.detector_type
) t1 left join (
select b.user_id AS userId,
COUNT(b.id) AS historyAlarmNum,
SUM(CASE b.is_cancel_alarm WHEN '0' THEN 1 ELSE 0 END) AS processingAlarmNum,
COUNT(b.id) - SUM(CASE b.is_cancel_alarm WHEN '0' THEN 1 ELSE 0 END) AS cancelAlarmNum
from(select b1.id,b1.is_cancel_alarm,b2.*
from t_detector_report_data b1
left join t_detector_info b2 on b1.detector_code = b2.detector_code
right join t_detector_user b3 on b2.user_id = b3.user_id
where b2.is_del = '0' and b3.is_del = '0' and b3.user_id = #{userId}) b
group by b.detector_type
) t2 on t2.userId = t1.userId
</select> </select>
<insert id="insertTDetectorUser" parameterType="TDetectorUser" useGeneratedKeys="true" keyProperty="userId"> <insert id="insertTDetectorUser" parameterType="TDetectorUser" useGeneratedKeys="true" keyProperty="userId">
......
...@@ -64,6 +64,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -64,6 +64,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where device_id = #{deviceId} and is_del='0' where device_id = #{deviceId} and is_del='0'
</select> </select>
<select id="getDeviceInfoAlarmList" resultType="Map">
select a2.device_id as deviceId,
a2.device_type as deviceType
from t_detector_info a1
right join t_device_info a2 on a1.device_id = a2.device_id
where a1.is_del = '0' and a2.is_del = '0' and a1.detector_status = '2'
</select>
<insert id="insertTDeviceInfo" parameterType="TDeviceInfo" useGeneratedKeys="true" keyProperty="deviceId"> <insert id="insertTDeviceInfo" parameterType="TDeviceInfo" useGeneratedKeys="true" keyProperty="deviceId">
insert into t_device_info insert into t_device_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
......
...@@ -46,6 +46,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -46,6 +46,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where site_station_id = #{siteStationId} and is_del='0' where site_station_id = #{siteStationId} and is_del='0'
</select> </select>
<select id="getSiteStationAlarmList" resultType="Map">
select a2.site_station_id as siteStationId
from t_detector_info a1
right join t_site_station_info a2 on a1.site_station_id = a2.site_station_id
where a1.is_del = '0' and a2.is_del = '0' and a1.detector_status = '2'
</select>
<insert id="insertTSiteStationInfo" parameterType="TSiteStationInfo" useGeneratedKeys="true" keyProperty="siteStationId"> <insert id="insertTSiteStationInfo" parameterType="TSiteStationInfo" useGeneratedKeys="true" keyProperty="siteStationId">
insert into t_site_station_info insert into t_site_station_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
......
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