自动生成培训计划
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
using Model;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Numerics;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
@@ -35,6 +33,18 @@ namespace BLL
|
||||
return db.Training_Plan.FirstOrDefault(e => e.CheckId == checkId && e.IsRetakeCourse == 1);
|
||||
}
|
||||
|
||||
/// <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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -52,6 +62,7 @@ namespace BLL
|
||||
PlanName = model.PlanName,
|
||||
TrainContent = model.TrainContent,
|
||||
TrainStartDate = model.TrainStartDate,
|
||||
TrainEndDate = model.TrainEndDate,
|
||||
TeachHour = model.TeachHour,
|
||||
TeachMan = model.TeachMan,
|
||||
TeachAddress = model.TeachAddress,
|
||||
@@ -64,7 +75,8 @@ namespace BLL
|
||||
Cycle = model.Cycle,
|
||||
IsRetakeCourse = model.IsRetakeCourse,
|
||||
CheckType = model.CheckType,
|
||||
CheckId = model.CheckId
|
||||
CheckId = model.CheckId,
|
||||
CompanyTrainingItemId = model.CompanyTrainingItemId
|
||||
};
|
||||
db.Training_Plan.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
@@ -82,8 +94,8 @@ namespace BLL
|
||||
isUpdate.PlanName = model.PlanName;
|
||||
isUpdate.TrainContent = model.TrainContent;
|
||||
isUpdate.TrainStartDate = model.TrainStartDate;
|
||||
isUpdate.TeachHour = model.TeachHour;
|
||||
isUpdate.TrainEndDate = model.TrainEndDate;
|
||||
isUpdate.TeachHour = model.TeachHour;
|
||||
isUpdate.TeachMan = model.TeachMan;
|
||||
isUpdate.TeachAddress = model.TeachAddress;
|
||||
isUpdate.TrainTypeId = model.TrainTypeId;
|
||||
@@ -96,6 +108,7 @@ namespace BLL
|
||||
isUpdate.IsRetakeCourse = model.IsRetakeCourse;
|
||||
isUpdate.CheckType = model.CheckType;
|
||||
isUpdate.CheckId = model.CheckId;
|
||||
isUpdate.CompanyTrainingItemId = model.CompanyTrainingItemId;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
@@ -123,12 +136,25 @@ namespace BLL
|
||||
return (from x in db.Training_Plan orderby x.PlanCode select x).ToList();
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查重修,并生成培训计划、任务
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
public static void RetakeCourseProducePlan(RetakeCourseProducePlanInfo info)
|
||||
public static void RetakeCourseProducePlan(ProducePlanInfo info)
|
||||
{
|
||||
var plan = GetPlanByCheckId(info.CheckId);
|
||||
var person = PersonService.GetPersonById(info.PersonId);
|
||||
@@ -157,7 +183,8 @@ namespace BLL
|
||||
Cycle = "",
|
||||
IsRetakeCourse = 1,
|
||||
CheckType = plan.CheckType,
|
||||
CheckId = plan.CheckId
|
||||
CheckId = plan.CheckId,
|
||||
CompanyTrainingItemId = info.CompanyTrainingItemId
|
||||
};
|
||||
UpdatePlan(planModel);
|
||||
}
|
||||
@@ -189,7 +216,8 @@ namespace BLL
|
||||
Cycle = "",
|
||||
IsRetakeCourse = 1,
|
||||
CheckType = info.CheckType.ToString(),
|
||||
CheckId = info.CheckId
|
||||
CheckId = info.CheckId,
|
||||
CompanyTrainingItemId = info.CompanyTrainingItemId
|
||||
};
|
||||
AddPlan(planModel);
|
||||
}
|
||||
@@ -239,5 +267,176 @@ namespace BLL
|
||||
};
|
||||
TrainingPlanItemService.AddPlanItem(newPlanItem);
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
bool result = false;
|
||||
//1、根据人员获取人员基本信息
|
||||
var person = PersonService.GetPersonById(info.PersonId);
|
||||
if (string.IsNullOrWhiteSpace(person.WorkPostId))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user