同步金蝶-代码处理提交
This commit is contained in:
@@ -160,7 +160,7 @@ namespace WMS.Web.Api.Controllers
|
||||
if (loginInfo == null || loginInfo.UserInfo == null)
|
||||
return Result.ReFailure(ResultCodes.Token_Invalid_Error);
|
||||
|
||||
return await _inStockService.Sync(dto);
|
||||
return await _inStockService.Sync(dto,loginInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,6 +775,41 @@
|
||||
单据编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.Erp.ErpPurchaseInStockSaveDto">
|
||||
<summary>
|
||||
修改采购入库单
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPurchaseInStockSaveDto.Id">
|
||||
<summary>
|
||||
单据Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPurchaseInStockSaveDto.Details">
|
||||
<summary>
|
||||
明细
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.Erp.ErpPurchaseInStockDetailsSaveDto">
|
||||
<summary>
|
||||
明细
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPurchaseInStockDetailsSaveDto.DetailId">
|
||||
<summary>
|
||||
明细Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPurchaseInStockDetailsSaveDto.PurchaseDetailId">
|
||||
<summary>
|
||||
采购订单明细Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPurchaseInStockDetailsSaveDto.Qty">
|
||||
<summary>
|
||||
数量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.Erp.ErpPushDto">
|
||||
<summary>
|
||||
下推
|
||||
|
||||
@@ -546,6 +546,11 @@
|
||||
仓位ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStock.ErpDetails">
|
||||
<summary>
|
||||
ERP明细
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStock.Details">
|
||||
<summary>
|
||||
明细
|
||||
@@ -570,6 +575,23 @@
|
||||
生成单据号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.InStock.SyncSuccess(System.Int32,System.Int32,System.String)">
|
||||
<summary>
|
||||
同步金蝶(成功)
|
||||
</summary>
|
||||
<param name="erpDetailId"></param>
|
||||
<param name="operateId"></param>
|
||||
<param name="erpBillNo"></param>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.InStock.SyncFail(System.String,System.Int32,System.Int32,WMS.Web.Domain.Values.SyncStatus)">
|
||||
<summary>
|
||||
同步金蝶(失败)
|
||||
</summary>
|
||||
<param name="remark"></param>
|
||||
<param name="erpDetailId"></param>
|
||||
<param name="operateId"></param>
|
||||
<param name="syncStatus"></param>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InStockDetails">
|
||||
<summary>
|
||||
wms入库单明细
|
||||
@@ -625,6 +647,51 @@
|
||||
序列号集
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InStockErpDetails">
|
||||
<summary>
|
||||
wms入库单ERP明细
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockErpDetails.Id">
|
||||
<summary>
|
||||
ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockErpDetails.Fid">
|
||||
<summary>
|
||||
单据头ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockErpDetails.ErpDetailId">
|
||||
<summary>
|
||||
对应金蝶的明细ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockErpDetails.SourceBillNo">
|
||||
<summary>
|
||||
来源单号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockErpDetails.MaterialId">
|
||||
<summary>
|
||||
物料ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockErpDetails.Qty">
|
||||
<summary>
|
||||
数量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockErpDetails.SuccessSync">
|
||||
<summary>
|
||||
同步成功或者失败 默认是失败状态
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockErpDetails.ErpSyncBillNo">
|
||||
<summary>
|
||||
同步到金蝶后金蝶的单据Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InStockTask">
|
||||
<summary>
|
||||
erp入库任务表
|
||||
@@ -2037,6 +2104,21 @@
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockRepositories.Update(WMS.Web.Domain.Entitys.InStock,System.Boolean)">
|
||||
<summary>
|
||||
修改
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockRepositories.GetList(System.Collections.Generic.List{System.Int32})">
|
||||
<summary>
|
||||
根据单据头id获取数据
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories">
|
||||
<summary>
|
||||
箱与任务单绑定(收货)关系表-仓储接口
|
||||
@@ -2466,11 +2548,12 @@
|
||||
入库单服务接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.IInStockService.Sync(WMS.Web.Core.Dto.OperateRequest)">
|
||||
<member name="M:WMS.Web.Domain.IService.IInStockService.Sync(WMS.Web.Core.Dto.OperateRequest,WMS.Web.Core.Dto.Login.LoginInDto)">
|
||||
<summary>
|
||||
同步
|
||||
同步金蝶
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<param name="loginInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.IInStockService.Receive(WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskRequest,WMS.Web.Core.Dto.Login.LoginInDto)">
|
||||
@@ -2797,6 +2880,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForPurchaseInStock(System.String)">
|
||||
<summary>
|
||||
erp:查询采购入库单信息
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForPurchaseInStock(System.Collections.Generic.List{System.String})">
|
||||
<summary>
|
||||
erp:单据查询-采购入库单
|
||||
@@ -3736,11 +3826,12 @@
|
||||
入库单服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Sync(WMS.Web.Core.Dto.OperateRequest)">
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Sync(WMS.Web.Core.Dto.OperateRequest,WMS.Web.Core.Dto.Login.LoginInDto)">
|
||||
<summary>
|
||||
同步-金蝶
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<param name="loginInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Receive(WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskRequest,WMS.Web.Core.Dto.Login.LoginInDto)">
|
||||
@@ -3819,6 +3910,23 @@
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.PurchaseInStock(WMS.Web.Domain.Entitys.InStock,WMS.Web.Core.Dto.Login.LoginInDto)">
|
||||
<summary>
|
||||
采购:同步金蝶
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<param name="loginInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Push(WMS.Web.Core.Dto.Erp.ErpPushDto,WMS.Web.Domain.Entitys.InStockErpDetails,System.String)">
|
||||
<summary>
|
||||
下推
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<param name="erpDetail"></param>
|
||||
<param name="billNo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Services.InStockTaskService">
|
||||
<summary>
|
||||
入库任务单-服务
|
||||
|
||||
53
src/WMS.Web.Core/Dto/Erp/ErpPurchaseInStockSaveDto.cs
Normal file
53
src/WMS.Web.Core/Dto/Erp/ErpPurchaseInStockSaveDto.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Core.Dto.Erp
|
||||
{
|
||||
/// <summary>
|
||||
/// 修改采购入库单
|
||||
/// </summary>
|
||||
public class ErpPurchaseInStockSaveDto
|
||||
{
|
||||
public ErpPurchaseInStockSaveDto() { }
|
||||
public ErpPurchaseInStockSaveDto(string id)
|
||||
{
|
||||
this.Id = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单据Id
|
||||
/// </summary>
|
||||
[JsonProperty("FID")]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
[JsonProperty("FEntity")]
|
||||
public List<ErpPurchaseInStockDetailsSaveDto> Details { get; set; } = new List<ErpPurchaseInStockDetailsSaveDto>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
public class ErpPurchaseInStockDetailsSaveDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 明细Id
|
||||
/// </summary>
|
||||
[JsonProperty("FENTRYID")]
|
||||
public string DetailId { get; set; }
|
||||
/// <summary>
|
||||
/// 采购订单明细Id
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string PurchaseDetailId { get; set; }
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
[JsonProperty("FRealQty")]
|
||||
public decimal Qty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -33,28 +33,6 @@ namespace WMS.Web.Core.Dto.InStock
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "供应商不能为空")]
|
||||
public int SupplierId { get; set; }
|
||||
///// <summary>
|
||||
///// 组织
|
||||
///// </summary>
|
||||
//[Required(ErrorMessage = "组织不能为空")]
|
||||
//public int OrgId { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 组织编码:仓位-仓库-带出
|
||||
///// </summary>
|
||||
//[Required(ErrorMessage = "组织不能为空")]
|
||||
//public string OrgCode { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 仓库编码
|
||||
/////</summary>
|
||||
//[Required(ErrorMessage = "仓库不能为空")]
|
||||
//public string StockCode { get; set; }
|
||||
///// <summary>
|
||||
///// 仓位ID
|
||||
/////</summary>
|
||||
//[Required(ErrorMessage = " 仓位不能为空")]
|
||||
//public int SubStockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对应金蝶的明细ID
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
@@ -73,6 +74,12 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 仓位ID
|
||||
/// </summary>
|
||||
public int SubStockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ERP明细
|
||||
/// </summary>
|
||||
public List<InStockErpDetails> ErpDetails { get; set; } = new List<InStockErpDetails>();
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
@@ -125,5 +132,44 @@ namespace WMS.Web.Domain.Entitys
|
||||
}
|
||||
this.BillNo = "RK" + idStr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步金蝶(成功)
|
||||
/// </summary>
|
||||
/// <param name="erpDetailId"></param>
|
||||
/// <param name="operateId"></param>
|
||||
/// <param name="erpBillNo"></param>
|
||||
public void SyncSuccess(int erpDetailId, int operateId, string erpBillNo)
|
||||
{
|
||||
var erpd = this.ErpDetails.Where(s=>s.ErpDetailId==erpDetailId).FirstOrDefault();
|
||||
erpd.SuccessSync = SyncStatus.Success;
|
||||
erpd.ErpSyncBillNo = erpBillNo;
|
||||
|
||||
//所有erp明细同步成功才是整个单据成功
|
||||
if (this.ErpDetails.Where(w => w.SuccessSync == SyncStatus.Success).Count() == this.Details.Count())
|
||||
{
|
||||
this.SuccessSync = SyncStatus.Success;
|
||||
this.Remark = "";
|
||||
}
|
||||
this.OperateId = operateId;
|
||||
this.SyncTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步金蝶(失败)
|
||||
/// </summary>
|
||||
/// <param name="remark"></param>
|
||||
/// <param name="erpDetailId"></param>
|
||||
/// <param name="operateId"></param>
|
||||
/// <param name="syncStatus"></param>
|
||||
public void SyncFail(string remark, int erpDetailId, int operateId, SyncStatus syncStatus)
|
||||
{
|
||||
var erpd = this.ErpDetails.FirstOrDefault(w => w.ErpDetailId == erpDetailId);
|
||||
erpd.SuccessSync = syncStatus;
|
||||
this.SuccessSync = SyncStatus.Fail;
|
||||
this.Remark = remark;
|
||||
this.OperateId = operateId;
|
||||
this.SyncTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using WMS.Web.Core;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
@@ -10,12 +12,12 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_wms_instock_details")]
|
||||
public class InStockDetails
|
||||
public class InStockDetails : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 单据头ID
|
||||
/// </summary>
|
||||
@@ -43,26 +45,10 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 供应商ID
|
||||
/// </summary>
|
||||
public int SupplierId { get; set; }
|
||||
///// <summary>
|
||||
///// 组织ID
|
||||
///// </summary>
|
||||
//public int OrgId { get; set; }
|
||||
///// <summary>
|
||||
///// 组织编码
|
||||
///// </summary>
|
||||
//public string OrgCode { get; set; }
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public int MaterialId { get; set; }
|
||||
///// <summary>
|
||||
///// 仓库编码
|
||||
///// </summary>
|
||||
//public string StockCode { get; set; }
|
||||
///// <summary>
|
||||
///// 仓位ID
|
||||
///// </summary>
|
||||
//public int SubStockId { get; set; }
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
|
||||
57
src/WMS.Web.Domain/Entitys/InStockErpDetails.cs
Normal file
57
src/WMS.Web.Domain/Entitys/InStockErpDetails.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using WMS.Web.Core;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// wms入库单ERP明细
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_wms_instock_erp_details")]
|
||||
public class InStockErpDetails : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public override int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据头ID
|
||||
/// </summary>
|
||||
public int Fid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对应金蝶的明细ID
|
||||
/// </summary>
|
||||
public int ErpDetailId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单号
|
||||
/// </summary>
|
||||
public string SourceBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public int MaterialId { get; set; }
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public decimal Qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 同步成功或者失败 默认是失败状态
|
||||
/// </summary>
|
||||
public SyncStatus SuccessSync { get; set; } = SyncStatus.Fail;
|
||||
|
||||
/// <summary>
|
||||
/// 同步到金蝶后金蝶的单据Id
|
||||
/// </summary>
|
||||
public string ErpSyncBillNo { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,12 @@ namespace WMS.Web.Domain.IService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 同步
|
||||
/// 同步金蝶
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Sync(OperateRequest dto);
|
||||
Task<Result> Sync(OperateRequest dto, LoginInDto loginInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 收货
|
||||
|
||||
@@ -20,6 +20,13 @@ namespace WMS.Web.Domain.IService.Public
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpBaseDto>> BillQueryForBillType();
|
||||
|
||||
/// <summary>
|
||||
/// erp:查询采购入库单信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result<ErpPurchaseInStockSaveDto>> BillQueryForPurchaseInStock(string id);
|
||||
|
||||
/// <summary>
|
||||
/// erp:单据查询-采购入库单
|
||||
/// </summary>
|
||||
|
||||
@@ -50,5 +50,20 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddRangeTotalDetails(List<InStockTotalDetails> entitys, bool isTransaction = true);
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<InStock> Update(InStock entity, bool isTransaction = true);
|
||||
|
||||
/// <summary>
|
||||
/// 根据单据头id获取数据
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<InStock>> GetList(List<int> ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -21,6 +23,7 @@ using WMS.Web.Domain.IService;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Mappers;
|
||||
using WMS.Web.Domain.Values;
|
||||
using WMS.Web.Domain.Values.Erp;
|
||||
|
||||
namespace WMS.Web.Domain.Services
|
||||
{
|
||||
@@ -43,10 +46,12 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly IInStockTaskRepositories _inStockTaskRepositories;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
private readonly IBoxInventoryRepositories _boxInventoryRepositories;
|
||||
private readonly ILogger<InStockService> _logger;
|
||||
public InStockService(IMapper mapper, ISerialNumbersRepositories serialNumbersRepositories, IErpService erpService, IBoxInventoryService boxInventoryService, ISerialNumberService serialNumberService, ILoginService loginService, IBoxRepositories boxRepositories,
|
||||
IBasicsRepositories basicsRepositories, IErpBasicDataExtendService erpBasicDataExtendService, IChangeMoveBoxService changeMoveBoxService, IInStockTaskBoxRepositories inStockTaskBoxRepositories,
|
||||
IInStockRepositories inStockRepositories, IInStockTaskRepositories inStockTaskRepositories, IBoxInventoryRepositories boxInventoryRepositories)
|
||||
IInStockRepositories inStockRepositories, IInStockTaskRepositories inStockTaskRepositories, IBoxInventoryRepositories boxInventoryRepositories, ILogger<InStockService> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_mapper = mapper;
|
||||
_erpService = erpService;
|
||||
_loginService = loginService;
|
||||
@@ -67,9 +72,15 @@ namespace WMS.Web.Domain.Services
|
||||
/// 同步-金蝶
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Sync(OperateRequest dto)
|
||||
public async Task<Result> Sync(OperateRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
var list = await _inStockRepositories.GetList(dto.Ids);
|
||||
foreach (var entity in list)
|
||||
{
|
||||
await this.PurchaseInStock(entity, loginInfo);
|
||||
}
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
@@ -235,6 +246,15 @@ namespace WMS.Web.Domain.Services
|
||||
entity.Details = _mapper.Map<List<InStockDetails>>(dto.Details);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
|
||||
//组装:erp明细
|
||||
entity.ErpDetails = dto.Details.GroupBy(x => new { x.ErpDetailId, x.MaterialId, x.SourceBillNo })
|
||||
.Select(x => new InStockErpDetails
|
||||
{
|
||||
ErpDetailId = x.Key.ErpDetailId,
|
||||
MaterialId = x.Key.MaterialId,
|
||||
SourceBillNo = x.Key.SourceBillNo,
|
||||
Qty = x.Sum(t => t.Qty)
|
||||
}).ToList();
|
||||
|
||||
//序列号集:箱里面的
|
||||
var serialNumbers = await _serialNumbersRepositories.GetEntityListByBoxIds(dto.Details.GroupBy(x => x.BoxId).Select(x => x.Key).ToList());
|
||||
@@ -270,7 +290,7 @@ namespace WMS.Web.Domain.Services
|
||||
var isSuccess = await _inStockRepositories.AddRangeTotalDetails(totalDetails, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
//同步金蝶后,反写任务单的已交数量
|
||||
//反写任务单的已交数量
|
||||
var taskIds = dto.Details.GroupBy(x => x.TaskId).Select(x => x.Key).ToList();
|
||||
var tasks = await _inStockTaskRepositories.GetList(taskIds);
|
||||
if (tasks != null && tasks.Count != 0)
|
||||
@@ -305,6 +325,10 @@ namespace WMS.Web.Domain.Services
|
||||
if (!boxInventoryResult.IsSuccess)
|
||||
return boxInventoryResult;
|
||||
|
||||
//同步金蝶
|
||||
if (entity.Type == InstockType.Purchase)
|
||||
await this.PurchaseInStock(entity, loginInfo);
|
||||
|
||||
return Result.ReSuccess();
|
||||
|
||||
|
||||
@@ -685,6 +709,91 @@ namespace WMS.Web.Domain.Services
|
||||
return Result<ContrastMaterialsResponse>.ReSuccess(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 采购:同步金蝶
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Result> PurchaseInStock(InStock entity, LoginInDto loginInfo)
|
||||
{
|
||||
if (entity.Type != InstockType.Purchase) return Result.ReSuccess();
|
||||
if (entity.SuccessSync == SyncStatus.Success) return Result.ReSuccess();
|
||||
var erpDetails = entity.ErpDetails.Where(w => w.SuccessSync == SyncStatus.Fail).ToList();
|
||||
foreach (var s in erpDetails)
|
||||
{
|
||||
var erp_details = entity.ErpDetails
|
||||
.Where(w => w.SourceBillNo.Equals(s)).Select(s => s.ErpDetailId).ToList();
|
||||
var erpDto = new ErpPushDto()
|
||||
{
|
||||
RuleId = "PUR_PurchaseOrder-STK_InStock",//转换规则内码 采购订单下推采购入库单
|
||||
FormId = FormIdParam.PUR_PurchaseOrder.ToString(),
|
||||
TargetFormId = FormIdParam.STK_InStock.ToString(),
|
||||
DetailsId = s.ErpDetailId.ToString()
|
||||
};
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto, s, entity.BillNo);
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(s.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
else
|
||||
entity.SyncFail(res.result.Message, s.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
}
|
||||
//最好一条一条执行,否则执行失败 但是金蝶那边又同步成功 就会造成数据比价乱
|
||||
var isSuccess = await _inStockRepositories.Update(entity, true);
|
||||
if (entity == null) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下推
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="erpDetail"></param>
|
||||
/// <param name="billNo"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<(Result result, SyncStatus syncStatus, string erpBillNo)> Push(ErpPushDto dto, InStockErpDetails erpDetail, string billNo)
|
||||
{
|
||||
var res = await _erpService.Push(dto);
|
||||
if (!res.IsSuccess)
|
||||
{
|
||||
_logger.LogInformation($"入库单->下推失败 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 错误:{res.Message}");
|
||||
return (Result.ReFailure(res.Message, res.Status), SyncStatus.Fail, "");
|
||||
}
|
||||
string id = res.Data;
|
||||
var resPurchaseInStock = await _erpService.BillQueryForPurchaseInStock(id);
|
||||
var purchaseInStock = resPurchaseInStock.Data;
|
||||
purchaseInStock.Details[0].Qty = erpDetail.Qty;
|
||||
//{"Id":12709885,"Number":"XSCKD10629570","DIndex":0}
|
||||
|
||||
string formId = dto.TargetFormId.ToString();
|
||||
_logger.LogInformation($"入库单->开始同步金蝶 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 数据: {JsonConvert.SerializeObject(dto)}");
|
||||
var res_s = await _erpService.Save<ErpPurchaseInStockSaveDto>(purchaseInStock, formId);
|
||||
if (!res_s.IsSuccess)
|
||||
{
|
||||
_logger.LogInformation($"入库单->修改数量失败 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 错误:{res_s.Message}");
|
||||
return (Result.ReFailure(res_s.Message, res_s.Status), SyncStatus.SubmitFail, id);
|
||||
}
|
||||
//提交
|
||||
_logger.LogInformation($"入库单->保存成功 开始提交 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId}");
|
||||
ErpOperateDto o_dto = new ErpOperateDto(formId, res_s.Data);//res_s.Data
|
||||
var resSubmit = await _erpService.Submit(o_dto, formId);
|
||||
if (!resSubmit.IsSuccess)
|
||||
{
|
||||
_logger.LogInformation($"入库单->提交失败 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 错误:{resSubmit.Message}");
|
||||
return (resSubmit, SyncStatus.SubmitFail, o_dto.Numbers.First());
|
||||
}
|
||||
//审核
|
||||
_logger.LogInformation($"入库单->提交成功 开始审核 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId}");
|
||||
resSubmit = await _erpService.Audit(o_dto, formId);
|
||||
if (!resSubmit.IsSuccess)
|
||||
{
|
||||
_logger.LogInformation($"入库单->审核失败 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 错误:{resSubmit.Message}");
|
||||
return (resSubmit, SyncStatus.CheckFail, o_dto.Numbers.First());
|
||||
}
|
||||
_logger.LogInformation($"同步金蝶成功");
|
||||
return (Result.ReSuccess(), SyncStatus.Success, o_dto.Numbers.First());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2092,6 +2092,48 @@ namespace WMS.Web.Domain.Services.Public
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Result<ErpPurchaseInStockSaveDto>> BillQueryForPurchaseInStock(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
//1.先登录金蝶-拿到token
|
||||
var token_result = await this.Init();
|
||||
if (!token_result.IsSuccess)
|
||||
return Result<ErpPurchaseInStockSaveDto>.ReFailure(token_result);
|
||||
|
||||
|
||||
//3.获取金蝶采购订单:拼接参数和条件
|
||||
var query = new ErpBillQueryDto(token_result.Data);
|
||||
var param = new ErpBillQueryParamDto(FormIdParam.STK_InStock.ToString());
|
||||
param.FieldKeys = "FID,FInStockEntry_FEntryID,FRealQty";
|
||||
param.Limit = 10000;
|
||||
param.FilterString = $"FID={id}";
|
||||
|
||||
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 ErpPurchaseInStockSaveDto(id);
|
||||
foreach (var item in result)
|
||||
{
|
||||
var lis = new ErpPurchaseInStockDetailsSaveDto();
|
||||
lis.DetailId = item[1];
|
||||
lis.Qty = Convert.ToDecimal(item[2]);
|
||||
lis.PurchaseDetailId = "";
|
||||
erp_list.Details.Add(lis);
|
||||
}
|
||||
return Result<ErpPurchaseInStockSaveDto>.ReSuccess(erp_list);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result<ErpPurchaseInStockSaveDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,11 @@ namespace WMS.Web.Repositories.Configuration
|
||||
.WithOne()
|
||||
.HasForeignKey(p => p.Fid)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
ent.HasMany(p => p.ErpDetails)
|
||||
.WithOne()
|
||||
.HasForeignKey(p => p.Fid)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
builder.Entity<InStockDetails>(ent =>
|
||||
{
|
||||
@@ -200,6 +205,11 @@ namespace WMS.Web.Repositories.Configuration
|
||||
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
|
||||
c => (List<string>)c.ToList()));
|
||||
});
|
||||
builder.Entity<InStockErpDetails>(ent =>
|
||||
{
|
||||
ent.ToTable("t_wms_instock_erp_details");
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
builder.Entity<InStockTotalDetails>(ent =>
|
||||
{
|
||||
ent.ToTable("t_wms_instock_total_details");
|
||||
|
||||
@@ -14,6 +14,7 @@ using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Mappers;
|
||||
using WMS.Web.Domain.Values;
|
||||
using WMS.Web.Domain.Values.Single;
|
||||
using WMS.Web.Repositories.Configuration;
|
||||
@@ -249,5 +250,55 @@ namespace WMS.Web.Repositories
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<InStock> Update(InStock entity, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var model = await _context.Instock
|
||||
.AsNoTracking()
|
||||
.Include(s => s.Details)
|
||||
.FirstOrDefaultAsync(f => f.Id == entity.Id);
|
||||
if (model == null)
|
||||
return null;
|
||||
_mapper.Map(entity, model);
|
||||
//子集单独映射
|
||||
_mapper.ToMapList(entity.Details, model.Details);
|
||||
await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return model;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据单据头id获取数据
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<InStock>> GetList(List<int> ids)
|
||||
{
|
||||
var res = await _context.Instock
|
||||
.Include(s => s.Details)
|
||||
.Include(s => s.ErpDetails)
|
||||
.Where(f => ids.Contains(f.Id))
|
||||
.ToListAsync();
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user