Selaa lähdekoodia

林武泰/修复设备重复借用问题

LinWuTai 2 vuotta sitten
vanhempi
commit
0b022740e1

+ 2 - 5
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetBorrowRecordServiceImpl.java

@@ -151,7 +151,7 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
         if (tbAsset == null) {
             return AjaxResult.error("资产设备不存在");
         }
-        TbAssetBorrowRecord borrowRecord = query().eq("asset_bar_code", assetBarCode).orderByDesc("borrow_date").last("limit 1").one();
+        TbAssetBorrowRecord borrowRecord = query().eq("asset_bar_code", assetBarCode).eq("isReturn", 0).one();
         if (borrowRecord != null && borrowRecord.getIsreturn() < 1) {
             return AjaxResult.error("当前资产设备已借出");
         }
@@ -204,11 +204,8 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
         if (StrUtil.isBlank(barCode)) {
             return AjaxResult.error("资产条形码不能为空");
         }
-        TbAssetBorrowRecord borrowRecord = query().eq("asset_bar_code", barCode).orderByDesc("borrow_date").last("limit 1").one();
+        TbAssetBorrowRecord borrowRecord = query().eq("asset_bar_code", barCode).eq("isReturn", 0).one();
         if (borrowRecord == null) {
-            return AjaxResult.error("查无借用记录");
-        }
-        if (borrowRecord.getIsreturn() > 0) {
             return AjaxResult.error("资产设备已归还");
         }
         Long borrowUserId = borrowRecord.getUserId();

+ 7 - 7
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetServiceImpl.java

@@ -220,19 +220,19 @@ public class TbAssetServiceImpl extends ServiceImpl<TbAssetMapper, TbAsset> impl
                 continue;
             }
             QueryWrapper<TbAssetBorrowRecord> borrowRecordQueryWrapper = new QueryWrapper<>();
-            borrowRecordQueryWrapper.eq("asset_bar_code", tbAsset.getBarCode()).orderByDesc("borrow_date").last("limit 1");
+            borrowRecordQueryWrapper.eq("asset_bar_code", tbAsset.getBarCode()).eq("isReturn", 0);
             TbAssetBorrowRecord borrowRecord = tbAssetBorrowRecordMapper.selectOne(borrowRecordQueryWrapper);
             if (borrowRecord == null) {
                 tbAssetDTO.setBorrowStatus("可借出");
                 assetDTOList.add(tbAssetDTO);
                 continue;
             }
-            Long isReturn = borrowRecord.getIsreturn();
-            if (isReturn > 0) {
-                tbAssetDTO.setBorrowStatus("可借出");
-                assetDTOList.add(tbAssetDTO);
-                continue;
-            }
+//            Long isReturn = borrowRecord.getIsreturn();
+//            if (isReturn > 0) {
+//                tbAssetDTO.setBorrowStatus("可借出");
+//                assetDTOList.add(tbAssetDTO);
+//                continue;
+//            }
             tbAssetDTO.setBorrowStatus("已借出");
             Long userId = borrowRecord.getUserId();
             SysUser sysUser = sysUserMapper.selectUserById(userId);