奥体项目接口及天气接口开发
正在显示
13 个修改的文件
包含
808 行增加
和
0 行删除
fm-product/src/main/java/com/skua/modules/business/controller/OlympicCenterController.java
0 → 100644
1 | package com.skua.modules.business.controller; | ||
2 | |||
3 | import com.skua.core.api.vo.Result; | ||
4 | import com.skua.modules.business.service.IOlympicCenterService; | ||
5 | import com.skua.modules.business.service.ISynthesizeService; | ||
6 | import com.skua.modules.business.vo.EchartResult; | ||
7 | import io.swagger.annotations.Api; | ||
8 | import io.swagger.annotations.ApiOperation; | ||
9 | import lombok.extern.slf4j.Slf4j; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | ||
11 | import org.springframework.web.bind.annotation.GetMapping; | ||
12 | import org.springframework.web.bind.annotation.RequestMapping; | ||
13 | import org.springframework.web.bind.annotation.RestController; | ||
14 | |||
15 | import java.util.ArrayList; | ||
16 | import java.util.HashMap; | ||
17 | import java.util.List; | ||
18 | import java.util.Map; | ||
19 | |||
20 | /** | ||
21 | * 武汉奥体中心接口 | ||
22 | */ | ||
23 | @Slf4j | ||
24 | @Api(tags="武汉奥体中心接口") | ||
25 | @RestController | ||
26 | @RequestMapping("/3d/olympic") | ||
27 | public class OlympicCenterController { | ||
28 | |||
29 | @Autowired | ||
30 | private IOlympicCenterService olympicCenterService; | ||
31 | |||
32 | @ApiOperation(value="获取整体实时数据", notes="获取整体实时数据") | ||
33 | @GetMapping(value = "/getRealTimeData") | ||
34 | public Result<Map<String,Object>> getRealTimeData(){ | ||
35 | Result<Map<String,Object>> result = new Result<Map<String,Object>>(); | ||
36 | Map<String,Object> map = olympicCenterService.getRealTimeData(); | ||
37 | result.setResult(map); | ||
38 | result.setSuccess(true); | ||
39 | return result; | ||
40 | } | ||
41 | |||
42 | @ApiOperation(value="获取指标历史趋势曲线", notes="获取指标历史趋势曲线") | ||
43 | @GetMapping(value = "/getHistoryData") | ||
44 | public Result<Map<String,Object>> getHistoryData(String field){ | ||
45 | Result<Map<String,Object>> result = new Result<Map<String,Object>>(); | ||
46 | Map<String,Object> map = olympicCenterService.getHistoryData(field); | ||
47 | result.setResult(map); | ||
48 | result.setSuccess(true); | ||
49 | return result; | ||
50 | } | ||
51 | |||
52 | @ApiOperation(value="获取供水量趋势柱折图", notes="获取供水量趋势柱折图") | ||
53 | @GetMapping(value = "/getWaterChart") | ||
54 | public Result<List<EchartResult>> getWaterChart(String sourceType,String dateType,String start,String end){ | ||
55 | Result<List<EchartResult>> result = new Result<List<EchartResult>>(); | ||
56 | List<EchartResult> list = new ArrayList<EchartResult>(); | ||
57 | list = olympicCenterService.getWaterChart(sourceType, dateType, start, end); | ||
58 | result.setResult(list); | ||
59 | result.setSuccess(true); | ||
60 | return result; | ||
61 | } | ||
62 | |||
63 | @ApiOperation(value="获取压力趋势图", notes="获取压力趋势图") | ||
64 | @GetMapping(value = "/getPressureChart") | ||
65 | public Result<List<EchartResult>> getPressureChart(String equipId){ | ||
66 | Result<List<EchartResult>> result = new Result<List<EchartResult>>(); | ||
67 | List<EchartResult> list = new ArrayList<EchartResult>(); | ||
68 | list = olympicCenterService.getPressureChart(equipId); | ||
69 | result.setResult(list); | ||
70 | result.setSuccess(true); | ||
71 | return result; | ||
72 | } | ||
73 | |||
74 | } |
1 | package com.skua.modules.business.service; | ||
2 | |||
3 | import com.skua.modules.business.vo.EchartResult; | ||
4 | |||
5 | import java.util.List; | ||
6 | import java.util.Map; | ||
7 | |||
8 | /** | ||
9 | * 武汉奥体中心接口 | ||
10 | */ | ||
11 | public interface IOlympicCenterService { | ||
12 | |||
13 | Map<String,Object> getRealTimeData(); | ||
14 | |||
15 | Map<String, Object> getHistoryData(String field); | ||
16 | |||
17 | List<EchartResult> getWaterChart(String sourceType, String dateType, String start, String end); | ||
18 | |||
19 | List<EchartResult> getPressureChart(String equipId); | ||
20 | } |
fm-product/src/main/java/com/skua/modules/business/service/impl/OlympicCenterServiceImpl.java
0 → 100644
1 | package com.skua.modules.business.service.impl; | ||
2 | |||
3 | import com.skua.core.service.IPgQueryService; | ||
4 | import com.skua.modules.business.service.IOlympicCenterService; | ||
5 | import com.skua.modules.business.vo.EchartResult; | ||
6 | import org.springframework.beans.factory.annotation.Autowired; | ||
7 | import org.springframework.stereotype.Service; | ||
8 | |||
9 | import java.text.SimpleDateFormat; | ||
10 | import java.util.*; | ||
11 | |||
12 | /** | ||
13 | * 武汉奥体中心接口 | ||
14 | */ | ||
15 | @Service | ||
16 | public class OlympicCenterServiceImpl implements IOlympicCenterService { | ||
17 | |||
18 | @Autowired | ||
19 | private IPgQueryService pgQueryService; | ||
20 | |||
21 | @Override | ||
22 | public Map<String,Object> getRealTimeData() { | ||
23 | Map<String,Object> map = new HashMap<>(); | ||
24 | String jsFields = "BKYHWSC_JS_Tag2,BKYHWSC_JS_Tag3"; | ||
25 | List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData("",jsFields); | ||
26 | if(monitorList.size()==1){ | ||
27 | map = monitorList.get(0); | ||
28 | } | ||
29 | return map; | ||
30 | } | ||
31 | |||
32 | @Override | ||
33 | public Map<String, Object> getHistoryData(String field) { | ||
34 | return null; | ||
35 | } | ||
36 | |||
37 | @Override | ||
38 | public List<EchartResult> getWaterChart(String sourceType, String dateType, String start, String end) { | ||
39 | List<EchartResult> list = new ArrayList<>(); | ||
40 | for (int i = 0; i < 30; i++) { | ||
41 | Calendar date = Calendar.getInstance(); | ||
42 | date.add(Calendar.DATE, i-30); | ||
43 | String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10); | ||
44 | EchartResult rgsResult = new EchartResult(); | ||
45 | rgsResult.setName(newDate); | ||
46 | rgsResult.setValue(formatDouble(100*getRandom(2.00,3.00)).toString()); | ||
47 | rgsResult.setSeries("日供水量"); | ||
48 | list.add(rgsResult); | ||
49 | EchartResult shResult = new EchartResult(); | ||
50 | shResult.setName(newDate); | ||
51 | shResult.setValue(formatDouble(getRandom(4.00,8.00)).toString()); | ||
52 | shResult.setSeries("生活用水"); | ||
53 | list.add(shResult); | ||
54 | EchartResult xzResult = new EchartResult(); | ||
55 | xzResult.setName(newDate); | ||
56 | xzResult.setValue(formatDouble(getRandom(4.00,8.00)).toString()); | ||
57 | xzResult.setSeries("行政用水"); | ||
58 | list.add(xzResult); | ||
59 | } | ||
60 | return list; | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public List<EchartResult> getPressureChart(String equipId) { | ||
65 | List<EchartResult> list = new ArrayList<>(); | ||
66 | for (int i = 0; i < 30; i++) { | ||
67 | Calendar date = Calendar.getInstance(); | ||
68 | date.add(Calendar.DATE, i-30); | ||
69 | String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10); | ||
70 | EchartResult echartResult = new EchartResult(); | ||
71 | echartResult.setName(newDate); | ||
72 | echartResult.setValue(formatDouble(getRandom(0.40,0.50)).toString()); | ||
73 | echartResult.setSeries("压力表"); | ||
74 | list.add(echartResult); | ||
75 | } | ||
76 | return list; | ||
77 | } | ||
78 | |||
79 | public static void main(String[] args) { | ||
80 | for (int i = 0; i < 30; i++) { | ||
81 | Calendar date = Calendar.getInstance(); | ||
82 | date.add(Calendar.DATE, i-30); | ||
83 | String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10); | ||
84 | System.out.println("=========="+newDate+"============"); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * 获取大于等于min,小于max的随机小数 | ||
90 | * @param min | ||
91 | * @param max | ||
92 | * @return | ||
93 | */ | ||
94 | private static Double getRandom(Double min, Double max){ | ||
95 | return Math.random() * (max - min) + min; | ||
96 | } | ||
97 | |||
98 | /** | ||
99 | * 保留两位小数 | ||
100 | * @param two | ||
101 | * @return | ||
102 | */ | ||
103 | private static Double formatDouble(Double two){ | ||
104 | String str = String.format("%.2f",two); | ||
105 | return Double.parseDouble(str); | ||
106 | } | ||
107 | |||
108 | } |
1 | package com.skua.modules.remote.controller; | ||
2 | |||
3 | import com.alibaba.fastjson.JSON; | ||
4 | import com.alibaba.fastjson.JSONObject; | ||
5 | import com.skua.core.api.vo.Result; | ||
6 | import com.skua.core.aspect.annotation.AutoLog; | ||
7 | import io.swagger.annotations.Api; | ||
8 | import io.swagger.annotations.ApiOperation; | ||
9 | import lombok.extern.slf4j.Slf4j; | ||
10 | import org.springframework.web.bind.annotation.*; | ||
11 | import java.util.*; | ||
12 | |||
13 | /** | ||
14 | * 获取实时数据 | ||
15 | */ | ||
16 | @Slf4j | ||
17 | @Api(tags="获取实时数据") | ||
18 | @RestController | ||
19 | @RequestMapping("/3d/monitorData") | ||
20 | public class MonitorDataController { | ||
21 | |||
22 | /** | ||
23 | * 获取实时数据 | ||
24 | * @param json | ||
25 | * @return | ||
26 | */ | ||
27 | @AutoLog(value = "获取实时数据") | ||
28 | @ApiOperation(value="获取实时数据", notes="获取实时数据") | ||
29 | @GetMapping(value = "/receiveJson") | ||
30 | public Result<?> receiveJson(String json) { | ||
31 | System.out.println("==="+json); | ||
32 | Result<?> result = new Result<>(); | ||
33 | JSONObject dataJson = JSON.parseObject(json); | ||
34 | JSONObject buildFlinkJson = new JSONObject(); | ||
35 | List<Map> dataList = (List<Map>)dataJson.get("datas"); | ||
36 | buildFlinkJson.put("frmt",dataJson.get("frmt")); | ||
37 | buildFlinkJson.put("ver", dataJson.get("ver")); | ||
38 | buildFlinkJson.put("cid", dataJson.get("cid")); | ||
39 | buildFlinkJson.put("datas", dataList); | ||
40 | result.setSuccess(true); | ||
41 | return result; | ||
42 | } | ||
43 | |||
44 | } |
1 | package com.skua.modules.util; | ||
2 | |||
3 | import org.slf4j.Logger; | ||
4 | import org.slf4j.LoggerFactory; | ||
5 | |||
6 | import javax.crypto.Cipher; | ||
7 | import javax.crypto.spec.IvParameterSpec; | ||
8 | import javax.crypto.spec.SecretKeySpec; | ||
9 | import java.io.UnsupportedEncodingException; | ||
10 | import java.security.MessageDigest; | ||
11 | import java.security.NoSuchAlgorithmException; | ||
12 | import java.util.Base64; | ||
13 | |||
14 | public class AesUtil { | ||
15 | private static Logger log = LoggerFactory.getLogger(AesUtil.class); | ||
16 | private static final String CIPHER_ALGORITHM = "AES"; | ||
17 | /** | ||
18 | * 默认编码 | ||
19 | */ | ||
20 | private static final String CHARSET = "utf-8"; | ||
21 | /** | ||
22 | * 通过密码/token 生产16位byte数组,password对应字节不足16位数组末尾补0,超过16位取前16位 | ||
23 | * | ||
24 | * @param password | ||
25 | * @return | ||
26 | */ | ||
27 | private static byte[] encodeKey(String password) { | ||
28 | byte[] result = new byte[16]; | ||
29 | for (int i = 0; i < 16; i++) { | ||
30 | result[i] = 0; | ||
31 | } | ||
32 | byte[] passByte = password.getBytes(); | ||
33 | for (int i = 0; i < passByte.length; i++) { | ||
34 | if (i >= 16) { | ||
35 | break; | ||
36 | } | ||
37 | result[i] = passByte[i]; | ||
38 | } | ||
39 | return result; | ||
40 | } | ||
41 | /** | ||
42 | * AES解密,对加密后的base64字符串进行解密 | ||
43 | * | ||
44 | */ | ||
45 | public static String decrypt(String password, String data) { | ||
46 | if (password == null || password.trim().length() < 1) { | ||
47 | throw new RuntimeException("加密失败,key不能为空"); | ||
48 | } | ||
49 | if (data == null) { | ||
50 | return null; | ||
51 | } | ||
52 | try { | ||
53 | SecretKeySpec key = new SecretKeySpec(encodeKey(password), CIPHER_ALGORITHM); | ||
54 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); | ||
55 | cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(new byte[16])); | ||
56 | return new String(cipher.doFinal(Base64.getDecoder().decode(data.getBytes(CHARSET))), CHARSET); | ||
57 | } catch (Exception e) { | ||
58 | log.error("", e); | ||
59 | return data; | ||
60 | } | ||
61 | } | ||
62 | /** | ||
63 | * 根据传入的字符串,返回Base64编码的MD5值 | ||
64 | * | ||
65 | * @param str | ||
66 | * @return | ||
67 | */ | ||
68 | public static String getMD5(String str) { | ||
69 | MessageDigest messageDigest = null; | ||
70 | try { | ||
71 | messageDigest = MessageDigest.getInstance("MD5"); | ||
72 | messageDigest.reset(); | ||
73 | messageDigest.update(str.getBytes(CHARSET)); | ||
74 | byte[] byteArray = messageDigest.digest(); | ||
75 | return Base64.getEncoder().encodeToString(byteArray); | ||
76 | } catch (NoSuchAlgorithmException e) { | ||
77 | log.error("", e); | ||
78 | } catch (UnsupportedEncodingException e) { | ||
79 | log.error("", e); | ||
80 | } return ""; | ||
81 | } | ||
82 | |||
83 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.skua.modules.weather.controller; | ||
2 | |||
3 | import com.skua.core.api.vo.Result; | ||
4 | import com.skua.core.aspect.annotation.AutoLog; | ||
5 | import com.skua.modules.weather.entity.ResultWeather; | ||
6 | import com.skua.modules.weather.service.IWeatherService; | ||
7 | import io.swagger.annotations.Api; | ||
8 | import io.swagger.annotations.ApiOperation; | ||
9 | import lombok.extern.slf4j.Slf4j; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | ||
11 | import org.springframework.web.bind.annotation.GetMapping; | ||
12 | import org.springframework.web.bind.annotation.RequestMapping; | ||
13 | import org.springframework.web.bind.annotation.RestController; | ||
14 | |||
15 | import java.util.HashMap; | ||
16 | import java.util.Map; | ||
17 | |||
18 | @Slf4j | ||
19 | @Api(tags = "获取实时天气") | ||
20 | @RestController | ||
21 | @RequestMapping("/v1/weather") | ||
22 | public class WeatherController { | ||
23 | |||
24 | @Autowired | ||
25 | private IWeatherService weatherService; | ||
26 | |||
27 | @AutoLog(value = "获取实时天气") | ||
28 | @ApiOperation(value="获取实时天气", notes="获取实时天气") | ||
29 | @GetMapping(value = "/getWeather") | ||
30 | public Result<Map<String,Object>> getWeather(String location) { | ||
31 | Result<Map<String, Object>> result = new Result<>(); | ||
32 | Map<String, Object> map = new HashMap<>(); | ||
33 | ResultWeather resultWeather = new ResultWeather(); | ||
34 | resultWeather = weatherService.getNowWeatherData(location); | ||
35 | map.put("weatherData", "气温:"+resultWeather.getTemp()+"℃;" + | ||
36 | "风向/风力:"+resultWeather.getWindDir()+" "+resultWeather.getWindScale()+";" + | ||
37 | "湿度:"+resultWeather.getHumidity()+";" + | ||
38 | "空气质量:"+resultWeather.getCategory()+";" + | ||
39 | "天气:"+resultWeather.getText()); | ||
40 | result.setSuccess(true); | ||
41 | result.setResult(map); | ||
42 | return result; | ||
43 | } | ||
44 | |||
45 | @AutoLog(value = "获取实时天气") | ||
46 | @ApiOperation(value="获取实时天气", notes="获取实时天气") | ||
47 | @GetMapping(value = "/getNowWeather") | ||
48 | public Result<Map<String,Object>> getNowWeather(String location) { | ||
49 | Result<Map<String, Object>> result = new Result<>(); | ||
50 | Map<String, Object> map = new HashMap<>(); | ||
51 | ResultWeather resultWeather = new ResultWeather(); | ||
52 | resultWeather = weatherService.getNowWeatherData(location); | ||
53 | map.put("weatherData",resultWeather); | ||
54 | result.setSuccess(true); | ||
55 | result.setResult(map); | ||
56 | return result; | ||
57 | } | ||
58 | |||
59 | } |
1 | package com.skua.modules.weather.entity; | ||
2 | |||
3 | import lombok.Data; | ||
4 | |||
5 | import java.util.Date; | ||
6 | |||
7 | /** | ||
8 | * 实况空气质量 | ||
9 | */ | ||
10 | @Data | ||
11 | public class AirNow { | ||
12 | |||
13 | /**实况观测时间*/ | ||
14 | private Date pubTime; | ||
15 | /**实时空气质量指数*/ | ||
16 | private String aqi; | ||
17 | /**实时空气质量指数等级*/ | ||
18 | private String level; | ||
19 | /**实时空气质量指数级别 */ | ||
20 | private String category; | ||
21 | /**实时空气质量的主要污染物*/ | ||
22 | private String primary; | ||
23 | /**实时 pm10*/ | ||
24 | private String pm10; | ||
25 | /**实时 pm2.5*/ | ||
26 | private String pm2p5; | ||
27 | /** 实时 二氧化氮*/ | ||
28 | private String no2; | ||
29 | /** 实时 二氧化硫*/ | ||
30 | private String so2; | ||
31 | /** 实时 一氧化碳*/ | ||
32 | private String co; | ||
33 | /**实时 臭氧*/ | ||
34 | private String o3; | ||
35 | } |
1 | package com.skua.modules.weather.entity; | ||
2 | |||
3 | import lombok.Data; | ||
4 | |||
5 | import java.util.Date; | ||
6 | |||
7 | /** | ||
8 | * 实况天气及空气质量 | ||
9 | */ | ||
10 | @Data | ||
11 | public class ResultWeather { | ||
12 | |||
13 | /**实况观测时间*/ | ||
14 | private Date obsTime; | ||
15 | /**实况温度,默认单位:摄氏度*/ | ||
16 | private String temp; | ||
17 | /**天气图标*/ | ||
18 | private String icon; | ||
19 | /**实况天气状况的文字描述*/ | ||
20 | private String text; | ||
21 | /**实况风向*/ | ||
22 | private String windDir; | ||
23 | /**实况风力等级*/ | ||
24 | private String windScale; | ||
25 | /**实况相对湿度,百分比数值*/ | ||
26 | private String humidity; | ||
27 | /**实时空气质量指数级别 */ | ||
28 | private String category; | ||
29 | |||
30 | } |
1 | package com.skua.modules.weather.entity; | ||
2 | |||
3 | import lombok.Data; | ||
4 | |||
5 | import java.util.Date; | ||
6 | |||
7 | /** | ||
8 | * 实况天气 | ||
9 | */ | ||
10 | @Data | ||
11 | public class WeatherNow { | ||
12 | |||
13 | /**实况观测时间*/ | ||
14 | private Date obsTime; | ||
15 | /**实况温度,默认单位:摄氏度*/ | ||
16 | private String temp; | ||
17 | /**实况体感温度,默认单位:摄氏度*/ | ||
18 | private String feelsLike; | ||
19 | /**当前天气状况和图标的代码,图标可通过天气状况和图标下载 */ | ||
20 | private String icon; | ||
21 | /**实况天气状况的文字描述,包括阴晴雨雪等天气状态的描述*/ | ||
22 | private String text; | ||
23 | /**实况风向360角度*/ | ||
24 | private String wind360; | ||
25 | /**实况风向*/ | ||
26 | private String windDir; | ||
27 | /**实况风力等级*/ | ||
28 | private String windScale; | ||
29 | /**实况风速,公里/小时*/ | ||
30 | private String windSpeed; | ||
31 | /**实况相对湿度,百分比数值*/ | ||
32 | private String humidity; | ||
33 | /**实况降水量,默认单位:毫米*/ | ||
34 | private String precip; | ||
35 | /**降水级别*/ | ||
36 | private String waterLevel; | ||
37 | /**实况大气压强,默认单位:百帕*/ | ||
38 | private String pressure; | ||
39 | /**实况能见度,默认单位:公里*/ | ||
40 | private String vis; | ||
41 | /**实况云量,百分比数值*/ | ||
42 | private String cloud; | ||
43 | /**实况露点温度*/ | ||
44 | private String dew; | ||
45 | } |
1 | package com.skua.modules.weather.service.impl; | ||
2 | |||
3 | import com.alibaba.fastjson.JSONObject; | ||
4 | import com.skua.modules.weather.entity.AirNow; | ||
5 | import com.skua.modules.weather.entity.ResultWeather; | ||
6 | import com.skua.modules.weather.entity.WeatherNow; | ||
7 | import com.skua.modules.weather.service.IWeatherService; | ||
8 | import org.apache.http.HttpEntity; | ||
9 | import org.apache.http.client.config.RequestConfig; | ||
10 | import org.apache.http.client.methods.CloseableHttpResponse; | ||
11 | import org.apache.http.client.methods.HttpGet; | ||
12 | import org.apache.http.impl.client.CloseableHttpClient; | ||
13 | import org.apache.http.impl.client.HttpClientBuilder; | ||
14 | import org.apache.http.util.EntityUtils; | ||
15 | import org.springframework.stereotype.Service; | ||
16 | |||
17 | import java.net.URLEncoder; | ||
18 | import java.text.SimpleDateFormat; | ||
19 | import java.util.Date; | ||
20 | |||
21 | /** | ||
22 | * 实时天气 | ||
23 | */ | ||
24 | @Service | ||
25 | public class WeatherServiceImpl implements IWeatherService { | ||
26 | |||
27 | private static String WeatherUrl = "https://devapi.qweather.com/v7/weather/now?"; | ||
28 | private static String AirUrl = "https://devapi.qweather.com/v7/air/now?"; | ||
29 | private static String KEY = "b480cc7cdc974e76bceb9b0bd06b64f1"; | ||
30 | private static String ICON = "https://a.hecdn.net/img/common/icon/202101/"; | ||
31 | private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmXXX"); | ||
32 | |||
33 | @Override | ||
34 | public ResultWeather getNowWeatherData(String location) { | ||
35 | ResultWeather resultWeather = new ResultWeather(); | ||
36 | String weatherResult = getDataByUrl(WeatherUrl,location); | ||
37 | String resultAir = getDataByUrl(AirUrl,location); | ||
38 | try{ | ||
39 | if (weatherResult != null) { | ||
40 | JSONObject jsonObject = JSONObject.parseObject(weatherResult); | ||
41 | JSONObject jsonWeater = JSONObject.parseObject(jsonObject.get("now").toString()); | ||
42 | String obsTime = jsonWeater.get("obsTime").toString(); | ||
43 | Date obsTimeDate = simpleDateFormat.parse(obsTime); | ||
44 | jsonWeater.put("obsTime", obsTimeDate); | ||
45 | WeatherNow weatherNow = JSONObject.toJavaObject(jsonWeater, WeatherNow.class); | ||
46 | resultWeather.setHumidity(weatherNow.getHumidity()+"%");//湿度 | ||
47 | resultWeather.setWindDir(weatherNow.getWindDir());//风向 | ||
48 | resultWeather.setWindScale(weatherNow.getWindScale()+"级");//风力 | ||
49 | resultWeather.setTemp(weatherNow.getTemp());//温度 | ||
50 | resultWeather.setText(weatherNow.getText());//天气 | ||
51 | resultWeather.setIcon(ICON + weatherNow.getIcon()+".png"); | ||
52 | resultWeather.setObsTime(weatherNow.getObsTime()); | ||
53 | } | ||
54 | if (resultAir != null) { | ||
55 | JSONObject jsonObject = JSONObject.parseObject(resultAir); | ||
56 | JSONObject jsonAir = JSONObject.parseObject(jsonObject.get("now").toString()); | ||
57 | String pubTime = jsonAir.get("pubTime").toString(); | ||
58 | Date pubTimeDate = simpleDateFormat.parse(pubTime); | ||
59 | jsonAir.put("pubTime", pubTimeDate); | ||
60 | AirNow airNow = JSONObject.toJavaObject(jsonAir, AirNow.class); | ||
61 | resultWeather.setCategory(airNow.getCategory()); | ||
62 | } | ||
63 | }catch(Exception e){ | ||
64 | e.printStackTrace(); | ||
65 | } | ||
66 | return resultWeather; | ||
67 | } | ||
68 | |||
69 | private static String getDataByUrl(String url,String location) { | ||
70 | String result = null; | ||
71 | StringBuffer params = new StringBuffer(); | ||
72 | // 获得Http客户端(可以理解为:你得先有一个浏览器;注意:实际上HttpClient与浏览器是不一样的) | ||
73 | CloseableHttpClient httpClient = HttpClientBuilder.create().build(); | ||
74 | try { | ||
75 | // 字符数据最好encoding以下;这样一来,某些特殊字符才能传过去(如:某人的名字就是“&”,不encoding的话,传不过去) | ||
76 | params.append("location=" + URLEncoder.encode(location, "utf-8")); | ||
77 | params.append("&"); | ||
78 | params.append("key=" + KEY); | ||
79 | // 创建Get请求 | ||
80 | HttpGet httpGet = new HttpGet(url + params); | ||
81 | // 响应模型 | ||
82 | CloseableHttpResponse response = null; | ||
83 | // 配置信息 | ||
84 | RequestConfig requestConfig = RequestConfig.custom() | ||
85 | // 设置连接超时时间(单位毫秒) | ||
86 | .setConnectTimeout(5000) | ||
87 | // 设置请求超时时间(单位毫秒) | ||
88 | .setConnectionRequestTimeout(5000) | ||
89 | // socket读写超时时间(单位毫秒) | ||
90 | .setSocketTimeout(5000) | ||
91 | // 设置是否允许重定向(默认为true) | ||
92 | .setRedirectsEnabled(true).build(); | ||
93 | // 将上面的配置信息 运用到这个Get请求里 | ||
94 | httpGet.setConfig(requestConfig); | ||
95 | // 由客户端执行(发送)Get请求 | ||
96 | response = httpClient.execute(httpGet); | ||
97 | // 从响应模型中获取响应实体 | ||
98 | HttpEntity responseEntity = response.getEntity(); | ||
99 | if (responseEntity != null) { | ||
100 | result = EntityUtils.toString(responseEntity); | ||
101 | } | ||
102 | } catch (Exception e) { | ||
103 | e.printStackTrace(); | ||
104 | } | ||
105 | return result; | ||
106 | } | ||
107 | |||
108 | } |
... | @@ -90,6 +90,8 @@ public class ShiroConfig { | ... | @@ -90,6 +90,8 @@ public class ShiroConfig { |
90 | filterChainDefinitionMap.put("/sys/sysGeneralProcess/**", "anon"); | 90 | filterChainDefinitionMap.put("/sys/sysGeneralProcess/**", "anon"); |
91 | filterChainDefinitionMap.put("/sys/sysExcelParse/**", "anon"); | 91 | filterChainDefinitionMap.put("/sys/sysExcelParse/**", "anon"); |
92 | filterChainDefinitionMap.put("/v1/customAnalysis/**", "anon"); | 92 | filterChainDefinitionMap.put("/v1/customAnalysis/**", "anon"); |
93 | //天气接口 | ||
94 | filterChainDefinitionMap.put("/v1/weather/**", "anon"); | ||
93 | 95 | ||
94 | filterChainDefinitionMap.put("/v1/product/waterQualityMonitoring/testPush", "anon"); | 96 | filterChainDefinitionMap.put("/v1/product/waterQualityMonitoring/testPush", "anon"); |
95 | filterChainDefinitionMap.put("/v1/secretary/smallSecretarySenderConf/sendMsgTest", "anon"); | 97 | filterChainDefinitionMap.put("/v1/secretary/smallSecretarySenderConf/sendMsgTest", "anon"); | ... | ... |
1 | server: | ||
2 | port: 8803 | ||
3 | servlet: | ||
4 | context-path: /fmboot | ||
5 | compression: | ||
6 | enabled: true | ||
7 | mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/* | ||
8 | |||
9 | management: | ||
10 | endpoints: | ||
11 | web: | ||
12 | exposure: | ||
13 | include: metrics,httptrace | ||
14 | |||
15 | spring: | ||
16 | servlet: | ||
17 | multipart: | ||
18 | max-file-size: 10MB | ||
19 | max-request-size: 10MB | ||
20 | mail: | ||
21 | host: smtp.163.com | ||
22 | username: zhanglei891008@163.com | ||
23 | password: ?? | ||
24 | properties: | ||
25 | mail: | ||
26 | smtp: | ||
27 | auth: true | ||
28 | starttls: | ||
29 | enable: true | ||
30 | required: true | ||
31 | ## quartz定时任务,采用数据库方式 | ||
32 | quartz: | ||
33 | job-store-type: jdbc | ||
34 | #json 时间戳统一转换 | ||
35 | jackson: | ||
36 | date-format: yyyy-MM-dd HH:mm:ss | ||
37 | time-zone: GMT+8 | ||
38 | aop: | ||
39 | proxy-target-class: true | ||
40 | #配置freemarker | ||
41 | freemarker: | ||
42 | # 设置模板后缀名 | ||
43 | suffix: .ftl | ||
44 | # 设置文档类型 | ||
45 | content-type: text/html | ||
46 | # 设置页面编码格式 | ||
47 | charset: UTF-8 | ||
48 | # 设置页面缓存 | ||
49 | cache: false | ||
50 | prefer-file-system-access: false | ||
51 | # 设置ftl文件路径 | ||
52 | template-loader-path: | ||
53 | - classpath:/templates | ||
54 | # 设置静态文件路径,js,css等 | ||
55 | mvc: | ||
56 | static-path-pattern: /** | ||
57 | resource: | ||
58 | static-locations: classpath:/static/,classpath:/public/ | ||
59 | autoconfigure: | ||
60 | exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure | ||
61 | datasource: | ||
62 | druid: | ||
63 | stat-view-servlet: | ||
64 | enabled: true | ||
65 | loginUsername: admin | ||
66 | loginPassword: 123456 | ||
67 | web-stat-filter: | ||
68 | enabled: true | ||
69 | dynamic: | ||
70 | druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置) | ||
71 | # 连接池的配置信息 | ||
72 | # 初始化大小,最小,最大 | ||
73 | initial-size: 5 | ||
74 | min-idle: 5 | ||
75 | maxActive: 20 | ||
76 | # 配置获取连接等待超时的时间 | ||
77 | maxWait: 60000 | ||
78 | # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 | ||
79 | timeBetweenEvictionRunsMillis: 60000 | ||
80 | # 配置一个连接在池中最小生存的时间,单位是毫秒 | ||
81 | minEvictableIdleTimeMillis: 300000 | ||
82 | validationQuery: SELECT 1 | ||
83 | testWhileIdle: true | ||
84 | testOnBorrow: false | ||
85 | testOnReturn: false | ||
86 | # 打开PSCache,并且指定每个连接上PSCache的大小 | ||
87 | poolPreparedStatements: true | ||
88 | maxPoolPreparedStatementPerConnectionSize: 20 | ||
89 | # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 | ||
90 | filters: stat,wall,slf4j | ||
91 | # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 | ||
92 | connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 | ||
93 | datasource: | ||
94 | master: | ||
95 | url: jdbc:mysql://192.168.21.6:13306/zhsw_modules?characterEncoding=UTF-8&useUnicode=true&useSSL=false | ||
96 | username: root | ||
97 | password: jkauto@123wh | ||
98 | driver-class-name: com.mysql.jdbc.Driver | ||
99 | # 多数据源配置 | ||
100 | pg-db: | ||
101 | url: jdbc:mysql://192.168.21.6:13306/zhsw_modules?characterEncoding=UTF-8&useUnicode=true&useSSL=false | ||
102 | username: root | ||
103 | password: jkauto@123wh | ||
104 | driver-class-name: org.postgresql.Driver | ||
105 | #redis 配置 | ||
106 | redis: | ||
107 | database: 0 | ||
108 | host: 127.0.0.1 | ||
109 | lettuce: | ||
110 | pool: | ||
111 | max-active: 8 #最大连接数据库连接数,设 0 为没有限制 | ||
112 | max-idle: 8 #最大等待连接中的数量,设 0 为没有限制 | ||
113 | max-wait: -1ms #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。 | ||
114 | min-idle: 0 #最小等待连接中的数量,设 0 为没有限制 | ||
115 | shutdown-timeout: 100ms | ||
116 | password: '' | ||
117 | port: 6379 | ||
118 | #mybatis plus 设置 | ||
119 | mybatis-plus: | ||
120 | #mapper-locations: classpath*:com/skua/modules/**/xml/*Mapper.xml | ||
121 | mapper-locations: classpath*:com/skua/**/xml/*Mapper.xml | ||
122 | global-config: | ||
123 | db-config: | ||
124 | #主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID", | ||
125 | #3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID", | ||
126 | #5:"字符串全局唯一ID (idWorker 的字符串表示)"; | ||
127 | id-type: 4 | ||
128 | # 默认数据库表下划线命名 | ||
129 | table-underline: true | ||
130 | configuration: | ||
131 | call-setters-on-nulls: true | ||
132 | # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 | ||
133 | #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | ||
134 | #数矿专用配置 | ||
135 | skua : | ||
136 | path : | ||
137 | #文件上传根目录 设置 | ||
138 | upload: /mnt/app/uploadfile | ||
139 | #webapp文件路径 | ||
140 | webapp: /mnt/app/uploadfile | ||
141 | # 断点续传路径 | ||
142 | chunk: /app/skboot/zujianhua/voice | ||
143 | #短信秘钥 | ||
144 | sms: | ||
145 | #应用地址 | ||
146 | accessKeyUrl: http://smssh1.253.com/msg/send/json | ||
147 | #账户 | ||
148 | accessKeyId: N8464035 | ||
149 | #密码 | ||
150 | accessKeySecret: H9eu8oABz | ||
151 | factoryId: d60401ac4a9943b1943c6b8edbe4df27 | ||
152 | iosUpdateUrl: https://itunes.apple.com/cn/lookup?id=1486744187 | ||
153 | viewPath: http://189.200.0.109:8081/fmboot/sys/common/view/ | ||
154 | #展示运行报表id | ||
155 | reportShowParentId: 6958c2d7f6d391a86b2c58059dbcddc3 | ||
156 | #数据采集服务频率,单位秒,注意如果调整了数据采集频率,请记得同步修改此配置 | ||
157 | collectionFrequency: 10 | ||
158 | #视频对接相关配置 | ||
159 | video: | ||
160 | ip: 120.25.102.53 | ||
161 | port: 8667 | ||
162 | username: admin | ||
163 | password: xrjkauto@123 | ||
164 | #海康威视需要填写密钥 | ||
165 | appkey: 22650577 | ||
166 | secretkey: yKovn09uAsl2NTfebzqA | ||
167 | streamMediaIp: 120.25.102.53 | ||
168 | #消息推送 | ||
169 | push: | ||
170 | #是否开启流程消息推送 | ||
171 | process-enable: false | ||
172 | #极光推送 | ||
173 | jg: | ||
174 | masterSecret: bb892f7772238f3279e1ae6a | ||
175 | appKey: cb69e9fb44ed811b487ec3b5 | ||
176 | #洪城内网推送地址 | ||
177 | deviceHostName: http://189.200.0.223/device | ||
178 | pushHostName: http://189.200.0.223/api | ||
179 | mob: | ||
180 | appSecret: 1dc50510bb62e65add34dab122f4536f | ||
181 | appKey: 347052887a080 | ||
182 | pushHostName: http://api.push.mob.com/v3/push/createPush | ||
183 | iosProduction: 1 | ||
184 | packageName: com.kingtrol.flutter_xingrong | ||
185 | #后面更换推送服务向下扩展添加 | ||
186 | #cas单点登录 | ||
187 | cas: | ||
188 | prefixUrl: http://cas.example.org:8443/cas |
-
请 注册 或 登录 后发表评论