You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Settlements/FeePayAuditService.aspx.cs

866 lines
54 KiB
C#

3 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
using DSWeb.WorkFlow;
namespace DSWeb.Settlements
{
public partial class FeePayAuditService : System.Web.UI.Page
{
private string strHandle;
private string strUserID;
private string strBillNO;
private string strShowName;
private string strCompanyID;//公司GID
private string strDeptName;//部门名称
private string stroplb;//业务类别
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
if (Session["SHOWNAME"] != null)
{
this.strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString();
}
if (Request.QueryString["oplb"] != null)
{
stroplb = Request.QueryString["oplb"].ToString();
}
if (Request.QueryString["billno"] != null)
{
strBillNO = Request.QueryString["billno"].ToString();
}
if (strHandle != null)
{
//通过付费审批操作
if (strHandle == "auditpass" && strBillNO != null)
{
Response.Write(FeePayApplicationAuditPass(strBillNO).ToString());
}
//驳回
if (strHandle == "auditreject" && strBillNO != null)
{
Response.Write(FeePayApplicationAuditReject(strBillNO).ToString());
}
//查看申请付费是否已经结算过了
if (strHandle == "issettled")
{
Response.Write(IsFeePayApplicationSettled(strBillNO));
}
}
}
#region 查看付费申请是否已经结算完成
/// <summary>
/// 查看付费申请是否已经结算完成
/// </summary>
/// <param name="tempBillNO"></param>
/// <returns></returns>
private int IsFeePayApplicationSettled(string tempBillNO)
{
int iResult = 0;
FeePayApplicationEntity feePayApplicationEntity = new FeePayApplicationEntity();
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
feePayApplicationEntity = feePaySettleApplicationDA.GetFeePayApplicationByBillNO(tempBillNO,strCompanyID);
if (feePayApplicationEntity.GID != null)
{
if (feePayApplicationEntity.BillStatus == 4)
{
iResult = 1;//付费申请已经结算完毕
}
else if (feePayApplicationEntity.BillStatus == 0)
{
iResult = 0;
}
else if (feePayApplicationEntity.BillStatus == 3)
{
iResult = -2;//付费申请正在审批中
}
}
else
{
iResult = -1;//没有相关申请信息
}
return iResult;
}
#endregion
#region 付费审核通过
/// <summary>
/// 付费审核通过
/// </summary>
/// <param name="tempBillNO">申请编号</param>
/// <returns>值1审核通过 值-1审核异常 值-2没有权限审核付费 值-3付费步骤已经完成,不能重复审核</returns>
private int FeePayApplicationAuditPass(string tempBillNO)
{
int iResult = 0;
int bsnoCount = 0;
//工作流
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string sqlstr = " SELECT BSNO,OPLB,OPLBNAME,CUSTOMERNAME,MBLNO FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE A.BILLNO ='"+tempBillNO.Trim()+"') ";
DataSet ds = T_ALL_DA.GetAllSQL(sqlstr);
if (ds != null && ds.Tables[0].Rows.Count > 1)
{
string topBsno = ds.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim();
for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
{
if (stroplb.ToLower().Trim() == "")
{
stroplb = ds.Tables[0].Rows[i]["OPLB"].ToString().Trim();
}
//
if (topBsno != ds.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim())
{
bsnoCount++;
}
else
{
continue;
}
}
}
//查找付费工作流信息
string ls = "SELECT top 1 [WORKFLOWID] FROM [workflow_do] where [BILLNO]='" + tempBillNO + "' order by [AUDITTIME] desc";
string workFlowEntity_GID = T_ALL_DA.GetStrSQL("WORKFLOWID", ls);
//WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.PAYSETTLEAUDIT, strCompanyID);//WorkFlowType.SeaiPAYSETTLEAUDIT
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
if (stroplb.ToLower() == "op_seae")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.PAYSETTLEAUDIT, strCompanyID);
if (workFlowEntity_GID.Trim() != workFlowEntity.GID.ToString().Trim())
{
WorkFlowHelper workFlowHelper2 = new WorkFlowHelper();
workFlowEntity = null;
workFlowEntity = workFlowHelper2.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "op_seai")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiPAYSETTLEAUDIT, strCompanyID);
if (workFlowEntity_GID.Trim() != workFlowEntity.GID.ToString().Trim())
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead" )//51 陆运
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.tMsWlPAYSETTLEAUDIT, strCompanyID);
}
else if (stroplb.ToLower() == "import_main")//91 进口贸易for新协航
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.WmszxPAYSETTLEAUDIT, strCompanyID);
}
else if (stroplb.ToLower() == "op_apply")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.APPLYPAYSETTLEAUDIT, strCompanyID);
if (workFlowEntity_GID.Trim() != workFlowEntity.GID.ToString().Trim())
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "op_bulk")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.BULKPAYSETTLEAUDIT, strCompanyID);
if (workFlowEntity_GID.Trim() != workFlowEntity.GID.ToString().Trim())
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
//如果工作流信息存在
if (workFlowEntity != null)
{
FeePaySettleApplicationDA feePaySettlementApplicationDA = new FeePaySettleApplicationDA();
FeePayApplicationEntity feePayApplicationEntity = feePaySettlementApplicationDA.GetFeePayApplicationByBillNO(tempBillNO,strCompanyID);
IList<MessageEntity> messageEntities = new List<MessageEntity>();
MessageDA messageDA = new MessageDA();
IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
//先查看是否当前付费申请已经进入工作流
workFlowDoEntities = workFlowDoDA.GetAllWorkFlowDoByBillNO(workFlowEntity.GID, tempBillNO);
if (workFlowDoEntities.Count > 0)
{
int iCount = 0;
//如果付费申请已经进入工作流,先判断当前打开付费审核页面操作人是否是工作流内相关审核人,如果是则
foreach (WorkFlowDoEntity workFlowDoEntity in workFlowDoEntities)
{
//查看当前操作人是否为审核人
if (workFlowDoEntity.Auditor == strUserID)
{
//查看当前审核人所处的步骤是否已经完成
if (!workFlowDoEntity.IsFinish)
{
//iResult等于1表示工作执行操作成功
iResult = workFlowHelper.DoWorkFlowStep(workFlowDoEntity, workFlowEntity);
if (iResult == 1)
{
FeePaySettleApplicationDA feePaySettleAppDA = new FeePaySettleApplicationDA();
//遍历工作流步骤信息,如果是工作流步骤最后一步,表示审核通过则置ch_fee审核通过
foreach (WorkFlowStepEntity workFlowStepEntity in workFlowEntity.WorkFlowSteps)
{
if (workFlowStepEntity.StepNO == workFlowDoEntity.StepNO)
{
if (workFlowStepEntity.IsLast)
{
int iTempStatus = feePaySettleAppDA.UpdatePayApplicationStatus(workFlowDoEntity.BillNO, 0,strCompanyID);
if (iTempStatus != 1)
{
iResult = -5;//更新费用状态失败
}
}
}
}
}
}
else if (workFlowDoEntity.IsFinish)
{
iResult = -4;//付费审核步骤已经完成,不能重复审核
}
iCount++;
}
}
if (iResult == 1)
{
int iApplicantState = 0;
workFlowDoEntities = workFlowDoDA.GetWorkFlowDoAuditPassForMessage(workFlowEntity.GID, tempBillNO);
if (workFlowDoEntities.Count > 0)
{
foreach (WorkFlowDoEntity workFlowDo in workFlowDoEntities)
{
foreach (WorkFlowStepEntity workFlowStepEntity in workFlowEntity.WorkFlowSteps)
{
if (workFlowStepEntity.StepNO == workFlowDo.StepNO)
{
if (workFlowStepEntity.IsLast)
{
if (!workFlowDo.IsFinish)
{
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
if (bsnoCount == 0)
{
messageEntity.Name = "FeePayAudit";
}
else
{
messageEntity.Name = "FeeSeaAllPaySettleAudit";
}
//messageEntity.Description = "付费申请审核通知";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
//messageEntity.MessageContent = strShowName + " 已批准 [付费申请审核] 审核,当前等待您的审核 ";
messageEntity.TaskID = "";
messageEntity.Receiver = workFlowDo.Auditor;
messageEntity.TaskUrl = "settlements/FeePayAudit.aspx";
messageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAY);//2013-02-03 修改
messageEntity.RecvType = 2;//申请审核类型
if (stroplb.ToLower() == "op_seae")
{
messageEntity.Description = "海运出口付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [海运出口付费申请审核] 审核,当前等待您的审核 ";
}
else if (stroplb.ToLower() == "op_seai")
{
messageEntity.Description = "海运进口付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [海运进口付费申请审核] 审核,当前等待您的审核 ";
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead")//51 陆运
{
messageEntity.Description = "陆运付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已经批准通过 [陆运付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61 仓储
{
messageEntity.Description = "仓储付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已经批准通过 [仓储付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "import_main")
{
messageEntity.Description = "海运进口付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [海运进口付费申请审核] 审核,当前等待您的审核 ";
}
else if (stroplb.ToLower() == "op_apply")
{
messageEntity.Description = "报关业务付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [报关业务付费申请审核] 审核,当前等待您的审核 ";
}
else if (stroplb.ToLower() == "op_bulk")
{
messageEntity.Description = "大宗散货付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [大宗散货付费申请审核] 审核,当前等待您的审核 ";
}
messageEntities.Add(messageEntity);
if (iApplicantState == 0)
{
MessageEntity applicantMessageEntity = new MessageEntity();
applicantMessageEntity.GID = Guid.NewGuid().ToString();
//applicantMessageEntity.Name = "FeePayAudit";
if (bsnoCount == 0)
{
applicantMessageEntity.Name = "FeePayAudit";
}
else
{
applicantMessageEntity.Name = "FeeSeaAllPaySettleAudit";
}
//applicantMessageEntity.Description = "付费申请审核通知";
applicantMessageEntity.IsRead = false;
applicantMessageEntity.ReadCount = 0;
//applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [付费申请审核] 申请,现等待下一步审核 ";
applicantMessageEntity.TaskID = "";
applicantMessageEntity.Receiver = workFlowDo.Applicant;
applicantMessageEntity.TaskUrl = "settlements/paysettleapplication.aspx";
applicantMessageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAY);//2013-02-03 修改
applicantMessageEntity.RecvType = 3;//审核完成类型
if (stroplb.ToLower() == "op_seae")
{
applicantMessageEntity.Description = "海运出口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运出口付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "op_seai")
{
applicantMessageEntity.Description = "海运进口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运进口付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead")//51 陆运
{
applicantMessageEntity.Description = "陆运付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [陆运付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61 仓储
{
applicantMessageEntity.Description = "仓储付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [仓储付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "import_main")
{
applicantMessageEntity.Description = "海运进口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运进口付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "op_apply")
{
applicantMessageEntity.Description = "报关业务付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [报关业务付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "op_bulk")
{
applicantMessageEntity.Description = "大宗散货付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [大宗散货付费申请审核] 申请,现等待下一步审核 ";
}
messageEntities.Add(applicantMessageEntity);
iApplicantState++;
}
break;
}
else
{
if (iApplicantState == 0)
{
MessageEntity applicantMessageEntity = new MessageEntity();
applicantMessageEntity.GID = Guid.NewGuid().ToString();
//applicantMessageEntity.Name = "FeePayAudit";
if (bsnoCount == 0)
{
applicantMessageEntity.Name = "FeePayAudit";
}
else
{
applicantMessageEntity.Name = "FeeSeaAllPaySettleAudit";
}
//applicantMessageEntity.Description = "付费申请审核通知";
applicantMessageEntity.IsRead = false;
applicantMessageEntity.ReadCount = 0;
//applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [付费申请审核] 申请,全部审核已完成 ";
applicantMessageEntity.TaskID = "";
applicantMessageEntity.Receiver = workFlowDo.Applicant;
applicantMessageEntity.TaskUrl = "settlements/paysettleapplication.aspx";
applicantMessageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAY);//2013-02-03 修改
applicantMessageEntity.RecvType = 3;//审核完成类型
if (stroplb.ToLower() == "op_seae")
{
applicantMessageEntity.Description = "海运出口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运出口付费申请审核] 申请,全部审核已完成 ";
}
else if (stroplb.ToLower() == "op_seai")
{
applicantMessageEntity.Description = "海运进口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运进口付费申请审核] 申请,全部审核已完成 ";
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead")//51 陆运
{
applicantMessageEntity.Description = "陆运付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [陆运付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61 仓储
{
applicantMessageEntity.Description = "仓储付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [仓储付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "import_main")
{
applicantMessageEntity.Description = "海运进口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运进口付费申请审核] 申请,全部审核已完成 ";
}
else if (stroplb.ToLower() == "op_apply")
{
applicantMessageEntity.Description = "报关业务付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [报关业务付费申请审核] 申请,全部审核已完成 ";
}
else if (stroplb.ToLower() == "op_bulk")
{
applicantMessageEntity.Description = "大宗散货付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [大宗散货付费申请审核] 申请,全部审核已完成 ";
}
messageEntities.Add(applicantMessageEntity);
iApplicantState++;
}
break;
}
}
else
{
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
//messageEntity.Name = "FeePayAudit";
if (bsnoCount == 0)
{
messageEntity.Name = "FeePayAudit";
}
else
{
messageEntity.Name = "FeeSeaAllPaySettleAudit";
}
//messageEntity.Description = "付费申请审核通知";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
//messageEntity.MessageContent = strShowName + " 已批准 [付费申请审核] 审核,当前等待您的审核 ";
messageEntity.TaskID = "";
messageEntity.Receiver = workFlowDo.Auditor;
messageEntity.TaskUrl = "settlements/FeePayAudit.aspx";
messageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAY);//2013-02-03 修改
messageEntity.RecvType = 2;//申请审核类型
if (stroplb.ToLower() == "op_seae")
{
messageEntity.Description = "海运出口付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [海运出口付费申请审核] 审核,当前等待您的审核 ";
}
else if (stroplb.ToLower() == "op_seai")
{
messageEntity.Description = "海运进口付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [海运进口付费申请审核] 审核,当前等待您的审核 ";
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead")//51 陆运
{
messageEntity.Description = "陆运付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已经批准通过 [陆运付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61 仓储
{
messageEntity.Description = "仓储付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已经批准通过 [仓储付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "import_main")
{
messageEntity.Description = "海运进口付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [海运进口付费申请审核] 审核,当前等待您的审核 ";
}
else if (stroplb.ToLower() == "op_apply")
{
messageEntity.Description = "报关业务付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [报关业务付费申请审核] 审核,当前等待您的审核 ";
}
else if (stroplb.ToLower() == "op_bulk")
{
messageEntity.Description = "大宗散货付费申请审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [大宗散货付费申请审核] 审核,当前等待您的审核 ";
}
messageEntities.Add(messageEntity);
if (iApplicantState == 0)
{
MessageEntity applicantMessageEntity = new MessageEntity();
applicantMessageEntity.GID = Guid.NewGuid().ToString();
//applicantMessageEntity.Name = "FeePayAudit";
if (bsnoCount == 0)
{
applicantMessageEntity.Name = "FeePayAudit";
}
else
{
applicantMessageEntity.Name = "FeeSeaAllPaySettleAudit";
}
//applicantMessageEntity.Description = "付费申请审核通知";
applicantMessageEntity.IsRead = false;
applicantMessageEntity.ReadCount = 0;
//applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [付费申请审核] 申请,现等待下一步审核 ";
applicantMessageEntity.TaskID = "";
applicantMessageEntity.Receiver = workFlowDo.Applicant;
applicantMessageEntity.TaskUrl = "settlements/paysettleapplication.aspx";
applicantMessageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAY);//2013-02-03 修改
applicantMessageEntity.RecvType = 3;//审核完成类型
if (stroplb.ToLower() == "op_seae")
{
applicantMessageEntity.Description = "海运出口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运出口付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "op_seai")
{
applicantMessageEntity.Description = "海运进口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运进口付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead")//51 陆运
{
applicantMessageEntity.Description = "陆运付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [陆运付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61 仓储
{
applicantMessageEntity.Description = "仓储付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [仓储付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "import_main")
{
applicantMessageEntity.Description = "海运进口付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运进口付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "op_apply")
{
applicantMessageEntity.Description = "报关业务付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [报关业务付费申请审核] 申请,现等待下一步审核 ";
}
else if (stroplb.ToLower() == "op_bulk")
{
applicantMessageEntity.Description = "大宗散货付费申请审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [大宗散货付费申请审核] 申请,现等待下一步审核 ";
}
messageEntities.Add(applicantMessageEntity);
iApplicantState++;
}
break;
}
}
}
}
}
}
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.FEEPAYAPP, messageEntities);
}
if (iCount == 0)
{
iResult = -3;//没有权利审核付费
}
}
}
return iResult;
}
#endregion
#region 驳回申请
/// <summary>
/// 驳回申请
/// </summary>
/// <param name="tempBillNO">申请编号</param>
/// <returns></returns>
private int FeePayApplicationAuditReject(string tempBillNO)
{
int iResult = 0;
FeeDoDA feeDoDA = new FeeDoDA();
IList<FeeDoEntity> feeDoEntities = new List<FeeDoEntity>();
feeDoEntities = feeDoDA.GetFeeDoByBillNO(tempBillNO);
int bsnoCount = 0;
T_ALL_DA t_all_da = new T_ALL_DA();
string sqlstr = " SELECT BSNO,OPLBNAME,CUSTOMERNAME,MBLNO FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication "
+ "as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE A.BILLNO ='" + tempBillNO.Trim() + "') ";
DataSet ds = t_all_da.GetAllSQL(sqlstr);
if (ds != null && ds.Tables[0].Rows.Count > 1)
{
string topBsno = ds.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim();
for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
{
if (topBsno != ds.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim())
{
bsnoCount++;
}
else
{
continue;
}
}
}
//工作流
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//查找付费工作流信息
//WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.PAYSETTLEAUDIT,strCompanyID);
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
if (stroplb.ToLower() == "op_seae")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.PAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "op_seai")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead")//51 陆运
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.tMsWlPAYSETTLEAUDIT, strCompanyID);
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61 仓储
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.WmszxPAYSETTLEAUDIT, strCompanyID);
}
else if (stroplb.ToLower() == "import_main")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
else if (stroplb.ToLower() == "op_apply")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.APPLYPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "op_bulk")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.BULKPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
//如果工作流信息存在
if (workFlowEntity != null)
{
int iCount = 0;
FeePaySettleApplicationDA feePaySettlementApplicationDA = new FeePaySettleApplicationDA();
FeePayApplicationEntity feePayApplicationEntity = feePaySettlementApplicationDA.GetFeePayApplicationByBillNO(tempBillNO,strCompanyID);
IList<MessageEntity> messageEntities = new List<MessageEntity>();
MessageDA messageDA = new MessageDA();
IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
//先查看是否当前付费申请已经进入工作流
workFlowDoEntities = workFlowDoDA.GetAllWorkFlowDoByBillNO(workFlowEntity.GID, tempBillNO);
if (workFlowDoEntities.Count > 0)
{
//如果付费申请已经进入工作流,先判断当前打开付费审核页面操作人是否是工作流内相关审核人,如果是则
foreach (WorkFlowDoEntity workFlowDoEntity in workFlowDoEntities)
{
//查看当前操作人是否为审核人
if (workFlowDoEntity.Auditor == strUserID)
{
iCount++;
if (!workFlowDoEntity.IsFinish)
{
workFlowDoEntity.IsFinish = true;
workFlowDoEntity.IsDelete = true;
workFlowDoEntity.DeleteStep = workFlowDoEntity.StepID;
workFlowDoEntity.DeleteOperator = strUserID;
workFlowDoEntity.DeleteStepNO = workFlowDoEntity.StepNO;
workFlowDoEntity.IsFinish = true;
int iTempRejectStatus = workFlowHelper.DoWorkFlowReject(workFlowDoEntity, WorkFlowType.PAYSETTLEAUDIT, feeDoEntities, tempBillNO,strCompanyID);
if (iTempRejectStatus == 1)
{
iResult = 1;//执行驳回成功
}
else
{
iResult = -1;//执行驳回失败
}
break;
}
else
{
//查看当前审核人所处的步骤是否已经完成
foreach (WorkFlowStepEntity workFlowStep in workFlowEntity.WorkFlowSteps)
{
if (workFlowDoEntity.StepNO == workFlowStep.StepNO)
{
if (workFlowStep.IsLast)
{
workFlowDoEntity.IsFinish = true;
workFlowDoEntity.IsDelete = true;
workFlowDoEntity.DeleteStep = workFlowDoEntity.StepID;
workFlowDoEntity.DeleteOperator = strUserID;
workFlowDoEntity.DeleteStepNO = workFlowDoEntity.StepNO;
workFlowDoEntity.IsFinish = true;
int iTempRejectStatus = workFlowHelper.DoWorkFlowReject(workFlowDoEntity, WorkFlowType.PAYSETTLEAUDIT, feeDoEntities, tempBillNO,strCompanyID);
if (iTempRejectStatus == 1)
{
iResult = 1;//执行驳回成功
}
else
{
iResult = -1;//执行驳回失败
}
break;
}
else
{
iResult = -3;//审核已经进入下一步,不能执行驳回操作
}
}
}
}
}
}
if (iCount == 0)
{
iResult = -2;//没有权利审核付费
}
}
if (iResult == 1)
{
workFlowDoEntities = workFlowDoDA.GetWorkFlowDoAuditRejectForMessage(workFlowEntity.GID, tempBillNO);
if (workFlowDoEntities.Count > 0)
{
foreach (WorkFlowDoEntity workFlowDo in workFlowDoEntities)
{
MessageEntity applicantMessageEntity = new MessageEntity();
applicantMessageEntity.GID = Guid.NewGuid().ToString();
if (bsnoCount == 0)
{
applicantMessageEntity.Name = "FeePayAudit";
}
else
{
applicantMessageEntity.Name = "FeeSeaAllPaySettleAudit";
}
applicantMessageEntity.Description = "付费申请审核通知";
applicantMessageEntity.IsRead = false;
applicantMessageEntity.ReadCount = 0;
applicantMessageEntity.MessageContent = strShowName + " 驳回 [付费申请审核] 申请 ";
applicantMessageEntity.TaskID = "";
applicantMessageEntity.Receiver = workFlowDo.Applicant;
applicantMessageEntity.TaskUrl = "settlements/paysettleapplication.aspx";
applicantMessageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAYAPP);
applicantMessageEntity.RecvType = 3;//审核完成类型
messageEntities.Add(applicantMessageEntity);
}
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.FEEPAYAPP, messageEntities);
}
}
}
}
return iResult;
}
#endregion
}
}