物联设备损坏增加更换设备
This commit is contained in:
parent
e94e0c12a5
commit
a73785a9f4
|
|
@ -358,4 +358,23 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
|
|||
service.updateById(deviceManager);
|
||||
return Result.OK("绑定成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param DeviceManager
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/ghList")
|
||||
public Result<IPage<DeviceManager>> ghList(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.findGhPage(page, DeviceManager);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,5 @@ public class DeviceBindLog implements Serializable {
|
|||
private String optType;
|
||||
private String remarks;
|
||||
private Integer ywId;
|
||||
private Integer newId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,4 +41,5 @@ public interface DeviceManagerMapper extends BaseMapper<DeviceManager> {
|
|||
IPage<HumidDevice> findHumidDeviceUnbindPage(Page<HumidDevice> page, @Param("params") DeviceManager deviceManager);
|
||||
void editPreviewStatusBySn(DeviceManager deviceManager);
|
||||
void editPreviewById(DeviceManager deviceManager);
|
||||
IPage<DeviceManager> findGhPage(Page<DeviceManager> page, @Param("params") DeviceManager deviceManager);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@
|
|||
a.yw_id,
|
||||
t.device_index
|
||||
from nu_iot_device_preview a
|
||||
inner join (
|
||||
select distinct sdi.item_value,sdi.item_text
|
||||
from sys_dict sd inner join sys_dict_item sdi on sd.id = sdi.dict_id
|
||||
where sd.dict_code = 'tplink_device_type' and sdi.status = '0'
|
||||
) dict on a.device_type = dict.item_value
|
||||
left join nu_base_info c on a.nu_id = c.nu_id
|
||||
left join (
|
||||
select mac as sn,
|
||||
|
|
@ -46,21 +51,14 @@
|
|||
) t on a.sn = t.sn
|
||||
where a.sn is not null
|
||||
and ifnull(a.device_status,'') != '损坏'
|
||||
<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>
|
||||
<if test="params.batchNo != null and params.batchNo != ''">
|
||||
AND a.batch_no = #{params.batchNo}
|
||||
</if>
|
||||
<if test="params.deviceStatus != null and params.deviceStatus != ''">
|
||||
AND t.online_status = #{params.deviceStatus}
|
||||
</if>
|
||||
<if test="params.nuName != null and params.nuName != ''">
|
||||
AND (
|
||||
c.nu_name LIKE concat('%',#{params.nuName},'%')
|
||||
or a.dimension LIKE concat('%',#{params.nuName},'%')
|
||||
or a.batch_no LIKE concat('%',#{params.nuName},'%')
|
||||
or dict.item_text LIKE concat('%',#{params.nuName},'%')
|
||||
)
|
||||
</if>
|
||||
order by a.batch_no,a.dimension,a.device_type,a.device_model,a.sn
|
||||
</select>
|
||||
|
||||
|
|
@ -159,7 +157,7 @@
|
|||
AND device_name LIKE concat('%',#{params.deviceName},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by factory asc ,device_type asc ,device_model asc ,sn asc,opt_date desc
|
||||
order by opt_date desc ,factory asc ,device_type asc ,device_model asc ,sn asc
|
||||
</select>
|
||||
|
||||
<insert id="addLog">
|
||||
|
|
@ -298,4 +296,61 @@
|
|||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="findGhPage" parameterType="com.nu.modules.manager.entity.DeviceManager" resultType="com.nu.modules.manager.entity.DeviceManager">
|
||||
select
|
||||
a.id,
|
||||
a.batch_no,
|
||||
a.dimension,
|
||||
a.device_name,
|
||||
a.device_type,
|
||||
a.device_model,
|
||||
a.factory,
|
||||
a.sn,
|
||||
a.create_time,
|
||||
a.update_time,
|
||||
a.remarks,
|
||||
a.device_status,
|
||||
t.online_status,
|
||||
a.yw_id,
|
||||
t.device_index
|
||||
from nu_iot_device_preview a
|
||||
inner join (
|
||||
select mac as sn,
|
||||
( case device_status when '0' then '离线' when '1' then '在线' end ) as online_status,
|
||||
device_index
|
||||
from nu_iot_tplink_camera
|
||||
union all
|
||||
select sn,
|
||||
( case relay_state when '0' then '离线' else '在线' end ) as online_status,
|
||||
'' as device_index
|
||||
from nu_iot_ds_electricity_meter
|
||||
union all
|
||||
select cid as sn,
|
||||
( case relay_state when '0' then '离线' else '在线' end ) as online_status,
|
||||
'' as device_index
|
||||
from nu_iot_tq_water_meter
|
||||
union all
|
||||
select sn,
|
||||
( case status when '0' then '在线' else '离线' end ) as online_status,
|
||||
'' as device_index
|
||||
from nu_iot_yiweilian_humid_device
|
||||
) t on a.sn = t.sn
|
||||
where a.sn is not null
|
||||
and a.nu_id is null
|
||||
and ifnull(a.device_status,'') != '损坏'
|
||||
<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>
|
||||
<if test="params.batchNo != null and params.batchNo != ''">
|
||||
AND a.batch_no = #{params.batchNo}
|
||||
</if>
|
||||
<if test="params.id != null and params.id != ''">
|
||||
AND a.id != #{params.id}
|
||||
</if>
|
||||
order by a.batch_no,a.dimension,a.device_type,a.device_model,a.sn
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public interface IDeviceManagerService extends IService<DeviceManager> {
|
|||
IPage<DeviceManager> findAllPage(Page<DeviceManager> page, DeviceManager deviceManager);
|
||||
IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, DeviceBindLog deviceBindLog);
|
||||
Result<String> updateManager(DeviceManager deviceManager);
|
||||
void addLog(DeviceBindLog deviceBindLog);
|
||||
void addLog(DeviceBindLog deviceBindLog) throws Exception;
|
||||
List<DeviceManager> queryNuList(DeviceManager deviceManager);
|
||||
List<DeviceManager> exportDeviceExcel(DeviceManager deviceManager);
|
||||
List<DeviceManagerHz> exportDeviceHzExcel(DeviceManagerHz deviceManager);
|
||||
|
|
@ -40,4 +40,6 @@ public interface IDeviceManagerService extends IService<DeviceManager> {
|
|||
DeviceManager findOneByType(DeviceManager deviceManager);
|
||||
void editPreviewStatusBySn(DeviceManager deviceManager);
|
||||
void editPreviewById(DeviceManager deviceManager);
|
||||
IPage<DeviceManager> findGhPage(Page<DeviceManager> page, DeviceManager deviceManager);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nu.modules.manager.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -22,6 +23,7 @@ import org.jeecg.common.system.api.ISysBaseAPI;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -74,13 +76,17 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
|
|||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void addLog(DeviceBindLog deviceBindLog){
|
||||
public void addLog(DeviceBindLog deviceBindLog) throws Exception {
|
||||
baseMapper.addLog(deviceBindLog);
|
||||
DeviceManager deviceManager = new DeviceManager();
|
||||
deviceManager.setId(deviceBindLog.getId());
|
||||
deviceManager.setDeviceStatus(deviceBindLog.getOptType());
|
||||
if(deviceBindLog.getOptType().equals("绑定区域")||deviceBindLog.getOptType().equals("更换区域")){
|
||||
if(!deviceBindLog.getOptType().equals("损坏")){
|
||||
deviceManager.setDeviceStatus("已绑定");
|
||||
}
|
||||
if(deviceBindLog.getDimension().equals("区域维度")){
|
||||
deviceManager.setNuId(deviceBindLog.getNuId());
|
||||
}
|
||||
baseMapper.updateById(deviceManager);
|
||||
|
|
@ -92,6 +98,38 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
|
|||
dto.setOrgCode(orgCode);
|
||||
dto.setDeviceStatus(deviceBindLog.getOptType());
|
||||
rabbitMQUtil.sendToExchange("hldy.iotsyncbiz", "iotsyncbiz.bindpreview", dto);
|
||||
|
||||
if(deviceBindLog.getOptType().equals("损坏")){
|
||||
if(deviceBindLog.getNewId()!=null){
|
||||
//更新新数据状态为绑定,如区域维度给定nuId
|
||||
if(deviceBindLog.getDimension().equals("区域维度")){
|
||||
deviceManager.setNuId(deviceBindLog.getNuId());
|
||||
}
|
||||
QueryWrapper<DeviceManager> qw = new QueryWrapper<>();
|
||||
qw.eq("id",deviceBindLog.getNewId());
|
||||
DeviceManager entity = this.getOne(qw);
|
||||
if(deviceBindLog.getDimension().equals("区域维度")){
|
||||
entity.setNuId(deviceBindLog.getNuId());
|
||||
entity.setNuName(deviceBindLog.getNuName());
|
||||
}
|
||||
entity.setDeviceStatus("已绑定");
|
||||
baseMapper.updateById(entity);
|
||||
|
||||
//同步给运维平台
|
||||
DevicePreviewMqDto dto2 = new DevicePreviewMqDto();
|
||||
BeanUtils.copyProperties(entity, dto2);
|
||||
dto2.setOrgCode(orgCode);
|
||||
dto2.setDeviceStatus("更换设备");
|
||||
dto2.setRemarks(deviceBindLog.getRemarks());
|
||||
rabbitMQUtil.sendToExchange("hldy.iotsyncbiz", "iotsyncbiz.bindpreview", dto2);
|
||||
|
||||
DeviceBindLog deviceBindLog2 = new DeviceBindLog();
|
||||
BeanUtils.copyProperties(entity, deviceBindLog2);
|
||||
deviceBindLog2.setOptType("更换设备");
|
||||
deviceBindLog2.setRemarks(deviceBindLog.getRemarks());
|
||||
baseMapper.addLog(deviceBindLog2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -162,4 +200,9 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
|
|||
public void editPreviewById(DeviceManager deviceManager){
|
||||
baseMapper.editPreviewById(deviceManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<DeviceManager> findGhPage(Page<DeviceManager> page, DeviceManager deviceManager){
|
||||
return baseMapper.findGhPage(page,deviceManager);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,13 +156,19 @@ public class IotSyncBizMQListener {
|
|||
deviceManager.setDeviceType(iotCameraInfoMQDto.getDeviceType());
|
||||
DeviceManager dm = deviceManagerService.findBySn(deviceManager);
|
||||
if(dm!=null){
|
||||
deviceManager.setDeviceStatus("正常");
|
||||
deviceManager.setDeviceStatus("未绑定");
|
||||
if(dm.getDimension().equals("机构维度")){
|
||||
deviceManager.setDeviceStatus("已绑定");
|
||||
}
|
||||
deviceManagerService.editPreviewStatusBySn(deviceManager);
|
||||
}else{
|
||||
DeviceManager snEmpty = deviceManagerService.findOneByType(deviceManager);
|
||||
if(snEmpty!=null){
|
||||
deviceManager.setId(snEmpty.getId());
|
||||
deviceManager.setDeviceStatus("正常");
|
||||
deviceManager.setDeviceStatus("未绑定");
|
||||
if(snEmpty.getDimension().equals("机构维度")){
|
||||
deviceManager.setDeviceStatus("已绑定");
|
||||
}
|
||||
deviceManagerService.updateById(deviceManager);
|
||||
|
||||
deviceManager.setYwId(snEmpty.getYwId());
|
||||
|
|
@ -250,7 +256,7 @@ public class IotSyncBizMQListener {
|
|||
mqttMessageHandler.subscribeUplinkMessage(iotElectricityMeterMQDto.getSn());
|
||||
DeviceManager deviceManager = new DeviceManager();
|
||||
deviceManager.setSn(iotElectricityMeterMQDto.getSn());
|
||||
deviceManager.setDeviceStatus("正常");
|
||||
deviceManager.setDeviceStatus("未绑定");
|
||||
deviceManagerService.editPreviewStatusBySn(deviceManager);
|
||||
}
|
||||
statusList.add(statusMQDto);
|
||||
|
|
@ -297,7 +303,7 @@ public class IotSyncBizMQListener {
|
|||
waterMeterService.save(waterMeter);
|
||||
DeviceManager deviceManager = new DeviceManager();
|
||||
deviceManager.setSn(iotWaterMeterMQDto.getCid());
|
||||
deviceManager.setDeviceStatus("正常");
|
||||
deviceManager.setDeviceStatus("未绑定");
|
||||
deviceManagerService.editPreviewStatusBySn(deviceManager);
|
||||
}
|
||||
statusList.add(statusMQDto);
|
||||
|
|
@ -375,7 +381,7 @@ public class IotSyncBizMQListener {
|
|||
humidDeviceService.save(humidDevice);
|
||||
DeviceManager deviceManager = new DeviceManager();
|
||||
deviceManager.setSn(iotHumidDeviceMQDto.getSn());
|
||||
deviceManager.setDeviceStatus("正常");
|
||||
deviceManager.setDeviceStatus("未绑定");
|
||||
deviceManagerService.editPreviewStatusBySn(deviceManager);
|
||||
}
|
||||
statusList.add(statusMQDto);
|
||||
|
|
|
|||
Loading…
Reference in New Issue