Form1.cs 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191
  1. using Common;
  2. using iTextSharp.text;
  3. using iTextSharp.text.pdf;
  4. using LisPacsDataUpload.business;
  5. using LisPacsDataUpload.Models;
  6. using Newtonsoft.Json;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Web.UI.WebControls;
  15. using System.Windows.Forms;
  16. using System.Xml;
  17. namespace LisPacsDataUpload
  18. {
  19. public partial class Form1 : Form
  20. {
  21. private static int zlhrConstant_true=1;// 是临生免 常量
  22. //定时器
  23. private System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
  24. //private DateTime Date;
  25. //private int PageSize = 10;
  26. //private int PageIndex = 0;
  27. //PageIndex = PageIndex + 1;
  28. // int PageStart = (PageIndex - 1) * PageSize + 1;
  29. //int PageEnd = PageSize * PageIndex;
  30. private int UploadPacs;//是否上传pacs
  31. private string ShowLog = "";
  32. private int Lis_total = 0;//今日lis上传总数
  33. private int pacs_total = 0;//今日pacs上传总数
  34. private string DicPacs = AppDomain.CurrentDomain.BaseDirectory + "Pacs\\";
  35. private string DicLis = AppDomain.CurrentDomain.BaseDirectory + "Lis\\";
  36. private int zlhr = 0;// 是否为临生免
  37. private int lisSource = 1;// 0中联老版lis 1 中联新版lis 2 专业版临生免 3 三方lis
  38. private int open_multiple_upload_flag = 0;// 开启多个线程上传
  39. private delegate void SetTextCallback(string text);
  40. //在给textBox1.text赋值的地方调用以下方法即可
  41. public Form1()
  42. {
  43. InitializeComponent();
  44. this.MinimumSize = new Size(0, 0);
  45. timer1.Interval = OracleHelper<object>.Time();
  46. timer1.Enabled = true;
  47. timer1.Tick += new EventHandler(DataUpload);//添加事件
  48. timer1.Start();
  49. }
  50. private void Form1_Load(object sender, EventArgs e)
  51. {
  52. ShowLog = "启动正常。";
  53. LogHelper.Info(ShowLog);
  54. this.SetText(ShowLog);
  55. ShowCheckBox1();
  56. ShowCheckBox2();
  57. UploadPacs = OracleHelper<object>.UploadPacs();
  58. GetLisDefault();
  59. if (UploadPacs == 1)
  60. {
  61. GetPacsDefault();
  62. }
  63. //AutoStart();
  64. DataUpload(sender, e);
  65. }
  66. private void ShowCheckBox1()
  67. {
  68. try
  69. {
  70. string sql_lis = @"select 互认,zlhr,open_multiple_upload,lis_source from 互认配置表";
  71. DataTable dt_lis = OracleHelper<object>.RunQueryDS(sql_lis);
  72. int total = int.Parse(dt_lis.Rows[0]["互认"].ToString());
  73. if (total == 1)
  74. {
  75. checkBox1.Checked = true;
  76. }
  77. else
  78. {
  79. checkBox1.Checked = false;
  80. }
  81. int zlhrValue = int.Parse(dt_lis.Rows[0]["zlhr"].ToString());
  82. if (zlhrValue == zlhrConstant_true)
  83. {
  84. zlhr = zlhrValue;
  85. }
  86. open_multiple_upload_flag = int.Parse(dt_lis.Rows[0]["open_multiple_upload"].ToString());
  87. lisSource = int.Parse(dt_lis.Rows[0]["lis_source"].ToString());
  88. }
  89. catch (Exception ex)
  90. {
  91. LogHelper.Info("ex===" + ex.Message);
  92. }
  93. }
  94. private void ShowCheckBox2()
  95. {
  96. XmlDocument xmldoc = new XmlDocument();
  97. string xmlpath = AppDomain.CurrentDomain.BaseDirectory + "Xml.xml";
  98. xmldoc.Load(xmlpath);
  99. string str = xmldoc.SelectSingleNode("/root/key").InnerXml;
  100. if (str == "0")
  101. {
  102. checkBox2.Checked = false;
  103. }
  104. else
  105. {
  106. checkBox2.Checked = true;
  107. }
  108. }
  109. /// <summary>
  110. /// 开机启动
  111. /// </summary>
  112. private void AutoStart()
  113. {
  114. try
  115. {
  116. XmlDocument xmldoc = new XmlDocument();
  117. string xmlpath = AppDomain.CurrentDomain.BaseDirectory + "Xml.xml";
  118. xmldoc.Load(xmlpath);
  119. string str = xmldoc.SelectSingleNode("/root/key").InnerXml;
  120. if (str == "0")
  121. {
  122. string regPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
  123. string path = Application.ExecutablePath.ToLower(); //将当前程序起动路径
  124. string name = System.IO.Path.GetFileName(path); //获得应用程序名称
  125. var regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regPath, true);
  126. if (regKey != null && regKey.GetValue("LisPacsDataUpload") == null)
  127. {
  128. regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(regPath);
  129. regKey.SetValue("LisPacsDataUpload", path);
  130. regKey.Close();
  131. }
  132. XmlElement element = (XmlElement)xmldoc.SelectSingleNode("/root/key");
  133. element.InnerText = "1";
  134. xmldoc.Save(xmlpath);
  135. ShowLog = "写入注册表成功。";
  136. this.SetText(ShowLog);
  137. LogHelper.Info("写入注册表成功。");
  138. }
  139. else
  140. {
  141. ShowLog = "不允许此操作!";
  142. this.SetText(ShowLog);
  143. if (checkBox2.Checked)
  144. {
  145. checkBox2.Checked = false;
  146. }
  147. else
  148. {
  149. checkBox2.Checked = true;
  150. }
  151. }
  152. }
  153. catch (Exception ex)
  154. {
  155. //ShowLog = "不允许此操作!";
  156. //this.SetText(ShowLog);
  157. if (checkBox2.Checked)
  158. {
  159. checkBox2.Checked = false;
  160. }
  161. else
  162. {
  163. checkBox2.Checked = true;
  164. }
  165. ShowLog = "写入注册表异常:" + ex.Message;
  166. this.SetText(ShowLog);
  167. LogHelper.Info(ShowLog);
  168. }
  169. }
  170. private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
  171. {
  172. //switch (e.Button)
  173. //{
  174. // case System.Windows.Forms.MouseButtons.Left: //左击
  175. // //判断是否已经最小化于托盘
  176. // if (WindowState == FormWindowState.Minimized)
  177. // {
  178. // //还原窗体显示
  179. // WindowState = FormWindowState.Normal;
  180. // //激活窗体并给予它焦点
  181. // this.Activate();
  182. // //任务栏区显示图标
  183. // this.ShowInTaskbar = true;
  184. // //托盘区图标隐藏
  185. // notifyIcon1.Visible = false;
  186. // }
  187. // break;
  188. // case System.Windows.Forms.MouseButtons.Right:
  189. // //MessageBox.Show("右键");
  190. // break;
  191. //}
  192. }
  193. private void open_click(object sender, EventArgs e)
  194. {
  195. if (WindowState == FormWindowState.Minimized)
  196. {
  197. WindowState = FormWindowState.Normal;
  198. this.Activate();
  199. this.ShowInTaskbar = true;
  200. }
  201. }
  202. private void close_click(object sender, EventArgs e)
  203. {
  204. //this.Close();
  205. LogHelper.Info("程序退出。");
  206. System.Environment.Exit(0);
  207. }
  208. private void Form1_SizeChanged(object sender, EventArgs e)
  209. {
  210. //判断是否选择的是最小化按钮
  211. if (WindowState == FormWindowState.Minimized)
  212. {
  213. //托盘显示图标等于托盘图标对象
  214. //注意notifyIcon1是控件的名字而不是对象的名字
  215. //隐藏任务栏区图标
  216. this.ShowInTaskbar = false;
  217. //图标显示在托盘区
  218. notifyIcon1.Visible = true;
  219. }
  220. }
  221. private void DataUpload(object source, EventArgs e)
  222. {
  223. LogHelper.Info("开始轮询。");
  224. DateTime Date = DateTime.Now;
  225. int time = Date.Hour;
  226. int StartTime = OracleHelper<object>.StartTime();//18
  227. if (time == 0)
  228. {//今日上传数清零
  229. Lis_total = 0;
  230. pacs_total = 0;
  231. }
  232. else if (time < StartTime && time > 7)//
  233. {
  234. ShowLog = "开始轮询时间为[" + StartTime + "]点至明日早上7点,现在是" + time + "点。";
  235. this.SetText(ShowLog);
  236. LogHelper.Info(ShowLog);
  237. if (Directory.Exists(DicLis))
  238. {
  239. Directory.Delete(DicLis, true);
  240. }
  241. if (Directory.Exists(DicPacs))
  242. {
  243. Directory.Delete(DicPacs, true);
  244. }
  245. DelPDF();
  246. return;
  247. }
  248. LogHelper.Info("zlhr=="+zlhr);
  249. string name = "LIS1" + Tools.GuidTo16String();
  250. Thread th = new Thread(new ParameterizedThreadStart(CountUpload));
  251. th.IsBackground = true;
  252. th.Name = name;
  253. th.Start(name);
  254. System.Threading.Thread.Sleep(5000);
  255. string name2 = "LIS2" + Tools.GuidTo16String();
  256. Thread th2 = new Thread(new ParameterizedThreadStart(LisUpload));
  257. th2.IsBackground = true;
  258. th2.Name = name2;
  259. th2.Start(name2);
  260. // 开启第二个上传
  261. if (1== open_multiple_upload_flag)
  262. {
  263. System.Threading.Thread.Sleep(5000);
  264. string name3 = "LIS3" + Tools.GuidTo16String();
  265. Thread th3 = new Thread(new ParameterizedThreadStart(LisUpload2));
  266. th3.IsBackground = true;
  267. th3.Name = name3;
  268. th3.Start(name3);
  269. }
  270. if (UploadPacs == 1)//没传影像云的需要上传检查
  271. {
  272. LogHelper.Info("没传影像云的需要上传检查");
  273. Thread thp = new Thread(new ThreadStart(PacsUpload));
  274. thp.IsBackground = true;
  275. thp.Name = "PACS" + Tools.GuidTo16String();
  276. thp.Start();
  277. }
  278. }
  279. private object CountLock = new object();
  280. private void CountUpload(object Thname)
  281. {
  282. try
  283. {
  284. lock (CountLock)
  285. {
  286. string Thread_name = "[" + Thname.ToString() + "]";
  287. string url = "http://40.26.204.3:8084/phimp-napi/qyhrApplyInfo/upload";
  288. int success_count = 0;
  289. LogHelper.Info(Thread_name + "上传开单合计开始");
  290. string count_sql = @"select * from bill_project_view"
  291. ;
  292. List<Count> list_count = OracleHelper<Count>.RunQueryList(count_sql);
  293. LogHelper.Info("list_count" + list_count);
  294. if (list_count.Count < 1)
  295. {
  296. LogHelper.Info(Thread_name + "本次开单无数据,等待下一次轮询。");
  297. LogHelper.Info("执行sql:" + count_sql);
  298. }
  299. else
  300. {
  301. for (int i = 0; i < list_count.Count; i++)
  302. {
  303. if (!isAuthorization())
  304. {
  305. continue;
  306. }
  307. Dictionary<string, object> dic_pc = new Dictionary<string, object>();
  308. foreach (var property in list_count[i].GetType().GetProperties())
  309. {
  310. //LogHelper.Info("[count]Name:" + property.Name);
  311. //LogHelper.Info("[count]value:" + property.GetValue(list_count[i], null));
  312. dic_pc.Add(property.Name, property.GetValue(list_count[i], null));
  313. }
  314. string json_count = JsonConvert.SerializeObject(dic_pc);
  315. string json_count_log = json_count;
  316. string vi_count = Tools.GuidTo16String();
  317. json_count = Tools.AESEncrypt(json_count, Tools.pwd, vi_count);
  318. string res_pacs_pc = Tools.WSCenterData(url, json_count, vi_count, Tools.accessToken, 1);
  319. string res_aes_pacs_pc = Tools.AESDecrypt(res_pacs_pc, Tools.pwd, vi_count);
  320. ResPacs respacs_pc = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs_pc), Encoding.UTF8);
  321. if (respacs_pc.statusCode != "1")
  322. {
  323. ShowLog = respacs_pc.message + ",[LIS]清单数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_count;
  324. this.SetText(ShowLog);
  325. LogHelper.Info(ShowLog);
  326. LogHelper.Info("[count]出错入参:" + json_count_log);
  327. LogHelper.Info("[LIS]出错入参:" + json_count + "|....|" + Tools.accessToken);
  328. LogHelper.Info("[count]出错出参:" + res_aes_pacs_pc);
  329. continue;
  330. }
  331. else
  332. {
  333. // LogHelper.Info(success_count + "入参:" + json_count_log);
  334. //LogHelper.Info(success_count + "出参:" + respacs_pc.message);
  335. //修改状态
  336. string sql_upload = @"update 互认开单项目 set 是否上传 = 1,上传时间 = to_date('{1}','yyyy/mm/dd hh24:mi:ss') where 相关id = '{0}'";
  337. sql_upload = string.Format(sql_upload, list_count[i].HISAPPLYCODE, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
  338. int upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
  339. LogHelper.Info("清单上传"+ upload_count);
  340. success_count++;
  341. }
  342. }
  343. LogHelper.Info("本次清单上传:" + success_count);
  344. }
  345. }
  346. }
  347. catch (Exception e)
  348. {
  349. LogHelper.Error(e);
  350. }
  351. }
  352. private object LisLock = new object();
  353. private void LisUpload(object Thname)
  354. {
  355. try
  356. {
  357. lock (LisLock)
  358. {
  359. string Thread_name = "[" + Thname.ToString() + "]";
  360. string url = "http://40.26.204.3:8084/phimp-napi/qyhrlischeckreportinfo/save";
  361. #region 1、单条上传lis文件及数据
  362. LogHelper.Info(Thread_name + "[LIS]开始");
  363. string lis_sql = @"select * from( Select rownum rn,b.* From (Select t.* from lis_upload t
  364. Where
  365. t.attachmentId Is Null
  366. Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss')
  367. ) b
  368. ) where rn <= 150 ";
  369. DataTable dt = new DataTable();
  370. if (zlhr == zlhrConstant_true)
  371. {
  372. lis_sql = @"Select t.* from lis_upload t Where t.attachmentId Is Null
  373. Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss') limit 100";
  374. dt = OracleHelper<object>.PgQueryDS(lis_sql);
  375. }
  376. else
  377. {
  378. dt = OracleHelper<object>.RunQueryDS(lis_sql);
  379. }
  380. LogHelper.Info("执行sql:" + lis_sql);
  381. if (dt.Rows.Count < 1)
  382. {
  383. LogHelper.Info(Thread_name + "本次[LIS]无数据,等待下一次轮询。");
  384. }
  385. else
  386. {
  387. ShowLog = Thread_name + "本次需上传[LIS]数据总条数为[" + dt.Rows.Count + "]条,逐条上传中,请耐心等待。";
  388. this.SetText(ShowLog);
  389. LogHelper.Info(ShowLog);
  390. int pdfcountAll = 0;
  391. int uploaded = 0;
  392. for (int i = 0; i < dt.Rows.Count; i++)
  393. {
  394. //生成pdf
  395. string generatePdfUrl = "未生成pdf成功";
  396. if (zlhr == zlhrConstant_true)
  397. {
  398. string requestId = dt.Rows[i]["requestId"].ToString(); // 临生免报告id
  399. string sql_zlhr = @"select dr.id as id from specimen_rec sr, diagnosticreport_rec dr where sr.id = dr.specmids::int
  400. and dr.status in ('3003', '3004') and sr.id = " + requestId;
  401. DataTable dt_lis = OracleHelper<object>.PgQueryDS(sql_zlhr);
  402. string reportId = dt_lis.Rows[0]["id"].ToString();
  403. generatePdfUrl = PdfUtils.GeneratePdf(lisSource, reportId, reportId,null);
  404. }
  405. else if(lisSource==3){
  406. string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
  407. generatePdfUrl = PdfUtils.GeneratePdf(lisSource, requestId, requestId,null);
  408. if (!generatePdfUrl.Contains(".pdf"))
  409. {
  410. LogHelper.Info("生成pdf失败,原因是 = " + generatePdfUrl);
  411. ShowLog = "生成pdf失败,原因是 =" + generatePdfUrl;
  412. this.SetText(ShowLog);
  413. continue;
  414. }
  415. }
  416. else if (lisSource == 10)
  417. {
  418. string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
  419. string pdfUrl = dt.Rows[i]["pdfUrl"].ToString(); // 三方pdf地址 需要下载
  420. generatePdfUrl = PdfUtils.GeneratePdf(lisSource, pdfUrl, requestId,null);
  421. if (string.IsNullOrEmpty(generatePdfUrl))
  422. {
  423. LogHelper.Info("生成pdf失败,原因是 = " + generatePdfUrl);
  424. ShowLog = "生成pdf失败,原因是 =" + generatePdfUrl;
  425. this.SetText(ShowLog);
  426. continue;
  427. }
  428. }
  429. else
  430. {
  431. string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
  432. //获取标本号 和报表编号
  433. string reportNumber = dt.Rows[i]["reportNumber"].ToString(); //报告编号
  434. string bbid = dt.Rows[i]["bbid"].ToString(); // 标本id
  435. generatePdfUrl = PdfUtils.GeneratePdf(lisSource, reportNumber, bbid, requestId);
  436. if (!generatePdfUrl.Contains(".pdf"))
  437. {
  438. LogHelper.Info("生成pdf失败,原因是 = " + generatePdfUrl);
  439. ShowLog = "生成pdf失败,原因是 =" + generatePdfUrl;
  440. this.SetText(ShowLog);
  441. continue;
  442. }
  443. LogHelper.Info("生成pdf成功,地址为 = " + generatePdfUrl);
  444. }
  445. /*string orgName = dt.Rows[i]["orgName"].ToString();
  446. string name = dt.Rows[i]["patientName"].ToString();
  447. string sex = dt.Rows[i]["sex"].ToString();
  448. string ch = dt.Rows[i]["bedNo"].ToString();
  449. string zyh = dt.Rows[i]["zyh"].ToString();
  450. string mzh = dt.Rows[i]["mzh"].ToString();
  451. string age = dt.Rows[i]["age"].ToString();
  452. string dep = dt.Rows[i]["dep"].ToString();
  453. string type;
  454. string title = dt.Rows[i]["reportName"].ToString();
  455. string patientType = dt.Rows[i]["patientType"].ToString();
  456. if (patientType == "1")
  457. {
  458. type = "门诊";
  459. }
  460. else if (patientType == "2")
  461. {
  462. type = "住院";
  463. }
  464. else if (patientType == "3")
  465. {
  466. type = "体检";
  467. }
  468. else
  469. {
  470. type = "其他";
  471. }
  472. string baseInfo = "姓名:{0} 性别:{1} 年龄:{2} 病人来源:{3} 床号:{4} 住院号:{5} 门诊号:{6} 申请科室:{7}";
  473. string signature = "签名:{0} 日期:{1}";
  474. string qname = dt.Rows[i]["auditorName"].ToString();
  475. string qdate = dt.Rows[i]["auditTime"].ToString();
  476. signature = string.Format(signature, qname, qdate);
  477. baseInfo = string.Format(baseInfo, name, sex, age, type, ch, zyh, mzh, dep);
  478. string reportId = dt.Rows[i]["reportId"].ToString();
  479. string dt_sql = @"Select * From lis_upload_items t Where t.groupItemCode = '" + reportId+"'";
  480. LogHelper.Info("查询LIS项目指标数据执行sql:" + dt_sql);
  481. DataTable items = new DataTable();
  482. if (zlhr == zlhrConstant_true)
  483. {
  484. items = OracleHelper<object>.PgQueryDS(dt_sql);
  485. }
  486. else
  487. {
  488. items = OracleHelper<object>.RunQueryDS(dt_sql);
  489. }
  490. LogHelper.Info("查询LIS项目指标数据执行sql 条数=:" + items.Rows.Count);
  491. if (items.Rows.Count < 1)
  492. {
  493. LogHelper.Info("查询LIS项目指标数据为空,生成PDF失败,跳过本条数据生成下一条PDF。");
  494. continue;
  495. }
  496. string res = CreateLisPDF(orgName, baseInfo, items, signature, title);
  497. if (res == "")
  498. {
  499. ShowLog = "生成PDF文件失败,[LIS]上传失败!跳过本条数据上传下一条。";
  500. this.SetText(ShowLog);
  501. LogHelper.Info(ShowLog);
  502. continue;
  503. }*/
  504. //是否授权
  505. if (!isAuthorization())
  506. {
  507. continue;
  508. }
  509. //最新调整 需要获取 原始pdf 文件 存在场景 有三方lis、中联lis 、 以及专业版临生免 的报告 三种
  510. LogHelper.Info("最后GeneratePdfUrl= " + generatePdfUrl);
  511. string attachmentFile = "";
  512. if (zlhr == zlhrConstant_true)
  513. {
  514. attachmentFile = generatePdfUrl;
  515. }
  516. else
  517. {
  518. attachmentFile = Tools.FileToBase64Str(generatePdfUrl);
  519. }
  520. //LogHelper.Info("上传的文件类容==" + attachmentFile);
  521. //上传文件
  522. string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + attachmentFile + "\"}";
  523. string file_vi = Tools.GuidTo16String();
  524. file_json = Tools.AESEncrypt(file_json, Tools.pwd, file_vi);
  525. string file_url = "http://40.26.204.3:8084/phimp-napi/attachMent/upload";
  526. string file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
  527. string file_res_aes = Tools.AESDecrypt(file_res, Tools.pwd, file_vi);
  528. ResFile resfile = Tools.JsonToObject<ResFile>(Tools.FormatStr(file_res_aes), Encoding.UTF8);
  529. if (resfile.statusCode != "1")
  530. {
  531. LogHelper.Info(resfile.message + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。");
  532. LogHelper.Info("入参:" + file_json);
  533. LogHelper.Info("出参:" + file_res_aes);
  534. ShowLog = "入参:" + file_json + ",出参:" + file_res_aes + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。";
  535. this.SetText(ShowLog);
  536. continue;
  537. }
  538. 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'))";
  539. 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"));
  540. int file_count = 0;
  541. if (zlhr == zlhrConstant_true)
  542. {
  543. LogHelper.Info("sql:" + sql);
  544. file_count = OracleHelper<object>.PgExecuteNonQuery(sql);
  545. }
  546. else
  547. {
  548. file_count = OracleHelper<object>.ExecuteNonQuery(sql);
  549. }
  550. if (file_count < 1)
  551. {
  552. LogHelper.Info("[LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!");
  553. LogHelper.Info("执行sql:" + sql);
  554. ShowLog = "[LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql;
  555. this.SetText(ShowLog);
  556. continue;
  557. }
  558. pdfcountAll += 1;
  559. //上传lis数据
  560. string item_sql = @"select a.orgCode,
  561. a.orgName,
  562. a.orgThrdCode,
  563. a.reportId,
  564. a.reportName,
  565. a.requestId,
  566. a.barcode,
  567. a.sampleNo,
  568. a.businessNumber,
  569. a.patientType,
  570. a.patientName,
  571. a.patientSex,
  572. a.patientBirthday,
  573. a.patientAge,
  574. a.ageUnit,
  575. a.patientIdCard,
  576. a.inpatientAreaName,
  577. a.roomNo,
  578. a.bedNo,
  579. a.phoneNo,
  580. a.address,
  581. a.reportType,
  582. a.reportTypeName,
  583. a.sampCode,
  584. a.sampName,
  585. a.diagnosisCode,
  586. a.diagnosisName,
  587. a.resultType,
  588. a.applyTime,
  589. a.applyerCode,
  590. a.applyerName,
  591. a.applyDeptCode,
  592. a.applyDeptName,
  593. a.collectTime,
  594. a.collectCode,
  595. a.collectName,
  596. a.transportCode,
  597. a.transportName,
  598. a.transportDeptCode,
  599. a.transportDeptName,
  600. a.transportOrgCode,
  601. a.transportOrgName,
  602. a.acceptTime,
  603. a.acceptorCode,
  604. a.acceptorName,
  605. a.receiveTime,
  606. a.receiverCode,
  607. a.receiverName,
  608. a.checkTime,
  609. a.checkerCode,
  610. a.checkerName,
  611. a.checkDeptCode,
  612. a.checkDeptName,
  613. a.auditTime,
  614. a.auditorCode,
  615. a.auditorName,
  616. a.reportTime,
  617. a.reportorCode,
  618. a.reportorName,
  619. a.sampleNotes,
  620. a.checkPrice,
  621. a.attachmentId,
  622. a.patientId ,
  623. a.healthNo ,
  624. a.medicareNo ,
  625. a.socialNo ,
  626. a.inpatientAreaCode ,
  627. a.sampleName ,
  628. a.execHospitalCode ,
  629. a.execHospitalName,
  630. a.sameHospital,
  631. a.projectCode,
  632. a.projectName
  633. from lis_upload a ,已上传PDF b
  634. where b.businessnumber = a.BUSINESSNUMBER
  635. and b.reportid = a.REPORTID
  636. and b.attachmentid is not null
  637. and b.uploaded = 0
  638. and b.type = 2
  639. and a.BUSINESSNUMBER = '{0}'
  640. and a.REPORTID = '{1}'";
  641. item_sql = string.Format(item_sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString());
  642. List<LIS> list = new List<LIS>();
  643. if (zlhr == zlhrConstant_true)
  644. {
  645. list = OracleHelper<LIS>.PgRunQueryList(item_sql);
  646. }
  647. else
  648. {
  649. list = OracleHelper<LIS>.RunQueryList(item_sql);
  650. }
  651. if (list.Count < 1)
  652. {
  653. LogHelper.Info("查询LIS数据为空,跳过本条数据上传下一条。");
  654. LogHelper.Info("执行sql:" + item_sql);
  655. continue;
  656. }
  657. List<Dictionary<string, object>> plist = new List<Dictionary<string, object>>();
  658. Dictionary<string, object> dic = new Dictionary<string, object>();
  659. foreach (var property in list[0].GetType().GetProperties())
  660. {
  661. dic.Add(property.Name, property.GetValue(list[0], null));
  662. }
  663. string lisitems_sql = @"Select * From lis_upload_items t Where t.groupItemCode = '" + list[0].REPORTID + "'";
  664. List<LISITEMS> lisitems = new List<LISITEMS>();
  665. if (zlhr == zlhrConstant_true)
  666. {
  667. lisitems = OracleHelper<LISITEMS>.PgRunQueryList(lisitems_sql);
  668. }
  669. else
  670. {
  671. lisitems = OracleHelper<LISITEMS>.RunQueryList(lisitems_sql);
  672. }
  673. if (lisitems.Count < 1)
  674. {
  675. LogHelper.Info("查询LIS项目指标数据为空,跳过本条数据上传下一条。");
  676. LogHelper.Info("执行sql:" + lisitems_sql);
  677. continue;
  678. }
  679. if (zlhr == zlhrConstant_true)
  680. {
  681. //处理 互认编码的数据
  682. HandleLisItemData(lisitems);
  683. }
  684. dic.Add("DETAILLIST", lisitems);
  685. plist.Add(dic);
  686. //是否授权
  687. if (!isAuthorization())
  688. {
  689. continue;
  690. }
  691. string json_pacs = JsonConvert.SerializeObject(plist);
  692. LogHelper.Info("lis 上传的json>>"+ json_pacs);
  693. json_pacs = "{\"mainBody\":" + json_pacs + "}";
  694. string json_pacs_log = json_pacs;
  695. string vi_pacs = Tools.GuidTo16String();
  696. json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
  697. string res_pacs = Tools.WSCenterData(url, json_pacs, vi_pacs, Tools.accessToken, 1);
  698. string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
  699. ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
  700. LogHelper.Info("上传检验报告的接口状态==" + JsonConvert.SerializeObject(respacs));
  701. if (respacs.statusCode != "1")
  702. {
  703. ShowLog = respacs.message + ",[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
  704. this.SetText(ShowLog);
  705. LogHelper.Info(ShowLog);
  706. LogHelper.Info("[LIS]出错入参:" + json_pacs_log);
  707. LogHelper.Info("[LIS]出错出参:" + res_aes_pacs);
  708. continue;
  709. }
  710. else
  711. {
  712. Lis_total += 1;
  713. uploaded += 1;//(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED) Values('{0}','{1}',2,'{2}',0)
  714. string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 2
  715. and BUSINESSNUMBER = '{0}'
  716. and REPORTID = '{1}'";
  717. sql_upload = string.Format(sql_upload, list[0].BUSINESSNUMBER, list[0].REPORTID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
  718. int upload_count = 0;
  719. if (zlhr == zlhrConstant_true)
  720. {
  721. upload_count = OracleHelper<object>.PgExecuteNonQuery(sql_upload);
  722. }
  723. else
  724. {
  725. upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
  726. }
  727. if (upload_count < 1)
  728. {
  729. LogHelper.Info("[LIS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
  730. LogHelper.Info("执行sql:" + sql_upload);
  731. ShowLog = "[LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
  732. this.SetText(ShowLog);
  733. continue;
  734. }
  735. }
  736. }
  737. ShowLog = Thread_name + "本次已生成、上传[LIS]PDF文件总条数为[" + pdfcountAll + "]条,上传[LIS]总条数为[" + uploaded + "]条。";
  738. this.SetText(ShowLog);
  739. LogHelper.Info(ShowLog);
  740. GetLisDefault();
  741. }
  742. #endregion
  743. #region 2、补传失败lis数据
  744. LogHelper.Info("补传失败lis数据开始");
  745. ShowLog = Thread_name + "补传失败lis数据开始";
  746. this.SetText(ShowLog);
  747. this.SetText("补传失败lis数据开始");
  748. int count_pc = 0;
  749. string pc_sql = @"select a.orgCode,
  750. a.orgName,
  751. a.orgThrdCode,
  752. a.reportId,
  753. a.reportName,
  754. a.requestId,
  755. a.barcode,
  756. a.sampleNo,
  757. a.businessNumber,
  758. a.patientType,
  759. a.patientName,
  760. a.patientSex,
  761. a.patientBirthday,
  762. a.patientAge,
  763. a.ageUnit,
  764. a.patientIdCard,
  765. a.inpatientAreaName,
  766. a.roomNo,
  767. a.bedNo,
  768. a.phoneNo,
  769. a.address,
  770. a.reportType,
  771. a.reportTypeName,
  772. a.sampCode,
  773. a.sampName,
  774. a.diagnosisCode,
  775. a.diagnosisName,
  776. a.resultType,
  777. a.applyTime,
  778. a.applyerCode,
  779. a.applyerName,
  780. a.applyDeptCode,
  781. a.applyDeptName,
  782. a.collectTime,
  783. a.collectCode,
  784. a.collectName,
  785. a.transportCode,
  786. a.transportName,
  787. a.transportDeptCode,
  788. a.transportDeptName,
  789. a.transportOrgCode,
  790. a.transportOrgName,
  791. a.acceptTime,
  792. a.acceptorCode,
  793. a.acceptorName,
  794. a.receiveTime,
  795. a.receiverCode,
  796. a.receiverName,
  797. a.checkTime,
  798. a.checkerCode,
  799. a.checkerName,
  800. a.checkDeptCode,
  801. a.checkDeptName,
  802. a.auditTime,
  803. a.auditorCode,
  804. a.auditorName,
  805. a.reportTime,
  806. a.reportorCode,
  807. a.reportorName,
  808. a.sampleNotes,
  809. a.checkPrice,
  810. a.attachmentId,
  811. a.patientId ,
  812. a.healthNo ,
  813. a.medicareNo ,
  814. a.socialNo ,
  815. a.inpatientAreaCode ,
  816. a.sampleName ,
  817. a.execHospitalCode ,
  818. a.execHospitalName,
  819. a.sameHospital,
  820. a.projectCode,
  821. a.projectName
  822. from lis_upload a ,已上传PDF b
  823. where b.businessnumber = a.BUSINESSNUMBER
  824. and b.reportid = a.REPORTID
  825. and b.attachmentid is not null
  826. and b.uploaded = 0
  827. and b.type = 2 ";
  828. LogHelper.Info("补传lis数据执行sql:" + pc_sql);
  829. List<LIS> list_pc = new List<LIS>();
  830. if (zlhr == zlhrConstant_true)
  831. {
  832. list_pc = OracleHelper<LIS>.PgRunQueryList(pc_sql);
  833. }
  834. else
  835. {
  836. list_pc = OracleHelper<LIS>.RunQueryList(pc_sql);
  837. }
  838. if (list_pc.Count < 1)
  839. {
  840. LogHelper.Info("查询补传[LIS]数据为空,等待下一次轮询。"+ list_pc.Count);
  841. return;
  842. }
  843. for (int i = 0; i < list_pc.Count; i++)
  844. {
  845. List<Dictionary<string, object>> plist_pc = new List<Dictionary<string, object>>();
  846. Dictionary<string, object> dic_pc = new Dictionary<string, object>();
  847. foreach (var property in list_pc[i].GetType().GetProperties())
  848. {
  849. dic_pc.Add(property.Name, property.GetValue(list_pc[i], null));
  850. }
  851. string lisitems_sql = @"Select * From lis_upload_items t Where t.groupItemCode = '" + list_pc[i].REPORTID +"'";
  852. List<LISITEMS> lisitems = OracleHelper<LISITEMS>.RunQueryList(lisitems_sql);
  853. if (zlhr == zlhrConstant_true)
  854. {
  855. lisitems = OracleHelper<LISITEMS>.PgRunQueryList(lisitems_sql);
  856. }
  857. else
  858. {
  859. lisitems = OracleHelper<LISITEMS>.RunQueryList(lisitems_sql);
  860. }
  861. if (lisitems.Count < 1)
  862. {
  863. LogHelper.Info("补传查询LIS项目指标数据为空,跳过本条数据上传下一条。");
  864. LogHelper.Info("执行sql:" + lisitems_sql);
  865. continue;
  866. }
  867. if (zlhr == zlhrConstant_true)
  868. {
  869. //处理 互认编码的数据
  870. HandleLisItemData(lisitems);
  871. }
  872. dic_pc.Add("DETAILLIST", lisitems);
  873. plist_pc.Add(dic_pc);
  874. //是否授权
  875. if (!isAuthorization())
  876. {
  877. continue;
  878. }
  879. string json_pacs_pc = JsonConvert.SerializeObject(plist_pc);
  880. json_pacs_pc = "{\"mainBody\":" + json_pacs_pc + "}";
  881. string json_pacs_log_pc = json_pacs_pc;
  882. string vi_pacs_pc = Tools.GuidTo16String();
  883. json_pacs_pc = Tools.AESEncrypt(json_pacs_pc, Tools.pwd, vi_pacs_pc);
  884. //string url_pacs = "http://40.26.204.3:8084/phimp-napi/qyhrlischeckreportinfo/save";
  885. string res_pacs_pc = Tools.WSCenterData(url, json_pacs_pc, vi_pacs_pc, Tools.accessToken, 1);
  886. string res_aes_pacs_pc = Tools.AESDecrypt(res_pacs_pc, Tools.pwd, vi_pacs_pc);
  887. ResPacs respacs_pc = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs_pc), Encoding.UTF8);
  888. if (respacs_pc.statusCode != "1")
  889. {
  890. ShowLog = respacs_pc.message + ",补传[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs_pc;
  891. this.SetText(ShowLog);
  892. LogHelper.Info(ShowLog);
  893. LogHelper.Info("[LIS]出错入参:" + json_pacs_log_pc);
  894. LogHelper.Info("[LIS]出错出参:" + res_aes_pacs_pc);
  895. continue;
  896. }
  897. else
  898. {
  899. Lis_total += 1;
  900. count_pc += 1;//(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED) Values('{0}','{1}',2,'{2}',0)
  901. string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 2
  902. and BUSINESSNUMBER = '{0}'
  903. and REPORTID = '{1}'";
  904. sql_upload = string.Format(sql_upload, list_pc[i].BUSINESSNUMBER, list_pc[i].REPORTID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
  905. int upload_count = 0;
  906. if (zlhr==zlhrConstant_true)
  907. {
  908. upload_count = OracleHelper<object>.PgExecuteNonQuery(sql_upload);
  909. }
  910. else
  911. {
  912. upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
  913. }
  914. if (upload_count < 1)
  915. {
  916. LogHelper.Info("补传[LIS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
  917. LogHelper.Info("执行sql:" + sql_upload);
  918. ShowLog = "补传[LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
  919. this.SetText(ShowLog);
  920. continue;
  921. }
  922. }
  923. ShowLog = Thread_name + "补传第"+i+"条数据成功:医嘱id=" + list_pc[i].REPORTID;
  924. this.SetText(ShowLog);
  925. }
  926. if (count_pc > 0)
  927. {
  928. ShowLog = Thread_name + "本次补传[LIS]数据为[" + count_pc + "]条,等待下一次轮询。";
  929. this.SetText(ShowLog);
  930. LogHelper.Info(ShowLog);
  931. GetLisDefault();
  932. }
  933. #endregion
  934. }
  935. }
  936. catch (Exception ex)
  937. {
  938. LogHelper.Error(ex);
  939. }
  940. }
  941. //处理编码的数据 为医保编码数据
  942. private void HandleLisItemData(List<LISITEMS> items)
  943. {
  944. //处理 互认编码的数据
  945. foreach (LISITEMS item in items)
  946. {
  947. string ITEMCODE = item.ITEMCODE;
  948. string sqlhis = @"Select l.医保编码 From 诊疗项目目录 x,诊疗收费关系 y,收费项目目录 z,保险支付项目 m,互认项目清单 l
  949. Where y.诊疗项目id = x.id And z.id = y.收费项目id And m.收费细目id = z.Id And l.医保通用编码 = m.项目编码 And Rownum = 1
  950. And x.类别 = 'C' And m.险类 = 111
  951. And x.编码 ='{0}'";
  952. sqlhis = string.Format(sqlhis, ITEMCODE);
  953. DataTable dtYbCode = OracleHelper<object>.RunQueryDS(sqlhis);
  954. if (dtYbCode.Rows.Count > 0)
  955. {
  956. //取出诊疗项目id 取获取收费项目的医保编码 并赋值
  957. item.STANDARDITEMID = dtYbCode.Rows[0]["医保编码"].ToString();
  958. }
  959. // 复制 报告id
  960. /* string ITEMCODE = item.STANDARDITEMID;
  961. string sqlhis = @"Select l.医保编码 From 诊疗项目目录 x,诊疗收费关系 y,收费项目目录 z,保险支付项目 m,互认项目清单 l
  962. Where y.诊疗项目id = x.id And z.id = y.收费项目id And m.收费细目id = z.Id And l.医保通用编码 = m.项目编码 And Rownum = 1
  963. And x.类别 = 'C' And m.险类 = 111
  964. And x.编码 ='{0}'";
  965. sqlhis = string.Format(sqlhis, ITEMCODE);
  966. DataTable dtYbCode = OracleHelper<object>.RunQueryDS(sqlhis);
  967. if (dtYbCode.Rows.Count > 0)
  968. {
  969. //取出诊疗项目id 取获取收费项目的医保编码 并赋值
  970. item.STANDARDITEMID = dtYbCode.Rows[0]["医保编码"].ToString();
  971. }*/
  972. }
  973. }
  974. private object LisLock2 = new object();
  975. private void LisUpload2(object Thname)
  976. {
  977. try
  978. {
  979. lock (LisLock2)
  980. {
  981. string Thread_name = "[" + Thname.ToString() + "]";
  982. string url = "http://40.26.204.3:8084/phimp-napi/qyhrlischeckreportinfo/save";
  983. #region 1、单条上传lis文件及数据
  984. LogHelper.Info(Thread_name + "[LIS]开始");
  985. string lis_sql = @"select * from( Select rownum rn,b.* From (Select t.* from lis_upload t
  986. Where
  987. t.attachmentId Is Null
  988. Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss')
  989. ) b
  990. ) where rn <300 and rn >150 ";
  991. DataTable dt = new DataTable();
  992. if (zlhr == zlhrConstant_true)
  993. {
  994. /*limit 100 offset 100*/
  995. lis_sql = @"Select t.* from lis_upload t Where t.attachmentId Is Null
  996. Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss') limit 100 offset 100";
  997. dt = OracleHelper<object>.PgQueryDS(lis_sql);
  998. }
  999. else
  1000. {
  1001. dt = OracleHelper<object>.RunQueryDS(lis_sql);
  1002. }
  1003. LogHelper.Info("thread2 " + lis_sql);
  1004. if (dt.Rows.Count < 1)
  1005. {
  1006. LogHelper.Info(Thread_name + " thread2 本次[LIS]无数据,等待下一次轮询。");
  1007. LogHelper.Info("thread2 执行sql:" + lis_sql);
  1008. }
  1009. else
  1010. {
  1011. ShowLog = Thread_name + "thread2 本次需上传[LIS]数据总条数为[" + dt.Rows.Count + "]条,逐条上传中,请耐心等待。";
  1012. this.SetText(ShowLog);
  1013. LogHelper.Info(ShowLog);
  1014. int pdfcountAll = 0;
  1015. int uploaded = 0;
  1016. for (int i = 0; i < dt.Rows.Count; i++)
  1017. {
  1018. //生成pdf
  1019. string generatePdfUrl = "未生成pdf成功";
  1020. if (zlhr == zlhrConstant_true)
  1021. {
  1022. string requestId = dt.Rows[i]["requestId"].ToString(); // 临生免报告id
  1023. string sql_zlhr = @"select dr.id as id from specimen_rec sr, diagnosticreport_rec dr where sr.id = dr.specmids::int
  1024. and dr.status in ('3003', '3004') and sr.id = " + requestId;
  1025. DataTable dt_lis = OracleHelper<object>.PgQueryDS(sql_zlhr);
  1026. string reportId = dt_lis.Rows[0]["id"].ToString();
  1027. generatePdfUrl = PdfUtils.GeneratePdf(lisSource, reportId, reportId,null);
  1028. }
  1029. else if (lisSource == 3)
  1030. {
  1031. string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
  1032. generatePdfUrl = PdfUtils.GeneratePdf(lisSource, requestId, requestId, null);
  1033. if (!generatePdfUrl.Contains(".pdf"))
  1034. {
  1035. LogHelper.Info("生成pdf失败,原因是 = " + generatePdfUrl);
  1036. ShowLog = "生成pdf失败,原因是 =" + generatePdfUrl;
  1037. this.SetText(ShowLog);
  1038. continue;
  1039. }
  1040. }
  1041. else if (lisSource == 10)
  1042. {
  1043. string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
  1044. string pdfUrl = dt.Rows[i]["pdfUrl"].ToString(); // 三方pdf地址 需要下载
  1045. generatePdfUrl = PdfUtils.GeneratePdf(lisSource, pdfUrl, requestId, null);
  1046. if (string.IsNullOrEmpty(generatePdfUrl))
  1047. {
  1048. LogHelper.Info("生成pdf失败,原因是 = " + generatePdfUrl);
  1049. ShowLog = "生成pdf失败,原因是 =" + generatePdfUrl;
  1050. this.SetText(ShowLog);
  1051. continue;
  1052. }
  1053. }
  1054. else
  1055. {
  1056. string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
  1057. //获取标本号 和报表编号
  1058. string reportNumber = dt.Rows[i]["reportNumber"].ToString(); //报告编号
  1059. string bbid = dt.Rows[i]["bbid"].ToString(); // 标本id
  1060. generatePdfUrl = PdfUtils.GeneratePdf(lisSource, reportNumber, bbid, requestId);
  1061. if (!generatePdfUrl.Contains(".pdf"))
  1062. {
  1063. LogHelper.Info("生成pdf失败,原因是 = " + generatePdfUrl);
  1064. ShowLog = "生成pdf失败,原因是 =" + generatePdfUrl;
  1065. this.SetText(ShowLog);
  1066. continue;
  1067. }
  1068. LogHelper.Info("生成pdf成功,地址为 = " + generatePdfUrl);
  1069. }
  1070. /*string orgName = dt.Rows[i]["orgName"].ToString();
  1071. string name = dt.Rows[i]["patientName"].ToString();
  1072. string sex = dt.Rows[i]["sex"].ToString();
  1073. string ch = dt.Rows[i]["bedNo"].ToString();
  1074. string zyh = dt.Rows[i]["zyh"].ToString();
  1075. string mzh = dt.Rows[i]["mzh"].ToString();
  1076. string age = dt.Rows[i]["age"].ToString();
  1077. string dep = dt.Rows[i]["dep"].ToString();
  1078. string type;
  1079. string title = dt.Rows[i]["reportName"].ToString();
  1080. string patientType = dt.Rows[i]["patientType"].ToString();
  1081. if (patientType == "1")
  1082. {
  1083. type = "门诊";
  1084. }
  1085. else if (patientType == "2")
  1086. {
  1087. type = "住院";
  1088. }
  1089. else if (patientType == "3")
  1090. {
  1091. type = "体检";
  1092. }
  1093. else
  1094. {
  1095. type = "其他";
  1096. }
  1097. string baseInfo = "姓名:{0} 性别:{1} 年龄:{2} 病人来源:{3} 床号:{4} 住院号:{5} 门诊号:{6} 申请科室:{7}";
  1098. string signature = "签名:{0} 日期:{1}";
  1099. string qname = dt.Rows[i]["auditorName"].ToString();
  1100. string qdate = dt.Rows[i]["auditTime"].ToString();
  1101. signature = string.Format(signature, qname, qdate);
  1102. baseInfo = string.Format(baseInfo, name, sex, age, type, ch, zyh, mzh, dep);
  1103. string reportId = dt.Rows[i]["reportId"].ToString();
  1104. string dt_sql = @"Select * From lis_upload_items t Where t.groupItemCode = '" + reportId + "'";
  1105. LogHelper.Info("thread2 项目指标执行sql:" + dt_sql);
  1106. DataTable items = new DataTable();
  1107. if (zlhr==zlhrConstant_true)
  1108. {
  1109. items = OracleHelper<object>.PgQueryDS(dt_sql);
  1110. }
  1111. else
  1112. {
  1113. items = OracleHelper<object>.RunQueryDS(dt_sql);
  1114. }
  1115. LogHelper.Info("thread2 项目指标执行sql 条数:" + items.Rows.Count);
  1116. if (items.Rows.Count < 1)
  1117. {
  1118. LogHelper.Info("查询LIS项目指标数据为空,生成PDF失败,跳过本条数据生成下一条PDF。");
  1119. continue;
  1120. }
  1121. string res = CreateLisPDF(orgName, baseInfo, items, signature, title);
  1122. if (res == "")
  1123. {
  1124. ShowLog = "生成PDF文件失败,[LIS]上传失败!跳过本条数据上传下一条。";
  1125. this.SetText(ShowLog);
  1126. LogHelper.Info(ShowLog);
  1127. continue;
  1128. }*/
  1129. //是否授权
  1130. if (!isAuthorization())
  1131. {
  1132. continue;
  1133. }
  1134. LogHelper.Info("thread2 最后GeneratePdfUrl= " + generatePdfUrl);
  1135. string attachmentFile = "";
  1136. if (zlhr == zlhrConstant_true)
  1137. {
  1138. attachmentFile = generatePdfUrl;
  1139. }
  1140. else
  1141. {
  1142. attachmentFile = Tools.FileToBase64Str(generatePdfUrl);
  1143. }
  1144. //上传文件
  1145. string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + attachmentFile + "\"}";
  1146. string file_vi = Tools.GuidTo16String();
  1147. file_json = Tools.AESEncrypt(file_json, Tools.pwd, file_vi);
  1148. string file_url = "http://40.26.204.3:8084/phimp-napi/attachMent/upload";
  1149. string file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
  1150. string file_res_aes = Tools.AESDecrypt(file_res, Tools.pwd, file_vi);
  1151. ResFile resfile = Tools.JsonToObject<ResFile>(Tools.FormatStr(file_res_aes), Encoding.UTF8);
  1152. if (resfile.statusCode != "1")
  1153. {
  1154. LogHelper.Info(resfile.message + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。thread2 ");
  1155. LogHelper.Info("入参:" + file_json);
  1156. LogHelper.Info("出参:" + file_res_aes);
  1157. ShowLog = "入参:" + file_json + ",出参:" + file_res_aes + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。";
  1158. this.SetText(ShowLog);
  1159. continue;
  1160. }
  1161. 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'))";
  1162. 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"));
  1163. int file_count = 0;
  1164. if (zlhr==zlhrConstant_true)
  1165. {
  1166. file_count = OracleHelper<object>.PgExecuteNonQuery(sql);
  1167. }
  1168. else
  1169. {
  1170. file_count = OracleHelper<object>.ExecuteNonQuery(sql);
  1171. }
  1172. if (file_count < 1)
  1173. {
  1174. LogHelper.Info("thread2 [LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!");
  1175. LogHelper.Info("thread2 执行sql:" + sql);
  1176. ShowLog = "thread2 [LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql;
  1177. this.SetText(ShowLog);
  1178. continue;
  1179. }
  1180. pdfcountAll += 1;
  1181. //上传lis数据
  1182. string item_sql = @"select a.orgCode,
  1183. a.orgName,
  1184. a.orgThrdCode,
  1185. a.reportId,
  1186. a.reportName,
  1187. a.requestId,
  1188. a.barcode,
  1189. a.sampleNo,
  1190. a.businessNumber,
  1191. a.patientType,
  1192. a.patientName,
  1193. a.patientSex,
  1194. a.patientBirthday,
  1195. a.patientAge,
  1196. a.ageUnit,
  1197. a.patientIdCard,
  1198. a.inpatientAreaName,
  1199. a.roomNo,
  1200. a.bedNo,
  1201. a.phoneNo,
  1202. a.address,
  1203. a.reportType,
  1204. a.reportTypeName,
  1205. a.sampCode,
  1206. a.sampName,
  1207. a.diagnosisCode,
  1208. a.diagnosisName,
  1209. a.resultType,
  1210. a.applyTime,
  1211. a.applyerCode,
  1212. a.applyerName,
  1213. a.applyDeptCode,
  1214. a.applyDeptName,
  1215. a.collectTime,
  1216. a.collectCode,
  1217. a.collectName,
  1218. a.transportCode,
  1219. a.transportName,
  1220. a.transportDeptCode,
  1221. a.transportDeptName,
  1222. a.transportOrgCode,
  1223. a.transportOrgName,
  1224. a.acceptTime,
  1225. a.acceptorCode,
  1226. a.acceptorName,
  1227. a.receiveTime,
  1228. a.receiverCode,
  1229. a.receiverName,
  1230. a.checkTime,
  1231. a.checkerCode,
  1232. a.checkerName,
  1233. a.checkDeptCode,
  1234. a.checkDeptName,
  1235. a.auditTime,
  1236. a.auditorCode,
  1237. a.auditorName,
  1238. a.reportTime,
  1239. a.reportorCode,
  1240. a.reportorName,
  1241. a.sampleNotes,
  1242. a.checkPrice,
  1243. a.attachmentId,
  1244. a.patientId ,
  1245. a.healthNo ,
  1246. a.medicareNo ,
  1247. a.socialNo ,
  1248. a.inpatientAreaCode ,
  1249. a.sampleName ,
  1250. a.execHospitalCode ,
  1251. a.execHospitalName,
  1252. a.sameHospital,
  1253. a.projectCode,
  1254. a.projectName
  1255. from lis_upload a ,已上传PDF b
  1256. where b.businessnumber = a.BUSINESSNUMBER
  1257. and b.reportid = a.REPORTID
  1258. and b.attachmentid is not null
  1259. and b.uploaded = 0
  1260. and b.type = 2
  1261. and a.BUSINESSNUMBER = '{0}'
  1262. and a.REPORTID = '{1}'";
  1263. item_sql = string.Format(item_sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString());
  1264. List<LIS> list = new List<LIS>();
  1265. if (zlhr==zlhrConstant_true)
  1266. {
  1267. list = OracleHelper<LIS>.PgRunQueryList(item_sql);
  1268. }
  1269. else
  1270. {
  1271. list = OracleHelper<LIS>.RunQueryList(item_sql);
  1272. }
  1273. if (list.Count < 1)
  1274. {
  1275. LogHelper.Info("thread2 查询LIS数据为空,跳过本条数据上传下一条。");
  1276. LogHelper.Info("thread2 执行sql:" + item_sql);
  1277. continue;
  1278. }
  1279. List<Dictionary<string, object>> plist = new List<Dictionary<string, object>>();
  1280. Dictionary<string, object> dic = new Dictionary<string, object>();
  1281. foreach (var property in list[0].GetType().GetProperties())
  1282. {
  1283. dic.Add(property.Name, property.GetValue(list[0], null));
  1284. }
  1285. string lisitems_sql = @"Select* From lis_upload_items t Where t.groupItemCode = '" + list[0].REPORTID + "'";
  1286. List<LISITEMS> lisitems = new List<LISITEMS>();
  1287. if (zlhr==zlhrConstant_true)
  1288. {
  1289. lisitems = OracleHelper<LISITEMS>.PgRunQueryList(lisitems_sql);
  1290. }
  1291. else
  1292. {
  1293. lisitems = OracleHelper<LISITEMS>.RunQueryList(lisitems_sql);
  1294. }
  1295. if (lisitems.Count < 1)
  1296. {
  1297. LogHelper.Info("查询LIS项目指标数据为空,跳过本条数据上传下一条。");
  1298. LogHelper.Info("执行sql:" + lisitems_sql);
  1299. continue;
  1300. }
  1301. if(zlhr == zlhrConstant_true)
  1302. {
  1303. //处理 互认编码的数据
  1304. HandleLisItemData(lisitems);
  1305. }
  1306. dic.Add("DETAILLIST", lisitems);
  1307. plist.Add(dic);
  1308. //是否授权
  1309. if (!isAuthorization())
  1310. {
  1311. continue;
  1312. }
  1313. string json_pacs = JsonConvert.SerializeObject(plist);
  1314. json_pacs = "{\"mainBody\":" + json_pacs + "}";
  1315. string json_pacs_log = json_pacs;
  1316. string vi_pacs = Tools.GuidTo16String();
  1317. json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
  1318. string res_pacs = Tools.WSCenterData(url, json_pacs, vi_pacs, Tools.accessToken, 1);
  1319. string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
  1320. ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
  1321. if (respacs.statusCode != "1")
  1322. {
  1323. ShowLog = respacs.message + ",thread2 ,[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
  1324. this.SetText(ShowLog);
  1325. LogHelper.Info(ShowLog);
  1326. LogHelper.Info("thread2 [LIS]出错入参:" + json_pacs_log);
  1327. LogHelper.Info("thread2 [LIS]出错出参:" + res_aes_pacs);
  1328. continue;
  1329. }
  1330. else
  1331. {
  1332. Lis_total += 1;
  1333. uploaded += 1;//(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED) Values('{0}','{1}',2,'{2}',0)
  1334. string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 2
  1335. and BUSINESSNUMBER = '{0}'
  1336. and REPORTID = '{1}'";
  1337. sql_upload = string.Format(sql_upload, list[0].BUSINESSNUMBER, list[0].REPORTID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
  1338. int upload_count = 0;
  1339. if (zlhr==zlhrConstant_true)
  1340. {
  1341. upload_count = OracleHelper<object>.PgExecuteNonQuery(sql_upload);
  1342. }
  1343. else
  1344. {
  1345. upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
  1346. }
  1347. if (upload_count < 1)
  1348. {
  1349. LogHelper.Info("thread2 [LIS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
  1350. LogHelper.Info("thread2 执行sql:" + sql_upload);
  1351. ShowLog = "thread2 [LIS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
  1352. this.SetText(ShowLog);
  1353. continue;
  1354. }
  1355. }
  1356. }
  1357. ShowLog = Thread_name + "thread2 本次已生成、上传[LIS]PDF文件总条数为[" + pdfcountAll + "]条,上传[LIS]总条数为[" + uploaded + "]条。";
  1358. this.SetText(ShowLog);
  1359. LogHelper.Info(ShowLog);
  1360. GetLisDefault();
  1361. }
  1362. #endregion
  1363. }
  1364. }
  1365. catch (Exception ex)
  1366. {
  1367. LogHelper.Error(ex);
  1368. }
  1369. }
  1370. private object PacsLock = new object();
  1371. private void PacsUpload()
  1372. {
  1373. try
  1374. {
  1375. lock (PacsLock)
  1376. {
  1377. int uploaded = 0;
  1378. string url_pacs = "http://40.26.204.3:8084/phimp-napi/qyhrpacscheckreportinfo/save";
  1379. #region 1、生成、上传单条PACS文件及数据
  1380. LogHelper.Info("[PACS]开始");
  1381. string sql_pdf = @"select * from (
  1382. Select rownum as rn,b.* From (select t.* from PACS_UPLOAD t
  1383. Where t.attachmentId Is Null
  1384. Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss')
  1385. ) b
  1386. ) Where rn <= 100";
  1387. DataTable dt = OracleHelper<object>.RunQueryDS(sql_pdf);
  1388. if (dt.Rows.Count < 1)
  1389. {
  1390. LogHelper.Info("本次无数据,或[PACS]PDF已生成并上传。");
  1391. LogHelper.Info("执行sql:" + sql_pdf);
  1392. }
  1393. else
  1394. {
  1395. ShowLog = "本次需上传[PACS]数据总条数为[" + dt.Rows.Count + "]条,逐条上传中,请耐心等待。";
  1396. this.SetText(ShowLog);
  1397. int countAll = 0;
  1398. for (int i = 0; i < dt.Rows.Count; i++)
  1399. {
  1400. string orgName = dt.Rows[i]["orgName"].ToString();
  1401. string name = dt.Rows[i]["patientName"].ToString();
  1402. string sex = dt.Rows[i]["sex"].ToString();
  1403. string ch = dt.Rows[i]["bedNo"].ToString();
  1404. string zyh = dt.Rows[i]["zyh"].ToString();
  1405. string mzh = dt.Rows[i]["mzh"].ToString();//patientType
  1406. string age = dt.Rows[i]["age"].ToString();
  1407. string type;
  1408. string patientType = dt.Rows[i]["patientType"].ToString();
  1409. string dep = dt.Rows[i]["dep"].ToString();
  1410. if (patientType == "1")
  1411. {
  1412. type = "门诊";
  1413. }
  1414. else if (patientType == "2")
  1415. {
  1416. type = "住院";
  1417. }
  1418. else if (patientType == "3")
  1419. {
  1420. type = "体检";
  1421. }
  1422. else
  1423. {
  1424. type = "其他";
  1425. }
  1426. string baseInfo = "姓名:{0} 性别:{1} 年龄:{2} 病人来源:{3} 床号:{4} 住院号:{5} 门诊号:{6} 申请科室:{7}";
  1427. string findings = dt.Rows[i]["findings"].ToString();
  1428. string diagnosResult = dt.Rows[i]["diagnosResult"].ToString();
  1429. string signature = "签名:{0} 日期:{1}";
  1430. string qname = dt.Rows[i]["auditorName"].ToString();
  1431. string qdate = dt.Rows[i]["auditTime"].ToString();
  1432. signature = string.Format(signature, qname, qdate);
  1433. baseInfo = string.Format(baseInfo, name, sex, age, type, ch, zyh, mzh, dep);
  1434. string res = CreatePDF(orgName, baseInfo, findings, diagnosResult, signature);
  1435. if (res == "")
  1436. {
  1437. ShowLog = "生成PACS的PDF文件失败。[PACS]上传失败!跳过本条数据上传下一条。";
  1438. LogHelper.Info(ShowLog);
  1439. this.SetText(ShowLog);
  1440. continue;
  1441. }
  1442. //是否授权
  1443. if (!isAuthorization())
  1444. {
  1445. continue;
  1446. }
  1447. //string path = Application.StartupPath + "\\pacs.pdf";
  1448. //上传文件
  1449. string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检查报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + Tools.FileToBase64Str(res) + "\"}";
  1450. string file_vi = Tools.GuidTo16String();
  1451. file_json = Tools.AESEncrypt(file_json, Tools.pwd, file_vi);
  1452. string file_url = "http://40.26.204.3:8084/phimp-napi/attachMent/upload";
  1453. string file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
  1454. string file_res_aes = Tools.AESDecrypt(file_res, Tools.pwd, file_vi);
  1455. ResFile resfile = Tools.JsonToObject<ResFile>(Tools.FormatStr(file_res_aes), Encoding.UTF8);
  1456. if (resfile.statusCode != "1")
  1457. {
  1458. //LogHelper.Info(resfile.message + ",[PACS]文件上传失败,跳过本条数据上传下一条。");
  1459. LogHelper.Info("入参:" + file_json);
  1460. LogHelper.Info("出参:" + file_res_aes);
  1461. ShowLog = "入参:" + file_json + ",出参:" + file_res_aes + ",[PACS]文件上传失败,跳过本条数据上传下一条。";
  1462. this.SetText(ShowLog);
  1463. continue;
  1464. }
  1465. 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'))";
  1466. 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"));
  1467. int file_count = OracleHelper<object>.ExecuteNonQuery(sql);
  1468. if (file_count < 1)
  1469. {
  1470. ShowLog = "[PACS]新增表【已上传PDF】失败,跳过本条数据上传下一条。!";
  1471. LogHelper.Info(ShowLog);
  1472. this.SetText(ShowLog);
  1473. continue;
  1474. }
  1475. countAll += 1;
  1476. //上传数据
  1477. string item_sql = @"select
  1478. a.patientAge ,
  1479. a.ageUnit ,
  1480. a.patientIdCard ,
  1481. a.inTime ,
  1482. a.inpatientAreaName ,
  1483. a.roomNo ,
  1484. a.bedNo ,
  1485. a.phoneNo ,
  1486. a.address ,
  1487. a.reportTypeName ,
  1488. a.reportTypeCode ,
  1489. a.diagnosisCode ,
  1490. a.diagnosisName ,
  1491. a.applyTime ,
  1492. a.applyerCode ,
  1493. a.applyerName ,
  1494. a.applyDeptCode ,
  1495. a.applyDeptName ,
  1496. a.applyOrgCode ,
  1497. a.applyOrgName ,
  1498. a.receiverTime ,
  1499. a.receiverCode ,
  1500. a.receiverName ,
  1501. a.checkTime ,
  1502. a.checkerCode ,
  1503. a.checkerName ,
  1504. a.checkDeptCode ,
  1505. a.checkDeptName ,
  1506. a.reportTime ,
  1507. a.reportorCode ,
  1508. a.reportorName ,
  1509. a.auditTime ,
  1510. a.auditorCode ,
  1511. a.auditorName ,
  1512. a.localItemId ,
  1513. a.standardItemId ,
  1514. a.itemName ,
  1515. a.purpose ,
  1516. a.testPrice ,
  1517. a.checkTypeCode ,
  1518. a.checkTypeName ,
  1519. a.positionCode ,
  1520. a.positionName ,
  1521. a.methodCode ,
  1522. a.methodName ,
  1523. a.isEnganced ,
  1524. a.isMakeShadow ,
  1525. a.process ,
  1526. a.findings ,
  1527. a.diagnosResult ,
  1528. a.resultType ,
  1529. a.unit ,
  1530. a.machineType ,
  1531. a.machineCode ,
  1532. a.machineName ,
  1533. a.attachmentId ,
  1534. a.studyInstanceUid ,
  1535. a.dicomImgFtpUrl ,
  1536. a.orgCode ,
  1537. a.orgName ,
  1538. a.pacsYunOrgCode ,
  1539. a.reportId ,
  1540. a.reportName ,
  1541. a.reportType ,
  1542. a.requestId ,
  1543. a.businessNumber ,
  1544. a.patientType ,
  1545. a.patientName ,
  1546. a.patientSex ,
  1547. a.patientBirthday ,
  1548. a.regionHr,
  1549. a.HEALTHNO,
  1550. a.MEDICARENO ,
  1551. a.ACCESSNUMBER,
  1552. a.CONCLUSION,
  1553. a.BRIEFHISTORY,
  1554. a.ISIMAGESERVICE,
  1555. a.STUDYUID
  1556. from pacs_upload a ,已上传PDF b
  1557. where b.businessnumber = a.BUSINESSNUMBER
  1558. and b.reportid = a.REPORTID
  1559. and b.attachmentid is not null
  1560. and b.uploaded = 0
  1561. and b.type = 1
  1562. and a.BUSINESSNUMBER = '{0}'
  1563. and a.REPORTID = '{1}'";
  1564. item_sql = string.Format(item_sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString());
  1565. List<PACS> list = OracleHelper<PACS>.RunQueryList(item_sql);
  1566. if (list.Count < 1)
  1567. {
  1568. LogHelper.Info("查询PACS数据为空,跳过本条数据上传下一条。");
  1569. LogHelper.Info("执行sql:" + item_sql);
  1570. continue;
  1571. }
  1572. string json_pacs = Tools.ObjectToJson<List<PACS>>(list, Encoding.UTF8);
  1573. json_pacs = "{\"mainBody\":" + json_pacs + "}";
  1574. if (!isAuthorization())
  1575. {
  1576. continue;
  1577. }
  1578. string json_pacs_log = json_pacs;
  1579. string vi_pacs = Tools.GuidTo16String();
  1580. json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
  1581. string res_pacs = Tools.WSCenterData(url_pacs, json_pacs, vi_pacs, Tools.accessToken, 1);
  1582. string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
  1583. //LogHelper.Info("[PACS]上传出参:" + res_aes_pacs);
  1584. ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
  1585. if (respacs.statusCode != "1")
  1586. {
  1587. ShowLog = respacs.message + ",[PACS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
  1588. this.SetText(ShowLog);
  1589. LogHelper.Info("[PACS]出错入参:" + json_pacs_log);
  1590. LogHelper.Info("[PACS]出错出参:" + res_aes_pacs);
  1591. continue;
  1592. }
  1593. else
  1594. {
  1595. pacs_total += 1;
  1596. uploaded += 1;//(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED) Values('{0}','{1}',2,'{2}',0)
  1597. string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 1
  1598. and BUSINESSNUMBER = '{0}'
  1599. and REPORTID = '{1}'";
  1600. sql_upload = string.Format(sql_upload, list[0].BUSINESSNUMBER, list[0].REPORTID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
  1601. int upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
  1602. if (upload_count < 1)
  1603. {
  1604. LogHelper.Info("[PACS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
  1605. LogHelper.Info("执行sql:" + sql_upload);
  1606. ShowLog = "[PACS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
  1607. this.SetText(ShowLog);
  1608. continue;
  1609. }
  1610. }
  1611. }
  1612. ShowLog = "本次已生成、上传[PACS]PDF文件总条数为[" + countAll + "]条,上传[PACS]总条数为[" + uploaded + "]条。";
  1613. this.SetText(ShowLog);
  1614. LogHelper.Info(ShowLog);
  1615. GetPacsDefault();
  1616. }
  1617. #endregion
  1618. #region 2、补传失败数据
  1619. //上传数据
  1620. LogHelper.Info("PACS补传失败数据");
  1621. string pc_sql = @"select
  1622. a.patientAge ,
  1623. a.ageUnit ,
  1624. a.patientIdCard ,
  1625. a.inTime ,
  1626. a.inpatientAreaName ,
  1627. a.roomNo ,
  1628. a.bedNo ,
  1629. a.phoneNo ,
  1630. a.address ,
  1631. a.reportTypeName ,
  1632. a.reportTypeCode ,
  1633. a.diagnosisCode ,
  1634. a.diagnosisName ,
  1635. a.applyTime ,
  1636. a.applyerCode ,
  1637. a.applyerName ,
  1638. a.applyDeptCode ,
  1639. a.applyDeptName ,
  1640. a.applyOrgCode ,
  1641. a.applyOrgName ,
  1642. a.receiverTime ,
  1643. a.receiverCode ,
  1644. a.receiverName ,
  1645. a.checkTime ,
  1646. a.checkerCode ,
  1647. a.checkerName ,
  1648. a.checkDeptCode ,
  1649. a.checkDeptName ,
  1650. a.reportTime ,
  1651. a.reportorCode ,
  1652. a.reportorName ,
  1653. a.auditTime ,
  1654. a.auditorCode ,
  1655. a.auditorName ,
  1656. a.localItemId ,
  1657. a.standardItemId ,
  1658. a.itemName ,
  1659. a.purpose ,
  1660. a.testPrice ,
  1661. a.checkTypeCode ,
  1662. a.checkTypeName ,
  1663. a.positionCode ,
  1664. a.positionName ,
  1665. a.methodCode ,
  1666. a.methodName ,
  1667. a.isEnganced ,
  1668. a.isMakeShadow ,
  1669. a.process ,
  1670. a.findings ,
  1671. a.diagnosResult ,
  1672. a.resultType ,
  1673. a.unit ,
  1674. a.machineType ,
  1675. a.machineCode ,
  1676. a.machineName ,
  1677. a.attachmentId ,
  1678. a.studyInstanceUid ,
  1679. a.dicomImgFtpUrl ,
  1680. a.orgCode ,
  1681. a.orgName ,
  1682. a.pacsYunOrgCode ,
  1683. a.reportId ,
  1684. a.reportName ,
  1685. a.reportType ,
  1686. a.requestId ,
  1687. a.businessNumber ,
  1688. a.patientType ,
  1689. a.patientName ,
  1690. a.patientSex ,
  1691. a.patientBirthday ,
  1692. a.regionHr,
  1693. a.HEALTHNO,
  1694. a.MEDICARENO ,
  1695. a.ACCESSNUMBER,
  1696. a.CONCLUSION,
  1697. a.BRIEFHISTORY,
  1698. a.ISIMAGESERVICE,
  1699. a.STUDYUID
  1700. from pacs_upload a ,已上传PDF b
  1701. where b.businessnumber = a.BUSINESSNUMBER
  1702. and b.reportid = a.REPORTID
  1703. and b.attachmentid is not null
  1704. and b.uploaded = 0
  1705. and b.type = 1";
  1706. List<PACS> list_pc = OracleHelper<PACS>.RunQueryList(pc_sql);
  1707. if (list_pc.Count < 1)
  1708. {
  1709. LogHelper.Info("查询补传PACS数据为空,等待下一次轮询。");
  1710. LogHelper.Info("执行sql:" + pc_sql);
  1711. return;
  1712. }
  1713. int count_pc = 0;
  1714. for (int i = 0; i < list_pc.Count; i++)
  1715. {
  1716. if (!isAuthorization())
  1717. {
  1718. continue;
  1719. }
  1720. string json_pacs = Tools.ObjectToJson<List<PACS>>(list_pc[i], Encoding.UTF8);
  1721. json_pacs = "{\"mainBody\":[" + json_pacs + "]}";
  1722. string json_pacs_log = json_pacs;
  1723. string vi_pacs = Tools.GuidTo16String();
  1724. json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
  1725. string res_pacs = Tools.WSCenterData(url_pacs, json_pacs, vi_pacs, Tools.accessToken, 1);
  1726. string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
  1727. //LogHelper.Info("[PACS]上传出参:" + res_aes_pacs);
  1728. ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
  1729. if (respacs.statusCode != "1")
  1730. {
  1731. ShowLog = respacs.message + ",[PACS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
  1732. this.SetText(ShowLog);
  1733. LogHelper.Info("[PACS]出错入参:" + json_pacs_log);
  1734. LogHelper.Info("[PACS]出错出参:" + res_aes_pacs);
  1735. continue;
  1736. }
  1737. else
  1738. {
  1739. pacs_total += 1;
  1740. count_pc += 1;
  1741. string sql_upload = @"update 已上传PDF set UPLOADED = 1,UPLOADE_TIME = to_date('{2}','yyyy/mm/dd hh24:mi:ss') where type = 1
  1742. and BUSINESSNUMBER = '{0}'
  1743. and REPORTID = '{1}'";
  1744. sql_upload = string.Format(sql_upload, list_pc[i].BUSINESSNUMBER, list_pc[i].REPORTID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
  1745. int upload_count = OracleHelper<object>.ExecuteNonQuery(sql_upload);
  1746. if (upload_count < 1)
  1747. {
  1748. LogHelper.Info("[PACS]更新表【已上传PDF】失败,跳过本条数据上传下一条!");
  1749. LogHelper.Info("执行sql:" + sql_upload);
  1750. ShowLog = "[PACS]新增表【已上传PDF】失败,跳过本条数据上传下一条!执行sql:" + sql_upload;
  1751. this.SetText(ShowLog);
  1752. continue;
  1753. }
  1754. }
  1755. }
  1756. if (count_pc > 0)
  1757. {
  1758. ShowLog = "本次补传[PACS]数据为[" + count_pc + "]条,等待下一次轮询。";
  1759. this.SetText(ShowLog);
  1760. LogHelper.Info(ShowLog);
  1761. GetPacsDefault();
  1762. }
  1763. #endregion
  1764. }
  1765. }
  1766. catch (Exception ex)
  1767. {
  1768. LogHelper.Error(ex);
  1769. }
  1770. }
  1771. /// <summary>
  1772. /// 生成pdf
  1773. /// </summary>
  1774. /// <param name="orgName">印江自治县人民医院</param>
  1775. /// <param name="baseInfo">"姓名:刘蚝 性别:男 年龄:20岁 床号:8床 住院号:20121545 门诊号:65478854"</param>
  1776. /// <param name="findings"></param>
  1777. /// <param name="diagnosResult"></param>
  1778. /// <param name="signature">签名:杨添红 日期:2022.9.7</param>
  1779. private string CreatePDF(string orgName, string baseInfo, string findings, string diagnosResult, string signature)
  1780. {
  1781. string res = "";
  1782. try
  1783. {
  1784. Document document = new Document(HeaderAndFooterEvent.rect);
  1785. //string dic = AppDomain.CurrentDomain.BaseDirectory + "Pacs\\";
  1786. if (!Directory.Exists(DicPacs))
  1787. {
  1788. Directory.CreateDirectory(DicPacs);
  1789. }
  1790. string path = DicPacs + Guid.NewGuid() + ".pdf";
  1791. //此处使用的是http请求的流,你也可以使用文件流Stream
  1792. FileStream str = new FileStream(path, FileMode.Create);
  1793. PdfWriter writer = PdfWriter.GetInstance(document, str);
  1794. document.Open();
  1795. writer.PageEvent = new HeaderAndFooterEvent();
  1796. HeaderAndFooterEvent.PAGE_NUMBER = false;//实现页眉跟页脚
  1797. HeaderAndFooterEvent.tpl = writer.DirectContent.CreateTemplate(500, 500); //定义模板
  1798. //印江自治县人民医院
  1799. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
  1800. document.Add(HeaderAndFooterEvent.AddParagraph(orgName, 1, 1.5f));
  1801. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
  1802. document.Add(HeaderAndFooterEvent.AddParagraph("检查报告单", 1, 1.5f));
  1803. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
  1804. document.Add(HeaderAndFooterEvent.AddParagraph(baseInfo, 0, 3f));
  1805. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
  1806. document.Add(HeaderAndFooterEvent.AddParagraph(" ", 1, 1.5f));
  1807. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
  1808. document.Add(HeaderAndFooterEvent.AddParagraph(@"诊断意见:" + diagnosResult, 0, 1.5f));
  1809. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
  1810. document.Add(HeaderAndFooterEvent.AddParagraph(@"检查所见:" + findings, 0, 1.5f));
  1811. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
  1812. document.Add(HeaderAndFooterEvent.AddParagraph(" ", 1, 1.5f));
  1813. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
  1814. document.Add(HeaderAndFooterEvent.AddParagraph(signature, 2, 1.5f));
  1815. writer.Flush();
  1816. writer.CloseStream = true;
  1817. document.Close();
  1818. //writer.Close();
  1819. //str.Close();
  1820. res = path;
  1821. }
  1822. catch (Exception ex)
  1823. {
  1824. res = "";
  1825. LogHelper.Error(ex);
  1826. }
  1827. return res;
  1828. }
  1829. private string CreateLisPDF(string orgName, string baseInfo, DataTable dt, string signature, string title)
  1830. {
  1831. string res = "";
  1832. try
  1833. {
  1834. Document document = new Document(HeaderAndFooterEvent.rect);
  1835. //此处使用的是http请求的流,你也可以使用文件流Stream
  1836. //string dic = AppDomain.CurrentDomain.BaseDirectory + "Lis\\";
  1837. if (!Directory.Exists(DicLis))
  1838. {
  1839. Directory.CreateDirectory(DicLis);
  1840. }
  1841. string path = DicLis + Guid.NewGuid() + ".pdf";
  1842. FileStream str = new FileStream(path, FileMode.Create);
  1843. PdfWriter writer = PdfWriter.GetInstance(document, str);
  1844. document.Open();
  1845. writer.PageEvent = new HeaderAndFooterEvent();
  1846. HeaderAndFooterEvent.PAGE_NUMBER = false;//实现页眉跟页脚
  1847. HeaderAndFooterEvent.tpl = writer.DirectContent.CreateTemplate(500, 500); //定义模板
  1848. //印江自治县人民医院
  1849. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
  1850. document.Add(HeaderAndFooterEvent.AddParagraph(orgName, 1, 1.5f));
  1851. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
  1852. document.Add(HeaderAndFooterEvent.AddParagraph(title + "报告单", 1, 1.5f));
  1853. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
  1854. document.Add(HeaderAndFooterEvent.AddParagraph(baseInfo, 0, 3f));
  1855. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
  1856. document.Add(HeaderAndFooterEvent.AddParagraph(" ", 1, 1.5f));
  1857. //HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
  1858. //document.Add(HeaderAndFooterEvent.AddParagraph(@"序号 项目 结果 单位 参考区间", 0, 1.5f));
  1859. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
  1860. HeaderAndFooterEvent.CreateTable(dt, document);
  1861. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 12);
  1862. document.Add(HeaderAndFooterEvent.AddParagraph(" ", 1, 1.5f));
  1863. HeaderAndFooterEvent.SetFont(BaseColor.DARK_GRAY, "宋体", 8);
  1864. document.Add(HeaderAndFooterEvent.AddParagraph(signature, 2, 1.5f));
  1865. writer.Flush();
  1866. writer.CloseStream = true;
  1867. document.Close();
  1868. res = path;
  1869. }
  1870. catch (Exception ex)
  1871. {
  1872. LogHelper.Info("CreateLisPDF 生成失败");
  1873. res = "";
  1874. LogHelper.Error(ex);
  1875. }
  1876. return res;
  1877. }
  1878. //token是否过期
  1879. private bool isAuthorization()
  1880. {
  1881. bool result = true;
  1882. if (string.IsNullOrWhiteSpace(Tools.accessToken) || Tools.DateTimes == null || Tools.DateTimes <= DateTime.Now)
  1883. {
  1884. //获取授权
  1885. string vi = Tools.GuidTo16String();
  1886. string url = "http://40.26.204.3:8084/phimp-napi/token";
  1887. string res = Tools.WSCenterData(url, "", vi);
  1888. string res_aes = Tools.AESDecrypt(res, Tools.pwd, vi);
  1889. Authorization ahz = Tools.JsonToObject<Authorization>(Tools.FormatStr(res_aes), Encoding.UTF8);
  1890. if (ahz.statusCode != "1")
  1891. {
  1892. ShowLog = ahz.message + ",获取Token授权失败!等待下一次轮询。";
  1893. this.SetText(ShowLog);
  1894. LogHelper.Info(ShowLog);
  1895. result = false;
  1896. }
  1897. Tools.accessToken = ahz.mainBody.accessToken;
  1898. Tools.DateTimes = DateTime.Now.AddSeconds(int.Parse(ahz.mainBody.expirationTime));
  1899. }
  1900. return result;
  1901. }
  1902. private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  1903. {
  1904. if (e.CloseReason == CloseReason.UserClosing)
  1905. {
  1906. //是否取消close操作
  1907. e.Cancel = true;
  1908. this.WindowState = FormWindowState.Minimized;
  1909. }
  1910. }
  1911. private void checkBox1_Click(object sender, EventArgs e)
  1912. {
  1913. int hr = 0;
  1914. string sql = @"update 互认配置表 set 互认 = {0}";
  1915. bool bl = checkBox1.Checked;
  1916. if (checkBox1.Checked)
  1917. {
  1918. hr = 1;
  1919. }
  1920. sql = string.Format(sql, hr);
  1921. int res = OracleHelper<object>.ExecuteNonQuery(sql);
  1922. if (res > 0)
  1923. {
  1924. if (bl)
  1925. {
  1926. textBox1.Text = "已修改为互认!";
  1927. }
  1928. else
  1929. {
  1930. textBox1.Text = "已修改为不互认!";
  1931. }
  1932. }
  1933. else
  1934. {
  1935. textBox1.Text = "是否互认修改失败!";
  1936. if (bl)
  1937. {
  1938. checkBox1.Checked = false;
  1939. }
  1940. else
  1941. {
  1942. checkBox1.Checked = true;
  1943. }
  1944. }
  1945. }
  1946. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  1947. {
  1948. AutoStart();
  1949. }
  1950. public void GetLisDefault()
  1951. {
  1952. string sql = @"select count(1) listotal from lis_upload where attachmentId is null";
  1953. DataTable dt = new DataTable();
  1954. if (zlhr==zlhrConstant_true)
  1955. {
  1956. dt = OracleHelper<object>.PgQueryDS(sql);
  1957. }
  1958. else
  1959. {
  1960. dt = OracleHelper<object>.RunQueryDS(sql);
  1961. }
  1962. string label_lis = dt.Rows[0]["listotal"].ToString() + "条";
  1963. string lis_count = Lis_total + "条";
  1964. this.SetLisText(label_lis);
  1965. this.SetLisCountText(lis_count);
  1966. //获取待上传的数量
  1967. string waitsql = @"select count(1) listotal from lis_upload a ,已上传PDF b
  1968. where b.businessnumber = a.BUSINESSNUMBER
  1969. and b.reportid = a.REPORTID
  1970. and b.attachmentid is not null
  1971. and b.uploaded = 0
  1972. and b.type = 2";
  1973. DataTable waitdt = new DataTable();
  1974. if (zlhr == zlhrConstant_true)
  1975. {
  1976. waitdt = OracleHelper<object>.PgQueryDS(waitsql);
  1977. }
  1978. else
  1979. {
  1980. waitdt = OracleHelper<object>.RunQueryDS(sql);
  1981. }
  1982. LogHelper.Info("待上传数量为:" + waitdt.Rows[0]["listotal"].ToString() + "条");
  1983. }
  1984. public void GetPacsDefault()
  1985. {
  1986. string sql = @"select count(1) pacstotal from pacs_upload where attachmentId is null";
  1987. DataTable dt = OracleHelper<object>.RunQueryDS(sql);
  1988. string label_pacs = dt.Rows[0]["pacstotal"].ToString() + "条";
  1989. string pacs_count = pacs_total + "条";
  1990. this.SetPassText(label_pacs);
  1991. this.SetPacsCountText(pacs_count);
  1992. }
  1993. private void SetText(string text)
  1994. {
  1995. // InvokeRequired需要比较调用线程ID和创建线程ID
  1996. // 如果它们不相同则返回true
  1997. if (this.textBox1.InvokeRequired)
  1998. {
  1999. SetTextCallback d = new SetTextCallback(SetText);
  2000. this.Invoke(d, new object[] { text });
  2001. }
  2002. else
  2003. {
  2004. this.textBox1.Text = text;
  2005. }
  2006. }
  2007. private void SetLisText(string text)
  2008. {
  2009. // InvokeRequired需要比较调用线程ID和创建线程ID
  2010. // 如果它们不相同则返回true
  2011. if (this.textBox1.InvokeRequired)
  2012. {
  2013. SetTextCallback d = new SetTextCallback(SetLisText);
  2014. this.Invoke(d, new object[] { text });
  2015. }
  2016. else
  2017. {
  2018. this.label_lis.Text = text;
  2019. }
  2020. }
  2021. private void SetPassText(string text)
  2022. {
  2023. // InvokeRequired需要比较调用线程ID和创建线程ID
  2024. // 如果它们不相同则返回true
  2025. if (this.textBox1.InvokeRequired)
  2026. {
  2027. SetTextCallback d = new SetTextCallback(SetPassText);
  2028. this.Invoke(d, new object[] { text });
  2029. }
  2030. else
  2031. {
  2032. this.label_pacs.Text = text;
  2033. }
  2034. }
  2035. private void SetLisCountText(string text)
  2036. {
  2037. // InvokeRequired需要比较调用线程ID和创建线程ID
  2038. // 如果它们不相同则返回true
  2039. if (this.textBox1.InvokeRequired)
  2040. {
  2041. SetTextCallback d = new SetTextCallback(SetLisCountText);
  2042. this.Invoke(d, new object[] { text });
  2043. }
  2044. else
  2045. {
  2046. this.lis_count.Text = text;
  2047. }
  2048. }
  2049. private void SetPacsCountText(string text)
  2050. {
  2051. // InvokeRequired需要比较调用线程ID和创建线程ID
  2052. // 如果它们不相同则返回true
  2053. if (this.textBox1.InvokeRequired)
  2054. {
  2055. SetTextCallback d = new SetTextCallback(SetPacsCountText);
  2056. this.Invoke(d, new object[] { text });
  2057. }
  2058. else
  2059. {
  2060. this.pacs_count.Text = text;
  2061. }
  2062. }
  2063. private void DelPDF()
  2064. {
  2065. //每月1号删除
  2066. if (DateTime.Now.Day != 1)
  2067. {
  2068. return;
  2069. }
  2070. int month = OracleHelper<object>.UploadTime();
  2071. if (month < 1)
  2072. {
  2073. return;
  2074. }
  2075. string sql = @"delete from 已上传PDF a where a.uploaded = 1 And a.Uploade_Time < add_months(Sysdate,-{0})";
  2076. sql = string.Format(sql,month);
  2077. OracleHelper<object>.ExecuteNonQuery(sql);
  2078. }
  2079. }
  2080. }