/// <summary> /// 获取列表 /// </summary> /// <param name="pagination">分页</param> /// <param name="queryJson">查询参数</param> /// <returns>返回列表</returns> public DataTable GetList(Pagination pagination, string queryJson, string authType, Operator user) { DatabaseType dataTye = DatabaseType.Oracle; #region 查表 pagination.p_kid = "a.id"; pagination.p_fields = @"a.flowdeptname,a.flowname,a.flowrolename,a.flowdept,a.investigatestate,a.workdeptid,a.engineeringid,a.flowid,b.outtransferuseraccount,b.intransferuseraccount, a.workdepttype,a.workdeptname,a.applynumber,a.createdate,a.applystate,a.workplace,a.workcontent,a.workuserids,a.workareaname,a.workareacode, a.workstarttime,a.workendtime,a.applyusername,a.applydeptname,a.createuserid,a.createuserdeptcode,nvl(a.conditionstate,0) conditionstate, a.createuserorgcode,a.flowremark,a.specialtytype,'' as approveuserid,'' as approveusername,'' as approveuseraccount,case when a.applystate='3' and (a.conditionstate='0' or a.conditionstate is null) then '1' else '0' end appconditionstate"; pagination.p_tablename = " bis_firewater a left join (select recid,flowid,outtransferuseraccount,intransferuseraccount,row_number() over(partition by recid,flowid order by createdate desc) as num from BIS_TRANSFERRECORD where disable=0) b on a.id=b.recid and a.flowid=b.flowid and b.num=1"; pagination.conditionJson = " 1=1 "; if (!string.IsNullOrEmpty(authType)) { //配置的部门拥有特殊查看权限 string specialDeptId = new DataItemDetailService().GetItemValue(user.OrganizeId, "FireDept"); var IsHrdl = new DataItemDetailService().GetItemValue("IsOpenPassword"); string isAllDataRange = dataitemdetailservice.GetEnableItemValue("HighRiskWorkDataRange"); //特殊标记,高风险作业模块是否看全厂数据 if (!string.IsNullOrEmpty(specialDeptId) && specialDeptId.Contains(user.DeptId) || IsHrdl == "true" || !string.IsNullOrWhiteSpace(isAllDataRange)) { pagination.conditionJson += " and a.createuserorgcode='" + user.OrganizeCode + "'"; } else { switch (authType) { case "1": pagination.conditionJson += " and a.applyuserid='" + user.UserId + "'"; break; case "2": pagination.conditionJson += " and a.workdeptid='" + user.DeptId + "'"; break; case "3": //本子部门 pagination.conditionJson += string.Format(" and ((a.workdeptid in(select departmentid from base_department where encode like '{0}%')) or (a.engineeringid in(select id from epg_outsouringengineer a where a.engineerletdeptid = '{1}')))", user.DeptCode, user.DeptId); break; case "4": pagination.conditionJson += " and a.createuserorgcode='" + user.OrganizeCode + "'"; break; case "app": if (user.RoleName.Contains("公司") || user.RoleName.Contains("厂级")) { pagination.conditionJson += " and a.createuserorgcode='" + user.OrganizeCode + "'"; } else { pagination.conditionJson += string.Format(" and ((a.workdeptid in(select departmentid from base_department where encode like '{0}%')) or (a.engineeringid in(select id from epg_outsouringengineer a where a.engineerletdeptid = '{1}')))", user.DeptCode, user.DeptId); } break; } } } else { pagination.conditionJson += " and 0=1"; } #endregion #region 筛选条件 var queryParam = JObject.Parse(queryJson); //查询条件 if (!queryParam["applynumber"].IsEmpty())//申请编号 { pagination.conditionJson += string.Format(" and applynumber like '%{0}%'", queryParam["applynumber"].ToString()); } //查询条件 if (!queryParam["status"].IsEmpty())//许可状态 { pagination.conditionJson += string.Format(" and applystate='{0}'", queryParam["status"].ToString()); } //时间选择 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["workdept"].IsEmpty() && !queryParam["workdeptid"].IsEmpty())//使用消防水单位 { 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}')))", queryParam["workdept"].ToString(), queryParam["workdeptid"].ToString()); } //查询条件 if (!queryParam["workdeptcode"].IsEmpty())//使用消防水单位code { pagination.conditionJson += string.Format(" and workdeptcode='{0}'", queryParam["workdeptcode"].ToString()); } if (!queryParam["viewrange"].IsEmpty()) { //本人 if (queryParam["viewrange"].ToString().ToLower() == "self") { pagination.conditionJson += string.Format(" and a.applyuserid='{0}'", user.UserId); } else if (queryParam["viewrange"].ToString().ToLower() == "selfaudit") { string strCondition = " and a.applystate ='1'"; DataTable dt = BaseRepository().FindTable("select " + pagination.p_kid + "," + pagination.p_fields + " from " + pagination.p_tablename + " where " + pagination.conditionJson + strCondition); for (int i = 0; i < dt.Rows.Count; i++) { string executedept = string.Empty; highriskcommonapplyservice.GetExecutedept(dt.Rows[i]["workdepttype"].ToString(), dt.Rows[i]["workdeptid"].ToString(), dt.Rows[i]["engineeringid"].ToString(), out executedept); string createdetpid = departmentservice.GetEntityByCode(dt.Rows[i]["createuserdeptcode"].ToString()).IsEmpty() ? "" : departmentservice.GetEntityByCode(dt.Rows[i]["createuserdeptcode"].ToString()).DepartmentId; string outsouringengineerdept = string.Empty; highriskcommonapplyservice.GetOutsouringengineerDept(dt.Rows[i]["workdeptid"].ToString(), out outsouringengineerdept); string str = manypowercheckservice.GetApproveUserAccount(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["id"].ToString(), "", dt.Rows[i]["specialtytype"].ToString(), executedept, outsouringengineerdept, createdetpid, "", ""); dt.Rows[i]["approveuseraccount"] = str; } string[] applyids = dt.Select(" (outtransferuseraccount is null or outtransferuseraccount not like '%" + user.Account + ",%') and (approveuseraccount like '%" + user.Account + ",%' or intransferuseraccount like '%" + user.Account + ",%')").AsEnumerable().Select(d => d.Field <string>("id")).ToArray(); pagination.conditionJson += string.Format(" and a.id in ('{0}') {1}", string.Join("','", applyids), strCondition); } else { //排除其他人申请保存的数据 pagination.conditionJson += string.Format(" and a.id not in(select id from bis_firewater where applystate='0' and applyuserid!='{0}')", user.UserId); } } #endregion DataTable data = this.BaseRepository().FindTableByProcPager(pagination, dataTye); for (int i = 0; i < data.Rows.Count; i++) { string executedept = string.Empty; highriskcommonapplyservice.GetExecutedept(data.Rows[i]["workdepttype"].ToString(), data.Rows[i]["workdeptid"].ToString(), data.Rows[i]["engineeringid"].ToString(), out executedept); //获取执行部门 string createdetpid = departmentservice.GetEntityByCode(data.Rows[i]["createuserdeptcode"].ToString()).IsEmpty() ? "" : departmentservice.GetEntityByCode(data.Rows[i]["createuserdeptcode"].ToString()).DepartmentId; //获取创建部门 string outsouringengineerdept = string.Empty; highriskcommonapplyservice.GetOutsouringengineerDept(data.Rows[i]["workdeptid"].ToString(), out outsouringengineerdept); string str = manypowercheckservice.GetApproveUserAccount(data.Rows[i]["flowid"].ToString(), data.Rows[i]["id"].ToString(), "", data.Rows[i]["specialtytype"].ToString(), executedept, outsouringengineerdept, createdetpid, "", ""); string outtransferuseraccount = data.Rows[i]["outtransferuseraccount"].IsEmpty() ? "" : data.Rows[i]["outtransferuseraccount"].ToString(); //转交申请人 string intransferuseraccount = data.Rows[i]["intransferuseraccount"].IsEmpty() ? "" : data.Rows[i]["intransferuseraccount"].ToString(); //转交接收人 string[] outtransferuseraccountlist = outtransferuseraccount.Split(','); string[] intransferuseraccountlist = intransferuseraccount.Split(','); foreach (var item in intransferuseraccountlist) { if (!item.IsEmpty() && !str.Contains(item + ",")) { str += (item + ",");//将转交接收人加入审核账号中 } } foreach (var item in outtransferuseraccountlist) { if (!item.IsEmpty() && str.Contains(item + ",")) { str = str.Replace(item + ",", "");//将转交申请人从审核账号中移除 } } data.Rows[i]["approveuseraccount"] = str; DataTable dtuser = userservice.GetUserTable(str.Split(',')); string[] usernames = dtuser.AsEnumerable().Select(d => d.Field <string>("realname")).ToArray(); data.Rows[i]["approveusername"] = usernames.Length > 0 ? string.Join(",", usernames) : ""; } return(data); }
/// <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); }