/*
Copyright [2020] [https://www.xiaonuo.vip]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：

1.请不要删除和修改根目录下的LICENSE文件。
2.请不要删除和修改Snowy源码头部的版权声明。
3.请保留源码和相关描述文件的项目出处，作者声明等。
4.分发源码时候，请注明软件出处 https://gitee.com/xiaonuobase/snowy
5.在修改包名，模块名称，项目代码等时，请注明软件出处 https://gitee.com/xiaonuobase/snowy
6.若您的项目无法满足以上几点，可申请商业授权，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package com.huimv.modular.eartagdata.controller;

import com.huimv.core.annotion.Permission;
import com.huimv.core.pojo.page.PageResult;
import com.huimv.core.pojo.response.ResponseData;
import com.huimv.core.pojo.response.SuccessResponseData;
import com.huimv.modular.eartagdata.entity.EartagData;
import com.huimv.modular.eartagdata.param.EartagDataParam;
import com.huimv.modular.eartagdata.service.EartagDataService;
import com.huimv.modular.result.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
/**
 * 耳标数据详情控制器
 *
 * @author Yangdi
 * @date 2021-08-19 13:18:22
 */
@RestController
public class EartagDataController {

    @Resource
    private EartagDataService eartagDataService;

    //增加处理耳标数据接口

    //根据耳标电量查询
    @Permission
    @PostMapping("/manager/eartagdata/findByConditions")
    //@BusinessLog(title = "栋舍表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData findByConditions(@RequestParam Map<String, Object> params  ) throws ParseException {
        System.out.println("进入查询111");
        PageResult<EartagData> byConditions = eartagDataService.findByConditions(params);
        System.out.println("进入查询");
        return   new SuccessResponseData(byConditions);
    }

/*

    @PostMapping("/manager/eartagdata/findByConditions2")
    //@BusinessLog(title = "栋舍表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData findByConditions2(@RequestParam Map<String, Object> params  ) throws ParseException {
        System.out.println("进入查询111");
        PageResult<EartagData> byConditions = eartagDataService.findByConditions2(params);
        System.out.println("进入查询");
        return   new SuccessResponseData(byConditions);
    }
*/






    @Permission
    @PostMapping("/getearagdataBytime")
    //@BusinessLog(title = "栋舍表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData getearagdataBytime(@RequestParam Map<String, Object> params  ) throws ParseException {
        System.out.println("进入查询111");
        PageResult<EartagData> byConditions = eartagDataService.findByTime(params);
        System.out.println("进入查询");
        return   new SuccessResponseData(byConditions);
    }



    @PostMapping("/manager/eartagdata/list_deatils_byeartagno")
    public R listDeatils01(@RequestParam Map<String, Object> params) throws ParseException {
        Map queryDetailsMap = eartagDataService.queryDetailsByEarTag(params);
        return R.ok().put("page", queryDetailsMap);
    }





    /**
     * 查询耳标数据详情
     *
     * @author Yangdi
     * @date 2021-08-19 13:18:22
     */
    @GetMapping("/eartagData/page")
    public ResponseData page(@RequestParam Map<String, Object> params ) throws ParseException {
        PageResult<EartagData> byConditions = eartagDataService.findByTime(params);
        System.out.println("进入查询");
        return   new SuccessResponseData(byConditions);
    }

    /**
     * 添加耳标数据详情
     *
     * @author Yangdi
     * @date 2021-08-19 13:18:22
     */
    @PostMapping("/eartagData/add")
    public ResponseData add(@RequestBody @Validated(EartagDataParam.add.class) EartagDataParam eartagDataParam) {
            eartagDataService.add(eartagDataParam);
        return new SuccessResponseData();
    }

    /**
     * 删除耳标数据详情，可批量删除
     *
     * @author Yangdi
     * @date 2021-08-19 13:18:22
     */
    @PostMapping("/eartagData/delete")
    public ResponseData delete(@RequestBody @Validated(EartagDataParam.delete.class) List<EartagDataParam> eartagDataParamList) {
            eartagDataService.delete(eartagDataParamList);
        return new SuccessResponseData();
    }

    /**
     * 编辑耳标数据详情
     *
     * @author Yangdi
     * @date 2021-08-19 13:18:22
     */
    @PostMapping("/eartagData/edit")
    public ResponseData edit(@RequestBody @Validated(EartagDataParam.edit.class) EartagDataParam eartagDataParam) {
            eartagDataService.edit(eartagDataParam);
        return new SuccessResponseData();
    }

    /**
     * 查看耳标数据详情
     *
     * @author Yangdi
     * @date 2021-08-19 13:18:22
     */
    @GetMapping("/eartagData/detail")
    public ResponseData detail(@Validated(EartagDataParam.detail.class) EartagDataParam eartagDataParam) {
        return new SuccessResponseData(eartagDataService.detail(eartagDataParam));
    }

    /**
     * 耳标数据详情列表
     *
     * @author Yangdi
     * @date 2021-08-19 13:18:22
     */
    @GetMapping("/eartagData/list")
    public ResponseData list(EartagDataParam eartagDataParam) {
        return new SuccessResponseData(eartagDataService.list(eartagDataParam));
    }

    /**
     * 导出系统用户
     *
     * @author Yangdi
     * @date 2021-08-19 13:18:22
     */
    @GetMapping("/eartagData/export")
    public void export(EartagDataParam eartagDataParam) {
        eartagDataService.export(eartagDataParam);
    }



    /**
     * 查询每小时的上传量
     */
    @RequestMapping("/eartagData/countByTime")
    public ResponseData countByTime(@RequestParam Map<String, Object> params){


        return eartagDataService.countByTime(params);
    }

    /**
     * 查询每小时的上传量
     */
    @RequestMapping("/eartagData/countByDay")
    public ResponseData countByDay(@RequestParam Map<String, Object> params){
        return  eartagDataService.countByDay(params);
    }


    //删除耳标下面所有的数据
    @Permission
    @PostMapping("/eartagData/deletebyeartagno")
    //@BusinessLog(title = "栋舍表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData deletebyeartagno(@RequestParam Map<String, Object> params  ) throws ParseException {
        System.out.println("进入查询111");
        PageResult<EartagData> byConditions = eartagDataService.findByTime(params);
        System.out.println("进入查询");
        return   new SuccessResponseData(byConditions);
    }















}
