From 8ca2d296feab2534837b166908d16983d79a0696 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 17 三月 2023 09:15:56 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs |  150 +++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 111 insertions(+), 39 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
index 95da203..d8fe2f7 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
@@ -141,10 +141,10 @@
         }
         #endregion
 
-        #region 濮斿宸ュ簭鍙戝嚭鍗曟祦姘村彿鍥炶溅鑾峰彇鏉$爜淇℃伅2锛堝澶栧伐搴忔帴鏀躲�佸伐搴忚繘绔欐帴鏀堕�氱敤锛�
+        #region 濮斿宸ュ簭鍙戝嚭鍗曟祦姘村彿鍥炶溅鑾峰彇鏉$爜淇℃伅2
         [Route("Cj_StationBill/txtHBarCode_KeyDown2")]
         [HttpGet]
-        public object txtHBarCode_KeyDown2(string HBarCode,string HInterID,string UserID)
+        public object txtHBarCode_KeyDown2(string HBarCode,string HInterID,string UserID,string HBillType)
         {
             try
             {
@@ -204,15 +204,31 @@
                         string sReturn = "";
                         if (oSystemParameter.ShowBill(ref sReturn) == true)
                         {
-                            //绯荤粺鍙傛暟鏄惁涓哄彧鏄剧ず褰撳墠鐧诲綍鐢ㄦ埛鍏宠仈鐨勫伐搴忎俊鎭�,N涓哄惁锛孻涓烘槸
-                            if (oSystemParameter.omodel.MES_StationInBill_ShowUSERProcess == "Y")
+                            if(HBillType == "In")
                             {
-                                ds = oCN.RunProcReturn("select * from h_v_Gy_ProcessList_GetProcNoByUser  where HItemID = '" + BillNo + "' and HInterID = '" + HInterID + "' and 鐢ㄦ埛缂栫爜 = '" + UserID + "'", "h_v_Gy_ProcessList_GetProcNoByUser");
+                                //绯荤粺鍙傛暟鏄惁涓哄彧鏄剧ず褰撳墠鐧诲綍鐢ㄦ埛鍏宠仈鐨勫伐搴忎俊鎭�,N涓哄惁锛孻涓烘槸
+                                if (oSystemParameter.omodel.MES_StationInBill_ShowUSERProcess == "Y")
+                                {
+                                    ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_ProcessList_GetProcNoByUser where HItemID = '" + BillNo + "' and HInterID = '" + HInterID + "' and 鐢ㄦ埛缂栫爜 = '" + UserID + "'" + " order by 搴忓彿 asc", "h_v_Gy_ProcessList_GetProcNoByUser");
+                                }
+                                else
+                                {
+                                    ds = oCN.RunProcReturn("select * from h_v_Gy_ProcessList_GetProcNo  where HItemID = '" + BillNo + "' and HInterID = '" + 
+                                      HInterID + "'" + " order by 搴忓彿 asc", "h_v_Gy_ProcessList_GetProcNo");
+                                }
                             }
-                            else
+                            else if(HBillType == "Out")
                             {
-                                ds = oCN.RunProcReturn("select * from h_v_Gy_ProcessList_GetProcNo  where HItemID = '" + BillNo + "' and HInterID = '" + 
-                                  HInterID + "'", "h_v_Gy_ProcessList_GetProcNo");
+                                //绯荤粺鍙傛暟鏄惁涓哄彧鏄剧ず褰撳墠鐧诲綍鐢ㄦ埛鍏宠仈鐨勫伐搴忎俊鎭�,N涓哄惁锛孻涓烘槸
+                                if (oSystemParameter.omodel.MES_StationOutBill_ShowUSERProcess == "Y")
+                                {
+                                    ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_ProcessList_GetProcNoByUser where HItemID = '" + BillNo + "' and HInterID = '" + HInterID + "' and 鐢ㄦ埛缂栫爜 = '" + UserID + "'" + " order by 搴忓彿 asc", "h_v_Gy_ProcessList_GetProcNoByUser");
+                                }
+                                else
+                                {
+                                    ds = oCN.RunProcReturn("select * from h_v_Gy_ProcessList_GetProcNo  where HItemID = '" + BillNo + "' and HInterID = '" +
+                                      HInterID + "'" + " order by 搴忓彿 asc", "h_v_Gy_ProcessList_GetProcNo");
+                                }
                             }
                         }
                         break;
@@ -265,59 +281,115 @@
         #region 鏍规嵁鐧诲綍鐢ㄦ埛鑾峰彇宸ュ簭
         [Route("Sc_StationInBill/autoGetProcNo")]
         [HttpGet]
-        public object autoGetProcNo(string HUserID, string HInterID)
+        public object autoGetProcNo(string HUserID, string HInterID, string BillType)
         {
             string sReturn = "";
             if (oSystemParameter.ShowBill(ref sReturn) == true)
             {
-                //绯荤粺鍙傛暟鏄惁涓鸿嚜鍔ㄥ尮閰嶆祦姘村彿,N涓烘墜鍔ㄨ緭鍏ワ紝Y涓鸿嚜鍔ㄥ尮閰�
-                if (oSystemParameter.omodel.MES_StationOutBill_ShowUSERProcess == "Y")
+                if(BillType == "In")//宸ュ簭杩涚珯鎺ユ敹鍗�
                 {
-                    try
+                    //绯荤粺鍙傛暟鏄惁涓鸿嚜鍔ㄥ尮閰嶆祦姘村彿,N涓烘墜鍔ㄨ緭鍏ワ紝Y涓鸿嚜鍔ㄥ尮閰�
+                    if (oSystemParameter.omodel.MES_StationInBill_AutoFindSNO == "Y")
                     {
-                        if (HUserID == null || HUserID.Equals(""))
+                        try
+                        {
+                            if (HUserID == null || HUserID.Equals(""))
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鐢ㄦ埛缂栫爜涓嶈兘涓虹┖锛�";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            //寰楀埌淇℃伅                     
+                            ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_StationBill_autoGetProcNo  where HInterID = '" + HInterID + "' and 鐢ㄦ埛缂栫爜 ='" + HUserID + "'" + " and 绱杩涚珯鏁伴噺 < 璁″垝鏁伴噺 and 涓嬮亾娴佽浆宸ュ簭<>'杞�' and 濮斿鏍囪=0 order by 搴忓彿 asc", "h_v_Sc_StationBill_autoGetProcNo");
+                            //鍐欏叆淇℃伅
+                            if (ds == null || ds.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鏈煡璇㈠埌宸ュ簭淇℃伅锛�";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "Sucess锛�";
+                            objJsonResult.data = ds.Tables[0];
+                            return objJsonResult;
+                        }
+                        catch (Exception e)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
-                            objJsonResult.Message = "鐢ㄦ埛缂栫爜涓嶈兘涓虹┖锛�";
+                            objJsonResult.Message = "Exception锛�" + e.ToString();
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //寰楀埌淇℃伅
-                        ds = oCN.RunProcReturn("select  * from h_v_Sc_StationBill_autoGetProcNo  where HInterID = '" + HInterID + "' and 鐢ㄦ埛缂栫爜 ='" + HUserID + "'", "h_v_Sc_StationBill_autoGetProcNo");
-                        //鍐欏叆淇℃伅
-                        if (ds == null || ds.Tables[0].Rows.Count == 0)
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鏈煡璇㈠埌宸ュ簭淇℃伅锛�";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        objJsonResult.code = "1";
-                        objJsonResult.count = 1;
-                        objJsonResult.Message = "Sucess锛�";
-                        objJsonResult.data = ds.Tables[0];
-                        return objJsonResult;
                     }
-                    catch (Exception e)
+                    else
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
-                        objJsonResult.Message = "Exception锛�" + e.ToString();
-                        objJsonResult.data = null;
+                        objJsonResult.Message = "鎵嬪姩杈撳叆妯″紡";
+                        objJsonResult.data = "";
+                        return objJsonResult;
+                    }
+                }
+                else if(BillType == "Out")//宸ュ簭鍑虹珯姹囨姤鍗�
+                {
+                    //绯荤粺鍙傛暟鏄惁涓鸿嚜鍔ㄥ尮閰嶆祦姘村彿,N涓烘墜鍔ㄨ緭鍏ワ紝Y涓鸿嚜鍔ㄥ尮閰�
+                    if (oSystemParameter.omodel.MES_StationOutBill_AutoFindSNO == "Y")
+                    {
+                        try
+                        {
+                            if (HUserID == null || HUserID.Equals(""))
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鐢ㄦ埛缂栫爜涓嶈兘涓虹┖锛�";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            //寰楀埌淇℃伅
+                            ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_StationBill_autoGetProcNo  where HInterID = '" + HInterID + "' and 鐢ㄦ埛缂栫爜 ='" + HUserID + "'" + " and 绱鍑虹珯鏁伴噺 < 璁″垝鏁伴噺 and 涓嬮亾娴佽浆宸ュ簭<>'杞�' and 濮斿鏍囪=0 order by 搴忓彿 asc", "h_v_Sc_StationBill_autoGetProcNo");
+                            //鍐欏叆淇℃伅
+                            if (ds == null || ds.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鏈煡璇㈠埌宸ュ簭淇℃伅锛�";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "Sucess锛�";
+                            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;
+                        }
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鎵嬪姩杈撳叆妯″紡";
+                        objJsonResult.data = "";
                         return objJsonResult;
                     }
                 }
                 else
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鎵嬪姩杈撳叆妯″紡";
-                    objJsonResult.data = "";
-                    return objJsonResult;
+                    return 0;
                 }
-
             }
             else
             {

--
Gitblit v1.9.1