Procházet zdrojové kódy

林武泰/修改优化小程序扫码查询、关键字搜索查询、设备借出、设备归还、最新通知公告查询功能;新增用户名注册限制;新增故障上报、故障处理功能

LinWuTai před 2 roky
rodič
revize
b733f955ea
25 změnil soubory, kde provedl 381 přidání a 30 odebrání
  1. 49 0
      lab-admin/src/main/java/com/ruoyi/asset/controller/TbFaultReportController.java
  2. 1 1
      lab-admin/src/main/java/com/ruoyi/asset/domain/TbAssetBorrowRecord.java
  3. 13 0
      lab-admin/src/main/java/com/ruoyi/asset/domain/dto/TbFaultReportProcessDTO.java
  4. 25 0
      lab-admin/src/main/java/com/ruoyi/asset/domain/enums/TbAssetStatusEnum.java
  5. 23 0
      lab-admin/src/main/java/com/ruoyi/asset/domain/enums/TbFaultProcessStateEnum.java
  6. 5 0
      lab-admin/src/main/java/com/ruoyi/asset/mapper/TbAssetMapper.java
  7. 4 0
      lab-admin/src/main/java/com/ruoyi/asset/mapper/TbAssetStatusRecordMapper.java
  8. 2 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetBorrowRecordService.java
  9. 2 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetCategoryService.java
  10. 2 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetService.java
  11. 2 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbAssetStatusRecordService.java
  12. 20 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbFaultReportService.java
  13. 2 0
      lab-admin/src/main/java/com/ruoyi/asset/service/ITbPlaceService.java
  14. 29 1
      lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetBorrowRecordServiceImpl.java
  15. 120 0
      lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbFaultReportServiceImpl.java
  16. 4 0
      lab-admin/src/main/java/com/ruoyi/asset/utils/RegexPatterns.java
  17. 8 0
      lab-admin/src/main/java/com/ruoyi/asset/utils/RegexUtils.java
  18. 27 14
      lab-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java
  19. 2 0
      lab-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
  20. 6 0
      lab-system/pom.xml
  21. 2 2
      lab-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java
  22. 4 4
      lab-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java
  23. 4 4
      lab-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java
  24. 21 0
      lab-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
  25. 4 4
      lab-system/src/main/resources/mapper/system/SysNoticeMapper.xml

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

@@ -2,6 +2,10 @@ 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 org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -101,4 +105,49 @@ public class TbFaultReportController extends BaseController
     {
         return toAjax(tbFaultReportService.deleteTbFaultReportByIds(ids));
     }
+
+    /**
+     * 小程序:新增故障报备
+     */
+    @PreAuthorize("@ss.hasPermi('asset:fault:add')")
+    @Log(title = "故障报备", businessType = BusinessType.INSERT)
+    @PostMapping("/save")
+    public AjaxResult saveFaultReport(@RequestBody TbFaultReport tbFaultReport)
+    {
+        String assetBarCode = tbFaultReport.getAssetBarCode();
+        if (StrUtil.isBlank(assetBarCode)) {
+            return AjaxResult.error("资产设备条形码不能为空");
+        }
+        String tel = tbFaultReport.getTel();
+        if (StrUtil.isBlank(tel)) {
+            return AjaxResult.error("报备人电话不能为空");
+        }
+        if (RegexUtils.isPhoneInvalid(tel)) {
+            return AjaxResult.error("电话格式错误");
+        }
+        String faultPhenomenon = tbFaultReport.getFaultPhenomenon();
+        if (StrUtil.isBlank(faultPhenomenon)) {
+            return AjaxResult.error("故障现象不能为空");
+        }
+        return tbFaultReportService.saveTbFaultReport(tbFaultReport);
+    }
+
+    /**
+     * 故障报备处理
+     */
+    @PreAuthorize("@ss.hasPermi('asset:fault:edit')")
+    @Log(title = "故障报备", businessType = BusinessType.UPDATE)
+    @PutMapping("/process")
+    public AjaxResult faultReportProcess(@RequestBody TbFaultReportProcessDTO faultReportProcessDTO)
+    {
+        Long tbFaultReportId = faultReportProcessDTO.getTbFaultReportId();
+        if (tbFaultReportId == null) {
+            return AjaxResult.error("故障报备编号不能为空");
+        }
+        String processResult = faultReportProcessDTO.getProcessResult();
+        if (StrUtil.isBlank(processResult)) {
+            return AjaxResult.error("处理结果不能为空");
+        }
+        return tbFaultReportService.tbFaultReportProcess(faultReportProcessDTO);
+    }
 }

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

@@ -67,7 +67,7 @@ public class TbAssetBorrowRecord extends BaseEntity
 
     /** 借用地点 */
     @Excel(name = "借用地点")
-    @TableField("asset_bar_code")
+    @TableField("borrow_place_name")
     private String borrowPlaceName;
 
     @Excel(name = "备注")

+ 13 - 0
lab-admin/src/main/java/com/ruoyi/asset/domain/dto/TbFaultReportProcessDTO.java

@@ -0,0 +1,13 @@
+package com.ruoyi.asset.domain.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+@Data
+public class TbFaultReportProcessDTO {
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private Long tbFaultReportId; // 故障报备编号
+    private String processResult; // 处理结果
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private Long feedbackStatus; // 反馈状态
+}

+ 25 - 0
lab-admin/src/main/java/com/ruoyi/asset/domain/enums/TbAssetStatusEnum.java

@@ -0,0 +1,25 @@
+package com.ruoyi.asset.domain.enums;
+
+public enum TbAssetStatusEnum {
+    /** 故障 */
+    fault("故障", 0L),
+    /** 正常 */
+    normal("正常", 1L),
+    /** 报废 */
+    scrap("报废", 2L);
+    private final String statusName;
+    private final Long statusCode;
+
+    public String getStatusName() {
+        return statusName;
+    }
+
+    public Long getStatusCode() {
+        return statusCode;
+    }
+
+    TbAssetStatusEnum(String statusName, Long statusCode) {
+        this.statusName = statusName;
+        this.statusCode = statusCode;
+    }
+}

+ 23 - 0
lab-admin/src/main/java/com/ruoyi/asset/domain/enums/TbFaultProcessStateEnum.java

@@ -0,0 +1,23 @@
+package com.ruoyi.asset.domain.enums;
+
+public enum TbFaultProcessStateEnum {
+    /** 待处理 */
+    pending("待处理", 0L),
+    /** 已处理 */
+    processed("已处理", 1L);
+    private final String processStateName;
+    private final Long processStateCode;
+
+    public String getProcessStateName() {
+        return processStateName;
+    }
+
+    public Long getProcessStateCode() {
+        return processStateCode;
+    }
+
+    TbFaultProcessStateEnum(String processStateName, Long processStateCode) {
+        this.processStateName = processStateName;
+        this.processStateCode = processStateCode;
+    }
+}

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

@@ -5,7 +5,9 @@ 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.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 /**
  * 资产信息Mapper接口
@@ -74,4 +76,7 @@ public interface TbAssetMapper extends BaseMapper<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);
+
+    @Update("update tb_asset set status = #{status} where bar_code = #{barCode}")
+    public int updateTbAssetStatus(@Param("barCode") String barCode, @Param("status") Long status);
 }

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

@@ -5,6 +5,7 @@ import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.asset.domain.TbAssetStatusRecord;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 资产设备状态记录Mapper接口
@@ -62,4 +63,7 @@ public interface TbAssetStatusRecordMapper extends BaseMapper<TbAssetStatusRecor
      * @return 结果
      */
     public int deleteTbAssetStatusRecordByIds(Long[] ids);
+
+    @Select("select id, asset_bar_code, borrow_number, fault_number, last_fault_date from tb_asset_status_record where asset_bar_code = #{barCode}")
+    public TbAssetStatusRecord selectTbAssetStatusRecordByAssetBarCode(String barCode);
 }

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

@@ -5,6 +5,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;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 设备借用记录Service接口
@@ -12,6 +13,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
  * @author 原动力
  * @date 2023-03-27
  */
+@Transactional
 public interface ITbAssetBorrowRecordService extends IService<TbAssetBorrowRecord>
 {
     /**

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.asset.domain.TbAssetCategory;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 资产分类Service接口
@@ -11,6 +12,7 @@ import com.ruoyi.asset.domain.TbAssetCategory;
  * @author 原动力
  * @date 2023-03-27
  */
+@Transactional
 public interface ITbAssetCategoryService extends IService<TbAssetCategory>
 {
     /**

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

@@ -5,6 +5,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;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 资产信息Service接口
@@ -12,6 +13,7 @@ import com.ruoyi.asset.domain.dto.TbAssetDTO;
  * @author 原动力
  * @date 2023-03-27
  */
+@Transactional
 public interface ITbAssetService extends IService<TbAsset>
 {
     /**

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.asset.domain.TbAssetStatusRecord;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 资产设备状态记录Service接口
@@ -11,6 +12,7 @@ import com.ruoyi.asset.domain.TbAssetStatusRecord;
  * @author 原动力
  * @date 2023-03-27
  */
+@Transactional
 public interface ITbAssetStatusRecordService extends IService<TbAssetStatusRecord>
 {
     /**

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

@@ -4,6 +4,9 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.asset.domain.TbFaultReport;
+import com.ruoyi.asset.domain.dto.TbFaultReportProcessDTO;
+import com.ruoyi.common.core.domain.AjaxResult;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 故障报备Service接口
@@ -11,6 +14,7 @@ import com.ruoyi.asset.domain.TbFaultReport;
  * @author 原动力
  * @date 2023-03-27
  */
+@Transactional
 public interface ITbFaultReportService extends IService<TbFaultReport>
 {
     /**
@@ -60,4 +64,20 @@ public interface ITbFaultReportService extends IService<TbFaultReport>
      * @return 结果
      */
     public int deleteTbFaultReportById(Long id);
+
+    /**
+     * 小程序:新增故障报备信息
+     *
+     * @param tbFaultReport 故障报备信息
+     * @return 结果
+     */
+    public AjaxResult saveTbFaultReport(TbFaultReport tbFaultReport);
+
+    /**
+     * 故障报备处理
+     *
+     * @param faultReportProcessDTO 处理信息
+     * @return 结果
+     */
+    public AjaxResult tbFaultReportProcess(TbFaultReportProcessDTO faultReportProcessDTO);
 }

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.asset.domain.TbPlace;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 地点Service接口
@@ -11,6 +12,7 @@ import com.ruoyi.asset.domain.TbPlace;
  * @author 原动力
  * @date 2023-03-27
  */
+@Transactional
 public interface ITbPlaceService extends IService<TbPlace>
 {
     /**

+ 29 - 1
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetBorrowRecordServiceImpl.java

@@ -7,12 +7,15 @@ 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.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.core.domain.AjaxResult;
+import com.ruoyi.common.exception.ServiceException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +46,9 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
     @Resource
     private TbPlaceMapper tbPlaceMapper;
 
+    @Resource
+    private TbAssetStatusRecordMapper tbAssetStatusRecordMapper;
+
     /**
      * 查询设备借用记录
      * 
@@ -151,7 +157,29 @@ public class TbAssetBorrowRecordServiceImpl extends ServiceImpl<TbAssetBorrowRec
         tbAssetBorrowRecord.setIsreturn(0L);
         tbAssetBorrowRecord.setActualReturnDate(null);
 
-        return AjaxResult.success();
+        boolean result = save(tbAssetBorrowRecord);
+
+        if (result) {
+            TbAssetStatusRecord tbAssetStatusRecord = tbAssetStatusRecordMapper.selectTbAssetStatusRecordByAssetBarCode(assetBarCode);
+            if (tbAssetStatusRecord == null) {
+                TbAssetStatusRecord statusRecord = new TbAssetStatusRecord();
+                statusRecord.setAssetBarCode(assetBarCode);
+                statusRecord.setBorrowNumber(1L);
+                int insert = tbAssetStatusRecordMapper.insert(statusRecord);
+                if (insert < 1) {
+                    throw new ServiceException("借用失败");
+                }
+            } else {
+                Long borrowNumber = tbAssetStatusRecord.getBorrowNumber();
+                tbAssetStatusRecord.setBorrowNumber(borrowNumber+1);
+                int update = tbAssetStatusRecordMapper.updateById(tbAssetStatusRecord);
+                if (update < 1) {
+                    throw new ServiceException("借用失败");
+                }
+            }
+        }
+
+        return result ? AjaxResult.success("借用成功", tbAssetBorrowRecord) : AjaxResult.error("借用失败");
     }
 
     @Override

+ 120 - 0
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbFaultReportServiceImpl.java

@@ -1,14 +1,30 @@
 package com.ruoyi.asset.service.impl;
 
+import java.util.Date;
 import java.util.List;
 
+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.TbAssetBorrowRecord;
+import com.ruoyi.asset.domain.TbAssetStatusRecord;
+import com.ruoyi.asset.domain.dto.TbFaultReportProcessDTO;
+import com.ruoyi.asset.domain.enums.TbAssetStatusEnum;
+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.core.domain.AjaxResult;
+import com.ruoyi.common.exception.ServiceException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.asset.mapper.TbFaultReportMapper;
 import com.ruoyi.asset.domain.TbFaultReport;
 import com.ruoyi.asset.service.ITbFaultReportService;
 
+import javax.annotation.Resource;
+
 /**
  * 故障报备Service业务层处理
  * 
@@ -21,6 +37,15 @@ public class TbFaultReportServiceImpl extends ServiceImpl<TbFaultReportMapper, T
     @Autowired
     private TbFaultReportMapper tbFaultReportMapper;
 
+    @Resource
+    private TbAssetMapper tbAssetMapper;
+
+    @Resource
+    private TbAssetBorrowRecordMapper tbAssetBorrowRecordMapper;
+
+    @Resource
+    private TbAssetStatusRecordMapper tbAssetStatusRecordMapper;
+
     /**
      * 查询故障报备
      * 
@@ -92,4 +117,99 @@ public class TbFaultReportServiceImpl extends ServiceImpl<TbFaultReportMapper, T
     {
         return tbFaultReportMapper.deleteTbFaultReportById(id);
     }
+
+    /**
+     * 小程序:新增故障报备信息
+     *
+     * @param tbFaultReport 故障报备信息
+     * @return 结果
+     */
+    @Override
+    public AjaxResult saveTbFaultReport(TbFaultReport tbFaultReport) {
+        String assetBarCode = tbFaultReport.getAssetBarCode();
+        TbAsset tbAsset = tbAssetMapper.selectTbAssetByBarCode(assetBarCode);
+        if (tbAsset == null) {
+            return AjaxResult.error("资产设备不存在");
+        }
+        Long status = tbAsset.getStatus();
+        if (status != 1) {
+            return AjaxResult.error("资产设备已报备");
+        }
+        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 && borrowRecord.getIsreturn() < 1) {
+            return AjaxResult.error("资产设备未归还");
+        }
+        Long loginUserId = UserUtils.getLoginUserId();
+        tbFaultReport.setUserId(loginUserId);
+        Date faultReportDate = new Date();
+        tbFaultReport.setReportDate(faultReportDate);
+
+        tbFaultReport.setId(null);
+        tbFaultReport.setProcessState(TbFaultProcessStateEnum.pending.getProcessStateCode());
+        tbFaultReport.setProcessResult(null);
+
+        boolean result = save(tbFaultReport);
+        if (result) {
+            int updateResult = tbAssetMapper.updateTbAssetStatus(assetBarCode, TbAssetStatusEnum.fault.getStatusCode());
+            if (updateResult < 1) {
+                throw new ServiceException("故障上报失败", 500);
+            }
+            TbAssetStatusRecord tbAssetStatusRecord = tbAssetStatusRecordMapper.selectTbAssetStatusRecordByAssetBarCode(assetBarCode);
+            if (tbAssetStatusRecord == null) {
+                TbAssetStatusRecord statusRecord = new TbAssetStatusRecord();
+                statusRecord.setAssetBarCode(assetBarCode);
+                statusRecord.setFaultNumber(1L);
+                statusRecord.setLastFaultDate(faultReportDate);
+                int insert = tbAssetStatusRecordMapper.insert(statusRecord);
+                if (insert < 1) {
+                    throw new ServiceException("故障上报失败");
+                }
+            } else {
+                Long faultNumber = tbAssetStatusRecord.getFaultNumber();
+                tbAssetStatusRecord.setFaultNumber(faultNumber+1);
+                tbAssetStatusRecord.setLastFaultDate(faultReportDate);
+                int update = tbAssetStatusRecordMapper.updateById(tbAssetStatusRecord);
+                if (update < 1) {
+                    throw new ServiceException("故障上报失败");
+                }
+            }
+        }
+        return result ? AjaxResult.success("故障上报成功", tbFaultReport) : AjaxResult.error("故障上报失败");
+    }
+
+    /**
+     * 故障报备处理
+     *
+     * @param faultReportProcessDTO 处理信息
+     * @return 结果
+     */
+    @Override
+    public AjaxResult tbFaultReportProcess(TbFaultReportProcessDTO faultReportProcessDTO) {
+        Long faultReportId = faultReportProcessDTO.getTbFaultReportId();
+        TbFaultReport faultReport = getById(faultReportId);
+        if (faultReport == null) {
+            return AjaxResult.error("故障报备不存在");
+        }
+        Long processState = faultReport.getProcessState();
+        if (processState != null && processState.equals(TbFaultProcessStateEnum.processed.getProcessStateCode())) {
+            return AjaxResult.error("故障报备已处理");
+        }
+        Long feedbackStatus = faultReportProcessDTO.getFeedbackStatus();
+        if (feedbackStatus == null || feedbackStatus < 1 || feedbackStatus > 2){
+            feedbackStatus = TbAssetStatusEnum.normal.getStatusCode();
+        }
+        faultReport.setProcessState(TbFaultProcessStateEnum.processed.getProcessStateCode());
+        faultReport.setProcessResult(faultReportProcessDTO.getProcessResult());
+        boolean result = updateById(faultReport);
+        if (result) {
+            int updateResult = tbAssetMapper.updateTbAssetStatus(faultReport.getAssetBarCode(), feedbackStatus);
+            if (updateResult < 1) {
+                throw new ServiceException("故障报备处理失败", 500);
+            }
+        }
+        return result ? AjaxResult.success("故障报备处理成功", faultReport) : AjaxResult.error("故障报备处理失败");
+    }
+
 }

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

@@ -11,6 +11,10 @@ public abstract class RegexPatterns {
      */
     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 USERNAME_REGEX = "^[a-zA-Z0-9]+$";
+    /**
      * 邮箱正则
      */
     public static final String EMAIL_REGEX = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";

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

@@ -26,6 +26,14 @@ public class RegexUtils {
         return mismatch(phone, PHONE_REGEX);
     }
     /**
+     * 是否是无效用户名
+     * @param username 要校验的用户名
+     * @return true:符合,false:不符合
+     */
+    public static boolean isUsernameInvalid(String username) {
+        return mismatch(username, RegexPatterns.USERNAME_REGEX);
+    }
+    /**
      * 是否是无效邮箱格式
      * @param email 要校验的邮箱
      * @return true:符合,false:不符合

+ 27 - 14
lab-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java

@@ -4,14 +4,7 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-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;
@@ -94,10 +87,20 @@ public class SysNoticeController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:notice:query')")
     @GetMapping("/newNotice")
-    public AjaxResult getNewNotice()
+    public AjaxResult getNewNotice(@RequestParam(value = "number", required = false) Long number)
     {
-        SysNotice sysNotice = noticeService.selectNewNotice();
-        return sysNotice != null ? AjaxResult.success(sysNotice) : error("暂无公告");
+        if (number == null || number <= 0) {
+            number = 1L;
+        }
+        List<SysNotice> sysNoticeList = noticeService.selectNewNotice(number);
+        if (sysNoticeList.isEmpty()) {
+            return error("暂无公告");
+        }
+        if (number == 1) {
+            SysNotice sysNotice = sysNoticeList.get(0);
+            return AjaxResult.success(sysNotice);
+        }
+        return AjaxResult.success(sysNoticeList);
     }
 
     /**
@@ -105,9 +108,19 @@ public class SysNoticeController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:notice:query')")
     @GetMapping("/newInform")
-    public AjaxResult getNewInform()
+    public AjaxResult getNewInform(@RequestParam(value = "number", required = false) Long number)
     {
-        SysNotice sysNotice = noticeService.selectNewInform();
-        return sysNotice != null ? AjaxResult.success(sysNotice) : error("暂无通知");
+        if (number == null || number <= 0) {
+            number = 1L;
+        }
+        List<SysNotice> sysNoticeList = noticeService.selectNewInform(number);
+        if (sysNoticeList.isEmpty()) {
+            return error("暂无通知");
+        }
+        if (number == 1) {
+            SysNotice sysNotice = sysNoticeList.get(0);
+            return AjaxResult.success(sysNotice);
+        }
+        return AjaxResult.success(sysNoticeList);
     }
 }

+ 2 - 0
lab-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -2,6 +2,7 @@ package com.ruoyi.common.core.domain.entity;
 
 import java.util.Date;
 import java.util.List;
+import javax.validation.Valid;
 import javax.validation.constraints.*;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
@@ -11,6 +12,7 @@ import com.ruoyi.common.annotation.Excel.Type;
 import com.ruoyi.common.annotation.Excels;
 import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.common.xss.Xss;
+import org.springframework.validation.annotation.Validated;
 
 /**
  * 用户对象 sys_user

+ 6 - 0
lab-system/pom.xml

@@ -23,6 +23,12 @@
             <artifactId>lab-common</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.7.17</version>
+        </dependency>
+
     </dependencies>
 
 </project>

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

@@ -63,12 +63,12 @@ public interface SysNoticeMapper
      *
      * @return 公告信息
      */
-    SysNotice selectNewNotice();
+    List<SysNotice> selectNewNotice(Long number);
 
     /**
      * 获取最新通知信息
      *
      * @return 通知信息
      */
-    SysNotice selectNewInform();
+    List<SysNotice> selectNewInform(Long number);
 }

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

@@ -60,16 +60,16 @@ public interface ISysNoticeService
     public int deleteNoticeByIds(Long[] noticeIds);
 
     /**
-     * 获取最新公告信息
+     * 获取最新number条公告信息
      *
      * @return 公告信息
      */
-    SysNotice selectNewNotice();
+    List<SysNotice> selectNewNotice(Long number);
 
     /**
-     * 获取最新通知信息
+     * 获取最新number条通知信息
      *
      * @return 公告信息
      */
-    SysNotice selectNewInform();
+    List<SysNotice> selectNewInform(Long number);
 }

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

@@ -96,12 +96,12 @@ public class SysNoticeServiceImpl implements ISysNoticeService
      * @return 公告信息
      */
     @Override
-    public SysNotice selectNewNotice() {
-        return noticeMapper.selectNewNotice();
+    public List<SysNotice> selectNewNotice(Long number) {
+        return noticeMapper.selectNewNotice(number);
     }
 
     @Override
-    public SysNotice selectNewInform() {
-        return noticeMapper.selectNewInform();
+    public List<SysNotice> selectNewInform(Long number) {
+        return noticeMapper.selectNewInform(number);
     }
 }

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

@@ -4,6 +4,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 import javax.validation.Validator;
+
+import cn.hutool.core.util.StrUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,6 +41,7 @@ import com.ruoyi.system.service.ISysUserService;
 public class SysUserServiceImpl implements ISysUserService
 {
     private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
+    public static final String USERNAME_REGEX = "^[a-zA-Z0-9]+$";
 
     @Autowired
     private SysUserMapper userMapper;
@@ -255,6 +258,11 @@ public class SysUserServiceImpl implements ISysUserService
     @Transactional
     public int insertUser(SysUser user)
     {
+        // 判断用户名是否有效
+        boolean mismatch = mismatch(user.getUserName(), USERNAME_REGEX);
+        if (mismatch) {
+            throw new ServiceException("用户名格式错误,要求:英文、数字");
+        }
         // 新增用户信息
         int rows = userMapper.insertUser(user);
         // 新增用户岗位关联
@@ -273,6 +281,11 @@ public class SysUserServiceImpl implements ISysUserService
     @Override
     public boolean registerUser(SysUser user)
     {
+        // 判断用户名是否有效
+        boolean mismatch = mismatch(user.getUserName(), USERNAME_REGEX);
+        if (mismatch) {
+            throw new ServiceException("用户名格式错误,要求:英文、数字");
+        }
         return userMapper.insertUser(user) > 0;
     }
 
@@ -537,4 +550,12 @@ public class SysUserServiceImpl implements ISysUserService
         }
         return successMsg.toString();
     }
+
+    // 校验是否不符合正则格式
+    private static boolean mismatch(String str, String regex){
+        if (StrUtil.isBlank(str)) {
+            return true;
+        }
+        return !str.matches(regex);
+    }
 }

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

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