Commit 749c8563 authored by zhangjianqian's avatar zhangjianqian

新增设备监控

parent ea72faa6
...@@ -3,6 +3,7 @@ package com.dcit.danger.controller; ...@@ -3,6 +3,7 @@ package com.dcit.danger.controller;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import com.dcit.authority.model.SysUser; import com.dcit.authority.model.SysUser;
import com.dcit.authority.service.SysUserService; import com.dcit.authority.service.SysUserService;
...@@ -125,6 +126,9 @@ public class SafetyDeviceInfoController { ...@@ -125,6 +126,9 @@ public class SafetyDeviceInfoController {
if(!"all".equals(enterpriseId)&&!"".equals(enterpriseId)){ if(!"all".equals(enterpriseId)&&!"".equals(enterpriseId)){
criteria.andEnterpriseIdEqualTo(enterpriseId); criteria.andEnterpriseIdEqualTo(enterpriseId);
} }
if(safetyDeviceInfoQuery.getEnterpriseId()!=null && safetyDeviceInfoQuery.getEnterpriseId()!=""){
criteria.andEnterpriseIdEqualTo(safetyDeviceInfoQuery.getEnterpriseId());
}
criteria.andIsDelEqualTo("0"); criteria.andIsDelEqualTo("0");
if(!StringUtils.isEmpty(safetyDeviceInfoQuery.getDataType())){ if(!StringUtils.isEmpty(safetyDeviceInfoQuery.getDataType())){
criteria.andDataTypeEqualTo(safetyDeviceInfoQuery.getDataType()); criteria.andDataTypeEqualTo(safetyDeviceInfoQuery.getDataType());
...@@ -176,6 +180,7 @@ public class SafetyDeviceInfoController { ...@@ -176,6 +180,7 @@ public class SafetyDeviceInfoController {
safetyDeviceInfo = new SafetyDeviceInfo(); safetyDeviceInfo = new SafetyDeviceInfo();
BeanUtils.copyProperties(safetyDeviceInfoForm, safetyDeviceInfo, BeanCopyUtil.getNullOrIgnorePropertyNames(safetyDeviceInfoForm, null)); BeanUtils.copyProperties(safetyDeviceInfoForm, safetyDeviceInfo, BeanCopyUtil.getNullOrIgnorePropertyNames(safetyDeviceInfoForm, null));
safetyDeviceInfo.setId(KeyUtil.getUUIDKey()); safetyDeviceInfo.setId(KeyUtil.getUUIDKey());
safetyDeviceInfo.setUnit(safetyDeviceInfoForm.getUnit());
//safetyDeviceInfo.setEnterpriseId(enterpriseId); //safetyDeviceInfo.setEnterpriseId(enterpriseId);
safetyDeviceInfoService.insertSelective(safetyDeviceInfo); safetyDeviceInfoService.insertSelective(safetyDeviceInfo);
...@@ -235,5 +240,52 @@ public class SafetyDeviceInfoController { ...@@ -235,5 +240,52 @@ public class SafetyDeviceInfoController {
return ResultVOUtil.success(dto); return ResultVOUtil.success(dto);
} }
@ApiOperation(value = "查询传感器监控列表")
@PostMapping("/getDeviceSensor/{enterpriseId}")
public ResultVO<Object> getDeviceSensor(@PathVariable String enterpriseId, @RequestBody SafetyDeviceInfoQuery safetyDeviceInfoQuery,String deviceName,String deviceNumber){
ModelMap modelMap = new ModelMap();
try {
PageHelper.offsetPage(safetyDeviceInfoQuery.getPage(), safetyDeviceInfoQuery.getSize());
SafetyDeviceInfoExample safetyDeviceInfoExample = new SafetyDeviceInfoExample();
Criteria criteria = safetyDeviceInfoExample.createCriteria();
if(!"all".equals(enterpriseId)&&!"".equals(enterpriseId)){
criteria.andEnterpriseIdEqualTo(enterpriseId);
}
criteria.andIsDelEqualTo("0");
if(!StringUtils.isEmpty(safetyDeviceInfoQuery.getDataType())){
criteria.andDataTypeEqualTo(safetyDeviceInfoQuery.getDataType());
}
if(!StringUtils.isEmpty(safetyDeviceInfoQuery.getDeviceName())){
criteria.andDeviceNameLike("%"+ safetyDeviceInfoQuery.getDeviceName() +"%");
}
List<Map<String,Object>> safetyDeviceList = safetyDeviceInfoService.selectBySensorExample(safetyDeviceInfoQuery.getDeviceName(),
safetyDeviceInfoQuery.getDeviceNumber(),safetyDeviceInfoQuery.getEnterpriseId());
PageInfo<Map<String,Object>> pageList = new PageInfo<Map<String,Object>>(safetyDeviceList);
// List<SafetyDeviceInfoDTO> dtoList = new ArrayList<SafetyDeviceInfoDTO>();
// SafetyDeviceInfoDTO dto = null;
// for(SafetyDeviceInfo safetyDeviceInfo : pageList.getList()){
// dto = new SafetyDeviceInfoDTO();
// BeanUtils.copyProperties(safetyDeviceInfo, dto, BeanCopyUtil.getNullOrIgnorePropertyNames(safetyDeviceInfo, null));
//
// dtoList.add(dto);
// }
modelMap.addAttribute("pageData", pageList.getList());
modelMap.addAttribute("total", pageList.getTotal());
} catch (Exception e) {
e.printStackTrace();
log.error("【查询企业安全设备列表】操作出错,error={}",e.getMessage());
throw new IOCException(ResultEnum.OPERATION_FAIL);
}
return ResultVOUtil.success(modelMap);
}
} }
...@@ -3,6 +3,8 @@ package com.dcit.danger.dao; ...@@ -3,6 +3,8 @@ package com.dcit.danger.dao;
import com.dcit.danger.model.SafetyDeviceInfo; import com.dcit.danger.model.SafetyDeviceInfo;
import com.dcit.danger.model.SafetyDeviceInfoExample; import com.dcit.danger.model.SafetyDeviceInfoExample;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
public interface SafetyDeviceInfoMapper { public interface SafetyDeviceInfoMapper {
...@@ -27,4 +29,8 @@ public interface SafetyDeviceInfoMapper { ...@@ -27,4 +29,8 @@ public interface SafetyDeviceInfoMapper {
int updateByPrimaryKeySelective(SafetyDeviceInfo record); int updateByPrimaryKeySelective(SafetyDeviceInfo record);
int updateByPrimaryKey(SafetyDeviceInfo record); int updateByPrimaryKey(SafetyDeviceInfo record);
List<Map<String,Object>> selectBySensorExample(@Param("deviceName")String deviceName,
@Param("deviceNumber")String deviceNumber,
@Param("enterpriseId")String enterpriseId
);
} }
\ No newline at end of file
...@@ -108,4 +108,6 @@ public class SafetyDeviceInfoForm { ...@@ -108,4 +108,6 @@ public class SafetyDeviceInfoForm {
private String enterpriseId; private String enterpriseId;
private String unit;
} }
...@@ -30,6 +30,9 @@ public class SafetyDeviceInfoQuery extends PageBasic{ ...@@ -30,6 +30,9 @@ public class SafetyDeviceInfoQuery extends PageBasic{
*/ */
private String dataType; private String dataType;
/**
* 公司名称
*/
private String enterpriseId;
} }
...@@ -74,9 +74,12 @@ public class SafetyDeviceInfo implements Serializable { ...@@ -74,9 +74,12 @@ public class SafetyDeviceInfo implements Serializable {
* 设备登录端口 * 设备登录端口
*/ */
private String deviceLoginPort; private String deviceLoginPort;
/** /**
* 类型 * 单位
*/
private String unit;
/**
* 介质
*/ */
private String category; private String category;
......
package com.dcit.danger.service; package com.dcit.danger.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.dcit.danger.model.SafetyDeviceInfo; import com.dcit.danger.model.SafetyDeviceInfo;
import com.dcit.danger.model.SafetyDeviceInfoExample; import com.dcit.danger.model.SafetyDeviceInfoExample;
...@@ -18,6 +19,8 @@ public interface SafetyDeviceInfoService { ...@@ -18,6 +19,8 @@ public interface SafetyDeviceInfoService {
int insertSelective(SafetyDeviceInfo record); int insertSelective(SafetyDeviceInfo record);
List<SafetyDeviceInfo> selectByExample(SafetyDeviceInfoExample example); List<SafetyDeviceInfo> selectByExample(SafetyDeviceInfoExample example);
List<Map<String,Object>> selectBySensorExample(String deviceName, String deviceNumber, String enterpriseId);
SafetyDeviceInfo selectByPrimaryKey(String id); SafetyDeviceInfo selectByPrimaryKey(String id);
......
package com.dcit.danger.service.impl; package com.dcit.danger.service.impl;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -46,6 +47,11 @@ public class SafetyDeviceInfoServiceImpl implements SafetyDeviceInfoService { ...@@ -46,6 +47,11 @@ public class SafetyDeviceInfoServiceImpl implements SafetyDeviceInfoService {
return safetyDeviceInfoMapper.insertSelective(record); return safetyDeviceInfoMapper.insertSelective(record);
} }
@Override
public List<Map<String,Object>> selectBySensorExample(String deviceName, String deviceNumber, String enterpriseId) {
// TODO Auto-generated method stub
return safetyDeviceInfoMapper.selectBySensorExample(deviceName,deviceNumber,enterpriseId);
}
@Override @Override
public List<SafetyDeviceInfo> selectByExample(SafetyDeviceInfoExample example) { public List<SafetyDeviceInfo> selectByExample(SafetyDeviceInfoExample example) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
......
...@@ -193,6 +193,9 @@ ...@@ -193,6 +193,9 @@
<if test="contacts != null"> <if test="contacts != null">
contacts, contacts,
</if> </if>
<if test="unit != null">
unit,
</if>
<if test="phone != null"> <if test="phone != null">
phone, phone,
</if> </if>
...@@ -273,6 +276,9 @@ ...@@ -273,6 +276,9 @@
<if test="contacts != null"> <if test="contacts != null">
#{contacts,jdbcType=VARCHAR}, #{contacts,jdbcType=VARCHAR},
</if> </if>
<if test="unit != null">
#{unit,jdbcType=VARCHAR},
</if>
<if test="phone != null"> <if test="phone != null">
#{phone,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
</if> </if>
...@@ -471,6 +477,9 @@ ...@@ -471,6 +477,9 @@
<if test="category != null"> <if test="category != null">
category = #{category,jdbcType=VARCHAR}, category = #{category,jdbcType=VARCHAR},
</if> </if>
<if test="unit != null">
unit = #{unit,jdbcType=VARCHAR},
</if>
<if test="isBigDanger != null"> <if test="isBigDanger != null">
is_big_danger = #{isBigDanger,jdbcType=VARCHAR}, is_big_danger = #{isBigDanger,jdbcType=VARCHAR},
</if> </if>
...@@ -542,4 +551,19 @@ ...@@ -542,4 +551,19 @@
create_time = #{createTime,jdbcType=TIMESTAMP} create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </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`
LEFT JOIN enterprise_basic_info e ON e.id = s.enterprise_id
WHERE s.data_type = 3
<if test="deviceName!=null">
AND s.device_name LIKE concat('%',#{deviceName},'%')
</if>
<if test="deviceNumber!=null">
AND s.device_number LIKE concat('%',#{deviceNumber},'%')
</if>
<if test="enterpriseId!=null and enterpriseId!=''">
AND e.id = #{enterpriseId}
</if>
</select>
</mapper> </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