Exemplo n.º 1
0
        /// <summary>
        /// 获取商品回执
        /// </summary>
        /// <returns></returns>
        public Result GetRecByType(OrderStatus.商检反馈报文类型 type)
        {
            string strType = "";

            if (type == Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品检查)
            {
                strType = "商品检查";
            }
            if (type == Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品审核报文)
            {
                strType = "商品审核";
            }
            Result result = new Result();

            try
            {
                FtpUtil  ftp      = new FtpUtil(config.NSIcpInfo.FtpUrl, config.NSIcpInfo.FtpName, config.NSIcpInfo.FtpPassword);
                string[] fileList = GetCustomsOutResult(type);
                if (fileList != null)
                {
                    if (type == Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品检查)
                    {
                        foreach (string fileTxt in fileList)
                        {
                            string msg    = "";
                            Stream stream = ftp.FileStream(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.REPORT/" + fileTxt, ref msg);
                            //设置当前流的位置为流的开始,防止读取位置错误造成无法读取完整流的内容
                            stream.Seek(0, SeekOrigin.Begin);
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                string txt = reader.ReadToEnd();
                                //接收回执
                                if (fileTxt.Contains("DOCREC_"))
                                {
                                    Model.Icp.GZNanSha.CustomsResult.Commodity.ROOT root = Hyt.Util.Serialization.SerializationUtil.XmlDeserialize <Model.Icp.GZNanSha.CustomsResult.Commodity.ROOT>(txt);
                                    //更新商检回执信息
                                    if (root.declaration.OrgMessageType == "661105")
                                    {
                                        CIcp Icp = IcpBo.Instance.GetEntityByMessageIDType(root.declaration.OrgMessageType, root.declaration.OrgMessageID);
                                        if (Icp != null)
                                        {
                                            if (Icp.Status == (int)OrderStatus.商检状态.已推送)
                                            {
                                                IcpBo.Instance.UpdatePlatDocRecByMessageID(root.declaration.OrgMessageID, txt, root.declaration.Status);
                                                if (root.declaration.Status == "10")
                                                {
                                                    IcpBo.Instance.UpdateStatus(root.declaration.OrgMessageID, (int)IcpStatus.商品商检推送状态.已接收);
                                                }
                                                if (root.declaration.Status == "20")
                                                {
                                                    IcpBo.Instance.UpdateStatus(root.declaration.OrgMessageID, (int)IcpStatus.商品商检推送状态.申报失败);
                                                    IcpBo.Instance.UpdateEntGoodsNoByMessageID(root.declaration.OrgMessageID, "None");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (type == Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品审核报文)
                    {
                        foreach (string fileTxt in fileList)
                        {
                            string msg    = "";
                            Stream stream = ftp.FileStream(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.AUDIT/out/" + fileTxt, ref msg);
                            //设置当前流的位置为流的开始,防止读取位置错误造成无法读取完整流的内容
                            stream.Seek(0, SeekOrigin.Begin);
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                string txt = reader.ReadToEnd();
                                Hyt.Model.Icp.GZNanSha.CustomsResult.CommodityAudit.ROOT          root       = Hyt.Util.Serialization.SerializationUtil.XmlDeserialize <Model.Icp.GZNanSha.CustomsResult.CommodityAudit.ROOT>(txt);
                                List <Hyt.Model.Icp.GZNanSha.CustomsResult.CommodityAudit.Record> RecordList = root.declaration.GoodsRegRecList.RecordList;
                                foreach (Hyt.Model.Icp.GZNanSha.CustomsResult.CommodityAudit.Record item in RecordList)
                                {
                                    //审核通过,更新检验检疫商品备案编号
                                    if (item.RegStatus == "10")
                                    {
                                        IcpBo.Instance.UpdateNSCIQGoodsNo(item.Gcode, item.CIQGoodsNO);
                                    }
                                }
                            }
                        }
                    }
                    result.Status  = true;
                    result.Message = strType + "回执获取成功";
                }
                else
                {
                    result.Status  = true;
                    result.Message = strType + "暂未生成相应的回执";
                }
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取订单回执
        /// </summary>
        /// <returns></returns>
        public override Result GetOrderRec()
        {
            Result result = new Result();

            try
            {
                FtpUtil  ftp      = new FtpUtil(config.NSIcpInfo.FtpUrl, config.NSIcpInfo.FtpName, config.NSIcpInfo.FtpPassword);
                string[] fileList = GetCustomsOutResult(OrderStatus.商检反馈报文类型.商品订单);
                if (fileList != null)
                {
                    foreach (string fileTxt in fileList)
                    {
                        string msg    = "";
                        Stream stream = ftp.FileStream(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBEBTRADE.REPORT/" + fileTxt, ref msg);
                        //设置当前流的位置为流的开始,防止读取位置错误造成无法读取完整流的内容
                        stream.Seek(0, SeekOrigin.Begin);
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            string txt = reader.ReadToEnd();
                            //接收回执
                            if (fileTxt.Contains("DOCREC_"))
                            {
                                Model.Icp.GZNanSha.CustomsResult.Commodity.ROOT root = Hyt.Util.Serialization.SerializationUtil.XmlDeserialize <Model.Icp.GZNanSha.CustomsResult.Commodity.ROOT>(txt);
                                //更新商检回执信息
                                if (root.declaration.OrgMessageType == "661101")
                                {
                                    CIcp Icp = IcpBo.Instance.GetEntityByMessageIDType(root.declaration.OrgMessageType, root.declaration.OrgMessageID);
                                    if (Icp != null)
                                    {
                                        if (Icp.Status == (int)OrderStatus.商检状态.已推送)
                                        {
                                            IcpBo.Instance.UpdatePlatDocRecByMessageID(root.declaration.OrgMessageID, txt, root.declaration.Status);

                                            //Status: 10 入库成功,20 出错
                                            if (root.declaration.Status == "10")
                                            {
                                                //更新订单的商检推送状态为已通过
                                                IcpBo.Instance.UpdateStatus(root.declaration.OrgMessageID, (int)IcpStatus.商品商检推送状态.已接收);
                                                SoOrderBo.Instance.UpdateOrderNsStatus(Icp.SourceSysNo, (int)OrderStatus.商检状态.已通过);
                                            }
                                            if (root.declaration.Status == "20")
                                            {
                                                //更新订单的商检推送状态为未推送
                                                IcpBo.Instance.UpdateStatus(root.declaration.OrgMessageID, (int)IcpStatus.商品商检推送状态.申报失败);
                                                SoOrderBo.Instance.UpdateOrderNsStatus(Icp.SourceSysNo, (int)OrderStatus.商检状态.未推送);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    result.Status  = true;
                    result.Message = "商品订单回执获取成功";
                }
                else
                {
                    result.Status  = true;
                    result.Message = "暂未生成相应的回执";
                }
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }