二楼暂存仓逻辑完善,新增外协入库与盘点接收接口

This commit is contained in:
2024-05-09 16:03:37 +08:00
parent 87d8da928a
commit 72ddc61591
10 changed files with 638 additions and 270 deletions

View File

@@ -289,5 +289,18 @@
/// 盘点状态-盘点结账
/// </summary>
public const string CHECKSTATUS_PDJZ_ID = "27584597303317";
/// <summary>
/// 一楼成品出库工位
/// </summary>
public const string FinishproductOutstockStation1 = "30018211902485";
/// <summary>
/// 一楼成品出库工位
/// </summary>
public const string FinishproductOutstockStation2 = "30018225923349";
/// <summary>
/// 一楼成品出库工位
/// </summary>
public const string FinishproductOutstockStation3 = "30018217822229";
}
}

View File

@@ -0,0 +1,23 @@
namespace Tnb.WarehouseMgr.Entities.Dto
{
/// <summary>
/// 库房业务更新输入参数
/// </summary>
public class FinishproductOutstockSortInput
{
/// <summary>
/// 载具id
/// </summary>
public string? carry_id { get; set; }
///// <summary>
///// 物料id
///// </summary>
//public string? material_id { get; set; }
/// <summary>
/// 数量
/// </summary>
public decimal qty { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
namespace Tnb.WarehouseMgr.Entities.Dto
{
/// <summary>
/// 库房业务更新输入参数
/// </summary>
public class FinishproductOutstockSignInput
{
/// <summary>
/// 起点
/// </summary>
public string? location_id { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
namespace Tnb.WarehouseMgr.Entities.Dto
{
/// <summary>
/// 库房业务更新输入参数
/// </summary>
public class OutsourcedPartsInstockInput
{
/// <summary>
/// 载具ID
/// </summary>
public string? carry_id { get; set; }
/// <summary>
/// 物料ID
/// </summary>
public string? material_id { get; set; }
/// <summary>
/// 物料数量
/// </summary>
public decimal qty { get; set; }
/// <summary>
/// 起点
/// </summary>
public string? startlocation_id { get; set; }
}
}

View File

@@ -84,4 +84,9 @@ public partial class WmsMechanicalArmH : BaseEntity<string>
/// 取放货确认
/// </summary>
public int? mechanicalconfirm { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? note { get; set; }
}

View File

@@ -538,6 +538,8 @@ namespace Tnb.WarehouseMgr
}
/// <summary>
/// 申请进出电梯
/// </summary>

View File

@@ -1,9 +1,11 @@
using System.Diagnostics;
using System.Dynamic;
using System.Linq.Expressions;
using System.Net;
using System.Security.Policy;
using System.Threading.Tasks;
using Aop.Api.Domain;
using Aspose.Cells;
using JNPF;
using JNPF.Common.Contracts;
using JNPF.Common.Core.Manager;
@@ -36,6 +38,7 @@ using Tnb.WarehouseMgr.Entities.Configs;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
using Tnb.WarehouseMgr.Entities.Dto.Queries;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Entities.Enums;
@@ -476,16 +479,16 @@ namespace Tnb.WarehouseMgr
else // 去暂存仓放货
{
// 回写料架料箱绑定表的库位
ISugarQueryable<WmsCarrybindH> wmsCarryHs = db.Queryable<WmsCarrybindH>().Where(r => r.carry_code == disTask.carry_code);
var wmsCarryHList = wmsCarryHs.ToList();
wmsCarryHList.ForEach(r =>
ISugarQueryable<WmsCarryCode> WmsCarryCodes = db.Queryable<WmsCarryCode>()
.InnerJoin<WmsCarryD>((a, b) => b.membercarry_id == a.carry_id)
.Where((a, b) => b.carry_id == disTask.carry_id);
var WmsCarryCodeList = WmsCarryCodes.ToList();
WmsCarryCodeList.ForEach(r =>
{
r.location_id = disTask.endlocation_id;
r.location_code = disTask.endlocation_code;
r.source_id = disTask.id;
r.source_code = disTask.bill_code;
});
await db.Updateable(wmsCarryHList).ExecuteCommandAsync();
await db.Updateable(WmsCarryCodeList).ExecuteCommandAsync();
}
}
else
@@ -506,6 +509,25 @@ namespace Tnb.WarehouseMgr
}
WmsMechanicalArmH target = WmsMechanicalArmHs.First();
if (target.note == "上升降机")
{
bool result = await Floor2UpDownMachinecode_SetTag($"上升降机满托{target.stackingposition}移走", "true");
Logger.LogInformation($@"【上升降机】设定升上升降机满托{target.stackingposition}移走 结果为 {result}");
if (!result)
{
throw new Exception($@"【上升降机】设定升上升降机满托{target.stackingposition}移走 结果为 {result}");
}
}
else if (target.note == "下升降机")
{
bool result = await Floor2UpDownMachinecode_SetTag($"下升降机空托{target.stackingposition}移走", "true");
Logger.LogInformation($@"【上升降机】设定升下升降机空托{target.stackingposition}移走 结果为 {result}");
if (!result)
{
throw new Exception($@"【上升降机】设定升下升降机空托{target.stackingposition}移走 结果为 {result}");
}
}
//回写出库单状态
await db.Updateable<WmsEmptyOutstockH>().SetColumns(r => new WmsEmptyOutstockH
{
@@ -532,6 +554,28 @@ namespace Tnb.WarehouseMgr
return true;
}
private async Task<bool> Floor2UpDownMachinecode_SetTag(string tag, string value)
{
string DevName = "东面提升机输送线";
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = DevName,
["token"] = _eleCtlCfg.token,
["TagName"] = tag,
["Value"] = value,
};
string result = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand);
// TODO 测试
//JObject valueJson = new JObject();
//valueJson["Value"] = value;
//bool res = await _redisData.HSet(DevName, tag, valueJson.ToString());
//return true;
return result.Contains("Ok");
}
/// <summary>
/// 生成任务执行
/// </summary>
@@ -1363,6 +1407,12 @@ namespace Tnb.WarehouseMgr
// 一楼中储仓
kiva.Add("ZSSSXCTU02");
kiva.Add("ZSSSXCTU01");
List<string> floor2 = new List<string>();
// 二楼暂存仓
floor2.Add("AS01");
floor2.Add("AS02");
floor2.Add("AX01");
floor2.Add("AX02");
//调用AGV创建任务链接口
try
{
@@ -1378,6 +1428,7 @@ namespace Tnb.WarehouseMgr
sourceName = it.startpoint_code,
targetName = it.endpoint_code,
containerCode = it.carry_code,
shelfNumber = floor2.Contains(it.startlocation_code) || floor2.Contains(it.endlocation_code) ? it.carry_code : "" // 二楼暂存仓传料架
}));
Logger.Information($"【AgvDispatch】 Agv任务执行的taskChainCodeDic{JsonConvert.SerializeObject(taskChainCodeDic)}");
@@ -1386,7 +1437,7 @@ namespace Tnb.WarehouseMgr
{
var typeflag = false;
var dis = disTasks.Where(p => p.groups == k).First();
if (kiva.Contains(dis.startlocation_code) || kiva.Contains(dis.endlocation_code))
if (kiva.Contains(dis.startlocation_code) || kiva.Contains(dis.endlocation_code) || floor2.Contains(dis.startlocation_code) || floor2.Contains(dis.endlocation_code))
{
typeflag = true;
}

View File

@@ -193,17 +193,15 @@ namespace Tnb.WarehouseMgr
WmsCarryH? subCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.membercarry_id);
if (carry != null && subCarry != null)
{
WmsCarrybindH wmsCarrybindH = new()
WmsCarryD wmsCarryD = new()
{
carry_id = input.carry_id,
carry_code = input.carry_code,
membercarry_id = input.membercarry_id,
membercarry_code = input.membercarry_code,
loc = 1,
type = 0,
create_time = DateTime.Now
};
int row = await _db.Insertable(wmsCarrybindH).ExecuteCommandAsync();
int row = await _db.Insertable(wmsCarryD).ExecuteCommandAsync();
isOk = row > 0;
if (!isOk)
{
@@ -243,10 +241,9 @@ namespace Tnb.WarehouseMgr
}
WmsCarryH? carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
WmsCarryH? subCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.membercarry_id);
if (carry != null && subCarry != null)
if (carry != null)
{
int row = await _db.Deleteable<WmsCarrybindH>().Where(r => r.carry_id == input.carry_id && r.membercarry_id == input.membercarry_id).ExecuteCommandAsync();
int row = await _db.Deleteable<WmsCarryD>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
isOk = row > 0;
if (!isOk)
@@ -256,7 +253,7 @@ namespace Tnb.WarehouseMgr
}
else
{
if (carry == null || subCarry == null)
if (carry == null)
{
throw new AppFriendlyException("没有可用的主载具", 500);
}

View File

@@ -8,9 +8,15 @@ using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
{
@@ -25,11 +31,13 @@ namespace Tnb.WarehouseMgr
private readonly IVisualDevService _visualDevService;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
private readonly IWareHouseService _wareHouseService;
public WmsPDACarryBindService(
ISqlSugarRepository<WmsCarryH> repository,
IRunService runService,
IVisualDevService visualDevService,
IUserManager userManager,
IWareHouseService wareHouseService,
IBillRullService billRullService)
{
_db = repository.AsSugarClient();
@@ -37,6 +45,7 @@ namespace Tnb.WarehouseMgr
_visualDevService = visualDevService;
_userManager = userManager;
_billRullService = billRullService;
_wareHouseService = wareHouseService;
OverideFuncs.CreateAsync = PDACarryBind;
}
@@ -130,5 +139,257 @@ namespace Tnb.WarehouseMgr
var isOk = await _db.Updateable<WmsCarryReplaceH>().SetColumns(it => new WmsCarryReplaceH { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
}*/
/// <summary>
/// 1楼到3楼 外协入库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="AppFriendlyException"></exception>
[HttpPost, NonUnify, AllowAnonymous]
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> OutsourcedPartsInstock(OutsourcedPartsInstockInput input)
{
try
{
if (string.IsNullOrEmpty(input.carry_id))
{
throw new AppFriendlyException("载具id不可为空", 500);
}
if (string.IsNullOrEmpty(input.material_id))
{
throw new AppFriendlyException("物料不可为空", 500);
}
if (input.qty <= 0)
{
throw new AppFriendlyException("数量必须大于0", 500);
}
if (string.IsNullOrEmpty(input.startlocation_id))
{
throw new AppFriendlyException("起点不可为空", 500);
}
await s_taskExecuteSemaphore.WaitAsync();
await _db.Ado.BeginTranAsync();
//入库取终点 //出库起点
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = 1 };
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
WmsPointH sPoint = null!;
WmsPointH ePoint = null!;
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.startlocation_id);
if (endLocations?.Count > 0)
{
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
BasLocation loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
if (!isMatch)
{
throw new AppFriendlyException("库位与载具规格不匹配", 500);
}
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
}
else
{
throw new AppFriendlyException($"库位{endLocations[0].location_code}未在点位表中维护对应点位", 500);
}
string endLocationId = endLocations[0].id;
// 在线开发
//VisualDevEntity? templateEntity = await _visualDevService?.GetInfoById(ModuleConsts.MODULE_WMSDELIVERYPDA_ID, true)!;
//await _runService.Create(templateEntity, input);
// 计算路径,插入预任务申请
if (sPoint != null && ePoint != null)
{
List<WmsPointH> points = new List<WmsPointH>();
if (sPoint.area_code != ePoint.area_code)
{
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2)
{
throw new AppFriendlyException("该路径不存在", 500);
}
}
else
{
points.Add(sPoint);
points.Add(ePoint);
}
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.carry_id);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
{
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
WmsPointH? sPoint = it.FirstOrDefault();
WmsPointH? ePoint = it.LastOrDefault();
WmsPretaskH preTask = new()
{
org_id = _userManager!.User.OrganizeId,
startlocation_id = sPoint?.location_id!,
startlocation_code = sPoint?.location_code!,
endlocation_id = ePoint?.location_id!,
endlocation_code = ePoint?.location_code!,
start_floor = sPoint?.floor.ToString(),
end_floor = ePoint?.floor.ToString(),
startpoint_id = sPoint?.id!,
startpoint_code = sPoint?.point_code!,
endpoint_id = ePoint?.id!,
endpoint_code = ePoint?.point_code!,
bill_code = _billRullService!.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
biz_type = WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID,
task_type = WmsWareHouseConst.WMS_PRETASK_TRANSFER_TYPE_ID
};
preTask.carry_id = input.carry_id;
preTask.carry_code = wmsCarryH.carry_code;
preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key;
preTask.require_id = "";
preTask.require_code = "";
preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
bool isOk = await _wareHouseService.GenPreTask(preTasks, null!);
if (isOk)
{
if (endLocationId != null)
{
//查询库位表
BasLocation location = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.startlocation_id);
{
//载具加锁,增加库位信息
_ = await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH
{
carry_status = ((int)EnumCarryStatus.).ToString(),
is_lock = 1,
location_id = input.startlocation_id,
location_code = location.location_code
}).Where(it => it.id == input.carry_id).ExecuteCommandAsync();
}
//所有库位加锁
string?[] ids = new[] { input.startlocation_id, endLocationId };
_ = await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync();
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == input.material_id);
WmsCarryCode wmsCarryCode = new WmsCarryCode();
wmsCarryCode.carry_id = input.carry_id;
wmsCarryCode.barcode = wmsCarryH.carry_code;
wmsCarryCode.codeqty = input.qty;
wmsCarryCode.material_id = input.material_id;
wmsCarryCode.material_code = basMaterial.code;
wmsCarryCode.material_name = basMaterial.name;
wmsCarryCode.location_id = endLocations[0].id;
wmsCarryCode.location_code = endLocations[0].location_code;
_ = await _db.Insertable<WmsCarryCode>(wmsCarryCode).ExecuteCommandAsync();
}
}
}
}
await _db.Ado.CommitTranAsync();
}
catch (Exception)
{
await _db.Ado.RollbackTranAsync();
throw;
}
finally
{
_ = s_taskExecuteSemaphore.Release();
await InvokeGenPretaskExcute();
}
return await ToApiResult(HttpStatusCode.OK, "成功");
}
/// <summary>
/// 3楼到1楼出库 盘点签收 解锁一楼库位
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost, NonUnify, AllowAnonymous]
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> FinishproductOutstockSign(FinishproductOutstockSignInput input)
{
if (string.IsNullOrEmpty(input.location_id))
{
throw new AppFriendlyException("起点id不可为空", 500);
}
if (input.location_id != WmsWareHouseConst.FinishproductOutstockStation1 && input.location_id != WmsWareHouseConst.FinishproductOutstockStation2
&& input.location_id != WmsWareHouseConst.FinishproductOutstockStation3)
{
throw new AppFriendlyException("非一楼出库库位不允许通过此功能解锁", 500);
}
await _db.Ado.BeginTranAsync();
try
{
await _db.Updateable<BasLocation>().SetColumns(r => new BasLocation
{
is_lock = 0,
is_use = "0"
}).Where(r => r.id == input.location_id).ExecuteCommandAsync();
await _db.Updateable<WmsPointH>().SetColumns(r => new WmsPointH
{
is_lock = 0
}).Where(r => r.location_id == input.location_id).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await _db.Ado.RollbackTranAsync();
throw;
}
return await ToApiResult(HttpStatusCode.OK, "成功");
}
/// <summary>
/// 3楼到1楼出库 盘点签收 解锁一楼库位
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost, NonUnify, AllowAnonymous]
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> FinishproductOutstockSort(FinishproductOutstockSortInput input)
{
if (string.IsNullOrEmpty(input.carry_id))
{
throw new AppFriendlyException("载具id不可为空", 500);
}
if (input.qty <= 0)
{
throw new AppFriendlyException("数量必须大于0", 500);
}
await _db.Ado.BeginTranAsync();
try
{
await _db.Updateable<WmsCarryCode>().SetColumns(r => new WmsCarryCode
{
codeqty = input.qty,
}).Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await _db.Ado.RollbackTranAsync();
throw;
}
return await ToApiResult(HttpStatusCode.OK, "成功");
}
}
}