修改根据材料和仓库获取库存

This commit is contained in:
qiankunpingtai
2019-06-11 10:50:51 +08:00
parent 0b07e2d61f
commit 99d856111e
5 changed files with 260 additions and 314 deletions

View File

@@ -538,10 +538,7 @@
type: "get", type: "get",
url: '/depotItem/findStockNumByMaterialId', url: '/depotItem/findStockNumByMaterialId',
data: { data: {
materialId: mId, materialId: mId
monthTime: monthTime,
currentPage: 1,
pageSize: 10
}, },
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
@@ -667,6 +664,7 @@
pageSize: initPageSize, pageSize: initPageSize,
pageList: initPageNum, pageList: initPageNum,
columns: [[ columns: [[
{ {
title: '单据编号', field: 'Number', width: 150, title: '单据编号', field: 'Number', width: 150,
formatter: function (value, row) { formatter: function (value, row) {
@@ -676,7 +674,10 @@
}, },
{title: '类型', field: 'Type', width: 100}, {title: '类型', field: 'Type', width: 100},
{title: '数量', field: 'BasicNumber', width: 80}, {title: '数量', field: 'BasicNumber', width: 80},
{title: '日期', field: 'OperTime', width: 180} {title: '仓库', field: 'depotName', width: 180},
{title: '日期', field: 'OperTime', width: 180},
{title: '调入仓库', field: 'depotInName', width: 180}
]], ]],
onLoadError: function () { onLoadError: function () {
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error'); $.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');

View File

@@ -46,11 +46,6 @@
<table id="tableForSelectData" style="top:300px;border-bottom-color:#FFFFFF"></table> <table id="tableForSelectData" style="top:300px;border-bottom-color:#FFFFFF"></table>
</div> </div>
<div id="materialDetailListDlg" class="easyui-dialog" style="width:900px;height:500px;padding:10px 20px" closed="true"
modal="true" collapsible="false" closable="true">
<table id="materialTableData" style="top:50px;border-bottom-color:#FFFFFF"></table>
</div>
<script type="text/javascript"> <script type="text/javascript">
var setCategoryId = "1"; var setCategoryId = "1";
var cid = 1; var cid = 1;
@@ -105,10 +100,7 @@
type: "get", type: "get",
url: '/depotItem/findStockNumByMaterialId', url: '/depotItem/findStockNumByMaterialId',
data: { data: {
materialId: mId, materialId: mId
monthTime: monthTime,
currentPage: 1,
pageSize: 10
}, },
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
@@ -116,15 +108,7 @@
if (res.data && res.data.page && res.data.page[0]) { if (res.data && res.data.page && res.data.page[0]) {
thisStock = res.data.page[0].thisSum - 0; thisStock = res.data.page[0].thisSum - 0;
if (thisStock > 0) { if (thisStock > 0) {
$("#tablePanel .class-" + rec.id).text(thisStock); //延迟加载库存数据 $("#tableForSelectPanel .class-" + rec.id).text(thisStock); //延迟加载库存数据
$("#tablePanel .class-" + rec.id).css("color", "blue").css("text-decoration", "underline").css("cursor", "pointer");
$("#tablePanel .class-" + rec.id).off("click").on("click", function () {
$('#materialDetailListDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;查看出入库明细');
$(".window-mask").css({width: webW, height: webH});
initMaterialDetailData(mId);
getMaterialInOutList(mId, 1, initPageSize);
ininMaterialDetailPager(mId);
});
} }
} }
} }
@@ -163,52 +147,8 @@
} }
//分页信息处理
function ininMaterialDetailPager(mId) {
try {
var opts = $("#materialTableData").datagrid('options');
var pager = $("#materialTableData").datagrid('getPager');
pager.pagination({
onSelectPage: function (pageNum, pageSize) {
opts.pageNumber = pageNum;
opts.pageSize = pageSize;
pager.pagination('refresh', {
pageNumber: pageNum,
pageSize: pageSize
});
getMaterialInOutList(mId, pageNum, pageSize);
}
});
}
catch (e) {
$.messager.alert('异常处理提示', "分页信息异常 : " + e.name + ": " + e.message, 'error');
}
}
function getMaterialInOutList(mId, pageNo, pageSize) {
$.ajax({
type: "get",
url: "/depotItem/findDetailByTypeAndMaterialId",
dataType: "json",
data: ({
materialId: mId,
currentPage: pageNo,
pageSize: pageSize
}),
success: function (res) {
if(res && res.code === 200){
if(res.data && res.data.page) {
$("#materialTableData").datagrid('loadData', res.data.page);
}
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
//初始化键盘enter事件 //初始化键盘enter事件
$(document).keydown(function (event) { $(document).keydown(function (event) {

View File

@@ -4,7 +4,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.entities.DepotItemVo4DetailByTypeAndMId;
import com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx;
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount; import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depotItem.DepotItemService; import com.jsh.erp.service.depotItem.DepotItemService;
@@ -12,8 +13,10 @@ import com.jsh.erp.service.material.MaterialService;
import com.jsh.erp.utils.*; import com.jsh.erp.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@@ -73,6 +76,8 @@ public class DepotItemController {
item.put("Type", d.getNewtype()); //进出类型 item.put("Type", d.getNewtype()); //进出类型
item.put("BasicNumber", d.getBnum()); //数量 item.put("BasicNumber", d.getBnum()); //数量
item.put("OperTime", d.getOtime()); //时间 item.put("OperTime", d.getOtime()); //时间
item.put("depotName", d.getDepotName()); //仓库名称
item.put("depotInName", d.getDepotInName()); //调入仓库名称
dataArray.add(item); dataArray.add(item);
} }
} }
@@ -113,55 +118,21 @@ public class DepotItemController {
/** /**
* 只根据商品id查询库存数量 * 只根据商品id查询库存数量
* @param pageSize
* @param currentPage
* @param mId * @param mId
* @param request * @param request
* @return * @return
*/ */
@GetMapping(value = "/findStockNumByMaterialId") @RequestMapping(value = "/findStockNumByMaterialId")
public String findStockNumByMaterialId( public String findStockNumByMaterialId(
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
@RequestParam("materialId") String mId, @RequestParam("materialId") String mId,
@RequestParam("monthTime") String monthTime,
HttpServletRequest request) throws Exception{ HttpServletRequest request) throws Exception{
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
parameterMap.put("mId", mId);
parameterMap.put("monthTime", monthTime);
PageQueryInfo queryInfo = new PageQueryInfo();
Map<String, Object> objectMap = new HashMap<String, Object>(); Map<String, Object> objectMap = new HashMap<String, Object>();
if (pageSize != null && pageSize <= 0) {
pageSize = 10;
}
String offset = ParamUtils.getPageOffset(currentPage, pageSize);
if (StringUtil.isNotEmpty(offset)) {
parameterMap.put(Constants.OFFSET, offset);
}
List<DepotItemVo4Material> list = depotItemService.findStockNumByMaterialIdList(parameterMap);
//存放数据json数组 //存放数据json数组
JSONArray dataArray = new JSONArray(); JSONArray dataArray = new JSONArray();
if (null != list) {
for (DepotItemVo4Material di : list) {
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
int InSum = sumNumberByMaterialId("入库", di.getMaterialid()); item.put("thisSum", depotItemService.getCurrentRepByMaterialIdAndDepotId(Long.valueOf(mId),null));
int OutSum = sumNumberByMaterialId("出库", di.getMaterialid());
item.put("MaterialId", di.getMaterialid() == null ? "" : di.getMaterialid());
item.put("MaterialName", di.getMname());
item.put("MaterialModel", di.getMmodel());
item.put("thisSum", InSum - OutSum);
dataArray.add(item); dataArray.add(item);
}
}
objectMap.put("page", dataArray); objectMap.put("page", dataArray);
if (list == null) {
queryInfo.setRows(new ArrayList<Object>());
queryInfo.setTotal(BusinessConstants.DEFAULT_LIST_NULL_NUMBER);
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
}
queryInfo.setRows(list);
queryInfo.setTotal(depotItemService.findStockNumByMaterialIdCounts(parameterMap));
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} }

View File

@@ -11,6 +11,10 @@ public class DepotItemVo4DetailByTypeAndMId {
private Integer bnum; private Integer bnum;
private Date otime; private Date otime;
//仓库名称
private String depotName;
//调入仓库名称
private String depotInName;
public String getNumber() { public String getNumber() {
return number; return number;
@@ -43,4 +47,20 @@ public class DepotItemVo4DetailByTypeAndMId {
public void setOtime(Date otime) { public void setOtime(Date otime) {
this.otime = otime; this.otime = otime;
} }
public String getDepotName() {
return depotName;
}
public void setDepotName(String depotName) {
this.depotName = depotName;
}
public String getDepotInName() {
return depotInName;
}
public void setDepotInName(String depotInName) {
this.depotInName = depotInName;
}
} }

View File

@@ -7,6 +7,8 @@
<result column="newType" jdbcType="VARCHAR" property="newtype" /> <result column="newType" jdbcType="VARCHAR" property="newtype" />
<result column="b_num" jdbcType="BIGINT" property="bnum" /> <result column="b_num" jdbcType="BIGINT" property="bnum" />
<result column="oTime" jdbcType="TIMESTAMP" property="otime" /> <result column="oTime" jdbcType="TIMESTAMP" property="otime" />
<result column="depotName" jdbcType="VARCHAR" property="depotName" />
<result column="depotInName" jdbcType="VARCHAR" property="depotInName" />
</resultMap> </resultMap>
<resultMap extends="com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap" id="ResultAndMaterialMap" type="com.jsh.erp.datasource.entities.DepotItemVo4Material"> <resultMap extends="com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap" id="ResultAndMaterialMap" type="com.jsh.erp.datasource.entities.DepotItemVo4Material">
@@ -91,12 +93,22 @@
<select id="findDetailByTypeAndMaterialIdList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="DetailByTypeAndMIdResultMap"> <select id="findDetailByTypeAndMaterialIdList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="DetailByTypeAndMIdResultMap">
select dh.Number,concat(dh.SubType,dh.Type) as newType, select dh.Number,concat(dh.SubType,dh.Type) as newType,
case when type='入库' then di.BasicNumber when type='出库' then 0-di.BasicNumber else 0 end as b_num, case when dh.type='入库' then ifnull(di.BasicNumber,0)
date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime when dh.type='出库' and dh.SubType!='调拨' then 0 - ifnull(di.BasicNumber,0)
when dh.SubType='组装单' and di.MType='组合件' then ifnull(di.BasicNumber,0)
when dh.SubType='组装单' and di.MType='普通子件' then 0-ifnull(di.BasicNumber,0)
when dh.SubType='拆卸单' and di.MType='普通子件' then ifnull(di.BasicNumber,0)
when dh.SubType='拆卸单' and di.MType='组合件' then 0-ifnull(di.BasicNumber,0)
when dh.SubType='调拨' then 0-ifnull(di.BasicNumber,0)
else 0 end as b_num,
date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime,
depot.name as depotName,depotIn.name as depotInName
from jsh_depothead dh from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1' INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type!='其它' left join jsh_depot depot on depot.id=di.depotId and ifnull(depot.delete_Flag,'0') !='1'
and dh.SubType!='调拨' left join jsh_depot depotIn on depotIn.id=di.AnotherDepotId and ifnull(depotIn.delete_Flag,'0') !='1'
where 1=1
and dh.SubType not in('采购订单','销售订单')
and di.MaterialId =#{mId} and di.MaterialId =#{mId}
and ifnull(dh.delete_Flag,'0') !='1' and ifnull(dh.delete_Flag,'0') !='1'
ORDER BY oTime desc ORDER BY oTime desc
@@ -108,8 +120,10 @@
select count(1) select count(1)
from jsh_depothead dh from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1' INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type!='其它' left join jsh_depot depot on depot.id=di.depotId and ifnull(depot.delete_Flag,'0') !='1'
and dh.SubType!='调拨' left join jsh_depot depotIn on depotIn.id=di.AnotherDepotId and ifnull(depotIn.delete_Flag,'0') !='1'
where 1=1
and dh.SubType not in('采购订单','销售订单')
and di.MaterialId =#{mId} and di.MaterialId =#{mId}
and ifnull(dh.delete_Flag,'0') !='1' and ifnull(dh.delete_Flag,'0') !='1'
</select> </select>
@@ -592,21 +606,21 @@
select ((curep.inTotal+curep.transfInTotal+curep.assemInTotal+curep.disAssemInTotal) select ((curep.inTotal+curep.transfInTotal+curep.assemInTotal+curep.disAssemInTotal)
-(curep.transfOutTotal+curep.outTotal+curep.assemOutTotal+curep.disAssemOutTotal)) as currentRepo -(curep.transfOutTotal+curep.outTotal+curep.assemOutTotal+curep.disAssemOutTotal)) as currentRepo
from from
(select sum(if(dh.type='入库' and di.DepotId=#{depotId},di.BasicNumber,0)) as inTotal, (select sum(if(dh.type='入库' <if test="depotId != null">and di.DepotId=#{depotId}</if>, di.BasicNumber,0)) as inTotal,
sum(if(dh.SubType='调拨' and di.AnotherDepotId=#{depotId},di.BasicNumber,0)) as transfInTotal, sum(if(dh.SubType='调拨' <if test="depotId != null">and di.AnotherDepotId=#{depotId}</if>,di.BasicNumber,0)) as transfInTotal,
sum(if(dh.SubType='调拨' and di.DepotId=#{depotId},di.BasicNumber,0)) as transfOutTotal, sum(if(dh.SubType='调拨' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as transfOutTotal,
sum(if(dh.type='出库' and dh.SubType!='调拨' and di.DepotId=#{depotId},di.BasicNumber,0)) as outTotal, sum(if(dh.type='出库' and dh.SubType!='调拨' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as outTotal,
sum(if(dh.SubType='组装单' and di.MType='组合件' and di.DepotId=#{depotId},di.BasicNumber,0)) as assemInTotal, sum(if(dh.SubType='组装单' and di.MType='组合件' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as assemInTotal,
sum(if(dh.SubType='组装单' and di.MType='普通子件' and di.DepotId=#{depotId},di.BasicNumber,0)) as assemOutTotal, sum(if(dh.SubType='组装单' and di.MType='普通子件' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as assemOutTotal,
sum(if(dh.SubType='拆卸单' and di.MType='普通子件' and di.DepotId=#{depotId},di.BasicNumber,0)) as disAssemInTotal, sum(if(dh.SubType='拆卸单' and di.MType='普通子件' <if test="depotId != null">and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as disAssemInTotal,
sum(if(dh.SubType='拆卸单' and di.MType='组合件' and di.DepotId=#{depotId},di.BasicNumber,0)) as disAssemOutTotal sum(if(dh.SubType='拆卸单' and di.MType='组合件' <if test="depotId != null"> and di.DepotId=#{depotId}</if>,di.BasicNumber,0)) as disAssemOutTotal
from from
jsh_depothead dh,jsh_depotitem di jsh_depothead dh,jsh_depotitem di
where 1=1 where 1=1
and dh.id=di.HeaderId and dh.id=di.HeaderId
and di.MaterialId=#{materialId} and di.MaterialId=#{materialId}
and ifnull(dh.delete_Flag,'0') !='1' and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1') curep and ifnull(di.delete_Flag,'0') !='1') as curep
</select> </select>
</mapper> </mapper>