新增采购退料(源单:采购入库单)、生产退料(源单:生产领料单)上传生成CLOUD单据方法
1个文件已修改
1028 ■■■■■ 已修改文件
CLOUDWEB/WebService1.asmx.cs 1028 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CLOUDWEB/WebService1.asmx.cs
@@ -21193,21 +21193,20 @@
                    return false;
                }
            }
            //else if (sHSourceType == "1204")   //生产领料单
            //{
            //    if (SaveMateOutBackBill_MateOut_CLD(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
            //    {
            //        //"保存成功!";
            //        sErrMsg = "保存成功!" + oMain.HBillNo;
            //        return true;
            //    }
            //    else
            //    {
            //        //"保存失败!";
            //        sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";" + sErrMsg;
            //        return false;
            //    }
            //}
            else if (sHSourceType == "1204")   //生产领料单
            {
                if (SaveMateOutBackBill_MateOut_CLD(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
                {
                    //"保存成功!";
                    return true;
                }
                else
                {
                    //"保存失败!";
                    sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";" + sErrMsg;
                    return false;
                }
            }
            else
            {
                sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";错误的源单类型";
@@ -21669,6 +21668,429 @@
            }
        }
        /// <summary>
        /// 生产退料单   (源单:生产领料单)
        /// </summary>
        /// <param name="oMain"></param>
        /// <param name="sErrMsg"></param>
        /// <returns></returns>
        public bool SaveMateOutBackBill_MateOut_CLD(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            string sRemark = "";
            //从配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
            if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
            {
                sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
                return false;
            }
            //获取CLOUD账号密码
            string sCLOUDUseName = Pub_Class.ClsPub.sCLOUDUseName;
            string sCLOUDPsd = Pub_Class.ClsPub.sCLOUDPsd;
            //从用户表获取用户绑定金蝶账号
            DataSet ds11 = oCn.RunProcReturn("exec h_p_API_GetCloudUserByLoginUser '" + oMain.HMaker + "'", "h_p_API_GetCloudUserByLoginUser");
            if (ds11 == null || ds11.Tables[0].Rows.Count == 0)
            {
            }
            else
            {
                sCLOUDUseName = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserName"]);
                sCLOUDPsd = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserPsd"]);
            }
            string HReturn;
            ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
            string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
            bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052);
            sRemark = sRemark + " ;获取验证CLOUD账号密码" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
            try
            {
                //判断会计期是否合理
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                if (oSystemParameterMain.Kf_MateOutBackBill_BillDateMode.ToUpper() == "N") //系统参数  单据日期是否取界面递入日期
                {
                    oMain.HDate = DateTime.Today;
                }
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oMain.HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    sErrMsg = s;
                    return false;
                }
                oMain.HYear = sYear;
                oMain.HPeriod = sPeriod;
                oCn.BeginTran();
                //生成出入库单据
                //插入子表
                oCn.RunProc("EXEC h_p_Kf_MateOutBackBillSub_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + sHSourceType + "'");
                //插入主表
                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
                ",HSTOCKORGID,HOWNERID" +
                ") " +
                " values('1244','1244'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HDate.ToShortDateString() + "','" + oMain.HMainSourceBillType + "'" +
                ", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "','" + oMain.HMaker + "',getdate()" +
                ", " + oMain.HSupID.ToString() + "," + oMain.HWHID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HEmpID.ToString() + "," + oMain.HManagerID.ToString() + "," + oMain.HSecManagerID.ToString() +
                ", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) +
                ", " + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() +
                ") ");
                //更新关联数量
                oCn.RunProc("exec h_p_Kf_UpDateRelation_MateOutToMateOutBack_Add " + oMain.HInterID.ToString());
                sRemark = sRemark + " ;生成出入库单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                //根据TMP表 返回 信息
                DataSet Ds;
                if (oSystemParameterMain.WMS_CloudMode.ToUpper() == "N") //系统参数  是否为私有云模式(N为公有云模式,Y为私有云模式)
                {
                    Ds = oCn.RunProcReturn("exec h_p_Kf_GetMateOutBackBill_MateOut_PUBCLD_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetMateOutBackBill_MateOut_PUBCLD_New");
                    sRemark = sRemark + " ;公有云模式";
                }
                else
                {
                    Ds = oCn.RunProcReturn("exec h_p_Kf_GetMateOutBackBill_MateOut_CLD_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetMateOutBackBill_MateOut_CLD_New");
                    sRemark = sRemark + " ;私有云模式";
                }
                if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
                {
                    sErrMsg = "获取子表信息失败!";
                    oCn.RollBack();
                    return false;
                }
                else
                {
                    string sJson_MainCustom = "";   //主表自定义字段
                    string sJson_Date = "";         //单据日期
                    sJson_MainCustom = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["MainCustom"]);
                    if (oSystemParameterMain.Kf_MateOutBackBill_BillDateMode.ToUpper() == "Y") //系统参数  单据日期是否取界面递入日期
                    {
                        sJson_Date = "\"FDATE\":\"" + oMain.HDate.ToShortDateString() + "\",";
                    }
                    else
                    {
                        sJson_Date = "\"FDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDATE"]) + "\",";
                    }
                    string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\", " +
                    "\"IsEntryBatchFill\":\"True\",\"ValidateFlag\":\"True\",\"NumberSearch\":\"True\",\"InterationFlags\":\"\"," +
                    "\"Model\": { \"FBILLNO\":\"" + oMain.HBillNo + "\"," +
                    //\"FID\":\"0\",
                    "\"FBillType\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillType"]) + "\"}," +
                    sJson_Date +
                    "\"FStockOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\"}," +
                    "\"FPrdOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPrdOrgId"]) + "\"}," +
                    "\"FOwnerTypeId0\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeId0"]) + "\"," +
                    //\"FOwnerId0\":{\"FNumber\":\"\"},
                    "\"FReturnerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FReturnerId"]) + "\"}," +
                    "\"FSTOCKERID\":{\"FNAME\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSTOCKERID"]) + "\"}," +
                    //\"FDescription\":\"\",
                    "\"FCurrId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCurrId"]) + "\"}," +
                    "\"FIsCrossTrade\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsCrossTrade"]) + "\"," +
                    "\"FVmiBusiness\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FVmiBusiness"]) + "\"," +
                    "\"FIsOwnerTInclOrg\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsOwnerTInclOrg"]) + "\"," +
                    //\"FScanBox\":\"\",
                    //\"FSourceType\":\"\",
                    sJson_MainCustom +
                    "\"FEntity\": [  ";
                    string sJson_Entry = "";
                    for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
                    {
                        if (sJson_Entry != "")
                        {
                            sJson_Entry = sJson_Entry + " , ";
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FAUXPROPID = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        string sJson_SubCustom = "";        //子表自定义字段
                        //子表自定义字段
                        sJson_SubCustom = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["SubCustom"]);
                        //是否启用批次管理
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HISBATCHMANAGE"]) == "1")
                        {
                            sJson_BatchNo = "  \"FLOT\": {\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"},    \"FLOT_TEXT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"  , ";
                        }
                        else
                        {
                            sJson_BatchNo = "";
                        }
                        //是否启用保质期控制
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISKFPERIOD"]) == "1")
                        {
                            sJson_FProduceDate = " \"FProduceDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + "\",";
                            sJson_FExpiryDate = " \"FExpiryDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "\",";
                        }
                        else
                        {
                            sJson_FProduceDate = "";
                            sJson_FExpiryDate = "";
                        }
                        //辅助属性
                        sJson_FAUXPROPID = " \"FAUXPROPID\":{\"FAUXPROPID__FF100002\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXPROPID"]) + "\"}},";
                        //仓位
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) == "")
                        {
                            sJson_StockPlace = "";
                        }
                        else
                        {
                            sJson_StockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) + "\"}},";
                        }
                        sJson_Entry = sJson_Entry + "{" +
                        //\"FEntryID\":\"0\",
                        "\"FMaterialId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMaterialId"]) + "\"}," +
                        "\"FUnitID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUnitID"]) + "\"}," +
                        "\"FAPPQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAPPQty"]) + "\"," +
                        "\"FQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQty"]) + "\"," +
                        "\"FReturnType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReturnType"]) + "\"," +
                        //\"FReturnReason\":{\"FNumber\":\"\"},
                        "\"FStockId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockId"]) + "\"}," +
                        sJson_StockPlace +
                        sJson_BatchNo +
                        //\"FEntrtyMemo\":\"\",
                        "\"FSrcBillType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBillType"]) + "\"," +
                        "\"FSrcBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBillNo"]) + "\"," +
                        "\"FEntrySrcEntrySeq\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrySrcEntrySeq"]) + "\"," +
                        "\"FPPBomBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPPBomBillNo"]) + "\"," +
                        "\"FProcessId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProcessId"]) + "\"}," +
                        "\"FParentMaterialId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FParentMaterialId"]) + "\"}," +
                        "\"FPPBOMEntryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPPBOMEntryId"]) + "\"," +
                        "\"FMoId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMoId"]) + "\"," +
                        //\"FConsome\":\"\",
                        "\"FReserveType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReserveType"]) + "\"," +
                        "\"FBASESTOCKQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASESTOCKQTY"]) + "\"," +
                        "\"FMoBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMoBillNo"]) + "\"," +
                        "\"FEntryVmiBusiness\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntryVmiBusiness"]) + "\"," +
                        "\"FOptQueue\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOptQueue"]) + "\"," +
                        "\"FOptPlanBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOptPlanBillNo"]) + "\"," +
                        "\"FOptPlanBillId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOptPlanBillId"]) + "\"," +
                        "\"FWorkCenterId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FWorkCenterId"]) + "\"}," +
                        "\"FOptDetailId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOptDetailId"]) + "\"," +
                        "\"FMoEntryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMoEntryId"]) + "\"," +
                        //\"FEquipmentId\":{\"FNUMBER\":\"\"},
                        "\"FMoEntrySeq\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMoEntrySeq"]) + "\"," +
                        sJson_FAUXPROPID +
                        "\"FStockUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockUnitId"]) + "\"}," +
                        "\"FStockAppQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockAppQty"]) + "\"," +
                        "\"FSecUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSecUnitId"]) + "\"}," +
                        //\"FSecStockQty\":\"0\",
                        "\"FStockQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockQty"]) + "\"," +
                        "\"FMtoNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMtoNo"]) + "\"," +
                        "\"FProjectNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProjectNo"]) + "\"," +
                        "\"FStockStatusId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockStatusId"]) + "\"}," +
                        "\"FKeeperTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeId"]) + "\"," +
                        "\"FKeeperId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperId"]) + "\"}," +
                        "\"FOperId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOperId"]) + "\"," +
                        "\"FBomId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBomId"]) + "\"}," +
                        //\"FSelRePickedQty\":\"0\",
                        "\"FBaseUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseUnitId"]) + "\"}," +
                        "\"FBaseAppQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseAppQty"]) + "\"," +
                        //\"FBaseSelRePickedQty\":\"0\",
                        "\"FBaseQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseQty"]) + "\"," +
                        "\"FOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeId"]) + "\"," +
                        "\"FOwnerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerId"]) + "\"}," +
                        "\"FEntrySrcEnteryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrySrcEnteryId"]) + "\"," +
                        "\"FEntrySrcInterId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrySrcInterId"]) + "\"," +
                        sJson_FProduceDate +
                        sJson_FExpiryDate +
                        "\"FWorkShopId1\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FWorkShopId1"]) + "\"}," +
                        "\"FParentOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FParentOwnerTypeId"]) + "\"," +
                        "\"FParentOwnerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FParentOwnerId"]) + "\"}," +
                        "\"FSrcBizBillType\":{\"FNAME\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBizBillType"]) + "\"}," +
                        "\"FSrcBizBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBizBillNo"]) + "\"," +
                        "\"FSrcBizInterId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBizInterId"]) + "\"," +
                        "\"FSrcBizEntryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBizEntryId"]) + "\"," +
                        "\"FSrcBizEntrySeq\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBizEntrySeq"]) + "\"," +
                        //
                        "\"FSNUnitID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUnitID"]) + "\"}," +
                        "\"FReqSrc\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReqSrc"]) + "\"," +
                        "\"FReqBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReqBillNo"]) + "\"," +
                        "\"FReqBillId\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReqBillId"]) + "," +
                        "\"FReqEntrySeq\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReqEntrySeq"]) + "," +
                        "\"FReqEntryId\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReqEntryId"]) + "," +
                        "\"FisFX\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FisFX"]) + "\"," +
                        "\"FIsUpdateQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsUpdateQty"]) + "\"," +
                         sJson_SubCustom +
                        //\"FSerialSubEntity\":[{\"FDetailID\":\"0\",
                        //\"FSerialNo\":\"\",
                        //\"FSerialId\":{\"FNumber\":\"\"},
                        //\"FSerialNote\":\"\"}]
                        "\"FEntity_Link\": [ {  " +
                        "\"FEntity_Link_FFlowId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FFlowId"]) + "\"," +
                        "\"FEntity_Link_FFlowLineId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FFlowLineId"]) + "\"," +
                        "\"FEntity_Link_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FRuleId"]) + "\"," +
                        "\"FEntity_Link_FSTableName\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSTableName"]) + "\"," +
                        "\"FEntity_Link_FSBillId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSBillId"]) + "\"," +
                        "\"FEntity_Link_FBASEQTYOLD\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FBASEQTYOLD"]) + "\"," +
                        "\"FEntity_Link_FSId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSId"]) + "\"" +
                        " } ]," +
                        " \"FBFLowId\":{\"FID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBFLowId"]) + "\"}}";
                    }
                    string sJson_End = "  ]  }}";
                    string sJson = sJson_Main + sJson_Entry + sJson_End;
                    sRemark = sRemark + " ;获取CLOUD单据API递入值" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                    //生成金蝶云单据
                    if (bLogin)
                    {
                        var result = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
                        new object[] { "PRD_ReturnMtrl", sJson });
                        sRemark = sRemark + " ;生成CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                        //生成单据后更新自定义字段
                        oCn.RunProc("exec h_p_Sc_UpDateSelfFildMateOutBack '" + oMain.HBillNo + "','" + sHSourceType + "'");
                        sRemark = sRemark + " ;生成单据后回填字段信息" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                        HReturn = result.ToString();
                        if (HReturn.Contains("\"IsSuccess\":false") == true)
                        {
                            //反序列化json数据
                            var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(HReturn);
                            //接收金蝶报错信息
                            var strErrorMsg = string.Empty;
                            //遍历获取报错信息
                            foreach (var item in retModel.Result.ResponseStatus.Errors)
                            {
                                strErrorMsg += item.Message + "\r\n";
                            };
                            sErrMsg = "生成生产退料单失败!金蝶云提示:" + strErrorMsg;
                            LogService.Write("生成生产退料单(源单:生产领料单)失败!" + HReturn + sJson);   //写入txt文本
                            oCn.RollBack();
                            return false;
                        }
                        else
                        {
                            sRemark = sRemark + sJson;
                            oCn.Commit();
                        }
                    }
                    else
                    {
                        sErrMsg = "生成生产退料单失败!金蝶云登录失败!";
                        oCn.RollBack();
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                LogService.Write("生成回滚" + e.Message + sRemark);
                sErrMsg = "生成生产退料单失败!" + e.Message;
                oCn.RollBack();
                return false;
            }
            if (oSystemParameterMain.Kf_MateOutBackBill_AutoCheck.ToUpper() == "Y") //系统参数  自动审核
            {
                //审核WMS单据
                oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=getdate(),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
                //提交、审核金蝶云单据
                HReturn = "";
                string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
                new object[] { "PRD_ReturnMtrl", sJson2 });
                sRemark = sRemark + " ;提交CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
                new object[] { "PRD_ReturnMtrl", sJson3 });
                sRemark = sRemark + " ;审核CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                HReturn = result2.ToString() + "," + result3.ToString();
                if (HReturn.Contains("\"IsSuccess\":false") == true)
                {
                    //反序列化json数据
                    var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(result3);
                    //接收金蝶报错信息
                    var strErrorMsg = string.Empty;
                    //遍历获取报错信息
                    foreach (var item in retModel.Result.ResponseStatus.Errors)
                    {
                        strErrorMsg += item.Message + "\r\n";
                    };
                    sErrMsg = "生成生产退料单成功,审核单据失败!金蝶云提示:" + strErrorMsg;
                    LogService.Write("审核单据失败" + sRemark + HReturn);
                    return true;
                }
                else
                {
                    LogService.Write("生成并审核生产退料单(源单:生产领料单)成功!" + sRemark);
                    sErrMsg = "生成并审核生产退料单成功!单据号为:" + oMain.HBillNo;
                    return true;
                }
            }
            else if (oSystemParameterMain.Kf_MateOutBackBill_AutoSubmit.ToUpper() == "Y") //系统参数  自动提交
            {
                //提交金蝶云单据
                HReturn = "";
                string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
                new object[] { "PRD_ReturnMtrl", sJson2 });
                sRemark = sRemark + " ;提交CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                HReturn = result2.ToString();
                if (HReturn.Contains("\"IsSuccess\":false") == true)
                {
                    //反序列化json数据
                    var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(HReturn);
                    //接收金蝶报错信息
                    var strErrorMsg = string.Empty;
                    //遍历获取报错信息
                    foreach (var item in retModel.Result.ResponseStatus.Errors)
                    {
                        strErrorMsg += item.Message + "\r\n";
                    };
                    sErrMsg = "生成生产退料单成功,提交单据失败!金蝶云提示:" + strErrorMsg;
                    LogService.Write("提交单据失败" + sRemark + HReturn);
                    return true;
                }
                else
                {
                    LogService.Write("生成并提交生产退料单(源单:生产领料单)成功!" + sRemark);
                    sErrMsg = "生成并提交生产退料单成功!单据号为:" + oMain.HBillNo;
                    return true;
                }
            }
            else
            {
                LogService.Write("生成生产退料单(源单:生产领料单)成功!" + sRemark);
                sErrMsg = "生成生产退料单成功!单据号为:" + oMain.HBillNo;
                return true;
            }
        }
        #endregion
@@ -31048,9 +31470,9 @@
        #endregion
        #region 外购退料        外购入库(红字)   *
        #region 采购退料        采购入库(红字)   *
        //生成外购退料单
        //生成采购退料单
        [WebMethod]
        public bool set_SavePOStockInBackBill_New(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, ref string sErrMsg)
        {
@@ -31123,7 +31545,7 @@
                }
            }
            sErrMsg = "保存外购退料单失败!" + sErrMsg;
            sErrMsg = "保存采购退料单失败!" + sErrMsg;
            return false;
        }
@@ -31321,9 +31743,9 @@
        #endregion
        #region 外购退料CLOUD   外购入库(红字)   *New
        #region 采购退料CLOUD   采购入库(红字)   *New
        //生成外购退料单
        //生成采购退料单
        [WebMethod]
        public bool set_SavePOStockInBackBill_CLD_New(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
@@ -31355,6 +31777,20 @@
                    return false;
                }
            }
            else if (sHSourceType == "1201")   //采购入库单
            {
                if (SavePOStockInBackBill_POStockIn_CLD_New(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
                {
                    //"保存成功!";
                    return true;
                }
                else
                {
                    //"保存失败!";
                    sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";" + sErrMsg;
                    return false;
                }
            }
            else
            {
                sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";错误的源单类型";
@@ -31363,7 +31799,7 @@
        }
        /// <summary>
        /// 外购退料单   (源单:采购订单)
        /// 采购退料单   (源单:采购订单)
        /// </summary>
        /// <param name="oMain"></param>
        /// <param name="sErrMsg"></param>
@@ -31719,8 +32155,8 @@
                            {
                                strErrorMsg += item.Message + "\r\n";
                            };
                            sErrMsg = "生成外购退料单失败!金蝶云提示:" + strErrorMsg;
                            LogService.Write("生成外购退料单(源单:采购订单)失败!" + HReturn + sJson);   //写入txt文本
                            sErrMsg = "生成采购退料单失败!金蝶云提示:" + strErrorMsg;
                            LogService.Write("生成采购退料单(源单:采购订单)失败!" + HReturn + sJson);   //写入txt文本
                            oCn.RollBack();
                            return false;
                        }
@@ -31732,7 +32168,7 @@
                    }
                    else
                    {
                        sErrMsg = "生成外购退料单失败!金蝶云登录失败!";
                        sErrMsg = "生成采购退料单失败!金蝶云登录失败!";
                        oCn.RollBack();
                        return false;
                    }
@@ -31741,7 +32177,7 @@
            catch (Exception e)
            {
                LogService.Write("生成回滚" + e.Message + sRemark);
                sErrMsg = "生成外购退料单失败!" + e.Message;
                sErrMsg = "生成采购退料单失败!" + e.Message;
                oCn.RollBack();
                return false;
            }
@@ -31781,15 +32217,15 @@
                        {
                            strErrorMsg += item.Message + "\r\n";
                        };
                        sErrMsg = "生成外购退料单成功,审核单据失败!金蝶云提示:" + strErrorMsg;
                        sErrMsg = "生成采购退料单成功,审核单据失败!金蝶云提示:" + strErrorMsg;
                        LogService.Write("审核单据失败" + sRemark + HReturn);
                        oCn.RollBack();
                        return true;
                    }
                    else
                    {
                        LogService.Write("生成并审核外购退料单(源单:采购订单)成功!" + sRemark);
                        sErrMsg = "生成并审核外购退料单成功!单据号为:" + oMain.HBillNo;
                        LogService.Write("生成并审核采购退料单(源单:采购订单)成功!" + sRemark);
                        sErrMsg = "生成并审核采购退料单成功!单据号为:" + oMain.HBillNo;
                        oCn.Commit();
                        return true;
                    }
@@ -31797,7 +32233,7 @@
                catch (Exception e)
                {
                    LogService.Write("审核回滚" + sRemark + HReturn);
                    sErrMsg = "审核外购退料单失败!" + e.Message;
                    sErrMsg = "审核采购退料单失败!" + e.Message;
                    oCn.RollBack();
                    return false;
                }
@@ -31828,15 +32264,15 @@
                        {
                            strErrorMsg += item.Message + "\r\n";
                        };
                        sErrMsg = "生成外购退料单成功,提交单据失败!金蝶云提示:" + strErrorMsg;
                        sErrMsg = "生成采购退料单成功,提交单据失败!金蝶云提示:" + strErrorMsg;
                        LogService.Write("提交单据失败" + sRemark + HReturn);
                        oCn.RollBack();
                        return true;
                    }
                    else
                    {
                        LogService.Write("生成并提交外购退料单(源单:采购订单)成功!" + sRemark);
                        sErrMsg = "生成并提交外购退料单成功!单据号为:" + oMain.HBillNo;
                        LogService.Write("生成并提交采购退料单(源单:采购订单)成功!" + sRemark);
                        sErrMsg = "生成并提交采购退料单成功!单据号为:" + oMain.HBillNo;
                        oCn.Commit();
                        return true;
                    }
@@ -31844,22 +32280,22 @@
                catch (Exception e)
                {
                    LogService.Write("提交回滚" + sRemark + HReturn);
                    sErrMsg = "提交外购退料单失败!" + e.Message;
                    sErrMsg = "提交采购退料单失败!" + e.Message;
                    oCn.RollBack();
                    return false;
                }
            }
            else
            {
                LogService.Write("生成外购退料单(源单:采购订单)成功!" + sRemark);
                sErrMsg = "生成外购退料单成功!单据号为:" + oMain.HBillNo;
                LogService.Write("生成采购退料单(源单:采购订单)成功!" + sRemark);
                sErrMsg = "生成采购退料单成功!单据号为:" + oMain.HBillNo;
                return true;
            }
        }
        /// <summary>
        /// 外购退料单   (源单:退料通知单)
        /// 采购退料单   (源单:退料通知单)
        /// </summary>
        /// <param name="oMain"></param>
        /// <param name="sErrMsg"></param>
@@ -32203,8 +32639,8 @@
                            {
                                strErrorMsg += item.Message + "\r\n";
                            };
                            sErrMsg = "生成外购退料单失败!金蝶云提示:" + strErrorMsg;
                            LogService.Write("生成外购退料单(源单:退料通知单)失败!" + HReturn + sJson);   //写入txt文本
                            sErrMsg = "生成采购退料单失败!金蝶云提示:" + strErrorMsg;
                            LogService.Write("生成采购退料单(源单:退料通知单)失败!" + HReturn + sJson);   //写入txt文本
                            oCn.RollBack();
                            return false;
                        }
@@ -32216,7 +32652,7 @@
                    }
                    else
                    {
                        sErrMsg = "生成外购退料单失败!金蝶云登录失败!";
                        sErrMsg = "生成采购退料单失败!金蝶云登录失败!";
                        oCn.RollBack();
                        return false;
                    }
@@ -32225,7 +32661,7 @@
            catch (Exception e)
            {
                LogService.Write("生成回滚" + e.Message + sRemark);
                sErrMsg = "生成外购退料单失败!" + e.Message;
                sErrMsg = "生成采购退料单失败!" + e.Message;
                oCn.RollBack();
                return false;
            }
@@ -32265,15 +32701,15 @@
                        {
                            strErrorMsg += item.Message + "\r\n";
                        };
                        sErrMsg = "生成外购退料单成功,审核单据失败!金蝶云提示:" + strErrorMsg;
                        sErrMsg = "生成采购退料单成功,审核单据失败!金蝶云提示:" + strErrorMsg;
                        LogService.Write("审核单据失败" + sRemark + HReturn);
                        oCn.RollBack();
                        return true;
                    }
                    else
                    {
                        LogService.Write("生成并审核外购退料单(源单:退料通知单)成功!" + sRemark);
                        sErrMsg = "生成并审核外购退料单成功!单据号为:" + oMain.HBillNo;
                        LogService.Write("生成并审核采购退料单(源单:退料通知单)成功!" + sRemark);
                        sErrMsg = "生成并审核采购退料单成功!单据号为:" + oMain.HBillNo;
                        oCn.Commit();
                        return true;
                    }
@@ -32281,7 +32717,7 @@
                catch (Exception e)
                {
                    LogService.Write("审核回滚" + sRemark + HReturn);
                    sErrMsg = "审核外购退料单失败!" + e.Message;
                    sErrMsg = "审核采购退料单失败!" + e.Message;
                    oCn.RollBack();
                    return false;
                }
@@ -32312,15 +32748,15 @@
                        {
                            strErrorMsg += item.Message + "\r\n";
                        };
                        sErrMsg = "生成外购退料单成功,提交单据失败!金蝶云提示:" + strErrorMsg;
                        sErrMsg = "生成采购退料单成功,提交单据失败!金蝶云提示:" + strErrorMsg;
                        LogService.Write("提交单据失败" + sRemark + HReturn);
                        oCn.RollBack();
                        return true;
                    }
                    else
                    {
                        LogService.Write("生成并提交外购退料单(源单:退料通知单)成功!" + sRemark);
                        sErrMsg = "生成并提交外购退料单成功!单据号为:" + oMain.HBillNo;
                        LogService.Write("生成并提交采购退料单(源单:退料通知单)成功!" + sRemark);
                        sErrMsg = "生成并提交采购退料单成功!单据号为:" + oMain.HBillNo;
                        oCn.Commit();
                        return true;
                    }
@@ -32328,15 +32764,481 @@
                catch (Exception e)
                {
                    LogService.Write("提交回滚" + sRemark + HReturn);
                    sErrMsg = "提交外购退料单失败!" + e.Message;
                    sErrMsg = "提交采购退料单失败!" + e.Message;
                    oCn.RollBack();
                    return false;
                }
            }
            else
            {
                LogService.Write("生成外购退料单(源单:退料通知单)成功!" + sRemark);
                sErrMsg = "生成外购退料单成功!单据号为:" + oMain.HBillNo;
                LogService.Write("生成采购退料单(源单:退料通知单)成功!" + sRemark);
                sErrMsg = "生成采购退料单成功!单据号为:" + oMain.HBillNo;
                return true;
            }
        }
        /// <summary>
        /// 采购退料单   (源单:采购入库单)
        /// </summary>
        /// <param name="oMain"></param>
        /// <param name="sErrMsg"></param>
        /// <returns></returns>
        public bool SavePOStockInBackBill_POStockIn_CLD_New(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            string sRemark = "";
            //从配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
            if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
            {
                sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
                return false;
            }
            //获取CLOUD账号密码
            string sCLOUDUseName = Pub_Class.ClsPub.sCLOUDUseName;
            string sCLOUDPsd = Pub_Class.ClsPub.sCLOUDPsd;
            //从用户表获取用户绑定金蝶账号
            DataSet ds11 = oCn.RunProcReturn("exec h_p_API_GetCloudUserByLoginUser '" + oMain.HMaker + "'", "h_p_API_GetCloudUserByLoginUser");
            if (ds11 == null || ds11.Tables[0].Rows.Count == 0)
            {
            }
            else
            {
                sCLOUDUseName = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserName"]);
                sCLOUDPsd = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserPsd"]);
            }
            string HReturn;
            ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
            string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
            bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052);
            sRemark = sRemark + " ;获取验证CLOUD账号密码" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
            try
            {
                //判断会计期是否合理
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                if (oSystemParameterMain.Kf_POStockInBackBill_BillDateMode.ToUpper() == "N") //系统参数  单据日期是否取界面递入日期
                {
                    oMain.HDate = DateTime.Today;
                }
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oMain.HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    sErrMsg = s;
                    return false;
                }
                oMain.HYear = sYear;
                oMain.HPeriod = sPeriod;
                oCn.BeginTran();
                //生成出入库单据
                //插入子表
                oCn.RunProc("EXEC h_p_Kf_POStockInBackBillSub_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + sHSourceType + "'");
                //插入主表
                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
                ",HSTOCKORGID,HOWNERID" +
                ") " +
                " values('1239','1239'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HDate.ToShortDateString() + "','" + oMain.HMainSourceBillType + "'" +
                ", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "','" + oMain.HMaker + "',getdate()" +
                ", " + oMain.HSupID.ToString() + "," + oMain.HWHID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HEmpID.ToString() + "," + oMain.HManagerID.ToString() + "," + oMain.HSecManagerID.ToString() +
                ", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) +
                ", " + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() +
                ") ");
                //更新关联数量
                oCn.RunProc("exec h_p_Kf_UpDateRelation_POStockInToPOStockInBack_Add " + oMain.HInterID.ToString());
                sRemark = sRemark + " ;生成出入库单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                //根据TMP表 返回 信息
                DataSet Ds;
                if (oSystemParameterMain.WMS_CloudMode.ToUpper() == "N") //系统参数  是否为私有云模式(N为公有云模式,Y为私有云模式)
                {
                    Ds = oCn.RunProcReturn("exec h_p_Kf_GetPOStockInBackBill_POStockIn_PUBCLD_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetPOStockInBackBill_POStockIn_PUBCLD_New");
                    sRemark = sRemark + " ;公有云模式";
                }
                else
                {
                    Ds = oCn.RunProcReturn("exec h_p_Kf_GetPOStockInBackBill_POStockIn_CLD_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetPOStockInBackBill_POStockIn_CLD_New");
                    sRemark = sRemark + " ;私有云模式";
                }
                if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
                {
                    sErrMsg = "获取子表信息失败!";
                    oCn.RollBack();
                    return false;
                }
                else
                {
                    string sJson_MainCustom = "";   //主表自定义字段
                    string sJson_Date = "";         //单据日期
                    sJson_MainCustom = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["MainCustom"]);
                    if (oSystemParameterMain.Kf_POStockInBackBill_BillDateMode.ToUpper() == "Y") //系统参数  单据日期是否取界面递入日期
                    {
                        sJson_Date = "\"FDATE\":\"" + oMain.HDate.ToShortDateString() + "\",";
                    }
                    else
                    {
                        sJson_Date = "\"FDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDATE"]) + "\",";
                    }
                    string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\", " +
                    "\"IsEntryBatchFill\":\"True\",\"ValidateFlag\":\"True\",\"NumberSearch\":\"True\",\"InterationFlags\":\"\"," +
                    "\"Model\": { \"FBILLNO\":\"" + oMain.HBillNo + "\"," +
                    //\"FID\":\"0\",
                    "\"FBillTypeID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillTypeID"]) + "\"}," +
                    //\"FBillNo\":\"\",
                    sJson_Date +
                    "\"FMRTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FMRTYPE"]) + "\"," +
                    "\"FMRMODE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FMRMODE"]) + "\"," +
                    "\"FStockOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\"}," +
                    "\"FMRDeptId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FMRDeptId"]) + "\"}," +
                    "\"FSTOCKERGROUPID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSTOCKERGROUPID"]) + "\"}," +
                    "\"FCorrespondOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCorrespondOrgId"]) + "\"}," +
                    "\"FSTOCKERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSTOCKERID"]) + "\"}," +
                    //"\"FMRREASON\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FMRREASON"]) + "\"}," +
                    "\"FRequireOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FRequireOrgId"]) + "\"}," +
                    "\"FPurchaseOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPurchaseOrgId"]) + "\"}," +
                    "\"FPURCHASEDEPTID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPURCHASEDEPTID"]) + "\"}," +
                    "\"FPURCHASERGROUPID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPURCHASERGROUPID"]) + "\"}," +
                    "\"FPURCHASERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPURCHASERID"]) + "\"}," +
                    "\"FSupplierID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplierID"]) + "\"}," +
                    //\"FDESCRIPTION\":\"\",
                    "\"FACCEPTORID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FACCEPTORID"]) + "\"}," +
                    "\"FAcceptAddress\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FAcceptAddress"]) + "\"," +
                    "\"FSettleId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleId"]) + "\"}," +
                    "\"FCHARGEID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCHARGEID"]) + "\"}," +
                    "\"FOwnerTypeIdHead\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeIdHead"]) + "\"," +
                    "\"FOwnerIdHead\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerIdHead"]) + "\"}," +
                    //\"FScanPoint\":{\"FNUMBER\":\"\"},
                    //\"FConfirmerId\":{\"FUserID\":\"\"},
                    //\"FConfirmDate\":\"1900-01-01\",
                    //\"FScanBox\":\"\",
                    //\"FCDateOffsetUnit\":\"\",
                    //\"FCDateOffsetValue\":\"0\",
                    "\"FAcceptorContactID\":{\"FCONTACTNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FAcceptorContactID"]) + "\"}," +
                    //
                    "\"FREPLENISHMODE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FREPLENISHMODE"]) + "\"," +
                    "\"FBusinessType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBusinessType"]) + "\"," +
                    sJson_MainCustom +
                    "\"FPURMRBFIN\":{" +
                    //\"FEntryId\":\"0\",
                    "\"FSettleOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleOrgId"]) + "\"}," +
                    "\"FSETTLETYPEID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLETYPEID"]) + "\"}," +
                    "\"FSettleCurrId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleCurrId"]) + "\"}," +
                    "\"FPAYCONDITIONID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPAYCONDITIONID"]) + "\"}," +
                    "\"FIsIncludedTax\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsIncludedTax"]) + "\"," +
                    "\"FPriceTimePoint\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPriceTimePoint"]) + "\"," +
                    //\"FPRICELISTID\":{\"FNumber\":\"\"},
                    "\"FDISCOUNTLISTID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDISCOUNTLISTID"]) + "\"}," +
                    "\"FLOCALCURRID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FLOCALCURRID"]) + "\"}," +
                    "\"FEXCHANGETYPEID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FEXCHANGETYPEID"]) + "\"}," +
                    "\"FEXCHANGERATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FEXCHANGERATE"]) + "\"," +
                    "\"FPAYORGID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPAYORGID"]) + "\"}," +
                    "\"FISPRICEEXCLUDETAX\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FISPRICEEXCLUDETAX"]) + "\"}," +
                    "\"FPURMRBENTRY\": [  ";
                    string sJson_Entry = "";
                    for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
                    {
                        if (sJson_Entry != "")
                        {
                            sJson_Entry = sJson_Entry + " , ";
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        string sJson_FAUXPROPID = "";
                        string sJson_SubCustom = "";        //子表自定义字段
                        //子表自定义字段
                        sJson_SubCustom = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["SubCustom"]);
                        //是否启用批次管理
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HISBATCHMANAGE"]) == "1")
                        {
                            sJson_BatchNo = "  \"FLOT\": {\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"},    \"FLOT_TEXT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"  , ";
                        }
                        else
                        {
                            sJson_BatchNo = "";
                        }
                        //是否启用保质期控制
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISKFPERIOD"]) == "1")
                        {
                            sJson_FProduceDate = " \"FProduceDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + "\",";
                            sJson_FExpiryDate = " \"FExpiryDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "\",";
                        }
                        else
                        {
                            sJson_FProduceDate = "";
                            sJson_FExpiryDate = "";
                        }
                        //辅助属性
                        sJson_FAUXPROPID = " \"FAUXPROPID\":{\"FAUXPROPID__FF100002\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXPROPID"]) + "\"}},";
                        //仓位
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) == "")
                        {
                            sJson_StockPlace = "";
                        }
                        else
                        {
                            sJson_StockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) + "\"}},";
                        }
                        sJson_Entry = sJson_Entry + "{" +
                        //\"FEntryID\":\"0\",
                        "\"FRowType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRowType"]) + "\"," +
                        "\"FMATERIALID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMATERIALID"]) + "\"}," +
                        "\"FMaterialDesc\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMaterialDesc"]) + "\"," +
                        "\"FParentMatId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FParentMatId"]) + "\"}," +
                        "\"FProjectNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProjectNo"]) + "\"," +
                        "\"FUnitID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUnitID"]) + "\"}," +
                        "\"FRMREALQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRMREALQTY"]) + "\"," +
                        "\"FREPLENISHQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREPLENISHQTY"]) + "\"," +
                        "\"FKEAPAMTQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKEAPAMTQTY"]) + "\"," +
                        "\"FPRICEUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICEUNITID"]) + "\"}," +
                        "\"FSTOCKID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKID"]) + "\"}," +
                        sJson_StockPlace +
                        "\"FStockStatusId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockStatusId"]) + "\"}," +
                        "\"FNOTE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FNOTE"]) + "\"," +
                        "\"FTaxCombination\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTaxCombination"]) + "\"}," +
                        "\"FPrice\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPrice"]) + "\"," +
                        "\"FBaseUnitPrice\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseUnitPrice"]) + "\"," +
                        "\"FExtAuxUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExtAuxUnitId"]) + "\"}," +
                        //\"FExtAuxUnitQty\":\"0\",
                        "\"FREQTRACENO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREQTRACENO"]) + "\"," +
                        "\"FIsReceiveUpdateStock\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsReceiveUpdateStock"]) + "\"," +
                        //\"FInvoicedJoinQty\":\"0\",
                        "\"FGiveAway\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FGiveAway"]) + "\"," +
                        "\"FPriceBaseQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceBaseQty"]) + "\"," +
                        //\"FSetPriceUnitID\":{\"FNumber\":\"\"},
                        "\"FCarryUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCarryUnitId"]) + "\"}," +
                        "\"FSysPrice\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSysPrice"]) + "\"," +
                        "\"FCarryQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCarryQty"]) + "\"," +
                        "\"FCarryBaseQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCarryBaseQty"]) + "\"," +
                        "\"FPOORDERENTRYID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPOORDERENTRYID"]) + "\"," +
                        "\"FBILLINGCLOSE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBILLINGCLOSE"]) + "\"," +
                        "\"FPriceListEntry\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceListEntry"]) + "\"}," +
                        sJson_FAUXPROPID +
                        //\"FRMMUSTQTY\":\"0\",
                        "\"FBOMID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMID"]) + "\"}," +
                        "\"FSupplierLot\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSupplierLot"]) + "\"," +
                        sJson_BatchNo +
                        sJson_FProduceDate +
                        sJson_FExpiryDate +
                        //\"FAUXUNITQTY\":\"0\",
                        "\"FENTRYTAXRATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FENTRYTAXRATE"]) + "\"," +
                        "\"FDISCOUNTRATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDISCOUNTRATE"]) + "\"," +
                        "\"FTAXPRICE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXPRICE"]) + "\"," +
                        "\"FIsStock\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsStock"]) + "\"," +
                        //\"FChargeProjectID\":{\"FNumber\":\"\"},
                        "\"FMtoNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMtoNo"]) + "\"," +
                        //
                        //"\"FCONTRACTNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCONTRACTNO"]) + "\"," +
                        "\"FORDERNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERNO"]) + "\"," +
                        "\"FPRICECOEFFICIENT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICECOEFFICIENT"]) + "\"," +
                        "\"FOWNERTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERTYPEID"]) + "\"," +
                        "\"FOWNERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERID"]) + "\"}," +
                        "\"FKeeperTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeId"]) + "\"," +
                        "\"FKEEPERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKEEPERID"]) + "\"}," +
                        "\"FAUXUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXUNITID"]) + "\"}," +
                        "\"FBASEUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITID"]) + "\"}," +
                        "\"FSNUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUNITID"]) + "\"}," +
                        "\"FPRILSTENTRYID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRILSTENTRYID"]) + "\"," +
                        "\"FSRCBIZUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBIZUNITID"]) + "\"}," +
                        "\"FSRCBILLTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLTYPEID"]) + "\"," +
                        "\"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," +
                        "\"FSrcSeq\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcSeq"]) + "\"," +
                        "\"FPURBASENUM\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURBASENUM"]) + "\"," +
                        "\"FSTOCKBASEDEN\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKBASEDEN"]) + "\"," +
                        "\"FCostPrice\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCostPrice"]) + "\"," +
                        sJson_SubCustom +
                        //\"FEntryPruCost\":[{\"FDetailID\":\"0\"}],
                        "\"FTaxDetailSubEntity\":[{" +
                        //\"FDetailID\":\"0\",
                        "\"FTAXRATEID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXRATEID"]) + "\"}," +
                        "\"FTaxRate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTaxRate"]) + "\"," +
                        "\"FTAXAMOUNT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXAMOUNT"]) + "\"," +
                        "\"FCOSTPERCENT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCOSTPERCENT"]) + "\"," +
                        "\"FTaxCostAmount\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTaxCostAmount"]) + "\"," +
                        "\"FVAT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FVAT"]) + "\"," +
                        "\"FSellerWithholding\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSellerWithholding"]) + "\"," +
                        "\"FBuyerWithholding\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBuyerWithholding"]) + "\"" +
                        " } ]," +
                        //\"FSerialSubEntity\":[{\"FDetailID\":\"0\",
                        //\"FSerialNo\":\"\",
                        //\"FSerialNote\":\"\"}]
                        "\"FPURMRBENTRY_Link\": [ {  " +
                        "\"FPURMRBENTRY_Link_FFlowId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURMRBENTRY_Link_FFlowId"]) + "\"," +
                        "\"FPURMRBENTRY_Link_FFlowLineId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURMRBENTRY_Link_FFlowLineId"]) + "\"," +
                        "\"FPURMRBENTRY_Link_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURMRBENTRY_Link_FRuleId"]) + "\"," +
                        "\"FPURMRBENTRY_Link_FSTableName\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURMRBENTRY_Link_FSTableName"]) + "\"," +
                        "\"FPURMRBENTRY_Link_FSBillId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURMRBENTRY_Link_FSBillId"]) + "\"," +
                        "\"FPURMRBENTRY_Link_FBASEUNITQTYOLD\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURMRBENTRY_Link_FBASEUNITQTYOLD"]) + "\"," +
                        "\"FPURMRBENTRY_Link_FCARRYBASEQTYOLD\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURMRBENTRY_Link_FCARRYBASEQTYOLD"]) + "\"," +
                        "\"FPURMRBENTRY_Link_FSId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPURMRBENTRY_Link_FSId"]) + "\"" +
                        " } ]," +
                        " \"FBFLowId\":{\"FID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBFLowId"]) + "\"}}";
                    }
                    string sJson_End = "  ]  }}";
                    string sJson = sJson_Main + sJson_Entry + sJson_End;
                    sRemark = sRemark + " ;获取CLOUD单据API递入值" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                    //生成金蝶云单据
                    if (bLogin)
                    {
                        var result = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
                        new object[] { "PUR_MRB", sJson });
                        sRemark = sRemark + " ;生成CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                        //生成单据后更新自定义字段
                        oCn.RunProc("exec h_p_Sc_UpDateSelfFildPOStockInBack '" + oMain.HBillNo + "','" + sHSourceType + "'");
                        sRemark = sRemark + " ;生成单据后回填字段信息" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                        HReturn = result.ToString();
                        if (HReturn.Contains("\"IsSuccess\":false") == true)
                        {
                            //反序列化json数据
                            var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(HReturn);
                            //接收金蝶报错信息
                            var strErrorMsg = string.Empty;
                            //遍历获取报错信息
                            foreach (var item in retModel.Result.ResponseStatus.Errors)
                            {
                                strErrorMsg += item.Message + "\r\n";
                            };
                            sErrMsg = "生成采购退料单失败!金蝶云提示:" + strErrorMsg;
                            LogService.Write("生成采购退料单(源单:采购入库单)失败!" + HReturn + sJson);   //写入txt文本
                            oCn.RollBack();
                            return false;
                        }
                        else
                        {
                            sRemark = sRemark + sJson;
                            oCn.Commit();
                        }
                    }
                    else
                    {
                        sErrMsg = "生成采购退料单失败!金蝶云登录失败!";
                        oCn.RollBack();
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                LogService.Write("生成回滚" + e.Message + sRemark);
                sErrMsg = "生成采购退料单失败!" + e.Message;
                oCn.RollBack();
                return false;
            }
            if (oSystemParameterMain.Kf_POStockInBackBill_AutoCheck.ToUpper() == "Y") //系统参数  自动审核
            {
                //审核WMS单据
                oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=getdate(),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
                //提交、审核金蝶云单据
                HReturn = "";
                string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
                new object[] { "PUR_MRB", sJson2 });
                sRemark = sRemark + " ;提交CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
                new object[] { "PUR_MRB", sJson3 });
                sRemark = sRemark + " ;审核CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                HReturn = result2.ToString() + "," + result3.ToString();
                if (HReturn.Contains("\"IsSuccess\":false") == true)
                {
                    //反序列化json数据
                    var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(result3);
                    //接收金蝶报错信息
                    var strErrorMsg = string.Empty;
                    //遍历获取报错信息
                    foreach (var item in retModel.Result.ResponseStatus.Errors)
                    {
                        strErrorMsg += item.Message + "\r\n";
                    };
                    sErrMsg = "生成采购退料单成功,审核单据失败!金蝶云提示:" + strErrorMsg;
                    LogService.Write("审核单据失败" + sRemark + HReturn);
                    return true;
                }
                else
                {
                    LogService.Write("生成并审核采购退料单(源单:采购入库单)成功!" + sRemark);
                    sErrMsg = "生成并审核采购退料单成功!单据号为:" + oMain.HBillNo;
                    return true;
                }
            }
            else if (oSystemParameterMain.Kf_POStockInBackBill_AutoSubmit.ToUpper() == "Y") //系统参数  自动提交
            {
                //提交金蝶云单据
                HReturn = "";
                string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
                new object[] { "PUR_MRB", sJson2 });
                sRemark = sRemark + " ;提交CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                HReturn = result2.ToString();
                if (HReturn.Contains("\"IsSuccess\":false") == true)
                {
                    //反序列化json数据
                    var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(HReturn);
                    //接收金蝶报错信息
                    var strErrorMsg = string.Empty;
                    //遍历获取报错信息
                    foreach (var item in retModel.Result.ResponseStatus.Errors)
                    {
                        strErrorMsg += item.Message + "\r\n";
                    };
                    sErrMsg = "生成采购退料单成功,提交单据失败!金蝶云提示:" + strErrorMsg;
                    LogService.Write("提交单据失败" + sRemark + HReturn);
                    return true;
                }
                else
                {
                    LogService.Write("生成并提交采购退料单(源单:采购入库单)成功!" + sRemark);
                    sErrMsg = "生成并提交采购退料单成功!单据号为:" + oMain.HBillNo;
                    return true;
                }
            }
            else
            {
                LogService.Write("生成采购退料单(源单:采购入库单)成功!" + sRemark);
                sErrMsg = "生成采购退料单成功!单据号为:" + oMain.HBillNo;
                return true;
            }
        }
@@ -57672,6 +58574,32 @@
                    return oBar;
                }
            }
            else if (HBillType == "1239")
            {
                //采购退料单
                oBar = get_SourceBarCode_POStockInBack(HInterID, HBillNo, HBillType, HSourceBillNo, HSourceBillType, HMaker, HStockOrgID, ref sErrMsg);
                if (oBar == null)
                {
                    return null;
                }
                else
                {
                    return oBar;
                }
            }
            else if (HBillType == "1244")
            {
                //生产退料单
                oBar = get_SourceBarCode_MateOutBack(HInterID, HBillNo, HBillType, HSourceBillNo, HSourceBillType, HMaker, HStockOrgID, ref sErrMsg);
                if (oBar == null)
                {
                    return null;
                }
                else
                {
                    return oBar;
                }
            }
            else
            {
                sErrMsg = "单据类型错误!";