Exemplo n.º 1
0
        /// <summary>
        /// 发送改判信息给NC
        /// </summary>
        /// <param name="xmlFileName">xml完整路径</param>
        /// <returns></returns>
        public string SendXml_DM(string xmlFileName, string fydh)
        {
            try
            {
                string name = "FYSJ" + fydh + ".xml";
                xmlFileName += "\\NCXML\\" + name;
                Mod_TMD_DISPATCH modDispatch = dal_TMD_DISPATCH.GetModel(fydh);
                XmlDocument      xmlDoc      = new XmlDocument();
                //创建类型声明节点
                XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "no");
                xmlDoc.AppendChild(node);
                //创建根节点
                XmlElement root = xmlDoc.CreateElement("ufinterface");
                #region//给节点属性赋值
                root.SetAttribute("billtype", "7F");
                root.SetAttribute("filename", name);
                root.SetAttribute("isexchange", "Y");
                root.SetAttribute("operation", "req");
                root.SetAttribute("proc", "update");
                root.SetAttribute("receiver", "101");
                root.SetAttribute("replace", "Y");
                root.SetAttribute("roottag", "bill");
                root.SetAttribute("sender", "1107");
                #endregion
                xmlDoc.AppendChild(root);

                //创建子根节点
                XmlElement bill = xmlDoc.CreateElement("bill");
                bill.SetAttribute("id", modDispatch.C_GUID);//发运单表头主键
                root.AppendChild(bill);

                XmlNode head = xmlDoc.CreateNode(XmlNodeType.Element, "bill_head", null);

                #region                                                                                                   //表头_order_head
                CreateNode(xmlDoc, head, "apprdate", Convert.ToDateTime(modDispatch.D_APPROVE_DT).ToString("yyy-MM-dd")); //审批日期
                CreateNode(xmlDoc, head, "bconfirm", "N");
                CreateNode(xmlDoc, head, "billdate", Convert.ToDateTime(modDispatch.D_CREATE_DT).ToString("yyy-MM-dd"));  //制单日期
                CreateNode(xmlDoc, head, "billnewaddtime", Convert.ToDateTime(modDispatch.D_CREATE_DT).ToString("yyy-MM-dd HH:mm:ss"));
                CreateNode(xmlDoc, head, "bisopen", "");
                CreateNode(xmlDoc, head, "bmissionbill", "N");
                CreateNode(xmlDoc, head, "bmustreturnbillcode", "");
                CreateNode(xmlDoc, head, "btestbyinvoice", "");
                CreateNode(xmlDoc, head, "clastmodifierid", modDispatch.C_EMP_ID);//最后修改人
                CreateNode(xmlDoc, head, "clastmodiname", "");
                CreateNode(xmlDoc, head, "curbilltype", "");
                CreateNode(xmlDoc, head, "dallpacknum", "0");
                CreateNode(xmlDoc, head, "dallvolumn", "0");
                CreateNode(xmlDoc, head, "dallweight", "0");
                CreateNode(xmlDoc, head, "dfactweight", "");
                CreateNode(xmlDoc, head, "dr", "0");
                CreateNode(xmlDoc, head, "dtotal", "");
                CreateNode(xmlDoc, head, "employee", "");
                CreateNode(xmlDoc, head, "h_confirmarrivedate", "");
                CreateNode(xmlDoc, head, "iprintcount", "");
                CreateNode(xmlDoc, head, "isendtype", "3");//运费类别
                CreateNode(xmlDoc, head, "linkman1", "");
                CreateNode(xmlDoc, head, "oprdepartname", "");
                CreateNode(xmlDoc, head, "phone1", "");
                CreateNode(xmlDoc, head, "pk_defdoc0", modDispatch.C_IS_WIRESALE_ID); //是否线材销售主键
                CreateNode(xmlDoc, head, "pk_defdoc1", "");
                CreateNode(xmlDoc, head, "pk_defdoc10", "");
                CreateNode(xmlDoc, head, "pk_defdoc11", "");
                CreateNode(xmlDoc, head, "pk_defdoc12", "");
                CreateNode(xmlDoc, head, "pk_defdoc13", "");
                CreateNode(xmlDoc, head, "pk_defdoc14", "");
                CreateNode(xmlDoc, head, "pk_defdoc15", "");
                CreateNode(xmlDoc, head, "pk_defdoc16", "");
                CreateNode(xmlDoc, head, "pk_defdoc17", "");
                CreateNode(xmlDoc, head, "pk_defdoc18", "");
                CreateNode(xmlDoc, head, "pk_defdoc19", "");
                CreateNode(xmlDoc, head, "pk_defdoc2", "");
                CreateNode(xmlDoc, head, "pk_defdoc3", "");
                CreateNode(xmlDoc, head, "pk_defdoc4", "");
                CreateNode(xmlDoc, head, "pk_defdoc5", "");
                CreateNode(xmlDoc, head, "pk_defdoc6", "");
                CreateNode(xmlDoc, head, "pk_defdoc7", "");
                CreateNode(xmlDoc, head, "pk_defdoc8", "");
                CreateNode(xmlDoc, head, "pk_defdoc9", "");
                CreateNode(xmlDoc, head, "pk_delivbill_h", "");                       //发运单表头主键
                CreateNode(xmlDoc, head, "pkapprperson", "");
                CreateNode(xmlDoc, head, "pkbillperson", modDispatch.C_CREATE_ID);    //制单人
                CreateNode(xmlDoc, head, "pkcorpforgenoid", "1001");
                CreateNode(xmlDoc, head, "pkdelivmode", modDispatch.C_SHIPVIA);       //发运方式主键
                CreateNode(xmlDoc, head, "pkdelivorg", "1001NC10000000006EHS");       //发运组织主键固定
                CreateNode(xmlDoc, head, "pkdelivroute", "1001NC10000000006EHV");     //发运路线主键 固定
                CreateNode(xmlDoc, head, "pkdriver", "");
                CreateNode(xmlDoc, head, "pkoperator", modDispatch.C_BUSINESS_ID);    //业务员主键
                CreateNode(xmlDoc, head, "pkoprdepart", modDispatch.C_BUSINESS_DEPT); //业务部门主键
                CreateNode(xmlDoc, head, "pksendperson", "");
                CreateNode(xmlDoc, head, "pktrancust", modDispatch.C_COMCAR);         //承运商
                CreateNode(xmlDoc, head, "pktranorg", "");
                CreateNode(xmlDoc, head, "pkvehicle", "");
                CreateNode(xmlDoc, head, "pkvehicletype", "");
                CreateNode(xmlDoc, head, "returndate", "");
                CreateNode(xmlDoc, head, "returntime", "");
                CreateNode(xmlDoc, head, "senddate", Convert.ToDateTime(modDispatch.D_DISP_DT).ToString("yyy-MM-dd"));//发运日期
                CreateNode(xmlDoc, head, "startdate", "");
                CreateNode(xmlDoc, head, "starttime", "");
                CreateNode(xmlDoc, head, "taudittime", "");
                CreateNode(xmlDoc, head, "tlastmodifytime", Convert.ToDateTime(modDispatch.D_MOD_DT).ToString("yyy-MM-dd HH:mm:ss")); //最后修改时间
                CreateNode(xmlDoc, head, "tmaketime", Convert.ToDateTime(modDispatch.D_CREATE_DT).ToString("yyy-MM-dd HH:mm:ss"));    // 制单时间
                CreateNode(xmlDoc, head, "ts", Convert.ToDateTime(modDispatch.D_CREATE_DT).ToString("yyy-MM-dd HH:mm:ss"));
                CreateNode(xmlDoc, head, "userid", modDispatch.C_CREATE_ID);                                                          //制单人
                CreateNode(xmlDoc, head, "vapprpersonname", "");
                CreateNode(xmlDoc, head, "vbillpersonname", "");
                CreateNode(xmlDoc, head, "vdelivbillcode", modDispatch.C_ID);//发运单单据号
                CreateNode(xmlDoc, head, "vdoname", "");
                CreateNode(xmlDoc, head, "vdrivername", "");
                CreateNode(xmlDoc, head, "vehiclelicense", "");
                CreateNode(xmlDoc, head, "vnote", "");
                CreateNode(xmlDoc, head, "voldDelivbillcode", "");
                CreateNode(xmlDoc, head, "vroutedescr", "");
                CreateNode(xmlDoc, head, "vroutename", "");
                CreateNode(xmlDoc, head, "vsendtypename", "");
                CreateNode(xmlDoc, head, "vtranname", "");
                CreateNode(xmlDoc, head, "vtranorgname", "");
                CreateNode(xmlDoc, head, "vuserdef0", modDispatch.C_IS_WIRESALE);// 是否线材销售 是/ 否  *****
                CreateNode(xmlDoc, head, "vuserdef1", "");
                CreateNode(xmlDoc, head, "vuserdef10", "");
                CreateNode(xmlDoc, head, "vuserdef11", "");
                CreateNode(xmlDoc, head, "vuserdef12", "");
                CreateNode(xmlDoc, head, "vuserdef13", "");
                CreateNode(xmlDoc, head, "vuserdef14", "");
                CreateNode(xmlDoc, head, "vuserdef15", "");
                CreateNode(xmlDoc, head, "vuserdef16", "");
                CreateNode(xmlDoc, head, "vuserdef17", "");
                CreateNode(xmlDoc, head, "vuserdef18", "");
                CreateNode(xmlDoc, head, "vuserdef19", "");
                CreateNode(xmlDoc, head, "vuserdef2", "");
                CreateNode(xmlDoc, head, "vuserdef3", "Y");                      //是否已导出
                CreateNode(xmlDoc, head, "vuserdef4", modDispatch.C_LIC_PLA_NO); //车牌号
                CreateNode(xmlDoc, head, "vuserdef5", "");
                CreateNode(xmlDoc, head, "vuserdef6", "");
                CreateNode(xmlDoc, head, "vuserdef7", "");
                CreateNode(xmlDoc, head, "vuserdef8", "");
                CreateNode(xmlDoc, head, "vuserdef9", "");
                CreateNode(xmlDoc, head, "vvehiclename", "");
                CreateNode(xmlDoc, head, "vvhcltypename", "");

                #endregion

                bill.AppendChild(head);
                XmlElement body = xmlDoc.CreateElement("bill_body");
                bill.AppendChild(body);

                DataTable dt = GetZJBList(fydh).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int rowno = i + 1;

                        Mod_TMP_DAYPLAN modDayPlan = dal_TMP_DAYPLAN.GetModel(dt.Rows[i]["C_PLAN_ID"].ToString());
                        if (modDayPlan != null)
                        {
                            #region //实体参数

                            Mod_TMO_ORDER           modOrder           = dal_TMO_ORDER.GetModel(modDayPlan.C_PKBILLB);
                            Mod_TPB_LINEWH          mbck               = dal_TPB_LINEWH.GetModel_Interface_Trans(dt.Rows[i]["C_SEND_STOCK"].ToString()); //目标仓库
                            Mod_TPB_SLABWH          slabwh             = dal_TPB_SLABWH.GetModel_Interface_Trans(dt.Rows[i]["C_SEND_STOCK"].ToString());
                            Mod_TS_CUSTFILE         modCust            = dal_TS_CUSTFILE.GetCustModel(modDayPlan.C_PKCUST);                              //客户档案
                            Mod_TMB_AREA            modArea            = dal_TMB_AREA.GetModel(modDayPlan.C_PKARRIVEAREA);                               //区域
                            Mod_TB_MATRL_MAIN       modMat             = dal_TB_MATRL_MAIN.GetMatModel(modDayPlan.C_PKINV);                              //物料
                            Mod_TQB_CHECKSTATE      mod_TQB_CHECKSTATE = dal_TQB_CHECKSTATE.GetModelByName(dt.Rows[i]["C_ZLDJ"].ToString(), "1001");
                            Mod_TMD_DISPATCHDETAILS modfyditem         = dal_fyditem.GetModel(dt.Rows[i]["C_PK_NCID"].ToString());

                            string    addrpk   = "";
                            DataTable dtaddess = dal_TMB_AREA.GetAreaAddress(modfyditem.C_SEND_AREA).Tables[0];
                            if (dtaddess.Rows.Count > 0)
                            {
                                addrpk = dtaddess.Rows[0]["PK_ADDRESS"].ToString();
                            }
                            #endregion

                            decimal dunitprice = Convert.ToDecimal(modDayPlan.N_UNITPRICE); //含税单价
                            string  wgt        = dt.Rows[i]["N_JZ"].ToString();             //重量
                            string  num        = dt.Rows[i]["N_NUM"].ToString();            //数量
                            decimal dmoney     = dunitprice * Convert.ToDecimal(wgt);       //订单金额

                            XmlNode item = xmlDoc.CreateNode(XmlNodeType.Element, "item", null);

                            #region //表体_item
                            CreateNode(xmlDoc, item, "bappendent", "");
                            CreateNode(xmlDoc, item, "bcloseout", "");
                            CreateNode(xmlDoc, item, "bcloseout_old", "");
                            CreateNode(xmlDoc, item, "blargess", "N");
                            CreateNode(xmlDoc, item, "borderreturn", "N");
                            CreateNode(xmlDoc, item, "breceiveinform", "");
                            CreateNode(xmlDoc, item, "bsigned", "");
                            CreateNode(xmlDoc, item, "btestbyinvoice", "");
                            CreateNode(xmlDoc, item, "carrivecorpname", "");
                            CreateNode(xmlDoc, item, "cbiztype", modDayPlan.C_BIZTYPE);           //业务类型
                            CreateNode(xmlDoc, item, "ccheckstate_bid", mod_TQB_CHECKSTATE.C_ID); //质量等级**
                            CreateNode(xmlDoc, item, "ccheckstatename", "");
                            CreateNode(xmlDoc, item, "cfreezeid", "");
                            CreateNode(xmlDoc, item, "cinvmanid", "");
                            CreateNode(xmlDoc, item, "confirmarrivedate", "");
                            CreateNode(xmlDoc, item, "cquoteunitid", modDayPlan.C_UNITID);//报价计量单位ID
                            CreateNode(xmlDoc, item, "cquoteunitname", "");
                            CreateNode(xmlDoc, item, "creceiptcorp", "");
                            CreateNode(xmlDoc, item, "creceiptcorpid", modDayPlan.C_RECEIPTCORPID);//收货单位
                            CreateNode(xmlDoc, item, "csendcorp", "");
                            CreateNode(xmlDoc, item, "csendcorpid", "");
                            CreateNode(xmlDoc, item, "dcancelassistnum", "");
                            CreateNode(xmlDoc, item, "dcancelnum", "");
                            CreateNode(xmlDoc, item, "dfee", "");
                            CreateNode(xmlDoc, item, "dfeeitem", "");
                            CreateNode(xmlDoc, item, "dinvassist", num); //辅数量-件数
                            CreateNode(xmlDoc, item, "dinvnum", wgt);    //存货数量
                            CreateNode(xmlDoc, item, "dinvweight", "");
                            CreateNode(xmlDoc, item, "dmileage", "");
                            CreateNode(xmlDoc, item, "dmoney", dmoney.ToString());//订单金额
                            CreateNode(xmlDoc, item, "doutassistnum", "");
                            CreateNode(xmlDoc, item, "doutnum", "");
                            CreateNode(xmlDoc, item, "doutnummargin", "");
                            CreateNode(xmlDoc, item, "dpackboxnum", "");
                            CreateNode(xmlDoc, item, "dpacknum", "");
                            CreateNode(xmlDoc, item, "dpackvolumn", "");
                            CreateNode(xmlDoc, item, "dpackweight", "");
                            CreateNode(xmlDoc, item, "dr", "0");
                            CreateNode(xmlDoc, item, "dreturnassistnum", "");
                            CreateNode(xmlDoc, item, "dreturnnum", "");
                            CreateNode(xmlDoc, item, "dsignasnum", "");
                            CreateNode(xmlDoc, item, "dsignassistnum", "");
                            CreateNode(xmlDoc, item, "dsignnum", "");
                            CreateNode(xmlDoc, item, "dsourcerow", "");
                            CreateNode(xmlDoc, item, "dtotalout", "");
                            CreateNode(xmlDoc, item, "dunitprice", dunitprice.ToString());//含税单价
                            CreateNode(xmlDoc, item, "dvolumn", "");
                            CreateNode(xmlDoc, item, "dwaylossasnum", "");
                            CreateNode(xmlDoc, item, "dwaylossnum", "");
                            CreateNode(xmlDoc, item, "hsl", "");
                            CreateNode(xmlDoc, item, "iattitude", "");
                            CreateNode(xmlDoc, item, "ibatchstatus", "0");
                            CreateNode(xmlDoc, item, "ibetimes", "");
                            CreateNode(xmlDoc, item, "iloadnum", "");
                            CreateNode(xmlDoc, item, "ilockstatus", "");
                            CreateNode(xmlDoc, item, "ionroadtime", "");
                            CreateNode(xmlDoc, item, "ipacking", "");
                            CreateNode(xmlDoc, item, "irownumber", rowno.ToString());//行号
                            CreateNode(xmlDoc, item, "irowstatus", "0");
                            CreateNode(xmlDoc, item, "ischeckatp", "N");
                            CreateNode(xmlDoc, item, "linkman1", "");
                            CreateNode(xmlDoc, item, "nassistnetwgt", num);
                            CreateNode(xmlDoc, item, "nfeedbacknum", wgt);   //回写上游数量
                            CreateNode(xmlDoc, item, "nnetwgt", wgt);        //净重
                            CreateNode(xmlDoc, item, "nquoteunitnum", wgt);  //报价计量单位数量?-存货数量
                            CreateNode(xmlDoc, item, "nquoteunitrate", "1"); //报价计量单位换算率固定
                            CreateNode(xmlDoc, item, "ntotalshouldoutnum", "");
                            CreateNode(xmlDoc, item, "orderplantime", "");
                            CreateNode(xmlDoc, item, "packsortcode", "");
                            CreateNode(xmlDoc, item, "packsortname", "");
                            CreateNode(xmlDoc, item, "phone1", "");//****?
                            CreateNode(xmlDoc, item, "pk_corp", "");
                            CreateNode(xmlDoc, item, "pk_defdoc0", "");
                            CreateNode(xmlDoc, item, "pk_defdoc1", "");
                            CreateNode(xmlDoc, item, "pk_defdoc10", "");
                            CreateNode(xmlDoc, item, "pk_defdoc11", "");
                            CreateNode(xmlDoc, item, "pk_defdoc12", "");
                            CreateNode(xmlDoc, item, "pk_defdoc13", "");
                            CreateNode(xmlDoc, item, "pk_defdoc14", "");
                            CreateNode(xmlDoc, item, "pk_defdoc15", "");
                            CreateNode(xmlDoc, item, "pk_defdoc16", "");
                            CreateNode(xmlDoc, item, "pk_defdoc17", "");
                            CreateNode(xmlDoc, item, "pk_defdoc18", "");
                            CreateNode(xmlDoc, item, "pk_defdoc19", "");
                            CreateNode(xmlDoc, item, "pk_defdoc2", "");
                            CreateNode(xmlDoc, item, "pk_defdoc3", "");
                            CreateNode(xmlDoc, item, "pk_defdoc4", "");
                            CreateNode(xmlDoc, item, "pk_defdoc5", "");
                            CreateNode(xmlDoc, item, "pk_defdoc6", "");
                            CreateNode(xmlDoc, item, "pk_defdoc7", "");
                            CreateNode(xmlDoc, item, "pk_defdoc8", "");
                            CreateNode(xmlDoc, item, "pk_defdoc9", "");
                            CreateNode(xmlDoc, item, "pk_delivbill_b", "");                   //置空
                            CreateNode(xmlDoc, item, "pk_delivbill_h", "");
                            CreateNode(xmlDoc, item, "pk_invbasdoc", modOrder.C_INVBASDOCID); //存货档案主键
                            CreateNode(xmlDoc, item, "pk_packsort", "");
                            CreateNode(xmlDoc, item, "pk_transcontainer", "");
                            CreateNode(xmlDoc, item, "pkarriveaddress", addrpk);              //到货地点
                            CreateNode(xmlDoc, item, "pkarrivearea", modfyditem.C_SEND_AREA); //到货地区主键
                            CreateNode(xmlDoc, item, "pkarrivecorp", "");
                            CreateNode(xmlDoc, item, "pkassistmeasure", modOrder.C_FUNITID);  //辅计量单位
                            CreateNode(xmlDoc, item, "pkbasinv", modOrder.C_INVBASDOCID);     //存货档案主键
                            CreateNode(xmlDoc, item, "pkbasreceiptcorp", modCust.C_NC_ID);    //客户主键
                            CreateNode(xmlDoc, item, "pkbassendcorp", "");
                            CreateNode(xmlDoc, item, "pkconsign", "");
                            CreateNode(xmlDoc, item, "pkcorpforgenoid", modDayPlan.C_PKSALECORP); //销售公司(1001)
                            CreateNode(xmlDoc, item, "pkcusbasdoc", modCust.C_NC_ID);             //客户主键
                            CreateNode(xmlDoc, item, "pkcusmandoc", modDayPlan.C_PKCUST);         //客户管理主键
                            CreateNode(xmlDoc, item, "pkcustinvoice", "");
                            CreateNode(xmlDoc, item, "pkdayplan", "");
                            CreateNode(xmlDoc, item, "pkdestrep", "");
                            CreateNode(xmlDoc, item, "pkdeststockorg", "");
                            CreateNode(xmlDoc, item, "pkinv", modOrder.C_INVENTORYID);//存货管理档案主键
                            CreateNode(xmlDoc, item, "pkinvoice", "");
                            CreateNode(xmlDoc, item, "pkitem", "");
                            CreateNode(xmlDoc, item, "pkitemperiod", "");
                            CreateNode(xmlDoc, item, "pkoperator", modDayPlan.C_PKOPERATOR);   //业务员ID
                            CreateNode(xmlDoc, item, "pkoprdepart", modDayPlan.C_PKOPRDEPART); //业务员部门
                            CreateNode(xmlDoc, item, "pkorder", "");
                            CreateNode(xmlDoc, item, "pkorderplanid", "");
                            CreateNode(xmlDoc, item, "pkorderrow", "");
                            CreateNode(xmlDoc, item, "pkpackboxtype", "");
                            CreateNode(xmlDoc, item, "pksalecorp", "1001");
                            CreateNode(xmlDoc, item, "pksalegrp", modDayPlan.C_PKSALEORG);     //销售组织主键
                            CreateNode(xmlDoc, item, "pksendaddress", "0001AA1000000002LFNT"); //发货地点
                            CreateNode(xmlDoc, item, "pksendarea", "dqda0000000000000057");    //发货地区
                            if (mbck != null)
                            {
                                CreateNode(xmlDoc, item, "pksendstock", mbck.C_ID);//发货仓库
                            }
                            else
                            {
                                CreateNode(xmlDoc, item, "pksendstock", slabwh.C_ID);           //发货仓库
                            }
                            CreateNode(xmlDoc, item, "pksendstockorg", "1001NC10000000000669"); //发货库存组织主键-固定
                            CreateNode(xmlDoc, item, "pksrccalbodyar", "");
                            CreateNode(xmlDoc, item, "pkunit", "");
                            CreateNode(xmlDoc, item, "plantime", "");
                            CreateNode(xmlDoc, item, "receivedate", "");
                            CreateNode(xmlDoc, item, "requireday", Convert.ToDateTime(modDayPlan.D_REQUIREDATE).ToString("yyy-MM-dd")); //要求到货日期
                            CreateNode(xmlDoc, item, "sourcebillts", "");
                            CreateNode(xmlDoc, item, "ts", "");                                                                         //HH:mm:ss
                            CreateNode(xmlDoc, item, "ufdtmp", "");
                            CreateNode(xmlDoc, item, "userid", "");
                            CreateNode(xmlDoc, item, "varriveaddress", "其他地区");
                            CreateNode(xmlDoc, item, "vassistmeaname", "");
                            string batch = "";
                            if (modMat.C_MAT_TYPE == "6")
                            {
                                if (dt.Rows[i]["C_BATCH_NO"].ToString() != "")
                                {
                                    batch = dt.Rows[i]["C_BATCH_NO"].ToString();
                                }
                                else
                                {
                                    batch = dt.Rows[i]["C_STOVE"].ToString();
                                }
                            }
                            if (modMat.C_MAT_TYPE == "8")
                            {
                                batch = dt.Rows[i]["C_BATCH_NO"].ToString();
                            }
                            CreateNode(xmlDoc, item, "vbatchcode", batch);
                            CreateNode(xmlDoc, item, "vbilltype", "30");
                            CreateNode(xmlDoc, item, "vbilltypename", "");
                            CreateNode(xmlDoc, item, "vcargcode", "");
                            CreateNode(xmlDoc, item, "vconsign", "");
                            CreateNode(xmlDoc, item, "vcontainername", "");
                            CreateNode(xmlDoc, item, "vcustcode", modCust.C_NO);           //客户编码
                            CreateNode(xmlDoc, item, "vcustname", modCust.C_NAME);         //客户名称
                            CreateNode(xmlDoc, item, "vdayplancode", modDayPlan.C_PLCODE); //对应日计划单据号
                            CreateNode(xmlDoc, item, "vdestaddress", modfyditem.C_AREA);   //收货地址
                            CreateNode(xmlDoc, item, "vdestarea", modfyditem.C_SEND_AREA); //收货地区
                            CreateNode(xmlDoc, item, "vdeststoreaddre", "");
                            CreateNode(xmlDoc, item, "vdeststorename", "");
                            CreateNode(xmlDoc, item, "vdeststoreorgname", "");
                            CreateNode(xmlDoc, item, "vfree0", "");
                            CreateNode(xmlDoc, item, "vfree1", modDayPlan.C_VFREE1);                 //自由项1
                            CreateNode(xmlDoc, item, "vfree10", dt.Rows[i]["C_PK_NCID"].ToString()); //CRM发运单表体主键//C_PK_NCID
                            CreateNode(xmlDoc, item, "vfree2", modDayPlan.C_VFREE2);                 //自由项2
                            CreateNode(xmlDoc, item, "vfree3", dt.Rows[i]["C_BZYQ"].ToString());     //包装钢坯传空
                            CreateNode(xmlDoc, item, "vfree4", "");
                            CreateNode(xmlDoc, item, "vfree5", "");
                            CreateNode(xmlDoc, item, "vfree6", "");
                            CreateNode(xmlDoc, item, "vfree7", "");
                            CreateNode(xmlDoc, item, "vfree8", modDayPlan.C_ID);    //CRM发运日计划主键
                            CreateNode(xmlDoc, item, "vfree9", modDispatch.C_GUID); // CRM发运单表头主键
                            CreateNode(xmlDoc, item, "vfreeid1", "");
                            CreateNode(xmlDoc, item, "vfreeid10", "");
                            CreateNode(xmlDoc, item, "vfreeid2", "");
                            CreateNode(xmlDoc, item, "vfreeid3", "");
                            CreateNode(xmlDoc, item, "vfreeid4", "");
                            CreateNode(xmlDoc, item, "vfreeid5", "");
                            CreateNode(xmlDoc, item, "vfreeid6", "");
                            CreateNode(xmlDoc, item, "vfreeid7", "");
                            CreateNode(xmlDoc, item, "vfreeid8", "");
                            CreateNode(xmlDoc, item, "vfreeid9", "");
                            CreateNode(xmlDoc, item, "vfreename1", "");
                            CreateNode(xmlDoc, item, "vfreename10", "");
                            CreateNode(xmlDoc, item, "vfreename2", "");
                            CreateNode(xmlDoc, item, "vfreename3", "");
                            CreateNode(xmlDoc, item, "vfreename4", "");
                            CreateNode(xmlDoc, item, "vfreename5", "");
                            CreateNode(xmlDoc, item, "vfreename6", "");
                            CreateNode(xmlDoc, item, "vfreename7", "");
                            CreateNode(xmlDoc, item, "vfreename8", "");
                            CreateNode(xmlDoc, item, "vfreename9", "");
                            CreateNode(xmlDoc, item, "vinvcode", modMat.C_MAT_CODE);
                            CreateNode(xmlDoc, item, "vinvname", "");
                            CreateNode(xmlDoc, item, "vinvoicecode", "");
                            CreateNode(xmlDoc, item, "vitemname", "");
                            CreateNode(xmlDoc, item, "vitemperiodname", "");
                            CreateNode(xmlDoc, item, "vnote", "");
                            CreateNode(xmlDoc, item, "voperatorname", "");
                            CreateNode(xmlDoc, item, "voprdepartname", "");
                            CreateNode(xmlDoc, item, "vordercode", modDayPlan.C_SALECODE);//销售单据号
                            CreateNode(xmlDoc, item, "vreceiptcorpname", "");
                            CreateNode(xmlDoc, item, "vsalecorpname", "");
                            CreateNode(xmlDoc, item, "vsaleorgname", "");
                            CreateNode(xmlDoc, item, "vsendaddr", "");
                            CreateNode(xmlDoc, item, "vsendaddress", "");
                            CreateNode(xmlDoc, item, "vsendarea", "");
                            CreateNode(xmlDoc, item, "vsendcorpname", "");
                            CreateNode(xmlDoc, item, "vsendstoreaddre", "");
                            CreateNode(xmlDoc, item, "vsendstorename", "");
                            CreateNode(xmlDoc, item, "vsendstoreorgaddre", "");
                            CreateNode(xmlDoc, item, "vsendstoreorgname", "");
                            CreateNode(xmlDoc, item, "vsignname", "");
                            CreateNode(xmlDoc, item, "vsignnote", "");
                            CreateNode(xmlDoc, item, "vspec", modMat.C_SPEC);           //规格
                            CreateNode(xmlDoc, item, "vsrccalbodyarname", "");
                            CreateNode(xmlDoc, item, "vtype", modMat.C_STL_GRD);        //钢种
                            CreateNode(xmlDoc, item, "vunit", modMat.C_ZJLDWMC);        //主计量单位名称
                            CreateNode(xmlDoc, item, "vuserdef0", "");
                            CreateNode(xmlDoc, item, "vuserdef1", "");                  //计量毛重日期*****
                            CreateNode(xmlDoc, item, "vuserdef10", modDayPlan.C_CONNO); //合同号
                            CreateNode(xmlDoc, item, "vuserdef11", "");
                            CreateNode(xmlDoc, item, "vuserdef12", "");
                            CreateNode(xmlDoc, item, "vuserdef13", "");
                            CreateNode(xmlDoc, item, "vuserdef14", "");
                            CreateNode(xmlDoc, item, "vuserdef15", "");
                            CreateNode(xmlDoc, item, "vuserdef16", "");
                            CreateNode(xmlDoc, item, "vuserdef17", "");
                            CreateNode(xmlDoc, item, "vuserdef18", "");
                            CreateNode(xmlDoc, item, "vuserdef19", "");
                            CreateNode(xmlDoc, item, "vuserdef2", ""); //毛重*****
                            CreateNode(xmlDoc, item, "vuserdef3", ""); //计量皮重日期****
                            CreateNode(xmlDoc, item, "vuserdef4", ""); //皮重
                            CreateNode(xmlDoc, item, "vuserdef5", ""); //净重
                            CreateNode(xmlDoc, item, "vuserdef6", ""); //计量毛重时间
                            CreateNode(xmlDoc, item, "vuserdef7", ""); //计量皮重时间
                            CreateNode(xmlDoc, item, "vuserdef8", "");
                            CreateNode(xmlDoc, item, "vuserdef9", "");
                            #endregion

                            body.AppendChild(item);
                        }
                    }
                }
                xmlDoc.Save(xmlFileName);
                List <string> parem = dalSendNC.SendXML(xmlFileName);
                if (parem[0] == "1")
                {
                    return("1");
                }
                else
                {
                    return(parem[1]);
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 上传NC
        /// </summary>
        /// <param name="list">委外组批计划ID(组批计划包含完工信息)</param>
        public void SendToNC(List <string> list)
        {
            if (list.Any() == false)
            {
                throw new Exception("请选择后再上传");
            }

            var ids        = "('" + string.Join("','", list) + "')";
            var updateMods = dalWWMain.GetList($"C_ID IN {ids}").Tables[0].DataTableToList2 <Mod_TRC_ROLL_WW_MAIN>();

            if (updateMods.Any() == false)
            {
                throw new Exception("没有需要上传NC的数据");
            }

            if (updateMods.Any(w => w.N_STATUS < 1 || w.N_STATUS == 30))
            {
                throw new Exception("只有状态为已完工或未上传完毕的,才能上传NC");
            }

            foreach (var item in updateMods)
            {
                if (string.IsNullOrEmpty(item.C_PRODUCE_EMP_ID))
                {
                    item.C_PRODUCE_EMP_ID = "1001NC100000002SS9XB";
                }

                if (string.IsNullOrEmpty(item.C_EMP_ID))
                {
                    item.C_EMP_ID = "1001NC100000002SS9XB";
                }

                // 获取用户信息
                var planUser    = dalUser.GetModel(item.C_EMP_ID);         // 组批计划员
                var productUser = dalUser.GetModel(item.C_PRODUCE_EMP_ID); // 生产人员

                // 合同信息
                var contractInfo = dalOrder.GetModel(item.C_ORD_ID);

                if (contractInfo == null)
                {
                    continue;
                }

                // 订单物料信息
                var ordMatrl = bll_TB_MATRL_MAIN.GetModel(contractInfo.C_MAT_CODE);

                if (contractInfo == null)
                {
                    continue;
                }

                // 耗用线材物料信息
                var consumeMatrl = bll_TB_MATRL_MAIN.GetModel(item.C_MAT_XC_CODE);

                if (consumeMatrl == null)
                {
                    continue;
                }
                // 线材批次信息
                var xcBatchInfo = dalWWMain.GetItemList(item.C_ID).FirstOrDefault();
                if (xcBatchInfo == null)
                {
                    continue;
                }

                if (contractInfo == null || ordMatrl == null)
                {
                    continue;
                }

                // 传入外委物料代码决定工序,获取ERP代码
                var mod_TB_STA = dalTbSta.GetModelByCODE(Bll_TRC_ROLL_PRODCUT.GetStaCode(contractInfo.C_MAT_CODE));

                if (item.N_STATUS == 1)
                {
                    // 上传NC
                    var itemA1   = GetA1(contractInfo, ordMatrl, item, mod_TB_STA, planUser);
                    var a1Result = dalA1.SendXml_ROLL_A1(item.C_ID, string.Empty, "A1.xml", itemA1, AppDomain.CurrentDomain.BaseDirectory);

                    if (NCInterface.NCConfig.IsSendToNC)
                    {
                        // 状态0创建,10完工,21已传NC_A1,22已传NC_A2,23已传NC_A3,24已传NC_A4,25已传NC_A46,30上传NC完毕,
                        if (a1Result[0] == "1")
                        {
                            // 上传成功,更新状态
                            item.N_STATUS = 21;
                            dalWWMain.SetStatu(item);
                        }
                        else
                        {
                            throw new Exception(GetNCError(a1Result));
                        }
                    }
                }

                if (item.N_STATUS == 21)
                {
                    // 上传NC
                    var itemA2   = GetA2(contractInfo, ordMatrl, item, mod_TB_STA, planUser);
                    var a2Result = dalA2.SendXml_ROLL_A2(item.C_ID, string.Empty, "A2.xml", itemA2, AppDomain.CurrentDomain.BaseDirectory);

                    if (NCInterface.NCConfig.IsSendToNC)
                    {
                        if (a2Result[0] == "1")
                        {
                            item.N_STATUS = 22;
                            // 上传成功,更新状态
                            dalWWMain.SetStatu(item);
                        }
                        else
                        {
                            throw new Exception(GetNCError(a2Result));
                        }
                    }
                }

                if (item.N_STATUS == 22)
                {
                    // 上传NC
                    var itemA3   = GetA3(contractInfo, ordMatrl, consumeMatrl, item, mod_TB_STA, xcBatchInfo);
                    var a3Result = dalA3.SendXml_ROLL_A3(item.C_ID, string.Empty, "A3.xml", itemA3, AppDomain.CurrentDomain.BaseDirectory);

                    if (NCInterface.NCConfig.IsSendToNC)
                    {
                        if (a3Result[0] == "1")
                        {
                            // 上传成功,更新状态
                            item.N_STATUS = 23;
                            dalWWMain.SetStatu(item);
                        }
                        else
                        {
                            throw new Exception(GetNCError(a3Result));
                        }
                    }
                }

                if (item.N_STATUS == 23)
                {
                    // 上传NC
                    var itemA4   = GetA4(contractInfo, ordMatrl, item, mod_TB_STA, productUser);
                    var a4Result = dalA4.SendXml_ROLL_A4(item.C_ID, string.Empty, item.C_ID + "A4.xml", itemA4, AppDomain.CurrentDomain.BaseDirectory);

                    if (NCInterface.NCConfig.IsSendToNC)
                    {
                        if (a4Result[0] == "1")
                        {
                            item.N_STATUS = 24;
                            // 上传成功,更新状态
                            dalWWMain.SetStatu(item);
                        }
                        else
                        {
                            throw new Exception(GetNCError(a4Result));
                        }
                    }
                }

                if (item.N_STATUS == 24)
                {
                    // 上传NC
                    var item46    = Get46(contractInfo, ordMatrl, item, mod_TB_STA, productUser);
                    var a46Result = dal46.SendXml_ROLL_46(item.C_ID, string.Empty, "A46.xml", new List <NcRoll46> {
                        item46
                    }, AppDomain.CurrentDomain.BaseDirectory);

                    if (NCInterface.NCConfig.IsSendToNC)
                    {
                        if (a46Result[0] == "1")
                        {
                            item.N_STATUS = 25;
                            dalWWMain.SetStatu(item);
                        }
                        else
                        {
                            throw new Exception(GetNCError(a46Result));
                        }
                    }
                }
                if (item.N_STATUS == 25)
                {
                    // 入库操作
                    RuKu(item, mod_TB_STA, contractInfo);
                    // 更新状态
                    item.N_STATUS = 30;
                    dalWWMain.SetStatu(item);

                    dalWWMain.SetDesignNo(item);
                }
                else
                {
                    throw new Exception("上传NC失败");
                }
            }
        }
        /// <summary>
        /// 发送炉次计划给NC
        /// </summary>
        /// <param name="xmlFileName">xml完整路径</param>
        /// <param name="urlname">xml名称</param>
        /// <param name="urlname">计划表主键</param>
        /// <param name="c_stove">炉号</param>
        /// <returns></returns>
        public bool SendXml_SLAB_A2(string xmlFileName, string tsp_plan_sms_id, string stove)
        {
            try
            {
                string urlname = "A2LC" + stove + ".XML";//XML名称

                string url = xmlFileName + "\\NCXML";
                if (!Directory.Exists(url))
                {
                    Directory.CreateDirectory(url);
                }
                //DataTable dt = dal_slab_mes.GetList("", "", stove, "", "").Tables[0];
                Mod_TSP_PLAN_SMS  mod_plan_sms   = dal_plan_sms.GetModel(tsp_plan_sms_id);           //连铸生产计划表
                Mod_TPP_CAST_PLAN mod_cast_plan  = dal_cast_plan.GetModel_PLAN_ID(tsp_plan_sms_id);
                Mod_TB_MATRL_MAIN mod_mater_main = dal_mater_main.GetModel(mod_plan_sms.C_MATRL_NO); //物料主表
                Mod_TS_USER       mod_ts_user    = dal_user.GetModel(mod_plan_sms.C_EMP_ID);         //用户主表
                Mod_TMO_ORDER     mod_Order      = dal_tmo_order.GetModel(mod_plan_sms.C_ORDER_NO);
                Mod_TB_STA        modSta         = dalSta.GetModel(mod_plan_sms.C_CCM_ID);
                if (mod_plan_sms == null)
                {
                    return(false);
                }
                if (mod_cast_plan == null)
                {
                    return(false);
                }
                if (mod_mater_main == null)
                {
                    return(false);
                }
                if (mod_ts_user == null)
                {
                    return(false);
                }
                if (mod_Order == null)
                {
                    return(false);
                }
                if (modSta == null)
                {
                    return(false);
                }


                XmlDocument xmlDoc = new XmlDocument();
                //创建类型声明节点
                XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "no");
                xmlDoc.AppendChild(node);

                //创建根节点
                XmlElement root = xmlDoc.CreateElement("ufinterface");
                #region//给节点属性赋值
                root.SetAttribute("billtype", "A2");
                root.SetAttribute("filename", "");
                root.SetAttribute("isexchange", "Y");
                root.SetAttribute("operation", "req");
                root.SetAttribute("proc", "add");
                root.SetAttribute("receiver", "101");
                root.SetAttribute("replace", "Y");
                root.SetAttribute("roottag", "bill");
                root.SetAttribute("sender", "1107");
                #endregion
                xmlDoc.AppendChild(root);

                //创建子根节点
                XmlElement bill = xmlDoc.CreateElement("bill");
                #region//节点属性
                bill.SetAttribute("id", mod_cast_plan.C_HEAT_ID);
                #endregion
                root.AppendChild(bill);

                XmlNode head = xmlDoc.CreateNode(XmlNodeType.Element, "bill_head", null);

                #region                                                                                                                          //表头_order_head
                CreateNode(xmlDoc, head, "scddh", "");                                                                                           //生产订单号 (空)
                CreateNode(xmlDoc, head, "pk_poid", "");                                                                                         //计划订单主键 (空)
                CreateNode(xmlDoc, head, "jhddh", "");                                                                                           //计划订单号 (空)
                CreateNode(xmlDoc, head, "wlbmid", mod_mater_main.C_PK_INVBASDOC);                                                               //物料编码ID (C_PK_INVBASDOC)
                CreateNode(xmlDoc, head, "pk_produce", "");                                                                                      //物料PK
                CreateNode(xmlDoc, head, "invcode", mod_mater_main.C_ID);                                                                        //物料编码
                CreateNode(xmlDoc, head, "invname", "");
                CreateNode(xmlDoc, head, "pch", stove);                                                                                          //批次号
                CreateNode(xmlDoc, head, "scbmid", "1001NC1000000000037T");                                                                      //生产部门ID
                CreateNode(xmlDoc, head, "gzzxid", modSta.C_ERP_PK);                                                                             //工作中心ID-连铸机号
                CreateNode(xmlDoc, head, "gzzxbm", "");                                                                                          //工作中心编码ID
                CreateNode(xmlDoc, head, "ksid", "");                                                                                            //客商ID
                CreateNode(xmlDoc, head, "memo", "");                                                                                            //备注
                CreateNode(xmlDoc, head, "sfjj", "");                                                                                            //是否加急
                CreateNode(xmlDoc, head, "yxj", "");                                                                                             //有效机时
                CreateNode(xmlDoc, head, "bcid", "1001NC1000000000103W");                                                                        //班次ID
                CreateNode(xmlDoc, head, "bzid", "1001NC100000002E7W1K");                                                                        //班组
                CreateNode(xmlDoc, head, "jhkgrq", Convert.ToDateTime(mod_plan_sms.D_P_START_TIME.ToString()).ToString("yyyy-MM-dd"));           //计划开工日期
                CreateNode(xmlDoc, head, "jhwgrq", Convert.ToDateTime(mod_plan_sms.D_P_END_TIME.ToString()).ToString("yyyy-MM-dd"));             //计划完工日期
                CreateNode(xmlDoc, head, "jhkssj", Convert.ToDateTime(mod_plan_sms.D_P_START_TIME.ToString()).ToString("HH:mm:ss"));             //计划开始时间
                CreateNode(xmlDoc, head, "jhjssj", Convert.ToDateTime(mod_plan_sms.D_P_END_TIME.ToString()).ToString("HH:mm:ss"));               //计划结束时间
                CreateNode(xmlDoc, head, "sjkgrq", Convert.ToDateTime(mod_cast_plan.D_AIM_CASTINGSTART_TIME.ToString()).ToString("yyyy-MM-dd")); //实际开工日期
                CreateNode(xmlDoc, head, "sjwgrq", Convert.ToDateTime(mod_cast_plan.D_AIM_CASTINGEND_TIME.ToString()).ToString("yyyy-MM-dd"));   //实际完工日期
                CreateNode(xmlDoc, head, "sjkssj", Convert.ToDateTime(mod_cast_plan.D_AIM_CASTINGSTART_TIME.ToString()).ToString("HH:mm:ss"));   //实际开始时间
                CreateNode(xmlDoc, head, "sjjssj", Convert.ToDateTime(mod_cast_plan.D_AIM_CASTINGEND_TIME.ToString()).ToString("HH:mm:ss"));     //实际结束时间
                CreateNode(xmlDoc, head, "jhwgsl", mod_plan_sms.N_SLAB_WGT.ToString());                                                          //计划完工数量
                CreateNode(xmlDoc, head, "fjhsl", mod_plan_sms.C_QUA);                                                                           //辅计量数量
                CreateNode(xmlDoc, head, "jldwid", mod_mater_main.C_PK_MEASDOC);                                                                 //计量单位ID
                CreateNode(xmlDoc, head, "fjlid", mod_mater_main.C_FJLDW);                                                                       //辅计量ID
                CreateNode(xmlDoc, head, "sjwgsl", mod_plan_sms.N_SLAB_WGT.ToString());                                                          //实际完工数量
                CreateNode(xmlDoc, head, "fwcsl", "");
                CreateNode(xmlDoc, head, "zdy1", "");                                                                                            //自定义项1
                CreateNode(xmlDoc, head, "zdy2", "");                                                                                            //自定义项2
                CreateNode(xmlDoc, head, "zdy3", "");                                                                                            //自定义项3
                CreateNode(xmlDoc, head, "zdy4", "");                                                                                            //自定义项4
                CreateNode(xmlDoc, head, "zdy5", "");                                                                                            //自定义项5
                CreateNode(xmlDoc, head, "freeitemvalue1", mod_Order.C_FREE1);
                CreateNode(xmlDoc, head, "freeitemvalue2", mod_Order.C_FREE2);
                CreateNode(xmlDoc, head, "freeitemvalue3", "");
                CreateNode(xmlDoc, head, "freeitemvalue4", "");
                CreateNode(xmlDoc, head, "freeitemvalue5", mod_plan_sms.C_ID); //PCI计划订单主键(tsp_plan_sms主键)
                CreateNode(xmlDoc, head, "pk_corp", "1001");                   //公司ID
                CreateNode(xmlDoc, head, "gcbm", "1001NC10000000000669");      //工厂
                CreateNode(xmlDoc, head, "zdrid", mod_ts_user.C_ACCOUNT);      //制单人
                CreateNode(xmlDoc, head, "pk_moid", "");                       //生产定单ID

                #endregion

                bill.AppendChild(head);
                XmlElement body = xmlDoc.CreateElement("bill_body");
                bill.AppendChild(body);

                XmlNode item = xmlDoc.CreateNode(XmlNodeType.Element, "item", null);


                body.AppendChild(item);


                xmlDoc.Save(url + "\\" + urlname);
                List <string> parem = dalSendNC.SendXML(url + "\\" + urlname);

                if (parem[0] == "1")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// 发送计划给NC
        /// </summary>
        /// <param name="xmlFileName">xml完整路径</param>
        /// <param name="tsp_plan_sms_id">炉号</param>
        /// <param name="stove">炉号</param>
        /// <returns></returns>
        public string SendXml_SLAB_A1(string xmlFileName, string tsp_plan_sms_id, string stove)
        {
            try
            {
                string urlname = "A1ED" + stove + ".XML";//XML名称

                string url = xmlFileName + "\\NCXML";
                if (!Directory.Exists(url))
                {
                    Directory.CreateDirectory(url);
                }

                Mod_TSP_PLAN_SMS  mod_plan_sms   = dal_plan_sms.GetModel_Trans(tsp_plan_sms_id);     //连铸生产计划表
                Mod_TB_MATRL_MAIN mod_mater_main = dal_mater_main.GetModel(mod_plan_sms.C_MATRL_NO); //物料主表
                Mod_TMO_ORDER     mod_Order      = dal_tmo_order.GetModel(mod_plan_sms.C_ORDER_NO);
                Mod_TB_STA        modSta         = dalSta.GetModel(mod_plan_sms.C_CCM_ID);
                if (mod_plan_sms == null)
                {
                    return("获取连铸计划失败!");
                }
                if (mod_mater_main == null)
                {
                    return("获取物料信息失败!");
                }
                if (mod_Order == null)
                {
                    return("获取订单信息失败!");
                }
                if (modSta == null)
                {
                    return("获取工位信息失败!");
                }
                XmlDocument xmlDoc = new XmlDocument();
                //创建类型声明节点
                XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "no");
                xmlDoc.AppendChild(node);

                //创建根节点
                XmlElement root = xmlDoc.CreateElement("ufinterface");
                #region//给节点属性赋值
                root.SetAttribute("account", "1");
                root.SetAttribute("billtype", "A1");
                root.SetAttribute("filename", urlname);
                root.SetAttribute("isexchange", "Y");
                root.SetAttribute("proc", "add");
                root.SetAttribute("receiver", "101");
                root.SetAttribute("replace", "Y");
                root.SetAttribute("roottag", "bill");
                root.SetAttribute("sender", "1107");
                #endregion
                xmlDoc.AppendChild(root);

                //创建子根节点
                XmlElement so_order = xmlDoc.CreateElement("bill");
                //#region//节点属性
                //so_order.SetAttribute("id", dayplcode);
                //#endregiond
                root.AppendChild(so_order);

                XmlNode head = xmlDoc.CreateNode(XmlNodeType.Element, "billhead", null);

                #region                                                   //表头_order_head

                CreateNode(xmlDoc, head, "bgbz", "1");                    //变更标志
                CreateNode(xmlDoc, head, "bmid", "1001NC10000000000345"); //部门ID
                CreateNode(xmlDoc, head, "bmmc", "");                     //部门名称
                CreateNode(xmlDoc, head, "bomver", "");                   //BOM版本
                CreateNode(xmlDoc, head, "busiDate", "");
                CreateNode(xmlDoc, head, "ckbm", "");                     //仓库编码
                CreateNode(xmlDoc, head, "ckbmid", "");                   //仓库编码ID
                CreateNode(xmlDoc, head, "ckmc", "");                     //仓库名称
                CreateNode(xmlDoc, head, "curwwsl", "");
                CreateNode(xmlDoc, head, "ddlx", "1");                    //订单类型
                CreateNode(xmlDoc, head, "ddlxshow", "");
                CreateNode(xmlDoc, head, "durl", "");                     //资料路径
                CreateNode(xmlDoc, head, "fah", "");
                CreateNode(xmlDoc, head, "fjbz", "0");                    //分解标记
                CreateNode(xmlDoc, head, "fjldwid", "");                  //辅计量单位ID
                CreateNode(xmlDoc, head, "fjldwmc", "");
                CreateNode(xmlDoc, head, "gcbm", "1001NC10000000000669"); //工厂
                CreateNode(xmlDoc, head, "gcbmcode", "");
                CreateNode(xmlDoc, head, "graphid", "");
                CreateNode(xmlDoc, head, "gzzxbm", ""); //工作中心编码ID
                CreateNode(xmlDoc, head, "gzzxid", ""); //工作中心ID
                CreateNode(xmlDoc, head, "gzzxmc", ""); //工作中心名称
                CreateNode(xmlDoc, head, "hbbz", "0");  //合并标志
                CreateNode(xmlDoc, head, "hsl", "");    //换算率
                CreateNode(xmlDoc, head, "invspec", "");
                CreateNode(xmlDoc, head, "invtype", "");
                CreateNode(xmlDoc, head, "jhbmbm", "");
                CreateNode(xmlDoc, head, "jhddh", "");                                                                    //计划订单号
                CreateNode(xmlDoc, head, "jhfaid", mod_mater_main.C_PK_PSID);                                             //计划方案ID
                CreateNode(xmlDoc, head, "jhlx", "0");                                                                    //备料计划类型(固定)
                CreateNode(xmlDoc, head, "jhrq", Convert.ToDateTime(mod_plan_sms.D_P_START_TIME).ToString("yyyy-MM-dd")); //计划日期
                CreateNode(xmlDoc, head, "jhxxsl", "");                                                                   //计划下限数量
                CreateNode(xmlDoc, head, "jhyid", mod_mater_main.C_PLANEMP);                                              //计划员ID
                CreateNode(xmlDoc, head, "jldw", "");                                                                     //计量单位
                CreateNode(xmlDoc, head, "jldwid", mod_mater_main.C_PK_MEASDOC);                                          //计量单位ID
                CreateNode(xmlDoc, head, "ksid", "");                                                                     //客商ID
                CreateNode(xmlDoc, head, "memo", "");                                                                     //备注
                CreateNode(xmlDoc, head, "pch", "");                                                                      //批次号
                CreateNode(xmlDoc, head, "pk_corp", "1001");                                                              //公司
                CreateNode(xmlDoc, head, "pk_poid", "");                                                                  //计划订单主键
                CreateNode(xmlDoc, head, "pk_produce", mod_mater_main.C_PK_PRODUCE);                                      //物料PK
                CreateNode(xmlDoc, head, "primaryKey", "");
                CreateNode(xmlDoc, head, "pzh", "");                                                                      //配置号
                CreateNode(xmlDoc, head, "qrrid", "");
                CreateNode(xmlDoc, head, "qrrq", "");
                CreateNode(xmlDoc, head, "rtver", "");
                CreateNode(xmlDoc, head, "scbmbm", "");
                CreateNode(xmlDoc, head, "scbmid", modSta.C_SSBMID);//生产部门ID
                CreateNode(xmlDoc, head, "scbmmc", "");
                CreateNode(xmlDoc, head, "scbz", "1");
                CreateNode(xmlDoc, head, "scxid", "");
                CreateNode(xmlDoc, head, "shrid", mod_plan_sms.C_EMP_ID);                                                 //操作人员
                CreateNode(xmlDoc, head, "shrq", Convert.ToDateTime(mod_plan_sms.D_P_START_TIME).ToString("yyyy-MM-dd")); //审核日期
                CreateNode(xmlDoc, head, "slrq", Convert.ToDateTime(mod_Order.D_NEED_DT).ToString("yyyy-MM-dd"));         //需求日期
                CreateNode(xmlDoc, head, "unitcode", "");
                CreateNode(xmlDoc, head, "userid", "");
                CreateNode(xmlDoc, head, "wlbm", "");
                CreateNode(xmlDoc, head, "wlbmid", mod_mater_main.C_PK_INVBASDOC);
                CreateNode(xmlDoc, head, "wlmc", "");
                CreateNode(xmlDoc, head, "wpcsl", "0.00000000");
                CreateNode(xmlDoc, head, "wwlx", "OA");
                CreateNode(xmlDoc, head, "xdrq", Convert.ToDateTime(mod_plan_sms.D_P_START_TIME).ToString("yyyy-MM-dd")); //下单日期
                CreateNode(xmlDoc, head, "xqfsl", "");
                CreateNode(xmlDoc, head, "xqrq", Convert.ToDateTime(mod_Order.D_DELIVERY_DT).ToString("yyyy-MM-dd"));     //交货日期
                CreateNode(xmlDoc, head, "xqsl", mod_Order.N_WGT.ToString());                                             //计划量
                CreateNode(xmlDoc, head, "xsddh", "");
                CreateNode(xmlDoc, head, "xsddid", "");
                CreateNode(xmlDoc, head, "xxbz", "0");
                CreateNode(xmlDoc, head, "yfjsl", "");
                CreateNode(xmlDoc, head, "ypcsl", "");
                CreateNode(xmlDoc, head, "ywwsl", "");
                CreateNode(xmlDoc, head, "zdrid", mod_plan_sms.C_EMP_ID);                                           //制单人ID
                CreateNode(xmlDoc, head, "zdrmc", "");
                CreateNode(xmlDoc, head, "zdrq", Convert.ToDateTime(mod_plan_sms.D_MOD_DT).ToString("yyyy-MM-dd")); //制单日期
                CreateNode(xmlDoc, head, "zdy1", "");
                CreateNode(xmlDoc, head, "zdy2", "其它要求");
                CreateNode(xmlDoc, head, "zdy3", "");
                CreateNode(xmlDoc, head, "zdy4", "");
                CreateNode(xmlDoc, head, "zdy5", "");
                CreateNode(xmlDoc, head, "zt", "B");
                CreateNode(xmlDoc, head, "zyx1", mod_Order.C_FREE1); //自由项1
                CreateNode(xmlDoc, head, "zyx2", mod_Order.C_FREE2); //自由项2
                CreateNode(xmlDoc, head, "zyx3", "");                //自由项3
                CreateNode(xmlDoc, head, "zyx4", "");
                CreateNode(xmlDoc, head, "zyx5", mod_Order.C_ID);    //pci主键
                #endregion

                so_order.AppendChild(head);

                xmlDoc.Save(url + "\\" + urlname);
                List <string> parem = dalSendNC.SendXML(url + "\\" + urlname);

                if (parem[0] == "1")
                {
                    return("1");
                }
                else
                {
                    return(parem[1].ToString());
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Mod_TMO_ORDER GetModel(string C_ID)
 {
     return(dal.GetModel(C_ID));
 }