|
@@ -1,5 +1,8 @@
|
|
|
package com.welampiot.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.dto.*;
|
|
@@ -58,6 +61,14 @@ public class BasePlatformController {
|
|
|
private ProgramService programService;
|
|
|
@Autowired
|
|
|
private WifiService wifiService;
|
|
|
+ @Autowired
|
|
|
+ private ChargeService chargeService;
|
|
|
+ @Autowired
|
|
|
+ private BroadcastService broadcastService;
|
|
|
+ @Autowired
|
|
|
+ private BroadcastProListService broadcastProListService;
|
|
|
+ @Autowired
|
|
|
+ private BroadcastItemService broadcastItemService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -271,7 +282,7 @@ public class BasePlatformController {
|
|
|
}else {
|
|
|
lampPoleDetailVO.setBroadcastPro("Нет программы");
|
|
|
}
|
|
|
-
|
|
|
+ lampPoleDetailVO.setIsPlay(0);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDetailVO);
|
|
|
}
|
|
|
for (LampInfoDTO dto:lampJoinLogList) {
|
|
@@ -421,142 +432,127 @@ public class BasePlatformController {
|
|
|
LampPoleDTO localDataById = lampPoleService.getLocalDataById(id);
|
|
|
String urlStr = "https://devapi.heweather.net/v7/weather/3d?location="+localDataById.getLongitude()+","+localDataById.getLatitude()+"&key="+ToolUtils.WEATHER_KEY;
|
|
|
|
|
|
- String info = toolUtils.sendHttp("get", urlStr, null, 5, ToolUtils.ContentTypeEnum.CONTENT_TYPE_FORM, null);
|
|
|
-
|
|
|
+ //String info = toolUtils.sendHttp("get", urlStr, null, 5, ToolUtils.ContentTypeEnum.CONTENT_TYPE_FORM, null);
|
|
|
+ String zlibNetwork = toolUtils.zlibNetwork(urlStr);
|
|
|
+ WeatherDTO weather = new WeatherDTO();
|
|
|
+ if (!zlibNetwork.isEmpty()){
|
|
|
+ JSONObject jsonObject = JSON.parseObject(zlibNetwork);
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
+ if (code.equals("200")){
|
|
|
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("daily");
|
|
|
+ JSONObject o = (JSONObject)jsonArray.get(0);
|
|
|
+ weather.setTempMax(o.getString("tempMax"));
|
|
|
+ weather.setTempMin(o.getString("tempMin"));
|
|
|
|
|
|
- // $weather_info = file_get_contents("compress.zlib://".$url);
|
|
|
-// $weather_info = json_decode($weather_info,true);
|
|
|
+ String weatherUrl = "https://devapi.heweather.net/v7/weather/now?location="+localDataById.getLongitude()+","+localDataById.getLatitude()+"&key="+ToolUtils.WEATHER_KEY;
|
|
|
+ String weatherResult = toolUtils.zlibNetwork(weatherUrl);
|
|
|
+ if (!weatherResult.isEmpty()){
|
|
|
+ JSONObject weatherJsonObject = JSON.parseObject(weatherResult);
|
|
|
+ if (weatherJsonObject.get("now") != null){
|
|
|
+ String weatherCode = weatherJsonObject.getString("code");
|
|
|
+ if (weatherCode.equals("200")){
|
|
|
+ JSONObject w = (JSONObject)weatherJsonObject.get("now");
|
|
|
+ weather.setTemp(w.getString("temp"));
|
|
|
+ if (version == 0){
|
|
|
+ weather.setWeatherText(w.getString("text"));
|
|
|
+ } else if (version == 1) {
|
|
|
+ weather.setWeatherText(toolUtils.weatherTranslateEn(w.getString("icon")));
|
|
|
+ }else {
|
|
|
+ weather.setWeatherText(toolUtils.weatherTranslateRu(w.getString("icon")));
|
|
|
+ }
|
|
|
+ weather.setWeatherCode(w.getString("icon"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String airUrl = "https://devapi.heweather.net/v7/air/now?location="+localDataById.getLongitude()+","+localDataById.getLatitude()+"&key="+ToolUtils.WEATHER_KEY;
|
|
|
+ String airResult = toolUtils.zlibNetwork(airUrl);
|
|
|
+ if (!airResult.isEmpty()){
|
|
|
+ JSONObject airJsonObject = JSONObject.parseObject(airResult);
|
|
|
+ String airCode = airJsonObject.getString("code");
|
|
|
+ if (airCode.equals("200")){
|
|
|
+ JSONObject air = (JSONObject)airJsonObject.get("now");
|
|
|
+ if (air != null){
|
|
|
+ weather.setAqi(air.getString("aqi"));
|
|
|
+ weather.setCategory(air.getString("level"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lampPoleDetailVO.setWeatherInfo(weather);
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setWeatherInfo(new WeatherDTO());
|
|
|
+ }
|
|
|
|
|
|
+ //充电桩
|
|
|
+ ChargeDTO infoByLampPoleId = chargeService.getChargeInfoByLampPoleId(id);
|
|
|
+ if (infoByLampPoleId != null){
|
|
|
+ ChargeDTO chargeDTO = new ChargeDTO();
|
|
|
+ chargeDTO.setStatus(infoByLampPoleId.getStatus());
|
|
|
+ chargeDTO.setOnline(infoByLampPoleId.getOnline());
|
|
|
+ chargeDTO.setEquipmentElectricity(infoByLampPoleId.getEquipmentElectricity());
|
|
|
+ chargeDTO.setBillAmt(infoByLampPoleId.getBillAmt());
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setCharge(new ChargeDTO());
|
|
|
+ }
|
|
|
|
|
|
-// if (!empty($res)) {
|
|
|
-// $enddate = date('Y-m-d H:00:00',time()-8*3600);
|
|
|
-// $startdate = date('Y-m-d H:00:00',time()-8*3600-7*24*3600);
|
|
|
-// $data['day_flow'] = $res['day_flow'];
|
|
|
-// $temp_list = [];
|
|
|
-// for ($i=0; $i < 7; $i++) {
|
|
|
-// $in = date('Y-m-d',time()-$i*24*3600);
|
|
|
-// $temp_list[$in] = ['max'=>0,'min'=>0];
|
|
|
-// }
|
|
|
-// $flow_list = $this->db->query('select total_com,updatetime from wifi_info_log where id = '.$res['id'].' and updatetime >= "'.$startdate.'" and updatetime <= "'.$enddate.'" order by updatetime desc')->result_array();
|
|
|
-// foreach ($flow_list as $key => $value) {
|
|
|
-// $in = date('Y-m-d',strtotime($value['updatetime'])+8*3600);
|
|
|
-// if (isset($temp_list[$in])) {
|
|
|
-// $temp_list[$in]['min'] = $value['total_com'];
|
|
|
-// if ($temp_list[$in]['max'] == 0) {
|
|
|
-// $temp_list[$in]['max'] = $value['total_com'];
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// $temp_list = array_reverse($temp_list);
|
|
|
-// foreach ($temp_list as $key => $value) {
|
|
|
-// $data['flow_list']['date'][] = date('m-d',strtotime($key));
|
|
|
-// $data['flow_list']['flow'][] = $value['max'] > $value['min'] ? $value['max'] - $value['min'] : 0;
|
|
|
-// }
|
|
|
-// }
|
|
|
+ // 故障信息
|
|
|
+ String[] alamDevArr = {"路灯","摄像头","云盒","RFID","LED屏","一键报警","充电桩","气象站","微基站","广播音柱"};
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ List<LampPoleDTO> lampPoleAlarmInfoList = lampPoleService.getLampPoleAlarmInfoList(lampPoleVO);
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (LampPoleDTO dto:lampPoleAlarmInfoList) {
|
|
|
+ if (dto.getDType() != null){
|
|
|
+ dto.setContent(alamDevArr[dto.getDType()]+dto.getContent());
|
|
|
+ dto.setAlarmTypeStr(dto.getContent());
|
|
|
+ }
|
|
|
+ Date cmdTime = null;
|
|
|
+ try {
|
|
|
+ cmdTime = simpleDateFormat.parse(dto.getUpdateTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ long timeStamp = cmdTime.getTime() + dto.getTimezone() * 3600 * 1000;
|
|
|
+ String newUpdateTime = simpleDateFormat.format(new Date(timeStamp));
|
|
|
+ dto.setUpdateTime(newUpdateTime);
|
|
|
+ dto.setTimezone(null);
|
|
|
+ dto.setDType(null);
|
|
|
+ dto.setContent(null);
|
|
|
+ }
|
|
|
+ if (lampPoleAlarmInfoList != null && lampPoleAlarmInfoList.size() != 0){
|
|
|
+ lampPoleDetailVO.setAlarmList(lampPoleAlarmInfoList);
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setAlarmList(new ArrayList<>());
|
|
|
+ }
|
|
|
|
|
|
- // 故障列表
|
|
|
-// List<LampPoleDTO> alarmList = lampPoleService.getLampPoleAlarmListByLampPoleId(id);
|
|
|
-// // 灯控列表
|
|
|
-// List<LampPoleDTO> lampList = lampPoleService.getLampListByLampPoleId(id);
|
|
|
-// // 灯杆详情
|
|
|
-// LampPoleDTO dto = lampPoleService.getNewLampPoleDetailsById(id);
|
|
|
-// if (dto == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
-//
|
|
|
-//// LampPoleDetailVO lampPoleDetailVO = new LampPoleDetailVO();
|
|
|
-// // 气象信息
|
|
|
-// String longitude = dto.getLongitude();
|
|
|
-// String latitude = dto.getLatitude();
|
|
|
-// WeatherDTO weatherInfo = WeatherUtil.getNowWeatherInfo(longitude, latitude);
|
|
|
-// lampPoleDetailVO.setWeatherInfo(weatherInfo);
|
|
|
-// // 音柱当前播放的节目
|
|
|
-// lampPoleDetailVO.setBroadcastPro(dto.getBroadcastPro());
|
|
|
-// // 音柱当前播放节目的id
|
|
|
-// lampPoleDetailVO.setProgramId(dto.getProgramId());
|
|
|
-// // 音柱id
|
|
|
-// lampPoleDetailVO.setBroadcastId(dto.getBroadcastId());
|
|
|
-// // 当天流量
|
|
|
-// lampPoleDetailVO.setDayFlow(dto.getDayFlow());
|
|
|
-// // 故障列表
|
|
|
-// lampPoleDetailVO.setAlarmList(alarmList);
|
|
|
-// // 灯控列表
|
|
|
-// lampPoleDetailVO.setLampList(lampList);
|
|
|
-// // 摄像头
|
|
|
-// VideoMonitorDTO videoMonitorDTO = new VideoMonitorDTO();
|
|
|
-// videoMonitorDTO.setId(dto.getVideoId());
|
|
|
-// videoMonitorDTO.setVideoAddress(dto.getVideoAddress());
|
|
|
-// lampPoleDetailVO.setVideo(videoMonitorDTO);
|
|
|
-// // 屏幕
|
|
|
-// ScreenDTO screenDTO = new ScreenDTO();
|
|
|
-// screenDTO.setId(dto.getScreenId());
|
|
|
-// screenDTO.setName(dto.getProgramName());
|
|
|
-// screenDTO.setStatus(dto.getScreenStatus());
|
|
|
-// screenDTO.setLight(dto.getLight());
|
|
|
-// screenDTO.setVolume(dto.getVolume());
|
|
|
-// screenDTO.setMaxLight(dto.getMaxLight());
|
|
|
-// screenDTO.setPlayingId(dto.getPlayingId());
|
|
|
-// screenDTO.setScreenImage(dto.getImage());
|
|
|
-// lampPoleDetailVO.setScreen(screenDTO);
|
|
|
-// // 充电桩
|
|
|
-// ChargeDTO chargeDTO = new ChargeDTO();
|
|
|
-// chargeDTO.setOnline(dto.getChargeOnline());
|
|
|
-// chargeDTO.setStatus(dto.getChargeStatus());
|
|
|
-// chargeDTO.setEquipmentElectricity(dto.getEquipmentElectricity());
|
|
|
-// if (dto.getBillAmt() != null) {
|
|
|
-// chargeDTO.setBillAmt(Float.parseFloat(dto.getBillAmt()));
|
|
|
-// }
|
|
|
-// lampPoleDetailVO.setCharge(chargeDTO);
|
|
|
-// // 流量列表
|
|
|
-// List<Object> dateList = new ArrayList<>();
|
|
|
-// List<Object> flowList = new ArrayList<>();
|
|
|
-// long l = System.currentTimeMillis();
|
|
|
-// long startTime = l - 24 * 3600 * 1000 * 6;
|
|
|
-// HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
|
|
|
-// long timeT = startTime;
|
|
|
-// int i = 0;
|
|
|
-//
|
|
|
-// DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
-// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
|
|
|
-// SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
-// while (timeT <= l) {
|
|
|
-// objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)), i);
|
|
|
-// dateList.add(simpleDateFormat.format(new Date(timeT)));
|
|
|
-// flowList.add(0);
|
|
|
-// timeT += 3600 * 1000;
|
|
|
-// i++;
|
|
|
-// }
|
|
|
-//
|
|
|
-// int dayNumber = 1;
|
|
|
-// WifiInfoLogDTO wifiInfoLogDTO = new WifiInfoLogDTO();
|
|
|
-// wifiInfoLogDTO.setDayNum(7);
|
|
|
-// wifiInfoLogDTO.setDayNumber(dayNumber);
|
|
|
-// wifiInfoLogDTO.setLampPoleId(id);
|
|
|
-// List<WifiInfoLogDTO> wifiInfoLogList = wifiInfoLogService.getWifiStatisticsListByDTO(wifiInfoLogDTO);
|
|
|
-// for (WifiInfoLogDTO dto1 : wifiInfoLogList) {
|
|
|
-// Date date = new Date(simpleDateFormat2.parse(dto1.getUpdateTime()).getTime());
|
|
|
-// String s = simpleDateFormat.format(date);
|
|
|
-// long time = simpleDateFormat.parse(s).getTime();
|
|
|
-// String formatStart = simpleDateFormat.format(startTime);
|
|
|
-// startTime = simpleDateFormat.parse(formatStart).getTime();
|
|
|
-// long timespan = (time - startTime) / (3600 * 1000 * dayNumber);
|
|
|
-// long newTime = startTime + timespan * (3600 * 1000 * dayNumber);
|
|
|
-// date = new Date(newTime);
|
|
|
-// s = simpleDateFormat.format(date);
|
|
|
-// Integer integer = null;
|
|
|
-// if (objectObjectHashMap.containsKey(s)) {
|
|
|
-// integer = objectObjectHashMap.get(s);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (dto1.getMinFlow() != null && !dto1.getMinFlow().equals("0") && integer != null &&
|
|
|
-// dto1.getMaxFlow() != null && !dto1.getMaxFlow().equals("0")) {
|
|
|
-// Float flow = Float.parseFloat(dto1.getMaxFlow()) - Float.parseFloat(dto1.getMinFlow());
|
|
|
-// flowList.set(integer,Float.parseFloat(decimalFormat.format(flow)));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// WifiInfoLogVO wifiInfoLogVO = new WifiInfoLogVO();
|
|
|
-// wifiInfoLogVO.setDate(dateList);
|
|
|
-// wifiInfoLogVO.setFlow(flowList);
|
|
|
-// lampPoleDetailVO.setFlowList(wifiInfoLogVO);
|
|
|
+ //广播
|
|
|
+ BroadcastDTO oneDataByLampPoleId = broadcastService.getOneDataByLampPoleId(id);
|
|
|
+ if (oneDataByLampPoleId != null){
|
|
|
+ //BroadcastDTO broadcastDTO = new BroadcastDTO();
|
|
|
+ lampPoleDetailVO.setIsPlay(oneDataByLampPoleId.getIsPlay());
|
|
|
+ lampPoleDetailVO.setBroadcastId(oneDataByLampPoleId.getId());
|
|
|
+ lampPoleDetailVO.setProgramId(oneDataByLampPoleId.getItemId());
|
|
|
+ if (oneDataByLampPoleId.getIsPlay() == 1){
|
|
|
+ if (oneDataByLampPoleId.getProId() != 0){
|
|
|
+ BroadcastProListDTO oneById = broadcastProListService.getOneById(oneDataByLampPoleId.getProId());
|
|
|
+ if (oneById != null){
|
|
|
+ lampPoleDetailVO.setBroadcastPro(oneById.getName());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (oneDataByLampPoleId.getItemId() !=0 ){
|
|
|
+ BroadcastItemDTO oneDataById = broadcastItemService.getOneDataById(oneDataByLampPoleId.getItemId());
|
|
|
+ if (oneDataById != null){
|
|
|
+ lampPoleDetailVO.setBroadcastPro(oneDataById.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setBroadcastPro("");
|
|
|
+ lampPoleDetailVO.setProgramId(0);
|
|
|
+ lampPoleDetailVO.setBroadcastId(0);
|
|
|
+ lampPoleDetailVO.setIsPlay(0);
|
|
|
+ }
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDetailVO);
|
|
|
}
|
|
|
}
|