12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027 |
- using Common;
- using iTextSharp.text;
- using iTextSharp.text.pdf;
- using LisPacsDataUpload.Models;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
- using System.Xml;
- namespace LisPacsDataUpload
- {
- public partial class Form1 : Form
- {
- private static int zlhrConstant_true=1;// 是临生免 常量
- //定时器
- private System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
- //private DateTime Date;
- //private int PageSize = 10;
- //private int PageIndex = 0;
- //PageIndex = PageIndex + 1;
- // int PageStart = (PageIndex - 1) * PageSize + 1;
- //int PageEnd = PageSize * PageIndex;
- private int UploadPacs;//是否上传pacs
- private string ShowLog = "";
- private int Lis_total = 0;//今日lis上传总数
- private int pacs_total = 0;//今日pacs上传总数
- private string DicPacs = AppDomain.CurrentDomain.BaseDirectory + "Pacs\\";
- private string DicLis = AppDomain.CurrentDomain.BaseDirectory + "Lis\\";
- private int zlhr = 0;// 是否为临生免
- private int open_multiple_upload_flag = 0;// 开启多个线程上传
- private delegate void SetTextCallback(string text);
- //在给textBox1.text赋值的地方调用以下方法即可
- public Form1()
- {
- InitializeComponent();
- this.MinimumSize = new Size(0, 0);
- timer1.Interval = OracleHelper<object>.Time();
- timer1.Enabled = true;
- timer1.Tick += new EventHandler(DataUpload);//添加事件
- timer1.Start();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- ShowLog = "启动正常。";
- LogHelper.Info(ShowLog);
- this.SetText(ShowLog);
- ShowCheckBox1();
- ShowCheckBox2();
- UploadPacs = OracleHelper<object>.UploadPacs();
- GetLisDefault();
- if (UploadPacs == 1)
- {
- GetPacsDefault();
- }
- //AutoStart();
- DataUpload(sender, e);
- }
- private void ShowCheckBox1()
- {
- string sql_lis = @"select 互认,zlhr,open_multiple_upload from 互认配置表";
- DataTable dt_lis = OracleHelper<object>.RunQueryDS(sql_lis);
- int total = int.Parse(dt_lis.Rows[0]["互认"].ToString());
- if (total == 1)
- {
- checkBox1.Checked = true;
- }
- else
- {
- checkBox1.Checked = false;
- }
- int zlhrValue = int.Parse(dt_lis.Rows[0]["zlhr"].ToString());
- if (zlhrValue == zlhrConstant_true)
- {
- zlhr= zlhrValue;
- }
- open_multiple_upload_flag = int.Parse(dt_lis.Rows[0]["open_multiple_upload"].ToString());
- }
- private void ShowCheckBox2()
- {
- XmlDocument xmldoc = new XmlDocument();
- string xmlpath = AppDomain.CurrentDomain.BaseDirectory + "Xml.xml";
- xmldoc.Load(xmlpath);
- string str = xmldoc.SelectSingleNode("/root/key").InnerXml;
- if (str == "0")
- {
- checkBox2.Checked = false;
- }
- else
- {
- checkBox2.Checked = true;
- }
- }
- /// <summary>
- /// 开机启动
- /// </summary>
- private void AutoStart()
- {
- try
- {
- XmlDocument xmldoc = new XmlDocument();
- string xmlpath = AppDomain.CurrentDomain.BaseDirectory + "Xml.xml";
- xmldoc.Load(xmlpath);
- string str = xmldoc.SelectSingleNode("/root/key").InnerXml;
- if (str == "0")
- {
- string regPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
- string path = Application.ExecutablePath.ToLower(); //将当前程序起动路径
- string name = System.IO.Path.GetFileName(path); //获得应用程序名称
- var regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regPath, true);
- if (regKey != null && regKey.GetValue("LisPacsDataUpload") == null)
- {
- regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(regPath);
- regKey.SetValue("LisPacsDataUpload", path);
- regKey.Close();
- }
- XmlElement element = (XmlElement)xmldoc.SelectSingleNode("/root/key");
- element.InnerText = "1";
- xmldoc.Save(xmlpath);
- ShowLog = "写入注册表成功。";
- this.SetText(ShowLog);
- LogHelper.Info("写入注册表成功。");
- }
- else
- {
- ShowLog = "不允许此操作!";
- this.SetText(ShowLog);
- if (checkBox2.Checked)
- {
- checkBox2.Checked = false;
- }
- else
- {
- checkBox2.Checked = true;
- }
- }
- }
- catch (Exception ex)
- {
- //ShowLog = "不允许此操作!";
- //this.SetText(ShowLog);
- if (checkBox2.Checked)
- {
- checkBox2.Checked = false;
- }
- else
- {
- checkBox2.Checked = true;
- }
- ShowLog = "写入注册表异常:" + ex.Message;
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- }
- }
- private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
- {
- //switch (e.Button)
- //{
- // case System.Windows.Forms.MouseButtons.Left: //左击
- // //判断是否已经最小化于托盘
- // if (WindowState == FormWindowState.Minimized)
- // {
- // //还原窗体显示
- // WindowState = FormWindowState.Normal;
- // //激活窗体并给予它焦点
- // this.Activate();
- // //任务栏区显示图标
- // this.ShowInTaskbar = true;
- // //托盘区图标隐藏
- // notifyIcon1.Visible = false;
- // }
- // break;
- // case System.Windows.Forms.MouseButtons.Right:
- // //MessageBox.Show("右键");
- // break;
- //}
- }
- private void open_click(object sender, EventArgs e)
- {
- if (WindowState == FormWindowState.Minimized)
- {
- WindowState = FormWindowState.Normal;
- this.Activate();
- this.ShowInTaskbar = true;
- }
- }
- private void close_click(object sender, EventArgs e)
- {
- //this.Close();
- LogHelper.Info("程序退出。");
- System.Environment.Exit(0);
- }
- private void Form1_SizeChanged(object sender, EventArgs e)
- {
- //判断是否选择的是最小化按钮
- if (WindowState == FormWindowState.Minimized)
- {
- //托盘显示图标等于托盘图标对象
- //注意notifyIcon1是控件的名字而不是对象的名字
- //隐藏任务栏区图标
- this.ShowInTaskbar = false;
- //图标显示在托盘区
- notifyIcon1.Visible = true;
- }
- }
- private void DataUpload(object source, EventArgs e)
- {
- LogHelper.Info("开始轮询。");
- DateTime Date = DateTime.Now;
- int time = Date.Hour;
- int StartTime = OracleHelper<object>.StartTime();//18
- if (time == 0)
- {//今日上传数清零
- Lis_total = 0;
- pacs_total = 0;
- }
- else if (time < StartTime && time > 7)//
- {
- ShowLog = "开始轮询时间为[" + StartTime + "]点至明日早上7点,现在是" + time + "点。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- if (Directory.Exists(DicLis))
- {
- Directory.Delete(DicLis, true);
- }
- if (Directory.Exists(DicPacs))
- {
- Directory.Delete(DicPacs, true);
- }
- DelPDF();
- 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)
- {
- 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)//没传影像云的需要上传检查
- {
- Thread thp = new Thread(new ThreadStart(PacsUpload));
- thp.IsBackground = true;
- thp.Name = "PACS" + Tools.GuidTo16String();
- thp.Start();
- }
- }
- private object CountLock = new object();
- private void CountUpload(object Thname)
- {
- try
- {
- lock (CountLock)
- {
- string Thread_name = "[" + Thname.ToString() + "]";
- string url = "http://40.26.204.3:8084/phimp-napi/qyhrApplyInfo/upload";
- int success_count = 0;
- LogHelper.Info(Thread_name + "上传开单合计开始");
- string count_sql = @"select * from bill_project_view"
- ;
- List<Count> list_count = OracleHelper<Count>.RunQueryList(count_sql);
- //LogHelper.Info("list_count" + list_count);
- if (list_count.Count < 1)
- {
- LogHelper.Info(Thread_name + "本次开单无数据,等待下一次轮询。");
- LogHelper.Info("执行sql:" + count_sql);
- }
- else
- {
- for (int i = 0; i < list_count.Count; i++)
- {
- if (!isAuthorization())
- {
- continue;
- }
- Dictionary<string, object> dic_pc = new Dictionary<string, object>();
- foreach (var property in list_count[i].GetType().GetProperties())
- {
- //LogHelper.Info("[count]Name:" + property.Name);
- //LogHelper.Info("[count]value:" + property.GetValue(list_count[i], null));
- dic_pc.Add(property.Name, property.GetValue(list_count[i], null));
- }
- string json_count = JsonConvert.SerializeObject(dic_pc);
- string json_count_log = json_count;
- string vi_count = Tools.GuidTo16String();
- json_count = Tools.AESEncrypt(json_count, Tools.pwd, vi_count);
- string res_pacs_pc = Tools.WSCenterData(url, json_count, vi_count, Tools.accessToken, 1);
- string res_aes_pacs_pc = Tools.AESDecrypt(res_pacs_pc, Tools.pwd, vi_count);
- ResPacs respacs_pc = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs_pc), Encoding.UTF8);
- if (respacs_pc.statusCode != "1")
- {
- ShowLog = respacs_pc.message + ",[LIS]清单数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_count;
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- LogHelper.Info("[count]出错入参:" + json_count_log);
- LogHelper.Info("[LIS]出错入参:" + json_count + "|....|" + Tools.accessToken);
- LogHelper.Info("[count]出错出参:" + res_aes_pacs_pc);
- continue;
- }
- else
- {
- // LogHelper.Info(success_count + "入参:" + json_count_log);
- //LogHelper.Info(success_count + "出参:" + respacs_pc.message);
- success_count++;
- }
- }
- LogHelper.Info("本次清单上传:" + success_count);
- }
- }
- }
- catch (Exception e)
- {
- LogHelper.Error(e);
- }
- }
- private object LisLock = new object();
- private void LisUpload(object Thname)
- {
- try
- {
- lock (LisLock)
- {
- string Thread_name = "[" + Thname.ToString() + "]";
- string url = "http://40.26.204.3:8084/phimp-napi/qyhrlischeckreportinfo/save";
- #region 1、单条上传lis文件及数据
- LogHelper.Info(Thread_name + "[LIS]开始");
- string lis_sql = @"select * from( Select rownum rn,b.* From (Select t.* from lis_upload t
- Where
- t.attachmentId Is Null
- Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss')
- ) b
- ) where rn <= 150 ";
- DataTable dt = new DataTable();
- if (zlhr == zlhrConstant_true)
- {
- lis_sql = @"Select t.* from lis_upload t Where t.attachmentId Is Null
- Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss') limit 100";
- dt = OracleHelper<object>.PgQueryDS(lis_sql);
- }
- else
- {
- dt = OracleHelper<object>.RunQueryDS(lis_sql);
- }
- LogHelper.Info("执行sql:" + lis_sql);
- if (dt.Rows.Count < 1)
- {
- LogHelper.Info(Thread_name + "本次[LIS]无数据,等待下一次轮询。");
- }
- else
- {
- ShowLog = Thread_name + "本次需上传[LIS]数据总条数为[" + dt.Rows.Count + "]条,逐条上传中,请耐心等待。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- int pdfcountAll = 0;
- int uploaded = 0;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- 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();
- string age = dt.Rows[i]["age"].ToString();
- string dep = dt.Rows[i]["dep"].ToString();
- string type;
- string title = dt.Rows[i]["reportName"].ToString();
- string patientType = dt.Rows[i]["patientType"].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 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 reportId = dt.Rows[i]["reportId"].ToString();
- string dt_sql = @"Select * From lis_upload_items t Where t.groupItemCode = '" + reportId+"'";
- LogHelper.Info("查询LIS项目指标数据执行sql:" + dt_sql);
- DataTable items = new DataTable();
- if (zlhr == zlhrConstant_true)
- {
- items = OracleHelper<object>.PgQueryDS(dt_sql);
- }
- else
- {
- items = OracleHelper<object>.RunQueryDS(dt_sql);
- }
- LogHelper.Info("查询LIS项目指标数据执行sql 条数=:" + items.Rows.Count);
- if (items.Rows.Count < 1)
- {
- LogHelper.Info("查询LIS项目指标数据为空,生成PDF失败,跳过本条数据生成下一条PDF。");
- continue;
- }
- string res = CreateLisPDF(orgName, baseInfo, items, signature, title);
- if (res == "")
- {
-
- ShowLog = "生成PDF文件失败,[LIS]上传失败!跳过本条数据上传下一条。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- continue;
- }
- //是否授权
- if (!isAuthorization())
- {
- continue;
- }
- //上传文件
- string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + Tools.FileToBase64Str(res) + "\"}";
- string file_vi = Tools.GuidTo16String();
- file_json = Tools.AESEncrypt(file_json, Tools.pwd, file_vi);
- string file_url = "http://40.26.204.3:8084/phimp-napi/attachMent/upload";
- string file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
- string file_res_aes = Tools.AESDecrypt(file_res, Tools.pwd, file_vi);
- ResFile resfile = Tools.JsonToObject<ResFile>(Tools.FormatStr(file_res_aes), Encoding.UTF8);
- if (resfile.statusCode != "1")
- {
- LogHelper.Info(resfile.message + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。");
- LogHelper.Info("入参:" + file_json);
- LogHelper.Info("出参:" + file_res_aes);
- ShowLog = "入参:" + file_json + ",出参:" + file_res_aes + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。";
- this.SetText(ShowLog);
- continue;
- }
- string sql = @"Insert Into 已上传PDF(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED,UPLOADE_TIME) Values('{0}','{1}',2,'{2}',0,to_date('{3}','yyyy/mm/dd hh24:mi:ss'))";
- sql = string.Format(sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString(), resfile.mainBody.attachmentId, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
- int file_count = 0;
- if (zlhr == zlhrConstant_true)
- {
- LogHelper.Info("sql:" + sql);
- file_count = OracleHelper<object>.PgExecuteNonQuery(sql);
- }
- else
- {
- file_count = OracleHelper<object>.ExecuteNonQuery(sql);
- }
- if (file_count < 1)
- {
- LogHelper.Info("[LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!");
- LogHelper.Info("执行sql:" + sql);
- ShowLog = "[LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql;
- this.SetText(ShowLog);
- continue;
- }
- pdfcountAll += 1;
- //上传lis数据
- string item_sql = @"select a.orgCode,
- a.orgName,
- a.orgThrdCode,
- a.reportId,
- a.reportName,
- a.requestId,
- a.barcode,
- a.sampleNo,
- a.businessNumber,
- a.patientType,
- a.patientName,
- a.patientSex,
- a.patientBirthday,
- a.patientAge,
- a.ageUnit,
- a.patientIdCard,
- a.inpatientAreaName,
- a.roomNo,
- a.bedNo,
- a.phoneNo,
- a.address,
- a.reportType,
- a.reportTypeName,
- a.sampCode,
- a.sampName,
- a.diagnosisCode,
- a.diagnosisName,
- a.resultType,
- a.applyTime,
- a.applyerCode,
- a.applyerName,
- a.applyDeptCode,
- a.applyDeptName,
- a.collectTime,
- a.collectCode,
- a.collectName,
- a.transportCode,
- a.transportName,
- a.transportDeptCode,
- a.transportDeptName,
- a.transportOrgCode,
- a.transportOrgName,
- a.acceptTime,
- a.acceptorCode,
- a.acceptorName,
- a.receiveTime,
- a.receiverCode,
- a.receiverName,
- a.checkTime,
- a.checkerCode,
- a.checkerName,
- a.checkDeptCode,
- a.checkDeptName,
- a.auditTime,
- a.auditorCode,
- a.auditorName,
- a.reportTime,
- a.reportorCode,
- a.reportorName,
- a.sampleNotes,
- a.checkPrice,
- a.attachmentId,
- a.patientId ,
- a.healthNo ,
- a.medicareNo ,
- a.socialNo ,
- a.inpatientAreaCode ,
- a.sampleName ,
- a.execHospitalCode ,
- a.execHospitalName,
- a.sameHospital,
- a.projectCode,
- a.projectName
- from lis_upload a ,已上传PDF b
- where b.businessnumber = a.BUSINESSNUMBER
- and b.reportid = a.REPORTID
- and b.attachmentid is not null
- and b.uploaded = 0
- and b.type = 2
- and a.BUSINESSNUMBER = '{0}'
- and a.REPORTID = '{1}'";
- item_sql = string.Format(item_sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString());
- List<LIS> list = new List<LIS>();
- if (zlhr == zlhrConstant_true)
- {
- list = OracleHelper<LIS>.PgRunQueryList(item_sql);
- }
- else
- {
- list = OracleHelper<LIS>.RunQueryList(item_sql);
- }
- if (list.Count < 1)
- {
- LogHelper.Info("查询LIS数据为空,跳过本条数据上传下一条。");
- LogHelper.Info("执行sql:" + item_sql);
- 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 lis_upload_items t Where t.groupItemCode = '" + list[0].REPORTID + "'";
- List<LISITEMS> lisitems = new List<LISITEMS>();
- if (zlhr == zlhrConstant_true)
- {
- lisitems = OracleHelper<LISITEMS>.PgRunQueryList(lisitems_sql);
- }
- else
- {
- lisitems = OracleHelper<LISITEMS>.RunQueryList(lisitems_sql);
- }
- if (lisitems.Count < 1)
- {
- LogHelper.Info("查询LIS项目指标数据为空,跳过本条数据上传下一条。");
- LogHelper.Info("执行sql:" + lisitems_sql);
- continue;
- }
- if (zlhr == zlhrConstant_true)
- {
- //处理 互认编码的数据
- HandleLisItemData(lisitems);
- }
- dic.Add("DETAILLIST", lisitems);
- plist.Add(dic);
- //是否授权
- if (!isAuthorization())
- {
- continue;
- }
- string json_pacs = JsonConvert.SerializeObject(plist);
- 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(url, json_pacs, vi_pacs, Tools.accessToken, 1);
- string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
- ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
- if (respacs.statusCode != "1")
- {
- ShowLog = respacs.message + ",[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- LogHelper.Info("[LIS]出错入参:" + json_pacs_log);
- LogHelper.Info("[LIS]出错出参:" + res_aes_pacs);
- continue;
- }
- else
- {
- Lis_total += 1;
- uploaded += 1;//(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED) Values('{0}','{1}',2,'{2}',0)
- string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 2
- and BUSINESSNUMBER = '{0}'
- and REPORTID = '{1}'";
- sql_upload = string.Format(sql_upload, list[0].BUSINESSNUMBER, list[0].REPORTID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
- int upload_count = 0;
- if (zlhr == zlhrConstant_true)
- {
- upload_count = OracleHelper<object>.PgExecuteNonQuery(sql_upload);
- }
- else
- {
- upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
- }
- if (upload_count < 1)
- {
- LogHelper.Info("[LIS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
- LogHelper.Info("执行sql:" + sql_upload);
- ShowLog = "[LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
- this.SetText(ShowLog);
- continue;
- }
- }
- }
- ShowLog = Thread_name + "本次已生成、上传[LIS]PDF文件总条数为[" + pdfcountAll + "]条,上传[LIS]总条数为[" + uploaded + "]条。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- GetLisDefault();
- }
- #endregion
- #region 2、补传失败lis数据
- LogHelper.Info("补传失败lis数据开始");
- ShowLog = Thread_name + "补传失败lis数据开始";
- this.SetText(ShowLog);
- this.SetText("补传失败lis数据开始");
- int count_pc = 0;
- string pc_sql = @"select a.orgCode,
- a.orgName,
- a.orgThrdCode,
- a.reportId,
- a.reportName,
- a.requestId,
- a.barcode,
- a.sampleNo,
- a.businessNumber,
- a.patientType,
- a.patientName,
- a.patientSex,
- a.patientBirthday,
- a.patientAge,
- a.ageUnit,
- a.patientIdCard,
- a.inpatientAreaName,
- a.roomNo,
- a.bedNo,
- a.phoneNo,
- a.address,
- a.reportType,
- a.reportTypeName,
- a.sampCode,
- a.sampName,
- a.diagnosisCode,
- a.diagnosisName,
- a.resultType,
- a.applyTime,
- a.applyerCode,
- a.applyerName,
- a.applyDeptCode,
- a.applyDeptName,
- a.collectTime,
- a.collectCode,
- a.collectName,
- a.transportCode,
- a.transportName,
- a.transportDeptCode,
- a.transportDeptName,
- a.transportOrgCode,
- a.transportOrgName,
- a.acceptTime,
- a.acceptorCode,
- a.acceptorName,
- a.receiveTime,
- a.receiverCode,
- a.receiverName,
- a.checkTime,
- a.checkerCode,
- a.checkerName,
- a.checkDeptCode,
- a.checkDeptName,
- a.auditTime,
- a.auditorCode,
- a.auditorName,
- a.reportTime,
- a.reportorCode,
- a.reportorName,
- a.sampleNotes,
- a.checkPrice,
- a.attachmentId,
- a.patientId ,
- a.healthNo ,
- a.medicareNo ,
- a.socialNo ,
- a.inpatientAreaCode ,
- a.sampleName ,
- a.execHospitalCode ,
- a.execHospitalName,
- a.sameHospital,
- a.projectCode,
- a.projectName
- from lis_upload a ,已上传PDF b
- where b.businessnumber = a.BUSINESSNUMBER
- and b.reportid = a.REPORTID
- and b.attachmentid is not null
- and b.uploaded = 0
- and b.type = 2
- and b.uploade_time > sysdate -5 ";
- LogHelper.Info("补传lis数据执行sql:" + pc_sql);
- List<LIS> list_pc = new List<LIS>();
- if (zlhr == zlhrConstant_true)
- {
- list_pc = OracleHelper<LIS>.PgRunQueryList(pc_sql);
- }
- else
- {
- list_pc = OracleHelper<LIS>.RunQueryList(pc_sql);
- }
- if (list_pc.Count < 1)
- {
- LogHelper.Info("查询补传[LIS]数据为空,等待下一次轮询。"+ list_pc.Count);
- return;
- }
- 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 lisitems_sql = @"Select * From lis_upload_items t Where t.groupItemCode = '" + list_pc[i].REPORTID +"'";
- List<LISITEMS> lisitems = OracleHelper<LISITEMS>.RunQueryList(lisitems_sql);
- if (zlhr == zlhrConstant_true)
- {
- lisitems = OracleHelper<LISITEMS>.PgRunQueryList(lisitems_sql);
- }
- else
- {
- lisitems = OracleHelper<LISITEMS>.RunQueryList(lisitems_sql);
- }
- if (lisitems.Count < 1)
- {
- LogHelper.Info("补传查询LIS项目指标数据为空,跳过本条数据上传下一条。");
- LogHelper.Info("执行sql:" + lisitems_sql);
- continue;
- }
- if (zlhr == zlhrConstant_true)
- {
- //处理 互认编码的数据
- HandleLisItemData(lisitems);
- }
-
- dic_pc.Add("DETAILLIST", lisitems);
- plist_pc.Add(dic_pc);
- //是否授权
- if (!isAuthorization())
- {
- continue;
- }
- string json_pacs_pc = JsonConvert.SerializeObject(plist_pc);
- json_pacs_pc = "{\"mainBody\":" + json_pacs_pc + "}";
- string json_pacs_log_pc = json_pacs_pc;
- string vi_pacs_pc = Tools.GuidTo16String();
- json_pacs_pc = Tools.AESEncrypt(json_pacs_pc, Tools.pwd, vi_pacs_pc);
- //string url_pacs = "http://40.26.204.3:8084/phimp-napi/qyhrlischeckreportinfo/save";
- string res_pacs_pc = Tools.WSCenterData(url, json_pacs_pc, vi_pacs_pc, Tools.accessToken, 1);
- string res_aes_pacs_pc = Tools.AESDecrypt(res_pacs_pc, Tools.pwd, vi_pacs_pc);
- ResPacs respacs_pc = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs_pc), Encoding.UTF8);
- if (respacs_pc.statusCode != "1")
- {
- ShowLog = respacs_pc.message + ",补传[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs_pc;
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- LogHelper.Info("[LIS]出错入参:" + json_pacs_log_pc);
- LogHelper.Info("[LIS]出错出参:" + res_aes_pacs_pc);
- continue;
- }
- else
- {
- Lis_total += 1;
- count_pc += 1;//(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED) Values('{0}','{1}',2,'{2}',0)
- string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 2
- 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 = 0;
- if (zlhr==zlhrConstant_true)
- {
- upload_count = OracleHelper<object>.PgExecuteNonQuery(sql_upload);
- }
- else
- {
- upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
- }
- if (upload_count < 1)
- {
- LogHelper.Info("补传[LIS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
- LogHelper.Info("执行sql:" + sql_upload);
- ShowLog = "补传[LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
- this.SetText(ShowLog);
- continue;
- }
- }
- ShowLog = Thread_name + "补传第"+i+"条数据成功:医嘱id=" + list_pc[i].REPORTID;
- this.SetText(ShowLog);
- }
- if (count_pc > 0)
- {
- ShowLog = Thread_name + "本次补传[LIS]数据为[" + count_pc + "]条,等待下一次轮询。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- GetLisDefault();
- }
- #endregion
- }
- }
- catch (Exception ex)
- {
- LogHelper.Error(ex);
- }
- }
- //处理编码的数据 为医保编码数据
- private void HandleLisItemData(List<LISITEMS> items)
- {
- //处理 互认编码的数据
- foreach (LISITEMS item in items)
- {
- string ITEMCODE = item.ITEMCODE;
- string sqlhis = @"Select l.医保编码 From 诊疗项目目录 x,诊疗收费关系 y,收费项目目录 z,保险支付项目 m,互认项目清单 l
- Where y.诊疗项目id = x.id And z.id = y.收费项目id And m.收费细目id = z.Id And l.医保通用编码 = m.项目编码 And Rownum = 1
- And x.类别 = 'C' And m.险类 = 111
- And x.编码 ='{0}'";
- sqlhis = string.Format(sqlhis, ITEMCODE);
- DataTable dtYbCode = OracleHelper<object>.RunQueryDS(sqlhis);
- if (dtYbCode.Rows.Count > 0)
- {
- //取出诊疗项目id 取获取收费项目的医保编码 并赋值
- item.STANDARDITEMID = dtYbCode.Rows[0]["医保编码"].ToString();
- }
- // 复制 报告id
- /* string ITEMCODE = item.STANDARDITEMID;
- string sqlhis = @"Select l.医保编码 From 诊疗项目目录 x,诊疗收费关系 y,收费项目目录 z,保险支付项目 m,互认项目清单 l
- Where y.诊疗项目id = x.id And z.id = y.收费项目id And m.收费细目id = z.Id And l.医保通用编码 = m.项目编码 And Rownum = 1
- And x.类别 = 'C' And m.险类 = 111
- And x.编码 ='{0}'";
- sqlhis = string.Format(sqlhis, ITEMCODE);
- DataTable dtYbCode = OracleHelper<object>.RunQueryDS(sqlhis);
- if (dtYbCode.Rows.Count > 0)
- {
- //取出诊疗项目id 取获取收费项目的医保编码 并赋值
- item.STANDARDITEMID = dtYbCode.Rows[0]["医保编码"].ToString();
- }*/
- }
- }
- private object LisLock2 = new object();
- private void LisUpload2(object Thname)
- {
- try
- {
- lock (LisLock2)
- {
- string Thread_name = "[" + Thname.ToString() + "]";
- string url = "http://40.26.204.3:8084/phimp-napi/qyhrlischeckreportinfo/save";
- #region 1、单条上传lis文件及数据
- LogHelper.Info(Thread_name + "[LIS]开始");
- string lis_sql = @"select * from( Select rownum rn,b.* From (Select t.* from lis_upload t
- Where
- t.attachmentId Is Null
- Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss')
- ) b
- ) where rn <300 and rn >150 ";
- DataTable dt = new DataTable();
- if (zlhr == zlhrConstant_true)
- {
- /*limit 100 offset 100*/
- lis_sql = @"Select t.* from lis_upload t Where t.attachmentId Is Null
- Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss') limit 100 offset 100";
- dt = OracleHelper<object>.PgQueryDS(lis_sql);
- }
- else
- {
- dt = OracleHelper<object>.RunQueryDS(lis_sql);
- }
- LogHelper.Info("thread2 " + lis_sql);
- if (dt.Rows.Count < 1)
- {
- LogHelper.Info(Thread_name + " thread2 本次[LIS]无数据,等待下一次轮询。");
- LogHelper.Info("thread2 执行sql:" + lis_sql);
- }
- else
- {
- ShowLog = Thread_name + "thread2 本次需上传[LIS]数据总条数为[" + dt.Rows.Count + "]条,逐条上传中,请耐心等待。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- int pdfcountAll = 0;
- int uploaded = 0;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- 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();
- string age = dt.Rows[i]["age"].ToString();
- string dep = dt.Rows[i]["dep"].ToString();
- string type;
- string title = dt.Rows[i]["reportName"].ToString();
- string patientType = dt.Rows[i]["patientType"].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 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 reportId = dt.Rows[i]["reportId"].ToString();
- string dt_sql = @"Select * From lis_upload_items t Where t.groupItemCode = '" + reportId + "'";
- LogHelper.Info("thread2 项目指标执行sql:" + dt_sql);
- DataTable items = new DataTable();
- if (zlhr==zlhrConstant_true)
- {
- items = OracleHelper<object>.PgQueryDS(dt_sql);
- }
- else
- {
- items = OracleHelper<object>.RunQueryDS(dt_sql);
- }
- LogHelper.Info("thread2 项目指标执行sql 条数:" + items.Rows.Count);
- if (items.Rows.Count < 1)
- {
- LogHelper.Info("查询LIS项目指标数据为空,生成PDF失败,跳过本条数据生成下一条PDF。");
- continue;
- }
- string res = CreateLisPDF(orgName, baseInfo, items, signature, title);
- if (res == "")
- {
- ShowLog = "生成PDF文件失败,[LIS]上传失败!跳过本条数据上传下一条。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- continue;
- }
- //是否授权
- if (!isAuthorization())
- {
- continue;
- }
- //上传文件
- string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + Tools.FileToBase64Str(res) + "\"}";
- string file_vi = Tools.GuidTo16String();
- file_json = Tools.AESEncrypt(file_json, Tools.pwd, file_vi);
- string file_url = "http://40.26.204.3:8084/phimp-napi/attachMent/upload";
- string file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
- string file_res_aes = Tools.AESDecrypt(file_res, Tools.pwd, file_vi);
- ResFile resfile = Tools.JsonToObject<ResFile>(Tools.FormatStr(file_res_aes), Encoding.UTF8);
- if (resfile.statusCode != "1")
- {
- LogHelper.Info(resfile.message + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。thread2 ");
- LogHelper.Info("入参:" + file_json);
- LogHelper.Info("出参:" + file_res_aes);
- ShowLog = "入参:" + file_json + ",出参:" + file_res_aes + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。";
- this.SetText(ShowLog);
- continue;
- }
- string sql = @"Insert Into 已上传PDF(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED,UPLOADE_TIME) Values('{0}','{1}',2,'{2}',0,to_date('{3}','yyyy/mm/dd hh24:mi:ss'))";
- sql = string.Format(sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString(), resfile.mainBody.attachmentId, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
- int file_count = 0;
- if (zlhr==zlhrConstant_true)
- {
- file_count = OracleHelper<object>.PgExecuteNonQuery(sql);
- }
- else
- {
- file_count = OracleHelper<object>.ExecuteNonQuery(sql);
- }
- if (file_count < 1)
- {
- LogHelper.Info("thread2 [LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!");
- LogHelper.Info("thread2 执行sql:" + sql);
- ShowLog = "thread2 [LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql;
- this.SetText(ShowLog);
- continue;
- }
- pdfcountAll += 1;
- //上传lis数据
- string item_sql = @"select a.orgCode,
- a.orgName,
- a.orgThrdCode,
- a.reportId,
- a.reportName,
- a.requestId,
- a.barcode,
- a.sampleNo,
- a.businessNumber,
- a.patientType,
- a.patientName,
- a.patientSex,
- a.patientBirthday,
- a.patientAge,
- a.ageUnit,
- a.patientIdCard,
- a.inpatientAreaName,
- a.roomNo,
- a.bedNo,
- a.phoneNo,
- a.address,
- a.reportType,
- a.reportTypeName,
- a.sampCode,
- a.sampName,
- a.diagnosisCode,
- a.diagnosisName,
- a.resultType,
- a.applyTime,
- a.applyerCode,
- a.applyerName,
- a.applyDeptCode,
- a.applyDeptName,
- a.collectTime,
- a.collectCode,
- a.collectName,
- a.transportCode,
- a.transportName,
- a.transportDeptCode,
- a.transportDeptName,
- a.transportOrgCode,
- a.transportOrgName,
- a.acceptTime,
- a.acceptorCode,
- a.acceptorName,
- a.receiveTime,
- a.receiverCode,
- a.receiverName,
- a.checkTime,
- a.checkerCode,
- a.checkerName,
- a.checkDeptCode,
- a.checkDeptName,
- a.auditTime,
- a.auditorCode,
- a.auditorName,
- a.reportTime,
- a.reportorCode,
- a.reportorName,
- a.sampleNotes,
- a.checkPrice,
- a.attachmentId,
- a.patientId ,
- a.healthNo ,
- a.medicareNo ,
- a.socialNo ,
- a.inpatientAreaCode ,
- a.sampleName ,
- a.execHospitalCode ,
- a.execHospitalName,
- a.sameHospital,
- a.projectCode,
- a.projectName
- from lis_upload a ,已上传PDF b
- where b.businessnumber = a.BUSINESSNUMBER
- and b.reportid = a.REPORTID
- and b.attachmentid is not null
- and b.uploaded = 0
- and b.type = 2
- and a.BUSINESSNUMBER = '{0}'
- and a.REPORTID = '{1}'";
- item_sql = string.Format(item_sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString());
- List<LIS> list = new List<LIS>();
- if (zlhr==zlhrConstant_true)
- {
- list = OracleHelper<LIS>.PgRunQueryList(item_sql);
- }
- else
- {
- list = OracleHelper<LIS>.RunQueryList(item_sql);
- }
- if (list.Count < 1)
- {
- LogHelper.Info("thread2 查询LIS数据为空,跳过本条数据上传下一条。");
- LogHelper.Info("thread2 执行sql:" + item_sql);
- 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 lis_upload_items t Where t.groupItemCode = '" + list[0].REPORTID + "'";
-
- List<LISITEMS> lisitems = new List<LISITEMS>();
- if (zlhr==zlhrConstant_true)
- {
- lisitems = OracleHelper<LISITEMS>.PgRunQueryList(lisitems_sql);
- }
- else
- {
- lisitems = OracleHelper<LISITEMS>.RunQueryList(lisitems_sql);
- }
- if (lisitems.Count < 1)
- {
- LogHelper.Info("查询LIS项目指标数据为空,跳过本条数据上传下一条。");
- LogHelper.Info("执行sql:" + lisitems_sql);
- continue;
- }
- if(zlhr == zlhrConstant_true)
- {
- //处理 互认编码的数据
- HandleLisItemData(lisitems);
- }
-
- dic.Add("DETAILLIST", lisitems);
- plist.Add(dic);
- //是否授权
- if (!isAuthorization())
- {
- continue;
- }
- string json_pacs = JsonConvert.SerializeObject(plist);
- 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(url, json_pacs, vi_pacs, Tools.accessToken, 1);
- string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
- ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
- if (respacs.statusCode != "1")
- {
- ShowLog = respacs.message + ",thread2 ,[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- LogHelper.Info("thread2 [LIS]出错入参:" + json_pacs_log);
- LogHelper.Info("thread2 [LIS]出错出参:" + res_aes_pacs);
- continue;
- }
- else
- {
- Lis_total += 1;
- uploaded += 1;//(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED) Values('{0}','{1}',2,'{2}',0)
- string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 2
- and BUSINESSNUMBER = '{0}'
- and REPORTID = '{1}'";
- sql_upload = string.Format(sql_upload, list[0].BUSINESSNUMBER, list[0].REPORTID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
- int upload_count = 0;
- if (zlhr==zlhrConstant_true)
- {
- upload_count = OracleHelper<object>.PgExecuteNonQuery(sql_upload);
- }
- else
- {
- upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
- }
- if (upload_count < 1)
- {
- LogHelper.Info("thread2 [LIS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
- LogHelper.Info("thread2 执行sql:" + sql_upload);
- ShowLog = "thread2 [LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
- this.SetText(ShowLog);
- continue;
- }
- }
- }
- ShowLog = Thread_name + "thread2 本次已生成、上传[LIS]PDF文件总条数为[" + pdfcountAll + "]条,上传[LIS]总条数为[" + uploaded + "]条。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- GetLisDefault();
- }
- #endregion
-
- }
- }
- catch (Exception ex)
- {
- LogHelper.Error(ex);
- }
- }
- private object PacsLock = new object();
- private void PacsUpload()
- {
- 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]开始");
- string sql_pdf = @"select * from (
- Select rownum as rn,b.* From (select t.* from PACS_UPLOAD t
- Where t.attachmentId Is Null
- Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss')
- ) b
- ) Where rn <= 100";
- DataTable dt = OracleHelper<object>.RunQueryDS(sql_pdf);
- if (dt.Rows.Count < 1)
- {
- LogHelper.Info("本次无数据,或[PACS]PDF已生成并上传。");
- LogHelper.Info("执行sql:" + sql_pdf);
- }
- else
- {
- ShowLog = "本次需上传[PACS]数据总条数为[" + dt.Rows.Count + "]条,逐条上传中,请耐心等待。";
- this.SetText(ShowLog);
- int countAll = 0;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- 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;
- }
- //是否授权
- if (!isAuthorization())
- {
- continue;
- }
- //string path = Application.StartupPath + "\\pacs.pdf";
- //上传文件
- string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检查报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + Tools.FileToBase64Str(res) + "\"}";
- string file_vi = Tools.GuidTo16String();
- file_json = Tools.AESEncrypt(file_json, Tools.pwd, file_vi);
- string file_url = "http://40.26.204.3:8084/phimp-napi/attachMent/upload";
- string file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
- string file_res_aes = Tools.AESDecrypt(file_res, Tools.pwd, file_vi);
- ResFile resfile = Tools.JsonToObject<ResFile>(Tools.FormatStr(file_res_aes), Encoding.UTF8);
- if (resfile.statusCode != "1")
- {
- //LogHelper.Info(resfile.message + ",[PACS]文件上传失败,跳过本条数据上传下一条。");
- LogHelper.Info("入参:" + file_json);
- LogHelper.Info("出参:" + file_res_aes);
- ShowLog = "入参:" + file_json + ",出参:" + file_res_aes + ",[PACS]文件上传失败,跳过本条数据上传下一条。";
- this.SetText(ShowLog);
- continue;
- }
- string sql = @"Insert Into 已上传PDF(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED,UPLOADE_TIME) Values('{0}','{1}',1,'{2}',0, to_date('{3}','yyyy/mm/dd hh24:mi:ss'))";
- sql = string.Format(sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString(), resfile.mainBody.attachmentId, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
- int file_count = OracleHelper<object>.ExecuteNonQuery(sql);
- if (file_count < 1)
- {
- ShowLog = "[PACS]新增表【已上传PDF】失败,跳过本条数据上传下一条。!";
- LogHelper.Info(ShowLog);
- this.SetText(ShowLog);
- continue;
- }
- countAll += 1;
- //上传数据
- string item_sql = @"select
- a.patientAge ,
- a.ageUnit ,
- a.patientIdCard ,
- a.inTime ,
- a.inpatientAreaName ,
- a.roomNo ,
- a.bedNo ,
- a.phoneNo ,
- a.address ,
- a.reportTypeName ,
- a.reportTypeCode ,
- a.diagnosisCode ,
- a.diagnosisName ,
- a.applyTime ,
- a.applyerCode ,
- a.applyerName ,
- a.applyDeptCode ,
- a.applyDeptName ,
- a.applyOrgCode ,
- a.applyOrgName ,
- a.receiverTime ,
- a.receiverCode ,
- a.receiverName ,
- a.checkTime ,
- a.checkerCode ,
- a.checkerName ,
- a.checkDeptCode ,
- a.checkDeptName ,
- a.reportTime ,
- a.reportorCode ,
- a.reportorName ,
- a.auditTime ,
- a.auditorCode ,
- a.auditorName ,
- a.localItemId ,
- a.standardItemId ,
- a.itemName ,
- a.purpose ,
- a.testPrice ,
- a.checkTypeCode ,
- a.checkTypeName ,
- a.positionCode ,
- a.positionName ,
- a.methodCode ,
- a.methodName ,
- a.isEnganced ,
- a.isMakeShadow ,
- a.process ,
- a.findings ,
- a.diagnosResult ,
- a.resultType ,
- a.unit ,
- a.machineType ,
- a.machineCode ,
- a.machineName ,
- a.attachmentId ,
- a.studyInstanceUid ,
- a.dicomImgFtpUrl ,
- a.orgCode ,
- a.orgName ,
- a.pacsYunOrgCode ,
- a.reportId ,
- a.reportName ,
- a.reportType ,
- a.requestId ,
- a.businessNumber ,
- a.patientType ,
- a.patientName ,
- a.patientSex ,
- a.patientBirthday ,
- a.regionHr
- from pacs_upload a ,已上传PDF b
- where b.businessnumber = a.BUSINESSNUMBER
- and b.reportid = a.REPORTID
- and b.attachmentid is not null
- and b.uploaded = 0
- and b.type = 1
- and a.BUSINESSNUMBER = '{0}'
- and a.REPORTID = '{1}'";
- item_sql = string.Format(item_sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString());
- List<PACS> list = OracleHelper<PACS>.RunQueryList(item_sql);
- if (list.Count < 1)
- {
- LogHelper.Info("查询PACS数据为空,跳过本条数据上传下一条。");
- LogHelper.Info("执行sql:" + item_sql);
- continue;
- }
- string json_pacs = Tools.ObjectToJson<List<PACS>>(list, Encoding.UTF8);
- json_pacs = "{\"mainBody\":" + json_pacs + "}";
- if (!isAuthorization())
- {
- continue;
- }
- 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(url_pacs, 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;//(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED) Values('{0}','{1}',2,'{2}',0)
- 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[0].BUSINESSNUMBER, list[0].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;
- }
- }
- }
- ShowLog = "本次已生成、上传[PACS]PDF文件总条数为[" + countAll + "]条,上传[PACS]总条数为[" + uploaded + "]条。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- GetPacsDefault();
- }
- #endregion
- #region 2、补传失败数据
- //上传数据
- string pc_sql = @"select
- a.patientAge ,
- a.ageUnit ,
- a.patientIdCard ,
- a.inTime ,
- a.inpatientAreaName ,
- a.roomNo ,
- a.bedNo ,
- a.phoneNo ,
- a.address ,
- a.reportTypeName ,
- a.reportTypeCode ,
- a.diagnosisCode ,
- a.diagnosisName ,
- a.applyTime ,
- a.applyerCode ,
- a.applyerName ,
- a.applyDeptCode ,
- a.applyDeptName ,
- a.applyOrgCode ,
- a.applyOrgName ,
- a.receiverTime ,
- a.receiverCode ,
- a.receiverName ,
- a.checkTime ,
- a.checkerCode ,
- a.checkerName ,
- a.checkDeptCode ,
- a.checkDeptName ,
- a.reportTime ,
- a.reportorCode ,
- a.reportorName ,
- a.auditTime ,
- a.auditorCode ,
- a.auditorName ,
- a.localItemId ,
- a.standardItemId ,
- a.itemName ,
- a.purpose ,
- a.testPrice ,
- a.checkTypeCode ,
- a.checkTypeName ,
- a.positionCode ,
- a.positionName ,
- a.methodCode ,
- a.methodName ,
- a.isEnganced ,
- a.isMakeShadow ,
- a.process ,
- a.findings ,
- a.diagnosResult ,
- a.resultType ,
- a.unit ,
- a.machineType ,
- a.machineCode ,
- a.machineName ,
- a.attachmentId ,
- a.studyInstanceUid ,
- a.dicomImgFtpUrl ,
- a.orgCode ,
- a.orgName ,
- a.pacsYunOrgCode ,
- a.reportId ,
- a.reportName ,
- a.reportType ,
- a.requestId ,
- a.businessNumber ,
- a.patientType ,
- a.patientName ,
- a.patientSex ,
- a.patientBirthday ,
- a.regionHr
- from pacs_upload a ,已上传PDF b
- where b.businessnumber = a.BUSINESSNUMBER
- and b.reportid = a.REPORTID
- and b.attachmentid is not null
- and b.uploaded = 0
- and b.type = 1";
- List<PACS> list_pc = OracleHelper<PACS>.RunQueryList(pc_sql);
- if (list_pc.Count < 1)
- {
- LogHelper.Info("查询补传PACS数据为空,等待下一次轮询。");
- LogHelper.Info("执行sql:" + pc_sql);
- return;
- }
- int count_pc = 0;
- for (int i = 0; i < list_pc.Count; i++)
- {
- if (!isAuthorization())
- {
- continue;
- }
- 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(url_pacs, 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
- /// </summary>
- /// <param name="orgName">印江自治县人民医院</param>
- /// <param name="baseInfo">"姓名:刘蚝 性别:男 年龄:20岁 床号:8床 住院号:20121545 门诊号:65478854"</param>
- /// <param name="findings"></param>
- /// <param name="diagnosResult"></param>
- /// <param name="signature">签名:杨添红 日期:2022.9.7</param>
- private string CreatePDF(string orgName, string baseInfo, string findings, string diagnosResult, string signature)
- {
- string res = "";
- try
- {
- Document document = new Document(HeaderAndFooterEvent.rect);
- //string dic = AppDomain.CurrentDomain.BaseDirectory + "Pacs\\";
- if (!Directory.Exists(DicPacs))
- {
- Directory.CreateDirectory(DicPacs);
- }
- string path = DicPacs + Guid.NewGuid() + ".pdf";
- //此处使用的是http请求的流,你也可以使用文件流Stream
- FileStream str = new FileStream(path, FileMode.Create);
- PdfWriter writer = PdfWriter.GetInstance(document, str);
- document.Open();
- writer.PageEvent = new HeaderAndFooterEvent();
- HeaderAndFooterEvent.PAGE_NUMBER = false;//实现页眉跟页脚
- HeaderAndFooterEvent.tpl = writer.DirectContent.CreateTemplate(500, 500); //定义模板
- //印江自治县人民医院
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
- document.Add(HeaderAndFooterEvent.AddParagraph(orgName, 1, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
- document.Add(HeaderAndFooterEvent.AddParagraph("检查报告单", 1, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
- document.Add(HeaderAndFooterEvent.AddParagraph(baseInfo, 0, 3f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
- document.Add(HeaderAndFooterEvent.AddParagraph(" ", 1, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
- document.Add(HeaderAndFooterEvent.AddParagraph(@"诊断意见:" + diagnosResult, 0, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
- document.Add(HeaderAndFooterEvent.AddParagraph(@"检查所见:" + findings, 0, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
- document.Add(HeaderAndFooterEvent.AddParagraph(" ", 1, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
- document.Add(HeaderAndFooterEvent.AddParagraph(signature, 2, 1.5f));
- writer.Flush();
- writer.CloseStream = true;
- document.Close();
- //writer.Close();
- //str.Close();
- res = path;
- }
- catch (Exception ex)
- {
- res = "";
- LogHelper.Error(ex);
- }
- return res;
- }
- private string CreateLisPDF(string orgName, string baseInfo, DataTable dt, string signature, string title)
- {
- string res = "";
- try
- {
- Document document = new Document(HeaderAndFooterEvent.rect);
- //此处使用的是http请求的流,你也可以使用文件流Stream
- //string dic = AppDomain.CurrentDomain.BaseDirectory + "Lis\\";
- if (!Directory.Exists(DicLis))
- {
- Directory.CreateDirectory(DicLis);
- }
- string path = DicLis + Guid.NewGuid() + ".pdf";
- FileStream str = new FileStream(path, FileMode.Create);
- PdfWriter writer = PdfWriter.GetInstance(document, str);
- document.Open();
- writer.PageEvent = new HeaderAndFooterEvent();
- HeaderAndFooterEvent.PAGE_NUMBER = false;//实现页眉跟页脚
- HeaderAndFooterEvent.tpl = writer.DirectContent.CreateTemplate(500, 500); //定义模板
- //印江自治县人民医院
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
- document.Add(HeaderAndFooterEvent.AddParagraph(orgName, 1, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
- document.Add(HeaderAndFooterEvent.AddParagraph(title + "报告单", 1, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
- document.Add(HeaderAndFooterEvent.AddParagraph(baseInfo, 0, 3f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
- document.Add(HeaderAndFooterEvent.AddParagraph(" ", 1, 1.5f));
- //HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
- //document.Add(HeaderAndFooterEvent.AddParagraph(@"序号 项目 结果 单位 参考区间", 0, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
- HeaderAndFooterEvent.CreateTable(dt, document);
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
- document.Add(HeaderAndFooterEvent.AddParagraph(" ", 1, 1.5f));
- HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
- document.Add(HeaderAndFooterEvent.AddParagraph(signature, 2, 1.5f));
- writer.Flush();
- writer.CloseStream = true;
- document.Close();
- res = path;
- }
- catch (Exception ex)
- {
- LogHelper.Info("CreateLisPDF 生成失败");
- res = "";
- LogHelper.Error(ex);
- }
- return res;
- }
- //token是否过期
- private bool isAuthorization()
- {
- bool result = true;
- if (string.IsNullOrWhiteSpace(Tools.accessToken) || Tools.DateTimes == null || Tools.DateTimes <= DateTime.Now)
- {
- //获取授权
- string vi = Tools.GuidTo16String();
- string url = "http://40.26.204.3:8084/phimp-napi/token";
- string res = Tools.WSCenterData(url, "", vi);
- string res_aes = Tools.AESDecrypt(res, Tools.pwd, vi);
- Authorization ahz = Tools.JsonToObject<Authorization>(Tools.FormatStr(res_aes), Encoding.UTF8);
- if (ahz.statusCode != "1")
- {
- ShowLog = ahz.message + ",获取Token授权失败!等待下一次轮询。";
- this.SetText(ShowLog);
- LogHelper.Info(ShowLog);
- result = false;
- }
- Tools.accessToken = ahz.mainBody.accessToken;
- Tools.DateTimes = DateTime.Now.AddSeconds(int.Parse(ahz.mainBody.expirationTime));
- }
- return result;
- }
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (e.CloseReason == CloseReason.UserClosing)
- {
- //是否取消close操作
- e.Cancel = true;
- this.WindowState = FormWindowState.Minimized;
- }
- }
- private void checkBox1_Click(object sender, EventArgs e)
- {
- int hr = 0;
- string sql = @"update 互认配置表 set 互认 = {0}";
- bool bl = checkBox1.Checked;
- if (checkBox1.Checked)
- {
- hr = 1;
- }
- sql = string.Format(sql, hr);
- int res = OracleHelper<object>.ExecuteNonQuery(sql);
- if (res > 0)
- {
- if (bl)
- {
- textBox1.Text = "已修改为互认!";
- }
- else
- {
- textBox1.Text = "已修改为不互认!";
- }
- }
- else
- {
- textBox1.Text = "是否互认修改失败!";
- if (bl)
- {
- checkBox1.Checked = false;
- }
- else
- {
- checkBox1.Checked = true;
- }
- }
- }
- private void checkBox2_CheckedChanged(object sender, EventArgs e)
- {
- AutoStart();
- }
- public void GetLisDefault()
- {
- string sql = @"select count(1) listotal from lis_upload where attachmentId is null";
- DataTable dt = new DataTable();
- if (zlhr==zlhrConstant_true)
- {
- dt = OracleHelper<object>.PgQueryDS(sql);
- }
- else
- {
- dt = OracleHelper<object>.RunQueryDS(sql);
- }
- string label_lis = dt.Rows[0]["listotal"].ToString() + "条";
- string lis_count = Lis_total + "条";
- this.SetLisText(label_lis);
- this.SetLisCountText(lis_count);
- //获取待上传的数量
- string waitsql = @"select count(1) listotal from lis_upload a ,已上传PDF b
- where b.businessnumber = a.BUSINESSNUMBER
- and b.reportid = a.REPORTID
- and b.attachmentid is not null
- and b.uploaded = 0
- and b.type = 2";
- DataTable waitdt = new DataTable();
- if (zlhr == zlhrConstant_true)
- {
- waitdt = OracleHelper<object>.PgQueryDS(waitsql);
- }
- else
- {
- waitdt = OracleHelper<object>.RunQueryDS(sql);
- }
- LogHelper.Info("待上传数量为:" + waitdt.Rows[0]["listotal"].ToString() + "条");
- }
- public void GetPacsDefault()
- {
- string sql = @"select count(1) pacstotal from pacs_upload where attachmentId is null";
- DataTable dt = OracleHelper<object>.RunQueryDS(sql);
- string label_pacs = dt.Rows[0]["pacstotal"].ToString() + "条";
- string pacs_count = pacs_total + "条";
- this.SetPassText(label_pacs);
- this.SetPacsCountText(pacs_count);
- }
- private void SetText(string text)
- {
- // InvokeRequired需要比较调用线程ID和创建线程ID
- // 如果它们不相同则返回true
- if (this.textBox1.InvokeRequired)
- {
- SetTextCallback d = new SetTextCallback(SetText);
- this.Invoke(d, new object[] { text });
- }
- else
- {
- this.textBox1.Text = text;
- }
- }
- private void SetLisText(string text)
- {
- // InvokeRequired需要比较调用线程ID和创建线程ID
- // 如果它们不相同则返回true
- if (this.textBox1.InvokeRequired)
- {
- SetTextCallback d = new SetTextCallback(SetLisText);
- this.Invoke(d, new object[] { text });
- }
- else
- {
- this.label_lis.Text = text;
- }
- }
- private void SetPassText(string text)
- {
- // InvokeRequired需要比较调用线程ID和创建线程ID
- // 如果它们不相同则返回true
- if (this.textBox1.InvokeRequired)
- {
- SetTextCallback d = new SetTextCallback(SetPassText);
- this.Invoke(d, new object[] { text });
- }
- else
- {
- this.label_pacs.Text = text;
- }
- }
- private void SetLisCountText(string text)
- {
- // InvokeRequired需要比较调用线程ID和创建线程ID
- // 如果它们不相同则返回true
- if (this.textBox1.InvokeRequired)
- {
- SetTextCallback d = new SetTextCallback(SetLisCountText);
- this.Invoke(d, new object[] { text });
- }
- else
- {
- this.lis_count.Text = text;
- }
- }
- private void SetPacsCountText(string text)
- {
- // InvokeRequired需要比较调用线程ID和创建线程ID
- // 如果它们不相同则返回true
- if (this.textBox1.InvokeRequired)
- {
- SetTextCallback d = new SetTextCallback(SetPacsCountText);
- this.Invoke(d, new object[] { text });
- }
- else
- {
- this.pacs_count.Text = text;
- }
- }
- private void DelPDF()
- {
- //每月1号删除
- if (DateTime.Now.Day != 1)
- {
- return;
- }
- int month = OracleHelper<object>.UploadTime();
- if (month < 1)
- {
- return;
- }
- string sql = @"delete from 已上传PDF a where a.uploaded = 1 And a.Uploade_Time < add_months(Sysdate,-{0})";
- sql = string.Format(sql,month);
- OracleHelper<object>.ExecuteNonQuery(sql);
-
- }
- }
- }
|