diff --git a/CompetitionAPI/CompetitionAPI/Competition.Mysql/BLL/T_STK_STORAGE_SILO.cs b/CompetitionAPI/CompetitionAPI/Competition.Mysql/BLL/T_STK_STORAGE_SILO.cs index 13ad153..32657a6 100644 --- a/CompetitionAPI/CompetitionAPI/Competition.Mysql/BLL/T_STK_STORAGE_SILO.cs +++ b/CompetitionAPI/CompetitionAPI/Competition.Mysql/BLL/T_STK_STORAGE_SILO.cs @@ -19,6 +19,7 @@ using System.Data; using System.Collections.Generic; using Maticsoft.Common; using Competition.Mysql.Model; +using Competition.Mysql.Other; namespace Competition.Mysql.BLL { /// @@ -170,18 +171,22 @@ namespace Competition.Mysql.BLL { return dal.GetListByPage( strWhere, orderby, startIndex, endIndex); } - /// - /// 分页获取数据列表 - /// - //public DataSet GetList(int PageSize,int PageIndex,string strWhere) - //{ - //return dal.GetList(PageSize,PageIndex,strWhere); - //} + /// + /// 分页获取数据列表 + /// + //public DataSet GetList(int PageSize,int PageIndex,string strWhere) + //{ + //return dal.GetList(PageSize,PageIndex,strWhere); + //} - #endregion BasicMethod - #region ExtensionMethod - - #endregion ExtensionMethod - } + #endregion BasicMethod + #region ExtensionMethod + public List CheckYardList(ReqYardCheck req) + { + DataSet ds = dal.CheckYardList(req); + return DataTableToList(ds.Tables[0]); + } + #endregion ExtensionMethod + } } diff --git a/CompetitionAPI/CompetitionAPI/Competition.Mysql/DAL/T_STK_STORAGE_SILO.cs b/CompetitionAPI/CompetitionAPI/Competition.Mysql/DAL/T_STK_STORAGE_SILO.cs index 29a9658..6a09521 100644 --- a/CompetitionAPI/CompetitionAPI/Competition.Mysql/DAL/T_STK_STORAGE_SILO.cs +++ b/CompetitionAPI/CompetitionAPI/Competition.Mysql/DAL/T_STK_STORAGE_SILO.cs @@ -18,12 +18,13 @@ using System; using System.Data; using System.Text; using System.Data.SqlClient; -using Maticsoft.DBUtility;//Please add references +using Maticsoft.DBUtility; +using Competition.Mysql.Other;//Please add references namespace Competition.Mysql.DAL { - /// - /// 数据访问类:T_STK_STORAGE_SILO - /// + /// + /// 数据访问类:T_STK_STORAGE_SILO + /// public partial class T_STK_STORAGE_SILO { public T_STK_STORAGE_SILO() @@ -378,7 +379,7 @@ namespace Competition.Mysql.DAL return DbHelperSQL.Query(strSql.ToString()); } - /* + /* /// /// 分页获取数据列表 /// @@ -403,10 +404,67 @@ namespace Competition.Mysql.DAL return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); }*/ - #endregion BasicMethod - #region ExtensionMethod + #endregion BasicMethod + #region ExtensionMethod + public DataSet CheckYardList(ReqYardCheck req) + { + string T1, T2; - #endregion ExtensionMethod - } + if (string.IsNullOrEmpty(req.SILO_CODE)) + { + T1 = "T_STK_STORAGE_SILO"; + } + else + { + T1 = string.Format("(select * FROM T_STK_STORAGE_SILO WHERE SILO_CODE LIKE '{0}')", req.SILO_CODE); + } + + if(string.IsNullOrEmpty(req.SHIP_NAME_EN) && string.IsNullOrEmpty(req.VOYAGE_NO) && string.IsNullOrEmpty(req.STANDARD_NAME)) + { + T2 = "T_STK_STORAGE"; + } + else + { + T2 = "(select * FROM T_STK_STORAGE WHERE "; + string tmp1="",tmp2="",tmp3=""; + if(!string.IsNullOrEmpty(req.SHIP_NAME_EN)) + { + tmp1 = string.Format("SHIP_NAME_EN LIKE '{0}' AND ", req.SHIP_NAME_EN); + } + + if (!string.IsNullOrEmpty(req.VOYAGE_NO)) + { + tmp2 = string.Format("VOYAGE_NO LIKE '{0}' AND ", req.VOYAGE_NO); + } + + if (!string.IsNullOrEmpty(req.STANDARD_NAME)) + { + tmp3 = string.Format("STANDARD_NAME LIKE '{0}' AND ", req.STANDARD_NAME); + } + + //拼接 + T2 = T2 + tmp1 + tmp2 + tmp3; + T2 = T2.TrimEnd(" AND ".ToCharArray()); + + //结尾 + T2 += ")"; + } + + string sql = string.Format( + "select T1.* " + + "FROM " + + "{0} T1 " + + "INNER JOIN " + + "{1} T2 " + + "ON T1.STORAGE_CODE = T2.STORAGE_CODE",T1,T2); + + StringBuilder strSql = new StringBuilder(); + strSql.Append(sql); + + return DbHelperSQL.Query(strSql.ToString()); + } + + #endregion ExtensionMethod + } } diff --git a/CompetitionAPI/CompetitionAPI/Competition.Mysql/Other/ReqYardCheck.cs b/CompetitionAPI/CompetitionAPI/Competition.Mysql/Other/ReqYardCheck.cs new file mode 100644 index 0000000..77e2c16 --- /dev/null +++ b/CompetitionAPI/CompetitionAPI/Competition.Mysql/Other/ReqYardCheck.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Competition.Mysql.Other +{ + /// + /// YardController_CheckYard()查询条件 + /// + public class ReqYardCheck + { + /// + /// 船名 + /// + public string SHIP_NAME_EN; + /// + /// 航次 + /// + public string VOYAGE_NO; + /// + /// 商品名称 + /// + public string STANDARD_NAME; + /// + /// 卸货地(堆场编码) + /// + public string SILO_CODE; + } +} diff --git a/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/YardController.cs b/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/YardController.cs index cc6a21b..96359d4 100644 --- a/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/YardController.cs +++ b/CompetitionAPI/CompetitionAPI/CompetitionAPI/Controllers/api/YardController.cs @@ -1,6 +1,9 @@ using Competition.Common.Util; +using Competition.Mysql.Other; using Microsoft.AspNetCore.Mvc; using NPOI.POIFS.Crypt.Dsig; +using NPOI.SS.Formula.Functions; +using System.Reflection.Metadata; namespace CompetitionAPI.Controllers.api { @@ -97,6 +100,24 @@ namespace CompetitionAPI.Controllers.api return Json(Tool.GetJsonWithCode(APICode.Success, list)); } + /// + /// 堆场模糊查询 + /// + /// + /// + [HttpPost] + public JsonResult CheckYard([FromBody] ReqYardCheck req) + { + var mysql = Configuration.GetConnectionString("MySQL").ToString(); + //查询商品库存地列表 + var list = bll_storageSILO.CheckYardList(req); + var silos=list.GroupBy(a => a.SILO_CODE).ToList(); + List tmps= new List(); + silos.ForEach(a => + { + tmps.Add(new { SILO_CODE = a.Key, SILO_NAME = a.First().SILO_NAME }); + }); + return Json(Tool.GetJsonWithCode(APICode.Success, tmps)); + } } - }