Commit c0945204 by guanzhenshan

增加进销存差异报表页面

parent bdadc520
...@@ -69,5 +69,21 @@ namespace Bailun.DC.Models ...@@ -69,5 +69,21 @@ namespace Bailun.DC.Models
/// </summary> /// </summary>
public DateTime createtime { get; set; } public DateTime createtime { get; set; }
/// <summary>
/// 出库金额
/// </summary>
public decimal? amount_outbound { get; set; }
/// <summary>
/// 入库金额
/// </summary>
public decimal? amount_putin { get; set; }
/// <summary>
/// 差异金额
/// </summary>
public decimal? amount_diff { get; set; }
} }
} }
...@@ -119,5 +119,18 @@ namespace Bailun.DC.Models ...@@ -119,5 +119,18 @@ namespace Bailun.DC.Models
/// </summary> /// </summary>
public int? is_aimsorder { get; set; } public int? is_aimsorder { get; set; }
/// <summary>
/// 出库金额
/// </summary>
public decimal? amount_outbound { get; set; }
/// <summary>
/// 入库金额
/// </summary>
public decimal? amount_putin { get; set; }
/// <summary>
/// 差异金额
/// </summary>
public decimal? amount_diff { get; set; }
} }
} }
...@@ -4794,5 +4794,225 @@ group by currency"; ...@@ -4794,5 +4794,225 @@ group by currency";
#endregion #endregion
#region 进销存不合理报告分析
/// <summary>
/// 进销存差异汇总
/// </summary>
/// <param name="month">月份</param>
/// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param>
/// <returns></returns>
public List<dc_mid_month_sale_putin> ListMonthSalePutin(string month,int? type)
{
var sql = $@"select t1.warehouse_type,sum(t1.count_outbound) count_outbound,sum(t1.count_outbound*t1.buyprice) amount_outbound,sum(t1.count_putin) count_putin,sum(t1.count_putin*t1.buyprice) amount_putin,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 where t1.`month`='{month}'
";
if (type.HasValue)
{
if (type.Value == 1)
{
sql += " and 0<t1.count_putin-t1.count_outbound";
}
else if (type.Value == 2)
{
sql += " and 0>t1.count_putin-t1.count_outbound";
}
}
sql += " group by t1.warehouse_type";
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
var list = cn.Query<dc_mid_month_sale_putin>(sql, null, null, true, 2 * 60).ToList();
return list;
}
}
/// <summary>
/// 进销存差异明细
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="month">月份,必填</param>
/// <param name="warehousetype">仓库类型</param>
/// <param name="warehouse">仓库编码</param>
/// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param>
/// <param name="total">符合条件的总数</param>
/// <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)
{
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
left join dc_mid_month_sale_putin_report t2 on t1.id=t2.sale_putin_id
where t1.`month`='{month}'";
if (!string.IsNullOrEmpty(warehousetype))
{
sql += " and t1.warehouse_type=@warehouse_type";
sqlparam.Add("warehouse_type", warehousetype);
}
if (!string.IsNullOrEmpty(warehouse))
{
sql += " and t1.warehouse_code=@warehouse_code";
sqlparam.Add("warehouse_code", warehouse);
}
if (type.HasValue)
{
if (type.Value == 1)
{
sql += " and 0<t1.count_putin-t1.count_outbound";
}
else if (type.Value == 2)
{
sql += " and 0>t1.count_putin-t1.count_outbound";
}
}
if (isclear.HasValue)
{
if (isclear.Value == 1)
{
sql += " and t2.is_clear=1";
}
else
{
sql += " and t2.is_clear!=1";
}
}
if (isnew.HasValue)
{
if (isnew.Value == 1)
{
sql += " and t2.is_new=1";
}
else
{
sql += " and t2.is_new!=1";
}
}
if (isaims.HasValue)
{
if (isaims.Value == 1)
{
sql += " and t2.is_aimsorder=1";
}
else
{
sql += " and t2.is_aimsorder!=1";
}
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if(cn.State== ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.Page<dc_mid_month_sale_putin_report>(parameter.pageIndex, parameter.limit, sql, ref total, sqlparam).ToList();
return obj;
}
}
/// <summary>
/// 进销存差异明细统计
/// </summary>
/// <param name="month">月份,必填</param>
/// <param name="warehousetype">仓库类型</param>
/// <param name="warehouse">仓库编码</param>
/// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param>
/// <returns></returns>
public dc_mid_month_sale_putin_report ListMonthSalePutinDetailCount(string month, string warehousetype, string warehouse, int? type, int? isclear, int? isnew, int? isaims)
{
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
left join dc_mid_month_sale_putin_report t2 on t1.id=t2.sale_putin_id
where t1.`month`='{month}'";
if (!string.IsNullOrEmpty(warehousetype))
{
sql += " and t1.warehouse_type=@warehouse_type";
sqlparam.Add("warehouse_type", warehousetype);
}
if (!string.IsNullOrEmpty(warehouse))
{
sql += " and t1.warehouse_code=@warehouse_code";
sqlparam.Add("warehouse_code", warehouse);
}
if (type.HasValue)
{
if (type.Value == 1)
{
sql += " and 0<t1.count_putin-t1.count_outbound";
}
else if (type.Value == 2)
{
sql += " and 0>t1.count_putin-t1.count_outbound";
}
}
if (isclear.HasValue)
{
if (isclear.Value == 1)
{
sql += " and t2.is_clear=1";
}
else
{
sql += " and t2.is_clear!=1";
}
}
if (isnew.HasValue)
{
if (isnew.Value == 1)
{
sql += " and t2.is_new=1";
}
else
{
sql += " and t2.is_new!=1";
}
}
if (isaims.HasValue)
{
if (isaims.Value == 1)
{
sql += " and t2.is_aimsorder=1";
}
else
{
sql += " and t2.is_aimsorder!=1";
}
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.QueryFirstOrDefault<dc_mid_month_sale_putin_report>(sql,sqlparam);
return obj;
}
}
#endregion
} }
} }
...@@ -6208,6 +6208,160 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -6208,6 +6208,160 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
return View(); return View();
} }
/// <summary>
/// 进销存差异汇总
/// </summary>
/// <param name="month">月份</param>
/// <returns></returns>
[BailunAuthentication(LoginMode.Enforce)]
[HttpPost]
public JsonResult UnReasonableJson(string month)
{
if (string.IsNullOrEmpty(month))
{
return Json(new
{
success = false,
msg = "请选择月份。",
});
}
try
{
var _service = new Services.FinanceReportServices();
var obj1 = _service.ListMonthSalePutin(month, null);
var obj2 = _service.ListMonthSalePutin(month, 1); //增加部分
var obj3 = _service.ListMonthSalePutin(month, 2); //减少部分
if (obj1.Count > 0)
{
obj1.Add(new dc_mid_month_sale_putin
{
warehouse_type = "总计",
count_outbound = obj1.Sum(a => a.count_outbound),
amount_outbound = obj1.Sum(a => a.amount_outbound),
count_putin = obj1.Sum(a => a.count_putin),
amount_putin = obj1.Sum(a => a.amount_putin),
count_diff = obj1.Sum(a => a.count_diff),
amount_diff = obj1.Sum(a => a.amount_diff)
});
}
if (obj2.Count > 0)
{
obj2.Add(new dc_mid_month_sale_putin
{
warehouse_type = "总计",
count_outbound = obj2.Sum(a => a.count_outbound),
amount_outbound = obj2.Sum(a => a.amount_outbound),
count_putin = obj2.Sum(a => a.count_putin),
amount_putin = obj2.Sum(a => a.amount_putin),
count_diff = obj2.Sum(a => a.count_diff),
amount_diff = obj2.Sum(a => a.amount_diff)
});
}
if (obj3.Count > 0)
{
obj3.Add(new dc_mid_month_sale_putin
{
warehouse_type = "总计",
count_outbound = obj3.Sum(a => a.count_outbound),
amount_outbound = obj3.Sum(a => a.amount_outbound),
count_putin = obj3.Sum(a => a.count_putin),
amount_putin = obj3.Sum(a => a.amount_putin),
count_diff = obj3.Sum(a => a.count_diff),
amount_diff = obj3.Sum(a => a.amount_diff)
});
}
return Json(new
{
success = true,
msg = "",
list0 = obj1,
list1 = obj2,
list2 = obj3
});
}
catch (Exception ex)
{
return Json(new
{
success = false,
msg = ex.Message,
});
}
}
/// <summary>
/// 销进比差异明细
/// </summary>
/// <param name="warehousetype">仓库类型</param>
/// <param name="month">月份</param>
/// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param>
/// <returns></returns>
public ActionResult ListUnReasonable(string warehousetype, string month,int? type)
{
ViewBag.warehousetype = warehousetype;
ViewBag.month = month;
ViewBag.type = type ?? -1;
return View();
}
/// <summary>
/// 销进比差异明细
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="month">月份</param>
/// <param name="warehousetype">仓库类型</param>
/// <param name="warehouse">仓库编码</param>
/// <param name="type">是否筛选增加了或者减少了,1:增加了,2:减少了</param>
/// <param name="isclear">是否清货</param>
/// <param name="isnew">是否新品</param>
/// <param name="isaims">是否aims下单</param>
/// <returns></returns>
[BailunAuthentication(LoginMode.Enforce)]
public string ListUnReasonableJson(BtTableParameter parameter, string month, string warehousetype,string warehouse,int? type,int? isclear,int? isnew,int? isaims)
{
var total = 0;
var _service = new Services.FinanceReportServices();
var obj = _service.ListMonthSalePutinDetail(parameter, month, warehousetype, warehouse, type, isclear, isnew, isaims, ref total);
var objCount = _service.ListMonthSalePutinDetailCount(month, warehousetype, warehouse, type, isclear, isnew, isaims);
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
});
return JsonConvert.SerializeObject(new
{
total = total,
rows = list,
count_row = new
{
warehouse_name = "总计",
count_outbound = objCount.count_outbound.ToString("N2"),
amount_outbound = (objCount.amount_outbound??0).ToString("N2"),
count_putin = objCount.count_putin.ToString("N2"),
amount_putin = (objCount.amount_putin??0).ToString("N2"),
count_diff = objCount.count_diff.ToString("N2"),
amount_diff = (objCount.amount_diff??0).ToString("N2")
}
});
}
#endregion #endregion
} }
......

@{
ViewData["Title"] = "每月进销存差异明细";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "财务报表", "每月进销存差异汇总" };
}
<div class="row">
<div class="col-sm-12">
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>仓库类型:</label>
<select id="warehousetype" name="warehousetype" class="form-control">
<option value="">选择仓库类型</option>
<option value="国内仓">国内仓</option>
<option value="海外仓">海外仓</option>
<option value="FBA仓">FBA仓</option>
<option value="第三方仓库">第三方仓库</option>
<option value="耗材仓">耗材仓</option>
</select>
</div>
@*<div class="form-group">
<label>仓库:</label>
<select id="warehouse" name="warehouse" class="form-control">
<option value="">请选择仓库</option>
</select>
</div>*@
<div class="form-group">
<label>请选择开始月份</label>
<input id="month" name="month" class="form-control" style="width:130px;" placeholder="年-月" value="@(ViewBag.month)" />
</div>
<div class="form-group">
<label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
</div>
</div>
</form>
</div>
<div class="ibox-content m-b-sm border-bottom">
<table id="roletable" style="table-layout:fixed;"></table>
</div>
</div>
</div>
@section css{
<style>
.mules {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
}
@section scripts{
<script src="~/css/Layer-2.1/extend/layer.ext.js"></script>
<script type="text/javascript">
var tb;
$(document).ready(function () {
var height = document.body.clientHeight;
$("#roletable").attr("data-height", (height - 160));
laydate.render({ elem: '#month', type: 'month' });
$('#warehousetype').val('@(ViewBag.warehousetype)');
list();
})
function list() {
var columns = [
{ field: 'warehouse_type', title: '仓库类型', width: '130', 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: 'count_outbound', title: '出库数量', width: '110', iscount: true, sortable: true },
{ field: 'amount_outbound', 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: 'count_diff', title: '(入库-出库)数量', width: '150', iscount: true, sortable: true },
{ field: 'amount_diff', title: '(入库-出库)金额', width: '150', iscount: true, sortable: true }
];
var url = '@Url.Content("~/Reports/Finance/ListUnReasonableJson")' + '?' + $("#toolbar").serialize();
if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "", {
showfooter: true, showCount: true
});
}
else {
tb.bootstrapTable('refresh', { url: url });
}
}
function listwarehouse() {
var type = $('#warehousetype').val();
$.submit({
url: '@Url.Content("~/Home/ListWareHouse")',
paramData: 'warehousetype=' + type,
type:'POST',
func: function (result) {
if (result != null && result != undefined) {
$('#warehouse').html('<option value="">仓库不限</option>');
for (var i = 0; i < result.length; i++) {
$('#warehouse').append('<option value="' + result[i].warehouse_code + '">' + result[i].warehouse_name + '</option>');
}
}
}
})
}
</script>
}

@{
ViewData["Title"] = "UnReasonable";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "财务报表", "每月进销存差异汇总" };
}
<div class="row">
<div class="col-sm-12">
<div class="alert alert-warning">
说明:数据从2019-12月份开始
</div>
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>请选择开始月份</label>
<input id="month" name="month" class="form-control" style="width:130px;" placeholder="年-月" value="@(DateTime.Now.AddMonths(-1).ToString("yyyy-MM"))" />
</div>
<div class="form-group">
<label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="init();"><i class="fa fa-search"></i>&nbsp;查询</button>
</div>
</div>
</form>
</div>
<div class="ibox-content m-b-sm border-bottom">
<label>汇总</label>
<table id="tb0" class="table table-hover table-bordered table-condensed table-striped">
<thead>
<tr>
<td>仓库类型</td>
<td>出库数量</td>
<td>出库金额</td>
<td>入库数量</td>
<td>入库金额</td>
<td>(入库-出库)数量</td>
<td>(入库-出库)金额</td>
</tr>
</thead>
<tbody></tbody>
</table>
<hr />
<label>增加部分</label>
<table id="tb1" class="table table-hover table-bordered table-condensed table-striped">
<thead>
<tr>
<td>仓库类型</td>
<td>出库数量</td>
<td>出库金额</td>
<td>入库数量</td>
<td>入库金额</td>
<td>(入库-出库)数量</td>
<td>(入库-出库)金额</td>
</tr>
</thead>
<tbody></tbody>
</table>
<label>减少部分</label>
<table id="tb2" class="table table-hover table-bordered table-condensed table-striped">
<thead>
<tr>
<td>仓库类型</td>
<td>出库数量</td>
<td>出库金额</td>
<td>入库数量</td>
<td>入库金额</td>
<td>(入库-出库)数量</td>
<td>(入库-出库)金额</td>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
@section scripts{
<script src="~/css/Layer-2.1/extend/layer.ext.js"></script>
<script type="text/javascript">
$(document).ready(function () {
laydate.render({ elem: '#month', type: 'month' });
init();
})
function init() {
var m = $('#month').val();
if (m == '') {
layer.msg('请选择月份');
return;
}
var lindex = layer.load(1, { shade: false }); //0代表加载的风格,支持0-2
$.submit({
type:'POST',
url: '@Url.Content("~/Reports/Finance/UnReasonableJson")',
paramData: 'month='+m,
func: function (result) {
layer.close(lindex);
if (result.success) {
$('#tb0').find('tbody').html('');
$('#tb1').find('tbody').html('');
$('#tb2').find('tbody').html('');
//汇总
for (var i in result.list0) {
var o = result.list0[i];
var s = '<tr><td>' + o.warehouse_type + '</td>';
s += '<td>' + o.count_outbound+'</td>';
s += '<td>' + o.amount_outbound+'</td>';
s += '<td>' + o.count_putin+'</td>';
s += '<td>' + o.amount_putin+'</td>';
s += '<td>' + o.count_diff+'</td>';
s += '<td>' + o.amount_diff+'</td>';
s += '</tr>';
$('#tb0').find('tbody').append(s);
}
//增加
for (var i in result.list1) {
var o = result.list1[i];
var s = '<tr><td>' + o.warehouse_type + '</td>';
s += '<td>' + o.count_outbound + '</td>';
s += '<td>' + o.amount_outbound + '</td>';
s += '<td>' + o.count_putin + '</td>';
s += '<td>' + o.amount_putin + '</td>';
s += '<td>' + o.count_diff + '</td>';
s += '<td>' + o.amount_diff + '</td>';
s += '</tr>';
$('#tb1').find('tbody').append(s);
}
//减少
for (var i in result.list2) {
var o = result.list2[i];
var s = '<tr><td>' + o.warehouse_type + '</td>';
s += '<td>' + o.count_outbound + '</td>';
s += '<td>' + o.amount_outbound + '</td>';
s += '<td>' + o.count_putin + '</td>';
s += '<td>' + o.amount_putin + '</td>';
s += '<td>' + o.count_diff + '</td>';
s += '<td>' + o.amount_diff + '</td>';
s += '</tr>';
$('#tb2').find('tbody').append(s);
}
}
else {
layer.msg(result.msg);
}
}
})
}
function showdetail(title,month, warehousetype, type) {
layer_show(title, '@Url.Content("~/Reports/Finance/ListUnReasonable?month=")' + month + '&warehousetype=' + warehousetype + (type != undefined ?'&type='+type:''), '95%', '95%');
}
</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