1
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using BLL;
|
||||
using Microsoft.Ajax.Utilities;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
@@ -6,8 +9,6 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using BLL;
|
||||
using Model;
|
||||
using WebAPI.Filter;
|
||||
|
||||
namespace WebAPI.Controllers
|
||||
@@ -42,7 +43,7 @@ namespace WebAPI.Controllers
|
||||
if (getProject != null)
|
||||
{
|
||||
projectId = getProject.ProjectId;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
@@ -103,7 +104,7 @@ namespace WebAPI.Controllers
|
||||
isIn = 1;
|
||||
}
|
||||
APIPersonService.getPersonInOut(getPerson, isIn, facerecord.DateTimeRecord.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
responeData.message = "插入成功!";
|
||||
}
|
||||
@@ -157,116 +158,116 @@ namespace WebAPI.Controllers
|
||||
{
|
||||
var getUnit = UnitService.getUnitByCollCropCodeUnitName(person.CollCropCode, person.UnitName);
|
||||
if (getUnit != null)
|
||||
{
|
||||
Model.SitePerson_Person newPerson = new Model.SitePerson_Person
|
||||
{
|
||||
PersonId = SQLHelper.GetNewID(),
|
||||
ProjectId = getProject.ProjectId,
|
||||
UnitId = getUnit.UnitId,
|
||||
PersonName = person.PersonName,
|
||||
IdentityCard = person.IdentityCard,
|
||||
IdcardType = "SHENFEN_ZHENGJIAN",
|
||||
IdcardAddress = person.IdcardAddress,
|
||||
IdcardForever = "N",
|
||||
IdcardStartDate = Funs.GetNewDateTime(person.IdcardStartDate),
|
||||
IdcardEndDate = Funs.GetNewDateTime(person.IdcardEndDate),
|
||||
Sex = (person.Sex == "女" || person.Sex == "2") ? "2" : "1",
|
||||
Address = person.Address,
|
||||
OutResult = person.OutResult,
|
||||
Birthday = person.Birthday,
|
||||
Telephone = person.Telephone,
|
||||
IsUsed = person.IsUsed == false ? false : true,
|
||||
InTime = Funs.GetNewDateTimeOrNow(person.InTime),
|
||||
Password = BLL.PersonService.GetPersonPassWord(person.IdentityCard),
|
||||
Isprint = "0",
|
||||
//PositionId = person.PositionId,
|
||||
//PostTitleId = person.PostTitleId,
|
||||
//IsForeign = person.IsForeign,
|
||||
//IsOutside = person.IsOutside,
|
||||
//EduLevel = person.EduLevel,
|
||||
//MaritalStatus = person.MaritalStatus,
|
||||
//PoliticsStatus = person.PoliticsStatus,
|
||||
//Nation = person.Nation,
|
||||
//CountryCode = person.CountryCode,
|
||||
//ProvinceCode = person.ProvinceCode,
|
||||
};
|
||||
{
|
||||
Model.SitePerson_Person newPerson = new Model.SitePerson_Person
|
||||
{
|
||||
PersonId = SQLHelper.GetNewID(),
|
||||
ProjectId = getProject.ProjectId,
|
||||
UnitId = getUnit.UnitId,
|
||||
PersonName = person.PersonName,
|
||||
IdentityCard = person.IdentityCard,
|
||||
IdcardType = "SHENFEN_ZHENGJIAN",
|
||||
IdcardAddress = person.IdcardAddress,
|
||||
IdcardForever = "N",
|
||||
IdcardStartDate = Funs.GetNewDateTime(person.IdcardStartDate),
|
||||
IdcardEndDate = Funs.GetNewDateTime(person.IdcardEndDate),
|
||||
Sex = (person.Sex == "女" || person.Sex == "2") ? "2" : "1",
|
||||
Address = person.Address,
|
||||
OutResult = person.OutResult,
|
||||
Birthday = person.Birthday,
|
||||
Telephone = person.Telephone,
|
||||
IsUsed = person.IsUsed == false ? false : true,
|
||||
InTime = Funs.GetNewDateTimeOrNow(person.InTime),
|
||||
Password = BLL.PersonService.GetPersonPassWord(person.IdentityCard),
|
||||
Isprint = "0",
|
||||
//PositionId = person.PositionId,
|
||||
//PostTitleId = person.PostTitleId,
|
||||
//IsForeign = person.IsForeign,
|
||||
//IsOutside = person.IsOutside,
|
||||
//EduLevel = person.EduLevel,
|
||||
//MaritalStatus = person.MaritalStatus,
|
||||
//PoliticsStatus = person.PoliticsStatus,
|
||||
//Nation = person.Nation,
|
||||
//CountryCode = person.CountryCode,
|
||||
//ProvinceCode = person.ProvinceCode,
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(person.TeamGroupName) && !string.IsNullOrEmpty(newPerson.UnitId))
|
||||
if (!string.IsNullOrEmpty(person.TeamGroupName) && !string.IsNullOrEmpty(newPerson.UnitId))
|
||||
{
|
||||
var getTeamGroup = TeamGroupService.getTeamGroupByTeamGroupName(getProject.ProjectId, newPerson.UnitId, person.TeamGroupName);
|
||||
if (getTeamGroup != null)
|
||||
{
|
||||
var getTeamGroup = TeamGroupService.getTeamGroupByTeamGroupName(getProject.ProjectId, newPerson.UnitId, person.TeamGroupName);
|
||||
if (getTeamGroup != null)
|
||||
newPerson.TeamGroupId = getTeamGroup.TeamGroupId;
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.ProjectData_TeamGroup newTeamGroup = new Model.ProjectData_TeamGroup
|
||||
{
|
||||
newPerson.TeamGroupId = getTeamGroup.TeamGroupId;
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.ProjectData_TeamGroup newTeamGroup = new Model.ProjectData_TeamGroup
|
||||
{
|
||||
TeamGroupId = SQLHelper.GetNewID(),
|
||||
ProjectId = getProject.ProjectId,
|
||||
UnitId = newPerson.UnitId,
|
||||
TeamGroupName = person.TeamGroupName,
|
||||
Remark = "来源:门禁对接数据",
|
||||
TeamTypeId = "CANJIAN_TEAM",
|
||||
EntryTime = System.DateTime.Now,
|
||||
RealNamePushTime = null,
|
||||
};
|
||||
db.ProjectData_TeamGroup.InsertOnSubmit(newTeamGroup);
|
||||
db.SubmitChanges();
|
||||
newPerson.TeamGroupId = newTeamGroup.TeamGroupId;
|
||||
}
|
||||
TeamGroupId = SQLHelper.GetNewID(),
|
||||
ProjectId = getProject.ProjectId,
|
||||
UnitId = newPerson.UnitId,
|
||||
TeamGroupName = person.TeamGroupName,
|
||||
Remark = "来源:门禁对接数据",
|
||||
TeamTypeId = "CANJIAN_TEAM",
|
||||
EntryTime = System.DateTime.Now,
|
||||
RealNamePushTime = null,
|
||||
};
|
||||
db.ProjectData_TeamGroup.InsertOnSubmit(newTeamGroup);
|
||||
db.SubmitChanges();
|
||||
newPerson.TeamGroupId = newTeamGroup.TeamGroupId;
|
||||
}
|
||||
var getWorkArea = UnitWorkService.GetUnitWorkByUnitWorkName(getProject.ProjectId, person.WorkAreaName);
|
||||
if (getWorkArea != null)
|
||||
}
|
||||
var getWorkArea = UnitWorkService.GetUnitWorkByUnitWorkName(getProject.ProjectId, person.WorkAreaName);
|
||||
if (getWorkArea != null)
|
||||
{
|
||||
newPerson.WorkAreaId = getWorkArea.UnitWorkId;
|
||||
}
|
||||
var getWorkPost = WorkPostService.GetWorkPostByName(person.WorkPostName);
|
||||
if (getWorkPost != null)
|
||||
{
|
||||
newPerson.WorkPostId = getWorkPost.WorkPostId;
|
||||
}
|
||||
var getHsseMan = ProjectService.getHSSEManager(getProject.ProjectId);
|
||||
if (getHsseMan != null)
|
||||
{
|
||||
newPerson.AuditorId = getHsseMan.UserId;
|
||||
newPerson.AuditorDate = DateTime.Now;
|
||||
}
|
||||
newPerson.OutTime = Funs.GetNewDateTime(person.OutTime);
|
||||
if (person.headImage.Length == 0 && !string.IsNullOrEmpty(person.PhotoUrl))
|
||||
{
|
||||
var getS = AttachFileService.SetImageToByteArray(person.PhotoUrl);
|
||||
if (getS != null)
|
||||
{
|
||||
newPerson.WorkAreaId = getWorkArea.UnitWorkId;
|
||||
person.headImage = getS.ToString();
|
||||
}
|
||||
var getWorkPost = WorkPostService.GetWorkPostByName(person.WorkPostName);
|
||||
if (getWorkPost != null)
|
||||
}
|
||||
if (person.headImage.Length > 0)
|
||||
{
|
||||
var image = Convert.FromBase64String(person.headImage);
|
||||
newPerson.HeadImage = image;
|
||||
string rootPath = ConfigurationManager.AppSettings["localRoot"];
|
||||
string path = "FileUpLoad/PersonBaseInfo/" + DateTime.Now.ToString("yyyy-MM") + "/";
|
||||
string fileUrl = (rootPath + path).Replace('/', '\\');
|
||||
string flieName = Funs.GetNewFileName() + "~" + person.PersonName + ".jpg";
|
||||
if (!Directory.Exists(fileUrl))
|
||||
{
|
||||
newPerson.WorkPostId = getWorkPost.WorkPostId;
|
||||
}
|
||||
var getHsseMan = ProjectService.getHSSEManager(getProject.ProjectId);
|
||||
if (getHsseMan != null)
|
||||
{
|
||||
newPerson.AuditorId = getHsseMan.UserId;
|
||||
newPerson.AuditorDate = DateTime.Now;
|
||||
}
|
||||
newPerson.OutTime = Funs.GetNewDateTime(person.OutTime);
|
||||
if (person.headImage.Length == 0 && !string.IsNullOrEmpty(person.PhotoUrl))
|
||||
{
|
||||
var getS = AttachFileService.SetImageToByteArray(person.PhotoUrl);
|
||||
if (getS != null)
|
||||
{
|
||||
person.headImage = getS.ToString();
|
||||
}
|
||||
}
|
||||
if (person.headImage.Length > 0)
|
||||
{
|
||||
var image = Convert.FromBase64String(person.headImage);
|
||||
newPerson.HeadImage = image;
|
||||
string rootPath = ConfigurationManager.AppSettings["localRoot"];
|
||||
string path = "FileUpLoad/PersonBaseInfo/" + DateTime.Now.ToString("yyyy-MM") + "/";
|
||||
string fileUrl = (rootPath + path).Replace('/', '\\');
|
||||
string flieName = Funs.GetNewFileName() + "~" + person.PersonName + ".jpg";
|
||||
if (!Directory.Exists(fileUrl))
|
||||
{
|
||||
Directory.CreateDirectory(fileUrl);
|
||||
}
|
||||
newPerson.PhotoUrl = path + flieName;
|
||||
System.IO.File.WriteAllBytes((fileUrl + flieName), image);
|
||||
//AttachFileService.Base64ToImage(person.headImage, path, person.PersonName);
|
||||
Directory.CreateDirectory(fileUrl);
|
||||
}
|
||||
newPerson.PhotoUrl = path + flieName;
|
||||
System.IO.File.WriteAllBytes((fileUrl + flieName), image);
|
||||
//AttachFileService.Base64ToImage(person.headImage, path, person.PersonName);
|
||||
}
|
||||
|
||||
var getPerson = PersonService.GetPersonByIdentityCard(getProject.ProjectId, person.IdentityCard);
|
||||
if (getPerson == null)
|
||||
if (getPerson == null && !string.IsNullOrWhiteSpace(newPerson.PersonName))
|
||||
{
|
||||
PersonService.AddPerson(newPerson);
|
||||
responeData.message = "新增人员成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
newPerson.PersonId =getPerson.PersonId;
|
||||
newPerson.PersonId = getPerson.PersonId;
|
||||
PersonService.UpdateDoorPerson(newPerson);
|
||||
responeData.message = "更新人员成功!";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user