SystemController.java 5.39 KB
package org.rcisoft.business.system.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.system.service.SystemService;
import org.rcisoft.business.system.vo.ParamStatus;
import org.rcisoft.business.system.vo.ParamStatusList;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by JiChao on 2018/5/2.
 * 系统模块
 */
@Api(tags = "系统检测")
@RestController
@RequestMapping("system")
public class SystemController {

    @Autowired
    private SystemService systemServiceImpl;

    @ApiOperation(value="气候自适应统计", notes="气候自适应统计")
    @ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目主键", required = true, dataType = "字符串")
    })
    @RequestMapping("/statClimate")
    public Result statClimate(@RequestParam String proId) {
        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.statClimate(proId));
    }

    @ApiOperation(value="能源消耗", notes="能源消耗")
    @ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目主键", required = true, dataType = "字符串")
    })
    @RequestMapping("/energyConsume")
    public Result energyConsume(@RequestParam String proId) {
        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.energyConsume(proId));
    }

    @ApiOperation(value="逐时负荷", notes="逐时负荷")
    @ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目主键", required = true, dataType = "字符串")
    })
    @RequestMapping("/burdenHour")
    public Result burdenHour(@RequestParam String proId) {
        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.burdenHour(proId));
    }

    @ApiOperation(value="故障报修 and 运行时长", notes="根据项目id查询所有设备的错误数量和运行时长,10分钟查询一次")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "proId", value = "项目主键", required = true, dataType = "字符串")
    })
    @RequestMapping("/selectErrorandRuntime")
    public Result selectErrorandRuntime(@RequestParam String proId) {
        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.selectErrorandRuntime(proId));
    }

    @ApiOperation(value="查询参数列表", notes="根据设备num查询所有参数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "devNum", value = "设备num", required = true, dataType = "字符串")
    })
    @RequestMapping("/selectDeviceParamList")
    public Result selectDeviceParamList(@RequestParam String devNum) {
        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.selectDeviceParamList(devNum));
    }

    @ApiOperation(value="查询参数数据", notes="查询缓存中的数据,10秒钟查询1次")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "proId", value = "项目主键", required = true, dataType = "字符串")
    })
    @RequestMapping("/selectDataByCache")
    public String selectDataByCache(@RequestParam String proId) {
        return systemServiceImpl.selectDataByCache(proId);
//        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.selectDataByCache(proId));
    }

    @ApiOperation(value="查询传感器code", notes="查询传感器code")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "proId", value = "项目主键", required = true, dataType = "字符串")
    })
    @RequestMapping("/selectSensorCode")
    public Result selectSensorCode(@RequestParam String proId, @RequestParam String devNum) {
        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.selectSensorCode(proId, devNum));
    }

    @ApiOperation(value="查询项目下所有设备的信息", notes="通过电流参数判断设备是否开启")
    @RequestMapping("/selectDeviceAll")
    public Result selectDeviceAll(@RequestParam String proId) {
        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.selectDeviceAll(proId));
    }

    @ApiOperation(value="查询每个设备的状态", notes="0:关闭,1:开启")
    @RequestMapping("/selectDeviceStatus")
    public Result selectDeviceStatus(@RequestBody ParamStatusList list) {
        return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, systemServiceImpl.selectDeviceStatus(list));
    }

}