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
50905f5f
Commit
50905f5f
authored
Sep 21, 2021
by
季圣华
Browse files
优化商品的sku库存
parent
82c7dfa5
Changes
2
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
50905f5f
...
@@ -123,16 +123,21 @@ public class DepotItemController {
...
@@ -123,16 +123,21 @@ public class DepotItemController {
List
<
MaterialVo4Unit
>
list
=
materialService
.
getMaterialByBarCode
(
barCode
);
List
<
MaterialVo4Unit
>
list
=
materialService
.
getMaterialByBarCode
(
barCode
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
MaterialVo4Unit
materialVo4Unit
=
list
.
get
(
0
);
MaterialVo4Unit
materialVo4Unit
=
list
.
get
(
0
);
stock
=
depotItemService
.
getStockByParam
(
depotId
,
materialVo4Unit
.
getId
(),
null
,
null
);
BigDecimal
skuStock
=
depotItemService
.
getSkuStockByParam
(
depotId
,
materialVo4Unit
.
getMeId
(),
null
,
null
);
String
commodityUnit
=
materialVo4Unit
.
getCommodityUnit
();
if
(
skuStock
.
compareTo
(
BigDecimal
.
ZERO
)!=
0
){
Long
unitId
=
materialVo4Unit
.
getUnitId
();
stock
=
skuStock
;
if
(
unitId
!=
null
)
{
}
else
{
Integer
ratio
=
1
;
stock
=
depotItemService
.
getStockByParam
(
depotId
,
materialVo4Unit
.
getId
(),
null
,
null
);
Unit
unit
=
unitService
.
getUnit
(
unitId
);
String
commodityUnit
=
materialVo4Unit
.
getCommodityUnit
();
if
(
commodityUnit
.
equals
(
unit
.
getOtherUnit
())){
Long
unitId
=
materialVo4Unit
.
getUnitId
();
ratio
=
unit
.
getRatio
();
if
(
unitId
!=
null
)
{
if
(
ratio
!=
0
)
{
Integer
ratio
=
1
;
stock
=
stock
.
divide
(
BigDecimal
.
valueOf
(
ratio
),
2
,
BigDecimal
.
ROUND_HALF_UP
);
//两位小数
Unit
unit
=
unitService
.
getUnit
(
unitId
);
if
(
commodityUnit
.
equals
(
unit
.
getOtherUnit
())){
ratio
=
unit
.
getRatio
();
if
(
ratio
!=
0
)
{
stock
=
stock
.
divide
(
BigDecimal
.
valueOf
(
ratio
),
2
,
BigDecimal
.
ROUND_HALF_UP
);
//两位小数
}
}
}
}
}
}
}
...
@@ -173,13 +178,19 @@ public class DepotItemController {
...
@@ -173,13 +178,19 @@ public class DepotItemController {
item
.
put
(
"model"
,
diEx
.
getMModel
());
item
.
put
(
"model"
,
diEx
.
getMModel
());
item
.
put
(
"materialOther"
,
getOtherInfo
(
mpArr
,
diEx
));
item
.
put
(
"materialOther"
,
getOtherInfo
(
mpArr
,
diEx
));
Integer
ratio
=
diEx
.
getRatio
();
Integer
ratio
=
diEx
.
getRatio
();
BigDecimal
stock
=
depotItemService
.
getStockByParam
(
diEx
.
getDepotId
(),
diEx
.
getMaterialId
(),
null
,
null
);
BigDecimal
stock
;
if
(
ratio
!=
null
){
BigDecimal
skuStock
=
depotItemService
.
getSkuStockByParam
(
diEx
.
getDepotId
(),
diEx
.
getMaterialExtendId
(),
null
,
null
);
BigDecimal
ratioDecimal
=
new
BigDecimal
(
ratio
.
toString
());
if
(
skuStock
.
compareTo
(
BigDecimal
.
ZERO
)!=
0
){
if
(
ratioDecimal
.
compareTo
(
BigDecimal
.
ZERO
)!=
0
){
stock
=
skuStock
;
String
otherUnit
=
diEx
.
getOtherUnit
();
}
else
{
if
(
otherUnit
.
equals
(
diEx
.
getMaterialUnit
()))
{
stock
=
depotItemService
.
getStockByParam
(
diEx
.
getDepotId
(),
diEx
.
getMaterialId
(),
null
,
null
);
stock
=
stock
.
divide
(
ratioDecimal
,
2
,
BigDecimal
.
ROUND_HALF_UP
);
//两位小数
if
(
ratio
!=
null
){
BigDecimal
ratioDecimal
=
new
BigDecimal
(
ratio
.
toString
());
if
(
ratioDecimal
.
compareTo
(
BigDecimal
.
ZERO
)!=
0
){
String
otherUnit
=
diEx
.
getOtherUnit
();
if
(
otherUnit
.
equals
(
diEx
.
getMaterialUnit
()))
{
stock
=
stock
.
divide
(
ratioDecimal
,
2
,
BigDecimal
.
ROUND_HALF_UP
);
//两位小数
}
}
}
}
}
}
}
...
...
jshERP-boot/src/main/resources/mapper_xml/MaterialMapperEx.xml
View file @
50905f5f
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
</resultMap>
</resultMap>
<resultMap
extends=
"com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap"
id=
"ResultAndUnitMap"
type=
"com.jsh.erp.datasource.entities.MaterialVo4Unit"
>
<resultMap
extends=
"com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap"
id=
"ResultAndUnitMap"
type=
"com.jsh.erp.datasource.entities.MaterialVo4Unit"
>
<result
column=
"meId"
jdbcType=
"BIGINT"
property=
"meId"
/>
<result
column=
"unit_name"
jdbcType=
"VARCHAR"
property=
"unitName"
/>
<result
column=
"unit_name"
jdbcType=
"VARCHAR"
property=
"unitName"
/>
<result
column=
"sku"
jdbcType=
"VARCHAR"
property=
"sku"
/>
<result
column=
"sku"
jdbcType=
"VARCHAR"
property=
"sku"
/>
</resultMap>
</resultMap>
...
@@ -303,7 +304,7 @@
...
@@ -303,7 +304,7 @@
</select>
</select>
<select
id=
"getMaterialByBarCode"
parameterType=
"com.jsh.erp.datasource.entities.MaterialExample"
resultMap=
"ResultAndUnitMap"
>
<select
id=
"getMaterialByBarCode"
parameterType=
"com.jsh.erp.datasource.entities.MaterialExample"
resultMap=
"ResultAndUnitMap"
>
select m.*,u.name unit_name,me.bar_code m_bar_code, me.commodity_unit, me.purchase_decimal, me.commodity_decimal,
select m.*,u.name unit_name,
me.id meId,
me.bar_code m_bar_code, me.commodity_unit, me.purchase_decimal, me.commodity_decimal,
me.wholesale_decimal, me.low_decimal, me.sku
me.wholesale_decimal, me.low_decimal, me.sku
from jsh_material m
from jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
...
...
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