소스 검색

林武泰/新增小程序重置密码功能,新增设备故障上报邮箱通知超管功能

LinWuTai 2 년 전
부모
커밋
accd96c790

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

@@ -17,9 +17,12 @@ 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.EmailUtils;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.UserUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.system.mapper.SysUserMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.asset.mapper.TbFaultReportMapper;
@@ -44,11 +47,17 @@ public class TbFaultReportServiceImpl extends ServiceImpl<TbFaultReportMapper, T
     private TbAssetMapper tbAssetMapper;
 
     @Resource
+    private SysUserMapper userMapper;
+
+    @Resource
     private TbAssetBorrowRecordMapper tbAssetBorrowRecordMapper;
 
     @Resource
     private TbAssetStatusRecordMapper tbAssetStatusRecordMapper;
 
+    @Resource
+    private EmailUtils emailUtils;
+
     /**
      * 查询故障报备
      * 
@@ -187,7 +196,15 @@ public class TbFaultReportServiceImpl extends ServiceImpl<TbFaultReportMapper, T
                     throw new ServiceException("故障上报失败");
                 }
             }
+
+            SysUser sysUser = userMapper.selectUserById(1L);
+            String format = String.format("报备设备条形码:%s,报备设备名称:%s,故障原因:%s", assetBarCode, tbAsset.getName(), tbFaultReport.getFaultPhenomenon());
+            // emailUtils.sendSimpleEmail(sysUser.getEmail(), "设备报备通知", format);
+
+            // TODO 记得改回注释代码
+            emailUtils.sendSimpleEmail("1248708657@qq.com", "设备报备通知", format);
         }
+
         return result ? AjaxResult.success("故障上报成功", tbFaultReport) : AjaxResult.error("故障上报失败");
     }
 

+ 21 - 0
lab-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ruoyi.common.exception.ServiceException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.ArrayUtils;
@@ -207,6 +208,26 @@ public class SysUserController extends BaseController
     }
 
     /**
+     * 重置密码(工号)
+     */
+    @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
+    @ApiOperation("重置密码(工号)")
+    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
+    @PutMapping("/resetPwd/{username}")
+    public AjaxResult resetPwd2(@PathVariable("username") String username)
+    {
+        SysUser user = userService.selectUserByUserName(username);
+        if (user == null) {
+            throw new ServiceException("工号不存在");
+        }
+        userService.checkUserAllowed(user);
+        userService.checkUserDataScope(user.getUserId());
+        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
+        user.setUpdateBy(getUsername());
+        return toAjax(userService.resetPwd(user));
+    }
+
+    /**
      * 状态修改
      */
     @PreAuthorize("@ss.hasPermi('system:user:edit')")