优化报表的查询

This commit is contained in:
季圣华
2020-06-05 00:02:55 +08:00
parent c46ab52362
commit e8e43675fb
14 changed files with 225 additions and 394 deletions

View File

@@ -29,6 +29,18 @@
class="txt Wdate width-160" style="height: 30px;border: 1px solid #95B8E7;border-radius:5px;"/> class="txt Wdate width-160" style="height: 30px;border: 1px solid #95B8E7;border-radius:5px;"/>
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label">名称:</label>
<div class="control-inline">
<input name="mName" id="mName" style="width:100px;"></input>
</div>
</div>
<div class="form-group">
<label class="control-label">型号:</label>
<div class="control-inline">
<input type="text" name="mModel" id="mModel" class="easyui-textbox" style="width:100px;"></input>
</div>
</div>
<div class="form-group"> <div class="form-group">
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp; <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
@@ -43,6 +55,7 @@
$(function () { $(function () {
var thisDate = getNowFormatMonth(); //当前月份 var thisDate = getNowFormatMonth(); //当前月份
$("#searchMonth").val(thisDate); $("#searchMonth").val(thisDate);
initMaterialNameList();
initMProperty(); //初始化商品属性 initMProperty(); //初始化商品属性
initTableData(); initTableData();
ininPager(); ininPager();
@@ -50,6 +63,21 @@
print(); print();
}); });
//初始化商品名称模糊匹配
function initMaterialNameList() {
$('#mName').combobox({
method:"get",
url: "/material/getMaterialNameList",
valueField: 'value',
textField: 'text',
hasDownArrow: false,
filter: function(q, row){
var opts = $(this).combobox('options');
return row[opts.textField].indexOf(q) >-1;
}
});
}
//初始化商品属性 //初始化商品属性
function initMProperty() { function initMProperty() {
$.ajax({ $.ajax({
@@ -184,64 +212,20 @@
function showDetails(pageNo, pageSize) { function showDetails(pageNo, pageSize) {
$.ajax({ $.ajax({
type: "get", type: "post",
url: "/depotHead/findByMonth", url: "/depotItem/buyIn",
dataType: "json", dataType: "json",
data: ({ data: ({
monthTime: $("#searchMonth").val() currentPage: pageNo,
pageSize: pageSize,
monthTime: $("#searchMonth").val(),
name: $("#mName").combobox("getValue"),
model: $("#mModel").textbox("getValue"),
mpList: mPropertyList
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200 && res.data) { if (res && res.code === 200 && res.data) {
var HeadIds = res.data.HeadIds; $("#tableData").datagrid('loadData', res.data);
if (HeadIds) {
//获取排序后的产品ID
$.ajax({
type: "get",
url: "/material/findByOrder",
dataType: "json",
success: function (res) {
if(res && res.code === 200 && res.data) {
var mIds = res.data.mIds;
if (mIds) {
$.ajax({
type: "post",
url: "/depotItem/buyIn",
dataType: "json",
data: ({
currentPage: pageNo,
pageSize: pageSize,
monthTime: $("#searchMonth").val(),
headIds: HeadIds,
materialIds: mIds,
mpList: mPropertyList
}),
success: function (res) {
if (res && res.code === 200 && res.data) {
$("#tableData").datagrid('loadData', res.data);
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
else {
$.messager.alert('查询提示', '本月无数据!', 'error');
}
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
else {
$.messager.alert('查询提示', '本月无数据!', 'error');
}
} }
}, },
//此处添加错误处理 //此处添加错误处理

View File

@@ -316,112 +316,69 @@
}); });
function showEachDetails(pageNo, pageSize) { function showEachDetails(pageNo, pageSize) {
$.ajax({ if (pageSize === 3000) {
type: "get", window.location.href = "/depotItem/exportExcel?browserType=" + getOs()
url: "/depotHead/findByMonth", + "&currentPage=" + pageNo + "&pageSize=" + pageSize
dataType: "json", + "&depotId=" + $.trim($("#searchProjectId").val())
data: ({ + "&monthTime=" + $("#searchMonth").val()
monthTime: $("#searchMonth").val() + "&name=" + $("#mName").combobox("getValue")
}), + "&model=" + $("#mModel").textbox("getValue");
success: function (res) { }
if(res && res.code === 200 && res.data) { else {
var HeadIds = res.data.HeadIds; $.ajax({
if (HeadIds) { type: "post",
//获取排序后的产品ID url: "/depotItem/findByAll",
$.ajax({ dataType: "json",
type: "get", data: ({
url: "/material/findByOrder", currentPage: pageNo,
dataType: "json", pageSize: pageSize,
data: ({ depotId: $.trim($("#searchProjectId").val()),
name: $("#mName").combobox("getValue"), monthTime: $("#searchMonth").val(),
model: $("#mModel").textbox("getValue") name: $("#mName").combobox("getValue"),
}), model: $("#mModel").textbox("getValue"),
success: function (res) { mpList: mPropertyList
if(res && res.code === 200 && res.data) { }),
var mIds = res.data.mIds; success: function (res) {
if (mIds) { if(res && res.code === 200) {
if (pageSize === 3000) { $("#tableData").datagrid('loadData', res.data);
window.location.href = "/depotItem/exportExcel?browserType=" + getOs() + "&currentPage=" + pageNo + "&pageSize=" + pageSize + "&depotId=" + $.trim($("#searchProjectId").val()) + "&monthTime=" + $("#searchMonth").val() + "&headIds=" + HeadIds + "&materialIds=" + mIds;
}
else {
$.ajax({
type: "post",
url: "/depotItem/findByAll",
dataType: "json",
data: ({
currentPage: pageNo,
pageSize: pageSize,
depotId: $.trim($("#searchProjectId").val()),
monthTime: $("#searchMonth").val(),
headIds: HeadIds,
materialIds: mIds,
mpList: mPropertyList
}),
success: function (res) {
if(res && res.code === 200) {
$("#tableData").datagrid('loadData', res.data);
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
//总金额
$.ajax({
type: "post",
url: "/depotItem/totalCountMoney",
dataType: "json",
data: ({
depotId: $.trim($("#searchProjectId").val()),
monthTime: $("#searchMonth").val(),
headIds: HeadIds,
materialIds: mIds
}),
success: function (res) {
if(res && res.code === 200) {
if(res.data && res.data.totalCount) {
var count = res.data.totalCount.toString();
if (count.lastIndexOf('.') > -1) {
count = count.substring(0, count.lastIndexOf('.') + 3);
}
$("#tablePanel .total-count").text("本月合计金额:" + count + "");//本月合计金额
}
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
}
else {
$.messager.alert('查询提示', '本月无数据!', 'error');
}
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
else {
$.messager.alert('查询提示', '本月无数据!', 'error');
} }
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
} }
}, });
//此处添加错误处理
error: function () { //总金额
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error'); $.ajax({
return; type: "post",
} url: "/depotItem/totalCountMoney",
}); dataType: "json",
data: ({
depotId: $.trim($("#searchProjectId").val()),
monthTime: $("#searchMonth").val(),
name: $("#mName").combobox("getValue"),
model: $("#mModel").textbox("getValue")
}),
success: function (res) {
if(res && res.code === 200) {
if(res.data && res.data.totalCount) {
var count = res.data.totalCount.toString();
if (count.lastIndexOf('.') > -1) {
count = count.substring(0, count.lastIndexOf('.') + 3);
}
$("#tablePanel .total-count").text("本月合计金额:" + count + "");//本月合计金额
}
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
} }
//报表打印 //报表打印

View File

@@ -29,6 +29,18 @@
class="txt Wdate width-160" style="height: 30px;border: 1px solid #95B8E7;border-radius:5px;"/> class="txt Wdate width-160" style="height: 30px;border: 1px solid #95B8E7;border-radius:5px;"/>
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label">名称:</label>
<div class="control-inline">
<input name="mName" id="mName" style="width:100px;"></input>
</div>
</div>
<div class="form-group">
<label class="control-label">型号:</label>
<div class="control-inline">
<input type="text" name="mModel" id="mModel" class="easyui-textbox" style="width:100px;"></input>
</div>
</div>
<div class="form-group"> <div class="form-group">
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp; <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
@@ -47,6 +59,7 @@
$("#searchTable .tip").css("padding-left", "15px").css("color", "red"); $("#searchTable .tip").css("padding-left", "15px").css("color", "red");
var thisDate = getNowFormatMonth(); //当前月份 var thisDate = getNowFormatMonth(); //当前月份
$("#searchMonth").val(thisDate); $("#searchMonth").val(thisDate);
initMaterialNameList();
initMProperty(); //初始化商品属性 initMProperty(); //初始化商品属性
initTableData(); initTableData();
ininPager(); ininPager();
@@ -54,6 +67,21 @@
print(); print();
}); });
//初始化商品名称模糊匹配
function initMaterialNameList() {
$('#mName').combobox({
method:"get",
url: "/material/getMaterialNameList",
valueField: 'value',
textField: 'text',
hasDownArrow: false,
filter: function(q, row){
var opts = $(this).combobox('options');
return row[opts.textField].indexOf(q) >-1;
}
});
}
//初始化商品属性 //初始化商品属性
function initMProperty() { function initMProperty() {
$.ajax({ $.ajax({
@@ -191,72 +219,28 @@
function showDetails(pageNo, pageSize) { function showDetails(pageNo, pageSize) {
$.ajax({ $.ajax({
type: "get", type: "post",
url: "/depotHead/findByMonth", url: "/depotItem/saleOut",
dataType: "json", dataType: "json",
data: ({ data: ({
monthTime: $("#searchMonth").val() currentPage: pageNo,
pageSize: pageSize,
monthTime: $("#searchMonth").val(),
name: $("#mName").combobox("getValue"),
model: $("#mModel").textbox("getValue"),
mpList: mPropertyList
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200 && res.data) { if (res && res.code === 200) {
var HeadIds = res.data.HeadIds; $("#tableData").datagrid('loadData', res.data);
if (HeadIds) {
//获取排序后的产品ID
$.ajax({
type: "get",
url: "/material/findByOrder",
dataType: "json",
success: function (res) {
if (res && res.code === 200 && res.data) {
var mIds = res.data.mIds;
if (mIds) {
$.ajax({
type: "post",
url: "/depotItem/saleOut",
dataType: "json",
data: ({
currentPage: pageNo,
pageSize: pageSize,
monthTime: $("#searchMonth").val(),
headIds: HeadIds,
materialIds: mIds,
mpList: mPropertyList
}),
success: function (res) {
if (res && res.code === 200) {
$("#tableData").datagrid('loadData', res.data);
}
var total = 0;
res.data.rows.forEach(function(value, index, array){
//执行某些操作
total += value.OutInSumPrice;
})
$(".first-total").text(total); //当前总余额
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
else {
$.messager.alert('查询提示', '本月无数据!', 'error');
}
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
else {
$.messager.alert('查询提示', '本月无数据!', 'error');
}
} }
var total = 0;
res.data.rows.forEach(function(value, index, array){
//执行某些操作
total += value.OutInSumPrice;
})
$(".first-total").text(total); //当前总余额
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {

View File

@@ -109,39 +109,6 @@ public class DepotHeadController {
return res; return res;
} }
/**
* 查找单据_根据月份(报表)
* @param monthTime
* @param request
* @return
*/
@GetMapping(value = "/findByMonth")
public BaseResponseInfo findByMonth(@RequestParam("monthTime") String monthTime,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<DepotHead> dataList = depotHeadService.findByMonth(monthTime);
String headId = "";
if (null != dataList) {
for (DepotHead depotHead : dataList) {
headId = headId + depotHead.getId() + ",";
}
}
if (headId != "") {
headId = headId.substring(0, headId.lastIndexOf(","));
}
map.put("HeadIds", headId);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/** /**
* 入库出库明细接口 * 入库出库明细接口
* @param currentPage * @param currentPage

View File

@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@@ -258,17 +259,20 @@ public class DepotItemController {
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageSize") Integer pageSize,
@RequestParam("depotId") Long depotId, @RequestParam("depotId") Long depotId,
@RequestParam("monthTime") String monthTime, @RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds, @RequestParam("name") String name,
@RequestParam("materialIds") String materialIds, @RequestParam("model") String model,
@RequestParam("mpList") String mpList, @RequestParam("mpList") String mpList,
HttpServletRequest request)throws Exception { HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString()); Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
String timeA = monthTime+"-01 00:00:00";
String timeB = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try { try {
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize); List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(name), StringUtil.toNull(model),
timeB,(currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(","); String[] mpArr = mpList.split(",");
int total = depotItemService.findByAllCount(headIds, materialIds); int total = depotItemService.findByAllCount(StringUtil.toNull(name), timeB, StringUtil.toNull(model));
map.put("total", total); map.put("total", total);
//存放数据json数组 //存放数据json数组
JSONArray dataArray = new JSONArray(); JSONArray dataArray = new JSONArray();
@@ -281,8 +285,6 @@ public class DepotItemController {
for (DepotItemVo4WithInfoEx diEx : dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
Long mId = diEx.getMId(); Long mId = diEx.getMId();
String timeA = monthTime+"-01 00:00:00";
String timeB = monthTime+"-31 23:59:59";
item.put("MaterialName", diEx.getMName()); item.put("MaterialName", diEx.getMName());
item.put("MaterialModel", diEx.getMModel()); item.put("MaterialModel", diEx.getMModel());
//扩展信息 //扩展信息
@@ -294,7 +296,7 @@ public class DepotItemController {
item.put("prevSum", depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId)); item.put("prevSum", depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId));
item.put("InSum", depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId)); item.put("InSum", depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId));
item.put("OutSum", depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId)); item.put("OutSum", depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId));
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,null,tenantId); BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,timeB,tenantId);
item.put("thisSum", thisSum); item.put("thisSum", thisSum);
for(MaterialExtend me:meList) { for(MaterialExtend me:meList) {
if(me.getMaterialId().longValue() == diEx.getMId().longValue()) { if(me.getMaterialId().longValue() == diEx.getMId().longValue()) {
@@ -336,12 +338,15 @@ public class DepotItemController {
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageSize") Integer pageSize,
@RequestParam("depotId") Long depotId, @RequestParam("depotId") Long depotId,
@RequestParam("monthTime") String monthTime, @RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds, @RequestParam("name") String name,
@RequestParam("materialIds") String materialIds, @RequestParam("model") String model,
HttpServletRequest request, HttpServletResponse response) { HttpServletRequest request, HttpServletResponse response) throws Exception {
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString()); Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
String timeA = monthTime+"-01 00:00:00";
String timeB = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try { try {
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize); List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(name), StringUtil.toNull(model),
timeB, (currentPage-1)*pageSize, pageSize);
//存放数据json数组 //存放数据json数组
String[] names = {"名称", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"}; String[] names = {"名称", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
String title = "库存报表"; String title = "库存报表";
@@ -349,8 +354,6 @@ public class DepotItemController {
if (null != dataList) { if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) {
Long mId = diEx.getMId(); Long mId = diEx.getMId();
String timeA = monthTime+"-01 00:00:00";
String timeB = monthTime+"-31 23:59:59";
String[] objs = new String[9]; String[] objs = new String[9];
objs[0] = diEx.getMName().toString(); objs[0] = diEx.getMName().toString();
objs[1] = diEx.getMModel().toString(); objs[1] = diEx.getMModel().toString();
@@ -359,7 +362,7 @@ public class DepotItemController {
objs[4] = depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId).toString(); objs[4] = depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId).toString();
objs[5] = depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId).toString(); objs[5] = depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
objs[6] = depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId).toString(); objs[6] = depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,null,tenantId); BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,timeB,tenantId);
objs[7] = thisSum.toString(); objs[7] = thisSum.toString();
objs[8] = thisSum.multiply(getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy())).toString(); objs[8] = thisSum.multiply(getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy())).toString();
objects.add(objs); objects.add(objs);
@@ -384,20 +387,22 @@ public class DepotItemController {
@PostMapping(value = "/totalCountMoney") @PostMapping(value = "/totalCountMoney")
public BaseResponseInfo totalCountMoney(@RequestParam("depotId") Long depotId, public BaseResponseInfo totalCountMoney(@RequestParam("depotId") Long depotId,
@RequestParam("monthTime") String monthTime, @RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds, @RequestParam("name") String name,
@RequestParam("materialIds") String materialIds, @RequestParam("model") String model,
HttpServletRequest request) throws Exception{ HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString()); Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try { try {
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, null, null); List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(name), StringUtil.toNull(model),
endTime, null, null);
BigDecimal thisAllPrice = BigDecimal.ZERO; BigDecimal thisAllPrice = BigDecimal.ZERO;
if (null != dataList) { if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) {
Long mId = diEx.getMId(); Long mId = diEx.getMId();
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,null,tenantId); BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,endTime,tenantId);
BigDecimal unitPrice = getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy()); BigDecimal unitPrice = diEx.getPurchaseDecimal();
thisAllPrice = thisAllPrice.add(thisSum.multiply(unitPrice)); thisAllPrice = thisAllPrice.add(thisSum.multiply(unitPrice));
} }
} }
@@ -427,16 +432,18 @@ public class DepotItemController {
public BaseResponseInfo buyIn(@RequestParam("currentPage") Integer currentPage, public BaseResponseInfo buyIn(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageSize") Integer pageSize,
@RequestParam("monthTime") String monthTime, @RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds, @RequestParam("name") String name,
@RequestParam("materialIds") String materialIds, @RequestParam("model") String model,
@RequestParam("mpList") String mpList, @RequestParam("mpList") String mpList,
HttpServletRequest request)throws Exception { HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try { try {
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize); List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(name), StringUtil.toNull(model),
endTime, (currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(","); String[] mpArr = mpList.split(",");
int total = depotItemService.findByAllCount(headIds, materialIds); int total = depotItemService.findByAllCount(StringUtil.toNull(name), StringUtil.toNull(model), endTime);
map.put("total", total); map.put("total", total);
//存放数据json数组 //存放数据json数组
JSONArray dataArray = new JSONArray(); JSONArray dataArray = new JSONArray();
@@ -488,16 +495,18 @@ public class DepotItemController {
public BaseResponseInfo saleOut(@RequestParam("currentPage") Integer currentPage, public BaseResponseInfo saleOut(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageSize") Integer pageSize,
@RequestParam("monthTime") String monthTime, @RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds, @RequestParam("name") String name,
@RequestParam("materialIds") String materialIds, @RequestParam("model") String model,
@RequestParam("mpList") String mpList, @RequestParam("mpList") String mpList,
HttpServletRequest request)throws Exception { HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try { try {
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize); List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(name), StringUtil.toNull(model),
endTime,(currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(","); String[] mpArr = mpList.split(",");
int total = depotItemService.findByAllCount(headIds, materialIds); int total = depotItemService.findByAllCount(StringUtil.toNull(name), StringUtil.toNull(model), endTime);
map.put("total", total); map.put("total", total);
//存放数据json数组 //存放数据json数组
JSONArray dataArray = new JSONArray(); JSONArray dataArray = new JSONArray();

View File

@@ -208,40 +208,6 @@ public class MaterialController {
return object; return object;
} }
/**
* 查找商品信息-统计排序
* @param request
* @return
*/
@GetMapping(value = "/findByOrder")
public BaseResponseInfo findByOrder(@RequestParam("name") String name,
@RequestParam("model") String model,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Material> dataList = materialService.findByOrder(StringUtil.toNull(name), StringUtil.toNull(model));
String mId = "";
if (null != dataList) {
for (Material material : dataList) {
mId = mId + material.getId() + ",";
}
}
if (mId != "") {
mId = mId.substring(0, mId.lastIndexOf(","));
}
map.put("mIds", mId);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/** /**
* 根据商品id查找商品信息 * 根据商品id查找商品信息
* @param meId * @param meId

View File

@@ -40,14 +40,16 @@ public interface DepotItemMapperEx {
@Param("headerId") Long headerId); @Param("headerId") Long headerId);
List<DepotItemVo4WithInfoEx> findByAll( List<DepotItemVo4WithInfoEx> findByAll(
@Param("headIds") String headIds, @Param("name") String name,
@Param("materialIds") String materialIds, @Param("model") String model,
@Param("endTime") String endTime,
@Param("offset") Integer offset, @Param("offset") Integer offset,
@Param("rows") Integer rows); @Param("rows") Integer rows);
int findByAllCount( int findByAllCount(
@Param("headIds") String headIds, @Param("name") String name,
@Param("materialIds") String materialIds); @Param("model") String model,
@Param("endTime") String endTime);
BigDecimal buyOrSaleNumber( BigDecimal buyOrSaleNumber(
@Param("type") String type, @Param("type") String type,

View File

@@ -41,8 +41,6 @@ public interface MaterialMapperEx {
List<MaterialVo4Unit> findByIdWithBarCode(@Param("meId") Long meId); List<MaterialVo4Unit> findByIdWithBarCode(@Param("meId") Long meId);
List<MaterialVo4Unit> findBySelect();
List<MaterialVo4Unit> findBySelectWithBarCode(@Param("q") String q, List<MaterialVo4Unit> findBySelectWithBarCode(@Param("q") String q,
@Param("offset") Integer offset, @Param("offset") Integer offset,
@Param("rows") Integer rows); @Param("rows") Integer rows);
@@ -76,7 +74,4 @@ public interface MaterialMapperEx {
@Param("meId") Long meId); @Param("meId") Long meId);
List<String> getMaterialNameList(); List<String> getMaterialNameList();
List<Material> findByOrder(@Param("name") String name,
@Param("model") String model);
} }

View File

@@ -285,20 +285,6 @@ public class DepotHeadService {
return result; return result;
} }
public List<DepotHead> findByMonth(String monthTime)throws Exception {
DepotHeadExample example = new DepotHeadExample();
monthTime = monthTime + "-31 23:59:59";
Date month = StringUtil.getDateByString(monthTime, null);
example.createCriteria().andOpertimeLessThanOrEqualTo(month).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<DepotHead> list = null;
try{
list = depotHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) throws Exception{ public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) throws Exception{
List<DepotHeadVo4InDetail> list = null; List<DepotHeadVo4InDetail> list = null;
try{ try{

View File

@@ -234,20 +234,20 @@ public class DepotItemService {
return list; return list;
} }
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows)throws Exception { public List<DepotItemVo4WithInfoEx> findByAll(String name, String model, String endTime, Integer offset, Integer rows)throws Exception {
List<DepotItemVo4WithInfoEx> list =null; List<DepotItemVo4WithInfoEx> list =null;
try{ try{
list = depotItemMapperEx.findByAll(headIds, materialIds, offset, rows); list = depotItemMapperEx.findByAll(name, model, endTime, offset, rows);
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
return list; return list;
} }
public int findByAllCount(String headIds, String materialIds)throws Exception { public int findByAllCount(String name, String model, String endTime)throws Exception {
int result=0; int result=0;
try{ try{
result = depotItemMapperEx.findByAllCount(headIds, materialIds); result = depotItemMapperEx.findByAllCount(name, model, endTime);
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }

View File

@@ -317,26 +317,6 @@ public class MaterialService {
return list; return list;
} }
public List<MaterialVo4Unit> findBySelect()throws Exception{
List<MaterialVo4Unit> list =null;
try{
list= materialMapperEx.findBySelect();
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Material> findByOrder(String name, String model)throws Exception{
List<Material> list =null;
try{
list= materialMapperEx.findByOrder(name, model);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<MaterialVo4Unit> findBySelectWithBarCode(String q,Integer offset, Integer rows)throws Exception{ public List<MaterialVo4Unit> findBySelectWithBarCode(String q,Integer offset, Integer rows)throws Exception{
List<MaterialVo4Unit> list =null; List<MaterialVo4Unit> list =null;
try{ try{

View File

@@ -459,6 +459,20 @@ public class Tools {
return new SimpleDateFormat("yyyy-MM").format(c.getTime()); return new SimpleDateFormat("yyyy-MM").format(c.getTime());
} }
/**
* 根据月份获取当月最后一天
* @param monthTime
* @return
* @throws ParseException
*/
public static String lastDayOfMonth(String monthTime) throws ParseException {
Date date = new SimpleDateFormat("yyyy-MM").parse(monthTime);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.roll(Calendar.DAY_OF_MONTH, -1);
return new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
}
/** /**
* 获取email用户姓名 * 获取email用户姓名

View File

@@ -149,20 +149,25 @@
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial"> <select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
select m.id MId, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor, select m.id MId, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor,
me.purchase_decimal, u.UName UName me.purchase_decimal, u.UName UName
from jsh_depotitem di from jsh_material m
inner join jsh_material m on di.MaterialId=m.id and ifnull(m.delete_Flag,'0') !='1' left join jsh_depotitem di on di.MaterialId=m.id and ifnull(m.delete_Flag,'0') !='1'
left join jsh_depothead dh on di.HeaderId=dh.id and ifnull(dh.delete_Flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1' left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_unit u on m.UnitId=u.id and ifnull(u.delete_Flag,'0') !='1' left join jsh_unit u on m.UnitId=u.id and ifnull(u.delete_Flag,'0') !='1'
where 1=1 where 1=1
and me.default_flag=1 and me.default_flag=1
<if test="headIds != null"> <if test="name != null">
and di.HeaderId in (${headIds}) and m.name like '%${name}%'
</if> </if>
<if test="materialIds != null"> <if test="model != null">
and di.MaterialId in (${materialIds}) and m.model like '%${model}%'
</if>
<if test="endTime != null">
and dh.OperTime &lt;= '${endTime}'
</if> </if>
and ifnull(di.delete_Flag,'0') !='1' and ifnull(di.delete_Flag,'0') !='1'
group by m.id,m.Name, m.Model, m.Unit, m.Color, me.purchase_decimal, u.UName group by m.id,m.Name, m.Model, m.Unit, m.Color, me.purchase_decimal, u.UName
order by m.Name, m.Model asc
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
limit #{offset},#{rows} limit #{offset},#{rows}
</if> </if>
@@ -170,14 +175,18 @@
<select id="findByAllCount" resultType="java.lang.Integer"> <select id="findByAllCount" resultType="java.lang.Integer">
select count(1) from (select m.id select count(1) from (select m.id
from jsh_depotitem di from jsh_material m
inner join jsh_material m on di.MaterialId=m.id and ifnull(m.delete_Flag,'0') !='1' left join jsh_depotitem di on di.MaterialId=m.id and ifnull(m.delete_Flag,'0') !='1'
left join jsh_depothead dh on di.HeaderId=dh.id and ifnull(dh.delete_Flag,'0') !='1'
where 1=1 where 1=1
<if test="headIds != null"> <if test="name != null">
and di.HeaderId in (${headIds}) and m.name like '%${name}%'
</if> </if>
<if test="materialIds != null"> <if test="model != null">
and di.MaterialId in (${materialIds}) and m.model like '%${model}%'
</if>
<if test="endTime != null">
and dh.OperTime &lt;= '${endTime}'
</if> </if>
and ifnull(di.delete_Flag,'0') !='1' and ifnull(di.delete_Flag,'0') !='1'
group by m.id) cc group by m.id) cc

View File

@@ -97,14 +97,6 @@
and ifnull(m.delete_Flag,'0') !='1' and ifnull(m.delete_Flag,'0') !='1'
</select> </select>
<select id="findBySelect" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
select m.*,u.UName from jsh_material m
left join jsh_unit u on m.UnitId=u.id and ifnull(u.delete_Flag,'0') !='1'
where m.enabled=1
and ifnull(m.delete_Flag,'0') !='1'
ORDER BY Id desc
</select>
<select id="findBySelectWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap"> <select id="findBySelectWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
select m.*,u.UName,me.bar_code m_bar_code,me.id meId,me.commodity_unit from jsh_material m select m.*,u.UName,me.bar_code m_bar_code,me.id meId,me.commodity_unit 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'
@@ -258,18 +250,4 @@
group by m.name group by m.name
order by m.name asc order by m.name asc
</select> </select>
<select id="findByOrder" resultType="com.jsh.erp.datasource.entities.Material">
select m.*
FROM jsh_material m
where 1=1
<if test="name != null">
and m.name like '%${name}%'
</if>
<if test="model != null">
and m.model like '%${model}%'
</if>
and ifnull(m.delete_Flag,'0') !='1'
order by m.name,m.model asc
</select>
</mapper> </mapper>