yandaniu пре 1 месец
родитељ
комит
eb3b46f99e
37 измењених фајлова са 575 додато и 217 уклоњено
  1. BIN
      .vs/Ropin.Inspection.Api/FileContentIndex/7f02d622-7ee6-4c49-9019-84ec6e560b51.vsidx
  2. BIN
      .vs/Ropin.Inspection.Api/FileContentIndex/8746401a-d6c0-4645-b14e-5f76724f0e5e.vsidx
  3. BIN
      .vs/Ropin.Inspection.Api/FileContentIndex/9eaf3ec7-a104-4f9e-bc1e-3ed7760dc957.vsidx
  4. BIN
      .vs/Ropin.Inspection.Api/FileContentIndex/a68678a8-2980-42ab-aa28-4e73cca27cc0.vsidx
  5. BIN
      .vs/Ropin.Inspection.Api/FileContentIndex/bd7015a5-9762-4f6e-8105-68dd54ae8250.vsidx
  6. 1 1
      Ropin.Environmentally.AlarmService/Service/RabbitMQReceiveService.cs
  7. 79 5
      Ropin.Inspection.Api/Controllers/Base/AIController.cs
  8. 11 11
      Ropin.Inspection.Api/Controllers/ISP/TispRecordController.cs
  9. 42 33
      Ropin.Inspection.Api/Controllers/MTN/TmtnAlarmOrderController.cs
  10. 0 1
      Ropin.Inspection.Api/Controllers/SYS/TsysMessageController.cs
  11. 18 0
      Ropin.Inspection.Api/TmtnPushMsgResultController.cs
  12. 2 0
      Ropin.Inspection.Common/DataDictionaryHelper.cs
  13. 155 9
      Ropin.Inspection.Common/Helper/AIProjectHelper.cs
  14. 12 6
      Ropin.Inspection.Common/Helper/WeChatHelper.cs
  15. 1 1
      Ropin.Inspection.Model/Entities/TMTN_AlarmOrder.cs
  16. 1 0
      Ropin.Inspection.Model/Entities/TSYS_Message.cs
  17. 1 0
      Ropin.Inspection.Model/Entities/TSYS_MessageFile.cs
  18. 1 0
      Ropin.Inspection.Model/SearchModel/MTN/AlarmOrderSearchModel.cs
  19. 8 0
      Ropin.Inspection.Model/TmtnPushMsgToCreateModel.cs
  20. 4 0
      Ropin.Inspection.Model/ViewModel/MTN/AlarmOrderViewModel.cs
  21. 1 0
      Ropin.Inspection.Model/ViewModel/SYS/TsysMessageUpdateModel.cs
  22. 7 2
      Ropin.Inspection.Model/ViewModel/SYS/TsysMessageViewModel.cs
  23. 1 0
      Ropin.Inspection.Repository/ITmtnPushMsgResultRepository.cs
  24. 15 4
      Ropin.Inspection.Repository/MTN/TmtnAlarmOrderRepository.cs
  25. 18 14
      Ropin.Inspection.Repository/SYS/TsysMessageRepository.cs
  26. 12 0
      Ropin.Inspection.Repository/TmtnPushMsgResultRepository.cs
  27. 0 73
      Ropin.Inspection.Service/ISP/TispRecordItemService.cs
  28. 0 29
      Ropin.Inspection.Service/ISP/TispRecordService.cs
  29. 1 0
      Ropin.Inspection.Service/ITmtnPushMsgResultService.cs
  30. 9 2
      Ropin.Inspection.Service/MTN/TmtnAlarmOrderService.cs
  31. 85 22
      Ropin.Inspection.Service/PushMsgService.cs
  32. 3 1
      Ropin.Inspection.Service/SYS/Interface/ITsysMessageService.cs
  33. 74 0
      Ropin.Inspection.Service/SYS/TsysMessageService.cs
  34. 1 1
      Ropin.Inspection.Service/TmtnDevOpsService.cs
  35. 10 0
      Ropin.Inspection.Service/TmtnPushMsgResultService.cs
  36. 1 1
      Ropin.Inspection.Service/TmtnRepairOrderItemService.cs
  37. 1 1
      Ropin.Inspection.Service/TmtnRepairOrderService.cs

BIN
.vs/Ropin.Inspection.Api/FileContentIndex/7f02d622-7ee6-4c49-9019-84ec6e560b51.vsidx


BIN
.vs/Ropin.Inspection.Api/FileContentIndex/8746401a-d6c0-4645-b14e-5f76724f0e5e.vsidx


BIN
.vs/Ropin.Inspection.Api/FileContentIndex/9eaf3ec7-a104-4f9e-bc1e-3ed7760dc957.vsidx


BIN
.vs/Ropin.Inspection.Api/FileContentIndex/a68678a8-2980-42ab-aa28-4e73cca27cc0.vsidx


BIN
.vs/Ropin.Inspection.Api/FileContentIndex/bd7015a5-9762-4f6e-8105-68dd54ae8250.vsidx


+ 1 - 1
Ropin.Environmentally.AlarmService/Service/RabbitMQReceiveService.cs

@@ -146,7 +146,7 @@ namespace Ropin.Environmentally.AlarmService.Service
                 rabbitMQModels.HostName = _rabbitMQModel.HostName;
                 rabbitMQModels.Port = _rabbitMQModel.Port;
                 rabbitMQModels.VirtualHost = _rabbitMQModel.VirtualHost;
-                rabbitMQModels.ExchangeName = rabbitMQModels.QueueName+".DirectExchange"; ;
+                rabbitMQModels.ExchangeName = rabbitMQModels.QueueName+".DirectExchange";
                 rabbitMQModels.RoutingKey = rabbitMQModels.QueueName + ".key";
                 bool bols = await _pushMsgService.PushAlarmMsgAsync(pushMsg, pushMsg.Subject, rabbitMQModels);
                 if (bols)

+ 79 - 5
Ropin.Inspection.Api/Controllers/Base/AIController.cs

@@ -14,6 +14,9 @@ using Microsoft.AspNetCore.Authorization;
 using Ropin.Inspection.Api.Common;
 using System.Threading.Tasks;
 using Ropin.Inspection.Model;
+using System.Collections.Generic;
+using System;
+using Newtonsoft.Json;
 
 namespace Ropin.Inspection.Api.Controllers.Base
 {
@@ -21,9 +24,13 @@ namespace Ropin.Inspection.Api.Controllers.Base
     {
         private readonly IHttpClientFactory _httpClientFactory;
         private readonly AIProjectHelper aIHelper;
-        public AIController(IHttpClientFactory httpClientFactory)
+        private readonly ITsysMessageService _TsysMessageService;
+        private readonly IPushMsgService _pushMsgService;
+        public AIController(IHttpClientFactory httpClientFactory, ITsysMessageService tsysMessageService, IPushMsgService pushMsgService)
         {
-            aIHelper= new AIProjectHelper(httpClientFactory);
+            aIHelper = new AIProjectHelper(httpClientFactory);
+            _TsysMessageService = tsysMessageService;
+            _pushMsgService = pushMsgService;
         }
         /// <summary>
         /// AI登录
@@ -43,10 +50,77 @@ namespace Ropin.Inspection.Api.Controllers.Base
         /// <returns></returns>
         [HttpGet("AiHistoricAlmrecord/{Devno}/{Page}/{pageSize}")]
         [AllowAnonymous]
-        public async Task<ApiResult<AISqlSugarPagedList<AlmRecordOutput>>> AiHistoricAlmrecord(string Devno,int Page=1,int pageSize=10)
+        public async Task<ApiResult<AISqlSugarPagedList<AlmRecordOutput>>> AiHistoricAlmrecord(string Devno,int Page=1,int pageSize=10, long? entityId = null)
         {
-            var data = await aIHelper.GetHistoricAlmrecord(Devno,Page,pageSize);
-            return new ApiResult<AISqlSugarPagedList<AlmRecordOutput>>(data, ReturnCode.Success); ;
+            var data = await aIHelper.GetHistoricAlmrecord(Devno,Page,pageSize, entityId);
+            return new ApiResult<AISqlSugarPagedList<AlmRecordOutput>>(data, ReturnCode.Success);
+        }
+        /// <summary>
+        /// AI-获取报警处理列表
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("AiAlmDispose/{Devno}/{Page}/{pageSize}")]
+        [AllowAnonymous]
+        public async Task<ApiResult<AISqlSugarPagedList<AlmRecordOutput>>> AiAlmDispose(string Devno, int Page = 1, int pageSize = 10, long? entityId = null)
+        {
+            var data = await aIHelper.GetAlmDispose(Devno, Page, pageSize, entityId);
+            return new ApiResult<AISqlSugarPagedList<AlmRecordOutput>>(data, ReturnCode.Success);
+        }
+        /// <summary>
+        /// AI-报警数据保存到环保消息表数据
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("AiAlmSaveMessage")]
+        [AllowAnonymous]
+        public async Task<ApiResult> AiAlmSaveMessage()
+        {
+            //40124884581189
+            var data = await aIHelper.GetAlmDispose("", 0, 10, 33379713109829);
+            //var data = await aIHelper.GetHistoricAlmrecord("", 1, 10, 33379713109829);
+            if (data!=null)
+            {
+                foreach (var item in data.Items)
+                {
+                    if (item!=null)
+                    {
+                        var textJson = new
+                        {
+                            PanoramaId = item.PanoramaId,
+                            PanoramaUrl = item.PanoramaUrl,
+                            RoiJson = item.RoiJson,
+                            NonRoiJson = item.NonRoiJson,
+                            DetectionFrameJson = item.DetectionFrameJson
+                        };
+                        var datas = JsonConvert.SerializeObject(textJson);
+                        MessageFile messageFile = new MessageFile();
+                        messageFile.Text = datas;
+                        messageFile.Type = "FILE_TYP_006";
+                        TpushMsgModel model = new TpushMsgModel
+                        {
+                            C_DevStoreCode = "d705ceb5-7473-4b19-91dd-d3eff223f05b",
+                            C_MsgTypeCode = "MSG_TYPE_024",
+                            Subject = item.Device_TypeName + "报警",
+                            Msg = item.Event_Name,
+                            UserName = "AI",
+                            UserMobile = "",
+                            CreateOn = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                            GenerationType = 1,
+                            msgStatus = 1,
+                            FileList=new List<MessageFile> { messageFile }
+                        };
+                        bool bol = await _pushMsgService.PushAlarmMsgAsync(model, model.Subject);
+                        //if (bol)
+                        //{
+                        //   bool result= await aIHelper.UpdateAlmIsDelete(item.Id);
+                        //}
+                    }
+                }
+            }
+            TsysMessageSearchModel searchModel = new TsysMessageSearchModel();
+            searchModel.IsPagination = true;
+            searchModel.C_MsgTypeCode = "MSG_TYPE_024";
+            var msgData = await _TsysMessageService.GetConditionAsync(searchModel);
+            return new ApiResult<IEnumerable<TsysMessageViewModel>>(msgData, ReturnCode.Success);
         }
     }
 }

+ 11 - 11
Ropin.Inspection.Api/Controllers/ISP/TispRecordController.cs

@@ -142,17 +142,17 @@ namespace Ropin.Inspection.Api.Controllers
                 if (record.TispRecordItemList.Where(i => i.C_Status == "0").Any())
                 {
                     //没有设备ID不能发消息
-                    await _pushMsgService.PushAlarmMsgAsync(new TpushMsgModel
-                    {
-                        C_DevStoreCode = "",
-                        C_MsgTypeCode = "MSG_TYPE_002",
-                        Msg = record.TispRecordItemList.Where(i => i.C_Status == "0").Select(x => x.C_InspectionContent).First(),
-                        Subject = "点检异常",
-                        DevNumber = record.C_SpotCode.ToString(),
-                        DevName = "未知",
-                        GenerationType = 2,
-                        msgStatus = 0,
-                    }, "点检异常");
+                    //await _pushMsgService.PushAlarmMsgAsync(new TpushMsgModel
+                    //{
+                    //    C_DevStoreCode = "",
+                    //    C_MsgTypeCode = "MSG_TYPE_002",
+                    //    Msg = record.TispRecordItemList.Where(i => i.C_Status == "0").Select(x => x.C_InspectionContent).First(),
+                    //    Subject = "点检异常",
+                    //    DevNumber = record.C_SpotCode.ToString(),
+                    //    DevName = "未知",
+                    //    GenerationType = 2,
+                    //    msgStatus = 0,
+                    //}, "点检异常");
 
                     //await _pushMsgService.PushAlarmMsgAsync(new TpushMsgModel
                     //{

+ 42 - 33
Ropin.Inspection.Api/Controllers/MTN/TmtnAlarmOrderController.cs

@@ -25,6 +25,7 @@ using Newtonsoft.Json;
 using ICSharpCode.SharpZipLib.Zip;
 using Ropin.Inspection.Common.Helper;
 using NPOI.SS.Formula;
+using Ropin.Inspection.Repository;
 
 namespace Ropin.Inspection.Api.Controllers.MTN
 {
@@ -34,6 +35,7 @@ namespace Ropin.Inspection.Api.Controllers.MTN
         private readonly ITmtnAlarmOrderService _repository;
         private readonly IPushMsgService _pushMsgService;
         private readonly ITmtnPushMsgResultService _tmtnPushMsgResultService;
+        private readonly ITsysMessageService _tsysMessageService;
 
         private static readonly ILog log = LogManager.GetLogger(typeof(TmtnAlarmOrderController));
         /// <summary>
@@ -43,12 +45,13 @@ namespace Ropin.Inspection.Api.Controllers.MTN
         /// <param name="repository"></param>
         /// <param name="pushMsgService"></param>
         /// <param name="tmtnPushMsgResultService"></param>
-        public TmtnAlarmOrderController(ILogger<TmtnAlarmOrderController> logger, ITmtnAlarmOrderService repository, IPushMsgService pushMsgService, ITmtnPushMsgResultService tmtnPushMsgResultService)
+        public TmtnAlarmOrderController(ILogger<TmtnAlarmOrderController> logger, ITmtnAlarmOrderService repository, IPushMsgService pushMsgService, ITmtnPushMsgResultService tmtnPushMsgResultService, ITsysMessageService tsysMessageService)
         {
             _logger = logger;
             _repository = repository;
             _pushMsgService = pushMsgService;
             _tmtnPushMsgResultService = tmtnPushMsgResultService;
+            _tsysMessageService = tsysMessageService;
         }
         /// <summary>
         /// 创建报警工单
@@ -81,7 +84,7 @@ namespace Ropin.Inspection.Api.Controllers.MTN
         [HttpPost("CreateAlarmOrderAsync")]
         public async Task<ApiResult> CreateAlarmOrderAsync(AddAlarmOrderViewModel content)
         {
-            if (content == null|| content.C_PushMsgResultCode==null)
+            if (content == null|| content.C_MessageCode == null)
             {
                 return new ApiResult(ReturnCode.ArgsError);
             }
@@ -90,19 +93,22 @@ namespace Ropin.Inspection.Api.Controllers.MTN
                 await _repository.CreateOrderAsync(content);
                 log.Info($"创建报警工单+处理记录-保存数据成功【数据=[{JsonConvert.SerializeObject(content)}]】");
                 //Guid guid = Guid.Parse(content.C_PushMsgResultCode);
-                var PushMsg=await _tmtnPushMsgResultService.GetByIdAsync(content.C_PushMsgResultCode);
-                log.Info($"创建报警工单+处理记录-根据PushMsgResultCode获取 TMTN_PushMsgResult 数据=[{JsonConvert.SerializeObject(PushMsg)}]");
-                await _pushMsgService.PushAlarmMsgAsync(new TpushMsgModel
+                var PushMsg=await _tsysMessageService.GetByIdAsync(content.C_MessageCode);
+                log.Info($"创建报警工单+处理记录-根据MessageCode获取 TSYS_Message 数据=[{JsonConvert.SerializeObject(PushMsg)}]");
+                if (PushMsg!=null&&!string.IsNullOrEmpty(PushMsg.C_DevStoreCode))
                 {
-                    C_DevStoreCode = PushMsg.C_DevStoreCode,
-                    C_MsgTypeCode = "MSG_TYPE_019", 
-                    Msg = content.C_Record,//content.C_Name + "  " + content.C_Remark,
-                    Subject = content.C_Name,//"上报报警," + content.C_Name,
-                    DevNumber = PushMsg.C_DevStoreCode,
-                    DevName = "",
-                    GenerationType = 2,
-                    msgStatus = 0,
-                },"设备报警工单");
+                    await _pushMsgService.PushAlarmMsgAsync(new TpushMsgModel
+                    {
+                        C_DevStoreCode = PushMsg.C_DevStoreCode,
+                        C_MsgTypeCode = "MSG_TYPE_019",
+                        Msg = content.C_Record,//content.C_Name + "  " + content.C_Remark,
+                        Subject = content.C_Name,//"上报报警," + content.C_Name,
+                        DevNumber = PushMsg.C_DevStoreCode,
+                        DevName = "",
+                        GenerationType = 2,
+                        msgStatus = 0,
+                    },"设备报警工单");
+                }
                 log.Info($"创建报警工单+处理记录-保存数据END");
             }
             catch (Exception ex)
@@ -152,7 +158,7 @@ namespace Ropin.Inspection.Api.Controllers.MTN
                 await _repository.UpdateAsync(id, updateModel);
                 log.Info($"更新报警工单-保存数据成功【id={id};数据=[{JsonConvert.SerializeObject(updateModel)}]】");
                 var content = await _repository.GetByIdAsync(id);
-                if (updateModel.C_Status=="5") {
+                if (updateModel.C_Status=="5"&& content!=null&&!string.IsNullOrEmpty(content.C_DevStoreCode)) {
                     await _pushMsgService.PushAlarmMsgAsync(new TpushMsgModel
                     {
                         C_DevStoreCode = content.C_DevStoreCode,
@@ -196,25 +202,28 @@ namespace Ropin.Inspection.Api.Controllers.MTN
                 if (updateModel.C_Status=="2"|| updateModel.C_Status=="4" || updateModel.C_Status == "7")
                 {
                     var content = await _repository.GetByIdAsync(id);
-                    string title = "";string code = "";
-                    switch (updateModel.C_Status)
-                    {
-                        case "2": title = "报警确认,"; code = "MSG_TYPE_021"; break;
-                        case "7": title = "报警完成确认,"; code = "MSG_TYPE_021"; break;
-                        case "4": title = "报警完成,"; code = "MSG_TYPE_022"; break;
-                        case "5": title = "报警取消,"; code = "MSG_TYPE_020"; break;
-                    }
-                    await _pushMsgService.PushAlarmMsgAsync(new TpushMsgModel
+                    if (content != null && !string.IsNullOrEmpty(content.C_DevStoreCode))
                     {
-                        C_DevStoreCode = content.C_DevStoreCode,
-                        C_MsgTypeCode = code,
-                        Msg = updateModel.C_Record,//content.C_Name + "  " + updateModel.C_Remark,
-                        Subject = content.C_Name,// title + content.C_Name,
-                        DevNumber = content.C_DevStoreCode,
-                        DevName = content.C_DevName,
-                        GenerationType = 2,
-                        msgStatus = 0,
-                    }, "设备报警工单");
+                        string title = ""; string code = "";
+                        switch (updateModel.C_Status)
+                        {
+                            case "2": title = "报警确认,"; code = "MSG_TYPE_021"; break;
+                            case "7": title = "报警完成确认,"; code = "MSG_TYPE_021"; break;
+                            case "4": title = "报警完成,"; code = "MSG_TYPE_022"; break;
+                            case "5": title = "报警取消,"; code = "MSG_TYPE_020"; break;
+                        }
+                        await _pushMsgService.PushAlarmMsgAsync(new TpushMsgModel
+                        {
+                            C_DevStoreCode = content.C_DevStoreCode,
+                            C_MsgTypeCode = code,
+                            Msg = updateModel.C_Record,//content.C_Name + "  " + updateModel.C_Remark,
+                            Subject = content.C_Name,// title + content.C_Name,
+                            DevNumber = content.C_DevStoreCode,
+                            DevName = content.C_DevName,
+                            GenerationType = 2,
+                            msgStatus = 0,
+                        }, "设备报警工单");
+                    }                    
                 }
                 log.Info($"报警工单-流程-保存数据END");
             }

+ 0 - 1
Ropin.Inspection.Api/Controllers/SYS/TsysMessageController.cs

@@ -78,7 +78,6 @@ namespace Ropin.Inspection.Api.Controllers
             {
                 return new ApiResult(ReturnCode.ArgsError);
             }
-            searchModel.IsPagination = false;
             try
             {
                 var contentList = await _TsysMessageService.GetConditionAsync(searchModel);

+ 18 - 0
Ropin.Inspection.Api/TmtnPushMsgResultController.cs

@@ -369,6 +369,24 @@ namespace Ropin.Inspection.Api
         //        return new ApiResult(ReturnCode.GeneralError, ex.Message);
         //    }
         //}
+
+        /// <summary>
+        ///根据消息ID和推送人员修改状态
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("UpdateStatusAsync/{msgCode}/{userId}/{status}")]
+        public async Task<ApiResult> UpdateStatusAsync(string msgCode, string userId, string status)
+        {
+            try
+            {
+                await _TmtnPushMsgResultService.UpdateStatusAsync(msgCode, status, userId);
+                return new ApiResult(ReturnCode.Success);
+            }
+            catch (Exception ex)
+            {
+                return new ApiResult(ReturnCode.GeneralError, ex.Message);
+            }
+        }
     }
 }
 

+ 2 - 0
Ropin.Inspection.Common/DataDictionaryHelper.cs

@@ -43,6 +43,7 @@ namespace Ropin.Inspection.Common
                     case "MSG_TYPE_021": val = "报警确认消息"; break;
                     case "MSG_TYPE_022": val = "报警完成消息"; break;
                     case "MSG_TYPE_023": val = "手动报警消息"; break;
+                    case "MSG_TYPE_024": val = "AI报警消息"; break;
                     default: val = "未知类型"; break;
                 }
             }
@@ -68,6 +69,7 @@ namespace Ropin.Inspection.Common
                 case "MSG_TYPE_012": //设备点报警消息
                 case "MSG_TYPE_017"://设备点预警消息
                 case "MSG_TYPE_023"://手动报警消息
+                case "MSG_TYPE_024"://AI报警消息
                     val =1; break;
             }
             return val;

+ 155 - 9
Ropin.Inspection.Common/Helper/AIProjectHelper.cs

@@ -83,7 +83,7 @@ namespace Ropin.Inspection.Common.Helper
         /// 获取历史报警记录
         /// </summary>
         /// <returns></returns>
-        public async Task<AISqlSugarPagedList<AlmRecordOutput>> GetHistoricAlmrecord(string Devno, int Page = 1, int pageSize = 10)
+        public async Task<AISqlSugarPagedList<AlmRecordOutput>> GetHistoricAlmrecord(string Devno, int Page = 1, int pageSize = 10,long? entityId=null)
         {
             if (loginResult == null)
             {
@@ -92,11 +92,13 @@ namespace Ropin.Inspection.Common.Helper
             if (loginResult==null|| loginResult.RefreshToken==null)
             {
                 log.Info($"AI-获取历史报警记录-token 为空");
+                return null;
             }
             AISqlSugarPagedList<AlmRecordOutput> almData= null;
             string url = AIConst.ApiUrl + AIConst.HistoricAlmrecord;
             using (var client = _httpClientFactory.CreateClient())
-            { 
+            {
+                entityId = entityId ?? AIConst.AIEntityId;
                 // 设置请求头,添加 token
                 client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult.AccessToken);
                 var data = new
@@ -105,7 +107,8 @@ namespace Ropin.Inspection.Common.Helper
                     Page= Page,
                     PageSize=pageSize,
                     SearchKey = Devno,
-                    ThirdParty="",
+                    EntityId= entityId,
+                    ThirdParty = "",
                     Device_Type="",
                     Event_Code = "",
                     Mistake=false,
@@ -146,6 +149,138 @@ namespace Ropin.Inspection.Common.Helper
             }
             return almData;
         }
+
+        /// <summary>
+        /// 获取报警处理
+        /// </summary>
+        /// <returns></returns>
+        public async Task<AISqlSugarPagedList<AlmRecordOutput>> GetAlmDispose(string Devno, int Page = 1, int pageSize = 10, long? entityId = null)
+        {
+            if (loginResult == null)
+            {
+                loginResult = await GetToken();
+            }
+            if (loginResult == null || loginResult.RefreshToken == null)
+            {
+                log.Info($"AI-获取历史报警记录-token 为空");
+                return null;
+            }
+            AISqlSugarPagedList<AlmRecordOutput> almData = null;
+            string url = AIConst.ApiUrl + AIConst.AlmDispose;
+            using (var client = _httpClientFactory.CreateClient())
+            {
+                entityId = entityId ?? AIConst.AIEntityId;
+                // 设置请求头,添加 token
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult.AccessToken);
+                var data = new
+                {
+                    isPage = Page == 0 ? false : true,
+                    Page = Page,
+                    PageSize = pageSize,
+                    SearchKey = Devno,
+                    EntityId = entityId,
+                    ThirdParty = "",
+                    Device_Type = "",
+                    Event_Code = "",
+                    Mistake = false,
+                    //StartTimeRange = ["",""]
+                };
+                var dataStr = JsonConvert.SerializeObject(data);
+                var request = new HttpRequestMessage(HttpMethod.Post, url)
+                {
+                    Content = new StringContent(dataStr, System.Text.Encoding.UTF8, "application/json")
+                };
+                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+                try
+                {
+                    var response = await client.SendAsync(request);
+                    response.EnsureSuccessStatusCode(); // 确保响应状态码为成功
+                    if (response.IsSuccessStatusCode)
+                    {
+                        var strReturn = await response.Content.ReadAsStringAsync();
+                        AIModel<AISqlSugarPagedList<AlmRecordOutput>> ResponseRestult = JsonConvert.DeserializeObject<AIModel<AISqlSugarPagedList<AlmRecordOutput>>>(strReturn);
+                        if (ResponseRestult != null && ResponseRestult.code == "200")
+                        {
+                            almData = ResponseRestult.result;
+                        }
+                    }
+                }
+                catch (HttpRequestException ex)
+                {
+                    log.Info($"AI-获取历史报警记录-异常【{ex.Message}】");
+                }
+                catch (JsonException ex)
+                {
+                    log.Info($"解析AI-获取历史报警记录-响应异常【{ex.Message}】");
+                }
+                catch (Exception ex)
+                {
+                    log.Info($"获取AI-获取历史报警记录-时发生未知异常【{ex.Message}】");
+                }
+            }
+            return almData;
+        }
+
+        /// <summary>
+        /// AI报警软删除
+        /// </summary>
+        /// <returns></returns>
+        public async Task<bool> UpdateAlmIsDelete(long AlmId)
+        {
+            if (loginResult == null)
+            {
+                loginResult = await GetToken();
+            }
+            if (loginResult == null || loginResult.RefreshToken == null)
+            {
+                log.Info($"AI-AI报警软删除-token 为空");
+                return false;
+            }
+            bool result=false;
+            string url = AIConst.ApiUrl + AIConst.AlmDeleteDispose;
+            using (var client = _httpClientFactory.CreateClient())
+            {
+                // 设置请求头,添加 token
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult.AccessToken);
+                var data = new
+                {
+                    Id= AlmId
+                };
+                var dataStr = JsonConvert.SerializeObject(data);
+                var request = new HttpRequestMessage(HttpMethod.Post, url)
+                {
+                    Content = new StringContent(dataStr, System.Text.Encoding.UTF8, "application/json")
+                };
+                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+                try
+                {
+                    var response = await client.SendAsync(request);
+                    response.EnsureSuccessStatusCode(); // 确保响应状态码为成功
+                    if (response.IsSuccessStatusCode)
+                    {
+                        var strReturn = await response.Content.ReadAsStringAsync();
+                        AIModel<object> ResponseRestult = JsonConvert.DeserializeObject<AIModel<object>>(strReturn);
+                        if (ResponseRestult != null && ResponseRestult.code == "200")
+                        {
+                            result =true;
+                        }
+                    }
+                }
+                catch (HttpRequestException ex)
+                {
+                    log.Info($"AI报警软删除-异常【{ex.Message}】");
+                }
+                catch (JsonException ex)
+                {
+                    log.Info($"AI报警软删除-响应异常【{ex.Message}】");
+                }
+                catch (Exception ex)
+                {
+                    log.Info($"AI报警软删除-时发生未知异常【{ex.Message}】");
+                }
+            }
+            return result;
+        }
     }
     public class AIModel<T>
     {
@@ -456,24 +591,35 @@ namespace Ropin.Inspection.Common.Helper
     public static class AIConst
     {
         /// <summary>
-        /// 用户名
+        /// 用户名-cszg
         /// </summary>
         public const string userName1 = "cszg";
         /// <summary>
-        /// 密码
+        /// 密码-cszg
         /// </summary>
         public const string userPwd1 = "04aac704c9490f242acf2d9b6e211da5bfae117737a627eacbc0d064414b13ad454833d6d4d38bc3fddd5108319960e38923e94b3f574616f43e8aaff09817e3d25b551b1e5e26c3a402ba1e42e4b58efdbc83357b62ac4f4369b2ce84ca5481541b5b2c683d52d32b6b";
         /// <summary>
-        /// 用户名
+        /// 用户名-yszh
+        /// </summary>
+        public const string userName2 = "yszh";
+        /// <summary>
+        /// 密码-yszh
+        /// </summary>
+        public const string userPwd2 = "cf8d0e72832c74b3e566aa83f677c4a35c28fdc3b091cce608949806339a44fb5f523729c1d22fc824e2ea411ab8cae7e373762ccba8641dd2050f04f27d1373c8326f6877668bec57e1c8deace9b2ac1398a5cb5b9eee04c996d8c774ad9c55946708db089e6416cf";
+        /// <summary>
+        /// 用户名-ropin
         /// </summary>
-        public const string userName = "yszh";
+        public const string userName = "ropin";
         /// <summary>
-        /// 密码
+        /// 密码-ropin
         /// </summary>
-        public const string userPwd = "cf8d0e72832c74b3e566aa83f677c4a35c28fdc3b091cce608949806339a44fb5f523729c1d22fc824e2ea411ab8cae7e373762ccba8641dd2050f04f27d1373c8326f6877668bec57e1c8deace9b2ac1398a5cb5b9eee04c996d8c774ad9c55946708db089e6416cf";
+        public const string userPwd = "cfa965675d4efbbb0d4a8d5fadf08bad0f780759ab55a414564b87652a015ba44cd8a9ab79dbde503995f7fbffa6a3b1f6322e3d94a4309bed578d8c262e4a3702a4574d20d00d6d54194c7c09b7f4d54cd9d347640de197b1a8f35663c89019b6054415ec7bbb33ef458ecb";
+        public const long AIEntityId = 40124884581189;
         public const string ApiUrl = "https://ropiniot.com/prod-api/api";
         public const string ApiUrl1 = "http://localhost:5005/api";
         public const string loginUrl = "/sysAuth/loginNoCode";
         public const string HistoricAlmrecord = "/AlmRecord/HistoryPage";
+        public const string AlmDispose = "/AlmRecord/NotPage";
+        public const string AlmDeleteDispose = "/AlmRecord/Delete";
     }
 }

+ 12 - 6
Ropin.Inspection.Common/Helper/WeChatHelper.cs

@@ -256,6 +256,7 @@ namespace Ropin.Inspection.Common.Helper
                     if (response.IsSuccessStatusCode)
                     {
                         var strReturn = await response.Content.ReadAsStringAsync();
+                        log.Info($"发送微信模板消息返回数据【strReturn={strReturn}】");
                         var responseMessage = JsonConvert.DeserializeObject<WXResult>(strReturn);
                         if (responseMessage != null && responseMessage.errcode == 0)
                         {
@@ -378,17 +379,22 @@ namespace Ropin.Inspection.Common.Helper
         /// </summary>
         public const string XCXSecret = "8c1117595f359f4ebc60650ed27e835a";
         /// <summary>
-        /// 公众号-AppId
+        /// 公众号-AppId//AI:"wx5e59258499b53581";
         /// </summary>
-        public const string GZHAppId = "wx0fddd2b0603913e0";//AI:"wx5e59258499b53581";
+        public const string GZHAppId = "wx0fddd2b0603913e0";
         /// <summary>
-        /// 公众号-Secret
+        /// 公众号-Secret// AI:"60c43e714f143b31f5528a28fbc19c9d";
         /// </summary>
-        public const string GZHSecret = "4e4b16dcf7286261bb60df3fe28395f3";// AI:"60c43e714f143b31f5528a28fbc19c9d";
+        public const string GZHSecret = "4e4b16dcf7286261bb60df3fe28395f3";
         /// <summary>
-        /// 公众号模板
+        /// 公众号模板 【设备编号{character_string2.DATA};设备名称{ thing1.DATA};关闭状态{ thing3.DATA};关闭时间{time4.DATA}】
+        /// //AI:"KfPCaPhJkUVi3em1baZu1HmsN9qRi-AbOSTo_I3GSfQ";
         /// </summary>
-        public const string GZHTemplateId = "_wP22WQxAlfYGfS8zlnHTl_-KgKS8j_FP5HDeqfsPtU";//AI:"KfPCaPhJkUVi3em1baZu1HmsN9qRi-AbOSTo_I3GSfQ";
+        public const string GZHTemplateId = "_wP22WQxAlfYGfS8zlnHTl_-KgKS8j_FP5HDeqfsPtU";
+        /// <summary>
+        /// 公众号模板-设备报警【设备名称;设备编号;报警内容;报警时间】
+        /// </summary>
+        public const string GZHDevAlarmTemplateId = "7eGjzIBAyysTOLfcn-oqkpOCEL_My5ItXHkd_DdniGw";
         /// <summary>
         /// 微信登录
         /// </summary>

+ 1 - 1
Ropin.Inspection.Model/Entities/TMTN_AlarmOrder.cs

@@ -15,8 +15,8 @@ namespace Ropin.Inspection.Model.Entities
         public string C_ID { get; set; }
         [Required]
         public string C_Name { get; set; }
-        [Required]
         public string C_PushMsgResultCode { get; set; }
+        public string C_MessageCode { get; set; }
         public string C_ExamineBy { get; set; }
         public DateTime? D_ExamineOn { get; set; }
         public string C_Remark { get; set; }

+ 1 - 0
Ropin.Inspection.Model/Entities/TSYS_Message.cs

@@ -16,6 +16,7 @@ namespace Ropin.Inspection.Model.Entities
         public string C_MsgTypeCode { get; set; }
         public string C_Subject { get; set; }
         public DateTime? D_MsgCreateOn { get; set; }
+        public string C_GenerationCode { get; set; }
         public int? I_GenerationType { get; set; } = 1;
         public int? I_MsgStatus { get; set; } = 0;
         public string C_Remark { get; set; }

+ 1 - 0
Ropin.Inspection.Model/Entities/TSYS_MessageFile.cs

@@ -14,6 +14,7 @@ namespace Ropin.Inspection.Model.Entities
         public string C_MessageCode { get; set; }
         public string C_Url { get; set; }
         public string C_Type { get; set; }
+        public string C_Text { get; set; }
         public string C_CreateBy { get; set; }
         public DateTime D_CreateOn { get; set; }
         public string C_LastUpdatedBy { get; set; }

+ 1 - 0
Ropin.Inspection.Model/SearchModel/MTN/AlarmOrderSearchModel.cs

@@ -17,6 +17,7 @@ namespace Ropin.Inspection.Model.SearchModel.MTN
         public string C_DevCode { get; set; }
         public string C_ID { get; set; }
         public string C_PushMsgResultCode { get; set; }
+        public string C_MessageCode { get; set; }
         public string C_Status { get; set; }
         public string C_Name { get; set; }
         public DateTime? BeginTime { get; set; }

+ 8 - 0
Ropin.Inspection.Model/TmtnPushMsgToCreateModel.cs

@@ -37,7 +37,15 @@ namespace Ropin.Inspection.Model
         public int GenerationType { get; set; } = 1;
         //0=普通消息,无需确认;1=报警,待确认,大屏黄色显示;2=已确认,非报警,大屏黄色显示;3=已确认,报警,大屏红色显示
         public int msgStatus { get; set; } = 1;
+        public List<MessageFile> FileList { get; set; } = null;
     }
+    public class MessageFile
+    {
+        public string Type { get;set; }
+        public string Url { get; set; }
+        public string Text { get; set; }
+    }
+
     public class TmtnPushMsgToListDelete
     {
         public string C_DevStoreCode { get; set; }

+ 4 - 0
Ropin.Inspection.Model/ViewModel/MTN/AlarmOrderViewModel.cs

@@ -15,6 +15,8 @@ namespace Ropin.Inspection.Model.ViewModel.MTN
         public string C_ID { get; set; }
         public string C_Name { get; set; }
         public string C_PushMsgResultCode { get; set; }
+        public string C_MessageCode { get; set; }
+        public string C_MsgTypeCode { get; set; }
         public string C_DevStoreCode { get; set; }
         public string C_DevName { get;set; }
         public string C_StoreCode { get; set; }
@@ -30,6 +32,7 @@ namespace Ropin.Inspection.Model.ViewModel.MTN
         public string C_Status { get; set; } = "1";
         public string C_Content { get; set; }
         public List<AlarmOrderRecordViewModel> historyRecord { get; set; }
+        public List<MessageFileViewModel> messageFile { get; set; }
     }
 
     /// <summary>
@@ -53,6 +56,7 @@ namespace Ropin.Inspection.Model.ViewModel.MTN
     {
         public string C_Name { get; set; }
         public string C_PushMsgResultCode { get; set; }
+        public string C_MessageCode { get; set; }
         public string C_ExamineBy { get; set; }
         public DateTime? D_ExamineOn { get; set; }
         public string C_Remark { get; set; }

+ 1 - 0
Ropin.Inspection.Model/ViewModel/SYS/TsysMessageUpdateModel.cs

@@ -15,6 +15,7 @@ namespace Ropin.Inspection.Model
         public string C_MsgTypeCode { get; set; }
         public string C_Subject { get; set; }
         public DateTime? D_MsgCreateOn { get; set; }
+        public string C_GenerationCode { get; set; }
         public int? I_GenerationType { get; set; } = 1;
         public int? I_MsgStatus { get; set; } = 0;
         public string C_Remark { get; set; }

+ 7 - 2
Ropin.Inspection.Model/ViewModel/SYS/TsysMessageViewModel.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 
 namespace Ropin.Inspection.Model
 {
-    public class TsysMessageViewModel:BaseViewModel
+    public class TsysMessageViewModel : BaseViewModel
     {
         public string C_ID { get; set; }
         public string C_LicenseCode { get; set; }
@@ -18,8 +18,11 @@ namespace Ropin.Inspection.Model
         public string C_MsgTypeName { get; set; }
         public string C_Subject { get; set; }
         public DateTime? D_MsgCreateOn { get; set; }
+        public string C_GenerationCode { get; set; }
         public int? I_GenerationType { get; set; } = 1;
         public int? I_MsgStatus { get; set; } = 0;
+        public string C_Url {get;set;}
+        public string C_StaticUrl{get;set;}
         public string C_Remark { get; set; }
         public string C_CreateBy { get; set; }
         public string C_Creator { get; set; }
@@ -28,7 +31,7 @@ namespace Ropin.Inspection.Model
         public string C_Modifier { get; set; }
         public DateTime? D_LastUpdatedOn { get; set; }
         public string C_Status { get; set; } = "1";
-        public long? IsFile { get; set; }
+        public long? IsVideo { get; set; }
         public List<MessageFileViewModel> fileList { get; set; }
     }
 
@@ -43,6 +46,7 @@ namespace Ropin.Inspection.Model
         public string C_MsgTypeName { get; set; }
         public string C_Subject { get; set; }
         public DateTime? D_MsgCreateOn { get; set; }
+        public string C_GenerationCode { get; set; }
         public int? I_GenerationType { get; set; } = 1;
         public int? I_MsgStatus { get; set; } = 0;
         public string C_Remark { get; set; }
@@ -61,6 +65,7 @@ namespace Ropin.Inspection.Model
         public string C_ID { get; set; }
         public string C_Url { get; set; }
         public string C_Type { get; set; }
+        public string C_Text { get; set; }
         public string C_Status { get; set; } = "1";
     }
 }

+ 1 - 0
Ropin.Inspection.Repository/ITmtnPushMsgResultRepository.cs

@@ -12,5 +12,6 @@ namespace Ropin.Inspection.Repository
     {
         Task<IEnumerable<TMTN_PushMsgResultModel>> GetConditionAsync(TmtnPushMsgResultSearchModel searchModel);
         Task<DevAlarmCount> GetPushMsgResultContentAsync(TmtnPushMsgResultSearchModel searchModel);
+        Task<bool> UpdateStatus(string msgCode, string Status, string userId);
     }
 }

+ 15 - 4
Ropin.Inspection.Repository/MTN/TmtnAlarmOrderRepository.cs

@@ -34,10 +34,11 @@ namespace Ropin.Inspection.Repository.MTN
             };
             StringBuilder sql = new StringBuilder();
             sql.Append(@" select * from (
-select a.*,p.C_Content,p.C_DevStoreCode,d.C_Name as C_DevName,d.C_StoreCode,u.C_Name as C_ExamineName,c.C_Name as C_CreateName
+select a.*,m.C_Content,m.C_DevStoreCode,m.C_MsgTypeCode,d.C_Name as C_DevName,d.C_StoreCode,u.C_Name as C_ExamineName,c.C_Name as C_CreateName
 from TMTN_AlarmOrder a
 LEFT JOIN TMTN_PushMsgResult p on (a.C_PushMsgResultCode=p.C_ID)
-LEFT JOIN TDEV_DevStore d on (p.C_DevStoreCode=d.C_ID)
+LEFT JOIN TSYS_Message m on (a.C_MessageCode=m.C_ID)
+LEFT JOIN TDEV_DevStore d on (m.C_DevStoreCode=d.C_ID)
 LEFT JOIN TSYS_User u on (a.C_ExamineBy=u.C_UserID)
 LEFT JOIN TSYS_User c on (a.C_CreateBy=c.C_UserID)
 ) tab
@@ -105,7 +106,8 @@ CASE WHEN ISNULL(SUM(if(C_Status='7',1,0))) THEN 0 ELSE SUM(if(C_Status='7',1,0)
 FROM (
 SELECT A.D_CreateOn,A.C_Status FROM TMTN_AlarmOrder A 
 LEFT JOIN TMTN_PushMsgResult p on (A.C_PushMsgResultCode=p.C_ID)
-LEFT JOIN TDEV_DevStore d on (p.C_DevStoreCode=d.C_ID)
+LEFT JOIN TSYS_Message m on (A.C_MessageCode=m.C_ID)
+LEFT JOIN TDEV_DevStore d on (m.C_DevStoreCode=d.C_ID)
 WHERE d.C_Status != '0' 
 AND d.C_StoreCode =@storeCode 
 AND A.D_CreateOn >= date_sub(NOW(),INTERVAL 6 MONTH)
@@ -130,7 +132,8 @@ AND A.D_CreateOn >= date_sub(NOW(),INTERVAL 6 MONTH)
         {
             MySqlConnector.MySqlParameter[] parameters = new[] {
                 new MySqlConnector.MySqlParameter("id", searchModel.C_ID),
-                new MySqlConnector.MySqlParameter("PushMsgResultCode", searchModel.C_PushMsgResultCode)
+                new MySqlConnector.MySqlParameter("PushMsgResultCode", searchModel.C_PushMsgResultCode),
+                new MySqlConnector.MySqlParameter("messageCode", searchModel.C_MessageCode)
             };
             string sql = @"select a.*,o.C_Name as C_AlarmOrderName,u.C_Name as C_CreateName
 from TMTN_AlarmHandleRecord a 
@@ -143,6 +146,14 @@ from TMTN_AlarmHandleRecord a
 LEFT JOIN TMTN_AlarmOrder o on (a.C_AlarmOrderCode=o.C_ID)
 LEFT JOIN TSYS_User u on (a.C_CreateBy=u.C_UserID)
 where o.C_PushMsgResultCode=@PushMsgResultCode order by a.D_CreateOn asc";
+            }
+            if (!string.IsNullOrEmpty(searchModel.C_MessageCode))
+            {
+                sql = @"select a.*,o.C_Name as C_AlarmOrderName,u.C_Name as C_CreateName
+from TMTN_AlarmHandleRecord a 
+LEFT JOIN TMTN_AlarmOrder o on (a.C_AlarmOrderCode=o.C_ID)
+LEFT JOIN TSYS_User u on (a.C_CreateBy=u.C_UserID)
+where o.C_MessageCode=@messageCode order by a.D_CreateOn asc";
             }
             IEnumerable<AlarmOrderRecordViewModel> recordItemlist = EntityFrameworkCoreExtensions.GetList<AlarmOrderRecordViewModel>(DbContext.Database, sql, parameters);
             return Task.FromResult(recordItemlist);

+ 18 - 14
Ropin.Inspection.Repository/SYS/TsysMessageRepository.cs

@@ -45,21 +45,22 @@ namespace Ropin.Inspection.Repository
                 new MySqlConnector.MySqlParameter("endTime ", searchModel.EndTime?.ToString("yyyy-MM-dd"))
             };
             StringBuilder sql = new StringBuilder();
+            StringBuilder pushMsgSql= new StringBuilder();
+            if (!string.IsNullOrEmpty(searchModel.C_PushMsgToCode))
+            {
+                pushMsgSql.Append("  and C_PushMsgToCode=@pushMsgToCode ");
+            }
             sql.Append(@"
  select * from (
- select m.*,d.C_StoreCode,d.C_Name as C_DevName,c.C_Name as C_MsgTypeName,pm.C_PushMsgToCode,ifnull(f.cut,0) as IsFile 
+ select m.*,d.C_StoreCode,d.C_Name as C_DevName,d.C_Url,d.C_StaticUrl,c.C_Name as C_MsgTypeName,ifnull(f.cut4,0) as IsVideo 
  from TSYS_Message m
  LEFT JOIN TDEV_DevStore d on (m.C_DevStoreCode=d.C_ID)
  LEFT JOIN TBDM_CodeDetail c on (m.C_MsgTypeCode=c.C_Code)
- LEFT JOIN 
- (select C_MessageCode,C_PushMsgToCode,count(1) cut from TMTN_PushMsgResult 
-");
-            if (!string.IsNullOrEmpty(searchModel.C_PushMsgToCode))
-            {
-                sql.Append(" where C_PushMsgToCode=@pushMsgToCode ");
-            }
-            sql.Append(@" group by C_MessageCode,C_PushMsgToCode) pm on(m.C_ID=pm.C_MessageCode) 
-LEFT JOIN ( select C_MessageCode,Count(1) cut from TSYS_MessageFile group by C_MessageCode) f on (m.C_ID=f.C_MessageCode)
+LEFT JOIN ( select C_MessageCode,count(CASE WHEN C_Type='FILE_TYP_001' THEN 1 END) as cut1,
+count(CASE WHEN C_Type='FILE_TYP_002' THEN 1 END) as cut2,count(CASE WHEN C_Type='FILE_TYP_003' THEN 1 END) as cut3,
+count(CASE WHEN C_Type='FILE_TYP_004' THEN 1 END) as cut4,count(CASE WHEN C_Type='FILE_TYP_005' THEN 1 END) as cut5,
+count(CASE WHEN C_Type='FILE_TYP_006' THEN 1 END) as cut6
+from TSYS_MessageFile group by C_MessageCode) f on (m.C_ID=f.C_MessageCode)
 ) tab ");
             if (!string.IsNullOrEmpty(searchModel.C_Status))
             {
@@ -69,7 +70,6 @@ LEFT JOIN ( select C_MessageCode,Count(1) cut from TSYS_MessageFile group by C_M
             {
                 sql.Append(" where C_Status!='0' ");
             }
-
             if (!string.IsNullOrEmpty(searchModel.C_ID))
             {
                 sql.Append(" and C_ID=@id ");
@@ -106,13 +106,17 @@ LEFT JOIN ( select C_MessageCode,Count(1) cut from TSYS_MessageFile group by C_M
             }
             if (searchModel.BeginTime != null && searchModel.BeginTime != DateTime.MinValue)
             {
-                sql.Append(" and DATE_FORMAT(D_CreateOn, '%Y-%m-%d')>=@beginTme  ");
+                sql.Append(" and DATE_FORMAT(D_MsgCreateOn, '%Y-%m-%d')>=@beginTme  ");
             }
             if (searchModel.EndTime != null && searchModel.EndTime != DateTime.MinValue)
             {
-                sql.Append(" and DATE_FORMAT(D_CreateOn, '%Y-%m-%d')<=@endTime  ");
+                sql.Append(" and DATE_FORMAT(D_MsgCreateOn, '%Y-%m-%d')<=@endTime  ");
+            }
+            if (pushMsgSql.Length>0)
+            {
+                sql.Append($" and C_ID in (select C_MessageCode from TMTN_PushMsgResult  where C_Status='1'  {pushMsgSql.ToString()} group by C_MessageCode) ");
             }
-            sql.Append(" order by D_CreateOn desc ");
+            sql.Append(" order by D_MsgCreateOn desc ");
             IEnumerable<TsysMessageViewModel> recordItemlist = EntityFrameworkCoreExtensions.GetList<TsysMessageViewModel>(DbContext.Database, sql.ToString(), parameters);
             searchModel.TotalCount = recordItemlist.First() != null ? recordItemlist.ToList().Count : 0;
             if (searchModel.TotalCount == 0)

+ 12 - 0
Ropin.Inspection.Repository/TmtnPushMsgResultRepository.cs

@@ -16,6 +16,18 @@ namespace Ropin.Inspection.Repository
         public TmtnPushMsgResultRepository(InspectionDbContext DbContext) : base(DbContext)
         {
 
+        }
+        public Task<bool> UpdateStatus(string msgCode, string Status,string userId)
+        {
+            MySqlConnector.MySqlParameter[] parameters = new[] {
+                new MySqlConnector.MySqlParameter("msgCode", msgCode),
+                new MySqlConnector.MySqlParameter("status", Status),
+                new MySqlConnector.MySqlParameter("userId", userId)
+            };
+            string sql = $" UPDATE  TMTN_PushMsgResult  SET C_Status = @status  WHERE (C_MessageCode =@msgCode) AND (C_PushMsgToCode=@userId); ";
+            int iResult = EntityFrameworkCoreExtensions.ExecuteSqlNoQuery(DbContext.Database, sql, parameters);
+            bool result = iResult > 0;
+            return Task.FromResult(result);
         }
         public Task<IEnumerable<TMTN_PushMsgResultModel>> GetConditionAsync(TmtnPushMsgResultSearchModel searchModel)
         {

+ 0 - 73
Ropin.Inspection.Service/ISP/TispRecordItemService.cs

@@ -242,30 +242,6 @@ namespace Ropin.Inspection.Service
             TispRecordItemAlarmDetailViewModel itemDetail = itemDetails.FirstOrDefault();
             if (itemDetail == null) return;
             await _pushMsgService.PushRecordMsgAsync("MSG_TYPE_005", itemDetail);
-            if (false)
-            {
-                IEnumerable<TSYS_User> users = await _tsysUserRepository.GetByRecordItemCodeAsync(recordItem.C_ID.ToString()); //GetAllAsync();//
-                //List<string> openIds = users.Where(u => u.C_WechatID != null).Select(i => i.C_WechatID).ToList();
-                //var content = new
-                //{
-                //    thing2 = new { value = itemDetail.ReportUserName ?? "" },
-                //    time4 = new { value = DateTime.Now.ToString("yyyy-MM-dd hh:mm") },
-                //    thing5 = new { value = "巡检异常取消" ?? "" },
-                //    thing6 = new { value = itemDetail.C_Name ?? "" },
-                //    thing9 = new { value = itemDetail.SpotName ?? "" }
-                //};
-                //new WeChatHelper(_httpClientFactory).PushMessageToUser(openIds, content);
-                List<string> openIds = users.Where(u => u.C_WxopenID != null).Select(i => i.C_WxopenID).ToList();
-                var data = new
-                {
-                    thing4 = new { value = itemDetail.SpotName }, //异常位置
-                    thing6 = new { value = itemDetail.C_Name },//异常点位
-                    thing2 = new { value = itemDetail.ReportUserName }, //上报人
-                    time3 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }//上报时间
-                };
-                var row = new WeChatHelper(_httpClientFactory).PushGZHMessageToUser(openIds, null, "", data, "", "");
-            }
-
         }
         public async Task RecoveryRecordItemAlarmAsync(Guid recordItemId, TispRecoveryRecordItemAlarmUpdateViewModel updateModel)
         {
@@ -332,31 +308,6 @@ namespace Ropin.Inspection.Service
             TispRecordItemAlarmDetailViewModel itemDetail = itemDetails.FirstOrDefault();
             if (itemDetail == null) return;
             await _pushMsgService.PushRecordMsgAsync("MSG_TYPE_005", itemDetail);
-            if (false)
-            {
-                IEnumerable<TSYS_User> users = await _tsysUserRepository.GetByRecordItemCodeAsync(recordItem.C_ID.ToString());//.GetAllAsync();
-                //List<string> openIds = users.Where(u => u.C_WechatID != null).Select(i => i.C_WechatID).ToList();
-                //var content = new
-                //{
-                //    thing2 = new { value = itemDetail.ReportUserName ?? "" },
-                //    time4 = new { value = DateTime.Now.ToString("yyyy-MM-dd hh:mm") },
-                //    thing5 = new { value = "巡检异常恢复" ?? "" },
-                //    thing6 = new { value = itemDetail.C_Name ?? "" },
-                //    thing9 = new { value = itemDetail.SpotName ?? "" }
-                //};
-                //new WeChatHelper(_httpClientFactory).PushMessageToUser(openIds, content);
-                List<string> openIds = users.Where(u => u.C_WxopenID != null).Select(i => i.C_WxopenID).ToList();
-                var data = new
-                {
-                    thing4 = new { value = itemDetail.SpotName }, //异常位置
-                    thing6 = new { value = itemDetail.C_Name },//异常点位
-                    thing2 = new { value = itemDetail.ReportUserName }, //上报人
-                    time3 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }//上报时间
-
-                };
-                var row = new WeChatHelper(_httpClientFactory).PushGZHMessageToUser(openIds, null, "", data, "", "");
-            }
-
         }
 
         public async Task ConfirmRecordItemAlarmAsync(Guid recordItemId, TispRecoveryRecordItemAlarmUpdateViewModel updateModel)
@@ -414,30 +365,6 @@ namespace Ropin.Inspection.Service
             if (itemDetail == null) return;
 
             await _pushMsgService.PushRecordMsgAsync("MSG_TYPE_004", itemDetail);
-            if (false)
-            {
-                IEnumerable<TSYS_User> users = await _tsysUserRepository.GetByRecordItemCodeAsync(recordItem.C_ID.ToString()); //GetAllAsync();
-                List<string> openIds = users.Where(u => u.C_WxopenID != null).Select(i => i.C_WxopenID).ToList();
-                //List<string> openIds = users.Where(u => u.C_WechatID != null).Select(i => i.C_WechatID).ToList();
-                //var content = new
-                //{
-                //    thing2 = new { value = itemDetail.ReportUserName ?? "" },
-                //    time4 = new { value = DateTime.Now.ToString("yyyy-MM-dd hh:mm") },
-                //    thing5 = new { value = "巡检异常确认" ?? "" },
-                //    thing6 = new { value = itemDetail.C_Name ?? "" },
-                //    thing9 = new { value = itemDetail.SpotName ?? "" }
-                //};
-                //new WeChatHelper(_httpClientFactory).PushMessageToUser(openIds, content);
-                var data = new
-                {
-                    thing4 = new { value = itemDetail.SpotName }, //异常位置
-                    thing6 = new { value = itemDetail.C_Name },//异常点位
-                    thing2 = new { value = itemDetail.ReportUserName }, //上报人
-                    time3 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }//上报时间
-
-                };
-                var row = new WeChatHelper(_httpClientFactory).PushGZHMessageToUser(openIds, null, "", data, "", "");
-            }
         }
 
         public async Task UpdateRecordItemAsync(Guid recordItemId, TispRecordItemUpdateViewModel updateModel)

+ 0 - 29
Ropin.Inspection.Service/ISP/TispRecordService.cs

@@ -144,35 +144,6 @@ namespace Ropin.Inspection.Service
                     TispRecordItemAlarmDetailViewModel itemDetail = itemDetails.FirstOrDefault();
                     if (itemDetail == null) return;
                     await _pushMsgService.PushRecordMsgAsync("MSG_TYPE_003", itemDetail);
-                    if (false)
-                    {
-                        TsysUserByRoleSearchModel roleSearchModel = new TsysUserByRoleSearchModel { Roles = new List<string> { "d1f28dae-559b-49bc-a991-36e9cc89b453", "33ed642d-17bf-45b4-82d6-60432f0a11d2" } };
-                        IEnumerable<TSYS_User> users = await _tsysUserRepository.GetByRecordItemCodeAsync(item.C_ID.ToString()); //GetAllAsync();//  await _tsysUserRepository.GetUserDetailByRole(roleSearchModel);
-                        if (!users.Any()) continue;
-                        //List<string> openIds = users.Where(u => u.C_WechatID != null).Select(i => i.C_WechatID).ToList();
-                        List<string> openIds = users.Where(u => u.C_WxopenID != null).Select(i => i.C_WxopenID).ToList();
-                        if (!users.Any()) continue;
-                        string sCheckContent = itemDetail.SpotNumber + " " + itemDetail.SpotName + " " + itemDetail.C_Name;
-                        string sCheckResult = itemDetail.C_InspectionContent + itemDetail.C_Remark;
-                        //var content = new
-                        //{
-                        //    thing2 = new { value = itemDetail.ReportUserName ?? "" },
-                        //    time4 = new { value = DateTime.Now.ToString("yyyy-MM-dd hh:mm") },
-                        //    thing5 = new { value = "巡检异常上报" ?? "" },
-                        //    thing6 = new { value = itemDetail.C_Name ?? "" },
-                        //    thing9 = new { value = itemDetail.SpotName ?? "" }
-                        //};
-                        //new WeChatHelper(_httpClientFactory).PushMessageToUser(openIds, content); 
-                        var data = new
-                        {
-                            thing4 = new { value = itemDetail.SpotName }, //异常位置
-                            thing6 = new { value = itemDetail.C_Name },//异常点位
-                            thing2 = new { value = itemDetail.ReportUserName }, //上报人
-                            time3 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }//上报时间
-
-                        };
-                        var row = new WeChatHelper(_httpClientFactory).PushGZHMessageToUser(openIds, null, "", data, "", "");
-                    }
                 }
             }
 

+ 1 - 0
Ropin.Inspection.Service/ITmtnPushMsgResultService.cs

@@ -17,6 +17,7 @@ namespace Ropin.Inspection.Service
         Task<IEnumerable<TmtnPushMsgResultViewModel>> GetConditionAsync(TmtnPushMsgResultSearchModel searchModel);
         Task DeleteAsync(string code);
         //Task<DevAlarmCount> GetPushMsgResultContentAsync(TmtnPushMsgResultSearchModel searchModel);
+        Task UpdateStatusAsync(string msgCode, string Status, string userId);
     }
 }
 

+ 9 - 2
Ropin.Inspection.Service/MTN/TmtnAlarmOrderService.cs

@@ -9,6 +9,7 @@ using Ropin.Inspection.Repository.DEV.Interface;
 using Ropin.Inspection.Repository.Interface;
 using Ropin.Inspection.Repository.MTN;
 using Ropin.Inspection.Repository.MTN.Interface;
+using Ropin.Inspection.Repository.SYS.Interface;
 using Ropin.Inspection.Service.DEV.Interface;
 using Ropin.Inspection.Service.MTN.Interface;
 using System;
@@ -33,7 +34,8 @@ namespace Ropin.Inspection.Service.MTN
         private readonly IClaimsAccessor _claims;
         private readonly InspectionDbContext _sqlDBContext;
         private readonly IUnitOfWork _unitOfWork;
-        public TmtnAlarmOrderService(IClaimsAccessor claims, InspectionDbContext sqlDBContext, ITmtnAlarmOrderRepository repository, IMapper mapper, IUnitOfWork unitOfWork, ITmtnAlarmOrderRecordRepository recorRrepository, ITmtnAlarmOrderRecordAppRepository recorAppRrepository)
+        private readonly ITsysMessageFileRepository _tsysMessageFileRepository;
+        public TmtnAlarmOrderService(IClaimsAccessor claims, InspectionDbContext sqlDBContext, ITmtnAlarmOrderRepository repository, IMapper mapper, IUnitOfWork unitOfWork, ITmtnAlarmOrderRecordRepository recorRrepository, ITmtnAlarmOrderRecordAppRepository recorAppRrepository, ITsysMessageFileRepository tsysMessageFileRepository)
         {
             _repository = repository;
             _mapper = mapper;
@@ -42,6 +44,7 @@ namespace Ropin.Inspection.Service.MTN
             _unitOfWork = unitOfWork;
             _recorRrepository = recorRrepository;
             _recorAppRrepository = recorAppRrepository;
+            _tsysMessageFileRepository = tsysMessageFileRepository;
         }
         /// <summary>
         /// 工单创建
@@ -76,7 +79,7 @@ namespace Ropin.Inspection.Service.MTN
         /// <exception cref="Exception"></exception>
         public async Task CreateOrderAsync(AddAlarmOrderViewModel viewModel)
         {
-            var IsExit = await _repository.GetByConditionAsync(t => t.C_PushMsgResultCode == viewModel.C_PushMsgResultCode);
+            var IsExit = await _repository.GetByConditionAsync(t => t.C_MessageCode == viewModel.C_MessageCode);
             if (IsExit.Count() > 0)
             {
                 throw new Exception("报警记录已存在");
@@ -362,6 +365,10 @@ namespace Ropin.Inspection.Service.MTN
                     }
                 }
                 entity.historyRecord = list.ToList();
+
+                TsysMessageFileSearchModel fileSearch = new TsysMessageFileSearchModel();
+                fileSearch.C_MessageCode = entity.C_MessageCode; fileSearch.IsPagination = false; fileSearch.C_Status = "1";
+                entity.messageFile = (List<MessageFileViewModel>)await _tsysMessageFileRepository.GetList(fileSearch);
             }
             return content.FirstOrDefault();
         }

+ 85 - 22
Ropin.Inspection.Service/PushMsgService.cs

@@ -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, "", "");
             }

+ 3 - 1
Ropin.Inspection.Service/SYS/Interface/ITsysMessageService.cs

@@ -1,4 +1,5 @@
-using Ropin.Inspection.Model;
+using Ropin.Inspection.Common.Helper;
+using Ropin.Inspection.Model;
 using Ropin.Inspection.Service.Interface;
 using System;
 using System.Collections.Generic;
@@ -17,5 +18,6 @@ namespace Ropin.Inspection.Service
         Task UpdateMsgStatusAsync(string id, int msgStatus);
         Task<IEnumerable<TsysMessageViewModel>> GetConditionAsync(TsysMessageSearchModel searchModel);
         Task<IEnumerable<TsysMessageModel>> GetConditionScreenAsync(TsysMessageSearchModel searchModel);
+        Task<bool> AddMessage(AlmRecordOutput almRecord);
     }
 }

+ 74 - 0
Ropin.Inspection.Service/SYS/TsysMessageService.cs

@@ -1,6 +1,8 @@
 using AutoMapper;
 using LinqKit;
+using Newtonsoft.Json;
 using Ropin.Inspection.Common.Accessor.Interface;
+using Ropin.Inspection.Common.Helper;
 using Ropin.Inspection.Model;
 using Ropin.Inspection.Model.Entities;
 using Ropin.Inspection.Repository;
@@ -84,6 +86,78 @@ namespace Ropin.Inspection.Service
             }
         }
 
+        public async Task<bool> AddMessage(AlmRecordOutput almRecord)
+        {
+            var IsData = await _repository.GetByConditionAsync(t => t.C_GenerationCode == almRecord.Id.ToString());
+            var dataList = IsData.ToList();
+            if (dataList != null && dataList.Count() > 0)
+            {
+                return true;
+            }
+            bool result = false;
+            try
+            {
+                _unitOfWork.BeginTransaction();
+                TSYS_Message content = new TSYS_Message();
+                content.C_ID = Guid.NewGuid().ToString();
+                content.C_LicenseCode = "SYSTEM";
+                content.C_Content = almRecord.Event_Name;
+                content.C_DevStoreCode = "d705ceb5-7473-4b19-91dd-d3eff223f05b";
+                content.C_MsgTypeCode = "MSG_TYPE_024";
+                content.C_Subject = almRecord.Device_TypeName + "报警";
+                content.D_MsgCreateOn = almRecord.StartTime;
+                content.C_GenerationCode= almRecord.Id.ToString();
+                content.I_GenerationType = 1;
+                content.I_MsgStatus = 1;
+                content.C_Remark = "来源:AI项目报警处理";
+                content.C_CreateBy = "6e864cbc-5252-11ec-8681-fa163e02b3e4";
+                content.C_Creator = "AI";
+                content.D_CreateOn = DateTime.Now;
+                content.C_Status = "1";
+                result = await _unitOfWork.RegisterNew(content);
+                if (!result)
+                {
+                    throw new Exception("创建失败");
+                }
+                else
+                {
+                    var textJson = new
+                    {
+                        PanoramaId=almRecord.PanoramaId,
+                        PanoramaUrl=almRecord.PanoramaUrl,
+                        RoiJson=almRecord.RoiJson,
+                        NonRoiJson=almRecord.NonRoiJson,
+                        DetectionFrameJson=almRecord.DetectionFrameJson
+                    };
+                    var datas = JsonConvert.SerializeObject(textJson);
+                    TSYS_MessageFile app = new TSYS_MessageFile
+                    {
+                        C_ID = Guid.NewGuid().ToString(),
+                        C_MessageCode = content.C_ID,
+                        C_Type = "FILE_TYP_006",
+                        C_Text = datas,
+                        C_CreateBy = "6e864cbc-5252-11ec-8681-fa163e02b3e4",
+                        D_CreateOn = DateTime.Now,
+                        C_Status = "1"
+                    };
+                    result = await _unitOfWork.RegisterNew(app); 
+                }
+            }
+            catch
+            {
+                _unitOfWork.Rollback();
+                throw;
+            }
+            finally
+            {
+                if (result)
+                    await _unitOfWork.CommitAsync();
+                else
+                    _unitOfWork.Rollback();
+            }
+            return result;
+        }
+
         public async Task DeleteAsync(string id)
         {
             var content = await _repository.GetByIdAsync(id);

+ 1 - 1
Ropin.Inspection.Service/TmtnDevOpsService.cs

@@ -257,7 +257,7 @@ namespace Ropin.Inspection.Service
                         C_CreateBy = _claims.ApiUserId,
                         D_CreateOn = DateTime.Now,
                         C_Status = "1"
-                    }); ;
+                    });
                     var resultItemImage = await _tmtnDevOpsAppRepository.SaveAsync();
                     if (!resultItemImage)
                     {

+ 10 - 0
Ropin.Inspection.Service/TmtnPushMsgResultService.cs

@@ -170,6 +170,16 @@ namespace Ropin.Inspection.Service
             DevAlarmCount data = await _repository.GetPushMsgResultContentAsync(searchModel);
             return data;
         }
+
+        public async Task UpdateStatusAsync(string msgCode, string Status, string userId)
+        {
+            var result = await _repository.UpdateStatus(msgCode, Status, userId);
+            if (!result)
+            {
+                throw new Exception("更新失败");
+            }
+        }
+
         public Task<int> UpdateOneAsync(TmtnPushMsgResultViewModel viewModel, params string[] fields)
         {
             throw new NotImplementedException();

+ 1 - 1
Ropin.Inspection.Service/TmtnRepairOrderItemService.cs

@@ -134,7 +134,7 @@ namespace Ropin.Inspection.Service
                             C_CreateBy = _claims.ApiUserId,
                             D_CreateOn = DateTime.Now,
                             C_Status = "1"
-                        });;
+                        });
                         var resultItemImage = await _tmtnRepairOrderItemAppRepository.SaveAsync();
                         if (!resultItemImage)
                         {

+ 1 - 1
Ropin.Inspection.Service/TmtnRepairOrderService.cs

@@ -383,7 +383,7 @@ namespace Ropin.Inspection.Service
                         C_CreateBy = _claims.ApiUserId,
                         D_CreateOn = DateTime.Now,
                         C_Status = "1"
-                    }); ;
+                    });
                     var resultItemImage = await _tmtnRepairOrderItemAppRepository.SaveAsync();
                     if (!resultItemImage)
                     {