|
|
@ -1,23 +1,33 @@ |
|
|
|
package com.ccsens.wisdomcar.api; |
|
|
|
|
|
|
|
import cn.hutool.core.codec.Base64; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.util.ImageUtil; |
|
|
|
import com.ccsens.cloudutil.annotation.MustLogin; |
|
|
|
import com.ccsens.util.JsonResponse; |
|
|
|
import com.ccsens.util.baidu.BaiDuDto; |
|
|
|
import com.ccsens.util.baidu.BaiDuUtil; |
|
|
|
import com.ccsens.util.baidu.BaiDuVo; |
|
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
|
import com.ccsens.wisdomcar.bean.dto.ProjectDto; |
|
|
|
import com.ccsens.wisdomcar.bean.vo.ProjectVo; |
|
|
|
import com.ccsens.wisdomcar.service.IProjectService; |
|
|
|
import com.ccsens.wisdomcar.util.Constant; |
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
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.RequestMethod; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import javax.servlet.http.Part; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@ -52,6 +62,35 @@ public class ProjectController { |
|
|
|
log.info("查询称重和剂量:{}", list); |
|
|
|
return JsonResponse.newInstance().ok(list); |
|
|
|
} |
|
|
|
@MustLogin |
|
|
|
@ApiOperation(value = "查询开始时间", notes = "whj") |
|
|
|
@RequestMapping(value = "/getStartTime", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|
|
|
public JsonResponse<ProjectVo.GetStartTime> getStartTime(@ApiParam @Validated @RequestBody QueryDto<ProjectDto.GetStartTime> params){ |
|
|
|
log.info("查询开始时间:{}", params); |
|
|
|
ProjectVo.GetStartTime time = projectService.getStartTime(params.getParam(), params.getUserId()); |
|
|
|
log.info("查询开始时间结束:{}", time); |
|
|
|
return JsonResponse.newInstance().ok(time); |
|
|
|
} |
|
|
|
// @MustLogin
|
|
|
|
@ApiOperation(value = "图像识别", notes = "whj") |
|
|
|
@RequestMapping(value = "/identifyWords", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|
|
|
public JsonResponse<ProjectVo.PersonMsg> identifyWords(@RequestParam(required = true) Part part) throws IOException { |
|
|
|
log.info("图像识别"); |
|
|
|
// 压缩图像
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
|
|
ImageUtil.scale(ImageIO.read(part.getInputStream()), out, 0.5f); |
|
|
|
String img = Base64.encode(out.toByteArray()); |
|
|
|
// 图像识别
|
|
|
|
BaiDuDto.GeneralBasic basic = new BaiDuDto.GeneralBasic(); |
|
|
|
basic.setImage(img); |
|
|
|
BaiDuVo.GeneralBasic words = BaiDuUtil.accurateBasic(Constant.BaiDu.APP_KEY, Constant.BaiDu.SECRET_KEY, basic); |
|
|
|
// 返回图像
|
|
|
|
ProjectVo.PersonMsg personMsg = new ProjectVo.PersonMsg(); |
|
|
|
personMsg.toMsg(words.getWordsResult()); |
|
|
|
log.info("图像识别结束:{}", personMsg); |
|
|
|
return JsonResponse.newInstance().ok(personMsg); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@MustLogin |
|
|
|