优化详情

This commit is contained in:
tongfei
2024-04-22 09:37:05 +08:00
parent 4f668a209b
commit 319c5a8c77
6 changed files with 112 additions and 219 deletions

View File

@@ -1100,6 +1100,11 @@
收货人 收货人
</summary> </summary>
</member> </member>
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBox.UnBind">
<summary>
是否解绑
</summary>
</member>
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBox.Details"> <member name="P:WMS.Web.Domain.Entitys.InStockTaskBox.Details">
<summary> <summary>
明细 明细
@@ -2874,13 +2879,6 @@
箱与任务单绑定(收货)关系表-仓储接口 箱与任务单绑定(收货)关系表-仓储接口
</summary> </summary>
</member> </member>
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.GetListBy(System.Int32)">
<summary>
集合:任务单ID
</summary>
<param name="taskId"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.GetListBy(System.Collections.Generic.List{System.Int32})"> <member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.GetListBy(System.Collections.Generic.List{System.Int32})">
<summary> <summary>
集合根据boxIDS 集合根据boxIDS
@@ -2926,6 +2924,14 @@
<param name="isTransaction"></param> <param name="isTransaction"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.UpdateRange(System.Collections.Generic.List{WMS.Web.Domain.Entitys.InStockTaskBox},System.Boolean)">
<summary>
修改
</summary>
<param name="entitys"></param>
<param name="isTransaction"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories"> <member name="T:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories">
<summary> <summary>
入库任务-仓储接口 入库任务-仓储接口

View File

@@ -49,6 +49,11 @@ namespace WMS.Web.Domain.Entitys
/// </summary> /// </summary>
public int? ReceiverId { get; set; } public int? ReceiverId { get; set; }
/// <summary>
/// 是否解绑
/// </summary>
public bool? UnBind { get; set; } = false;
/// <summary> /// <summary>
/// 明细 /// 明细
/// </summary> /// </summary>

View File

@@ -11,12 +11,6 @@ namespace WMS.Web.Domain.Infrastructure
/// </summary> /// </summary>
public interface IInStockTaskBoxRepositories public interface IInStockTaskBoxRepositories
{ {
/// <summary>
/// 集合:任务单ID
/// </summary>
/// <param name="taskId"></param>
/// <returns></returns>
Task<List<InStockTaskBox>> GetListBy(int taskId);
/// <summary> /// <summary>
/// 集合根据boxIDS /// 集合根据boxIDS
@@ -62,5 +56,13 @@ namespace WMS.Web.Domain.Infrastructure
/// <param name="isTransaction"></param> /// <param name="isTransaction"></param>
/// <returns></returns> /// <returns></returns>
Task<bool> DeleteRange(List<int> ids, bool isTransaction = true); Task<bool> DeleteRange(List<int> ids, bool isTransaction = true);
/// <summary>
/// 修改
/// </summary>
/// <param name="entitys"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
Task<bool> UpdateRange(List<InStockTaskBox> entitys, bool isTransaction = true);
} }
} }

View File

@@ -38,7 +38,7 @@ namespace WMS.Web.Domain.Services
var t_boxIds = boxIds.Distinct().ToList(); var t_boxIds = boxIds.Distinct().ToList();
var list= await _inStockTaskBoxRepositories.GetListBy(t_boxIds); var list= await _inStockTaskBoxRepositories.GetListBy(t_boxIds);
delete_ids= list.Select(x => x.Id).ToList(); //delete_ids= list.Select(x => x.Id).ToList();
//var boxInvetList = await _boxInventoryRepositories.GetList(t_boxIds); //var boxInvetList = await _boxInventoryRepositories.GetList(t_boxIds);
//foreach (var item in list) //foreach (var item in list)
//{ //{
@@ -47,9 +47,16 @@ namespace WMS.Web.Domain.Services
// delete_ids.Add(item.Id); // delete_ids.Add(item.Id);
//} //}
if (delete_ids.Count != 0) //if (delete_ids.Count != 0)
//{
// var isSuccess= await _inStockTaskBoxRepositories.DeleteRange(delete_ids, isTransaction);
// if (!isSuccess)
// return Result.ReFailure(ResultCodes.DateWriteError);
//}
if (list.Count != 0)
{ {
var isSuccess= await _inStockTaskBoxRepositories.DeleteRange(delete_ids, isTransaction); var isSuccess = await _inStockTaskBoxRepositories.UpdateRange(list, isTransaction);
if (!isSuccess) if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError); return Result.ReFailure(ResultCodes.DateWriteError);
} }

View File

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Entitys;
using WMS.Web.Domain.Infrastructure; using WMS.Web.Domain.Infrastructure;
using WMS.Web.Domain.IService.Public; using WMS.Web.Domain.IService.Public;
using WMS.Web.Domain.Mappers;
using WMS.Web.Repositories.Configuration; using WMS.Web.Repositories.Configuration;
namespace WMS.Web.Repositories namespace WMS.Web.Repositories
@@ -47,18 +48,6 @@ namespace WMS.Web.Repositories
_erpBasicDataExtendService = erpBasicDataExtendService; _erpBasicDataExtendService = erpBasicDataExtendService;
} }
/// <summary>
/// 集合根据任务ID
/// </summary>
/// <param name="taskId"></param>
/// <returns></returns>
public async Task<List<InStockTaskBox>> GetListBy(int taskId)
{
var entitys = await _context.InstockTaskBox
.Include(s => s.Details).Where(x => x.TaskId == taskId).ToListAsync();
return entitys;
}
/// <summary> /// <summary>
/// 集合根据boxIDS /// 集合根据boxIDS
/// </summary> /// </summary>
@@ -67,7 +56,7 @@ namespace WMS.Web.Repositories
public async Task<List<InStockTaskBox>> GetListBy(List<int> boxIds) public async Task<List<InStockTaskBox>> GetListBy(List<int> boxIds)
{ {
var entitys = await _context.InstockTaskBox var entitys = await _context.InstockTaskBox
.Include(s => s.Details).Where(x => boxIds.Contains(x.BoxId)).ToListAsync(); .Include(s => s.Details).Where(x => boxIds.Contains(x.BoxId) && (x.UnBind==null || x.UnBind==false)).ToListAsync();
return entitys; return entitys;
} }
@@ -79,7 +68,7 @@ namespace WMS.Web.Repositories
public async Task<List<InStockTaskBox>> GetListBy(List<string> boxBillNos) public async Task<List<InStockTaskBox>> GetListBy(List<string> boxBillNos)
{ {
var entitys = await _context.InstockTaskBox var entitys = await _context.InstockTaskBox
.Include(s => s.Details).Where(x => boxBillNos.Contains(x.BoxBillNo)).ToListAsync(); .Include(s => s.Details).Where(x => boxBillNos.Contains(x.BoxBillNo) && (x.UnBind == null || x.UnBind == false)).ToListAsync();
return entitys; return entitys;
} }
@@ -91,7 +80,7 @@ namespace WMS.Web.Repositories
public async Task<InStockTaskBox> GetBy(string boxBillNo) public async Task<InStockTaskBox> GetBy(string boxBillNo)
{ {
var entity = await _context.InstockTaskBox var entity = await _context.InstockTaskBox
.Include(s => s.Details).Where(x => x.BoxBillNo == boxBillNo).FirstOrDefaultAsync(); .Include(s => s.Details).Where(x => x.BoxBillNo == boxBillNo && (x.UnBind == null || x.UnBind == false)).FirstOrDefaultAsync();
return entity; return entity;
} }
@@ -103,7 +92,7 @@ namespace WMS.Web.Repositories
public async Task<InStockTaskBox> GetBy(string boxBillNo, int? taskId) public async Task<InStockTaskBox> GetBy(string boxBillNo, int? taskId)
{ {
var query = _context.InstockTaskBox var query = _context.InstockTaskBox
.Include(s => s.Details).Where(x => x.BoxBillNo == boxBillNo); .Include(s => s.Details).Where(x => x.BoxBillNo == boxBillNo && (x.UnBind == null || x.UnBind == false));
if (taskId.HasValue) if (taskId.HasValue)
query = query.Where(x => x.TaskId == taskId.Value); query = query.Where(x => x.TaskId == taskId.Value);
@@ -169,5 +158,35 @@ namespace WMS.Web.Repositories
} }
return true; return true;
} }
/// <summary>
/// 批量修改
/// </summary>
/// <param name="entitys"></param>
/// <returns></returns>
public async Task<bool> UpdateRange(List<InStockTaskBox> 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.InstockTaskBox.Include(x => x.Details).Where(f => list.Contains(f.Id)).ToListAsync();
_mapper.Map(entitys, res);
var tt = await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
return true;
}
}
} }
} }

View File

@@ -157,8 +157,9 @@ namespace WMS.Web.Repositories
var entity = await _context.InStockTask.Include(x => x.Details).Where(x => x.Id == id).FirstOrDefaultAsync(); var entity = await _context.InStockTask.Include(x => x.Details).Where(x => x.Id == id).FirstOrDefaultAsync();
if (entity != null) if (entity == null)
{ return null;
var response = new InStockTaskInfoDto() var response = new InStockTaskInfoDto()
{ {
Id = entity.Id, Id = entity.Id,
@@ -171,115 +172,6 @@ namespace WMS.Web.Repositories
Org = _erpBasicDataExtendService.GetOrgName(orgs, entity.OrgCode), Org = _erpBasicDataExtendService.GetOrgName(orgs, entity.OrgCode),
CreateTime = entity.CreateTime.ToString("yyyy-MM-dd HH:mm:ss") CreateTime = entity.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}; };
if (entity.Type == InstockType.Purchase)
{
//采购任务的箱明细
var boxList = await _context.InStockTaskBoxDetails
.GroupJoin(_context.InstockTaskBox, boxde => boxde.Fid, ts => ts.Id, (detail, ts) => new { detail, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, box) => new { p.detail, box })
.GroupJoin(_context.InStockTaskDetails, p => p.box.TaskDetailId, ts => ts.Id, (p, ts) => new { p.detail, p.box, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, taskDet) => new { p.detail, p.box, taskDet })
.Where(x => x.box.TaskId == entity.Id).Select(x => new InStockTaskBoxInfoDto()
{
BoxId = x.box.BoxId,
BoxBillNo = x.box.BoxBillNo,
SaleBillNo = x.taskDet.SaleBillNo,
Method = InventoryInOutMethod.Box.GetRemark(),
MaterialNumber = x.detail.MaterialNumber,
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, x.detail.MaterialNumber),
ReceiveTime = x.box.CreateTime.HasValue ? x.box.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
Receiver = x.box.ReceiverId.HasValue ? _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.box.ReceiverId.Value) : "",
Qty = x.detail.ReceiveQty,
ReceiveQty = x.detail.ReceiveQty,
SerialNumbers = x.detail.SerialNumbers != null && x.detail.SerialNumbers.Count() > 0 ? (string.Join(",", x.detail.SerialNumbers).TrimEnd(',')) : "",
}).ToListAsync();
if (boxList != null && boxList.Count != 0)
{
//采购入库明细
var boxInstockList_details = await _context.InStockDetails.Where(x => x.TaskId == entity.Id).ToListAsync();
if (boxInstockList_details != null && boxInstockList_details.Count != 0)
{
var instockOrder_ids = boxInstockList_details.GroupBy(x => x.Fid).Select(x => x.Key).ToList();
var instockOrder = await _context.Instock.Where(x => instockOrder_ids.Contains(x.Id)).ToListAsync();
boxList.ForEach(x =>
{
var currentInstock = boxInstockList_details.Where(t => t.BoxId == x.BoxId && t.MaterialNumber == x.MaterialNumber).FirstOrDefault();
if (currentInstock != null)
{
var order = instockOrder.Where(o => o.Id == currentInstock.Fid).FirstOrDefault();
x.RealityQty = currentInstock.Qty;
x.Shelfer = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, (order == null ? 0 : order.CreatorId));
x.ShelfTime = order == null ? "" : order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
}
});
}
}
else
{
boxList = await _context.InStockDetails
.GroupJoin(_context.Instock, det => det.Fid, ts => ts.Id, (detail, ts) => new { detail, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.GroupJoin(_context.Box, p => p.detail.BoxId, ts => ts.Id, (p, ts) => new { p.detail, p.order, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, box) => new { p.detail, p.order, box })
.GroupJoin(_context.InStockTaskDetails, p => p.detail.TaskDetailId, ts => ts.Id, (p, ts) => new { p.detail, p.order, p.box, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, taskDet) => new { p.detail, p.order, p.box, taskDet })
.Where(x => x.detail.TaskId == entity.Id).Select(x => new InStockTaskBoxInfoDto()
{
BoxId = x.box.Id,
BoxBillNo = x.box.BoxBillNo,
Method = x.order.Method.GetRemark(),
MethodForInt = (int)x.order.Method,
MaterialNumber = x.detail.MaterialNumber,
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, x.detail.MaterialNumber),
SaleBillNo = x.taskDet.SaleBillNo,
Qty = 0,
RealityQty = x.detail.Qty,
ShelfTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
Shelfer = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId),
ReceiveQty = x.detail.Qty,
Receiver = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId),
ReceiveTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
SerialNumbers = (string.Join(",", x.detail.SerialNumbers).TrimEnd(','))
}).ToListAsync();
if (boxList != null && boxList.Count != 0)
{
var boxIds = boxList.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
var boxdetails = await _context.BoxDetails
.GroupJoin(_context.Box, det => det.Fid, ts => ts.Id, (detail, ts) => new { detail, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, box) => new { p.detail, box })
.Where(x => boxIds.Contains(x.box.Id)).Select(x => new
{
BoxId = x.box.Id,
MaterialNumber = x.detail.MaterialNumber,
Qty = x.detail.Qty
}).ToListAsync();
if (boxdetails != null && boxdetails.Count != 0)
{
boxList.ForEach(x =>
{
var method = (InventoryInOutMethod)x.MethodForInt;
if (method == InventoryInOutMethod.Box)
{
var currentBoxDet = boxdetails.Where(t => t.BoxId == x.BoxId && t.MaterialNumber == x.MaterialNumber).FirstOrDefault();
if (currentBoxDet != null)
{
x.Qty = currentBoxDet.Qty;
}
}
});
}
}
}
response.Boxs = boxList;
}
else
{
var boxList = await _context.InStockDetails var boxList = await _context.InStockDetails
.GroupJoin(_context.Instock, det => det.Fid, ts => ts.Id, (detail, ts) => new { detail, ts }) .GroupJoin(_context.Instock, det => det.Fid, ts => ts.Id, (detail, ts) => new { detail, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, order) => new { p.detail, order }) .SelectMany(x => x.ts.DefaultIfEmpty(), (p, order) => new { p.detail, order })
@@ -296,57 +188,19 @@ namespace WMS.Web.Repositories
MaterialNumber = x.detail.MaterialNumber, MaterialNumber = x.detail.MaterialNumber,
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, x.detail.MaterialNumber), Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, x.detail.MaterialNumber),
SaleBillNo = x.taskDet.SaleBillNo, SaleBillNo = x.taskDet.SaleBillNo,
Qty = 0, Qty = x.detail.Qty,
RealityQty = x.detail.Qty, RealityQty = x.detail.Qty,
ReceiveQty = x.detail.Qty,
ShelfTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), ShelfTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
Shelfer = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId), Shelfer = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId),
ReceiveQty = x.detail.Qty,
Receiver = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId), Receiver = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId),
ReceiveTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), ReceiveTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
SerialNumbers = (string.Join(",", x.detail.SerialNumbers).TrimEnd(',')) SerialNumbers = (string.Join(",", x.detail.SerialNumbers).TrimEnd(','))
}).ToListAsync(); }).ToListAsync();
if (boxList != null && boxList.Count != 0)
{
var boxIds = boxList.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
var boxdetails = await _context.BoxDetails
.GroupJoin(_context.Box, det => det.Fid, ts => ts.Id, (detail, ts) => new { detail, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, box) => new { p.detail, box })
.Where(x => boxIds.Contains(x.box.Id)).Select(x => new
{
BoxId = x.box.Id,
MaterialNumber = x.detail.MaterialNumber,
Qty = x.detail.Qty
}).ToListAsync();
if (boxdetails != null && boxdetails.Count != 0)
{
boxList.ForEach(x =>
{
var method = (InventoryInOutMethod)x.MethodForInt;
if (method == InventoryInOutMethod.Box)
{
var currentBoxDet = boxdetails.Where(t => t.BoxId == x.BoxId && t.MaterialNumber == x.MaterialNumber).FirstOrDefault();
if (currentBoxDet != null)
{
x.Qty = currentBoxDet.Qty;
}
}
});
}
}
response.Boxs = boxList; response.Boxs = boxList;
}
return response; return response;
} }
return null;
}
/// <summary> /// <summary>
/// 列表-根据明细中的来源单号 /// 列表-根据明细中的来源单号