Compare commits
10 Commits
aeaa906bc9
...
dyf-device
Author | SHA1 | Date | |
---|---|---|---|
a7340c744e | |||
3feafc2cd9 | |||
f2921ff12f | |||
ec89dd8c1e | |||
57322c9c87 | |||
7d91426414 | |||
ad06811747 | |||
34188f20dd | |||
0fa0e4ab1b | |||
e321dcd652 |
@ -50,6 +50,12 @@ public class UserQueryCriteria extends BaseEntity {
|
||||
@Schema(name = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
@Schema(name = "帐号状态(0正常 1停用)")
|
||||
private String status;
|
||||
|
||||
@Schema(name = "部门ID")
|
||||
private Long deptId;
|
||||
|
||||
|
@ -58,6 +58,12 @@ public class ConsumerVo extends TenantEntity {
|
||||
@Schema(name = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
@Schema(name = "帐号状态(0正常 1停用)")
|
||||
private String status;
|
||||
|
||||
@Schema(name = "是否为admin账号", hidden = true)
|
||||
private Boolean isAdmin = false;
|
||||
|
||||
|
@ -112,6 +112,11 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCustomer(Customer resources) throws Exception {
|
||||
if (resources.getEnabled()) {
|
||||
resources.setStatus("0");
|
||||
} else {
|
||||
resources.setStatus("1");
|
||||
}
|
||||
saveOrUpdate(resources);
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@
|
||||
<if test="criteria.id != null">
|
||||
and u1.user_id = #{criteria.id}
|
||||
</if>
|
||||
<if test="criteria.enabled != null">
|
||||
and u1.enabled = #{criteria.enabled}
|
||||
<if test="criteria.status != null">
|
||||
and u.status = #{criteria.status}
|
||||
</if>
|
||||
<if test="criteria.deptIds != null and criteria.deptIds.size() != 0">
|
||||
and u1.dept_id in
|
||||
@ -94,7 +94,7 @@
|
||||
<!-- 分页查询客户 -->
|
||||
<select id="findCustomers" resultType="com.fuyuanshen.customer.domain.Customer">
|
||||
select
|
||||
u.user_id as customerId, u.nick_name , u.user_name, u.enabled, u.create_time
|
||||
u.user_id as customerId, u.nick_name , u.user_name, u.enabled, u.create_time,u.status
|
||||
from sys_user u
|
||||
<where>
|
||||
<if test="criteria.ids != null and !criteria.ids.isEmpty()">
|
||||
@ -109,8 +109,8 @@
|
||||
<if test="criteria.blurry != null and criteria.blurry.trim() != ''">
|
||||
and u.nick_name like concat('%', TRIM(#{criteria.blurry}), '%')
|
||||
</if>
|
||||
<if test="criteria.enabled != null">
|
||||
and u.enabled = #{criteria.enabled}
|
||||
<if test="criteria.status != null">
|
||||
and u.status = #{criteria.status}
|
||||
</if>
|
||||
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
||||
and u.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
||||
@ -139,8 +139,8 @@
|
||||
<if test="criteria.blurry != null and criteria.blurry.trim() != ''">
|
||||
and u.nick_name like concat('%', TRIM(#{criteria.blurry}), '%')
|
||||
</if>
|
||||
<if test="criteria.enabled != null">
|
||||
and u.enabled = #{criteria.enabled}
|
||||
<if test="criteria.status != null">
|
||||
and u.status = #{criteria.status}
|
||||
</if>
|
||||
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
||||
and u.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
||||
|
@ -21,6 +21,9 @@ import java.util.Date;
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解
|
||||
public class Device extends TenantEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@Schema(name = "ID")
|
||||
private Long id;
|
||||
@ -29,6 +32,9 @@ public class Device extends TenantEntity {
|
||||
@TableField(exist = false)
|
||||
private Long assignId;
|
||||
|
||||
/**
|
||||
* device_type
|
||||
*/
|
||||
@Schema(name = "设备类型")
|
||||
private Long deviceType;
|
||||
|
||||
@ -100,8 +106,6 @@ public class Device extends TenantEntity {
|
||||
private Integer deviceStatus;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 绑定状态
|
||||
* 0 未绑定
|
||||
@ -117,5 +121,8 @@ public class Device extends TenantEntity {
|
||||
|
||||
private Long bindingUserId;
|
||||
|
||||
/**
|
||||
* 绑定时间
|
||||
*/
|
||||
private Date bindingTime;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public class DeviceAssignments extends TenantEntity {
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
* device_id
|
||||
*/
|
||||
private Long deviceId;
|
||||
|
||||
@ -34,7 +35,7 @@ public class DeviceAssignments extends TenantEntity {
|
||||
private Long fromCustomerId;
|
||||
|
||||
/**
|
||||
* 接收方
|
||||
* 接收方(当前设备所处位置)
|
||||
*/
|
||||
private Long toCustomerId;
|
||||
|
||||
|
@ -58,7 +58,9 @@ public class DeviceExcelImportDTO {
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("设备类型名称")
|
||||
@ColumnWidth(20)
|
||||
private String typeName;
|
||||
|
||||
@ExcelProperty("蓝牙名称")
|
||||
private String bluetoothName;
|
||||
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class AppDeviceVo {
|
||||
public class AppDeviceVo implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@ -39,7 +41,7 @@ public class AppDeviceVo {
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 蓝牙名称
|
||||
* 蓝牙名称
|
||||
*/
|
||||
private String bluetoothName;
|
||||
|
||||
@ -49,4 +51,10 @@ public class AppDeviceVo {
|
||||
* 1 正常
|
||||
*/
|
||||
private Integer deviceStatus;
|
||||
|
||||
/**
|
||||
* 绑定时间
|
||||
*/
|
||||
private Date bindingTime;
|
||||
|
||||
}
|
||||
|
@ -85,6 +85,14 @@ public interface DeviceService extends IService<Device> {
|
||||
*/
|
||||
void unbindDevice(DeviceForm deviceForm);
|
||||
|
||||
|
||||
/**
|
||||
* WEB端查看APP客户设备绑定
|
||||
*
|
||||
* @param bo
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
TableDataInfo<AppDeviceVo> queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery);
|
||||
|
||||
int bindDevice(AppDeviceBo bo);
|
||||
|
@ -100,6 +100,12 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
public TableDataInfo<Device> queryAll(DeviceQueryCriteria criteria, Page<Device> page) throws IOException {
|
||||
|
||||
criteria.setCurrentOwnerId(LoginHelper.getUserId());
|
||||
if (criteria.getDeviceType() != null) {
|
||||
DeviceTypeGrants deviceTypeGrant = deviceTypeGrantsMapper.selectById(criteria.getDeviceType());
|
||||
if (deviceTypeGrant != null) {
|
||||
criteria.setDeviceType(deviceTypeGrant.getDeviceTypeId());
|
||||
}
|
||||
}
|
||||
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
||||
|
||||
List<Device> records = devices.getRecords();
|
||||
@ -141,6 +147,16 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addDevice(DeviceForm deviceForm) throws Exception {
|
||||
|
||||
Device device1 = deviceMapper.selectOne(new QueryWrapper<Device>().eq("device_mac", deviceForm.getDeviceMac()));
|
||||
if (device1 != null) {
|
||||
throw new BadRequestException("设备MAC已存在!!!");
|
||||
}
|
||||
Device device2 = deviceMapper.selectOne(new QueryWrapper<Device>().eq("device_imei", deviceForm.getDeviceImei()));
|
||||
if (device2 != null) {
|
||||
throw new BadRequestException("设备IMEI已存在!!!");
|
||||
}
|
||||
|
||||
DeviceTypeQueryCriteria queryCriteria = new DeviceTypeQueryCriteria();
|
||||
queryCriteria.setDeviceTypeId(deviceForm.getDeviceType());
|
||||
queryCriteria.setCustomerId(LoginHelper.getUserId());
|
||||
@ -319,9 +335,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
List<DeviceTypeGrants> deviceTypeGrants = new ArrayList<>();
|
||||
for (DeviceAssignments assignment : assignments) {
|
||||
|
||||
if (assignment.getToCustomerId() != null) {
|
||||
if (assignment.getToCustomerId() != null && assignment.getToCustomerId() != 0L) {
|
||||
log.info("设备已经分配客户!!!");
|
||||
continue;
|
||||
throw new RuntimeException("设备已经分配客户!!!");
|
||||
}
|
||||
|
||||
Device device = deviceMapper.selectById(assignment.getDeviceId());
|
||||
@ -412,54 +428,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 撤回设备
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
// @Override
|
||||
// public void withdrawDevice(List<Long> ids) {
|
||||
// ids.forEach((id) -> {
|
||||
// List<Device> deviceChain = getDeviceChain(id);
|
||||
// deviceChain.forEach((device) -> {
|
||||
// device.setDeviceStatus(DeviceStatusEnum.INVALID.getCode());
|
||||
// deviceMapper.updateById(device);
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// ids.forEach((id) -> {
|
||||
// Device device = new Device();
|
||||
// device.setId(id);
|
||||
// device.setCustomerId(null);
|
||||
// device.setCustomerName("");
|
||||
// deviceMapper.updateById(device);
|
||||
// });
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public List<Device> getDeviceChain(Long originalDeviceId) {
|
||||
// List<Device> chain = new ArrayList<>();
|
||||
// Set<Long> visited = new HashSet<>(); // 防止循环引用
|
||||
// findNext(chain, visited, originalDeviceId);
|
||||
// return chain;
|
||||
// }
|
||||
//
|
||||
// private void findNext(List<Device> chain, Set<Long> visited, Long currentOriginalDeviceId) {
|
||||
// if (visited.contains(currentOriginalDeviceId)) {
|
||||
// log.info("检测到循环引用,终止递归");
|
||||
// return;
|
||||
// }
|
||||
// visited.add(currentOriginalDeviceId);
|
||||
//
|
||||
// List<Device> devices = deviceMapper.findByOriginalDeviceId(currentOriginalDeviceId);
|
||||
// for (Device device : devices) {
|
||||
// chain.add(device);
|
||||
// findNext(chain, visited, device.getId());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 撤回设备
|
||||
*
|
||||
@ -474,7 +442,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
Device device = deviceMapper.selectById(assignment.getDeviceId());
|
||||
// 接收者
|
||||
assignment.setAssigneeName("");
|
||||
assignment.setToCustomerId(null);
|
||||
assignment.setToCustomerId(0L);
|
||||
deviceAssignmentsMapper.updateById(assignment);
|
||||
|
||||
// 获取所有已分配的设备
|
||||
@ -502,7 +470,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WEB端查看APP客户设备绑定
|
||||
*
|
||||
* @param bo
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<AppDeviceVo> queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||
if (bo.getBindingUserId() == null) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fuyuanshen.equipment.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
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;
|
||||
@ -10,11 +12,13 @@ import com.fuyuanshen.common.core.utils.PageUtil;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||
import com.fuyuanshen.equipment.domain.DeviceTypeGrants;
|
||||
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||
@ -41,6 +45,7 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
||||
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
||||
|
||||
|
||||
/**
|
||||
@ -155,30 +160,33 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(List<Long> ids) {
|
||||
|
||||
List<Long> deviceTypeId = new ArrayList<>();
|
||||
|
||||
for (Long id : ids) {
|
||||
DeviceTypeGrants deviceTypeGrant = deviceTypeGrantsMapper.selectById(id);
|
||||
|
||||
// List<DeviceTypeGrants> deviceTypeGrants = deviceTypeGrantsMapper.selectList(new QueryWrapper<DeviceTypeGrants>()
|
||||
// .eq("device_type_id", deviceTypeGrant.getDeviceTypeId()));
|
||||
|
||||
// List<DeviceTypeGrants> deviceAssignments = deviceTypeGrantsMapper.selectList(new QueryWrapper<DeviceTypeGrants>()
|
||||
// .eq("device_id", deviceTypeGrant.getDeviceTypeId()));
|
||||
|
||||
// if (CollectionUtil.isNotEmpty(deviceAssignments)) {
|
||||
// throw new RuntimeException("该设备类型已绑定设备,无法删除");
|
||||
// }
|
||||
// Device device = deviceMapper.selectById(deviceTypeGrant.getDeviceTypeId());
|
||||
|
||||
List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
|
||||
.eq("device_type", deviceTypeGrant.getDeviceTypeId()));
|
||||
if (CollectionUtil.isNotEmpty(devices)) {
|
||||
throw new RuntimeException("该设备类型已绑定设备,无法删除!!!");
|
||||
}
|
||||
deviceTypeId.add(deviceTypeGrant.getDeviceTypeId());
|
||||
}
|
||||
|
||||
deviceTypeGrantsMapper.deleteByIds(ids);
|
||||
//
|
||||
// List<Long> invalidIds = new ArrayList<>();
|
||||
// List<Long> invalidId2 = new ArrayList<>();
|
||||
// for (Long id : ids) {
|
||||
// DeviceType deviceType = deviceTypeMapper.selectById(id);
|
||||
// if (deviceType == null || !Objects.equals(deviceType.getOwnerCustomerId(), LoginHelper.getUserId())) {
|
||||
// invalidIds.add(id);
|
||||
// }
|
||||
// DeviceQueryCriteria deviceQueryCriteria = new DeviceQueryCriteria();
|
||||
// deviceQueryCriteria.setDeviceType(id);
|
||||
// List<Device> devices = deviceMapper.findAll(deviceQueryCriteria);
|
||||
// if (!devices.isEmpty()) {
|
||||
// invalidId2.add(id);
|
||||
// }
|
||||
// }
|
||||
// if (!invalidIds.isEmpty()) {
|
||||
// throw new RuntimeException("以下设备类型无法删除(ID 不存在或无权限): " + invalidIds);
|
||||
// }
|
||||
// if (!invalidId2.isEmpty()) {
|
||||
// throw new RuntimeException("以下设备类型无法删除(已绑定设备): " + invalidId2);
|
||||
// }
|
||||
//
|
||||
// deviceTypeMapper.deleteByIds(ids);
|
||||
deviceTypeMapper.deleteByIds(deviceTypeId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,7 +138,8 @@
|
||||
d.device_pic,
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name
|
||||
d.bluetooth_name,
|
||||
d.binding_time
|
||||
from device d
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
where d.binding_user_id = #{criteria.bindingUserId}
|
||||
|
Reference in New Issue
Block a user