예제 #1
0
        /// <summary>
        /// 获取审核列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WF_AuditBillResult GetAuditBillRecord(WF_AuditRecordParam param)
        {
            WF_AuditBillResult ret = new WF_AuditBillResult();

            this.CheckSession();
            if (string.IsNullOrEmpty(param.SourceTableEngName))
            {
                throw new WarnException("请指定相关审核业务单据!");
            }
            if (param.SourceBillGuid == null)
            {
                throw new WarnException("请指定相关审核业务单据的ID!");
            }
            #region 获取相关表定义
            WF_TableResult tblRst = new WF_TableResult();
            WF_TableBLL    tblBll = new WF_TableBLL();
            tblBll.SessionInfo = this.SessionInfo;
            tblRst             = tblBll.GetInfo(new WF_TableParam()
            {
                WF_TableEngName = param.SourceTableEngName
            });
            if (tblRst == null || tblRst.WF_TableID <= 0)
            {
                throw new WarnException("系统中未发现定义的业务表!");
            }
            if (tblRst.WF_TableFieldList == null || tblRst.WF_TableFieldList.Count < 0)
            {
                throw new WarnException("系统中未发现定义的业务表相关字段!");
            }
            if (!tblRst.WF_TableFieldList.Exists(a => a.IsKeyGuid.ToBooleanHasNull() == true))
            {
                throw new WarnException("系统中未发现定义的业务表相关主键字段!");
            }
            #endregion
            #region 判断当前记录状态
            object sourceInfo    = this.GetSourceAuditStatus(tblRst, param.SourceBillGuid);
            string billStatus    = sourceInfo.GetType().GetProperty("Status").GetValue(sourceInfo, null).ToStringHasNull();
            string approveStatus = sourceInfo.GetType().GetProperty("ApproveStatus").GetValue(sourceInfo, null).ToStringHasNull();
            #endregion
            #region 审核状态
            WF_AuditBillBLL auditBll = new WF_AuditBillBLL();
            auditBll.SessionInfo = this.SessionInfo;
            ret = auditBll.GetInfo(new WF_AuditBillParam()
            {
                TableName = param.SourceTableEngName
            });
            if (ret == null)
            {
                return(ret);
            }
            PageList <WF_AuditRecordResult> recordRstList = new PageList <WF_AuditRecordResult>();
            recordRstList = GetAuditRecList(new WF_AuditRecordParam()
            {
                PageIndex = 1, PageSize = int.MaxValue, SourceTableEngName = param.SourceTableEngName, SourceBillGuid = param.SourceBillGuid
            });
            ret.WF_AuditRecordResultList = recordRstList.ResultList;
            ret.BillStatus    = billStatus;
            ret.ApproveStatus = approveStatus;
            #endregion
            return(ret);
        }
예제 #2
0
        /// <summary>
        /// 提交审核
        /// </summary>
        /// <param name="param">条件实体</param>
        /// <returns>返回生效的当前审核</returns>
        public WCFAddUpdateResult SubmitBill(WF_AuditRecordParam param)
        {
            WCFAddUpdateResult rst = new WCFAddUpdateResult();

            try
            {
                #region 判断提交值
                this.CheckSession();
                if (string.IsNullOrEmpty(param.SourceTableEngName))
                {
                    throw new WarnException("请指定相关审核业务单据!");
                }
                if (param.SourceBillGuid == null)
                {
                    throw new WarnException("请指定相关审核业务单据ID!");
                }
                //if (string.IsNullOrEmpty(param.SourceBillNo)) throw new WarnException("请指定相关审核业务单据编号!");

                #endregion
                #region 获取相关表定义
                WF_TableResult tblRst = new WF_TableResult();
                WF_TableBLL    tblBll = new WF_TableBLL();
                tblBll.SessionInfo = this.SessionInfo;
                tblRst             = tblBll.GetInfo(new WF_TableParam()
                {
                    WF_TableEngName = param.SourceTableEngName
                });
                if (tblRst == null || tblRst.WF_TableID <= 0)
                {
                    throw new WarnException("系统中未发现定义的业务表!");
                }
                if (tblRst.WF_TableFieldList == null || tblRst.WF_TableFieldList.Count < 0)
                {
                    throw new WarnException("系统中未发现定义的业务表相关字段!");
                }
                if (!tblRst.WF_TableFieldList.Exists(a => a.IsKeyGuid.ToBooleanHasNull() == true))
                {
                    throw new WarnException("系统中未发现定义的业务表相关主键字段!");
                }
                #endregion
                #region 判断当前记录状态
                object sourceInfo = this.GetSourceAuditStatus(tblRst, param.SourceBillGuid);
                //判断是否取消
                bool isCancel = sourceInfo.GetType().GetProperty("IsCancel") != null?sourceInfo.GetType().GetProperty("IsCancel").GetValue(sourceInfo, null).ToBooleanHasNull() : false;

                if (isCancel)
                {
                    throw new WarnException("您的单据已取消不允许执行当前操作!");
                }
                string oldStatus = sourceInfo.GetType().GetProperty("Status").GetValue(sourceInfo, null).ToStringHasNull();
                if (oldStatus.ToLower() == "approve")
                {
                    throw new WarnException("您的单据已提交,不允许重复提交!");
                }
                if (oldStatus.ToLower() == "complete")
                {
                    throw new WarnException("您的单据已审核完成,不允许提交!");
                }
                if (oldStatus.ToLower() == "nopass")
                {
                    throw new WarnException("您提交的单据已拒绝,不允许再次提交!");
                }
                #endregion
                #region 获取相关审核基础流程
                WF_AuditBillBLL auditBll = new WF_AuditBillBLL();
                auditBll.SessionInfo = this.SessionInfo;
                WF_AuditBillResult auditBillRst = auditBll.GetInfo(new WF_AuditBillParam()
                {
                    TableName = param.SourceTableEngName
                });
                if (auditBillRst == null || auditBillRst.WFAuditGuid == null ||
                    auditBillRst.WF_AuditBillLineList == null || auditBillRst.WF_AuditBillLineList.Count <= 0)
                {
                    throw new WarnException("未定相关业务单据的审核流程!");
                }
                if (auditBillRst.WF_AuditBillLineList.Exists(a => a.AuditEmpIDs.ToStringHasNull().Trim() == "" && a.NextType != "审核完成"))
                {
                    throw new WarnException("相关审批流程中,未找到相关审核人!");
                }
                #endregion
                #region 判断是否已提交业务单据,否则加入审核记录
                WF_AuditRecordResult currentStep = new WF_AuditRecordResult();
                WhereClip            whereClip   = WF_AuditRecord._.SourceBillGuid == param.SourceBillGuid &&
                                                   WF_AuditRecord._.GCompanyID == this.SessionInfo.CompanyID &&
                                                   WF_AuditRecord._.IsDeleted == false &&
                                                   WF_AuditRecord._.SourceTableEngName == param.SourceTableEngName &&
                                                   WF_AuditRecord._.IsCurrent == true;
                currentStep = this.Select <WF_AuditRecordResult>(whereClip);
                if (currentStep != null && currentStep.WF_RecGuid != null)
                {
                    throw new WarnException("当前单据已提交,正处于审核流程中,不允许重复提交!");
                }
                List <WF_AuditRecordResult> newAuditRecList = new List <WF_AuditRecordResult>();
                WF_AuditRecordResult        newAuditRec     = new WF_AuditRecordResult();
                #region 添加提交LOG记录
                newAuditRec.WF_RecGuid         = Guid.NewGuid();
                newAuditRec.GCompanyID         = this.SessionInfo.CompanyID;
                newAuditRec.SourceTableEngName = auditBillRst.TableName;
                newAuditRec.SourceBillNo       = param.SourceBillNo;
                newAuditRec.SourceBillGuid     = param.SourceBillGuid;
                newAuditRec.WFAuditGuid        = auditBillRst.WFAuditGuid;
                newAuditRec.WFAuditLineGuid    = null;
                newAuditRec.SeqNo          = 0;
                newAuditRec.GreeMans       = 0;
                newAuditRec.AuditEmpIDs    = "," + this.SessionInfo.UserID + ",";
                newAuditRec.AuditEmpNames  = this.SessionInfo.UserName;
                newAuditRec.IsCurrent      = 0;
                newAuditRec.AuditResult    = "提交";
                newAuditRec.AuditRemark    = "用户" + this.SessionInfo.UserName + "提交审核";
                newAuditRec.CreatedEmpID   = this.SessionInfo.UserID;
                newAuditRec.CreatedEmpName = this.SessionInfo.UserName;
                newAuditRec.CreatedTime    = DateTime.Now;
                newAuditRec.IsDeleted      = false;
                newAuditRecList.Add(newAuditRec);
                #endregion
                #region 添加审核记录
                string   billStatus = "", billApproveStatus = "";
                string[] arrEmpIds, arrEmpNames; int idx = 0;
                WF_AuditRecordLineResult auditRecLine;
                foreach (WF_AuditBillLineResult info in auditBillRst.WF_AuditBillLineList)
                {
                    newAuditRec                    = new WF_AuditRecordResult();
                    newAuditRec.WF_RecGuid         = Guid.NewGuid();
                    newAuditRec.GCompanyID         = this.SessionInfo.CompanyID;
                    newAuditRec.SourceTableEngName = auditBillRst.TableName;
                    newAuditRec.SourceBillNo       = param.SourceBillNo;
                    newAuditRec.SourceBillGuid     = param.SourceBillGuid;
                    newAuditRec.WFAuditGuid        = auditBillRst.WFAuditGuid;
                    newAuditRec.WFAuditLineGuid    = info.WFAuditLineGuid;
                    newAuditRec.SeqNo              = info.StepNo;
                    newAuditRec.GreeMans           = info.GreeMans;
                    newAuditRec.AuditEmpIDs        = info.AuditEmpIDs.ToStringHasNull().Trim() != "" ? ("," + info.AuditEmpIDs + ",") : "";//暂时是指定到人
                    newAuditRec.AuditEmpNames      = info.AuditEmpNames;
                    newAuditRec.IsCurrent          = 2;
                    newAuditRec.CreatedEmpID       = this.SessionInfo.UserID;
                    newAuditRec.CreatedEmpName     = this.SessionInfo.UserName;
                    newAuditRec.CreatedTime        = DateTime.Now;
                    newAuditRec.IsDeleted          = false;
                    if (info.OperationType == "提交")
                    {
                        newAuditRec.IsCurrent = 1;
                        billStatus            = "Approve";
                        billApproveStatus     = "待审核";//" + info.AuditEmpNames.ToStringHasNull() + "
                        if (info.NextType == "审核完成" && info.AuditEmpIDs.ToStringHasNull().Trim() == "")
                        {
                            billStatus            = "Complete";
                            billApproveStatus     = "审核完成";
                            newAuditRec.IsCurrent = 0;
                            newAuditRecList.Add(newAuditRec);
                            break;
                        }
                    }
                    newAuditRecList.Add(newAuditRec);
                    #region 添加审人明细记录
                    idx         = 0;
                    arrEmpIds   = newAuditRec.AuditEmpIDs.ToStringHasNull().Split(',').Where(a => a.ToStringHasNull().Trim() != "").Distinct().ToArray();
                    arrEmpNames = newAuditRec.AuditEmpNames.ToStringHasNull().Split(',').Where(a => a.ToStringHasNull().Trim() != "").Distinct().ToArray();
                    foreach (string s in arrEmpIds)
                    {
                        auditRecLine                    = new WF_AuditRecordLineResult();
                        auditRecLine.WF_RecGuid         = newAuditRec.WF_RecGuid;
                        auditRecLine.SourceBillGuid     = newAuditRec.SourceBillGuid;
                        auditRecLine.WFAuditGuid        = newAuditRec.WFAuditGuid;
                        auditRecLine.WFAuditLineGuid    = newAuditRec.WFAuditLineGuid;
                        auditRecLine.SourceTableEngName = newAuditRec.SourceTableEngName;
                        auditRecLine.SourceBillNo       = newAuditRec.SourceBillNo;
                        auditRecLine.AuditEmpID         = s.ToInt32();
                        auditRecLine.AuditEmpName       = arrEmpNames[idx];
                        this.AddOrUpdateAuditRecLine(auditRecLine);
                        idx++;
                    }
                    #endregion
                }
                if (newAuditRecList.Count > 0)
                {
                    this.BatchInsert <WF_AuditRecordResult>(newAuditRecList);
                    this.BatchExecute();
                }
                if (billStatus != "")
                {
                    ChangeSourceBllAuditStatus(tblRst, billStatus, billApproveStatus, sourceInfo);
                    AfterAuditExeMethod(param.SourceTableEngName, oldStatus, billStatus, tblRst.TriggerStatus, tblRst.AfterAuditMethodPath, tblRst.AfterAuditMethodName, param.SourceBillGuid);
                }
                #endregion
                #endregion
                rst.Key = 1;
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(rst);
        }