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

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

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