public ActionResult GetFormJson(string keyValue)
 {
     try
     {
         Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
         var      data = suppliesacceptbll.GetEntity(keyValue);
         if (data.Status == 1)
         {
             ManyPowerCheckBLL    bll   = new ManyPowerCheckBLL();
             ManyPowerCheckEntity power = bll.GetListByModuleNo(user.OrganizeCode, "YJWZLYSP").OrderByDescending(t => t.SERIALNUM).FirstOrDefault();
             ManyPowerCheckEntity flow  = bll.GetEntity(data.FlowId);
             if (power != null && power.SERIALNUM == flow.SERIALNUM)
             {
                 data.IsLastAudit = true;
             }
             else
             {
                 data.IsLastAudit = false;
             }
         }
         else
         {
             data.IsLastAudit = false;
         }
         return(ToJsonResult(data));
     }
     catch (System.Exception ex)
     {
         return(Error(ex.ToString()));
     }
 }
        public ActionResult SubmitForm(string keyValue, SafetyCollectEntity entity)
        {
            Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();

            string state = string.Empty;

            string flowid = string.Empty;

            string moduleName = "竣工安全验收";

            // <param name="state">是否有权限审核 1:能审核 0 :不能审核</param>
            ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId);

            //新增时会根据角色自动审核
            List <ManyPowerCheckEntity> powerList  = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, "竣工安全验收");
            List <ManyPowerCheckEntity> checkPower = new List <ManyPowerCheckEntity>();
            var outsouringengineer = outsouringengineerbll.GetEntity(entity.EngineerId);

            //先查出执行部门编码
            for (int i = 0; i < powerList.Count; i++)
            {
                if (powerList[i].CHECKDEPTCODE == "-1" || powerList[i].CHECKDEPTID == "-1")
                {
                    var createdeptentity  = new DepartmentBLL().GetEntity(outsouringengineer.ENGINEERLETDEPTID);
                    var createdeptentity2 = new DepartmentEntity();
                    while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组")
                    {
                        createdeptentity2 = new DepartmentBLL().GetEntity(createdeptentity.ParentId);
                        if (createdeptentity2.Nature != "专业" || createdeptentity2.Nature != "班组")
                        {
                            break;
                        }
                    }
                    powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode;
                    powerList[i].CHECKDEPTID   = createdeptentity.DepartmentId;
                    if (createdeptentity2 != null)
                    {
                        powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode + "," + createdeptentity2.DeptCode;
                        powerList[i].CHECKDEPTID   = createdeptentity.DepartmentId + "," + createdeptentity2.DepartmentId;
                    }
                }
                //创建部门
                if (powerList[i].CHECKDEPTCODE == "-3" || powerList[i].CHECKDEPTID == "-3")
                {
                    var createdeptentity = new DepartmentBLL().GetEntityByCode(curUser.DeptCode);
                    while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组")
                    {
                        createdeptentity = new DepartmentBLL().GetEntity(createdeptentity.ParentId);
                    }
                    powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode;
                    powerList[i].CHECKDEPTID   = createdeptentity.DepartmentId;
                }
            }
            //登录人是否有审核权限--有审核权限直接审核通过
            for (int i = 0; i < powerList.Count; i++)
            {
                if (powerList[i].CHECKDEPTID.Contains(curUser.DeptId))
                {
                    var rolelist = curUser.RoleName.Split(',');
                    for (int j = 0; j < rolelist.Length; j++)
                    {
                        if (powerList[i].CHECKROLENAME.Contains(rolelist[j]))
                        {
                            checkPower.Add(powerList[i]);
                            break;
                        }
                    }
                }
            }
            if (checkPower.Count > 0)
            {
                state = "1";
                ManyPowerCheckEntity check = checkPower.Last();//当前

                for (int i = 0; i < powerList.Count; i++)
                {
                    if (check.ID == powerList[i].ID)
                    {
                        flowid = powerList[i].ID;
                    }
                }
            }
            else
            {
                state     = "0";
                mpcEntity = powerList.First();
            }
            if (null != mpcEntity)
            {
                entity.FLOWDEPT     = mpcEntity.CHECKDEPTID;
                entity.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME;
                entity.FLOWROLE     = mpcEntity.CHECKROLEID;
                entity.FLOWROLENAME = mpcEntity.CHECKROLENAME;
                entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                entity.ISOVER       = "0"; //流程未完成,1表示完成
                //entity.FLOWNAME = entity.FLOWDEPTNAME + "审核中";
                if (mpcEntity.CHECKDEPTNAME == "执行部门" && mpcEntity.CHECKROLENAME == "负责人")
                {
                    entity.FLOWNAME = outsouringengineer.ENGINEERLETDEPT + "审批中";
                }
                else
                {
                    entity.FLOWNAME = mpcEntity.CHECKDEPTNAME + "审批中";
                }
                entity.FlowId = mpcEntity.ID;
            }
            else  //为空则表示已经完成流程
            {
                entity.FLOWDEPT     = "";
                entity.FLOWDEPTNAME = "";
                entity.FLOWROLE     = "";
                entity.FLOWROLENAME = "";
                entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                entity.ISOVER       = "1"; //流程未完成,1表示完成
                entity.FLOWNAME     = "";
                entity.FlowId       = flowid;
            }
            SafetyCollectbll.SaveForm(keyValue, entity);

            //添加审核记录
            if (state == "1")
            {
                //审核信息表
                AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity();
                aidEntity.AUDITRESULT   = "0"; //通过
                aidEntity.AUDITTIME     = DateTime.Now;
                aidEntity.AUDITPEOPLE   = curUser.UserName;
                aidEntity.AUDITPEOPLEID = curUser.UserId;
                aidEntity.APTITUDEID    = entity.ID; //关联的业务ID
                aidEntity.AUDITOPINION  = "";        //审核意见
                aidEntity.AUDITSIGNIMG  = curUser.SignImg;
                if (null != mpcEntity)
                {
                    aidEntity.REMARK = (powerList[0].AUTOID.Value - 1).ToString(); //备注 存流程的顺序号

                    //aidEntity.FlowId = mpcEntity.ID;
                }
                else
                {
                    aidEntity.REMARK = "7";
                }
                aidEntity.FlowId      = flowid;
                aidEntity.AUDITDEPTID = curUser.DeptId;
                aidEntity.AUDITDEPT   = curUser.DeptName;

                aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity);
            }

            return(Success("操作成功!"));
        }
Exemple #3
0
        public object SubmitForm()
        {
            try
            {
                string  res      = HttpContext.Current.Request["json"];;
                dynamic dy       = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  keyValue = res.Contains("keyvalue") ? dy.data.keyvalue : "";
                string  userid   = dy.userid;
                string  fileid   = res.Contains("fileid") ? dy.data.fileid : "";

                Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();

                DailyexamineEntity entity = new DailyexamineEntity
                {
                    Id              = keyValue,
                    ExamineCode     = dy.data.examinecode,
                    ExamineDept     = dy.data.examinedept,
                    ExamineDeptId   = dy.data.examinedeptid,
                    ExamineType     = dy.data.examinetype,
                    ExamineMoney    = Convert.ToDouble(dy.data.examinemoney),
                    ExaminePerson   = dy.data.examineperson,
                    ExaminePersonId = dy.data.examinepersonid,
                    ExamineTime     = Convert.ToDateTime(dy.data.examinetime),
                    ExamineBasis    = dy.data.examinebasis,
                    Remark          = dy.data.remark,
                    IsSaved         = 1,
                    IsOver          = 0,
                    ExamineContent  = dy.data.examinecontent,
                    ExamineToDept   = dy.data.examinetodept,
                    ExamineToDeptId = dy.data.examinetodeptid
                };
                string state = string.Empty;

                string moduleName = "日常考核";
                string flowid     = string.Empty;
                /// <param name="currUser">当前登录人</param>
                /// <param name="state">是否有权限审核 1:能审核 0 :不能审核</param>
                /// <param name="moduleName">模块名称</param>
                /// <param name="outengineerid">工程Id</param>
                ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId);

                List <ManyPowerCheckEntity> powerList  = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, moduleName);
                List <ManyPowerCheckEntity> checkPower = new List <ManyPowerCheckEntity>();
                //先查出执行部门编码
                for (int i = 0; i < powerList.Count; i++)
                {
                    if (powerList[i].CHECKDEPTCODE == "-3" || powerList[i].CHECKDEPTID == "-3")
                    {
                        if (curUser.RoleName.Contains("班组") || curUser.RoleName.Contains("专业"))
                        {
                            var pDept = new DepartmentBLL().GetParentDeptBySpecialArgs(curUser.ParentId, "部门");
                            powerList[i].CHECKDEPTCODE = pDept.EnCode;
                            powerList[i].CHECKDEPTID   = pDept.DepartmentId;
                        }
                        else
                        {
                            powerList[i].CHECKDEPTCODE = new DepartmentBLL().GetEntity(curUser.DeptId).EnCode;
                            powerList[i].CHECKDEPTID   = new DepartmentBLL().GetEntity(curUser.DeptId).DepartmentId;
                        }
                    }
                }
                //登录人是否有审核权限--有审核权限直接审核通过
                for (int i = 0; i < powerList.Count; i++)
                {
                    if (powerList[i].CHECKDEPTID == curUser.DeptId)
                    {
                        var rolelist = curUser.RoleName.Split(',');
                        for (int j = 0; j < rolelist.Length; j++)
                        {
                            if (powerList[i].CHECKROLENAME.Contains(rolelist[j]))
                            {
                                checkPower.Add(powerList[i]);
                                break;
                            }
                        }
                    }
                }
                if (checkPower.Count > 0)
                {
                    ManyPowerCheckEntity check = checkPower.Last();//当前

                    for (int i = 0; i < powerList.Count; i++)
                    {
                        if (check.ID == powerList[i].ID)
                        {
                            flowid = powerList[i].ID;
                        }
                    }
                }
                //if (curUser.RoleName.Contains("公司级用户"))
                //{
                //    mpcEntity = null;
                //}
                if (null != mpcEntity)
                {
                    //保存日常考核
                    entity.FlowDept     = mpcEntity.CHECKDEPTID;
                    entity.FlowDeptName = mpcEntity.CHECKDEPTNAME;
                    entity.FlowRole     = mpcEntity.CHECKROLEID;
                    entity.FlowRoleName = mpcEntity.CHECKROLENAME;
                    entity.IsSaved      = 1; //标记已经从登记到审核阶段
                    entity.IsOver       = 0; //流程未完成,1表示完成
                    entity.FlowID       = mpcEntity.ID;
                    entity.FlowName     = mpcEntity.CHECKDEPTNAME + "审核中";
                }
                else  //为空则表示已经完成流程
                {
                    entity.FlowDept     = "";
                    entity.FlowDeptName = "";
                    entity.FlowRole     = "";
                    entity.FlowRoleName = "";
                    entity.IsSaved      = 1; //标记已经从登记到审核阶段
                    entity.IsOver       = 1; //流程未完成,1表示完成
                    entity.FlowName     = "";
                    entity.FlowID       = flowid;
                }

                HttpFileCollection files = HttpContext.Current.Request.Files;
                keyValue = string.IsNullOrEmpty(keyValue) ? Guid.NewGuid().ToString() : keyValue;
                if (!string.IsNullOrEmpty(fileid))
                {
                    DeleteFile(fileid);
                }
                string path = string.Empty;
                UploadifyFile(keyValue, files, ref path);

                dailyexaminebll.SaveForm(keyValue, entity);

                //添加审核记录
                if (state == "1")
                {
                    //审核信息表
                    AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity();
                    aidEntity.AUDITRESULT   = "0"; //通过
                    aidEntity.AUDITTIME     = DateTime.Now;
                    aidEntity.AUDITPEOPLE   = curUser.UserName;
                    aidEntity.AUDITPEOPLEID = curUser.UserId;
                    aidEntity.APTITUDEID    = entity.Id; //关联的业务ID
                    aidEntity.AUDITOPINION  = "";        //审核意见
                    aidEntity.AUDITSIGNIMG  = curUser.SignImg;
                    aidEntity.FlowId        = flowid;
                    aidEntity.AUDITDEPTID   = curUser.DeptId;
                    aidEntity.AUDITDEPT     = curUser.DeptName;
                    aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity);
                }

                return(new { Code = 0, Count = 0, Info = "保存成功" });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
Exemple #4
0
        public ActionResult SubmitForm(string keyValue, SecurityDynamicsEntity entity)
        {
            Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();

            string state = string.Empty;

            string outengineerid = curUser.DeptId;
            string flowid        = string.Empty;

            string moduleName = "安全动态";
            /// <param name="currUser">当前登录人</param>
            /// <param name="state">是否有权限审核 1:能审核 0 :不能审核</param>
            /// <param name="moduleName">模块名称</param>
            /// <param name="outengineerid">工程Id</param>
            ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId);

            //新增时会根据角色自动审核,此时需根据工程和审核配置查询审核流程Id
            OutsouringengineerEntity    engineerEntity = new OutsouringengineerBLL().GetEntity(curUser.DeptId);
            List <ManyPowerCheckEntity> powerList      = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, "安全动态");
            List <ManyPowerCheckEntity> checkPower     = new List <ManyPowerCheckEntity>();

            //先查出执行部门编码
            for (int i = 0; i < powerList.Count; i++)
            {
                if (powerList[i].CHECKDEPTCODE == "-1" || powerList[i].CHECKDEPTID == "-1")
                {
                    //powerList[i].CHECKDEPTCODE = new DepartmentBLL().GetEntity(entity.PROJECTID).EnCode;
                    //powerList[i].CHECKDEPTID = new DepartmentBLL().GetEntity(entity.PROJECTID).DepartmentId;
                    //powerList[i].CHECKDEPTCODE = new DepartmentBLL().GetEntityByCode(entity.CreateUserDeptCode).EnCode;
                    //powerList[i].CHECKDEPTID = new DepartmentBLL().GetEntityByCode(entity.CreateUserDeptCode).DepartmentId;
                    powerList[i].CHECKDEPTCODE = curUser.DeptCode;
                    powerList[i].CHECKDEPTID   = curUser.DeptId;
                }
                //创建部门
                if (powerList[i].CHECKDEPTCODE == "-3" || powerList[i].CHECKDEPTID == "-3")
                {
                    if (entity.CreateUserDeptCode == null || entity.CreateUserDeptCode == "")
                    {
                        powerList[i].CHECKDEPTCODE = new DepartmentBLL().GetEntityByCode(curUser.DeptCode).EnCode;
                        powerList[i].CHECKDEPTID   = new DepartmentBLL().GetEntityByCode(curUser.DeptCode).DepartmentId;
                    }
                    else
                    {
                        powerList[i].CHECKDEPTCODE = new DepartmentBLL().GetEntityByCode(entity.CreateUserDeptCode).EnCode;
                        powerList[i].CHECKDEPTID   = new DepartmentBLL().GetEntityByCode(entity.CreateUserDeptCode).DepartmentId;
                    }
                }
            }
            //登录人是否有审核权限--有审核权限直接审核通过
            for (int i = 0; i < powerList.Count; i++)
            {
                if (powerList[i].CHECKDEPTID == curUser.DeptId)
                {
                    var rolelist = curUser.RoleName.Split(',');
                    for (int j = 0; j < rolelist.Length; j++)
                    {
                        if (powerList[i].CHECKROLENAME.Contains(rolelist[j]))
                        {
                            checkPower.Add(powerList[i]);
                            break;
                        }
                    }
                }
            }
            if (checkPower.Count > 0)
            {
                ManyPowerCheckEntity check = checkPower.Last();//当前

                for (int i = 0; i < powerList.Count; i++)
                {
                    if (check.ID == powerList[i].ID)
                    {
                        flowid = powerList[i].ID;
                    }
                }
            }
            if (null != mpcEntity)
            {
                //保存安全动态记录
                entity.FLOWDEPT     = mpcEntity.CHECKDEPTID;
                entity.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME;
                entity.FLOWROLE     = mpcEntity.CHECKROLEID;
                entity.FLOWROLENAME = mpcEntity.CHECKROLENAME;
                entity.IsSend       = "0"; //标记已经从登记到审核阶段
                entity.ISOVER       = "0"; //流程未完成,1表示完成
                entity.FLOWNAME     = mpcEntity.CHECKDEPTNAME + "审核中";
                entity.FlowId       = mpcEntity.ID;
                //DataTable dt = new UserBLL().GetUserAccountByRoleAndDept(curUser.OrganizeId, mpcEntity.CHECKDEPTID, mpcEntity.CHECKROLENAME);
                //var userAccount = dt.Rows[0]["account"].ToString();
                //var userName = dt.Rows[0]["realname"].ToString();
                //JPushApi.PushMessage(userAccount, userName, "WB001", entity.ID);
            }
            else  //为空则表示已经完成流程
            {
                entity.FLOWDEPT     = "";
                entity.FLOWDEPTNAME = "";
                entity.FLOWROLE     = "";
                entity.FLOWROLENAME = "";
                entity.IsSend       = "0"; //标记已经从登记到审核阶段
                entity.ISOVER       = "1"; //流程未完成,1表示完成
                entity.FLOWNAME     = "";
                entity.FlowId       = flowid;
                entity.ReleaseTime  = DateTime.Now;//发布时间
            }
            securitydynamicsbll.SaveForm(keyValue, entity);

            //添加审核记录
            if (state == "1")
            {
                //审核信息表
                AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity();
                aidEntity.AUDITRESULT   = "0"; //通过
                aidEntity.AUDITTIME     = DateTime.Now;
                aidEntity.AUDITPEOPLE   = curUser.UserName;
                aidEntity.AUDITPEOPLEID = curUser.UserId;
                aidEntity.APTITUDEID    = entity.Id; //关联的业务ID
                aidEntity.AUDITOPINION  = "";        //审核意见
                aidEntity.AUDITSIGNIMG  = curUser.SignImg;
                if (null != mpcEntity)
                {
                    aidEntity.REMARK = (powerList[0].AUTOID.Value - 1).ToString(); //备注 存流程的顺序号

                    //aidEntity.FlowId = mpcEntity.ID;
                }
                else
                {
                    aidEntity.REMARK = "7";
                }
                aidEntity.FlowId = flowid;
                //if (curUser.RoleName.Contains("公司级用户") || curUser.RoleName.Contains("厂级部门用户"))
                //{
                //    aidEntity.AUDITDEPTID = curUser.OrganizeId;
                //    aidEntity.AUDITDEPT = curUser.OrganizeName;
                //}
                //else
                //{
                aidEntity.AUDITDEPTID = curUser.DeptId;
                aidEntity.AUDITDEPT   = curUser.DeptName;
                //}
                aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity);
            }

            return(Success("操作成功!"));
        }
Exemple #5
0
        public ActionResult SubmitForm(string keyValue, DailyexamineEntity entity)
        {
            Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();

            string state = string.Empty;

            string moduleName = "日常考核";

            /// <param name="currUser">当前登录人</param>
            /// <param name="state">是否有权限审核 1:能审核 0 :不能审核</param>
            /// <param name="moduleName">模块名称</param>
            /// <param name="outengineerid">工程Id</param>
            ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId);

            string flowid = string.Empty;
            List <ManyPowerCheckEntity> powerList  = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, moduleName);
            List <ManyPowerCheckEntity> checkPower = new List <ManyPowerCheckEntity>();

            //先查出执行部门编码
            for (int i = 0; i < powerList.Count; i++)
            {
                if (powerList[i].CHECKDEPTCODE == "-3" || powerList[i].CHECKDEPTID == "-3")
                {
                    if (curUser.RoleName.Contains("班组") || curUser.RoleName.Contains("专业"))
                    {
                        var pDept = new DepartmentBLL().GetParentDeptBySpecialArgs(curUser.ParentId, "部门");
                        powerList[i].CHECKDEPTCODE = pDept.EnCode;
                        powerList[i].CHECKDEPTID   = pDept.DepartmentId;
                    }
                    else
                    {
                        powerList[i].CHECKDEPTCODE = new DepartmentBLL().GetEntity(curUser.DeptId).EnCode;
                        powerList[i].CHECKDEPTID   = new DepartmentBLL().GetEntity(curUser.DeptId).DepartmentId;
                    }
                }
            }
            //登录人是否有审核权限--有审核权限直接审核通过
            for (int i = 0; i < powerList.Count; i++)
            {
                if (powerList[i].CHECKDEPTID == curUser.DeptId)
                {
                    var rolelist = curUser.RoleName.Split(',');
                    for (int j = 0; j < rolelist.Length; j++)
                    {
                        if (powerList[i].CHECKROLENAME.Contains(rolelist[j]))
                        {
                            checkPower.Add(powerList[i]);
                            break;
                        }
                    }
                }
            }
            if (checkPower.Count > 0)
            {
                ManyPowerCheckEntity check = checkPower.Last();//当前

                for (int i = 0; i < powerList.Count; i++)
                {
                    if (check.ID == powerList[i].ID)
                    {
                        flowid = powerList[i].ID;
                    }
                }
            }
            //if (curUser.RoleName.Contains("公司级用户"))
            //{
            //    mpcEntity = null;
            //}
            if (null != mpcEntity)
            {
                //保存三措两案记录
                entity.FlowDept     = mpcEntity.CHECKDEPTID;
                entity.FlowDeptName = mpcEntity.CHECKDEPTNAME;
                entity.FlowRole     = mpcEntity.CHECKROLEID;
                entity.FlowRoleName = mpcEntity.CHECKROLENAME;
                entity.IsSaved      = 1; //标记已经从登记到审核阶段
                entity.IsOver       = 0; //流程未完成,1表示完成
                entity.FlowID       = mpcEntity.ID;
                entity.FlowName     = mpcEntity.CHECKDEPTNAME + "审核中";
            }
            else  //为空则表示已经完成流程
            {
                entity.FlowDept     = "";
                entity.FlowDeptName = "";
                entity.FlowRole     = "";
                entity.FlowRoleName = "";
                entity.IsSaved      = 1; //标记已经从登记到审核阶段
                entity.IsOver       = 1; //流程未完成,1表示完成
                entity.FlowName     = "";
                entity.FlowID       = flowid;
            }
            dailyexaminebll.SaveForm(keyValue, entity);

            //添加审核记录
            if (state == "1")
            {
                //审核信息表
                AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity();
                aidEntity.AUDITRESULT   = "0"; //通过
                aidEntity.AUDITTIME     = DateTime.Now;
                aidEntity.AUDITPEOPLE   = curUser.UserName;
                aidEntity.AUDITPEOPLEID = curUser.UserId;
                aidEntity.APTITUDEID    = entity.Id; //关联的业务ID
                aidEntity.AUDITOPINION  = "";        //审核意见
                aidEntity.AUDITSIGNIMG  = curUser.SignImg;
                aidEntity.FlowId        = flowid;
                if (null != mpcEntity)
                {
                    aidEntity.REMARK = (mpcEntity.AUTOID.Value - 1).ToString(); //备注 存流程的顺序号
                }
                else
                {
                    aidEntity.REMARK = "7";
                }
                aidEntity.AUDITDEPTID = curUser.DeptId;
                aidEntity.AUDITDEPT   = curUser.DeptName;
                aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity);
            }

            return(Success("操作成功!"));
        }
        public ActionResult SaveForm(string keyValue, PowerplantreformEntity entity)
        {
            try
            {
                PowerplanthandledetailEntity powerplanthandledetailentity = powerplanthandledetailbll.GetEntity(entity.PowerPlantHandleDetailId);
                if (powerplanthandledetailentity != null)
                {
                    Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();
                    powerplanthandledetailentity.RealReformDept     = curUser.DeptName;
                    powerplanthandledetailentity.RealReformDeptId   = curUser.DeptId;
                    powerplanthandledetailentity.RealReformDeptCode = curUser.DeptCode;
                    string state = string.Empty;

                    string moduleName = "事故事件处理记录-验收";

                    /// <param name="currUser">当前登录人</param>
                    /// <param name="state">是否有权限审核 1:能审核 0 :不能审核</param>
                    /// <param name="moduleName">模块名称</param>
                    /// <param name="outengineerid">工程Id</param>
                    ManyPowerCheckEntity mpcEntity = powerplanthandlebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId);

                    string flowid = string.Empty;
                    List <ManyPowerCheckEntity> powerList  = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, moduleName);
                    List <ManyPowerCheckEntity> checkPower = new List <ManyPowerCheckEntity>();
                    foreach (var item in powerList)
                    {
                        if (item.CHECKDEPTID == "-3" || item.CHECKDEPTID == "-1")
                        {
                            item.CHECKDEPTID   = curUser.DeptId;
                            item.CHECKDEPTCODE = curUser.DeptCode;
                            item.CHECKDEPTNAME = curUser.DeptName;
                        }
                    }
                    for (int i = 0; i < powerList.Count; i++)
                    {
                        if (powerList[i].CHECKDEPTID == curUser.DeptId)
                        {
                            var rolelist = curUser.RoleName.Split(',');
                            for (int j = 0; j < rolelist.Length; j++)
                            {
                                if (powerList[i].CHECKROLENAME.Contains(rolelist[j]))
                                {
                                    checkPower.Add(powerList[i]);
                                    break;
                                }
                            }
                        }
                    }
                    if (checkPower.Count > 0)
                    {
                        ManyPowerCheckEntity check = checkPower.Last();//当前

                        for (int i = 0; i < powerList.Count; i++)
                        {
                            if (check.ID == powerList[i].ID)
                            {
                                flowid = powerList[i].ID;
                            }
                        }
                    }
                    if (null != mpcEntity)
                    {
                        powerplanthandledetailentity.FlowDept     = mpcEntity.CHECKDEPTID;
                        powerplanthandledetailentity.FlowDeptName = mpcEntity.CHECKDEPTNAME;
                        powerplanthandledetailentity.FlowRole     = mpcEntity.CHECKROLEID;
                        powerplanthandledetailentity.FlowRoleName = mpcEntity.CHECKROLENAME;
                        powerplanthandledetailentity.ApplyState   = 4; //流程未完成,1表示完成
                        powerplanthandledetailentity.FlowId       = mpcEntity.ID;
                        powerplanthandledetailentity.FlowName     = mpcEntity.CHECKDEPTNAME + "验收中";
                    }
                    else  //为空则表示已经完成流程
                    {
                        powerplanthandledetailentity.FlowDept     = "";
                        powerplanthandledetailentity.FlowDeptName = "";
                        powerplanthandledetailentity.FlowRole     = "";
                        powerplanthandledetailentity.FlowRoleName = "";
                        powerplanthandledetailentity.ApplyState   = 5; //流程未完成,1表示完成
                        powerplanthandledetailentity.FlowName     = "";
                        powerplanthandledetailentity.FlowId       = "";
                    }
                    entity.RectificationPerson   = curUser.UserName;
                    entity.RectificationPersonId = curUser.UserId;
                    entity.Disable = 0;
                    entity.RectificationPersonSignImg = string.IsNullOrWhiteSpace(entity.RectificationPersonSignImg) ? "" : entity.RectificationPersonSignImg.ToString().Replace("../..", "");
                    powerplantreformbll.SaveForm(keyValue, entity);
                    powerplanthandledetailbll.SaveForm(powerplanthandledetailentity.Id, powerplanthandledetailentity);
                    powerplanthandlebll.UpdateApplyStatus(entity.PowerPlantHandleId);

                    //添加验收信息
                    if (state == "1")
                    {
                        //验收信息
                        PowerplantcheckEntity checkEntity = new PowerplantcheckEntity();
                        checkEntity.AuditResult              = 0; //通过
                        checkEntity.AuditTime                = DateTime.Now;
                        checkEntity.AuditPeople              = curUser.UserName;
                        checkEntity.AuditPeopleId            = curUser.UserId;
                        checkEntity.PowerPlantHandleId       = entity.PowerPlantHandleId;
                        checkEntity.PowerPlantHandleDetailId = entity.PowerPlantHandleDetailId;
                        checkEntity.PowerPlantReformId       = keyValue;
                        checkEntity.AuditOpinion             = ""; //审核意见
                        checkEntity.AuditSignImg             = string.IsNullOrWhiteSpace(entity.RectificationPersonSignImg) ? "" : entity.RectificationPersonSignImg.ToString().Replace("../..", "");
                        checkEntity.FlowId = flowid;
                        if (null != mpcEntity)
                        {
                            checkEntity.Remark = (mpcEntity.AUTOID.Value - 1).ToString(); //备注 存流程的顺序号
                        }
                        else
                        {
                            checkEntity.Remark = "7";
                        }
                        checkEntity.AuditDeptId = curUser.DeptId;
                        checkEntity.AuditDept   = curUser.DeptName;
                        checkEntity.Disable     = 0;
                        powerplantcheckbll.SaveForm(checkEntity.Id, checkEntity);
                    }
                    powerplantreformbll.SaveForm(keyValue, entity);
                    return(Success("操作成功。"));
                }
                else
                {
                    return(Error("系统错误,请联系系统管理员"));
                }
            }
            catch (Exception ex)
            {
                return(Error(ex.ToString()));
            }
        }
        public ActionResult SubmitForm(string keyValue, DangerChemicalsReceiveEntity entity)
        {
            var clEntity = DangerChemicalsBll.GetEntity(entity.MainId);

            if (clEntity.IsScene == "现场存放")
            {
                try
                {
                    if (entity.ReceiveUnit == clEntity.Unit)
                    {
                        if (Convert.ToDecimal(entity.ReceiveNum) <= Convert.ToDecimal(clEntity.Inventory))
                        {
                            clEntity.Inventory = (Convert.ToDecimal(clEntity.Inventory) - Convert.ToDecimal(entity.ReceiveNum)).ToString();
                            clEntity.Amount    = (Convert.ToDecimal(clEntity.Inventory) / Convert.ToDecimal(clEntity.Specification)).ToString("#0.00");
                            DangerChemicalsBll.SaveForm(entity.MainId, clEntity);
                            entity.PracticalNum = Convert.ToDecimal(entity.ReceiveNum).ToString(); //实际发放库存量
                        }
                        else
                        {
                            return(Error("操作失败,该危化品实际库存已变化,库存为:" + clEntity.Inventory + " " + clEntity.Unit + "!"));
                        }
                    }
                    if (entity.ReceiveUnit == clEntity.AmountUnit)
                    {
                        if (Convert.ToDecimal(entity.ReceiveNum) <= Convert.ToDecimal(clEntity.Amount))
                        {
                            clEntity.Inventory = (Convert.ToDecimal(clEntity.Inventory) - (Convert.ToDecimal(entity.ReceiveNum) * Convert.ToDecimal(clEntity.Specification))).ToString();
                            clEntity.Amount    = (Convert.ToDecimal(clEntity.Inventory) / Convert.ToDecimal(clEntity.Specification)).ToString("#0.00");
                            DangerChemicalsBll.SaveForm(entity.MainId, clEntity);
                            entity.PracticalNum = (Convert.ToDecimal(entity.ReceiveNum) * Convert.ToDecimal(clEntity.Specification)).ToString(); //实际发放库存量
                        }
                        else
                        {
                            return(Error("操作失败,该危化品实际库存已变化,库存为:" + clEntity.Inventory + " " + clEntity.Unit + "!"));
                        }
                    }
                }
                catch { }

                entity.FLOWDEPT     = "";
                entity.FLOWDEPTNAME = "";
                entity.FLOWROLE     = "";
                entity.FLOWROLENAME = "";
                entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                entity.ISOVER       = "1"; //流程未完成,1表示完成
                entity.GrantState   = 3;   //2表示发放中
                entity.FLOWNAME     = "";
                entity.FlowId       = "";
                entity.GrantDate    = DateTime.Now;

                DangerChemicalsReceiveBll.SaveForm(keyValue, entity);
            }
            else
            {
                Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();

                string state = string.Empty;

                string flowid = string.Empty;

                string moduleName = "危化品领用";

                // <param name="state">是否有权限审核 1:能审核 0 :不能审核</param>
                ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId);

                //新增时会根据角色自动审核
                List <ManyPowerCheckEntity> powerList  = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, "危化品领用");
                List <ManyPowerCheckEntity> checkPower = new List <ManyPowerCheckEntity>();
                //先查出执行部门编码
                for (int i = 0; i < powerList.Count; i++)
                {
                    if (powerList[i].CHECKDEPTCODE == "-1" || powerList[i].CHECKDEPTID == "-1")
                    {
                        var createdeptentity = new DepartmentBLL().GetEntityByCode(curUser.DeptCode);
                        while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组")
                        {
                            createdeptentity = new DepartmentBLL().GetEntity(createdeptentity.ParentId);
                        }
                        powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode;
                        powerList[i].CHECKDEPTID   = createdeptentity.DepartmentId;
                    }
                    //创建部门
                    if (powerList[i].CHECKDEPTCODE == "-3" || powerList[i].CHECKDEPTID == "-3")
                    {
                        var createdeptentity = new DepartmentBLL().GetEntityByCode(curUser.DeptCode);
                        while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组")
                        {
                            createdeptentity = new DepartmentBLL().GetEntity(createdeptentity.ParentId);
                        }
                        powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode;
                        powerList[i].CHECKDEPTID   = createdeptentity.DepartmentId;
                    }
                }
                //登录人是否有审核权限--有审核权限直接审核通过
                for (int i = 0; i < powerList.Count; i++)
                {
                    if (powerList[i].CHECKDEPTID == curUser.DeptId)
                    {
                        var rolelist = curUser.RoleName.Split(',');
                        for (int j = 0; j < rolelist.Length; j++)
                        {
                            if (powerList[i].CHECKROLENAME.Contains(rolelist[j]))
                            {
                                checkPower.Add(powerList[i]);
                                break;
                            }
                        }
                    }
                }
                if (checkPower.Count > 0)
                {
                    ManyPowerCheckEntity check = checkPower.Last();//当前

                    for (int i = 0; i < powerList.Count; i++)
                    {
                        if (check.ID == powerList[i].ID)
                        {
                            flowid = powerList[i].ID;
                        }
                    }
                }
                else
                {
                    if (powerList.Count > 0)
                    {
                        mpcEntity = powerList.First();
                    }
                }
                if (null != mpcEntity)
                {
                    //保存三措两案记录
                    entity.FLOWDEPT     = mpcEntity.CHECKDEPTID;
                    entity.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME;
                    entity.FLOWROLE     = mpcEntity.CHECKROLEID;
                    entity.FLOWROLENAME = mpcEntity.CHECKROLENAME;
                    entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                    entity.ISOVER       = "0"; //流程未完成,1表示完成
                    entity.FLOWNAME     = mpcEntity.CHECKDEPTNAME + "审核中";
                    entity.FlowId       = mpcEntity.ID;
                }
                else  //为空则表示已经完成流程
                {
                    entity.FLOWDEPT     = "";
                    entity.FLOWDEPTNAME = "";
                    entity.FLOWROLE     = "";
                    entity.FLOWROLENAME = "";
                    entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                    entity.ISOVER       = "1"; //流程未完成,1表示完成
                    entity.GrantState   = 2;   //2表示发放中
                    entity.FLOWNAME     = "";
                    entity.FlowId       = flowid;
                }

                DangerChemicalsReceiveBll.SaveForm(keyValue, entity);


                //添加审核记录
                if (state == "1")
                {
                    //审核信息表
                    AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity();
                    aidEntity.AUDITRESULT   = "0"; //通过
                    aidEntity.AUDITTIME     = DateTime.Now;
                    aidEntity.AUDITPEOPLE   = curUser.UserName;
                    aidEntity.AUDITPEOPLEID = curUser.UserId;
                    aidEntity.APTITUDEID    = entity.ID; //关联的业务ID
                    aidEntity.AUDITOPINION  = "";        //审核意见
                    aidEntity.AUDITSIGNIMG  = curUser.SignImg;
                    if (null != mpcEntity)
                    {
                        aidEntity.REMARK = (powerList[0].AUTOID.Value - 1).ToString(); //备注 存流程的顺序号

                        //aidEntity.FlowId = mpcEntity.ID;
                    }
                    else
                    {
                        aidEntity.REMARK = "7";
                    }
                    aidEntity.FlowId      = flowid;
                    aidEntity.AUDITDEPTID = curUser.DeptId;
                    aidEntity.AUDITDEPT   = curUser.DeptName;

                    aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity);
                }
            }

            return(Success("操作成功!"));
        }
        /// <summary>
        /// 导出审批单
        /// </summary>
        /// <param name="keyValue"></param>
        public void ExportData(string keyValue)
        {
            Operator     user = ERCHTMS.Code.OperatorProvider.Provider.Current();
            HttpResponse resp = System.Web.HttpContext.Current.Response;
            //报告对象
            string fileName = Server.MapPath("~/Resource/ExcelTemplate/应急物资领用单模板.docx");

            Aspose.Words.Document doc     = new Aspose.Words.Document(fileName);
            DocumentBuilder       builder = new DocumentBuilder(doc);
            DataTable             dt      = new DataTable();

            dt.Columns.Add("applydept");   //申请部门
            dt.Columns.Add("applyperson"); //申请人
            dt.Columns.Add("applytime");   //申请时间
            dt.Columns.Add("reason");      //申请原因
            dt.Columns.Add("idea1");       //部门负责人意见
            dt.Columns.Add("person1");     //部门负责人
            dt.Columns.Add("time1");       //部门负责人审批时间
            dt.Columns.Add("idea2");       //安环部负责人意见
            dt.Columns.Add("person2");     //安环部负责人
            dt.Columns.Add("time2");       //安环部负责人审批时间
            dt.Columns.Add("idea3");       //物料部负责人意见
            dt.Columns.Add("person3");     //物料部负责人
            dt.Columns.Add("time3");       //物料部负责人审批时间
            dt.Columns.Add("idea4");       //分管领导意见
            dt.Columns.Add("person4");     //分管领导签名
            dt.Columns.Add("time4");       //分管领导时间
            dt.Columns.Add("idea5");       //应急物资出库人审批意见
            dt.Columns.Add("person5");     //应急物资出库人
            dt.Columns.Add("time5");       //应急物资出库人审批时间
            DataRow row = dt.NewRow();

            SuppliesacceptEntity entity = suppliesacceptbll.GetEntity(keyValue);

            row["applydept"]   = entity.ApplyDept;
            row["applyperson"] = entity.ApplyPerson;
            row["applytime"]   = entity.ApplyDate.Value.ToString("yyyy年MM月dd日HH时mm分");
            row["reason"]      = entity.AcceptReason;


            //物资信息
            DataTable dt1 = new DataTable("A");

            dt1.Columns.Add("num");
            dt1.Columns.Add("suppliesname");
            dt1.Columns.Add("models");
            dt1.Columns.Add("acceptnum");

            SuppliesAcceptDetailBLL suppliesacceptdetailbll = new SuppliesAcceptDetailBLL();

            var list = suppliesacceptdetailbll.GetList("").Where(t => t.RecId == keyValue).ToList();

            for (int i = 0; i < list.Count; i++)
            {
                DataRow row1 = dt1.NewRow();
                row1["num"]          = i + 1;
                row1["suppliesname"] = list[i].SuppliesName;
                row1["models"]       = list[i].Models;
                row1["acceptnum"]    = list[i].AcceptNum;
                dt1.Rows.Add(row1);
            }
            doc.MailMerge.ExecuteWithRegions(dt1);


            //审核记录
            AptitudeinvestigateauditBLL aptitudeinvestigateauditbll = new AptitudeinvestigateauditBLL();
            ManyPowerCheckBLL           manypowercheckbll           = new ManyPowerCheckBLL();
            var data = aptitudeinvestigateauditbll.GetAuditRecList(keyValue);

            for (int i = 0; i < data.Rows.Count; i++)
            {
                try
                {
                    var power = manypowercheckbll.GetEntity(data.Rows[i]["flowid"].ToString());
                    row["idea" + power.SERIALNUM] = data.Rows[i]["auditopinion"].ToString();
                    if (string.IsNullOrWhiteSpace(data.Rows[i]["auditsignimg"].ToString()))
                    {
                        row["person" + power.SERIALNUM] = Server.MapPath("~/content/Images/no_1.png");
                    }
                    else
                    {
                        var filepath = Server.MapPath("~/") + data.Rows[i]["auditsignimg"].ToString().Replace("../../", "").ToString();
                        if (System.IO.File.Exists(filepath))
                        {
                            row["person" + power.SERIALNUM] = filepath;
                        }
                        else
                        {
                            row["person" + power.SERIALNUM] = Server.MapPath("~/content/Images/no_1.png");
                        }
                    }
                    row["time" + power.SERIALNUM] = Convert.ToDateTime(data.Rows[i]["audittime"].ToString()).ToString("yyyy年MM月dd日");
                }
                catch (System.Exception ex)
                {
                }
            }
            dt.Rows.Add(row);
            doc.MailMerge.Execute(dt);
            doc.MailMerge.DeleteFields();
            doc.Save(resp, Server.UrlEncode("应急物资领用单" + DateTime.Now.ToString("yyyyMMdd") + ".docx"), ContentDisposition.Attachment, Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Docx));
        }