Commit 4d0ed736 authored by zhangjianqian's avatar zhangjianqian

设备监控

parent 749c8563
......@@ -9,6 +9,7 @@ import com.dcit.authority.model.SysUser;
import com.dcit.authority.service.SysUserService;
import com.dcit.danger.dto.node.DeviceTreeNode;
import com.dcit.authority.exception.AuthException;
import com.dcit.danger.dto.query.Devicerreport;
import com.dcit.danger.model.EnterpriseBasicInfo;
import com.dcit.danger.model.EnterpriseBasicInfoExample;
import com.dcit.danger.service.EnterpriseInfoService;
......@@ -263,10 +264,10 @@ public class SafetyDeviceInfoController {
criteria.andDeviceNameLike("%"+ safetyDeviceInfoQuery.getDeviceName() +"%");
}
List<Map<String,Object>> safetyDeviceList = safetyDeviceInfoService.selectBySensorExample(safetyDeviceInfoQuery.getDeviceName(),
List<Devicerreport> safetyDeviceList = safetyDeviceInfoService.selectBySensorExample(safetyDeviceInfoQuery.getDeviceName(),
safetyDeviceInfoQuery.getDeviceNumber(),safetyDeviceInfoQuery.getEnterpriseId());
PageInfo<Map<String,Object>> pageList = new PageInfo<Map<String,Object>>(safetyDeviceList);
PageInfo<Devicerreport> pageList = new PageInfo<Devicerreport>(safetyDeviceList);
// List<SafetyDeviceInfoDTO> dtoList = new ArrayList<SafetyDeviceInfoDTO>();
// SafetyDeviceInfoDTO dto = null;
......
package com.dcit.danger.dao;
import com.dcit.danger.dto.query.Devicerreport;
import com.dcit.danger.model.SafetyDeviceInfo;
import com.dcit.danger.model.SafetyDeviceInfoExample;
import java.util.List;
......@@ -29,8 +30,9 @@ public interface SafetyDeviceInfoMapper {
int updateByPrimaryKeySelective(SafetyDeviceInfo record);
int updateByPrimaryKey(SafetyDeviceInfo record);
List<Map<String,Object>> selectBySensorExample(@Param("deviceName")String deviceName,
List<Devicerreport> selectBySensorExample(@Param("deviceName")String deviceName,
@Param("deviceNumber")String deviceNumber,
@Param("enterpriseId")String enterpriseId
);
Devicerreport selectReportbydeviceNum(@Param("deviceNum")String deviceNum);
}
\ No newline at end of file
package com.dcit.danger.dto.query;
import lombok.Data;
@Data
public class Devicerreport {
private String deviceName;
private String category;
private String unit;
private String enterpriseName;
private String deviceNum;
private String status;
private String concentration;
private String createTime;
}
......@@ -3,6 +3,7 @@ package com.dcit.danger.service;
import java.util.List;
import java.util.Map;
import com.dcit.danger.dto.query.Devicerreport;
import com.dcit.danger.model.SafetyDeviceInfo;
import com.dcit.danger.model.SafetyDeviceInfoExample;
......@@ -19,7 +20,7 @@ public interface SafetyDeviceInfoService {
int insertSelective(SafetyDeviceInfo record);
List<SafetyDeviceInfo> selectByExample(SafetyDeviceInfoExample example);
List<Map<String,Object>> selectBySensorExample(String deviceName, String deviceNumber, String enterpriseId);
List<Devicerreport> selectBySensorExample(String deviceName, String deviceNumber, String enterpriseId);
SafetyDeviceInfo selectByPrimaryKey(String id);
......
......@@ -3,6 +3,7 @@ package com.dcit.danger.service.impl;
import java.util.List;
import java.util.Map;
import com.dcit.danger.dto.query.Devicerreport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -48,9 +49,18 @@ public class SafetyDeviceInfoServiceImpl implements SafetyDeviceInfoService {
}
@Override
public List<Map<String,Object>> selectBySensorExample(String deviceName, String deviceNumber, String enterpriseId) {
public List<Devicerreport> selectBySensorExample(String deviceName, String deviceNumber, String enterpriseId) {
// TODO Auto-generated method stub
return safetyDeviceInfoMapper.selectBySensorExample(deviceName,deviceNumber,enterpriseId);
List<Devicerreport> list = safetyDeviceInfoMapper.selectBySensorExample(deviceName,deviceNumber,enterpriseId);
for (Devicerreport d : list){
Devicerreport report = safetyDeviceInfoMapper.selectReportbydeviceNum(d.getDeviceNum());
if(report!=null){
d.setConcentration(report.getConcentration());
d.setCreateTime(report.getCreateTime());
d.setStatus(report.getStatus());
}
}
return list;
}
@Override
public List<SafetyDeviceInfo> selectByExample(SafetyDeviceInfoExample example) {
......
......@@ -551,9 +551,8 @@
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectBySensorExample" resultType="java.util.HashMap">
SELECT IFNULL(t.`create_time`,"") AS createTime,t.*,s.device_name AS deviceName,s.category,s.unit,e.unit_name AS enterpriseName,s.`device_number` AS deviceNum FROM safety_device_info s
LEFT JOIN (SELECT device_num,MAX(id) AS did ,`status`,concentration, create_time FROM monitor GROUP BY device_num) t ON t.`device_num` = s.`device_number`
<select id="selectBySensorExample" resultType="com.dcit.danger.dto.query.Devicerreport">
SELECT s.device_name AS deviceName,s.category,s.unit,e.unit_name AS enterpriseName,s.`device_number` AS deviceNum FROM safety_device_info s
LEFT JOIN enterprise_basic_info e ON e.id = s.enterprise_id
WHERE s.data_type = 3
<if test="deviceName!=null">
......@@ -566,4 +565,10 @@
AND e.id = #{enterpriseId}
</if>
</select>
<select id="selectReportbydeviceNum" resultType="com.dcit.danger.dto.query.Devicerreport">
SELECT device_num,`device_status` AS `status` ,
device_potency AS concentration, report_time as createTime FROM t_device_report_data
WHERE device_num = #{deviceNum}
order by report_time desc limit 1
</select>
</mapper>
\ No newline at end of file
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