设备管理-设备清单-批次的设备清单-新增区域维度功能调整:展示机构+批次下所有护理单元的护理单元信息、已配置基础服务、设备信息数量

This commit is contained in:
1378012178@qq.com 2026-04-24 10:11:54 +08:00
parent 232b1af5b0
commit bd13a5aaa8
6 changed files with 918 additions and 487 deletions

View File

@ -6,13 +6,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nu.modules.device.config.entity.DeviceConfig;
import com.nu.modules.device.manager.entity.*;
import com.nu.modules.device.manager.service.IDeviceManagerService;
import dm.jdbc.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Param;
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.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
@ -23,34 +27,34 @@ import java.util.Map;
/**
* @Description: 设备管理
* @Author: jeecg-boot
* @Date: 2026-03-30
* @Date: 2026-03-30
* @Version: V1.0
*/
@RestController
@RequestMapping("/iot/device/manager")
@Slf4j
public class DeviceManagerController extends JeecgController<DeviceManager, IDeviceManagerService> {
@Autowired
private IDeviceManagerService service;
@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.findPlanPage(page, DeviceManager);
return Result.OK(pageList);
}
/**
* 分页列表查询
*
* @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.findPlanPage(page, DeviceManager);
return Result.OK(pageList);
}
/**
* 分页列表查询
@ -63,8 +67,8 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@GetMapping(value = "/batchList")
public Result<IPage<DeviceBatch>> queryBatchPageList(DeviceBatch deviceBatch,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@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);
@ -72,54 +76,54 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
}
/**
* 获取批次号
* 获取批次号
*
* @param deviceBatch
* @return
*/
@GetMapping(value = "/getBatchNo")
public Result<Map<String,String>> getBatchNo(DeviceBatch deviceBatch) {
public Result<Map<String, String>> getBatchNo(DeviceBatch deviceBatch) {
String batchNo = service.getBatchNo(deviceBatch);
Map<String,String> map = new HashMap<>();
map.put("batchNo",batchNo);
Map<String, String> map = new HashMap<>();
map.put("batchNo", batchNo);
return Result.OK(map);
}
/**
* 添加
*
* @param deviceBatch
* @return
*/
@PostMapping(value = "/addBatch")
public Result<String> addBatch(@RequestBody DeviceBatch deviceBatch) {
service.saveBatch(deviceBatch);
return Result.OK("添加成功!");
}
/**
* 添加
*
* @param deviceBatch
* @return
*/
@PostMapping(value = "/addBatch")
public Result<String> addBatch(@RequestBody DeviceBatch deviceBatch) {
service.saveBatch(deviceBatch);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param deviceBatch
* @return
*/
@RequestMapping(value = "/editBatch", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> editBatch(@RequestBody DeviceBatch deviceBatch) {
service.updateBatch(deviceBatch);
return Result.OK("编辑成功!");
}
/**
* 编辑
*
* @param deviceBatch
* @return
*/
@RequestMapping(value = "/editBatch", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> editBatch(@RequestBody DeviceBatch deviceBatch) {
service.updateBatch(deviceBatch);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param deviceBatch
* @return
*/
@RequestMapping(value = "/deleteBatch", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> deleteBatch(@RequestBody DeviceBatch deviceBatch) {
service.removeBatch(deviceBatch);
return Result.OK("删除成功!");
}
/**
* 通过id删除
*
* @param deviceBatch
* @return
*/
@RequestMapping(value = "/deleteBatch", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> deleteBatch(@RequestBody DeviceBatch deviceBatch) {
service.removeBatch(deviceBatch);
return Result.OK("删除成功!");
}
/**
* 设备集成-机构设备清单分页列表查询
@ -132,8 +136,8 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@GetMapping(value = "/departPreview")
public Result<IPage<DevicePreview>> departPreview(DevicePreview devicePreview,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<DevicePreview> page = new Page<DevicePreview>(pageNo, pageSize);
IPage<DevicePreview> pageList = service.findDepartPreviewPlanPage(page, devicePreview);
@ -162,16 +166,16 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@GetMapping(value = "/nuPreview")
public Result<IPage<DevicePreview>> nuPreview(DevicePreview devicePreview,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<DevicePreview> page = new Page<DevicePreview>(pageNo, pageSize);
IPage<DevicePreview> pageList = service.findNuPreviewPlanPage(page, devicePreview);
return Result.OK(pageList);
}
/**
* 增加设备清单
* 增加设备清单
*
* @param devicePreview
* @return
@ -183,7 +187,7 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
}
/**
* 修改设备清单
* 修改设备清单
*
* @param devicePreview
* @return
@ -195,7 +199,45 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
}
/**
* 通过id删除
* 查询对应机构+批次 各护理单元已配置的设备数量
* @param batchNo
* @param orgCode
* @return
*/
@RequestMapping(value = "/queryQuantityByOrgCode", method = RequestMethod.GET)
public Result<List<DevicePreview>> queryQuantityByOrgCode(@RequestParam("batchNo") String batchNo, @RequestParam("orgCode") String orgCode) {
return Result.OK(service.queryQuantityByOrgCode(batchNo, orgCode));
}
@RequestMapping(value = "/batchSave", method = RequestMethod.POST)
public Result<String> batchSave(@RequestBody List<DevicePreview> list) {
list.forEach(item -> {
if (item.getId() == null) {
service.addPreviewPlan(item);
} else {
service.updatePreviewPlan(item);
}
});
return Result.OK("保存成功!");
}
/**
* 根据orgCode获取护理单元信息
*
* @param orgCode
* @return
*/
@GetMapping("/getNuListByOrgCode")
public Result<Map<String,Map<String, Object>>> getNuListByOrgCode(@RequestParam("orgCode") String orgCode) {
if(StringUtils.isBlank(orgCode)){
return Result.error("orgCode不能为空");
}
Map<String,Map<String, Object>> result = service.getNuListByOrgCode(orgCode);
return Result.ok(result);
}
/**
* 通过id删除
*
* @param devicePreview
* @return
@ -207,7 +249,7 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
}
/**
* 推送业务
* 推送业务
*
* @param devicePreview
* @return
@ -229,9 +271,9 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@GetMapping(value = "/cameraList")
public Result<IPage<DeviceIntegration>> cameraList(DeviceIntegration deviceIntegration,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<DeviceIntegration> page = new Page<DeviceIntegration>(pageNo, pageSize);
IPage<DeviceIntegration> pageList = service.findCameraPage(page, deviceIntegration);
return Result.OK(pageList);
@ -259,9 +301,9 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@GetMapping(value = "/networkList")
public Result<IPage<DeviceIntegration>> networkList(DeviceIntegration deviceIntegration,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<DeviceIntegration> page = new Page<DeviceIntegration>(pageNo, pageSize);
IPage<DeviceIntegration> pageList = service.findNetworkPage(page, deviceIntegration);
return Result.OK(pageList);
@ -290,9 +332,9 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@GetMapping(value = "/electricityList")
public Result<IPage<DeviceIntegration>> electricityList(DeviceIntegration deviceIntegration,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<DeviceIntegration> page = new Page<DeviceIntegration>(pageNo, pageSize);
IPage<DeviceIntegration> pageList = service.findElectricityPage(page, deviceIntegration);
return Result.OK(pageList);
@ -325,9 +367,9 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@GetMapping(value = "/waterList")
public Result<IPage<DeviceIntegration>> waterList(DeviceIntegration deviceIntegration,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<DeviceIntegration> page = new Page<DeviceIntegration>(pageNo, pageSize);
IPage<DeviceIntegration> pageList = service.findWaterPage(page, deviceIntegration);
return Result.OK(pageList);
@ -355,9 +397,9 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@GetMapping(value = "/humidList")
public Result<IPage<DeviceIntegration>> humidList(DeviceIntegration deviceIntegration,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<DeviceIntegration> page = new Page<DeviceIntegration>(pageNo, pageSize);
IPage<DeviceIntegration> pageList = service.findHumidPage(page, deviceIntegration);
return Result.OK(pageList);
@ -385,9 +427,9 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
*/
@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) {
@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);

View File

@ -0,0 +1,165 @@
package com.nu.modules.device.manager.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
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.ArrayList;
import java.util.List;
/**
* @Description: 护理单元
* @Author: jeecg-boot
* @Date: 2025-04-11
* @Version: V1.0
*/
@Data
public class DeviceNuBaseInfoEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "ID")
private String id;
/**
* openId
*/
@Excel(name = "openId", width = 15)
@ApiModelProperty(value = "openId")
private String openId;
/**
* 长者id nu_biz_elder_info.id
*/
@Excel(name = "长者id", width = 15)
@ApiModelProperty(value = "长者id")
private String elderId;
/**
* 护理单元名称
*/
@Excel(name = "护理单元名称", width = 15)
@ApiModelProperty(value = "护理单元名称")
private String nuName;
/**
* 护理单元编码
*/
@Excel(name = "护理单元编码", width = 15)
@ApiModelProperty(value = "护理单元编码")
private String nuId;
/**
* 区域标签ID
*/
@Excel(name = "区域标签ID", width = 15, dicCode = "nu_type")
@ApiModelProperty(value = "区域标签ID")
private String areaFlag;
/**
* 使用状态 0未使用 1占用 2入住 3退住 4留床
*/
@Excel(name = "使用状态 0未使用 1占用 2入住 3退住 4留床", width = 15, dicCode = "nu_status")
@Dict(dicCode = "nu_status")
@ApiModelProperty(value = "使用状态 0未使用 1占用 2入住 3退住 4留床")
private String status;
/**
* 客户
*/
// @Excel(name = "客户", width = 15)
// @ApiModelProperty(value = "客户")
// private java.lang.String customerId;
/**
* 是否删除 0未删除 1删除
*/
@Excel(name = "是否删除 0未删除 1删除", width = 15)
@ApiModelProperty(value = "是否删除 0未删除 1删除")
@TableLogic
private String delFlag;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**
* 创建日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**
* 所属部门
*/
@ApiModelProperty(value = "所属部门")
private String sysOrgCode;
/**
* 是否已同步0已同步 1未同步
*/
@ApiModelProperty(value = "是否已同步0已同步 1未同步")
private String izSync;
/**
* 是否绑定护理单元支付中 Y支付中有客户正在给护理单元充值 N没有人在绑定缴费可以让用户绑定
*/
private String izBindPaying;
@TableField(exist = false)
private String deviceId;//摄像头 ID
@TableField(exist = false)
private String deviceName;//摄像头名称
@TableField(exist = false)
private String deviceSn;//设备编号
@TableField(exist = false)
private String deviceStatus;//摄像头状态
@TableField(exist = false)
private String deviceMac;//摄像头状态
@TableField(exist = false)
private int streamType;
@TableField(exist = false)
private String deviceIndex;
@TableField(exist = false)
private String elderTableId;
@TableField(exist = false)
private String maintainStatus;//设备状态
@TableField(exist = false)
private String deviceType;//设备类型
@TableField(exist = false)
private String parentId;//上级id
@TableField(exist = false)
private List<DeviceNuBaseInfoEntity> children = new ArrayList<>();
// 构造方法
public DeviceNuBaseInfoEntity(String id, String nuName, String nuId, String parentId) {
this.id = id;
this.nuName = nuName;
this.nuId = nuId;
this.parentId = parentId;
}
// 添加子节点
public void addChild(DeviceNuBaseInfoEntity child) {
children.add(child);
}
}

View File

@ -11,44 +11,82 @@ import java.util.List;
/**
* @Description: 设备管理-机构信息
* @Author: jeecg-boot
* @Date: 2026-03-30
* @Date: 2026-03-30
* @Version: V1.0
*/
public interface DeviceManagerMapper extends BaseMapper<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);
void syncBatch(DevicePreview devicePreview);
List<DevicePreview> queryNuList(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);
int addPreviewPlan(DevicePreview devicePreview);
void updatePreviewPlan(DevicePreview devicePreview);
void deletePreviewPlanById(DevicePreview devicePreview);
void deletePreviewPlanByBatch(DeviceBatch deviceBatch);
DevicePreview getPreviewPlanQuantity(DevicePreview devicePreview);
void deletePreviewByBatch(DevicePreview devicePreview);
int addPreview(DevicePreview devicePreview);
List<DevicePreview> getPreviewList(DevicePreview devicePreview);
// DevicePreview getPreview(DevicePreview devicePreview);
void syncPreview(String id);
void editPreviewStatusBySn(DeviceIntegration deviceIntegration);
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);
void addDeviceReleaseLog(String orgCode,String nuId);
void releaseNu(String orgCode,String nuId);
void addDeviceReleaseLog(String orgCode, String nuId);
void releaseNu(String orgCode, String nuId);
List<DevicePreview> queryQuantityByOrgCode(@Param("batchNo") String batchNo, @Param("orgCode") String orgCode);
List<DeviceNuBaseInfoEntity> selectWlsbList();
List<DeviceNuBaseInfoEntity> selectJcgnList();
List<DeviceNuBaseInfoEntity> selectAllNu();
}

View File

@ -2,13 +2,14 @@
<!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="findPlanPage" 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,
b.org_leader,
b.audit_status,
b.audit_time
a.org_code,
a.depart_name,
b.org_leader,
b.audit_status,
b.audit_time
from sys_depart a
inner join nu_org_info b on a.id = b.id
inner join nu_work_order c on c.org_id = a.id and c.status = '3'
@ -23,15 +24,16 @@
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 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
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}
@ -44,128 +46,133 @@
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 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},
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
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
from nu_iot_device_preview_plan
where batch_no = #{batchNo}
</delete>
<update id="syncBatch">
update nu_iot_device_preview_batch
set iz_push = 'Y',
set iz_push = 'Y',
push_time = now()
where batch_no = #{batchNo}
</update>
<select id="queryNuList" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
select nu_id,nu_name
<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
where status != '5'
and sys_org_code = #{orgCode}
order by nu_id asc
</select>
<select id="findDepartPreviewPlanPage" 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(a.purchase_quantity) as purchaseQuantity
a.org_code,
b.depart_name,
a.batch_no,
a.device_name,
a.device_type,
a.device_model,
a.factory,
a.dimension,
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} 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>
<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_name,a.device_type,a.device_model,a.factory,a.dimension
order by a.device_type asc
</select>
<select id="findNuPreviewPlanPage" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
<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,
a.purchase_quantity
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,
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} and a.batch_no = #{params.batchNo}
<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.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.nu_id,a.device_type asc
</select>
<select id="getPreviewPlanList" 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,
purchase_quantity,
create_time,
create_by,
update_time,
update_by
batch_no,
org_code,
nu_id,
dimension,
device_name,
device_type,
device_model,
factory,
purchase_quantity,
create_time,
create_by,
update_time,
update_by
from nu_iot_device_preview_plan
<where> org_code = #{orgCode} and batch_no = #{batchNo}
<where>org_code = #{orgCode} and batch_no = #{batchNo}
<if test="dimension != null and dimension != ''">
AND dimension = #{dimension}
</if>
@ -187,107 +194,112 @@
</where>
</select>
<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},
#{batchNo},
#{deviceName},
#{deviceType},
#{deviceModel},
#{factory},
#{dimension},
now(),
#{createBy},
#{purchaseQuantity}
)
<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},
#{batchNo},
#{deviceName},
#{deviceType},
#{deviceModel},
#{factory},
#{dimension},
now(),
#{createBy},
#{purchaseQuantity})
</insert>
<update id="updatePreviewPlan">
update nu_iot_device_preview_plan
set nu_id = #{nuId},
purchase_quantity = #{purchaseQuantity},
update_time = now()
set
<if test="nuId !=null and nuId != ''">
nu_id = #{nuId},
</if>
purchase_quantity = #{purchaseQuantity},
update_time = now()
where id = #{id}
</update>
<delete id="deletePreviewPlanById">
delete from nu_iot_device_preview_plan where id = #{id}
delete
from nu_iot_device_preview_plan
where id = #{id}
</delete>
<delete id="deletePreviewPlanByBatch">
delete from nu_iot_device_preview_plan where batch_no = #{batchNo}
delete
from nu_iot_device_preview_plan
where batch_no = #{batchNo}
</delete>
<select id="getPreviewPlanQuantity" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
<select id="getPreviewPlanQuantity" parameterType="com.nu.modules.device.manager.entity.DevicePreview"
resultType="com.nu.modules.device.manager.entity.DevicePreview">
select sum(purchase_quantity) as purchaseQuantity
from nu_iot_device_preview_plan
where batch_no = #{batchNo}
</select>
<delete id="deletePreviewByBatch">
delete from nu_iot_device_preview where batch_no = #{batchNo}
delete
from nu_iot_device_preview
where batch_no = #{batchNo}
</delete>
<insert id="addPreview" parameterType="com.nu.modules.device.manager.entity.DevicePreview" useGeneratedKeys="true" keyProperty="id">
insert into nu_iot_device_preview(
org_code,
nu_id,
batch_no,
device_name,
device_type,
device_model,
factory,
dimension,
create_time,
create_by
)
values(
#{orgCode},
#{nuId},
#{batchNo},
#{deviceName},
#{deviceType},
#{deviceModel},
#{factory},
#{dimension},
now(),
#{createBy}
)
<insert id="addPreview" parameterType="com.nu.modules.device.manager.entity.DevicePreview" useGeneratedKeys="true"
keyProperty="id">
insert into nu_iot_device_preview(org_code,
nu_id,
batch_no,
device_name,
device_type,
device_model,
factory,
dimension,
create_time,
create_by)
values (#{orgCode},
#{nuId},
#{batchNo},
#{deviceName},
#{deviceType},
#{deviceModel},
#{factory},
#{dimension},
now(),
#{createBy})
</insert>
<select id="getPreviewList" parameterType="com.nu.modules.device.manager.entity.DevicePreview" resultType="com.nu.modules.device.manager.entity.DevicePreview">
<select id="getPreviewList" parameterType="com.nu.modules.device.manager.entity.DevicePreview"
resultType="com.nu.modules.device.manager.entity.DevicePreview">
select id,
org_code,
nu_id,
batch_no,
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
org_code,
nu_id,
batch_no,
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
from nu_iot_device_preview
<where>
<if test="orgCode != null and orgCode != ''">
@ -367,7 +379,7 @@
<update id="syncPreview">
update nu_iot_device_preview
set iz_sync = 'Y',
set iz_sync = 'Y',
sync_time = now()
where id = #{id}
</update>
@ -379,7 +391,9 @@
</update>
<delete id="deletePreviewById">
delete from nu_iot_device_preview where id = #{id}
delete
from nu_iot_device_preview
where id = #{id}
</delete>
<update id="editPreviewSn">
@ -390,140 +404,150 @@
<update id="bindPreview">
update nu_iot_device_preview
set nu_id = #{nuId},
set nu_id = #{nuId},
device_status = #{deviceStatus},
update_time = now()
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.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case when b.id is null then '待集成'
else (case ifnull(b.device_status,'') when '0' then '离线' when '1' then '在线' else '-' end)
end
) as device_status,
a.device_status as maintainStatus,
b.device_index
<select id="findCameraPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration"
resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select a.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case
when b.id is null then '待集成'
else (case ifnull(b.device_status, '') when '0' then '离线' when '1' then '在线' else '-' end)
end
) as device_status,
a.device_status as maintainStatus,
b.device_index
from nu_iot_device_preview a
left join nu_iot_tplink_camera b on a.sn = b.mac
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')
AND a.device_type in ('SURVEILLANCECAMERA', 'NETWORKVIDEORECORDER')
order by a.id
</select>
<select id="findNetworkPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration" resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select
a.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case when b.id is null then '待集成'
else (case ifnull(b.device_status,'') when '0' then '离线' when '1' then '在线' else '-' end)
end
) as device_status,
a.device_status as maintainStatus
<select id="findNetworkPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration"
resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select a.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case
when b.id is null then '待集成'
else (case ifnull(b.device_status, '') when '0' then '离线' when '1' then '在线' else '-' end)
end
) as device_status,
a.device_status as maintainStatus
from nu_iot_device_preview a
left join nu_iot_tplink_camera b on a.sn = b.mac
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')
AND a.device_type in ('SWITCH', 'ROUTER', 'AP')
order by a.id
</select>
<select id="findElectricityPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration" resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select
a.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case when b.id is null then '待集成'
else
(case when b.sim is null then '待集成'
else (case ifnull(b.relay_state,'') when '0' then '拉闸' when '1' then '合闸' else '-' end) end)
end
) as device_status,
a.device_status as maintainStatus
<select id="findElectricityPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration"
resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select a.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case
when b.id is null then '待集成'
else
(case
when b.sim is null then '待集成'
else (case ifnull(b.relay_state, '')
when '0' then '拉闸'
when '1' then '合闸'
else '-' end) end)
end
) as device_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
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.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case when b.id is null then '待集成'
else (case ifnull(b.relay_state,'') when '0' then '关阀' when '1' then '开阀' else '-' end)
end
) as device_status,
a.device_status as maintainStatus
<select id="findWaterPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration"
resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select a.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case
when b.id is null then '待集成'
else (case ifnull(b.relay_state, '') when '0' then '关阀' when '1' then '开阀' else '-' end)
end
) as device_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
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.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case when b.id is null then '待集成'
else (case ifnull(b.status,'') when '0' then '在线' when '1' then '离线' else '-' end)
end
) as device_status,
a.device_status as maintainStatus
<select id="findHumidPage" parameterType="com.nu.modules.device.manager.entity.DeviceIntegration"
resultType="com.nu.modules.device.manager.entity.DeviceIntegration">
select a.org_code,
a.dimension,
a.sn,
a.device_name,
a.device_type,
a.device_model,
a.factory,
(
case
when b.id is null then '待集成'
else (case ifnull(b.status, '') when '0' then '在线' when '1' then '离线' else '-' end)
end
) as device_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
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>
<select id="findBingLogPage" parameterType="com.nu.modules.device.manager.entity.DeviceBindLog" resultType="com.nu.modules.device.manager.entity.DeviceBindLog">
<select id="findBingLogPage" parameterType="com.nu.modules.device.manager.entity.DeviceBindLog"
resultType="com.nu.modules.device.manager.entity.DeviceBindLog">
select
id,
org_code,
nu_id,
nu_name,
dimension,
device_name,
device_type,
device_model,
sn,
factory,
opt_date,
opt_type,
remarks
id,
org_code,
nu_id,
nu_name,
dimension,
device_name,
device_type,
device_model,
sn,
factory,
opt_date,
opt_type,
remarks
from nu_iot_device_bind_log
where org_code = #{params.orgCode}
<if test="params.dimension != null and params.dimension != ''">
@ -538,71 +562,92 @@
order by org_code asc ,factory asc ,device_type asc ,device_model asc ,sn asc,opt_date desc
</select>
<select id="queryQuantityByOrgCode" resultType="com.nu.modules.device.manager.entity.DevicePreview">
select *
from nu_iot_device_preview_plan
<where>
<if test="batchNo != null and batchNo != ''">
and batch_no = #{batchNo}
</if>
<if test="orgCode != null and orgCode != ''">
and org_code = #{orgCode}
</if>
</where>
</select>
<select id="selectWlsbList" resultType="com.nu.modules.device.manager.entity.DeviceNuBaseInfoEntity">
select nu_id as device_sn,device_name, device_type,nu_id,device_status as maintain_status from nu_iot_device_preview
where nu_id is not null and device_status is not null and device_status != '损坏'
</select>
<select id="selectJcgnList" resultType="com.nu.modules.device.manager.entity.DeviceNuBaseInfoEntity">
SELECT a.permission_id as id,b.name as nu_name,a.role_id as nu_id,b.parent_id from nu_app_nuid_permission a
inner join nu_app_permission b on a.permission_id = b.id
</select>
<select id="selectAllNu" resultType="com.nu.modules.device.manager.entity.DeviceNuBaseInfoEntity">
select * from nu_base_info where del_flag = '0'
</select>
<insert id="addBindPreview">
insert into nu_iot_device_bind_log(
org_code,
nu_id,
nu_name,
dimension,
device_name,
device_type,
device_model,
sn,
factory,
opt_date,
opt_type,
remarks
)values(
#{orgCode},
#{nuId},
#{nuName},
#{dimension},
#{deviceName},
#{deviceType},
#{deviceModel},
#{sn},
#{factory},
now(),
#{optType},
#{remarks}
)
insert into nu_iot_device_bind_log(org_code,
nu_id,
nu_name,
dimension,
device_name,
device_type,
device_model,
sn,
factory,
opt_date,
opt_type,
remarks)
values (#{orgCode},
#{nuId},
#{nuName},
#{dimension},
#{deviceName},
#{deviceType},
#{deviceModel},
#{sn},
#{factory},
now(),
#{optType},
#{remarks})
</insert>
<insert id="addDeviceReleaseLog">
insert into nu_iot_device_bind_log(
org_code,
sn,
dimension,
device_name,
device_type,
device_model,
factory,
opt_date,
opt_type,
remarks
)
select
#{orgCode},
sn,
dimension,
device_name,
device_type,
device_model,
factory,
now(),
'释放',
'区域停用'
insert into nu_iot_device_bind_log(org_code,
sn,
dimension,
device_name,
device_type,
device_model,
factory,
opt_date,
opt_type,
remarks)
select #{orgCode},
sn,
dimension,
device_name,
device_type,
device_model,
factory,
now(),
'释放',
'区域停用'
from nu_iot_device_preview a
where a.org_code = #{orgCode}
and a.nu_id = #{nuId}
and ifnull(a.device_status,'') != '损坏'
and ifnull(a.device_status, '') != '损坏'
</insert>
<update id="releaseNu">
update nu_iot_device_preview
set nu_id = null
where org_code = #{orgCode}
and nu_id = #{nuId}
and nu_id = #{nuId}
</update>
</mapper>

View File

@ -7,6 +7,7 @@ import com.nu.modules.device.manager.entity.*;
import org.jeecg.common.api.vo.Result;
import java.util.List;
import java.util.Map;
/**
* @Description: 设备管理-机构信息
@ -48,4 +49,7 @@ public interface IDeviceManagerService extends IService<DeviceManager> {
void addBindPreview(DeviceBindLog deviceBindLog);
void releaseNu(String orgCode,String nuId);
List<DevicePreview> queryQuantityByOrgCode(String batchNo, String orgCode);
Map<String,Map<String, Object>> getNuListByOrgCode(String orgCode);
}

View File

@ -3,6 +3,8 @@ 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.dynamic.datasource.annotation.DS;
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;
@ -40,14 +42,13 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: 设备管理-机构信息
* @Author: jeecg-boot
* @Date: 2026-03-30
* @Date: 2026-03-30
* @Version: V1.0
*/
@Service
@ -78,15 +79,15 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
IHumidDeviceService humidDeviceService;
@Override
public IPage<DeviceManager> findPlanPage(Page<DeviceManager> page, DeviceManager deviceManager){
return baseMapper.findPlanPage(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);
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++){
for (int i = 0; i < list.size(); i++) {
DeviceBatch entity = list.get(i);
DevicePreview dp = new DevicePreview();
dp.setOrgCode(entity.getOrgCode());
@ -98,13 +99,13 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public String getBatchNo(DeviceBatch deviceBatch){
public String getBatchNo(DeviceBatch deviceBatch) {
// 机构编码 + 年月日时分秒
return deviceBatch.getOrgCode() + DateUtil.format(new Date(),"yyMMddHHmmss");
return deviceBatch.getOrgCode() + DateUtil.format(new Date(), "yyMMddHHmmss");
}
@Override
public void saveBatch(DeviceBatch deviceBatch){
public void saveBatch(DeviceBatch deviceBatch) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
deviceBatch.setCreateBy(sysUser.getRealname());
@ -113,7 +114,7 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public void updateBatch(DeviceBatch deviceBatch){
public void updateBatch(DeviceBatch deviceBatch) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
deviceBatch.setUpdateBy(sysUser.getRealname());
@ -122,28 +123,28 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public void removeBatch(DeviceBatch deviceBatch){
public void removeBatch(DeviceBatch deviceBatch) {
baseMapper.deletePreviewPlanByBatch(deviceBatch);
baseMapper.removeBatch(deviceBatch);
}
@Override
public List<DevicePreview> queryNuList(DevicePreview devicePreview){
public List<DevicePreview> queryNuList(DevicePreview devicePreview) {
return baseMapper.queryNuList(devicePreview);
}
@Override
public IPage<DevicePreview> findDepartPreviewPlanPage(Page<DevicePreview> page, DevicePreview devicePreview){
return baseMapper.findDepartPreviewPlanPage(page,devicePreview);
public IPage<DevicePreview> findDepartPreviewPlanPage(Page<DevicePreview> page, DevicePreview devicePreview) {
return baseMapper.findDepartPreviewPlanPage(page, devicePreview);
}
@Override
public IPage<DevicePreview> findNuPreviewPlanPage(Page<DevicePreview> page, DevicePreview devicePreview){
return baseMapper.findNuPreviewPlanPage(page,devicePreview);
public IPage<DevicePreview> findNuPreviewPlanPage(Page<DevicePreview> page, DevicePreview devicePreview) {
return baseMapper.findNuPreviewPlanPage(page, devicePreview);
}
@Override
public void addPreviewPlan(DevicePreview devicePreview){
public void addPreviewPlan(DevicePreview devicePreview) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
devicePreview.setCreateBy(sysUser.getRealname());
@ -152,7 +153,7 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public void updatePreviewPlan(DevicePreview devicePreview){
public void updatePreviewPlan(DevicePreview devicePreview) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
devicePreview.setUpdateBy(sysUser.getRealname());
@ -161,22 +162,22 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public void deletePreviewPlan(DevicePreview devicePreview){
public void deletePreviewPlan(DevicePreview devicePreview) {
baseMapper.deletePreviewPlanById(devicePreview);
}
@Override
public void sendBatch(DevicePreview devicePreview){
public void sendBatch(DevicePreview devicePreview) {
DevicePreview qdp = baseMapper.getPreviewPlanQuantity(devicePreview);
List<DevicePreview> list = baseMapper.getPreviewList(devicePreview);
if(qdp.getPurchaseQuantity()!=list.size()){
if (qdp.getPurchaseQuantity() != list.size()) {
List<DevicePreview> planList = baseMapper.getPreviewPlanList(devicePreview);
if(planList.size()>0){
if (planList.size() > 0) {
baseMapper.deletePreviewByBatch(devicePreview);
for(int i=0;i<planList.size();i++){
for (int i = 0; i < planList.size(); i++) {
DevicePreview entity = planList.get(i);
int quantity = entity.getPurchaseQuantity();
for(int j=0;j<quantity;j++){
for (int j = 0; j < quantity; j++) {
entity.setNuId(null);
baseMapper.addPreview(entity);
}
@ -186,11 +187,11 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
List<DevicePreviewMqDto> iotList = new ArrayList<>();
list = baseMapper.getPreviewList(devicePreview);
for(int i=0;i<list.size();i++){
for (int i = 0; i < list.size(); i++) {
DevicePreview entity = list.get(i);
DevicePreviewMqDto previewDto = new DevicePreviewMqDto();
BeanUtils.copyProperties(entity,previewDto);
String resId = addLog(entity.getOrgCode(),"", JSON.toJSONString(entity),"推送清单",entity.getDeviceType());
BeanUtils.copyProperties(entity, previewDto);
String resId = addLog(entity.getOrgCode(), "", JSON.toJSONString(entity), "推送清单", entity.getDeviceType());
previewDto.setLogId(resId);
previewDto.setYwId(previewDto.getId());
iotList.add(previewDto);
@ -202,58 +203,59 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public void syncPreview(String id){
public void syncPreview(String id) {
baseMapper.syncPreview(id);
}
@Override
public void syncPreviewPlan(String batchNo){
public void syncPreviewPlan(String batchNo) {
DevicePreview devicePreview = new DevicePreview();
devicePreview.setBatchNo(batchNo);
devicePreview.setIzSync("Y");
DevicePreview qdp = baseMapper.getPreviewPlanQuantity(devicePreview);
List<DevicePreview> list = baseMapper.getPreviewList(devicePreview);
if(qdp.getPurchaseQuantity()==list.size()){
if (qdp.getPurchaseQuantity() == list.size()) {
baseMapper.syncBatch(devicePreview);
}
}
@Override
public void deletePreviewById(String id){
public void deletePreviewById(String id) {
baseMapper.deletePreviewById(id);
}
@Override
public void editPreviewSn(DevicePreview devicePreview){
public void editPreviewSn(DevicePreview devicePreview) {
baseMapper.editPreviewSn(devicePreview);
}
@Override
public void bindPreview(DevicePreview devicePreview){
public void bindPreview(DevicePreview devicePreview) {
baseMapper.bindPreview(devicePreview);
}
@Override
public IPage<DeviceIntegration> findCameraPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration){
return baseMapper.findCameraPage(page,deviceIntegration);
public IPage<DeviceIntegration> findCameraPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration) {
return baseMapper.findCameraPage(page, deviceIntegration);
}
/**
* 拉取监控设备
*
* @param deviceIntegration
*/
@Override
public Result<String> pullCamera(DeviceIntegration deviceIntegration){
public Result<String> pullCamera(DeviceIntegration deviceIntegration) {
String mac = formatMacAddress(deviceIntegration.getSn());
CameraInfo cameraInfo = new CameraInfo();
cameraInfo.setMac(mac);
cameraInfo.setDeviceType(deviceIntegration.getDeviceType());
Result<String> res = cameraInfoService.syncAllDevices(cameraInfo);
if(!res.isSuccess()){
if (!res.isSuccess()) {
return res;
}
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(),deviceIntegration.getSn());
if(!res.isSuccess()){
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(), deviceIntegration.getSn());
if (!res.isSuccess()) {
return res;
}
deviceIntegration.setDeviceStatus("正常");
@ -262,25 +264,26 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public IPage<DeviceIntegration> findNetworkPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration){
return baseMapper.findNetworkPage(page,deviceIntegration);
public IPage<DeviceIntegration> findNetworkPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration) {
return baseMapper.findNetworkPage(page, deviceIntegration);
}
@Override
public IPage<DeviceIntegration> findElectricityPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration){
return baseMapper.findElectricityPage(page,deviceIntegration);
public IPage<DeviceIntegration> findElectricityPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration) {
return baseMapper.findElectricityPage(page, deviceIntegration);
}
/**
* 拉取电表
*
* @param deviceIntegration
*/
@Override
public Result<String> pullElectricity(DeviceIntegration deviceIntegration){
public Result<String> pullElectricity(DeviceIntegration deviceIntegration) {
DsElectricityMeter dsElectricityMeter = new DsElectricityMeter();
dsElectricityMeter.setSn(deviceIntegration.getSn());
Result<String> res = electricityMeterService.add(dsElectricityMeter);
if(!res.isSuccess()){
if (!res.isSuccess()) {
return res;
}
//获取设备sim
@ -296,34 +299,36 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
/**
* 拉取电表
*
* @param deviceIntegration
*/
@Override
public Result<String> deleteElectricity(DeviceIntegration deviceIntegration){
public Result<String> deleteElectricity(DeviceIntegration deviceIntegration) {
DsElectricityMeter dsElectricityMeter = new DsElectricityMeter();
dsElectricityMeter.setSn(deviceIntegration.getSn());
Result<String> res = electricityMeterService.delete(dsElectricityMeter);
if(!res.isSuccess()){
if (!res.isSuccess()) {
return res;
}
return Result.OK("拉取电表成功!");
}
@Override
public IPage<DeviceIntegration> findWaterPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration){
return baseMapper.findWaterPage(page,deviceIntegration);
public IPage<DeviceIntegration> findWaterPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration) {
return baseMapper.findWaterPage(page, deviceIntegration);
}
/**
* 拉取水表
*
* @param deviceIntegration
*/
@Override
public Result<String> pullWater(DeviceIntegration deviceIntegration){
public Result<String> pullWater(DeviceIntegration deviceIntegration) {
TqDeviceInfo tqDeviceInfo = new TqDeviceInfo();
tqDeviceInfo.setCid(deviceIntegration.getSn());
String errorMsg = tqDeviceInfoService.addCollector(tqDeviceInfo);
if(!errorMsg.equals("")){
if (!errorMsg.equals("")) {
tqDeviceInfoService.deleteCollector(tqDeviceInfo);
return Result.error(errorMsg);
}
@ -331,7 +336,7 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
waterMeter.setCid(deviceIntegration.getSn());
waterMeter.setAddress(deviceIntegration.getSn());
errorMsg = waterMeterService.addWater(waterMeter);
if(!errorMsg.equals("")){
if (!errorMsg.equals("")) {
waterMeterService.deleteWater(waterMeter);
return Result.error(errorMsg);
}
@ -340,14 +345,14 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
// 2或在异步中判断opr_id进行推送
// waterMeter.setOprId("集成");
Result<String> res = waterMeterService.waterRead(waterMeter);
if(!res.isSuccess()){
if (!res.isSuccess()) {
tqDeviceInfoService.deleteCollector(tqDeviceInfo);
waterMeterService.deleteWater(waterMeter);
return res;
}
tqDeviceInfoService.getAllMeter(true);
tqDeviceInfoService.getAllCollector(true);
syncBizService.syncDevice(deviceIntegration.getOrgCode(),deviceIntegration.getSn());
syncBizService.syncDevice(deviceIntegration.getOrgCode(), deviceIntegration.getSn());
deviceIntegration.setDeviceStatus("正常");
baseMapper.editPreviewStatusBySn(deviceIntegration);
return Result.OK("拉取水表成功!");
@ -355,26 +360,27 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public IPage<DeviceIntegration> findHumidPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration){
return baseMapper.findHumidPage(page,deviceIntegration);
public IPage<DeviceIntegration> findHumidPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration) {
return baseMapper.findHumidPage(page, deviceIntegration);
}
/**
* 拉取温湿度计
*
* @param deviceIntegration
*/
@Override
public Result<String> pullHumid(DeviceIntegration deviceIntegration){
public Result<String> pullHumid(DeviceIntegration deviceIntegration) {
HumidDevice humidDevice = new HumidDevice();
humidDevice.setSn(deviceIntegration.getSn());
humidDevice.setDeviceName(deviceIntegration.getDeviceName());
humidDevice.setTimeCode("01");
Result<String> res = humidDeviceService.insertDevice(humidDevice);
if(!res.isSuccess()){
if (!res.isSuccess()) {
return res;
}
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(),deviceIntegration.getSn());
if(!res.isSuccess()){
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(), deviceIntegration.getSn());
if (!res.isSuccess()) {
return res;
}
deviceIntegration.setDeviceStatus("正常");
@ -383,16 +389,16 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, DeviceBindLog deviceBindLog){
return baseMapper.findBingLogPage(page,deviceBindLog);
public IPage<DeviceBindLog> findBingLogPage(Page<DeviceBindLog> page, DeviceBindLog deviceBindLog) {
return baseMapper.findBingLogPage(page, deviceBindLog);
}
@Override
public void addBindPreview(DeviceBindLog deviceBindLog){
public void addBindPreview(DeviceBindLog deviceBindLog) {
baseMapper.addBindPreview(deviceBindLog);
}
public String addLog(String orgCode,String orgName,String json,String type,String iotType){
public String addLog(String orgCode, String orgName, String json, String type, String iotType) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String logId = UuidUtils.getUUID();
@ -412,9 +418,14 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
}
@Override
public void releaseNu(String orgCode,String nuId){
baseMapper.addDeviceReleaseLog(orgCode,nuId);// 记录设备释放日志
baseMapper.releaseNu(orgCode,nuId);// 更新湿度计
public void releaseNu(String orgCode, String nuId) {
baseMapper.addDeviceReleaseLog(orgCode, nuId);// 记录设备释放日志
baseMapper.releaseNu(orgCode, nuId);// 更新湿度计
}
@Override
public List<DevicePreview> queryQuantityByOrgCode(String batchNo, String orgCode) {
return baseMapper.queryQuantityByOrgCode(batchNo, orgCode);
}
public String formatMacAddress(String mac) {
@ -428,4 +439,130 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
// 使用正则表达式每2个字符插入一个"-"
return mac.toUpperCase().replaceAll("(.{2})(?!$)", "$1-");
}
@Override
@DS("#orgCode")
public Map<String, Map<String, Object>> getNuListByOrgCode(String orgCode) {
//护理单元
List<DeviceNuBaseInfoEntity> list = baseMapper.selectAllNu();
Map<String, Map<String, Object>> result = new HashMap<>();
//设备信息
List<DeviceNuBaseInfoEntity> wlsbList = baseMapper.selectWlsbList();
//基础功能
List<DeviceNuBaseInfoEntity> jcgnList = baseMapper.selectJcgnList();
List<DeviceNuBaseInfoEntity> mergedTrees = buildTree(jcgnList);
for (DeviceNuBaseInfoEntity info : list) {
String sxtStr = "";//摄像头集合
String dbStr = "";//电表集合
String sbStr = "";//水表集合
String wsdjStr = "";//温湿度计集合
List<DeviceNuBaseInfoEntity> children = new ArrayList<>();
if (wlsbList == null) {
continue;
}
for (DeviceNuBaseInfoEntity wlsb : wlsbList) {
if (info.getNuId().equals(wlsb.getNuId())) {
if ("SURVEILLANCECAMERA".equals(wlsb.getDeviceType())) {
sxtStr = sxtStr + wlsb.getNuId() + ",";
} else if ("db".equals(wlsb.getDeviceType())) {
dbStr = dbStr + wlsb.getNuId() + ",";
} else if ("sb".equals(wlsb.getDeviceType())) {
sbStr = sbStr + wlsb.getNuId() + ",";
} else if ("wsdj".equals(wlsb.getDeviceType())) {
wsdjStr = wsdjStr + wlsb.getNuId() + ",";
}
}
}
if (sxtStr.length() > 0) sxtStr = sxtStr.split(",").length + "";
if (dbStr.length() > 0) dbStr = dbStr.split(",").length + "";
if (sbStr.length() > 0) sbStr = sbStr.split(",").length + "";
if (wsdjStr.length() > 0) wsdjStr = wsdjStr.split(",").length + "";
for (DeviceNuBaseInfoEntity mergedTree : mergedTrees) {
if (info.getNuId().equals(mergedTree.getNuId())) {
children.add(mergedTree);
}
}
Map<String, Object> map = Map.of(
"nuId", info.getNuId(),
"nuName", info.getNuName(),
"status", info.getStatus(),
"sxtList", sxtStr,
"dbList", dbStr,
"sbList", sbStr,
"wsdjList", wsdjStr,
"children", children
);
result.put(info.getNuId(),map);
}
return result;
}
/**
* 构建分类树
*
* @param nodes 原始节点列表
* @return 根节点列表
*/
public List<DeviceNuBaseInfoEntity> buildTree(List<DeviceNuBaseInfoEntity> nodes) {
// nuId 分组
Map<String, List<DeviceNuBaseInfoEntity>> groupByNuId = nodes.stream()
.collect(Collectors.groupingBy(DeviceNuBaseInfoEntity::getNuId));
List<DeviceNuBaseInfoEntity> allRootNodes = new ArrayList<>();
// 对每个 nuId 分组单独构建树
for (Map.Entry<String, List<DeviceNuBaseInfoEntity>> entry : groupByNuId.entrySet()) {
String nuId = entry.getKey();
List<DeviceNuBaseInfoEntity> sameNuIdNodes = entry.getValue();
List<DeviceNuBaseInfoEntity> rootNodes = buildSingleTree(sameNuIdNodes, nuId);
allRootNodes.addAll(rootNodes);
}
return allRootNodes;
}
/**
* 构建单个 nuId 的分类树
*/
private List<DeviceNuBaseInfoEntity> buildSingleTree(List<DeviceNuBaseInfoEntity> nodes, String nuId) {
List<DeviceNuBaseInfoEntity> rootNodes = new ArrayList<>();
Map<String, DeviceNuBaseInfoEntity> nodeMap = new HashMap<>();
// 第一步将所有节点存入map
for (DeviceNuBaseInfoEntity node : nodes) {
nodeMap.put(node.getId(), node);
}
// 第二步建立父子关系
for (DeviceNuBaseInfoEntity node : nodes) {
String parentId = node.getParentId();
if (parentId == null || parentId.isEmpty() || parentId.equals("0")) {
// 根节点
rootNodes.add(node);
} else {
// 查找父节点
DeviceNuBaseInfoEntity parent = nodeMap.get(parentId);
if (parent != null) {
// 父节点存在添加到父节点的children
if (parent.getChildren() == null) {
parent.setChildren(new ArrayList<>());
}
parent.getChildren().add(node);
} else {
// 父节点不存在作为根节点处理
rootNodes.add(node);
}
}
}
return rootNodes;
}
}