HumanVehicleAssociationController.java 3.87 KB
package com.objecteye.controller;

import com.objecteye.common.CommonResult;
import com.objecteye.entity.PageResult;
import com.objecteye.pojo.FaceInfoParam;
import com.objecteye.pojo.SearchPeopleOfHphmInfo;
import com.objecteye.pojo.SearchPeopleOfHphmRequest;
import com.objecteye.pojo.SearchPeopleOfhphmResult;
import com.objecteye.service.HumanVehicleAssociationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 人车关联类
 */
@RestController
@RequestMapping("/HumanVehicle")
@Api(tags = "HumanVehicleAssociationController", description = "人车关联类")
@CrossOrigin
public class HumanVehicleAssociationController {

    @Autowired
    private HumanVehicleAssociationService humanVehicleAssociationService;

    @ApiOperation("以人搜车")
    @RequestMapping(value = "/hvAssociation/searchVehicleFromHuman", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult searchVehicleFromHuman(@RequestParam Long starttime, @RequestParam Long endtime, @RequestParam Float thresholds, @RequestParam int currentpage, @RequestParam int pagevolume, MultipartFile picfile) {
        try {
            PageResult pageResult = humanVehicleAssociationService.searchVehicleFromHuman(starttime, endtime, thresholds, currentpage, pagevolume, picfile);
            if (pageResult == null || pageResult.getRow().size() == 0) {
                return CommonResult.success(201, "没有符合要求的数据", null);
            }
            return CommonResult.success(pageResult);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }

    }

    @ApiOperation("以车牌搜人")
    @RequestMapping(value = "/hvAssociation/searchPeopleFromHphm", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult searchPeopleFromHphm(@RequestBody SearchPeopleOfHphmRequest searchPeopleOfHphmRequest) {
        try {
            SearchPeopleOfhphmResult searchPeopleOfhphmResult = humanVehicleAssociationService.searchPeopleFromHphm(searchPeopleOfHphmRequest.getStarttime(), searchPeopleOfHphmRequest.getEndtime(), searchPeopleOfHphmRequest.getCurrentpage(),
                    searchPeopleOfHphmRequest.getPagevolume(), searchPeopleOfHphmRequest.getHphm());
            List<SearchPeopleOfHphmInfo> row = searchPeopleOfhphmResult.getRow();
            if (row == null || row.size() == 0) {
                return CommonResult.success(201, "没有符合要求的数据", searchPeopleOfhphmResult);
            }
            return CommonResult.success(searchPeopleOfhphmResult);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }

    @ApiOperation("以车辆图片搜人")
    @RequestMapping(value = "/hvAssociation/searchPeopleFromVehiclePic", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult searchPeopleFromVehiclePic(@RequestParam int number, @RequestParam double threshold, @RequestParam int currentpage,
                                                   @RequestParam int pagevolume, @RequestParam MultipartFile picfile) {
        try {
            List<FaceInfoParam> faceInfoParam = humanVehicleAssociationService.searchPeopleOfVehiclePic(number, threshold, currentpage, pagevolume, picfile);
            if (faceInfoParam == null || faceInfoParam.size() == 0) {
                return CommonResult.success(201, "没有符合要求的数据", faceInfoParam);
            }
            return CommonResult.success(faceInfoParam);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }
}