SpecialtyVehicleController.java 4.31 KB
package com.objecteye.controller;

import com.alibaba.fastjson.JSONObject;
import com.objecteye.dao.MongoTemplates;
import com.objecteye.pojo.VehicleCondition;
import com.objecteye.service.SpecialtyServices;
import com.objecteye.utils.CustomAssert;
import com.objecteye.utils.CustomParamCollections;
import com.objecteye.utils.VehicleEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/vehicle")
public class SpecialtyVehicleController {
    @Autowired
    private MongoTemplates mongoTemplates;
    @Autowired
    private SpecialtyServices specialtyServices;
    @Autowired
    private VehicleEngine vehicleEngine;

    /**
     * 通过车牌(支持模糊)、多条件查询车辆信息(平铺)
     *
     * @param vehicleCondition
     * @return
     */
    @RequestMapping("/slagCar/findByCondition")
    public JSONObject findByCondition(@RequestBody VehicleCondition vehicleCondition) {
        //渣土车查询
        return mongoTemplates.findBy(vehicleCondition, 2);
    }


    /**
     * 通过图片返回各种车的坐标
     *
     * @param picfile
     * @return
     */
    @RequestMapping("/slagCar/findCoordinateByPic")
    public JSONObject siteByPic(@RequestParam("picfile") MultipartFile picfile, Integer vehicle_special_type_number) {
        //渣土车坐标  vehicle_special_type_number
        return specialtyServices.findCoordinateByPic(picfile, vehicle_special_type_number);


    }

    /**
     * 通过车辆特征码、时间、地点范围进行搜索
     *
     * @return
     */
    @RequestMapping("/slagCar/findByPic")
    public JSONObject findByPic(@RequestParam int number, @RequestParam double threshold, @RequestParam int currentpage,
                                @RequestParam int pagevolume, MultipartFile picfile, @RequestParam Long starttime,
                                @RequestParam Long endtime) throws InterruptedException {
        return specialtyServices.findByPic(number, threshold, currentpage, pagevolume, picfile, starttime, endtime, 2);
    }

    /**
     * 通过id搜索相关车辆
     *
     * @return
     */
    @RequestMapping("/slagCar/findById")
    public JSONObject findById(@RequestBody Map<String, String> map) {
        return specialtyServices.findById(map.get("id"));
    }

    /**
     * 通过过车序号搜索相关车辆
     *
     * @return
     */
    @RequestMapping("/slagCar/findByGcxh")
    public JSONObject findByGcxh(int gcxh, MultipartFile picfile) {
        return specialtyServices.findByGcxh(gcxh, picfile);
    }

    /**
     * 危化品车
     * 通过车牌(支持模糊)、多条件查询车辆信息(平铺)
     *
     * @return
     */
    @RequestMapping("/chemistryCar/findByCondition")
    public JSONObject chemistryFindByCondition(@RequestBody VehicleCondition vehicleCondition) {
        //危化品车查询
        return mongoTemplates.findBy(vehicleCondition, 1);
    }

    /**
     * 危化品车
     * 通通过车辆特征码、时间、地点范围进行搜索
     *
     * @return
     */
    @RequestMapping("/chemistryCar/findByPic")
    public JSONObject chemistryFindByPic(@RequestParam int number, @RequestParam Double threshold, @RequestParam int currentpage,
                                         @RequestParam int pagevolume, MultipartFile picfile, @RequestParam Long starttime,
                                         @RequestParam Long endtime) throws InterruptedException {
        return specialtyServices.findByPic(number, threshold, currentpage, pagevolume, picfile, starttime, endtime, 1);

    }

    /**
     * 测试
     *
     * @return
     */
    @RequestMapping("/chemistryCar/test")
    public JSONObject test(Integer gcxh, @RequestParam("picfile") MultipartFile picfile) {


        return specialtyServices.findByGcxh(gcxh, picfile);

    }

    /**
     * 测试
     *
     * @return
     */
    @RequestMapping("/getResult")
    public Object getResult(@RequestBody Map<String, Object> body) {
        CustomAssert.checkField(body, CustomParamCollections.VEHICLE_SINGLE_PARAM);
        CustomAssert.checkSimpleMapParam(body, CustomParamCollections.VEHICLE_SINGLE_PARAM);
        return specialtyServices.getColorAndBrand(body);
    }
}