调整接口
This commit is contained in:
Binary file not shown.
@@ -29,6 +29,8 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Delete(ProductInventoryType type, bool isTransaction = true);
|
||||
Task<bool> EditEntityList(List<ProductInventory> entitys, bool isTransaction = true);
|
||||
Task<List<ProductInventory>> GetEntityList(ProductInventoryType type);
|
||||
/// <summary>
|
||||
/// 列表-分页
|
||||
/// </summary>
|
||||
|
||||
17
src/WMS.Web.Domain/Mappers/ProductInventoryMapper.cs
Normal file
17
src/WMS.Web.Domain/Mappers/ProductInventoryMapper.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WMS.Web.Core.Dto.Erp;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
|
||||
namespace WMS.Web.Domain.Mappers
|
||||
{
|
||||
public class ProductInventoryMapper : Profile
|
||||
{
|
||||
public ProductInventoryMapper()
|
||||
{
|
||||
CreateMap<ProductInventory, ProductInventory>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,6 +130,9 @@ namespace WMS.Web.Domain.Services
|
||||
.Select(s => s.WarehouseCodeOfJushuitan)
|
||||
.ToList();
|
||||
if (listNames.Count() <= 0) return Result.ReSuccess();
|
||||
//获取原数据
|
||||
var yList = await _repositories.GetEntityList(ProductInventoryType.JushuiTan);
|
||||
|
||||
//获取领星仓库
|
||||
var resStock = await _juShuiTanService.GetStock();
|
||||
if (!resStock.IsSuccess) return resStock;
|
||||
@@ -139,6 +142,8 @@ namespace WMS.Web.Domain.Services
|
||||
var resInventory = await _juShuiTanService.GetInventory(ids);
|
||||
if (!resInventory.IsSuccess) return resStock;
|
||||
|
||||
|
||||
|
||||
//物料
|
||||
var materials_result = await _erpService.BillQueryForMaterial();
|
||||
List<ErpMaterialDto> materials = new List<ErpMaterialDto>();
|
||||
@@ -146,6 +151,7 @@ namespace WMS.Web.Domain.Services
|
||||
materials = materials_result.Data.ToList();
|
||||
|
||||
List<ProductInventory> inventoryList = new List<ProductInventory>();
|
||||
List<ProductInventory> update_List = new List<ProductInventory>();
|
||||
foreach (var item in resInventory.Data)
|
||||
{
|
||||
//如果物料不匹配 过滤
|
||||
@@ -167,6 +173,16 @@ namespace WMS.Web.Domain.Services
|
||||
Qty = item.ky_qty,
|
||||
BeforeQty = item.qty ?? 0
|
||||
};
|
||||
|
||||
var old_Entity = yList.FirstOrDefault(f => f.MaterialNumber.Equals(entity.MaterialNumber) &&
|
||||
f.OrgCode.Equals(entity.OrgCode) && f.StockCode.Equals(entity.StockCode));
|
||||
if (old_Entity != null)
|
||||
{
|
||||
old_Entity.Qty = entity.Qty;
|
||||
old_Entity.BeforeQty = entity.BeforeQty;
|
||||
update_List.Add(old_Entity);
|
||||
}
|
||||
else
|
||||
inventoryList.Add(entity);
|
||||
}
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
@@ -176,7 +192,7 @@ namespace WMS.Web.Domain.Services
|
||||
//先删除之前的再添加
|
||||
if (res_Rollback.IsSuccess)
|
||||
{
|
||||
isSuccess = await _repositories.Delete(ProductInventoryType.LingXing, false);
|
||||
isSuccess = await _repositories.EditEntityList(update_List, false);
|
||||
if (isSuccess == false) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
if (res_Rollback.IsSuccess)
|
||||
|
||||
@@ -19,6 +19,8 @@ using WMS.Web.Core.Dto.OutStockTask;
|
||||
using WMS.Web.Domain.Values.Single;
|
||||
using WMS.Web.Core;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using WMS.Web.Domain.Mappers;
|
||||
using WMS.Web.Core.Help;
|
||||
|
||||
namespace WMS.Web.Repositories
|
||||
{
|
||||
@@ -173,5 +175,50 @@ namespace WMS.Web.Repositories
|
||||
var (list, count, qty) = await GetListAsync(dto, companyId);
|
||||
return (list, count);
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量修改
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditEntityList(List<ProductInventory> 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.ProductInventory
|
||||
.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;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取数据
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ProductInventory>> GetEntityList(ProductInventoryType type)
|
||||
{
|
||||
var res = await _context.ProductInventory
|
||||
.Where(f => f.Type==type)
|
||||
.ToListAsync();
|
||||
|
||||
return res.Clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user