批号管理
This commit is contained in:
@@ -3987,6 +3987,20 @@
|
||||
<param name="number"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForMaterialByNumber(System.String)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="number"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForMaterialByNumber(System.String,System.String)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="number"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForOrg">
|
||||
<summary>
|
||||
|
||||
@@ -5093,7 +5107,7 @@
|
||||
<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,WMS.Web.Domain.IService.Public.IErpService)">
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Push(WMS.Web.Core.Dto.Erp.ErpPushDto,WMS.Web.Domain.Entitys.InStockErpDetails,System.String,WMS.Web.Domain.IService.Public.IErpService,WMS.Web.Domain.Infrastructure.IInStockRepositories)">
|
||||
<summary>
|
||||
下推
|
||||
</summary>
|
||||
|
||||
@@ -128,6 +128,19 @@ namespace WMS.Web.Domain.IService.Public
|
||||
/// <returns></returns>
|
||||
Task<Result<ErpMaterialDto>> BillQueryForMaterial(string number);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
Task<ErpMaterialDto> BillQueryForMaterialByNumber(string number);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
Task<ErpMaterialDto> BillQueryForMaterialByNumber(string number, string orgCode);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
@@ -734,6 +734,7 @@ namespace WMS.Web.Domain.Services
|
||||
//要下推的明细
|
||||
var erpDetails = new List<InStockErpDetails>();
|
||||
var sc_erpService = scope.ServiceProvider.GetRequiredService<IErpService>();
|
||||
var sc_inStockRepositories = scope.ServiceProvider.GetRequiredService<IInStockRepositories>();
|
||||
|
||||
//找到金蝶最新的采购订单数据
|
||||
var erp_purchase_result = await sc_erpService.BillQueryForPurchaseInStock(entity.ErpDetails.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList());
|
||||
@@ -760,7 +761,7 @@ namespace WMS.Web.Domain.Services
|
||||
IsDraftWhenSaveFail = true
|
||||
};
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto, s, entity.BillNo, sc_erpService);
|
||||
var res = await this.Push(erpDto, s, entity.BillNo, sc_erpService, sc_inStockRepositories);
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(s.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
else
|
||||
@@ -779,7 +780,7 @@ namespace WMS.Web.Domain.Services
|
||||
/// <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, IErpService sc_erpService)
|
||||
private async Task<(Result result, SyncStatus syncStatus, string erpBillNo)> Push(ErpPushDto dto, InStockErpDetails erpDetail, string billNo, IErpService sc_erpService, IInStockRepositories sc_inStockRepositories)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -794,8 +795,27 @@ namespace WMS.Web.Domain.Services
|
||||
var resPurchaseInStock = await sc_erpService.BillQueryForPurchaseInStock(id);
|
||||
var purchaseInStock = resPurchaseInStock.Data;
|
||||
purchaseInStock.Details[0].Qty = erpDetail.Qty;
|
||||
if (!string.IsNullOrEmpty(erpDetail.BatchBillNo))
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(erpDetail.BatchBillNo))
|
||||
{
|
||||
var current_erp_material = await sc_erpService.BillQueryForMaterialByNumber(erpDetail.MaterialNumber);
|
||||
if (current_erp_material != null && current_erp_material.IsBatchManage == true)
|
||||
{
|
||||
//1.获取最新的erp明细信息
|
||||
var billNo_new = await sc_inStockRepositories.GetLastBillNo();
|
||||
//erp明细:生成批号
|
||||
int new_firstBillNo = billNo_new == null ? 0 : (billNo_new.FirstBillNo.HasValue ? billNo_new.FirstBillNo.Value : 0);
|
||||
int new_lastBillNo = billNo_new == null ? 0 : (billNo_new.LastBillNo.HasValue ? billNo_new.LastBillNo.Value : 0);
|
||||
|
||||
erpDetail.GenerateBatchBillNo(new_firstBillNo, new_lastBillNo, current_erp_material.IsBatchManage);
|
||||
if (!string.IsNullOrEmpty(erpDetail.BatchBillNo))
|
||||
purchaseInStock.Details[0].Lot = erpDetail.BatchBillNo;
|
||||
}
|
||||
}
|
||||
else
|
||||
purchaseInStock.Details[0].Lot = erpDetail.BatchBillNo;
|
||||
|
||||
string formId = dto.TargetFormId.ToString();
|
||||
_logger.LogInformation($"入库单->开始同步金蝶 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 数据: {JsonConvert.SerializeObject(dto)}");
|
||||
var res_s = await sc_erpService.Save<ErpPurchaseInStockSaveDto>(purchaseInStock, formId);
|
||||
|
||||
@@ -1081,7 +1081,7 @@ namespace WMS.Web.Domain.Services.Public
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<ErpMaterialDto> BillQueryForMaterialByNumber(string number)
|
||||
public async Task<ErpMaterialDto> BillQueryForMaterialByNumber(string number)
|
||||
{
|
||||
if (string.IsNullOrEmpty(number)) return null;
|
||||
//2.先登录金蝶-拿到token
|
||||
@@ -1149,6 +1149,74 @@ namespace WMS.Web.Domain.Services.Public
|
||||
|
||||
}
|
||||
|
||||
public async Task<ErpMaterialDto> BillQueryForMaterialByNumber(string number,string orgCode)
|
||||
{
|
||||
if (string.IsNullOrEmpty(number)) return null;
|
||||
//2.先登录金蝶-拿到token
|
||||
var token_result = await this.Init();
|
||||
if (!token_result.IsSuccess)
|
||||
return null;
|
||||
|
||||
//3.获取金蝶物料:拼接参数和条件
|
||||
var query = new ErpBillQueryDto(token_result.Data);
|
||||
var param = new ErpBillQueryParamDto(FormIdParam.BD_MATERIAL.ToString());
|
||||
param.FieldKeys = "FMATERIALID,FName,FNumber,FSpecification,FBaseUnitId,FBaseUnitId.FName,FBaseUnitId.FNumber,FBARCODE,FUseOrgId,FUseOrgId.FNumber,FIsBatchManage";
|
||||
param.Limit = 10000;
|
||||
|
||||
//查询条件:备注其中的条件值以金蝶的值为准!!!
|
||||
//1.审核状态:已审核
|
||||
//2.禁用状态:A否,B是
|
||||
//3.使用组织:只查询“深圳市元创时代科技有限公司”这个组织;组织ID=100008--固定值查询(测试端和正式是一样的)---按ID查询就不需要固定组织条件了
|
||||
param.FilterString = "FDocumentStatus='C' and FForbidStatus='A'";
|
||||
param.OrderString = "FCreateDate ASC";
|
||||
|
||||
//根据物料ID查询
|
||||
param.FilterString = param.FilterString + $" and FNumber='{number}' and FUseOrgId.FNumber='{orgCode}'";
|
||||
|
||||
//4.循环拿金蝶数据
|
||||
var erp_materials_list = new List<ErpMaterialDto>();
|
||||
|
||||
//4.2.参数json化
|
||||
query.Data = JsonConvert.SerializeObject(param);
|
||||
var json = JsonConvert.SerializeObject(query);
|
||||
|
||||
var error_josn = "";
|
||||
try
|
||||
{
|
||||
//4.3.请求查询接口并返回数据
|
||||
var result_json = await _client.ExecuteBillQueryAsync(json);
|
||||
error_josn = result_json;
|
||||
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
|
||||
//4.5.拼装
|
||||
foreach (var item in result)
|
||||
{
|
||||
var lis = new ErpMaterialDto();
|
||||
lis.MaterialId = Convert.ToInt32(item[0]);
|
||||
lis.MaterialName = item[1];
|
||||
lis.MaterialNumber = item[2];
|
||||
lis.Specifications = item[3];
|
||||
lis.BaseUnitId = Convert.ToInt32(item[4]);
|
||||
lis.BaseUnitName = item[5];
|
||||
lis.BaseUnitNumber = item[6];
|
||||
lis.BarCode = item[7];
|
||||
lis.OrgId = Convert.ToInt32(item[8]);
|
||||
lis.OrgCode = item[9];
|
||||
lis.IsBatchManage = Convert.ToBoolean(item[10]);
|
||||
erp_materials_list.Add(lis);
|
||||
}
|
||||
if (erp_materials_list.Count == 0)
|
||||
return null;
|
||||
else
|
||||
return erp_materials_list.FirstOrDefault();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_logger.LogInformation("物料拉取按Number->错误的Json:" + error_josn + ";参数:" + json);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// erp:单据查询-组织数据
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user