Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
d923c8f1
Commit
d923c8f1
authored
Mar 16, 2022
by
季圣华
Browse files
给商品excel导入增加校验:校验条码是否是正整数
parent
3cfa2908
Changes
3
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
d923c8f1
...
@@ -296,6 +296,9 @@ public class ExceptionConstants {
...
@@ -296,6 +296,9 @@ public class ExceptionConstants {
//商品-单位匹配不上
//商品-单位匹配不上
public
static
final
int
MATERIAL_UNIT_MATE_CODE
=
8000006
;
public
static
final
int
MATERIAL_UNIT_MATE_CODE
=
8000006
;
public
static
final
String
MATERIAL_UNIT_MATE_MSG
=
"抱歉,商品条码:%s的单位匹配不上,请完善计量单位信息!"
;
public
static
final
String
MATERIAL_UNIT_MATE_MSG
=
"抱歉,商品条码:%s的单位匹配不上,请完善计量单位信息!"
;
//商品条码不是正整数
public
static
final
int
MATERIAL_BARCODE_NOT_INTEGER_CODE
=
8000007
;
public
static
final
String
MATERIAL_BARCODE_NOT_INTEGER_MSG
=
"商品条码:%s不是正整数"
;
/**
/**
* 单据信息
* 单据信息
* type = 85
* type = 85
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
d923c8f1
...
@@ -496,6 +496,16 @@ public class MaterialService {
...
@@ -496,6 +496,16 @@ public class MaterialService {
String
wholesaleDecimal
=
ExcelUtils
.
getContent
(
src
,
i
,
13
);
//销售价
String
wholesaleDecimal
=
ExcelUtils
.
getContent
(
src
,
i
,
13
);
//销售价
String
lowDecimal
=
ExcelUtils
.
getContent
(
src
,
i
,
14
);
//最低售价
String
lowDecimal
=
ExcelUtils
.
getContent
(
src
,
i
,
14
);
//最低售价
String
enabled
=
ExcelUtils
.
getContent
(
src
,
i
,
15
);
//状态
String
enabled
=
ExcelUtils
.
getContent
(
src
,
i
,
15
);
//状态
//校验基础条码是否是正整数
if
(!
StringUtil
.
isPositiveInteger
(
barCode
))
{
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_BARCODE_NOT_INTEGER_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_BARCODE_NOT_INTEGER_MSG
,
barCode
));
}
//校验副条码是否是正整数
if
(
StringUtil
.
isNotEmpty
(
manyBarCode
)
&&
!
StringUtil
.
isPositiveInteger
(
manyBarCode
))
{
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_BARCODE_NOT_INTEGER_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_BARCODE_NOT_INTEGER_MSG
,
manyBarCode
));
}
//校验条码是否存在
//校验条码是否存在
List
<
MaterialVo4Unit
>
basicMaterialList
=
getMaterialByBarCode
(
barCode
);
List
<
MaterialVo4Unit
>
basicMaterialList
=
getMaterialByBarCode
(
barCode
);
if
(
basicMaterialList
!=
null
&&
basicMaterialList
.
size
()>
0
)
{
if
(
basicMaterialList
!=
null
&&
basicMaterialList
.
size
()>
0
)
{
...
...
jshERP-boot/src/main/java/com/jsh/erp/utils/StringUtil.java
View file @
d923c8f1
...
@@ -275,6 +275,28 @@ public class StringUtil {
...
@@ -275,6 +275,28 @@ public class StringUtil {
}
}
}
}
/**
* 判断对象是否为正整数
* @param value
* @return
*/
public
static
boolean
isPositiveInteger
(
Object
value
)
{
if
(
value
!=
null
)
{
String
str
=
value
.
toString
();
if
(
isNotEmpty
(
str
))
{
if
((
str
.
matches
(
"[0-9]+"
))&&(
Integer
.
parseInt
(
str
)>
0
))
{
return
true
;
}
else
{
return
false
;
}
}
else
{
return
false
;
}
}
else
{
return
false
;
}
}
/**
/**
* sql注入过滤,保障sql的安全执行
* sql注入过滤,保障sql的安全执行
* @param originStr
* @param originStr
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment