package cn.com.victorysoft.business.condition.controller;

import cn.com.victorysoft.business.condition.entity.AbnormalUnit;
import cn.com.victorysoft.business.condition.entity.WaterRealtime;
import cn.com.victorysoft.business.condition.service.AbnormalUnitService;
import cn.com.victorysoft.business.condition.service.WaterRealtimeService;
import cn.com.victorysoft.business.sys.entity.ExportResult;
import cn.com.victorysoft.business.sys.param.UnitDatePageExportParam;
import cn.com.victorysoft.business.sys.param.UnitDatePageParam;
import cn.com.victorysoft.business.util.ExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Api(tags = "异常井单位统计")
@RestController
@RequestMapping("condition/abnormalUnit")
public class AbnormalUnitController {
    @Resource
    private AbnormalUnitService abnormalUnitService;
    @Resource
    private WaterRealtimeService waterRealtimeService;

    @GetMapping("/list")
    @ApiOperation("查询本单位及子单位数据")
    public List<AbnormalUnit> list(UnitDatePageParam param) {
        return abnormalUnitService.selectUnitChildren(param);
    }

    @PostMapping("/export")
    @ApiOperation("导出数据")
    public ExportResult export(@RequestBody UnitDatePageExportParam param) {
        List<AbnormalUnit> list = abnormalUnitService.selectUnitChildren(param);
        return ExcelUtils.export(param.getColumnConfig(), list, param.getFileName());
    }

    @GetMapping("/realtime")
    @ApiOperation("水井实时数据")
    public List<WaterRealtime> realtime(String wellname, Date startDate, Date endDate) {
        return waterRealtimeService.getData(wellname, startDate, endDate);
    }

}
