package com.nantian.cloud.dbcapp.controller;


import com.nantian.cloud.dbcapp.service.MobileService;
import com.nantian.sc.cloud.common.core.util.R;
import com.nantian.sc.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
* @Description: 手机端controller
* @Param: 
* @return: 
* @Author: zfw
* @Date: 2020/1/12
* @Date: 20:05
*/
@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/mobile")
@Api(value = "mobile", tags = "手机端接口")

public class MobileController {

    private final MobileService mobileService;

    /**
     * 查询综合能耗值(按月)
     *
     * @param
     * @return R
     */
    @GetMapping("/total")
    @SysLog("手机端-根据条件获取综合能耗")
    @ApiOperation(value = "根据条件获取综合能耗", notes = "根据条件获取综合能耗")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "周期", required = false, dataType = "string", paramType = "path")
                })
    public R getTotal( String area ,String industry,String time) {
        return R.ok(mobileService.getTotal(area,industry,time),"查询成功");
    }


    /**
     * 查询企业详细
     *
     * @param
     * @return R
     */
    @GetMapping("/getCompanyInfo")
    @SysLog("手机端-查询企业详细")
    @ApiOperation(value = "查询企业详细", notes = "查询企业详细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "enterpriseCode", value = "企业code", required = true, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "周期", required = true, dataType = "string", paramType = "path")
    })
    public R getCompanyInfo( String enterpriseCode ,String time) {
        return R.ok(mobileService.getCompanyInfo(enterpriseCode,time),"查询成功");
    }

// ====================================能源计量===================================================================================
    /**
     * 能源计量人员数(合计)
     *
     * @param
     * @return R
     */
    @GetMapping("/getSumMeasurer")
    @SysLog("手机端-能源计量人员合计")
    @ApiOperation(value = "能源计量人员合计", notes = "能源计量人员合计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "areaCode", value = "企业名称", required = false, dataType = "string", paramType = "path"),
    })
    public R getSumMeasurer(String areaCode) {
        return R.ok(mobileService.getSumMeasurer(areaCode),"查询成功");
    }


    /**
     * 能源计量人员数列表
     *
     * @param
     * @return R
     */
    @GetMapping("/getSumMeasurerList")
    @SysLog("手机端-能源计量人员数")
    @ApiOperation(value = "能源计量人员数", notes = "能源计量人员数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cmpName", value = "企业名称", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path")
    })
    public R getSumMeasurerList( String cmpName ,String area,String industry) {
        return R.ok(mobileService.getSumMeasurerList(cmpName,area,industry),"查询成功");
    }

    /**
     * 能源计量人员数按地区统计
     *
     * @param
     * @return R
     */
    @GetMapping("/getSumMeasurerByArea")
    @SysLog("手机端-能源计量人员数按地区统计")
    @ApiOperation(value = "能源计量人员数按地区统计", notes = "能源计量人员数按地区统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cmpName", value = "企业名称", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path")
    })
    public R getSumMeasurerByArea( String cmpName ,String area,String industry) {
        return R.ok(mobileService.getSumMeasurerByArea(cmpName,area,industry),"查询成功");
    }
        /**
         * 能源计量审查任务(合计)
         *
         * @param
         * @return R
         */
        @GetMapping("/getSumTask")
        @SysLog("手机端-能源计量审查任务")
        @ApiOperation(value = "能源计量审查任务", notes = "能源计量审查任务")
        public R getSumTask(String areaCode) {
            return R.ok(mobileService.getSumTask(areaCode),"查询成功");
        }


        /**
         * 能源计量审查任务
         *
         * @param
         * @return R
         */
        @GetMapping("/getSumTaskList")
        @SysLog("手机端-能源计量审查任务列表")
        @ApiOperation(value = "能源计量审查任务列表", notes = "能源计量审查任务列表")
        @ApiImplicitParams({
                @ApiImplicitParam(name = "name", value = "审查名称", required = false, dataType = "string", paramType = "path"),
                @ApiImplicitParam(name = "type", value = "类型", required = false, dataType = "string", paramType = "path")
        })
        public R getSumTaskList( String name ,String type) {
            return R.ok(mobileService.getSumTaskList(name,type),"查询成功");
        }

    /**
     * 计量能源器具详情
     *
     * @param
     * @return R
     */
    @GetMapping("/getInstrumentsNum")
    @SysLog("手机端-能源计量能源器具总数")
    @ApiOperation(value = "能源计量能源器具总数", notes = "能源计量能源器具总数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cmpName", value = "企业名称", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path")
    })
    public R getInstrumentsNum(String areaCode) {
        return R.ok(mobileService.getInstrumentsNum(areaCode),"查询成功");
    }


    /**
     * 能源计量器具列表
     *
     * @param
     * @return R
     */
    @GetMapping("/getInstrumentsInfo")
    @SysLog("手机端-计量器具详情列表")
    @ApiOperation(value = "计量器具详情列表", notes = "计量器具详情列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cmpName", value = "企业名称", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "level", value = "器具等级", required = false, dataType = "string", paramType = "path"),
    })
    public R getInstrumentsInfo( String cmpName ,String area,String industry,String level,String page) {
        return R.ok(mobileService.getInstrumentsInfo(cmpName,area,industry,level),"查询成功");
    }
    /**
     * 能源计量器具列表
     *
     * @param
     * @return R
     */
    @GetMapping("/getInstrumentsNumByArea")
    @SysLog("手机端-按地区查询计量器具详情列表")
    @ApiOperation(value = "计量器具详情列表", notes = "计量器具详情列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cmpName", value = "企业名称", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "level", value = "器具等级", required = false, dataType = "string", paramType = "path"),
    })
    public R getInstrumentsNumByArea( String cmpName ,String area,String industry,String level) {
        return R.ok(mobileService.getInstrumentsNumByArea(cmpName,area,industry,level),"查询成功");
    }
    //===============================================================上送国家平台数据=================================================
    /**
     *
     *
     * @param
     * @return R
     */
        @GetMapping("/getUpDateCountryInfo")
        @SysLog("上送国家平台情况")
    @ApiOperation(value = "上送国家平台情况", notes = "上送国家平台情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "time", value = "统计时间", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path")
    })
    public R getUpDateCountryInfo( String time ,String area,String industry) {
        return R.ok(mobileService.getUpDateCountryInfo(time,area,industry),"查询成功");
    }

    @GetMapping("/getUpDateEnterpriseInfo")
    @SysLog("上送国家企业情况")
    @ApiOperation(value = "上送国家企业情况", notes = "上送国家企业情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cmpName", value = "公司名称", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path")
    })
    public R getInstrumentsInfo( String cmpName ,String area,String industry) {
        return R.ok(mobileService.getUpDateEnterpriseInfo(cmpName,area,industry),"查询成功");
    }

    @GetMapping("/getUpDateEnterpriseSimple")
    @SysLog("按日查询上送明细")
    @ApiOperation(value = "按日查询上送明细", notes = "按日查询上送明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cmpName", value = "公司名称", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "时间", required = false, dataType = "string", paramType = "path")
    })
    public R getUpDateEnterpriseSimple( String cmpName,String time) {
        return R.ok(mobileService.getUpDateEnterpriseSimple(cmpName,time),"查询成功");
    }

    @GetMapping("/getName")
    @SysLog("依据编码获取名称")
    @ApiOperation(value = "依据编码获取名称", notes = "依据编码获取名称")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "地区编码", required = false, dataType = "string", paramType = "path")
    })
    public R getUpDateEnterpriseSimple(String code) {
        return R.ok(
                mobileService.getName(code),"查询成功");
    }
    //================================异常详情=================================
    @GetMapping("/getExceptionByDay")
    @SysLog("按天查询异常记录")
    @ApiOperation(value = "按天查询异常记录", notes = "按天查询异常记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "time", value = "查询月份", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path")
    })
    public R getExceptionByDay(String time,String area) {
        return R.ok(mobileService.getExceptionByDay(time,area),"查询成功");
    }

    @GetMapping("/getExceptionByArea")
    @SysLog("按地区查询异常记录")
    @ApiOperation(value = "按地区查询异常记录", notes = "按地区查询异常记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "time", value = "查询月份", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path")
    })
    public R getExceptionByArea(String time,String area) {
        return R.ok(mobileService.getExceptionByArea(time,area),"查询成功");
    }

//=========================================================首页=========================================================
@GetMapping("/getEnterpriseNum")
@SysLog("首页-查询企业数量")
@ApiOperation(value = "查询企业数量", notes = "查询企业数量")
@ApiImplicitParams({
        @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
        @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path")
})
public R getEnterpriseNum(String industry,String area) {
    return R.ok(mobileService.getEnterpriseNum(industry,area),"查询成功");
}
}

