|
@@ -16,6 +16,7 @@ import com.huimv.environ.utils.HttpTemplete;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.domain.Example;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
@@ -24,6 +25,7 @@ import java.text.ParseException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @Project : huimv.shiwan
|
|
@@ -54,6 +56,9 @@ public class EnvironImpl implements IEnviron {
|
|
|
//小时数据服务
|
|
|
@Value("${dataCenter.service.hourEnviron}")
|
|
|
private String hourEnvironService;
|
|
|
+ //分钟数据服务
|
|
|
+ @Value("${dataCenter.service.minuteEnviron}")
|
|
|
+ private String hourMinuteService;
|
|
|
//实时数据服务
|
|
|
@Value("${dataCenter.service.realTimeEnviron}")
|
|
|
private String realTimeEnvironService;
|
|
@@ -208,6 +213,44 @@ public class EnvironImpl implements IEnviron {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void sendMinuteEnviron(String data) {
|
|
|
+ String url = ipAddr + port + hourMinuteService;
|
|
|
+ log.info("推送数据地址:"+url);
|
|
|
+ //
|
|
|
+ Map<String,String> paramsMap = new HashMap<String,String>();
|
|
|
+ paramsMap.put("data", data);
|
|
|
+ //
|
|
|
+ Map<String,Integer> timeoutMap = new HashMap<String,Integer>();
|
|
|
+ timeoutMap.put("connectTimeout", 5000);
|
|
|
+ timeoutMap.put("requestTimeout", 5000);
|
|
|
+ timeoutMap.put("socketTimeout", 5000);
|
|
|
+ try{
|
|
|
+ // 用Post方法推送接口数据
|
|
|
+ httpTemplete.doPost(url,paramsMap,timeoutMap);
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.out.println("###错误信息:"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getMinuteEnv(Integer farmId) {
|
|
|
+ //读取分钟数据
|
|
|
+ EnvMinuteEntity envMinuteEntity = new EnvMinuteEntity();
|
|
|
+ envMinuteEntity.setId(129558);
|
|
|
+ Example<EnvMinuteEntity> example = Example.of(envMinuteEntity);
|
|
|
+ Optional<EnvMinuteEntity> opl = envMinuteRepo.findOne(example);
|
|
|
+ if(opl.isPresent()){
|
|
|
+ EnvMinuteEntity envMinuteEntity2 = opl.get();
|
|
|
+ //推送数据
|
|
|
+ sendMinuteEnviron(JSON.toJSON(envMinuteEntity2).toString());
|
|
|
+ }else{
|
|
|
+ System.out.println("数据不存在.");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//向数据中心发送警报
|
|
|
public void _sendAlarmToCenter(String alarmInfo,Integer alarmType) throws ParseException {
|
|
|
log.info("警报内容>>"+alarmInfo);
|