Commit b262a45985598a76c24b5b42866798e72f5e894e
1 parent
b6b294eecb
Exists in
master
and in
6 other branches
就诊卡密码获取
Showing 3 changed files with 100 additions and 1 deletions
platform-operate-api/libry/QHD_Card.dll
View file @
b262a45
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
b262a45
... | ... | @@ -31,6 +31,7 @@ |
31 | 31 | import com.lyms.platform.operate.web.service.IBloodPressureService; |
32 | 32 | import com.lyms.platform.operate.web.service.SyncDataTaskService; |
33 | 33 | import com.lyms.platform.operate.web.utils.CommonsHelper; |
34 | +import com.lyms.platform.operate.web.utils.QhdvcCardNoUtils; | |
34 | 35 | import com.lyms.platform.operate.web.worker.*; |
35 | 36 | import com.lyms.platform.permission.dao.master.CouponMapper; |
36 | 37 | import com.lyms.platform.permission.model.*; |
37 | 38 | |
... | ... | @@ -3318,8 +3319,24 @@ |
3318 | 3319 | Patients patients = patientsService.findOnePatientById(patientId); |
3319 | 3320 | cdGwInterface.getPersonId(patients); |
3320 | 3321 | Map<String,String> map = new HashMap<>(); |
3321 | - map.put("id,","2134123412431"); | |
3322 | + map.put("id,", "2134123412431"); | |
3322 | 3323 | return map; |
3323 | 3324 | } |
3325 | + | |
3326 | + | |
3327 | + /** | |
3328 | + * 返回秦皇岛就诊卡的密码 | |
3329 | + * 根据传入的卡的id来计算解密卡号的密码 | |
3330 | + * @param kid | |
3331 | + * @return | |
3332 | + */ | |
3333 | + @RequestMapping(value = "/qhd/getVcCardNoPwd", method = RequestMethod.GET) | |
3334 | + @ResponseBody | |
3335 | + public String getVcCardNoPwd(@RequestParam(required = true) String kid) | |
3336 | + { | |
3337 | + String pwd = QhdvcCardNoUtils.getKey(kid); | |
3338 | + return pwd; | |
3339 | + } | |
3340 | + | |
3324 | 3341 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/QhdvcCardNoUtils.java
View file @
b262a45
1 | +package com.lyms.platform.operate.web.utils; | |
2 | + | |
3 | +import com.sun.jna.Library; | |
4 | +import com.sun.jna.Native; | |
5 | + | |
6 | +import java.io.UnsupportedEncodingException; | |
7 | +import java.util.ArrayList; | |
8 | +import java.util.Collections; | |
9 | +import java.util.List; | |
10 | + | |
11 | +/** | |
12 | + * 秦皇岛就诊卡密码获取 | |
13 | + * Created by Administrator on 2019-09-11. | |
14 | + */ | |
15 | +public class QhdvcCardNoUtils { | |
16 | + | |
17 | + /** | |
18 | + * 加载QHD_Card.dll | |
19 | + */ | |
20 | + public interface ReaderDll extends Library { | |
21 | + ReaderDll instanceDll = (ReaderDll) Native.loadLibrary("QHD_Card", ReaderDll.class); | |
22 | + //读取卡中基本信息 | |
23 | + public int getKeyA(String data, int iReaderHandle, byte[] dataInfo); | |
24 | + //public int getKeyStr_ext(byte[] oErrMsg); | |
25 | + //public int getKeyStr(IntByReference iReaderPort, int iReaderHandle, byte[] oErrMsg); | |
26 | + } | |
27 | + | |
28 | + | |
29 | + /** | |
30 | + * //String a = "434A2865"; //65284A43 | |
31 | + * 就诊卡的卡id | |
32 | + * @param kid | |
33 | + * @return | |
34 | + */ | |
35 | + public static String getKey(String kid) | |
36 | + { | |
37 | + kid = covertKey(kid); | |
38 | + byte[] dataInfo = new byte[50]; | |
39 | + int areaCode = 100; | |
40 | + int status = ReaderDll.instanceDll.getKeyA(kid,areaCode,dataInfo); | |
41 | + try { | |
42 | + if (status == 0) | |
43 | + { | |
44 | + return new String(dataInfo,"utf-8"); | |
45 | + } | |
46 | + } catch (UnsupportedEncodingException e) { | |
47 | + } | |
48 | + return null; | |
49 | + } | |
50 | + | |
51 | + /** | |
52 | + * 转换 | |
53 | + * 65284A43 > 434A2865 | |
54 | + * @param kid | |
55 | + * @return | |
56 | + */ | |
57 | + public static String covertKey(String kid) | |
58 | + { | |
59 | + StringBuffer sb = new StringBuffer(); | |
60 | + try { | |
61 | + byte[] list = kid.getBytes(); | |
62 | + | |
63 | + List<String> contents = new ArrayList(); | |
64 | + for (int i = 0; i <list.length; i+=2) | |
65 | + { | |
66 | + byte[] datas = new byte[2]; | |
67 | + datas[0] = list[i]; | |
68 | + datas[1] = list[i+1]; | |
69 | + contents.add(new String(datas,"utf-8")); | |
70 | + } | |
71 | + Collections.reverse(contents); | |
72 | + for (String key : contents) | |
73 | + { | |
74 | + sb.append(key); | |
75 | + } | |
76 | + }catch (Exception e) | |
77 | + { | |
78 | + | |
79 | + } | |
80 | + return sb.toString(); | |
81 | + } | |
82 | +} |