2025-04-24 18:31:27 +08:00
|
|
|
|
using Kingdee.CDP.WebApi.SDK;
|
|
|
|
|
using Microsoft.Practices.ObjectBuilder2;
|
|
|
|
|
using Microsoft.SqlServer.Server;
|
|
|
|
|
using MyCode.Project.Domain.Message.Act.PurchaseOrder;
|
|
|
|
|
using MyCode.Project.Domain.Message.Common;
|
|
|
|
|
using MyCode.Project.Domain.Message.Request.KingDee;
|
|
|
|
|
using MyCode.Project.Domain.Message.Request.PurchaseOrder;
|
|
|
|
|
using MyCode.Project.Domain.Message.Response.Common;
|
|
|
|
|
using MyCode.Project.Domain.Message.Response.PurchaseOrder;
|
|
|
|
|
using MyCode.Project.Domain.Message.Response.User;
|
|
|
|
|
using MyCode.Project.Domain.Model;
|
|
|
|
|
using MyCode.Project.Domain.Repositories;
|
|
|
|
|
using MyCode.Project.Infrastructure.Common;
|
|
|
|
|
using MyCode.Project.Infrastructure.Exceptions;
|
|
|
|
|
using MyCode.Project.Infrastructure.Extensions;
|
|
|
|
|
using MyCode.Project.OutSideService;
|
|
|
|
|
using MyCode.Project.Repositories;
|
|
|
|
|
using MyCode.Project.Repositories.Common;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace MyCode.Project.Services.Implementation
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 采购订单 相关服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class PurchaseOrderService : ServiceBase, IPurchaseOrderService
|
|
|
|
|
{
|
|
|
|
|
private IWorkProcessService _workProcessService;
|
|
|
|
|
private IKingDeeService _kingDeeService;
|
|
|
|
|
private IPurchaseOrderRepository _purchaseOrderRepository;
|
|
|
|
|
private IPurchaseOrderItemRepository _purchaseOrderItemRepository;
|
|
|
|
|
private IInvoiceOrderItemRepository _invoiceOrderItemRepository;
|
|
|
|
|
private IInvoiceOrderRepository _invoiceOrderRepository;
|
|
|
|
|
private ISysLoginRepository _sysLoginRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PurchaseOrderService(IPurchaseOrderRepository purchaseOrderRepository
|
|
|
|
|
, IPurchaseOrderItemRepository purchaseOrderItemRepository
|
|
|
|
|
, IInvoiceOrderItemRepository invoiceOrderItemRepository
|
|
|
|
|
, IInvoiceOrderRepository invoiceOrderRepository
|
|
|
|
|
, ISysLoginRepository sysLoginRepository
|
|
|
|
|
, IWorkProcessService workProcessService
|
|
|
|
|
, IKingDeeService kingDeeService)
|
|
|
|
|
{
|
|
|
|
|
_purchaseOrderItemRepository = purchaseOrderItemRepository;
|
|
|
|
|
_purchaseOrderRepository = purchaseOrderRepository;
|
|
|
|
|
_invoiceOrderItemRepository = invoiceOrderItemRepository;
|
|
|
|
|
_invoiceOrderRepository = invoiceOrderRepository;
|
|
|
|
|
_sysLoginRepository = sysLoginRepository;
|
|
|
|
|
_workProcessService = workProcessService;
|
|
|
|
|
_kingDeeService = kingDeeService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public K3CloudApi GetK3CloudClient()
|
|
|
|
|
{
|
|
|
|
|
return _kingDeeService.GetK3CloudClient();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取供应商
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetBDSupplier()
|
|
|
|
|
{
|
|
|
|
|
//string text = ConfigurationManager.AppSettings.Get("X-KDApi-AppID");
|
|
|
|
|
var result = _kingDeeService.GetBDSupplier();
|
|
|
|
|
List<dynamic> data = JsonHelper.ToObject<List<dynamic>>(result);
|
|
|
|
|
ItemResult kk = new ItemResult();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region GetBDSupplierList(获取金蝶系统的供应商列表)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取金蝶系统的供应商列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<ItemResult> GetBDSupplierList()
|
|
|
|
|
{
|
|
|
|
|
List<ItemResult> result = new List<ItemResult>();
|
|
|
|
|
var resultString = _kingDeeService.GetBDSupplier();
|
|
|
|
|
List<dynamic> data = JsonHelper.ToObject<List<dynamic>>(resultString);
|
2025-04-28 10:25:01 +08:00
|
|
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
2025-04-24 18:31:27 +08:00
|
|
|
|
foreach (var item in data)
|
|
|
|
|
{
|
2025-04-28 10:25:01 +08:00
|
|
|
|
if (!keyValuePairs.ContainsKey((string) item["FNumber"]))
|
|
|
|
|
{
|
|
|
|
|
keyValuePairs.Add((string) item["FNumber"], (string) item["FName"]);
|
|
|
|
|
ItemResult kk = new ItemResult();
|
|
|
|
|
kk.Text = item["FName"];
|
|
|
|
|
kk.Value = item["FNumber"];
|
|
|
|
|
result.Add(kk);
|
|
|
|
|
}
|
2025-04-24 18:31:27 +08:00
|
|
|
|
}
|
2025-04-28 10:25:01 +08:00
|
|
|
|
result = result.Distinct().ToList();
|
2025-04-24 18:31:27 +08:00
|
|
|
|
result = result.OrderBy(t => t.Value).ToList();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region GetFPurchaseOrgList(获取金蝶系统的采购组织)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取金蝶系统的采购组织
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<ItemResult> GetFPurchaseOrgList()
|
|
|
|
|
{
|
|
|
|
|
List<ItemResult> result = new List<ItemResult>();
|
|
|
|
|
var resultString = _kingDeeService.GetFPurchaseOrgList();
|
|
|
|
|
List<dynamic> data = JsonHelper.ToObject<List<dynamic>>(resultString);
|
|
|
|
|
foreach (var item in data)
|
|
|
|
|
{
|
|
|
|
|
ItemResult kk = new ItemResult();
|
|
|
|
|
kk.Text = item["FName"];
|
|
|
|
|
kk.Value = item["FORGID"];
|
|
|
|
|
result.Add(kk);
|
|
|
|
|
}
|
|
|
|
|
result = result.OrderBy(t => t.Value).ToList();
|
|
|
|
|
ItemResult item1 = new ItemResult();
|
|
|
|
|
item1.Value = "-1";
|
|
|
|
|
item1.Text = "全部";
|
|
|
|
|
result.Insert(0, item1);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 采购订单列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2025-05-16 18:37:51 +08:00
|
|
|
|
public string QueryList(DateTime begin, DateTime end, string FSupplierId, string yuYan = "")
|
2025-04-24 18:31:27 +08:00
|
|
|
|
{
|
|
|
|
|
BillQuery queryParam = new BillQuery();
|
|
|
|
|
queryParam = new BillQuery()
|
|
|
|
|
{
|
|
|
|
|
FormId = "PUR_PurchaseOrder",
|
2025-05-07 14:21:24 +08:00
|
|
|
|
FieldKeys = $@"FID,FBillNo,FDate,FBILLTYPEID,FSUPPLIERID,FSupplierId.FNAME,FSupplierId,FSupplierId.FShortName,FModifyDate,FPurchaserId,FMaterialId,FPOOrderEntry_FEntryId
|
2025-04-24 18:31:27 +08:00
|
|
|
|
,FSupplierLot,FLot,FBaseDeliveryMaxQty,FBaseJoinQty
|
|
|
|
|
,FEntryNote,FBillAllAmount_LC,FMaterialId.FNAME,FQty,FEntryNote,FUnitId.fname,FDeliveryDate,FMaterialId.FSpecification,FPurchaserId.fname,FSupplierId.FNumber,FMaterialId.FNumber
|
|
|
|
|
,FSettleCurrId.fname,FBillTaxAmount,FExchangeTypeId.fname,FExchangeRate,FEntryTaxRate,FPrice,FAllAmount,FEntryAmount,FEntryTaxAmount,FReceiveQty,FMRPCloseStatus
|
2025-04-26 13:23:45 +08:00
|
|
|
|
,FPurchaseOrgId,FPurchaseOrgId.FName,F_TSPR_Text_qtr1,FDEMANDBILLNO
|
2025-04-24 18:31:27 +08:00
|
|
|
|
,FCancelStatus,FRemainReceiveQty",
|
|
|
|
|
//FieldKeys ="",
|
|
|
|
|
TopRowCount = 100000,
|
|
|
|
|
Limit = 2000000,
|
|
|
|
|
StartRow = 0,
|
|
|
|
|
};
|
|
|
|
|
FilterList filterString = new FilterList(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FilterItem FDocumentStatusItem = new FilterItem("FDocumentStatus", "105", "C", "0");
|
|
|
|
|
//FilterItem FCancelStatusItem = new FilterItem("FCancelStatus", "105", "A", "0");
|
|
|
|
|
FilterItem FCancelStatusItem1 = new FilterItem { FieldName = "FModifyDate", Compare = "39", Value = begin.ToString("yyyy-MM-dd"), Logic = "0" };
|
|
|
|
|
FilterItem FCancelStatusItem2 = new FilterItem { FieldName = "FModifyDate", Compare = "16", Value = end.ToString("yyyy-MM-dd"), Logic = "0" };
|
|
|
|
|
FilterItem FCancelStatusItem3 = new FilterItem { FieldName = "FSupplierId.FNumber", Compare = "67", Value = FSupplierId.ToString(), Logic = "0" };
|
|
|
|
|
FilterItem FCancelStatusItem4 = new FilterItem { FieldName = "FBaseDeliveryMaxQty", Compare = "21", Value = "0", Logic = "0" };
|
|
|
|
|
|
|
|
|
|
filterString.AddFilterItem(FDocumentStatusItem).AddFilterItem(FCancelStatusItem1)
|
|
|
|
|
//.AddFilterItem(FCancelStatusItem4)
|
|
|
|
|
.AddFilterItem(FCancelStatusItem2).AddFilterItem(FCancelStatusItem3);
|
|
|
|
|
queryParam.FilterString = filterString.GetFilterString();
|
2025-05-16 18:37:51 +08:00
|
|
|
|
var result = _kingDeeService.QueryList(queryParam, yuYan);
|
2025-04-24 18:31:27 +08:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region GetPageList(采购单分页列表)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 采购单分页列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pagedSearch"></param>
|
|
|
|
|
/// <param name="loginInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
public PageResult<PurchaseOrderPageList> GetPageList(PagedSearch<PurchaseOrderPageSearch> pagedSearch, LoginInfo loginInfo)
|
|
|
|
|
{
|
|
|
|
|
return _purchaseOrderRepository.GetPageList(pagedSearch, loginInfo.SupplierId, loginInfo.FPurchaseOrgId);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region GetPurchaseOrderItemList(根据采购订单FID获取明细列表)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据采购订单FID获取明细列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="purchaseOrderItemSearch"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
public List<PurchaseOrderItemList> GetPurchaseOrderItemList(PurchaseOrderItemSearch purchaseOrderItemSearch, LoginInfo loginInfo)
|
|
|
|
|
{
|
|
|
|
|
return _purchaseOrderRepository.GetPurchaseOrderItemList(purchaseOrderItemSearch, loginInfo.SupplierId);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region BatchSetChengNuoJiaoQi(批量修改供应商承诺交期字段)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量修改供应商承诺交期字段
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="updateList"></param>
|
|
|
|
|
/// <param name="supplierId"></param>
|
|
|
|
|
[TransactionCallHandler]
|
|
|
|
|
public void BatchSetChengNuoJiaoQi(List<UpdateTime> updateList, string supplierId)
|
|
|
|
|
{
|
|
|
|
|
var ids = updateList.Select(t => t.Id).ToList();
|
|
|
|
|
var list = _purchaseOrderItemRepository.Queryable().Where(t => t.SupplierId == supplierId && ids.Contains(t.Id)).ToList();
|
|
|
|
|
SetChengNuoJiaoQiAct act = new SetChengNuoJiaoQiAct();
|
|
|
|
|
act.NeedUpDateFields = new List<string>();
|
|
|
|
|
act.NeedUpDateFields.Add("FPOOrderEntry");
|
|
|
|
|
act.NeedUpDateFields.Add("FSupDueDate");
|
|
|
|
|
|
|
|
|
|
list.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
var temp = updateList.FirstOrDefault(h => h.Id == t.Id);
|
|
|
|
|
if (temp != null)
|
|
|
|
|
{
|
|
|
|
|
t.ChengNuoJiaoQi = temp.NewTime;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
act.values = temp.NewTime.Date.ToString();
|
|
|
|
|
act.FNumber = t.SupplierId.ToString();
|
|
|
|
|
act.EntityId = t.EntityId.SafeValue();
|
|
|
|
|
act.Fid = t.Fid.SafeValue();
|
|
|
|
|
SetChengNuoJiaoQi(act);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new BaseException($"修改承诺最新交期失败,原因是{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_purchaseOrderItemRepository.Update(list);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region BatchSetChengNuoJiaoQi(批量修改供应商承诺最新交期字段)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量修改供应商承诺最新交期字段
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="updateList"></param>
|
|
|
|
|
/// <param name="supplierId"></param>
|
|
|
|
|
[TransactionCallHandler]
|
|
|
|
|
public void BatchSetNewChengNuoJiaoQi(List<UpdateTime> updateList, string supplierId)
|
|
|
|
|
{
|
|
|
|
|
var ids = updateList.Select(t => t.Id).ToList();
|
|
|
|
|
var list = _purchaseOrderItemRepository.Queryable().Where(t => t.SupplierId == supplierId && ids.Contains(t.Id)).ToList();
|
|
|
|
|
SetChengNuoJiaoQiAct act = new SetChengNuoJiaoQiAct();
|
|
|
|
|
act.NeedUpDateFields = new List<string>();
|
|
|
|
|
act.NeedUpDateFields.Add("FPOOrderEntry");
|
|
|
|
|
act.NeedUpDateFields.Add("FSupDueNewDate");
|
|
|
|
|
list.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
var temp = updateList.FirstOrDefault(h => h.Id == t.Id);
|
|
|
|
|
if (temp != null)
|
|
|
|
|
{
|
|
|
|
|
t.NewChengNuoJiaoQi = temp.NewTime;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
act.values = temp.NewTime.Date.ToString();
|
|
|
|
|
act.FNumber = t.SupplierId.ToString();
|
|
|
|
|
act.EntityId = t.EntityId.SafeValue();
|
|
|
|
|
act.Fid = t.Fid.SafeValue();
|
|
|
|
|
SetChengNuoJiaoQi(act);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new BaseException($"修改承诺最新交期失败,原因是{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//修改金蝶的供应商承诺最新交期字段
|
|
|
|
|
|
|
|
|
|
_purchaseOrderItemRepository.Update(list);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region BatchAddInvoiceOrder(选中明细生成发货通知单)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选中明细生成发货通知单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="updateList"></param>
|
|
|
|
|
/// <param name="loginInfo"></param>
|
|
|
|
|
/// <exception cref="BaseException"></exception>
|
|
|
|
|
[TransactionCallHandler]
|
|
|
|
|
public string BatchAddInvoiceOrder(AddOrder act , LoginInfo loginInfo)
|
|
|
|
|
{
|
|
|
|
|
List<UpdateQty> updateList = act.UpDateList;
|
|
|
|
|
string supplierId = loginInfo.SupplierId;
|
|
|
|
|
var ids = updateList.Select(t => t.Id).ToList(); ;
|
|
|
|
|
var list = _purchaseOrderItemRepository.Queryable().Where(t => t.SupplierId == supplierId && ids.Contains(t.Id)).ToList();
|
|
|
|
|
var fidList = list.Select(t => t.Fid).ToList();
|
|
|
|
|
var orderHeadList = _purchaseOrderRepository.Queryable().Where(t => fidList.Contains( t.FiD)).ToList();
|
|
|
|
|
if (orderHeadList == null)
|
|
|
|
|
{
|
|
|
|
|
throw new BaseException("订单不属于此供应商");
|
|
|
|
|
}
|
|
|
|
|
var FPurchaseOrgIdList = orderHeadList.Select(t => t.FPurchaseOrgId).Distinct().ToList();
|
|
|
|
|
if (FPurchaseOrgIdList.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
throw new BaseException("不能跨采购组织创建发货通知单");
|
|
|
|
|
}
|
2025-05-15 12:36:05 +08:00
|
|
|
|
|
|
|
|
|
if (loginInfo.IfForeign == 1 && string.IsNullOrWhiteSpace(act.F_VHUB_Text))
|
|
|
|
|
{
|
|
|
|
|
throw new BaseException("国外的供应商发票号和发票日期是必填.");
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 18:31:27 +08:00
|
|
|
|
InvoiceOrder NewInvoiceOrder = new InvoiceOrder();
|
|
|
|
|
NewInvoiceOrder.Id = Guid.NewGuid();
|
|
|
|
|
NewInvoiceOrder.FiD = null;
|
|
|
|
|
NewInvoiceOrder.Status = 1;
|
|
|
|
|
NewInvoiceOrder.EditTime = DateTime.Now;
|
|
|
|
|
NewInvoiceOrder.Editor = loginInfo.Name;
|
|
|
|
|
NewInvoiceOrder.CreateTime = DateTime.Now;
|
|
|
|
|
NewInvoiceOrder.Creater = loginInfo.Name;
|
|
|
|
|
NewInvoiceOrder.SupplierId = supplierId;
|
|
|
|
|
NewInvoiceOrder.SupplierName = orderHeadList.FirstOrDefault().SupplierName;
|
|
|
|
|
NewInvoiceOrder.FDate = DateTime.Now;
|
|
|
|
|
NewInvoiceOrder.Sheet = DateTime.Now.ToString("yyMMddhhmmssfff");
|
|
|
|
|
NewInvoiceOrder.PurchaseOrderId = 0;
|
|
|
|
|
NewInvoiceOrder.F_VHUB_Text = act.F_VHUB_Text;
|
2025-05-13 13:51:53 +08:00
|
|
|
|
NewInvoiceOrder.F_URXD_Date = act.F_URXD_Date;
|
2025-04-24 18:31:27 +08:00
|
|
|
|
NewInvoiceOrder.FPurchaseOrgId = orderHeadList.FirstOrDefault().FPurchaseOrgId;
|
|
|
|
|
NewInvoiceOrder.FPurchaseOrgName = orderHeadList.FirstOrDefault().FPurchaseOrgName;
|
|
|
|
|
List<InvoiceOrderItem> invoiceOrderItems = new List<InvoiceOrderItem>();
|
|
|
|
|
//invoiceOrderItems=list.Select(t=>new InvoiceOrderItem {Id=Guid.NewGuid(), Amount1=t.Amount1, Amount2=t.Amount2,t })
|
|
|
|
|
var allInvoiceOrderItem = _invoiceOrderItemRepository.Queryable().Where(t => ids.Contains(t.PurchaseOrderItemId.Value)).ToList();
|
|
|
|
|
List<string> errorList = new List<string>();
|
|
|
|
|
|
|
|
|
|
string FormId = "PUR_PurchaseOrder";
|
|
|
|
|
var entityIdList = list.Select(t => t.EntityId).ToList();
|
|
|
|
|
BillPush billPush = new BillPush();
|
|
|
|
|
billPush.EntryIds = string.Join(",", entityIdList);
|
|
|
|
|
billPush.TargetFormId = "PUR_ReceiveBill";
|
|
|
|
|
billPush.IsEnableDefaultRule = true;
|
|
|
|
|
billPush.CustomParams = new CustomParams();
|
|
|
|
|
billPush.CustomParams.AutoAudit = false;
|
|
|
|
|
billPush.CustomParams.ScanEntry = new List<ScanEntry>();
|
|
|
|
|
|
|
|
|
|
List<AddTiaoMa> addTiaoMas = new List<AddTiaoMa>();
|
|
|
|
|
|
|
|
|
|
list.ForEach(t =>
|
|
|
|
|
{
|
2025-05-15 23:43:24 +08:00
|
|
|
|
//var allqty = allInvoiceOrderItem.Where(h => h.PurchaseOrderItemId == t.Id ).Sum(h => h.Qty).SafeValue();
|
2025-04-24 18:31:27 +08:00
|
|
|
|
var temp = updateList.Where(h => h.Id == t.Id).FirstOrDefault();
|
|
|
|
|
if (temp != null)
|
|
|
|
|
{
|
|
|
|
|
var purchaseOrder = orderHeadList.FirstOrDefault(h=>h.FiD==t.Fid);
|
|
|
|
|
if (purchaseOrder == null)
|
|
|
|
|
throw new BaseException("找不到对应的采购订单主表信息");
|
2025-05-15 23:43:24 +08:00
|
|
|
|
if ((temp.Qty ) > (t.Qty - t.MSSReceiveQty))
|
2025-04-24 18:31:27 +08:00
|
|
|
|
{
|
|
|
|
|
string error = $@"{t.MaterialName}";
|
|
|
|
|
errorList.Add(error);
|
|
|
|
|
}
|
|
|
|
|
//else if ((temp.Qty + allqty) == t.Qty)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
InvoiceOrderItem invoiceOrderItemTemp = new InvoiceOrderItem();
|
|
|
|
|
invoiceOrderItemTemp.Id = Guid.NewGuid();
|
|
|
|
|
invoiceOrderItemTemp.InvoiceOrderId = NewInvoiceOrder.Id;
|
|
|
|
|
invoiceOrderItemTemp.NewChengNuoJiaoQi = t.NewChengNuoJiaoQi;
|
|
|
|
|
invoiceOrderItemTemp.ChengNuoJiaoQi = t.ChengNuoJiaoQi;
|
|
|
|
|
invoiceOrderItemTemp.UnitPrice = t.UnitPrice;
|
|
|
|
|
invoiceOrderItemTemp.PurchaseOrderId = t.Fid;
|
|
|
|
|
invoiceOrderItemTemp.MaterialCode = t.MaterialCode;
|
|
|
|
|
invoiceOrderItemTemp.MaterialName = t.MaterialName;
|
|
|
|
|
invoiceOrderItemTemp.Amount1 = t.UnitPrice * temp.Qty;
|
|
|
|
|
invoiceOrderItemTemp.Amount2 = t.UnitPrice * temp.Qty * t.TaxRate;
|
|
|
|
|
invoiceOrderItemTemp.DeliveryDate = DateTime.Now;
|
|
|
|
|
invoiceOrderItemTemp.Qty = temp.Qty;
|
|
|
|
|
invoiceOrderItemTemp.Remark = t.Remark;
|
|
|
|
|
invoiceOrderItemTemp.SpecificationModel = t.SpecificationModel;
|
|
|
|
|
invoiceOrderItemTemp.TaxAmount = t.TaxAmount;
|
|
|
|
|
invoiceOrderItemTemp.PurchaseOrderItemId = t.Id;
|
|
|
|
|
invoiceOrderItemTemp.FSupplierLot = temp.FSupplierLot==null ?"" : temp.FSupplierLot;
|
|
|
|
|
invoiceOrderItemTemp.MSSSupplierLot = t.MSSSupplierLot;
|
|
|
|
|
invoiceOrderItemTemp.UnitName = t.UnitName;
|
|
|
|
|
invoiceOrderItemTemp.FBillNo = purchaseOrder.FBillNo;
|
|
|
|
|
invoiceOrderItemTemp.PurchaseEntityId = t.EntityId;
|
|
|
|
|
invoiceOrderItems.Add(invoiceOrderItemTemp);
|
|
|
|
|
ScanEntry tempUpdate = new ScanEntry();
|
|
|
|
|
tempUpdate.Qty = (int)temp.Qty;
|
|
|
|
|
tempUpdate.FENTRYID = t.EntityId.SafeValue();
|
|
|
|
|
tempUpdate.FSupplierLot = temp.FSupplierLot;
|
|
|
|
|
billPush.CustomParams.ScanEntry.Add(tempUpdate);
|
2025-05-15 09:22:12 +08:00
|
|
|
|
billPush.CustomParams.FPH= act.F_VHUB_Text;
|
2025-05-13 13:51:53 +08:00
|
|
|
|
billPush.CustomParams.F_URXD_Date = act.F_URXD_Date;
|
2025-05-15 09:22:12 +08:00
|
|
|
|
if (string.IsNullOrWhiteSpace(billPush.CustomParams.F_URXD_Date))
|
|
|
|
|
billPush.CustomParams.F_URXD_Date = null;
|
2025-05-15 12:36:05 +08:00
|
|
|
|
t.FReceiveQty = t.FReceiveQty + temp.Qty;
|
|
|
|
|
t.FRemainReceiveQty = t.FRemainReceiveQty - temp.Qty;
|
2025-04-24 18:31:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (errorList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string e = string.Join(",", errorList);
|
|
|
|
|
if(loginInfo.IfForeign==0)
|
|
|
|
|
e = e + "的总发货数量大于总采购数量,请检查";
|
|
|
|
|
else
|
|
|
|
|
e=e+" The delivery QTY exceeds the PO's maximum QTY!";
|
|
|
|
|
throw new BaseException(e);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var resultKD= _kingDeeService.Push(FormId, billPush);
|
|
|
|
|
LogHelper.Info("推送收料订单");
|
|
|
|
|
LogHelper.Info(resultKD);
|
|
|
|
|
//var sda = resultKD.GetProperty("IsSuccess") [["SuccessEntitys"];
|
|
|
|
|
dynamic data = JsonHelper.ToObject<dynamic>(resultKD);
|
|
|
|
|
int row = 0;
|
|
|
|
|
foreach (var item in data)
|
|
|
|
|
{
|
|
|
|
|
NewInvoiceOrder.FBillNo = item["Number"];
|
|
|
|
|
NewInvoiceOrder.FiD = item["Id"];
|
|
|
|
|
row++;
|
|
|
|
|
}
|
|
|
|
|
_invoiceOrderRepository.Add(NewInvoiceOrder);
|
|
|
|
|
_invoiceOrderItemRepository.Add(invoiceOrderItems);
|
|
|
|
|
_purchaseOrderItemRepository.Update(list);
|
|
|
|
|
|
|
|
|
|
////物料编码,数量,收料通知单号,供应商批号,key
|
|
|
|
|
//AddTiaoMa addTiao = new AddTiaoMa();
|
|
|
|
|
|
|
|
|
|
//addTiaoMas = invoiceOrderItems.Select(t => new AddTiaoMa {
|
|
|
|
|
// FBarCode = $@"{t.MaterialCode}*{t.Qty.Value.ToString("F2")}*{NewInvoiceOrder.FBillNo}*{t.FSupplierLot}"
|
|
|
|
|
//, FBarCodeRule= "03", FBillCode= NewInvoiceOrder.FBillNo, FSupplierLot=t.FSupplierLot==null?"": t.FSupplierLot, FMaterialId=t.MaterialCode, FQty=t.Qty.Value.ToString()
|
|
|
|
|
//}).ToList();
|
|
|
|
|
_workProcessService.Add<IInvoiceOrderService>(this.MerchantId, "SetMSSSupplierLot", "写入金蝶的美塞斯批号", NewInvoiceOrder.Sheet, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("推送收料订单出错");
|
|
|
|
|
LogHelper.Error(ex);
|
|
|
|
|
throw new BaseException(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NewInvoiceOrder.Sheet;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 抓取金蝶的采购订单
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
2025-04-29 10:51:23 +08:00
|
|
|
|
public void AddOrderFromKingDee(string SupplierId="")
|
2025-04-24 18:31:27 +08:00
|
|
|
|
{
|
|
|
|
|
var userList = _sysLoginRepository.Queryable().Where(t => t.Status == 1 && t.IsDeleted == false && t.SystemType == 0 && t.SupplierId != "").ToList();
|
2025-04-29 10:51:23 +08:00
|
|
|
|
if (SupplierId != "")
|
|
|
|
|
userList = userList.Where(t => t.SupplierId == SupplierId).ToList();
|
2025-04-24 18:31:27 +08:00
|
|
|
|
userList.ForEach(t =>
|
|
|
|
|
{
|
2025-05-15 12:36:05 +08:00
|
|
|
|
|
|
|
|
|
var items = _purchaseOrderItemRepository.Queryable().Where(h => h.SupplierId == t.SupplierId && h.Qty > h.MSSReceiveQty).Select(h=>h.Fid).ToList().Distinct().ToList();
|
|
|
|
|
var maxDate = _purchaseOrderRepository.Queryable().Where(h => h.SupplierId == t.SupplierId && items.Contains(h.FiD)).Min(h => h.FModifyDate);
|
2025-04-25 18:42:29 +08:00
|
|
|
|
DateTime begin = DateTime.Parse("2024-01-01");
|
2025-04-24 18:31:27 +08:00
|
|
|
|
if (maxDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
begin = maxDate.Value.Date;
|
|
|
|
|
}
|
2025-05-16 18:37:51 +08:00
|
|
|
|
string yuyan = "";
|
|
|
|
|
if (t.IfForeign == 1)
|
|
|
|
|
yuyan = "1033"; //语言ID,中文2052(默认),英文1033,繁体3076;
|
2025-04-24 18:31:27 +08:00
|
|
|
|
DateTime end = begin.AddMonths(1);
|
|
|
|
|
bool stop = false;
|
|
|
|
|
Dictionary<int, List<int>> keyValuePairs = new Dictionary<int, List<int>>();
|
|
|
|
|
while (end < DateTime.Now || stop == false)
|
|
|
|
|
{
|
|
|
|
|
end = begin.AddMonths(1);
|
2025-05-16 18:37:51 +08:00
|
|
|
|
var result = QueryList(begin, end, t.SupplierId, yuyan);
|
2025-04-26 13:23:45 +08:00
|
|
|
|
if (t.SupplierId == "9999.1")
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Info(t.SupplierName + "的采购订单数据" + begin.ToString() + "-----" + end.ToString());
|
|
|
|
|
LogHelper.Info(result);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Info(t.SupplierName + "的采购订单数据" + begin.ToString() + "-----" + end.ToString());
|
|
|
|
|
LogHelper.Info(result);
|
|
|
|
|
}
|
2025-04-24 18:31:27 +08:00
|
|
|
|
List<dynamic> data = JsonHelper.ToObject<List<dynamic>>(result);
|
|
|
|
|
//List<dynamic> data = System.Text.Json.JsonSerializer.Deserialize<List<dynamic>>(result);
|
|
|
|
|
if (data.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int fid = 0;
|
|
|
|
|
Guid ida = Guid.Empty;
|
|
|
|
|
List<int> fids = data.Select(k => int.Parse((string)k["FID"])).ToList().Distinct().ToList();
|
|
|
|
|
var oldOrderList = _purchaseOrderRepository.Queryable().Where(g => fids.Contains(g.FiD.Value)).ToList();
|
|
|
|
|
var oldOrderItemList = _purchaseOrderItemRepository.Queryable().Where(g => fids.Contains(g.Fid.Value)).ToList();
|
|
|
|
|
List<int?> entityIdList = new List<int?>();
|
|
|
|
|
|
|
|
|
|
foreach (var item in data)
|
|
|
|
|
{
|
|
|
|
|
object fido = (item["FID"]);
|
|
|
|
|
|
|
|
|
|
if (fid != int.Parse(fido.ToString()) || fid == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
fid = item["FID"];
|
|
|
|
|
var oldOrder = oldOrderList.Where(g => g.FiD == fid).FirstOrDefault();
|
|
|
|
|
if (oldOrder == null)
|
|
|
|
|
{
|
|
|
|
|
PurchaseOrder purchaseOrder = new PurchaseOrder();
|
|
|
|
|
purchaseOrder.Id = Guid.NewGuid();
|
|
|
|
|
ida = purchaseOrder.Id;
|
|
|
|
|
purchaseOrder.SupplierId = t.SupplierId;
|
2025-05-07 14:21:24 +08:00
|
|
|
|
purchaseOrder.SupplierName = item["FSupplierId.FShortName"];
|
|
|
|
|
if (purchaseOrder.SupplierName.Trim() == "")
|
|
|
|
|
purchaseOrder.SupplierName = item["FSupplierId.FNAME"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
purchaseOrder.FCancelStatus = item["FCancelStatus"];
|
|
|
|
|
purchaseOrder.SettlementCcurrency = item["FSettleCurrId.fname"];
|
|
|
|
|
purchaseOrder.ExchangeRate = item["FExchangeRate"];
|
|
|
|
|
purchaseOrder.ExchangeRateType = item["FExchangeTypeId.fname"];
|
|
|
|
|
purchaseOrder.FDate = item["FDate"];
|
|
|
|
|
purchaseOrder.FBillNo = item["FBillNo"];
|
|
|
|
|
purchaseOrder.FiD = item["FID"];
|
|
|
|
|
purchaseOrder.Purchaser = item["FPurchaserId.fname"];
|
|
|
|
|
purchaseOrder.FModifyDate = item["FModifyDate"];
|
|
|
|
|
purchaseOrder.FPurchaseOrgId= item["FPurchaseOrgId"];
|
|
|
|
|
purchaseOrder.FPurchaseOrgName = item["FPurchaseOrgId.FName"];
|
|
|
|
|
_purchaseOrderRepository.Add(purchaseOrder);
|
|
|
|
|
//if (purchaseOrder.FBillNo == "C20250401048")
|
|
|
|
|
//{
|
|
|
|
|
// int kk = 8;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oldOrder.SupplierId = t.SupplierId;
|
2025-05-07 14:21:24 +08:00
|
|
|
|
oldOrder.SupplierName = item["FSupplierId.FShortName"];
|
|
|
|
|
if (oldOrder.SupplierName.Trim()=="")
|
|
|
|
|
oldOrder.SupplierName = item["FSupplierId.FNAME"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
oldOrder.FCancelStatus = item["FCancelStatus"];
|
|
|
|
|
oldOrder.SettlementCcurrency = item["FSettleCurrId.fname"];
|
|
|
|
|
oldOrder.ExchangeRate = item["FExchangeRate"];
|
|
|
|
|
oldOrder.ExchangeRateType = item["FExchangeTypeId.fname"];
|
|
|
|
|
oldOrder.FDate = item["FDate"];
|
|
|
|
|
oldOrder.FBillNo = item["FBillNo"];
|
|
|
|
|
oldOrder.FiD = item["FID"];
|
|
|
|
|
oldOrder.Purchaser = item["FPurchaserId.fname"];
|
|
|
|
|
oldOrder.FModifyDate = item["FModifyDate"];
|
|
|
|
|
oldOrder.FPurchaseOrgId = item["FPurchaseOrgId"];
|
|
|
|
|
oldOrder.FPurchaseOrgName = item["FPurchaseOrgId.FName"];
|
|
|
|
|
_purchaseOrderRepository.Update(oldOrder);
|
|
|
|
|
//if (oldOrder.FBillNo == "C20250401048")
|
|
|
|
|
//{
|
|
|
|
|
// int kk = 8;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
int entityId = item["FPOOrderEntry_FEntryId"];
|
|
|
|
|
if (!keyValuePairs.ContainsKey(int.Parse(fido.ToString())))
|
|
|
|
|
{
|
|
|
|
|
keyValuePairs.Add(int.Parse(fido.ToString()), new List<int> { entityId });
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
keyValuePairs[int.Parse(fido.ToString())].Add(entityId);
|
|
|
|
|
}
|
|
|
|
|
entityIdList.Add(entityId);
|
|
|
|
|
var oldItem = oldOrderItemList.Where(k => k.EntityId == entityId).FirstOrDefault();
|
|
|
|
|
if (oldItem == null)
|
|
|
|
|
{
|
|
|
|
|
PurchaseOrderItem purchaseOrderItem = new PurchaseOrderItem();
|
|
|
|
|
purchaseOrderItem.Id = Guid.NewGuid();
|
|
|
|
|
purchaseOrderItem.UnitPrice = item["FPrice"];
|
|
|
|
|
purchaseOrderItem.Amount1 = item["FEntryAmount"];
|
|
|
|
|
purchaseOrderItem.Amount2 = item["FAllAmount"];
|
|
|
|
|
purchaseOrderItem.MaterialName = item["FMaterialId.FNAME"];
|
|
|
|
|
purchaseOrderItem.MaterialCode = item["FMaterialId.FNumber"];
|
|
|
|
|
purchaseOrderItem.Fid = item["FID"];
|
|
|
|
|
purchaseOrderItem.Qty = item["FQty"];
|
|
|
|
|
purchaseOrderItem.Remark = item["FEntryNote"];
|
|
|
|
|
purchaseOrderItem.SupplierId = t.SupplierId;
|
|
|
|
|
purchaseOrderItem.UnitName = item["FUnitId.fname"];
|
2025-04-26 13:23:45 +08:00
|
|
|
|
purchaseOrderItem.FDeliveryDate = item["FDeliveryDate"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
purchaseOrderItem.TaxRate = item["FEntryTaxRate"];
|
|
|
|
|
purchaseOrderItem.FBillTaxAmount = item["FEntryTaxAmount"];
|
|
|
|
|
purchaseOrderItem.FRemainReceiveQty = item["FBaseDeliveryMaxQty"];
|
|
|
|
|
purchaseOrderItem.FReceiveQty = item["FBaseJoinQty"];
|
2025-05-15 12:36:05 +08:00
|
|
|
|
purchaseOrderItem.FRemainReceiveQty = purchaseOrderItem.Qty - purchaseOrderItem.FReceiveQty;
|
|
|
|
|
purchaseOrderItem.MSSReceiveQty= item["FReceiveQty"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
purchaseOrderItem.FMRPCloseStatus = item["FMRPCloseStatus"];
|
2025-04-25 18:42:29 +08:00
|
|
|
|
purchaseOrderItem.EntityId = item["FPOOrderEntry_FEntryId"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
purchaseOrderItem.MSSSupplierLot = item["FLot"];
|
|
|
|
|
purchaseOrderItem.SpecificationModel = item["FMaterialId.FSpecification"];
|
2025-04-26 13:23:45 +08:00
|
|
|
|
purchaseOrderItem.F_TSPR_Text_qtr1 = item["F_TSPR_Text_qtr1"];
|
|
|
|
|
purchaseOrderItem.FDEMANDBILLNO = item["FDEMANDBILLNO"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
_purchaseOrderItemRepository.Add(purchaseOrderItem);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oldItem.UnitPrice = item["FPrice"];
|
|
|
|
|
oldItem.Amount1 = item["FEntryAmount"];
|
|
|
|
|
oldItem.Amount2 = item["FAllAmount"];
|
|
|
|
|
oldItem.MaterialName = item["FMaterialId.FNAME"];
|
|
|
|
|
oldItem.MaterialCode = item["FMaterialId.FNumber"];
|
|
|
|
|
oldItem.Fid = item["FID"];
|
|
|
|
|
oldItem.Qty = item["FQty"];
|
|
|
|
|
oldItem.Remark = item["FEntryNote"];
|
|
|
|
|
oldItem.SupplierId = t.SupplierId;
|
|
|
|
|
oldItem.UnitName = item["FUnitId.fname"];
|
2025-04-26 13:23:45 +08:00
|
|
|
|
oldItem.FDeliveryDate = item["FDeliveryDate"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
oldItem.TaxRate = item["FEntryTaxRate"];
|
|
|
|
|
oldItem.FBillTaxAmount = item["FEntryTaxAmount"];
|
|
|
|
|
oldItem.FReceiveQty = item["FBaseJoinQty"];
|
2025-05-15 12:36:05 +08:00
|
|
|
|
oldItem.MSSReceiveQty = item["FReceiveQty"];
|
|
|
|
|
oldItem.FRemainReceiveQty = oldItem.Qty - oldItem.FReceiveQty;
|
2025-04-24 18:31:27 +08:00
|
|
|
|
oldItem.SpecificationModel = item["FMaterialId.FSpecification"];
|
|
|
|
|
//oldItem.FRemainReceiveQty = item["FBaseDeliveryMaxQty"];
|
|
|
|
|
//purchaseOrderItem.FReceiveQty = item["FBaseDeliveryMaxQty"];
|
2025-05-15 12:36:05 +08:00
|
|
|
|
oldItem.FReceiveQty = oldItem.Qty - oldItem.FRemainReceiveQty;
|
2025-04-24 18:31:27 +08:00
|
|
|
|
oldItem.FMRPCloseStatus = item["FMRPCloseStatus"];
|
2025-04-25 18:42:29 +08:00
|
|
|
|
oldItem.EntityId = item["FPOOrderEntry_FEntryId"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
oldItem.MSSSupplierLot = item["FLot"];
|
2025-04-26 13:23:45 +08:00
|
|
|
|
oldItem.F_TSPR_Text_qtr1 = item["F_TSPR_Text_qtr1"];
|
|
|
|
|
oldItem.FDEMANDBILLNO = item["FDEMANDBILLNO"];
|
2025-04-24 18:31:27 +08:00
|
|
|
|
_purchaseOrderItemRepository.Update(oldItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//var deleteRow = oldOrderItemList.Where(h => !entityIdList.Contains(h.EntityId) && fids.Contains(h.Fid.Value)).ToList();
|
|
|
|
|
//var delIds = deleteRow.Select(h => h.Id).ToList();
|
|
|
|
|
//if (fids.Count > 0)
|
|
|
|
|
// _purchaseOrderItemRepository.Delete(h => !entityIdList.Contains(h.EntityId) && fids.Contains(h.Fid.Value));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
begin = end;
|
|
|
|
|
if (begin > DateTime.Now)
|
|
|
|
|
stop = true;
|
|
|
|
|
//if (end > DateTime.Now)
|
|
|
|
|
//{
|
|
|
|
|
// end = DateTime.Now.AddDays(-1);
|
|
|
|
|
// begin = end;
|
|
|
|
|
//}
|
2025-04-25 18:42:29 +08:00
|
|
|
|
Thread.Sleep(500);
|
2025-04-24 18:31:27 +08:00
|
|
|
|
}
|
2025-04-25 18:42:29 +08:00
|
|
|
|
|
2025-04-24 18:31:27 +08:00
|
|
|
|
keyValuePairs.Keys.ForEach(key =>
|
|
|
|
|
{
|
|
|
|
|
List<int> templist = keyValuePairs[key];
|
|
|
|
|
_purchaseOrderItemRepository.Delete(h => !templist.Contains(h.EntityId.Value) && key == (h.Fid.Value));
|
|
|
|
|
Thread.Sleep(300);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改供应商的承诺时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="act"></param>
|
|
|
|
|
public void SetChengNuoJiaoQi(SetChengNuoJiaoQiAct act)
|
|
|
|
|
{
|
|
|
|
|
string FormId = "PUR_PurchaseOrder";
|
|
|
|
|
BillSave bill = new BillSave();
|
|
|
|
|
bill.NeedUpDateFields = new List<string>();
|
|
|
|
|
bill.NeedUpDateFields.AddRange(act.NeedUpDateFields);
|
|
|
|
|
//bill.NeedUpDateFields.Add("FPOOrderEntry");
|
|
|
|
|
//bill.NeedUpDateFields.Add("FSupDueDate");
|
|
|
|
|
bill.NeedReturnFields = new List<string>();
|
|
|
|
|
bill.NeedReturnFields.AddRange(act.NeedUpDateFields);
|
|
|
|
|
bill.IsDeleteEntry = false;
|
|
|
|
|
PurchaseOrderSaveModel orderSaveModel = new PurchaseOrderSaveModel();
|
|
|
|
|
orderSaveModel.FPOOrderEntry = new List<FPOOrderEntryItem>();
|
|
|
|
|
orderSaveModel.FSupplierId = new FSupplierId();
|
|
|
|
|
orderSaveModel.FSupplierId.FNumber = act.FNumber;
|
|
|
|
|
orderSaveModel.FID = act.Fid;
|
|
|
|
|
FPOOrderEntryItem temp = new FPOOrderEntryItem();
|
|
|
|
|
temp.FEntryID = act.EntityId;
|
|
|
|
|
temp.FSupDueDate = act.values.ToString();
|
|
|
|
|
temp.FSupDueNewDate = act.values.ToString();
|
|
|
|
|
orderSaveModel.FPOOrderEntry.Add(temp);
|
|
|
|
|
//Dictionary<string, object> keyValuePairs = new Dictionary<string, object>();
|
|
|
|
|
//keyValuePairs.Add(NeedUpDateFields, values);
|
|
|
|
|
//keyValuePairs.Add("FEntryID", EntityId);
|
|
|
|
|
|
|
|
|
|
//Dictionary<string, object> keyValuePairs2 = new Dictionary<string, object>();
|
|
|
|
|
//keyValuePairs2.Add("FPOOrderEntry", keyValuePairs);
|
|
|
|
|
bill.Model = orderSaveModel;
|
|
|
|
|
LogHelper.Info(bill.Model);
|
|
|
|
|
var result = _kingDeeService.Save(FormId, bill);
|
|
|
|
|
LogHelper.Info(result);
|
|
|
|
|
|
|
|
|
|
//bill
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-25 18:42:29 +08:00
|
|
|
|
|
2025-04-24 18:31:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|