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.Api/Controllers/SysConfigController.cs b/src/WMS.Web.Api/Controllers/SysConfigController.cs
index 848c1d2e..ae437c47 100644
--- a/src/WMS.Web.Api/Controllers/SysConfigController.cs
+++ b/src/WMS.Web.Api/Controllers/SysConfigController.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -7,6 +8,7 @@ using System.Linq;
using System.Threading.Tasks;
using WMS.Web.Core;
using WMS.Web.Core.Dto;
+using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.SingleData;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Infrastructure;
@@ -123,22 +125,22 @@ namespace WMS.Web.Api.Controllers
///
/// 根据仓库获取金蝶子仓库
///
- /// 仓库id
+ /// 仓库编码
+ /// 模糊匹配
///
[HttpGet]
- [Route("GetErp_SubUcStock/{id}")]
- public async Task>> GetErp_SubUcStock([FromRoute] int id)
+ [Route("GetErp_SubUcStock/{number}")]
+ public async Task>> GetErp_SubUcStock([FromRoute] string number, [FromQuery] string name)
{
var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
if (loginInfo == null || loginInfo.UserInfo == null)
return Result>.ReFailure(ResultCodes.Token_Invalid_Error);
List list = new List();
- var code = _singleDataService.GetSingleDataCode(SingleAction.Stocks, loginInfo.UserInfo.CompanyId, id);
- if (code.Substring(0, 2).Equals("HD") || code.Substring(0, 2).Equals("GD"))
+ if (number.Substring(0, 2).Equals("HD") || number.Substring(0, 2).Equals("GD"))
{
- var subs = await _erpService.BillQueryForSubStock(code);
- foreach (var s in subs.Data)
+ var subs = await _erpService.BillQueryForSubStock(number);
+ foreach (var s in subs.Data.Where(w=> EF.Functions.Like(w.Name, "%" + name + "%")))
{
list.Add(new UcStockResponse()
{
@@ -152,6 +154,42 @@ namespace WMS.Web.Api.Controllers
return Result>.ReSuccess(list);
}
+ ///
+ /// 获取出库单客户下拉列表
+ ///
+ ///
+ [HttpGet]
+ [Route("GetCustomers")]
+ public async Task>> GetCustomers()
+ {
+ var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
+ if (loginInfo == null || loginInfo.UserInfo == null)
+ return Result>.ReFailure(ResultCodes.Token_Invalid_Error);
+ var customers = await _erpService.BillQueryForCustomer();
+ var orgs = await _erpService.BillQueryForOrg();
+ List pullList = new List();
+ foreach (var c in customers.Data)
+ {
+ pullList.Add(new PullDownStrResponse()
+ {
+ Id = "c_" + c.Id,
+ Name = c.Name,
+ Code = c.Number
+ });
+ }
+ foreach (var o in orgs.Data)
+ {
+ pullList.Add(new PullDownStrResponse()
+ {
+ Id = "o_" + o.Id,
+ Name = o.Name,
+ Code = o.Number
+ });
+ }
+
+ return Result>.ReSuccess(pullList);
+ }
+
///
/// 获取仓位:模糊名称
///
diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml
index 9b174e90..54e963e2 100644
--- a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml
+++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml
@@ -283,11 +283,18 @@
仓库id
-
+
根据仓库获取金蝶子仓库
- 仓库id
+ 仓库编码
+ 模糊匹配
+
+
+
+
+ 获取出库单客户下拉列表
+
diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
index 1324203a..1ed35a82 100644
--- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
+++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
@@ -465,9 +465,24 @@
单据类型
-
+
- 非采购上架方式
+ 客户
+
+
+
+
+ ID
+
+
+
+
+ 编码
+
+
+
+
+ 名称
@@ -780,6 +795,26 @@
含税单价 取对应发货通知单对应物料编码行的 含税单价
+
+
+ key为string 下拉列表对象
+
+
+
+
+ id
+
+
+
+
+ 编码
+
+
+
+
+ 名字
+
+
erp-采购入库-返回数据源
@@ -1535,36 +1570,6 @@
同步成功或者失败
-
-
- 非采购单上架请求对象-按箱
-
-
-
-
- 单据ID(等同-入库任务单ID)
-
-
-
-
- 上架方式
-
-
-
-
- 箱集合
-
-
-
-
- 入库任务单明细
-
-
-
-
- 入库单明细
-
-
采购上架-请求对象
diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
index e2a875be..ee88f33b 100644
--- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
+++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
@@ -459,12 +459,6 @@
-
-
- 非采购上架
-
-
-
erp入库任务单的对应box箱信息表
@@ -757,7 +751,7 @@
明细
-
+
创建
@@ -1536,14 +1530,6 @@
-
-
- 上架-非采购订单
-
-
-
-
-
获取任务单:根据箱号信息
@@ -1551,7 +1537,7 @@
-
+
修改-入库任务信息
@@ -1652,6 +1638,14 @@
+
+
+ 获取客户名称
+
+
+
+
+
获取仓库名称
@@ -1736,6 +1730,12 @@
+
+
+ 客户
+
+
+
获取仓库信息
@@ -1823,7 +1823,7 @@
出库任务
-
+
采购发货通知单
@@ -1854,6 +1854,13 @@
+
+
+ 同步金蝶数据 不传源订单号则更新所有
+
+
+
+
单点数据返回服务接口
@@ -2336,14 +2343,6 @@
-
-
- 非采购单上架-按箱
-
-
-
-
-
获取任务单:根据箱号信息
@@ -2351,7 +2350,7 @@
-
+
采购上架-保存
@@ -2360,16 +2359,7 @@
-
-
- 非采购上架-按箱-保存
-
-
-
-
-
-
-
+
修改-入库任务信息
@@ -2455,7 +2445,7 @@
-
+
发货通知单同步数据
@@ -2494,6 +2484,13 @@
+
+
+ 同步金蝶数据 不传源订单号则更新所有
+
+
+
+
erp基础数据:扩展服务
@@ -2547,6 +2544,14 @@
+
+
+ 获取客户名称
+
+
+
+
+
获取仓库名称
@@ -2606,6 +2611,12 @@
+
+
+ 客户
+
+
+
erp:仓库
@@ -3146,6 +3157,11 @@
分布式调出单
+
+
+ 客户
+
+
入库状态
@@ -3371,21 +3387,6 @@
序列号操作类型
-
-
- 非采购上架方式
-
-
-
-
- 按箱上架
-
-
-
-
- 按产品上架
-
-
对接单点的接口方法-枚举
diff --git a/src/WMS.Web.Core/Dto/ChangeBoxRecord/SaveChangeBoxRecordRequest.cs b/src/WMS.Web.Core/Dto/ChangeBoxRecord/SaveChangeBoxRecordRequest.cs
index ef24724b..5f2ceb76 100644
--- a/src/WMS.Web.Core/Dto/ChangeBoxRecord/SaveChangeBoxRecordRequest.cs
+++ b/src/WMS.Web.Core/Dto/ChangeBoxRecord/SaveChangeBoxRecordRequest.cs
@@ -13,7 +13,6 @@ namespace WMS.Web.Core.Dto.ChangeBoxRecord
///
/// 原箱子ID
///
- [Required(ErrorMessage = "原箱子不能为空")]
public int SrcBoxId { get; set; }
///
/// 目标箱子ID
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.Core/Dto/Erp/PullDownStrResponse.cs b/src/WMS.Web.Core/Dto/Erp/PullDownStrResponse.cs
new file mode 100644
index 00000000..2965f375
--- /dev/null
+++ b/src/WMS.Web.Core/Dto/Erp/PullDownStrResponse.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WMS.Web.Core.Dto.Erp
+{
+ ///
+ /// key为string 下拉列表对象
+ ///
+ public class PullDownStrResponse
+ {
+ ///
+ /// id
+ ///
+ public string Id { get; set; }
+ ///
+ /// 编码
+ ///
+ public string Code { get; set; }
+ ///
+ /// 名字
+ ///
+ public string Name { get; set; }
+ }
+}
diff --git a/src/WMS.Web.Domain/Entitys/OutStock.cs b/src/WMS.Web.Domain/Entitys/OutStock.cs
index 20e5cde5..e9a7d6ef 100644
--- a/src/WMS.Web.Domain/Entitys/OutStock.cs
+++ b/src/WMS.Web.Domain/Entitys/OutStock.cs
@@ -73,10 +73,12 @@ namespace WMS.Web.Domain.Entitys
/// 创建
///
///
- public void Create(int creatorId,int taskId, OutStockType type)
+ public void Create(int creatorId, OutStockTask task)
{
- this.TaskId = taskId;
- this.Type = type;
+ this.TaskId = task.Id;
+ this.Type = task.Type;
+ this.DeliveryOrgId = task.DeliveryOrgId;
+ this.ReceiptCustomerId = task.ReceiptCustomerId;
this.CreatorId = creatorId;
this.CreateTime = DateTime.Now;
}
diff --git a/src/WMS.Web.Domain/IService/IChangeMoveBoxService.cs b/src/WMS.Web.Domain/IService/IChangeMoveBoxService.cs
index 68fb92ea..db52e99c 100644
--- a/src/WMS.Web.Domain/IService/IChangeMoveBoxService.cs
+++ b/src/WMS.Web.Domain/IService/IChangeMoveBoxService.cs
@@ -17,7 +17,7 @@ namespace WMS.Web.Domain.IService
public interface IChangeMoveBoxService
{
//改箱保存
- Task ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo);
+ Task ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo, bool isTransaction=true);
//移箱保存
Task MoveBoxSave(SaveMoveBoxRecordRequest dto, LoginInDto loginInfo);
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/IService/Public/IOutStockTaskService.cs b/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs
index 4df6006e..14efef7a 100644
--- a/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs
+++ b/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs
@@ -19,7 +19,7 @@ namespace WMS.Web.Domain.IService.Public
///
///
///
- Task SsynDeliveryNoticeOutStock(bool isTransaction,List sourceBillNos = null);
+ Task BillQueryForDeliveryNoticeOutStock(bool isTransaction,List sourceBillNos = null);
///
/// erp:单据查询-直接调拨出库
///
@@ -44,5 +44,11 @@ namespace WMS.Web.Domain.IService.Public
Task Repeal(OperateRequest dto, LoginInDto loginInfo);
//出库任务作废
Task merge(OperateRequest dto, LoginInDto loginInfo);
+ ///
+ /// 同步金蝶数据 不传源订单号则更新所有
+ ///
+ ///
+ ///
+ Task Ssyn(List sourceBillNos = null);
}
}
diff --git a/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs b/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs
index a8f6a448..d2cec87c 100644
--- a/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs
+++ b/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs
@@ -14,7 +14,7 @@ using WMS.Web.Domain.Options;
namespace WMS.Web.Domain.QuartzJob
{
- public class OutStockOrderQuartzJob : IJob
+ public class OutStockOrderQuartzJob : IJob
{
private readonly ILogger _logger;
private readonly IServiceScopeFactory _serviceScopeFactory;
@@ -44,28 +44,11 @@ namespace WMS.Web.Domain.QuartzJob
{
try
{
- //1.事务
- IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
- bool isRollback = false;
- bool isTransaction = false;
//2.记录:开始时间
var begindatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行开始时间->{begindatetime}");
//3.同步数据
- var result = await _outStockTaskService.SsynDeliveryNoticeOutStock(isTransaction);
- if (!result.IsSuccess) isRollback = true;
- result = await _outStockTaskService.BillQueryForTransferDirectOutStock(isTransaction);
- if (!result.IsSuccess) isRollback = true;
- result = await _outStockTaskService.BillQueryForTransferOutOutStock(isTransaction);
- if (!result.IsSuccess) isRollback = true;
- result = await _outStockTaskService.BillQueryForMisDeliveryOutStock(isTransaction);
- if (!result.IsSuccess) isRollback = true;
- result = await _outStockTaskService.BillQueryForAssembledAppOutStock(isTransaction);
- if (!result.IsSuccess) isRollback = true;
-
- //4.提交事务
- var isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
-
+ var result = await _outStockTaskService.Ssyn(null);
//5.记录:结束时间
var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行结束时间->{begindatetime}");
diff --git a/src/WMS.Web.Domain/Services/ChangeMoveBoxService.cs b/src/WMS.Web.Domain/Services/ChangeMoveBoxService.cs
index a7f8b403..44fb65cb 100644
--- a/src/WMS.Web.Domain/Services/ChangeMoveBoxService.cs
+++ b/src/WMS.Web.Domain/Services/ChangeMoveBoxService.cs
@@ -43,23 +43,29 @@ namespace WMS.Web.Domain.Services
///
///
///
- public async Task ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
+ public async Task ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo, bool isTransaction = false)
{
List boxList = new List();
+ //原箱有可能没有
var srcBox = await _boxRepositories.Get(dto.SrcBoxId);
var destBox = await _boxRepositories.Get(dto.DestBoxId);
- if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
+ //if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
if (destBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
var l = dto.Details.Select(s => (s.MaterialId, s.Qty, s.SerialNumbers)).ToList();
//原箱移出
- var res = srcBox.Out(l);
- if (!res.IsSuccess) return res;
+ Result res;
+ if (srcBox != null)
+ {
+ res = srcBox.Out(l);
+ if (!res.IsSuccess) return res;
+ }
//目标箱移入
res = destBox.In(l);
if (!res.IsSuccess) return res;
-
- boxList.Add(srcBox);
- boxList.Add(destBox);
+ if (srcBox != null)
+ boxList.Add(srcBox);
+ if (destBox != null)
+ boxList.Add(destBox);
//var entity = _mapper.Map(dto);\
List list = new List();
@@ -72,8 +78,9 @@ namespace WMS.Web.Domain.Services
//需要填写序列号
//需要修改库存
-
- IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
+ IDbContextTransaction _transaction = null;
+ if (isTransaction)
+ _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isSuccess = true;
isSuccess = await _changeBoxRecordRepositories.AddRange(list, false);
@@ -81,12 +88,15 @@ namespace WMS.Web.Domain.Services
isSuccess = await _boxRepositories.EditEntityList(boxList, false);
if (!isSuccess) isRollback = true;
-
+
//提交事务
- isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
- if (!isSuccess)
- return Result.ReFailure(ResultCodes.DateWriteError);
+ if (isTransaction)
+ {
+ isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
+ if (!isSuccess)
+ return Result.ReFailure(ResultCodes.DateWriteError);
+ }
return Result.ReSuccess();
}
diff --git a/src/WMS.Web.Domain/Services/OutStockService.cs b/src/WMS.Web.Domain/Services/OutStockService.cs
index 3962eccc..18ac6157 100644
--- a/src/WMS.Web.Domain/Services/OutStockService.cs
+++ b/src/WMS.Web.Domain/Services/OutStockService.cs
@@ -28,15 +28,17 @@ namespace WMS.Web.Domain.Services
public readonly IBasicsRepositories _transactionRepositories;
private readonly IOutStockRepositories _outStockRepositories;
private readonly IOutStockTaskRepositories _outStockTaskRepositories;
+ private readonly IOutStockTaskService _outStockTaskService;
public OutStockService(IMapper mapper, ILoginService loginService,
IBasicsRepositories transactionRepositories,
- IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories)
+ IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories, IOutStockTaskService outStockTaskService)
{
_mapper = mapper;
_loginService = loginService;
_transactionRepositories = transactionRepositories;
_outStockRepositories = outStockRepositories;
_outStockTaskRepositories = outStockTaskRepositories;
+ _outStockTaskService = outStockTaskService;
}
///
/// 出库单
@@ -48,15 +50,20 @@ namespace WMS.Web.Domain.Services
{
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
//OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId);
+ //同步该订单最新数据到wms系统
+ List nos = new List();
+ nos.Add(outStockTask.SourceBillNo);
+ var res = await _outStockTaskService.Ssyn(nos);
+ if (!res.IsSuccess) return Result.ReSuccess();
OutStock entity = new OutStock();
- entity.Create(loginInfo.UserInfo.StaffId, outStockTask.Id, outStockTask.Type);
+ entity.Create(loginInfo.UserInfo.StaffId, outStockTask);
foreach (var d in dto.Details)
{
//任务单明细
var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
if (tDetail == null) continue;
- var res = outStockTask.OutStock(d.MaterialId, d.Qty);
+ res = outStockTask.OutStock(d.MaterialId, d.Qty);
if (!res.IsSuccess) return res;
var outd = _mapper.Map(tDetail);
diff --git a/src/WMS.Web.Domain/Services/OutStockTaskService.cs b/src/WMS.Web.Domain/Services/OutStockTaskService.cs
index cf232675..9f67e015 100644
--- a/src/WMS.Web.Domain/Services/OutStockTaskService.cs
+++ b/src/WMS.Web.Domain/Services/OutStockTaskService.cs
@@ -158,7 +158,7 @@ namespace WMS.Web.Domain.Services
///
///
///
- public async Task SsynDeliveryNoticeOutStock(bool isTransaction, List sourceBillNos = null)
+ public async Task BillQueryForDeliveryNoticeOutStock(bool isTransaction, List sourceBillNos = null)
{
//1.获取金蝶数据:采购订单数据
var erp_result = await _erpService.BillQueryForDeliveryNoticeOutStock(sourceBillNos);
@@ -204,7 +204,7 @@ namespace WMS.Web.Domain.Services
public async Task BillQueryForAssembledAppOutStock(bool isTransaction, List sourceBillNos = null)
{
List list = new List();
-
+
var erp_result = await _erpService.BillQueryForAssembledAppOutStock_Dassembly(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
@@ -231,5 +231,99 @@ namespace WMS.Web.Domain.Services
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
+ ///
+ /// 同步金蝶数据 不传源订单号则更新所有
+ ///
+ ///
+ ///
+ public async Task Ssyn(List sourceBillNos = null)
+ {
+ //1.事务
+ IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
+ bool isRollback = false;
+ bool isSuccess = true;
+ Result result;
+ //定时任务更新
+ if (sourceBillNos == null)
+ {
+
+ //更新时间范围内所有
+ result= await BillQueryForDeliveryNoticeOutStock(false, null);
+ if (!result.IsSuccess) isRollback = true;
+ result = await BillQueryForTransferDirectOutStock(false, null);
+ if (!result.IsSuccess) isRollback = true;
+ result = await BillQueryForTransferOutOutStock(false, null);
+ if (!result.IsSuccess) isRollback = true;
+ result = await BillQueryForAssembledAppOutStock(false, null);
+ if (!result.IsSuccess) isRollback = true;
+ result = await BillQueryForMisDeliveryOutStock(false, null);
+ if (!result.IsSuccess) isRollback = true;
+
+ //同步成功后 更新定时开始时间
+ if (!isRollback)
+ {
+ }
+
+ //4.提交事务
+ isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
+ if (!isSuccess)
+ return Result.ReFailure(ResultCodes.DateWriteError);
+
+ return Result.ReSuccess();
+ }
+
+ //根据指定单号更新
+ List DeliveryNotice_Nos = new List();
+ List TransferDirect_Nos = new List();
+ List TransferOut_Nos = new List();
+ List AssembledApp_Nos = new List();
+ List MisDeliveryOut_Nos = new List();
+ var taskList = await _outStockTaskRepositories.GetListBySourceBillNo(sourceBillNos);
+ foreach (var entity in taskList)
+ {
+ if (entity.Type == OutStockType.Sal)
+ DeliveryNotice_Nos.Add(entity.SourceBillNo);
+ else if (entity.Type == OutStockType.Stkdirecttransfers)
+ TransferDirect_Nos.Add(entity.SourceBillNo);
+ else if (entity.Type == OutStockType.StktransferInst)
+ TransferOut_Nos.Add(entity.SourceBillNo);
+ else if (entity.Type == OutStockType.Assembled)
+ AssembledApp_Nos.Add(entity.SourceBillNo);
+ else if (entity.Type == OutStockType.Miscellaneous)
+ MisDeliveryOut_Nos.Add(entity.SourceBillNo);
+ }
+
+ if (DeliveryNotice_Nos.Count() > 0)
+ {
+ result= await BillQueryForDeliveryNoticeOutStock(false, DeliveryNotice_Nos);
+ if (!result.IsSuccess) isRollback = true;
+ }
+ if (TransferDirect_Nos.Count() > 0)
+ {
+ result = await BillQueryForDeliveryNoticeOutStock(false, TransferDirect_Nos);
+ if (!result.IsSuccess) isRollback = true;
+ }
+ if (TransferOut_Nos.Count() > 0)
+ {
+ result = await BillQueryForDeliveryNoticeOutStock(false, TransferOut_Nos);
+ if (!result.IsSuccess) isRollback = true;
+ }
+ if (AssembledApp_Nos.Count() > 0)
+ {
+ result = await BillQueryForDeliveryNoticeOutStock(false, AssembledApp_Nos);
+ if (!result.IsSuccess) isRollback = true;
+ }
+ if (MisDeliveryOut_Nos.Count() > 0)
+ {
+ result = await BillQueryForDeliveryNoticeOutStock(false, MisDeliveryOut_Nos);
+ if (!result.IsSuccess) isRollback = true;
+ }
+
+ //4.提交事务
+ isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
+ if (!isSuccess)
+ return Result.ReFailure(ResultCodes.DateWriteError);
+ return Result.ReSuccess();
+ }
}
}
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..9cb83af9 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,13 +100,36 @@ 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();
+
+ //取客户
+ var customer_result = await _erpService.BillQueryForCustomer();
+ if (!customer_result.IsSuccess)
+ return (new List(), 0);
+ var customers = customer_result.Data.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 })
.OrderByDescending(o => o.order.Id)
.Where(adv => 1 == 1);
- //if (!string.IsNullOrEmpty(dto.ReceiptCustomer))
+ if (!string.IsNullOrEmpty(dto.ReceiptCustomer))
+ {
+ var rec_type = dto.ReceiptCustomer.Substring(0, 1);
+ var rec_id = Convert.ToInt32(dto.ReceiptCustomer.Substring(2, dto.ReceiptCustomer.Length - 1));
+
+ if (rec_type.Equals("c"))//差销售出库单(客户)
+ query = query.Where(w => rec_id == w.order.ReceiptCustomerId && w.order.Type == OutStockType.Sal);
+ else//查其他单据(组织)
+ query = query.Where(w => rec_id == w.order.ReceiptCustomerId && w.order.Type != OutStockType.Sal);
+ }
if (mIds.Count() != 0)
query = query.Where(w => mIds.Contains(w.detail.MaterialId));
if (ids.Count() > 0)
@@ -139,8 +162,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..a9439152 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,38 @@ 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();
+
+ //取客户
+ var customer_result = await _erpService.BillQueryForCustomer();
+ if (!customer_result.IsSuccess)
+ return (new List(), 0);
+ var customers = customer_result.Data.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 (!string.IsNullOrEmpty(dto.ReceiptCustomer))
+ {
+ var rec_type = dto.ReceiptCustomer.Substring(0, 1);
+ var rec_id = Convert.ToInt32(dto.ReceiptCustomer.Substring(2, dto.ReceiptCustomer.Length - 1));
+
+ if (rec_type.Equals("c"))//差销售出库单(客户)
+ query = query.Where(w => rec_id == w.order.ReceiptCustomerId && w.order.Type == OutStockType.Sal);
+ else//查其他单据(组织)
+ query = query.Where(w => rec_id == w.order.ReceiptCustomerId && w.order.Type != OutStockType.Sal);
+ }
+ 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 +280,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),