244 lines
9.3 KiB
C#
244 lines
9.3 KiB
C#
using Microsoft.Office.Interop.Excel;
|
|
using Microsoft.SqlServer.Dts.Runtime;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
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)
|
|
{
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 添加培训计划
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
public static void AddPlan(Model.Training_Plan model)
|
|
{
|
|
Model.Training_Plan newModel = new Model.Training_Plan
|
|
{
|
|
PlanId = model.PlanId,
|
|
PlanCode = model.PlanCode,
|
|
ProjectId = model.ProjectId,
|
|
DesignerId = model.DesignerId,
|
|
PlanName = model.PlanName,
|
|
TrainContent = model.TrainContent,
|
|
TrainStartDate = model.TrainStartDate,
|
|
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,
|
|
CheckId = model.CheckId
|
|
};
|
|
db.Training_Plan.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改培训计划
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
public static void UpdatePlan(Model.Training_Plan model)
|
|
{
|
|
Model.Training_Plan isUpdate = Funs.DB.Training_Plan.FirstOrDefault(e => e.PlanId == model.PlanId);
|
|
if (isUpdate != null)
|
|
{
|
|
isUpdate.PlanName = model.PlanName;
|
|
isUpdate.TrainContent = model.TrainContent;
|
|
isUpdate.TrainStartDate = model.TrainStartDate;
|
|
isUpdate.TeachHour = model.TeachHour;
|
|
isUpdate.TrainEndDate = model.TrainEndDate;
|
|
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;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除培训计划信息
|
|
/// </summary>
|
|
/// <param name="planId"></param>
|
|
public static void DeletePlanById(string planId)
|
|
{
|
|
Model.Training_Plan plan = db.Training_Plan.FirstOrDefault(e => e.PlanId == planId);
|
|
if (plan != null)
|
|
{
|
|
db.Training_Plan.DeleteOnSubmit(plan);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取培训计划列
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<Model.Training_Plan> GetPlanList()
|
|
{
|
|
return (from x in db.Training_Plan orderby x.PlanCode select x).ToList();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 检查重修,并生成培训计划、任务
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
public static void RetakeCourseProducePlan(RetakeCourseProducePlanInfo info)
|
|
{
|
|
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,
|
|
CheckId = plan.CheckId
|
|
};
|
|
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(),
|
|
CheckId = info.CheckId
|
|
};
|
|
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);
|
|
}
|
|
}
|
|
}
|