Răsfoiți Sursa

林武泰/新增小程序扫码查询、关键字搜索查询、设备借出、设备归还、最新通知公告查询功能;新增正则表达式工具类;新增设备借用记录“实际归还时间”字段;

LinWuTai 2 ani în urmă
părinte
comite
e7f4073d77
21 a modificat fișierele cu 556 adăugiri și 41 ștergeri
  1. 51 0
      lab-admin/src/main/java/com/ruoyi/asset/controller/TbAssetBorrowRecordController.java
  2. 13 12
      lab-admin/src/main/java/com/ruoyi/asset/controller/TbAssetController.java
  3. 16 1
      lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetBorrowRecord.java
  4. 79 0
      lab-admin/src/main/java/com/ruoyi/asset/domain/dto/TbAssetDTO.java
  5. 4 0
      lab-admin/src/main/java/com/ruoyi/asset/mapper/TbAssetMapper.java
  6. 4 0
      lab-admin/src/main/java/com/ruoyi/asset/mapper/TbPlaceMapper.java
  7. 17 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetBorrowRecordService.java
  8. 11 9
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetService.java
  9. 84 0
      lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetBorrowRecordServiceImpl.java
  10. 89 16
      lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetServiceImpl.java
  11. 26 0
      lab-admin/src/main/java/com/ruoyi/asset/utils/RegexPatterns.java
  12. 53 0
      lab-admin/src/main/java/com/ruoyi/asset/utils/RegexUtils.java
  13. 22 0
      lab-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java
  14. 6 1
      lab-admin/src/main/resources/mapper/asset/TbAssetBorrowRecordMapper.xml
  15. 1 1
      lab-admin/src/main/resources/mapper/asset/TbAssetMapper.xml
  16. 3 0
      lab-system/src/main/java/com/ruoyi/system/domain/SysNotice.java
  17. 14 0
      lab-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java
  18. 15 0
      lab-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java
  19. 15 0
      lab-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java
  20. 10 1
      lab-system/src/main/resources/mapper/system/SysNoticeMapper.xml
  21. 23 0
      lab-ui/src/views/asset/borrow/index.vue

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

@@ -1,7 +1,11 @@
 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.utils.RegexUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -101,4 +105,51 @@ public class TbAssetBorrowRecordController extends BaseController
     {
         return toAjax(tbAssetBorrowRecordService.deleteTbAssetBorrowRecordByIds(ids));
     }
+
+    /**
+     * 小程序:新增设备借用记录
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:add')")
+    @Log(title = "设备借用记录", businessType = BusinessType.INSERT)
+    @PostMapping("/save")
+    public AjaxResult saveBorrowRecord(@RequestBody TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        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 = tbAssetBorrowRecord.getBorrowDate();
+        if (nowDate.after(borrowDate)) {
+            return AjaxResult.error("借用日期不能早于当前日期");
+        }
+        Date returnDate = tbAssetBorrowRecord.getReturnDate();
+        if (!returnDate.after(borrowDate)) {
+            return AjaxResult.error("归还日期不能早于借用日期");
+        }
+
+        return tbAssetBorrowRecordService.saveBorrowRecord(tbAssetBorrowRecord);
+    }
+
+    /**
+     * 修改设备借用记录为归还
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:edit')")
+    @Log(title = "修改设备借用记录为归还", businessType = BusinessType.UPDATE)
+    @PutMapping("/return/{barCode}")
+    public AjaxResult updateBorrowRecordToReturn(@PathVariable("barCode") String barCode)
+    {
+        return tbAssetBorrowRecordService.updateBorrowRecordToReturn(barCode);
+    }
 }

+ 13 - 12
lab-admin/src/main/java/com/ruoyi/asset/controller/TbAssetController.java

@@ -3,16 +3,10 @@ package com.ruoyi.asset.controller;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ruoyi.asset.domain.dto.TbAssetDTO;
 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;
@@ -129,11 +123,18 @@ public class TbAssetController extends BaseController
     }
 
     /**
-     * 根据条形码获取资产信息
+     * 小程序:获取资产信息
      */
     @PreAuthorize("@ss.hasPermi('asset:asset:query')")
-    @GetMapping(value = "/barcode/{barCode}")
-    public AjaxResult selectTbAssetByBarCode(@PathVariable("barCode") String barCode) {
-        return AjaxResult.success(tbAssetService.selectTbAssetByBarCode(barCode));
+    @GetMapping(value = "/search")
+    public AjaxResult selectTbAssetByBarCode(
+            @RequestParam(value = "barCode", required = false) String barCode,
+            @RequestParam(value = "numberOrName", required = false) String numberOrName
+    ) {
+        List<TbAssetDTO> tbAssetDTOS = tbAssetService.selectTbAsset(barCode, numberOrName);
+        if (barCode != null) {
+            return AjaxResult.success(tbAssetDTOS.get(0));
+        }
+        return AjaxResult.success(tbAssetDTOS);
     }
 }

+ 16 - 1
lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetBorrowRecord.java

@@ -59,6 +59,12 @@ public class TbAssetBorrowRecord extends BaseEntity
     @Excel(name = "归还时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date returnDate;
 
+    /** 实际归还时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @TableField("actual_return_date")
+    @Excel(name = "实际归还时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date actualReturnDate;
+
     /** 借用地点 */
     @Excel(name = "借用地点")
     @TableField("asset_bar_code")
@@ -131,7 +137,16 @@ public class TbAssetBorrowRecord extends BaseEntity
     {
         return returnDate;
     }
-    public void setBorrowPlaceName(String borrowPlaceName) 
+
+    public Date getActualReturnDate() {
+        return actualReturnDate;
+    }
+
+    public void setActualReturnDate(Date actualReturnDate) {
+        this.actualReturnDate = actualReturnDate;
+    }
+
+    public void setBorrowPlaceName(String borrowPlaceName)
     {
         this.borrowPlaceName = borrowPlaceName;
     }

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

@@ -0,0 +1,79 @@
+package com.ruoyi.asset.domain.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.asset.domain.TbAsset;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.Date;
+
+public class TbAssetDTO extends TbAsset {
+    private String borrowStatus; // 借用状态 不可借、可借出、已借出
+    private String borrowUserName; // 借出用户登录名称
+    private String tel; // 联系电话
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date borrowDate; // 借出时间
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date returnDate; // 归还时间
+    private boolean isMeBorrow; // 是否自己借出
+
+    public String getBorrowStatus() {
+        return borrowStatus;
+    }
+
+    public void setBorrowStatus(String borrowStatus) {
+        this.borrowStatus = borrowStatus;
+    }
+
+    public String getBorrowUserName() {
+        return borrowUserName;
+    }
+
+    public void setBorrowUserName(String borrowUserName) {
+        this.borrowUserName = borrowUserName;
+    }
+
+    public String getTel() {
+        return tel;
+    }
+
+    public void setTel(String tel) {
+        this.tel = tel;
+    }
+
+    public Date getBorrowDate() {
+        return borrowDate;
+    }
+
+    public void setBorrowDate(Date borrowDate) {
+        this.borrowDate = borrowDate;
+    }
+
+    public Date getReturnDate() {
+        return returnDate;
+    }
+
+    public void setReturnDate(Date returnDate) {
+        this.returnDate = returnDate;
+    }
+
+    public boolean isMeBorrow() {
+        return isMeBorrow;
+    }
+
+    public void setMeBorrow(boolean meBorrow) {
+        this.isMeBorrow = meBorrow;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("borrowStatus", getBorrowStatus())
+                .append("borrowUserName", getBorrowUserName())
+                .append("tel", getTel())
+                .append("borrowDate", getBorrowDate())
+                .append("returnDate", getReturnDate())
+                .append("isMeBorrow", isMeBorrow())
+                .toString();
+    }
+}

+ 4 - 0
lab-admin/src/main/java/com/ruoyi/asset/mapper/TbAssetMapper.java

@@ -5,6 +5,7 @@ import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.asset.domain.TbAsset;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 资产信息Mapper接口
@@ -70,4 +71,7 @@ public interface TbAssetMapper extends BaseMapper<TbAsset>
      * @return 结果
      */
     public int replace(TbAsset tbAsset);
+
+    @Select("select id, bar_code, number, name, kind, category_number, amount, quantity, quantity_unit, build_date, place_name, purpose, dept_id, registrant, specifications_model, remark, manufacturer, brand, supplier, status from tb_asset where bar_code = #{barCode}")
+    public TbAsset selectTbAssetByBarCode(String barCode);
 }

+ 4 - 0
lab-admin/src/main/java/com/ruoyi/asset/mapper/TbPlaceMapper.java

@@ -5,6 +5,7 @@ import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.asset.domain.TbPlace;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 地点Mapper接口
@@ -64,4 +65,7 @@ public interface TbPlaceMapper extends BaseMapper<TbPlace>
     public int deleteTbPlaceByIds(Long[] ids);
 
     int replace(TbPlace place);
+
+    @Select("select id, name, purpose from tb_place where name = #{name}")
+    TbPlace selectTbPlaceByName(String name);
 }

+ 17 - 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.common.core.domain.AjaxResult;
 
 /**
  * 设备借用记录Service接口
@@ -60,4 +61,20 @@ public interface ITbAssetBorrowRecordService extends IService<TbAssetBorrowRecor
      * @return 结果
      */
     public int deleteTbAssetBorrowRecordById(Long id);
+
+    /**
+     * 新增设备借用记录
+     *
+     * @param tbAssetBorrowRecord 设备借用记录信息
+     * @return 结果
+     */
+    AjaxResult saveBorrowRecord(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
+     * 修改设备借用记录为归还
+     *
+     * @param barCode 资产条形码
+     * @return 结果
+     */
+    AjaxResult updateBorrowRecordToReturn(String barCode);
 }

+ 11 - 9
lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.asset.domain.TbAsset;
+import com.ruoyi.asset.domain.dto.TbAssetDTO;
 
 /**
  * 资产信息Service接口
@@ -55,21 +56,13 @@ public interface ITbAssetService extends IService<TbAsset>
 
     /**
      * 删除资产信息信息
-     * 
+     *
      * @param id 资产信息主键
      * @return 结果
      */
     public int deleteTbAssetById(Long id);
 
     /**
-     * 根据条形码查询资产信息
-     *
-     * @param barCode 资产条形码
-     * @return 资产信息
-     */
-    TbAsset selectTbAssetByBarCode(String barCode);
-
-    /**
      * 批量新增
      *
      * @param tbAssetList 资产信息集合
@@ -83,4 +76,13 @@ public interface ITbAssetService extends IService<TbAsset>
      * @return 资产信息集合
      */
     List<TbAsset> exportData(TbAsset tbAsset);
+
+    /**
+     * 查询资产信息
+     *
+     * @param barCode 资产条形码
+     * @param numberOrName 资产编号或名称
+     * @return 资产信息列表
+     */
+    List<TbAssetDTO> selectTbAsset(String barCode, String numberOrName);
 }

+ 84 - 0
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetBorrowRecordServiceImpl.java

@@ -1,14 +1,28 @@
 package com.ruoyi.asset.service.impl;
 
+import java.util.Date;
 import java.util.List;
 
+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.TbPlace;
+import com.ruoyi.asset.mapper.TbAssetMapper;
+import com.ruoyi.asset.mapper.TbPlaceMapper;
+import com.ruoyi.asset.utils.UserUtils;
+import com.ruoyi.common.annotation.RepeatSubmit;
+import com.ruoyi.common.core.domain.AjaxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.asset.mapper.TbAssetBorrowRecordMapper;
 import com.ruoyi.asset.domain.TbAssetBorrowRecord;
 import com.ruoyi.asset.service.ITbAssetBorrowRecordService;
 
+import javax.annotation.Resource;
+
 /**
  * 设备借用记录Service业务层处理
  * 
@@ -18,9 +32,17 @@ import com.ruoyi.asset.service.ITbAssetBorrowRecordService;
 @Service
 public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRecordMapper, TbAssetBorrowRecord> implements ITbAssetBorrowRecordService
 {
+    private static final Logger log = LoggerFactory.getLogger(TbAssetBorrowRecordServiceImpl.class);
+
     @Autowired
     private TbAssetBorrowRecordMapper tbAssetBorrowRecordMapper;
 
+    @Resource
+    private TbAssetMapper tbAssetMapper;
+
+    @Resource
+    private TbPlaceMapper tbPlaceMapper;
+
     /**
      * 查询设备借用记录
      * 
@@ -92,4 +114,66 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
     {
         return tbAssetBorrowRecordMapper.deleteTbAssetBorrowRecordById(id);
     }
+
+    /**
+     * 新增设备借用记录
+     *
+     * @param tbAssetBorrowRecord 设备借用记录信息
+     * @return 结果
+     */
+    @Override
+    public AjaxResult saveBorrowRecord(TbAssetBorrowRecord tbAssetBorrowRecord) {
+        String assetBarCode = tbAssetBorrowRecord.getAssetBarCode();
+        TbAsset tbAsset = tbAssetMapper.selectTbAssetByBarCode(assetBarCode);
+        if (tbAsset == null) {
+            return AjaxResult.error("资产设备不存在");
+        }
+        TbAssetBorrowRecord borrowRecord = query().eq("asset_bar_code", assetBarCode).orderByDesc("borrow_date").last("limit 1").one();
+        if (borrowRecord != null && borrowRecord.getIsreturn() > 0) {
+            return AjaxResult.error("当前资产设备已借出");
+        }
+        if (tbAsset.getStatus() != 1) {
+            if (tbAsset.getStatus() == 0) {
+                return AjaxResult.error("当前资产设备已故障");
+            }
+            if (tbAsset.getStatus() == 2) {
+                return AjaxResult.error("当前资产设备已报废");
+            }
+        }
+        String borrowPlaceName = tbAssetBorrowRecord.getBorrowPlaceName();
+        TbPlace tbPlace = tbPlaceMapper.selectTbPlaceByName(borrowPlaceName);
+        if (tbPlace == null) {
+            return AjaxResult.error("借用地点不存在");
+        }
+
+        Long userId = UserUtils.getLoginUserId();
+        tbAssetBorrowRecord.setUserId(userId);
+        tbAssetBorrowRecord.setIsreturn(0L);
+        tbAssetBorrowRecord.setActualReturnDate(null);
+
+        return AjaxResult.success();
+    }
+
+    @Override
+    public AjaxResult updateBorrowRecordToReturn(String barCode) {
+        if (StrUtil.isBlank(barCode)) {
+            return AjaxResult.error("资产条形码不能为空");
+        }
+        TbAssetBorrowRecord borrowRecord = query().eq("asset_bar_code", barCode).orderByDesc("borrow_date").last("limit 1").one();
+        if (borrowRecord == null) {
+            return AjaxResult.error("查无借用记录");
+        }
+        if (borrowRecord.getIsreturn() > 0) {
+            return AjaxResult.error("资产设备已归还");
+        }
+        Long borrowUserId = borrowRecord.getUserId();
+        Long returnUserId = UserUtils.getLoginUserId();
+        if (!borrowUserId.equals(returnUserId)) {
+            return AjaxResult.error("非借用人本人归还");
+        }
+        borrowRecord.setIsreturn(1L);
+        borrowRecord.setActualReturnDate(new Date());
+        boolean result = updateById(borrowRecord);
+        return result ? AjaxResult.success("归还成功") : AjaxResult.error("归还失败");
+    }
 }

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

@@ -1,19 +1,24 @@
 package com.ruoyi.asset.service.impl;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 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.core.domain.entity.SysDept;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.system.mapper.SysDeptMapper;
+import com.ruoyi.system.mapper.SysUserMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.asset.mapper.TbAssetMapper;
@@ -38,8 +43,14 @@ public class TbAssetServiceImpl extends ServiceImpl<TbAssetMapper, TbAsset> impl
     private SysDeptMapper sysDeptMapper;
 
     @Resource
+    private SysUserMapper sysUserMapper;
+
+    @Resource
     private TbAssetCategoryMapper tbAssetCategoryMapper;
 
+    @Resource
+    private TbAssetBorrowRecordMapper tbAssetBorrowRecordMapper;
+
     /**
      * 查询资产信息
      * 
@@ -113,22 +124,12 @@ public class TbAssetServiceImpl extends ServiceImpl<TbAssetMapper, TbAsset> impl
     }
 
     /**
-     * 根据条形码查询资产信息
+     * 批量新增资产信息
      *
-     * @param barCode 资产条形码
-     * @return 资产信息
+     * @param tbAssetList 资产信息集合
+     * @return 结果
      */
     @Override
-    public TbAsset selectTbAssetByBarCode(String barCode) {
-        // 判断条形码是否为空
-        if (StrUtil.isBlank(barCode)) {
-            return null;
-        }
-        // 查询资产信息
-        return query().eq("bar_code", barCode).one();
-    }
-
-    @Override
     public boolean batchTbAsset(List<TbAsset> tbAssetList) {
         int success = 0;
         List<SysDept> deptList = sysDeptMapper.allDept();
@@ -157,6 +158,12 @@ public class TbAssetServiceImpl extends ServiceImpl<TbAssetMapper, TbAsset> impl
         return success != 0;
     }
 
+    /**
+     * 数据导出
+     *
+     * @param asset 资产信息
+     * @return 资产信息集合
+     */
     @Override
     public List<TbAsset> exportData(TbAsset asset) {
         List<SysDept> deptList = sysDeptMapper.allDept();
@@ -168,4 +175,70 @@ public class TbAssetServiceImpl extends ServiceImpl<TbAssetMapper, TbAsset> impl
         }
         return assetList;
     }
+
+    /**
+     * 小程序:获取资产信息
+     *
+     * @param barCode 资产条形码
+     * @param numberOrName 资产编号或名称
+     * @return 资产信息(含借用信息)集合
+     */
+    @Override
+    public List<TbAssetDTO> selectTbAsset(String barCode, String numberOrName) {
+        List<SysDept> deptList = sysDeptMapper.allDept();
+        if (StrUtil.isBlank(barCode) && StrUtil.isBlank(numberOrName)) {
+            return Collections.emptyList();
+        }
+        List<TbAsset> assetList = new ArrayList<>();
+        if (StrUtil.isNotBlank(barCode)) {
+            TbAsset asset = query().eq("bar_code", barCode).one();
+            assetList.add(asset);
+        } else {
+            assetList = query().like("bar_code", numberOrName).or().like("number", numberOrName).or().like("name", numberOrName).list();
+        }
+
+        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());
+            if (!collect.isEmpty()) {
+                SysDept sysDept = collect.get(0);
+                tbAsset.setDeptName(sysDept.getDeptName());
+            }
+            TbAssetDTO tbAssetDTO = BeanUtil.toBean(tbAsset, TbAssetDTO.class);
+            if (tbAsset.getStatus() != 1) {
+                tbAssetDTO.setBorrowStatus("不可借");
+                assetDTOList.add(tbAssetDTO);
+                continue;
+            }
+            QueryWrapper<TbAssetBorrowRecord> borrowRecordQueryWrapper = new QueryWrapper<>();
+            borrowRecordQueryWrapper.eq("asset_bar_code", tbAsset.getBarCode()).orderByDesc("borrow_date").last("limit 1");
+            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;
+            }
+            tbAssetDTO.setBorrowStatus("已借出");
+            Long userId = borrowRecord.getUserId();
+            SysUser sysUser = sysUserMapper.selectUserById(userId);
+            tbAssetDTO.setBorrowUserName(sysUser.getUserName());
+            tbAssetDTO.setBorrowDate(borrowRecord.getBorrowDate());
+            tbAssetDTO.setReturnDate(borrowRecord.getBorrowDate());
+            tbAssetDTO.setTel(borrowRecord.getTel());
+            tbAssetDTO.setMeBorrow(borrowRecord.getUserId().equals(loginUserId));
+
+            assetDTOList.add(tbAssetDTO);
+        }
+
+
+        return assetDTOList;
+    }
 }

+ 26 - 0
lab-admin/src/main/java/com/ruoyi/asset/utils/RegexPatterns.java

@@ -0,0 +1,26 @@
+package com.ruoyi.asset.utils;
+
+
+public abstract class RegexPatterns {
+    /**
+     * 负浮点数
+     */
+    public static final String NEGATIVE_FLOAT = "^-([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)$";
+    /**
+     * 手机号正则
+     */
+    public static final String PHONE_REGEX = "^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\\d{8}$";
+    /**
+     * 邮箱正则
+     */
+    public static final String EMAIL_REGEX = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
+    /**
+     * 密码正则。4~32位的字母、数字、下划线
+     */
+    public static final String PASSWORD_REGEX = "^\\w{4,32}$";
+    /**
+     * 验证码正则, 6位数字或字母
+     */
+    public static final String VERIFY_CODE_REGEX = "^[a-zA-Z\\d]{6}$";
+
+}

+ 53 - 0
lab-admin/src/main/java/com/ruoyi/asset/utils/RegexUtils.java

@@ -0,0 +1,53 @@
+package com.ruoyi.asset.utils;
+
+import cn.hutool.core.util.StrUtil;
+
+import static com.ruoyi.asset.utils.RegexPatterns.*;
+
+/**
+ * @author 林武泰
+ * 正则校验工具类
+ */
+public class RegexUtils {
+    /**
+     * 是否非负浮点数
+     * @param number 要检验的浮点数
+     * @return true:符合,false:不符合
+     */
+    public static boolean isNegativeFloat(String number) {
+        return mismatch(number, NEGATIVE_FLOAT);
+    }
+    /**
+     * 是否是无效手机格式
+     * @param phone 要校验的手机号
+     * @return true:符合,false:不符合
+     */
+    public static boolean isPhoneInvalid(String phone){
+        return mismatch(phone, PHONE_REGEX);
+    }
+    /**
+     * 是否是无效邮箱格式
+     * @param email 要校验的邮箱
+     * @return true:符合,false:不符合
+     */
+    public static boolean isEmailInvalid(String email){
+        return mismatch(email, EMAIL_REGEX);
+    }
+
+    /**
+     * 是否是无效验证码格式
+     * @param code 要校验的验证码
+     * @return true:符合,false:不符合
+     */
+    public static boolean isCodeInvalid(String code){
+        return mismatch(code, VERIFY_CODE_REGEX);
+    }
+
+    // 校验是否不符合正则格式
+    private static boolean mismatch(String str, String regex){
+        if (StrUtil.isBlank(str)) {
+            return true;
+        }
+        return !str.matches(regex);
+    }
+}

+ 22 - 0
lab-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java

@@ -88,4 +88,26 @@ public class SysNoticeController extends BaseController
     {
         return toAjax(noticeService.deleteNoticeByIds(noticeIds));
     }
+
+    /**
+     * 获取最新公告信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:notice:query')")
+    @GetMapping("/newNotice")
+    public AjaxResult getNewNotice()
+    {
+        SysNotice sysNotice = noticeService.selectNewNotice();
+        return sysNotice != null ? AjaxResult.success(sysNotice) : error("暂无公告");
+    }
+
+    /**
+     * 获取最新通知信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:notice:query')")
+    @GetMapping("/newInform")
+    public AjaxResult getNewInform()
+    {
+        SysNotice sysNotice = noticeService.selectNewInform();
+        return sysNotice != null ? AjaxResult.success(sysNotice) : error("暂无通知");
+    }
 }

+ 6 - 1
lab-admin/src/main/resources/mapper/asset/TbAssetBorrowRecordMapper.xml

@@ -12,12 +12,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isreturn"    column="isReturn"    />
         <result property="borrowDate"    column="borrow_date"    />
         <result property="returnDate"    column="return_date"    />
+        <result property="actualReturnDate"    column="actual_return_date"    />
         <result property="borrowPlaceName"    column="borrow_place_name"    />
         <result property="remark"    column="remark"    />
     </resultMap>
 
     <sql id="selectTbAssetBorrowRecordVo">
-        select id, asset_bar_code, user_id, tel, isReturn, borrow_date, return_date, borrow_place_name, remark from tb_asset_borrow_record
+        select id, asset_bar_code, user_id, tel, isReturn, borrow_date, return_date, actual_return_date, borrow_place_name, remark from tb_asset_borrow_record
     </sql>
 
     <select id="selectTbAssetBorrowRecordList" parameterType="TbAssetBorrowRecord" resultMap="TbAssetBorrowRecordResult">
@@ -28,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isreturn != null "> and isReturn = #{isreturn}</if>
             <if test="borrowDate != null "> and borrow_date = #{borrowDate}</if>
             <if test="returnDate != null "> and return_date = #{returnDate}</if>
+            <if test="actualReturnDate != null "> and actual_return_date = #{actualReturnDate}</if>
         </where>
     </select>
     
@@ -45,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isreturn != null">isReturn,</if>
             <if test="borrowDate != null">borrow_date,</if>
             <if test="returnDate != null">return_date,</if>
+            <if test="actualReturnDate != null">actual_return_date,</if>
             <if test="borrowPlaceName != null and borrowPlaceName != ''">borrow_place_name,</if>
             <if test="remark != null">remark,</if>
          </trim>
@@ -55,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isreturn != null">#{isreturn},</if>
             <if test="borrowDate != null">#{borrowDate},</if>
             <if test="returnDate != null">#{returnDate},</if>
+            <if test="actualReturnDate != null">#{actualReturnDate},</if>
             <if test="borrowPlaceName != null and borrowPlaceName != ''">#{borrowPlaceName},</if>
             <if test="remark != null">#{remark},</if>
          </trim>
@@ -69,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isreturn != null">isReturn = #{isreturn},</if>
             <if test="borrowDate != null">borrow_date = #{borrowDate},</if>
             <if test="returnDate != null">return_date = #{returnDate},</if>
+            <if test="actualReturnDate != null">actual_return_date = #{actualReturnDate},</if>
             <if test="borrowPlaceName != null and borrowPlaceName != ''">borrow_place_name = #{borrowPlaceName},</if>
             <if test="remark != null">remark = #{remark},</if>
         </trim>

+ 1 - 1
lab-admin/src/main/resources/mapper/asset/TbAssetMapper.xml

@@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="purpose != null  and purpose != ''"> and purpose = #{purpose}</if>
             <if test="deptId != null "> and dept_id = #{deptId}</if>
             <if test="registrant != null  and registrant != ''"> and registrant = #{registrant}</if>
-            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>
+            <if test="remark != null  and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
             <if test="manufacturer != null  and manufacturer != ''"> and manufacturer = #{manufacturer}</if>
             <if test="brand != null  and brand != ''"> and brand = #{brand}</if>
             <if test="supplier != null  and supplier != ''"> and supplier = #{supplier}</if>

+ 3 - 0
lab-system/src/main/java/com/ruoyi/system/domain/SysNotice.java

@@ -2,6 +2,8 @@ package com.ruoyi.system.domain;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.Size;
+
+import com.baomidou.mybatisplus.annotation.TableName;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.core.domain.BaseEntity;
@@ -12,6 +14,7 @@ import com.ruoyi.common.xss.Xss;
  * 
  * @author ruoyi
  */
+@TableName("sys_notice")
 public class SysNotice extends BaseEntity
 {
     private static final long serialVersionUID = 1L;

+ 14 - 0
lab-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java

@@ -57,4 +57,18 @@ public interface SysNoticeMapper
      * @return 结果
      */
     public int deleteNoticeByIds(Long[] noticeIds);
+
+    /**
+     * 获取最新公告信息
+     *
+     * @return 公告信息
+     */
+    SysNotice selectNewNotice();
+
+    /**
+     * 获取最新通知信息
+     *
+     * @return 通知信息
+     */
+    SysNotice selectNewInform();
 }

+ 15 - 0
lab-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java

@@ -2,6 +2,7 @@ package com.ruoyi.system.service;
 
 import java.util.List;
 import com.ruoyi.system.domain.SysNotice;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 公告 服务层
@@ -57,4 +58,18 @@ public interface ISysNoticeService
      * @return 结果
      */
     public int deleteNoticeByIds(Long[] noticeIds);
+
+    /**
+     * 获取最新公告信息
+     *
+     * @return 公告信息
+     */
+    SysNotice selectNewNotice();
+
+    /**
+     * 获取最新通知信息
+     *
+     * @return 公告信息
+     */
+    SysNotice selectNewInform();
 }

+ 15 - 0
lab-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java

@@ -89,4 +89,19 @@ public class SysNoticeServiceImpl implements ISysNoticeService
     {
         return noticeMapper.deleteNoticeByIds(noticeIds);
     }
+
+    /**
+     * 获取最新公告信息
+     *
+     * @return 公告信息
+     */
+    @Override
+    public SysNotice selectNewNotice() {
+        return noticeMapper.selectNewNotice();
+    }
+
+    @Override
+    public SysNotice selectNewInform() {
+        return noticeMapper.selectNewInform();
+    }
 }

+ 10 - 1
lab-system/src/main/resources/mapper/system/SysNoticeMapper.xml

@@ -85,5 +85,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{noticeId}
         </foreach>
     </delete>
-    
+
+    <select id="selectNewNotice" resultMap="SysNoticeResult">
+        <include refid="selectNoticeVo"/>
+        where status = 0 and notice_type = 2 order by create_time desc, update_time desc limit 1
+    </select>
+
+    <select id="selectNewInform" resultMap="SysNoticeResult">
+        <include refid="selectNoticeVo"/>
+        where status = 0 and notice_type = 1 order by create_time desc, update_time desc limit 1
+    </select>
 </mapper>

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

@@ -43,6 +43,14 @@
           placeholder="请选择归还时间">
         </el-date-picker>
       </el-form-item>
+      <el-form-item label="实际归还时间" prop="actualReturnDate">
+        <el-date-picker clearable
+          v-model="queryParams.actualReturnDate"
+          type="date"
+          value-format="yyyy-MM-dd"
+          placeholder="请选择实际归还时间">
+        </el-date-picker>
+      </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -116,6 +124,11 @@
           <span>{{ parseTime(scope.row.returnDate, '{y}-{m}-{d}') }}</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>
+        </template>
+      </el-table-column>
       <el-table-column label="借用地点" align="center" prop="borrowPlaceName" />
       <el-table-column label="备注" align="center" prop="remark" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -184,6 +197,14 @@
             placeholder="请选择归还时间">
           </el-date-picker>
         </el-form-item>
+        <el-form-item label="实际归还时间" prop="returnDate">
+          <el-date-picker clearable
+            v-model="form.actualReturnDate"
+            type="date"
+            value-format="yyyy-MM-dd"
+            placeholder="请选择实际归还时间">
+          </el-date-picker>
+        </el-form-item>
         <el-form-item label="借用地点" prop="borrowPlaceName">
           <el-input v-model="form.borrowPlaceName" placeholder="请输入借用地点" />
         </el-form-item>
@@ -234,6 +255,7 @@ export default {
         isreturn: null,
         borrowDate: null,
         returnDate: null,
+        actualReturnDate: null
       },
       // 表单参数
       form: {},
@@ -291,6 +313,7 @@ export default {
         isreturn: null,
         borrowDate: null,
         returnDate: null,
+        actualReturnDate: null,
         borrowPlaceName: null,
         remark: null
       };