cjy 4 months ago
commit 721a0d60a2

@ -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)
@ -3720,28 +3718,28 @@ namespace DS.WMS.Core.Op.Method
var ctnList = tenantDb.Queryable<BookingSlotCtn>().Where(x=>x.SlotId == id).ToList();
ctnList.ForEach(async t =>
ctnList.ForEach(t =>
{
t.Deleted = true;
t.DeleteTime = DateTime.Now;
t.DeleteBy = long.Parse(user.UserId);
t.DeleteUserName = user.UserName;
await tenantDb.Updateable<BookingSlotCtn>(t).ExecuteCommandAsync();
tenantDb.Updateable<BookingSlotCtn>(t).ExecuteCommand();
});
var alloc = tenantDb.Queryable<BookingSlotAllocation>().Where(a => a.BookingSlotId == id && a.Deleted == false).ToList();
if (alloc.Count > 0)
{
alloc.ForEach(async t =>
alloc.ForEach(t =>
{
t.Deleted = true;
t.DeleteTime = DateTime.Now;
t.DeleteBy = long.Parse(user.UserId);
t.DeleteUserName = user.UserName;
await tenantDb.Updateable<BookingSlotAllocation>(t).ExecuteCommandAsync();
tenantDb.Updateable<BookingSlotAllocation>(t).ExecuteCommand();
});
}
@ -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

@ -0,0 +1,18 @@
namespace DS.WMS.Core.TaskPlat.Dtos
{
/// <summary>
/// 任务接收人信息
/// </summary>
public class RecvUserInfo
{
/// <summary>
/// 接收人信息主键
/// </summary>
public long RecvUserId { get; set; }
/// <summary>
/// 接收人信息姓名
/// </summary>
public string RecvUserName { get; set; }
}
}

@ -56,25 +56,30 @@ namespace DS.WMS.Core.TaskPlat.Dtos
public int IsException { get; set; } = 0;
/// <summary>
/// 任务对应操作人ID
/// 任务对应操作人ID(任务制单人)
/// </summary>
public string TaskUserId { get; set; }
/// <summary>
/// 任务对应操作人名称
/// 任务对应操作人名称(任务制单人)
/// </summary>
public string TaskUserName { get; set; }
/// <summary>
/// 任务对应接收操作人ID
/// 任务对应接收操作人ID(任务接收人)
/// </summary>
public string RecvUserId { get; set; }
/// <summary>
/// 任务对应接收操作人名称
/// 任务对应接收操作人名称(任务接收人)
/// </summary>
public string RecvUserName { get; set; }
/// <summary>
/// 任务接收人列表
/// </summary>
public List<RecvUserInfo> RecvUserInfoList { get; set; }
/// <summary>
/// 任务对应接收操作人ID(大简云账户体系)
/// </summary>

@ -0,0 +1,37 @@
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.TaskPlat.Entity
{
/// <summary>
/// 任务归属关系表
///</summary>
[SugarTable("task_base_allocation", "任务归属关系表")]
public class TaskBaseAllocation : BaseModelV2<long>
{
/// <summary>
/// 任务主键
/// </summary>
[SugarColumn(ColumnDescription = "任务主键", IsNullable = false)]
public long TaskId { get; set; }
/// <summary>
/// 所属人员主键
/// </summary>
[SugarColumn(ColumnDescription = "所属人员主键", IsNullable = false)]
public long UserId { get; set; }
/// <summary>
/// 所属人员姓名
/// </summary>
[SugarColumn(ColumnDescription = "所属人员姓名", IsNullable = false, Length = 255)]
public string UserName { get; set; }
/// <summary>
/// 所属机构主键
/// </summary>
[SugarColumn(ColumnDescription = "所属机构主键", IsNullable = true)]
public long? OrgId { get; set; }
}
}

@ -64,13 +64,17 @@ namespace DS.WMS.Core.TaskPlat.Method
_logger.LogInformation("接收到任务状态修改报文 任务主键={id} 状态设置={status}", taskInfo.Id, taskStatusEnum.ToString());
taskInfo.STATUS = taskStatusEnum.ToString();
taskInfo.RealUserId = long.Parse(user.UserId);
taskInfo.RealUserName = user.UserName;
await tenantDb.Updateable(taskInfo).UpdateColumns(x => new
{
x.UpdateBy,
x.UpdateTime,
x.UpdateUserName,
x.STATUS
x.STATUS,
x.RealUserId,
x.RealUserName
}).ExecuteCommandAsync();
return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataUpdateSuccess)));
@ -156,37 +160,57 @@ namespace DS.WMS.Core.TaskPlat.Method
BATCH_STATIC = info.Main.BatchStatic,
DJYUserId = info.Head.DJYUserId,
OUT_BS_NO = info.Head.BSNO,
CreateTime = DateTime.Now,
};
long taskReqUserId = 0;
// 人员字段说明:
// TaskBaseInfo.CreateBy 创建人:谁创建的,只有一个人(可能是某个租户的管理员,因为任务可以由外部(邮件)创建,无法为每个人创建接口授权信息)
// TaskBaseInfo.TASK_REQ_USERID 制单人只有一个人使用任务创建报文中传入的TaskUserId
// TaskBaseAllocation.UserId 任务关系任务属于谁谁能够查看并处理可能是多个人可能是多个人一起处理取值优先级TaskBaseInfo.TASK_REQ_USERID>关联订单>TaskBaseInfo.CreateBy
// TaskBaseInfo.RealUserId 实际操作人:谁实际处理的,只有一个人
// 创建人
taskInfo.CreateBy = long.Parse(user.UserId);
taskInfo.CreateUserName = user.UserName;
// 制单人
long taskReqUserId = 0;
if (!string.IsNullOrWhiteSpace(info.Main.TaskUserId))
{
if (long.TryParse(info.Main.TaskUserId, out taskReqUserId))
{
taskInfo.TASK_REQ_USERID = taskReqUserId;
taskInfo.TASK_REQ_USERNAME = info.Main.TaskUserName;
}
}
// 忽略
taskInfo.CreateBy = long.Parse(user.UserId);
taskInfo.CreateTime = DateTime.Now;
//taskInfo.CreatedUserId = userTendInfo.userId;
//taskInfo.CreatedUserName = userTendInfo.userName;
//taskInfo.TenantId = userTendInfo.tendId;
//taskInfo.TenantName = userTendInfo.tenantName;
_logger.LogInformation("批次={no} 获取登录人详情 recvUserId={recvUserId} UserId={UserId}", batchNo,
info.Main.RecvUserId,
user.UserId);
if (info.Main.TaskType == TaskBaseTypeEnum.TRUCK_DISPATCH || info.Main.TaskType == TaskBaseTypeEnum.CAUTION_NOTICE)
// 任务所属人员列表
// 如果明确指出接收人(接收人列表),则将任务作为个人任务
if (info.Main.RecvUserInfoList?.Count > 0)
{
_logger.LogInformation("批次={no} 接收人列表 recvUserList={recvUserList} ", batchNo,
JsonConvert.SerializeObject(info.Main.RecvUserInfoList));
taskInfo.IS_PUBLIC = 0;
var allocationList = info.Main.RecvUserInfoList.Select(x => new TaskBaseAllocation
{
TaskId = taskInfo.Id,
UserId = x.RecvUserId,
UserName = x.RecvUserName
}).ToList();
await tenantDb.Insertable(allocationList).ExecuteCommandAsync();
}
// 否则判断任务关联订单,如果能关联到,则判断任务设置的角色;如果有设置,则将任务挂载到订单的指定角色上;如果没关联到或者没有设置,则作为公共任务
else
{
taskInfo.IS_PUBLIC = 1;
//
}
_logger.LogInformation("批次={no} 获取登录人详情 userid={userid} UserId={UserId}", batchNo,
info.Main.RecvUserId,
user.UserId);
if (info.Main != null && info.Main.TruckInfo != null && info.Main.TruckInfo.NeedArriveTime.HasValue)
{

@ -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-24T07:38:29.2442086Z||;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