Răsfoiți Sursa

林武泰/修改借用记录,新增借用人用户名属性

LinWuTai 2 ani în urmă
părinte
comite
40bb4630ff

+ 3 - 3
lab-admin/src/main/java/com/ruoyi/asset/controller/TbAssetBorrowRecordController.java

@@ -44,7 +44,7 @@ public class TbAssetBorrowRecordController extends BaseController
     public TableDataInfo list(TbAssetBorrowRecord tbAssetBorrowRecord)
     {
         startPage();
-        List<TbAssetBorrowRecord> list = tbAssetBorrowRecordService.selectTbAssetBorrowRecordList(tbAssetBorrowRecord);
+        List<TbBorrowRecordDTO> list = tbAssetBorrowRecordService.selectTbAssetBorrowRecordDTOList(tbAssetBorrowRecord);
         return getDataTable(list);
     }
 
@@ -57,8 +57,8 @@ public class TbAssetBorrowRecordController extends BaseController
     @PostMapping("/export")
     public void export(HttpServletResponse response, TbAssetBorrowRecord tbAssetBorrowRecord)
     {
-        List<TbAssetBorrowRecord> list = tbAssetBorrowRecordService.selectTbAssetBorrowRecordList(tbAssetBorrowRecord);
-        ExcelUtil<TbAssetBorrowRecord> util = new ExcelUtil<TbAssetBorrowRecord>(TbAssetBorrowRecord.class);
+        List<TbBorrowRecordDTO> list = tbAssetBorrowRecordService.selectTbAssetBorrowRecordDTOList(tbAssetBorrowRecord);
+        ExcelUtil<TbBorrowRecordDTO> util = new ExcelUtil<TbBorrowRecordDTO>(TbBorrowRecordDTO.class);
         util.exportExcel(response, list, "设备借用记录数据");
     }
 

+ 12 - 0
lab-admin/src/main/java/com/ruoyi/asset/domain/dto/TbBorrowRecordDTO.java

@@ -2,11 +2,14 @@ package com.ruoyi.asset.domain.dto;
 
 import com.ruoyi.asset.domain.TbAsset;
 import com.ruoyi.asset.domain.TbAssetBorrowRecord;
+import com.ruoyi.common.annotation.Excel;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
 public class TbBorrowRecordDTO extends TbAssetBorrowRecord {
     private TbAsset tbAsset;
+    @Excel(name = "借用人工号")
+    private String username;
 
     public TbAsset getTbAsset() {
         return tbAsset;
@@ -16,10 +19,19 @@ public class TbBorrowRecordDTO extends TbAssetBorrowRecord {
         this.tbAsset = tbAsset;
     }
 
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                 .append("tbAsset", getTbAsset())
+                .append("username", getUsername())
                 .toString();
     }
 }

+ 8 - 0
lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetBorrowRecordService.java

@@ -34,6 +34,14 @@ public interface ITbAssetBorrowRecordService extends IService<TbAssetBorrowRecor
     public List<TbAssetBorrowRecord> selectTbAssetBorrowRecordList(TbAssetBorrowRecord tbAssetBorrowRecord);
 
     /**
+     * 查询设备借用记录列表
+     *
+     * @param tbAssetBorrowRecord 设备借用记录
+     * @return 设备借用记录集合
+     */
+    public List<TbBorrowRecordDTO> selectTbAssetBorrowRecordDTOList(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
      * 新增设备借用记录
      * 
      * @param tbAssetBorrowRecord 设备借用记录

+ 26 - 8
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetBorrowRecordServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.asset.service.impl;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -14,9 +15,11 @@ import com.ruoyi.asset.domain.dto.TbBorrowRecordDTO;
 import com.ruoyi.asset.mapper.TbAssetMapper;
 import com.ruoyi.asset.mapper.TbAssetStatusRecordMapper;
 import com.ruoyi.asset.mapper.TbPlaceMapper;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.UserUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.system.mapper.SysUserMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -50,6 +53,9 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
     @Resource
     private TbAssetStatusRecordMapper tbAssetStatusRecordMapper;
 
+    @Resource
+    private SysUserMapper sysUserMapper;
+
     /**
      * 查询设备借用记录
      * 
@@ -62,18 +68,30 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
         return tbAssetBorrowRecordMapper.selectTbAssetBorrowRecordById(id);
     }
 
-    /**
-     * 查询设备借用记录列表
-     * 
-     * @param tbAssetBorrowRecord 设备借用记录
-     * @return 设备借用记录
-     */
     @Override
-    public List<TbAssetBorrowRecord> selectTbAssetBorrowRecordList(TbAssetBorrowRecord tbAssetBorrowRecord)
-    {
+    public List<TbAssetBorrowRecord> selectTbAssetBorrowRecordList(TbAssetBorrowRecord tbAssetBorrowRecord) {
         return tbAssetBorrowRecordMapper.selectTbAssetBorrowRecordList(tbAssetBorrowRecord);
     }
 
+    @Override
+    public List<TbBorrowRecordDTO> selectTbAssetBorrowRecordDTOList(TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        List<TbAssetBorrowRecord> tbAssetBorrowRecords = tbAssetBorrowRecordMapper.selectTbAssetBorrowRecordList(tbAssetBorrowRecord);
+        List<TbBorrowRecordDTO> borrowRecordDTOS = new ArrayList<>();
+        for (TbAssetBorrowRecord assetBorrowRecord : tbAssetBorrowRecords) {
+            TbBorrowRecordDTO tbBorrowRecordDTO = BeanUtil.toBean(assetBorrowRecord, TbBorrowRecordDTO.class);
+            Long userId = assetBorrowRecord.getUserId();
+            SysUser sysUser = sysUserMapper.selectUserById(userId);
+            tbBorrowRecordDTO.setUsername(sysUser.getUserName());
+            String assetBarCode = assetBorrowRecord.getAssetBarCode();
+            TbAsset tbAsset = tbAssetMapper.selectTbAssetByBarCode(assetBarCode);
+            tbBorrowRecordDTO.setTbAsset(tbAsset);
+
+            borrowRecordDTOS.add(tbBorrowRecordDTO);
+        }
+        return borrowRecordDTOS;
+    }
+
     /**
      * 新增设备借用记录
      * 

+ 1 - 1
lab-ui/src/views/asset/borrow/index.vue

@@ -107,7 +107,7 @@
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="记录编号" align="center" prop="id" />
       <el-table-column label="设备条形码" align="center" prop="assetBarCode" />
-      <el-table-column label="借用人" align="center" prop="userId" />
+      <el-table-column label="借用人" align="center" prop="username" />
       <el-table-column label="借用人电话" align="center" prop="tel" />
       <el-table-column label="是否归还" align="center" prop="isreturn">
         <template slot-scope="scope">