From 9b79040354b59f3182cd90f7157e682d65310712 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期二, 29 八月 2023 09:20:15 +0800
Subject: [PATCH] 后端

---
 DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs |  562 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 558 insertions(+), 4 deletions(-)

diff --git a/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs b/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs
index 6badc72..85207de 100644
--- a/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs
+++ b/DocumentServiceAPI.Application/ProjectInfo/Services/ProjectInfoService.cs
@@ -24,6 +24,7 @@
 using SqlSugar.Extensions;
 using System;
 using System.Collections.Generic;
+using System.Data;
 using System.Diagnostics.Metrics;
 using System.Linq;
 using System.Reflection.Metadata;
@@ -818,11 +819,11 @@
 
                     if (documentProjectInfoDTO.IsAdvise == 1)
                     {
-                        documentProjectInfoDTO.Advise = "鈭�";
+                        documentProjectInfoDTO.Advise = "鏂规淇濆瓨";// "鈭�";
                     }
                     else
                     {
-                        documentProjectInfoDTO.Advise = "";
+                        documentProjectInfoDTO.Advise = "鏂规淇濆瓨";
                     }
 
                     if (!string.IsNullOrEmpty(documentProjectInfoDTO.FilePathzy))
@@ -957,7 +958,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 +1104,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 +1265,54 @@
         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).ToList() ;//鎵ц鏌ヨ
 
-            return result;
+            var ids = result.Select(x => x.id).ToArray();
+            var file = _db.Queryable<File_Info>().Where(x => ids.Contains(x.doc_id)).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).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 = 1;
+                document_AptitudeInfo.UserId = doc_Info.tenant_code;
+
+                document_AptitudeInfos.Add(document_AptitudeInfo);
+            }
+
+
+            return document_AptitudeInfos;
         }
 
 
@@ -1231,5 +1432,358 @@
 
             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 result = _db.Queryable<Document_DocumentTempletInfo>().Where(x => x.IsUsed == 1).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<Document_TBXYFile> 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<Document_TBXYFile> result = new PageResult<Document_TBXYFile>();
+
+
+
+            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))
+
+             .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,
+
+             }
+              )
+             .OrderBy(a => a.Sort).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_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,
+
+                }).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;
+        }
+
     }
 }

--
Gitblit v1.9.1