示例#1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, StandardCheckEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult SubmitPresident(string keyValue, StandardCheckEntity pEntity)
        {
            //当前用户
            Operator curUser = OperatorProvider.Provider.Current();
            //参与人员
            var    errorMsg      = "";
            string checkUserId   = "";
            string checkUserName = "";
            string checkDeptId   = "";
            string checkDeptName = "";
            string wfFlag        = string.Empty; //流程标识
            string participant   = string.Empty; //获取流程下一节点的参与人员

            var entity = standardApplybll.GetEntity(pEntity.RecID);

            if (pEntity.CheckResult == "0")
            {//不通过,退回
                var appEntity = standardApplybll.GetEntity(keyValue);
                wfFlag = "2";
                string createuserid = appEntity.CREATEUSERID;
                var    userEntity   = userbll.GetEntity(createuserid);
                participant   = userEntity.Account; //申请用户
                checkUserId   = userEntity.UserId;
                checkUserName = userEntity.RealName;
                checkDeptId   = userEntity.DepartmentId;
                checkDeptName = deptbll.GetEntity(userEntity.DepartmentId).FullName;
                errorMsg      = "申请用户";

                if (pEntity.CheckBackType == "驳回人")
                {
                    entity.CheckBackFlag     = "6";
                    entity.CheckBackUserID   = curUser.UserId;
                    entity.CheckBackUserName = curUser.UserName;
                    entity.CheckBackDeptID   = curUser.DeptId;
                    entity.CheckBackDeptName = curUser.DeptName;
                }
                else
                {
                    entity.CheckBackFlag = entity.CheckBackUserID = entity.CheckBackUserName = entity.CheckBackDeptID = entity.CheckBackDeptName = "";
                }
            }
            else
            {                        //总经理审批,批准通过
                wfFlag        = "1"; // 审批=>结束
                errorMsg      = "总经理";
                participant   = curUser.Account;
                checkUserId   = curUser.UserId;
                checkUserName = curUser.UserName;
                checkDeptId   = curUser.DeptId;
                checkDeptName = curUser.DeptName;
            }
            //保存基本信息
            pEntity.ID = Guid.NewGuid().ToString();
            standardCheckbll.SaveForm("", pEntity);
            if (!string.IsNullOrEmpty(participant))
            {
                entity.CheckDeptID   = checkDeptId;
                entity.CheckDeptName = checkDeptName;
                entity.CheckUserID   = checkUserId;
                entity.CheckUserName = checkUserName;
                standardApplybll.SaveForm(entity.ID, entity);

                int count = htworkflowbll.SubmitWorkFlow(keyValue, participant, wfFlag, curUser.UserId);
                if (count > 0)
                {
                    htworkflowbll.UpdateFlowStateByObjectId("hrs_standardapply", "flowstate", keyValue);  //更新业务流程状态
                    if (wfFlag == "1")
                    {
                        SendMessage(entity);
                    }
                }
            }
            else
            {
                return(Error("请联系系统管理员,确认" + errorMsg + "!"));
            }

            return(Success("操作成功。"));
        }
        public ActionResult SubmitForm2(string keyValue, StandardCheckEntity pEntity)
        {
            //当前用户
            Operator curUser = OperatorProvider.Provider.Current();
            //参与人员
            var    errorMsg      = "";
            string checkUserId   = "";
            string checkUserName = "";
            string checkDeptId   = "";
            string checkDeptName = "";
            string wfFlag        = string.Empty; //流程标识
            string participant   = string.Empty; //获取流程下一节点的参与人员
            //标准化办公室审核用户
            DataItemModel checkuser = dataitemdetailbll.GetDataItemListByItemCode("'CheckUserAccount'").Where(p => p.ItemName == curUser.OrganizeId).ToList().FirstOrDefault();

            var entity = standardApplybll.GetEntity(pEntity.RecID);

            if (pEntity.CheckResult == "0")
            {//不通过,退回
                var appEntity = standardApplybll.GetEntity(keyValue);
                wfFlag = "2";
                string createuserid = appEntity.CREATEUSERID;
                var    userEntity   = userbll.GetEntity(createuserid);
                participant   = userEntity.Account; //申请用户
                checkUserId   = userEntity.UserId;
                checkUserName = userEntity.RealName;
                checkDeptId   = userEntity.DepartmentId;
                checkDeptName = deptbll.GetEntity(userEntity.DepartmentId).FullName;
                errorMsg      = "申请用户";

                if (pEntity.CheckBackType == "驳回人")
                {
                    entity.CheckBackFlag     = "2";
                    entity.CheckBackUserID   = curUser.UserId;
                    entity.CheckBackUserName = curUser.UserName;
                    entity.CheckBackDeptID   = curUser.DeptId;
                    entity.CheckBackDeptName = curUser.DeptName;
                }
                else
                {
                    entity.CheckBackFlag = entity.CheckBackUserID = entity.CheckBackUserName = entity.CheckBackDeptID = entity.CheckBackDeptName = "";
                }
            }
            else
            {                   //主任/主管,核准通过
                wfFlag   = "1"; // 2级审核=>审核分配会签
                errorMsg = "标准化办公室审核用户";
                if (checkuser != null)
                {
                    var chkStr = checkuser.ItemValue.Split(new char[] { '|' });
                    participant = chkStr[0];
                    var uList = userbll.GetListForCon(x => participant.Contains(x.Account)).ToList();
                    checkUserId   = string.Join(",", uList.Select(x => x.UserId));
                    checkUserName = string.Join(",", uList.Select(x => x.RealName));
                    checkDeptId   = chkStr.Length >= 3 ? chkStr[1] : "";
                    checkDeptName = chkStr.Length >= 3 ? chkStr[2] : "";
                }
            }
            //保存基本信息
            pEntity.ID = Guid.NewGuid().ToString();
            standardCheckbll.SaveForm("", pEntity);
            if (!string.IsNullOrEmpty(participant))
            {
                entity.CheckDeptID   = checkDeptId;
                entity.CheckDeptName = checkDeptName;
                entity.CheckUserID   = checkUserId;
                entity.CheckUserName = checkUserName;
                standardApplybll.SaveForm(entity.ID, entity);

                int count = htworkflowbll.SubmitWorkFlow(keyValue, participant, wfFlag, curUser.UserId);
                if (count > 0)
                {
                    htworkflowbll.UpdateFlowStateByObjectId("hrs_standardapply", "flowstate", keyValue);  //更新业务流程状态
                }
            }
            else
            {
                return(Error("请联系系统管理员,确认" + errorMsg + "!"));
            }

            return(Success("操作成功。"));
        }
        public ActionResult SubmitCommittee(string keyValue, StandardCheckEntity pEntity)
        {
            //当前用户
            Operator curUser = OperatorProvider.Provider.Current();
            //参与人员
            var    errorMsg      = "";
            string checkUserId   = "";
            string checkUserName = "";
            string checkDeptId   = "";
            string checkDeptName = "";
            string wfFlag        = string.Empty; //流程标识
            string participant   = string.Empty; //获取流程下一节点的参与人员
            //总经理用户
            DataItemModel president = dataitemdetailbll.GetDataItemListByItemCode("'PresidentApprove'").Where(p => p.ItemName == curUser.OrganizeId).ToList().FirstOrDefault();

            var entity = standardApplybll.GetEntity(pEntity.RecID);

            if (pEntity.CheckResult == "0")
            {//不通过,退回
                var appEntity = standardApplybll.GetEntity(keyValue);
                wfFlag = "2";
                string createuserid = appEntity.CREATEUSERID;
                var    userEntity   = userbll.GetEntity(createuserid);
                participant   = userEntity.Account; //申请用户
                checkUserId   = userEntity.UserId;
                checkUserName = userEntity.RealName;
                checkDeptId   = userEntity.DepartmentId;
                checkDeptName = deptbll.GetEntity(userEntity.DepartmentId).FullName;
                errorMsg      = "申请用户";

                if (pEntity.CheckBackType == "驳回人")
                {
                    entity.CheckBackFlag     = "5";
                    entity.CheckBackUserID   = entity.CheckUserID;
                    entity.CheckBackUserName = entity.CheckUserName;
                    entity.CheckBackDeptID   = entity.CheckDeptID;
                    entity.CheckBackDeptName = entity.CheckDeptName;
                }
                else
                {
                    entity.CheckBackFlag = entity.CheckBackUserID = entity.CheckBackUserName = entity.CheckBackDeptID = entity.CheckBackDeptName = "";
                }
            }
            else
            {                   //分委会审核,会签通过
                wfFlag   = "1"; // 分委会审核=>总经理审核
                errorMsg = "总经理用户";
                if (president != null)
                {
                    participant = president.ItemValue;
                    var pUser = userbll.GetUserInfoByAccount(participant);
                    if (pUser != null)
                    {
                        checkUserId   = pUser.UserId;
                        checkUserName = pUser.RealName;
                        checkDeptId   = pUser.DepartmentId;
                        checkDeptName = pUser.DeptName;
                    }
                    //更新会签人员信息
                    entity.CheckUserName = entity.CheckUserName.Replace(curUser.UserName, string.Format("{0}(已审)", curUser.UserName));
                    standardApplybll.SaveForm(entity.ID, entity);
                }
            }
            //保存基本信息
            pEntity.ID = Guid.NewGuid().ToString();
            standardCheckbll.SaveForm("", pEntity);

            if (!string.IsNullOrEmpty(participant))
            {
                if (pEntity.CheckResult == "0")
                {
                    entity.CheckDeptID   = checkDeptId;
                    entity.CheckDeptName = checkDeptName;
                    entity.CheckUserID   = checkUserId;
                    entity.CheckUserName = checkUserName;
                    standardApplybll.SaveForm(entity.ID, entity);

                    int count = htworkflowbll.SubmitWorkFlow(keyValue, participant, wfFlag, curUser.UserId);
                    if (count > 0)
                    {
                        htworkflowbll.UpdateFlowStateByObjectId("hrs_standardapply", "flowstate", keyValue);  //更新业务流程状态
                    }
                }
                else
                {
                    if (standardCheckbll.FinishComplete(entity.CheckUserID, entity.CheckUserName, "已审"))
                    {//会签完成才推送流程
                        entity.CheckDeptID   = checkDeptId;
                        entity.CheckDeptName = checkDeptName;
                        entity.CheckUserID   = checkUserId;
                        entity.CheckUserName = checkUserName;
                        standardApplybll.SaveForm(entity.ID, entity);

                        int count = htworkflowbll.SubmitWorkFlow(keyValue, participant, wfFlag, curUser.UserId);
                        if (count > 0)
                        {
                            htworkflowbll.UpdateFlowStateByObjectId("hrs_standardapply", "flowstate", keyValue);  //更新业务流程状态
                        }
                    }
                    else
                    {
                        var uList = userbll.GetListForCon(x => entity.CheckUserID.Contains(x.UserId)).ToList();
                        participant = string.Join(",", uList.Select(x => x.Account));
                        htworkflowbll.SubmitWorkFlowNoChangeStatus(keyValue, participant, curUser.UserId);
                    }
                }
            }
            else
            {
                return(Error("请联系系统管理员,确认" + errorMsg + "!"));
            }

            return(Success("操作成功。"));
        }
        public ActionResult SubmitForm(string keyValue, StandardCheckEntity pEntity)
        {
            //当前用户
            Operator curUser = OperatorProvider.Provider.Current();
            //参与人员
            var    errorMsg      = "";
            string checkUserId   = "";
            string checkUserName = "";
            string checkDeptId   = "";
            string checkDeptName = "";
            string wfFlag        = string.Empty; //流程标识
            string participant   = string.Empty; //获取流程下一节点的参与人员

            var entity = standardApplybll.GetEntity(pEntity.RecID);

            if (pEntity.CheckResult == "0")
            {//不通过,退回
                var appEntity = standardApplybll.GetEntity(keyValue);
                wfFlag = "2";
                string createuserid = appEntity.CREATEUSERID;
                var    userEntity   = userbll.GetEntity(createuserid);
                participant   = userEntity.Account; //申请用户
                checkUserId   = userEntity.UserId;
                checkUserName = userEntity.RealName;
                checkDeptId   = userEntity.DepartmentId;
                checkDeptName = deptbll.GetEntity(userEntity.DepartmentId).FullName;
                errorMsg      = "申请用户";

                if (pEntity.CheckBackType == "驳回人")
                {
                    entity.CheckBackFlag     = "1";
                    entity.CheckBackUserID   = curUser.UserId;
                    entity.CheckBackUserName = curUser.UserName;
                    entity.CheckBackDeptID   = curUser.DeptId;
                    entity.CheckBackDeptName = curUser.DeptName;
                }
                else
                {
                    entity.CheckBackFlag = entity.CheckBackUserID = entity.CheckBackUserName = entity.CheckBackDeptID = entity.CheckBackDeptName = "";
                }
            }
            else
            {                   //副主任/主管,核准通过
                wfFlag   = "1"; // 1级审核=>2级审核
                errorMsg = "主任/主管";
                //找当前用户所有部门,不是所在班组或专业。
                var dept = new DepartmentBLL().GetDepts(curUser.OrganizeId).Where(x => x.Nature == "部门" && curUser.DeptCode.StartsWith(x.EnCode)).FirstOrDefault();
                if (dept != null)
                {
                    var mgUser = userbll.GetUserListByRole(dept.EnCode, "'100104'", "");
                    if (mgUser != null)
                    {
                        participant   = string.Join(",", mgUser.Select(x => x.Account));
                        checkUserId   = string.Join(",", mgUser.Select(x => x.UserId));
                        checkUserName = string.Join(",", mgUser.Select(x => x.RealName));
                        checkDeptId   = curUser.DeptId;
                        checkDeptName = curUser.DeptName;
                    }
                }
            }
            //保存基本信息
            pEntity.ID = Guid.NewGuid().ToString();
            standardCheckbll.SaveForm("", pEntity);
            if (!string.IsNullOrEmpty(participant))
            {
                entity.CheckDeptID   = checkDeptId;
                entity.CheckDeptName = checkDeptName;
                entity.CheckUserID   = checkUserId;
                entity.CheckUserName = checkUserName;
                standardApplybll.SaveForm(entity.ID, entity);

                int count = htworkflowbll.SubmitWorkFlow(keyValue, participant, wfFlag, curUser.UserId);
                if (count > 0)
                {
                    htworkflowbll.UpdateFlowStateByObjectId("hrs_standardapply", "flowstate", keyValue);  //更新业务流程状态
                }
            }
            else
            {
                return(Error("请联系系统管理员,确认" + errorMsg + "!"));
            }

            return(Success("操作成功。"));
        }