737 lines
47 KiB
C#
737 lines
47 KiB
C#
using Competition.Common.Util;
|
|
using CompetitionAPI.api.unity;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
using System.Collections;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using CompetitionAPI.Util;
|
|
|
|
namespace CompetitionAPI.Controllers.unity
|
|
{
|
|
[Route("unity/[controller]")]
|
|
[ApiController]
|
|
public class AddFaultOperationController : Controller
|
|
{
|
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
|
|
|
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 AddFaultOperationController(IWebHostEnvironment webHostEnvironment)
|
|
{
|
|
_webHostEnvironment = webHostEnvironment;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传故障排故数据接口
|
|
/// </summary>
|
|
/// <param name="req"></param>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpPost]
|
|
[APIFilter]
|
|
public JsonResult Index([FromBody] AddFaultOperationRequest req)
|
|
{
|
|
try
|
|
{
|
|
if (req != null)
|
|
{
|
|
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(string.Format(" ExamId='{0}' and UserId='{1}' ", req.ExamId, 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 add_details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
var update_details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
var delete_details_model = new Competition.Mysql.Model.pow_achievement_details();
|
|
var user_fault_model = new Competition.Mysql.Model.pow_user_fault();
|
|
var correct_model = new Competition.Mysql.Model.pow_exam_fault();
|
|
var TotalDefectScore = decimal.Parse(config_model.TotalDefectScore);
|
|
var is_processing_score = "0";
|
|
//组织树
|
|
var tree_list = ReadTree();
|
|
var root_device_name = "";
|
|
var device_name = "";
|
|
if (req.Details != null)
|
|
{
|
|
user_fault_model = user_fault_bll.GetModelList(" ExamId='" + req.ExamId + "' and UserId='" + req.UserId + "' and FaultId='" + req.FaultId + "' and RootDeviceId='" + req.RootDeviceId + "' and DeviceId='" + req.Details.DeviceId + "' ").FirstOrDefault();
|
|
correct_model = exam_fault_list.Where(a => a.FaultId == req.FaultId && a.RootDeviceId == req.RootDeviceId && a.DeviceId == req.Details.DeviceId).FirstOrDefault();
|
|
if (user_fault_model != null)
|
|
{
|
|
var first_list = tree_list.Where(a => a.TowerId == user_fault_model.RootDeviceId).FirstOrDefault();
|
|
if (first_list != null)
|
|
{
|
|
root_device_name = first_list.Tower;
|
|
if (first_list.TowerId != user_fault_model.DeviceId)
|
|
{
|
|
if (first_list.Data != null)
|
|
{
|
|
var two_list = first_list.Data.Where(a => a.PowerDistributionBoxId == user_fault_model.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 == user_fault_model.DeviceId).FirstOrDefault();
|
|
if (three_list != null)
|
|
{
|
|
device_name = three_list.Line;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
decimal processing_score = 0;
|
|
var value_list = new List<string>();
|
|
if (user_fault_model.FaultDesc == "配电箱箱门未加锁" || user_fault_model.FaultDesc == "柜门与箱体没有链接线")
|
|
{
|
|
value_list = user_fault_model.Position.Split('|').ToList();
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.FaultDesc == "配电箱孔洞未封堵"
|
|
|| user_fault_model.FaultDesc == "熔断器下桩头发热"
|
|
|| user_fault_model.FaultDesc == "熔芯不匹配"
|
|
|| user_fault_model.FaultDesc == "熔芯损坏"
|
|
|| user_fault_model.FaultDesc == "电缆头套管相色缺失"
|
|
|| user_fault_model.FaultDesc == "电缆接头发热"
|
|
|| user_fault_model.FaultDesc == "电缆绝缘层老化开裂"
|
|
|| user_fault_model.FaultDesc == "拉线无警示套管"
|
|
|| user_fault_model.FaultDesc == "拉线松动"
|
|
|| user_fault_model.FaultDesc == "拉线断股锈蚀"
|
|
|| user_fault_model.FaultDesc == "拉线UT线夹螺帽不齐全"
|
|
|| user_fault_model.FaultDesc == "接头发热"
|
|
|| user_fault_model.FaultDesc == "线路弧垂不一致")
|
|
{
|
|
if (!string.IsNullOrEmpty(user_fault_model.MultipleQuestion))
|
|
{
|
|
if (user_fault_model.FaultDesc != "相色标识错误")
|
|
{
|
|
value_list = user_fault_model.MultipleQuestion.Split('|').ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (value_list.Count == 0)
|
|
{
|
|
processing_score = System.Decimal.Round((decimal.Parse(correct_model.HandlerScore) / total) * TotalDefectScore, 3);
|
|
}
|
|
else
|
|
{
|
|
var processing_score_model = System.Decimal.Round((decimal.Parse(correct_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(req.Details.FaultLocation.Replace("配电箱名牌-", "").Replace("电缆名称牌-411#", ""));
|
|
if (user_Index == 0)
|
|
{
|
|
processing_score = firstQuestionScore;
|
|
}
|
|
else
|
|
{
|
|
processing_score = otherQuestionScore;
|
|
}
|
|
}
|
|
|
|
|
|
if (user_fault_model.FaultDesc == "配电箱名称牌缺失" || user_fault_model.FaultDesc == "出线电缆编号牌型号编写错误" || user_fault_model.FaultDesc == "无出线电缆名称牌" || user_fault_model.FaultDesc == "出线开关编号牌缺失" || user_fault_model.FaultDesc == "熔芯不匹配" || user_fault_model.FaultDesc == "熔芯损坏")
|
|
{
|
|
if (user_fault_model.FaultDesc == "熔芯不匹配")
|
|
{
|
|
if (!string.IsNullOrEmpty(req.Details.FaultLocation))
|
|
{
|
|
var correct = correct_model.MultipleQuestion.Split('|').ToList();
|
|
if (correct.Contains(req.Details.FaultLocation))
|
|
{
|
|
var multiple_value_list = new List<string>();
|
|
if (!string.IsNullOrEmpty(user_fault_model.MultipleQuestion))
|
|
{
|
|
multiple_value_list = user_fault_model.MultipleQuestion.Split('|').ToList();
|
|
}
|
|
if (multiple_value_list.Contains(req.Details.FaultLocation))
|
|
{
|
|
if (correct_model.FusibleCoreNormal == req.Details.CurreSelectDetail)
|
|
{
|
|
is_processing_score = "1";
|
|
multiple_value_list.Remove(req.Details.FaultLocation);
|
|
}
|
|
else
|
|
{
|
|
user_fault_model.FusibleCoreFault = req.Details.CurreSelectDetail;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
multiple_value_list.Add(req.Details.FaultLocation);
|
|
user_fault_model.MultipleQuestion = string.Join("|", multiple_value_list);
|
|
}
|
|
if (is_processing_score == "1")
|
|
{
|
|
user_fault_model.MultipleQuestion = string.Join("|", multiple_value_list);
|
|
if (multiple_value_list.Count == 0)
|
|
{
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.ChoiceQuestion == "0")
|
|
{
|
|
user_fault_model.ChoiceQuestion = "2";
|
|
user_fault_model.MultipleQuestion = string.Join("|", multiple_value_list);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (user_fault_model.FaultDesc == "熔芯损坏")
|
|
{
|
|
if (!string.IsNullOrEmpty(req.Details.FaultLocation))
|
|
{
|
|
var correct = correct_model.MultipleQuestion.Split('|').ToList();
|
|
if (correct.Contains(req.Details.FaultLocation))
|
|
{
|
|
var multiple_value_list = new List<string>();
|
|
if (!string.IsNullOrEmpty(user_fault_model.MultipleQuestion))
|
|
{
|
|
multiple_value_list = user_fault_model.MultipleQuestion.Split('|').ToList();
|
|
}
|
|
if (multiple_value_list.Contains(req.Details.FaultLocation))
|
|
{
|
|
if (req.Details.CurreSelectDetail == "true")
|
|
{
|
|
is_processing_score = "1";
|
|
multiple_value_list.Remove(req.Details.FaultLocation);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
multiple_value_list.Add(req.Details.FaultLocation);
|
|
user_fault_model.MultipleQuestion = string.Join("|", multiple_value_list);
|
|
}
|
|
if (is_processing_score == "1")
|
|
{
|
|
user_fault_model.MultipleQuestion = string.Join("|", multiple_value_list);
|
|
if (multiple_value_list.Count == 0)
|
|
{
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.ChoiceQuestion == "0")
|
|
{
|
|
user_fault_model.ChoiceQuestion = "2";
|
|
user_fault_model.MultipleQuestion = string.Join("|", multiple_value_list);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (user_fault_model.FaultDesc == "出线开关编号牌缺失")
|
|
{
|
|
if (req.Details.CurreSelectDetail == "411开关")
|
|
{
|
|
is_processing_score = "1";
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.ChoiceQuestion == "0")
|
|
{
|
|
user_fault_model.ChoiceQuestion = "1";
|
|
}
|
|
}
|
|
}
|
|
else if (user_fault_model.FaultDesc == "配电箱名称牌缺失")
|
|
{
|
|
if (req.Details.CurreSelectDetail.Replace("配电箱名牌-", "") == user_exam_model.PlatformAreaName)
|
|
{
|
|
is_processing_score = "1";
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.ChoiceQuestion == "0")
|
|
{
|
|
user_fault_model.ChoiceQuestion = "1";
|
|
}
|
|
}
|
|
}
|
|
else if (user_fault_model.FaultDesc == "无出线电缆名称牌")
|
|
{
|
|
if (req.Details.CurreSelectDetail.Replace("电缆名称牌-411#", "") == user_exam_model.PlatformAreaName)
|
|
{
|
|
is_processing_score = "1";
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.ChoiceQuestion == "0")
|
|
{
|
|
user_fault_model.ChoiceQuestion = "1";
|
|
}
|
|
}
|
|
}
|
|
else if (user_fault_model.FaultDesc == "出线电缆编号牌型号编写错误")
|
|
{
|
|
if (req.Details.CurreSelectDetail.Replace("电缆名称牌-411#", "") == user_exam_model.PlatformAreaName)
|
|
{
|
|
is_processing_score = "1";
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.ChoiceQuestion == "0")
|
|
{
|
|
user_fault_model.ChoiceQuestion = "1";
|
|
}
|
|
}
|
|
}
|
|
user_fault_model.CurreSelectDetail = req.Details.CurreSelectDetail;
|
|
|
|
if (is_processing_score == "1")
|
|
{
|
|
var item_name = user_fault_model.FaultDesc + "-" + "缺陷处理分值";
|
|
if (!string.IsNullOrEmpty(req.Details.FaultLocation))
|
|
{
|
|
item_name = user_fault_model.FaultDesc + "-" + req.Details.FaultLocation.Replace("配电箱名牌-", "").Replace("电缆名称牌-411#", "") + "-" + "缺陷处理分值";
|
|
}
|
|
item_name = root_device_name + "-" + device_name + "-" + item_name;
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model != null)
|
|
{
|
|
delete_details_model = achievement_details_model;
|
|
//update_details_model.DetailsId = achievement_details_model.DetailsId;
|
|
//update_details_model.AchievementId = achievement_model.AchievementId;
|
|
//update_details_model.ItemName = item_name;
|
|
//update_details_model.ItemizedScore = processing_score;
|
|
//update_details_model.Type = "故障排故处理";
|
|
//update_details_model.CreateTime = DateTime.Now;
|
|
//update_details_model.TotalScore = processing_score;
|
|
}
|
|
else
|
|
{
|
|
add_details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
add_details_model.AchievementId = achievement_model.AchievementId;
|
|
add_details_model.ItemName = item_name;
|
|
add_details_model.ItemizedScore = processing_score;
|
|
add_details_model.Type = "故障排故处理";
|
|
add_details_model.CreateTime = DateTime.Now;
|
|
add_details_model.TotalScore = processing_score;
|
|
add_details_model.FaultDesc = item_name.Replace("-缺陷处理分值", "");
|
|
add_details_model.ScoreType = "缺陷处理分值";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.ChoiceQuestion != "0")
|
|
{
|
|
var item_name = user_fault_model.FaultDesc + "-" + "缺陷处理分值";
|
|
if (!string.IsNullOrEmpty(req.Details.FaultLocation))
|
|
{
|
|
item_name = user_fault_model.FaultDesc + "-" + req.Details.FaultLocation.Replace("配电箱名牌-", "").Replace("电缆名称牌-411#", "") + "-" + "缺陷处理分值";
|
|
}
|
|
item_name = root_device_name + "-" + device_name + "-" + item_name;
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
//if (achievement_details_model != null)
|
|
//{
|
|
// delete_details_model = achievement_details_model;
|
|
//}
|
|
if (achievement_details_model != null)
|
|
{
|
|
delete_details_model = achievement_details_model;
|
|
}
|
|
else
|
|
{
|
|
add_details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
add_details_model.AchievementId = achievement_model.AchievementId;
|
|
add_details_model.ItemName = item_name;
|
|
add_details_model.ItemizedScore = 0;
|
|
add_details_model.Type = "故障排故处理";
|
|
add_details_model.CreateTime = DateTime.Now;
|
|
add_details_model.TotalScore = processing_score;
|
|
add_details_model.FaultDesc = item_name.Replace("-缺陷处理分值", "");
|
|
add_details_model.ScoreType = "缺陷处理分值";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(req.Details.FaultLocation))
|
|
{
|
|
if (!string.IsNullOrEmpty(correct_model.MultipleQuestion))
|
|
{
|
|
var multiple_value_list = correct_model.MultipleQuestion.Split('|').ToList();
|
|
if (multiple_value_list.Contains(req.Details.FaultLocation))
|
|
{
|
|
is_processing_score = "1";
|
|
multiple_value_list.Remove(req.Details.FaultLocation);
|
|
}
|
|
if (is_processing_score == "1")
|
|
{
|
|
user_fault_model.MultipleQuestion = string.Join("|", multiple_value_list);
|
|
if (multiple_value_list.Count == 0)
|
|
{
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(correct_model.Position))
|
|
{
|
|
var multiple_value_list = correct_model.Position.Split('|').ToList();
|
|
if (multiple_value_list.Contains(req.Details.FaultLocation))
|
|
{
|
|
is_processing_score = "1";
|
|
multiple_value_list.Remove(req.Details.FaultLocation);
|
|
}
|
|
if (is_processing_score == "1")
|
|
{
|
|
user_fault_model.Position = string.Join("|", multiple_value_list);
|
|
if (multiple_value_list.Count == 0)
|
|
{
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
is_processing_score = "1";
|
|
}
|
|
|
|
if (is_processing_score == "1")
|
|
{
|
|
var item_name = user_fault_model.FaultDesc + "-" + "缺陷处理分值";
|
|
if (!string.IsNullOrEmpty(req.Details.FaultLocation))
|
|
{
|
|
item_name = user_fault_model.FaultDesc + "-" + req.Details.FaultLocation + "-" + "缺陷处理分值";
|
|
}
|
|
item_name = root_device_name + "-" + device_name + "-" + item_name;
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model != null)
|
|
{
|
|
update_details_model.DetailsId = achievement_details_model.DetailsId;
|
|
update_details_model.AchievementId = achievement_model.AchievementId;
|
|
update_details_model.ItemName = item_name;
|
|
update_details_model.ItemizedScore = processing_score;
|
|
update_details_model.Type = "故障排故处理";
|
|
update_details_model.CreateTime = DateTime.Now;
|
|
update_details_model.TotalScore = processing_score;
|
|
update_details_model.FaultDesc = item_name.Replace("-缺陷处理分值", "");
|
|
update_details_model.ScoreType = "缺陷处理分值";
|
|
}
|
|
else
|
|
{
|
|
add_details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
add_details_model.AchievementId = achievement_model.AchievementId;
|
|
add_details_model.ItemName = item_name;
|
|
add_details_model.ItemizedScore = processing_score;
|
|
add_details_model.Type = "故障排故处理";
|
|
add_details_model.CreateTime = DateTime.Now;
|
|
add_details_model.TotalScore = processing_score;
|
|
add_details_model.FaultDesc = item_name.Replace("-缺陷处理分值", "");
|
|
add_details_model.ScoreType = "缺陷处理分值";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (req.Screen != null)
|
|
{
|
|
#region 断路器
|
|
user_fault_model = user_fault_bll.GetModelList(" ExamId='" + req.ExamId + "' and UserId='" + req.UserId + "' and FaultId='" + req.FaultId + "' and RootDeviceId='" + req.RootDeviceId + "' and DeviceId='" + req.Screen.DeviceId + "' ").FirstOrDefault();
|
|
if (user_fault_model != null)
|
|
{
|
|
var first_list = tree_list.Where(a => a.TowerId == user_fault_model.RootDeviceId).FirstOrDefault();
|
|
if (first_list != null)
|
|
{
|
|
root_device_name = first_list.Tower;
|
|
if (first_list.TowerId != user_fault_model.DeviceId)
|
|
{
|
|
if (first_list.Data != null)
|
|
{
|
|
var two_list = first_list.Data.Where(a => a.PowerDistributionBoxId == user_fault_model.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 == user_fault_model.DeviceId).FirstOrDefault();
|
|
if (three_list != null)
|
|
{
|
|
device_name = three_list.Line;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
correct_model = exam_fault_list.Where(a => a.FaultId == req.FaultId && a.RootDeviceId == req.RootDeviceId && a.DeviceId == req.Screen.DeviceId).FirstOrDefault();
|
|
if (null == correct_model)
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, "故障:" + req.FaultDesc + ":无需操作!"));
|
|
}
|
|
var name_list = user_fault_model.Name.Split('|');
|
|
ArrayList name_arry = new ArrayList(name_list);
|
|
var value_list = user_fault_model.Value.Split('|');
|
|
var success_index = 0;
|
|
var value = new List<string>();
|
|
|
|
if (user_fault_model.FaultDesc == "漏电保护设置不合理" || user_fault_model.FaultDesc == "欠压保护设置错误" || user_fault_model.FaultDesc == "过压保护设置错误")
|
|
{
|
|
if (user_fault_model.FaultDesc == "欠压保护设置错误")
|
|
value = user_exam_model.UndervoltageProtection.Split('|').ToList();
|
|
else if (user_fault_model.FaultDesc == "过压保护设置错误")
|
|
value = user_exam_model.OvervoltageProtection.Split('|').ToList();
|
|
else
|
|
value = user_exam_model.LeakageProtection.Split('|').ToList();
|
|
if (value.Count > 1 && !string.IsNullOrEmpty(value[0]))
|
|
{
|
|
foreach (var item in req.Screen.Params)
|
|
{
|
|
if (item.Name == "档位")
|
|
{
|
|
if (item.Value == value[0])
|
|
{
|
|
success_index++;
|
|
}
|
|
}
|
|
else if (item.Name == "开关")
|
|
{
|
|
if (item.Value == value[1])
|
|
{
|
|
success_index++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (user_fault_model.FaultDesc == "过载保护设置错误")
|
|
{
|
|
value = user_exam_model.OverloadProtection.Split('|').ToList();
|
|
if (value.Count > 1 && !string.IsNullOrEmpty(value[0]))
|
|
{
|
|
foreach (var item in req.Screen.Params)
|
|
{
|
|
if (item.Name == "ln1")
|
|
{
|
|
if (item.Value == value[0])
|
|
{
|
|
success_index++;
|
|
}
|
|
}
|
|
else if (item.Name == "保护")
|
|
{
|
|
if (item.Value == value[1])
|
|
{
|
|
success_index++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (user_fault_model.FaultDesc == "短路延时保护设置错误" || user_fault_model.FaultDesc == "短路瞬时保护设置错误")
|
|
{
|
|
if (user_fault_model.FaultDesc == "短路瞬时保护设置错误")
|
|
value = user_exam_model.ShortCircuitProtection.Split('|').ToList();
|
|
else
|
|
value = user_exam_model.ShortCircuitDelayProtection.Split('|').ToList();
|
|
if (value.Count > 1 && !string.IsNullOrEmpty(value[0]))
|
|
{
|
|
foreach (var item in req.Screen.Params)
|
|
{
|
|
if (item.Name == "ln2")
|
|
{
|
|
if (item.Value == value[0])
|
|
{
|
|
success_index++;
|
|
}
|
|
}
|
|
else if (item.Name == "保护")
|
|
{
|
|
if (item.Value == value[1])
|
|
{
|
|
success_index++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (user_fault_model.FaultDesc == "缺相保护设置错误")
|
|
{
|
|
value = user_exam_model.PhaseLossProtection.Split('|').ToList();
|
|
if (!string.IsNullOrEmpty(value[0]))
|
|
{
|
|
foreach (var item in req.Screen.Params)
|
|
{
|
|
if (item.Name == "开关")
|
|
{
|
|
if (item.Value == value[0])
|
|
{
|
|
success_index++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var item in req.Screen.Params)
|
|
{
|
|
var subscript = name_arry.IndexOf(item.Name);
|
|
if (subscript > -1)
|
|
{
|
|
value_list[subscript] = item.Value;
|
|
}
|
|
}
|
|
user_fault_model.Value = string.Join("|", value_list);
|
|
|
|
if (success_index == value.Count)
|
|
{
|
|
user_fault_model.ChoiceQuestion = "0";
|
|
decimal processing_score = 0;
|
|
|
|
processing_score = System.Decimal.Round((decimal.Parse(correct_model.HandlerScore) / total) * TotalDefectScore, 3);
|
|
|
|
var item_name = user_fault_model.FaultDesc + "-" + "缺陷处理分值";
|
|
item_name = root_device_name + "-" + device_name + "-" + item_name;
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model != null)
|
|
{
|
|
delete_details_model = achievement_details_model;
|
|
//update_details_model.DetailsId = achievement_details_model.DetailsId;
|
|
//update_details_model.AchievementId = achievement_model.AchievementId;
|
|
//update_details_model.ItemName = item_name;
|
|
//update_details_model.ItemizedScore = processing_score;
|
|
//update_details_model.Type = "故障排故处理";
|
|
//update_details_model.TotalScore= processing_score;
|
|
//update_details_model.CreateTime = DateTime.Now;
|
|
}
|
|
else
|
|
{
|
|
add_details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
add_details_model.AchievementId = achievement_model.AchievementId;
|
|
add_details_model.ItemName = item_name;
|
|
add_details_model.ItemizedScore = processing_score;
|
|
add_details_model.Type = "故障排故处理";
|
|
add_details_model.TotalScore = processing_score;
|
|
add_details_model.CreateTime = DateTime.Now;
|
|
add_details_model.FaultDesc = item_name.Replace("-缺陷处理分值", "");
|
|
add_details_model.ScoreType = "缺陷处理分值";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (user_fault_model.ChoiceQuestion == "0")
|
|
{
|
|
decimal processing_score = 0;
|
|
|
|
processing_score = System.Decimal.Round((decimal.Parse(correct_model.HandlerScore) / total) * TotalDefectScore, 3);
|
|
user_fault_model.ChoiceQuestion = "1";
|
|
var item_name = user_fault_model.FaultDesc + "-" + "缺陷处理分值";
|
|
item_name = root_device_name + "-" + device_name + "-" + item_name;
|
|
var achievement_details_model = achievement_details_bll.GetModelList(" AchievementId='" + achievement_model.AchievementId + "' and ItemName='" + item_name + "' ").FirstOrDefault();
|
|
if (achievement_details_model != null)
|
|
{
|
|
delete_details_model = achievement_details_model;
|
|
}
|
|
else
|
|
{
|
|
add_details_model.DetailsId = Guid.NewGuid().ToString("N");
|
|
add_details_model.AchievementId = achievement_model.AchievementId;
|
|
add_details_model.ItemName = item_name;
|
|
add_details_model.ItemizedScore = 0;
|
|
add_details_model.Type = "故障排故处理";
|
|
add_details_model.TotalScore = processing_score;
|
|
add_details_model.CreateTime = DateTime.Now;
|
|
add_details_model.FaultDesc = item_name.Replace("-缺陷处理分值", "");
|
|
add_details_model.ScoreType = "缺陷处理分值";
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
user_fault_model.IsProcessingScore = is_processing_score;
|
|
|
|
if (user_fault_bll.OperationUpdateAddData(user_fault_model, add_details_model, update_details_model, delete_details_model) > 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;
|
|
}
|
|
}
|
|
}
|