修改舱位

usertest
jianghaiqing 4 months ago
parent 4d6f7e7486
commit 471ee2693b

@ -3,6 +3,7 @@ using DS.Module.Core.Data;
using DS.Module.DjyServiceStatus;
using DS.WMS.Core.Op.Dtos;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
@ -38,6 +39,13 @@ namespace DS.WMS.Core.Op.Interface
/// <returns>返回详情</returns>
Task<DataResult<BookingSlotBaseSaveOutput>> Detail(long id);
// <summary>
/// 分页查询可用的舱位及箱子列表
/// </summary>
/// <param name="input">可选:舱位查询条件</param>
/// <param name="pageInfo">可选:分页信息</param>
Task<DataResult<SqlSugarPagedList<BookingSlotBaseWithCtnDto>>> GetAvailableSlots(BookingSlotBaseDto input, PageWithTotal pageInfo);
/// <summary>
/// 查询可用的舱位及箱子列表
/// </summary>
@ -216,5 +224,12 @@ namespace DS.WMS.Core.Op.Interface
/// <param name="ids">舱位主键数组</param>
/// <returns>返回回执</returns>
Task<DataResult> Delete(long[] ids);
/// <summary>
/// 查询指定舱位可用的箱子列表
/// </summary>
/// <param name="slotId">舱位主键</param>
/// <returns>可用的箱子列表</returns>
Task<DataResult<List<BookingSlotCtnDto>>> GetAvailableCtnsBySlot(long slotId);
}
}

@ -1849,8 +1849,7 @@ namespace DS.WMS.Core.Op.Method
/// </summary>
/// <param name="input">可选:舱位查询条件</param>
/// <param name="pageInfo">可选:分页信息</param>
public async Task<SqlSugarPagedList<BookingSlotBaseWithCtnDto>> GetAvailableSlots([FromQuery] BookingSlotBaseDto input,
[FromQuery] PageWithTotal pageInfo)
public async Task<DataResult<SqlSugarPagedList<BookingSlotBaseWithCtnDto>>> GetAvailableSlots(BookingSlotBaseDto input,PageWithTotal pageInfo)
{
var result = await GetAvailableSlots(input, null, pageInfo);
@ -1861,7 +1860,7 @@ namespace DS.WMS.Core.Op.Method
TotalCount = pageInfo.Total,
Items = result,
};
return pageResult;
return DataResult<SqlSugarPagedList<BookingSlotBaseWithCtnDto>>.Success(pageResult);
}
#endregion
@ -1873,7 +1872,6 @@ namespace DS.WMS.Core.Op.Method
/// <param name="slotIdListInput">筛选条件2舱位主键列表</param>
/// <param name="pageInfo">筛选条件3分页</param>
/// <returns>可用的舱位列表(含可用的箱子列表)</returns>
[NonAction]
public async Task<List<BookingSlotBaseWithCtnDto>> GetAvailableSlots(BookingSlotBaseDto slotInput = null,
List<long> slotIdListInput = null,
PageWithTotal pageInfo = null)
@ -3762,6 +3760,86 @@ namespace DS.WMS.Core.Op.Method
return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotDeleteSucc)));
}
#endregion
/// <summary>
/// 查询指定舱位可用的箱子列表
/// </summary>
/// <param name="slotId">舱位主键</param>
/// <returns>可用的箱子列表</returns>
public async Task<DataResult<List<BookingSlotCtnDto>>> GetAvailableCtnsBySlot(long slotId)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (await tenantDb.Queryable<BookingSlotBase>().AnyAsync(x => x.Id == slotId && x.IsCancellation == false) == false)
{
//获取舱位失败,舱位不存在或已作废
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotCreateRecordDeletedOrNoExists)));
}
// 1. 【舱位基础表】与【箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【总的箱量】作为queryable1
var queryable1 = tenantDb.Queryable<BookingSlotBase, BookingSlotCtn>((bas, ctn) => bas.Id == ctn.SlotId)
.Where(bas => bas.IsCancellation == false && bas.Id == slotId)
.GroupBy((bas, ctn) => new
{
bas.Id,
ctn.CtnCode
})
.Select((bas, ctn) => new
{
id = bas.Id,
ctnCode = ctn.CtnCode,
numAll = SqlFunc.AggregateSum(ctn.CtnNum)
})
.MergeTable();
// 2. 【已引入舱位表】与【已使用的箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【已使用的箱量】作为queryable2
var queryable2 = tenantDb.Queryable<BookingSlotAllocation, BookingSlotAllocationCtn>((alc, ctn) => alc.Id == ctn.SlotAllocId)
.Where((alc, ctn) => alc.BookingSlotId == slotId)
.GroupBy((alc, ctn) => new
{
alc.BookingSlotId,
ctn.CtnCode
})
.Select((alc, ctn) => new
{
id = alc.BookingSlotId,
ctnCode = ctn.CtnCode,
numUse = SqlFunc.AggregateSum(ctn.CtnNum)
})
.MergeTable();
// 3. 将queryable1 左连接 queryable2使用【总的箱量】减去【已使用的箱量】得到【剩余的箱量】添加【剩余的箱量】> 0 的条件作为queryable3
var queryable3 = queryable1.LeftJoin(queryable2, (q1, q2) => q1.id == q2.id && q1.ctnCode == q2.ctnCode)
.Select((q1, q2) => new
{
q1.id,
q1.ctnCode,
numResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll)
})
.MergeTable()
.Where(r => r.numResidue > 0);
// 4. 执行ToList(),得到可用的【舱位主键】、【箱型】、【箱量】列表
var canUselist = await queryable3.ToListAsync();
List<CodeCtnRes> ctnCodeCache = new List<CodeCtnRes>();
var allCtnCodeList = await _codeCtnService.GetAllList();
if (allCtnCodeList.Succeeded)
{
ctnCodeCache = allCtnCodeList.Data;
}
List<BookingSlotCtnDto> result = canUselist.Select(c => new BookingSlotCtnDto()
{
CtnCode = c.ctnCode,
CtnNum = c.numResidue,
CtnAll = ctnCodeCache.FirstOrDefault(e => $"{e.CtnSize}{e.CtnType}" == c.ctnCode)?.CtnName ?? throw new Exception($"舱位信息中存在未收录的箱型:{c.ctnCode},需要在箱型字典中补充"),
}).ToList();
return DataResult<List<BookingSlotCtnDto>>.Success(result);
}
}
public static class LetterIndexUtil

@ -59,17 +59,17 @@ namespace DS.WMS.OpApi.Controllers
#region 查询可用的舱位及箱子列表
/// <summary>
/// 查询可用的舱位及箱子列表
/// 分页查询可用的舱位及箱子列表
/// </summary>
/// <param name="slotInput">筛选条件1舱位信息、箱型</param>
/// <param name="slotIdListInput">筛选条件2舱位主键列表</param>
/// <param name="pageInfo">筛选条件3分页</param>
/// <param name="input">可选:舱位查询条件</param>
/// <param name="pageInfo">可选:分页信息</param>
/// <returns>可用的舱位列表(含可用的箱子列表)</returns>
[HttpPost]
[HttpGet]
[Route("GetAvailableSlots")]
public async Task<DataResult<List<BookingSlotBaseWithCtnDto>>> GetAvailableSlots([FromBody] BookingSlotBaseDto slotInput )
public async Task<DataResult<SqlSugarPagedList<BookingSlotBaseWithCtnDto>>> GetAvailableSlots([FromQuery] BookingSlotBaseDto input,
[FromQuery] PageWithTotal pageInfo)
{
return await _bookingSlotService.GetAvailableSlots(slotInput, null, null);
return await _bookingSlotService.GetAvailableSlots(input, pageInfo);
}
#endregion
@ -357,5 +357,19 @@ namespace DS.WMS.OpApi.Controllers
return await _bookingSlotService.Delete(ids);
}
#endregion
#region 查询指定舱位可用的箱子列表
/// <summary>
/// 查询指定舱位可用的箱子列表
/// </summary>
/// <param name="slotId">舱位主键</param>
/// <returns>可用的箱子列表</returns>
[HttpGet]
[Route("GetAvailableCtnsBySlot")]
public async Task<DataResult<List<BookingSlotCtnDto>>> GetAvailableCtnsBySlot(long slotId)
{
return await _bookingSlotService.GetAvailableCtnsBySlot(slotId);
}
#endregion
}
}

@ -782,3 +782,17 @@
2024-07-24 14:14:41.8726 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
2024-07-24 14:14:41.8726 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-07-24 14:14:41.8863 Info Configuration initialized.
2024-07-24 17:43:01.5160 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-07-24 17:43:01.5361 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-07-24 17:43:01.5361 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-07-24 17:43:01.5528 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-07-24 17:43:01.5595 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
2024-07-24 17:43:01.5595 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-07-24 17:43:01.5595 Info Configuration initialized.
2024-07-24 17:52:22.4155 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-07-24 17:52:22.4304 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-07-24 17:52:22.4304 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-07-24 17:52:22.4474 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-07-24 17:52:22.4474 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
2024-07-24 17:52:22.4592 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-07-24 17:52:22.4592 Info Configuration initialized.

@ -6,7 +6,7 @@
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Code\PublishCopy\ds8-opapi</_PublishTargetUrl>
<History>True|2024-07-24T08:01:13.8217949Z||;True|2024-07-24T15:56:15.7589616+08:00||;True|2024-07-24T15:38:29.2442086+08:00||;True|2024-07-24T14:48:12.2303919+08:00||;True|2024-07-24T14:18:05.5309704+08:00||;True|2024-07-24T12:56:48.1663545+08:00||;True|2024-07-24T08:47:26.1616069+08:00||;True|2024-07-24T08:42:02.7606608+08:00||;True|2024-07-24T08:41:18.4678459+08:00||;False|2024-07-24T08:40:29.5381703+08:00||;False|2024-07-24T08:39:20.2230656+08:00||;True|2024-07-23T15:56:16.8305907+08:00||;True|2024-07-22T16:42:12.1933090+08:00||;True|2024-07-19T18:28:29.1420269+08:00||;True|2024-07-19T15:45:49.1068004+08:00||;True|2024-07-19T15:33:45.3242155+08:00||;False|2024-07-19T15:32:41.9604526+08:00||;True|2024-07-19T13:48:27.9722093+08:00||;False|2024-07-19T13:47:56.7900396+08:00||;True|2024-07-19T11:41:15.4223247+08:00||;True|2024-07-19T08:46:28.8014836+08:00||;True|2024-07-18T19:24:50.4184188+08:00||;True|2024-07-18T19:19:14.7056635+08:00||;True|2024-07-18T19:04:43.5615501+08:00||;True|2024-07-18T18:38:39.1976753+08:00||;True|2024-07-18T18:25:15.6833492+08:00||;True|2024-07-18T18:08:46.3114951+08:00||;True|2024-07-18T17:59:12.5292256+08:00||;True|2024-07-18T16:18:45.8049777+08:00||;True|2024-07-18T16:12:42.9723969+08:00||;True|2024-07-18T16:07:14.1432207+08:00||;True|2024-07-17T17:44:18.4741963+08:00||;True|2024-07-17T17:42:47.2735071+08:00||;True|2024-07-17T16:13:32.9037697+08:00||;True|2024-07-17T15:40:21.2550083+08:00||;True|2024-07-17T14:03:08.1814323+08:00||;True|2024-07-15T13:43:42.6073130+08:00||;True|2024-07-15T11:53:40.6498579+08:00||;True|2024-07-15T11:53:03.1652559+08:00||;True|2024-07-15T11:42:33.0154478+08:00||;True|2024-07-15T10:20:03.3925876+08:00||;True|2024-07-15T10:13:28.1415352+08:00||;True|2024-07-08T14:33:12.6884426+08:00||;True|2024-07-08T09:56:58.4995696+08:00||;</History>
<History>True|2024-07-24T10:10:14.9409342Z||;True|2024-07-24T17:52:10.3966338+08:00||;True|2024-07-24T16:01:13.8217949+08:00||;True|2024-07-24T15:56:15.7589616+08:00||;True|2024-07-24T15:38:29.2442086+08:00||;True|2024-07-24T14:48:12.2303919+08:00||;True|2024-07-24T14:18:05.5309704+08:00||;True|2024-07-24T12:56:48.1663545+08:00||;True|2024-07-24T08:47:26.1616069+08:00||;True|2024-07-24T08:42:02.7606608+08:00||;True|2024-07-24T08:41:18.4678459+08:00||;False|2024-07-24T08:40:29.5381703+08:00||;False|2024-07-24T08:39:20.2230656+08:00||;True|2024-07-23T15:56:16.8305907+08:00||;True|2024-07-22T16:42:12.1933090+08:00||;True|2024-07-19T18:28:29.1420269+08:00||;True|2024-07-19T15:45:49.1068004+08:00||;True|2024-07-19T15:33:45.3242155+08:00||;False|2024-07-19T15:32:41.9604526+08:00||;True|2024-07-19T13:48:27.9722093+08:00||;False|2024-07-19T13:47:56.7900396+08:00||;True|2024-07-19T11:41:15.4223247+08:00||;True|2024-07-19T08:46:28.8014836+08:00||;True|2024-07-18T19:24:50.4184188+08:00||;True|2024-07-18T19:19:14.7056635+08:00||;True|2024-07-18T19:04:43.5615501+08:00||;True|2024-07-18T18:38:39.1976753+08:00||;True|2024-07-18T18:25:15.6833492+08:00||;True|2024-07-18T18:08:46.3114951+08:00||;True|2024-07-18T17:59:12.5292256+08:00||;True|2024-07-18T16:18:45.8049777+08:00||;True|2024-07-18T16:12:42.9723969+08:00||;True|2024-07-18T16:07:14.1432207+08:00||;True|2024-07-17T17:44:18.4741963+08:00||;True|2024-07-17T17:42:47.2735071+08:00||;True|2024-07-17T16:13:32.9037697+08:00||;True|2024-07-17T15:40:21.2550083+08:00||;True|2024-07-17T14:03:08.1814323+08:00||;True|2024-07-15T13:43:42.6073130+08:00||;True|2024-07-15T11:53:40.6498579+08:00||;True|2024-07-15T11:53:03.1652559+08:00||;True|2024-07-15T11:42:33.0154478+08:00||;True|2024-07-15T10:20:03.3925876+08:00||;True|2024-07-15T10:13:28.1415352+08:00||;True|2024-07-08T14:33:12.6884426+08:00||;True|2024-07-08T09:56:58.4995696+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save