|
@@ -2,18 +2,15 @@ package com.ktg.iscs.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
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.IsJobTicket;
|
|
|
|
|
-import com.ktg.iscs.domain.IsJobTicketKey;
|
|
|
|
|
-import com.ktg.iscs.domain.IsKey;
|
|
|
|
|
-import com.ktg.iscs.domain.dto.hardwareApi.UpdateKeyStatusDTO;
|
|
|
|
|
-import com.ktg.iscs.service.HardwareApiService;
|
|
|
|
|
-import com.ktg.iscs.service.IIsJobTicketKeyService;
|
|
|
|
|
-import com.ktg.iscs.service.IIsJobTicketService;
|
|
|
|
|
-import com.ktg.iscs.service.IIsKeyService;
|
|
|
|
|
|
|
+import com.ktg.iscs.domain.*;
|
|
|
|
|
+import com.ktg.iscs.domain.dto.hardwareApi.*;
|
|
|
|
|
+import com.ktg.iscs.service.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 硬件Service业务层处理
|
|
* 硬件Service业务层处理
|
|
@@ -29,6 +26,12 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
private IIsKeyService isKeyService;
|
|
private IIsKeyService isKeyService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IIsJobTicketKeyService iIsJobTicketKeyService;
|
|
private IIsJobTicketKeyService iIsJobTicketKeyService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsLockService iIsLockService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsJobTicketLockService iIsJobTicketLockService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsIsolationPointService iIsIsolationPointService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean updateTicketKetStatus(UpdateKeyStatusDTO dto) {
|
|
public Boolean updateTicketKetStatus(UpdateKeyStatusDTO dto) {
|
|
@@ -78,4 +81,95 @@ public class HardwareApiServiceImpl implements HardwareApiService {
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateTicketLockTake(List<TakeTicketLockDTO> list) {
|
|
|
|
|
+ Assert.notNull(list.get(0).getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
|
|
+ Assert.isFalse(list.isEmpty(), "请取出至少一把挂锁!");
|
|
|
|
|
+ int size = list.size();
|
|
|
|
|
+ List<String> nfcList = list.stream().map(TakeTicketLockDTO::getLockNfc).collect(Collectors.toList());
|
|
|
|
|
+ Assert.isFalse(nfcList.isEmpty() || size != nfcList.size(), "钥匙NFC不可为空!");
|
|
|
|
|
+ // 1.查询挂锁信息
|
|
|
|
|
+ List<IsLock> lockList = iIsLockService.list(Wrappers.<IsLock>lambdaQuery()
|
|
|
|
|
+ .in(IsLock::getLockNfc, nfcList));
|
|
|
|
|
+ Assert.isFalse(lockList.isEmpty(), "通过nfc查询不到相关挂锁信息!");
|
|
|
|
|
+ // 2.获取本次作业票产生的和挂锁关联的数据,因为取挂锁可能分批,多以按顺序更新关联数据的前几个
|
|
|
|
|
+ List<IsJobTicketLock> jobTicketLockList = iIsJobTicketLockService.list(Wrappers.<IsJobTicketLock>lambdaQuery()
|
|
|
|
|
+ .eq(IsJobTicketLock::getTicketId, list.get(0).getTicketId())
|
|
|
|
|
+ .isNull(IsJobTicketLock::getLockId)
|
|
|
|
|
+ .orderByAsc(IsJobTicketLock::getRecordId)
|
|
|
|
|
+ .last("limit" + size));
|
|
|
|
|
+ // 3.把查出来的锁id放到对应的dto中,组装查出来的IsJobTicketLock数据
|
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
+ for (IsLock isLock : lockList) {
|
|
|
|
|
+ if (list.get(i).getLockNfc().equals(isLock.getLockNfc())) {
|
|
|
|
|
+ list.get(i).setLockId(isLock.getLockId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 3.1组装更新的数据
|
|
|
|
|
+ IsJobTicketLock isJobTicketLock = jobTicketLockList.get(i);
|
|
|
|
|
+ isJobTicketLock.setLockId(list.get(i).getLockId());
|
|
|
|
|
+ isJobTicketLock.setFromHardwareId(list.get(i).getFromHardwareId());
|
|
|
|
|
+ isJobTicketLock.setLockStatus("1");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 4.开始批量更新
|
|
|
|
|
+ return iIsJobTicketLockService.updateBatchById(jobTicketLockList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateTicketLockReturn(ReturnTicketLockDTO dto) {
|
|
|
|
|
+ Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
|
|
+ Assert.notBlank(dto.getLockNfc(), "挂锁nfc缺失!");
|
|
|
|
|
+ Assert.notNull(dto.getToHardwareId(), "请告知归还到哪一个柜子!");
|
|
|
|
|
+ // 1.通过nfc查询挂锁信息
|
|
|
|
|
+ IsLock lock = iIsLockService.getOne(Wrappers.<IsLock>lambdaQuery()
|
|
|
|
|
+ .eq(IsLock::getLockNfc, dto.getLockNfc()));
|
|
|
|
|
+ Assert.notNull(lock, "该nfc无对应的挂锁信息");
|
|
|
|
|
+ // 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"));
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateTicketLockPoint(LockPointDTO dto) {
|
|
|
|
|
+ Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
|
|
+ Assert.notBlank(dto.getLockNfc(), "挂锁nfc缺失!");
|
|
|
|
|
+ Assert.notNull(dto.getPointNfc(), "请告知隔离点信息!");
|
|
|
|
|
+ // 1.通过nfc查询挂锁信息
|
|
|
|
|
+ IsLock lock = iIsLockService.getOne(Wrappers.<IsLock>lambdaQuery()
|
|
|
|
|
+ .eq(IsLock::getLockNfc, dto.getLockNfc()));
|
|
|
|
|
+ Assert.notNull(lock, "该nfc无对应的挂锁信息");
|
|
|
|
|
+ // 2.通过nfc查询隔离点信息
|
|
|
|
|
+ IsIsolationPoint point = iIsIsolationPointService.getOne(Wrappers.<IsIsolationPoint>lambdaQuery()
|
|
|
|
|
+ .eq(IsIsolationPoint::getPointNfc, dto.getPointNfc()));
|
|
|
|
|
+ Assert.notNull(point, "该nfc无对应的隔离点信息");
|
|
|
|
|
+ // 3.开始更新绑定关系
|
|
|
|
|
+ iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
|
|
|
+ .eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
|
|
|
+ .eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
|
|
+ .set(IsJobTicketLock::getIsolationPointId, point.getPointId())
|
|
|
|
|
+ .set(IsJobTicketLock::getLockStatus, "2"));
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateTicketLockStatus(UpdateTicketStatusDTO dto) {
|
|
|
|
|
+ Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
|
|
|
|
|
+ Assert.notBlank(dto.getLockNfc(), "挂锁nfc缺失!");
|
|
|
|
|
+ Assert.notBlank(dto.getLockStatus(), "锁具状态缺失!");
|
|
|
|
|
+ // 1.通过nfc查询挂锁信息
|
|
|
|
|
+ IsLock lock = iIsLockService.getOne(Wrappers.<IsLock>lambdaQuery()
|
|
|
|
|
+ .eq(IsLock::getLockNfc, dto.getLockNfc()));
|
|
|
|
|
+ Assert.notNull(lock, "该nfc无对应的挂锁信息");
|
|
|
|
|
+ // 3.开始更新绑定关系
|
|
|
|
|
+ iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
|
|
|
|
|
+ .eq(IsJobTicketLock::getTicketId, dto.getTicketId())
|
|
|
|
|
+ .eq(IsJobTicketLock::getLockId, lock.getLockId())
|
|
|
|
|
+ .set(IsJobTicketLock::getLockStatus, dto.getLockStatus()));
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|