package com.mirs.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.mirs.biz.domain.BrdfData;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mirs.common.annotation.Log;
import com.mirs.common.core.controller.BaseController;
import com.mirs.common.core.domain.AjaxResult;
import com.mirs.common.enums.BusinessType;
import com.mirs.biz.domain.EmiMeasurement;
import com.mirs.biz.service.IEmiMeasurementService;
import com.mirs.common.utils.poi.ExcelUtil;
import com.mirs.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 测量数据Controller
 * 
 * @author kk
 * @date 2025-04-24
 */
@RestController
@RequestMapping("/manage/emiMeasure")
public class EmiMeasurementController extends BaseController
{
    @Autowired
    private IEmiMeasurementService emiMeasurementService;

    /**
     * 查询测量数据列表
     */
    @PreAuthorize("@ss.hasPermi('manage:emiMeasure:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmiMeasurement emiMeasurement)
    {
        startPage();
        List<EmiMeasurement> list = emiMeasurementService.selectEmiMeasurementList(emiMeasurement);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('manage:emiMeasure:list')")
    @GetMapping("/getList")
    public List<EmiMeasurement> getList(EmiMeasurement emiMeasurement)
    {
        return emiMeasurementService.selectEmiMeasurementList(emiMeasurement);
    }

    /**
     * 导出测量数据列表
     */
    @PreAuthorize("@ss.hasPermi('manage:emiMeasure:export')")
    @Log(title = "测量数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmiMeasurement emiMeasurement)
    {
        List<EmiMeasurement> list = emiMeasurementService.selectEmiMeasurementList(emiMeasurement);
        ExcelUtil<EmiMeasurement> util = new ExcelUtil<EmiMeasurement>(EmiMeasurement.class);
        util.exportExcel(response, list, "测量数据数据");
    }

    /**
     * 获取测量数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:emiMeasure:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(emiMeasurementService.selectEmiMeasurementById(id));
    }

    /**
     * 新增测量数据
     */
    @PreAuthorize("@ss.hasPermi('manage:emiMeasure:add')")
    @Log(title = "测量数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmiMeasurement emiMeasurement)
    {
        return toAjax(emiMeasurementService.insertEmiMeasurement(emiMeasurement));
    }

    /**
     * 修改测量数据
     */
    @PreAuthorize("@ss.hasPermi('manage:emiMeasure:edit')")
    @Log(title = "测量数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmiMeasurement emiMeasurement)
    {
        return toAjax(emiMeasurementService.updateEmiMeasurement(emiMeasurement));
    }

    /**
     * 删除测量数据
     */
    @PreAuthorize("@ss.hasPermi('manage:emiMeasure:remove')")
    @Log(title = "测量数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emiMeasurementService.deleteEmiMeasurementByIds(ids));
    }

    @Log(title = "测量数据", businessType = BusinessType.IMPORT)
    @PreAuthorize("@ss.hasPermi('manage:emiMeasure:add')")
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<EmiMeasurement> util = new ExcelUtil<>(EmiMeasurement.class);
        List<EmiMeasurement> emiMeasurementList = util.importExcel(file.getInputStream());
        String operName = getUsername();
        String message = emiMeasurementService.importEmiMeasurement(emiMeasurementList, updateSupport, operName);
        return success(message);
    }

    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response)
    {
        ExcelUtil<EmiMeasurement> util = new ExcelUtil<>(EmiMeasurement.class);
        util.importTemplateExcel(response, "测量数据");
    }
}
