diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CheckPutInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CheckPutInput.cs new file mode 100644 index 00000000..7bc98a7e --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CheckPutInput.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Inputs +{ + public class CheckPutInput + { + public string point_code { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs index f5eb3179..361949a2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs @@ -44,11 +44,11 @@ namespace Tnb.WarehouseMgr //遍历字典,找出需要查询数据库拿的相关字段 foreach (Dictionary d in dics) - { + { /* if (d.Select(x => x.Value.ToString()).ToList().Find(v => v != "" && v != string.Empty && v != null) == null) { continue; - } + }*/ string LCode = d["location_code"]?.ToString() ?? string.Empty; if (LCode == string.Empty) { @@ -134,13 +134,14 @@ namespace Tnb.WarehouseMgr { row = await _db.Fastest().BulkCopyAsync(locs); } + /* else if (locs.Count > 400) { _db.Utilities.PageEach(locs, 100, async pageList => { row = await _db.Insertable(pageList).ExecuteCommandAsync(); }); - } + }*/ else { row = await _db.Insertable(locs).ExecuteCommandAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 8afa268e..dbbe073b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -12,12 +12,15 @@ using JNPF.FriendlyException; using JNPF.Systems.Interfaces.System; using Mapster; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.CodeAnalysis; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using NPOI.OpenXmlFormats.Dml; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.Common.Extension; +using Tnb.Common.Redis; using Tnb.Common.Utils; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Configs; @@ -45,8 +48,8 @@ namespace Tnb.WarehouseMgr private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build(); private static Dictionary locMap = new Dictionary(StringComparer.OrdinalIgnoreCase); public Func AddUnExecuteTask { get; set; } - - public WareHouseService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, + private readonly RedisData _redisData; + public WareHouseService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, RedisData redisData, IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService) //: base(repository.AsSugarClient()) { @@ -57,9 +60,8 @@ namespace Tnb.WarehouseMgr _cacheManager = cacheManager; _elevatorControlService = elevatorControlService; _ = InitializationTask; + _redisData = redisData; } - - /// /// 根据载具Id带出库位、仓库信息 /// @@ -223,6 +225,31 @@ namespace Tnb.WarehouseMgr .ToListAsync(); return input.Size > 0 ? items.Take(input.Size).ToList() : items; } + /// + /// 判断CTU是否可以放货 + /// + /// + [HttpPost] + public async Task CheckPut(CheckPutInput input) + { + Dictionary dic = new Dictionary(); + dic.Add("5号输送线点位", new string[] { "TY4C-ZHUSU1", "weighDone_5" }); + dic.Add("6号输送线点位", new string[] { "TY4C-ZHUSU1", "weighDone_6" }); + if (!dic.ContainsKey(input.point_code)) + throw new AppFriendlyException("点位" + input.point_code + "不存在", 500); + var strs = dic.Where(p => p.Key == input.point_code).First().Value; + bool flag = await _redisData.HashExist(strs[0], strs[1]); + if (!flag) + { + throw new AppFriendlyException("点位" + input.point_code + "不存在", 500); + } + string data = await _redisData.GetHash(strs[0], strs[1]); + JObject? res = JsonConvert.DeserializeObject(data); + bool result = res != null && res["Value"] != null ? res.Value("Value") : false; + if (!result) + throw new AppFriendlyException("点位" + input.point_code + "不可放", 500); + } + /// /// 生成任务执行 ///