From 1bbd45a2bf28afc9da6abe335f8072cf29d78456 Mon Sep 17 00:00:00 2001
From: ch <37327@LLOOCCY>
Date: 星期二, 29 十一月 2022 08:58:14 +0800
Subject: [PATCH] 修改了安瑞所需模块解析条码方法

---
 WebAPI/Controllers/POStockInBillController.cs | 1707 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 1,641 insertions(+), 66 deletions(-)

diff --git a/WebAPI/Controllers/POStockInBillController.cs b/WebAPI/Controllers/POStockInBillController.cs
index f058753..2d5de67 100644
--- a/WebAPI/Controllers/POStockInBillController.cs
+++ b/WebAPI/Controllers/POStockInBillController.cs
@@ -1,5 +1,6 @@
 锘縰sing DBUtility;
 using Model;
+using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using SQLHelper;
 using System;
@@ -14,6 +15,8 @@
 using WebAPI;
 using WebAPI.Code;
 using WebAPI.Models;
+using WebAPI.Utility;
+
 namespace WebAPI.Controllers
 {
     /**
@@ -26,14 +29,14 @@
         public Int64 HWhID;//浠撳簱ID
         public Int64 HSPID;//浠撲綅ID
 
-        public string HSupName=string.Empty;
-        public string HDeptName=string.Empty;
-        public string HWhName=string.Empty;
-        public string HSPName=string.Empty;
+        public string HSupName = string.Empty;
+        public string HDeptName = string.Empty;
+        public string HWhName = string.Empty;
+        public string HSPName = string.Empty;
 
         public Int64 HInterID;//鏈崟ID
         public string HBillNo;
-        public string HSourceBillNo=string.Empty;
+        public string HSourceBillNo = string.Empty;
         public string HBillType = "1201";//鍗曟嵁绫诲瀷
         public string sBillCode = "ICStockBill";
         public string sTranType = "1";
@@ -43,16 +46,18 @@
         public string sSourceTypeName = "閲囪喘璁㈠崟";
         public string sRedBlue2 = "钃濆瓧";
         //public bool sRedBlue = false;
-        public WebServer webserver =new WebServer();
-        public DataSet ds =new DataSet();
-        public ClsGy_BarCodeBill_WMS_Model_View oView =new ClsGy_BarCodeBill_WMS_Model_View();
-        public ClsKF_PonderationBillMain_Temp model =new ClsKF_PonderationBillMain_Temp();
+        public WebServer webserver = new WebServer();
+        public DataSet ds = new DataSet();
+        public ClsGy_BarCodeBill_WMS_Model_View oView = new ClsGy_BarCodeBill_WMS_Model_View();
+        public ClsKF_PonderationBillMain_Temp model = new ClsKF_PonderationBillMain_Temp();
         public ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
         public double sRelQty = 0;
-       // private DataBaseServices objDataBaseServices = new DataBaseServices();
+        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+        // private DataBaseServices objDataBaseServices = new DataBaseServices();
 
         private JsonResult objJsonResult = new JsonResult();
-       // private string msgModel = "{{\"count\":{0},\"code\":{0},\"message\":\"{1}\",\"result\":{2}}}";
+        // private string msgModel = "{{\"count\":{0},\"code\":{0},\"message\":\"{1}\",\"result\":{2}}}";
 
         public static string GetSession(string sMsg)
         {
@@ -75,32 +80,647 @@
         [HttpGet]
         public Object get_CheckTypeByBarCode_Json(string sCode, Int64 sInterID, string sBillNo, string sBillType, string sMaker, Int64 WhID, Int64 SPID, Double sQty, bool sRedBlue, bool SourceFlag, string sSourceBillNo, string sSourceType, Int64 HOWNERID)
         {
-            //if (sRedBlue == true)
-            //{
-            //    HBillType = "1239";
-            //}
-            //oBar = webserver.get_CheckTypeByBarCode(sCode, sInterID, sBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, ref DBUtility.ClsPub.sErrInfo);
-            WebS.WebService1 oWebs = new WebS.WebService1();
-            WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS();
-            string sExpressNumber = "";
-            WebSoBar = oWebs.get_CheckTypeByBarCode_All(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
-            if (WebSoBar == null)
+            try
             {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
-                objJsonResult.data = null;
-                return objJsonResult;
+                var sJXCode = POStockInBillController.JX_Json(sCode, sInterID, HBillType, HOWNERID, HBillNo, sMaker);
+                //if (sRedBlue == true)
+                //{
+                //    HBillType = "1239";
+                //}
+                //oBar = webserver.get_CheckTypeByBarCode(sCode, sInterID, sBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, ref DBUtility.ClsPub.sErrInfo);
+                WebS.WebService1 oWebs = new WebS.WebService1();
+                WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS();
+                string sExpressNumber = "";
+                WebSoBar = oWebs.get_CheckTypeByBarCode_All(sJXCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
+                //WebSoBar = oWebs.get_ba(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
+                if (WebSoBar == null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
+                    objJsonResult.data = WebSoBar;
+                    return objJsonResult;
+                }
             }
-            else
+            catch (Exception e)
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
-                objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
-                objJsonResult.data = WebSoBar;
+                objJsonResult.Message = e.Message + ";" + e.StackTrace;
+                objJsonResult.data = null;
                 return objJsonResult;
             }
+
         }
+
+
+
+
+        /// <summary>
+        /// 鐢熶骇姹囨姤/鎵潯鐮�/鐩存帴璋冪敤webservice
+        /// </summary>
+        /// <returns></returns>
+        [Route("ICMOReportBill/get_CheckTypeByBarCode_Json1")]
+        [HttpGet]
+        public Object get_CheckTypeByBarCode_Json1(string sCode, Int64 sInterID, string sBillType, string sBillNo, string sMaker, Int64 WhID, Int64 SPID, Double sQty, bool sRedBlue, bool SourceFlag, string sSourceBillNo, string sSourceType, Int64 HOWNERID)
+        {
+            try
+            {
+                //if (sRedBlue == true)
+                //{
+                //    HBillType = "1239";
+                //}
+                //oBar = webserver.get_CheckTypeByBarCode(sCode, sInterID, sBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, ref DBUtility.ClsPub.sErrInfo);
+                WebS.WebService1 oWebs = new WebS.WebService1();
+                WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS();
+                string sExpressNumber = "";
+                WebSoBar = oWebs.get_CheckTypeByBarCode_All(sCode, sInterID, sBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
+                if (WebSoBar == null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
+                    objJsonResult.data = WebSoBar;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = e.Message + ";" + e.StackTrace;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+
+
+        [Route("kf_PoStockInBill/JX_Json")]
+        [HttpGet]
+        public static string JX_Json(string sBarCodeNew, Int64 hinterid, string HBillType,Int64 HOrgID,string HBillNo,string HMaker)
+        {
+            try
+            {
+                //1.鍒ゆ柇绯荤粺鍙傛暟鏄惁瀹夌憺  涓嶆槸瀹夌憺 鐩存帴璺虫帀
+                //濡傛灉鏄畨鐟�  璧颁笅闈�
+
+                //瑙f瀽鏉$爜
+                //濡傛灉鍦ㄦ潯鐮佹。妗堥噷闈�   涓嶅鐞�  娌℃湁鐨勮瘽 瀛樺叆鏉$爜妗f
+
+                //鏍规嵁瑙f瀽鐨勭墿鏂� +  鎵规  鍒ゆ柇 鏉$爜涓存椂琛�  璁板綍鏄惁瀛樺湪  娌℃湁鐨勮瘽  杩涜鎵簮鍗曠殑鍔ㄤ綔
+
+
+                //鍔犱簡  鐢熶骇鏃ユ湡  鏈夋晥鏈熻嚦   淇濊川鏈熸爣蹇�
+
+                Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+                //if (oSystemParameter.omodel.WMS_CampanyName == "瀹夌憺")
+                //{
+                string HTM = "";
+                //閲囪喘鍏ュ簱
+                if (HBillType == "1201")
+                {
+                    string[] sArray = sBarCodeNew.Split('@');
+                    string HMaterNumber = "";
+                    HMaterNumber = sArray[0];
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sArray[4]);
+                    string HBarchNo = "";
+                    HBarchNo = sArray[6];
+
+                    DateTime HSCRQ = ClsPub.isDate(sArray[3]);
+                    DateTime HYXQZ = ClsPub.isDate(sArray[5]);
+
+                    //閲囪喘璁㈠崟鍙�
+                    string HPOOrderBillNo = "";
+                    HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
+
+
+
+                    Int64 HMaterID = 0;
+
+                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                    DataSet Dss;
+                    Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+
+                    DataSet Dss1;
+                    Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+                    
+                    HTM = HOrgNumber + HMaterID + HBarchNo;
+
+                    //濡傛灉鏉$爜妗f涓嶅瓨鍦�  杩涜瀛樺叆鏉$爜妗f鐨勫姩浣�
+                    //鏍规嵁鐗╂枡 + 鎵规  +   閲囪喘璁㈠崟鍙� 鎵惧埌瀵瑰簲鐨勬敹鏂欓�氱煡鍗曞彿
+                    DataSet Dss2;
+                    Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
+                    Int64 HSourceInterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["fid"]);
+                    Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FENTRYID"]);
+                    string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
+                    //鍒ゆ柇鏉$爜妗f鏄惁瀛樺湪璇ユ潯鐮�
+                    //濡傛灉瀛樺湪 鍐嶅垽鏂壂鐮佷复鏃惰〃鏄惁瀛樺湪璇ユ潯鐮�
+                    //濡傛灉涓嶅瓨鍦�  杩涜鎵簮鍗曠殑鏂规硶
+                    DataSet Dss5;
+                    Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+                        DataSet Dss6;
+                        Dss6 = oCn.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
+                        if (Dss6.Tables[0].Rows.Count > 0)
+                        {
+
+                        }
+                        else
+                        {
+                            POStockInBillController POStockInBill = new POStockInBillController();
+                            POStockInBill.set_SavePonderationBillMain_Temp_Source_Fast_Json("1103", HSourceBillNo, hinterid, HBillNo);
+
+                        }
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','1103',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                        DataSet Dss7;
+                        Dss7 = oCn.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
+                        if (Dss7.Tables[0].Rows.Count > 0)
+                        {
+
+                        }
+                        else
+                        {
+                            POStockInBillController POStockInBill = new POStockInBillController();
+                            POStockInBill.set_SavePonderationBillMain_Temp_Source_Fast_Json("1103", HSourceBillNo, hinterid, HBillNo);
+
+                        }
+
+                    }
+                }
+                //浜у搧鍏ュ簱
+                if(HBillType == "1202")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year =  ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                    DataSet ds;
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    ds = oCN.RunProcReturn("select * from h_v_SCStockInCheckBill_Json where  HYear =" + Year + " and HMonth = " + Month + " and HDay = " + Day + " and HMaterID = " + HMaterID.ToString() + "and 鎵规 = '" + HBatchNo.ToString() + "'", "h_v_SCStockInCheckBill_Json");
+                    Int64 HSourceInterID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[0]["HSourceInterID"]);
+                    Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[0]["HSourceEntryID"]);
+                    string HSourceBillNo = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string  HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33,3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+                        DataSet Dss6;
+                        Dss6 = oCN.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
+                        if (Dss6.Tables[0].Rows.Count > 0)
+                        {
+
+                        }
+                        else
+                        {
+
+                            WEBSController WEBS = new WEBSController();
+                            WEBS.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, HSourceBillNo, "3714", HMaker,HOrgID);
+
+                        }
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','3714',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                        DataSet Dss7;
+                        Dss7 = oCN.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
+                        if (Dss7.Tables[0].Rows.Count > 0)
+                        {
+
+                        }
+                        else
+                        {
+                            WEBSController WEBS = new WEBSController();
+                            WEBS.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, HSourceBillNo, "3714", HMaker, HOrgID);
+
+                        }
+
+                    }
+
+                }
+                //鐢熶骇閫�鏂�
+                if (HBillType == "1244")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                    
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+                       
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", 0,0,'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+
+                    }
+
+                }
+                //璋冩嫧鍗�
+                if (HBillType == "1207")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", 0,0,'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+
+                    }
+
+                }
+                //鍏朵粬鍑哄簱鍗�
+                if (HBillType == "1206")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", 0,0,'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+
+                    }
+
+                }
+                //棰嗘枡鍑哄簱鏍¢獙
+                if (HBillType == "1204")
+                {
+                    string[] sArray = sBarCodeNew.Split('@');
+                    string HMaterNumber = "";
+                    HMaterNumber = sArray[0];
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sArray[4]);
+                    string HBarchNo = "";
+                    HBarchNo = sArray[6];
+
+                    DateTime HSCRQ = ClsPub.isDate(sArray[3]);
+                    DateTime HYXQZ = ClsPub.isDate(sArray[5]);
+
+                    //閲囪喘璁㈠崟鍙�
+                    string HPOOrderBillNo = "";
+                    HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
+
+
+
+                    Int64 HMaterID = 0;
+
+                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                    DataSet Dss;
+                    Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+
+                    DataSet Dss1;
+                    Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+
+                    HTM = HOrgNumber + HMaterID + HBarchNo;
+
+                   
+                    DataSet Dss5;
+                    Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+                      
+                    }
+                    else
+                    {
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", " + 0 + "," + 0 + ",'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                       
+                    }
+
+                }
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 1;
+                //objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
+                //objJsonResult.data = ;
+                return HTM;
+               
+            }
+            catch (Exception e)
+            {
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 1;
+                //objJsonResult.Message = e.Message + ";" + e.StackTrace;
+                //objJsonResult.data = null;
+                return e.Message + ";" + e.StackTrace;
+            }
+
+        }
+
+
+
+     
+
+
+
         /// <summary>
         /// 涓�閿壂鐮佺孩瀛�
         /// </summary>
@@ -113,7 +733,7 @@
             {
                 HBillType = "1239";
             }
-            oBar = webserver.get_CheckTypeByBarCode_All(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID,sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
+            oBar = webserver.get_CheckTypeByBarCode_All(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
             if (oBar == null)
             {
                 objJsonResult.code = "0";
@@ -168,16 +788,16 @@
                     objJsonResult.count = 0;
                     objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + HSourceBillType;
                     objJsonResult.data = null;
-                    return objJsonResult; 
+                    return objJsonResult;
                 }
                 else
-                { 
+                {
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
                     objJsonResult.data = ds.Tables[0];
                     return objJsonResult;
-                    
+
                 }
             }
             catch (Exception ex)
@@ -199,12 +819,12 @@
         /// <returns></returns>
         [Route("POStockInBill/set_SavePonderationBillMain_Temp_Source_Fast_Json")]
         [HttpGet]
-        public object set_SavePonderationBillMain_Temp_Source_Fast_Json(string HSourceBillType,string HSourceBillNo, Int64 sInterID, string sBillNo)
+        public object set_SavePonderationBillMain_Temp_Source_Fast_Json(string HSourceBillType, string HSourceBillNo, Int64 sInterID, string sBillNo)
         {
             try
             {
-               // DataSet ds = new DataSet();
-               // WebServer webserver = new WebServer();
+                // DataSet ds = new DataSet();
+                // WebServer webserver = new WebServer();
                 string sWhere = " Where 鍗曟嵁鍙� like '%" + HSourceBillNo.Trim() + "'";
                 //鏍规嵁婧愬崟绫诲瀷鏉ヨ皟鐢ㄤ笉鍚岀殑WEBS鏂规硶 new 
                 if (HSourceBillType == "1102")
@@ -213,7 +833,7 @@
                 }
                 else if (HSourceBillType == "1103")
                 {
-                    ds = webserver.GetCg_PoInStockBillList(sWhere + "  and isnull(HBillSubType,0)=12510 ");
+                    ds = webserver.GetCg_PoInStockBillList(sWhere + "");
                 }
                 else
                 {
@@ -259,14 +879,332 @@
             }
             catch (Exception ex)
             {
-                
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�"+ex.ToString();
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
             }
         }
+
+
+
+        /// <summary>
+        /// 鍐欏叆涓存椂琛�  鎵簮鍗曠殑鏂规硶
+        /// </summary>
+        /// <param name="HSourceBillNo"></param>
+        /// <returns></returns>
+        [Route("ICMOReportBill/set_SavePonderationBillMain_Temp_Source_Fast_Json_New")]
+        [HttpGet]
+        public object set_SavePonderationBillMain_Temp_Source_Fast_Json_New(string HSourceBillType, string HSourceBillNo, Int64 sInterID, string sBillNo)
+        {
+            try
+            {
+                LogService.Write("鎵ц鎴愬姛!");
+                // DataSet ds = new DataSet();
+                // WebServer webserver = new WebServer();
+                string sWhere = " Where 鍗曟嵁鍙� like '%" + HSourceBillNo.Trim() + "'";
+                //鏍规嵁婧愬崟绫诲瀷鏉ヨ皟鐢ㄤ笉鍚岀殑WEBS鏂规硶 new 
+                if (HSourceBillType == "3710")
+                {
+                    ds = webserver.GetSc_ICMOBillList(sWhere + "  ");
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍,婧愬崟绫诲瀷鏈夐敊璇紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                //
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + HSourceBillType;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                    //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
+                }
+                else
+                {
+                    HDeptID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HDeptID"]);
+                    HDeptName = Convert.ToString(ds.Tables[0].Rows[0]["HDeptName"]);
+                    if (webserver.set_SavePonderationBillMain_Temp_Source_Fast(sInterID, sBillNo, "3711", HSourceBillNo, HSourceBillType, "钃濆瓧", ref DBUtility.ClsPub.sErrInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
+                        objJsonResult.data = ds.Tables[0];
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍐欏叆涓存椂琛ㄥけ璐ワ紒" + DBUtility.ClsPub.sErrInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+
+
+
+
+        [Route("Kf_QCStockInCheckBill_Fast/BarCode_Json")]
+        [HttpGet]
+        public object BarCode_Json(string HBarCode,Int64 HOrgID)
+        {
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                //string[] sArray = HBarCode.Split('@');
+                //string HMaterNumber = "";
+                //HMaterNumber = sArray[0];
+
+                ////閲囪喘璁㈠崟鍙�
+                //string HPOOrderBillNo = "";
+                //HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
+
+
+
+                //Int64 HMaterID = 0;
+
+
+                //DataSet Dss1;
+                //Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                //HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+
+
+                ////鏍规嵁鐗╂枡 + 鎵规  +   閲囪喘璁㈠崟鍙� 鎵惧埌瀵瑰簲鐨勬敹鏂欓�氱煡鍗曞彿
+                //DataSet Dss2;
+                //Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
+                //HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
+                //string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
+
+
+                string HTM = "";
+                string[] sArray = HBarCode.Split('@');
+                string HMaterNumber = "";
+                HMaterNumber = sArray[0];
+                Int64 HQty = 0;
+                HQty = ClsPub.isInt(sArray[4]);
+                string HBarchNo = "";
+                HBarchNo = sArray[6];
+
+                DateTime HSCRQ = ClsPub.isDate(sArray[3]);
+                DateTime HYXQZ = ClsPub.isDate(sArray[5]);
+
+                //閲囪喘璁㈠崟鍙�
+                string HPOOrderBillNo = "";
+                HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
+
+
+
+                Int64 HMaterID = 0;
+
+                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                DataSet Dss;
+                Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+
+                DataSet Dss1;
+                Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+
+                HTM = HOrgNumber + HMaterID + HBarchNo;
+
+                //濡傛灉鏉$爜妗f涓嶅瓨鍦�  杩涜瀛樺叆鏉$爜妗f鐨勫姩浣�
+                //鏍规嵁鐗╂枡 + 鎵规  +   閲囪喘璁㈠崟鍙� 鎵惧埌瀵瑰簲鐨勬敹鏂欓�氱煡鍗曞彿
+                DataSet Dss2;
+                Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
+                HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
+                Int64 HSourceInterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["fid"]);
+                Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FENTRYID"]);
+                string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
+                //鍒ゆ柇鏉$爜妗f鏄惁瀛樺湪璇ユ潯鐮�
+                //濡傛灉瀛樺湪 鍐嶅垽鏂壂鐮佷复鏃惰〃鏄惁瀛樺湪璇ユ潯鐮�
+                //濡傛灉涓嶅瓨鍦�  杩涜鎵簮鍗曠殑鏂规硶
+                DataSet Dss5;
+                Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                if (Dss5.Tables[0].Rows.Count > 0)
+                {
+                    DataSet ds;
+                    ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  HSourceBillNo ='" + HSourceBillNo.ToString() + "'", "h_v_QCStockInCheckBill_Json");
+                    if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                    {
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                        //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                        objJsonResult.data = ds.Tables[0];
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+
+
+
+                    string ModName = "85";
+                    var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                    Int64 HSupID = 0;
+                    oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                       ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                       ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                       ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                       ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                       ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                       ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                       ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                       ") values ("
+                                       + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                       + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                       + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','1103',0"
+                                       + ", 0,'',0,0,0,''"
+                                       + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
+                                       + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                       + ",0,0,0"
+                                       + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                    DataSet ds;
+                    ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  HSourceBillNo ='" + HSourceBillNo.ToString() + "'", "h_v_QCStockInCheckBill_Json");
+                    if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                    {
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                        //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                        objJsonResult.data = ds.Tables[0];
+                        return objJsonResult;
+                    }
+                }
+                //ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  鏉$爜缂栧彿 ='" + HBarCode.ToString() + "'", "h_v_QCStockInCheckBill_Json");
+                
+            }
+            catch (Exception e)
+            {
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+        [Route("Kf_SCStockInCheckBill_Fast/BarCode_Json1")]
+        [HttpGet]
+        public object BarCode_Json1(string HBarCode,Int64 HOrgID)
+        {
+            try
+            {
+
+                //鏍规嵁鎷嗗垎鐨勭墿鏂橧D +  鎵规 +  鐢熶骇鏃ユ湡 鑳芥壘鍒板敮涓�鐨勫伐搴忔眹鎶ュ崟
+                string HMaterNumber = "";
+                HMaterNumber = HBarCode.Substring(0, 10);
+                string HSCRQ = "";
+                HSCRQ = "20" + HBarCode.Substring(10, 6);
+                Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                string HBatchNo = "";
+                HBatchNo = HBarCode.Substring(16, 11);
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                DataSet ds;
+                Int64 HMaterID = 0;
+                DataSet Dss1;
+                Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+
+                DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+
+                Int64 HQty = 0;
+                HQty = ClsPub.isInt(HBarCode.Substring(33, 3));
+
+              
+                ds = oCN.RunProcReturn("select * from h_v_SCStockInCheckBill_Json where  HYear =" + Year.ToString() + "and HMonth = " + Month.ToString() + "and HDay = " + Day.ToString() + " and HMaterID = " + HMaterID.ToString() + "and 鎵规 = '" + HBatchNo.ToString() + "'", "h_v_SCStockInCheckBill_Json");
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                    //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+
+
+
+
+
+
         /// <summary>
         /// 杩斿洖鍑哄叆搴撴潯鐮佷复鏃惰〃     
         /// </summary>
@@ -299,12 +1237,12 @@
             }
             catch (Exception e)
             {
-                
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�"+e.ToString();
-                    objJsonResult.data = null;
-                    return objJsonResult;
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
             }
         }
         /// <summary>
@@ -327,7 +1265,7 @@
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
-                objJsonResult.Message ="";
+                objJsonResult.Message = "";
                 objJsonResult.data = null;
                 return objJsonResult;
             }
@@ -335,7 +1273,7 @@
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "澶辫触锛�"+DBUtility.ClsPub.sErrInfo;
+                objJsonResult.Message = "澶辫触锛�" + DBUtility.ClsPub.sErrInfo;
                 objJsonResult.data = null;
                 return objJsonResult;
             }
@@ -363,7 +1301,7 @@
             else
             {
 
-                if (webserver.set_SavePonderationBillMain_Temp_Source_SourceBillType(sInterID, sBillNo, HBillType, sBarCode, sRedBlue2, ref HSourceBillNo, ref sSourceTypeName, ref HSupID, ref  HSupName, ref HDeptID, ref HDeptName, ref DBUtility.ClsPub.sErrInfo))
+                if (webserver.set_SavePonderationBillMain_Temp_Source_SourceBillType(sInterID, sBillNo, HBillType, sBarCode, sRedBlue2, ref HSourceBillNo, ref sSourceTypeName, ref HSupID, ref HSupName, ref HDeptID, ref HDeptName, ref DBUtility.ClsPub.sErrInfo))
                 {
                     //----------鍒涘缓铏氳〃------------------------
                     DataTable dt_Main = new DataTable("Json");
@@ -424,7 +1362,7 @@
         [HttpGet]
         public object get_InfoByBarCode_Source_Json(string sBarCode, Int64 sInterID, string sBillNo, Double sQty, Int64 HWHID, Int64 HSPID)
         {
-           // string sRedBlue = "钃濆瓧";
+            // string sRedBlue = "钃濆瓧";
             try
             {
                 string sErrMsg = "";
@@ -473,12 +1411,12 @@
             }
             catch (Exception e)
             {
-                
-                 objJsonResult.code = "0";
-                 objJsonResult.count = 0;
-                 objJsonResult.Message = "鎵爜澶辫触,姝ゆ潯鐮佷笉瀛樺湪锛�"+e.ToString();
-                 objJsonResult.data = null;
-                 return objJsonResult;
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵爜澶辫触,姝ゆ潯鐮佷笉瀛樺湪锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
             }
         }
         /// <summary>
@@ -487,7 +1425,7 @@
         /// <returns></returns>
         [Route("POStockInBill/set_SavePOStockInBackBill_Json")]
         [HttpPost]
-        public object set_SavePOStockInBackBill_Json([FromBody]JObject oMain)
+        public object set_SavePOStockInBackBill_Json([FromBody] JObject oMain)
         {
             var _value = oMain["oMain"].ToString();
             string msg1 = _value.ToString();
@@ -543,7 +1481,7 @@
         /// <returns></returns>
         [Route("POStockInBill/set_SavePOStockInBill_Json")]
         [HttpPost]
-        public object set_SavePOStockInBill_Json([FromBody]JObject oMain)
+        public object set_SavePOStockInBill_Json([FromBody] JObject oMain)
         {
             var _value = oMain["oMain"].ToString();
             string msg1 = _value.ToString();
@@ -565,6 +1503,7 @@
                 websLsmain.HDeptID = lsmain[0].HDeptID;
                 websLsmain.HWHID = lsmain[0].HWHID;
                 websLsmain.HSCWHID = 0;
+                //websLsmain.HSPID = lsmain[0].HSPID;
                 websLsmain.HSupID = lsmain[0].HSupID;
                 websLsmain.HKeeperID = lsmain[0].HKeeperID;
                 websLsmain.HSecManagerID = lsmain[0].HSecManagerID;
@@ -572,11 +1511,13 @@
                 websLsmain.HManagerID = 0;
                 websLsmain.HBillerID = lsmain[0].HBillerID;
                 websLsmain.HRemark = "";
+                websLsmain.HExplanation = lsmain[0].HExplanation;
                 websLsmain.HInnerBillNo = "";
                 websLsmain.HRedBlueFlag = false;//false钃濆瓧 true绾㈠瓧
                 websLsmain.HMainSourceBillType = lsmain[0].HBillType;
-                websLsmain.HExplanation = lsmain[0].HExplanation;
-
+                websLsmain.HMaker = lsmain[0].HMaker;
+                websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
+                websLsmain.HOWNERID = lsmain[0].HSTOCKORGID;
 
                 if (webserver.set_SavePOStockInBill_New(websLsmain, sSourceBillType, ref DBUtility.ClsPub.sErrInfo))
                 {
@@ -605,16 +1546,75 @@
             }
         }
 
+
+        /// <summary>
+        /// 鐢熶骇姹囨姤鍗�/鎻愪氦/鐩存帴璋僿ebservice
+        /// </summary>
+        /// <returns></returns>
+        [Route("ICMOReportBill/set_SaveICMOReportBill_Json")]
+        [HttpPost]
+        public object set_SaveICMOReportBill_Json([FromBody] JObject oMain)
+        {
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                List<Model.ClsSc_ICMOReportBillMain> lsmain = new List<Model.ClsSc_ICMOReportBillMain>();
+                ListModels oListModels = new ListModels();
+                lsmain = oListModels.getICMOReportBillMainByJson(msg1);
+                lsmain[0].HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                lsmain[0].HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
+                string sSourceBillType = lsmain[0].HBillType;
+
+                WebAPI.WebS.ClsSc_ICMOReportBillMain websLsmain = new WebS.ClsSc_ICMOReportBillMain();
+
+                websLsmain.HInterID = lsmain[0].HInterID;
+                websLsmain.HBillNo = lsmain[0].HBillNo;
+                websLsmain.HBillType = "3711";//鍥哄畾鍊�
+                websLsmain.HDate = lsmain[0].HDate;
+                websLsmain.HDeptID = lsmain[0].HDeptID;
+                websLsmain.HEmpID = 0;
+                websLsmain.HBillerID = lsmain[0].HBillerID;
+                websLsmain.HRemark = "";
+                websLsmain.HMainSourceBillType = lsmain[0].HBillType;
+
+
+                if (webserver.set_SaveICMOReportBill_Json(websLsmain, sSourceBillType, ref DBUtility.ClsPub.sErrInfo))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鎴愬姛锛佸崟鎹彿涓猴細";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "涓婁紶澶辫触锛�" + DBUtility.ClsPub.sErrInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "涓婁紶澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
         [Route("POStockInBill/GetSpName_Json")]
         [HttpGet]
-        public object GetSpName_Json(long HSpID, long HWHID,long HStockOrgID, ref string sErrMsg)
+        public object GetSpName_Json(long HSpID, long HWHID, long HStockOrgID, ref string sErrMsg)
         {
             try
             {
                 ds = webserver.GetSPInfoByIDandHWHIDandOrg(HSpID, HWHID, HStockOrgID, ref sErrMsg);
                 if (ds == null || ds.Tables[0].Rows.Count <= 0)
                 {
-
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
@@ -641,8 +1641,6 @@
                 return objJsonResult;
             }
         }
-
-
         [Route("POStockInBill/Delete_Json")]
         [HttpGet]
         public object Delete_Json(long HInterID, long HMaterID, long HAuxPropID, string HMTONo, long HSourceInterID, long HSourceEntryID, string sHBillType)
@@ -650,7 +1648,7 @@
             string sErrMsg = string.Empty;
             try
             {
-                if (webserver.set_DelPonderationBillMain_Temp_InterIDAndSource(HInterID, HMaterID,HAuxPropID,HMTONo,HSourceInterID,HSourceEntryID,sHBillType,ref sErrMsg))
+                if (webserver.set_DelPonderationBillMain_Temp_InterIDAndSource(HInterID, HMaterID, HAuxPropID, HMTONo, HSourceInterID, HSourceEntryID, sHBillType, ref sErrMsg))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
@@ -719,7 +1717,7 @@
 
         [Route("POStockInBillList/DisBillEntryList_Mate_Webs_Json")]
         [HttpGet]
-        public object DisBillEntryList_Webs_Json(string HBillType,string sWhere)
+        public object DisBillEntryList_Webs_Json(string HBillType, string sWhere)
         {
             try
             {
@@ -779,7 +1777,6 @@
             }
             catch (Exception)
             {
-
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "鍒犻櫎澶辫触锛�";
@@ -789,5 +1786,583 @@
 
         }
 
+        #region 鍒拌揣纭
+        [Route("POStockInBillList/Get_ReciveBill")]
+        [HttpGet]
+        public object get_InfoByBillNo(string HBillno)
+        {
+            try
+            {
+                json result = Get_ReciveBillCheckDate(HBillno);
+                return result;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        public int GetHinterIDByBillNo(string HBillNo, string type)
+        {
+            SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
+            int HInterID = 0;
+            string sql = "select HInterID from CG_POINSTOCKBILLMAIN where HBILLNO = '" + HBillNo + "'";
+            if (type == "Print")
+                sql += " and HBillStatus = '2' ";//鎵撳嵃鍒ゆ柇鏄惁瀹℃牳
+            DataTable dt = oCn.RunProcReturn(sql, "HInterID").Tables[0];
+            if (dt.Rows.Count > 0)
+                HInterID = Convert.ToInt32(dt.Rows[0]["HInterID"]);
+            return HInterID;
+        }
+
+        /// <summary>
+        /// 鍒拌揣纭鎵敹鏂欓�氱煡鍗曞彿 鑾峰彇琛ㄤ綋鍜岃〃澶存暟鎹�
+        /// </summary>
+        /// <param name="HBarCode"></param>
+        /// <returns></returns>
+        public json Get_ReciveBillCheckDate(string HBarCode)
+        {
+            json objjson = new json();
+            try
+            {
+                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                DataSet Ds;
+                string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//瀹㈡埛鍚嶇О
+                if (FCusName.Contains("瀹夌憺"))
+                    Ds = oCn.RunProcReturn("exec h_p_GetPOInStockByBarCode'" + HBarCode + "'", "h_p_GetPOInStockByBarCode");
+                else
+                    Ds = oCn.RunProcReturn("exec h_p_KF_PonderationBillMain_Temp_Add_POInStockCheck2 '" + HBarCode + "'", "h_p_KF_PonderationBillMain_Temp_Add_POInStockCheck2");
+                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
+                {
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objjson.data = null;
+                    return objjson;
+                }
+                else
+                {
+                    if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) == 0)
+                    {
+                        objjson.code = "1";
+                        objjson.count = 1;
+                        objjson.Message = "Sucess锛�";
+                        objjson.data = Ds.Tables[0];
+                        return objjson;
+                    }
+                    else
+                    {
+                        objjson.code = "0";
+                        objjson.count = 0;
+                        objjson.Message = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
+                        objjson.data = null;
+                        return objjson;
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                objjson.code = "0";
+                objjson.count = 0;
+                objjson.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objjson.data = null;
+                return objjson;
+
+            }
+        }
+
+        [Route("POStockInBillList/AuditPOInStockBillPost")]
+        [HttpPost]
+        public object AuditPOInStockBill([FromBody] JObject msg)
+        {
+            try
+            {
+                string _msg = msg["msg"].ToString();
+                _msg = _msg.Replace("\\", "");
+                _msg = _msg.Replace("\n", "");
+                List<Models.ReciveBill_FastModel> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ReciveBill_FastModel>>(_msg);
+                DAL.ClsCg_POInStockBill oBill = new DAL.ClsCg_POInStockBill();
+                var hinterID = list[0].HInterID;
+                var FID = list[0].FID;
+                string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//瀹㈡埛鍚嶇О
+                string FisRealess = oSystemParameter.GetSingleSystemParameter("Cg_POInStockBill_ErpAduit", ref DBUtility.ClsPub.sExeReturnInfo);//閫佽揣鍗曞埌璐х‘璁ゅ悗鍚屾閲戣澏浜戞敹鏂欓�氱煡鍗�
+                string FishaveBarcode = oSystemParameter.GetSingleSystemParameter("Cg_POInStockBill_BarCodeCtl", ref DBUtility.ClsPub.sExeReturnInfo);//鍒拌揣纭蹇呴』鎵爜绠辨潯鐮�
+                var kdTbaleName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DataBaseName");
+                string sql = string.Empty;
+                #region 鏍¢獙鏄惁鎵弿鏉$爜
+                if (FishaveBarcode == "Y")
+                {
+                    var HInterID = list[0].HInterID;
+                    string jysql = string.Format(@"select * from KF_PonderationBillMain_Temp where HSourceInterID = {0}", HInterID);
+                    DataTable jyDt = oCn.RunProcReturn(jysql, "jysql").Tables[0];
+                    if (jyDt.Rows.Count == 0 || jyDt == null)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "璇锋壂鎻忔潯鐮�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                #endregion
+                #region 閲戣澏瀹℃牳鍚庝細閲嶆柊鍚屾鍗曟嵁鍒癿es 鏁呬笉闇�瑕佹洿鏂癿es鐨勬敹鏂欓�氱煡鍗� 
+                oCn.BeginTran();
+                foreach (var item in list)
+                {
+                    if (item.HSQty == 0)
+                        continue;
+                    sql = $"update Cg_POInStockBillSub set Hqty = {item.HSQty} where HInterID ={item.HInterID} and HEntryID = {item.HEntryID}";
+                    oCn.RunProc(sql);
+                }
+                //鏇存柊鎴愬姛鍚� 鍚屾鏇存柊閲戣澏
+                oCn.Commit();
+                #endregion
+
+                if (FCusName.Contains("瀹夌憺"))
+                {
+                    sql = string.Format(@"
+SELECT T3.FNAME AS FTYPENAME,M.HBILLNO,B.HINTERID,B.HENTRYID,C.FID,C.FENTRYID, D.FBILLNO,B.HQTY,CD.FRECEIVEORGID,CDOO.FNUMBER AS FRECEIVENUMBER
+,D.FSUPPLIERID,DS.FNUMBER AS FSUPPLIERNUMBER,D.FPURCHASEORGID,DOO.FNUMBER AS FPURCHASEORGNUMBER,CROO.FNUMBER  AS FSETTLEORGNUMBER,
+E.FPRICETIMEPOINT,E.FSETTLECURRID,EC.FNUMBER AS FSETTLECURRNUMBER,C.FMATERIALID,CM.FNUMBER AS FMATERIALNUMBER ,C.FUNITID 
+,CU.FNUMBER AS FUNITNUMBER,CR.FPRICE,CR.FTAXPRICE,CR.FTAXRATE,D.FPURCHASERID,isnull(T4.FNUMBER,'') AS FPURCHASERNUMBER
+FROM CG_POINSTOCKBILLSUB B  
+JOIN CG_POINSTOCKBILLMAIN M ON B.HINTERID = M.HINTERID
+JOIN {0}..T_PUR_POORDERENTRY C ON B.HSOURCEINTERID = C.FID AND B.HSOURCEENTRYID = C.FENTRYID
+LEFT JOIN {0}..T_BD_MATERIAL CM ON C.FMATERIALID =CM.FMATERIALID
+LEFT JOIN {0}..T_BD_UNIT CU ON C.FUNITID =CU.FUNITID
+JOIN {0}..T_PUR_POORDERENTRY_D CD ON    C.FENTRYID = CD.FENTRYID
+LEFT JOIN {0}..T_ORG_ORGANIZATIONS CDOO ON CD.FRECEIVEORGID = CDOO.FORGID
+JOIN {0}..T_PUR_POORDERENTRY_F CR ON    C.FENTRYID = CR.FENTRYID
+LEFT JOIN {0}..T_ORG_ORGANIZATIONS CROO ON CR.FSETTLEORGID = CROO.FORGID
+LEFT JOIN {0}..T_PUR_POORDER D ON C.FID =D.FID
+LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID
+LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID and FLOCALEID = 2052
+LEFT JOIN  {0}..V_BD_BUYER T4 ON D.FPURCHASERID =T4.FID
+LEFT JOIN {0}..T_BD_SUPPLIER DS ON D.FSUPPLIERID = DS.FSUPPLIERID
+LEFT JOIN {0}..T_ORG_ORGANIZATIONS DOO ON D.FPURCHASEORGID = DOO.FORGID
+JOIN {0}..T_PUR_POORDERFIN E ON C.FID =E.FID
+LEFT JOIN {0}..T_BD_CURRENCY EC ON E. FSETTLECURRID =EC.FCURRENCYID  
+ WHERE b.hinterid in ({1}) and M.HERPInterID = 0
+", kdTbaleName, hinterID);
+                    DataTable dt = oCn.RunProcReturn(sql, "sltz").Tables[0];
+                    List<string> fidList = new List<string>();
+                    if (dt.Rows.Count > 0)
+                    {
+                        //foreach (DataRow dr in dt.Rows)
+                        //{
+                        //    //閲囪喘璁㈠崟涓嬫帹鐢熸垚閫佽揣鍗� 鏃跺�� 鍒ゆ柇鏄惁鏈夌敓鎴愰噰璐鍗曞彉鏇村崟 濡傛灉鏈変笖鍙樻洿鍗曠姸鎬佷笉涓哄凡瀹℃牳 闄愬埗涓嬫帹
+                        //    objJsonResult = TestPOOrder(dr["FEntryID"].ToString());
+                        //    if (objJsonResult.code == "0")
+                        //        return objJsonResult;
+                        //}
+                        foreach (DataRow dr in dt.Rows)
+                        {
+                            if (fidList.Contains(dr["HINTERID"].ToString()))
+                                continue;
+                            else
+                                fidList.Add(dr["HINTERID"].ToString());
+                            DataRow[] drs = dt.Select("HINTERID = " + dr["HINTERID"].ToString());
+                            JObject model = new JObject();
+                            string fTypeName = "SLD01_SYS";//鏍囧噯閲囪喘璁㈠崟绫诲瀷
+                            string ywTypeName = "CG";//鏍囧噯涓氬姟绫诲瀷
+                            if (dr["FTYPENAME"].ToString().Contains("濮斿"))
+                            {
+                                fTypeName = "SLD03_SYS";
+                                ywTypeName = "WW";
+                            }
+                            if (dr["FTYPENAME"].ToString().Contains("璧勪骇"))
+                            {
+                                fTypeName = "SLD04_SYS";
+                                ywTypeName = "ZCCG";
+                            }
+                            model.Add("FBILLTYPEID", new JObject() { ["Fnumber"] = fTypeName }); //鍗曟嵁绫诲瀷
+                            model.Add("FBusinessType", ywTypeName); //涓氬姟绫诲瀷
+                            model.Add("FBILLNO", dr["HBillNo"].ToString()); //鍗曟嵁缂栧彿
+                            model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //閫氱煡鏃ユ湡
+                            model.Add("FStockOrgId", new JObject() { ["Fnumber"] = dr["FRECEIVENUMBER"].ToString() }); // 鏀舵枡缁勭粐 
+                            model.Add("FPurOrgId", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() }); //閲囪喘缁勭粐
+                            model.Add("FSupplierId", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() }); //渚涘簲鍟�
+                            model.Add("FPURCHASERID", new JObject() { ["Fnumber"] = dr["FPURCHASERNUMBER"].ToString() }); //閲囪喘鍛�
+                            model.Add("FOwnerTypeIdHead", "BD_Supplier");//  璐т富绫诲瀷
+                            model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() });//璐т富 渚涘簲鍟� 
+                            JArray Fentity = new JArray();
+                            foreach (var item in drs)
+                            {
+                                JObject FentityModel = new JObject();
+                                FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = item["FMATERIALNUMBER"].ToString() }); // 鐗╂枡缂栫爜   
+                                FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 鍗曚綅   
+                                FentityModel.Add("FPreDeliveryDate", DateTime.Now.ToString("yyyy-MM-dd")); //棰勮鍒拌揣鏃ユ湡   
+                                FentityModel.Add("FPriceUnitId", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 璁′环鍗曚綅   
+                                FentityModel.Add("FStockUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); //  搴撳瓨鍗曚綅   
+                                FentityModel.Add("FStockID", new JObject() { ["Fnumber"] = "BJCK-SH.01.005" }); //  搴撳瓨鍗曚綅   
+                                FentityModel.Add("FActReceiveQty", Convert.ToDecimal(item["HQTY"])); // 渚涘簲鍟嗛�佽揣鏁伴噺锛堟彁鏂欒鍒掓暟閲� - 宸茬敓鎴愰�佽揣鍗曟暟閲忥級
+                                FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//璐т富绫诲瀷
+                                FentityModel.Add("FOwnerID", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() });//璐т富 
+                                FentityModel.Add("FSrcId", item["FID"].ToString());//婧愬崟鍐呯爜
+                                FentityModel.Add("FSRCFORMID", "PUR_PurchaseOrder");//婧愬崟绫诲瀷
+                                FentityModel.Add("FSrcBillNo", item["FBILLNO"].ToString());//婧愬崟鍗曞彿
+                                FentityModel.Add("FSRCENTRYID", item["FENTRYID"].ToString());//婧愬崟鍒嗗綍鍐呯爜
+                                FentityModel.Add("FORDERBILLNO", item["FBILLNO"].ToString());//婧愬崟鍗曞彿
+                                FentityModel.Add("FPOORDERENTRYID", item["FENTRYID"].ToString());//婧愬崟鍒嗗綍鍐呯爜
+                                FentityModel.Add("FSRMENTRYID", item["HENTRYID"].ToString());//SRM hentryid
+                                FentityModel.Add("FPrice", item["FPRICE"].ToString());//鍗曚环
+                                FentityModel.Add("FTaxPrice", item["FTAXPRICE"].ToString());//鍚◣鍗曚环
+                                FentityModel.Add("FEntryTaxRate", item["FTAXRATE"].ToString());//绋庣巼
+
+                                JArray Fentity2 = new JArray();
+                                JObject FentityModel2 = new JObject();
+                                FentityModel2.Add("FDetailEntity_Link_FRULEID", "PUR_PurchaseOrder-PUR_ReceiveBill");
+                                FentityModel2.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry");
+                                FentityModel2.Add("FDetailEntity_Link_FSBillId", item["FID"].ToString());
+                                FentityModel2.Add("FDetailEntity_Link_FSId", item["FEntryID"].ToString());
+                                Fentity2.Add(FentityModel2);
+                                FentityModel.Add("FDetailEntity_Link", Fentity2);
+                                Fentity.Add(FentityModel);
+                            }
+                            model.Add("FDetailEntity", Fentity); //鏄庣粏淇℃伅
+
+                            JObject _FentityModel = new JObject();
+                            _FentityModel.Add("FSettleOrgId", new JObject() { ["Fnumber"] = dr["FSETTLEORGNUMBER"].ToString() }); //  缁撶畻缁勭粐  
+                            _FentityModel.Add("FSettleCurrId", new JObject() { ["Fnumber"] = dr["FSETTLECURRNUMBER"].ToString() }); //  缁撶畻甯佸埆
+                            _FentityModel.Add("FPricePoint", 0); //  瀹氫环鏃剁偣
+                            model.Add("FinanceEntity ", _FentityModel);//璐㈠姟淇℃伅
+                            JObject jsonRoot = new JObject()
+                            {
+                                ["Creator"] = "",
+                                ["NeedUpDateFields"] = new JArray(),
+                                ["NeedReturnFields"] = new JArray(),
+                                ["IsDeleteEntry"] = "false",
+                                ["SubSystemId"] = "",
+                                ["IsVerifyBaseDataField"] = "false",
+                                ["Model"] = model
+                            };
+                            var loginRet = InvokeHelper.Login();
+                            var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+                            if (isSuccess == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = loginRet;
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            //LogService.Write("jsonRoot:" + jsonRoot.ToString());
+                            var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
+                            //LogService.Write(result);
+                            if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() == "TRUE")
+                            {
+                                //鏇存柊閫佽揣鍗� 涓昏〃 ERP鍗曟嵁鍙� 浠ュ強 ERP涓诲唴鐜�
+                                string FBillNo = JObject.Parse(result)["Result"]["Number"].ToString();
+                                FID = JObject.Parse(result)["Result"]["Id"].ToString();
+                                string updateSql = string.Format(@"
+                                                      update a set 
+                                                      a.HERPInterID = {0} ,
+                                                      a.HERPBillNO   ='{1}'
+                                                      from Cg_POInStockBillMain a
+                                                      join Cg_POInStockBillSub b on a.hinterid = b.hinterid
+                                                      where b.HInterID = ({2})
+                                                      and b. HSOURCEINTERID = {3}
+                                                      and a.HERPInterID = 0
+                                                     ", FID, FBillNo, dr["HINTERID"].ToString(), dr["FID"].ToString());
+                                oCn.RunProc(updateSql);
+                            }
+                            else
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = result;
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+
+                        }
+                    }
+                    else
+                    {
+                        LogService.Write("鏀舵枡閫氱煡鍗曞鏍告棤鏁版嵁锛�" + sql);
+                    }
+                }
+                else //澶忓疂 锛屾洿鏂癳rp淇℃伅
+                {
+                    JObject jsonRoot = new JObject();
+                    jsonRoot.Add("Creator", "");
+                    jsonRoot.Add("NeedUpDateFields", new JArray());
+                    jsonRoot.Add("NeedReturnFields", new JArray());
+                    jsonRoot.Add("IsDeleteEntry", "false");
+                    jsonRoot.Add("SubSystemId", "");
+                    jsonRoot.Add("IsVerifyBaseDataField", "");
+
+                    JObject jsonModel = new JObject();
+                    jsonModel.Add("FID", FID);
+                    JArray Entry = new JArray();
+                    foreach (var item in list)
+                    {
+                        if (item.HSQty == 0)
+                            continue;
+                        JObject jsonFPOOrderEntry = new JObject();
+                        jsonFPOOrderEntry.Add("FEntryID", item.FEntryID);
+                        jsonFPOOrderEntry.Add("FActReceiveQty ", item.HSQty); ;
+                        Entry.Add(jsonFPOOrderEntry);
+                    }
+                    jsonModel.Add("FDetailEntity", Entry);
+                    jsonRoot.Add("Model", jsonModel);
+                    var loginRet = InvokeHelper.Login();
+                    var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+                    if (isSuccess <= 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = loginRet;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
+                    //LogService.Write(result);
+                    if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                    {
+                        LogService.Write("鏀舵枡閫氱煡鍗曚慨鏀瑰け璐sonRoot:" + jsonRoot.ToString());
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曟洿鏂板け璐�" + result;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                var json = new
+                {
+                    Ids = FID,
+                };
+                //LogService.Write(json);
+                //鎻愪氦
+                var _result = InvokeHelper.Submit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
+                var _saveObj = JObject.Parse(_result);
+                if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                {
+                    LogService.Write("鏀舵枡閫氱煡鍗曟彁浜ゅけ璐sonRoot:" + json.ToString());
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曟彁浜ゅけ璐�" + _result;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+                //瀹℃牳
+                _result = InvokeHelper.Audit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
+                _saveObj = JObject.Parse(_result);
+                if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                {
+                    LogService.Write("鏀舵枡閫氱煡鍗曞鏍稿け璐sonRoot:" + json.ToString());
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曞鏍稿け璐sonRoot" + _result;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎿嶄綔鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                //oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "寮傚父锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+
+        /// <summary>
+        /// 鍒拌揣纭 鎵潯鐮� 鏍¢獙
+        /// </summary>
+        /// <param name="HBarcode"></param>
+        /// <param name="HInterID"></param>
+        /// <returns></returns>
+        [Route("POStockInBillList/Get_ReciveBillByBarcode")]
+        [HttpGet]
+        public object Get_ReciveBillByBarcode(string HBarcode, string HInterID)
+        {
+            try
+            {
+                //var code = HBarcode.Split('#')[0];
+                //鏍¢獙鏉$爜鏄惁瀛樺湪
+                string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//瀹㈡埛鍚嶇О
+                string sql = string.Empty;
+                if (FCusName.Contains("瀹夌憺"))
+                    sql = $"select HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode}' and HBarCodeType ='绠卞彿鍐呮潯鐮�'";
+                else
+                    sql = $"select HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode.Split('#')[0]}' and HQty = {HBarcode.Split('#')[1]}";
+                DataSet ds = oCn.RunProcReturn(sql, "H_v_SRM_POOrderBillList");
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏉$爜涓嶅瓨鍦紒";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+                else
+                {
+                    //瀛樺叆鏉$爜涓存椂琛�
+                    sql = $"delete from KF_PonderationBillMain_Temp Where HBillNo='{ds.Tables[0].Rows[0]["HSourceBillNo"]}' ";
+                    oCn.RunProc(sql);
+                    sql = string.Format(@"Insert into KF_PonderationBillMain_Temp 
+	(HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID
+	,HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty
+	,HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate
+	,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo
+	,HSTOCKORGID,HOWNERID,HExpressNumber,HSubBillType
+	,HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag
+	,HCusID)
+	select HInterID,HSourceBillNo,HBillType,HMaterID,0,0,0
+	,0,0,0,HQty,HQty,0
+	,HAuxPropID,HBatchNo,'','','System',getdate()
+	,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo
+	,HSTOCKORGID,HOWNERID,'',HBillType
+	,0,0,'',0
+	,0 from Gy_BarCodeBill  
+	where HItemID = {0}", ds.Tables[0].Rows[0]["HItemID"]);
+                    oCn.RunProc(sql);
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                //string sql = $"select * from H_v_SRM_POInStockBillList where 鍗曟嵁鍙� ='{HBillno}'";
+                //ds = oCn.RunProcReturn(sql, "H_v_SRM_POInStockBillList");
+                //if (ds == null || ds.Tables[0].Rows.Count == 0)
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+                //else
+                //{
+
+                //}
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        //鏀舵枡閫氱煡鍗曞鏍� 瀹℃牳鎻愪氦
+        [Route("POStockInBillList/Exec_ReciveBillCheck")]
+        [HttpGet]
+        public json Exec_ReciveBillCheck(string HBarCode)
+        {
+            json objjson = new json();
+            try
+            {
+                //淇敼閲戣澏鐢熶骇鍗曠殑鐘舵��
+                //璁块棶閲戣澏
+                var loginRet = InvokeHelper.Login();
+                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+
+                if (isSuccess == 0)
+                {
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet;
+                    objjson.data = null;
+                    return objjson;
+                }
+                var json = new
+                {
+                    //CreateOrgId = 0,
+                    Numbers = HBarCode,
+                    //Ids = (EntyID).Split('-')[0],
+                    //PkEntryIds = (EntyID).Split('-')[1]
+                };
+                string result1 = string.Empty;
+                string result2 = string.Empty;
+                DataSet Ds = oCn.RunProcReturn("select FDOCUMENTSTATUS,FID from  AIS20210811135644..T_PUR_RECEIVE where FBILLNO='" + HBarCode + "'", "AIS20210811135644..T_PUR_RECEIVE");
+                //鍒ゆ柇褰撳墠鏀舵枡閫氱煡鍗曠姸鎬佲�斺�斿凡鍒涘缓鍒欏厛鎻愪氦鍐嶅鏍搞�佷互鎻愪氦鍒欏彧瀹℃牳
+                if (Ds.Tables[0].Rows[0][0].ToString() == "A" || Ds.Tables[0].Rows[0][0].ToString() == "D")
+                {
+                    result1 = InvokeHelper.Submit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
+                    result2 = InvokeHelper.Audit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
+                }
+                if (Ds.Tables[0].Rows[0][0].ToString() == "B")
+                {
+                    result2 = InvokeHelper.Audit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
+                }
+                //鍒ゆ柇瀹℃牳鏄惁鎴愬姛
+                if (JObject.Parse(result2)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                {
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = "瀹℃牳鏀舵枡閫氱煡鍗曞け璐ワ紒鍗曟嵁鍙凤細" + HBarCode;
+                    objjson.data = null;
+                    return objjson;
+                }
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "瀹℃牳鎴愬姛锛�";
+                objJsonResult.data = 1;
+                return objjson;
+            }
+            catch (Exception e)
+            {
+                objjson.code = "0";
+                objjson.count = 0;
+                objjson.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objjson.data = null;
+                return objjson;
+            }
+
+        }
+        #endregion
+
+        #region PDA閿�鍞嚭搴�
+        //PDA閿�鍞嚭搴撴暣鎵樺垹闄�
+        [Route("POStockInBillList/SellOutBillSDeleCode")]
+        [HttpGet]
+        public object SellOutBillSDeleCode(string HBarCode, string HInterID)
+        {
+            try
+            {
+                //鏍规嵁鏉$爜鍦ㄦ潯鐮佹。妗堜腑鎵惧埌瀵瑰簲鐨勬墭鏉$爜锛屽啀鍦ㄤ复鏃惰〃涓垹闄よ鎵樻潯鐮佺殑鍏ㄩ儴璁板綍
+                string sql = string.Format(@"delete from KF_PonderationBillMain_Temp where HBillType=1205 and HInterID=" + HInterID + " and HBarCode" +
+                    " in (select HBarCode from Gy_BarCodeBill where HBarCode_Pack = (select HBarCode_Pack from Gy_BarCodeBill where HBarCode = '" + HBarCode + "'))");
+                oCn.RunProc(sql);
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鏁存墭鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1