From 67a0042c5f29e4bb0e0b82f6190f2bc51480b45c Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期二, 28 二月 2023 13:25:09 +0800 Subject: [PATCH] 工资绩效改版 --- zhengcaioa/Services/ProjectService.cs | 986 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 962 insertions(+), 24 deletions(-) diff --git a/zhengcaioa/Services/ProjectService.cs b/zhengcaioa/Services/ProjectService.cs index 2543a63..089febc 100644 --- a/zhengcaioa/Services/ProjectService.cs +++ b/zhengcaioa/Services/ProjectService.cs @@ -5,6 +5,7 @@ using AutoMapper; using CommonToolsCore; using DTO; +using DTO.WebCrawler; using IServices; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.EntityFrameworkCore; @@ -16,10 +17,12 @@ { private readonly zhengcaioaContext _context; private readonly IMapper _mapper; - public ProjectService(zhengcaioaContext context, IMapper mapper) + private readonly WebCrawlerContext _webcontext; + public ProjectService(zhengcaioaContext context, IMapper mapper, WebCrawlerContext webcontext) { _context = context; _mapper = mapper; + _webcontext = webcontext; } public ResultEntity saveLiaotian(ProjectDTO projectDTO) @@ -27,7 +30,7 @@ ResultEntity resultEntity = new ResultEntity(); try { - var checkUserSn = _context.Projects.Where(x => x.Name == projectDTO.Name && x.RecStatus == "A" && x.Id != projectDTO.Id).FirstOrDefault(); + var checkUserSn = _context.Projects.Where(x => x.Name == projectDTO.Name.Trim() && x.RecStatus == "A" && x.Id != projectDTO.Id).FirstOrDefault(); if (checkUserSn != null && (string.IsNullOrWhiteSpace(projectDTO.Id) || (!string.IsNullOrWhiteSpace(projectDTO.Id) && checkUserSn.Id != projectDTO.Id))) { resultEntity.Result = false; @@ -64,6 +67,9 @@ updateproject.Name = project.Name; updateproject.Drhx = project.Drhx; updateproject.DrhxPrice = project.DrhxPrice; + updateproject.DrhxDefen = project.DrhxDefen; + updateproject.DshxDefen = project.DshxDefen; + updateproject.Dshx = project.Dshx; updateproject.Dshx = project.Dshx; updateproject.DshxPrice = project.DshxPrice; updateproject.Zhuanjia = project.Zhuanjia; @@ -89,6 +95,16 @@ updateproject.Dailiname = project.Dailiname; updateproject.Dailicontact = project.Dailicontact; updateproject.Dailiaddress = project.Dailiaddress; + updateproject.Fencha = project.Fencha; + updateproject.Shuliang = project.Shuliang; + updateproject.Caigouyusuan = project.Caigouyusuan; + + if (updateproject.Creater == "111") + { + updateproject.Creater = project.Modifier; + updateproject.Createtime = project.Modifytime; + } + } //瀛愯〃 @@ -121,6 +137,12 @@ projectreason.Reasonname = projectDTO.Reasonname[i]; projectreason.Reasonremark = projectDTO.Reasonremark[i]; projectreason.ProjectId = project.Id; + projectreason.WxZhiyistatus = projectDTO.WxZhiyistatus[i]; + projectreason.WxZhiyishijian = projectDTO.WxZhiyishijian[i]; + projectreason.WxZhiyichengli = projectDTO.WxZhiyichengli[i]; + projectreason.WxTousustatus = projectDTO.WxTousustatus[i]; + projectreason.WxTousushijian = projectDTO.WxTousushijian[i]; + projectreason.WxTousuchengli = projectDTO.WxTousuchengli[i]; _context.Projectreasons.Add(projectreason); } } @@ -155,6 +177,13 @@ projectyouxiao.Namesyouxiao = projectDTO.Namesyouxiao[i]; projectyouxiao.Priceyouxiao = projectDTO.Priceyouxiao[i]; projectyouxiao.ProjectId = project.Id; + + projectyouxiao.YxZhiyistatus = projectDTO.YxZhiyistatus[i]; + projectyouxiao.YxZhiyishijian = projectDTO.YxZhiyishijian[i]; + projectyouxiao.YxZhiyichengli = projectDTO.YxZhiyichengli[i]; + projectyouxiao.YxTousustatus = projectDTO.YxTousustatus[i]; + projectyouxiao.YxTousushijian = projectDTO.YxTousushijian[i]; + projectyouxiao.YxTousuchengli = projectDTO.YxTousuchengli[i]; _context.Projectyouxiaos.Add(projectyouxiao); } } @@ -188,7 +217,16 @@ } projectzhongbiao.Names = projectDTO.Names[i]; projectzhongbiao.Price = projectDTO.Price[i]; + projectzhongbiao.Defen = projectDTO.Defen[i]; projectzhongbiao.ProjectId = project.Id; + + projectzhongbiao.ZbZhiyistatus = projectDTO.ZbZhiyistatus[i]; + projectzhongbiao.ZbZhiyishijian = projectDTO.ZbZhiyishijian[i]; + projectzhongbiao.ZbZhiyichengli = projectDTO.ZbZhiyichengli[i]; + projectzhongbiao.ZbTousustatus = projectDTO.ZbTousustatus[i]; + projectzhongbiao.ZbTousushijian = projectDTO.ZbTousushijian[i]; + projectzhongbiao.ZbTousuchengli = projectDTO.ZbTousuchengli[i]; + _context.Projectzhongbiaos.Add(projectzhongbiao); } } @@ -227,7 +265,10 @@ var projectDTO = _mapper.Map<ProjectDTO>(entity); - if(projectreasons!=null && projectreasons.Count>0) + 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; } @@ -251,12 +292,33 @@ if (Projectzhongbiaos != null && Projectzhongbiaos.Count > 0) { - projectDTO.Projectzhongbiaos = Projectzhongbiaos; + List<ProjectzhongbiaoDTO> projectzhongbiaoDTOs = new List<ProjectzhongbiaoDTO>(); + foreach(var projectzhongbiao in Projectzhongbiaos) + { + ProjectzhongbiaoDTO projectzhongbiaoDTO = new ProjectzhongbiaoDTO(); + projectzhongbiaoDTO.DefenName = projectzhongbiao.Defen.HasValue ? projectzhongbiao.Defen.Value.ToString("F2") : ""; + + projectzhongbiaoDTO.ZhongbiaoId = projectzhongbiao.ZhongbiaoId; + projectzhongbiaoDTO.ProjectId = projectzhongbiao.ProjectId; + projectzhongbiaoDTO.Names = projectzhongbiao.Names; + projectzhongbiaoDTO.Price = projectzhongbiao.Price; + projectzhongbiaoDTO.Defen = projectzhongbiao.Defen; + + projectzhongbiaoDTO.ZbZhiyichengli = projectzhongbiao.ZbZhiyichengli; + projectzhongbiaoDTO.ZbZhiyishijian = projectzhongbiao.ZbZhiyishijian; + projectzhongbiaoDTO.ZbZhiyistatus = projectzhongbiao.ZbZhiyistatus; + projectzhongbiaoDTO.ZbTousuchengli = projectzhongbiao.ZbTousuchengli; + projectzhongbiaoDTO.ZbTousushijian = projectzhongbiao.ZbTousushijian; + projectzhongbiaoDTO.ZbTousustatus = projectzhongbiao.ZbTousustatus; + + projectzhongbiaoDTOs.Add(projectzhongbiaoDTO); + } + projectDTO.Projectzhongbiaos = projectzhongbiaoDTOs; } else { - var Projectzhongbiaoslist = new List<Projectzhongbiao>(); - Projectzhongbiaoslist.Add(new Projectzhongbiao()); + var Projectzhongbiaoslist = new List<ProjectzhongbiaoDTO>(); + Projectzhongbiaoslist.Add(new ProjectzhongbiaoDTO()); projectDTO.Projectzhongbiaos = Projectzhongbiaoslist; } @@ -272,11 +334,11 @@ List<ProjectDTO> list = new List<ProjectDTO>(); //绛涢�� StringBuilder sql = new StringBuilder(); - sql.Append("SELECT distinct a.[Id],a.[start_time] ,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.[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] ,a.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 ,a.[dehx_zhiyistatus],a.[dehx_zhiyishijian],a.[dehx_zhiyichengli],a.[dshx_zhiyistatus],a.[dshx_zhiyishijian],a.[dshx_zhiyichengli],a.[dehx_tousustatus],a.[dehx_tousushijian],a.[dehx_tousuchengli],a.[dshx_tousustatus],a.[dshx_tousushijian],a.[dshx_tousuchengli] "); //zhuanjia = stuff((select ','+name from [Zhuanjia] f where CHARINDEX(f.id,a.[zhuanjia]) >0 for xml path('')), 1,1, '') = stuff((select '銆�'+ f.[names] from [Projectzhongbiao] f where f.[ProjectId] = a.[Id] 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] "); - sql.Append("left join [Area] d on a.[area_id] = d.[codeID] "); + //sql.Append("left join [Area] b on a.[sheng] = b.[codeID] "); + //sql.Append("left join [Area] c on a.[city] = c.[codeID] "); + //sql.Append("left join [Area] d on a.[area_id] = d.[codeID] "); //sql.Append("left join [Zhuanjia] e on CHARINDEX(e.id,a.[zhuanjia]) >0 "); sql.Append(" where a.rec_status='A' "); @@ -301,17 +363,176 @@ sql.Append(" )"); } + if (!string.IsNullOrWhiteSpace(searchEntity.Fencha)) + { + decimal aaaa = 0; + decimal.TryParse(searchEntity.Fencha, out aaaa); + if (aaaa > 0) + { + sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) <= " + aaaa + " ) "); + } + } + if (!string.IsNullOrWhiteSpace(searchEntity.Baojiachaxiaoyu)) + { + decimal aaaa = 0; + decimal.TryParse(searchEntity.Baojiachaxiaoyu, out aaaa); + if (aaaa > 0) + { + sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (convert(numeric(10,2),b.[price] )-convert(numeric(10,2),a.[drhx_price] )) <= " + aaaa + " ) "); + } + } + + + if (!string.IsNullOrWhiteSpace(searchEntity.Fenchadayu)) + { + decimal aaaa = 0; + decimal.TryParse(searchEntity.Fenchadayu, out aaaa); + if (aaaa > 0) + { + sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) >= " + aaaa + " ) "); + } + } + + if (!string.IsNullOrWhiteSpace(searchEntity.Shuliang)) + { + decimal aaaa = 0; + decimal.TryParse(searchEntity.Shuliang, out aaaa); + if (aaaa > 0) + { + 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 <= " + aaaa + ""); + 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)) + { + sql.Append(" and exists (select b.[ProjectId] from [Projectreason] b where a.[Id]=b.[ProjectId] and b.[reasonname] like '%" + searchEntity.Reasonname + "%') "); + + } + + if (!string.IsNullOrWhiteSpace(searchEntity.ShiFouyReasonname)) + { + if (searchEntity.ShiFouyReasonname == "A") + { + sql.Append(" and exists (select b.[ProjectId] from [Projectreason] b where a.[Id]=b.[ProjectId] ) "); + + } + else + { + sql.Append(" and not exists (select b.[ProjectId] from [Projectreason] b where a.[Id]=b.[ProjectId] ) "); + } + + + } + + + if (!string.IsNullOrWhiteSpace(searchEntity.fblx)) + { + if (searchEntity.fblx == "A") + { + sql.Append(" and a.fblx is not null "); + } + else + { + sql.Append(" and a.fblx is null "); + } + + + } + if (!string.IsNullOrWhiteSpace(searchEntity.Shifouqueren)) + { + if (searchEntity.Shifouqueren == "A") + { + sql.Append(" and a.creater != '111' "); + } + else + { + sql.Append(" and a.creater = '111' "); + } + + + } + + + DateTime StartTimestarstart = DateTime.Now; + DateTime StartTimestarend = DateTime.Now; + if (!string.IsNullOrWhiteSpace(searchEntity.StartTimestar)) + { + string[] StartTimestars = searchEntity.StartTimestar.Split("|"); + DateTime.TryParse(StartTimestars[0], out StartTimestarstart); + DateTime.TryParse(StartTimestars[1], out StartTimestarend); + //Createtimeend = Createtimeend.AddDays(1); + } + if (!string.IsNullOrWhiteSpace(searchEntity.StartTimestar)) { - sql.Append(" and a.start_time >='"+ searchEntity.StartTimestar.Trim().Replace("'","''") + "'"); - - } - if (!string.IsNullOrWhiteSpace(searchEntity.StartTimeend)) - { - sql.Append(" and a.start_time <='" + DateTime.Parse(searchEntity.StartTimeend.Trim().Replace("'", "''")).AddDays(1).ToString("yyyy-MM-dd") + "'"); ; + sql.Append(" and a.start_time >='" + StartTimestarstart.ToString("yyyy-MM-dd") + "'"); } + 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 + "'"); + + } + + if (!string.IsNullOrWhiteSpace(searchEntity.Caigourenname)) + { + sql.Append("and a.[caigourenname] like '%" + searchEntity.Caigourenname.Trim().Replace("'", "''") + "%'"); + + } + + if (!string.IsNullOrWhiteSpace(searchEntity.Dailiname)) + { + sql.Append("and a.[dailiname] like '%" + searchEntity.Dailiname.Trim().Replace("'", "''") + "%'"); + + } + + if (!string.IsNullOrWhiteSpace(searchEntity.Sheng)) { @@ -394,23 +615,169 @@ //} + if (!string.IsNullOrEmpty(searchEntity.Wanshan)) + { + if (searchEntity.Wanshan == "A") + { + sql.Append(" and ( a.[drhx] is null or exists ( select b.[Id] from [CooperatecustomCustomer] b where b.rec_status='A' and a.[drhx] = b.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and a.[drhx] = c.[name] ) ) "); + + sql.Append(" and ( a.[dshx] is null or exists ( select b.[Id] from [CooperatecustomCustomer] b where b.rec_status='A' and a.[dshx] = b.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and a.[dshx] = c.[name] ) ) "); + + sql.Append(" and ( a.[caigourenname] is null or exists ( select b.[Id] from [CooperatecustomCustomer] b where b.rec_status='A' and a.[caigourenname] = b.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and a.[caigourenname] = c.[name] ) ) "); + + sql.Append(" and ( a.[dailiname] is null or exists ( select b.[Id] from [CooperatecustomCustomer] b where b.rec_status='A' and a.[dailiname] = b.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and a.[dailiname] = c.[name] ) ) "); + + + sql.Append(" and ( (select count(b.zhongbiaoId) from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] ) = 0 or ( (select count(b.zhongbiaoId) from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] ) = ( select count(b.zhongbiaoId) from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and exists ( select d.[Id] from [CooperatecustomCustomer] d where d.rec_status='A' and b.[names] = d.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and b.[names] = c.[name] ) ))) "); + sql.Append(" and ( (select count(b.youxiaoId) from [Projectyouxiao] b where a.[Id]=b.[ProjectId] ) = 0 or ( (select count(b.youxiaoId) from [Projectyouxiao] b where a.[Id]=b.[ProjectId] ) = ( select count(b.youxiaoId) from [Projectyouxiao] b where a.[Id]=b.[ProjectId] and exists ( select d.[Id] from [CooperatecustomCustomer] d where d.rec_status='A' and b.[namesyouxiao] = d.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and b.[namesyouxiao] = c.[name] ) ))) "); + sql.Append(" and ( (select count(b.reasonId) from [Projectreason] b where a.[Id]=b.[ProjectId] ) = 0 or ( (select count(b.reasonId) from [Projectreason] b where a.[Id]=b.[ProjectId] ) = ( select count(b.reasonId) from [Projectreason] b where a.[Id]=b.[ProjectId] and exists ( select d.[Id] from [CooperatecustomCustomer] d where d.rec_status='A' and b.[reasonname] = d.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and b.[reasonname] = c.[name] ) ))) "); + } + else + { + sql.Append(" and not ( ( a.[drhx] is null or exists ( select b.[Id] from [CooperatecustomCustomer] b where b.rec_status='A' and a.[drhx] = b.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and a.[drhx] = c.[name] ) ) "); + + sql.Append(" and ( a.[dshx] is null or exists ( select b.[Id] from [CooperatecustomCustomer] b where b.rec_status='A' and a.[dshx] = b.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and a.[dshx] = c.[name] ) ) "); + + sql.Append(" and ( a.[caigourenname] is null or exists ( select b.[Id] from [CooperatecustomCustomer] b where b.rec_status='A' and a.[caigourenname] = b.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and a.[caigourenname] = c.[name] ) ) "); + + sql.Append(" and ( a.[dailiname] is null or exists ( select b.[Id] from [CooperatecustomCustomer] b where b.rec_status='A' and a.[dailiname] = b.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and a.[dailiname] = c.[name] ) ) "); + + + sql.Append(" and ( (select count(b.zhongbiaoId) from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] ) = 0 or ( (select count(b.zhongbiaoId) from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] ) = ( select count(b.zhongbiaoId) from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and exists ( select d.[Id] from [CooperatecustomCustomer] d where d.rec_status='A' and b.[names] = d.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and b.[names] = c.[name] ) ))) "); + sql.Append(" and ( (select count(b.youxiaoId) from [Projectyouxiao] b where a.[Id]=b.[ProjectId] ) = 0 or ( (select count(b.youxiaoId) from [Projectyouxiao] b where a.[Id]=b.[ProjectId] ) = ( select count(b.youxiaoId) from [Projectyouxiao] b where a.[Id]=b.[ProjectId] and exists ( select d.[Id] from [CooperatecustomCustomer] d where d.rec_status='A' and b.[namesyouxiao] = d.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and b.[namesyouxiao] = c.[name] ) ))) "); + sql.Append(" and ( (select count(b.reasonId) from [Projectreason] b where a.[Id]=b.[ProjectId] ) = 0 or ( (select count(b.reasonId) from [Projectreason] b where a.[Id]=b.[ProjectId] ) = ( select count(b.reasonId) from [Projectreason] b where a.[Id]=b.[ProjectId] and exists ( select d.[Id] from [CooperatecustomCustomer] d where d.rec_status='A' and b.[reasonname] = d.[name] union select c.[Id] from [IntentionCustomer] c where c.rec_status='A' and b.[reasonname] = c.[name] ) ))) ) "); + } + } + var query = _context.Projects + .FromSqlRaw(sql.ToString()); - var query = _context.Projects - .FromSqlRaw(sql.ToString()).OrderByDescending(x=>x.StartTime) - .ToList(); - - - if (searchEntity.totalrows == 0) - searchEntity.totalrows = query.Count(); - var lianlist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); + + + + + //if (searchEntity.totalrows == 0) + searchEntity.totalrows = query.Count(); + var lianlist = query.OrderByDescending(x => x.StartTime).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; + } + + } + var areas = _context.Areas.ToList(); + + foreach (var projectDTO in list) + { + var sheng = areas.Where(x => x.CodeId == projectDTO.Sheng).FirstOrDefault(); + if (sheng != null) + { + projectDTO.Sheng = sheng.Name ; + } + var City = areas.Where(x => x.CodeId == projectDTO.City).FirstOrDefault(); + if (City != null) + { + projectDTO.Sheng += "-" + City.Name; + } + var AreaId = areas.Where(x => x.CodeId == projectDTO.AreaId).FirstOrDefault(); + if (AreaId != null) + { + projectDTO.Sheng += "-" + AreaId.Name; + } + + } + + List<string> projiectid = new List<string>(); + foreach (var projectDTO in list) + { + projiectid.Add(projectDTO.Id); + } + var projectzhongbiaos = _context.Projectzhongbiaos.Where(x => projiectid.Contains(x.ProjectId)).ToList(); + var projectreasons = _context.Projectreasons.Where(x => projiectid.Contains(x.ProjectId)).ToList(); + var projectyouxiaos = _context.Projectyouxiaos.Where(x => projiectid.Contains(x.ProjectId)).ToList(); + foreach (var projectDTO in list) + { + if (projectDTO.DehxZhiyistatus == "A"|| projectDTO.DshxZhiyistatus == "A") + { + projectDTO.Zhiyistatus = "鈭�"; + } + if (projectDTO.DehxTousustatus == "A" || projectDTO.DshxTousustatus == "A") + { + projectDTO.Tousustatus = "鈭�"; + } + + var ProjectIds = projectzhongbiaos.Where(x => x.ProjectId == projectDTO.Id).ToList(); + projectDTO.Toubiaocishu = ""; + for (int i=0;i< ProjectIds.Count; i++) + { + if(i== ProjectIds.Count - 1) + { + projectDTO.Toubiaocishu += ProjectIds[i].Names ; + } + else + { + projectDTO.Toubiaocishu += ProjectIds[i].Names + "銆�"; + } + + if (ProjectIds[i].ZbZhiyistatus == "A" ) + { + projectDTO.Zhiyistatus = "鈭�"; + } + if (ProjectIds[i].ZbTousustatus == "A") + { + projectDTO.Tousustatus = "鈭�"; + } + + } + + var projectreasons1 = projectreasons.Where(x => x.ProjectId == projectDTO.Id).ToList(); + for (int i = 0; i < projectreasons1.Count; i++) + { + if (projectreasons1[i].WxZhiyistatus == "A") + { + projectDTO.Zhiyistatus = "鈭�"; + } + if (projectreasons1[i].WxZhiyistatus == "A") + { + projectDTO.Tousustatus = "鈭�"; + } + } + + var projectyouxiaos1 = projectyouxiaos.Where(x => x.ProjectId == projectDTO.Id).ToList(); + for (int i = 0; i < projectyouxiaos1.Count; i++) + { + if (projectyouxiaos1[i].YxZhiyistatus == "A") + { + projectDTO.Zhiyistatus = "鈭�"; + } + if (projectyouxiaos1[i].YxZhiyistatus == "A") + { + projectDTO.Tousustatus = "鈭�"; + } + } + + if (projectDTO.Zhiyistatus != "鈭�") + { + projectDTO.Zhiyistatus = "璐ㄧ枒"; + } + if (projectDTO.Tousustatus != "鈭�") + { + projectDTO.Tousustatus = "鎶曡瘔"; + } + } + data.LoadData(searchEntity, list); return data; } @@ -505,5 +872,576 @@ CacheHelperNetCore.CacheInsert("Projects", list); return list; } + + + public List<ProjectDTO> GetListsalary(string userid, DateTime datemin, DateTime datemax) + { + + + var listPosition = _context.Projects.Where(r => r.RecStatus == "A" && r.Creater == userid && r.Createtime >= datemin && r.Createtime < datemax).ToList(); + + var list = _mapper.Map<List<ProjectDTO>>(listPosition); + return list; + } + + public List<ZhengfuProjectDTO> GetcaigougonggaoListsalary(string userid, DateTime datemin, DateTime datemax) + { + + + var listPosition = _webcontext.ZhengfuProjects.Where(r => r.RecStatus == "A" && r.Creater == userid && r.Createtime >= datemin && r.Createtime < datemax).ToList(); + + var list = _mapper.Map<List<ZhengfuProjectDTO>>(listPosition); + return list; + } + + + + + + public ResultEntity saveZxdsfxl(ZxdsfxlDTO zxdsfxlDTO) + { + ResultEntity resultEntity = new ResultEntity(); + try + { + + var zxdsfxl = _mapper.Map<Zxdsfxl>(zxdsfxlDTO); + + + + + if (String.IsNullOrEmpty(zxdsfxl.Id)) + { + zxdsfxl.Id = Guid.NewGuid().ToString(); + _context.Zxdsfxls.Add(zxdsfxl); + } + else + { + var updatezxdsfxl = _context.Zxdsfxls.Find(zxdsfxl.Id); + updatezxdsfxl.Huiyuanid = zxdsfxl.Huiyuanid; + updatezxdsfxl.Huiyuanname = zxdsfxl.Huiyuanname; + updatezxdsfxl.Visittime = zxdsfxl.Visittime; + updatezxdsfxl.Token = zxdsfxl.Token; + updatezxdsfxl.Leixing = zxdsfxl.Leixing; + + + + updatezxdsfxl.RecStatus = zxdsfxl.RecStatus; + updatezxdsfxl.Modifier = zxdsfxl.Modifier; + updatezxdsfxl.Modifytime = zxdsfxl.Modifytime; + + } + + + + _context.SaveChanges(); + resultEntity.ReturnID = zxdsfxl.Id; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } + + public List<ZxdsfxlDTO> GetListZxdsfxl(string userid, DateTime datemin, DateTime datemax, string leixing) + { + + + var listPosition = _context.Zxdsfxls.Where(r => r.RecStatus == "A" && r.Leixing == leixing && r.Huiyuanid == userid && r.Visittime >= datemin && r.Visittime < datemax).ToList(); + + var list = _mapper.Map<List<ZxdsfxlDTO>>(listPosition); + return list; + } + + + public ResultEntity savezhiyi(string zhiyistatus, DateTime? zhiyishijian, string zhiyichengli, string projiectid, string mingxiid, string type) + { + ResultEntity resultEntity = new ResultEntity(); + try + { + if (type == "1") + { + var updateliaotian = _context.Projectzhongbiaos.Find(mingxiid); + updateliaotian.ZbZhiyistatus = zhiyistatus; + updateliaotian.ZbZhiyishijian = zhiyishijian; + updateliaotian.ZbZhiyichengli = zhiyichengli; + } + else if (type == "2") + { + var updateliaotian = _context.Projects.Find(projiectid); + updateliaotian.DehxZhiyistatus = zhiyistatus; + updateliaotian.DehxZhiyishijian = zhiyishijian; + updateliaotian.DehxZhiyichengli = zhiyichengli; + } + else if (type == "3") + { + var updateliaotian = _context.Projects.Find(projiectid); + updateliaotian.DshxZhiyistatus = zhiyistatus; + updateliaotian.DshxZhiyishijian = zhiyishijian; + updateliaotian.DshxZhiyichengli = zhiyichengli; + } + else if (type == "4") + { + var updateliaotian = _context.Projectyouxiaos.Find(mingxiid); + updateliaotian.YxZhiyistatus = zhiyistatus; + updateliaotian.YxZhiyishijian = zhiyishijian; + updateliaotian.YxZhiyichengli = zhiyichengli; + } + else if (type == "5") + { + var updateliaotian = _context.Projectreasons.Find(mingxiid); + updateliaotian.WxZhiyistatus = zhiyistatus; + updateliaotian.WxZhiyishijian = zhiyishijian; + updateliaotian.WxZhiyichengli = zhiyichengli; + } + + + + _context.SaveChanges(); + resultEntity.ReturnID = projiectid; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } + + + + public ResultEntity savetousu(string tousustatus, DateTime? tousushijian, string tousuchengli, string projiectid, string mingxiid, string type) + { + ResultEntity resultEntity = new ResultEntity(); + try + { + if (type == "1") + { + var updateliaotian = _context.Projectzhongbiaos.Find(mingxiid); + updateliaotian.ZbTousustatus = tousustatus; + updateliaotian.ZbTousushijian = tousushijian; + updateliaotian.ZbTousuchengli = tousuchengli; + } + else if (type == "2") + { + var updateliaotian = _context.Projects.Find(projiectid); + updateliaotian.DehxTousustatus = tousustatus; + updateliaotian.DehxTousushijian = tousushijian; + updateliaotian.DehxTousuchengli = tousuchengli; + } + else if (type == "3") + { + var updateliaotian = _context.Projects.Find(projiectid); + updateliaotian.DshxTousustatus = tousustatus; + updateliaotian.DshxTousushijian = tousushijian; + updateliaotian.DshxTousuchengli = tousuchengli; + } + else if (type == "4") + { + var updateliaotian = _context.Projectyouxiaos.Find(mingxiid); + updateliaotian.YxTousustatus = tousustatus; + updateliaotian.YxTousushijian = tousushijian; + updateliaotian.YxTousuchengli = tousuchengli; + } + else if (type == "5") + { + var updateliaotian = _context.Projectreasons.Find(mingxiid); + updateliaotian.WxTousustatus = tousustatus; + updateliaotian.WxTousushijian = tousushijian; + updateliaotian.WxTousuchengli = tousuchengli; + } + + + + _context.SaveChanges(); + resultEntity.ReturnID = projiectid; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } + + + + public ResultDataEntity<ZhengfuProjectDTO> SearchByPagingCaigougonggao(ZhengfuProjectDTOSearch searchEntity) + { + ResultDataEntity<ZhengfuProjectDTO> data = new ResultDataEntity<ZhengfuProjectDTO>(); + List<ZhengfuProjectDTO> list = new List<ZhengfuProjectDTO>(); + + + + + var listCode = (from a in _context.SysCodeDtls + join b in _context.SysCodes + on a.CodeId equals b.Id + where a.RecStatus == "A" + && b.RecStatus == "A" + select new CodeDataEntity() + { + CodeId = b.Id, + CodeTable = b.CodeTable, + CodeField = b.CodeField, + CodeSn = a.CodeSn, + Comments = a.Comments, + Contents = a.Contents, + RecStatus = a.RecStatus, + Sort = a.Sort + } + ); + + + DateTime Createtimestart = DateTime.Now; + DateTime Createtimeend = DateTime.Now; + if (!string.IsNullOrWhiteSpace(searchEntity.Createtime)) + { + string[] Createtimes = searchEntity.Createtime.Split("|"); + DateTime.TryParse(Createtimes[0], out Createtimestart); + DateTime.TryParse(Createtimes[1], out Createtimeend); + Createtimeend = Createtimeend.AddDays(1); + } + + DateTime StartTimestart = DateTime.Now; + DateTime StartTimeeend = DateTime.Now; + if (!string.IsNullOrWhiteSpace(searchEntity.StartTime)) + { + string[] StartTimes = searchEntity.StartTime.Split("|"); + DateTime.TryParse(StartTimes[0], out StartTimestart); + DateTime.TryParse(StartTimes[1], out StartTimeeend); + StartTimeeend = StartTimeeend.AddDays(1); + } + + + + var query = (from a in _webcontext.ZhengfuProjects + + + where a.RecStatus == "A" + && (string.IsNullOrWhiteSpace(searchEntity.Createtime) || (a.Createtime >= Createtimestart && a.Createtime <= Createtimeend)) + && (string.IsNullOrWhiteSpace(searchEntity.StartTime) || (a.NoticeTime >= StartTimestart && a.NoticeTime <= StartTimeeend)) + && (string.IsNullOrWhiteSpace(searchEntity.Name) || a.Title.Contains(searchEntity.Name.Trim())) + && (string.IsNullOrWhiteSpace(searchEntity.Number) || a.OpenTenderCode.Contains(searchEntity.Number.Trim())) + && (string.IsNullOrWhiteSpace(searchEntity.Sheng) || a.Sheng == searchEntity.Sheng.Trim()) + && (string.IsNullOrWhiteSpace(searchEntity.City) || a.City == searchEntity.City.Trim()) + && (string.IsNullOrWhiteSpace(searchEntity.AreaId) || a.RegionCode == searchEntity.AreaId.Trim()) + && (string.IsNullOrWhiteSpace(searchEntity.Cgfs) || a.Cgfs == searchEntity.Cgfs.Trim()) + + && (string.IsNullOrWhiteSpace(searchEntity.Gglx) || a.Gglx == searchEntity.Gglx.Trim()) + && (string.IsNullOrWhiteSpace(searchEntity.Creater) || a.Creater == searchEntity.Creater.Trim()) + + select a + + ); + + + + //if (searchEntity.totalrows == 0) + searchEntity.totalrows = query.Count(); + + var lianlist = query.OrderByDescending(x => x.NoticeTime).Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); + var querytrsult = _mapper.Map<List<ZhengfuProjectDTO>>(lianlist); + //var querytrsult = ( from a in lianlist + + // // join f in _context.Areas on a.Sheng equals f.CodeId + // //into fsss + // // from fff in fsss.DefaultIfEmpty() + + + // //join g in _context.Areas on a.City equals g.CodeId + // // into gsss + // //from ggg in gsss.DefaultIfEmpty() + + + // //join h in _context.Areas on a.RegionCode equals h.CodeId + // // into hsss + // //from hhh in hsss.DefaultIfEmpty() + + // // join b in listCode.Where(x => x.CodeTable == "zhengfu_Project" && x.CodeField == "cgfs") + // //on a.Cgfs equals b.CodeSn + // //into bsss + // // from bbb in bsss.DefaultIfEmpty() + + // //join c in listCode.Where(x => x.CodeTable == "zhengfu_Project" && x.CodeField == "gglx") + // //on a.Gglx equals c.CodeSn + // // into csss + // //from ccc in csss.DefaultIfEmpty() + + // // join e in _context.PltUsers + // //on a.Creater equals e.Id + // //into esss + // // from abi in esss.DefaultIfEmpty() + + // select new ZhengfuProjectDTO + // { + // Id = a.Id, + // NoticeTime = a.NoticeTime, + // NoticeTimeName = a.NoticeTime.ToString("yyyy-MM-dd"), + // Sheng = a.Sheng, + // City = a.City, + // RegionCode = a.RegionCode, + // /*ShengName = fff.Name + "-" + ggg.Name + "-" + hhh.Name,*/ + // Cgfs = a.Cgfs, + // //CgfsName = bbb.Comments, + // Gglx = a.Gglx, + // //GglxName = ccc.Comments, + + // OpenTenderCode = a.OpenTenderCode, + // Title = a.Title, + + // Shorttitle = a.Shorttitle, + // Pageurl = a.Pageurl, + // Remark = a.Remark, + // RecStatus = a.RecStatus, + // Creater = a.Creater, + // //CreaterName = abi.UserName, + // Createtime = a.Createtime, + // Modifier = a.Modifier, + + // Modifytime = a.Modifytime, + // Content = a.Content, + // Pingmu = a.Pingmu, + // Purchaser = a.Purchaser, + // Budget = a.Budget, + + // Agency = a.Agency, + // AgencyCode = a.AgencyCode, + + // } + // ).OrderByDescending(x => x.NoticeTime).ToList(); + + + foreach ( var zhengfuProjectDTO in querytrsult) + { + if (zhengfuProjectDTO.Creater != "1") + { + var pltUser = _context.PltUsers.Where(x=>x.Id == zhengfuProjectDTO.Creater).FirstOrDefault(); + if (pltUser != null) + { + zhengfuProjectDTO.CreaterName = pltUser.UserName; + } + + } + if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.Cgfs)) + { + var codeDataEntity = listCode.Where(x => x.CodeTable == "zhengfu_Project" && x.CodeField == "cgfs").Where(x => x.CodeSn == zhengfuProjectDTO.Cgfs).FirstOrDefault(); + if (codeDataEntity != null) + { + zhengfuProjectDTO.CgfsName = codeDataEntity.Comments; + } + + } + if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.Gglx)) + { + var codeDataEntity = listCode.Where(x => x.CodeTable == "zhengfu_Project" && x.CodeField == "gglx").Where(x => x.CodeSn == zhengfuProjectDTO.Gglx).FirstOrDefault(); + if (codeDataEntity != null) + { + zhengfuProjectDTO.GglxName = codeDataEntity.Comments; + } + + } + if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.Sheng)) + { + var area1 = _context.Areas.Where(x => x.CodeId == zhengfuProjectDTO.Sheng).FirstOrDefault(); + if (area1 != null) + { + zhengfuProjectDTO.ShengName = area1.Name; + } + + } + + if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.City)) + { + var area = _context.Areas.Where(x => x.CodeId == zhengfuProjectDTO.City).FirstOrDefault(); + if (area != null) + { + zhengfuProjectDTO.ShengName += "-" + area.Name; + } + + if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.RegionCode)) + { + var area1 = _context.Areas.Where(x => x.CodeId == zhengfuProjectDTO.RegionCode).FirstOrDefault(); + if (area1 != null) + { + zhengfuProjectDTO.ShengName += "-" + area1.Name; + } + + } + } + + } + + data.LoadData(searchEntity, querytrsult); + return data; + } + + + + public ZhengfuProjectDTO GetZhengfuProjectDTO(string id) + { + + var entity = _webcontext.ZhengfuProjects.Find(id); + if (entity.RecStatus != "A") + { + entity = new ZhengfuProject(); + } + + + var zhengfuProjectDTO = _mapper.Map<ZhengfuProjectDTO>(entity); + + + return zhengfuProjectDTO; + } + + + public ResultEntity saveZhengfuProjectDTO(ZhengfuProjectDTO dTO) + { + ResultEntity resultEntity = new ResultEntity(); + try + { + var checkUserSn = _webcontext.ZhengfuProjects.Where(x => x.Pageurl == dTO.Pageurl && x.RecStatus == "A" && x.Id != dTO.Id).FirstOrDefault(); + if (checkUserSn != null && (string.IsNullOrWhiteSpace(dTO.Id) || (!string.IsNullOrWhiteSpace(dTO.Id) && checkUserSn.Id != dTO.Id))) + { + resultEntity.Result = false; + resultEntity.Message = "璇ラ〉闈㈠凡缁忎繚瀛�"; + return resultEntity; + } + + + var checkUserSnss = _webcontext.ZhengfuProjects.Where(x => x.Title == dTO.Title && x.RecStatus == "A" && x.Id != dTO.Id && x.NoticeTime > dTO.NoticeTime.AddDays(-1) && x.NoticeTime < dTO.NoticeTime.AddDays(1)).FirstOrDefault(); + if (checkUserSnss != null && (string.IsNullOrWhiteSpace(dTO.Id) || (!string.IsNullOrWhiteSpace(dTO.Id) && checkUserSnss.Id != dTO.Id))) + { + resultEntity.Result = false; + resultEntity.Message = "璇ラ〉闈㈠凡缁忎繚瀛�"; + return resultEntity; + } + + + + + var zhengfuProject = _mapper.Map<ZhengfuProject>(dTO); + + + if (String.IsNullOrEmpty(zhengfuProject.Id)) + { + zhengfuProject.Id = Guid.NewGuid().ToString(); + dTO.Id = zhengfuProject.Id; + _webcontext.ZhengfuProjects.Add(zhengfuProject); + } + else + { + var updateproject = _webcontext.ZhengfuProjects.Find(dTO.Id); + + updateproject.NoticeTime = dTO.NoticeTime; + updateproject.Sheng = dTO.Sheng; + updateproject.City = dTO.City; + updateproject.RegionCode = dTO.RegionCode; + updateproject.Cgfs = dTO.Cgfs; + updateproject.Gglx = dTO.Gglx; + updateproject.OpenTenderCode = dTO.OpenTenderCode; + updateproject.Title = dTO.Title; + updateproject.Shorttitle = dTO.Shorttitle; + updateproject.Pageurl = dTO.Pageurl; + updateproject.Remark = dTO.Remark; + + + + updateproject.Content = dTO.Content; + updateproject.Pingmu = dTO.Pingmu; + updateproject.Purchaser = dTO.Purchaser; + + updateproject.Budget = dTO.Budget; + updateproject.Agency = dTO.Agency; + updateproject.AgencyCode = dTO.AgencyCode; + updateproject.OpenTenderTime = dTO.OpenTenderTime; + + + updateproject.RecStatus = dTO.RecStatus; + updateproject.Modifier = dTO.Modifier; + updateproject.Modifytime = dTO.Modifytime; + } + + _webcontext.SaveChanges(); + + + resultEntity.ReturnID = dTO.Id; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } + + + public ResultEntity GetZhengfuProjectDTOByPageurl(string Pageurl, string Id) + { + ResultEntity resultEntity = new ResultEntity(); + resultEntity.Result = true; + var checkUserSn = _webcontext.ZhengfuProjects.Where(x => x.Pageurl == Pageurl && x.RecStatus == "A" && x.Id != Id).FirstOrDefault(); + if (checkUserSn != null && (string.IsNullOrWhiteSpace(Id) || (!string.IsNullOrWhiteSpace(Id) && checkUserSn.Id != Id))) + { + resultEntity.Result = false; + resultEntity.Message = "璇ラ〉闈㈠凡缁忓瓨鍦�"; + + } + + + return resultEntity; + } + + + public ResultEntity GetZhengfuProjectDTOByTitle(string Title, string Id, DateTime? NoticeTime) + { + ResultEntity resultEntity = new ResultEntity(); + resultEntity.Result = true; + if(!string.IsNullOrWhiteSpace(Title) && NoticeTime.HasValue) + { + var checkUserSn = _webcontext.ZhengfuProjects.Where(x => x.Title == Title && x.RecStatus == "A" && x.Id != Id && x.NoticeTime >= NoticeTime.Value.AddDays(-1) && x.NoticeTime <= NoticeTime.Value.AddDays(1)).FirstOrDefault(); + if (checkUserSn != null && (string.IsNullOrWhiteSpace(Id) || (!string.IsNullOrWhiteSpace(Id) && checkUserSn.Id != Id))) + { + resultEntity.Result = false; + resultEntity.Message = "璇ラ〉闈㈠凡缁忓瓨鍦�"; + + } + } + + + + return resultEntity; + } + + + public ResultEntity saveProjectfasongxiaoxi(Projectfasongxiaoxi project) + { + ResultEntity resultEntity = new ResultEntity(); + try + { + + project.Id = Guid.NewGuid().ToString(); + _context.Projectfasongxiaoxis.Add(project); + _context.SaveChanges(); + resultEntity.ReturnID = project.Id; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } } } -- Gitblit v1.9.1