From 838ed2eabcac0a0f5daa13bb4f0e46b745edca0a Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期四, 31 八月 2023 10:49:45 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 Model/质检管理/ClsQC_FirstPieceCheckBillMain.cs                  |    2 
 Model/车间管理/ClsQC_TestSampleCheckBillMain.cs                  |   63 ++++
 WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs |  727 ++++++++++++++++++++++++++++++++++++++++++++++++
 Model/Model.csproj                                           |    2 
 Model/车间管理/ClsQC_TestSampleCheckBillSub.cs                   |   56 +++
 5 files changed, 850 insertions(+), 0 deletions(-)

diff --git a/Model/Model.csproj b/Model/Model.csproj
index c4eb85a..b0d1071 100644
--- a/Model/Model.csproj
+++ b/Model/Model.csproj
@@ -721,7 +721,9 @@
     <Compile Include="杞﹂棿绠$悊\ClsSc_StationEntrustOutBillSub_Item.cs" />
     <Compile Include="杞﹂棿绠$悊\ClsSc_StationInBillMain.cs" />
     <Compile Include="杞﹂棿绠$悊\ClsSc_StationInBillSub.cs" />
+    <Compile Include="杞﹂棿绠$悊\ClsQC_TestSampleCheckBillMain.cs" />
     <Compile Include="杞﹂棿绠$悊\ClsSc_StationOutBillMain.cs" />
+    <Compile Include="杞﹂棿绠$悊\ClsQC_TestSampleCheckBillSub.cs" />
     <Compile Include="杞﹂棿绠$悊\ClsSc_StationOutBillSub.cs" />
     <Compile Include="杞﹂棿绠$悊\ClsSc_StationOutBillSub_Emp.cs" />
     <Compile Include="杞﹂棿绠$悊\ClsSc_StationOutBillSub_Item.cs" />
diff --git "a/Model/\350\264\250\346\243\200\347\256\241\347\220\206/ClsQC_FirstPieceCheckBillMain.cs" "b/Model/\350\264\250\346\243\200\347\256\241\347\220\206/ClsQC_FirstPieceCheckBillMain.cs"
index ed85bf3..633a7d6 100644
--- "a/Model/\350\264\250\346\243\200\347\256\241\347\220\206/ClsQC_FirstPieceCheckBillMain.cs"
+++ "b/Model/\350\264\250\346\243\200\347\256\241\347\220\206/ClsQC_FirstPieceCheckBillMain.cs"
@@ -21,6 +21,8 @@
         public Int64 HPrintQty;
         public Int64 HICMOEntryID;
         public Int64 HQCSchemeID;
+        public Int64 HUnitID;
+        public Int64 HProcID;
 
     }
 }
diff --git "a/Model/\350\275\246\351\227\264\347\256\241\347\220\206/ClsQC_TestSampleCheckBillMain.cs" "b/Model/\350\275\246\351\227\264\347\256\241\347\220\206/ClsQC_TestSampleCheckBillMain.cs"
new file mode 100644
index 0000000..5020778
--- /dev/null
+++ "b/Model/\350\275\246\351\227\264\347\256\241\347\220\206/ClsQC_TestSampleCheckBillMain.cs"
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model
+{
+    public class ClsQC_TestSampleCheckBillMain : DBUtility.ClsXt_BaseBillMain
+    {
+        public Int64 HPrintQty;
+        public Int64 HICMOInterID;
+        public Int64 HICMOEntryID;
+        public String HICMOBillNo;
+        public Int64 HProcPlanInterID;
+        public Int64 HProcPlanEntryID;
+        public String HProcPlanBillNo;
+        public Int64 HProcExchInterID;
+        public Int64 HProcExchEntryID;
+        public String HProcExchBillNo;
+        public Int64 HMaterID;
+        public Int64 HUnitID;
+        public Int64 HProcID;
+        public Int64 HPayProcID;
+        public double HICMOQty;
+        public double HPlanQty;
+        public double HDSQty;
+        public DateTime HStationOutTime;
+        public Int64 HSourceID;
+        public Int64 HGroupID;
+        public Int64 HDeptID;
+        public Int64 HEmpID;
+        public String HReportType;
+        public String HBarCode;
+        public String HAddr;
+        public String HBarCodeMaker;
+        public DateTime HBarCodeMakeDate;
+        public Int64 HSupID;
+        public double HQty;
+        public double HPieceQty;
+        public double HPrice;
+        public double HMoney;
+        public double HBadCount;
+        public double HWasterQty;
+        public String HSourceName;
+        public double HPlanPieceQty;
+        public double HBadPNL;
+        public Int64 HCenterID;
+        public int HProcNo;
+        public string HOrderProcNO;
+        public bool HLastSubProc;
+        public double HChongQty;
+        public double HPriceRate;
+        public string HMouldNum;//模穴号
+        public string HBarCode_Cus;//客户条码编码
+        public Single HWorkTimes;//工时
+        public Int64 HQCCheckID;//检验员
+        public string HSourceNameList;//设备清单
+        public Int64 HPersonNums;       //人员数
+        public Int64 HMachineNums;      //机器数
+        public string HEmpNum; //职员代码
+        public string eventType { get; set; }
+        public Int64 HLastResult;//试样结论
+    }
+}
diff --git "a/Model/\350\275\246\351\227\264\347\256\241\347\220\206/ClsQC_TestSampleCheckBillSub.cs" "b/Model/\350\275\246\351\227\264\347\256\241\347\220\206/ClsQC_TestSampleCheckBillSub.cs"
new file mode 100644
index 0000000..a7a8880
--- /dev/null
+++ "b/Model/\350\275\246\351\227\264\347\256\241\347\220\206/ClsQC_TestSampleCheckBillSub.cs"
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model
+{
+    public class ClsQC_TestSampleCheckBillSub : DBUtility.ClsXt_BaseBillSub
+    {
+
+        public string HBillNo_bak;//		varchar(50)	--单据号(备份,以免内码丢失,找不到对应主表)
+
+        public Int64 HProcID;//		int			--工序 
+        public Int64 HMaterID;//		int			--物料 
+        public Int64 HEmpID;//		int			--操作工 
+        public Int64 HSourceID;//	int			--生产资源ID(Gy_Source)
+        public Int64 HSourceID2;//	int			--生产资源ID(Gy_Source)
+        public Int64 HSourceID3;//	int			--生产资源ID(Gy_Source)
+        public Int64 HSourceID4;//	int			--生产资源ID(Gy_Source)
+        public Int64 HSourceID5;//	int			--生产资源ID(Gy_Source)
+        public DateTime HRelBeginDate;//   datetime         	--实际开工日期
+        public DateTime HRelEndDate;//    datetime               	--实际完工日期
+        public double HTimes;//	money		--实作时间
+        public double HQty;//	dec		--实作数量
+        public double HPieceQty;//	dec		--板数
+        public double HCheckQty;	//dec(18,8)	--合格数量
+        public double HBadCount;  //不良品数
+        public double HWasterQty;// 因工报废数量
+        public double HWasterQty2;// 因料报废数量
+
+        public double HWeight;//		dec(18,8)	--重量	
+        public double HPrice;// 		 dec(18,8)	--工序工价
+        public double HMoney;//		 money  	-- 计件金额
+        public double HOtherDeduct;//	money		--其他扣款
+        public double HRelPay;//		money		--实得工资
+        public string HOtherItem1;//	varchar(50)	--其他属性1
+        public string HOtherItem2;//	varchar(50)	--其他属性2
+        public long HCheckEmpID;//	int		--检验员(gy_employee)
+
+        public Int64 HProcPlanInterID;//	int			--工序计划单ID
+        public Int64 HProcPlanEntryID;//	int			--工序计划单子ID
+        public string HProcPlanBillNo;//	varchar(50)		--工序计划单号
+        public Int64 HICMOInterID;//    int         		--任务单ID     
+        public string HICMOBillNo;//        varchar(50)      	--任务单号
+        public Int64 HSeOrderInterID;//    int        		--销售订单主ID
+        public Int64 HSeOrderEntryID;//   int         		--销售子ID
+        public string HSeOrderBillNo;//    varchar(50)         	--销售订单号 
+        public Int64 HWWOrderInterID;//	int			--委外订单内码
+        public Int64 HWWOrderEntryID;//	int			--委外订单子内码
+        public string HWWOrderBillNo;//	varchar(50)		--委外订单号
+        public Int64 HProcExchInterID;//	int			--工序流转卡ID
+        public Int64 HProcExchEntryID;//	int			--工序流转卡子ID
+        public string HProcExchBillNo;//	varchar(50)		--工序流转卡号
+        public Int64 HProcNo;//		int			--工序号 
+        public string HSourceName;// 机台
+    }
+}
diff --git a/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
index 2940b96..7d625ff 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
@@ -316,6 +316,733 @@
         }
         #endregion
 
+        #region 鎸囧紩鍗℃壂鐮佽幏鍙栦俊鎭�
+        [Route("MES_SampleRecordBill_PDA/SampleRecordBillHBarCode_KeyDown")]
+        [HttpGet]
+        public object SampleRecordBillHBarCode_KeyDown(string HBarCode, string HInterID, string UserID, string HBillType)
+        {
+            try
+            {
+                if (HBarCode == null || HBarCode.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绌虹櫧鐮�,鏉″舰鐮佷笉鑳戒负绌猴紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鎷嗗垎鏉″舰鐮�
+                string sBillBarCode = HBarCode.Trim();
+                string[] NewBarCode;
+                if (sBillBarCode.CompareTo("#") > 0)
+                {
+                    NewBarCode = sBillBarCode.Split(Convert.ToChar("#"));
+                    sBillBarCode = NewBarCode[0];
+                }
+                string sBillNo = sBillBarCode; //鏉″舰鐮�
+
+                string[] arr = sBillNo.Split('&'); //浠ョ鍙封��&鈥欏垎鍓叉潯褰㈢爜
+                string BillNo_PGD = arr[0]; //鍗曟嵁鍙�
+                string entryid_PGD = "";//瀛恑d
+                if (arr.Length > 1)
+                {
+                    entryid_PGD = arr[1];
+                }
+
+            
+                //鎴彇鏉$爜绫诲瀷2 鍓嶅洓浣�
+                string BillNoType2 = BillNo_PGD.Substring(0, Math.Min(4, BillNo_PGD.Length));
+              
+                switch (BillNoType2)
+                {
+                    case "GXLX"://娴佽浆鍗�
+                        string sErr = "";
+                        if (oSystemParameter.ShowBill(ref sErr))
+                        {
+                            if (oSystemParameter.omodel.WMS_CampanyName == "涔斾竴")
+                            { //绯荤粺鍙傛暟鏄惁涓哄彧鏄剧ず褰撳墠鐧诲綍鐢ㄦ埛鍏宠仈鐨勫伐搴忎俊鎭�,N涓哄惁锛孻涓烘槸
+                                ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList  where 鍗曟嵁鍙�= '" + BillNo_PGD + "'", "h_v_Sc_ProcessExchangeBillList");
+                            }
+                            else
+                            {
+                                ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList  where 鍗曟嵁鍙�= '" + BillNo_PGD + "'", "h_v_Sc_ProcessExchangeBillList");
+                            }
+                        }
+                        break;
+                    default:
+                        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;
+            }
+        }
+        #endregion
+
+        #region  璇曟牱璁板綍 鏌ヨ鍒楄〃
+        [Route("MES_SampleRecordBill_PDA/SampleRecordList")]
+        [HttpGet]
+        public object SampleRecordList(string sWhere,string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("QC_TestSampleCheckBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "select * from  h_v_QC_TestSampleCheckBillList where 1=1  " + sWhere + " order by 鏃ユ湡 ";
+
+                ds = oCN.RunProcReturn(sql, "h_v_QC_TestSampleCheckBillList");
+
+                DataTable dt = ds.Tables[0];
+
+                //鑾峰彇鍒楀悕
+                List<object> columnNameList = new List<object>();
+                //娣诲姞鍒楀悕
+                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 = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = dt;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 璇曟牱璁板綍鏂板淇濆瓨
+        [Route("MES_SampleRecordBill_PDA/SampleRecordAddBill")]
+        [HttpPost]
+        public object SampleRecordAddBill([FromBody] JObject oMain)
+        {
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            try
+            {
+                //鍙嶅簭鍒楀寲
+                string msg2 = "[" + sArray[0].ToString() + "]";
+                string user = sArray[1].ToString();//鐢ㄦ埛鍚�
+                string OperationType = sArray[2].ToString();//绫诲瀷
+
+                //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("QC_TestSampleCheckBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犵紪杈戞潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<Model.ClsQC_TestSampleCheckBillMain> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsQC_TestSampleCheckBillMain>>(msg2);
+                string BillType = "7510";
+                string HBillSubType = "7510";
+                string eventType = list[0].eventType;
+                long HInterID = list[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = list[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                int HBillStatus = 1;
+                string HMaker = user;//鍒跺崟浜�
+                int HYear = DateTime.Now.Year;
+                double HPeriod = DateTime.Now.Month;
+                long HSourceID = list[0].HSourceID;//鐢熶骇璧勬簮
+                long HICMOInterID = list[0].HICMOInterID;//浠诲姟鍗旾D
+                string HICMOBillNo = list[0].HICMOBillNo;//浠诲姟鍗�
+                string HProcExchBillNo = list[0].HProcExchBillNo;//鎸囧紩鍗�
+                long HMaterID = list[0].HMaterID;//浜у搧ID
+                long HUnitID = list[0].HUnitID;//璁¢噺鍗曚綅
+                long HProcID = list[0].HProcID;//宸ュ簭ID
+                long HPRDORGID = list[0].HPRDORGID;//缁勭粐ID
+                long HLastResult = list[0].HLastResult;//璇曟牱缁撹
+
+                //鍗曟嵁瀹屾暣鎬у垽鏂�
+                if (HProcExchBillNo =="")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娴佽浆鍗℃病鏈夐�夋嫨锛佽鎵弿鏉″舰鐮佹垨杈撳叆鏉″舰鐮佸悗鍥炶溅";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var num = 0;
+
+                oCN.BeginTran();
+                if ("Add".Equals(eventType))
+                {
+                    num = 1;
+
+                    ds = oCN.RunProcReturn("select * from QC_TestSampleCheckBillMain where HBillNo='" + HBillNo + "'", "QC_TestSampleCheckBillMain");
+                    if (ds.Tables[0].Rows.Count == 1)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    oCN.RunProc("Insert Into QC_TestSampleCheckBillMain " +
+                    "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
+                    ",HYear,HPeriod,HMaterID,HSourceID,HICMOInterID,HICMOBillNo,HProcExchBillNo,HUnitID" +
+                    ",HPRDORGID,HLastResult)" +
+                    " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate()" +
+                    "," + HYear + "," + HPeriod + ",'" + HMaterID + "','" + HSourceID + "'," + HICMOInterID + ",'" + HICMOBillNo + "','" + HProcExchBillNo + "'," + HUnitID +
+                    "," + HPRDORGID + ",'" + HLastResult + "') ");
+                }
+                else
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎿嶄綔绫诲瀷鏃犳晥锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 璇曟牱璁板綍 瀹℃牳/鍙嶅鏍稿姛鑳�
+        [Route("MES_SampleRecordBill_PDA/CheckSampleRecordBill")]
+        [HttpGet]
+        public object CheckSampleRecordBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("QC_TestSampleCheckBill_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                BillOld.MvarItemKey = "QC_TestSampleCheckBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶉渶瑕佸啀瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    //瀹℃牳鍗曟嵁
+                    oCN.RunProc(" Update " + BillOld.MvarItemKey + " set HChecker='" + user + "',HCheckDate=getdate(),HBillStatus=2 Where HInterID=" + HInterID.ToString());
+
+                }
+                else
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插弽瀹℃牳!涓嶉渶瑕佸啀鍙嶅鏍�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    //鍙嶅鏍稿崟鎹�
+                    oCN.RunProc(" Update " + BillOld.MvarItemKey + " set HChecker='',HCheckDate=null,HBillStatus=1 Where HInterID=" + HInterID.ToString());
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 璇曟牱璁板綍 鍒犻櫎鍔熻兘
+        [Route("MES_SampleRecordBill_PDA/DelSampleRecordBill")]
+        [HttpGet]
+        public object DelSampleRecordBill(Int64 lngBillKey, string user)
+        {
+            DataSet ds;
+            string ModRightNameCheck = "QC_TestSampleCheckBill_Detete";
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (lngBillKey == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁id涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+                ds = oCN.RunProcReturn("select * from QC_TestSampleCheckBillMain where HInterID=" + lngBillKey, "QC_TestSampleCheckBillMain");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                string HChecker = Convert.ToString(ds.Tables[0].Rows[0]["HChecker"]);
+                if (HChecker != "")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+               
+                oCN.RunProc("delete from QC_TestSampleCheckBillMain where HInterID=" + lngBillKey);
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "* 鏁版嵁鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  瀵硅壊璁板綍 鏌ヨ鍒楄〃
+        [Route("ColorRecord/ColorRecordList")]
+        [HttpGet]
+        public object ColorRecordList(string sWhere,string user)
+        {
+            try
+            {
+                
+                //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("QC_FirstPieceCheckBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "select * from  h_v_QC_FirstPieceCheckBillMainList where 1=1  " + sWhere + " order by 鏃ユ湡 ";
+
+                ds = oCN.RunProcReturn(sql, "h_v_QC_FirstPieceCheckBillMainList");
+
+                DataTable dt = ds.Tables[0];
+
+                //鑾峰彇鍒楀悕
+                List<object> columnNameList = new List<object>();
+                //娣诲姞鍒楀悕
+                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 = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = dt;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀵硅壊璁板綍鏂板淇濆瓨
+        [Route("ColorRecord/ColorRecordAddBill")]
+        [HttpPost]
+        public object ColorRecordAddBill([FromBody] JObject oMain)
+        {
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            try
+            {
+                //鍙嶅簭鍒楀寲
+                string msg2 = "[" + sArray[0].ToString() + "]";
+                string user = sArray[1].ToString();//鐢ㄦ埛鍚�
+                string OperationType = sArray[2].ToString();//绫诲瀷
+
+                //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("QC_FirstPieceCheckBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犵紪杈戞潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<Model.ClsQC_FirstPieceCheckBillMain> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsQC_FirstPieceCheckBillMain>>(msg2);
+                string BillType = "7505";
+                string HBillSubType = "7505";
+                long HInterID = list[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = list[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                int HBillStatus = 1;
+                string HMaker = user;//鍒跺崟浜�
+                int HYear = DateTime.Now.Year;
+                double HPeriod = DateTime.Now.Month;
+                long HSourceID = list[0].HSourceID;//鐢熶骇璧勬簮
+                long HICMOInterID = list[0].HICMOInterID;//浠诲姟鍗旾D
+                string HICMOBillNo = list[0].HICMOBillNo;//浠诲姟鍗�
+                string HProcExchBillNo = list[0].HProcExchBillNo;//鎸囧紩鍗�
+                long HMaterID = list[0].HMaterID;//浜у搧ID
+                //long HUnitID = list[0].HUnitID;//璁¢噺鍗曚綅
+                long HProcID = list[0].HProcID;//宸ュ簭ID
+                long HPRDORGID = list[0].HPRDORGID;//缁勭粐ID
+                bool HLastResult = list[0].HLastResult;//璇曟牱缁撹
+
+                //鍗曟嵁瀹屾暣鎬у垽鏂�
+                if (HProcExchBillNo == "")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娴佽浆鍗℃病鏈夐�夋嫨锛佽鎵弿鏉″舰鐮佹垨杈撳叆鏉″舰鐮佸悗鍥炶溅";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var num = 0;
+
+                oCN.BeginTran();
+                if (OperationType=="1")
+                {
+                    num = 1;
+
+                    ds = oCN.RunProcReturn("select * from QC_FirstPieceCheckBillMain where HBillNo='" + HBillNo + "'", "QC_FirstPieceCheckBillMain");
+                    if (ds.Tables[0].Rows.Count == 1)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    oCN.RunProc("Insert Into QC_FirstPieceCheckBillMain " +
+                    "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
+                    ",HYear,HPeriod,HMaterID,HSourceID,HICMOInterID,HICMOBillNo,HProcExchBillNo" +
+                    ",HPRDORGID,HLastResult)" +
+                    " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate()" +
+                    "," + HYear + "," + HPeriod + ",'" + HMaterID + "','" + HSourceID + "'," + HICMOInterID + ",'" + HICMOBillNo + "','" + HProcExchBillNo + "'" +  
+                    "," + HPRDORGID + ",'" + HLastResult + "') ");
+                }
+                else
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎿嶄綔绫诲瀷鏃犳晥锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀵硅壊璁板綍 瀹℃牳/鍙嶅鏍稿姛鑳�
+        [Route("ColorRecord/CheckColorRecordBill")]
+        [HttpGet]
+        public object CheckColorRecordBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("QC_FirstPieceCheckBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                BillOld.MvarItemKey = "QC_FirstPieceCheckBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶉渶瑕佸啀瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    //瀹℃牳鍗曟嵁
+                    oCN.RunProc(" Update " + BillOld.MvarItemKey + " set HChecker='" + user + "',HCheckDate=getdate(),HBillStatus=2 Where HInterID=" + HInterID.ToString());
+
+                }
+                else
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插弽瀹℃牳!涓嶉渶瑕佸啀鍙嶅鏍�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    //鍙嶅鏍稿崟鎹�
+                    oCN.RunProc(" Update " + BillOld.MvarItemKey + " set HChecker='',HCheckDate=null,HBillStatus=1 Where HInterID=" + HInterID.ToString());
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀵硅壊璁板綍 鍒犻櫎鍔熻兘
+        [Route("ColorRecord/DelColorRecordBill")]
+        [HttpGet]
+        public object DelColorRecordBill(Int64 lngBillKey, string user)
+        {
+            DataSet ds;
+            string ModRightNameCheck = "QC_FirstPieceCheckBill_Delete";
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (lngBillKey == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁id涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+                ds = oCN.RunProcReturn("select * from QC_FirstPieceCheckBillMain where HInterID=" + lngBillKey, "QC_FirstPieceCheckBillMain");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                string HChecker = Convert.ToString(ds.Tables[0].Rows[0]["HChecker"]);
+                if (HChecker != "")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.RunProc("delete from QC_FirstPieceCheckBillMain where HInterID=" + lngBillKey);
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "* 鏁版嵁鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 鏍规嵁鐧诲綍鐢ㄦ埛鑾峰彇宸ュ簭
         [Route("Sc_StationInBill/autoGetProcNo")]
         [HttpGet]

--
Gitblit v1.9.1