public bool IsAuditByUserId(string userid) { var user = new UserService().GetEntity(userid); if (user == null) { return(false); } if (string.IsNullOrWhiteSpace(user.ProjectId)) { return(false); } else { var project = new OutsouringengineerService().GetEntity(user.ProjectId); if (project == null) { return(false); } else { var proess = new StartappprocessstatusService().GetList("").Where(x => x.OUTPROJECTID == project.ID).FirstOrDefault(); if (proess == null) { return(false); } else { if (proess.PEOPLESTATUS == "1") { return(true); } else { return(false); } } } } }
/// <summary> /// 待审(核)批单位资质审查、待审(核)批人员资质审查、待审(核)批三措两案、待审(核)批特种设备验收、待审(核)批安全/电动工器具验收、待审(核)批入厂许可、待审(核)批开工申请 /// </summary> /// <param name="user"></param> /// <returns></returns> public List <int> ToAuditOutPeoject(Operator currUser) { List <int> toAuditNum = new List <int>(); string role = currUser.RoleName; string deptId = string.Empty; string deptName = string.Empty; //公司级用户取机构对象 if (role.Contains("公司级用户")) { deptId = currUser.OrganizeId; //机构ID deptName = currUser.OrganizeName; //机构名称 } else { deptId = currUser.DeptId; //部门ID deptName = currUser.DeptName; //部门ID } string sql = string.Empty; string[] arrRole = role.Split(','); string strWhere = string.Empty; #region 单位资质审查待审核(查) sql = string.Empty; sql = string.Format("select '' as approveuserids,outengineerid,flowid,id from epg_aptitudeinvestigateinfo s "); strWhere = string.Empty; strWhere += string.Format(" where s.isauditover=0 and s.createuserorgcode='{0}' and s.issaveorcommit='1' ", currUser.OrganizeCode); var dt = this.BaseRepository().FindTable(sql + strWhere); for (int i = 0; i < dt.Rows.Count; i++) { var engineerEntity = new OutsouringengineerService().GetEntity(dt.Rows[i]["outengineerid"].ToString()); var excutdept = new DepartmentService().GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId; var outengineerdept = new DepartmentService().GetEntity(engineerEntity.OUTPROJECTID).DepartmentId; var supervisordept = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : new DepartmentService().GetEntity(engineerEntity.SupervisorId).DepartmentId; //获取下一步审核人 string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["outengineerid"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["outengineerid"].ToString()); dt.Rows[i]["approveuserids"] = str; } string[] applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("id")).ToArray(); if (applyids.Length > 0) { toAuditNum.Add(applyids.Length); } else { toAuditNum.Add(0); } #endregion #region 人员审查待审核 sql = string.Empty; sql = string.Format("select '' as approveuserids,outengineerid,flowid,id from epg_peoplereview s "); strWhere = string.Empty; strWhere += string.Format(" where s.createuserorgcode='{0}' and isauditover=0 and s.issaveorcommit='1' ", currUser.OrganizeCode); dt = this.BaseRepository().FindTable(sql + strWhere); for (int i = 0; i < dt.Rows.Count; i++) { var engineerEntity = new OutsouringengineerService().GetEntity(dt.Rows[i]["outengineerid"].ToString()); var excutdept = new DepartmentService().GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId; var outengineerdept = new DepartmentService().GetEntity(engineerEntity.OUTPROJECTID).DepartmentId; var supervisordept = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : new DepartmentService().GetEntity(engineerEntity.SupervisorId).DepartmentId; //获取下一步审核人 string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["outengineerid"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["outengineerid"].ToString()); dt.Rows[i]["approveuserids"] = str; } applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("id")).ToArray(); if (applyids.Length > 0) { toAuditNum.Add(applyids.Length); } else { toAuditNum.Add(0); } #endregion #region 措两案待审核 sql = string.Empty; sql = string.Format("select '' as approveuserids,projectid,flowid,id,ENGINEERLETDEPTID from epg_schememeasure s "); strWhere = string.Empty; strWhere += string.Format(" where s.createuserorgcode='{0}' and s.isover='0' and s.issaved='1' ", currUser.OrganizeCode); dt = this.BaseRepository().FindTable(sql + strWhere); for (int i = 0; i < dt.Rows.Count; i++) { var engineerEntity = new OutsouringengineerService().GetEntity(dt.Rows[i]["projectid"].ToString()); if (engineerEntity != null) { var excutdept = new DepartmentService().GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId; var outengineerdept = new DepartmentService().GetEntity(engineerEntity.OUTPROJECTID).DepartmentId; var supervisordept = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : new DepartmentService().GetEntity(engineerEntity.SupervisorId).DepartmentId; //获取下一步审核人 string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["id"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["projectid"].ToString()); dt.Rows[i]["approveuserids"] = str; } else { string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["id"].ToString(), "", "", dt.Rows[i]["engineerletdeptid"].ToString(), "", "", "", "", "", dt.Rows[i]["projectid"].ToString()); dt.Rows[i]["approveuserids"] = str; } //dt.Rows[i]["approveuserids"] = str; } applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("id")).ToArray(); if (applyids.Length > 0) { toAuditNum.Add(applyids.Length); } else { toAuditNum.Add(0); } #endregion #region 特种设备 sql = string.Empty; sql = string.Format("select '' as approveuserids,outengineerid,flowid,toolsid from epg_tools s "); strWhere = string.Empty; strWhere += string.Format(" where equiptype='2' and s.createuserorgcode='{0}' and s.isover='0' and s.issaved='1' ", currUser.OrganizeCode); dt = this.BaseRepository().FindTable(sql + strWhere); for (int i = 0; i < dt.Rows.Count; i++) { var engineerEntity = new OutsouringengineerService().GetEntity(dt.Rows[i]["outengineerid"].ToString()); var excutdept = new DepartmentService().GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId; var outengineerdept = new DepartmentService().GetEntity(engineerEntity.OUTPROJECTID).DepartmentId; var supervisordept = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : new DepartmentService().GetEntity(engineerEntity.SupervisorId).DepartmentId; //获取下一步审核人 string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["toolsid"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["outengineerid"].ToString()); dt.Rows[i]["approveuserids"] = str; } applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("toolsid")).ToArray(); if (applyids.Length > 0) { toAuditNum.Add(applyids.Length); } else { toAuditNum.Add(0); } #endregion #region 普通设备 sql = string.Empty; sql = string.Format("select '' as approveuserids,outengineerid,flowid,toolsid from epg_tools s "); strWhere = string.Empty; strWhere += string.Format(" where equiptype='1' and s.createuserorgcode='{0}' and s.isover='0' and s.issaved='1' ", currUser.OrganizeCode); dt = this.BaseRepository().FindTable(sql + strWhere); for (int i = 0; i < dt.Rows.Count; i++) { var engineerEntity = new OutsouringengineerService().GetEntity(dt.Rows[i]["outengineerid"].ToString()); var excutdept = new DepartmentService().GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId; var outengineerdept = new DepartmentService().GetEntity(engineerEntity.OUTPROJECTID).DepartmentId; var supervisordept = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : new DepartmentService().GetEntity(engineerEntity.SupervisorId).DepartmentId; //获取下一步审核人 string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["toolsid"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["outengineerid"].ToString()); dt.Rows[i]["approveuserids"] = str; } applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("toolsid")).ToArray(); if (applyids.Length > 0) { toAuditNum.Add(applyids.Length); } else { toAuditNum.Add(0); } #endregion #region 入场许可 sql = string.Empty; sql = string.Format("select '' as approveuserids,outengineerid,flowid,id from epg_intromission s "); strWhere = string.Empty; strWhere += string.Format(" where s.createuserorgcode='{0}' and (s.investigatestate='1' or s.investigatestate='2') ", currUser.OrganizeCode); dt = this.BaseRepository().FindTable(sql + strWhere); for (int i = 0; i < dt.Rows.Count; i++) { var engineerEntity = new OutsouringengineerService().GetEntity(dt.Rows[i]["outengineerid"].ToString()); var excutdept = new DepartmentService().GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId; var outengineerdept = new DepartmentService().GetEntity(engineerEntity.OUTPROJECTID).DepartmentId; var supervisordept = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : new DepartmentService().GetEntity(engineerEntity.SupervisorId).DepartmentId; //获取下一步审核人 string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["id"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["outengineerid"].ToString()); dt.Rows[i]["approveuserids"] = str; } applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("id")).ToArray(); if (applyids.Length > 0) { toAuditNum.Add(applyids.Length); } else { toAuditNum.Add(0); } //sql = string.Empty; //sql = string.Format("select count(id) intromnum from epg_intromission s "); //strWhere = string.Empty; //foreach (string str in arrRole) //{ // //审查内容 // strWhere += string.Format(@" select distinct a.id from epg_intromission a // left join bis_manypowercheck b on a.flowid = b.id // left join bis_manypowercheck c on b.serialnum = c.serialnum and b.moduleno = c.moduleno // left join epg_outsouringengineer d on a.outengineerid = d.id // where a.investigatestate ='1' and ((c.checkdeptid ='-1' and d.engineerletdeptid='{0}' and c.checkrolename like '%{1}%') // or (c.checkdeptid = '{0}' and c.checkrolename like '%{1}%') or ( c.checkdeptid ='-2' and d.outprojectid='{0}' and c.checkrolename like '%{1}%')) // union // ", deptId, str); // //审核内容 // strWhere += string.Format(@" select distinct a.id from epg_intromission a where a.flowdept='{0}' and a.flowrolename like '%{1}%' and a.investigatestate ='2' // union", deptId, str); //} //if (!string.IsNullOrEmpty(strWhere)) //{ // strWhere = strWhere.Substring(0, strWhere.Length - 5); //} //var conditionDt1 = new IntromissionService().GetDataTableBySql(strWhere); //string ids1 = string.Empty; //foreach (DataRow row in conditionDt1.Rows) //{ // ids1 += "'" + row["id"].ToString() + "',"; //} //if (!string.IsNullOrEmpty(ids1)) //{ // ids1 = ids1.Substring(0, ids1.Length - 1); // sql += string.Format("where s.id in ({0})", ids1); //} //else //{ // sql += string.Format("where 1!=1 "); //} //sql += string.Format(" and s.createuserorgcode='{0}'", currUser.OrganizeCode); //strWhere = string.Empty; //strWhere += string.Format(" where s.flowdept like'%{0}%' and s.createuserorgcode='{1}' and s.investigatestate !='3' ", currUser.DeptId, currUser.OrganizeCode); //strWhere += " and ("; //foreach (string str in arrRole) //{ // strWhere += string.Format(" s.flowrolename like '%{0}%' or", str); //} //strWhere = strWhere.Substring(0, strWhere.Length - 2); //strWhere += " )"; //sql = sql + strWhere; //dt = this.BaseRepository().FindTable(sql); //if (dt.Rows.Count > 0) //{ // toAuditNum.Add(Convert.ToInt32(dt.Rows[0]["intromnum"].ToString())); //} //else //{ // toAuditNum.Add(0); //} #endregion #region 开工申请待审核(查) sql = string.Empty; sql = string.Format("select '' as approveuserids,outengineerid,nodeid,id from epg_startapplyfor s "); strWhere = string.Empty; strWhere += string.Format(" where s.createuserorgcode='{0}' and s.iscommit ='1' and s.isover =0 ", currUser.OrganizeCode); dt = this.BaseRepository().FindTable(sql + strWhere); for (int i = 0; i < dt.Rows.Count; i++) { var engineerEntity = new OutsouringengineerService().GetEntity(dt.Rows[i]["outengineerid"].ToString()); var excutdept = new DepartmentService().GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId; var outengineerdept = new DepartmentService().GetEntity(engineerEntity.OUTPROJECTID).DepartmentId; var supervisordept = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : new DepartmentService().GetEntity(engineerEntity.SupervisorId).DepartmentId; //获取下一步审核人 string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["nodeid"].ToString(), dt.Rows[i]["id"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["outengineerid"].ToString()); dt.Rows[i]["approveuserids"] = str; } applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("id")).ToArray(); if (applyids.Length > 0) { toAuditNum.Add(applyids.Length); } else { toAuditNum.Add(0); } #endregion #region 待审核安全技术交底 sql = string.Empty; sql = string.Format("select '' as approveuserids,projectid as outengineerid,flowid,id from epg_techdisclosure s "); strWhere = string.Empty; strWhere += string.Format(" where s.status=1 and s.createuserorgcode='{0}' and s.issubmit=1 ", currUser.OrganizeCode); dt = this.BaseRepository().FindTable(sql + strWhere); for (int i = 0; i < dt.Rows.Count; i++) { var engineerEntity = new OutsouringengineerService().GetEntity(dt.Rows[i]["outengineerid"].ToString()); var excutdept = engineerEntity == null ? "" : new DepartmentService().GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId; var outengineerdept = engineerEntity == null ? "" : new DepartmentService().GetEntity(engineerEntity.OUTPROJECTID).DepartmentId; var supervisordept = engineerEntity == null ? "" : string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : new DepartmentService().GetEntity(engineerEntity.SupervisorId).DepartmentId; //获取下一步审核人 string str = new ManyPowerCheckService().GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["id"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["outengineerid"].ToString()); dt.Rows[i]["approveuserids"] = str; } applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("id")).ToArray(); if (applyids.Length > 0) { toAuditNum.Add(applyids.Length); } else { toAuditNum.Add(0); } #endregion return(toAuditNum); }
/// <summary> /// 获取使用消防水台账 /// </summary> /// <param name="pagination">分页</param> /// <param name="queryJson">查询参数</param> /// <returns>返回分页列表</returns> public DataTable GetLedgerList(Pagination pagination, string queryJson, Operator user) { DatabaseType dataType = DatabaseType.Oracle; #region 数据权限 string curUserId = user.UserId; #endregion /* * 即将作业:审批通过且实际作业时间为空 * 作业中:审批通过且实际作业开始时间不为空且实际作业结束时间为空 * 已结束:审批通过且实际作业结束时间不为空 */ #region 查表 pagination.p_kid = "Id as workid"; pagination.p_fields = "case when workdepttype=0 then '单位内部' when workdepttype=1 then '外包单位' end workdepttypename,workdepttype,workdeptid,workdeptname,workdeptcode,applynumber,a.createdate,workplace,workcontent,workstarttime,workendtime,applyusername,engineeringname,engineeringid,case when a.workoperate='1' then '作业暂停' when realityworkstarttime is not null and realityworkendtime is null then '作业中' when realityworkendtime is not null then '已结束' else '即将作业' end ledgertype,a.workuserids,a.RealityWorkStartTime,a.RealityWorkEndTime,'' as isoperate,a.createuserid"; pagination.p_tablename = " bis_firewater a"; pagination.conditionJson = "applystate='3'"; if (!user.IsSystem) { //配置的部门拥有特殊查看权限 string specialDeptId = new DataItemDetailService().GetItemValue(user.OrganizeId, "FireDept"); if (!string.IsNullOrEmpty(specialDeptId) && specialDeptId.Contains(user.DeptId)) { pagination.conditionJson += " and a.createuserorgcode='" + user.OrganizeCode + "'"; } else { if (user.RoleName.Contains("公司") || user.RoleName.Contains("厂级")) { pagination.conditionJson += " and a.createuserorgcode='" + user.OrganizeCode + "'"; } else { pagination.conditionJson += string.Format(" and ((workdeptcode in(select encode from base_department where encode like '{0}%')) or (engineeringid in(select id from epg_outsouringengineer a where a.engineerletdeptid = '{1}')))", user.DeptCode, user.DeptId); } } } #endregion #region 筛选条件 var queryParam = JObject.Parse(queryJson); //时间选择 if (!queryParam["st"].IsEmpty())//使用消防水开始时间 { string from = queryParam["st"].ToString().Trim(); pagination.conditionJson += string.Format(" and WorkStartTime>=to_date('{0}','yyyy-mm-dd')", from); } if (!queryParam["et"].IsEmpty())//使用消防水结束时间 { string to = Convert.ToDateTime(queryParam["et"].ToString().Trim()).AddDays(1).ToString("yyyy-MM-dd"); pagination.conditionJson += string.Format(" and WorkEndTime<=to_date('{0}','yyyy-mm-dd')", to); } //查询条件 if (!queryParam["workdeptcode"].IsEmpty())//使用消防水单位code { pagination.conditionJson += string.Format(" and workdeptcode='{0}'", queryParam["workdeptcode"].ToString()); } if (!queryParam["ledgertype"].IsEmpty()) { var ledgertype = queryParam["ledgertype"].ToString(); if (ledgertype == "0")// 即将作业 { pagination.conditionJson += " and RealityWorkStartTime is null"; } else if (ledgertype == "1")//作业中 { pagination.conditionJson += " and RealityWorkStartTime is not null and RealityWorkEndTime is null"; } else if (ledgertype == "3") { pagination.conditionJson += " and workoperate='1'"; } else//已结束 { pagination.conditionJson += " and RealityWorkEndTime is not null and workoperate is null"; } } if (!queryParam["keyname"].IsEmpty()) { pagination.conditionJson += string.Format(" and (workdeptname like '%{0}%' or engineeringname like '%{0}%')", queryParam["keyname"].ToString()); } if (!queryParam["applynumber"].IsEmpty()) { pagination.conditionJson += string.Format(" and applynumber like '%{0}%'", queryParam["applynumber"].ToString()); } #endregion var data = this.BaseRepository().FindTableByProcPager(pagination, dataType); #region 操作权限 if (data != null) { string strRole = dataitemdetailservice.GetItemValue(user.OrganizeId, "LedgerSendDept"); //责任部门角色 string strManageRole = dataitemdetailservice.GetItemValue(user.OrganizeId, "LedgerManageDept"); //安全主管部门监管角色 string strWorkRole = dataitemdetailservice.GetItemValue(user.OrganizeId, "LedgerWorkDept"); //作业单位 for (int i = 0; i < data.Rows.Count; i++) { string str = "0"; string workUserIds = data.Rows[i]["workuserids"].ToString(); //作业人员 string applyUserId = data.Rows[i]["createuserid"].ToString(); string engineeringid = data.Rows[i]["engineeringid"].ToString(); //工程id string workDeptType = data.Rows[i]["workdepttype"].ToString(); string workdeptid = data.Rows[i]["workdeptid"].ToString(); //作业单位id var dept = new OutsouringengineerService().GetEntity(engineeringid); //获取工程id对应的责任部门 if (user.RoleName.Contains("厂级") && !string.IsNullOrEmpty(strManageRole)) //安全主管部门 { string[] arrrolename = strManageRole.Split(','); for (int j = 0; j < arrrolename.Length; j++) { if (user.RoleName.Contains(arrrolename[j])) { str = "1"; break; } } } if (str != "1" && !string.IsNullOrEmpty(workdeptid)) { string[] arrrolename = strWorkRole.Split(','); for (int j = 0; j < arrrolename.Length; j++) { if (user.RoleName.Contains(arrrolename[j])) { str = "1"; break; } } } if (str != "1" && ((!string.IsNullOrEmpty(workUserIds) && workUserIds.Contains(curUserId)) || curUserId == applyUserId))//作业人员或申请人 { str = "1"; } if (str != "1" && dept != null) { if (workDeptType == "1")//责任部门 { if (dept.ENGINEERLETDEPTID == user.DeptId && !string.IsNullOrEmpty(strRole)) { string[] arrrolename = strRole.Split(','); for (int j = 0; j < arrrolename.Length; j++) { if (user.RoleName.Contains(arrrolename[j])) { str = "1"; break; } } } } } data.Rows[i]["isoperate"] = str; } } #endregion return(data); }