TVehicleInfosController.java 4.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
package com.zehong.web.controller.system;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TVehicleInfo;
import com.zehong.system.domain.TVehicleLocationInfo;
import com.zehong.system.service.ITVehicleInfoService;
import com.zehong.system.service.ITVehicleLocationInfoService;
import io.jsonwebtoken.lang.Collections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 燃气车辆信息Controller
 *
 * @author zehong
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/system/infos")
public class TVehicleInfosController extends BaseController
{
    @Autowired
    private ITVehicleInfoService tVehicleInfoService;
    @Autowired
    private ITVehicleLocationInfoService itVehicleLocationInfoService;
    /**
     * 查询燃气车辆信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TVehicleInfo tVehicleInfo)
    {
        startPage();
        List<TVehicleInfo> list = tVehicleInfoService.selectTVehicleInfoList(tVehicleInfo);
        for (int i=0;i<list.size();i++){
            //获取最后位置信息
            TVehicleLocationInfo tVehicleLocationInfo = new TVehicleLocationInfo();
            tVehicleLocationInfo.setCarNum(list.get(i).getCarNum());
            tVehicleLocationInfo.setLast(true);
            List<TVehicleLocationInfo> tVehicleLocationInfoList=itVehicleLocationInfoService.selectTVehicleLocationInfoList(tVehicleLocationInfo);
            //车辆最后位置
            if(!Collections.isEmpty(tVehicleLocationInfoList) && tVehicleLocationInfoList.size() > 0){
                list.get(i).setLongitude(tVehicleLocationInfoList.get(0).getLongitude());
                list.get(i).setLatitude(tVehicleLocationInfoList.get(0).getLatitude());
            }
        }
        return getDataTable(list);
    }

    /**
     * 导出燃气车辆信息列表
     */
    @Log(title = "燃气车辆信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TVehicleInfo tVehicleInfo)
    {
        List<TVehicleInfo> list = tVehicleInfoService.selectTVehicleInfoList(tVehicleInfo);
        ExcelUtil<TVehicleInfo> util = new ExcelUtil<TVehicleInfo>(TVehicleInfo.class);
        return util.exportExcel(list, "燃气车辆信息数据");
    }

    /**
     * 获取燃气车辆信息详细信息
     */
    @GetMapping(value = "/{vehicleId}")
    public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId)
    {
        return AjaxResult.success(tVehicleInfoService.selectTVehicleInfoById(vehicleId));
    }

    /**
     * 微信小程序  车辆详细信息查询接口
     * @param tVehicleInfo
     * @return
     */
    @PostMapping("/getTVehicleInfo")
    public AjaxResult getTVehicleInfo(@RequestBody TVehicleInfo tVehicleInfo)
    {
        TVehicleInfo tVehicleInfo1 = tVehicleInfoService.getTVehicleInfo(tVehicleInfo);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("tGasBottleInfo", tVehicleInfo1);
        return ajax;
    }
    /**
     * 新增燃气车辆信息
     */
    @Log(title = "燃气车辆信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TVehicleInfo tVehicleInfo)
    {
        return toAjax(tVehicleInfoService.insertTVehicleInfo(tVehicleInfo));
    }

    /**
     * 修改燃气车辆信息
     */
    @Log(title = "燃气车辆信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TVehicleInfo tVehicleInfo)
    {
        return toAjax(tVehicleInfoService.updateTVehicleInfo(tVehicleInfo));
    }

    /**
     * 删除燃气车辆信息
     */
    @Log(title = "燃气车辆信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vehicleIds}")
    public AjaxResult remove(@PathVariable Long[] vehicleIds)
    {
        return toAjax(tVehicleInfoService.deleteTVehicleInfoByIds(vehicleIds));
    }
}