From b57861a0c89364b7812bf5d3018c529ee5ae0ede Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 7 Feb 2025 14:17:11 +0800 Subject: [PATCH] =?UTF-8?q?=20=E8=AF=95=E5=8D=B7=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghre/Ghre_ExamPaperController.cs | 9 +++- .../Ghre/IGhre_ExamPaperServices.cs | 2 + Tiobon.Core.Services/CommonServices.cs | 2 + .../Ghre/Ghre_ExamPaperServices.cs | 46 ++++++++++++++++++- .../Ghre/Ghre_StudyRuleServices.cs | 10 ++-- .../Ghrh/Ghrh_ResumeServices.cs | 5 +- 6 files changed, 64 insertions(+), 10 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs index 6f8d8205..3aaa061e 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs @@ -1,4 +1,6 @@ -namespace Tiobon.Core.Api.Controllers; +using NPOI.Util; + +namespace Tiobon.Core.Api.Controllers; /// /// 试卷(Controller) @@ -113,4 +115,9 @@ public class Ghre_ExamPaperController : BaseController Copy(long id) => await _service.Copy(id); + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs index 31b04057..b0957936 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs @@ -24,4 +24,6 @@ public interface IGhre_ExamPaperServices : IBaseServices> GetSelectAsync(long? linkId, string KeyWords); Task> ExportExcel(QueryExport body, string status); + + Task Copy(long id); } \ No newline at end of file diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index bf62df37..45f4a22d 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -899,6 +899,8 @@ public partial class CommonServices : BaseServices>, ICommon case "F_ExamPaperReleased": toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault(); if (toolbar != null) { toolbar.fnKey = "TBD3YN"; } + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "CopyYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD4YN"; } result.JM_PageControlT1.Toolbar.Insert(0, new Toolbar() { diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs index 9de704b8..8b95a4dc 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs @@ -912,7 +912,7 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); for (int i = 0; i < dt.Rows.Count; i++) { - item = new JObject + item = new JObject { new JProperty("value",long.Parse(dt.Rows[i]["Id"].ToString())), new JProperty("label", dt.Rows[i]["PaperName"].ToString() + "("+dt.Rows[i]["PaperNo"].ToString()+")") @@ -920,7 +920,7 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); DT_TableDataT1.Add(item); } - item = new JObject + item = new JObject { new JProperty("ListMax",100), new JProperty("ListMin",10), @@ -936,4 +936,46 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); return new ServiceResult() { Success = true, Message = "查询成功", Data = result, }; } #endregion + + #region 复制 + + public async Task Copy(long id) + { + + var entity = await base.QueryById(id); + entity.PaperName = entity.PaperName + "_复制"; + entity.PaperNo = await GenerateContinuousSequence("Ghre_ExamPaper", "PaperNo", "P"); + + entity.Status = "Draft"; + var id1 = await base.Add(Mapper.Map(entity).ToANew()); + + var configs = await _ghre_ExamPaperConfigServices.Query(x => x.ExamPaperId == id); + var questions = await _ghre_ExamPaperQuestionServices.Query(x => x.ExamPaperId == id); + + for (int i = 0; i < configs.Count; i++) + { + var config = configs[i]; + config.ExamPaperId = id1; + + var configId = await _ghre_ExamPaperConfigServices.Add(Mapper.Map(config).ToANew()); + + var questions1 = Mapper.Map(questions.Where(x => x.ConfigId == config.Id)).ToANew>(); + questions1.ForEach(x => + { + x.ConfigId = configId; + x.ExamPaperId = id1; + }); + await _ghre_ExamPaperQuestionServices.Add(questions1); + } + + //var result = await BaseDal.Update(entities); + //if (status == "Released") + // return ServiceResult.OprateSuccess("发布成功!"); + //else if (status == "Draft") + // return ServiceResult.OprateSuccess(" 已启用成功,请进入草稿箱查看!"); + //else + // return ServiceResult.OprateSuccess("停用成功!"); + return ServiceResult.OprateSuccess("复制成功!"); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs index 373b0f18..ac637b34 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs @@ -228,15 +228,15 @@ public class Ghre_StudyRuleServices : BaseServices Update(long Id, EditGhre_StudyRuleInput entity) { - if (!entity.ZoneIds.IsNull() && entity.ZoneIds.Any()) + if (!entity.ZoneIds.IsNull()) entity.ZoneId = JsonHelper.ObjToJson(entity.ZoneIds); - if (!entity.DeptIds.IsNull() && entity.DeptIds.Any()) + if (!entity.DeptIds.IsNull()) entity.DeptId = JsonHelper.ObjToJson(entity.DeptIds); - if (!entity.TitleIds.IsNull() && entity.TitleIds.Any()) + if (!entity.TitleIds.IsNull()) entity.TitleId = JsonHelper.ObjToJson(entity.TitleIds); - if (!entity.GradeIds.IsNull() && entity.GradeIds.Any()) + if (!entity.GradeIds.IsNull()) entity.GradeId = JsonHelper.ObjToJson(entity.GradeIds); - if (!entity.JobIds.IsNull() && entity.JobIds.Any()) + if (!entity.JobIds.IsNull()) entity.JobId = JsonHelper.ObjToJson(entity.JobIds); var result = await base.Update(Id, entity); diff --git a/Tiobon.Core.Services/Ghrh/Ghrh_ResumeServices.cs b/Tiobon.Core.Services/Ghrh/Ghrh_ResumeServices.cs index 82cad970..45e9a9a0 100644 --- a/Tiobon.Core.Services/Ghrh/Ghrh_ResumeServices.cs +++ b/Tiobon.Core.Services/Ghrh/Ghrh_ResumeServices.cs @@ -797,10 +797,11 @@ ORDER BY A.SortNo ASC"; }); else { - if (input.IdCardNo.IsNullOrEmpty()) + if (input.IdCardNo.IsNullOrEmpty() && resume.IdCardNo.IsNotEmptyOrNull()) return ServiceResult.OprateFailed(await QueryLangValue("F_ResumeMaintenance_0147", "请输入身份证号码后六位!")); - resume = await QuerySingle(x => x.Mobile == input.Mobile && x.IdCardNo.Contains(input.IdCardNo)); + if (input.IdCardNo.IsNotEmptyOrNull() && resume.IdCardNo.IsNotEmptyOrNull()) + resume = await QuerySingle(x => x.Mobile == input.Mobile && x.IdCardNo.Contains(input.IdCardNo)); id = resume.Id;