祥云 考勤数据同步
This commit is contained in:
parent
c699a8dcd0
commit
b600761659
|
@ -5,12 +5,158 @@ using System.Linq;
|
||||||
using System.Web.UI.WebControls;
|
using System.Web.UI.WebControls;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
//using Microsoft.SqlServer.Dts.Runtime;
|
//using Microsoft.SqlServer.Dts.Runtime;
|
||||||
|
|
||||||
namespace BLL
|
namespace BLL
|
||||||
{
|
{
|
||||||
public class MonitorService
|
public class MonitorService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
private static Timer inOutTimer1;
|
||||||
|
|
||||||
|
public static void StartInOutSync()
|
||||||
|
{
|
||||||
|
ErrLogInfo.WriteLog("启用出入定时器开始!");
|
||||||
|
if (inOutTimer1 != null)
|
||||||
|
{
|
||||||
|
inOutTimer1.Stop();
|
||||||
|
inOutTimer1.Dispose();
|
||||||
|
inOutTimer1 = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
inOutTimer1 = new Timer
|
||||||
|
{
|
||||||
|
AutoReset = true
|
||||||
|
};
|
||||||
|
inOutTimer1.Elapsed += new ElapsedEventHandler(InOutProcess1);
|
||||||
|
inOutTimer1.Interval = 1000 * 60 * 10;// 60分钟 60000 * adTimeJ;
|
||||||
|
inOutTimer1.Start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ErrLogInfo.WriteLog("启用出入定时器结束!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void InOutProcess1(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
ErrLogInfo.WriteLog("氟化工出入同步开始");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var db = Funs.DB;
|
||||||
|
string projectid1 = "a6cedfb2-d90a-434e-bc2a-0e4a651c1cf3";
|
||||||
|
|
||||||
|
var intout1 = db.SitePerson_PersonInOut.Where(x => x.ProjectId == projectid1).OrderByDescending(x => x.ChangeTime).FirstOrDefault();
|
||||||
|
DateTime date = DateTime.Now.AddDays(-1);
|
||||||
|
if (intout1 != null && intout1.ChangeTime.HasValue)
|
||||||
|
{
|
||||||
|
date = intout1.ChangeTime.Value;
|
||||||
|
}
|
||||||
|
int page = 1;
|
||||||
|
int size = 100;
|
||||||
|
while (size > 0)
|
||||||
|
{
|
||||||
|
string result2 = APIGetHttpService.Http("http://219.139.48.4:8098/api/transaction/list?startDate=" + date.ToString("yyyy-MM-dd HH:mm:ss") + "&endDate=" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "&pageNo=" + page + "&pageSize=100&access_token=DE2930A5E95BDECC6AC6C39A6A18FBAE17951BB668F50A35F28C883C324B8DF0", "GET", "application/json;charset=utf-8", null, null);
|
||||||
|
|
||||||
|
var j2 = JsonConvert.DeserializeObject<dynamic>(result2);
|
||||||
|
size = j2.data.Count;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
string name = "" + j2.data[i].name;
|
||||||
|
string eventTime = "" + j2.data[i].eventTime;
|
||||||
|
string readerName = "" + j2.data[i].readerName;
|
||||||
|
string projectid = projectid1;
|
||||||
|
string idCard = "";
|
||||||
|
string Intype = "白名单";
|
||||||
|
int maxId = 0;
|
||||||
|
int isIn = 0;
|
||||||
|
DateTime changeTime = DateTime.Parse(eventTime);
|
||||||
|
if (!string.IsNullOrEmpty(readerName) && readerName.Contains("入"))
|
||||||
|
{
|
||||||
|
isIn = 1;
|
||||||
|
}
|
||||||
|
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonName == name && x.ProjectId == projectid);
|
||||||
|
if (getPerson != null)
|
||||||
|
{
|
||||||
|
name = getPerson.PersonName;
|
||||||
|
idCard = getPerson.IdentityCard;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getPerson = db.SitePerson_Person.Where(x => x.PersonName == name).OrderByDescending(x => x.InTime).FirstOrDefault();
|
||||||
|
if (getPerson != null)
|
||||||
|
{
|
||||||
|
name = getPerson.PersonName;
|
||||||
|
projectid = getPerson.ProjectId;
|
||||||
|
idCard = getPerson.IdentityCard;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) { ErrLogInfo.WriteLog("氟化工出入同步出错2!" + ex.StackTrace + "/n" + ex.Message); }
|
||||||
|
|
||||||
|
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception eee) { }
|
||||||
|
ErrLogInfo.WriteLog("氟化工出入同步结束");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region 启动监视器 系统启动5分钟
|
#region 启动监视器 系统启动5分钟
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 监视组件
|
/// 监视组件
|
||||||
|
|
|
@ -117,6 +117,8 @@
|
||||||
QuartzServices.Init();
|
QuartzServices.Init();
|
||||||
BLL.MonitorService.StartMonitor();
|
BLL.MonitorService.StartMonitor();
|
||||||
BLL.MonitorService.StartMonitorEve();
|
BLL.MonitorService.StartMonitorEve();
|
||||||
|
BLL.MonitorService.StartInOutSync();
|
||||||
|
|
||||||
// BLL.MonitorService.StartPersonQuarterCheck();
|
// BLL.MonitorService.StartPersonQuarterCheck();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
Loading…
Reference in New Issue