|
@@ -0,0 +1,64 @@
|
|
|
+package com.huyi.service.common.cfcaCommon.impl;
|
|
|
+
|
|
|
+import com.google.zxing.BarcodeFormat;
|
|
|
+import com.google.zxing.EncodeHintType;
|
|
|
+import com.google.zxing.MultiFormatWriter;
|
|
|
+import com.google.zxing.common.BitMatrix;
|
|
|
+import com.huyi.service.common.cfcaCommon.ICfcaFaceAuthService;
|
|
|
+import com.tianhu.common.core.cfca.CfcaUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import static com.google.zxing.client.j2se.MatrixToImageWriter.writeToFile;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class CfcaFaceAuthServiceImpl implements ICfcaFaceAuthService {
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String faceAuth(boolean isPro, String institutionid, String name, String returnImage, String identificationNumber, String frontUrl, String backUrl, String remark, String url) throws Exception {
|
|
|
+ Map<String,String> map = CfcaUtil.faceAuth(isPro,institutionid,name,returnImage,identificationNumber,frontUrl,backUrl,remark);
|
|
|
+ url = url+"?reqMessage="+map.get("reqMessage")
|
|
|
+ +"&reqSignature="+map.get("reqSignature")
|
|
|
+ +"&requestDgtlEnvlp="+map.get("requestDgtlEnvlp")
|
|
|
+ +"&requestSignSN="+map.get("requestSignSN")
|
|
|
+ +"&requestEncryptSN"+map.get("requestEncryptSN");
|
|
|
+ String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".jpg";
|
|
|
+ String fileUrl = createQrCode(url,"D://",fileName);
|
|
|
+ return fileUrl;
|
|
|
+ }
|
|
|
+ public static String createQrCode(String url, String path, String fileName) {
|
|
|
+ try {
|
|
|
+ Map<EncodeHintType, String> hints = new HashMap<>();
|
|
|
+ hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
|
|
+ BitMatrix bitMatrix = new MultiFormatWriter().encode(url, BarcodeFormat.QR_CODE, 400, 400, hints);
|
|
|
+ File file = new File(path, fileName);
|
|
|
+ if (file.exists() || ((file.getParentFile().exists() || file.getParentFile().mkdirs()) && file.createNewFile())) {
|
|
|
+ writeToFile(bitMatrix, "jpg", file);
|
|
|
+ System.out.println("搞定:" + file);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+
|
|
|
+ Map<String,String> map = CfcaUtil.faceAuth(false,"100804","李三","","370724199512106110","http://localhost:8080/ReceiveNoticePage","http://localhost:8080/ReceiveNoticeBackground","");
|
|
|
+ System.out.println(map);
|
|
|
+// String url= "http://zcyl.keao.tech/auth";
|
|
|
+// url = url+"?reqMessage="+map.get("reqMessage")
|
|
|
+// +"&reqSignature="+map.get("reqSignature")
|
|
|
+// +"&requestDgtlEnvlp="+map.get("requestDgtlEnvlp")
|
|
|
+// +"&requestSignSN="+map.get("requestSignSN")
|
|
|
+// +"&requestEncryptSN"+map.get("requestEncryptSN");
|
|
|
+// String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".jpg";
|
|
|
+// String fileUrl = createQrCode(url,"D://",fileName);
|
|
|
+ }
|
|
|
+}
|