vince
2023-07-07 7f228da10dd393e45c36e1240c5e71aa9f14fc43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.ld.igds.protocol.bhzn.verb.analysis;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.common.CoreCommonService;
import com.ld.igds.common.CoreDeviceService;
import com.ld.igds.constant.BizType;
import com.ld.igds.gas.CoreGasService;
import com.ld.igds.io.constant.OrderRespEnum;
import com.ld.igds.io.notify.NotifyWebInvoker;
import com.ld.igds.models.*;
import com.ld.igds.protocol.bhzn.verb.command.BaseRemoteImpl;
import com.ld.igds.protocol.bhzn.verb.dto.IoMessage;
import com.ld.igds.protocol.bhzn.verb.dto.Res209;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.NumberUtil;
import com.ld.igds.weather.WeatherUtil;
import com.ld.igds.weather.notify.NotifyWeatherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * 气体解析
 */
@Slf4j
@Component(AnalysisWeather.BEAN_ID)
public class AnalysisWeather extends BaseRemoteImpl {
 
    public static final String BEAN_ID = "bhzn.analysisWeather";
 
    @Autowired
    private CoreDeviceService deviceService;
    @Autowired
    private NotifyWebInvoker notifyInvoker;
    @Autowired
    private CoreCommonService commonService;
    @Resource(name = NotifyWeatherService.BEAN_ID)
    private NotifyWeatherService notifyService;
 
    /**
     * 设备状态
     *
     * @param reMessage
     * @param ser
     */
    public void analysis(IoMessage reMessage, DeviceSer ser) {
 
        log.info("气象站检测开始解析");
        JSONObject jsonObject = JSONObject.parseObject(reMessage.getStrMsg());
 
 
        log.info("气象返回结果={}", reMessage.getStrMsg());
        int Temper = jsonObject.getInteger("Temper");
        int Humy = jsonObject.getInteger("Humy");
        int WindSpeed = jsonObject.getInteger("WindSpeed");
        int RainFall = jsonObject.getInteger("RainFall");
        int Pressure = jsonObject.getInteger("Pressure");
        int WindDir = jsonObject.getInteger("WindDir");
 
 
        WeatherInfo info = new WeatherInfo();
        info.setId(WeatherUtil.buildWeatherId("5324_001", new Date()));
//        info.setAirLevel(dto.getAir_level());
        info.setCompanyId(ser.getCompanyId());
        info.setDeptId("5324_001");
        info.setHumidity((Humy/10)+"");
        //info.setPm25(dto.getAir_pm25());
        info.setPressure(Pressure+"");
        info.setSource(WeatherUtil.SOURCE_01);
        info.setTemp((Temper/10)+"");
        info.setWeather(RainFall > 0?"下雨":"晴天");
        info.setWindDirection(WindDir+"");
//        info.setWindSpeed();
        info.setWindMeter((WindSpeed/10) + "");
        info.setCity("高州市");
        info.setUpdateTime(new Date());
 
        notifyService.notify(info);
        log.info("控制柜----->>>平台:气象站检测解析完成-");
 
    }
 
}