From 39c09dede499f7ba23bcd26b17b2199a31bddccc Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周三, 28 8月 2024 11:10:53 +0800 Subject: [PATCH] 出库执行 哟花 --- iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs | 61 +++++++++++++++++++++++++++--- 1 files changed, 54 insertions(+), 7 deletions(-) diff --git a/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs b/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs index 655cbdd..48ddb7f 100644 --- a/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs +++ b/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs @@ -9,6 +9,7 @@ using Furion.DynamicApiController; using System.Text; using iWare.Wms.Core.Enum; +using Microsoft.AspNetCore.Authorization; namespace iWare.Wms.Application.Service.Pda { @@ -18,6 +19,7 @@ //[Route("api")] [ApiDescriptionSettings("Pda鐩稿叧鎺ュ彛", Name = "PdaService", Order = 100)] [Route("api/[Controller]")] + [DisableOpLog] public class PdaService : IDynamicApiController, ITransient { private readonly IRepository<EquipmentBaseInfo, MasterDbContextLocator> _equipmentBaseInfoRep; @@ -30,12 +32,14 @@ private readonly IRepository<SysDictType, MasterDbContextLocator> _sysDictTypeRep; private readonly IRepository<WorkPieceInfoLog, MasterDbContextLocator> _workPieceInfoLogRep; private readonly IRepository<WorkPieceOutbound, MasterDbContextLocator> _workPieceOutboundRep; + private readonly IRepository<WorkPieceUnLine, MasterDbContextLocator> _workPieceUnLineRep; /// <summary> /// 璁惧鍩虹淇℃伅鏋勯�犲嚱鏁� /// </summary> /// <param name="equipmentBaseInfoRep"></param> public PdaService( + IRepository<WorkPieceUnLine, MasterDbContextLocator> workPieceUnLineRep, IRepository<EquipmentBaseInfo, MasterDbContextLocator> equipmentBaseInfoRep, IRepository<V_GetEquipmentAlert, MasterDbContextLocator> v_GetEquipmentAlert, IRepository<EquipmentCurrentMonitor, MasterDbContextLocator> equipmentCurrentMonitorRep, @@ -48,6 +52,7 @@ IRepository<WorkPieceOutbound, MasterDbContextLocator> workPieceOutboundRep ) { + _workPieceUnLineRep = workPieceUnLineRep; _equipmentBaseInfoRep = equipmentBaseInfoRep; _v_GetEquipmentAlertRep = v_GetEquipmentAlert; _equipmentCurrentMonitorRep = equipmentCurrentMonitorRep; @@ -221,6 +226,7 @@ /// <param name="input"></param> /// <returns></returns> [HttpGet("getWorkPieceProcess")] + [DisableOpLog] public async Task<WorkPieceProcessPdaOutput> getWorkPieceProcess([FromQuery] WorkPieceProcessPdaSearch input) { var workPieceProcesss = await _workPieceProcessRep.DetachedEntities @@ -411,12 +417,18 @@ /// </summary> /// <returns></returns> [HttpGet("getWorkPieceByOP80NewCode")] + [DisableOpLog] + [AllowAnonymous] public async Task<WorkPieceInfoOutput> getWorkPieceByOP80NewCode([FromQuery] WorkPieceByOP80NewCodeInputSearch input) { if (string.IsNullOrEmpty(input.OP80NewCode)) { - throw Oops.Oh($"璇疯緭鍏P80鎵撳嵃鎴愬搧鐮佹垨浜岀淮鐮侊紒"); + throw Oops.Oh($"璇疯緭鍏ユ垚鍝佺爜鎴栧伐浠剁爜锛�"); + } + if (input.OP80NewCode.Length > 22) + { + throw Oops.Oh($"宸ヤ欢鐮佹垨鎴愬搧鐮亄input.OP80NewCode}闀垮害涓嶆纭紒"); } string OP80NewCode = input.OP80NewCode.Trim(); var workPieceInfo = await _workPieceInfoRep.DetachedEntities @@ -447,6 +459,16 @@ OP80NewCode = OP80NewCode, }; } + + //鍒ゆ柇鏄惁宸茬粡鍑哄簱 + List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.DetachedEntities.Where(w => (w.WorkPieceID == OP80NewCode || w.OP80NewCode == OP80NewCode) && w.IsDeleted == false).ToListAsync(); + if (db_itemModelList != null && db_itemModelList.Count > 0) + { + var itemModel = db_itemModelList.First(); + var createitme = itemModel.CreatedTime == null ? "" : (((DateTimeOffset)itemModel.CreatedTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss")); + throw Oops.Oh($"宸ヤ欢{itemModel.WorkPieceID}宸插嚭搴擄紝鍑哄簱鏃堕棿:{createitme}"); + } + return workPieceInfo; } @@ -456,6 +478,8 @@ /// <param name="input"></param> /// <returns></returns> [HttpPost("outBoundWorkPiece")] + [DisableOpLog] + [UnitOfWork] public async Task<string> outBoundWorkPiece([FromBody] OutBoundInput input) { @@ -468,27 +492,39 @@ throw Oops.Oh("宸ヤ欢鍑哄簱澶辫触锛氭暟鎹笉鑳戒负绌猴紒"); } - List<WorkPieceInfoOutput> WorkPieceInfoLst = input.WorkPieceInfoLst; + List<OutBoundDetailsInput> WorkPieceInfoLst = input.WorkPieceInfoLst; var addOutBoundList = new List<WorkPieceOutbound>(); - var queryWorkPieceIDList = WorkPieceInfoLst.Select(x => x.WorkPieceID).ToList(); - List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.Where(w => queryWorkPieceIDList.Contains(w.WorkPieceID) && w.IsDeleted == false).ToListAsync(); + var queryOP80NewCodeList = WorkPieceInfoLst.Select(x => x.OP80NewCode).ToList(); + List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); + + List<WorkPieceInfo> db_WorkPieceInfoList = await _workPieceInfoRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); foreach (var item in WorkPieceInfoLst) { - var itemModel = db_itemModelList.FirstOrDefault(w => w.WorkPieceID == item.WorkPieceID); + var itemModel = db_itemModelList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); if (itemModel != null) { //itemModel.IsDeleted = true; //itemModel.Remark = itemModel.Remark ?? "" + "浜屾鍙戣揣鑷姩鎾ら攢鍙戣揣"; //await _workPieceOutboundRep.UpdateAsync(itemModel); var createitme = itemModel.CreatedTime == null ? "" : (((DateTimeOffset)itemModel.CreatedTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss")); - throw Oops.Oh($"宸ヤ欢{itemModel.WorkPieceID}宸插嚭搴擄紝鍑哄簱鏃堕棿:{createitme}"); + throw Oops.Oh($"鎴愬搧鐮亄itemModel.OP80NewCode}宸插嚭搴擄紝鍑哄簱鏃堕棿:{createitme}"); + } + var workPiece = db_WorkPieceInfoList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); + if (workPiece != null) + { + workPiece.OutPerson = CurrentUserInfo.Name; + workPiece.OutRemark = "鎾ら攢宸ヤ欢鍑哄簱"; + workPiece.OutTime = DateTime.Now; + workPiece.IsOut = false; + + await _workPieceInfoRep.UpdateAsync(workPiece); } var outBoundLog = new WorkPieceOutbound { - WorkPieceID = item.WorkPieceID, + WorkPieceID = workPiece?.WorkPieceID, OP80NewCode = item.OP80NewCode, WorkPieceOutboundTime = DateTime.Now, WorkPieceOutboundUserId = CurrentUserInfo.UserId, @@ -497,6 +533,8 @@ CreatedUserName = CurrentUserInfo.Name, }; addOutBoundList.Add(outBoundLog); + + } await _workPieceOutboundRep.InsertAsync(addOutBoundList); return "鍑哄簱鎴愬姛"; @@ -508,6 +546,7 @@ /// <param name="input"></param> /// <returns></returns> [HttpPost("getOutBoundWorkPieceInfoCount")] + [DisableOpLog] public async Task<string> GetOutBoundWorkPieceInfoCount() { DateTimeOffset now = DateTimeOffset.Now; // 鑾峰彇褰撳墠鏃堕棿锛屽寘鎷椂鍖哄亸绉婚噺 @@ -518,5 +557,13 @@ return db_itemModelList.Count().ToString(); } + + #region 鏂扮増 涓嬬嚎銆佸嚭搴撴墽琛� + + + + + #endregion + } } -- Gitblit v1.9.3