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
0d6c24d5
Commit
0d6c24d5
authored
Jun 14, 2019
by
qiankunpingtai
Browse files
添加物品单位和基础单位副单位不一致的判断
parent
5a93cd47
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
0d6c24d5
...
...
@@ -278,6 +278,9 @@ public class ExceptionConstants {
//商品库存不足
public
static
final
int
MATERIAL_STOCK_NOT_ENOUGH_CODE
=
8000004
;
public
static
final
String
MATERIAL_STOCK_NOT_ENOUGH_MSG
=
"商品:%s库存不足"
;
//商品单位不正确
public
static
final
int
MATERIAL_UNIT_NOT_RIGHT_CODE
=
8000005
;
public
static
final
String
MATERIAL_UNIT_NOT_RIGHT_MSG
=
"商品:%s单位不正确,使用单位:%s,基础单位:%s,副单位:%s"
;
/**
* 单据信息
* type = 85
...
...
src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
0d6c24d5
...
...
@@ -513,34 +513,35 @@ public class DepotItemService {
depotItem
.
setHeaderid
(
headerId
);
depotItem
.
setMaterialid
(
tempInsertedJson
.
getLong
(
"MaterialId"
));
depotItem
.
setMunit
(
tempInsertedJson
.
getString
(
"Unit"
));
Material
material
=
materialService
.
getMaterial
(
depotItem
.
getMaterialid
());
if
(!
StringUtil
.
isEmpty
(
tempInsertedJson
.
get
(
"OperNumber"
).
toString
()))
{
depotItem
.
setOpernumber
(
tempInsertedJson
.
getBigDecimal
(
"OperNumber"
));
tr
y
{
String
Unit
=
tempInsertedJson
.
get
(
"Unit"
).
toString
(
);
BigDecimal
oNumber
=
tempInsertedJson
.
getBigDecimal
(
"OperNumber"
);
Long
mId
=
Long
.
parseLong
(
tempInsertedJson
.
get
(
"MaterialId"
).
toString
());
/***
* 为什么调用的方法要先把基础单位去掉,去掉之后后续还能获取到?
* */
//以下进行单位换算
//
String
U
nitName = findUnitName(mId);
//查询计量单位名称
String
unitName
=
materialService
.
findU
nitName
(
mId
);
if
(!
String
Util
.
isEmpty
(
unitName
))
{
String
unit
List
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratioLis
t
=
unit
Name
.
substring
(
unit
Name
.
indexOf
(
"
(
"
));
String
basic
Unit
=
unitList
.
substring
(
0
,
unitList
.
indexOf
(
","
));
//
基本
单位
String
otherUnit
=
unit
List
.
substring
(
unit
List
.
indexOf
(
"
,
"
)
+
1
);
//
副单位
Integer
ratio
=
Integer
.
parseInt
(
ratioList
.
substring
(
ratioList
.
indexOf
(
":"
)
+
1
).
replace
(
")"
,
""
));
//比例
if
(
Unit
.
equals
(
basicUnit
))
{
//如果等于基础单位
depotItem
.
setBasicnumber
(
oNumber
);
//数量一致
}
else
if
(
Unit
.
equals
(
otherUnit
))
{
//
如果等于副单位
depotItem
.
setBasicnumber
(
oNumber
.
multiply
(
new
BigDecimal
(
ratio
))
);
//数量乘以比例
}
}
else
{
depotItem
.
setBasicnumber
(
oNumber
);
//其他情况
S
tr
ing
Unit
=
tempInsertedJson
.
get
(
"Unit"
).
toString
();
BigDecimal
oNumber
=
tempInsertedJson
.
get
BigDecimal
(
"OperNumber"
);
Long
mId
=
Long
.
parseLong
(
tempInsertedJson
.
get
(
"MaterialId"
).
toString
()
);
/***
* 为什么调用的方法要先把基础单位去掉,去掉之后后续还能获取到?
* */
//以下进行单位换算
//
String UnitName = findUnitName(mId); //查询计量单位名称
String
u
nitName
=
materialService
.
findUnitName
(
mId
);
if
(!
String
Util
.
isEmpty
(
u
nitName
))
{
String
unitList
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratio
List
=
unitName
.
substring
(
unitName
.
indexOf
(
"("
));
String
basicUni
t
=
unit
List
.
substring
(
0
,
unit
List
.
indexOf
(
"
,
"
));
//基本单位
String
other
Unit
=
unitList
.
substring
(
unitList
.
indexOf
(
","
)
+
1
);
//
副
单位
Integer
ratio
=
Integer
.
parseInt
(
ratio
List
.
substring
(
ratio
List
.
indexOf
(
"
:
"
)
+
1
)
.
replace
(
")"
,
""
))
;
//
比例
if
(
Unit
.
equals
(
basicUnit
))
{
//如果等于基础单位
depotItem
.
setBasicnumber
(
oNumber
);
//数量一致
}
else
if
(
Unit
.
equals
(
otherUnit
))
{
//如果等于副单位
depotItem
.
setBasicnumber
(
oNumber
.
multiply
(
new
BigDecimal
(
ratio
))
);
//
数量乘以比例
}
else
{
//不等于基础单位也不等于副单位,单位存在问题
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_UNIT_NOT_RIGHT_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_UNIT_NOT_RIGHT_MSG
,
material
==
null
?
""
:
material
.
getName
(),
Unit
,
basicUnit
,
otherUnit
));
}
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>>>>>>>>>>设置基础数量异常"
,
e
);
}
else
{
depotItem
.
setBasicnumber
(
oNumber
);
//其他情况
}
}
if
(!
StringUtil
.
isEmpty
(
tempInsertedJson
.
get
(
"UnitPrice"
).
toString
()))
{
...
...
@@ -593,7 +594,6 @@ public class DepotItemService {
if
(
depotItem
==
null
){
continue
;
}
Material
material
=
materialService
.
getMaterial
(
depotItem
.
getMaterialid
());
if
(
material
==
null
){
continue
;
}
...
...
@@ -648,31 +648,34 @@ public class DepotItemService {
depotItem
.
setId
(
tempUpdatedJson
.
getLong
(
"Id"
));
depotItem
.
setMaterialid
(
tempUpdatedJson
.
getLong
(
"MaterialId"
));
depotItem
.
setMunit
(
tempUpdatedJson
.
getString
(
"Unit"
));
if
(!
material
.
getId
().
equals
(
depotItem
.
getMaterialid
())){
material
=
materialService
.
getMaterial
(
depotItem
.
getMaterialid
());
}
if
(!
StringUtil
.
isEmpty
(
tempUpdatedJson
.
get
(
"OperNumber"
).
toString
()))
{
depotItem
.
setOpernumber
(
tempUpdatedJson
.
getBigDecimal
(
"OperNumber"
));
tr
y
{
String
Unit
=
tempUpdatedJson
.
get
(
"Unit"
).
toString
(
);
BigDecimal
oNumber
=
tempUpdatedJson
.
getBigDecimal
(
"OperNumber"
);
Long
mId
=
Long
.
parseLong
(
tempUpdatedJson
.
get
(
"MaterialId"
).
toString
());
//以下进行单位换算
//
String
U
nitName = findUnitName(mId);
//查询计量单位名称
String
unitName
=
materialService
.
findU
nitName
(
mId
);
if
(!
String
Util
.
isEmpty
(
unitName
))
{
String
unit
List
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratioLis
t
=
unit
Name
.
substring
(
unit
Name
.
indexOf
(
"
(
"
));
String
basic
Unit
=
unitList
.
substring
(
0
,
unitList
.
indexOf
(
","
));
//
基本
单位
String
otherUnit
=
unit
List
.
substring
(
unit
List
.
indexOf
(
"
,
"
)
+
1
);
//
副单位
Integer
ratio
=
Integer
.
parseInt
(
ratioList
.
substring
(
ratioList
.
indexOf
(
":"
)
+
1
).
replace
(
")"
,
""
));
//比例
if
(
Unit
.
equals
(
basicUnit
))
{
//如果等于基础单位
depotItem
.
setBasicnumber
(
oNumber
);
//数量一致
}
else
if
(
Unit
.
equals
(
otherUnit
))
{
//如果等于副单位
depotItem
.
setBasicnumber
(
oNumber
.
multiply
(
new
BigDecimal
(
ratio
)));
//数量乘以比例
}
}
else
{
depotItem
.
setBasicnumber
(
oNumber
);
//其他情况
S
tr
ing
Unit
=
tempUpdatedJson
.
get
(
"Unit"
).
toString
();
BigDecimal
oNumber
=
tempUpdatedJson
.
get
BigDecimal
(
"OperNumber"
);
Long
mId
=
Long
.
parseLong
(
tempUpdatedJson
.
get
(
"MaterialId"
).
toString
()
);
//以下进行单位换算
//
String UnitName = findUnitName(mId); //查询计量单位名称
String
u
nitName
=
materialService
.
findUnitName
(
mId
);
if
(!
String
Util
.
isEmpty
(
u
nitName
))
{
String
unitList
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratio
List
=
unitName
.
substring
(
unitName
.
indexOf
(
"("
));
String
basicUni
t
=
unit
List
.
substring
(
0
,
unit
List
.
indexOf
(
"
,
"
));
//基本单位
String
other
Unit
=
unitList
.
substring
(
unitList
.
indexOf
(
","
)
+
1
);
//
副
单位
Integer
ratio
=
Integer
.
parseInt
(
ratio
List
.
substring
(
ratio
List
.
indexOf
(
"
:
"
)
+
1
)
.
replace
(
")"
,
""
))
;
//
比例
if
(
Unit
.
equals
(
basicUnit
))
{
//如果等于基础单位
depotItem
.
setBasicnumber
(
oNumber
);
//数量一致
}
else
if
(
Unit
.
equals
(
otherUnit
))
{
//如果等于副单位
depotItem
.
setBasicnumber
(
oNumber
.
multiply
(
new
BigDecimal
(
ratio
)));
//数量乘以比例
}
else
{
//不等于基础单位也不等于副单位,单位存在问题
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_UNIT_NOT_RIGHT_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_UNIT_NOT_RIGHT_MSG
,
material
==
null
?
""
:
material
.
getName
(),
Unit
,
basicUnit
,
otherUnit
));
}
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>>>>>>>>>>设置基础数量异常"
,
e
);
}
else
{
depotItem
.
setBasicnumber
(
oNumber
);
//其他情况
}
}
if
(!
StringUtil
.
isEmpty
(
tempUpdatedJson
.
get
(
"UnitPrice"
).
toString
()))
{
...
...
@@ -715,7 +718,6 @@ public class DepotItemService {
* 这里需要重新获取页面传递的商品信息
*/
if
(!
material
.
getId
().
equals
(
depotItem
.
getMaterialid
())){
material
=
materialService
.
getMaterial
(
depotItem
.
getMaterialid
());
if
(
material
==
null
){
continue
;
}
...
...
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