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

大屏标点报警接口

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