SpecialtyVehicleController.java 4.81 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) {
        //渣土车查询
        JSONObject by = mongoTemplates.findBy(vehicleCondition, 2);
        return by;
    }


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


    }

    /**
     * 通过车辆特征码、时间、地点范围进行搜索
     *
     * @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) {
        JSONObject byPic = specialtyServices.findById(map.get("id"));
        return byPic;
    }

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


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

    /**
     * 危化品车
     * 通通过车辆特征码、时间、地点范围进行搜索
     *
     * @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) {


        JSONObject coordinateByPic = specialtyServices.findByGcxh(gcxh, picfile);
        return coordinateByPic;

    }


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

        return colorAndBrand;
    }
}