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
d0f56f84
Commit
d0f56f84
authored
Dec 25, 2020
by
季圣华
Browse files
优化商品的库存计算
parent
fd8219fd
Changes
5
Show whitespace changes
Inline
Side-by-side
erp_web/pages/materials/material.html
View file @
d0f56f84
...
...
@@ -434,7 +434,8 @@
{
title: '库存', field: 'stock', width: 70, formatter: function (value, rec) {
var str = '';
str += '<span title="查看库存及明细" class="n-link" onclick="findStockList(' + rec.id + ');">' + rec.stock + '</span>';
str += '<span title="查看库存及明细" class="n-link" ' +
'onclick="findStockList(' + rec.id + ',' + rec.mBarCode + ',\'' + rec.name + '\');">' + rec.stock + '</span>';
return str;
}
},
...
...
@@ -643,8 +644,9 @@
}
}
function findStockList(mId) {
$('#materialDetailListDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui/themes/icons/pencil.png"/> 查看库存及明细');
function findStockList(mId, barCode, name) {
var titleInfo = " " + name + "[" + barCode + "]库存及明细";
$('#materialDetailListDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui/themes/icons/pencil.png"/>' + titleInfo);
$(".window-mask").css({width: webW, height: webH});
initDepotList(mId, "show"); //加载仓库及库存数量
initMaterialDetailData(mId);
...
...
@@ -1321,7 +1323,7 @@
} else if(type == "show"){
$.ajax({
type: "get",
url: "../../../pages/template/init_depot_show_list.html?
888
",
url: "../../../pages/template/init_depot_show_list.html?
555
",
async: false,
success: function (tem) {
if (tem) {
...
...
erp_web/pages/template/init_depot_show_list.html
View file @
d0f56f84
...
...
@@ -9,8 +9,8 @@
<td
style=
"width:130px;height:30px;line-height:30px;padding:8px;float:left;"
title=
"{{name}}"
>
<p
style=
"width:110px;overflow: hidden;white-space:nowrap;text-overflow: ellipsis;"
>
{{name}}
</p>
</td>
<td
style=
"width:120px;height:30px;line-height:30px;padding:8px;float:left;"
>
{{
s
tock}}
</td>
<td
style=
"width:120px;height:30px;line-height:30px;padding:8px;float:left;"
>
{{
all
Stock}}
</td>
<td
style=
"width:120px;height:30px;line-height:30px;padding:8px;float:left;"
>
{{
initS
tock}}
</td>
<td
style=
"width:120px;height:30px;line-height:30px;padding:8px;float:left;"
>
{{
current
Stock}}
</td>
</tr>
{{/depotList}}
</table>
\ No newline at end of file
src/main/java/com/jsh/erp/controller/DepotController.java
View file @
d0f56f84
...
...
@@ -198,13 +198,13 @@ public class DepotController {
for
(
Depot
depot:
list
)
{
DepotEx
de
=
new
DepotEx
();
if
(
mId
!=
0
)
{
BigDecimal
s
tock
=
materialService
.
getInitStock
(
mId
,
depot
.
getId
());
BigDecimal
initS
tock
=
materialService
.
getInitStock
(
mId
,
depot
.
getId
());
BigDecimal
currentStock
=
materialService
.
getCurrentStock
(
mId
,
depot
.
getId
());
de
.
setStock
(
s
tock
);
de
.
set
AllStock
(
stock
.
add
(
currentStock
)
)
;
de
.
set
Init
Stock
(
initS
tock
);
de
.
set
CurrentStock
(
currentStock
);
}
else
{
de
.
setStock
(
BigDecimal
.
ZERO
);
de
.
set
All
Stock
(
BigDecimal
.
ZERO
);
de
.
set
Init
Stock
(
BigDecimal
.
ZERO
);
de
.
set
Current
Stock
(
BigDecimal
.
ZERO
);
}
de
.
setId
(
depot
.
getId
());
de
.
setName
(
depot
.
getName
());
...
...
src/main/java/com/jsh/erp/datasource/entities/DepotEx.java
View file @
d0f56f84
...
...
@@ -15,8 +15,8 @@ public class DepotEx extends Depot{
//负责人名字
private
String
principalName
;
private
BigDecimal
s
tock
;
private
BigDecimal
initS
tock
;
private
BigDecimal
all
Stock
;
private
BigDecimal
current
Stock
;
}
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
d0f56f84
...
...
@@ -742,45 +742,45 @@ public class MaterialService {
}
/**
* 根据商品
和仓库
获取初始库存
* 根据商品获取初始库存
,仓库为空的时候查全部库存
* @param materialId
* @param depotId
* @return
*/
public
BigDecimal
getInitStock
(
Long
material
Id
,
Long
depot
Id
)
{
public
BigDecimal
getInitStock
ByMid
(
Long
depot
Id
,
Long
material
Id
)
{
BigDecimal
stock
=
BigDecimal
.
ZERO
;
MaterialInitialStockExample
example
=
new
MaterialInitialStockExample
();
if
(
depotId
!=
null
)
{
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
).
andDepotIdEqualTo
(
depotId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
else
{
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
List
<
MaterialInitialStock
>
list
=
materialInitialStockMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
stock
=
list
.
get
(
0
).
getNumber
();
for
(
MaterialInitialStock
ms:
list
)
{
if
(
ms
!=
null
)
{
stock
=
stock
.
add
(
ms
.
getNumber
());
}
}
}
return
stock
;
}
/**
* 根据商品获取初始库存
* 根据商品
和仓库
获取初始库存
* @param materialId
* @param depotId
* @return
*/
public
BigDecimal
getInitStock
ByMid
(
Long
depot
Id
,
Long
material
Id
)
{
public
BigDecimal
getInitStock
(
Long
material
Id
,
Long
depot
Id
)
{
BigDecimal
stock
=
BigDecimal
.
ZERO
;
MaterialInitialStockExample
example
=
new
MaterialInitialStockExample
();
if
(
depotId
!=
null
)
{
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
).
andDepotIdEqualTo
(
depotId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
else
{
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
List
<
MaterialInitialStock
>
list
=
materialInitialStockMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
for
(
MaterialInitialStock
ms:
list
)
{
if
(
ms
!=
null
)
{
stock
=
stock
.
add
(
ms
.
getNumber
());
}
}
stock
=
list
.
get
(
0
).
getNumber
();
}
return
stock
;
}
...
...
@@ -799,6 +799,8 @@ public class MaterialService {
List
<
MaterialCurrentStock
>
list
=
materialCurrentStockMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
stock
=
list
.
get
(
0
).
getCurrentNumber
();
}
else
{
stock
=
getInitStock
(
materialId
,
depotId
);
}
return
stock
;
}
...
...
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