Compare commits
3 Commits
0d3b48bbbb
...
d219105b73
Author | SHA1 | Date | |
---|---|---|---|
d219105b73 | |||
908ca6753e | |||
8a66e5ca51 |
@ -1,5 +1,8 @@
|
|||||||
package com.fuyuanshen.app.controller;
|
package com.fuyuanshen.app.controller;
|
||||||
|
|
||||||
|
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
|
||||||
|
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||||
|
import com.fuyuanshen.app.service.equipment.APPDeviceService;
|
||||||
import com.fuyuanshen.common.core.domain.R;
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
@ -9,10 +12,11 @@ import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
|||||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||||
import com.fuyuanshen.equipment.service.DeviceService;
|
import com.fuyuanshen.equipment.service.DeviceService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.ibatis.annotations.Delete;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APP 设备信息管理
|
* APP 设备信息管理
|
||||||
*/
|
*/
|
||||||
@ -24,6 +28,9 @@ public class AppDeviceController extends BaseController {
|
|||||||
|
|
||||||
private final DeviceService deviceService;
|
private final DeviceService deviceService;
|
||||||
|
|
||||||
|
|
||||||
|
private final APPDeviceService appDeviceService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询文件列表
|
* 查询文件列表
|
||||||
*/
|
*/
|
||||||
@ -45,8 +52,28 @@ public class AppDeviceController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 解绑设备
|
* 解绑设备
|
||||||
*/
|
*/
|
||||||
@Delete("/unBind")
|
@DeleteMapping("/unBind")
|
||||||
public R<Void> unBind(Long id) {
|
public R<Void> unBind(Long id) {
|
||||||
return toAjax(deviceService.unBindDevice(id));
|
return toAjax(deviceService.unBindDevice(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备类型列表
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/typeList")
|
||||||
|
public R<List<APPDeviceTypeVo>> getTypeList() {
|
||||||
|
List<APPDeviceTypeVo> typeList = appDeviceService.getTypeList();
|
||||||
|
return R.ok(typeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重命名设备
|
||||||
|
* @param reNameDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/reName")
|
||||||
|
public R<String> reName(@Validated @RequestBody APPReNameDTO reNameDTO) {
|
||||||
|
appDeviceService.reName(reNameDTO);
|
||||||
|
return R.ok("重命名成功!!!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,7 @@ public class APPDeviceController {
|
|||||||
public TableDataInfo<APPDevice> appDeviceList(@RequestBody APPDeviceQueryCriteria criteria) {
|
public TableDataInfo<APPDevice> appDeviceList(@RequestBody APPDeviceQueryCriteria criteria) {
|
||||||
Page<APPDevice> page = new Page<>(criteria.getPage(), criteria.getSize());
|
Page<APPDevice> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
|
||||||
TableDataInfo<APPDevice> devices = appDeviceService.appDeviceList(page, criteria);
|
return appDeviceService.appDeviceList(page, criteria);
|
||||||
return devices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,11 +68,12 @@ public class APPDeviceController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/unbind")
|
@PostMapping(value = "/unbind")
|
||||||
@Operation(summary = "WEB端APP客户设备解绑")
|
@Operation(summary = "设备解绑")
|
||||||
public ResponseVO<String> unbindAPPDevice(@Validated @ModelAttribute APPUnbindDTO deviceForm) {
|
public ResponseVO<String> unbindAPPDevice(@Validated @ModelAttribute APPUnbindDTO deviceForm) {
|
||||||
appDeviceService.unbindAPPDevice(deviceForm);
|
appDeviceService.unbindAPPDevice(deviceForm);
|
||||||
return ResponseVO.success("解绑成功!!!");
|
return ResponseVO.success("解绑成功!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.fuyuanshen.app.domain.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-06-1818:36
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class APPReNameDTO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@NotBlank(message = "设备名称不能为空")
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.fuyuanshen.app.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class APPDeviceTypeVo {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
private String communicationMode;
|
||||||
|
|
||||||
|
}
|
@ -4,10 +4,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fuyuanshen.app.domain.APPDevice;
|
import com.fuyuanshen.app.domain.APPDevice;
|
||||||
|
import com.fuyuanshen.app.domain.APPDeviceType;
|
||||||
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||||
|
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Author: WY
|
* @Author: WY
|
||||||
@ -36,4 +40,5 @@ public interface APPDeviceMapper extends BaseMapper<APPDevice> {
|
|||||||
IPage<APPDevice> queryAll(Page<APPDevice> page, @Param("criteria") APPDeviceQueryCriteria criteria);
|
IPage<APPDevice> queryAll(Page<APPDevice> page, @Param("criteria") APPDeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
|
List<APPDeviceTypeVo> getTypeList(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fuyuanshen.app.domain.APPDevice;
|
import com.fuyuanshen.app.domain.APPDevice;
|
||||||
import com.fuyuanshen.app.domain.APPDeviceType;
|
import com.fuyuanshen.app.domain.APPDeviceType;
|
||||||
|
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
|
||||||
import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
||||||
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -58,4 +59,7 @@ public interface APPDeviceService extends IService<APPDevice> {
|
|||||||
void unbindAPPDevice(APPUnbindDTO deviceForm);
|
void unbindAPPDevice(APPUnbindDTO deviceForm);
|
||||||
|
|
||||||
|
|
||||||
|
List<APPDeviceTypeVo> getTypeList();
|
||||||
|
|
||||||
|
void reName(APPReNameDTO reNameDTO);
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,23 @@ package com.fuyuanshen.app.service.impl.equipment;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuyuanshen.app.domain.APPDevice;
|
import com.fuyuanshen.app.domain.APPDevice;
|
||||||
import com.fuyuanshen.app.domain.APPDeviceType;
|
import com.fuyuanshen.app.domain.APPDeviceType;
|
||||||
|
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
|
||||||
import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
||||||
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||||
|
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||||
import com.fuyuanshen.app.enums.UserType;
|
import com.fuyuanshen.app.enums.UserType;
|
||||||
import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper;
|
import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper;
|
||||||
import com.fuyuanshen.app.mapper.equipment.AppDeviceTypeMapper;
|
import com.fuyuanshen.app.mapper.equipment.AppDeviceTypeMapper;
|
||||||
import com.fuyuanshen.app.service.equipment.APPDeviceService;
|
import com.fuyuanshen.app.service.equipment.APPDeviceService;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
|
||||||
import com.fuyuanshen.common.core.exception.BadRequestException;
|
import com.fuyuanshen.common.core.exception.BadRequestException;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
@ -32,7 +35,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:
|
* @Description:
|
||||||
@ -192,5 +194,20 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<APPDeviceTypeVo> getTypeList() {
|
||||||
|
Long userId = AppLoginHelper.getUserId();
|
||||||
|
return appDeviceMapper.getTypeList(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reName(APPReNameDTO reNameDTO) {
|
||||||
|
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("id", reNameDTO.getId())
|
||||||
|
.eq("binding_user_id", AppLoginHelper.getUserId())
|
||||||
|
.set("device_name", reNameDTO.getDeviceName());
|
||||||
|
deviceMapper.update(updateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -87,5 +87,10 @@
|
|||||||
order by d.create_time desc
|
order by d.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getTypeList" resultType="com.fuyuanshen.app.domain.vo.APPDeviceTypeVo">
|
||||||
|
SELECT dt.id, dt.type_name, dt.communication_mode FROM device_type dt
|
||||||
|
WHERE EXISTS(select 1 from device d where d.device_type = dt.id and d.binding_user_id = #{userId} AND d.binding_status = 1 )
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -107,4 +107,5 @@ public class Device extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private String createByName;
|
private String createByName;
|
||||||
|
|
||||||
|
private Long bindingUserId;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
}
|
@ -27,4 +27,9 @@ public class AppDeviceVo {
|
|||||||
* 通讯方式 0:4G;1:蓝牙
|
* 通讯方式 0:4G;1:蓝牙
|
||||||
*/
|
*/
|
||||||
private Integer communicationMode;
|
private Integer communicationMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备图片
|
||||||
|
*/
|
||||||
|
private String devicePic;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,11 @@ package com.fuyuanshen.equipment.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
||||||
|
import com.fuyuanshen.equipment.domain.query.DeviceAssignmentQuery;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 97433
|
* @author 97433
|
||||||
@ -13,6 +17,11 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface DeviceAssignmentsMapper extends BaseMapper<DeviceAssignments> {
|
public interface DeviceAssignmentsMapper extends BaseMapper<DeviceAssignments> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备分配信息
|
||||||
|
*
|
||||||
|
* @param deviceAssignmentQuery
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DeviceAssignments> deviceAssignmentsMapper(@Param("query") DeviceAssignmentQuery deviceAssignmentQuery);
|
||||||
}
|
}
|
||||||
|
@ -90,4 +90,5 @@ public interface DeviceService extends IService<Device> {
|
|||||||
int bindDevice(AppDeviceBo bo);
|
int bindDevice(AppDeviceBo bo);
|
||||||
|
|
||||||
int unBindDevice(Long id);
|
int unBindDevice(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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<DeviceTypeGrants> {
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.fuyuanshen.equipment.service.impl;
|
package com.fuyuanshen.equipment.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.lang.UUID;
|
import cn.hutool.core.lang.UUID;
|
||||||
import cn.hutool.core.lang.generator.SnowflakeGenerator;
|
import cn.hutool.core.lang.generator.SnowflakeGenerator;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.DeviceTypeGrants;
|
||||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
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.DeviceQueryCriteria;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
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.mapper.DeviceTypeMapper;
|
||||||
import com.fuyuanshen.equipment.service.DeviceAssignmentsService;
|
import com.fuyuanshen.equipment.service.DeviceAssignmentsService;
|
||||||
import com.fuyuanshen.equipment.service.DeviceService;
|
import com.fuyuanshen.equipment.service.DeviceService;
|
||||||
|
import com.fuyuanshen.equipment.service.DeviceTypeGrantsService;
|
||||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
import com.fuyuanshen.system.service.ISysOssService;
|
import com.fuyuanshen.system.service.ISysOssService;
|
||||||
|
import com.fuyuanshen.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -62,6 +66,8 @@ import java.util.*;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements DeviceService {
|
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements DeviceService {
|
||||||
|
|
||||||
|
public static final String USER_ID_SEPARATOR = ":";
|
||||||
|
|
||||||
@Value("${file.device.pic}")
|
@Value("${file.device.pic}")
|
||||||
private String filePath;
|
private String filePath;
|
||||||
@Value("${file.device.ip}")
|
@Value("${file.device.ip}")
|
||||||
@ -75,6 +81,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
|
|
||||||
private final DeviceAssignmentsService deviceAssignmentsService;
|
private final DeviceAssignmentsService deviceAssignmentsService;
|
||||||
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
||||||
|
|
||||||
|
private final DeviceTypeGrantsService deviceTypeGrantsService;
|
||||||
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +97,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
@Override
|
@Override
|
||||||
public TableDataInfo<Device> queryAll(DeviceQueryCriteria criteria, Page<Device> page) throws IOException {
|
public TableDataInfo<Device> queryAll(DeviceQueryCriteria criteria, Page<Device> page) throws IOException {
|
||||||
|
|
||||||
// criteria.setCustomerId(LoginHelper.getUserId());
|
|
||||||
criteria.setCurrentOwnerId(LoginHelper.getUserId());
|
criteria.setCurrentOwnerId(LoginHelper.getUserId());
|
||||||
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
||||||
|
|
||||||
@ -100,7 +107,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return PageUtil.toPage(devices);
|
|
||||||
return new TableDataInfo<Device>(records, devices.getTotal());
|
return new TableDataInfo<Device>(records, devices.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,43 +129,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> 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<DeviceType> 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);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增设备
|
* 新增设备
|
||||||
*
|
*
|
||||||
@ -187,15 +156,15 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
|
|
||||||
// 转换对象并插入数据库
|
// 转换对象并插入数据库
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
|
BeanUtil.copyProperties(deviceForm, device, true);
|
||||||
|
device.setDeviceNo(createDeviceNo());
|
||||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
device.setCurrentOwnerId(loginUser.getUserId());
|
device.setCurrentOwnerId(loginUser.getUserId());
|
||||||
device.setOriginalOwnerId(loginUser.getUserId());
|
device.setOriginalOwnerId(loginUser.getUserId());
|
||||||
device.setCreateByName(loginUser.getNickname());
|
device.setCreateByName(loginUser.getNickname());
|
||||||
device.setTypeName(deviceTypes.getTypeName());
|
device.setTypeName(deviceTypes.getTypeName());
|
||||||
device.setDeviceType(deviceTypes.getId());
|
device.setDeviceType(deviceTypes.getId());
|
||||||
BeanUtil.copyProperties(deviceForm, device, true);
|
|
||||||
|
|
||||||
device.setDeviceNo(createDeviceNo());
|
|
||||||
deviceMapper.insert(device);
|
deviceMapper.insert(device);
|
||||||
|
|
||||||
// 新增设备类型记录
|
// 新增设备类型记录
|
||||||
@ -208,16 +177,18 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
// 接收者
|
// 接收者
|
||||||
assignments.setAssigneeId(loginUser.getUserId());
|
assignments.setAssigneeId(loginUser.getUserId());
|
||||||
assignments.setActive(DeviceActiveStatusEnum.ACTIVE.getCode());
|
assignments.setActive(DeviceActiveStatusEnum.ACTIVE.getCode());
|
||||||
String lever = loginUser.getUserId() + ":";
|
String lever = USER_ID_SEPARATOR + loginUser.getUserId();
|
||||||
assignments.setLever(lever);
|
assignments.setLever(lever);
|
||||||
deviceAssignmentsService.save(assignments);
|
deviceAssignmentsService.save(assignments);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createDeviceNo() {
|
private String createDeviceNo() {
|
||||||
String uuidStr = UUID.fastUUID().toString(); // 获取带 - 的标准格式字符串
|
String uuidStr = UUID.fastUUID().toString(); // 获取带 - 的标准格式字符串
|
||||||
return uuidStr.replaceAll("-", "");
|
return uuidStr.replaceAll("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新设备信息
|
* 更新设备信息
|
||||||
*
|
*
|
||||||
@ -323,139 +294,108 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
*
|
*
|
||||||
* @param customerVo
|
* @param customerVo
|
||||||
*/
|
*/
|
||||||
// @Override
|
|
||||||
// @Transactional(rollbackFor = Exception.class)
|
|
||||||
// public void assignCustomer1(CustomerVo customerVo) {
|
|
||||||
// List<Long> deviceIds = customerVo.getDeviceIds();
|
|
||||||
// Long customerId = customerVo.getCustomerId();
|
|
||||||
//
|
|
||||||
// Customer customer = customerMapper.queryCustomerById(customerId, LoginHelper.getLoginUser().getPid());
|
|
||||||
// if (customer == null) {
|
|
||||||
// throw new RuntimeException("待分配的客户不存在!!!");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// List<Long> invalidIds = new ArrayList<>();
|
|
||||||
// List<Device> 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
|
@Override
|
||||||
public void assignCustomer(CustomerVo customerVo) {
|
|
||||||
List<Long> deviceIds = customerVo.getDeviceIds();
|
|
||||||
Long customerId = customerVo.getCustomerId();
|
|
||||||
|
|
||||||
Customer customer = customerMapper.queryCustomerById(customerId, LoginHelper.getLoginUser().getPid());
|
|
||||||
if (customer == null) {
|
|
||||||
throw new RuntimeException("待分配的客户不存在!!!");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Device> devicesToAssign = new ArrayList<>();
|
|
||||||
List<Long> invalidIds = 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());
|
|
||||||
devicesToAssign.add(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!invalidIds.isEmpty()) {
|
|
||||||
throw new RuntimeException("以下设备无法分配(ID 不存在或无权限): " + invalidIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 批量处理设备分配
|
|
||||||
batchAssignDevices(devicesToAssign, customer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchAssignDevices(List<Device> devicesToAssign, Customer customer) {
|
public void assignCustomer(CustomerVo customerVo) {
|
||||||
Long userId = LoginHelper.getUserId();
|
|
||||||
SnowflakeGenerator snowflakeGenerator = new SnowflakeGenerator();
|
if (customerVo.getDeviceIds().isEmpty() || customerVo.getCustomerId() == null) {
|
||||||
for (Device device : devicesToAssign) {
|
throw new RuntimeException("请选择设备或客户");
|
||||||
if (device.getDeviceType() == null) {
|
|
||||||
throw new RuntimeException("设备类型有问题!!! ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceMapper.updateById(device);
|
// 获取当前登录用户
|
||||||
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
|
// 获取分配用户信息
|
||||||
|
Customer assignUser = customerMapper.selectById(customerVo.getCustomerId());
|
||||||
|
// 获取分配设备信息
|
||||||
|
List<DeviceAssignments> assignments = deviceAssignmentsMapper.selectByIds(customerVo.getDeviceIds());
|
||||||
|
|
||||||
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
// 批量更新设备状态
|
||||||
DeviceType assignType = deviceTypeMapper.getAssignType(device.getDeviceType(), customer.getCustomerId());
|
List<DeviceTypeGrants> deviceTypeGrants = new ArrayList<>();
|
||||||
|
for (DeviceAssignments assignment : assignments) {
|
||||||
|
Device device = deviceMapper.selectById(assignment.getDeviceId());
|
||||||
|
|
||||||
Long next = snowflakeGenerator.next();
|
// 如果设备已分配给需要分配的客户,则跳过
|
||||||
|
DeviceAssignmentQuery dq = DeviceAssignmentQuery.builder().deviceId(device.getId()).assigneeId(customerVo.getCustomerId())
|
||||||
device.setOriginalDeviceId(device.getId());
|
.active(DeviceActiveStatusEnum.ACTIVE.getCode()).lever(assignment.getLever() + USER_ID_SEPARATOR).build();
|
||||||
device.setCurrentOwnerId(customer.getCustomerId());
|
// 查询分配
|
||||||
device.setOriginalOwnerId(device.getCurrentOwnerId());
|
List<DeviceAssignments> assignmentsList = deviceAssignmentsMapper.deviceAssignmentsMapper(dq);
|
||||||
device.setCustomerId(null);
|
if (CollectionUtil.isNotEmpty(assignmentsList)) {
|
||||||
device.setCustomerName("");
|
log.info("设备 {} 已分配给客户 {}", device.getDeviceName(), device.getCustomerName());
|
||||||
device.setId(next);
|
continue;
|
||||||
|
|
||||||
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);
|
// 更改分配客户
|
||||||
|
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<DeviceAssignments> 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<DeviceTypeGrants>().eq(DeviceTypeGrants::getDeviceTypeId, device.getId()));
|
||||||
|
if (dtg != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 创建并保存设备类型授权记录
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceTypeGrantsService.saveBatch(deviceTypeGrants);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建并保存设备类型授权记录
|
||||||
|
*
|
||||||
|
* @param device 当前设备对象
|
||||||
|
* @param currentUser 当前登录用户
|
||||||
|
* @param customerVo 客户信息
|
||||||
|
* @param deviceTypeGrants 授权记录集合
|
||||||
|
*/
|
||||||
|
private void createAndSaveDeviceTypeGrants(Device device, LoginUser currentUser, CustomerVo customerVo, List<DeviceTypeGrants> 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<DeviceMapper, Device> impleme
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<AppDeviceVo> queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
public TableDataInfo<AppDeviceVo> queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||||
Long userId = AppLoginHelper.getUserId();
|
Long userId = AppLoginHelper.getUserId();
|
||||||
@ -544,7 +485,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||||
deviceUpdateWrapper.eq("id", device.getId())
|
deviceUpdateWrapper.eq("id", device.getId())
|
||||||
.set("binding_status", BindingStatusEnum.BOUND.getCode())
|
.set("binding_status", BindingStatusEnum.BOUND.getCode())
|
||||||
.set("binding_user_id",userId);;
|
.set("binding_user_id", userId);
|
||||||
|
;
|
||||||
|
|
||||||
return baseMapper.update(null, deviceUpdateWrapper);
|
return baseMapper.update(null, deviceUpdateWrapper);
|
||||||
} else if (mode == CommunicationModeEnum.BLUETOOTH.getValue()) {
|
} else if (mode == CommunicationModeEnum.BLUETOOTH.getValue()) {
|
||||||
|
@ -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<DeviceTypeGrantsMapper, DeviceTypeGrants>
|
||||||
|
implements DeviceTypeGrantsService {
|
||||||
|
|
||||||
|
}
|
@ -14,6 +14,32 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
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
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询设备分配信息 -->
|
||||||
|
<select id="deviceAssignmentsMapper" resultType="com.fuyuanshen.equipment.domain.DeviceAssignments"
|
||||||
|
parameterType="com.fuyuanshen.equipment.domain.query.DeviceAssignmentQuery">
|
||||||
|
SELECT *
|
||||||
|
FROM device_assignments
|
||||||
|
<where>
|
||||||
|
<if test="query.deviceId != null">
|
||||||
|
AND device_id = #{query.deviceId}
|
||||||
|
</if>
|
||||||
|
<if test="query.assigneeId != null">
|
||||||
|
AND assignee_id = #{query.assigneeId}
|
||||||
|
</if>
|
||||||
|
<if test="query.active != null">
|
||||||
|
AND active = #{query.active}
|
||||||
|
</if>
|
||||||
|
<if test="query.assignerId != null">
|
||||||
|
AND assigner_id = #{query.assignerId}
|
||||||
|
</if>
|
||||||
|
<if test="query.lever != null">
|
||||||
|
AND lever LIKE CONCAT('%', #{query.lever}, '%')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -77,11 +77,12 @@
|
|||||||
select
|
select
|
||||||
da.id AS id,d.device_name,
|
da.id AS id,d.device_name,
|
||||||
d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei,
|
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.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
|
da.create_time AS create_time , da.assigner_name AS createByName , da.id AS assignId
|
||||||
from device d
|
from device d
|
||||||
LEFT JOIN device_type t ON d.device_type = t.id
|
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
|
LEFT JOIN device_assignments da ON da.device_id = d.id
|
||||||
<where>
|
<where>
|
||||||
<!-- 时间范围等其他条件保持原样 -->
|
<!-- 时间范围等其他条件保持原样 -->
|
||||||
|
Reference in New Issue
Block a user