|
@@ -26,6 +26,8 @@ using ICSharpCode.SharpZipLib.Zip;
|
|
|
using Ropin.Inspection.Common.Helper;
|
|
|
using NPOI.SS.Formula;
|
|
|
using Ropin.Inspection.Repository;
|
|
|
+using Ropin.Inspection.Common;
|
|
|
+using ICSharpCode.SharpZipLib.Core;
|
|
|
|
|
|
namespace Ropin.Inspection.Api.Controllers.MTN
|
|
|
{
|
|
@@ -671,25 +673,126 @@ namespace Ropin.Inspection.Api.Controllers.MTN
|
|
|
}
|
|
|
AlarmOrderSearchModel orderSearchModel = new AlarmOrderSearchModel();
|
|
|
orderSearchModel.IsPagination = false;
|
|
|
- orderSearchModel.C_PushMsgResultCode = searchModel.C_MessageCode;
|
|
|
- var recordItems = await _repository.GetAlarmOrderRecordList(orderSearchModel);
|
|
|
+ orderSearchModel.C_MessageCode = searchModel.C_MessageCode;
|
|
|
+ ////var recordItems = await _repository.GetAlarmOrderRecordList(orderSearchModel);
|
|
|
+ var MsgData = await _repository.GetByMessageCodeAsync(searchModel.C_MessageCode);
|
|
|
string zip = @"wwwroot\\ZipFile";
|
|
|
if (!System.IO.Directory.Exists(zip))
|
|
|
{
|
|
|
Directory.CreateDirectory(zip);
|
|
|
}
|
|
|
string zipPaht = zip + $"\\{searchModel.C_MessageCode}报警详情下载.zip";
|
|
|
- if (recordItems.Count() > 0)
|
|
|
+ List<string> FileDel =new List<string>();
|
|
|
+ if (MsgData!=null)
|
|
|
{
|
|
|
+ var msgEntity = JsonConvert.DeserializeObject<TpushMsgModel>(MsgData.C_Content);
|
|
|
+ string msgTypeName= DataDictionaryHelper.GetValNameByCode(msgEntity.C_MsgTypeCode);
|
|
|
XWPFDocument doc = new XWPFDocument();
|
|
|
var paragraph = doc.CreateParagraph();
|
|
|
var run1 = paragraph.CreateRun();
|
|
|
run1.FontSize = 18;
|
|
|
- run1.AppendText("报警时间:" + searchModel.AlarmTime);
|
|
|
+ run1.AppendText("报警主题:" + msgEntity.Subject);
|
|
|
run1.AddCarriageReturn();
|
|
|
- run1.AppendText("报警内容:" + searchModel.AlarmContent);
|
|
|
+ run1.AppendText("报警设备:" + msgEntity.DevName);
|
|
|
+ run1.AddCarriageReturn();
|
|
|
+ run1.AppendText("报警来源:" + msgEntity.UserName);
|
|
|
+ run1.AddCarriageReturn();
|
|
|
+ run1.AppendText("报警时间:" + msgEntity.CreateOn);
|
|
|
+ run1.AddCarriageReturn();
|
|
|
+ run1.AppendText("报警内容:" + msgEntity.Msg);
|
|
|
+ run1.AddCarriageReturn();
|
|
|
+ run1.AppendText("报警类型:" + msgTypeName);
|
|
|
+ #region 消息图片信息
|
|
|
+ if (MsgData.messageFile != null&& MsgData.messageFile.Count>0)
|
|
|
+ {
|
|
|
+ foreach (var files in MsgData.messageFile)
|
|
|
+ {
|
|
|
+ if (files != null)
|
|
|
+ {
|
|
|
+ if (files.C_Type== "FILE_TYP_006")
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var fileText = JsonConvert.DeserializeObject<AlmImage>(files.C_Text);
|
|
|
+ string images = AIConst.AIImageUrl+fileText.PanoramaUrl;
|
|
|
+ var imgArray= fileText.PanoramaUrl.Split('/');
|
|
|
+ string AiAlmFile = @"wwwroot\\AiAlm";// + fileText.PanoramaUrl;
|
|
|
+ string imgName = "";int fI = 0;
|
|
|
+ foreach (var img in imgArray)
|
|
|
+ {
|
|
|
+ if (fI>0)
|
|
|
+ {
|
|
|
+ if (!img.Contains("."))
|
|
|
+ {
|
|
|
+ AiAlmFile = AiAlmFile + "/" + img;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ imgName = img;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fI++;
|
|
|
+ }
|
|
|
+ if (!System.IO.Directory.Exists(AiAlmFile))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(AiAlmFile);
|
|
|
+ }
|
|
|
+ string pathFile = AiAlmFile + "/" + imgName;
|
|
|
+ bool IsDown = true;
|
|
|
+ if (!System.IO.File.Exists(pathFile))
|
|
|
+ {
|
|
|
+ IsDown = FileHelp.FilesDown(images, pathFile);
|
|
|
+ }
|
|
|
+ if (IsDown)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(pathFile))
|
|
|
+ {
|
|
|
+ if (pathFile[0].ToString() == @"/")
|
|
|
+ {
|
|
|
+ pathFile = pathFile.Substring(1);
|
|
|
+ }
|
|
|
+ if (System.IO.File.Exists(pathFile))
|
|
|
+ {
|
|
|
+ FileStream fileStream = new FileStream(pathFile, FileMode.Open, FileAccess.Read);
|
|
|
+ run1.AddCarriageReturn();
|
|
|
+ run1.AddPicture(fileStream, 6, pathFile, Units.ToEMU(400), Units.ToEMU(300));
|
|
|
+ FileDel.Add(pathFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (files.C_Type == "FILE_TYP_003")
|
|
|
+ {
|
|
|
+ string pathFile = files.C_Url;
|
|
|
+ if (!string.IsNullOrEmpty(pathFile))
|
|
|
+ {
|
|
|
+ if (pathFile[0].ToString() == @"/")
|
|
|
+ {
|
|
|
+ pathFile = pathFile.Substring(1);
|
|
|
+ }
|
|
|
+ if (!System.IO.File.Exists(pathFile))
|
|
|
+ {
|
|
|
+ pathFile = @"wwwroot/error.png";
|
|
|
+ }
|
|
|
+ FileStream fileStream = new FileStream(pathFile, FileMode.Open, FileAccess.Read);
|
|
|
+ run1.AddCarriageReturn();
|
|
|
+ run1.AddPicture(fileStream, 6, pathFile, Units.ToEMU(100), Units.ToEMU(100));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
int serialNum = 1;
|
|
|
- foreach (var recordItem in recordItems)
|
|
|
+ foreach (var recordItem in MsgData.historyRecord)
|
|
|
{
|
|
|
if (recordItem == null) { continue; }
|
|
|
var p0 = doc.CreateParagraph();
|
|
@@ -767,6 +870,13 @@ namespace Ropin.Inspection.Api.Controllers.MTN
|
|
|
});
|
|
|
}
|
|
|
System.IO.File.Delete(zipPaht);
|
|
|
+ //foreach (var item in FileDel)
|
|
|
+ //{
|
|
|
+ // if (System.IO.File.Exists(item))
|
|
|
+ // {
|
|
|
+ // System.IO.File.Delete(item);
|
|
|
+ // };
|
|
|
+ //}
|
|
|
return new ApiResult(ReturnCode.Success);
|
|
|
}
|
|
|
catch (Exception ex)
|