Commit f3ef302d by guanzhenshan

增加sku库存分析报表

parent 36baf9a7
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.Stock
{
/// <summary>
/// Sku库存分析报表
/// Create by Allan
/// At 2019-02-24
/// </summary>
public class mSkuStockAnalyze
{
/// <summary>
/// 主键
/// </summary>
/// <returns></returns>
public int id { get; set; }
/// <summary>
/// 仓库编码
/// </summary>
/// <returns></returns>
public string warehouse_code { get; set; }
/// <summary>
/// 仓库名称
/// </summary>
/// <returns></returns>
public string warehouse_name { get; set; }
/// <summary>
/// 百伦SKU
/// </summary>
/// <returns></returns>
public string bailun_sku { get; set; }
/// <summary>
/// 月初库存数
/// </summary>
/// <returns></returns>
public int? quantity_begin_month_inventory { get; set; }
/// <summary>
/// 采购在途数
/// </summary>
/// <returns></returns>
public int? quantity_purchase_transit { get; set; }
/// <summary>
/// 调拨在途数
/// </summary>
/// <returns></returns>
public int? quantity_transfer_transit { get; set; }
/// <summary>
/// 采购入库数
/// </summary>
/// <returns></returns>
public int? quantity_purchase_inbound { get; set; }
/// <summary>
/// 采购入库金额
/// </summary>
public decimal? purchase_inbound_amount { get; set; }
/// <summary>
/// 调拨入库数
/// </summary>
public int? quantity_transfer_inbound { get; set; }
/// <summary>
/// 调拨入库金额
/// </summary>
public decimal? transfer_inbound_amount { get; set; }
/// <summary>
/// 入库金额
/// </summary>
public decimal? inboundamount { get; set; }
/// <summary>
/// 报损数
/// </summary>
/// <returns></returns>
public int? quantity_damaged { get; set; }
/// <summary>
/// 报溢数
/// </summary>
/// <returns></returns>
public int? quantity_overflow { get; set; }
/// <summary>
/// sku转换数量
/// </summary>
/// <returns></returns>
public int? quantity_sku_changed { get; set; }
/// <summary>
/// 销售数量
/// </summary>
/// <returns></returns>
public int? quantity_sales { get; set; }
/// <summary>
/// 月末库存数
/// </summary>
/// <returns></returns>
public int? quantity_end_month_inventory { get; set; }
/// <summary>
/// 周转率
/// </summary>
/// <returns></returns>
public decimal? turnover_rate { get; set; }
/// <summary>
/// 周转天数
/// </summary>
/// <returns></returns>
public int? turnover_date { get; set; }
/// <summary>
/// 库龄(0-1)月
/// </summary>
/// <returns></returns>
public int? inv_age_0to1_month { get; set; }
/// <summary>
/// 库龄(1-3)月
/// </summary>
/// <returns></returns>
public int? inv_age_1to3_month { get; set; }
/// <summary>
/// 库龄(3-6)月
/// </summary>
/// <returns></returns>
public int? inv_age_3to6_month { get; set; }
/// <summary>
/// 库龄(6-12)月
/// </summary>
/// <returns></returns>
public int? inv_age_6to12_month { get; set; }
/// <summary>
/// 库龄(1-2)年
/// </summary>
/// <returns></returns>
public int? inv_age_1to2_year { get; set; }
/// <summary>
/// 库龄(2-3)年
/// </summary>
/// <returns></returns>
public int? inv_age_2to3_year { get; set; }
/// <summary>
/// 库龄大于3年
/// </summary>
/// <returns></returns>
public int? inv_age_gt3_year { get; set; }
/// <summary>
/// 即时库存数
/// </summary>
/// <returns></returns>
public int? quantity_instant_inventory { get; set; }
/// <summary>
/// 即时库存金额
/// </summary>
public decimal? instant_inventory_amount { get; set; }
/// <summary>
/// 本月累计出口数
/// </summary>
/// <returns></returns>
public int? month_total_exports { get; set; }
/// <summary>
/// 本月累计出口金额
/// </summary>
public decimal? exportamount { get; set; }
/// <summary>
/// 创建时间
/// </summary>
/// <returns></returns>
public DateTime gmt_create { get; set; }
/// <summary>
/// 修改时间
/// </summary>
/// <returns></returns>
public DateTime gmt_modified { get; set; }
/// <summary>
/// 采购单价
/// </summary>
/// <returns></returns>
public decimal? purchase_price { get; set; }
/// <summary>
/// 内购数量
/// </summary>
public int? quantity_inner_purchase { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Bailun.DC.Models;
using Bailun.DC.DB;
using Dapper;
using MySql.Data.MySqlClient;
using Bailun.DC.Models.Stock;
namespace Bailun.DC.Services
{
/// <summary>
/// 库存相关服务
/// </summary>
public class InventoryServices
{
/// <summary>
/// Sku库存分析报表列表
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="sku">sku编码</param>
/// <param name="warehouse">仓库编码</param>
/// <param name="month">月份</param>
/// <param name="total">符合条件的记录数</param>
/// <returns></returns>
public List<Models.Stock.mSkuStockAnalyze> ListSkuStockAnalyze(BtTableParameter parameter,string sku,string warehouse,DateTime? month,ref int total)
{
var sqlparam = new DynamicParameters();
var sql = @"select t0.warehouse_code,t0.warehouse_name,t0.bailun_sku,t0.quantity_begin_month_inventory,t0.quantity_purchase_transit,t0.quantity_transfer_transit,t0.quantity_purchase_inbound,t0.quantity_purchase_inbound*t0.purchase_price as purchase_inbound_amount,t0.quantity_transfer_inbound,t0.quantity_transfer_inbound*t0.purchase_price as transfer_inbound_amount,t0.quantity_damaged,t0.quantity_overflow,t0.quantity_sku_changed,t0.quantity_sales,t0.quantity_end_month_inventory,t0.turnover_rate,t0.turnover_date,t0.inv_age_0to1_month,t0.inv_age_1to3_month,t0.inv_age_3to6_month,t0.inv_age_6to12_month,t0.inv_age_1to2_year,t0.inv_age_2to3_year,t0.inv_age_gt3_year,t0.quantity_instant_inventory,t0.quantity_instant_inventory*t0.purchase_price as instant_inventory_amount,t0.month_total_exports,t0.month_total_exports*t0.purchase_price as exportamount,t0.quantity_inner_purchase,t0.purchase_price ";
var sqlwhere = @"from (
select* from dc_month_inventory where warehouse_name <> '' group by warehouse_code,bailun_sku having MAX(record_time)
) as t0 where 1 = 1 ";
if (!string.IsNullOrEmpty(sku))
{
sqlwhere += (" and t0.bailun_sku=@sku");
sqlparam.Add("sku", sku);
}
if (!string.IsNullOrEmpty(warehouse))
{
sqlwhere += (" and t0.warehouse_code=@warehouse");
sqlparam.Add("warehouse", warehouse);
}
if (month.HasValue)
{
var monthEnd = month.Value.AddMonths(1);
sqlwhere += (" and t0.record_time>=@monthstart and t0.record_time<@monthend");
sqlparam.Add("monthstart", month.Value);
sqlparam.Add("monthend", monthEnd);
}
if (!string.IsNullOrEmpty(parameter.sort))
{
sqlwhere += " order by " + parameter.sort + " " + parameter.order;
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.Page<Models.Stock.mSkuStockAnalyze>(parameter.pageIndex, parameter.limit, sql + sqlwhere, ref total, sqlparam, "select count(t0.id) "+sqlwhere);
return obj.AsList();
}
}
}
}
......@@ -72,5 +72,64 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
return JsonConvert.SerializeObject(new { total = total, rows = list });
}
/// <summary>
/// Sku库存分析报表(财务)
/// </summary>
/// <returns></returns>
public ActionResult SkuInventory()
{
return View();
}
/// <summary>
/// Sku库存分析报表数据
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="sku">sku编码</param>
/// <param name="warehouse">仓库编码</param>
/// <param name="date">月份</param>
/// <returns></returns>
public string ListSkuInventoryJson(Models.BtTableParameter parameter,string sku,string warehouse,DateTime? date)
{
var total = 1;
var obj = new Services.InventoryServices().ListSkuStockAnalyze(parameter, sku, warehouse, date, ref total);
foreach (var item in obj)
{
item.exportamount = item.exportamount ?? 0;
item.inboundamount = item.inboundamount ?? 0;
item.instant_inventory_amount = item.instant_inventory_amount ?? 0;
item.inv_age_0to1_month = item.inv_age_0to1_month ?? 0;
item.inv_age_1to2_year = item.inv_age_1to2_year ?? 0;
item.inv_age_1to3_month = item.inv_age_1to3_month ?? 0;
item.inv_age_2to3_year = item.inv_age_2to3_year ?? 0;
item.inv_age_3to6_month = item.inv_age_3to6_month ?? 0;
item.inv_age_6to12_month = item.inv_age_6to12_month ?? 0;
item.inv_age_gt3_year = item.inv_age_gt3_year ?? 0;
item.month_total_exports = item.month_total_exports ?? 0;
item.purchase_price = item.purchase_price ?? 0;
item.quantity_begin_month_inventory = item.quantity_begin_month_inventory ?? 0;
item.quantity_damaged = item.quantity_damaged ?? 0;
item.quantity_end_month_inventory = item.quantity_end_month_inventory ?? 0;
item.quantity_purchase_inbound = item.quantity_purchase_inbound ?? 0;
item.quantity_inner_purchase = item.quantity_inner_purchase ?? 0;
item.quantity_instant_inventory = item.quantity_instant_inventory ?? 0;
item.quantity_overflow = item.quantity_overflow ?? 0;
item.quantity_purchase_transit = item.quantity_purchase_transit ?? 0;
item.quantity_sales = item.quantity_sales ?? 0;
item.quantity_sku_changed = item.quantity_sku_changed ?? 0;
item.quantity_transfer_transit = item.quantity_transfer_transit ?? 0;
item.turnover_date = item.turnover_date ?? 0;
item.turnover_rate = item.turnover_rate ?? 0;
}
return JsonConvert.SerializeObject(new { total = total,rows = obj});
}
}
}
\ No newline at end of file

@{
ViewData["Title"] = "sku库存分析报表";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "库存", "库存财务报表", "sku库存分析报表" };
}
<div class="row">
<div class="col-sm-12">
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<input id="isfba" name="isfba" type="hidden" value="0" />
<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>
</select>
</div>
<div class="form-group">
<label>仓库:</label>
<select id="warehouse" name="warehouse" class="form-control" style="width:160px;">
<option value="">选择仓库</option>
</select>
</div>
<div class="form-group">
<label>月份</label>
<input id="date_" name="date_" class="form-control" style="width:110px;" readonly />
</div>
<div class="form-group">
<label>&nbsp;</label>
<input id="sku" name="sku" class="form-control" style="width:160px" placeholder="Sku编码" />
</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 type="text/javascript">
var tb;
$(document).ready(function () {
var height = document.body.clientHeight;
$("#roletable").attr("data-height", (height - 160));
laydate.render({ elem: '#date_', type: 'month'});
list();
listwarehouse();
})
function list() {
var columns = [
{
field: 'warehouse_name', title: '仓库名称', width: '190', sortable: false
},
{
field: 'bailun_sku', title: 'Sku', width: '160', sortable: false, formatter: function (idx, data) {
return '<div class="mules" title="' + data.bailun_sku + '">' + data.bailun_sku + '</div>';
}
},
{
field: 'quantity_begin_month_inventory', title: '月初库存数量', width: '140', sortable: true
},
{
field: 'quantity_purchase_transit', title: '采购在途', width: '110', sortable: true
},
{ field: 'quantity_purchase_inbound', title: '采购入库数量', width: '130', sortable: true },
{
field: 'quantity_transfer_transit', title: '调拨在途数量', width: '130', sortable: true
},
{
field: 'quantity_transfer_inbound', title: '调拨入库数量', width: '130', sortable: true
},
{
field: 'quantity_damaged', title: '报损数量', width: '110', sortable: true
},
{
field: 'quantity_overflow', title: '报溢数量', width: '110', sortable: true
},
{ field: 'quantity_sku_changed', title: 'Sku转换数量', width: '130', sortable: true },
{ field: 'quantity_sales', title: '销售数量', width: '110', sortable: true },
{ field: 'quantity_end_month_inventory', title: '月末库存数量', width: '130', sortable: true },
{ field: 'turnover_rate', title: '周转率', width: '110', sortable: true },
{ field: 'turnover_date', title: '周转天数', width: '110', sortable: true },
{ field: 'inv_age_0to1_month', title: '库龄0-1月', width: '130', sortable: true },
{ field: 'inv_age_1to3_month', title: '库龄1-3月', width: '130', sortable: true },
{ field: 'inv_age_3to6_month', title: '库龄3-6月', width: '130', sortable: true },
{ field: 'inv_age_6to12_month', title: '库龄6-12月', width: '130', sortable: true },
{ field: 'inv_age_1to2_year', title: '库龄1-2年', width: '130', sortable: true },
{ field: 'inv_age_gt3_year', title: '库龄3年以上', width: '140', sortable: true },
{ field: 'quantity_instant_inventory', title: '即时库存数', width: '130', sortable: true },
{ field: 'instant_inventory_amount', title: '即时库存金额', width: '130', sortable: true },
{ field: 'month_total_exports', title: '本月累计出口数量', width: '180', sortable: true },
{ field: 'exportamount', title: '本月累计出口金额', width: '180', sortable: true },
{ field: 'thirtyday_total_sales', title: '一个月销售额趋势图', width: '180', sortable: true }
];
var date = $('#date_').val();
if (date != null) {
date = date + '_01';
}
var url = '@Url.Content("~/Reports/Inventory/ListSkuInventoryJson")' + '?' + $("#toolbar").serialize() + '&date=' + date;
if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "",);
}
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>
}
......@@ -74,12 +74,20 @@
<li>
<a class="J_menuItem" href="@Url.Content("~/Reports/Sku/ListSku")" data-index="0" style="padding-left:74px;">Sku</a>
</li>
@*<li>
<a class="J_menuItem" href="#" data-index="0">物理仓库</a>
</li>
<li>
<a class="J_menuItem" href="#" data-index="0">Sku</a>
</li>*@
</ul>
</li>
<li>
<a href="#">
<i class="fa fa-refresh"></i>
<span class="nav-label">库存财务报表</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-third-level">
<li>
<a class="J_menuItem" href="@Url.Content("~/Reports/Inventory/SkuInventory")" data-index="0" style="padding-left:74px;">
<span class="nav-label">Sku库存分析报表</span>
</a>
</li>
</ul>
</li>
</ul>
......
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