堆场模糊查询

This commit is contained in:
陈向学 2024-06-18 13:42:57 +08:00
parent 2da7dd1ae6
commit 937eca3566
4 changed files with 137 additions and 22 deletions

View File

@ -19,6 +19,7 @@ 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;
namespace Competition.Mysql.BLL namespace Competition.Mysql.BLL
{ {
/// <summary> /// <summary>
@ -170,18 +171,22 @@ namespace Competition.Mysql.BLL
{ {
return dal.GetListByPage( strWhere, orderby, startIndex, endIndex); return dal.GetListByPage( strWhere, orderby, startIndex, endIndex);
} }
/// <summary> /// <summary>
/// 分页获取数据列表 /// 分页获取数据列表
/// </summary> /// </summary>
//public DataSet GetList(int PageSize,int PageIndex,string strWhere) //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
//{ //{
//return dal.GetList(PageSize,PageIndex,strWhere); //return dal.GetList(PageSize,PageIndex,strWhere);
//} //}
#endregion BasicMethod #endregion BasicMethod
#region ExtensionMethod #region ExtensionMethod
public List<Competition.Mysql.Model.T_STK_STORAGE_SILO> CheckYardList(ReqYardCheck req)
#endregion ExtensionMethod {
} DataSet ds = dal.CheckYardList(req);
return DataTableToList(ds.Tables[0]);
}
#endregion ExtensionMethod
}
} }

View File

@ -18,12 +18,13 @@ using System;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Data.SqlClient; using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references using Maticsoft.DBUtility;
using Competition.Mysql.Other;//Please add references
namespace Competition.Mysql.DAL namespace Competition.Mysql.DAL
{ {
/// <summary> /// <summary>
/// 数据访问类:T_STK_STORAGE_SILO /// 数据访问类:T_STK_STORAGE_SILO
/// </summary> /// </summary>
public partial class T_STK_STORAGE_SILO public partial class T_STK_STORAGE_SILO
{ {
public T_STK_STORAGE_SILO() public T_STK_STORAGE_SILO()
@ -378,7 +379,7 @@ namespace Competition.Mysql.DAL
return DbHelperSQL.Query(strSql.ToString()); return DbHelperSQL.Query(strSql.ToString());
} }
/* /*
/// <summary> /// <summary>
/// 分页获取数据列表 /// 分页获取数据列表
/// </summary> /// </summary>
@ -403,10 +404,67 @@ namespace Competition.Mysql.DAL
return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
}*/ }*/
#endregion BasicMethod #endregion BasicMethod
#region ExtensionMethod #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
}
} }

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Competition.Mysql.Other
{
/// <summary>
/// YardController_CheckYard()查询条件
/// </summary>
public class ReqYardCheck
{
/// <summary>
/// 船名
/// </summary>
public string SHIP_NAME_EN;
/// <summary>
/// 航次
/// </summary>
public string VOYAGE_NO;
/// <summary>
/// 商品名称
/// </summary>
public string STANDARD_NAME;
/// <summary>
/// 卸货地(堆场编码)
/// </summary>
public string SILO_CODE;
}
}

View File

@ -1,6 +1,9 @@
using Competition.Common.Util; using Competition.Common.Util;
using Competition.Mysql.Other;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NPOI.POIFS.Crypt.Dsig; using NPOI.POIFS.Crypt.Dsig;
using NPOI.SS.Formula.Functions;
using System.Reflection.Metadata;
namespace CompetitionAPI.Controllers.api namespace CompetitionAPI.Controllers.api
{ {
@ -97,6 +100,24 @@ namespace CompetitionAPI.Controllers.api
return Json(Tool.GetJsonWithCode(APICode.Success, list)); return Json(Tool.GetJsonWithCode(APICode.Success, list));
} }
/// <summary>
/// 堆场模糊查询
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[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<object> tmps= new List<object>();
silos.ForEach(a =>
{
tmps.Add(new { SILO_CODE = a.Key, SILO_NAME = a.First().SILO_NAME });
});
return Json(Tool.GetJsonWithCode(APICode.Success, tmps));
}
} }
} }