From 51a5cc65c7f899b7156effb81d73ab69ae245492 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 16 Aug 2021 10:30:15 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=90=8D=E5=8D=95=E8=AF=8D=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/utils/poi/ExcelUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index dc28480a3..b63fad3cd 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -195,11 +195,11 @@ public class ExcelUtil Map pictures; if (isXSSFWorkbook) { - pictures = getSheetPictrues07((XSSFSheet) sheet, (XSSFWorkbook) wb); + pictures = getSheetPictures07((XSSFSheet) sheet, (XSSFWorkbook) wb); } else { - pictures = getSheetPictrues03((HSSFSheet) sheet, (HSSFWorkbook) wb); + pictures = getSheetPictures03((HSSFSheet) sheet, (HSSFWorkbook) wb); } // 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1 int rows = sheet.getLastRowNum(); @@ -1196,7 +1196,7 @@ public class ExcelUtil * @param workbook 工作簿对象 * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData */ - public static Map getSheetPictrues03(HSSFSheet sheet, HSSFWorkbook workbook) + public static Map getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook) { Map sheetIndexPicMap = new HashMap(); List pictures = workbook.getAllPictures(); @@ -1229,7 +1229,7 @@ public class ExcelUtil * @param workbook 工作簿对象 * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData */ - public static Map getSheetPictrues07(XSSFSheet sheet, XSSFWorkbook workbook) + public static Map getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) { Map sheetIndexPicMap = new HashMap(); for (POIXMLDocumentPart dr : sheet.getRelations()) From 2796a96872ac48fd487bc7b137cc58712c8f5b36 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 16 Aug 2021 15:13:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DemoOperateController.java | 6 +- .../error/{business.html => service.html} | 2 +- .../common/exception/BusinessException.java | 30 ---------- .../common/exception/GlobalException.java | 58 +++++++++++++++++++ .../common/exception/ServiceException.java | 57 ++++++++++++++++++ .../com/ruoyi/common/utils/poi/ExcelUtil.java | 4 +- .../web/exception/GlobalExceptionHandler.java | 50 ++++++++-------- .../service/impl/GenTableServiceImpl.java | 18 +++--- .../service/impl/SysConfigServiceImpl.java | 4 +- .../service/impl/SysDeptServiceImpl.java | 4 +- .../service/impl/SysDictTypeServiceImpl.java | 4 +- .../service/impl/SysPostServiceImpl.java | 6 +- .../service/impl/SysRoleServiceImpl.java | 6 +- .../service/impl/SysUserServiceImpl.java | 8 +-- 14 files changed, 169 insertions(+), 88 deletions(-) rename ruoyi-admin/src/main/resources/templates/error/{business.html => service.html} (94%) delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/exception/BusinessException.java create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java index c7544a325..95412d84f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java @@ -18,7 +18,7 @@ import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.web.controller.demo.domain.CustomerModel; @@ -265,7 +265,7 @@ public class DemoOperateController extends BaseController { if (StringUtils.isNull(userList) || userList.size() == 0) { - throw new BusinessException("导入用户数据不能为空!"); + throw new ServiceException("导入用户数据不能为空!"); } int successNum = 0; int failureNum = 0; @@ -315,7 +315,7 @@ public class DemoOperateController extends BaseController if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); - throw new BusinessException(failureMsg.toString()); + throw new ServiceException(failureMsg.toString()); } else { diff --git a/ruoyi-admin/src/main/resources/templates/error/business.html b/ruoyi-admin/src/main/resources/templates/error/service.html similarity index 94% rename from ruoyi-admin/src/main/resources/templates/error/business.html rename to ruoyi-admin/src/main/resources/templates/error/service.html index 541fd5f21..b64341d3f 100644 --- a/ruoyi-admin/src/main/resources/templates/error/business.html +++ b/ruoyi-admin/src/main/resources/templates/error/service.html @@ -3,7 +3,7 @@ - RuoYi - 403 + RuoYi - 500 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/BusinessException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/BusinessException.java deleted file mode 100644 index d490675e7..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/BusinessException.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ruoyi.common.exception; - -/** - * 业务异常 - * - * @author ruoyi - */ -public class BusinessException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - protected final String message; - - public BusinessException(String message) - { - this.message = message; - } - - public BusinessException(String message, Throwable e) - { - super(message, e); - this.message = message; - } - - @Override - public String getMessage() - { - return message; - } -} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java new file mode 100644 index 000000000..318b9aecc --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java @@ -0,0 +1,58 @@ +package com.ruoyi.common.exception; + +/** + * 全局异常 + * + * @author ruoyi + */ +public class GlobalException extends RuntimeException +{ + + private static final long serialVersionUID = 1L; + + /** + * 错误提示 + */ + private String message; + + /** + * 错误明细,内部调试错误 + * + * 和 {@link CommonResult#getDetailMessage()} 一致的设计 + */ + private String detailMessage; + + /** + * 空构造方法,避免反序列化问题 + */ + public GlobalException() + { + } + + public GlobalException(String message) + { + this.message = message; + } + + public String getDetailMessage() + { + return detailMessage; + } + + public GlobalException setDetailMessage(String detailMessage) + { + this.detailMessage = detailMessage; + return this; + } + + public String getMessage() + { + return message; + } + + public GlobalException setMessage(String message) + { + this.message = message; + return this; + } +} \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java new file mode 100644 index 000000000..bd2592212 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java @@ -0,0 +1,57 @@ +package com.ruoyi.common.exception; + +/** + * 业务异常 + * + * @author ruoyi + */ +public final class ServiceException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** + * 错误提示 + */ + private String message; + + /** + * 错误明细,内部调试错误 + * + * 和 {@link CommonResult#getDetailMessage()} 一致的设计 + */ + private String detailMessage; + + /** + * 空构造方法,避免反序列化问题 + */ + public ServiceException() + { + } + + public ServiceException(String message) + { + this.message = message; + } + + public String getDetailMessage() + { + return detailMessage; + } + + public ServiceException setDetailMessage(String detailMessage) + { + this.detailMessage = detailMessage; + return this; + } + + public String getMessage() + { + return message; + } + + public ServiceException setMessage(String message) + { + this.message = message; + return this; + } +} \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index b63fad3cd..4862a4bc2 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -66,7 +66,7 @@ import com.ruoyi.common.annotation.Excels; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.UtilException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.StringUtils; @@ -450,7 +450,7 @@ public class ExcelUtil catch (Exception e) { log.error("导出Excel异常{}", e.getMessage()); - throw new BusinessException("导出Excel失败,请联系网站管理员!"); + throw new UtilException("导出Excel失败,请联系网站管理员!"); } finally { diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java index d9812d8a4..e31590690 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java @@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.servlet.ModelAndView; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.exception.DemoModeException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.security.PermissionUtils; @@ -26,63 +26,62 @@ public class GlobalExceptionHandler private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class); /** - * 权限校验失败 如果请求为ajax返回json,普通请求跳转页面 + * 权限校验异常(ajax请求返回json,redirect请求跳转页面) */ @ExceptionHandler(AuthorizationException.class) - public Object handleAuthorizationException(HttpServletRequest request, AuthorizationException e) + public Object handleAuthorizationException(AuthorizationException e, HttpServletRequest request) { - log.error(e.getMessage(), e); + String requestURI = request.getRequestURI(); + log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage()); if (ServletUtils.isAjaxRequest(request)) { return AjaxResult.error(PermissionUtils.getMsg(e.getMessage())); } else { - ModelAndView modelAndView = new ModelAndView(); - modelAndView.setViewName("error/unauth"); - return modelAndView; + return new ModelAndView("error/unauth"); } } /** * 请求方式不支持 */ - @ExceptionHandler({ HttpRequestMethodNotSupportedException.class }) - public AjaxResult handleException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, + HttpServletRequest request) { String requestURI = request.getRequestURI(); - String msg = String.format("访问的URL[%s]不支持%s请求", requestURI, e.getMethod()); - log.error(msg, e); - return AjaxResult.error(msg); + log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod()); + return AjaxResult.error(e.getMessage()); } /** * 拦截未知的运行时异常 */ @ExceptionHandler(RuntimeException.class) - public AjaxResult notFount(RuntimeException e, HttpServletRequest request) + public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); - String msg = String.format("访问的URL[%s]发生异常%s", requestURI, e.getMessage()); - log.error(msg, e); - return AjaxResult.error(msg); + log.error("请求地址'{}',发生未知异常.", requestURI, e); + return AjaxResult.error(e.getMessage()); } /** * 系统异常 */ @ExceptionHandler(Exception.class) - public AjaxResult handleException(Exception e) + public AjaxResult handleException(Exception e, HttpServletRequest request) { - log.error(e.getMessage(), e); - return AjaxResult.error("服务器错误,请联系管理员"); + String requestURI = request.getRequestURI(); + log.error("请求地址'{}',发生系统异常.", requestURI, e); + return AjaxResult.error(e.getMessage()); } /** * 业务异常 */ - @ExceptionHandler(BusinessException.class) - public Object businessException(HttpServletRequest request, BusinessException e) + @ExceptionHandler(ServiceException.class) + public Object handleServiceException(ServiceException e, HttpServletRequest request) { log.error(e.getMessage(), e); if (ServletUtils.isAjaxRequest(request)) @@ -91,10 +90,7 @@ public class GlobalExceptionHandler } else { - ModelAndView modelAndView = new ModelAndView(); - modelAndView.addObject("errorMessage", e.getMessage()); - modelAndView.setViewName("error/business"); - return modelAndView; + return new ModelAndView("error/service", "errorMessage", e.getMessage()); } } @@ -102,7 +98,7 @@ public class GlobalExceptionHandler * 自定义验证异常 */ @ExceptionHandler(BindException.class) - public AjaxResult validatedBindException(BindException e) + public AjaxResult handleBindException(BindException e) { log.error(e.getMessage(), e); String message = e.getAllErrors().get(0).getDefaultMessage(); @@ -113,7 +109,7 @@ public class GlobalExceptionHandler * 演示模式异常 */ @ExceptionHandler(DemoModeException.class) - public AjaxResult demoModeException(DemoModeException e) + public AjaxResult handleDemoModeException(DemoModeException e) { return AjaxResult.error("演示模式,不允许操作"); } diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/impl/GenTableServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/impl/GenTableServiceImpl.java index b809d6a37..c4818965c 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/impl/GenTableServiceImpl.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/impl/GenTableServiceImpl.java @@ -26,7 +26,7 @@ import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.GenConstants; import com.ruoyi.common.core.text.CharsetKit; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.generator.domain.GenTable; import com.ruoyi.generator.domain.GenTableColumn; @@ -181,7 +181,7 @@ public class GenTableServiceImpl implements IGenTableService } catch (Exception e) { - throw new BusinessException("导入失败:" + e.getMessage()); + throw new ServiceException("导入失败:" + e.getMessage()); } } @@ -270,7 +270,7 @@ public class GenTableServiceImpl implements IGenTableService } catch (IOException e) { - throw new BusinessException("渲染模板失败,表名:" + table.getTableName()); + throw new ServiceException("渲染模板失败,表名:" + table.getTableName()); } } } @@ -292,7 +292,7 @@ public class GenTableServiceImpl implements IGenTableService List dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); if (StringUtils.isEmpty(dbTableColumns)) { - throw new BusinessException("同步数据失败,原表结构不存在"); + throw new ServiceException("同步数据失败,原表结构不存在"); } List dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); @@ -385,26 +385,26 @@ public class GenTableServiceImpl implements IGenTableService JSONObject paramsObj = JSONObject.parseObject(options); if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) { - throw new BusinessException("树编码字段不能为空"); + throw new ServiceException("树编码字段不能为空"); } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) { - throw new BusinessException("树父编码字段不能为空"); + throw new ServiceException("树父编码字段不能为空"); } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) { - throw new BusinessException("树名称字段不能为空"); + throw new ServiceException("树名称字段不能为空"); } } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) { if (StringUtils.isEmpty(genTable.getSubTableName())) { - throw new BusinessException("关联子表的表名不能为空"); + throw new ServiceException("关联子表的表名不能为空"); } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) { - throw new BusinessException("子表关联的外键名不能为空"); + throw new ServiceException("子表关联的外键名不能为空"); } } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index 1dc17b768..5a0df39d4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -7,7 +7,7 @@ import org.springframework.stereotype.Service; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.CacheUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.SysConfig; @@ -134,7 +134,7 @@ public class SysConfigServiceImpl implements ISysConfigService SysConfig config = selectConfigById(configId); if (StringUtils.equals(UserConstants.YES, config.getConfigType())) { - throw new BusinessException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); + throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); } configMapper.deleteConfigById(configId); CacheUtils.remove(getCacheName(), getCacheKey(config.getConfigKey())); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 584b5aea7..4047f61f7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -13,7 +13,7 @@ import com.ruoyi.common.core.domain.Ztree; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.service.ISysDeptService; @@ -201,7 +201,7 @@ public class SysDeptServiceImpl implements ISysDeptService // 如果父节点不为"正常"状态,则不允许新增子节点 if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { - throw new BusinessException("部门停用,不允许新增"); + throw new ServiceException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); return deptMapper.insertDept(dept); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java index a04f56405..a4a1e36c2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java @@ -11,7 +11,7 @@ import com.ruoyi.common.core.domain.Ztree; import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.domain.entity.SysDictType; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.mapper.SysDictDataMapper; @@ -126,7 +126,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService SysDictType dictType = selectDictTypeById(dictId); if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) { - throw new BusinessException(String.format("%1$s已分配,不能删除", dictType.getDictName())); + throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName())); } dictTypeMapper.deleteDictTypeById(dictId); DictUtils.removeDictCache(dictType.getDictType()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index 885b89240..a68e9ce4c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.mapper.SysPostMapper; @@ -93,7 +93,7 @@ public class SysPostServiceImpl implements ISysPostService * @throws Exception */ @Override - public int deletePostByIds(String ids) throws BusinessException + public int deletePostByIds(String ids) { Long[] postIds = Convert.toLongArray(ids); for (Long postId : postIds) @@ -101,7 +101,7 @@ public class SysPostServiceImpl implements ISysPostService SysPost post = selectPostById(postId); if (countUserPostById(postId) > 0) { - throw new BusinessException(String.format("%1$s已分配,不能删除", post.getPostName())); + throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName())); } } return postMapper.deletePostByIds(postIds); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 0714edc11..dadd2b866 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -12,7 +12,7 @@ import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.system.domain.SysRoleDept; @@ -160,7 +160,7 @@ public class SysRoleServiceImpl implements ISysRoleService SysRole role = selectRoleById(roleId); if (countUserRoleByRoleId(roleId) > 0) { - throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName())); + throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); } } // 删除角色与菜单关联 @@ -314,7 +314,7 @@ public class SysRoleServiceImpl implements ISysRoleService { if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { - throw new BusinessException("不允许操作超级管理员角色"); + throw new ServiceException("不允许操作超级管理员角色"); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 884b7d0f5..110829a63 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -12,7 +12,7 @@ import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.security.Md5Utils; import com.ruoyi.system.domain.SysPost; @@ -399,7 +399,7 @@ public class SysUserServiceImpl implements ISysUserService { if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { - throw new BusinessException("不允许操作超级管理员用户"); + throw new ServiceException("不允许操作超级管理员用户"); } } @@ -460,7 +460,7 @@ public class SysUserServiceImpl implements ISysUserService { if (StringUtils.isNull(userList) || userList.size() == 0) { - throw new BusinessException("导入用户数据不能为空!"); + throw new ServiceException("导入用户数据不能为空!"); } int successNum = 0; int failureNum = 0; @@ -505,7 +505,7 @@ public class SysUserServiceImpl implements ISysUserService if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); - throw new BusinessException(failureMsg.toString()); + throw new ServiceException(failureMsg.toString()); } else { From aac0ba1791646b055a4229ae23978c977023db71 Mon Sep 17 00:00:00 2001 From: Bo Date: Mon, 16 Aug 2021 15:51:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?Excel=E5=AF=BC=E5=85=A5=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=BF=AB=E9=80=92=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E4=BA=BA=E5=91=98=EF=BC=8C=E9=80=81=E8=B4=A7=E5=AE=A2=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/bps/domain/ExpressInfo.java | 28 ++++++++++++++++++- .../impl/ExpImportQueryServiceImpl.java | 2 ++ .../mapper/bps/ExpressInfoMapper.xml | 16 +++++++++-- .../templates/bps/expImportQuery/detail.html | 8 ++++++ 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java index 6d31fc294..bfaeb80a4 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java +++ b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java @@ -22,11 +22,18 @@ public class ExpressInfo extends BaseEntity @Excel(name = "消息",type= Excel.Type.EXPORT) private String message; - /** 出货单号 */ @Excel(name = "出货单号") private String deliveryNum; + /** 送货客户*/ + @Excel(name = "送货客户") + private String customer; + + /** 客服人员*/ + @Excel(name = "客服人员") + private String csName; + /** 快递单号 */ @Excel(name = "快递单号") private String nu; @@ -97,6 +104,7 @@ public class ExpressInfo extends BaseEntity /** 查询类型*/ private String queryType; + public static long getSerialVersionUID() { return serialVersionUID; } @@ -269,6 +277,22 @@ public class ExpressInfo extends BaseEntity this.queryType = queryType; } + public String getCsName() { + return csName; + } + + public void setCsName(String csName) { + this.csName = csName; + } + + public String getCustomer() { + return customer; + } + + public void setCustomer(String customer) { + this.customer = customer; + } + @Override public String toString() { return "ExpressInfo{" + @@ -293,6 +317,8 @@ public class ExpressInfo extends BaseEntity ", queryUserName='" + queryUserName + '\'' + ", queryId='" + queryId + '\'' + ", queryType='" + queryType + '\'' + + ", csName='" + csName + '\'' + + ", customer='" + customer + '\'' + '}'; } } diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpImportQueryServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpImportQueryServiceImpl.java index 03d794858..1db0f00aa 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpImportQueryServiceImpl.java +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpImportQueryServiceImpl.java @@ -140,6 +140,8 @@ public class ExpImportQueryServiceImpl implements IExpImportQueryService ei.setQueryUserName(ShiroUtils.getSysUser().getUserName()); ei.setQueryType("excel"); ei.setQueryTime(queryTime); + ei.setCustomer(expressInfo.getCustomer()); //送货客户 + ei.setCsName(expressInfo.getCsName()); //客服人员 //expressInfoService.insertExpressInfo(ei); expressInfoListForInsert.add(ei); /* for(int i=1;i<1001;i++){ //测试批量插入效率用时打开Mark,产生5万条数据。 diff --git a/box-bps/src/main/resources/mapper/bps/ExpressInfoMapper.xml b/box-bps/src/main/resources/mapper/bps/ExpressInfoMapper.xml index 5d9416346..d9df789f5 100644 --- a/box-bps/src/main/resources/mapper/bps/ExpressInfoMapper.xml +++ b/box-bps/src/main/resources/mapper/bps/ExpressInfoMapper.xml @@ -26,12 +26,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + select sid, message, nu, deliveryNum, ischeck, com, status, `data`, `state`, `condition`, routeInfo, returnCode, `result`, phone, - collectTime, singedTime, lastUpdateTime, queryTime, queryUserName, queryId, queryType + collectTime, singedTime, lastUpdateTime, queryTime, queryUserName, queryId, queryType, csName, customer from expressInfo @@ -43,6 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and phone = #{phone} and queryId = #{queryId} and deliveryNum = #{deliveryNum} + and csName = #{csName} + and customer = #{customer} @@ -74,6 +78,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" queryId, queryType, deliveryNum, + csName, + customer, #{message}, @@ -96,6 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{queryId}, #{queryType}, #{deliveryNum}, + #{csName}, + #{customer}, @@ -121,6 +129,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" queryId = #{queryId}, queryType = #{queryType}, deliveryNum = #{deliveryNum}, + csName = #{csName}, + customer = #{customer}, where message = #{message} @@ -138,12 +148,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into expressInfo(message, nu, deliveryNum, ischeck, com, status, `data`, `state`, `condition`, routeInfo, returnCode, `result`, phone, - collectTime, singedTime, lastUpdateTime, queryTime, queryUserName, queryId, queryType) values + collectTime, singedTime, lastUpdateTime, queryTime, queryUserName, queryId, queryType, csName, customer) values ( #{expressInfo.message}, #{expressInfo.nu}, #{expressInfo.deliveryNum}, #{expressInfo.ischeck}, #{expressInfo.com}, #{expressInfo.status}, #{expressInfo.data}, #{expressInfo.state}, #{expressInfo.condition}, #{expressInfo.routeInfo}, #{expressInfo.returnCode}, #{expressInfo.result}, #{expressInfo.phone}, #{expressInfo.collectTime}, #{expressInfo.singedTime}, #{expressInfo.lastUpdateTime}, - #{expressInfo.queryTime}, #{expressInfo.queryUserName}, #{expressInfo.queryId}, #{expressInfo.queryType} + #{expressInfo.queryTime}, #{expressInfo.queryUserName}, #{expressInfo.queryId}, #{expressInfo.queryType}, #{expressInfo.csName}, #{expressInfo.customer} ) diff --git a/box-bps/src/main/resources/templates/bps/expImportQuery/detail.html b/box-bps/src/main/resources/templates/bps/expImportQuery/detail.html index b88440c8d..a851c1185 100644 --- a/box-bps/src/main/resources/templates/bps/expImportQuery/detail.html +++ b/box-bps/src/main/resources/templates/bps/expImportQuery/detail.html @@ -55,6 +55,14 @@ field: 'deliveryNum', title: '出货单号' }, + { + field: 'customer', + title: '送货客户' + }, + { + field: 'csName', + title: '客服人员' + }, { field: 'nu', title: '快递单号' From 29157e8387819ab4ef13c0b1e250e9cf41c35e3a Mon Sep 17 00:00:00 2001 From: Bo Date: Mon, 16 Aug 2021 18:05:59 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BF=AB=E9=80=92?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=9F=A5=E8=AF=A2=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bps/expsubspushresp/expsubspushresp.html | 2 ++ .../resources/templates/bps/subscribe/subscribe.html | 2 ++ .../java/com/ruoyi/common/utils/http/HttpUtils.java | 11 +++++------ .../ruoyi/system/service/impl/SysDeptServiceImpl.java | 2 -- .../ruoyi/system/service/impl/SysUserServiceImpl.java | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html b/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html index 0b8c2dc29..6151f813b 100644 --- a/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html +++ b/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html @@ -84,6 +84,8 @@ removeUrl: prefix + "/remove", exportUrl: prefix + "/export", detailUrl: prefix + "/detail/{id}", + sortName: "lastresponsetime", + sortOrder: "desc", modalName: "快递订阅推送信息", columns: [{ checkbox: true diff --git a/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html b/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html index 6c20e4111..58b59ffc1 100644 --- a/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html +++ b/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html @@ -90,6 +90,8 @@ updateUrl: prefix + "/edit/{id}", removeUrl: prefix + "/remove", exportUrl: prefix + "/export", + sortName: "subscribetime", + sortOrder: "desc", modalName: "快递订阅", columns: [{ checkbox: true diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java index dcaa8c5a2..51fe3b122 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java @@ -292,13 +292,13 @@ public class HttpUtils } log.info("recv - {}", result); } catch (ConnectException e) { - log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); + log.error("调用HttpUtils.sendXmlPost ConnectException, url=" + url + ",param=" + param, e); } catch (SocketTimeoutException e) { - log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); + log.error("调用HttpUtils.sendXmlPost SocketTimeoutException, url=" + url + ",param=" + param, e); } catch (IOException e) { - log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); + log.error("调用HttpUtils.sendXmlPost IOException, url=" + url + ",param=" + param, e); } catch (Exception e) { - log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); + log.error("调用HttpsUtil.sendXmlPost Exception, url=" + url + ",param=" + param, e); } finally { try { if (out != null) { @@ -334,7 +334,7 @@ public class HttpUtils result=restTemplate.postForEntity(url,params,String.class); statusCode=result.getStatusCode().value(); }catch (RestClientException e){ - System.out.println("POST Request uri: "+url+", params:"+params+" error:"+e.getMessage()); + log.error("POST Request uri: "+url+", params:"+params+" error:"+e.getMessage()); } Map map=new HashMap<>(); map.put("statusCode",String.valueOf(statusCode)); @@ -343,7 +343,6 @@ public class HttpUtils } else{ map.put("result",String.valueOf(statusCode)); } - return map; } } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 98165eece..85f1c90dd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -8,10 +8,8 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.Ztree; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysRole; -import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.http.HttpUtils; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index ba789ef27..3c6a06280 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -9,12 +9,14 @@ import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.http.HttpUtils; import com.ruoyi.common.utils.security.Md5Utils; -import com.ruoyi.system.domain.*; +import com.ruoyi.system.domain.EcologyUser; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.domain.SysUserPost; +import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysUserService; @@ -26,7 +28,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map;