mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
长度容错添加
This commit is contained in:
+8
-1
@@ -9,6 +9,7 @@ import com.cf.imes.module.manage.controller.admin.parts.vo.PartsSaveReqVO;
|
||||
import com.cf.imes.module.manage.util.file.FileHelperUtil;
|
||||
import com.cf.imes.module.manage.dal.dataobject.parts.PartsDO;
|
||||
import com.cf.imes.module.manage.dal.mysql.parts.PartsMapper;
|
||||
import com.cf.imes.module.manage.util.number.NumberUtil;
|
||||
import com.cf.imes.module.system.api.organ.OrganApi;
|
||||
import com.cf.imes.module.system.api.permission.PermissionApi;
|
||||
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
||||
@@ -50,6 +51,9 @@ public class PartsServiceImpl implements PartsService {
|
||||
@Resource
|
||||
private PermissionApi permissionApi;
|
||||
|
||||
@Resource
|
||||
private NumberUtil numberUtil;
|
||||
|
||||
private final static String BASE_PARTS_IMPORT_PERMISSION = "base:accessory:import"; // 导入板材
|
||||
private final static String BASE_PARTS_DELETE_PERMISSION = "base:accessory:delete"; // 删除板材信息
|
||||
private final static String BASE_PARTS_CREATE_PERMISSION = "base:accessory:create"; // 创建板材信息
|
||||
@@ -139,7 +143,10 @@ public class PartsServiceImpl implements PartsService {
|
||||
@Override
|
||||
@OrganIgnore
|
||||
public PageResult<PartsDO> getPage(PartsPageReqVO pageReqVO) {
|
||||
pageReqVO.setOrganId(getOrganId(BASE_PARTS_QUERY_PERMISSION, getLoginUser().getId(), pageReqVO.getOrganId()));
|
||||
pageReqVO.setOrganId(getOrganId(BASE_PARTS_QUERY_PERMISSION, getLoginUser().getId(), pageReqVO.getOrganId()))
|
||||
.setLength(numberUtil.compareLength(pageReqVO.getLength()))
|
||||
.setWidth(numberUtil.compareLength(pageReqVO.getWidth()))
|
||||
.setThickness(numberUtil.compareLength(pageReqVO.getThickness()));
|
||||
|
||||
return partsMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.cf.imes.module.manage.util.number;
|
||||
|
||||
/**
|
||||
* 数据处理相关工具类
|
||||
*/
|
||||
public class NumberUtil {
|
||||
|
||||
public Double[] compareLength(Double[] numbers) {
|
||||
if (numbers == null || numbers.length < 2) {
|
||||
return numbers; // 如果数组为空或长度不足2,直接返回原数组
|
||||
}
|
||||
|
||||
Double min = numbers[0];
|
||||
Double max = numbers[1];
|
||||
|
||||
// 检查前值和后值是否都为null或小于等于0
|
||||
if ((min == null || min <= 0) && (max == null || max <= 0)) {
|
||||
return new Double[]{null, null}; // 忽略该字段
|
||||
}
|
||||
|
||||
// 只输入前值,不输入后值
|
||||
if (max == null || max <= 0) {
|
||||
return new Double[]{min, null};
|
||||
}
|
||||
|
||||
// 不输入前值,只输入后值
|
||||
if (min == null || min <= 0) {
|
||||
return new Double[]{null, max};
|
||||
}
|
||||
|
||||
// 前值和后值都输入,且前值大于后值,则前值和后值交换
|
||||
if (min > max) {
|
||||
return new Double[]{max, min};
|
||||
}
|
||||
|
||||
return new Double[]{min, max};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user