diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
index 2528b66c..3fc8e29a 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
@@ -170,6 +170,11 @@ namespace Tnb.WarehouseMgr.Entities.Consts
/// 预任务生成业务类型-配送申请
///
public const string BIZTYPE_WMSDELIVERY_ID = "26585291847957";
+ ///
+ /// 预任务生成业务类型-载具绑定
+ ///
+ public const string BIZTYPE_WMSCARRYBIND_ID = "27118595509525";
+
///
/// 条码打印状态-已完成
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/RobotCallBackInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/RobotCallBackInput.cs
index 3d0338a9..a4ae81bf 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/RobotCallBackInput.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/RobotCallBackInput.cs
@@ -35,5 +35,9 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// 是否最后一个
///
public bool isLast { get; set; }
+ ///
+ /// 位置
+ ///
+ public int loc { get; set; }
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs
index 1eb7a537..b28ac64a 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs
@@ -42,7 +42,7 @@ public partial class WmsCarrybindH : BaseEntity
///
/// dataType
///
- public int biz_type { get; set; }
+ public int type { get; set; }
///
/// 载具分类ID
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryBindService.cs
new file mode 100644
index 00000000..8a60fe25
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryBindService.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JNPF.Common.Dtos.VisualDev;
+
+namespace Tnb.WarehouseMgr.Interfaces
+{
+ ///
+ /// 载具绑定服务接口
+ ///
+ public interface IWmsCarryBindService
+ {
+ Task CarryBind(VisualDevModelDataCrInput input);
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
index c8a19f8f..50e377e4 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
@@ -31,7 +31,7 @@ namespace Tnb.WarehouseMgr
/// 载具绑定
///
[OverideVisualDev(ModuleConsts.MODULE_WMSCARRYBIND_ID)]
- public class WmsCarryBindService : BaseWareHouseService
+ public class WmsCarryBindService : BaseWareHouseService, IWmsCarryBindService
{
private readonly ISqlSugarClient _db;
private readonly IRunService _runService;
@@ -52,8 +52,8 @@ namespace Tnb.WarehouseMgr
_billRullService = billRullService;
OverideFuncs.CreateAsync = CarryBind;
}
-
- private async Task CarryBind(VisualDevModelDataCrInput input)
+ [NonAction]
+ public async Task CarryBind(VisualDevModelDataCrInput input)
{
var isOk = false;
try
@@ -88,6 +88,7 @@ namespace Tnb.WarehouseMgr
};
row = await _db.Insertable(wmsCarryD).ExecuteCommandAsync();
var items = await _db.Queryable().Where(it => it.carry_id == subCarryId).ToListAsync();
+ List wmsCarrybindCodes = new();
//更新载具绑定条码表
for (int i = 0; i < items.Count; i++)
{
@@ -106,8 +107,9 @@ namespace Tnb.WarehouseMgr
wmsCarrybindCode.unit_code = items[i].unit_code;
wmsCarrybindCode.create_id = _userManager.UserId;
wmsCarrybindCode.create_time = DateTime.Now;
- row = await _db.Insertable(wmsCarrybindCode).ExecuteCommandAsync();
+ wmsCarrybindCodes.Add(wmsCarrybindCode);
}
+ row = await _db.Insertable(wmsCarrybindCodes).ExecuteCommandAsync();
isOk = (row > 0);
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
}
@@ -128,17 +130,8 @@ namespace Tnb.WarehouseMgr
return Task.FromResult(true);
}
- ///
- /// 机器人回调操作
- ///
- ///
- [HttpPost]
- public async Task RobotCallBack()
- {
- }
-
/* public override async Task ModifyAsync(WareHouseUpInput input)
{
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs
index 51e86739..a2f903ce 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs
@@ -84,8 +84,8 @@ namespace Tnb.WarehouseMgr
//入库取终点 //出库起点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
- WmsPointH sPoint = null;
- WmsPointH ePoint = null;
+ WmsPointH sPoint = null!;
+ WmsPointH ePoint = null!;
if (input.data.ContainsKey(nameof(WmsHandleH.startlocation_id)))
{
sPoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsHandleH.startlocation_id)].ToString());
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs
new file mode 100644
index 00000000..6f9dc631
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs
@@ -0,0 +1,173 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Dtos.VisualDev;
+using JNPF.Common.Extension;
+using JNPF.Common.Security;
+using JNPF.FriendlyException;
+using JNPF.Systems.Interfaces.System;
+using Mapster;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+using NPOI.OpenXmlFormats;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Consts;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
+using Tnb.WarehouseMgr.Entities.Enums;
+using Tnb.WarehouseMgr.Interfaces;
+
+namespace Tnb.WarehouseMgr
+{
+ ///
+ /// 机器人回调服务类
+ ///
+ public class WmsRobotCallbackService : BaseWareHouseService
+ {
+ private readonly IWmsCarryBindService _wmsCarryBindService;
+ private readonly ISqlSugarClient _db;
+ private readonly IUserManager _userManager;
+ private readonly IWareHouseService _warehouseService;
+ private readonly IBillRullService _billRullService;
+ public WmsRobotCallbackService(IWmsCarryBindService wmsCarryBindService, ISqlSugarRepository repository, IUserManager userManager, IWareHouseService warehouseService, IBillRullService billRullService)
+ {
+ _wmsCarryBindService = wmsCarryBindService;
+ _db = repository.AsSugarClient();
+ _userManager = userManager;
+ _warehouseService = warehouseService;
+ _billRullService = billRullService;
+ }
+
+ [HttpPost]
+ public async Task RobotCallback(RobotCallBackInput input)
+ {
+ var carry = await _db.Queryable().SingleAsync(it => it.id == input.carry_id);
+ var subCarry = await _db.Queryable().SingleAsync(it => it.id == input.membercarry_id);
+ if (carry != null && subCarry != null)
+ {
+ VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary() };
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id;
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code;
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id;
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code;
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0;
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id;
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = _userManager.UserId;
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now;
+ visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = input.loc;
+ await _wmsCarryBindService.CarryBind(visualDevModelCrInput);
+
+ carry.collocation_scheme_id = subCarry.collocation_scheme_id;
+ carry.collocation_scheme_code = subCarry.collocation_scheme_code;
+ carry.carry_status = ((int)EnumCarryStatus.齐套).ToString();
+ await _db.Updateable(carry).UpdateColumns(it => new { it.collocation_scheme_id, it.collocation_scheme_code, it.carry_status }).ExecuteCommandAsync();
+
+ if (input.isLast)
+ {
+ var kittingout = await _db.Queryable().FirstAsync(it => it.collocation_scheme_id == carry.collocation_scheme_id && it.status == WmsWareHouseConst.BILLSTATUS_CALLED_ID);
+ if (kittingout != null)
+ {
+ WmsPointH sPoint = null!;
+ WmsPointH ePoint = null!;
+
+ var location = await _db.Queryable().SingleAsync(it => it.id == kittingout.location_id);
+ if (kittingout.location_id.IsNullOrWhiteSpace() || (location != null && location.is_type.ToEnum() == EnumLocationType.存储库位))
+ {
+ //入库
+ InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = location.wh_id };
+ var endLocations = await _warehouseService.InStockStrategy(inStockStrategyInput);
+ sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id);
+ if (endLocations?.Count > 0)
+ {
+ ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
+ }
+ }
+ else
+ {
+ if (location != null && location.is_use == (int)EnumCarryStatus.空闲 && location.is_lock == 0)
+ {
+ //出库
+ sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id);
+ ePoint = await _db.Queryable().FirstAsync(it => it.location_id == kittingout.location_id);
+ if (sPoint != null && ePoint != null)
+ {
+ var kittingOutObj = new { requireId = kittingout.id, requireCode = kittingout.bill_code };
+ var preTasks = await _genPreTask(sPoint, ePoint, carry, kittingOutObj);
+ var carryCodes = await _db.Queryable().Where(it => it.carry_id == carry.id).ToListAsync();
+ List pretaskCodes = new();
+ foreach (var pt in preTasks)
+ {
+ var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
+ var curPreTaskCodes = partCodes.Adapt>();
+ curPreTaskCodes.ForEach(x =>
+ {
+ x.id = SnowflakeIdHelper.NextId();
+ x.bill_id = pt.id;
+ x.create_time = DateTime.Now;
+ });
+ pretaskCodes.AddRange(curPreTaskCodes);
+ }
+ await _warehouseService.GenPreTask(preTasks, pretaskCodes);
+ await _db.Updateable(kittingout).UpdateColumns(it => it.status == WmsWareHouseConst.BILLSTATUS_ON_ID).ExecuteCommandAsync();
+ GenPreTaskUpInput genPreTaskAfterUpInput = new();
+ genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
+ genPreTaskAfterUpInput.LocationIds = new List { carry.location_id! };
+ await _warehouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
+ }
+ }
+ else
+ {
+ //入库
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private async Task> _genPreTask(WmsPointH sPoint, WmsPointH ePoint, WmsCarryH carry, dynamic KittingOutObj)
+ {
+ List preTasks = new();
+ var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
+ //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
+ if (points?.Count > 0)
+ {
+ if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
+ preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
+ {
+ var sPoint = it.FirstOrDefault();
+ var ePoint = it.LastOrDefault();
+
+ WmsPretaskH preTask = new();
+ preTask.org_id = _userManager.User.OrganizeId;
+ preTask.startlocation_id = sPoint?.location_id!;
+ preTask.startlocation_code = sPoint?.location_code!;
+ preTask.endlocation_id = ePoint?.location_id!;
+ preTask.endlocation_code = ePoint?.location_code!;
+ preTask.start_floor = sPoint?.floor.ToString();
+ preTask.end_floor = ePoint?.floor.ToString();
+ preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
+ preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
+ preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSKITTINGOUTSTK_ID;
+ preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
+ preTask.carry_id = carry.id!;
+ preTask.carry_code = carry.carry_code!;
+ preTask.area_id = sPoint?.area_id!;
+ preTask.area_code = it.Key;
+ preTask.require_id = KittingOutObj.requireId;
+ preTask.require_code = KittingOutObj.requireCode;
+ preTask.create_id = _userManager.UserId;
+ preTask.create_time = DateTime.Now;
+ return preTask;
+ }).ToList();
+ }
+ return preTasks;
+ }
+ }
+}