系统配置-封边条对应配置数据正确性校验

This commit is contained in:
liuzhaotian
2025-03-14 11:18:29 +08:00
parent f9ef90e9ce
commit 1bd78d24f6
2 changed files with 45 additions and 2 deletions
@@ -383,6 +383,10 @@ public class ErrorCodeConstants {
public static final ErrorCode THIS_CONFIG_DATA_ERROR = new ErrorCode(1_002_040_020, "当前系统配置的数据有误,请重新尝试排序");
public static final ErrorCode PROCESS_CONFIG_USED_ALREADY = new ErrorCode(1_002_040_021, "当前加工分线配置在加工方案组中已使用,无法删除");
public static final ErrorCode OPTIMIZATION_CONFIG_USED_ALREADY = new ErrorCode(1_002_040_022, "当前数据处理配置在加工方案组中已使用,无法删除");
public static final ErrorCode SEALEDGE_CONFIG_NOT_EXISTS = new ErrorCode(1_002_040_023, "第 {} 条配置中,有字段值为空,请添加数据");
public static final ErrorCode SEALEDGE_CONFIG_MIN_VALUE_DATA_ERROR = new ErrorCode(1_002_040_024, "第 {} 条配置中,宽最小值大于宽取值,请修改数据");
public static final ErrorCode SEALEDGE_CONFIG_MAX_VALUE_DATA_ERROR = new ErrorCode(1_002_040_025, "第 {} 条配置中,宽最大值小于宽取值,请修改数据");
public static final ErrorCode SEALEDGE_CONFIG_DATA_ERROR = new ErrorCode(1_002_040_026, "当前封边条配置有误,请重新检查后新增");
@@ -2,7 +2,11 @@ package com.cf.imes.module.system.service.systemconfig.factory.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
@@ -12,6 +16,7 @@ import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigSealedg
import com.cf.imes.module.system.dal.mysql.systemconfig.SystemConfigSealedgeMapper;
import com.cf.imes.module.system.service.systemconfig.factory.service.AbstractSystemConfigServiceHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -19,7 +24,7 @@ import java.time.LocalDateTime;
import java.util.List;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_NOT_EXISTS;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
/**
@@ -49,7 +54,41 @@ public class SealedgeServiceHandler extends AbstractSystemConfigServiceHandler {
@Override
public void checkValid(String setting) {
// todo checkValid
try {
JSONArray jsonArray = JSON.parseArray(setting);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String widthMin = jsonObject.getString("widthMin");
String widthMax = jsonObject.getString("widthMax");
String widthValue = jsonObject.getString("widthValue");
if(StringUtils.isEmpty(widthMin) || StringUtils.isEmpty(widthMax) || StringUtils.isEmpty(widthValue) ){
throw exception(SEALEDGE_CONFIG_NOT_EXISTS,(i+1));
}
if(Integer.parseInt(widthMin) > Integer.parseInt(widthValue) ){
throw exception(SEALEDGE_CONFIG_MIN_VALUE_DATA_ERROR,(i+1));
}
if(Integer.parseInt(widthMax) < Integer.parseInt(widthValue) ){
throw exception(SEALEDGE_CONFIG_MAX_VALUE_DATA_ERROR,(i+1));
}
}
}
catch (ServiceException e){
throw e;
}catch (Exception e){
log.error("封边条配置有误:"+e.getMessage());
throw new ServiceException(SEALEDGE_CONFIG_DATA_ERROR);
}
}