using AngleSharp.Dom; using AngleSharp.Html.Parser; using DocumentServiceAPI.Application.ProjectInfo.Services.Interfaces; using DocumentServiceAPI.Application.ProjectInfo.ViewMode; using DocumentServiceAPI.Application.Repository; using DocumentServiceAPI.Application.UserAndLogin.ViewMode; using DocumentServiceAPI.Application.WorkRemind.Services.Interfaces; using DocumentServiceAPI.Application.WorkRemind.ViewMode; using DocumentServiceAPI.Core; using DocumentServiceAPI.Model; using DocumentServiceAPI.Model.cyDocumentModel; using DocumentServiceAPI.Model.UserInfoModel; using DocumentServiceAPI.Utility; using Furion.LinqBuilder; using Furion.Logging; using Furion.Logging.Extensions; using Furion.Schedule; using MapsterMapper; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using NetTaste; using Newtonsoft.Json; using SqlSugar; using SqlSugar.Extensions; using System; using System.Collections.Generic; using System.Diagnostics.Metrics; using System.Linq; using System.Reflection.Metadata; using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; using System.Security.Claims; using System.Text; using System.Threading.Tasks; namespace DocumentServiceAPI.Application.ProjectInfo.Services { public class ProjectInfoService : IProjectInfoService, IScoped { private ISqlSugarClient _db { get; set; } private ProjectInfoRepository _projectInfoRepository { get; set; } private IMapper _mapper { get; set; } public ProjectInfoService(ISqlSugarClient db, ProjectInfoRepository projectInfoRepository, IMapper mapper) { _db = db; _projectInfoRepository = projectInfoRepository; _mapper = mapper; } public bool InProjectInfo(DocumentProjectInfoDTO dp) { //var a = GetJwtInfo(); //dp.LastUpTime = DateTime.Now; //dp.CreatEmployeeId = a.EID; //var tentlist = _db.Queryable() // .Where(x => x.EmployeeId == a.EID //).First(); //if (tentlist != null) //{ // dw.CreatEmployeeName = tentlist.EmployeeName; //} var documentProjectInfo = _mapper.Map(dp); return _projectInfoRepository.Insert(documentProjectInfo); } public bool IsExistProject(string ProjectName, string ProjectCode) { var a = GetJwtInfo(); var ret = _db.Queryable().Count(x => x.ProjectCode == ProjectCode && x.ProjectName == ProjectName && x.TenantID == a.TEID); if(ret > 0) { return true; } else { return false; } } /// /// 获取Jwt相关信息 /// public JwtInfo GetJwtInfo() { JwtInfo jwtInfo = new JwtInfo(); jwtInfo.LogInSource = (LogInFrom)(App.User?.FindFirstValue("loginfrom")?.ObjToInt() ?? 0); jwtInfo.EID = App.User?.FindFirstValue("eid")?.ObjToInt(); jwtInfo.UID = App.User?.FindFirstValue("uid")?.ObjToInt(); jwtInfo.TEID = App.User?.FindFirstValue("teid")?.ObjToInt(); var guid = App.User?.FindFirstValue("jid"); jwtInfo.JID = string.IsNullOrEmpty(guid) ? null : new Guid(guid); return jwtInfo; } public Document_ProjectInfo ProjectInfoByUrl(Document_ProjectInfo dp) { Document_ProjectInfo document_ProjectInfo = new Document_ProjectInfo(); string url = dp.ProjectUrl; document_ProjectInfo.ProjectUrl = dp.ProjectUrl; var parser = new HtmlParser(); var list11 = new List(); if (url.StartsWith("http://www.ccgp.gov.cn")) { using (HttpClient client = new HttpClient()) { client.Timeout = TimeSpan.FromSeconds(60); //List data = new List(); HttpResponseMessage response = client.GetAsync(url).Result; var res = response.Content.ReadAsStringAsync().Result; var document = parser.ParseDocument(res); var sssdfsdfsd = document.All.Where(m => m.ClassName == "vF_detail_header").FirstOrDefault(); var tc = sssdfsdfsd.QuerySelectorAll(".tc"); document_ProjectInfo.ProjectName = tc[0].TextContent; var aaa = sssdfsdfsd.QuerySelectorAll("span"); foreach (var element in aaa) { if(element.GetAttribute("id").StartsWith("pubTime")) { DateTime a; if (DateTime.TryParse(element.TextContent, out a)) { document_ProjectInfo.GongGaoTime = a; } } } document_ProjectInfo.PurchaseMethod = 0; if (document_ProjectInfo.ProjectName.IndexOf("公开招标")>=0) { document_ProjectInfo.PurchaseMethod = 3; } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性谈判") >= 0) { document_ProjectInfo.PurchaseMethod = 4; } else if (document_ProjectInfo.ProjectName.IndexOf("单一来源") >= 0) { document_ProjectInfo.PurchaseMethod = 5; } else if (document_ProjectInfo.ProjectName.IndexOf("询价") >= 0) { document_ProjectInfo.PurchaseMethod = 6; } else if (document_ProjectInfo.ProjectName.IndexOf("邀请") >= 0) { document_ProjectInfo.PurchaseMethod = 31; } var vF_detail_content = document.All.Where(m => m.ClassName == "vF_detail_content").FirstOrDefault(); var td = vF_detail_content.QuerySelectorAll("p"); if (td != null && td.Length > 0) { for (int i = 0; i < td.Length; i++) { if (td[i].TextContent.IndexOf("项目编号:") >= 0 && td[i].TextContent.IndexOf("、") < 0) { if (string.IsNullOrEmpty(document_ProjectInfo.ProjectCode)) { document_ProjectInfo.ProjectCode = td[i].TextContent.Replace("项目编号:", "").Replace("1.", "").Replace("/", "").Trim(); } } if (td[i].TextContent.IndexOf("预算金额:") >= 0) { if (td[i].TextContent.IndexOf("万元") >= 0) { var yusuan = td[i].TextContent.Replace("预算金额:", "").Replace("3.", "").Replace("(", "").Replace(")", "").Replace("万元", "").Replace("人民币", "").Trim(); decimal a = 0; if (decimal.TryParse(yusuan, out a)) { //document_ProjectInfo.ys = a * 10000; } } else { var yusuan = td[i].TextContent.Replace("预算金额:", "").Replace("3.", "").Replace("(", "").Replace(")", "").Replace("元", "").Replace("人民币", "").Trim(); decimal a = 0; if (decimal.TryParse(yusuan, out a)) { //Budget = a; } } } if (td[i].TextContent.IndexOf("开标时间:") >= 0) { DateTime a; var sss = td[i].TextContent.Replace("开标时间:", "").Replace("北京时间)", "").Replace("年", "-").Replace("月", "-").Replace("日", " ").Replace("点", ":").Replace("时", ":").Replace("分(", "").Replace("分", ":").Replace("秒", "").Replace("(", "").Trim(); if (DateTime.TryParse(sss, out a)) { document_ProjectInfo.TenderTime = a; document_ProjectInfo.SignupStartTime = a; document_ProjectInfo.SignupEndTime = a; } } if (td[i].TextContent.IndexOf("1.时间:") >= 0) { if (!document_ProjectInfo.TenderTime.HasValue) { DateTime a; var sss = td[i].TextContent.Replace("1.时间:", "").Replace("北京时间)", "").Replace("年", "-").Replace("月", "-").Replace("日", " ").Replace("点", ":").Replace("时", ":").Replace("分(", "").Replace("分", ":").Replace("秒", "").Replace("(", "").Trim(); if (DateTime.TryParse(sss, out a)) { document_ProjectInfo.TenderTime = a; document_ProjectInfo.SignupStartTime = a; document_ProjectInfo.SignupEndTime = a; } } } if (td[i].TextContent.StartsWith("时间:")) { if (!document_ProjectInfo.TenderTime.HasValue) { DateTime a; var sss = td[i].TextContent.Replace("时间:", "").Replace("北京时间)", "").Replace("年", "-").Replace("月", "-").Replace("日", " ").Replace("点", ":").Replace("时", ":").Replace("分(", "").Replace("分", ":").Replace("秒", "").Replace("(", "").Trim(); if (DateTime.TryParse(sss, out a)) { document_ProjectInfo.TenderTime = a; document_ProjectInfo.SignupStartTime = a; document_ProjectInfo.SignupEndTime = a; } } } if (td[i].TextContent.IndexOf("采购人信息")>=0) { if(td[i+1]!=null) { document_ProjectInfo.PurchaseUnit = td[i + 1].TextContent.Replace("名 称:", "").Replace("名称:", "").Trim(); } if (td[i + 2] != null) { document_ProjectInfo.PurchaseAddress = td[i + 2].TextContent.Replace("地址:", "").Replace("地 址:", "").Replace("地 址:", "").Trim(); } if (td[i + 3] != null) { document_ProjectInfo.PurchasePhone = td[i + 3].TextContent.Replace("联系方式:", "").Trim(); } } if (td[i].TextContent.IndexOf("采购代理机构信息") >= 0) { if (td[i + 1] != null) { document_ProjectInfo.AgencyUnit = td[i + 1].TextContent.Replace("名 称:", "").Replace("名称:", "").Trim(); } if (td[i + 2] != null) { document_ProjectInfo.AgencyAddress = td[i + 2].TextContent.Replace("地址:", "").Replace("地 址:", "").Replace("地 址:", "").Trim(); } if (td[i + 3] != null) { document_ProjectInfo.AgencyPhone = td[i + 3].TextContent.Replace("联系方式:", "").Trim(); } } } } } } else if (url.StartsWith("https://zfcg.scsczt.cn")) { using (HttpClient client = new HttpClient()) { client.Timeout = TimeSpan.FromSeconds(60); HttpResponseMessage response = client.GetAsync(url).Result; var res = response.Content.ReadAsStringAsync().Result; var document = parser.ParseDocument(res); var sssdfsdfsd = document.All.Where(m => m.LocalName == "h1" && m.ClassName == "info-title").FirstOrDefault(); document_ProjectInfo.ProjectName = sssdfsdfsd.TextContent.Replace("\n", "").Trim(); var AllDiv = document.All.Where(m => m.LocalName == "span" && m.HasAttribute("id") && m.GetAttribute("id").StartsWith("noticeTime")).FirstOrDefault(); string ssssss = AllDiv.QuerySelector("i").TextContent.Replace("北京时间)", "").Replace("年", "-").Replace("月", "-").Replace("日", " ").Replace("点", ":").Replace("时", ":").Replace("分(", "").Replace("分", ":").Replace("秒", "").Replace("(", "").Trim(); DateTime b; if (DateTime.TryParse(ssssss, out b)) { document_ProjectInfo.GongGaoTime = b; } var TenderTime = document.All.Where(m => m.LocalName == "span" && m.ClassName == "noticePurchaseTime-noticePurchaseTime _notice_content_noticePurchaseTime-noticePurchaseTime bidFileSubmitTime dynamic-form-editor").FirstOrDefault(); string TenderTimes = TenderTime.TextContent.Replace("北京时间)", "").Replace("年", "-").Replace("月", "-").Replace("日", " ").Replace("点", ":").Replace("时", ":").Replace("分(", "").Replace("分", "").Replace("秒", "").Replace("(", "").Trim(); if (DateTime.TryParse(TenderTimes, out b)) { document_ProjectInfo.TenderTime = b; document_ProjectInfo.SignupStartTime = b; document_ProjectInfo.SignupEndTime = b; } document_ProjectInfo.PurchaseMethod = 0; if (document_ProjectInfo.ProjectName.IndexOf("公开招标") >= 0) { document_ProjectInfo.PurchaseMethod = 3; } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性谈判") >= 0) { document_ProjectInfo.PurchaseMethod = 4; } else if (document_ProjectInfo.ProjectName.IndexOf("单一来源") >= 0) { document_ProjectInfo.PurchaseMethod = 5; } else if (document_ProjectInfo.ProjectName.IndexOf("询价") >= 0) { document_ProjectInfo.PurchaseMethod = 6; } else if (document_ProjectInfo.ProjectName.IndexOf("邀请") >= 0) { document_ProjectInfo.PurchaseMethod = 31; } var vF_detail_content = document.All.Where(m => m.LocalName == "div" && m.HasAttribute("id") && m.GetAttribute("id").StartsWith("print-content")).FirstOrDefault(); var td = vF_detail_content.QuerySelectorAll("p"); if (td != null && td.Length > 0) { for (int i = 0; i < td.Length; i++) { if (td[i].TextContent.IndexOf("项目编号:") >= 0 && td[i].TextContent.IndexOf("、") < 0) { if (string.IsNullOrEmpty(document_ProjectInfo.ProjectCode)) { document_ProjectInfo.ProjectCode = td[i].TextContent.Replace("项目编号:", "").Replace("1.", "").Replace("/", "").Trim(); } } } } var lianxiren = document.All.Where(m => m.LocalName == "div" && m.ClassName == "innercontent").ToList(); foreach (var element in lianxiren) { if(element.TextContent.IndexOf("采购人信息")>=0 && element.TextContent.IndexOf("采购代理机构信息") >= 0) { var lianxirentd = element.QuerySelectorAll("p"); if (lianxirentd != null && lianxirentd.Length > 0) { if (lianxirentd[0] != null) { document_ProjectInfo.PurchaseUnit = lianxirentd[0].TextContent.Replace("名 称:", "").Replace("名称:", "").Trim(); } if (lianxirentd[1] != null) { document_ProjectInfo.PurchaseAddress = lianxirentd[1].TextContent.Replace("地址:", "").Replace("地 址:", "").Replace("地 址:", "").Trim(); } if (lianxirentd[2] != null) { document_ProjectInfo.PurchasePhone = lianxirentd[2].TextContent.Replace("联系方式:", "").Trim(); } if (lianxirentd[3] != null) { document_ProjectInfo.AgencyUnit = lianxirentd[3].TextContent.Replace("名 称:", "").Replace("名称:", "").Trim(); } if (lianxirentd[4] != null) { document_ProjectInfo.AgencyAddress = lianxirentd[4].TextContent.Replace("地址:", "").Replace("地 址:", "").Replace("地 址:", "").Trim(); } if (lianxirentd[5] != null) { document_ProjectInfo.AgencyPhone = lianxirentd[5].TextContent.Replace("联系方式:", "").Trim(); } } } } } } else if (url.StartsWith("http://202.61.88.152:9080")) { using (HttpClient client = new HttpClient()) { client.Timeout = TimeSpan.FromSeconds(60); HttpResponseMessage response = client.GetAsync(url).Result; var res = response.Content.ReadAsStringAsync().Result; var document = parser.ParseDocument(res); var sssdfsdfsd = document.All.Where(m => m.LocalName == "div" && m.ClassName == "cont-info").FirstOrDefault(); var ProjectName = sssdfsdfsd.QuerySelectorAll("h1").FirstOrDefault(); document_ProjectInfo.ProjectName = ProjectName.TextContent.Replace("\n", "").Trim(); var AllDiv = document.All.Where(m => m.LocalName == "p" && m.ClassName == "time").FirstOrDefault(); string ssssss = AllDiv.TextContent.Replace("系统发布时间:", "").Trim(); DateTime b; if (DateTime.TryParse(ssssss, out b)) { document_ProjectInfo.GongGaoTime = b; } //var TenderTime = document.All.Where(m => m.LocalName == "span" && m.ClassName == "noticePurchaseTime-noticePurchaseTime _notice_content_noticePurchaseTime-noticePurchaseTime bidFileSubmitTime dynamic-form-editor").FirstOrDefault(); //string TenderTimes = TenderTime.TextContent.Replace("北京时间)", "").Replace("年", "-").Replace("月", "-").Replace("日", " ").Replace("点", ":").Replace("时", ":").Replace("分(", "").Replace("分", "").Replace("秒", "").Replace("(", "").Trim(); //if (DateTime.TryParse(TenderTimes, out b)) //{ // document_ProjectInfo.TenderTime = b; // document_ProjectInfo.SignupStartTime = b; // document_ProjectInfo.SignupEndTime = b; //} document_ProjectInfo.PurchaseMethod = 0; if (document_ProjectInfo.ProjectName.IndexOf("公开招标") >= 0) { document_ProjectInfo.PurchaseMethod = 3; } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性谈判") >= 0) { document_ProjectInfo.PurchaseMethod = 4; } else if (document_ProjectInfo.ProjectName.IndexOf("单一来源") >= 0) { document_ProjectInfo.PurchaseMethod = 5; } else if (document_ProjectInfo.ProjectName.IndexOf("询价") >= 0) { document_ProjectInfo.PurchaseMethod = 6; } else if (document_ProjectInfo.ProjectName.IndexOf("邀请") >= 0) { document_ProjectInfo.PurchaseMethod = 31; } var vF_detail_content = document.All.Where(m => m.LocalName == "div" && m.HasAttribute("id") && m.GetAttribute("id").StartsWith("myPrintArea")).FirstOrDefault(); var td = vF_detail_content.QuerySelectorAll("td"); if (td != null && td.Length > 0) { for (int i = 0; i < td.Length; i++) { if (td[i].TextContent.IndexOf("项目编号") >= 0) { if (string.IsNullOrEmpty(document_ProjectInfo.ProjectCode)) { document_ProjectInfo.ProjectCode = td[i+1].TextContent.Trim(); } } if (td[i].TextContent.IndexOf("提交投标文件截止时间") >= 0) { if (string.IsNullOrEmpty(document_ProjectInfo.ProjectCode)) { string TenderTimes = td[i + 1].TextContent.Replace("北京时间", "").Replace("年", "-").Replace("月", "-").Replace("日", " ").Replace("点", ":").Replace("时", ":").Replace("分(", "").Replace("分", ":").Replace("秒", "").Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "").Trim(); DateTime a; if (DateTime.TryParse(TenderTimes, out a)) { document_ProjectInfo.TenderTime = a; document_ProjectInfo.SignupStartTime = a; document_ProjectInfo.SignupEndTime = a; } } } if (td[i].TextContent.IndexOf("采购人信息") >= 0) { if (string.IsNullOrEmpty(document_ProjectInfo.PurchaseUnit)) { if(td[i + 1].TextContent.IndexOf("名称") >= 0) { document_ProjectInfo.PurchaseUnit = td[i + 2].TextContent.Trim(); } } if (string.IsNullOrEmpty(document_ProjectInfo.PurchaseAddress)) { if (td[i + 3].TextContent.IndexOf("地址") >= 0) { document_ProjectInfo.PurchaseAddress = td[i + 4].TextContent.Trim(); } } if (string.IsNullOrEmpty(document_ProjectInfo.PurchasePhone)) { if (td[i + 5].TextContent.IndexOf("联系方式") >= 0) { document_ProjectInfo.PurchasePhone = td[i + 6].TextContent.Trim(); } } } if (td[i].TextContent.IndexOf("采购代理机构信息") >= 0) { if (string.IsNullOrEmpty(document_ProjectInfo.AgencyUnit)) { if (td[i + 1].TextContent.IndexOf("名称") >= 0) { document_ProjectInfo.AgencyUnit = td[i + 2].TextContent.Trim(); } } if (string.IsNullOrEmpty(document_ProjectInfo.AgencyAddress)) { if (td[i + 3].TextContent.IndexOf("地址") >= 0) { document_ProjectInfo.AgencyAddress = td[i + 4].TextContent.Trim(); } } if (string.IsNullOrEmpty(document_ProjectInfo.AgencyPhone)) { if (td[i + 5].TextContent.IndexOf("联系方式") >= 0) { document_ProjectInfo.AgencyPhone = td[i + 6].TextContent.Trim(); } } } } } } string ssss = "234234234"; } else { } return document_ProjectInfo; } public PageResult postProjectInfoList(DocumentProjectInfoPageSearch page) { var aaa = GetJwtInfo(); SqlSugar.PageModel pg = new SqlSugar.PageModel(); pg.PageSize = page.PageSize; pg.PageIndex = page.PageIndex; //page.ToEmployeeId = a.EID; int total = 0; PageResult result = new PageResult(); result.Items = _db.Queryable((a, d, e,f,g,h,i,j,k,l,m,n) => new JoinQueryInfos ( JoinType.Left, a.ProjectId == d.ProjectId && d.UnitId == page.UnitId, JoinType.Left, a.ProjectId == e.ProjectId && e.UnitId == page.UnitId, JoinType.Left, a.ProjectId == f.ProjectId && f.UnitId == page.UnitId, JoinType.Left, a.ProjectId == g.ProjectId && g.UnitId == page.UnitId, JoinType.Left, a.ProjectId == h.ProjectId && h.UnitId == page.UnitId, JoinType.Left, a.ProjectId == i.ProjectId && i.UnitId == page.UnitId, JoinType.Left, a.ProjectId == j.ProjectId && j.UnitId == page.UnitId, JoinType.Left, a.ProjectId == k.ProjectId && k.UnitId == page.UnitId, JoinType.Left, a.ProjectId == l.ProjectId && l.UnitId == page.UnitId, JoinType.Left, a.ProjectId == m.ProjectId && m.UnitId == page.UnitId, JoinType.Left, a.ProjectId == n.ProjectId && n.UnitId == page.UnitId )) .Where((a, d, e, f, g, h, i, j, k, l, m, n) =>a.TenantID == aaa.TEID) //省 .WhereIF(!string.IsNullOrEmpty(page.Province) && page.Province!= "请选择", (a, d, e, f, g, h, i, j, k, l, m, n) => (a.Province == page.Province)) //市 .WhereIF(!string.IsNullOrEmpty(page.City) && page.City != "请选择", (a, d, e, f, g, h, i, j, k, l, m, n) => (a.City == page.City)) //区县 .WhereIF(!string.IsNullOrEmpty(page.County) && page.County != "请选择", (a, d, e, f, g, h, i, j, k, l, m, n) => (a.County == page.County)) //报名时间 .WhereIF(!string.IsNullOrEmpty(page.ddlSignupStartTime), (a, d, e, f, g, h, i, j, k, l, m, n) => a.SignupStartTime >= DateTime.Parse(page.ddlSignupStartTime)) //报名时间 .WhereIF(!string.IsNullOrEmpty(page.ddlSignupEndTime), (a, d, e, f, g, h, i, j, k, l, m, n) => a.SignupEndTime <= DateTime.Parse(page.ddlSignupEndTime)) //开标时间 .WhereIF(!string.IsNullOrEmpty(page.ddlTenderStartTime), (a, d, e, f, g, h, i, j, k, l, m, n) => a.TenderTime >= DateTime.Parse(page.ddlTenderStartTime)) //开标时间 .WhereIF(!string.IsNullOrEmpty(page.ddlTenderEndTime), (a, d, e, f, g, h, i, j, k, l, m, n) => a.TenderTime <= DateTime.Parse(page.ddlTenderEndTime)) //采购方式 .WhereIF(page.ddlPurchaseMethod>0, (a, d, e, f, g, h, i, j, k, l, m, n) => a.PurchaseMethod == page.ddlPurchaseMethod) //项目名称 .WhereIF(!string.IsNullOrEmpty(page.txtProjectName), (a, d, e, f, g, h, i, j, k, l, m, n) => a.ProjectName.Contains(page.txtProjectName)) //项目编号 .WhereIF(!string.IsNullOrEmpty(page.txtProjectCode), (a, d, e, f, g, h, i, j, k, l, m, n) => a.ProjectCode.Contains(page.txtProjectCode)) //采购单位 .WhereIF(!string.IsNullOrEmpty(page.txtPurchaseUnit), (a, d, e, f, g, h, i, j, k, l, m, n) => a.PurchaseUnit.Contains(page.txtPurchaseUnit)) //代理机构 .WhereIF(!string.IsNullOrEmpty(page.txtAgencyUnit), (a, d, e, f, g, h, i, j, k, l, m, n) => a.AgencyUnit.Contains(page.txtAgencyUnit)) //投标人 .WhereIF(!string.IsNullOrEmpty(page.txtTenderPerson), (a, d, e, f, g, h, i, j, k, l, m, n) => d.TenderPerson.Contains(page.txtTenderPerson)) //专家 .WhereIF(!string.IsNullOrEmpty(page.Experts), (a, d, e, f, g, h, i, j, k, l, m, n) => d.Experts.Contains(page.Experts)) //报名状态 .WhereIF(page.ddlSignUp > 0 && page.ddlSignUp == 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (d.IsSignup == 0 || d.IsSignup == null)) .WhereIF(page.ddlSignUp > 0 && page.ddlSignUp != 1, (a, d, e, f, g, h, i, j, k, l, m, n) => d.IsSignup == 1 ) //保证金状态 .WhereIF(page.ddlTenderDeposit > 0 && page.ddlTenderDeposit == 12, (a, d, e, f, g, h, i, j, k, l, m, n) => d.TenderDepositStatus == null) .WhereIF(page.ddlTenderDeposit > 0 && page.ddlTenderDeposit == 36, (a, d, e, f, g, h, i, j, k, l, m, n) => a.TenderTime < DateTime.Now.AddDays(15) && d.TenderDepositStatus == 13 ) .WhereIF(page.ddlTenderDeposit > 0 && page.ddlTenderDeposit != 12 && page.ddlTenderDeposit != 36, (a, d, e, f, g, h, i, j, k, l, m, n) => d.TenderDepositStatus == page.ddlTenderDeposit) //履约金状态 .WhereIF(page.ddlBidbond > 0 && page.ddlBidbond == 32, (a, d, e, f, g, h, i, j, k, l, m, n) => (d.BidbondStatus == null)) .WhereIF(page.ddlBidbond > 0 && page.ddlBidbond != 32, (a, d, e, f, g, h, i, j, k, l, m, n) => d.BidbondStatus == page.ddlBidbond ) //标书状态 .WhereIF(page.ddlDocumentStatus > 0 && page.ddlDocumentStatus == 15, (a, d, e, f, g, h, i, j, k, l, m, n) => (d.DocumentStatus == null || d.DocumentStatus == 0 || d.DocumentStatus == 15)) .WhereIF(page.ddlDocumentStatus > 0 && page.ddlDocumentStatus != 15, (a, d, e, f, g, h, i, j, k, l, m, n) => d.DocumentStatus == page.ddlDocumentStatus) //投标状态 .WhereIF(page.ddlTenderStatus > 0 && page.ddlTenderStatus == 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (d.TenderStatus == null || d.TenderStatus == 0 )) .WhereIF(page.ddlTenderStatus > 0 && page.ddlTenderStatus != 1, (a, d, e, f, g, h, i, j, k, l, m, n) => d.TenderStatus == 1) //中标情况 .WhereIF(page.ddlWinStatus > 0 && page.ddlWinStatus == 1, (a, d, e, f, g, h, i, j, k, l, m, n) => n.IsWin == null ) .WhereIF(page.ddlWinStatus > 0 && page.ddlWinStatus != 1, (a, d, e, f, g, h, i, j, k, l, m, n) => n.IsWin == (page.ddlWinStatus -1) ) //质疑情况 .WhereIF(page.ddlOppugnStatus > 0 && page.ddlOppugnStatus == 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (e.FilePath == null || e.FilePath =="" )) .WhereIF(page.ddlOppugnStatus > 0 && page.ddlOppugnStatus != 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (e.FilePath != null && e.FilePath != "")) //投诉情况 .WhereIF(page.ddlComplainStatus > 0 && page.ddlComplainStatus == 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (f.FilePath == null || f.FilePath == "")) .WhereIF(page.ddlComplainStatus > 0 && page.ddlComplainStatus != 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (f.FilePath != null && f.FilePath != "")) //复议情况 .WhereIF(page.ddlReviewStatus > 0 && page.ddlReviewStatus == 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (g.FilePath == null || g.FilePath == "")) .WhereIF(page.ddlReviewStatus > 0 && page.ddlReviewStatus != 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (g.FilePath != null && g.FilePath != "")) //诉讼情况 .WhereIF(page.ddlLitigationStatus > 0 && page.ddlLitigationStatus == 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (h.FilePath == null || h.FilePath == "")) .WhereIF(page.ddlLitigationStatus > 0 && page.ddlLitigationStatus != 1, (a, d, e, f, g, h, i, j, k, l, m, n) => (h.FilePath != null && h.FilePath != "")) .Select((a, d, e, f, g, h, i, j, k, l, m, n) => new DocumentProjectInfoDTO { ProjectId = a.ProjectId, SignupStartTime = a.SignupStartTime, Province = a.Province, City = a.City, County = a.County, ProjectName = a.ProjectName, PurchaseUnit = a.PurchaseUnit, AgencyUnit = a.AgencyUnit, TenderTime = a.TenderTime, TenderPerson = d.TenderPerson, IsSignup = d.IsSignup, TenderDepositStatus = d.TenderDepositStatus, BidbondStatus = d.BidbondStatus, TenderStatus = d.TenderStatus, IsWin = n.IsWin, IsAdvise = i.IsAdvise, FilePathzy = k.FilePath, FilePathts = j.FilePath, FilePathfy = m.FilePath, FilePathss = l.FilePath, tbqk = "投标情况", wj = "", NoticeTypeName = "招标公告", NoticeType = a.NoticeType, PurchaseMethod = a.PurchaseMethod, DocumentStatus = d.DocumentStatus } ) .OrderByDescending(a => a.ProjectId).ToPageList(page.PageIndex, page.PageSize, ref total); result.TotalCount = total; result.TotalPage = total % page.PageSize == 0 ? total / page.PageSize : total / page.PageSize + 1; if(result.Items!=null && result.Items.Count > 0) { var ret = _db.Queryable().ToList(); foreach (var documentProjectInfoDTO in result.Items) { if(documentProjectInfoDTO.City == "请选择" && documentProjectInfoDTO.County == "请选择") { documentProjectInfoDTO.xmqy = documentProjectInfoDTO.Province; } else if (documentProjectInfoDTO.City == "请选择" && documentProjectInfoDTO.County == "其他") { documentProjectInfoDTO.xmqy = documentProjectInfoDTO.City; } else { documentProjectInfoDTO.xmqy = documentProjectInfoDTO.City+ documentProjectInfoDTO.County; } if(documentProjectInfoDTO.IsSignup == 1) { documentProjectInfoDTO.bm = "√"; } else { documentProjectInfoDTO.bm = "报名"; } if (!documentProjectInfoDTO.TenderDepositStatus.HasValue || documentProjectInfoDTO.TenderDepositStatus == 0 ) { documentProjectInfoDTO.bzj = "缴费"; } else if(documentProjectInfoDTO.TenderDepositStatus == 13) { documentProjectInfoDTO.bzj = "退款"; } else { documentProjectInfoDTO.bzj = "√"; } if (!documentProjectInfoDTO.BidbondStatus.HasValue || documentProjectInfoDTO.BidbondStatus == 0) { documentProjectInfoDTO.lybzj = "缴费"; } else if (documentProjectInfoDTO.BidbondStatus == 33) { documentProjectInfoDTO.lybzj = "退款"; } else { documentProjectInfoDTO.lybzj = "√"; } if (documentProjectInfoDTO.TenderStatus == 1) { documentProjectInfoDTO.tb = "√"; } else { documentProjectInfoDTO.tb = "投标"; } if (documentProjectInfoDTO.DocumentStatus == 17) { documentProjectInfoDTO.bs = "√"; } else if (documentProjectInfoDTO.DocumentStatus == 16) { documentProjectInfoDTO.bs = "制作中"; } else { documentProjectInfoDTO.bs = "未制作"; } if (!documentProjectInfoDTO.IsWin.HasValue || documentProjectInfoDTO.IsWin <= 0) { documentProjectInfoDTO.zb = "中标"; } else if (documentProjectInfoDTO.IsWin == 2) { documentProjectInfoDTO.zb = "√"; } else { documentProjectInfoDTO.zb = "×"; } if (documentProjectInfoDTO.IsAdvise == 1) { documentProjectInfoDTO.Advise = "√"; } else { documentProjectInfoDTO.Advise = ""; } if (!string.IsNullOrEmpty(documentProjectInfoDTO.FilePathzy)) { documentProjectInfoDTO.zy = "√"; } else { documentProjectInfoDTO.zy = ""; } if (!string.IsNullOrEmpty(documentProjectInfoDTO.FilePathts)) { documentProjectInfoDTO.ts = "√"; } else { documentProjectInfoDTO.ts = ""; } if (!string.IsNullOrEmpty(documentProjectInfoDTO.FilePathfy)) { documentProjectInfoDTO.fy = "√"; } else { documentProjectInfoDTO.fy = ""; } if (!string.IsNullOrEmpty(documentProjectInfoDTO.FilePathss)) { documentProjectInfoDTO.ss = "√"; } else { documentProjectInfoDTO.ss = ""; } if(documentProjectInfoDTO.PurchaseMethod.HasValue && documentProjectInfoDTO.PurchaseMethod.Value > 0) { var document_Dictionary = ret.Where(x => x.Id == documentProjectInfoDTO.PurchaseMethod).FirstOrDefault(); if (document_Dictionary != null) { documentProjectInfoDTO.PurchaseMethodName = document_Dictionary.Name; } } } } return result; } public bool DelProjectInfoByIds(List projectIdList) { try { _db.Ado.BeginTran(); foreach (int item in projectIdList) { _db.Deleteable().Where(new Document_ProjectInfo() { ProjectId = item }).ExecuteCommand(); _db.Deleteable().Where(new Document_ProjectDocumentInfo() { ProjectId = item }).ExecuteCommand(); _db.Deleteable().Where(new Document_ProjectExpand() { ProjectId = item }).ExecuteCommand(); _db.Deleteable().Where(new Document_ProjectLitigationInfo() { ProjectId = item }).ExecuteCommand(); _db.Deleteable().Where(new Document_ProjectOppugnInfo() { ProjectId = item }).ExecuteCommand(); _db.Deleteable().Where(new Document_ProjectReviewInfo() { ProjectId = item }).ExecuteCommand(); _db.Deleteable().Where(x=>x.ProjectId == item).ExecuteCommand(); _db.Deleteable().Where(new Document_ProjectComplainInfo() { ProjectId = item }).ExecuteCommand(); _db.Deleteable().Where(new Document_ProjectDocumentInfo() { ProjectId = item }).ExecuteCommand(); } _db.Ado.CommitTran(); } catch (Exception ex) { _db.Ado.RollbackTran(); return false; } return true; } public DocumentProjectInfoDTO GetProjectInfo(int ID , int TenantID) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.TenantID == TenantID).First(); if (ret == null) { ret = new Document_ProjectInfo(); } var documentProjectInfo = _mapper.Map(ret); var sys_CitySites = _db.Queryable().ToList(); if (!string.IsNullOrEmpty(documentProjectInfo.Province)) { var provice = sys_CitySites.Where(x => x.Name == documentProjectInfo.Province && x.ProvinceId == 0 && x.CityId == 0).FirstOrDefault(); if (provice != null) { documentProjectInfo.ProvinceId = provice.Keyid.Value; } } if (!string.IsNullOrEmpty(documentProjectInfo.City)) { var city = sys_CitySites.Where(x => x.Name == documentProjectInfo.City && x.ProvinceId == documentProjectInfo.ProvinceId && x.CityId == 0).FirstOrDefault(); if (city != null) { documentProjectInfo.CityId = city.Keyid.Value; } } if (!string.IsNullOrEmpty(documentProjectInfo.County)) { var county = sys_CitySites.Where(x => x.Name == documentProjectInfo.County && x.ProvinceId == documentProjectInfo.ProvinceId && x.CityId == documentProjectInfo.CityId).FirstOrDefault(); if (county != null) { documentProjectInfo.CountyId = county.Keyid.Value; } } return documentProjectInfo; } public Document_ProjectExpand GetProjectExpand(int ID, int UnitId) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.UnitId == UnitId ).First(); return ret; } public Document_WinInfo GetDocument_WinInfo(int ID, int UnitId) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.UnitId == UnitId ).First(); return ret; } public Document_AdviseInfo GetDocument_AdviseInfo(int ID, int UnitId) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); return ret; } public Document_ProjectOppugnInfo GetProjectOppugnInfo(int ID, int UnitId) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); return ret; } public Document_ProjectComplainInfo GetProjectComplainInfo(int ID, int UnitId) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); return ret; } public Document_ProjectReviewInfo GetProjectReviewInfo(int ID, int UnitId) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); return ret; } public Document_ProjectLitigationInfo GetProjectLitigationInfo(int ID, int UnitId) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); return ret; } public List GetOtherCompanyTenderInfoList(int ID, int TenantID) { var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.TenantID == TenantID).ToList(); return ret; } public Document_OtherCompanyTenderInfo GetOtherCompanyTenderInfo(int ID, string companyName) { var a = GetJwtInfo(); var ret = _db.Queryable().Where(x => x.TenantID == a.TEID && x.ProjectId == ID && x.CompanyName == companyName).First(); return ret; } public bool DelOtherCompanyTenderInfo(int Id) { _db.Deleteable().Where(new Document_OtherCompanyTenderInfo() { ID = Id }).ExecuteCommand(); return true; } public bool SaveOtherCompanyTenderInfo(Document_OtherCompanyTenderInfo dp) { if (dp.ID > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public bool UpdateProjectInfo(Document_ProjectInfo dp) { //var a = GetJwtInfo(); //dp.LastUpTime = DateTime.Now; //dp.CreatEmployeeId = a.EID; //var tentlist = _db.Queryable() // .Where(x => x.EmployeeId == a.EID //).First(); //if (tentlist != null) //{ // dw.CreatEmployeeName = tentlist.EmployeeName; //} return _projectInfoRepository.Update(dp); } public bool SaveDocumentWinInfo(Document_WinInfo dp) { if (dp.ID > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public bool SaveDocumentProjectExpand(Document_ProjectExpand dp) { if (dp.ID > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public Model.cyDocumentModel.Document_TenderUnit GetTenderUnit(int ID) { var ret = _db.Queryable().Where(x => x.UnitId == ID).First(); return ret; } public Document_EmployeeInfo GetDocument_EmployeeInfoByName(string EmployeeName) { var a = GetJwtInfo(); var ret1 = _db.Queryable().Where(x => x.TenantID == a.TEID).Select(x=>x.EmployeeID).ToList(); var ret = _db.Queryable().Where(x => x.EmployeeName == EmployeeName && ret1.Contains(x.EmployeeId)).First(); return ret; } public Model.cyDocumentModel.Document_EmployeeInfo GetDocument_EmployeeInfoInfo(int ID) { var ret = _db.Queryable().Where(x => x.EmployeeId == ID).First(); return ret; } public List GetAptitudeInfoByUnitId(int UnitId) { var result = _db.Queryable().Where( x=> x.UnitId == UnitId).ToList() ;//执行查询 return result; } public bool GetDeleteDocumentModel(int projectId, int unitId) { _db.Deleteable().Where(x=>x.ProjectId == projectId && x.UnitId == unitId).ExecuteCommand(); return true; } public Document_ProjectDocumentInfo GetProjectDocumentInfo(int projectId, int unitId) { var ret = _db.Queryable().Where(x => x.ProjectId == projectId && x.UnitId == unitId).First(); return ret; } public PageResult postDocumentList(DocumentProjectInfoPageSearch page) { var aaa = GetJwtInfo(); SqlSugar.PageModel pg = new SqlSugar.PageModel(); pg.PageSize = page.PageSize; pg.PageIndex = page.PageIndex; //page.ToEmployeeId = a.EID; int total = 0; PageResult result = new PageResult(); result.Items = _db.Queryable((a,b, d) => new JoinQueryInfos ( JoinType.Inner, a.ProjectId == b.ProjectId && b.TenantID == aaa.TEID, JoinType.Left, a.ProjectId == d.ProjectId && d.UnitId == page.UnitId )) .Where((a, b, d) => a.UnitId == page.UnitId) //省 .WhereIF(!string.IsNullOrEmpty(page.Province) && page.Province != "请选择", (a, b, d) => (b.Province == page.Province)) //市 .WhereIF(!string.IsNullOrEmpty(page.City) && page.City != "请选择", (a, b, d) => (b.City == page.City)) //区县 .WhereIF(!string.IsNullOrEmpty(page.County) && page.County != "请选择", (a, b, d) => (b.County == page.County)) //开标时间 .WhereIF(!string.IsNullOrEmpty(page.ddlTenderStartTime), (a, b, d) => b.TenderTime >= DateTime.Parse(page.ddlTenderStartTime)) //开标时间 .WhereIF(!string.IsNullOrEmpty(page.ddlTenderEndTime), (a, b, d) => b.TenderTime <= DateTime.Parse(page.ddlTenderEndTime)) //采购方式 .WhereIF(page.ddlPurchaseMethod > 0, (a, b, d) => b.PurchaseMethod == page.ddlPurchaseMethod) //项目名称 .WhereIF(!string.IsNullOrEmpty(page.txtProjectName), (a, b, d) => b.ProjectName.Contains(page.txtProjectName)) .Select((a, b, d) => new DocumentProjectInfoDTO { ProjectId = b.ProjectId, DocumentId = a.ID, TenderTime = b.TenderTime, Province = b.Province, City = b.City, County = b.County, ProjectName = b.ProjectName, PurchaseMethod = b.PurchaseMethod, LastUpdateTime = a.LastUpdateTime, } ) .OrderByDescending(a => a.LastUpdateTime).ToPageList(page.PageIndex, page.PageSize, ref total); result.TotalCount = total; result.TotalPage = total % page.PageSize == 0 ? total / page.PageSize : total / page.PageSize + 1; if (result.Items != null && result.Items.Count > 0) { var ret = _db.Queryable().ToList(); foreach (var documentProjectInfoDTO in result.Items) { if (documentProjectInfoDTO.City == "请选择" && documentProjectInfoDTO.County == "请选择") { documentProjectInfoDTO.xmqy = documentProjectInfoDTO.Province; } else if (documentProjectInfoDTO.City == "请选择" && documentProjectInfoDTO.County == "其他") { documentProjectInfoDTO.xmqy = documentProjectInfoDTO.City; } else { documentProjectInfoDTO.xmqy = documentProjectInfoDTO.City + documentProjectInfoDTO.County; } if (documentProjectInfoDTO.PurchaseMethod.HasValue && documentProjectInfoDTO.PurchaseMethod.Value > 0) { var document_Dictionary = ret.Where(x => x.Id == documentProjectInfoDTO.PurchaseMethod).FirstOrDefault(); if (document_Dictionary != null) { documentProjectInfoDTO.PurchaseMethodName = document_Dictionary.Name; } } } } return result; } public bool SaveDocumentProjectDocumentInfo(Document_ProjectDocumentInfo dp) { if (dp.ID > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } } }