2025-04-24 18:31:27 +08:00
|
|
|
|
using MyCode.Project.Domain.Message.Request.InvoiceOrder;
|
|
|
|
|
using MyCode.Project.Domain.Message.Response.InvoiceOrder;
|
|
|
|
|
using MyCode.Project.Domain.Message.Response.PurchaseOrder;
|
|
|
|
|
using MyCode.Project.Domain.Model;
|
|
|
|
|
using MyCode.Project.Domain.Repositories;
|
|
|
|
|
using MyCode.Project.Infrastructure.Common;
|
2025-04-27 16:59:10 +08:00
|
|
|
|
using MyCode.Project.Infrastructure.Extensions;
|
2025-04-24 18:31:27 +08:00
|
|
|
|
using MyCode.Project.Infrastructure.Search;
|
|
|
|
|
using MyCode.Project.Repositories.Common;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace MyCode.Project.Repositories
|
|
|
|
|
{
|
|
|
|
|
public class InvoiceOrderRepository: Repository<InvoiceOrder>, IInvoiceOrderRepository
|
|
|
|
|
{
|
|
|
|
|
public InvoiceOrderRepository(MyCodeSqlSugarClient context) : base(context)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region GetPageList(发货通知单分页列表)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发货通知单分页列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="search"></param>
|
|
|
|
|
/// <param name="supplierId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
public PageResult<InvoiceOrderPageList> GetPageList(PagedSearch<InvoiceOrderPageSearch> search, string supplierId, string FPurchaseOrgId)
|
|
|
|
|
{
|
|
|
|
|
var condition = search.Condition;
|
|
|
|
|
SearchCondition where = new SearchCondition();
|
|
|
|
|
|
|
|
|
|
where.AddCondition("a.PurchaseOrderFBillNo", condition.PurchaseOrderFBillNo, SqlOperator.Like, !string.IsNullOrWhiteSpace(condition.PurchaseOrderFBillNo));
|
|
|
|
|
where.AddCondition("a.[Sheet]", condition.Sheet, SqlOperator.Like, !string.IsNullOrWhiteSpace(condition.Sheet));
|
|
|
|
|
where.AddCondition("a.[FBillNo]", condition.FBillNo, SqlOperator.Like, !string.IsNullOrWhiteSpace(condition.FBillNo));
|
|
|
|
|
if (condition.FDateEmd.HasValue)
|
|
|
|
|
{
|
|
|
|
|
DateTime end = condition.FDateEmd.Value.AddDays(1).Date;
|
|
|
|
|
where.AddCondition("b.DeliveryDate", end, SqlOperator.LessThan, true);
|
|
|
|
|
}
|
|
|
|
|
if (condition.FDateBegin.HasValue)
|
|
|
|
|
{
|
|
|
|
|
DateTime begin = condition.FDateBegin.Value.AddDays(1).Date;
|
|
|
|
|
where.AddCondition("b.[DeliveryDate]", begin, SqlOperator.MoreThanOrEqual, true);
|
|
|
|
|
}
|
|
|
|
|
where.AddCondition("b.MaterialCode", condition.MaterialCode, SqlOperator.Like, !string.IsNullOrWhiteSpace(condition.MaterialCode));
|
|
|
|
|
where.AddCondition("a.supplierId", supplierId, SqlOperator.Equal, !string.IsNullOrWhiteSpace(supplierId));
|
|
|
|
|
where.AddCondition("a.FPurchaseOrgId", FPurchaseOrgId, SqlOperator.Equal, !string.IsNullOrWhiteSpace(FPurchaseOrgId) && FPurchaseOrgId != "-1");
|
|
|
|
|
//where.AddCondition("a.Status", condition.Status, SqlOperator.Equal, condition.Status.HasValue && condition.Status != -1);
|
|
|
|
|
string sql = $@"
|
|
|
|
|
select a.[Id] AS FormId ,A.[FBillNo]
|
|
|
|
|
,[SupplierId]
|
|
|
|
|
,[SupplierName]
|
|
|
|
|
,[Sheet]
|
|
|
|
|
,[FDate]
|
|
|
|
|
,[Creater]
|
|
|
|
|
,[CreateTime]
|
|
|
|
|
,[Editor]
|
|
|
|
|
,[EditTime],FPurchaseOrgId,FPurchaseOrgName
|
|
|
|
|
,F_VHUB_Text
|
|
|
|
|
,(SELECT qty FROM PurchaseOrderItem cc WITH(NOLOCK) WHERE cc.id=b.[PurchaseOrderItemId] ) PurchaseQty
|
|
|
|
|
, (b.[FBillNo] ) AS PurchaseOrderFBillNo
|
|
|
|
|
, isnull((select FReceiveQty from PurchaseOrderItem bb with(nolock) where bb.id=b.[PurchaseOrderItemId] ),0) as SendedQty
|
|
|
|
|
,TiaoMa=B.MaterialCode+'*'+CONVERT(NVARCHAR(20),B.Qty)+'*'+A.FBillNo+'*'+ISNULL(B.FSupplierLot,'')
|
|
|
|
|
,b.[Id]
|
|
|
|
|
,b.[Fid]
|
|
|
|
|
,[MaterialCode]
|
|
|
|
|
,[MaterialName]
|
|
|
|
|
,[SpecificationModel]
|
|
|
|
|
,[Qty]
|
|
|
|
|
,[UnitPrice]
|
|
|
|
|
,[Amount1]
|
|
|
|
|
,[Amount2]
|
|
|
|
|
,[DeliveryDate]
|
|
|
|
|
,[TaxAmount]
|
|
|
|
|
,[ChengNuoJiaoQi]
|
|
|
|
|
,[NewChengNuoJiaoQi]
|
|
|
|
|
,[Remark]
|
|
|
|
|
,b.[PurchaseOrderId]
|
|
|
|
|
,[InvoiceOrderId]
|
2025-04-27 13:44:26 +08:00
|
|
|
|
,b.CuseQty
|
2025-04-24 18:31:27 +08:00
|
|
|
|
,[UnitName]
|
|
|
|
|
,[TaxRate]
|
|
|
|
|
,[FBillTaxAmount]
|
|
|
|
|
,[PurchaseOrderItemId]
|
|
|
|
|
,[FSupplierLot]
|
|
|
|
|
,[MSSSupplierLot]
|
|
|
|
|
,[PurchaseEntityId] FROM [InvoiceOrder] a left join [InvoiceOrderItem] b on a.id=b.[InvoiceOrderId] ";
|
|
|
|
|
var list= this.SelectListPage<InvoiceOrderPageList>(sql, where, search.Page, search.PageSize, " [CreateTime] desc ,FormId,MaterialCode ");
|
|
|
|
|
Guid fid = Guid.Empty;
|
|
|
|
|
list.DataList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
if (fid == t.FormId)
|
|
|
|
|
t.IfHidden = 1;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(t.DeliveryDate))
|
|
|
|
|
{
|
|
|
|
|
t.DeliveryDate = DateTime.Parse(t.DeliveryDate).ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
|
|
|
|
t.TiaoMa = $@"{t.MaterialCode}*{t.Qty.Value.ToString("F2")}*{t.FBillNo}*{t.FSupplierLot}";
|
|
|
|
|
fid = t.FormId;
|
2025-04-27 16:59:10 +08:00
|
|
|
|
if (t.CuseQty == 0)
|
|
|
|
|
t.CuseQty = t.Qty.SafeValue();
|
2025-04-24 18:31:27 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|