zrg
2025-11-05 4c7cb8434be52f1de8557c069ebf82dfbfd8d6ee
WebAPI/Controllers/XSGL/Kf_SellOutBillController.cs
@@ -1257,7 +1257,7 @@
            {
                List<object> columnNameListSum = new List<object>();
                List<object> columnNameList0 = new List<object>();
                //List<object> columnNameList1 = new List<object>();
                List<object> columnNameList1 = new List<object>();
                //List<object> columnNameList2 = new List<object>();
                //List<object> columnNameList3 = new List<object>();
                //List<object> columnNameList4 = new List<object>();
@@ -1273,13 +1273,13 @@
                    columnNameList0.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                ////添加 生产订单 列名
                //foreach (DataColumn col in ds.Tables[1].Columns)
                //{
                //    Type dataType = col.DataType;
                //    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                //    columnNameList1.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                //}
                //添加 生产订单 列名
                foreach (DataColumn col in ds.Tables[1].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList1.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                ////添加 特批申请单 列名
                //foreach (DataColumn col in ds.Tables[2].Columns)
@@ -1306,7 +1306,7 @@
                //}
                columnNameListSum.Add(columnNameList0);
                //columnNameListSum.Add(columnNameList1);
                columnNameListSum.Add(columnNameList1);
                //columnNameListSum.Add(columnNameList2);
                //columnNameListSum.Add(columnNameList3);
                //columnNameListSum.Add(columnNameList4);
@@ -1971,7 +1971,7 @@
                }
                string sql = "select * from h_v_Kf_SellOutBillQuerySub where hmainid =  " + hmainid;
                ds = oCN.RunProcReturn(sql + " order by hsubid desc", "h_v_Kf_SellOutBillQuerySub");
                ds = oCN.RunProcReturn(sql + " order by hsubid ASC", "h_v_Kf_SellOutBillQuerySub");
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -1999,5 +1999,519 @@
        }
        #endregion
        #region 销售出库单 判断是否具备查看金额权限
        [Route("Kf_SellOutBill/CheckRight_Money")]
        [HttpGet]
        public object CheckRight_Money(string user)
        {
            try
            {
                //判断查询权限
                if (!DBUtility.ClsPub.Security_Log("Kf_SellOutBill_Money", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查询!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 销售出库单 价格查询
        [Route("Kf_SellOutBill/GetKf_CheckSellOutBill_BalanceQuery")]
        [HttpGet]
        public object GetKf_CheckSellOutBill_BalanceQuery(string HInterID, string user)
        {
            try
            {
                //判断查询权限
                if (!DBUtility.ClsPub.Security_Log("Kf_SellOutBill_Money", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查询!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DataSet ds2 = oCN.RunProcReturn("exec h_p_Kf_CheckSellOutBill_CrediControl " + HInterID, "h_p_Kf_CheckSellOutBill_BalanceQuery");
                if (ds2 == null)
                {
                    throw new Exception("无返回值!");
                }else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.data = ds2.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 样品销售出库 审核/反审核
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Kf_SellOutBill/AuditKf_SellOutBill_YP")]
        [HttpGet]
        public object AuditKf_SellOutBill_YP(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Kf_SellOutBill_Check_YP";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //审核权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "审核失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsKf_SellOutBill oBill = new DAL.ClsKf_SellOutBill();                              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HCloseMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已关闭!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //审核判断
                    {
                        if (oBill.omodel.HChecker.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不能再次审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反审核判断
                    {
                        if (oBill.omodel.HChecker.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未审核!不需要反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行 会计期间 结账 的判断和控制
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                //进行需要进行的审核/反审核操作
                if (IsAudit == 0) //审核提交
                {
                    ds = oCN.RunProcReturn("exec h_p_Kf_CheckSellOutBill_CrediControl " + oBill.omodel.HInterID, "h_p_Kf_CheckSellOutBill_CrediControl");
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核前控制=========================================
                    string sql1 = "exec h_p_Kf_SellOutBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Kf_SellOutBill_BeforeCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //==================================================================================
                    //审核提交
                    oCN.BeginTran();
                    //增加关联
                    oCN.RunProc("exec h_p_Kf_SellOutBill_Check " + HInterID + ",'" + oBill.BillType + "','" + CurUserName + "'");
                    //审核更新 及时库存表 减少库存
                    ds = oCN.RunProcReturn("exec h_KF_UPDateICinventory  '" + HInterID + "','" + oBill.BillType + "','1'", "h_KF_UPDateICinventory");
                    //=========================审核反审核后负库存控制
                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_KF_ICinventoryStockCtrl '" + HInterID + "', '" + oBill.BillType + "'", "h_p_KF_ICinventoryStockCtrl");
                    if (ds2 == null)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + "库存更新后控制判断失败";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        oCN.RollBack();
                        string sReturn = "库存更新失败!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + sReturn;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //============================
                    //写入日志
                    string WorkList = "审核单据,单据号:" + oBill.omodel.HBillNo;
                    string SystemName = "LMES-销售出库单模块";
                    oCN.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
                        "(getdate(),'" + CurUserName + "','" + SystemInformation.ComputerName + "','" + WorkList + "','" + SystemName + "','','审核')"
                        );
                    //审核后控制=========================================
                    string sql = "exec h_p_Kf_SellOutBill_AfterCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Kf_SellOutBill_AfterCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:审核过程中出错,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================
                    oCN.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核成功";
                    objJsonResult.data = null;
                    return objJsonResult;
                    //if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_SellOutBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    //{
                    //    objJsonResult.code = "1";
                    //    objJsonResult.count = 1;
                    //    objJsonResult.Message = "审核成功";
                    //    objJsonResult.data = null;
                    //    return objJsonResult;
                    //}
                    //else
                    //{
                    //    objJsonResult.code = "0";
                    //    objJsonResult.count = 0;
                    //    objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    //    objJsonResult.data = null;
                    //    return objJsonResult;
                    //}
                }
                if (IsAudit == 1) //反审核提交
                {
                    //反审核前控制=========================================
                    string sql1 = "exec h_p_Kf_SellOutBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Kf_SellOutBill_BeforeUnCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //===========================================================
                    //反审核提交AbandonCheck
                    //删除关联
                    oCN.BeginTran();
                    oCN.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellOut_UnCheck " + HInterID + ",'" + CurUserName + "'");
                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_SellOutBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        oCN.Commit();
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 销售出库 根据销售订单主id查询条码明细
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <returns></returns>
        [Route("Kf_SellOutBill/GetBarCode_Detail")]
        [HttpGet]
        public object GetBarCode_Detail(string HInterID)
        {
            try
            {
                List<object> columnNameListSum = new List<object>();
                List<object> columnNameList0 = new List<object>();
                List<object> columnNameList1 = new List<object>();
                string sql = "exec h_p_Kf_SellOutBillBarCodeNote_Detail  '" + HInterID+"'";
                ds = oCN.RunProcReturn(sql, "h_p_Kf_SellOutBillBarCodeNote_Detail");
                //添加 汇总信息 列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList0.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                //添加 条码明细 列名
                foreach (DataColumn col in ds.Tables[1].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList1.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                columnNameListSum.Add(columnNameList0);
                columnNameListSum.Add(columnNameList1);
                List<DataTable> tableList = new List<DataTable>();
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                objJsonResult.list = columnNameListSum;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region [销售出库单同步插件]
        [Route("Kf_SellOutBill/SaveKf_SellOutBillApi")]
        [HttpPost]
        public object SaveKf_SellOutBillApi([FromBody] JObject sMainSub)
        {
            try
            {
                LogService.Write("销售出库单同步:" + sMainSub.ToString());
                var model = sMainSub["model"].ToString();
                var entry = sMainSub["model"]["HENTRY"].ToString();
                model = "[" + model.ToString() + "]";
                List<Model.ClsKf_SellOutBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsKf_SellOutBillMain>>(model);
                List< Model.ClsKf_SellOutBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List< Model.ClsKf_SellOutBillSub>> (entry);
                string sql = string.Empty;
                oCN.BeginTran();
                // 判断 数据库中是否存在id和单据号相等的打单据,存在,则重建,只有id号相等,则申请新的id号
                var ds1 = oCN.RunProcReturn($@"select HInterID,HBillNO from Kf_ICStockBillMain where HInterID= {mainList[0].HInterID}", "Kf_ICStockBillMain");
                var HInterID_Old = mainList[0].HInterID;
                if (ds1.Tables[0].Rows.Count > 0 && ds1.Tables[0].Rows[0]["HInterID"] != null)
                {
                    if (string.Equals(ds1.Tables[0].Rows[0]["HBillNo"].ToString(), mainList[0].HBillNo, StringComparison.OrdinalIgnoreCase))
                    {
                        sql = $"delete Kf_ICStockBillMain where HinterID = {mainList[0].HInterID}";
                        oCN.RunProc(sql);
                        sql = $"delete Kf_ICStockBillSub where HinterID = {mainList[0].HInterID}";
                        oCN.RunProc(sql);
                    }
                    else
                    {
                        // 重新申请HInterID
                        var HInterID_Exch = DBUtility.ClsPub.CreateBillID("1205", ref DBUtility.ClsPub.sExeReturnInfo);
                        mainList[0].HInterID = HInterID_Exch;
                        foreach (var oSub in subList)
                        {
                            oSub.HInterID = HInterID_Exch;
                        }
                    }
                }
                //主表
                sql = @"insert into Kf_ICStockBillMain
              (HInterID, HYear, HPeriod, HBillNo, HBillType, HBillSubType, HMainSourceBillType, HDate,
               HSupID, HWHID, HSCWHID, HEmpID, HManagerID, HSecManagerID, HKeeperID, HDeptID,
               HCurID, HSeOrderBillNo, HExplanation, HRemark, HInnerBillNo, HRedBlueFlag, HBillStatus, HMaker,
               HMakeDate, HChecker, HCheckDate, HUpDater, HUpDateDate, HDeleteMan, HDeleteDate, HOWNERID,
               HOWNERTYPEID, HERPInterID, HERPBillType, HERPBillNo, HPRDORGID, HSTOCKORGID)
               values(" + mainList[0].HInterID + ", " + mainList[0].HYear + ", " + mainList[0].HPeriod + ", '" + mainList[0].HBillNo + "', '" + mainList[0].HBillType + "', '" + mainList[0].HBillSubType + "', '" + mainList[0].HMainSourceBillType + "', '" + mainList[0].HDate + "'" +
               "," + mainList[0].HSupID + ", " + mainList[0].HWHID + ", " + mainList[0].HSCWHID + ", " + mainList[0].HEmpID + ", " + mainList[0].HManagerID + ", " + mainList[0].HSecManagerID + ", " + mainList[0].HKeeperID + ", " + mainList[0].HDeptID + "" +
               "," + mainList[0].HCurID + ", '" + mainList[0].HSeOrderBillNo + "', '" + mainList[0].HExplanation + "', '" + mainList[0].HRemark + "', '" + mainList[0].HInnerBillNo + "', '" + mainList[0].HRedBlueFlag + "', " + mainList[0].HBillStatus + ", '" + mainList[0].HMaker + "'" +
               ",'" + mainList[0].HMakeDate + "', '" + mainList[0].HChecker + "', '" + mainList[0].HCheckDate + "', '" + mainList[0].HUpDater + "', '" + mainList[0].HUpDateDate + "', '" + mainList[0].HDeleteMan + "', '" + mainList[0].HDeleteDate + "', " + mainList[0].HOWNERID + "" +
               ",'" + mainList[0].HOWNERTYPEID + "', " + mainList[0].HERPInterID + ", '" + mainList[0].HERPBillType + "', '" + mainList[0].HERPBillNo + "', " + mainList[0].HPRDORGID + ", " + mainList[0].HSTOCKORGID + ")";
                LogService.Write("销售出库单主表同步:" + sql);
                oCN.RunProc(sql);
                //保存子表
                foreach (var oSub in subList)
                {
                    sql = $@"insert into Kf_ICStockBillSub
                  (HInterID, HEntryID, HMTONo, HPlanMode, HRemark, HExpressNumber, HMaterID, HUnitID,
                   HBatchNo, HPropertyID, HWHID, HSPID, HSCWHID, HSCSPID, HQtyMust, HQty,
                   HPrice, HMoney, HTaxPrice, HTaxRate, HTaxMoney, HRelationQty, HRelationMoney, HSourceInterID,
                   HSourceEntryID, HSourceBillNo, HSourceBillType, HERPInterID, HERPEntryID, HERPBillNo_Sub, HPOOrderInterID, HPOOrderEntryID,
                   HPOOrderBillNo, HSeOrderInterID, HSeOrderEntryID, HSeOrderBillNo, HICMOInterID, HICMOEntryID,
                   HICMOBillNo, HWWOrderInterID, HWWOrderEntryID, HWWOrderBillNo, HProduceDate, HExpiryDate, HOWNERID, HOWNERTYPEID,
                   HKEEPERID, HKEEPERTYPEID)
                    values('{mainList[0].HInterID }', '{oSub.HEntryID}', '{oSub.HMTONo}', '{oSub.HPlanMode}', '{oSub.HRemark}', '{oSub.HExpressNumber}', '{oSub.HMaterID}', '{oSub.HUnitID}',
                           '{oSub.HBatchNo}', '{oSub.HPropertyID}', '{oSub.HWHID}', '{oSub.HSPID}', '{oSub.HSCWHID}', '{oSub.HSCSPID}', '{oSub.HQtyMust}', '{oSub.HQty}',
                           '{oSub.HPrice}', '{oSub.HMoney}', '{oSub.HTaxPrice}', '{oSub.HTaxRate}', '{oSub.HTaxMoney}', '{oSub.HRelationQty}', '{oSub.HRelationMoney}', '{oSub.HSourceInterID}',
                           '{oSub.HSourceEntryID}', '{oSub.HSourceBillNo}', '{oSub.HSourceBillType}', '{oSub.HERPInterID}', '{oSub.HERPEntryID}', '{oSub.HERPBillNo_Sub}', '{oSub.HPOOrderInterID}', '{oSub.HPOOrderEntryID}',
                           '{oSub.HPOOrderBillNo}', '{oSub.HSeOrderInterID}', '{oSub.HSeOrderEntryID}', '{oSub.HSeOrderBillNo}', '{oSub.HICMOInterID}', '{oSub.HICMOEntryID}',
                           '{oSub.HICMOBillNo}', '{oSub.HWWOrderInterID}', '{oSub.HWWOrderEntryID}', '{oSub.HWWOrderBillNo}', '{oSub.HProduceDate}', '{oSub.HExpiryDate}', '{oSub.HOWNERID}', '{oSub.HOWNERTYPEID}',
                           '{oSub.HKEEPERID}', '{oSub.HKEEPERTYPEID}')";
                    LogService.Write("销售出库单子表同步:" + sql);
                    oCN.RunProc(sql);
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "单据保存成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                LogService.Write("销售出库单同步异常,保存方法执行完成异常:" + e.Message.ToString());
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}