考试调整

This commit is contained in:
李超 2024-03-31 11:01:00 +08:00
parent 53473b9f66
commit 49283a7433
5 changed files with 84 additions and 50 deletions

View File

@ -52,38 +52,38 @@ namespace BLL
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
db.SubmitChanges();
}
public static void AddTestRecordForApi(Model.Training_TestRecord testRecord)
}
public static void AddTestRecordForApi(Model.Training_TestRecord testRecord)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
{
TestRecordId = testRecord.TestRecordId,
ProjectId = testRecord.ProjectId,
TestPlanId = testRecord.TestPlanId,
TestManId = testRecord.TestManId,
TestType = testRecord.TestType,
};
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
{
TestRecordId = testRecord.TestRecordId,
ProjectId = testRecord.ProjectId,
TestPlanId = testRecord.TestPlanId,
TestManId = testRecord.TestManId,
TestType = testRecord.TestType,
};
if (string.IsNullOrEmpty(newTestRecord.TestType))
{
var getTrainTypeName = (from x in db.Training_TestPlan
join y in db.Training_Plan on x.PlanId equals y.PlanId
join z in db.Base_TrainType on y.TrainTypeId equals z.TrainTypeId
where x.TestPlanId == testRecord.TestPlanId
select z).FirstOrDefault();
if (string.IsNullOrEmpty(newTestRecord.TestType))
{
var getTrainTypeName = (from x in db.Training_TestPlan
join y in db.Training_Plan on x.PlanId equals y.PlanId
join z in db.Base_TrainType on y.TrainTypeId equals z.TrainTypeId
where x.TestPlanId == testRecord.TestPlanId
select z).FirstOrDefault();
if (getTrainTypeName != null)
{
testRecord.TestType = getTrainTypeName.TrainTypeName;
}
}
if (getTrainTypeName != null)
{
testRecord.TestType = getTrainTypeName.TrainTypeName;
}
}
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
db.SubmitChanges();
}
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
db.SubmitChanges();
}
}
/// <summary>
/// 修改考试记录信息
/// </summary>

View File

@ -79,24 +79,41 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
var getTasks = new Model.SGGLDB(Funs.ConnString).Training_Task.FirstOrDefault(x => x.PlanId == trainingPlanId);
if (getTasks != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
if (CommonService.IsMainUnitOrAdmin(userId))
var getTasks =db.Training_Task.FirstOrDefault(x => x.PlanId == trainingPlanId);
if (getTasks != null)
{
responeData.data = APITestPlanService.SaveTestPlanByTrainingPlanId(trainingPlanId, userId);
bool result = false;
if (userId == Const.sysglyId || userId == Const.hfnbdId)
{
result = true;
}
else
{
var user = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
if (user != null && user.UnitId == Const.UnitId_CD)
{
result = true;
}
}
if ( result)
//if (CommonService.IsMainUnitOrAdmin(userId))
{
responeData.data = APITestPlanService.SaveTestPlanByTrainingPlanId(trainingPlanId, userId);
}
else
{
responeData.code = 0;
responeData.message = "非本单位用户,不能生成考试计划!";
}
}
else
{
responeData.code = 0;
responeData.message = "非本单位用户,不能生成考试计划!";
responeData.message = "培训计划下没有培训人员,不能生成考试计划!";
}
}
else
{
responeData.code = 0;
responeData.message = "培训计划下没有培训人员,不能生成考试计划!";
}
}
catch (Exception ex)
{
@ -201,11 +218,11 @@ namespace WebAPI.Controllers
Model.SitePerson_Person person;
if (user != null)
{
person = Funs.DB.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
person = db.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
}
else
{
person = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
}
if (person != null || user != null)
@ -246,7 +263,7 @@ namespace WebAPI.Controllers
TestPlanId = getTestPlan.TestPlanId,
TestManId = personId,
};
TestRecordService.AddTestRecord(newTestRecord);
TestRecordService.AddTestRecordForApi(newTestRecord);
responeData.code = 3;
responeData.message = "您已加入考试计划!";
}
@ -265,7 +282,7 @@ namespace WebAPI.Controllers
TestPlanId = getTestPlan.TestPlanId,
TestManId = personId,
};
TestRecordService.AddTestRecord(newTestRecord);
TestRecordService.AddTestRecordForApi(newTestRecord);
responeData.code = 3;
responeData.message = "您已加入考试计划!";
}

View File

@ -164,7 +164,7 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
personId = PersonService.GetPersonIdByUserId(personId);
personId = PersonService.GetPersonIdByUserIdForApi(personId);
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectIdPersonId(projectId, personId);
int pageCount = getDataLists.Count;
if (pageCount > 0 && pageIndex > 0)

View File

@ -101,14 +101,31 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
if (CommonService.IsMainUnitOrAdmin(trainingPlan.DesignerId))
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
APITrainingPlanService.SaveTrainingPlan(trainingPlan);
}
else
{
responeData.code = 0;
responeData.message = "非本单位用户,不能制定培训计划!";
bool result = false;
if (trainingPlan.DesignerId == Const.sysglyId || trainingPlan.DesignerId == Const.hfnbdId)
{
result = true;
}
else
{
var user = db.Sys_User.FirstOrDefault(e => e.UserId == trainingPlan.DesignerId);
if (user != null && user.UnitId == Const.UnitId_CD)
{
result = true;
}
}
if (result)
// if (CommonService.IsMainUnitOrAdmin(trainingPlan.DesignerId))
{
APITrainingPlanService.SaveTrainingPlan(trainingPlan);
}
else
{
responeData.code = 0;
responeData.message = "非本单位用户,不能制定培训计划!";
}
}
}
catch (Exception ex)

View File

@ -86,7 +86,7 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
string newPersonId = PersonService.GetPersonIdByUserId(personId);
string newPersonId = PersonService.GetPersonIdByUserIdForApi(personId);
responeData.message = APITrainingTaskService.getTrainingTaskByPlanIdPersonIdCondition(planId, newPersonId);
if (string.IsNullOrEmpty(responeData.message))
{