|
|
using Infrastructure.Data;
|
|
|
using Infrastructure.Extensions;
|
|
|
using Infrastructure.Web;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Newtonsoft.Json;
|
|
|
using Newtonsoft.Json.Serialization;
|
|
|
using NPOI.SS.UserModel;
|
|
|
using NPOI.XSSF.UserModel;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
using System.Globalization;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Reflection;
|
|
|
using TeacherExt.Entities;
|
|
|
using TeacherExt.Models;
|
|
|
|
|
|
namespace TeacherExt.Controllers
|
|
|
{
|
|
|
[Authorize]
|
|
|
[ApiController]
|
|
|
[Route("[controller]/[action]")]
|
|
|
public class HomeController : BaseController
|
|
|
{
|
|
|
private readonly IHostEnvironment _env;
|
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
private readonly AesHelper _helper;
|
|
|
private readonly IRepository<DictionaryItem> _directoryRepo;
|
|
|
private readonly IRepository<Person> _personRepo;
|
|
|
private readonly IRepository<PersonLogin> _loginRepo;
|
|
|
private readonly IRepository<Organization> _organizationRepo;
|
|
|
private readonly IRepository<CheckLog> _checkLogRepo;
|
|
|
|
|
|
public HomeController(IHostEnvironment env,
|
|
|
ILogger<HomeController> logger,
|
|
|
AesHelper helper,
|
|
|
IRepository<DictionaryItem> directoryRepo,
|
|
|
IRepository<Person> personRepo,
|
|
|
IRepository<Organization> organizationRepo,
|
|
|
IRepository<PersonLogin> loginRepo,
|
|
|
IRepository<CheckLog> checkLogRepo
|
|
|
)
|
|
|
{
|
|
|
this._env = env;
|
|
|
_logger = logger;
|
|
|
this._helper = helper;
|
|
|
this._directoryRepo = directoryRepo;
|
|
|
this._personRepo = personRepo;
|
|
|
this._organizationRepo = organizationRepo;
|
|
|
this._loginRepo = loginRepo;
|
|
|
this._checkLogRepo = checkLogRepo;
|
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
|
[Route("/")]
|
|
|
public IActionResult Index(QueryTeacherModel model)
|
|
|
{
|
|
|
var query = this._personRepo.ReadOnlyTable()
|
|
|
.Where(o => o.OrganId == model.bureau_id)
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.person_name), o => o.RealName.Contains(model.person_name))
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.RequestEditStatus), o => o.RequestEditStatus == model.RequestEditStatus)
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.CheckStatus), o => o.CheckStatus == model.CheckStatus)
|
|
|
.OrderBy(o => o.BureauId)
|
|
|
.ThenBy(o => o.CreateAt);
|
|
|
var count = query.Count();
|
|
|
var list = query
|
|
|
.Skip(model.PageSize * (model.PageNumber - 1))
|
|
|
.Take(model.PageSize)
|
|
|
.Select(o => new TeacherListItem
|
|
|
{
|
|
|
RequestEditStatus = o.RequestEditStatus,
|
|
|
CheckStatus = o.CheckStatus,
|
|
|
person_name = o.RealName,
|
|
|
sex = o.Sex,
|
|
|
nation = o.Nation,
|
|
|
placeofbirth = o.NativePlace,
|
|
|
person_id = o.Id,
|
|
|
})
|
|
|
.ToList();
|
|
|
var nations = this.GetNation();
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
item.nation_name = nations.GetText(item.nation);
|
|
|
}
|
|
|
model.TotalRow = count;
|
|
|
model.List.AddRange(list);
|
|
|
if (!model.HeaderSelectList.Any())
|
|
|
{
|
|
|
model.HeaderSelectList = typeof(EditTeacherModel).GetProperties()
|
|
|
.Select(o => o.GetCustomAttribute<ExcelHeaderAttribute>())
|
|
|
.Where(o => o != null)
|
|
|
.Select(o => new SelectListItem
|
|
|
{
|
|
|
Value = o.Header,
|
|
|
Text = o.Headers.Last().Key.Replace("\r\n", ""),
|
|
|
Selected = Request.Method.ToLower() == "get" ? true : model.Headers.Any(h => h == o.Header)
|
|
|
})
|
|
|
.ToList();
|
|
|
}
|
|
|
var organs = this._organizationRepo.ReadOnlyTable().Where(o => o.AreaId == 302705).ToList();
|
|
|
var bureau = organs.FirstOrDefault(o => o.Name == "城中区教育局");
|
|
|
bureau.Children = organs.Where(o => o.Name != "城中区教育局").ToList();
|
|
|
model.Organs.Add(bureau);
|
|
|
ViewData.SelectList(o => model.RequestEditStatus, () => this.GetRequestEditStatus(model.RequestEditStatus));
|
|
|
ViewData.SelectList(o => model.CheckStatus, () => this.GetCheckStatus(model.CheckStatus));
|
|
|
return Result(model);
|
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
|
[Route("/")]
|
|
|
public IActionResult Index(QueryTeacherModel model, bool isPost)
|
|
|
{
|
|
|
var result = this.Index(model);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
|
public IActionResult Edit(int id)
|
|
|
{
|
|
|
var person = this._personRepo.ReadOnlyTable().Where(o => o.Id == id).FirstOrDefault();
|
|
|
var organ = this._organizationRepo.ReadOnlyTable().Where(o => o.Id == person.OrganId).FirstOrDefault();
|
|
|
|
|
|
var model = person.To<EditTeacherModel>();
|
|
|
model.OrganName = organ.Name;
|
|
|
this.EntityToModel(person, model);
|
|
|
this.ToEditModel(person, model);
|
|
|
return Result<EditTeacherModel>(model);
|
|
|
}
|
|
|
|
|
|
private void EntityToModel(Person entity, EditTeacherModel model)
|
|
|
{
|
|
|
if (entity != null)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(entity.PhoneNumber))
|
|
|
{
|
|
|
model.PhoneNumber = _helper.Decrypt(entity.PhoneNumber);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(entity.IdNumber))
|
|
|
{
|
|
|
model.IdNumber = _helper.Decrypt(entity.IdNumber);
|
|
|
if (!string.IsNullOrWhiteSpace(model.IdNumber))
|
|
|
{
|
|
|
if (model.IdNumber.Length == 15 || model.IdNumber.Length == 18)
|
|
|
{
|
|
|
var value = model.IdNumber.Length == 15 ? $"19{model.IdNumber.Substring(6, 6)}" : model.IdNumber.Substring(6, 8);
|
|
|
var birthday = DateTime.ParseExact(value, "yyyyMMdd", CultureInfo.InvariantCulture);
|
|
|
model.Age = DateTime.Now.Year - birthday.Year;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (entity.WorkingTime.HasValue)
|
|
|
{
|
|
|
model.JobAgeYear = DateTime.Now.Year - model.WorkingTime.Value.Year;
|
|
|
model.JobAgeMonth = model.JobAgeYear * 12 + Math.Abs((model.WorkingTime.Value.Month - DateTime.Now.Month));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
|
public IActionResult Details(int id)
|
|
|
{
|
|
|
return this.Edit(id);
|
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
|
public IActionResult Details([FromForm] EditTeacherModel model)
|
|
|
{
|
|
|
ValidEditModel(model);
|
|
|
var entity = this._personRepo.Table().Where(o => o.Id == model.Id).FirstOrDefault();
|
|
|
var login = this._loginRepo.ReadOnlyTable().Where(o => o.PersonId == model.Id).FirstOrDefault();
|
|
|
if (ModelState.IsValid)
|
|
|
{
|
|
|
if (entity.CheckStatus != model.CheckStatus)
|
|
|
{
|
|
|
this._checkLogRepo.Add(new CheckLog
|
|
|
{
|
|
|
UpdateBy = User.Identity.Name,
|
|
|
UpdateAt = DateTime.Now,
|
|
|
LoginName = login.LoginName,
|
|
|
RealName = login.RealName,
|
|
|
FromStatus = entity.CheckStatus,
|
|
|
ToStatus = model.CheckStatus
|
|
|
});
|
|
|
}
|
|
|
entity.From(model);
|
|
|
this._personRepo.SaveChanges();
|
|
|
return Success();
|
|
|
}
|
|
|
this.EntityToModel(entity, model);
|
|
|
this.ToEditModel(entity, model);
|
|
|
return Result<EditTeacherModel>(model);
|
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
|
public IActionResult Edit([FromForm] EditTeacherModel model)
|
|
|
{
|
|
|
ValidEditModel(model);
|
|
|
var entity = this._personRepo.Table().Where(o => o.Id == model.Id).FirstOrDefault();
|
|
|
if (ModelState.IsValid)
|
|
|
{
|
|
|
entity.From(model);
|
|
|
this._personRepo.SaveChanges();
|
|
|
return Success();
|
|
|
}
|
|
|
this.EntityToModel(entity, model);
|
|
|
this.ToEditModel(entity, model);
|
|
|
return View(model);
|
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
|
public IActionResult History([FromQuery] QueryHistoryModel model)
|
|
|
{
|
|
|
var query = this._checkLogRepo.ReadOnlyTable()
|
|
|
.Where(o => o.PersonId == model.Id)
|
|
|
.OrderByDescending(o => o.UpdateAt);
|
|
|
model.TotalRow = query.Count();
|
|
|
var list = query.Skip(model.PageSize * (model.PageNumber - 1))
|
|
|
.OrderByDescending(o => o.UpdateAt)
|
|
|
.Take(model.PageSize)
|
|
|
.ToList();
|
|
|
model.List.AddRange(list);
|
|
|
return Result(model);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// https://github.com/nissl-lab/npoi/wiki/How-to-use-NPOI-on-Linux
|
|
|
/// apt-get install libgdiplus libc6-dev
|
|
|
/// cd /usr/lib
|
|
|
/// ln -s libgdiplus.so gdiplus.dll
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
public FileResult Export([FromForm] QueryTeacherModel model)
|
|
|
{
|
|
|
var template = Path.Combine(this._env.ContentRootPath, "wwwroot", "teacher.xlsx");
|
|
|
using var fs = System.IO.File.OpenRead(template);
|
|
|
var wk = new XSSFWorkbook(fs);
|
|
|
var sheet = wk.GetSheetAt(0);
|
|
|
this.ExportInternal(sheet, model);
|
|
|
using var ms = new MemoryStream();
|
|
|
wk.Write(ms);
|
|
|
return File(ms.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"在编汇总_{DateTime.Now.ToString("yyyy_MM-dd_HH_mm_ss")}.xlsx");
|
|
|
}
|
|
|
|
|
|
private void ValidEditModel(EditTeacherModel model)
|
|
|
{
|
|
|
if (!ModelState.IsValid)
|
|
|
{
|
|
|
if (model.IsJobAsMaxTitle.HasValue)
|
|
|
{
|
|
|
if (model.IsJobAsMaxTitle.Value)
|
|
|
{//最高职称聘任
|
|
|
if (ModelState.ContainsKey(nameof(model.JobAsNotMaxTitleReason)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.JobAsNotMaxTitleReason));
|
|
|
}
|
|
|
if (ModelState.ContainsKey(nameof(model.NotMaxTitle)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.NotMaxTitle));
|
|
|
}
|
|
|
if (ModelState.ContainsKey(nameof(model.NotMaxTitleStart)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.NotMaxTitleStart));
|
|
|
}
|
|
|
if (ModelState.ContainsKey(nameof(model.JobAsNotMaxTitleDate)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.JobAsNotMaxTitleDate));
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ModelState.ContainsKey(nameof(model.JobAsMaxTitleDate)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.JobAsMaxTitleDate));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(model.EducationGrade) && ModelState.ContainsKey(nameof(model.EducationGradeDate)))
|
|
|
{//不享受待遇
|
|
|
ModelState.Remove(nameof(model.EducationGradeDate));
|
|
|
}
|
|
|
if (model.HasPosition.HasValue)
|
|
|
{
|
|
|
if (model.HasPosition.Value)
|
|
|
{//在编在岗
|
|
|
if (ModelState.ContainsKey(nameof(model.NotOnPostReason)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.NotOnPostReason));
|
|
|
}
|
|
|
if (ModelState.ContainsKey(nameof(model.NotOnPostReasonDate)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.NotOnPostReasonDate));
|
|
|
}
|
|
|
if (model.IsMiddleLevel.HasValue)
|
|
|
{
|
|
|
if (model.IsMiddleLevel.Value)
|
|
|
{//中层
|
|
|
if (ModelState.ContainsKey(nameof(model.FrontTeacher)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.FrontTeacher));
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{//一线教师
|
|
|
if (ModelState.ContainsKey(nameof(model.Position)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.Position));
|
|
|
}
|
|
|
if (ModelState.ContainsKey(nameof(model.PositionStart)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.PositionStart));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{//在编不在岗
|
|
|
if (ModelState.ContainsKey(nameof(model.Position)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.Position));
|
|
|
}
|
|
|
if (ModelState.ContainsKey(nameof(model.PositionStart)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.PositionStart));
|
|
|
}
|
|
|
if (ModelState.ContainsKey(nameof(model.FrontTeacher)))
|
|
|
{
|
|
|
ModelState.Remove(nameof(model.FrontTeacher));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void ExportInternal(ISheet sheet, QueryTeacherModel model)
|
|
|
{
|
|
|
var personQuery = this._personRepo.ReadOnlyTable()
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.person_name), o => o.RealName.Contains(model.person_name))
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.RequestEditStatus), o => o.RequestEditStatus == model.RequestEditStatus)
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.CheckStatus), o => o.CheckStatus == model.CheckStatus);
|
|
|
|
|
|
var organQuery = this._organizationRepo.ReadOnlyTable();
|
|
|
var query = from person in personQuery
|
|
|
join organ in organQuery on person.BureauId equals organ.Id
|
|
|
join organ2 in organQuery on person.OrganId equals organ2.Id
|
|
|
where (person.IsUsed && person.BureauId == model.bureau_id)
|
|
|
orderby person.BureauId, person.CreateAt
|
|
|
select new { organ2.Name, person = person };
|
|
|
//
|
|
|
var nations = this.GetNation();
|
|
|
var titles = this.GetTitle();
|
|
|
var politics = this.GetPolitics();
|
|
|
var postTypes = this.GetPostType();
|
|
|
//
|
|
|
|
|
|
var style = NPOIHelper.CreateStyle(sheet, fontName: "宋体", fontSize: 11);
|
|
|
|
|
|
var headers = NPOIHelper.CreateHader(sheet, typeof(EditTeacherModel), model.Headers);
|
|
|
var list = query
|
|
|
.ToList()
|
|
|
.Select(o =>
|
|
|
{
|
|
|
var model = o.person.To<EditTeacherModel>();
|
|
|
this.EntityToModel(o.person, model);
|
|
|
model.OrganName = o.Name;
|
|
|
return model;
|
|
|
})
|
|
|
.ToList();
|
|
|
var rowIndex = 0;
|
|
|
var colIndex = -1;
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
{
|
|
|
var teacher = list[i];
|
|
|
var rowNumber = i + 1;
|
|
|
rowIndex = i + 4;
|
|
|
colIndex = -1;
|
|
|
var row = sheet.CreateRow(rowIndex);
|
|
|
teacher.DisplayOrder = rowNumber;
|
|
|
|
|
|
row.Export("A", headers, () => teacher.DisplayOrder)?.SetCell(++colIndex, style, teacher.DisplayOrder);
|
|
|
row.Export("B", headers, () => teacher.OrganName)?.SetCell(++colIndex, style, teacher.OrganName);
|
|
|
row.Export("C", headers, () => teacher.RealName)?.SetCell(++colIndex, style, teacher.RealName);
|
|
|
row.Export("D", headers, () => teacher.Sex)?.SetCell(++colIndex, style,teacher.Sex);
|
|
|
row.Export("E", headers, () => teacher.Birthday)?.SetCell(++colIndex, style, teacher.Birthday);
|
|
|
row.Export("F", headers, () => teacher.Age)?.SetCell(++colIndex, style, teacher.Age);
|
|
|
row.Export("G", headers, () => teacher.Nation)?.SetCell(++colIndex, style, nations.GetText(teacher.Nation));
|
|
|
row.Export("H", headers, () => teacher.NativePlace)?.SetCell(++colIndex, style, teacher.NativePlace);
|
|
|
row.Export("I", headers, () => teacher.PhoneNumber)?.SetCell(++colIndex, style, teacher.PhoneNumber);
|
|
|
row.Export("J", headers, () => teacher.IdNumber)?.SetCell(++colIndex, style, teacher.IdNumber);
|
|
|
row.Export("K", headers, () => teacher.WorkingTime)?.SetCell(++colIndex, style, teacher.WorkingTime);
|
|
|
row.Export("L", headers, () => teacher.TeachDate)?.SetCell(++colIndex, style, teacher.TeachDate.HasValue);
|
|
|
row.Export("M", headers, () => teacher.CurrentJobStart)?.SetCell(++colIndex, style, teacher.CurrentJobStart);
|
|
|
row.Export("N", headers, () => teacher.JobAgeYear)?.SetCell(++colIndex, style, teacher.JobAgeYear, teacher.WorkingTime.HasValue);
|
|
|
row.Export("O", headers, () => teacher.JobAgeMonth)?.SetCell(++colIndex, style, teacher.JobAgeMonth, teacher.WorkingTime.HasValue);
|
|
|
row.Export("P", headers, () => teacher.Politics)?.SetCell(++colIndex, style,politics.GetText( teacher.Politics));
|
|
|
row.Export("Q", headers, () => teacher.JoinPartyDate)?.SetCell(++colIndex, style, teacher.JoinPartyDate);
|
|
|
row.Export("R", headers, () => teacher.MaxTitle)?.SetCell(++colIndex, style,titles.GetText(teacher.MaxTitle));
|
|
|
row.Export("S", headers, () => teacher.MaxTitleStart)?.SetCell(++colIndex, style, teacher.MaxTitleStart);
|
|
|
row.Export("T", headers, () => teacher.JobAsMaxTitleDate)?.SetCell(++colIndex, style, teacher.JobAsMaxTitleDate, teacher.IsJobAsMaxTitle.HasValue && teacher.IsJobAsMaxTitle.Value);
|
|
|
row.Export("U", headers, () => teacher.JobAsNotMaxTitleReason)?.SetCell(++colIndex, style, teacher.JobAsNotMaxTitleReason, teacher.IsJobAsMaxTitle.HasValue && !teacher.IsJobAsMaxTitle.Value);
|
|
|
row.Export("V", headers, () => teacher.NotMaxTitle)?.SetCell(++colIndex, style,titles.GetText(teacher.NotMaxTitle), teacher.IsJobAsMaxTitle.HasValue && !teacher.IsJobAsMaxTitle.Value);
|
|
|
row.Export("W", headers, () => teacher.NotMaxTitleStart)?.SetCell(++colIndex, style, teacher.NotMaxTitleStart, teacher.IsJobAsMaxTitle.HasValue && !teacher.IsJobAsMaxTitle.Value);
|
|
|
row.Export("X", headers, () => teacher.JobAsNotMaxTitleDate)?.SetCell(++colIndex, style, teacher.JobAsNotMaxTitleDate, teacher.IsJobAsMaxTitle.HasValue && !teacher.IsJobAsMaxTitle.Value);
|
|
|
row.Export("Y", headers, () => teacher.PostType)?.SetCell(++colIndex, style, postTypes.GetText(teacher.PostType));
|
|
|
row.Export("Z", headers, () => teacher.PostGrade)?.SetCell(++colIndex, style, teacher.PostGrade);
|
|
|
|
|
|
row.Export("AA", headers, () => teacher.CurrentPostGradeStart)?.SetCell(++colIndex, style, teacher.CurrentPostGradeStart);
|
|
|
row.Export("AB", headers, () => teacher.EducationGrade)?.SetCell(++colIndex, style, teacher.EducationGrade);
|
|
|
row.Export("AC", headers, () => teacher.EducationGradeDate)?.SetCell(++colIndex, style, teacher.EducationGradeDate, !string.IsNullOrEmpty(teacher.EducationGrade));
|
|
|
row.Export("AD", headers, () => teacher.FullTimeSchool)?.SetCell(++colIndex, style, teacher.FullTimeSchool);
|
|
|
row.Export("AE", headers, () => teacher.FullTimeSchoolType)?.SetCell(++colIndex, style, teacher.FullTimeSchoolType);
|
|
|
row.Export("AF", headers, () => teacher.FullTimeSchoolMajor)?.SetCell(++colIndex, style, teacher.FullTimeSchoolMajor);
|
|
|
row.Export("AG", headers, () => teacher.FullTimeSchoolEducation)?.SetCell(++colIndex, style, teacher.FullTimeSchoolEducation);
|
|
|
row.Export("AH", headers, () => teacher.FullTimeSchoolEducationDate)?.SetCell(++colIndex, style, teacher.FullTimeSchoolEducationDate);
|
|
|
row.Export("AI", headers, () => teacher.JobTimeSchool)?.SetCell(++colIndex, style, teacher.JobTimeSchool);
|
|
|
row.Export("AJ", headers, () => teacher.JobTimeSchoolType)?.SetCell(++colIndex, style, teacher.JobTimeSchoolType);
|
|
|
row.Export("AK", headers, () => teacher.JobTimeSchoolMajor)?.SetCell(++colIndex, style, teacher.JobTimeSchoolMajor);
|
|
|
row.Export("AL", headers, () => teacher.JobTimeSchoolEducation)?.SetCell(++colIndex, style, teacher.JobTimeSchoolEducation);
|
|
|
row.Export("AM", headers, () => teacher.JobTimeSchoolEducationDate)?.SetCell(++colIndex, style, teacher.JobTimeSchoolEducationDate);
|
|
|
row.Export("AN", headers, () => teacher.MaxEducation)?.SetCell(++colIndex, style, teacher.MaxEducation);
|
|
|
row.Export("AO", headers, () => teacher.MaxDegree)?.SetCell(++colIndex, style, teacher.MaxDegree);
|
|
|
row.Export("AP", headers, () => teacher.IsClassTeacher)?.SetCell(++colIndex, style, teacher.IsClassTeacher ? "是" : "否");
|
|
|
row.Export("AQ", headers, () => teacher.MainTeachPeriod)?.SetCell(++colIndex, style, teacher.MainTeachPeriod);
|
|
|
row.Export("AR", headers, () => teacher.MainTeachSubject)?.SetCell(++colIndex, style, teacher.MainTeachSubject);
|
|
|
row.Export("AS", headers, () => teacher.MainTeachGrade)?.SetCell(++colIndex, style, teacher.MainTeachGrade);
|
|
|
row.Export("AT", headers, () => teacher.OtherTeachPeriod)?.SetCell(++colIndex, style, teacher.OtherTeachPeriod);
|
|
|
row.Export("AU", headers, () => teacher.OtherTeachSubject)?.SetCell(++colIndex, style, teacher.OtherTeachSubject);
|
|
|
row.Export("AV", headers, () => teacher.Position)?.SetCell(++colIndex, style, teacher.Position, teacher.HasPosition.HasValue && teacher.HasPosition.Value && teacher.IsMiddleLevel.HasValue && teacher.IsMiddleLevel.Value);
|
|
|
row.Export("AW", headers, () => teacher.PositionStart)?.SetCell(++colIndex, style, teacher.PositionStart, teacher.HasPosition.HasValue && teacher.HasPosition.Value && teacher.IsMiddleLevel.HasValue && teacher.IsMiddleLevel.Value);
|
|
|
row.Export("AX", headers, () => teacher.FrontTeacher)?.SetCell(++colIndex, style, teacher.FrontTeacher, teacher.HasPosition.HasValue && teacher.HasPosition.Value && teacher.IsMiddleLevel.HasValue && !teacher.IsMiddleLevel.Value);
|
|
|
row.Export("AY", headers, () => teacher.NotOnPostReason)?.SetCell(++colIndex, style, teacher.NotOnPostReason, teacher.HasPosition.HasValue && !teacher.HasPosition.Value);
|
|
|
row.Export("AZ", headers, () => teacher.NotOnPostReasonDate)?.SetCell(++colIndex, style, teacher.NotOnPostReasonDate, teacher.HasPosition.HasValue && !teacher.HasPosition.Value);
|
|
|
|
|
|
row.Export("BA", headers, () => teacher.TeacherCardType)?.SetCell(++colIndex, style, teacher.TeacherCardType);
|
|
|
row.Export("BB", headers, () => teacher.TeacherCardSubject)?.SetCell(++colIndex, style, teacher.TeacherCardSubject);
|
|
|
row.Export("BC", headers, () => teacher.TeacherCardLangLevel)?.SetCell(++colIndex, style, teacher.TeacherCardLangLevel);
|
|
|
row.Export("BD", headers, () => teacher.CurrentAddressArea)?.SetCell(++colIndex, style, teacher.CurrentAddressArea);
|
|
|
row.Export("BE", headers, () => teacher.AddressDetails)?.SetCell(++colIndex, style, teacher.AddressDetails);
|
|
|
row.Export("BF", headers, () => teacher.Comment)?.SetCell(++colIndex, style, "");
|
|
|
}
|
|
|
NPOIHelper.SetColWidth(3, sheet);
|
|
|
}
|
|
|
|
|
|
private void ToEditModel(Person entity, EditTeacherModel model)
|
|
|
{
|
|
|
ViewData.SelectList(o => model.Nation, () => this.GetNation(model.Nation));
|
|
|
ViewData.SelectList(o => model.Politics, () => this.GetPolitics(model.Politics));
|
|
|
ViewData.SelectList(o => model.MaxTitle, () => this.GetTitle(model.MaxTitle));
|
|
|
ViewData.SelectList(o => model.NotMaxTitle, () => this.GetTitle(model.MaxTitle));
|
|
|
//
|
|
|
ViewData.SelectList(o => model.Nationality, () => this.GetSelectListFromDirectory("NATIONALITY", model.Nationality));
|
|
|
ViewData.SelectList(o => model.UserType, () => this.GetSelectListFromDirectory("PERSON_STATUS", model.UserType));
|
|
|
ViewData.SelectList(o => model.PostType, () => this.GetPostType(model.PostType));
|
|
|
ViewData.SelectList(o => model.MaritalStatus, () => this.GetSelectListFromDirectory("MARITAL_STATUS", model.MaritalStatus));
|
|
|
ViewData.SelectList(o => model.MaxDegree, () => this.GetSelectListFromDirectory("DEGREE", model.MaxDegree));
|
|
|
ViewData.SelectList(o => model.FirstEducation, () => this.GetSelectListFromDirectory("DEGREE", model.FirstEducation));
|
|
|
ViewData.SelectList(o => model.MaxEducation, () => this.GetSelectListFromDirectory("DEGREE", model.MaxEducation));
|
|
|
ViewData.SelectList(o => model.Position, () => this.GetSelectListFromDirectory("ADMINISTRATIVE_POST", model.Position));
|
|
|
//
|
|
|
ViewData.SelectList(o => model.FullTimeSchoolEducation, () => this.GetSelectListFromDirectory("DEGREE", model.MaxDegree));
|
|
|
ViewData.SelectList(o => model.JobTimeSchoolEducation, () => this.GetSelectListFromDirectory("DEGREE", model.MaxDegree));
|
|
|
////
|
|
|
ViewData.SelectList(o => model.Sex, () => this.GetSex(model.Sex));
|
|
|
ViewData.SelectList(o => model.MainTeachPeriod, () => this.GetTeachPeriod(model.MainTeachPeriod));
|
|
|
ViewData.SelectList(o => model.MainTeachSubject, () => this.GetTeachSubject(model.MainTeachSubject));
|
|
|
ViewData.SelectList(o => model.OtherTeachPeriod, () => this.GetTeachPeriod(model.OtherTeachPeriod));
|
|
|
ViewData.SelectList(o => model.OtherTeachSubject, () => this.GetTeachSubject(model.OtherTeachSubject));
|
|
|
//
|
|
|
ViewData.SelectList(o => model.RequestEditStatus, () => this.GetRequestEditStatus(model.RequestEditStatus));
|
|
|
ViewData.SelectList(o => model.CheckStatus, () => this.GetCheckStatus(model.CheckStatus));
|
|
|
ViewData.SelectList(o => model.PostGrade, () => this.GetPostGrade(model.PostGrade));
|
|
|
ViewData.SelectList(o => model.EducationGrade, () => this.GetEducationGrade(model.EducationGrade));
|
|
|
ViewData.SelectList(o => model.FullTimeSchoolType, () => this.GetFullTimeSchoolType(model.FullTimeSchoolType));
|
|
|
ViewData.SelectList(o => model.JobTimeSchoolType, () => this.GetFullTimeSchoolType(model.JobTimeSchoolType));
|
|
|
ViewData.SelectList(o => model.MainTeachGrade, () => this.GetTeachGrade(model.MainTeachGrade));
|
|
|
|
|
|
ViewData.SelectList(o => model.FrontTeacher, () => this.GetFrontTeacher(model.FrontTeacher));
|
|
|
ViewData.SelectList(o => model.NotOnPostReason, () => this.GetNotOnPostReason(model.NotOnPostReason));
|
|
|
ViewData.SelectList(o => model.TeacherCardType, () => this.GetTeacherCardType(model.TeacherCardType));
|
|
|
ViewData.SelectList(o => model.TeacherCardLangLevel, () => this.GetLangLevel(model.TeacherCardLangLevel));
|
|
|
ViewData.SelectList(o => model.CurrentAddressArea, () => this.GetAddressArea(model.CurrentAddressArea));
|
|
|
}
|
|
|
|
|
|
private SelectList GetRequestEditStatus(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"未申请",
|
|
|
"已申请",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetCheckStatus(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"未提交",
|
|
|
"待审核",
|
|
|
"审核失败",
|
|
|
"审核成功",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
//private SelectList GetUserType(string selected)
|
|
|
//{
|
|
|
// return new string[] {
|
|
|
// "在编教师",
|
|
|
// "区聘教师",
|
|
|
// "校聘教师",
|
|
|
// }.ToSelectList(selected);
|
|
|
//}
|
|
|
|
|
|
private SelectList GetSex(object selected=null)
|
|
|
{
|
|
|
return this.GetSelectListFromDirectory("SEX2", selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetNation(object selected = null)
|
|
|
{
|
|
|
return this.GetSelectListFromDirectory("ETHNIC_GROUP", selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetPolitics(object selected = null)
|
|
|
{
|
|
|
return this.GetSelectListFromDirectory("POLITICALSTATUS", selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetTitle(object selected = null)
|
|
|
{
|
|
|
return this.GetSelectListFromDirectory("PROFESSIONAL_TITLE", selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetPostType(object selected = null)
|
|
|
{
|
|
|
return this.GetSelectListFromDirectory("POST_CATEGORY", selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetPostGrade(object selected=null)
|
|
|
{
|
|
|
return this.GetSelectListFromDirectory("POSTGRADE2", selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetEducationGrade(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"专技十一级",
|
|
|
"专技十二级",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetFullTimeSchoolType(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"师范院校师范专业",
|
|
|
"师范院校非师范专业",
|
|
|
"非师范院校师范专业",
|
|
|
"非师范院校非师范专业",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
//private SelectList GetEducation(string selected)
|
|
|
//{
|
|
|
// return new string[] {
|
|
|
// "研究生博士教育",
|
|
|
// "研究生硕士教育",
|
|
|
// "大学本科教育",
|
|
|
// "大学专科教育",
|
|
|
// "中等专业教育",
|
|
|
// "普通高级中学教育",
|
|
|
// "初级中学教育",
|
|
|
// "小学教育",
|
|
|
// "其他",
|
|
|
// }.ToSelectList(selected);
|
|
|
//}
|
|
|
|
|
|
//private SelectList GetDegree(string selected)
|
|
|
//{
|
|
|
// return new string[] {
|
|
|
// "学士学位",
|
|
|
// "硕士学位",
|
|
|
// "博士学位",
|
|
|
// }.ToSelectList(selected);
|
|
|
//}
|
|
|
private SelectList GetTeachPeriod(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"学前教育",
|
|
|
"小学",
|
|
|
"普通初中",
|
|
|
"无",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetTeachSubject(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"语文",
|
|
|
"数学",
|
|
|
"英语",
|
|
|
"音乐",
|
|
|
"体育",
|
|
|
"美术",
|
|
|
"科学",
|
|
|
"书法",
|
|
|
"信息技术",
|
|
|
"政治",
|
|
|
"历史",
|
|
|
"地理",
|
|
|
"物理",
|
|
|
"化学",
|
|
|
"生物",
|
|
|
"幼教全科",
|
|
|
"心理健康",
|
|
|
"综合实践课",
|
|
|
"无",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetTeachGrade(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"九年级",
|
|
|
"八年级",
|
|
|
"七年级",
|
|
|
"六年级",
|
|
|
"五年级",
|
|
|
"四年级",
|
|
|
"三年级",
|
|
|
"二年级",
|
|
|
"一年级",
|
|
|
"幼儿园大班",
|
|
|
"幼儿园中班",
|
|
|
"幼儿园小班",
|
|
|
"无",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
//private SelectList GetPosition(string selected)
|
|
|
//{
|
|
|
// return new string[] {
|
|
|
// "校长",
|
|
|
// "副校长",
|
|
|
// "党支部副书记",
|
|
|
// "办公室主任",
|
|
|
// "办公室副主任",
|
|
|
// "教导处主任",
|
|
|
// "教导处副主任",
|
|
|
// "德育主任",
|
|
|
// "团支部书记",
|
|
|
// "大队辅导员",
|
|
|
// "工会主席",
|
|
|
// "总务主任",
|
|
|
// "总务副主任",
|
|
|
// "无",
|
|
|
// }.ToSelectList(selected);
|
|
|
//}
|
|
|
|
|
|
private SelectList GetFrontTeacher(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"一线教师",
|
|
|
"无",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetNotOnPostReason(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"长期病假",
|
|
|
"产假",
|
|
|
"挂职",
|
|
|
"支教",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetTeacherCardType(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"幼儿园教师资格",
|
|
|
"小学教师资格",
|
|
|
"初级中学教师资格",
|
|
|
"高级中学教师资格",
|
|
|
"中等职业学校教师资格",
|
|
|
"中等职业学校实习指导教师资格",
|
|
|
"高等学校教师资格",
|
|
|
"无",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetLangLevel(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"一级甲等",
|
|
|
"一级乙等",
|
|
|
"二级甲等",
|
|
|
"二级乙等",
|
|
|
"三级甲等",
|
|
|
"无",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
private SelectList GetAddressArea(string selected)
|
|
|
{
|
|
|
return new string[] {
|
|
|
"城中区",
|
|
|
"城北区",
|
|
|
"城西区",
|
|
|
"城东区",
|
|
|
}.ToSelectList(selected);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 民族:ETHNIC_GROUP
|
|
|
/// </summary>
|
|
|
/// <param name="category"></param>
|
|
|
/// <param name="selected"></param>
|
|
|
/// <returns></returns>
|
|
|
private SelectList GetSelectListFromDirectory(string category, object selected)
|
|
|
{
|
|
|
var list = this._directoryRepo.ReadOnlyTable()
|
|
|
.Where(o => o.IsUsed)
|
|
|
.Where(o => o.Category == category)
|
|
|
.OrderBy(o => o.Order)
|
|
|
.Select(o => new SelectListItem { Text = o.Remark, Value = o.Code })
|
|
|
.ToList();
|
|
|
return new SelectList(list, nameof(SelectListItem.Value), nameof(SelectListItem.Text), selected);
|
|
|
}
|
|
|
|
|
|
private List<DictionaryItem> GetItems(string category)
|
|
|
{
|
|
|
return this._directoryRepo.ReadOnlyTable()
|
|
|
.Where(o => o.IsUsed)
|
|
|
.Where(o => o.Category == category)
|
|
|
.ToList();
|
|
|
}
|
|
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
|
|
protected IActionResult Success()
|
|
|
{
|
|
|
if (this.IsJsonRequest())
|
|
|
{
|
|
|
return this.NoContent();
|
|
|
}
|
|
|
return RedirectTo();
|
|
|
}
|
|
|
|
|
|
private IActionResult Result<T>(T model)
|
|
|
{
|
|
|
if (this.IsJsonRequest())
|
|
|
{
|
|
|
return Json(new
|
|
|
{
|
|
|
schema = this.GetJsonSchema<T>(),
|
|
|
model,
|
|
|
errors = ModelState.Where(o => o.Value.ValidationState == ModelValidationState.Invalid),
|
|
|
data = ViewData
|
|
|
}, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
|
|
|
}
|
|
|
return View(model);
|
|
|
}
|
|
|
}
|
|
|
} |