1、报表2、基础库导入集团
This commit is contained in:
parent
2dfd13bafc
commit
e9eb296832
@ -6,6 +6,7 @@ using APT.MS.Domain.Enums.SK;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace APT.MS.Domain.Entities.SK
|
namespace APT.MS.Domain.Entities.SK
|
||||||
@ -27,6 +28,7 @@ namespace APT.MS.Domain.Entities.SK
|
|||||||
[DataFieldForeignKey("Nav_ProductionUnit")]
|
[DataFieldForeignKey("Nav_ProductionUnit")]
|
||||||
public Guid? PRODUCTION_UNIT_ID { get; set; }
|
public Guid? PRODUCTION_UNIT_ID { get; set; }
|
||||||
[Description("导航属性:生产单元")]
|
[Description("导航属性:生产单元")]
|
||||||
|
[NotMapped]
|
||||||
public T_FM_USER_PRODUCTION_UNIT_SET Nav_ProductionUnit { get; set; }
|
public T_FM_USER_PRODUCTION_UNIT_SET Nav_ProductionUnit { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 辨识区域
|
/// 辨识区域
|
||||||
@ -40,6 +42,7 @@ namespace APT.MS.Domain.Entities.SK
|
|||||||
/// 导航属性:辨识区域
|
/// 导航属性:辨识区域
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("导航属性:辨识区域")]
|
[Description("导航属性:辨识区域")]
|
||||||
|
[NotMapped]
|
||||||
public T_SK_RISK_AREA Nav_Area { get; set; }
|
public T_SK_RISK_AREA Nav_Area { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 风险名称
|
/// 风险名称
|
||||||
@ -64,6 +67,7 @@ namespace APT.MS.Domain.Entities.SK
|
|||||||
/// 导航属性:风险类别
|
/// 导航属性:风险类别
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("导航属性:风险类别")]
|
[Description("导航属性:风险类别")]
|
||||||
|
[NotMapped]
|
||||||
public T_SK_RISK_TYPE Nav_Type { get; set; }
|
public T_SK_RISK_TYPE Nav_Type { get; set; }
|
||||||
|
|
||||||
[Description("风险评价L")]
|
[Description("风险评价L")]
|
||||||
@ -105,12 +109,14 @@ namespace APT.MS.Domain.Entities.SK
|
|||||||
public Guid? RISK_NAME_ID { get; set; }
|
public Guid? RISK_NAME_ID { get; set; }
|
||||||
|
|
||||||
[Description("导航属性:风险名称")]
|
[Description("导航属性:风险名称")]
|
||||||
|
[NotMapped]
|
||||||
public T_SK_RISK_NAME Nav_RiskName { get; set; }
|
public T_SK_RISK_NAME Nav_RiskName { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导航属性:管控措施
|
/// 导航属性:管控措施
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("管控措施")]
|
[Description("管控措施")]
|
||||||
[FormFieldEdit]
|
[FormFieldEdit]
|
||||||
|
[NotMapped]
|
||||||
public ICollection<T_SK_BASIC_LIBRARY_DETAIL> Nav_Details { get; set; }
|
public ICollection<T_SK_BASIC_LIBRARY_DETAIL> Nav_Details { get; set; }
|
||||||
|
|
||||||
[Description("是否有效")]
|
[Description("是否有效")]
|
||||||
@ -128,29 +134,37 @@ namespace APT.MS.Domain.Entities.SK
|
|||||||
|
|
||||||
[Description("是否同步企业库")]
|
[Description("是否同步企业库")]
|
||||||
[DataFieldIngore]
|
[DataFieldIngore]
|
||||||
|
[NotMapped]
|
||||||
public string PUBLISH { get; set; }
|
public string PUBLISH { get; set; }
|
||||||
|
|
||||||
[Description("管控措施")]
|
[Description("管控措施")]
|
||||||
[DataFieldIngore]
|
[DataFieldIngore]
|
||||||
|
[NotMapped]
|
||||||
public string MEASURE { get; set; }
|
public string MEASURE { get; set; }
|
||||||
|
|
||||||
[Description("检查内容")]
|
[Description("检查内容")]
|
||||||
[DataFieldIngore]
|
[DataFieldIngore]
|
||||||
|
[NotMapped]
|
||||||
public string CHECKCONTENTS { get; set; }
|
public string CHECKCONTENTS { get; set; }
|
||||||
[Description("检查依据")]
|
[Description("检查依据")]
|
||||||
[DataFieldIngore]
|
[DataFieldIngore]
|
||||||
|
[NotMapped]
|
||||||
public string CHECKBASICS { get; set; }
|
public string CHECKBASICS { get; set; }
|
||||||
[Description("检查标准")]
|
[Description("检查标准")]
|
||||||
[DataFieldIngore]
|
[DataFieldIngore]
|
||||||
|
[NotMapped]
|
||||||
public string CHECKSTANDARDS { get; set; }
|
public string CHECKSTANDARDS { get; set; }
|
||||||
[Description("隐患描述")]
|
[Description("隐患描述")]
|
||||||
[DataFieldIngore]
|
[DataFieldIngore]
|
||||||
|
[NotMapped]
|
||||||
public string HIDDENSCRIPTION { get; set; }
|
public string HIDDENSCRIPTION { get; set; }
|
||||||
[Description("隐患等级")]
|
[Description("隐患等级")]
|
||||||
[DataFieldIngore]
|
[DataFieldIngore]
|
||||||
|
[NotMapped]
|
||||||
public string HIDDENLEVEL { get; set; }
|
public string HIDDENLEVEL { get; set; }
|
||||||
[Description("整改措施")]
|
[Description("整改措施")]
|
||||||
[DataFieldIngore]
|
[DataFieldIngore]
|
||||||
|
[NotMapped]
|
||||||
public string RECIFYMEASURE { get; set; }
|
public string RECIFYMEASURE { get; set; }
|
||||||
[Description("分值L")]
|
[Description("分值L")]
|
||||||
[DataFieldForeignKey("Nav_SCOREL")]
|
[DataFieldForeignKey("Nav_SCOREL")]
|
||||||
@ -158,6 +172,7 @@ namespace APT.MS.Domain.Entities.SK
|
|||||||
public Guid? SCOREL_ID { get; set; }
|
public Guid? SCOREL_ID { get; set; }
|
||||||
|
|
||||||
[Description("导航属性:分值L")]
|
[Description("导航属性:分值L")]
|
||||||
|
[NotMapped]
|
||||||
public T_SK_SCOREL Nav_SCOREL { get; set; }
|
public T_SK_SCOREL Nav_SCOREL { get; set; }
|
||||||
|
|
||||||
[Description("分值E")]
|
[Description("分值E")]
|
||||||
@ -166,6 +181,7 @@ namespace APT.MS.Domain.Entities.SK
|
|||||||
public Guid? SCOREE_ID { get; set; }
|
public Guid? SCOREE_ID { get; set; }
|
||||||
|
|
||||||
[Description("导航属性:分值E")]
|
[Description("导航属性:分值E")]
|
||||||
|
[NotMapped]
|
||||||
public T_SK_SCOREE Nav_SCOREE { get; set; }
|
public T_SK_SCOREE Nav_SCOREE { get; set; }
|
||||||
|
|
||||||
[Description("分值C")]
|
[Description("分值C")]
|
||||||
@ -174,6 +190,7 @@ namespace APT.MS.Domain.Entities.SK
|
|||||||
public Guid? SCOREC_ID { get; set; }
|
public Guid? SCOREC_ID { get; set; }
|
||||||
|
|
||||||
[Description("导航属性:分值C")]
|
[Description("导航属性:分值C")]
|
||||||
|
[NotMapped]
|
||||||
public T_SK_SCOREC Nav_SCOREC { get; set; }
|
public T_SK_SCOREC Nav_SCOREC { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11230,6 +11230,10 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
|||||||
USER_NAME = item["USER_NAME"] != null ? item["USER_NAME"].ToString() : null
|
USER_NAME = item["USER_NAME"] != null ? item["USER_NAME"].ToString() : null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrEmpty(filter.Keyword))
|
||||||
|
{
|
||||||
|
listAddNew = listAddNew.Where(t => t.COMPANY_NAME == filter.Keyword).ToList();
|
||||||
|
}
|
||||||
var taskGroup = listAddNew.GroupBy(t => new { t.COMPANY_NAME, t.MOULD_NAME, t.FORM_NAME }).ToList();
|
var taskGroup = listAddNew.GroupBy(t => new { t.COMPANY_NAME, t.MOULD_NAME, t.FORM_NAME }).ToList();
|
||||||
if (taskGroup != null && taskGroup.Any())
|
if (taskGroup != null && taskGroup.Any())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,12 +3,14 @@ using APT.BaseData.Domain.IServices.BD;
|
|||||||
using APT.BaseData.Domain.IServices.BS;
|
using APT.BaseData.Domain.IServices.BS;
|
||||||
using APT.BaseData.Domain.IServices.EX;
|
using APT.BaseData.Domain.IServices.EX;
|
||||||
using APT.BaseData.Domain.IServices.FM;
|
using APT.BaseData.Domain.IServices.FM;
|
||||||
|
using APT.BaseData.Domain.IServices.OP;
|
||||||
using APT.BaseData.Domain.IServices.Platform;
|
using APT.BaseData.Domain.IServices.Platform;
|
||||||
using APT.BaseData.Services.DomainServices;
|
using APT.BaseData.Services.DomainServices;
|
||||||
using APT.BaseData.Services.Services.BD;
|
using APT.BaseData.Services.Services.BD;
|
||||||
using APT.BaseData.Services.Services.BS;
|
using APT.BaseData.Services.Services.BS;
|
||||||
using APT.BaseData.Services.Services.EX;
|
using APT.BaseData.Services.Services.EX;
|
||||||
using APT.BaseData.Services.Services.FM;
|
using APT.BaseData.Services.Services.FM;
|
||||||
|
using APT.BaseData.Services.Services.OP;
|
||||||
using APT.BaseData.Services.Services.Platform;
|
using APT.BaseData.Services.Services.Platform;
|
||||||
using APT.BaseData.Services.Sys;
|
using APT.BaseData.Services.Sys;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
@ -57,6 +59,7 @@ namespace APT.SK.WebApi.App_Start
|
|||||||
builder.RegisterType<ExtConnConfigService>().As<IExtConnConfigService>().InstancePerLifetimeScope();
|
builder.RegisterType<ExtConnConfigService>().As<IExtConnConfigService>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<FMNotificationTaskService>().As<IFMNotificationTaskService>().InstancePerLifetimeScope();
|
builder.RegisterType<FMNotificationTaskService>().As<IFMNotificationTaskService>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<BSSafeCheckService>().As<IBSSafeCheckService>().InstancePerLifetimeScope();
|
builder.RegisterType<BSSafeCheckService>().As<IBSSafeCheckService>().InstancePerLifetimeScope();
|
||||||
|
builder.RegisterType<OPTenantDBConnService>().As<IOPTenantDBConnService>().InstancePerLifetimeScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,31 @@
|
|||||||
using APT.BaseData.Domain.Entities.FM;
|
using APT.BaseData.Domain.ApiModel;
|
||||||
using APT.BaseData.Domain.Entities;
|
using APT.BaseData.Domain.Entities;
|
||||||
|
using APT.BaseData.Domain.Entities.FM;
|
||||||
using APT.BaseData.Domain.Enums;
|
using APT.BaseData.Domain.Enums;
|
||||||
|
using APT.BaseData.Domain.Enums.PF;
|
||||||
|
using APT.BaseData.Domain.IServices.OP;
|
||||||
|
using APT.BaseData.Services.DomainServices;
|
||||||
using APT.BaseData.Services.Services.FM;
|
using APT.BaseData.Services.Services.FM;
|
||||||
|
using APT.BaseData.Services.Services.OP;
|
||||||
|
using APT.Infrastructure.Api;
|
||||||
using APT.Infrastructure.Core;
|
using APT.Infrastructure.Core;
|
||||||
using APT.MS.Domain.Entities.FO;
|
using APT.MS.Domain.Entities.FO;
|
||||||
using APT.MS.Domain.Entities.SK;
|
using APT.MS.Domain.Entities.SK;
|
||||||
using APT.MS.Domain.Enums;
|
using APT.MS.Domain.Enums;
|
||||||
|
using APT.MS.Domain.Enums.SK;
|
||||||
|
using APT.SK.WebApi.Controllers.Api;
|
||||||
using APT.Utility;
|
using APT.Utility;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using APT.BaseData.Domain.Enums.PF;
|
using Microsoft.Data.SqlClient;
|
||||||
using APT.BaseData.Services.DomainServices;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
using MySqlX.XDevAPI.Common;
|
using MySqlX.XDevAPI.Common;
|
||||||
using System.Security.Policy;
|
using NPOI.SS.Formula.PTG;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System;
|
using System;
|
||||||
using APT.MS.Domain.Enums.SK;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Policy;
|
||||||
|
|
||||||
namespace APT.SK.WebApi.Controllers
|
namespace APT.SK.WebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -25,6 +35,11 @@ namespace APT.SK.WebApi.Controllers
|
|||||||
[Route("api/SK/SKBasicLibrary")]
|
[Route("api/SK/SKBasicLibrary")]
|
||||||
public partial class BasicLibraryController : AuthorizeApiController<T_SK_BASIC_LIBRARY>
|
public partial class BasicLibraryController : AuthorizeApiController<T_SK_BASIC_LIBRARY>
|
||||||
{
|
{
|
||||||
|
IOPTenantDBConnService OPTenantDBConnService { get; set; }
|
||||||
|
public BasicLibraryController(IOPTenantDBConnService opTenantDBConnService)
|
||||||
|
{
|
||||||
|
OPTenantDBConnService = opTenantDBConnService;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存
|
/// 保存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -565,5 +580,242 @@ namespace APT.SK.WebApi.Controllers
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取集团基础库
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filter">过滤实体</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
[HttpPost, Route("JTOrderEntities")]
|
||||||
|
public JsonActionResult<IEnumerable<T_SK_BASIC_LIBRARY>> JTOrderEntities([FromBody] KeywordFilter filter)
|
||||||
|
{
|
||||||
|
var result = new JsonActionResult<IEnumerable<T_SK_BASIC_LIBRARY>>();
|
||||||
|
string strConn = OPTenantDBConnService.GetConnByORGID(filter.OrgId.Value);
|
||||||
|
string name = "mh_jy_head";
|
||||||
|
if (!string.IsNullOrEmpty(strConn))
|
||||||
|
{
|
||||||
|
// 找左边字符串结束位置
|
||||||
|
int start = strConn.IndexOf("Database=");
|
||||||
|
if (start != -1) {
|
||||||
|
start += "Database=".Length;
|
||||||
|
}
|
||||||
|
// 找右边字符串开始位置
|
||||||
|
int end = strConn.IndexOf(";uid", start);
|
||||||
|
if (end != -1)
|
||||||
|
{
|
||||||
|
// 截取中间
|
||||||
|
name = strConn.Substring(start, end - start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 2. 传入构造函数
|
||||||
|
using var db = new CrossDbContext(strConn);
|
||||||
|
|
||||||
|
// 3. 要跨哪些库?自己定义,指定总部
|
||||||
|
var dbNames = new List<string>();
|
||||||
|
//{
|
||||||
|
// "mh_jy_head",
|
||||||
|
//};
|
||||||
|
dbNames.Add(name);
|
||||||
|
result.Data = db.QueryCrossDatabases(dbNames).ToList();
|
||||||
|
//DataTable library = new DataTable();
|
||||||
|
//using (SqlConnection connection = new SqlConnection(strConn))
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// connection.Open();
|
||||||
|
// //风险等级占比
|
||||||
|
// string sqlRisk = "select * from T_SK_BASIC_LIBRARY ";
|
||||||
|
// SqlCommand comRisk = new SqlCommand(sqlRisk, connection);
|
||||||
|
// SqlDataAdapter riskData = new SqlDataAdapter(comRisk);
|
||||||
|
// riskData.Fill(library);
|
||||||
|
// connection.Close();
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||||
|
// throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||||
|
// else
|
||||||
|
// throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (result != null && result.Data != null)
|
||||||
|
{
|
||||||
|
if (result.Data != null && result.Data.Any())
|
||||||
|
{
|
||||||
|
foreach (var item in result.Data)
|
||||||
|
{
|
||||||
|
var detailStr = new List<string>();
|
||||||
|
var contentStr = new List<string>();
|
||||||
|
var basicStr = new List<string>();
|
||||||
|
var standardStr = new List<string>();
|
||||||
|
var scripStr = new List<string>();
|
||||||
|
var levelStr = new List<string>();
|
||||||
|
var measureStr = new List<string>();
|
||||||
|
if (item.Nav_Details != null && item.Nav_Details.Any())
|
||||||
|
{
|
||||||
|
foreach (var item2 in item.Nav_Details.OrderBy(t => t.NUM))
|
||||||
|
{
|
||||||
|
//var i = 1;
|
||||||
|
if (item2 != null && !string.IsNullOrEmpty(item2.MEASURES_NAME))
|
||||||
|
{
|
||||||
|
detailStr.Add(item2.MEASURES_NAME);
|
||||||
|
var temp = item2.NUM + "、" + item2.MEASURES_NAME + Environment.NewLine;
|
||||||
|
item.MINE_NAME = item.MINE_NAME + temp;
|
||||||
|
item.MEASURE = item.MEASURE + temp;
|
||||||
|
//i++;
|
||||||
|
}
|
||||||
|
if (item2 != null && item2.Nav_DetailContents != null && item2.Nav_DetailContents.Any())
|
||||||
|
{
|
||||||
|
foreach (var item3 in item2.Nav_DetailContents.OrderBy(t => t.NUM))
|
||||||
|
{
|
||||||
|
if (item3 != null)
|
||||||
|
{
|
||||||
|
if (item3.Nav_Contents != null && !string.IsNullOrEmpty(item3.Nav_Contents.CHECKCONTENT))
|
||||||
|
{
|
||||||
|
contentStr.Add(item3.Nav_Contents.CHECKCONTENT);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(item3.CHECK_STANDARD))
|
||||||
|
{
|
||||||
|
standardStr.Add(item3.CHECK_STANDARD);
|
||||||
|
}
|
||||||
|
if (item3.Nav_DetailBasics != null && item3.Nav_DetailBasics.Any())
|
||||||
|
{
|
||||||
|
foreach (var item4 in item3.Nav_DetailBasics)
|
||||||
|
{
|
||||||
|
if (item4 != null && item4.Nav_Law != null && !string.IsNullOrEmpty(item4.Nav_Law.NAME))
|
||||||
|
{
|
||||||
|
basicStr.Add(item4.Nav_Law.NAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item3.Nav_DetailHiddens != null && item3.Nav_DetailHiddens.Any())
|
||||||
|
{
|
||||||
|
foreach (var item4 in item3.Nav_DetailHiddens.OrderBy(t => t.NUM))
|
||||||
|
{
|
||||||
|
if (item4 != null)
|
||||||
|
{
|
||||||
|
if (item4.Nav_Question != null && !string.IsNullOrEmpty(item4.Nav_Question.DESCREPTION))
|
||||||
|
{
|
||||||
|
scripStr.Add(item4.Nav_Question.DESCREPTION);
|
||||||
|
}
|
||||||
|
levelStr.Add(item4.HIDDEN_LEVEL.GetDescription());
|
||||||
|
if (!string.IsNullOrEmpty(item4.RECTIFICATION_MEASURES))
|
||||||
|
{
|
||||||
|
measureStr.Add(item4.RECTIFICATION_MEASURES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if (detailStr.Any())
|
||||||
|
//{
|
||||||
|
// detailStr = detailStr.Distinct().ToList();
|
||||||
|
// var i = 1;
|
||||||
|
// foreach (var item2 in detailStr)
|
||||||
|
// {
|
||||||
|
// if (!string.IsNullOrEmpty(item2))
|
||||||
|
// {
|
||||||
|
// var temp = i + "、" + item2 + "\r\n";
|
||||||
|
// item.MEASURE = item.MEASURE + temp;
|
||||||
|
// i++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
if (contentStr.Any())
|
||||||
|
{
|
||||||
|
contentStr = contentStr.Distinct().ToList();
|
||||||
|
var i = 1;
|
||||||
|
foreach (var item2 in contentStr)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item2))
|
||||||
|
{
|
||||||
|
var temp = i + "、" + item2 + "\r\n";
|
||||||
|
item.CHECKCONTENTS = item.CHECKCONTENTS + temp;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (basicStr.Any())
|
||||||
|
{
|
||||||
|
basicStr = basicStr.Distinct().ToList();
|
||||||
|
var i = 1;
|
||||||
|
foreach (var item2 in basicStr)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item2))
|
||||||
|
{
|
||||||
|
var temp = i + "、" + item2 + "\r\n";
|
||||||
|
item.CHECKBASICS = item.CHECKBASICS + temp;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (standardStr.Any())
|
||||||
|
{
|
||||||
|
standardStr = standardStr.Distinct().ToList();
|
||||||
|
var i = 1;
|
||||||
|
foreach (var item2 in standardStr)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item2))
|
||||||
|
{
|
||||||
|
var temp = i + "、" + item2 + "\r\n";
|
||||||
|
item.CHECKSTANDARDS = item.CHECKSTANDARDS + temp;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scripStr.Any())
|
||||||
|
{
|
||||||
|
scripStr = scripStr.Distinct().ToList();
|
||||||
|
var i = 1;
|
||||||
|
foreach (var item2 in scripStr)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item2))
|
||||||
|
{
|
||||||
|
var temp = i + "、" + item2 + "\r\n";
|
||||||
|
item.HIDDENSCRIPTION = item.HIDDENSCRIPTION + temp;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (levelStr.Any())
|
||||||
|
{
|
||||||
|
levelStr = levelStr.Distinct().ToList();
|
||||||
|
var i = 1;
|
||||||
|
foreach (var item2 in levelStr)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item2))
|
||||||
|
{
|
||||||
|
var temp = i + "、" + item2 + "\r\n";
|
||||||
|
item.HIDDENLEVEL = item.HIDDENLEVEL + temp;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (measureStr.Any())
|
||||||
|
{
|
||||||
|
measureStr = measureStr.Distinct().ToList();
|
||||||
|
var i = 1;
|
||||||
|
foreach (var item2 in measureStr)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item2))
|
||||||
|
{
|
||||||
|
var temp = i + "、" + item2 + "\r\n";
|
||||||
|
item.RECIFYMEASURE = item.RECIFYMEASURE + temp;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Data.OrderBy(t => t.AREA_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
73
APT.MicroApi/APT.SK.WebApi/Controllers/Api/CrossDbContext.cs
Normal file
73
APT.MicroApi/APT.SK.WebApi/Controllers/Api/CrossDbContext.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
using APT.BaseData.Domain.ApiModel;
|
||||||
|
using APT.BaseData.Domain.ApiModel.PF;
|
||||||
|
using APT.BaseData.Domain.Entities.FM;
|
||||||
|
using APT.BaseData.Domain.IServices.OP;
|
||||||
|
using APT.MS.Domain.Entities.SK;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace APT.SK.WebApi.Controllers.Api
|
||||||
|
{
|
||||||
|
public class CrossDbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<T_SK_BASIC_LIBRARY> T_SK_BASIC_LIBRARY { get; set; }
|
||||||
|
// 动态连接字符串(外部传入)
|
||||||
|
private readonly string _connString;
|
||||||
|
|
||||||
|
// 构造函数:动态接收连接字符串
|
||||||
|
public CrossDbContext(string connString)
|
||||||
|
{
|
||||||
|
_connString = connString;
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
// 使用动态的连接字符串
|
||||||
|
optionsBuilder.UseSqlServer(_connString);
|
||||||
|
}
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
// 必须把你的实体配置进去,EF才认识它
|
||||||
|
modelBuilder.Entity<T_SK_BASIC_LIBRARY>()
|
||||||
|
.Ignore(x => x.Nav_Org)
|
||||||
|
.Ignore(x => x.DbConn)
|
||||||
|
.Ignore(x => x.TaskID);
|
||||||
|
//modelBuilder.Entity<OrgRuleDeptCheck>()
|
||||||
|
// .Ignore(x => x.departmentCheckedKeys);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 跨库查询:同服务器,多个库
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="databaseNames">库名列表</param>
|
||||||
|
/// <returns>跨库合并结果</returns>
|
||||||
|
public IQueryable<T_SK_BASIC_LIBRARY> QueryCrossDatabases(List<string> databaseNames)
|
||||||
|
{
|
||||||
|
IQueryable<T_SK_BASIC_LIBRARY>? query = null;
|
||||||
|
|
||||||
|
foreach (var dbName in databaseNames)
|
||||||
|
{
|
||||||
|
// 核心:动态拼接 库名.dbo.表名
|
||||||
|
string sql = $"SELECT * FROM {dbName}.dbo.T_SK_BASIC_LIBRARY";
|
||||||
|
var dbSet = this.Set<T_SK_BASIC_LIBRARY>().FromSqlRaw(sql);
|
||||||
|
query = dbSet;
|
||||||
|
//query = query == null ? dbSet : query.UnionAll(dbSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query ?? Enumerable.Empty<T_SK_BASIC_LIBRARY>().AsQueryable();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 跨库查询:同服务器,多个库,静态数据库连接时直接给库名称
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>跨库合并结果</returns>
|
||||||
|
// ========== 查询方法:直接跨库合并 ==========
|
||||||
|
public IQueryable<T_SK_BASIC_LIBRARY> GetAllUserInfos()
|
||||||
|
{
|
||||||
|
// 查询库B(关键:直接修改表名,同服务器跨库)
|
||||||
|
var dbBUsers = this.Set<T_SK_BASIC_LIBRARY>()
|
||||||
|
.FromSqlRaw("SELECT * FROM mh_jy_head.dbo.T_SK_BASIC_LIBRARY");
|
||||||
|
|
||||||
|
return dbBUsers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user