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
39f07cea
Commit
39f07cea
authored
May 17, 2019
by
qiankunpingtai
Browse files
添加库存校验
parent
ff015295
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java
View file @
39f07cea
...
...
@@ -179,4 +179,6 @@ public interface DepotItemMapperEx {
@Param
(
"rows"
)
Integer
rows
,
@Param
(
"pid"
)
Integer
pid
);
int
findStockWarningCountTotal
(
@Param
(
"pid"
)
Integer
pid
);
BigDecimal
getCurrentRepByMaterialIdAndDepotId
(
@Param
(
"materialId"
)
Long
materialId
,
@Param
(
"depotId"
)
Long
depotId
);
}
src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
39f07cea
...
...
@@ -241,7 +241,7 @@ public class DepotItemService {
String
mIdStr
=
map
.
get
(
"mId"
);
Long
mId
=
null
;
if
(!
StringUtil
.
isEmpty
(
mIdStr
))
{
mId
=
Long
.
parseLong
(
mIdStr
);
mId
=
Long
.
valueOf
(
mIdStr
);
}
String
monthTime
=
map
.
get
(
"monthTime"
);
List
<
DepotItemVo4Material
>
list
=
null
;
...
...
@@ -601,7 +601,7 @@ public class DepotItemService {
if
(
material
==
null
){
continue
;
}
if
(
getCurrent
InStock
(
depotItem
.
getMaterialid
())<
(
depotItem
.
getBasicnumber
()==
null
?
0
:
depotItem
.
getBasicnumber
())
.
intValue
()
){
if
(
getCurrent
RepByMaterialIdAndDepotId
(
material
.
getId
(),
depotItem
.
getDepotid
()).
compareTo
(
depotItem
.
getBasicnumber
()==
null
?
BigDecimal
.
ZERO
:
depotItem
.
getBasicnumber
())
==-
1
){
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_MSG
,
material
==
null
?
""
:
material
.
getName
()));
}
...
...
@@ -633,19 +633,21 @@ public class DepotItemService {
continue
;
}
//首先回收序列号
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())
&&!
BusinessConstants
.
SUB_TYPE_TRANSFER
.
equals
(
depotHead
.
getSubtype
()))
{
/**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
if
(
BusinessConstants
.
ENABLE_SERIAL_NUMBER_ENABLED
.
equals
(
material
.
getEnableserialnumber
()))
{
serialNumberService
.
cancelSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
(
depotItem
.
getBasicnumber
()==
null
?
0
:
depotItem
.
getBasicnumber
()).
intValue
(),
userInfo
);
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
()))
{
if
(!
BusinessConstants
.
SUB_TYPE_TRANSFER
.
equals
(
depotHead
.
getSubtype
()))
{
/**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
if
(
BusinessConstants
.
ENABLE_SERIAL_NUMBER_ENABLED
.
equals
(
material
.
getEnableserialnumber
()))
{
serialNumberService
.
cancelSerialNumber
(
depotItem
.
getMaterialid
(),
depotItem
.
getHeaderid
(),
(
depotItem
.
getBasicnumber
()
==
null
?
0
:
depotItem
.
getBasicnumber
()).
intValue
(),
userInfo
);
}
/**收回序列号的时候释放库存*/
depotItem
.
setOpernumber
(
BigDecimal
.
ZERO
);
depotItem
.
setBasicnumber
(
BigDecimal
.
ZERO
);
this
.
updateDepotItemWithObj
(
depotItem
);
}
/**收回序列号的时候释放库存*/
depotItem
.
setOpernumber
(
BigDecimal
.
ZERO
);
depotItem
.
setBasicnumber
(
BigDecimal
.
ZERO
);
this
.
updateDepotItemWithObj
(
depotItem
);
}
depotItem
.
setId
(
tempUpdatedJson
.
getLong
(
"Id"
));
depotItem
.
setMaterialid
(
tempUpdatedJson
.
getLong
(
"MaterialId"
));
...
...
@@ -724,7 +726,8 @@ public class DepotItemService {
}
/**出库时处理序列号*/
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())){
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
())<(
depotItem
.
getBasicnumber
()==
null
?
0
:
depotItem
.
getBasicnumber
()).
intValue
()){
if
(
getCurrentRepByMaterialIdAndDepotId
(
material
.
getId
(),
depotItem
.
getDepotid
())
.
compareTo
(
depotItem
.
getBasicnumber
()==
null
?
BigDecimal
.
ZERO
:
depotItem
.
getBasicnumber
())==-
1
){
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_MSG
,
material
==
null
?
""
:
material
.
getName
()));
}
...
...
@@ -820,4 +823,23 @@ public class DepotItemService {
}
return
result
;
}
/**
* create by: qiankunpingtai
* create time: 2019/5/16 18:15
* website:https://qiankunpingtai.cn
* description:
* 查询指定仓库指定材料的当前库存
*/
public
BigDecimal
getCurrentRepByMaterialIdAndDepotId
(
Long
materialId
,
Long
depotId
)
{
BigDecimal
result
=
BigDecimal
.
ZERO
;
try
{
result
=
depotItemMapperEx
.
getCurrentRepByMaterialIdAndDepotId
(
materialId
,
depotId
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
result
;
}
}
src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
39f07cea
...
...
@@ -610,5 +610,25 @@
AND ifnull(m.delete_Flag, '0') != '1'
AND intype.BasicInNumber > 0
</select>
<select
id=
"getCurrentRepByMaterialIdAndDepotId"
resultType=
"java.math.BigDecimal"
>
select ((curep.inTotal+curep.transfInTotal+curep.assemInTotal+curep.disAssemInTotal)
-(curep.transfOutTotal+curep.outTotal+curep.assemOutTotal+curep.disAssemOutTotal)) as currentRepo
from
(select sum(dh.type='入库' and di.DepotId=#{depotId}) as inTotal,
sum(dh.SubType='调拨' and di.AnotherDepotId=#{depotId}) as transfInTotal,
sum(dh.SubType='调拨' and di.DepotId=#{depotId}) as transfOutTotal,
sum(dh.type='出库' and dh.SubType!='调拨' and di.DepotId=#{depotId}) as outTotal,
sum(dh.SubType='组装单' and di.MType='组合件' and di.DepotId=#{depotId}) as assemInTotal,
sum(dh.SubType='组装单' and di.MType='普通子件' and di.DepotId=#{depotId}) as assemOutTotal,
sum(dh.SubType='拆卸单' and di.MType='普通子件' and di.DepotId=#{depotId}) as disAssemInTotal,
sum(dh.SubType='拆卸单' and di.MType='组合件' and di.DepotId=#{depotId}) as disAssemOutTotal
from
jsh_depothead dh,jsh_depotitem di
where 1=1
and dh.id=di.HeaderId
and di.MaterialId=#{materialId}
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1') curep
</select>
</mapper>
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