Merge branch 'master' of https://codeup.aliyun.com/62ce7bca487c500c27f70a79/OPS/WMS-Api
This commit is contained in:
@@ -37,10 +37,11 @@ namespace WMS.Web.Api.Controllers
|
|||||||
private readonly IBoxInventoryRepositories _boxInventoryRepositories;
|
private readonly IBoxInventoryRepositories _boxInventoryRepositories;
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||||
|
private readonly IOutStockRepositories _outStockRepositories;
|
||||||
public SysConfigController(ILoginService loginService, IBasicsRepositories basicsRepositories,
|
public SysConfigController(ILoginService loginService, IBasicsRepositories basicsRepositories,
|
||||||
IBoxRepositories boxRepositories, IErpService erpService, ISingleDataService singleDataService,
|
IBoxRepositories boxRepositories, IErpService erpService, ISingleDataService singleDataService,
|
||||||
ISerialNumbersRepositories serialNumbersRepositories, IBoxInventoryRepositories boxInventoryRepositories,
|
ISerialNumbersRepositories serialNumbersRepositories, IBoxInventoryRepositories boxInventoryRepositories,
|
||||||
IMapper mapper, IErpBasicDataExtendService erpBasicDataExtendService)
|
IMapper mapper, IErpBasicDataExtendService erpBasicDataExtendService, IOutStockRepositories outStockRepositories)
|
||||||
{
|
{
|
||||||
_loginService = loginService;
|
_loginService = loginService;
|
||||||
_basicsRepositories = basicsRepositories;
|
_basicsRepositories = basicsRepositories;
|
||||||
@@ -51,6 +52,7 @@ namespace WMS.Web.Api.Controllers
|
|||||||
_boxInventoryRepositories = boxInventoryRepositories;
|
_boxInventoryRepositories = boxInventoryRepositories;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_erpBasicDataExtendService = erpBasicDataExtendService;
|
_erpBasicDataExtendService = erpBasicDataExtendService;
|
||||||
|
_outStockRepositories = outStockRepositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -357,6 +359,26 @@ namespace WMS.Web.Api.Controllers
|
|||||||
return Result<BoxResponse>.ReSuccess(res.First());
|
return Result<BoxResponse>.ReSuccess(res.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据箱号获取箱对应出库单信息 最新一条
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="boxBillNo">必填</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("GetBox_OutStock")]
|
||||||
|
public async Task<Result<BoxResponse>> GetBox_OutStock([FromQuery] string boxBillNo)
|
||||||
|
{
|
||||||
|
var res = await _boxRepositories.GetBox(new List<string>() { boxBillNo });
|
||||||
|
if (res.Count() <= 0)
|
||||||
|
return Result<BoxResponse>.ReFailure("箱号" + boxBillNo + "不存在", 800000);
|
||||||
|
var response = res[0];
|
||||||
|
var detail = await _outStockRepositories.GetDetailsByBoxId(response.Id);
|
||||||
|
response.Details = detail;
|
||||||
|
response.TotalQty = detail.Sum(s => s.Qty);
|
||||||
|
return Result<BoxResponse>.ReSuccess(response);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据序列号或规格型号,物料编码搜索物料信息-PDA
|
/// 根据序列号或规格型号,物料编码搜索物料信息-PDA
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -517,6 +517,13 @@
|
|||||||
<param name="boxBillNo">必填</param>
|
<param name="boxBillNo">必填</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:WMS.Web.Api.Controllers.SysConfigController.GetBox_OutStock(System.String)">
|
||||||
|
<summary>
|
||||||
|
根据箱号获取箱对应出库单信息 最新一条
|
||||||
|
</summary>
|
||||||
|
<param name="boxBillNo">必填</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:WMS.Web.Api.Controllers.SysConfigController.GetMaterial(System.String)">
|
<member name="M:WMS.Web.Api.Controllers.SysConfigController.GetMaterial(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
根据序列号或规格型号,物料编码搜索物料信息-PDA
|
根据序列号或规格型号,物料编码搜索物料信息-PDA
|
||||||
|
|||||||
@@ -2746,6 +2746,9 @@
|
|||||||
<member name="M:WMS.Web.Domain.IService.ISerialNumberService.BackRecord(WMS.Web.Domain.Entitys.BackRecord,WMS.Web.Core.Dto.Login.LoginInDto,System.Boolean)">
|
<member name="M:WMS.Web.Domain.IService.ISerialNumberService.BackRecord(WMS.Web.Domain.Entitys.BackRecord,WMS.Web.Core.Dto.Login.LoginInDto,System.Boolean)">
|
||||||
出入库回退
|
出入库回退
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:WMS.Web.Domain.IService.ISerialNumberService.TakeStock(System.Collections.Generic.List{WMS.Web.Domain.Entitys.TakeStock},WMS.Web.Core.Dto.Login.LoginInDto,System.Boolean)">
|
||||||
|
盘点
|
||||||
|
</member>
|
||||||
<member name="M:WMS.Web.Domain.IService.ISerialNumberService.SerialNumberOperate(System.Collections.Generic.List{WMS.Web.Domain.Entitys.SerialNumberOperate},System.Boolean)">
|
<member name="M:WMS.Web.Domain.IService.ISerialNumberService.SerialNumberOperate(System.Collections.Generic.List{WMS.Web.Domain.Entitys.SerialNumberOperate},System.Boolean)">
|
||||||
<summary>
|
<summary>
|
||||||
序列号操作记录
|
序列号操作记录
|
||||||
@@ -4919,6 +4922,15 @@
|
|||||||
<param name="isTransaction"></param>
|
<param name="isTransaction"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:WMS.Web.Domain.Services.SerialNumberService.TakeStock(System.Collections.Generic.List{WMS.Web.Domain.Entitys.TakeStock},WMS.Web.Core.Dto.Login.LoginInDto,System.Boolean)">
|
||||||
|
<summary>
|
||||||
|
盘点
|
||||||
|
</summary>
|
||||||
|
<param name="takeStocks"></param>
|
||||||
|
<param name="loginInfo"></param>
|
||||||
|
<param name="isTransaction"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="T:WMS.Web.Domain.Services.TakeStockService">
|
<member name="T:WMS.Web.Domain.Services.TakeStockService">
|
||||||
<summary>
|
<summary>
|
||||||
盘点单服务
|
盘点单服务
|
||||||
@@ -5499,6 +5511,11 @@
|
|||||||
出库回退上架
|
出库回退上架
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="F:WMS.Web.Domain.Values.SerialNumberOperateType.TakeStock">
|
||||||
|
<summary>
|
||||||
|
盘点
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:WMS.Web.Domain.Values.ShelfMethod">
|
<member name="T:WMS.Web.Domain.Values.ShelfMethod">
|
||||||
<summary>
|
<summary>
|
||||||
非采购上架方式
|
非采购上架方式
|
||||||
|
|||||||
@@ -95,5 +95,20 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
}
|
}
|
||||||
return Result.ReSuccess();
|
return Result.ReSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//移入
|
||||||
|
public Result TakeStock(int materialId, decimal qty)
|
||||||
|
{
|
||||||
|
var d = this.Details.FirstOrDefault(f => f.MaterialId == materialId);
|
||||||
|
if(d==null)
|
||||||
|
{
|
||||||
|
this.Details.Add(new BoxDetails()
|
||||||
|
{
|
||||||
|
MaterialId = materialId,
|
||||||
|
Qty= qty
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Result.ReSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ namespace WMS.Web.Domain.IService
|
|||||||
Task<Result> InStock(InStock inStock, LoginInDto loginInfo, bool isTransaction = true);
|
Task<Result> InStock(InStock inStock, LoginInDto loginInfo, bool isTransaction = true);
|
||||||
/// 出入库回退
|
/// 出入库回退
|
||||||
Task<Result> BackRecord(BackRecord backRecord, LoginInDto loginInfo, bool isTransaction = true);
|
Task<Result> BackRecord(BackRecord backRecord, LoginInDto loginInfo, bool isTransaction = true);
|
||||||
|
/// 盘点
|
||||||
|
Task<Result> TakeStock(List<TakeStock> takeStocks, LoginInDto loginInfo, bool isTransaction = true);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列号操作记录
|
/// 序列号操作记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using WMS.Web.Core.Dto;
|
||||||
using WMS.Web.Core.Dto.OutStock;
|
using WMS.Web.Core.Dto.OutStock;
|
||||||
using WMS.Web.Domain.Entitys;
|
using WMS.Web.Domain.Entitys;
|
||||||
|
|
||||||
@@ -23,5 +24,7 @@ namespace WMS.Web.Domain.Infrastructure
|
|||||||
Task<bool> EditEntityList(List<OutStock> entitys, bool isTransaction = true);
|
Task<bool> EditEntityList(List<OutStock> entitys, bool isTransaction = true);
|
||||||
//获取详情
|
//获取详情
|
||||||
Task<OutStockInfoResponse> GetInfo(int id);
|
Task<OutStockInfoResponse> GetInfo(int id);
|
||||||
|
//获取出库单明细
|
||||||
|
Task<List<BoxDetailResponse>> GetDetailsByBoxId(int boxId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -431,5 +431,89 @@ namespace WMS.Web.Domain.Services
|
|||||||
|
|
||||||
return Result.ReSuccess();
|
return Result.ReSuccess();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="takeStocks"></param>
|
||||||
|
/// <param name="loginInfo"></param>
|
||||||
|
/// <param name="isTransaction"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<Result> TakeStock(List<TakeStock> takeStocks, LoginInDto loginInfo, bool isTransaction = true)
|
||||||
|
{
|
||||||
|
var serialNumbers = takeStocks.SelectMany(s => s.Details).SelectMany(s => s.SerialNumbers).ToList();
|
||||||
|
var entityList = await _serialNumbersRepositories.GetEntityList(serialNumbers);
|
||||||
|
var boxIds = entityList.Select(s => s.BoxId).ToList();
|
||||||
|
var boxList = await _boxRepositories.GetEntityList(boxIds);
|
||||||
|
|
||||||
|
List<Box> box_New_List = new List<Box>();
|
||||||
|
List<SerialNumberOperate> soList = new List<SerialNumberOperate>();
|
||||||
|
List<SerialNumbers> sList = new List<SerialNumbers>();
|
||||||
|
foreach (var s in serialNumbers)
|
||||||
|
{
|
||||||
|
var takeStockDetail = takeStocks.SelectMany(s => s.Details).FirstOrDefault(w => w.SerialNumbers.Contains(s));
|
||||||
|
if (takeStockDetail == null) continue;
|
||||||
|
var box = boxList.FirstOrDefault(f => f.Id == takeStockDetail.BoxId);
|
||||||
|
var s_entity = entityList.FirstOrDefault(f => f.SerialNumber.Equals(s));
|
||||||
|
if (box != null && box.Details.FirstOrDefault(f => f.MaterialId == takeStockDetail.MaterialId) == null)
|
||||||
|
{
|
||||||
|
//如果这个物料不存在箱箱信息 添加进去
|
||||||
|
box.TakeStock(takeStockDetail.MaterialId, takeStockDetail.AfterQty);
|
||||||
|
box_New_List.Add(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_entity == null)
|
||||||
|
{
|
||||||
|
//序列号
|
||||||
|
SerialNumbers s_new = new SerialNumbers(s, takeStockDetail.MaterialId, takeStockDetail.Id, 0, "", DateTime.Now, DateTime.Now);
|
||||||
|
sList.Add(s_new);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (s_entity.BoxId == takeStockDetail.BoxId) continue;
|
||||||
|
s_entity.BoxId = takeStockDetail.BoxId;
|
||||||
|
|
||||||
|
var takeStock = takeStocks.FirstOrDefault(w => w.Details.FirstOrDefault(w => w.SerialNumbers.Contains(s)) != null);
|
||||||
|
//记录序列号操作日志
|
||||||
|
SerialNumberOperate op = new SerialNumberOperate()
|
||||||
|
{
|
||||||
|
MaterialId = takeStockDetail.MaterialId,
|
||||||
|
SerialNumber = s,
|
||||||
|
OrgId = box.OrgId,
|
||||||
|
SupplierId = box.SupplierId,
|
||||||
|
OperateTime = DateTime.Now,
|
||||||
|
OperateType = SerialNumberOperateType.TakeStock,
|
||||||
|
OperateUser = "",
|
||||||
|
Remark = "单号:" + takeStock.BillNo + "\r\n" + "箱号:" + box.BoxBillNo
|
||||||
|
};
|
||||||
|
soList.Add(op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IDbContextTransaction _transaction = null;
|
||||||
|
if (isTransaction)
|
||||||
|
_transaction = _transactionRepositories.GetTransaction();
|
||||||
|
bool isRollback = false;
|
||||||
|
bool isSuccess = true;
|
||||||
|
isSuccess = await _serialNumbersRepositories.EditEntityList(entityList, false);
|
||||||
|
if (isSuccess)
|
||||||
|
isSuccess = await _serialNumbersRepositories.AddRange(sList, false);
|
||||||
|
if (isSuccess)
|
||||||
|
isSuccess = await _boxRepositories.EditEntityList(box_New_List,false);
|
||||||
|
|
||||||
|
//序列号操作记录
|
||||||
|
var res = await this.SerialNumberOperate(soList, false);
|
||||||
|
//提交事务
|
||||||
|
if (isTransaction)
|
||||||
|
{
|
||||||
|
if (!isSuccess) isRollback = true;
|
||||||
|
if (!res.Success) isRollback = true;
|
||||||
|
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||||
|
if (!isSuccess)
|
||||||
|
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||||
|
}
|
||||||
|
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||||
|
if (!res.Success) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||||
|
return Result.ReSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ namespace WMS.Web.Domain.Services
|
|||||||
private readonly ILogger<TakeStockService> _logger;
|
private readonly ILogger<TakeStockService> _logger;
|
||||||
private readonly IBoxInventoryService _boxInventoryService;
|
private readonly IBoxInventoryService _boxInventoryService;
|
||||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||||
|
private readonly ISerialNumberService _serialNumberService;
|
||||||
public TakeStockService(IMapper mapper, ILoginService loginService,
|
public TakeStockService(IMapper mapper, ILoginService loginService,
|
||||||
IBasicsRepositories transactionRepositories,
|
IBasicsRepositories transactionRepositories,
|
||||||
ITakeStockRepositories takeStockRepositories, ILoginRepositories loginRepositories,
|
ITakeStockRepositories takeStockRepositories, ILoginRepositories loginRepositories,
|
||||||
ISingleDataService singleDataService, IErpService erpService, ILogger<TakeStockService> logger,
|
ISingleDataService singleDataService, IErpService erpService, ILogger<TakeStockService> logger,
|
||||||
IBoxInventoryService boxInventoryService, IErpBasicDataExtendService erpBasicDataExtendService)
|
IBoxInventoryService boxInventoryService, IErpBasicDataExtendService erpBasicDataExtendService,
|
||||||
|
ISerialNumberService serialNumberService)
|
||||||
{
|
{
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_loginService = loginService;
|
_loginService = loginService;
|
||||||
@@ -55,6 +57,7 @@ namespace WMS.Web.Domain.Services
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_boxInventoryService = boxInventoryService;
|
_boxInventoryService = boxInventoryService;
|
||||||
_erpBasicDataExtendService = erpBasicDataExtendService;
|
_erpBasicDataExtendService = erpBasicDataExtendService;
|
||||||
|
_serialNumberService = serialNumberService;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存
|
/// 保存
|
||||||
@@ -114,6 +117,11 @@ namespace WMS.Web.Domain.Services
|
|||||||
if (!isSuccess) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
|
if (!isSuccess) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
|
||||||
}
|
}
|
||||||
if (res_Rollback.IsSuccess)
|
if (res_Rollback.IsSuccess)
|
||||||
|
{
|
||||||
|
var res_change = await _serialNumberService.TakeStock(list, loginInfo, false);
|
||||||
|
if (!res_change.IsSuccess) res_Rollback = res_change;
|
||||||
|
}
|
||||||
|
if (res_Rollback.IsSuccess)
|
||||||
{
|
{
|
||||||
var res_Inventory = await _boxInventoryService.GenerateTakeBox(list, false);
|
var res_Inventory = await _boxInventoryService.GenerateTakeBox(list, false);
|
||||||
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ namespace WMS.Web.Domain.Values
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[EnumRemark("出库回退上架")]
|
[EnumRemark("出库回退上架")]
|
||||||
BackRecord_On = 16,
|
BackRecord_On = 16,
|
||||||
|
/// <summary>
|
||||||
|
/// 盘点
|
||||||
|
/// </summary>
|
||||||
|
[EnumRemark("盘点")]
|
||||||
|
TakeStock = 17,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WMS.Web.Core;
|
using WMS.Web.Core;
|
||||||
|
using WMS.Web.Core.Dto;
|
||||||
using WMS.Web.Core.Dto.Erp;
|
using WMS.Web.Core.Dto.Erp;
|
||||||
using WMS.Web.Core.Dto.OutStock;
|
using WMS.Web.Core.Dto.OutStock;
|
||||||
using WMS.Web.Core.Help;
|
using WMS.Web.Core.Help;
|
||||||
@@ -320,5 +321,36 @@ namespace WMS.Web.Repositories
|
|||||||
{
|
{
|
||||||
return await GetListAsync(dto);
|
return await GetListAsync(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<BoxDetailResponse>> GetDetailsByBoxId(int boxId)
|
||||||
|
{
|
||||||
|
var res = await _context.OutStock
|
||||||
|
.Include(s => s.Details).ThenInclude(s => s.ErpDetails)
|
||||||
|
.Include(s => s.Details).ThenInclude(s => s.BoxsDetails.Where(w => w.BoxId == boxId))
|
||||||
|
.Where(f => f.Details.SelectMany(s => s.BoxsDetails).Where(w => w.BoxId == boxId).Any())
|
||||||
|
.OrderByDescending(o => o.Id)
|
||||||
|
.FirstAsync();
|
||||||
|
List<BoxDetailResponse> details = new List<BoxDetailResponse>();
|
||||||
|
|
||||||
|
var materials_result = await _erpService.BillQueryForMaterial();
|
||||||
|
if (!materials_result.IsSuccess)
|
||||||
|
return new List<BoxDetailResponse>();
|
||||||
|
var materials = materials_result.Data.ToList();
|
||||||
|
|
||||||
|
foreach (var d in res.Details)
|
||||||
|
{
|
||||||
|
var boxDetail = d.BoxsDetails.FirstOrDefault(f => f.BoxId == boxId);
|
||||||
|
if (boxDetail == null) continue;
|
||||||
|
BoxDetailResponse detail = new BoxDetailResponse();
|
||||||
|
detail.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, d.MaterialId);
|
||||||
|
detail.MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, d.MaterialId);
|
||||||
|
detail.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, d.MaterialId);
|
||||||
|
detail.SerialNumbers = d.SerialNumbers;
|
||||||
|
detail.MaterialId = d.MaterialId;
|
||||||
|
detail.Qty = boxDetail.Qty;
|
||||||
|
details.Add(detail);
|
||||||
|
}
|
||||||
|
return details;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user