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
d1a5d471
Commit
d1a5d471
authored
Feb 02, 2019
by
cjl
Browse files
修复库存判断不准确的问题
parent
b1d74a16
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
View file @
d1a5d471
...
...
@@ -396,7 +396,8 @@ public class DepotHeadService {
/**回收序列号*/
if
(
depotItemList
!=
null
&&
depotItemList
.
size
()>
0
){
for
(
DepotItem
depotItem:
depotItemList
){
serialNumberService
.
cancelSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
depotItem
.
getOpernumber
().
intValue
(),
userInfo
);
//BasicNumber=OperNumber*ratio
serialNumberService
.
cancelSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
depotItem
.
getBasicnumber
().
intValue
(),
userInfo
);
}
}
}
...
...
src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
d1a5d471
...
...
@@ -224,7 +224,11 @@ public class DepotItemService {
return
depotItemMapperEx
.
findGiftByTypeOut
(
subType
,
ProjectId
,
MId
);
}
}
/**
* 2019-02-02修改
* 我之前对操作数量的理解有偏差
* 这里重点重申一下:BasicNumber=OperNumber*ratio
* */
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
String
saveDetials
(
String
inserted
,
String
deleted
,
String
updated
,
Long
headerId
)
throws
Exception
{
//查询单据主表信息
...
...
@@ -259,7 +263,7 @@ public class DepotItemService {
continue
;
}
if
(
BusinessConstants
.
ENABLE_SERIAL_NUMBER_ENABLED
.
equals
(
material
.
getEnableSerialNumber
())){
serialNumberMapperEx
.
cancelSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
depotItem
.
get
Oper
number
().
intValue
(),
serialNumberMapperEx
.
cancelSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
depotItem
.
get
Basic
number
().
intValue
(),
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
());
}
}
...
...
@@ -279,14 +283,18 @@ public class DepotItemService {
String
Unit
=
tempInsertedJson
.
get
(
"Unit"
).
toString
();
BigDecimal
oNumber
=
tempInsertedJson
.
getBigDecimal
(
"OperNumber"
);
Long
mId
=
Long
.
parseLong
(
tempInsertedJson
.
get
(
"MaterialId"
).
toString
());
/***
* 为什么调用的方法要先把基础单位去掉,去掉之后后续还能获取到?
* */
//以下进行单位换算
String
UnitName
=
findUnitName
(
mId
);
//查询计量单位名称
if
(!
StringUtil
.
isEmpty
(
UnitName
))
{
String
UnitList
=
UnitName
.
substring
(
0
,
UnitName
.
indexOf
(
"("
));
String
RatioList
=
UnitName
.
substring
(
UnitName
.
indexOf
(
"("
));
String
basicUnit
=
UnitList
.
substring
(
0
,
UnitList
.
indexOf
(
","
));
//基本单位
String
otherUnit
=
UnitList
.
substring
(
UnitList
.
indexOf
(
","
)
+
1
);
//副单位
Integer
ratio
=
Integer
.
parseInt
(
RatioList
.
substring
(
RatioList
.
indexOf
(
":"
)
+
1
).
replace
(
")"
,
""
));
//比例
// String UnitName = findUnitName(mId); //查询计量单位名称
String
unitName
=
materialService
.
findUnitName
(
mId
);
if
(!
StringUtil
.
isEmpty
(
unitName
))
{
String
unitList
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratioList
=
unitName
.
substring
(
unitName
.
indexOf
(
"("
));
String
basicUnit
=
unitList
.
substring
(
0
,
unitList
.
indexOf
(
","
));
//基本单位
String
otherUnit
=
unitList
.
substring
(
unitList
.
indexOf
(
","
)
+
1
);
//副单位
Integer
ratio
=
Integer
.
parseInt
(
ratioList
.
substring
(
ratioList
.
indexOf
(
":"
)
+
1
).
replace
(
")"
,
""
));
//比例
if
(
Unit
.
equals
(
basicUnit
))
{
//如果等于基础单位
depotItem
.
setBasicnumber
(
oNumber
);
//数量一致
}
else
if
(
Unit
.
equals
(
otherUnit
))
{
//如果等于副单位
...
...
@@ -353,7 +361,7 @@ public class DepotItemService {
if
(
material
==
null
){
continue
;
}
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
())<
depotItem
.
get
Oper
number
().
intValue
()){
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
())<
depotItem
.
get
Basic
number
().
intValue
()){
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_MSG
,
material
==
null
?
""
:
material
.
getName
()));
}
...
...
@@ -391,9 +399,13 @@ public class DepotItemService {
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
if
(
BusinessConstants
.
ENABLE_SERIAL_NUMBER_ENABLED
.
equals
(
material
.
getEnableSerialNumber
()))
{
serialNumberMapperEx
.
cancelSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
depotItem
.
get
Oper
number
().
intValue
(),
serialNumberMapperEx
.
cancelSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
depotItem
.
get
Basic
number
().
intValue
(),
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
());
}
/**收回序列号的时候释放库存*/
depotItem
.
setOpernumber
(
BigDecimal
.
ZERO
);
depotItem
.
setBasicnumber
(
BigDecimal
.
ZERO
);
this
.
updateDepotItemWithObj
(
depotItem
);
}
depotItem
.
setId
(
tempUpdatedJson
.
getLong
(
"Id"
));
depotItem
.
setMaterialid
(
tempUpdatedJson
.
getLong
(
"MaterialId"
));
...
...
@@ -405,13 +417,14 @@ public class DepotItemService {
BigDecimal
oNumber
=
tempUpdatedJson
.
getBigDecimal
(
"OperNumber"
);
Long
mId
=
Long
.
parseLong
(
tempUpdatedJson
.
get
(
"MaterialId"
).
toString
());
//以下进行单位换算
String
UnitName
=
findUnitName
(
mId
);
//查询计量单位名称
if
(!
StringUtil
.
isEmpty
(
UnitName
))
{
String
UnitList
=
UnitName
.
substring
(
0
,
UnitName
.
indexOf
(
"("
));
String
RatioList
=
UnitName
.
substring
(
UnitName
.
indexOf
(
"("
));
String
basicUnit
=
UnitList
.
substring
(
0
,
UnitList
.
indexOf
(
","
));
//基本单位
String
otherUnit
=
UnitList
.
substring
(
UnitList
.
indexOf
(
","
)
+
1
);
//副单位
Integer
ratio
=
Integer
.
parseInt
(
RatioList
.
substring
(
RatioList
.
indexOf
(
":"
)
+
1
).
replace
(
")"
,
""
));
//比例
// String UnitName = findUnitName(mId); //查询计量单位名称
String
unitName
=
materialService
.
findUnitName
(
mId
);
if
(!
StringUtil
.
isEmpty
(
unitName
))
{
String
unitList
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratioList
=
unitName
.
substring
(
unitName
.
indexOf
(
"("
));
String
basicUnit
=
unitList
.
substring
(
0
,
unitList
.
indexOf
(
","
));
//基本单位
String
otherUnit
=
unitList
.
substring
(
unitList
.
indexOf
(
","
)
+
1
);
//副单位
Integer
ratio
=
Integer
.
parseInt
(
ratioList
.
substring
(
ratioList
.
indexOf
(
":"
)
+
1
).
replace
(
")"
,
""
));
//比例
if
(
Unit
.
equals
(
basicUnit
))
{
//如果等于基础单位
depotItem
.
setBasicnumber
(
oNumber
);
//数量一致
}
else
if
(
Unit
.
equals
(
otherUnit
))
{
//如果等于副单位
...
...
@@ -457,7 +470,7 @@ public class DepotItemService {
depotItem
.
setMtype
(
tempUpdatedJson
.
getString
(
"MType"
));
/**出库时处理序列号*/
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())){
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
())<
depotItem
.
get
Oper
number
().
intValue
()){
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
())<
depotItem
.
get
Basic
number
().
intValue
()){
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_MSG
,
material
==
null
?
""
:
material
.
getName
()));
}
...
...
src/main/java/com/jsh/erp/service/serialNumber/SerialNumberService.java
View file @
d1a5d471
...
...
@@ -286,14 +286,15 @@ public class SerialNumberService {
if
(
depotItem
!=
null
){
//查询商品下已分配的可用序列号数量
int
SerialNumberSum
=
serialNumberMapperEx
.
countSerialNumberByMaterialIdAndDepotheadId
(
depotItem
.
getMaterialid
(),
null
,
BusinessConstants
.
IS_SELL_HOLD
);
if
(
depotItem
.
getOpernumber
().
intValue
()>
SerialNumberSum
){
//BasicNumber=OperNumber*ratio
if
(
depotItem
.
getBasicnumber
().
intValue
()>
SerialNumberSum
){
//获取商品名称
Material
material
=
materialMapper
.
selectByPrimaryKey
(
depotItem
.
getMaterialid
());
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG
,
material
==
null
?
""
:
material
.
getName
()));
}
//商品下序列号充足,分配序列号
sellSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
depotItem
.
get
Oper
number
().
intValue
(),
userInfo
);
sellSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
depotItem
.
get
Basic
number
().
intValue
(),
userInfo
);
}
}
...
...
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