|
@@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 硬件Service业务层处理
|
|
* 硬件Service业务层处理
|
|
@@ -40,6 +39,8 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
private IIsLocksetService iIsLocksetService;
|
|
private IIsLocksetService iIsLocksetService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IIsJobTicketLocksetService iIsJobTicketLocksetService;
|
|
private IIsJobTicketLocksetService iIsJobTicketLocksetService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsHardwareService isHardwareService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean updateTicketKetStatus(UpdateKeyStatusDTO dto) {
|
|
public Boolean updateTicketKetStatus(UpdateKeyStatusDTO dto) {
|
|
@@ -92,9 +93,36 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean updateTicketLockTake(List<TakeTicketLockDTO> list) {
|
|
public Boolean updateTicketLockTake(List<TakeTicketLockDTO> list) {
|
|
|
- Assert.notNull(list.get(0).getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
|
|
Assert.isFalse(list.isEmpty(), "请取出至少一把挂锁!");
|
|
Assert.isFalse(list.isEmpty(), "请取出至少一把挂锁!");
|
|
|
- int size = list.size();
|
|
|
|
|
|
|
+ // 情况复杂,遍历处理吧
|
|
|
|
|
+ for (TakeTicketLockDTO dto : list) {
|
|
|
|
|
+ Assert.notBlank(dto.getLockNfc(), "挂锁nfc缺失!");
|
|
|
|
|
+ Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
|
|
+ Assert.notBlank(dto.getSerialNumber(), "请告知归还到哪一个柜子!");
|
|
|
|
|
+ // 1.查询挂锁信息
|
|
|
|
|
+ IsLock lock = iIsLockService.getOne(Wrappers.<IsLock>lambdaQuery()
|
|
|
|
|
+ .eq(IsLock::getLockNfc, dto.getLockNfc()));
|
|
|
|
|
+ Assert.notNull(lock, "该nfc无对应的挂锁信息!");
|
|
|
|
|
+ // 1.1通过序列号查询柜子信息
|
|
|
|
|
+ IsHardware isHardware = isHardwareService.getOne(Wrappers.<IsHardware>lambdaQuery()
|
|
|
|
|
+ .eq(IsHardware::getSerialNumber, dto.getSerialNumber()));
|
|
|
|
|
+ Assert.notNull(isHardware, "该序列号无对应的硬件信息!");
|
|
|
|
|
+ // 2.获取本次作业票产生的和挂锁关联的数据,按照从上到下的顺序,取一个可以使用的
|
|
|
|
|
+ IsJobTicketLock isJobTicketLock = iIsJobTicketLockService.getOne(Wrappers.<IsJobTicketLock>lambdaQuery()
|
|
|
|
|
+ .eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
|
|
|
+ .isNull(IsJobTicketLock::getLockId)
|
|
|
|
|
+ .orderByAsc(IsJobTicketLock::getRecordId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ Assert.notNull(isJobTicketLock, "无初始化数据来提供给该挂锁更新");
|
|
|
|
|
+ // 1.2开始补充该条数据
|
|
|
|
|
+ isJobTicketLock.setLockId(lock.getLockId());
|
|
|
|
|
+ isJobTicketLock.setFromHardwareId(isHardware.getId());
|
|
|
|
|
+ isJobTicketLock.setLockStatus(LockStatusEnum.NOT_LOCK.status);
|
|
|
|
|
+ iIsJobTicketLockService.updateById(isJobTicketLock);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /*int size = list.size();
|
|
|
List<String> nfcList = list.stream().map(TakeTicketLockDTO::getLockNfc).collect(Collectors.toList());
|
|
List<String> nfcList = list.stream().map(TakeTicketLockDTO::getLockNfc).collect(Collectors.toList());
|
|
|
Assert.isFalse(nfcList.isEmpty() || size != nfcList.size(), "钥匙NFC不可为空!");
|
|
Assert.isFalse(nfcList.isEmpty() || size != nfcList.size(), "钥匙NFC不可为空!");
|
|
|
// 1.查询挂锁信息
|
|
// 1.查询挂锁信息
|
|
@@ -121,25 +149,29 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
isJobTicketLock.setLockStatus(LockStatusEnum.NOT_LOCK.status);
|
|
isJobTicketLock.setLockStatus(LockStatusEnum.NOT_LOCK.status);
|
|
|
}
|
|
}
|
|
|
// 4.开始批量更新
|
|
// 4.开始批量更新
|
|
|
- return iIsJobTicketLockService.updateBatchById(jobTicketLockList);
|
|
|
|
|
|
|
+ iIsJobTicketLockService.updateBatchById(jobTicketLockList);*/
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean updateTicketLockReturn(ReturnTicketLockDTO dto) {
|
|
public Boolean updateTicketLockReturn(ReturnTicketLockDTO dto) {
|
|
|
// Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
|
|
// Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
Assert.notBlank(dto.getLockNfc(), "挂锁nfc缺失!");
|
|
Assert.notBlank(dto.getLockNfc(), "挂锁nfc缺失!");
|
|
|
- Assert.notNull(dto.getToHardwareId(), "请告知归还到哪一个柜子!");
|
|
|
|
|
|
|
+ Assert.notBlank(dto.getSerialNumber(), "请告知归还到哪一个柜子!");
|
|
|
// 1.通过nfc查询挂锁信息
|
|
// 1.通过nfc查询挂锁信息
|
|
|
IsLock lock = iIsLockService.getOne(Wrappers.<IsLock>lambdaQuery()
|
|
IsLock lock = iIsLockService.getOne(Wrappers.<IsLock>lambdaQuery()
|
|
|
.eq(IsLock::getLockNfc, dto.getLockNfc()));
|
|
.eq(IsLock::getLockNfc, dto.getLockNfc()));
|
|
|
- Assert.notNull(lock, "该nfc无对应的挂锁信息");
|
|
|
|
|
|
|
+ Assert.notNull(lock, "该nfc无对应的挂锁信息!");
|
|
|
|
|
+ // 1.1通过序列号查询柜子信息
|
|
|
|
|
+ IsHardware isHardware = isHardwareService.getOne(Wrappers.<IsHardware>lambdaQuery().eq(IsHardware::getSerialNumber, dto.getSerialNumber()));
|
|
|
|
|
+ Assert.notNull(isHardware, "该序列号无对应的硬件信息!");
|
|
|
// 2.开始更新归还信息
|
|
// 2.开始更新归还信息
|
|
|
if (dto.getTicketId() != null) {
|
|
if (dto.getTicketId() != null) {
|
|
|
// 2.1登陆后归还
|
|
// 2.1登陆后归还
|
|
|
iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
|
.eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
.eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
|
.eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
.eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
- .set(IsJobTicketLock::getToHardwareId, dto.getToHardwareId())
|
|
|
|
|
|
|
+ .set(IsJobTicketLock::getToHardwareId, isHardware.getId())
|
|
|
.set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
|
|
.set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
|
|
|
} else {
|
|
} else {
|
|
|
// 2.2不登陆状态下归还
|
|
// 2.2不登陆状态下归还
|
|
@@ -153,7 +185,7 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
// 说明找到的就是
|
|
// 说明找到的就是
|
|
|
iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
|
.eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
.eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
- .set(IsJobTicketLock::getToHardwareId, dto.getToHardwareId())
|
|
|
|
|
|
|
+ .set(IsJobTicketLock::getToHardwareId, isHardware.getId())
|
|
|
.set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
|
|
.set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
|
|
|
} else {
|
|
} else {
|
|
|
// 出现了多条对应
|
|
// 出现了多条对应
|
|
@@ -212,7 +244,11 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
// 1.查询辅件的详情
|
|
// 1.查询辅件的详情
|
|
|
IsLockset lockset = iIsLocksetService.getOne(Wrappers.<IsLockset>lambdaQuery().eq(IsLockset::getLocksetNfc, dto.getLocksetNfc()));
|
|
IsLockset lockset = iIsLocksetService.getOne(Wrappers.<IsLockset>lambdaQuery().eq(IsLockset::getLocksetNfc, dto.getLocksetNfc()));
|
|
|
Assert.notNull(lockset, dto.getLocksetNfc() + "无对应的辅件信息!");
|
|
Assert.notNull(lockset, dto.getLocksetNfc() + "无对应的辅件信息!");
|
|
|
- // 1.1获取该辅件的类型,找到is_job_ticket_lockset有没有对应的,可能会有多条,取其中一条即可,
|
|
|
|
|
|
|
+ // 1.1通过序列号查询柜子信息
|
|
|
|
|
+ IsHardware isHardware = isHardwareService.getOne(Wrappers.<IsHardware>lambdaQuery()
|
|
|
|
|
+ .eq(IsHardware::getSerialNumber, dto.getSerialNumber()));
|
|
|
|
|
+ Assert.notNull(isHardware, "该序列号无对应的硬件信息!");
|
|
|
|
|
+ // 1.2获取该辅件的类型,找到is_job_ticket_lockset有没有对应的,可能会有多条,取其中一条即可,
|
|
|
IsJobTicketLockset jobTicketLockset = iIsJobTicketLocksetService.getOne(Wrappers.<IsJobTicketLockset>lambdaQuery()
|
|
IsJobTicketLockset jobTicketLockset = iIsJobTicketLocksetService.getOne(Wrappers.<IsJobTicketLockset>lambdaQuery()
|
|
|
.eq(IsJobTicketLockset::getJobTicketId, dto.getTicketId())
|
|
.eq(IsJobTicketLockset::getJobTicketId, dto.getTicketId())
|
|
|
// 未使用过的数据
|
|
// 未使用过的数据
|
|
@@ -221,9 +257,9 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
.orderByAsc(IsJobTicketLockset::getRecordId)
|
|
.orderByAsc(IsJobTicketLockset::getRecordId)
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
|
Assert.notNull(jobTicketLockset, "无初始化数据来提供给该辅件更新");
|
|
Assert.notNull(jobTicketLockset, "无初始化数据来提供给该辅件更新");
|
|
|
- // 1.2开始补充该条数据
|
|
|
|
|
|
|
+ // 1.3开始补充该条数据
|
|
|
jobTicketLockset.setLocksetId(lockset.getLocksetId());
|
|
jobTicketLockset.setLocksetId(lockset.getLocksetId());
|
|
|
- jobTicketLockset.setFromHardwareId(dto.getFromHardwareId());
|
|
|
|
|
|
|
+ jobTicketLockset.setFromHardwareId(isHardware.getId());
|
|
|
jobTicketLockset.setLocksetStatus(LocksetStatusEnum.TAKED.status);
|
|
jobTicketLockset.setLocksetStatus(LocksetStatusEnum.TAKED.status);
|
|
|
jobTicketLockset.setCollectTime(new Date());
|
|
jobTicketLockset.setCollectTime(new Date());
|
|
|
iIsJobTicketLocksetService.updateById(jobTicketLockset);
|
|
iIsJobTicketLocksetService.updateById(jobTicketLockset);
|
|
@@ -252,4 +288,45 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
.set(IsJobTicketLockset::getLocksetStatus, LocksetStatusEnum.USING.status));
|
|
.set(IsJobTicketLockset::getLocksetStatus, LocksetStatusEnum.USING.status));
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateLocksetReturn(ReturnLocksetDTO dto) {
|
|
|
|
|
+ Assert.notBlank(dto.getLocksetNfc(), "辅件nfc缺失!");
|
|
|
|
|
+ Assert.notBlank(dto.getSerialNumber(), "请告知归还到哪一个柜子!");
|
|
|
|
|
+ // 1.通过nfc查询辅件信息
|
|
|
|
|
+ IsLockset lockset = iIsLocksetService.getOne(Wrappers.<IsLockset>lambdaQuery()
|
|
|
|
|
+ .eq(IsLockset::getLocksetNfc, dto.getLocksetNfc()));
|
|
|
|
|
+ Assert.notNull(lockset, "该nfc无对应的辅件信息!");
|
|
|
|
|
+ // 1.1通过序列号查询柜子信息
|
|
|
|
|
+ IsHardware isHardware = isHardwareService.getOne(Wrappers.<IsHardware>lambdaQuery().eq(IsHardware::getSerialNumber, dto.getSerialNumber()));
|
|
|
|
|
+ Assert.notNull(isHardware, "该序列号无对应的硬件信息!");
|
|
|
|
|
+ // 2.开始更新归还信息
|
|
|
|
|
+ if (dto.getTicketId() != null) {
|
|
|
|
|
+ // 2.1登陆后归还
|
|
|
|
|
+ iIsJobTicketLocksetService.update(Wrappers.<IsJobTicketLockset>lambdaUpdate()
|
|
|
|
|
+ .eq(IsJobTicketLockset::getJobTicketId, dto.getTicketId())
|
|
|
|
|
+ .eq(IsJobTicketLockset::getLocksetId, lockset.getLocksetId())
|
|
|
|
|
+ .set(IsJobTicketLockset::getToHardwareId, isHardware.getId())
|
|
|
|
|
+ .set(IsJobTicketLockset::getLocksetStatus, LocksetStatusEnum.RETURNED.status));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 2.2不登陆状态下归还
|
|
|
|
|
+ // 查一下哪个作业票用了这个挂锁,而且还没有完成
|
|
|
|
|
+ List<IsJobTicketLockset> jobTicketLocksetList = iIsJobTicketLocksetService.list(Wrappers.<IsJobTicketLockset>lambdaQuery()
|
|
|
|
|
+ .eq(IsJobTicketLockset::getLocksetId, lockset.getLocksetId())
|
|
|
|
|
+ .ne(IsJobTicketLockset::getLocksetStatus, LocksetStatusEnum.RETURNED.status));
|
|
|
|
|
+ if (jobTicketLocksetList.isEmpty()) {
|
|
|
|
|
+ log.error("当前辅件未找到关联的作业票, nfc: {}, name : {}", dto.getLocksetNfc(), lockset.getLocksetName());
|
|
|
|
|
+ } else if (jobTicketLocksetList.size() == 1) {
|
|
|
|
|
+ // 说明找到的就是
|
|
|
|
|
+ iIsJobTicketLocksetService.update(Wrappers.<IsJobTicketLockset>lambdaUpdate()
|
|
|
|
|
+ .eq(IsJobTicketLockset::getLocksetId, lockset.getLocksetId())
|
|
|
|
|
+ .set(IsJobTicketLockset::getToHardwareId, isHardware.getId())
|
|
|
|
|
+ .set(IsJobTicketLockset::getLocksetStatus, LocksetStatusEnum.RETURNED.status));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 出现了多条对应
|
|
|
|
|
+ log.error("当前辅件找到多条关联的作业票, nfc: {}, name : {}", dto.getLocksetNfc(), lockset.getLocksetName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|