From 1b4310c60ecb7bd07f27a6c0bb04aae0d960f6a3 Mon Sep 17 00:00:00 2001 From: chenwenkai <1084072318@qq.com> Date: Fri, 8 Nov 2024 14:48:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E4=BD=8D=E7=BC=96=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E5=BA=93=E4=BD=8D=E6=8E=A5=E5=8F=A3=EF=BC=9B?= =?UTF-8?q?=E6=8F=90=E6=8A=A5=E5=85=A5=E5=BA=93=E6=8A=A5=E9=94=99=E5=9B=9E?= =?UTF-8?q?=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BasicData/Tnb.BasicData/BasLocationService.cs | 33 +++++++++++++++++++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 1 + 2 files changed, 34 insertions(+) diff --git a/BasicData/Tnb.BasicData/BasLocationService.cs b/BasicData/Tnb.BasicData/BasLocationService.cs index af13f6d3..fb218647 100644 --- a/BasicData/Tnb.BasicData/BasLocationService.cs +++ b/BasicData/Tnb.BasicData/BasLocationService.cs @@ -1,5 +1,6 @@ using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.FriendlyException; using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.BasicData.Entities; @@ -48,5 +49,37 @@ namespace Tnb.BasicData List items = await _db.Queryable().Where(it => locIds.Contains(it.id)).ToListAsync(); return items; } + + + + /// + /// 根据库位编码,清空库位 + /// + /// + /// + [HttpPost] + public async Task ClearLocation(Dictionary dic) + { + try + { + var location_code = dic["code"].ToString(); + if (string.IsNullOrEmpty(location_code)) + throw Oops.Bah("库位编码不能为空"); + + var location = await _db.Queryable().Where(r => r.location_code == location_code).FirstAsync(); + if (location == null) + throw Oops.Bah($"库位编号{location_code}不存在"); + await _db.Ado.BeginTranAsync(); + //把状态改为空闲 + await _db.Updateable().SetColumns(r => r.is_use == "0").Where(r=>r.id==location.id).ExecuteCommandAsync(); + await _db.Ado.CommitTranAsync(); + } + catch(Exception e) + { + await _db.Ado.RollbackTranAsync(); + throw Oops.Bah(e.Message); + } + return "成功"; + } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 89b1b690..a8b22004 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2758,6 +2758,7 @@ namespace Tnb.ProductionMgr } catch (Exception e) { + await db.Ado.RollbackTranAsync(); Log.Error("提报入库任务下发失败:"+e.Message, e); throw new Exception("提报入库任务下发失败:"+e.Message); }