TGasBottleInfoController.java 5.56 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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
package com.zehong.web.controller.gasBottleTrack;

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.BottleStatistics;
import com.zehong.system.domain.TGasBottleInfo;
import com.zehong.system.service.ITGasBottleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 气瓶信息Controller
 *
 * @author zehong
 * @date 2023-08-15
 */
@RestController
@RequestMapping("/gasBottle/info")
public class TGasBottleInfoController extends BaseController
{
    @Autowired
    private ITGasBottleInfoService tGasBottleInfoService;

    /**
     * 查询气瓶信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TGasBottleInfo tGasBottleInfo)
    {
        startPage();
        List<TGasBottleInfo> list = tGasBottleInfoService.selectTGasBottleInfoList(tGasBottleInfo);
        return getDataTable(list);
    }

    @GetMapping("/bottleInfoList")
    public AjaxResult bottleInfoList(TGasBottleInfo tGasBottleInfo)
    {
        List<TGasBottleInfo> list = tGasBottleInfoService.selectTGasBottleInfoList(tGasBottleInfo);
        return AjaxResult.success(list);
    }

    /**
     * 导出气瓶信息列表
     */
    @Log(title = "气瓶信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TGasBottleInfo tGasBottleInfo)
    {
        List<TGasBottleInfo> list = tGasBottleInfoService.selectTGasBottleInfoList(tGasBottleInfo);
        ExcelUtil<TGasBottleInfo> util = new ExcelUtil<TGasBottleInfo>(TGasBottleInfo.class);
        return util.exportExcel(list, "气瓶信息数据");
    }

    /**
     * 获取气瓶信息详细信息
     */
    @GetMapping(value = "/{bottleId}")
    public AjaxResult getInfo(@PathVariable("bottleId") Long bottleId)
    {
        return AjaxResult.success(tGasBottleInfoService.selectTGasBottleInfoById(bottleId));
    }

    @GetMapping("/getInf")
    public AjaxResult getInf(String bottleId)
    {
        /**
         * 查询气瓶详细信息
         */
        TGasBottleInfo inf = tGasBottleInfoService.getInf(bottleId);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("tGasBottleInfo", inf);
        return ajax;
    }


    @GetMapping("/getInfn")
    public AjaxResult getInfn(String bottleId)
    {
        /**
         * 查询气瓶详细信息
         */
        TGasBottleInfo inf = tGasBottleInfoService.getInfn(bottleId);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("tGasBottleInfo", inf);
        return ajax;
    }

    /**
     * 新增气瓶信息
     */
    @Log(title = "气瓶信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGasBottleInfo tGasBottleInfo)
    {
        TGasBottleInfo tGasBottleInfo1=new TGasBottleInfo();
        tGasBottleInfo1.setBottleCode(tGasBottleInfo.getBottleCode());
        /**
         * 查询气瓶详细信息
         */
        List<TGasBottleInfo> list = tGasBottleInfoService.selectTGasBottleInfoList(tGasBottleInfo1);
        if (list.size()>=1){
            return null;
        }
        return toAjax(tGasBottleInfoService.insertTGasBottleInfo(tGasBottleInfo));
    }

    /**
     * 修改气瓶信息
     */
    @Log(title = "气瓶信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGasBottleInfo tGasBottleInfo)
    {
        return toAjax(tGasBottleInfoService.updateTGasBottleInfo(tGasBottleInfo));
    }

    /**
     * 删除气瓶信息
     */
    @Log(title = "气瓶信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bottleIds}")
    public AjaxResult remove(@PathVariable Long[] bottleIds)
    {
        return toAjax(tGasBottleInfoService.deleteTGasBottleInfoByIds(bottleIds));
    }

    /**
     * 气瓶导入
     * @param file
     * @param updateSupport
     * @return
     * @throws Exception
     */
    @Log(title = "气瓶导入", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<TGasBottleInfo> util = new ExcelUtil<>(TGasBottleInfo.class);
        List<TGasBottleInfo> tGasBottleInfoList = util.importExcel(file.getInputStream());
        String message = tGasBottleInfoService.importTGasBottleInfo(tGasBottleInfoList, updateSupport);
        return AjaxResult.success(message);
    }

    @GetMapping("/importTemplate")
    public AjaxResult importTemplate(){
        ExcelUtil<TGasBottleInfo> util = new ExcelUtil<>(TGasBottleInfo.class);
        return util.importTemplateExcel("气瓶数据");
    }

    @GetMapping("/bottleStatistics")
    public TableDataInfo bottleStatistics(@RequestParam(value="stationId",required = false) Long stationId){
        startPage();
        return getDataTable(tGasBottleInfoService.bottleStatistics(stationId));
    }

    @GetMapping("/bottleStatisticsExport")
    public AjaxResult bottleStatisticsExport(@RequestParam(value = "stationId",required = false) Long stationId)
    {
        List<BottleStatistics> statistics = tGasBottleInfoService.bottleStatistics(stationId);
        ExcelUtil<BottleStatistics> util = new ExcelUtil<>(BottleStatistics.class);
        return util.exportExcel(statistics, "气瓶信息数据");
    }
}