package com.bz.rmcp.alarm;
import java.util.Date;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;

import com.bz.rmcp.alarm.service.impl.DeviceAlarmServiceImpl;
import com.zcxk.rmcp.api.dto.product.MeasureDataDto;
import com.zcxk.rmcp.core.mongo.DeviceData;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.Map;

/**
 * @author linqingwei
 * @date 2021-08-06 9:37
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@EnableCaching  //开启缓存
@ComponentScan(basePackages = {"com.zcxk","com.bz"})
@MapperScan("com.zcxk.rmcp.core.dao")
public class AlarmTests {

    @Autowired
    private DeviceAlarmServiceImpl deviceAlarmService;

    @Test
    public void alarm(){
        String json = "{\"VOL\":3.56,\"ALARM\":\"0\",\"VOL_STATUS\":\"0\",\"VALVE\":\"01\",\"WSV\":110,\"FORCED\":\"1\",\"DISTURB\":\"1\",\"OVERDRAFT\":\"1\"}";
        Map<String,Object> map  = JSON.parseObject(json, HashMap.class);

        MeasureDataDto measureDataDto = new MeasureDataDto();
        measureDataDto.setDeviceId(880829562492162048L);
        measureDataDto.setReceiveDate(new Date());
        measureDataDto.setMeasureMap(map);



        deviceAlarmService.handle(measureDataDto);
    }
}
