From 5391a8241a48fda661bb9655caa9a8e872f533cf Mon Sep 17 00:00:00 2001 From: chenxiangxue <910695411@qq.com> Date: Wed, 17 Jul 2024 19:08:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=89=E7=BB=B4=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../Controllers/api/CorporationController.cs | 19 +++++++----- .../Controllers/api/StorageController.cs | 30 +++++++++++-------- .../Controllers/api/YardController.cs | 8 +++-- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index dfdec7d..df0bf8f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bin /CompetitionAPI/CompetitionAPI/Competition.Common/obj obj +/CompetitionAPI/CompetitionAPI/CompetitionAPI/CompetitionAPI.csproj.user diff --git a/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/CorporationController.cs b/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/CorporationController.cs index 4e6e47f..99ae754 100644 --- a/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/CorporationController.cs +++ b/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/CorporationController.cs @@ -1,7 +1,9 @@ using Competition.Common.Util; +using Competition.Mysql.Model; using Microsoft.AspNetCore.Mvc; using NPOI.POIFS.Crypt.Dsig; using System; +using System.Collections.Generic; namespace CompetitionAPI.Controllers.api { @@ -34,32 +36,33 @@ namespace CompetitionAPI.Controllers.api //查询企业表所有数据 var list = bll.GetModelList(""); //按海关区分组统计 - int maWei = 0; - int rongCheng = 0; - int ningDe = 0; - int puTian = 0; + List maWei = new List(); + List rongCheng = new List(); + List ningDe = new List(); + List puTian = new List(); + list.ForEach(model => { if(model.CUSTOMS_CODE =="3501") { //马尾 - maWei++; + maWei.Add(model); } else if (model.CUSTOMS_CODE == "3500" || model.CUSTOMS_CODE == "3505") { //蓉城 - rongCheng++; + rongCheng.Add(model); } else if(model.CUSTOMS_CODE == "3503") { //宁德 - ningDe++; + ningDe.Add(model); } else if(model.CUSTOMS_CODE=="3506") { //莆田 - puTian++; + puTian.Add(model); } }); var data = new { rongCheng = rongCheng, maWei = maWei, ningDe = ningDe, puTian = puTian }; diff --git a/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/StorageController.cs b/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/StorageController.cs index f67cca7..f860d8a 100644 --- a/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/StorageController.cs +++ b/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/StorageController.cs @@ -26,20 +26,21 @@ namespace CompetitionAPI.Controllers.api } /// - /// //全年进出口商品种类 + /// (首页)全年进出口商品种类(monitorId可不传) /// /// /// 年份 /// [HttpGet] - public JsonResult GetGoodNumByYear(int year) + public JsonResult GetGoodNumByYear(int year, string monitorId) { CompetitionAPI.Util.LogHelper.WriteLog(DateTime.Now.ToString() + " 调接口:全年进出口商品种类 GetGoodNumByYear"); 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(string.Format("YEAR(INSTRG_DATE) = {0}",year)).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE)); + string sql = string.IsNullOrEmpty(monitorId) ? string.Format("YEAR(INSTRG_DATE) = {0}", year) : string.Format("YEAR(INSTRG_DATE) = {0} AND MONITOR_ID = '{1}'", year, monitorId); + var list = bll_storage.GetModelList(sql).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE)); //总进出口重量 decimal allWT = 0; if(list.Count > 0) @@ -162,18 +163,19 @@ namespace CompetitionAPI.Controllers.api } /// - /// 全年累计进出口传播艘次 + /// 全年累计进出口传播艘次(monitorId可不传) /// /// /// [HttpGet] - public JsonResult GetBoCiByYear(int year) + public JsonResult GetBoCiByYear(int year,string monitorId) { CompetitionAPI.Util.LogHelper.WriteLog(DateTime.Now.ToString() + " 调接口:全年累计进出口传播艘次 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) && a.INSTRG_DATE.HasValue && !string.IsNullOrEmpty(a.VOYAGE_NO) && !string.IsNullOrEmpty(a.SHIP_NAME_EN)).GroupBy(a => a.VOYAGE_NO + "," + a.SHIP_NAME_EN).ToList(); + string sql = string.IsNullOrEmpty(monitorId) ? string.Format("YEAR(INSTRG_DATE) = {0}", year) : string.Format("YEAR(INSTRG_DATE) = {0} AND MONITOR_ID = '{1}'", year, monitorId); + var list = bll_storage.GetModelList(sql).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE) && a.INSTRG_DATE.HasValue && !string.IsNullOrEmpty(a.VOYAGE_NO) && !string.IsNullOrEmpty(a.SHIP_NAME_EN)).GroupBy(a => a.VOYAGE_NO + "," + a.SHIP_NAME_EN).ToList(); Dictionary dic = new Dictionary(); dic.Add(1, 0); dic.Add(2, 0); @@ -197,17 +199,19 @@ namespace CompetitionAPI.Controllers.api } /// - /// 全年累计进口总量,按年度查询 + /// 全年累计进口总量,按年度查询(monitorId可不传) /// /// [HttpGet] - public JsonResult GetInNumByYear(int year) + public JsonResult GetInNumByYear(int year,string monitorId) { CompetitionAPI.Util.LogHelper.WriteLog(DateTime.Now.ToString() + " 调接口:全年累计进口总量,按年度查询 GetInNumByYear"); //全年累计进口总量,按年度查询 var mysql = Configuration.GetConnectionString("MySQL").ToString(); + + string sql = string.IsNullOrEmpty(monitorId) ? string.Format("I_E_FLAG = 'I' AND YEAR(INSTRG_DATE) = {0}", year) : string.Format("I_E_FLAG = 'I' AND YEAR(INSTRG_DATE) = {0} AND MONITOR_ID = '{1}'", year, monitorId); //按年度,福州海关下的,进口,BILL_GROSS_WT提单毛重即入库数量 - var list = bll_storage.GetModelList("I_E_FLAG = 'I' AND YEAR(INSTRG_DATE) = " + year).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE)); + var list = bll_storage.GetModelList(sql).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE)); Dictionary dic = new Dictionary(); dic.Add(1, 0); dic.Add(2, 0); @@ -237,13 +241,15 @@ namespace CompetitionAPI.Controllers.api /// /// [HttpGet] - public JsonResult GetInNumWithCurrent() + public JsonResult GetInNumWithCurrent(string monitorId) { CompetitionAPI.Util.LogHelper.WriteLog(DateTime.Now.ToString() + " 调接口:本年度和本季度进口总量 GetInNumWithCurrent"); //本年度,本季度进口总量 var mysql = Configuration.GetConnectionString("MySQL").ToString(); + + string sql = string.IsNullOrEmpty(monitorId) ? "I_E_FLAG = 'I' AND YEAR(INSTRG_DATE) = YEAR(GETDATE())" : string.Format("I_E_FLAG = 'I' AND YEAR(INSTRG_DATE) = YEAR(GETDATE()) AND MONITOR_ID = '{0}'", monitorId); //本年度,福州海关下的,进口,BILL_GROSS_WT提单毛重即入库数量 - var list = bll_storage.GetModelList("I_E_FLAG = 'I' AND YEAR(INSTRG_DATE) = YEAR(GETDATE())").FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE)); + var list = bll_storage.GetModelList(sql).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE)); Dictionary dic = new Dictionary(); dic.Add(1, 0); dic.Add(2, 0); diff --git a/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/YardController.cs b/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/YardController.cs index be54024..9eb423e 100644 --- a/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/YardController.cs +++ b/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/YardController.cs @@ -41,13 +41,13 @@ namespace CompetitionAPI.Controllers.api } /// - /// 首页堆场总数 + /// 首页堆场总数(monitorId不传就是所有的) /// /// /// /// [HttpGet] - public JsonResult GetAllInfo() + public JsonResult GetAllInfo(string monitorId) { CompetitionAPI.Util.LogHelper.WriteLog(DateTime.Now.ToString()+ " 调接口:首页堆场总数 GetAllInfo"); //堆场总数 @@ -59,7 +59,8 @@ namespace CompetitionAPI.Controllers.api //读取配置文件示例 var mysql = Configuration.GetConnectionString("MySQL").ToString(); //查询企业表所有数据 - var list = bll_corporation.GetModelList("").FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE)); + string sql = string.IsNullOrEmpty(monitorId) ? "" : string.Format("MONITOR_ID = '{0}'", monitorId); + var list = bll_corporation.GetModelList(sql).FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE)); list.ForEach(x => { allNum += int.Parse(x.YARD_NUM); @@ -77,6 +78,7 @@ namespace CompetitionAPI.Controllers.api return Json(Tool.GetJsonWithCode(APICode.Success, data)); } + /// /// 根据企业id获取堆场信息 ///