This commit is contained in:
gaofei
2022-05-22 10:35:38 +08:00
34 changed files with 952 additions and 171 deletions
+3 -1
View File
@@ -30,6 +30,7 @@ namespace BLL
}
}
request.Headers.Add("token", "AF17168B-87BD-4GLY-1111-F0A0A1158F9B");
request.Timeout = 20000; /// 设置5秒超时
if (!string.IsNullOrEmpty(data))
{
Stream RequestStream = request.GetRequestStream();
@@ -92,7 +93,7 @@ namespace BLL
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = string.IsNullOrEmpty(method) ? "GET" : method;
request.ContentType = string.IsNullOrEmpty(contenttype) ? "application/json;charset=utf-8" : contenttype;
request.ContentType = string.IsNullOrEmpty(contenttype) ? "application/json;charset=utf-8" : contenttype;
if (header != null)
{
foreach (var i in header.Keys)
@@ -161,6 +162,7 @@ namespace BLL
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = string.IsNullOrEmpty(method) ? "GET" : method;
request.ContentType = string.IsNullOrEmpty(contenttype) ? "application/json;charset=utf-8" : contenttype;
request.Timeout = 20000; /// 设置5秒超时
if (header != null)
{
foreach (var i in header.Keys)
+32 -29
View File
@@ -56,35 +56,38 @@ namespace BLL
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = from x in db.Training_TestPlan
where x.TestPlanId == testPlanId
select new Model.TestPlanItem
{
TestPlanId = x.TestPlanId,
ProjectId = x.ProjectId,
TestPlanCode = x.PlanCode,
TestPlanName = x.PlanName,
TestPlanManId = x.PlanManId,
TestPlanManName = db.Sys_User.First(y => y.UserId == x.TestPlanId).UserName,
TestPlanDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.PlanDate),
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
Duration = x.Duration,
SValue = x.SValue,
MValue = x.MValue,
JValue = x.JValue,
TotalScore = x.TotalScore ?? 0,
QuestionCount = x.QuestionCount ?? 0,
TestPalce = x.TestPalce,
UnitIds = x.UnitIds,
UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds),
WorkPostIds = x.WorkPostIds,
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostIds),
States = x.States,
QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'),
TrainingPlanId = x.PlanId,
};
return getDataLists.FirstOrDefault();
Model.TestPlanItem returnItem = new Model.TestPlanItem();
var getTestP = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == testPlanId);
if (getTestP != null)
{
returnItem.TestPlanId = getTestP.TestPlanId;
returnItem.ProjectId = getTestP.ProjectId;
returnItem.TestPlanCode = getTestP.PlanCode;
returnItem.TestPlanName = getTestP.PlanName;
returnItem.TestPlanManId = getTestP.PlanManId;
returnItem.TestPlanManName = UserService.GetUserNameByUserId(getTestP.PlanManId);
returnItem.TestPlanDate = getTestP.PlanDate.HasValue ? string.Format("{0:yyyy-MM-dd HH:mm}", getTestP.PlanDate) : "";
returnItem.TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", getTestP.TestStartTime);
returnItem.TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", getTestP.TestEndTime);
returnItem.Duration = getTestP.Duration;
returnItem.SValue = getTestP.SValue;
returnItem.MValue = getTestP.MValue;
returnItem.JValue = getTestP.JValue;
returnItem.TotalScore = getTestP.TotalScore ?? 0;
returnItem.QuestionCount = getTestP.QuestionCount ?? 0;
returnItem.TestPalce = getTestP.TestPalce;
returnItem.UnitIds = getTestP.UnitIds;
returnItem.UnitNames = UnitService.getUnitNamesUnitIds(getTestP.UnitIds);
returnItem.WorkPostIds = getTestP.WorkPostIds;
returnItem.WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(getTestP.WorkPostIds);
returnItem.States = getTestP.States;
if (!string.IsNullOrEmpty(getTestP.QRCodeUrl))
{
returnItem.QRCodeUrl = getTestP.QRCodeUrl.Replace('\\', '/');
}
returnItem.TrainingPlanId = getTestP.PlanId;
}
return returnItem;
}
}
#endregion
+95 -31
View File
@@ -21,6 +21,7 @@ namespace BLL
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.Training_TestRecord
join y in db.SitePerson_Person on x.TestManId equals y.PersonId
where x.TestPlanId == testPlanId
orderby x.TestStartTime descending
select new Model.TestRecordItem
@@ -29,7 +30,7 @@ namespace BLL
ProjectId = x.ProjectId,
TestPlanId = x.TestPlanId,
TestManId = x.TestManId,
TestManName = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == x.TestManId).PersonName,
TestManName = y.PersonName,
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
TestScores = x.TestScores ?? 0,
@@ -39,6 +40,25 @@ namespace BLL
return getDataLists;
}
}
/// <summary>
/// 根据TestPlanId获取考试人员列表
/// </summary>
/// <param name="testPlanId"></param>
/// <returns>考试人员</returns>
public static string getTestRecordTestManByTestPlanId(string testPlanId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
string name = string.Empty;
var getManList = db.Training_TestRecord.Where(x => x.TestPlanId == testPlanId).Select(x => x.TestManId).Distinct();
if (getManList.Count() > 0)
{
name = PersonService.getPersonsPersonIds(getManList.ToList());
}
return name;
}
}
#endregion
#region ID获取试卷记录详细
@@ -99,14 +119,32 @@ namespace BLL
if (item == null)
{
List<Model.Training_TestTrainingItem> getTestTrainingItemList = new List<Model.Training_TestTrainingItem>();
//// 计划考试中单选、多选、判断题总数
int sumTestType1Count =0;
int sumTestType2Count = 0;
int sumTestType3Count = 0;
var testPlanTrainings = from x in db.Training_TestPlanTraining
where x.TestPlanId == getTestPlan.TestPlanId
select x;
//// 计划考试中单选、多选、判断题总数
int sumTestType1Count = testPlanTrainings.Sum(x => x.TestType1Count) ?? 0;
int sumTestType2Count = testPlanTrainings.Sum(x => x.TestType2Count) ?? 0;
int sumTestType3Count = testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
if (testPlanTrainings.Count() > 0)
{
//// 计划考试中单选、多选、判断题总数
sumTestType1Count = testPlanTrainings.Sum(x => x.TestType1Count) ?? 0;
sumTestType2Count = testPlanTrainings.Sum(x => x.TestType2Count) ?? 0;
sumTestType3Count = testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
}
else
{
var getTestRule = db.Sys_TestRule.FirstOrDefault();
if (getTestRule != null)
{
sumTestType1Count = getTestRule.SCount;
sumTestType2Count = getTestRule.MCount;
sumTestType3Count = getTestRule.JCount;
}
}
////获取类型下适合岗位试题集合
var getTestTrainingItemALLs = from x in db.Training_TestTrainingItem
where x.TrainingId != null && (x.WorkPostIds == null || (x.WorkPostIds.Contains(person.WorkPostId) && person.WorkPostId != null))
@@ -331,38 +369,64 @@ namespace BLL
#region TestRecordId获取试卷题目列表
/// <summary>
/// 记录数
/// </summary>
public static int geTestRecordItemCount
{
get;
set;
}
/// <summary>
/// 根据TestRecordId获取试卷题目列表
/// </summary>
/// <param name="testPlanId"></param>
/// <returns>考试人员</returns>
public static List<Model.TestRecordItemItem> geTestRecordItemListByTestRecordId(string testRecordId)
public static List<Model.TestRecordItemItem> geTestRecordItemListByTestRecordId(string testRecordId, int pageIndex)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.Training_TestRecordItem
where x.TestRecordId == testRecordId
orderby x.TestType, x.TrainingItemCode
select new Model.TestRecordItemItem
{
TestRecordItemId = x.TestRecordItemId,
TestRecordId = x.TestRecordId,
TrainingItemCode = x.TrainingItemCode,
TrainingItemName = x.TrainingItemName,
Abstracts = x.Abstracts,
AttachUrl = x.AttachUrl.Replace("\\", "/") ?? "",
TestType = x.TestType,
TestTypeName = x.TestType == "1" ? "单选题" : (x.TestType == "2" ? "多选题" : "判断题"),
AItem = x.AItem ?? "",
BItem = x.BItem ?? "",
CItem = x.CItem ?? "",
DItem = x.DItem ?? "",
EItem = x.EItem ?? "",
AnswerItems = x.AnswerItems ?? "",
Score = x.Score ?? 0,
SubjectScore = x.SubjectScore ?? 0,
SelectedItem = x.SelectedItem ?? "",
}).ToList();
return getDataLists;
var getDatas= from x in db.Training_TestRecordItem
where x.TestRecordId == testRecordId
select x;
geTestRecordItemCount = getDatas.Count();
if (geTestRecordItemCount == 0)
{
return null;
}
else
{
var getDataLists = from x in getDatas
orderby x.TestType, x.TrainingItemCode
select new Model.TestRecordItemItem
{
TestRecordItemId = x.TestRecordItemId,
TestRecordId = x.TestRecordId,
TrainingItemCode = x.TrainingItemCode,
TrainingItemName = x.TrainingItemName,
Abstracts = x.Abstracts,
AttachUrl = x.AttachUrl.Replace("\\", "/") ?? "",
TestType = x.TestType,
TestTypeName = x.TestType == "1" ? "单选题" : (x.TestType == "2" ? "多选题" : "判断题"),
AItem = x.AItem ?? "",
BItem = x.BItem ?? "",
CItem = x.CItem ?? "",
DItem = x.DItem ?? "",
EItem = x.EItem ?? "",
AnswerItems = x.AnswerItems ?? "",
Score = x.Score ?? 0,
SubjectScore = x.SubjectScore ?? 0,
SelectedItem = x.SelectedItem ?? "",
};
if (pageIndex > 0)
{
return getDataLists.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
}
else
{
return getDataLists.ToList();
}
}
}
}
#endregion
+26 -1
View File
@@ -63,7 +63,8 @@ namespace BLL
}
if (!string.IsNullOrEmpty(workPostIds))
{
getPersonList = getPersonList.Where(x => workPostIds.Contains(x.WorkPostId));
List<string> wIds = Funs.GetStrListByStr(workPostIds, ',');
getPersonList = getPersonList.Where(x => wIds.Contains(x.WorkPostId));
}
if (ckTrain)
{
@@ -197,6 +198,30 @@ namespace BLL
return personId;
}
#region ID得到用户名称字符串
/// <summary>
/// 根据多用户ID得到用户名称字符串
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
public static string getPersonsPersonIds(List<string> personIds)
{
string personName = string.Empty;
foreach (string id in personIds)
{
var q = GetPersonNameById(id);
if (q != null)
{
personName += q + ",";
}
}
if (!string.IsNullOrEmpty(personName))
{
personName = personName.Substring(0, personName.Length - 1); ;
}
return personName;
}
#endregion
/// <summary>
/// 根据UserId主键获取人员信息
/// </summary>
+209 -30
View File
@@ -7,23 +7,19 @@ namespace BLL
{
public class RealNameMonitorService
{
#region 5
#region 5
/// <summary>
/// 监视组件
/// </summary>
private static Timer messageTimer;
// private static Timer messageTimer;
/// <summary>
/// 启动监视器,不一定能成功,根据系统设置决定对监视器执行的操作 系统启动5分钟
/// </summary>
public static void StartMonitor()
{
int adTimeJ = Funs.GetNewInt(ConfigurationManager.AppSettings["Intervaltime"]) ?? 30;
//var getSynchroSet = Funs.DB.RealName_SynchroSet.FirstOrDefault();
//if (getSynchroSet != null && getSynchroSet.Intervaltime.HasValue)
//{
// adTimeJ = getSynchroSet.Intervaltime.Value;
//}
public static void StartMonitor(string jtProCode)
{
int adTimeJ = Funs.GetNewInt(ConfigurationManager.AppSettings["Intervaltime"]) ?? 30;
Timer messageTimer = new Timer();
if (messageTimer != null)
{
messageTimer.Stop();
@@ -36,7 +32,8 @@ namespace BLL
{
AutoReset = true
};
messageTimer.Elapsed += new ElapsedEventHandler(AdUserInProcess);
messageTimer.Elapsed += (sender, args) => AdUserInProcess(sender, jtProCode);
//messageTimer.Elapsed += new ElapsedEventHandler(AdUserInProcess);
messageTimer.Interval = 1000 * 60 * adTimeJ;// 60分钟 60000 * adTimeJ;
messageTimer.Start();
}
@@ -47,34 +44,25 @@ namespace BLL
/// </summary>
/// <param name="sender">Timer组件</param>
/// <param name="e">事件参数</param>
private static void AdUserInProcess(object sender, ElapsedEventArgs e)
public static void AdUserInProcess(object sender, string jtProCode)
{
try
{
SynchroSetService.PushCollCompany();
var getRProjects = from x in Funs.DB.RealName_Project
select x;
if (getRProjects.Count() > 0)
if (!string.IsNullOrEmpty(jtProCode))
{
foreach (var item in getRProjects)
{
var getSynchroSet = Funs.DB.RealName_SynchroSet.FirstOrDefault(x => x.ProCode == item.JTproCode);
if (getSynchroSet != null && !string.IsNullOrEmpty(item.JTproCode))
{
SynchroSetService.PushProCollCompany(item.JTproCode);
//SynchroSetService.PushCollTeam(item.ProCode);
//SynchroSetService.getCollTeam(item.ProCode);
SynchroSetService.PushPersons(Const.BtnAdd, item.JTproCode, null);
SynchroSetService.PushPersons(Const.BtnModify, item.JTproCode, null);
SynchroSetService.PushAttendance(item.JTproCode);
SynchroSetService.updatePersonsExitTime(item.JTproCode);
}
}
SynchroSetService.PushProCollCompany(jtProCode);
SynchroSetService.PushCollTeam(jtProCode);
SynchroSetService.getCollTeam(jtProCode);
SynchroSetService.PushPersons(Const.BtnAdd, jtProCode, null);
SynchroSetService.PushPersons(Const.BtnModify, jtProCode, null);
SynchroSetService.PushAttendance(jtProCode);
SynchroSetService.updatePersonsExitTime(jtProCode);
}
}
catch (Exception ex)
{
StartMonitor();
StartMonitor(jtProCode);
ErrLogInfo.WriteLog(ex, "数据接口定时器", "RealNameMonitorService.AdUserInProcess");
}
}
@@ -176,5 +164,196 @@ namespace BLL
}
}
#endregion
#region
/// <summary>
/// 监视组件
/// </summary>
private static Timer messageTimer1;
/// <summary>
/// 定时清理推送日志
/// </summary>
public static void StartMonitorDeletePushLog()
{
int adTimeJ = 60 * 12;
if (messageTimer1 != null)
{
messageTimer1.Stop();
messageTimer1.Dispose();
messageTimer1 = null;
}
if (adTimeJ > 0)
{
messageTimer1 = new Timer
{
AutoReset = true
};
messageTimer1.Elapsed += new ElapsedEventHandler(DeletePushLog);
messageTimer1.Interval = 1000 * 60 * adTimeJ;// 60分钟 60000 * adTimeJ;
messageTimer1.Start();
}
}
/// <summary>
/// 流程确认 定时执行 系统启动5分钟
/// </summary>
/// <param name="sender">Timer组件</param>
/// <param name="e">事件参数</param>
private static void DeletePushLog(object sender, ElapsedEventArgs e)
{
try
{
/// 3天推送实名制日志
var getPushLogs = Funs.DB.RealName_PushLog.Where(x => x.PushTime.Value.AddDays(3) < DateTime.Now);
if (getPushLogs.Count() > 0)
{
Funs.DB.RealName_PushLog.DeleteAllOnSubmit(getPushLogs);
Funs.DB.SubmitChanges();
}
/// 3个月操作日志
var getSys_Logs = Funs.DB.Sys_Log.Where(x => x.OperationTime.Value.AddMonths(3) < DateTime.Now);
if (getSys_Logs.Count() > 0)
{
Funs.DB.Sys_Log.DeleteAllOnSubmit(getSys_Logs);
Funs.DB.SubmitChanges();
}
/// 1个月推送消息日志
var getSys_HttpLogs = Funs.DB.Sys_HttpLog.Where(x => x.LogTime.Value.AddMonths(1) < DateTime.Now);
if (getSys_HttpLogs.Count() > 0)
{
Funs.DB.Sys_HttpLog.DeleteAllOnSubmit(getSys_HttpLogs);
Funs.DB.SubmitChanges();
}
}
catch (Exception ex)
{
}
}
#endregion
#region
/// <summary>
/// 监视组件
/// </summary>
private static Timer messageTimer2;
/// <summary>
/// 定时清理推送日志
/// </summary>
public static void StartMonitorCleanAttendance()
{
int adTimeJ = 60 * 12;
if (messageTimer2 != null)
{
messageTimer2.Stop();
messageTimer2.Dispose();
messageTimer2 = null;
}
if (adTimeJ > 0)
{
messageTimer2 = new Timer
{
AutoReset = true
};
messageTimer2.Elapsed += new ElapsedEventHandler(CleanAttendance);
messageTimer2.Interval = 1000 * 60 * adTimeJ;// 60分钟 60000 * adTimeJ;
messageTimer2.Start();
}
}
/// <summary>
/// 流程确认 定时执行 系统启动5分钟
/// </summary>
/// <param name="sender">Timer组件</param>
/// <param name="e">事件参数</param>
private static void CleanAttendance(object sender, ElapsedEventArgs e)
{
try
{
/// 清理出入记录
var getRecords = from x in Funs.DB.T_d_facerecord where x.DateTimeRecord.Value.AddDays(1) < DateTime.Now select x;
if (getRecords.Count() > 0)
{
foreach (var item in getRecords)
{
if (item.InOrOut == "进门")
{
var getDelRecordsIn = from x in Funs.DB.T_d_facerecord
where x.ProjectId == item.ProjectId && x.EmployNO == item.EmployNO && x.InOrOut == item.InOrOut
&& x.DateTimeRecord.Value.Year == item.DateTimeRecord.Value.Year
&& x.DateTimeRecord.Value.Month == item.DateTimeRecord.Value.Month
&& x.DateTimeRecord.Value.Day == item.DateTimeRecord.Value.Day
&& x.DateTimeRecord > item.DateTimeRecord
select x;
if (getDelRecordsIn.Count() > 0)
{
Funs.DB.T_d_facerecord.DeleteAllOnSubmit(getDelRecordsIn);
Funs.DB.SubmitChanges();
}
}
else
{
var getDelRecordsOut = from x in Funs.DB.T_d_facerecord
where x.ProjectId == item.ProjectId && x.EmployNO == item.EmployNO && x.InOrOut == item.InOrOut
&& x.DateTimeRecord.Value.Year == item.DateTimeRecord.Value.Year
&& x.DateTimeRecord.Value.Month == item.DateTimeRecord.Value.Month
&& x.DateTimeRecord.Value.Day == item.DateTimeRecord.Value.Day
&& x.DateTimeRecord < item.DateTimeRecord
select x;
if (getDelRecordsOut.Count() > 0)
{
Funs.DB.T_d_facerecord.DeleteAllOnSubmit(getDelRecordsOut);
Funs.DB.SubmitChanges();
}
}
}
}
var getVRecords = from x in Funs.DB.T_d_validcardevent
where x.RecordDateTime.Value.AddDays(1) < DateTime.Now
select x;
if (getVRecords.Count() > 0)
{
foreach (var item in getVRecords)
{
if (item.InOrOut == 1)
{
var getDelVRecordsIn = from x in Funs.DB.T_d_validcardevent
where x.ProjectId == item.ProjectId && x.IDCardNo == item.IDCardNo && x.InOrOut == item.InOrOut
&& x.RecordDateTime.Value.Year == item.RecordDateTime.Value.Year
&& x.RecordDateTime.Value.Month == item.RecordDateTime.Value.Month
&& x.RecordDateTime.Value.Day == item.RecordDateTime.Value.Day
&& x.RecordDateTime > item.RecordDateTime
select x;
if (getDelVRecordsIn.Count() > 0)
{
Funs.DB.T_d_validcardevent.DeleteAllOnSubmit(getDelVRecordsIn);
Funs.DB.SubmitChanges();
}
}
else
{
var getDelVRecordsOut = from x in Funs.DB.T_d_validcardevent
where x.ProjectId == item.ProjectId && x.IDCardNo == item.IDCardNo && x.InOrOut == item.InOrOut
&& x.RecordDateTime.Value.Year == item.RecordDateTime.Value.Year
&& x.RecordDateTime.Value.Month == item.RecordDateTime.Value.Month
&& x.RecordDateTime.Value.Day == item.RecordDateTime.Value.Day
&& x.RecordDateTime < item.RecordDateTime
select x;
if (getDelVRecordsOut.Count() > 0)
{
Funs.DB.T_d_validcardevent.DeleteAllOnSubmit(getDelVRecordsOut);
Funs.DB.SubmitChanges();
}
}
}
}
}
catch (Exception ex)
{
}
}
#endregion
}
}
+13 -1
View File
@@ -56,6 +56,11 @@ namespace BLL
}
#endregion
public static List<Model.RealName_Project> GetRealNameProject()
{
return (from x in Funs.DB.RealName_Project select x).ToList();
}
#region
/// <summary>
/// 表下拉框
@@ -1426,7 +1431,14 @@ namespace BLL
addTeam(getData.Select(x => x.TeamGroupId).Distinct().ToList(), newToken);
getTeam(proCode, newToken);
addPerson(getData.Select(x => x.PersonId).Distinct().ToList(), newToken);
var getPersonS = getData.Select(x => x.idcardNumber).Distinct().ToList();
foreach (var pitem in getPersonS)
{
PushPersonsByIdentityCard(Const.BtnAdd, proCode, pitem);
PushPersonsByIdentityCard(Const.BtnModify, proCode, pitem);
}
pushContent = JsonConvert.SerializeObject(listObject);
var returndata = BLL.APIGetHttpService.OutsideHttp(url, "POST", null, newToken, pushContent);
if (!string.IsNullOrEmpty(returndata))