优化商品的库存计算
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;">{{stock}}</td>
|
||||
<td style="width:120px;height:30px;line-height:30px;padding:8px;float:left;">{{allStock}}</td>
|
||||
<td style="width:120px;height:30px;line-height:30px;padding:8px;float:left;">{{initStock}}</td>
|
||||
<td style="width:120px;height:30px;line-height:30px;padding:8px;float:left;">{{currentStock}}</td>
|
||||
</tr>
|
||||
{{/depotList}}
|
||||
</table>
|
||||
@@ -198,13 +198,13 @@ public class DepotController {
|
||||
for(Depot depot: list) {
|
||||
DepotEx de = new DepotEx();
|
||||
if(mId!=0) {
|
||||
BigDecimal stock = materialService.getInitStock(mId, depot.getId());
|
||||
BigDecimal initStock = materialService.getInitStock(mId, depot.getId());
|
||||
BigDecimal currentStock = materialService.getCurrentStock(mId, depot.getId());
|
||||
de.setStock(stock);
|
||||
de.setAllStock(stock.add(currentStock));
|
||||
de.setInitStock(initStock);
|
||||
de.setCurrentStock(currentStock);
|
||||
} else {
|
||||
de.setStock(BigDecimal.ZERO);
|
||||
de.setAllStock(BigDecimal.ZERO);
|
||||
de.setInitStock(BigDecimal.ZERO);
|
||||
de.setCurrentStock(BigDecimal.ZERO);
|
||||
}
|
||||
de.setId(depot.getId());
|
||||
de.setName(depot.getName());
|
||||
|
||||
@@ -15,8 +15,8 @@ public class DepotEx extends Depot{
|
||||
//负责人名字
|
||||
private String principalName;
|
||||
|
||||
private BigDecimal stock;
|
||||
private BigDecimal initStock;
|
||||
|
||||
private BigDecimal allStock;
|
||||
private BigDecimal currentStock;
|
||||
|
||||
}
|
||||
|
||||
@@ -742,25 +742,7 @@ public class MaterialService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品和仓库获取初始库存
|
||||
* @param materialId
|
||||
* @param depotId
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getInitStock(Long materialId, Long depotId) {
|
||||
BigDecimal stock = BigDecimal.ZERO;
|
||||
MaterialInitialStockExample example = new MaterialInitialStockExample();
|
||||
example.createCriteria().andMaterialIdEqualTo(materialId).andDepotIdEqualTo(depotId)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<MaterialInitialStock> list = materialInitialStockMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
stock = list.get(0).getNumber();
|
||||
}
|
||||
return stock;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品获取初始库存
|
||||
* 根据商品获取初始库存,仓库为空的时候查全部库存
|
||||
* @param materialId
|
||||
* @return
|
||||
*/
|
||||
@@ -785,6 +767,24 @@ public class MaterialService {
|
||||
return stock;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品和仓库获取初始库存
|
||||
* @param materialId
|
||||
* @param depotId
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getInitStock(Long materialId, Long depotId) {
|
||||
BigDecimal stock = BigDecimal.ZERO;
|
||||
MaterialInitialStockExample example = new MaterialInitialStockExample();
|
||||
example.createCriteria().andMaterialIdEqualTo(materialId).andDepotIdEqualTo(depotId)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<MaterialInitialStock> list = materialInitialStockMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
stock = list.get(0).getNumber();
|
||||
}
|
||||
return stock;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品和仓库获取当前库存
|
||||
* @param materialId
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user