| | |
| | | package com.moral.controller;
|
| | |
|
| | | import static com.moral.common.util.ResourceUtil.getValue;
|
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.InputStream;
|
| | | import java.io.InputStreamReader;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Collection;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Optional;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.apache.commons.net.ftp.FTPClient;
|
| | | import org.apache.log4j.Logger;
|
| | | import org.dom4j.Document;
|
| | | import org.dom4j.Element;
|
| | | import org.dom4j.io.SAXReader;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.cglib.beans.BeanMap;
|
| | | import org.springframework.data.redis.core.RedisTemplate;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.util.ObjectUtils;
|
| | | import org.springframework.web.bind.annotation.CrossOrigin;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.bind.annotation.ResponseBody;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import org.springframework.web.servlet.ModelAndView;
|
| | | import org.xml.sax.InputSource;
|
| | |
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONArray;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | |
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.common.util.WebUtils;
|
| | | import com.moral.common.xml.Version;
|
| | | import com.moral.entity.*;
|
| | | import com.moral.entity.Account;
|
| | | import com.moral.entity.AreaNames;
|
| | | import com.moral.entity.Device;
|
| | | import com.moral.entity.DeviceVersion;
|
| | | import com.moral.entity.MapBounds;
|
| | | import com.moral.entity.MonitorPoint;
|
| | | import com.moral.entity.Organization;
|
| | | import com.moral.entity.Region;
|
| | | import com.moral.entity.alarm.AlarmConfig;
|
| | | import com.moral.entity.alarm.AlarmConfigValue;
|
| | | import com.moral.entity.alarm.AlarmSensorLevel;
|
| | | import com.moral.entity.charts.DataSortCondition;
|
| | | import com.moral.entity.layout.RealTimeDeviceLayout;
|
| | | import com.moral.service.*;
|
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.AlarmConfigService;
|
| | | import com.moral.service.AlarmDailyService;
|
| | | import com.moral.service.AreaService;
|
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.DeviceVersionService;
|
| | | import com.moral.service.DictionaryDataService;
|
| | | import com.moral.service.HangzhouAqiService;
|
| | | import com.moral.service.HistoryDailyService;
|
| | | import com.moral.service.HistoryMinutelyService;
|
| | | import com.moral.service.HistoryService;
|
| | | import com.moral.service.MachineActivateService;
|
| | | import com.moral.service.MonitorPointService;
|
| | | import com.moral.service.OrganizationLayoutService;
|
| | | import com.moral.service.OrganizationService;
|
| | | import com.moral.service.QualityDailyService;
|
| | | import com.moral.service.SensorService;
|
| | | import com.moral.service.SensorUnitService;
|
| | | import com.moral.service.WeatherService;
|
| | |
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiImplicitParam;
|
| | | import io.swagger.annotations.ApiImplicitParams;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.apache.commons.net.ftp.FTPClient;
|
| | | import org.apache.log4j.Logger;
|
| | | import org.dom4j.Document;
|
| | | import org.dom4j.Element;
|
| | | import org.dom4j.io.SAXReader;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.cglib.beans.BeanMap;
|
| | | import org.springframework.data.redis.core.RedisTemplate;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.util.ObjectUtils;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | | import org.springframework.web.servlet.ModelAndView;
|
| | | import org.xml.sax.InputSource;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import java.io.BufferedReader;
|
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.InputStream;
|
| | | import java.io.InputStreamReader;
|
| | | import java.util.*;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import static com.moral.common.util.ResourceUtil.getValue;
|
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | /**
|
| | | * The Class ScreenController.大屏接口
|
| | |
| | | Long code = monitorPoint.getAreaCode().longValue();
|
| | | String regionName = areaService.queryFullNameByCode(code);
|
| | | Device device = deviceService.getDeviceByMac(mac, false);
|
| | | Device deviceSecond = deviceService.getDeviceByLongitudeAsc(mac);
|
| | | params.put("sensorInfo", resultMap);
|
| | | params.put("regionCode", code);
|
| | | params.put("regionName", regionName);
|
| | | params.put("monitorPoint", monitorPoint);
|
| | | params.put("device", device);
|
| | | params.put("deviceSecond",deviceSecond);
|
| | | String paramsJson = params.toJSONString();
|
| | | model.addObject("traceabilityParams", paramsJson);
|
| | | model.setViewName("traceability");
|
| | |
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "monitor_point_id", value = "监测站点id", required = true, paramType = "query", dataType = "String")
|
| | | })
|
| | | public ResultBean<Map<String, Object>> getSensorByMonitorPointId(HttpServletRequest request) throws Exception {
|
| | | public ResultBean<List<Map<String, Object>>> getSensorByMonitorPointId(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | String monitor_point_id = (String) parameters.get("monitor_point_id");
|
| | | System.out.println("ScreenController-----getSensorByMonitorPointId-----monitor_point_id:"+monitor_point_id);
|
| | | Map<String, Object> map = sensorUnitService.getSensorsByMonitPointId(monitor_point_id);
|
| | | System.out.println("ScreenController-----getSensorByMonitorPointId-----map:"+map);
|
| | | return new ResultBean<Map<String, Object>>(map);
|
| | | List<Map<String, Object>> map = sensorUnitService.getSensorsByMonitPointId2(monitor_point_id);
|
| | | return new ResultBean<List<Map<String, Object>>>(map);
|
| | | }
|
| | |
|
| | | @GetMapping("AIForecast")
|
| | |
| | | })
|
| | | public ResultBean<List<Map<String, Object>>> AIForecast (HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | ParameterUtils.getTimeType4Time(parameters);
|
| | | String monitor_point_id = (String) parameters.get("monitorPoint");
|
| | | parameters.put("monitorPointId", parameters.remove("monitorPoint"));
|
| | | Object sensorKey = parameters.remove("sensorKey");
|
| | | parameters.put("sensors", Arrays.asList(sensorKey));
|
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
|
| | | |
| | | //获取单位信息
|
| | | Map<String, Object> sensorMap = sensorUnitService.getSensorsByMonitPointId(monitor_point_id);
|
| | | |
| | | for (Map<String, Object> map : list) {
|
| | | String time = map.get("time").toString();
|
| | | time = time.substring(time.length() - 2);
|
| | | map.put("time", Integer.valueOf(time));
|
| | | map.put("value", map.remove(sensorKey));
|
| | | //System.out.println(parameters);
|
| | | String intoTime = parameters.get("time").toString();
|
| | | String[] timeArray = intoTime.split("-");
|
| | | //System.out.println(timeArray);
|
| | | Integer year = Integer.parseInt(timeArray[0]);
|
| | | Integer mon = Integer.parseInt(timeArray[1]);
|
| | | if(mon>1) {
|
| | | mon = mon-1;
|
| | | }else {
|
| | | mon = 12;
|
| | | year = year-1;
|
| | | }
|
| | | |
| | | return null;
|
| | | //return new ResultBean<List<Map<String, Object>>>(result);
|
| | | String alterTime = year.toString()+"-"+mon.toString()+"-"+timeArray[2];
|
| | | //System.out.println(alterTime);
|
| | | parameters.put("time", alterTime);
|
| | | ParameterUtils.getTimeType4Time(parameters);
|
| | | String monitor_point_id = (String) parameters.get("monitorPoint");
|
| | | parameters.put("monitorPointId", parameters.remove("monitorPoint"));
|
| | | String[] sensorKeys = parameters.remove("sensorKey").toString().split(",");
|
| | | parameters.put("sensors", Arrays.asList(sensorKeys));
|
| | | // monitorPointService.isCompensateCalculation(parameters);
|
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
|
| | | |
| | | //获取单位信息
|
| | | Map<String, Map<String, Object>> sensorUnitMap = sensorUnitService.getSensorsByMonitPointId(monitor_point_id);
|
| | |
|
| | | for (Map<String, Object> map : list) {
|
| | | String time = map.get("time").toString();
|
| | | time = time.substring(time.length() - 2);
|
| | | map.put("time", Integer.valueOf(time));
|
| | | List<Number> values = new ArrayList<Number>();
|
| | | List<String> units = new ArrayList<String>();
|
| | | for (String string : sensorKeys) {
|
| | | if(sensorUnitMap!=null && !sensorUnitMap.isEmpty()) {
|
| | | if(sensorUnitMap.get(string)!=null) {
|
| | | units.add(sensorUnitMap.get(string).get("name").toString());
|
| | | }else {
|
| | | Map<String, Object> sensorMap = sensorService.getSensorBySensorKey(string);
|
| | | units.add(sensorMap.get("unit").toString());
|
| | | }
|
| | | }else {
|
| | | Map<String, Object> sensorMap = sensorService.getSensorBySensorKey(string);
|
| | | units.add(sensorMap.get("unit").toString());
|
| | | }
|
| | | values.add((Number) map.remove(string));
|
| | | }
|
| | | map.put("values", values);
|
| | | map.put("units", units);
|
| | | }
|
| | | return new ResultBean<List<Map<String, Object>>>(list);
|
| | | }
|
| | |
|
| | | }
|