forked from dyf/fys-Multi-tenant
删除设备
This commit is contained in:
@ -297,14 +297,18 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
|
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
DeviceAssignments deviceAssignment = deviceAssignmentsMapper.selectById(id);
|
DeviceAssignments deviceAssignment = deviceAssignmentsMapper.selectById(id);
|
||||||
Device deviceType = deviceMapper.selectById(deviceAssignment.getDeviceId());
|
Device device = deviceMapper.selectById(deviceAssignment.getDeviceId());
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(deviceAssignment.getAssigneeName())) {
|
if (StringUtils.isNotEmpty(deviceAssignment.getAssigneeName())) {
|
||||||
throw new BadRequestException(deviceType.getDeviceName() + ":设备已分配,请先解绑设备!!!");
|
throw new BadRequestException(device.getDeviceName() + ":设备已分配,请先解绑设备!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device.getBindingStatus().equals(1)){
|
||||||
|
throw new BadRequestException(device.getDeviceName() + ":设备已绑定,请先解绑设备!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接收者
|
// 接收者
|
||||||
if (Objects.equals(deviceAssignment.getAssigneeId(), deviceType.getOriginalOwnerId())) {
|
if (Objects.equals(deviceAssignment.getAssigneeId(), device.getOriginalOwnerId())) {
|
||||||
invalidIds.add(deviceAssignment.getDeviceId());
|
invalidIds.add(deviceAssignment.getDeviceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,13 +38,19 @@
|
|||||||
|
|
||||||
<!-- 分页查询设备 -->
|
<!-- 分页查询设备 -->
|
||||||
<select id="findAll" resultType="com.fuyuanshen.equipment.domain.Device">
|
<select id="findAll" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||||
select
|
SELECT *
|
||||||
da.id AS id,d.device_name,d.bluetooth_name,d.pub_topic,d.sub_topic,
|
FROM (
|
||||||
d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei,
|
SELECT
|
||||||
d.update_time, dg.id AS device_type, d.remark, d.binding_status,t.type_name AS typeName,
|
da.id AS id, d.device_name, d.bluetooth_name,
|
||||||
da.assignee_id AS customerId, da.assignee_name AS customerName, da.active AS deviceStatus,
|
d.pub_topic, d.sub_topic, d.device_pic,
|
||||||
da.create_time AS create_time , da.assigner_name AS createByName , da.id AS assignId
|
d.device_mac, d.device_sn, d.update_by,
|
||||||
from device d
|
d.device_imei, d.update_time, dg.id AS device_type,
|
||||||
|
d.remark, d.binding_status, t.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,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY d.id ORDER BY da.create_time DESC) AS rn
|
||||||
|
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_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
|
||||||
@ -71,9 +77,12 @@
|
|||||||
AND da.assignee_id = #{criteria.currentOwnerId}
|
AND da.assignee_id = #{criteria.currentOwnerId}
|
||||||
AND dg.customer_id = #{criteria.currentOwnerId}
|
AND dg.customer_id = #{criteria.currentOwnerId}
|
||||||
</where>
|
</where>
|
||||||
ORDER BY da.create_time DESC
|
) AS ranked
|
||||||
|
WHERE rn = 1
|
||||||
|
ORDER BY create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="findAllDevices" resultType="com.fuyuanshen.equipment.domain.Device">
|
<select id="findAllDevices" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||||
select
|
select
|
||||||
d.id, d.customer_id, d.device_name,d.bluetooth_name,
|
d.id, d.customer_id, d.device_name,d.bluetooth_name,
|
||||||
|
Reference in New Issue
Block a user