|  |  | 
 |  |  | using DBUtility; | 
 |  |  | using Model; | 
 |  |  | using Newtonsoft.Json; | 
 |  |  | using Newtonsoft.Json.Linq; | 
 |  |  | using SQLHelper; | 
 |  |  | using System; | 
 |  |  | 
 |  |  | using WebAPI; | 
 |  |  | using WebAPI.Code; | 
 |  |  | using WebAPI.Models; | 
 |  |  | using WebAPI.Utility; | 
 |  |  |  | 
 |  |  | namespace WebAPI.Controllers | 
 |  |  | { | 
 |  |  |     /** | 
 |  |  | 
 |  |  |         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"; | 
 |  |  | 
 |  |  |         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(); | 
 |  |  |         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) | 
 |  |  |         { | 
 |  |  | 
 |  |  |         [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; | 
 |  |  |                 //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) | 
 |  |  |                 { | 
 |  |  |                     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; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// 一键扫码红字 | 
 |  |  |         /// </summary> | 
 |  |  | 
 |  |  |             { | 
 |  |  |                 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"; | 
 |  |  | 
 |  |  |                     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) | 
 |  |  | 
 |  |  |         /// <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") | 
 |  |  | 
 |  |  |             } | 
 |  |  |             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; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// 返回出入库条码临时表      | 
 |  |  |         /// </summary> | 
 |  |  | 
 |  |  |             } | 
 |  |  |             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> | 
 |  |  | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  |                 objJsonResult.Message =""; | 
 |  |  |                 objJsonResult.Message = ""; | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "失败!"+DBUtility.ClsPub.sErrInfo; | 
 |  |  |                 objJsonResult.Message = "失败!" + DBUtility.ClsPub.sErrInfo; | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  | 
 |  |  |             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"); | 
 |  |  | 
 |  |  |         [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 = ""; | 
 |  |  | 
 |  |  |             } | 
 |  |  |             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> | 
 |  |  | 
 |  |  |         /// <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(); | 
 |  |  | 
 |  |  |         /// <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(); | 
 |  |  | 
 |  |  |                 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; | 
 |  |  | 
 |  |  |                 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)) | 
 |  |  |                 { | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// 生产汇报单/提交/直接调webservice | 
 |  |  |         /// </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 = "没有返回任何记录!"; | 
 |  |  | 
 |  |  |                 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) | 
 |  |  | 
 |  |  |             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; | 
 |  |  | 
 |  |  |  | 
 |  |  |         [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 | 
 |  |  |             { | 
 |  |  | 
 |  |  |             } | 
 |  |  |             catch (Exception) | 
 |  |  |             { | 
 |  |  |  | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "删除失败!"; | 
 |  |  | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         #region 到货确认 | 
 |  |  |         [Route("POStockInBillList/Get_ReciveBill")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object get_InfoByBillNo(string HBillno) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 json result = Get_ReciveBillCheckDate(HBillno); | 
 |  |  |                 return result; | 
 |  |  |                 //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 | 
 |  |  |                 //{ | 
 |  |  |                 //    objJsonResult.code = "1"; | 
 |  |  |                 //    objJsonResult.count = 1; | 
 |  |  |                 //    objJsonResult.Message = "Sucess!"; | 
 |  |  |                 //    objJsonResult.data = ds.Tables[0]; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "没有返回任何记录!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         [Route("POStockInBillList/AuditPOInStockBill")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object AuditPOInStockBill(string HInterID, string CurUserName, string HBillNo) | 
 |  |  |         { | 
 |  |  |             Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); | 
 |  |  |             json objjson = new json(); | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); | 
 |  |  |                 //采购订单 生成送货单列表 | 
 |  |  |                 if (!String.IsNullOrEmpty(HBillNo)) | 
 |  |  |                     HInterID = GetHinterIDByBillNo(HBillNo, "Aduit").ToString(); | 
 |  |  |                 if (HInterID == "0") | 
 |  |  |                 { | 
 |  |  |                     objjson.code = "0"; | 
 |  |  |                     objjson.count = 0; | 
 |  |  |                     objjson.Message = "操作失败,请先保存订单"; | 
 |  |  |                     objjson.data = null; | 
 |  |  |                     return objjson; | 
 |  |  |                 } | 
 |  |  |                 string parameterSql = $"select HValue from Xt_SystemParameter where HKey ='Cg_POInStockBill_ErpAduit'"; | 
 |  |  |                 var HValue = oCn.RunProcReturn(parameterSql, "dt").Tables[0].Rows[0][0].ToString(); | 
 |  |  |                 string sql = string.Empty; | 
 |  |  |                 if (HValue == "Y") | 
 |  |  |                 { | 
 |  |  |                     var kdTbaleName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DataBaseName"); | 
 |  |  |                     string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo); | 
 |  |  |                     DataTable dt = new DataTable(); | 
 |  |  |                     List<string> fidList = new List<string>(); | 
 |  |  |                     if (FCusName == "瑞与祺" || FCusName == "") | 
 |  |  |                     { | 
 |  |  |                         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); | 
 |  |  |                         //LEFT JOIN  {0}..T_HR_EMPINFO T5 ON D.F_XBKF_BASE1 = T5.FID | 
 |  |  |                         dt = oCn.RunProcReturn(sql, "sltz").Tables[0]; | 
 |  |  |                         if (dt.Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             foreach (DataRow dr in dt.Rows) | 
 |  |  |                             { | 
 |  |  |                                 if (fidList.Contains(dr["FID"].ToString() + dr["HINTERID"].ToString())) | 
 |  |  |                                     continue; | 
 |  |  |                                 else | 
 |  |  |                                     fidList.Add(dr["FID"].ToString() + dr["HINTERID"].ToString()); | 
 |  |  |  | 
 |  |  |                                 DataRow[] drs = dt.Select("FID = " + dr["FID"].ToString() + " and 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("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) | 
 |  |  |                                 { | 
 |  |  |                                     objjson.code = "0"; | 
 |  |  |                                     objjson.count = 0; | 
 |  |  |                                     objjson.Message = loginRet; | 
 |  |  |                                     objjson.data = null; | 
 |  |  |                                     return objjson; | 
 |  |  |                                 } | 
 |  |  |                                 //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(); | 
 |  |  |                                     string 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 | 
 |  |  |                                 { | 
 |  |  |                                     objjson.code = "0"; | 
 |  |  |                                     objjson.count = 0; | 
 |  |  |                                     objjson.Message = result; | 
 |  |  |                                     objjson.data = null; | 
 |  |  |                                     return objjson; | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     else if (FCusName == "夏宝电器") | 
 |  |  |                     { | 
 |  |  |                         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,D.F_XBKF_COMBO1,CR.FPRICE,CR.FTAXPRICE,CR.FTAXRATE,D.FPURCHASERID,isnull(T4.FNUMBER,'') AS FPURCHASERNUMBER,D.F_XBKF_BASE1,isnull(T5.FNUMBER,'') AS FRECEIVEMENNUMBER | 
 |  |  | 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_HR_EMPINFO T5 ON D.F_XBKF_BASE1 = T5.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); | 
 |  |  |                         dt = oCn.RunProcReturn(sql, "sltz").Tables[0]; | 
 |  |  |                         if (dt.Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             foreach (DataRow dr in dt.Rows) | 
 |  |  |                             { | 
 |  |  |                                 if (fidList.Contains(dr["FID"].ToString() + dr["HINTERID"].ToString())) | 
 |  |  |                                     continue; | 
 |  |  |                                 else | 
 |  |  |                                     fidList.Add(dr["FID"].ToString() + dr["HINTERID"].ToString()); | 
 |  |  |  | 
 |  |  |                                 DataRow[] drs = dt.Select("FID = " + dr["FID"].ToString() + " and 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("F_xbkf_Base", new JObject() { ["Fnumber"] = dr["FRECEIVEMENNUMBER"].ToString() }); //收料员 | 
 |  |  |                                 model.Add("FOwnerTypeIdHead", "BD_Supplier");//  货主类型 | 
 |  |  |                                 model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() });//货主 供应商  | 
 |  |  |                                 model.Add("F_XBKF_COMBO", dr["F_xbkf_Combo1"].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("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) | 
 |  |  |                                 { | 
 |  |  |                                     objjson.code = "0"; | 
 |  |  |                                     objjson.count = 0; | 
 |  |  |                                     objjson.Message = loginRet; | 
 |  |  |                                     objjson.data = null; | 
 |  |  |                                     return objjson; | 
 |  |  |                                 } | 
 |  |  |                                 //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(); | 
 |  |  |                                     string 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 | 
 |  |  |                                 { | 
 |  |  |                                     objjson.code = "0"; | 
 |  |  |                                     objjson.count = 0; | 
 |  |  |                                     objjson.Message = result; | 
 |  |  |                                     objjson.data = null; | 
 |  |  |                                     return objjson; | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 var check = Exec_ReciveBillCheck(HBillNo); | 
 |  |  |                 if (check.code == "0") | 
 |  |  |                     return check; | 
 |  |  |                 //if(check) | 
 |  |  |                 //更新主表状态 审核 | 
 |  |  |                 sql = string.Format(@"update Cg_POInStockBillMain set  | 
 |  |  | HBillStatus = 2 , | 
 |  |  | HChecker   ='{0}', | 
 |  |  | HCheckDate   = getdate() | 
 |  |  | where HInterID in ({1})", CurUserName, HInterID); | 
 |  |  |                 oCn.RunProc(sql); | 
 |  |  |                 objjson.code = "1"; | 
 |  |  |                 objjson.count = 1; | 
 |  |  |                 objjson.Message = "操作成功"; | 
 |  |  |                 objjson.data = null; | 
 |  |  |                 return objjson; | 
 |  |  |             } | 
 |  |  |             catch (Exception ex) | 
 |  |  |             { | 
 |  |  |                 objjson.code = "0"; | 
 |  |  |                 objjson.count = 0; | 
 |  |  |                 objjson.Message = "操作失败" + ex.Message.ToString(); | 
 |  |  |                 objjson.data = null; | 
 |  |  |                 return objjson; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         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 = 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; | 
 |  |  |  | 
 |  |  |                 #region 金蝶审核后会重新同步单据到mes 故不需要更新mes的收料通知单  | 
 |  |  |                 /* | 
 |  |  |                 oCn.BeginTran(); | 
 |  |  |                 string sql = string.Empty; | 
 |  |  |  | 
 |  |  |                 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.RunProc("exec h_p_Cg_UpDatePOOrderRelation_Del " + hinterID);//删除关联关系 | 
 |  |  |                 sql = string.Format(@"update Cg_POInStockBillMain set  | 
 |  |  | HBillStatus = 2 , | 
 |  |  | HCheckDate   = getdate() | 
 |  |  | where HInterID in ({0})", HInterID); | 
 |  |  |                 oCn.RunProc(sql);//更新mes状态   | 
 |  |  |                 //更新成功后 同步更新金蝶 | 
 |  |  |                 oCn.Commit(); | 
 |  |  |                 **/ | 
 |  |  |                 #endregion  | 
 |  |  |  | 
 |  |  |                 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("收料通知单修改失败jsonRoot:" + jsonRoot.ToString()); | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "金蝶收料通知单更新失败" + result; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 var json = new | 
 |  |  |                 { | 
 |  |  |                     Ids = FID, | 
 |  |  |                 }; | 
 |  |  |                 //提交 | 
 |  |  |                 var _result = InvokeHelper.Submit("PUR_ReceiveBill", JsonConvert.SerializeObject(json)); | 
 |  |  |                 var _saveObj = JObject.Parse(_result); | 
 |  |  |                 if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") | 
 |  |  |                 { | 
 |  |  |                     LogService.Write("收料通知单提交失败jsonRoot:" + jsonRoot.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("收料通知单审核失败jsonRoot:" + jsonRoot.ToString()); | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "金蝶收料通知单审核失败jsonRoot" + _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 sql = $"select* 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; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 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 | 
 |  |  |     } | 
 |  |  | } |