CarsController.java 3.82 KB
package com.bsth.controller.schedule.basicinfo;

import com.bsth.common.ResponseCode;
import com.bsth.controller.schedule.BController;
import com.bsth.entity.Cars;
import com.bsth.service.schedule.CarsService;
import com.bsth.service.schedule.exception.ScheduleException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 车辆基础信息controller
 */
@RestController(value = "carsController_sc")
@RequestMapping("cars_sc")
public class CarsController extends BController<Cars, Integer> {
    @Autowired
    private CarsService carsService;

    @RequestMapping(value = "/validate_zbh", method = RequestMethod.GET)
    public Map<String, Object> validate_zbh(@RequestParam Map<String, Object> param) {
        Map<String, Object> rtn = new HashMap<>();
        try {
            // 自编号验证
            Cars cars = new Cars(
                    param.get("id_eq"),
                    param.get("insideCode_eq"),
                    null,
                    null,
                    null);
            carsService.validate_nbbh(cars);
            rtn.put("status", ResponseCode.SUCCESS);
        } catch (ScheduleException exp) {
            rtn.put("status", ResponseCode.ERROR);
            rtn.put("msg", exp.getMessage());
        }
        return rtn;
    }

    @RequestMapping(value = "/validate_clbh", method = RequestMethod.GET)
    public Map<String, Object> validate_clbh(@RequestParam Map<String, Object> param) {
        Map<String, Object> rtn = new HashMap<>();
        try {
            // 车辆编号验证
            Cars cars = new Cars(
                    param.get("id_eq"),
                    null,
                    param.get("carCode_eq"),
                    null,
                    null);
            carsService.validate_clbh(cars);
            rtn.put("status", ResponseCode.SUCCESS);
        } catch (ScheduleException exp) {
            rtn.put("status", ResponseCode.ERROR);
            rtn.put("msg", exp.getMessage());
        }
        return rtn;
    }

    @RequestMapping(value = "/validate_cph", method = RequestMethod.GET)
    public Map<String, Object> validate_cph(@RequestParam Map<String, Object> param) {
        Map<String, Object> rtn = new HashMap<>();
        try {
            // 车牌号验证
            Cars cars = new Cars(
                    param.get("id_eq"),
                    null,
                    null,
                    param.get("carPlate_eq"),
                    null);
            carsService.validate_cph(cars);
            rtn.put("status", ResponseCode.SUCCESS);
        } catch (ScheduleException exp) {
            rtn.put("status", ResponseCode.ERROR);
            rtn.put("msg", exp.getMessage());
        }
        return rtn;
    }

    @RequestMapping(value = "/validate_sbbh", method = RequestMethod.GET)
    public Map<String, Object> validate_sbbh(@RequestParam Map<String, Object> param) {
        Map<String, Object> rtn = new HashMap<>();
        try {
            // 设备编号验证
            Cars cars = new Cars(
                    param.get("id_eq"),
                    null,
                    null,
                    null,
                    param.get("equipmentCode_eq")
            );
            carsService.validate_sbbh(cars);
            rtn.put("status", ResponseCode.SUCCESS);
        } catch (ScheduleException exp) {
            rtn.put("status", ResponseCode.ERROR);
            rtn.put("msg", exp.getMessage());
        }
        return rtn;
    }
}