684 lines
47 KiB
C#
684 lines
47 KiB
C#
using Competition.Common.Util;
|
|
using CompetitionAPI.api.unity;
|
|
using CompetitionAPI.Util;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace CompetitionAPI.Controllers.unity
|
|
{
|
|
[Route("unity/[controller]")]
|
|
[ApiController]
|
|
public class AddUserChoiceQuestionController : Controller
|
|
{
|
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
|
|
|
Competition.Mysql.BLL.pow_user_fault_record user_fault_record_bll = new Competition.Mysql.BLL.pow_user_fault_record();
|
|
|
|
Competition.Mysql.BLL.pow_user_fault user_fault_bll = new Competition.Mysql.BLL.pow_user_fault();
|
|
|
|
Competition.Mysql.BLL.pow_exam_fault exam_fault_bll = new Competition.Mysql.BLL.pow_exam_fault();
|
|
|
|
Competition.Mysql.BLL.pow_user_exam user_exam_bll = new Competition.Mysql.BLL.pow_user_exam();
|
|
|
|
Competition.Mysql.BLL.pow_achievement achievement_bll = new Competition.Mysql.BLL.pow_achievement();
|
|
|
|
Competition.Mysql.BLL.pow_achievement_details achievement_details_bll = new Competition.Mysql.BLL.pow_achievement_details();
|
|
|
|
Competition.Mysql.BLL.pow_config config_bll = new Competition.Mysql.BLL.pow_config();
|
|
|
|
public AddUserChoiceQuestionController(IWebHostEnvironment webHostEnvironment)
|
|
{
|
|
_webHostEnvironment = webHostEnvironment;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传考试选择题数据接口
|
|
/// </summary>
|
|
/// <param name="req"></param>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpPost]
|
|
[APIFilter]
|
|
public JsonResult Index([FromBody] AddUserChoiceQuestionRequest req)
|
|
{
|
|
try
|
|
{
|
|
if (req != null)
|
|
{
|
|
var test = JsonConvert.SerializeObject(req);
|
|
var config_model = config_bll.GetModelList("").FirstOrDefault();
|
|
if (config_model == null)
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "配置信息不存在"));
|
|
}
|
|
var user_exam_model = user_exam_bll.GetModelList(" ExamId='" + req.ExamId + "' and UserId='" + req.UserId + "' ").FirstOrDefault();
|
|
if (user_exam_model != null)
|
|
{
|
|
if (user_exam_model.Status == "已结束")
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "考生考试已结束"));
|
|
}
|
|
var achievement_model = achievement_bll.GetModelList(" ExamId='" + req.ExamId + "' and UserId='" + req.UserId + "' ").FirstOrDefault();
|
|
if (achievement_model == null)
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "考生成绩数据不存在"));
|
|
}
|
|
|
|
var exam_fault_list = exam_fault_bll.GetModelList(" ExamId='" + req.ExamId + "' and ChoiceQuestion!='0' ");
|
|
var select_total_score = exam_fault_list.Sum(a => decimal.Parse(a.SelectSocre));
|
|
var fault_total_score = exam_fault_list.Sum(a => decimal.Parse(a.FaultScore));
|
|
var handler_score = exam_fault_list.Sum(a => decimal.Parse(a.HandlerScore));
|
|
var total = select_total_score + fault_total_score + handler_score;//总分
|
|
var record_list = new List<Competition.Mysql.Model.pow_user_fault_record>();
|
|
var details_list = new List<Competition.Mysql.Model.pow_achievement_details>();
|
|
var user_fault_record_list = user_fault_record_bll.GetModelList(" ExamId='" + req.ExamId + "' and UserId='" + req.UserId + "' ");
|
|
decimal total_score = 0;//总分
|
|
var TotalDefectScore = decimal.Parse(config_model.TotalDefectScore);
|
|
//组织树
|
|
var tree_list = ReadTree();
|
|
foreach (var item in req.Data)
|
|
{
|
|
var fault_model = new Competition.Mysql.Model.pow_user_fault_record();
|
|
var root_device_name = "";
|
|
var device_name = "";
|
|
var exam_fault_model = exam_fault_list.Where(a => a.RootDeviceId == item.RootDeviceId && a.DeviceId == item.DeviceId && a.FaultId == item.FaultId).FirstOrDefault();
|
|
if (exam_fault_model != null)
|
|
{
|
|
if (exam_fault_model.FaultDesc == "导线未绑扎、扎线断股" || exam_fault_model.FaultDesc == "瓷瓶歪斜松动" || exam_fault_model.FaultDesc == "瓷瓶损坏")
|
|
{
|
|
item.Value = "";
|
|
}
|
|
else if (exam_fault_model.FaultDesc == "电缆接头发热")
|
|
{
|
|
item.Value = item.Value + "发热";
|
|
}
|
|
if (item.Value.Contains("东侧") || item.Value.Contains("北侧") || item.Value.Contains("西侧"))
|
|
{
|
|
item.Value = item.Value + "拉线";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(item.Value))
|
|
{
|
|
fault_model = user_fault_record_list.Where(a => a.FaultId == item.FaultId && a.RootDeviceId == item.RootDeviceId && a.DeviceId == item.DeviceId && a.Value == item.Value).FirstOrDefault();
|
|
}
|
|
else
|
|
{
|
|
fault_model = user_fault_record_list.Where(a => a.FaultId == item.FaultId && a.RootDeviceId == item.RootDeviceId && a.DeviceId == item.DeviceId).FirstOrDefault();
|
|
}
|
|
if (fault_model != null)
|
|
{
|
|
var first_list = tree_list.Where(a => a.TowerId == item.RootDeviceId).FirstOrDefault();
|
|
if (first_list != null)
|
|
{
|
|
root_device_name = first_list.Tower;
|
|
if (first_list.TowerId != item.DeviceId)
|
|
{
|
|
if (first_list.Data != null)
|
|
{
|
|
var two_list = first_list.Data.Where(a => a.PowerDistributionBoxId == item.DeviceId).FirstOrDefault();
|
|
if (two_list != null)
|
|
{
|
|
device_name = two_list.PowerDistributionBox;
|
|
}
|
|
else
|
|
{
|
|
var three_list = first_list.Data.SelectMany(a => a.Data).Where(a => a.LineId == item.DeviceId).FirstOrDefault();
|
|
if (three_list != null)
|
|
{
|
|
device_name = three_list.Line;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(fault_model.UserFaultRecordId))
|
|
{
|
|
var is_processing_score = "0";
|
|
|
|
if (fault_model.ChoiceQuestion != "0")
|
|
{
|
|
var right_key_content = new List<string>();
|
|
var right_key_list = fault_model.RightKey.Split('|');
|
|
foreach (var right_key in right_key_list)
|
|
{
|
|
if (right_key == "A")
|
|
{
|
|
right_key_content.Add(fault_model.OptionA);
|
|
}
|
|
if (right_key == "B")
|
|
{
|
|
right_key_content.Add(fault_model.OptionB);
|
|
}
|
|
if (right_key == "C")
|
|
{
|
|
right_key_content.Add(fault_model.OptionC);
|
|
}
|
|
if (right_key == "D")
|
|
{
|
|
right_key_content.Add(fault_model.OptionD);
|
|
}
|
|
if (right_key == "E")
|
|
{
|
|
right_key_content.Add(fault_model.OptionE);
|
|
}
|
|
}
|
|
if (fault_model.FaultDesc == "配电箱箱门未加锁" || fault_model.FaultDesc == "柜门与箱体没有链接线" || fault_model.FaultDesc == "配电箱孔洞未封堵")
|
|
{
|
|
var value_list = new List<string>();
|
|
if (fault_model.FaultDesc != "配电箱孔洞未封堵")
|
|
{
|
|
value_list = fault_model.Position.Split('|').ToList();
|
|
}
|
|
else
|
|
{
|
|
value_list = fault_model.MultipleQuestion.Split('|').ToList();
|
|
}
|
|
foreach (var position_item in value_list)
|
|
{
|
|
var success_index = 0;
|
|
var fault_index = 0;
|
|
var answer_list = item.Answer.Split('|');
|
|
foreach (var answer_item in answer_list)
|
|
{
|
|
if (right_key_content.Contains(answer_item))
|
|
{
|
|
success_index++;
|
|
}
|
|
else
|
|
{
|
|
fault_index++;
|
|
}
|
|
}
|
|
if (success_index == right_key_list.Length && fault_index == 0)
|
|
{
|
|
is_processing_score = "1";
|
|
}
|
|
|
|
decimal processing_score = 0;
|
|
|
|
var processing_score_model = System.Decimal.Round((decimal.Parse(fault_model.HandlerScore) / total) * TotalDefectScore, 3);
|
|
decimal otherQuestionScore = 0;
|
|
var firstQuestionScore = Tool.TransFormation(processing_score_model, value_list.Count, out otherQuestionScore);
|
|
|
|
var user_Index = value_list.IndexOf(position_item);
|
|
if (user_Index == 0)
|
|
{
|
|
processing_score = firstQuestionScore;
|
|
}
|
|
else
|
|
{
|
|
processing_score = otherQuestionScore;
|
|
}
|
|
|
|
if (is_processing_score == "1")
|
|
{
|
|
var item_name = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + position_item + "-" + "缺陷处理分值";
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model == null)
|
|
{
|
|
var new_details_model = details_list.Where(a => a.ItemName == item_name).FirstOrDefault();
|
|
if (new_details_model == null)
|
|
{
|
|
var details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
details_model.AchievementId = achievement_model.AchievementId;
|
|
details_model.ItemName = item_name;
|
|
details_model.ItemizedScore = processing_score;
|
|
details_model.Type = "故障选择题处理";
|
|
details_model.CreateTime = DateTime.Now;
|
|
details_model.TotalScore = processing_score;
|
|
details_model.FaultDesc = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + position_item;
|
|
details_model.ScoreType = "缺陷处理分值";
|
|
details_list.Add(details_model);
|
|
total_score = total_score + processing_score;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var item_name = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + position_item + "-" + "缺陷处理分值";
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model == null)
|
|
{
|
|
var new_details_model = details_list.Where(a => a.ItemName == item_name).FirstOrDefault();
|
|
if (new_details_model == null)
|
|
{
|
|
var details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
details_model.AchievementId = achievement_model.AchievementId;
|
|
details_model.ItemName = item_name;
|
|
details_model.ItemizedScore = 0;
|
|
details_model.Type = "故障选择题处理";
|
|
details_model.CreateTime = DateTime.Now;
|
|
details_model.TotalScore = processing_score;
|
|
details_model.FaultDesc = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + position_item;
|
|
details_model.ScoreType = "缺陷处理分值";
|
|
details_list.Add(details_model);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var value_list = new List<string>();
|
|
if (fault_model.FaultDesc == "配电箱孔洞未封堵"
|
|
|| fault_model.FaultDesc == "熔断器下桩头发热"
|
|
|| fault_model.FaultDesc == "熔芯不匹配"
|
|
|| fault_model.FaultDesc == "熔芯损坏"
|
|
|| fault_model.FaultDesc == "电缆头套管相色缺失"
|
|
|| fault_model.FaultDesc == "电缆接头发热"
|
|
|| fault_model.FaultDesc == "电缆绝缘层老化开裂"
|
|
|| fault_model.FaultDesc == "拉线无警示套管"
|
|
|| fault_model.FaultDesc == "拉线松动"
|
|
|| fault_model.FaultDesc == "拉线断股锈蚀"
|
|
|| fault_model.FaultDesc == "拉线UT线夹螺帽不齐全"
|
|
|| fault_model.FaultDesc == "接头发热"
|
|
|| fault_model.FaultDesc == "线路弧垂不一致")
|
|
{
|
|
if (!string.IsNullOrEmpty(fault_model.MultipleQuestion))
|
|
{
|
|
if (fault_model.FaultDesc != "相色标识错误")
|
|
{
|
|
value_list = fault_model.MultipleQuestion.Split('|').ToList();
|
|
}
|
|
}
|
|
}
|
|
|
|
decimal processing_score = 0;
|
|
if (value_list.Count == 0)
|
|
{
|
|
processing_score = System.Decimal.Round((decimal.Parse(fault_model.HandlerScore) / total) * TotalDefectScore, 3);
|
|
}
|
|
else
|
|
{
|
|
var processing_score_model = System.Decimal.Round((decimal.Parse(fault_model.HandlerScore) / total) * TotalDefectScore, 3);
|
|
decimal otherQuestionScore = 0;
|
|
var firstQuestionScore = Tool.TransFormation(processing_score_model, value_list.Count, out otherQuestionScore);
|
|
|
|
var user_Index = value_list.IndexOf(item.Value);
|
|
if (user_Index == 0)
|
|
{
|
|
processing_score = firstQuestionScore;
|
|
}
|
|
else
|
|
{
|
|
processing_score = otherQuestionScore;
|
|
}
|
|
}
|
|
|
|
var success_index = 0;
|
|
var fault_index = 0;
|
|
var answer_list = item.Answer.Split('|');
|
|
foreach (var answer_item in answer_list)
|
|
{
|
|
if (right_key_content.Contains(answer_item))
|
|
{
|
|
success_index++;
|
|
}
|
|
else
|
|
{
|
|
fault_index++;
|
|
}
|
|
}
|
|
if (success_index == right_key_list.Length && fault_index == 0)
|
|
{
|
|
is_processing_score = "1";
|
|
}
|
|
|
|
if (is_processing_score == "1")
|
|
{
|
|
var item_name = "";
|
|
var desc = "";
|
|
if (!string.IsNullOrEmpty(item.Value))
|
|
{
|
|
item_name = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + item.Value + "-" + "缺陷处理分值";
|
|
desc = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + item.Value;
|
|
}
|
|
else
|
|
{
|
|
item_name = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + "缺陷处理分值";
|
|
desc = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc;
|
|
}
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model == null)
|
|
{
|
|
var new_details_model = details_list.Where(a => a.ItemName == item_name).FirstOrDefault();
|
|
if (new_details_model == null)
|
|
{
|
|
var details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
details_model.AchievementId = achievement_model.AchievementId;
|
|
details_model.ItemName = item_name;
|
|
details_model.FaultDesc = desc;
|
|
details_model.ItemizedScore = processing_score;
|
|
details_model.Type = "故障选择题处理";
|
|
details_model.CreateTime = DateTime.Now;
|
|
details_model.TotalScore = processing_score;
|
|
details_model.ScoreType = "缺陷处理分值";
|
|
details_list.Add(details_model);
|
|
total_score = total_score + processing_score;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var item_name = "";
|
|
var desc = "";
|
|
if (!string.IsNullOrEmpty(item.Value))
|
|
{
|
|
item_name = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + item.Value + "-" + "缺陷处理分值";
|
|
desc = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + item.Value;
|
|
}
|
|
else
|
|
{
|
|
item_name = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc + "-" + "缺陷处理分值";
|
|
desc = root_device_name + "-" + device_name + "-" + fault_model.FaultDesc;
|
|
}
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model == null)
|
|
{
|
|
var new_details_model = details_list.Where(a => a.ItemName == item_name).FirstOrDefault();
|
|
if (new_details_model == null)
|
|
{
|
|
var details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
details_model.AchievementId = achievement_model.AchievementId;
|
|
details_model.ItemName = item_name;
|
|
details_model.FaultDesc = desc;
|
|
details_model.ItemizedScore = 0;
|
|
details_model.Type = "故障选择题处理";
|
|
details_model.CreateTime = DateTime.Now;
|
|
details_model.TotalScore = processing_score;
|
|
details_model.ScoreType = "缺陷处理分值";
|
|
details_list.Add(details_model);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fault_model.Answer = item.Answer;
|
|
fault_model.IsProcessingScore = is_processing_score;
|
|
record_list.Add(fault_model);
|
|
}
|
|
}
|
|
}
|
|
|
|
var fault_list = req.Data.Select(a => a.FaultId).ToList();
|
|
//本地数据库正确数据里有,用户选择数据里没有,少选
|
|
var correct_data = exam_fault_list.Where(s => s.ChoiceQuestion != "0" && s.SpecificSimulation == "选择题" && !fault_list.Contains(s.FaultId)).ToList();
|
|
foreach (var item in correct_data)
|
|
{
|
|
var root_device_name = "";
|
|
var device_name = "";
|
|
|
|
var first_list = tree_list.Where(a => a.TowerId == item.RootDeviceId).FirstOrDefault();
|
|
if (first_list != null)
|
|
{
|
|
root_device_name = first_list.Tower;
|
|
if (first_list.TowerId != item.DeviceId)
|
|
{
|
|
if (first_list.Data != null)
|
|
{
|
|
var two_list = first_list.Data.Where(a => a.PowerDistributionBoxId == item.DeviceId).FirstOrDefault();
|
|
if (two_list != null)
|
|
{
|
|
device_name = two_list.PowerDistributionBox;
|
|
}
|
|
else
|
|
{
|
|
var three_list = first_list.Data.SelectMany(a => a.Data).Where(a => a.LineId == item.DeviceId).FirstOrDefault();
|
|
if (three_list != null)
|
|
{
|
|
device_name = three_list.Line;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
decimal processing_score = 0;
|
|
var value_list = new List<string>();
|
|
if (item.FaultDesc == "配电箱箱门未加锁" || item.FaultDesc == "柜门与箱体没有链接线")
|
|
{
|
|
value_list = item.Position.Split('|').ToList();
|
|
}
|
|
else
|
|
{
|
|
if (item.FaultDesc == "配电箱孔洞未封堵"
|
|
|| item.FaultDesc == "熔断器下桩头发热"
|
|
|| item.FaultDesc == "熔芯不匹配"
|
|
|| item.FaultDesc == "熔芯损坏"
|
|
|| item.FaultDesc == "电缆头套管相色缺失"
|
|
|| item.FaultDesc == "电缆接头发热"
|
|
|| item.FaultDesc == "电缆绝缘层老化开裂"
|
|
|| item.FaultDesc == "拉线无警示套管"
|
|
|| item.FaultDesc == "拉线松动"
|
|
|| item.FaultDesc == "拉线断股锈蚀"
|
|
|| item.FaultDesc == "拉线UT线夹螺帽不齐全"
|
|
|| item.FaultDesc == "接头发热"
|
|
|| item.FaultDesc == "线路弧垂不一致")
|
|
{
|
|
if (!string.IsNullOrEmpty(item.MultipleQuestion))
|
|
{
|
|
if (item.FaultDesc != "相色标识错误")
|
|
{
|
|
value_list = item.MultipleQuestion.Split('|').ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (value_list.Count == 0)
|
|
{
|
|
processing_score = System.Decimal.Round((decimal.Parse(item.HandlerScore) / total) * TotalDefectScore, 3);
|
|
var item_name = root_device_name + "-" + device_name + "-" + item.FaultDesc + "-" + "缺陷处理分值";
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model == null)
|
|
{
|
|
var new_details_model = details_list.Where(a => a.ItemName == item_name).FirstOrDefault();
|
|
if (new_details_model == null)
|
|
{
|
|
var details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
details_model.AchievementId = achievement_model.AchievementId;
|
|
details_model.ItemName = item_name;
|
|
details_model.ItemizedScore = 0;
|
|
details_model.Type = "故障选择题处理";
|
|
details_model.CreateTime = DateTime.Now;
|
|
details_model.TotalScore = processing_score;
|
|
details_model.FaultDesc = root_device_name + "-" + device_name + "-" + item.FaultDesc;
|
|
details_model.ScoreType = "缺陷处理分值";
|
|
details_list.Add(details_model);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var position_item in value_list)
|
|
{
|
|
var processing_score_model = System.Decimal.Round((decimal.Parse(item.HandlerScore) / total) * TotalDefectScore, 3);
|
|
decimal otherQuestionScore = 0;
|
|
var firstQuestionScore = Tool.TransFormation(processing_score_model, value_list.Count, out otherQuestionScore);
|
|
|
|
var user_Index = value_list.IndexOf(position_item);
|
|
if (user_Index == 0)
|
|
{
|
|
processing_score = firstQuestionScore;
|
|
}
|
|
else
|
|
{
|
|
processing_score = otherQuestionScore;
|
|
}
|
|
var item_name = root_device_name + "-" + device_name + "-" + item.FaultDesc + "-" + position_item + "-" + "缺陷处理分值";
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model == null)
|
|
{
|
|
var new_details_model = details_list.Where(a => a.ItemName == item_name).FirstOrDefault();
|
|
if (new_details_model == null)
|
|
{
|
|
var details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
details_model.AchievementId = achievement_model.AchievementId;
|
|
details_model.ItemName = item_name;
|
|
details_model.ItemizedScore = 0;
|
|
details_model.Type = "故障选择题处理";
|
|
details_model.CreateTime = DateTime.Now;
|
|
details_model.TotalScore = processing_score;
|
|
details_model.FaultDesc = root_device_name + "-" + device_name + "-" + item.FaultDesc + "-" + position_item;
|
|
details_model.ScoreType = "缺陷处理分值";
|
|
details_list.Add(details_model);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//单条数据多选故障少选情况
|
|
var moment_data = exam_fault_list.Where(s => s.ChoiceQuestion != "0" && s.SpecificSimulation == "选择题" && (s.FaultDesc == "配电箱箱门未加锁" || s.FaultDesc == "柜门与箱体没有链接线" || s.FaultDesc == "配电箱孔洞未封堵" || s.FaultDesc == "熔断器下桩头发热" || s.FaultDesc == "熔芯不匹配" || s.FaultDesc == "熔芯损坏" || s.FaultDesc == "电缆头套管相色缺失" || s.FaultDesc == "电缆接头发热" || s.FaultDesc == "电缆绝缘层老化开裂" || s.FaultDesc == "拉线无警示套管" || s.FaultDesc == "拉线松动" || s.FaultDesc == "拉线断股锈蚀" || s.FaultDesc == "拉线UT线夹螺帽不齐全" || s.FaultDesc == "接头发热" || s.FaultDesc == "线路弧垂不一致")).ToList();
|
|
foreach (var item in moment_data)
|
|
{
|
|
var select_list = req.Data.Where(a => a.FaultId == item.FaultId).ToList();
|
|
if (select_list.Count > 0)
|
|
{
|
|
var root_device_name = "";
|
|
var device_name = "";
|
|
|
|
var first_list = tree_list.Where(a => a.TowerId == item.RootDeviceId).FirstOrDefault();
|
|
if (first_list != null)
|
|
{
|
|
root_device_name = first_list.Tower;
|
|
if (first_list.TowerId != item.DeviceId)
|
|
{
|
|
if (first_list.Data != null)
|
|
{
|
|
var two_list = first_list.Data.Where(a => a.PowerDistributionBoxId == item.DeviceId).FirstOrDefault();
|
|
if (two_list != null)
|
|
{
|
|
device_name = two_list.PowerDistributionBox;
|
|
}
|
|
else
|
|
{
|
|
var three_list = first_list.Data.SelectMany(a => a.Data).Where(a => a.LineId == item.DeviceId).FirstOrDefault();
|
|
if (three_list != null)
|
|
{
|
|
device_name = three_list.Line;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
decimal processing_score = 0;
|
|
var value_list = new List<string>();
|
|
if (item.FaultDesc == "配电箱箱门未加锁" || item.FaultDesc == "柜门与箱体没有链接线")
|
|
{
|
|
value_list = item.Position.Split('|').ToList();
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(item.MultipleQuestion))
|
|
{
|
|
if (item.FaultDesc != "相色标识错误")
|
|
{
|
|
value_list = item.MultipleQuestion.Split('|').ToList();
|
|
}
|
|
}
|
|
}
|
|
|
|
if (value_list.Count > 0)
|
|
{
|
|
foreach (var position_item in value_list)
|
|
{
|
|
var count = details_list.Where(a => a.FaultDesc == root_device_name + "-" + device_name + "-" + item.FaultDesc + "-" + position_item).Count();
|
|
if (count == 0)
|
|
{
|
|
var processing_score_model = System.Decimal.Round((decimal.Parse(item.HandlerScore) / total) * TotalDefectScore, 3);
|
|
decimal otherQuestionScore = 0;
|
|
var firstQuestionScore = Tool.TransFormation(processing_score_model, value_list.Count, out otherQuestionScore);
|
|
|
|
var user_Index = value_list.IndexOf(position_item);
|
|
if (user_Index == 0)
|
|
{
|
|
processing_score = firstQuestionScore;
|
|
}
|
|
else
|
|
{
|
|
processing_score = otherQuestionScore;
|
|
}
|
|
var item_name = root_device_name + "-" + device_name + "-" + item.FaultDesc + "-" + position_item + "-" + "缺陷处理分值";
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model == null)
|
|
{
|
|
var new_details_model = details_list.Where(a => a.ItemName == item_name).FirstOrDefault();
|
|
if (new_details_model == null)
|
|
{
|
|
var details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
details_model.AchievementId = achievement_model.AchievementId;
|
|
details_model.ItemName = item_name;
|
|
details_model.ItemizedScore = 0;
|
|
details_model.Type = "故障选择题处理";
|
|
details_model.CreateTime = DateTime.Now;
|
|
details_model.TotalScore = processing_score;
|
|
details_model.FaultDesc = root_device_name + "-" + device_name + "-" + item.FaultDesc + "-" + position_item;
|
|
details_model.ScoreType = "缺陷处理分值";
|
|
details_list.Add(details_model);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (user_fault_record_bll.OperationUpdateAddData(record_list, details_list, achievement_model.AchievementId, total_score) > 0)
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, "成功"));
|
|
}
|
|
else
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "失败"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "考生考试信息不存在"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "请求参数无数据"));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取树结构json
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private List<Competition.Mysql.Other.fault_tree> ReadTree()
|
|
{
|
|
var tree_list = new List<Competition.Mysql.Other.fault_tree>();
|
|
string fault_tree_file = _webHostEnvironment.WebRootPath + "/Json/FaultTree.json";
|
|
//读取json文件
|
|
using (StreamReader file = System.IO.File.OpenText(fault_tree_file))
|
|
{
|
|
using (JsonTextReader reader = new JsonTextReader(file))
|
|
{
|
|
tree_list = JsonConvert.DeserializeObject<List<Competition.Mysql.Other.fault_tree>>(JToken.ReadFrom(reader).ToString());
|
|
}
|
|
}
|
|
return tree_list;
|
|
}
|
|
}
|
|
}
|