Exemplo n.º 1
0
        public object GetEngineerList([FromBody] JObject json)
        {
            string  res          = json.Value <string>("json").ToLower();
            dynamic dy           = JsonConvert.DeserializeObject <ExpandoObject>(res);
            string  userid       = dy.userid;
            string  senddeptid   = ""; //发包单位
            string  outprojectid = ""; //外包单位

            if (res.Contains("data"))
            {
                if (res.Contains("senddeptid"))
                {
                    senddeptid = dy.data.senddeptid;
                }
                if (res.Contains("outprojectid"))
                {
                    outprojectid = dy.data.outprojectid;
                }
            }
            //获取用户基本信息
            OperatorProvider.AppUserId = userid;  //设置当前用户
            Operator curUser = OperatorProvider.Provider.Current();

            if (null == curUser)
            {
                return(new { code = -1, count = 0, info = "请求失败,请登录!", data = new object() });
            }
            string roleNames = curUser.RoleName;
            //分页获取数据
            Pagination pagination = new Pagination();

            pagination.page        = 1;    // int.Parse(dy.page ?? "1");
            pagination.rows        = 9000; // int.Parse(dy.rows ?? "1");
            pagination.p_kid       = "e.ID";
            pagination.p_fields    = @"e.usedeptpeople,
	                                        e.engineerusedept,
	                                        e.usedeptpeopphone,
	                                        e.engineerdirector,
	                                        e.engineerdirectorphone,
                                           e.ENGINEERCODE,b.senddeptid,b.senddeptname,
                                           e.ENGINEERNAME,
                                           d.itemname ENGINEERTYPE,
                                           l.itemname engineerlevel,
                                           e.OUTPROJECTID,
                                           e.PLANENDDATE,
                                           e.ACTUALENDDATE,
                                           s.itemname engineerstate,
                                           e.CREATEDATE,
                                           b.fullname outprojectName,
                                            decode(ss.EXAMSTATUS, '1', '', '单位资质审查') EXAMSTATUS,
                                           decode(ss.pactstatus, '1', '', '协议管理') pactstatus,
                                           decode(ss.threetwostatus, '1', '', '三措两案') threetwostatus,
                                           decode(ss.technicalstatus, '1', '', '安全技术交底') technicalstatus,
                                           decode(ss.equipmenttoolstatus, '1', '', '工器具验收') equipmenttoolstatus,
                                            decode(ss.peoplestatus, '1', '', '人员资质审查') peoplestatus,
                                             decode(ss.compactstatus, '1', '', '合同管理') compactstatus,
                                            i.busvalidstarttime,
                                            i.busvalidendtime,
                                            i.splvalidstarttime,
                                            i.splvalidendtime,   
                                            i.cqvalidstarttime,
                                            i.cqvalidendtime 
                                    ";
            pagination.p_tablename = @"EPG_OutSouringEngineer e
                                          left join base_department b on b.departmentid=e.outprojectid
                                          left join epg_aptitudeinvestigateinfo i on i.outengineerid = e.id
                                          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
                                          left join epg_startappprocessstatus ss on ss.outengineerid=e.id";
            pagination.sidx        = "e.createdate"; //排序字段
            pagination.sord        = "desc";         //排序方式
            if (curUser.IsSystem)
            {
                pagination.conditionJson = "  1=1 ";
            }
            else if (curUser.RoleName.Contains("厂级部门用户") || curUser.RoleName.Contains("公司级用户") || curUser.RoleName.Contains("公司管理员"))
            {
                pagination.conditionJson = string.Format(" e.createuserorgcode = '{0}' ", curUser.OrganizeCode);
            }
            else if (curUser.RoleName.Contains("承包商级用户"))
            {
                pagination.conditionJson = string.Format("  e.OUTPROJECTID ='{0}'", curUser.DeptId);
            }
            else
            {
                pagination.conditionJson = string.Format("  e.OUTPROJECTID in(select departmentid from base_department where  senddeptid ='{0}')", curUser.DeptId);
            }
            if (!string.IsNullOrWhiteSpace(senddeptid))
            {//发包单位下的外包工程
                pagination.conditionJson = string.Format("  e.OUTPROJECTID in(select departmentid from base_department where  senddeptid ='{0}')", senddeptid);
            }
            if (!string.IsNullOrWhiteSpace(outprojectid))
            {//外包单位下的外包工程
                pagination.conditionJson = string.Format("  e.OUTPROJECTID ='{0}'", outprojectid);
            }

            var queryJson = JsonConvert.SerializeObject(new { engineerstate = "002" });
            var data      = outsouringengineerbll.GetPageList(pagination, queryJson);

            //var JsonData = new
            //{
            //    rows = data,
            //    total = pagination.total,
            //    page = pagination.page,
            //    records = pagination.records,
            //};
            JsonSerializerSettings settings = new JsonSerializerSettings
            {
                //ContractResolver = new LowercaseContractResolver(dict_props), //转小写,并对指定的列进行自定义名进行更换
                DateFormatString = "yyyy-MM-dd HH:mm:ss", //格式化日期
                //NullValueHandling = NullValueHandling.Ignore 值为空则在JSON中体现
            };

            return(new { code = 0, info = "获取数据成功", count = data == null ? 0 : data.Rows.Count, data = JArray.Parse(JsonConvert.SerializeObject(data, Formatting.None, settings)) });
            //return Json(new { code = 0, info = "获取数据成功", count = data == null ? 0 : data.Rows.Count, data = JsonData }, new JsonSerializerSettings() { DateFormatString = "yyyy-MM-dd HH:mm:ss" });
        }
Exemplo n.º 2
0
        public object GetEngineerSelect([FromBody] JObject json)
        {
            try
            {
                string  res = json.Value <string>("json");
                dynamic dy  = JsonConvert.DeserializeObject <ExpandoObject>(res);
                //获取用户Id
                string userId = dy.userid;
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!" });
                }

                //获取页数和条数
                //int page = Convert.ToInt32(dy.data.pageNum), rows = Convert.ToInt32(dy.data.pageSize);
                Pagination pagination = new Pagination();
                pagination.p_kid         = "e.id";
                pagination.p_fields      = "e.engineerletdept,e.engineername,p.outsourcingname,e.unitsuper,'' as examstatus,'' as pactstatus,'' as compactstatus,'' as technicalstatus,'' as equipmenttoolstatus,'' as peoplestatus,'' as threetwostatus,e.engineerstate";
                pagination.p_tablename   = "EPG_OUTSOURINGENGINEER e left join EPG_OUTSOURCINGPROJECT p on e.outprojectid = p.outprojectid";
                pagination.conditionJson = string.Format(" e.CREATEUSERORGCODE ='{0}'", curUser.OrganizeCode);
                pagination.page          = 1;              //页数
                pagination.rows          = 999999999;      //行数
                pagination.sidx          = "e.createdate"; //排序字段
                pagination.sord          = "desc";         //排序方式
                Operator currUser = OperatorProvider.Provider.Current();
                if (currUser.IsSystem)
                {
                    pagination.conditionJson = "  1=1 ";
                }
                else if (currUser.RoleName.Contains("省级"))
                {
                    pagination.conditionJson = string.Format(@" e.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("公司级用户"))
                {
                    pagination.conditionJson = string.Format(" e.createuserorgcode like'%{0}%' ", currUser.OrganizeCode);
                }
                else if (currUser.RoleName.Contains("承包商级用户"))
                {
                    pagination.conditionJson = string.Format("  (e.outprojectid ='{0}' or e.supervisorid='{0}')", currUser.DeptId);
                }
                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}%') ", deptentity.EnCode, currUser.UserId);

                    //pagination.conditionJson = string.Format("  e.engineerletdeptid ='{0}'", currUser.DeptId);
                }
                pagination.conditionJson += string.Format(" and e.engineerstate in('003','002') ");
                DataTable dt = outsouringengineerbll.GetPageList(pagination, null);

                return(new { code = 0, info = "获取数据成功", count = pagination.records, data = dt });
            }
            catch (Exception ex)
            {
                return(new { code = -1, info = ex.Message, count = 0 });
            }
        }