From f6e624ccbea24503d0a77e839eeb2af13038d8ac Mon Sep 17 00:00:00 2001
From: cjs <2216046164@qq.com>
Date: 星期一, 30 六月 2025 17:31:46 +0800
Subject: [PATCH] 111

---
 HH.WCS.Mobox3.NongFuLinZhi/api/ApiHelper.cs |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/HH.WCS.Mobox3.NongFuLinZhi/api/ApiHelper.cs b/HH.WCS.Mobox3.NongFuLinZhi/api/ApiHelper.cs
index 83a590a..5e3f3fa 100644
--- a/HH.WCS.Mobox3.NongFuLinZhi/api/ApiHelper.cs
+++ b/HH.WCS.Mobox3.NongFuLinZhi/api/ApiHelper.cs
@@ -673,6 +673,50 @@
             return result;
         }
 
+        internal static ReturnResult bindCntr(bindModel model)
+        {
+            ReturnResult result = new ReturnResult() {ResultCode = -1 };
+            var db = new SqlHelper<object>().GetInstance();
+
+            if (TaskProcess.BindLocCntr(model.S_LOC_CODE, model.S_CNTR_CODE, model.S_ITEM_CODE, model.S_BATCH_CODE))
+            {
+                int num = model.S_CNTR_CODE.Split(',').Count();
+                var locInfo = db.Queryable<Location>().Where(a => a.S_CODE == model.S_LOC_CODE).First();
+                if(locInfo != null)
+                {
+                    locInfo.N_CURRENT_NUM = locInfo.N_CURRENT_NUM + num > locInfo.N_CAPACITY ? locInfo.N_CAPACITY : locInfo.N_CURRENT_NUM + num;
+                    db.Updateable(locInfo).UpdateColumns(a => new { a.N_CURRENT_NUM }).ExecuteCommand();
+                    result.ResultCode = 0;
+                }
+            }
+            return result;
+        }
+
+        internal static ReturnResult unBindCntr(unBindModel model)
+        {
+            ReturnResult result = new ReturnResult() { ResultCode = -1 };
+            var db = new SqlHelper<object>().GetInstance();
+            var locInfo = db.Queryable<Location>().Where(a => a.S_CODE == model.S_LOC_CODE).First();
+            if(locInfo != null)
+            {
+                var cntrList = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == model.S_LOC_CODE).ToList();
+                if(cntrList.Count > 0)
+                {
+                    for (int i = cntrList.Count - 1; i >= 0; i --)
+                    {
+                        string cntrCode = cntrList[i].S_CNTR_CODE;
+                        db.Deleteable<CntrItemRel>().Where(a => a.S_CNTR_CODE == cntrCode).ExecuteCommand();
+                        db.Deleteable<LocCntrRel>().Where(a => a.S_CNTR_CODE == cntrCode).ExecuteCommand();
+                    }
+                }
+                locInfo.N_CURRENT_NUM = locInfo.N_CURRENT_NUM - 1;
+                if (locInfo.N_CURRENT_NUM < 0) locInfo.N_CURRENT_NUM = 0;
+                db.Updateable(locInfo).UpdateColumns(a => new { a.N_CURRENT_NUM }).ExecuteCommand();
+                result.ResultCode = 0;
+            }
+            return result;
+        }
+
 
         //public class AddTaskModel
         //{

--
Gitblit v1.9.1