优化
This commit is contained in:
@@ -3122,6 +3122,22 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IMaterialsRepositories.GetEntityList(System.Collections.Generic.List{System.String},System.Boolean)">
|
||||
<summary>
|
||||
列表
|
||||
</summary>
|
||||
<param name="materNumbers"></param>
|
||||
<param name="isBatchManage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IMaterialsRepositories.UpdateRange(System.Collections.Generic.List{WMS.Web.Domain.Entitys.Materials},System.Boolean)">
|
||||
<summary>
|
||||
修改物料
|
||||
</summary>
|
||||
<param name="entitys"></param>
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IMoveBoxRecordRepositories.AddRange(System.Collections.Generic.List{WMS.Web.Domain.Entitys.MoveBoxRecord},System.Boolean)">
|
||||
批量添加
|
||||
</member>
|
||||
|
||||
@@ -45,5 +45,21 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<string>> GetAllNumbers();
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="materNumbers"></param>
|
||||
/// <param name="isBatchManage"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<Materials>> GetEntityList(List<string> materNumbers, bool isBatchManage);
|
||||
|
||||
/// <summary>
|
||||
/// 修改物料
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateRange(List<Materials> entitys, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,6 +794,7 @@ 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))
|
||||
purchaseInStock.Details[0].Lot = erpDetail.BatchBillNo;
|
||||
string formId = dto.TargetFormId.ToString();
|
||||
_logger.LogInformation($"入库单->开始同步金蝶 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 数据: {JsonConvert.SerializeObject(dto)}");
|
||||
|
||||
@@ -65,6 +65,23 @@ namespace WMS.Web.Domain.Services
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
//5.修改物料数据
|
||||
if (mats.Count != 0)
|
||||
{
|
||||
var isBatchManageMatNumbs= mats.Where(x => x.IsBatchManage == true).Select(x=>x.MaterialNumber).ToList();
|
||||
//取:金蝶拉取的已启用批号管理的物料并且本地数据库中的未启用批号管理的物料;来更新批号管理修改为true
|
||||
var updateList= await _materialsRepositories.GetEntityList(isBatchManageMatNumbs,false);
|
||||
if (updateList.Count != 0)
|
||||
{
|
||||
updateList.ForEach(x => { x.IsBatchManage = true; });
|
||||
var isSuccess= await _materialsRepositories.UpdateRange(updateList);
|
||||
if (!isSuccess)
|
||||
_logger.LogInformation("同步金蝶新物料-修改物料:失败");
|
||||
else
|
||||
_logger.LogInformation("同步金蝶新物料-修改物料:成功->" + updateList.Count + "条");
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("同步金蝶新物料:结束->" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->添加数量:" + entitys.Count);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using WMS.Web.Core.Help;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Mappers;
|
||||
using WMS.Web.Repositories.Configuration;
|
||||
|
||||
namespace WMS.Web.Repositories
|
||||
@@ -118,5 +119,46 @@ namespace WMS.Web.Repositories
|
||||
var numbers = await _context.Materials.Select(x => x.MaterialNumber).ToListAsync();
|
||||
return numbers.Clone().Distinct().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部的物料编码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Materials>> GetEntityList(List<string> materNumbers, bool isBatchManage)
|
||||
{
|
||||
var entitys = await _context.Materials.Where(x => materNumbers.Contains(x.MaterialNumber) && x.IsBatchManage == isBatchManage).ToListAsync();
|
||||
return entitys;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改物料
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateRange(List<Materials> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
{
|
||||
try
|
||||
{
|
||||
List<int> list = entitys.Select(s => s.Id).ToList();
|
||||
var res = await _context.Materials.AsNoTracking().Where(f => list.Contains(f.Id)).ToListAsync();
|
||||
_mapper.ToMapList(entitys, res);
|
||||
await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user