物联设备管理
This commit is contained in:
parent
75c5a25f25
commit
ce7c094260
|
|
@ -0,0 +1,200 @@
|
|||
package com.nu.modules.manager.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.manager.entity.DeviceBindLog;
|
||||
import com.nu.modules.manager.entity.DeviceManager;
|
||||
import com.nu.modules.manager.service.IDeviceManagerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 设备管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-03-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/iot/device/manager")
|
||||
@Slf4j
|
||||
public class DeviceManagerController extends JeecgController<DeviceManager, IDeviceManagerService> {
|
||||
@Autowired
|
||||
private IDeviceManagerService service;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param DeviceManager
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<DeviceManager>> queryPageList(DeviceManager DeviceManager,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Page<DeviceManager> page = new Page<DeviceManager>(pageNo, pageSize);
|
||||
IPage<DeviceManager> pageList = service.findPage(page, DeviceManager);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param DeviceManager
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/previewList")
|
||||
public Result<IPage<DeviceManager>> previewList(DeviceManager DeviceManager,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Page<DeviceManager> page = new Page<DeviceManager>(pageNo, pageSize);
|
||||
IPage<DeviceManager> pageList = service.findAllPage(page, DeviceManager);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设备集成-绑定日志分页列表查询
|
||||
*
|
||||
* @param deviceBindLog
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/bingLogList")
|
||||
public Result<IPage<DeviceBindLog>> bingLogList(DeviceBindLog deviceBindLog,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Page<DeviceBindLog> page = new Page<DeviceBindLog>(pageNo, pageSize);
|
||||
IPage<DeviceBindLog> pageList = service.findBingLogPage(page, deviceBindLog);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param DeviceManager
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody DeviceManager DeviceManager) {
|
||||
service.save(DeviceManager);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param DeviceManager
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody DeviceManager DeviceManager) {
|
||||
service.updateById(DeviceManager);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
service.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.service.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<DeviceManager> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
DeviceManager DeviceManager = service.getById(id);
|
||||
if(DeviceManager==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(DeviceManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param DeviceManager
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, DeviceManager DeviceManager) {
|
||||
return super.exportXls(request, DeviceManager, DeviceManager.class, "物联设备清单");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, DeviceManager.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加日志
|
||||
*
|
||||
* @param deviceBindLog
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/addLog")
|
||||
public Result<String> addLog(@RequestBody DeviceBindLog deviceBindLog) {
|
||||
service.addLog(deviceBindLog);
|
||||
return Result.OK("更改成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备集成-区域列表查询
|
||||
*
|
||||
* @param deviceManager
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/nuList")
|
||||
public Result<List<DeviceManager>> nuList(DeviceManager deviceManager) {
|
||||
return Result.OK(service.queryNuList(deviceManager));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.nu.modules.manager.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class DeviceBindLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**ID*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
private String nuId;
|
||||
private String nuName;
|
||||
private String dimension;
|
||||
@Dict(dicCode = "tplink_device_type")
|
||||
private String deviceType;
|
||||
private String deviceModel;
|
||||
private String factory;
|
||||
private String sn;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date optDate;
|
||||
private String optType;
|
||||
private String remarks;
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.nu.modules.manager.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("nu_iot_device_preview")
|
||||
public class DeviceManager implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**ID*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
private String nuId;
|
||||
@TableField(exist = false)
|
||||
private String nuName;
|
||||
@Excel(name = "设备类型", width = 15, dicCode = "tplink_device_type")
|
||||
@Dict(dicCode = "tplink_device_type")
|
||||
private String deviceType;
|
||||
@Excel(name = "规格型号", width = 15)
|
||||
private String deviceModel;
|
||||
@Excel(name = "生产厂家", width = 15)
|
||||
private String factory;
|
||||
@Excel(name = "设备维度", width = 15)
|
||||
private String dimension;
|
||||
@Excel(name = "设备标识", width = 15)
|
||||
private String sn;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
@Excel(name = "备注", width = 15)
|
||||
private String remarks;
|
||||
@TableField(exist = false)
|
||||
private String onlineStatus;//在线状态
|
||||
private String deviceStatus;//设备状态
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.nu.modules.manager.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.manager.entity.DeviceBindLog;
|
||||
import com.nu.modules.manager.entity.DeviceManager;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 设备管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-03-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface DeviceManagerMapper extends BaseMapper<DeviceManager> {
|
||||
IPage<DeviceManager> findPage(Page<DeviceManager> page, @Param("params") DeviceManager deviceManager);
|
||||
IPage<DeviceManager> findAllPage(Page<DeviceManager> page, @Param("params") DeviceManager deviceManager);
|
||||
IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, @Param("params") DeviceBindLog deviceBindLog);
|
||||
void addLog(DeviceBindLog deviceBindLog);
|
||||
List<DeviceManager> queryNuList(DeviceManager deviceManager);
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.manager.mapper.DeviceManagerMapper">
|
||||
|
||||
<select id="findPage" parameterType="com.nu.modules.manager.entity.DeviceManager" resultType="com.nu.modules.manager.entity.DeviceManager">
|
||||
select
|
||||
a.id,
|
||||
a.nu_id,
|
||||
c.nu_name,
|
||||
a.dimension,
|
||||
a.device_type,
|
||||
a.device_model,
|
||||
a.factory,
|
||||
a.sn,
|
||||
a.create_time,
|
||||
a.update_time,
|
||||
a.remarks,
|
||||
a.device_status,
|
||||
t.online_status
|
||||
from nu_iot_device_preview a
|
||||
left join nu_base_info c on a.nu_id = c.nu_id
|
||||
left join (
|
||||
select mac as sn,
|
||||
( case device_status when '0' then '离线' when '1' then '在线' end ) as online_status
|
||||
from nu_iot_tplink_camera
|
||||
union all
|
||||
select sn,
|
||||
( case relay_state when '0' then '离线' else '在线' end ) as online_status
|
||||
from nu_iot_ds_electricity_meter
|
||||
union all
|
||||
select cid as sn,
|
||||
( case relay_state when '0' then '离线' else '在线' end ) as online_status
|
||||
from nu_iot_tq_water_meter
|
||||
union all
|
||||
select sn,
|
||||
( case status when '0' then '在线' else '离线' end ) as online_status
|
||||
from nu_iot_yiweilian_humid_device
|
||||
) t on a.sn = t.sn
|
||||
where a.sn is not null
|
||||
<if test="params.nuName != null and params.nuName != ''">
|
||||
AND c.nu_name LIKE concat('%',#{params.nuName},'%')
|
||||
</if>
|
||||
<if test="params.dimension != null and params.dimension != ''">
|
||||
AND a.dimension = #{params.dimension}
|
||||
</if>
|
||||
<if test="params.deviceType != null and params.deviceType != ''">
|
||||
AND a.device_type = #{params.deviceType}
|
||||
</if>
|
||||
order by a.dimension,a.device_type,a.device_model,a.sn
|
||||
</select>
|
||||
|
||||
<select id="findAllPage" parameterType="com.nu.modules.manager.entity.DeviceManager" resultType="com.nu.modules.manager.entity.DeviceManager">
|
||||
select
|
||||
a.id,
|
||||
a.dimension,
|
||||
a.device_type,
|
||||
a.device_model,
|
||||
a.factory,
|
||||
a.sn,
|
||||
a.create_time,
|
||||
a.update_time,
|
||||
a.remarks,
|
||||
a.device_status
|
||||
from nu_iot_device_preview a
|
||||
<where>
|
||||
<if test="params.dimension != null and params.dimension != ''">
|
||||
AND a.dimension = #{params.dimension}
|
||||
</if>
|
||||
<if test="params.deviceType != null and params.deviceType != ''">
|
||||
AND a.device_type = #{params.deviceType}
|
||||
</if>
|
||||
</where>
|
||||
order by a.dimension,a.device_type,a.device_model,a.sn
|
||||
</select>
|
||||
|
||||
<select id="findBingLogPage" parameterType="com.nu.modules.manager.entity.DeviceBindLog" resultType="com.nu.modules.manager.entity.DeviceBindLog">
|
||||
select
|
||||
id,
|
||||
nu_id,
|
||||
nu_name,
|
||||
dimension,
|
||||
device_type,
|
||||
device_model,
|
||||
sn,
|
||||
factory,
|
||||
opt_date,
|
||||
opt_type
|
||||
from nu_iot_device_bind_log
|
||||
order by factory asc ,device_type asc ,device_model asc ,sn asc,opt_date desc
|
||||
</select>
|
||||
|
||||
<insert id="addLog">
|
||||
insert into nu_iot_device_bind_log(
|
||||
nu_id,
|
||||
nu_name,
|
||||
dimension,
|
||||
device_type,
|
||||
device_model,
|
||||
sn,
|
||||
factory,
|
||||
opt_date,
|
||||
opt_type,
|
||||
remarks
|
||||
)values(
|
||||
#{nuId},
|
||||
#{nuName},
|
||||
#{dimension},
|
||||
#{deviceType},
|
||||
#{deviceModel},
|
||||
#{sn},
|
||||
#{factory},
|
||||
now(),
|
||||
#{optType},
|
||||
#{remarks}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryNuList" parameterType="com.nu.modules.manager.entity.DeviceManager" resultType="com.nu.modules.manager.entity.DeviceManager">
|
||||
select nu_id,nu_name
|
||||
from nu_base_info
|
||||
where status != '5'
|
||||
order by nu_id asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.nu.modules.manager.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.manager.entity.DeviceBindLog;
|
||||
import com.nu.modules.manager.entity.DeviceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 设备管理-机构信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-03-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IDeviceManagerService extends IService<DeviceManager> {
|
||||
IPage<DeviceManager> findPage(Page<DeviceManager> page, DeviceManager deviceManager);
|
||||
IPage<DeviceManager> findAllPage(Page<DeviceManager> page, DeviceManager deviceManager);
|
||||
IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, DeviceBindLog deviceBindLog);
|
||||
void addLog(DeviceBindLog deviceBindLog);
|
||||
List<DeviceManager> queryNuList(DeviceManager deviceManager);
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.nu.modules.manager.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.manager.entity.DeviceBindLog;
|
||||
import com.nu.modules.manager.entity.DeviceManager;
|
||||
import com.nu.modules.manager.mapper.DeviceManagerMapper;
|
||||
import com.nu.modules.manager.service.IDeviceManagerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 设备管理-机构信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-03-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, DeviceManager> implements IDeviceManagerService {
|
||||
|
||||
@Override
|
||||
public IPage<DeviceManager> findPage(Page<DeviceManager> page, DeviceManager deviceManager){
|
||||
return baseMapper.findPage(page,deviceManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<DeviceManager> findAllPage(Page<DeviceManager> page, DeviceManager deviceManager){
|
||||
return baseMapper.findAllPage(page,deviceManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, DeviceBindLog deviceBindLog){
|
||||
return baseMapper.findBingLogPage(page,deviceBindLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLog(DeviceBindLog deviceBindLog){
|
||||
baseMapper.addLog(deviceBindLog);
|
||||
DeviceManager deviceManager = new DeviceManager();
|
||||
deviceManager.setId(deviceBindLog.getId());
|
||||
deviceManager.setDeviceStatus(deviceBindLog.getOptType());
|
||||
if(deviceBindLog.getOptType().equals("换绑")){
|
||||
deviceManager.setNuId(deviceBindLog.getNuId());
|
||||
}
|
||||
baseMapper.updateById(deviceManager);
|
||||
//需同步到运维
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceManager> queryNuList(DeviceManager deviceManager){
|
||||
return baseMapper.queryNuList(deviceManager);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue