1、优化考勤记录导入,优化出入记录写实名制推送记录表。2、优化考试答题,交卷接口方法。3、优化写入培训记录。
This commit is contained in:
@@ -17,19 +17,20 @@ namespace BLL
|
||||
/// <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))
|
||||
{
|
||||
int maxId = 0;
|
||||
string name = string.Empty;
|
||||
var getPersonByIdCard = db.SitePerson_Person.Where(x => x.IdentityCard == idCard).OrderByDescending(x=>x.InTime).FirstOrDefault();
|
||||
if (getPersonByIdCard != null)
|
||||
getPerson = db.SitePerson_Person.Where(x => x.IdentityCard == idCard).OrderByDescending(x => x.InTime).FirstOrDefault();
|
||||
if (getPerson != null)
|
||||
{
|
||||
name = getPersonByIdCard.PersonName;
|
||||
projectId = getPersonByIdCard.ProjectId;
|
||||
name = getPerson.PersonName;
|
||||
projectId = getPerson.ProjectId;
|
||||
}
|
||||
else
|
||||
{
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == idCard && x.ProjectId == projectId);
|
||||
getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == idCard && x.ProjectId == projectId);
|
||||
if (getPerson != null)
|
||||
{
|
||||
name = getPerson.PersonName;
|
||||
@@ -41,7 +42,7 @@ namespace BLL
|
||||
{
|
||||
maxId = getmax.Max() + 1;
|
||||
}
|
||||
|
||||
|
||||
Model.T_d_facerecord newFacerecord = new Model.T_d_facerecord()
|
||||
{
|
||||
NewID = SQLHelper.GetNewID(),
|
||||
@@ -56,7 +57,10 @@ namespace BLL
|
||||
};
|
||||
db.T_d_facerecord.InsertOnSubmit(newFacerecord);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
if (getPerson != null)
|
||||
{
|
||||
///// 根据出入记录 写入考勤记录
|
||||
Model.t_d_facerecordItem facerecord = new Model.t_d_facerecordItem
|
||||
{
|
||||
@@ -70,9 +74,10 @@ namespace BLL
|
||||
RecordDes = Intype,
|
||||
InOrOut = (isIn == 1 ? "进门" : "出门"),
|
||||
};
|
||||
DoorServerService.InsertEmployInOutRecord(facerecord);
|
||||
|
||||
DoorServerService.InsertEmployInOutRecord(facerecord, getPerson);
|
||||
APIPersonService.getPersonInOut(getPerson, isIn, changeTime);
|
||||
}
|
||||
APIPersonService.getPersonInOut(projectId, idCard, isIn, changeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1046,13 +1046,12 @@ namespace BLL
|
||||
/// <param name="idCard"></param>
|
||||
/// <param name="isIn"></param>
|
||||
/// <param name="changeTime"></param>
|
||||
public static void getPersonInOut(string projectId, string idCard, int isIn, DateTime changeTime)
|
||||
public static void getPersonInOut(Model.SitePerson_Person getPerson, int isIn, DateTime changeTime)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(idCard))
|
||||
if (!string.IsNullOrEmpty(getPerson.IdentityCard))
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.ProjectId == projectId && x.IdentityCard == idCard);
|
||||
{
|
||||
if (getPerson != null)
|
||||
{
|
||||
string postType = null;
|
||||
@@ -1061,13 +1060,13 @@ namespace BLL
|
||||
{
|
||||
postType = getWokPost.PostType;
|
||||
}
|
||||
var getPersonInOut = db.SitePerson_PersonInOut.FirstOrDefault(x => x.PersonId == getPerson.PersonId && x.ProjectId == projectId && x.ChangeTime == changeTime);
|
||||
var getPersonInOut = db.SitePerson_PersonInOut.FirstOrDefault(x => x.PersonId == getPerson.PersonId && x.ProjectId == getPerson.ProjectId && x.ChangeTime == changeTime);
|
||||
if (getPersonInOut == null)
|
||||
{
|
||||
Model.SitePerson_PersonInOut newInOut = new Model.SitePerson_PersonInOut
|
||||
{
|
||||
PersonInOutId = SQLHelper.GetNewID(),
|
||||
ProjectId = projectId,
|
||||
ProjectId = getPerson.ProjectId,
|
||||
UnitId = getPerson.UnitId,
|
||||
PersonId = getPerson.PersonId,
|
||||
IsIn = isIn == 1 ? true : false,
|
||||
@@ -1079,7 +1078,7 @@ namespace BLL
|
||||
db.SitePerson_PersonInOut.InsertOnSubmit(newInOut);
|
||||
db.SubmitChanges();
|
||||
|
||||
string proCode = ProjectService.GetJTProjectCodeByProjectId(projectId);
|
||||
string proCode = ProjectService.GetJTProjectCodeByProjectId(getPerson.ProjectId);
|
||||
Model.SitePerson_PersonInOutNow newNow = new Model.SitePerson_PersonInOutNow
|
||||
{
|
||||
PersonInOutId = newInOut.PersonInOutId,
|
||||
|
||||
@@ -245,6 +245,14 @@ namespace BLL
|
||||
TestType = item.TestType,
|
||||
Duration = newTestPlan.Duration,
|
||||
};
|
||||
if (string.IsNullOrEmpty(newTrainDetail.TestType))
|
||||
{
|
||||
var getTrainTypeName = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTrainDetail.TestPlanId);
|
||||
if (getTrainTypeName != null)
|
||||
{
|
||||
newTrainDetail.TestType = getTrainTypeName.PlanName;
|
||||
}
|
||||
}
|
||||
db.Training_TestRecord.InsertOnSubmit(newTrainDetail);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ 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
|
||||
@@ -30,7 +29,7 @@ namespace BLL
|
||||
ProjectId = x.ProjectId,
|
||||
TestPlanId = x.TestPlanId,
|
||||
TestManId = x.TestManId,
|
||||
TestManName = y.PersonName,
|
||||
//TestManName = db.SitePerson_Person.First(p=>x.TestManId ==p.PersonId).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,
|
||||
@@ -100,21 +99,20 @@ namespace BLL
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getDataLists = from x in db.Training_TestRecord
|
||||
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
|
||||
var getDataLists = from x in db.Training_TestRecord
|
||||
where x.TestRecordId == testRecordId
|
||||
select new Model.TestRecordItem
|
||||
{
|
||||
TestRecordId = x.TestRecordId,
|
||||
ProjectId = x.ProjectId,
|
||||
TestPlanId = x.TestPlanId,
|
||||
TestPlanName = y.PlanName,
|
||||
TestPlanName = x.TestType,
|
||||
TestManId = x.TestManId,
|
||||
TestManName = db.SitePerson_Person.First(u => u.PersonId == x.TestManId).PersonName,
|
||||
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
|
||||
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
|
||||
TestPlanEndTime = x.TestStartTime.HasValue ? string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime.Value.AddMinutes(x.Duration)) : "",
|
||||
Duration = y.Duration,
|
||||
Duration = x.Duration,
|
||||
TestScores = x.TestScores ?? 0,
|
||||
TestType = x.TestType,
|
||||
TemporaryUser = x.TemporaryUser,
|
||||
@@ -572,62 +570,17 @@ namespace BLL
|
||||
var getRItem = db.Training_TestRecordItem.Where(x => x.TestRecordId == getTestRecord.TestRecordId);
|
||||
if (getRItem.Count() > 0)
|
||||
{
|
||||
getTestRecord.TestScores = getRItem.Sum(x => x.SubjectScore);
|
||||
getTestRecord.TestScores = getRItem.Sum(x => x.SubjectScore ?? 0);
|
||||
}
|
||||
db.SubmitChanges();
|
||||
|
||||
getCode = getTestRecord.TestScores ?? 0;
|
||||
|
||||
}
|
||||
}
|
||||
return getCode;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="testPlanId"></param>
|
||||
public static void updateAll(string testPlanId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
//// 获取考试计划
|
||||
var getTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == testPlanId);
|
||||
if (getTestPlan != null)
|
||||
{
|
||||
//// 获取参加考试 记录
|
||||
var getAllTestRecords = db.Training_TestRecord.Where(x => x.TestPlanId == getTestPlan.TestPlanId);
|
||||
if (getAllTestRecords.Count() > 0)
|
||||
{
|
||||
/// 参加考试人数
|
||||
int testManCout = getAllTestRecords.Select(x => x.TestManId).Distinct().Count();
|
||||
//// 获取培训计划人员
|
||||
var getAllTrainingTasks = db.Training_Task.Where(x => x.PlanId == getTestPlan.PlanId);
|
||||
//// 考试人数大于等于 培训人数
|
||||
if (testManCout >= getAllTrainingTasks.Count())
|
||||
{
|
||||
////所有人员 都交卷时 考试计划结束 状态置为3
|
||||
var getAllTestRecord = getAllTestRecords.FirstOrDefault(x => !x.TestEndTime.HasValue);
|
||||
if (getAllTestRecord == null)
|
||||
{
|
||||
var getTrainingTasks = getAllTrainingTasks.Where(x => x.States != "2" || x.States == null);
|
||||
foreach (var item in getTrainingTasks)
|
||||
{
|
||||
item.States = "2";
|
||||
db.SubmitChanges();
|
||||
}
|
||||
getTestPlan.States = "3";
|
||||
db.SubmitChanges();
|
||||
////TODO 讲培训计划 考试记录 写入到培训记录
|
||||
APITrainRecordService.InsertTrainRecord(getTestPlan);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 根据TestRecord生成一条补考记录
|
||||
/// <summary>
|
||||
/// 根据TestRecord生成一条补考记录
|
||||
|
||||
Reference in New Issue
Block a user