From 8a66e5ca5147f96eb71ccc7235a655e5e1e260ee Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Wed, 9 Jul 2025 13:41:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=85=8D=E5=AE=A2=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/query/DeviceAssignmentQuery.java | 54 ++++ .../mapper/DeviceAssignmentsMapper.java | 23 +- .../service/DeviceTypeGrantsService.java | 14 + .../service/impl/DeviceServiceImpl.java | 280 +++++++----------- .../impl/DeviceTypeGrantsServiceImpl.java | 18 ++ .../equipment/DeviceAssignmentsMapper.xml | 40 ++- .../mapper/equipment/DeviceMapper.xml | 3 +- 7 files changed, 248 insertions(+), 184 deletions(-) create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceAssignmentQuery.java create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceTypeGrantsService.java create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeGrantsServiceImpl.java diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceAssignmentQuery.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceAssignmentQuery.java new file mode 100644 index 0000000..5597e1f --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceAssignmentQuery.java @@ -0,0 +1,54 @@ +package com.fuyuanshen.equipment.domain.query; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author: 默苍璃 + * @date: 2025-07-0910:27 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DeviceAssignmentQuery implements Serializable { + + /** + * 表示这个 serialVersionUID 字段是专门为 Java 序列化机制服务的。 + */ + @Serial + private static final long serialVersionUID = 1L; + + private Long deviceId; + + /** + * 分配者 + */ + private Long assignerId; + + /** + * 接收者 + */ + private Long assigneeId; + + /** + * 0 否 + * 1 是 + * 设备是否有效 + */ + private Integer active; + + /** + * 分配等级(用于失效) + */ + private String lever; + + + // Getters and Setters + +} \ No newline at end of file diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceAssignmentsMapper.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceAssignmentsMapper.java index 8cc0cb9..e411c23 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceAssignmentsMapper.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceAssignmentsMapper.java @@ -2,17 +2,26 @@ package com.fuyuanshen.equipment.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.fuyuanshen.equipment.domain.DeviceAssignments; +import com.fuyuanshen.equipment.domain.query.DeviceAssignmentQuery; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** -* @author 97433 -* @description 针对表【device_assignments】的数据库操作Mapper -* @createDate 2025-06-19 18:19:13 -* @Entity system.domain.DeviceAssignments -*/ + * @author 97433 + * @description 针对表【device_assignments】的数据库操作Mapper + * @createDate 2025-06-19 18:19:13 + * @Entity system.domain.DeviceAssignments + */ @Mapper public interface DeviceAssignmentsMapper extends BaseMapper { - - + /** + * 查询设备分配信息 + * + * @param deviceAssignmentQuery + * @return + */ + List deviceAssignmentsMapper(@Param("query") DeviceAssignmentQuery deviceAssignmentQuery); } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceTypeGrantsService.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceTypeGrantsService.java new file mode 100644 index 0000000..dfe2f20 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceTypeGrantsService.java @@ -0,0 +1,14 @@ +package com.fuyuanshen.equipment.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuyuanshen.equipment.domain.DeviceTypeGrants; + +/** +* @author 97433 +* @description 针对表【device_type_grants】的数据库操作Service +* @createDate 2025-06-19 13:49:33 +*/ +public interface DeviceTypeGrantsService extends IService { + +} diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java index ef84ed2..50c0aaf 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java @@ -1,6 +1,7 @@ package com.fuyuanshen.equipment.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.UUID; import cn.hutool.core.lang.generator.SnowflakeGenerator; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -23,6 +24,7 @@ import com.fuyuanshen.equipment.domain.DeviceType; import com.fuyuanshen.equipment.domain.DeviceTypeGrants; import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; import com.fuyuanshen.equipment.domain.form.DeviceForm; +import com.fuyuanshen.equipment.domain.query.DeviceAssignmentQuery; import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria; import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria; import com.fuyuanshen.equipment.domain.vo.AppDeviceVo; @@ -37,8 +39,10 @@ import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper; import com.fuyuanshen.equipment.mapper.DeviceTypeMapper; import com.fuyuanshen.equipment.service.DeviceAssignmentsService; import com.fuyuanshen.equipment.service.DeviceService; +import com.fuyuanshen.equipment.service.DeviceTypeGrantsService; import com.fuyuanshen.system.domain.vo.SysOssVo; import com.fuyuanshen.system.service.ISysOssService; +import com.fuyuanshen.system.service.ISysUserService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -62,6 +66,8 @@ import java.util.*; @RequiredArgsConstructor public class DeviceServiceImpl extends ServiceImpl implements DeviceService { + public static final String USER_ID_SEPARATOR = ":"; + @Value("${file.device.pic}") private String filePath; @Value("${file.device.ip}") @@ -75,6 +81,8 @@ public class DeviceServiceImpl extends ServiceImpl impleme private final DeviceAssignmentsService deviceAssignmentsService; private final DeviceAssignmentsMapper deviceAssignmentsMapper; + + private final DeviceTypeGrantsService deviceTypeGrantsService; private final DeviceTypeGrantsMapper deviceTypeGrantsMapper; @@ -89,7 +97,6 @@ public class DeviceServiceImpl extends ServiceImpl impleme @Override public TableDataInfo queryAll(DeviceQueryCriteria criteria, Page page) throws IOException { - // criteria.setCustomerId(LoginHelper.getUserId()); criteria.setCurrentOwnerId(LoginHelper.getUserId()); IPage devices = deviceMapper.findAll(criteria, page); @@ -100,7 +107,6 @@ public class DeviceServiceImpl extends ServiceImpl impleme } } - // return PageUtil.toPage(devices); return new TableDataInfo(records, devices.getTotal()); } @@ -123,43 +129,6 @@ public class DeviceServiceImpl extends ServiceImpl impleme } - // /** - // * 新增设备 - // * - // * @param deviceForm - // * @throws Exception - // */ - // @Override - // @Transactional(rollbackFor = Exception.class) - // public void addDevice(DeviceForm deviceForm) throws Exception { - // DeviceTypeQueryCriteria queryCriteria = new DeviceTypeQueryCriteria(); - // queryCriteria.setDeviceTypeId(deviceForm.getDeviceType()); - // queryCriteria.setCustomerId(LoginHelper.getUserId()); - // List deviceTypes = deviceTypeMapper.findAll(queryCriteria); - // if (deviceTypes.isEmpty()) { - // throw new Exception("设备类型不存在!!!"); - // } - // - // // 保存图片并获取URL - // if (deviceForm.getFile() != null) { - // SysOssVo upload = ossService.upload(deviceForm.getFile()); - // // 设置图片路径 - // deviceForm.setDevicePic(upload.getUrl()); - // } - // - // // 转换对象并插入数据库 - // Device device = new Device(); - // LoginUser loginUser = LoginHelper.getLoginUser(); - // device.setCurrentOwnerId(loginUser.getUserId()); - // device.setOriginalOwnerId(loginUser.getUserId()); - // device.setCreateByName(loginUser.getNickname()); - // device.setTypeName(deviceTypes.get(0).getTypeName()); - // BeanUtil.copyProperties(deviceForm, device, true); - // - // deviceMapper.insert(device); - // - // } - /** * 新增设备 * @@ -174,7 +143,7 @@ public class DeviceServiceImpl extends ServiceImpl impleme queryCriteria.setCustomerId(LoginHelper.getUserId()); DeviceTypeGrants typeGrants = deviceTypeGrantsMapper.selectById(queryCriteria.getDeviceTypeId()); DeviceType deviceTypes = deviceTypeMapper.selectById(typeGrants.getDeviceTypeId()); - if (deviceTypes== null) { + if (deviceTypes == null) { throw new Exception("设备类型不存在!!!"); } @@ -187,15 +156,15 @@ public class DeviceServiceImpl extends ServiceImpl impleme // 转换对象并插入数据库 Device device = new Device(); + BeanUtil.copyProperties(deviceForm, device, true); + device.setDeviceNo(createDeviceNo()); LoginUser loginUser = LoginHelper.getLoginUser(); device.setCurrentOwnerId(loginUser.getUserId()); device.setOriginalOwnerId(loginUser.getUserId()); device.setCreateByName(loginUser.getNickname()); device.setTypeName(deviceTypes.getTypeName()); device.setDeviceType(deviceTypes.getId()); - BeanUtil.copyProperties(deviceForm, device, true); - device.setDeviceNo(createDeviceNo()); deviceMapper.insert(device); // 新增设备类型记录 @@ -208,16 +177,18 @@ public class DeviceServiceImpl extends ServiceImpl impleme // 接收者 assignments.setAssigneeId(loginUser.getUserId()); assignments.setActive(DeviceActiveStatusEnum.ACTIVE.getCode()); - String lever = loginUser.getUserId() + ":"; + String lever = USER_ID_SEPARATOR + loginUser.getUserId(); assignments.setLever(lever); deviceAssignmentsService.save(assignments); } + private String createDeviceNo() { String uuidStr = UUID.fastUUID().toString(); // 获取带 - 的标准格式字符串 return uuidStr.replaceAll("-", ""); } + /** * 更新设备信息 * @@ -323,137 +294,106 @@ public class DeviceServiceImpl extends ServiceImpl impleme * * @param customerVo */ - // @Override - // @Transactional(rollbackFor = Exception.class) - // public void assignCustomer1(CustomerVo customerVo) { - // List deviceIds = customerVo.getDeviceIds(); - // Long customerId = customerVo.getCustomerId(); - // - // Customer customer = customerMapper.queryCustomerById(customerId, LoginHelper.getLoginUser().getPid()); - // if (customer == null) { - // throw new RuntimeException("待分配的客户不存在!!!"); - // } - // - // List invalidIds = new ArrayList<>(); - // List devices = new ArrayList<>(); - // for (Long id : deviceIds) { - // Device device = deviceMapper.selectById(id); - // if (device == null || !Objects.equals(device.getCurrentOwnerId(), LoginHelper.getUserId())) { - // invalidIds.add(id); - // continue; - // } - // Device assignCustomer = deviceMapper.getAssignCustomer(device.getId()); - // if (assignCustomer != null) { - // invalidIds.add(id); - // continue; - // } - // device.setCustomerId(customerId); - // device.setCustomerName(customer.getNickName()); - // devices.add(device); - // } - // if (!invalidIds.isEmpty()) { - // throw new RuntimeException("以下设备无法分配(ID 不存在或无权限): " + invalidIds); - // } - // - // devices.forEach((device) -> { - // - // deviceMapper.updateById(device); - // device.setCurrentOwnerId(customerId); - // if (device.getDeviceType() == null) { - // throw new RuntimeException("设备类型有问题!!! "); - // } - // DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType()); - // SnowflakeGenerator snowflakeGenerator = new SnowflakeGenerator(); - // device.setOriginalDeviceId(device.getId()); - // Long next = snowflakeGenerator.next(); - // device.setId(next); - // device.setDeviceType(next); - // - // DeviceType assignType = deviceTypeMapper.getAssignType(device.getDeviceType(), customerId); - // if (assignType == null) { - // deviceType.setOriginalDeviceId(deviceType.getId()); - // deviceType.setId(next); - // deviceType.setOwnerCustomerId(customerId); - // deviceTypeMapper.insert(deviceType); - // } - // - // deviceMapper.insert(device); - // - // }); - // } @Override + @Transactional(rollbackFor = Exception.class) public void assignCustomer(CustomerVo customerVo) { - List deviceIds = customerVo.getDeviceIds(); - Long customerId = customerVo.getCustomerId(); - Customer customer = customerMapper.queryCustomerById(customerId, LoginHelper.getLoginUser().getPid()); - if (customer == null) { - throw new RuntimeException("待分配的客户不存在!!!"); + if (customerVo.getDeviceIds().isEmpty() || customerVo.getCustomerId() == null) { + throw new RuntimeException("请选择设备或客户"); } - List devicesToAssign = new ArrayList<>(); - List invalidIds = new ArrayList<>(); + // 获取当前登录用户 + LoginUser loginUser = LoginHelper.getLoginUser(); + // 获取分配用户信息 + Customer assignUser = customerMapper.selectById(customerVo.getCustomerId()); + // 获取分配设备信息 + List assignments = deviceAssignmentsMapper.selectByIds(customerVo.getDeviceIds()); - for (Long id : deviceIds) { - Device device = deviceMapper.selectById(id); - if (device == null || !Objects.equals(device.getCurrentOwnerId(), LoginHelper.getUserId())) { - invalidIds.add(id); + // 批量更新设备状态 + List deviceTypeGrants = new ArrayList<>(); + for (DeviceAssignments assignment : assignments) { + Device device = deviceMapper.selectById(assignment.getDeviceId()); + + // 如果设备已分配给需要分配的客户,则跳过 + DeviceAssignmentQuery dq = DeviceAssignmentQuery.builder().deviceId(device.getId()).assigneeId(customerVo.getCustomerId()) + .active(DeviceActiveStatusEnum.ACTIVE.getCode()).lever(assignment.getLever() + USER_ID_SEPARATOR).build(); + // 查询分配 + List assignmentsList = deviceAssignmentsMapper.deviceAssignmentsMapper(dq); + if (CollectionUtil.isNotEmpty(assignmentsList)) { + log.info("设备 {} 已分配给客户 {}", device.getDeviceName(), device.getCustomerName()); continue; } - Device assignCustomer = deviceMapper.getAssignCustomer(device.getId()); - if (assignCustomer != null) { - invalidIds.add(id); + + // 更改分配客户 + assignment.setAssigneeName(assignUser.getNickName()); + deviceAssignmentsMapper.updateById(assignment); + + // 设备失效 + // 获取用户的设备记录 + DeviceAssignmentQuery dq1 = DeviceAssignmentQuery.builder().deviceId(device.getId()).assignerId(loginUser.getUserId()) + .active(DeviceActiveStatusEnum.ACTIVE.getCode()).lever(assignment.getLever() + USER_ID_SEPARATOR).build(); + List ag = deviceAssignmentsMapper.deviceAssignmentsMapper(dq1); + if (CollectionUtil.isNotEmpty(ag)) { + for (DeviceAssignments d : ag) { + d.setActive(DeviceActiveStatusEnum.INACTIVE.getCode()); + deviceAssignmentsMapper.updateById(d); + } + } + + // 新增设备类型记录 + DeviceAssignments dam = new DeviceAssignments(); + dam.setDeviceId(device.getId()); + dam.setAssignedAt(LocalDateTime.now()); + // 分配者 + dam.setAssignerId(loginUser.getUserId()); + dam.setAssignerName(loginUser.getUsername()); + // 接收者 + dam.setAssigneeId(assignUser.getCustomerId()); + // assignments.setAssigneeName(assignUser.getUsername()); + dam.setActive(DeviceActiveStatusEnum.ACTIVE.getCode()); + String lever = assignment.getLever() + USER_ID_SEPARATOR + assignUser.getCustomerId(); + dam.setLever(lever); + deviceAssignmentsService.save(dam); + + // 判断设备类型是否存在 + DeviceTypeGrants dtg = deviceTypeGrantsMapper.selectOne(new LambdaQueryWrapper().eq(DeviceTypeGrants::getDeviceTypeId, device.getId())); + if (dtg != null) { continue; } - device.setCustomerId(customerId); - device.setCustomerName(customer.getNickName()); - devicesToAssign.add(device); + // 创建并保存设备类型授权记录 + DeviceTypeGrants deviceTypeGrant = new DeviceTypeGrants(); + deviceTypeGrant.setGrantedAt(new Date()); + deviceTypeGrant.setDeviceTypeId(device.getDeviceType()); + // 关联分配记录 + deviceTypeGrant.setAssignmentId(dam.getId()); + // 被授权的客户 + deviceTypeGrant.setCustomerId(customerVo.getCustomerId()); + // 授权方客户 + deviceTypeGrant.setGrantorCustomerId(loginUser.getUserId()); + deviceTypeGrants.add(deviceTypeGrant); } - if (!invalidIds.isEmpty()) { - throw new RuntimeException("以下设备无法分配(ID 不存在或无权限): " + invalidIds); - } + deviceTypeGrantsService.saveBatch(deviceTypeGrants); - // 批量处理设备分配 - batchAssignDevices(devicesToAssign, customer); } - @Transactional(rollbackFor = Exception.class) - public void batchAssignDevices(List devicesToAssign, Customer customer) { - Long userId = LoginHelper.getUserId(); - SnowflakeGenerator snowflakeGenerator = new SnowflakeGenerator(); - for (Device device : devicesToAssign) { - if (device.getDeviceType() == null) { - throw new RuntimeException("设备类型有问题!!! "); - } - - deviceMapper.updateById(device); - - DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType()); - DeviceType assignType = deviceTypeMapper.getAssignType(device.getDeviceType(), customer.getCustomerId()); - - Long next = snowflakeGenerator.next(); - - device.setOriginalDeviceId(device.getId()); - device.setCurrentOwnerId(customer.getCustomerId()); - device.setOriginalOwnerId(device.getCurrentOwnerId()); - device.setCustomerId(null); - device.setCustomerName(""); - device.setId(next); - - if (assignType == null) { - deviceType.setOriginalDeviceId(deviceType.getId()); - deviceType.setOriginalOwnerId(deviceType.getOwnerCustomerId()); - deviceType.setId(next); - device.setDeviceType(next); - deviceType.setOwnerCustomerId(customer.getCustomerId()); - deviceTypeMapper.insert(deviceType); - } else { - device.setDeviceType(assignType.getId()); - } - - deviceMapper.insert(device); - } + /** + * 创建并保存设备类型授权记录 + * + * @param device 当前设备对象 + * @param currentUser 当前登录用户 + * @param customerVo 客户信息 + * @param deviceTypeGrants 授权记录集合 + */ + private void createAndSaveDeviceTypeGrants(Device device, LoginUser currentUser, CustomerVo customerVo, List deviceTypeGrants) { + // Long generatedId = NanoId.generate(NanoIdLengthEnum.HIGH_CONCURRENCY.getLength()); + DeviceTypeGrants deviceTypeGrant = new DeviceTypeGrants(); + deviceTypeGrant.setGrantedAt(new Date()); + deviceTypeGrant.setDeviceTypeId(device.getDeviceType()); + // deviceTypeGrant.setAssignmentId(generatedId); + deviceTypeGrant.setCustomerId(customerVo.getCustomerId()); + deviceTypeGrant.setGrantorCustomerId(currentUser.getUserId()); + deviceTypeGrants.add(deviceTypeGrant); } @@ -516,6 +456,7 @@ public class DeviceServiceImpl extends ServiceImpl impleme } + @Override public TableDataInfo queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery) { Long userId = AppLoginHelper.getUserId(); @@ -528,43 +469,44 @@ public class DeviceServiceImpl extends ServiceImpl impleme public int bindDevice(AppDeviceBo bo) { Integer mode = bo.getCommunicationMode(); Long userId = AppLoginHelper.getUserId(); - if(mode == CommunicationModeEnum.FOUR_G.getValue()){ + if (mode == CommunicationModeEnum.FOUR_G.getValue()) { String deviceImei = bo.getDeviceImei(); QueryWrapper qw = new QueryWrapper() .eq("device_imei", deviceImei); List devices = baseMapper.selectList(qw); - if(devices.isEmpty()){ + if (devices.isEmpty()) { throw new RuntimeException("请先将设备入库!!!"); } Device device = devices.get(0); - if(device.getBindingStatus()!=null && device.getBindingStatus() == BindingStatusEnum.BOUND.getCode()){ + if (device.getBindingStatus() != null && device.getBindingStatus() == BindingStatusEnum.BOUND.getCode()) { throw new RuntimeException("设备已绑定"); } UpdateWrapper deviceUpdateWrapper = new UpdateWrapper<>(); deviceUpdateWrapper.eq("id", device.getId()) .set("binding_status", BindingStatusEnum.BOUND.getCode()) - .set("binding_user_id",userId);; + .set("binding_user_id", userId); + ; return baseMapper.update(null, deviceUpdateWrapper); - }else if(mode == CommunicationModeEnum.BLUETOOTH.getValue()){ + } else if (mode == CommunicationModeEnum.BLUETOOTH.getValue()) { String deviceMac = bo.getDeviceMac(); QueryWrapper qw = new QueryWrapper() .eq("device_mac", deviceMac); List devices = baseMapper.selectList(qw); - if(devices.isEmpty()){ + if (devices.isEmpty()) { throw new RuntimeException("请先将设备入库!!!"); } Device device = devices.get(0); - if(device.getBindingStatus() != null && device.getBindingStatus() == BindingStatusEnum.BOUND.getCode()){ + if (device.getBindingStatus() != null && device.getBindingStatus() == BindingStatusEnum.BOUND.getCode()) { throw new RuntimeException("设备已绑定"); } UpdateWrapper deviceUpdateWrapper = new UpdateWrapper<>(); deviceUpdateWrapper.eq("id", device.getId()) .set("binding_status", BindingStatusEnum.BOUND.getCode()) - .set("binding_user_id",userId); + .set("binding_user_id", userId); return baseMapper.update(null, qw); - }else{ + } else { throw new RuntimeException("通讯方式错误"); } @@ -573,7 +515,7 @@ public class DeviceServiceImpl extends ServiceImpl impleme @Override public int unBindDevice(Long id) { Device device = baseMapper.selectById(id); - if(device == null){ + if (device == null) { throw new RuntimeException("请先将设备入库!!!"); } // DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType()); diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeGrantsServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeGrantsServiceImpl.java new file mode 100644 index 0000000..650c3a3 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeGrantsServiceImpl.java @@ -0,0 +1,18 @@ +package com.fuyuanshen.equipment.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuyuanshen.equipment.domain.DeviceTypeGrants; +import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper; +import com.fuyuanshen.equipment.service.DeviceTypeGrantsService; +import org.springframework.stereotype.Service; + +/** +* @author 97433 +* @description 针对表【device_type_grants】的数据库操作Service实现 +* @createDate 2025-06-19 13:49:33 +*/ +@Service +public class DeviceTypeGrantsServiceImpl extends ServiceImpl +implements DeviceTypeGrantsService { + +} diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceAssignmentsMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceAssignmentsMapper.xml index 4b8da37..6055d0e 100644 --- a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceAssignmentsMapper.xml +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceAssignmentsMapper.xml @@ -5,15 +5,41 @@ - - - - - - + + + + + + - id,device_id,from_customer_id,to_customer_id,assigned_at,device_type_granted + id + ,device_id,from_customer_id,to_customer_id,assigned_at,device_type_granted + + + + diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml index 81b5ee2..27a823c 100644 --- a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml @@ -77,11 +77,12 @@ select da.id AS id,d.device_name, d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei, - d.update_time, d.device_type, d.remark, d.binding_status,d.type_name AS typeName, + d.update_time, dg.id AS device_type, d.remark, d.binding_status,d.type_name AS typeName, da.assignee_id AS customerId, da.assignee_name AS customerName, da.active AS deviceStatus, da.create_time AS create_time , da.assigner_name AS createByName , da.id AS assignId from device d LEFT JOIN device_type t ON d.device_type = t.id + LEFT JOIN device_type_grants dg ON dg.device_type_id = t.id LEFT JOIN device_assignments da ON da.device_id = d.id