package com.fuyuanshen.web.service.device;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.app.domain.AppPersonnelInfo;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDevice6075DetailVo;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.utils.*;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceType;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.equipment.enums.LightModeEnum;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
import com.fuyuanshen.global.mqtt.config.MqttGateway;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.global.mqtt.constants.MqttConstants;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.time.Duration;
import java.util.*;

import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
import static com.fuyuanshen.common.core.utils.Bitmap80x12Generator.buildArr;
import static com.fuyuanshen.common.core.utils.Bitmap80x12Generator.generateFixedBitmapData;
import static com.fuyuanshen.common.core.utils.ImageToCArrayConverter.convertHexToDecimal;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;


@Service
public interface DeviceBJQ6075BizService {

    /**
     * 获取设备详情
     *
     * @param id 设备ID
     * @return 设备详情
     */
    public AppDevice6075DetailVo getInfo(Long id);

    public int sendMessage(AppDeviceSendMsgBo bo);

    /**
     * 记录设备操作日志
     *
     * @param deviceId 设备ID
     * @param content  日志内容
     * @param operator 操作人
     */
    public void recordDeviceLog(Long deviceId, String deviceName, String deviceAction, String content, Long operator);

    /**
     * 注册人员信息
     *
     * @param bo 参数
     * @return 结果
     */
    public boolean registerPersonInfo(AppPersonnelInfoBo bo);

    public void uploadDeviceLogo2(AppDeviceLogoUploadDto bo);

    public void uploadDeviceLogo(AppDeviceLogoUploadDto bo);

    /**
     * 灯光模式
     * （主光模式）
     * 0（关闭灯光），1（强光），2（超强光）,  3（工作光）, 4（节能光），5（爆闪），6（SOS）
     */
    public void lightModeSettings(DeviceInstructDto params);

    // 灯光亮度设置
    public void lightBrightnessSettings(DeviceInstructDto params);

    // 激光模式设置
    public void laserModeSettings(DeviceInstructDto params);

    public String mapReverseGeocoding(DeviceInstructDto params);

    public int sendAlarmMessage(AppDeviceSendMsgBo bo);

    public void messageSending(String deviceImei);

    public boolean getDeviceStatus(String deviceImei);

    public void batchUploadLogo(AppDeviceLogoUploadDto bo);

}
