|
@@ -4,7 +4,10 @@ import cn.hutool.core.lang.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.ktg.iscs.domain.*;
|
|
import com.ktg.iscs.domain.*;
|
|
|
import com.ktg.iscs.domain.dto.hardwareApi.*;
|
|
import com.ktg.iscs.domain.dto.hardwareApi.*;
|
|
|
|
|
+import com.ktg.iscs.domain.enums.LockStatusEnum;
|
|
|
|
|
+import com.ktg.iscs.domain.enums.LocksetStatusEnum;
|
|
|
import com.ktg.iscs.service.*;
|
|
import com.ktg.iscs.service.*;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -18,6 +21,7 @@ import java.util.stream.Collectors;
|
|
|
* @author cgj
|
|
* @author cgj
|
|
|
* @date 2024-10-16
|
|
* @date 2024-10-16
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class HardwareApiServiceImpl implements HardwareApiService {
|
|
public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -32,6 +36,10 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
private IIsJobTicketLockService iIsJobTicketLockService;
|
|
private IIsJobTicketLockService iIsJobTicketLockService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IIsIsolationPointService iIsIsolationPointService;
|
|
private IIsIsolationPointService iIsIsolationPointService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsLocksetService iIsLocksetService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsJobTicketLocksetService iIsJobTicketLocksetService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean updateTicketKetStatus(UpdateKeyStatusDTO dto) {
|
|
public Boolean updateTicketKetStatus(UpdateKeyStatusDTO dto) {
|
|
@@ -110,7 +118,7 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
IsJobTicketLock isJobTicketLock = jobTicketLockList.get(i);
|
|
IsJobTicketLock isJobTicketLock = jobTicketLockList.get(i);
|
|
|
isJobTicketLock.setLockId(list.get(i).getLockId());
|
|
isJobTicketLock.setLockId(list.get(i).getLockId());
|
|
|
isJobTicketLock.setFromHardwareId(list.get(i).getFromHardwareId());
|
|
isJobTicketLock.setFromHardwareId(list.get(i).getFromHardwareId());
|
|
|
- isJobTicketLock.setLockStatus("1");
|
|
|
|
|
|
|
+ isJobTicketLock.setLockStatus(LockStatusEnum.NOT_LOCK.status);
|
|
|
}
|
|
}
|
|
|
// 4.开始批量更新
|
|
// 4.开始批量更新
|
|
|
return iIsJobTicketLockService.updateBatchById(jobTicketLockList);
|
|
return iIsJobTicketLockService.updateBatchById(jobTicketLockList);
|
|
@@ -118,7 +126,7 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
|
|
|
|
|
@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.notNull(dto.getToHardwareId(), "请告知归还到哪一个柜子!");
|
|
|
// 1.通过nfc查询挂锁信息
|
|
// 1.通过nfc查询挂锁信息
|
|
@@ -126,11 +134,32 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
.eq(IsLock::getLockNfc, dto.getLockNfc()));
|
|
.eq(IsLock::getLockNfc, dto.getLockNfc()));
|
|
|
Assert.notNull(lock, "该nfc无对应的挂锁信息");
|
|
Assert.notNull(lock, "该nfc无对应的挂锁信息");
|
|
|
// 2.开始更新归还信息
|
|
// 2.开始更新归还信息
|
|
|
- iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
|
|
|
- .eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
|
|
|
- .eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
|
|
- .set(IsJobTicketLock::getToHardwareId, dto.getToHardwareId())
|
|
|
|
|
- .set(IsJobTicketLock::getLockStatus, "4"));
|
|
|
|
|
|
|
+ if (dto.getTicketId() != null) {
|
|
|
|
|
+ // 2.1登陆后归还
|
|
|
|
|
+ iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
|
|
|
+ .eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
|
|
|
+ .eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
|
|
+ .set(IsJobTicketLock::getToHardwareId, dto.getToHardwareId())
|
|
|
|
|
+ .set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 2.2不登陆状态下归还
|
|
|
|
|
+ // 查一下哪个作业票用了这个挂锁,而且还没有完成
|
|
|
|
|
+ List<IsJobTicketLock> jobTicketLockList = iIsJobTicketLockService.list(Wrappers.<IsJobTicketLock>lambdaQuery()
|
|
|
|
|
+ .eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
|
|
+ .ne(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
|
|
|
|
|
+ if (jobTicketLockList.isEmpty()) {
|
|
|
|
|
+ log.error("当前挂锁未找到关联的作业票, nfc: {}, name : {}", dto.getLockNfc(), lock.getLockName());
|
|
|
|
|
+ } else if (jobTicketLockList.size() == 1) {
|
|
|
|
|
+ // 说明找到的就是
|
|
|
|
|
+ iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
|
|
|
+ .eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
|
|
+ .set(IsJobTicketLock::getToHardwareId, dto.getToHardwareId())
|
|
|
|
|
+ .set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 出现了多条对应
|
|
|
|
|
+ log.error("当前挂锁找到多条关联的作业票, nfc: {}, name : {}", dto.getLockNfc(), lock.getLockName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -152,7 +181,7 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
.eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
.eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
|
.eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
.eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
.set(IsJobTicketLock::getIsolationPointId, point.getPointId())
|
|
.set(IsJobTicketLock::getIsolationPointId, point.getPointId())
|
|
|
- .set(IsJobTicketLock::getLockStatus, "2"));
|
|
|
|
|
|
|
+ .set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -172,4 +201,55 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
.set(IsJobTicketLock::getLockStatus, dto.getLockStatus()));
|
|
.set(IsJobTicketLock::getLockStatus, dto.getLockStatus()));
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateLocksetTake(List<TakeLocksetDTO> list) {
|
|
|
|
|
+ Assert.isFalse(list.isEmpty(), "请取出至少一个辅件!");
|
|
|
|
|
+ // 情况复杂,软条件过多,单条剥离处理吧
|
|
|
|
|
+ for (TakeLocksetDTO dto : list) {
|
|
|
|
|
+ Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
|
|
+ Assert.notBlank(dto.getLocksetNfc(), "辅件nfc缺失!");
|
|
|
|
|
+ // 1.查询辅件的详情
|
|
|
|
|
+ IsLockset lockset = iIsLocksetService.getOne(Wrappers.<IsLockset>lambdaQuery().eq(IsLockset::getLocksetNfc, dto.getLocksetNfc()));
|
|
|
|
|
+ Assert.notNull(lockset, dto.getLocksetNfc() + "无对应的辅件信息!");
|
|
|
|
|
+ // 1.1获取该辅件的类型,找到is_job_ticket_lockset有没有对应的,可能会有多条,取其中一条即可,
|
|
|
|
|
+ IsJobTicketLockset jobTicketLockset = iIsJobTicketLocksetService.getOne(Wrappers.<IsJobTicketLockset>lambdaQuery()
|
|
|
|
|
+ .eq(IsJobTicketLockset::getJobTicketId, dto.getTicketId())
|
|
|
|
|
+ // 未使用过的数据
|
|
|
|
|
+ .isNull(IsJobTicketLockset::getLocksetId)
|
|
|
|
|
+ // 处理下多条取一条用,按照从上倒下顺序使用
|
|
|
|
|
+ .orderByAsc(IsJobTicketLockset::getRecordId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ Assert.notNull(jobTicketLockset, "无初始化数据来提供给该辅件更新");
|
|
|
|
|
+ // 1.2开始补充该条数据
|
|
|
|
|
+ jobTicketLockset.setLocksetId(lockset.getLocksetId());
|
|
|
|
|
+ jobTicketLockset.setFromHardwareId(dto.getFromHardwareId());
|
|
|
|
|
+ jobTicketLockset.setLocksetStatus(LocksetStatusEnum.TAKED.status);
|
|
|
|
|
+ jobTicketLockset.setCollectTime(new Date());
|
|
|
|
|
+ iIsJobTicketLocksetService.updateById(jobTicketLockset);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateLocksetPoint(LocksetPointDTO dto) {
|
|
|
|
|
+ Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
|
|
+ Assert.notBlank(dto.getLocksetNfc(), "辅件nfc缺失!");
|
|
|
|
|
+ Assert.notNull(dto.getPointNfc(), "请告知隔离点信息!");
|
|
|
|
|
+ // 1.通过nfc查询挂锁信息
|
|
|
|
|
+ IsLockset lockset = iIsLocksetService.getOne(Wrappers.<IsLockset>lambdaQuery()
|
|
|
|
|
+ .eq(IsLockset::getLocksetNfc, dto.getLocksetNfc()));
|
|
|
|
|
+ Assert.notNull(lockset, "该nfc无对应的辅件信息");
|
|
|
|
|
+ // 2.通过nfc查询隔离点信息
|
|
|
|
|
+ IsIsolationPoint point = iIsIsolationPointService.getOne(Wrappers.<IsIsolationPoint>lambdaQuery()
|
|
|
|
|
+ .eq(IsIsolationPoint::getPointNfc, dto.getPointNfc()));
|
|
|
|
|
+ Assert.notNull(point, "该nfc无对应的隔离点信息");
|
|
|
|
|
+ // 3.开始更新绑定关系
|
|
|
|
|
+ iIsJobTicketLocksetService.update(Wrappers.<IsJobTicketLockset>lambdaUpdate()
|
|
|
|
|
+ .eq(IsJobTicketLockset::getJobTicketId, dto.getTicketId())
|
|
|
|
|
+ .eq(IsJobTicketLockset::getLocksetId, lockset.getLocksetId())
|
|
|
|
|
+ .set(IsJobTicketLockset::getPointId, point.getPointId())
|
|
|
|
|
+ .set(IsJobTicketLockset::getLocksetStatus, LocksetStatusEnum.USING.status));
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|