From 450ea471b75134bd34b2591b2217152924798bab Mon Sep 17 00:00:00 2001 From: majian <780924089@qq.com> Date: Tue, 28 May 2024 09:56:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E5=85=A5=E5=BA=93=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/RedisBackGround.cs | 98 ++++---- .../Consts/ModuleConsts.cs | 6 +- .../Consts/WmsWareHouseConst.cs | 14 ++ .../Dto/Inputs/CommonCreatePretaskInput.cs | 3 +- .../Dto/Inputs/WmsPrdInstockCodeInput.cs | 18 ++ .../Dto/Inputs/WmsPrdInstockDInput.cs | 18 ++ .../Dto/Inputs/WmsPrdInstockInput.cs | 24 ++ .../Entity/WmsPrdInstockCode.cs | 52 +++++ .../Entity/WmsPrdInstockD.cs | 57 +++++ .../Entity/WmsPrdInstockH.cs | 92 ++++++++ .../Tnb.WarehouseMgr/WareHouseService.cs | 23 +- .../Tnb.WarehouseMgr/WmsPrdInstockHService.cs | 220 ++++++++++++++++++ 12 files changed, 549 insertions(+), 76 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockCodeInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockDInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockCode.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockD.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockH.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index c6f1cabb..844f5a39 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -11,6 +11,7 @@ using JNPF.Common.Cache; 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 Microsoft.AspNetCore.Identity; @@ -61,7 +62,10 @@ namespace Tnb.ProductionMgr // 二楼上升降机 private Timer? Floor2UpMachinecodetimer; // 二楼料架配送 - private Timer? Floor2RackDeliverytimer; + private Timer? Floor2timer送空托到上升降区; + private Timer? Floor2timer送满托到下升降区; + private Timer? Floor2timer移走上升降区未生成预任务且满托的料架; + private Timer? Floor2timer移走下升降区未生成预任务且空托的料架; public static SemaphoreSlim s_taskExecuteFloor2UpMachinecodetimer = new(1); public static SemaphoreSlim s_task送空托到上升降区 = new(1); @@ -93,7 +97,7 @@ namespace Tnb.ProductionMgr _wmsCarryBindService = wmsCarryBindService; } //获取redis数据 - private void GetRedisData(object state) + private void GetRedisData(object? state) { var _redisReadConfigs = _repository.AsQueryable().Where(p => p.enabled == 1).ToList(); foreach (var config in _redisReadConfigs) @@ -173,7 +177,7 @@ namespace Tnb.ProductionMgr } } //ctu取货 - private void CheckGet(object state) + private void CheckGet(object? state) { Dictionary getdic = new Dictionary(); getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" }); @@ -424,7 +428,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA #region 八工位 //扫码入库 - private void ScanInStock(object state) + private void ScanInStock(object? state) { Dictionary getdic = new Dictionary(); getdic.Add("BGWRKYCL02", new string[] { "CP8", "AllowGetFullBox1", "code1", "PutDoneEmptyBox", "false" }); @@ -506,7 +510,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA /// /// 八工位空托盘补充 /// - private async void BGWCarrySupplement(object state) + private async void BGWCarrySupplement(object? state) { Dictionary getdic = new Dictionary(); getdic.Add("YCLCKBGW", new string[] { "CP8", "AllowPutEmptyBox1" }); @@ -597,7 +601,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA /// /// 供料叠盘机空托盘自动入库 /// - private async void YCLGLDPJInstock(object state) + private async void YCLGLDPJInstock(object? state) { Dictionary getdic = new Dictionary(); getdic.Add("SGW-YCL", new string[] { "CP3-3", "AllowGetFullBox" }); @@ -682,7 +686,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA /// /// 外协叠盘机空托盘自动入库 /// - private async void YCLWXDPJInstock(object state) + private async void YCLWXDPJInstock(object? state) { Dictionary getdic = new Dictionary(); getdic.Add("未定", new string[] { "CP3-3", "AllowGetFullBox" }); @@ -769,7 +773,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA #region 中储仓 - private void SSXcode(object state) + private void SSXcode(object? state) { Dictionary dic = new Dictionary(); dic.Add("东面提升机输送线", new string[] { "下升降机判断请求", "下升降机判断条码", "下升降机判断完毕", "下升降机判断结果" }); @@ -868,7 +872,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA Scantimer?.Dispose(); SSXcodetimer?.Dispose(); Floor2UpMachinecodetimer?.Dispose(); - Floor2RackDeliverytimer?.Dispose(); + Floor2timer送空托到上升降区?.Dispose(); + Floor2timer送满托到下升降区?.Dispose(); + Floor2timer移走上升降区未生成预任务且满托的料架?.Dispose(); + Floor2timer移走下升降区未生成预任务且空托的料架?.Dispose(); + BGWCarrySupplementtimer?.Dispose(); YCLGLDPJInstocktimer?.Dispose(); YCLWXDPJInstocktimer?.Dispose(); @@ -876,7 +884,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA #region 二楼上升降机机械臂 // 上升降机 - private async void Floor2UpMachinecode(object args) + private async void Floor2UpMachinecode(object? args) { string barcode = await Floor2UpDownMachinecode_GetTag(MechanicalArmConsts.上升降机条码); if (string.IsNullOrEmpty(barcode)) @@ -968,7 +976,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA } // 尝试写入空托送到信号 bool result上升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"上升降机空托{target.stackingposition}送到", "true"); - LoggerFloor2UpDownMachine.LogInformation($@"【送空托到上升降区】回写 上升降机空托{target.stackingposition}送到 结果为{result上升降机空托送到}"); + LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】回写 上升降机空托{target.stackingposition}送到 结果为{result上升降机空托送到}"); if (!result上升降机空托送到) { return; @@ -1056,7 +1064,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA /// 送空托到上升降区 /// /// - public async Task 送空托到上升降区() + public async void 送空托到上升降区(object? args) { #region 检查信号 List configs_upMachine = new List(); @@ -1073,7 +1081,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA // 没有有效信号 if (configs_upMachine.Count == 0) - return false; + return; #endregion using (var db = _repository.AsSugarClient().CopyNew()) @@ -1086,13 +1094,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA InnerJoin((a, b) => a.point_id == b.id) .InnerJoin((a, b, c) => b.location_id == c.id) .Where((a, b, c) => string.IsNullOrEmpty(a.rackcode) && c.is_lock == 0 && configs_upMachine.Contains(a.name)); - + List WmsMechanicalArmHs = WmsMechanicalArmHsuagar.ToList(); if (WmsMechanicalArmHs.Count() == 0) { LoggerFloor2RackDelivery.LogWarning($"【送空托到上升降区】 无需补充料架区 {WmsMechanicalArmHsuagar.ToSqlString()}"); - return false; + return; } // 料架区 @@ -1171,15 +1179,16 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA continue; } } - return true; + } catch (Exception ex) { - return false; + } finally { s_task送空托到上升降区.Release(); + _wareHouseService.GenTaskExecute(); } } } @@ -1188,7 +1197,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA /// 送满托到下升降区 /// /// - public async Task 送满托到下升降区() + public async void 送满托到下升降区(object? args) { #region 检查信号 List configs_upMachine = new List(); @@ -1205,7 +1214,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA // 没有有效信号 if (configs_upMachine.Count == 0) - return false; + return; #endregion using (var db = _repository.AsSugarClient().CopyNew()) @@ -1224,7 +1233,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA if (WmsMechanicalArmHs.Count() == 0) { LoggerFloor2RackDelivery.LogWarning($"【送满托到下升降区】 无需补充料架区 {WmsMechanicalArmHsuagar.ToSqlString()}"); - return false; + return; } // 料架区 @@ -1326,15 +1335,14 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA continue; } } - return true; } catch (Exception ex) { - return false; } finally { s_task送满托到下升降区.Release(); + _wareHouseService.GenTaskExecute(); } } } @@ -1344,7 +1352,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA /// 移走上升降区未生成预任务且满托的料架 /// /// - public async Task 移走上升降区未生成预任务且满托的料架() + public async void 移走上升降区未生成预任务且满托的料架(object? args) { #region 检查信号 List configs_upMachine = new List(); @@ -1361,7 +1369,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA // 没有有效信号 if (configs_upMachine.Count == 0) - return false; + return; #endregion using (var db = _repository.AsSugarClient().CopyNew()) @@ -1435,15 +1443,14 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA } LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 成功生成预任务 {result.Item2}"); } - return true; } catch (Exception ex) { - return false; } finally { s_task移走上升降区未生成预任务且满托的料架.Release(); + _wareHouseService.GenTaskExecute(); } } } @@ -1453,7 +1460,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA /// 移走下升降区未生成预任务且空托的料架 /// /// - public async Task 移走下升降区未生成预任务且空托的料架() + public async void 移走下升降区未生成预任务且空托的料架(object? args) { #region 检查信号 List configs_upMachine = new List(); @@ -1471,7 +1478,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA // 没有有效信号 if (configs_upMachine.Count == 0) - return false; + return; #endregion using (var db = _repository.AsSugarClient().CopyNew()) { @@ -1551,47 +1558,20 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA continue; } } - return true; } catch (Exception ex) { LoggerFloor2RackDelivery.LogError(ex.ToString()); LoggerFloor2RackDelivery.LogError(ex.StackTrace); - return false; } finally { s_task移走下升降区未生成预任务且空托的料架.Release(); + _wareHouseService.GenTaskExecute(); } } } - // 料架配送 - private async void Floor2RackDelivery(object args) - { - try - { - // 送空托到上升降区 - await 送空托到上升降区(); - - // 送满托到下升降区 - await 送满托到下升降区(); - - // 移走上升降区未生成预任务且满托的料架 - await 移走上升降区未生成预任务且满托的料架(); - - // 移走下升降区未生成预任务且空托的料架 - await 移走下升降区未生成预任务且空托的料架(); - - _ = _wareHouseService.GenTaskExecute(); - } - catch (Exception ex) - { - LoggerFloor2RackDelivery.LogError(ex.ToString()); - LoggerFloor2RackDelivery.LogError(ex.StackTrace); - } - } - // 上下升降机生成预任务(补充料架、上升降机取货到料架、上升降机满托运走,下升降机拿货到输送线、下升降机空托运走) private async Task> createPretask(List points, string carry_id, string carry_code, ILogger logger) { @@ -1695,8 +1675,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA // 二楼上升降机 Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10)); + // 二楼料架配送 - Floor2RackDeliverytimer = new Timer(Floor2RackDelivery, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); + Floor2timer送空托到上升降区 = new Timer(送空托到上升降区, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); + Floor2timer送满托到下升降区 = new Timer(送满托到下升降区, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); + Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(移走上升降区未生成预任务且满托的料架, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); + Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(移走下升降区未生成预任务且空托的料架, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); return Task.CompletedTask; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs index 3e6016da..b50b3848 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs @@ -222,8 +222,12 @@ public class ModuleConsts /// public const string MODULE_WMSTRANSFERINSTOCKH_ID = "34154749548053"; /// - /// 模块标识-原材料转库单 TODO + /// 模块标识-原材料转库单 /// public const string MODULE_WMSMATERIALTRANSFER_ID = "34354738929685"; + /// + /// 模块标识-生产入库单 todo + /// + public const string MODULE_WMSPRDINSTOCK_ID = "MODULE_WMSPRDINSTOCK_ID"; } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index 70e8e7e3..b69bd880 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -228,6 +228,11 @@ /// public const string BIZTYPE_WMSTRANSFERINSTOCK_ID = "34154749548053"; + /// + /// 生产入库 todo + /// + public const string BIZTYPE_WMSPRDINSTOCK_ID = "BIZTYPE_WMSPRDINSTOCK_ID"; + /// /// 条码打印状态-已完成 /// @@ -273,6 +278,12 @@ /// 单据类型-来料入库单 /// public const string BILLTYPE_MATERIALINSTOCK_ID = "25103338755861"; + + /// + /// 单据类型-生产入库单 + /// + public const string BILLTYPE_PRDINSTOCK_ID = "27410834411541"; + /// /// 管理员Id(天益4厂管理员) /// @@ -346,5 +357,8 @@ /// 料箱id /// public const string LIAOXIANGID = "26037262680357"; + + + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CommonCreatePretaskInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CommonCreatePretaskInput.cs index 5a6cf78f..c12ed4a5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CommonCreatePretaskInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CommonCreatePretaskInput.cs @@ -25,8 +25,9 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs public string require_id { get; set; } public string require_code { get; set; } - + public string moduleConsts { get; set; } + /// /// 如果要生成业务表,传入此对象以及对应业务表单的自定义字段 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockCodeInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockCodeInput.cs new file mode 100644 index 00000000..33ef1a41 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockCodeInput.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto +{ + public class WmsPrdInstockCodeInput + { + public decimal planqty { get; set; } + public decimal pqty { get; set; } + public string code_batch { get; set; } + public string code { get; set; } + public string unit_id { get; set; } + public string carry_id { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockDInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockDInput.cs new file mode 100644 index 00000000..3803c32d --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockDInput.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto +{ + public class WmsPrdInstockDInput + { + public string task_bill_code { get; set; } + + public string warehouse_id { get; set; } + + public string startlocation_id { get; set; } + public string carry_id { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockInput.cs new file mode 100644 index 00000000..f33496dc --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsPrdInstockInput.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Inputs +{ + public class WmsPrdInstockInput + { + public string prd_bill_code { get; set; } + public string material_id { get; set; } + public string material_code { get; set; } + public string material_name { get; set; } + public string material_spec { get; set; } + public decimal planqty { get; set; } + public decimal pqty { get; set; } + public decimal rqty { get; set; } + public string type { get; set; } + public string create_id { get; set; } + public List prdInstockDs { get; set; } + public List prdInstockCodes { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockCode.cs new file mode 100644 index 00000000..da74e35c --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockCode.cs @@ -0,0 +1,52 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities.Entity; + +/// +/// 载具条码表 +/// +[SugarTable("wms_prd_instock_code")] +public partial class WmsPrdInstockCode : BaseEntity +{ + public WmsPrdInstockCode() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 计划数 + /// + public decimal? planqty { get; set; } + + /// + /// 合格数 + /// + public decimal? pqty { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 条码信息 + /// + public string? code { get; set; } + + /// + /// 单位 + /// + public string? unit_id { get; set; } + + /// + /// 父表ID + /// + public string? prd_instock_id { get; set; } + + /// + /// 载具ID + /// + public string? carry_id { get; set; } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockD.cs new file mode 100644 index 00000000..251f1ad9 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockD.cs @@ -0,0 +1,57 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities.Entity; + +/// +/// 生产入库子表 +/// +[SugarTable("wms_prd_instock_d")] +public partial class WmsPrdInstockD : BaseEntity +{ + public WmsPrdInstockD() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 生产任务单号 + /// + public string? task_bill_code { get; set; } + + /// + /// 入库仓库 + /// + public string? warehouse_id { get; set; } + + /// + /// 起始库位 + /// + public string? startlocation_id { get; set; } + + /// + /// 载具 + /// + public string? carry_id { get; set; } + + /// + /// 主表ID + /// + public string? prd_instock_id { get; set; } + + /// + /// 状态 + /// + public string? status { get; set; } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockH.cs new file mode 100644 index 00000000..9d0c6479 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPrdInstockH.cs @@ -0,0 +1,92 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities.Entity; + +/// +/// 生产入库主表 +/// +[SugarTable("wms_prd_instock_h")] +public partial class WmsPrdInstockH : BaseEntity +{ + public WmsPrdInstockH() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 生产工单 + /// + public string? prd_bill_code { get; set; } + + /// + /// 入库单号 + /// + public string? bill_code { get; set; } + + /// + /// 物料ID + /// + public string? material_id { get; set; } + + /// + /// 物料编码 + /// + public string? material_code { get; set; } + + /// + /// 物料名称 + /// + public string? material_name { get; set; } + + /// + /// 规格型号 + /// + public string? material_spec { get; set; } + + /// + /// 计划入库数 + /// + public decimal? planqty { get; set; } + + /// + /// 合格数 + /// + public decimal? pqty { get; set; } + + /// + /// 不合格数 + /// + public decimal? rqty { get; set; } + + /// + /// 工单类型 + /// + public string? type { get; set; } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 317835f9..4c0631bb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -2353,9 +2353,10 @@ namespace Tnb.WarehouseMgr commonCreatePretaskInput.endlocation_id = endLocation.id; commonCreatePretaskInput.carry_id = wmsCarryD.membercarry_id; commonCreatePretaskInput.carry_code = wmsCarryD.membercarry_code; - commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; + commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID; commonCreatePretaskInput.isExcuteMission = false; + commonCreatePretaskInput.moduleConsts = ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID; VisualDevModelDataCrInput visualDevInput = new VisualDevModelDataCrInput(); visualDevInput.data = new Dictionary(); @@ -2465,34 +2466,22 @@ namespace Tnb.WarehouseMgr else if (!string.IsNullOrEmpty(input.carry_id)) { wmsCarryH = _db.Queryable().Where(r => r.id == input.carry_id).First(); + carry_id = wmsCarryH.id; + carry_code = wmsCarryH.carry_code; } // carry_code else if (!string.IsNullOrEmpty(input.carry_code)) { wmsCarryH = _db.Queryable().Where(r => r.carry_code == input.carry_code).First(); - } - // 如果carry_id和carry_code都没有指定,随机取库位上载具记录的一条 - else - { - wmsCarryH = _db.Queryable().InnerJoin((a, b) => a.id == b.location_id) - .Where((a, b) => a.id == sPoint.location_id).Select((a, b) => b).First(); - } - - if (wmsCarryH != null) - { carry_id = wmsCarryH.id; carry_code = wmsCarryH.carry_code; } - //if (string.IsNullOrEmpty(carry_id)) - //{ - // throw new AppFriendlyException("起点库位上没有载具", 500); - //} if (input.visualDevInput != null) { - //在线开发 - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID, true); + //在线开发moduleConsts + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(input.moduleConsts, true); await _runService.Create(templateEntity, input.visualDevInput); input.require_id = input.visualDevInput.data["ReturnIdentity"].ToString() ?? ""; input.require_code = input.visualDevInput.data["bill_code"].ToString() ?? ""; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs new file mode 100644 index 00000000..666e1343 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs @@ -0,0 +1,220 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.FriendlyException; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Microsoft.Extensions.Logging; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.ProductionMgr.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.Entity; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + [OverideVisualDev(ModuleConsts.MODULE_WMSPRDINSTOCK_ID)] + public class WmsPrdInstockHService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private readonly IWareHouseService _wareHouseService; + + public WmsPrdInstockHService(ISqlSugarRepository repository, IRunService runService, + IVisualDevService visualDevService, IWareHouseService wareHouseService) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + _wareHouseService = wareHouseService; + } + + /// + /// 工单提报 第一次主表所有参数全传,后续主表只需要传工单号prd_bill_code和更新后的合格数pqty、不合格数rqty + /// + /// + /// + public async Task PrdInstock(WmsPrdInstockInput input) + { + try + { + await _db.Ado.BeginTranAsync(); + + WmsPrdInstockH prdInstockH = _db.Queryable().Where(r => r.prd_bill_code == input.prd_bill_code).First(); + + string prd_instock_code_id = ""; + // 新建主表 + if (prdInstockH == null) + { + VisualDevModelDataCrInput visualDevInput = new VisualDevModelDataCrInput(); + visualDevInput.data = new Dictionary(); + visualDevInput.data.Add("bill_code", ""); + + visualDevInput.data.Add("status", WmsWareHouseConst.BILLSTATUS_ADD_ID); + + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSPRDINSTOCK_ID, true); + await _runService.Create(templateEntity, visualDevInput); + + prd_instock_code_id = visualDevInput.data["ReturnIdentity"].ToString() ?? ""; + } + else + { + prd_instock_code_id = prdInstockH.id; + + await _db.Updateable(r => new WmsPrdInstockH + { + pqty = input.pqty, + rqty = input.rqty + }).ExecuteCommandAsync(); + } + + List WmsPrdInstockDs = new List(); + foreach (WmsPrdInstockDInput prdInstockDInput in input.prdInstockDs) + { + WmsPrdInstockDs.Add(new WmsPrdInstockD() + { + task_bill_code = prdInstockDInput.task_bill_code, + warehouse_id = prdInstockDInput.warehouse_id, + startlocation_id = prdInstockDInput.startlocation_id, + carry_id = prdInstockDInput.carry_id, + create_id = input.create_id, + create_time = DateTime.Now, + prd_instock_id = prd_instock_code_id, + status = WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID + }); + } + + List WmsPrdInstockCodes = new List(); + foreach (WmsPrdInstockCodeInput prdInstockCodeInput in input.prdInstockCodes) + { + + WmsPrdInstockCodes.Add(new WmsPrdInstockCode() + { + planqty = prdInstockCodeInput.planqty, + pqty = prdInstockCodeInput.pqty, + code_batch = prdInstockCodeInput.code_batch, + code = prdInstockCodeInput.code, + unit_id = prdInstockCodeInput.unit_id, + carry_id = prdInstockCodeInput.carry_id, + prd_instock_id = prd_instock_code_id + }); + } + + await _db.Insertable(WmsPrdInstockDs).ExecuteCommandAsync(); + + await _db.Insertable(WmsPrdInstockCodes).ExecuteCommandAsync(); + + foreach (WmsPrdInstockD wmsPrdInstockD in WmsPrdInstockDs) + { + //入库取终点 + InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = wmsPrdInstockD.warehouse_id, Size = 1 }; + List endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + if (endLocations?.Count == 0) + { + throw new AppFriendlyException("没有可用的中储仓库位", 500); + } + BasLocation endLocation = endLocations[0]; + + BasLocation startLocation = _db.Queryable().Where(r => r.id == wmsPrdInstockD.startlocation_id).First(); + if (startLocation == null) + { + throw new AppFriendlyException("系统中找不到起点ID的库位信息", 500); + } + + BasLocation endlocation_ssx = null; + string startlocation_id_ssx = null; + // 注塑线边库到2,4输送线 + if (startLocation.wh_id == "32604516180501") + { + // 根据ZSSSXCTU01 ZSSSXCTU02任务数平均分配任务 + endlocation_ssx = await _db.Queryable().Where(r => new string[2] { "32624148726549", "32624157608981" }.Contains(r.id)).OrderBy("is_lock, task_nums, location_code").FirstAsync(); + await _db.Updateable().SetColumns(it => it.task_nums == it.task_nums + 1).Where(it => endlocation_ssx.id == it.id).ExecuteCommandAsync(); + + // ZSSSXCTU01 对应 SSX-011-002 + if (endlocation_ssx.location_code == "ZSSSXCTU01") + { + startlocation_id_ssx = "32609073591317"; + } + // ZSSSXCTU02 对应 SSX-011-004 + else if (endlocation_ssx.location_code == "ZSSSXCTU02") + { + startlocation_id_ssx = "32609093546005"; + } + } + + // 生成到输送线任务 + CommonCreatePretaskInput commonCreatePretaskInput1 = new CommonCreatePretaskInput(); + commonCreatePretaskInput1.startlocation_id = startLocation.id; + commonCreatePretaskInput1.endlocation_id = endlocation_ssx.id; + commonCreatePretaskInput1.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; + commonCreatePretaskInput1.biz_type = ""; + commonCreatePretaskInput1.require_id = wmsPrdInstockD.id; + commonCreatePretaskInput1.isExcuteMission = false; + Entities.Dto.Outputs.Result res1 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput1); + + // 生成到中储仓任务 + CommonCreatePretaskInput commonCreatePretaskInput2 = new CommonCreatePretaskInput(); + commonCreatePretaskInput2.startlocation_id = startlocation_id_ssx; + commonCreatePretaskInput2.endlocation_id = endLocation.id; + commonCreatePretaskInput2.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; + commonCreatePretaskInput2.biz_type = WmsWareHouseConst.BIZTYPE_WMSPRDINSTOCK_ID; + commonCreatePretaskInput2.require_id = wmsPrdInstockD.id; + commonCreatePretaskInput2.isExcuteMission = false; + + Entities.Dto.Outputs.Result res2 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput2); + } + + + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + Logger.Error(ex.Message); + Logger.Error(ex.StackTrace); + await _db.Ado.RollbackTranAsync(); + return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message); + } + finally + { + _wareHouseService.GenTaskExecute(); + } + + return await ToApiResult(HttpStatusCode.OK, "成功"); + } + + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) + { + throw new ArgumentNullException(nameof(input)); + } + + bool isOk = true; + // 如果生产入库 输送线到仓库这条任务完成,反写单据数据 + if (input.bizTypeId == WmsWareHouseConst.BIZTYPE_WMSPRDINSTOCK_ID) + { + isOk = await _db.Updateable().SetColumns(it => new WmsPrdInstockD { status = WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID }) + .Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + } + + + + if (!isOk) + { + throw Oops.Oh(ErrorCode.COM1001); + } + } + } +}