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

大屏用户列表接口调整

parent 7af23906
...@@ -22,9 +22,6 @@ public class TDetectorUserVO ...@@ -22,9 +22,6 @@ public class TDetectorUserVO
/** 图标类型 */ /** 图标类型 */
private String iconType; private String iconType;
/** 用户账号 */
private String username;
/** 用户名称 */ /** 用户名称 */
private String nickName; private String nickName;
...@@ -71,10 +68,4 @@ public class TDetectorUserVO ...@@ -71,10 +68,4 @@ public class TDetectorUserVO
/** 邮箱 */ /** 邮箱 */
private String email; private String email;
/** 是否删除(0正常,1删除) */
private String isDel;
/** 备注 */
private String remarks;
} }
...@@ -2,6 +2,7 @@ package com.zehong.system.mapper; ...@@ -2,6 +2,7 @@ package com.zehong.system.mapper;
import java.util.List; import java.util.List;
import com.zehong.system.domain.TDetectorUser; import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.domain.vo.TDetectorUserVO;
/** /**
* 燃气用户Mapper接口 * 燃气用户Mapper接口
...@@ -19,6 +20,13 @@ public interface TDetectorUserMapper ...@@ -19,6 +20,13 @@ public interface TDetectorUserMapper
*/ */
public TDetectorUser selectTDetectorUserById(Long userId); public TDetectorUser selectTDetectorUserById(Long userId);
/**
* 查询燃气用户统计信息
*
* @return 燃气用户
*/
public List<TDetectorUserVO> countTDetectorUser();
/** /**
* 查询燃气用户列表 * 查询燃气用户列表
* *
......
...@@ -21,6 +21,14 @@ public interface ITDetectorUserService ...@@ -21,6 +21,14 @@ public interface ITDetectorUserService
*/ */
public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser); public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser);
/**
* 查询探测器用户报警列表
*
* @param tDetectorUser 探测器用户
* @return 探测器用户集合
*/
public List<TDetectorUserVO> detectorUserAlarmList(TDetectorUser tDetectorUser);
/** /**
* 查询燃气用户 * 查询燃气用户
* *
......
...@@ -56,8 +56,10 @@ public class TDetectorInfoServiceImpl implements ITDetectorInfoService ...@@ -56,8 +56,10 @@ public class TDetectorInfoServiceImpl implements ITDetectorInfoService
for(TDetectorInfo detector : list){ for(TDetectorInfo detector : list){
if("0".equals(detector.getDetectorStatus())){ if("0".equals(detector.getDetectorStatus())){
detector.setDetectorStatus("正常"); detector.setDetectorStatus("正常");
} else { } else if("1".equals(detector.getDetectorStatus())) {
detector.setDetectorStatus("离线"); detector.setDetectorStatus("离线");
} else {
detector.setDetectorStatus("报警");
} }
} }
...@@ -77,8 +79,10 @@ public class TDetectorInfoServiceImpl implements ITDetectorInfoService ...@@ -77,8 +79,10 @@ public class TDetectorInfoServiceImpl implements ITDetectorInfoService
for(TDetectorInfo detector : list){ for(TDetectorInfo detector : list){
if("0".equals(detector.getDetectorStatus())){ if("0".equals(detector.getDetectorStatus())){
detector.setDetectorStatus("正常"); detector.setDetectorStatus("正常");
} else { } else if("1".equals(detector.getDetectorStatus())) {
detector.setDetectorStatus("离线"); detector.setDetectorStatus("离线");
} else {
detector.setDetectorStatus("报警");
} }
} }
return new PageInfo(list); return new PageInfo(list);
......
...@@ -43,52 +43,60 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService ...@@ -43,52 +43,60 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser) public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser)
{ {
List<TDetectorUserVO> list = new ArrayList<>(); List<TDetectorUserVO> list = new ArrayList<>();
List<TDetectorUser> tDetectorUserList = tDetectorUserMapper.selectTDetectorUserList(tDetectorUser); List<TDetectorUserVO> tDetectorUserList = tDetectorUserMapper.countTDetectorUser();
TDetectorInfo detector = new TDetectorInfo(); List<Object> initList = new ArrayList<>();
for(TDetectorUser user : tDetectorUserList){ for(TDetectorUserVO user : tDetectorUserList){
TDetectorUserVO userVO = new TDetectorUserVO(); TDetectorUserVO userVO = new TDetectorUserVO();
BeanUtils.copyProperties(user, userVO); BeanUtils.copyProperties(user, userVO);
detector.setUserId(user.getUserId()); TDetectorUserVO temp = new TDetectorUserVO();
detector.setIsDel("0"); if(user.getUserId().equals(temp.getUserId())){
List<TDetectorInfo> tDetectorInfoList = tDetectorInfoMapper.selectTDetectorInfoList(detector); initList.add(user);
userVO.setDetectorCountList(initList);
int onLineNum = 0; userVO.setIconType("6");
int offLineNum = 0; } else {
int cancelAlarmNum = 0; BeanUtils.copyProperties(user, temp);
int historyAlarmNum = 0; List<Object> newList = new ArrayList<>();
newList.add(temp);
if(tDetectorInfoList.size() > 0){ userVO.setDetectorCountList(newList);
for(TDetectorInfo info : tDetectorInfoList){ list.add(userVO);
if(!StringUtils.isEmpty(info.getDetectorStatus()) && info.getDetectorStatus().equals("0")){
++onLineNum;
}else{
++offLineNum;
}
}
List<TDetectorReportData> dataList = tDetectorReportDataMapper.countDetectorByUserId(detector);
historyAlarmNum = dataList.size();
for(TDetectorReportData data : dataList){
if(!StringUtils.isEmpty(data.getIsCancelAlarm()) && data.getIsCancelAlarm().equals("1")){
++cancelAlarmNum;
}
}
} }
}
userVO.setDetectorCount(tDetectorInfoList.size()); return list;
userVO.setOnLineNum(onLineNum); }
userVO.setOffLineNum(offLineNum);
userVO.setHistoryAlarmNum(historyAlarmNum);
userVO.setCancelAlarmNum(cancelAlarmNum);
userVO.setProcessingAlarmNum(Math.abs(historyAlarmNum - cancelAlarmNum));
userVO.setIconType("6");
userVO.setDetectorType("气体探测器");
list.add(userVO); /**
} * 查询探测器用户列表
*
* @param tDetectorUser 探测器用户
* @return 探测器用户
*/
@Override
public List<TDetectorUserVO> detectorUserAlarmList(TDetectorUser tDetectorUser)
{
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);
// }
// }
return list; return list;
} }
......
...@@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if> <if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if> <if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
</where> </where>
order by detector_status desc, alarm_time desc
</select> </select>
<select id="selectTDetectorInfoById" parameterType="Long" resultMap="TDetectorInfoResult"> <select id="selectTDetectorInfoById" parameterType="Long" resultMap="TDetectorInfoResult">
......
...@@ -37,6 +37,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -37,6 +37,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where user_id = #{userId} where user_id = #{userId}
</select> </select>
<select id="countTDetectorUser" resultType="TDetectorUserVO">
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') a
group by a.user_id,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') 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>-->
<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
<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