From bd13a5aaa85ff95c524848846651fd1321b7515a Mon Sep 17 00:00:00 2001 From: "1378012178@qq.com" <1378012178@qq.com> Date: Fri, 24 Apr 2026 10:11:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86-=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=B8=85=E5=8D=95-=E6=89=B9=E6=AC=A1=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=B8=85=E5=8D=95-=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E7=BB=B4=E5=BA=A6=E5=8A=9F=E8=83=BD=E8=B0=83?= =?UTF-8?q?=E6=95=B4=EF=BC=9A=E5=B1=95=E7=A4=BA=E6=9C=BA=E6=9E=84+?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E4=B8=8B=E6=89=80=E6=9C=89=E6=8A=A4=E7=90=86?= =?UTF-8?q?=E5=8D=95=E5=85=83=E7=9A=84=E6=8A=A4=E7=90=86=E5=8D=95=E5=85=83?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E3=80=81=E5=B7=B2=E9=85=8D=E7=BD=AE=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E6=9C=8D=E5=8A=A1=E3=80=81=E8=AE=BE=E5=A4=87=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DeviceManagerController.java | 222 +++--- .../entity/DeviceNuBaseInfoEntity.java | 165 +++++ .../manager/mapper/DeviceManagerMapper.java | 44 +- .../mapper/xml/DeviceManagerMapper.xml | 693 ++++++++++-------- .../service/IDeviceManagerService.java | 4 + .../impl/DeviceManagerServiceImpl.java | 277 +++++-- 6 files changed, 918 insertions(+), 487 deletions(-) create mode 100644 nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/entity/DeviceNuBaseInfoEntity.java diff --git a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/controller/DeviceManagerController.java b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/controller/DeviceManagerController.java index ebe7801..ec6b88e 100644 --- a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/controller/DeviceManagerController.java +++ b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/controller/DeviceManagerController.java @@ -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 { - @Autowired - private IDeviceManagerService service; - - /** - * 分页列表查询 - * - * @param DeviceManager - * @param pageNo - * @param pageSize - * @param req - * @return - */ - @GetMapping(value = "/list") - public Result> queryPageList(DeviceManager DeviceManager, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - Page page = new Page(pageNo, pageSize); - IPage pageList = service.findPlanPage(page, DeviceManager); - return Result.OK(pageList); - } + @Autowired + private IDeviceManagerService service; + + /** + * 分页列表查询 + * + * @param DeviceManager + * @param pageNo + * @param pageSize + * @param req + * @return + */ + @GetMapping(value = "/list") + public Result> queryPageList(DeviceManager DeviceManager, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + Page page = new Page(pageNo, pageSize); + IPage pageList = service.findPlanPage(page, DeviceManager); + return Result.OK(pageList); + } /** * 分页列表查询 @@ -63,8 +67,8 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findBatchPage(page, deviceBatch); @@ -72,54 +76,54 @@ public class DeviceManagerController extends JeecgController> getBatchNo(DeviceBatch deviceBatch) { + public Result> getBatchNo(DeviceBatch deviceBatch) { String batchNo = service.getBatchNo(deviceBatch); - Map map = new HashMap<>(); - map.put("batchNo",batchNo); + Map map = new HashMap<>(); + map.put("batchNo", batchNo); return Result.OK(map); } - /** - * 添加 - * - * @param deviceBatch - * @return - */ - @PostMapping(value = "/addBatch") - public Result addBatch(@RequestBody DeviceBatch deviceBatch) { - service.saveBatch(deviceBatch); - return Result.OK("添加成功!"); - } - - /** - * 编辑 - * - * @param deviceBatch - * @return - */ - @RequestMapping(value = "/editBatch", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result editBatch(@RequestBody DeviceBatch deviceBatch) { - service.updateBatch(deviceBatch); - return Result.OK("编辑成功!"); - } - - /** - * 通过id删除 - * - * @param deviceBatch - * @return - */ - @RequestMapping(value = "/deleteBatch", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result deleteBatch(@RequestBody DeviceBatch deviceBatch) { - service.removeBatch(deviceBatch); - return Result.OK("删除成功!"); - } + /** + * 添加 + * + * @param deviceBatch + * @return + */ + @PostMapping(value = "/addBatch") + public Result addBatch(@RequestBody DeviceBatch deviceBatch) { + service.saveBatch(deviceBatch); + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param deviceBatch + * @return + */ + @RequestMapping(value = "/editBatch", method = {RequestMethod.PUT, RequestMethod.POST}) + public Result editBatch(@RequestBody DeviceBatch deviceBatch) { + service.updateBatch(deviceBatch); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param deviceBatch + * @return + */ + @RequestMapping(value = "/deleteBatch", method = {RequestMethod.PUT, RequestMethod.POST}) + public Result deleteBatch(@RequestBody DeviceBatch deviceBatch) { + service.removeBatch(deviceBatch); + return Result.OK("删除成功!"); + } /** * 设备集成-机构设备清单分页列表查询 @@ -132,8 +136,8 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findDepartPreviewPlanPage(page, devicePreview); @@ -162,16 +166,16 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findNuPreviewPlanPage(page, devicePreview); return Result.OK(pageList); } /** - * 增加设备清单 + * 增加设备清单 * * @param devicePreview * @return @@ -183,7 +187,7 @@ public class DeviceManagerController extends JeecgController> queryQuantityByOrgCode(@RequestParam("batchNo") String batchNo, @RequestParam("orgCode") String orgCode) { + return Result.OK(service.queryQuantityByOrgCode(batchNo, orgCode)); + } + + @RequestMapping(value = "/batchSave", method = RequestMethod.POST) + public Result batchSave(@RequestBody List 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>> getNuListByOrgCode(@RequestParam("orgCode") String orgCode) { + if(StringUtils.isBlank(orgCode)){ + return Result.error("orgCode不能为空"); + } + Map> result = service.getNuListByOrgCode(orgCode); + return Result.ok(result); + } + + /** + * 通过id删除 * * @param devicePreview * @return @@ -207,7 +249,7 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findCameraPage(page, deviceIntegration); return Result.OK(pageList); @@ -259,9 +301,9 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findNetworkPage(page, deviceIntegration); return Result.OK(pageList); @@ -290,9 +332,9 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findElectricityPage(page, deviceIntegration); return Result.OK(pageList); @@ -325,9 +367,9 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findWaterPage(page, deviceIntegration); return Result.OK(pageList); @@ -355,9 +397,9 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findHumidPage(page, deviceIntegration); return Result.OK(pageList); @@ -385,9 +427,9 @@ public class DeviceManagerController extends JeecgController> 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 page = new Page(pageNo, pageSize); IPage pageList = service.findBingLogPage(page, deviceBindLog); return Result.OK(pageList); diff --git a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/entity/DeviceNuBaseInfoEntity.java b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/entity/DeviceNuBaseInfoEntity.java new file mode 100644 index 0000000..4052d3a --- /dev/null +++ b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/entity/DeviceNuBaseInfoEntity.java @@ -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 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); + } + +} diff --git a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/mapper/DeviceManagerMapper.java b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/mapper/DeviceManagerMapper.java index 4997ddb..caae184 100644 --- a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/mapper/DeviceManagerMapper.java +++ b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/mapper/DeviceManagerMapper.java @@ -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 { IPage findPlanPage(Page page, @Param("params") DeviceManager deviceManager); + IPage findBatchPage(Page 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 queryNuList(DevicePreview devicePreview); + IPage findDepartPreviewPlanPage(Page page, @Param("params") DevicePreview devicePreview); + IPage findNuPreviewPlanPage(Page page, @Param("params") DevicePreview devicePreview); + List 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 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 findCameraPage(Page page, @Param("params") DeviceIntegration deviceIntegration); + IPage findNetworkPage(Page page, @Param("params") DeviceIntegration deviceIntegration); + IPage findElectricityPage(Page page, @Param("params") DeviceIntegration deviceIntegration); + IPage findWaterPage(Page page, @Param("params") DeviceIntegration deviceIntegration); + IPage findHumidPage(Page page, @Param("params") DeviceIntegration deviceIntegration); + IPage findBingLogPage(Page 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 queryQuantityByOrgCode(@Param("batchNo") String batchNo, @Param("orgCode") String orgCode); + + List selectWlsbList(); + + List selectJcgnList(); + + List selectAllNu(); } diff --git a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/mapper/xml/DeviceManagerMapper.xml b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/mapper/xml/DeviceManagerMapper.xml index 023dc9e..e088c1b 100644 --- a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/mapper/xml/DeviceManagerMapper.xml +++ b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/mapper/xml/DeviceManagerMapper.xml @@ -2,13 +2,14 @@ - 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 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 - - 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 into nu_iot_device_preview_batch(batch_no, + org_code, + iz_push, + create_time, + create_by, + remarks) + values (#{batchNo}, + #{orgCode}, + 'N', + now(), + #{createBy}, + #{remarks}) 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} - delete from nu_iot_device_preview_batch where id = #{id} + delete + from nu_iot_device_preview_batch + where id = #{id} - delete from nu_iot_device_preview_plan where batch_no = #{batchNo} + delete + from nu_iot_device_preview_plan + where batch_no = #{batchNo} update nu_iot_device_preview_batch - set iz_push = 'Y', + set iz_push = 'Y', push_time = now() where batch_no = #{batchNo} - + select nu_id, nu_name from nu_base_info where status != '5' and sys_org_code = #{orgCode} order by nu_id asc - 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} - - AND a.dimension = #{params.dimension} - - - AND a.device_type = #{params.deviceType} - + + AND a.dimension = #{params.dimension} + + + AND a.device_type = #{params.deviceType} + 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 - 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} - - AND c.nu_name LIKE concat('%',#{params.nuName},'%') - - - AND a.dimension = #{params.dimension} - - - AND a.device_type = #{params.deviceType} - + + AND c.nu_name LIKE concat('%',#{params.nuName},'%') + + + AND a.dimension = #{params.dimension} + + + AND a.device_type = #{params.deviceType} + order by a.nu_id,a.device_type asc - 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 - org_code = #{orgCode} and batch_no = #{batchNo} + org_code = #{orgCode} and batch_no = #{batchNo} AND dimension = #{dimension} @@ -187,107 +194,112 @@ - - 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 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}) update nu_iot_device_preview_plan - set nu_id = #{nuId}, - purchase_quantity = #{purchaseQuantity}, - update_time = now() + set + + nu_id = #{nuId}, + + purchase_quantity = #{purchaseQuantity}, + update_time = now() where id = #{id} - delete from nu_iot_device_preview_plan where id = #{id} + delete + from nu_iot_device_preview_plan + where id = #{id} - delete from nu_iot_device_preview_plan where batch_no = #{batchNo} + delete + from nu_iot_device_preview_plan + where batch_no = #{batchNo} - select sum(purchase_quantity) as purchaseQuantity from nu_iot_device_preview_plan where batch_no = #{batchNo} - delete from nu_iot_device_preview where batch_no = #{batchNo} + delete + from nu_iot_device_preview + where batch_no = #{batchNo} - - 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 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}) - 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 @@ -367,7 +379,7 @@ update nu_iot_device_preview - set iz_sync = 'Y', + set iz_sync = 'Y', sync_time = now() where id = #{id} @@ -379,7 +391,9 @@ - delete from nu_iot_device_preview where id = #{id} + delete + from nu_iot_device_preview + where id = #{id} @@ -390,140 +404,150 @@ 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} - + 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 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 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 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 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 - 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} @@ -538,71 +562,92 @@ order by org_code asc ,factory asc ,device_type asc ,device_model asc ,sn asc,opt_date desc + + + + + + + + - 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 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, '') != '损坏' update nu_iot_device_preview set nu_id = null where org_code = #{orgCode} - and nu_id = #{nuId} + and nu_id = #{nuId} diff --git a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/service/IDeviceManagerService.java b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/service/IDeviceManagerService.java index 4d39185..f9d513a 100644 --- a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/service/IDeviceManagerService.java +++ b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/service/IDeviceManagerService.java @@ -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 { void addBindPreview(DeviceBindLog deviceBindLog); void releaseNu(String orgCode,String nuId); + List queryQuantityByOrgCode(String batchNo, String orgCode); + + Map> getNuListByOrgCode(String orgCode); } diff --git a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/service/impl/DeviceManagerServiceImpl.java b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/service/impl/DeviceManagerServiceImpl.java index 51c6964..3cd93cd 100644 --- a/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/service/impl/DeviceManagerServiceImpl.java +++ b/nursing-unit-iot/nu-iot-biz/src/main/java/com/nu/modules/device/manager/service/impl/DeviceManagerServiceImpl.java @@ -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 findPlanPage(Page page, DeviceManager deviceManager){ - return baseMapper.findPlanPage(page,deviceManager); + public IPage findPlanPage(Page page, DeviceManager deviceManager) { + return baseMapper.findPlanPage(page, deviceManager); } @Override - public IPage findBatchPage(Page page, DeviceBatch deviceBatch){ - IPage records = baseMapper.findBatchPage(page,deviceBatch); + public IPage findBatchPage(Page page, DeviceBatch deviceBatch) { + IPage records = baseMapper.findBatchPage(page, deviceBatch); List list = records.getRecords(); - for(int i=0;i queryNuList(DevicePreview devicePreview){ + public List queryNuList(DevicePreview devicePreview) { return baseMapper.queryNuList(devicePreview); } @Override - public IPage findDepartPreviewPlanPage(Page page, DevicePreview devicePreview){ - return baseMapper.findDepartPreviewPlanPage(page,devicePreview); + public IPage findDepartPreviewPlanPage(Page page, DevicePreview devicePreview) { + return baseMapper.findDepartPreviewPlanPage(page, devicePreview); } @Override - public IPage findNuPreviewPlanPage(Page page, DevicePreview devicePreview){ - return baseMapper.findNuPreviewPlanPage(page,devicePreview); + public IPage findNuPreviewPlanPage(Page 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 list = baseMapper.getPreviewList(devicePreview); - if(qdp.getPurchaseQuantity()!=list.size()){ + if (qdp.getPurchaseQuantity() != list.size()) { List planList = baseMapper.getPreviewPlanList(devicePreview); - if(planList.size()>0){ + if (planList.size() > 0) { baseMapper.deletePreviewByBatch(devicePreview); - for(int i=0;i iotList = new ArrayList<>(); list = baseMapper.getPreviewList(devicePreview); - for(int i=0;i 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 findCameraPage(Page page, DeviceIntegration deviceIntegration){ - return baseMapper.findCameraPage(page,deviceIntegration); + public IPage findCameraPage(Page page, DeviceIntegration deviceIntegration) { + return baseMapper.findCameraPage(page, deviceIntegration); } /** * 拉取监控设备 + * * @param deviceIntegration */ @Override - public Result pullCamera(DeviceIntegration deviceIntegration){ + public Result pullCamera(DeviceIntegration deviceIntegration) { String mac = formatMacAddress(deviceIntegration.getSn()); CameraInfo cameraInfo = new CameraInfo(); cameraInfo.setMac(mac); cameraInfo.setDeviceType(deviceIntegration.getDeviceType()); Result 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 findNetworkPage(Page page, DeviceIntegration deviceIntegration){ - return baseMapper.findNetworkPage(page,deviceIntegration); + public IPage findNetworkPage(Page page, DeviceIntegration deviceIntegration) { + return baseMapper.findNetworkPage(page, deviceIntegration); } @Override - public IPage findElectricityPage(Page page, DeviceIntegration deviceIntegration){ - return baseMapper.findElectricityPage(page,deviceIntegration); + public IPage findElectricityPage(Page page, DeviceIntegration deviceIntegration) { + return baseMapper.findElectricityPage(page, deviceIntegration); } /** * 拉取电表 + * * @param deviceIntegration */ @Override - public Result pullElectricity(DeviceIntegration deviceIntegration){ + public Result pullElectricity(DeviceIntegration deviceIntegration) { DsElectricityMeter dsElectricityMeter = new DsElectricityMeter(); dsElectricityMeter.setSn(deviceIntegration.getSn()); Result res = electricityMeterService.add(dsElectricityMeter); - if(!res.isSuccess()){ + if (!res.isSuccess()) { return res; } //获取设备sim @@ -296,34 +299,36 @@ public class DeviceManagerServiceImpl extends ServiceImpl deleteElectricity(DeviceIntegration deviceIntegration){ + public Result deleteElectricity(DeviceIntegration deviceIntegration) { DsElectricityMeter dsElectricityMeter = new DsElectricityMeter(); dsElectricityMeter.setSn(deviceIntegration.getSn()); Result res = electricityMeterService.delete(dsElectricityMeter); - if(!res.isSuccess()){ + if (!res.isSuccess()) { return res; } return Result.OK("拉取电表成功!"); } @Override - public IPage findWaterPage(Page page, DeviceIntegration deviceIntegration){ - return baseMapper.findWaterPage(page,deviceIntegration); + public IPage findWaterPage(Page page, DeviceIntegration deviceIntegration) { + return baseMapper.findWaterPage(page, deviceIntegration); } /** * 拉取水表 + * * @param deviceIntegration */ @Override - public Result pullWater(DeviceIntegration deviceIntegration){ + public Result 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 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 findHumidPage(Page page, DeviceIntegration deviceIntegration){ - return baseMapper.findHumidPage(page,deviceIntegration); + public IPage findHumidPage(Page page, DeviceIntegration deviceIntegration) { + return baseMapper.findHumidPage(page, deviceIntegration); } /** * 拉取温湿度计 + * * @param deviceIntegration */ @Override - public Result pullHumid(DeviceIntegration deviceIntegration){ + public Result pullHumid(DeviceIntegration deviceIntegration) { HumidDevice humidDevice = new HumidDevice(); humidDevice.setSn(deviceIntegration.getSn()); humidDevice.setDeviceName(deviceIntegration.getDeviceName()); humidDevice.setTimeCode("01"); Result 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 findBingLogPage(Page page, DeviceBindLog deviceBindLog){ - return baseMapper.findBingLogPage(page,deviceBindLog); + public IPage findBingLogPage(Page 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 queryQuantityByOrgCode(String batchNo, String orgCode) { + return baseMapper.queryQuantityByOrgCode(batchNo, orgCode); } public String formatMacAddress(String mac) { @@ -428,4 +439,130 @@ public class DeviceManagerServiceImpl extends ServiceImpl> getNuListByOrgCode(String orgCode) { + //护理单元 + List list = baseMapper.selectAllNu(); + Map> result = new HashMap<>(); + //设备信息 + List wlsbList = baseMapper.selectWlsbList(); + //基础功能 + List jcgnList = baseMapper.selectJcgnList(); + List mergedTrees = buildTree(jcgnList); + + for (DeviceNuBaseInfoEntity info : list) { + String sxtStr = "";//摄像头集合 + String dbStr = "";//电表集合 + String sbStr = "";//水表集合 + String wsdjStr = "";//温湿度计集合 + List 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 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 buildTree(List nodes) { + // 按 nuId 分组 + Map> groupByNuId = nodes.stream() + .collect(Collectors.groupingBy(DeviceNuBaseInfoEntity::getNuId)); + + List allRootNodes = new ArrayList<>(); + + // 对每个 nuId 分组单独构建树 + for (Map.Entry> entry : groupByNuId.entrySet()) { + String nuId = entry.getKey(); + List sameNuIdNodes = entry.getValue(); + + List rootNodes = buildSingleTree(sameNuIdNodes, nuId); + allRootNodes.addAll(rootNodes); + } + + return allRootNodes; + } + + /** + * 构建单个 nuId 的分类树 + */ + private List buildSingleTree(List nodes, String nuId) { + List rootNodes = new ArrayList<>(); + Map 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; + } }