|
|
using Dapper;
|
|
|
using Estsh.Core.Dapper;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Repository.IRepositories;
|
|
|
using System.Collections;
|
|
|
using System.Data;
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:收货查询补打数据库访问类
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Repositories
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 收货查询补打模块的业务数据
|
|
|
/// </summary>
|
|
|
public class FinishedInventoryQueryRepository : BaseRepository<MesOutPdline>, IFinishedInventoryQueryRepository
|
|
|
{
|
|
|
public FinishedInventoryQueryRepository(DapperDbContext _dapperDbContext) : base(_dapperDbContext)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取列表
|
|
|
/// </summary>
|
|
|
/// <param name="PageSize"></param>
|
|
|
/// <param name="PageIndex"></param>
|
|
|
/// <param name="strWhere"></param>
|
|
|
/// <param name="OrderBy"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getListByPage(int PageSize, int PageIndex, string strWhere, string OrderBy)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append(@"select a.mtoc,a.mtoc_desc,isnull(rejectsYtbale.rejectsY,0) rejectsY,isnull(rejectsNtbale.rejectsN,0) rejectsN from (
|
|
|
select mtoc, mtoc_desc from sys_stock (nolock) where mtoc <> '' and mtoc is not null and tray_no <> '' and tray_no is not null and status in ('50', '90') and enabled = 'Y'
|
|
|
group by mtoc, mtoc_desc) as a
|
|
|
left join(
|
|
|
select mtoc, mtoc_desc, count(1) rejectsY from sys_stock(nolock) where status = '50' and mtoc<> ''
|
|
|
and mtoc is not null and tray_no <> '' and tray_no is not null and enabled = 'Y' group by mtoc,mtoc_desc ) as rejectsYtbale on a.mtoc = rejectsYtbale.mtoc
|
|
|
left join(
|
|
|
select mtoc, mtoc_desc, count(1) rejectsN from sys_stock(nolock) where status = '90' and mtoc<> ''
|
|
|
and mtoc is not null and tray_no <> '' and tray_no is not null and enabled = 'Y' group by mtoc,mtoc_desc ) as rejectsNtbale on a.mtoc = rejectsNtbale.mtoc
|
|
|
" + strWhere + " order by " + OrderBy);
|
|
|
|
|
|
List<SysStock> dataList = dbConn.Query<SysStock>(SqlStringBuilder.ToString()).ToList();
|
|
|
result.Add("dataList", dataList);
|
|
|
result.Add("totalCount", dataList.Count());
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public Hashtable getTrayNoListByPage(int PageSize, int PageIndex, string strWhere, string OrderBy)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append(@"select a.tray_no,a.mtoc,a.mtoc_desc,isnull(rejectsYtbale.rejectsY,0) rejectsY,isnull(rejectsNtbale.rejectsN,0) rejectsN,isnull(rejectsYtbale.channel_number,0)+isnull (rejectsNtbale.channel_number,0) channel_number from (
|
|
|
select tray_no, mtoc, mtoc_desc from sys_stock (nolock) where mtoc <> '' and mtoc is not null and tray_no <> '' and tray_no is not null and status in ('50', '90') and enabled = 'Y'
|
|
|
group by tray_no, mtoc, mtoc_desc) as a
|
|
|
left join(
|
|
|
select tray_no, mtoc, mtoc_desc, count(1) rejectsY,max(channel_number) channel_number from sys_stock(nolock) where status = '50' and mtoc<> ''
|
|
|
and mtoc is not null and tray_no <> '' and tray_no is not null and enabled = 'Y' group by mtoc,mtoc_desc,tray_no ) as rejectsYtbale on a.tray_no = rejectsYtbale.tray_no
|
|
|
left join(
|
|
|
select tray_no, mtoc, mtoc_desc, count(1) rejectsN,max(channel_number) channel_number from sys_stock(nolock) where status = '90' and mtoc<> ''
|
|
|
and mtoc is not null and tray_no <> '' and tray_no is not null and enabled = 'Y' group by mtoc,mtoc_desc,tray_no ) as rejectsNtbale on a.tray_no = rejectsNtbale.tray_no
|
|
|
" + strWhere + " order by " + OrderBy);
|
|
|
|
|
|
List<SysStock> dataList = dbConn.Query<SysStock>(SqlStringBuilder.ToString()).ToList();
|
|
|
result.Add("dataList", dataList);
|
|
|
result.Add("totalCount", dataList.Count());
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public Hashtable getCartonNoListByPage(int PageSize, int PageIndex, string strWhere, string OrderBy)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append(" select * from sys_stock " + strWhere + " order by " + OrderBy);
|
|
|
|
|
|
List<SysStock> dataList = dbConn.Query<SysStock>(SqlStringBuilder.ToString()).ToList();
|
|
|
result.Add("dataList", dataList);
|
|
|
result.Add("totalCount", dataList.Count());
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<FinishedInventory> getMtocDetailsList(string strWhere, string OrderBy)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append("select a.mtoc,a.mtoc_desc,isnull(b.rejectsY, 0) rejectsY,isnull(c.rejectsN, 0) rejectsN from ");
|
|
|
SqlStringBuilder.Append(" (select mtoc,mtoc_desc from sys_stock (nolock) where mtoc <> '' and mtoc is not null and tray_no <> '' and tray_no is not null group by mtoc,mtoc_desc) as a ");
|
|
|
SqlStringBuilder.Append(" left join(select mtoc,mtoc_desc,count(1) rejectsY from (select tray_no, mtoc,mtoc_desc, count(1) rejectsY from sys_stock (nolock) where status = '50' and mtoc <> '' and mtoc is not null and tray_no <> '' and tray_no is not null and enabled='Y' " + strWhere + " group by mtoc,mtoc_desc,tray_no) a ");
|
|
|
SqlStringBuilder.Append(" group by mtoc,mtoc_desc) as b ");
|
|
|
SqlStringBuilder.Append(" on a.mtoc = b.mtoc ");
|
|
|
SqlStringBuilder.Append(" left join(select mtoc,mtoc_desc,count(1) rejectsN from (select tray_no, mtoc,mtoc_desc, count(1) rejectsY from sys_stock (nolock) where status = '90' and mtoc <> '' and mtoc is not null and tray_no <> '' and tray_no is not null and enabled='Y' " + strWhere + " group by mtoc,mtoc_desc,tray_no) a ");
|
|
|
SqlStringBuilder.Append(" group by mtoc,mtoc_desc) as c ");
|
|
|
SqlStringBuilder.Append(" on a.mtoc = c.mtoc where b.rejectsY!=0 or c.rejectsN!=0 order by " + OrderBy);
|
|
|
|
|
|
List<FinishedInventory> dataList = dbConn.Query<FinishedInventory>(SqlStringBuilder.ToString()).ToList();
|
|
|
return dataList;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |