Ver Fonte

修改物资柜id为序列号,新增辅件归还触发接口

车车 há 11 meses atrás
pai
commit
115e718a60

+ 8 - 0
ktg-iscs/src/main/java/com/ktg/iscs/controller/HardwareApiController.java

@@ -89,5 +89,13 @@ public class HardwareApiController extends BaseController
         return CommonResult.success(hardwareApiService.updateLocksetPoint(dto));
     }
 
+    @ApiOperation("辅件归还物资柜")
+    @Log(title = "辅件归还物资柜", businessType = BusinessType.UPDATE)
+    @PostMapping("/updateLocksetReturn")
+    public CommonResult<Boolean> updateLocksetReturn(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") ReturnLocksetDTO dto)
+    {
+        return CommonResult.success(hardwareApiService.updateLocksetReturn(dto));
+    }
+
 
 }

+ 24 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/hardwareApi/ReturnLocksetDTO.java

@@ -0,0 +1,24 @@
+package com.ktg.iscs.domain.dto.hardwareApi;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * UpdateTicketLockDTO
+ *
+ * @author cgj
+ * @date 2024-10-16
+ */
+@Data
+public class ReturnLocksetDTO {
+
+    @ApiModelProperty(value = "作业票ID")
+    private Long ticketId;
+
+    @ApiModelProperty(value = "挂锁NFC")
+    private String locksetNfc;
+
+    @ApiModelProperty(value = "归还硬件的序列号")
+    private String serialNumber;
+
+}

+ 2 - 2
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/hardwareApi/ReturnTicketLockDTO.java

@@ -18,7 +18,7 @@ public class ReturnTicketLockDTO {
     @ApiModelProperty(value = "挂锁NFC")
     private String lockNfc;
 
-    @ApiModelProperty(value = "归还硬件ID")
-    private Long toHardwareId;
+    @ApiModelProperty(value = "归还硬件的序列号")
+    private String serialNumber;
 
 }

+ 2 - 2
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/hardwareApi/TakeLocksetDTO.java

@@ -18,8 +18,8 @@ public class TakeLocksetDTO {
     @ApiModelProperty(value = "锁具NFC")
     private String locksetNfc;
 
-    @ApiModelProperty(value = "取出硬件ID")
-    private Long fromHardwareId;
+    @ApiModelProperty(value = "序列号-取出硬件ID")
+    private String serialNumber;
 
     @ApiModelProperty(value = "对接时不需要传入,给了NFC就行")
     private Long locksetId;

+ 2 - 2
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/hardwareApi/TakeTicketLockDTO.java

@@ -18,8 +18,8 @@ public class TakeTicketLockDTO {
     @ApiModelProperty(value = "挂锁NFC")
     private String lockNfc;
 
-    @ApiModelProperty(value = "取出硬件ID")
-    private Long fromHardwareId;
+    @ApiModelProperty(value = "取出硬件的序列号")
+    private String serialNumber;
 
     @ApiModelProperty(value = "对接时不需要传入,给了NFC就行")
     private Long lockId;

+ 3 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/vo/workarea/PointsMapVO.java

@@ -27,6 +27,9 @@ public class PointsMapVO implements Serializable {
     @ApiModelProperty(value = "点位Name")
     private String pointName;
 
+    @ApiModelProperty(value = "前置点位id")
+    private Long prePointId;
+
     @ApiModelProperty(value = "隔离点类型")
     private String pointType;
 

+ 7 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/HardwareApiService.java

@@ -67,4 +67,11 @@ public interface HardwareApiService {
      */
     Boolean updateLocksetPoint(LocksetPointDTO dto);
 
+    /**
+     * 辅件归还物资柜
+     * @param dto
+     * @return
+     */
+    Boolean updateLocksetReturn(ReturnLocksetDTO dto);
+
 }

+ 88 - 11
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/HardwareApiServiceImpl.java

@@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
 
 import java.util.Date;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * 硬件Service业务层处理
@@ -40,6 +39,8 @@ public class HardwareApiServiceImpl implements HardwareApiService {
     private IIsLocksetService iIsLocksetService;
     @Autowired
     private IIsJobTicketLocksetService iIsJobTicketLocksetService;
+    @Autowired
+    private IIsHardwareService isHardwareService;
 
     @Override
     public Boolean updateTicketKetStatus(UpdateKeyStatusDTO dto) {
@@ -92,9 +93,36 @@ public class HardwareApiServiceImpl implements HardwareApiService {
 
     @Override
     public Boolean updateTicketLockTake(List<TakeTicketLockDTO> list) {
-        Assert.notNull(list.get(0).getTicketId(), "请告诉我关于哪个作业票!");
         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());
         Assert.isFalse(nfcList.isEmpty() || size != nfcList.size(), "钥匙NFC不可为空!");
         // 1.查询挂锁信息
@@ -121,25 +149,29 @@ public class HardwareApiServiceImpl implements HardwareApiService {
             isJobTicketLock.setLockStatus(LockStatusEnum.NOT_LOCK.status);
         }
         // 4.开始批量更新
-        return iIsJobTicketLockService.updateBatchById(jobTicketLockList);
+        iIsJobTicketLockService.updateBatchById(jobTicketLockList);*/
+        return true;
     }
 
     @Override
     public Boolean updateTicketLockReturn(ReturnTicketLockDTO dto) {
         // Assert.notNull(dto.getTicketId(), "请告诉我关于哪个作业票!");
         Assert.notBlank(dto.getLockNfc(), "挂锁nfc缺失!");
-        Assert.notNull(dto.getToHardwareId(), "请告知归还到哪一个柜子!");
+        Assert.notBlank(dto.getSerialNumber(), "请告知归还到哪一个柜子!");
         // 1.通过nfc查询挂锁信息
         IsLock lock = iIsLockService.getOne(Wrappers.<IsLock>lambdaQuery()
                 .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.开始更新归还信息
         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::getToHardwareId, isHardware.getId())
                     .set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
         } else {
             // 2.2不登陆状态下归还
@@ -153,7 +185,7 @@ public class HardwareApiServiceImpl implements HardwareApiService {
                 // 说明找到的就是
                 iIsJobTicketLockService.update(Wrappers.<IsJobTicketLock>lambdaUpdate()
                         .eq(IsJobTicketLock::getLockId, lock.getLockId())
-                        .set(IsJobTicketLock::getToHardwareId, dto.getToHardwareId())
+                        .set(IsJobTicketLock::getToHardwareId, isHardware.getId())
                         .set(IsJobTicketLock::getLockStatus, LockStatusEnum.RETURN_LOCK.status));
             } else {
                 // 出现了多条对应
@@ -212,7 +244,11 @@ public class HardwareApiServiceImpl implements HardwareApiService {
             // 1.查询辅件的详情
             IsLockset lockset = iIsLocksetService.getOne(Wrappers.<IsLockset>lambdaQuery().eq(IsLockset::getLocksetNfc, 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()
                     .eq(IsJobTicketLockset::getJobTicketId, dto.getTicketId())
                     // 未使用过的数据
@@ -221,9 +257,9 @@ public class HardwareApiServiceImpl implements HardwareApiService {
                     .orderByAsc(IsJobTicketLockset::getRecordId)
                     .last("limit 1"));
             Assert.notNull(jobTicketLockset, "无初始化数据来提供给该辅件更新");
-            // 1.2开始补充该条数据
+            // 1.3开始补充该条数据
             jobTicketLockset.setLocksetId(lockset.getLocksetId());
-            jobTicketLockset.setFromHardwareId(dto.getFromHardwareId());
+            jobTicketLockset.setFromHardwareId(isHardware.getId());
             jobTicketLockset.setLocksetStatus(LocksetStatusEnum.TAKED.status);
             jobTicketLockset.setCollectTime(new Date());
             iIsJobTicketLocksetService.updateById(jobTicketLockset);
@@ -252,4 +288,45 @@ public class HardwareApiServiceImpl implements HardwareApiService {
                 .set(IsJobTicketLockset::getLocksetStatus, LocksetStatusEnum.USING.status));
         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;
+    }
 }

+ 4 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsWorkareaServiceImpl.java

@@ -213,6 +213,8 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
                         for (IsSopPoints isSopPoint : isSopPoints) {
                             if (o.getPointId().equals(isSopPoint.getPointId())) {
                                 o.setState(true);
+                                // 根据sop的前置节点赋值
+                                o.setPrePointId(isSopPoint.getPrePointId());
                             }
                         }
                     }
@@ -221,6 +223,8 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
                         for (IsJobTicketPoints ticketPoint : isJobTicketPoints) {
                             if (o.getPointId().equals(ticketPoint.getPointId())) {
                                 o.setState(true);
+                                // 根据作业票的前置节点赋值
+                                o.setPrePointId(ticketPoint.getPrePointId());
                             }
                         }
                     }