From bbce3accf3981bcfe9fd54ac5020b3ed8a6d409c Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 18 Jul 2023 10:32:23 +0800 Subject: [PATCH 1/2] bug --- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 2 +- .../Tnb.ProductionMgr/PrdTaskManageService.cs | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index f73b3872..4b8074d5 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -515,7 +515,7 @@ namespace Tnb.ProductionMgr [HttpGet] public async Task GetUnSchedulingList([FromQuery] VisualDevModelListQueryInput input) { - Dictionary queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject>(input.queryJson) : null; + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); List moStatusList = new List(); if (queryJson!=null && queryJson.ContainsKey("mo_stauts")) { diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index ff33e912..c7cb7feb 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -23,6 +23,7 @@ using Microsoft.AspNetCore.Mvc; using DbModels; using JNPF.Common.Extension; using JNPF.Common.Filter; +using JNPF.Common.Security; using Tnb.ProductionMgr.Entities.Dto.PrdManage; using NPOI.OpenXmlFormats; using JNPF.Systems.Entitys.Permission; @@ -116,26 +117,31 @@ namespace Tnb.ProductionMgr private async Task GetList(VisualDevModelListQueryInput input) { var db = _repository.AsSugarClient(); - Dictionary queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject>(input.queryJson) : null; + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); string moTaskCode = queryJson!=null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; - Dictionary dic = new Dictionary() + Dictionary dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus); + + DateTime[] planStartDateArr = null; + DateTime[] planEndDateArr = null; + if (queryJson.TryGetValue("plan_start_date", out var value1)) { - [DictConst.ToBeStartedEnCode] = "待开工", - [DictConst.InProgressEnCode] = "进行中", - [DictConst.ClosedEnCode] = "关闭", - [DictConst.ComplatedEnCode] = "完工", - [DictConst.ToBeScheduledEncode] = "待排产", - [DictConst.MoStatusPauseCode] = "暂停", - [DictConst.MoStatusExceptionCode] = "异常", - [DictConst.MoStatusRevokeCode] = "撤销", - }; + planStartDateArr = value1.ToObject().Select(x=>x.TimeStampToDateTime()).ToArray(); + } + if (queryJson.TryGetValue("plan_end_date", out var value2)) + { + planEndDateArr = value2.ToObject().Select(x=>x.TimeStampToDateTime()).ToArray(); + } + + var result = await db.Queryable() .LeftJoin((a, b) => a.eqp_id == b.id) .LeftJoin((a, b, c) => a.material_id == c.id) .LeftJoin((a, b, c, d) => a.mold_id == d.id) - //.Where((a,b,c,d)=>(a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_status==DictConst.InProgressEnCode || a.mo_task_status==DictConst.MoStatusExceptionCode)) + .Where((a,b,c,d)=>(a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_status==DictConst.InProgressEnCode || a.mo_task_status==DictConst.MoStatusExceptionCode || a.mo_task_status==DictConst.MoStatusPauseCode || a.mo_task_status==DictConst.ComplatedEnCode)) .Where((a,b,c,d)=>a.schedule_type==1) .WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c,d)=>a.mo_task_code.Contains(moTaskCode)) + .WhereIF(planStartDateArr!=null, (a, b, c, d) => a.estimated_start_date>=planStartDateArr[0] && a.estimated_start_date<=planStartDateArr[1]) + .WhereIF(planEndDateArr!=null, (a, b, c, d) => a.estimated_end_date>=planEndDateArr[0] && a.estimated_end_date<=planEndDateArr[1]) .OrderByDescending((a, b, c, d) => a.create_time) .Select((a, b, c, d) => new PrdTaskManageListOutput() { @@ -152,7 +158,7 @@ namespace Tnb.ProductionMgr schedule_type = a.schedule_type.ToString() }) - .Mapper(x=>x.mo_task_status=dic[x.mo_task_status]) + .Mapper(x=>x.mo_task_status=dic[x.mo_task_status].ToString()) .ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); } From 81f7672980a7579b780b6661a6e0c91a472584bc Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 18 Jul 2023 10:38:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=8C=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E7=9B=AE=E6=A0=87=E5=BA=93=E4=BD=8D=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=94=BE=E7=BD=AE=E5=BD=93=E5=89=8D=E8=BD=BD?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BasLocation.cs | 4 +++ .../Tnb.WarehouseMgr/BaseWareHouseService.cs | 28 ++++++++++++++++++- .../Tnb.WarehouseMgr/WmsSetSortingService.cs | 23 +++++++++------ 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs index 4a348d76..9c902bc1 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs @@ -75,6 +75,10 @@ public partial class BasLocation : BaseEntity /// 修改用户 /// public string? modify_id { get; set; } + /// + /// 载具规格分类Id + /// + public string carrystd_id { get; set; } /// /// 修改时间 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index bb3d2c6f..aa747ad7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -15,7 +15,9 @@ using JNPF.DynamicApiController; using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json.Linq; using SqlSugar; +using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; @@ -47,8 +49,32 @@ namespace Tnb.WarehouseMgr } } } + /// + /// 判断最终目标库位是否可以放置当前载具 + /// + /// 当前载具 + /// 目标库位 + /// + /// + [NonAction] + protected Task IsCarryAndLocationMatchByCarryStd(WmsCarryH carry, BasLocation locDest) + { + bool isMatch = false; + string errMessage = string.Empty; + if (carry == null) throw new ArgumentNullException(nameof(carry)); + if (locDest == null) throw new ArgumentNullException(nameof(locDest)); + if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty()) + { + var jsonArr = JArray.Parse(locDest.carrystd_id); + var locCarryStdArr = jsonArr.Select(x => x.ToObject()).ToArray(); + if (locCarryStdArr.Contains(carry.carrystd_id)) + { + isMatch = true; + } + } + return Task.FromResult(isMatch); + } - [NonAction] protected async Task DoUpdate(WareHouseUpInput input) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index 282556f8..a2a3af29 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -52,6 +52,9 @@ namespace Tnb.WarehouseMgr [HttpPost] public async Task PackSortingByAdd(WmsCarryMat? carryMat) { + string firstLocationId = "27010980724501", secondLocationId = "27010987857941"; + var endLocation = await _db.Queryable().SingleAsync(it => it.id == secondLocationId); + var setSortings = await _db.Queryable() .Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID).OrderBy(a => a.seq) .ToListAsync(); @@ -61,9 +64,14 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); + var singleSorting = setSortings[^setSortings.Count]; + var curCarry = await _db.Queryable().SingleAsync(it => it.id == singleSorting.carry_id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); + if (setSortings?.Count > 0 && !onFlag) { - var singleSorting = setSortings[^setSortings.Count]; + var setSortingDList = await _db.Queryable().Where(it => it.bill_id == singleSorting.id).ToListAsync(); if (setSortingDList?.Count > 0) { @@ -141,18 +149,18 @@ namespace Tnb.WarehouseMgr { List preTasks = new(); List locIds = new(); - string firstLocationId = "27010980724501", secondLocationId = "27010987857941"; + var mid = 6; if (carrys.Length > mid) { var leftCarrys = carrys[..mid]; var rightCarrys = carrys[mid..]; - await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks); - await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks); + await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); + await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); } else { - await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks); + await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); } List pretaskCodes = new(); foreach (var pt in preTasks) @@ -187,9 +195,8 @@ namespace Tnb.WarehouseMgr } } - private async Task InnerGenPreTask(WmsCarryH[] carrys, List locIds, string eLocationId, string requireId, string requireCode, List preTasks) + private async Task InnerGenPreTask(WmsCarryH[] carrys, List locIds, string eLocationId, string requireId, string requireCode, List preTasks, BasLocation endLocation) { - var loc = await _db.Queryable().SingleAsync(it => it.id == eLocationId); foreach (var carry in carrys) { WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); @@ -232,7 +239,7 @@ namespace Tnb.WarehouseMgr }; return preTask; }).ToList(); - if (loc.is_sign == 0) + if (endLocation.is_sign == 0) { curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 }