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); 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>
/// 添加 /// 添加
/// </summary> /// </summary>

View File

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Web;
namespace BLL namespace BLL
{ {
@ -414,5 +416,45 @@ namespace BLL
} }
} }
#endregion #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>
/// 根据身份证号获取人员信息 /// 根据身份证号获取人员信息
/// </summary> /// </summary>

View File

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

View File

@ -124,6 +124,11 @@ namespace BLL
orderby x.TeamGroupCode select x).ToList(); 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 #region
/// <summary> /// <summary>
/// 表下拉框 /// 表下拉框

View File

@ -167,6 +167,11 @@ namespace BLL
return Funs.DB.WBS_UnitWork.FirstOrDefault(e => e.UnitWorkId == UnitWorkId); 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>
/// 获取单位工程信息 /// 获取单位工程信息
/// </summary> /// </summary>

View File

@ -662,7 +662,18 @@ namespace BLL
{ {
return Funs.DB.Base_Unit.FirstOrDefault(e => e.UnitName == unitName); 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> /// <summary>
/// 根据项目Id获取单位名称项 /// 根据项目Id获取单位名称项
/// </summary> /// </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> <HintPath>..\..\..\CQMS_New\CQMS\FineUIPro.Web\bin\Aspose.Words.dll</HintPath>
</Reference> </Reference>
<Reference Include="AxInterop.SYNCARDOCXLib"> <Reference Include="AxInterop.SYNCARDOCXLib">
<HintPath>..\..\..\SGGL\SGGL\FineUIPro.Web\bin\AxInterop.SYNCARDOCXLib.dll</HintPath> <HintPath>..\FineUIPro\Reference BLL\AxInterop.SYNCARDOCXLib.dll</HintPath>
</Reference> </Reference>
<Reference Include="FineUIPro, Version=6.3.0.0, Culture=neutral, PublicKeyToken=9cbe753c029f291a, processorArchitecture=MSIL"> <Reference Include="FineUIPro, Version=6.3.0.0, Culture=neutral, PublicKeyToken=9cbe753c029f291a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -79,7 +79,7 @@
<Reference Include="Interop.WIA, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Interop.WIA, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes> <EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>..\..\..\SGGL\SGGL\FineUIPro.Web\bin\Interop.WIA.dll</HintPath> <HintPath>..\FineUIPro\Reference BLL\Interop.WIA.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"> <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="System.Xml.Linq" />
<Reference Include="ThoughtWorks.QRCode, Version=1.0.2774.19990, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ThoughtWorks.QRCode, Version=1.0.2774.19990, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\SGGL\SGGL\FineUIPro.Web\bin\ThoughtWorks.QRCode.dll</HintPath> <HintPath>..\FineUIPro\Reference BLL\ThoughtWorks.QRCode.dll</HintPath>
</Reference> </Reference>
<Reference Include="ThoughtWorks.QRCode.Fakes"> <Reference Include="ThoughtWorks.QRCode.Fakes">
<HintPath>FakesAssemblies\ThoughtWorks.QRCode.Fakes.dll</HintPath> <HintPath>FakesAssemblies\ThoughtWorks.QRCode.Fakes.dll</HintPath>

View File

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

View File

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

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
@ -14,7 +16,7 @@ namespace WebAPI.Controllers
/// </summary> /// </summary>
public class uploadController : ApiController public class uploadController : ApiController
{ {
#region #region
/// <summary> /// <summary>
/// 保存出入记录信息 /// 保存出入记录信息
/// </summary> /// </summary>
@ -29,9 +31,22 @@ namespace WebAPI.Controllers
if (records != null && records.records.Count() > 0) if (records != null && records.records.Count() > 0)
{ {
List<Model.attendanceItem> attendanceItems = records.records; List<Model.attendanceItem> attendanceItems = records.records;
var getprojectCode = attendanceItems.FirstOrDefault(x => x.ProjectCode != null || x.ProjectId != null);
if (getprojectCode != null)
{
string projectId = getprojectCode.ProjectId;
if (string.IsNullOrEmpty(projectId))
{
var getProject = ProjectService.GetProjectByProjectCode(getprojectCode.ProjectCode);
if (getProject != null)
{
projectId = getProject.ProjectId;
}
}
if (!string.IsNullOrEmpty(projectId))
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{ {
string projectId = "310e790e-5ede-4345-98a4-8bd0866e69ef"; ////潮州华瀛
int maxId = 0; int maxId = 0;
var getmax = db.T_d_facerecord.Where(x => x.ProjectId == projectId && x.RoleID == "白名单").Select(x => x.ID); var getmax = db.T_d_facerecord.Where(x => x.ProjectId == projectId && x.RoleID == "白名单").Select(x => x.ID);
if (getmax.Count() > 0) if (getmax.Count() > 0)
@ -88,11 +103,23 @@ namespace WebAPI.Controllers
APIPersonService.getPersonInOut(facerecord.ProjectId, facerecord.EmployNO, isIn, facerecord.DateTimeRecord.Value); APIPersonService.getPersonInOut(facerecord.ProjectId, facerecord.EmployNO, isIn, facerecord.DateTimeRecord.Value);
} }
} }
} }
} }
else else
{ {
responeData.code = 0;
responeData.message = "项目号异常!";
}
}
else
{
responeData.code = 0;
responeData.message = "项目号为空!";
}
}
else
{
responeData.code = 0;
responeData.message = "数据为空!"; responeData.message = "数据为空!";
} }
} }
@ -106,25 +133,150 @@ namespace WebAPI.Controllers
} }
#endregion #endregion
#region #region
/// <summary> /// <summary>
/// 保存人员信息 /// 保存人员信息
/// </summary> /// </summary>
/// <param name="person">人员信息</param> /// <param name="person">人员信息</param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public Model.ResponeData person([FromBody] Model.attendanceItem person) public Model.ResponeData person([FromBody] Model.PersonItem person)
{ {
var responeData = new Model.ResponeData(); var responeData = new Model.ResponeData();
try try
{ {
if (person != null) if (person != null)
{ {
responeData.message="success"; 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 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 = "数据为空!"; responeData.message = "数据为空!";
} }
} }

Binary file not shown.