|
@@ -3,8 +3,10 @@ using iTextSharp.text;
|
|
|
using iTextSharp.text.pdf;
|
|
|
using LisPacsDataUpload.business;
|
|
|
using LisPacsDataUpload.Models;
|
|
|
+using LisPacsDataUpload.services;
|
|
|
using Newtonsoft.Json;
|
|
|
using System;
|
|
|
+using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
@@ -29,6 +31,7 @@ namespace LisPacsDataUpload
|
|
|
// int PageStart = (PageIndex - 1) * PageSize + 1;
|
|
|
//int PageEnd = PageSize * PageIndex;
|
|
|
private int UploadPacs;//是否上传pacs
|
|
|
+ private int UploadLis;//是否上传 Lis
|
|
|
private string ShowLog = "";
|
|
|
private int Lis_total = 0;//今日lis上传总数
|
|
|
private int pacs_total = 0;//今日pacs上传总数
|
|
@@ -40,6 +43,8 @@ namespace LisPacsDataUpload
|
|
|
private int open_multiple_upload_flag = 0;// 开启多个线程上传
|
|
|
|
|
|
string lis_upload_url = "http://40.26.204.3:8084/phimp-napi/qyhrlischeckreportinfo/save"; //lis 上传接口地址
|
|
|
+ string pacs_upload_url = "http://40.26.204.3:8084/phimp-napi/qyhrpacscheckreportinfo/save"; //pacs 上传地址
|
|
|
+
|
|
|
string file_url = "http://40.26.204.3:8084/phimp-napi/attachMent/upload"; // 文件上传地址
|
|
|
private delegate void SetTextCallback(string text);
|
|
|
//在给textBox1.text赋值的地方调用以下方法即可
|
|
@@ -60,7 +65,11 @@ namespace LisPacsDataUpload
|
|
|
ShowCheckBox1();
|
|
|
ShowCheckBox2();
|
|
|
UploadPacs = OracleHelper<object>.UploadPacs();
|
|
|
- GetLisDefault();
|
|
|
+ UploadLis = OracleHelper<object>.UploadLis();
|
|
|
+ if (UploadLis == 1)
|
|
|
+ {
|
|
|
+ GetLisDefault();
|
|
|
+ }
|
|
|
if (UploadPacs == 1)
|
|
|
{
|
|
|
GetPacsDefault();
|
|
@@ -264,33 +273,36 @@ namespace LisPacsDataUpload
|
|
|
return;
|
|
|
}
|
|
|
LogHelper.Info("zlhr=="+zlhr);
|
|
|
- string name = "LIS1" + Tools.GuidTo16String();
|
|
|
- Thread th = new Thread(new ParameterizedThreadStart(CountUpload));
|
|
|
- th.IsBackground = true;
|
|
|
- th.Name = name;
|
|
|
- th.Start(name);
|
|
|
- System.Threading.Thread.Sleep(5000);
|
|
|
- string name2 = "LIS2" + Tools.GuidTo16String();
|
|
|
- Thread th2 = new Thread(new ParameterizedThreadStart(LisUpload));
|
|
|
- th2.IsBackground = true;
|
|
|
- th2.Name = name2;
|
|
|
- th2.Start(name2);
|
|
|
-
|
|
|
- // 开启第二个上传
|
|
|
- if (1== open_multiple_upload_flag)
|
|
|
+ if (UploadLis == 1)
|
|
|
{
|
|
|
+ string name = "LIS1" + Tools.GuidTo16String();
|
|
|
+ Thread th = new Thread(new ParameterizedThreadStart(CountUpload));
|
|
|
+ th.IsBackground = true;
|
|
|
+ th.Name = name;
|
|
|
+ th.Start(name);
|
|
|
System.Threading.Thread.Sleep(5000);
|
|
|
- string name3 = "LIS3" + Tools.GuidTo16String();
|
|
|
- Thread th3 = new Thread(new ParameterizedThreadStart(LisUpload2));
|
|
|
- th3.IsBackground = true;
|
|
|
- th3.Name = name3;
|
|
|
- th3.Start(name3);
|
|
|
+ string name2 = "LIS2" + Tools.GuidTo16String();
|
|
|
+ Thread th2 = new Thread(new ParameterizedThreadStart(LisUpload));
|
|
|
+ th2.IsBackground = true;
|
|
|
+ th2.Name = name2;
|
|
|
+ th2.Start(name2);
|
|
|
+
|
|
|
+ // 开启第二个上传
|
|
|
+ if (1 == open_multiple_upload_flag)
|
|
|
+ {
|
|
|
+ System.Threading.Thread.Sleep(5000);
|
|
|
+ string name3 = "LIS3" + Tools.GuidTo16String();
|
|
|
+ Thread th3 = new Thread(new ParameterizedThreadStart(LisUpload2));
|
|
|
+ th3.IsBackground = true;
|
|
|
+ th3.Name = name3;
|
|
|
+ th3.Start(name3);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (UploadPacs == 1)//没传影像云的需要上传检查
|
|
|
{
|
|
|
LogHelper.Info("没传影像云的需要上传检查");
|
|
|
- Thread thp = new Thread(new ThreadStart(PacsUpload));
|
|
|
+ Thread thp = new Thread(new ThreadStart(PacsUploadNew));
|
|
|
thp.IsBackground = true;
|
|
|
thp.Name = "PACS" + Tools.GuidTo16String();
|
|
|
thp.Start();
|
|
@@ -1885,6 +1897,287 @@ namespace LisPacsDataUpload
|
|
|
}
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PacsUploadNew()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ lock (PacsLock)
|
|
|
+ {
|
|
|
+ int uploaded = 0;
|
|
|
+ // string url_pacs = "http://40.26.204.3:8084/phimp-napi/qyhrpacscheckreportinfo/save";
|
|
|
+ #region 1、生成、上传单条PACS文件及数据
|
|
|
+ LogHelper.Info("[PACS]开始");
|
|
|
+
|
|
|
+ DataTable dt = PacsUploadServiceImpl.getPacsDataTable();
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ ShowLog = "本次需上传[PACS]数据总条数为[" + dt.Rows.Count + "]条,逐条上传中,请耐心等待。";
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ int countAll = 0;
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ string reportId = dt.Rows[i]["reportId"].ToString();
|
|
|
+ string businessNumber = dt.Rows[i]["businessNumber"].ToString();
|
|
|
+ #region 获取报告数据并生成报告 开始
|
|
|
+
|
|
|
+ string orgName = dt.Rows[i]["orgName"].ToString();
|
|
|
+ string name = dt.Rows[i]["patientName"].ToString();
|
|
|
+ string sex = dt.Rows[i]["sex"].ToString();
|
|
|
+ string ch = dt.Rows[i]["bedNo"].ToString();
|
|
|
+ string zyh = dt.Rows[i]["zyh"].ToString();
|
|
|
+ string mzh = dt.Rows[i]["mzh"].ToString();//patientType
|
|
|
+ string age = dt.Rows[i]["age"].ToString();
|
|
|
+ string type;
|
|
|
+ string patientType = dt.Rows[i]["patientType"].ToString();
|
|
|
+ string dep = dt.Rows[i]["dep"].ToString();
|
|
|
+ if (patientType == "1")
|
|
|
+ {
|
|
|
+ type = "门诊";
|
|
|
+ }
|
|
|
+ else if (patientType == "2")
|
|
|
+ {
|
|
|
+ type = "住院";
|
|
|
+ }
|
|
|
+ else if (patientType == "3")
|
|
|
+ {
|
|
|
+ type = "体检";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ type = "其他";
|
|
|
+ }
|
|
|
+ string baseInfo = "姓名:{0} 性别:{1} 年龄:{2} 病人来源:{3} 床号:{4} 住院号:{5} 门诊号:{6} 申请科室:{7}";
|
|
|
+ string findings = dt.Rows[i]["findings"].ToString();
|
|
|
+ string diagnosResult = dt.Rows[i]["diagnosResult"].ToString();
|
|
|
+ string signature = "签名:{0} 日期:{1}";
|
|
|
+ string qname = dt.Rows[i]["auditorName"].ToString();
|
|
|
+ string qdate = dt.Rows[i]["auditTime"].ToString();
|
|
|
+ signature = string.Format(signature, qname, qdate);
|
|
|
+ baseInfo = string.Format(baseInfo, name, sex, age, type, ch, zyh, mzh, dep);
|
|
|
+ string res = CreatePDF(orgName, baseInfo, findings, diagnosResult, signature);
|
|
|
+ if (res == "")
|
|
|
+ {
|
|
|
+ ShowLog = "生成PACS的PDF文件失败。[PACS]上传失败!跳过本条数据上传下一条。";
|
|
|
+ LogHelper.Info(ShowLog);
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //获取报告数据并生成报告 结束
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ // 这里需要获取原始报告
|
|
|
+
|
|
|
+
|
|
|
+ //是否授权
|
|
|
+ if (!isAuthorization())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ string base64FileContent = Tools.FileToBase64Str(res);
|
|
|
+
|
|
|
+ ResFile resfile = PdfUtils.uploadFileToPlatform(file_url, base64FileContent);
|
|
|
+ if (resfile.statusCode != "1")
|
|
|
+ {
|
|
|
+ LogHelper.Info(resfile.message + ",[PACS]文件上传失败,跳过本条数据上传下一条。报告id = "+ reportId);
|
|
|
+ ShowLog = reportId+" 报告上传失败,[PACS]文件上传失败,跳过本条数据上传下一条。";
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int file_count = PacsUploadServiceImpl.insertPdfForPacs(businessNumber, reportId,resfile.mainBody.attachmentId);
|
|
|
+ if (file_count < 1)
|
|
|
+ {
|
|
|
+ ShowLog = "[PACS]新增表【已上传PDF】失败,跳过本条数据上传下一条。!";
|
|
|
+ LogHelper.Info(ShowLog);
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ countAll += 1;
|
|
|
+
|
|
|
+ //上传数据
|
|
|
+
|
|
|
+ List<PACS> list = PacsUploadServiceImpl.beginUploadPacsData(businessNumber,reportId);
|
|
|
+ if (list.Count < 1)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Dictionary<string, object>> plist = new List<Dictionary<string, object>>();
|
|
|
+ Dictionary<string, object> dic = new Dictionary<string, object>();
|
|
|
+ foreach (var property in list[0].GetType().GetProperties())
|
|
|
+ {
|
|
|
+ dic.Add(property.Name, property.GetValue(list[0], null));
|
|
|
+ }
|
|
|
+ string lisitems_sql = @"Select * From pacs_upload_items t Where t.yzxgid = " + list[0].YZID + "";
|
|
|
+ List<PacsItems> pacsItems = new List<PacsItems>();
|
|
|
+ if (zlhr == zlhrConstant_true)
|
|
|
+ {
|
|
|
+ pacsItems = OracleHelper<PacsItems>.PgRunQueryList(lisitems_sql);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pacsItems = OracleHelper<PacsItems>.RunQueryList(lisitems_sql);
|
|
|
+ }
|
|
|
+ if (pacsItems.Count < 1)
|
|
|
+ {
|
|
|
+ LogHelper.Info("查询pacs检查项目明细数据为空,跳过本条数据上传下一条。");
|
|
|
+ LogHelper.Info("执行sql:" + lisitems_sql);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ /*if (zlhr == zlhrConstant_true)
|
|
|
+ {
|
|
|
+ //处理 互认编码的数据
|
|
|
+ HandleLisItemDataForWebLis(lisitems);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ dic.Add("ITEMLIST", pacsItems);
|
|
|
+ plist.Add(dic);
|
|
|
+ if (!isAuthorization())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ string json_pacs = JsonConvert.SerializeObject(plist);
|
|
|
+ //string json_pacs = Tools.ObjectToJson<List<PACS>>(list, Encoding.UTF8);
|
|
|
+ json_pacs = "{\"mainBody\":" + json_pacs + "}";
|
|
|
+ string json_pacs_log = json_pacs;
|
|
|
+ string vi_pacs = Tools.GuidTo16String();
|
|
|
+ json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
|
|
|
+ string res_pacs = Tools.WSCenterData(pacs_upload_url, json_pacs, vi_pacs, Tools.accessToken, 1);
|
|
|
+ string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
|
|
|
+ //LogHelper.Info("[PACS]上传出参:" + res_aes_pacs);
|
|
|
+ ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
|
|
|
+ if (respacs.statusCode != "1")
|
|
|
+ {
|
|
|
+ ShowLog = respacs.message + ",[PACS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ LogHelper.Info("[PACS]出错入参:" + json_pacs_log);
|
|
|
+ LogHelper.Info("[PACS]出错出参:" + res_aes_pacs);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pacs_total += 1;
|
|
|
+ uploaded += 1;
|
|
|
+ int upload_count = PacsUploadServiceImpl.updatePdfForPacs(businessNumber,reportId);
|
|
|
+ if (upload_count < 1)
|
|
|
+ {
|
|
|
+ LogHelper.Info("[PACS]更新表【已上传PDF】失败,跳过本条数据上传下一条!"+ reportId);
|
|
|
+ ShowLog = "[PACS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + reportId;
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ShowLog = "本次已生成、上传[PACS]PDF文件总条数为[" + countAll + "]条,上传[PACS]总条数为[" + uploaded + "]条。";
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ LogHelper.Info(ShowLog);
|
|
|
+ GetPacsDefault();
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ #region 2、补传失败数据
|
|
|
+ //上传数据
|
|
|
+ LogHelper.Info("PACS补传失败数据");
|
|
|
+
|
|
|
+ ShowLog = "PACS补传失败数据开始";
|
|
|
+ this.SetText(ShowLog);
|
|
|
+
|
|
|
+ List<PACS> list_pc = PacsUploadServiceImpl.completUploadPacsData();
|
|
|
+ if (list_pc.Count < 1)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int count_pc = 0;
|
|
|
+ for (int i = 0; i < list_pc.Count; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ List<Dictionary<string, object>> plist_pc = new List<Dictionary<string, object>>();
|
|
|
+ Dictionary<string, object> dic_pc = new Dictionary<string, object>();
|
|
|
+ foreach (var property in list_pc[i].GetType().GetProperties())
|
|
|
+ {
|
|
|
+ dic_pc.Add(property.Name, property.GetValue(list_pc[i], null));
|
|
|
+ }
|
|
|
+ string pacsitems_sql = @"Select * From pacs_upload_items t Where t.yzxgid = " + list_pc[i].YZID + "";
|
|
|
+ List<PacsItems> pacsItems = new List<PacsItems>();
|
|
|
+ if (zlhr == zlhrConstant_true)
|
|
|
+ {
|
|
|
+ pacsItems = OracleHelper<PacsItems>.PgRunQueryList(pacsitems_sql);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pacsItems = OracleHelper<PacsItems>.RunQueryList(pacsitems_sql);
|
|
|
+ }
|
|
|
+ if (pacsItems.Count < 1)
|
|
|
+ {
|
|
|
+ LogHelper.Info("查询pacs检查项目明细数据为空,跳过本条数据上传下一条。");
|
|
|
+ LogHelper.Info("执行sql:" + pacsitems_sql);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ dic_pc.Add("ITEMLIST", pacsItems);
|
|
|
+ plist_pc.Add(dic_pc);
|
|
|
+ if (!isAuthorization())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ string json_pacs = JsonConvert.SerializeObject(plist_pc);
|
|
|
+ //string json_pacs = Tools.ObjectToJson<List<PACS>>(list_pc[i], Encoding.UTF8);
|
|
|
+ json_pacs = "{\"mainBody\":[" + json_pacs + "]}";
|
|
|
+ string json_pacs_log = json_pacs;
|
|
|
+ string vi_pacs = Tools.GuidTo16String();
|
|
|
+ json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
|
|
|
+ string res_pacs = Tools.WSCenterData(pacs_upload_url, json_pacs, vi_pacs, Tools.accessToken, 1);
|
|
|
+ string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
|
|
|
+ //LogHelper.Info("[PACS]上传出参:" + res_aes_pacs);
|
|
|
+ ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
|
|
|
+ if (respacs.statusCode != "1")
|
|
|
+ {
|
|
|
+ ShowLog = respacs.message + ",[PACS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ LogHelper.Info("[PACS]出错入参:" + json_pacs_log);
|
|
|
+ LogHelper.Info("[PACS]出错出参:" + res_aes_pacs);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pacs_total += 1;
|
|
|
+ count_pc += 1;
|
|
|
+ string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 1
|
|
|
+ and BUSINESSNUMBER = '{0}'
|
|
|
+ and REPORTID = '{1}'";
|
|
|
+ sql_upload = string.Format(sql_upload, list_pc[i].BUSINESSNUMBER, list_pc[i].REPORTID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
|
|
+ int upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
|
|
|
+ if (upload_count < 1)
|
|
|
+ {
|
|
|
+ LogHelper.Info("[PACS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
|
|
|
+ LogHelper.Info("执行sql:" + sql_upload);
|
|
|
+ ShowLog = "[PACS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count_pc > 0)
|
|
|
+ {
|
|
|
+ ShowLog = "本次补传[PACS]数据为[" + count_pc + "]条,等待下一次轮询。";
|
|
|
+ this.SetText(ShowLog);
|
|
|
+ LogHelper.Info(ShowLog);
|
|
|
+ GetPacsDefault();
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.Error(ex);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 生成pdf
|