/// <summary> /// 下载报文 /// </summary> /// <param name="type"></param> /// <param name="localDir"></param> /// <param name="filePath"></param> /// <returns></returns> public override string DownResultFileData(OrderStatus.商检反馈报文类型 type, string localDir, string filePath) { FtpUtil ftp = new FtpUtil(config.NSIcpInfo.FtpUrl, config.NSIcpInfo.FtpName, config.NSIcpInfo.FtpPassword); string msg = ""; switch (type) { case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品检查: ftp.DownloadFile(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.REPORT/out/" + filePath, localDir, out msg); //ftp.DeleteFile(ftpUri + "4200.IMPBA.SWBCARGOBACK.REPORT/out/" + filePath); break; case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品订单: ftp.DownloadFile(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBEBTRADE.REPORT/out/" + filePath, localDir, out msg); //ftp.DeleteFile(ftpUri + "4200.IMPBA.SWBEBTRADE.REPORT/out/" + filePath); break; case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品审核报文: ftp.DownloadFile(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.AUDIT/out/" + filePath, localDir, out msg); //ftp.DeleteFile(ftpUri + "4200.IMPBA.SWBCARGOBACK.AUDIT/out/" + filePath); break; } return(msg); }
/// <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); }