using AngleSharp.Dom; using AngleSharp.Html.Parser; using DocumentServiceAPI.Application.DocManage.Dtos; 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.Data; using System.Diagnostics.Metrics; using System.Linq; using System.Reflection.Emit; 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")|| url.StartsWith("https://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; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("公开招标", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性谈判") >= 0) { document_ProjectInfo.PurchaseMethod = 4; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("竞争性谈判", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("单一来源") >= 0) { document_ProjectInfo.PurchaseMethod = 5; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("单一来源", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("询价") >= 0) { document_ProjectInfo.PurchaseMethod = 6; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("询价", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("邀请") >= 0) { document_ProjectInfo.PurchaseMethod = 31; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("邀请招标", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性磋商") >= 0) { document_ProjectInfo.PurchaseMethod = 37; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("竞争性磋商", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("框架协议") >= 0) { document_ProjectInfo.PurchaseMethod = 38; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("框架协议", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("比选") >= 0) { document_ProjectInfo.PurchaseMethod = 39; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("比选", "").Replace("公告", ""); } 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; } var jiezhishijian = document.All.Where(m => m.HasAttribute("id") && m.GetAttribute("id").StartsWith("_notice_content_noticePurchaseTime-noticePurchaseTime")).FirstOrDefault(); var jiezhishijians = jiezhishijian.QuerySelectorAll("span"); if (jiezhishijians != null && jiezhishijians.Length > 0) { //for (int i = 0; i < jiezhishijians.Length; i++) //{ // if (jiezhishijians[i].TextContent.IndexOf("年") >= 0 && jiezhishijians[i].TextContent.IndexOf("、") < 0) // { // } //} if (DateTime.TryParse(jiezhishijians[0].TextContent.Trim(), out b)) { document_ProjectInfo.SignupStartTime = b; } if (DateTime.TryParse(jiezhishijians[1].TextContent.Trim(), out b)) { document_ProjectInfo.SignupEndTime = b; } } document_ProjectInfo.PurchaseMethod = 0; if (document_ProjectInfo.ProjectName.IndexOf("公开招标") >= 0) { document_ProjectInfo.PurchaseMethod = 3; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("公开招标", "").Replace("公告",""); } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性谈判") >= 0) { document_ProjectInfo.PurchaseMethod = 4; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("竞争性谈判", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("单一来源") >= 0) { document_ProjectInfo.PurchaseMethod = 5; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("单一来源", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("询价") >= 0) { document_ProjectInfo.PurchaseMethod = 6; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("询价", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("邀请") >= 0) { document_ProjectInfo.PurchaseMethod = 31; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("邀请招标", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性磋商") >= 0) { document_ProjectInfo.PurchaseMethod = 37; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("竞争性磋商", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("框架协议") >= 0) { document_ProjectInfo.PurchaseMethod = 38; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("框架协议", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("比选") >= 0) { document_ProjectInfo.PurchaseMethod = 39; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("比选", "").Replace("公告", ""); } 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(); } } if (td[i].TextContent.IndexOf("项目名称:") >= 0 && td[i].TextContent.IndexOf("、") < 0) { if (string.IsNullOrEmpty(document_ProjectInfo.ProjectName)) { document_ProjectInfo.ProjectName = td[i].TextContent.Replace("项目名称:", "").Replace("1.", "").Replace("/", "").Trim(); } } if (td[i].TextContent.IndexOf("采购方式:") >= 0 && td[i].TextContent.IndexOf("、") < 0) { if (td[i].TextContent.IndexOf("公开招标") >= 0) { document_ProjectInfo.PurchaseMethod = 3; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("公开招标", "").Replace("公告", ""); } else if (td[i].TextContent.IndexOf("竞争性谈判") >= 0) { document_ProjectInfo.PurchaseMethod = 4; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("竞争性谈判", "").Replace("公告", ""); } else if (td[i].TextContent.IndexOf("单一来源") >= 0) { document_ProjectInfo.PurchaseMethod = 5; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("单一来源", "").Replace("公告", ""); } else if (td[i].TextContent.IndexOf("询价") >= 0) { document_ProjectInfo.PurchaseMethod = 6; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("询价", "").Replace("公告", ""); } else if (td[i].TextContent.IndexOf("邀请") >= 0) { document_ProjectInfo.PurchaseMethod = 31; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("邀请招标", "").Replace("公告", ""); } else if (td[i].TextContent.IndexOf("竞争性磋商") >= 0) { document_ProjectInfo.PurchaseMethod = 37; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("竞争性磋商", "").Replace("公告", ""); } else if (td[i].TextContent.IndexOf("框架协议") >= 0) { document_ProjectInfo.PurchaseMethod = 38; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("框架协议", "").Replace("公告", ""); } else if (td[i].TextContent.IndexOf("比选") >= 0) { document_ProjectInfo.PurchaseMethod = 39; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("比选", "").Replace("公告", ""); } } } } var txtAgencyManager = document.All.Where(m => m.LocalName == "span" && m.HasAttribute("id") && m.GetAttribute("id").StartsWith("_notice_content_projectContact-managerName")).FirstOrDefault(); if (txtAgencyManager != null) { document_ProjectInfo.AgencyManager = txtAgencyManager.TextContent; } 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; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("公开招标", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性谈判") >= 0) { document_ProjectInfo.PurchaseMethod = 4; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("竞争性谈判", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("单一来源") >= 0) { document_ProjectInfo.PurchaseMethod = 5; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("单一来源", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("询价") >= 0) { document_ProjectInfo.PurchaseMethod = 6; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("询价", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("邀请") >= 0) { document_ProjectInfo.PurchaseMethod = 31; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("邀请招标", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("竞争性磋商") >= 0) { document_ProjectInfo.PurchaseMethod = 37; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("竞争性磋商", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("框架协议") >= 0) { document_ProjectInfo.PurchaseMethod = 38; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("框架协议", "").Replace("公告", ""); } else if (document_ProjectInfo.ProjectName.IndexOf("比选") >= 0) { document_ProjectInfo.PurchaseMethod = 39; document_ProjectInfo.ProjectName = document_ProjectInfo.ProjectName.Replace("比选", "").Replace("公告", ""); } 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(); //var document_OtherCompanyTenderInfos = _db.Queryable().Where(x => x.TenantID == aaa.TEID).ToList(); 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) => a.TenderDeposit != null && a.TenderDeposit > 0 && 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) => (a.Bidbond!=null && a.Bidbond >0 && 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 != "")) .WhereIF(!string.IsNullOrEmpty(page.txtCompanyName), (a, d, e, f, g, h, i, j, k, l, m, n) => (n.FirstWinCompany.Contains(page.txtCompanyName) || n.SecondWinCompany.Contains(page.txtCompanyName) || n.ThirdCompany.Contains(page.txtCompanyName) || SqlFunc.Subqueryable().Where(s => s.TenantID == a.TenantID && s.ProjectId == a.ProjectId && s.CompanyName.Contains(page.txtCompanyName)).Any())) .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, SignupMethod = a.SignupMethod, } ) .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.SignupMethod == 9 ) { 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; } } var sss = _db.Queryable().Count(x => x.ProjectId == documentProjectInfoDTO.ProjectId && x.UnitId == page.UnitId); if (sss > 0) { documentProjectInfoDTO.zbwj = "√"; } else { documentProjectInfoDTO.zbwj = "招标文件"; } } } 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 aaa = GetJwtInfo(); var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.UnitId == UnitId ).First(); if (ret == null || string.IsNullOrEmpty(ret.FirstWinCompany)) { var projectInfo = _db.Queryable().Where(x => x.ProjectId == ID && x.TenantID == aaa.TEID).First(); if (projectInfo != null) { _db.AsTenant().ChangeDatabase("zhengcaioa"); var sss = _db.Ado.GetDataTable("select [Id] ,[start_time] ,[sheng] ,[city] ,[area_id] ,[cgfs] ,[number] ,[name] from Project where number=@number", new { number = projectInfo.ProjectCode }); if(sss!=null && sss.Rows.Count > 0) { ret = new Document_WinInfo(); ret.ProjectId = ID; ret.UnitId = UnitId; ret.IsWin = 0; foreach (DataRow row in sss.Rows) { var aaaaaaaa = _db.Ado.GetDataTable("select [zhongbiaoId] ,[ProjectId] ,[names] ,[price] ,[defen] ,[zb_zhiyistatus] ,[zb_zhiyishijian] ,[zb_zhiyichengli] ,[zb_tousustatus] ,[zb_tousushijian] ,[zb_tousuchengli] from Projectzhongbiao where ProjectId=@ProjectId", new { ProjectId = Convert.ToString(row["Id"]).Trim() }); if (aaaaaaaa != null && aaaaaaaa.Rows.Count > 0) { int i = 0; foreach (DataRow row0 in aaaaaaaa.Rows) { if (i == 0) { ret.FirstWinCompany = Convert.ToString(row0["names"]).Trim(); if(row0["price"]!=null && !string.IsNullOrEmpty(row0["price"].ToString())) { string price = row0["price"].ToString().Trim().Replace("元", "").Replace("万", ""); decimal priceprice = 0; if(decimal.TryParse(price,out priceprice)) { ret.FirstPrice = priceprice; } } ret.FirstWinDefen = Convert.ToString(row0["defen"]).Trim(); } if (i == 1) { ret.SecondWinCompany = Convert.ToString(row0["names"]).Trim(); if (row0["price"] != null && !string.IsNullOrEmpty(row0["price"].ToString())) { string price = row0["price"].ToString().Trim().Replace("元", "").Replace("万", ""); decimal priceprice = 0; if (decimal.TryParse(price, out priceprice)) { ret.SecondPrice = priceprice; } } ret.SecondWinDefen = Convert.ToString(row0["defen"]).Trim(); } if (i == 2) { ret.ThirdCompany = Convert.ToString(row0["names"]).Trim(); if (row0["price"] != null && !string.IsNullOrEmpty(row0["price"].ToString())) { string price = row0["price"].ToString().Trim().Replace("元", "").Replace("万", ""); decimal priceprice = 0; if (decimal.TryParse(price, out priceprice)) { ret.ThirdPrice = priceprice; } } ret.ThirdWinDefen = Convert.ToString(row0["defen"]).Trim(); } i += 1; } //if (aaaaaaaa.Rows.Count > 0) //{ // DataRow row0 = aaaaaaaa.Rows[0]; // ret.FirstWinCompany = Convert.ToString(row0.ItemArray[2]).Trim(); // ret.FirstPrice = Convert.ToDecimal(row0.ItemArray[3]); // ret.FirstWinDefen = Convert.ToString(row0.ItemArray[4]).Trim(); //} //if (aaaaaaaa.Rows.Count > 1) //{ // DataRow row1 = aaaaaaaa.Rows[1]; // ret.SecondWinCompany = Convert.ToString(row1.ItemArray[2]).Trim(); // ret.SecondPrice = Convert.ToDecimal(row1.ItemArray[3]); // ret.SecondWinDefen = Convert.ToString(row1.ItemArray[4]).Trim(); //} //if (aaaaaaaa.Rows.Count > 2) //{ // DataRow row2 = aaaaaaaa.Rows[2]; // ret.ThirdCompany = Convert.ToString(row2.ItemArray[2]).Trim(); // ret.ThirdPrice = Convert.ToDecimal(row2.ItemArray[3]); // ret.ThirdWinDefen = Convert.ToString(row2.ItemArray[4]).Trim(); //} break; } } } } } 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 aaa = GetJwtInfo(); var ret = _db.Queryable().Where(x => x.ProjectId == ID && x.TenantID == TenantID).ToList(); if (ret == null || ret.Count==0) { var projectInfo = _db.Queryable().Where(x => x.ProjectId == ID && x.TenantID == TenantID).First(); if (projectInfo != null) { _db.AsTenant().ChangeDatabase("zhengcaioa"); var sss = _db.Ado.GetDataTable("select [Id] ,[start_time] ,[sheng] ,[city] ,[area_id] ,[cgfs] ,[number] ,[name] from Project where number=@number", new { number = projectInfo.ProjectCode }); if (sss != null && sss.Rows.Count > 0) { ret = new List(); foreach (DataRow row in sss.Rows) { var aaaaaaaa = _db.Ado.GetDataTable("select [youxiaoId] ,[ProjectId] ,[namesyouxiao] ,[priceyouxiao] ,[yx_zhiyistatus] ,[yx_zhiyishijian] ,[yx_zhiyichengli] ,[yx_tousustatus] ,[yx_tousushijian] ,[yx_tousuchengli] from Projectyouxiao where ProjectId=@ProjectId", new { ProjectId = Convert.ToString(row["Id"]).Trim() }); if (aaaaaaaa != null && aaaaaaaa.Rows.Count > 0) { foreach (DataRow row0 in aaaaaaaa.Rows) { Document_OtherCompanyTenderInfo document_OtherCompanyTenderInfo = new Document_OtherCompanyTenderInfo(); document_OtherCompanyTenderInfo.ProjectId = ID; document_OtherCompanyTenderInfo.CompanyName = Convert.ToString(row0["namesyouxiao"]).Trim(); if (row0["priceyouxiao"] != null && !string.IsNullOrEmpty(row0["priceyouxiao"].ToString())) { string price = row0["priceyouxiao"].ToString().Trim().Replace("元", "").Replace("万", ""); decimal priceprice = 0; if (decimal.TryParse(price, out priceprice)) { document_OtherCompanyTenderInfo.TenderPrice = priceprice; } } document_OtherCompanyTenderInfo.TenantID = TenantID; ret.Add(document_OtherCompanyTenderInfo); } break; } } } } } 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.is_del == false && x.org_id == UnitId && x.zige_code > 0).OrderBy(x=>x.doc_code).OrderBy(x=>x.sort).ToList() ;//执行查询 var ids = result.Select(x => x.id).ToArray(); var file = _db.Queryable().Where(x => ids.Contains(x.doc_id) && x.status ==1 ).ToList();//执行查询 var document_AptitudeInfos = new List(); foreach (var doc_Info in result) { var document_AptitudeInfo = new Document_AptitudeInfo(); var filesss = file.Where(x => x.doc_id == doc_Info.id).OrderBy(x => x.sort).ToList(); if(filesss!=null && filesss.Count > 0) { document_AptitudeInfo.FilePath = ""; document_AptitudeInfo.FileName = ""; document_AptitudeInfo.FileSize = 0; for (int i=0;i< filesss.Count; i++) { document_AptitudeInfo.FilePath += filesss[i].filepath; document_AptitudeInfo.FileName += filesss[i].filenewname; document_AptitudeInfo.FileSize += filesss[i].filesize; ; if (i!= filesss.Count - 1) { document_AptitudeInfo.FilePath += ";"; document_AptitudeInfo.FileName += ";"; } } } document_AptitudeInfo.AptitudeId = doc_Info.id; document_AptitudeInfo.AptitudeName = doc_Info.doc_name; document_AptitudeInfo.AptitudeType = doc_Info.classification_id; document_AptitudeInfo.IsUsed = doc_Info.status; document_AptitudeInfo.FileVersionNo = ""; document_AptitudeInfo.SendTime = doc_Info.add_time.ToShortDateString(); document_AptitudeInfo.UnitId = doc_Info.org_id.HasValue ? doc_Info.org_id.Value : 0; ; document_AptitudeInfo.LastUpdateTime = doc_Info.add_time; document_AptitudeInfo.LastUpdateName = ""; document_AptitudeInfo.AdviseFlag = doc_Info.zige_code; ; document_AptitudeInfo.UserId = doc_Info.tenant_code; document_AptitudeInfos.Add(document_AptitudeInfo); } //var resultAchievement = _db.Queryable().Where(x => x.status == 1 && x.tenant_code == UnitId).OrderBy(x=>x.sort).ToList();//执行查询 //foreach (var achievement in resultAchievement) //{ // var document_AptitudeInfo = new Document_AptitudeInfo(); // document_AptitudeInfo.FilePath = ""; // document_AptitudeInfo.FileName = ""; // document_AptitudeInfo.FileSize = 0; // if (!string.IsNullOrEmpty(achievement.zbtzs_url)) // { // document_AptitudeInfo.FilePath += achievement.zbtzs_url; // document_AptitudeInfo.FileName += "中标通知书"; // document_AptitudeInfo.FileSize += 0 ; // document_AptitudeInfo.FilePath += ";"; // document_AptitudeInfo.FileName += ";"; // } // if (!string.IsNullOrEmpty(achievement.ht_url)) // { // document_AptitudeInfo.FilePath += achievement.ht_url; // document_AptitudeInfo.FileName += "合同"; // document_AptitudeInfo.FileSize += 0; // document_AptitudeInfo.FilePath += ";"; // document_AptitudeInfo.FileName += ";"; // } // if (!string.IsNullOrEmpty(achievement.ysbg_url)) // { // document_AptitudeInfo.FilePath += achievement.ysbg_url; // document_AptitudeInfo.FileName += "验收报告"; // document_AptitudeInfo.FileSize += 0; // document_AptitudeInfo.FilePath += ";"; // document_AptitudeInfo.FileName += ";"; // } // if (!string.IsNullOrEmpty(achievement.fkpz_url)) // { // document_AptitudeInfo.FilePath += achievement.fkpz_url; // document_AptitudeInfo.FileName += "付款凭证"; // document_AptitudeInfo.FileSize += 0; // document_AptitudeInfo.FilePath += ";"; // document_AptitudeInfo.FileName += ";"; // } // if (!string.IsNullOrEmpty(achievement.yhpj_url)) // { // document_AptitudeInfo.FilePath += achievement.yhpj_url; // document_AptitudeInfo.FileName += "用户评价"; // document_AptitudeInfo.FileSize += 0; // document_AptitudeInfo.FilePath += ";"; // document_AptitudeInfo.FileName += ";"; // } // if (!string.IsNullOrEmpty(achievement.hjzs_url)) // { // document_AptitudeInfo.FilePath += achievement.hjzs_url; // document_AptitudeInfo.FileName += "获奖证书"; // document_AptitudeInfo.FileSize += 0; // document_AptitudeInfo.FilePath += ";"; // document_AptitudeInfo.FileName += ";"; // } // if (document_AptitudeInfo.FilePath.EndsWith(";")) // { // document_AptitudeInfo.FilePath = document_AptitudeInfo.FilePath.Substring(0, document_AptitudeInfo.FilePath.Length - 1); // } // if (document_AptitudeInfo.FileName.EndsWith(";")) // { // document_AptitudeInfo.FileName = document_AptitudeInfo.FileName.Substring(0, document_AptitudeInfo.FileName.Length - 1); // } // document_AptitudeInfo.AptitudeId = achievement.id; // document_AptitudeInfo.AptitudeName = achievement.achievement_name; // document_AptitudeInfo.AptitudeType = achievement.classification_id; // document_AptitudeInfo.IsUsed = achievement.status; // document_AptitudeInfo.FileVersionNo = ""; // document_AptitudeInfo.SendTime = achievement.add_time.ToShortDateString(); // document_AptitudeInfo.UnitId = achievement.tenant_code ; // document_AptitudeInfo.LastUpdateTime = achievement.add_time; // document_AptitudeInfo.LastUpdateName = ""; // document_AptitudeInfo.AdviseFlag = 1; // document_AptitudeInfo.UserId = achievement.tenant_code; // document_AptitudeInfos.Add(document_AptitudeInfo); //} var resultShebeinengli = _db.Queryable().Where(x => x.status == 1 && x.tenant_code == UnitId && (x.sbzp_zige > 0 || x.gmht_zige > 0 || x.fp_zige > 0 || x.fkpz_zige > 0 || x.csmp_zige > 0)).OrderBy(x => x.sort).ToList();//执行查询 foreach (var achievement in resultShebeinengli) { var document_AptitudeInfo = new Document_AptitudeInfo(); document_AptitudeInfo.FilePath = ""; document_AptitudeInfo.FileName = ""; document_AptitudeInfo.FileSize = 0; if (!string.IsNullOrEmpty(achievement.sbzp_url) && achievement.sbzp_zige > 0) { document_AptitudeInfo.FilePath += achievement.sbzp_url; document_AptitudeInfo.FileName += "设备照片"; document_AptitudeInfo.FileSize += 0; document_AptitudeInfo.FilePath += ";"; document_AptitudeInfo.FileName += ";"; } if (!string.IsNullOrEmpty(achievement.gmht_url) && achievement.gmht_zige > 0) { document_AptitudeInfo.FilePath += achievement.gmht_url; document_AptitudeInfo.FileName += "购买合同"; document_AptitudeInfo.FileSize += 0; document_AptitudeInfo.FilePath += ";"; document_AptitudeInfo.FileName += ";"; } if (!string.IsNullOrEmpty(achievement.fp_url) && achievement.fp_zige > 0) { document_AptitudeInfo.FilePath += achievement.fp_url; document_AptitudeInfo.FileName += "发票"; document_AptitudeInfo.FileSize += 0; document_AptitudeInfo.FilePath += ";"; document_AptitudeInfo.FileName += ";"; } if (!string.IsNullOrEmpty(achievement.fkpz_url) && achievement.fkpz_zige > 0) { document_AptitudeInfo.FilePath += achievement.fkpz_url; document_AptitudeInfo.FileName += "付款凭证"; document_AptitudeInfo.FileSize += 0; document_AptitudeInfo.FilePath += ";"; document_AptitudeInfo.FileName += ";"; } if (!string.IsNullOrEmpty(achievement.csmp_url) && achievement.csmp_zige > 0) { document_AptitudeInfo.FilePath += achievement.csmp_url; document_AptitudeInfo.FileName += "参数(铭牌)"; document_AptitudeInfo.FileSize += 0; document_AptitudeInfo.FilePath += ";"; document_AptitudeInfo.FileName += ";"; } if (document_AptitudeInfo.FilePath.EndsWith(";")) { document_AptitudeInfo.FilePath = document_AptitudeInfo.FilePath.Substring(0, document_AptitudeInfo.FilePath.Length - 1); } if (document_AptitudeInfo.FileName.EndsWith(";")) { document_AptitudeInfo.FileName = document_AptitudeInfo.FileName.Substring(0, document_AptitudeInfo.FileName.Length - 1); } document_AptitudeInfo.AptitudeId = achievement.id; document_AptitudeInfo.AptitudeName = achievement.shebeinengli_name; document_AptitudeInfo.AptitudeType = achievement.classification_id; document_AptitudeInfo.IsUsed = achievement.status; document_AptitudeInfo.FileVersionNo = ""; document_AptitudeInfo.SendTime = achievement.add_time.ToShortDateString(); document_AptitudeInfo.UnitId = achievement.tenant_code; document_AptitudeInfo.LastUpdateTime = achievement.add_time; document_AptitudeInfo.LastUpdateName = ""; document_AptitudeInfo.AdviseFlag = achievement.zige_code; document_AptitudeInfo.UserId = achievement.tenant_code; document_AptitudeInfos.Add(document_AptitudeInfo); } return document_AptitudeInfos; } 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; } public Document_DelegatePersonInfo GetDelegatePersonInfo(int ID) { var ret = _db.Queryable().Where(x => x.DelegateId == ID).First(); return ret; } public bool SaveDocumentProjectOppugnInfo(Document_ProjectOppugnInfo dp) { if (dp.ID > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public List GetAllDelegatePerson() { var a = GetJwtInfo(); var result = _db.Queryable().Where(x => x.IsUse == 1 && x.TenantID == a.TEID ).ToList();//执行查询 return result; } public bool SaveDocumentProjectComplainInfo(Document_ProjectComplainInfo dp) { if (dp.ID > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public bool SaveDocumentProjectReviewInfo(Document_ProjectReviewInfo dp) { if (dp.ID > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public string GetPreUnit(string childName) { string preUnit = ""; Sys_CitySite preModel = null; var m_Sys_CitySite = _db.Queryable().Where(x => x.Name == childName).First();//执行查询 if (m_Sys_CitySite != null) { if (m_Sys_CitySite.CityLevel == 3) { preModel = _db.Queryable().Where(x=>x.Keyid == m_Sys_CitySite.CityId).First(); } else if (m_Sys_CitySite.CityLevel == 2) { preModel = _db.Queryable().Where(x => x.Keyid == m_Sys_CitySite.ProvinceId).First(); } else { preModel = m_Sys_CitySite; } } if (preModel != null) { preUnit = preModel.Name; } return preUnit; } public bool SaveDocumentProjectLitigationInfo(Document_ProjectLitigationInfo dp) { if (dp.ID > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public bool SaveDocumentAdviseInfo(Document_AdviseInfo dp) { { if (dp.Id > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } } public Document_DocumentTempletInfo GetTempletModel(int templetId) { var ret = _db.Queryable().Where(x => x.TempletId == templetId).First(); return ret; } public List GetDocumentTempletList() { var aaa = GetJwtInfo(); var result = _db.Queryable().Where(x => x.IsUsed == 1 && x.UnitId == aaa.UID).OrderByDescending(x=>x.LastUpdateTime).ToList();//执行查询 return result; } public PageResult postDocumentZhaobiaoFileList(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() .Where(a => a.UnitId == page.UnitId && a.ProjectId == page.ProjectId) //文件名称 .WhereIF(!string.IsNullOrEmpty(page.FileName), a=>a.FileName.Contains(page.FileName)) .Select(a => new Document_ZhaobiaoFile { Id = a.Id, FileName = a.FileName, FilePath = a.FilePath, FileVersionNo = a.FileVersionNo, FileSize = a.FileSize, UnitId = a.UnitId, LastUpdateTime = a.LastUpdateTime, LastUpdateName = a.LastUpdateName, AdviseFlag = a.AdviseFlag, UserId = a.UserId, } ) .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; return result; } public Document_ZhaobiaoFile GetDocumentZhaobiaoFileInfo(int ID) { var result = _db.Queryable().Where(x => x.Id == ID).First();//执行查询 return result; } public bool GetDeleteDocumentZhaobiaoFile(int ID) { _db.Deleteable().Where(x => x.Id == ID).ExecuteCommand(); return true; } public bool SaveDocumentZhaobiaoFileInfo(Document_ZhaobiaoFile dp) { if (dp.Id > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public PageResult postDocumentTBXYFileList(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() .Where(a => a.UnitId == page.UnitId && a.ProjectId == page.ProjectId) //文件名称 .WhereIF(!string.IsNullOrEmpty(page.FileName), a => a.FileName.Contains(page.FileName)) .WhereIF(page.Classification>0, a => a.Classification == page.Classification) .WhereIF(!string.IsNullOrEmpty(page.FilePath), a => ( a.FilePath !=null && a.FilePath != "")) .Select(a => new DocumentTBXYFileDTO { Id = a.Id, FileName = a.FileName, FilePath = a.FilePath, FileVersionNo = a.FileVersionNo, FileSize = a.FileSize, UnitId = a.UnitId, LastUpdateTime = a.LastUpdateTime, LastUpdateName = a.LastUpdateName, AdviseFlag = a.AdviseFlag, UserId = a.UserId, Sort = a.Sort, Classification = a.Classification, } ) .OrderBy(a => a.Sort).ToPageList(page.PageIndex, page.PageSize, ref total); if(result.Items !=null&& result.Items.Count > 0) { var doc_Classifications = _db.Queryable().Where(x => x.parent_code == "000").ToList();//执行查询 foreach (var item in result.Items) { var doc_Classification = doc_Classifications.Where(x => x.id == item.Classification).FirstOrDefault(); if (doc_Classification != null) { item.ClassificationName = doc_Classification.doc_classification; } } } result.TotalCount = total; result.TotalPage = total % page.PageSize == 0 ? total / page.PageSize : total / page.PageSize + 1; return result; } public Document_TBXYFile GetDocumentTBXYFileInfo(int ID) { var result = _db.Queryable().Where(x => x.Id == ID).First();//执行查询 return result; } public bool GetDeleteDocumentTBXYFile(int ID) { _db.Deleteable().Where(x => x.Id == ID).ExecuteCommand(); return true; } public bool SaveDocumentTBXYFileInfo(Document_TBXYFile dp) { var result = _db.Queryable().Where(x => x.ProjectId == dp.ProjectId && x.UnitId == dp.UnitId).First();//执行查询 if (result != null) { result.LastUpdateTime = dp.LastUpdateTime; _db.Updateable(result).ExecuteCommand(); } if (dp.Id > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public List GetDocumentTBXYFileList(int projectId, int unitId) { var ret = _db.Queryable() .Where(x => x.ProjectId == projectId && x.UnitId == unitId) .Select(a => new Document_TBXYFile { Id = a.Id, FileName = a.FileName, FilePath = a.FilePath, FileVersionNo = a.FileVersionNo, FileSize = a.FileSize, UnitId = a.UnitId, LastUpdateTime = a.LastUpdateTime, LastUpdateName = a.LastUpdateName, AdviseFlag = a.AdviseFlag, UserId = a.UserId, Sort = a.Sort, SaveFlag = a.SaveFlag, Classification = a.Classification, }).OrderBy(a => a.Sort).ToList(); return ret; } public Document_TBXYFile GetDocumentTBXYFileByFileName(int projectId, int unitId, string FileName) { var ret = _db.Queryable().Where(x => x.ProjectId == projectId && x.UnitId == unitId && x.FileName == FileName ).First(); return ret; } public int SaveDocInfo(Doc_Info dp) { if (dp.id > 0) { _db.Updateable(dp).ExecuteCommand(); } else { dp.id = _db.Insertable(dp).ExecuteReturnIdentity(); } return dp.id; } public bool SaveFileInfo(File_Info dp) { if (dp.id > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public List GetDocClassificationList() { var ret = _db.Queryable().Where(x => x.parent_code =="000" && x.is_system == true).ToList(); return ret; } public bool SaveDocumentTBXYFileInfoNotRep(Document_TBXYFile dp) { if (dp.Id > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public PageResult postDocClassificationList(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) => new JoinQueryInfos ( JoinType.Left, a.id == b.doc_classification_id && b.tenant_code == page.TenantID )) .Where((a, b) => ( a.tenant_code == page.TenantID || a.is_system == true) ) //文件名称 .WhereIF(!string.IsNullOrEmpty(page.FileName), (a, b) => a.doc_classification.Contains(page.FileName)) .WhereIF(!string.IsNullOrEmpty(page.parentcode), (a, b) => a.parent_code == page.parentcode ) .WhereIF(page.Status.HasValue, (a, b) => (a.is_system == false && a.status == page.Status.Value ) || (page.Status.Value == 1 && a.is_system == true && b.tenant_code == null ) || (page.Status.Value == 0 && a.is_system == true && b.tenant_code != null)) .Select((a, b) => new DocClassificationDTO { id = a.id, doc_classification_code = a.doc_classification_code, doc_classification = a.doc_classification, parent_code = a.parent_code, is_system = a.is_system, sort_id = a.sort_id, tenant_code = a.tenant_code, add_time = a.add_time, status = a.status, } ) .OrderBy(a => a.sort_id).ToPageList(page.PageIndex, page.PageSize, ref total); if (result.Items != null && result.Items.Count > 0) { foreach (var item in result.Items) { if (item.is_system) { var doc_ClassDel = _db.Queryable().Where(x => x.doc_classification_id == item.id && x.tenant_code == page.TenantID ).First();//执行查询 if (doc_ClassDel != null) { item.status = 0; item.statusName = "停用"; } else { item.statusName = "启用"; } } else { if(item.status == 1) { item.statusName = "启用"; } else { item.statusName = "停用"; } } } } result.TotalCount = total; result.TotalPage = total % page.PageSize == 0 ? total / page.PageSize : total / page.PageSize + 1; return result; } public Doc_Classification GetDocClassificationInfo(int ID) { var aaa = GetJwtInfo(); var result = _db.Queryable().Where(x => x.id == ID).First();//执行查询 if (result!=null && result.is_system) { var doc_ClassDel = _db.Queryable().Where(x => x.doc_classification_id == result.id && x.tenant_code == aaa.TEID).First();//执行查询 if (doc_ClassDel != null) { result.status = 0; } else { result.status = 1; } } return result; } public bool GetDeleteDocClassDel(int ID , int tenantId) { _db.Deleteable().Where(x => x.doc_classification_id == ID && x.tenant_code == tenantId ).ExecuteCommand(); return true; } public bool GetDeleteDocClassification(int ID ) { var result = _db.Queryable().Where(x => x.id == ID).First();//执行查询 if (result != null) { _db.Deleteable().Where(x => x.parent_code == result.doc_classification_code).ExecuteCommand(); } _db.Deleteable().Where(x => x.id == ID ).ExecuteCommand(); return true; } public bool SaveDocClassificationInfo(Doc_Classification dp) { if (dp.id > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public bool SaveDocClassDelInfo(Doc_ClassDel dp) { if (dp.id > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public List GetDocClassificationList(int tenantId) { var ret = _db.Queryable() .Where(x => ((x.tenant_code == tenantId && x.status == 1) || x.is_system == true) && x.parent_code == "00" ) //.Select(a => new Document_TBXYFile //{ // Id = a.Id, // FileName = a.FileName, // FilePath = a.FilePath, // FileVersionNo = a.FileVersionNo, // FileSize = a.FileSize, // UnitId = a.UnitId, // LastUpdateTime = a.LastUpdateTime, // LastUpdateName = a.LastUpdateName, // AdviseFlag = a.AdviseFlag, // UserId = a.UserId, // Sort = a.Sort, // SaveFlag = a.SaveFlag, // Classification = a.Classification, //}) .OrderBy(a => a.sort_id).ToList(); if (ret != null && ret.Count > 0) { foreach (var item in ret) { if (item.is_system) { var doc_ClassDel = _db.Queryable().Where(x => x.doc_classification_id == item.id && x.tenant_code == tenantId).First();//执行查询 if (doc_ClassDel != null) { item.status = 0; } } } } ret = ret.Where(x => x.status == 1).ToList(); return ret; } public Doc_Classification GetDocClassificationByFileName(int tenantId , string FileName, string parent_code) { var ret = _db.Queryable().Where(x => ( x.tenant_code == tenantId || x.is_system == true ) && x.doc_classification == FileName && x.parent_code == parent_code).First(); return ret; } public Doc_Classification GetDocClassificationcode(int tenantId,string parent_code) { var ret = _db.Queryable().Where(x => (x.tenant_code == tenantId || x.is_system == true) && x.parent_code == parent_code).OrderByDescending(x=>x.doc_classification_code).First(); string doc_classification_code = (int.Parse(ret.doc_classification_code) + 1).ToString().PadLeft(3, '0'); Doc_Classification doc_Classification = new Doc_Classification(); doc_Classification.doc_classification_code = doc_classification_code; return doc_Classification; } public Doc_Classification GetDocClassificationInfoMaxSortId(int tenantId ,string docclassificationcode) { var ret = _db.Queryable() .Where(x => (x.tenant_code == tenantId || x.is_system == true)) .WhereIF(!string.IsNullOrEmpty(docclassificationcode), x => x.parent_code == docclassificationcode) .Where(x => x.sort_id <= 99999) .Max(x => x.sort_id); Doc_Classification doc_Classification = new Doc_Classification(); doc_Classification.sort_id = ret; return doc_Classification; } public Doc_Classification GetDocumentInfoMaxSortId(int unitId, string doccode) { var ret = _db.Queryable() .Where(x => x.org_id == unitId ) .WhereIF(!string.IsNullOrEmpty(doccode), x => x.doc_code == doccode) .Max(x => x.sort); Doc_Classification doc_Classification = new Doc_Classification(); doc_Classification.sort_id = ret??0; return doc_Classification; } public Doc_Classification GetAchievementInfoMaxSortId(int unitId) { var ret = _db.Queryable() .Where(x => x.tenant_code == unitId) //.WhereIF(!string.IsNullOrEmpty(doccode), x => x.doc_code == doccode) .Max(x => x.sort); Doc_Classification doc_Classification = new Doc_Classification(); doc_Classification.sort_id = ret ?? 0; return doc_Classification; } public Doc_Classification GetShebeinengliInfoMaxSortId(int unitId) { var ret = _db.Queryable() .Where(x => x.tenant_code == unitId) //.WhereIF(!string.IsNullOrEmpty(doccode), x => x.doc_code == doccode) .Max(x => x.sort); Doc_Classification doc_Classification = new Doc_Classification(); doc_Classification.sort_id = ret ?? 0; return doc_Classification; } public PageResult postDocumentTempletList(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(); var document_DocumentTempletInfos = _db.Queryable () .Where(x=>x.UnitId == aaa.UID) //文件名称 .WhereIF(!string.IsNullOrEmpty(page.templetName), a => a.TempletName.Contains(page.templetName)) .WhereIF(page.purchaseMethod !=0, a => a.PurchaseMethod == page.purchaseMethod) .WhereIF(page.IsUsed>0, a => (page.IsUsed == 1 && a.IsUsed == 1 ) || (page.IsUsed != 1 && a.IsUsed == 2)) .OrderByDescending(a => a.TempletId).ToPageList(page.PageIndex, page.PageSize, ref total); result.Items = _mapper.Map>(document_DocumentTempletInfos); if (result.Items != null && result.Items.Count > 0) { foreach (var item in result.Items) { if (item.IsUsed == 1) { item.isUseName = "启用"; item.isUseOp = "停用"; } else { item.isUseName = "停用"; item.isUseOp = "启用"; } } } result.TotalCount = total; result.TotalPage = total % page.PageSize == 0 ? total / page.PageSize : total / page.PageSize + 1; return result; } public bool GetDeleteDocumentTempletInfo(int ID) { _db.Deleteable().Where(x => x.TempletId == ID ).ExecuteCommand(); return true; } public bool SaveDocumentTempletInfo(Document_DocumentTempletInfo dp) { if (dp.TempletId > 0) { _db.Updateable(dp).ExecuteCommand(); } else { _db.Insertable(dp).ExecuteCommand(); } return true; } public Document_DocumentTempletInfo GetTempletModelByProjectId(int projiectid) { var aaa = GetJwtInfo(); var ret = _db.Queryable().Where(x => x.ProjectId == projiectid && x.UnitId == aaa.UID ).First(); return ret; } } }