public ActionResult GetPageListJson(Pagination pagination, string queryJson)
        {
            try
            {
                var watch = CommonHelper.TimerStart();
                pagination.p_kid = "t.id";
                pagination.p_fields = @"t.outengineerid,e.engineername,e.engineerareaname as districtname,d.itemname engineertype,l.itemname engineerlevel,
                                       e.id eid,t.issaveorcommit,t.nextcheckrolename,
                                       p.outprojectid,t.isauditover,t.nextcheckdeptid,e.engineerarea,
                                       p.outsourcingname,e.engineerstate,
                                       t.createusername,
                                       t.createdate,t.createuserorgcode,t.flowid,
                                       t.createuserid,e.engineerletdept,e.engineerletdeptid,'' as approveuserids ";
                pagination.p_tablename = @" epg_aptitudeinvestigateinfo t
                                          left join epg_outsouringengineer e on e.id = t.outengineerid
                                          left join epg_outsourcingproject p on p.outprojectid = t.outprojectid
                                           left join base_department b on b.departmentid = t.outprojectid 
                                            left join ( select m.itemname,m.itemvalue from base_dataitem t
                                          left join base_dataitemdetail m on m.itemid=t.itemid where t.itemcode='ProjectType') d on d.itemvalue=e.engineertype
                                          left join ( select m.itemname,m.itemvalue from base_dataitem t
                                          left join base_dataitemdetail m on m.itemid=t.itemid where t.itemcode='ProjectLevel') l on l.itemvalue=e.engineerlevel
                                          left join ( select m.itemname,m.itemvalue from base_dataitem t
                                          left join base_dataitemdetail m on m.itemid=t.itemid where t.itemcode='OutProjectState') s on s.itemvalue=e.engineerstate";
                pagination.sidx = "t.createdate";//排序字段
                pagination.sord = "desc";//排序方式
                Operator currUser = OperatorProvider.Provider.Current();
                string allrangedept = "";
                try
                {
                    allrangedept = dataitemdetailbll.GetDataItemByDetailCode("SBDept", "SBDeptId").FirstOrDefault().ItemValue;
                }
                catch (Exception)
                {

                }
                if (currUser.IsSystem)
                {
                    pagination.conditionJson = "  1=1 ";
                }
                else if (currUser.RoleName.Contains("省级"))
                {
                    pagination.conditionJson = string.Format(@" t.createuserorgcode  in (select encode from BASE_DEPARTMENT d
                        where d.deptcode like '{0}%' and d.nature = '厂级' and d.description is null)", currUser.NewDeptCode);
                }
                else if (currUser.RoleName.Contains("厂级部门用户") || currUser.RoleName.Contains("公司级用户") || allrangedept.Contains(currUser.DeptId))
                {
                    pagination.conditionJson = string.Format(" (t.issaveorcommit='1' or t.createuserid='{0}') ", currUser.UserId);
                }
                else if (currUser.RoleName.Contains("承包商级用户"))
                {
                    pagination.conditionJson = string.Format(" ( e.outprojectid ='{0}' or e.supervisorid='{0}' or t.createuserid='{1}') ", currUser.DeptId, currUser.UserId);
                }
                else
                {
                    var deptentity = departmentbll.GetEntity(currUser.DeptId);
                    while (deptentity.Nature == "班组" || deptentity.Nature == "专业")
                    {
                        deptentity = departmentbll.GetEntity(deptentity.ParentId);
                    }
                    pagination.conditionJson = string.Format(" (e.engineerletdeptid in (select departmentid from base_department where encode like '{0}%') and t.issaveorcommit='1' or t.createuserid='{1}') ", deptentity.EnCode, currUser.UserId);
                }
                //pagination.conditionJson += string.Format(" or t.createuserid='{0}' ", currUser.UserId);
                var data = aptitudeinvestigateinfobll.GetPageList(pagination, queryJson);
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    var engineerEntity = Outsouringengineernll.GetEntity(data.Rows[i]["outengineerid"].ToString());
                    var excutdept = departmentbll.GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId;
                    var outengineerdept = departmentbll.GetEntity(engineerEntity.OUTPROJECTID).DepartmentId;
                    var supervisordept = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : departmentbll.GetEntity(engineerEntity.SupervisorId).DepartmentId;
                    //获取下一步审核人
                    string str = manypowercheckbll.GetApproveUserId(data.Rows[i]["flowid"].ToString(), data.Rows[i]["outengineerid"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, data.Rows[i]["outengineerid"].ToString());
                    data.Rows[i]["approveuserids"] = str;
                }
                var jsonData = new
                {
                    rows = data,
                    total = pagination.total,
                    page = pagination.page,
                    records = pagination.records,
                    costtime = CommonHelper.TimerEnd(watch)
                };
                return ToJsonResult(jsonData);
            }
            catch (System.Exception ex)
            {
                return Error(ex.ToString());
            }

        }
Пример #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;
                long    pageIndex             = dy.data.pageindex;
                long    pageSize              = dy.data.pagesize;
                string  starttime             = dy.data.starttime;
                string  endtime               = dy.data.endtime;
                string  deptid                = dy.data.deptid;
                string  unitid                = dy.data.unitid;
                string  engineerid            = dy.data.engineerid;
                string  actiontype            = dy.data.actiontype;                                                         //0全部 1 我的
                string  disclosuremajor       = res.Contains("disclosuremajor") ? dy.data.disclosuremajor : "";             //所属专业
                string  disclosuremajordeptid = res.Contains("disclosuremajordeptid") ? dy.data.disclosuremajordeptid : ""; //交底部门
                //获取用户基本信息
                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";
                pagination.p_fields       = @" r.id as engineerid,t.disclosurename,t.createusername,to_char(t.createdate, 'yyyy-MM-dd') as createdate,
                                           e.fullname,
                                           t.ENGINEERNAME,disclosuremajordept,d.itemname as disclosuremajor,
                                           t.disclosuretype,
                                           to_char(t.disclosuredate, 'yyyy-mm-dd') as disclosuredate,
                                           t.disclosurepersonnum,
                                           t.disclosureplace,
                                           t.disclosureperson,
                                           t.receiveperson,
                                           t.createuserid,'' as approveuserids,flowid,to_char(issubmit) as issubmit,to_char(status) as status ";
                pagination.p_tablename    = @" epg_techdisclosure t
                                          left join epg_outsouringengineer r
                                            on t.projectid = r.id
                                          left join base_department e
                                            on r.outprojectid = e.departmentid left join base_dataitemdetail d on t.disclosuremajor=d.itemvalue and d.itemid =(select itemid from base_dataitem where itemcode='BelongMajor')";
                pagination.sidx           = "t.createdate"; //排序字段
                pagination.sord           = "desc";         //排序方式
                pagination.conditionJson += "1=1";
                string role = currUser.RoleName;
                if (actiontype == "0")
                {
                    pagination.conditionJson = "((";

                    if (role.Contains("公司级用户") || role.Contains("厂级部门用户"))
                    {
                        pagination.conditionJson += string.Format(" t.CREATEUSERORGCODE  = '{0}'", currUser.OrganizeCode);
                    }
                    else
                    if (role.Contains("承包商级用户"))
                    {
                        pagination.conditionJson += string.Format(" e.departmentid = '{0}'", currUser.DeptId);
                    }
                    else
                    {
                        pagination.conditionJson += string.Format(" r.engineerletdeptid = '{0}'", currUser.DeptId);
                    }
                    pagination.conditionJson += " and t.issubmit=1) or t.projectid is null)";
                }
                else if (actiontype == "1")
                {
                    string strCondition = "";
                    strCondition = string.Format(" and t.createuserorgcode='{0}' and t.issubmit=1 and t.status=1 ", currUser.OrganizeCode);
                    DataTable dt = intromissionbll.GetDataTableBySql("select " + pagination.p_kid + "," + pagination.p_fields + " from " + pagination.p_tablename + " where " + pagination.conditionJson + strCondition);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        var engineerEntity  = outsouringengineerbll.GetEntity(dt.Rows[i]["engineerid"].ToString());
                        var excutdept       = engineerEntity == null ? "" : departmentbll.GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId;
                        var outengineerdept = engineerEntity == null ? "" : departmentbll.GetEntity(engineerEntity.OUTPROJECTID).DepartmentId;
                        var supervisordept  = engineerEntity == null ? "" : string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : departmentbll.GetEntity(engineerEntity.SupervisorId).DepartmentId;
                        //获取下一步审核人
                        string str = manypowercheckbll.GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["id"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["engineerid"].ToString());
                        dt.Rows[i]["approveuserids"] = str;
                    }

                    string[] applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("id")).ToArray();

                    pagination.conditionJson += string.Format(" and (t.id in ('{0}') {1}", string.Join("','", applyids), strCondition);
                    pagination.conditionJson += string.Format(" or (t.issubmit = '0' and t.createuserid ='{0}'))", currUser.UserId);
                }
                else if (actiontype == "2")
                {
                    string strCondition = "";
                    strCondition = string.Format(" and t.createuserorgcode='{0}' and t.issubmit=1 and t.status=1 ", currUser.OrganizeCode);
                    DataTable dt = intromissionbll.GetDataTableBySql("select " + pagination.p_kid + "," + pagination.p_fields + " from " + pagination.p_tablename + " where " + pagination.conditionJson + strCondition);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        var engineerEntity  = outsouringengineerbll.GetEntity(dt.Rows[i]["engineerid"].ToString());
                        var excutdept       = engineerEntity == null ? "" : departmentbll.GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId;
                        var outengineerdept = engineerEntity == null ? "" : departmentbll.GetEntity(engineerEntity.OUTPROJECTID).DepartmentId;
                        var supervisordept  = engineerEntity == null ? "" : string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : departmentbll.GetEntity(engineerEntity.SupervisorId).DepartmentId;
                        //获取下一步审核人
                        string str = manypowercheckbll.GetApproveUserId(dt.Rows[i]["flowid"].ToString(), dt.Rows[i]["id"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, dt.Rows[i]["engineerid"].ToString());
                        dt.Rows[i]["approveuserids"] = str;
                    }

                    string[] applyids = dt.Select(" approveuserids like '%" + currUser.UserId + "%'").AsEnumerable().Select(d => d.Field <string>("id")).ToArray();

                    pagination.conditionJson += string.Format(" and t.id in ('{0}') {1}", string.Join("','", applyids), strCondition);
                }

                string queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                {
                    sTime                 = starttime,
                    eTime                 = endtime,
                    outengineerid         = engineerid,
                    unitid                = unitid,
                    deptid                = deptid,
                    disclosuremajor       = disclosuremajor,
                    disclosuremajordeptid = disclosuremajordeptid
                });
                var data = techdisclosurebll.GetList(pagination, queryJson);
                return(new { code = 0, count = pagination.records, info = "获取数据成功", data = data });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
Пример #3
0
        public ActionResult GetIntromissionList(Pagination pagination, string queryJson)
        {
            pagination.p_kid       = "a.id";
            pagination.p_fields    = @"a.createuserid,a.createdate, a.applypeople,a.applytime,
                                    a.investigatestate,a.outengineerid,b.engineername,c.fullname,
                                    a.flowdeptname,a.flowdept,a.flowrolename,a.flowrole,a.flowname,a.flowid,
                                     b.engineerareaname as districtname,d.itemname engineertype,l.itemname engineerlevel,b.engineerletdept,b.engineerletdeptid,'' as approveuserids";
            pagination.p_tablename = @" epg_intromission a  
                                      left join epg_outsouringengineer b on a.outengineerid = b.id 
                                      left join base_department c on b.outprojectid=c.departmentid
                                      left join ( select m.itemname,m.itemvalue from base_dataitem t
                                      left join base_dataitemdetail m on m.itemid=t.itemid where t.itemcode='ProjectType') d on d.itemvalue=b.engineertype
                                      left join ( select m.itemname,m.itemvalue from base_dataitem t
                                      left join base_dataitemdetail m on m.itemid=t.itemid where t.itemcode='ProjectLevel') l on l.itemvalue=b.engineerlevel
                                      left join ( select m.itemname,m.itemvalue from base_dataitem t
                                      left join base_dataitemdetail m on m.itemid=t.itemid where t.itemcode='OutProjectState') s on s.itemvalue=b.engineerstate ";
            Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
            string   role = user.RoleName;

            string allrangedept = "";

            try
            {
                allrangedept = dataitemdetailbll.GetDataItemByDetailCode("SBDept", "SBDeptId").FirstOrDefault().ItemValue;
            }
            catch (Exception)
            {
            }
            //公用下不显示登记
            pagination.conditionJson = "(( a.investigatestate !='0' and ";

            if (role.Contains("公司级用户") || role.Contains("厂级部门用户") || allrangedept.Contains(user.DeptId))
            {
                pagination.conditionJson += string.Format(" a.createuserorgcode  = '{0}'", user.OrganizeCode);
            }
            else if (role.Contains("承包商级用户"))
            {
                pagination.conditionJson += string.Format("( c.departmentid = '{0}' or b.supervisorid ='{0}')", user.DeptId);
            }
            else
            {
                var deptentity = departmentbll.GetEntity(user.DeptId);
                while (deptentity.Nature == "班组" || deptentity.Nature == "专业")
                {
                    deptentity = departmentbll.GetEntity(deptentity.ParentId);
                }
                pagination.conditionJson += string.Format(" b.engineerletdeptid in (select departmentid from base_department where encode like '{0}%')  ", deptentity.EnCode);

                // pagination.conditionJson += string.Format(" b.engineerletdeptid = '{0}'", user.DeptId);
            }
            pagination.conditionJson += string.Format(" )  or  (a.investigatestate ='0'  and a.createuserid = '{0}'))", user.UserId);


            var watch = CommonHelper.TimerStart();
            var data  = intromissionbll.GetIntromissionPageList(pagination, queryJson);

            for (int i = 0; i < data.Rows.Count; i++)
            {
                var engineerEntity  = Outsouringengineernll.GetEntity(data.Rows[i]["outengineerid"].ToString());
                var excutdept       = departmentbll.GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId;
                var outengineerdept = departmentbll.GetEntity(engineerEntity.OUTPROJECTID).DepartmentId;
                var supervisordept  = string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : departmentbll.GetEntity(engineerEntity.SupervisorId).DepartmentId;
                //获取下一步审核人
                string str = manypowercheckbll.GetApproveUserId(data.Rows[i]["flowid"].ToString(), data.Rows[i]["outengineerid"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, data.Rows[i]["outengineerid"].ToString());
                data.Rows[i]["approveuserids"] = str;
            }

            var jsonData = new
            {
                rows     = data,
                total    = pagination.total,
                page     = pagination.page,
                records  = pagination.records,
                costtime = CommonHelper.TimerEnd(watch)
            };

            return(ToJsonResult(jsonData));
        }
Пример #4
0
        public ActionResult GetListJson(Pagination pagination, string queryJson)
        {
            pagination.p_kid       = "t.ID";
            pagination.p_fields    = @" r.id as engineerid,e.fullname,t.ENGINEERNAME,t.DisclosureType,to_char(t.DisclosureDate,'yyyy-MM-dd') as DisclosureDate,disclosurename,disclosuremajordept,d.itemname as disclosuremajor,t.DisclosurePersonNum,t.DisclosurePlace,t.DisclosurePerson,t.ReceivePerson,t.CreateUserId,'' as approveuserids,flowid,issubmit,status ";
            pagination.p_tablename = @"EPG_TechDisclosure t left join EPG_OutSouringEngineer r 
on t.projectid=r.id left join base_department e on r.outprojectid=e.departmentid left join base_dataitemdetail d on t.disclosuremajor=d.itemvalue and d.itemid =(select itemid from base_dataitem where itemcode='BelongMajor')";
            Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
            string   role = user.RoleName;

            pagination.conditionJson += "(";
            if (role.Contains("省级"))
            {
                pagination.conditionJson += string.Format(@" t.createuserorgcode  in (select encode
                from BASE_DEPARTMENT d
                        where d.deptcode like '{0}%' and d.nature = '厂级' and d.description is null)", user.NewDeptCode);
            }
            else if (role.Contains("公司级用户") || role.Contains("厂级部门用户"))
            {
                pagination.conditionJson += string.Format(" t.CREATEUSERORGCODE  = '{0}'", user.OrganizeCode);
            }
            else if (role.Contains("承包商级用户"))
            {
                pagination.conditionJson += string.Format(" (e.departmentid = '{0}' or r.supervisorid = '{0}' )", user.DeptId);
            }
            else
            {
                var deptentity = departmentbll.GetEntity(user.DeptId);
                while (deptentity.Nature == "班组" || deptentity.Nature == "专业")
                {
                    deptentity = departmentbll.GetEntity(deptentity.ParentId);
                }
                pagination.conditionJson += string.Format(" r.engineerletdeptid in (select departmentid from base_department where encode like '{0}%') ", deptentity.EnCode);
                //pagination.conditionJson = string.Format(" r.engineerletdeptid = '{0}'", user.DeptId);
            }
            pagination.conditionJson += " or t.projectid is null)";
            var watch = CommonHelper.TimerStart();
            var data  = techdisclosurebll.GetList(pagination, queryJson);

            for (int i = 0; i < data.Rows.Count; i++)
            {
                if (data.Rows[i]["status"].ToString() == "1")
                {
                    var engineerEntity  = outsouringengineerbll.GetEntity(data.Rows[i]["engineerid"].ToString());
                    var excutdept       = engineerEntity == null ? "" : departmentbll.GetEntity(engineerEntity.ENGINEERLETDEPTID).DepartmentId;
                    var outengineerdept = engineerEntity == null ? "" : departmentbll.GetEntity(engineerEntity.OUTPROJECTID).DepartmentId;
                    var supervisordept  = engineerEntity == null ? "" : string.IsNullOrEmpty(engineerEntity.SupervisorId) ? "" : departmentbll.GetEntity(engineerEntity.SupervisorId).DepartmentId;
                    //获取下一步审核人
                    string str = manypowercheckbll.GetApproveUserId(data.Rows[i]["flowid"].ToString(), data.Rows[i]["id"].ToString(), "", "", excutdept, outengineerdept, "", "", "", supervisordept, data.Rows[i]["engineerid"].ToString());
                    data.Rows[i]["approveuserids"] = str;
                }
            }
            var jsonData = new
            {
                rows     = data,
                total    = pagination.total,
                page     = pagination.page,
                records  = pagination.records,
                costtime = CommonHelper.TimerEnd(watch)
            };

            return(ToJsonResult(jsonData));
        }