机器人回调出库功能
This commit is contained in:
@@ -170,6 +170,11 @@ namespace Tnb.WarehouseMgr.Entities.Consts
|
||||
/// 预任务生成业务类型-配送申请
|
||||
/// </summary>
|
||||
public const string BIZTYPE_WMSDELIVERY_ID = "26585291847957";
|
||||
/// <summary>
|
||||
/// 预任务生成业务类型-载具绑定
|
||||
/// </summary>
|
||||
public const string BIZTYPE_WMSCARRYBIND_ID = "27118595509525";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 条码打印状态-已完成
|
||||
|
||||
@@ -35,5 +35,9 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
|
||||
/// 是否最后一个
|
||||
/// </summary>
|
||||
public bool isLast { get; set; }
|
||||
/// <summary>
|
||||
/// 位置
|
||||
/// </summary>
|
||||
public int loc { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public partial class WmsCarrybindH : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// dataType
|
||||
/// </summary>
|
||||
public int biz_type { get; set; }
|
||||
public int type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 载具分类ID
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 载具绑定服务接口
|
||||
/// </summary>
|
||||
public interface IWmsCarryBindService
|
||||
{
|
||||
Task<dynamic> CarryBind(VisualDevModelDataCrInput input);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// 载具绑定
|
||||
/// </summary>
|
||||
[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<dynamic> CarryBind(VisualDevModelDataCrInput input)
|
||||
[NonAction]
|
||||
public async Task<dynamic> 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<WmsCarryCode>().Where(it => it.carry_id == subCarryId).ToListAsync();
|
||||
List<WmsCarrybindCode> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 机器人回调操作
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task RobotCallBack()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
|
||||
@@ -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<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsHandleH.startlocation_id)].ToString());
|
||||
|
||||
173
WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs
Normal file
173
WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 机器人回调服务类
|
||||
/// </summary>
|
||||
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<WmsCarrybindH> 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<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
|
||||
var subCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.membercarry_id);
|
||||
if (carry != null && subCarry != null)
|
||||
{
|
||||
VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary<string, object>() };
|
||||
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<WmsKittingoutH>().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<BasLocation>().SingleAsync(it => it.id == kittingout.location_id);
|
||||
if (kittingout.location_id.IsNullOrWhiteSpace() || (location != null && location.is_type.ToEnum<EnumLocationType>() == EnumLocationType.存储库位))
|
||||
{
|
||||
//入库
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = location.wh_id };
|
||||
var endLocations = await _warehouseService.InStockStrategy(inStockStrategyInput);
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||
if (endLocations?.Count > 0)
|
||||
{
|
||||
ePoint = await _db.Queryable<WmsPointH>().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<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||
ePoint = await _db.Queryable<WmsPointH>().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<WmsCarryCode>().Where(it => it.carry_id == carry.id).ToListAsync();
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (var pt in preTasks)
|
||||
{
|
||||
var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
|
||||
var curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
|
||||
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<string> { carry.location_id! };
|
||||
await _warehouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//入库
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<WmsPretaskH>> _genPreTask(WmsPointH sPoint, WmsPointH ePoint, WmsCarryH carry, dynamic KittingOutObj)
|
||||
{
|
||||
List<WmsPretaskH> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user