From 6f89acbf74c6838db518a9f2b6c83f0ab0d97e7f Mon Sep 17 00:00:00 2001
From: 杨张扬 <634643841@qq.com>
Date: 星期二, 29 七月 2025 18:13:31 +0800
Subject: [PATCH] 余料回库流程增加绑定和解绑,RFID校验必须校验开头

---
 api/ApiHelper.cs |  156 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 156 insertions(+), 0 deletions(-)

diff --git a/api/ApiHelper.cs b/api/ApiHelper.cs
index b12c74c..ba574df 100644
--- a/api/ApiHelper.cs
+++ b/api/ApiHelper.cs
@@ -326,6 +326,162 @@
         }
 
         /// <summary>
+        /// 浣欐枡瑙g粦鍑哄簱
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static SimpleResult SurplusUnBind(SurplusUnBindInfo model)
+        {
+            LogHelper.Info("瑙﹀彂API锛氫綑鏂欑粦瀹氬叆搴� + JsonConvert.SerializeObject(model), "API");
+            var result = new SimpleResult();//杩斿洖缁撴灉
+            try
+            {
+                if (string.IsNullOrWhiteSpace(model.spec))
+                {
+                    result.resultCode = -1;
+                    result.resultMsg = $"瑙勬牸鍙傛暟涓嶈兘涓虹┖锛屼篃涓嶈兘涓虹┖瀛楃涓�;
+                    LogHelper.Info(result.resultMsg);
+                    return result;
+                }
+
+                if (string.IsNullOrWhiteSpace(model.loc))
+                {
+                    result.resultCode = -1;
+                    result.resultMsg = $"璐т綅鍙傛暟涓嶈兘涓虹┖锛屼篃涓嶈兘涓虹┖瀛楃涓�;
+                    LogHelper.Info(result.resultMsg);
+                    return result;
+                }
+
+                if (model.weight <= 0)
+                {
+                    result.resultCode = -1;
+                    result.resultMsg = $"閲嶉噺鍙傛暟蹇呴』澶т簬0";
+                    LogHelper.Info(result.resultMsg);
+                    return result;
+                }
+
+                var db = new SqlHelper<object>().GetInstance();
+
+                
+                var cgDetail = db.Queryable<TN_CG_Detail>()
+                    .First(a => a.S_LOC_CODE == model.loc
+                    && a.S_USE_TYPE == "浣欐枡" 
+                    &&(a.S_ITEM_SPEC == model.spec || a.S_SPE == model.spec)
+                    && a.F_QTY == model.weight);
+                
+                if (cgDetail == null)
+                {
+                    result.resultCode = -1;
+                    result.resultMsg = $"搴撲綅{model.loc}瀵瑰簲鐨勭墿鏂欐槑缁嗕笉瀛樺湪锛屾棤闇�嚭搴�;
+                    LogHelper.Info(result.resultMsg);
+                    return result;
+                }
+
+                using (var trans = db.Ado.UseTran())
+                {
+                    if (db.Deleteable<TN_CG_Detail>(cgDetail).ExecuteCommand() > 0 )
+                    {
+                        trans.CommitTran();
+                        result.resultCode = 0;
+                        result.resultMsg = $"鍑哄簱鎴愬姛锛岃揣浣嶏細{model.loc}锛岃В缁戠殑璐у搧涓猴細{JsonConvert.SerializeObject(cgDetail)}";
+                        LogHelper.Info(result.resultMsg);
+                        return result;
+                    }
+                    else
+                    {
+                        trans.RollbackTran();
+                        result.resultCode = -1;
+                        result.resultMsg = $"鍑哄簱澶辫触锛岃揣浣嶏細{model.loc}";
+                        LogHelper.Info(result.resultMsg);
+                        return result;
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                result.resultCode = -1;
+                result.resultMsg = $"PDA婊℃墭澶嶆鍒ゆ柇锛屽彂鐢熶簡寮傚父锛歿ex.Message}";
+                LogHelper.Info(result.resultMsg);
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// 浣欐枡缁戝畾鍏ュ簱
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static SimpleResult SurplusBind(SurplusBindInfo model)
+        {
+            LogHelper.Info("瑙﹀彂API锛氫綑鏂欑粦瀹氬叆搴� + JsonConvert.SerializeObject(model), "API");
+            var result = new SimpleResult();//杩斿洖缁撴灉
+            try
+            {
+                if (string.IsNullOrWhiteSpace(model.spec))
+                {
+                    result.resultCode = -1;
+                    result.resultMsg = $"瑙勬牸鍙傛暟涓嶈兘涓虹┖锛屼篃涓嶈兘涓虹┖瀛楃涓�;
+                    LogHelper.Info(result.resultMsg);
+                    return result;
+                }
+
+                if (string.IsNullOrWhiteSpace(model.loc))
+                {
+                    result.resultCode = -1;
+                    result.resultMsg = $"璐т綅鍙傛暟涓嶈兘涓虹┖锛屼篃涓嶈兘涓虹┖瀛楃涓�;
+                    LogHelper.Info(result.resultMsg);
+                    return result;
+                }
+
+                if (model.weight <= 0)
+                {
+                    result.resultCode = -1;
+                    result.resultMsg = $"閲嶉噺鍙傛暟蹇呴』澶т簬0";
+                    LogHelper.Info(result.resultMsg);
+                    return result;
+                }
+
+                var db = new SqlHelper<object>().GetInstance();
+
+                var cgDetail = new TN_CG_Detail()
+                {
+                    S_ITEM_SPEC = model.spec,
+                    S_SPE = model.spec,
+                    F_QTY = model.weight,
+                    S_LOC_CODE = model.loc,
+                    S_USE_TYPE = "浣欐枡",
+                };
+
+                using (var trans = db.Ado.UseTran())
+                {
+                    if (db.Insertable<TN_CG_Detail>(cgDetail).ExecuteCommand() > 0 )
+                    {
+                        trans.CommitTran();
+                        result.resultCode = 0;
+                        result.resultMsg = $"鍏ュ簱鎴愬姛锛岃揣浣嶏細{model.loc}锛屽凡缁戝畾璐у搧锛寋JsonConvert.SerializeObject(cgDetail)}";
+                        LogHelper.Info(result.resultMsg);
+                        return result;
+                    }
+                    else
+                    {
+                        trans.RollbackTran();
+                        result.resultCode = -1;
+                        result.resultMsg = $"鍏ュ簱澶辫触锛岃揣浣嶏細{model.loc}";
+                        LogHelper.Info(result.resultMsg);
+                        return result;
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                result.resultCode = -1;
+                result.resultMsg = $"PDA婊℃墭澶嶆鍒ゆ柇锛屽彂鐢熶簡寮傚父锛歿ex.Message}";
+                LogHelper.Info(result.resultMsg);
+                return result;
+            }
+        }
+
+        /// <summary>
         /// 绾胯竟绌烘墭鍒扮┖鎵樺爢鍙犲尯
         /// </summary>
         /// <param name="model"></param>

--
Gitblit v1.9.1