|
@@ -10,11 +10,13 @@ using Ropin.Inspection.Model;
|
|
|
using Ropin.Inspection.Model.Entities;
|
|
|
using Ropin.Inspection.Model.ViewModel;
|
|
|
using Ropin.Inspection.Repository;
|
|
|
+using Ropin.Inspection.Repository.SYS.Interface;
|
|
|
using Ropin.Inspection.Service.Interface;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Net.Http;
|
|
|
+using System.Net.NetworkInformation;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace Ropin.Inspection.Service
|
|
@@ -32,6 +34,7 @@ namespace Ropin.Inspection.Service
|
|
|
private readonly ITdevDevStoreRepository _tdevDevStoreRepository;
|
|
|
private readonly ITsysUserService _tsysUserService;
|
|
|
private readonly ITsysMessageRepository _messageRepository;
|
|
|
+ private readonly ITsysMessageFileRepository _tsysMessageFileRepository;
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(PushMsgService));
|
|
|
private string IsSendEmail = "true";
|
|
|
public PushMsgService(IClaimsAccessor claims,
|
|
@@ -43,7 +46,7 @@ namespace Ropin.Inspection.Service
|
|
|
ITsysUserService tsysUserService,
|
|
|
IHttpClientFactory httpClientFactory,
|
|
|
ITsysUserRepository tsysUserRepository
|
|
|
- , IConfiguration configuration, ITsysMessageRepository messageRepository)
|
|
|
+ , IConfiguration configuration, ITsysMessageRepository messageRepository, ITsysMessageFileRepository tsysMessageFileRepository)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_claims = claims;
|
|
@@ -55,6 +58,7 @@ namespace Ropin.Inspection.Service
|
|
|
_tdevDevStoreRepository = tdevDevStoreRepository;
|
|
|
_tsysUserService = tsysUserService;
|
|
|
_messageRepository = messageRepository;
|
|
|
+ _tsysMessageFileRepository= tsysMessageFileRepository;
|
|
|
string IsEmail = configuration.GetSection("IsSendEmail")?.Value;
|
|
|
IsSendEmail = !string.IsNullOrEmpty(IsEmail)? IsEmail :"true";
|
|
|
}
|
|
@@ -64,6 +68,8 @@ namespace Ropin.Inspection.Service
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ List<MessageFile> messageFiles = pushModel.FileList;
|
|
|
+ pushModel.FileList = null;
|
|
|
log.Info($"发送消息-Begin");
|
|
|
log.Info($"发送消息-接收数据【{JsonConvert.SerializeObject(pushModel)}】");
|
|
|
int msgStatus = DataDictionaryHelper.GetMsgStatus(pushModel.C_MsgTypeCode);
|
|
@@ -102,6 +108,7 @@ namespace Ropin.Inspection.Service
|
|
|
if (string.IsNullOrWhiteSpace(pushModel.UserName))
|
|
|
{
|
|
|
var creadUser = await _tsysUserService.GetByIdAsync(_claims.ApiUserId);
|
|
|
+ createBy = _claims.ApiUserId.ToString();
|
|
|
pushModel.UserName = creadUser?.C_Name;
|
|
|
pushModel.UserMobile = creadUser?.C_Mobile;
|
|
|
}
|
|
@@ -228,7 +235,13 @@ namespace Ropin.Inspection.Service
|
|
|
|
|
|
}
|
|
|
log.Info($"发送消息-sendUserWechatIDList【{JsonConvert.SerializeObject(sendUserWechatIDList)}】pushMsgResultList=【{JsonConvert.SerializeObject(pushMsgResultList)}】");
|
|
|
-
|
|
|
+ string GenerationCode = "";
|
|
|
+ switch (pushModel.GenerationType)
|
|
|
+ {
|
|
|
+ case 1: GenerationCode = pushModel.C_DevStoreCode; break;
|
|
|
+ case 2: GenerationCode = _claims.ApiUserId.ToString(); break;
|
|
|
+ case 3: GenerationCode = "6e864cbc-5252-11ec-8681-fa163e02b3e4"; break;
|
|
|
+ }
|
|
|
TSYS_Message message = new TSYS_Message
|
|
|
{
|
|
|
C_ID = Guid.NewGuid().ToString(),
|
|
@@ -237,6 +250,7 @@ namespace Ropin.Inspection.Service
|
|
|
C_MsgTypeCode = pushModel.C_MsgTypeCode,
|
|
|
C_Subject = Subject,
|
|
|
D_MsgCreateOn = Convert.ToDateTime(pushModel.CreateOn),
|
|
|
+ C_GenerationCode= GenerationCode,
|
|
|
I_GenerationType = pushModel.GenerationType,
|
|
|
I_MsgStatus = pushModel.msgStatus,
|
|
|
C_DevStoreCode = pushModel.C_DevStoreCode,
|
|
@@ -246,7 +260,26 @@ namespace Ropin.Inspection.Service
|
|
|
D_CreateOn = DateTime.Now,
|
|
|
C_Status = "1"
|
|
|
};
|
|
|
-
|
|
|
+ List<TSYS_MessageFile> FileList = null;
|
|
|
+ if (messageFiles != null)
|
|
|
+ {
|
|
|
+ FileList=new List<TSYS_MessageFile>();
|
|
|
+ foreach (var item in messageFiles)
|
|
|
+ {
|
|
|
+ TSYS_MessageFile mesFile = new TSYS_MessageFile
|
|
|
+ {
|
|
|
+ C_ID = Guid.NewGuid().ToString(),
|
|
|
+ C_MessageCode= message.C_ID,
|
|
|
+ C_Url=item.Url,
|
|
|
+ C_Text = item.Text,
|
|
|
+ C_Type = item.Type,
|
|
|
+ C_CreateBy = createBy,
|
|
|
+ D_CreateOn = DateTime.Now,
|
|
|
+ C_Status = "1"
|
|
|
+ };
|
|
|
+ FileList.Add(mesFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (sendUserWechatIDList.Any())
|
|
|
{
|
|
|
try
|
|
@@ -458,27 +491,44 @@ namespace Ropin.Inspection.Service
|
|
|
#endregion
|
|
|
|
|
|
#region 公众号模板【2025-3-5】
|
|
|
- //var data = new
|
|
|
- //{
|
|
|
- // thing4 = new { value = devStore.C_Name }, //异常位置
|
|
|
- // thing6 = new { value = devStore.C_NumberCode },//异常点位
|
|
|
- // thing2 = new { value = typeName }, //上报人
|
|
|
- // time3 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }//上报时间
|
|
|
-
|
|
|
- //};
|
|
|
+ string msg = pushModel.Msg;
|
|
|
+ if (msg.Length>20)
|
|
|
+ {
|
|
|
+ msg=msg.Substring(0,17)+"...";
|
|
|
+ }
|
|
|
+ string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ if (!string.IsNullOrEmpty(pushModel.CreateOn))
|
|
|
+ {
|
|
|
+ time=Convert.ToDateTime(pushModel.CreateOn).ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ #region //_wP22WQxAlfYGfS8zlnHTl_-KgKS8j_FP5HDeqfsPtU
|
|
|
//设备编号{ { character_string2.DATA} }
|
|
|
//设备名称{ { thing1.DATA} }
|
|
|
//关闭状态{ { thing3.DATA} }
|
|
|
//关闭时间{ { time4.DATA} }
|
|
|
+ //var data = new
|
|
|
+ //{
|
|
|
+ // thing1 = new { value = devStore.C_Name }, //异常位置
|
|
|
+ // character_string2 = new { value = devStore.C_NumberCode },//异常点位
|
|
|
+ // thing3 = new { value = typeName }, //上报人
|
|
|
+ // time4 = new { value = pushModel.CreateOn}//上报时间
|
|
|
+ //};
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 7eGjzIBAyysTOLfcn-oqkpOCEL_My5ItXHkd_DdniGw
|
|
|
+ //设备名称{ { thing2.DATA} }
|
|
|
+ //设备编号{ { character_string20.DATA} }
|
|
|
+ //报警时间{ { time4.DATA} }
|
|
|
+ //报警内容{ { thing5.DATA} }
|
|
|
var data = new
|
|
|
{
|
|
|
- thing1 = new { value = devStore.C_Name }, //异常位置
|
|
|
- character_string2 = new { value = devStore.C_NumberCode },//异常点位
|
|
|
- thing3 = new { value = typeName }, //上报人
|
|
|
- time4 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }//上报时间
|
|
|
-
|
|
|
+ thing2 = new { value = devStore.C_Name }, //异常位置
|
|
|
+ character_string20 = new { value = devStore.C_NumberCode },//异常点位
|
|
|
+ thing5 = new { value = msg }, //上报人
|
|
|
+ time4 = new { value = time }//上报时间
|
|
|
};
|
|
|
- var row = new WeChatHelper(_httpClientFactory).PushGZHMessageToUser(sendUserWechatIDList, null, "", data, "", "");
|
|
|
+ #endregion
|
|
|
+ var row = new WeChatHelper(_httpClientFactory).PushGZHMessageToUser(sendUserWechatIDList, WXConstModel.GZHDevAlarmTemplateId, "", data, "", "");
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
@@ -494,6 +544,10 @@ namespace Ropin.Inspection.Service
|
|
|
bool messResult = await _messageRepository.SaveAsync();
|
|
|
if (messResult)
|
|
|
{
|
|
|
+ if (FileList!=null&& FileList.Count>0)
|
|
|
+ {
|
|
|
+ int fileSaveResult = await _tsysMessageFileRepository.CreateRangeAsync(FileList);
|
|
|
+ }
|
|
|
//await _tmtnPushMsgResultRepository.CreateRangeAsync(pushMsgResultList);
|
|
|
foreach (var content in pushMsgResultList)
|
|
|
{
|
|
@@ -513,7 +567,7 @@ namespace Ropin.Inspection.Service
|
|
|
//
|
|
|
if (pushModel.C_MsgTypeCode == "MSG_TYPE_012" && rabbitMQModel != null)
|
|
|
{
|
|
|
- rabbitMQModel.msgStr = JsonConvert.SerializeObject(pushMsgResultList);
|
|
|
+ rabbitMQModel.msgStr = JsonConvert.SerializeObject(message);
|
|
|
bool bol = await RabbitMQHelper.SnedRabbitMQ_ExchangeDirect(rabbitMQModel);
|
|
|
if (!bol)
|
|
|
{
|
|
@@ -564,13 +618,22 @@ namespace Ropin.Inspection.Service
|
|
|
// thing2 = new { value = viewModel.ReportUserName }, //上报人
|
|
|
// time3 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }//上报时间
|
|
|
//};
|
|
|
+ string statusStr = "未知";
|
|
|
+ //1 = 正常; 0 = 异常; 2 = 恢复; 3 = 确认异常; 4 = 取消异常
|
|
|
+ switch (viewModel.SecurityStatus)
|
|
|
+ {
|
|
|
+ case "0": statusStr = "异常"; break;
|
|
|
+ case "1": statusStr = "正常"; break;
|
|
|
+ case "2": statusStr = "恢复"; break;
|
|
|
+ case "3": statusStr = "确认异常"; break;
|
|
|
+ case "4": statusStr = "取消异常"; break;
|
|
|
+ }
|
|
|
var data = new
|
|
|
{
|
|
|
- thing1 = new { value = viewModel.C_Name }, //异常位置
|
|
|
- character_string2 = new { value = viewModel.SpotName },//异常点位
|
|
|
- thing3 = new { value = viewModel.ReportUserName }, //上报人
|
|
|
+ thing1 = new { value = viewModel.SpotName }, //异常位置
|
|
|
+ character_string2 = new { value = viewModel.SpotNumber },//异常点位
|
|
|
+ thing3 = new { value = statusStr }, //上报人
|
|
|
time4 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }//上报时间
|
|
|
-
|
|
|
};
|
|
|
var row = new WeChatHelper(_httpClientFactory).PushGZHMessageToUser(openIds, null, "", data, "", "");
|
|
|
}
|