From 1d97bffe5449a6b3e29d619f5a45400483fb6748 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期一, 01 十二月 2025 15:41:59 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/BaseSet/Gy_MaterialController.cs |  208 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 138 insertions(+), 70 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
index b6107d7..880faae 100644
--- a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -1808,12 +1808,12 @@
                 }
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_Gy_MouldFileList " + sWhere + "order by 鏃ユ湡 desc", "h_v_Gy_MouldFileList");
+                    ds = oCN.RunProcReturn("select * from h_v_Gy_MouldFileList " + sWhere + "order by 鏉$爜缂栧彿 desc", "h_v_Gy_MouldFileList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_Gy_MouldFileList where 1 = 1 ";
-                    string sql = sql1 + sWhere + "order by 鏃ユ湡 desc";
+                    string sql = sql1 + sWhere + "order by 鏉$爜缂栧彿 desc";
                     ds = oCN.RunProcReturn(sql, "h_v_Gy_MouldFileList");
                 }
 
@@ -2918,8 +2918,7 @@
                 }
                 //=========================================================
 
-                //涓昏〃
-                oCN.RunProc("UpDate Gy_MouldFileMain set  " +
+                string sql = "UpDate Gy_MouldFileMain set  " +
                 " HBillNo='" + HBillNo + "'" +  //鍥哄畾璧嬪��===============
                 ",HDate='" + HDate + "'" +
                 ",HYear='" + HYear.ToString() + "'" +
@@ -2972,10 +2971,13 @@
                 ",HMadeSupID=" + HMadeSupID +
                 ",HNowWHID=" + HNowWHID +
                 ",HNowSPID=" + HNowSPID +
-                ",HInitLife='" + HInitLife +
-                "',HNextMainDate='" + HNextMainDate +
+                ",HInitLife='" + HInitLife + "'" +
+                ",HNextMainDate='" + HNextMainDate +
                 "',HMouldUseStatus='" + HMouldUseStatus +
-                "' where HInterID=" + HInterID.ToString());
+                "' where HInterID=" + HInterID.ToString();
+
+                //涓昏〃
+                oCN.RunProc(sql);
 
                 //淇敼瀛愰」鐩唬鐮�
                 //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Department,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
@@ -4377,11 +4379,11 @@
                 if (!tb2.Columns.Contains("鐘舵��"))
                     error += "娌℃湁鎵惧埌銆愮姸鎬併�戠殑鏍囬,";
 
-                if (!tb2.Columns.Contains("榛樿浠撳簱"))
-                    error += "娌℃湁鎵惧埌銆愰粯璁や粨搴撱�戠殑鏍囬,";
+                //if (!tb2.Columns.Contains("榛樿浠撳簱"))
+                //    error += "娌℃湁鎵惧埌銆愰粯璁や粨搴撱�戠殑鏍囬,";
 
-                if (!tb2.Columns.Contains("榛樿浠撲綅"))
-                    error += "娌℃湁鎵惧埌銆愰粯璁や粨浣嶃�戠殑鏍囬,";
+                //if (!tb2.Columns.Contains("榛樿浠撲綅"))
+                //    error += "娌℃湁鎵惧埌銆愰粯璁や粨浣嶃�戠殑鏍囬,";
 
                 if (!tb2.Columns.Contains("鐗堟湰鍙�"))
                     error += "娌℃湁鎵惧埌銆愮増鏈彿銆戠殑鏍囬,";
@@ -4442,8 +4444,8 @@
                     HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀵瑰簲ERP鐗╂枡"].ToString());
                     HUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅"].ToString());
                     HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["浣跨敤閮ㄩ棬"].ToString());
-                    HWHName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撳簱"].ToString());
-                    HSPName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撲綅"].ToString());
+                        HWHName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撳簱"].ToString());
+                        HSPName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撲綅"].ToString());
                     HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟�"].ToString());
                     HSupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString());
                     HMadeSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍒堕�犲晢"].ToString());
@@ -4534,67 +4536,83 @@
                         {
                             tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                         }
-                        //鏌ヨ浠撳簱
-                        ds = oCN.RunProcReturn("select * from Gy_Warehouse where  HName='" + HWHName + "'  and HUSEORGID=" + HORGid + "", "Gy_Warehouse");
+                        if (HWHName != "")
+                        {
+                            //鏌ヨ浠撳簱
+                            ds = oCN.RunProcReturn("select * from Gy_Warehouse where  HName='" + HWHName + "'  and HUSEORGID=" + HORGid + "", "Gy_Warehouse");
 
-                        if (ds.Tables[0].Rows.Count == 0)
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撳簱:" + HWHName + ",涓嶅瓨鍦紒";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        else
-                        {
-                            tb2.Rows[i]["HWHID"] = ds.Tables[0].Rows[0]["HSPGroupID"].ToString();
-                        }
-                        string HWHID = tb2.Rows[i]["HWHID"].ToString();
-                        //鏌ヨ浠撲綅
-                        ds = oCN.RunProcReturn("select * from Gy_StockPlace where  HName='" + HSPName + "'and HSPGroupID=" + HWHID+ "  and HUSEORGID=" + HORGid + "", "Gy_StockPlace");
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撳簱:" + HWHName + ",涓嶅瓨鍦紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                tb2.Rows[i]["HWHID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                            }
+                            
+                            string HWHID = tb2.Rows[i]["HWHID"].ToString();
+                            if (HWHID != "")
+                            {
+                                //鏌ヨ浠撲綅
+                                ds = oCN.RunProcReturn("select * from Gy_StockPlace where  HName='" + HSPName + "'and HSPGroupID=" + HWHID + "  and HUSEORGID=" + HORGid + "", "Gy_StockPlace");
 
-                        if (ds.Tables[0].Rows.Count == 0)
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撲綅:" + HSPName + ",涓嶅瓨鍦紒";
-                            objJsonResult.data = null;
-                            return objJsonResult;
+                                if (ds.Tables[0].Rows.Count == 0)
+                                {
+                                    objJsonResult.code = "0";
+                                    objJsonResult.count = 0;
+                                    objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撲綅:" + HSPName + ",涓嶅瓨鍦紒";
+                                    objJsonResult.data = null;
+                                    return objJsonResult;
+                                }
+                                else
+                                {
+                                    tb2.Rows[i]["HSPID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                                }
+                            }
+                               
                         }
-                        else
+                       if(HSupName!="")
                         {
-                            tb2.Rows[i]["HSPID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                            ds = oCN.RunProcReturn("select * from Gy_Supplier where  HNumber='" + HSupNumber + "'  and HUSEORGID=" + HORGid + "", "Gy_Supplier");
+
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,渚涘簲鍟�:" + HSupName + ",涓嶅瓨鍦紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                tb2.Rows[i]["HSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                            }
                         }
                         //鏌ヨ渚涘簲鍟�
-                        ds = oCN.RunProcReturn("select * from Gy_Supplier where  HNumber='" + HSupNumber + "'  and HUSEORGID=" + HORGid + "", "Gy_Supplier");
+                       if(HMadeSupName!="")
+                        {
+                            //鏌ヨ鍒堕�犲晢
+                            ds = oCN.RunProcReturn("select * from Gy_Supplier where  HName='" + HMadeSupName + "'  and HUSEORGID=" + HORGid + "", "Gy_Supplier");
 
-                        if (ds.Tables[0].Rows.Count == 0)
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,渚涘簲鍟�:" + HSupName + ",涓嶅瓨鍦紒";
-                            objJsonResult.data = null;
-                            return objJsonResult;
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍒堕�犲晢:" + HMadeSupName + ",涓嶅瓨鍦紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                tb2.Rows[i]["HMadeSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                            }
                         }
-                        else
-                        {
-                            tb2.Rows[i]["HSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
-                        }
-                        //鏌ヨ鍒堕�犲晢
-                        ds = oCN.RunProcReturn("select * from Gy_Supplier where  HName='" + HMadeSupName + "'  and HUSEORGID=" + HORGid + "", "Gy_Supplier");
-
-                        if (ds.Tables[0].Rows.Count == 0)
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍒堕�犲晢:" + HMadeSupName + ",涓嶅瓨鍦紒";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        else
-                        {
-                            tb2.Rows[i]["HMadeSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
-                        }
+              
+                        
 
                         //鍣ㄥ叿妗f鍚嶇О
                         if (HMouldName == "")
@@ -4704,15 +4722,19 @@
                     long HUnitID = int.Parse(item["HUnitID"].ToString());
                     DateTime HOutComDate = DateTime.Now;
                     string HOutComNo = item["鍣ㄥ叿鍑哄巶缂栧彿"].ToString();
-                    long HDeptID = int.Parse(item["HDeptID"].ToString());
-                    long HSupID = int.Parse(item["HSupID"].ToString());
+                    var HDeptID_temp = item["HDeptID"].ToString() == "" ? "0" : item["HDeptID"].ToString();
+                    long HDeptID = int.Parse(HDeptID_temp);
+                    var HSupID_temp = item["HSupID"].ToString() == "" ? "0" : item["HSupID"].ToString();
+                    long HSupID = int.Parse(HSupID_temp);
                     string HMouldStatus = item["鐘舵��"].ToString();
-                    long HWHID = int.Parse(item["HWHID"].ToString());
+                    var HWHID_TEMP = item["HWHID"].ToString() == "" ? "0" : item["HWHID"].ToString();
+                    long HWHID = int.Parse(HWHID_TEMP);
                     long HRoutingID = 0;//宸ヨ壓璺嚎id
                     long HBOMID = 0;
                     string HVersion = "";//鐗堟湰
                     long HSPGroupID = 0;//榛樿浠撲綅缁�
-                    long HSPID = int.Parse(item["HSPID"].ToString());//浠撲綅id
+                    var HSPID_temp = item["HSPID"].ToString() == "" ? "0" : item["HSPID"].ToString();
+                    long HSPID = int.Parse(HSPID_temp);//浠撲綅id
                     Double HDesignLife = item["璁捐瀵垮懡"].ToString()=="" ? 0: double.Parse(item["璁捐瀵垮懡"].ToString());
                     Double HUseLife = item["浣跨敤瀵垮懡"].ToString() == "" ? 0 : double.Parse(item["浣跨敤瀵垮懡"].ToString());
                     Double HInitLife = 0;//涓婄嚎鍒濆鍖栧鍛�
@@ -4855,5 +4877,51 @@
         #endregion
         #endregion
 
+
+        //鏍规嵁鏉$爜鎵剧墿鏂欎俊鎭�
+        [Route("Gy_Material/findMaterialByNumber")]
+        [HttpGet]
+        public object findMaterialByNumber(string HbarCode,string HSTOCKORGID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn($"select * from Gy_BarCodeBill where HBarCode='{HbarCode}' ", "Gy_Material");
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎴愬姛";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception)
+            {
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒濆鍖栧け璐ワ紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+        [Route("Gy_BarCodeBillList/GetBarCodeBillPermission")]
+        [HttpGet]
+        public object GetBarCodeBillPermission(string user)
+        {
+            if (!DBUtility.ClsPub.Security_Log("Gy_BarCodeBillList_Print", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犳潈闄愭煡璇�!";
+                objJsonResult.data = 0;
+                return objJsonResult;
+            }
+            else
+            {
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+                
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1