package com.zehong.web.controller.equipment;

import java.util.List;
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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TStoreyInfo;
import com.zehong.system.service.ITStoreyInfoService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 老化层信息Controller
 * 
 * @author zehong
 * @date 2025-05-28
 */
@RestController
@RequestMapping("/storey")
public class TStoreyInfoController extends BaseController
{
    @Autowired
    private ITStoreyInfoService tStoreyInfoService;

    /**
     * 查询老化层信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TStoreyInfo tStoreyInfo)
    {
        startPage();
        List<TStoreyInfo> list = tStoreyInfoService.selectTStoreyInfoList(tStoreyInfo);
        return getDataTable(list);
    }

    /**
     * 导出老化层信息列表
     */
    @Log(title = "老化层信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TStoreyInfo tStoreyInfo)
    {
        List<TStoreyInfo> list = tStoreyInfoService.selectTStoreyInfoList(tStoreyInfo);
        ExcelUtil<TStoreyInfo> util = new ExcelUtil<TStoreyInfo>(TStoreyInfo.class);
        return util.exportExcel(list, "老化层信息数据");
    }

    /**
     * 获取老化层信息详细信息
     */
    @GetMapping(value = "/queryByDepartmentId/{fEquipmentId}")
    public AjaxResult queryByDepartmentId(@PathVariable("fEquipmentId") Long fEquipmentId)
    {
        return AjaxResult.success(tStoreyInfoService.queryByDepartmentId(fEquipmentId));
    }

    /**
     * 给设备上电
     */
    @GetMapping(value = "/powerOn")
    public AjaxResult powerOn(TStoreyInfo tStoreyInfo) {
        return tStoreyInfoService.powerOn(tStoreyInfo);
    }

    /**
     * 给设备上电
     */
    @GetMapping(value = "/powerOutage")
    public AjaxResult powerOutage(TStoreyInfo tStoreyInfo) {
        return tStoreyInfoService.powerOutage(tStoreyInfo);
    }

    /**
     * 批量读取老化柜状态
     */
    @GetMapping(value = "/batchReadingCabinetStatus/{fEquipmentCode}")
    public AjaxResult batchReadingCabinetStatus(@PathVariable("fEquipmentCode") String fEquipmentCode) {
        return tStoreyInfoService.batchReadingCabinetStatus(fEquipmentCode);
    }

    /**
     * 获取老化层信息详细信息
     */
    @GetMapping(value = "/{fStoreyId}")
    public AjaxResult getInfo(@PathVariable("fStoreyId") Long fStoreyId)
    {
        return AjaxResult.success(tStoreyInfoService.selectTStoreyInfoById(fStoreyId));
    }

    /**
     * 新增老化层信息
     */
    @Log(title = "老化层信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TStoreyInfo tStoreyInfo)
    {
        return toAjax(tStoreyInfoService.insertTStoreyInfo(tStoreyInfo));
    }

    /**
     * 修改老化层信息
     */
    @Log(title = "老化层信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TStoreyInfo tStoreyInfo)
    {
        return toAjax(tStoreyInfoService.updateTStoreyInfo(tStoreyInfo));
    }

    /**
     * 删除老化层信息
     */
    @Log(title = "老化层信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fStoreyIds}")
    public AjaxResult remove(@PathVariable Long[] fStoreyIds)
    {
        return toAjax(tStoreyInfoService.deleteTStoreyInfoByIds(fStoreyIds));
    }
}
