Răsfoiți Sursa

林武泰/新增借用记录与报备记录查询,新增故障上报,故障处理功能

LinWuTai 2 ani în urmă
părinte
comite
8b038240c8
24 a modificat fișierele cu 337 adăugiri și 42 ștergeri
  1. 94 8
      lab-admin/src/main/java/com/ruoyi/asset/controller/TbAssetBorrowRecordController.java
  2. 3 0
      lab-admin/src/main/java/com/ruoyi/asset/controller/TbAssetController.java
  3. 63 0
      lab-admin/src/main/java/com/ruoyi/asset/controller/TbFaultReportController.java
  4. 4 0
      lab-admin/src/main/java/com/ruoyi/asset/domain/TbAsset.java
  5. 9 6
      lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetBorrowRecord.java
  6. 2 0
      lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetCategory.java
  7. 5 2
      lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetStatusRecord.java
  8. 5 2
      lab-admin/src/main/java/com/ruoyi/asset/domain/TbFaultReport.java
  9. 2 0
      lab-admin/src/main/java/com/ruoyi/asset/domain/TbPlace.java
  10. 2 2
      lab-admin/src/main/java/com/ruoyi/asset/domain/dto/TbAssetDTO.java
  11. 25 0
      lab-admin/src/main/java/com/ruoyi/asset/domain/dto/TbBorrowRecordDTO.java
  12. 25 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetBorrowRecordService.java
  13. 2 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetStatusRecordService.java
  14. 7 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbFaultReportService.java
  15. 53 3
      lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetBorrowRecordServiceImpl.java
  16. 12 5
      lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetServiceImpl.java
  17. 12 1
      lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbFaultReportServiceImpl.java
  18. 0 5
      lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbPlaceServiceImpl.java
  19. 4 0
      lab-admin/src/main/resources/application.yml
  20. 1 1
      lab-common/src/main/java/com/ruoyi/common/utils/UserUtils.java
  21. 1 1
      lab-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
  22. 3 3
      lab-ui/src/views/asset/borrow/index.vue
  23. 2 2
      lab-ui/src/views/asset/fault/index.vue
  24. 1 1
      lab-ui/src/views/asset/record/index.vue

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

@@ -1,20 +1,17 @@
 package com.ruoyi.asset.controller;
 
+import java.util.Date;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.util.StrUtil;
+import com.ruoyi.asset.domain.dto.TbBorrowRecordDTO;
+import com.ruoyi.asset.utils.RegexUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -111,4 +108,93 @@ public class TbAssetBorrowRecordController extends BaseController
     {
         return toAjax(tbAssetBorrowRecordService.deleteTbAssetBorrowRecordByIds(ids));
     }
+
+    /**
+     * 小程序:新增设备借用记录
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:add')")
+    @Log(title = "设备借用记录", businessType = BusinessType.INSERT)
+    @PostMapping("/save/{borrowTime}/{returnTime}")
+    public AjaxResult saveBorrowRecord(@RequestBody TbAssetBorrowRecord tbAssetBorrowRecord, @PathVariable("borrowTime") Long borrowTime, @PathVariable("returnTime") Long returnTime)
+    {
+        String assetBarCode = tbAssetBorrowRecord.getAssetBarCode();
+        if (StrUtil.isBlank(assetBarCode)) {
+            return AjaxResult.error("资产设备条形码不能为空");
+        }
+        String borrowPlaceName = tbAssetBorrowRecord.getBorrowPlaceName();
+        if (StrUtil.isBlank(borrowPlaceName)) {
+            return AjaxResult.error("借用地点不能为空");
+        }
+        String tel = tbAssetBorrowRecord.getTel();
+        if (StrUtil.isBlank(tel)) {
+            return AjaxResult.error("联系电话不能为空");
+        }
+        if (RegexUtils.isPhoneInvalid(tel)) {
+            return AjaxResult.error("联系电话格式错误");
+        }
+        Date nowDate = new Date();
+        Date borrowDate = new Date(borrowTime);
+        if (nowDate.after(borrowDate)) {
+            return AjaxResult.error("借用时间不能早于当前时间");
+        }
+        tbAssetBorrowRecord.setBorrowDate(borrowDate);
+        Date returnDate = new Date(returnTime);
+        if (!returnDate.after(borrowDate)) {
+            return AjaxResult.error("归还时间不能早于借用时间");
+        }
+        if (returnDate.equals(borrowDate)) {
+            return AjaxResult.error("归还时间不能与借用时间相等");
+        }
+        tbAssetBorrowRecord.setReturnDate(returnDate);
+
+        return tbAssetBorrowRecordService.saveBorrowRecord(tbAssetBorrowRecord);
+    }
+
+    /**
+     * 修改设备借用记录为归还
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:add')")
+    @Log(title = "修改设备借用记录为归还", businessType = BusinessType.UPDATE)
+    @PutMapping("/return/{barCode}")
+    public AjaxResult updateBorrowRecordToReturn(@PathVariable("barCode") String barCode)
+    {
+        return tbAssetBorrowRecordService.updateBorrowRecordToReturn(barCode);
+    }
+
+    /**
+     * 获取用户自己设备借用记录
+     */
+    @ApiOperation("获取用户自己设备借用记录")
+    @PreAuthorize("@ss.hasPermi('asset:borrow:list')")
+    @GetMapping("/recordList")
+    public TableDataInfo selectMeBorrowRecordList(@RequestParam(value = "status", required = false) Long status)
+    {
+        startPage();
+        List<TbAssetBorrowRecord> tbAssetBorrowRecords = tbAssetBorrowRecordService.selectMeTbAssetBorrowRecord(status);
+        return getDataTable(tbAssetBorrowRecords);
+    }
+
+    /**
+     * 获取用户自己设备借用记录详细
+     */
+    @ApiOperation("获取用户自己设备借用记录")
+    @PreAuthorize("@ss.hasPermi('asset:borrow:list')")
+    @GetMapping("/record/{id}")
+    public AjaxResult selectMeBorrowRecord(@PathVariable("id") Long id)
+    {
+        TbBorrowRecordDTO tbAssetBorrowRecord = tbAssetBorrowRecordService.selectMeTbAssetBorrowRecordById(id);
+        return AjaxResult.success("查询成功", tbAssetBorrowRecord);
+    }
+
+    /**
+     * 统计用户自己设备借用记录
+     */
+    @ApiOperation("统计用户自己设备借用记录")
+    @PreAuthorize("@ss.hasPermi('asset:borrow:list')")
+    @GetMapping("/recordCount")
+    public AjaxResult countMeTbAssetBorrow(@RequestParam(value = "status", required = false) Long status)
+    {
+        return tbAssetBorrowRecordService.countMeTbAssetBorrowRecord(status);
+    }
+
 }

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

@@ -145,6 +145,9 @@ public class TbAssetController extends BaseController
     ) {
         List<TbAssetDTO> tbAssetDTOS = tbAssetService.selectTbAsset(barCode, numberOrName);
         if (barCode != null) {
+            if (tbAssetDTOS.isEmpty()) {
+                return AjaxResult.success("查询成功", new TbAsset());
+            }
             return AjaxResult.success(tbAssetDTOS.get(0));
         }
         return AjaxResult.success(tbAssetDTOS);

+ 63 - 0
lab-admin/src/main/java/com/ruoyi/asset/controller/TbFaultReportController.java

@@ -3,6 +3,9 @@ package com.ruoyi.asset.controller;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.util.StrUtil;
+import com.ruoyi.asset.domain.dto.TbFaultReportProcessDTO;
+import com.ruoyi.asset.utils.RegexUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -111,4 +114,64 @@ public class TbFaultReportController extends BaseController
     {
         return toAjax(tbFaultReportService.deleteTbFaultReportByIds(ids));
     }
+
+    /**
+     * 小程序:新增故障报备
+     */
+    @ApiOperation("小程序:新增故障报备")
+    @PreAuthorize("@ss.hasPermi('asset:fault:add')")
+    @Log(title = "故障报备", businessType = BusinessType.INSERT)
+    @PostMapping("/save")
+    public AjaxResult save(@RequestBody TbFaultReport tbFaultReport)
+    {
+        String assetBarCode = tbFaultReport.getAssetBarCode();
+        if (StrUtil.isBlank(assetBarCode)) {
+            return AjaxResult.error("资产设备条形码不能为空");
+        }
+        String faultPhenomenon = tbFaultReport.getFaultPhenomenon();
+        if (StrUtil.isBlank(faultPhenomenon)) {
+            return AjaxResult.error("故障现象不能为空");
+        }
+        String tel = tbFaultReport.getTel();
+        if (StrUtil.isBlank(tel)) {
+            return AjaxResult.error("报备人手机号不能为空");
+        }
+        if (RegexUtils.isPhoneInvalid(tel)) {
+            return AjaxResult.error("手机号格式错误");
+        }
+        return tbFaultReportService.saveTbFaultReport(tbFaultReport);
+    }
+
+    /**
+     * 修改故障报备
+     */
+    @ApiOperation("故障报备处理")
+    @PreAuthorize("@ss.hasPermi('asset:fault:edit')")
+    @Log(title = "故障报备", businessType = BusinessType.UPDATE)
+    @PutMapping("/process")
+    public AjaxResult faultReportProcess(@RequestBody TbFaultReportProcessDTO tbFaultReportProcessDTO)
+    {
+        Long tbFaultReportId = tbFaultReportProcessDTO.getTbFaultReportId();
+        if (tbFaultReportId == null) {
+            return AjaxResult.error("故障报备编号不能为空");
+        }
+        String processResult = tbFaultReportProcessDTO.getProcessResult();
+        if (StrUtil.isBlank(processResult)) {
+            return AjaxResult.error("故障处理结果不能为空");
+        }
+        return tbFaultReportService.tbFaultReportProcess(tbFaultReportProcessDTO);
+    }
+
+    /**
+     * 获取用户自己故障报备记录
+     */
+    @ApiOperation("查询故障报备列表")
+    @PreAuthorize("@ss.hasPermi('asset:fault:list')")
+    @GetMapping("/faultReportList")
+    public TableDataInfo selectMeTbFaultReport()
+    {
+        startPage();
+        List<TbFaultReport> list = tbFaultReportService.selectMeTbFaultReport();
+        return getDataTable(list);
+    }
 }

+ 4 - 0
lab-admin/src/main/java/com/ruoyi/asset/domain/TbAsset.java

@@ -26,6 +26,7 @@ public class TbAsset extends BaseEntity
     /** 编号 */
     @Excel(name = "编号")
     @TableId("id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long id;
 
     /** 条形码 */
@@ -61,6 +62,7 @@ public class TbAsset extends BaseEntity
     /** 数量 */
     @Excel(name = "数量")
     @TableField("quantity")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long quantity;
 
     /** 数量计量单位 */
@@ -86,6 +88,7 @@ public class TbAsset extends BaseEntity
 
     /** 使用部门ID */
     @TableField("dept_id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long deptId;
 
     /** 使用部门名称 */
@@ -121,6 +124,7 @@ public class TbAsset extends BaseEntity
     /** 状态 */
     @Excel(name = "状态", readConverterExp = "0=故障,1=正常,2=报废", combo = {"正常", "故障", "报废"})
     @TableField("status")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long status;
 
     public void setId(Long id) 

+ 9 - 6
lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetBorrowRecord.java

@@ -25,6 +25,7 @@ public class TbAssetBorrowRecord extends BaseEntity
     /** 记录编号 */
     @Excel(name = "记录编号")
     @TableId("id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long id;
 
     /** 设备条形码 */
@@ -35,6 +36,7 @@ public class TbAssetBorrowRecord extends BaseEntity
     /** 借用人 */
     @Excel(name = "借用人")
     @TableField("user_id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long userId;
 
     /** 借用人电话 */
@@ -45,24 +47,25 @@ public class TbAssetBorrowRecord extends BaseEntity
     /** 是否归还 */
     @Excel(name = "是否归还")
     @TableField("isReturn")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long isreturn;
 
     /** 借用时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @TableField("borrow_date")
-    @Excel(name = "借用时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "借用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date borrowDate;
 
     /** 归还时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @TableField("return_date")
-    @Excel(name = "归还时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "归还时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date returnDate;
 
     /** 实际归还时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @TableField("actual_return_date")
-    @Excel(name = "实际归还时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "实际归还时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date actualReturnDate;
 
     /** 借用地点 */

+ 2 - 0
lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetCategory.java

@@ -3,6 +3,7 @@ package com.ruoyi.asset.domain;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
@@ -22,6 +23,7 @@ public class TbAssetCategory extends BaseEntity
     /** 编号 */
     @Excel(name = "编号")
     @TableId("id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long id;
 
     /** 资产分类编号 */

+ 5 - 2
lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetStatusRecord.java

@@ -25,6 +25,7 @@ public class TbAssetStatusRecord extends BaseEntity
     /** 记录编号 */
     @Excel(name = "记录编号")
     @TableId("id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long id;
 
     /** 设备条形码 */
@@ -35,16 +36,18 @@ public class TbAssetStatusRecord extends BaseEntity
     /** 借用次数 */
     @Excel(name = "借用次数")
     @TableField("borrow_number")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long borrowNumber;
 
     /** 故障次数 */
     @Excel(name = "故障次数")
     @TableField("fault_number")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long faultNumber;
 
     /** 最近故障时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "最近故障时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "最近故障时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     @TableField("last_fault_date")
     private Date lastFaultDate;
 

+ 5 - 2
lab-admin/src/main/java/com/ruoyi/asset/domain/TbFaultReport.java

@@ -25,6 +25,7 @@ public class TbFaultReport extends BaseEntity
     /** 报备编号 */
     @Excel(name = "报备编号")
     @TableId("id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long id;
 
     /** 设备条形码 */
@@ -35,12 +36,13 @@ public class TbFaultReport extends BaseEntity
     /** 报备人 */
     @Excel(name = "报备人")
     @TableField("user_id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long userId;
 
     /** 报备时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @TableField("report_date")
-    @Excel(name = "报备时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "报备时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date reportDate;
 
     /** 故障现象 */
@@ -56,6 +58,7 @@ public class TbFaultReport extends BaseEntity
     /** 处理状态 */
     @Excel(name = "处理状态")
     @TableField("process_state")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long processState;
 
     /** 处理结果 */

+ 2 - 0
lab-admin/src/main/java/com/ruoyi/asset/domain/TbPlace.java

@@ -3,6 +3,7 @@ package com.ruoyi.asset.domain;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
@@ -22,6 +23,7 @@ public class TbPlace extends BaseEntity
     /** 编号 */
     @Excel(name = "编号")
     @TableId("id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long id;
 
     /** 地点名称 */

+ 2 - 2
lab-admin/src/main/java/com/ruoyi/asset/domain/dto/TbAssetDTO.java

@@ -11,9 +11,9 @@ public class TbAssetDTO extends TbAsset {
     private String borrowStatus; // 借用状态 不可借、可借出、已借出
     private String borrowUserName; // 借出用户登录名称
     private String tel; // 联系电话
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date borrowDate; // 借出时间
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date returnDate; // 归还时间
     private boolean isMeBorrow; // 是否自己借出
 

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

@@ -0,0 +1,25 @@
+package com.ruoyi.asset.domain.dto;
+
+import com.ruoyi.asset.domain.TbAsset;
+import com.ruoyi.asset.domain.TbAssetBorrowRecord;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+public class TbBorrowRecordDTO extends TbAssetBorrowRecord {
+    private TbAsset tbAsset;
+
+    public TbAsset getTbAsset() {
+        return tbAsset;
+    }
+
+    public void setTbAsset(TbAsset tbAsset) {
+        this.tbAsset = tbAsset;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("tbAsset", getTbAsset())
+                .toString();
+    }
+}

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.asset.domain.TbAssetBorrowRecord;
+import com.ruoyi.asset.domain.dto.TbBorrowRecordDTO;
 import com.ruoyi.common.core.domain.AjaxResult;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -79,4 +80,28 @@ public interface ITbAssetBorrowRecordService extends IService<TbAssetBorrowRecor
      * @return 结果
      */
     AjaxResult updateBorrowRecordToReturn(String barCode);
+
+    /**
+     * 获取用户自己设备借用记录
+     *
+     * @param status 借用状态
+     * @return 设备借用记录集合
+     */
+    List<TbAssetBorrowRecord> selectMeTbAssetBorrowRecord(Long status);
+
+    /**
+     * 获取用户自己设备借用记录详细信息
+     *
+     * @param id 借用记录ID
+     * @return 设备借用记录信息
+     */
+    TbBorrowRecordDTO selectMeTbAssetBorrowRecordById(Long id);
+
+    /**
+     * 统计用户自己设备借用记录
+     *
+     * @param status 借用状态
+     * @return 统计数量
+     */
+    AjaxResult countMeTbAssetBorrowRecord(Long status);
 }

+ 2 - 0
lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetStatusRecordService.java

@@ -62,4 +62,6 @@ public interface ITbAssetStatusRecordService extends IService<TbAssetStatusRecor
      * @return 结果
      */
     public int deleteTbAssetStatusRecordById(Long id);
+
+
 }

+ 7 - 0
lab-admin/src/main/java/com/ruoyi/asset/service/ITbFaultReportService.java

@@ -80,4 +80,11 @@ public interface ITbFaultReportService extends IService<TbFaultReport>
      * @return 结果
      */
     public AjaxResult tbFaultReportProcess(TbFaultReportProcessDTO faultReportProcessDTO);
+
+    /**
+     * 获取用户自己故障报备记录
+     *
+     * @return 故障报备信息列表
+     */
+    List<TbFaultReport> selectMeTbFaultReport();
 }

+ 53 - 3
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetBorrowRecordServiceImpl.java

@@ -3,17 +3,18 @@ package com.ruoyi.asset.service.impl;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.asset.domain.TbAsset;
 import com.ruoyi.asset.domain.TbAssetStatusRecord;
 import com.ruoyi.asset.domain.TbPlace;
+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.asset.utils.UserUtils;
-import com.ruoyi.common.annotation.RepeatSubmit;
+import com.ruoyi.common.utils.UserUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.exception.ServiceException;
 import org.slf4j.Logger;
@@ -135,7 +136,7 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
             return AjaxResult.error("资产设备不存在");
         }
         TbAssetBorrowRecord borrowRecord = query().eq("asset_bar_code", assetBarCode).orderByDesc("borrow_date").last("limit 1").one();
-        if (borrowRecord != null && borrowRecord.getIsreturn() > 0) {
+        if (borrowRecord != null && borrowRecord.getIsreturn() < 1) {
             return AjaxResult.error("当前资产设备已借出");
         }
         if (tbAsset.getStatus() != 1) {
@@ -204,4 +205,53 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
         boolean result = updateById(borrowRecord);
         return result ? AjaxResult.success("归还成功") : AjaxResult.error("归还失败");
     }
+
+    /**
+     * 获取用户自己设备借用记录
+     *
+     * @return 设备借用记录集合
+     */
+    @Override
+    public List<TbAssetBorrowRecord> selectMeTbAssetBorrowRecord(Long status) {
+        Long loginUserId = UserUtils.getLoginUserId();
+        QueryWrapper<TbAssetBorrowRecord> borrowRecordQueryWrapper = new QueryWrapper<>();
+        borrowRecordQueryWrapper.eq("user_id", loginUserId).orderByDesc("borrow_date");
+        if (status != null) {
+            if (status < 0 || status > 1) {
+                status = 0L;
+            }
+            borrowRecordQueryWrapper.eq("isReturn", status);
+        }
+        return list(borrowRecordQueryWrapper);
+    }
+
+    @Override
+    public TbBorrowRecordDTO selectMeTbAssetBorrowRecordById(Long id) {
+        Long loginUserId = UserUtils.getLoginUserId();
+        TbAssetBorrowRecord borrowRecord = query().eq("user_id", loginUserId).eq("id", id).one();
+        if (borrowRecord == null) {
+            return null;
+        }
+        String assetBarCode = borrowRecord.getAssetBarCode();
+        TbAsset tbAsset = tbAssetMapper.selectTbAssetByBarCode(assetBarCode);
+
+        TbBorrowRecordDTO tbBorrowRecordDTO = BeanUtil.toBean(borrowRecord, TbBorrowRecordDTO.class);
+        tbBorrowRecordDTO.setTbAsset(tbAsset);
+        return tbBorrowRecordDTO;
+    }
+
+    @Override
+    public AjaxResult countMeTbAssetBorrowRecord(Long status) {
+        Long loginUserId = UserUtils.getLoginUserId();
+        QueryWrapper<TbAssetBorrowRecord> borrowRecordQueryWrapper = new QueryWrapper<>();
+        borrowRecordQueryWrapper.eq("user_id", loginUserId);
+        if (status != null) {
+            if (status < 0 || status > 1) {
+                status = 0L;
+            }
+            borrowRecordQueryWrapper.eq("isReturn", status);
+        }
+        int count = count(borrowRecordQueryWrapper);
+        return AjaxResult.success("查询成功", count);
+    }
 }

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

@@ -6,15 +6,13 @@ import java.util.stream.Collectors;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.asset.domain.TbAssetBorrowRecord;
 import com.ruoyi.asset.domain.TbAssetCategory;
 import com.ruoyi.asset.domain.dto.TbAssetDTO;
 import com.ruoyi.asset.mapper.TbAssetBorrowRecordMapper;
 import com.ruoyi.asset.mapper.TbAssetCategoryMapper;
-import com.ruoyi.asset.utils.UserUtils;
+import com.ruoyi.common.utils.UserUtils;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.system.mapper.SysDeptMapper;
@@ -197,11 +195,20 @@ public class TbAssetServiceImpl extends ServiceImpl<TbAssetMapper, TbAsset> impl
             assetList = query().like("bar_code", numberOrName).or().like("number", numberOrName).or().like("name", numberOrName).list();
         }
 
+        assetList = assetList.stream().filter(Objects::nonNull).collect(Collectors.toList());
+
+        if (assetList.isEmpty()) {
+            return Collections.emptyList();
+        }
+
         Long loginUserId = UserUtils.getLoginUserId();
 
         ArrayList<TbAssetDTO> assetDTOList = new ArrayList<>();
         for (TbAsset tbAsset : assetList) {
-            List<SysDept> collect = deptList.stream().filter(sysDept -> sysDept.getDeptId().equals(tbAsset.getDeptId())).collect(Collectors.toList());
+            List<SysDept> collect = Collections.emptyList();
+            if (tbAsset.getDeptId() != null) {
+                collect = deptList.stream().filter(sysDept -> sysDept.getDeptId().equals(tbAsset.getDeptId())).collect(Collectors.toList());
+            }
             if (!collect.isEmpty()) {
                 SysDept sysDept = collect.get(0);
                 tbAsset.setDeptName(sysDept.getDeptName());
@@ -231,7 +238,7 @@ public class TbAssetServiceImpl extends ServiceImpl<TbAssetMapper, TbAsset> impl
             SysUser sysUser = sysUserMapper.selectUserById(userId);
             tbAssetDTO.setBorrowUserName(sysUser.getUserName());
             tbAssetDTO.setBorrowDate(borrowRecord.getBorrowDate());
-            tbAssetDTO.setReturnDate(borrowRecord.getBorrowDate());
+            tbAssetDTO.setReturnDate(borrowRecord.getReturnDate());
             tbAssetDTO.setTel(borrowRecord.getTel());
             tbAssetDTO.setMeBorrow(borrowRecord.getUserId().equals(loginUserId));
 

+ 12 - 1
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbFaultReportServiceImpl.java

@@ -14,7 +14,7 @@ import com.ruoyi.asset.domain.enums.TbFaultProcessStateEnum;
 import com.ruoyi.asset.mapper.TbAssetBorrowRecordMapper;
 import com.ruoyi.asset.mapper.TbAssetMapper;
 import com.ruoyi.asset.mapper.TbAssetStatusRecordMapper;
-import com.ruoyi.asset.utils.UserUtils;
+import com.ruoyi.common.utils.UserUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.exception.ServiceException;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -212,4 +212,15 @@ public class TbFaultReportServiceImpl extends ServiceImpl<TbFaultReportMapper, T
         return result ? AjaxResult.success("故障报备处理成功", faultReport) : AjaxResult.error("故障报备处理失败");
     }
 
+    /**
+     * 获取用户自己故障报备记录
+     *
+     * @return 故障报备信息列表
+     */
+    @Override
+    public List<TbFaultReport> selectMeTbFaultReport() {
+        Long loginUserId = UserUtils.getLoginUserId();
+        return query().eq("user_id", loginUserId).orderByDesc("report_date").list();
+    }
+
 }

+ 0 - 5
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbPlaceServiceImpl.java

@@ -3,12 +3,7 @@ package com.ruoyi.asset.service.impl;
 import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.asset.utils.UserUtils;
-import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.framework.web.service.TokenService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Service;
 import com.ruoyi.asset.mapper.TbPlaceMapper;
 import com.ruoyi.asset.domain.TbPlace;

+ 4 - 0
lab-admin/src/main/resources/application.yml

@@ -107,6 +107,10 @@ mybatis-plus:
   mapperLocations: classpath*:mapper/**/*Mapper.xml
   # 加载全局的配置文件
   configLocation: classpath:mybatis/mybatis-config.xml
+  # 主键自增
+  global-config:
+    db-config:
+      id-type: auto
 
 # PageHelper分页插件
 pagehelper: 

+ 1 - 1
lab-admin/src/main/java/com/ruoyi/asset/utils/UserUtils.java → lab-common/src/main/java/com/ruoyi/common/utils/UserUtils.java

@@ -1,4 +1,4 @@
-package com.ruoyi.asset.utils;
+package com.ruoyi.common.utils;
 
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;

+ 1 - 1
lab-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -376,7 +376,7 @@ public class SysUserServiceImpl implements ISysUserService
 
     /**
      * 重置用户密码
-     * 
+     *
      * @param userName 用户名
      * @param password 密码
      * @return 结果

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

@@ -116,17 +116,17 @@
       </el-table-column>
       <el-table-column label="借用时间" align="center" prop="borrowDate" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.borrowDate, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.borrowDate, '{y}-{m}-{d} {hh}:{mm}:{ss}') }}</span>
         </template>
       </el-table-column>
       <el-table-column label="归还时间" align="center" prop="returnDate" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.returnDate, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.returnDate, '{y}-{m}-{d} {hh}:{mm}:{ss}') }}</span>
         </template>
       </el-table-column>
       <el-table-column label="实际归还时间" align="center" prop="actualReturnDate" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.actualReturnDate, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.actualReturnDate, '{y}-{m}-{d} {hh}:{mm}:{ss}') }}</span>
         </template>
       </el-table-column>
       <el-table-column label="借用地点" align="center" prop="borrowPlaceName" />

+ 2 - 2
lab-ui/src/views/asset/fault/index.vue

@@ -94,7 +94,7 @@
       <el-table-column label="报备人" align="center" prop="userId" />
       <el-table-column label="报备时间" align="center" prop="reportDate" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.reportDate, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.reportDate, '{y}-{m}-{d} {hh}:{mm}:{ss}') }}</span>
         </template>
       </el-table-column>
       <el-table-column label="故障现象" align="center" prop="faultPhenomenon" />
@@ -162,7 +162,7 @@
               v-for="dict in dict.type.asset_fault_process_state"
               :key="dict.value"
               :label="dict.label"
-:value="parseInt(dict.value)"
+              :value="parseInt(dict.value)"
             ></el-option>
           </el-select>
         </el-form-item>

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

@@ -77,7 +77,7 @@
       <el-table-column label="故障次数" align="center" prop="faultNumber" />
       <el-table-column label="最近故障时间" align="center" prop="lastFaultDate" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.lastFaultDate, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.lastFaultDate, '{y}-{m}-{d} {hh}:{mm}:{ss}') }}</span>
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">