84 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C#
		
	
	
	
using EmitMapper;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
 | 
						|
namespace BLL
 | 
						|
{
 | 
						|
    public static class APIDoorServerService
 | 
						|
    {
 | 
						|
        /// <summary>
 | 
						|
        /// 保存 出入记录
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="projectId">项目ID</param>
 | 
						|
        /// <param name="idCard">身份证号码</param>
 | 
						|
        /// <param name="isIn">1进0出</param>
 | 
						|
        /// <param name="changeTime">进出时间</param>
 | 
						|
        /// <param name="changeTime">进出方式</param>
 | 
						|
        public static void SaveDoorInOutRecord(string projectId, string idCard, int isIn, DateTime changeTime, string Intype)
 | 
						|
        {
 | 
						|
            Model.SitePerson_Person getPerson = new Model.SitePerson_Person();
 | 
						|
            int maxId = 0;
 | 
						|
            string name = string.Empty;
 | 
						|
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
 | 
						|
            {
 | 
						|
                getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == idCard && x.ProjectId == projectId);
 | 
						|
                if (getPerson != null)
 | 
						|
                {
 | 
						|
                    name = getPerson.PersonName;
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    getPerson = db.SitePerson_Person.Where(x => x.IdentityCard == idCard).OrderByDescending(x => x.InTime).FirstOrDefault();
 | 
						|
                    if (getPerson != null)
 | 
						|
                    {
 | 
						|
                        name = getPerson.PersonName;
 | 
						|
                        projectId = getPerson.ProjectId;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
 | 
						|
                var getmax = db.T_d_facerecord.Where(x => x.ProjectId == projectId && x.RoleID == Intype).Select(x => x.ID);
 | 
						|
                if (getmax.Count() > 0)
 | 
						|
                {
 | 
						|
                    maxId = getmax.Max() + 1;
 | 
						|
                }
 | 
						|
 | 
						|
                Model.T_d_facerecord newFacerecord = new Model.T_d_facerecord()
 | 
						|
                {
 | 
						|
                    NewID = SQLHelper.GetNewID(),
 | 
						|
                    ProjectId = projectId,
 | 
						|
                    ID = maxId + 1,
 | 
						|
                    EmployName = name,
 | 
						|
                    EmployNO = idCard,
 | 
						|
                    RoleID = Intype,
 | 
						|
                    DateTimeRecord = changeTime,
 | 
						|
                    RecordDes = Intype,
 | 
						|
                    InOrOut = (isIn == 1 ? "进门" : "出门"),
 | 
						|
                };
 | 
						|
                db.T_d_facerecord.InsertOnSubmit(newFacerecord);
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
 | 
						|
            if (getPerson != null)
 | 
						|
            {
 | 
						|
                ///// 根据出入记录 写入考勤记录
 | 
						|
                Model.t_d_facerecordItem facerecord = new Model.t_d_facerecordItem
 | 
						|
                {
 | 
						|
                    ID = maxId + 1,
 | 
						|
                    EmployName = name,
 | 
						|
                    IDCardNo = idCard,
 | 
						|
                    EmployNO = idCard,
 | 
						|
                    ProjectId = projectId,
 | 
						|
                    RoleID = Intype,
 | 
						|
                    DateTimeRecord = changeTime,
 | 
						|
                    RecordDes = Intype,
 | 
						|
                    InOrOut = (isIn == 1 ? "进门" : "出门"),
 | 
						|
                };
 | 
						|
 | 
						|
                DoorServerService.InsertEmployInOutRecord(facerecord, getPerson);
 | 
						|
                APIPersonService.getPersonInOut(getPerson, isIn, changeTime);
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |