|  |  |  | 
|---|
|  |  |  | package com.doumee.api.common; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.annotation.trace.Trace; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.HKConstants; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.param.BaseResponse; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.param.request.FacePictureCheckRequest; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.param.respose.FacePictureCheckResponse; | 
|---|
|  |  |  | import com.doumee.core.haikang.service.HKService; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.FtpUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.aliyun.ALiYunUtil; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMethod; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.ResponseBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartHttpServletRequest; | 
|---|
|  |  |  | import org.springframework.web.multipart.commons.CommonsMultipartResolver; | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.io.InputStream; | 
|---|
|  |  |  | import java.io.PrintWriter; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.UUID; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author Eva.Caesar Liu | 
|---|
|  |  |  | * @date 2023/02/14 11:14 | 
|---|
|  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "上传文件到FTP") | 
|---|
|  |  |  | @RequestMapping(method= RequestMethod.POST,value="upload") | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | public void upload(HttpServletRequest request, HttpServletResponse response, String folder) throws Exception { | 
|---|
|  |  |  | public void upload(HttpServletRequest request, HttpServletResponse response, String folder,Integer isFace) throws Exception { | 
|---|
|  |  |  | //        folder = systemDictDataBiz.queryByCode(Constants.FTP,folder).getCode(); | 
|---|
|  |  |  | String prefixPath = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode(); | 
|---|
|  |  |  | InputStream is = null; | 
|---|
|  |  |  | 
|---|
|  |  |  | String fileName = folder+fName; | 
|---|
|  |  |  | boolean r = ftp.uploadInputstream(is,fileName); | 
|---|
|  |  |  | if(r){ | 
|---|
|  |  |  | if(Objects.nonNull(isFace) && Constants.equalsInteger(isFace,Constants.ZERO)){ | 
|---|
|  |  |  | //验证人脸评分 | 
|---|
|  |  |  | //人脸评分 | 
|---|
|  |  |  | FacePictureCheckRequest param = new FacePictureCheckRequest(); | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_LOCAL_RESOURCE_PATH).getCode(); | 
|---|
|  |  |  | param.setFacePicUrl(prefixUrl + fileName); | 
|---|
|  |  |  | BaseResponse<FacePictureCheckResponse> responseBaseResponse = HKService.facePictureCheck(param); | 
|---|
|  |  |  | if(responseBaseResponse == null || !StringUtils.equals(responseBaseResponse.getCode(), HKConstants.RESPONSE_SUCCEE)){ | 
|---|
|  |  |  | context.put("code", 0); | 
|---|
|  |  |  | context.put("message", "对不起,人脸评分获取数据失败~"); | 
|---|
|  |  |  | context.put("errno",0); | 
|---|
|  |  |  | writerJson(response, context); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | FacePictureCheckResponse facePictureCheckResponse = responseBaseResponse.getData(); | 
|---|
|  |  |  | if(Objects.isNull(facePictureCheckResponse) || Objects.isNull(facePictureCheckResponse.getCheckResult())){ | 
|---|
|  |  |  | context.put("code", 0); | 
|---|
|  |  |  | context.put("message", "对不起,人脸评分获取数据失败~"); | 
|---|
|  |  |  | context.put("errno",0); | 
|---|
|  |  |  | writerJson(response, context); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!facePictureCheckResponse.getCheckResult()){ | 
|---|
|  |  |  | context.put("code", 0); | 
|---|
|  |  |  | context.put("message", facePictureCheckResponse.getStatusMessage()); | 
|---|
|  |  |  | context.put("errno",0); | 
|---|
|  |  |  | writerJson(response, context); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | context.put("success", true); | 
|---|
|  |  |  | context.put("code", 200); | 
|---|
|  |  |  | context.put("errno",0); | 
|---|