From 787a297ca94ec53ae3e06e4c670cd9c40a0ef095 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 15 Aug 2024 17:13:28 +0800 Subject: [PATCH] bug --- .../ToolMoldRequisitionService.cs | 11 +- .../Helpers/TimerPoolHelper.cs | 57 +++++++++ .../Tnb.ProductionMgr/PrdPackReportService.cs | 7 ++ .../PrdRawMaterialBarcodeRecordTwoService.cs | 115 ++++++++++++++++++ 4 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr/Helpers/TimerPoolHelper.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeRecordTwoService.cs diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldRequisitionService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldRequisitionService.cs index 6bd69542..ff67e59e 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldRequisitionService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldRequisitionService.cs @@ -115,9 +115,18 @@ namespace Tnb.EquipMgr } private async Task Create(VisualDevModelDataCrInput input) { - string Code = await _billRuleService.GetBillNumber("moldRequisition"); + string moldId = input.data[nameof(ToolMoldRequisition.mold_id)].ToString(); + ToolMolds toolMolds = await _db.Queryable() + .SingleAsync(x => x.id == moldId); + + if (toolMolds.mold_status == Tnb.BasicData.DictConst.SCTypeId) + { + throw Oops.Bah("模具不在库,不可领用"); + } + DbResult result = await _db.Ado.UseTranAsync(async () => { + string Code = await _billRuleService.GetBillNumber("moldRequisition"); ToolMoldRequisition toolMoldRequisition = new ToolMoldRequisition(); toolMoldRequisition.code = Code; toolMoldRequisition.mold_id= input.data[nameof(ToolMoldRequisition.mold_id)].ToString(); diff --git a/ProductionMgr/Tnb.ProductionMgr/Helpers/TimerPoolHelper.cs b/ProductionMgr/Tnb.ProductionMgr/Helpers/TimerPoolHelper.cs new file mode 100644 index 00000000..07f1f23a --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/Helpers/TimerPoolHelper.cs @@ -0,0 +1,57 @@ +using JNPF.DependencyInjection; + +namespace Tnb.ProductionMgr.Helpers +{ + public class TimerPoolHelper : ISingleton + { + private static TimerPoolHelper instance = null; + + public static TimerPoolHelper GetInstance() + { + if (instance == null) + { + if (instance == null) + { + instance = new TimerPoolHelper(); + } + } + + return instance; + } + + private readonly Dictionary _timers = new Dictionary(); + private readonly object _lockObject = new object(); + + public TimerPoolHelper() + { + // 初始化代码,如果有必要的话 + } + + public void StartTimer(TimerCallback timerCallback,object data,TimeSpan dueTime, TimeSpan period) + { + Timer timer; + lock (_lockObject) + { + string timestamp = DateTime.Now.Ticks.ToString(); + Dictionary dic = new Dictionary(); + dic.Add("key",timestamp); + dic.Add("value",data); + timerCallback += DisposeTimer; + timer = new Timer(timerCallback, dic, dueTime, period); + _timers.Add(timestamp,timer); + } + } + + private void DisposeTimer(object args) + { + Dictionary dic = (Dictionary)args; + string key = dic["key"].ToString(); + if (_timers.ContainsKey(key)) + { + _timers[dic["key"].ToString()].Dispose(); + _timers[dic["key"].ToString()] = null; + _timers.Remove(dic["key"].ToString()); + } + } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 964e1722..53e506bb 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -483,6 +483,7 @@ namespace Tnb.ProductionMgr upmat_location_id = f.upmat_location_id, downmat_location_id = f.as_location_id, instock_warehouse_id = f.as_location_id, + mold_location_id = g.location_id, }) .MergeTable() .OrderBy($"{input.sidx} {input.sort}") @@ -507,6 +508,12 @@ namespace Tnb.ProductionMgr item.downmat_location_code = basLocation.location_code; } + if (!string.IsNullOrEmpty(item.mold_location_id)) + { + ToolLocation basLocation = await _db.Queryable().SingleAsync(x => x.id == item.mold_location_id); + item.mold_location_code = basLocation.location_code; + } + if (item.schedule_type == 2) { PerProcessStandardsH processStandardsH = await _db.Queryable() diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeRecordTwoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeRecordTwoService.cs new file mode 100644 index 00000000..ca13c53b --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeRecordTwoService.cs @@ -0,0 +1,115 @@ +using JNPF; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Extension; +using JNPF.Common.Filter; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.Logging; +using JNPF.Systems.Entitys.System; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using JNPF.VisualDev.Interfaces; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Senparc.CO2NET.HttpUtility; +using SqlSugar; +using Tnb.BasicData; +using Tnb.BasicData.Entities; +using Tnb.Common.Extension; +using Tnb.EquipMgr.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.WarehouseMgr.Entities.Configs; +using Tnb.Common.Utils; +using Tnb.WarehouseMgr.Entities.Consts; +using HttpClientHelper = Tnb.Common.Utils.HttpClientHelper; +using Tnb.Common.Redis; +using Tnb.ProductionMgr.Entities.Dto.PrdManage; + +namespace Tnb.ProductionMgr +{ + /// + /// 机台原料设定服务 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class PrdRawMaterialBarcodeRecordTwoService: IOverideVisualDevService,IDynamicApiController, ITransient + { + private const string ModuleId = "36014724856597"; + private readonly ISqlSugarClient _db; + private readonly IDictionaryDataService _dictionaryDataService; + private readonly IUserManager _userManager; + private static Dictionary> _dicWorkLine = new(); + private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build(); + private readonly IBillRullService _billRuleService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + private readonly IVisualDevService _visualDevService; + private readonly IRunService _runService; + private readonly RedisData _redisData; + + public PrdRawMaterialBarcodeRecordTwoService(ISqlSugarRepository repository, + IUserManager userManager, + IBillRullService billRuleService, + IVisualDevService visualDevService, + RedisData redisData, + IRunService runService, + IDictionaryDataService dictionaryDataService) + { + _db = repository.AsSugarClient(); + _userManager = userManager; + _billRuleService = billRuleService; + _dictionaryDataService = dictionaryDataService; + _visualDevService = visualDevService; + _runService = runService; + _redisData = redisData; + OverideFuncs.GetListAsync = GetList; + } + + private async Task GetList(VisualDevModelListQueryInput input) + { + Dictionary? queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string billCode = queryJson.ContainsKey("bill_code") ? queryJson["bill_code"].ToString() : ""; + string equipTypeId = queryJson.ContainsKey("f_flowid") ? queryJson["f_flowid"].ToString() : ""; + string isUpdate = queryJson.ContainsKey("is_update") ? queryJson["is_update"].ToString() : ""; + string equipId = queryJson.ContainsKey("equip_id") ? queryJson["equip_id"].ToString() : ""; + string stopValue = queryJson.ContainsKey("stop_valve") ? queryJson["stop_valve"].ToString() : ""; + + SqlSugarPagedList result = await _db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b,c) => a.equip_id == c.id) + .LeftJoin((a,b,c,d)=>c.equip_type_id==d.id) + .WhereIF(!string.IsNullOrEmpty(billCode),(a,b,c)=>a.bill_code.Contains(billCode)) + .WhereIF(!string.IsNullOrEmpty(equipTypeId),(a,b,c)=>c.equip_type_id==equipTypeId) + .WhereIF(!string.IsNullOrEmpty(isUpdate),(a,b,c)=>a.is_update.ToString()==isUpdate) + .WhereIF(!string.IsNullOrEmpty(equipId),(a,b,c)=>a.equip_id.ToString()==equipId) + .WhereIF(!string.IsNullOrEmpty(stopValue),(a,b,c)=>a.stop_valve.ToString()==stopValue) + .Where((a,b,c)=>a.type=="2") + .Select((a, b, c,d) => new PrdRawMaterialBarcodeListDto + { + id = a.id, + bill_code = a.bill_code, + equip_id = c.name, + material_id = b.name, + absorb_material_finish = a.absorb_material_finish==1 ? "是" : "否", + is_update = a.is_update==1 ? "是" : "否", + piping_status = a.piping_status == 1 ? "开" : "关", + start_time = a.start_time!=null ? a.start_time.ToString(DbTimeFormat.SS) : "", + end_time = a.end_time!=null ? a.end_time.ToString(DbTimeFormat.SS) : "", + remark = a.remark, + stop_valve = a.stop_valve, + f_flowid = d.name, + equip_id_id = c.id, + material_id_id = b.id, + equip_ids = SqlFunc.Subqueryable().Where(x=>a.equip_ids.Contains(x.id)).SelectStringJoin(x=>x.name,",") + }).ToPagedListAsync(input.currentPage, int.MaxValue); + return PageResult.SqlSugarPageResult(result); + } + + } +} \ No newline at end of file