package com.chinaitop.depot.intelligent.comprehensive.controller;

import com.chinaitop.depot.intelligent.comprehensive.service.ComprehensiveService;
import com.chinaitop.depot.intelligent.socket.SocketClient;
import com.chinaitop.depot.intelligent.ventilation.model.TVentilation;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.unissoft.model.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
@RequestMapping(value = "/intelligents/comprehensive")
@Api(value = "ComprehensiveController", description = "综合查询控制类")
public class ComprehensiveController {


    @Resource
    private ComprehensiveService comprehensiveService;

    @RequestMapping(value = "/getList", method = RequestMethod.GET)
    @ApiOperation(value = "查询设备操作记录列表", notes = "查询设备操作记录列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
            @ApiImplicitParam(name = "vCfCode", value = "仓库名称", paramType = "query"),
            @ApiImplicitParam(name = "vDistinguishState", value = "操作类别", paramType = "query")
    })
    public ResponseEntity<PageInfo<TVentilation>> getList(Integer pageNum, Integer pageSize, String vCfCode, String vDistinguishState) {
        List<TVentilation> list = null;
        try {
            if (null != pageNum && null != pageSize) {
                PageHelper.startPage(pageNum, pageSize);
            }
            list = comprehensiveService.getList(vCfCode, vDistinguishState);
        } catch (Exception e) {
            e.printStackTrace();
            ResponseEntity.failed(e.getMessage());
        }
        PageInfo<TVentilation> pageInfo = new PageInfo<TVentilation>(list);
        return ResponseEntity.ok(pageInfo);
    }
    @RequestMapping(value = "/getById", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询设备操作记录", notes = "根据id查询设备操作记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "设备操作记录id", paramType = "query")
    })
    public ResponseEntity<TVentilation> getById(String id) {
        TVentilation byId = comprehensiveService.getById(id);
        return ResponseEntity.ok(byId);
    }
}
