撤回设备
This commit is contained in:
@ -17,6 +17,9 @@ public class DeviceForm {
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "设备记录ID")
|
||||
private Long assignId;
|
||||
|
||||
@ApiModelProperty(value = "设备类型")
|
||||
private Long deviceType;
|
||||
|
||||
|
@ -146,6 +146,20 @@ public class DeviceController {
|
||||
}
|
||||
|
||||
|
||||
@Log("撤回设备")
|
||||
@ApiOperation("撤回设备")
|
||||
@PostMapping(value = "/withdraw")
|
||||
public ResponseVO<Object> withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
|
||||
try {
|
||||
deviceService.withdrawDevice(deviceForm);
|
||||
} catch (Exception e) {
|
||||
log.error("updateDevice error: " + e.getMessage());
|
||||
return ResponseVO.fail("出错了");
|
||||
}
|
||||
return ResponseVO.success(null);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("设备详情")
|
||||
@GetMapping(value = "/detail/{id}")
|
||||
public ResponseVO<Object> getDevice(@PathVariable Long id) {
|
||||
|
@ -73,6 +73,8 @@ public interface DeviceService extends IService<Device> {
|
||||
*/
|
||||
void assignCustomer(CustomerVo customerVo);
|
||||
|
||||
void withdrawDevice(DeviceForm deviceForm);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
@ -110,5 +112,4 @@ public interface DeviceService extends IService<Device> {
|
||||
*/
|
||||
void unbindDevice(DeviceForm deviceForm);
|
||||
|
||||
|
||||
}
|
||||
|
@ -456,6 +456,30 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 撤回设备
|
||||
*
|
||||
* @param deviceForm
|
||||
*/
|
||||
@Override
|
||||
public void withdrawDevice(DeviceForm deviceForm) {
|
||||
DeviceAssignments assignment = deviceAssignmentsMapper.selectById(deviceForm.getAssignId());
|
||||
// 接收者
|
||||
assignment.setAssigneeName("");
|
||||
deviceAssignmentsMapper.updateById(assignment);
|
||||
|
||||
LambdaQueryWrapper<DeviceAssignments> q1 = new LambdaQueryWrapper<>();
|
||||
q1.eq(DeviceAssignments::getAssignerId, assignment.getAssigneeId())
|
||||
.like(DeviceAssignments::getLever, assignment.getLever())
|
||||
.ne(DeviceAssignments::getId, assignment.getId());
|
||||
|
||||
DeviceAssignments d1 = new DeviceAssignments();
|
||||
d1.setActive(DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
deviceAssignmentsMapper.update(d1, q1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建并保存设备类型授权记录
|
||||
*
|
||||
@ -551,6 +575,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
* @param ids
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAssign(List<Long> ids) {
|
||||
// Step 1: 查询所有传入的设备(根据 ID)
|
||||
List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
|
||||
@ -562,7 +587,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
throw new BadRequestException("已分配的设备不允许删除!!!");
|
||||
}
|
||||
|
||||
deviceAssignmentsMapper.deleteBatchIds(ids);
|
||||
deviceAssignmentsMapper.deleteBatchIds(nonNullCustomerIds);
|
||||
deviceTypeGrantsMapper.delete(new QueryWrapper<DeviceTypeGrants>().in("assignment_id", nonNullCustomerIds));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user