优化
This commit is contained in:
@@ -2135,6 +2135,21 @@
|
||||
采购上架-请求对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.PurchaseShelfRequest.OrgCode">
|
||||
<summary>
|
||||
组织编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.PurchaseShelfRequest.StockCode">
|
||||
<summary>
|
||||
仓库编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.PurchaseShelfRequest.SubStockId">
|
||||
<summary>
|
||||
仓位ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.PurchaseShelfRequest.Details">
|
||||
<summary>
|
||||
明细
|
||||
@@ -2165,26 +2180,6 @@
|
||||
供应商
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockDetailsRequest.OrgId">
|
||||
<summary>
|
||||
组织
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockDetailsRequest.OrgCode">
|
||||
<summary>
|
||||
组织编码:仓位-仓库-带出
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockDetailsRequest.StockCode">
|
||||
<summary>
|
||||
仓库编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockDetailsRequest.SubStockId">
|
||||
<summary>
|
||||
仓位ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockDetailsRequest.ErpDetailId">
|
||||
<summary>
|
||||
对应金蝶的明细ID
|
||||
|
||||
@@ -521,6 +521,26 @@
|
||||
备注
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStock.OrgId">
|
||||
<summary>
|
||||
组织ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStock.OrgCode">
|
||||
<summary>
|
||||
组织编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStock.StockCode">
|
||||
<summary>
|
||||
仓库编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStock.SubStockId">
|
||||
<summary>
|
||||
仓位ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStock.Details">
|
||||
<summary>
|
||||
明细
|
||||
@@ -585,31 +605,11 @@
|
||||
供应商ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockDetails.OrgId">
|
||||
<summary>
|
||||
组织ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockDetails.OrgCode">
|
||||
<summary>
|
||||
组织编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockDetails.MaterialId">
|
||||
<summary>
|
||||
物料ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockDetails.StockCode">
|
||||
<summary>
|
||||
仓库编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockDetails.SubStockId">
|
||||
<summary>
|
||||
仓位ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockDetails.Qty">
|
||||
<summary>
|
||||
数量
|
||||
@@ -863,6 +863,51 @@
|
||||
明细备注
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InStockTotalDetails">
|
||||
<summary>
|
||||
wms入库单-汇总明细
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTotalDetails.Id">
|
||||
<summary>
|
||||
ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTotalDetails.InStockId">
|
||||
<summary>
|
||||
入库单ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTotalDetails.TaskId">
|
||||
<summary>
|
||||
任务单ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTotalDetails.SourceBillNo">
|
||||
<summary>
|
||||
来源单号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTotalDetails.SupplierId">
|
||||
<summary>
|
||||
供应商ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTotalDetails.MaterialId">
|
||||
<summary>
|
||||
物料ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTotalDetails.Qty">
|
||||
<summary>
|
||||
数量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTotalDetails.SerialNumbers">
|
||||
<summary>
|
||||
序列号集
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InventoryDetails">
|
||||
<summary>
|
||||
wms即时库存明细表
|
||||
@@ -1974,6 +2019,14 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockRepositories.AddRangeTotalDetails(System.Collections.Generic.List{WMS.Web.Domain.Entitys.InStockTotalDetails},System.Boolean)">
|
||||
<summary>
|
||||
批量添加:入库汇总明细
|
||||
</summary>
|
||||
<param name="entitys"></param>
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories">
|
||||
<summary>
|
||||
箱与任务单绑定(收货)关系表-仓储接口
|
||||
@@ -2324,7 +2377,7 @@
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.IBoxInventoryService.GenerateInStockBox(System.Collections.Generic.List{WMS.Web.Domain.Entitys.InStock},System.Boolean)">
|
||||
<member name="M:WMS.Web.Domain.IService.IBoxInventoryService.GenerateInStockBox(WMS.Web.Domain.Entitys.InStock,System.Boolean)">
|
||||
<summary>
|
||||
入库单-箱库存的变更
|
||||
</summary>
|
||||
@@ -2672,6 +2725,13 @@
|
||||
<param name="orgCode"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.Public.IErpBasicDataExtendService.GetOrgId(System.Collections.Generic.List{WMS.Web.Core.Dto.Erp.Org.ErpOrgDto},System.String)">
|
||||
<summary>
|
||||
获取组织ID
|
||||
</summary>
|
||||
<param name="erpOrgs"></param>
|
||||
<param name="orgCode"></param>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.Public.IErpBasicDataExtendService.GetSupplierName(System.Collections.Generic.List{WMS.Web.Core.Dto.Erp.Supplier.ErpSupplierDto},System.Int32)">
|
||||
<summary>
|
||||
获取供应商名称
|
||||
@@ -3449,7 +3509,7 @@
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.BoxInventoryService.GenerateInStockBox(System.Collections.Generic.List{WMS.Web.Domain.Entitys.InStock},System.Boolean)">
|
||||
<member name="M:WMS.Web.Domain.Services.BoxInventoryService.GenerateInStockBox(WMS.Web.Domain.Entitys.InStock,System.Boolean)">
|
||||
<summary>
|
||||
入库单-箱库存的变更
|
||||
</summary>
|
||||
@@ -4008,6 +4068,14 @@
|
||||
<param name="orgCode"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.Public.ErpBasicDataExtendService.GetOrgId(System.Collections.Generic.List{WMS.Web.Core.Dto.Erp.Org.ErpOrgDto},System.String)">
|
||||
<summary>
|
||||
获取组织id
|
||||
</summary>
|
||||
<param name="erpOrgs"></param>
|
||||
<param name="orgCode"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.Public.ErpBasicDataExtendService.GetSupplierName(System.Collections.Generic.List{WMS.Web.Core.Dto.Erp.Supplier.ErpSupplierDto},System.Int32)">
|
||||
<summary>
|
||||
获取供应商名称
|
||||
|
||||
@@ -10,7 +10,18 @@ namespace WMS.Web.Core.Dto.InStock
|
||||
/// </summary>
|
||||
public class PurchaseShelfRequest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 组织编码
|
||||
/// </summary>
|
||||
public string OrgCode { get; set; }
|
||||
/// <summary>
|
||||
/// 仓库编码
|
||||
/// </summary>
|
||||
public string StockCode { get; set; }
|
||||
/// <summary>
|
||||
/// 仓位ID
|
||||
/// </summary>
|
||||
public int SubStockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
|
||||
@@ -33,28 +33,28 @@ namespace WMS.Web.Core.Dto.InStock
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "供应商不能为空")]
|
||||
public int SupplierId { get; set; }
|
||||
/// <summary>
|
||||
/// 组织
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "组织不能为空")]
|
||||
public int OrgId { get; set; }
|
||||
///// <summary>
|
||||
///// 组织
|
||||
///// </summary>
|
||||
//[Required(ErrorMessage = "组织不能为空")]
|
||||
//public int OrgId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组织编码:仓位-仓库-带出
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "组织不能为空")]
|
||||
public string OrgCode { get; set; }
|
||||
///// <summary>
|
||||
///// 组织编码:仓位-仓库-带出
|
||||
///// </summary>
|
||||
//[Required(ErrorMessage = "组织不能为空")]
|
||||
//public string OrgCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓库编码
|
||||
///</summary>
|
||||
[Required(ErrorMessage = "仓库不能为空")]
|
||||
public string StockCode { get; set; }
|
||||
/// <summary>
|
||||
/// 仓位ID
|
||||
///</summary>
|
||||
[Required(ErrorMessage = " 仓位不能为空")]
|
||||
public int SubStockId { get; set; }
|
||||
///// <summary>
|
||||
///// 仓库编码
|
||||
/////</summary>
|
||||
//[Required(ErrorMessage = "仓库不能为空")]
|
||||
//public string StockCode { get; set; }
|
||||
///// <summary>
|
||||
///// 仓位ID
|
||||
/////</summary>
|
||||
//[Required(ErrorMessage = " 仓位不能为空")]
|
||||
//public int SubStockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对应金蝶的明细ID
|
||||
|
||||
@@ -57,8 +57,22 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 组织ID
|
||||
/// </summary>
|
||||
public int OrgId { get; set; }
|
||||
/// <summary>
|
||||
/// 组织编码
|
||||
/// </summary>
|
||||
public string OrgCode { get; set; }
|
||||
/// <summary>
|
||||
/// 仓库编码
|
||||
/// </summary>
|
||||
public string StockCode { get; set; }
|
||||
/// <summary>
|
||||
/// 仓位ID
|
||||
/// </summary>
|
||||
public int SubStockId { get; set; }
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
|
||||
@@ -43,26 +43,26 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 供应商ID
|
||||
/// </summary>
|
||||
public int SupplierId { get; set; }
|
||||
/// <summary>
|
||||
/// 组织ID
|
||||
/// </summary>
|
||||
public int OrgId { get; set; }
|
||||
/// <summary>
|
||||
/// 组织编码
|
||||
/// </summary>
|
||||
public string OrgCode { get; set; }
|
||||
///// <summary>
|
||||
///// 组织ID
|
||||
///// </summary>
|
||||
//public int OrgId { get; set; }
|
||||
///// <summary>
|
||||
///// 组织编码
|
||||
///// </summary>
|
||||
//public string OrgCode { get; set; }
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public int MaterialId { get; set; }
|
||||
/// <summary>
|
||||
/// 仓库编码
|
||||
/// </summary>
|
||||
public string StockCode { get; set; }
|
||||
/// <summary>
|
||||
/// 仓位ID
|
||||
/// </summary>
|
||||
public int SubStockId { get; set; }
|
||||
///// <summary>
|
||||
///// 仓库编码
|
||||
///// </summary>
|
||||
//public string StockCode { get; set; }
|
||||
///// <summary>
|
||||
///// 仓位ID
|
||||
///// </summary>
|
||||
//public int SubStockId { get; set; }
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
|
||||
53
src/WMS.Web.Domain/Entitys/InStockTotalDetails.cs
Normal file
53
src/WMS.Web.Domain/Entitys/InStockTotalDetails.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// wms入库单-汇总明细
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_wms_instock_total_details")]
|
||||
public class InStockTotalDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 入库单ID
|
||||
/// </summary>
|
||||
public int InStockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务单ID
|
||||
/// </summary>
|
||||
public int TaskId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单号
|
||||
/// </summary>
|
||||
public string SourceBillNo { get; set; }
|
||||
/// <summary>
|
||||
/// 供应商ID
|
||||
/// </summary>
|
||||
public int SupplierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public int MaterialId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public decimal Qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序列号集
|
||||
/// </summary>
|
||||
public List<string> SerialNumbers { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace WMS.Web.Domain.IService
|
||||
/// <param name="dtoDatas"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> GenerateInStockBox(List<InStock> dtoDatas, bool isTransaction);
|
||||
Task<Result> GenerateInStockBox(InStock dtoDatas, bool isTransaction);
|
||||
|
||||
/// <summary>
|
||||
/// 出库单-箱库存的变更
|
||||
|
||||
@@ -73,6 +73,13 @@ namespace WMS.Web.Domain.IService.Public
|
||||
/// <returns></returns>
|
||||
string GetOrgName(List<ErpOrgDto> erpOrgs, string orgCode);
|
||||
|
||||
/// <summary>
|
||||
/// 获取组织ID
|
||||
/// </summary>
|
||||
/// <param name="erpOrgs"></param>
|
||||
/// <param name="orgCode"></param>
|
||||
int GetOrgId(List<ErpOrgDto> erpOrgs, string orgCode);
|
||||
|
||||
/// <summary>
|
||||
/// 获取供应商名称
|
||||
/// </summary>
|
||||
|
||||
@@ -42,5 +42,13 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<InStockInfoResponse> GetInfo(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加:入库汇总明细
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddRangeTotalDetails(List<InStockTotalDetails> entitys, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace WMS.Web.Domain.Mappers
|
||||
|
||||
CreateMap<SaveInStockDetailsRequest, InStockDetails>().ReverseMap();
|
||||
CreateMap<NoPurchaseShelfDetailsRequest, InStockDetails>().ReverseMap();
|
||||
CreateMap<SaveInStockDetailsRequest, InStockTotalDetails>();
|
||||
CreateMap<NoPurchaseShelfDetailsRequest, InStockTotalDetails>();
|
||||
CreateMap<NoPurchaseShelfDetailsRequest, BoxInventoryGenerateDetailsDto>();
|
||||
|
||||
|
||||
|
||||
@@ -440,33 +440,31 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="dtoDatas"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> GenerateInStockBox(List<InStock> dtoDatas, bool isTransaction)
|
||||
public async Task<Result> GenerateInStockBox(InStock dtoData, bool isTransaction)
|
||||
{
|
||||
//1.判断来源数据是否存在
|
||||
if (dtoDatas == null || dtoDatas.Count == 0)
|
||||
if (dtoData == null)
|
||||
return Result.ReFailure(ResultCodes.InventoryNoSourceError);
|
||||
|
||||
//物料收发明细dtos
|
||||
var InventoryInOutDetailsGenerateDtoList = new List<InventoryInOutDetailsGenerateDto>();
|
||||
|
||||
#region 按箱
|
||||
//2.组装-按箱入库
|
||||
var dtoDatas_details_Method_box = dtoDatas.Where(x => x.Method == InventoryInOutMethod.Box).SelectMany(x => x.Details).ToList();
|
||||
var generateDtoList_Metod_Box = dtoDatas_details_Method_box.GroupBy(x => new { x.BoxId, x.OrgCode, x.StockCode, x.SubStockId })
|
||||
//2.组装-按箱和按产品入库
|
||||
var generateDtoList = dtoData.Details.GroupBy(x => new { x.BoxId })
|
||||
.Select(x => new BoxInventoryGenerateDto()
|
||||
{
|
||||
BoxId = x.Key.BoxId,
|
||||
OrgCode = x.Key.OrgCode,
|
||||
StockCode = x.Key.StockCode,
|
||||
SubStockId = x.Key.SubStockId,
|
||||
InventoryInOutMethod = (int)InventoryInOutMethod.Box,
|
||||
OrgCode = dtoData.OrgCode,
|
||||
StockCode = dtoData.StockCode,
|
||||
SubStockId = dtoData.SubStockId,
|
||||
InventoryInOutMethod = (int)dtoData.Method,
|
||||
InventoryInOutType = (int)InventoryInOutType.In
|
||||
}).ToList();
|
||||
|
||||
//2.1.遍历:组装明细
|
||||
generateDtoList_Metod_Box.ForEach(x =>
|
||||
generateDtoList.ForEach(x =>
|
||||
{
|
||||
foreach (var detItem in dtoDatas_details_Method_box)
|
||||
foreach (var detItem in dtoData.Details)
|
||||
{
|
||||
//2.1箱是当前的
|
||||
if (detItem.BoxId == x.BoxId)
|
||||
@@ -480,63 +478,21 @@ namespace WMS.Web.Domain.Services
|
||||
}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
|
||||
#region 按产品
|
||||
//3.组装-按产品入库
|
||||
var dtoDatas_details_Method_Product = dtoDatas.Where(x => x.Method == InventoryInOutMethod.Product).SelectMany(x => x.Details).ToList();
|
||||
var generateDtoList_Metod_Product = dtoDatas_details_Method_Product.GroupBy(x => new { x.BoxId, x.OrgCode, x.StockCode, x.SubStockId })
|
||||
.Select(x => new BoxInventoryGenerateDto()
|
||||
{
|
||||
BoxId = x.Key.BoxId,
|
||||
OrgCode = x.Key.OrgCode,
|
||||
StockCode = x.Key.StockCode,
|
||||
SubStockId = x.Key.SubStockId,
|
||||
InventoryInOutMethod = (int)InventoryInOutMethod.Product,
|
||||
InventoryInOutType = (int)InventoryInOutType.In
|
||||
}).ToList();
|
||||
|
||||
//3.1.遍历:组装明细
|
||||
generateDtoList_Metod_Product.ForEach(x =>
|
||||
{
|
||||
foreach (var detItem in dtoDatas_details_Method_Product)
|
||||
{
|
||||
//3.1箱是当前的
|
||||
if (detItem.BoxId == x.BoxId)
|
||||
{
|
||||
//3.2组装明细
|
||||
var det = new BoxInventoryGenerateDetailsDto();
|
||||
det.MaterialId = detItem.MaterialId;
|
||||
det.Qty = detItem.Qty;
|
||||
det.SerialNumbers = detItem.SerialNumbers;
|
||||
x.Details.Add(det);
|
||||
}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
|
||||
//整合一起
|
||||
var generateDtoList = new List<BoxInventoryGenerateDto>();
|
||||
generateDtoList.AddRange(generateDtoList_Metod_Box);
|
||||
generateDtoList.AddRange(generateDtoList_Metod_Product);
|
||||
//提交处理
|
||||
var result = await this.ExeInStockBox(generateDtoList, isTransaction);
|
||||
if (!result.IsSuccess)
|
||||
return result;
|
||||
|
||||
//5.组装物料收发明细dto
|
||||
foreach (var item in dtoDatas.SelectMany(x => x.Details).ToList())
|
||||
foreach (var item in dtoData.Details)
|
||||
{
|
||||
var entity = dtoDatas.Where(x => x.Id == item.Fid).FirstOrDefault();
|
||||
if (entity != null)
|
||||
{
|
||||
var inventoryInOutDet = _inventoryInOutDetailsService.GenerateDto(
|
||||
item.BoxId, item.MaterialId,
|
||||
item.OrgCode, item.StockCode,
|
||||
item.SubStockId, InStockTypeConvert(entity.Type),
|
||||
item.SourceBillNo, item.Qty, InventoryInOutType.In);
|
||||
InventoryInOutDetailsGenerateDtoList.Add(inventoryInOutDet);
|
||||
}
|
||||
var inventoryInOutDet = _inventoryInOutDetailsService.GenerateDto(
|
||||
item.BoxId, item.MaterialId,
|
||||
dtoData.OrgCode, dtoData.StockCode,
|
||||
dtoData.SubStockId, InStockTypeConvert(dtoData.Type),
|
||||
item.SourceBillNo, item.Qty, InventoryInOutType.In);
|
||||
InventoryInOutDetailsGenerateDtoList.Add(inventoryInOutDet);
|
||||
|
||||
}
|
||||
//5.提交物料收发明细:新增
|
||||
if (InventoryInOutDetailsGenerateDtoList.Count != 0)
|
||||
@@ -565,16 +521,16 @@ namespace WMS.Web.Domain.Services
|
||||
var InventoryInOutDetailsGenerateDtoList = new List<InventoryInOutDetailsGenerateDto>();
|
||||
|
||||
//找出所有的箱库存
|
||||
var boxIds = dtoData.Details.SelectMany(x => x.BoxsDetails).GroupBy(x=>x.BoxId).Select(x => x.Key).ToList();
|
||||
var boxIds = dtoData.Details.SelectMany(x => x.BoxsDetails).GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
|
||||
var boxInventorys = await _boxInventoryRepositories.GetList(boxIds);
|
||||
//判断箱库存是否存在
|
||||
foreach (var bid in boxIds)
|
||||
{
|
||||
var isHaveBoxInvetory= boxInventorys.Where(x => x.BoxId == bid).Any();
|
||||
var isHaveBoxInvetory = boxInventorys.Where(x => x.BoxId == bid).Any();
|
||||
if (!isHaveBoxInvetory)
|
||||
return Result.ReFailure(ResultCodes.BoxInventoryNoDataError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//2.组装
|
||||
var generateDtoList = dtoData.Details.SelectMany(x => x.BoxsDetails).GroupBy(x => new { x.BoxId })
|
||||
@@ -590,7 +546,7 @@ namespace WMS.Web.Domain.Services
|
||||
{
|
||||
//从箱库存找到:组织、仓库、仓位、进行赋值;
|
||||
var current_box_invetory = boxInventorys.Where(t => t.BoxId == x.BoxId).FirstOrDefault();
|
||||
if (current_box_invetory != null && current_box_invetory.BoxId==x.BoxId)
|
||||
if (current_box_invetory != null && current_box_invetory.BoxId == x.BoxId)
|
||||
{
|
||||
x.OrgCode = current_box_invetory.OrgCode;
|
||||
x.StockCode = current_box_invetory.StockCode;
|
||||
@@ -1439,7 +1395,7 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="boxInventorys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Result> ExeOutStockBox(List<BoxInventoryGenerateDto> dtoDatas,List<BoxInventory> boxInventorys, bool isTransaction)
|
||||
private async Task<Result> ExeOutStockBox(List<BoxInventoryGenerateDto> dtoDatas, List<BoxInventory> boxInventorys, bool isTransaction)
|
||||
{
|
||||
//1.判断来源数据是否存在
|
||||
if (dtoDatas == null || dtoDatas.Count == 0)
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.ChangeBoxRecord;
|
||||
using WMS.Web.Core.Dto.Erp;
|
||||
using WMS.Web.Core.Dto.Erp.Org;
|
||||
using WMS.Web.Core.Dto.InStock;
|
||||
using WMS.Web.Core.Dto.InStockTask;
|
||||
using WMS.Web.Core.Dto.Inventory;
|
||||
@@ -217,8 +218,19 @@ namespace WMS.Web.Domain.Services
|
||||
/// <returns></returns>
|
||||
private async Task<Result> ShelfSave(PurchaseShelfRequest dto, InstockType type, LoginInDto loginInfo, bool isTransaction = true)
|
||||
{
|
||||
// 组织集合
|
||||
var orgs = new List<ErpOrgDto>();
|
||||
var orgs_result = await _erpService.BillQueryForOrg();
|
||||
if (orgs_result.IsSuccess)
|
||||
orgs = orgs_result.Data.ToList();
|
||||
var currentOrg= orgs.Where(x => x.Number == dto.OrgCode).FirstOrDefault();
|
||||
|
||||
var entity = new InStock();
|
||||
entity.Type = type;
|
||||
entity.OrgId = currentOrg == null ? 0 : currentOrg.Id;
|
||||
entity.StockCode = dto.StockCode;
|
||||
entity.OrgCode = dto.OrgCode;
|
||||
entity.SubStockId = dto.SubStockId;
|
||||
entity.Method = InventoryInOutMethod.Box;
|
||||
entity.Details = _mapper.Map<List<InStockDetails>>(dto.Details);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
@@ -242,6 +254,22 @@ namespace WMS.Web.Domain.Services
|
||||
if (entity == null)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
//处理添加入库汇总明细
|
||||
var totalDetails = dto.Details.GroupBy(x => new { x.TaskId, x.SourceBillNo, x.SupplierId, x.MaterialId })
|
||||
.Select(x => new InStockTotalDetails
|
||||
{
|
||||
InStockId= entity.Id,
|
||||
TaskId=x.Key.TaskId,
|
||||
SourceBillNo=x.Key.SourceBillNo,
|
||||
SupplierId=x.Key.SupplierId,
|
||||
MaterialId=x.Key.MaterialId,
|
||||
Qty=x.Sum(t=>t.Qty),
|
||||
SerialNumbers= x.SelectMany(t=>t.SerialNumbers).ToList()
|
||||
}).ToList();
|
||||
|
||||
var isSuccess= await _inStockRepositories.AddRangeTotalDetails(totalDetails, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
//同步金蝶后,反写任务单的已交数量
|
||||
var taskIds = dto.Details.GroupBy(x => x.TaskId).Select(x => x.Key).ToList();
|
||||
var tasks = await _inStockTaskRepositories.GetList(taskIds);
|
||||
@@ -262,7 +290,7 @@ namespace WMS.Web.Domain.Services
|
||||
task.Shelf(loginInfo.UserInfo.StaffId);
|
||||
}
|
||||
|
||||
var isSuccess = await _inStockTaskRepositories.UpdateRange(tasks, isTransaction);
|
||||
isSuccess = await _inStockTaskRepositories.UpdateRange(tasks, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
@@ -273,9 +301,7 @@ namespace WMS.Web.Domain.Services
|
||||
return serialNumber_result;
|
||||
|
||||
//箱库存变动
|
||||
var dtoDatas = new List<InStock>();
|
||||
dtoDatas.Add(entity);
|
||||
var boxInventoryResult = await _boxInventoryService.GenerateInStockBox(dtoDatas, isTransaction);
|
||||
var boxInventoryResult = await _boxInventoryService.GenerateInStockBox(entity, isTransaction);
|
||||
if (!boxInventoryResult.IsSuccess)
|
||||
return boxInventoryResult;
|
||||
|
||||
@@ -306,6 +332,10 @@ namespace WMS.Web.Domain.Services
|
||||
//2.生成:入库单
|
||||
var entity = new InStock();
|
||||
entity.Type = task.Type;
|
||||
entity.OrgId = task.Details.Select(x => x.OrgId).FirstOrDefault();
|
||||
entity.StockCode = dto.StockCode;
|
||||
entity.OrgCode = dto.OrgCode;
|
||||
entity.SubStockId = dto.SubStockId;
|
||||
entity.Method = dto.ShelfMethod == (int)ShelfMethod.Box ? InventoryInOutMethod.Box : InventoryInOutMethod.Product;
|
||||
entity.Details = new List<InStockDetails>();
|
||||
|
||||
@@ -321,10 +351,10 @@ namespace WMS.Web.Domain.Services
|
||||
item.TaskId = dto.TaskId;
|
||||
item.SourceBillNo = task.SourceBillNo;
|
||||
item.BoxId = box.BoxId;
|
||||
item.SubStockId = dto.SubStockId;
|
||||
item.StockCode = dto.StockCode;
|
||||
item.OrgCode = dto.OrgCode;
|
||||
item.OrgId = task.Details.Select(x => x.OrgId).FirstOrDefault();
|
||||
//item.SubStockId = dto.SubStockId;
|
||||
//item.StockCode = dto.StockCode;
|
||||
//item.OrgCode = dto.OrgCode;
|
||||
//item.OrgId = task.Details.Select(x => x.OrgId).FirstOrDefault();
|
||||
});
|
||||
//3.3添加到临时集合中
|
||||
temps.AddRange(dets);
|
||||
@@ -356,6 +386,22 @@ namespace WMS.Web.Domain.Services
|
||||
if (entity == null)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
//处理添加入库汇总明细
|
||||
var totalDetails = dto.Boxs.SelectMany(x=>x.Details).GroupBy(x => new { x.MaterialId })
|
||||
.Select(x => new InStockTotalDetails
|
||||
{
|
||||
InStockId = entity.Id,
|
||||
TaskId =dto.TaskId,
|
||||
SourceBillNo = task.SourceBillNo,
|
||||
MaterialId = x.Key.MaterialId,
|
||||
Qty = x.Sum(t => t.Qty),
|
||||
SerialNumbers = x.SelectMany(t => t.SerialNumbers).ToList()
|
||||
}).ToList();
|
||||
|
||||
var isSuccess = await _inStockRepositories.AddRangeTotalDetails(totalDetails, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
//同步金蝶后,反写任务单的已交数量
|
||||
if (task != null)
|
||||
{
|
||||
@@ -422,9 +468,7 @@ namespace WMS.Web.Domain.Services
|
||||
return serialNumber_result;
|
||||
|
||||
//箱库存变动
|
||||
var dtoDatas = new List<InStock>();
|
||||
dtoDatas.Add(entity);
|
||||
var boxInventoryResult = await _boxInventoryService.GenerateInStockBox(dtoDatas, isTransaction);
|
||||
var boxInventoryResult = await _boxInventoryService.GenerateInStockBox(entity, isTransaction);
|
||||
if (!boxInventoryResult.IsSuccess)
|
||||
return boxInventoryResult;
|
||||
|
||||
|
||||
@@ -168,6 +168,18 @@ namespace WMS.Web.Domain.Services.Public
|
||||
return org == null ? "" : org.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组织id
|
||||
/// </summary>
|
||||
/// <param name="erpOrgs"></param>
|
||||
/// <param name="orgCode"></param>
|
||||
/// <returns></returns>
|
||||
public int GetOrgId(List<ErpOrgDto> erpOrgs, string orgCode)
|
||||
{
|
||||
var org = erpOrgs.Where(x => x.Number == orgCode).FirstOrDefault();
|
||||
return org == null ? 0 : org.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取供应商名称
|
||||
/// </summary>
|
||||
|
||||
@@ -321,7 +321,7 @@ namespace WMS.Web.Domain.Services
|
||||
{
|
||||
var box = boxList.FirstOrDefault(f => f.Id == entity.BoxId);
|
||||
var instockDetail = inStock.Details.FirstOrDefault(f => f.MaterialId == entity.MaterialId);
|
||||
var subStock = _singleDataService.GetSingleData(SingleAction.SubStocks, loginInfo.UserInfo.CompanyId, instockDetail.SubStockId);
|
||||
var subStock = _singleDataService.GetSingleData(SingleAction.SubStocks, loginInfo.UserInfo.CompanyId, inStock.SubStockId);
|
||||
//修改序列号和箱绑定关系
|
||||
entity.InStock(instockDetail.SourceBillNo, inStock.Type);
|
||||
|
||||
|
||||
@@ -200,6 +200,18 @@ namespace WMS.Web.Repositories.Configuration
|
||||
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
|
||||
c => (List<string>)c.ToList()));
|
||||
});
|
||||
builder.Entity<InStockTotalDetails>(ent =>
|
||||
{
|
||||
ent.ToTable("t_wms_instock_total_details");
|
||||
ent.HasKey(x => x.Id);
|
||||
ent.Property(f => f.SerialNumbers).HasConversion(
|
||||
v => JsonConvert.SerializeObject(v),
|
||||
v => JsonConvert.DeserializeObject<List<string>>(v),
|
||||
new ValueComparer<List<string>>(
|
||||
(c1, c2) => c1.SequenceEqual(c2),
|
||||
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
|
||||
c => (List<string>)c.ToList()));
|
||||
});
|
||||
# endregion
|
||||
|
||||
#region 入库任务单
|
||||
@@ -335,6 +347,8 @@ namespace WMS.Web.Repositories.Configuration
|
||||
public DbSet<TakeStockDetails> TakeStockDetails { get; set; }
|
||||
public DbSet<InStock> Instock { get; set; }
|
||||
public DbSet<InStockDetails> InStockDetails { get; set; }
|
||||
public DbSet<InStockTotalDetails> InStockTotalDetails { get; set; }
|
||||
|
||||
public DbSet<InStockTask> InStockTask { get; set; }
|
||||
public DbSet<InStockTaskBox> InstockTaskBox { get; set; }
|
||||
public DbSet<InStockTaskBoxDetails> InStockTaskBoxDetails { get; set; }
|
||||
|
||||
@@ -80,8 +80,12 @@ namespace WMS.Web.Repositories
|
||||
if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
materials = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber)).ToList();
|
||||
|
||||
var query=_context.InStockDetails
|
||||
.GroupJoin(_context.Instock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
//var query=_context.InStockDetails
|
||||
// .GroupJoin(_context.Instock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
// .SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
|
||||
// .Where(adv => 1 == 1);
|
||||
var query = _context.InStockTotalDetails
|
||||
.GroupJoin(_context.Instock, detail => detail.InStockId, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
|
||||
.Where(adv => 1 == 1);
|
||||
|
||||
@@ -99,12 +103,12 @@ namespace WMS.Web.Repositories
|
||||
query = query.Where(w => w.detail.SupplierId == dto.SupplierId.Value);
|
||||
|
||||
if (dto.OrgId.HasValue)
|
||||
query = query.Where(w => w.detail.OrgId == dto.OrgId.Value);
|
||||
query = query.Where(w => w.order.OrgId == dto.OrgId.Value);
|
||||
|
||||
if (!string.IsNullOrEmpty(dto.StockCode))
|
||||
{
|
||||
var splitStrs = dto.StockCode.Split("_$");
|
||||
query = query.Where(w => w.detail.StockCode == splitStrs[0] && w.detail.OrgCode == splitStrs[1]);
|
||||
query = query.Where(w => w.order.StockCode == splitStrs[0] && w.order.OrgCode == splitStrs[1]);
|
||||
}
|
||||
|
||||
if (dto.Type.HasValue)
|
||||
@@ -126,11 +130,11 @@ namespace WMS.Web.Repositories
|
||||
Type=s.order.Type.GetRemark(),
|
||||
SourceBillNo=s.detail.SourceBillNo,
|
||||
Supplier= _erpBasicDataExtendService.GetSupplierName(suppliers, s.detail.SupplierId),
|
||||
Org = _erpBasicDataExtendService.GetOrgName(orgs, s.detail.OrgId),
|
||||
Org = _erpBasicDataExtendService.GetOrgName(orgs, s.order.OrgId),
|
||||
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialId),
|
||||
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.detail.MaterialId),
|
||||
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialId),
|
||||
Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, _loginRepositories.CompanyId, s.detail.StockCode+s.detail.OrgCode),
|
||||
Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, _loginRepositories.CompanyId, s.order.StockCode+s.order.OrgCode),
|
||||
Qty =s.detail.Qty,
|
||||
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.order.CreatorId),
|
||||
CreateTime =s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
@@ -215,5 +219,35 @@ namespace WMS.Web.Repositories
|
||||
};
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加:入库汇总明细
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddRangeTotalDetails(List<InStockTotalDetails> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (entitys != null && entitys.Count != 0)
|
||||
{
|
||||
await _context.InStockTotalDetails.AddRangeAsync(entitys);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user