platform.dart 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'dart:typed_data';
  4. import 'package:fis_common/json_convert.dart';
  5. import '../client_base.dart';
  6. import 'platform.m.dart';
  7. /// 平台服务
  8. class PlatformService extends JsonRpcClientBase {
  9. PlatformService(
  10. String host, {
  11. String serviceName = "IPlatformService",
  12. Map<String, String>? headers,
  13. int? timeout,
  14. }) : super(
  15. host,
  16. serviceName,
  17. headers: headers,
  18. timeout: timeout,
  19. ) {
  20. /// 注册响应实体反序列化处理器
  21. FJsonConvert.setDecoder((map) => LoadVidResult.fromJson(map));
  22. FJsonConvert.setDecoder((map) => GetVidFrameResult.fromJson(map));
  23. }
  24. /// 加载主题
  25. Future<bool> loadTheme(String name) async {
  26. var rpcRst = await call("LoadTheme", name);
  27. return rpcRst;
  28. }
  29. /// 保存配置
  30. ///
  31. /// [jsonText] 配置json文本
  32. Future<bool> saveConfig(String jsonText) async {
  33. var rpcRst = await call("SaveConfig", jsonText);
  34. return rpcRst;
  35. }
  36. /// 获取配置
  37. Future<String?> getConfig() async {
  38. var rpcRst = await call("GetConfig");
  39. return rpcRst;
  40. }
  41. /// 保存文本文件
  42. ///
  43. /// [name] 文件名
  44. ///
  45. /// [text] 文本
  46. Future<bool> saveText(String name, String text) async {
  47. var rpcRst = await call("SaveText", [name, text]);
  48. return rpcRst;
  49. }
  50. /// 获取文件文本
  51. ///
  52. /// [name] 文件名
  53. Future<String?> getText(String name) async {
  54. var rpcRst = await call("GetText", name);
  55. return rpcRst;
  56. }
  57. /// 加载Vid文件
  58. ///
  59. /// [url] Vid文件链接
  60. Future<LoadVidResult> loadVid(String url) async {
  61. var rpcRst = await call("LoadVid", url);
  62. var result = LoadVidResult.fromJson(rpcRst as Map<String, dynamic>);
  63. return result;
  64. }
  65. /// 获取Vid单针帧图
  66. Future<GetVidFrameResult> getVidFrame(GetVidFrameRequest request) async {
  67. var rpcRst = await call("GetVidFrame", request);
  68. var result = GetVidFrameResult.fromJson(rpcRst as Map<String, dynamic>);
  69. return result;
  70. }
  71. /// 释放Vid缓存资源
  72. void releaseVid() => notify("ReleaseVid");
  73. /// 获取单帧Vid文件图像
  74. Future<GetVidFrameResult> getSingleImage(String url) async {
  75. var rpcRst = await call("GetSingleImage", url);
  76. var result = GetVidFrameResult.fromJson(rpcRst as Map<String, dynamic>);
  77. return result;
  78. }
  79. /// 获取vid文件(base64)
  80. Future<String?> getVidFile(String url) async {
  81. var rpcRst = await call("GetVidFile", [url]);
  82. return rpcRst;
  83. }
  84. /// 导出文件
  85. Future<bool> setBytesToExport(String data, String fileName) async {
  86. var rpcRst = await call("SetBytesToExport", [data, fileName]);
  87. return rpcRst;
  88. }
  89. ///缓存文件
  90. Future<bool> setBinaryFileCache(String data, String fileName) async {
  91. var rpcRst = await call("SetBinaryFileCache", [data, fileName]);
  92. return rpcRst;
  93. }
  94. ///读取缓存文件
  95. Future<String?> getBinaryFileCache(String fileName) async {
  96. var rpcRst = await call("GetBinaryFileCache", [fileName]);
  97. return rpcRst;
  98. }
  99. ///导出病例zip文件
  100. Future<bool> exportPatientZipFile(String data, String fileName) async {
  101. var rpcRst = await call("ExportPatientZipFile", [data, fileName]);
  102. return rpcRst;
  103. }
  104. ///撤销病例导出
  105. Future<bool> abortExportOperation() async {
  106. var rpcRst = await call("AbortExportOperation", []);
  107. return rpcRst;
  108. }
  109. ///选择文件
  110. Future<bool> selectFile() async {
  111. var rpcResult = await call("SelectFile", []);
  112. return rpcResult;
  113. }
  114. ///读取打印驱动块
  115. Future<Uint8List> readPrintDriverChunk(int index) async {
  116. String rpcResult = await call("ReadPrintDriverChunk", [index]);
  117. Uint8List byteData = base64.decode(rpcResult);
  118. return byteData;
  119. }
  120. ///打开图像测量页(独立窗口)
  121. Future<bool?> openImageMeasureAsync(
  122. String token, String patientCode, String remedicalCode, String recordCode,
  123. {String source = '0'}) async {
  124. var rpcRst = await call("OpenImageMeasure",
  125. [token, patientCode, remedicalCode, recordCode, source]);
  126. return rpcRst;
  127. }
  128. ///打开报告预览页(独立窗口)
  129. Future<bool?> openReportPreviewAsync(String token, String reportCode,
  130. String recordCode, String isFormEditor) async {
  131. var rpcRst = await call(
  132. "OpenReportPreview", [token, reportCode, recordCode, isFormEditor]);
  133. return rpcRst;
  134. }
  135. ///打开图像测量页(独立窗口)
  136. Future<bool?> openReportEditAsync(
  137. String token,
  138. String patientCode,
  139. String reportCode,
  140. String recordCode,
  141. String referralRecordCode,
  142. String consultationCode) async {
  143. var rpcRst = await call("OpenReportEdit", [
  144. token,
  145. patientCode,
  146. reportCode,
  147. recordCode,
  148. referralRecordCode,
  149. consultationCode
  150. ]);
  151. return rpcRst;
  152. }
  153. ///打开报告设计器页面(独立窗口)
  154. Future<bool?> openReportDesignerAsync(String templateId, String name,
  155. String type, String token, String json) async {
  156. var rpcRst =
  157. await call("OpenReportDesigner", [templateId, name, type, token, json]);
  158. return rpcRst;
  159. }
  160. ///打开在线会诊页面(独立窗口)
  161. Future<void> openLiveConsultationAsync(
  162. String consultationCode, bool isJoin, int pageIndex, String token) async {
  163. await call(
  164. "OpenLiveConsultation", [consultationCode, isJoin, pageIndex, token]);
  165. }
  166. /// 打开设备直播 独立窗口
  167. ///
  168. /// [deviceCode] 设备编码
  169. ///
  170. /// [token] 登录令牌
  171. Future<void> openDeviceLiveWindow(String deviceCode, String token) {
  172. return call("OpenDeviceLiveWindow", [deviceCode, token]);
  173. }
  174. ///获取屏幕个数
  175. Future<int> getWindowsNum() async {
  176. var rpcRst = await call("GetWindowsNum");
  177. return rpcRst;
  178. }
  179. ///关闭副窗口
  180. Future<void> closeSlaveWindow() async {
  181. var rpcRst = await call("CloseSlaveWindow");
  182. return rpcRst;
  183. }
  184. ///关闭会诊窗口
  185. Future<void> closeLiveConsultation() async {
  186. var rpcRst = await call("CloseLiveConsultation");
  187. return rpcRst;
  188. }
  189. ///开启拖拽窗口
  190. Future<void> beginWindowDrag(String windowName) async {
  191. var rpcRst = await call("BeginWindowDrag", [windowName]);
  192. return rpcRst;
  193. }
  194. ///关闭拖拽窗口
  195. Future<void> endWindowDrag(String windowName) async {
  196. var rpcRst = await call("EndWindowDrag", [windowName]);
  197. return rpcRst;
  198. }
  199. ///最小化窗口
  200. Future<void> minimizeWindow(String windowName) async {
  201. var rpcRst = await call("MinimizeWindow", [windowName]);
  202. return rpcRst;
  203. }
  204. ///最大化窗口
  205. Future<void> maximizeWindow(String windowName) async {
  206. var rpcRst = await call("MaximizeWindow", [windowName]);
  207. return rpcRst;
  208. }
  209. ///重置
  210. Future<void> restoreWindow(String windowName) async {
  211. var rpcRst = await call("RestoreWindow", [windowName]);
  212. return rpcRst;
  213. }
  214. ///获取Window状态
  215. Future<int> getWindowState(String windowName) async {
  216. var rpcRst = await call("GetWindowStateAsync", [windowName]);
  217. return rpcRst;
  218. }
  219. ///关闭窗口
  220. Future<void> closeWindow(String windowName) async {
  221. var rpcRst = await call("CloseWindow", [windowName]);
  222. return rpcRst;
  223. }
  224. ///设置语言Code
  225. Future<void> setLanguageCodeAsync(String code) async {
  226. var rpcRst = await call("SetLanguageCode", [code]);
  227. return rpcRst;
  228. }
  229. //获取语言Code
  230. Future<String> getLanguageCodeAsync() async {
  231. var rpcRst = await call("GetLanguageCode");
  232. return rpcRst;
  233. }
  234. ///设置当前登录信息
  235. Future<void> setLoginUserInfoAsync(String userInfo) async {
  236. var rpcRst = await call("SetUserLoginInfo", [userInfo]);
  237. return rpcRst;
  238. }
  239. ///设置当前第二窗口状态
  240. Future<void> setSecondWindowStateInfoAsync(bool isSecondWindowMode) async {
  241. var rpcRst = await call("SetSecondWindowState", [isSecondWindowMode]);
  242. return rpcRst;
  243. }
  244. ///默认词条变更
  245. Future<void> thesaurusChange(String token) async {
  246. var rpcRst = await call("ThesaurusChange", [token]);
  247. return rpcRst;
  248. }
  249. ///提交报告通知
  250. Future<void> onSubmitReport(String patientId, String code) async {
  251. var rpcRst = await call("OnSubmitReport", [patientId, code]);
  252. return rpcRst;
  253. }
  254. ///刷新报告通知
  255. Future<void> refershReports() async {
  256. var rpcRst = await call("RefershReports", []);
  257. return rpcRst;
  258. }
  259. ///刷新报告通知
  260. Future<void> reloadConfig() async {
  261. var rpcRst = await call("ReloadConfig", []);
  262. return rpcRst;
  263. }
  264. ///重载配置
  265. Future<bool> getIsUseSecondWindow() async {
  266. var rpcRst = await call("GetIsUseSecondWindow", []);
  267. return rpcRst;
  268. }
  269. ///重载配置
  270. Future<bool> getIsWin7() async {
  271. var rpcRst = await call("GetIsWin7", []);
  272. return rpcRst;
  273. }
  274. ///打开控制台
  275. Future<void> openConsole() async {
  276. var rpcRst = await call("OpenConsole", []);
  277. return rpcRst;
  278. }
  279. ///主窗口关闭通知
  280. Future<void> onMainWindowLogout() async {
  281. var rpcRst = await call("OnMainWindowLogout", []);
  282. return rpcRst;
  283. }
  284. ///设置开启自启动
  285. Future<void> setAutoStartAsync(bool isAutoStart) async {
  286. var rpcRst = await call("SetAutoStart", [isAutoStart]);
  287. return rpcRst;
  288. }
  289. ///启用壳子录音
  290. Future<void> startShellRecord() async {
  291. var rpcRst = await call("StartShellRecord");
  292. return rpcRst;
  293. }
  294. ///停止壳子录音
  295. Future<String> stopShellRecord() async {
  296. var rpcRst = await call("StopShellRecord");
  297. return rpcRst;
  298. }
  299. ///导出日志
  300. Future<bool> exportAppLogZipFile(int exportType, String fileName) async {
  301. var rpcRst = await call("ExportAppLogZipFile", [exportType, fileName]);
  302. return rpcRst;
  303. }
  304. ///开始录制
  305. Future<void> startRecording(
  306. String filePrefixTitle, String micDeviceId) async {
  307. var rpcRst = await call("StartRecording", [filePrefixTitle, micDeviceId]);
  308. return rpcRst;
  309. }
  310. ///暂停录制
  311. Future<void> pauseRecording(bool isPause) async {
  312. var rpcRst = await call("PauseRecording", [isPause]);
  313. return rpcRst;
  314. }
  315. ///结束录制
  316. Future<void> stopRecording() async {
  317. var rpcRst = await call("StopRecording");
  318. return rpcRst;
  319. }
  320. ///导出会诊病例zip文件
  321. Future<bool> exportConsultationZipFile(String data, String fileName) async {
  322. var rpcRst = await call("ExportConsultationZipFile", [data, fileName]);
  323. return rpcRst;
  324. }
  325. ///升级客户端
  326. Future<bool> doUpgradClient(String upgradInfo) async {
  327. var rpcRst = await call("DoUpgradClient", [upgradInfo]);
  328. return rpcRst;
  329. }
  330. ///获得当前客户端版本
  331. Future<String> getCurrentAppVersion() async {
  332. var rpcRst = await call("GetCurrentAppVersion");
  333. return rpcRst;
  334. }
  335. ///下载测量数据
  336. Future<void> downloadMeasureData(String url) async {
  337. var rpcRst = await call("DownloadMeasureData", [url]);
  338. return rpcRst;
  339. }
  340. ///下载大文件接口
  341. Future<void> downloadBigFile(String url, String fileName) async {
  342. var rpcRst = await call("DownloadBigFile", [url, fileName]);
  343. return rpcRst;
  344. }
  345. ///获取所有已安装的打印驱动
  346. Future<List<String>> getAllInstalledPrinterInfos() async {
  347. var rpcRst = await call("GetAllInstalledPrinterInfos");
  348. List<String> result = [];
  349. for (var i in rpcRst) {
  350. result.add(i.toString());
  351. }
  352. return result;
  353. }
  354. ///打印测试(调用后会在指定的打印机打印一张测试页)
  355. Future<bool> printTestPage(String name) async {
  356. var rpcRst = await call("PrintTestPage", [name]);
  357. return rpcRst;
  358. }
  359. ///搜索未安装的打印驱动
  360. Future<List<String>> getUninstalledPrinters({String? ip}) async {
  361. var rpcRst = await call("GetUninstalledPrinters", [ip]);
  362. List<String> result = [];
  363. for (var i in rpcRst) {
  364. result.add(i.toString());
  365. }
  366. return result;
  367. }
  368. /// 安装打印驱动
  369. Future<bool> installPrinterDriver(String printerDriveStr) async {
  370. var rpcRst = await call("InstallPrinterDriver", [printerDriveStr]);
  371. return rpcRst;
  372. }
  373. ///选择本地打印驱动
  374. Future<bool> chooseLocalDrive() async {
  375. var rpcRst = await call("ChooseLocalDrive");
  376. return rpcRst;
  377. }
  378. /// 关闭打印驱动工具
  379. Future<void> closePrinterDriverManager() async {
  380. var rpcRst = await call("ClosePrinterDriverManager");
  381. return rpcRst;
  382. }
  383. /// 获取当前魔盒设备的UniqueId
  384. Future<String> getUltrasoundUniqueId() async {
  385. var rpcRst = await call("GetUltrasoundUniqueIdAsync");
  386. return rpcRst;
  387. }
  388. ///获取网卡信息
  389. Future<String> getNetworkCardsInfo() async {
  390. var rpcRst = await call("GetNetworkCardsInfo");
  391. return rpcRst;
  392. }
  393. ///保存网卡信息
  394. Future<bool> saveNetworkCardsInfo(String networkWireListModel) async {
  395. var rpcRst = await call("SaveNetworkCardsInfo", [networkWireListModel]);
  396. return rpcRst;
  397. }
  398. ///获取无线网卡信息
  399. Future<String> getWirelessCardInfo() async {
  400. var rpcRst = await call('GetWirelessCardInfo');
  401. return rpcRst;
  402. }
  403. ///保存无线网卡信息
  404. Future<bool> saveWifiNetworkCard(String networkInterface) async {
  405. var rpcRst = await call("SaveWifiNetworkCard", [networkInterface]);
  406. return rpcRst;
  407. }
  408. ///连接Wifi网络
  409. Future<bool> connectWifi(String wifiInfo) async {
  410. var rpcRst = await call("ConnectWifi", [wifiInfo]);
  411. return rpcRst;
  412. }
  413. ///断开Wifi网络
  414. Future<bool> disconnectWifi(String wifiInfo) async {
  415. var rpcRst = await call("DisconnectWifi", [wifiInfo]);
  416. return rpcRst;
  417. }
  418. ///忘记Wifi密码
  419. Future<bool> forgetWifiPassword(String wifiInfo) async {
  420. var rpcRst = await call("ForgetWifiPassword", [wifiInfo]);
  421. return rpcRst;
  422. }
  423. ///刷新DNS
  424. Future<bool> flushDNS() async {
  425. var rpcRst = await call("FlushDNS");
  426. return rpcRst;
  427. }
  428. ///Ping 测试Ip是否可以连通
  429. Future<bool> ping(String ipInfo) async {
  430. var rpcRst = await call("Ping", [ipInfo]);
  431. return rpcRst;
  432. }
  433. ///开始培训推流
  434. Future<bool> startTrainningPush(String pushURL, String micDeviceId,
  435. TranningPushEnum tranningPushEnum) async {
  436. var rpcRst = await call("StartTrainningPush", [
  437. pushURL,
  438. micDeviceId,
  439. tranningPushEnum.index,
  440. ]);
  441. return rpcRst;
  442. }
  443. ///切换培训推流模式
  444. Future<bool> switchPushMode(TranningPushEnum tranningPushEnum) async {
  445. var rpcRst = await call("SwitchPushMode", [
  446. tranningPushEnum.index,
  447. ]);
  448. return rpcRst;
  449. }
  450. ///调整培训音频音量
  451. Future<bool> adjustAudioVoice(
  452. AudioTypeEnum audioTypeEnum, double audioVolume) async {
  453. var rpcRst = await call("AdjustAudioVoice", [
  454. audioTypeEnum.index,
  455. audioVolume,
  456. ]);
  457. return rpcRst;
  458. }
  459. ///停止培训直播推流
  460. Future<bool> stopTrainningPush() async {
  461. var rpcRst = await call("StopTrainningPush");
  462. return rpcRst;
  463. }
  464. ///开始培训直播录制
  465. Future<bool> startTrainningRecord(
  466. String filePrefixTitle, String pullURL) async {
  467. var rpcRst = await call("StartTrainningRecord", [
  468. filePrefixTitle,
  469. pullURL,
  470. ]);
  471. return rpcRst;
  472. }
  473. ///停止培训直播录制
  474. Future<bool> stopTrainningRecord() async {
  475. var rpcRst = await call("StopTrainningRecord");
  476. return rpcRst;
  477. }
  478. ///打开直播课页面
  479. Future<void> openLiveCoursePage(String courseCode, String token) async {
  480. var rpcRst = await call("OpenLiveCoursePage", [courseCode, token]);
  481. return rpcRst;
  482. }
  483. ///取消文件下载
  484. Future<void> cancelDownloadBigFile() async {
  485. var rpcRst = await call('CancelDownloadBigFile');
  486. return rpcRst;
  487. }
  488. ///复制到粘贴板
  489. Future<void> copyToClipboard(String txtToCopy) async {
  490. var rpcRst = await call('CopyToClipboard', [txtToCopy]);
  491. return rpcRst;
  492. }
  493. }
  494. /// 一些platform 的数据结构定义
  495. enum TranningPushEnum {
  496. /// <summary>
  497. /// 窗口
  498. /// </summary>
  499. Window,
  500. /// <summary>
  501. /// 屏幕
  502. /// </summary>
  503. Screen,
  504. }
  505. enum AudioTypeEnum {
  506. /// <summary>
  507. /// 麦克风
  508. /// </summary>
  509. Mic,
  510. /// <summary>
  511. /// 扬声器
  512. /// </summary>
  513. Speaker,
  514. }