物联设备BUG处理

This commit is contained in:
曹磊 2026-04-15 18:04:37 +08:00
parent 7c527a98ca
commit 9fec315c9e
11 changed files with 301 additions and 130 deletions

View File

@ -1,5 +1,6 @@
package com.nu.modules.manager.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nu.modules.manager.entity.DeviceBindLog;
@ -11,16 +12,28 @@ import com.nu.modules.tq.water.entity.WaterMeter;
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.JeecgBaseConfig;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description: 设备管理
@ -34,7 +47,8 @@ import java.util.Map;
public class DeviceManagerController extends JeecgController<DeviceManager, IDeviceManagerService> {
@Autowired
private IDeviceManagerService service;
@Resource
private JeecgBaseConfig jeecgBaseConfig;
/**
* 分页列表查询
*
@ -164,7 +178,47 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, DeviceManager DeviceManager) {
return super.exportXls(request, DeviceManager, DeviceManager.class, "物联设备清单");
// Step.1 组装查询条件
QueryWrapper<DeviceManager> queryWrapper = QueryGenerator.initQueryWrapper(DeviceManager, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
queryWrapper.in("id",selectionList);
}
// Step.2 获取导出数据
List<DeviceManager> exportList = service.list(queryWrapper);
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.FILE_NAME, "物联设备清单");
mv.addObject(NormalExcelConstants.CLASS, DeviceManager.class);
//update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams("物联设备清单", "导出人:" + sysUser.getRealname(), "物联设备清单");
exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
//update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
Map<String, Integer> result = new HashMap<>();
for (DeviceManager device : exportList) {
String name = device.getDeviceName();
result.put(name, result.getOrDefault(name, 0) + 1);
}
for (Map.Entry<String, Integer> entry : result.entrySet()) {
String deviceName = entry.getKey();
Integer count = entry.getValue();
DeviceManager dm = new DeviceManager();
dm.setDeviceName(deviceName + ", 数量: " + count);
exportList.add(dm);
}
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;
// return super.exportXls(request, DeviceManager, DeviceManager.class, "物联设备清单");
}
/**

View File

@ -22,6 +22,7 @@ public class DeviceBindLog implements Serializable {
private String nuId;
private String nuName;
private String dimension;
private String deviceName;
@Dict(dicCode = "tplink_device_type")
private String deviceType;
private String deviceModel;

View File

@ -83,6 +83,7 @@
nu_id,
nu_name,
dimension,
device_name,
device_type,
device_model,
sn,
@ -90,6 +91,17 @@
opt_date,
opt_type
from nu_iot_device_bind_log
<where>
<if test="params.dimension != null and params.dimension != ''">
AND dimension = #{params.dimension}
</if>
<if test="params.deviceType != null and params.deviceType != ''">
AND device_type = #{params.deviceType}
</if>
<if test="params.deviceName != null and params.deviceName != ''">
AND device_name LIKE concat('%',#{params.deviceName},'%')
</if>
</where>
order by factory asc ,device_type asc ,device_model asc ,sn asc,opt_date desc
</select>
@ -98,6 +110,7 @@
nu_id,
nu_name,
dimension,
device_name,
device_type,
device_model,
sn,
@ -109,6 +122,7 @@
#{nuId},
#{nuName},
#{dimension},
#{deviceName},
#{deviceType},
#{deviceModel},
#{sn},

View File

@ -107,32 +107,60 @@
</select>
<select id="findAllList" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
-- select a.id,
-- device_index as deviceIndex,
-- device_name as deviceName,
-- device_type as deviceType,
-- device_status as deviceStatus,
-- device_model as deviceModel,
-- ip as ip,
-- mac as mac,
-- region_id as regionId,
-- region_name as regionName,
-- parent_id as parentId,
-- parent_device_name as parentDeviceName,
-- project_id as projectId,
-- project_name as projectName,
-- firmware_ver as firmwareVer,
-- hardware_ver as hardwareVer,
-- manager_auth_type as managerAuthType,
-- msg_auth_type as msgAuthType,
-- sip_code as sipCode,
-- location_name as locationName,
-- system_type as systemType,
-- protocol as protocol,
-- record_plan_id as recordPlanId,
-- nu_id as nuId,
-- a.channel
-- from nu_iot_tplink_camera a
select a.id,
device_index as deviceIndex,
device_name as deviceName,
device_type as deviceType,
device_status as deviceStatus,
device_model as deviceModel,
ip as ip,
mac as mac,
region_id as regionId,
region_name as regionName,
parent_id as parentId,
parent_device_name as parentDeviceName,
project_id as projectId,
project_name as projectName,
firmware_ver as firmwareVer,
hardware_ver as hardwareVer,
manager_auth_type as managerAuthType,
msg_auth_type as msgAuthType,
sip_code as sipCode,
location_name as locationName,
system_type as systemType,
protocol as protocol,
record_plan_id as recordPlanId,
nu_id as nuId,
a.device_index as deviceIndex,
b.device_name as deviceName,
b.device_type as deviceType,
a.device_status as deviceStatus,
b.device_model as deviceModel,
a.ip as ip,
a.mac as mac,
a.region_id as regionId,
a.region_name as regionName,
a.parent_id as parentId,
a.parent_device_name as parentDeviceName,
a.project_id as projectId,
a.project_name as projectName,
a.firmware_ver as firmwareVer,
a.hardware_ver as hardwareVer,
a.manager_auth_type as managerAuthType,
a.msg_auth_type as msgAuthType,
a.sip_code as sipCode,
a.location_name as locationName,
a.system_type as systemType,
a.protocol as protocol,
a.record_plan_id as recordPlanId,
b.nu_id as nuId,
a.channel
from nu_iot_tplink_camera a
inner join nu_iot_device_preview b on a.mac = b.sn
where b.device_status != '损坏'
</select>
<select id="findNuPage" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
@ -281,48 +309,54 @@
</update>
<select id="previewList" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
select a.*,b.nu_name,b.area_flag
from (
select mac as id,nu_id,device_index,mac as sn,device_model,device_type,
( case device_status when '0' then '离线' when '1' then '在线' end ) as device_status,
dimension,
maintain_status
select
a.id,
a.nu_id,
c.nu_name,
a.dimension,
a.device_name,
a.device_type,
a.device_model,
a.factory,
a.sn,
a.create_time,
a.update_time,
a.remarks,
t.online_status as deviceStatus
from nu_iot_device_preview a
inner join nu_base_info c on a.nu_id = c.nu_id
inner 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 as id,nu_id,sn as device_index,sn,'' as device_model,'db' as device_type,
( case relay_state when '0' then '拉闸' else '合闸' end ) as device_status,
dimension,
maintain_status
select sn,
( case relay_state when '0' then '离线' else '在线' end ) as online_status
from nu_iot_ds_electricity_meter
union all
select cid as id,nu_id,cid as device_index,cid as sn,'' as device_model,'sb' as device_type,
( case relay_state when '0' then '关阀' else '开阀' end ) as device_status,
dimension,
maintain_status
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 as id,nu_id,sn as device_index,sn,'' as device_model,'wsdj' as device_type,
( case status when '0' then '在线' else '离线' end ) as device_status,
dimension,
maintain_status
select sn,
( case status when '0' then '在线' else '离线' end ) as online_status
from nu_iot_yiweilian_humid_device
) a
left join nu_base_info b on a.nu_id = b.nu_id
<where>
<if test="params.nuName != null and params.nuName != ''">
and b.nu_name like concat('%',#{params.nuName},'%')
</if>
<if test="params.deviceStatus != null and params.deviceStatus != ''">
and a.device_status = #{params.deviceStatus}
</if>
<if test="params.deviceType != null and params.deviceType != ''">
and a.device_type = #{params.deviceType}
</if>
<if test="params.dimension != null and params.dimension != ''">
and a.dimension = #{params.dimension}
</if>
</where>
order by a.nu_id,a.device_type,a.sn
) t on a.sn = t.sn
where a.sn is not null
and ifnull(a.device_status,'') != '损坏'
<if test="params.nuId != null and params.nuId != ''">
AND a.nu_id = #{params.nuId}
</if>
<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>
<update id="release">

View File

@ -6,8 +6,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface HumidDeviceMapper extends BaseMapper<HumidDevice> {
IPage<HumidDevice> findPage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
List<HumidDevice> addList();
HumidDevice getHumidDevice(HumidDevice humidDevice);
int insertDevice(HumidDevice humidDevice);
int updateDevice(HumidDevice humidDevice);

View File

@ -54,6 +54,37 @@
</where>
</select>
<select id="addList" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
select
a.id,
a.sn,
b.device_name as deviceName,
b.device_type as deviceTypes,
a.reporting_interval as reportingInterval,
a.record_interval as recordInterval,
a.history_report_time as historyReportTime,
a.history_interval as historyInterval,
a.temperature_high as temperatureHigh,
a.temperature_low as temperatureLow,
a.temperature_buffer as temperatureBuffer,
a.humidity_high as humidityHigh,
a.humidity_low as humidityLow,
a.humidity_buffer as humidityBuffer,
a.iz_outages as izOutages,
a.iz_low_battery as izLowBattery,
a.iz_online as izOnline,
a.time_code as timeCode,
a.temperature,
a.humidity,
a.status,
a.reporting_time as reportingTime,
a.electricity,
b.nu_id as nuId
from nu_iot_yiweilian_humid_device a
inner join nu_iot_device_preview b on a.sn = b.sn
where b.device_status != '损坏'
</select>
<select id="getHumidDevice" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
select
id,

View File

@ -616,7 +616,7 @@ public class HumidDeviceServiceImpl extends ServiceImpl<HumidDeviceMapper, Humid
@Override
public List<HumidDeviceEntity> listAll() {
List<HumidDevice> list = baseMapper.selectList(new QueryWrapper<>());
List<HumidDevice> list = baseMapper.addList();
List<HumidDeviceEntity> list2 = BeanUtil.copyToList(list, HumidDeviceEntity.class);
return list2;
}

View File

@ -131,16 +131,16 @@ public class IotSyncBizMQListener {
cameraQw.eq("device_index",iotCameraInfoMQDto.getDeviceIndex());
CameraInfo entity = cameraInfoService.getOne(cameraQw);
if(entity!=null){
if(entity.getNuId()==null||entity.getNuId().equals("")){
entity.setNuId(iotCameraInfoMQDto.getNuId());
cameraInfoService.updateById(entity);
}
if(iotCameraInfoMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
// if(entity.getNuId()==null||entity.getNuId().equals("")){
// entity.setNuId(iotCameraInfoMQDto.getNuId());
// cameraInfoService.updateById(entity);
// }
// if(iotCameraInfoMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
statusMQDto.setMessage("忽略");
}else{
entity.setMaintainStatus(iotCameraInfoMQDto.getMaintainStatus());
cameraInfoService.updateById(entity);
}
// }else{
// entity.setMaintainStatus(iotCameraInfoMQDto.getMaintainStatus());
// cameraInfoService.updateById(entity);
// }
}else{
CameraInfo cameraInfo = new CameraInfo();
BeanUtils.copyProperties(iotCameraInfoMQDto, cameraInfo);
@ -209,16 +209,16 @@ public class IotSyncBizMQListener {
electricityQw.eq("sn",iotElectricityMeterMQDto.getSn());
ElectricityMeter entity = electricityMeterService.getOne(electricityQw);
if(entity!=null){
if(entity.getNuId()==null||entity.getNuId().equals("")){
entity.setNuId(iotElectricityMeterMQDto.getNuId());
electricityMeterService.updateById(entity);
}
if(iotElectricityMeterMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
// if(entity.getNuId()==null||entity.getNuId().equals("")){
// entity.setNuId(iotElectricityMeterMQDto.getNuId());
// electricityMeterService.updateById(entity);
// }
// if(iotElectricityMeterMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
statusMQDto.setMessage("忽略");
}else{
entity.setMaintainStatus(iotElectricityMeterMQDto.getMaintainStatus());
electricityMeterService.updateById(entity);
}
// }else{
// entity.setMaintainStatus(iotElectricityMeterMQDto.getMaintainStatus());
// electricityMeterService.updateById(entity);
// }
}else{
ElectricityMeter electricityMeter = new ElectricityMeter();
BeanUtils.copyProperties(iotElectricityMeterMQDto, electricityMeter);
@ -257,16 +257,16 @@ public class IotSyncBizMQListener {
waterQw.eq("cid",iotWaterMeterMQDto.getCid());
WaterMeter entity = waterMeterService.getOne(waterQw);
if(entity!=null){
if(entity.getNuId()==null||entity.getNuId().equals("")){
entity.setNuId(iotWaterMeterMQDto.getNuId());
waterMeterService.updateById(entity);
}
if(iotWaterMeterMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
// if(entity.getNuId()==null||entity.getNuId().equals("")){
// entity.setNuId(iotWaterMeterMQDto.getNuId());
// waterMeterService.updateById(entity);
// }
// if(iotWaterMeterMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
statusMQDto.setMessage("忽略");
}else{
entity.setMaintainStatus(iotWaterMeterMQDto.getMaintainStatus());
waterMeterService.updateById(entity);
}
// }else{
// entity.setMaintainStatus(iotWaterMeterMQDto.getMaintainStatus());
// waterMeterService.updateById(entity);
// }
}else{
WaterMeter waterMeter = new WaterMeter();
BeanUtils.copyProperties(iotWaterMeterMQDto, waterMeter);
@ -335,16 +335,16 @@ public class IotSyncBizMQListener {
humidQw.eq("sn",iotHumidDeviceMQDto.getSn());
HumidDevice entity = humidDeviceService.getOne(humidQw);
if(entity!=null){
if(entity.getNuId()==null||entity.getNuId().equals("")){
entity.setNuId(iotHumidDeviceMQDto.getNuId());
humidDeviceService.updateById(entity);
}
if(iotHumidDeviceMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
// if(entity.getNuId()==null||entity.getNuId().equals("")){
// entity.setNuId(iotHumidDeviceMQDto.getNuId());
// humidDeviceService.updateById(entity);
// }
// if(iotHumidDeviceMQDto.getMaintainStatus().equals(entity.getMaintainStatus())){
statusMQDto.setMessage("忽略");
}else{
entity.setMaintainStatus(iotHumidDeviceMQDto.getMaintainStatus());
humidDeviceService.updateById(entity);
}
// }else{
// entity.setMaintainStatus(iotHumidDeviceMQDto.getMaintainStatus());
// humidDeviceService.updateById(entity);
// }
}else{
HumidDevice humidDevice = new HumidDevice();
BeanUtils.copyProperties(iotHumidDeviceMQDto, humidDevice);

View File

@ -35,11 +35,10 @@ public interface NuBaseInfoMapper extends BaseMapper<NuBaseInfo> {
List<NuBaseInfo> queryReadList(@Param("employeesId") String employeesId,@Param("username") String username);
void updateSbsfTplink(@Param("nuId") String nuId);
void updateSbsfElectricity(@Param("nuId") String nuId);
void updateSbsfWater(@Param("nuId") String nuId);
void updateSbsfHumid(@Param("nuId") String nuId);
// void updateSbsfTplink(@Param("nuId") String nuId);
// void updateSbsfElectricity(@Param("nuId") String nuId);
// void updateSbsfWater(@Param("nuId") String nuId);
// void updateSbsfHumid(@Param("nuId") String nuId);
void addDeviceReleaseLog(@Param("nuId") String nuId);
void updateDevice(@Param("nuId") String nuId);
}

View File

@ -86,28 +86,61 @@
select create_by as empId,nu_id,'pdd' as type,'盘点单' as typeName from nu_invoicing_pdd_main where pdd_type = '1' and create_by = #{username} GROUP BY create_by,nu_id
</select>
<update id="updateSbsfTplink">
update nu_iot_tplink_camera
set nu_id = null,
dimension = null
where nu_id = #{nuId}
</update>
<update id="updateSbsfElectricity">
update nu_iot_ds_electricity_meter
set nu_id = null,
dimension = null
where nu_id = #{nuId}
</update>
<update id="updateSbsfWater">
update nu_iot_tq_water_meter
set nu_id = null,
dimension = null
where nu_id = #{nuId}
</update>
<update id="updateSbsfHumid">
update nu_iot_yiweilian_humid_device
set nu_id = null,
dimension = null
<!-- <update id="updateSbsfTplink">-->
<!-- update nu_iot_tplink_camera-->
<!-- set nu_id = null,-->
<!-- dimension = null-->
<!-- where nu_id = #{nuId}-->
<!-- </update>-->
<!-- <update id="updateSbsfElectricity">-->
<!-- update nu_iot_ds_electricity_meter-->
<!-- set nu_id = null,-->
<!-- dimension = null-->
<!-- where nu_id = #{nuId}-->
<!-- </update>-->
<!-- <update id="updateSbsfWater">-->
<!-- update nu_iot_tq_water_meter-->
<!-- set nu_id = null,-->
<!-- dimension = null-->
<!-- where nu_id = #{nuId}-->
<!-- </update>-->
<!-- <update id="updateSbsfHumid">-->
<!-- update nu_iot_yiweilian_humid_device-->
<!-- set nu_id = null,-->
<!-- dimension = null-->
<!-- where nu_id = #{nuId}-->
<!-- </update>-->
<insert id="addDeviceReleaseLog">
insert into nu_iot_device_bind_log(
sn,
dimension,
device_name,
device_type,
device_model,
factory,
opt_date,
opt_type,
remarks
)
select
sn,
dimension,
device_name,
device_type,
device_model,
factory,
now(),
'释放',
'区域停用'
from nu_iot_device_preview a
where a.nu_id = #{nuId}
and ifnull(a.device_status,'') != '损坏'
</insert>
<update id="updateDevice">
update nu_iot_device_preview
set nu_id = null
where nu_id = #{nuId}
</update>

View File

@ -167,10 +167,12 @@ public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseI
@Override
public void updateSbsf(NuBaseInfo nuBaseInfo) {
baseMapper.updateSbsfTplink(nuBaseInfo.getNuId());// 更新tplink
baseMapper.updateSbsfElectricity(nuBaseInfo.getNuId());// 更新电表
baseMapper.updateSbsfWater(nuBaseInfo.getNuId());// 更新水表
baseMapper.updateSbsfHumid(nuBaseInfo.getNuId());// 更新湿度计
// baseMapper.updateSbsfTplink(nuBaseInfo.getNuId());// 更新tplink
// baseMapper.updateSbsfElectricity(nuBaseInfo.getNuId());// 更新电表
// baseMapper.updateSbsfWater(nuBaseInfo.getNuId());// 更新水表
// baseMapper.updateSbsfHumid(nuBaseInfo.getNuId());// 更新湿度计
baseMapper.addDeviceReleaseLog(nuBaseInfo.getNuId());// 记录设备释放日志
baseMapper.updateDevice(nuBaseInfo.getNuId());// 更新湿度计
// 通知运维平台设防对应设备释放
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
String orgCode = deptInfo.getString("code");