2025-02-21 18:11:40 +08:00
|
|
|
|
using MiniExcelLibs;
|
|
|
|
|
using Model;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 岗位培训记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class PostTrainingRecordService
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据主键获取岗位培训记录信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static PostTraining_Record GetRecordById(string Id)
|
|
|
|
|
{
|
|
|
|
|
return Funs.DB.PostTraining_Record.FirstOrDefault(e => e.Id == Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加岗位培训记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
public static void AddRecord(PostTraining_Record model)
|
|
|
|
|
{
|
|
|
|
|
PostTraining_Record newModel = new PostTraining_Record
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
ProjectId = model.ProjectId,
|
|
|
|
|
Code = model.Code,
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
Content = model.Content,
|
|
|
|
|
CategoryId = model.CategoryId,
|
|
|
|
|
CategoryName = model.CategoryName,
|
|
|
|
|
CourseId = model.CourseId,
|
|
|
|
|
CourseName = model.CourseName,
|
|
|
|
|
Location = model.Location,
|
|
|
|
|
Method = model.Method,
|
|
|
|
|
Lecturer = model.Lecturer,
|
|
|
|
|
UnitIds = model.UnitIds,
|
2025-02-25 16:41:06 +08:00
|
|
|
|
//RoleIds = model.RoleIds,
|
|
|
|
|
WorkPostIds = model.WorkPostIds,
|
2025-02-21 18:11:40 +08:00
|
|
|
|
PersonNum = model.PersonNum,
|
|
|
|
|
TrainingTime = model.TrainingTime,
|
|
|
|
|
Duration = model.Duration,
|
|
|
|
|
CompileDate = model.CompileDate,
|
|
|
|
|
CompileMan = model.CompileMan,
|
|
|
|
|
Remark = model.Remark
|
|
|
|
|
};
|
|
|
|
|
Funs.DB.PostTraining_Record.InsertOnSubmit(newModel);
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
public static void UpdateRecord(PostTraining_Record model)
|
|
|
|
|
{
|
|
|
|
|
PostTraining_Record newModel = Funs.DB.PostTraining_Record.FirstOrDefault(e => e.Id == model.Id);
|
|
|
|
|
if (newModel != null)
|
|
|
|
|
{
|
|
|
|
|
newModel.Code = model.Code;
|
|
|
|
|
newModel.Name = model.Name;
|
|
|
|
|
newModel.Content = model.Content;
|
|
|
|
|
newModel.CategoryId = model.CategoryId;
|
|
|
|
|
newModel.CategoryName = model.CategoryName;
|
|
|
|
|
newModel.CourseId = model.CourseId;
|
|
|
|
|
newModel.CourseName = model.CourseName;
|
|
|
|
|
newModel.Location = model.Location;
|
|
|
|
|
newModel.Method = model.Method;
|
|
|
|
|
newModel.Lecturer = model.Lecturer;
|
|
|
|
|
newModel.UnitIds = model.UnitIds;
|
2025-02-25 16:41:06 +08:00
|
|
|
|
newModel.WorkPostIds = model.WorkPostIds;
|
|
|
|
|
//newModel.RoleIds = model.RoleIds;
|
2025-02-21 18:11:40 +08:00
|
|
|
|
newModel.PersonNum = model.PersonNum;
|
|
|
|
|
newModel.TrainingTime = model.TrainingTime;
|
|
|
|
|
newModel.Duration = model.Duration;
|
|
|
|
|
newModel.Remark = model.Remark;
|
|
|
|
|
newModel.CompileDate = model.CompileDate;
|
|
|
|
|
newModel.CompileMan = model.CompileMan;
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
public static void DeleteRecordById(string Id)
|
|
|
|
|
{
|
|
|
|
|
PostTraining_Record model = Funs.DB.PostTraining_Record.FirstOrDefault(e => e.Id == Id);
|
|
|
|
|
if (model != null)
|
|
|
|
|
{
|
|
|
|
|
CommonService.DeleteAttachFileById(Id);
|
|
|
|
|
Funs.DB.PostTraining_Record.DeleteOnSubmit(model);
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 导入数据
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 导入数据
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="path"></param>
|
|
|
|
|
///// <param name="projectid"></param>
|
|
|
|
|
///// <param name="creatUserId"></param>
|
|
|
|
|
///// <param name="errorList"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//public static ResponeData ImportData(string OriFileName, string path, string projectid, string creatUserId, ref List<ErrorInfo> errorList)
|
|
|
|
|
//{
|
|
|
|
|
// var responeData = new ResponeData();
|
|
|
|
|
// List<PostTrainingRecord_InputDataIn> temeplateDtoIns;
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// temeplateDtoIns = MiniExcel.Query<PostTrainingRecord_InputDataIn>(path, startCell: "A1").ToList();
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// responeData.code = 0;
|
|
|
|
|
// responeData.message = "模板错误:" + ex.ToString();
|
|
|
|
|
// return responeData;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (temeplateDtoIns.Count == 0)
|
|
|
|
|
// {
|
|
|
|
|
// responeData.code = 0;
|
|
|
|
|
// responeData.message = "导入数据为空!";
|
|
|
|
|
// return responeData;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// //培训标准
|
|
|
|
|
// var lstRecord = GetRecordInfoList();
|
|
|
|
|
// //培训课程
|
|
|
|
|
// var lstCourse = PostTrainingCourseService.GetCourseList();
|
|
|
|
|
// //培训角色
|
|
|
|
|
// var lstRole = PostTrainingRoleService.GetRoleList();
|
|
|
|
|
// //培训类别
|
|
|
|
|
// var lstCategory = PostTrainingCategoryService.GetCategoryList();
|
|
|
|
|
// //培训方式
|
|
|
|
|
// var lstMethod = PostTrainingMethodService.GetMethodList();
|
|
|
|
|
// //培训教资
|
|
|
|
|
// var lstTeachers = PostTrainingTeachersService.GetTeachersList();
|
|
|
|
|
// //培训效果
|
|
|
|
|
// var lstOutcome = GetPostTrainingOutcomeList();
|
|
|
|
|
|
|
|
|
|
// #region 数据校验
|
|
|
|
|
|
|
|
|
|
// string errorMsg = string.Empty;
|
|
|
|
|
// int rowIndex = 3;
|
|
|
|
|
// foreach (var item in temeplateDtoIns)
|
|
|
|
|
// {
|
|
|
|
|
// string roleName = !string.IsNullOrWhiteSpace(item.RoleName) ? item.RoleName.Trim() : string.Empty;
|
|
|
|
|
// string categoryName = !string.IsNullOrWhiteSpace(item.CategoryName) ? item.CategoryName.Trim() : string.Empty;
|
|
|
|
|
// string courseName = !string.IsNullOrWhiteSpace(item.CourseName) ? item.CourseName.Trim() : string.Empty;
|
|
|
|
|
// string classHourStr = !string.IsNullOrWhiteSpace(item.ClassHour) ? item.ClassHour.Trim() : string.Empty;
|
|
|
|
|
// string cycleStr = !string.IsNullOrWhiteSpace(item.Cycle) ? item.Cycle.Trim() : string.Empty;
|
|
|
|
|
// decimal classHour = 0;
|
|
|
|
|
// decimal cycle = 0;
|
|
|
|
|
// string method = !string.IsNullOrWhiteSpace(item.Method) ? item.Method.Trim() : string.Empty;
|
|
|
|
|
// string outcome = !string.IsNullOrWhiteSpace(item.Outcome) ? item.Outcome.Trim() : string.Empty;
|
|
|
|
|
// string teachers = !string.IsNullOrWhiteSpace(item.Teachers) ? item.Teachers.Trim() : string.Empty;
|
|
|
|
|
// string remark = !string.IsNullOrWhiteSpace(item.Remark) ? item.Remark.Trim() : string.Empty;
|
|
|
|
|
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(roleName))
|
|
|
|
|
// {
|
|
|
|
|
// if (!lstRole.Where(x => x.Name == roleName).Any())
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "适用岗位角色";
|
|
|
|
|
// errorInfo.Reason = $"角色不存在:{roleName}";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "适用岗位角色";
|
|
|
|
|
// errorInfo.Reason = "不可为空";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(categoryName))
|
|
|
|
|
// {
|
|
|
|
|
// if (!lstCategory.Where(x => x.Name == categoryName).Any())
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训类别";
|
|
|
|
|
// errorInfo.Reason = $"培训类别不存在:{categoryName}";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训类别";
|
|
|
|
|
// errorInfo.Reason = "不可为空";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (string.IsNullOrWhiteSpace(courseName))
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训课程";
|
|
|
|
|
// errorInfo.Reason = "不可为空";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(categoryName) && !string.IsNullOrWhiteSpace(courseName))
|
|
|
|
|
// {
|
|
|
|
|
// if (temeplateDtoIns.Where(x => x.RoleName == roleName && x.CourseName == courseName && x.CategoryName == categoryName).Count() > 1)
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训课程";
|
|
|
|
|
// errorInfo.Reason = $"【{roleName}】导入数据重复:{courseName}({categoryName})";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// if (!lstCourse.Where(x => x.Name == courseName && x.CategoryName == categoryName).Any())
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训课程";
|
|
|
|
|
// errorInfo.Reason = $"【{roleName}】不存在培训课程:{courseName}({categoryName})";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// else if (lstRecord.Where(x => x.CourseName == courseName && x.CategoryName == categoryName).Any())
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训课程";
|
|
|
|
|
// errorInfo.Reason = $"培训标准已存在:{courseName}({categoryName})";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (!string.IsNullOrEmpty(classHourStr))
|
|
|
|
|
// {
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// classHour = decimal.Parse(classHourStr);
|
|
|
|
|
// if (classHour <= 0)
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训课时";
|
|
|
|
|
// errorInfo.Reason = "请填写大于0的数值";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception)
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训课时";
|
|
|
|
|
// errorInfo.Reason = "请填写大于0的数值";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训课时";
|
|
|
|
|
// errorInfo.Reason = "请填写大于0的数值";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (!string.IsNullOrEmpty(cycleStr))
|
|
|
|
|
// {
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// cycle = decimal.Parse(cycleStr);
|
|
|
|
|
// if (cycle <= 0)
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训周期";
|
|
|
|
|
// errorInfo.Reason = "请填写大于0的数值";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception)
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训周期";
|
|
|
|
|
// errorInfo.Reason = "请填写大于0的数值";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训周期";
|
|
|
|
|
// errorInfo.Reason = "请填写大于0的数值";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(method))
|
|
|
|
|
// {
|
|
|
|
|
// if (!lstMethod.Where(x => x.Name == method).Any())
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训方式";
|
|
|
|
|
// errorInfo.Reason = $"培训方式字典不存在:{method}";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(outcome))
|
|
|
|
|
// {
|
|
|
|
|
// if (!lstOutcome.Where(x => x.Text == outcome).Any())
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训效果";
|
|
|
|
|
// errorInfo.Reason = $"培训效果字典不存在:{outcome}";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(teachers))
|
|
|
|
|
// {
|
|
|
|
|
// if (!lstTeachers.Where(x => x.Name == teachers).Any())
|
|
|
|
|
// {
|
|
|
|
|
// ErrorInfo errorInfo = new ErrorInfo();
|
|
|
|
|
// errorInfo.Row = rowIndex.ToString();
|
|
|
|
|
// errorInfo.Column = "培训师资";
|
|
|
|
|
// errorInfo.Reason = $"培训师资字典不存在:{teachers}";
|
|
|
|
|
// errorList.Add(errorInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// rowIndex++;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (errorList.Any())
|
|
|
|
|
// {
|
|
|
|
|
// responeData.code = 0;
|
|
|
|
|
// responeData.message = "存在异常数据!";
|
|
|
|
|
// return responeData;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
|
|
// foreach (var item in temeplateDtoIns)
|
|
|
|
|
// {
|
|
|
|
|
// string roleName = !string.IsNullOrWhiteSpace(item.RoleName) ? item.RoleName.Trim() : string.Empty;
|
|
|
|
|
// string categoryName = !string.IsNullOrWhiteSpace(item.CategoryName) ? item.CategoryName.Trim() : string.Empty;
|
|
|
|
|
// string courseName = !string.IsNullOrWhiteSpace(item.CourseName) ? item.CourseName.Trim() : string.Empty;
|
|
|
|
|
// decimal classHour = decimal.Parse(item.ClassHour);
|
|
|
|
|
// decimal cycle = decimal.Parse(item.Cycle);
|
|
|
|
|
// string method = !string.IsNullOrWhiteSpace(item.Method) ? item.Method.Trim() : string.Empty;
|
|
|
|
|
// string outcome = !string.IsNullOrWhiteSpace(item.Outcome) ? item.Outcome.Trim() : string.Empty;
|
|
|
|
|
// string teachers = !string.IsNullOrWhiteSpace(item.Teachers) ? item.Teachers.Trim() : string.Empty;
|
|
|
|
|
// string remark = !string.IsNullOrWhiteSpace(item.Remark) ? item.Remark.Trim() : string.Empty;
|
|
|
|
|
|
|
|
|
|
// PostTraining_Record newModel = new PostTraining_Record
|
|
|
|
|
// {
|
|
|
|
|
// Id = SQLHelper.GetNewID(typeof(PostTraining_Record)),
|
|
|
|
|
// Code = SQLHelper.RunProcNewId("SpGetNewCode5", "dbo.PostTraining_Record", "Code", ""),
|
|
|
|
|
// //ProjectId = this.ProjectId,
|
|
|
|
|
// CompileDate = DateTime.Now,
|
|
|
|
|
// CompileMan = creatUserId
|
|
|
|
|
// };
|
|
|
|
|
// newModel.CourseId = lstCourse.Where(x => x.Name == courseName).FirstOrDefault().Id;
|
|
|
|
|
// newModel.RoleId = lstRole.Where(x => x.Name == roleName).FirstOrDefault().Id;
|
|
|
|
|
// newModel.ClassHour = classHour;
|
|
|
|
|
// newModel.Cycle = cycle;
|
|
|
|
|
// newModel.Method = method;
|
|
|
|
|
// newModel.Outcome = outcome;
|
|
|
|
|
// newModel.Teachers = teachers;
|
|
|
|
|
// newModel.Remark = remark;
|
|
|
|
|
|
|
|
|
|
// AddRecord(newModel);
|
|
|
|
|
// }
|
|
|
|
|
// return responeData;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|