This commit is contained in:
tongfei
2023-11-06 16:56:42 +08:00
16 changed files with 907 additions and 23 deletions

View File

@@ -35,7 +35,7 @@ namespace WMS.Web.Api.Controllers
[Route("hj")] [Route("hj")]
public async Task<string> TestHJ() public async Task<string> TestHJ()
{ {
var res = await this._erpService.BillQueryForDeliveryNoticeOutStock(); var res = await this._erpService.BillQueryForTransferDirectOutStock();
//var result= await this._erpService.BillQueryForPurchaseInStock(); //var result= await this._erpService.BillQueryForPurchaseInStock();
//var result = await this._erpService.BillQueryForOrg(); //var result = await this._erpService.BillQueryForOrg();
var result = await this._erpService.BillQueryForMaterial(); var result = await this._erpService.BillQueryForMaterial();

View File

@@ -675,6 +675,11 @@
创建时间erp那边的创建时间 创建时间erp那边的创建时间
</summary> </summary>
</member> </member>
<member name="P:WMS.Web.Core.Dto.Erp.OutStock.ErpDeliveryNoticeOutStockResultDto.Type">
<summary>
用来自动构建单据类型 跟OutStockType 一致
</summary>
</member>
<member name="T:WMS.Web.Core.Dto.Erp.OutStock.ErpOutStockSaveDto"> <member name="T:WMS.Web.Core.Dto.Erp.OutStock.ErpOutStockSaveDto">
<summary> <summary>
出库单同步金蝶 出库单同步金蝶

View File

@@ -746,7 +746,7 @@
明细 明细
</summary> </summary>
</member> </member>
<member name="M:WMS.Web.Domain.Entitys.OutStock.Create(System.Int32,System.Int32,WMS.Web.Domain.Values.OrderType)"> <member name="M:WMS.Web.Domain.Entitys.OutStock.Create(System.Int32,System.Int32,WMS.Web.Domain.Values.OutStockType)">
<summary> <summary>
创建 创建
</summary> </summary>
@@ -1344,9 +1344,24 @@
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockRepositories.EditEntityList(System.Collections.Generic.List{WMS.Web.Domain.Entitys.OutStock},System.Boolean)"> <member name="M:WMS.Web.Domain.Infrastructure.IOutStockRepositories.EditEntityList(System.Collections.Generic.List{WMS.Web.Domain.Entitys.OutStock},System.Boolean)">
修改实体集合 修改实体集合
</member> </member>
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.AddRange(System.Collections.Generic.List{WMS.Web.Domain.Entitys.OutStockTask},System.Boolean)">
<summary>
批量添加
</summary>
<param name="entitys"></param>
<param name="isTransaction"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityList(System.Collections.Generic.List{System.Int32})"> <member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityList(System.Collections.Generic.List{System.Int32})">
查询实体集合 查询实体集合
</member> </member>
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetListBySourceBillNo(System.Collections.Generic.List{System.String})">
<summary>
列表-根据明细中的来源单号
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.EditEntityList(System.Collections.Generic.List{WMS.Web.Domain.Entitys.OutStockTask},System.Boolean)"> <member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.EditEntityList(System.Collections.Generic.List{WMS.Web.Domain.Entitys.OutStockTask},System.Boolean)">
修改实体集合 修改实体集合
</member> </member>
@@ -1468,7 +1483,37 @@
</member> </member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForDeliveryNoticeOutStock(System.Collections.Generic.List{System.String})"> <member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForDeliveryNoticeOutStock(System.Collections.Generic.List{System.String})">
<summary> <summary>
erp:单据查询-采购入库单 erp:单据查询-库单
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferDirectOutStock(System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-直接调拨出库
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferOutOutStock(System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-分布式调出
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledAppOutStock_Dassembly(System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-组装拆卸单(拆卸 主出)
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledAppOutStock_Assembly(System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-组装拆卸单(组装 子出)
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForMisDeliveryOutStock(System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-其他出库
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
@@ -1565,13 +1610,37 @@
出库任务 出库任务
</summary> </summary>
</member> </member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.SsynDeliveryNoticeOutStock(System.Boolean)"> <member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.SsynDeliveryNoticeOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary> <summary>
采购发货通知单 采购发货通知单
</summary> </summary>
<param name="isTransaction"></param> <param name="isTransaction"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.BillQueryForTransferDirectOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-直接调拨出库
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.BillQueryForTransferOutOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-分布式调出
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.BillQueryForAssembledAppOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-组装拆卸单(拆卸 主出) 组装 子出
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.BillQueryForMisDeliveryOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary>
erp:单据查询-其他出库
</summary>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.IService.Public.ISingleDataService"> <member name="T:WMS.Web.Domain.IService.Public.ISingleDataService">
<summary> <summary>
单点数据返回服务接口 单点数据返回服务接口
@@ -2116,13 +2185,53 @@
<param name="dto"></param> <param name="dto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.SsynDeliveryNoticeOutStock(System.Boolean)"> <member name="M:WMS.Web.Domain.Services.OutStockTaskService.SsynDate(System.Collections.Generic.List{WMS.Web.Core.Dto.Erp.OutStock.ErpDeliveryNoticeOutStockResultDto},System.Boolean)">
<summary>
erp数据转化wms 执行数据库操作
</summary>
<param name="erp_list"></param>
<param name="isTransaction"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.SsynDeliveryNoticeOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary> <summary>
发货通知单同步数据 发货通知单同步数据
</summary> </summary>
<param name="isTransaction"></param> <param name="isTransaction"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.BillQueryForTransferDirectOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary>
直接调拨
</summary>
<param name="isTransaction"></param>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.BillQueryForTransferOutOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary>
分布式调出
</summary>
<param name="isTransaction"></param>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.BillQueryForAssembledAppOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary>
组装拆卸单
</summary>
<param name="isTransaction"></param>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.BillQueryForMisDeliveryOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary>
其他入库单
</summary>
<param name="isTransaction"></param>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.Services.Public.ErpService"> <member name="T:WMS.Web.Domain.Services.Public.ErpService">
<summary> <summary>
erp数据交互服务 erp数据交互服务
@@ -2173,6 +2282,41 @@
<param name="dto"></param> <param name="dto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferDirectOutStock(System.Collections.Generic.List{System.String})">
<summary>
直接调拨出库
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferOutOutStock(System.Collections.Generic.List{System.String})">
<summary>
分布式调出
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledAppOutStock_Dassembly(System.Collections.Generic.List{System.String})">
<summary>
组装拆卸单 (拆卸 主出)
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForMisDeliveryOutStock(System.Collections.Generic.List{System.String})">
<summary>
其他出库
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledAppOutStock_Assembly(System.Collections.Generic.List{System.String})">
<summary>
组装拆卸单 (组装 子出)
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.HttpClientService.GetAsync``1(System.String,System.Int32)"> <member name="M:WMS.Web.Domain.Services.Public.HttpClientService.GetAsync``1(System.String,System.Int32)">
<summary> <summary>
Get方法 Get方法
@@ -2635,6 +2779,16 @@
销售发货通知单 销售发货通知单
</summary> </summary>
</member> </member>
<member name="F:WMS.Web.Domain.Values.Erp.FormIdParam.STK_MisDelivery">
<summary>
其他出库单
</summary>
</member>
<member name="F:WMS.Web.Domain.Values.Erp.FormIdParam.STK_TRANSFEROUT">
<summary>
分布式调出单
</summary>
</member>
<member name="T:WMS.Web.Domain.Values.InstockStatus"> <member name="T:WMS.Web.Domain.Values.InstockStatus">
<summary> <summary>
入库状态 入库状态

View File

@@ -49,5 +49,9 @@ namespace WMS.Web.Core.Dto.Erp.OutStock
/// 创建时间erp那边的创建时间 /// 创建时间erp那边的创建时间
///</summary> ///</summary>
public DateTime? CreateTime { get; set; } public DateTime? CreateTime { get; set; }
/// <summary>
/// 用来自动构建单据类型 跟OutStockType 一致
/// </summary>
public int Type { get; set; }
} }
} }

View File

@@ -44,7 +44,7 @@ namespace WMS.Web.Domain.Entitys
/// 单据类型 /// 单据类型
/// </summary> /// </summary>
[Column("Type")] [Column("Type")]
public OrderType Type { get; set; } = OrderType.Sal_Out; public OutStockType Type { get; set; } = OutStockType.Sal;
/// <summary> /// <summary>
/// 发货组织 /// 发货组织
///</summary> ///</summary>
@@ -78,7 +78,7 @@ namespace WMS.Web.Domain.Entitys
/// 创建 /// 创建
/// </summary> /// </summary>
/// <param name="creatorId"></param> /// <param name="creatorId"></param>
public void Create(int creatorId,int taskId, OrderType type) public void Create(int creatorId,int taskId, OutStockType type)
{ {
this.TaskId = taskId; this.TaskId = taskId;
this.Type = type; this.Type = type;

View File

@@ -51,7 +51,7 @@ namespace WMS.Web.Domain.Entitys
/// 单据类型 /// 单据类型
/// </summary> /// </summary>
[Column("Type")] [Column("Type")]
public OrderType Type { get; set; } = OrderType.Sal_Out; public OutStockType Type { get; set; } = OutStockType.Sal;
/// <summary> /// <summary>
/// 操作人(出库人) /// 操作人(出库人)
/// </summary> /// </summary>
@@ -71,6 +71,14 @@ namespace WMS.Web.Domain.Entitys
/// 明细 /// 明细
/// </summary> /// </summary>
public List<OutStockTaskDetails> Details = new List<OutStockTaskDetails>(); public List<OutStockTaskDetails> Details = new List<OutStockTaskDetails>();
public void Create(OutStockType type, string sourceBillNo, int deliveryOrgId, int receiptCustomerId, DateTime createTime)
{
this.Type = type;
this.SourceBillNo = sourceBillNo;
this.DeliveryOrgId = deliveryOrgId;
this.ReceiptCustomerId = receiptCustomerId;
this.CreateTime = createTime;
}
/// <summary> /// <summary>
/// 生成单据号 /// 生成单据号
/// </summary> /// </summary>
@@ -114,7 +122,7 @@ namespace WMS.Web.Domain.Entitys
{ {
// 符合合并数据逻辑:出库状态为”待拣货”+出库类型为:销售出库+发货组织一致+收货客户一致+发货仓库一致 // 符合合并数据逻辑:出库状态为”待拣货”+出库类型为:销售出库+发货组织一致+收货客户一致+发货仓库一致
if (list.Where(w => w.Status != OutStockStatus.Wait).Any()) return Result.ReFailure(ResultCodes.MergeStatusError); if (list.Where(w => w.Status != OutStockStatus.Wait).Any()) return Result.ReFailure(ResultCodes.MergeStatusError);
if (list.Where(w => w.Type != OrderType.Sal_Out).Any()) return Result.ReFailure(ResultCodes.MergeStatusError); if (list.Where(w => w.Type != OutStockType.Sal).Any()) return Result.ReFailure(ResultCodes.MergeStatusError);
if (list.GroupBy(g => g.DeliveryOrgId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError); if (list.GroupBy(g => g.DeliveryOrgId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError);
if (list.GroupBy(g => g.ReceiptCustomerId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError); if (list.GroupBy(g => g.ReceiptCustomerId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError);
@@ -131,7 +139,7 @@ namespace WMS.Web.Domain.Entitys
this.OperatorId = creatorId; this.OperatorId = creatorId;
this.OperateTime = DateTime.Now; this.OperateTime = DateTime.Now;
this.Status = OutStockStatus.Wait; this.Status = OutStockStatus.Wait;
this.Type = OrderType.Sal_Out; this.Type = OutStockType.Sal;
this.Details = details; this.Details = details;
return Result.ReSuccess(); return Result.ReSuccess();

View File

@@ -19,12 +19,35 @@ namespace WMS.Web.Domain.IService.Public
/// <returns></returns> /// <returns></returns>
Task<ResultList<ErpPurchaseInStockResultDto>> BillQueryForPurchaseInStock(); Task<ResultList<ErpPurchaseInStockResultDto>> BillQueryForPurchaseInStock();
/// <summary> /// <summary>
/// erp:单据查询-采购入库单 /// erp:单据查询-库单
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForDeliveryNoticeOutStock(List<string> sourceBillNos = null); Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForDeliveryNoticeOutStock(List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-直接调拨出库
/// </summary>
/// <returns></returns>
Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForTransferDirectOutStock(List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-分布式调出
/// </summary>
/// <returns></returns>
Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForTransferOutOutStock(List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-组装拆卸单(拆卸 主出)
/// </summary>
/// <returns></returns>
Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForAssembledAppOutStock_Dassembly(List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-组装拆卸单(组装 子出)
/// </summary>
/// <returns></returns>
Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForAssembledAppOutStock_Assembly(List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-其他出库
/// </summary>
/// <returns></returns>
Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForMisDeliveryOutStock(List<string> sourceBillNos = null);
/// <summary> /// <summary>
/// erp:单据查询-物料 /// erp:单据查询-物料
/// </summary> /// </summary>

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WMS.Web.Core.Dto; using WMS.Web.Core.Dto;
using WMS.Web.Core.Dto.Erp.OutStock;
using WMS.Web.Core.Dto.Login; using WMS.Web.Core.Dto.Login;
using WMS.Web.Core.Internal.Results; using WMS.Web.Core.Internal.Results;
@@ -18,7 +19,27 @@ namespace WMS.Web.Domain.IService.Public
/// </summary> /// </summary>
/// <param name="isTransaction"></param> /// <param name="isTransaction"></param>
/// <returns></returns> /// <returns></returns>
Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction); Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction,List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-直接调拨出库
/// </summary>
/// <returns></returns>
Task<Result> BillQueryForTransferDirectOutStock(bool isTransaction, List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-分布式调出
/// </summary>
/// <returns></returns>
Task<Result> BillQueryForTransferOutOutStock(bool isTransaction, List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-组装拆卸单(拆卸 主出) 组装 子出
/// </summary>
/// <returns></returns>
Task<Result> BillQueryForAssembledAppOutStock(bool isTransaction, List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-其他出库
/// </summary>
/// <returns></returns>
Task<Result> BillQueryForMisDeliveryOutStock(bool isTransaction, List<string> sourceBillNos = null);
//出库任务作废 //出库任务作废
Task<Result> Repeal(OperateRequest dto, LoginInDto loginInfo); Task<Result> Repeal(OperateRequest dto, LoginInDto loginInfo);
//出库任务作废 //出库任务作废

View File

@@ -11,10 +11,23 @@ namespace WMS.Web.Domain.Infrastructure
{ {
// 新增 // 新增
Task<OutStockTask> Add(OutStockTask entity, bool isTransaction = true); Task<OutStockTask> Add(OutStockTask entity, bool isTransaction = true);
/// <summary>
/// 批量添加
/// </summary>
/// <param name="entitys"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
Task<bool> AddRange(List<OutStockTask> entitys, bool isTransaction = true);
// 获取列表 // 获取列表
Task<(List<OutStockTaskQueryInfoResponse> list, int total)> GetListAsync(OutStockTaskQueryRequest dto); Task<(List<OutStockTaskQueryInfoResponse> list, int total)> GetListAsync(OutStockTaskQueryRequest dto);
/// 查询实体集合 /// 查询实体集合
Task<List<OutStockTask>> GetEntityList(List<int> ids); Task<List<OutStockTask>> GetEntityList(List<int> ids);
/// <summary>
/// 列表-根据明细中的来源单号
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
Task<List<OutStockTask>> GetListBySourceBillNo(List<string> sourceBillNos);
/// 修改实体集合 /// 修改实体集合
Task<bool> EditEntityList(List<OutStockTask> entitys, bool isTransaction = true); Task<bool> EditEntityList(List<OutStockTask> entitys, bool isTransaction = true);
//编辑 //编辑

View File

@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using WMS.Web.Core.Dto.Erp.OutStock;
using WMS.Web.Core.Dto.OutStock; using WMS.Web.Core.Dto.OutStock;
using WMS.Web.Core.Dto.OutStockTask; using WMS.Web.Core.Dto.OutStockTask;
using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Entitys;
@@ -22,6 +23,8 @@ namespace WMS.Web.Domain.Mappers
CreateMap<OutStockTask, GetOutStockTaskByNoResponse>(); CreateMap<OutStockTask, GetOutStockTaskByNoResponse>();
CreateMap<OutStockTaskDetails, GetOutStockTaskByNoDetailsResponse>(); CreateMap<OutStockTaskDetails, GetOutStockTaskByNoDetailsResponse>();
CreateMap<ErpDeliveryNoticeOutStockResultDto, OutStockTaskDetails>();
} }
} }
} }

View File

@@ -0,0 +1,81 @@
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Quartz;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Domain.Infrastructure;
using WMS.Web.Domain.IService;
using WMS.Web.Domain.IService.Public;
using WMS.Web.Domain.Options;
namespace WMS.Web.Domain.QuartzJob
{
public class OutStockOrderQuartzJob : IJob
{
private readonly ILogger<OutStockOrderQuartzJob> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly AppOptions _options;
private readonly IOutStockTaskService _outStockTaskService;
private readonly ITransactionRepositories _transactionRepositories;
public OutStockOrderQuartzJob(ILogger<OutStockOrderQuartzJob> logger,
IServiceScopeFactory serviceScopeFactory,
IOptions<AppOptions> options,
IOutStockTaskService inStockTaskService,
ITransactionRepositories transactionRepositories)
{
this._logger = logger;
_serviceScopeFactory = serviceScopeFactory;
this._options = options?.Value;
_outStockTaskService = inStockTaskService;
_transactionRepositories = transactionRepositories;
}
/// <summary>
/// 执行方法
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task Execute(IJobExecutionContext context)
{
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);
//5.记录:结束时间
var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行结束时间->{begindatetime}");
}
catch (Exception ex)
{
_logger.LogInformation($"同步金蝶入库单数据:定时任务执行失败->{ex.Message}");
}
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WMS.Web.Core.Dto; using WMS.Web.Core.Dto;
using WMS.Web.Core.Dto.Erp.OutStock;
using WMS.Web.Core.Dto.Erp.Purchase; using WMS.Web.Core.Dto.Erp.Purchase;
using WMS.Web.Core.Dto.Login; using WMS.Web.Core.Dto.Login;
using WMS.Web.Core.Internal.Results; using WMS.Web.Core.Internal.Results;
@@ -20,7 +21,7 @@ namespace WMS.Web.Domain.Services
/// <summary> /// <summary>
/// 出库任务 /// 出库任务
/// </summary> /// </summary>
public class OutStockTaskService: IOutStockTaskService public class OutStockTaskService : IOutStockTaskService
{ {
private readonly IMapper _mapper; private readonly IMapper _mapper;
private readonly IErpService _erpService; private readonly IErpService _erpService;
@@ -85,20 +86,150 @@ namespace WMS.Web.Domain.Services
return Result.ReSuccess(); return Result.ReSuccess();
} }
/// <summary>
/// erp数据转化wms 执行数据库操作
/// </summary>
/// <param name="erp_list"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<Result> SsynDate(List<ErpDeliveryNoticeOutStockResultDto> erp_list, bool isTransaction)
{
//2.通过单据编号找到wms系统现有的任务单并修改
var erp_removeList = new List<ErpDeliveryNoticeOutStockResultDto>();
var SourceBillNo_list = erp_list.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
var data_list = await _outStockTaskRepositories.GetListBySourceBillNo(SourceBillNo_list);
if (data_list.Count != 0)
{
//2.1提取出wms任务单明细信息
foreach (var e in erp_list)
{
//代表单据已经存在 那么就对单据进行修改
var data = data_list.FirstOrDefault(f => f.SourceBillNo == e.SourceBillNo);
var detail = data.Details.FirstOrDefault(w => w.MaterialId == e.MaterialId);
//存在就修改,没有就添加
if (detail != null)
detail.AccruedQty = e.AccruedQty;
else
data.Details.Add(_mapper.Map<OutStockTaskDetails>(e));
erp_removeList.Add(e);
}
//2.2.提交修改
var isSuccess = await _outStockTaskRepositories.EditEntityList(data_list, isTransaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
//2.3剔除:已修改的单据
foreach (var item in erp_removeList)
erp_list.Remove(item);
//3.wms任务单的来源单据编号不存在于erp中那么就新增
if (erp_list.Count != 0)
{
var add_entitys = new List<OutStockTask>();
var billNos = erp_list.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
foreach (var item in billNos)
{
var e = erp_list.FirstOrDefault(f => f.SourceBillNo == item);
var dto = new OutStockTask();
dto.SourceBillNo = e.SourceBillNo;
dto.Create((OutStockType)e.Type, e.SourceBillNo, e.DeliveryOrgId, e.ReceiptCustomerId, (DateTime)e.CreateTime);
//找到当前对应来源单据编号的集合数据
var current_erp_details = erp_list.Where(x => x.SourceBillNo == item).ToList();
//给到dto的实体明细中
dto.Details = _mapper.Map<List<OutStockTaskDetails>>(current_erp_details);
add_entitys.Add(dto);
}
//3.1提交新增
isSuccess = await _outStockTaskRepositories.AddRange(add_entitys, isTransaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
}
}
return Result.ReSuccess();
}
/// <summary> /// <summary>
/// 发货通知单同步数据 /// 发货通知单同步数据
/// </summary> /// </summary>
/// <param name="isTransaction"></param> /// <param name="isTransaction"></param>
/// <returns></returns> /// <returns></returns>
public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction) public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction, List<string> sourceBillNos = null)
{ {
//1.获取金蝶数据:采购订单数据 //1.获取金蝶数据:采购订单数据
var erp_result = await _erpService.BillQueryForPurchaseInStock(); var erp_result = await _erpService.BillQueryForDeliveryNoticeOutStock(sourceBillNos);
if (!erp_result.IsSuccess) if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status); return Result.ReFailure(erp_result.Message, erp_result.Status);
var erp_list = erp_result.Data;
return Result.ReSuccess(); return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
/// <summary>
/// 直接调拨
/// </summary>
/// <param name="isTransaction"></param>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> BillQueryForTransferDirectOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
var erp_result = await _erpService.BillQueryForTransferDirectOutStock(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
/// <summary>
/// 分布式调出
/// </summary>
/// <param name="isTransaction"></param>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> BillQueryForTransferOutOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
var erp_result = await _erpService.BillQueryForTransferOutOutStock(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
/// <summary>
/// 组装拆卸单
/// </summary>
/// <param name="isTransaction"></param>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> BillQueryForAssembledAppOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
List<ErpDeliveryNoticeOutStockResultDto> list = new List<ErpDeliveryNoticeOutStockResultDto>();
var erp_result = await _erpService.BillQueryForAssembledAppOutStock_Dassembly(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
list.AddRange(erp_result.Data);
var erp_result_a = await _erpService.BillQueryForAssembledAppOutStock_Assembly(sourceBillNos);
if (!erp_result_a.IsSuccess)
return Result.ReFailure(erp_result_a.Message, erp_result_a.Status);
list.AddRange(erp_result_a.Data);
return await this.SsynDate(list, isTransaction);
}
/// <summary>
/// 其他入库单
/// </summary>
/// <param name="isTransaction"></param>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> BillQueryForMisDeliveryOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
var erp_result = await _erpService.BillQueryForMisDeliveryOutStock(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
} }
} }
} }

View File

@@ -360,6 +360,7 @@ namespace WMS.Web.Domain.Services.Public
return Result.ReSuccess(); return Result.ReSuccess();
} }
#region
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForDeliveryNoticeOutStock(List<string> sourceBillNos = null) public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForDeliveryNoticeOutStock(List<string> sourceBillNos = null)
{ {
try try
@@ -376,7 +377,7 @@ namespace WMS.Web.Domain.Services.Public
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result); return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件 //2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2000).ToString("yyyy-MM-dd 00:00:00"); var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件 //3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data); var query = new ErpBillQueryDto(token_result.Data);
@@ -421,6 +422,7 @@ namespace WMS.Web.Domain.Services.Public
lis.AccruedQty = Convert.ToDecimal(item[7]); lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8]; lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]); lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Sal;
erp_list.Add(lis); erp_list.Add(lis);
} }
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list); return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
@@ -430,5 +432,386 @@ namespace WMS.Web.Domain.Services.Public
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error); return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
} }
} }
/// <summary>
/// 直接调拨出库
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForTransferDirectOutStock(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_TransferDirect.ToString());
param.FieldKeys = "FBillNo,'',FStockOutOrgId,FStockOrgId,FMaterialID,FSrcStockId,FSrcStockLocId,FQty,FNoteEntry,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockId in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Stkdirecttransfers;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 分布式调出
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForTransferOutOutStock(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_TRANSFEROUT.ToString());
param.FieldKeys = "FBillNo,'',FStockOrgID,FStockInOrgID,FMaterialID,FSrcStockID,FSrcStockLocId,FQty,FEntryNote,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockID in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.StktransferInst;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 组装拆卸单 (拆卸 主出)
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForAssembledAppOutStock_Dassembly(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_AssembledApp.ToString());
param.FieldKeys = "FBillNo,'','0','0',FMaterialID,FStockID,FStockLocId,FQty,FDescription,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步 FBillTypeID
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C' and FAffairType='Dassembly'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockID in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Assembled;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 其他出库
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForMisDeliveryOutStock(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_MisDelivery.ToString());
param.FieldKeys = "FBillNo,'',FStockOrgId,FPickOrgId,FMaterialId,FStockId,FStockLocId ,FQty,FEntryNote,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockID in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Miscellaneous;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 组装拆卸单 (组装 子出)
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForAssembledAppOutStock_Assembly(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_AssembledApp.ToString());
param.FieldKeys = "FBillNo,'',FSubProOwnerIdH,FOwnerIdHead,FMaterialIDSETY,FStockIDSETY,FStockLocIdSETY,FQtySETY,FDescriptionSETY,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步 FBillTypeID
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C' and FAffairType='Assembly'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockID in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Assembled;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
#endregion
} }
} }

View File

@@ -60,6 +60,14 @@ namespace WMS.Web.Domain.Values.Erp
/// <summary> /// <summary>
/// 销售发货通知单 /// 销售发货通知单
/// </summary> /// </summary>
SAL_DELIVERYNOTICE = 13 SAL_DELIVERYNOTICE = 13,
/// <summary>
/// 其他出库单
/// </summary>
STK_MisDelivery=14,
/// <summary>
/// 分布式调出单
/// </summary>
STK_TRANSFEROUT=15
} }
} }

View File

@@ -99,7 +99,7 @@ namespace WMS.Web.Repositories
if (!string.IsNullOrEmpty(dto.SourceBillNo)) if (!string.IsNullOrEmpty(dto.SourceBillNo))
query = query.Where(w => EF.Functions.Like(w.order.SourceBillNo, "%" + dto.SourceBillNo + "%")); query = query.Where(w => EF.Functions.Like(w.order.SourceBillNo, "%" + dto.SourceBillNo + "%"));
if (dto.Type != null) if (dto.Type != null)
query = query.Where(w => w.order.Type == (OrderType)dto.Type); query = query.Where(w => w.order.Type == (OutStockType)dto.Type);
if (dto.SuccessSync != null) if (dto.SuccessSync != null)
query = query.Where(w => w.order.SuccessSync == dto.SuccessSync); query = query.Where(w => w.order.SuccessSync == dto.SuccessSync);
if (dto.DeliveryOrgId != null) if (dto.DeliveryOrgId != null)

View File

@@ -225,7 +225,7 @@ namespace WMS.Web.Repositories
if (!string.IsNullOrEmpty(dto.SourceBillNo)) if (!string.IsNullOrEmpty(dto.SourceBillNo))
query = query.Where(w => EF.Functions.Like(w.order.SourceBillNo, "%" + dto.SourceBillNo + "%")); query = query.Where(w => EF.Functions.Like(w.order.SourceBillNo, "%" + dto.SourceBillNo + "%"));
if (dto.Type != null) if (dto.Type != null)
query = query.Where(w => w.order.Type == (OrderType)dto.Type); query = query.Where(w => w.order.Type == (OutStockType)dto.Type);
if (dto.Status != null) if (dto.Status != null)
query = query.Where(w => w.order.Status == (OutStockStatus)dto.Status); query = query.Where(w => w.order.Status == (OutStockStatus)dto.Status);
if (dto.DeliveryOrgId != null) if (dto.DeliveryOrgId != null)
@@ -273,5 +273,55 @@ namespace WMS.Web.Repositories
var mIds = entity.Details.Select(s => s.MaterialId).ToList(); var mIds = entity.Details.Select(s => s.MaterialId).ToList();
return response; return response;
} }
/// <summary>
/// 根据来源单号搜索
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<List<OutStockTask>> GetListBySourceBillNo(List<string> sourceBillNos)
{
var entitys = await _context.OutStockTask
.Include(s => s.Details)
.Where(w => sourceBillNos.Contains(w.SourceBillNo))
.ToListAsync();
return entitys.Clone();
}
/// <summary>
/// 批量添加
/// </summary>
/// <param name="entitys"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<bool> AddRange(List<OutStockTask> entitys, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
if (entitys != null && entitys.Count != 0)
{
await _context.OutStockTask.AddRangeAsync(entitys);
await _context.SaveChangesAsync();
foreach (var item in entitys)
{
if (string.IsNullOrEmpty(item.BillNo))
//自动生成单据编号
item.GenerateNo();
}
await _context.SaveChangesAsync();
}
if (_transaction != null)
_transaction.Commit();
return true;
}
catch
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
}
} }
} }