username@email.com
2024-07-08 3cf9d2b6664bf83216c25d33f3f2890de6f25443
zhengcaioa/Services/ProjectService.cs
@@ -5,6 +5,7 @@
using AutoMapper;
using CommonToolsCore;
using DTO;
using DTO.WebCrawler;
using IServices;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
@@ -16,10 +17,12 @@
    {
        private readonly zhengcaioaContext _context;
        private readonly IMapper _mapper;
        public ProjectService(zhengcaioaContext context, IMapper mapper)
        private readonly WebCrawlerContext _webcontext;
        public ProjectService(zhengcaioaContext context, IMapper mapper, WebCrawlerContext webcontext)
        {
            _context = context;
            _mapper = mapper;
            _webcontext = webcontext;
        }
        public ResultEntity saveLiaotian(ProjectDTO projectDTO)
@@ -228,7 +231,7 @@
                        }
                    }
                }
                CacheHelperNetCore.CacheNull("Projects");
                //CacheHelperNetCore.CacheNull("Projects");
                _context.SaveChanges();
@@ -345,21 +348,7 @@
            }
            if (!string.IsNullOrWhiteSpace(searchEntity.NamesToubiao))
            {
                sql.Append(" and ( exists (select b.[ProjectId] from [Projectzhongbiao] b  where  a.[Id]=b.[ProjectId] and   b.[names] like '%" + searchEntity.NamesToubiao + "%') ");
                sql.Append("  or exists (select c.[ProjectId] from [Projectreason] c  where  a.[Id]=c.[ProjectId] and   c.[reasonname] like '%" + searchEntity.NamesToubiao + "%') ");
                sql.Append("  or exists (select d.[ProjectId] from [Projectyouxiao] d  where  a.[Id]=d.[ProjectId] and   d.[namesyouxiao] like '%" + searchEntity.NamesToubiao + "%') ");
                sql.Append("  or   a.[drhx] like '%" + searchEntity.NamesToubiao + "%' ");
                sql.Append("   or   a.[dshx] like '%" + searchEntity.NamesToubiao + "%'  ");
                sql.Append(" )");
            }
            if (!string.IsNullOrWhiteSpace(searchEntity.Fencha))
            {
                decimal aaaa = 0;
@@ -612,22 +601,77 @@
            //}
            if (!string.IsNullOrEmpty(searchEntity.Wanshan))
            {
                if (searchEntity.Wanshan == "A")
                {
                    sql.Append(" and ( a.[drhx] is null or exists  ( select b.[Id] from    [CooperatecustomCustomer] b where b.rec_status='A' and a.[drhx] = b.[name] union  select c.[Id] from    [IntentionCustomer] c where c.rec_status='A' and a.[drhx] = c.[name] ) ) ");
                    sql.Append(" and ( a.[dshx] is null or  exists  ( select b.[Id] from    [CooperatecustomCustomer] b where b.rec_status='A' and a.[dshx] = b.[name] union  select c.[Id] from    [IntentionCustomer] c where c.rec_status='A' and a.[dshx] = c.[name] )  ) ");
                    sql.Append(" and  ( a.[caigourenname] is null or  exists  ( select b.[Id] from    [CooperatecustomCustomer] b where b.rec_status='A' and a.[caigourenname] = b.[name] union  select c.[Id] from    [IntentionCustomer] c where c.rec_status='A' and a.[caigourenname] = c.[name] ) )  ");
                    sql.Append(" and ( a.[dailiname] is null or  exists  ( select b.[Id] from    [CooperatecustomCustomer] b where b.rec_status='A' and a.[dailiname] = b.[name] union  select c.[Id] from    [IntentionCustomer] c where c.rec_status='A' and a.[dailiname] = c.[name] ) )  ");
                    sql.Append(" and  (  (select count(b.zhongbiaoId)  from [Projectzhongbiao] b  where  a.[Id]=b.[ProjectId] )  = 0  or    ( (select count(b.zhongbiaoId)  from [Projectzhongbiao] b  where  a.[Id]=b.[ProjectId] ) = ( select count(b.zhongbiaoId) from [Projectzhongbiao] b  where  a.[Id]=b.[ProjectId]    and exists  ( select d.[Id] from    [CooperatecustomCustomer] d where d.rec_status='A' and b.[names] = d.[name] union  select c.[Id] from     [IntentionCustomer] c where c.rec_status='A' and b.[names] = c.[name] )   )))     ");
                    sql.Append(" and  (  (select count(b.youxiaoId)  from [Projectyouxiao] b  where  a.[Id]=b.[ProjectId] )  = 0  or    ( (select count(b.youxiaoId)  from [Projectyouxiao] b  where  a.[Id]=b.[ProjectId] ) = ( select count(b.youxiaoId) from [Projectyouxiao] b  where  a.[Id]=b.[ProjectId]    and exists  ( select d.[Id] from    [CooperatecustomCustomer] d where d.rec_status='A' and b.[namesyouxiao] = d.[name] union  select c.[Id] from     [IntentionCustomer] c where c.rec_status='A' and b.[namesyouxiao] = c.[name] )   )))     ");
                    sql.Append(" and  (  (select count(b.reasonId)  from [Projectreason] b  where  a.[Id]=b.[ProjectId] )  = 0   or    ( (select count(b.reasonId)  from [Projectreason] b  where  a.[Id]=b.[ProjectId] ) = ( select count(b.reasonId) from [Projectreason] b  where  a.[Id]=b.[ProjectId]    and exists  ( select d.[Id] from    [CooperatecustomCustomer] d where d.rec_status='A' and b.[reasonname] = d.[name] union  select c.[Id] from     [IntentionCustomer] c where c.rec_status='A' and b.[reasonname] = c.[name] )   )))     ");
                }
                else
                {
                    sql.Append(" and not  ( ( a.[drhx] is null or exists  ( select b.[Id] from    [CooperatecustomCustomer] b where b.rec_status='A' and a.[drhx] = b.[name] union  select c.[Id] from    [IntentionCustomer] c where c.rec_status='A' and a.[drhx] = c.[name] ) ) ");
                    sql.Append(" and ( a.[dshx] is null or  exists  ( select b.[Id] from    [CooperatecustomCustomer] b where b.rec_status='A' and a.[dshx] = b.[name] union  select c.[Id] from    [IntentionCustomer] c where c.rec_status='A' and a.[dshx] = c.[name] )  ) ");
                    sql.Append(" and  ( a.[caigourenname] is null or  exists  ( select b.[Id] from    [CooperatecustomCustomer] b where b.rec_status='A' and a.[caigourenname] = b.[name] union  select c.[Id] from    [IntentionCustomer] c where c.rec_status='A' and a.[caigourenname] = c.[name] ) )  ");
                    sql.Append(" and ( a.[dailiname] is null or  exists  ( select b.[Id] from    [CooperatecustomCustomer] b where b.rec_status='A' and a.[dailiname] = b.[name] union  select c.[Id] from    [IntentionCustomer] c where c.rec_status='A' and a.[dailiname] = c.[name] ) )  ");
                    sql.Append(" and  (  (select count(b.zhongbiaoId)  from [Projectzhongbiao] b  where  a.[Id]=b.[ProjectId] )  = 0  or    ( (select count(b.zhongbiaoId)  from [Projectzhongbiao] b  where  a.[Id]=b.[ProjectId] ) = ( select count(b.zhongbiaoId) from [Projectzhongbiao] b  where  a.[Id]=b.[ProjectId]    and exists  ( select d.[Id] from    [CooperatecustomCustomer] d where d.rec_status='A' and b.[names] = d.[name] union  select c.[Id] from     [IntentionCustomer] c where c.rec_status='A' and b.[names] = c.[name] )   )))     ");
                    sql.Append(" and  (  (select count(b.youxiaoId)  from [Projectyouxiao] b  where  a.[Id]=b.[ProjectId] )  = 0  or    ( (select count(b.youxiaoId)  from [Projectyouxiao] b  where  a.[Id]=b.[ProjectId] ) = ( select count(b.youxiaoId) from [Projectyouxiao] b  where  a.[Id]=b.[ProjectId]    and exists  ( select d.[Id] from    [CooperatecustomCustomer] d where d.rec_status='A' and b.[namesyouxiao] = d.[name] union  select c.[Id] from     [IntentionCustomer] c where c.rec_status='A' and b.[namesyouxiao] = c.[name] )   )))     ");
                    sql.Append(" and  (  (select count(b.reasonId)  from [Projectreason] b  where  a.[Id]=b.[ProjectId] )  = 0   or    ( (select count(b.reasonId)  from [Projectreason] b  where  a.[Id]=b.[ProjectId] ) = ( select count(b.reasonId) from [Projectreason] b  where  a.[Id]=b.[ProjectId]    and exists  ( select d.[Id] from    [CooperatecustomCustomer] d where d.rec_status='A' and b.[reasonname] = d.[name] union  select c.[Id] from     [IntentionCustomer] c where c.rec_status='A' and b.[reasonname] = c.[name] )   ))) )    ");
                }
            }
            if (!string.IsNullOrWhiteSpace(searchEntity.NamesToubiao))
            {
              var  sqlsss =   sql.ToString();
                sql.Append(" and ( exists (select b.[ProjectId] from [Projectzhongbiao] b  where  a.[Id]=b.[ProjectId] and   b.[names] like '%" + searchEntity.NamesToubiao + "%') ");
                sql.Append("  or exists (select c.[ProjectId] from [Projectreason] c  where  a.[Id]=c.[ProjectId] and   c.[reasonname] like '%" + searchEntity.NamesToubiao + "%') ");
                sql.Append("  or exists (select d.[ProjectId] from [Projectyouxiao] d  where  a.[Id]=d.[ProjectId] and   d.[namesyouxiao] like '%" + searchEntity.NamesToubiao + "%') ");
                sql.Append(" )");
                sql.Append(" union "+ sqlsss + " and (   a.[drhx] like '%" + searchEntity.NamesToubiao + "%' ");
                sql.Append("   or   a.[dshx] like '%" + searchEntity.NamesToubiao + "%'  ");
                sql.Append(" )");
            }
            var query = _context.Projects
           .FromSqlRaw(sql.ToString()).OrderByDescending(x=>x.StartTime)
           .ToList();
           .FromSqlRaw(sql.ToString());
            //if (searchEntity.totalrows == 0)
                searchEntity.totalrows = query.Count();
            var lianlist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
            searchEntity.totalrows = query.Count();
            var lianlist = query.OrderByDescending(x => x.StartTime).Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
            list = _mapper.Map<List<ProjectDTO>>(lianlist);
            var cgfs = GetCgfs();
@@ -823,16 +867,12 @@
        /// <returns></returns>
        public List<ProjectDTO> GetList()
        {
            List<ProjectDTO> projectDTOs = (List<ProjectDTO>)CacheHelperNetCore.CacheValue("Projects");
            if (projectDTOs!=null&& projectDTOs.Count > 0)
            {
                return projectDTOs;
            }
            var listPosition = _context.Projects.Where(r => r.RecStatus == "A").ToList();
           
            var list = _mapper.Map<List<ProjectDTO>>(listPosition);
            CacheHelperNetCore.CacheInsert("Projects", list);
            return list;
        }
@@ -846,6 +886,27 @@
            var list = _mapper.Map<List<ProjectDTO>>(listPosition);
            return list;
        }
        public List<ZhengfuProjectDTO> GetListsalaryzhengfu(string userid, DateTime datemin, DateTime datemax)
        {
            var listPosition = _webcontext.ZhengfuProjects.Where(r => r.RecStatus == "A" && r.Creater == userid && r.Createtime >= datemin && r.Createtime < datemax).ToList();
            var list = _mapper.Map<List<ZhengfuProjectDTO>>(listPosition);
            return list;
        }
        public List<ZhengfuProjectDTO> GetcaigougonggaoListsalary(string userid, DateTime datemin, DateTime datemax)
        {
            var listPosition = _webcontext.ZhengfuProjects.Where(r => r.RecStatus == "A" && r.Creater == userid && r.Createtime >= datemin && r.Createtime < datemax).ToList();
            var list = _mapper.Map<List<ZhengfuProjectDTO>>(listPosition);
            return list;
        }
@@ -1023,5 +1084,377 @@
            return resultEntity;
        }
        public ResultDataEntity<ZhengfuProjectDTO> SearchByPagingCaigougonggao(ZhengfuProjectDTOSearch searchEntity)
        {
            ResultDataEntity<ZhengfuProjectDTO> data = new ResultDataEntity<ZhengfuProjectDTO>();
            List<ZhengfuProjectDTO> list = new List<ZhengfuProjectDTO>();
            var listCode = (from a in _context.SysCodeDtls
                            join b in _context.SysCodes
                            on a.CodeId equals b.Id
                            where a.RecStatus == "A"
                                          && b.RecStatus == "A"
                            select new CodeDataEntity()
                            {
                                CodeId = b.Id,
                                CodeTable = b.CodeTable,
                                CodeField = b.CodeField,
                                CodeSn = a.CodeSn,
                                Comments = a.Comments,
                                Contents = a.Contents,
                                RecStatus = a.RecStatus,
                                Sort = a.Sort
                            }
                      );
            DateTime Createtimestart = DateTime.Now;
            DateTime Createtimeend = DateTime.Now;
            if (!string.IsNullOrWhiteSpace(searchEntity.Createtime))
            {
                string[] Createtimes = searchEntity.Createtime.Split("|");
                DateTime.TryParse(Createtimes[0], out Createtimestart);
                DateTime.TryParse(Createtimes[1], out Createtimeend);
                Createtimeend = Createtimeend.AddDays(1);
            }
            DateTime StartTimestart = DateTime.Now;
            DateTime StartTimeeend = DateTime.Now;
            if (!string.IsNullOrWhiteSpace(searchEntity.StartTime))
            {
                string[] StartTimes = searchEntity.StartTime.Split("|");
                DateTime.TryParse(StartTimes[0], out StartTimestart);
                DateTime.TryParse(StartTimes[1], out StartTimeeend);
                StartTimeeend = StartTimeeend.AddDays(1);
            }
            var query = (from a in _webcontext.ZhengfuProjects
                         where a.RecStatus == "A"
                          && (string.IsNullOrWhiteSpace(searchEntity.Createtime) || (a.Createtime >= Createtimestart && a.Createtime <= Createtimeend))
                            && (string.IsNullOrWhiteSpace(searchEntity.StartTime) || (a.NoticeTime >= StartTimestart && a.NoticeTime <= StartTimeeend))
                         && (string.IsNullOrWhiteSpace(searchEntity.Name) || a.Title.Contains(searchEntity.Name.Trim()))
                           && (string.IsNullOrWhiteSpace(searchEntity.Number) || a.OpenTenderCode.Contains(searchEntity.Number.Trim()))
                          && (string.IsNullOrWhiteSpace(searchEntity.Sheng) || a.Sheng == searchEntity.Sheng.Trim())
                           && (string.IsNullOrWhiteSpace(searchEntity.City) || a.City == searchEntity.City.Trim())
                            && (string.IsNullOrWhiteSpace(searchEntity.AreaId) || a.RegionCode == searchEntity.AreaId.Trim())
                             && (string.IsNullOrWhiteSpace(searchEntity.Cgfs) || a.Cgfs == searchEntity.Cgfs.Trim())
                                 && (string.IsNullOrWhiteSpace(searchEntity.Gglx) || a.Gglx == searchEntity.Gglx.Trim())
                                   && (string.IsNullOrWhiteSpace(searchEntity.Creater) || a.Creater == searchEntity.Creater.Trim())
                         select a
                        );
            //if (searchEntity.totalrows == 0)
            searchEntity.totalrows = query.Count();
            var lianlist = query.OrderByDescending(x => x.NoticeTime).Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
            var querytrsult = _mapper.Map<List<ZhengfuProjectDTO>>(lianlist);
            //var querytrsult = (  from a in lianlist
            //               //      join f in _context.Areas on a.Sheng equals f.CodeId
            //               //into fsss
            //               //      from fff in fsss.DefaultIfEmpty()
            //                     //join g in _context.Areas on a.City equals g.CodeId
            //                     //   into gsss
            //                     //from ggg in gsss.DefaultIfEmpty()
            //                     //join h in _context.Areas on a.RegionCode equals h.CodeId
            //                     //   into hsss
            //                     //from hhh in hsss.DefaultIfEmpty()
            //            //         join b in listCode.Where(x => x.CodeTable == "zhengfu_Project" && x.CodeField == "cgfs")
            //            //on a.Cgfs equals b.CodeSn
            //            //into bsss
            //            //         from bbb in bsss.DefaultIfEmpty()
            //                     //join c in listCode.Where(x => x.CodeTable == "zhengfu_Project" && x.CodeField == "gglx")
            //                     //on a.Gglx equals c.CodeSn
            //                     // into csss
            //                     //from ccc in csss.DefaultIfEmpty()
            //             //        join e in _context.PltUsers
            //             //on a.Creater equals e.Id
            //             //into esss
            //             //        from abi in esss.DefaultIfEmpty()
            //                     select new ZhengfuProjectDTO
            //                     {
            //                         Id = a.Id,
            //                         NoticeTime = a.NoticeTime,
            //                         NoticeTimeName = a.NoticeTime.ToString("yyyy-MM-dd"),
            //                         Sheng = a.Sheng,
            //                         City = a.City,
            //                         RegionCode = a.RegionCode,
            //                         /*ShengName = fff.Name + "-" + ggg.Name + "-" + hhh.Name,*/
            //                         Cgfs = a.Cgfs,
            //                         //CgfsName = bbb.Comments,
            //                         Gglx = a.Gglx,
            //                         //GglxName = ccc.Comments,
            //                         OpenTenderCode = a.OpenTenderCode,
            //                         Title = a.Title,
            //                         Shorttitle = a.Shorttitle,
            //                         Pageurl = a.Pageurl,
            //                         Remark = a.Remark,
            //                         RecStatus = a.RecStatus,
            //                         Creater = a.Creater,
            //                         //CreaterName = abi.UserName,
            //                         Createtime = a.Createtime,
            //                         Modifier = a.Modifier,
            //                         Modifytime = a.Modifytime,
            //                         Content = a.Content,
            //                         Pingmu = a.Pingmu,
            //                         Purchaser = a.Purchaser,
            //                         Budget = a.Budget,
            //                         Agency = a.Agency,
            //                         AgencyCode = a.AgencyCode,
            //                     }
            //     ).OrderByDescending(x => x.NoticeTime).ToList();
            foreach ( var zhengfuProjectDTO   in querytrsult)
            {
                if (zhengfuProjectDTO.Creater != "1")
                {
                 var pltUser   =   _context.PltUsers.Where(x=>x.Id == zhengfuProjectDTO.Creater).FirstOrDefault();
                    if (pltUser != null)
                    {
                        zhengfuProjectDTO.CreaterName = pltUser.UserName;
                    }
                }
                if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.Cgfs))
                {
                    var codeDataEntity = listCode.Where(x => x.CodeTable == "zhengfu_Project" && x.CodeField == "cgfs").Where(x => x.CodeSn == zhengfuProjectDTO.Cgfs).FirstOrDefault();
                    if (codeDataEntity != null)
                    {
                        zhengfuProjectDTO.CgfsName = codeDataEntity.Comments;
                    }
                }
                if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.Gglx))
                {
                    var codeDataEntity = listCode.Where(x => x.CodeTable == "zhengfu_Project" && x.CodeField == "gglx").Where(x => x.CodeSn == zhengfuProjectDTO.Gglx).FirstOrDefault();
                    if (codeDataEntity != null)
                    {
                        zhengfuProjectDTO.GglxName = codeDataEntity.Comments;
                    }
                }
                if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.Sheng))
                {
                    var area1 = _context.Areas.Where(x => x.CodeId == zhengfuProjectDTO.Sheng).FirstOrDefault();
                    if (area1 != null)
                    {
                        zhengfuProjectDTO.ShengName  =   area1.Name;
                    }
                }
                if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.City))
                {
                    var area = _context.Areas.Where(x => x.CodeId == zhengfuProjectDTO.City).FirstOrDefault();
                    if (area != null)
                    {
                        zhengfuProjectDTO.ShengName += "-" + area.Name;
                    }
                    if (!string.IsNullOrWhiteSpace(zhengfuProjectDTO.RegionCode))
                    {
                        var area1 = _context.Areas.Where(x => x.CodeId == zhengfuProjectDTO.RegionCode).FirstOrDefault();
                        if (area1 != null)
                        {
                            zhengfuProjectDTO.ShengName += "-" + area1.Name;
                        }
                    }
                }
            }
            data.LoadData(searchEntity, querytrsult);
            return data;
        }
        public ZhengfuProjectDTO GetZhengfuProjectDTO(string id)
        {
            var entity = _webcontext.ZhengfuProjects.Find(id);
            if (entity.RecStatus != "A")
            {
                entity = new ZhengfuProject();
            }
            var zhengfuProjectDTO = _mapper.Map<ZhengfuProjectDTO>(entity);
            return zhengfuProjectDTO;
        }
        public ResultEntity saveZhengfuProjectDTO(ZhengfuProjectDTO dTO)
        {
            ResultEntity resultEntity = new ResultEntity();
            try
            {
                var checkUserSn = _webcontext.ZhengfuProjects.Where(x => x.Pageurl == dTO.Pageurl && x.RecStatus == "A" && x.Id != dTO.Id).FirstOrDefault();
                if (checkUserSn != null && (string.IsNullOrWhiteSpace(dTO.Id) || (!string.IsNullOrWhiteSpace(dTO.Id) && checkUserSn.Id != dTO.Id)))
                {
                    resultEntity.Result = false;
                    resultEntity.Message = "该页面已经保存";
                    return resultEntity;
                }
                var checkUserSnss = _webcontext.ZhengfuProjects.Where(x => x.Title == dTO.Title && x.RecStatus == "A" && x.Id != dTO.Id && x.NoticeTime > dTO.NoticeTime.AddDays(-1) && x.NoticeTime < dTO.NoticeTime.AddDays(1)).FirstOrDefault();
                if (checkUserSnss != null && (string.IsNullOrWhiteSpace(dTO.Id) || (!string.IsNullOrWhiteSpace(dTO.Id) && checkUserSnss.Id != dTO.Id)))
                {
                    resultEntity.Result = false;
                    resultEntity.Message = "该页面已经保存";
                    return resultEntity;
                }
                var zhengfuProject = _mapper.Map<ZhengfuProject>(dTO);
                if (String.IsNullOrEmpty(zhengfuProject.Id))
                {
                    zhengfuProject.Id = Guid.NewGuid().ToString();
                    dTO.Id = zhengfuProject.Id;
                    _webcontext.ZhengfuProjects.Add(zhengfuProject);
                }
                else
                {
                    var updateproject = _webcontext.ZhengfuProjects.Find(dTO.Id);
                    updateproject.NoticeTime = dTO.NoticeTime;
                    updateproject.Sheng = dTO.Sheng;
                    updateproject.City = dTO.City;
                    updateproject.RegionCode = dTO.RegionCode;
                    updateproject.Cgfs = dTO.Cgfs;
                    updateproject.Gglx = dTO.Gglx;
                    updateproject.OpenTenderCode = dTO.OpenTenderCode;
                    updateproject.Title = dTO.Title;
                    updateproject.Shorttitle = dTO.Shorttitle;
                    updateproject.Pageurl = dTO.Pageurl;
                    updateproject.Remark = dTO.Remark;
                    updateproject.Content = dTO.Content;
                    updateproject.Pingmu = dTO.Pingmu;
                    updateproject.Purchaser = dTO.Purchaser;
                    updateproject.Budget = dTO.Budget;
                    updateproject.Agency = dTO.Agency;
                    updateproject.AgencyCode = dTO.AgencyCode;
                    updateproject.OpenTenderTime = dTO.OpenTenderTime;
                    updateproject.RecStatus = dTO.RecStatus;
                    updateproject.Modifier = dTO.Modifier;
                    updateproject.Modifytime = dTO.Modifytime;
                }
                _webcontext.SaveChanges();
                resultEntity.ReturnID = dTO.Id;
                resultEntity.Result = true;
            }
            catch (Exception ex)
            {
                resultEntity.Result = false;
                resultEntity.Message = "保存失败,请联系管理员";
            }
            return resultEntity;
        }
        public ResultEntity GetZhengfuProjectDTOByPageurl(string Pageurl, string Id)
        {
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = true;
            var checkUserSn = _webcontext.ZhengfuProjects.Where(x => x.Pageurl == Pageurl && x.RecStatus == "A" && x.Id != Id).FirstOrDefault();
            if (checkUserSn != null && (string.IsNullOrWhiteSpace(Id) || (!string.IsNullOrWhiteSpace(Id) && checkUserSn.Id != Id)))
            {
                resultEntity.Result = false;
                resultEntity.Message = "该页面已经存在";
            }
            return resultEntity;
        }
        public ResultEntity GetZhengfuProjectDTOByTitle(string Title, string Id, DateTime? NoticeTime)
        {
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = true;
            if(!string.IsNullOrWhiteSpace(Title) && NoticeTime.HasValue)
            {
                var checkUserSn = _webcontext.ZhengfuProjects.Where(x => x.Title == Title && x.RecStatus == "A" && x.Id != Id && x.NoticeTime >= NoticeTime.Value.AddDays(-1) && x.NoticeTime <= NoticeTime.Value.AddDays(1)).FirstOrDefault();
                if (checkUserSn != null && (string.IsNullOrWhiteSpace(Id) || (!string.IsNullOrWhiteSpace(Id) && checkUserSn.Id != Id)))
                {
                    resultEntity.Result = false;
                    resultEntity.Message = "该页面已经存在";
                }
            }
            return resultEntity;
        }
        public ResultEntity saveProjectfasongxiaoxi(Projectfasongxiaoxi project)
        {
            ResultEntity resultEntity = new ResultEntity();
            try
            {
                project.Id = Guid.NewGuid().ToString();
                _context.Projectfasongxiaoxis.Add(project);
                _context.SaveChanges();
                resultEntity.ReturnID = project.Id;
                resultEntity.Result = true;
            }
            catch (Exception ex)
            {
                resultEntity.Result = false;
                resultEntity.Message = "保存失败,请联系管理员";
            }
            return resultEntity;
        }
    }
}