using Learun.Util;
using System.Data;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
using System;
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.PersonnelManagement;
namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-01-29 17:31
/// 描 述:教师信息管理
///
public class EmpInfoController : MvcControllerBase
{
private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
private ArrangeLessonSyncIBLL arrangeLessonSyncIBLL = new ArrangeLessonSyncBLL();
private DataItemIBLL dataItemIBLL = new DataItemBLL();
private DepartmentIBLL departmentIBLL = new DepartmentBLL();
private DataSourceIBLL dataSourceIBLL = new DataSourceBLL();
private PM_ResumeIBLL pM_ResumeIBLL = new PM_ResumeBLL();
private PM_EducationExperienceIBLL pM_EducationExperienceIBLL = new PM_EducationExperienceBLL();
private PM_FamilySituationIBLL pM_FamilySituationIBLL = new PM_FamilySituationBLL();
private TeacherTrainIBLL teacherTrainIBLL = new TeacherTrainBLL();
private TeacherEncourgementIBLL teacherEncourgementIBLL = new TeacherEncourgementBLL();
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
private TeacherPunishmentIBLL teacherPunishmentIBLL = new TeacherPunishmentBLL();
#region 视图功能
///
/// 主页面
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
///
/// 主页面【大厂】
///
///
[HttpGet]
public ActionResult IndexOfDC()
{
return View();
}
///
/// 表单页
///
///
[HttpGet]
public ActionResult Form()
{
ViewBag.NewEmpId = Guid.NewGuid().ToString();
return View();
}
///
/// 导入页
///
///
[HttpGet]
public ActionResult ImportForm()
{
return View();
}
[HttpGet]
public ActionResult FormView()
{
return View();
}
public ActionResult FormAdd()
{
return View();
}
///
/// 表单页【修改部门、系部】
///
///
[HttpGet]
public ActionResult FormEdit()
{
return View();
}
///
/// 表单页【编辑部分内容】
///
///
[HttpGet]
public ActionResult FormModify()
{
return View();
}
///
/// 打印
///
///
[HttpGet]
public ActionResult Print(string keyValue)
{
var empInfo = empInfoIBLL.GetEmpInfoEntity(keyValue);
if (empInfo != null)
{
//性别
var genderNo = empInfo.GenderNo.ToString().ToLower();
empInfo.GenderNoName = dataItemIBLL.GetDetailList("usersexbit").FirstOrDefault(x => x.F_ItemValue == genderNo)?.F_ItemName;
//部门
empInfo.DepartmentName = departmentIBLL.GetEntity(empInfo.F_DepartmentId)?.F_FullName;
//民族
empInfo.NationalityNo = dataItemIBLL.GetDetailList("National").FirstOrDefault(x => x.F_ItemValue == empInfo.NationalityNo)?.F_ItemName;
//var nationality = dataSourceIBLL.GetDataTable("BCdNationality", "t.NationalityNo='" + empInfo.NationalityNo + "'");
//if (nationality != null && nationality.Rows.Count > 0)
//{
// empInfo.NationalityNo = nationality.Rows[0][1].ToString();
//}
//政治面貌
empInfo.PartyFaceNo = dataItemIBLL.GetDetailList("BCdPartyFace").FirstOrDefault(x => x.F_ItemValue == empInfo.PartyFaceNo)?.F_ItemName;
//最高学历
var highestRecord = dataSourceIBLL.GetDataTable("BCdCultureDegree", "t.CultureDegreeNo='" + empInfo.HighestRecord + "'");
if (highestRecord != null && highestRecord.Rows.Count > 0)
{
empInfo.HighestRecord = highestRecord.Rows[0][1].ToString();
}
//头像
empInfo.Photo = annexesFileIBLL.GetEntityByFolderId(empInfo.Photo)?.F_FilePath;
if (!string.IsNullOrEmpty(empInfo.Photo))
{
empInfo.Photo = empInfo.Photo.Substring(empInfo.Photo.IndexOf("Resource") - 1);
}
//本人简历
empInfo.PM_ResumeList = pM_ResumeIBLL.GetListByEmpId(empInfo.EmpId).OrderByDescending(x => x.RTime).ToList();
//教育经历
empInfo.PM_EducationExperienceList = pM_EducationExperienceIBLL.GetListByEmpId(empInfo.EmpId).OrderByDescending(x => x.ETime).ToList();
//家庭主要成员及重要社会关系
empInfo.PM_FamilySituationList = pM_FamilySituationIBLL.GetListByEmpId(empInfo.EmpId).ToList();
foreach (var item in empInfo.PM_FamilySituationList)
{
item.Application = dataItemIBLL.GetDetailList("FamilyRelation").FirstOrDefault(x => x.F_ItemValue == item.Application)?.F_ItemName;
item.PoliticalAffiliation = dataItemIBLL.GetDetailList("PolityStatus").FirstOrDefault(x => x.F_ItemValue == item.PoliticalAffiliation)?.F_ItemName;
}
//培训进修
empInfo.TeacherTrainList = teacherTrainIBLL.GetListByEmpId(empInfo.EmpId).OrderByDescending(x => x.TTStartTime).ToList();
//奖罚情况
empInfo.TeacherEncourgementList = teacherEncourgementIBLL.GetListByEmpId(empInfo.EmpId).OrderByDescending(x => x.EncourgeDate).ToList();
empInfo.TeacherPunishmentList = teacherPunishmentIBLL.GetListByEmpId(empInfo.EmpId).OrderByDescending(x => x.StartTime).ToList();
}
return View(empInfo);
}
#endregion
#region 获取数据
///
/// 获取页面显示列表数据
///
/// 查询参数
///
[HttpGet]
[AjaxOnly]
public ActionResult GetPageList(string pagination, string queryJson)
{
Pagination paginationobj = pagination.ToObject();
var data = empInfoIBLL.GetPageList(paginationobj, queryJson);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records
};
return Success(jsonData);
}
///
/// 获取表单数据
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetFormData(string keyValue)
{
var EmpInfoData = empInfoIBLL.GetEmpInfoEntity(keyValue);
if (EmpInfoData != null)
{
EmpInfoData.resume = WebHelper.HtmlDecode(EmpInfoData.resume);
}
var jsonData = new
{
EmpInfo = EmpInfoData,
};
return Success(jsonData);
}
///
/// 获取表单数据
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetEmpInfoEntityByEmpNo(string empNo)
{
var EmpInfoData = empInfoIBLL.GetEmpInfoEntityByEmpNo(empNo);
EmpInfoData.resume = WebHelper.HtmlDecode(EmpInfoData.resume);
return Success(EmpInfoData);
}
///
/// 根据部门获取人员
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetEmpInfoEntityByDepartment(string departmentId)
{
var EmpInfoData = empInfoIBLL.GetEmpInfoEntityByDepartment(departmentId);
return Success(EmpInfoData);
}
///
/// 获取表单数据
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetEmpInfoEntitiesByEmpName(string empName)
{
var EmpInfoList = empInfoIBLL.GetEmpInfoEntitiesByName(empName);
return Success(EmpInfoList);
}
#endregion
#region 提交数据
///
/// 生成帐号
///
///
[HttpPost]
[AjaxOnly]
public ActionResult Generate()
{
empInfoIBLL.GenerateAccout();
return Success("生成成功!");
}
[HttpPost]
[AjaxOnly]
public ActionResult UpdateAccount()
{
empInfoIBLL.UpdateAccount();
return Success("生成成功!");
}
[HttpPost]
[AjaxOnly]
public ActionResult Lock(string keyValue)
{
empInfoIBLL.Lock(keyValue);
empInfoIBLL.GenerateAccout(keyValue);
empInfoIBLL.UpdateAccount(keyValue);
return Success("审核成功!");
}
[HttpPost]
[AjaxOnly]
public ActionResult UnLock(string keyValue)
{
empInfoIBLL.UnLock(keyValue);
return Success("去审成功!");
}
///
/// 删除实体数据
/// 主键
///
///
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
empInfoIBLL.DeleteEntity(keyValue);
return Success("删除成功!");
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
[ValidateInput(false)]
public ActionResult SaveForm(string keyValue, string strEntity)
{
EmpInfoEntity entity = strEntity.ToObject();
entity.resume = WebHelper.HtmlEncode(entity.resume);
entity.SyncFlag = false;
var model = empInfoIBLL.GetEmpInfoEntityByEmpNo(entity.EmpNo);
var model_mobile = empInfoIBLL.GetEmpInfoEntityByMobile(entity.mobile);
if (string.IsNullOrEmpty(keyValue))
{
if (model != null)
{
return Fail("职工编号已存在!");
}
if (model_mobile != null)
{
return Fail("手机号已存在!");
}
}
else
{
if (model != null && model.EmpId != keyValue)
{
return Fail("职工编号已存在!");
}
if (model_mobile != null && model_mobile.EmpId != keyValue)
{
return Fail("手机号已存在!");
}
entity.SyncFlag = true;
//判断排课同步数据是否存在:若存在,清除同步数据;
var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
if (arrangeLessonSyncList.Any())
{
arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
}
else
{
entity.SyncFlag = false;
}
}
empInfoIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");
}
[HttpPost]
[AjaxOnly]
public ActionResult CheckAll()
{
empInfoIBLL.CheckAll();
empInfoIBLL.GenerateAccout();
empInfoIBLL.UpdateAccount();
return Success("全部审核成功!");
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
[ValidateInput(false)]
public ActionResult SaveFormEdit(string keyValue, string strEntity)
{
EmpInfoEntity entity = strEntity.ToObject();
empInfoIBLL.SaveEditEntity(keyValue, entity);
return Success("保存成功!");
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
[ValidateInput(false)]
public ActionResult SaveFormModify(string keyValue, string strEntity)
{
if (string.IsNullOrEmpty(keyValue))
{
return Fail("主键不存在!");
}
EmpInfoEntity entity = strEntity.ToObject();
entity.resume = WebHelper.HtmlEncode(entity.resume);
empInfoIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");
}
#endregion
}
}