获取企业每个堆场的在库数量
This commit is contained in:
parent
d73f83e340
commit
1c52322414
|
@ -19,6 +19,8 @@ using System.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Maticsoft.Common;
|
using Maticsoft.Common;
|
||||||
using Competition.Mysql.Model;
|
using Competition.Mysql.Model;
|
||||||
|
using Competition.Mysql.Other;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
namespace Competition.Mysql.BLL
|
namespace Competition.Mysql.BLL
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -148,6 +150,25 @@ namespace Competition.Mysql.BLL
|
||||||
return modelList;
|
return modelList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Competition.Mysql.Other.YardStorageCheck> DataTableToList_YardStorageCheck(DataTable dt)
|
||||||
|
{
|
||||||
|
List<Competition.Mysql.Other.YardStorageCheck> modelList = new List<Competition.Mysql.Other.YardStorageCheck>();
|
||||||
|
int rowsCount = dt.Rows.Count;
|
||||||
|
if (rowsCount > 0)
|
||||||
|
{
|
||||||
|
Competition.Mysql.Other.YardStorageCheck model;
|
||||||
|
for (int n = 0; n < rowsCount; n++)
|
||||||
|
{
|
||||||
|
model = dal.DataRowToModel_YardStorageCheck(dt.Rows[n]);
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
modelList.Add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modelList;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得数据列表
|
/// 获得数据列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -190,6 +211,17 @@ namespace Competition.Mysql.BLL
|
||||||
DataSet ds = dal.GetYardStorage(siloCode);
|
DataSet ds = dal.GetYardStorage(siloCode);
|
||||||
return DataTableToList(ds.Tables[0]);
|
return DataTableToList(ds.Tables[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取堆库存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="monotorid"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<YardStorageCheck> GetYardLastStorage(string monotorid)
|
||||||
|
{
|
||||||
|
DataSet ds = dal.GetYardLastStorage(monotorid);
|
||||||
|
return DataTableToList_YardStorageCheck(ds.Tables[0]);
|
||||||
|
}
|
||||||
#endregion ExtensionMethod
|
#endregion ExtensionMethod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -583,6 +583,63 @@ namespace Competition.Mysql.DAL
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Competition.Mysql.Other.YardStorageCheck DataRowToModel_YardStorageCheck(DataRow row)
|
||||||
|
{
|
||||||
|
Competition.Mysql.Other.YardStorageCheck model = new Competition.Mysql.Other.YardStorageCheck();
|
||||||
|
if (row != null)
|
||||||
|
{
|
||||||
|
if (row["STORAGE_CODE"] != null && row["STORAGE_CODE"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.STORAGE_CODE = new Guid(row["STORAGE_CODE"].ToString());
|
||||||
|
}
|
||||||
|
if (row["GOODS_CODE"] != null)
|
||||||
|
{
|
||||||
|
model.GOODS_CODE = row["GOODS_CODE"].ToString();
|
||||||
|
}
|
||||||
|
if (row["GOODS_TYPE"] != null && row["GOODS_TYPE"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.GOODS_TYPE = int.Parse(row["GOODS_TYPE"].ToString());
|
||||||
|
}
|
||||||
|
if (row["STANDARD_NAME"] != null)
|
||||||
|
{
|
||||||
|
model.STANDARD_NAME = row["STANDARD_NAME"].ToString();
|
||||||
|
}
|
||||||
|
if (row["MONITOR_ID"] != null)
|
||||||
|
{
|
||||||
|
model.MONITOR_ID = row["MONITOR_ID"].ToString();
|
||||||
|
}
|
||||||
|
if (row["MONITOR_NAME"] != null)
|
||||||
|
{
|
||||||
|
model.MONITOR_NAME = row["MONITOR_NAME"].ToString();
|
||||||
|
}
|
||||||
|
if (row["CUSTOMS_CODE"] != null)
|
||||||
|
{
|
||||||
|
model.CUSTOMS_CODE = row["CUSTOMS_CODE"].ToString();
|
||||||
|
}
|
||||||
|
if (row["STOCK_BALANCE"] != null && row["STOCK_BALANCE"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.STOCK_BALANCE = decimal.Parse(row["STOCK_BALANCE"].ToString());
|
||||||
|
}
|
||||||
|
if (row["INSTRG_DATE"] != null && row["INSTRG_DATE"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.INSTRG_DATE = DateTime.Parse(row["INSTRG_DATE"].ToString());
|
||||||
|
}
|
||||||
|
if (row["STORAGE_SILO_CODE"] !=null && row["STORAGE_SILO_CODE"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.STORAGE_SILO_CODE = new Guid(row["STORAGE_SILO_CODE"].ToString());
|
||||||
|
}
|
||||||
|
if (row["SILO_CODE"]!=null && row["SILO_CODE"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.SILO_CODE = row["SILO_CODE"].ToString();
|
||||||
|
}
|
||||||
|
if (row["SILO_NAME"]!=null && row["SILO_NAME"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.SILO_NAME = row["SILO_NAME"].ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得数据列表
|
/// 获得数据列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -718,6 +775,22 @@ namespace Competition.Mysql.DAL
|
||||||
StringBuilder strSql = new StringBuilder();
|
StringBuilder strSql = new StringBuilder();
|
||||||
strSql.Append(sql);
|
strSql.Append(sql);
|
||||||
|
|
||||||
|
return DbHelperSQL.Query(strSql.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataSet GetYardLastStorage(string monitorid)
|
||||||
|
{
|
||||||
|
string sql = string.Format(
|
||||||
|
"select T1.STORAGE_CODE,T1.GOODS_CODE,T1.GOODS_TYPE,T1.STANDARD_NAME,T1.MONITOR_ID,T1.MONITOR_NAME,T1.CUSTOMS_CODE,T1.STOCK_BALANCE,T1.INSTRG_DATE,T2.STORAGE_SILO_CODE,T2.SILO_CODE,T2.SILO_NAME FROM "+
|
||||||
|
"(select * FROM T_STK_STORAGE where STOCK_BALANCE > 0 AND MONITOR_ID = '{0}') T1 "+
|
||||||
|
"INNER JOIN "+
|
||||||
|
"T_STK_STORAGE_SILO T2 "+
|
||||||
|
"ON T1.STORAGE_CODE = T2.STORAGE_CODE"
|
||||||
|
, monitorid);
|
||||||
|
|
||||||
|
StringBuilder strSql = new StringBuilder();
|
||||||
|
strSql.Append(sql);
|
||||||
|
|
||||||
return DbHelperSQL.Query(strSql.ToString());
|
return DbHelperSQL.Query(strSql.ToString());
|
||||||
}
|
}
|
||||||
#endregion ExtensionMethod
|
#endregion ExtensionMethod
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Competition.Mysql.Other
|
||||||
|
{
|
||||||
|
public class YardStorageCheck
|
||||||
|
{
|
||||||
|
public Guid STORAGE_CODE;
|
||||||
|
public string GOODS_CODE;
|
||||||
|
public int GOODS_TYPE;
|
||||||
|
public string STANDARD_NAME;
|
||||||
|
public string MONITOR_ID;
|
||||||
|
public string MONITOR_NAME;
|
||||||
|
public string CUSTOMS_CODE;
|
||||||
|
public decimal STOCK_BALANCE;
|
||||||
|
public DateTime INSTRG_DATE;
|
||||||
|
public Guid STORAGE_SILO_CODE;
|
||||||
|
public string SILO_CODE;
|
||||||
|
public string SILO_NAME;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
using Competition.Common.Util;
|
using Competition.Common.Util;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.POIFS.Crypt.Dsig;
|
||||||
|
|
||||||
namespace CompetitionAPI.Controllers.api
|
namespace CompetitionAPI.Controllers.api
|
||||||
{
|
{
|
||||||
|
@ -36,9 +37,12 @@ namespace CompetitionAPI.Controllers.api
|
||||||
var mysql = Configuration.GetConnectionString("MySQL").ToString();
|
var mysql = Configuration.GetConnectionString("MySQL").ToString();
|
||||||
//福州海关下的,本年度,按货种分类
|
//福州海关下的,本年度,按货种分类
|
||||||
var list_good = bll_good.GetModelList("");
|
var list_good = bll_good.GetModelList("");
|
||||||
var list = bll_storage.GetModelList("YEAR(INSTRG_DATE) = YEAR(GETDATE())").FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
|
//var list = bll_storage.GetModelList("YEAR(INSTRG_DATE) = YEAR(GETDATE())").FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
|
||||||
|
var list = bll_storage.GetModelList(string.Format("YEAR(INSTRG_DATE) = {0}",year)).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
|
||||||
//总进出口重量
|
//总进出口重量
|
||||||
decimal allWT = 0;
|
decimal allWT = 0;
|
||||||
|
if(list.Count > 0)
|
||||||
|
{
|
||||||
//商品编号,重量
|
//商品编号,重量
|
||||||
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
|
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
|
||||||
//所有商品按种类累计重量
|
//所有商品按种类累计重量
|
||||||
|
@ -118,6 +122,15 @@ namespace CompetitionAPI.Controllers.api
|
||||||
|
|
||||||
return Json(Tool.GetJsonWithCode(APICode.Success, data));
|
return Json(Tool.GetJsonWithCode(APICode.Success, data));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
//响应数据
|
||||||
|
var data = new { allNum = list_good.Count, showData = new List<object>() };
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, data));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在库总量
|
/// 在库总量
|
||||||
|
|
|
@ -102,6 +102,39 @@ namespace CompetitionAPI.Controllers.api
|
||||||
return Json(Tool.GetJsonWithCode(APICode.Success, list));
|
return Json(Tool.GetJsonWithCode(APICode.Success, list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取企业每个堆场的在库数量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="monitorId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public JsonResult GetYardLastStorage(string monitorId)
|
||||||
|
{
|
||||||
|
var mysql = Configuration.GetConnectionString("MySQL").ToString();
|
||||||
|
var list = bll_storage.GetYardLastStorage(monitorId);
|
||||||
|
|
||||||
|
//堆场id,重量
|
||||||
|
Dictionary<string,decimal> dic=new Dictionary<string, decimal>();
|
||||||
|
//当库存放到多个堆场,看作平均分配货物
|
||||||
|
list.GroupBy(a => a.STORAGE_CODE).ToList().ForEach(a =>
|
||||||
|
{
|
||||||
|
//平均每份货物重量
|
||||||
|
decimal one = a.First().STOCK_BALANCE / a.Count();
|
||||||
|
foreach (YardStorageCheck item in a)
|
||||||
|
{
|
||||||
|
if(!dic.ContainsKey(item.SILO_CODE))
|
||||||
|
{
|
||||||
|
dic.Add(item.SILO_CODE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//累计
|
||||||
|
dic[item.SILO_CODE] += one;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, dic));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 堆场模糊查询
|
/// 堆场模糊查询
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue