405 lines
25 KiB
C#
405 lines
25 KiB
C#
using Competition.Common.Util;
|
|
using CompetitionAPI.api.back;
|
|
using CompetitionAPI.Util;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Win32;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CompetitionAPI.Controllers.unity.newinterface
|
|
{
|
|
[Route("unity/[controller]")]
|
|
[ApiController]
|
|
public class GetGradeDetailsController : Controller
|
|
{
|
|
Competition.Mysql.BLL.pow_achievement achievement_bll = new Competition.Mysql.BLL.pow_achievement();
|
|
|
|
Competition.Mysql.BLL.pow_achievement_details details_bll = new Competition.Mysql.BLL.pow_achievement_details();
|
|
|
|
Competition.Mysql.BLL.pow_config config_bll = new Competition.Mysql.BLL.pow_config();
|
|
|
|
Competition.Mysql.BLL.pow_user_exam user_exam_bll = new Competition.Mysql.BLL.pow_user_exam();
|
|
|
|
Competition.Mysql.BLL.pow_user_tool user_tool_bll = new Competition.Mysql.BLL.pow_user_tool();
|
|
|
|
Competition.Mysql.BLL.pow_user_operation_ticket user_operation_ticket_bll = new Competition.Mysql.BLL.pow_user_operation_ticket();
|
|
|
|
Competition.Mysql.BLL.pow_user_operation_proc_ticket user_operation_proc_ticket_bll = new Competition.Mysql.BLL.pow_user_operation_proc_ticket();
|
|
|
|
public GetGradeDetailsController()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取成绩详情接口
|
|
/// </summary>
|
|
/// <param name="UserId">用户id</param>
|
|
/// <param name="ExamId">考试id</param>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpGet]
|
|
[APIFilter]
|
|
public JsonResult Index(string UserId, string ExamId)
|
|
{
|
|
try
|
|
{
|
|
var config_model = config_bll.GetModelList("").FirstOrDefault();
|
|
if (config_model == null)
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "配置信息不存在"));
|
|
}
|
|
|
|
var res = new GetAchievementDetailsResponse();
|
|
var achievement_model = achievement_bll.GetModelList(string.Format(" ExamId='{0}' and UserId='{1}' ", ExamId, UserId)).FirstOrDefault();
|
|
if (achievement_model != null)
|
|
{
|
|
var user_exam_model = user_exam_bll.GetModelList(string.Format(" ExamId='{0}' and UserId='{1}' ", ExamId, UserId)).FirstOrDefault();
|
|
if (user_exam_model != null)
|
|
{
|
|
if (user_exam_model.Status == "已结束")
|
|
{
|
|
res.ExamName = user_exam_model.ExamName;
|
|
res.Time = int.Parse((user_exam_model.EndExamTime.Value - user_exam_model.StartExamTime.Value).TotalSeconds.ToString());
|
|
var item_data = new List<ItemData>();
|
|
var answer_info_model1 = new ItemData() { ItemName = "巡线工器具选择", Total = 3, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
var answer_info_model2 = new ItemData() { ItemName = "排故工器具选择", Total = 3, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
|
|
var answer_info_model3 = new ItemData() { ItemName = "停电操作票选择", Total = 5, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
var answer_info_model4 = new ItemData() { ItemName = "送电操作票选择", Total = 5, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
var answer_info_model5 = new ItemData() { ItemName = "停电操作票步骤", Total = 5, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
var answer_info_model6 = new ItemData() { ItemName = "送电操作票步骤", Total = 5, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
var answer_info_model7 = new ItemData() { ItemName = "围栏和验电", Total = 4, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
var answer_info_model9 = new ItemData() { ItemName = "时间分", Total = 5, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
|
|
|
|
var answer_info_model10 = new ItemData() { ItemName = "故障查询及设置故障", Total = 0, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
var answer_info_model11 = new ItemData() { ItemName = "故障处理", Total = 0, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
var answer_info_model12 = new ItemData() { ItemName = "其它扣分", Total = 0, Score = 0, TwoTotal = 0, TwoScore = 0, Data = new List<ContentData>() { } };
|
|
|
|
var data = details_bll.GetModelList(string.Format(" AchievementId='{0}' order by CreateTime asc ", achievement_model.AchievementId));
|
|
|
|
#region 巡检工器具
|
|
var all_line_tool_list = new List<ContentData>();
|
|
var line_tool_model = data.Where(a => a.Type == "巡线工器具").FirstOrDefault();
|
|
if (line_tool_model != null)
|
|
{
|
|
answer_info_model1.Total = decimal.Parse(line_tool_model.TotalScore.ToString());
|
|
answer_info_model1.Score = decimal.Parse(line_tool_model.ItemizedScore.ToString());
|
|
}
|
|
|
|
var user_tool_list = user_tool_bll.GetModelList(string.Format(" ExamId='{0}' and UserId='{1}' and IsScore=1 ", ExamId, UserId));
|
|
var line_tool_list = user_tool_list.Where(a => a.Purpose == "巡线").ToList();
|
|
for (int i = 0; i < line_tool_list.Count; i++)
|
|
{
|
|
decimal score = 0;
|
|
if (line_tool_list[i].IsSelect == "1")
|
|
{
|
|
score = decimal.Parse(config_model.LineMultipleScore);
|
|
}
|
|
else
|
|
{
|
|
score = decimal.Parse(config_model.LineMomentScore);
|
|
}
|
|
var tool_model = new ContentData() { Content = line_tool_list[i].ToolName, ItemScore = decimal.Parse((-score).ToString()) };
|
|
all_line_tool_list.Add(tool_model);
|
|
}
|
|
|
|
if (all_line_tool_list.Count() > 0)
|
|
{
|
|
answer_info_model1.Data = all_line_tool_list;
|
|
}
|
|
#endregion
|
|
|
|
#region 排故工器具
|
|
var all_trouble_tool_list = new List<ContentData>();
|
|
var trouble_tool_model = data.Where(a => a.Type == "排故工器具").FirstOrDefault();
|
|
if (trouble_tool_model != null)
|
|
{
|
|
answer_info_model2.Total = decimal.Parse(trouble_tool_model.TotalScore.ToString());
|
|
answer_info_model2.Score = decimal.Parse(trouble_tool_model.ItemizedScore.ToString());
|
|
}
|
|
|
|
var trouble_tool_list = user_tool_list.Where(a => a.Purpose == "排故").ToList();
|
|
for (int i = 0; i < trouble_tool_list.Count; i++)
|
|
{
|
|
decimal score = 0;
|
|
if (trouble_tool_list[i].IsSelect == "1")
|
|
{
|
|
score = decimal.Parse(config_model.LineMultipleScore);
|
|
}
|
|
else
|
|
{
|
|
score = decimal.Parse(config_model.LineMomentScore);
|
|
}
|
|
var tool_model = new ContentData() { Content = trouble_tool_list[i].ToolName, ItemScore = decimal.Parse((-score).ToString()) };
|
|
all_trouble_tool_list.Add(tool_model);
|
|
}
|
|
if (all_trouble_tool_list.Count() > 0)
|
|
{
|
|
answer_info_model2.Data = all_trouble_tool_list;
|
|
}
|
|
#endregion
|
|
|
|
#region 停电操作票
|
|
var all_stop_ticket_list = new List<ContentData>();
|
|
var power_failure_model = data.Where(a => a.Type == "停电操作票").FirstOrDefault();
|
|
if (power_failure_model != null)
|
|
{
|
|
answer_info_model3.Total = decimal.Parse(power_failure_model.TotalScore.ToString());
|
|
answer_info_model3.Score = decimal.Parse(power_failure_model.ItemizedScore.ToString());
|
|
}
|
|
|
|
var user_ticket_list = user_operation_ticket_bll.GetModelList(string.Format(" ExamId='{0}' and UserId='{1}' and IsScore='1' ", ExamId, UserId));
|
|
var stop_ticket_list = user_ticket_list.Where(a => a.Type == "停电").ToList();
|
|
for (int i = 0; i < stop_ticket_list.Count; i++)
|
|
{
|
|
decimal score = 1;
|
|
var ticket_model = new ContentData() { Content = stop_ticket_list[i].Content, ItemScore = decimal.Parse((-score).ToString()) };
|
|
all_stop_ticket_list.Add(ticket_model);
|
|
}
|
|
|
|
if (all_stop_ticket_list.Count() > 0)
|
|
{
|
|
answer_info_model3.Data = all_stop_ticket_list;
|
|
}
|
|
#endregion
|
|
|
|
#region 送电操作票
|
|
var all_give_ticket_list = new List<ContentData>();
|
|
var power_transmission_model = data.Where(a => a.Type == "送电操作票").FirstOrDefault();
|
|
if (power_transmission_model != null)
|
|
{
|
|
answer_info_model4.Total = decimal.Parse(power_transmission_model.TotalScore.ToString());
|
|
answer_info_model4.Score = decimal.Parse(power_transmission_model.ItemizedScore.ToString());
|
|
}
|
|
|
|
var give_ticket_list = user_ticket_list.Where(a => a.Type == "送电").ToList();
|
|
for (int i = 0; i < give_ticket_list.Count; i++)
|
|
{
|
|
decimal score = 1;
|
|
var ticket_model = new ContentData() { Content = give_ticket_list[i].Content, ItemScore = decimal.Parse((-score).ToString()) };
|
|
all_give_ticket_list.Add(ticket_model);
|
|
}
|
|
|
|
if (all_give_ticket_list.Count() > 0)
|
|
{
|
|
answer_info_model4.Data = all_give_ticket_list;
|
|
}
|
|
#endregion
|
|
|
|
#region 停电操作票步骤
|
|
var all_power_failure_step_list = new List<ContentData>();
|
|
var power_failure_step_model = data.Where(a => a.Type == "停电操作票步骤").FirstOrDefault();
|
|
if (power_failure_step_model != null)
|
|
{
|
|
answer_info_model5.Total = decimal.Parse(power_failure_step_model.TotalScore.ToString());
|
|
answer_info_model5.Score = decimal.Parse(power_failure_step_model.ItemizedScore.ToString());
|
|
}
|
|
|
|
var proc_ticket_list = user_operation_proc_ticket_bll.GetModelList(string.Format(" ExamId='{0}' and UserId='{1}' and IsScore='1' ", ExamId, UserId));
|
|
var power_failure_step_list = proc_ticket_list.Where(a => a.Type == "停电").OrderBy(a => a.SerialNumber).ToList();
|
|
for (int i = 0; i < power_failure_step_list.Count; i++)
|
|
{
|
|
var power_model = new ContentData() { Content = power_failure_step_list[i].Content, ItemScore = decimal.Parse((-power_failure_step_list[i].Score).ToString()) };
|
|
all_power_failure_step_list.Add(power_model);
|
|
}
|
|
if (all_power_failure_step_list.Count() > 0)
|
|
{
|
|
answer_info_model5.Data = all_power_failure_step_list;
|
|
}
|
|
#endregion
|
|
|
|
#region 送电操作票步骤
|
|
var all_power_transmission_step_list = new List<ContentData>();
|
|
var power_transmission_step_model = data.Where(a => a.Type == "送电操作票步骤").FirstOrDefault();
|
|
if (power_transmission_step_model != null)
|
|
{
|
|
answer_info_model6.Total = decimal.Parse(power_transmission_step_model.TotalScore.ToString());
|
|
answer_info_model6.Score = decimal.Parse(power_transmission_step_model.ItemizedScore.ToString());
|
|
}
|
|
|
|
var power_transmission_step_list = proc_ticket_list.Where(a => a.Type == "送电").OrderBy(a => a.SerialNumber).ToList();
|
|
for (int i = 0; i < power_transmission_step_list.Count; i++)
|
|
{
|
|
var power_model = new ContentData() { Content = power_transmission_step_list[i].Content, ItemScore = decimal.Parse((-power_transmission_step_list[i].Score).ToString()) };
|
|
all_power_transmission_step_list.Add(power_model);
|
|
}
|
|
if (all_power_transmission_step_list.Count() > 0)
|
|
{
|
|
answer_info_model6.Data = all_power_transmission_step_list;
|
|
}
|
|
#endregion
|
|
|
|
#region 围栏
|
|
var place_elec_list = new List<ContentData>();
|
|
var place_model = data.Where(a => a.Type == "围栏").FirstOrDefault();
|
|
if (place_model != null)
|
|
{
|
|
place_elec_list.Add(new ContentData() { Content = place_model.ItemName, ItemTotal = decimal.Parse(place_model.TotalScore.ToString()), ItemScore = decimal.Parse(place_model.ItemizedScore.ToString()) });
|
|
}
|
|
else
|
|
{
|
|
place_elec_list.Add(new ContentData() { Content = "不放置围栏分值", ItemTotal = 2, ItemScore = 0 });
|
|
}
|
|
#endregion
|
|
|
|
#region 验电
|
|
var electricity_model = data.Where(a => a.Type == "验电").FirstOrDefault();
|
|
if (electricity_model != null)
|
|
{
|
|
place_elec_list.Add(new ContentData() { Content = electricity_model.ItemName, ItemTotal = decimal.Parse(electricity_model.TotalScore.ToString()), ItemScore = decimal.Parse(electricity_model.ItemizedScore.ToString()) });
|
|
}
|
|
else
|
|
{
|
|
place_elec_list.Add(new ContentData() { Content = "箱门或插座未验电或验电顺序错误", ItemTotal = 2, ItemScore = 0 });
|
|
}
|
|
|
|
if (place_elec_list.Count() > 0)
|
|
{
|
|
answer_info_model7.Score = place_elec_list.Sum(a => a.ItemScore);
|
|
answer_info_model7.Data = place_elec_list;
|
|
}
|
|
#endregion
|
|
|
|
#region 时间分
|
|
var time_model = data.Where(a => a.Type == "时间分").FirstOrDefault();
|
|
if (time_model != null)
|
|
{
|
|
answer_info_model9.Total = decimal.Parse(time_model.TotalScore.ToString());
|
|
answer_info_model9.Score = decimal.Parse(time_model.ItemizedScore.ToString());
|
|
answer_info_model9.Data = new List<ContentData>() { new ContentData() { Content = time_model.ItemName, ItemScore = decimal.Parse(time_model.ItemizedScore.ToString()), ItemTotal = decimal.Parse(time_model.TotalScore.ToString()) } };
|
|
}
|
|
else
|
|
{
|
|
answer_info_model9.Data = new List<ContentData>() { new ContentData() { Content = "时间分", ItemScore = 0, ItemTotal = 5 } };
|
|
}
|
|
#endregion
|
|
|
|
#region 缺陷查找、缺陷处理
|
|
var all_fault_list = new List<ContentData>();
|
|
var fault_list = data.Where(a => a.Type == "故障记录选择" || a.Type == "故障选择题处理" || a.Type == "故障排故处理").OrderBy(a => a.CreateTime).ToList();
|
|
var fault_type_list = fault_list.GroupBy(a => a.FaultDesc).ToList();
|
|
for (int i = 0; i < fault_type_list.Count; i++)
|
|
{
|
|
var fault = fault_list.Where(a => a.FaultDesc == fault_type_list[i].Key).ToList();
|
|
var power_model = new ContentData() { Content = fault_type_list[i].Key, ItemTotal = 0, ItemScore = 0, TwoItemTotal = 0, TwoItemScore = 0 };
|
|
|
|
var first = fault.Where(a => a.ScoreType == "缺陷查找分值").FirstOrDefault();
|
|
if (first != null)
|
|
{
|
|
power_model.ItemTotal = decimal.Parse(first.TotalScore.ToString());
|
|
power_model.ItemScore = decimal.Parse(first.ItemizedScore.ToString());
|
|
}
|
|
|
|
var second = fault.Where(a => a.ScoreType == "缺陷分类分值").FirstOrDefault();
|
|
if (second != null)
|
|
{
|
|
power_model.TwoItemTotal = decimal.Parse(second.TotalScore.ToString());
|
|
power_model.TwoItemScore = decimal.Parse(second.ItemizedScore.ToString());
|
|
}
|
|
|
|
all_fault_list.Add(power_model);
|
|
}
|
|
if (all_fault_list.Count() > 0)
|
|
{
|
|
answer_info_model10.Total = all_fault_list.Sum(a => a.ItemTotal);
|
|
answer_info_model10.Score = all_fault_list.Sum(a => a.ItemScore);
|
|
answer_info_model10.TwoTotal = all_fault_list.Sum(a => a.TwoItemTotal);
|
|
answer_info_model10.TwoScore = all_fault_list.Sum(a => a.TwoItemScore);
|
|
answer_info_model10.Data = all_fault_list;
|
|
}
|
|
#endregion
|
|
|
|
#region 缺陷分类分值
|
|
var all_fault_list2 = new List<ContentData>();
|
|
for (int i = 0; i < fault_type_list.Count; i++)
|
|
{
|
|
var fault = fault_list.Where(a => a.FaultDesc == fault_type_list[i].Key).ToList();
|
|
var power_model = new ContentData() { Content = fault_type_list[i].Key, ItemTotal = 0, ItemScore = 0 };
|
|
|
|
var third = fault.Where(a => a.ScoreType == "缺陷处理分值").FirstOrDefault();
|
|
if (third != null)
|
|
{
|
|
power_model.ItemTotal = decimal.Parse(third.TotalScore.ToString());
|
|
power_model.ItemScore = decimal.Parse(third.ItemizedScore.ToString());
|
|
}
|
|
|
|
all_fault_list2.Add(power_model);
|
|
}
|
|
if (all_fault_list2.Count() > 0)
|
|
{
|
|
answer_info_model11.Total = all_fault_list2.Sum(a => a.ItemTotal);
|
|
answer_info_model11.Score = all_fault_list2.Sum(a => a.ItemScore);
|
|
answer_info_model11.Data = all_fault_list2;
|
|
}
|
|
#endregion
|
|
|
|
#region 其它扣分项
|
|
var other_step_list = new List<ContentData>();
|
|
//巡检爬杆
|
|
var climbrod_model = data.Where(a => a.Type == "巡检爬杆").FirstOrDefault();
|
|
if (climbrod_model != null)
|
|
{
|
|
var power_model = new ContentData() { Content = climbrod_model.ItemName, ItemTotal = decimal.Parse(climbrod_model.TotalScore.ToString()), ItemScore = decimal.Parse(climbrod_model.ItemizedScore.ToString()) };
|
|
other_step_list.Add(power_model);
|
|
}
|
|
|
|
var platform_area_model = data.Where(a => a.Type == "台区选择").FirstOrDefault();
|
|
if (platform_area_model != null)
|
|
{
|
|
var power_model = new ContentData() { Content = platform_area_model.ItemName, ItemTotal = decimal.Parse(platform_area_model.TotalScore.ToString()), ItemScore = decimal.Parse(platform_area_model.ItemizedScore.ToString()) };
|
|
other_step_list.Add(power_model);
|
|
}
|
|
|
|
var fusible_core_model = data.Where(a => a.Type == "未分闸状态拉合熔芯").FirstOrDefault();
|
|
if (fusible_core_model != null)
|
|
{
|
|
var power_model = new ContentData() { Content = fusible_core_model.ItemName, ItemTotal = decimal.Parse(fusible_core_model.TotalScore.ToString()), ItemScore = decimal.Parse(fusible_core_model.ItemizedScore.ToString()) };
|
|
other_step_list.Add(power_model);
|
|
}
|
|
|
|
if (other_step_list.Count() > 0)
|
|
{
|
|
answer_info_model12.Score = other_step_list.Sum(a => a.ItemScore);
|
|
answer_info_model12.Data = other_step_list;
|
|
}
|
|
#endregion
|
|
|
|
item_data.Add(answer_info_model1);
|
|
item_data.Add(answer_info_model10);
|
|
item_data.Add(answer_info_model2);
|
|
item_data.Add(answer_info_model3);
|
|
item_data.Add(answer_info_model4);
|
|
item_data.Add(answer_info_model5);
|
|
item_data.Add(answer_info_model11);
|
|
item_data.Add(answer_info_model6);
|
|
item_data.Add(answer_info_model7);
|
|
item_data.Add(answer_info_model9);
|
|
item_data.Add(answer_info_model12);
|
|
res.Total = item_data.Sum(a => a.Total) + item_data.Sum(a => a.TwoTotal);
|
|
res.Sorce = item_data.Sum(a => a.Score) + item_data.Sum(a => a.TwoScore);
|
|
if (res.Sorce < 0)
|
|
{
|
|
res.Sorce = 0;
|
|
}
|
|
res.Data = item_data;
|
|
}
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(res.ExamName))
|
|
{
|
|
res = null;
|
|
}
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, res));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
|
}
|
|
}
|
|
}
|
|
}
|