humuyu 3 år sedan
förälder
incheckning
fdbddfd042

+ 190 - 130
eladmin-system/src/main/java/me/zhengjie/application/bank/controller/BankNotarizeController.java

@@ -1,9 +1,25 @@
 package me.zhengjie.application.bank.controller;
 
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import me.zhengjie.annotation.rest.AnonymousGetMapping;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.application.bank.service.BankNotarizeService;
 import me.zhengjie.application.bank.service.UserAXQInfoService;
@@ -14,140 +30,184 @@ import me.zhengjie.base.util.FileUploadUtil;
 import me.zhengjie.base.util.tencent.h5face.SdkTest;
 import me.zhengjie.dao.mybatis.OrderFileRepository;
 import me.zhengjie.dao.mybatis.entity.OrderFileEntity;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import me.zhengjie.exception.BadRequestException;
 
 @Validated
 @RestController
-@RequestMapping("${fqgz.bank.app.url-prefix}")
+//@RequestMapping("${fqgz.bank.app.url-prefix}")
 @Slf4j
 @RequiredArgsConstructor
 public class BankNotarizeController {
-    private final OrderFileRepository orderFileRepository;
-    private final UserAXQInfoService userAXQInfoService;
-    private final BankNotarizeService bankNotarizeService;
-    private final TencentHumanFaceVerify faceVerify;
-
-    /**
-     * 获取签名公证书URL
-     *
-     * @param json
-     * @return
-     */
-    @RequestMapping("/getNotarization")
-    public ResponseDTO<?> getNotarization(@RequestBody String json) {
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String businessNo = jsonObj.getString("businessNo");
-        if (StringUtils.isEmpty(businessNo)) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        OrderFileEntity orderFile = orderFileRepository.getOrderNotarization(businessNo);
-        return ResponseDTO.success(FileUploadUtil.getPreviewUrl(orderFile.getSignedPdfUrl()));
-    }
-
-    @RequestMapping("/axqRegister")
-    public ResponseDTO<?> axqRegister(@RequestBody String json) {
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String idCard = jsonObj.getString("idCard");
-        String phone = jsonObj.getString("phone");
-        String name = jsonObj.getString("name");
-        if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(phone) || StringUtils.isEmpty(name)) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        return userAXQInfoService.registAXQUser(idCard, phone, name);
-    }
-
-    // 人脸核身
-    @RequestMapping("/order/getFaceId")
-    public ResponseDTO<?> getFaceId(@RequestBody String json) throws Exception {
-
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String userName = jsonObj.getString("userName");
-        String idCard = jsonObj.getString("idCard");
-        if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(idCard)) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        JSONObject str = SdkTest.getFaceId(faceVerify.getBankWebankAppId(), faceVerify.getBankSecret(),
-                faceVerify.getBankKeyLicence(), userName, idCard, idCard);
-        return ResponseDTO.success(str);
-    }
-
-    @AnonymousPostMapping("/video/call")
-    public ResponseDTO<?> videoCall(@RequestBody String json) {
-        return bankNotarizeService.videoCall(json);
-    }
-
-    @RequestMapping("/order/pdf")
-    public ResponseDTO<?> getOrderPDF(@RequestBody String json) {
-
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String businessNo = jsonObj.getString("businessNo");
-        if (StringUtils.isEmpty(businessNo)) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        ResponseDTO<?> order = bankNotarizeService.getOrderPDF(businessNo);
-
-        return order;
-    }
-
-    @AnonymousPostMapping("/order/note")
-    public ResponseDTO<?> note(@RequestBody String json) {
-
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String businessNo = jsonObj.getString("businessNo");
-        if (StringUtils.isEmpty(businessNo)) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        //
-        OrderFileEntity orderFile = orderFileRepository.getOrderNote(businessNo);
-        // pdf的地址预览
-        String noteUrl = FileUploadUtil.getPreviewUrl(orderFile.getHtmlUrl());
-
-        return ResponseDTO.success(noteUrl);
-    }
-
-    @RequestMapping("/sendAuthMessage")
-    public ResponseDTO<?> sendAuthMessage(@RequestBody String json) {
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String idCard = jsonObj.getString("idCard");
-        if (StringUtils.isEmpty(idCard)) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        return userAXQInfoService.sendAuthMessage(idCard);
-    }
-
-    @RequestMapping("/verifyAuthMessage")
-    public ResponseDTO<?> verifyAuthMessage(@RequestBody String json) {
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String idCard = jsonObj.getString("idCard");
-        String checkCode = jsonObj.getString("checkCode");
-        if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(checkCode)) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        return userAXQInfoService.verifyAuthMessage(idCard, checkCode);
-    }
-
-    @RequestMapping("/getAuthStatus")
-    public ResponseDTO<?> getAuthStatus(@RequestBody String json) {
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String idCard = jsonObj.getString("idCard");
-        if (StringUtils.isEmpty(idCard)) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        return userAXQInfoService.getAuthStatus(idCard);
-    }
-
-    @AnonymousPostMapping("/uploadSeal")
-    public ResponseDTO<?> uploadSeal(@RequestBody String json) {
-        JSONObject jsonObj = JSONObject.parseObject(json);
-        String businessNo = jsonObj.getString("businessNo");
-        JSONArray jsonArray = jsonObj.getJSONArray("signInfo");
-        if (StringUtils.isEmpty(businessNo) || jsonArray == null) {
-            return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-        }
-        return userAXQInfoService.uploadSeal(businessNo, jsonArray);
-    }
+	private final OrderFileRepository orderFileRepository;
+	private final UserAXQInfoService userAXQInfoService;
+	private final BankNotarizeService bankNotarizeService;
+	private final TencentHumanFaceVerify faceVerify;
+
+	/**
+	 * 获取签名公证书URL
+	 *
+	 * @param json
+	 * @return
+	 * @throws IOException
+	 * @throws ServletException
+	 */
+//    @RequestMapping("/getNotarization")
+	@RequestMapping(value = "/getNotarization/{businessNo}")
+	public void getNotarization(@PathVariable("businessNo") String businessNo, HttpServletRequest request,
+			HttpServletResponse response) throws Exception {
+
+		if (StringUtils.isEmpty(businessNo)) {
+			throw new BadRequestException("参数错误");
+		}
+		OrderFileEntity orderFile = orderFileRepository.getOrderNotarization(businessNo);
+		ServletOutputStream outputStream = null;
+		InputStream inputStream = null;
+
+		try {
+			inputStream = FileUploadUtil.getInputStream(orderFile.getSignedPdfUrl());
+			response.setContentType("application/pdf");
+			outputStream = response.getOutputStream();
+
+			int len = 0;
+			byte[] buffer = new byte[4096];
+			while ((len = inputStream.read(buffer)) != -1) {
+				outputStream.write(buffer, 0, len);
+			}
+			outputStream.flush();
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			outputStream.close();
+			inputStream.close();
+		}
+//		return ResponseDTO.success();
+	}
+
+	@RequestMapping("/axqRegister")
+	public ResponseDTO<?> axqRegister(@RequestBody String json) {
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String idCard = jsonObj.getString("idCard");
+		String phone = jsonObj.getString("phone");
+		String name = jsonObj.getString("name");
+		if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(phone) || StringUtils.isEmpty(name)) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		return userAXQInfoService.registAXQUser(idCard, phone, name);
+	}
+
+	// 人脸核身
+	@RequestMapping("/order/getFaceId")
+	public ResponseDTO<?> getFaceId(@RequestBody String json) throws Exception {
+
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String userName = jsonObj.getString("userName");
+		String idCard = jsonObj.getString("idCard");
+		if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(idCard)) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		JSONObject str = SdkTest.getFaceId(faceVerify.getBankWebankAppId(), faceVerify.getBankSecret(),
+				faceVerify.getBankKeyLicence(), userName, idCard, idCard);
+		return ResponseDTO.success(str);
+	}
+
+	@AnonymousPostMapping("/video/call")
+	public ResponseDTO<?> videoCall(@RequestBody String json) {
+		return bankNotarizeService.videoCall(json);
+	}
+
+	@AnonymousGetMapping("/preview/{path}")
+	public void preview(@PathVariable("path") String path, HttpServletRequest request, HttpServletResponse response)
+			throws IOException {
+		ServletOutputStream outputStream = null;
+		InputStream inputStream = null;
+		try {
+			inputStream = FileUploadUtil.getInputStream(path);
+			response.setContentType("application/pdf");
+			outputStream = response.getOutputStream();
+
+			int len = 0;
+			byte[] buffer = new byte[4096];
+			while ((len = inputStream.read(buffer)) != -1) {
+				outputStream.write(buffer, 0, len);
+			}
+			outputStream.flush();
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			outputStream.close();
+			inputStream.close();
+		}
+
+	}
+
+	@RequestMapping("/order/pdf")
+	public ResponseDTO<?> getOrderPDF(@RequestBody String json) {
+
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String businessNo = jsonObj.getString("businessNo");
+		if (StringUtils.isEmpty(businessNo)) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		ResponseDTO<?> order = bankNotarizeService.getOrderPDF(businessNo);
+
+		return order;
+	}
+
+	@AnonymousPostMapping("/order/note")
+	public ResponseDTO<?> note(@RequestBody String json) {
+
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String businessNo = jsonObj.getString("businessNo");
+		if (StringUtils.isEmpty(businessNo)) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		//
+		OrderFileEntity orderFile = orderFileRepository.getOrderNote(businessNo);
+		// pdf的地址预览
+		String noteUrl = FileUploadUtil.getPreviewUrl(orderFile.getHtmlUrl());
+
+		return ResponseDTO.success(noteUrl);
+	}
+
+	@RequestMapping("/sendAuthMessage")
+	public ResponseDTO<?> sendAuthMessage(@RequestBody String json) {
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String idCard = jsonObj.getString("idCard");
+		if (StringUtils.isEmpty(idCard)) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		return userAXQInfoService.sendAuthMessage(idCard);
+	}
+
+	@RequestMapping("/verifyAuthMessage")
+	public ResponseDTO<?> verifyAuthMessage(@RequestBody String json) {
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String idCard = jsonObj.getString("idCard");
+		String checkCode = jsonObj.getString("checkCode");
+		if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(checkCode)) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		return userAXQInfoService.verifyAuthMessage(idCard, checkCode);
+	}
+
+	@RequestMapping("/getAuthStatus")
+	public ResponseDTO<?> getAuthStatus(@RequestBody String json) {
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String idCard = jsonObj.getString("idCard");
+		if (StringUtils.isEmpty(idCard)) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		return userAXQInfoService.getAuthStatus(idCard);
+	}
+
+	@AnonymousPostMapping("/uploadSeal")
+	public ResponseDTO<?> uploadSeal(@RequestBody String json) {
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String businessNo = jsonObj.getString("businessNo");
+		JSONArray jsonArray = jsonObj.getJSONArray("signInfo");
+		if (StringUtils.isEmpty(businessNo) || jsonArray == null) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		return userAXQInfoService.uploadSeal(businessNo, jsonArray);
+	}
 }

+ 14 - 7
eladmin-system/src/main/java/me/zhengjie/application/user/app/controller/AppUserController.java

@@ -44,9 +44,9 @@ public class AppUserController {
 	@Autowired
 	BankOrderService bankOrderService;
 	@Autowired
-    UserOrderService userOrderService;
+	UserOrderService userOrderService;
 	@Autowired
-    UserAXQInfoService userAXQInfoService;
+	UserAXQInfoService userAXQInfoService;
 	@Autowired
 	private RedisTemplate<String, String> redisTemplate;
 
@@ -89,7 +89,7 @@ public class AppUserController {
 		JSONObject jsonObj = JSONObject.parseObject(json);
 		String businessNo = jsonObj.getString("businessNo");
 		String contractNo = jsonObj.getString("contractNo");
-		if (StringUtils.isEmpty(businessNo)||StringUtils.isEmpty(contractNo)) {
+		if (StringUtils.isEmpty(businessNo) || StringUtils.isEmpty(contractNo)) {
 			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
 		}
 		BankOrderVO order = bankOrderService.getContractOrderWithBizNo(businessNo);
@@ -128,16 +128,18 @@ public class AppUserController {
 
 		return order;
 	}
+
 	@RequestMapping("/order/search")
-	public ResponseDTO<?> orderSearch( @RequestBody BankOrderVO order ) {
-		 
+	public ResponseDTO<?> orderSearch(@RequestBody BankOrderVO order) {
+
 		if (order == null) {
 			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
 		}
-		 List<BankOrderVO> orders = this.apiService.getOrderByContion(order);
-		
+		List<BankOrderVO> orders = this.apiService.getOrderByContion(order);
+
 		return ResponseDTO.success(orders);
 	}
+
 	@AnonymousPostMapping("/order/note")
 	public ResponseDTO<?> note(@RequestBody String json) {
 
@@ -252,6 +254,11 @@ public class AppUserController {
 			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
 		}
 		OrderFileEntity orderFile = orderFileRepository.getOrderNotarization(businessNo);
+		// 下载pdf
+		String pdf = orderFile.getSignedPdfUrl();
+		//APP_UPLOAD_PATH
+		//pdf
+		// FileUploadUtil.getInputStream(objectName)
 		return ResponseDTO.success(FileUploadUtil.getPreviewUrl(orderFile.getSignedPdfUrl()));
 	}
 }