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 + "不能为空!");