From 90858c80d9921b555119f41060c1f883f6e6ffc5 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期四, 26 十二月 2024 12:49:35 +0800 Subject: [PATCH] 提交 --- DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs | 1338 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1,320 insertions(+), 18 deletions(-) diff --git a/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs b/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs index 6badc72..b54d682 100644 --- a/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs +++ b/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs @@ -1,5 +1,6 @@ 锘縰sing 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; @@ -24,8 +25,10 @@ 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; @@ -115,7 +118,7 @@ document_ProjectInfo.ProjectUrl = dp.ProjectUrl; var parser = new HtmlParser(); var list11 = new List<AngleSharp.Dom.IElement>(); - if (url.StartsWith("http://www.ccgp.gov.cn")) + if (url.StartsWith("http://www.ccgp.gov.cn")|| url.StartsWith("https://www.ccgp.gov.cn")) { using (HttpClient client = new HttpClient()) { @@ -141,29 +144,49 @@ } } document_ProjectInfo.PurchaseMethod = 0; - if (document_ProjectInfo.ProjectName.IndexOf("鍏紑鎷涙爣")>=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"); @@ -335,9 +358,35 @@ if (DateTime.TryParse(TenderTimes, out b)) { document_ProjectInfo.TenderTime = b; - document_ProjectInfo.SignupStartTime = b; - document_ProjectInfo.SignupEndTime = 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; + } + } + @@ -345,25 +394,43 @@ 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" && @@ -386,9 +453,77 @@ } - + + 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) { @@ -473,22 +608,42 @@ 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("鍏憡", ""); } @@ -613,8 +768,8 @@ //page.ToEmployeeId = a.EID; int total = 0; PageResult<DocumentProjectInfoDTO> result = new PageResult<DocumentProjectInfoDTO>(); - + //var document_OtherCompanyTenderInfos = _db.Queryable<Document_OtherCompanyTenderInfo>().Where(x => x.TenantID == aaa.TEID).ToList(); 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 @@ -664,11 +819,11 @@ .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 == 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) => (d.BidbondStatus == null)) + .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)) @@ -691,6 +846,9 @@ //璇夎鎯呭喌 .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<Document_OtherCompanyTenderInfo>().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, @@ -718,7 +876,9 @@ NoticeTypeName = "鎷涙爣鍏憡", NoticeType = a.NoticeType, PurchaseMethod = a.PurchaseMethod, - DocumentStatus = d.DocumentStatus + DocumentStatus = d.DocumentStatus, + SignupMethod = a.SignupMethod, + } ) .OrderByDescending(a => a.ProjectId).ToPageList(page.PageIndex, page.PageSize, ref total); @@ -745,7 +905,7 @@ documentProjectInfoDTO.xmqy = documentProjectInfoDTO.City+ documentProjectInfoDTO.County; } - if(documentProjectInfoDTO.IsSignup == 1) + if(documentProjectInfoDTO.IsSignup == 1 || documentProjectInfoDTO.SignupMethod == 9 ) { documentProjectInfoDTO.bm = "鈭�"; } @@ -818,11 +978,11 @@ if (documentProjectInfoDTO.IsAdvise == 1) { - documentProjectInfoDTO.Advise = "鈭�"; + documentProjectInfoDTO.Advise = "鏂规淇濆瓨";// "鈭�"; } else { - documentProjectInfoDTO.Advise = ""; + documentProjectInfoDTO.Advise = "鏂规淇濆瓨"; } if (!string.IsNullOrEmpty(documentProjectInfoDTO.FilePathzy)) @@ -870,7 +1030,18 @@ documentProjectInfoDTO.PurchaseMethodName = document_Dictionary.Name; } } - + + var sss = _db.Queryable<Document_ZhaobiaoFile>().Count(x => x.ProjectId == documentProjectInfoDTO.ProjectId && x.UnitId == page.UnitId); + if (sss > 0) + { + documentProjectInfoDTO.zbwj = "鈭�"; + } + else + { + documentProjectInfoDTO.zbwj = "鎷涙爣鏂囦欢"; + } + + } } @@ -957,7 +1128,117 @@ public Document_WinInfo GetDocument_WinInfo(int ID, int UnitId) { + var aaa = GetJwtInfo(); var ret = _db.Queryable<Document_WinInfo>().Where(x => x.ProjectId == ID && x.UnitId == UnitId ).First(); + if (ret == null || string.IsNullOrEmpty(ret.FirstWinCompany)) + { + + var projectInfo = _db.Queryable<Document_ProjectInfo>().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; } @@ -993,7 +1274,52 @@ public List<Document_OtherCompanyTenderInfo> GetOtherCompanyTenderInfoList(int ID, int TenantID) { + var aaa = GetJwtInfo(); + var ret = _db.Queryable<Document_OtherCompanyTenderInfo>().Where(x => x.ProjectId == ID && x.TenantID == TenantID).ToList(); + if (ret == null || ret.Count==0) + { + + var projectInfo = _db.Queryable<Document_ProjectInfo>().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<Document_OtherCompanyTenderInfo>(); + 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) @@ -1109,9 +1435,220 @@ public List<Document_AptitudeInfo> GetAptitudeInfoByUnitId(int UnitId) { - var result = _db.Queryable<Document_AptitudeInfo>().Where( x=> x.UnitId == UnitId).ToList() ;//鎵ц鏌ヨ + var result = _db.Queryable<Doc_Info>().Where( x=>x.is_del == false && x.org_id == UnitId && x.zige_code > 0).OrderBy(x=>x.doc_code).OrderBy(x=>x.sort).ToList() ;//鎵ц鏌ヨ - return result; + var ids = result.Select(x => x.id).ToArray(); + var file = _db.Queryable<File_Info>().Where(x => ids.Contains(x.doc_id) && x.status ==1 ).ToList();//鎵ц鏌ヨ + var document_AptitudeInfos = new List<Document_AptitudeInfo>(); + + 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<Doc_Achievement>().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<Doc_Shebeinengli>().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; } @@ -1231,5 +1768,770 @@ return true; } + + + public Document_DelegatePersonInfo GetDelegatePersonInfo(int ID) + { + var ret = _db.Queryable<Document_DelegatePersonInfo>().Where(x => x.DelegateId == ID).First(); + return ret; + } + + public bool SaveDocumentProjectOppugnInfo(Document_ProjectOppugnInfo dp) + { + if (dp.ID > 0) + { + _db.Updateable<Document_ProjectOppugnInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_ProjectOppugnInfo>(dp).ExecuteCommand(); + } + + return true; + } + + public List<Document_DelegatePersonInfo> GetAllDelegatePerson() + { + var a = GetJwtInfo(); + + var result = _db.Queryable<Document_DelegatePersonInfo>().Where(x => x.IsUse == 1 && x.TenantID == a.TEID ).ToList();//鎵ц鏌ヨ + return result; + + } + + public bool SaveDocumentProjectComplainInfo(Document_ProjectComplainInfo dp) + { + if (dp.ID > 0) + { + _db.Updateable<Document_ProjectComplainInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_ProjectComplainInfo>(dp).ExecuteCommand(); + } + + return true; + } + + public bool SaveDocumentProjectReviewInfo(Document_ProjectReviewInfo dp) + { + if (dp.ID > 0) + { + _db.Updateable<Document_ProjectReviewInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_ProjectReviewInfo>(dp).ExecuteCommand(); + } + + return true; + } + + public string GetPreUnit(string childName) + { + + string preUnit = ""; + Sys_CitySite preModel = null; + var m_Sys_CitySite = _db.Queryable<Sys_CitySite>().Where(x => x.Name == childName).First();//鎵ц鏌ヨ + if (m_Sys_CitySite != null) + { + if (m_Sys_CitySite.CityLevel == 3) + { + preModel = _db.Queryable<Sys_CitySite>().Where(x=>x.Keyid == m_Sys_CitySite.CityId).First(); + } + else if (m_Sys_CitySite.CityLevel == 2) + { + preModel = _db.Queryable<Sys_CitySite>().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<Document_ProjectLitigationInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_ProjectLitigationInfo>(dp).ExecuteCommand(); + } + + return true; + } + + + public bool SaveDocumentAdviseInfo(Document_AdviseInfo dp) + { + { + if (dp.Id > 0) + { + _db.Updateable<Document_AdviseInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_AdviseInfo>(dp).ExecuteCommand(); + } + + return true; + } + } + + public Document_DocumentTempletInfo GetTempletModel(int templetId) + { + var ret = _db.Queryable<Document_DocumentTempletInfo>().Where(x => x.TempletId == templetId).First(); + return ret; + } + + public List<Document_DocumentTempletInfo> GetDocumentTempletList() + { + var aaa = GetJwtInfo(); + var result = _db.Queryable<Document_DocumentTempletInfo>().Where(x => x.IsUsed == 1 && x.UnitId == aaa.UID).OrderByDescending(x=>x.LastUpdateTime).ToList();//鎵ц鏌ヨ + return result; + } + + + + + public PageResult<Document_ZhaobiaoFile> 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<Document_ZhaobiaoFile> result = new PageResult<Document_ZhaobiaoFile>(); + + + + result.Items = _db.Queryable<Document_ZhaobiaoFile>() + .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<Document_ZhaobiaoFile>().Where(x => x.Id == ID).First();//鎵ц鏌ヨ + return result; + } + + + public bool GetDeleteDocumentZhaobiaoFile(int ID) + { + _db.Deleteable<Document_ZhaobiaoFile>().Where(x => x.Id == ID).ExecuteCommand(); + + return true; + } + + public bool SaveDocumentZhaobiaoFileInfo(Document_ZhaobiaoFile dp) + { + if (dp.Id > 0) + { + _db.Updateable<Document_ZhaobiaoFile>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_ZhaobiaoFile>(dp).ExecuteCommand(); + } + + return true; + } + + + + public PageResult<DocumentTBXYFileDTO> 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<DocumentTBXYFileDTO> result = new PageResult<DocumentTBXYFileDTO>(); + + + + result.Items = _db.Queryable<Document_TBXYFile>() + .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<Doc_Classification>().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<Document_TBXYFile>().Where(x => x.Id == ID).First();//鎵ц鏌ヨ + return result; + } + + + public bool GetDeleteDocumentTBXYFile(int ID) + { + + _db.Deleteable<Document_TBXYFile>().Where(x => x.Id == ID).ExecuteCommand(); + + return true; + } + + public bool SaveDocumentTBXYFileInfo(Document_TBXYFile dp) + { + + + + var result = _db.Queryable<Document_ProjectDocumentInfo>().Where(x => x.ProjectId == dp.ProjectId && x.UnitId == dp.UnitId).First();//鎵ц鏌ヨ + if (result != null) + { + result.LastUpdateTime = dp.LastUpdateTime; + _db.Updateable<Document_ProjectDocumentInfo>(result).ExecuteCommand(); + } + if (dp.Id > 0) + { + _db.Updateable<Document_TBXYFile>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_TBXYFile>(dp).ExecuteCommand(); + } + + return true; + } + + + public List<Document_TBXYFile> GetDocumentTBXYFileList(int projectId, int unitId) + { + var ret = _db.Queryable<Document_TBXYFile>() + .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<Document_TBXYFile>().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<Doc_Info>(dp).ExecuteCommand(); + } + else + { + dp.id = _db.Insertable<Doc_Info>(dp).ExecuteReturnIdentity(); + } + + return dp.id; + } + + public bool SaveFileInfo(File_Info dp) + { + if (dp.id > 0) + { + _db.Updateable<File_Info>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<File_Info>(dp).ExecuteCommand(); + } + + return true; + } + + + public List<Doc_Classification> GetDocClassificationList() + { + var ret = _db.Queryable<Doc_Classification>().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<Document_TBXYFile>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_TBXYFile>(dp).ExecuteCommand(); + } + + return true; + } + + + + + + + + public PageResult<DocClassificationDTO> 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<DocClassificationDTO> result = new PageResult<DocClassificationDTO>(); + + + + result.Items = _db.Queryable<Doc_Classification, Doc_ClassDel>((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<Doc_ClassDel>().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<Doc_Classification>().Where(x => x.id == ID).First();//鎵ц鏌ヨ + if (result!=null && result.is_system) + { + var doc_ClassDel = _db.Queryable<Doc_ClassDel>().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<Doc_ClassDel>().Where(x => x.doc_classification_id == ID && x.tenant_code == tenantId ).ExecuteCommand(); + + return true; + } + + + public bool GetDeleteDocClassification(int ID ) + { + var result = _db.Queryable<Doc_Classification>().Where(x => x.id == ID).First();//鎵ц鏌ヨ + if (result != null) + { + _db.Deleteable<Doc_Classification>().Where(x => x.parent_code == result.doc_classification_code).ExecuteCommand(); + } + + _db.Deleteable<Doc_Classification>().Where(x => x.id == ID ).ExecuteCommand(); + + return true; + } + + public bool SaveDocClassificationInfo(Doc_Classification dp) + { + + + + + + if (dp.id > 0) + { + _db.Updateable<Doc_Classification>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Doc_Classification>(dp).ExecuteCommand(); + } + + return true; + } + + public bool SaveDocClassDelInfo(Doc_ClassDel dp) + { + + if (dp.id > 0) + { + _db.Updateable<Doc_ClassDel>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Doc_ClassDel>(dp).ExecuteCommand(); + } + return true; + } + + + public List<Doc_Classification> GetDocClassificationList(int tenantId) + { + var ret = _db.Queryable<Doc_Classification>() + .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<Doc_ClassDel>().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<Doc_Classification>().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<Doc_Classification>().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<Doc_Classification>() + .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<Doc_Info>() + .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<Doc_Achievement>() + .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<Doc_Shebeinengli>() + .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<Document_DocumentTempletInfoDTO> 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<Document_DocumentTempletInfoDTO> result = new PageResult<Document_DocumentTempletInfoDTO>(); + + + + var document_DocumentTempletInfos = _db.Queryable<Document_DocumentTempletInfo> () + .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<List<Document_DocumentTempletInfoDTO>>(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<Document_DocumentTempletInfo>().Where(x => x.TempletId == ID ).ExecuteCommand(); + + return true; + } + + + public bool SaveDocumentTempletInfo(Document_DocumentTempletInfo dp) + { + if (dp.TempletId > 0) + { + _db.Updateable<Document_DocumentTempletInfo>(dp).ExecuteCommand(); + } + else + { + _db.Insertable<Document_DocumentTempletInfo>(dp).ExecuteCommand(); + } + return true; + } + + + public Document_DocumentTempletInfo GetTempletModelByProjectId(int projiectid) + { + + var aaa = GetJwtInfo(); + var ret = _db.Queryable<Document_DocumentTempletInfo>().Where(x => x.ProjectId == projiectid && x.UnitId == aaa.UID ).First(); + return ret; + } } } -- Gitblit v1.9.1