/// <summary>
        /// 上上报机制 节点上报
        /// </summary>
        /// <param name="senderCodeList"></param>
        /// <param name="loginkNode"></param>
        /// <param name="nodeInfo"></param>
        /// <returns></returns>
        public static XML GetWaitUploadNode(List <string> senderCodeList, ref M_TMSNode loginkNode, ref NodeInfo nodeInfo)
        {
            XML result = null;

            try
            {
                nodeInfo = GetWaitUploadNode(senderCodeList);
                if (nodeInfo != null)
                {
                    result             = new XML();
                    result.CONTENTLIST = new List <CONTENT>();
                    result.CONTENTLIST.Add(new CONTENT());
                    result.CONTENTLIST[0].DETAILLIST = new List <DETAIL>();

                    string driverInfo = ((nodeInfo.Driver == null ? string.Empty : nodeInfo.Driver) + " " + (nodeInfo.DriverTel == null ? string.Empty : nodeInfo.DriverTel)).Trim();
                    string trackType  = "17";
                    if (nodeInfo.ParentStorageId == 0)
                    {
                        trackType = "15";//启运
                    }
                    else if (nodeInfo.Arrived == 2)
                    {
                        trackType = "18";//正常签收
                    }
                    else if (nodeInfo.StorageType == 1)
                    {
                        trackType = "16";//到中转站
                    }
                    else
                    {
                        trackType = "17";//中转站驾驶员已接单出发
                    }
                    //if (senderCodeList != null)
                    //{
                    loginkNode             = new M_TMSNode();
                    loginkNode.JcOrderNo   = nodeInfo.ScanNumber;
                    loginkNode.JcNodeId    = nodeInfo.Id;
                    loginkNode.TrackPerson = driverInfo;
                    loginkNode.TrackInfo   = nodeInfo.Content;
                    loginkNode.TrackTime   = DateTime.Parse(nodeInfo.OperateAt);
                    loginkNode.Arrived     = nodeInfo.Arrived;
                    loginkNode.OrderNo     = nodeInfo.ScanNumber;
                    loginkNode.TrackType   = trackType;
                    loginkNode.StorageName = nodeInfo.StorageName;
                    //}
                    //else
                    //{
                    DETAIL d = new DETAIL();
                    d.ECNO        = nodeInfo.ShipmentCode;
                    d.CECNO       = nodeInfo.ScanNumber;
                    d.LEGNO       = nodeInfo.ScanNumber;
                    d.TRACKTIME   = DateTime.Parse(nodeInfo.OperateAt).ToString("yyyy-MM-dd HH:mm:ss");
                    d.TRACKPERSON = driverInfo;
                    d.TRACKINFO   = nodeInfo.Content;
                    d.TRACKTYPE   = trackType;
                    result.CONTENTLIST[0].DETAILLIST.Add(d);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("获取待上报节点失败:" + ex.Message);
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 暂时忽略掉的关系
        /// </summary>
        //private List<int> _ignoreTempRelationList = new List<int>();

        #region Logink正式环境
        private void _bw_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime      dtNow     = DateTime.Now;
            string        msg       = dtNow.ToString() + ":【节点上报】 ";
            string        xmlResult = string.Empty;
            RelationModel relation  = new RelationModel();

            try
            {
                List <string> senderCodeList = null;
                M_TMSNode     loginkNode     = null;
                if (Utility._LinkType == "2")
                {
                    senderCodeList = TMSOrderServer.GetAllLoginkSenderCode();
                    if (senderCodeList.Count == 0)
                    {
                        msg += "没有配置通过运管平台交换数据的上游发货单位";
                        return;
                    }
                }
                Model.NodeUpload.MESSAGEDETAIL.XML details = NodeUploadServer.GetFirstWaitUploadNode(senderCodeList, ref loginkNode, out relation);

                if (relation != null && relation.Id != 0)
                {
                    msg += string.Format("Relation【{0}】 Number【{1}】 CustomerId【{3}】 当前上报节点Id【{2}】 ", relation.RelationId, relation.Number, relation.CurrentUploadNodeId, relation.CustomerId);
                }
                if (details == null)
                {
                    if (relation != null && relation.Id != 0)                  // && !_ignoreTempRelationList.Contains(relation.Id))
                    {
                        NodeUploadServer.UpdateHandleTime(relation.Id, false); //_ignoreTempRelationList.Add(relation.Id);
                    }
                    msg += "暂无需要上报的节点";
                    return;
                }
                //运管平台上报
                if (senderCodeList != null)
                {
                    string nodeXml      = Utility.ParseXMLToString(loginkNode);
                    string receiverCode = TMSOrderServer.GetAllLoginkSenderCode(relation.CustomerId.ToString())[0];
                    LoginkHelp.Send(Utility._SecurityURL, Utility._TransportURL, Utility._MyCode, Utility._MyPwd, receiverCode, nodeXml, ActionType.LOGINK_CN_TRANSPORT_PREBOOKING);
                    msg += "上报成功 Receiver[" + receiverCode + "]";
                    bool isArrived = false;
                    if (details.CONTENTLIST[0].DETAILLIST[0].TRACKTYPE == "18")//正常签收
                    {
                        isArrived = true;
                        msg      += " 当前为签收节点 ";
                    }
                    bool isUpdate = NodeUploadServer.UpdateCurrentUploadNodeId(relation, isArrived, senderCodeList);
                    Utility.SaveXMLRequestAndRespond(nodeXml, string.Empty, "Node", relation.RelationId);
                    msg += isUpdate ? "更新当前上报节点成功" : "更新当前上报节点失败";
                    return;
                }
                #region 大华东供应链节点上报处理
                _UploadXML.MESSAGEHEAD.SENDTIME = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
                _UploadXML.MESSAGEHEAD.FILENAME = dtNow.ToString("yyyyMMddHHmmss");
                _UploadXML.MESSAGEDETAIL        = "<![CDATA[" + Utility.ParseXMLToString <Model.NodeUpload.MESSAGEDETAIL.XML>(details) + "]]>";
                string xmlRequest = Utility.ParseXMLToString <Model.NodeUpload.XML>(_UploadXML).Replace("<", "&lt;").Replace(">", "&gt;");
                Utility.AddLogText("上传前:" + xmlRequest);
                StringBuilder param = new StringBuilder();
                param.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.webservice.vtradex.com\" > ");
                param.Append("<soapenv:Header/>");
                param.Append("<soapenv:Body>");
                param.Append("<ser:tmsShipmentInTransitXml>" + xmlRequest + "</ser:tmsShipmentInTransitXml>");
                param.Append("</soapenv:Body>");
                param.Append("</soapenv:Envelope>");
                xmlResult = HTTPHelper.SendHTTPRequest(param.ToString(), "tmsShipmentInTransitXml", "tmsShipmentInTransitXml");
                Model.NodeUpload.XML uploadResult = Utility.ParseXMLToObjec <Model.NodeUpload.XML>(xmlResult);
                if (uploadResult.MSGCODE == "0" || string.IsNullOrEmpty(uploadResult.MSGCODE))
                {
                    msg += "上报失败" + " " + uploadResult.MSGCONTENT;
                }
                else if (uploadResult.MSGCODE == "1")
                {
                    msg += "上报成功 ";
                    try
                    {
                        bool isArrived = false;
                        if (details.CONTENTLIST[0].DETAILLIST[0].TRACKTYPE == "18")//正常签收
                        {
                            isArrived = true;
                            msg      += " 当前为签收节点 ";
                        }
                        bool isUpdate = NodeUploadServer.UpdateCurrentUploadNodeId(relation, isArrived, senderCodeList);
                        msg += isUpdate ? "更新当前上报节点成功" : "更新当前上报节点失败";
                        if (isArrived && isUpdate)
                        {
                            UploadCarrierArrived(details.CONTENTLIST[0].DETAILLIST[0], relation.CurrentUploadDataTime);
                        }
                    }
                    catch (Exception ex1)
                    {
                        msg += ex1.Message;
                    }
                }
                Utility.SaveXMLRequestAndRespond(param.ToString(), xmlResult, "Node", relation.RelationId);
                #endregion
            }
            catch (Exception ex)
            {
                msg += ex.Message;
                Utility.SaveErrLog(ex.Message, "Node");
                if (!ex.Message.Contains("重新开始") && !ex.Message.Contains("成功"))
                {
                    if (relation != null)
                    {
                        NodeUploadServer.UpdateHandleTime(relation.Id, false);
                    }
                    SendEmail(new Exception(msg));
                }
            }
            finally
            {
                Console.WriteLine(msg.Replace("\n", ""));
            }
        }
        /// <summary>
        /// 获取第一个需要上报的运单的下一个需要上报的节点
        /// </summary>
        /// <returns></returns>
        public static XML GetFirstWaitUploadNode(List <string> senderCodeList, ref M_TMSNode loginkNode, out RelationModel relation)
        {
            XML result = null;

            try
            {
                Utility.AddLogText(string.Format("开始查询下一个上报节点"));
                relation = GetFirstWaitUploadNodeOrderRelation(senderCodeList);//, ref _ignoreTempRelationList);
                if (relation != null)
                {
                    Utility.AddLogText(string.Format("CECNO:{0},LEGNO:{1}", relation.Number, relation.RelationId));
                }
                if (relation != null)
                {
                    NodeInfo nodeInfo = GetNextUploadNodeInfo(relation.CurrentUploadNodeId, relation.Number);
                    if (nodeInfo != null)
                    {
                        string driverInfo = ((nodeInfo.Driver == null ? string.Empty : nodeInfo.Driver) + " " + (nodeInfo.DriverTel == null ? string.Empty : nodeInfo.DriverTel)).Trim();
                        string trackType  = "17";
                        if (relation.CurrentUploadNodeId == null || relation.CurrentUploadNodeId == -1)
                        {
                            trackType = "15";//启运
                        }
                        else if (nodeInfo.Arrived == 2)
                        {
                            trackType = "18";//正常签收
                        }
                        else if (nodeInfo.StorageType == 1)
                        {
                            trackType = "16";//到中转站
                        }
                        else
                        {
                            trackType = "17";//中转站驾驶员已接单出发
                        }
                        //if (senderCodeList != null)
                        //{
                        loginkNode             = new M_TMSNode();
                        loginkNode.JcOrderNo   = relation.Number;
                        loginkNode.JcNodeId    = nodeInfo.Id;
                        loginkNode.TrackPerson = driverInfo;
                        loginkNode.TrackInfo   = nodeInfo.Content;
                        loginkNode.TrackTime   = DateTime.Parse(nodeInfo.OperateAt);
                        loginkNode.Arrived     = nodeInfo.Arrived;
                        loginkNode.OrderNo     = relation.RelationId;
                        loginkNode.TrackType   = trackType;
                        loginkNode.StorageName = nodeInfo.StorageName.Replace("[默认]", string.Empty);
                        //}
                        //else
                        //{
                        result             = new XML();
                        result.CONTENTLIST = new List <CONTENT>();
                        result.CONTENTLIST.Add(new CONTENT());
                        result.CONTENTLIST[0].DETAILLIST = new List <DETAIL>();
                        DETAIL d = new DETAIL();
                        d.ECNO        = GetShipmentCodeByTMSOrder(relation.RelationId);
                        d.CECNO       = relation.Number;
                        d.LEGNO       = relation.RelationId;
                        d.TRACKTIME   = DateTime.Parse(nodeInfo.OperateAt).ToString("yyyy-MM-dd HH:mm:ss");
                        d.TRACKPERSON = driverInfo;
                        d.TRACKINFO   = nodeInfo.Content;
                        d.TRACKTYPE   = trackType;
                        result.CONTENTLIST[0].DETAILLIST.Add(d);
                        relation.CurrentUploadDataTime = nodeInfo.StorageName.Replace("[默认]", string.Empty);//此字段暂存车牌号
                        ////}
                        relation.CurrentUploadNodeId = nodeInfo.Id;
                        Utility.AddLogText(string.Format("ECNO:{0},CECNO:{1}", d.ECNO, d.CECNO));
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.AddLogText("GetFirstWaitUploadNode异常:" + ex.Message);
                throw ex;
            }
            return(result);
        }