From 402f9568e48e6e1a9d29d37dcda46737047425d5 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期四, 25 十一月 2021 10:49:10 +0800 Subject: [PATCH] 专家通讯录优化 --- zhengcaioa/Services/ProjectService.cs | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 55 insertions(+), 2 deletions(-) diff --git a/zhengcaioa/Services/ProjectService.cs b/zhengcaioa/Services/ProjectService.cs index 5193469..0c22304 100644 --- a/zhengcaioa/Services/ProjectService.cs +++ b/zhengcaioa/Services/ProjectService.cs @@ -93,7 +93,8 @@ updateproject.Dailicontact = project.Dailicontact; updateproject.Dailiaddress = project.Dailiaddress; updateproject.Fencha = project.Fencha; - updateproject.Shuliang = updateproject.Shuliang; + updateproject.Shuliang = project.Shuliang; + updateproject.Caigouyusuan = project.Caigouyusuan; } @@ -236,6 +237,7 @@ var projectDTO = _mapper.Map<ProjectDTO>(entity); projectDTO.DrhxDefenName = projectDTO.DrhxDefen.HasValue ? projectDTO.DrhxDefen.Value.ToString("F2") : ""; projectDTO.DshxDefenName = projectDTO.DshxDefen.HasValue ? projectDTO.DshxDefen.Value.ToString("F2") : ""; + projectDTO.CaigouyusuanName = projectDTO.Caigouyusuan.HasValue ? projectDTO.Caigouyusuan.Value.ToString() : ""; if (projectreasons!=null && projectreasons.Count>0) { projectDTO.projectreasons = projectreasons; @@ -295,7 +297,7 @@ List<ProjectDTO> list = new List<ProjectDTO>(); //绛涢�� StringBuilder sql = new StringBuilder(); - sql.Append("SELECT distinct a.[Id],a.[start_time],a.[drhx_defen],a.[dshx_defen] ,b.[name] +'-'+c.[name]+'-'+d.[name] Sheng ,a.city ,a.[area_id],a.cgfs, a.[name] ,a.[number],a.creater,a.createtime,a.modifier,a.modifytime ,a.[drhx],a.[drhx_price],a.[dshx],a.[dshx_price],a.[Fencha],a.[Shuliang],a.[remark],a.[rec_status] ,a.[question] ,a.[zhongbiaocishu],a.[feibiaocishu],a.[zhongbiaojine],a.[Fblx],a.[Fbyy] , a.[zhuanjia] , a.[caigourenname], a.[caigourenaddress], a.[caigourencontact], a.[dailiname], a.[dailiaddress], a.[dailicontact] ,toubiaocishu = stuff((select '銆�'+ f.[names] from [Projectzhongbiao] f where f.[ProjectId] = a.[Id] for xml path('')), 1,1, '') "); //zhuanjia = stuff((select ','+name from [Zhuanjia] f where CHARINDEX(f.id,a.[zhuanjia]) >0 for xml path('')), 1,1, '') + sql.Append("SELECT distinct a.[Id],a.[start_time],a.[drhx_defen],a.[caigouyusuan],a.[dshx_defen] ,b.[name] +'-'+c.[name]+'-'+d.[name] Sheng ,a.city ,a.[area_id],a.cgfs, a.[name] ,a.[number],a.creater,a.createtime,a.modifier,a.modifytime ,a.[drhx],a.[drhx_price],a.[dshx],a.[dshx_price],a.[Fencha],a.[Shuliang],a.[remark],a.[rec_status] ,a.[question] ,a.[zhongbiaocishu],a.[feibiaocishu],a.[zhongbiaojine],a.[Fblx],a.[Fbyy] , a.[zhuanjia] , a.[caigourenname], a.[caigourenaddress], a.[caigourencontact], a.[dailiname], a.[dailiaddress], a.[dailicontact] ,toubiaocishu = stuff((select '銆�'+ f.[names] from [Projectzhongbiao] f where f.[ProjectId] = a.[Id] for xml path('')), 1,1, '') "); //zhuanjia = stuff((select ','+name from [Zhuanjia] f where CHARINDEX(f.id,a.[zhuanjia]) >0 for xml path('')), 1,1, '') sql.Append("FROM [Project] a "); sql.Append("left join [Area] b on a.[sheng] = b.[codeID] "); sql.Append("left join [Area] c on a.[city] = c.[codeID] "); @@ -370,6 +372,32 @@ sql.Append(" ) "); } } + if (!string.IsNullOrWhiteSpace(searchEntity.Chuanbiaofenxi)) + { + if (searchEntity.Chuanbiaofenxi == "01") + { + sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) >= 10 ) "); + sql.Append(" and exists ( select * from( select ( isnull((select COUNT(*) ProjectIdshuliang from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] group by b.ProjectId) ,0)+ "); + + sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Projectreason] b where a.[Id]=b.[ProjectId] group by b.ProjectId),0)+ "); + sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Projectyouxiao] b where a.[Id]=b.[ProjectId] group by b.ProjectId),0)+ "); + sql.Append(" isnull( ( select COUNT(*) ProjectIdshuliang from [Project] b where a.[Id]=b.[Id] and b.drhx is not null ),0)+ "); + sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Project] b where a.[Id]=b.[Id] and b.dshx is not null ),0) "); + sql.Append(" ) as sum_count ) a where a.sum_count <= 5 "); + sql.Append(" ) "); + } + else if (searchEntity.Chuanbiaofenxi == "02") + { + sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) >= 20 ) "); + + + } + else if (searchEntity.Chuanbiaofenxi == "03") + { + sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) >= 10 ) "); + } + + } if (!string.IsNullOrWhiteSpace(searchEntity.Reasonname)) @@ -427,6 +455,17 @@ if (!string.IsNullOrWhiteSpace(searchEntity.StartTimestar)) { sql.Append(" and a.start_time <='" + StartTimestarend.AddDays(1).ToString("yyyy-MM-dd") + "'"); + + } + + if (!string.IsNullOrWhiteSpace(searchEntity.KaibiaoTimeStar)) + { + sql.Append(" and a.start_time >='" + searchEntity.KaibiaoTimeStar + "'"); + + } + if (!string.IsNullOrWhiteSpace(searchEntity.KaibiaoTimeEnd)) + { + sql.Append(" and a.start_time <='" + searchEntity.KaibiaoTimeEnd + "'"); } @@ -542,6 +581,20 @@ searchEntity.totalrows = query.Count(); var lianlist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); list = _mapper.Map<List<ProjectDTO>>(lianlist); + + var cgfs = GetCgfs(); + foreach(var projectDTO in list) + { + var cgf = cgfs.Where(x=>x.Id == projectDTO.Cgfs).FirstOrDefault(); + if (cgf != null) + { + projectDTO.CgfsName = cgf.Name; + } + + } + + + data.LoadData(searchEntity, list); return data; } -- Gitblit v1.9.1