package com.njcn.prepare.harmonic.controller.device;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.prepare.harmonic.pojo.param.DeviceAbnormaStatisticsParam;
import com.njcn.prepare.harmonic.service.mysql.device.DeviceAbnormalStatisticsService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

@Slf4j
@Api(tags = "终端异常统计")
@RestController
@RequestMapping("/deviceAbnormal")
@RequiredArgsConstructor
public class DeviceAbnormalController extends BaseController {

    private final DeviceAbnormalStatisticsService deviceAbnormaStatisticsService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/statistics")
    @ApiOperation("终端异常统计")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<Boolean> dailyDeviceAbnormaStatistics(@RequestBody DeviceAbnormaStatisticsParam param) {
        String methodDescribe = getMethodDescribe("dailyDeviceAbnormaStatistics");
        boolean res = deviceAbnormaStatisticsService.dailyDeviceAbnormaStatistics(param);
        if(res){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }
    }






}
