|
@@ -1,9 +1,15 @@
|
|
|
using Common;
|
|
|
+using LisPacsDataUpload.Models;
|
|
|
using LisPacsDataUpload.Models.Report;
|
|
|
+using Newtonsoft.Json;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Configuration;
|
|
|
+using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Reflection;
|
|
|
using System.Text;
|
|
|
|
|
|
namespace LisPacsDataUpload.business
|
|
@@ -14,17 +20,27 @@ namespace LisPacsDataUpload.business
|
|
|
public class PdfUtils
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// 根据lis版本获取请求生成pdf报告的参数 0中联老版lis 1 中联新版lis 2 专业版临生免 3 三方lis
|
|
|
+ /// 根据lis版本获取请求生成pdf报告的参数 0中联老版lis 1 中联新版lis 2 专业版临生免 10 标准服务老版lis 11标准服务新版lis 3 三方lis
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public static string getPdfParamByLisVersion(int lisVersion,long yzid)
|
|
|
+ public static string getPdfParamByLisVersion(int lisVersion, string reportNumber,string bbid)
|
|
|
{
|
|
|
+
|
|
|
+ string dicLis = AppDomain.CurrentDomain.BaseDirectory + "Lis\\";
|
|
|
+
|
|
|
+ if (!Directory.Exists(dicLis))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(dicLis);
|
|
|
+ }
|
|
|
+ string path = dicLis + "LIS" + bbid+ ".pdf";
|
|
|
Paramater paramter = new Paramater
|
|
|
{
|
|
|
ZlSysCode = 2500,
|
|
|
- PdfPath = $"pdf={AppDomain.CurrentDomain.BaseDirectory}PDF\\Report\\LIS{yzid}.pdf"
|
|
|
+ RePortCode = reportNumber,
|
|
|
+ PdfPath = $"pdf={path}",
|
|
|
+ InvokeType = 4
|
|
|
};
|
|
|
-
|
|
|
+ paramter.Params.Add(new SubParameter { Param = $"标本id={bbid}" });
|
|
|
if (lisVersion==0)
|
|
|
{
|
|
|
//老版lis
|
|
@@ -38,9 +54,23 @@ namespace LisPacsDataUpload.business
|
|
|
else if (lisVersion == 1)
|
|
|
{
|
|
|
// 新版lis
|
|
|
- /* Select distinct 'ZLLISBILL00' || Decode(b.病人来源, 2, c.住院单据, 3, c.体检单据, 4, c.院外单据, c.门诊单据) || '-2' 报表编号, a.Id 标本id
|
|
|
-From 检验报告记录 A, 检验申请组合 B, 检验仪器记录 C
|
|
|
-Where a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
|
|
|
+ /* Select distinct 'ZLLISBILL00' || Decode(b.病人来源, 2, c.住院单据, 3, c.体检单据, 4, c.院外单据, c.门诊单据) || '-2' 报表编号, a.Id 标本id
|
|
|
+ From 检验报告记录 A, 检验申请组合 B, 检验仪器记录 C
|
|
|
+ Where a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
|
|
|
+ string strJson= JsonConvert.SerializeObject(paramter);
|
|
|
+ LogHelper.Info("strJson=="+ strJson);
|
|
|
+ if (!Init())
|
|
|
+ {
|
|
|
+ LogHelper.Info("Init初始化异常");
|
|
|
+ return "Init初始化异常";
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成pdf成功
|
|
|
+ if (OutPdf(strJson))
|
|
|
+ {
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
else if (lisVersion == 2)
|
|
@@ -53,17 +83,24 @@ Where a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
|
|
|
{
|
|
|
// 三方lis
|
|
|
}
|
|
|
+ return "失败";
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ public static string GeneratePdf(int lisVersion, string reportNumber, string bbid)
|
|
|
+ {
|
|
|
+ return getPdfParamByLisVersion(lisVersion, reportNumber, bbid);
|
|
|
}
|
|
|
|
|
|
- public bool GeneratePdf()
|
|
|
+
|
|
|
+ //调用exe
|
|
|
+ public static bool CallingProgram(string strJson)
|
|
|
{
|
|
|
+
|
|
|
// 定义要启动的外部程序的路径
|
|
|
- string exePath = @"C:\Path\To\Your\Program.exe";
|
|
|
+ string exePath = @"C:\APPSOFT\ReportPrint\zlgyReport.exe";
|
|
|
|
|
|
// 定义要传递给外部程序的参数
|
|
|
- string arguments = "strJson value1";
|
|
|
+ string arguments = "strJson " + strJson;
|
|
|
|
|
|
// 创建一个新的 ProcessStartInfo 对象
|
|
|
ProcessStartInfo startInfo = new ProcessStartInfo
|
|
@@ -73,7 +110,7 @@ Where a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
|
|
|
RedirectStandardOutput = false, // 是否重定向标准输出(根据需要设置)
|
|
|
RedirectStandardError = false, // 是否重定向标准错误(根据需要设置)
|
|
|
UseShellExecute = true, // 是否使用操作系统的 shell 启动进程(通常设置为 true)
|
|
|
- CreateNoWindow = true // 是否创建窗口(如果不需要显示窗口,可以设置为 true)
|
|
|
+ CreateNoWindow = false // 是否创建窗口(如果不需要显示窗口,可以设置为 true)
|
|
|
};
|
|
|
try
|
|
|
{
|
|
@@ -85,8 +122,11 @@ Where a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
|
|
|
process.WaitForExit();
|
|
|
LogHelper.Info("成功生成lis报告");
|
|
|
// 如果需要读取输出或错误,可以在这里处理
|
|
|
- // string output = process.StandardOutput.ReadToEnd();
|
|
|
- // string error = process.StandardError.ReadToEnd();
|
|
|
+ string output = process.StandardOutput.ReadToEnd();
|
|
|
+ string error = process.StandardError.ReadToEnd();
|
|
|
+
|
|
|
+ LogHelper.Info("output==" + output);
|
|
|
+ LogHelper.Info("error==" + error);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -97,6 +137,62 @@ Where a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ static object Instance = null;
|
|
|
+ public static bool Init()
|
|
|
+ {
|
|
|
+ if (Instance != null )
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ var para = JsonConvert.SerializeObject(new UserLogin
|
|
|
+ {
|
|
|
+ UserName = ConfigurationManager.AppSettings["UserName"],
|
|
|
+ PassWord = ConfigurationManager.AppSettings["PasWord"],
|
|
|
+ Server = ConfigurationManager.AppSettings["Server"]
|
|
|
+ });
|
|
|
+ LogHelper.Info("初始化入参" + para);
|
|
|
+ string strReval = string.Empty;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Process.GetProcessesByName("zlgyReport").ToList().ForEach(x => x.Kill());
|
|
|
+ }
|
|
|
+ catch (Exception ex) {
|
|
|
+ LogHelper.Info("进程结束异常" + ex.Message); }
|
|
|
+ var type = Type.GetTypeFromProgID("zlgyReport.clsGyReport");
|
|
|
+ Instance = Activator.CreateInstance(type);
|
|
|
+ ParameterModifier modifier = new ParameterModifier(2);
|
|
|
+ modifier[1] = true;
|
|
|
+ var result = type.InvokeMember("Init", BindingFlags.Default | BindingFlags.InvokeMethod, null, Instance, new object[] { para, strReval },
|
|
|
+ new ParameterModifier[] { modifier },
|
|
|
+ null,
|
|
|
+ new string[] { "strJson", "strResult" });
|
|
|
+ LogHelper.Info("出参:" + strReval);
|
|
|
+ LogHelper.Info("返回:" + result.ToString());
|
|
|
+ return (bool)result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool OutPdf(string para)
|
|
|
+ {
|
|
|
+ var type = Type.GetTypeFromProgID("zlgyReport.clsGyReport");
|
|
|
+ ParameterModifier modifier = new ParameterModifier(2);
|
|
|
+ modifier[1] = true;
|
|
|
+ string strReval = string.Empty;
|
|
|
+ var result = type.InvokeMember("ReportOpen", BindingFlags.Default | BindingFlags.InvokeMethod, null, Instance, new object[] { para, strReval },
|
|
|
+ new ParameterModifier[] { modifier },
|
|
|
+ null,
|
|
|
+ new string[] { "strJson", "strResult" });
|
|
|
+ LogHelper.Info("出参:" + strReval);
|
|
|
+ LogHelper.Info("返回:" + result.ToString());
|
|
|
+ return (bool)result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public class UserLogin
|
|
|
+ {
|
|
|
+ public string UserName { get; set; }
|
|
|
+ public string PassWord { get; set; }
|
|
|
+ public string Server { get; set; }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|