From b11d3ccd610488865627693789bca482f4ed76cf Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Fri, 20 Jun 2025 18:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=85=8D=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/system/domain/Device.java | 8 ++++ .../domain/dto/DeviceQueryCriteria.java | 3 ++ .../service/impl/DeviceServiceImpl.java | 37 ++++++++++++++----- .../resources/mapper/system/DeviceMapper.xml | 19 +++++----- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/fys-system/src/main/java/com/fuyuanshen/modules/system/domain/Device.java b/fys-system/src/main/java/com/fuyuanshen/modules/system/domain/Device.java index c82a81c..8ba3ebd 100644 --- a/fys-system/src/main/java/com/fuyuanshen/modules/system/domain/Device.java +++ b/fys-system/src/main/java/com/fuyuanshen/modules/system/domain/Device.java @@ -35,9 +35,17 @@ public class Device extends BaseEntity implements Serializable { @ApiModelProperty(value = "客户号") private Long customerId; + /** + * 当前所有者 + * current_owner_id + */ @ApiModelProperty(value = "当前所有者") private Long currentOwnerId; + /** + * 原始所有者(创建者) + * original_owner_id + */ @ApiModelProperty(value = "原始所有者(创建者)") private Long originalOwnerId; diff --git a/fys-system/src/main/java/com/fuyuanshen/modules/system/domain/dto/DeviceQueryCriteria.java b/fys-system/src/main/java/com/fuyuanshen/modules/system/domain/dto/DeviceQueryCriteria.java index 76bac9e..ff6dbfd 100644 --- a/fys-system/src/main/java/com/fuyuanshen/modules/system/domain/dto/DeviceQueryCriteria.java +++ b/fys-system/src/main/java/com/fuyuanshen/modules/system/domain/dto/DeviceQueryCriteria.java @@ -25,6 +25,9 @@ public class DeviceQueryCriteria { @ApiModelProperty(value = "设备MAC") private String deviceMac; + @ApiModelProperty(value = "设备IMEI") + private String deviceImei; + @ApiModelProperty(value = "设备SN") private String deviceSn; diff --git a/fys-system/src/main/java/com/fuyuanshen/modules/system/service/impl/DeviceServiceImpl.java b/fys-system/src/main/java/com/fuyuanshen/modules/system/service/impl/DeviceServiceImpl.java index 9e77151..256bc41 100644 --- a/fys-system/src/main/java/com/fuyuanshen/modules/system/service/impl/DeviceServiceImpl.java +++ b/fys-system/src/main/java/com/fuyuanshen/modules/system/service/impl/DeviceServiceImpl.java @@ -97,8 +97,8 @@ public class DeviceServiceImpl extends ServiceImpl impleme // 只能看到自己的创建的设备,以及被分配的设备。 if (onlineuser.getTenantId() != null && !onlineuser.getTenantId().equals(UserConstants.SUPER_ADMIN_ID)) { - // criteria.setTenantId(onlineuser.getTenantId()); - criteria.setCurrentOwnerId(onlineuser.getId()); + criteria.setTenantId(onlineuser.getTenantId()); + // criteria.setCurrentOwnerId(onlineuser.getId()); } IPage devices = deviceMapper.findAll(criteria, page); @@ -242,13 +242,12 @@ public class DeviceServiceImpl extends ServiceImpl impleme /** - * 分配客户 + * 分配客户 历史记录版本 * * @param customerVo */ - @Override - @Transactional(rollbackFor = Exception.class) - public void assignCustomer(CustomerVo customerVo) { + + public void assignCustomer1(CustomerVo customerVo) { // 防止管理员误操作 User currentUser = userService.findById(SecurityUtils.getCurrentUserId()); @@ -296,7 +295,7 @@ public class DeviceServiceImpl extends ServiceImpl impleme // -- 更新设备所有者 device.setCurrentOwnerId(customerVo.getCustomerId()); - devices.add( device); + devices.add(device); }); deviceAssignmentsService.saveBatch(assignments); @@ -307,11 +306,13 @@ public class DeviceServiceImpl extends ServiceImpl impleme /** - * 分配客户代码复制 + * 分配客户 * * @param customerVo */ - public void assignCustomer1(CustomerVo customerVo) { + @Override + @Transactional(rollbackFor = Exception.class) + public void assignCustomer(CustomerVo customerVo) { // 防止管理员误操作 User currentUser = userService.findById(SecurityUtils.getCurrentUserId()); @@ -330,6 +331,7 @@ public class DeviceServiceImpl extends ServiceImpl impleme this.updateBatchById(devices); // 批量更新设备状态 + List deviceTypeGrants = new ArrayList<>(); for (Device device : devices) { // 获取当前用户的所有祖先用户 List ancestorsById = userMapper.findAncestorsById(currentUser.getId()); @@ -349,7 +351,24 @@ public class DeviceServiceImpl extends ServiceImpl impleme // 根据条件批量更新 deviceMapper.update(updateDevice, wrapper); + + // 自定义16位id + Long generatedId = NanoId.generate(16); + // -- 授权设备类型给客户 + // QueryWrapper deviceTypeGrantsQueryWrapper = new QueryWrapper<>(); + // Long count = deviceTypeGrantsMapper.selectCount(deviceTypeGrantsQueryWrapper); + DeviceTypeGrants deviceTypeGrant = new DeviceTypeGrants(); + deviceTypeGrant.setGrantedAt(new Date()); + // 设备类型 + deviceTypeGrant.setDeviceTypeId(device.getDeviceType()); + deviceTypeGrant.setAssignmentId(generatedId); + // 被授权的客户 + deviceTypeGrant.setCustomerId(customerVo.getCustomerId()); + // 授权方客户 + deviceTypeGrant.setGrantorCustomerId(currentUser.getId()); + deviceTypeGrants.add(deviceTypeGrant); } + deviceTypeGrantsService.saveBatch(deviceTypeGrants); // 批量分配 Set deviceTypes = new HashSet<>(); diff --git a/fys-system/src/main/resources/mapper/system/DeviceMapper.xml b/fys-system/src/main/resources/mapper/system/DeviceMapper.xml index a812fb1..572bdb6 100644 --- a/fys-system/src/main/resources/mapper/system/DeviceMapper.xml +++ b/fys-system/src/main/resources/mapper/system/DeviceMapper.xml @@ -39,11 +39,12 @@