From 461a7bfc0a2250ec5ff4b7a85cb6ce3c2f0bf06e Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期二, 13 八月 2024 11:20:44 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/BaseSet/Gy_MaterialController.cs |  124 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 123 insertions(+), 1 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
index 5e64423..d899f19 100644
--- a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -13,6 +13,7 @@
 using System.Windows.Forms;
 using WebAPI.Models;
 using WebAPI.Service;
+using System.Text.RegularExpressions;
 
 namespace WebAPI.Controllers
 {
@@ -113,6 +114,127 @@
                 return objJsonResult;
             }
         }
+
+        #region 鐗╂枡鏍规嵁鍒嗙被鑾峰彇鏈�澶х墿鏂欑紪鐮�
+        [Route("Gy_Material/getMaxNum")]
+        [HttpGet]
+        public object getMaxNum(int HMaterTypeID, string user, string Organization)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Material", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (HMaterTypeID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁閫夋嫨鍏蜂綋鍒嗙被锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn(@"select * from h_v_Gy_MaterialList where 缁勭粐鍚嶇О='" + Organization + "'" + "and HMaterTypeID = '"+ HMaterTypeID + "'" + " order by 鐗╂枡浠g爜 desc", "h_v_Gy_MaterialList");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "娌℃湁鎵惧埌璇ュ垎绫荤殑鐗╂枡缂栫爜璇蜂娇鐢ㄦ櫘閫氭柊澧�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    string HNumber = ds.Tables[0].Rows[0]["鐗╂枡浠g爜"].ToString();
+                    // 浣跨敤姝e垯琛ㄨ揪寮忔壘鍒版暟瀛楅儴鍒�  (?<=\D)鏄竴涓浂瀹芥柇瑷�锛岃〃绀哄墠闈㈢殑瀛楃涓嶆槸鏁板瓧 (\d+)$琛ㄧず鍚庨潰璺熺潃涓�杩炰覆瀛楃涓茬煡閬撴湯灏�
+                    Match match = Regex.Match(HNumber, @"(?<=\D)(\d+)$");
+                    if (match.Success)
+                    {
+                        string prefix = HNumber.Substring(0, HNumber.Length - match.Length); // 鎻愬彇鍓嶇紑  
+                        int number = int.Parse(match.Value); // 瑙f瀽鏁板瓧  
+                        // 鏁板瓧+1  
+                        number++;
+                        // 鏍煎紡鍖栨暟瀛楋紝淇濇寔鍘熼暱搴�  
+                        string formattedNumber = number.ToString().PadLeft(match.Length, '0');
+                        // 閲嶆柊缁勫悎瀛楃涓�  
+                        string result = prefix + formattedNumber;
+
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "success";
+                        objJsonResult.data = result;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "姝ゅ垎绫荤墿鏂欑紪鐮佹牸寮忔湁璇�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鑾峰彇鐗╂枡绮惧害閫氳繃id
+        [Route("Gy_Material/getDecByID")]
+        [HttpGet]
+        public object getDecByID(int HMaterID)
+        {
+            try
+            {
+                if(HMaterID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁閫夋嫨鐗╂枡";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                ds = oCN.RunProcReturn(@"select HQtyDec,HPriceDec,HMoneyDec from Gy_Material where HitemID=" + HMaterID , "Gy_Material");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "娌℃湁鎵惧埌璇ョ墿鏂欑紪鐮�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Success";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
 
         /// <summary>
         /// 鐗╂枡璁剧疆鑾峰彇淇℃伅
@@ -1951,7 +2073,7 @@
                 ,HPERUNITSTANDHOUR,HSTDLABORPREPARETIME,HSTDMACHINEPREPARETIME
                  )
                 values
-                ({jsonData.HItemID},{jsonData.HERPItemID},'{jsonData.HNumber}','{jsonData.HName}','{jsonData.HModel}',
+                ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}','{jsonData.HModel}',
                 '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}',{jsonData.HMaterClsID},{jsonData.HUnitID},{jsonData.HUnitGroupID},{jsonData.HLength},{jsonData.HWidth},{jsonData.HHeight},{jsonData.HJQty},{jsonData.HMQty},'{jsonData.HOldMaterNumber}',{jsonData.HWHID},{jsonData.HSPID},'{jsonData.HPlanMode}','{jsonData.HUseFlag}','{jsonData.HMakeTime}',{jsonData.HMinPickQty},{jsonData.HCREATEORGID},{jsonData.HUSEORGID},'{jsonData.HBatchManager}',{jsonData.HCHECKINCOMING},{jsonData.HAuxPropFlag},{jsonData.HISKFPERIOD},{jsonData.HAuxUnitID},{jsonData.HSNUnitID},{jsonData.HBASEUNITID},{jsonData.HSALEUNITID},{jsonData.HSALEPRICEUNITID},{jsonData.HPERUNITSTANDHOUR},'{jsonData.HSTDLABORPREPARETIME}','{jsonData.HSTDMACHINEPREPARETIME}')";
 
                     oCN.RunProc(sql);

--
Gitblit v1.9.1