using System; using System.Data; using DSWeb.Models; using DSWeb.EntityDA; using System.Collections; using System.Collections.Generic; namespace DSWeb.WorkFlow { public class WorkFlowHelper { private WorkFlowEntity _workFlowEntity; public WorkFlowHelper() { } #region 通过模块NAME获取工作流信息 /// /// 通过模块NAME获取工作流信息 /// /// 模块NAME /// public WorkFlowEntity FindWorkFlow(WorkFlowType tempWorkFlowType,string tempCompanyID) { if (_workFlowEntity == null) { WorkFlowDA workFlowDA = new WorkFlowDA(); int iType = 0; switch (tempWorkFlowType) { case WorkFlowType.FEEAUDIT: iType = 1; break; case WorkFlowType.PAYSETTLEAUDIT: iType = 2; break; case WorkFlowType.FEEMODIFYAUDIT: iType = 3; break; case WorkFlowType.SeaiFEEAUDIT: iType = 11; break; case WorkFlowType.SeaiPAYSETTLEAUDIT: iType = 12; break; case WorkFlowType.SeaiFEEMODIFYAUDIT: iType = 13; break; case WorkFlowType.WmsOutFEEAUDIT: iType = 21; break; case WorkFlowType.WmsOutPAYSETTLEAUDIT: iType = 22; break; case WorkFlowType.WmsOutFEEMODIFYAUDIT: iType = 23; break; case WorkFlowType.WmszxPAYSETTLEAUDIT: iType = 61; break; case WorkFlowType.tMsWlPAYSETTLEAUDIT: iType = 51; break; case WorkFlowType.FeeOpSeanRecvPayAudit: iType=72; break; case WorkFlowType.FeeOpSeanSettleAudit: iType = 71; break; case WorkFlowType.SEANFEEMODIFYAUDIT: iType = 73; break; case WorkFlowType.FeeSeaAllPaySettleAudit: iType = 74; break; case WorkFlowType.APPLYFEEAUDIT: iType = 101; break; case WorkFlowType.APPLYPAYSETTLEAUDIT: iType = 102; break; case WorkFlowType.APPLYFEEMODIFYAUDIT: iType = 103; break; case WorkFlowType.BULKFEEAUDIT: iType = 104; break; case WorkFlowType.BULKPAYSETTLEAUDIT: iType = 105; break; case WorkFlowType.BULKFEEMODIFYAUDIT: iType = 106; break; case WorkFlowType.FeeOpOtherRecvPayAudit: iType = 82; break; } try { //根据工作流类型获取工作流信息 _workFlowEntity = workFlowDA.GetSingleWorkFlowByTypeNo(iType, tempCompanyID); if (_workFlowEntity.WorkFlowSteps == null) { WorkFlowStepDA workFlowStepDA = new WorkFlowStepDA(); //获取工作流所有步骤信息 if (_workFlowEntity.GID != null) { _workFlowEntity.WorkFlowSteps = workFlowStepDA.GetWorkFlowSteps(_workFlowEntity.GID); for (int i = 0; i < _workFlowEntity.WorkFlowSteps.Count; i++) { if (_workFlowEntity.WorkFlowSteps[i].ConditionID != null) { WorkFlowConditionDA workFlowConditionDA = new WorkFlowConditionDA(); //根据工作流条件Gid返回工作流条件信息 _workFlowEntity.WorkFlowSteps[i].WorkFlowCondition = workFlowConditionDA.GetWorkFlowCondition(_workFlowEntity.WorkFlowSteps[i].ConditionID); } } } else { _workFlowEntity = null; } } } catch (Exception) { _workFlowEntity = null; return _workFlowEntity; } } return _workFlowEntity; } #endregion #region 注释 //public int GetWorkFlowStepOperatorRange(string strUserID) //{ // string strResult = "0"; // if (_workFlowEntity != null) // { // if (_workFlowEntity.GID != null) // { // WorkFlowDoEntity workFlowDoEntity = null; // WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA(); // workFlowDoEntity = workFlowDoDA.GetSigleWorkFlowDoByAuditor(_workFlowEntity.GID, strUserID); // if (workFlowDoEntity != null) // { // if (workFlowDoEntity.GID != null) // { // //遍历所有工作流下步骤,获取第一步骤GID信息 // foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps) // { // } // } // } // } // } // return strResult; //} #endregion #region 顺序执行工作流步骤(审核通过) /// /// 顺序执行工作流步骤(审核通过) /// /// 审核步骤DO信息实体类 /// 值1执行成功 值不等于1执行失败 public int DoWorkFlowStep(WorkFlowDoEntity tempWorkFlowDoEntity,WorkFlowEntity workFlowEntity) { int iResult = 0; if (workFlowEntity != null)//_workFlowEntity { WorkFlowDA workFlowDA = new WorkFlowDA(); WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA(); IList workFlowDoEntities = new List(); IList nextWorkFlowDoEntities = new List(); int iStepNO = 0; bool isLastStep = false; foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)//_workFlowEntity { //先判断当前工作流是否是最后一步,如果是最后一步则只更新ISFINISH字段,不再预先插入下一步信息 if (step.GID == tempWorkFlowDoEntity.StepID) { if (step.IsLast) { isLastStep = true; tempWorkFlowDoEntity.IsFinish = true; workFlowDoEntities.Add(tempWorkFlowDoEntity); iResult = workFlowDoDA.UpdateWorkFlowDoStep(workFlowDoEntities, nextWorkFlowDoEntities, isLastStep, workFlowEntity.WorkFlowSteps);//_workFlowEntity } else { iStepNO = step.StepNO + 1; foreach (WorkFlowStepEntity nextStep in workFlowEntity.WorkFlowSteps)//_workFlowEntity { if (nextStep.StepNO == iStepNO) { if (!nextStep.IsDepartment) { //先把当前审核人通过审核状态更新到ISFINISH字段 tempWorkFlowDoEntity.IsFinish = true; //然后插入一条新的记录到workflow_do表,主要是下一步骤审核信息 WorkFlowDoEntity nextWorkFlowDoEntity = new WorkFlowDoEntity(); nextWorkFlowDoEntity.GID = Guid.NewGuid().ToString(); nextWorkFlowDoEntity.BillNO = tempWorkFlowDoEntity.BillNO; nextWorkFlowDoEntity.WorkFlowID = tempWorkFlowDoEntity.WorkFlowID; nextWorkFlowDoEntity.StepID = nextStep.GID; nextWorkFlowDoEntity.StepNO = nextStep.StepNO; nextWorkFlowDoEntity.Auditor = nextStep.Auditor; nextWorkFlowDoEntity.BSNO = tempWorkFlowDoEntity.BSNO; nextWorkFlowDoEntity.FeeID = tempWorkFlowDoEntity.FeeID; nextWorkFlowDoEntity.FeeStatus = tempWorkFlowDoEntity.FeeStatus; nextWorkFlowDoEntity.DoQuerySql = tempWorkFlowDoEntity.DoQuerySql; nextWorkFlowDoEntity.IsFinish = false; nextWorkFlowDoEntity.Applicant = tempWorkFlowDoEntity.Applicant; workFlowDoEntities.Add(tempWorkFlowDoEntity); nextWorkFlowDoEntities.Add(nextWorkFlowDoEntity); } else { string strDepartmentID = step.DepartmentID == null?"":step.DepartmentID; if (strDepartmentID.Trim() != null) { SysDeptDA sysDeptDA = new SysDeptDA(); string strDeptID = sysDeptDA.GetDepartmentIdByUser(nextStep.Auditor); if (strDeptID.Trim().Equals(strDepartmentID) && strDepartmentID != "") { } } //先把当前审核人通过审核状态更新到ISFINISH字段 tempWorkFlowDoEntity.IsFinish = true; //然后插入一条新的记录到workflow_do表,主要是下一步骤审核信息 WorkFlowDoEntity nextWorkFlowDoEntity = new WorkFlowDoEntity(); nextWorkFlowDoEntity.GID = Guid.NewGuid().ToString(); nextWorkFlowDoEntity.BillNO = tempWorkFlowDoEntity.BillNO; nextWorkFlowDoEntity.WorkFlowID = tempWorkFlowDoEntity.WorkFlowID; nextWorkFlowDoEntity.StepID = nextStep.GID; nextWorkFlowDoEntity.StepNO = nextStep.StepNO; nextWorkFlowDoEntity.Auditor = nextStep.Auditor; nextWorkFlowDoEntity.BSNO = tempWorkFlowDoEntity.BSNO; nextWorkFlowDoEntity.FeeID = tempWorkFlowDoEntity.FeeID; nextWorkFlowDoEntity.FeeStatus = tempWorkFlowDoEntity.FeeStatus; nextWorkFlowDoEntity.DoQuerySql = tempWorkFlowDoEntity.DoQuerySql; nextWorkFlowDoEntity.IsFinish = false; nextWorkFlowDoEntity.Applicant = tempWorkFlowDoEntity.Applicant; workFlowDoEntities.Add(tempWorkFlowDoEntity); nextWorkFlowDoEntities.Add(nextWorkFlowDoEntity); } } } } } } //将更新和插入操作对象加入到实体类组内 if (workFlowDoEntities.Count >= 1) { iResult = workFlowDoDA.UpdateWorkFlowDoStep(workFlowDoEntities, nextWorkFlowDoEntities, false, workFlowEntity.WorkFlowSteps);//_workFlowEntity } } return iResult; } #endregion #region 工作流审核步骤驳回 /// /// 工作流审核步骤驳回 /// /// 工作流DO实体类 /// 工作流类型 /// FeeDo数据集 /// 编号 /// 分公司GID /// 值1工作流审核步骤驳回成功 值不等于1工作流步骤驳回失败 public int DoWorkFlowReject(WorkFlowDoEntity workFlowDoEntity,WorkFlowType workFlowType,IList feeDoEntities,string tempBillNO,string tempCompanyID) { int iResult = 0; //当某一审核工作流步骤审核人提出驳回申请后,先记录哪个步骤驳回,然后将所有审核步骤信息置删除位 if (_workFlowEntity != null) { WorkFlowDA workFlowDA = new WorkFlowDA(); WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA(); iResult = workFlowDoDA.ExcuteRejectWorkFlowDo(workFlowDoEntity, workFlowType, feeDoEntities, tempBillNO,tempCompanyID); } return iResult; } #endregion } public enum WorkFlowType { FEEAUDIT = 1,//应收应付费用审核 PAYSETTLEAUDIT = 2,//付费审核 FEEMODIFYAUDIT = 3,//费用更改审核 SeaiFEEAUDIT = 11,//海运进口应收应付费用审核 SeaiPAYSETTLEAUDIT = 12,//海运进口付费审核 SeaiFEEMODIFYAUDIT = 13,//海运进口费用更改审核 WmsOutFEEAUDIT = 21,//海运进口应收应付费用审核 WmsOutPAYSETTLEAUDIT = 22,//海运进口付费审核 WmsOutFEEMODIFYAUDIT = 23,//海运进口费用更改审核 WmszxPAYSETTLEAUDIT = 61,//仓储付费用审核 tMsWlPAYSETTLEAUDIT = 51,//陆运付费用审核 FeeOpSeanRecvPayAudit=72,//内贸海运应收应付费用审核 FeeOpSeanSettleAudit=71,//内贸海运付费用审核 SEANFEEMODIFYAUDIT=73,//内贸海运费用申请更改审核 FeeSeaAllPaySettleAudit = 74,//全部付费用审核20130913 APPLYFEEAUDIT =101,//应收应付费用审核 APPLYPAYSETTLEAUDIT =102,//付费审核 APPLYFEEMODIFYAUDIT =103,//费用更改审核 BULKFEEAUDIT = 104,//应收应付费用审核 BULKPAYSETTLEAUDIT = 105,//付费审核 BULKFEEMODIFYAUDIT = 106,//费用更改审核 FeeOpOtherRecvPayAudit = 82,//散杂运输_应收应付费用审核 //import_main = 12,//进口贸易 20131221 } }