package com.bonus.app.controller;

import com.bonus.app.service.ICraneMonitorService;
import com.bonus.common.core.constant.BusinessConstants;
import com.bonus.common.core.text.Convert;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.entity.app.AppParamsDto;
import com.bonus.common.entity.app.vo.DevWarnVo;
import com.bonus.common.entity.app.vo.JdConfigVo;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @className:CraneMonitorController
 * @author:cwchen
 * @date:2024-08-12-15:35
 * @version:1.0
 * @description:吊车监控
 */
@RestController
@RequestMapping("/craneMonitor/")
@Slf4j
public class CraneMonitorController {

    @Resource(name = "ICraneMonitorService")
    private ICraneMonitorService service;

    @GetMapping("getDzWarnList")
    @SysLog(title = "APP->吊装监控", businessType = OperaType.QUERY,logType = 0,module = "APP->吊装监控",details ="查询吊装预警设备")
    public AjaxResult getDzWarnList(AppParamsDto dto){
        return service.getDzWarnList(dto);
    }

    @GetMapping("getJdList")
    @SysLog(title = "APP->吊装监控", businessType = OperaType.QUERY,logType = 0,module = "APP->吊装监控",details ="查询近电感应设备")
    public AjaxResult getJdList(AppParamsDto dto){
        return service.getJdList(dto);
    }

    @GetMapping("getJdWarnList")
    @SysLog(title = "APP->吊装监控", businessType = OperaType.QUERY,logType = 0,module = "APP->吊装监控",details ="查询近电感应设备预警信息")
    public AjaxResult getJdWarnList(AppParamsDto dto){
        Integer pageNum = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_SIZE), 10);
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<DevWarnVo> pageInfo = service.getJdWarnList(dto);
        return AjaxResult.success(pageInfo.getList());
    }

    @PostMapping("configJdDevice")
    @SysLog(title = "APP->吊装监控", businessType = OperaType.INSERT,logType = 0,module = "APP->吊装监控",details ="配置近电感应设备属性")
    public AjaxResult configJdDevice(@Validated @RequestBody JdConfigVo vo){
        return service.configJdDevice(vo);
    }
    @GetMapping("getConfigJdDevice")
    @SysLog(title = "APP->吊装监控", businessType = OperaType.QUERY,logType = 0,module = "APP->吊装监控",details ="查询近电感应设备配置属性")
    public AjaxResult getConfigJdDevice(AppParamsDto dto){
        return service.getConfigJdDevice(dto);
    }

}
