This commit is contained in:
陈向学 2024-06-16 09:34:31 +08:00
parent 2953dc7aa5
commit 94d80533c9
4 changed files with 149 additions and 21 deletions

View File

@ -457,6 +457,7 @@ namespace Competition.Common.Util
/// <returns></returns>
public static bool IsFuZhouCustom(string customCode)
{
//目前只考虑了蓉城,马尾,宁德,莆田
if (customCode == "3501" || customCode == "3502" || customCode == "3503" || customCode == "3505" || customCode == "3506")
{
return true;

View File

@ -41,10 +41,7 @@ namespace CompetitionAPI.Controllers.api
int rongCheng = 0;
int ningDe = 0;
int puTian = 0;
int sanMing = 0;
int pingTan = 0;
int changLeJiChang = 0;
int wuYiShan = 0;
list.ForEach(model =>
{
if(model.CUSTOMS_CODE =="3501")
@ -69,7 +66,7 @@ namespace CompetitionAPI.Controllers.api
}
});
var data = new { rongCheng = rongCheng, maWei = maWei, ningDe = ningDe, puTian = puTian, sanMing = sanMing, pingTan = pingTan, changLeJiChang = changLeJiChang, wuYiShan = wuYiShan };
var data = new { rongCheng = rongCheng, maWei = maWei, ningDe = ningDe, puTian = puTian };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}

View File

@ -8,6 +8,10 @@ namespace CompetitionAPI.Controllers.api
[ApiController]
public class StorageController : Controller
{
/// <summary>
/// 种货表
/// </summary>
Competition.Mysql.BLL.T_BAS_GOODS bll_good = new Competition.Mysql.BLL.T_BAS_GOODS();
/// <summary>
/// 库存表
/// </summary>
@ -21,39 +25,164 @@ namespace CompetitionAPI.Controllers.api
}
[HttpGet]
public JsonResult Index(string action)
public JsonResult Index(string action,int year)
{
if (action == "getGoodNum")
if (action == "getGoodNumThisYear")
{
//进出口商品种类
//读取配置文件示例
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//福州海关,本年度,按货种分类
var list = bll_storage.GetModelList("").FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE) && a.INSTRG_DATE.Value.Year==DateTime.Now.Year).GroupBy(a=>a.GOODS_CODE).ToList();
list.ForEach(x =>
//福州海关下的,本年度,按货种分类
var list_good = bll_good.GetModelList("");
var list = bll_storage.GetModelList("YEAR(INSTRG_DATE) = YEAR(GETDATE())").FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
//总进出口重量
decimal allWT = 0;
//商品编号,重量
Dictionary<string,decimal> dic = new Dictionary<string,decimal>();
//所有商品按种类累计重量
list.ForEach(a =>
{
allWT += a.BILL_GROSS_WT.Value;
if(!dic.ContainsKey(a.GOODS_CODE))
{
dic.Add(a.GOODS_CODE,a.BILL_GROSS_WT.Value);
}
else
{
dic[a.GOODS_CODE] += a.BILL_GROSS_WT.Value;
}
});
var tmp=dic.OrderByDescending(a => a.Value).ToList();
//取前三个商品+其他
Dictionary<string,decimal> dic2 = new Dictionary<string,decimal>();
if(tmp.Count==1)
{
//1种货物
dic2.Add(tmp[0].Key, tmp[0].Value);
}
else if(tmp.Count == 2)
{
//2种货物
dic2.Add(tmp[0].Key, tmp[0].Value);
dic2.Add(tmp[1].Key, tmp[1].Value);
}
else if(tmp.Count==3)
{
//3种货物
dic2.Add(tmp[0].Key, tmp[0].Value);
dic2.Add(tmp[1].Key, tmp[1].Value);
dic2.Add(tmp[2].Key, tmp[2].Value);
}
else
{
//大于三种
dic2.Add(tmp[0].Key, tmp[0].Value);
dic2.Add(tmp[1].Key, tmp[1].Value);
dic2.Add(tmp[2].Key, tmp[2].Value);
dic2.Add("other", 0);
//其他总和
decimal other = 0;
for (int i = 3; i < tmp.Count; i++)
{
other += tmp[i].Value;
}
dic2["other"] = other;
}
//构造分类数据
List<object> showData = new List<object>();
//临时索引
int index = 1;
dic2.Keys.ToList().ForEach(a =>
{
if (index <= 3)
{
//商品名称,重量,单位,占比
var tmp = new { goodName = list_good.Find(b => b.GOODS_CODE == a).STANDARD_NAME, wt = dic2[a], danWei = "kg", percent = dic2[a] / allWT };
}
else
{
var tmp= new { goodName = "其他", wt = dic2[a], danWei = "kg", percent = dic2[a] / allWT };
}
showData.Add(tmp);
index++;
});
var data = new { };
//响应数据
var data = new { allNum= list_good.Count, showData = showData };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
else if(action=="getLastNum")
{
//在库总量
decimal num=0;
//读取配置文件示例
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var list = bll_storage.GetModelList("STOCK_BALANCE > 0");
//库存字段大于0
var list = bll_storage.GetModelList("STOCK_BALANCE > 0").FindAll(a=>Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
list.ForEach(a =>
{
num += a.STOCK_BALANCE.Value;
});
return Json(Tool.GetJsonWithCode(APICode.Success, num));
var data=new {num=num,dw="kg" };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
else if(action=="getBoCiByYear")
{
//全年累计进出口传播艘次
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//按年度福州海关下的按VOYAGE_NO+SHIP_NAME_EN 航次+船名算一个艘次
var list = bll_storage.GetModelList("YEAR(INSTRG_DATE) = " + year).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE)).GroupBy(a => a.VOYAGE_NO+","+a.SHIP_NAME_EN).ToList();
Dictionary<int, decimal> dic = new Dictionary<int, decimal>();
dic.Add(1, 0);
dic.Add(2, 0);
dic.Add(3, 0);
dic.Add(4, 0);
dic.Add(5, 0);
dic.Add(6, 0);
dic.Add(7, 0);
dic.Add(8, 0);
dic.Add(9, 0);
dic.Add(10, 0);
dic.Add(11, 0);
dic.Add(12, 0);
list.ForEach(a =>
{
//次数加1
dic[a.First().INSTRG_DATE.Value.Month]++;
});
return Json(Tool.GetJsonWithCode(APICode.Success, dic));
}
else if(action=="getInNumByYear")
{
//全年累计进口总量
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//按年度福州海关下的进口BILL_GROSS_WT提单毛重即入库数量
var list = bll_storage.GetModelList("I_E_FLAG = 'I' AND YEAR(INSTRG_DATE) = " + year).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
Dictionary<int,decimal> dic = new Dictionary<int,decimal>();
dic.Add(1, 0);
dic.Add(2, 0);
dic.Add(3, 0);
dic.Add(4, 0);
dic.Add(5, 0);
dic.Add(6, 0);
dic.Add(7, 0);
dic.Add(8, 0);
dic.Add(9, 0);
dic.Add(10, 0);
dic.Add(11, 0);
dic.Add(12, 0);
list.ForEach(a =>
{
dic[a.INSTRG_DATE.Value.Month] += a.BILL_GROSS_WT.Value;
});
var data = new {dic };
return Json(Tool.GetJsonWithCode(APICode.Success, dic));
}
else
{

View File

@ -37,13 +37,14 @@ namespace CompetitionAPI.Controllers.api
//读取配置文件示例
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//查询企业表所有数据
var list = bll_corporation.GetModelList("");
var list = bll_corporation.GetModelList("").FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
list.ForEach(x =>
{
if(Tool.IsFuZhouCustom(x.CUSTOMS_CODE))
allNum += int.Parse(x.YARD_NUM);
allArea += int.Parse(x.YARD_AREA.Replace("平方米",""));
//不是所有企业都有筒仓
if (!string.IsNullOrEmpty(x.SILO_NUM))
{
allNum += int.Parse(x.YARD_NUM);
allArea += int.Parse(x.YARD_AREA.Replace("平方米",""));
allSilo += int.Parse(x.SILO_NUM);
}
});