diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ChainStatusReportingUpInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ChainStatusReportingUpInput.cs
new file mode 100644
index 00000000..2eac52e8
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ChainStatusReportingUpInput.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
+{
+ ///
+ /// 创建任务链输入参数
+ ///
+ public class ChainStatusReportingUpInput
+ {
+ ///
+ /// 任务链编号
+ ///
+ public string taskChainCode { get; set; }
+
+ ///
+ /// 任务链任务状态
+ ///
+ public string status { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ConfirmInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ConfirmInput.cs
new file mode 100644
index 00000000..9a5329fc
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ConfirmInput.cs
@@ -0,0 +1,25 @@
+using Tnb.WarehouseMgr.Entities.Enums;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ public class ConfirmInput
+ {
+ ///
+ /// 任务链编号
+ ///
+ public string taskChainCode { get; set; }
+ ///
+ /// 子任务编号
+ ///
+ public string taskCode { get; set; }
+ ///
+ /// 起点编号
+ ///
+ public string sourceName { get; set; }
+ ///
+ /// 终点编号
+ ///
+ public string targetName { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TaskCallBackInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TaskCallBackInput.cs
new file mode 100644
index 00000000..a5182436
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TaskCallBackInput.cs
@@ -0,0 +1,34 @@
+using Tnb.WarehouseMgr.Entities.Enums;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ public class TaskCallBackInput
+ {
+ ///
+ /// 任务链编号
+ ///
+ public string taskChainCode { get; set; }
+ ///
+ /// 任务链编号
+ ///
+ public string taskCode { get; set; }
+ ///
+ /// 起点编号
+ ///
+ public string sourceName { get; set; }
+ ///
+ /// 终点编号
+ ///
+ public string targetName { get; set; }
+ ///
+ /// 状态
+ ///
+ public string status { get; set; }
+ ///
+ /// 取货/放货
+ ///
+ public string action { get; set; }
+
+
+ }
+}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TaskChainCallBackInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TaskChainCallBackInput.cs
new file mode 100644
index 00000000..697ff122
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TaskChainCallBackInput.cs
@@ -0,0 +1,18 @@
+using Tnb.WarehouseMgr.Entities.Enums;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ public class TaskChainCallBackInput
+ {
+ ///
+ /// 任务链编号
+ ///
+ public string taskChainCode { get; set; }
+ ///
+ /// 状态
+ ///
+ public string status { get; set; }
+
+
+ }
+}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/Result.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/Result.cs
index 1941562b..7e3012bd 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/Result.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/Result.cs
@@ -17,6 +17,10 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Outputs
/// 响应信息
///
public string msg { get; set; }
+ ///
+ /// 错误提示消息
+ ///
+ public string error { get; set; }
public DateTime? timestamp { get; set; }
///
/// 响应数据
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
index e4cfc765..93adbc1c 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
@@ -54,5 +54,18 @@ namespace Tnb.WarehouseMgr.Interfaces
///
///
Task TaskComplate(TaskCompleUpInput input);
+ ///
+ /// 任务执行
+ ///
+ ///
+ ///
+ Task TaskExecute(TaskExecuteUpInput input);
+ ///
+ /// 任务执行取操作返回(后续操作)
+ ///
+ /// ///
+ ///
+ Task TaskExecuteAfter(TaskExecuteAfterUpInput input);
+
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs
index 2fa07bb8..97600ffe 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs
@@ -3,26 +3,189 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Enums;
+using JNPF.Common.Extension;
+using JNPF.FriendlyException;
+using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Mvc;
+using NPOI.OpenXmlFormats;
using Senparc.NeuChar.ApiHandlers;
+using SqlSugar;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
+using Tnb.WarehouseMgr.Entities.Entity;
+using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
{
///
/// Wms设备接口提供程序服务类
///
-
+
public class DeviceProviderService : BaseWareHouseService
{
+ private readonly ISqlSugarClient _db;
+ private readonly IWareHouseService _wareHouseService;
+
+ public DeviceProviderService(ISqlSugarRepository repository, IWareHouseService wareHouseService)
+ {
+ _db = repository.AsSugarClient();
+ _wareHouseService = wareHouseService;
+ }
+
///
/// 创建任务链
///
///
- [HttpPost]
- public async Task CreateTaskChain()
+ [HttpPost, NonUnify]
+ public async Task CreateTaskChain()
{
return await Task.FromResult(null);
- }
+ }
+
+ ///
+ /// 取货确认/申请取货
+ ///
+ ///
+ ///
+ [HttpPost, NonUnify]
+ public async Task LoadConfirm(ConfirmInput input)
+ {
+ try
+ {
+ var eles = await _db.Queryable().LeftJoin((a, b) => a.id == b.bill_id)
+ .LeftJoin((a, b, c) => b.location_id == c.startlocation_id)
+ .Where((a, b, c) => c.startlocation_code == input.sourceName && c.bill_code == $"{input.taskChainCode}-{input.taskCode}")
+ .ToListAsync();
+ }
+ catch (Exception)
+ {
+ return await ToApiResult(HttpStatusCode.InternalServerError, "请重试!");
+ throw;
+ }
+ return await ToApiResult(HttpStatusCode.OK, "未启用");
+ }
+
+ ///
+ /// 放货确认/申请放货
+ ///
+ ///
+ ///
+ [HttpPost, NonUnify]
+ public async Task UnloadConfirm(ConfirmInput input)
+ {
+ try
+ {
+ var eles = await _db.Queryable().LeftJoin((a, b) => a.id == b.bill_id)
+ .LeftJoin((a, b, c) => b.location_id == c.endlocation_id)
+ .Where((a, b, c) => c.endlocation_code == input.targetName && c.bill_code == $"{input.taskChainCode}-{input.taskCode}")
+ .ToListAsync();
+ }
+ catch (Exception)
+ {
+ return await ToApiResult(HttpStatusCode.InternalServerError, "请重试!");
+ throw;
+ }
+ return await ToApiResult(HttpStatusCode.OK, "未启用");
+ }
+
+ ///
+ /// 任务链状态上报
+ ///
+ ///
+ [HttpPost, NonUnify]
+ public async Task TaskChainCallBack(TaskChainCallBackInput input)
+ {
+ try
+ {
+ switch (input.status)
+ {
+ case "CREATED": break;
+ case "ALLOCATED":
+ var disTasks = await _db.Queryable().Where(it => it.bill_code.Contains(input.taskChainCode)).ToListAsync();
+ TaskExecuteUpInput taskExecuteUpInput = new()
+ {
+ disTaskIds = disTasks.Select(x => x.id).ToList(),
+ };
+ await _wareHouseService.TaskExecute(taskExecuteUpInput); break;
+ case "PROGRESSING": break;
+ case "CANCELLED": break;
+ case "SUCCEED": break;
+ case "FAILURE": break;
+ case "FINISHED": break;
+ default: break;
+ }
+ }
+ catch (Exception)
+ {
+ return await ToApiResult(HttpStatusCode.InternalServerError, "请重试!");
+ throw;
+ }
+ return await ToApiResult(HttpStatusCode.OK, "成功");
+ }
+
+ ///
+ /// 任务状态上报
+ ///
+ ///
+ ///
+ [HttpPost, NonUnify]
+ public async Task TaskCallback(TaskCallBackInput input)
+ {
+ try
+ {
+ var disTasks = await _db.Queryable().Where(it => it.bill_code.Contains($"{input.taskChainCode}-{input.taskCode}")).ToListAsync();
+ if (input.action == "取货")
+ {
+ TaskExecuteAfterUpInput taskExecuteAfterUpInput = new()
+ {
+ disTaskIds = disTasks.Select(x => x.id).ToList()
+ };
+ await _wareHouseService.TaskExecuteAfter(taskExecuteAfterUpInput);
+ }
+ else if (input.action == "放货")
+ {
+ TaskCompleUpInput taskCompleUpInput = new()
+ {
+ disTaskIds = disTasks.Select(x => x.id).ToList()
+ };
+ await _wareHouseService.TaskComplate(taskCompleUpInput);
+ }
+ }
+ catch (Exception)
+ {
+ return await ToApiResult(HttpStatusCode.InternalServerError, "请重试!");
+ throw;
+ }
+ return await ToApiResult(HttpStatusCode.OK, "成功");
+ }
+
+ ///
+ /// 申请进出电梯
+ ///
+ ///
+ ///
+ [HttpPost, NonUnify]
+ public async Task ElevatorConfirm(ConfirmInput input)
+ {
+ try
+ {
+ var eles = await _db.Queryable().LeftJoin((a, b) => a.id == b.bill_id)
+ .LeftJoin((a, b, c) => b.location_id == c.startlocation_id)
+ .Where((a, b, c) => c.startlocation_code == input.sourceName && c.bill_code == $"{input.taskChainCode}-{input.taskCode}")
+ .ToListAsync();
+ }
+ catch (Exception)
+ {
+ return await ToApiResult(HttpStatusCode.InternalServerError, "请重试!");
+ throw;
+ }
+ return await ToApiResult(HttpStatusCode.OK, "未启用");
+ }
+
+
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index a8a61455..1f6da2b4 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
@@ -19,6 +20,7 @@ using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Config;
using JNPF.FriendlyException;
+using JNPF.Logging;
using JNPF.Systems.Entitys.Dto.Module;
using JNPF.Systems.Interfaces.System;
using Mapster;
@@ -164,6 +166,7 @@ namespace Tnb.WarehouseMgr
var whereExp = Expressionable.Create()
.And(it => it.wh_id == input.warehouse_id)
.And(it => it.is_lock == 0)
+ .And(it => it.is_type == ((int)EnumLocationType.存储库位).ToString())
.And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
.ToExpression();
items = await _db.Queryable().Where(whereExp).OrderBy(policy.policy).ToListAsync();
@@ -213,6 +216,7 @@ namespace Tnb.WarehouseMgr
[HttpPost]
public async Task GenTaskExecute()
{
+ Stopwatch sw = Stopwatch.StartNew();
//获取所有未下发的预任务申请
var preTasks = await _db.Queryable().InnerJoin((a, b) => a.startlocation_id == b.location_id && a.carry_id == b.id)
.InnerJoin((a, b, c) => a.area_id == c.id)
@@ -316,6 +320,19 @@ namespace Tnb.WarehouseMgr
row = await _db.Updateable().SetColumns(it => new WmsPretaskH { status = WmsWareHouseConst.PRETASK_BILL_STATUS_YXF_ID }).Where(it => preTaskIds.Contains(it.id)).ExecuteCommandAsync();
}
+ //调用AGV创建任务链接口
+ var taskChainCodeDic = disTasks.Where(t => !t.groups.IsNullOrWhiteSpace()).GroupBy(g => g.groups!)
+ .ToDictionary(x => x.Key, x => x.Select(it => new
+ {
+ taskCode = it.bill_code,
+ sourceName = it.startlocation_code,
+ targetName = it.endlocation_code
+ }));
+
+ dynamic reqBody = new ExpandoObject();
+
+ sw.Stop();
+ Log.Information($"程序运行耗时{sw.ElapsedMilliseconds}ms");
await _db.Ado.CommitTranAsync();
}
catch (Exception)
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs
index 6a3eb7fc..01d00f36 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs
@@ -136,7 +136,7 @@ namespace Tnb.WarehouseMgr
preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!;
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!;
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!;
- preTaskUpInput.LocationIds = points.Select(x => x.id).ToList();
+ preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!;
preTaskUpInput.PreTaskRecords = preTasks.Adapt>();
preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId());
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs
index fda743f8..71b40265 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs
@@ -132,7 +132,7 @@ namespace Tnb.WarehouseMgr
preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!;
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!;
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!;
- preTaskUpInput.LocationIds = points.Select(x => x.id).ToList();
+ preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!;
preTaskUpInput.PreTaskRecords = preTasks.Adapt>();
preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId());
WmsHandleH handleH = new();