This commit is contained in:
杨红卫 2021-09-06 16:46:05 +08:00
parent 4955bbcba0
commit 8add136b66
1 changed files with 107 additions and 101 deletions

View File

@ -154,125 +154,131 @@ namespace WebAPI.Controllers
var getProject = ProjectService.GetProjectByProjectCode(person.ProjectCode);
if (getProject != null)
{
var getPerson = PersonService.GetPersonByIdentityCard(getProject.ProjectId, person.IdentityCard);
if (getPerson == null)
var getUnit = UnitService.getUnitByCollCropCodeUnitName(person.CollCropCode, person.UnitName);
if (getUnit != null)
{
Model.SitePerson_Person newPerson = new Model.SitePerson_Person
var getPerson = PersonService.GetPersonByIdentityCard(getProject.ProjectId, person.IdentityCard);
if (getPerson == null)
{
PersonId = SQLHelper.GetNewID(),
ProjectId = getProject.ProjectId,
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,
};
var getUnit = UnitService.getUnitByCollCropCodeUnitName(person.CollCropCode, person.UnitName);
if (getUnit != null)
{
newPerson.UnitId = getUnit.UnitId;
}
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))
{
var getTeamGroup = TeamGroupService.getTeamGroupByTeamGroupName(getProject.ProjectId, newPerson.UnitId, person.TeamGroupName);
if (getTeamGroup != null)
if (!string.IsNullOrEmpty(person.TeamGroupName) && !string.IsNullOrEmpty(newPerson.UnitId))
{
newPerson.TeamGroupId = getTeamGroup.TeamGroupId;
}
else
{
Model.ProjectData_TeamGroup newTeamGroup = new Model.ProjectData_TeamGroup
var getTeamGroup = TeamGroupService.getTeamGroupByTeamGroupName(getProject.ProjectId, newPerson.UnitId, person.TeamGroupName);
if (getTeamGroup != null)
{
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 = 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;
}
}
}
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 != null)
{
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))
var getWorkArea = UnitWorkService.GetUnitWorkByUnitWorkName(getProject.ProjectId, person.WorkAreaName);
if (getWorkArea != null)
{
Directory.CreateDirectory(fileUrl);
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 != null)
{
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);
}
newPerson.PhotoUrl = path + flieName;
System.IO.File.WriteAllBytes((fileUrl + flieName), image);
//AttachFileService.Base64ToImage(person.headImage, path, person.PersonName);
}
PersonService.AddPerson(newPerson);
responeData.message = "新增人员成功!";
}
else
{
if (!string.IsNullOrEmpty(person.OutTime))
{
var outTime = Funs.GetNewDateTimeOrNow(person.OutTime);
PersonService.PersonOut(getPerson.PersonId, outTime);
responeData.message = "更新出场时间";
PersonService.AddPerson(newPerson);
responeData.message = "新增人员成功!";
}
else
{
responeData.message = "该身份证号码人员已存在!";
if (!string.IsNullOrEmpty(person.OutTime))
{
var outTime = Funs.GetNewDateTimeOrNow(person.OutTime);
PersonService.PersonOut(getPerson.PersonId, outTime);
responeData.message = "更新出场时间";
}
else
{
responeData.message = "该身份证号码人员已存在!";
}
}
}
else
{
responeData.code = 0;
responeData.message = "单位:" + person.UnitName + "施工平台不存在!";
}
}
else
{
responeData.code = 0;
responeData.message = "项目号:" + person.ProjectCode + "不存在!";
responeData.message = "项目号:" + person.ProjectCode + "施工平台不存在!";
}
}
}