From 51532b2c67dbaa4a0aa075eeac51dcc95b87775c Mon Sep 17 00:00:00 2001 From: liuzhaotian Date: Mon, 17 Mar 2025 11:21:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E-es=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E5=AD=97=E6=AE=B5=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E4=B9=9F?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/enums/ErrorCodeConstants.java | 1 + .../executor/util/elasticsearch/EsUtils.java | 30 +++++++++++++++---- .../admin/plate/RemainPlateController.java | 2 +- .../service/auth/AdminAuthServiceImpl.java | 2 +- .../system/service/dept/DeptService.java | 7 +++++ .../system/service/dept/DeptServiceImpl.java | 19 ++++++++++++ 6 files changed, 54 insertions(+), 7 deletions(-) diff --git a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java index 18ff2044c..356a423ee 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java +++ b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java @@ -28,6 +28,7 @@ public class ErrorCodeConstants { // public static final ErrorCode ORDER_PLAN_ERROR = new ErrorCode(1_001_109_001, "选中删除对象有已开料板件,请联系管理员修改开料状态后再删除!"); public static final ErrorCode PLATE_IS_PLAN = new ErrorCode(1_001_109_002, "删除对象中有已排单板件,请将该对象从排单中移除后再选择删除!"); public static final ErrorCode ORDER_ERROR = new ErrorCode(1_001_109_003, "当前生产单柜体,房间已全部删除!"); + public static final ErrorCode ORDER_DATA_ERROR = new ErrorCode(1_001_109_004, "生产单/排单的数据已无法使用,请删除重新"); // ========== 生产单 TODO 补充编号 ========== public static final ErrorCode MODULE_NOT_EXISTS = new ErrorCode(1_001_110_000, "模块不存在"); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/elasticsearch/EsUtils.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/elasticsearch/EsUtils.java index 8b4b1ab8f..33867cee2 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/elasticsearch/EsUtils.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/elasticsearch/EsUtils.java @@ -12,6 +12,7 @@ import co.elastic.clients.elasticsearch.core.SearchRequest; import co.elastic.clients.elasticsearch.core.SearchResponse; import co.elastic.clients.elasticsearch.core.search.Hit; import co.elastic.clients.elasticsearch.indices.RefreshRequest; +import co.elastic.clients.json.JsonpMappingException; import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.es.core.dal.ESDocument; import com.cf.imes.framework.es.core.service.ESDocumentService; @@ -25,6 +26,7 @@ import java.util.List; import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.DATA_DATA_ERROR; import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.ES_DATA_ERROR; +import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_DATA_ERROR; /** * @author ES 工具类 @@ -67,7 +69,10 @@ public class EsUtils { return hits.stream().map(Hit::source).toList(); } return new ArrayList<>(); - } catch (IOException | ElasticsearchException e) { + }catch (JsonpMappingException e){ + log.error(e.getMessage()); + throw new ServiceException(ORDER_DATA_ERROR); + }catch (IOException | ElasticsearchException e) { log.error(e.getMessage()); throw new ServiceException(DATA_DATA_ERROR); } @@ -89,6 +94,9 @@ public class EsUtils { return hits.stream().map(Hit::source).toList(); } return new ArrayList<>(); + }catch (JsonpMappingException e){ + log.error(e.getMessage()); + throw new ServiceException(ORDER_DATA_ERROR); } catch (IOException | ElasticsearchException e) { log.error(e.getMessage()); throw new ServiceException(DATA_DATA_ERROR); @@ -116,7 +124,10 @@ public class EsUtils { return hits.stream().map(Hit::source).toList(); } return new ArrayList<>(); - } catch (IOException | ElasticsearchException e) { + }catch (JsonpMappingException e){ + log.error(e.getMessage()); + throw new ServiceException(ORDER_DATA_ERROR); + }catch (IOException | ElasticsearchException e) { log.error(e.getMessage()); throw new ServiceException(DATA_DATA_ERROR); } @@ -138,7 +149,10 @@ public class EsUtils { return hits.stream().map(Hit::source).toList(); } return new ArrayList<>(); - } catch (IOException | ElasticsearchException e) { + }catch (JsonpMappingException e){ + log.error(e.getMessage()); + throw new ServiceException(ORDER_DATA_ERROR); + }catch (IOException | ElasticsearchException e) { log.error(e.getMessage()); throw new ServiceException(DATA_DATA_ERROR); } @@ -165,7 +179,10 @@ public class EsUtils { return hits.stream().map(Hit::source).toList(); } return new ArrayList<>(); - } catch (IOException | ElasticsearchException e) { + }catch (JsonpMappingException e){ + log.error(e.getMessage()); + throw new ServiceException(ORDER_DATA_ERROR); + }catch (IOException | ElasticsearchException e) { log.error(e.getMessage()); throw new ServiceException(DATA_DATA_ERROR); } @@ -192,7 +209,10 @@ public class EsUtils { return hits.stream().map(Hit::source).toList(); } return new ArrayList<>(); - } catch (IOException | ElasticsearchException e) { + }catch (JsonpMappingException e){ + log.error(e.getMessage()); + throw new ServiceException(ORDER_DATA_ERROR); + }catch (IOException | ElasticsearchException e) { log.error(e.getMessage()); throw new ServiceException(DATA_DATA_ERROR); } diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/RemainPlateController.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/RemainPlateController.java index 64ad34ba2..07d167d75 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/RemainPlateController.java +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/RemainPlateController.java @@ -99,7 +99,7 @@ public class RemainPlateController { @GetMapping("/page") @Operation(summary = "获得生产单余料板表分页") - @PreAuthorize("@ss.hasAnyPermissions('manage:remain-plate:query','placeorder:optimize','placeorder:remain-insert')") + @PreAuthorize("@ss.hasAnyPermissions('manage:remain-plate:query','placeorder:optimize','placeorder:remain-insert','production:manager-list:calculate')") public CommonResult> getRemainPlatePage(@Valid RemainPlatePageReqVO pageReqVO) { PageResult pageResult = remainPlateService.getRemainPlatePage(pageReqVO); return success(BeanUtils.toBean(pageResult, RemainPlateRespVO.class)); diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java index eb7a12c9b..e9ebe956b 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java @@ -111,7 +111,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { // 校验机构有效性 organService.validOrgan(user.getOrganId()); // 校验部门有效性 - deptService.validDept(user.getDeptId()); + deptService.validUserLoginDept(user.getDeptId()); // 校验密码 if (!userService.isPasswordMatch(password, user.getPassword())) { createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS); diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/dept/DeptService.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/dept/DeptService.java index 0ef995d63..391d5816b 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/dept/DeptService.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/dept/DeptService.java @@ -106,6 +106,13 @@ public interface DeptService { */ void validDept(Long deptId); + /** + * 用户登陆时部门校验 + * + * @param deptId + */ + void validUserLoginDept(Long deptId); + /** * 移除没有归属(上级)的部门 * diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/dept/DeptServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/dept/DeptServiceImpl.java index 65dacff7f..c4255c43b 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/dept/DeptServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/dept/DeptServiceImpl.java @@ -309,6 +309,25 @@ public class DeptServiceImpl implements DeptService { validParentDept(deptDO); } + + // 用户登陆时部门校验,部门不存在时也可以进行登录 + @Override + public void validUserLoginDept(Long deptId){ + DeptDO deptDO = deptMapper.selectById(deptId); + if (deptDO == null) { + return; + } + if (!CommonStatusEnum.ENABLE.getStatus().equals(deptDO.getStatus())) { + throw ServiceExceptionUtil.exception(ErrorCodeConstants.DEPT_DISABLE, deptDO.getName()); + } + // 递归校验上级部门 + validParentDept(deptDO); + } + + + + + /** * 递归校验上级部门 *