|  |  |  | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Propagation; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import sun.misc.BASE64Encoder; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.ByteArrayOutputStream; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.io.InputStream; | 
|---|
|  |  |  | import java.net.HttpURLConnection; | 
|---|
|  |  |  | import java.net.URL; | 
|---|
|  |  |  | import java.nio.file.Files; | 
|---|
|  |  |  | import java.nio.file.Path; | 
|---|
|  |  |  | import java.nio.file.Paths; | 
|---|
|  |  |  | 
|---|
|  |  |  | FacePictureCheckRequest param = new FacePictureCheckRequest(); | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); | 
|---|
|  |  |  | param.setFacePicBinaryData(visits.getFaceImg()); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | Path path = Paths.get(prefixUrl + visits.getFaceImg()); | 
|---|
|  |  |  | //            Path path = Paths.get("d://c75848e1-f6f2-4474-bfa8-ddb05a8c7413.jpg"); | 
|---|
|  |  |  | byte[] imageBytes = Files.readAllBytes(path); | 
|---|
|  |  |  | param.setFacePicBinaryData(Base64.getEncoder().encodeToString(imageBytes)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"人脸信息解析失败"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | param.setFacePicUrl(prefixUrl + visits.getFaceImg()); | 
|---|
|  |  |  | BaseResponse<FacePictureCheckResponse> response = HKService.facePictureCheck(param); | 
|---|
|  |  |  | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,人脸评分获取数据失败~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | FacePictureCheckResponse facePictureCheckResponse = response.getData(); | 
|---|
|  |  |  | if(Objects.isNull(facePictureCheckResponse) || Objects.isNull(facePictureCheckResponse.getCheckResult())){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,人脸评分获取数据失败~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!facePictureCheckResponse.getCheckResult()){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), facePictureCheckResponse.getStatusMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | visitsMapper.insert(visits); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //发起ERP审批申请 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return visits.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|