From 841d00c7c874c2429564bbe166b82d8f7d007137 Mon Sep 17 00:00:00 2001
From: chenwenkai <1084072318@qq.com>
Date: Wed, 13 Nov 2024 09:18:29 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=A9=E7=9B=8A=E5=9B=9B=E5=8E=82=E5=9B=9B?=
=?UTF-8?q?=E6=A5=BC=E4=B8=8D=E5=90=88=E6=A0=BC=E5=93=81=E7=A7=BB=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/Inputs/UnqualifyTransferInput.cs | 24 +++++++++
.../Tnb.WarehouseMgr/WmsPDATransferService.cs | 49 +++++++++++++++++++
2 files changed, 73 insertions(+)
create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/UnqualifyTransferInput.cs
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/UnqualifyTransferInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/UnqualifyTransferInput.cs
new file mode 100644
index 00000000..419af685
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/UnqualifyTransferInput.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.BouncyCastle.Bcpg.OpenPgp;
+
+namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
+{
+ ///
+ /// 不合格品移库
+ ///
+ public class UnqualifyTransferInput
+ {
+ ///
+ /// 载具编号
+ ///
+ public string carry_code { get; set; }
+ ///
+ /// 终点库位
+ ///
+ public string end_location_code { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs
index 51ecc8f6..64c41473 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs
@@ -9,6 +9,7 @@ using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
+using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis;
using SqlSugar;
using Tnb.BasicData.Entities;
@@ -16,6 +17,7 @@ using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
@@ -182,6 +184,53 @@ namespace Tnb.WarehouseMgr
throw Oops.Oh(ErrorCode.COM1001);
}
}
+
+ ///
+ /// 转移不合格品(api/wms/wms-pda-transfer/transfer-unqualify)
+ ///
+ ///
+ [HttpPost]
+ public async Task TransferUnqualify(UnqualifyTransferInput input)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(input.carry_code))
+ throw Oops.Bah("载具编号不能为空");
+ if (string.IsNullOrEmpty(input.end_location_code))
+ throw Oops.Bah("终点库位不能为空");
+
+ var wmsCarryH = await _db.Queryable().Where(r => r.carry_code == input.carry_code).FirstAsync();
+ if (wmsCarryH == null)
+ throw Oops.Bah($"不存在编号为{input.carry_code}的载具");
+ var endLocation = await _db.Queryable().Where(r => r.location_code == input.end_location_code).FirstAsync();
+ if (endLocation == null)
+ throw Oops.Bah($"不存在编号为{input.end_location_code}的库位");
+ if (endLocation.is_lock == 1)
+ throw Oops.Bah($"库位编号{input.end_location_code}已被锁定,无法入库");
+ if (string.IsNullOrEmpty(wmsCarryH.location_id))
+ throw Oops.Bah($"载具编号{input.carry_code}未绑定库位");
+ var startLocation=await _db.Queryable().Where(r=>r.id==wmsCarryH.location_id).FirstAsync();
+ if (startLocation == null)
+ throw Oops.Bah($"载具编号{input.carry_code}绑定的库位未找到");
+
+ await _db.Ado.BeginTranAsync();
+
+ //先解锁起点库位,再锁定终点库位,载具重新绑定终点库位
+
+ await _db.Updateable().SetColumns(r => r.is_lock == 0).Where(r => r.id == startLocation.id).ExecuteCommandAsync();
+ await _db.Updateable().SetColumns(r => r.is_lock == 1).Where(r => r.id == endLocation.id).ExecuteCommandAsync();
+ await _db.Updateable().SetColumns(r => r.location_id == endLocation.id).SetColumns(r => r.location_code == endLocation.location_code).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync();
+
+ //生成转库单给bip
+
+ await _db.Ado.CommitTranAsync();
+ }
+ catch (Exception e)
+ {
+
+ }
+ return null;
+ }
}
}