From e1064dd08bba4326d19c81a0b9f4da18c2fa462d Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期四, 24 十一月 2022 13:22:42 +0800 Subject: [PATCH] 废标公告写入oa --- zhengcaioa/Services/ProjectService.cs | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 262 insertions(+), 9 deletions(-) diff --git a/zhengcaioa/Services/ProjectService.cs b/zhengcaioa/Services/ProjectService.cs index 8c304df..03221d8 100644 --- a/zhengcaioa/Services/ProjectService.cs +++ b/zhengcaioa/Services/ProjectService.cs @@ -27,7 +27,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; @@ -96,6 +96,12 @@ updateproject.Shuliang = project.Shuliang; updateproject.Caigouyusuan = project.Caigouyusuan; + if (updateproject.Creater == "111") + { + updateproject.Creater = project.Modifier; + updateproject.Createtime = project.Modifytime; + } + } //瀛愯〃 @@ -128,6 +134,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); } } @@ -162,6 +174,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); } } @@ -197,6 +216,14 @@ 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); } } @@ -274,7 +301,14 @@ projectzhongbiaoDTO.Price = projectzhongbiao.Price; projectzhongbiaoDTO.Defen = projectzhongbiao.Defen; - projectzhongbiaoDTOs.Add(projectzhongbiaoDTO); + 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; } @@ -297,7 +331,7 @@ List<ProjectDTO> list = new List<ProjectDTO>(); //绛涢�� StringBuilder sql = new StringBuilder(); - 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 "); //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("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] "); @@ -435,6 +469,20 @@ } + 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; @@ -564,21 +612,56 @@ //} + 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 + var query = _context.Projects .FromSqlRaw(sql.ToString()).OrderByDescending(x=>x.StartTime) .ToList(); - - + + + + + //if (searchEntity.totalrows == 0) - searchEntity.totalrows = query.Count(); + searchEntity.totalrows = query.Count(); var lianlist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); list = _mapper.Map<List<ProjectDTO>>(lianlist); @@ -620,8 +703,19 @@ 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++) @@ -635,7 +729,50 @@ 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 = "鎶曡瘔"; } } @@ -805,5 +942,121 @@ 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; + } + } } -- Gitblit v1.9.1