This commit is contained in:
陈向学 2024-06-17 20:43:00 +08:00
parent a23762cccb
commit d769bf9622
8 changed files with 452 additions and 312 deletions

View File

@ -170,9 +170,9 @@ namespace Competition.Mysql.BLL
{
return dal.GetListByPage( strWhere, orderby, startIndex, endIndex);
}
/// <summary>
/// 分页获取数据列表
/// </summary>
///// <summary>
///// 分页获取数据列表
///// </summary>
//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
//{
//return dal.GetList(PageSize,PageIndex,strWhere);
@ -180,7 +180,16 @@ namespace Competition.Mysql.BLL
#endregion BasicMethod
#region ExtensionMethod
/// <summary>
/// 获取堆场内库存记录
/// </summary>
/// <param name="siloCode"></param>
/// <returns></returns>
public List<Competition.Mysql.Model.T_STK_STORAGE> GetYardList(string siloCode)
{
DataSet ds = dal.GetYardStorage(siloCode);
return DataTableToList(ds.Tables[0]);
}
#endregion ExtensionMethod
}
}

View File

@ -666,7 +666,7 @@ namespace Competition.Mysql.DAL
return DbHelperSQL.Query(strSql.ToString());
}
/*
/*
/// <summary>
/// 分页获取数据列表
/// </summary>
@ -691,10 +691,36 @@ namespace Competition.Mysql.DAL
return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
}*/
#endregion BasicMethod
#region ExtensionMethod
#endregion BasicMethod
#region ExtensionMethod
/// <summary>
/// 获取堆场库存
/// </summary>
/// <param name="strWhere"></param>
/// <returns></returns>
public DataSet GetYardStorage(string silo_code)
{
//string sql=string.Format(
// "select T1.* " +
// "FROM T_STK_STORAGE T1 " +
// "LEFT JOIN " +
// "T_STK_STORAGE_SILO T2 " +
// "ON T1.STORAGE_CODE = T2.STORAGE_CODE " +
// "WHERE T2.SILO_CODE = '{0}'", silo_code);
#endregion ExtensionMethod
}
string sql = string.Format(
"select T1.* " +
"FROM T_STK_STORAGE T1 " +
"INNER JOIN " +
"(select * FROM T_STK_STORAGE_SILO WHERE SILO_CODE='{0}') T2 " +
"ON T1.STORAGE_CODE = T2.STORAGE_CODE", silo_code);
StringBuilder strSql = new StringBuilder();
strSql.Append(sql);
return DbHelperSQL.Query(strSql.ToString());
}
#endregion ExtensionMethod
}
}

View File

@ -20,26 +20,17 @@ namespace CompetitionAPI.Controllers.api
}
/// <summary>
///
/// 根据企业id获取相机列表
/// </summary>
/// <param name="action"></param>
/// <param name="monotorId">公司id</param>
/// <param name="monotorId"></param>
/// <returns></returns>
[HttpGet]
public JsonResult Index(string action,string monotorId)
public JsonResult GetList(string monotorId)
{
if(action =="GetList")
{
//获取公司所有相机信息
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var list = bll_camera.GetModelList("MONITOR_ID = " + monotorId).FindAll(a=>Tool.IsFuZhouCustom(monotorId));
return Json(Tool.GetJsonWithCode(APICode.Success, list));
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "action填写错误"));
}
//获取公司所有相机信息
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var list = bll_camera.GetModelList(string.Format("MONITOR_ID = '{0}'", monotorId)).FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
return Json(Tool.GetJsonWithCode(APICode.Success, list));
}
}
}

View File

@ -21,59 +21,61 @@ namespace CompetitionAPI.Controllers.api
}
/// <summary>
/// 企业
/// 获取福州海关所有监管企业总数
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpGet]
public JsonResult Index(string action)
public JsonResult GetNum()
{
if (action == "getNum")
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//查询企业表所有数据
var list = bll.GetModelList("");
//按海关区分组统计
int maWei = 0;
int rongCheng = 0;
int ningDe = 0;
int puTian = 0;
list.ForEach(model =>
{
//获取监管企业总数接口
//读取配置文件示例
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//查询企业表所有数据
var list = bll.GetModelList("");
//按海关区分组统计
int maWei = 0;
int rongCheng = 0;
int ningDe = 0;
int puTian = 0;
list.ForEach(model =>
if(model.CUSTOMS_CODE =="3501")
{
if(model.CUSTOMS_CODE =="3501")
{
//马尾
maWei++;
}
else if (model.CUSTOMS_CODE == "3500" || model.CUSTOMS_CODE == "3505")
{
//蓉城
rongCheng++;
}
else if(model.CUSTOMS_CODE == "3503")
{
//宁德
ningDe++;
}
else if(model.CUSTOMS_CODE=="3506")
{
//莆田
puTian++;
}
});
//马尾
maWei++;
}
else if (model.CUSTOMS_CODE == "3500" || model.CUSTOMS_CODE == "3505")
{
//蓉城
rongCheng++;
}
else if(model.CUSTOMS_CODE == "3503")
{
//宁德
ningDe++;
}
else if(model.CUSTOMS_CODE=="3506")
{
//莆田
puTian++;
}
});
var data = new { rongCheng = rongCheng, maWei = maWei, ningDe = ningDe, puTian = puTian };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
var data = new { rongCheng = rongCheng, maWei = maWei, ningDe = ningDe, puTian = puTian };
/// <summary>
/// 根据企业id获取企业信息
/// </summary>
/// <param name="monitorId"></param>
/// <returns></returns>
[HttpGet]
public JsonResult GetInfo(string monitorId)
{
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var tmp = bll.GetModel(monitorId);
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "参数输入错误"));
}
return Json(Tool.GetJsonWithCode(APICode.Success, tmp));
}
}
}

View File

@ -25,222 +25,238 @@ namespace CompetitionAPI.Controllers.api
}
/// <summary>
///
/// //全年进出口商品种类
/// </summary>
/// <param name="action"></param>
/// <param name="year">年份</param>
/// <returns></returns>
[HttpGet]
public JsonResult Index(string action,int year)
public JsonResult GetGoodNumByYear(int year)
{
if (action == "getGoodNumThisYear")
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//福州海关下的,本年度,按货种分类
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 =>
{
//进出口商品种类
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//福州海关下的,本年度,按货种分类
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))
{
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);
dic.Add(a.GOODS_CODE,a.BILL_GROSS_WT.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;
dic[a.GOODS_CODE] += a.BILL_GROSS_WT.Value;
}
});
var tmp=dic.OrderByDescending(a => a.Value).ToList();
//构造分类数据
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 { allNum= list_good.Count, showData = showData };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
else if(action=="getLastNum")
//取前三个商品+其他
Dictionary<string,decimal> dic2 = new Dictionary<string,decimal>();
if(tmp.Count==1)
{
//在库总量
decimal num=0;
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//库存字段大于0
var list = bll_storage.GetModelList("STOCK_BALANCE > 0").FindAll(a=>Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
list.ForEach(a =>
{
num += a.STOCK_BALANCE.Value;
});
var data=new {num=num,dw="kg" };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
//1种货物
dic2.Add(tmp[0].Key, tmp[0].Value);
}
else if(action=="getBoCiByYear")
else if(tmp.Count == 2)
{
//全年累计进出口传播艘次
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));
//2种货物
dic2.Add(tmp[0].Key, tmp[0].Value);
dic2.Add(tmp[1].Key, tmp[1].Value);
}
else if(action=="getInNumByYear")
else if(tmp.Count==3)
{
//全年累计进口总量,按年度查询
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 if(action== "getInNumWithCurrent")
{
//本年度,本季度进口总量
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//本年度福州海关下的进口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));
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;
});
//计算总和
decimal sumYear = dic.Sum(a => a.Value);
decimal sumQuarter = 0;
if (new int[] { 1, 2, 3 }.Contains(DateTime.Now.Month))
{
sumQuarter = dic[1] + dic[2] + dic[3];
}
else if(new int[] { 4, 5, 6 }.Contains(DateTime.Now.Month))
{
sumQuarter = dic[4] + dic[5] + dic[6];
}
else if (new int[] { 7, 8, 9 }.Contains(DateTime.Now.Month))
{
sumQuarter = dic[7] + dic[8] + dic[9];
}
else
{
sumQuarter = dic[10] + dic[11] + dic[12];
}
var data = new { currentYearSum= sumYear, currentQuarterSum= sumQuarter,dw="kg" };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
//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
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "action填写错误"));
//大于三种
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 =>
{
object lastTmp;
if (index <= 3)
{
//商品名称,重量,单位,占比
lastTmp = new { goodCode=a ,goodName = list_good.Find(b => b.GOODS_CODE == a).STANDARD_NAME, wt = dic2[a], danWei = "kg", percent = dic2[a] / allWT };
}
else
{
lastTmp = new { goodName = "其他", wt = dic2[a], danWei = "kg", percent = dic2[a] / allWT };
}
showData.Add(lastTmp);
index++;
});
//响应数据
var data = new { allNum= list_good.Count, showData = showData };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
/// <summary>
/// 在库总量
/// </summary>
/// <returns></returns>
[HttpGet]
public JsonResult GetLastNum()
{
//在库总量
decimal num = 0;
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//库存字段大于0
var list = bll_storage.GetModelList("STOCK_BALANCE > 0").FindAll(a => Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
list.ForEach(a =>
{
num += a.STOCK_BALANCE.Value;
});
var data = new { num = num, dw = "kg" };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
/// <summary>
/// 全年累计进出口传播艘次
/// </summary>
/// <param name="year"></param>
/// <returns></returns>
[HttpGet]
public JsonResult GetBoCiByYear(int year)
{
//全年累计进出口传播艘次
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));
}
/// <summary>
/// 全年累计进口总量,按年度查询
/// </summary>
/// <returns></returns>
[HttpGet]
public JsonResult GetInNumByYear(int year)
{
//全年累计进口总量,按年度查询
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));
}
/// <summary>
/// 本年度和本季度进口总量
/// </summary>
/// <returns></returns>
[HttpGet]
public JsonResult GetInNumWithCurrent()
{
//本年度,本季度进口总量
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//本年度福州海关下的进口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));
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;
});
//计算总和
decimal sumYear = dic.Sum(a => a.Value);
decimal sumQuarter = 0;
if (new int[] { 1, 2, 3 }.Contains(DateTime.Now.Month))
{
sumQuarter = dic[1] + dic[2] + dic[3];
}
else if (new int[] { 4, 5, 6 }.Contains(DateTime.Now.Month))
{
sumQuarter = dic[4] + dic[5] + dic[6];
}
else if (new int[] { 7, 8, 9 }.Contains(DateTime.Now.Month))
{
sumQuarter = dic[7] + dic[8] + dic[9];
}
else
{
sumQuarter = dic[10] + dic[11] + dic[12];
}
var data = new { currentYearSum = sumYear, currentQuarterSum = sumQuarter, dw = "kg" };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
}
}

View File

@ -1,5 +1,8 @@
using Competition.Common.Util;
using CompetitionAPI.api.version;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.IO.Pipelines;
namespace CompetitionAPI.Controllers.api
{
@ -8,7 +11,7 @@ namespace CompetitionAPI.Controllers.api
public class WeighterController : Controller
{
/// <summary>
/// 相机
/// 皮带秤
/// </summary>
Competition.Mysql.BLL.T_BAS_ELEC_WEIGHTER bll_elec_weighter = new Competition.Mysql.BLL.T_BAS_ELEC_WEIGHTER();
/// <summary>
@ -27,32 +30,82 @@ namespace CompetitionAPI.Controllers.api
Configuration = configuration;
}
/// <summary>
/// 根据皮带秤编码和企业id获取皮带秤信息
/// </summary>
/// <param name="pipeCode"></param>
/// <param name="customCode"></param>
/// <returns></returns>
[HttpGet]
public JsonResult Index(string action,string pipeCode,string customCode)
public JsonResult GetInfo(string pipeCode,string monitorId)
{
if (action == "GetInfo")
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var pipe = bll_elec_weighter.GetModel(pipeCode, monitorId);
if (Tool.IsFuZhouCustom(pipe.CUSTOMS_CODE))
{
//获取皮带秤信息
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//福州海关下的,本年度
var pipe = bll_elec_weighter.GetModel(pipeCode,customCode);
if (Tool.IsFuZhouCustom(pipe.CUSTOMS_CODE))
{
return Json(Tool.GetJsonWithCode(APICode.Success, pipe));
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "不是福州海关数据"));
}
return Json(Tool.GetJsonWithCode(APICode.Success, pipe));
}
//else if (action == "GetHistory")
//{
// //获取历史信息
//}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "action填写错误"));
return Json(Tool.GetJsonWithCode(APICode.Fail, "不是福州海关数据"));
}
}
/// <summary>
/// 根据企业id获取皮带秤列表
/// </summary>
/// <param name="monitorId"></param>
/// <returns></returns>
[HttpGet]
public JsonResult GetList(string monitorId)
{
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var list = bll_elec_weighter.GetModelList(string.Format("MONITOR_ID = '{0}'", monitorId)).FindAll(a=>Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
return Json(Tool.GetJsonWithCode(APICode.Success, list));
}
/// <summary>
/// 获取一个皮带秤实时数据
/// </summary>
/// <param name="pipeCode"></param>
/// <returns></returns>
[HttpGet]
public JsonResult GetRealTimeData(string pipeCode)
{
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var tmp=bll_pipeReal.GetModel(pipeCode);
return Json(Tool.GetJsonWithCode(APICode.Success, tmp));
}
/// <summary>
/// 获取一个皮带秤历史数据列表(按时间倒序,间隔筛选出N条)
/// </summary>
/// <param name="pipeCode"></param>
/// <returns></returns>
[HttpPost]
public JsonResult GetHistroyData([FromBody] RequestHistoryData req)
{
if (!string.IsNullOrEmpty(req.pipeCode) && req.startTime != null && req.endTime != null && req.startTime<=req.endTime)
{
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var list = bll_pipeHistory.GetModelList(string.Format("PIPE_CODE = '{0}' AND (COLL_TIME BETWEEN '{1}' AND '{2}')", req.pipeCode,req.startTime,req.endTime)).OrderByDescending(a => a.COLL_TIME.Value).ToList();
return Json(Tool.GetJsonWithCode(APICode.Success, list));
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "请求参数不全"));
}
}
}
/// <summary>
/// 获取历史数据
/// </summary>
public class RequestHistoryData
{
public string pipeCode;
public DateTime startTime;
public DateTime endTime;
}
}

View File

@ -1,5 +1,6 @@
using Competition.Common.Util;
using Microsoft.AspNetCore.Mvc;
using NPOI.POIFS.Crypt.Dsig;
namespace CompetitionAPI.Controllers.api
{
@ -8,7 +9,22 @@ namespace CompetitionAPI.Controllers.api
[ApiController]
public class YardController : Controller
{
/// <summary>
/// 企业表
/// </summary>
Competition.Mysql.BLL.T_BAS_CORPORATION bll_corporation = new Competition.Mysql.BLL.T_BAS_CORPORATION();
/// <summary>
/// 堆场表
/// </summary>
Competition.Mysql.BLL.T_BAS_YARD bll_yard=new Competition.Mysql.BLL.T_BAS_YARD();
/// <summary>
/// 堆场表
/// </summary>
Competition.Mysql.BLL.T_STK_STORAGE bll_storage=new Competition.Mysql.BLL.T_STK_STORAGE();
/// <summary>
/// 库存存储地表
/// </summary>
Competition.Mysql.BLL.T_STK_STORAGE_SILO bll_storageSILO=new Competition.Mysql.BLL.T_STK_STORAGE_SILO();
public IConfiguration Configuration { get; }
@ -18,46 +34,69 @@ namespace CompetitionAPI.Controllers.api
}
/// <summary>
/// 首页堆场
/// 首页堆场
/// </summary>
/// <param name="action"></param>
/// <param name="name"></param>
/// <returns></returns>
[HttpGet]
public JsonResult Index(string action)
public JsonResult GetAllInfo()
{
if(action=="getNum")
//堆场总数
int allNum = 0;
//堆场面积
decimal allArea = 0;
//筒仓总数
int allSilo = 0;
//读取配置文件示例
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//查询企业表所有数据
var list = bll_corporation.GetModelList("").FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
list.ForEach(x =>
{
//堆场总数
int allNum = 0;
//堆场面积
int allArea = 0;
//筒仓总数
int allSilo = 0;
//读取配置文件示例
var mysql = Configuration.GetConnectionString("MySQL").ToString();
//查询企业表所有数据
var list = bll_corporation.GetModelList("").FindAll(a=> Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
list.ForEach(x =>
allNum += int.Parse(x.YARD_NUM);
//格式不标准不计算
if (decimal.TryParse(x.YARD_AREA.Replace("平方米", "").Replace("㎡", "").Replace("㎡", ""), out decimal area))
{
allNum += int.Parse(x.YARD_NUM);
allArea += int.Parse(x.YARD_AREA.Replace("平方米",""));
//不是所有企业都有筒仓
if (!string.IsNullOrEmpty(x.SILO_NUM))
{
allSilo += int.Parse(x.SILO_NUM);
}
});
var data = new { allNum = allNum, allArea = allArea, allSilo = allSilo };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "action填写错误"));
}
allArea += area;
}
//不是所有企业都有筒仓
if (!string.IsNullOrEmpty(x.SILO_NUM))
{
allSilo += int.Parse(x.SILO_NUM);
}
});
var data = new { allNum = allNum, allArea = allArea, allSilo = allSilo };
return Json(Tool.GetJsonWithCode(APICode.Success, data));
}
/// <summary>
/// 根据企业id获取堆场信息
/// </summary>
/// <param name="monitorId">企业id</param>
/// <returns></returns>
[HttpGet]
public JsonResult GetYardList(string monitorId)
{
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var list = bll_yard.GetModelList(string.Format("MONITOR_ID = '{0}'", monitorId)).FindAll(a=>Tool.IsFuZhouCustom(a.CUSTOMS_CODE));
return Json(Tool.GetJsonWithCode(APICode.Success, list));
}
/// <summary>
/// 根据堆场id获取堆场库存信息
/// </summary>
/// <param name="SILO_CODE"></param>
/// <returns></returns>
[HttpGet]
public JsonResult GetYardStorage(string SILO_CODE)
{
var mysql = Configuration.GetConnectionString("MySQL").ToString();
var list = bll_storage.GetYardList(SILO_CODE).OrderByDescending(a=>a.INSTRG_DATE.Value).ToList();
return Json(Tool.GetJsonWithCode(APICode.Success, list));
}
}
}

View File

@ -1,4 +1,5 @@
using Autofac.Extensions.DependencyInjection;
using CompetitionAPI.Controllers.api;
using Microsoft.AspNetCore.Hosting;
namespace CompetitionAPI
@ -7,6 +8,9 @@ namespace CompetitionAPI
{
public static void Main(string[] args)
{
//string tmp = Newtonsoft.Json.JsonConvert.SerializeObject(new RequestHistoryData { pipeCode = "aaa", startTime = DateTime.UtcNow, endTime = DateTime.UtcNow });
//log4net.Config.XmlConfigurator.Configure();
CreateHostBuilder(args).Build().Run();
}