diff --git a/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 b/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2
index 1aca7bb9..cc7ffb65 100644
Binary files a/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 and b/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 differ
diff --git a/src/WMS.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs b/src/WMS.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs
new file mode 100644
index 00000000..5e05f3e0
--- /dev/null
+++ b/src/WMS.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WMS.Web.Core.Dto.Erp.Customer
+{
+ ///
+ /// 客户
+ ///
+ public class ErpCustomerDto
+ {
+ ///
+ /// ID
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// 编码
+ ///
+ public string Number { get; set; }
+
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; }
+ }
+}
diff --git a/src/WMS.Web.Domain/IService/Public/IErpBasicDataExtendService.cs b/src/WMS.Web.Domain/IService/Public/IErpBasicDataExtendService.cs
index de5a657d..ae09e909 100644
--- a/src/WMS.Web.Domain/IService/Public/IErpBasicDataExtendService.cs
+++ b/src/WMS.Web.Domain/IService/Public/IErpBasicDataExtendService.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using WMS.Web.Core.Dto.Erp;
+using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.Supplier;
@@ -58,7 +59,14 @@ namespace WMS.Web.Domain.IService.Public
///
///
string GetSupplierName(List erpSuppliers, int supplierId);
-
+ ///
+ /// 获取客户名称
+ ///
+ ///
+ ///
+ ///
+ string GetCustomerName(List erpCustomers, int customerId);
+
///
/// 获取仓库名称
///
diff --git a/src/WMS.Web.Domain/IService/Public/IErpService.cs b/src/WMS.Web.Domain/IService/Public/IErpService.cs
index b31974da..d09b81b9 100644
--- a/src/WMS.Web.Domain/IService/Public/IErpService.cs
+++ b/src/WMS.Web.Domain/IService/Public/IErpService.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.Erp;
+using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.OutStock;
using WMS.Web.Core.Dto.Erp.Purchase;
@@ -66,7 +67,11 @@ namespace WMS.Web.Domain.IService.Public
///
///
Task> BillQueryForSupplier();
-
+ ///
+ /// 客户
+ ///
+ ///
+ Task> BillQueryForCustomer();
///
/// 获取仓库信息
///
diff --git a/src/WMS.Web.Domain/Services/Public/ErpBasicDataExtendService.cs b/src/WMS.Web.Domain/Services/Public/ErpBasicDataExtendService.cs
index 4f9a5a7b..a836efc4 100644
--- a/src/WMS.Web.Domain/Services/Public/ErpBasicDataExtendService.cs
+++ b/src/WMS.Web.Domain/Services/Public/ErpBasicDataExtendService.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using WMS.Web.Core.Dto.Erp;
+using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.Supplier;
using WMS.Web.Domain.Infrastructure;
@@ -100,6 +101,17 @@ namespace WMS.Web.Domain.Services.Public
var supplier = erpSuppliers.Where(x => x.Id == supplierId).FirstOrDefault();
return supplier == null ? "" : supplier.Name;
}
+ ///
+ /// 获取客户名称
+ ///
+ ///
+ ///
+ ///
+ public string GetCustomerName(List erpCustomers, int customerId)
+ {
+ var supplier = erpCustomers.Where(x => x.Id == customerId).FirstOrDefault();
+ return supplier == null ? "" : supplier.Name;
+ }
///
/// 获取仓库名称
@@ -136,5 +148,7 @@ namespace WMS.Web.Domain.Services.Public
var stock = erpStocks.Where(x => x.Id == stockId).FirstOrDefault();
return stock == null ? "" : stock.Code;
}
+
+
}
}
diff --git a/src/WMS.Web.Domain/Services/Public/ErpService.cs b/src/WMS.Web.Domain/Services/Public/ErpService.cs
index 1f5329d7..35f86e58 100644
--- a/src/WMS.Web.Domain/Services/Public/ErpService.cs
+++ b/src/WMS.Web.Domain/Services/Public/ErpService.cs
@@ -12,6 +12,7 @@ using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.Erp;
+using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.OutStock;
using WMS.Web.Core.Dto.Erp.Purchase;
@@ -397,7 +398,74 @@ namespace WMS.Web.Domain.Services.Public
return ResultList.ReFailure(ResultCodes.ErpSupplierError);
}
}
+ ///
+ /// 客户
+ ///
+ ///
+ public async Task> BillQueryForCustomer()
+ {
+ try
+ {
+ //1.获取缓存中的供应商数据;
+ var cache_key = "erp_customer_list";
+ var customers = _memoryCache.Get>(cache_key);
+ if (customers == null || customers.Count == 0)
+ {
+ //2.先登录金蝶-拿到token
+ var token_result = await this.Init();
+ if (!token_result.IsSuccess)
+ return ResultList.ReFailure(token_result);
+
+ //3.获取金蝶供应商:拼接参数和条件
+ var query = new ErpBillQueryDto(token_result.Data);
+ var param = new ErpBillQueryParamDto(FormIdParam.BD_Customer.ToString());
+ param.FieldKeys = "FCUSTID,FNumber,FName";
+ param.Limit = 10000;
+ //查询条件:备注其中的条件值以金蝶的值为准!!!
+ param.FilterString = "";
+
+ //备注:因为供应商数据不是很多,就不能和获取物料一样循环获取;组织这里就获取10000条数据就行了
+ var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
+ _logger.LogInformation($"供应商拉取-开始时间:{beginTime}");
+ //4.参数json化
+ query.Data = JsonConvert.SerializeObject(param);
+ var json = JsonConvert.SerializeObject(query);
+
+ //5.请求查询接口并返回数据
+ var result_json = await _client.ExecuteBillQueryAsync(json);
+ var result = JsonConvert.DeserializeObject>>(result_json);
+
+ var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
+ _logger.LogInformation($"供应商拉取-结束时间:{endTime}");
+ //6.拼装
+ var list = new List();
+ foreach (var item in result)
+ {
+ var lis = new ErpCustomerDto();
+ lis.Id = int.Parse(item[0]);
+ lis.Number = item[1];
+ lis.Name = item[2];
+ list.Add(lis);
+
+ }
+ //5.供应商集合进行缓存
+ _memoryCache.Set(cache_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12)));
+ _logger.LogInformation($"供应商拉取-总条数:{list.Count}");
+ return ResultList.ReSuccess(list);
+
+ }
+ else
+ {
+ return ResultList.ReSuccess(customers);
+ }
+
+ }
+ catch (Exception)
+ {
+ return ResultList.ReFailure(ResultCodes.ErpSupplierError);
+ }
+ }
///
/// erp:仓库
///
@@ -1006,6 +1074,8 @@ namespace WMS.Web.Domain.Services.Public
}
}
+
+
#endregion
}
}
diff --git a/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs b/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs
index 9221849a..ad225a75 100644
--- a/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs
+++ b/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs
@@ -68,6 +68,10 @@ namespace WMS.Web.Domain.Values.Erp
///
/// 分布式调出单
///
- STK_TRANSFEROUT=15
+ STK_TRANSFEROUT=15,
+ ///
+ /// 客户
+ ///
+ BD_Customer=16
}
}
diff --git a/src/WMS.Web.Repositories/OutStockRepositories.cs b/src/WMS.Web.Repositories/OutStockRepositories.cs
index 30b15a6f..4b422fae 100644
--- a/src/WMS.Web.Repositories/OutStockRepositories.cs
+++ b/src/WMS.Web.Repositories/OutStockRepositories.cs
@@ -88,7 +88,7 @@ namespace WMS.Web.Repositories
var staffList = await _basicsRepositories.GetStaffListAsync(_loginRepositories.CompanyId);
ids = staffList.Where(w => EF.Functions.Like(w.Name, "%" + dto.Creator + "%")).Select(s => s.Id).ToList();
}
-
+ #region erp基础资料
List mIds = new List();
var materials_result = await _erpService.BillQueryForMaterial();
if (!materials_result.IsSuccess)
@@ -100,6 +100,24 @@ namespace WMS.Web.Repositories
mIds = materials.Where(w => EF.Functions.Like(w.MaterialNumber, "%" + dto.MaterialNumber + "%")).Select(s => s.MaterialId).ToList();
}
+ //取组织
+ var org_result = await _erpService.BillQueryForOrg();
+ if (!org_result.IsSuccess)
+ return (new List(), 0);
+ var orgs = org_result.Data.ToList();
+
+ List cIds = new List();
+ var customer_result = await _erpService.BillQueryForCustomer();
+ if (!customer_result.IsSuccess)
+ return (new List(), 0);
+ var customers = customer_result.Data.ToList();
+ //物料集合;模糊查询后的物料集合
+ if (!string.IsNullOrEmpty(dto.ReceiptCustomer))
+ {
+ cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.MaterialId).ToList();
+ }
+ #endregion
+
var query = _context.OutStockDetails
.GroupJoin(_context.OutStock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
@@ -139,8 +157,10 @@ namespace WMS.Web.Repositories
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockId),
SourceBillNo = s.order.SourceBillNo,
SaleBillNo = s.detail.SaleBillNo,
- DeliveryOrg = "",
- ReceiptCustomer = "",
+ DeliveryOrg = _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId),
+ ReceiptCustomer = s.order.Type == OutStockType.Sal
+ ? _erpBasicDataExtendService.GetCustomerName(customers, s.order.ReceiptCustomerId)
+ : _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId),
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialId),
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.detail.MaterialId),
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialId),
diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs
index 6d9c5fd7..2d2dae1f 100644
--- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs
+++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs
@@ -214,6 +214,7 @@ namespace WMS.Web.Repositories
///
public async Task<(List list, int total)> GetListAsync(OutStockTaskQueryRequest dto)
{
+ #region erp基础资料
List mIds = new List();
var materials_result = await _erpService.BillQueryForMaterial();
if (!materials_result.IsSuccess)
@@ -224,14 +225,34 @@ namespace WMS.Web.Repositories
{
mIds = materials.Where(w => EF.Functions.Like(w.MaterialNumber, "%" + dto.MaterialNumber + "%")).Select(s => s.MaterialId).ToList();
}
+
+ //取组织
+ var org_result = await _erpService.BillQueryForOrg();
+ if (!org_result.IsSuccess)
+ return (new List(), 0);
+ var orgs = org_result.Data.ToList();
+
+ List cIds = new List();
+ var customer_result = await _erpService.BillQueryForCustomer();
+ if (!customer_result.IsSuccess)
+ return (new List(), 0);
+ var customers = customer_result.Data.ToList();
+ //物料集合;模糊查询后的物料集合
+ if (!string.IsNullOrEmpty(dto.ReceiptCustomer))
+ {
+ cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.MaterialId).ToList();
+ }
+ #endregion
+
var query = _context.OutStockTaskDetails
.GroupJoin(_context.OutStockTask, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.OrderByDescending(o => o.order.Id)
.Where(adv => 1 == 1);
- //if (!string.IsNullOrEmpty(dto.ReceiptCustomer))
- if (mIds.Count()!=0)
+ if (cIds.Count() != 0)
+ query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId));
+ if (mIds.Count() != 0)
query = query.Where(w => mIds.Contains(w.detail.MaterialId));
if (dto.Ids.Count() > 0)
query = query.Where(w => dto.Ids.Contains(w.detail.Id));
@@ -255,18 +276,20 @@ namespace WMS.Web.Repositories
{
#region dto组装
Id = s.order.Id,
- DetailId=s.detail.Id,
- BillNo =s.order.BillNo,
+ DetailId = s.detail.Id,
+ BillNo = s.order.BillNo,
Status = s.order.Status.GetRemark(),
Type = s.order.Type.GetRemark(),
CreateTime = s.order.OperateTime.DateToStringSeconds(),
- OutStockBeginTime= s.detail.OutStockBeginTime.DateToStringSeconds(),
+ OutStockBeginTime = s.detail.OutStockBeginTime.DateToStringSeconds(),
OutStockEndTime = s.detail.OutStockEndTime.DateToStringSeconds(),
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockId),
SourceBillNo = s.order.SourceBillNo,
SaleBillNo = s.detail.SaleBillNo,
- DeliveryOrg = "",
- ReceiptCustomer = "",
+ DeliveryOrg = _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId),
+ ReceiptCustomer = s.order.Type == OutStockType.Sal
+ ? _erpBasicDataExtendService.GetCustomerName(customers, s.order.ReceiptCustomerId)
+ : _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId),
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialId),
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.detail.MaterialId),
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialId),