Commit e26dcac6 by guanzhenshan

完善进销存不合理报表和增加导出功能

parent c0945204
...@@ -4843,10 +4843,10 @@ group by currency"; ...@@ -4843,10 +4843,10 @@ group by currency";
/// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param> /// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param>
/// <param name="total">符合条件的总数</param> /// <param name="total">符合条件的总数</param>
/// <returns></returns> /// <returns></returns>
public List<dc_mid_month_sale_putin_report> ListMonthSalePutinDetail(BtTableParameter parameter, string month, string warehousetype, string warehouse, int? type,int? isclear,int? isnew,int? isaims,ref int total) public List<dc_mid_month_sale_putin_report> ListMonthSalePutinDetail(BtTableParameter parameter, string month, string warehousetype, string warehouse, int? type,int? isclear,int? isnew,int? isaims,ref int total,int isreasonable=-1)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = $@"select t1.warehouse_type,t1.warehouse_code,t1.warehouse_name,t1.bailun_sku,t1.count_putin,(t1.count_putin*t1.buyprice) amount_putin,t1.count_outbound,(t1.count_outbound*t1.buyprice) amount_outbound,(t1.count_putin-t1.count_outbound) count_diff,((t1.count_putin-t1.count_outbound)*t1.buyprice) amount_diff,t2.is_clear,t2.is_new,t2.is_aimsorder from dc_mid_month_sale_putin t1 var sql = $@"select t1.warehouse_type,t1.warehouse_code,t1.warehouse_name,t1.bailun_sku,t1.count_putin,(t1.count_putin*t1.buyprice) amount_putin,t1.count_outbound,(t1.count_outbound*t1.buyprice) amount_outbound,(t1.count_putin-t1.count_outbound) count_diff,((t1.count_putin-t1.count_outbound)*t1.buyprice) amount_diff,t2.is_clear,t2.is_new,t2.is_aimsorder,t2.count_usable_stock,t2.avg_sevenday_sales,t2.avg_fourteenday_sales,t2.avg_thirtyday_sales,t2.avg_sales from dc_mid_month_sale_putin t1
left join dc_mid_month_sale_putin_report t2 on t1.id=t2.sale_putin_id left join dc_mid_month_sale_putin_report t2 on t1.id=t2.sale_putin_id
where t1.`month`='{month}'"; where t1.`month`='{month}'";
...@@ -4910,6 +4910,16 @@ group by currency"; ...@@ -4910,6 +4910,16 @@ group by currency";
} }
} }
if (isreasonable == 0) //不合理
{
sql += " and t2.id is not null ";
}
if (!string.IsNullOrEmpty(parameter.sort))
{
sql += " order by "+parameter.sort+" "+parameter.order;
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString)) using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{ {
...@@ -4918,9 +4928,18 @@ group by currency"; ...@@ -4918,9 +4928,18 @@ group by currency";
cn.Open(); cn.Open();
} }
var obj = cn.Page<dc_mid_month_sale_putin_report>(parameter.pageIndex, parameter.limit, sql, ref total, sqlparam).ToList(); if (parameter.pageIndex > 0 && parameter.limit > 0)
{
var obj = cn.Page<dc_mid_month_sale_putin_report>(parameter.pageIndex, parameter.limit, sql, ref total, sqlparam).ToList();
return obj; return obj;
}
else
{
var obj = cn.Query<dc_mid_month_sale_putin_report>(sql,sqlparam).ToList();
return obj;
}
} }
} }
...@@ -4932,7 +4951,7 @@ group by currency"; ...@@ -4932,7 +4951,7 @@ group by currency";
/// <param name="warehouse">仓库编码</param> /// <param name="warehouse">仓库编码</param>
/// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param> /// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param>
/// <returns></returns> /// <returns></returns>
public dc_mid_month_sale_putin_report ListMonthSalePutinDetailCount(string month, string warehousetype, string warehouse, int? type, int? isclear, int? isnew, int? isaims) public dc_mid_month_sale_putin_report ListMonthSalePutinDetailCount(string month, string warehousetype, string warehouse, int? type, int? isclear, int? isnew, int? isaims, int isreasonable = -1)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = $@"select sum(t1.count_putin) count_putin,sum(t1.count_putin*t1.buyprice) amount_putin,sum(t1.count_outbound) count_outbound,sum(t1.count_outbound*t1.buyprice) amount_outbound,sum(t1.count_putin-t1.count_outbound) count_diff,sum((t1.count_putin-t1.count_outbound)*t1.buyprice) amount_diff from dc_mid_month_sale_putin t1 var sql = $@"select sum(t1.count_putin) count_putin,sum(t1.count_putin*t1.buyprice) amount_putin,sum(t1.count_outbound) count_outbound,sum(t1.count_outbound*t1.buyprice) amount_outbound,sum(t1.count_putin-t1.count_outbound) count_diff,sum((t1.count_putin-t1.count_outbound)*t1.buyprice) amount_diff from dc_mid_month_sale_putin t1
...@@ -4999,6 +5018,11 @@ group by currency"; ...@@ -4999,6 +5018,11 @@ group by currency";
} }
} }
if (isreasonable == 0) //不合理
{
sql += " and t2.id is not null ";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString)) using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{ {
if (cn.State == ConnectionState.Closed) if (cn.State == ConnectionState.Closed)
......
...@@ -6301,11 +6301,12 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -6301,11 +6301,12 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
/// <param name="month">月份</param> /// <param name="month">月份</param>
/// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param> /// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param>
/// <returns></returns> /// <returns></returns>
public ActionResult ListUnReasonable(string warehousetype, string month,int? type) public ActionResult ListUnReasonable(string warehousetype, string month,int? type,int isun=-1)
{ {
ViewBag.warehousetype = warehousetype; ViewBag.warehousetype = warehousetype;
ViewBag.month = month; ViewBag.month = (string.IsNullOrEmpty(month)?DateTime.Now.AddMonths(-1).ToString("yyyy-MM"):month);
ViewBag.type = type ?? -1; ViewBag.type = type ?? -1;
ViewBag.isun = isun;
return View(); return View();
} }
...@@ -6323,13 +6324,13 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -6323,13 +6324,13 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
/// <param name="isaims">是否aims下单</param> /// <param name="isaims">是否aims下单</param>
/// <returns></returns> /// <returns></returns>
[BailunAuthentication(LoginMode.Enforce)] [BailunAuthentication(LoginMode.Enforce)]
public string ListUnReasonableJson(BtTableParameter parameter, string month, string warehousetype,string warehouse,int? type,int? isclear,int? isnew,int? isaims) public string ListUnReasonableJson(BtTableParameter parameter, string month, string warehousetype,string warehouse,int? type,int? isclear,int? isnew,int? isaims,int isreasonable = -1)
{ {
var total = 0; var total = 0;
var _service = new Services.FinanceReportServices(); var _service = new Services.FinanceReportServices();
var obj = _service.ListMonthSalePutinDetail(parameter, month, warehousetype, warehouse, type, isclear, isnew, isaims, ref total); var obj = _service.ListMonthSalePutinDetail(parameter, month, warehousetype, warehouse, type, isclear, isnew, isaims, ref total, isreasonable);
var objCount = _service.ListMonthSalePutinDetailCount(month, warehousetype, warehouse, type, isclear, isnew, isaims); var objCount = _service.ListMonthSalePutinDetailCount(month, warehousetype, warehouse, type, isclear, isnew, isaims,isreasonable);
var list = obj.Select(a=> new { var list = obj.Select(a=> new {
a.warehouse_type, a.warehouse_type,
...@@ -6342,7 +6343,16 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -6342,7 +6343,16 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
a.count_putin, a.count_putin,
a.amount_putin, a.amount_putin,
a.count_diff, a.count_diff,
a.amount_diff a.amount_diff,
is_clear = (a.is_clear??0)==0?"否":"是",
is_new = (a.is_new??0)==0?"否":"是",
is_aimsorder = (a.is_aimsorder??0)==0?"否":"是",
a.count_usable_stock,
a.avg_sevenday_sales,
a.avg_fourteenday_sales,
a.avg_thirtyday_sales,
a.avg_sales
}); });
return JsonConvert.SerializeObject(new return JsonConvert.SerializeObject(new
...@@ -6362,6 +6372,79 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -6362,6 +6372,79 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}); });
} }
/// <summary>
/// 导出进销存明细
/// </summary>
/// <param name="month">月</param>
/// <param name="warehousetype">仓库类型</param>
/// <param name="warehouse">仓库编码</param>
/// <param name="type"></param>
/// <param name="isclear">是否清货</param>
/// <param name="isnew">是否新品</param>
/// <param name="isaims">是否aims下单</param>
/// <param name="isreasonable">是否获取不合理数据,0:是</param>
/// <returns></returns>
public ActionResult ExportUnReasonable(string month, string warehousetype, string warehouse, int? type, int? isclear, int? isnew, int? isaims, int isreasonable = -1)
{
var total = 0;
var _service = new Services.FinanceReportServices();
var obj = _service.ListMonthSalePutinDetail(new BtTableParameter { limit=0,offset=1}, month, warehousetype, warehouse, type, isclear, isnew, isaims, ref total, isreasonable);
var list = obj.Select(a => new {
a.warehouse_type,
a.warehouse_code,
a.warehouse_name,
a.bailun_sku,
a.count_outbound,
a.amount_outbound,
a.count_putin,
a.amount_putin,
a.count_diff,
a.amount_diff,
is_clear = (a.is_clear ?? 0) == 0 ? "否" : "是",
is_new = (a.is_new ?? 0) == 0 ? "否" : "是",
is_aimsorder = (a.is_aimsorder ?? 0) == 0 ? "否" : "是",
a.count_usable_stock,
a.avg_sevenday_sales,
a.avg_fourteenday_sales,
a.avg_thirtyday_sales,
a.avg_sales
});
var colNames = new List<string>() { "仓库类型", "仓库名称", "sku", "出库数量", "出库金额", "入库数量", "入途金额", "(入库-出库)数量", "(入库-出库)金额" }; ;
if (isreasonable == 0)
{
colNames.AddRange(new List<string> { "是否清货", "是否新品", "可用库存", "7日日均", "14日日均", "30日日均", "可消耗天数"});
}
var listval = new List<string>();
foreach (var item in list)
{
listval.Add(item.warehouse_type + "|" + item.warehouse_name + "|" + item.bailun_sku + "|" + item.count_outbound + "|" + item.amount_outbound + "|" +
item.count_putin + "|" + item.amount_putin + "|" + item.count_diff + "|" + item.amount_diff+(isreasonable == 0?("|"+item.is_clear+"|"+item.is_new+"|"+item.count_usable_stock+"|"+item.avg_sevenday_sales+"|"+item.avg_fourteenday_sales+"|"+item.avg_thirtyday_sales+"|"+item.avg_sales):"")
);
}
var guid = Guid.NewGuid().ToString();
var filename = "每月进销存明细" + DateTime.Now.ToString("yyyyMMddHHmmss");
var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\";
ToCSV(listval, colNames, guid, filepath);
var ms = new System.IO.MemoryStream();
using (var f = new System.IO.FileStream(filepath + guid + ".csv", System.IO.FileMode.Open))
{
f.CopyTo(ms);
}
ms.Position = 0;
return File(ms, "text/csv", filename + ".csv");
}
#endregion #endregion
} }
......
...@@ -28,12 +28,21 @@ ...@@ -28,12 +28,21 @@
</select> </select>
</div>*@ </div>*@
<div class="form-group"> <div class="form-group">
<label>差异类型</label>
<select id="type" name="type" class="form-control">
<option value="">选择差异类型</option>
<option value="1">增加部分</option>
<option value="2">减少部分</option>
</select>
</div>
<div class="form-group">
<label>请选择开始月份</label> <label>请选择开始月份</label>
<input id="month" name="month" class="form-control" style="width:130px;" placeholder="年-月" value="@(ViewBag.month)" /> <input id="month" name="month" class="form-control" style="width:130px;" placeholder="年-月" value="@(ViewBag.month)" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label>&nbsp;</label> <label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button> <button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
<button type="button" class="btn btn-success" onclick="exportlist();">导出</button>
</div> </div>
</div> </div>
</form> </form>
...@@ -63,8 +72,13 @@ ...@@ -63,8 +72,13 @@
$("#roletable").attr("data-height", (height - 160)); $("#roletable").attr("data-height", (height - 160));
laydate.render({ elem: '#month', type: 'month' }); laydate.render({ elem: '#month', type: 'month' });
$('#warehousetype').val('@(ViewBag.warehousetype)'); if ('@(ViewBag.warehousetype)' != '') {
$('#warehousetype').val('@(ViewBag.warehousetype)');
}
if (@(ViewBag.type)!= -1) {
$('#type').val(@(ViewBag.type));
}
list(); list();
}) })
...@@ -74,14 +88,26 @@ ...@@ -74,14 +88,26 @@
{ field: 'warehouse_name', title: '仓库名称', width: '160', iscount: true, sortable: true }, { field: 'warehouse_name', title: '仓库名称', width: '160', iscount: true, sortable: true },
{ field: 'bailun_sku', title: 'sku', width: '180', iscount: true, sortable: true }, { field: 'bailun_sku', title: 'sku', width: '180', iscount: true, sortable: true },
{ field: 'count_outbound', title: '出库数量', width: '110', iscount: true, sortable: true }, { field: 'count_outbound', title: '出库数量', width: '110', iscount: true, sortable: true },
{ field: 'amount_outbound', title: '出库金额', width: '110', iscount: true, sortable: true }, { field: 'amount_outbound', title: '出库金额', width: '110', iscount: true },
{ field: 'count_putin', title: '入库数量', width: '110', iscount: true, sortable: true }, { field: 'count_putin', title: '入库数量', width: '110', iscount: true, sortable: true },
{ field: 'amount_putin', title: '入途金额', width: '110', iscount: true, sortable: true }, { field: 'amount_putin', title: '入途金额', width: '110', iscount: true },
{ field: 'count_diff', title: '(入库-出库)数量', width: '150', iscount: true, sortable: true }, { field: 'count_diff', title: '(入库-出库)数量', width: '150', iscount: true, sortable: true },
{ field: 'amount_diff', title: '(入库-出库)金额', width: '150', iscount: true, sortable: true } { field: 'amount_diff', title: '(入库-出库)金额', width: '150', iscount: true }
]; ];
var url = '@Url.Content("~/Reports/Finance/ListUnReasonableJson")' + '?' + $("#toolbar").serialize();
if (@(ViewBag.isun)== 0) {
columns.push({ field: 'is_clear', title: '是否清货', width: '110', sortable: true });
columns.push({ field: 'is_new', title: '是否新品', width: '110', sortable: true });
columns.push({ field: 'count_usable_stock', title: '可用库存', width: '110', sortable: true });
columns.push({ field: 'avg_sevenday_sales', title: '7日日均', width: '110' });
columns.push({ field: 'avg_fourteenday_sales', title: '14日日均', width: '110' });
columns.push({ field: 'avg_thirtyday_sales', title: '30天日均', width: '110' });
columns.push({ field: 'avg_sales', title: '可消耗天数', width: '110', sortable: true });
}
var url = '@Url.Content("~/Reports/Finance/ListUnReasonableJson")' + '?' + $("#toolbar").serialize() + (@(ViewBag.isun)== 0 ?'&isreasonable=0':'');
if (tb == undefined) { if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "", { tb = OnlyTable("roletable", columns, url, "", {
...@@ -111,6 +137,10 @@ ...@@ -111,6 +137,10 @@
}) })
} }
function exportlist() {
window.open('@Url.Content("~/Reports/Finance/ExportUnReasonable?")' + $("#toolbar").serialize() + (@(ViewBag.isun)== 0 ? '&isreasonable=0' : ''), '_blank');
}
</script> </script>
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
//汇总 //汇总
for (var i in result.list0) { for (var i in result.list0) {
var o = result.list0[i]; var o = result.list0[i];
var s = '<tr><td>' + o.warehouse_type + '</td>'; var s = '<tr><td><a href="javascript:;" onclick="showdetail(\'' + o.warehouse_type+'汇总明细\',\'' + m + '\',\'' + o.warehouse_type + '\');">' + o.warehouse_type + '</a></td>';
s += '<td>' + o.count_outbound+'</td>'; s += '<td>' + o.count_outbound+'</td>';
s += '<td>' + o.amount_outbound+'</td>'; s += '<td>' + o.amount_outbound+'</td>';
s += '<td>' + o.count_putin+'</td>'; s += '<td>' + o.count_putin+'</td>';
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
//增加 //增加
for (var i in result.list1) { for (var i in result.list1) {
var o = result.list1[i]; var o = result.list1[i];
var s = '<tr><td>' + o.warehouse_type + '</td>'; var s = '<tr><td><a href="javascript:;" onclick="showdetail(\'' + o.warehouse_type + '增加部分的明细\',\'' + m + '\',\'' + o.warehouse_type + '\',1);">' + o.warehouse_type + '</a></td>';
s += '<td>' + o.count_outbound + '</td>'; s += '<td>' + o.count_outbound + '</td>';
s += '<td>' + o.amount_outbound + '</td>'; s += '<td>' + o.amount_outbound + '</td>';
s += '<td>' + o.count_putin + '</td>'; s += '<td>' + o.count_putin + '</td>';
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
//减少 //减少
for (var i in result.list2) { for (var i in result.list2) {
var o = result.list2[i]; var o = result.list2[i];
var s = '<tr><td>' + o.warehouse_type + '</td>'; var s = '<tr><td><a href="javascript:;" onclick="showdetail(\'' + o.warehouse_type + '减少部分的明细\',\'' + m + '\',\'' + o.warehouse_type + '\',2);">' + o.warehouse_type + '</a></td>';
s += '<td>' + o.count_outbound + '</td>'; s += '<td>' + o.count_outbound + '</td>';
s += '<td>' + o.amount_outbound + '</td>'; s += '<td>' + o.amount_outbound + '</td>';
s += '<td>' + o.count_putin + '</td>'; s += '<td>' + o.count_putin + '</td>';
...@@ -158,8 +158,13 @@ ...@@ -158,8 +158,13 @@
}) })
} }
function showdetail(title,month, warehousetype, type) { function showdetail(title, month, warehousetype, type) {
layer_show(title, '@Url.Content("~/Reports/Finance/ListUnReasonable?month=")' + month + '&warehousetype=' + warehousetype + (type != undefined ?'&type='+type:''), '95%', '95%');
if (warehousetype == '总计') {
return false;
}
layer_show(title, '@Url.Content("~/Reports/Finance/ListUnReasonable?month=")' + month + '&warehousetype=' + warehousetype + ((type == null || type == undefined) ? "":'&type=' + type), '95%', '95%');
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment