From 69cc15d9e4e798b8250c19d34451d38ddc3f3a42 Mon Sep 17 00:00:00 2001
From: 18942506660 <18942506660@A18942506660>
Date: Thu, 2 Nov 2023 11:42:47 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=98=E7=82=B9=20erp?=
=?UTF-8?q?=E5=90=8C=E6=AD=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml | 39 ++++++--
src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml | 17 ++++
.../Dto/Erp/{TakeStock => }/ErpSave.cs | 11 ++-
src/WMS.Web.Core/Dto/Erp/ErpSubmitDto.cs | 28 ++++++
src/WMS.Web.Core/Dto/Erp/Stock/ErpStockDto.cs | 4 +-
.../IService/Public/IErpService.cs | 5 +
.../Services/Public/ErpService.cs | 97 ++++++++++++++++++-
src/WMS.Web.Domain/Values/Erp/FormIdParam.cs | 10 +-
src/WMS.Web.Domain/Values/ResultCodes.cs | 2 +
9 files changed, 197 insertions(+), 16 deletions(-)
rename src/WMS.Web.Core/Dto/Erp/{TakeStock => }/ErpSave.cs (60%)
create mode 100644 src/WMS.Web.Core/Dto/Erp/ErpSubmitDto.cs
diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
index 25d9e6f7..094ee7ff 100644
--- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
+++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
@@ -595,6 +595,31 @@
创建时间
+
+
+ 仓库信息
+
+
+
+
+ id
+
+
+
+
+ 编码
+
+
+
+
+ 名字
+
+
+
+
+ 业务组织(使用组织)编码
+
+
出厂价格
@@ -627,7 +652,7 @@
- 单据类型(标准盘亏单; 标准盘盈单)
+ 单据类型(标准盘亏单; 标准盘盈单 PY01_SYS) 盘亏 PK01_SYS
@@ -637,7 +662,7 @@
- 货主类型: 默认为业务组织
+ 货主类型: 默认为业务组织 BD_OwnerOrg
@@ -657,17 +682,17 @@
- 库存状态
+ 库存状态 KCZT001
-
- 货主类型: 默认为业务组织
+
+ 货主类型: 默认为业务组织 BD_OwnerOrg
- 取仓库对应的货主信息
+ 取仓库对应的货主信息 货主: 等于库存组织
@@ -677,7 +702,7 @@
- 保管者
+ 保管者 仓库”库存组织”
diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
index 0f00a434..fba257b5 100644
--- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
+++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
@@ -1393,6 +1393,12 @@
+
+
+ 获取仓库信息
+
+
+
登录服务接口
@@ -2013,6 +2019,12 @@
+
+
+ 获取使用组织
+
+
+
Get方法
@@ -2436,6 +2448,11 @@
供应商
+
+
+ 仓库
+
+
入库状态
diff --git a/src/WMS.Web.Core/Dto/Erp/TakeStock/ErpSave.cs b/src/WMS.Web.Core/Dto/Erp/ErpSave.cs
similarity index 60%
rename from src/WMS.Web.Core/Dto/Erp/TakeStock/ErpSave.cs
rename to src/WMS.Web.Core/Dto/Erp/ErpSave.cs
index 489e374b..8585d865 100644
--- a/src/WMS.Web.Core/Dto/Erp/TakeStock/ErpSave.cs
+++ b/src/WMS.Web.Core/Dto/Erp/ErpSave.cs
@@ -10,11 +10,16 @@ namespace WMS.Web.Core.Dto.Erp
///
public class ErpSave
{
+ public ErpSave(string formId,T model)
+ {
+ this.FormId = formId;
+ this.Model = model;
+ }
///
- /// 校验Json数据包是否重复传入,一旦重复传入,接口调用失败,默认false(非必录)
+ /// 业务对象表单Id(必录)
///
- [JsonProperty("ValidateRepeatJson")]
- public bool ValidateRepeatJson { get; set; } = false;
+ [JsonProperty("FormId")]
+ public string FormId { get; set; }
///
/// 单据体
///
diff --git a/src/WMS.Web.Core/Dto/Erp/ErpSubmitDto.cs b/src/WMS.Web.Core/Dto/Erp/ErpSubmitDto.cs
new file mode 100644
index 00000000..5c2c0653
--- /dev/null
+++ b/src/WMS.Web.Core/Dto/Erp/ErpSubmitDto.cs
@@ -0,0 +1,28 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WMS.Web.Core.Dto.Erp
+{
+ ///
+ /// erp 提交和审核
+ ///
+ public class ErpSubmitDto
+ {
+ public ErpSubmitDto(string formId, string id)
+ {
+ this.FormId = formId;
+ this.Ids = id;
+ }
+ ///
+ /// 业务对象表单Id(必录)
+ ///
+ [JsonProperty("FormId")]
+ public string FormId { get; set; }
+ ///
+ /// 单据Id
+ ///
+ public string Ids { get; set; }
+ }
+}
diff --git a/src/WMS.Web.Core/Dto/Erp/Stock/ErpStockDto.cs b/src/WMS.Web.Core/Dto/Erp/Stock/ErpStockDto.cs
index 900f00a5..69484205 100644
--- a/src/WMS.Web.Core/Dto/Erp/Stock/ErpStockDto.cs
+++ b/src/WMS.Web.Core/Dto/Erp/Stock/ErpStockDto.cs
@@ -22,8 +22,8 @@ namespace WMS.Web.Core.Dto.Erp
///
public string Name { get; set; }
///
- /// 业务组织(使用组织)编码
+ /// 业务组织(使用组织)
///
- public string OrgCode { get; set; }
+ public int OrgId { get; set; }
}
}
diff --git a/src/WMS.Web.Domain/IService/Public/IErpService.cs b/src/WMS.Web.Domain/IService/Public/IErpService.cs
index 093c61e7..d88300a9 100644
--- a/src/WMS.Web.Domain/IService/Public/IErpService.cs
+++ b/src/WMS.Web.Domain/IService/Public/IErpService.cs
@@ -6,6 +6,7 @@ using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.Purchase;
using WMS.Web.Core.Internal.Results;
+using WMS.Web.Domain.Entitys;
namespace WMS.Web.Domain.IService.Public
{
@@ -28,5 +29,9 @@ namespace WMS.Web.Domain.IService.Public
///
///
Task> BillQueryForStock();
+ //盘盈
+ Task TakeStock_Profit(TakeStock entity);
+ //盘亏
+ Task TakeStock_Loss(TakeStock entity);
}
}
diff --git a/src/WMS.Web.Domain/Services/Public/ErpService.cs b/src/WMS.Web.Domain/Services/Public/ErpService.cs
index ae16b736..82508cbe 100644
--- a/src/WMS.Web.Domain/Services/Public/ErpService.cs
+++ b/src/WMS.Web.Domain/Services/Public/ErpService.cs
@@ -14,6 +14,7 @@ using System.Threading.Tasks;
using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.Purchase;
+using WMS.Web.Core.Dto.Erp.TakeStock;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Entitys;
using WMS.Web.Domain.Infrastructure;
@@ -21,6 +22,7 @@ using WMS.Web.Domain.IService.Public;
using WMS.Web.Domain.Options;
using WMS.Web.Domain.Values;
using WMS.Web.Domain.Values.Erp;
+using WMS.Web.Domain.Values.Single;
namespace WMS.Web.Domain.Services.Public
{
@@ -35,14 +37,18 @@ namespace WMS.Web.Domain.Services.Public
private ERPGWSoapClient _client;
private readonly IMemoryCache _memoryCache;
private readonly IInStockTaskRepositories _inStockTaskRepositories;
+ private readonly ISingleDataService _singleDataService;
public readonly ITransactionRepositories _transactionRepositories;
+ private readonly ILoginRepositories _loginRepositories;
public ErpService(
IMapper mapper,
IOptions erpOptions,
ILogger logger,
IMemoryCache memoryCache,
IInStockTaskRepositories inStockTaskRepositories,
- ITransactionRepositories transactionRepositories)
+ ITransactionRepositories transactionRepositories,
+ ISingleDataService singleDataService,
+ ILoginRepositories loginRepositories)
{
this._erpOptions = erpOptions?.Value;
this._mapper = mapper;
@@ -50,6 +56,8 @@ namespace WMS.Web.Domain.Services.Public
this._memoryCache = memoryCache;
this._inStockTaskRepositories = inStockTaskRepositories;
this._transactionRepositories = transactionRepositories;
+ this._singleDataService = singleDataService;
+ this._loginRepositories = loginRepositories;
}
///
@@ -101,7 +109,7 @@ namespace WMS.Web.Domain.Services.Public
//3.单据类型:标准采购订单和标准委外订单
//4.明细关闭状态:正常
//5.仓库:wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步
- param.FilterString = "FCreateDate>='"+beginTime+"' and FCreateDate<='"+endTime+ "' and FDocumentStatus='C' and (FBillTypeID='83d822ca3e374b4ab01e5dd46a0062bd' or FBillTypeID='6d01d059713d42a28bb976c90a121142') and FMRPCloseStatus='A'";
+ param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C' and (FBillTypeID='83d822ca3e374b4ab01e5dd46a0062bd' or FBillTypeID='6d01d059713d42a28bb976c90a121142') and FMRPCloseStatus='A'";
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
@@ -123,6 +131,12 @@ namespace WMS.Web.Domain.Services.Public
lis.FSOSTOCKID = Convert.ToInt32(item[6]);
lis.FQty = Convert.ToDecimal(item[7]);
lis.FEntryNote = item[8];
+ lis.FCreateDate = Convert.ToDateTime(item[9]);
+ lis.FDocumentStatus = item[10];
+ lis.FBillTypeID = item[11];
+ lis.FMRPCloseStatus = item[12];
+ lis.FBillTypeFName = item[13];
+ //list.FCHUCHANGPRICE=FCHUCHANGPRICE[?];//这个是出厂价,但是金蝶测试没有这个字段,正式有的
lis.FCreateDate =Convert.ToDateTime(item[9]);
lis.FCHUCHANGPRICE = Convert.ToDecimal(item[10]);
lis.StockFNumber = item[11];
@@ -207,7 +221,7 @@ namespace WMS.Web.Domain.Services.Public
lis.Id = int.Parse(item[0]);
lis.Name = item[1];
lis.Code = item[2];
- lis.OrgCode = item[3];
+ lis.OrgId = Convert.ToInt32(item[3]);
list.Add(lis);
}
@@ -219,5 +233,82 @@ namespace WMS.Web.Domain.Services.Public
return ResultList.ReFailure("错误", 10002);
}
}
+ ///
+ /// 盘盈
+ ///
+ ///
+ ///
+ public async Task TakeStock_Profit(TakeStock entity)
+ {
+ try
+ {
+ //获取金蝶仓库仓位编码
+ var stockCode = _singleDataService.GetSingleDataCode(SingleAction.Stocks, _loginRepositories.CompanyId, entity.StockId);
+ var subStockCode = _singleDataService.GetSingleDataCode(SingleAction.Stocks, _loginRepositories.CompanyId, entity.SubStockId);
+
+ var res = await this.BillQueryForStock();
+ var stock = res.Data.FirstOrDefault(f => f.Code == stockCode);//需要根据单点code搜索
+ var subStock = res.Data.FirstOrDefault(f => f.Code == subStockCode);//需要根据单点code搜索
+ if (stock == null || subStock == null) return Result.ReFailure(ResultCodes.ErpStockNoData);
+ //组装dto
+ #region 组装dto
+ List detils = new List();
+ detils.Add(new ErpTakeStockDetailsSaveDto()
+ {
+ FOwnerid = stock.OrgId.ToString(),
+ FKeeperId = stock.OrgId.ToString(),
+ MaterialId = entity.MaterialId.ToString(),
+ UnitId = entity.UnitId.ToString(),
+ StockId = stock.Id.ToString(),
+ SubStockId = subStock.Id.ToString(),
+ BeforeQty = entity.BeforeQty,
+ AfterQty = entity.AfterQty,
+ FinalQty = entity.FinalQty,
+ Fnote = ""
+ });
+ ErpTakeStockSaveDto dto = new ErpTakeStockSaveDto()
+ {
+ BillNo = entity.BillNo,
+ StockOrgId = stock.OrgId.ToString(),
+ Type = "PY01_SYS",
+ Date = entity.Date,
+ Details = detils
+ };
+ #endregion
+
+ var token_result = await this.Init();
+ if (!token_result.IsSuccess)
+ return token_result;
+ var query = new ErpBillQueryDto(token_result.Data);
+ var param = new ErpSave(FormIdParam.STK_StockCountGain.ToString(), dto);
+ query.Data = JsonConvert.SerializeObject(param);
+
+ var result_json = await _client.SaveAsync(JsonConvert.SerializeObject(query));
+ //提交
+ var sparam = new ErpSubmitDto(FormIdParam.STK_StockCountGain.ToString(), "");
+ query.Data = JsonConvert.SerializeObject(sparam);
+ result_json = await _client.SubmitAsync(JsonConvert.SerializeObject(query));
+
+ //审核
+ result_json = await _client.AuditAsync(JsonConvert.SerializeObject(query));
+
+
+ return Result.ReSuccess();
+
+ }
+ catch (Exception)
+ {
+ return Result.ReFailure("错误", 10002);
+ }
+ }
+ ///
+ /// 盘亏
+ ///
+ ///
+ ///
+ public async Task TakeStock_Loss(TakeStock entity)
+ {
+ return Result.ReSuccess();
+ }
}
}
diff --git a/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs b/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs
index 3c59312a..a6a33311 100644
--- a/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs
+++ b/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs
@@ -44,6 +44,14 @@ namespace WMS.Web.Domain.Values.Erp
///
/// 仓库
///
- BD_STOCK=9
+ BD_STOCK=9,
+ ///
+ /// 盘盈单
+ ///
+ STK_StockCountGain,
+ ///
+ /// 盘亏单
+ ///
+ STK_StockCountLoss,
}
}
diff --git a/src/WMS.Web.Domain/Values/ResultCodes.cs b/src/WMS.Web.Domain/Values/ResultCodes.cs
index 6d8fa1e5..b96e0bdf 100644
--- a/src/WMS.Web.Domain/Values/ResultCodes.cs
+++ b/src/WMS.Web.Domain/Values/ResultCodes.cs
@@ -27,5 +27,7 @@ namespace WMS.Web.Domain.Values
public static ValueTuple BoxNoData = (80000, "箱信息不存在");
public static ValueTuple BoxMateriaNoData = (800010, "箱对应物料信息不存在");
+
+ public static ValueTuple ErpStockNoData = (900000, "Erp仓库信息不完整");
}
}