物联设备管理-增加设备批次清单、设备配置增加设备名称

This commit is contained in:
曹磊 2026-04-07 18:01:15 +08:00
parent 58612987b5
commit 619eb055cd
17 changed files with 783 additions and 202 deletions

View File

@ -0,0 +1,30 @@
package com.nu.dto;
import lombok.Data;
import java.util.Date;
@Data
public class DevicePreviewMqDto {
private Integer id;
private String orgCode;
private String departName;
private String nuId;
private String nuName;
private String dimension;
private String sn;
private String deviceType;
private String deviceModel;
private String factory;
private String deviceStatus;
private Date createTime;//更新时间
private String createBy;//创建人
private Date updateTime;//更新时间
private String updateBy;//更新人
private String izSync;//是否同步
private Date syncTime;//同步时间
private String syncBy;//同步人
private Integer purchaseQuantity;
private String logId;//日志ID
private String remarks;//备注
private Integer ywId;//运维ID
}

View File

@ -0,0 +1,9 @@
package com.nu.dto;
import lombok.Data;
import java.util.List;
@Data
public class IotSyncPreviewMQDto {
private List<DevicePreviewMqDto> previewList;
}

View File

@ -65,6 +65,7 @@ public class DeviceConfigController extends JeecgController<DeviceConfig, IDevic
@PostMapping(value = "/add")
public Result<String> add(@RequestBody DeviceConfig DeviceConfig) {
QueryWrapper<DeviceConfig> emQw = new QueryWrapper<>();
emQw.eq("device_name",DeviceConfig.getDeviceName());
emQw.eq("device_type",DeviceConfig.getDeviceType());
emQw.eq("device_model",DeviceConfig.getDeviceModel());
emQw.eq("factory",DeviceConfig.getFactory());

View File

@ -19,6 +19,7 @@ public class DeviceConfig implements Serializable {
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "ID")
private Integer id;
private String deviceName;
@Dict(dicCode = "tplink_device_type")
private String deviceType;
private String deviceModel;

View File

@ -5,6 +5,7 @@
<select id="queryList" parameterType="com.nu.modules.device.config.entity.DeviceConfig" resultType="com.nu.modules.device.config.entity.DeviceConfig">
select
id,
device_name,
device_type,
device_model,
factory,

View File

@ -4,13 +4,11 @@ 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.device.config.entity.DeviceConfig;
import com.nu.modules.device.manager.entity.DeviceBindLog;
import com.nu.modules.device.manager.entity.DeviceIntegration;
import com.nu.modules.device.manager.entity.DeviceManager;
import com.nu.modules.device.manager.entity.DevicePreview;
import com.nu.modules.device.manager.entity.*;
import com.nu.modules.device.manager.service.IDeviceManagerService;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -18,7 +16,9 @@ import org.springframework.web.servlet.ModelAndView;
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;
/**
* @Description: 设备管理
@ -48,95 +48,78 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Page<DeviceManager> page = new Page<DeviceManager>(pageNo, pageSize);
IPage<DeviceManager> pageList = service.findPage(page, DeviceManager);
IPage<DeviceManager> pageList = service.findPlanPage(page, DeviceManager);
return Result.OK(pageList);
}
/**
* 分页列表查询
*
* @param deviceBatch
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@GetMapping(value = "/batchList")
public Result<IPage<DeviceBatch>> queryBatchPageList(DeviceBatch deviceBatch,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Page<DeviceBatch> page = new Page<DeviceBatch>(pageNo, pageSize);
IPage<DeviceBatch> pageList = service.findBatchPage(page, deviceBatch);
return Result.OK(pageList);
}
/**
* 获取批次号
*
* @param deviceBatch
* @return
*/
@GetMapping(value = "/getBatchNo")
public Result<Map<String,String>> getBatchNo(DeviceBatch deviceBatch) {
String batchNo = service.getBatchNo(deviceBatch);
Map<String,String> map = new HashMap<>();
map.put("batchNo",batchNo);
return Result.OK(map);
}
/**
* 添加
*
* @param DeviceManager
* @param deviceBatch
* @return
*/
@PostMapping(value = "/add")
public Result<String> add(@RequestBody DeviceManager DeviceManager) {
service.save(DeviceManager);
@PostMapping(value = "/addBatch")
public Result<String> addBatch(@RequestBody DeviceBatch deviceBatch) {
service.saveBatch(deviceBatch);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param DeviceManager
* @param deviceBatch
* @return
*/
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody DeviceManager DeviceManager) {
service.updateById(DeviceManager);
@RequestMapping(value = "/editBatch", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> editBatch(@RequestBody DeviceBatch deviceBatch) {
service.updateBatch(deviceBatch);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @param deviceBatch
* @return
*/
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
service.removeById(id);
@RequestMapping(value = "/deleteBatch", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> deleteBatch(@RequestBody DeviceBatch deviceBatch) {
service.removeBatch(deviceBatch);
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);
}
/**
* 设备集成-机构设备清单分页列表查询
@ -153,7 +136,7 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Page<DevicePreview> page = new Page<DevicePreview>(pageNo, pageSize);
IPage<DevicePreview> pageList = service.findDepartPreviewPage(page, devicePreview);
IPage<DevicePreview> pageList = service.findDepartPreviewPlanPage(page, devicePreview);
return Result.OK(pageList);
}
@ -183,7 +166,7 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Page<DevicePreview> page = new Page<DevicePreview>(pageNo, pageSize);
IPage<DevicePreview> pageList = service.findNuPreviewPage(page, devicePreview);
IPage<DevicePreview> pageList = service.findNuPreviewPlanPage(page, devicePreview);
return Result.OK(pageList);
}
@ -195,7 +178,7 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@RequestMapping(value = "/savePreview", method = RequestMethod.POST)
public Result<String> savePreview(@RequestBody DevicePreview devicePreview) {
service.addPreview(devicePreview);
service.addPreviewPlan(devicePreview);
return Result.OK("添加成功!");
}
@ -207,7 +190,7 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@RequestMapping(value = "/updatePreview", method = RequestMethod.POST)
public Result<String> updatePreview(@RequestBody DevicePreview devicePreview) {
service.updatePreview(devicePreview);
service.updatePreviewPlan(devicePreview);
return Result.OK("修改成功!");
}
@ -219,7 +202,7 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@RequestMapping(value = "/deletePreview", method = RequestMethod.POST)
public Result<String> deletePreview(@RequestBody DevicePreview devicePreview) {
service.deletePreview(devicePreview);
service.deletePreviewPlan(devicePreview);
return Result.OK("删除成功!");
}

View File

@ -0,0 +1,29 @@
package com.nu.modules.device.manager.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
public class DeviceBatch implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String orgCode;
private String departName;
private String batchNo;
private String izPush;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date createTime;//创建时间
private String createBy;//创建人
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date updateTime;//更新时间
private String updateBy;//更新人
private String remarks;//备注
private int childrenCn;//设备清单数量
}

View File

@ -32,4 +32,5 @@ public class DeviceBindLog implements Serializable {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date optDate;
private String optType;
private String remarks;
}

View File

@ -10,14 +10,17 @@ public class DeviceIntegration implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String departId;
private String orgCode;
private String dimension;
@Dict(dicCode = "tplink_device_type")
private String deviceType;
private String deviceModel;
private String factory;
private String sn;
//在线状态
private String deviceStatus;
//分配
private String allocateStatus;
//设备状态
private String maintainStatus;
}

View File

@ -3,11 +3,14 @@ package com.nu.modules.device.manager.entity;
import com.baomidou.mybatisplus.annotation.IdType;
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.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
public class DevicePreview implements Serializable {
@ -21,10 +24,29 @@ public class DevicePreview implements Serializable {
private String departName;
private String nuId;
private String nuName;
private String batchNo;
private String dimension;
private String sn;
private String deviceName;
@Dict(dicCode = "tplink_device_type")
private String deviceType;
private String deviceModel;
private String factory;
private String dimension;
private String deviceStatus;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date createTime;//创建时间
private String createBy;//创建人
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date updateTime;//更新时间
private String updateBy;//更新人
private String izSync;//是否同步
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date syncTime;//同步时间
private String syncBy;//同步人
private String allocateStatus;//分配
private Integer purchaseQuantity;
private String logId;//日志ID
}

View File

@ -3,10 +3,7 @@ package com.nu.modules.device.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.device.manager.entity.DeviceIntegration;
import com.nu.modules.device.manager.entity.DeviceManager;
import com.nu.modules.device.manager.entity.DevicePreview;
import com.nu.modules.device.manager.entity.DeviceBindLog;
import com.nu.modules.device.manager.entity.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -18,18 +15,29 @@ import java.util.List;
* @Version: V1.0
*/
public interface DeviceManagerMapper extends BaseMapper<DeviceManager> {
IPage<DeviceManager> findPage(Page<DeviceManager> page, @Param("params") DeviceManager deviceManager);
IPage<DeviceManager> findPlanPage(Page<DeviceManager> page, @Param("params") DeviceManager deviceManager);
IPage<DeviceBatch> findBatchPage(Page<DeviceBatch> page, @Param("params") DeviceBatch deviceBatch);
void saveBatch(DeviceBatch deviceBatch);
void updateBatch(DeviceBatch deviceBatch);
void removeBatch(DeviceBatch deviceBatch);
void removePlanByBatch(DeviceBatch deviceBatch);
List<DevicePreview> queryNuList(DevicePreview devicePreview);
IPage<DevicePreview> findDepartPreviewPage(Page<DevicePreview> page, @Param("params") DevicePreview devicePreview);
IPage<DevicePreview> findNuPreviewPage(Page<DevicePreview> page, @Param("params") DevicePreview devicePreview);
IPage<DevicePreview> findDepartPreviewPlanPage(Page<DevicePreview> page, @Param("params") DevicePreview devicePreview);
IPage<DevicePreview> findNuPreviewPlanPage(Page<DevicePreview> page, @Param("params") DevicePreview devicePreview);
List<DevicePreview> getPreviewPlanList(DevicePreview devicePreview);
DevicePreview getPreview(DevicePreview devicePreview);
void addPreview(DevicePreview devicePreview);
void updatePreview(DevicePreview devicePreview);
void deletePreview(DevicePreview devicePreview);
int addPreviewPlan(DevicePreview devicePreview);
void updatePreviewPlan(DevicePreview devicePreview);
void deletePreviewPlanById(DevicePreview devicePreview);
void syncPreview(String id);
void deletePreviewById(String id);
void editPreviewSn(DevicePreview devicePreview);
void bindPreview(DevicePreview devicePreview);
IPage<DeviceIntegration> findCameraPage(Page<DeviceIntegration> page, @Param("params") DeviceIntegration deviceIntegration);
IPage<DeviceIntegration> findNetworkPage(Page<DeviceIntegration> page, @Param("params") DeviceIntegration deviceIntegration);
IPage<DeviceIntegration> findElectricityPage(Page<DeviceIntegration> page, @Param("params") DeviceIntegration deviceIntegration);
IPage<DeviceIntegration> findWaterPage(Page<DeviceIntegration> page, @Param("params") DeviceIntegration deviceIntegration);
IPage<DeviceIntegration> findHumidPage(Page<DeviceIntegration> page, @Param("params") DeviceIntegration deviceIntegration);
IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, @Param("params") DeviceBindLog deviceBindLog);
void addBindPreview(DeviceBindLog deviceBindLog);
}

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nu.modules.device.manager.mapper.DeviceManagerMapper">
<select id="findPage" parameterType="com.nu.modules.device.manager.entity.DeviceManager" resultType="com.nu.modules.device.manager.entity.DeviceManager">
<select id="findPlanPage" parameterType="com.nu.modules.device.manager.entity.DeviceManager" resultType="com.nu.modules.device.manager.entity.DeviceManager">
select a.id,
a.org_code,
a.depart_name,
@ -22,6 +22,63 @@
order by a.org_code desc
</select>
<select id="findBatchPage" parameterType="com.nu.modules.device.manager.entity.DeviceBatch" resultType="com.nu.modules.device.manager.entity.DeviceBatch">
select a.id,
a.batch_no,
a.org_code,
b.depart_name,
a.iz_push,
a.create_time,
a.create_by,
a.remarks
from nu_iot_device_preview_batch a
inner join sys_depart b on a.org_code = b.org_code
where a.org_code = #{params.orgCode}
<if test="params.batchNo != null and params.batchNo != ''">
AND a.batch_no LIKE concat('%',#{params.batchNo},'%')
</if>
<if test="params.izPush != null and params.izPush != ''">
AND a.iz_push = #{params.izPush}
</if>
order by a.create_time desc
</select>
<insert id="saveBatch" parameterType="com.nu.modules.device.manager.entity.DevicePreview" useGeneratedKeys="true" keyProperty="id">
insert into nu_iot_device_preview_batch(
batch_no,
org_code,
iz_push,
create_time,
create_by,
remarks
)
values(
#{batchNo},
#{orgCode},
'N',
now(),
#{createBy},
#{remarks}
)
</insert>
<update id="updateBatch">
update nu_iot_device_preview_batch
set iz_push = #{izPush},
remarks = #{remarks},
update_by = #{updateBy},
update_time = now()
where id = #{id}
</update>
<delete id="removeBatch">
delete from nu_iot_device_preview_batch where id = #{id}
</delete>
<delete id="removePlanByBatch">
delete from nu_iot_device_preview_plan where batch_no = #{batchNo}
</delete>
<select id="queryNuList" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
select nu_id,nu_name
from nu_base_info
@ -30,43 +87,48 @@
order by nu_id asc
</select>
<select id="findDepartPreviewPage" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
<select id="findDepartPreviewPlanPage" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
select
a.org_code,
b.depart_name,
a.batch_no,
a.device_name,
a.device_type,
a.device_model,
a.factory,
a.dimension,
sum(purchase_quantity) as purchaseQuantity
from nu_iot_device_preview a
sum(a.purchase_quantity) as purchaseQuantity
from nu_iot_device_preview_plan a
inner join sys_depart b on a.org_code = b.org_code
where a.org_code = #{params.orgCode}
where a.org_code = #{params.orgCode} and a.batch_no = #{params.batchNo}
<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>
group by a.org_code,b.depart_name,a.device_type,a.device_model,a.factory,a.dimension
group by a.org_code,b.depart_name,a.device_name,a.device_type,a.device_model,a.factory,a.dimension
order by a.device_type asc
</select>
<select id="findNuPreviewPage" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
select a.id,
<select id="findNuPreviewPlanPage" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
select
a.id,
a.org_code,
b.depart_name,
a.nu_id,
c.nu_name,
a.batch_no,
a.device_name,
a.device_type,
a.device_model,
a.factory,
a.dimension,
purchase_quantity
from nu_iot_device_preview a
a.purchase_quantity
from nu_iot_device_preview_plan a
inner join sys_depart b on a.org_code = b.org_code
left join nu_base_info c on a.nu_id = c.nu_id
where a.org_code = #{params.orgCode}
where a.org_code = #{params.orgCode} and a.batch_no = #{params.batchNo}
<if test="params.nuName != null and params.nuName != ''">
AND c.nu_name LIKE concat('%',#{params.nuName},'%')
</if>
@ -76,20 +138,26 @@
<if test="params.deviceType != null and params.deviceType != ''">
AND a.device_type = #{params.deviceType}
</if>
order by a.nu_id,a.device_type,a.id asc
order by a.nu_id,a.device_type asc
</select>
<select id="getPreview" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
<select id="getPreviewPlanList" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
select id,
batch_no,
org_code,
nu_id,
dimension,
device_name,
device_type,
device_model,
factory,
dimension,
purchase_quantity
from nu_iot_device_preview
<where> org_code = #{orgCode}
purchase_quantity,
create_time,
create_by,
update_time,
update_by
from nu_iot_device_preview_plan
<where> org_code = #{orgCode} and batch_no = #{batchNo}
<if test="dimension != null and dimension != ''">
AND dimension = #{dimension}
</if>
@ -109,51 +177,139 @@
AND nu_id = #{nuId}
</if>
</where>
</select>
<select id="getPreview" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
select id,
org_code,
nu_id,
dimension,
sn,
device_name,
device_type,
device_model,
factory,
device_status,
create_time,
create_by,
update_time,
update_by,
iz_sync,
sync_time,
sync_by,
allocate_status
from nu_iot_device_preview_plan
<where>
<if test="orgCode != null and orgCode != ''">
AND org_code = #{orgCode}
</if>
<if test="batchNo != null and batchNo != ''">
AND batch_no = #{batchNo}
</if>
<if test="dimension != null and dimension != ''">
AND dimension = #{dimension}
</if>
<if test="orgCode != null and orgCode != ''">
AND org_code = #{orgCode}
</if>
<if test="deviceType != null and deviceType != ''">
AND device_type = #{deviceType}
</if>
<if test="deviceModel != null and deviceModel != ''">
AND device_model = #{deviceModel}
</if>
<if test="factory != null and factory != ''">
AND factory = #{factory}
</if>
<if test="nuId != null and nuId != ''">
AND nu_id = #{nuId}
</if>
<if test="id != null and id != ''">
AND id = #{id}
</if>
</where>
limit 1
</select>
<insert id="addPreview">
insert into nu_iot_device_preview(
<insert id="addPreviewPlan" parameterType="com.nu.modules.device.manager.entity.DevicePreview" useGeneratedKeys="true" keyProperty="id">
insert into nu_iot_device_preview_plan(
org_code,
nu_id,
batch_no,
device_name,
device_type,
device_model,
factory,
dimension,
create_time,
create_by,
purchase_quantity
)
values(
#{orgCode},
#{nuId},
#{deviceType},
#{deviceModel},
#{factory},
#{dimension},
#{purchaseQuantity}
#{orgCode},
#{nuId},
#{batchNo},
#{deviceName},
#{deviceType},
#{deviceModel},
#{factory},
#{dimension},
now(),
#{createBy},
#{purchaseQuantity}
)
</insert>
<update id="updatePreview">
update nu_iot_device_preview
set purchase_quantity = #{purchaseQuantity}
<update id="updatePreviewPlan">
update nu_iot_device_preview_plan
set nu_id = #{nuId},
purchase_quantity = #{purchaseQuantity},
update_time = now()
where id = #{id}
</update>
<delete id="deletePreview">
<delete id="deletePreviewPlanById">
delete from nu_iot_device_preview_plan where id = #{id}
</delete>
<update id="syncPreview">
update nu_iot_device_preview
set iz_sync = 'Y',
sync_time = now()
where id = #{id}
</update>
<delete id="deletePreviewById">
delete from nu_iot_device_preview where id = #{id}
</delete>
<update id="editPreviewSn">
update nu_iot_device_preview
set sn = #{sn}
where id = #{id}
</update>
<update id="bindPreview">
update nu_iot_device_preview
set nu_id = #{nuId},
device_status = #{deviceStatus},
update_time = now()
where id = #{id}
</update>
<select id="findCameraPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration" resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select
a.dimension,
a.device_type,
a.device_model,
b.factory,
( case a.device_status when '0' then '离线' when '1' then '在线' end ) as device_status,
a.maintain_status
from nu_iot_tplink_camera a
inner join nu_iot_device_config b on a.device_config_id = b.id
where a.depart_id = #{params.departId}
a.dimension,
a.sn,
a.device_type,
a.device_model,
a.factory,
(case ifnull(b.device_status,'') when '0' then '离线' when '1' then '在线' else '待集成' end ) as device_status,
a.allocate_status,
a.device_status as maintainStatus
from nu_iot_device_preview a
left join nu_iot_tplink_camera b on a.sn = b.mac
where a.org_code = #{params.orgCode}
AND a.device_type in ('SURVEILLANCECAMERA','NETWORKVIDEORECORDER')
order by a.id
</select>
@ -161,14 +317,16 @@
<select id="findNetworkPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration" resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select
a.dimension,
a.sn,
a.device_type,
b.device_model,
b.factory,
( case a.device_status when '0' then '离线' when '1' then '在线' end ) as device_status,
a.maintain_status
from nu_iot_tplink_camera a
inner join nu_iot_device_config b on a.device_config_id = b.id
where a.depart_id = #{params.departId}
a.device_model,
a.factory,
(case ifnull(b.device_status,'') when '0' then '离线' when '1' then '在线' else '待集成' end ) as device_status,
a.allocate_status,
a.device_status as maintainStatus
from nu_iot_device_preview a
left join nu_iot_tplink_camera b on a.sn = b.mac
where a.org_code = #{params.orgCode}
AND a.device_type in ('SWITCH','ROUTER','AP')
order by a.id
</select>
@ -176,42 +334,51 @@
<select id="findElectricityPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration" resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select
a.dimension,
'db' as device_type,
b.device_model,
b.factory,
( case a.relay_state when '0' then '拉闸' else '合闸' end ) as device_status,
a.maintain_status
from nu_iot_ds_electricity_meter a
inner join nu_iot_device_config b on a.device_config_id = b.id
where a.depart_id = #{params.departId}
a.sn,
a.device_type,
a.device_model,
a.factory,
(case ifnull(b.relay_state,'') when '0' then '拉闸' when '1' then '合闸' else '待集成' end ) as device_status,
a.allocate_status,
a.device_status as maintainStatus
from nu_iot_device_preview a
left join nu_iot_ds_electricity_meter b on a.sn = b.sn
where a.org_code = #{params.orgCode}
AND a.device_type = 'db'
order by a.id
</select>
<select id="findWaterPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration" resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select
a.dimension,
'sb' as device_type,
b.device_model,
b.factory,
( case a.relay_state when '0' then '关阀' else '开阀' end ) as device_status,
a.maintain_status
from nu_iot_tq_water_meter a
inner join nu_iot_device_config b on a.device_config_id = b.id
where a.depart_id = #{params.departId}
a.sn,
a.device_type,
a.device_model,
a.factory,
(case ifnull(b.relay_state,'') when '0' then '关阀' when '1' then '开阀' else '待集成' end ) as device_status,
a.allocate_status,
a.device_status as maintainStatus
from nu_iot_device_preview a
left join nu_iot_tq_water_meter b on a.sn = b.cid
where a.org_code = #{params.orgCode}
AND a.device_type = 'sb'
order by a.id
</select>
<select id="findHumidPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration" resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select
a.dimension,
'wsdj' as device_type,
b.device_model,
b.factory,
( case status when '0' then '在线' else '离线' end ) as device_status,
a.maintain_status
from nu_iot_yiweilian_humid_device a
inner join nu_iot_device_config b on a.device_config_id = b.id
where a.depart_id = #{params.departId}
a.sn,
a.device_type,
a.device_model,
a.factory,
(case ifnull(b.status,'') when '0' then '在线' when '1' then '离线' else '待集成' end ) as device_status,
a.allocate_status,
a.device_status as maintainStatus
from nu_iot_device_preview a
left join nu_iot_yiweilian_humid_device b on a.sn = b.sn
where a.org_code = #{params.orgCode}
AND a.device_type = 'wsdj'
order by a.id
</select>
@ -233,4 +400,32 @@
order by org_code asc ,factory asc ,device_type asc ,device_model asc ,sn asc,opt_date desc
</select>
<insert id="addBindPreview">
insert into nu_iot_device_bind_log(
org_code,
nu_id,
nu_name,
dimension,
device_type,
device_model,
sn,
factory,
opt_date,
opt_type,
remarks
)values(
#{orgCode},
#{nuId},
#{nuName},
#{dimension},
#{deviceType},
#{deviceModel},
#{sn},
#{factory},
now(),
#{optType},
#{remarks}
)
</insert>
</mapper>

View File

@ -3,10 +3,7 @@ package com.nu.modules.device.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.device.manager.entity.DeviceBindLog;
import com.nu.modules.device.manager.entity.DeviceIntegration;
import com.nu.modules.device.manager.entity.DeviceManager;
import com.nu.modules.device.manager.entity.DevicePreview;
import com.nu.modules.device.manager.entity.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -18,17 +15,27 @@ import java.util.List;
* @Version: V1.0
*/
public interface IDeviceManagerService extends IService<DeviceManager> {
IPage<DeviceManager> findPage(Page<DeviceManager> page, DeviceManager deviceManager);
IPage<DeviceManager> findPlanPage(Page<DeviceManager> page, DeviceManager deviceManager);
IPage<DeviceBatch> findBatchPage(Page<DeviceBatch> page, DeviceBatch deviceBatch);
String getBatchNo(DeviceBatch deviceBatch);
void saveBatch(DeviceBatch deviceBatch);
void updateBatch(DeviceBatch deviceBatch);
void removeBatch(DeviceBatch deviceBatch);
List<DevicePreview> queryNuList(DevicePreview devicePreview);
IPage<DevicePreview> findDepartPreviewPage(Page<DevicePreview> page, DevicePreview devicePreview);
IPage<DevicePreview> findNuPreviewPage(Page<DevicePreview> page, DevicePreview devicePreview);
void addPreview(DevicePreview devicePreview);
void updatePreview(DevicePreview devicePreview);
void deletePreview(DevicePreview devicePreview);
IPage<DevicePreview> findDepartPreviewPlanPage(Page<DevicePreview> page, DevicePreview devicePreview);
IPage<DevicePreview> findNuPreviewPlanPage(Page<DevicePreview> page, DevicePreview devicePreview);
void addPreviewPlan(DevicePreview devicePreview);
void updatePreviewPlan(DevicePreview devicePreview);
void deletePreviewPlan(DevicePreview devicePreview);
void syncPreview(String id);
void deletePreviewById(String id);
void editPreviewSn(DevicePreview devicePreview);
void bindPreview(DevicePreview devicePreview);
IPage<DeviceIntegration> findCameraPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
IPage<DeviceIntegration> findNetworkPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
IPage<DeviceIntegration> findElectricityPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
IPage<DeviceIntegration> findWaterPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
IPage<DeviceIntegration> findHumidPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, DeviceBindLog deviceBindLog);
void addBindPreview(DeviceBindLog deviceBindLog);
}

View File

@ -1,17 +1,34 @@
package com.nu.modules.device.manager.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.device.manager.entity.DeviceBindLog;
import com.nu.modules.device.manager.entity.DeviceIntegration;
import com.nu.modules.device.manager.entity.DeviceManager;
import com.nu.modules.device.manager.entity.DevicePreview;
import com.nu.dto.DevicePreviewMqDto;
import com.nu.dto.IotSyncPreviewMQDto;
import com.nu.modules.device.manager.entity.*;
import com.nu.modules.device.manager.mapper.DeviceManagerMapper;
import com.nu.modules.device.manager.service.IDeviceManagerService;
import com.nu.modules.syncLog.entity.SyncBizLog;
import com.nu.modules.syncLog.service.ISyncBizLogService;
import com.nu.utils.RabbitMQUtil;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.utils.UuidUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -24,9 +41,60 @@ import java.util.List;
@Slf4j
public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, DeviceManager> implements IDeviceManagerService {
@Autowired
private RabbitMQUtil rabbitMQUtil;
@Autowired
private ISyncBizLogService logService;
@Override
public IPage<DeviceManager> findPage(Page<DeviceManager> page, DeviceManager deviceManager){
return baseMapper.findPage(page,deviceManager);
public IPage<DeviceManager> findPlanPage(Page<DeviceManager> page, DeviceManager deviceManager){
return baseMapper.findPlanPage(page,deviceManager);
}
@Override
public IPage<DeviceBatch> findBatchPage(Page<DeviceBatch> page, DeviceBatch deviceBatch){
IPage<DeviceBatch> records = baseMapper.findBatchPage(page,deviceBatch);
List<DeviceBatch> list = records.getRecords();
for(int i=0;i<list.size();i++){
DeviceBatch entity = list.get(i);
DevicePreview dp = new DevicePreview();
dp.setOrgCode(entity.getOrgCode());
dp.setBatchNo(entity.getBatchNo());
List<DevicePreview> dpList = baseMapper.getPreviewPlanList(dp);
entity.setChildrenCn(dpList.size());
}
return records;
}
@Override
public String getBatchNo(DeviceBatch deviceBatch){
// 机构编码 + 年月日时分秒
return deviceBatch.getOrgCode() + DateUtil.format(new Date(),"yyMMddHHmmss");
}
@Override
public void saveBatch(DeviceBatch deviceBatch){
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
deviceBatch.setCreateBy(sysUser.getRealname());
}
baseMapper.saveBatch(deviceBatch);
}
@Override
public void updateBatch(DeviceBatch deviceBatch){
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
deviceBatch.setUpdateBy(sysUser.getRealname());
}
baseMapper.updateBatch(deviceBatch);
}
@Override
public void removeBatch(DeviceBatch deviceBatch){
baseMapper.removeBatch(deviceBatch);
}
@Override
@ -35,40 +103,139 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public IPage<DevicePreview> findDepartPreviewPage(Page<DevicePreview> page, DevicePreview devicePreview){
return baseMapper.findDepartPreviewPage(page,devicePreview);
public IPage<DevicePreview> findDepartPreviewPlanPage(Page<DevicePreview> page, DevicePreview devicePreview){
return baseMapper.findDepartPreviewPlanPage(page,devicePreview);
}
@Override
public IPage<DevicePreview> findNuPreviewPage(Page<DevicePreview> page, DevicePreview devicePreview){
return baseMapper.findNuPreviewPage(page,devicePreview);
public IPage<DevicePreview> findNuPreviewPlanPage(Page<DevicePreview> page, DevicePreview devicePreview){
return baseMapper.findNuPreviewPlanPage(page,devicePreview);
}
@Override
public void addPreview(DevicePreview devicePreview){
DevicePreview entity = baseMapper.getPreview(devicePreview);
if(entity!=null){
int purchaseQuantity = devicePreview.getPurchaseQuantity()+entity.getPurchaseQuantity();
DevicePreview vo = new DevicePreview();
vo.setId(entity.getId());
vo.setPurchaseQuantity(purchaseQuantity);
baseMapper.updatePreview(vo);
}else{
baseMapper.addPreview(devicePreview);
public void addPreviewPlan(DevicePreview devicePreview){
// List<DevicePreviewMqDto> iotList = new ArrayList<>();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
devicePreview.setCreateBy(sysUser.getRealname());
}
//需同步到业务
// int quantity = devicePreview.getPurchaseQuantity();
// for(int i=0;i<quantity;i++){
baseMapper.addPreviewPlan(devicePreview);
// DevicePreviewMqDto previewDto = new DevicePreviewMqDto();
// BeanUtils.copyProperties(devicePreview,previewDto);
// String resId = addLog(devicePreview.getOrgCode(),"", JSON.toJSONString(devicePreview),"新增清单",devicePreview.getDeviceType());
// previewDto.setLogId(resId);
// previewDto.setYwId(previewDto.getId());
// iotList.add(previewDto);
// }
// IotSyncPreviewMQDto dto = new IotSyncPreviewMQDto();
// dto.setPreviewList(iotList);
//发送MQ同步到业务
// rabbitMQUtil.sendToExchange("hldy.iotsyncbiz", devicePreview.getOrgCode() + ".iotsyncbiz.addpreview", dto);
}
@Override
public void updatePreview(DevicePreview devicePreview){
baseMapper.updatePreview(devicePreview);
//需同步到业务
public void updatePreviewPlan(DevicePreview devicePreview){
// List<DevicePreviewMqDto> iotList = new ArrayList<>();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
devicePreview.setUpdateBy(sysUser.getRealname());
}
baseMapper.updatePreviewPlan(devicePreview);
// List<DevicePreview> list = baseMapper.getPreviewList(devicePreview);
// int quantity = devicePreview.getPurchaseQuantity();
// if(quantity>list.size()){
// int cn = quantity - list.size();
// for(int i=0;i<cn;i++){
// baseMapper.addPreview(devicePreview);
// DevicePreviewMqDto previewDto = new DevicePreviewMqDto();
// BeanUtils.copyProperties(devicePreview,previewDto);
// String resId = addLog(devicePreview.getOrgCode(),"", JSON.toJSONString(devicePreview),"新增清单",devicePreview.getDeviceType());
// previewDto.setLogId(resId);
// previewDto.setYwId(previewDto.getId());
// iotList.add(previewDto);
// }
// IotSyncPreviewMQDto dto = new IotSyncPreviewMQDto();
// dto.setPreviewList(iotList);
//发送MQ同步到业务
// rabbitMQUtil.sendToExchange("hldy.iotsyncbiz", devicePreview.getOrgCode() + ".iotsyncbiz.addpreview", dto);
// }
// if(quantity<list.size()){
// int cn = list.size() - quantity;
// List<DevicePreview> emptyList = new ArrayList<>();
// for(int i=0;i<list.size();i++){
// DevicePreview entity = list.get(i);
// if(entity.getSn()==null||entity.equals("")){
// emptyList.add(entity);
// }
// }
// int delCn = 0;
// if(emptyList.size()>=cn){
// delCn = cn;
// }else{
// delCn = emptyList.size();
// }
// for(int i=0;i<delCn;i++){
// DevicePreview entity = emptyList.get(i);
// baseMapper.deletePreviewById(entity.getId().toString());
// DevicePreviewMqDto previewDto = new DevicePreviewMqDto();
// BeanUtils.copyProperties(entity,previewDto);
// String resId = addLog(entity.getOrgCode(),"", JSON.toJSONString(entity),"删除清单",entity.getDeviceType());
// previewDto.setLogId(resId);
// previewDto.setYwId(previewDto.getId());
// iotList.add(previewDto);
// }
// IotSyncPreviewMQDto dto = new IotSyncPreviewMQDto();
// dto.setPreviewList(iotList);
//发送MQ同步到业务
// rabbitMQUtil.sendToExchange("hldy.iotsyncbiz", devicePreview.getOrgCode() + ".iotsyncbiz.deletepreview", dto);
// }
}
@Override
public void deletePreview(DevicePreview devicePreview){
baseMapper.deletePreview(devicePreview);
//需同步到业务
public void deletePreviewPlan(DevicePreview devicePreview){
baseMapper.deletePreviewPlanById(devicePreview);
// List<DevicePreviewMqDto> iotList = new ArrayList<>();
// List<DevicePreview> list = baseMapper.getPreviewList(devicePreview);
// for(int i=0;i<list.size();i++){
// DevicePreview entity = list.get(i);
// if(entity.getSn()==null||entity.equals("")){
// baseMapper.deletePreviewById(entity.getId().toString());
// DevicePreviewMqDto previewDto = new DevicePreviewMqDto();
// BeanUtils.copyProperties(entity,previewDto);
// String resId = addLog(entity.getOrgCode(),"", JSON.toJSONString(entity),"删除清单",entity.getDeviceType());
// previewDto.setLogId(resId);
// previewDto.setYwId(previewDto.getId());
// iotList.add(previewDto);
// }
// }
// IotSyncPreviewMQDto dto = new IotSyncPreviewMQDto();
// dto.setPreviewList(iotList);
//发送MQ同步到业务
// rabbitMQUtil.sendToExchange("hldy.iotsyncbiz", devicePreview.getOrgCode() + ".iotsyncbiz.deletepreview", dto);
}
@Override
public void syncPreview(String id){
baseMapper.syncPreview(id);
}
@Override
public void deletePreviewById(String id){
baseMapper.deletePreviewById(id);
}
@Override
public void editPreviewSn(DevicePreview devicePreview){
baseMapper.editPreviewSn(devicePreview);
}
@Override
public void bindPreview(DevicePreview devicePreview){
baseMapper.bindPreview(devicePreview);
}
@Override
@ -100,4 +267,28 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
public IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, DeviceBindLog deviceBindLog){
return baseMapper.findBingLogPage(page,deviceBindLog);
}
@Override
public void addBindPreview(DeviceBindLog deviceBindLog){
baseMapper.addBindPreview(deviceBindLog);
}
public String addLog(String orgCode,String orgName,String json,String type,String iotType){
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String logId = UuidUtils.getUUID();
SyncBizLog log = new SyncBizLog();
log.setLogId(logId);
log.setOrgCode(orgCode);
log.setOrgName(orgName);
log.setContent(json);
log.setSyncType(type);
log.setStatus("同步中");
log.setServerType(iotType);
if (sysUser != null) {
log.setCreateBy(sysUser.getRealname());
}
logService.addLog(log);
return logId;
}
}

View File

@ -38,6 +38,7 @@ public class SyncBizLog implements Serializable {
private String syncType;
private String status;
private String serverType;
private String createBy;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;

View File

@ -10,17 +10,19 @@
sync_type,
status,
server_type,
create_time
create_time,
create_by
)
values (
#{logId},
#{orgCode},
#{orgName},
#{content},
#{syncType},
#{status},
#{serverType},
now()
#{logId},
#{orgCode},
#{orgName},
#{content},
#{syncType},
#{status},
#{serverType},
now(),
#{createBy}
)
</insert>

View File

@ -1,8 +1,12 @@
package com.nu.mq.device.listener;
import com.nu.dto.DevicePreviewMqDto;
import com.nu.dto.IotNuBaseInfoMQDto;
import com.nu.dto.StatusListMQDto;
import com.nu.dto.StatusMQDto;
import com.nu.modules.device.manager.entity.DeviceBindLog;
import com.nu.modules.device.manager.entity.DevicePreview;
import com.nu.modules.device.manager.service.IDeviceManagerService;
import com.nu.modules.dingshuo.electricity.entity.DsElectricityMeter;
import com.nu.modules.dingshuo.electricity.service.IDsElectricityMeterService;
import com.nu.modules.manager.entity.IotDeviceInfo;
@ -29,6 +33,7 @@ import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -66,6 +71,9 @@ public class IotDeviceMQListener {
@Autowired
private IIotDeviceInfoService iotDeviceInfoService;
@Autowired
private IDeviceManagerService deviceManagerService;
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "iotsyncbiz.async.result", durable = "true"),
@ -250,7 +258,6 @@ public class IotDeviceMQListener {
if(statusList.size()>0){
for(int i=0;i<statusList.size();i++){
StatusMQDto sdto = statusList.get(i);
String message = sdto.getMessage();
SyncBizLog log = new SyncBizLog();
log.setLogId(sdto.getPrimaryKey());
log.setStatus(sdto.getMessage());
@ -258,4 +265,94 @@ public class IotDeviceMQListener {
}
}
}
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "iotsyncbiz.addpreview.result", durable = "true"),
exchange = @Exchange(name = "hldy.iotsyncbiz", type = ExchangeTypes.DIRECT),
key = "iotsyncbiz.addpreview.result"
),
errorHandler = "iotDeviceMQErrorHandler"
)
public void addPreviewMessage(StatusListMQDto dto) {
List<StatusMQDto> statusList = dto.getStatusList();
if(statusList.size()>0){
for(int i=0;i<statusList.size();i++){
StatusMQDto sdto = statusList.get(i);
String message = sdto.getMessage();
SyncBizLog log = new SyncBizLog();
log.setLogId(sdto.getPrimaryKey());
log.setStatus(sdto.getMessage());
logService.updateLog(log);
if(message.equals("成功")){
deviceManagerService.syncPreview(sdto.getAsyncId());
}
}
}
}
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "iotsyncbiz.deletepreview.result", durable = "true"),
exchange = @Exchange(name = "hldy.iotsyncbiz", type = ExchangeTypes.DIRECT),
key = "iotsyncbiz.deletepreview.result"
),
errorHandler = "iotDeviceMQErrorHandler"
)
public void deletePreviewMessage(StatusListMQDto dto) {
List<StatusMQDto> statusList = dto.getStatusList();
if(statusList.size()>0){
for(int i=0;i<statusList.size();i++){
StatusMQDto sdto = statusList.get(i);
String message = sdto.getMessage();
SyncBizLog log = new SyncBizLog();
log.setLogId(sdto.getPrimaryKey());
log.setStatus(sdto.getMessage());
logService.updateLog(log);
if(message.equals("成功")){
deviceManagerService.deletePreviewById(sdto.getAsyncId());
}
}
}
}
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "iotsyncbiz.editpreviewsn", durable = "true"),
exchange = @Exchange(name = "hldy.iotsyncbiz", type = ExchangeTypes.DIRECT),
key = "iotsyncbiz.editpreviewsn"
),
errorHandler = "iotDeviceMQErrorHandler"
)
public void editPreviewSnMessage(DevicePreviewMqDto dto) {
if(dto!=null){
DevicePreview devicePreview = new DevicePreview();
devicePreview.setSn(dto.getSn());
devicePreview.setId(dto.getYwId());
deviceManagerService.editPreviewSn(devicePreview);
}
}
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "iotsyncbiz.bindpreview", durable = "true"),
exchange = @Exchange(name = "hldy.iotsyncbiz", type = ExchangeTypes.DIRECT),
key = "iotsyncbiz.bindpreview"
),
errorHandler = "iotDeviceMQErrorHandler"
)
public void bindPreviewSnMessage(DevicePreviewMqDto dto) {
if(dto!=null){
DevicePreview devicePreview = new DevicePreview();
devicePreview.setId(dto.getYwId());
devicePreview.setDeviceStatus(dto.getDeviceStatus());
devicePreview.setNuId(dto.getNuId());
deviceManagerService.bindPreview(devicePreview);
DeviceBindLog deviceBindLog = new DeviceBindLog();
BeanUtils.copyProperties(dto,deviceBindLog);
deviceBindLog.setOptType(dto.getDeviceStatus());
deviceManagerService.addBindPreview(deviceBindLog);
}
}
}