BasicData.cs 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PTMedicalInsurance.Business;
  4. using PTMedicalInsurance.Helper;
  5. using PTMedicalInsurance.Variables;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. using PTMedicalInsurance.FormSetter;
  17. using PTMedicalInsurance.Common;
  18. using PTMedicalInsurance.Forms.BasicDatas;
  19. namespace PTMedicalInsurance.Forms
  20. {
  21. public partial class BasicData : Form
  22. {
  23. //设置实例
  24. CenterBusiness cBus = new CenterBusiness();
  25. HisMainBusiness hBus = new HisMainBusiness();
  26. HisIrisServices hIS = new HisIrisServices();
  27. MIIrisServices mIS = new MIIrisServices();
  28. InvokeHelper invoker = new InvokeHelper();
  29. private bool isStopLoopDownload = false;
  30. DataTable dtExport;
  31. public BasicData()
  32. {
  33. InitializeComponent();
  34. this.tcBasicData.TabPages[3].Parent = null;
  35. rbgDirecType.SelectedIndex = 0;
  36. rbgDirecType_C.SelectedIndex = 0;
  37. rbgDirecType.SelectedIndex = 8;
  38. rbgDownItemType_4.SelectedIndex = 0;
  39. rbgInsuDirecType_C.SelectedIndex = 0;
  40. rbSingleDown.Checked = true;
  41. this.rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(this.rbgDirecType_ValueChanged);
  42. this.pgDownload.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgDownload_PageChanged);
  43. this.pgCenterDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgCenterDirect_PageChanged);
  44. this.pgHISDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
  45. Font rowFont = new Font("UTF-8", 8);
  46. Font columnFont = new Font("UTF-8", 9);
  47. rbAll.Checked = true;
  48. this.rbAll.ValueChanged += new Sunny.UI.UIRadioButton.OnValueChanged(this.rbAll_ValueChanged);
  49. GridViewSetter gvs = new GridViewSetter();
  50. gvs.SetHeaderTextOfInsuDir(dgvInsuDirInfo);
  51. gvs.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory);
  52. }
  53. #region 函数封装
  54. private void queryInsuDirectory(int currentPage, int pageSize, int directoryType, int interfaceDr, string code)
  55. {
  56. try
  57. {
  58. string dirCode = "";
  59. string dirName = "";
  60. string verNO = "";
  61. string approvalNO = "";
  62. Sunny.UI.UIDataGridView dgv;
  63. Sunny.UI.UIPagination pg;
  64. if (tcBasicData.SelectedIndex == 1)
  65. {
  66. dirCode = tbDirectoryCode.Text;
  67. dirName = tbDircetoryName.Text;
  68. verNO = tbDirectoryVerNO.Text;
  69. approvalNO = "";
  70. dgv = dgvDirectoy;
  71. pg = pgDownload;
  72. }
  73. else
  74. {
  75. dirName = tbCenterDirectoryFilter.Text;
  76. dirCode = tbInsuCode.Text;
  77. dgv = dgvCenterDirectory;
  78. approvalNO = tbApprovalNO.Text;
  79. pg = pgCenterDirect;
  80. }
  81. JObject joInput = new JObject {
  82. { "currentPage" , currentPage },
  83. { "pageSize" , pageSize },
  84. { "serviceCode" , code },
  85. { "directoryType" , directoryType },
  86. { "directoryCode" , dirCode },
  87. { "directoryName" , dirName },
  88. { "approvalNO" , approvalNO },
  89. { "verNO" , verNO },
  90. { "directoryDr" , interfaceDr }
  91. };
  92. JObject joRtn = mIS.getMIDirectoryByPagination(joInput);
  93. if (joRtn["errorCode"].ToString() != "0")
  94. {
  95. MessageBox.Show("IRIS数据返回错误:" + joRtn["errorMessage"].ToString());
  96. return;
  97. }
  98. if (joRtn["result"]["rows"] == null)
  99. {
  100. MessageBox.Show("该节点不存在");
  101. return;
  102. }
  103. if (joRtn["result"]["total"].ToString() == "0")
  104. {
  105. MessageBox.Show("未查询到数据");
  106. dgv.DataSource = null;
  107. return;
  108. }
  109. DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
  110. int totalCount = int.Parse(joRtn["result"]["total"].ToString());
  111. pg.TotalCount = totalCount;
  112. pg.PageSize = pageSize;
  113. dgv.DataSource = dt;
  114. dgv.Columns[0].ReadOnly = true;
  115. }
  116. catch (Exception ex)
  117. {
  118. MessageBox.Show("查询异常:" + ex.Message);
  119. }
  120. }
  121. private void setHeaderTxt(int directoryType, Sunny.UI.UIDataGridView dgv)
  122. {
  123. GridViewSetter gvdSetter = new GridViewSetter();
  124. switch (directoryType)
  125. {
  126. case 0://药品
  127. {
  128. gvdSetter.SetHeaderTextOfDrug(dgv);
  129. break;
  130. }
  131. case 1://诊疗
  132. {
  133. gvdSetter.SetHeaderTextOfMedicalService(dgv);
  134. break;
  135. }
  136. case 2://材料
  137. {
  138. gvdSetter.SetHeaderTextOfMaterials(dgv);
  139. break;
  140. }
  141. case 3://疾病诊断
  142. {
  143. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  144. break;
  145. }
  146. case 4://手术
  147. {
  148. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  149. break;
  150. }
  151. case 5://慢性病
  152. {
  153. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  154. break;
  155. }
  156. case 6://DRGs
  157. {
  158. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  159. break; ;
  160. }
  161. case 7://日间手术
  162. {
  163. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  164. break; ;
  165. }
  166. case 8://字典表
  167. {
  168. gvdSetter.SetHeaderTextOfDictionary(dgv);
  169. break;
  170. }
  171. case 9://中药饮片
  172. {
  173. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  174. break;
  175. }
  176. case 10://医疗机构制剂
  177. {
  178. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  179. break;
  180. }
  181. case 11://民族药品
  182. {
  183. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  184. break;
  185. }
  186. case 12://肿瘤形态学
  187. {
  188. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  189. break;
  190. }
  191. case 13://中医疾病目录
  192. {
  193. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  194. break;
  195. }
  196. case 14://中医证候目录
  197. {
  198. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  199. break;
  200. }
  201. }
  202. }
  203. private void queryHISInsuDirectory(int directoryType, int pageIndex, int count, Sunny.UI.UIDataGridView dgv, int interfaceDr)
  204. {
  205. string code = "09010042";
  206. if (tcBasicData.SelectedIndex == 1)
  207. {
  208. if (rbgDirecType.SelectedIndex == 8)
  209. { code = "09010043"; }
  210. }
  211. queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
  212. if (tcBasicData.SelectedIndex == 1)
  213. {
  214. setHeaderTxt(directoryType, dgv);
  215. }
  216. else
  217. {
  218. setHeaderTxt(directoryType, dgv);
  219. }
  220. }
  221. private int queryHISDirectory(int currentPage, int pageSize, out string errMsg)
  222. {
  223. errMsg = "";
  224. string directoryType = string.Empty;
  225. switch (rbgDirecType_C.SelectedIndex)
  226. {
  227. case 0:
  228. {
  229. directoryType = "drugs";
  230. break;
  231. }
  232. case 1:
  233. {
  234. directoryType = "diagnosi";
  235. break;
  236. }
  237. case 2:
  238. {
  239. directoryType = "consumables";
  240. break;
  241. }
  242. }
  243. JObject joHISRtn = new JObject();
  244. JObject joRtn = new JObject();
  245. InvokeHelper invoker = new InvokeHelper();
  246. string flag = "";
  247. //全部是先调HIS,然后再匹配医保平台的对照关系
  248. if (rbAll.Checked)
  249. {
  250. JArray jaPagination = new JArray();
  251. JArray jaParams = new JArray();
  252. flag = "All";
  253. dynamic joParam = new JObject();
  254. joParam.code = "";
  255. joParam.descripts = "";
  256. joParam.FindType = new JArray();
  257. joParam.TypeID = "";
  258. joParam.alias = tbHISDirectoryFilter.Text;
  259. joParam.include = "Hosp";
  260. joParam.groupID = "324";
  261. joParam.hospID = Global.inf.hisHospitalDr;
  262. joParam.interfaceDr = Global.inf.interfaceDr;
  263. joParam.type = directoryType;
  264. joParam.flag = flag;
  265. joParam.specInput = "";
  266. jaParams.Add(joParam);
  267. dynamic joPagination = new JObject();
  268. joPagination.pageSize = pageSize;
  269. //joPagination.pageSize = 2;
  270. joPagination.currentPage = currentPage;
  271. joPagination.sortColumn = "Code";
  272. joPagination.sortOrder = "asc";
  273. jaPagination.Add(joPagination);
  274. //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
  275. //joInParams.code = "09010038";
  276. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  277. {
  278. return -1;
  279. }
  280. joRtn = mIS.ConvertHISDir(joHISRtn);
  281. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  282. {
  283. return -1;
  284. }
  285. }
  286. //已对照是先调云医保,然后再匹配HIS
  287. if (rbMaped.Checked)
  288. {
  289. JArray jaPagination = new JArray();
  290. JArray jaParams = new JArray();
  291. flag = "Maped";
  292. dynamic joParam = new JObject();
  293. joParam.alias = tbHISDirectoryFilter.Text;
  294. joParam.InsuAlias = tbMappedInfo.Text;
  295. joParam.HospitalDr = Global.inf.hospitalDr;
  296. joParam.InterfaceDr = Global.inf.interfaceDr;
  297. joParam.hisType = directoryType;
  298. jaParams.Add(joParam);
  299. dynamic joPagination = new JObject();
  300. joPagination.pageSize = pageSize;
  301. joPagination.currentPage = currentPage;
  302. joPagination.sortColumn = "HisCode";
  303. joPagination.sortOrder = "asc";
  304. jaPagination.Add(joPagination);
  305. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
  306. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  307. {
  308. return -1;
  309. }
  310. JArray jaMaped = JArray.FromObject(joMIRtn["result"]["Data"]);
  311. if (jaMaped.Count < 1)
  312. {
  313. errMsg = "未查询到对照数据!";
  314. dgvHISDirectory.DataSource = null;
  315. return -1;
  316. }
  317. //传给HIS,进行匹配
  318. joParam = new JObject();
  319. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  320. joParam.type = directoryType;
  321. joParam.flag = flag;
  322. joParam.hospID = Global.inf.hisHospitalDr;
  323. joParam.interfaceDr = Global.inf.interfaceDr;
  324. joParam.alias = tbHISDirectoryFilter.Text;
  325. joParam.include = "Hosp";
  326. joParam.groupID = "324";
  327. joParam.compareArr = joMIRtn["result"]["Data"];
  328. jaParams = new JArray();
  329. jaParams.Add(joParam);
  330. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  331. {
  332. return -1;
  333. }
  334. else
  335. {
  336. JArray jaData = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.Data"));
  337. for (int i = 0; i < jaData.Count; i++)
  338. {
  339. jaData[i]["flag"] = new JObject();
  340. jaData[i]["flag"] = "已对照";
  341. }
  342. joRtn["result"]["Data"] = jaData;
  343. Global.writeLog(joRtn.ToString());
  344. }
  345. }
  346. //未对照
  347. if (rbNoMaped.Checked)
  348. {
  349. JArray jaPagination = new JArray();
  350. JArray jaParams = new JArray();
  351. flag = "All";
  352. dynamic joParam = new JObject();
  353. joParam.code = "";
  354. joParam.descripts = "";
  355. joParam.FindType = new JArray();
  356. joParam.TypeID = "";
  357. joParam.alias = tbHISDirectoryFilter.Text;
  358. joParam.include = "Hosp";
  359. joParam.groupID = "324";
  360. joParam.hospID = Global.inf.hisHospitalDr;
  361. joParam.interfaceDr = Global.inf.interfaceDr;
  362. joParam.type = directoryType;
  363. joParam.flag = flag;
  364. joParam.specInput = "";
  365. jaParams.Add(joParam);
  366. dynamic joPagination = new JObject();
  367. joPagination.pageSize = pageSize; //pageSize;
  368. //joPagination.pageSize = 2;
  369. joPagination.currentPage = currentPage;
  370. joPagination.sortColumn = "Code";
  371. joPagination.sortOrder = "asc";
  372. jaPagination.Add(joPagination);
  373. //1.获取全部HIS目录
  374. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  375. {
  376. return -1;
  377. }
  378. joRtn = mIS.GetNoMappHISDir(joHISRtn);
  379. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  380. {
  381. return -1;
  382. }
  383. }
  384. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  385. dtExport = dt;
  386. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  387. pgHISDirect.TotalCount = totalCount;
  388. pgHISDirect.PageSize = 50;
  389. dgvHISDirectory.DataSource = null;
  390. dgvHISDirectory.DataSource = dt;
  391. dgvHISDirectory.Columns[0].ReadOnly = true;
  392. return 0;
  393. }
  394. private void queryCenterDirectory_09010012(int currentPage, int pageSize)
  395. {
  396. string directoryType = string.Empty;
  397. switch (rbgDirecType_C.SelectedIndex)
  398. {
  399. case 0:
  400. {
  401. directoryType = "drugs";
  402. break;
  403. }
  404. case 1:
  405. {
  406. directoryType = "diagnosi";
  407. break;
  408. }
  409. case 2:
  410. {
  411. directoryType = "consumables";
  412. break;
  413. }
  414. }
  415. dynamic joInParams = new JObject();
  416. joInParams.pagination = new JArray() as dynamic;
  417. joInParams.session = new JArray() as dynamic;
  418. JArray jaParams = new JArray();
  419. dynamic joParams = new JObject();
  420. joParams.code = "";
  421. joParams.descripts = "";
  422. joParams.FindType = new JArray();
  423. joParams.TypeID = "";
  424. joParams.alias = "";
  425. joParams.include = "Hosp";
  426. joParams.groupID = "324";
  427. joParams.hospID = "25";
  428. joParams.type = directoryType;
  429. joParams.specInput = "";
  430. jaParams.Add(joParams);
  431. joInParams.Add("params", JArray.FromObject(jaParams));
  432. dynamic joSession = new JObject();
  433. joSession.userID = "";
  434. joSession.locID = "";
  435. joSession.groupID = "";
  436. joSession.hospID = "";
  437. joSession.sessionID = "";
  438. joSession.hospCode = "";
  439. joSession.language = "";
  440. joSession.hostName = "";
  441. joSession.ipv4 = "";
  442. joSession.ipv6 = "";
  443. joSession.mac = "";
  444. joInParams.session.Add(joSession);
  445. dynamic joPagination = new JObject();
  446. joPagination.pageSize = pageSize;
  447. joPagination.currentPage = currentPage;
  448. joPagination.sortColumn = "Code";
  449. joPagination.sortOrder = "asc";
  450. joInParams.pagination.Add(joPagination);
  451. joInParams.code = "09010012";
  452. string sInput = joInParams.ToString();
  453. string sRtn = invoker.invokeInsuService(joInParams, "");
  454. JObject jsonRtn = JObject.Parse(sRtn);
  455. if (jsonRtn["result"]["Data"] == null)
  456. {
  457. MessageBox.Show("该节点不存在");
  458. return;
  459. }
  460. JObject joRtn = JObject.Parse(sRtn);
  461. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  462. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  463. pgCenterDirect.TotalCount = totalCount;
  464. pgCenterDirect.PageSize = 50;
  465. dgvCenterDirectory.DataSource = dt;
  466. }
  467. private void Mapping()
  468. {
  469. JObject joRtn = new JObject();
  470. JObject joIn = new JObject();
  471. int iRtn = -1;
  472. try
  473. {
  474. int iHis = dgvHISDirectory.CurrentRow.Index;
  475. if (dgvCenterDirectory.CurrentRow == null)
  476. {
  477. MessageBox.Show("请查询中心目录");
  478. return;
  479. }
  480. int iCenter = dgvCenterDirectory.CurrentRow.Index;
  481. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  482. DataTable dtCenter = (DataTable)dgvCenterDirectory.DataSource;
  483. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Code"].Value.ToString();
  484. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Name"].Value.ToString();
  485. int hisType = rbgDirecType_C.SelectedIndex + 1;
  486. string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString(); ;
  487. JArray jaParams = new JArray();
  488. dynamic jsonTemp = new JObject();
  489. if (dtHis.Rows[iHis]["MapID"].ToString() == "0")
  490. {
  491. jsonTemp.ID = "";
  492. }
  493. else
  494. {
  495. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  496. }
  497. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  498. jsonTemp.updateUserID = Global.user.ID;
  499. jsonTemp.InterfaceDr = Global.inf.interfaceDr;
  500. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  501. jsonTemp.HISName = dgvHISDirectory.Rows[iHis].Cells["itemDesc"].Value;
  502. jsonTemp.ChargeItemDr = dtHis.Rows[iHis]["ID"];
  503. jsonTemp.DiretoryDr = dtCenter.Rows[iCenter]["medInsuDirectoryID"];
  504. //1.已对照 2.已对照但未上传 3 已对照且已上传
  505. jsonTemp.State = 1;
  506. jsonTemp.HisType = hisType;
  507. jsonTemp.HisTypeName = hisTypeName;
  508. jsonTemp.InsuCode = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Code"].Value;
  509. jsonTemp.InsuName = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Name"].Value;
  510. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  511. jaParams.Add(jsonTemp);
  512. joIn = new JObject();
  513. joIn.Add(new JProperty("params", jaParams));
  514. joIn.Add("code", "09010040");
  515. InvokeHelper invoker = new InvokeHelper();
  516. joRtn = invoker.invokeInsuService(joIn.ToString(), "插入对照信息");
  517. //JObject joRtn = JObject.Parse(irisRtn);
  518. iRtn = (int)joRtn["errorCode"];
  519. if (iRtn == 0)
  520. {
  521. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "已对照";
  522. }
  523. else
  524. {
  525. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
  526. }
  527. }
  528. finally
  529. {
  530. invoker.saveYHLog("数据对照", joIn.ToString(),DateTime.Now.ToString("yyyyMMddHHmmssnnn") ,"",joRtn.ToString(),iRtn,$"{Global.user.ID}:{Global.user.name}");
  531. Global.writeLog($"数据对照({Global.user.ID}:{Global.user.name})", joIn.ToString(),joRtn.ToString());
  532. }
  533. }
  534. private void CancleMapping()
  535. {
  536. int iHis = dgvHISDirectory.CurrentRow.Index;
  537. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  538. JArray jaParams = new JArray();
  539. dynamic jsonTemp = new JObject();
  540. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  541. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  542. jsonTemp.updateUserID = Global.user.ID;
  543. jsonTemp.InterfaceDr = Global.inf.interfaceDr;
  544. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  545. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  546. jaParams.Add(jsonTemp);
  547. JObject joIn = new JObject();
  548. joIn.Add(new JProperty("params", jaParams));
  549. joIn.Add("code", "09010041");
  550. InvokeHelper invoker = new InvokeHelper();
  551. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "取消对照");
  552. if ((int)joRtn["errorCode"] == 0)
  553. {
  554. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = "";
  555. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = "";
  556. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "未对照";
  557. dtHis.Rows[iHis]["MapID"] = 0;
  558. }
  559. else
  560. {
  561. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
  562. }
  563. }
  564. /// <summary>
  565. /// 医保目录单个版本号的下载
  566. /// </summary>
  567. /// <param name="ver"></param>
  568. /// <param name="directoryType"></param>
  569. /// <param name="uiProcessBar"></param>
  570. /// <param name="errorMessage"></param>
  571. /// <returns></returns>
  572. public int SingleDownload(out string errorMessage, out string currentMaxVerNO)
  573. {
  574. errorMessage = "";
  575. currentMaxVerNO = "";
  576. PTMedicalInsurance.Business.HIS.DownLoad hDL = new Business.HIS.DownLoad();
  577. try
  578. {
  579. if (isStopLoopDownload)
  580. {
  581. errorMessage = "操作员主动停止下载";
  582. return -1;
  583. }
  584. return hDL.DownloadMIDiretoryBySpecifyVerNO(tbVer_4.Text, rbgDownItemType_4.SelectedIndex, pbDownload_4, out errorMessage, out currentMaxVerNO);
  585. }
  586. catch (Exception ex)
  587. {
  588. errorMessage = "SingleDownload提示:" + ex.Message;
  589. return -1;
  590. }
  591. }
  592. /// <summary>
  593. /// 自动下载医保目录,直到最新版本(返回报错)
  594. /// </summary>
  595. /// <param name="directoryType"></param>
  596. /// <param name="uiProcessBar"></param>
  597. /// <param name="errorMessage"></param>
  598. /// <returns></returns>
  599. public int AutoDownload(int directoryType,out string errorMessage)
  600. {
  601. int iResult = 0;
  602. errorMessage = "";
  603. string currentMaxVerNO;
  604. try
  605. {
  606. while (iResult == 0)
  607. {
  608. JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(directoryType);
  609. string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
  610. tbVer_4.Text = ver;
  611. //iResult = JsonHelper.parseIrisRtnValue(joMaxVerNO, out errorMessage);
  612. iResult = SingleDownload(out errorMessage, out currentMaxVerNO);
  613. }
  614. return iResult;
  615. }
  616. catch (Exception ex)
  617. {
  618. errorMessage = ex.Message;
  619. return -1;
  620. }
  621. }
  622. public int loopDownloadBySpecVerNO(out string errorMessage)
  623. {
  624. int iResult = 0;
  625. errorMessage = "";
  626. string currentMaxVerNO;
  627. try
  628. {
  629. while (iResult == 0)
  630. {
  631. //tbVer_4.Text = ver;
  632. //iResult = JsonHelper.parseIrisRtnValue(joMaxVerNO, out errorMessage);
  633. iResult = SingleDownload(out errorMessage, out currentMaxVerNO);
  634. tbVer_4.Text = currentMaxVerNO;
  635. }
  636. return iResult;
  637. }
  638. catch (Exception ex)
  639. {
  640. errorMessage = ex.Message;
  641. return -1;
  642. }
  643. }
  644. #endregion
  645. private void Form1_Load(object sender, EventArgs e)
  646. {
  647. //rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(rbgDirecType_ValueChanged);
  648. this.WindowState = FormWindowState.Maximized;
  649. }
  650. private void btnDownload_Click(object sender, EventArgs e)
  651. {
  652. }
  653. private void btnQuery_Click(object sender, EventArgs e)
  654. {
  655. queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy, Global.inf.interfaceDr);
  656. }
  657. private void btnQueryHISDirectory_Click(object sender, EventArgs e)
  658. {
  659. this.dgvHISDirectory.SelectionChanged -= this.dgvHISDirectory_SelectionChanged;
  660. string errMsg;
  661. int iCount = 50;
  662. if (rbNoMaped.Checked) iCount = 5000;
  663. if (queryHISDirectory(1, iCount, out errMsg) != 0)
  664. {
  665. MessageBox.Show(errMsg);
  666. return;
  667. }
  668. this.dgvHISDirectory.SelectionChanged += this.dgvHISDirectory_SelectionChanged;
  669. }
  670. private void btnQueryCenterDirectory_Click(object sender, EventArgs e)
  671. {
  672. queryHISInsuDirectory(rbgInsuDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, Global.inf.interfaceDr);
  673. }
  674. private void pgDownload_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  675. {
  676. queryHISInsuDirectory(rbgDirecType.SelectedIndex, pageIndex, count, dgvDirectoy, Global.inf.interfaceDr);
  677. }
  678. private void pgHISDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  679. {
  680. string errMsg;
  681. if (queryHISDirectory(pageIndex, 50, out errMsg) != 0)
  682. {
  683. MessageBox.Show(errMsg);
  684. return;
  685. }
  686. }
  687. private void pgCenterDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  688. {
  689. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, pageIndex, count, dgvCenterDirectory, Global.inf.interfaceDr);
  690. }
  691. private void rbgDirecType_ValueChanged(object sender, int index, string text)
  692. {
  693. btnQuery_Click(null, new EventArgs());
  694. }
  695. private void toolStripMenuItem2_Click(object sender, EventArgs e)
  696. {
  697. CancleMapping();
  698. }
  699. private void tsmiMapping_Click(object sender, EventArgs e)
  700. {
  701. Mapping();
  702. }
  703. private void dgvHISDirectory_DoubleClick(object sender, EventArgs e)
  704. {
  705. }
  706. private void dgvDirectoy_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
  707. {
  708. //自动编号,与数据无关
  709. Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
  710. e.RowBounds.Location.Y,
  711. dgvDirectoy.RowHeadersWidth - 4,
  712. e.RowBounds.Height);
  713. TextRenderer.DrawText(e.Graphics,
  714. (e.RowIndex + 1).ToString(),
  715. dgvDirectoy.RowHeadersDefaultCellStyle.Font,
  716. rectangle,
  717. dgvDirectoy.RowHeadersDefaultCellStyle.ForeColor,
  718. TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
  719. }
  720. private void rbAll_ValueChanged(object sender, bool value)
  721. {
  722. if (rbAll.Checked)
  723. {
  724. btnQueryHISDirectory_Click(null, new EventArgs());
  725. }
  726. }
  727. private void rbMaped_CheckedChanged(object sender, EventArgs e)
  728. {
  729. if (rbMaped.Checked)
  730. {
  731. string errMsg;
  732. if (queryHISDirectory(1, 50, out errMsg) != 0)
  733. {
  734. MessageBox.Show(errMsg);
  735. return;
  736. }
  737. }
  738. }
  739. private void btAddDir_Click(object sender, EventArgs e)
  740. {
  741. if (rbgDirecType.SelectedIndex == 8)
  742. {
  743. string errMsg = "";
  744. AddSingleDictionary addDictionary = new AddSingleDictionary();
  745. if (addDictionary.ShowDialog() == DialogResult.OK)
  746. {
  747. if (UpdateDictionaryBySelf(addDictionary, out errMsg) != 0)
  748. {
  749. MessageBox.Show(errMsg);
  750. }
  751. else
  752. {
  753. MessageBox.Show("新增成功!");
  754. }
  755. }
  756. }
  757. else
  758. {
  759. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex);
  760. if (addDirectory.ShowDialog() == DialogResult.OK)
  761. {
  762. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  763. string error = "";
  764. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  765. {
  766. MessageBox.Show("新增失败:" + error);
  767. }
  768. else
  769. {
  770. MessageBox.Show("新增成功");
  771. }
  772. }
  773. }
  774. }
  775. private void btEditDir_Click(object sender, EventArgs e)
  776. {
  777. DataTable dt = (DataTable)dgvDirectoy.DataSource;
  778. if ((dt == null) || (dt.Rows.Count < 1))
  779. {
  780. MessageBox.Show("表中无数据,请检查!");
  781. return;
  782. }
  783. DataRow dr = dt.Rows[dgvDirectoy.CurrentRow.Index];
  784. if (rbgDirecType.SelectedIndex == 8)
  785. {
  786. string errMsg;
  787. AddSingleDictionary addDictionary = new AddSingleDictionary(dr);
  788. if (addDictionary.ShowDialog() == DialogResult.OK)
  789. {
  790. if (UpdateDictionaryBySelf(addDictionary, out errMsg) != 0)
  791. {
  792. MessageBox.Show(errMsg);
  793. }
  794. else
  795. {
  796. MessageBox.Show("修改成功!");
  797. }
  798. }
  799. }
  800. else
  801. {
  802. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex, dr);
  803. if (addDirectory.ShowDialog() == DialogResult.OK)
  804. {
  805. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  806. string error = "";
  807. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  808. {
  809. MessageBox.Show("修改失败:" + error);
  810. }
  811. else
  812. {
  813. MessageBox.Show("修改成功");
  814. }
  815. }
  816. }
  817. }
  818. private void rbgDownType_3_ValueChanged(object sender, int index, string text)
  819. {
  820. DataGridView dgs = new DataGridView();
  821. GridViewSetter gvs = new GridViewSetter();
  822. //gvs.SetHeaderTextOfMoreInfo()
  823. }
  824. private void btDownload_4_Click(object sender, EventArgs e)
  825. {
  826. isStopLoopDownload = false;
  827. string errMsg = "";
  828. string currentMaxVerNO;
  829. if (rbSingleDown.Checked)
  830. {
  831. if (SingleDownload(out errMsg, out currentMaxVerNO) != 0)
  832. {
  833. MessageBox.Show("下载失败:" + errMsg);
  834. }
  835. }
  836. else if (rbAutoDown.Checked)
  837. {
  838. if (AutoDownload(rbgDownItemType_4.SelectedIndex,out errMsg) != 0)
  839. {
  840. MessageBox.Show("下载失败:" + errMsg);
  841. }
  842. }
  843. else
  844. {
  845. if (loopDownloadBySpecVerNO(out errMsg) != 0)
  846. {
  847. MessageBox.Show("下载失败:" + errMsg);
  848. }
  849. }
  850. }
  851. private void dgvDownload_4_CellContentClick(object sender, DataGridViewCellEventArgs e)
  852. {
  853. }
  854. private void dgvDirectoy_CellContentClick(object sender, DataGridViewCellEventArgs e)
  855. {
  856. }
  857. private void btnExport_Click(object sender, EventArgs e)
  858. {
  859. this.pgHISDirect.PageChanged -= new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
  860. // 创建 DataLoader 并传递 queryExportData 方法
  861. DataLoader _dataLoader;
  862. _dataLoader = new DataLoader((out string errMsg) => queryExportData_CallBack(out errMsg), this);
  863. _dataLoader.StartQueryExportData((result, errMsg) =>
  864. {
  865. // 在这里处理结果和错误信息
  866. if (result == 0)
  867. {
  868. MessageBox.Show(errMsg);
  869. }
  870. else
  871. {
  872. MessageBox.Show(errMsg);
  873. }
  874. });
  875. }
  876. private int queryExportData(out string errMsg)
  877. {
  878. errMsg = "";
  879. int currentPage = 1; int pageSize = 50;
  880. string directoryType = string.Empty;
  881. switch (rbgDirecType_C.SelectedIndex)
  882. {
  883. case 0:
  884. {
  885. directoryType = "drugs";
  886. break;
  887. }
  888. case 1:
  889. {
  890. directoryType = "diagnosi";
  891. break;
  892. }
  893. case 2:
  894. {
  895. directoryType = "consumables";
  896. break;
  897. }
  898. }
  899. JObject joHISRtn = new JObject();
  900. JObject joRtn = new JObject();
  901. string flag = "";
  902. //全部是先调HIS,然后再匹配医保平台的对照关系
  903. if (rbAll.Checked)
  904. {
  905. JArray jaPagination = new JArray();
  906. JArray jaParams = new JArray();
  907. flag = "All";
  908. dynamic joParam = new JObject();
  909. joParam.code = "";
  910. joParam.descripts = "";
  911. joParam.FindType = new JArray();
  912. joParam.TypeID = "";
  913. joParam.alias = tbHISDirectoryFilter.Text;
  914. joParam.include = "Hosp";
  915. joParam.groupID = "324";
  916. joParam.hospID = Global.inf.hisHospitalDr;
  917. joParam.interfaceDr = Global.inf.interfaceDr;
  918. joParam.type = directoryType;
  919. joParam.flag = flag;
  920. //joParam.specInput = txtSpecFilter.Text.Trim();
  921. jaParams.Add(joParam);
  922. dynamic joPagination = new JObject();
  923. joPagination.pageSize = pageSize;
  924. //joPagination.pageSize = 2;
  925. joPagination.currentPage = currentPage;
  926. joPagination.sortColumn = "Code";
  927. joPagination.sortOrder = "asc";
  928. jaPagination.Add(joPagination);
  929. //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
  930. //joInParams.code = "09010038";
  931. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  932. {
  933. return -1;
  934. }
  935. int count = int.Parse(JsonHelper.getDestValue(joHISRtn, "result.TotalCount"));
  936. if (count > pageSize)
  937. {
  938. joPagination["pageSize"] = count;
  939. jaPagination = new JArray();
  940. jaPagination.Add(joPagination);
  941. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  942. {
  943. return -1;
  944. }
  945. }
  946. int defaultCount = 200;
  947. dtExport = null;
  948. if (count > defaultCount)
  949. {
  950. JArray jaHisDir = JArray.Parse(JsonHelper.getDestValue(joHISRtn, "result.Data"));
  951. JArray jaTmp = new JArray();
  952. for (int i = 0; i < count; i++)
  953. {
  954. JObject joTmp = (JObject)jaHisDir[i];
  955. foreach (var property in joTmp.Properties())
  956. {
  957. if (property.Value.Type == JTokenType.Integer || property.Value.Type == JTokenType.Float)
  958. {
  959. property.Value = new JValue(property.Value.ToString());
  960. }
  961. }
  962. jaTmp.Add(joTmp);
  963. if ((((i + 1) % defaultCount) == 0) || (i + 1 == count))
  964. {
  965. JObject joConvert = new JObject();
  966. joConvert.Add("errorCode", 0);
  967. joConvert.Add("errorMessage", "查询成功");
  968. JObject joResult = new JObject();
  969. if ((i % defaultCount) == 0)
  970. {
  971. joResult.Add("TotalCount", defaultCount);
  972. }
  973. else
  974. {
  975. joResult.Add("TotalCount", (i + 1) % defaultCount);
  976. }
  977. joResult.Add("Data", jaTmp);
  978. joConvert.Add("result", joResult);
  979. joRtn = mIS.ConvertHISDir(joConvert);
  980. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  981. {
  982. return -1;
  983. }
  984. else
  985. {
  986. DataTable dtTmp = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  987. if (dtExport == null)
  988. {
  989. dtExport = dtTmp.Clone();
  990. dtExport.Merge(dtTmp);
  991. }
  992. else
  993. {
  994. dtExport.Merge(dtTmp);
  995. }
  996. jaTmp = new JArray();
  997. }
  998. }
  999. }
  1000. }
  1001. else
  1002. {
  1003. joRtn = mIS.ConvertHISDir(joHISRtn);
  1004. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1005. {
  1006. return -1;
  1007. }
  1008. dtExport = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  1009. }
  1010. }
  1011. //已对照是先调云医保,然后再匹配HIS
  1012. if (rbMaped.Checked)
  1013. {
  1014. JArray jaPagination = new JArray();
  1015. JArray jaParams = new JArray();
  1016. flag = "Maped";
  1017. dynamic joParam = new JObject();
  1018. joParam.alias = tbHISDirectoryFilter.Text;
  1019. joParam.HospitalDr = Global.inf.hospitalDr;
  1020. joParam.InterfaceDr = Global.inf.interfaceDr;
  1021. joParam.hisType = directoryType;
  1022. jaParams.Add(joParam);
  1023. dynamic joPagination = new JObject();
  1024. joPagination.pageSize = pageSize;
  1025. joPagination.currentPage = currentPage;
  1026. joPagination.sortColumn = "HisCode";
  1027. joPagination.sortOrder = "asc";
  1028. jaPagination.Add(joPagination);
  1029. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
  1030. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  1031. {
  1032. return -1;
  1033. }
  1034. //传给HIS,进行匹配
  1035. joParam = new JObject();
  1036. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  1037. joParam.type = directoryType;
  1038. joParam.flag = flag;
  1039. joParam.hospID = Global.inf.hisHospitalDr;
  1040. joParam.interfaceDr = Global.inf.interfaceDr;
  1041. joParam.alias = tbHISDirectoryFilter.Text;
  1042. joParam.include = "Hosp";
  1043. joParam.groupID = "324";
  1044. joParam.compareArr = joMIRtn["result"]["Data"];
  1045. jaParams = new JArray();
  1046. jaParams.Add(joParam);
  1047. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  1048. {
  1049. return -1;
  1050. }
  1051. }
  1052. //if (rbNoMaped.Checked) { flag = "NoMaped"; }
  1053. if (rbNoMaped.Checked)
  1054. {
  1055. JArray jaPagination = new JArray();
  1056. JArray jaParams = new JArray();
  1057. flag = "All";
  1058. dynamic joParam = new JObject();
  1059. joParam.code = "";
  1060. joParam.descripts = "";
  1061. joParam.FindType = new JArray();
  1062. joParam.TypeID = "";
  1063. joParam.alias = tbHISDirectoryFilter.Text;
  1064. joParam.include = "Hosp";
  1065. joParam.groupID = "324";
  1066. joParam.hospID = Global.inf.hisHospitalDr;
  1067. joParam.interfaceDr = Global.inf.interfaceDr;
  1068. joParam.type = directoryType;
  1069. joParam.flag = flag;
  1070. joParam.specInput = "";
  1071. jaParams.Add(joParam);
  1072. dynamic joPagination = new JObject();
  1073. joPagination.pageSize = pageSize;
  1074. //joPagination.pageSize = 2;
  1075. joPagination.currentPage = currentPage;
  1076. joPagination.sortColumn = "Code";
  1077. joPagination.sortOrder = "asc";
  1078. jaPagination.Add(joPagination);
  1079. //1.获取全部HIS目录
  1080. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  1081. {
  1082. return -1;
  1083. }
  1084. joRtn = mIS.GetNoMappHISDir(joHISRtn);
  1085. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1086. {
  1087. return -1;
  1088. }
  1089. }
  1090. return 0;
  1091. }
  1092. private int queryExportData_CallBack(out string errMsg)
  1093. {
  1094. if (queryExportData(out errMsg) != 0)
  1095. {
  1096. return -1;
  1097. }
  1098. //test.Stop();
  1099. this.Invoke((MethodInvoker)delegate {
  1100. this.pgHISDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
  1101. });
  1102. if (dtExport.Rows.Count > 0)
  1103. {
  1104. string directoryType = string.Empty;
  1105. string sBZ = "";
  1106. switch (rbgDirecType_C.SelectedIndex)
  1107. {
  1108. case 0:
  1109. {
  1110. directoryType = "药品";
  1111. break;
  1112. }
  1113. case 1:
  1114. {
  1115. directoryType = "诊疗";
  1116. break;
  1117. }
  1118. case 2:
  1119. {
  1120. directoryType = "材料";
  1121. break;
  1122. }
  1123. }
  1124. if (rbAll.Checked) sBZ = "全部";
  1125. else
  1126. if (rbMaped.Checked) sBZ = "已对照";
  1127. else
  1128. if (rbNoMaped.Checked) sBZ = "未对照";
  1129. string LSH = DateTime.Now.ToString("yyyy-MM-dd"); //DateTime.Now.ToString("MMddHHmmssffff");
  1130. string filename = LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
  1131. string sFliePathName = Global.curEvt.path + "\\MapRelation\\" + filename;
  1132. //string sFliePathName = @"D:\" + LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
  1133. //如果不存在目录,则创建目录
  1134. if (!Directory.Exists(Global.curEvt.path + "\\MapRelation"))
  1135. {
  1136. //创建文件夹
  1137. DirectoryInfo dirInfo = Directory.CreateDirectory(Global.curEvt.path + "\\MapRelation");
  1138. }
  1139. //如存在同名文件不询问直接删除
  1140. if (File.Exists(sFliePathName))
  1141. {
  1142. File.Delete(sFliePathName);
  1143. }
  1144. //新版方法,用的EPPLUS,方便
  1145. ExportToExcel.ExportDataTableToExcel(dtExport, sFliePathName);
  1146. if (true)
  1147. {
  1148. errMsg = ($"导出成功,文件保存路径:{sFliePathName}");
  1149. return 0;
  1150. }
  1151. else
  1152. {
  1153. errMsg = ("导出失败!");
  1154. return -1;
  1155. }
  1156. }
  1157. else
  1158. {
  1159. errMsg = "查询数据集为空!";
  1160. return -1;
  1161. }
  1162. }
  1163. private void dgvHISDirectory_RowEnter(object sender, DataGridViewCellEventArgs e)
  1164. {
  1165. tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.SelectedRows[0].Cells["itemDesc"].Value.ToString() + "%";
  1166. tbApprovalNO.Text = dgvHISDirectory.SelectedRows[0].Cells["pprovalNo"].Value.ToString();
  1167. }
  1168. private void dgvHISDirectory_SelectionChanged(object sender, EventArgs e)
  1169. {
  1170. int i = dgvHISDirectory.CurrentRow.Index;
  1171. if (dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString() != "")
  1172. {
  1173. tbInsuCode.Text = dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString();
  1174. tbCenterDirectoryFilter.Text = "";
  1175. tbApprovalNO.Text = "";
  1176. }
  1177. else
  1178. {
  1179. tbInsuCode.Text = "";
  1180. tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.Rows[i].Cells["itemDesc"].Value.ToString() + "%";
  1181. tbApprovalNO.Text = "%" + dgvHISDirectory.Rows[i].Cells["pprovalNo"].Value.ToString() + "%";
  1182. }
  1183. }
  1184. private void btStopLoopDownload_Click(object sender, EventArgs e)
  1185. {
  1186. isStopLoopDownload = true;
  1187. }
  1188. private void tsmShowAuxInfo_Click(object sender, EventArgs e)
  1189. {
  1190. if (dgvDirectoy.CurrentRow != null)
  1191. {
  1192. // 获取当前行中 "code" 列的单元格值,并转换为字符串
  1193. string code = dgvDirectoy.CurrentRow.Cells["code"].Value?.ToString() ?? string.Empty;
  1194. LimitPriceAndSelfpayPropInfo frm = new LimitPriceAndSelfpayPropInfo(code);
  1195. frm.Show();
  1196. }
  1197. else
  1198. {
  1199. // 没有选中的行,处理这种情况
  1200. MessageBox.Show("请选择一行。");
  1201. }
  1202. }
  1203. public int UpdateDictionaryBySelf(AddSingleDictionary addDic, out string errMsg)
  1204. {
  1205. string outParam = "", HBDictionaryDr = "";
  1206. JObject joRtn;
  1207. JObject jo = addDic.joPamam;
  1208. try
  1209. {
  1210. //if (JsonHelper.getDestValue(jo, "operateType") == "0")
  1211. //{
  1212. //插入并获取字典主表的DR
  1213. JObject joDic = JObject.FromObject(jo["dicObj"]);
  1214. joRtn = mIS.insertDictionary(joDic);
  1215. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1216. {
  1217. return -1;
  1218. }
  1219. else
  1220. {
  1221. HBDictionaryDr = JsonHelper.getDestValue(joRtn, "data.HBDictionaryDr");
  1222. if (HBDictionaryDr == "")
  1223. {
  1224. errMsg = "HBDictionaryDr返回值为空";
  1225. return -1;
  1226. }
  1227. }
  1228. //插入明细表
  1229. JObject joDicDetail = JObject.FromObject(jo["detailObj"]);
  1230. joDicDetail.Add("HBDictionaryDr", HBDictionaryDr);
  1231. JArray jaParams = new JArray();
  1232. jaParams.Add(joDicDetail);
  1233. joRtn = mIS.insertDictionaryDataDetail(jaParams);
  1234. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1235. {
  1236. return -1;
  1237. }
  1238. else
  1239. {
  1240. return 0;
  1241. }
  1242. }
  1243. catch (Exception ex)
  1244. {
  1245. errMsg = ex.Message;
  1246. return -1;
  1247. }
  1248. }
  1249. }
  1250. }