2025-04-19 16:21:39 +08:00
|
|
|
|
using Model;
|
2025-03-04 18:12:07 +08:00
|
|
|
|
using System;
|
2024-11-19 09:45:27 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2025-04-19 16:21:39 +08:00
|
|
|
|
using System.Numerics;
|
2024-11-19 09:45:27 +08:00
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 培训计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class TrainingPlanService
|
|
|
|
|
{
|
|
|
|
|
public static Model.SGGLDB db = Funs.DB;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据主键获取培训计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static Model.Training_Plan GetPlanById(string planId)
|
|
|
|
|
{
|
2025-03-04 18:12:07 +08:00
|
|
|
|
return db.Training_Plan.FirstOrDefault(e => e.PlanId == planId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据检查Id获取培训计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="checkId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static Model.Training_Plan GetPlanByCheckId(string checkId)
|
|
|
|
|
{
|
|
|
|
|
return db.Training_Plan.FirstOrDefault(e => e.CheckId == checkId && e.IsRetakeCourse == 1);
|
2024-11-19 09:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-04-19 16:21:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据培训教材Id获取今年培训计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
/// <param name="itemId"></param>
|
|
|
|
|
/// <param name="year"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.Training_Plan> GetThisYearPlanByCompanyTrainingItemId(string projectId, string itemId, int year)
|
|
|
|
|
{
|
|
|
|
|
return db.Training_Plan.Where(e => e.ProjectId == projectId && e.CompanyTrainingItemId == itemId && e.IsRetakeCourse != 1 && ((DateTime)e.DesignerDate).Year == year).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-19 09:45:27 +08:00
|
|
|
|
|
2025-03-04 18:12:07 +08:00
|
|
|
|
|
2024-11-19 09:45:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加培训计划
|
|
|
|
|
/// </summary>
|
2025-03-04 18:12:07 +08:00
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
public static void AddPlan(Model.Training_Plan model)
|
2024-11-19 09:45:27 +08:00
|
|
|
|
{
|
2025-03-04 18:12:07 +08:00
|
|
|
|
Model.Training_Plan newModel = new Model.Training_Plan
|
2024-11-19 09:45:27 +08:00
|
|
|
|
{
|
2025-03-04 18:12:07 +08:00
|
|
|
|
PlanId = model.PlanId,
|
|
|
|
|
PlanCode = model.PlanCode,
|
|
|
|
|
ProjectId = model.ProjectId,
|
|
|
|
|
DesignerId = model.DesignerId,
|
|
|
|
|
PlanName = model.PlanName,
|
|
|
|
|
TrainContent = model.TrainContent,
|
|
|
|
|
TrainStartDate = model.TrainStartDate,
|
2025-04-19 16:21:39 +08:00
|
|
|
|
TrainEndDate = model.TrainEndDate,
|
2025-03-04 18:12:07 +08:00
|
|
|
|
TeachHour = model.TeachHour,
|
|
|
|
|
TeachMan = model.TeachMan,
|
|
|
|
|
TeachAddress = model.TeachAddress,
|
|
|
|
|
TrainTypeId = model.TrainTypeId,
|
|
|
|
|
TrainLevelId = model.TrainLevelId,
|
|
|
|
|
DesignerDate = model.DesignerDate,
|
|
|
|
|
UnitIds = model.UnitIds,
|
|
|
|
|
WorkPostId = model.WorkPostId,
|
|
|
|
|
States = model.States,
|
|
|
|
|
Cycle = model.Cycle,
|
|
|
|
|
IsRetakeCourse = model.IsRetakeCourse,
|
|
|
|
|
CheckType = model.CheckType,
|
2025-04-19 16:21:39 +08:00
|
|
|
|
CheckId = model.CheckId,
|
|
|
|
|
CompanyTrainingItemId = model.CompanyTrainingItemId
|
2024-11-19 09:45:27 +08:00
|
|
|
|
};
|
2025-03-04 18:12:07 +08:00
|
|
|
|
db.Training_Plan.InsertOnSubmit(newModel);
|
2024-11-19 09:45:27 +08:00
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改培训计划
|
|
|
|
|
/// </summary>
|
2025-03-04 18:12:07 +08:00
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
public static void UpdatePlan(Model.Training_Plan model)
|
2024-11-19 09:45:27 +08:00
|
|
|
|
{
|
2025-03-04 18:12:07 +08:00
|
|
|
|
Model.Training_Plan isUpdate = Funs.DB.Training_Plan.FirstOrDefault(e => e.PlanId == model.PlanId);
|
2024-11-19 09:45:27 +08:00
|
|
|
|
if (isUpdate != null)
|
|
|
|
|
{
|
2025-03-04 18:12:07 +08:00
|
|
|
|
isUpdate.PlanName = model.PlanName;
|
|
|
|
|
isUpdate.TrainContent = model.TrainContent;
|
|
|
|
|
isUpdate.TrainStartDate = model.TrainStartDate;
|
|
|
|
|
isUpdate.TrainEndDate = model.TrainEndDate;
|
2025-04-19 16:21:39 +08:00
|
|
|
|
isUpdate.TeachHour = model.TeachHour;
|
2025-03-04 18:12:07 +08:00
|
|
|
|
isUpdate.TeachMan = model.TeachMan;
|
|
|
|
|
isUpdate.TeachAddress = model.TeachAddress;
|
|
|
|
|
isUpdate.TrainTypeId = model.TrainTypeId;
|
|
|
|
|
isUpdate.TrainLevelId = model.TrainLevelId;
|
|
|
|
|
isUpdate.DesignerDate = model.DesignerDate;
|
|
|
|
|
isUpdate.UnitIds = model.UnitIds;
|
|
|
|
|
isUpdate.WorkPostId = model.WorkPostId;
|
|
|
|
|
isUpdate.States = model.States;
|
|
|
|
|
isUpdate.Cycle = model.Cycle;
|
|
|
|
|
isUpdate.IsRetakeCourse = model.IsRetakeCourse;
|
|
|
|
|
isUpdate.CheckType = model.CheckType;
|
|
|
|
|
isUpdate.CheckId = model.CheckId;
|
2025-04-19 16:21:39 +08:00
|
|
|
|
isUpdate.CompanyTrainingItemId = model.CompanyTrainingItemId;
|
2025-03-04 18:12:07 +08:00
|
|
|
|
db.SubmitChanges();
|
2024-11-19 09:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据主键删除培训计划信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planId"></param>
|
|
|
|
|
public static void DeletePlanById(string planId)
|
|
|
|
|
{
|
2025-03-04 18:12:07 +08:00
|
|
|
|
Model.Training_Plan plan = db.Training_Plan.FirstOrDefault(e => e.PlanId == planId);
|
2024-11-19 09:45:27 +08:00
|
|
|
|
if (plan != null)
|
|
|
|
|
{
|
2025-03-04 18:12:07 +08:00
|
|
|
|
db.Training_Plan.DeleteOnSubmit(plan);
|
|
|
|
|
db.SubmitChanges();
|
2024-11-19 09:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取培训计划列
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.Training_Plan> GetPlanList()
|
|
|
|
|
{
|
|
|
|
|
return (from x in db.Training_Plan orderby x.PlanCode select x).ToList();
|
|
|
|
|
}
|
2025-03-04 18:12:07 +08:00
|
|
|
|
|
2025-04-19 16:21:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取某一岗位今年入场培训计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
/// <param name="workPostId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.Training_Plan> GetPlanListByWorkPostId(string projectId, string workPostId)
|
|
|
|
|
{
|
|
|
|
|
var list = (from x in db.Training_Plan
|
|
|
|
|
where x.ProjectId == projectId && (x.WorkPostId == null || x.WorkPostId.Contains(workPostId)) && x.CompanyTrainingItemId != null && x.IsRetakeCourse == null && Convert.ToDateTime(x.DesignerDate).Year == DateTime.Now.Year
|
|
|
|
|
select x).ToList();
|
|
|
|
|
return list;
|
|
|
|
|
}
|
2025-03-04 18:12:07 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检查重修,并生成培训计划、任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
2025-04-19 16:21:39 +08:00
|
|
|
|
public static void RetakeCourseProducePlan(ProducePlanInfo info)
|
2025-03-04 18:12:07 +08:00
|
|
|
|
{
|
|
|
|
|
var plan = GetPlanByCheckId(info.CheckId);
|
|
|
|
|
var person = PersonService.GetPersonById(info.PersonId);
|
|
|
|
|
var companyTrainingItem = CompanyTrainingItemService.GetCompanyTrainingItemById(info.CompanyTrainingItemId);
|
|
|
|
|
var teachHour = companyTrainingItem.LearningTime / 3600;
|
|
|
|
|
|
|
|
|
|
string planId = string.Empty;
|
|
|
|
|
if (plan != null)
|
|
|
|
|
{//编辑培训计划
|
|
|
|
|
planId = plan.PlanId;
|
|
|
|
|
Model.Training_Plan planModel = new Model.Training_Plan
|
|
|
|
|
{
|
|
|
|
|
ProjectId = info.CurrProjectId,
|
|
|
|
|
PlanName = info.CheckTypeName,
|
|
|
|
|
TrainContent = info.CheckTypeName,
|
|
|
|
|
TeachHour = teachHour,
|
|
|
|
|
UnitIds = person.UnitId,
|
|
|
|
|
WorkPostId = person.WorkPostId,
|
|
|
|
|
TrainStartDate = plan.TrainStartDate,
|
|
|
|
|
TrainEndDate = info.TrainEndDate,
|
|
|
|
|
TeachMan = plan.TeachMan,
|
|
|
|
|
TeachAddress = plan.TeachAddress,
|
|
|
|
|
TrainTypeId = Const.RetakeCourseTrainTypeId,
|
|
|
|
|
TrainLevelId = Const.OtherTrainLevelId,
|
|
|
|
|
States = "1",
|
|
|
|
|
Cycle = "",
|
|
|
|
|
IsRetakeCourse = 1,
|
|
|
|
|
CheckType = plan.CheckType,
|
2025-04-19 16:21:39 +08:00
|
|
|
|
CheckId = plan.CheckId,
|
|
|
|
|
CompanyTrainingItemId = info.CompanyTrainingItemId
|
2025-03-04 18:12:07 +08:00
|
|
|
|
};
|
|
|
|
|
UpdatePlan(planModel);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{//生成培训计划
|
|
|
|
|
planId = SQLHelper.GetNewID();
|
|
|
|
|
string code = ProjectService.GetProjectByProjectId(info.CurrProjectId).ProjectCode + "-";
|
|
|
|
|
string planCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.Training_Plan", "PlanCode", info.CurrProjectId, code);
|
|
|
|
|
|
|
|
|
|
Model.Training_Plan planModel = new Model.Training_Plan
|
|
|
|
|
{
|
|
|
|
|
PlanId = planId,
|
|
|
|
|
PlanCode = planCode,
|
|
|
|
|
ProjectId = info.CurrProjectId,
|
|
|
|
|
DesignerId = info.CurrUserId,
|
|
|
|
|
DesignerDate = DateTime.Now,
|
|
|
|
|
PlanName = info.CheckTypeName,
|
|
|
|
|
TrainContent = info.CheckTypeName,
|
|
|
|
|
TrainStartDate = DateTime.Now,
|
|
|
|
|
TrainEndDate = info.TrainEndDate,
|
|
|
|
|
TeachHour = teachHour,
|
|
|
|
|
//TeachMan = model.TeachMan,
|
|
|
|
|
//TeachAddress = model.TeachAddress,
|
|
|
|
|
TrainTypeId = Const.RetakeCourseTrainTypeId,
|
|
|
|
|
TrainLevelId = Const.OtherTrainLevelId,
|
|
|
|
|
UnitIds = person.UnitId,
|
|
|
|
|
WorkPostId = person.WorkPostId,
|
|
|
|
|
States = "1",
|
|
|
|
|
Cycle = "",
|
|
|
|
|
IsRetakeCourse = 1,
|
|
|
|
|
CheckType = info.CheckType.ToString(),
|
2025-04-19 16:21:39 +08:00
|
|
|
|
CheckId = info.CheckId,
|
|
|
|
|
CompanyTrainingItemId = info.CompanyTrainingItemId
|
2025-03-04 18:12:07 +08:00
|
|
|
|
};
|
|
|
|
|
AddPlan(planModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除培训明细
|
|
|
|
|
TrainingPlanItemService.DeletePlanItemByPlanId(planId);
|
|
|
|
|
//删除任务
|
|
|
|
|
TrainingTaskService.DeleteTaskByPlanId(planId);
|
|
|
|
|
|
|
|
|
|
string taskId = SQLHelper.GetNewID();
|
|
|
|
|
//新增培训任务
|
|
|
|
|
Model.Training_Task newTrainDetail = new Model.Training_Task
|
|
|
|
|
{
|
|
|
|
|
TaskId = taskId,
|
|
|
|
|
ProjectId = info.CurrProjectId,
|
|
|
|
|
PlanId = planId,
|
|
|
|
|
UserId = info.PersonId,
|
|
|
|
|
TaskDate = DateTime.Now,
|
|
|
|
|
States = Const.State_1,
|
|
|
|
|
};
|
|
|
|
|
TrainingTaskService.AddTask(newTrainDetail);
|
|
|
|
|
|
|
|
|
|
//新增培训任务明细
|
|
|
|
|
Model.Training_TaskItem newTaskItem = new Model.Training_TaskItem
|
|
|
|
|
{
|
|
|
|
|
TaskItemId = SQLHelper.GetNewID(),
|
|
|
|
|
TaskId = taskId,
|
|
|
|
|
PlanId = planId,
|
|
|
|
|
PersonId = info.PersonId,
|
|
|
|
|
TrainingItemCode = companyTrainingItem.CompanyTrainingItemCode,
|
|
|
|
|
TrainingItemName = companyTrainingItem.CompanyTrainingItemName,
|
|
|
|
|
AttachUrl = companyTrainingItem.AttachUrl,
|
|
|
|
|
CompanyTrainingItemId = info.CompanyTrainingItemId,
|
|
|
|
|
//LearnTime = trainingItem.LearningTime,
|
|
|
|
|
//VideoProgress = 0,
|
|
|
|
|
};
|
|
|
|
|
db.Training_TaskItem.InsertOnSubmit(newTaskItem);
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
|
|
|
|
|
//新增培训明细
|
|
|
|
|
Model.Training_PlanItem newPlanItem = new Model.Training_PlanItem
|
|
|
|
|
{
|
|
|
|
|
PlanItemId = SQLHelper.GetNewID(),
|
|
|
|
|
PlanId = planId,
|
|
|
|
|
CompanyTrainingItemId = info.CompanyTrainingItemId,
|
|
|
|
|
CompanyTrainingId = companyTrainingItem.CompanyTrainingId
|
|
|
|
|
};
|
|
|
|
|
TrainingPlanItemService.AddPlanItem(newPlanItem);
|
|
|
|
|
}
|
2025-04-19 16:21:39 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择教材生成培训计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
|
|
|
|
public static void SelectCompanyTrainingItemProducePlan(ProducePlanInfo info)
|
|
|
|
|
{
|
|
|
|
|
var companyTrainingItem = CompanyTrainingItemService.GetCompanyTrainingItemById(info.CompanyTrainingItemId);
|
|
|
|
|
var teachHour = companyTrainingItem.LearningTime / 3600;
|
|
|
|
|
|
|
|
|
|
//1、根据教材id查询适用岗位下相关人员;
|
|
|
|
|
var workPostIds = !string.IsNullOrWhiteSpace(companyTrainingItem.WorkPostIds) ? companyTrainingItem.WorkPostIds.Split(',').ToList() : new List<string>();
|
|
|
|
|
|
|
|
|
|
var workPostPersons = PersonService.GetPersonListByWorkPostIds(info.CurrProjectId, workPostIds);
|
|
|
|
|
//人员单位
|
|
|
|
|
var unitIds = workPostPersons.Any() ? String.Join(", ", workPostPersons.Select(x => x.UnitId).Distinct()) : string.Empty;
|
|
|
|
|
//2、根据教材id查询今年是否有相关培训计划(排除重修培训计划),如果有先删除;
|
|
|
|
|
var plans = GetThisYearPlanByCompanyTrainingItemId(info.CurrProjectId, info.CompanyTrainingItemId, DateTime.Now.Year);
|
|
|
|
|
if (plans.Any())
|
|
|
|
|
{//删除今年的培训计划
|
|
|
|
|
foreach (var plan in plans)
|
|
|
|
|
{
|
|
|
|
|
//删除培训明细
|
|
|
|
|
TrainingPlanItemService.DeletePlanItemByPlanId(plan.PlanId);
|
|
|
|
|
//删除任务
|
|
|
|
|
TrainingTaskService.DeleteTaskByPlanId(plan.PlanId);
|
|
|
|
|
DeletePlanById(plan.PlanId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//生成培训计划
|
|
|
|
|
string planId = SQLHelper.GetNewID();
|
|
|
|
|
string code = ProjectService.GetProjectByProjectId(info.CurrProjectId).ProjectCode + "-";
|
|
|
|
|
string planCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.Training_Plan", "PlanCode", info.CurrProjectId, code);
|
|
|
|
|
|
|
|
|
|
Model.Training_Plan planModel = new Model.Training_Plan
|
|
|
|
|
{
|
|
|
|
|
PlanId = planId,
|
|
|
|
|
PlanCode = planCode,
|
|
|
|
|
ProjectId = info.CurrProjectId,
|
|
|
|
|
DesignerId = info.CurrUserId,
|
|
|
|
|
DesignerDate = DateTime.Now,
|
|
|
|
|
PlanName = companyTrainingItem.CompanyTrainingItemName,
|
|
|
|
|
TrainContent = companyTrainingItem.CompanyTrainingItemName,
|
|
|
|
|
TrainStartDate = DateTime.Now,
|
|
|
|
|
TrainEndDate = info.TrainEndDate,
|
|
|
|
|
TeachHour = teachHour,
|
|
|
|
|
//TeachMan = companyTrainingItem.,
|
|
|
|
|
//TeachAddress = model.TeachAddress,
|
|
|
|
|
TrainTypeId = Const.EntryTrainTypeId,
|
|
|
|
|
TrainLevelId = Const.OtherTrainLevelId,
|
|
|
|
|
UnitIds = unitIds,
|
|
|
|
|
WorkPostId = companyTrainingItem.WorkPostIds,
|
|
|
|
|
States = "1",
|
|
|
|
|
Cycle = "",
|
|
|
|
|
//IsRetakeCourse = 0,
|
|
|
|
|
//CheckType = info.CheckType.ToString(),
|
|
|
|
|
//CheckId = info.CheckId,
|
|
|
|
|
CompanyTrainingItemId = info.CompanyTrainingItemId
|
|
|
|
|
};
|
|
|
|
|
AddPlan(planModel);
|
|
|
|
|
|
|
|
|
|
//新增培训明细
|
|
|
|
|
Model.Training_PlanItem newPlanItem = new Model.Training_PlanItem
|
|
|
|
|
{
|
|
|
|
|
PlanItemId = SQLHelper.GetNewID(),
|
|
|
|
|
PlanId = planId,
|
|
|
|
|
CompanyTrainingItemId = info.CompanyTrainingItemId,
|
|
|
|
|
CompanyTrainingId = companyTrainingItem.CompanyTrainingId
|
|
|
|
|
};
|
|
|
|
|
TrainingPlanItemService.AddPlanItem(newPlanItem);
|
|
|
|
|
|
|
|
|
|
List<Training_Task> newTasks = new List<Training_Task>();
|
|
|
|
|
List<Training_TaskItem> newTaskItems = new List<Training_TaskItem>();
|
|
|
|
|
//循环给人员添加任务
|
|
|
|
|
foreach (var person in workPostPersons)
|
|
|
|
|
{
|
|
|
|
|
string taskId = SQLHelper.GetNewID();
|
|
|
|
|
//新增培训任务
|
|
|
|
|
Model.Training_Task newTask = new Model.Training_Task
|
|
|
|
|
{
|
|
|
|
|
TaskId = taskId,
|
|
|
|
|
ProjectId = info.CurrProjectId,
|
|
|
|
|
PlanId = planId,
|
|
|
|
|
UserId = person.PersonId,
|
|
|
|
|
TaskDate = DateTime.Now,
|
|
|
|
|
States = Const.State_1,
|
|
|
|
|
};
|
|
|
|
|
newTasks.Add(newTask);
|
|
|
|
|
|
|
|
|
|
//新增培训任务明细
|
|
|
|
|
Model.Training_TaskItem newTaskItem = new Model.Training_TaskItem
|
|
|
|
|
{
|
|
|
|
|
TaskItemId = SQLHelper.GetNewID(),
|
|
|
|
|
TaskId = taskId,
|
|
|
|
|
PlanId = planId,
|
|
|
|
|
PersonId = person.PersonId,
|
|
|
|
|
TrainingItemCode = companyTrainingItem.CompanyTrainingItemCode,
|
|
|
|
|
TrainingItemName = companyTrainingItem.CompanyTrainingItemName,
|
|
|
|
|
AttachUrl = companyTrainingItem.AttachUrl,
|
|
|
|
|
CompanyTrainingItemId = info.CompanyTrainingItemId,
|
|
|
|
|
//LearnTime = trainingItem.LearningTime,
|
|
|
|
|
//VideoProgress = 0,
|
|
|
|
|
};
|
|
|
|
|
newTaskItems.Add(newTaskItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db.Training_Task.InsertAllOnSubmit(newTasks);
|
|
|
|
|
db.Training_TaskItem.InsertAllOnSubmit(newTaskItems);
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择人员生成培训计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
|
|
|
|
public static bool SelectPersonProducePlan(ProducePlanInfo info)
|
|
|
|
|
{
|
|
|
|
|
//1、根据人员获取人员基本信息
|
|
|
|
|
var person = PersonService.GetPersonById(info.PersonId);
|
|
|
|
|
if (string.IsNullOrWhiteSpace(person.WorkPostId))
|
|
|
|
|
{
|
2025-04-19 16:40:45 +08:00
|
|
|
|
return false;
|
2025-04-19 16:21:39 +08:00
|
|
|
|
}
|
|
|
|
|
//2、根据人员岗位Id查询今年入场培训计划
|
|
|
|
|
var lstPlan = GetPlanListByWorkPostId(info.CurrProjectId, person.WorkPostId);
|
|
|
|
|
foreach (var plan in lstPlan)
|
|
|
|
|
{
|
|
|
|
|
var task = (from x in db.Training_Task
|
|
|
|
|
where x.ProjectId == info.CurrProjectId && x.PlanId == plan.PlanId && x.UserId == person.PersonId
|
|
|
|
|
select x).ToList();
|
|
|
|
|
if (task.Any())
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
var companyTrainingItem = CompanyTrainingItemService.GetCompanyTrainingItemById(plan.CompanyTrainingItemId);
|
|
|
|
|
string taskId = SQLHelper.GetNewID();
|
|
|
|
|
//新增培训任务
|
|
|
|
|
Model.Training_Task newTask = new Model.Training_Task
|
|
|
|
|
{
|
|
|
|
|
TaskId = taskId,
|
|
|
|
|
ProjectId = info.CurrProjectId,
|
|
|
|
|
PlanId = plan.PlanId,
|
|
|
|
|
UserId = person.PersonId,
|
|
|
|
|
TaskDate = DateTime.Now,
|
|
|
|
|
States = Const.State_1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//新增培训任务明细
|
|
|
|
|
Model.Training_TaskItem newTaskItem = new Model.Training_TaskItem
|
|
|
|
|
{
|
|
|
|
|
TaskItemId = SQLHelper.GetNewID(),
|
|
|
|
|
TaskId = taskId,
|
|
|
|
|
PlanId = plan.PlanId,
|
|
|
|
|
PersonId = person.PersonId,
|
|
|
|
|
TrainingItemCode = companyTrainingItem.CompanyTrainingItemCode,
|
|
|
|
|
TrainingItemName = companyTrainingItem.CompanyTrainingItemName,
|
|
|
|
|
AttachUrl = companyTrainingItem.AttachUrl,
|
|
|
|
|
CompanyTrainingItemId = info.CompanyTrainingItemId,
|
|
|
|
|
//LearnTime = trainingItem.LearningTime,
|
|
|
|
|
//VideoProgress = 0,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
db.Training_Task.InsertOnSubmit(newTask);
|
|
|
|
|
db.Training_TaskItem.InsertOnSubmit(newTaskItem);
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-11-19 09:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|