From 5dcbb2bd81bbc8afc9b9e4565df07241ede2be32 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Thu, 20 Feb 2025 10:08:56 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=89=9B=E5=B0=BE]=20=E5=9F=B9=E8=AE=AD?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E6=96=B0=E5=A2=9E=E9=9C=80=E6=B1=82=E4=BA=BA?= =?UTF-8?q?=E6=95=B0=E4=B8=8E=E5=9F=B9=E8=AE=AD=E5=AF=B9=E8=B1=A1=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Services/BASE/BaseServices.cs | 8 +++++++ .../Ghre/Ghre_RequestServices.cs | 24 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index c8af02f9..2f0f9bdc 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -2080,6 +2080,14 @@ ORDER BY SortNo ASC"; // } //} + public async Task QueryCompanyCode() + { + var sql = @$"SELECT CompanySpecCode + FROM ghro_company + WHERE IsEnable = 1"; + return await Db.Ado.GetStringAsync(sql); + } + #region 发送站内信 public async Task SendMessage(List staffIds, string title, string content, string webUrl = null) { diff --git a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs index 43bd44d2..c38d8373 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs @@ -100,7 +100,14 @@ FROM Ghre_Request A if (entity.TrainStaffIds.IsNotEmptyOrNull()) entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); entity.RequestNo = await GenerateContinuousSequence("Ghre_Request", "RequestNo", "R"); + if (entity.CourseSource != "Dept") + entity.RequestNum = null; + if (entity.CourseSource == "Dept" && await QueryCompanyCode() == "Ushio") + { + if (entity.TrainStaffIds.Any() && entity.TrainStaffIds.Count != entity.RequestNum) + throw new Exception("需求人数与培训对象人数不一致,请确认数据重新提交!"); + } var id = await base.Add(entity); var sql = $"SELECT ISNULL(MAX(id)+1,1) FROM Ghre_Request WHERE Id !='{id}'"; @@ -325,8 +332,9 @@ FROM Ghre_Request A #region Excel导入 - public static async Task<(List>, int)> ValidImportExcel(ISqlSugarClient Db, List columns, DataTable dt) + public async Task<(List>, int)> ValidImportExcel(ISqlSugarClient Db, List columns, DataTable dt) { + var CompanyCode = await QueryCompanyCode(); Type entityType = typeof(Ghre_Request); var properties = entityType.GetGenericProperties(); int ErrorCount = 0; @@ -344,8 +352,22 @@ FROM Ghre_Request A { var value = dt.Rows[i][x.label].ToString(); var courseSource = dt.Rows[i]["课程来源"].ToString(); + + if (x.label == "需求来源" && value == "部门需求" && CompanyCode == "Ushio") + { + var RequestNum = dt.Rows[i]["需求人数"].ObjToInt(); + var TrainStaffIds1 = dt.Rows[i]["培训对象"].ToString(); + TrainStaffIds1 = TrainStaffIds1.Replace(",", ","); + TrainStaffIds1 = TrainStaffIds1.Replace(";", ","); + TrainStaffIds1 = TrainStaffIds1.Replace(";", ","); + var value1 = value.Split(',').ToList(); + if (value1.Any() && value1.Count != RequestNum) + throw new Exception("需求人数与培训对象人数不一致,请确认数据重新提交!"); + } + if (x.label == "需求课程" || x.label == "新增课程") { + if (x.label == "需求课程" && courseSource == "已有课程" && value.IsNullOrEmpty()) { comments.Add(x.label + "不能为空!");