From ac3fdc886f4f5f15f3e0a77c315ba0571beed94a Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 01 三月 2023 10:07:20 +0800
Subject: [PATCH] 用户关联工序;工序进出站自动匹配对应流水号

---
 WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs |  183 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 158 insertions(+), 25 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
index e84c7db..9f2f099 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -28,6 +29,7 @@
         {
             try
             {
+                List<object> columnNameList = new List<object>();
                 //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
                 if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustInBill_Query", 1, false, user))
                 {
@@ -40,30 +42,41 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustInBillList " + sWhere+ " order by 鍙戝嚭鏃堕棿 desc", "h_v_MES_StationEntrustInBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustInBillList", "h_v_MES_StationEntrustInBillList");
+                    //  order by hmainid desc 鎺掑簭涓㈠埌鏁版嵁搴撻噷杩涜澶勭悊
                 }
                 else
                 {
-                    string sql1 = "select * from h_v_MES_StationEntrustInBillList where 1 = 1  order by 鍙戝嚭鏃堕棿 desc";
-                    string sql = sql1 + sWhere;
+                    string sql1 = "select * from h_v_MES_StationEntrustInBillList where 1 = 1  ";
+                    string sql = sql1 + sWhere+ " order by hmainid desc";
                     ds = oCN.RunProcReturn(sql, "h_v_MES_StationEntrustInBillList");
                 }
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "false锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "Sucess锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception e)
             {
@@ -107,7 +120,7 @@
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鏈煡璇㈠埌娴佽浆鍗′俊鎭紒";
+                    objJsonResult.Message = "鏈煡璇㈠埌娴佹按鍙蜂俊鎭紒宸ュ簭鍙烽敊璇垨鑰呭綋鍓嶅伐搴忓彿涓嶅厑璁歌繘绔欙紝璇锋坊鍔狅紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
@@ -115,6 +128,123 @@
                 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;
+            }
+        }
+        #endregion
+
+        #region 鏍规嵁鐧诲綍鐢ㄦ埛鑾峰彇宸ュ簭
+        [Route("Sc_StationInBill/autoGetProcNo")]
+        [HttpGet]
+        public object autoGetProcNo(string HUserName,string HInterID)
+        {
+            string sReturn = "";
+            if (oSystemParameter.ShowBill(ref sReturn) == true)
+            {
+                //绯荤粺鍙傛暟鏄惁涓鸿嚜鍔ㄥ尮閰嶆祦姘村彿,N涓烘墜鍔ㄨ緭鍏ワ紝Y涓鸿嚜鍔ㄥ尮閰�
+                if (oSystemParameter.omodel.MES_StationBill_ProcNo == "Y")
+                {
+                    try
+                    {
+                        if (HUserName == null || HUserName.Equals(""))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鐢ㄦ埛鍚嶄笉鑳戒负绌猴紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //寰楀埌淇℃伅
+                        ds = oCN.RunProcReturn("select  * from h_v_Sc_StationBill_autoGetProcNo  where HInterID = '" + HInterID + "' and 鐢ㄦ埛鍚嶇О ='" + HUserName + "'", "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;
+            }
+
+            
+        }
+        #endregion
+
+
+        #region 鍑虹珯姹囨姤鍗曟樉绀鸿〃浣撴槑缁�
+        [Route("Cj_StationEntrustInBill/DisBillEntryList")]
+        [HttpGet]
+        public object DisBillEntryList(Int64 HProcExchHinteID)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //寰楀埌淇℃伅
+                ds = oCN.RunProcReturn("exec h_p_Sc_ProcExchBilltransRelationQty " + HProcExchHinteID + "", "h_p_Sc_ProcExchBilltransRelationQty");
+                //鍐欏叆淇℃伅
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌鍑虹珯鍗曟槑缁嗕俊鎭紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
                 return objJsonResult;
             }
             catch (Exception e)
@@ -152,7 +282,8 @@
                     return objJsonResult;
                 }
 
-                List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg2); 
+                List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg2);
+                DBUtility.ClsPub.CurUserName = user;
                 long HMainInterID = 0;
                 HMainInterID = list[0].HMainInterID;
                 string eventType = list[0].eventType;
@@ -183,7 +314,7 @@
                 double HMoney = list[0].HMoney;//閲戦
                 string HRemark = list[0].HRemark;//澶囨敞
                 double HTaxRate = list[0].HTaxRate;//绋庣巼
-                long HProcNo = list[0].HProcNo;//娴佹按鍙�
+                string HProcNo = list[0].HProcNo;//娴佹按鍙�
                 string HOrderProcNO = list[0].HOrderProcNO;//璁㈠崟璺熻釜鍙�
                 int HWWWorkOrderInterID = 0;//濮斿宸ュ崟鍙峰瓙鍐呯爜
                 int HWWWorkOrderEntryID = 0;//濮斿宸ュ崟鍙蜂富鍐呭悧
@@ -196,6 +327,7 @@
                 string HBarCode = list[0].HBarCode;//鏉″舰鐮�
                 string HAddr = "";
                 string HBarCodeMaker = "";
+                long HPRDOrgID = list[0].HPRDOrgID;//缁勭粐ID
                 if (HProcExchInterID <= 0)
                 {
                     objJsonResult.code = "0";
@@ -212,7 +344,7 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                if (HProcNo <= 0)
+                if (HProcNo == "")
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -281,7 +413,7 @@
                     ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationInTime,HSourceID" +
                     ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" +
                     ",HSupID,HTaxRate,HQty,HPrice,HMoney,HPieceQty" +
-                    ",HProcNo,HOrderProcNO,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID,HMainInterID" +
+                    ",HProcNo,HOrderProcNO,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID,HMainInterID,HPRDOrgID" +
                     ") " +
                     " values('3792','3792'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillStatus.ToString() + "',getdate(),'" + HMaker + "',getdate()" +
                     ",'" + HYear.ToString() + "','" + HPeriod.ToString() + "','" + HRemark + "','" + HInnerBillNo + "'" +
@@ -289,7 +421,7 @@
                     ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID +
                     "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" +
                     "," + HSupID + "," + HTaxRate + "," + HQty + "," + HPrice + "," + HMoney + "," + HPieceQty +
-                    ",'" + HProcNo + "','" + HOrderProcNO + "'" + ",'" + HWWWorkOrderBillNo + "'" + "," + HWWWorkOrderInterID + "" + "," + HWWWorkOrderEntryID + "," + HMainInterID +
+                    ",'" + HProcNo + "','" + HOrderProcNO + "'" + ",'" + HWWWorkOrderBillNo + "'" + "," + HWWWorkOrderInterID + "" + "," + HWWWorkOrderEntryID + "," + HMainInterID + "," + HPRDOrgID +
                     ") ");
                 }
                 else if ("Modify".Equals(eventType))
@@ -314,6 +446,7 @@
                     ",HTaxRate=" + HTaxRate +
                     ",HMaterID=" + HMaterID +
                     ",HProcID=" + HProcID +
+                    ",HEmpID=" + HEmpID +
                     ",HProcNo=" + HProcNo +
                     ",HOrderProcNO='" + HOrderProcNO + "'" +
                     " where HInterID=" + HInterID);
@@ -372,7 +505,7 @@
                 }
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
+                objJsonResult.Message = "鎿嶄綔鍗曟嵁鎴愬姛锛�";
                 objJsonResult.data = ds.Tables[0];
                 return objJsonResult;
             }

--
Gitblit v1.9.1