예제 #1
0
        public object GetApplyList([FromBody] JObject json)
        {
            try
            {
                string  path       = new DataItemDetailBLL().GetItemValue("imgUrl");
                string  res        = json.Value <string>("json");
                dynamic dy         = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId     = dy.userid;
                string  starttime  = dy.data.starttime; //开始时间
                string  endtime    = dy.data.endtime;   //结束时间
                string  applyno    = dy.data.applyno;
                string  applytype  = dy.data.applytype;
                string  status     = dy.data.status;
                string  actiontype = dy.data.actiontype;//0全部 1 我的
                long    pageIndex  = dy.data.pageindex;
                long    pageSize   = dy.data.pagesize;
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator   currUser   = OperatorProvider.Provider.Current();
                Pagination pagination = new Pagination();
                pagination.page          = int.Parse(pageIndex.ToString());
                pagination.rows          = int.Parse(pageSize.ToString());
                pagination.p_kid         = "t.id applyid";
                pagination.p_fields      = @"t.createuserid,
                                           t.createdate,t.changetype,t.projectname,t.changename,
                                           t.applyunit,t.applychangetime,t.returntime,t.applytype,
                                           t.applyunitid,t.applypeople,t.applypeopleid,
                                           t.applytime, t.workunit,t.workunitid,t.applyno,
                                           t.iscommit,t.isaccepover,t.isapplyover,
                                           t.flowdept,t.nodename,t.nodeid,t.isaccpcommit,
                                           t.flowrole,t.flowdeptname,t.flowrolename,t.acceptime,t.workplace,'' as approveusername,
                                        case 
                                                 when t.iscommit=0 then 0
                                                 when t.iscommit=1 and (t.isapplyover=0 or t.isapplyover is null)  then 1
                                                 when t.iscommit=1 and t.isapplyover=2  then 2
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=0 and (t.isaccepover=0 or t.isaccepover is null) then 3
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and (t.isaccepover=0 or t.isaccepover is null) then 4
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=2 then 5
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=1 then 6 else 7 end applystate,
                                         case 
                                                 when t.iscommit=0 then '变动申请中'
                                                 when t.iscommit=1 and (t.isapplyover=0 or t.isapplyover is null) then '变动审核(批)中'
                                                 when t.iscommit=1 and t.isapplyover=2  then '变动审核(批)未通过'
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=0 and (t.isaccepover=0 or t.isaccepover is null) then '变动审核(批)通过待验收'
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and (t.isaccepover=0 or t.isaccepover is null) then '验收审核中'
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=2 then '验收审核(批)未通过'
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=1 then '验收审核(批)通过' else '' end applystatename";
                pagination.p_tablename   = @"   bis_safetychange t";
                pagination.sidx          = "t.createdate"; //排序字段
                pagination.sord          = "desc";         //排序方式
                pagination.conditionJson = "1=1";

                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
                }
                if (actiontype == "0")
                {
                    if (currUser.IsSystem)
                    {
                    }
                    else if (currUser.RoleName.Contains("厂级部门用户") || currUser.RoleName.Contains("公司级用户"))
                    {
                        pagination.conditionJson += " and t.createuserorgcode='" + currUser.OrganizeCode + "'";
                    }
                    else if (currUser.RoleName.Contains("承包商级用户") || currUser.RoleName.Contains("班组级用户"))
                    {
                        pagination.conditionJson += " and workunitcode='" + currUser.DeptCode + "'";
                    }
                    else
                    {
                        pagination.conditionJson += string.Format(" and workunitcode in(select encode from base_department  where encode like '{0}%' or senddeptid='{1}')", currUser.DeptCode, currUser.DeptId);
                    }
                }
                else
                {
                    string strWhere = string.Empty;

                    strWhere += string.Format(@"  select distinct a.id from bis_safetychange a  where a.createuserid ='{0}' ", currUser.UserId);
                    pagination.conditionJson += string.Format(" and t.id in ({0})", strWhere);
                }

                string queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                {
                    st        = starttime,
                    et        = endtime,
                    status    = status,
                    ApplyType = applytype,
                    applyno   = applyno
                });
                DataTable dt = safetychangebll.GetPageList(pagination, queryJson);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string str = new ScaffoldBLL().GetUserName(dt.Rows[i]["flowdept"].ToString(), dt.Rows[i]["flowrolename"].ToString());
                    dt.Rows[i]["approveusername"] = str.Split('|')[0];
                }
                return(new { code = 0, count = pagination.records, info = "获取数据成功", data = dt });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
예제 #2
0
        public object GetList([FromBody] JObject json)
        {
            try
            {
                string  res           = json.Value <string>("json");
                dynamic dy            = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId        = dy.userid;
                string  actiontype    = dy.data.actiontype;//0全部 1 我的 2 待审核
                long    pageIndex     = dy.pageindex;
                long    pageSize      = dy.pagesize;
                string  examinetodept = res.Contains("examinetodept") ? dy.data.examinetodept : "";
                string  startdate     = res.Contains("startdate") ? dy.data.startdate : "";
                string  enddate       = res.Contains("enddate") ? dy.data.enddate : "";
                string  examinetype   = res.Contains("examinetype") ? dy.data.examinetype : "";
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Pagination pagination = new Pagination();
                pagination.page        = int.Parse(pageIndex.ToString());
                pagination.rows        = int.Parse(pageSize.ToString());
                pagination.p_kid       = "id";
                pagination.p_fields    = @"examinetodept,examineperson,to_char(examinetime,'yyyy-mm-dd') examinetime,flowrolename,flowdept,'' as approveuserid,'' as approveusername,
                                        case when isover='1' then '1'
                                          when isover ='0' and issaved='1' then '2'
                                            when isover='0' and issaved ='0' then '0' end status,
                                              case when isover='1' then '审核完成'
                                          when isover ='0' and issaved='1' then '待审核'
                                            when isover='0' and issaved ='0' then '待提交' end statusinfo";
                pagination.p_tablename = "epg_dailyexamine ";
                pagination.sidx        = "createdate"; //排序字段
                pagination.sord        = "desc";       //排序方式
                Operator currUser = OperatorProvider.Provider.Current();
                pagination.conditionJson += "1=1 ";


                string role = currUser.RoleName;
                if (actiontype == "0")
                {
                    if (currUser.IsSystem)
                    {
                    }
                    else
                    {
                        pagination.conditionJson += " and createuserorgcode ='" + currUser.OrganizeCode + "'";
                    }
                    //(s.issaved = '0' and s.createuserid ='{0}')

                    pagination.conditionJson += " and issaved = '1'";
                }
                else if (actiontype == "1")
                {
                    //查询我的
                    pagination.conditionJson += string.Format(" and ((flowdept ='{0}'", currUser.DeptId);

                    string[] arr = currUser.RoleName.Split(',');
                    if (arr.Length > 0)
                    {
                        pagination.conditionJson += " and (";
                        foreach (var item in arr)
                        {
                            pagination.conditionJson += string.Format(" flowrolename  like '%{0}%' or", item);
                        }
                        pagination.conditionJson  = pagination.conditionJson.Substring(0, pagination.conditionJson.Length - 2);
                        pagination.conditionJson += " )";
                    }
                    pagination.conditionJson += string.Format(") or (issaved = '0' and createuserid ='{0}'))", currUser.UserId);
                }
                else if (actiontype == "2")//待我审核审批
                {
                    //查询我的
                    pagination.conditionJson += string.Format(" and ((flowdept ='{0}'", currUser.DeptId);

                    string[] arr = currUser.RoleName.Split(',');
                    if (arr.Length > 0)
                    {
                        pagination.conditionJson += " and (";
                        foreach (var item in arr)
                        {
                            pagination.conditionJson += string.Format(" flowrolename  like '%{0}%' or", item);
                        }
                        pagination.conditionJson  = pagination.conditionJson.Substring(0, pagination.conditionJson.Length - 2);
                        pagination.conditionJson += " )";
                    }
                    pagination.conditionJson += string.Format(") and isover='0' and issaved='1')");
                }

                if (!string.IsNullOrEmpty(startdate))
                {
                    pagination.conditionJson += string.Format(" and examinetime>= to_date('{0}','yyyy-MM-dd') ", startdate);
                }
                if (!string.IsNullOrEmpty(enddate))
                {
                    pagination.conditionJson += string.Format(" and examinetime<= to_date('{0}','yyyy-MM-dd') ", Convert.ToDateTime(enddate).AddDays(1).ToString("yyyy-MM-dd"));
                }
                if (!string.IsNullOrEmpty(examinetodept))
                {
                    pagination.conditionJson += string.Format(" and examinetodeptid = '{0}' ", examinetodept);
                }
                if (!string.IsNullOrEmpty(examinetype))
                {
                    pagination.conditionJson += string.Format(" and examinetype like '%{0}%' ", examinetype);
                }
                string queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                {
                });
                var data = dailyexaminebll.GetPageList(pagination, queryJson);
                foreach (DataRow row in data.Rows)
                {
                    string str = new ScaffoldBLL().GetUserName(row["flowdept"].ToString(), row["flowrolename"].ToString(), "0");
                    row["approveuserid"]   = str.Split('|')[1];
                    row["approveusername"] = str.Split('|')[0];
                }
                return(new { Code = 0, Count = pagination.records, Info = "获取数据成功", data = data });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }