20210813 对接门禁接口调整

This commit is contained in:
杨红卫 2021-08-13 10:48:08 +08:00
parent bacbffb714
commit 43acc57060
37 changed files with 345 additions and 68 deletions

View File

@ -19,7 +19,10 @@ namespace BLL
{
return Funs.DB.Base_WorkPost.FirstOrDefault(e => e.WorkPostId == workPostId);
}
public static Model.Base_WorkPost GetWorkPostByName(string name)
{
return Funs.DB.Base_WorkPost.FirstOrDefault(e => e.WorkPostName == name);
}
/// <summary>
/// 添加
/// </summary>

View File

@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
namespace BLL
{
@ -414,5 +416,45 @@ namespace BLL
}
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="base64Str"></param>
/// <param name="path"></param>
/// <param name="imgName"></param>
/// <returns></returns>
public static string Base64ToImage(string base64Str, string path, string imgName)
{
string filename = "";//声明一个string类型的相对路径
String base64 = base64Str.Substring(base64Str.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象接收转换完成的图片
try//会有异常抛出trycatch一下
{
byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
filename = path + imgName + ".jpg";//所要保存的相对路径及名字
string url = ConfigurationManager.AppSettings["localRoot"];
string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
bitmap.Save(imagesurl2, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
//bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
//bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
//bitmap.Save(filePath + ".png", System.Drawing.Imaging.ImageFormat.Png);
ms.Close();//关闭当前流,并释放所有与之关联的资源
bitmap.Dispose();
}
catch (Exception e)
{
string massage = e.Message;
}
return filename;//返回相对路径
}
}
}

View File

@ -465,6 +465,30 @@ namespace BLL
}
}
/// <summary>
/// 根据身份证号获取人员信息
/// </summary>
/// <param name="identityCard">身份证号</param>
/// <returns>人员信息</returns>
public static Model.SitePerson_Person GetPersonByProjectCodeIdentityCard(string projectCode, string identityCard)
{
if (!string.IsNullOrEmpty(identityCard))
{
var getProject = ProjectService.GetProjectByProjectCode(projectCode);
if (getProject != null)
{
return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.ProjectId == getProject.ProjectId && e.IdentityCard == identityCard);
}
else
{
return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.IdentityCard == identityCard && e.ProjectId == null);
}
}
else
{
return null;
}
}
/// <summary>
/// 根据身份证号获取人员信息
/// </summary>

View File

@ -76,6 +76,12 @@
return Funs.DB.Base_Project.FirstOrDefault(e => e.ProjectName == name);
}
public static Model.Base_Project GetProjectByProjectCode(string code)
{
return Funs.DB.Base_Project.FirstOrDefault(e => e.ProjectCode == code);
}
/// <summary>
///获取项目简称
/// </summary>
@ -440,16 +446,25 @@
string name = string.Empty;
if (projectId != null)
{
name = (from x in db.Base_Project
join y in db.Project_ProjectUser on x.ProjectId equals y.ProjectId
join z in db.Sys_User on y.UserId equals z.UserId
where x.ProjectId == projectId && y.RoleId.Contains(BLL.Const.HSSEManager)
select z.UserName).FirstOrDefault();
name = (from x in db.Project_ProjectUser
join y in db.Sys_User on x.UserId equals y.UserId
where x.ProjectId == projectId && x.RoleId.Contains(BLL.Const.HSSEManager)
select y.UserName).FirstOrDefault();
}
return name;
}
}
/// <summary>
/// 获取安全经理
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static Model.Project_ProjectUser getHSSEManager(string projectId)
{
return Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.ProjectId == projectId && x.RoleId.Contains(BLL.Const.HSSEManager));
}
/// <summary>
/// 质量经理
/// </summary>

View File

@ -124,6 +124,11 @@ namespace BLL
orderby x.TeamGroupCode select x).ToList();
}
public static Model.ProjectData_TeamGroup getTeamGroupByTeamGroupName(string projectId,string unitId, string name)
{
return Funs.DB.ProjectData_TeamGroup.FirstOrDefault(x => x.ProjectId == projectId && x.UnitId== unitId && x.TeamGroupName == name);
}
#region
/// <summary>
/// 表下拉框

View File

@ -167,6 +167,11 @@ namespace BLL
return Funs.DB.WBS_UnitWork.FirstOrDefault(e => e.UnitWorkId == UnitWorkId);
}
public static Model.WBS_UnitWork GetUnitWorkByUnitWorkName(string projectId,string unitWorkName)
{
return Funs.DB.WBS_UnitWork.FirstOrDefault(e =>e.ProjectId ==projectId && e.UnitWorkName == unitWorkName);
}
/// <summary>
/// 获取单位工程信息
/// </summary>

View File

@ -662,7 +662,18 @@ namespace BLL
{
return Funs.DB.Base_Unit.FirstOrDefault(e => e.UnitName == unitName);
}
public static Model.Base_Unit getUnitByCollCropCodeUnitName(string CollCropCode,string unitName)
{
var getUnit= Funs.DB.Base_Unit.FirstOrDefault(e => e.CollCropCode == CollCropCode);
if (getUnit != null)
{
return getUnit;
}
else
{
return Funs.DB.Base_Unit.FirstOrDefault(e => e.UnitName == unitName);
}
}
/// <summary>
/// 根据项目Id获取单位名称项
/// </summary>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

View File

@ -70,7 +70,7 @@
<HintPath>..\..\..\CQMS_New\CQMS\FineUIPro.Web\bin\Aspose.Words.dll</HintPath>
</Reference>
<Reference Include="AxInterop.SYNCARDOCXLib">
<HintPath>..\..\..\SGGL\SGGL\FineUIPro.Web\bin\AxInterop.SYNCARDOCXLib.dll</HintPath>
<HintPath>..\FineUIPro\Reference BLL\AxInterop.SYNCARDOCXLib.dll</HintPath>
</Reference>
<Reference Include="FineUIPro, Version=6.3.0.0, Culture=neutral, PublicKeyToken=9cbe753c029f291a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@ -79,7 +79,7 @@
<Reference Include="Interop.WIA, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>..\..\..\SGGL\SGGL\FineUIPro.Web\bin\Interop.WIA.dll</HintPath>
<HintPath>..\FineUIPro\Reference BLL\Interop.WIA.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
@ -117,7 +117,7 @@
<Reference Include="System.Xml.Linq" />
<Reference Include="ThoughtWorks.QRCode, Version=1.0.2774.19990, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\SGGL\SGGL\FineUIPro.Web\bin\ThoughtWorks.QRCode.dll</HintPath>
<HintPath>..\FineUIPro\Reference BLL\ThoughtWorks.QRCode.dll</HintPath>
</Reference>
<Reference Include="ThoughtWorks.QRCode.Fakes">
<HintPath>FakesAssemblies\ThoughtWorks.QRCode.Fakes.dll</HintPath>

View File

@ -36,6 +36,10 @@ namespace Model
/// </summary>
public string Address { get; set; }
/// <summary>
/// 生日
/// </summary>
public DateTime? Birthday { get; set; }
/// <summary>
/// 项目id
/// </summary>
public string ProjectId { get; set; }
@ -48,6 +52,10 @@ namespace Model
/// </summary>
public string ProjectName { get; set; }
/// <summary>
/// 单位 统一社会信用代码
/// </summary>
public string CollCropCode { get; set; }
/// <summary>
/// 单位ID
/// </summary>
public string UnitId { get; set; }
@ -96,6 +104,10 @@ namespace Model
/// </summary>
public string PhotoUrl { get; set; }
/// <summary>
/// 照片路径
/// </summary>
public string headImage { get; set; }
/// <summary>
/// 部门名称
/// </summary>
public string DepartName { get; set; }

View File

@ -19,6 +19,14 @@ namespace Model
set;
}
/// <summary>
/// ID
/// </summary>
public string ProjectCode
{
get;
set;
}
/// <summary>
/// 设备序列号
/// </summary>
public string deviceSn

View File

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
@ -14,7 +16,7 @@ namespace WebAPI.Controllers
/// </summary>
public class uploadController : ApiController
{
#region
#region
/// <summary>
/// 保存出入记录信息
/// </summary>
@ -29,70 +31,95 @@ namespace WebAPI.Controllers
if (records != null && records.records.Count() > 0)
{
List<Model.attendanceItem> attendanceItems = records.records;
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
var getprojectCode = attendanceItems.FirstOrDefault(x => x.ProjectCode != null || x.ProjectId != null);
if (getprojectCode != null)
{
string projectId = "310e790e-5ede-4345-98a4-8bd0866e69ef"; ////潮州华瀛
int maxId = 0;
var getmax = db.T_d_facerecord.Where(x => x.ProjectId == projectId && x.RoleID == "白名单").Select(x => x.ID);
if (getmax.Count() > 0)
string projectId = getprojectCode.ProjectId;
if (string.IsNullOrEmpty(projectId))
{
maxId = getmax.Max() + 1;
var getProject = ProjectService.GetProjectByProjectCode(getprojectCode.ProjectCode);
if (getProject != null)
{
projectId = getProject.ProjectId;
}
}
foreach (var item in attendanceItems)
if (!string.IsNullOrEmpty(projectId))
{
string name = string.Empty;
string cardNo = string.Empty;
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == item.idCardNumber);
if (getPerson != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
name = getPerson.PersonName;
cardNo = getPerson.CardNo;
}
Model.T_d_facerecord newFacerecord = new Model.T_d_facerecord()
{
NewID = SQLHelper.GetNewID(),
ProjectId = projectId,
ID = maxId + 1,
EmployName = name,
EmployNO = item.idCardNumber,
RoleID = "白名单",
DateTimeRecord = Funs.GetNewDateTime(item.attendanceTime),
RecordDes = "白名单:允许通行",
InOrOut = (item.attendanceType == 1 ? "进门" : "出门"),
};
db.T_d_facerecord.InsertOnSubmit(newFacerecord);
db.SubmitChanges();
///// 根据出入记录 写入考勤记录
Model.t_d_facerecordItem facerecord = new Model.t_d_facerecordItem
{
ID = maxId + 1,
EmployName = name,
IDCardNo = item.idCardNumber,
EmployNO = item.idCardNumber,
ProjectId = projectId,
RoleID = "白名单",
DateTimeRecord = Funs.GetNewDateTime(item.attendanceTime),
RecordDes = "白名单:允许通行",
InOrOut = (item.attendanceType == 1 ? "进门" : "出门"),
};
DoorServerService.InsertEmployInOutRecord(facerecord);
if (facerecord.DateTimeRecord.HasValue)
{
int isIn = 0;
if (facerecord.InOrOut == "进门")
int maxId = 0;
var getmax = db.T_d_facerecord.Where(x => x.ProjectId == projectId && x.RoleID == "白名单").Select(x => x.ID);
if (getmax.Count() > 0)
{
isIn = 1;
maxId = getmax.Max() + 1;
}
foreach (var item in attendanceItems)
{
string name = string.Empty;
string cardNo = string.Empty;
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == item.idCardNumber);
if (getPerson != null)
{
name = getPerson.PersonName;
cardNo = getPerson.CardNo;
}
Model.T_d_facerecord newFacerecord = new Model.T_d_facerecord()
{
NewID = SQLHelper.GetNewID(),
ProjectId = projectId,
ID = maxId + 1,
EmployName = name,
EmployNO = item.idCardNumber,
RoleID = "白名单",
DateTimeRecord = Funs.GetNewDateTime(item.attendanceTime),
RecordDes = "白名单:允许通行",
InOrOut = (item.attendanceType == 1 ? "进门" : "出门"),
};
db.T_d_facerecord.InsertOnSubmit(newFacerecord);
db.SubmitChanges();
///// 根据出入记录 写入考勤记录
Model.t_d_facerecordItem facerecord = new Model.t_d_facerecordItem
{
ID = maxId + 1,
EmployName = name,
IDCardNo = item.idCardNumber,
EmployNO = item.idCardNumber,
ProjectId = projectId,
RoleID = "白名单",
DateTimeRecord = Funs.GetNewDateTime(item.attendanceTime),
RecordDes = "白名单:允许通行",
InOrOut = (item.attendanceType == 1 ? "进门" : "出门"),
};
DoorServerService.InsertEmployInOutRecord(facerecord);
if (facerecord.DateTimeRecord.HasValue)
{
int isIn = 0;
if (facerecord.InOrOut == "进门")
{
isIn = 1;
}
APIPersonService.getPersonInOut(facerecord.ProjectId, facerecord.EmployNO, isIn, facerecord.DateTimeRecord.Value);
}
}
APIPersonService.getPersonInOut(facerecord.ProjectId, facerecord.EmployNO, isIn, facerecord.DateTimeRecord.Value);
}
}
else
{
responeData.code = 0;
responeData.message = "项目号异常!";
}
}
else
{
responeData.code = 0;
responeData.message = "项目号为空!";
}
}
else
{
responeData.code = 0;
responeData.message = "数据为空!";
}
}
@ -106,25 +133,150 @@ namespace WebAPI.Controllers
}
#endregion
#region
#region
/// <summary>
/// 保存人员信息
/// </summary>
/// <param name="person">人员信息</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData person([FromBody] Model.attendanceItem person)
public Model.ResponeData person([FromBody] Model.PersonItem person)
{
var responeData = new Model.ResponeData();
try
{
if (person != null )
{
responeData.message="success";
if (person != null)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getProject = ProjectService.GetProjectByProjectCode(person.ProjectCode);
if (getProject != null)
{
var getPerson = PersonService.GetPersonByIdentityCard(getProject.ProjectId, person.IdentityCard);
if (getPerson == null)
{
Model.SitePerson_Person newPerson = new Model.SitePerson_Person
{
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,
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;
}
if (!string.IsNullOrEmpty(person.TeamGroupName) && !string.IsNullOrEmpty(newPerson.UnitId))
{
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
{
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();
}
}
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))
{
Directory.CreateDirectory(fileUrl);
}
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))
{
getPerson.OutTime = Funs.GetNewDateTime(person.OutTime);
PersonService.AddPerson(getPerson);
responeData.message = "更新出场时间";
}
else
{
responeData.message = "该身份证号码人员已存在!";
}
}
}
else
{
responeData.code = 0;
responeData.message = "项目号:" + person.ProjectCode + "不存在!";
}
}
}
else
{
responeData.code = 0;
responeData.message = "数据为空!";
}
}

Binary file not shown.