From 9c7ff006100d327b1b60615304de348f5ad36c63 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期三, 16 八月 2023 09:06:14 +0800 Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/DocumentService --- DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs | 1235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1,235 insertions(+), 0 deletions(-) diff --git a/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs b/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs new file mode 100644 index 0000000..6badc72 --- /dev/null +++ b/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs @@ -0,0 +1,1235 @@ +锘縰sing 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<Document_EmployeeInfo>() + // .Where(x => x.EmployeeId == a.EID + + //).First(); + //if (tentlist != null) + //{ + // dw.CreatEmployeeName = tentlist.EmployeeName; + + //} + var documentProjectInfo = _mapper.Map<Document_ProjectInfo>(dp); + return _projectInfoRepository.Insert(documentProjectInfo); + + } + + public bool IsExistProject(string ProjectName, string ProjectCode) + { + var a = GetJwtInfo(); + + var ret = _db.Queryable<Document_ProjectInfo>().Count(x => x.ProjectCode == ProjectCode && x.ProjectName == ProjectName && x.TenantID == a.TEID); + + if(ret > 0) + { + return true; + } + else + { + return false; + } + + } + + + + + + + /// <summary> + /// 鑾峰彇Jwt鐩稿叧淇℃伅 + /// </summary> + 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<AngleSharp.Dom.IElement>(); + if (url.StartsWith("http://www.ccgp.gov.cn")) + { + using (HttpClient client = new HttpClient()) + { + client.Timeout = TimeSpan.FromSeconds(60); + //List<sichuanjieshoudtl> data = new List<sichuanjieshoudtl>(); + 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("閲囪喘浠g悊鏈烘瀯淇℃伅") >= 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("閲囪喘浠g悊鏈烘瀯淇℃伅") >= 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("閲囪喘浠g悊鏈烘瀯淇℃伅") >= 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<DocumentProjectInfoDTO> 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<DocumentProjectInfoDTO> result = new PageResult<DocumentProjectInfoDTO>(); + + + + result.Items = _db.Queryable<Document_ProjectInfo, Document_ProjectExpand, Document_ProjectOppugnInfo, Document_ProjectComplainInfo, Document_ProjectReviewInfo, Document_ProjectLitigationInfo, Document_AdviseInfo, Document_ProjectComplainInfo, Document_ProjectOppugnInfo, Document_ProjectLitigationInfo, Document_ProjectReviewInfo, Document_WinInfo>((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)) + //浠g悊鏈烘瀯 + .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<Document_Dictionary>().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<int> projectIdList) + { + try + { + _db.Ado.BeginTran(); + foreach (int item in projectIdList) + { + _db.Deleteable<Document_ProjectInfo>().Where(new Document_ProjectInfo() { ProjectId = item }).ExecuteCommand(); + _db.Deleteable<Document_ProjectDocumentInfo>().Where(new Document_ProjectDocumentInfo() { ProjectId = item }).ExecuteCommand(); + _db.Deleteable<Document_ProjectExpand>().Where(new Document_ProjectExpand() { ProjectId = item }).ExecuteCommand(); + _db.Deleteable<Document_ProjectLitigationInfo>().Where(new Document_ProjectLitigationInfo() { ProjectId = item }).ExecuteCommand(); + _db.Deleteable<Document_ProjectOppugnInfo>().Where(new Document_ProjectOppugnInfo() { ProjectId = item }).ExecuteCommand(); + _db.Deleteable<Document_ProjectReviewInfo>().Where(new Document_ProjectReviewInfo() { ProjectId = item }).ExecuteCommand(); + _db.Deleteable<Document_WinInfo>().Where(x=>x.ProjectId == item).ExecuteCommand(); + _db.Deleteable<Document_ProjectComplainInfo>().Where(new Document_ProjectComplainInfo() { ProjectId = item }).ExecuteCommand(); + _db.Deleteable<Document_ProjectDocumentInfo>().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<Document_ProjectInfo>().Where(x => x.ProjectId == ID && x.TenantID == TenantID).First(); + if (ret == null) + { + ret = new Document_ProjectInfo(); + } + var documentProjectInfo = _mapper.Map<DocumentProjectInfoDTO>(ret); + var sys_CitySites = _db.Queryable<Sys_CitySite>().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<Document_ProjectExpand>().Where(x => x.ProjectId == ID && x.UnitId == UnitId ).First(); + return ret; + } + + public Document_WinInfo GetDocument_WinInfo(int ID, int UnitId) + { + var ret = _db.Queryable<Document_WinInfo>().Where(x => x.ProjectId == ID && x.UnitId == UnitId ).First(); + return ret; + } + + public Document_AdviseInfo GetDocument_AdviseInfo(int ID, int UnitId) + { + var ret = _db.Queryable<Document_AdviseInfo>().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); + return ret; + } + + public Document_ProjectOppugnInfo GetProjectOppugnInfo(int ID, int UnitId) + { + var ret = _db.Queryable<Document_ProjectOppugnInfo>().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); + return ret; + } + + public Document_ProjectComplainInfo GetProjectComplainInfo(int ID, int UnitId) + { + var ret = _db.Queryable<Document_ProjectComplainInfo>().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); + return ret; + } + + public Document_ProjectReviewInfo GetProjectReviewInfo(int ID, int UnitId) + { + var ret = _db.Queryable<Document_ProjectReviewInfo>().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); + return ret; + } + + public Document_ProjectLitigationInfo GetProjectLitigationInfo(int ID, int UnitId) + { + var ret = _db.Queryable<Document_ProjectLitigationInfo>().Where(x => x.ProjectId == ID && x.UnitId == UnitId).First(); + return ret; + } + + public List<Document_OtherCompanyTenderInfo> GetOtherCompanyTenderInfoList(int ID, int TenantID) + { + var ret = _db.Queryable<Document_OtherCompanyTenderInfo>().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<Document_OtherCompanyTenderInfo>().Where(x => x.TenantID == a.TEID && x.ProjectId == ID && x.CompanyName == companyName).First(); + return ret; + } + + public bool DelOtherCompanyTenderInfo(int Id) + { + + + + _db.Deleteable<Document_OtherCompanyTenderInfo>().Where(new Document_OtherCompanyTenderInfo() { ID = Id }).ExecuteCommand(); + + + + + + return true; + } + + public bool SaveOtherCompanyTenderInfo(Document_OtherCompanyTenderInfo dp) + { + if (dp.ID > 0) + { + _db.Updateable<Document_OtherCompanyTenderInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_OtherCompanyTenderInfo>(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<Document_EmployeeInfo>() + // .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<Document_WinInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_WinInfo>(dp).ExecuteCommand(); + } + + return true; + } + + + public bool SaveDocumentProjectExpand(Document_ProjectExpand dp) + { + if (dp.ID > 0) + { + _db.Updateable<Document_ProjectExpand>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_ProjectExpand>(dp).ExecuteCommand(); + } + + return true; + } + + + public Model.cyDocumentModel.Document_TenderUnit GetTenderUnit(int ID) + { + var ret = _db.Queryable<Model.cyDocumentModel.Document_TenderUnit>().Where(x => x.UnitId == ID).First(); + return ret; + } + + public Document_EmployeeInfo GetDocument_EmployeeInfoByName(string EmployeeName) + { + var a = GetJwtInfo(); + var ret1 = _db.Queryable<EmployeeAtTenant>().Where(x => x.TenantID == a.TEID).Select(x=>x.EmployeeID).ToList(); + + var ret = _db.Queryable<Model.cyDocumentModel.Document_EmployeeInfo>().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<Model.cyDocumentModel.Document_EmployeeInfo>().Where(x => x.EmployeeId == ID).First(); + return ret; + } + + public List<Document_AptitudeInfo> GetAptitudeInfoByUnitId(int UnitId) + { + + var result = _db.Queryable<Document_AptitudeInfo>().Where( x=> x.UnitId == UnitId).ToList() ;//鎵ц鏌ヨ + + return result; + } + + + public bool GetDeleteDocumentModel(int projectId, int unitId) + { + _db.Deleteable<Document_ProjectDocumentInfo>().Where(x=>x.ProjectId == projectId && x.UnitId == unitId).ExecuteCommand(); + + return true; + } + + public Document_ProjectDocumentInfo GetProjectDocumentInfo(int projectId, int unitId) + { + var ret = _db.Queryable<Document_ProjectDocumentInfo>().Where(x => x.ProjectId == projectId && x.UnitId == unitId).First(); + return ret; + } + + + public PageResult<DocumentProjectInfoDTO> 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<DocumentProjectInfoDTO> result = new PageResult<DocumentProjectInfoDTO>(); + + + + result.Items = _db.Queryable<Document_ProjectDocumentInfo, Document_ProjectInfo, Document_ProjectExpand>((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<Document_Dictionary>().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<Document_ProjectDocumentInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_ProjectDocumentInfo>(dp).ExecuteCommand(); + } + + return true; + } + } +} -- Gitblit v1.9.1