安装单的优化数据表中新添加update_id,imgurl,修改者的id,图片路径字段,未派单的删除后设备状态更新为未激活,实现用户登录后头像的上传20231116wmz
| | |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | <!-- spring-boot-devtools --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | |
| | | /** |
| | | * 数据字典信息 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/dict/data") |
| | | public class SysDictDataController extends BaseController |
| | | { |
| | | public class SysDictDataController extends BaseController { |
| | | @Autowired |
| | | private ISysDictDataService dictDataService; |
| | | |
| | |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysDictData dictData) |
| | | { |
| | | public TableDataInfo list(SysDictData dictData) { |
| | | startPage(); |
| | | List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | return getDataTable(list); |
| | |
| | | @Log(title = "字典数据", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:dict:export')") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SysDictData dictData) |
| | | { |
| | | public void export(HttpServletResponse response, SysDictData dictData) { |
| | | List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); |
| | | util.exportExcel(response, list, "字典数据"); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')") |
| | | @GetMapping(value = "/{dictCode}") |
| | | public AjaxResult getInfo(@PathVariable Long dictCode) |
| | | { |
| | | public AjaxResult getInfo(@PathVariable Long dictCode) { |
| | | return AjaxResult.success(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据信息 |
| | | */ |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public AjaxResult dictType(@PathVariable String dictType) |
| | | { |
| | | public AjaxResult dictType(@PathVariable String dictType) { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (StringUtils.isNull(data)) |
| | | { |
| | | if (StringUtils.isNull(data)) { |
| | | data = new ArrayList<SysDictData>(); |
| | | } |
| | | return AjaxResult.success(data); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')") |
| | | @Log(title = "字典数据", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict) { |
| | | dict.setCreateBy(getUsername()); |
| | | return toAjax(dictDataService.insertDictData(dict)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:edit')") |
| | | @Log(title = "字典数据", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | public AjaxResult edit(@Validated @RequestBody SysDictData dict) { |
| | | dict.setUpdateBy(getUsername()); |
| | | return toAjax(dictDataService.updateDictData(dict)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')") |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public AjaxResult remove(@PathVariable Long[] dictCodes) |
| | | { |
| | | public AjaxResult remove(@PathVariable Long[] dictCodes) { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return success(); |
| | | } |
| | |
| | | */ |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult updateProfile(@RequestBody SysUser user) |
| | | { |
| | | public AjaxResult updateProfile(@RequestBody SysUser user) { |
| | | LoginUser loginUser = getLoginUser(); |
| | | SysUser sysUser = loginUser.getUser(); |
| | | user.setUserName(sysUser.getUserName()); |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | user.setUserId(sysUser.getUserId()); |
| | | user.setPassword(null); |
| | | if (userService.updateUserProfile(user) > 0) |
| | | { |
| | | if (userService.updateUserProfile(user) > 0) { |
| | | // 更新缓存用户信息 |
| | | sysUser.setNickName(user.getNickName()); |
| | | sysUser.setPhonenumber(user.getPhonenumber()); |
| | |
| | | */ |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public AjaxResult updatePwd(String oldPassword, String newPassword) |
| | | { |
| | | public AjaxResult updatePwd(String oldPassword, String newPassword) { |
| | | LoginUser loginUser = getLoginUser(); |
| | | String userName = loginUser.getUsername(); |
| | | String password = loginUser.getPassword(); |
| | | if (!SecurityUtils.matchesPassword(oldPassword, password)) |
| | | { |
| | | if (!SecurityUtils.matchesPassword(oldPassword, password)) { |
| | | return AjaxResult.error("修改密码失败,旧密码错误"); |
| | | } |
| | | if (SecurityUtils.matchesPassword(newPassword, password)) |
| | | { |
| | | if (SecurityUtils.matchesPassword(newPassword, password)) { |
| | | return AjaxResult.error("新密码不能与旧密码相同"); |
| | | } |
| | | if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) |
| | | { |
| | | if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) { |
| | | // 更新缓存用户密码 |
| | | loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword)); |
| | | tokenService.setLoginUser(loginUser); |
| | |
| | | */ |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException |
| | | { |
| | | if (!file.isEmpty()) |
| | | { |
| | | public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException { |
| | | if (!file.isEmpty()) { |
| | | LoginUser loginUser = getLoginUser(); |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); |
| | | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) |
| | | { |
| | | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("imgUrl", avatar); |
| | | // 更新缓存用户头像 |
| | |
| | | # 实例演示开关 |
| | | demoEnabled: true |
| | | # 文件路径,以uploadPath结尾 示例( Windows配置 D:/uploadPath,Linux配置 /uploadPath) |
| | | # /var/data/java/uploadPath |
| | | # D:/uploadPath |
| | | profile: /var/data/java/uploadPath |
| | | # 获取ip地址开关 |
| | | addressEnabled: true |
| | |
| | | # wumei-smart |
| | | password: wumei-smart |
| | | # 连接超时时间 |
| | | # 连接超时时间 |
| | | timeout: 10s |
| | | lettuce: |
| | | pool: |
| | |
| | | max-wait: -1ms |
| | | # mqtt 配置 |
| | | mqtt: |
| | | username: wumei-smart # 账号 |
| | | password: wumei-smart # 密码 |
| | | host-url: tcp://39.105.187.20:1883 # mqtt连接tcp地址 |
| | | client-id: ${random.int} # 客户端Id,不能相同,采用随机数 ${random.value} |
| | | default-topic: test # 默认主题 |
| | | timeout: 30 # 超时时间 |
| | | keepalive: 30 # 保持连接 |
| | | clearSession: true # 清除会话(设置为false,断开连接,重连后使用原来的会话 保留订阅的主题,能接收离线期间的消息) |
| | | username: wumei-smart # 账号 |
| | | password: wumei-smart # 密码 |
| | | host-url: tcp://39.105.187.20:1883 # mqtt连接tcp地址 |
| | | client-id: ${random.int} # 客户端Id,不能相同,采用随机数 ${random.value} |
| | | default-topic: test # 默认主题 |
| | | timeout: 30 # 超时时间 |
| | | keepalive: 30 # 保持连接 |
| | | clearSession: true # 清除会话(设置为false,断开连接,重连后使用原来的会话 保留订阅的主题,能接收离线期间的消息) |
| | | task: |
| | | execution: |
| | | pool: |
| | | core-size: 10 # 最小连接数 |
| | | max-size: 30 # 最大连接数 |
| | | queue-capacity: 3000 # 最大容量 |
| | | core-size: 10 # 最小连接数 |
| | | max-size: 30 # 最大连接数 |
| | | queue-capacity: 3000 # 最大容量 |
| | | |
| | | # token配置 |
| | | token: |
| | |
| | | |
| | | /** |
| | | * 读取项目相关配置 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | @ConfigurationProperties(prefix = "ruoyi") |
| | | public class RuoYiConfig |
| | | { |
| | | /** 项目名称 */ |
| | | public class RuoYiConfig { |
| | | /** |
| | | * 项目名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** 版本 */ |
| | | /** |
| | | * 版本 |
| | | */ |
| | | private String version; |
| | | |
| | | /** 版权年份 */ |
| | | /** |
| | | * 版权年份 |
| | | */ |
| | | private String copyrightYear; |
| | | |
| | | /** 实例演示开关 */ |
| | | /** |
| | | * 实例演示开关 |
| | | */ |
| | | private boolean demoEnabled; |
| | | |
| | | /** 上传路径 */ |
| | | /** |
| | | * 上传路径 |
| | | */ |
| | | private static String profile; |
| | | |
| | | /** 获取地址开关 */ |
| | | /** |
| | | * 获取地址开关 |
| | | */ |
| | | private static boolean addressEnabled; |
| | | |
| | | /** 验证码类型 */ |
| | | /** |
| | | * 验证码类型 |
| | | */ |
| | | private static String captchaType; |
| | | |
| | | public String getName() |
| | | { |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) |
| | | { |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getVersion() |
| | | { |
| | | public String getVersion() { |
| | | return version; |
| | | } |
| | | |
| | | public void setVersion(String version) |
| | | { |
| | | public void setVersion(String version) { |
| | | this.version = version; |
| | | } |
| | | |
| | | public String getCopyrightYear() |
| | | { |
| | | public String getCopyrightYear() { |
| | | return copyrightYear; |
| | | } |
| | | |
| | | public void setCopyrightYear(String copyrightYear) |
| | | { |
| | | public void setCopyrightYear(String copyrightYear) { |
| | | this.copyrightYear = copyrightYear; |
| | | } |
| | | |
| | | public boolean isDemoEnabled() |
| | | { |
| | | public boolean isDemoEnabled() { |
| | | return demoEnabled; |
| | | } |
| | | |
| | | public void setDemoEnabled(boolean demoEnabled) |
| | | { |
| | | public void setDemoEnabled(boolean demoEnabled) { |
| | | this.demoEnabled = demoEnabled; |
| | | } |
| | | |
| | | public static String getProfile() |
| | | { |
| | | public static String getProfile() { |
| | | return profile; |
| | | } |
| | | |
| | | public void setProfile(String profile) |
| | | { |
| | | public void setProfile(String profile) { |
| | | RuoYiConfig.profile = profile; |
| | | } |
| | | |
| | | public static boolean isAddressEnabled() |
| | | { |
| | | public static boolean isAddressEnabled() { |
| | | return addressEnabled; |
| | | } |
| | | |
| | | public void setAddressEnabled(boolean addressEnabled) |
| | | { |
| | | public void setAddressEnabled(boolean addressEnabled) { |
| | | RuoYiConfig.addressEnabled = addressEnabled; |
| | | } |
| | | |
| | |
| | | /** |
| | | * 获取导入上传路径 |
| | | */ |
| | | public static String getImportPath() |
| | | { |
| | | public static String getImportPath() { |
| | | return getProfile() + "/import"; |
| | | } |
| | | |
| | | /** |
| | | * 获取头像上传路径 |
| | | * 获取头像上传路径L |
| | | */ |
| | | public static String getAvatarPath() |
| | | { |
| | | public static String getAvatarPath() { |
| | | return getProfile() + "/avatar"; |
| | | } |
| | | |
| | | /** |
| | | * 获取下载路径 |
| | | */ |
| | | public static String getDownloadPath() |
| | | { |
| | | public static String getDownloadPath() { |
| | | return getProfile() + "/download/"; |
| | | } |
| | | |
| | | /** |
| | | * 获取上传路径 |
| | | */ |
| | | public static String getUploadPath() |
| | | { |
| | | public static String getUploadPath() { |
| | | return getProfile() + "/upload"; |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 返回状态码 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class HttpStatus |
| | | { |
| | | public class HttpStatus { |
| | | /** |
| | | * 操作成功 |
| | | */ |
| | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | |
| | | /** |
| | | * Entity基类 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class BaseEntity implements Serializable |
| | | { |
| | | public class BaseEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** 搜索值 */ |
| | | /** |
| | | * 搜索值 |
| | | */ |
| | | private String searchValue; |
| | | |
| | | /** 创建者 */ |
| | | /** |
| | | * 创建者 |
| | | */ |
| | | private String createBy; |
| | | |
| | | /** 创建时间 */ |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** 更新者 */ |
| | | /** |
| | | * 更新者 |
| | | */ |
| | | private String updateBy; |
| | | |
| | | /** 更新时间 */ |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** 备注 */ |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** 请求参数 */ |
| | | /** |
| | | * 请求参数 |
| | | */ |
| | | private Map<String, Object> params; |
| | | |
| | | public String getSearchValue() |
| | | { |
| | | public String getSearchValue() { |
| | | return searchValue; |
| | | } |
| | | |
| | | public void setSearchValue(String searchValue) |
| | | { |
| | | public void setSearchValue(String searchValue) { |
| | | this.searchValue = searchValue; |
| | | } |
| | | |
| | | public String getCreateBy() |
| | | { |
| | | public String getCreateBy() { |
| | | return createBy; |
| | | } |
| | | |
| | | public void setCreateBy(String createBy) |
| | | { |
| | | public void setCreateBy(String createBy) { |
| | | this.createBy = createBy; |
| | | } |
| | | |
| | | public Date getCreateTime() |
| | | { |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) |
| | | { |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public String getUpdateBy() |
| | | { |
| | | public String getUpdateBy() { |
| | | return updateBy; |
| | | } |
| | | |
| | | public void setUpdateBy(String updateBy) |
| | | { |
| | | public void setUpdateBy(String updateBy) { |
| | | this.updateBy = updateBy; |
| | | } |
| | | |
| | | public Date getUpdateTime() |
| | | { |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) |
| | | { |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getRemark() |
| | | { |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) |
| | | { |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public Map<String, Object> getParams() |
| | | { |
| | | if (params == null) |
| | | { |
| | | public Map<String, Object> getParams() { |
| | | if (params == null) { |
| | | params = new HashMap<>(); |
| | | } |
| | | return params; |
| | | } |
| | | |
| | | public void setParams(Map<String, Object> params) |
| | | { |
| | | public void setParams(Map<String, Object> params) { |
| | | this.params = params; |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 业务异常 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public final class ServiceException extends RuntimeException |
| | | { |
| | | public final class ServiceException extends RuntimeException { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 错误明细,内部调试错误 |
| | | * |
| | | * <p> |
| | | * 和 {@link CommonResult#getDetailMessage()} 一致的设计 |
| | | */ |
| | | private String detailMessage; |
| | |
| | | /** |
| | | * 空构造方法,避免反序列化问题 |
| | | */ |
| | | public ServiceException() |
| | | { |
| | | public ServiceException() { |
| | | } |
| | | |
| | | public ServiceException(String message) |
| | | { |
| | | public ServiceException(String message) { |
| | | this.message = message; |
| | | } |
| | | |
| | | public ServiceException(String message, Integer code) |
| | | { |
| | | public ServiceException(String message, Integer code) { |
| | | this.message = message; |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getDetailMessage() |
| | | { |
| | | public String getDetailMessage() { |
| | | return detailMessage; |
| | | } |
| | | |
| | | public String getMessage() |
| | | { |
| | | public String getMessage() { |
| | | return message; |
| | | } |
| | | |
| | | public Integer getCode() |
| | | { |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public ServiceException setMessage(String message) |
| | | { |
| | | public ServiceException setMessage(String message) { |
| | | this.message = message; |
| | | return this; |
| | | } |
| | | |
| | | public ServiceException setDetailMessage(String detailMessage) |
| | | { |
| | | public ServiceException setDetailMessage(String detailMessage) { |
| | | this.detailMessage = detailMessage; |
| | | return this; |
| | | } |
| | |
| | | package com.ruoyi.common.exception.file; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | import org.apache.commons.fileupload.FileUploadException; |
| | | |
| | | /** |
| | | * 文件上传 误异常类 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class InvalidExtensionException extends FileUploadException |
| | | { |
| | | public class InvalidExtensionException extends FileUploadException { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String[] allowedExtension; |
| | | private String extension; |
| | | private String filename; |
| | | |
| | | public InvalidExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | public InvalidExtensionException(String[] allowedExtension, String extension, String filename) { |
| | | super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]"); |
| | | this.allowedExtension = allowedExtension; |
| | | this.extension = extension; |
| | | this.filename = filename; |
| | | } |
| | | |
| | | public String[] getAllowedExtension() |
| | | { |
| | | public String[] getAllowedExtension() { |
| | | return allowedExtension; |
| | | } |
| | | |
| | | public String getExtension() |
| | | { |
| | | public String getExtension() { |
| | | return extension; |
| | | } |
| | | |
| | | public String getFilename() |
| | | { |
| | | public String getFilename() { |
| | | return filename; |
| | | } |
| | | |
| | | public static class InvalidImageExtensionException extends InvalidExtensionException |
| | | { |
| | | public static class InvalidImageExtensionException extends InvalidExtensionException { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) { |
| | | super(allowedExtension, extension, filename); |
| | | } |
| | | } |
| | | |
| | | public static class InvalidFlashExtensionException extends InvalidExtensionException |
| | | { |
| | | public static class InvalidFlashExtensionException extends InvalidExtensionException { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) { |
| | | super(allowedExtension, extension, filename); |
| | | } |
| | | } |
| | | |
| | | public static class InvalidMediaExtensionException extends InvalidExtensionException |
| | | { |
| | | public static class InvalidMediaExtensionException extends InvalidExtensionException { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) { |
| | | super(allowedExtension, extension, filename); |
| | | } |
| | | } |
| | | |
| | | public static class InvalidVideoExtensionException extends InvalidExtensionException |
| | | { |
| | | public static class InvalidVideoExtensionException extends InvalidExtensionException { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) { |
| | | super(allowedExtension, extension, filename); |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | |
| | | |
| | | /** |
| | | * 字典工具类 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class DictUtils |
| | | { |
| | | public class DictUtils { |
| | | /** |
| | | * 分隔符 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 设置字典缓存 |
| | | * |
| | | * @param key 参数键 |
| | | * |
| | | * @param key 参数键 |
| | | * @param dictDatas 字典数据列表 |
| | | */ |
| | | public static void setDictCache(String key, List<SysDictData> dictDatas) |
| | | { |
| | | public static void setDictCache(String key, List<SysDictData> dictDatas) { |
| | | SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典缓存 |
| | | * |
| | | * |
| | | * @param key 参数键 |
| | | * @return dictDatas 字典数据列表 |
| | | */ |
| | | public static List<SysDictData> getDictCache(String key) |
| | | { |
| | | public static List<SysDictData> getDictCache(String key) { |
| | | Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); |
| | | if (StringUtils.isNotNull(cacheObj)) |
| | | { |
| | | if (StringUtils.isNotNull(cacheObj)) { |
| | | List<SysDictData> dictDatas = StringUtils.cast(cacheObj); |
| | | return dictDatas; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据字典类型和字典值获取字典标签 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictValue 字典值 |
| | | * @return 字典标签 |
| | | */ |
| | | public static String getDictLabel(String dictType, String dictValue) |
| | | { |
| | | public static String getDictLabel(String dictType, String dictValue) { |
| | | return getDictLabel(dictType, dictValue, SEPARATOR); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型和字典标签获取字典值 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictLabel 字典标签 |
| | | * @return 字典值 |
| | | */ |
| | | public static String getDictValue(String dictType, String dictLabel) |
| | | { |
| | | public static String getDictValue(String dictType, String dictLabel) { |
| | | return getDictValue(dictType, dictLabel, SEPARATOR); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型和字典值获取字典标签 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictValue 字典值 |
| | | * @param separator 分隔符 |
| | | * @return 字典标签 |
| | | */ |
| | | public static String getDictLabel(String dictType, String dictValue, String separator) |
| | | { |
| | | public static String getDictLabel(String dictType, String dictValue, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | List<SysDictData> datas = getDictCache(dictType); |
| | | |
| | | if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) |
| | | { |
| | | for (SysDictData dict : datas) |
| | | { |
| | | for (String value : dictValue.split(separator)) |
| | | { |
| | | if (value.equals(dict.getDictValue())) |
| | | { |
| | | if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) { |
| | | for (SysDictData dict : datas) { |
| | | for (String value : dictValue.split(separator)) { |
| | | if (value.equals(dict.getDictValue())) { |
| | | propertyString.append(dict.getDictLabel() + separator); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (SysDictData dict : datas) |
| | | { |
| | | if (dictValue.equals(dict.getDictValue())) |
| | | { |
| | | } else { |
| | | for (SysDictData dict : datas) { |
| | | if (dictValue.equals(dict.getDictValue())) { |
| | | return dict.getDictLabel(); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据字典类型和字典标签获取字典值 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictLabel 字典标签 |
| | | * @param separator 分隔符 |
| | | * @return 字典值 |
| | | */ |
| | | public static String getDictValue(String dictType, String dictLabel, String separator) |
| | | { |
| | | public static String getDictValue(String dictType, String dictLabel, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | List<SysDictData> datas = getDictCache(dictType); |
| | | |
| | | if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) |
| | | { |
| | | for (SysDictData dict : datas) |
| | | { |
| | | for (String label : dictLabel.split(separator)) |
| | | { |
| | | if (label.equals(dict.getDictLabel())) |
| | | { |
| | | if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) { |
| | | for (SysDictData dict : datas) { |
| | | for (String label : dictLabel.split(separator)) { |
| | | if (label.equals(dict.getDictLabel())) { |
| | | propertyString.append(dict.getDictValue() + separator); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (SysDictData dict : datas) |
| | | { |
| | | if (dictLabel.equals(dict.getDictLabel())) |
| | | { |
| | | } else { |
| | | for (SysDictData dict : datas) { |
| | | if (dictLabel.equals(dict.getDictLabel())) { |
| | | return dict.getDictValue(); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 删除指定字典缓存 |
| | | * |
| | | * |
| | | * @param key 字典键 |
| | | */ |
| | | public static void removeDictCache(String key) |
| | | { |
| | | public static void removeDictCache(String key) { |
| | | SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key)); |
| | | } |
| | | |
| | | /** |
| | | * 清空字典缓存 |
| | | */ |
| | | public static void clearDictCache() |
| | | { |
| | | public static void clearDictCache() { |
| | | Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*"); |
| | | SpringUtils.getBean(RedisCache.class).deleteObject(keys); |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * |
| | | * @param configKey 参数键 |
| | | * @return 缓存键key |
| | | */ |
| | | public static String getCacheKey(String configKey) |
| | | { |
| | | public static String getCacheKey(String configKey) { |
| | | return Constants.SYS_DICT_KEY + configKey; |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 安全服务工具类 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SecurityUtils |
| | | { |
| | | public class SecurityUtils { |
| | | /** |
| | | * 用户ID |
| | | **/ |
| | | public static Long getUserId() |
| | | { |
| | | try |
| | | { |
| | | public static Long getUserId() { |
| | | try { |
| | | return getLoginUser().getUserId(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 获取部门ID |
| | | **/ |
| | | public static Long getDeptId() |
| | | { |
| | | try |
| | | { |
| | | public static Long getDeptId() { |
| | | try { |
| | | return getLoginUser().getDeptId(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户账户 |
| | | **/ |
| | | public static String getUsername() |
| | | { |
| | | try |
| | | { |
| | | public static String getUsername() { |
| | | try { |
| | | return getLoginUser().getUsername(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 获取用户 |
| | | **/ |
| | | public static LoginUser getLoginUser() |
| | | { |
| | | try |
| | | { |
| | | public static LoginUser getLoginUser() { |
| | | try { |
| | | return (LoginUser) getAuthentication().getPrincipal(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 获取Authentication |
| | | */ |
| | | public static Authentication getAuthentication() |
| | | { |
| | | public static Authentication getAuthentication() { |
| | | return SecurityContextHolder.getContext().getAuthentication(); |
| | | } |
| | | |
| | |
| | | * @param password 密码 |
| | | * @return 加密字符串 |
| | | */ |
| | | public static String encryptPassword(String password) |
| | | { |
| | | public static String encryptPassword(String password) { |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | return passwordEncoder.encode(password); |
| | | } |
| | |
| | | /** |
| | | * 判断密码是否相同 |
| | | * |
| | | * @param rawPassword 真实密码 |
| | | * @param rawPassword 真实密码 |
| | | * @param encodedPassword 加密后字符 |
| | | * @return 结果 |
| | | */ |
| | | public static boolean matchesPassword(String rawPassword, String encodedPassword) |
| | | { |
| | | public static boolean matchesPassword(String rawPassword, String encodedPassword) { |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | return passwordEncoder.matches(rawPassword, encodedPassword); |
| | | } |
| | | |
| | | /** |
| | | * 是否为管理员 |
| | | * |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 结果 |
| | | */ |
| | | public static boolean isAdmin(Long userId) |
| | | { |
| | | public static boolean isAdmin(Long userId) { |
| | | return userId != null && 1L == userId; |
| | | } |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import org.springframework.util.AntPathMatcher; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.text.StrFormatter; |
| | | |
| | | /** |
| | | * 字符串工具类 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class StringUtils extends org.apache.commons.lang3.StringUtils |
| | | { |
| | | /** 空字符串 */ |
| | | public class StringUtils extends org.apache.commons.lang3.StringUtils { |
| | | /** |
| | | * 空字符串 |
| | | */ |
| | | private static final String NULLSTR = ""; |
| | | |
| | | /** 下划线 */ |
| | | /** |
| | | * 下划线 |
| | | */ |
| | | private static final char SEPARATOR = '_'; |
| | | |
| | | /** |
| | | * 获取参数不为空值 |
| | | * |
| | | * |
| | | * @param value defaultValue 要判断的value |
| | | * @return value 返回值 |
| | | */ |
| | | public static <T> T nvl(T value, T defaultValue) |
| | | { |
| | | public static <T> T nvl(T value, T defaultValue) { |
| | | return value != null ? value : defaultValue; |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个Collection是否为空, 包含List,Set,Queue |
| | | * |
| | | * |
| | | * @param coll 要判断的Collection |
| | | * @return true:为空 false:非空 |
| | | */ |
| | | public static boolean isEmpty(Collection<?> coll) |
| | | { |
| | | public static boolean isEmpty(Collection<?> coll) { |
| | | return isNull(coll) || coll.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个Collection是否非空,包含List,Set,Queue |
| | | * |
| | | * |
| | | * @param coll 要判断的Collection |
| | | * @return true:非空 false:空 |
| | | */ |
| | | public static boolean isNotEmpty(Collection<?> coll) |
| | | { |
| | | public static boolean isNotEmpty(Collection<?> coll) { |
| | | return !isEmpty(coll); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个对象数组是否为空 |
| | | * |
| | | * |
| | | * @param objects 要判断的对象数组 |
| | | ** @return true:为空 false:非空 |
| | | * * @return true:为空 false:非空 |
| | | */ |
| | | public static boolean isEmpty(Object[] objects) |
| | | { |
| | | public static boolean isEmpty(Object[] objects) { |
| | | return isNull(objects) || (objects.length == 0); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个对象数组是否非空 |
| | | * |
| | | * |
| | | * @param objects 要判断的对象数组 |
| | | * @return true:非空 false:空 |
| | | */ |
| | | public static boolean isNotEmpty(Object[] objects) |
| | | { |
| | | public static boolean isNotEmpty(Object[] objects) { |
| | | return !isEmpty(objects); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个Map是否为空 |
| | | * |
| | | * |
| | | * @param map 要判断的Map |
| | | * @return true:为空 false:非空 |
| | | */ |
| | | public static boolean isEmpty(Map<?, ?> map) |
| | | { |
| | | public static boolean isEmpty(Map<?, ?> map) { |
| | | return isNull(map) || map.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个Map是否为空 |
| | | * |
| | | * |
| | | * @param map 要判断的Map |
| | | * @return true:非空 false:空 |
| | | */ |
| | | public static boolean isNotEmpty(Map<?, ?> map) |
| | | { |
| | | public static boolean isNotEmpty(Map<?, ?> map) { |
| | | return !isEmpty(map); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个字符串是否为空串 |
| | | * |
| | | * |
| | | * @param str String |
| | | * @return true:为空 false:非空 |
| | | */ |
| | | public static boolean isEmpty(String str) |
| | | { |
| | | public static boolean isEmpty(String str) { |
| | | return isNull(str) || NULLSTR.equals(str.trim()); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个字符串是否为非空串 |
| | | * |
| | | * |
| | | * @param str String |
| | | * @return true:非空串 false:空串 |
| | | */ |
| | | public static boolean isNotEmpty(String str) |
| | | { |
| | | public static boolean isNotEmpty(String str) { |
| | | return !isEmpty(str); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个对象是否为空 |
| | | * |
| | | * |
| | | * @param object Object |
| | | * @return true:为空 false:非空 |
| | | */ |
| | | public static boolean isNull(Object object) |
| | | { |
| | | public static boolean isNull(Object object) { |
| | | return object == null; |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个对象是否非空 |
| | | * |
| | | * |
| | | * @param object Object |
| | | * @return true:非空 false:空 |
| | | */ |
| | | public static boolean isNotNull(Object object) |
| | | { |
| | | public static boolean isNotNull(Object object) { |
| | | return !isNull(object); |
| | | } |
| | | |
| | | /** |
| | | * * 判断一个对象是否是数组类型(Java基本型别的数组) |
| | | * |
| | | * |
| | | * @param object 对象 |
| | | * @return true:是数组 false:不是数组 |
| | | */ |
| | | public static boolean isArray(Object object) |
| | | { |
| | | public static boolean isArray(Object object) { |
| | | return isNotNull(object) && object.getClass().isArray(); |
| | | } |
| | | |
| | | /** |
| | | * 去空格 |
| | | */ |
| | | public static String trim(String str) |
| | | { |
| | | public static String trim(String str) { |
| | | return (str == null ? "" : str.trim()); |
| | | } |
| | | |
| | | /** |
| | | * 截取字符串 |
| | | * |
| | | * @param str 字符串 |
| | | * |
| | | * @param str 字符串 |
| | | * @param start 开始 |
| | | * @return 结果 |
| | | */ |
| | | public static String substring(final String str, int start) |
| | | { |
| | | if (str == null) |
| | | { |
| | | public static String substring(final String str, int start) { |
| | | if (str == null) { |
| | | return NULLSTR; |
| | | } |
| | | |
| | | if (start < 0) |
| | | { |
| | | if (start < 0) { |
| | | start = str.length() + start; |
| | | } |
| | | |
| | | if (start < 0) |
| | | { |
| | | if (start < 0) { |
| | | start = 0; |
| | | } |
| | | if (start > str.length()) |
| | | { |
| | | if (start > str.length()) { |
| | | return NULLSTR; |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 截取字符串 |
| | | * |
| | | * @param str 字符串 |
| | | * |
| | | * @param str 字符串 |
| | | * @param start 开始 |
| | | * @param end 结束 |
| | | * @param end 结束 |
| | | * @return 结果 |
| | | */ |
| | | public static String substring(final String str, int start, int end) |
| | | { |
| | | if (str == null) |
| | | { |
| | | public static String substring(final String str, int start, int end) { |
| | | if (str == null) { |
| | | return NULLSTR; |
| | | } |
| | | |
| | | if (end < 0) |
| | | { |
| | | if (end < 0) { |
| | | end = str.length() + end; |
| | | } |
| | | if (start < 0) |
| | | { |
| | | if (start < 0) { |
| | | start = str.length() + start; |
| | | } |
| | | |
| | | if (end > str.length()) |
| | | { |
| | | if (end > str.length()) { |
| | | end = str.length(); |
| | | } |
| | | |
| | | if (start > end) |
| | | { |
| | | if (start > end) { |
| | | return NULLSTR; |
| | | } |
| | | |
| | | if (start < 0) |
| | | { |
| | | if (start < 0) { |
| | | start = 0; |
| | | } |
| | | if (end < 0) |
| | | { |
| | | if (end < 0) { |
| | | end = 0; |
| | | } |
| | | |
| | |
| | | * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br> |
| | | * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br> |
| | | * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br> |
| | | * |
| | | * |
| | | * @param template 文本模板,被替换的部分用 {} 表示 |
| | | * @param params 参数值 |
| | | * @param params 参数值 |
| | | * @return 格式化后的文本 |
| | | */ |
| | | public static String format(String template, Object... params) |
| | | { |
| | | if (isEmpty(params) || isEmpty(template)) |
| | | { |
| | | public static String format(String template, Object... params) { |
| | | if (isEmpty(params) || isEmpty(template)) { |
| | | return template; |
| | | } |
| | | return StrFormatter.format(template, params); |
| | |
| | | |
| | | /** |
| | | * 是否为http(s)://开头 |
| | | * |
| | | * |
| | | * @param link 链接 |
| | | * @return 结果 |
| | | */ |
| | | public static boolean ishttp(String link) |
| | | { |
| | | public static boolean ishttp(String link) { |
| | | return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS); |
| | | } |
| | | |
| | | /** |
| | | * 字符串转set |
| | | * |
| | | * |
| | | * @param str 字符串 |
| | | * @param sep 分隔符 |
| | | * @return set集合 |
| | | */ |
| | | public static final Set<String> str2Set(String str, String sep) |
| | | { |
| | | public static final Set<String> str2Set(String str, String sep) { |
| | | return new HashSet<String>(str2List(str, sep, true, false)); |
| | | } |
| | | |
| | | /** |
| | | * 字符串转list |
| | | * |
| | | * @param str 字符串 |
| | | * @param sep 分隔符 |
| | | * |
| | | * @param str 字符串 |
| | | * @param sep 分隔符 |
| | | * @param filterBlank 过滤纯空白 |
| | | * @param trim 去掉首尾空白 |
| | | * @param trim 去掉首尾空白 |
| | | * @return list集合 |
| | | */ |
| | | public static final List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) |
| | | { |
| | | public static final List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) { |
| | | List<String> list = new ArrayList<String>(); |
| | | if (StringUtils.isEmpty(str)) |
| | | { |
| | | if (StringUtils.isEmpty(str)) { |
| | | return list; |
| | | } |
| | | |
| | | // 过滤空白字符串 |
| | | if (filterBlank && StringUtils.isBlank(str)) |
| | | { |
| | | if (filterBlank && StringUtils.isBlank(str)) { |
| | | return list; |
| | | } |
| | | String[] split = str.split(sep); |
| | | for (String string : split) |
| | | { |
| | | if (filterBlank && StringUtils.isBlank(string)) |
| | | { |
| | | for (String string : split) { |
| | | if (filterBlank && StringUtils.isBlank(string)) { |
| | | continue; |
| | | } |
| | | if (trim) |
| | | { |
| | | if (trim) { |
| | | string = string.trim(); |
| | | } |
| | | list.add(string); |
| | |
| | | /** |
| | | * 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写 |
| | | * |
| | | * @param cs 指定字符串 |
| | | * @param cs 指定字符串 |
| | | * @param searchCharSequences 需要检查的字符串数组 |
| | | * @return 是否包含任意一个字符串 |
| | | */ |
| | | public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) |
| | | { |
| | | if (isEmpty(cs) || isEmpty(searchCharSequences)) |
| | | { |
| | | public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) { |
| | | if (isEmpty(cs) || isEmpty(searchCharSequences)) { |
| | | return false; |
| | | } |
| | | for (CharSequence testStr : searchCharSequences) |
| | | { |
| | | if (containsIgnoreCase(cs, testStr)) |
| | | { |
| | | for (CharSequence testStr : searchCharSequences) { |
| | | if (containsIgnoreCase(cs, testStr)) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 驼峰转下划线命名 |
| | | */ |
| | | public static String toUnderScoreCase(String str) |
| | | { |
| | | if (str == null) |
| | | { |
| | | public static String toUnderScoreCase(String str) { |
| | | if (str == null) { |
| | | return null; |
| | | } |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | boolean curreCharIsUpperCase = true; |
| | | // 下一字符是否大写 |
| | | boolean nexteCharIsUpperCase = true; |
| | | for (int i = 0; i < str.length(); i++) |
| | | { |
| | | for (int i = 0; i < str.length(); i++) { |
| | | char c = str.charAt(i); |
| | | if (i > 0) |
| | | { |
| | | if (i > 0) { |
| | | preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | preCharIsUpperCase = false; |
| | | } |
| | | |
| | | curreCharIsUpperCase = Character.isUpperCase(c); |
| | | |
| | | if (i < (str.length() - 1)) |
| | | { |
| | | if (i < (str.length() - 1)) { |
| | | nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); |
| | | } |
| | | |
| | | if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) |
| | | { |
| | | if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) { |
| | | sb.append(SEPARATOR); |
| | | } |
| | | else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) |
| | | { |
| | | } else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) { |
| | | sb.append(SEPARATOR); |
| | | } |
| | | sb.append(Character.toLowerCase(c)); |
| | |
| | | |
| | | /** |
| | | * 是否包含字符串 |
| | | * |
| | | * @param str 验证字符串 |
| | | * |
| | | * @param str 验证字符串 |
| | | * @param strs 字符串组 |
| | | * @return 包含返回true |
| | | */ |
| | | public static boolean inStringIgnoreCase(String str, String... strs) |
| | | { |
| | | if (str != null && strs != null) |
| | | { |
| | | for (String s : strs) |
| | | { |
| | | if (str.equalsIgnoreCase(trim(s))) |
| | | { |
| | | public static boolean inStringIgnoreCase(String str, String... strs) { |
| | | if (str != null && strs != null) { |
| | | for (String s : strs) { |
| | | if (str.equalsIgnoreCase(trim(s))) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld |
| | | * |
| | | * |
| | | * @param name 转换前的下划线大写方式命名的字符串 |
| | | * @return 转换后的驼峰式命名的字符串 |
| | | */ |
| | | public static String convertToCamelCase(String name) |
| | | { |
| | | public static String convertToCamelCase(String name) { |
| | | StringBuilder result = new StringBuilder(); |
| | | // 快速检查 |
| | | if (name == null || name.isEmpty()) |
| | | { |
| | | if (name == null || name.isEmpty()) { |
| | | // 没必要转换 |
| | | return ""; |
| | | } |
| | | else if (!name.contains("_")) |
| | | { |
| | | } else if (!name.contains("_")) { |
| | | // 不含下划线,仅将首字母大写 |
| | | return name.substring(0, 1).toUpperCase() + name.substring(1); |
| | | } |
| | | // 用下划线将原始字符串分割 |
| | | String[] camels = name.split("_"); |
| | | for (String camel : camels) |
| | | { |
| | | for (String camel : camels) { |
| | | // 跳过原始字符串中开头、结尾的下换线或双重下划线 |
| | | if (camel.isEmpty()) |
| | | { |
| | | if (camel.isEmpty()) { |
| | | continue; |
| | | } |
| | | // 首字母大写 |
| | |
| | | /** |
| | | * 驼峰式命名法 例如:user_name->userName |
| | | */ |
| | | public static String toCamelCase(String s) |
| | | { |
| | | if (s == null) |
| | | { |
| | | public static String toCamelCase(String s) { |
| | | if (s == null) { |
| | | return null; |
| | | } |
| | | s = s.toLowerCase(); |
| | | StringBuilder sb = new StringBuilder(s.length()); |
| | | boolean upperCase = false; |
| | | for (int i = 0; i < s.length(); i++) |
| | | { |
| | | for (int i = 0; i < s.length(); i++) { |
| | | char c = s.charAt(i); |
| | | |
| | | if (c == SEPARATOR) |
| | | { |
| | | if (c == SEPARATOR) { |
| | | upperCase = true; |
| | | } |
| | | else if (upperCase) |
| | | { |
| | | } else if (upperCase) { |
| | | sb.append(Character.toUpperCase(c)); |
| | | upperCase = false; |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | sb.append(c); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串 |
| | | * |
| | | * @param str 指定字符串 |
| | | * |
| | | * @param str 指定字符串 |
| | | * @param strs 需要检查的字符串数组 |
| | | * @return 是否匹配 |
| | | */ |
| | | public static boolean matches(String str, List<String> strs) |
| | | { |
| | | if (isEmpty(str) || isEmpty(strs)) |
| | | { |
| | | public static boolean matches(String str, List<String> strs) { |
| | | if (isEmpty(str) || isEmpty(strs)) { |
| | | return false; |
| | | } |
| | | for (String pattern : strs) |
| | | { |
| | | if (isMatch(pattern, str)) |
| | | { |
| | | for (String pattern : strs) { |
| | | if (isMatch(pattern, str)) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 判断url是否与规则配置: |
| | | * ? 表示单个字符; |
| | | * * 表示一层路径内的任意字符串,不可跨层级; |
| | | * 判断url是否与规则配置: |
| | | * ? 表示单个字符; |
| | | * * 表示一层路径内的任意字符串,不可跨层级; |
| | | * ** 表示任意层路径; |
| | | * |
| | | * |
| | | * @param pattern 匹配规则 |
| | | * @param url 需要匹配的url |
| | | * @param url 需要匹配的url |
| | | * @return |
| | | */ |
| | | public static boolean isMatch(String pattern, String url) |
| | | { |
| | | public static boolean isMatch(String pattern, String url) { |
| | | AntPathMatcher matcher = new AntPathMatcher(); |
| | | return matcher.match(pattern, url); |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public static <T> T cast(Object obj) |
| | | { |
| | | public static <T> T cast(Object obj) { |
| | | return (T) obj; |
| | | } |
| | | } |
| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class FileUploadUtils |
| | | { |
| | | public class FileUploadUtils { |
| | | /** |
| | | * 默认大小 50M |
| | | */ |
| | |
| | | */ |
| | | private static String defaultBaseDir = RuoYiConfig.getProfile(); |
| | | |
| | | public static void setDefaultBaseDir(String defaultBaseDir) |
| | | { |
| | | public static void setDefaultBaseDir(String defaultBaseDir) { |
| | | FileUploadUtils.defaultBaseDir = defaultBaseDir; |
| | | } |
| | | |
| | | public static String getDefaultBaseDir() |
| | | { |
| | | public static String getDefaultBaseDir() { |
| | | return defaultBaseDir; |
| | | } |
| | | |
| | |
| | | * @return 文件名称 |
| | | * @throws Exception |
| | | */ |
| | | public static final String upload(MultipartFile file) throws IOException |
| | | { |
| | | try |
| | | { |
| | | public static final String upload(MultipartFile file) throws IOException { |
| | | try { |
| | | return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | throw new IOException(e.getMessage(), e); |
| | | } |
| | | } |
| | |
| | | * 根据文件路径上传 |
| | | * |
| | | * @param baseDir 相对应用的基目录 |
| | | * @param file 上传的文件 |
| | | * @param file 上传的文件 |
| | | * @return 文件名称 |
| | | * @throws IOException |
| | | */ |
| | | public static final String upload(String baseDir, MultipartFile file) throws IOException |
| | | { |
| | | try |
| | | { |
| | | public static final String upload(String baseDir, MultipartFile file) throws IOException { |
| | | try { |
| | | return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | throw new IOException(e.getMessage(), e); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 文件上传 |
| | | * |
| | | * @param baseDir 相对应用的基目录 |
| | | * @param file 上传的文件 |
| | | * @param baseDir 相对应用的基目录 |
| | | * @param file 上传的文件 |
| | | * @param allowedExtension 上传文件类型 |
| | | * @return 返回上传成功的文件名 |
| | | * @throws FileSizeLimitExceededException 如果超出最大大小 |
| | | * @throws FileSizeLimitExceededException 如果超出最大大小 |
| | | * @throws FileNameLengthLimitExceededException 文件名太长 |
| | | * @throws IOException 比如读写文件出错时 |
| | | * @throws InvalidExtensionException 文件校验异常 |
| | | * @throws IOException 比如读写文件出错时 |
| | | * @throws InvalidExtensionException 文件校验异常 |
| | | */ |
| | | public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) |
| | | throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, |
| | | InvalidExtensionException |
| | | { |
| | | InvalidExtensionException { |
| | | int fileNamelength = file.getOriginalFilename().length(); |
| | | if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) |
| | | { |
| | | if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { |
| | | throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); |
| | | } |
| | | |
| | |
| | | /** |
| | | * 编码文件名 |
| | | */ |
| | | public static final String extractFilename(MultipartFile file) |
| | | { |
| | | public static final String extractFilename(MultipartFile file) { |
| | | String fileName = file.getOriginalFilename(); |
| | | String extension = getExtension(file); |
| | | fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension; |
| | | return fileName; |
| | | } |
| | | |
| | | public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException |
| | | { |
| | | public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { |
| | | File desc = new File(uploadDir + File.separator + fileName); |
| | | |
| | | if (!desc.exists()) |
| | | { |
| | | if (!desc.getParentFile().exists()) |
| | | { |
| | | if (!desc.exists()) { |
| | | if (!desc.getParentFile().exists()) { |
| | | desc.getParentFile().mkdirs(); |
| | | } |
| | | } |
| | | return desc; |
| | | } |
| | | |
| | | public static final String getPathFileName(String uploadDir, String fileName) throws IOException |
| | | { |
| | | public static final String getPathFileName(String uploadDir, String fileName) throws IOException { |
| | | int dirLastIndex = RuoYiConfig.getProfile().length() + 1; |
| | | String currentDir = StringUtils.substring(uploadDir, dirLastIndex); |
| | | String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; |
| | |
| | | * @throws InvalidExtensionException |
| | | */ |
| | | public static final void assertAllowed(MultipartFile file, String[] allowedExtension) |
| | | throws FileSizeLimitExceededException, InvalidExtensionException |
| | | { |
| | | throws FileSizeLimitExceededException, InvalidExtensionException { |
| | | long size = file.getSize(); |
| | | if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE) |
| | | { |
| | | if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE) { |
| | | throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); |
| | | } |
| | | |
| | | String fileName = file.getOriginalFilename(); |
| | | String extension = getExtension(file); |
| | | if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) |
| | | { |
| | | if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) |
| | | { |
| | | if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { |
| | | if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { |
| | | throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, |
| | | fileName); |
| | | } |
| | | else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) |
| | | { |
| | | } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) { |
| | | throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, |
| | | fileName); |
| | | } |
| | | else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) |
| | | { |
| | | } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) { |
| | | throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, |
| | | fileName); |
| | | } |
| | | else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) |
| | | { |
| | | } else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) { |
| | | throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, |
| | | fileName); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | throw new InvalidExtensionException(allowedExtension, extension, fileName); |
| | | } |
| | | } |
| | |
| | | * @param allowedExtension |
| | | * @return |
| | | */ |
| | | public static final boolean isAllowedExtension(String extension, String[] allowedExtension) |
| | | { |
| | | for (String str : allowedExtension) |
| | | { |
| | | if (str.equalsIgnoreCase(extension)) |
| | | { |
| | | public static final boolean isAllowedExtension(String extension, String[] allowedExtension) { |
| | | for (String str : allowedExtension) { |
| | | if (str.equalsIgnoreCase(extension)) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | * @param file 表单文件 |
| | | * @return 后缀名 |
| | | */ |
| | | public static final String getExtension(MultipartFile file) |
| | | { |
| | | public static final String getExtension(MultipartFile file) { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | if (StringUtils.isEmpty(extension)) |
| | | { |
| | | if (StringUtils.isEmpty(extension)) { |
| | | extension = MimeTypeUtils.getExtension(file.getContentType()); |
| | | } |
| | | return extension; |
| | |
| | | |
| | | /** |
| | | * 媒体类型工具类 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class MimeTypeUtils |
| | | { |
| | | public class MimeTypeUtils { |
| | | public static final String IMAGE_PNG = "image/png"; |
| | | |
| | | public static final String IMAGE_JPG = "image/jpg"; |
| | |
| | | public static final String IMAGE_BMP = "image/bmp"; |
| | | |
| | | public static final String IMAGE_GIF = "image/gif"; |
| | | |
| | | public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" }; |
| | | |
| | | public static final String[] FLASH_EXTENSION = { "swf", "flv" }; |
| | | public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"}; |
| | | |
| | | public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", |
| | | "asf", "rm", "rmvb" }; |
| | | public static final String[] FLASH_EXTENSION = {"swf", "flv"}; |
| | | |
| | | public static final String[] VIDEO_EXTENSION = { "mp4", "avi", "rmvb" }; |
| | | public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", |
| | | "asf", "rm", "rmvb"}; |
| | | |
| | | public static final String[] VIDEO_EXTENSION = {"mp4", "avi", "rmvb"}; |
| | | |
| | | public static final String[] DEFAULT_ALLOWED_EXTENSION = { |
| | | // 图片 |
| | |
| | | // 视频格式 |
| | | "mp4", "avi", "rmvb", |
| | | // pdf |
| | | "pdf" }; |
| | | "pdf"}; |
| | | |
| | | public static String getExtension(String prefix) |
| | | { |
| | | switch (prefix) |
| | | { |
| | | public static String getExtension(String prefix) { |
| | | switch (prefix) { |
| | | case IMAGE_PNG: |
| | | return "png"; |
| | | case IMAGE_JPG: |
| | |
| | | |
| | | /** |
| | | * spring工具类 方便在非spring管理环境中获取bean |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware |
| | | { |
| | | /** Spring应用上下文环境 */ |
| | | public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { |
| | | /** |
| | | * Spring应用上下文环境 |
| | | */ |
| | | private static ConfigurableListableBeanFactory beanFactory; |
| | | |
| | | private static ApplicationContext applicationContext; |
| | | |
| | | @Override |
| | | public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException |
| | | { |
| | | public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { |
| | | SpringUtils.beanFactory = beanFactory; |
| | | } |
| | | |
| | | @Override |
| | | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException |
| | | { |
| | | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
| | | SpringUtils.applicationContext = applicationContext; |
| | | } |
| | | |
| | |
| | | * @param name |
| | | * @return Object 一个以所给名字注册的bean的实例 |
| | | * @throws org.springframework.beans.BeansException |
| | | * |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <T> T getBean(String name) throws BeansException |
| | | { |
| | | public static <T> T getBean(String name) throws BeansException { |
| | | return (T) beanFactory.getBean(name); |
| | | } |
| | | |
| | |
| | | * @param clz |
| | | * @return |
| | | * @throws org.springframework.beans.BeansException |
| | | * |
| | | */ |
| | | public static <T> T getBean(Class<T> clz) throws BeansException |
| | | { |
| | | public static <T> T getBean(Class<T> clz) throws BeansException { |
| | | T result = (T) beanFactory.getBean(clz); |
| | | return result; |
| | | } |
| | |
| | | * @param name |
| | | * @return boolean |
| | | */ |
| | | public static boolean containsBean(String name) |
| | | { |
| | | public static boolean containsBean(String name) { |
| | | return beanFactory.containsBean(name); |
| | | } |
| | | |
| | |
| | | * @param name |
| | | * @return boolean |
| | | * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException |
| | | * |
| | | */ |
| | | public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException |
| | | { |
| | | public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { |
| | | return beanFactory.isSingleton(name); |
| | | } |
| | | |
| | |
| | | * @param name |
| | | * @return Class 注册对象的类型 |
| | | * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException |
| | | * |
| | | */ |
| | | public static Class<?> getType(String name) throws NoSuchBeanDefinitionException |
| | | { |
| | | public static Class<?> getType(String name) throws NoSuchBeanDefinitionException { |
| | | return beanFactory.getType(name); |
| | | } |
| | | |
| | |
| | | * @param name |
| | | * @return |
| | | * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException |
| | | * |
| | | */ |
| | | public static String[] getAliases(String name) throws NoSuchBeanDefinitionException |
| | | { |
| | | public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { |
| | | return beanFactory.getAliases(name); |
| | | } |
| | | |
| | | /** |
| | | * 获取aop代理对象 |
| | | * |
| | | * |
| | | * @param invoker |
| | | * @return |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <T> T getAopProxy(T invoker) |
| | | { |
| | | public static <T> T getAopProxy(T invoker) { |
| | | return (T) AopContext.currentProxy(); |
| | | } |
| | | |
| | |
| | | * |
| | | * @return 当前的环境配置 |
| | | */ |
| | | public static String[] getActiveProfiles() |
| | | { |
| | | public static String[] getActiveProfiles() { |
| | | return applicationContext.getEnvironment().getActiveProfiles(); |
| | | } |
| | | |
| | |
| | | * |
| | | * @return 当前的环境配置 |
| | | */ |
| | | public static String getActiveProfile() |
| | | { |
| | | public static String getActiveProfile() { |
| | | final String[] activeProfiles = getActiveProfiles(); |
| | | return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; |
| | | } |
| | |
| | | package com.ruoyi.iot.controller; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | import com.ruoyi.iot.domain.DeviceOrder; |
| | | import com.ruoyi.iot.service.IDeviceOrderService; |
| | | import com.ruoyi.iot.service.IDeviceService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.*; |
| | | import org.thymeleaf.util.ArrayUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | import static com.ruoyi.common.utils.SecurityUtils.getLoginUser; |
| | | |
| | | /** |
| | | * @author wmz |
| | |
| | | @ApiOperation(value = "获取设备订单分页列表") |
| | | public TableDataInfo list(DeviceOrder deviceOrder) throws Exception { |
| | | startPage(); |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | | deviceOrder.setCreateUserId(sysUser.getUserId()); |
| | | // SysUser sysUser = getLoginUser().getUser(); |
| | | // deviceOrder.setCreateUserId(sysUser.getUserId()); |
| | | List<DeviceOrder> list = iDeviceOrderService.selectDeviceOrderList(deviceOrder); |
| | | return getDataTable(list); |
| | | } |
| | |
| | | @Log(title = "修改设备订单信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody DeviceOrder deviceOrder) throws Exception { |
| | | return AjaxResult.success(iDeviceOrderService.updateDeviceOrder(deviceOrder)); |
| | | //获取修改订单的用户信息 |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | | //拿到修改安装单的用户id |
| | | deviceOrder.setUpdateUserId(sysUser.getUserId()); |
| | | return toAjax(iDeviceOrderService.updateDeviceOrder(deviceOrder)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws Exception |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('iot:device:list')") |
| | | @Log(title = "修改设备订单信息", businessType = BusinessType.DELETE) |
| | | @Log(title = "删除设备订单信息", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deviceId}") |
| | | @ApiOperation("删除订单信息") |
| | | public AjaxResult remove(@PathVariable("deviceId") Integer deviceId) throws Exception { |
| | |
| | | DeviceOrder deviceOrder = iDeviceOrderService.selectDeviceOrderById(deviceId); |
| | | //如果根据查询出来的安装单对象不为空的话,并且状态等于未派单才可以删除 |
| | | if (deviceOrder != null && deviceOrder.getState() == 0) { |
| | | //未派单的安装单删除后设备的状态更新为-未激活 |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setStatus(1); |
| | | deviceService.updateDevice(device); |
| | | int i = iDeviceOrderService.deleteDeviceOrderById(deviceOrder.getId()); |
| | | return toAjax(i); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | private BigDecimal firmwareVersion; |
| | | |
| | | /** |
| | | * 设备状态(1-未激活,2-禁用,3-在线,4-离线) |
| | | * 设备状态(1-未激活,2-禁用,3-在线,4-离线,5-安装中) |
| | | */ |
| | | @Excel(name = "设备状态") |
| | | private Integer status; |
| | |
| | | this.assignTime = assignTime; |
| | | } |
| | | |
| | | public Device() { |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
| | |
| | | package com.ruoyi.iot.domain; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | |
| | | */ |
| | | private Long createUserId; |
| | | |
| | | /** |
| | | * 修改用户的id |
| | | */ |
| | | private Long updateUserId; |
| | | /** |
| | | * 安装工名称 |
| | | */ |
| | |
| | | @Excel(name = "预约时间") |
| | | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JSONField(format = "yyyy-MM-dd HH:mm:ss") |
| | | private Date appointmentTime; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Excel(name = "安装工的状态") |
| | | private Integer state; |
| | | |
| | | /** |
| | | * 照片地址 |
| | | */ |
| | | private String imgUrl; |
| | | |
| | | /** |
| | | * 用户对象 |
| | |
| | | |
| | | public void setCreateUserId(Long createUserId) { |
| | | this.createUserId = createUserId; |
| | | } |
| | | |
| | | public Long getUpdateUserId() { |
| | | return updateUserId; |
| | | } |
| | | |
| | | public void setUpdateUserId(Long updateUserId) { |
| | | this.updateUserId = updateUserId; |
| | | } |
| | | |
| | | public String getErectoName() { |
| | |
| | | this.suser = suser; |
| | | } |
| | | |
| | | public String getImgUrl() { |
| | | return imgUrl; |
| | | } |
| | | |
| | | public void setImgUrl(String imgUrl) { |
| | | this.imgUrl = imgUrl; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | |
| | | .append("suser", getSuser()) |
| | | .append("device", getDevice()) |
| | | .append("createUserId", getCreateUserId()) |
| | | .append("updateUserId", getUpdateUserId()) |
| | | .append("imgUrl", getImgUrl()) |
| | | .toString(); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.iot.mapper; |
| | | |
| | | import com.ruoyi.iot.domain.Device; |
| | | import com.ruoyi.iot.domain.DeviceOrder; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wmz |
| | | * @version v1.0 |
| | | * @ClassName DeviceOrderMapper |
| | | * @description |
| | | * @description 设备安装订单Mapper接口 |
| | | * @createTime 2023/11/12 23:10 |
| | | */ |
| | | |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public DeviceOrder selectDeviceOrderById(int deviceId)throws Exception; |
| | | public DeviceOrder selectDeviceOrderById(int id) throws Exception; |
| | | |
| | | /** |
| | | * 添加安装设备订单信息 |
| | |
| | | package com.ruoyi.iot.service; |
| | | |
| | | import com.ruoyi.iot.domain.DeviceOrder; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @throws Exception |
| | | */ |
| | | public DeviceOrder selectDeviceOrderById(int id)throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 添加安装设备订单信息 |
| | |
| | | package com.ruoyi.iot.service.impl; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.iot.domain.DeviceOrder; |
| | | import com.ruoyi.iot.mapper.DeviceOrderMapper; |
| | | import com.ruoyi.iot.service.IDeviceOrderService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * @author wmz |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DeviceOrder selectDeviceOrderById(int deviceId) throws Exception { |
| | | return deviceOrderMapper.selectDeviceOrderById(deviceId); |
| | | public DeviceOrder selectDeviceOrderById(int id) throws Exception { |
| | | return deviceOrderMapper.selectDeviceOrderById(id); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改设备订单信息 |
| | | * 修改保存设备订单信息 |
| | | * |
| | | * @param order |
| | | * @return |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public int deleteDeviceOrderById(Integer deviceId) throws Exception { |
| | | return deviceOrderMapper.deleteDeviceOrderById(deviceId); |
| | | public int deleteDeviceOrderById(Integer id) throws Exception { |
| | | return deviceOrderMapper.deleteDeviceOrderById(id); |
| | | } |
| | | |
| | | /** |
| | |
| | | <mapper namespace="com.ruoyi.iot.mapper.DeviceOrderMapper"> |
| | | |
| | | <sql id="selectDeviceOrderVo"> |
| | | select id, |
| | | erecto_id, |
| | | device_id, |
| | | user_id, |
| | | erecto_name, |
| | | user_name, |
| | | user_phone, |
| | | address, |
| | | order_type, |
| | | remark, |
| | | appointment_time, |
| | | score, |
| | | evaluate, |
| | | create_time, |
| | | receive_time, |
| | | finsh_time, |
| | | state, |
| | | createuser_id |
| | | from iot_device_order |
| | | select d.id, |
| | | d.user_id, |
| | | d.erecto_id, |
| | | d.erecto_name, |
| | | d.user_name, |
| | | d.user_phone, |
| | | d.address, |
| | | d.order_type, |
| | | d.appointment_time, |
| | | d.evaluate, |
| | | d.device_id, |
| | | d.remark, |
| | | u.user_id, |
| | | u.user_name, |
| | | u.is_authentication, |
| | | d.score, |
| | | d.state, |
| | | d.createuser_id, |
| | | d.imgurl, |
| | | de.device_id, |
| | | de.device_name |
| | | from iot_device_order as d |
| | | left join sys_user as u on d.erecto_id = u.user_id |
| | | left join iot_device as de on d.device_id = de.device_id |
| | | where d.createuser_id = #{createUserId} |
| | | and d.order_type = #{orderType} |
| | | </sql> |
| | | |
| | | <resultMap id="DeviceOrderResult" type="DeviceOrder"> |
| | |
| | | <result property="finshTime" column="finsh_time"/> |
| | | <result property="state" column="state"/> |
| | | <result property="createUserId" column="createuser_id"/> |
| | | <result property="imgUrl" column="imgurl"/> |
| | | <association property="device" javaType="Device" resultMap="DeviceResult"/> |
| | | <collection property="suser" ofType="sysUser" resultMap="UserResult"/> |
| | | </resultMap> |
| | |
| | | d.score, |
| | | d.state, |
| | | d.createuser_id, |
| | | d.imgurl, |
| | | de.device_id, |
| | | de.device_name |
| | | from iot_device_order as d |
| | | left join sys_user as u on d.erecto_id = u.user_id |
| | | left join iot_device as de on d.device_id = de.device_id |
| | | where d.createuser_id= #{createUserId} |
| | | and d.order_type = #{orderType} |
| | | where d.order_type = #{orderType} |
| | | <if test=" createUserId != null and createUserId > 0"> |
| | | and d.createuser_id= #{createUserId} |
| | | </if> |
| | | <if test=" erectoId != null and erectoId > 0"> |
| | | and d.erecto_id= #{erectoId} |
| | | </if> |
| | | <if test="state != null and state >= 0"> |
| | | and d.state = #{state} |
| | | </if> |
| | | order by d.create_time desc |
| | | ${params.dataScope} |
| | | </select> |
| | | <select id="selectDeviceOrderById" resultType="com.ruoyi.iot.domain.DeviceOrder"> |
| | | <select id="selectDeviceOrderById" resultMap="DeviceOrderResult"> |
| | | select d.id, |
| | | d.user_id, |
| | | d.erecto_id, |
| | |
| | | <if test="finshTime != null">finsh_time,</if> |
| | | <if test="state != null and state != ''">state,</if> |
| | | <if test="createUserId != null and createUserId != 0">createuser_id,</if> |
| | | <if test="imgUrl != null and imgUrl != ''">imgurl,</if> |
| | | create_time) |
| | | values ( |
| | | <if test="id != null and id != ''">#{id},</if> |
| | |
| | | <if test="finshTime != null">#{finshTime},</if> |
| | | <if test="state != null and state != ''">#{state},</if> |
| | | <if test="createUserId != null and createUserId != 0">#{createUserId},</if> |
| | | <if test="imgUrl != null and imgUrl != ''">#{imgUrl}</if> |
| | | sysdate()) |
| | | </insert> |
| | | <update id="updateDeviceOrder"> |
| | | <update id="updateDeviceOrder" parameterType="DeviceOrder"> |
| | | update iot_device_order |
| | | <set> |
| | | <if test="id != null and id != 0">id = #{id},</if> |
| | |
| | | <if test="userPhone != null and userPhone != ''">user_phone = #{userPhone},</if> |
| | | <if test="address != null and address != ''">address = #{address},</if> |
| | | <if test="orderType != null and orderType != ''">order_type = #{orderType},</if> |
| | | <if test="remark != null and remark != ''">remark = #{remark},</if> |
| | | <if test="appointmentTime != null">appointment_time = #{appointmentTime},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | appointment_time = #{appointmentTime}, |
| | | <if test="score != null and score != ''">score = #{score},</if> |
| | | <if test="evaluate != null">evaluate = #{evaluate},</if> |
| | | <if test="receiveTime != null">receive_time = #{receiveTime},</if> |
| | | <if test="finshTime != null">finsh_time = #{finshTime},</if> |
| | | <if test="state != null and state != ''">state = #{state}</if> |
| | | <if test="state != null">state = #{state},</if> |
| | | <if test="updateUserId != null and updateUserId != 0">updateuser_id = #{updateUserId},</if> |
| | | <if test="imgUrl != null and imgUrl != ''">imgurl = #{imgUrl}</if> |
| | | </set> |
| | | where id = #{id} |
| | | </update> |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | |
| | | /** |
| | | * 字典 业务层 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDictTypeService |
| | | { |
| | | public interface ISysDictTypeService { |
| | | /** |
| | | * 根据条件分页查询字典类型 |
| | | * |
| | | * |
| | | * @param dictType 字典类型信息 |
| | | * @return 字典类型集合信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据所有字典类型 |
| | | * |
| | | * |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | public List<SysDictType> selectDictTypeAll(); |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据 |
| | | * |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典数据集合信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据字典类型ID查询信息 |
| | | * |
| | | * |
| | | * @param dictId 字典类型ID |
| | | * @return 字典类型 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据字典类型查询信息 |
| | | * |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典类型 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 批量删除字典信息 |
| | | * |
| | | * |
| | | * @param dictIds 需要删除的字典ID |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 新增保存字典类型信息 |
| | | * |
| | | * |
| | | * @param dictType 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改保存字典类型信息 |
| | | * |
| | | * |
| | | * @param dictType 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 校验字典类型称是否唯一 |
| | | * |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 结果 |
| | | */ |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 业务层处理 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysDictTypeServiceImpl implements ISysDictTypeService |
| | | { |
| | | public class SysDictTypeServiceImpl implements ISysDictTypeService { |
| | | @Autowired |
| | | private SysDictTypeMapper dictTypeMapper; |
| | | |
| | |
| | | * 项目启动时,初始化字典到缓存 |
| | | */ |
| | | @PostConstruct |
| | | public void init() |
| | | { |
| | | public void init() { |
| | | loadingDictCache(); |
| | | } |
| | | |
| | | /** |
| | | * 根据条件分页查询字典类型 |
| | | * |
| | | * |
| | | * @param dictType 字典类型信息 |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType) |
| | | { |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType) { |
| | | return dictTypeMapper.selectDictTypeList(dictType); |
| | | } |
| | | |
| | | /** |
| | | * 根据所有字典类型 |
| | | * |
| | | * |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictType> selectDictTypeAll() |
| | | { |
| | | public List<SysDictType> selectDictTypeAll() { |
| | | return dictTypeMapper.selectDictTypeAll(); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据 |
| | | * |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictData> selectDictDataByType(String dictType) |
| | | { |
| | | public List<SysDictData> selectDictDataByType(String dictType) { |
| | | List<SysDictData> dictDatas = DictUtils.getDictCache(dictType); |
| | | if (StringUtils.isNotEmpty(dictDatas)) |
| | | { |
| | | if (StringUtils.isNotEmpty(dictDatas)) { |
| | | return dictDatas; |
| | | } |
| | | dictDatas = dictDataMapper.selectDictDataByType(dictType); |
| | | if (StringUtils.isNotEmpty(dictDatas)) |
| | | { |
| | | if (StringUtils.isNotEmpty(dictDatas)) { |
| | | DictUtils.setDictCache(dictType, dictDatas); |
| | | return dictDatas; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据字典类型ID查询信息 |
| | | * |
| | | * |
| | | * @param dictId 字典类型ID |
| | | * @return 字典类型 |
| | | */ |
| | | @Override |
| | | public SysDictType selectDictTypeById(Long dictId) |
| | | { |
| | | public SysDictType selectDictTypeById(Long dictId) { |
| | | return dictTypeMapper.selectDictTypeById(dictId); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询信息 |
| | | * |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典类型 |
| | | */ |
| | | @Override |
| | | public SysDictType selectDictTypeByType(String dictType) |
| | | { |
| | | public SysDictType selectDictTypeByType(String dictType) { |
| | | return dictTypeMapper.selectDictTypeByType(dictType); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除字典类型信息 |
| | | * |
| | | * |
| | | * @param dictIds 需要删除的字典ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public void deleteDictTypeByIds(Long[] dictIds) |
| | | { |
| | | for (Long dictId : dictIds) |
| | | { |
| | | public void deleteDictTypeByIds(Long[] dictIds) { |
| | | for (Long dictId : dictIds) { |
| | | SysDictType dictType = selectDictTypeById(dictId); |
| | | if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) |
| | | { |
| | | if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) { |
| | | throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName())); |
| | | } |
| | | dictTypeMapper.deleteDictTypeById(dictId); |
| | |
| | | * 加载字典缓存数据 |
| | | */ |
| | | @Override |
| | | public void loadingDictCache() |
| | | { |
| | | public void loadingDictCache() { |
| | | List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll(); |
| | | for (SysDictType dictType : dictTypeList) |
| | | { |
| | | for (SysDictType dictType : dictTypeList) { |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); |
| | | DictUtils.setDictCache(dictType.getDictType(), dictDatas); |
| | | } |
| | |
| | | * 清空字典缓存数据 |
| | | */ |
| | | @Override |
| | | public void clearDictCache() |
| | | { |
| | | public void clearDictCache() { |
| | | DictUtils.clearDictCache(); |
| | | } |
| | | |
| | |
| | | * 重置字典缓存数据 |
| | | */ |
| | | @Override |
| | | public void resetDictCache() |
| | | { |
| | | public void resetDictCache() { |
| | | clearDictCache(); |
| | | loadingDictCache(); |
| | | } |
| | | |
| | | /** |
| | | * 新增保存字典类型信息 |
| | | * |
| | | * |
| | | * @param dict 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertDictType(SysDictType dict) |
| | | { |
| | | public int insertDictType(SysDictType dict) { |
| | | int row = dictTypeMapper.insertDictType(dict); |
| | | if (row > 0) |
| | | { |
| | | if (row > 0) { |
| | | DictUtils.setDictCache(dict.getDictType(), null); |
| | | } |
| | | return row; |
| | |
| | | |
| | | /** |
| | | * 修改保存字典类型信息 |
| | | * |
| | | * |
| | | * @param dict 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int updateDictType(SysDictType dict) |
| | | { |
| | | public int updateDictType(SysDictType dict) { |
| | | SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId()); |
| | | dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType()); |
| | | int row = dictTypeMapper.updateDictType(dict); |
| | | if (row > 0) |
| | | { |
| | | if (row > 0) { |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType()); |
| | | DictUtils.setDictCache(dict.getDictType(), dictDatas); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 校验字典类型称是否唯一 |
| | | * |
| | | * |
| | | * @param dict 字典类型 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public String checkDictTypeUnique(SysDictType dict) |
| | | { |
| | | public String checkDictTypeUnique(SysDictType dict) { |
| | | Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); |
| | | SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); |
| | | if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) |
| | | { |
| | | if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.system.mapper.SysDictDataMapper"> |
| | | |
| | | <resultMap type="SysDictData" id="SysDictDataResult"> |
| | | <id property="dictCode" column="dict_code" /> |
| | | <result property="dictSort" column="dict_sort" /> |
| | | <result property="dictLabel" column="dict_label" /> |
| | | <result property="dictValue" column="dict_value" /> |
| | | <result property="dictType" column="dict_type" /> |
| | | <result property="cssClass" column="css_class" /> |
| | | <result property="listClass" column="list_class" /> |
| | | <result property="isDefault" column="is_default" /> |
| | | <result property="status" column="status" /> |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectDictDataVo"> |
| | | select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark |
| | | from sys_dict_data |
| | | |
| | | <resultMap type="SysDictData" id="SysDictDataResult"> |
| | | <id property="dictCode" column="dict_code"/> |
| | | <result property="dictSort" column="dict_sort"/> |
| | | <result property="dictLabel" column="dict_label"/> |
| | | <result property="dictValue" column="dict_value"/> |
| | | <result property="dictType" column="dict_type"/> |
| | | <result property="cssClass" column="css_class"/> |
| | | <result property="listClass" column="list_class"/> |
| | | <result property="isDefault" column="is_default"/> |
| | | <result property="status" column="status"/> |
| | | <result property="createBy" column="create_by"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateBy" column="update_by"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | </resultMap> |
| | | |
| | | <sql id="selectDictDataVo"> |
| | | select dict_code, |
| | | dict_sort, |
| | | dict_label, |
| | | dict_value, |
| | | dict_type, |
| | | css_class, |
| | | list_class, |
| | | is_default, |
| | | status, |
| | | create_by, |
| | | create_time, |
| | | remark |
| | | from sys_dict_data |
| | | </sql> |
| | | |
| | | <select id="selectDictDataList" parameterType="SysDictData" resultMap="SysDictDataResult"> |
| | | <include refid="selectDictDataVo"/> |
| | | <where> |
| | | <if test="dictType != null and dictType != ''"> |
| | | AND dict_type = #{dictType} |
| | | </if> |
| | | <if test="dictLabel != null and dictLabel != ''"> |
| | | AND dict_label like concat('%', #{dictLabel}, '%') |
| | | </if> |
| | | <if test="status != null and status != ''"> |
| | | AND status = #{status} |
| | | </if> |
| | | </where> |
| | | order by dict_sort asc |
| | | </select> |
| | | |
| | | <select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult"> |
| | | <include refid="selectDictDataVo"/> |
| | | where status = '0' and dict_type = #{dictType} order by dict_sort asc |
| | | </select> |
| | | |
| | | <select id="selectDictLabel" resultType="String"> |
| | | select dict_label from sys_dict_data |
| | | where dict_type = #{dictType} and dict_value = #{dictValue} |
| | | </select> |
| | | |
| | | <select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult"> |
| | | <include refid="selectDictDataVo"/> |
| | | where dict_code = #{dictCode} |
| | | </select> |
| | | |
| | | <select id="countDictDataByType" resultType="Integer"> |
| | | select count(1) from sys_dict_data where dict_type=#{dictType} |
| | | </select> |
| | | |
| | | <delete id="deleteDictDataById" parameterType="Long"> |
| | | delete from sys_dict_data where dict_code = #{dictCode} |
| | | </delete> |
| | | |
| | | <delete id="deleteDictDataByIds" parameterType="Long"> |
| | | delete from sys_dict_data where dict_code in |
| | | <foreach collection="array" item="dictCode" open="(" separator="," close=")"> |
| | | #{dictCode} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <update id="updateDictData" parameterType="SysDictData"> |
| | | update sys_dict_data |
| | | <set> |
| | | <if test="dictSort != null">dict_sort = #{dictSort},</if> |
| | | <if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if> |
| | | <if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if> |
| | | <if test="dictType != null and dictType != ''">dict_type = #{dictType},</if> |
| | | <if test="cssClass != null">css_class = #{cssClass},</if> |
| | | <if test="listClass != null">list_class = #{listClass},</if> |
| | | <if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if> |
| | | <if test="status != null">status = #{status},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where dict_code = #{dictCode} |
| | | </update> |
| | | |
| | | <update id="updateDictDataType" parameterType="String"> |
| | | update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType} |
| | | </update> |
| | | |
| | | <insert id="insertDictData" parameterType="SysDictData"> |
| | | insert into sys_dict_data( |
| | | <if test="dictSort != null">dict_sort,</if> |
| | | <if test="dictLabel != null and dictLabel != ''">dict_label,</if> |
| | | <if test="dictValue != null and dictValue != ''">dict_value,</if> |
| | | <if test="dictType != null and dictType != ''">dict_type,</if> |
| | | <if test="cssClass != null and cssClass != ''">css_class,</if> |
| | | <if test="listClass != null and listClass != ''">list_class,</if> |
| | | <if test="isDefault != null and isDefault != ''">is_default,</if> |
| | | <if test="status != null">status,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | create_time |
| | | )values( |
| | | <if test="dictSort != null">#{dictSort},</if> |
| | | <if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if> |
| | | <if test="dictValue != null and dictValue != ''">#{dictValue},</if> |
| | | <if test="dictType != null and dictType != ''">#{dictType},</if> |
| | | <if test="cssClass != null and cssClass != ''">#{cssClass},</if> |
| | | <if test="listClass != null and listClass != ''">#{listClass},</if> |
| | | <if test="isDefault != null and isDefault != ''">#{isDefault},</if> |
| | | <if test="status != null">#{status},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | <select id="selectDictDataList" parameterType="SysDictData" resultMap="SysDictDataResult"> |
| | | <include refid="selectDictDataVo"/> |
| | | <where> |
| | | <if test="dictType != null and dictType != ''"> |
| | | AND dict_type = #{dictType} |
| | | </if> |
| | | <if test="dictLabel != null and dictLabel != ''"> |
| | | AND dict_label like concat('%', #{dictLabel}, '%') |
| | | </if> |
| | | <if test="status != null and status != ''"> |
| | | AND status = #{status} |
| | | </if> |
| | | </where> |
| | | order by dict_sort asc |
| | | </select> |
| | | |
| | | <select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult"> |
| | | <include refid="selectDictDataVo"/> |
| | | where status = '0' and dict_type = #{dictType} order by dict_sort asc |
| | | </select> |
| | | |
| | | <select id="selectDictLabel" resultType="String"> |
| | | select dict_label |
| | | from sys_dict_data |
| | | where dict_type = #{dictType} |
| | | and dict_value = #{dictValue} |
| | | </select> |
| | | |
| | | <select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult"> |
| | | <include refid="selectDictDataVo"/> |
| | | where dict_code = #{dictCode} |
| | | </select> |
| | | |
| | | <select id="countDictDataByType" resultType="Integer"> |
| | | select count(1) |
| | | from sys_dict_data |
| | | where dict_type = #{dictType} |
| | | </select> |
| | | |
| | | <delete id="deleteDictDataById" parameterType="Long"> |
| | | delete |
| | | from sys_dict_data |
| | | where dict_code = #{dictCode} |
| | | </delete> |
| | | |
| | | <delete id="deleteDictDataByIds" parameterType="Long"> |
| | | delete from sys_dict_data where dict_code in |
| | | <foreach collection="array" item="dictCode" open="(" separator="," close=")"> |
| | | #{dictCode} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <update id="updateDictData" parameterType="SysDictData"> |
| | | update sys_dict_data |
| | | <set> |
| | | <if test="dictSort != null">dict_sort = #{dictSort},</if> |
| | | <if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if> |
| | | <if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if> |
| | | <if test="dictType != null and dictType != ''">dict_type = #{dictType},</if> |
| | | <if test="cssClass != null">css_class = #{cssClass},</if> |
| | | <if test="listClass != null">list_class = #{listClass},</if> |
| | | <if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if> |
| | | <if test="status != null">status = #{status},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where dict_code = #{dictCode} |
| | | </update> |
| | | |
| | | <update id="updateDictDataType" parameterType="String"> |
| | | update sys_dict_data |
| | | set dict_type = #{newDictType} |
| | | where dict_type = #{oldDictType} |
| | | </update> |
| | | |
| | | <insert id="insertDictData" parameterType="SysDictData"> |
| | | insert into sys_dict_data( |
| | | <if test="dictSort != null">dict_sort,</if> |
| | | <if test="dictLabel != null and dictLabel != ''">dict_label,</if> |
| | | <if test="dictValue != null and dictValue != ''">dict_value,</if> |
| | | <if test="dictType != null and dictType != ''">dict_type,</if> |
| | | <if test="cssClass != null and cssClass != ''">css_class,</if> |
| | | <if test="listClass != null and listClass != ''">list_class,</if> |
| | | <if test="isDefault != null and isDefault != ''">is_default,</if> |
| | | <if test="status != null">status,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | create_time |
| | | )values( |
| | | <if test="dictSort != null">#{dictSort},</if> |
| | | <if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if> |
| | | <if test="dictValue != null and dictValue != ''">#{dictValue},</if> |
| | | <if test="dictType != null and dictType != ''">#{dictType},</if> |
| | | <if test="cssClass != null and cssClass != ''">#{cssClass},</if> |
| | | <if test="listClass != null and listClass != ''">#{listClass},</if> |
| | | <if test="isDefault != null and isDefault != ''">#{isDefault},</if> |
| | | <if test="status != null">#{status},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | |
| | | <!-- </el-table-column> --> |
| | | <el-table-column label="安装信息"> |
| | | <el-table-column prop="device" label="设备名称" width="120"> |
| | | <template slot-scope="scope"> |
| | | <div> |
| | | {{ scope.row.device && scope.row.device.deviceName ? scope.row.device.deviceName : '--' }} |
| | | </div> |
| | | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="erectoName" label="安装工" width="120"> |
| | | </el-table-column> |
| | | |
| | | <el-table-column prop="appointmentTime" label="预约时间" width="150"> |
| | | <template slot-scope="scope"> |
| | | <div> |
| | |
| | | </el-table-column> |
| | | |
| | | </el-table-column> |
| | | <el-table-column label="用户信息"> |
| | | <el-table-column prop="userName" label="联系人" width="120"> |
| | | </el-table-column> |
| | | <el-table-column prop="userPhone" label="联系电话" width="120"> |
| | | </el-table-column> |
| | | <el-table-column prop="address" label="地址"> |
| | | </el-table-column> |
| | | </el-table-column> |
| | | <!-- <el-table-column label="评价信息"> |
| | | <el-table-column prop="score" label="评分" width="120"> |
| | | </el-table-column> |
| | | <el-table-column prop="evaluate" label="评价" minWidth="120"> |
| | | </el-table-column> |
| | | </el-table-column> --> |
| | | <el-table-column label="状态" prop="state" width="120"> |
| | | <template slot-scope="scope"> |
| | | <div v-if="scope.row.state == 0"> |
| | |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="用户信息"> |
| | | <el-table-column prop="userName" label="联系人" width="120"> |
| | | </el-table-column> |
| | | <el-table-column prop="userPhone" label="联系电话" width="120"> |
| | | </el-table-column> |
| | | <el-table-column prop="address" label="地址"> |
| | | </el-table-column> |
| | | </el-table-column> |
| | | <!-- <el-table-column label="评价信息"> |
| | | <el-table-column prop="score" label="评分" width="120"> |
| | | </el-table-column> |
| | | <el-table-column prop="evaluate" label="评价" minWidth="120"> |
| | | </el-table-column> |
| | | </el-table-column> --> |
| | | |
| | | <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width" width="150"> |
| | | <template slot-scope="scope"> |
| | | <!-- <el-button @click="editModal(scope.row)" type="text" size="small">编辑</el-button> |
| | |
| | | <el-dialog :title="title" :visible.sync="AZModal"> |
| | | <el-form :model="form" :rules="rules" ref="form"> |
| | | <el-form-item label="设备" :label-width="formLabelWidth" prop="deviceId"> |
| | | <!-- <el-input v-model="form.deviceId" autocomplete="off"></el-input> --> |
| | | <el-select v-model="form.deviceId" placeholder="请选择"> |
| | | <el-select v-model="form.deviceId" placeholder="请选择" :disabled="title == '修改安装单'"> |
| | | <el-option v-for="item in deviceList" :label="item.deviceName" :value="item.deviceId"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="安装工" :label-width="formLabelWidth" prop="erectoId"> |
| | | <el-select v-model="form.erectoId" placeholder="请选择"> |
| | | <el-select v-model="form.erectoId" placeholder="请选择" :disabled="form.state>1"> |
| | | <el-option v-for="item in erectoList" :label="item.nickName" :value="item.userId"></el-option> |
| | | <!-- <el-option label="未指派" value="shanghai"></el-option> |
| | | <el-option label="安装工1号" value="beijing"></el-option> --> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="状态" :label-width="formLabelWidth" prop="state"> |
| | | <el-radio-group v-model="form.state" disabled> |
| | | <el-radio :label="0">未指派</el-radio> |
| | | <el-radio :label="1">已派单</el-radio> |
| | | <el-radio :label="2">已接单</el-radio> |
| | | <el-radio :label="3">已完成</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="用户姓名" :label-width="formLabelWidth" prop="userName"> |
| | | <el-input v-model="form.userName" autocomplete="off"></el-input> |
| | |
| | | }, |
| | | form: {}, |
| | | tableData: [ |
| | | { |
| | | "searchValue": null, |
| | | "createBy": null, |
| | | "createTime": null, |
| | | "updateBy": null, |
| | | "updateTime": null, |
| | | "remark": "需要多带两个人", |
| | | "params": {}, |
| | | "id": 3, |
| | | "erectoId": null, |
| | | "deviceId": null, |
| | | "userId": null, |
| | | "userName": null, |
| | | "userPhone": null, |
| | | "address": null, |
| | | "orderType": null, |
| | | "description": null, |
| | | "appointmentTime": null, |
| | | "score": 47, |
| | | "evaluate": "服务的态度的是好的", |
| | | "receiveTime": null, |
| | | "finshTime": null, |
| | | "state": 2, |
| | | // erectoName:'' |
| | | } |
| | | ], |
| | | formLabelWidth: '120px', |
| | | AZModal: false, |
| | |
| | | mounted() { |
| | | this.getList(); |
| | | this.getErectoList() |
| | | this.getDeviceList(); |
| | | |
| | | }, |
| | | methods: { |
| | | getErectoList() { |
| | |
| | | this.erectoList = res.rows |
| | | this.erectoList.unshift({ |
| | | nickName: '未指派', |
| | | userId: 0 |
| | | userId: -1 |
| | | }) |
| | | } else { |
| | | this.erectoList = [] |
| | |
| | | method: "get", |
| | | params: data |
| | | }).then((res) => { |
| | | console.log(res); |
| | | if (res.code == 200) { |
| | | this.deviceList = res.rows |
| | | } else { |
| | |
| | | pageNum: this.pageIndex, |
| | | pageSize: this.pageSize, |
| | | state: this.state, |
| | | orderType:1 |
| | | orderType: 1 |
| | | } |
| | | request({ |
| | | url: '/iot/deviceOrder/list', |
| | |
| | | this.tableData = [] |
| | | this.total = 0 |
| | | } |
| | | |
| | | }).catch((res) => { |
| | | this.tableData = [] |
| | | this.total = 0 |
| | |
| | | |
| | | }, |
| | | openAZModal() { |
| | | this.getDeviceList(); |
| | | this.form = { |
| | | deviceId: undefined, |
| | | address: '',//地址 |
| | | appointmentTime: '',//预约时间 |
| | | remark: '',//备注 |
| | | erectoId: 0,//安装工 |
| | | erectoId: -1,//安装工 |
| | | userName: '', //用户信息,联系人 |
| | | userPhone: '',//用户信息联系电话 |
| | | erectoName: '未指派' |
| | | erectoName: '未指派', |
| | | state: 0 |
| | | } |
| | | this.title = '创建安装单' |
| | | this.AZModal = true |
| | |
| | | this.form.erectoName = this.erectoList[i].nickName |
| | | } |
| | | } |
| | | console.log(this.form); |
| | | let data = { |
| | | deviceId: this.form.deviceId, |
| | | erectoId: this.form.erectoId, |
| | |
| | | address: this.form.address, |
| | | appointmentTime: this.form.appointmentTime, |
| | | remark: this.form.remark, |
| | | state: this.form.state, |
| | | } |
| | | console.log(data); |
| | | if (this.title == '修改安装单') { |
| | |
| | | editModal(item) { |
| | | this.title = '修改安装单' |
| | | this.form = item |
| | | this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }] |
| | | console.log(this.form); |
| | | this.AZModal = true |
| | | this.id = item.id |
| | | }, |
| | |
| | | that.getList() |
| | | that.deleteModal = false |
| | | }) |
| | | |
| | | |
| | | } |
| | | }, |
| | | |
| | | |
| | | watch: { |
| | | 'form.erectoId': { |
| | | handler(newVal, oldVal) { |
| | | if(this.form.state<2){ |
| | | if(newVal&&newVal==-1){ |
| | | this.form.state=0 |
| | | }else{ |
| | | this.form.state=1 |
| | | } |
| | | } |
| | | |
| | | }, |
| | | deep: true, |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | <style lang="scss" scoped> |