1270 lines
52 KiB
C#
1270 lines
52 KiB
C#
using BLL;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web.Http;
|
||
using SgManager.AI;
|
||
using System.Configuration;
|
||
using Newtonsoft.Json.Linq;
|
||
using Newtonsoft.Json;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Text;
|
||
using System.Web;
|
||
|
||
namespace WebAPI.Controllers
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public class PersonController : ApiController
|
||
{
|
||
#region 根据personid获取人员信息
|
||
/// <summary>
|
||
/// 根据personid获取人员信息
|
||
/// </summary>
|
||
/// <param name="personId"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonByPersonId(string personId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.data = APIPersonService.getPersonByPersonId(personId);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据identityCard获取人员信息
|
||
/// <summary>
|
||
/// 根据identityCard获取人员信息
|
||
/// </summary>
|
||
/// <param name="identityCard"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonByIdentityCard(string identityCard)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.data = APIPersonService.getPersonByPersonId(identityCard);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据projectId、identityCard获取人员信息
|
||
/// <summary>
|
||
/// 根据projectId、identityCard获取人员信息
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="identityCard"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonByProjectIdIdentityCard(string projectId, string identityCard)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.data = APIPersonService.getPersonByProjectIdIdentityCard(projectId, identityCard);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据projectId、unitid获取人员信息
|
||
/// <summary>
|
||
/// 根据projectId、unitid获取人员信息
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId"></param>
|
||
/// <param name="pageIndex"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonByProjectIdUnitId(string projectId, string unitId, int pageIndex)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = APIPersonService.getPersonByProjectIdUnitId(projectId, unitId);
|
||
int pageCount = getDataList.Count;
|
||
if (pageCount > 0 && pageIndex > 0)
|
||
{
|
||
getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||
}
|
||
responeData.data = new { pageCount, getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取在岗、离岗、待审人员数量
|
||
/// <summary>
|
||
/// 获取在岗、离岗、待审人员列表
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId"></param>
|
||
/// <param name="states"></param>
|
||
/// <param name="strUnitId"></param>
|
||
/// <param name="strWorkPostId"></param>
|
||
/// <param name="strParam"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonStatesCount(string projectId, string unitId, string states, string strUnitId, string strWorkPostId, string strParam)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var getViews = from x in db.SitePerson_Person
|
||
where x.ProjectId == projectId && (strUnitId == null || x.UnitId == strUnitId)
|
||
&& (strWorkPostId == null || x.WorkPostId == strWorkPostId)
|
||
select x;
|
||
if (unitId != CommonService.GetThisUnitId() && !string.IsNullOrEmpty(unitId))
|
||
{
|
||
getViews = getViews.Where(x => x.UnitId == unitId);
|
||
}
|
||
if (!string.IsNullOrEmpty(strParam))
|
||
{
|
||
getViews = getViews.Where(x => x.PersonName.Contains(strParam) || x.IdentityCard.Contains(strParam));
|
||
}
|
||
int tatalCount = getViews.Count();
|
||
//在审
|
||
int count0 = getViews.Where(x => x.IsUsed == false && !x.AuditorDate.HasValue).Count();
|
||
//在岗
|
||
int count1 = getViews.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now)).Count();
|
||
//离岗
|
||
int count2 = getViews.Where(x => x.IsUsed == true && x.OutTime <= DateTime.Now).Count();
|
||
//打回
|
||
int count3 = getViews.Where(x => x.IsUsed == false && x.AuditorDate.HasValue).Count();
|
||
responeData.data = new { tatalCount, count0, count1, count2, count3 };
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取在岗、离岗、待审人员列表
|
||
/// <summary>
|
||
/// 获取在岗、离岗、待审人员列表
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId">当前人单位ID</param>
|
||
/// <param name="states">0待审1在岗2离岗</param>
|
||
/// <param name="strUnitId">查询单位</param>
|
||
/// <param name="strWorkPostId">查询岗位</param>
|
||
/// <param name="strParam">查询条件</param>
|
||
/// <param name="pageIndex"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonListByProjectIdStates(string projectId, string unitId, string states, string strUnitId, string strWorkPostId, string strParam, int pageIndex)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = APIPersonService.getPersonListByProjectIdStates(projectId, unitId, states, strUnitId, strWorkPostId, strParam, pageIndex);
|
||
int pageCount = APIPersonService.getPersonListCount;
|
||
responeData.data = new { pageCount, getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据identityCard获取人员培训考试信息
|
||
/// <summary>
|
||
/// 根据identityCard获取人员培训考试信息
|
||
/// </summary>
|
||
/// <param name="identityCard"></param>
|
||
/// <param name="projectId"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonTestRecoedByIdentityCard(string identityCard, string projectId = null)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.data = APIPersonService.getPersonTestRecoedByIdentityCard(identityCard, projectId);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据identityCard获取人员资质信息
|
||
/// <summary>
|
||
/// 根据identityCard获取人员资质信息
|
||
/// </summary>
|
||
/// <param name="identityCard"></param>
|
||
/// <param name="projectId"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonQualityByIdentityCard(string identityCard, string projectId = null)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.data = APIPersonService.getPersonQualityByIdentityCard(identityCard, projectId);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据projectId、unitid获取特岗人员资质各状态数
|
||
/// <summary>
|
||
/// 根据projectId、unitid获取特岗人员资质各状态数
|
||
/// </summary>
|
||
/// <param name="projectId">项目ID</param>
|
||
/// <param name="unitId">单位ID</param>
|
||
/// <returns>人员资质数量</returns>
|
||
public Model.ResponeData getPersonQualityCount(string projectId, string unitId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var getDataList = db.View_QualityAudit_PersonQuality.Where(x => x.ProjectId == projectId && x.CertificateId != null);
|
||
if (ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(projectId, unitId))
|
||
{
|
||
getDataList = getDataList.Where(x => x.UnitId == unitId);
|
||
}
|
||
//总数
|
||
int tatalCount = getDataList.Count();
|
||
//过期
|
||
int count1 = getDataList.Where(x => x.LimitDate < DateTime.Now).Count();
|
||
//即将过期
|
||
int count2 = getDataList.Where(x => x.LimitDate >= DateTime.Now && x.LimitDate < DateTime.Now.AddMonths(1)).Count();
|
||
|
||
responeData.data = new { tatalCount, count1, count2 };
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据projectId、unitid获取特岗人员资质信息
|
||
/// <summary>
|
||
/// 根据projectId、unitid获取特岗人员资质信息
|
||
/// </summary>
|
||
/// <param name="projectId">项目ID</param>
|
||
/// <param name="unitId">单位ID</param>
|
||
/// <param name="type">数据类型0-已过期;1-即将过期;2-无证;3-待审核;4-已审核;-1打回</param>
|
||
/// <param name="pageIndex">页码</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonQualityByProjectIdUnitId(string projectId, string unitId, string type, int pageIndex)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = APIPersonService.getPersonQualityByProjectIdUnitId(projectId, unitId, type);
|
||
int pageCount = getDataList.Count();
|
||
if (pageCount > 0 && pageIndex > 0)
|
||
{
|
||
getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||
}
|
||
responeData.data = new { pageCount, getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 保存 人员资质信息 QualityAudit_PersonQuality
|
||
/// <summary>
|
||
/// 保存Meeting
|
||
/// </summary>
|
||
/// <param name="personQuality">人员资质信息</param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SavePersonQuality([FromBody] Model.PersonQualityItem personQuality)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
APIPersonService.SavePersonQuality(personQuality);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据项目\单位\岗位\培训类型获取项目培训\考试人员信息
|
||
/// <summary>
|
||
/// 查询人员信息实体类
|
||
/// </summary>
|
||
public class SearchModel {
|
||
public string projectId { get; set; }
|
||
public string unitIds { get; set; }
|
||
public string workPostIds { get; set; }
|
||
public string trainTypeId { get; set; }
|
||
public string unitId { get; set; }
|
||
public int pageIndex { get; set; } = 0;
|
||
public string inTimeStart { get; set; }
|
||
public string inTimeEnd { get; set; }
|
||
public string personName { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据项目\单位\岗位\培训类型获取项目培训\考试人员信息
|
||
/// </summary>
|
||
/// <param name="model">查询类</param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData getTrainingPersonListByTrainTypeId([FromBody] SearchModel model)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(model.unitId))
|
||
{
|
||
if (model.pageIndex == 0)
|
||
{
|
||
responeData.data = APIPersonService.getTrainingPersonListByTrainTypeId(model.projectId, model.unitIds, model.workPostIds, model.trainTypeId, model.pageIndex, model.inTimeStart,model.inTimeEnd, model.personName).
|
||
OrderBy(x => x.WorkPostName).ThenBy(x => x.ProjectName);
|
||
}
|
||
else {
|
||
var getDataList = APIPersonService.getTrainingPersonListByTrainTypeId(model.projectId, model.unitIds, model.workPostIds, model.trainTypeId, model.pageIndex, model.inTimeStart, model.inTimeEnd, model.personName).
|
||
OrderBy(x => x.WorkPostName).ThenBy(x => x.ProjectName).ToList();
|
||
//int pageCount = getDataList.Count;
|
||
//if (pageCount > 0 && pageIndex > 0)
|
||
//{
|
||
// getDataList = getDataList.OrderBy(u => u.UnitName).ThenBy(u => u.PersonName).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); ////200 ->Funs.PageSize
|
||
//}
|
||
responeData.data = new { getDataList };
|
||
}
|
||
|
||
}
|
||
else {
|
||
//公司级
|
||
if (model.pageIndex == 0)
|
||
{
|
||
//int pageCount = getDataList.Count;
|
||
//if (pageCount > 0 && pageIndex > 0)
|
||
//{
|
||
// getDataList = getDataList.OrderBy(u => u.UnitName).ThenBy(u => u.PersonName).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); ////200 ->Funs.PageSize
|
||
//}
|
||
responeData.data = APIPersonService.getTrainingPersonListByTrainTypeId(model.unitIds, model.workPostIds, model.trainTypeId, model.pageIndex, model.inTimeStart, model.inTimeEnd, model.personName);
|
||
}
|
||
else
|
||
{
|
||
var getDataList = APIPersonService.getTrainingPersonListByTrainTypeId(model.unitIds, model.workPostIds, model.trainTypeId, model.pageIndex, model.inTimeStart, model.inTimeEnd, model.personName).ToList();
|
||
//int pageCount = getDataList.Count;
|
||
//if (pageCount > 0 && pageIndex > 0)
|
||
//{
|
||
// getDataList = getDataList.OrderBy(u => u.UnitName).ThenBy(u => u.PersonName).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); ////200 ->Funs.PageSize
|
||
//}
|
||
responeData.data = new { getDataList };
|
||
}
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 保存项目人员信息
|
||
/// <summary>
|
||
/// 保存项目人员信息
|
||
/// </summary>
|
||
/// <param name="person">人员信息</param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SaveSitePerson([FromBody] Model.PersonItem person)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
if (person != null && !string.IsNullOrEmpty(person.IdentityCard))
|
||
{
|
||
string photourl = person.PhotoUrl;
|
||
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == person.IdentityCard.Trim() && x.ProjectId == person.ProjectId);
|
||
if (getPerson != null && getPerson.PersonId != person.PersonId && !string.IsNullOrEmpty(person.PersonId))
|
||
{
|
||
responeData.code = -1;
|
||
responeData.message = "该身份证号码已存在两条记录,请联系管理员处理!";
|
||
}
|
||
else
|
||
{
|
||
if (getPerson != null)
|
||
{
|
||
person.PersonId = getPerson.PersonId;
|
||
}
|
||
|
||
var getNewPerson = APIPersonService.SaveSitePerson(person);
|
||
if (getNewPerson != null)
|
||
{
|
||
var getProject = ProjectService.GetProjectByProjectId(getNewPerson.ProjectId);
|
||
if (!string.IsNullOrEmpty(getNewPerson.PhotoUrl) && getProject != null && getProject.IsFace == true)
|
||
{
|
||
responeData.message = APIPersonService.PersonFace(getNewPerson);
|
||
if (!responeData.message.Contains("成功"))
|
||
{
|
||
responeData.code = 2;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
responeData.code = -1;
|
||
responeData.message = "人员信息有误!";
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据personid人员打回
|
||
/// <summary>
|
||
/// 根据personid人员打回
|
||
/// </summary>
|
||
/// <param name="personId">人员ID</param>
|
||
/// <param name="userId">审核人id</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getReUserPersonByPersonId(string personId, string userId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
APIPersonService.getReUserPersonByPersonId(personId, userId);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 更新人员更新附件
|
||
/// <summary>
|
||
/// 更新人员更新附件
|
||
/// </summary>
|
||
/// <param name="person">人员信息</param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SaveSitePersonAttachment([FromBody] Model.PersonItem person)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
APIPersonService.SaveSitePersonAttachment(person);
|
||
var getNewPerson = PersonService.GetPersonById(person.PersonId);
|
||
if (getNewPerson != null)
|
||
{
|
||
var getProject = ProjectService.GetProjectByProjectId(getNewPerson.ProjectId);
|
||
if (!string.IsNullOrEmpty(person.PhotoUrl) && getProject != null && getProject.IsFace == true)
|
||
{
|
||
responeData.message = APIPersonService.PersonFace(getNewPerson);
|
||
if (!responeData.message.Contains("成功"))
|
||
{
|
||
responeData.code = 2;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
responeData.code = 2;
|
||
responeData.message = "人员附件信息有误!";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 人员离场
|
||
/// <summary>
|
||
/// 人员离场
|
||
/// </summary>
|
||
/// <param name="personId"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonOut(string personId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
APIPersonService.getPersonOut(personId);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 插入人员出入场记录
|
||
/// <summary>
|
||
/// 获取人员出入场记录
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="idCard"></param>
|
||
/// <param name="isIn"></param>
|
||
/// <param name="changeTime"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonInOut(string projectId, string idCard, int isIn, DateTime changeTime)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
Model.SitePerson_PersonInOut newInOut = new Model.SitePerson_PersonInOut
|
||
{
|
||
ProjectId = projectId,
|
||
IdentityCard = idCard,
|
||
IsIn = isIn == 1 ? true : false,
|
||
ChangeTime = changeTime,
|
||
InOutWay = Const.InOutWay_1,
|
||
};
|
||
|
||
PersonInOutService.AddPersonInOut(newInOut);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
ErrLogInfo.WriteLog(ex, "WX接口-插入人员出入场记录", "PersonController.getPersonInOut");
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取发卡人员
|
||
/// <summary>
|
||
/// 获取发卡人员
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonDataExchange(string projectId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.data = from x in Funs.DB.SitePerson_Person
|
||
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
||
where x.ProjectId == projectId
|
||
&& !x.ExchangeTime.HasValue
|
||
&& (!x.OutTime.HasValue || x.OutTime > DateTime.Now) && x.InTime.HasValue && x.InTime < DateTime.Now
|
||
&& x.IsUsed == true
|
||
&& x.PhotoUrl != null
|
||
select new
|
||
{
|
||
x.PersonId,
|
||
x.PersonName,
|
||
x.CardNo,
|
||
x.IdentityCard,
|
||
x.UnitId,
|
||
y.UnitCode,
|
||
y.UnitName,
|
||
y.ShortUnitName,
|
||
Funs.DB.ProjectData_TeamGroup.First(z => z.TeamGroupId == x.TeamGroupId).TeamGroupName,
|
||
x.Sex,
|
||
Funs.DB.Base_WorkPost.First(z => z.WorkPostId == x.WorkPostId).WorkPostName,
|
||
x.Telephone,
|
||
x.Address,
|
||
x.InTime,
|
||
x.AuditorDate,
|
||
x.ExchangeTime,
|
||
x.ExchangeTime2,
|
||
x.PhotoUrl,
|
||
};
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
ErrLogInfo.WriteLog(ex, "WX接口-获取人员下发门禁", "PersonController.getPersonDataExchange");
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取离场人员
|
||
/// <summary>
|
||
/// 获取离场人员
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonOutDataExchange(string projectId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
responeData.data = (from x in db.SitePerson_Person_Bak
|
||
where x.ProjectId == projectId && x.InTime.HasValue && x.InTime < DateTime.Now
|
||
&& ((x.IsUsed == true && !x.OutTime.HasValue) || x.OutTime.HasValue)
|
||
&& !x.ExchangeTime2.HasValue && x.ExchangeTime.HasValue
|
||
select new
|
||
{
|
||
x.PersonId,
|
||
x.PersonName,
|
||
x.CardNo,
|
||
x.IdentityCard,
|
||
OutTime = x.OutTime == null ? DateTime.Now.AddYears(10) : x.OutTime,
|
||
}).Take(200).ToList();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 更新人员数据交换时间
|
||
/// <summary>
|
||
/// 更新人员数据交换时间
|
||
/// </summary>
|
||
/// <param name="personId">人员ID</param>
|
||
/// <param name="type">交换类型</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getUpdatePersonExchangeTime(string personId, string type)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId);
|
||
if (getPerson != null && !string.IsNullOrEmpty(type))
|
||
{
|
||
if (type == "1")
|
||
{
|
||
getPerson.ExchangeTime2 = DateTime.Now;
|
||
if (!getPerson.ExchangeTime.HasValue)
|
||
{
|
||
getPerson.ExchangeTime = DateTime.Now;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
getPerson.ExchangeTime = DateTime.Now;
|
||
}
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
ErrLogInfo.WriteLog(ex, "WX接口-更新人员数据交换时间", "PersonController.getUpdatePersonExchangeTime");
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取人员信息出入场记录
|
||
/// <summary>
|
||
/// 获取人员信息出入场记录
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId">当前人单位ID</param>
|
||
/// <param name="startTime"></param>
|
||
/// <param name="endTime"></param>
|
||
/// <param name="pageIndex">页码</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonInOutList(string projectId, string unitId, string startTime, string endTime, int pageIndex)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = APIPersonService.getPersonInOutList(projectId, unitId, startTime, endTime);
|
||
int pageCount = getDataList.Count();
|
||
if (pageCount > 0 && pageIndex > 0)
|
||
{
|
||
getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||
}
|
||
responeData.data = new { pageCount, getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
ErrLogInfo.WriteLog(ex, "WX接口-获取人员信息出入场记录", "PersonController.getPersonInOutList");
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取人员信息出入场记录-查询
|
||
/// <summary>
|
||
/// 获取人员信息出入场记录
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId"></param>
|
||
/// <param name="userUnitId">当前人单位ID</param>
|
||
/// <param name="workPostId">岗位</param>
|
||
/// <param name="strParam">查询条件</param>
|
||
/// <param name="startTime"></param>
|
||
/// <param name="endTime"></param>
|
||
/// <param name="pageIndex">页码</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonInOutList(string projectId, string userUnitId, string workPostId, string strParam, string startTime, string endTime, int pageIndex, string unitId = null)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = APIPersonService.getPersonInOutList(projectId, userUnitId, unitId, workPostId, strParam, startTime, endTime);
|
||
int pageCount = getDataList.Count();
|
||
if (pageCount > 0 && pageIndex > 0)
|
||
{
|
||
getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||
}
|
||
responeData.data = new { pageCount, getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据人员ID获取个人出入场记录
|
||
/// <summary>
|
||
/// 根据人员ID获取个人出入场记录
|
||
/// </summary>
|
||
/// <param name="personId"></param>
|
||
/// <param name="startTime"></param>
|
||
/// <param name="endTime"></param>
|
||
/// <param name="pageIndex">页码</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonInOutListByPersonId(string personId, string startTime, string endTime, int pageIndex)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = APIPersonService.getPersonInOutListByPersonId(personId, startTime, endTime);
|
||
int pageCount = getDataList.Count();
|
||
if (pageCount > 0 && pageIndex > 0)
|
||
{
|
||
getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||
}
|
||
responeData.data = new { pageCount, getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取异常人员信息出入场记录
|
||
/// <summary>
|
||
/// 获取异常人员信息出入场记录
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId">单位ID</param>
|
||
/// <param name="startTime">开始时间</param>
|
||
/// <param name="endTime">结束时间</param>
|
||
/// <param name="inOut"> 入场异常 0 出场异常 1</param>
|
||
/// <param name="pageIndex">页码</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getAbnormalPersonInOutList(string projectId, string unitId, string startTime, string endTime, string inOut, int pageIndex)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = APIPersonService.getAbnormalPersonInOutList(projectId, unitId, startTime, endTime, inOut, pageIndex);
|
||
int pageCount = getDataList.Count();
|
||
responeData.data = new { pageCount, getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
ErrLogInfo.WriteLog(ex, "WX接口-获取异常人员信息出入场记录", "PersonController.getAbnormalPersonInOutList");
|
||
}
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 实业
|
||
|
||
|
||
#region 人员档案
|
||
|
||
/// <summary>
|
||
/// 获取在岗、离岗、待审人员列表
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId"></param>
|
||
/// <param name="states"></param>
|
||
/// <param name="strUnitId"></param>
|
||
/// <param name="strWorkPostId"></param>
|
||
/// <param name="strParam"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonList(string projectId, string unitId, int pageIndex)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var getDataList = APIPersonService.getPersonList(projectId, unitId, pageIndex,out int count);
|
||
int pageCount = count;
|
||
responeData.data = new { pageCount, getDataList };
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
return responeData;
|
||
}
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="personId"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonById(string personId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var getPerson = APIPersonService.getPersonByPersonId(personId);
|
||
responeData.data = getPerson;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
ErrLogInfo.WriteLog(ex, "人员获取失败", "PersonController.getPersonById");
|
||
}
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId"></param>
|
||
/// <param name="pageIndex"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonQualityList(string projectId, string unitId, int pageIndex)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var getDataList = APIPersonQualityService.getPersonQualitList(projectId, unitId, pageIndex, out int count);
|
||
int pageCount = count;
|
||
responeData.data = new { pageCount, getDataList };
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getPersonQualitybyId(string PersonId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var getData = APIPersonQualityService.getPersonQualityInfo("1", PersonId);
|
||
responeData.data = getData;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 根据单位\岗位\培训类型获取项目培训\考试人员信息
|
||
/// <summary>
|
||
/// 根据项目\单位\岗位\培训类型获取项目培训\考试人员信息
|
||
/// </summary>
|
||
/// <param name="unitIds">培训单位ID</param>
|
||
/// <param name="workPostIds">培训岗位ID(可为空)</param>
|
||
/// <param name="trainTypeId">培训类型ID(可为空)</param>
|
||
/// <param name="pageIndex">分页</param>
|
||
/// <returns></returns>
|
||
//public Model.ResponeData getTrainingPersonListByTrainTypeIdCompany(string unitIds, string workPostIds, string trainTypeId, int pageIndex)
|
||
//{
|
||
// var responeData = new Model.ResponeData();
|
||
// try
|
||
// {
|
||
// var getDataList = APIPersonService.getTrainingPersonListByTrainTypeId(unitIds, workPostIds, trainTypeId).OrderBy(x => x.UnitName).ThenBy(x => x.ProjectName).ToList();
|
||
// int pageCount = getDataList.Count;
|
||
// if (pageCount > 0 && pageIndex > 0)
|
||
// {
|
||
// getDataList = getDataList.OrderBy(u => u.UnitName).ThenBy(u => u.PersonName).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); ////200 ->Funs.PageSize
|
||
// }
|
||
// responeData.data = new { pageCount, getDataList };
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// responeData.code = 0;
|
||
// responeData.message = ex.Message;
|
||
// }
|
||
// return responeData;
|
||
//}
|
||
#endregion
|
||
|
||
#region 身份证上传+读取
|
||
/// <summary>
|
||
/// 身份证上传+读取
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public Model.ResponeData PostAddUrl()
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
HttpFileCollection files = HttpContext.Current.Request.Files;
|
||
string typeName = HttpContext.Current.Request["typeName"];
|
||
if (string.IsNullOrEmpty(typeName))
|
||
{
|
||
typeName = "WebApi";
|
||
}
|
||
|
||
// 定义允许上传的文件类型列表
|
||
List<string> allowExtensions = BLL.Funs.AllowExtensions;
|
||
string reUrl = string.Empty;
|
||
if (files != null && files.Count > 0)
|
||
{
|
||
string folderUrl = "FileUpLoad/" + typeName + "/" + DateTime.Now.ToString("yyyy-MM") + "/";
|
||
string localRoot = ConfigurationManager.AppSettings["localRoot"] + folderUrl; //物理路径
|
||
if (!Directory.Exists(localRoot))
|
||
{
|
||
Directory.CreateDirectory(localRoot);
|
||
}
|
||
|
||
foreach (string key in files.AllKeys)
|
||
{
|
||
string rootUrl = string.Empty;
|
||
string fileName = string.Empty;
|
||
string extensionstr = string.Empty;
|
||
HttpPostedFile file = files[key]; //file.ContentLength文件长度
|
||
if (!allowExtensions.Contains(Path.GetExtension(file.FileName)))
|
||
{
|
||
responeData.data = BadRequest($"Invalid file extension: {file.FileName}");
|
||
return responeData;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(file.FileName))
|
||
{
|
||
extensionstr = Path.GetExtension(file.FileName).ToLower();
|
||
fileName = SQLHelper.GetNewID() + extensionstr;
|
||
rootUrl = localRoot + fileName;
|
||
file.SaveAs(localRoot + fileName);
|
||
}
|
||
|
||
if (extensionstr == ".jpg" || extensionstr == ".gif" || extensionstr == ".bmp" ||
|
||
extensionstr == ".png")
|
||
{
|
||
string TakePicDateTime = string.Empty;
|
||
System.Drawing.Image image = System.Drawing.Image.FromStream(file.InputStream, true, false);
|
||
Encoding ascii = Encoding.ASCII;
|
||
//遍历图像文件元数据,检索所有属性
|
||
foreach (System.Drawing.Imaging.PropertyItem p in image.PropertyItems)
|
||
{
|
||
//如果是PropertyTagDateTime,则返回该属性所对应的值
|
||
if (p.Id == 0x0132)
|
||
{
|
||
TakePicDateTime = ascii.GetString(p.Value);
|
||
}
|
||
}
|
||
|
||
TakePicDateTime = string.IsNullOrEmpty(TakePicDateTime)
|
||
? string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now)
|
||
: TakePicDateTime;
|
||
if (!string.IsNullOrEmpty(TakePicDateTime))
|
||
{
|
||
////获取元数据中的拍照日期时间,以字符串形式保存
|
||
//TakePicDateTime = GetTakePicDateTime(pi);
|
||
//分析字符串分别保存拍照日期和时间的标准格式
|
||
var SpaceLocation = TakePicDateTime.IndexOf(" ");
|
||
var dt = TakePicDateTime.Substring(0, SpaceLocation);
|
||
dt = dt.Replace(":", "-");
|
||
var tm = TakePicDateTime.Substring(SpaceLocation + 1,
|
||
TakePicDateTime.Length - SpaceLocation - 2);
|
||
TakePicDateTime = dt + " " + tm;
|
||
//由列表中的文件创建内存位图对象
|
||
var Pic = new Bitmap(rootUrl);
|
||
//由位图对象创建Graphics对象的实例
|
||
var g = Graphics.FromImage(Pic);
|
||
Font ft = new Font("宋体", 20, FontStyle.Regular, GraphicsUnit.Point,
|
||
((byte)(134))); //定义字体
|
||
//在Graphics表面绘制数码照片的日期/时间戳
|
||
g.DrawString(TakePicDateTime, ft, Brushes.Gold, 0, Pic.Height - 100);
|
||
// - 50);
|
||
string newRoot = localRoot + "newfile/";
|
||
if (!Directory.Exists(newRoot))
|
||
{
|
||
Directory.CreateDirectory(newRoot);
|
||
}
|
||
|
||
//将添加日期/时间戳后的图像进行保存
|
||
Pic.Save(newRoot + fileName);
|
||
fileName = "newfile/" + fileName;
|
||
//释放内存位图对象
|
||
Pic.Dispose();
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(fileName))
|
||
{
|
||
if (string.IsNullOrEmpty(reUrl))
|
||
{
|
||
reUrl += folderUrl + fileName;
|
||
}
|
||
else
|
||
{
|
||
reUrl += "," + folderUrl + fileName;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
string url = Request.RequestUri.Scheme + "://" + Request.RequestUri.Host + ":" +
|
||
Request.RequestUri.Port +
|
||
"/JT/" + reUrl;
|
||
|
||
responeData.data = new {IDCard = APIIDCardInfoService.ReadIDCardInfo(url), IDCardUrl = reUrl,URL=url};
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 小程序保存人员信息
|
||
/// <summary>
|
||
/// 小程序保存人员信息
|
||
/// </summary>
|
||
/// <param name="person">人员信息</param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SavePerson([FromBody] Model.PersonItem person)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
if (person != null && !string.IsNullOrEmpty(person.IdentityCard))
|
||
{
|
||
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == person.IdentityCard.Trim() && x.ProjectId == person.ProjectId);
|
||
if (getPerson != null)
|
||
{
|
||
responeData.code = -1;
|
||
responeData.message = "该身份证号码已存在两条记录,请联系管理员处理!";
|
||
}
|
||
else
|
||
{
|
||
|
||
Model.SitePerson_Person newPerson = new Model.SitePerson_Person
|
||
{
|
||
PersonId = SQLHelper.GetNewID(),
|
||
ProjectId = person.ProjectId,
|
||
UnitId = person.UnitId,
|
||
PersonName = person.PersonName,
|
||
Sex = person.Sex ,
|
||
IdentityCard = person.IdentityCard,
|
||
Telephone = person.Telephone,
|
||
WorkPostId = person.WorkPostId,
|
||
IsUsedType = "2",
|
||
IsUsed = true,
|
||
IsCardUsed = false,
|
||
|
||
// IdcardType = "SHENFEN_ZHENGJIAN",
|
||
// IdcardAddress = person.IdcardAddress,
|
||
// IdcardForever = "N",
|
||
// IdcardStartDate = Funs.GetNewDateTime(person.IdcardStartDate),
|
||
// IdcardEndDate = Funs.GetNewDateTime(person.IdcardEndDate),
|
||
// Address = person.Address,
|
||
// OutResult = person.OutResult,
|
||
// Birthday = person.Birthday,
|
||
// InTime = Funs.GetNewDateTimeOrNow(person.InTime),
|
||
// Password = BLL.PersonService.GetPersonPassWord(person.IdentityCard),
|
||
// Isprint = "0",
|
||
};
|
||
PersonService.AddPerson(newPerson);
|
||
|
||
Model.ToDoItem toDoItem = new Model.ToDoItem
|
||
{
|
||
MenuId = Const.PersonListMenuId,
|
||
DataId = newPerson.PersonId + "#1",
|
||
UrlStr = person.AttachUrl1,
|
||
};
|
||
if (!string.IsNullOrEmpty(person.AttachUrl1))
|
||
{
|
||
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
||
}
|
||
|
||
toDoItem.DataId = newPerson.PersonId + "#5";
|
||
toDoItem.UrlStr = person.AttachUrl5;
|
||
if (!string.IsNullOrEmpty(person.AttachUrl5))
|
||
{
|
||
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
||
}
|
||
|
||
responeData.code = 1;
|
||
responeData.message = "新增人员成功!";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
responeData.code = -1;
|
||
responeData.message = "人员信息有误!";
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 岗位列表
|
||
|
||
public Model.ResponeData getWorkPostList(string WorkPostName)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var list = (from x in Funs.DB.Base_WorkPost
|
||
orderby x.WorkPostCode
|
||
select new
|
||
{
|
||
x.WorkPostId,
|
||
x.WorkPostName
|
||
}).ToList();
|
||
if (!string.IsNullOrEmpty(WorkPostName))
|
||
{
|
||
list = list.Where(x => x.WorkPostName.Contains(WorkPostName)).ToList();
|
||
}
|
||
responeData.data = new { list };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
}
|
||
} |