diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java index 0d196762..71be5103 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java @@ -38,6 +38,7 @@ public class WEBDeviceController extends BaseController { private final WEBDeviceService deviceService; private final DeviceBizService appDeviceService; + /** * @param id * @return @@ -52,14 +53,12 @@ public class WEBDeviceController extends BaseController { } - - /** * 查询设备列表 */ @GetMapping("/list") public TableDataInfo list(DeviceQueryCriteria bo, PageQuery pageQuery) { - return appDeviceService.queryAppDeviceList(bo,pageQuery); + return appDeviceService.queryAppDeviceList(bo, pageQuery); } /** @@ -90,6 +89,7 @@ public class WEBDeviceController extends BaseController { /** * 重命名设备 + * * @param reNameDTO * @return */ diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java index f38a2e88..7e328b8d 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java @@ -1,8 +1,13 @@ package com.fuyuanshen.web.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuyuanshen.app.domain.AppDeviceBindRecord; +import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper; import com.fuyuanshen.equipment.domain.Device; import com.fuyuanshen.equipment.domain.DeviceAssignments; +import com.fuyuanshen.equipment.enums.BindingStatusEnum; import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper; import com.fuyuanshen.equipment.mapper.DeviceMapper; import com.fuyuanshen.web.service.WEBDeviceService; @@ -10,6 +15,7 @@ import com.fuyuanshen.web.service.device.DeviceBizService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * @Description: @@ -25,6 +31,10 @@ public class WEBDeviceServiceImpl extends ServiceImpl impl private final DeviceAssignmentsMapper deviceAssignmentsMapper; + private final AppDeviceBindRecordMapper appDeviceBindRecordMapper; + + private final DeviceMapper deviceMapper; + /** * WEB端解绑设备 @@ -33,6 +43,7 @@ public class WEBDeviceServiceImpl extends ServiceImpl impl * @return */ @Override + @Transactional public int webUnBindDevice(Long id, Long userId) { // 设备端解绑 0:设备端解绑 1:web端解绑 int type = 1; @@ -44,7 +55,18 @@ public class WEBDeviceServiceImpl extends ServiceImpl impl id = deviceAssignments.getDeviceId(); type = 0; } - return appDeviceService.unBindDevice(id, userId, type); + + QueryWrapper deviceId = new QueryWrapper().eq("device_id", id); + + // appDeviceService.unBindDevice(id, userId, type); + UpdateWrapper deviceUpdateWrapper = new UpdateWrapper<>(); + deviceUpdateWrapper.eq("id", id) + .set("binding_user_id", null) + .set("binding_status", BindingStatusEnum.UNBOUND.getCode()) + .set("binding_time", null); + deviceMapper.update(null, deviceUpdateWrapper); + + return appDeviceBindRecordMapper.delete(deviceId); }