2021-05-10 20:26:19 +08:00
|
|
|
|
using NX.ERP.U8.Purchase;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
using Dapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace NX.ERP.U8.Finance
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FinanceQuery
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="strWhere"></param>
|
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<object> InventorySNDetail(NX.ERP.Model.Request.SnOrderRequest info1)
|
|
|
|
|
|
{
|
|
|
|
|
|
string sql = $@"
|
2021-12-16 14:49:23 +08:00
|
|
|
|
select a.cInvCode,e.cInvName,b.cCode+'-'+convert(varchar(50),k.irowno) as Cprk , b.dDate as rkrq,c.cWhName,
|
|
|
|
|
|
b.cMPoCode+'-'+convert(varchar(50),n.SortSeq) as cMPoCode,d.cDepName,a.cInvSN,a.csnmemo,k.iUnitCost,
|
|
|
|
|
|
g.cCode+'-'+convert(varchar(50),m.irowno) as Clck,g.dDate as ckrq,h.cCusAbbName,f.cInvSN as ckcInvSN
|
2021-05-11 13:11:56 +08:00
|
|
|
|
from ST_SNDetail_PROIN a WITH(NOLOCK)
|
|
|
|
|
|
left join rdrecord10 b WITH(NOLOCK) on a.iVouchID=b.id
|
|
|
|
|
|
left join rdrecords10 k WITH(NOLOCK) on a.iVouchsID=k.autoid
|
2021-12-16 14:49:23 +08:00
|
|
|
|
left join mom_orderdetail n WITH(NOLOCK) on n.MoDId=k.iMPoIds
|
2021-05-11 13:11:56 +08:00
|
|
|
|
left join Warehouse c WITH(NOLOCK) on b.cWhCode =c.cWhCode
|
|
|
|
|
|
left join Department d WITH(NOLOCK) on b.cDepCode =d.cDepCode
|
|
|
|
|
|
left join Inventory e WITH(NOLOCK) on a.cInvCode=e.cInvCode
|
|
|
|
|
|
left join ST_SNDetail_SaleOut f WITH(NOLOCK) on a.cInvSN= f.cInvSN
|
|
|
|
|
|
left join rdrecord32 g WITH(NOLOCK) on f.iVouchID=g.id
|
2021-12-16 14:49:23 +08:00
|
|
|
|
left join rdrecords32 m WITH(NOLOCK) on f.iVouchsID=m.AutoID
|
2021-05-21 13:55:05 +08:00
|
|
|
|
left join Customer h WITH(NOLOCK) on g.cCusCode=h.cCusCode";
|
2021-05-10 20:26:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<string> where = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
if (info1.cInvCodes != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" a.cInvCode in @cInvCode");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (info1.Cprk != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" b.cCode in @Cprk ");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (info1.Clck != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" g.cCode in @Clck ");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (info1.cInvSN != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" a.cInvSN in @cInvSN ");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (info1.BeginDate != null && info1.EndDate != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" b.dDate between @beginDate and @endDate ");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-11 13:11:56 +08:00
|
|
|
|
if (info1.BeginDate2 != null && info1.EndDate2 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" g.dDate between @beginDate2 and @endDate2 ");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-10 20:26:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var aa = string.Join(" and ", where.ToArray());
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(aa))
|
|
|
|
|
|
{
|
2021-05-26 08:50:35 +08:00
|
|
|
|
sql += " where " + aa;
|
2021-05-10 20:26:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
|
|
|
|
|
{
|
2021-05-11 13:11:56 +08:00
|
|
|
|
return conn.Query<object>(sql, new { cInvCode = info1.cInvCodes, Cprk = info1.Cprk, info1.Clck, info1.cInvSN, beginDate=info1.BeginDate, endDate= info1.EndDate, beginDate2 = info1.BeginDate2, endDate2 = info1.EndDate2 });
|
2021-05-10 20:26:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-10 14:25:20 +08:00
|
|
|
|
public IEnumerable<object> Voucherror(NX.ERP.Model.Request.VouchererrorRequest info)
|
|
|
|
|
|
{
|
|
|
|
|
|
string sql = $@"
|
2022-04-11 13:33:53 +08:00
|
|
|
|
select *from (
|
2021-06-10 14:25:20 +08:00
|
|
|
|
select c.MoCode,b.SortSeq,b.InvCode,d.cInvName,a.InvCode as InvCode1, t.cInvName as cInvName1,t.cInvStd,a.Qty , a.IssQty ,'超领' as error from mom_moallocate a WITH (NOLOCK)
|
|
|
|
|
|
left join mom_orderdetail b WITH (NOLOCK) on a.MoDId= b.MoDId
|
|
|
|
|
|
left join mom_order c WITH (NOLOCK) on b.MoId= c.MoId
|
|
|
|
|
|
left join Inventory d WITH (NOLOCK) on b.InvCode= d.cInvCode
|
|
|
|
|
|
left join Inventory t WITH (NOLOCK) on a.InvCode= t.cInvCode
|
|
|
|
|
|
where a.Qty < a.IssQty
|
|
|
|
|
|
|
|
|
|
|
|
union all
|
|
|
|
|
|
select c.MoCode,b.SortSeq,b.InvCode,d.cInvName,a.InvCode as InvCode1, t.cInvName as cInvName1,t.cInvStd,a.Qty , a.IssQty ,'缺领' as error from mom_moallocate a WITH (NOLOCK)
|
|
|
|
|
|
left join mom_orderdetail b WITH (NOLOCK) on a.MoDId= b.MoDId
|
|
|
|
|
|
left join mom_order c WITH (NOLOCK) on b.MoId= c.MoId
|
|
|
|
|
|
left join Inventory d WITH (NOLOCK) on b.InvCode= d.cInvCode
|
|
|
|
|
|
left join Inventory t WITH (NOLOCK) on a.InvCode= t.cInvCode
|
|
|
|
|
|
where a.IssQty < a.Qty*(b.QualifiedInQty/b.qty)
|
2022-04-11 13:33:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
union all
|
|
|
|
|
|
select c.MoCode,b.SortSeq,b.InvCode,d.cInvName,a.InvCode as InvCode1, t.cInvName as cInvName1,t.cInvStd,a.Qty , a.IssQty ,'无应领' as error from mom_moallocate a WITH (NOLOCK)
|
|
|
|
|
|
left join mom_orderdetail b WITH (NOLOCK) on a.MoDId= b.MoDId
|
|
|
|
|
|
left join mom_order c WITH (NOLOCK) on b.MoId= c.MoId
|
|
|
|
|
|
left join Inventory d WITH (NOLOCK) on b.InvCode= d.cInvCode
|
|
|
|
|
|
left join Inventory t WITH (NOLOCK) on a.InvCode= t.cInvCode
|
|
|
|
|
|
where a.Qty=0 and b.QualifiedInQty>0
|
|
|
|
|
|
) mm
|
2021-06-10 14:25:20 +08:00
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<string> where = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
if (info.Ccode != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" mm.MoCode in @Ccode");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (info.error != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" mm.error in @error");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var aa = string.Join(" and ", where.ToArray());
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(aa))
|
|
|
|
|
|
{
|
|
|
|
|
|
sql += " where " + aa;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
|
|
|
|
|
{
|
|
|
|
|
|
return conn.Query<object>(sql, new { info.Ccode, info.error });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-10 20:26:19 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|