|
@@ -7,8 +7,10 @@ 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 sun.misc.BASE64Encoder;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
@@ -21,7 +23,7 @@ public class CfcaFaceAuthServiceImpl implements ICfcaFaceAuthService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Map<String,String> faceAuth(boolean isPro, String institutionid, String name, String returnImage, String identificationNumber, String frontUrl, String backUrl, String remark, String url,String path,String imgurl) throws Exception {
|
|
|
+ public Map<String,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+"?message="+map.get("reqMessage")
|
|
|
+"&signature="+map.get("reqSignature")
|
|
@@ -29,23 +31,28 @@ public class CfcaFaceAuthServiceImpl implements ICfcaFaceAuthService {
|
|
|
+"&signSN="+map.get("requestSignSN")
|
|
|
+"&encryptSN"+map.get("requestEncryptSN");
|
|
|
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".jpg";
|
|
|
- createQrCode(url,path,fileName);
|
|
|
- String fileUrl = imgurl+fileName;
|
|
|
+ String baseUrl = createQrCode(url,fileName);
|
|
|
Map<String,String> reMap = new HashMap<>();
|
|
|
reMap.put("originalTxSN",map.get("originalTxSN"));
|
|
|
- reMap.put("fileUrl",fileUrl);
|
|
|
+ reMap.put("fileUrl",baseUrl);
|
|
|
return reMap;
|
|
|
}
|
|
|
- public static String createQrCode(String url, String path, String fileName) {
|
|
|
+ public static String createQrCode(String url, 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);
|
|
|
- }
|
|
|
+ File file = new File(fileName);
|
|
|
+ writeToFile(bitMatrix, "jpg", file);
|
|
|
+ FileInputStream inputFile = new FileInputStream(file);
|
|
|
+ byte[] buffer = new byte[(int)file.length()];
|
|
|
+ inputFile.read(buffer);
|
|
|
+ inputFile.close();
|
|
|
+// if (file.exists() || ((file.getParentFile().exists() || file.getParentFile().mkdirs()) && file.createNewFile())) {
|
|
|
+// writeToFile(bitMatrix, "jpg", file);
|
|
|
+// System.out.println("搞定:" + file);
|
|
|
+// }
|
|
|
+ return new BASE64Encoder().encode(buffer);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -64,7 +71,7 @@ public class CfcaFaceAuthServiceImpl implements ICfcaFaceAuthService {
|
|
|
+"&encryptSN="+map.get("requestEncryptSN");
|
|
|
System.out.println(url);
|
|
|
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".jpg";
|
|
|
- String fileUrl = createQrCode(url,"D://",fileName);
|
|
|
- System.out.println(fileUrl);
|
|
|
+// String fileUrl = createQrCode(url,"D://",fileName);
|
|
|
+// System.out.println(fileUrl);
|
|
|
}
|
|
|
}
|