363 lines
14 KiB
C#
363 lines
14 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
using System.Net.Http;
|
|||
|
using System.Web.Http;
|
|||
|
using BLL;
|
|||
|
using Model;
|
|||
|
|
|||
|
namespace WebAPI.Controllers.DataPenetrate
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 企业总部/分支机构安全人员控制器
|
|||
|
/// </summary>
|
|||
|
public class CompanyPersonPenetrateController : ApiController
|
|||
|
{
|
|||
|
#region 企业总部
|
|||
|
/// <summary>
|
|||
|
/// 保存企业总部,类型是总监的人员
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public Model.ResponeData SaveCompanyPersonGM([FromBody] Person_CompanyBranchPerson model) {
|
|||
|
var responeData = new Model.ResponeData();
|
|||
|
try
|
|||
|
{
|
|||
|
#region 判断是否未填
|
|||
|
if (string.IsNullOrEmpty(model.PersonName))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "姓名(PersonName)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(model.IdentityCard))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "身份证号码(IdentityCard)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
else if (BLL.CompanyBranchPersonService.IsExistPersonIdentityCard(model.CompanyBranchPersonId, model.IdentityCard) == true)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "身份证号码已存在";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
model.UnitId = CommonService.GetIsThisUnit().UnitId;
|
|||
|
model.WorkPostId = Const.WorkPost_HSSEDirector;//安全总监id
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(model.CompanyBranchPersonId))
|
|||
|
{
|
|||
|
model.CompanyBranchPersonId = SQLHelper.GetNewID(typeof(Model.Person_CompanyBranchPerson));
|
|||
|
CompanyBranchPersonService.AddCompanyBranchPerson(model);
|
|||
|
responeData.message = "保存成功";
|
|||
|
}
|
|||
|
else {
|
|||
|
var pmodel = Funs.DB.Person_CompanyBranchPerson.FirstOrDefault(x => x.CompanyBranchPersonId == model.CompanyBranchPersonId);
|
|||
|
if (pmodel == null)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "主键id(CompanyBranchPersonId)未查询到数据,无法修改,请检查是否正确。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
CompanyBranchPersonService.UpdateCompanyBranchPerson(model);
|
|||
|
responeData.message = "修改成功";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = ex.Message;
|
|||
|
}
|
|||
|
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 保存企业总部,类型是专职的人员
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public Model.ResponeData SaveCompanyPersonFT([FromBody] Person_CompanyBranchPerson model)
|
|||
|
{
|
|||
|
var responeData = new Model.ResponeData();
|
|||
|
try
|
|||
|
{
|
|||
|
#region 判断是否未填
|
|||
|
if (string.IsNullOrEmpty(model.PersonName))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "姓名(PersonName)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(model.WorkPostId))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "岗位(WorkPostId)不能为空,请前往岗位接口查询。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
else {
|
|||
|
var pmodel = Funs.DB.Base_WorkPost.FirstOrDefault(x => x.WorkPostId == model.WorkPostId && x.IsHsse==true);
|
|||
|
if (pmodel == null)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "岗位(WorkPostId)未查询到类型是专职数据,请检查是否正确。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(model.IdentityCard))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "身份证号码(IdentityCard)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
else if (BLL.CompanyBranchPersonService.IsExistPersonIdentityCard(model.CompanyBranchPersonId, model.IdentityCard) == true)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "身份证号码已存在";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
model.UnitId = CommonService.GetIsThisUnit().UnitId;
|
|||
|
if (string.IsNullOrEmpty(model.CompanyBranchPersonId))
|
|||
|
{
|
|||
|
model.CompanyBranchPersonId = SQLHelper.GetNewID(typeof(Model.Person_CompanyBranchPerson));
|
|||
|
CompanyBranchPersonService.AddCompanyBranchPerson(model);
|
|||
|
responeData.message = "保存成功";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var pmodel = Funs.DB.Person_CompanyBranchPerson.FirstOrDefault(x => x.CompanyBranchPersonId == model.CompanyBranchPersonId);
|
|||
|
if (pmodel == null)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "主键id(CompanyBranchPersonId)未查询到数据,无法修改,请检查是否正确。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
CompanyBranchPersonService.UpdateCompanyBranchPerson(model);
|
|||
|
responeData.message = "修改成功";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = ex.Message;
|
|||
|
}
|
|||
|
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 分支机构
|
|||
|
/// <summary>
|
|||
|
/// 保存分支机构,类型是总监的人员
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public Model.ResponeData SaveBranchPersonGM([FromBody] Person_CompanyBranchPerson model)
|
|||
|
{
|
|||
|
var responeData = new Model.ResponeData();
|
|||
|
try
|
|||
|
{
|
|||
|
#region 判断是否未填
|
|||
|
if (string.IsNullOrEmpty(model.PersonName))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "姓名(PersonName)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(model.UnitId))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "公司id(UnitId)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
else {
|
|||
|
var umodel = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == model.UnitId);
|
|||
|
if (umodel == null)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "UnitId未查询到数据,请检查是否正确。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(model.IdentityCard))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "身份证号码(IdentityCard)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
else if (BLL.CompanyBranchPersonService.IsExistPersonIdentityCard(model.CompanyBranchPersonId, model.IdentityCard) == true)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "身份证号码已存在";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
model.WorkPostId = Const.WorkPost_HSSEDirector;//安全总监id
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(model.CompanyBranchPersonId))
|
|||
|
{
|
|||
|
model.CompanyBranchPersonId = SQLHelper.GetNewID(typeof(Model.Person_CompanyBranchPerson));
|
|||
|
CompanyBranchPersonService.AddCompanyBranchPerson(model);
|
|||
|
responeData.message = "保存成功";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var pmodel = Funs.DB.Person_CompanyBranchPerson.FirstOrDefault(x => x.CompanyBranchPersonId == model.CompanyBranchPersonId);
|
|||
|
if (pmodel == null)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "主键id(CompanyBranchPersonId)未查询到数据,无法修改,请检查是否正确。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
CompanyBranchPersonService.UpdateCompanyBranchPerson(model);
|
|||
|
responeData.message = "修改成功";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = ex.Message;
|
|||
|
}
|
|||
|
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 保存分支机构,类型是专职的人员
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public Model.ResponeData SaveBranchPersonFT([FromBody] Person_CompanyBranchPerson model)
|
|||
|
{
|
|||
|
var responeData = new Model.ResponeData();
|
|||
|
try
|
|||
|
{
|
|||
|
#region 判断是否未填
|
|||
|
if (string.IsNullOrEmpty(model.PersonName))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "姓名(PersonName)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(model.UnitId))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "公司id(UnitId)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var umodel = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == model.UnitId);
|
|||
|
if (umodel == null)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "UnitId未查询到数据,请检查是否正确。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(model.WorkPostId))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "岗位(WorkPostId)不能为空,请前往岗位接口查询。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var pmodel = Funs.DB.Base_WorkPost.FirstOrDefault(x => x.WorkPostId == model.WorkPostId && x.IsHsse == true);
|
|||
|
if (pmodel == null)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "岗位(WorkPostId)未查询到类型是专职数据,请检查是否正确。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(model.IdentityCard))
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "身份证号码(IdentityCard)不能为空";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
else if (BLL.CompanyBranchPersonService.IsExistPersonIdentityCard(model.CompanyBranchPersonId, model.IdentityCard) == true)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "身份证号码已存在";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
if (string.IsNullOrEmpty(model.CompanyBranchPersonId))
|
|||
|
{
|
|||
|
model.CompanyBranchPersonId = SQLHelper.GetNewID(typeof(Model.Person_CompanyBranchPerson));
|
|||
|
CompanyBranchPersonService.AddCompanyBranchPerson(model);
|
|||
|
responeData.message = "保存成功";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var pmodel = Funs.DB.Person_CompanyBranchPerson.FirstOrDefault(x => x.CompanyBranchPersonId == model.CompanyBranchPersonId);
|
|||
|
if (pmodel == null)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = "主键id(CompanyBranchPersonId)未查询到数据,无法修改,请检查是否正确。";
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
CompanyBranchPersonService.UpdateCompanyBranchPerson(model);
|
|||
|
responeData.message = "修改成功";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = ex.Message;
|
|||
|
}
|
|||
|
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 查询岗位信息是专职的岗位
|
|||
|
/// <summary>
|
|||
|
/// 查询岗位信息是专职的岗位
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public Model.ResponeData getWorkPostInfoFT()
|
|||
|
{
|
|||
|
var responeData = new Model.ResponeData();
|
|||
|
try
|
|||
|
{
|
|||
|
var getDataList = Funs.DB.Base_WorkPost.Where(x => x.IsHsse == true)
|
|||
|
.Select(x => new Base_WorkPost
|
|||
|
{
|
|||
|
WorkPostId = x.WorkPostId,
|
|||
|
WorkPostName = x.WorkPostName,
|
|||
|
WorkPostCode=x.WorkPostCode
|
|||
|
}).ToList();
|
|||
|
|
|||
|
responeData.data = new { getDataList };
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
responeData.code = 0;
|
|||
|
responeData.message = ex.Message;
|
|||
|
}
|
|||
|
|
|||
|
return responeData;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|