优化报表的查询
This commit is contained in:
@@ -29,6 +29,18 @@
|
||||
class="txt Wdate width-160" style="height: 30px;border: 1px solid #95B8E7;border-radius:5px;"/>
|
||||
</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">
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
|
||||
@@ -43,6 +55,7 @@
|
||||
$(function () {
|
||||
var thisDate = getNowFormatMonth(); //当前月份
|
||||
$("#searchMonth").val(thisDate);
|
||||
initMaterialNameList();
|
||||
initMProperty(); //初始化商品属性
|
||||
initTableData();
|
||||
ininPager();
|
||||
@@ -50,6 +63,21 @@
|
||||
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() {
|
||||
$.ajax({
|
||||
@@ -184,64 +212,20 @@
|
||||
|
||||
function showDetails(pageNo, pageSize) {
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/depotHead/findByMonth",
|
||||
type: "post",
|
||||
url: "/depotItem/buyIn",
|
||||
dataType: "json",
|
||||
data: ({
|
||||
monthTime: $("#searchMonth").val()
|
||||
currentPage: pageNo,
|
||||
pageSize: pageSize,
|
||||
monthTime: $("#searchMonth").val(),
|
||||
name: $("#mName").combobox("getValue"),
|
||||
model: $("#mModel").textbox("getValue"),
|
||||
mpList: mPropertyList
|
||||
}),
|
||||
success: function (res) {
|
||||
if(res && res.code === 200 && res.data) {
|
||||
var HeadIds = res.data.HeadIds;
|
||||
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');
|
||||
}
|
||||
if (res && res.code === 200 && res.data) {
|
||||
$("#tableData").datagrid('loadData', res.data);
|
||||
}
|
||||
},
|
||||
//此处添加错误处理
|
||||
|
||||
@@ -316,112 +316,69 @@
|
||||
});
|
||||
|
||||
function showEachDetails(pageNo, pageSize) {
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/depotHead/findByMonth",
|
||||
dataType: "json",
|
||||
data: ({
|
||||
monthTime: $("#searchMonth").val()
|
||||
}),
|
||||
success: function (res) {
|
||||
if(res && res.code === 200 && res.data) {
|
||||
var HeadIds = res.data.HeadIds;
|
||||
if (HeadIds) {
|
||||
//获取排序后的产品ID
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/material/findByOrder",
|
||||
dataType: "json",
|
||||
data: ({
|
||||
name: $("#mName").combobox("getValue"),
|
||||
model: $("#mModel").textbox("getValue")
|
||||
}),
|
||||
success: function (res) {
|
||||
if(res && res.code === 200 && res.data) {
|
||||
var mIds = res.data.mIds;
|
||||
if (mIds) {
|
||||
if (pageSize === 3000) {
|
||||
window.location.href = "/depotItem/exportExcel?browserType=" + getOs() + "¤tPage=" + 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');
|
||||
if (pageSize === 3000) {
|
||||
window.location.href = "/depotItem/exportExcel?browserType=" + getOs()
|
||||
+ "¤tPage=" + pageNo + "&pageSize=" + pageSize
|
||||
+ "&depotId=" + $.trim($("#searchProjectId").val())
|
||||
+ "&monthTime=" + $("#searchMonth").val()
|
||||
+ "&name=" + $("#mName").combobox("getValue")
|
||||
+ "&model=" + $("#mModel").textbox("getValue");
|
||||
}
|
||||
else {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/depotItem/findByAll",
|
||||
dataType: "json",
|
||||
data: ({
|
||||
currentPage: pageNo,
|
||||
pageSize: pageSize,
|
||||
depotId: $.trim($("#searchProjectId").val()),
|
||||
monthTime: $("#searchMonth").val(),
|
||||
name: $("#mName").combobox("getValue"),
|
||||
model: $("#mModel").textbox("getValue"),
|
||||
mpList: mPropertyList
|
||||
}),
|
||||
success: function (res) {
|
||||
if(res && res.code === 200) {
|
||||
$("#tableData").datagrid('loadData', res.data);
|
||||
}
|
||||
},
|
||||
//此处添加错误处理
|
||||
error: function () {
|
||||
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
|
||||
return;
|
||||
}
|
||||
},
|
||||
//此处添加错误处理
|
||||
error: function () {
|
||||
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//总金额
|
||||
$.ajax({
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//报表打印
|
||||
|
||||
@@ -29,6 +29,18 @@
|
||||
class="txt Wdate width-160" style="height: 30px;border: 1px solid #95B8E7;border-radius:5px;"/>
|
||||
</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">
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</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");
|
||||
var thisDate = getNowFormatMonth(); //当前月份
|
||||
$("#searchMonth").val(thisDate);
|
||||
initMaterialNameList();
|
||||
initMProperty(); //初始化商品属性
|
||||
initTableData();
|
||||
ininPager();
|
||||
@@ -54,6 +67,21 @@
|
||||
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() {
|
||||
$.ajax({
|
||||
@@ -191,72 +219,28 @@
|
||||
|
||||
function showDetails(pageNo, pageSize) {
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/depotHead/findByMonth",
|
||||
type: "post",
|
||||
url: "/depotItem/saleOut",
|
||||
dataType: "json",
|
||||
data: ({
|
||||
monthTime: $("#searchMonth").val()
|
||||
currentPage: pageNo,
|
||||
pageSize: pageSize,
|
||||
monthTime: $("#searchMonth").val(),
|
||||
name: $("#mName").combobox("getValue"),
|
||||
model: $("#mModel").textbox("getValue"),
|
||||
mpList: mPropertyList
|
||||
}),
|
||||
success: function (res) {
|
||||
if(res && res.code === 200 && res.data) {
|
||||
var HeadIds = res.data.HeadIds;
|
||||
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');
|
||||
}
|
||||
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 () {
|
||||
|
||||
@@ -109,39 +109,6 @@ public class DepotHeadController {
|
||||
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
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -258,17 +259,20 @@ public class DepotItemController {
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
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 {
|
||||
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(",");
|
||||
int total = depotItemService.findByAllCount(headIds, materialIds);
|
||||
int total = depotItemService.findByAllCount(StringUtil.toNull(name), timeB, StringUtil.toNull(model));
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
@@ -281,8 +285,6 @@ public class DepotItemController {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
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("MaterialModel", diEx.getMModel());
|
||||
//扩展信息
|
||||
@@ -294,7 +296,7 @@ public class DepotItemController {
|
||||
item.put("prevSum", depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId));
|
||||
item.put("InSum", depotItemService.getInNumByParam(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);
|
||||
for(MaterialExtend me:meList) {
|
||||
if(me.getMaterialId().longValue() == diEx.getMId().longValue()) {
|
||||
@@ -336,12 +338,15 @@ public class DepotItemController {
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
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 {
|
||||
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数组
|
||||
String[] names = {"名称", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
|
||||
String title = "库存报表";
|
||||
@@ -349,8 +354,6 @@ public class DepotItemController {
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
Long mId = diEx.getMId();
|
||||
String timeA = monthTime+"-01 00:00:00";
|
||||
String timeB = monthTime+"-31 23:59:59";
|
||||
String[] objs = new String[9];
|
||||
objs[0] = diEx.getMName().toString();
|
||||
objs[1] = diEx.getMModel().toString();
|
||||
@@ -359,7 +362,7 @@ public class DepotItemController {
|
||||
objs[4] = depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId).toString();
|
||||
objs[5] = depotItemService.getInNumByParam(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[8] = thisSum.multiply(getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy())).toString();
|
||||
objects.add(objs);
|
||||
@@ -384,20 +387,22 @@ public class DepotItemController {
|
||||
@PostMapping(value = "/totalCountMoney")
|
||||
public BaseResponseInfo totalCountMoney(@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
|
||||
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
|
||||
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;
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
Long mId = diEx.getMId();
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,null,tenantId);
|
||||
BigDecimal unitPrice = getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy());
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,endTime,tenantId);
|
||||
BigDecimal unitPrice = diEx.getPurchaseDecimal();
|
||||
thisAllPrice = thisAllPrice.add(thisSum.multiply(unitPrice));
|
||||
}
|
||||
}
|
||||
@@ -427,16 +432,18 @@ public class DepotItemController {
|
||||
public BaseResponseInfo buyIn(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
|
||||
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(",");
|
||||
int total = depotItemService.findByAllCount(headIds, materialIds);
|
||||
int total = depotItemService.findByAllCount(StringUtil.toNull(name), StringUtil.toNull(model), endTime);
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
@@ -488,16 +495,18 @@ public class DepotItemController {
|
||||
public BaseResponseInfo saleOut(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
|
||||
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(",");
|
||||
int total = depotItemService.findByAllCount(headIds, materialIds);
|
||||
int total = depotItemService.findByAllCount(StringUtil.toNull(name), StringUtil.toNull(model), endTime);
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
|
||||
@@ -208,40 +208,6 @@ public class MaterialController {
|
||||
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查找商品信息
|
||||
* @param meId
|
||||
|
||||
@@ -40,14 +40,16 @@ public interface DepotItemMapperEx {
|
||||
@Param("headerId") Long headerId);
|
||||
|
||||
List<DepotItemVo4WithInfoEx> findByAll(
|
||||
@Param("headIds") String headIds,
|
||||
@Param("materialIds") String materialIds,
|
||||
@Param("name") String name,
|
||||
@Param("model") String model,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("rows") Integer rows);
|
||||
|
||||
int findByAllCount(
|
||||
@Param("headIds") String headIds,
|
||||
@Param("materialIds") String materialIds);
|
||||
@Param("name") String name,
|
||||
@Param("model") String model,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
BigDecimal buyOrSaleNumber(
|
||||
@Param("type") String type,
|
||||
|
||||
@@ -41,8 +41,6 @@ public interface MaterialMapperEx {
|
||||
|
||||
List<MaterialVo4Unit> findByIdWithBarCode(@Param("meId") Long meId);
|
||||
|
||||
List<MaterialVo4Unit> findBySelect();
|
||||
|
||||
List<MaterialVo4Unit> findBySelectWithBarCode(@Param("q") String q,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("rows") Integer rows);
|
||||
@@ -76,7 +74,4 @@ public interface MaterialMapperEx {
|
||||
@Param("meId") Long meId);
|
||||
|
||||
List<String> getMaterialNameList();
|
||||
|
||||
List<Material> findByOrder(@Param("name") String name,
|
||||
@Param("model") String model);
|
||||
}
|
||||
|
||||
@@ -285,20 +285,6 @@ public class DepotHeadService {
|
||||
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{
|
||||
List<DepotHeadVo4InDetail> list = null;
|
||||
try{
|
||||
|
||||
@@ -234,20 +234,20 @@ public class DepotItemService {
|
||||
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;
|
||||
try{
|
||||
list = depotItemMapperEx.findByAll(headIds, materialIds, offset, rows);
|
||||
list = depotItemMapperEx.findByAll(name, model, endTime, offset, rows);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
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;
|
||||
try{
|
||||
result = depotItemMapperEx.findByAllCount(headIds, materialIds);
|
||||
result = depotItemMapperEx.findByAllCount(name, model, endTime);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
|
||||
@@ -317,26 +317,6 @@ public class MaterialService {
|
||||
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{
|
||||
List<MaterialVo4Unit> list =null;
|
||||
try{
|
||||
|
||||
@@ -459,6 +459,20 @@ public class Tools {
|
||||
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用户姓名
|
||||
|
||||
@@ -149,20 +149,25 @@
|
||||
<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,
|
||||
me.purchase_decimal, u.UName UName
|
||||
from jsh_depotitem di
|
||||
inner join jsh_material m on di.MaterialId=m.id and ifnull(m.delete_Flag,'0') !='1'
|
||||
from jsh_material m
|
||||
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_unit u on m.UnitId=u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||
where 1=1
|
||||
and me.default_flag=1
|
||||
<if test="headIds != null">
|
||||
and di.HeaderId in (${headIds})
|
||||
<if test="name != null">
|
||||
and m.name like '%${name}%'
|
||||
</if>
|
||||
<if test="materialIds != null">
|
||||
and di.MaterialId in (${materialIds})
|
||||
<if test="model != null">
|
||||
and m.model like '%${model}%'
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and dh.OperTime <= '${endTime}'
|
||||
</if>
|
||||
and ifnull(di.delete_Flag,'0') !='1'
|
||||
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">
|
||||
limit #{offset},#{rows}
|
||||
</if>
|
||||
@@ -170,14 +175,18 @@
|
||||
|
||||
<select id="findByAllCount" resultType="java.lang.Integer">
|
||||
select count(1) from (select m.id
|
||||
from jsh_depotitem di
|
||||
inner join jsh_material m on di.MaterialId=m.id and ifnull(m.delete_Flag,'0') !='1'
|
||||
from jsh_material m
|
||||
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
|
||||
<if test="headIds != null">
|
||||
and di.HeaderId in (${headIds})
|
||||
<if test="name != null">
|
||||
and m.name like '%${name}%'
|
||||
</if>
|
||||
<if test="materialIds != null">
|
||||
and di.MaterialId in (${materialIds})
|
||||
<if test="model != null">
|
||||
and m.model like '%${model}%'
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and dh.OperTime <= '${endTime}'
|
||||
</if>
|
||||
and ifnull(di.delete_Flag,'0') !='1'
|
||||
group by m.id) cc
|
||||
|
||||
@@ -97,14 +97,6 @@
|
||||
and ifnull(m.delete_Flag,'0') !='1'
|
||||
</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 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'
|
||||
@@ -258,18 +250,4 @@
|
||||
group by m.name
|
||||
order by m.name asc
|
||||
</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>
|
||||
Reference in New Issue
Block a user