1、新增部门校验问题修复;2、自定义板编号跨单导入问题修复;

This commit is contained in:
gaoqr
2024-12-02 17:44:23 +08:00
parent 73d31dbf8c
commit 0effec4479
7 changed files with 33 additions and 17 deletions
@@ -1,6 +1,7 @@
package com.cf.imes.framework.organ.core.security;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
import com.cf.imes.framework.common.pojo.CommonResult;
@@ -93,14 +94,14 @@ public class OrganSecurityWebFilter extends ApiRequestFilter {
try {
// 校验组织
organFrameworkService.validOrgan(organId);
// 校验部门
organFrameworkService.validDept(deptId);
if (ObjectUtil.isNotNull(deptId)) {
// 校验部门
organFrameworkService.validDept(deptId);
}
} catch (Throwable ex) {
CommonResult<?> result = globalExceptionHandler.allExceptionHandler(request, ex);
// 组织失效返回401踢出系统
if (needUnauthorizedWhenOrgExpired(ex)) {
result.setCode(GlobalErrorCodeConstants.UNAUTHORIZED.getCode());
}
needUnauthorizedWhenOrgExpired(ex, result);
ServletUtils.writeJSON(response, result);
return;
}
@@ -134,15 +135,14 @@ public class OrganSecurityWebFilter extends ApiRequestFilter {
* @param ex
* @return
*/
private boolean needUnauthorizedWhenOrgExpired(Throwable ex) {
private void needUnauthorizedWhenOrgExpired(Throwable ex, CommonResult<?> result) {
if (ex instanceof ServiceException) {
ServiceException serviceException = (ServiceException) ex;
if (Objects.equals(serviceException.getCode(), ErrorCodeConstants.ORGAN_EXPIRE.getCode())
|| Objects.equals(serviceException.getCode(), ErrorCodeConstants.ORGAN_DISABLE.getCode())
|| Objects.equals(serviceException.getCode(), ErrorCodeConstants.ORGAN_NOT_EXISTS.getCode())) {
return true;
result.setCode(GlobalErrorCodeConstants.UNAUTHORIZED.getCode());
}
}
return false;
}
}
@@ -51,6 +51,6 @@ public class OrganFrameworkServiceImpl implements OrganFrameworkService {
@Override
public void validDept(Long id) {
deptApi.validateDept(id);
deptApi.validateDept(id).checkError();
}
}
@@ -3,10 +3,13 @@ package com.cf.imes.module.executor.service.customplateno;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.util.json.JsonUtils;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
import com.cf.imes.module.executor.enums.ErrorCodeConstants;
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
@@ -49,6 +52,9 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
@Resource
private List<CustomPlateNoGenerateRuleService> ruleServices;
@Resource
private OrderMapper orderMapper;
private static final DateTimeFormatter YEAR_FORMATTER = DateTimeFormatter.ofPattern("yyyy");
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
@@ -77,8 +83,14 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
}
// 3、保存生产单序号json、设置生产单所用配置id
orderDO.setCustomPlatenoSeq(JSON.toJSONString(generateConfig.getOrderCustomPlateNoSeqVO()));
orderDO.setCustomPlatenoConfigId(orgCustomPlateNoConfigId);
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
if (ObjectUtil.isNotNull(orderDO)) {
// 已有生产单更新序号
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderId).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
} else {
orderDO.setCustomPlatenoSeq(JSON.toJSONString(orderCustomPlateNoSeqVO));
orderDO.setCustomPlatenoConfigId(orgCustomPlateNoConfigId);
}
// 机构下序号配置同步
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
orgCustomPlateNoSeqRespDTO.setLastOrderNo(orderId);
@@ -38,10 +38,10 @@ public interface DeptApi {
@Parameter(name = "ids", description = "部门编号数组", example = "1,2", required = true)
CommonResult<Boolean> validateDeptList(@RequestParam("ids") Collection<Long> ids);
@GetMapping(PREFIX + "/valid/{deptId}")
@GetMapping(PREFIX + "/legitimacy/{deptId}")
@Operation(summary = "校验部门是否合法")
@Parameter(name = "id", description = "部门编号", example = "1024", required = true)
CommonResult<Boolean> validateDept(@PathVariable("id") Long deptId);
CommonResult<Boolean> validateDept(@PathVariable("deptId") Long deptId);
/**
* 获得指定编号的部门 Map
@@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
@@ -26,5 +27,5 @@ public interface SystemConfigApi {
@GetMapping(PREFIX + "/organ/custom-plateno-config/{id}")
@Operation(summary = "获取组织下自定义版编号配置")
CommonResult<SystemConfigRespDTO> getById(Long id);
CommonResult<SystemConfigRespDTO> getById(@PathVariable("id") Long id);
}
@@ -247,7 +247,7 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
// 查询机构下的现有自定义板编号配置最大版本号
Integer maxCustomPlateNoSystemConfigVersion = systemConfigMapper.selectOrgMaxCustomPlateNoSystemConfigVersion(OrganContextHolder.getOrganId());
// 版本号 + 1
reqVO.setVersion(maxCustomPlateNoSystemConfigVersion + 1);
reqVO.setVersion((ObjectUtil.isNotNull(maxCustomPlateNoSystemConfigVersion) ? maxCustomPlateNoSystemConfigVersion : 0) + 1);
// 自定义板编号每次保存都创建新版本
reqVO.setId(null);
}
@@ -534,8 +534,11 @@ public class AdminUserServiceImpl implements AdminUserService {
AdminUserDO adminUserDO = validateUserExists(id);
// 校验用户名唯一
validateUsernameUnique(id, username, organId);
// 校验部门处于开启状态
deptService.validDept(deptId);
// 组织管理员不归属部门
if (ObjectUtil.isNotNull(deptId)) {
// 校验部门处于开启状态
deptService.validDept(deptId);
}
// 校验岗位处于开启状态
postService.validatePostList(postIds);
return adminUserDO;