From 9b2ce9295586ba04d99f8ae49ce1748e287fa286 Mon Sep 17 00:00:00 2001
From: zzr99 <1940172413@qq.com>
Date: 星期二, 14 十二月 2021 17:45:26 +0800
Subject: [PATCH] 新增盘点方案

---
 /dev/null                                           |    0 
 LMES/bin/x86/Debug.rar                              |    0 
 LMES/ClsShowMod.cs                                  |   64 +++--
 WebAPI/DLL/ClsSc_PackUnionBill.cs                   |  383 ++++++++++++++++++++++++++++++++++
 WebAPI/Models/ClsSc_PackUnionBillSub.cs             |   23 ++
 WebAPI/Controllers/博日自动扫码线/ScanlineAPIController.cs |  166 ++++++++++++++
 DBUtility/业务单据/ClsXt_BaseBillMain.cs                |    2 
 WebAPI/Models/ClsSc_PackUnionBillMain.cs            |   15 +
 WebAPI/WebAPI.csproj                                |    5 
 9 files changed, 618 insertions(+), 40 deletions(-)

diff --git "a/DBUtility/\344\270\232\345\212\241\345\215\225\346\215\256/ClsXt_BaseBillMain.cs" "b/DBUtility/\344\270\232\345\212\241\345\215\225\346\215\256/ClsXt_BaseBillMain.cs"
index fa6bb96..6ad2004 100644
--- "a/DBUtility/\344\270\232\345\212\241\345\215\225\346\215\256/ClsXt_BaseBillMain.cs"
+++ "b/DBUtility/\344\270\232\345\212\241\345\215\225\346\215\256/ClsXt_BaseBillMain.cs"
@@ -43,5 +43,7 @@
         public Int64 HItemMainID;
         //组织
         public Int64 HPRDORGID;
+        //有效状态 
+        public bool HUseFlag;
     }
 }
diff --git a/LMES/ClsShowMod.cs b/LMES/ClsShowMod.cs
index e4adb40..2c8a23c 100644
--- a/LMES/ClsShowMod.cs
+++ b/LMES/ClsShowMod.cs
@@ -3934,6 +3934,12 @@
                         oPt_RadiumCarvingCodeBillList.Show();
                         oMainForm.AddTabPage(oPt_RadiumCarvingCodeBillList);
                         break;
+                    case "sc_packunionbill":
+                        Sc_PackUnionBill oSc_PackUnionBill = new Sc_PackUnionBill();
+                        oSc_PackUnionBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+                        oSc_PackUnionBill.ModCaption = gnmc;
+                        oSc_PackUnionBill.ShowDialog();
+                        break;
                     default:
                         break;
                 }
@@ -5728,23 +5734,23 @@
                     //    oSc_PackSplitBillList.Show();
                     //    oMainForm.AddTabPage(oSc_PackSplitBillList);
                     //    break;
-                    //case "sc_packunionbill":
-                    //    Sc_PackUnionBill oSc_PackUnionBill = new Sc_PackUnionBill();
-                    //    oSc_PackUnionBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
-                    //    oSc_PackUnionBill.ModCaption = gnmc;
-                    //    oSc_PackUnionBill.ShowDialog();
-                    //    break;
-                    //case "sc_packunionbilllist":
-                    //    Sc_PackUnionBillList oSc_PackUnionBillList = new Sc_PackUnionBillList();
-                    //    oSc_PackUnionBillList.MdiParent = oMain;
-                    //    oSc_PackUnionBillList.ModCaption = gnmc;
-                    //    oSc_PackUnionBillList.Show();
-                    //    oMainForm.AddTabPage(oSc_PackUnionBillList);
-                    //    break;
+                    case "sc_packunionbill":
+                        Sc_PackUnionBill oSc_PackUnionBill = new Sc_PackUnionBill();
+                        oSc_PackUnionBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+                        oSc_PackUnionBill.ModCaption = gnmc;
+                        oSc_PackUnionBill.ShowDialog();
+                        break;
+                    case "sc_packunionbilllist":
+                        Sc_PackUnionBillList oSc_PackUnionBillList = new Sc_PackUnionBillList();
+                        oSc_PackUnionBillList.MdiParent = oMain;
+                        oSc_PackUnionBillList.ModCaption = gnmc;
+                        oSc_PackUnionBillList.Show();
+                        oMainForm.AddTabPage(oSc_PackUnionBillList);
+                        break;
 
 
-                    
-     
+
+
 
                     //===========================MES平板系统单据
 
@@ -5806,20 +5812,20 @@
                         oMES_StationOutBillList.Show();
                         oMainForm.AddTabPage(oMES_StationOutBillList);
                         break;
-                    case "sc_packunionbill":
-                        Sc_PackUnionBill oSc_PackUnionBill = new Sc_PackUnionBill();
-                        oSc_PackUnionBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
-                        oSc_PackUnionBill.ModCaption = gnmc;
-                        oSc_PackUnionBill.ShowDialog();
-                        break;
-                    case "sc_packunionbilllist":
-                        //权限
-                        Sc_PackUnionBillList oSc_PackUnionBillList = new Sc_PackUnionBillList();
-                        oSc_PackUnionBillList.MdiParent = oMain;
-                        oSc_PackUnionBillList.ModCaption = gnmc;
-                        oSc_PackUnionBillList.Show();
-                        oMainForm.AddTabPage(oSc_PackUnionBillList);
-                        break;
+                    //case "sc_packunionbill":
+                    //    Sc_PackUnionBill oSc_PackUnionBill = new Sc_PackUnionBill();
+                    //    oSc_PackUnionBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+                    //    oSc_PackUnionBill.ModCaption = gnmc;
+                    //    oSc_PackUnionBill.ShowDialog();
+                    //    break;
+                    //case "sc_packunionbilllist":
+                    //    //权限
+                    //    Sc_PackUnionBillList oSc_PackUnionBillList = new Sc_PackUnionBillList();
+                    //    oSc_PackUnionBillList.MdiParent = oMain;
+                    //    oSc_PackUnionBillList.ModCaption = gnmc;
+                    //    oSc_PackUnionBillList.Show();
+                    //    oMainForm.AddTabPage(oSc_PackUnionBillList);
+                    //    break;
                     //case "mes_mesbeginworkbill":
                     //    MES_MESBeginWorkBill oMES_MESBeginWorkBill = new MES_MESBeginWorkBill();
                     //    oMES_MESBeginWorkBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
diff --git a/LMES/bin/x86/Debug.rar b/LMES/bin/x86/Debug.rar
new file mode 100644
index 0000000..de17e07
--- /dev/null
+++ b/LMES/bin/x86/Debug.rar
Binary files differ
diff --git "a/LMES/bin/x86/\345\245\245\351\202\246Debug.rar" "b/LMES/bin/x86/\345\245\245\351\202\246Debug.rar"
deleted file mode 100644
index 432b354..0000000
--- "a/LMES/bin/x86/\345\245\245\351\202\246Debug.rar"
+++ /dev/null
Binary files differ
diff --git "a/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs" "b/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
index 9a93a8d..1b23643 100644
--- "a/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
+++ "b/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
@@ -17,6 +17,7 @@
     {
         private jsonScanline objJsonResult = new jsonScanline();
         public DataSet ds = new DataSet();
+        public DataSet ds0 = new DataSet();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
 
         #region 鐢熸垚绠辩爜鎺ュ彛
@@ -66,13 +67,7 @@
         }
         #endregion
 
-
-        #region 鎶ュ伐骞冲彴寮�宸ュ崟淇濆瓨/缂栬緫
-        /// <summary>
-        /// 寮�宸ュ崟
-        /// </summary>
-        /// <param name="msg"></param>
-        /// <returns></returns>
+        #region 绠辨潯鐮佺粦瀹氬叧绯绘彁浜ゆ帴鍙�
         [Route("packagebarcode/pack")]
         [HttpPost]
         public object pack([FromBody] JObject msg)
@@ -81,6 +76,159 @@
             {
                 JavaScriptSerializer js = new JavaScriptSerializer();   //瀹炰緥鍖栦竴涓兘澶熷簭鍒楀寲鏁版嵁鐨勭被
                 ScanLineCode list = js.Deserialize<ScanLineCode>(msg.ToString());    //灏唈son鏁版嵁杞寲涓哄璞$被鍨嬪苟璧嬪�肩粰list
+                if (list.billno != "" && list.billno != null)  //浠诲姟鍗曞彿锛岄潪蹇呴』锛岄潪绌哄垯鏍¢獙barcodes閲宐arcode鏄惁鐢辨浠诲姟鍗曞埗浣滅敓鎴愮殑
+                {
+                    ds = oCN.RunProcReturn("Select HBarCode barcode from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim()+"'  Order by HItemID ", "Gy_BarCodeBill");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.status = -1;
+                        objJsonResult.msg = "褰撳墠璁㈠崟鏃犵粦瀹氭潯鐮�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    List<string> NameList = (from r in ds.Tables[0].AsEnumerable() select r.Field<string>("barcode")).ToList();
+                    List<string> NameList1= list.barcodes.Select(t => t.barcode).ToList();
+                    var strList = NameList1.Except(NameList).ToList();  //鍒ゆ柇鎻愪氦鏁版嵁涓潯鐮佹槸鍚﹀瓨鍦ㄤ簬璁㈠崟涓�
+                    if (strList.Count > 0) 
+                    {
+                        string Str=String.Join(",", strList.ToArray());
+                        objJsonResult.status = -1;
+                        objJsonResult.msg = "鏉$爜:"+ Str.ToString()+" 涓嶅寘鍚湪璁㈠崟:"+list.billno+"涓�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }                
+                }
+                DLL.ClsSc_PackUnionBill oBill = new DLL.ClsSc_PackUnionBill();
+                //鍒ゆ柇绠辩爜鏄惁瀛樺湪
+                bool IsBarCodePack = oBill.IsBarCodePack(list.packagebarcode);
+                if (IsBarCodePack == false) 
+                {
+                    objJsonResult.status = -1;
+                    objJsonResult.msg = "绠辩爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                Models.ClsSc_PackUnionBillMain oItem = new ClsSc_PackUnionBillMain();
+                oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+                oItem.HBillType = "3783";
+                oItem.HBillSubType = "3783";
+                oItem.HDate= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
+                oItem.HBillNo = DBUtility.ClsPub.CreateBillCode(oItem.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                oItem.HBillStatus = 1;
+                oItem.HCheckItemNowID = 0;
+                oItem.HCheckItemNextID = 0;
+                oItem.HCheckFlowID = 0;
+                oItem.HRemark = "鑷姩鍖呰绾跨敓杈扮鏉$爜";
+                oItem.HBacker = "";
+                oItem.HBackDate = "";
+                oItem.HMaker = "";
+                oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                oItem.HChecker = "";
+                oItem.HCheckDate = "";
+                oItem.HUpDater = "";
+                oItem.HUpDateDate = "";
+                oItem.HCloseMan = "";
+                oItem.HCloseDate = "";
+                oItem.HCloseType = false;
+                oItem.HDeleteMan = "";
+                oItem.HDeleteDate = "";
+                oItem.HICMOInterID = 0;
+                oItem.HICMOBillNo = "";
+                oItem.HBarCode_Pack= list.packagebarcode;
+                oItem.HMaterID = 0;
+                oItem.HUnitID = 0;
+                oItem.HUseFlag =false;   //鏈夋晥鐘舵��
+                oBill.omodel = oItem;
+                for (int i = 0; i < list.barcodes.Count; i++)
+                {
+                    //鍒ゆ柇鏉$爜鏄惁瀛樺湪
+                    bool IsBarCode = oBill.IsBarCodePack(list.barcodes[i].barcode);
+                    if (IsBarCodePack == false)
+                    {
+                        objJsonResult.status = -1;
+                        objJsonResult.msg = "鏉$爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    Models.ClsSc_PackUnionBillSub oItemSub = new ClsSc_PackUnionBillSub();
+                    ds0 = oCN.RunProcReturn("Select HBarCode,HMaterID,HUnitID,HQty,HSourceID,HGroupID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim() + "' and HBarCode='" + list.barcodes[i].barcode + "'  Order by HItemID ", "Gy_BarCodeBill");
+                    oItemSub.HEntryID = i+1;
+                    oItemSub.HMaterID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HMaterID"].ToString());
+                    oItemSub.HUnitID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HUnitID"].ToString());
+                    oItemSub.HQty = DBUtility.ClsPub.isDoule(ds0.Tables[0].Rows[0]["HQty"].ToString());
+                    oItemSub.HSourceID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceID"].ToString());
+                    oItemSub.HEquipID = 0;
+                    oItemSub.HGroupID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HGroupID"].ToString());
+                    oItemSub.HWorkerID = 0; 
+                    oItemSub.HBarCode = list.barcodes[i].barcode;
+                    oItemSub.HBarCode_Pack = list.packagebarcode;
+                    oItemSub.HCloseMan = "";
+                    oItemSub.HCloseType = false;
+                    oItemSub.HRemark = "";
+                    oItemSub.HSourceInterID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceInterID"].ToString());
+                    oItemSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceEntryID"].ToString());
+                    oItemSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds0.Tables[0].Rows[0]["HSourceBillNo"].ToString());
+                    oItemSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds0.Tables[0].Rows[0]["HSourceBillType"].ToString());
+                    oItemSub.HRelationQty = 0;
+                    oItemSub.HRelationMoney = 0;
+                    oBill.DetailColl.Add(oItemSub);
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.status = 0;
+                    objJsonResult.msg = "success";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.status = -1;
+                    objJsonResult.msg = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.status =-1;
+                objJsonResult.msg = e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 绠辨潯鐮佸彇娑堢粦瀹氬叧绯�
+        [Route("packagebarcode/cancel")]
+        [HttpPost]
+        public object cancel(string packagebarcode)
+        {
+            try
+            {
+                //
+                oCN.BeginTran();
+                //鍒犻櫎瀛愯〃
+                oCN.RunProc("Delete From Sc_PackUnionBillSub  where HBarCode_Pack=" + packagebarcode.ToString());
+                //鍒犻櫎涓昏〃
+                oCN.RunProc("Delete From Sc_PackUnionBillMain  where HBarCode_Pack=" + packagebarcode.ToString());
+                //鍒犻櫎鏉$爜妗f琛�
+                oCN.RunProc("Delete From Gy_BarCodeBill  where HBarCode=" + packagebarcode.ToString());
+
+                oCN.Commit();
 
                 objJsonResult.status = 0;
                 objJsonResult.msg = "success";
@@ -89,8 +237,8 @@
             }
             catch (Exception e)
             {
-                objJsonResult.status =-1;
-                objJsonResult.msg = "success";
+                objJsonResult.status = -1;
+                objJsonResult.msg = e.Message;
                 objJsonResult.data = null;
                 return objJsonResult;
             }
diff --git a/WebAPI/DLL/ClsSc_PackUnionBill.cs b/WebAPI/DLL/ClsSc_PackUnionBill.cs
new file mode 100644
index 0000000..e9b08f8
--- /dev/null
+++ b/WebAPI/DLL/ClsSc_PackUnionBill.cs
@@ -0,0 +1,383 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using System.Data;
+
+namespace WebAPI.DLL
+{
+    public class ClsSc_PackUnionBill : DBUtility.ClsXt_BaseBill
+    {
+        public Models.ClsSc_PackUnionBillMain omodel = new Models.ClsSc_PackUnionBillMain();
+        public List<Models.ClsSc_PackUnionBillSub> DetailColl = new List<Models.ClsSc_PackUnionBillSub>();
+
+        public ClsSc_PackUnionBill()
+        {
+            base.MvarItemKeySub = "Sc_PackUnionBillSub";
+            base.MvarItemKeySub2 = "";
+            base.MvarItemKeySub3 = "";
+            base.MvarItemKeySub4 = "";
+            base.MvarItemKey = "Sc_PackUnionBillMain";
+            base.MvarReportTitle = "鐢熶骇鍖呰鍗�";
+            base.BillType = "3783";
+        }
+
+        #region 鍥哄畾浠g爜
+
+        ~ClsSc_PackUnionBill()
+        {
+            DetailColl = null;
+        }
+
+        #endregion   鑷畾涔夋柟娉�
+        //淇敼鍗曟嵁
+        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //
+                oCn.BeginTran();
+                //鏇存柊涓昏〃
+                oCn.RunProc("UpDate Sc_PackUnionBillMain set  " +
+                " HBillNo='" + omodel.HBillNo + "'" +
+                ",HDate='" + omodel.HDate + "'" +
+                ",HICMOInterID=" + omodel.HICMOInterID + "" +
+                ",HICMOBillNo='" + omodel.HICMOBillNo + "'" +
+                ",HBarCode_Pack='" + omodel.HBarCode_Pack + "'" +
+                ",HMaterID=" + omodel.HMaterID + "" +
+                ",HUnitID=" + omodel.HUnitID + "" +
+                ",HRemark='" + omodel.HRemark + "'" +
+                ",HUpdater='" + DBUtility.ClsPub.CurUserName + "'" +
+                ",HUpdateDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" +
+                " where HInterID=" + lngBillKey.ToString());
+                //鍒犻櫎鍏宠仈
+                //DeleteRelation(ref sReturn, lngBillKey);
+                ////鍒犻櫎瀛愯〃
+                DeleteBillSub(lngBillKey);
+                ////鎻掑叆瀛愯〃
+                omodel.HInterID = lngBillKey;
+                foreach (Models.ClsSc_PackUnionBillSub oSub in DetailColl)
+                {
+                    oCn.RunProc("Insert into Sc_PackUnionBillSub " +
+                      " (HInterID,HEntryID,HMaterID,HUnitID,HQty,HSourceID" +
+                      ",HEquipID,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_Pack" +
+                      ",HCloseMan,HCloseType,HRemark" +
+                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)" +
+                      " values("
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() + "," + oSub.HSourceID.ToString() + "" +
+                      "," + oSub.HEquipID.ToString() + "," + oSub.HGroupID.ToString() + "," + oSub.HWorkerID.ToString() + ",'" + oSub.HScanDate.ToShortDateString() + "','" + oSub.HBarCode + "','" + oSub.HBarCode_Pack + "'" +
+                      ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                      ") ");
+                }
+                sReturn = "淇敼鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+        //鏂板鍗曟嵁
+        public override bool AddBill(ref string sReturn)
+        {
+            try
+            {
+                //寰楀埌mainid
+                omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                oCn.BeginTran();
+                //涓昏〃
+                oCn.RunProc("Insert Into Sc_PackUnionBillMain   " +
+                "(HYear,HPeriod,HBillType,HInterID" +
+                ",HDate,HBillNo,HBillStatus,HRemark,HICMOInterID" +
+                ",HICMOBillNo,HBarCode_Pack,HMaterID,HUnitID" +
+                ",HMaker,HMakeDate" +
+                ") " +
+                " values(" + omodel.HYear + "," + omodel.HPeriod + ",'" + this.BillType + "'," + omodel.HInterID + "" +
+                ",'" + omodel.HDate + "','" + omodel.HBillNo.ToString() + "'," + omodel.HBillStatus + ",'" + omodel.HRemark + "'," + omodel.HICMOInterID + "" +
+                ",'" + omodel.HICMOBillNo.ToString() + "','" + omodel.HBarCode_Pack.ToString() + "'," + omodel.HMaterID + "," + omodel.HUnitID + "" +
+                ",'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.GetServerDate(-1) + "'" +
+                ") ");
+                ////鎻掑叆瀛愯〃
+                string HSourceInterID = "0";
+                string HSourceEntryID = "0";
+                string HSourceBillNo = "0";
+                string HSourceBillType = "0";
+                string HMaterID = "0";
+                string HUnitID = "0";
+                double HQty = 0;
+                
+                foreach (Models.ClsSc_PackUnionBillSub oSub in DetailColl)
+                {
+                    HSourceInterID = oSub.HSourceInterID.ToString();
+                    HSourceEntryID = oSub.HSourceEntryID.ToString();
+                    HSourceBillNo = oSub.HSourceBillNo.ToString();
+                    HSourceBillType = oSub.HSourceBillType.ToString();
+                    HMaterID = oSub.HMaterID.ToString();
+                    HUnitID = oSub.HUnitID.ToString();
+                    oCn.RunProc("Insert into Sc_PackUnionBillSub " +
+                      " (HInterID,HEntryID,HMaterID,HUnitID,HQty,HSourceID" +
+                      ",HEquipID,HGroupID,HWorkerID,HBarCode,HBarCode_Pack" +
+                      ",HCloseMan,HCloseType,HRemark" +
+                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)" +
+                      " values("
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() + "," + oSub.HSourceID.ToString() + "" +
+                      "," + oSub.HEquipID.ToString() + "," + oSub.HGroupID.ToString() + "," + oSub.HWorkerID.ToString() + ",'" + oSub.HBarCode + "','" + oSub.HBarCode_Pack + "'" +
+                      ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                      ") ");
+                    HQty += oSub.HQty;
+                }
+                //绠辩爜鎻掑叆鏉$爜妗f琛�
+                oCn.RunProc("insert into Gy_BarCodeBill(HInterID,HEntryID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HMakeDate " +
+                             ",HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HUseFlag, HStopflag, HSupID, HGroupID, HPrintQty)" +
+                             "values('" + HSourceInterID + "', 1, '" + omodel.HBarCode_Pack + "', '绠卞彿鏉$爜', '" + HMaterID + "', '" + HUnitID + "','" + HQty + "', '', getdate()" +
+                             ", '" + HSourceInterID + "', '" + HSourceEntryID + "', '" + HSourceBillNo + "', '" + HSourceBillType + "', 1, 0, 0, 0, 0)");
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+        //鏄剧ず鍗曟嵁
+        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //鏌ヨ涓昏〃
+                DataSet Ds;
+                Ds = oCn.RunProcReturn("Select * from Sc_PackUnionBillMain Where HInterID=" + lngBillKey.ToString(), "Sc_PackUnionBillMain");
+                if (Ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "鍗曟嵁鏈壘鍒帮紒";
+                    return false;
+                }
+                //璧嬪��
+                omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
+                omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
+                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
+                omodel.HDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["HDate"]);
+                omodel.HBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]);
+                omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
+                //
+                omodel.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]);
+                omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HICMOBillNo"]);
+                omodel.HBarCode_Pack = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCode_Pack"]);
+                omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
+                omodel.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]);
+                //
+                omodel.HBacker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBacker"]);
+                omodel.HBackDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBackDate"]);
+                omodel.HChecker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HChecker"]);
+                omodel.HCheckDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCheckDate"]);
+                omodel.HMaker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaker"]);
+                omodel.HMakeDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMakeDate"]);
+                omodel.HUpDateDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUpDateDate"]);
+                omodel.HUpDater = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUpDater"]);
+                omodel.HCloseDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCloseDate"]);
+                omodel.HCloseMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCloseMan"]);
+                omodel.HDeleteDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeleteDate"]);
+                omodel.HDeleteMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeleteMan"]);
+                //寰幆
+                DataSet DsSub;
+                DsSub = oCn.RunProcReturn("Select * from Sc_PackUnionBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Sc_PackUnionBillSub");
+                DetailColl.Clear();//娓呯┖
+                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
+                {
+                    Models.ClsSc_PackUnionBillSub oSub = new Models.ClsSc_PackUnionBillSub();
+                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
+                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
+                    oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
+                    oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"]);
+                    oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]);
+                    oSub.HSourceID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceID"]);
+                    oSub.HEquipID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEquipID"]);
+                    oSub.HGroupID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HGroupID"]);
+                    oSub.HWorkerID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HWorkerID"]);
+                    oSub.HScanDate = Convert.ToDateTime(DsSub.Tables[0].Rows[i]["HScanDate"]);
+                    oSub.HBarCode = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HBarCode"]);
+                    oSub.HBarCode_Pack =DBUtility.ClsPub.isStrNull( DsSub.Tables[0].Rows[i]["HBarCode_Pack"]);
+                    oSub.HRemark = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HRemark"]);
+                    oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]);
+                    oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]);
+                    //
+                    oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]);
+                    oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]);
+                    oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSourceBillType"]);
+                    oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSourceBillNo"]);
+                    oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]);
+                    oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]);
+                    DetailColl.Add(oSub);
+                }
+                sReturn = "鏄剧ず鍗曟嵁鎴愬姛锛�";
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
+
+        /// <summary>
+        ///  鏉$爜鎵弿璁板綍,鏂板鍒板寘瑁呭崟瀛愯〃(鐘舵�佷负 0  涓存椂璁板綍)
+        /// </summary>
+        /// <param name="DetailColl"></param>
+        /// <param name="sReturn"></param>
+        /// <returns></returns>
+        public bool AddBill_PDA(Model.ClsSc_PackUnionBillSub oSub, ref string sReturn)
+        {
+            try
+            {
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                oCn.BeginTran();
+                ////鎻掑叆瀛愯〃
+                oCn.RunProc("Insert into Sc_PackUnionBillSub " +
+                  " (HInterID,HEntryID,HMaterID,HUnitID,HQty,HSourceID" +
+                  ",HEquipID,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_Pack" +
+                  ",HCloseMan,HCloseType,HRemark,HStatus" +
+                  ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)" +
+                  " values("
+                  + oSub.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() + "," + oSub.HSourceID.ToString() + "" +
+                  "," + oSub.HEquipID.ToString() + "," + oSub.HGroupID.ToString() + "," + oSub.HWorkerID.ToString() + ",getdate(),'" + oSub.HBarCode + "','" + oSub.HBarCode_Pack + "'" +
+                  ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "',0" +
+                  "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                  ") ");
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+
+        //鏉$爜鎵弿璁板綍,鏂板鍒板寘瑁呭崟
+        public bool AddBill_PDA(Model.ClsSc_PackUnionBillMain omodel, ref string sReturn)
+        {
+            try
+            {
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                oCn.BeginTran();
+                //淇敼瀛愯〃鐘舵�佷负 1  , 鏈夋晥鏁版嵁
+                oCn.RunProc("update Sc_PackUnionBillSub set HStatus=1 where HInterID=" + omodel.HInterID.ToString());
+                //涓昏〃
+                oCn.RunProc("Insert Into Sc_PackUnionBillMain   " +
+                "(HYear,HPeriod,HBillType,HInterID" +
+                ",HDate,HBillNo,HBillStatus,HRemark,HICMOInterID" +
+                ",HICMOBillNo,HBarCode_Pack,HMaterID,HUnitID" +
+                ",HMaker,HMakeDate" +
+                ") " +
+                " values(" + omodel.HYear + "," + omodel.HPeriod + ",'" + this.BillType + "'," + omodel.HInterID + "" +
+                ",getdate(),'" + omodel.HBillNo.ToString() + "'," + omodel.HBillStatus + ",'" + omodel.HRemark + "'," + omodel.HICMOInterID + "" +
+                ",'" + omodel.HICMOBillNo.ToString() + "','" + omodel.HBarCode_Pack.ToString() + "'," + omodel.HMaterID + "," + omodel.HUnitID + "" +
+                ",'" + omodel.HMaker + "',getdate()" +
+                ") ");
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+        //鏍规嵁浠g爜杩斿洖椤圭洰淇℃伅
+        public DataSet GetInfoByID_View(long HInterID, string sWhere)
+        {
+            DataSet DS;
+            try
+            {
+                DS = oCn.RunProcReturn("Select * from h_v_Sc_PackUnionBillSub Where HInterID=" + HInterID.ToString() + " " + sWhere, "h_v_Sc_PackUnionBillSub", ref DBUtility.ClsPub.sExeReturnInfo);
+                if (DS.Tables[0].Rows.Count == 0)
+                    return null;
+                else
+                {
+                    return DS;
+                }
+            }
+            catch (Exception e)
+            {
+                throw (e);
+            }
+        }
+
+        //鍒ゆ柇鏉$爜涓存椂琛ㄤ腑鏄惁瀛樺湪
+        public bool IsBarCodePack(string HBarCode_Pack)
+        {
+            DataSet DS;
+            try
+            {
+                DS = oCn.RunProcReturn("Select * from Sc_PackUnionBillMain Where  HBarCode_Pack='" + HBarCode_Pack + "'", "Sc_PackUnionBillMain", ref DBUtility.ClsPub.sExeReturnInfo);
+                if (DS.Tables[0].Rows.Count == 0)
+                    return true;       //涓嶅瓨鍦ㄧ浉鍚屾潯鐮�
+                else
+                {
+                    return false;
+                }
+            }
+            catch (Exception e)
+            {
+                throw (e);
+            }
+        }
+
+        //鍒ゆ柇鏉$爜涓存椂琛ㄤ腑鏄惁瀛樺湪
+        public bool IsBarCode(string sBarCode)
+        {
+            DataSet DS;
+            try
+            {
+                DS = oCn.RunProcReturn("Select * from Sc_PackUnionBillSub Where  HBarCode='" + sBarCode + "'", "Sc_PackUnionBillSub", ref DBUtility.ClsPub.sExeReturnInfo);
+                if (DS.Tables[0].Rows.Count == 0)
+                    return true;       //涓嶅瓨鍦ㄧ浉鍚屾潯鐮�
+                else
+                {
+                    return false;
+                }
+            }
+            catch (Exception e)
+            {
+                throw (e);
+            }
+        }
+
+        //瀹℃牳鍖呰鍗曪紙濡傛灉瀛愯〃涓殑鏉$爜涓嶅湪鏉$爜妗f涓� 鍒欙紝鍦ㄦ。妗堜腑鑷姩鐢熸垚锛� 
+        public bool CheckBill(Int64 lngBillKey, ref string sReturn)
+        { 
+            try
+            {
+                oCn.BeginTran();
+                string HChecker =DBUtility.ClsPub.CurUserName;
+                //string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
+                oCn.RunProc("Update " + MvarItemKey + " set HChecker='" + HChecker + "',HCheckDate=getdate() Where HInterID=" + lngBillKey.ToString());
+                oCn.RunProc("exec h_p_WMS_PackUnionToBarCode   " + lngBillKey.ToString() ); //鏇存柊鏉$爜妗f
+                sReturn = "";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/Models/ClsSc_PackUnionBillMain.cs b/WebAPI/Models/ClsSc_PackUnionBillMain.cs
new file mode 100644
index 0000000..98bc8ec
--- /dev/null
+++ b/WebAPI/Models/ClsSc_PackUnionBillMain.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsSc_PackUnionBillMain : DBUtility.ClsXt_BaseBillMain
+    {
+        public Int64 HICMOInterID;
+        public string HICMOBillNo;
+        public string HBarCode_Pack;
+        public Int64 HMaterID;
+        public Int64 HUnitID;
+    }
+}
diff --git a/WebAPI/Models/ClsSc_PackUnionBillSub.cs b/WebAPI/Models/ClsSc_PackUnionBillSub.cs
new file mode 100644
index 0000000..816d847
--- /dev/null
+++ b/WebAPI/Models/ClsSc_PackUnionBillSub.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsSc_PackUnionBillSub : DBUtility.ClsXt_BaseBillSub
+    {
+        //============
+        public Int64 HMaterID;
+        public Int64 HUnitID;
+        public double HQty;
+        public Int64 HErpClsID;
+        public Int64 HSourceID;
+        public Int64 HEquipID;
+        public Int64 HGroupID;
+        public Int64 HWorkerID;
+        public DateTime HScanDate;
+        public string HBatchNo;
+        public string HBarCode;
+        public string HBarCode_Pack;
+    }
+}
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index c7af795..75c5a74 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -349,7 +349,6 @@
     <Compile Include="Controllers\Open_PrintTemController.cs" />
     <Compile Include="Controllers\ReportStepPlatFormController.cs" />
     <Compile Include="Controllers\鍗氭棩鑷姩鎵爜绾縗ScanlineAPIController.cs" />
-    <Compile Include="Controllers\鍩虹璧勬枡\鍩虹璧勬枡\Gy_StockCheckItemBillController.cs" />
     <Compile Include="Controllers\宸ヨ祫绠$悊\Pay_OtherBalBillController.cs" />
     <Compile Include="Controllers\宸ヨ祫绠$悊\Pay_GroupBalBillController.cs" />
     <Compile Include="Controllers\PurchaseOrderController.cs" />
@@ -450,9 +449,11 @@
     <Compile Include="DLL\ClsSc_MouldOtherOutBill.cs" />
     <Compile Include="DLL\ClsSc_MouldOtherInBill.cs" />
     <Compile Include="DLL\ClsSc_MouldMoveStockStepOutBill.cs" />
+    <Compile Include="DLL\ClsSc_PackUnionBill.cs" />
     <Compile Include="DLL\宸ヨ祫绠$悊\ClsPay_GroupBalBill.cs" />
     <Compile Include="DLL\宸ヨ祫绠$悊\ClsPay_WorkTimesBill.cs" />
-    <Compile Include="Models\ClsGy_StockCheckItemBill.cs" />
+    <Compile Include="Models\ClsSc_PackUnionBillMain.cs" />
+    <Compile Include="Models\ClsSc_PackUnionBillSub.cs" />
     <Compile Include="Models\jsonScanline.cs" />
     <Compile Include="Models\ScanLineCode.cs" />
     <Compile Include="Models\宸ヨ祫绠$悊\ClsPay_GroupBalBillEmp.cs" />

--
Gitblit v1.9.1