YL
2021-07-30 19c497bd935346af5ec25979a86ea6c22bddf92f
CLOUDWEB/WebService1.asmx.cs
@@ -4951,6 +4951,373 @@
        #endregion
        #region 生产汇报单  报工平台产量汇报,报检申请 Layui调用*
        //生成生产汇报单
        [WebMethod]
        public bool set_SaveICMOProductReportBill_Layui(Model.ClsSc_ICMOReportBillMain oMain, string sHSourceType, ref string sErrMsg)
        {
            //获取系统参数
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref sErrMsg) == false)
            {
                sErrMsg = "获取系统参数失败! " + sErrMsg;
                return false;
            }
            //
            if (oSystemParameter.omodel.Sc_ICMOReportBill_ERPMode.ToUpper() == "WISE") //判断同步模式是金蝶WISE
            {
                return false;
            }
            if (oSystemParameter.omodel.Sc_ICMOReportBill_ERPMode.ToUpper() == "CLOUD")  //判断同步模式是金蝶CLOUD
            {
                if (set_SaveICMOProductReportBill_CLD_Layui(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg) == true)
                {
                    //"保存成功!";
                    return true;
                }
                else
                {
                    //"保存失败!";
                    return false;
                }
            }
            sErrMsg = "保存生产汇报单失败!" + sErrMsg;
            return false;
        }
        #endregion
        #region 生产汇报单CLOUD  报工平台产量汇报,报报检申请   Layui调用
        //生成生产汇报单
        [WebMethod]
        public bool set_SaveICMOProductReportBill_CLD_Layui(Model.ClsSc_ICMOReportBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            //if (sHSourceType == "3710")   //源单:生产订单
            //{
            if (SaveICMOProductReportBill_ICMO_CLD_Layui(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
            {
                //"保存成功!";
                sErrMsg = "保存成功!" + oMain.HBillNo + ";" + sErrMsg;
                return true;
            }
            else
            {
                //"保存失败!";
                sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";" + sErrMsg;
                return false;
            }
            //}
            //else
            //{
            //    sErrMsg = "错误的源单类型";
            //    return false;
            //}
        }
        /// <summary>
        /// 生产汇报单   源单:生产订单
        /// </summary>
        /// <param name="oMain"></param>
        /// <param name="sErrMsg"></param>
        /// <returns></returns>
        public bool SaveICMOProductReportBill_ICMO_CLD_Layui(Model.ClsSc_ICMOReportBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //建立一个 事务;
            try
            {
                //判断会计期是否合理
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                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;
                DataSet Ds;
                //DataSet Ds2;
                // 判断生产订单状态 是否为 完工 或结案
                //Ds2 = oCn.RunProcReturn("exec h_p_Sc_LoadICMOReportStatusCheck " + oMain.HInterID.ToString(), "h_p_Sc_LoadICMOReportStatusCheck");
                //if (Ds2 == null || Ds2.Tables[0].Rows.Count == 0)
                //{
                //    sErrMsg = "判断生产订单状态失败!";
                //    return false;
                //}
                //else
                //{
                //    if (DBUtility.ClsPub.isLong(Ds2.Tables[0].Rows[0]["HBack"]) == 2)
                //    {
                //        sErrMsg = "生产订单状态已完工不允许上传!" + DBUtility.ClsPub.isStrNull(Ds2.Tables[0].Rows[0]["HBackRemark"]);
                //        return false;
                //    }
                //}
                //写入WMS生产汇报单
                oCn.BeginTran();
                //插入子表
                oCn.RunProc("EXEC h_p_Sc_ICMOReportBillSub_Insert_WorkQty " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + sHSourceType + "'");
                //插入主表
                oCn.RunProc("Insert Into Sc_ICMOReportBillMain " +
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
                ",HEmpID,HGroupID,HDeptID,HPRDORGID" +
                ") " +
                " values('3711','3711'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120)" +
                ", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
                ", " + oMain.HEmpID.ToString() + "," + oMain.HGroupID.ToString() + "," + oMain.HDeptID.ToString() + "," + oMain.HPRDORGID.ToString() +
                ") ");
                //更新关联数量
                oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOToICMOReport_Add " + oMain.HInterID.ToString());
                //更新生产状态临时状态表数量
                oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOToICMOReport_Qty " + oMain.HMainSourceInterID.ToString() + "," + oMain.HMainSourceEntryID.ToString() + "");
                if (oSystemParameterMain.Sc_ICMOReportBill_AutoCheck == "Y") //系统参数  自动审核
                {
                    //审核单据
                    oCn.RunProc("Update Sc_ICMOReportBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
                }
                //根据TMP表 返回 子表信息
                Ds = oCn.RunProcReturn("exec h_p_Kf_GetICMOReportBill_ICMO_CLD_WorkQty " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetICMOReportBill_ICMO_CLD_WorkQty");
                if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
                {
                    sErrMsg = "获取json子表信息失败!";
                    oCn.RollBack();
                    return false;
                }
                else
                {
                    string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\"," +
                        "\"IsEntryBatchFill\":\"false\",\"ValidateFlag\":\"True\",\"NumberSearch\":\"True\",\"InterationFlags\":\"\"," +
                        "\"Model\": { \"FBILLNO\":\"" + oMain.HBillNo + "\"," +
                        //"\"FID\":\"" + oMain.HInterID.ToString() + "\"," +
                        "\"FBillType\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillType"]) + "\"}," +
                        //\"FDocumentStatus\":\"\",
                        "\"FDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDate"]) + "\"," +
                        "\"FPRDORGID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPRDORGID"]) + "\"}," +
                        //\"FWorkshipIdH\":{\"FNumber\":\"\"},
                        //\"FDescription\":\"\",
                        "\"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_EntryCustom = "";
                        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]["FSTOCKLOCID"]) == "")
                        {
                            sJson_StockPlace = "";
                        }
                        else
                        {
                            sJson_StockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKLOCID"]) + "\"}},";
                        }
                        //自定义字段处理
                        if (oSystemParameterMain.WMS_CampanyName == "四维尔") //系统参数  客户定制化名称     空白为通用
                        {
                            sJson_EntryCustom = "\"FBILLSTATUS\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBILLSTATUS"]) + "\"," +         //单据状态
                                                "\"F_abcd_Datetime\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["F_abcd_Datetime"]) + "\","; //计划开工日期
                        }
                        //
                        sJson_Entry = sJson_Entry + " {" +
                        //" \"FEntryID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HEntryID"]) + "," +
                        " \"FSRCENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCENTRYID"]) + "," +
                        " \"FIsNew\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsNew"]) + "," +
                        " \"FMATERIALID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMATERIALID"]) + "\"}," +
                        " \"FPRODUCTTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRODUCTTYPE"]) + "\"," +
                        " \"FREPORTTYPE\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREPORTTYPE"]) + "\"}," +
                        " \"FUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUNITID"]) + "\"}," +
                        " \"FWORKSHIPID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FWORKSHOPID"]) + "\"}," +
                        //\"FShiftGroupId\":{\"FNumber\":\"\"},
                        sJson_BatchNo +
                        //\"FDeptId\":{\"FNumber\":\"\"},
                        sJson_StockPlace +
                        " \"FMTONO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMTONO"]) + "\"," +
                        " \"FCHECKPRODUCT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCHECKPRODUCT"]) + "," +
                        " \"FISENTRUST\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISENTRUST"]) + "," +
                        " \"FSRCBILLTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLTYPE"]) + "\"," +
                        " \"FMOBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOBILLNO"]) + "\"," +
                        " \"FAUXPROPID\":{\"FAUXPROPID__FF100002\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXPROPID"]) + "\"}}," +
                        //\"FHumanQty\":\"0\",
                        " \"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," +
                        //\"FMachineQty\":\"0\",
                        //\"FMaterialUnitID\":{\"FNumber\":\"\"},
                        //\"FStartTime\":\"1900-01-01\",
                        //\"FEndTime\":\"1900-01-01\",
                        //\"FTimeUnitId\":\"\",
                        " \"FMOENTRYSEQ\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOENTRYSEQ"]) + "," +
                        //" \"FSTANDHOURUNITID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTANDHOURUNITID"]) + "\"," +
                        " \"FPROJECTNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPROJECTNO"]) + "\"," +
                        " \"FSTDMANHOUR\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTDMANHOUR"]) + "," +
                        " \"FHRPREPARETIME\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FHRPREPARETIME"]) + "," +
                        //\"FHrWorkTime\":\"0\",
                        " \"FMACPREPARETIME\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMACPREPARETIME"]) + "," +
                        //\"FMacWorkTime\":\"0\",
                        //\"FDescriptionE\":\"\",
                        " \"FSRCINTERID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCINTERID"]) + "," +
                        " \"FSRCENTRYSEQ\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCENTRYSEQ"]) + "," +
                        " \"FMOID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOID"]) + "," +
                        " \"FMOENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOENTRYID"]) + "," +
                        " \"FBASEUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITID"]) + "\"}," +
                        " \"FSTOCKINORGID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKINORGID"]) + "\"}," +
                        " \"FBOMID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMID"]) + "\"}," +
                        " \"FOWNERTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERTYPEID"]) + "\"," +
                        " \"FOWNERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERID"]) + "\"}," +
                        " \"FSTOCKID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKID"]) + "\"}," +
                        " \"FCOSTRATE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCOSTRATE"]) + "," +
                        " \"FSNUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUNITID"]) + "\"}," +
                        //\"FSNQty\":\"0\",
                        //\"FProduceDate\":\"1900-01-01\",
                        //\"FExpiryDate\":\"1900-01-01\",
                        " \"FISBACKFLUSH\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISBACKFLUSH"]) + "," +
                        " \"FMOMAINENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOMAINENTRYID"]) + "," +
                        " \"FQAIP\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQAIP"]) + "\"," +
                        " \"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"]) + "," +
                        " \"FBASEQUAQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEQUAQTY"]) + "," +
                        " \"FQUAQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQUAQTY"]) + "," +
                        " \"FBASEFINISHQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEFINISHQTY"]) + "," +
                        " \"FFINISHQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FFINISHQTY"]) + "," +
                        sJson_EntryCustom +
                        //\"FSerialSubEntity\":[{\"FDetailID\":\"0\",
                        //\"FQCMaterialId\":{\"FNUMBER\":\"\"},
                        //\"FInspectResult\":\"\",
                        //\"FQcAuxPropId\":{\"FQCAUXPROPID__FF100002\":{\"FNumber\":\"\"}},
                        //\"FQCQty\":\"0\",
                        //\"FSerialNo\":\"\",
                        //\"FSerialId\":{\"FNUMBER\":\"\"},
                        //\"FQCStockInSelQty\":\"0\",
                        //\"FSerialNote\":\"\",
                        //\"FBaseQCQty\":\"0\",
                        //\"FBaseQCStockInSelQty\":\"0\"}]
                        " \"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_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;
                    //从配置文件获取 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 = get_SaveCLOUDUseNameandPsd(oMain.HInterID);
                    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;
                    string HReturn2 = "";
                    ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
                    string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
                    bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052);
                    if (bLogin)
                    {
                        var result = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
                        new object[] { "PRD_MORPT", sJson }); //调用保存方式
                        if (oSystemParameterMain.Sc_ICMOReportBill_AutoCheck == "Y") //系统参数  自动审核
                        {
                            string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                            var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
                            new object[] { "PRD_MORPT", sJson2 }); //提交单据
                            string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                            var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
                            new object[] { "PRD_MORPT", sJson3 }); //审核单据
                            string sJson4 = "{\"Ids\":\"\",\"Numbers\":[\"" + oMain.HBillNo + "\"],\"EntryIds\":\"\",\"RuleId\":\"PRD_MORPT2INSTOCK\",\"TargetBillTypeId\":\"\",\"TargetOrgId\":\"0\",\"TargetFormId\":\"PRD_INSTOCK\",\"IsEnableDefaultRule\":\"false\",\"IsDraftWhenSaveFail\":\"true\",\"CustomParams\":{}}";
                            var result4 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Push",
                            new object[] { "PRD_MORPT", sJson4 }); //下推生产入库单
                            HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString();
                            HReturn2 = result4.ToString();
                        }
                        else
                        {
                            HReturn = result.ToString();
                        }
                        if (HReturn.Contains("\"IsSuccess\":false") == true)
                        {
                            sErrMsg = "生成生产汇报单失败!" + HReturn + sJson;
                            oCn.RollBack();
                            return false;
                        }
                        else
                        {
                            if (HReturn2.Contains("\"IsSuccess\":false") == true)
                            {
                                sErrMsg = "生成生产入库单失败!" + HReturn2;
                            }
                            else
                            {
                                sErrMsg = "";
                            }
                            oCn.Commit();
                            return true;
                        }
                    }
                    else
                    {
                        sErrMsg = "生成生产汇报单失败!登录失败!";
                        oCn.RollBack();
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                sErrMsg = "生成生产汇报单失败!" + e.Message;
                oCn.RollBack();
                return false;
            }
        }
        #endregion
        #region 调拨单(领料、销售、直接)CLOUD
        //调拨单(领料
@@ -4988,6 +5355,21 @@
                    //"保存失败!";
                    sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";" + sErrMsg;
                    //sErrMsg = sErrMsg;
                    return false;
                }
            }
            else if (sHSourceType == "1243") //调拨申请单
            {
                if (SaveMoveStockBill_MoveStockRequest_CLD(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
                {
                    //"保存成功!";
                    sErrMsg = "保存成功!" + oMain.HBillNo;
                    return true;
                }
                else
                {
                    //"保存失败!";
                    sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";" + sErrMsg;
                    return false;
                }
            }
@@ -7074,6 +7456,8 @@
                        string sJson_BatchNo = "";
                        string sJson_SrcStockPlace = "";
                        string sJson_DestStockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        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"]) + "\"  , ";
@@ -7082,6 +7466,18 @@
                        {
                            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 = "";
                        }
                        //调入仓位
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) == "")
                        {
@@ -7117,11 +7513,11 @@
                        " \"FSrcStockStatusId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockStatusId"]) + "\"}," +
                        //\"FDeliChkQualifyType\":\"\",
                        //\"FAmount\":\"0\",
                        " \"FProduceDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + "\"," +
                        sJson_FProduceDate +
                        " \"FDestStockStatusId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockStatusId"]) + "\"}," +
                        " \"FMtoNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMtoNo"]) + "\"," +
                        " \"FBusinessDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBusinessDate"]) + "\"," +
                        " \"FExpiryDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "\"," +
                        sJson_FExpiryDate +
                        " \"FOwnerTypeOutId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeOutId"]) + "\"," +
                        " \"FOwnerOutId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerOutId"]) + "\"}," +
                        " \"FOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeId"]) + "\"," +
@@ -9265,6 +9661,20 @@
        [WebMethod]
        public bool set_SaveSellOutBackBill_CLD_New(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            ////上传前判断是否存在相同条码
            //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            //DataSet ds = oCn.RunProcReturn("exec h_p_WMS_UpLoadControl " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'", "h_p_WMS_UpLoadControl");
            //if (ds == null || ds.Tables[0].Rows.Count == 0)
            //{
            //}
            //else
            //{
            //    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 1)
            //    {
            //        sErrMsg = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
            //        return false;
            //    }
            //}
            if (sHSourceType == "1403")   //退货通知单
            {
                if (SaveSellOutBackBill_SeOutStockBack_CLD_New(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
@@ -9424,6 +9834,8 @@
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        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"]) + "\"  , ";
@@ -9431,6 +9843,17 @@
                        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 = "";
                        }
                        //仓位
@@ -9463,8 +9886,8 @@
                        "\"FReturnType\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReturnType"]) + "\"}," +
                        "\"FOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeId"]) + "\"," +
                        "\"FOwnerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerId"]) + "\"}," +
                        "\"FProduceDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + "\"," +
                        "\"FExpiryDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "\"," +
                        sJson_FProduceDate +
                        sJson_FExpiryDate +
                        "\"FStockId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockId"]) + "\"}," +
                        sJson_StockPlace +
                        //\"FStockstatusId\":{\"FNumber\":\"\"},
@@ -9743,6 +10166,8 @@
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        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"]) + "\"  , ";
@@ -9750,6 +10175,17 @@
                        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 = "";
                        }
                        //仓位
@@ -9782,8 +10218,8 @@
                        //"\"FReturnType\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReturnType"]) + "\"}," +
                        "\"FOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeId"]) + "\"," +
                        "\"FOwnerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerId"]) + "\"}," +
                        "\"FProduceDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + "\"," +
                        "\"FExpiryDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "\"," +
                        sJson_FProduceDate +
                        sJson_FExpiryDate +
                        "\"FStockId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockId"]) + "\"}," +
                        sJson_StockPlace +
                        //\"FStockstatusId\":{\"FNumber\":\"\"},
@@ -11246,7 +11682,7 @@
                        "\"FDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDATE"]) + "\"," +
                        "\"FSALEORGID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSALEORGID"]) + "\"}," +
                        "\"FCUSTOMERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCUSTOMERID"]) + "\"}," +
                        "\"FSALEDEPTID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSALEDEPTID"]) + "\"}," +
                        //"\"FSALEDEPTID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSALEDEPTID"]) + "\"}," +    //移到最下方位置
                        "\"FHEADLOCATIONID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FHEADLOCATIONID"]) + "\"}," +
                        "\"FCORRESPONDORGID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCORRESPONDORGID"]) + "\"}," +
                        //\"FCarrierID\":{\"FNumber\":\"\"},
@@ -11269,8 +11705,9 @@
                        //\"FCDateOffsetUnit\":\"\",
                        //\"FCDateOffsetValue\":\"0\",
                        "\"FPLANRECADDRESS\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPLANRECADDRESS"]) + "\"," +
                        "\"FIsTotalServiceOrCost\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsTotalServiceOrCost"]) + "," +
                        "\"FIsTotalServiceOrCost\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsTotalServiceOrCost"]) + "\"," +
                        "\"FBUSINESSTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBUSINESSTYPE"]) + "\"," +
                        "\"FSALEDEPTID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSALEDEPTID"]) + "\"}," +
                        "\"SubHeadEntity\":{ " +
                        //\"FEntryId\":\"0\",
@@ -11281,12 +11718,12 @@
                        "\"FSETTLEORGID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLEORGID"]) + "\"}," +
                        "\"FSETTLETYPEID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLETYPEID"]) + "\"}," +
                        "\"FRECEIPTCONDITIONID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FRECEIPTCONDITIONID"]) + "\"}," +
                        //\"FPriceListId\":{\"FNumber\":\"\"},
                        //"\"FPriceListId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPriceListId"]) + "\"}," +
                        //\"FDiscountListId\":{\"FNumber\":\"\"},
                        "\"FISINCLUDEDTAX\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FISINCLUDEDTAX"]) + "," +
                        "\"FISINCLUDEDTAX\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FISINCLUDEDTAX"]) + "\"," +
                        "\"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"]) + "," +
                        "\"FEXCHANGERATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FEXCHANGERATE"]) + "\"," +
                        "\"FISPRICEEXCLUDETAX\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FISPRICEEXCLUDETAX"]) + "}," +
                        "\"FEntity\": [  ";
                    string sJson_Entry = "";
@@ -11298,6 +11735,8 @@
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        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"]) + "\"  , ";
@@ -11306,6 +11745,18 @@
                        {
                            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 = "";
                        }
                        //仓位
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKLOCID"]) == "")
                        {
@@ -11325,19 +11776,19 @@
                        " \"FUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUNITID"]) + "\"}," +
                        //\"FInventoryQty\":\"0\",
                        " \"FPARENTMATID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPARENTMATID"]) + "\"}," +
                        " \"FRealQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRealQty"]) + "," +
                        " \"FRealQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRealQty"]) + "\"," +
                        //\"FDisPriceQty\":\"0\",
                        " \"FPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICE"]) + "," +
                        " \"FTAXPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXPRICE"]) + "," +
                        " \"FISFREE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISFREE"]) + "," +
                        //" \"FPRICE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICE"]) + "\"," +   //移到最下方位置
                        //" \"FTAXPRICE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXPRICE"]) + "\"," +   //移到最下方位置
                        " \"FISFREE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISFREE"]) + "\"," +
                        " \"FBOMID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMID"]) + "\"}," +
                        " \"FPRODUCEDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRODUCEDATE"]) + "\"," +
                        sJson_FProduceDate +
                        " \"FOWNERTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERTYPEID"]) + "\"," +
                        " \"FOWNERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERID"]) + "\"}," +
                        sJson_BatchNo +
                        " \"FEXPIRYDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEXPIRYDATE"]) + "\"," +
                        sJson_FExpiryDate +
                        " \"FTAXCOMBINATION\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXCOMBINATION"]) + "\"}," +
                        " \"FENTRYTAXRATE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FENTRYTAXRATE"]) + "," +
                        " \"FENTRYTAXRATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FENTRYTAXRATE"]) + "\"," +
                        //\"FAuxUnitQty\":\"0\",
                        " \"FEXTAUXUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEXTAUXUNITID"]) + "\"}," +
                        //\"FExtAuxUnitQty\":\"0\",
@@ -11347,52 +11798,55 @@
                        //\"FQualifyType\":\"\",
                        " \"FMTONO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMTONO"]) + "\"," +
                        " \"FEntrynote\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrynote"]) + "\"," +
                        " \"FDISCOUNTRATE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDISCOUNTRATE"]) + "," +
                        " \"FDISCOUNTRATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDISCOUNTRATE"]) + "\"," +
                        //\"FPriceDiscount\":\"0\",
                        //\"FActQty\":\"0\",
                        " \"FSALUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALUNITID"]) + "\"}," +
                        " \"FSALUNITQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALUNITQTY"]) + "," +
                        " \"FSALBASEQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALBASEQTY"]) + "," +
                        " \"FPRICEBASEQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICEBASEQTY"]) + "," +
                        " \"FSALUNITQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALUNITQTY"]) + "\"," +
                        " \"FSALBASEQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALBASEQTY"]) + "\"," +
                        " \"FPRICEBASEQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICEBASEQTY"]) + "\"," +
                        //\"FProjectNo\":\"\",
                        " \"FOUTCONTROL\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOUTCONTROL"]) + "," +
                        " \"FOUTCONTROL\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOUTCONTROL"]) + "\"," +
                        //\"FRepairQty\":\"0\",
                        //\"FIsCreateProDoc\":\"\",
                        //\"FEOwnerSupplierId\":{\"FNUMBER\":\"\"},
                        " \"FISOVERLEGALORG\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISOVERLEGALORG"]) + "," +
                        " \"FISOVERLEGALORG\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISOVERLEGALORG"]) + "\"," +
                        //\"FESettleCustomerId\":{\"FNUMBER\":\"\"},
                        //\"FPriceListEntry\":{\"FNUMBER\":\"\"},
                        " \"FARNOTJOINQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FARNOTJOINQTY"]) + "," +
                        //" \"FPriceListEntry\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceListEntry"]) + "\"}," +
                        " \"FARNOTJOINQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FARNOTJOINQTY"]) + "\"," +
                        //\"FQmEntryID\":\"0\",
                        //\"FConvertEntryID\":\"0\",
                        " \"FSOENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSOENTRYID"]) + "," +
                        " \"FSOENTRYID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSOENTRYID"]) + "\"," +
                        //\"FThirdEntryId\":\"\",
                        //\"FBeforeDisPriceQty\":\"0\",
                        //\"FSignQty\":\"0\",
                        " \"FBASEUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITID"]) + "\"}," +
                        " \"FAUXUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXUNITID"]) + "\"}," +
                        " \"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," +
                        " \"FSOORDERNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSOORDERNO"]) + "\"," +
                        " \"FPRICEUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICEUNITID"]) + "\"}," +
                        " \"FPRICECOEFFICIENT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICECOEFFICIENT"]) + "," +
                        " \"FSYSPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSYSPRICE"]) + "," +
                        " \"FLIMITDOWNPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLIMITDOWNPRICE"]) + "," +
                        " \"FPRICECOEFFICIENT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICECOEFFICIENT"]) + "\"," +
                        " \"FSYSPRICE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSYSPRICE"]) + "\"," +
                        " \"FLIMITDOWNPRICE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLIMITDOWNPRICE"]) + "\"," +
                        " \"FSNUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUNITID"]) + "\"}," +
                        " \"FSRCBIZUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBIZUNITID"]) + "\"}," +
                        " \"FROWID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FROWID"]) + "\"," +
                        " \"FPARENTROWID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPARENTROWID"]) + "\"," +
                        " \"FSRCTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCTYPE"]) + "\"," +
                        " \"FMustQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMustQty"]) + "\"," +
                        " \"FBASEMUSTQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEMUSTQTY"]) + "," +
                        " \"FBASEUNITQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITQTY"]) + "," +
                        " \"FSALBASENUM\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALBASENUM"]) + "," +
                        " \"FSTOCKBASEDEN\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKBASEDEN"]) + "," +
                        " \"FBASEMUSTQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEMUSTQTY"]) + "\"," +
                        " \"FBASEUNITQTY\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITQTY"]) + "\"," +
                        " \"FSALBASENUM\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALBASENUM"]) + "\"," +
                        " \"FSTOCKBASEDEN\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKBASEDEN"]) + "\"," +
                        " \"FPRICE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICE"]) + "\"," +
                        " \"FTAXPRICE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXPRICE"]) + "\"," +
                        " \"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"]) + "," +
                            " \"FCOSTPERCENT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCOSTPERCENT"]) + "," +
                            " \"FTAXRATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXRATE"]) + "\"," +
                            " \"FCOSTPERCENT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCOSTPERCENT"]) + "\"," +
                            " \"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"]) + "\"" +
@@ -11417,6 +11871,8 @@
                            " \"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_FBASEUNITQTYOLD\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FBASEUNITQTYOLD"]) + "\"," +
                            " \"FEntity_Link_FSALBASEQTYOLD\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSALBASEQTYOLD"]) + "\"," +
                            " \"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"]) + "\"}}";
@@ -11623,6 +12079,8 @@
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        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"]) + "\"  , ";
@@ -11631,6 +12089,18 @@
                        {
                            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 = "";
                        }
                        //仓位
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKLOCID"]) == "")
                        {
@@ -11656,11 +12126,11 @@
                        " \"FTAXPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXPRICE"]) + "," +
                        " \"FISFREE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISFREE"]) + "," +
                        " \"FBOMID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMID"]) + "\"}," +
                        " \"FPRODUCEDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRODUCEDATE"]) + "\"," +
                        sJson_FProduceDate +
                        " \"FOWNERTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERTYPEID"]) + "\"," +
                        " \"FOWNERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERID"]) + "\"}," +
                        sJson_BatchNo +
                        " \"FEXPIRYDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEXPIRYDATE"]) + "\"," +
                        sJson_FExpiryDate +
                        " \"FTAXCOMBINATION\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXCOMBINATION"]) + "\"}," +
                        " \"FENTRYTAXRATE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FENTRYTAXRATE"]) + "," +
                        //\"FAuxUnitQty\":\"0\",
@@ -13599,6 +14069,19 @@
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";
                        string sJson_FExpiryDate = "";
                        if ((oSystemParameterMain.WMS_CampanyName == "横河模具")) //客户横河模具
                        {
                            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 = "";
                        }
                        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"]) + "\"  , ";
@@ -13690,7 +14173,8 @@
                        "\"FPickingStatus\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPickingStatus"]) + "\"," +
                        //
                        "\"FSNUnitID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUnitID"]) + "\"}," +
                         sJson_FProduceDate +
                         sJson_FExpiryDate +
                        //\"FSerialSubEntity\":[{\"FDetailID\":\"0\",
                        //\"FSerialNo\":\"\",
                        //\"FSerialId\":{\"FNumber\":\"\"},
@@ -14037,6 +14521,346 @@
            catch (Exception e)
            {
                sErrMsg = "生产领料单失败!" + e.Message;
                oCn.RollBack();
                return false;
            }
        }
        #endregion
        #region 生产补料单        *
        //生成生产补料单
        [WebMethod]
        public bool set_SaveMateReplenishOutBill_New(Model.ClsKf_MateReplenishOutBillMain oMain, string sHSourceType, ref string sErrMsg)
        {
            //获取系统参数
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref sErrMsg) == false)
            {
                sErrMsg = "获取系统参数失败! " + sErrMsg;
                return false;
            }
            //
            if (set_SaveMateReplenishOutBill_CLD_New(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg) == true)
            {
                //"保存成功!";
                return true;
            }
            else
            {
                //"保存失败!";
                return false;
            }
            sErrMsg = "保存生产补料单失败!" + sErrMsg;
            return false;
        }
        #endregion
        #region 生产补料CLOUD   *New
        [WebMethod]
        public bool set_SaveMateReplenishOutBill_CLD_New(Model.ClsKf_MateReplenishOutBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            if (sHSourceType == "3720")   //生产用料清单
            {
                if (SaveMateReplenishOutBill_PPBom_CLD(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
                {
                    //"保存成功!";
                    sErrMsg = "保存成功!" + oMain.HBillNo;
                    return true;
                }
                else
                {
                    //"保存失败!";
                    sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";" + sErrMsg;
                    return false;
                }
            }
            else
            {
                sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";错误的源单类型";
                return false;
            }
        }
        /// <summary>
        /// 生产补料单    (源单:生产用料清单)
        /// </summary>
        /// <param name="oMain"></param>
        /// <param name="sErrMsg"></param>
        /// <returns></returns>
        public bool SaveMateReplenishOutBill_PPBom_CLD(Model.ClsKf_MateReplenishOutBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            try
            {
                //判断会计期是否合理
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                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_MateReplenishOutBillSub_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('1254','1254'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120),'" + oMain.HMainSourceBillType + "'" +
                ", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
                ", " + 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() +
                ") ");
                //更新关联数量
                if (oSystemParameterMain.Kf_MateReplenishOutBill_AutoCheck == "Y") //系统参数  自动审核
                {
                    //审核单据
                    oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120) where HInterID= " + oMain.HInterID.ToString());
                }
                //根据TMP表 返回 信息
                DataSet Ds;
                Ds = oCn.RunProcReturn("exec h_p_Kf_GetMateReplenishOutBill_PPBom_CLD_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'," + oMain.HOWNERID.ToString(), "h_p_Kf_GetMateReplenishOutBill_PPBom_CLD_New");
                if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
                {
                    sErrMsg = "获取子表信息失败!";
                    oCn.RollBack();
                    return false;
                }
                else
                {
                    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"]) + "\"}," +
                        "\"FDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDate"]) + "\"," +
                        "\"FStockOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\"}," +
                        //\"FStockId0\":{\"FNumber\":\"\"},
                        "\"FPrdOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPrdOrgId"]) + "\"}," +
                        //\"FWorkShopId\":{\"FNumber\":\"\"},
                        "\"FOwnerTypeId0\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeId0"]) + "\"," +
                        //\"FOwnerId0\":{\"FNumber\":\"\"},
                        "\"FPickerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPickerId"]) + "\"}," +
                        "\"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"]) + "\"," +
                        //\"FScanBox\":\"\",
                        "\"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 = "";
                        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]["FStockLocId"]) == "")
                        {
                            sJson_StockPlace = "";
                        }
                        else
                        {
                            sJson_StockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) + "\"}},";
                        }
                        sJson_Entry = sJson_Entry + "{" +
                        //\"FEntryID\":\"0\",
                        "\"FParentMaterialId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FParentMaterialId"]) + "\"}," +
                        //\"FConsome\":\"\",
                        "\"FReserveType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReserveType"]) + "\"," +
                        "\"FBaseStockActualQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseStockActualQty"]) + "\"," +
                        "\"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"]) + "\"," +
                        "\"FActualQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FActualQty"]) + "\"," +
                        "\"FEntryVmiBusiness\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntryVmiBusiness"]) + "\"," +
                        //\"FScrapQty\":\"0\",
                        //\"FOptQueue\":\"\",
                        //\"FOptPlanBillNo\":\"\",
                        //\"FOptPlanBillId\":\"0\",
                        "\"FStockId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockId"]) + "\"}," +
                        //\"FWorkCenterId\":{\"FNUMBER\":\"\"},
                        sJson_StockPlace +
                        //\"FOptDetailId\":\"0\",
                        sJson_BatchNo +
                        "\"FProcessId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProcessId"]) + "\"}," +
                        "\"FBomId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBomId"]) + "\"}," +
                        //\"FFeedReasonId\":{\"FNumber\":\"\"},
                        //\"FEntrtyDescription\":\"\",
                        "\"FStockStatusId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockStatusId"]) + "\"}," +
                        //\"FProduceDate\":\"1900-01-01\",
                        "\"FMtoNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMtoNo"]) + "\"," +
                        "\"FProjectNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProjectNo"]) + "\"," +
                        "\"FMoBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMoBillNo"]) + "\"," +
                        "\"FMoEntryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMoEntryId"]) + "\"," +
                        "\"FPPBomEntryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPPBomEntryId"]) + "\"," +
                        "\"FOperId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOperId"]) + "\"," +
                        "\"FOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeId"]) + "\"," +
                        "\"FStockAppQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockAppQty"]) + "\"," +
                        "\"FStockActualQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockActualQty"]) + "\"," +
                        //\"FSecActualQty\":\"0\",
                        "\"FMoId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMoId"]) + "\"," +
                        "\"FMoEntrySeq\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMoEntrySeq"]) + "\"," +
                        "\"FBaseAppQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseAppQty"]) + "\"," +
                        //\"FStockScrapQty\":\"0\",
                        //\"FSecScrapQty\":\"0\",
                        //\"FBaseScrapQty\":\"0\",
                        "\"FPPBomBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPPBomBillNo"]) + "\"," +
                        "\"FBaseUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseUnitId"]) + "\"}," +
                        "\"FStockUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockUnitId"]) + "\"}," +
                        "\"FSecUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSecUnitId"]) + "\"}," +
                        "\"FEntryWorkShopId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntryWorkShopId"]) + "\"}," +
                        "\"FBaseActualQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseActualQty"]) + "\"," +
                        "\"FAuxPropId\":{\"FAUXPROPID__FF100002\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAuxPropId"]) + "\"}}," +
                        "\"FKeeperTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeId"]) + "\"," +
                        "\"FKeeperId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperId"]) + "\"}," +
                        "\"FOwnerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerId"]) + "\"}," +
                        //\"FExpiryDate\":\"1900-01-01\",
                        "\"FEntrySrcInterId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrySrcInterId"]) + "\"," +
                        "\"FEntrySrcBillType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrySrcBillType"]) + "\"," +
                        "\"FEntrySrcEnteryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrySrcEnteryId"]) + "\"," +
                        "\"FEntrySrcBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrySrcBillNo"]) + "\"," +
                        //\"FPrice\":\"0\",
                        //\"FAmount\":\"0\",
                        "\"FParentOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FParentOwnerTypeId"]) + "\"," +
                        "\"FParentOwnerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FParentOwnerId"]) + "\"}," +
                        "\"FEntrySrcEntrySeq\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntrySrcEntrySeq"]) + "\"," +
                        //\"FSrcBizBillNo\":\"\",
                        //\"FSrcBizBillType\":{\"FNAME\":\"\"},
                        //\"FSrcBizEntryId\":\"0\",
                        //\"FSrcBizInterId\":\"0\",
                        //\"FSrcBizEntrySeq\":\"0\",
                        //
                        "\"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"]) + "\"," +
                        //\"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_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;
                    //从配置文件获取 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 = get_SaveCLOUDUseNameandPsd(oMain.HInterID);
                    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);
                    if (bLogin)
                    {
                        var result = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
                        new object[] { "PRD_FeedMtrl", sJson });
                        //生成单据后更新自定义字段
                        oCn.RunProc("exec h_p_Sc_UpDateSelfFildMateReplenishOutBill '" + oMain.HBillNo + "','" + sHSourceType + "'");
                        if (oSystemParameterMain.Kf_MateReplenishOutBill_AutoCheck == "Y") //系统参数  自动审核
                        {
                            string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                            var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
                            new object[] { "PRD_FeedMtrl", sJson2 });
                            string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                            var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
                            new object[] { "PRD_FeedMtrl", sJson3 });
                            HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString();
                        }
                        else
                        {
                            HReturn = result.ToString();
                        }
                        if (HReturn.Contains("\"IsSuccess\":false") == true)
                        {
                            sErrMsg = "生成生产补料单失败!" + HReturn + sJson;
                            oCn.RollBack();
                            return false;
                        }
                        else
                        {
                            oCn.Commit();
                            return true;
                        }
                    }
                    else
                    {
                        sErrMsg = "生成生产补料单失败!登录失败!";
                        oCn.RollBack();
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                sErrMsg = "生成生产补料单失败!" + e.Message;
                oCn.RollBack();
                return false;
            }
@@ -19249,7 +20073,7 @@
                    "\"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"]) + "\"}," +
                    //"\"FSupplierId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplierId"]) + "\"}," +  //移最下方
                    "\"FSupplyId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyId"]) + "\"}," +
                    "\"FSupplyAddress\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyAddress"]) + "\"," +
                    "\"FSettleId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleId"]) + "\"}," +
@@ -19266,6 +20090,7 @@
                    "\"FDeliveryBill\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDeliveryBill"]) + "\"," +
                    "\"FTakeDeliveryBill\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTakeDeliveryBill"]) + "\"," +
                    "\"FBusinessType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBusinessType"]) + "\"," +
                    "\"FSupplierId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplierId"]) + "\"}," +
                    "\"FInStockFin\":{" +
                    //\"FEntryId\":\"0\",
@@ -19292,6 +20117,8 @@
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        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"]) + "\"  , " +    //批号
@@ -19300,6 +20127,17 @@
                        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 = "";
                        }
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) == "")  //仓位
@@ -19331,7 +20169,7 @@
                        //\"FMtoNo\":\"\",
                        "\"FGiveAway\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FGiveAway"]) + "," +
                        //\"FNote\":\"\",
                        "\"FProduceDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + "\"," +
                        sJson_FProduceDate +
                        "\"FExtAuxUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExtAuxUnitId"]) + "\"}," +
                        //\"FExtAuxUnitQty\":\"0\",
                        "\"FCheckInComing\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCheckInComing"]) + "," +
@@ -19353,7 +20191,7 @@
                        //\"FCostPrice\":\"0\",
                        "\"FBOMId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMId"]) + "\"}," +
                        "\"FSupplierLot\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSupplierLot"]) + "\"," +
                        "\"FExpiryDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "\"," +
                        sJson_FExpiryDate +
                        "\"FAuxUnitQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAuxUnitQty"]) + "," +
                        //\"FBeforeDisPriceQty\":\"0\",
                        //
@@ -21933,6 +22771,8 @@
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        string sJson_EntryCustom = "";
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HISBATCHMANAGE"]) == "1") //是否启用批次管理
                        {
@@ -21942,6 +22782,18 @@
                        {
                            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 = "";
                        }
                        //仓位
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKLOCID"]) == "")
                        {
@@ -22002,9 +22854,9 @@
                        " \"FMOMAINENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOMAINENTRYID"]) + "," +
                        " \"FKEEPERTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKEEPERTYPEID"]) + "\"," +
                        " \"FKEEPERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKEEPERID"]) + "\"}," +
                        " \"FPRODUCEDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRODUCEDATE"]) + "\"," +
                        sJson_FProduceDate +
                        //\"FSelReStkQty\":\"0\",
                        " \"FEXPIRYDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEXPIRYDATE"]) + "\"," +
                        sJson_FExpiryDate +
                        //\"FBaseSelReStkQty\":\"0\",
                        " \"FSNUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUNITID"]) + "\"}," +
                        " \"FQAIP\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQAIP"]) + "\"," +
@@ -23244,7 +24096,7 @@
                    "\"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"]) + "\"}," +
                    //"\"FSupplierId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplierId"]) + "\"}," +  //移最下方
                    "\"FSupplyId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyId"]) + "\"}," +
                    "\"FSupplyAddress\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyAddress"]) + "\"," +
                    "\"FSettleId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleId"]) + "\"}," +
@@ -23260,6 +24112,7 @@
                    "\"FDeliveryBill\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDeliveryBill"]) + "\"," +
                    "\"FTakeDeliveryBill\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTakeDeliveryBill"]) + "\"," +
                    "\"FBusinessType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBusinessType"]) + "\"," +
                    "\"FSupplierId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplierId"]) + "\"}," +
                    "\"FInStockFin\":{" +
                    //\"FEntryId\":\"0\",
@@ -23286,6 +24139,8 @@
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_FProduceDate = "";     //生产日期
                        string sJson_FExpiryDate = "";      //有效期至
                        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"]) + "\"  , " +    //批号
@@ -23294,6 +24149,17 @@
                        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 = "";
                        }
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) == "")  //仓位
@@ -23325,7 +24191,7 @@
                        //\"FMtoNo\":\"\",
                        "\"FGiveAway\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FGiveAway"]) + "," +
                        //\"FNote\":\"\",
                        "\"FProduceDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + "\"," +
                        sJson_FProduceDate +
                        "\"FExtAuxUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExtAuxUnitId"]) + "\"}," +
                        //\"FExtAuxUnitQty\":\"0\",
                        "\"FCheckInComing\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCheckInComing"]) + "," +
@@ -23347,7 +24213,7 @@
                        //\"FCostPrice\":\"0\",
                        "\"FBOMId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMId"]) + "\"}," +
                        "\"FSupplierLot\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSupplierLot"]) + "\"," +
                        "\"FExpiryDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "\"," +
                        sJson_FExpiryDate +
                        "\"FAuxUnitQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAuxUnitQty"]) + "," +
                        //\"FBeforeDisPriceQty\":\"0\",
                        "\"FReqTraceNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FReqTraceNo"]) + "\"," +
@@ -29505,46 +30371,101 @@
            //获取条码数量
            if (dal.omodel_View.HBarCodeType != "托盘条码")
            {
                if (dal.omodel_View.HBarCodeType == "唯一条码" && HQty > 0 && dal.omodel_View.HQty < HQty)
                if (dal.omodel_View.HBarCodeType == "唯一条码")
                {
                    sRelQty = dal.omodel_View.HQty;
                }
                else if (HQty > 0)
                {
                    sRelQty = HQty;
                    if (HQty > 0 && dal.omodel_View.HQty > HQty)
                    {
                        sRelQty = HQty;
                    }
                    else
                    {
                        sRelQty = dal.omodel_View.HQty;
                    }
                }
                else
                {
                    sRelQty = dal.omodel_View.HQty;
                    if (HQty > 0)
                    {
                        sRelQty = HQty;
                    }
                    else if(dal.omodel_View.HinitQty>0)
                    {
                        sRelQty = dal.omodel_View.HinitQty;
                    }
                    else
                    {
                        sRelQty = dal.omodel_View.HQty;
                    }
                }
                //if (dal.omodel_View.HBarCodeType == "唯一条码" && HQty > 0 && dal.omodel_View.HQty < HQty)
                //{
                //    sRelQty = dal.omodel_View.HQty;
                //}
                //else if (HQty > 0)
                //{
                //    sRelQty = HQty;
                //}
                //else
                //{
                //    sRelQty = dal.omodel_View.HQty;
                //}
                //采购入库(1201)、产品入库(1202)、其他入库蓝字(1203)、委外入库(1210)
                //生产退料(1244)、销售退库(1247)、其他出库红字(1249)、委外退料(1238)
                //生产领料(1204)、销售出库(1205)、其他出库蓝字(1206)、委外出库(1211)
                //外购退料(1239)、产品退库(1245)、其他入库红字(1248)、委外退库(1246)
                //生产补料(1254)
                if (HBillType == "1204" || HBillType == "1205" || HBillType == "1206" || HBillType == "1211"
                    || HBillType == "1239" || HBillType == "1245" || HBillType == "1248" || HBillType == "1246")
                    || HBillType == "1239" || HBillType == "1245" || HBillType == "1248" || HBillType == "1246"
                    || HBillType == "1254")
                {
                    //非唯一条码扫描时判断仓库仓位是否已选择
                    if (dal.omodel_View.HBarCodeType != "唯一条码")
                    {
                        if (HWhID == 0)
                        if (oSystemParameter.omodel.WMS_ERPStockCtl == "N")
                        {
                            sErrMsg = "仓库没有选择!";
                            return false;
                            if (HWhID == 0)
                            {
                                sErrMsg = "仓库没有选择!";
                                return false;
                            }
                            else
                            {
                                //根据仓库ID,判断是否启用仓位
                                DataSet ds3 = oCn.RunProcReturn(" select HSPFlag from Gy_Warehouse with(nolock) where HItemID= " + HWhID.ToString(), "Gy_Warehouse");
                                if (ds3 == null || ds3.Tables[0].Rows.Count == 0)
                                {
                                    sErrMsg = "仓库内码错误!";
                                    return false;
                                }
                                else if (HSPID == 0 && DBUtility.ClsPub.isBool(ds3.Tables[0].Rows[0]["HSPFlag"]) == true)
                                {
                                    sErrMsg = "仓位没有选择!";
                                    return false;
                                }
                            }
                        }
                        else
                        {
                            //根据仓库ID,判断是否启用仓位
                            DataSet ds3 = oCn.RunProcReturn(" select HSPFlag from Gy_Warehouse with(nolock) where HItemID= " + HWhID.ToString(), "Gy_Warehouse");
                            if (ds3 == null || ds3.Tables[0].Rows.Count == 0)
                            //判断ERP库存   返回ERP库存数量
                            DataSet ds6 = oCn.RunProcReturn("exec h_p_IF_CheckQtyByERPICInventory " + HBillID.ToString() + ",'" + HBillType + "','" + sBarCode + "'," + HWhID.ToString() + "," + HSPID.ToString() + "," + dal.omodel_View.HMaterID.ToString() + "," + dal.omodel_View.HAuxPropID.ToString() + ",'" + dal.omodel_View.HBatchNo + "'," + sRelQty.ToString() + "," + HOWNERID.ToString(), "h_p_IF_CheckQtyByERPICInventory");
                            if (ds6 == null || ds6.Tables[0].Rows.Count == 0)
                            {
                                sErrMsg = "仓库内码错误!";
                                sErrMsg = "判断ERP库存,未知错误!";
                                return false;
                            }
                            else if (HSPID == 0 && DBUtility.ClsPub.isBool(ds3.Tables[0].Rows[0]["HSPFlag"]) == true)
                            else
                            {
                                sErrMsg = "仓位没有选择!";
                                return false;
                                if (DBUtility.ClsPub.isLong(ds6.Tables[0].Rows[0][0]) == 0)
                                {
                                    dal.omodel_View.HMaterID = DBUtility.ClsPub.isLong(ds6.Tables[0].Rows[0]["HMaterID"]);
                                    HQty = DBUtility.ClsPub.isDoule(ds6.Tables[0].Rows[0]["HQty"]);
                                }
                                else
                                {
                                    sErrMsg = DBUtility.ClsPub.isStrNull(ds6.Tables[0].Rows[0]["HRemark"]);
                                    return false;
                                }
                            }
                        }
                    }
@@ -30634,6 +31555,212 @@
        #region 扫描源单条码
        [WebMethod]
        public Model.ClsKf_ICStockBill_WMS get_CheckTypeBySource_New(Int64 HInterID, string HBillNo, string HBillType, string HSourceBillNo, string HSourceBillType, bool HRedBlueflag, string HHMaker, Int64 HOWNERID, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            Model.ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
            Int64 HAccessFlag = 0;   //是否物料条码带出源单信息标志(0为直接扫源单条码,1为物料条码带出源单信息)
            //获取系统参数
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref sErrMsg) == false)
            {
                sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";扫描源单时获取系统参数失败! " + sErrMsg;
                return null;
            }
            oBar = getSourceBillList_New(HInterID, HBillNo, HBillType, HSourceBillNo, HSourceBillType, HRedBlueflag, HHMaker, HOWNERID, HAccessFlag, oSystemParameter.omodel, ref sErrMsg);
            if (oBar == null)
            {
                sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";扫描源单失败!" + sErrMsg;
                return null;
            }
            else
            {
                return oBar;
            }
        }
        #endregion
        #region 将源单信息存入条码出入库临时表
        [WebMethod]
        public Model.ClsKf_ICStockBill_WMS getSourceBillList_New(Int64 HInterID, string HBillNo, string HBillType, string HSourceBillNo, string HSourceBillType, bool HRedBlueflag, string HHMaker, Int64 HOWNERID, Int64 HAccessFlag, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            Model.ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
            Int64 sMulSourceFlag = 0;   //多源单标志(0为非多源单模式,1为多源单模式)
            string sRedBlue = "蓝字";
            if (HRedBlueflag)
            {
                sRedBlue = "红字";
            }
            else
            {
                sRedBlue = "蓝字";
            }
            //多源单模式时,sMulSourceFlag = 1
            if (HBillType == "1202" && oSystemParameterMain.Kf_ProductInBill_MulSourceBill == "Y")
            {
                //生产入库单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1201" && oSystemParameterMain.Kf_POStockInBill_MulSourceBill == "Y")
            {
                //采购入库单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1210" && oSystemParameterMain.Kf_EntrustInBill_MulSourceBill == "Y")
            {
                //委外入库单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1204" && oSystemParameterMain.Kf_MateOutBill_MulSourceBill == "Y")
            {
                //生产领料单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1205" && oSystemParameterMain.Kf_SellOutBill_MulSourceBill == "Y")
            {
                //销售出库单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1211" && oSystemParameterMain.Kf_EntrustOutBill_MulSourceBill == "Y")
            {
                //委外出库单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "3711" && oSystemParameterMain.Sc_ICMOReportBill_MulSourceBill == "Y")
            {
                //生产汇报单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1254" && oSystemParameterMain.Kf_MateReplenishOutBill_MulSourceBill == "Y")
            {
                //生产补料单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1207" && oSystemParameterMain.Kf_MoveStockBill_MulSourceBill == "Y")
            {
                //直接调拨单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1250" && oSystemParameterMain.Kf_MoveStockStepOutBill_MulSourceBill == "Y")
            {
                //分步式调出单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1251" && oSystemParameterMain.Kf_MoveStockStepInBill_MulSourceBill == "Y")
            {
                //分步式调入单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1245" && oSystemParameterMain.Kf_ProductInBackBill_MulSourceBill == "Y")
            {
                //生产退库单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1239" && oSystemParameterMain.Kf_POStockInBackBill_MulSourceBill == "Y")
            {
                //采购退料单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1246" && oSystemParameterMain.Kf_EntrustInBackBill_MulSourceBill == "Y")
            {
                //委外退库单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1244" && oSystemParameterMain.Kf_MateOutBackBill_MulSourceBill == "Y")
            {
                //生产退料单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1247" && oSystemParameterMain.Kf_SellOutBackBill_MulSourceBill == "Y")
            {
                //销售退货单
                sMulSourceFlag = 1;
            }
            else if (HBillType == "1238" && oSystemParameterMain.Kf_EntrustOutBackBill_MulSourceBill == "Y")
            {
                //委外退料单
                sMulSourceFlag = 1;
            }
            DataSet ds1 = oCn.RunProcReturn("exec h_p_KF_PonderationBillMain_Temp_AddSource_New " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "','" + HSourceBillNo + "','" + HSourceBillType + "','" + sRedBlue + "'," + sMulSourceFlag.ToString() + ",'" + HHMaker + "'," + HOWNERID.ToString() + "," + HAccessFlag.ToString(), "h_p_KF_PonderationBillMain_Temp_AddSource_New");
            if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
            {
                sErrMsg = "将源单信息存入条码出入库临时表失败!";
                return null;
            }
            else
            {
                if (DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0][0]) == 0)
                {
                    oBar.HBarType = "源单条码";
                    oBar.HMulSourceFlag = sMulSourceFlag;
                    oBar.HSourceBillType = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HSourceBillType"]);
                    oBar.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HSourceBillNo"]);
                    oBar.HSupID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSupID"]);
                    oBar.HSupName = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HSupName"]);
                    oBar.HDeptID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HDeptID"]);
                    oBar.HDeptName = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HDeptName"]);
                    oBar.HCustom = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HCustom"]);
                    return oBar;
                }
                else
                {
                    sErrMsg = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HRemark"]);
                    return null;
                }
            }
        }
        #endregion
        #region 返回源单信息
        //根据所输源单号模糊查询源单信息,并返回数据(按源单选择按钮时调用)
        [WebMethod]
        public DataSet GetSourceBillList(Int64 HInterID, string HBillNo, string HBillType, string HSourceBillNo, string HSourceBillType, Int64 HOWNERID, ref string sErrMsg)
        {
            try
            {
                DataSet ds;
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn("exec h_p_WMS_SourceBillList " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "','" + HSourceBillNo + "','" + HSourceBillType + "'," + HOWNERID, "h_p_WMS_SourceBillList");
                if (ds == null && ds.Tables[0].Rows.Count == 0)
                {
                    sErrMsg = "返回源单列表信息失败,未知错误!";
                    return null;
                }
                else
                {
                    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 0)
                    {
                        return ds;
                    }
                    else
                    {
                        sErrMsg = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                        return null;
                    }
                }
            }
            catch (Exception e)
            {
                sErrMsg = "返回源单列表信息失败!" + e.Message;
                return null;
            }
        }
        #endregion
        #region  桌面条码生成外网版
        [WebMethod]