Commit bd3ebb9f authored by 王晓倩's avatar 王晓倩

大屏用户列表接口、用户报警接口、泽宏云推送调用查询用户接口

parent 35db2bd1
......@@ -91,7 +91,7 @@ public class TDetectorReportController extends BaseController
TDetectorUser tDetectorUser = new TDetectorUser();
tDetectorUser.setNickName(username);
tDetectorUser.setIsDel("0");
List<TDetectorUserVO> tDetectorUserList = tDetectorUserService.detectorUserList(tDetectorUser);
List<TDetectorUser> tDetectorUserList = tDetectorUserService.selectTDetectorUser(tDetectorUser);
if(tDetectorUserList.size() == 0){
return AjaxResult.error(1,"查询不到用户名username=" + username);
}
......@@ -167,7 +167,7 @@ public class TDetectorReportController extends BaseController
TDetectorUser tDetectorUser = new TDetectorUser();
tDetectorUser.setNickName(username);
tDetectorUser.setIsDel("0");
List<TDetectorUserVO> tDetectorUserList = tDetectorUserService.detectorUserList(tDetectorUser);
List<TDetectorUser> tDetectorUserList = tDetectorUserService.selectTDetectorUser(tDetectorUser);
if(tDetectorUserList.size() == 0){
return AjaxResult.error(1,"查询不到用户名username=" + username);
}
......@@ -224,7 +224,7 @@ public class TDetectorReportController extends BaseController
TDetectorUser tDetectorUser = new TDetectorUser();
tDetectorUser.setNickName(username);
tDetectorUser.setIsDel("0");
List<TDetectorUserVO> tDetectorUserList = tDetectorUserService.detectorUserList(tDetectorUser);
List<TDetectorUser> tDetectorUserList = tDetectorUserService.selectTDetectorUser(tDetectorUser);
if(tDetectorUserList.size() == 0){
continue;
}
......@@ -265,7 +265,7 @@ public class TDetectorReportController extends BaseController
TDetectorUser tDetectorUser1 = new TDetectorUser();
tDetectorUser1.setNickName(sourceUsername);
tDetectorUser1.setIsDel("0");
List<TDetectorUserVO> tDetectorUserList1 = tDetectorUserService.detectorUserList(tDetectorUser1);
List<TDetectorUser> tDetectorUserList1 = tDetectorUserService.selectTDetectorUser(tDetectorUser1);
if(tDetectorUserList1.size() == 0){
return AjaxResult.error(4,"查询不到原用户名sourceUsername=" + sourceUsername);
}
......@@ -273,7 +273,7 @@ public class TDetectorReportController extends BaseController
TDetectorUser tDetectorUser2 = new TDetectorUser();
tDetectorUser2.setNickName(targetUsername);
tDetectorUser2.setIsDel("0");
List<TDetectorUserVO> tDetectorUserList2 = tDetectorUserService.detectorUserList(tDetectorUser2);
List<TDetectorUser> tDetectorUserList2 = tDetectorUserService.selectTDetectorUser(tDetectorUser2);
if(tDetectorUserList2.size() == 0){
return AjaxResult.error(5,"查询不到目标用户名targetUsername=" + targetUsername);
}
......
......@@ -47,12 +47,20 @@ public class TDetectorUserController extends BaseController
/**
* 获取探测器用户列表
* @param tDetectorUser
* @return
*/
@GetMapping("/detectorUserList")
public AjaxResult detectorUserList(TDetectorUser tDetectorUser){
return AjaxResult.success(tDetectorUserService.detectorUserList(tDetectorUser));
public AjaxResult detectorUserList(){
return AjaxResult.success(tDetectorUserService.detectorUserList());
}
/**
* 获取探测器用户列表
* @return
*/
@GetMapping("/getDetectorUserAlarmList")
public AjaxResult getDetectorUserAlarmList(){
return AjaxResult.success(tDetectorUserService.getDetectorUserAlarmList());
}
/**
......
......@@ -22,6 +22,9 @@ public class TDetectorUserVO
/** 图标类型 */
private String iconType;
/** 用户状态(1正常,2报警) */
private String userStatus;
/** 用户名称 */
private String nickName;
......
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.domain.vo.TDetectorUserVO;
......@@ -25,7 +27,23 @@ public interface TDetectorUserMapper
*
* @return 燃气用户
*/
public List<TDetectorUserVO> countTDetectorUser();
public List<TDetectorUserVO> countTDetectorUser(TDetectorInfo tDetectorInfo);
/**
* 查询探测器报警用户
*
* @param tDetectorUser 探测器用户
* @return 探测器用户
*/
public TDetectorUserVO countTDetectorUserAlarm(TDetectorUser tDetectorUser);
/**
* 泽宏云推送查询燃气用户
*
* @param tDetectorUser 燃气用户
* @return 燃气用户
*/
public List<TDetectorUser> selectTDetectorUser(TDetectorUser tDetectorUser);
/**
* 查询燃气用户列表
......
......@@ -16,18 +16,32 @@ public interface ITDetectorUserService
/**
* 查询探测器用户列表
*
* @param tDetectorUser 探测器用户
* @return 探测器用户集合
*/
public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser);
public List<TDetectorUserVO> detectorUserList();
/**
* 查询探测器报警用户(前台调用)
*
* @return 探测器用户
*/
public List<TDetectorUserVO> getDetectorUserAlarmList();
/**
* 查询探测器用户报警列表
* 查询探测器报警用户(后台推送)
*
* @param tDetectorUser 探测器用户
* @return 探测器用户集合
* @return 探测器用户
*/
public TDetectorUserVO detectorUserAlarmList(TDetectorUser tDetectorUser);
/**
* 泽宏云推送查询燃气用户
*
* @param tDetectorUser 燃气用户
* @return 燃气用户
*/
public List<TDetectorUserVO> detectorUserAlarmList(TDetectorUser tDetectorUser);
public List<TDetectorUser> selectTDetectorUser(TDetectorUser tDetectorUser);
/**
* 查询燃气用户
......
......@@ -36,14 +36,13 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
/**
* 查询探测器用户列表
*
* @param tDetectorUser 探测器用户
* @return 探测器用户
*/
@Override
public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser)
public List<TDetectorUserVO> detectorUserList()
{
List<TDetectorUserVO> list = new ArrayList<>();
List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser();
List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser(new TDetectorInfo());
List<Object> initList = new ArrayList<>();
for(TDetectorUserVO user : tDetectorUserList){
......@@ -55,11 +54,14 @@ 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);
}
}
......@@ -68,39 +70,76 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
}
/**
* 查询探测器用户列表
* 查询探测器报警用户(前台调用)
*
* @param tDetectorUser 探测器用户
* @return 探测器用户
*/
@Override
public List<TDetectorUserVO> detectorUserAlarmList(TDetectorUser tDetectorUser)
public List<TDetectorUserVO> getDetectorUserAlarmList()
{
List<TDetectorUserVO> list = new ArrayList<>();
// List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser();
//
// 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");
// } else {
// BeanUtils.copyProperties(user, temp);
// List<Object> newList = new ArrayList<>();
// newList.add(temp);
// userVO.setDetectorCountList(newList);
// list.add(userVO);
// }
// }
TDetectorInfo tDetectorInfo = new TDetectorInfo();
tDetectorInfo.setDetectorStatus("2");
// 查询报警的数据
List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser(tDetectorInfo);
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);
}
}
return list;
}
/**
* 查询探测器报警用户(后台推送)
*
* @param tDetectorUser 探测器用户
* @return 探测器用户
*/
@Override
public TDetectorUserVO detectorUserAlarmList(TDetectorUser tDetectorUser)
{
List<Object> list = new ArrayList<>();
TDetectorUserVO user = tDetectorUserMapper.countTDetectorUserAlarm(tDetectorUser);
TDetectorUserVO userVO = new TDetectorUserVO();
BeanUtils.copyProperties(user, userVO);
list.add(user);
userVO.setDetectorCountList(list);
return userVO;
}
/**
* 泽宏云推送查询燃气用户
*
* @param tDetectorUser 燃气用户
* @return 燃气用户
*/
@Override
public List<TDetectorUser> selectTDetectorUser(TDetectorUser tDetectorUser)
{
return tDetectorUserMapper.selectTDetectorUser(tDetectorUser);
}
/**
* 查询燃气用户
*
......
......@@ -69,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t_detector_report_data rd
LEFT JOIN t_detector_info di ON rd.detector_code = di.detector_code
LEFT JOIN t_detector_user u ON u.user_id = di.user_id
WHERE u.is_del = '0'
WHERE u.is_del = '0' and di.is_del = '0'
ORDER BY rd.create_time DESC LIMIT 50
</select>
......
......@@ -32,12 +32,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by user_id desc
</select>
<select id="selectTDetectorUser" parameterType="TDetectorUser" resultMap="TDetectorUserResult">
<include refid="selectTDetectorUserVo"/>
<where>
<if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
<if test="username != null and username != ''"> and username = #{username}</if>
<if test="nickName != null and nickName != ''"> and nick_name = #{nickName}</if>
</where>
group by user_id desc
</select>
<select id="selectTDetectorUserById" parameterType="Long" resultMap="TDetectorUserResult">
<include refid="selectTDetectorUserVo"/>
where user_id = #{userId}
</select>
<select id="countTDetectorUser" resultType="TDetectorUserVO">
<select id="countTDetectorUser" resultType="TDetectorUserVO" parameterType="TDetectorInfo">
select t1.*,
IFNULL(t2.historyAlarmNum,0) AS historyAlarmNum,
IFNULL(t2.processingAlarmNum,0) AS processingAlarmNum,
......@@ -66,7 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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') a
<where> a1.is_del = '0' and a2.is_del = '0'
<if test="detectorStatus != null and detectorStatus != ''"> and a1.detector_status = #{detectorStatus}</if>
</where>) a
group by a.user_id,a.detector_type
) t1 left join (
......@@ -79,18 +91,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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') b
<where> b2.is_del = '0' and b3.is_del = '0'
<if test="detectorStatus != null and detectorStatus != ''"> and b2.detector_status = #{detectorStatus}</if>
</where>) b
group by b.user_id,b.detector_type
) t2 on t2.userId = t1.userId
</select>
<!--<select id="selectTDetectorUserAlarmList" parameterType="TDetectorUser" resultMap="">
select * from t_detector_report_data a1
right join t_detector_info a2 on a1.detector_code = a2.detector_code
right join t_detector_user a3 on a2.user_id = a2.user_id
where a2.is_del = '0' and a3.is_del = '0'
</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
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>
<insert id="insertTDetectorUser" parameterType="TDetectorUser" useGeneratedKeys="true" keyProperty="userId">
insert into t_detector_user
......
......@@ -18,6 +18,15 @@ export function detectorUserList(query) {
})
}
// 探测器用户列表
export function getDetectorUserAlarmList(query) {
return request({
url: '/supervise/user/getDetectorUserAlarmList',
method: 'get',
params: query
})
}
// 查询探测器用户详细
export function getDetectorUser(userId) {
return request({
......
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