/// <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="queryJson">查询参数</param> /// <returns>返回列表</returns> public DataTable GetList(Pagination page, LifthoistSearchModel search) { DatabaseType dataTye = DatabaseType.Oracle; #region 查表 page.p_kid = "a.id"; page.p_fields = @"a.applyuserid,a.applyusername,a.applycompanyname,a.applydate,a.applycode,a.applycodestr,a.qualitytype,f.itemname as qualitytypename,a.toolname as toolvalue,c.itemname as toolname,a.workdepttype,a.engineeringid,a.createuserdeptcode, a.constructionunitid,a.constructionunitname,a.constructionunitcode,a.constructionaddress,a.workstartdate,a.workenddate,a.auditstate, a.flowid,a.flowname,a.specialtytype,a.flowroleid,a.flowrolename,a.flowdeptid,a.flowdeptname,a.flowremark,'' as approveuserid,'' as approveusername,'' as approveuseraccount,b.outtransferuseraccount,b.intransferuseraccount"; page.p_tablename = @"bis_lifthoistjob a left join base_dataitemdetail f on a.qualitytype=f.itemvalue and f.itemid=(select itemid from base_dataitem where itemcode='LifthoistQualityType') left join base_dataitemdetail c on a.toolname=c.itemvalue and c.itemid =(select itemid from base_dataitem where itemcode='ToolName') 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"; #endregion #region 筛选条件 //作业状态 if (!string.IsNullOrEmpty(search.auditstate)) { page.conditionJson += " and a.auditstate in (" + search.auditstate + ")"; } //作业时间 if (!string.IsNullOrEmpty(search.workstartdate)) { page.conditionJson += string.Format(" and a.WorkStartDate >= to_date('{0}','yyyy-MM-dd')", search.workstartdate); } if (!string.IsNullOrEmpty(search.workenddate)) { page.conditionJson += string.Format(" and a.WorkEndDate <= to_date('{0}','yyyy-MM-dd')", Convert.ToDateTime(search.workenddate).AddDays(1).ToString("yyyy-MM-dd")); } //申请编号 if (!string.IsNullOrEmpty(search.applycode)) { page.conditionJson += " and a.applycodestr like '%" + search.applycode + "%'"; } //作业单位 if (!string.IsNullOrEmpty(search.constructionunitid)) { page.conditionJson += " and a.constructionunitid = '" + search.constructionunitid + "'"; } if (!string.IsNullOrEmpty(search.qualitytype)) { page.conditionJson += " and a.qualitytype = " + search.qualitytype; } if (!string.IsNullOrEmpty(search.toolname)) { page.conditionJson += " and a.toolname like '%" + search.toolname + "%'"; } if (!string.IsNullOrEmpty(search.viewrange)) { var user = OperatorProvider.Provider.Current(); //本人 if (search.viewrange.ToLower() == "self") { page.conditionJson += string.Format(" and a.ApplyUserId='{0}'", user.UserId); } else if (search.viewrange == "selfaudit") { string strCondition = " and a.AuditState in(1)"; DataTable dt = BaseRepository().FindTable("select " + page.p_kid + "," + page.p_fields + " from " + page.p_tablename + " where " + page.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]["constructionunitid"].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]["constructionunitid"].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(); page.conditionJson += string.Format(" and a.id in ('{0}') {1}", string.Join("','", applyids), strCondition); } else if (search.viewrange == "selfoperator") { page.conditionJson += string.Format(" and a.id in(select businessid from bis_lifthoistauditrecord where audituserid='{0}')", user.UserId); } } #endregion DataTable data = this.BaseRepository().FindTableByProcPager(page, dataTye); for (int i = 0; i < data.Rows.Count; i++) { string executedept = string.Empty; highriskcommonapplyservice.GetExecutedept(data.Rows[i]["workdepttype"].ToString(), data.Rows[i]["constructionunitid"].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]["constructionunitid"].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="keyValue">业务表ID</param> /// <param name="modulename">逐级审核模块名</param> /// <returns></returns> public Flow GetFlow(string keyValue, string modulename) { List <nodes> nlist = new List <nodes>(); List <lines> llist = new List <lines>(); Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); DataTable nodeDt = GetAuditInfo(keyValue, modulename); SuppliesacceptEntity entity = GetEntity(keyValue); Flow flow = new Flow(); flow.title = ""; flow.initNum = 22; flow.activeID = entity.FlowId; if (nodeDt != null && nodeDt.Rows.Count > 0) { #region 创建node对象 for (int i = 0; i < nodeDt.Rows.Count; i++) { DataRow dr = nodeDt.Rows[i]; nodes nodes = new nodes(); nodes.alt = true; nodes.isclick = false; nodes.css = ""; nodes.id = dr["id"].ToString(); //主键 nodes.img = ""; nodes.name = dr["flowname"].ToString(); nodes.type = "stepnode"; nodes.width = 150; nodes.height = 60; //位置 int m = i % 4; int n = i / 4; if (m == 0) { nodes.left = 120; } else { nodes.left = 120 + ((150 + 60) * m); } if (n == 0) { nodes.top = 54; } else { nodes.top = (n * 100) + 54; } setInfo sinfo = new setInfo(); sinfo.NodeName = nodes.name; //审核记录 if (dr["auditdept"] != null && !string.IsNullOrEmpty(dr["auditdept"].ToString())) { sinfo.Taged = 1; List <NodeDesignateData> nodelist = new List <NodeDesignateData>(); NodeDesignateData nodedesignatedata = new NodeDesignateData(); DateTime auditdate; DateTime.TryParse(dr["audittime"].ToString(), out auditdate); nodedesignatedata.createdate = auditdate.ToString("yyyy-MM-dd HH:mm"); nodedesignatedata.creatdept = dr["auditdept"].ToString(); nodedesignatedata.createuser = dr["auditpeople"].ToString(); nodedesignatedata.status = dr["auditresult"].ToString() == "0" ? "同意" : "不同意"; if (i == 0) { nodedesignatedata.prevnode = "无"; } else { nodedesignatedata.prevnode = nodeDt.Rows[i - 1]["flowname"].ToString(); } nodelist.Add(nodedesignatedata); sinfo.NodeDesignateData = nodelist; nodes.setInfo = sinfo; } else { List <NodeDesignateData> nodelist = new List <NodeDesignateData>(); NodeDesignateData nodedesignatedata = new NodeDesignateData(); nodedesignatedata.createdate = "无"; string createdetpid = departmentservice.GetEntityByCode(entity.CreateUserDeptCode).IsEmpty() ? "" : departmentservice.GetEntityByCode(entity.CreateUserDeptCode).DepartmentId; string accountstr = manypowercheckservice.GetApproveUserAccount(dr["id"].ToString(), entity.Id, "", "", "", "", createdetpid, "", ""); DataTable dtuser = userservice.GetUserTable(accountstr.Split(',')); string[] usernames = dtuser.AsEnumerable().Select(d => d.Field <string>("realname")).ToArray(); string[] deptnames = dtuser.AsEnumerable().Select(d => d.Field <string>("deptname")).ToArray().GroupBy(t => t).Select(p => p.Key).ToArray(); nodedesignatedata.createuser = usernames.Length > 0 ? string.Join(",", usernames) : "无"; nodedesignatedata.creatdept = deptnames.Length > 0 ? string.Join(",", deptnames) : "无"; nodedesignatedata.status = "无"; if (i == 0) { nodedesignatedata.prevnode = "无"; } else { nodedesignatedata.prevnode = nodeDt.Rows[i - 1]["flowname"].ToString(); } nodelist.Add(nodedesignatedata); sinfo.NodeDesignateData = nodelist; nodes.setInfo = sinfo; } nlist.Add(nodes); } //流程结束节点 nodes nodes_end = new nodes(); nodes_end.alt = true; nodes_end.isclick = false; nodes_end.css = ""; nodes_end.id = Guid.NewGuid().ToString(); nodes_end.img = ""; nodes_end.name = "流程结束"; nodes_end.type = "endround"; nodes_end.width = 150; nodes_end.height = 60; //取最后一流程的位置,相对排位 nodes_end.left = nlist[nlist.Count - 1].left; nodes_end.top = nlist[nlist.Count - 1].top + 100; nlist.Add(nodes_end); //如果状态为审核通过或不通过,流程结束进行标识 if (entity.Status == 2 || entity.Status == 3) { setInfo sinfo = new setInfo(); sinfo.NodeName = nodes_end.name; sinfo.Taged = 1; List <NodeDesignateData> nodelist = new List <NodeDesignateData>(); NodeDesignateData nodedesignatedata = new NodeDesignateData(); //取流程结束时的节点信息 DataRow[] end_rows = nodeDt.Select("auditpeople is not null").OrderBy(t => t.Field <double>("serialnum")).ToArray(); if (end_rows.Count() > 0) { DataRow end_row = end_rows[end_rows.Count() - 1]; DateTime auditdate; DateTime.TryParse(end_row["audittime"].ToString(), out auditdate); nodedesignatedata.createdate = auditdate.ToString("yyyy-MM-dd HH:mm"); nodedesignatedata.creatdept = end_row["auditdept"].ToString(); nodedesignatedata.createuser = end_row["auditpeople"].ToString(); nodedesignatedata.status = end_row["auditresult"].ToString() == "0" ? "同意" : "不同意"; nodedesignatedata.prevnode = end_row["flowname"].ToString(); } else { nodedesignatedata.createdate = "无"; nodedesignatedata.creatdept = "无"; nodedesignatedata.createuser = "******"; nodedesignatedata.status = "无"; nodedesignatedata.prevnode = "无"; } nodelist.Add(nodedesignatedata); sinfo.NodeDesignateData = nodelist; nodes_end.setInfo = sinfo; } #endregion #region 创建line对象 for (int i = 0; i < nodeDt.Rows.Count; i++) { lines lines = new lines(); lines.alt = true; lines.id = Guid.NewGuid().ToString(); lines.from = nodeDt.Rows[i]["id"].ToString(); if (i < nodeDt.Rows.Count - 1) { lines.to = nodeDt.Rows[i + 1]["id"].ToString(); } lines.name = ""; lines.type = "sl"; llist.Add(lines); } lines lines_end = new lines(); lines_end.alt = true; lines_end.id = Guid.NewGuid().ToString(); lines_end.from = nodeDt.Rows[nodeDt.Rows.Count - 1]["id"].ToString(); lines_end.to = nodes_end.id; llist.Add(lines_end); #endregion flow.nodes = nlist; flow.lines = llist; } return(flow); }