Beispiel #1
0
        /// <summary>
        /// 获取审核列表
        /// </summary>
        /// <param name="param">参数实体条件</param>
        /// <returns></returns>
        public PageList <WF_AuditRecordResult> GetAuditRecList(WF_AuditRecordParam param)
        {
            PageList <WF_AuditRecordResult> ret = new PageList <WF_AuditRecordResult>();
            ExeResult rst = new ExeResult();

            rst = this.Execute("ZNLCRM.BLL.WF.WF_AuditRecordBLL", "GetAuditRecList", param);
            ret = (rst == null ? new PageList <WF_AuditRecordResult>() : rst.Result as PageList <WF_AuditRecordResult>);
            return(ret);
        }
Beispiel #2
0
        public WF_AuditBillResult GetAuditBillRecord(WF_AuditRecordParam param)
        {
            ExeResult rst = new ExeResult();

            rst = this.Execute("ZNLCRM.BLL.WF.WF_AuditRecordBLL", "GetAuditBillRecord", param);
            WF_AuditBillResult ret = new WF_AuditBillResult();

            ret = (rst == null ? new WF_AuditBillResult() : rst.Result as WF_AuditBillResult);
            return(ret);
        }
Beispiel #3
0
        public WCFAddUpdateResult AuditBill(WF_AuditRecordParam param)
        {
            ExeResult rst = new ExeResult();

            rst = this.Execute("ZNLCRM.BLL.WF.WF_AuditRecordBLL", "AuditBill", param);
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            ret = (rst == null ? new WCFAddUpdateResult() : rst.Result as WCFAddUpdateResult);
            return(ret);
        }
Beispiel #4
0
        public WCFAddUpdateResult TakeBackBill(WF_AuditRecordParam param)
        {
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            if (MessageBox.Show("是否真的收回当前单据审批状态!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            {
                return(ret);
            }
            ExeResult rst = new ExeResult();

            param.OperationType = "TakeBack";
            rst = this.Execute("ZNLCRM.BLL.WF.WF_AuditRecordBLL", "CancelBill", param);
            ret = (rst == null ? new WCFAddUpdateResult() : rst.Result as WCFAddUpdateResult);
            return(ret);
        }
Beispiel #5
0
        void BindData(int pageIndex)
        {
            this.btnReturn.Enabled      = false; //收回
            this.btnNoPass.Enabled      = false; //拒绝
            this.btnCancelCheck.Enabled = false; //驳回
            this.btnArgee.Enabled       = false; //同意

            WF_AuditRecordLogic logic = new WF_AuditRecordLogic(this);
            WF_AuditRecordParam param = new WF_AuditRecordParam();

            param.SourceTableEngName = _tableName;
            param.SourceBillGuid     = _sourceGuidKey;
            param.PageIndex          = pageIndex;
            param.PageSize           = int.MaxValue;
            param.IsPage             = true;
            WF_AuditBillResult rst = this.AsyncExecute <WF_AuditBillResult, WF_AuditRecordParam>(param, logic.GetAuditBillRecord, BindDataComplete);
        }
Beispiel #6
0
        public PageList <WF_AuditRecordResult> GetAuditRecList(WF_AuditRecordParam param)
        {
            this.CheckSession();
            PageList <WF_AuditRecordResult> ret = new PageList <WF_AuditRecordResult>();
            WhereClip   whereClip = WF_AuditRecord._.IsDeleted == false && WF_AuditRecord._.GCompanyID == this.SessionInfo.CompanyID;
            OrderByClip orderBy   = WF_AuditRecord._.SourceBillGuid.Asc && WF_AuditRecord._.CreatedTime.Asc && WF_AuditRecord._.SeqNo.Asc;

            if (param.SourceTableEngName.ToStringHasNull().Trim() != "")
            {
                whereClip = whereClip && WF_AuditRecord._.SourceTableEngName == param.SourceTableEngName;
            }
            if (param.SourceBillGuid != null)
            {
                whereClip = whereClip && WF_AuditRecord._.SourceBillGuid == param.SourceBillGuid;
            }
            ret = this.SelectList <WF_AuditRecordResult>(param.PageIndex.ToInt32(), param.PageSize.ToInt32(), whereClip, orderBy);
            return(ret);
        }
Beispiel #7
0
 protected void CheckAuditButton(string tableName, Guid?sourceGuid
                                 , Control conSubmit, Control conTakeBack, Control conAudit, Control conCancel)
 {
     #region 判断输入状态
     if (string.IsNullOrEmpty(tableName))
     {
         this.ShowMessage("请指定业务单据表名!");
     }
     if (sourceGuid == null)
     {
         this.ShowMessage("请指定业务单据ID!");
     }
     if (conSubmit == null && conTakeBack == null && conAudit == null && conCancel == null)
     {
         this.ShowMessage("请指定审批按钮!");
     }
     #endregion
     #region 获取审批状态
     WF_AuditBillResult  auditBillRst = new WF_AuditBillResult();
     WF_AuditRecordLogic recLogic     = new WF_AuditRecordLogic(this);
     WF_AuditRecordParam param        = new WF_AuditRecordParam();
     param.SourceTableEngName = tableName;
     param.SourceBillGuid     = sourceGuid;
     auditBillRst             = recLogic.GetAuditBillRecord(param);
     SetObjectPropertyValue(conSubmit, "Enabled", false);
     SetObjectPropertyValue(conAudit, "Enabled", false);
     SetObjectPropertyValue(conCancel, "Enabled", false);
     SetObjectPropertyValue(conTakeBack, "Enabled", false);
     if (auditBillRst == null)
     {
         this.ShowMessage("未定义当前单据审批流程!"); return;
     }
     #endregion
     #region 设置按钮状态
     List <WF_AuditRecordResult> lstAudit = auditBillRst.WF_AuditRecordResultList;
     if (lstAudit == null && lstAudit.Count <= 0)//未提交
     {
         SetObjectPropertyValue(conSubmit, "Enabled", true);
         SetObjectPropertyValue(conAudit, "Enabled", false);
         SetObjectPropertyValue(conCancel, "Enabled", false);
         SetObjectPropertyValue(conTakeBack, "Enabled", false);
     }
     else
     {
         int countNum = lstAudit.Where(a => a.IsCurrent.ToInt32() > 0).Count();
         if (countNum > 0)//已提交待审核
         {
             SetObjectPropertyValue(conSubmit, "Enabled", false);
             SetObjectPropertyValue(conAudit, "Enabled", true);
             SetObjectPropertyValue(conCancel, "Enabled", true);
             SetObjectPropertyValue(conTakeBack, "Enabled", true);
             if (lstAudit.Where(a => a.AuditEmpIDs.IndexOf("," + this.SessionInfo.UserID + ",") >= 0).Count() <= 0)
             {
                 SetObjectPropertyValue(conAudit, "Enabled", false);
             }
         }
         else //已提交待审核
         {
             if (auditBillRst.BillStatus.ToLower() == "new")
             {
                 SetObjectPropertyValue(conSubmit, "Enabled", true);
                 SetObjectPropertyValue(conAudit, "Enabled", true);
                 SetObjectPropertyValue(conCancel, "Enabled", false);
                 SetObjectPropertyValue(conTakeBack, "Enabled", false);
             }
             else if (auditBillRst.BillStatus.ToLower() == "complete")
             {
                 SetObjectPropertyValue(conSubmit, "Enabled", false);
                 SetObjectPropertyValue(conAudit, "Enabled", true);
                 SetObjectPropertyValue(conCancel, "Enabled", true);
                 SetObjectPropertyValue(conTakeBack, "Enabled", false);
             }
             else if (auditBillRst.BillStatus.ToLower() == "nopass")
             {
                 SetObjectPropertyValue(conSubmit, "Enabled", false);
                 SetObjectPropertyValue(conAudit, "Enabled", true);
                 SetObjectPropertyValue(conCancel, "Enabled", true);
                 SetObjectPropertyValue(conTakeBack, "Enabled", false);
             }
         }
     }
     #endregion
 }
Beispiel #8
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);
        }
Beispiel #9
0
        /// <summary>
        /// 撤消审核
        /// </summary>
        /// <param name="param">条件实体</param>
        /// <returns>返回生效的当前审核</returns>
        public WCFAddUpdateResult CancelBill(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 (param.AuditResult.ToStringHasNull() == "") 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 判断当前记录状态
                string operationType = "";
                object sourceInfo    = this.GetSourceAuditStatus(tblRst, param.SourceBillGuid);
                string oldStatus     = sourceInfo.GetType().GetProperty("Status").GetValue(sourceInfo, null).ToStringHasNull();
                if (param.OperationType.ToStringHasNull().ToLower() == "cancel")
                {
                    operationType = "撤消";
                    if (oldStatus.ToLower() == "new")
                    {
                        throw new WarnException("您的单据已处于未提交状态,不允许撤消!");
                    }
                }
                else
                {
                    operationType = "收回";
                    if (oldStatus.ToLower() == "new")
                    {
                        throw new WarnException("您的单据已处于未提交状态,不允许执行收回操作!");
                    }
                    else if (oldStatus.ToLower() == "complete")
                    {
                        throw new WarnException("您的单据已处于审核状态,不允许收回!");
                    }
                    #region 判断是否属于当前人的记录
                    string empFldIDName = tblRst.BelongEmpIDFld.ToStringHasNull();
                    if (empFldIDName != "")
                    {
                        string belongEmpID = sourceInfo.GetType().GetProperty(empFldIDName).GetValue(sourceInfo, null).ToStringHasNull();
                        if (belongEmpID.ToInt32() != this.SessionInfo.UserID)
                        {
                            throw new WarnException("当前单据记录不属于您创建,不允许收回!");
                        }
                    }
                    #endregion
                }
                #endregion
                #region 判断是否已提交业务单据,否则加入审核记录
                string billStatus = "", billApproveStatus = "";
                List <WF_AuditRecordResult> stepList = new List <WF_AuditRecordResult>();
                WhereClip whereClip = WF_AuditRecord._.SourceBillGuid == param.SourceBillGuid &&
                                      WF_AuditRecord._.GCompanyID == this.SessionInfo.CompanyID &&
                                      WF_AuditRecord._.IsDeleted == false &&
                                      WF_AuditRecord._.SourceTableEngName == param.SourceTableEngName;
                stepList = this.SelectList <WF_AuditRecordResult>(whereClip, WF_AuditRecord._.SeqNo.Asc);
                if (stepList == null && stepList.Count <= 0)
                {
                    throw new WarnException("您的相关单据未提交!");
                }
                List <WF_AuditRecordResult> newAuditRecList = new List <WF_AuditRecordResult>();
                WF_AuditRecordResult        currAuditRec    = new WF_AuditRecordResult();
                #region 撤消所有的审批
                currAuditRec      = stepList.LastOrDefault(a => a.IsCurrent == 0);
                billStatus        = "New";
                billApproveStatus = "未提交";
                ChangeSourceBllAuditStatus(tblRst, billStatus, billApproveStatus, sourceInfo);
                AfterAuditExeMethod(param.SourceTableEngName, oldStatus, billStatus, tblRst.TriggerStatus, tblRst.AfterAuditMethodPath, tblRst.AfterAuditMethodName, param.SourceBillGuid);
                #region 将后续审批节点失效掉(删除)
                this.Update <WF_AuditRecordResult>(new WF_AuditRecordResult()
                {
                    IsDeleted      = true,
                    UpdatedEmpID   = this.SessionInfo.UserID,
                    UpdatedEmpName = this.SessionInfo.UserName,
                    UpdatedTime    = DateTime.Now
                }, WF_AuditRecord._.IsCurrent > 0 &&
                                                   WF_AuditRecord._.WFAuditGuid == currAuditRec.WFAuditGuid &&
                                                   WF_AuditRecord._.SourceBillGuid == currAuditRec.SourceBillGuid &&
                                                   WF_AuditRecord._.IsDeleted == false);
                this.Update <WF_AuditRecordLineResult>(new WF_AuditRecordLineResult()
                {
                    IsDeleted      = true,
                    UpdatedEmpID   = this.SessionInfo.UserID,
                    UpdatedEmpName = this.SessionInfo.UserName,
                    UpdatedTime    = DateTime.Now
                }, WF_AuditRecordLine._.IsDeleted == false &&
                                                       WF_AuditRecordLine._.AuditResult.IsNull("") == "" &&
                                                       WF_AuditRecordLine._.WFAuditGuid == currAuditRec.WFAuditGuid &&
                                                       WF_AuditRecordLine._.SourceBillGuid == currAuditRec.SourceBillGuid);
                #endregion
                #endregion
                #region 添加撤消说明
                WF_AuditRecordResult newAuditRec = new WF_AuditRecordResult();
                newAuditRec.WF_RecGuid         = Guid.NewGuid();
                newAuditRec.GCompanyID         = this.SessionInfo.CompanyID;
                newAuditRec.SourceTableEngName = param.SourceTableEngName;
                newAuditRec.SourceBillNo       = currAuditRec.SourceBillNo;
                newAuditRec.SourceBillGuid     = param.SourceBillGuid;
                newAuditRec.WFAuditGuid        = currAuditRec.WFAuditGuid;
                newAuditRec.WFAuditLineGuid    = null;
                newAuditRec.SeqNo          = stepList.Max(a => a.SeqNo).ToInt32() + 1;
                newAuditRec.GreeMans       = 1;
                newAuditRec.AuditEmpIDs    = "," + this.SessionInfo.UserID + ",";//暂时是指定到人
                newAuditRec.AuditEmpNames  = this.SessionInfo.UserName;
                newAuditRec.AuditRemark    = "被用户" + this.SessionInfo.UserName + operationType;
                newAuditRec.AuditResult    = operationType;
                newAuditRec.IsCurrent      = 0;
                newAuditRec.CreatedEmpID   = this.SessionInfo.UserID;
                newAuditRec.CreatedEmpName = this.SessionInfo.UserName;
                newAuditRec.CreatedTime    = DateTime.Now;
                newAuditRec.IsDeleted      = false;
                this.Insert <WF_AuditRecordResult>(newAuditRec);
                #endregion
                #endregion
                rst.Key = 1;
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(rst);
        }
Beispiel #10
0
        /// <summary>
        /// 审核单据
        /// </summary>
        /// <param name="param">条件实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AuditBill(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("请指定相关审核业务单据编号!");
                if (param.AuditResult.ToStringHasNull() == "")
                {
                    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);
                string oldStatus  = sourceInfo.GetType().GetProperty("Status").GetValue(sourceInfo, null).ToStringHasNull();
                if (oldStatus.ToLower() == "complete")
                {
                    throw new WarnException("您的单据已审核完成,不允许提交!");
                }
                if (oldStatus.ToLower() == "nopass")
                {
                    throw new WarnException("您提交的单据已拒绝,不允许再次提交!");
                }
                #endregion
                #region 判断是否已提交业务单据,否则加入审核记录
                string billStatus = "", billApproveStatus = "";
                List <WF_AuditRecordResult> stepList = new List <WF_AuditRecordResult>();
                WhereClip whereClip = WF_AuditRecord._.SourceBillGuid == param.SourceBillGuid &&
                                      WF_AuditRecord._.GCompanyID == this.SessionInfo.CompanyID &&
                                      WF_AuditRecord._.IsDeleted == false &&
                                      WF_AuditRecord._.IsCurrent > 0 &&
                                      WF_AuditRecord._.SourceTableEngName == param.SourceTableEngName;
                stepList = this.SelectList <WF_AuditRecordResult>(whereClip, WF_AuditRecord._.SeqNo.Asc);
                if (stepList == null && stepList.Count <= 0)
                {
                    throw new WarnException("您的相关单据未提交!");
                }
                List <WF_AuditRecordResult> newAuditRecList = new List <WF_AuditRecordResult>();
                WF_AuditRecordResult        currAuditRec    = new WF_AuditRecordResult();
                WF_AuditRecordResult        nextAuditRec    = new WF_AuditRecordResult();
                #region 添加审核记录
                if (!stepList.Exists(a => a.IsCurrent > 0))
                {
                    throw new WarnException("当前业务单据已审核完成!");
                }
                currAuditRec = stepList.FirstOrDefault(a => a.IsCurrent == 1 && a.AuditEmpIDs.IndexOf("," + this.SessionInfo.UserID.ToStringHasNull() + ",") >= 0);
                if (currAuditRec == null)
                {
                    throw new WarnException("您没有审核当前业务单据的权限!");
                }
                nextAuditRec = stepList.FirstOrDefault(a => a.IsCurrent == 2 && a.SeqNo > currAuditRec.SeqNo);
                #region 审核情况
                int stdManNum      = currAuditRec.GreeMans.ToInt32();
                int stdCheckManNum = currAuditRec.AuditEmpIDs.ToStringHasNull().Split(',').ToArray().Where(a => a.ToStringHasNull().Trim() != "").Distinct().ToArray().Length;
                if (stdManNum > stdCheckManNum)
                {
                    stdManNum = stdCheckManNum;
                }
                if (stdManNum <= 0)
                {
                    stdManNum = 1;
                }
                List <WF_AuditRecordLineResult> auditRecList = this.GetAuditRecLineList(new WF_AuditRecordLineParam()
                {
                    WF_RecGuid = currAuditRec.WF_RecGuid
                });

                if (auditRecList.Exists(a => a.AuditEmpID == this.SessionInfo.UserID && a.AuditResult.ToStringHasNull() != ""))
                {
                    throw new WarnException("您已审核当前业务单据,不允许重复审核!");
                }
                WF_AuditRecordLineResult currEmpAuditRec = auditRecList.Find(a => a.AuditEmpID == this.SessionInfo.UserID);
                #region 更新审核人意见
                if (currEmpAuditRec == null)
                {
                    currEmpAuditRec                    = new WF_AuditRecordLineResult();
                    currEmpAuditRec.WF_RecGuid         = currAuditRec.WF_RecGuid;
                    currEmpAuditRec.SourceBillGuid     = currAuditRec.SourceBillGuid;
                    currEmpAuditRec.WFAuditGuid        = currAuditRec.WFAuditGuid;
                    currEmpAuditRec.WFAuditLineGuid    = currAuditRec.WFAuditLineGuid;
                    currEmpAuditRec.SourceTableEngName = currAuditRec.SourceTableEngName;
                    currEmpAuditRec.SourceBillNo       = currAuditRec.SourceBillNo;
                    currEmpAuditRec.AuditEmpID         = this.SessionInfo.UserID;
                    currEmpAuditRec.AuditEmpName       = this.SessionInfo.UserName;
                    currEmpAuditRec.AuditResult        = param.AuditResult;
                    currEmpAuditRec.AuditRemark        = param.AuditRemark;
                }
                else
                {
                    currEmpAuditRec.AuditResult = param.AuditResult;
                    currEmpAuditRec.AuditRemark = param.AuditRemark;
                }
                this.AddOrUpdateAuditRecLine(currEmpAuditRec);
                #endregion
                #region 重新获取当前步骤的审批记录
                auditRecList = this.GetAuditRecLineList(new WF_AuditRecordLineParam()
                {
                    WF_RecGuid = currAuditRec.WF_RecGuid
                });
                int currManGreeNum = auditRecList.Where(a => a.AuditResult.ToStringHasNull() == "同意").Select(a => a.AuditEmpID).Distinct().ToArray().Length;
                #endregion
                #region  意的处理
                if (param.AuditResult == "同意")
                {
                    currManGreeNum++;
                    if (currManGreeNum >= stdManNum)//审核人数通过
                    {
                        currAuditRec.IsCurrent      = 0;
                        currAuditRec.AuditResult    = param.AuditResult;
                        currAuditRec.AuditRemark    = param.AuditRemark;
                        currAuditRec.UpdatedEmpID   = this.SessionInfo.UserID;
                        currAuditRec.UpdatedEmpName = this.SessionInfo.UserName;
                        currAuditRec.UpdatedTime    = DateTime.Now;
                        if (nextAuditRec == null)//审核完成
                        {
                            billStatus        = "Complete";
                            billApproveStatus = "审核完成";
                            ChangeSourceBllAuditStatus(tblRst, billStatus, billApproveStatus, sourceInfo);
                            AfterAuditExeMethod(param.SourceTableEngName, oldStatus, billStatus, tblRst.TriggerStatus, tblRst.AfterAuditMethodPath, tblRst.AfterAuditMethodName, param.SourceBillGuid);
                        }
                        else
                        {
                            this.Update <WF_AuditRecordResult>(new WF_AuditRecordResult()
                            {
                                IsCurrent      = 1,
                                UpdatedEmpID   = this.SessionInfo.UserID,
                                UpdatedEmpName = this.SessionInfo.UserName,
                                UpdatedTime    = DateTime.Now
                            }, WF_AuditRecord._.WF_RecGuid == nextAuditRec.WF_RecGuid);
                        }
                        this.Update <WF_AuditRecordResult>(currAuditRec, WF_AuditRecord._.WF_RecGuid == currAuditRec.WF_RecGuid);
                    }
                }
                #endregion
                #region 拒绝和驳回的处理(NoPass,Reject)
                else
                {
                    currAuditRec.IsCurrent      = 0;
                    currAuditRec.AuditResult    = param.AuditResult;
                    currAuditRec.AuditRemark    = param.AuditRemark;
                    currAuditRec.UpdatedEmpID   = this.SessionInfo.UserID;
                    currAuditRec.UpdatedEmpName = this.SessionInfo.UserName;
                    currAuditRec.UpdatedTime    = DateTime.Now;
                    this.Update <WF_AuditRecordResult>(currAuditRec, WF_AuditRecord._.WF_RecGuid == currAuditRec.WF_RecGuid);
                    if (param.AuditResult == "拒绝")
                    {
                        billStatus        = "NoPass";
                        billApproveStatus = "拒绝";
                    }
                    else
                    {
                        billStatus        = "New";
                        billApproveStatus = "待提交";
                    }
                    ChangeSourceBllAuditStatus(tblRst, billStatus, billApproveStatus, sourceInfo);
                    AfterAuditExeMethod(param.SourceTableEngName, oldStatus, billStatus, tblRst.TriggerStatus, tblRst.AfterAuditMethodPath, tblRst.AfterAuditMethodName, param.SourceBillGuid);

                    //将后续审批节点失效掉(删除)
                    this.Update <WF_AuditRecordResult>(new WF_AuditRecordResult()
                    {
                        IsDeleted      = true,
                        UpdatedEmpID   = this.SessionInfo.UserID,
                        UpdatedEmpName = this.SessionInfo.UserName,
                        UpdatedTime    = DateTime.Now
                    }, WF_AuditRecord._.IsCurrent == 2 &&
                                                       WF_AuditRecord._.WFAuditGuid == currAuditRec.WFAuditGuid &&
                                                       WF_AuditRecord._.SourceBillGuid == currAuditRec.SourceBillGuid &&
                                                       WF_AuditRecord._.IsDeleted == false);
                    this.Update <WF_AuditRecordLineResult>(new WF_AuditRecordLineResult()
                    {
                        IsDeleted      = true,
                        UpdatedEmpID   = this.SessionInfo.UserID,
                        UpdatedEmpName = this.SessionInfo.UserName,
                        UpdatedTime    = DateTime.Now
                    }, WF_AuditRecordLine._.IsDeleted == false &&
                                                           WF_AuditRecordLine._.AuditResult.IsNull("") == "" &&
                                                           WF_AuditRecordLine._.WFAuditGuid == currAuditRec.WFAuditGuid &&
                                                           WF_AuditRecordLine._.SourceBillGuid == currAuditRec.SourceBillGuid);
                }
                #endregion
                #endregion
                #endregion
                #endregion
                rst.Key = 1;
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(rst);
        }
Beispiel #11
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);
        }