2206 lines
144 KiB
C#
2206 lines
144 KiB
C#
using Competition.Common.Util;
|
||
using CompetitionAPI.api.back;
|
||
using Microsoft.AspNetCore.Http;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Newtonsoft.Json.Linq;
|
||
using Newtonsoft.Json;
|
||
using Org.BouncyCastle.Ocsp;
|
||
using CompetitionAPI.Util;
|
||
using Microsoft.AspNetCore.Authorization;
|
||
|
||
namespace CompetitionAPI.Controllers.back
|
||
{
|
||
[Route("api/[controller]")]
|
||
[ApiController]
|
||
public class ImportExamController : Controller
|
||
{
|
||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||
|
||
Competition.Mysql.BLL.pow_exam bll = new Competition.Mysql.BLL.pow_exam();
|
||
Competition.Mysql.BLL.pow_tool tool_bll = new Competition.Mysql.BLL.pow_tool();
|
||
Competition.Mysql.BLL.pow_fault fault_bll = new Competition.Mysql.BLL.pow_fault();
|
||
Competition.Mysql.BLL.pow_operation_ticket operation_ticket_bll = new Competition.Mysql.BLL.pow_operation_ticket();
|
||
Competition.Mysql.BLL.pow_platform_area area_bll = new Competition.Mysql.BLL.pow_platform_area();
|
||
Competition.Mysql.BLL.pow_line line_bll = new Competition.Mysql.BLL.pow_line();
|
||
|
||
private static Object Lockobj = new object();
|
||
|
||
public ImportExamController(IWebHostEnvironment webHostEnvironment)
|
||
{
|
||
_webHostEnvironment = webHostEnvironment;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导入考试接口
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[Authorize]
|
||
[HttpPost]
|
||
[APIFilter]
|
||
public JsonResult Index([FromForm] IFormFile Files)
|
||
{
|
||
try
|
||
{
|
||
lock (Lockobj)
|
||
{
|
||
if (Files.Length <= 0)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "文件不能为空"));
|
||
}
|
||
|
||
//组织树
|
||
var tree_list = ReadTree();
|
||
var root_device_id_list = new List<string>();
|
||
var device_id_list = new List<string>();
|
||
|
||
var init_fault_list = fault_bll.GetModelList("");
|
||
var init_tool_list = tool_bll.GetModelList("");
|
||
var init_ticket_list = operation_ticket_bll.GetModelList("");
|
||
|
||
var exam_model = new Competition.Mysql.Model.pow_exam();
|
||
#region 考试试卷
|
||
var platform_area_id = "";
|
||
var line_id = "";
|
||
var leakage_protection = "";
|
||
var overload_protection = "";
|
||
var short_circuit_delay_protection = "";
|
||
var short_circuit_protection = "";
|
||
var undervoltage_protection = "";
|
||
var overvoltage_protection = "";
|
||
var phase_loss_protection = "";
|
||
var fusible_core_current = "";
|
||
var fileExtension = Path.GetExtension(Files.FileName);
|
||
var exam_table = Tool.ExcelToDataTable(Files.OpenReadStream(), fileExtension, "考试试卷", 0, true, false);
|
||
if (null != exam_table && exam_table.Rows.Count == 1)
|
||
{
|
||
#region ===检查上传的字段====
|
||
var row = exam_table.Rows[0];
|
||
#region 考试名称
|
||
var exam_name = row["考试名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(exam_name))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "存在考试名称为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (bll.GetRecordCount(string.Format(" ExamName = '{0}' ", exam_name)) > 0)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试名称已存在,请更换考试名称再试"));
|
||
}
|
||
#endregion
|
||
|
||
#region 考试时长
|
||
var exam_duration = row["考试时长"].ToString();
|
||
if (string.IsNullOrWhiteSpace(exam_duration))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "存在考试时长为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
int duration;
|
||
if (!int.TryParse(exam_duration, out duration))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试时长数据格式不对,必须是数字"));
|
||
}
|
||
#endregion
|
||
|
||
#region 开票日期
|
||
//var billing_date = row["开票日期"].ToString();
|
||
//if (string.IsNullOrWhiteSpace(billing_date))
|
||
//{
|
||
// msg = "存在开票日期为空的记录,请检查上传文件";
|
||
// return false;
|
||
//}
|
||
#endregion
|
||
|
||
#region 村组
|
||
//var village_group = row["村组"].ToString();
|
||
//if (string.IsNullOrWhiteSpace(village_group))
|
||
//{
|
||
// msg = "存在村组为空的记录,请检查上传文件";
|
||
// return false;
|
||
//}
|
||
#endregion
|
||
|
||
#region 台区
|
||
var platform_area = row["台区"].ToString();
|
||
if (string.IsNullOrWhiteSpace(platform_area))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "存在台区为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
var area_model = area_bll.GetModelList(" PlatformAreaName='" + platform_area + "' ").FirstOrDefault();
|
||
if (area_model == null)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "台区内容不对,必须是台区一、台区二、台区三、台区四、台区五之中"));
|
||
}
|
||
else
|
||
{
|
||
platform_area_id = area_model.PlatformAreaId;
|
||
}
|
||
#endregion
|
||
|
||
#region 线路
|
||
var line = row["线路"].ToString();
|
||
if (string.IsNullOrWhiteSpace(line))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "存在线路为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
var line_model = line_bll.GetModelList(" LineName='" + line + "' ").FirstOrDefault();
|
||
if (line_model == null)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "线路内容不对,必须是0.4kV台区1#配变411东线格式"));
|
||
}
|
||
else
|
||
{
|
||
line_id = line_model.LineId;
|
||
}
|
||
#endregion
|
||
|
||
#region 工单内容
|
||
var work_order_content = row["工单内容"].ToString();
|
||
if (string.IsNullOrWhiteSpace(work_order_content))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "存在工单内容为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 背景资料
|
||
var background_information = row["背景资料"].ToString();
|
||
if (string.IsNullOrWhiteSpace(background_information))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "存在背景资料为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 进线电缆型号及长度
|
||
var incoming_line_model_length = row["进线电缆型号及长度"].ToString();
|
||
if (string.IsNullOrWhiteSpace(incoming_line_model_length))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "存在进线电缆型号及长度为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 出线电缆型号及长度
|
||
var outgoing_line_model_length = row["出线电缆型号及长度"].ToString();
|
||
if (string.IsNullOrWhiteSpace(outgoing_line_model_length))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "存在出线电缆型号及长度为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
var protection_list = new List<string>();
|
||
protection_list.Add("411开关(保护器)额定剩余电流保护:");
|
||
protection_list.Add("411开关(保护器)过载保护:");
|
||
protection_list.Add("411开关(保护器)短路延时保护:");
|
||
protection_list.Add("411开关(保护器)短路瞬时保护:");
|
||
protection_list.Add("411开关(保护器)欠压保护:");
|
||
protection_list.Add("411开关(保护器)过压保护:");
|
||
protection_list.Add("411开关(保护器)缺相保护:");
|
||
protection_list.Add("411熔芯熔断电流:");
|
||
|
||
foreach (var item in protection_list)
|
||
{
|
||
if (!background_information.Trim().Contains(item))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料格式不正确,未包含" + item));
|
||
}
|
||
|
||
var content_list = background_information.Trim().Split(new char[2] { '\r', '\n' }).ToList();
|
||
var leakage_protection_value = content_list.Where(a => a.Contains(item)).FirstOrDefault();
|
||
if (!string.IsNullOrEmpty(leakage_protection_value))
|
||
{
|
||
var value = leakage_protection_value.Split(':');
|
||
if (value.Length != 2)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确"));
|
||
}
|
||
else
|
||
{
|
||
if (item != "411开关(保护器)缺相保护:" && item != "411熔芯熔断电流:")
|
||
{
|
||
if (!value[1].Contains("(") || !value[1].Contains(")"))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,值未包含()格式"));
|
||
}
|
||
var value_list = new List<string>();
|
||
var pro = value[1].Split('(');
|
||
|
||
if (item == "411开关(保护器)额定剩余电流保护:")
|
||
{
|
||
if (pro[0] == "50mA" || pro[0] == "100mA" || pro[0] == "200mA" || pro[0] == "300mA" || pro[0] == "400mA" || pro[0] == "500mA" || pro[0] == "600mA" || pro[0] == "800mA")
|
||
{
|
||
if (pro[0] == "50mA")
|
||
{
|
||
value_list.Add("050mA");
|
||
}
|
||
else
|
||
{
|
||
value_list.Add(pro[0]);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,档位值不在指定范围内(50mA、100mA、200mA、300mA、400mA、500mA、600mA、800mA)"));
|
||
}
|
||
}
|
||
|
||
if (item == "411开关(保护器)过载保护:")
|
||
{
|
||
if (pro[0] == "160A" || pro[0] == "200A" || pro[0] == "240A" || pro[0] == "280A" || pro[0] == "320A" || pro[0] == "360A" || pro[0] == "400A")
|
||
{
|
||
if (pro[0] == "160A")
|
||
{
|
||
value_list.Add("0.4ln");
|
||
}
|
||
else if (pro[0] == "200A")
|
||
{
|
||
value_list.Add("0.5ln");
|
||
}
|
||
else if (pro[0] == "240A")
|
||
{
|
||
value_list.Add("0.6ln");
|
||
}
|
||
else if (pro[0] == "280A")
|
||
{
|
||
value_list.Add("0.7ln");
|
||
}
|
||
else if (pro[0] == "320A")
|
||
{
|
||
value_list.Add("0.8ln");
|
||
}
|
||
else if (pro[0] == "360A")
|
||
{
|
||
value_list.Add("0.9ln");
|
||
}
|
||
else if (pro[0] == "400A")
|
||
{
|
||
value_list.Add("1.0ln");
|
||
}
|
||
else
|
||
{
|
||
value_list.Add(pro[0]);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,档位值不在指定范围内(160A、200A、240A、280A、320A、360A、400A)"));
|
||
}
|
||
}
|
||
|
||
if (item == "411开关(保护器)短路延时保护:")
|
||
{
|
||
Dictionary<string, string> delay_protection = new Dictionary<string, string>();
|
||
delay_protection.Add("800A", "2ln");
|
||
delay_protection.Add("1000A", "2.5ln");
|
||
delay_protection.Add("1200A", "3ln");
|
||
delay_protection.Add("1600A", "4ln");
|
||
delay_protection.Add("2000A", "5ln");
|
||
delay_protection.Add("2400A", "6ln");
|
||
delay_protection.Add("2800A", "7ln");
|
||
delay_protection.Add("3400A", "8ln");
|
||
delay_protection.Add("4000A", "10ln");
|
||
if (delay_protection.ContainsKey(pro[0]))
|
||
{
|
||
value_list.Add(delay_protection[pro[0]]);
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,档位值不在指定范围内(" + string.Join("、", delay_protection.Keys.ToArray()) + ")"));
|
||
}
|
||
}
|
||
|
||
if (item == "411开关(保护器)短路瞬时保护:")
|
||
{
|
||
Dictionary<string, string> delay_protection = new Dictionary<string, string>();
|
||
delay_protection.Add("2400A", "6ln");
|
||
delay_protection.Add("2800A", "7ln");
|
||
delay_protection.Add("3200A", "8ln");
|
||
delay_protection.Add("4000A", "10ln");
|
||
delay_protection.Add("4400A", "11ln");
|
||
delay_protection.Add("4800A", "12ln");
|
||
delay_protection.Add("5200A", "13ln");
|
||
delay_protection.Add("5600A", "14ln");
|
||
if (delay_protection.ContainsKey(pro[0]))
|
||
{
|
||
value_list.Add(delay_protection[pro[0]]);
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,档位值不在指定范围内(" + string.Join("、", delay_protection.Keys.ToArray()) + ")"));
|
||
}
|
||
}
|
||
|
||
if (item == "411开关(保护器)欠压保护:")
|
||
{
|
||
Dictionary<string, string> delay_protection = new Dictionary<string, string>();
|
||
delay_protection.Add("170V", "170");
|
||
delay_protection.Add("175V", "175");
|
||
delay_protection.Add("180V", "180");
|
||
delay_protection.Add("185V", "185");
|
||
delay_protection.Add("190V", "190");
|
||
delay_protection.Add("195V", "195");
|
||
delay_protection.Add("200V", "200");
|
||
if (delay_protection.ContainsKey(pro[0]))
|
||
{
|
||
value_list.Add(delay_protection[pro[0]]);
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,档位值不在指定范围内(" + string.Join("、", delay_protection.Keys.ToArray()) + ")"));
|
||
}
|
||
}
|
||
|
||
if (item == "411开关(保护器)过压保护:")
|
||
{
|
||
Dictionary<string, string> delay_protection = new Dictionary<string, string>();
|
||
delay_protection.Add("255V", "255");
|
||
delay_protection.Add("260V", "260");
|
||
delay_protection.Add("265V", "265");
|
||
delay_protection.Add("270V", "270");
|
||
delay_protection.Add("275V", "275");
|
||
delay_protection.Add("280V", "280");
|
||
delay_protection.Add("285V", "285");
|
||
delay_protection.Add("290V", "290");
|
||
if (delay_protection.ContainsKey(pro[0]))
|
||
{
|
||
value_list.Add(delay_protection[pro[0]]);
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,档位值不在指定范围内(" + string.Join("、", delay_protection.Keys.ToArray()) + ")"));
|
||
}
|
||
}
|
||
|
||
pro[1] = pro[1].Replace(")", "");
|
||
if (pro[1] == "开" || pro[1] == "关")
|
||
{
|
||
value_list.Add(pro[1]);
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,()里的值不是开或者关"));
|
||
}
|
||
|
||
if (item == "411开关(保护器)额定剩余电流保护:")
|
||
{
|
||
leakage_protection = string.Join("|", value_list.ToArray());
|
||
}
|
||
if (item == "411开关(保护器)过载保护:")
|
||
{
|
||
overload_protection = string.Join("|", value_list.ToArray());
|
||
}
|
||
if (item == "411开关(保护器)短路延时保护:")
|
||
{
|
||
short_circuit_delay_protection = string.Join("|", value_list.ToArray());
|
||
}
|
||
if (item == "411开关(保护器)短路瞬时保护:")
|
||
{
|
||
short_circuit_protection = string.Join("|", value_list.ToArray());
|
||
}
|
||
if (item == "411开关(保护器)欠压保护:")
|
||
{
|
||
undervoltage_protection = string.Join("|", value_list.ToArray());
|
||
}
|
||
if (item == "411开关(保护器)过压保护:")
|
||
{
|
||
overvoltage_protection = string.Join("|", value_list.ToArray());
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (item == "411开关(保护器)缺相保护:")
|
||
{
|
||
if (value[1] == "开" || value[1] == "关")
|
||
{
|
||
phase_loss_protection = value[1];
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,开关值不是开或者关"));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var pro = value[1];
|
||
if (value[1] == "100A" || value[1] == "200A" || value[1] == "400A" || value[1] == "800A")
|
||
{
|
||
fusible_core_current = value[1];
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "背景资料的" + item + "格式不正确,电流值不在指定范围内:100A、200A、400A、800A"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "上传失败:考试试卷表格内容为空"));
|
||
}
|
||
#endregion
|
||
|
||
if (bll.GetRecordCount(" ExamName='" + exam_table.Rows[0]["考试名称"].ToString() + "' ") > 0)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "该考试名称已存在,请重新修改后再导入"));
|
||
}
|
||
var now = DateTime.Now;
|
||
exam_model.ExamId = Guid.NewGuid().ToString("N");
|
||
exam_model.ExamName = exam_table.Rows[0]["考试名称"].ToString();
|
||
exam_model.ExaminationDuration = exam_table.Rows[0]["考试时长"].ToString();
|
||
exam_model.SceneId = "eab5920509b011ed844e7cd30a92bb1c";
|
||
exam_model.PlatformAreaId = platform_area_id;
|
||
exam_model.LineId = line_id;
|
||
exam_model.WorkOrderContent = exam_table.Rows[0]["工单内容"].ToString();
|
||
exam_model.BackgroundInformation = exam_table.Rows[0]["背景资料"].ToString();
|
||
exam_model.IncomingLineModelLength = exam_table.Rows[0]["进线电缆型号及长度"].ToString();
|
||
exam_model.OutgoingLineModelLength = exam_table.Rows[0]["出线电缆型号及长度"].ToString();
|
||
exam_model.Status = "未发布";
|
||
exam_model.CreateTime = now;
|
||
exam_model.LeakageProtection = leakage_protection;
|
||
exam_model.OverloadProtection = overload_protection;
|
||
exam_model.ShortCircuitDelayProtection = short_circuit_delay_protection;
|
||
exam_model.ShortCircuitProtection = short_circuit_protection;
|
||
exam_model.UndervoltageProtection = undervoltage_protection;
|
||
exam_model.OvervoltageProtection = overvoltage_protection;
|
||
exam_model.PhaseLossProtection = phase_loss_protection;
|
||
exam_model.FusibleCoreCurrent = fusible_core_current;
|
||
exam_model.LinePatrolDate = now;
|
||
exam_model.HandleDate = now;
|
||
#endregion
|
||
|
||
var tool_list = new List<Competition.Mysql.Model.pow_exam_tool>();
|
||
#region 巡线考试工具
|
||
var line_tool_table = Tool.ExcelToDataTable(Files.OpenReadStream(), fileExtension, "巡线考试工具", 0, true, false);
|
||
if (null != line_tool_table && line_tool_table.Rows.Count > 0)
|
||
{
|
||
for (int i = 0; i < line_tool_table.Rows.Count; i++)
|
||
{
|
||
#region ===检查上传的字段====
|
||
var row = line_tool_table.Rows[i];
|
||
#region 工具名称
|
||
var tool_name = row["工具名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(tool_name))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "巡线考试工具第" + (i + 2) + "行存在工具名称为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 类型(工具、材料、着装)
|
||
var tool_type = row["类型(工具、材料、着装)"].ToString();
|
||
if (string.IsNullOrWhiteSpace(tool_type))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "巡线考试工具第" + (i + 2) + "行存在类型(工具、材料、着装)为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "上传失败:考试工具表格内容为空"));
|
||
}
|
||
#endregion
|
||
|
||
for (int i = 0; i < line_tool_table.Rows.Count; i++)
|
||
{
|
||
var row = line_tool_table.Rows[i];
|
||
var tool_init_model = init_tool_list.Where(a => a.ToolName == row["工具名称"].ToString() && a.Purpose == "巡线").FirstOrDefault();
|
||
if (tool_init_model != null)
|
||
{
|
||
var tool_model = new Competition.Mysql.Model.pow_exam_tool();
|
||
tool_model.ExamId = exam_model.ExamId;
|
||
tool_model.ExamToolId = Guid.NewGuid().ToString("N");
|
||
tool_model.ToolId = tool_init_model.ToolId;
|
||
tool_model.ToolName = row["工具名称"].ToString();
|
||
tool_model.ToolType = row["类型(工具、材料、着装)"].ToString();
|
||
tool_model.Purpose = "巡线";
|
||
tool_model.ThreeToolId = tool_init_model.ThreeToolId;
|
||
tool_list.Add(tool_model);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 排故考试工具
|
||
var fault_tool_table = Tool.ExcelToDataTable(Files.OpenReadStream(), fileExtension, "排故考试工具", 0, true, false);
|
||
if (null != fault_tool_table && fault_tool_table.Rows.Count > 0)
|
||
{
|
||
for (int i = 0; i < fault_tool_table.Rows.Count; i++)
|
||
{
|
||
#region ===检查上传的字段====
|
||
var row = fault_tool_table.Rows[i];
|
||
#region 工具名称
|
||
var tool_name = row["工具名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(tool_name))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "排故考试工具第" + (i + 2) + "行存在工具名称为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 类型(工具、材料、着装)
|
||
var tool_type = row["类型(工具、材料、着装)"].ToString();
|
||
if (string.IsNullOrWhiteSpace(tool_type))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "排故考试工具第" + (i + 2) + "行存在类型(工具、材料、着装)为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "上传失败:考试工具表格内容为空"));
|
||
}
|
||
#endregion
|
||
|
||
for (int i = 0; i < fault_tool_table.Rows.Count; i++)
|
||
{
|
||
var row = fault_tool_table.Rows[i];
|
||
var tool_init_model = init_tool_list.Where(a => a.ToolName == row["工具名称"].ToString() && a.Purpose == "排故").FirstOrDefault();
|
||
if (tool_init_model != null)
|
||
{
|
||
var tool_model = new Competition.Mysql.Model.pow_exam_tool();
|
||
tool_model.ExamId = exam_model.ExamId;
|
||
tool_model.ExamToolId = Guid.NewGuid().ToString("N");
|
||
tool_model.ToolId = tool_init_model.ToolId;
|
||
tool_model.ToolName = row["工具名称"].ToString();
|
||
tool_model.ToolType = row["类型(工具、材料、着装)"].ToString();
|
||
tool_model.Purpose = "排故";
|
||
tool_model.ThreeToolId = tool_init_model.ThreeToolId;
|
||
tool_list.Add(tool_model);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
foreach (var item in tool_list)
|
||
{
|
||
if (tool_list.Where(a => a.ToolName == item.ToolName && a.Purpose == item.Purpose).Count() > 1)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, item.Purpose + "里有重复的工具名称:" + item.ToolName));
|
||
}
|
||
}
|
||
|
||
var fault_list = new List<Competition.Mysql.Model.pow_exam_fault>();
|
||
#region 考试故障
|
||
var fault_table = Tool.ExcelToDataTable(Files.OpenReadStream(), fileExtension, "考试故障", 0, true, false);
|
||
if (null != fault_table && fault_table.Rows.Count > 0)
|
||
{
|
||
for (int i = 0; i < fault_table.Rows.Count; i++)
|
||
{
|
||
var root_device_id = "";
|
||
var device_id = "";
|
||
#region ===检查上传的字段====
|
||
var row = fault_table.Rows[i];
|
||
#region 一级设备
|
||
var level_equipment = row["一级设备"].ToString();
|
||
if (string.IsNullOrWhiteSpace(level_equipment))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在一级设备为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
var first_model = tree_list.Where(a => a.Tower == level_equipment).FirstOrDefault();
|
||
if (first_model == null)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行一级设备内容不对,必须是" + string.Join("、", tree_list.Select(a => a.Tower).ToArray()) + "之中"));
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 二级设备
|
||
var secondary_equipment = row["二级设备"].ToString();
|
||
if (!string.IsNullOrWhiteSpace(secondary_equipment))
|
||
{
|
||
if (first_model.Data != null)
|
||
{
|
||
var second_model = first_model.Data.Where(a => a.PowerDistributionBox == secondary_equipment).FirstOrDefault();
|
||
if (second_model == null)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行二级设备内容不对,必须是" + string.Join("、", first_model.Data.Select(a => a.PowerDistributionBox).ToArray()) + "之中"));
|
||
}
|
||
else
|
||
{
|
||
root_device_id = first_model.TowerId;
|
||
device_id = second_model.PowerDistributionBoxId;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
#region 三级设备
|
||
var three_equipment = row["三级设备"].ToString();
|
||
if (!string.IsNullOrWhiteSpace(three_equipment))
|
||
{
|
||
if (first_model.Data.Where(a => a.PowerDistributionBox == secondary_equipment).FirstOrDefault().Data != null)
|
||
{
|
||
var three_model = first_model.Data.Where(a => a.PowerDistributionBox == secondary_equipment).FirstOrDefault().Data.Where(a => a.Line == three_equipment).FirstOrDefault();
|
||
if (three_model == null)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行三级设备内容不对,必须是" + string.Join("、", first_model.Data.Where(a => a.PowerDistributionBox == secondary_equipment).FirstOrDefault().Data.Select(a => a.Line).ToArray()) + "之中"));
|
||
}
|
||
else
|
||
{
|
||
root_device_id = first_model.TowerId;
|
||
device_id = three_model.LineId;
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
if (!string.IsNullOrEmpty(level_equipment) && string.IsNullOrEmpty(secondary_equipment) && string.IsNullOrEmpty(three_equipment))
|
||
{
|
||
root_device_id = first_model.TowerId;
|
||
device_id = first_model.TowerId;
|
||
}
|
||
|
||
root_device_id_list.Add(root_device_id);
|
||
device_id_list.Add(device_id);
|
||
|
||
#region 故障现象
|
||
var fault_desc = row["故障现象"].ToString();
|
||
if (string.IsNullOrWhiteSpace(fault_desc))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在故障现象为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
var fault_model = init_fault_list.Where(a => a.FaultDesc == fault_desc).FirstOrDefault();
|
||
if (fault_model == null)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障现象的内容不对"));
|
||
}
|
||
#endregion
|
||
|
||
#region 故障等级
|
||
var defect_level = row["故障等级"].ToString();
|
||
if (string.IsNullOrWhiteSpace(defect_level))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在故障等级为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (defect_level != "一般" && defect_level != "紧急" && defect_level != "重大")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障等级内容不正确,必须是一般、紧急、重大之中"));
|
||
}
|
||
#endregion
|
||
|
||
#region 是否具体模拟
|
||
var specific_simulation = row["是否具体模拟"].ToString();
|
||
if (string.IsNullOrWhiteSpace(specific_simulation))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在是否具体模拟为空的记录,请检查上传文件"));
|
||
}
|
||
if (specific_simulation != "现场处理" && specific_simulation != "选择题")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障等级内容不正确,必须是现场处理、选择题之中"));
|
||
}
|
||
#endregion
|
||
|
||
#region 查找缺陷分值
|
||
var select_socre_value = row["查找缺陷分值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(select_socre_value))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在查找缺陷分值为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
decimal select_socre;
|
||
if (!decimal.TryParse(select_socre_value, out select_socre))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行查找缺陷分值数据格式不对,必须是数字"));
|
||
}
|
||
#endregion
|
||
|
||
#region 故障缺陷分值
|
||
var fault_score_value = row["故障缺陷分值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(fault_score_value))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在故障缺陷分值为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
decimal fault_score;
|
||
if (!decimal.TryParse(fault_score_value, out fault_score))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障缺陷分值数据格式不对,必须是数字"));
|
||
}
|
||
#endregion
|
||
|
||
#region 处理缺陷分值
|
||
var handler_score_value = row["处理缺陷分值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(handler_score_value))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在处理缺陷分值为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
decimal handler_score;
|
||
if (!decimal.TryParse(handler_score_value, out handler_score))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行处理缺陷分值数据格式不对,必须是数字"));
|
||
}
|
||
#endregion
|
||
|
||
#region 故障状态
|
||
var choice_question = row["故障状态"].ToString();
|
||
if (string.IsNullOrWhiteSpace(choice_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在故障状态为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (choice_question != "正常" && choice_question != "单个故障" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、单个故障、多个故障之中"));
|
||
}
|
||
#endregion
|
||
|
||
if (specific_simulation == "选择题" && choice_question != "正常")
|
||
{
|
||
#region 题干
|
||
var topic = row["题干"].ToString();
|
||
if (string.IsNullOrWhiteSpace(topic))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在题干为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 选项A
|
||
var optionA = row["选项A"].ToString();
|
||
if (string.IsNullOrWhiteSpace(optionA))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在选项A为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 选项B
|
||
var optionB = row["选项B"].ToString();
|
||
if (string.IsNullOrWhiteSpace(optionB))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在选项B为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 选项C
|
||
var optionC = row["选项C"].ToString();
|
||
if (string.IsNullOrWhiteSpace(optionC))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在选项C为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 正确答案
|
||
var right_key = row["正确答案,多个以|分隔"].ToString();
|
||
if (string.IsNullOrWhiteSpace(right_key))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在正确答案为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (right_key.Contains("|"))
|
||
{
|
||
var right_key_list = right_key.Split('|');
|
||
foreach (var item in right_key_list)
|
||
{
|
||
if (item != "A" && item != "B" && item != "C" && item != "D" && item != "E")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行正确答案内容不对,多个答案选项,每个|分隔的值应该为:A、B、C、D、E之中"));
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (right_key != "A" && right_key != "B" && right_key != "C" && right_key != "D" && right_key != "E")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行正确答案内容不对,单个答案选项,值应该为:A、B、C、D、E之中"));
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
if (fault_desc == "出线电缆编号牌型号编写错误")
|
||
{
|
||
#region 电缆名称
|
||
var cable_name = row["电缆名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(cable_name))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在电缆名称为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 电缆起点
|
||
var cable_start = row["电缆起点"].ToString();
|
||
if (string.IsNullOrWhiteSpace(cable_start))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在电缆起点为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 电缆终点
|
||
var cable_end = row["电缆终点"].ToString();
|
||
if (string.IsNullOrWhiteSpace(cable_end))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在电缆终点为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
|
||
#region 型号长度
|
||
var model_length = row["型号长度"].ToString();
|
||
if (string.IsNullOrWhiteSpace(model_length))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在型号长度为空的记录,请检查上传文件"));
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
if (fault_desc == "配电箱箱门未加锁")
|
||
{
|
||
if (choice_question == "单个故障")
|
||
{
|
||
choice_question = "多个故障";
|
||
}
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["位置 左、中、右"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "左" && multiple_question_list[j] != "右")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是左、右之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "柜门与箱体没有链接线")
|
||
{
|
||
if (choice_question == "单个故障")
|
||
{
|
||
choice_question = "多个故障";
|
||
}
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["位置 左、中、右"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "左" && multiple_question_list[j] != "右")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是左、右之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "配电箱孔洞未封堵")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "411电缆出线孔" && multiple_question_list[j] != "412电缆出线孔" && multiple_question_list[j] != "备用电缆出线孔")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是411电缆出线孔、412电缆出线孔、备用电缆出线孔之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "熔断器下桩头发热")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "A相" && multiple_question_list[j] != "B相" && multiple_question_list[j] != "C相")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是A相、B相、C相之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "熔芯不匹配")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "A相熔芯" && multiple_question_list[j] != "B相熔芯" && multiple_question_list[j] != "C相熔芯")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是A相熔芯、B相熔芯、C相熔芯之中"));
|
||
}
|
||
}
|
||
}
|
||
|
||
var fusible_core_normal = row["熔芯正常值"].ToString();
|
||
if (fusible_core_normal != "100A" && fusible_core_normal != "200A" && fusible_core_normal != "400A" && fusible_core_normal != "800A")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行熔芯正常值内容不对,必须是100A、200A、400A、800A之中"));
|
||
}
|
||
|
||
var fusible_core_fault = row["熔芯故障值"].ToString();
|
||
if (fusible_core_fault != "100A" && fusible_core_fault != "200A" && fusible_core_fault != "400A" && fusible_core_fault != "800A")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行熔芯故障值内容不对,需要有个默认值,必须是100A、200A、400A、800A之中"));
|
||
}
|
||
|
||
if (fusible_core_normal == fusible_core_fault)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行熔芯正常值与熔芯故障值不能一样"));
|
||
}
|
||
}
|
||
else if (fault_desc == "熔芯损坏")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "A相熔芯" && multiple_question_list[j] != "B相熔芯" && multiple_question_list[j] != "C相熔芯")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是A相熔芯、B相熔芯、C相熔芯之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "电缆头套管相色缺失")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "A相" && multiple_question_list[j] != "B相" && multiple_question_list[j] != "C相" && multiple_question_list[j] != "N相")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是A相、B相、C相、N相之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "电缆接头发热")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "A相发热" && multiple_question_list[j] != "B相发热" && multiple_question_list[j] != "C相发热")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是A相发热、B相发热、C相发热之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "电缆绝缘层老化开裂")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "A相绝缘层老化开裂" && multiple_question_list[j] != "B相绝缘层老化开裂" && multiple_question_list[j] != "C相绝缘层老化开裂" && multiple_question_list[j] != "N相绝缘层老化开裂")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是A相绝缘层老化开裂、B相绝缘层老化开裂、C相绝缘层老化开裂、N相绝缘层老化开裂之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "通道有异物")
|
||
{
|
||
if (choice_question == "多个故障")
|
||
{
|
||
choice_question = "单个故障";
|
||
}
|
||
if (choice_question != "正常" && choice_question != "单个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、单个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
|
||
if (multiple_question != "大藤蔓" && multiple_question != "小藤蔓" && multiple_question != "异物")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的,具体故障必须是大藤蔓、小藤蔓、异物之中"));
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "拉线无警示套管")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "北侧拉线" && multiple_question_list[j] != "西侧拉线" && multiple_question_list[j] != "东侧拉线")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是北侧拉线、西侧拉线、东侧拉线之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "拉线松动")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "北侧拉线" && multiple_question_list[j] != "西侧拉线" && multiple_question_list[j] != "东侧拉线")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是北侧拉线、西侧拉线、东侧拉线之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "拉线断股锈蚀")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "北侧拉线" && multiple_question_list[j] != "西侧拉线" && multiple_question_list[j] != "东侧拉线")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是北侧拉线、西侧拉线、东侧拉线之中"));
|
||
}
|
||
}
|
||
}
|
||
|
||
var position = row["故障点位置 高,中,低"].ToString();
|
||
if (position != "高" && position != "中" && position != "低")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障点位置内容不对,需要有个默认值,必须是高、中、低之中"));
|
||
}
|
||
|
||
var difficulty_level = row["难度等级 高、中、低"].ToString();
|
||
if (difficulty_level != "高" && difficulty_level != "中" && difficulty_level != "低")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行难度等级内容不对,需要有个默认值,必须是高、中、低之中"));
|
||
}
|
||
}
|
||
else if (fault_desc == "拉线UT线夹螺帽不齐全")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "北侧拉线" && multiple_question_list[j] != "西侧拉线" && multiple_question_list[j] != "东侧拉线")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是北侧拉线、西侧拉线、东侧拉线之中"));
|
||
}
|
||
}
|
||
}
|
||
|
||
var position = row["位置 左、中、右"].ToString();
|
||
if (position != "左" && position != "右")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行位置 左、中、右内容不对,需要有个默认值,必须是左、右之中"));
|
||
}
|
||
}
|
||
else if (fault_desc == "接头发热")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "N相" && multiple_question_list[j] != "非N相")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是N相、非N相之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "电杆杆身露筋、有裂纹")
|
||
{
|
||
if (choice_question == "多个故障")
|
||
{
|
||
choice_question = "单个故障";
|
||
}
|
||
if (choice_question != "正常" && choice_question != "单个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、单个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
|
||
if (multiple_question != "露筋" && multiple_question != "大裂纹" && multiple_question != "小裂纹")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的,具体故障必须是露筋、大裂纹、小裂纹之中"));
|
||
}
|
||
}
|
||
|
||
var position = row["故障点位置 高,中,低"].ToString();
|
||
if (position != "高" && position != "中" && position != "低")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障点位置内容不对,需要有个默认值,必须是高、中、低之中"));
|
||
}
|
||
|
||
var difficulty_level = row["难度等级 高、中、低"].ToString();
|
||
if (difficulty_level != "高" && difficulty_level != "中" && difficulty_level != "低")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行难度等级内容不对,需要有个默认值,必须是高、中、低之中"));
|
||
}
|
||
|
||
var direction = row["方向 东、西、南、北"].ToString();
|
||
if (direction != "东" && direction != "西" && direction != "南" && direction != "北")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行方向内容不对,需要有个默认值,必须是东、西、南、北之中"));
|
||
}
|
||
}
|
||
else if (fault_desc == "鸟巢")
|
||
{
|
||
if (choice_question == "多个故障")
|
||
{
|
||
choice_question = "单个故障";
|
||
}
|
||
if (choice_question != "正常" && choice_question != "单个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、单个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
|
||
if (multiple_question != "A相与B相之间" && multiple_question != "B相与N相之间" && multiple_question != "N相与C相之间")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的,具体故障必须是A相与B相之间、B相与N相之间、N相与C相之间之中"));
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "电杆倾斜")
|
||
{
|
||
if (choice_question == "多个故障")
|
||
{
|
||
choice_question = "单个故障";
|
||
}
|
||
if (choice_question != "正常" && choice_question != "单个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、单个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["方向 东、西、南、北"].ToString();
|
||
|
||
if (multiple_question != "东" && multiple_question != "南" && multiple_question != "西" && multiple_question != "北")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的,具体故障必须是东、南、西、北之中"));
|
||
}
|
||
|
||
var degrees_value = row["故障点位置角度度数"].ToString();
|
||
if (string.IsNullOrEmpty(degrees_value))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在故障点位置角度度数为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
int number;
|
||
if (!int.TryParse(degrees_value, out number))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障点位置角度度数数据格式不对,必须是数字"));
|
||
}
|
||
if (number < -10 && number > 10)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障点位置角度度数范围必须在-10~10"));
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "瓷瓶损坏")//单个故障
|
||
{
|
||
if (choice_question != "正常" && choice_question != "单个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、单个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var fusible_core_normal = row["缺陷详细信息"].ToString();
|
||
if (fusible_core_normal != "大缺口" && fusible_core_normal != "上缺口" && fusible_core_normal != "下缺口" && fusible_core_normal != "瓷瓶裂纹")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行缺陷详细信息内容不对,必须是大缺口、上缺口、下缺口、瓷瓶裂纹之中"));
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "线路杂物")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "A相" && multiple_question_list[j] != "B相" && multiple_question_list[j] != "C相" && multiple_question_list[j] != "N相")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是A相、B相、C相、N相之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "线路弧垂不一致")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
|
||
if (choice_question != "正常")
|
||
{
|
||
var multiple_question = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrEmpty(multiple_question))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行设置为故障时,必须设置一个故障值"));
|
||
}
|
||
|
||
var multiple_question_list = multiple_question.Split('|');
|
||
for (int j = 0; j < multiple_question_list.Length; j++)
|
||
{
|
||
if (multiple_question_list[j] != "A相" && multiple_question_list[j] != "B相" && multiple_question_list[j] != "C相" && multiple_question_list[j] != "N相")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行" + fault_desc + "的第" + (j + 1) + "个值必须是A相、B相、C相、N相之中"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (fault_desc == "相色标识错误")
|
||
{
|
||
if (choice_question != "正常" && choice_question != "多个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、多个故障之中"));
|
||
}
|
||
var values = row["具体故障,多个故障以|分隔"].ToString();
|
||
if (string.IsNullOrWhiteSpace(values))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在具体故障为空的记录,请检查上传文件"));
|
||
}
|
||
if (!values.Contains("|"))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行具体故障必须为四个,并以|分隔"));
|
||
}
|
||
var values_list = values.Split('|');
|
||
if (values_list.Length != 4)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行具体故障必须为两个,并以|分隔"));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (choice_question != "正常" && choice_question != "单个故障")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行故障状态内容不对,必须是正常、单个故障之中"));
|
||
}
|
||
}
|
||
|
||
if (fault_desc == "漏电保护设置不合理")
|
||
{
|
||
#region 断路器设置名称
|
||
var settings = row["断路器设置名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(settings))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器设置名称为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (settings != "漏电保护设置")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器设置名称内容不对,必须是漏电保护设置"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数名
|
||
var names = row["断路器参数名"].ToString();
|
||
if (string.IsNullOrWhiteSpace(names))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数名为空的记录,请检查上传文件"));
|
||
}
|
||
if (names != "档位|开关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行漏电保护设置不合理的断路器参数名必须是:档位|开关"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数值
|
||
var values = row["断路器参数值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(values))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数值为空的记录,请检查上传文件"));
|
||
}
|
||
if (!values.Contains("|"))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为两个,并以|分隔"));
|
||
}
|
||
var values_list = values.Split('|');
|
||
if (values_list.Length != 2)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为两个,并以|分隔"));
|
||
}
|
||
if (values_list[0] == "50mA")
|
||
{
|
||
values_list[0] = "050mA";
|
||
}
|
||
if (values_list[0] != "50mA" && values_list[0] != "050mA" && values_list[0] != "100mA" && values_list[0] != "200mA" && values_list[0] != "300mA" && values_list[0] != "400mA" && values_list[0] != "500mA" && values_list[0] != "600mA" && values_list[0] != "800mA")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第一个值必须是50mA、100mA、200mA、300mA、400mA、500mA、600mA、800mA"));
|
||
}
|
||
if (values_list[1] != "开" && values_list[1] != "关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第二个值必须是开或者关"));
|
||
}
|
||
#endregion
|
||
}
|
||
else if (fault_desc == "过载保护设置错误")
|
||
{
|
||
#region 断路器设置名称
|
||
var settings = row["断路器设置名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(settings))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器设置名称为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (settings != "过载保护设置")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器设置名称内容不对,必须是:过载保护设置"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数名
|
||
var names = row["断路器参数名"].ToString();
|
||
if (string.IsNullOrWhiteSpace(names))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数名为空的记录,请检查上传文件"));
|
||
}
|
||
if (names != "ln1|保护|t1")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行过载保护设置错误的断路器参数名必须是:ln1|保护|t1"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数值
|
||
var values = row["断路器参数值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(values))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数值为空的记录,请检查上传文件"));
|
||
}
|
||
if (!values.Contains("|"))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为三个,并以|分隔"));
|
||
}
|
||
var values_list = values.Split('|');
|
||
if (values_list.Length != 3)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为三个,并以|分隔"));
|
||
}
|
||
if (values_list[0] != "0.4ln" && values_list[0] != "0.5ln" && values_list[0] != "0.6ln" && values_list[0] != "0.7ln" && values_list[0] != "0.8ln" && values_list[0] != "0.9ln" && values_list[0] != "1.0ln")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第一个值必须是0.4ln、0.5ln、0.6ln、0.7ln、0.8ln、0.9ln、1.0ln"));
|
||
}
|
||
if (values_list[1] != "开" && values_list[1] != "关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第二个值必须是开或者关"));
|
||
}
|
||
if (values_list[2] != "3S" && values_list[2] != "4S" && values_list[2] != "5S")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第三个值必须是3S、4S、5S"));
|
||
}
|
||
#endregion
|
||
}
|
||
else if (fault_desc == "短路延时保护设置错误")
|
||
{
|
||
#region 断路器设置名称
|
||
var settings = row["断路器设置名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(settings))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器设置名称为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (settings != "短路延时设置")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器设置名称内容不对,必须是:短路延时设置"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数名
|
||
var names = row["断路器参数名"].ToString();
|
||
if (string.IsNullOrWhiteSpace(names))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数名为空的记录,请检查上传文件"));
|
||
}
|
||
if (names != "ln2|保护|t2|时限")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行短路延时保护设置错误的断路器参数名必须是:ln2|保护|t2|时限"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数值
|
||
var values = row["断路器参数值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(values))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数值为空的记录,请检查上传文件"));
|
||
}
|
||
if (!values.Contains("|"))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为四个,并以|分隔"));
|
||
}
|
||
var values_list = values.Split('|');
|
||
if (values_list.Length != 4)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为四个,并以|分隔"));
|
||
}
|
||
if (values_list[0] != "2ln" && values_list[0] != "2.5ln" && values_list[0] != "3ln" && values_list[0] != "4ln" && values_list[0] != "5ln" && values_list[0] != "6ln" && values_list[0] != "7ln" && values_list[0] != "8ln" && values_list[0] != "10ln")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第一个值必须是2ln、2.5ln、3ln、4ln、5ln、6ln、7ln、8ln、10ln"));
|
||
}
|
||
if (values_list[1] != "开" && values_list[1] != "关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第二个值必须是开或者关"));
|
||
}
|
||
if (values_list[2] != "0.05S" && values_list[2] != "0.1S" && values_list[2] != "0.2S" && values_list[2] != "0.3S" && values_list[2] != "0.4S" && values_list[2] != "0.6S" && values_list[2] != "0.8S" && values_list[2] != "1S")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第三个值必须是0.05S、0.1S、0.2S、0.3S、0.4S、0.6S、0.8S、1S"));
|
||
}
|
||
if (values_list[3] != "定" && values_list[3] != "反")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第四个值必须是定或者反"));
|
||
}
|
||
#endregion
|
||
}
|
||
else if (fault_desc == "短路瞬时保护设置错误")
|
||
{
|
||
#region 断路器设置名称
|
||
var settings = row["断路器设置名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(settings))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器设置名称为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (settings != "短路瞬时设置")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器设置名称内容不对,必须是短路瞬时设置"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数名
|
||
var names = row["断路器参数名"].ToString();
|
||
if (string.IsNullOrWhiteSpace(names))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数名为空的记录,请检查上传文件"));
|
||
}
|
||
if (names != "ln2|保护")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行短路瞬时保护设置错误的断路器参数名必须是:ln2|保护"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数值
|
||
var values = row["断路器参数值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(values))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数值为空的记录,请检查上传文件"));
|
||
}
|
||
if (!values.Contains("|"))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为两个,并以|分隔"));
|
||
}
|
||
var values_list = values.Split('|');
|
||
if (values_list.Length != 2)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为两个,并以|分隔"));
|
||
}
|
||
if (values_list[0] != "6ln" && values_list[0] != "7ln" && values_list[0] != "8ln" && values_list[0] != "10ln" && values_list[0] != "11ln" && values_list[0] != "12ln" && values_list[0] != "13ln" && values_list[0] != "14ln")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第一个值必须是6ln、7ln、8ln、10ln、11ln、12ln、13ln、14ln"));
|
||
}
|
||
if (values_list[1] != "开" && values_list[1] != "关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第二个值必须是开或者关"));
|
||
}
|
||
#endregion
|
||
}
|
||
else if (fault_desc == "欠压保护设置错误")
|
||
{
|
||
#region 断路器设置名称
|
||
var settings = row["断路器设置名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(settings))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器设置名称为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (settings != "欠压保护设置")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器设置名称内容不对,必须是:欠压保护设置"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数名
|
||
var names = row["断路器参数名"].ToString();
|
||
if (string.IsNullOrWhiteSpace(names))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数名为空的记录,请检查上传文件"));
|
||
}
|
||
if (names != "档位|开关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行欠压保护设置错误的断路器参数名必须是:档位|开关"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数值
|
||
var values = row["断路器参数值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(values))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数值为空的记录,请检查上传文件"));
|
||
}
|
||
if (!values.Contains("|"))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为两个,并以|分隔"));
|
||
}
|
||
var values_list = values.Split('|');
|
||
if (values_list.Length != 2)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为两个,并以|分隔"));
|
||
}
|
||
if (values_list[0] != "170" && values_list[0] != "175" && values_list[0] != "180" && values_list[0] != "185" && values_list[0] != "190" && values_list[0] != "195" && values_list[0] != "200")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第一个值必须是170、175、180、185、190、195、200"));
|
||
}
|
||
if (values_list[1] != "开" && values_list[1] != "关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第二个值必须是开或者关"));
|
||
}
|
||
#endregion
|
||
}
|
||
else if (fault_desc == "过压保护设置错误")
|
||
{
|
||
#region 断路器设置名称
|
||
var settings = row["断路器设置名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(settings))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器设置名称为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (settings != "过压保护设置")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器设置名称内容不对,必须是:过压保护设"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数名
|
||
var names = row["断路器参数名"].ToString();
|
||
if (string.IsNullOrWhiteSpace(names))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数名为空的记录,请检查上传文件"));
|
||
}
|
||
if (names != "档位|开关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行过压保护设置错误的断路器参数名必须是:档位|开关"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数值
|
||
var values = row["断路器参数值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(values))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数值为空的记录,请检查上传文件"));
|
||
}
|
||
if (!values.Contains("|"))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为两个,并以|分隔"));
|
||
}
|
||
var values_list = values.Split('|');
|
||
if (values_list.Length != 2)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为两个,并以|分隔"));
|
||
}
|
||
if (values_list[0] != "255" && values_list[0] != "260" && values_list[0] != "265" && values_list[0] != "270" && values_list[0] != "275" && values_list[0] != "280" && values_list[0] != "285" && values_list[0] != "290")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第一个值必须是255、260、265、270、275、280、285、290"));
|
||
}
|
||
if (values_list[1] != "开" && values_list[1] != "关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第二个值必须是开或者关"));
|
||
}
|
||
#endregion
|
||
}
|
||
else if (fault_desc == "缺相保护设置错误")
|
||
{
|
||
#region 断路器设置名称
|
||
var settings = row["断路器设置名称"].ToString();
|
||
if (string.IsNullOrWhiteSpace(settings))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器设置名称为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
if (settings != "缺相保护设置")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器设置名称内容不对,必须是缺相保护设置"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数名
|
||
var names = row["断路器参数名"].ToString();
|
||
if (string.IsNullOrWhiteSpace(names))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数名为空的记录,请检查上传文件"));
|
||
}
|
||
if (names != "开关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行缺相保护设置错误的断路器参数名必须是:开关"));
|
||
}
|
||
#endregion
|
||
|
||
#region 断路器参数值
|
||
var values = row["断路器参数值"].ToString();
|
||
if (string.IsNullOrWhiteSpace(values))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在断路器参数值为空的记录,请检查上传文件"));
|
||
}
|
||
var values_list = values.Split('|');
|
||
if (values_list.Length != 1)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值必须为一个,并以|分隔"));
|
||
}
|
||
if (values_list[0] != "开" && values_list[0] != "关")
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行断路器参数值第一个值必须是开或者关"));
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "上传失败:考试故障表格内容为空"));
|
||
}
|
||
#endregion
|
||
#endregion
|
||
|
||
for (int i = 0; i < fault_table.Rows.Count; i++)
|
||
{
|
||
var row = fault_table.Rows[i];
|
||
var fault_model = new Competition.Mysql.Model.pow_exam_fault();
|
||
fault_model.ExamFaultId = Guid.NewGuid().ToString("N");
|
||
fault_model.ExamId = exam_model.ExamId;
|
||
var select_fault_model = init_fault_list.Where(a => a.FaultDesc == row["故障现象"].ToString() && a.RootDeviceId == root_device_id_list[i] && a.DeviceId == device_id_list[i]).FirstOrDefault();
|
||
fault_model.FaultId = select_fault_model.FaultId;
|
||
fault_model.ThreeFaultId = select_fault_model.ThreeFaultId;
|
||
fault_model.ThreeDeviceId = select_fault_model.ThreeDeviceId;
|
||
fault_model.RootDeviceId = root_device_id_list[i];
|
||
fault_model.DeviceId = device_id_list[i];
|
||
fault_model.Type = select_fault_model.Type;
|
||
fault_model.FaultType = select_fault_model.FaultType;
|
||
fault_model.FaultDesc = row["故障现象"].ToString();
|
||
fault_model.DefectLevel = row["故障等级"].ToString();
|
||
fault_model.SpecificSimulation = row["是否具体模拟"].ToString();
|
||
fault_model.FaultPosition = row["故障具体位置"].ToString();
|
||
fault_model.SelectSocre = row["查找缺陷分值"].ToString();
|
||
fault_model.FaultScore = row["故障缺陷分值"].ToString();
|
||
fault_model.HandlerScore = row["处理缺陷分值"].ToString();
|
||
if (row["缺陷详细信息"].ToString() == "大缺口")
|
||
{
|
||
fault_model.DegreesSerialNumber = "1";
|
||
}
|
||
else if (row["缺陷详细信息"].ToString() == "上缺口")
|
||
{
|
||
fault_model.DegreesSerialNumber = "2";
|
||
}
|
||
else if (row["缺陷详细信息"].ToString() == "下缺口")
|
||
{
|
||
fault_model.DegreesSerialNumber = "3";
|
||
}
|
||
else if (row["缺陷详细信息"].ToString() == "瓷瓶裂纹")
|
||
{
|
||
fault_model.DegreesSerialNumber = "4";
|
||
}
|
||
if (row["故障现象"].ToString() == "瓷瓶损坏")
|
||
{
|
||
if (string.IsNullOrEmpty(row["缺陷详细信息"].ToString()))
|
||
{
|
||
fault_model.DegreesSerialNumber = "0";
|
||
}
|
||
}
|
||
fault_model.DegreesValue = row["故障点位置角度度数"].ToString();
|
||
if (row["故障状态"].ToString() == "正常")
|
||
{
|
||
fault_model.ChoiceQuestion = "0";
|
||
}
|
||
else if (row["故障状态"].ToString() == "单个故障")
|
||
{
|
||
fault_model.ChoiceQuestion = "1";
|
||
}
|
||
else if (row["故障状态"].ToString() == "多个故障")
|
||
{
|
||
fault_model.ChoiceQuestion = "2";
|
||
}
|
||
if (row["故障状态"].ToString() != "正常")
|
||
{
|
||
if (row["故障现象"].ToString() == "通道有异物" || row["故障现象"].ToString() == "鸟巢" || row["故障现象"].ToString() == "电杆杆身露筋、有裂纹" || row["故障现象"].ToString() == "电杆倾斜")
|
||
{
|
||
fault_model.ChoiceQuestion = "2";
|
||
}
|
||
if (row["故障现象"].ToString() == "配电箱箱门未加锁" || row["故障现象"].ToString() == "柜门与箱体没有链接线")
|
||
{
|
||
fault_model.ChoiceQuestion = "1";
|
||
}
|
||
}
|
||
fault_model.MultipleQuestion = row["具体故障,多个故障以|分隔"].ToString();
|
||
fault_model.DifficultyLevel = row["难度等级 高、中、低"].ToString();
|
||
fault_model.PositionValue = row["故障点位置 高,中,低"].ToString();
|
||
fault_model.Position = row["位置 左、中、右"].ToString();
|
||
fault_model.FusibleCoreNormal = row["熔芯正常值"].ToString();
|
||
fault_model.FusibleCoreFault = row["熔芯故障值"].ToString();
|
||
fault_model.PorcelainBottleType = row["瓷瓶子类型(裙边1、裙边2、裙边3、裙边4)"].ToString();
|
||
fault_model.Direction = row["方向 东、西、南、北"].ToString();
|
||
fault_model.Topic = row["题干"].ToString();
|
||
fault_model.OptionA = row["选项A"].ToString();
|
||
fault_model.OptionB = row["选项B"].ToString();
|
||
fault_model.OptionC = row["选项C"].ToString();
|
||
fault_model.OptionD = row["选项D"].ToString();
|
||
fault_model.OptionE = row["选项E"].ToString();
|
||
fault_model.RightKey = row["正确答案,多个以|分隔"].ToString();
|
||
fault_model.Settings = row["断路器设置名称"].ToString();
|
||
fault_model.Name = row["断路器参数名"].ToString();
|
||
fault_model.Value = row["断路器参数值"].ToString();
|
||
fault_model.CableName = row["电缆名称"].ToString();
|
||
fault_model.CableStart = row["电缆起点"].ToString();
|
||
fault_model.CableEnd = row["电缆终点"].ToString();
|
||
fault_model.ModelLength = row["型号长度"].ToString();
|
||
fault_model.RequiredTool = select_fault_model.RequiredTool;
|
||
fault_model.CreateTime = select_fault_model.CreateTime;
|
||
fault_list.Add(fault_model);
|
||
}
|
||
|
||
var cable_fault_list = fault_list.Where(a => a.FaultDesc == "出线电缆编号牌型号编写错误").ToList();
|
||
if (cable_fault_list.Count > 0)
|
||
{
|
||
foreach (var item in cable_fault_list)
|
||
{
|
||
var name1 = "1#配变0.4kV411东线出线电缆";
|
||
var start1 = "1#配变低压综合配电箱411熔断器";
|
||
var end1 = "1#配变0.4kV411东线001#杆";
|
||
|
||
var name2 = "1#配变0.4kV412南线出线电缆";
|
||
var start2 = "1#配变低压综合配电箱412熔断器";
|
||
var end2 = "1#配变0.4kV412南线001#杆";
|
||
//411
|
||
if (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c")
|
||
{
|
||
item.CableName = exam_table.Rows[0]["台区"].ToString() + name1;
|
||
item.CableStart = exam_table.Rows[0]["台区"].ToString() + start1;
|
||
item.CableEnd = exam_table.Rows[0]["台区"].ToString() + end1;
|
||
item.ModelLength = exam_table.Rows[0]["进线电缆型号及长度"].ToString();
|
||
}
|
||
//412
|
||
if (item.DeviceId == "a238da230c0f11ed844e7cd30a92bb1c")
|
||
{
|
||
item.CableName = exam_table.Rows[0]["台区"].ToString() + name2;
|
||
item.CableStart = exam_table.Rows[0]["台区"].ToString() + start2;
|
||
item.CableEnd = exam_table.Rows[0]["台区"].ToString() + end2;
|
||
item.ModelLength = exam_table.Rows[0]["进线电缆型号及长度"].ToString();
|
||
}
|
||
|
||
var success = new List<string>();
|
||
var dic_name = "/Upload/Cable/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
|
||
var dir_path = _webHostEnvironment.WebRootPath + dic_name;
|
||
if (!Directory.Exists(dir_path))
|
||
Directory.CreateDirectory(dir_path);
|
||
var path1 = dic_name + Guid.NewGuid().ToString("N") + ".jpg";
|
||
|
||
var result1 = Tool.GeneratePictures("台区一" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? name1 : name2), "台区一" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? start1 : start2), "台区一" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? end1 : end2), exam_table.Rows[0]["进线电缆型号及长度"].ToString(), path1, _webHostEnvironment.WebRootPath);
|
||
if (result1)
|
||
{
|
||
item.SensitiveKnowledge = path1;
|
||
success.Add(path1);
|
||
}
|
||
|
||
var path2 = dic_name + Guid.NewGuid().ToString("N") + ".jpg";
|
||
var result2 = Tool.GeneratePictures("台区二" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? name1 : name2), "台区二" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? start1 : start2), "台区二" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? end1 : end2), exam_table.Rows[0]["进线电缆型号及长度"].ToString(), path2, _webHostEnvironment.WebRootPath);
|
||
if (result2)
|
||
{
|
||
item.Minhui = path2;
|
||
success.Add(path2);
|
||
}
|
||
|
||
var path3 = dic_name + Guid.NewGuid().ToString("N") + ".jpg";
|
||
var result3 = Tool.GeneratePictures("台区三" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? name1 : name2), "台区三" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? start1 : start2), "台区三" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? end1 : end2), exam_table.Rows[0]["进线电缆型号及长度"].ToString(), path3, _webHostEnvironment.WebRootPath);
|
||
if (result3)
|
||
{
|
||
item.SensitiveLine = path3;
|
||
success.Add(path3);
|
||
}
|
||
|
||
var path4 = dic_name + Guid.NewGuid().ToString("N") + ".jpg";
|
||
var result4 = Tool.GeneratePictures("台区四" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? name1 : name2), "台区四" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? start1 : start2), "台区四" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? end1 : end2), exam_table.Rows[0]["进线电缆型号及长度"].ToString(), path4, _webHostEnvironment.WebRootPath);
|
||
if (result4)
|
||
{
|
||
item.Allergy = path4;
|
||
success.Add(path4);
|
||
}
|
||
|
||
var path5 = dic_name + Guid.NewGuid().ToString("N") + ".jpg";
|
||
var result5 = Tool.GeneratePictures("台区五" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? name1 : name2), "台区五" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? start1 : start2), "台区五" + (item.DeviceId == "9d8da9360c0f11ed844e7cd30a92bb1c" ? end1 : end2), exam_table.Rows[0]["进线电缆型号及长度"].ToString(), path5, _webHostEnvironment.WebRootPath);
|
||
if (result5)
|
||
{
|
||
item.GracefulGraceful = path5;
|
||
success.Add(path5);
|
||
}
|
||
|
||
if (success.Count != 5)
|
||
{
|
||
foreach (var pic in success)
|
||
{
|
||
string path = _webHostEnvironment.WebRootPath + pic;
|
||
if (System.IO.File.Exists(path))
|
||
{
|
||
System.IO.File.Delete(path);
|
||
}
|
||
}
|
||
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "导入出错"));
|
||
}
|
||
}
|
||
}
|
||
|
||
var power_transmission_ticket_list = new List<Competition.Mysql.Model.pow_exam_operation_ticket>();
|
||
#region 考试停电操作票选项
|
||
var power_failure_ticket_table = Tool.ExcelToDataTable(Files.OpenReadStream(), fileExtension, "考试停电操作票选项", 0, true, false);
|
||
if (null != power_failure_ticket_table && power_failure_ticket_table.Rows.Count > 0)
|
||
{
|
||
for (int i = 0; i < power_failure_ticket_table.Rows.Count; i++)
|
||
{
|
||
#region ===检查上传的字段====
|
||
var row = power_failure_ticket_table.Rows[i];
|
||
#region 类型(送电、停电)
|
||
//var type = row["类型(送电、停电)"].ToString();
|
||
//if (string.IsNullOrWhiteSpace(type))
|
||
//{
|
||
// msg = "存在类型(送电、停电)为空的记录,请检查上传文件";
|
||
// return false;
|
||
//}
|
||
#endregion
|
||
|
||
#region 序号
|
||
var serial_number = row["序号"].ToString();
|
||
if (string.IsNullOrWhiteSpace(serial_number))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在序号为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
int number;
|
||
if (!int.TryParse(serial_number, out number))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行序号数据格式不对,必须是数字"));
|
||
}
|
||
#endregion
|
||
|
||
#region 内容
|
||
//var content = row["内容"].ToString();
|
||
//if (string.IsNullOrWhiteSpace(content))
|
||
//{
|
||
// msg = "存在内容为空的记录,请检查上传文件";
|
||
// return false;
|
||
//}
|
||
#endregion
|
||
#endregion
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "上传失败:考试停电操作票选项表格内容为空"));
|
||
}
|
||
for (int i = 0; i < power_failure_ticket_table.Rows.Count; i++)
|
||
{
|
||
var row = power_failure_ticket_table.Rows[i];
|
||
if (!string.IsNullOrEmpty(row["内容"].ToString()))
|
||
{
|
||
var operation_ticket_model = new Competition.Mysql.Model.pow_exam_operation_ticket();
|
||
var content = row["内容"].ToString().Replace("台区一", "xxxxx").Replace("台区二", "xxxxx").Replace("台区三", "xxxxx").Replace("台区四", "xxxxx").Replace("台区五", "xxxxx");
|
||
var ticket_init_model = init_ticket_list.Where(a => a.Content == content && a.Type == "停电").FirstOrDefault();
|
||
if (ticket_init_model != null)
|
||
{
|
||
operation_ticket_model.ExamOperationTicketId = Guid.NewGuid().ToString("N");
|
||
operation_ticket_model.OperationTicketId = ticket_init_model.OperationTicketId;
|
||
operation_ticket_model.ExamId = exam_model.ExamId;
|
||
operation_ticket_model.Type = "停电";
|
||
operation_ticket_model.SerialNumber = int.Parse(row["序号"].ToString());
|
||
operation_ticket_model.Content = row["内容"].ToString();
|
||
power_transmission_ticket_list.Add(operation_ticket_model);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 考试送电操作票选项
|
||
var power_transmission_ticket_table = Tool.ExcelToDataTable(Files.OpenReadStream(), fileExtension, "考试送电操作票选项", 0, true, false);
|
||
if (null != power_transmission_ticket_table && power_transmission_ticket_table.Rows.Count > 0)
|
||
{
|
||
for (int i = 0; i < power_transmission_ticket_table.Rows.Count; i++)
|
||
{
|
||
#region ===检查上传的字段====
|
||
var row = power_transmission_ticket_table.Rows[i];
|
||
#region 类型(送电、停电)
|
||
//var type = row["类型(送电、停电)"].ToString();
|
||
//if (string.IsNullOrWhiteSpace(type))
|
||
//{
|
||
// msg = "存在类型(送电、停电)为空的记录,请检查上传文件";
|
||
// return false;
|
||
//}
|
||
#endregion
|
||
|
||
#region 序号
|
||
var serial_number = row["序号"].ToString();
|
||
if (string.IsNullOrWhiteSpace(serial_number))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行存在序号为空的记录,请检查上传文件"));
|
||
}
|
||
|
||
int number;
|
||
if (!int.TryParse(serial_number, out number))
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试故障第" + (i + 2) + "行序号数据格式不对,必须是数字"));
|
||
}
|
||
#endregion
|
||
|
||
#region 内容
|
||
//var content = row["内容"].ToString();
|
||
//if (string.IsNullOrWhiteSpace(content))
|
||
//{
|
||
// msg = "存在内容为空的记录,请检查上传文件";
|
||
// return false;
|
||
//}
|
||
#endregion
|
||
#endregion
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, "上传失败:考试送电操作票选项表格内容为空"));
|
||
}
|
||
for (int i = 0; i < power_transmission_ticket_table.Rows.Count; i++)
|
||
{
|
||
var row = power_transmission_ticket_table.Rows[i];
|
||
if (!string.IsNullOrEmpty(row["内容"].ToString()))
|
||
{
|
||
var operation_ticket_model = new Competition.Mysql.Model.pow_exam_operation_ticket();
|
||
var content = row["内容"].ToString().Replace("台区一", "xxxxx").Replace("台区二", "xxxxx").Replace("台区三", "xxxxx").Replace("台区四", "xxxxx").Replace("台区五", "xxxxx");
|
||
var ticket_init_model = init_ticket_list.Where(a => a.Content == content && a.Type == "送电").FirstOrDefault();
|
||
if (ticket_init_model != null)
|
||
{
|
||
operation_ticket_model.ExamOperationTicketId = Guid.NewGuid().ToString("N");
|
||
operation_ticket_model.OperationTicketId = ticket_init_model.OperationTicketId;
|
||
operation_ticket_model.ExamId = exam_model.ExamId;
|
||
operation_ticket_model.Type = "送电";
|
||
operation_ticket_model.SerialNumber = int.Parse(row["序号"].ToString());
|
||
operation_ticket_model.Content = row["内容"].ToString();
|
||
power_transmission_ticket_list.Add(operation_ticket_model);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
foreach (var item in power_transmission_ticket_list)
|
||
{
|
||
if (power_transmission_ticket_list.Where(a => a.Type == item.Type && a.Content == item.Content).Count() > 1)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Fail, item.Type + "操作票里有相同的内容:" + item.Content));
|
||
}
|
||
}
|
||
|
||
if (bll.OperationData(exam_model, tool_list, fault_list, power_transmission_ticket_list) > 0)
|
||
{
|
||
return Json(Tool.GetJsonWithCode(APICode.Success, "上传导入成功"));
|
||
}
|
||
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;
|
||
}
|
||
}
|
||
}
|