包材入库 包材出库 PDA空载具出库bug、其它bug处理
This commit is contained in:
@@ -105,6 +105,13 @@ public class ModuleConsts
|
||||
/// <summary>
|
||||
/// 模块标识-生产退料单 todo
|
||||
public const string MODULE_WMSPRDRETURN_ID = "MODULE_WMSPRDRETURN_ID";
|
||||
/// <summary>
|
||||
/// 模块标识-四楼包材入库 todo
|
||||
public const string MODULE_WMSPACKINSTOCK_ID = "MODULE_WMSPACKINSTOCK_ID";
|
||||
/// <summary>
|
||||
/// 模块标识-四楼包材出库 todo
|
||||
public const string MODULE_WMSPACKOUTSTOCK_ID = "MODULE_WMSPACKOUTSTOCK_ID";
|
||||
|
||||
/// <summary>
|
||||
/// 模块标识-载具绑定
|
||||
/// </summary>
|
||||
|
||||
@@ -53,7 +53,10 @@
|
||||
/// 四楼灭菌仓
|
||||
/// </summary>
|
||||
public const string WAREHOUSE_MJC_ID = "35412482304021";
|
||||
|
||||
/// <summary>
|
||||
/// 二楼包材区
|
||||
/// </summary>
|
||||
public const string WAREHOUSE_F2BCQ_ID = "35434198944789";
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -277,6 +280,14 @@
|
||||
/// </summary>
|
||||
public const string BIZTYPE_PRDRETURN_ID = "BIZTYPE_PRDRETURN_ID";
|
||||
/// <summary>
|
||||
/// 预任务生成业务类型-包材入库 todo
|
||||
/// </summary>
|
||||
public const string BIZTYPE_WMSPACKINSTOCK_ID = "BIZTYPE_WMSPACKINSTOCK_ID";
|
||||
/// <summary>
|
||||
/// 预任务生成业务类型-包材出库 todo
|
||||
/// </summary>
|
||||
public const string BIZTYPE_WMSPACKOUTSTOCK_ID = "BIZTYPE_WMSPACKOUTSTOCK_ID";
|
||||
/// <summary>
|
||||
/// 预任务生成业务类型-载具绑定
|
||||
/// </summary>
|
||||
public const string BIZTYPE_WMSCARRYBIND_ID = "27118595509525";
|
||||
|
||||
@@ -46,6 +46,11 @@
|
||||
/// 任务执行区域
|
||||
/// </summary>
|
||||
public string area_code { get; set; }
|
||||
/// <summary>
|
||||
/// 任务执行
|
||||
/// </summary>
|
||||
public WmsDistaskH wmsDistaskH { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,6 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
|
||||
{
|
||||
public class WmsElevatorUnlockInput
|
||||
{
|
||||
public string? elevator_id { get; set; }
|
||||
public string? elevator_code { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
122
WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPackInstockD.cs
Normal file
122
WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPackInstockD.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 包材入库子表
|
||||
/// </summary>
|
||||
[SugarTable("wms_pack_instock_d")]
|
||||
public partial class WmsPackInstockD : BaseEntity<string>
|
||||
{
|
||||
public WmsPackInstockD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库单ID
|
||||
/// </summary>
|
||||
public string? bill_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行状态
|
||||
/// </summary>
|
||||
public string? status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料代码
|
||||
/// </summary>
|
||||
public string? material_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主单位
|
||||
/// </summary>
|
||||
public string? unit_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位代码
|
||||
/// </summary>
|
||||
public string? unit_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库需求数量
|
||||
/// </summary>
|
||||
public decimal? pr_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已下发数量
|
||||
/// </summary>
|
||||
public decimal? xf_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际入库数量
|
||||
/// </summary>
|
||||
public decimal? qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格
|
||||
/// </summary>
|
||||
public string? material_specification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批号
|
||||
/// </summary>
|
||||
public string? pi_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料描述
|
||||
/// </summary>
|
||||
public string? material_desc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 型号
|
||||
/// </summary>
|
||||
public string? model { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 辅数量
|
||||
/// </summary>
|
||||
public string? fu_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 包材入库主表
|
||||
/// </summary>
|
||||
[SugarTable("wms_pack_instock_h")]
|
||||
public partial class WmsPackInstockH : BaseEntity<string>
|
||||
{
|
||||
public WmsPackInstockH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 审核员
|
||||
/// </summary>
|
||||
public string? auditor_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 审核状态
|
||||
/// </summary>
|
||||
public int? audit_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库单号
|
||||
/// </summary>
|
||||
public string? bill_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库单创建日期
|
||||
/// </summary>
|
||||
public DateTime? bill_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据状态
|
||||
/// </summary>
|
||||
public string? status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型
|
||||
/// </summary>
|
||||
public string? code_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库仓库
|
||||
/// </summary>
|
||||
public string? incoming_ware { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 包材出库子表
|
||||
/// </summary>
|
||||
[SugarTable("wms_pack_outstock_d")]
|
||||
public partial class WmsPackOutstockD : BaseEntity<string>
|
||||
{
|
||||
public WmsPackOutstockD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 包材出库单ID
|
||||
/// </summary>
|
||||
public string? bill_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行状态
|
||||
/// </summary>
|
||||
public string? line_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料代码
|
||||
/// </summary>
|
||||
public string? material_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位ID
|
||||
/// </summary>
|
||||
public string? unit_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发货数量
|
||||
/// </summary>
|
||||
public decimal? qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已发货数量
|
||||
/// </summary>
|
||||
public decimal? prqty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展字段
|
||||
/// </summary>
|
||||
public string? extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳
|
||||
/// </summary>
|
||||
public DateTime? time_stamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批次
|
||||
/// </summary>
|
||||
public string? code_batch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 本次发货数量
|
||||
/// </summary>
|
||||
public decimal? sendqty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格型号
|
||||
/// </summary>
|
||||
public string? material_specification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱号
|
||||
/// </summary>
|
||||
public string? container_no { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 质检结果
|
||||
/// </summary>
|
||||
public string? qc_res { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 包材出库主表
|
||||
/// </summary>
|
||||
[SugarTable("wms_pack_outstock_h")]
|
||||
public partial class WmsPackOutstockH : BaseEntity<string>
|
||||
{
|
||||
public WmsPackOutstockH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 包材出库单号
|
||||
/// </summary>
|
||||
public string? bill_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型
|
||||
/// </summary>
|
||||
public string? bill_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据状态
|
||||
/// </summary>
|
||||
public string? status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 业务类型
|
||||
/// </summary>
|
||||
public string? biz_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库仓库ID
|
||||
/// </summary>
|
||||
public string? warehouse_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户ID
|
||||
/// </summary>
|
||||
public string? customer_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户代码
|
||||
/// </summary>
|
||||
public string? customer_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
public string? customer_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生成类型
|
||||
/// </summary>
|
||||
public string? generate_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展字段
|
||||
/// </summary>
|
||||
public string? extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳
|
||||
/// </summary>
|
||||
public DateTime? time_stamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单据ID
|
||||
/// </summary>
|
||||
public string? source_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单据代码
|
||||
/// </summary>
|
||||
public string? source_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 审核员
|
||||
/// </summary>
|
||||
public string? auditor_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 审核状态
|
||||
/// </summary>
|
||||
public string? audit_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
}
|
||||
@@ -69,6 +69,13 @@ namespace Tnb.WarehouseMgr.Interfaces
|
||||
/// <returns></returns>
|
||||
string[] GetFloor1OutstockLocation();
|
||||
|
||||
/// <summary>
|
||||
/// 是否为二楼包材出库工位
|
||||
/// </summary>
|
||||
/// <param name="location_id"></param>
|
||||
/// <returns></returns>
|
||||
string[] GetFloor2BCOutstockLocation();
|
||||
|
||||
/// <summary>
|
||||
/// 是否为供料三工位库位
|
||||
/// </summary>
|
||||
|
||||
@@ -457,10 +457,10 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
if (wmsDistaskH.startlocation_code.Contains("DT") || wmsDistaskH.endlocation_code.Contains("DT"))
|
||||
{
|
||||
WmsElevatorUnlockInput wmsElevatorUnlockInput = new ();
|
||||
wmsElevatorUnlockInput.elevator_id = wmsDistaskH.device_id;
|
||||
await WmsElevatorUnlock(wmsElevatorUnlockInput);
|
||||
Logger.Information($"WCS取消任务{wmsDistaskH.bill_code},自动解占用电梯{wmsDistaskH.device_id}");
|
||||
//WmsElevatorUnlockInput wmsElevatorUnlockInput = new ();
|
||||
//wmsElevatorUnlockInput.elevator_id = wmsDistaskH.device_id;
|
||||
//await WmsElevatorUnlock(wmsElevatorUnlockInput);
|
||||
//Logger.Information($"WCS取消任务{wmsDistaskH.bill_code},自动解占用电梯{wmsDistaskH.device_id}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -679,15 +679,22 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Information($"【WmsElevatorUnlock】操作电梯{input.elevator_id}手动解锁");
|
||||
WmsElevatorH wmsElevatorH = await _db.Queryable<WmsElevatorH>().Where(r => r.elevator_code == input.elevator_code).FirstAsync();
|
||||
if (wmsElevatorH == null)
|
||||
{
|
||||
Logger.LogWarning($"未找到电梯{input.elevator_code}的配置");
|
||||
throw new Exception($"未找到电梯{input.elevator_code}的配置");
|
||||
}
|
||||
Logger.Information($"【WmsElevatorUnlock】操作电梯{input.elevator_code}手动解锁");
|
||||
await _db.Updateable<WmsElevatorH>().SetColumns(r => r.is_use == (int)EnumElevatorUseStatus.空闲)
|
||||
.Where(it => it.elevator_id == input.elevator_id).ExecuteCommandAsync();
|
||||
s_eleUseStatusDic[input.elevator_id] = (int)EnumElevatorUseStatus.空闲;
|
||||
.Where(it => it.elevator_id == wmsElevatorH.elevator_id).ExecuteCommandAsync();
|
||||
s_eleUseStatusDic[wmsElevatorH.elevator_id] = (int)EnumElevatorUseStatus.空闲;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("【ElevatorConfirm】 申请进出电梯信号错误", ex);
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, "请重试!");
|
||||
Logger.Error("【WmsElevatorUnlock】 操作电梯手动解锁异常", ex.Message);
|
||||
Logger.Error("【WmsElevatorUnlock】 操作电梯手动解锁异常", ex.StackTrace);
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, "操作电梯手动解锁异常:" + ex.Message);
|
||||
throw;
|
||||
}
|
||||
return await ToApiResult(HttpStatusCode.OK, "解锁成功");
|
||||
|
||||
@@ -5,8 +5,10 @@ using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.EventBus;
|
||||
using JNPF.EventHandler;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NPOI.OpenXmlFormats.Dml.Diagram;
|
||||
using Tnb.Common.Extension;
|
||||
using Tnb.Common.Utils;
|
||||
@@ -53,7 +55,9 @@ namespace Tnb.WarehouseMgr
|
||||
["Value"] = "123",
|
||||
["token"] = _elevatorControlConfiguration.token
|
||||
};
|
||||
Log.Information($"{devName.Match(@"\d+")}#梯, 心跳检测");
|
||||
string result = await HttpClientHelper.GetAsync(_elevatorControlConfiguration.WriteTagUrl, pars: parameter);
|
||||
Log.Information($"{devName.Match(@"\d+")}#梯, 心跳检测结果:{result}");
|
||||
|
||||
//var result = await RedisHelper.HSetAsync(devName, ElevatorConsts.AGVKeepalive, "123");
|
||||
await Console.Out.WriteLineAsync($"{devName.Match(@"\d+")}#梯, 心跳检测结果:{result}");
|
||||
|
||||
@@ -246,6 +246,16 @@ namespace Tnb.WarehouseMgr
|
||||
, "30018211902485"};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为二楼包材出库工位
|
||||
/// </summary>
|
||||
/// <param name="location_id"></param>
|
||||
/// <returns></returns>
|
||||
public string[] GetFloor2BCOutstockLocation()
|
||||
{
|
||||
return new string[1] { "30018211902485" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为供料三工位库位
|
||||
/// </summary>
|
||||
@@ -2227,7 +2237,7 @@ namespace Tnb.WarehouseMgr
|
||||
List<WmsDistaskCode> disTaskCodes = await _db.Queryable<WmsDistaskCode>().Where(it => it.bill_id == dt.id).ToListAsync();
|
||||
WareHouseUpInput upInput = new() { bizTypeId = dt.biz_type, requireId = dt.require_id!, require_code = dt.require_code!, source_id = dt.source_id!
|
||||
, source_code = dt.source_code!, distaskCodes = disTaskCodes, carryIds = disTasks.Select(x => x.carry_id).ToList(),
|
||||
bill_code = dt.bill_code!,area_code= dt.area_code!
|
||||
bill_code = dt.bill_code!,area_code= dt.area_code!,wmsDistaskH = dt!
|
||||
};
|
||||
|
||||
/*if (!_userManager?.LoginType.IsNullOrEmpty() ?? false)
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace Tnb.WarehouseMgr
|
||||
//{
|
||||
// preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||
//}
|
||||
isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
|
||||
|
||||
if (isOk)
|
||||
{
|
||||
@@ -233,7 +233,7 @@ namespace Tnb.WarehouseMgr
|
||||
_ = await _db.Updateable<WmsEmptyOutstockH>().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { is_lock = 1 },
|
||||
it => new BasLocation { is_lock = 1 });
|
||||
it => new BasLocation { is_lock = 1 }, _db);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace Tnb.WarehouseMgr
|
||||
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
|
||||
commonCreatePretaskInput.isExcuteMission = false;
|
||||
|
||||
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput);
|
||||
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput, _db);
|
||||
|
||||
if (res.code != HttpStatusCode.OK)
|
||||
{
|
||||
|
||||
@@ -294,7 +294,7 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
|
||||
if (isOk)
|
||||
{
|
||||
if (endLocationId != null)
|
||||
@@ -372,7 +372,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 3楼到1楼出库 盘点签收 解锁一楼库位
|
||||
/// 盘点签收
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -61,10 +61,9 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
try
|
||||
{
|
||||
Logger.Information("开始PDA空载具出库");
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTKPDA_ID, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
|
||||
//判断目标库位是否自动签收
|
||||
BasLocation loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||
@@ -85,8 +84,15 @@ namespace Tnb.WarehouseMgr
|
||||
int i = 0;
|
||||
bool isOk = false;
|
||||
|
||||
Logger.Information($"PDA空载具出库实际可出载具数量:{carrys.Count}");
|
||||
|
||||
if (int.Parse(input.data["qty"].ToString())> carrys.Count)
|
||||
{
|
||||
throw new AppFriendlyException($"实际可出空载具数量只有 {carrys.Count}", 500);
|
||||
}
|
||||
|
||||
//根据每个载具的起始库位做路径运算
|
||||
for (i = 0; i < setQty.qty; i++)
|
||||
for (i = 0; i < int.Parse(input.data["qty"].ToString()); i++)
|
||||
{
|
||||
|
||||
if (carrys?.Count > 0)
|
||||
@@ -96,14 +102,26 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
List<WmsPointH>? points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
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($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points.Add(sPoint);
|
||||
points.Add(ePoint);
|
||||
}
|
||||
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTKPDA_ID, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
|
||||
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
@@ -143,7 +161,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||
}
|
||||
isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
|
||||
|
||||
}
|
||||
if (isOk)
|
||||
@@ -175,37 +193,39 @@ namespace Tnb.WarehouseMgr
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//生成操作记录表
|
||||
WmsHandleH handleH = new()
|
||||
{
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
startlocation_id = carrys?[i].location_id!,
|
||||
endlocation_id = ePoint!.location_id!,
|
||||
bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!,
|
||||
carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!,
|
||||
carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!,
|
||||
require_id = input.data["ReturnIdentity"].ToString(),
|
||||
require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
preTaskUpInput.PreTaskRecord = handleH;
|
||||
//WmsHandleH handleH = new()
|
||||
//{
|
||||
// org_id = _userManager.User.OrganizeId,
|
||||
// startlocation_id = carrys?[i].location_id!,
|
||||
// endlocation_id = ePoint!.location_id!,
|
||||
// bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!,
|
||||
// carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!,
|
||||
// carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!,
|
||||
// require_id = input.data["ReturnIdentity"].ToString(),
|
||||
// require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// create_id = _userManager.UserId,
|
||||
// create_time = DateTime.Now
|
||||
//};
|
||||
//preTaskUpInput.PreTaskRecord = handleH;
|
||||
//根据空载具出库Id,回更单据状态
|
||||
_ = await _db.Updateable<WmsEmptyOutstockH>().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
||||
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 });
|
||||
it => new BasLocation { is_lock = 1 }, _db);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("空载具出库错误", ex);
|
||||
Log.Error("PDA空载具出库错误", ex.Message);
|
||||
Log.Error("PDA空载具出库错误", ex.StackTrace);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
326
WarehouseMgr/Tnb.WarehouseMgr/WmsPackInstockService.cs
Normal file
326
WarehouseMgr/Tnb.WarehouseMgr/WmsPackInstockService.cs
Normal file
@@ -0,0 +1,326 @@
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.POIFS.Storage;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
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.Entity;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSPACKINSTOCK_ID)]
|
||||
[ServiceModule(BizTypeId)]
|
||||
public class WmsPackInstockService : BaseWareHouseService, IWmsPrdReturnService
|
||||
{
|
||||
private const string BizTypeId = WmsWareHouseConst.BIZTYPE_WMSPACKINSTOCK_ID;
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
private readonly IWmsCarryBindService _wmsCarryBindService;
|
||||
private readonly IBillRullService _billRullService;
|
||||
public static SemaphoreSlim s_packInstockSemaphore = new(1);
|
||||
private readonly IWmsCarryService _wmsCarryService;
|
||||
public WmsPackInstockService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IWareHouseService wareHouseService,
|
||||
IUserManager userManager,
|
||||
IWmsCarryBindService wmsCarryBindService,
|
||||
IBillRullService billRullService,
|
||||
IWmsCarryService wmsCarryService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_userManager = userManager;
|
||||
_wareHouseService = wareHouseService;
|
||||
_wmsCarryBindService = wmsCarryBindService;
|
||||
_billRullService = billRullService;
|
||||
_wmsCarryService = wmsCarryService;
|
||||
}
|
||||
|
||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//if (input.wmsDistaskH.start_floor == 4 && input.wmsDistaskH.end_floor == 4)
|
||||
{
|
||||
WmsCarryCode wmsCarryCode = await _db.Queryable<WmsCarryCode>().Where(r => r.carry_id == input.wmsDistaskH.carry_id).FirstAsync();
|
||||
await _db.Updateable<WmsPackInstockD>().SetColumns(r => r.qty == r.qty + wmsCarryCode.codeqty).Where(r => r.id == input.wmsDistaskH.require_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError("【WmsPackInstockService ModifyAsync】" + ex.Message);
|
||||
Logger.LogError("【WmsPackInstockService ModifyAsync】" + ex.StackTrace);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<dynamic> List(TransferInstockHListInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
JObject jobject = new JObject();
|
||||
jobject["code"] = "200";
|
||||
|
||||
List<WmsPackInstockD> wmsPackInstockD = _db.Queryable<WmsPackInstockD>().Where(r => r.bill_id == input.id && r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList();
|
||||
|
||||
|
||||
jobject["data"] = JArray.Parse(JsonConvert.SerializeObject(wmsPackInstockD));
|
||||
return await Task.FromResult(jobject);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Task.FromResult(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 1楼到4楼 包材入库
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> PackInstock(OutsourcedPartsInstockInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.carry_code))
|
||||
{
|
||||
throw new AppFriendlyException("载具编号不可为空", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.material_id))
|
||||
{
|
||||
throw new AppFriendlyException("物料id不可为空", 500);
|
||||
}
|
||||
if (input.qty <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("数量必须大于0", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.source_id))
|
||||
{
|
||||
throw new AppFriendlyException("包材入库明细id不可为空", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.startlocation_id))
|
||||
{
|
||||
throw new AppFriendlyException("起点不可为空", 500);
|
||||
}
|
||||
|
||||
WmsPackInstockD wmsPackInstockD = await _db.Queryable<WmsPackInstockD>().Where(r => r.id == input.source_id).FirstAsync();
|
||||
if (wmsPackInstockD.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID)
|
||||
{
|
||||
throw new AppFriendlyException("此包材入库任务已完成,不允许重复提交", 500);
|
||||
}
|
||||
await s_packInstockSemaphore.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
//入库取终点 //出库起点
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_BCK_ID, Size = 1 };
|
||||
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
if (endLocations.Count == 0)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的入库库位", 500);
|
||||
}
|
||||
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.carry_code == input.carry_code);
|
||||
if (carry.carry_status == "1")
|
||||
{
|
||||
throw new AppFriendlyException("载具已占用!", 500);
|
||||
}
|
||||
if (carry.is_lock == 1)
|
||||
{
|
||||
throw new AppFriendlyException("载具已锁定!", 500);
|
||||
}
|
||||
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;
|
||||
|
||||
// 计算路径,插入预任务申请
|
||||
|
||||
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($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points.Add(sPoint);
|
||||
points.Add(ePoint);
|
||||
}
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == input.carry_code);
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
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_WMSPACKINSTOCK_ID,
|
||||
task_type = WmsWareHouseConst.WMS_PRETASK_TRANSFER_TYPE_ID
|
||||
};
|
||||
preTask.carry_id = wmsCarryH.id;
|
||||
preTask.carry_code = wmsCarryH.carry_code;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
preTask.area_code = it.Key;
|
||||
preTask.require_id = input.source_id;
|
||||
preTask.require_code = "";
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
|
||||
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 == wmsCarryH.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);
|
||||
|
||||
BindCarryCodeInput bindCarryCodeInput = new BindCarryCodeInput();
|
||||
|
||||
bindCarryCodeInput.carry_id = wmsCarryH.id;
|
||||
bindCarryCodeInput.barcode = wmsCarryH.carry_code;
|
||||
bindCarryCodeInput.codeqty = input.qty;
|
||||
bindCarryCodeInput.material_id = input.material_id;
|
||||
bindCarryCodeInput.material_code = basMaterial.code;
|
||||
bindCarryCodeInput.material_name = basMaterial.name;
|
||||
bindCarryCodeInput.location_id = endLocations[0].id;
|
||||
bindCarryCodeInput.location_code = endLocations[0].location_code;
|
||||
bindCarryCodeInput.code_batch = wmsPackInstockD.pi_code;
|
||||
bindCarryCodeInput.unit_id = basMaterial.unit_id;
|
||||
|
||||
await _wmsCarryService.BindCarryMaterial(bindCarryCodeInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 更新包材入库单子表已下发数量
|
||||
await _db.Updateable<WmsPackInstockD>().SetColumns(r => r.xf_qty == r.xf_qty + input.qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
|
||||
|
||||
// 已下发数量达到需求数量回写已完成
|
||||
wmsPackInstockD = await _db.Queryable<WmsPackInstockD>().Where(r => r.id == input.source_id).FirstAsync();
|
||||
if (wmsPackInstockD.xf_qty == wmsPackInstockD.pr_qty)
|
||||
{
|
||||
await _db.Updateable<WmsPackInstockD>().SetColumns(r => r.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).Where(r => r.id == input.source_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
// 入库明细都完成 回写主表完成状态
|
||||
List<WmsPackInstockD> wmsPackInstockDs = _db.Queryable<WmsPackInstockD>().InnerJoin<WmsPackInstockD>((a, b) => a.bill_id == b.bill_id).Where((a, b) => a.id == input.source_id)
|
||||
.Where((a, b) => b.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList();
|
||||
if (wmsPackInstockDs.Count == 0)
|
||||
{
|
||||
await _db.Updateable<WmsPackInstockH>().SetColumns(r => r.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).Where(r => r.id == wmsPackInstockD.bill_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = s_packInstockSemaphore.Release();
|
||||
await InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
271
WarehouseMgr/Tnb.WarehouseMgr/WmsPackOutstockService.cs
Normal file
271
WarehouseMgr/Tnb.WarehouseMgr/WmsPackOutstockService.cs
Normal file
@@ -0,0 +1,271 @@
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.FriendlyException;
|
||||
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 Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.POIFS.Storage;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
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.Entity;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSPACKOUTSTOCK_ID)]
|
||||
[ServiceModule(BizTypeId)]
|
||||
public class WmsPackOutstockService : BaseWareHouseService, IWmsPrdReturnService
|
||||
{
|
||||
private const string BizTypeId = WmsWareHouseConst.BIZTYPE_WMSPACKOUTSTOCK_ID;
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
private readonly IWmsCarryBindService _wmsCarryBindService;
|
||||
private readonly IBillRullService _billRullService;
|
||||
public static SemaphoreSlim s_packOutstockSemaphore = new(1);
|
||||
private readonly IWmsCarryUnbindService _wmsCarryUnbindService;
|
||||
public WmsPackOutstockService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IWareHouseService wareHouseService,
|
||||
IUserManager userManager,
|
||||
IWmsCarryBindService wmsCarryBindService,
|
||||
IWmsCarryUnbindService wmsCarryUnbindService,
|
||||
IBillRullService billRullService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_userManager = userManager;
|
||||
_wareHouseService = wareHouseService;
|
||||
_wmsCarryBindService = wmsCarryBindService;
|
||||
_wmsCarryUnbindService = wmsCarryUnbindService;
|
||||
_billRullService = billRullService;
|
||||
}
|
||||
|
||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// TODO 二楼工位放货完成后更新出库明细的实际出库数量
|
||||
//if (input.wmsDistaskH.start_floor == 2 && input.wmsDistaskH.end_floor == 2)
|
||||
{
|
||||
WmsCarryCode wmsCarryCode = await _db.Queryable<WmsCarryCode>().Where(r => r.carry_id == input.wmsDistaskH.carry_id).FirstAsync();
|
||||
await _db.Updateable<WmsPackOutstockD>().SetColumns(r => r.prqty == r.prqty + wmsCarryCode.codeqty).Where(r => r.id == input.wmsDistaskH.require_id).ExecuteCommandAsync();
|
||||
|
||||
CarryCodeUnbindInput carryCodeUnbindInput = new CarryCodeUnbindInput();
|
||||
carryCodeUnbindInput.carry_id = input.wmsDistaskH.carry_id;
|
||||
await _wmsCarryUnbindService.CarryCodeUnbind(carryCodeUnbindInput, _db);
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError("【WmsPackOutStockService ModifyAsync】" + ex.Message);
|
||||
Logger.LogError("【WmsPackOutStockService ModifyAsync】" + ex.StackTrace);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料库存
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> MaterialInventory(MaterialTransferGetMaterialInventoryInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (input.palletCount <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("托盘数必须大于0", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.material_id))
|
||||
{
|
||||
throw new AppFriendlyException("物料id不可为空", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.code_batch))
|
||||
{
|
||||
throw new AppFriendlyException("批号不可为空", 500);
|
||||
}
|
||||
|
||||
//入库取终点 //出库起点
|
||||
OutStockStrategyQuery inStockStrategyInput = new()
|
||||
{
|
||||
warehouse_id = WmsWareHouseConst.WAREHOUSE_BCK_ID,
|
||||
material_id = input.material_id,
|
||||
code_batch = input.code_batch,
|
||||
Size = input.palletCount
|
||||
};
|
||||
List<WmsCarryH> items = await _wareHouseService.OutStockStrategyYCL(inStockStrategyInput);
|
||||
|
||||
decimal qty = _db.Queryable<WmsCarryCode>().Where(r => items.Select(a => a.id).Contains(r.carry_id) && r.material_id == input.material_id && r.code_batch == input.code_batch).Sum(r => r.codeqty);
|
||||
|
||||
JObject keyValuePairs = new JObject();
|
||||
keyValuePairs["realPalletCount"] = items.Count;
|
||||
keyValuePairs["realInvQty"] = qty;
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功", keyValuePairs);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按托下发
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> Distribute(MaterialTransferDistributeInput input)
|
||||
{
|
||||
Logger.LogInformation($"【Distribute】 包材出库下发");
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.source_id))
|
||||
{
|
||||
throw new AppFriendlyException("来源单据id不可为空", 500);
|
||||
}
|
||||
if (input.palletCount <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("托盘数必须大于0", 500);
|
||||
}
|
||||
if (input.qty <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("数量必须大于0", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.code_batch))
|
||||
{
|
||||
throw new AppFriendlyException("批号不可为空", 500);
|
||||
}
|
||||
|
||||
WmsPackOutstockD wmsPackOutstockD = await _db.Queryable<WmsPackOutstockD>().FirstAsync(it => it.id == input.source_id);
|
||||
WmsPackOutstockH wmsPackOutstockH = await _db.Queryable<WmsPackOutstockH>().FirstAsync(it => it.id == wmsPackOutstockD.bill_id);
|
||||
|
||||
if (wmsPackOutstockD.prqty == wmsPackOutstockD.qty)
|
||||
{
|
||||
throw new AppFriendlyException("已下发数量已达到出库数量", 500);
|
||||
}
|
||||
|
||||
await s_packOutstockSemaphore.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
//入库取终点 //出库起点
|
||||
OutStockStrategyQuery outStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_BCK_ID, material_id = wmsPackOutstockD.material_id, code_batch = input.code_batch, Size = input.palletCount };
|
||||
List<WmsCarryH> items = await _wareHouseService.OutStockStrategyYCL(outStockStrategyInput);
|
||||
|
||||
if (items.Count == 0)
|
||||
{
|
||||
throw new AppFriendlyException($@"没有可以出库的载具", 500);
|
||||
}
|
||||
|
||||
decimal qty = _db.Queryable<WmsCarryCode>().Where(r => items.Select(a => a.id).Contains(r.carry_id) && r.material_id == wmsPackOutstockD.material_id && r.code_batch == input.code_batch).Sum(r => r.codeqty);
|
||||
|
||||
// 暂定PDA上查询到的物料批次和库存数量与提交时获取的不一致时,需要前台重新获取库存接口
|
||||
if (input.palletCount != items.Count || input.qty != qty)
|
||||
{
|
||||
throw new AppFriendlyException($@"当前实际托盘数量为{input.palletCount} 实际库存数量为{qty},与前台数据不一致,请重新获取库存", HttpStatusCode.InternalServerError);
|
||||
}
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_F2BCQ_ID, Size = input.palletCount };
|
||||
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
if (endLocations.Count == 0)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的入库库位", 500);
|
||||
}
|
||||
|
||||
if (endLocations.Count() < input.palletCount)
|
||||
{
|
||||
throw new AppFriendlyException($@"可用的终点库位数量为{endLocations.Count()}个 下发数量为{input.palletCount}个 请检查终点库位的锁定和占用状态", 500);
|
||||
}
|
||||
|
||||
foreach (var wmsCarryH in items)
|
||||
{
|
||||
WmsCarryCode wmsCarryCode = await _db.Queryable<WmsCarryCode>().Where(r => r.carry_id == wmsCarryH.id).FirstAsync();
|
||||
BasLocation startLocation = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
|
||||
|
||||
InStockStrategyQuery _inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_F2BCQ_ID, Size = 1 };
|
||||
List<BasLocation> _endLocations = await _wareHouseService.InStockStrategy(_inStockStrategyInput);
|
||||
|
||||
BasLocation endLocation = _endLocations.First();
|
||||
if (endLocation == null)
|
||||
{
|
||||
throw new AppFriendlyException($@"没有可用的终点库位!请检查终点库位的锁定和占用状态", 500);
|
||||
}
|
||||
|
||||
CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput();
|
||||
commonCreatePretaskInput.startlocation_id = startLocation.id;
|
||||
commonCreatePretaskInput.endlocation_id = endLocation.id;
|
||||
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
|
||||
commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSPACKOUTSTOCK_ID;
|
||||
commonCreatePretaskInput.require_id = input.source_id;
|
||||
commonCreatePretaskInput.carry_id = wmsCarryH.id;
|
||||
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
|
||||
commonCreatePretaskInput.isExcuteMission = false;
|
||||
|
||||
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput, _db);
|
||||
|
||||
if (res.code != HttpStatusCode.OK)
|
||||
{
|
||||
Logger.LogInformation($@"生成预任务失败");
|
||||
throw new AppFriendlyException($@"生成预任务失败", 500);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新子表已下发数量
|
||||
await _db.Updateable<WmsPackOutstockD>().SetColumns(r => r.sendqty == r.sendqty + input.qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
Logger.LogInformation($"【Distribute】 包材出库下发完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
Logger.LogError("【Distribute】 包材出库" + ex.Message);
|
||||
Logger.LogError("【Distribute】 包材出库" + ex.StackTrace);
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = s_packOutstockSemaphore.Release();
|
||||
InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,8 +121,21 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
}
|
||||
|
||||
//try
|
||||
//{
|
||||
// WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.id == input.carryIds[0]).FirstAsync();
|
||||
|
||||
|
||||
// await _db.Ado.CommitTranAsync();
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// Logger.LogError("【WmsSaleService ModifyAsync】" + ex.Message);
|
||||
// Logger.LogError("【WmsSaleService ModifyAsync】" + ex.StackTrace);
|
||||
// await _db.Ado.RollbackTranAsync();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -259,7 +272,7 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
|
||||
if (isOk)
|
||||
{
|
||||
if (endLocationId != null)
|
||||
@@ -334,8 +347,8 @@ namespace Tnb.WarehouseMgr
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
Logger.LogError($"【Distribute】 {ex.Message}");
|
||||
Logger.LogError($"【Distribute】 {ex.StackTrace}");
|
||||
Logger.LogError($"【Distribute】 销售出库 {ex.Message}");
|
||||
Logger.LogError($"【Distribute】 销售出库 {ex.StackTrace}");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
@@ -395,5 +408,9 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,27 +104,5 @@ namespace Tnb.WarehouseMgr
|
||||
return await UpdateChackStatus<WmsOutstockH>(input);
|
||||
}
|
||||
|
||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
//if (input == null)
|
||||
//{
|
||||
// throw new ArgumentNullException(nameof(input));
|
||||
//}
|
||||
|
||||
//try
|
||||
//{
|
||||
// WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.id == input.carryIds[0]).FirstAsync();
|
||||
|
||||
|
||||
// await _db.Ado.CommitTranAsync();
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// Logger.LogError("【WmsSaleService ModifyAsync】" + ex.Message);
|
||||
// Logger.LogError("【WmsSaleService ModifyAsync】" + ex.StackTrace);
|
||||
// await _db.Ado.RollbackTranAsync();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"DevName1": "Elevator1",
|
||||
"DevName2": "Elevator2",
|
||||
"DevName3": "Elevator3",
|
||||
"DevName4": "Elevator4",
|
||||
"HeartbeatDevNames": [ "Elevator3", "Elevator4" ],
|
||||
"HeartbeatDevNames": [ "Elevator1", "Elevator2", "Elevator3", "Elevator4" ],
|
||||
"tags": [ "SysStatus", "RunStatus", "FloorNo", "DoorStatus", "AGVStatus" ],
|
||||
"token": "780BE4144636CF47DDF3920B0F1D069B",
|
||||
"GetTagListUrl": "http://192.168.11.110:9100/Dev/GetTagList",
|
||||
|
||||
Reference in New Issue
Block a user