diff --git a/Aucma.Scada.Api.Common/Aucma.Scada.Api.Common.csproj b/Aucma.Scada.Api.Common/Aucma.Scada.Api.Common.csproj
new file mode 100644
index 0000000..f7f7818
--- /dev/null
+++ b/Aucma.Scada.Api.Common/Aucma.Scada.Api.Common.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/Aucma.Scada.Api.Common/JsonChange.cs b/Aucma.Scada.Api.Common/JsonChange.cs
new file mode 100644
index 0000000..d36b71d
--- /dev/null
+++ b/Aucma.Scada.Api.Common/JsonChange.cs
@@ -0,0 +1,80 @@
+using Nancy.Json;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+
+namespace Aucma.Scada.Api.Common
+{
+ public class JsonChange
+ {
+ ///
+ /// Model 实体转json
+ ///
+ /// 可以是单个实体,也可是实体集(即:ToList())
+ ///
+ public string ModeToJson(object Model)
+ {
+ string str = "";
+ JavaScriptSerializer serializer = new JavaScriptSerializer();
+ str = serializer.Serialize(Model);
+ return str;
+ }
+
+ ///
+ /// json实体转Model
+ ///
+ ///
+ ///
+ ///
+ public T JsonToMode(string jsonStr)
+ {
+ T info = default(T);
+ JavaScriptSerializer serializer = new JavaScriptSerializer();
+ info = serializer.Deserialize(jsonStr);
+ return info;
+ }
+
+ ///
+ /// object转dictionary
+ ///
+ ///
+ ///
+ public Dictionary objectToDictionary(string jsonData)
+ {
+ Dictionary result = new Dictionary();
+
+ var inf = JsonConvert.DeserializeObject>(jsonData);
+
+ foreach (KeyValuePair item in inf)
+ {
+ if (item.Value != null)
+ {
+ var type = item.Value.GetType();
+ if (type == typeof(JObject))
+ {
+ var info = objectToDictionary(JsonConvert.SerializeObject(item.Value));
+ foreach (KeyValuePair ite in info)
+ {
+ result.Add(ite.Key, ite.Value);
+ }
+ continue;
+ }
+ else if (type == typeof(JArray))
+ {
+ JArray array = (JArray)item.Value;
+ var info = objectToDictionary(JsonConvert.SerializeObject(array[0]));
+ foreach (KeyValuePair ite in info)
+ {
+ result.Add(item.Key + ite.Key, ite.Value);
+ }
+ continue;
+ }
+ }
+
+ result.Add(item.Key, item.Value);
+ }
+
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Aucma.Scada.Api.Config/AppConfig.cs b/Aucma.Scada.Api.Config/AppConfig.cs
new file mode 100644
index 0000000..d5e0b2d
--- /dev/null
+++ b/Aucma.Scada.Api.Config/AppConfig.cs
@@ -0,0 +1,27 @@
+using Microsoft.Extensions.Options;
+
+namespace Aucma.Scada.Api.Config
+{
+ ///
+ /// 系统配置
+ ///
+ public class AppConfig : IOptions
+ {
+ ///
+ /// 日志文件路径
+ ///
+ public string logPath { get; set; }
+
+ ///
+ /// MES 数据库连接字符串
+ ///
+ public string mesConnStr { get; set; }
+
+ ///
+ /// MCS 数据库连接字符串
+ ///
+ public string mcsConnStr { get; set; }
+
+ public AppConfig Value => this;
+ }
+}
diff --git a/Aucma.Scada.Api.Config/Aucma.Scada.Api.Config.csproj b/Aucma.Scada.Api.Config/Aucma.Scada.Api.Config.csproj
new file mode 100644
index 0000000..144ffe8
--- /dev/null
+++ b/Aucma.Scada.Api.Config/Aucma.Scada.Api.Config.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Aucma.Scada.Api.Model/Aucma.Scada.Api.Model.csproj b/Aucma.Scada.Api.Model/Aucma.Scada.Api.Model.csproj
new file mode 100644
index 0000000..c34e818
--- /dev/null
+++ b/Aucma.Scada.Api.Model/Aucma.Scada.Api.Model.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Aucma.Scada.Api.Model/DetailElectricalinspection.cs b/Aucma.Scada.Api.Model/DetailElectricalinspection.cs
new file mode 100644
index 0000000..500350b
--- /dev/null
+++ b/Aucma.Scada.Api.Model/DetailElectricalinspection.cs
@@ -0,0 +1,50 @@
+using SqlSugar;
+using System.Runtime.Serialization;
+using System.Xml.Linq;
+
+namespace Aucma.Scada.Api.Model
+{
+ ///
+ /// 电检数据明细
+ ///
+ [SugarTable("DETAIL_ELECTRICALINSPECTION"), TenantAttribute("scada")]
+ [DataContract(Name = "DetailElectricalinspection 电检数据明细")]
+ public class DetailElectricalinspection
+ {
+ ///
+ /// 标识
+ ///
+ [SugarColumn(ColumnName = "UUID")]
+ public string Uuid { get; set; }
+ ///
+ /// 序号
+ ///
+ [SugarColumn(ColumnName = "SERIALNUMBER")]
+ public decimal? Serialnumber { get; set; }
+ ///
+ /// 项目名称
+ ///
+ [SugarColumn(ColumnName = "PROJECTNAME")]
+ public string Projectname { get; set; }
+ ///
+ /// 测试条件
+ ///
+ [SugarColumn(ColumnName = "TESTCONDITION")]
+ public string Testcondition { get; set; }
+ ///
+ /// 测试值
+ ///
+ [SugarColumn(ColumnName = "TESTVALUE")]
+ public string Testvalue { get; set; }
+ ///
+ /// 测试结果
+ ///
+ [SugarColumn(ColumnName = "TESTRESULT")]
+ public string Testresult { get; set; }
+ ///
+ /// 记录时间
+ ///
+ [SugarColumn(ColumnName = "RECORDTIME")]
+ public DateTime? Recordtime { get; set; }
+ }
+}
diff --git a/Aucma.Scada.Api.Model/RecordElectricalinspection.cs b/Aucma.Scada.Api.Model/RecordElectricalinspection.cs
new file mode 100644
index 0000000..2df803f
--- /dev/null
+++ b/Aucma.Scada.Api.Model/RecordElectricalinspection.cs
@@ -0,0 +1,50 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace Aucma.Scada.Api.Model
+{
+ ///
+ /// 电检数据记录
+ ///
+ [SugarTable("RECORD_ELECTRICALINSPECTION"), TenantAttribute("scada")]
+ [DataContract(Name = "RecordElectricalinspection 电检数据记录")]
+ public class RecordElectricalinspection
+ {
+ ///
+ /// 唯一标识
+ ///
+ [SugarColumn(ColumnName = "UUID")]
+ public string Uuid { get; set; }
+ ///
+ /// 测试总结果
+ ///
+ [SugarColumn(ColumnName = "RESULT")]
+ public string Result { get; set; }
+ ///
+ /// 产品条码
+ ///
+ [SugarColumn(ColumnName = "BARCODE")]
+ public string Barcode { get; set; }
+ ///
+ /// 测试时间
+ ///
+ [SugarColumn(ColumnName = "TESTTIME")]
+ public string Testtime { get; set; }
+ ///
+ /// 测试数据
+ ///
+ [SugarColumn(ColumnName = "TESTDATA")]
+ public string Testdata { get; set; }
+ ///
+ /// 记录时间
+ ///
+ [SugarColumn(ColumnName = "RECORDTIME")]
+ public DateTime? Recordtime { get; set; }
+ }
+}
diff --git a/Aucma.Scada.Api.Repository/Aucma.Scada.Api.Repository.csproj b/Aucma.Scada.Api.Repository/Aucma.Scada.Api.Repository.csproj
new file mode 100644
index 0000000..5907dd2
--- /dev/null
+++ b/Aucma.Scada.Api.Repository/Aucma.Scada.Api.Repository.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Aucma.Scada.Api.Repository/Repository.cs b/Aucma.Scada.Api.Repository/Repository.cs
new file mode 100644
index 0000000..f6f3021
--- /dev/null
+++ b/Aucma.Scada.Api.Repository/Repository.cs
@@ -0,0 +1,24 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Scada.Api.Repository
+{
+ public class Repository : SimpleClient where T : class, new()
+ {
+ public ITenant itenant = null;//多租户事务、GetConnection、IsAnyConnection等功能
+
+ public Repository(ISqlSugarClient db)
+ {
+ itenant = db.AsTenant();//用来处理事务
+ base.Context = db.AsTenant().GetConnectionScopeWithAttr();//获取子Db
+
+ //如果不想通过注入多个仓储
+ //用到ChangeRepository或者Db.GetMyRepository需要看标题4写法
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Aucma.Scada.Api.Repository/SqlsugarSetup.cs b/Aucma.Scada.Api.Repository/SqlsugarSetup.cs
new file mode 100644
index 0000000..5cdc1d8
--- /dev/null
+++ b/Aucma.Scada.Api.Repository/SqlsugarSetup.cs
@@ -0,0 +1,60 @@
+using Aucma.Scada.Api.Config;
+using Aucma.Scada.Api.Repository.service;
+using Aucma.Scada.Api.Repository.service.Impl;
+using Microsoft.Extensions.DependencyInjection;
+using SqlSugar;
+
+namespace Aucma.Scada.Api.Repository
+{
+ public static class SqlsugarSetup
+ {
+ ///
+ /// 注册SqlSugar
+ ///
+ ///
+ public static void AddSqlSugarSetup(this IServiceCollection services)
+ {
+ services.AddSingleton(x =>
+ {
+ var appConfig = x.GetService();
+ SqlSugarScope Db = new SqlSugarScope(new List()
+ {
+ new ConnectionConfig()
+ {
+ ConfigId = "mes",
+ DbType = DbType.SqlServer,
+ ConnectionString = appConfig.mesConnStr,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ },
+ new ConnectionConfig()
+ {
+ ConfigId = "scada",
+ DbType = DbType.Oracle,
+ ConnectionString = appConfig.mcsConnStr,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ }
+ },
+ db =>
+ {
+ db.Aop.OnLogExecuting = (sql, pars) => { };
+ });
+
+ return Db;
+ });
+ }
+
+ ///
+ /// 注册Repository、Service服务
+ ///
+ ///
+ public static void AddServices(this IServiceCollection services)
+ {
+ services.AddSingleton(typeof(Repository<>));
+
+ services.AddSingleton();
+ services.AddSingleton();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Aucma.Scada.Api.Repository/service/IDetailElectricalinspectionService.cs b/Aucma.Scada.Api.Repository/service/IDetailElectricalinspectionService.cs
new file mode 100644
index 0000000..5a49580
--- /dev/null
+++ b/Aucma.Scada.Api.Repository/service/IDetailElectricalinspectionService.cs
@@ -0,0 +1,19 @@
+using Aucma.Scada.Api.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Scada.Api.Repository.service
+{
+ public interface IDetailElectricalinspectionService
+ {
+ ///
+ /// 保存电检明细数据
+ ///
+ ///
+ ///
+ bool InsertRangeDetailElectricalinspection(List detailElectricalinspections);
+ }
+}
diff --git a/Aucma.Scada.Api.Repository/service/IRecordElectricalinspectionService.cs b/Aucma.Scada.Api.Repository/service/IRecordElectricalinspectionService.cs
new file mode 100644
index 0000000..16f3376
--- /dev/null
+++ b/Aucma.Scada.Api.Repository/service/IRecordElectricalinspectionService.cs
@@ -0,0 +1,23 @@
+using Aucma.Scada.Api.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Scada.Api.Repository.service
+{
+ ///
+ /// 电检数据记录
+ ///
+ public interface IRecordElectricalinspectionService
+ {
+
+ ///
+ /// 保存电检数据
+ ///
+ ///
+ ///
+ bool InsertRecordElectricalinspection(RecordElectricalinspection electricalinspection);
+ }
+}
diff --git a/Aucma.Scada.Api.Repository/service/Impl/DetailElectricalinspectionServiceImpl.cs b/Aucma.Scada.Api.Repository/service/Impl/DetailElectricalinspectionServiceImpl.cs
new file mode 100644
index 0000000..0f7ed90
--- /dev/null
+++ b/Aucma.Scada.Api.Repository/service/Impl/DetailElectricalinspectionServiceImpl.cs
@@ -0,0 +1,39 @@
+using Aucma.Scada.Api.Model;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Scada.Api.Repository.service.Impl
+{
+ public class DetailElectricalinspectionServiceImpl : IDetailElectricalinspectionService
+ {
+ private Repository _repository;
+
+ private ILogger _logger;
+
+ public DetailElectricalinspectionServiceImpl(Repository repository, ILogger logger)
+ {
+ _repository = repository;
+ _logger = logger;
+ }
+
+ public bool InsertRangeDetailElectricalinspection(List detailElectricalinspections)
+ {
+ bool result = false;
+
+ try
+ {
+ result = _repository.InsertRange(detailElectricalinspections);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"电检明细数据保存异常:{ex.Message}");
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/Aucma.Scada.Api.Repository/service/Impl/RecordElectricalinspectionServiceImpl.cs b/Aucma.Scada.Api.Repository/service/Impl/RecordElectricalinspectionServiceImpl.cs
new file mode 100644
index 0000000..3fe5842
--- /dev/null
+++ b/Aucma.Scada.Api.Repository/service/Impl/RecordElectricalinspectionServiceImpl.cs
@@ -0,0 +1,38 @@
+using Aucma.Scada.Api.Model;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Scada.Api.Repository.service.Impl
+{
+ internal class RecordElectricalinspectionServiceImpl : IRecordElectricalinspectionService
+ {
+ private Repository _repository;
+
+ private ILogger _logger;
+
+ public RecordElectricalinspectionServiceImpl(Repository repository, ILogger logger)
+ {
+ _repository = repository;
+ _logger = logger;
+ }
+
+ public bool InsertRecordElectricalinspection(RecordElectricalinspection electricalinspection)
+ {
+ bool result = false;
+
+ try
+ {
+ result = _repository.Insert(electricalinspection);
+ }catch(Exception ex)
+ {
+ _logger.LogError($"电检数据保存异常:{ex.Message}");
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/Aucma.Scada.Api.sln b/Aucma.Scada.Api.sln
new file mode 100644
index 0000000..0ad2de3
--- /dev/null
+++ b/Aucma.Scada.Api.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.33502.453
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aucma.Scada.Api", "Aucma.Scada.Api\Aucma.Scada.Api.csproj", "{F509601C-5E2D-4F06-ACEC-2AAB7E591E15}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aucma.Scada.Api.Model", "Aucma.Scada.Api.Model\Aucma.Scada.Api.Model.csproj", "{4F05A3C3-DCD4-4071-9F64-3936274CE011}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aucma.Scada.Api.Config", "Aucma.Scada.Api.Config\Aucma.Scada.Api.Config.csproj", "{A9FA0950-3380-441E-9E52-ADA7A8872610}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aucma.Scada.Api.Repository", "Aucma.Scada.Api.Repository\Aucma.Scada.Api.Repository.csproj", "{95BB1153-E37F-4F06-8289-C4388B966F5B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aucma.Scada.Api.Common", "Aucma.Scada.Api.Common\Aucma.Scada.Api.Common.csproj", "{740D0F39-3D9D-4758-B35A-11F1F9513A0A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F509601C-5E2D-4F06-ACEC-2AAB7E591E15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F509601C-5E2D-4F06-ACEC-2AAB7E591E15}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F509601C-5E2D-4F06-ACEC-2AAB7E591E15}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F509601C-5E2D-4F06-ACEC-2AAB7E591E15}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4F05A3C3-DCD4-4071-9F64-3936274CE011}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4F05A3C3-DCD4-4071-9F64-3936274CE011}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4F05A3C3-DCD4-4071-9F64-3936274CE011}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4F05A3C3-DCD4-4071-9F64-3936274CE011}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A9FA0950-3380-441E-9E52-ADA7A8872610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A9FA0950-3380-441E-9E52-ADA7A8872610}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A9FA0950-3380-441E-9E52-ADA7A8872610}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A9FA0950-3380-441E-9E52-ADA7A8872610}.Release|Any CPU.Build.0 = Release|Any CPU
+ {95BB1153-E37F-4F06-8289-C4388B966F5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {95BB1153-E37F-4F06-8289-C4388B966F5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {95BB1153-E37F-4F06-8289-C4388B966F5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {95BB1153-E37F-4F06-8289-C4388B966F5B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {740D0F39-3D9D-4758-B35A-11F1F9513A0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {740D0F39-3D9D-4758-B35A-11F1F9513A0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {740D0F39-3D9D-4758-B35A-11F1F9513A0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {740D0F39-3D9D-4758-B35A-11F1F9513A0A}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {41FD12F4-B3E2-45F2-98E6-BE4B1EB38DFA}
+ EndGlobalSection
+EndGlobal
diff --git a/Aucma.Scada.Api/Aucma.Scada.Api.csproj b/Aucma.Scada.Api/Aucma.Scada.Api.csproj
new file mode 100644
index 0000000..72b05ab
--- /dev/null
+++ b/Aucma.Scada.Api/Aucma.Scada.Api.csproj
@@ -0,0 +1,22 @@
+
+
+
+ net6.0
+ enable
+ enable
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Aucma.Scada.Api/Controllers/ElectricalinspectionController.cs b/Aucma.Scada.Api/Controllers/ElectricalinspectionController.cs
new file mode 100644
index 0000000..a965d5e
--- /dev/null
+++ b/Aucma.Scada.Api/Controllers/ElectricalinspectionController.cs
@@ -0,0 +1,97 @@
+using Aucma.Scada.Api.Common;
+using Aucma.Scada.Api.Config;
+using Aucma.Scada.Api.Model;
+using Aucma.Scada.Api.Repository.service;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+
+namespace Aucma.Scada.Api.Controllers
+{
+ ///
+ /// 电检数据接口
+ ///
+ [ApiController]
+ [Route("[controller]")]
+ public class ElectricalinspectionController : ControllerBase
+ {
+ private readonly ILogger _logger;
+
+ private IRecordElectricalinspectionService _recordElectricalinspectionService;
+
+ private IDetailElectricalinspectionService _detailElectricalinspectionService;
+
+ private JsonChange _jsonChange;
+
+ public ElectricalinspectionController(ILogger logger, IRecordElectricalinspectionService recordElectricalinspectionService, IDetailElectricalinspectionService detailElectricalinspectionService, JsonChange jsonChange)
+ {
+ _logger = logger;
+ _recordElectricalinspectionService = recordElectricalinspectionService;
+ _detailElectricalinspectionService = detailElectricalinspectionService;
+ _jsonChange = jsonChange;
+ }
+
+ ///
+ /// 保存电检数据
+ ///
+ ///
+ ///
+ [HttpPost]
+ public IActionResult save([FromBody]RecordElectricalinspection electricalinspection)
+ {
+ _logger.LogInformation($"收到电检数据:{_jsonChange.ModeToJson(electricalinspection)}");
+
+ if (electricalinspection == null)
+ {
+ return BadRequest();
+ }
+
+ try
+ {
+ electricalinspection.Recordtime = DateTime.Now;
+
+ var testDataStr = electricalinspection.Testdata;
+
+ electricalinspection.Testdata = System.Guid.NewGuid().ToString();
+
+ #region 解析TestData
+ string[] str = testDataStr.ToString().Split(";");
+
+ List detailElectricalinspections = new List();
+ foreach (string item in str)
+ {
+ if (!string.IsNullOrEmpty(item))
+ {
+ string[] items = item.Split("|");
+
+ if (items.Length == 5)
+ {
+ DetailElectricalinspection detailElectricalinspection = new DetailElectricalinspection();
+ detailElectricalinspection.Uuid = electricalinspection.Testdata;
+ detailElectricalinspection.Serialnumber = Convert.ToDecimal(items[0]);
+ detailElectricalinspection.Projectname = items[1].ToString();
+ detailElectricalinspection.Testcondition = items[2].ToString();
+ detailElectricalinspection.Testvalue = items[3].ToString();
+ detailElectricalinspection.Testresult = items[4].ToString();
+ detailElectricalinspection.Recordtime = DateTime.Now;
+ detailElectricalinspections.Add(detailElectricalinspection);
+ }
+ }
+ }
+ #endregion
+
+ _logger.LogInformation($"电检明细解析完成:{_jsonChange.ModeToJson(detailElectricalinspections)}");
+
+ _recordElectricalinspectionService.InsertRecordElectricalinspection(electricalinspection);
+
+ _detailElectricalinspectionService.InsertRangeDetailElectricalinspection(detailElectricalinspections);
+
+ }
+ catch(Exception ex)
+ {
+ _logger.LogError($"电检数据处理异常:{ex.Message}");
+ }
+
+ return Ok();
+ }
+ }
+}
diff --git a/Aucma.Scada.Api/Program.cs b/Aucma.Scada.Api/Program.cs
new file mode 100644
index 0000000..b3e3f02
--- /dev/null
+++ b/Aucma.Scada.Api/Program.cs
@@ -0,0 +1,23 @@
+using Aucma.Scada.Api.Config;
+using Serilog.Events;
+using Serilog;
+using Microsoft.AspNetCore.Hosting;
+
+namespace Aucma.Scada.Api
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateHostBuilder(args).Build().Run();
+ }
+
+ public static IHostBuilder CreateHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .UseSerilog()
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup();
+ });
+ }
+}
\ No newline at end of file
diff --git a/Aucma.Scada.Api/Properties/launchSettings.json b/Aucma.Scada.Api/Properties/launchSettings.json
new file mode 100644
index 0000000..5a3838c
--- /dev/null
+++ b/Aucma.Scada.Api/Properties/launchSettings.json
@@ -0,0 +1,31 @@
+{
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:32147",
+ "sslPort": 44302
+ }
+ },
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ //"launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "Aucma.Scada.Api": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ //"launchUrl": "swagger",
+ "applicationUrl": "http://localhost:5000",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
+
diff --git a/Aucma.Scada.Api/StartUp.cs b/Aucma.Scada.Api/StartUp.cs
new file mode 100644
index 0000000..42cf919
--- /dev/null
+++ b/Aucma.Scada.Api/StartUp.cs
@@ -0,0 +1,113 @@
+using Aucma.Scada.Api.Config;
+using Microsoft.Extensions.Configuration;
+using Microsoft.OpenApi.Models;
+using Serilog.Events;
+using Serilog;
+using System.Runtime.Serialization;
+using Aucma.Scada.Api.Repository;
+using Aucma.Scada.Api.Common;
+
+namespace Aucma.Scada.Api
+{
+ public class StartUp
+ {
+ public IConfiguration Configuration { get; }
+
+ public StartUp(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddControllers();
+
+ //配置Swagger
+ services.AddSwaggerGen(swagger =>
+ {
+ //自定义接口信息
+ swagger.SwaggerDoc("V1.0", new OpenApiInfo
+ {
+ Title = "MES Web Api",
+ Version = "V1.0",
+ Description = $"API版本V1.0",
+ Contact = new OpenApiContact
+ {
+ Name = "MES Web Api",
+ Email = "wenjy@mesnac.com"
+ }
+ });
+
+ //自定义实体别名
+ swagger.CustomSchemaIds(type => type.GetCustomAttributes(typeof(DataContractAttribute), true)
+ .Cast()
+ .FirstOrDefault()?.Name);
+
+ //配置Action名称
+ var path = Path.Combine(AppContext.BaseDirectory, "Aucma.Scada.Api.xml");
+ swagger.IncludeXmlComments(path, true); // true : 显示控制器层注释
+ swagger.OrderActionsBy(o => o.RelativePath); // 对action的名称进行排序,如果有多个,就可以看见效果了。
+ });
+
+ //注册配置类
+ services.AddSingleton(provider =>
+ {
+ var configuration = provider.GetService();
+ return configuration.GetSection("AppConfig").Get();
+ });
+
+ services.AddSingleton();
+
+ //注册SqlSugar
+ services.AddSqlSugarSetup();
+
+ //注册Repository、Service
+ services.AddServices();
+ }
+
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+
+ //启用Swagger中间件
+ app.UseSwagger();
+ app.UseSwaggerUI(c =>
+ {
+ c.SwaggerEndpoint("/swagger/V1.0/swagger.json", "MES Web Api V1.0");
+ c.RoutePrefix = "";
+ });
+
+ //启用Serilog中间件
+ app.UseSerilogRequestLogging();
+
+ #region 通过配置文件读取日志存放位置
+ var appConfig = app.ApplicationServices.GetService();
+ var logPath = $"{appConfig.logPath}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/";
+ #endregion
+
+ Log.Logger = new LoggerConfiguration().MinimumLevel.Information().WriteTo.Console()
+ .WriteTo.File(Path.Combine(logPath, "Info.log"), LogEventLevel.Information, fileSizeLimitBytes: 5 * 1024)
+ .WriteTo.File(Path.Combine(logPath, "Error.log"), LogEventLevel.Error, fileSizeLimitBytes: 5 * 1024)
+ .WriteTo.File(Path.Combine(logPath, "Warn.log"), LogEventLevel.Warning, fileSizeLimitBytes: 5 * 1024)
+ .WriteTo.File(Path.Combine(logPath, "Trace.log"), LogEventLevel.Verbose, fileSizeLimitBytes: 5 * 1024)
+ .CreateLogger();
+
+ //app.UseHttpsRedirection();
+
+ app.UseRouting();
+
+ app.UseAuthorization();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllers();
+ });
+
+ Log.Information($"项目初始化完成,日志存放路径:{appConfig.logPath}");
+
+ }
+ }
+}
diff --git a/Aucma.Scada.Api/appsettings.Development.json b/Aucma.Scada.Api/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/Aucma.Scada.Api/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/Aucma.Scada.Api/appsettings.json b/Aucma.Scada.Api/appsettings.json
new file mode 100644
index 0000000..dca8f9e
--- /dev/null
+++ b/Aucma.Scada.Api/appsettings.json
@@ -0,0 +1,14 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+ "AppConfig": {
+ "logPath": "E:\\桌面\\澳柯玛MES项目\\日志信息",
+ "mesConnStr": "server=.;uid=sa;pwd=123456;database=JiangYinMENS",
+ "mcsConnStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma"
+ }
+}