• 跨境电商个人物品清单申报开发代码


     经过几个月的开发终于完成的跨境电商统一申报开发

    这里把一些代码分享给大家:

     #region 发送到总署申报
            /// <summary>
            /// 发送到总署申报
            /// </summary>
            public void SendReceivedDeclare()
            {
                if (Grid_GoodsMainDeclare.CurrentRow == null)
                    return;
                if (BaseInterfaceLogic.CheckInputSelectAnyTwo(Grid_GoodsMainDeclare, "ColSelected"))
                {
                    int itemCount = 0;
                    int itemErrcount = 0;
                    ProgressForm progress = new ProgressForm(this);
                    string statusCode = string.Empty;
                    string statusMessage = string.Empty;
                    progress.Show();
                    try
                    {
                        #region 批量提交申报
                        for (int i = 0; i < GetSelecteIds().Length; i++)
                        {
                            progress.SetProgressValue(1);
                            string Id = string.Empty;
                            string FileName = string.Empty;
                            string CurrentOrderNo = string.Empty;
                            string XmlFileName = string.Empty;
                            string OrderXml = string.Empty;
                            string orderStatusCode = string.Empty;
                            string ShopNameId = string.Empty;
                            bool returnValueMsg = false;
                            //过滤表获得当前选中行的记录                        
                            string businessType = "PERSONAL_GOODS_DECLAR";//业务类型//运单信息
                            string sourceType = chkbusinessType.Checked == true ? "1" : "2";//申报类型//1新增 2修改
                            DataTable GoodsMainDeclaredtXml = new DataTable();
                            Id = GetSelecteIds()[i].ToString();
                            string Condition = string.Format("Id='{0}'", Id);
                            GoodsMainDeclaredtXml = BLLFactory<BLL.A8ERP_Customs_GoodsMainDeclare>.Instance.GetDataTable(Condition);
                            if (GoodsMainDeclaredtXml.Rows.Count == 0)
                                continue;
                            string AuditState = string.Empty;
                            for (int K = 0; K < GoodsMainDeclaredtXml.Rows.Count; K++)
                            {
                                CurrentOrderNo = GoodsMainDeclaredtXml.Rows[K]["OrderNo"].ToString();
                                ShopNameId = GoodsMainDeclaredtXml.Rows[K]["ShopNameId"].ToString();
                                AuditState = GoodsMainDeclaredtXml.Rows[K]["AuditState"].ToString();
                            }
                            #region 订单状态是否 已申报 已申报//已出库//海关入库
                            if ((AuditState == "30") || (AuditState == "40") || (AuditState == "120"))
                            {
                                progress.SetStatusInfo.Text = "订单已进入出货流程不能再申报...";
                                continue;
                            }
                            #endregion

                            #region 签名信息
                            string conditionSign = string.Format("ShopNameId='{0}' and BusinessType='{1}'", ShopNameId, businessType);
                            DataTable SignTableXml = new DataTable();
                            SignTableXml = BLLFactory<BLL.A8ERP_Customs_JkfSign>.Instance.GetDataTable(conditionSign);
                            if (SignTableXml.Rows.Count == 0)
                            {
                                MessageUtil.ShowTips("签名信息不存在!");
                                continue;
                            }
                            for (int j = 0; j < SignTableXml.Rows.Count; j++)
                            {
                                SignTableXml.Rows[j]["businessNo"] = CurrentOrderNo;
                                SignTableXml.Rows[j]["BusinessType"] = businessType;
                            }
                            #endregion

                            #region 申报明细表
                            DataTable GoodsDetaildt = new DataTable(A8ERP_Customs_GoodsDeclareDetailInfo.TableName);//个人申报明细表
                            string condition = string.Format("FId='{0}'", Id);
                            GoodsDetaildt = BLLFactory<BLL.A8ERP_Customs_GoodsDeclareDetail>.Instance.GetDataTable(condition);
                            #endregion

                            #region 开始申报
                            FileName = WebServiceXMLHelper.CareateXMLFileName(sourceType, businessType, CurrentOrderNo);//创建Xml文件名发送文件CurrentHeadOrderNo
                            XmlFileName = WebServiceXMLHelper.CareateXml(FileName);//创建并返回路径                        
                            OrderXml = OrderDelareUtilities.GetCreateGoodsDeclare(SignTableXml, GoodsMainDeclaredtXml, GoodsDetaildt, XmlFileName, businessType);//写入Xml文件
                            string ResultstatusMessage = WebServiceSend.OrderXmlSend(OrderXml, businessType, sourceType);
                            returnValueMsg = XmlOperation.MessageResultXml(ResultstatusMessage, CurrentOrderNo, out statusMessage);
                            if (returnValueMsg)
                            {
                                orderStatusCode = CustomsOrderState.Declaration.ToString();//申报中
                                if (BLLFactory<A8ERP_Customs_GoodsMainDeclare>.Instance.UPOrderAuditState(UserInfo, Id, orderStatusCode))
                                {
                                    statusMessage = string.Format(A8AppMessage.MSG, A8AppMessage.MSG99999);
                                    itemCount++;
                                }
                                #region 记录操作日志
                                if (returnValueMsg)
                                {
                                    A8ERP_WMS_OperationRecordsInfo OperationRecordsEntity = new A8ERP_WMS_OperationRecordsInfo();
                                    A8ERP_Customs_OrderDeclareParameterInfo PersonalSingleEntity = new A8ERP_Customs_OrderDeclareParameterInfo();
                                    string PersonalSingleSql = string.Format("ShopNameId='{0}'", ShopNameId);
                                    PersonalSingleEntity = BLLFactory<BLL.A8ERP_Customs_OrderDeclareParameter>.Instance.FindSingle(PersonalSingleSql);
                                    OperationRecordsEntity.CustomsField = PersonalSingleEntity.CustomsField;//路由产生地点
                                    OperationRecordsEntity.ProcessId = CurrentOrderNo;//服务Id
                                    OperationRecordsEntity.ProcessName = "总署清单申报";//服务名称
                                    OperationRecordsEntity.OperationName = "总署清单申报";//操作名称
                                    OperationRecordsEntity.OrderState = "30";//状态
                                    OperationRecordsEntity.Operation = UserInfo.RealName;//操作人  
                                    OperationRecordsEntity.Description = string.Format("单号:{0} 清单申报成功", CurrentOrderNo);//描述
                                    OperationRecordsEntity.CreateBy = UserInfo.UserName;//用户名称
                                    OperationRecordsEntity.CreateUserId = UserInfo.Id;//用户Id
                                    OperationRecordsEntity.OrgId = UserInfo.SubCompanyId;//机构Id
                                    OperationRecordsEntity.OrgName = UserInfo.SubCompanyName;//机构名称
                                    BLLFactory<BLL.A8ERP_WMS_OperationRecords>.Instance.Add(UserInfo, OperationRecordsEntity, out statusCode, out statusMessage);
                                }
                                #endregion
                                progress.SetStatusInfo.Text = "已申报: " + itemCount + " 条" + "错误:" + itemErrcount + "条";
                            }
                            else
                            {
                                itemErrcount++;
                                statusMessage = string.Format(A8AppMessage.MSG, statusMessage);
                                DevExpress.XtraEditors.XtraMessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            #endregion

                            progress.SetProgressValue(100);

                        }
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        MessageUtil.ShowTips(ex.Message);
                    }
                    finally
                    {
                        progress.SetProgressValue(100);
                        progress.SetStatusInfo.Text = "查找完毕...";
                        progress.Close();
                        statusMessage = string.Format("申报{0}:{1}条 " + "错误:{2} 条", statusMessage, itemCount, itemErrcount);
                        DevExpress.XtraEditors.XtraMessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //FormOnLoad();
                    }
                }
            }
            #endregion

    跨境监管仓库软件,跟申报一起

            /// <summary>
            /// 杭州版申报发送
            /// </summary>
            public override void RundeclareVoid()
            {
                if (Grid_GoodsMainDeclare.CurrentRow == null)
                    return;
                if (BaseInterfaceLogic.CheckInputSelectAnyTwo(Grid_GoodsMainDeclare, "ColSelected"))
                {
                    int itemCount = 0;
                    int itemErrcount = 0;
                    ProgressForm progress = new ProgressForm(this);
                    string statusCode = string.Empty;
                    string statusMessage = string.Empty;
                    progress.Show();
                    try
                    {
                        #region 批量提交申报
                        for (int i = 0; i < GetSelecteIds().Length; i++)
                        {
                            progress.SetProgressValue(1);
                            string Id = string.Empty;
                            string FileName = string.Empty;
                            string CurrentOrderNo = string.Empty;
                            string XmlFileName = string.Empty;
                            string OrderXml = string.Empty;
                            string orderStatusCode = string.Empty;
                            string ShopNameId = string.Empty;
                            bool returnValueMsg = false;
                            //过滤表获得当前选中行的记录                        
                            string businessType = "PERSONAL_GOODS_DECLAR";//业务类型//运单信息
                            string sourceType = chkbusinessType.Checked == true ? "1" : "2";//申报类型//1新增 2修改
                            DataTable GoodsMainDeclaredtXml = new DataTable();
                            Id = GetSelecteIds()[i].ToString();
                            string Condition = string.Format("Id='{0}'", Id);
                            GoodsMainDeclaredtXml = BLLFactory<BLL.A8ERP_Customs_GoodsMainDeclare>.Instance.GetDataTable(Condition);
                            for (int K = 0; K < GoodsMainDeclaredtXml.Rows.Count; K++)
                            {
                                CurrentOrderNo = GoodsMainDeclaredtXml.Rows[K]["OrderNo"].ToString();
                                ShopNameId = GoodsMainDeclaredtXml.Rows[K]["ShopNameId"].ToString();
                            }
                            #region 订单状态是否已申报
                            int OrderAuditState = BLLFactory<BLL.A8ERP_Customs_GoodsMainDeclare>.Instance.GetOrderAuditState(CurrentOrderNo);
                            if (OrderAuditState >= 30)
                            {
                                statusMessage = "订单已进入出货流程不能再申报...";
                                progress.SetStatusInfo.Text = statusMessage;
                                DevExpress.XtraEditors.XtraMessageBox.Show(AppMessage.Format(statusMessage, BaseInterfaceLogic.TargetNode.Text), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                continue;
                            }
                            #endregion
                            #region 签名信息
                            string conditionSign = string.Format("ShopNameId='{0}' and BusinessType='{1}'", ShopNameId, businessType);
                            DataTable SignTableXml = new DataTable();
                            SignTableXml = BLLFactory<BLL.A8ERP_Customs_JkfSign>.Instance.GetDataTable(conditionSign);
                            if (SignTableXml.Rows.Count == 0)
                            {
                                MessageUtil.ShowTips("签名信息不存在!");
                                continue;
                            }
                            for (int j = 0; j < SignTableXml.Rows.Count; j++)
                            {
                                SignTableXml.Rows[j]["businessNo"] = CurrentOrderNo;
                                SignTableXml.Rows[j]["BusinessType"] = businessType;
                            }
                            #endregion
                            #region 申报明细表
                            DataTable GoodsDetaildt = new DataTable(A8ERP_Customs_GoodsDeclareDetailInfo.TableName);//个人申报明细表
                            string condition = string.Format("FId='{0}'", Id);
                            GoodsDetaildt = BLLFactory<BLL.A8ERP_Customs_GoodsDeclareDetail>.Instance.GetDataTable(condition);
                            #endregion
                            #region 开始申报
                            FileName = WebServiceXMLHelper.CareateXMLFileName(sourceType, businessType, CurrentOrderNo);//创建Xml文件名发送文件CurrentHeadOrderNo
                            XmlFileName = WebServiceXMLHelper.CareateXml(FileName);//创建并返回路径                        
                            OrderXml = XmlOperation.CreateGoodsDeclare(SignTableXml, GoodsMainDeclaredtXml, GoodsDetaildt, XmlFileName, businessType);//写入Xml文件
                            string ResultstatusMessage = WebServiceSend.OrderXmlSend(OrderXml, businessType, sourceType);
                            returnValueMsg = XmlOperation.MessageResultXml(ResultstatusMessage, CurrentOrderNo, out statusMessage);
                            if (returnValueMsg)
                            {
                                orderStatusCode = CustomsOrderState.Declaration.ToString();//申报中
                                if (BLLFactory<A8ERP_Customs_GoodsMainDeclare>.Instance.UPOrderAuditState(UserInfo, Id, orderStatusCode))
                                {
                                    statusMessage = string.Format(A8AppMessage.MSG, A8AppMessage.MSG99999);
                                    itemCount++;
                                }
                                #region 记录操作日志
                                if (returnValueMsg)
                                {
                                    A8ERP_WMS_OperationRecordsInfo OperationRecordsEntity = new A8ERP_WMS_OperationRecordsInfo();
                                    A8ERP_Customs_OrderDeclareParameterInfo PersonalSingleEntity = new A8ERP_Customs_OrderDeclareParameterInfo();
                                    string PersonalSingleSql = string.Format("ShopNameId='{0}'", ShopNameId);
                                    PersonalSingleEntity = BLLFactory<BLL.A8ERP_Customs_OrderDeclareParameter>.Instance.FindSingle(PersonalSingleSql);
                                    OperationRecordsEntity.CustomsField = PersonalSingleEntity.CustomsField;//路由产生地点
                                    OperationRecordsEntity.ProcessId = CurrentOrderNo;//服务Id
                                    OperationRecordsEntity.ProcessName = "清单申报";//服务名称
                                    OperationRecordsEntity.OperationName = "清单申报";//操作名称
                                    OperationRecordsEntity.OrderState = "30";//状态
                                    OperationRecordsEntity.Operation = UserInfo.RealName;//操作人  
                                    OperationRecordsEntity.Description = string.Format("单号:{0} 清单申报成功", CurrentOrderNo);//描述
                                    OperationRecordsEntity.CreateBy = UserInfo.UserName;//用户名称
                                    OperationRecordsEntity.CreateUserId = UserInfo.Id;//用户Id
                                    OperationRecordsEntity.OrgId = UserInfo.SubCompanyId;//机构Id
                                    OperationRecordsEntity.OrgName = UserInfo.SubCompanyName;//机构名称
                                    BLLFactory<BLL.A8ERP_WMS_OperationRecords>.Instance.Add(UserInfo, OperationRecordsEntity, out statusCode, out statusMessage);

                                }
                                #endregion
                                progress.SetStatusInfo.Text = "已申报: " + itemCount + " 条" + "错误:" + itemErrcount + "条";
                            }
                            else
                            {
                                itemErrcount++;
                                statusMessage = string.Format(A8AppMessage.MSG, statusMessage);
                                MessageUtil.ShowTips(statusMessage);
                            }
                            #endregion
                            progress.SetProgressValue(100);
                        }
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        MessageUtil.ShowTips(ex.Message);
                    }
                    finally
                    {
                        progress.SetProgressValue(100);
                        progress.SetStatusInfo.Text = "查找完毕...";
                        progress.Close();
                        MessageUtil.ShowTips(string.Format("申报{0}:{1}条 " + "错误:{2} 条", statusMessage, itemCount, itemErrcount));
                        this.FormOnLoad();
                    }
                }
            }
          

  • 相关阅读:
    mysql卸载
    Nginx配置Https(详细、完整)
    国产数据库
    win11系统安装全过程
    微星b460主板如何开启TPM2.0
    如何查看计算机是否开启TPM2.0
    c语言实现复制文件
    如何使用格式工厂把视频变小
    格式工厂合并视频和音频文件
    IDM下载B站视频多个文件,视频、音频分开如何处理
  • 原文地址:https://www.cnblogs.com/kuangood/p/6806985.html
Copyright © 2020-2023  润新知