diff --git a/20220330_Vote/Ewide.Web.Entry/Ewide.Web.Entry.csproj b/20220330_Vote/Ewide.Web.Entry/Ewide.Web.Entry.csproj index c70479c..a9e17b4 100644 --- a/20220330_Vote/Ewide.Web.Entry/Ewide.Web.Entry.csproj +++ b/20220330_Vote/Ewide.Web.Entry/Ewide.Web.Entry.csproj @@ -642,6 +642,15 @@ Always + + Always + + + Always + + + Always + Always diff --git a/20220330_Vote/Ewide.Web.Entry/wwwroot/ExcelTemplate/票1 免于现场评估项目汇总表投票表格.xlsx b/20220330_Vote/Ewide.Web.Entry/wwwroot/ExcelTemplate/票1 免于现场评估项目汇总表投票表格.xlsx new file mode 100644 index 0000000..e36454c Binary files /dev/null and b/20220330_Vote/Ewide.Web.Entry/wwwroot/ExcelTemplate/票1 免于现场评估项目汇总表投票表格.xlsx differ diff --git a/20220330_Vote/Ewide.Web.Entry/wwwroot/ExcelTemplate/票2 现场评估项目(含)现场投票表格.xlsx b/20220330_Vote/Ewide.Web.Entry/wwwroot/ExcelTemplate/票2 现场评估项目(含)现场投票表格.xlsx new file mode 100644 index 0000000..f247096 Binary files /dev/null and b/20220330_Vote/Ewide.Web.Entry/wwwroot/ExcelTemplate/票2 现场评估项目(含)现场投票表格.xlsx differ diff --git a/20220330_Vote/Ewide.Web.Entry/wwwroot/html/Manage/Login.html b/20220330_Vote/Ewide.Web.Entry/wwwroot/html/Manage/Login.html index 7f3cbd3..dd49c0b 100644 --- a/20220330_Vote/Ewide.Web.Entry/wwwroot/html/Manage/Login.html +++ b/20220330_Vote/Ewide.Web.Entry/wwwroot/html/Manage/Login.html @@ -106,7 +106,7 @@ //location = '/gb/yjb/manage/VoteResult' //location = '/gb/yjb/manage/nbczResult' //location = '/202307/html/outsidewall/result.html' - location = '../yjbvote/voteresult.html'; + location = '../yjbvote2025/voteresult.html'; } } _this.loading = false; diff --git a/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/Expert.html b/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/Expert.html new file mode 100644 index 0000000..cd179a3 --- /dev/null +++ b/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/Expert.html @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + +
+

专家选票结果

+ + + + + + + +

+ 刷新数据 + 查看项目投票情况 + 新增专家 +

+ +
+ + 确定 +
+
+ + + +
+ + + + + \ No newline at end of file diff --git a/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/VoteResult.html b/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/VoteResult.html new file mode 100644 index 0000000..4fd00e0 --- /dev/null +++ b/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/VoteResult.html @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + +
+

2024年度宁波市市级优质工程免于现场评估项目选票结果

+ + + + + + + + + + + + + +

+ 刷新数据 + 导出Excel + 查看专家投票情况 +

+ +

2024年度宁波市市级优质工程现场评估项目选票结果

+ + + + + + + + + + + +

+ 刷新数据 + 导出Excel + 查看专家投票情况 +

+ +
+ + + + + \ No newline at end of file diff --git a/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/index.html b/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/index.html new file mode 100644 index 0000000..8981c57 --- /dev/null +++ b/20220330_Vote/Ewide.Web.Entry/wwwroot/html/yjbvote2025/index.html @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + +
+

2024年度宁波市市级优质工程免于现场评估项目

+ + + + {{project.serial_number}}:{{project.name}} + + + + + + +

2024年度宁波市市级优质工程现场评估项目

+ + + + {{project.serial_number}}:{{project.name}} + + + + + + +

+ +

+

+ 重置 + 提交 +

+
+ + + + + \ No newline at end of file diff --git a/20220330_Vote/Vote.Services/ApiController/Projects2025Service.cs b/20220330_Vote/Vote.Services/ApiController/Projects2025Service.cs new file mode 100644 index 0000000..a413577 --- /dev/null +++ b/20220330_Vote/Vote.Services/ApiController/Projects2025Service.cs @@ -0,0 +1,270 @@ +using COSXML.Model.Tag; +using Ewide.Core.Util; +using Furion.DatabaseAccessor; +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Vote.Services.Dto; +using Vote.Services.Entities; +using static Vote.Services.Dto.ProjectsList2Output; + +namespace Vote.Services.ApiController +{ + /// + /// 项目 + /// + [ApiDescriptionSettings("Vote", Order = 0)] + [Route("/gb/yjb/api/projects2025")] + public class Projects2025Service : IDynamicApiController + { + //private readonly IRepository rep_Projects; + private readonly IRepository rep_Projects2025; + private readonly IRepository rep_Experts; + private readonly IRepository rep_VoteRecords; + private readonly IRepository rep_Projects2021; + private readonly IRepository rep_VoteRecords2021; + private readonly IRepository rep_Projects2022; + private readonly IRepository rep_VoteRecords2022; + public Projects2025Service( + IRepository _rep_Projects, + IRepository _rep_Experts, + IRepository _rep_VoteRecords, + IRepository _rep_Projects2021, + IRepository _rep_VoteRecords2021, + IRepository _rep_Projects2022, + IRepository _rep_VoteRecords2022, + IRepository _rep_Projects2025) + { + //rep_Projects = _rep_Projects; + rep_Experts = _rep_Experts; + rep_VoteRecords = _rep_VoteRecords; + rep_Projects2021 = _rep_Projects2021; + rep_VoteRecords2021 = _rep_VoteRecords2021; + rep_Projects2022 = _rep_Projects2022; + rep_VoteRecords2022 = _rep_VoteRecords2022; + rep_Projects2025 = _rep_Projects2025; + } + + /// + /// 列表 + /// + /// + [HttpPost] + [Microsoft.AspNetCore.Authorization.AllowAnonymous] + public async Task List(ProjectsInput args) + { + var typeList = new List { "房建工程", "市政工程", "轨道交通工程", "能源工程", "交通工程", "水利工程" }; + var data = await rep_Projects2025.DetachedEntities.Where(p => !p.IsDeleted) + .Where(args.type != null, a => (int)a.type == args.type) + .Where(args.is_no_inspection != null, a => (int)a.is_no_inspection == args.is_no_inspection) + .ProjectToType() + .OrderBy(a => a.serial_number) + .ToListAsync(); + var data1 = data.Where(a => a.is_no_inspection == 1).ToList(); + var data2 = data.Where(a => a.is_no_inspection == 0).ToList(); + return new + { + typeList, + data1, + data2 + }; + } + + /// + /// 检验提交码 + /// + /// + [HttpPost] + [Microsoft.AspNetCore.Authorization.AllowAnonymous] + public async Task CheckSubmitCode(CheckSubmitCodeInput args) + { + var data = await rep_Experts.DetachedEntities.Where(p => !p.IsDeleted) + .Where(a => a.login_code == args.code) + .FirstOrDefaultAsync(); + return data != null; + } + + + /// + /// 提交 + /// + /// + [HttpPost] + [UnitOfWork] + [Microsoft.AspNetCore.Authorization.AllowAnonymous] + public async Task SubmitSubmitVote(SubmitInput args) + { + try + { + var data = await rep_Experts.DetachedEntities.Where(p => !p.IsDeleted) + .Where(a => a.login_code == args.code) + .FirstOrDefaultAsync(); + _ = (data == null) ? throw Oops.Oh("提交码错误") : 1; + //var list = args.projects.Adapt>(); + //删除这个专家上次提交的结果 + //或者提示不能再次提交 + _ = (await rep_VoteRecords.DetachedEntities.Where(a => !a.IsDeleted && a.expert_login_code == args.code).CountAsync() > 0) ? throw Oops.Oh("已提交,无需再次提交") : 1; + var now = DateTime.Now; + args.projects.ForEach(async a => + { + var model = new Entities.VoteRecords + { + expert_login_code = args.code, + project_id = a.id, + is_agree = a.vote, + vote_time = now + }; + await model.InsertOrUpdate(); + }); + return true; + } + catch (Exception ex) + { + return false; + } + } + private async Task> GetVoteData() + { + var query = from a in rep_Projects2025.DetachedEntities + join b in rep_VoteRecords.DetachedEntities + on a.Id equals b.project_id into grouping + from p in grouping.DefaultIfEmpty() + group new { a, p } by new { a.Id, a.name, a.serial_number, a.type, a.is_no_inspection } into pp + select new ProjectsList2Output + { + serial_number = pp.Key.serial_number, + id = pp.Key.Id, + name = pp.Key.name, + yes_count = pp.Where(a => a.p.is_agree).Count(), + no_count = pp.Where(a => !a.p.is_agree).Count(), + type = pp.Key.type, + is_no_inspection = pp.Key.is_no_inspection + }; + return await query.OrderBy(a => a.serial_number).ToListAsync(); + } + /// + /// 列表 + /// + /// + [HttpPost] + public async Task List2() + { + + //var data = rep_Projects.DetachedEntities.Where(p => !p.IsDeleted) + // //.Where(args.type != null, a => (int)a.type == args.type) + // .Join(rep_VoteRecords.DetachedEntities, a => a.Id, a => a.project_id, (a, b) => + // new + // { + // //a.Id, + // //type = (int)a.type, + // //serial_number = a.serial_number, + // //name = a.name, + // //no_count = b.Where(bb => !bb.is_agree).Count(), + // //yes_count = b.Where(bb => bb.is_agree).Count(), + // }).ToList(); + ////.ProjectToType() + ////.OrderBy(a => a.serial_number) + ////.ToListAsync(); + var data = await GetVoteData(); + //var data0 = data.Where(a => a.type == Entities.EnumProjectType.FangJian).ToList(); + //var data1 = data.Where(a => a.type == Entities.EnumProjectType.ShiZheng).ToList(); + //var data2 = data.Where(a => a.type == Entities.EnumProjectType.GuiDaoGongCheng).ToList(); + //var data3 = data.Where(a => a.type == Entities.EnumProjectType.DianLiGongCheng).ToList(); + //var data4 = data.Where(a => a.type == Entities.EnumProjectType.JiaoTongGongCheng).ToList(); + //var data5 = data.Where(a => a.type == Entities.EnumProjectType.ShuiLiGongCheng).ToList(); + //return new + //{ + // data0, + // data1, + // data2, + // data3, + // data4, + // data5 + //}; + var typeList = new List { "房建工程", "市政工程", "轨道交通工程", "能源工程", "交通工程", "水利工程" }; + return new { data, typeList }; + } + /// + /// + /// + /// + public async Task Download([FromQuery] int s) + { + var data = await GetVoteData(); + var data1 = data.Where(a => a.is_no_inspection == 1).ToList(); + var data2 = data.Where(a => a.is_no_inspection == 0).ToList(); + + //var filepath = Tools.ExcelHelper.WriteTemplate(data, 4, "C"); + string template_name = s == 1 ? "票1 免于现场评估项目汇总表投票表格.xlsx" : "票2 现场评估项目(含)现场投票表格.xlsx"; + var filepath = Tools.ExcelHelper.WriteTemplate(template_name, s == 1 ? data1 : data2, 5, "C"); + return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = filepath }; + } + /// + /// + /// + /// + public async Task ExpertVote() + { + try + { + var list = await rep_Experts.DetachedEntities.GroupJoin(rep_VoteRecords.DetachedEntities, a => a.login_code, a => a.expert_login_code, (a, b) => new { a, b }) + .SelectMany(a => a.b.DefaultIfEmpty(), (a, b) => new { a.a.Id, a.a.login_code, is_vote = b != null }) + .Distinct() + .OrderBy(a => a.Id) + .ToListAsync(); + return list; + //var query = from a in rep_Experts.DetachedEntities + // join b in rep_VoteRecords.DetachedEntities on a.login_code equals b.expert_login_code into temp + // from tt in temp.DefaultIfEmpty() + // select new + // { + // a.Id, + // a.login_code, + // is_vote = tt == null + // }; + //return await query.ToListAsync(); + } + catch (Exception ex) + { } + return null; + } + + /// + /// 新增专家 + /// + /// + [HttpPost] + public async Task AddExpert(AddExpertInput args) + { + if (args == null || args.expertnum <= 0) + throw Oops.Oh("参数异常"); + try + { + var list = new List(); + for (int i = 0; i < args.expertnum; i++) + { + var newid = Ulid.NewUlid().ToString(); + var newidsimple = newid.ToUpper().Replace("I", "").Replace("L", "").Replace("0", "").Replace("O", "").Replace("1", ""); + list.Add(new Experts + { + Id = newid, + login_code = newidsimple.Substring(newidsimple.Length - 6, 6), + CreatedTime = DateTime.Now + }); + } + await rep_Experts.InsertAsync(list); + } + catch (Exception ex) + { } + } + } +} diff --git a/20220330_Vote/Vote.Services/ApiController/ProjectsService.cs b/20220330_Vote/Vote.Services/ApiController/ProjectsService.cs index e8dea7a..d989c83 100644 --- a/20220330_Vote/Vote.Services/ApiController/ProjectsService.cs +++ b/20220330_Vote/Vote.Services/ApiController/ProjectsService.cs @@ -178,7 +178,8 @@ namespace Vote.Services.ApiController { var data = await GetVoteData(); //var filepath = Tools.ExcelHelper.WriteTemplate(data, 4, "C"); - var filepath = Tools.ExcelHelper.WriteTemplate(data, 5, "C"); + string template_name = "2024年度宁波市结构优质认定项目投票结果.xlsx"; + var filepath = Tools.ExcelHelper.WriteTemplate(template_name, data, 5, "C"); return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = filepath }; } /// diff --git a/20220330_Vote/Vote.Services/Dto/ProjectsInput.cs b/20220330_Vote/Vote.Services/Dto/ProjectsInput.cs index c114036..5448ac1 100644 --- a/20220330_Vote/Vote.Services/Dto/ProjectsInput.cs +++ b/20220330_Vote/Vote.Services/Dto/ProjectsInput.cs @@ -15,6 +15,7 @@ namespace Vote.Services.Dto /// 项目类型 /// public int? type { get; set; } + public int? is_no_inspection { get; set; } } public class ProjectsOutput { @@ -48,6 +49,7 @@ namespace Vote.Services.Dto /// /// public bool vote { get; set; } = false; + public int is_no_inspection { get; set; } } public class CheckSubmitCodeInput { @@ -116,5 +118,6 @@ namespace Vote.Services.Dto [Required] public int expertnum { get; set; } } + public int is_no_inspection { get; set; } } } diff --git a/20220330_Vote/Vote.Services/Entities/Projects.cs b/20220330_Vote/Vote.Services/Entities/Projects.cs index c46c5d7..87d3afe 100644 --- a/20220330_Vote/Vote.Services/Entities/Projects.cs +++ b/20220330_Vote/Vote.Services/Entities/Projects.cs @@ -174,9 +174,9 @@ namespace Vote.Services.Entities [Description("轨道工程")] GuiDaoGongCheng = 2, /// - /// 电力工程 + /// 能源工程 /// - [Description("电力工程")] + [Description("能源工程")] DianLiGongCheng = 3, /// /// 交通工程 diff --git a/20220330_Vote/Vote.Services/Entities/Projects_2025.cs b/20220330_Vote/Vote.Services/Entities/Projects_2025.cs new file mode 100644 index 0000000..443b594 --- /dev/null +++ b/20220330_Vote/Vote.Services/Entities/Projects_2025.cs @@ -0,0 +1,51 @@ +using Ewide.Core; +using Ewide.Core.Util; +using Furion; +using Furion.DatabaseAccessor; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vote.Services.Entities +{ + /// + /// 项目表 + /// + public class Projects_2025 : DEntityBase//, IEntitySeedData + { + /// + /// 项目序号 + /// + [Comment("项目序号")] + public int serial_number { get; set; } + /// + /// 工程名称 + /// + [Comment("工程名称")] + public string name { get; set; } + /// + /// 项目类型 + /// + [Comment("项目类型")] + public EnumProjectType type { get; set; } + /// + /// + /// + [NotMapped] + public string type_title + { + get + { + return type.GetEnumDescription(); + } + } + public int is_no_inspection { get; set; } + } + +} diff --git a/20220330_Vote/Vote.Services/Tools/ExcelHelper.cs b/20220330_Vote/Vote.Services/Tools/ExcelHelper.cs index 23821cf..9d9a4e3 100644 --- a/20220330_Vote/Vote.Services/Tools/ExcelHelper.cs +++ b/20220330_Vote/Vote.Services/Tools/ExcelHelper.cs @@ -114,11 +114,10 @@ namespace Vote.Services.Tools /// /// /// - public static string WriteTemplate(List list, int start_row, string start_column) + public static string WriteTemplate(string template_name, List list, int start_row, string start_column) { try { - string template_name = "2024年度宁波市结构优质认定项目投票结果.xlsx"; string excelFilePath = $"{App.WebHostEnvironment.WebRootPath}\\ExcelTemplate\\{template_name}"; string outputPath = string.Empty; if (!string.IsNullOrEmpty(excelFilePath)) diff --git a/20220330_Vote/Vote.Services/Vote.Services.xml b/20220330_Vote/Vote.Services/Vote.Services.xml index d716f93..b20a6ec 100644 --- a/20220330_Vote/Vote.Services/Vote.Services.xml +++ b/20220330_Vote/Vote.Services/Vote.Services.xml @@ -203,6 +203,53 @@ + + + 项目 + + + + + 列表 + + + + + + 检验提交码 + + + + + + 提交 + + + + + + 列表 + + + + + + + + + + + + + + + + + + 新增专家 + + + 项目 @@ -933,7 +980,7 @@ - 电力工程 + 能源工程 @@ -996,6 +1043,31 @@ + + + 项目表 + + + + + 项目序号 + + + + + 工程名称 + + + + + 项目类型 + + + + + + + 投票记录 @@ -1112,7 +1184,7 @@ - +