Compare commits
2 Commits
f1fa2ac664
...
56709e04ff
| Author | SHA1 | Date | |
|---|---|---|---|
| 56709e04ff | |||
| 72a2276c3e |
@ -1,16 +1,23 @@
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.BaseData.Domain.ApiModel.EX;
|
||||
using APT.BaseData.Domain.ApiModel.EX;
|
||||
using APT.BaseData.Domain.Entities;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.BaseData.Domain.Enums;
|
||||
using System.Collections.Generic;
|
||||
using APT.Infrastructure.Api;
|
||||
using APT.Infrastructure.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static APT.BaseData.Domain.ApiModel.SocketInfo;
|
||||
|
||||
namespace APT.BaseData.Domain.IServices.FM
|
||||
{
|
||||
public interface IFMNotificatoinService: ICommonService
|
||||
{
|
||||
/// <summary>
|
||||
/// 发送变更的菜单
|
||||
/// </summary>
|
||||
/// <param name="Menus"></param>
|
||||
/// <param name="userIds"></param>
|
||||
void MenusChangeNotice(List<Guid> userIds,WebSocketClientTypeEnum clientType);
|
||||
/// <summary>
|
||||
/// 发送通知公告
|
||||
/// </summary>
|
||||
|
||||
@ -28,7 +28,7 @@ namespace APT.BaseData.Services.Services.EX
|
||||
/// </summary>
|
||||
/// <param name="clientInfo"></param>
|
||||
/// <returns></returns>
|
||||
public static WebSocketResponseInfo OnOpenWebSocket(WebSocketClientInfo clientInfo)
|
||||
public static WebSocketResponseInfo OnOpenWebSocket(WebSocketClientInfo clientInfo, List<WebSocketClientInfo> WebSocketClientInfos)
|
||||
{
|
||||
Console.WriteLine($"Socket连接:{clientInfo?.UserId}");
|
||||
//clientInfo.WebSocketConnection.Close();
|
||||
@ -90,9 +90,10 @@ namespace APT.BaseData.Services.Services.EX
|
||||
/// websocket 关闭
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
public static void OnCloseWebSocket(Guid userId, WebSocketClientInfo clientInfo)
|
||||
public static void OnCloseWebSocket(Guid userId, WebSocketClientInfo clientInfo, List<WebSocketClientInfo> WebSocketClientInfos)
|
||||
{
|
||||
Console.WriteLine($"Socket连接断开:{userId}");
|
||||
WebSocketClientInfos.Remove(clientInfo);
|
||||
}
|
||||
/// <summary>
|
||||
/// websocket 信息
|
||||
@ -101,7 +102,7 @@ namespace APT.BaseData.Services.Services.EX
|
||||
/// <param name="requestInfo"></param>
|
||||
/// <returns></returns>
|
||||
public static WebSocketResponseInfo OnMessageWebSocket(WebSocketClientInfo clientInfo,
|
||||
WebSocketRequestInfo requestInfo)
|
||||
WebSocketRequestInfo requestInfo, List<WebSocketClientInfo> WebSocketClientInfos)
|
||||
{
|
||||
if (requestInfo != null)
|
||||
{
|
||||
@ -123,14 +124,12 @@ namespace APT.BaseData.Services.Services.EX
|
||||
List<WebSocketClientInfo> ingoreClientInfos = new List<WebSocketClientInfo>();
|
||||
ingoreClientInfos.Add(clientInfo);
|
||||
service.SendAlarmNotification(clientInfoByManu, ingoreClientInfos);
|
||||
|
||||
}
|
||||
break;
|
||||
case "P0001":
|
||||
{
|
||||
BaseFilter baseFilter = new BaseFilter();
|
||||
baseFilter.IgnoreOrgRule = true;
|
||||
baseFilter.IsMultipleDb = true;
|
||||
var commonService = ServiceLocator.Instance.GetService<ICommonService>();
|
||||
WebSocketClientInfos.Add(clientInfo);
|
||||
//var consumeService = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<ISOConsumeChargingOrderService>();
|
||||
//var cueerntInfo = commonService.GetEntity<T_CP_CHARGING_PILE>(x => x.CURRENT_CLIENT_ID == clientInfo.UserId, baseFilter);//当前占用充电桩
|
||||
//if (cueerntInfo != null && cueerntInfo.CURRENT_CLIENT_ID != null)
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using APT.BaseData.Domain.ApiModel.EX;
|
||||
using APT.BaseData.Domain.Entities;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.BaseData.Domain.Enums;
|
||||
using APT.BaseData.Domain.IServices.FM;
|
||||
using APT.Infrastructure.Api;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.Migrations;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -103,7 +105,26 @@ namespace APT.BaseData.Services.Services.FM
|
||||
SendNotification(sendNotificationModel, clientInfos);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送通知公告
|
||||
/// </summary>
|
||||
/// <param name="sendNotificationModel"></param>
|
||||
/// <param name="ingoreClientInfos"></param>
|
||||
public void MenusChangeNotice(List<Guid> userIds,WebSocketClientTypeEnum clientType)
|
||||
{
|
||||
var clientInfos = WebSocketServiceHelper.ClintInfos.Where(t => userIds.Contains(t.UserId.Value) && t.ClientType == clientType).ToList();
|
||||
if (!clientInfos.Any())
|
||||
return;
|
||||
foreach (var u in userIds)
|
||||
{
|
||||
WebSocketServiceHelper.SendToUser(u, new WebSocketResponseInfo()
|
||||
{
|
||||
TypeCode = "MQ02",
|
||||
Data = new SocketData(),
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -149,6 +149,7 @@
|
||||
<ProjectReference Include="..\..\APT.BaseData.Services\APT.BaseData.Services.csproj" />
|
||||
<ProjectReference Include="..\..\APT.Data.Migrations\APT.Data.Migrations.csproj" />
|
||||
<ProjectReference Include="..\..\APT.Utility\APT.Utility.csproj" />
|
||||
<ProjectReference Include="..\APT.PF.WebApi\APT.PF.WebApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -16,6 +16,7 @@ using NPOI.SS.Formula.Functions;
|
||||
using APT.BaseData.Domain.ApiModel.Platform;
|
||||
using System.Dynamic;
|
||||
using APT.BaseData.Domain.Entities.PF;
|
||||
using APT.Infrastructure.Api;
|
||||
|
||||
namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
{
|
||||
@ -468,6 +469,12 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
this.BantchAddEntityNoCommit<T_FM_ROLE_DEPARTMENT>(roleDepartments);
|
||||
});
|
||||
}
|
||||
//通知权限更新
|
||||
var menuFilter = new BaseFilter();
|
||||
menuFilter.SelectField =new string[] { "ID" };
|
||||
var users = this.GetEntities<T_FM_USER>(x => x.Nav_BelongRoles.Any(x => x.BELONG_ROLE_ID == role.ID), menuFilter);
|
||||
var notificationService = ServiceLocator.Instance.GetService<IFMNotificatoinService>();
|
||||
notificationService.MenusChangeNotice(users.Select(x => x.ID).ToList(),WebSocketClientTypeEnum.WEB后台);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,40 +1,40 @@
|
||||
using APT.BaseData.Domain.Msg;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.MS.Domain.ApiModel;
|
||||
using APT.BaseData.Domain.ApiModel;
|
||||
using APT.BaseData.Domain.Entities;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.BaseData.Domain.Entities.OP;
|
||||
using APT.BaseData.Domain.Entities.PF;
|
||||
using APT.BaseData.Domain.Enums;
|
||||
using APT.BaseData.Domain.Enums.PF;
|
||||
using APT.BaseData.Domain.IServices.FM;
|
||||
using APT.BaseData.Domain.IServices.OP;
|
||||
using APT.BaseData.Domain.Msg;
|
||||
using APT.BaseData.Services.Services.FM;
|
||||
using APT.Infrastructure.Api;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.Migrations;
|
||||
using APT.MS.Domain.ApiModel;
|
||||
using APT.MS.Domain.Entities.HM;
|
||||
using APT.MS.Domain.Entities.OG;
|
||||
using APT.MS.Domain.Entities.PF;
|
||||
using APT.MS.Domain.Entities.SC;
|
||||
using APT.MS.Domain.Entities.SC.PT;
|
||||
using APT.MS.Domain.Entities.SC.SC;
|
||||
using APT.MS.Domain.Entities.SE;
|
||||
using APT.MS.Domain.Entities.SK;
|
||||
using APT.MS.Domain.Enums;
|
||||
using APT.Utility;
|
||||
using Castle.Core.Internal;
|
||||
using InfluxData.Net.InfluxDb.Models.Responses;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using MySqlX.XDevAPI.Common;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using APT.Utility;
|
||||
using APT.BaseData.Domain.ApiModel;
|
||||
using System.Linq.Expressions;
|
||||
using APT.BaseData.Domain.Enums;
|
||||
using APT.BaseData.Domain.Entities.PF;
|
||||
using APT.MS.Domain.Entities.HM;
|
||||
using APT.MS.Domain.Entities.PF;
|
||||
using APT.BaseData.Domain.Entities;
|
||||
using APT.BaseData.Services.Services.FM;
|
||||
using MySqlX.XDevAPI.Common;
|
||||
using Castle.Core.Internal;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using APT.MS.Domain.Entities.SE;
|
||||
using APT.MS.Domain.Enums;
|
||||
using APT.BaseData.Domain.Entities.OP;
|
||||
using APT.Migrations;
|
||||
using InfluxData.Net.InfluxDb.Models.Responses;
|
||||
using APT.Infrastructure.Api;
|
||||
using APT.BaseData.Domain.Enums.PF;
|
||||
using APT.MS.Domain.Entities.OG;
|
||||
using APT.MS.Domain.Entities.SC;
|
||||
using APT.MS.Domain.Entities.SC.SC;
|
||||
using System.Security.Cryptography;
|
||||
using APT.MS.Domain.Entities.SC.PT;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using APT.MS.Domain.Entities.SK;
|
||||
using APT.BaseData.Domain.IServices.OP;
|
||||
|
||||
namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
{
|
||||
@ -530,8 +530,9 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
{
|
||||
return SafeExecute<bool>(() =>
|
||||
{
|
||||
var allUsers = this.GetEntities<T_FM_USER>(t => t.IS_DELETED == false, null, "Nav_ApproveRole");
|
||||
var isAdd = allUsers.Where(t => t.ID == entity.ID);
|
||||
//var allUsers = this.GetEntities<T_FM_USER>(t => t.IS_DELETED == false, null, "Nav_ApproveRole");
|
||||
var isAdd = this.GetEntity<T_FM_USER>(entity.ID.ToString(), "Nav_ApproveRole", "Nav_BelongRoles");
|
||||
var dbRuleStr = string.Join(',', isAdd.Nav_BelongRoles.OrderBy(x => x.BELONG_ROLE_ID).Select(x => x.BELONG_ROLE_ID).Distinct().ToList());
|
||||
var userList = new List<T_FM_USER>();
|
||||
entity.CODE = entity.CODE.ToUpper();
|
||||
if (entity.ENTRYTIME == DateTime.Parse("0001/1/1 0:00:00"))
|
||||
@ -558,7 +559,7 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
throw new Exception("岗位不允许为空!");
|
||||
}
|
||||
|
||||
if (!isAdd.Any())
|
||||
if (isAdd == null)
|
||||
{
|
||||
userList = this.GetEntities<T_FM_USER>(t => (t.CODE == entity.CODE || t.APPROVE_ROLE_ID == entity.APPROVE_ROLE_ID) && t.ORG_ID == entity.ORG_ID, null, "Nav_Department").ToList();
|
||||
var isRepeat = userList.FirstOrDefault(t => t.CODE == entity.CODE);
|
||||
@ -690,7 +691,7 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
else
|
||||
{
|
||||
var departInfo = this.GetEntity<T_FM_DEPARTMENT>(entity.DEPARTMENT_ID.ToString());
|
||||
if (departInfo != null && departInfo.PRODUCTION_UNIT_ID != null && departInfo.MineType != null && !isAdd.Any())
|
||||
if (departInfo != null && departInfo.PRODUCTION_UNIT_ID != null && departInfo.MineType != null && isAdd == null)
|
||||
{
|
||||
var enumList = this.GetEntity<T_FM_ENUMS>(t => t.CODE == "BSMineTypeEnum" && t.VALUE == departInfo.MineType);
|
||||
entity.MineType = departInfo.MineType.ToString();
|
||||
@ -1013,7 +1014,7 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
|
||||
#region 总用户库添加
|
||||
|
||||
if (!isAdd.Any())
|
||||
if (isAdd == null)
|
||||
{
|
||||
using (var context = new MigrationContext(ConfigurationManager.ConnectionStrings["default"]))
|
||||
{
|
||||
@ -1150,6 +1151,19 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
//通知权限更新
|
||||
var menuFilter = new BaseFilter();
|
||||
menuFilter.SelectField = new string[] { "ID" };
|
||||
if (isAdd != null)
|
||||
{
|
||||
|
||||
var nowRules = string.Join(',', belongRoles.OrderBy(x => x.BELONG_ROLE_ID).Select(x => x.BELONG_ROLE_ID).Distinct().ToList());
|
||||
if (dbRuleStr.CompareTo(nowRules) != 0)
|
||||
{
|
||||
var notificationService = ServiceLocator.Instance.GetService<IFMNotificatoinService>();
|
||||
notificationService.MenusChangeNotice(new List<Guid>() { isAdd.ID },WebSocketClientTypeEnum.WEB后台);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -31,6 +31,7 @@ using APT.Infrastructure.EF.Extensions;
|
||||
using APT.Infrastructure.Api;
|
||||
using ConfigurationManager = APT.Infrastructure.Api.ConfigurationManager;
|
||||
using APT.WebApi.Models;
|
||||
using APT.PF.WebApi.Utils;
|
||||
|
||||
namespace APT.FM.WebApi
|
||||
{
|
||||
@ -139,8 +140,7 @@ namespace APT.FM.WebApi
|
||||
|
||||
//fMOrganizationService.SetOrgCache();
|
||||
|
||||
|
||||
//APT.FM.WebApi.Utils.WebSokectHelper.Init();
|
||||
APT.PF.WebApi.Utils.WebSokectHelper.Init();
|
||||
}
|
||||
|
||||
public virtual void ConfigureContainer(ContainerBuilder builder)
|
||||
|
||||
@ -1,191 +1,191 @@
|
||||
using APT.Infrastructure.Core;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using APT.Utility;
|
||||
using APT.BaseData.Domain.Entities.LG;
|
||||
using APT.BaseData.Domain.ApiModel.LG;
|
||||
using System;
|
||||
using APT.BaseData.Domain.Enums;
|
||||
using System.Threading.Tasks;
|
||||
using InfluxData.Net.InfluxDb.Models;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using System.Linq;
|
||||
using APT.BaseData.Domain.ApiModel.Platform;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using APT.Infrastructure.Api.Redis;
|
||||
using APT.Infrastructure.Api;
|
||||
namespace APT.LG.WebApi.Controllers.Api
|
||||
{
|
||||
|
||||
#region Oprate-表单操作日志表
|
||||
/// <summary>
|
||||
/// 表单操作日志表
|
||||
/// </summary>
|
||||
[Route("api/LG/LGOperate")]
|
||||
public partial class OprateController : AuthorizeApiController<T_LG_OPRATE>
|
||||
{
|
||||
/// <summary>
|
||||
/// 新增日志
|
||||
/// </summary>
|
||||
/// <param name="filter">新增日志</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Add")]
|
||||
public async Task<JsonActionResult<bool>> Add([FromBody] LgOprateModel model)
|
||||
{
|
||||
//var redisManager = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<RedisManager>();
|
||||
//int num = 0;
|
||||
//if (CsRedisManager.KeyExists(RedisCacheKey.HardWarePVInfo))
|
||||
//using APT.Infrastructure.Core;
|
||||
//using Microsoft.AspNetCore.Mvc;
|
||||
//using System.Collections.Generic;
|
||||
//using APT.Utility;
|
||||
//using APT.BaseData.Domain.Entities.LG;
|
||||
//using APT.BaseData.Domain.ApiModel.LG;
|
||||
//using System;
|
||||
//using APT.BaseData.Domain.Enums;
|
||||
//using System.Threading.Tasks;
|
||||
//using InfluxData.Net.InfluxDb.Models;
|
||||
//using APT.BaseData.Domain.Entities.FM;
|
||||
//using Microsoft.EntityFrameworkCore.Internal;
|
||||
//using System.Linq;
|
||||
//using APT.BaseData.Domain.ApiModel.Platform;
|
||||
//using Microsoft.Extensions.DependencyInjection;
|
||||
//using APT.Infrastructure.Api.Redis;
|
||||
//using APT.Infrastructure.Api;
|
||||
//namespace APT.LG.WebApi.Controllers.Api
|
||||
//{
|
||||
// num = CsRedisManager.StringGet<int>(RedisCacheKey.HardWarePVInfo);
|
||||
//}
|
||||
//num++;
|
||||
//CsRedisManager.StringSet<int>(RedisCacheKey.HardWarePVInfo, num);
|
||||
var isLog = LibUtils.ToBoolean(
|
||||
ConfigurationManager.AppSettings["isSqlLog"]);
|
||||
bool isSuccess = true;
|
||||
if (isLog)
|
||||
{
|
||||
var user = this.GetEntityByRedis<T_FM_USER>(model.UserId, new Guid(model.OrgId));
|
||||
if (user == null)
|
||||
throw new Exception("用户不存在");
|
||||
var dt = DateTime.Now;
|
||||
var points = new Point
|
||||
{
|
||||
Name = dt.Year + dt.Month.PadLeft(2, '0'),
|
||||
Timestamp = dt,
|
||||
Tags = new Dictionary<string, object>()
|
||||
{
|
||||
{ "Id", Guid.NewGuid().ToString()}
|
||||
},
|
||||
Fields = new Dictionary<string, object>()
|
||||
{
|
||||
{ "FormCode", model.FormCode },
|
||||
{ "FormName", model.FormName },
|
||||
{ "BtnCode", model.BtnCode??"" },
|
||||
{ "BtnName", model.BtnName??"" },
|
||||
{ "OrgId", model.OrgId },
|
||||
{ "UserId", model.UserId },
|
||||
{ "UserCode",user.CODE },
|
||||
{ "OperateType",string.IsNullOrEmpty(model.BtnCode)?(int)LGOperateTypeEnum.表单加载:(int)LGOperateTypeEnum.按钮点击 }
|
||||
}
|
||||
};
|
||||
|
||||
var response = await InfluxDbHelper.InfluxDbClient.Client.WriteAsync(points, InfluxDbHelper.InfluxLogDbName);
|
||||
isSuccess = response.Success;
|
||||
}
|
||||
|
||||
return SafeExecute<bool>(() =>
|
||||
{
|
||||
return isSuccess;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("LGOrderPaged")]
|
||||
public async Task<PagedActionResult<LgOprateModel>> LGOrderPaged([FromBody] KeywordPageFilter filters)
|
||||
{
|
||||
var actionResult = new PagedActionResult<LgOprateModel>();
|
||||
string timestr = filters.Parameter1;
|
||||
if (string.IsNullOrEmpty(timestr))
|
||||
{
|
||||
this.ThrowError("120001");
|
||||
}
|
||||
//if (string.IsNullOrEmpty(filters.Parameter2))
|
||||
// #region Oprate-表单操作日志表
|
||||
// /// <summary>
|
||||
// /// 表单操作日志表
|
||||
// /// </summary>
|
||||
// [Route("api/LG/LGOperate")]
|
||||
// public partial class OprateController : AuthorizeApiController<T_LG_OPRATE>
|
||||
// {
|
||||
// this.ThrowError("120002");
|
||||
// /// <summary>
|
||||
// /// 新增日志
|
||||
// /// </summary>
|
||||
// /// <param name="filter">新增日志</param>
|
||||
// /// <returns></returns>
|
||||
// [HttpPost, Route("Add")]
|
||||
// public async Task<JsonActionResult<bool>> Add([FromBody] LgOprateModel model)
|
||||
// {
|
||||
// //var redisManager = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<RedisManager>();
|
||||
// //int num = 0;
|
||||
// //if (CsRedisManager.KeyExists(RedisCacheKey.HardWarePVInfo))
|
||||
// //{
|
||||
// // num = CsRedisManager.StringGet<int>(RedisCacheKey.HardWarePVInfo);
|
||||
// //}
|
||||
// //num++;
|
||||
// //CsRedisManager.StringSet<int>(RedisCacheKey.HardWarePVInfo, num);
|
||||
// var isLog = LibUtils.ToBoolean(
|
||||
// ConfigurationManager.AppSettings["isSqlLog"]);
|
||||
// bool isSuccess = true;
|
||||
// if (isLog)
|
||||
// {
|
||||
// var user = this.GetEntityByRedis<T_FM_USER>(model.UserId, new Guid(model.OrgId));
|
||||
// if (user == null)
|
||||
// throw new Exception("用户不存在");
|
||||
// var dt = DateTime.Now;
|
||||
// var points = new Point
|
||||
// {
|
||||
// Name = dt.Year + dt.Month.PadLeft(2, '0'),
|
||||
// Timestamp = dt,
|
||||
// Tags = new Dictionary<string, object>()
|
||||
// {
|
||||
// { "Id", Guid.NewGuid().ToString()}
|
||||
// },
|
||||
// Fields = new Dictionary<string, object>()
|
||||
// {
|
||||
// { "FormCode", model.FormCode },
|
||||
// { "FormName", model.FormName },
|
||||
// { "BtnCode", model.BtnCode??"" },
|
||||
// { "BtnName", model.BtnName??"" },
|
||||
// { "OrgId", model.OrgId },
|
||||
// { "UserId", model.UserId },
|
||||
// { "UserCode",user.CODE },
|
||||
// { "OperateType",string.IsNullOrEmpty(model.BtnCode)?(int)LGOperateTypeEnum.表单加载:(int)LGOperateTypeEnum.按钮点击 }
|
||||
// }
|
||||
var timeAry = timestr.Split(new char[] { ',' });
|
||||
if (timeAry.Length != 2)
|
||||
this.ThrowError("120001");
|
||||
var dtStart = DateTime.Parse(timeAry[0]);
|
||||
var dtEnd = DateTime.Parse(timeAry[1]);
|
||||
T_FM_USER user = null;
|
||||
if (!string.IsNullOrEmpty(filters.Keyword))
|
||||
{
|
||||
user = this.GetEntity<T_FM_USER>(i => i.NAME == filters.Keyword || i.CODE == filters.Keyword, new BaseFilter(filters.OrgId));
|
||||
if (user == null)
|
||||
return actionResult;
|
||||
}
|
||||
List<string> querys = new List<string>();
|
||||
List<string> queryCounts = new List<string>();
|
||||
for (var x = dtStart; x <= dtEnd; x = x.AddMonths(1))
|
||||
{
|
||||
var tableName = x.Year + x.Month.PadLeft(2, '0');
|
||||
var query = $" FROM \"{tableName}\" WHERE time >= '{dtStart.ToString("yyyy-MM-dd HH:mm:ss")}' and time<='{dtEnd.ToString("yyyy-MM-dd HH:mm:ss")}'";
|
||||
if (user != null)
|
||||
query += $" and UserId='{user.ID.ToString()}'";
|
||||
//表单
|
||||
if (!string.IsNullOrEmpty(filters.Parameter3))
|
||||
{
|
||||
query += $" and FormCode='{filters.Parameter3}'";
|
||||
}
|
||||
var offSet = (filters.PageIndex - 1) * filters.Limit;
|
||||
var querySql = query + $" order by time desc limit {filters.Limit} OFFSET {offSet}";
|
||||
querySql = "SELECT * " + querySql;
|
||||
querys.Add(querySql);
|
||||
var queryCount = "SELECT COUNT(OrgId) " + query;
|
||||
queryCounts.Add(queryCount);
|
||||
}
|
||||
// };
|
||||
|
||||
var response = await InfluxDbHelper.InfluxDbClient.Client.MultiQueryAsync(querys, InfluxDbHelper.InfluxLogDbName);
|
||||
if (!response.Any())
|
||||
return actionResult;
|
||||
//得到Serie集合对象(返回执行多个查询的结果)
|
||||
//取出第一条命令的查询结果,是一个集合
|
||||
List<LgOprateModel> opList = new List<LgOprateModel>();
|
||||
//从集合中取出第一条数据
|
||||
foreach (var list in response)
|
||||
{
|
||||
foreach (var table in list)
|
||||
{
|
||||
foreach (var item in table.Values)
|
||||
{
|
||||
var point = new LgOprateModel
|
||||
{
|
||||
BtnCode = item[1].ToString(),
|
||||
BtnName = item[2].ToString(),
|
||||
FormCode = item[3].ToString(),
|
||||
FormName = item[4].ToString(),
|
||||
ID = item[5].ToString(),
|
||||
OrgId = item[7].ToString(),
|
||||
UserCode = item[8].ToString(),
|
||||
UserId = item[9].ToString(),
|
||||
Datetime = item[0].ToString(),
|
||||
};
|
||||
opList.Add(point);
|
||||
}
|
||||
// // var response = await InfluxDbHelper.InfluxDbClient.Client.WriteAsync(points, InfluxDbHelper.InfluxLogDbName);
|
||||
// //isSuccess = response.Success;
|
||||
// }
|
||||
|
||||
// return SafeExecute<bool>(() =>
|
||||
// {
|
||||
// return isSuccess;
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 查询所有数据
|
||||
// /// </summary>
|
||||
// /// <param name="filter">过滤实体</param>
|
||||
// /// <returns></returns>
|
||||
// [HttpPost, Route("LGOrderPaged")]
|
||||
// public async Task<PagedActionResult<LgOprateModel>> LGOrderPaged([FromBody] KeywordPageFilter filters)
|
||||
// {
|
||||
// var actionResult = new PagedActionResult<LgOprateModel>();
|
||||
// string timestr = filters.Parameter1;
|
||||
// if (string.IsNullOrEmpty(timestr))
|
||||
// {
|
||||
// this.ThrowError("120001");
|
||||
// }
|
||||
// //if (string.IsNullOrEmpty(filters.Parameter2))
|
||||
// //{
|
||||
// // this.ThrowError("120002");
|
||||
// //}
|
||||
// var timeAry = timestr.Split(new char[] { ',' });
|
||||
// if (timeAry.Length != 2)
|
||||
// this.ThrowError("120001");
|
||||
// var dtStart = DateTime.Parse(timeAry[0]);
|
||||
// var dtEnd = DateTime.Parse(timeAry[1]);
|
||||
// T_FM_USER user = null;
|
||||
// if (!string.IsNullOrEmpty(filters.Keyword))
|
||||
// {
|
||||
// user = this.GetEntity<T_FM_USER>(i => i.NAME == filters.Keyword || i.CODE == filters.Keyword, new BaseFilter(filters.OrgId));
|
||||
// if (user == null)
|
||||
// return actionResult;
|
||||
// }
|
||||
// List<string> querys = new List<string>();
|
||||
// List<string> queryCounts = new List<string>();
|
||||
// for (var x = dtStart; x <= dtEnd; x = x.AddMonths(1))
|
||||
// {
|
||||
// var tableName = x.Year + x.Month.PadLeft(2, '0');
|
||||
// var query = $" FROM \"{tableName}\" WHERE time >= '{dtStart.ToString("yyyy-MM-dd HH:mm:ss")}' and time<='{dtEnd.ToString("yyyy-MM-dd HH:mm:ss")}'";
|
||||
// if (user != null)
|
||||
// query += $" and UserId='{user.ID.ToString()}'";
|
||||
// //表单
|
||||
// if (!string.IsNullOrEmpty(filters.Parameter3))
|
||||
// {
|
||||
// query += $" and FormCode='{filters.Parameter3}'";
|
||||
// }
|
||||
// var offSet = (filters.PageIndex - 1) * filters.Limit;
|
||||
// var querySql = query + $" order by time desc limit {filters.Limit} OFFSET {offSet}";
|
||||
// querySql = "SELECT * " + querySql;
|
||||
// querys.Add(querySql);
|
||||
// var queryCount = "SELECT COUNT(OrgId) " + query;
|
||||
// queryCounts.Add(queryCount);
|
||||
// }
|
||||
|
||||
// // var response = await InfluxDbHelper.InfluxDbClient.Client.MultiQueryAsync(querys, InfluxDbHelper.InfluxLogDbName);
|
||||
// if (!response.Any())
|
||||
// return actionResult;
|
||||
// //得到Serie集合对象(返回执行多个查询的结果)
|
||||
// //取出第一条命令的查询结果,是一个集合
|
||||
// List<LgOprateModel> opList = new List<LgOprateModel>();
|
||||
// //从集合中取出第一条数据
|
||||
// foreach (var list in response)
|
||||
// {
|
||||
// foreach (var table in list)
|
||||
// {
|
||||
// foreach (var item in table.Values)
|
||||
// {
|
||||
// var point = new LgOprateModel
|
||||
// {
|
||||
// BtnCode = item[1].ToString(),
|
||||
// BtnName = item[2].ToString(),
|
||||
// FormCode = item[3].ToString(),
|
||||
// FormName = item[4].ToString(),
|
||||
// ID = item[5].ToString(),
|
||||
// OrgId = item[7].ToString(),
|
||||
// UserCode = item[8].ToString(),
|
||||
// UserId = item[9].ToString(),
|
||||
// Datetime = item[0].ToString(),
|
||||
// };
|
||||
// opList.Add(point);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
opList = opList.OrderByDescending(t => t.Datetime).Take(filters.Limit).ToList();
|
||||
actionResult.Data = opList;
|
||||
// }
|
||||
// }
|
||||
// opList = opList.OrderByDescending(t => t.Datetime).Take(filters.Limit).ToList();
|
||||
// actionResult.Data = opList;
|
||||
|
||||
var responseCount = await InfluxDbHelper.InfluxDbClient.Client.MultiQueryAsync(queryCounts, InfluxDbHelper.InfluxLogDbName);
|
||||
var totalCount = 0;
|
||||
foreach (var list in responseCount)
|
||||
{
|
||||
foreach (var table in list)
|
||||
{
|
||||
foreach (var item in table.Values)
|
||||
{
|
||||
totalCount += int.Parse(item[1].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
actionResult.TotalCount = totalCount;
|
||||
// var responseCount = await InfluxDbHelper.InfluxDbClient.Client.MultiQueryAsync(queryCounts, InfluxDbHelper.InfluxLogDbName);
|
||||
// var totalCount = 0;
|
||||
// foreach (var list in responseCount)
|
||||
// {
|
||||
// foreach (var table in list)
|
||||
// {
|
||||
// foreach (var item in table.Values)
|
||||
// {
|
||||
// totalCount += int.Parse(item[1].ToString());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// actionResult.TotalCount = totalCount;
|
||||
|
||||
return actionResult;
|
||||
}
|
||||
// return actionResult;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
// }
|
||||
// #endregion
|
||||
//}
|
||||
|
||||
|
||||
@ -154,13 +154,13 @@ namespace APT.PF.WebApi
|
||||
////fMOrganizationService.SetOrgCache();
|
||||
//CheckLinse();
|
||||
//UpdateDatabase();
|
||||
APT.PF.WebApi.Utils.WebSokectHelper.Init();
|
||||
//APT.PF.WebApi.Utils.WebSokectHelper.Init();
|
||||
}
|
||||
|
||||
public virtual void ConfigureContainer(ContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterComponents();
|
||||
Thread.Sleep(10000);
|
||||
//Thread.Sleep(10000);
|
||||
var dbs = GetAllDbConns();
|
||||
foreach (var db in dbs)
|
||||
{
|
||||
|
||||
@ -4,11 +4,13 @@ using System;
|
||||
using APT.BaseData.Domain.IServices.Platform;
|
||||
using APT.BaseData.Services.Services.EX;
|
||||
using APT.Infrastructure.Api;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace APT.PF.WebApi.Utils
|
||||
{
|
||||
public static class WebSokectHelper
|
||||
{
|
||||
public static List<WebSocketClientInfo> WebSocketClientInfos = new List<WebSocketClientInfo>();
|
||||
public static void Init()
|
||||
{
|
||||
|
||||
@ -21,15 +23,15 @@ namespace APT.PF.WebApi.Utils
|
||||
WebSocketServiceHelper.InitService(webSocketPort,
|
||||
(clientInfo) =>
|
||||
{
|
||||
return WebSocketService.OnOpenWebSocket(clientInfo);
|
||||
return WebSocketService.OnOpenWebSocket(clientInfo, WebSocketClientInfos);
|
||||
},
|
||||
(clientInfo, requestInfo) =>
|
||||
{
|
||||
return WebSocketService.OnMessageWebSocket(clientInfo, requestInfo);
|
||||
return WebSocketService.OnMessageWebSocket(clientInfo, requestInfo, WebSocketClientInfos);
|
||||
},
|
||||
(userId, clientInfo) =>
|
||||
{
|
||||
WebSocketService.OnCloseWebSocket(userId, clientInfo);
|
||||
WebSocketService.OnCloseWebSocket(userId, clientInfo, WebSocketClientInfos);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -51,6 +51,38 @@ namespace APT.SK.WebApi.Controllers.Api
|
||||
return WitOrderPaged(null, pageFilter);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获得单条实体数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("SkGet")]
|
||||
public JsonActionResult<T_SK_CHECK_CONTENTS> SkGet([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<T_SK_CHECK_CONTENTS>(() =>
|
||||
{
|
||||
if(filter.FilterGroup.Rules.Any(t=>t.Field=="ID"))
|
||||
{
|
||||
var ids = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID").Value.ToString();
|
||||
if(ids.Contains(","))
|
||||
{
|
||||
var idArr = ids.Split(",");
|
||||
filter.FilterGroup.Rules.Remove(filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID"));
|
||||
filter.FilterGroup.Rules.Add(new APT.Infrastructure.Core.FilterRule
|
||||
{
|
||||
Field = "ID",
|
||||
Operate = FilterOperate.Equal,
|
||||
Value = idArr.FirstOrDefault()
|
||||
});
|
||||
}
|
||||
}
|
||||
var entity = this.GetEntity<T_SK_CHECK_CONTENTS>(null,filter);
|
||||
return entity;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新或新增数据
|
||||
/// </summary>
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user