Merge remote-tracking branch 'origin/master'
8 files added
16 files modified
| | |
| | | |
| | | import java.io.*; |
| | | import java.lang.reflect.Array; |
| | | import java.net.URLEncoder; |
| | | import java.text.DateFormat; |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | |
| | | |
| | | import com.rabbitmq.client.*; |
| | | import com.rabbitmq.client.Channel; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import io.swagger.models.auth.In; |
| | | import jdk.nashorn.internal.runtime.regexp.joni.Regex; |
| | | import net.sf.json.JSONString; |
| | | |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.collections.MapUtils; |
| | | import org.apache.commons.net.ftp.FTPClient; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import org.xml.sax.InputSource; |
| | | |
| | | import static com.moral.common.util.ResourceUtil.getValue; |
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith; |
| | | import static java.util.Calendar.*; |
| | |
| | | |
| | | @Resource |
| | | private ScreenVersionService screenVersionService; |
| | | |
| | | @Resource |
| | | private DeviceAdjustValueTimingService deviceAdjustValueTimingService; |
| | | |
| | | /** |
| | | * Screen login. 大屏登录 |
| | |
| | | public ResultBean<List<MonitorPoint>> getMonitorPointsAndDevicesByRegion(HttpServletRequest request) |
| | | throws Exception { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | String regionCode = parameters.get("regionCode").toString(); |
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(parameters); |
| | | |
| | | //剔除沧州非本公司设备 |
| | | if (regionCode.startsWith("1309")) { |
| | | List<Integer> orgIds = new ArrayList<>(); |
| | | Collections.addAll(orgIds, 60, 65, 159, 165, 166); |
| | | Iterator<MonitorPoint> iter = monitorPoints.iterator(); |
| | | while (iter.hasNext()) { |
| | | MonitorPoint next = iter.next(); |
| | | Integer mpId = next.getId(); |
| | | Integer orgId = next.getOrganizationId(); |
| | | if (!orgIds.contains(orgId)) { |
| | | iter.remove(); |
| | | } else { |
| | | if (orgId == 60) { |
| | | if (mpId != 56) { |
| | | iter.remove(); |
| | | } |
| | | } else if (orgId == 65) { |
| | | if (mpId != 83 && mpId != 84) { |
| | | iter.remove(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //给每一个monitorPoint下的设备通过device.getName()进行排序 |
| | | for (MonitorPoint monitorPoint : monitorPoints) { |
| | | List<Device> deviceList = monitorPoint.getDevices(); |
| | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MINUTE, (calendar.get(Calendar.MINUTE) - 2)); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String time = df.format(calendar.getTime()) + ":00"; |
| | | //String time = df.format(calendar.getTime()) + ":00"; |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | String mon; |
| | |
| | | mon = "" + month; |
| | | } |
| | | String table = "history_minutely_" + year + mon; |
| | | List list = deviceService.byMonitorIdGetDeviceAndWind(monitorPointId, time, table); |
| | | List list = deviceService.byMonitorIdGetDeviceAndWind(monitorPointId, table); |
| | | return list; |
| | | } |
| | | |
| | |
| | | mon = "" + month; |
| | | } |
| | | String table = "history_minutely_" + year + mon; |
| | | List list = deviceService.byMonitorIdGetDeviceAndWindSpecial(monitorPointId, time, table); |
| | | List list = deviceService.byMonitorIdGetDeviceAndWindSpecial(monitorPointId, table); |
| | | return list; |
| | | } |
| | | |
| | |
| | | for (Map<String, Object> dataMap : dataList) { |
| | | JSONObject dataJson = JSONObject.parseObject(dataMap.get("json").toString()); |
| | | if (dataMap.get("time").toString().equals(day + " 00:00:00.0")) { |
| | | oneSensorMap.put(dataMap.get("time").toString().substring(0, 10), dataJson.getJSONArray(key).get(2)); |
| | | oneSensorMap.put(dataMap.get("time").toString().substring(0, 10), dataJson.getJSONArray(key).get(0)); |
| | | break; |
| | | } else { |
| | | continue; |
| | |
| | | for (Map sameDayHourlyMap : sameDayHourlyList) { |
| | | List<Double> arr = new ArrayList<>(); |
| | | JSONObject hourlyJson = JSONObject.parseObject(sameDayHourlyMap.get("json").toString()); |
| | | arr.add(Double.parseDouble(hourlyJson.getJSONArray(key).get(2).toString())); |
| | | arr.add(Double.parseDouble(hourlyJson.getJSONArray(key).get(0).toString())); |
| | | Double sum = 0.0; |
| | | for (int i = 0; i < arr.size(); i++) { |
| | | sum += arr.get(i); |
| | |
| | | for (Map<String, Object> hourlyMap : hourlyList) { |
| | | JSONObject dataJson = JSONObject.parseObject(hourlyMap.get("json").toString()); |
| | | if (hourlyMap.get("time").toString().equals(hour + ".0")) { |
| | | oneSensorMap.put(hourlyMap.get("time").toString().substring(0, 19), dataJson.getJSONArray(key).get(2)); |
| | | break; |
| | | if (dataJson.getJSONArray(key) != null) { |
| | | oneSensorMap.put(hourlyMap.get("time").toString().substring(0, 19), dataJson.getJSONArray(key).get(0)); |
| | | break; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | |
| | | @ApiImplicitParam(name = "endTime", value = "结束时间(格式:2020-08-04)", required = false, paramType = "query", dataType = "String")}) |
| | | public ResultBean<List<Map<String, Object>>> getAllDeviceDataToExcel(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | ParameterUtils.getTimeType4Time(parameters); |
| | | List<Map<String, Object>> list = historyMinutelyService.getAllDeviceDataToExcel(parameters); |
| | | return new ResultBean<List<Map<String, Object>>>(list); |
| | | } |
| | | } |
| | | |
| | | /*@PostMapping("insertAdjustValue") |
| | | @ApiOperation(value = "所有设备多因子数据报表", notes = "所有设备多因子数据报表") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "设备id", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间(格式08:30:00)", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "dataArray", value = "公式", required = false, paramType = "query", dataType = "String")}) |
| | | public void insertAdjustValue(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | int device_id = Integer.parseInt(parameters.get("id").toString()); |
| | | String hour_minute_second = parameters.get("time").toString(); |
| | | String[] arr = hour_minute_second.split(":"); |
| | | int seconds = Integer.parseInt(arr[0])*3600+Integer.parseInt(arr[1])*60+Integer.parseInt(arr[2]); |
| | | String value = parameters.get("dataArray").toString(); |
| | | deviceAdjustValueTimingService.insertData(device_id,seconds,value);; |
| | | }*/ |
| | | |
| | | @PostMapping("insertAdjustValue") |
| | | public int insertAdjustValue(@RequestBody HashMap map){ |
| | | try{ |
| | | int device_id = Integer.parseInt(map.get("id").toString()); |
| | | String time = map.get("time").toString(); |
| | | String[] arr = time.split(":"); |
| | | int seconds = Integer.parseInt(arr[0])*3600+Integer.parseInt(arr[1])*60+Integer.parseInt(arr[2]); |
| | | //String t = URLEncoder.encode(参数,"UTF-8") |
| | | List list = (List) map.get("dataArray"); |
| | | String val=""; |
| | | for (int i = 0; i <list.size() ; i++) { |
| | | if (i==0){ |
| | | val=val+list.get(i); |
| | | }else { |
| | | val=val+","+list.get(i); |
| | | } |
| | | } |
| | | String value = "{"+val+"}"; |
| | | deviceAdjustValueTimingService.insertData(device_id,seconds,value); |
| | | return 1; |
| | | }catch (Exception e){ |
| | | log.warn(e); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | @RequestMapping("/biaozhun") |
| | | @ResponseBody |
| | | public List<Device> queryDevice(String macOrName){ |
| | | List<Device> deviceList = new ArrayList<>(); |
| | | if (!macOrName.equals("")){ |
| | | deviceList= deviceService.getDevice(macOrName); |
| | | } |
| | | return deviceList; |
| | | } |
| | | |
| | | @RequestMapping("/getBiaoZhun") |
| | | @ResponseBody |
| | | public List<DeviceAdjustValueTiming> getBiaoZhun(String id){ |
| | | List<DeviceAdjustValueTiming> dataByDeviceid = deviceAdjustValueTimingService.getDataByDeviceid(Integer.parseInt(id)); |
| | | for (DeviceAdjustValueTiming deviceAdjustValueTiming : dataByDeviceid) { |
| | | int seconds = Integer.parseInt(deviceAdjustValueTiming.getSeconds()); |
| | | String hour = String.valueOf(seconds/3600); |
| | | int millAndSeconds = seconds%3600; |
| | | String mill = String.valueOf(millAndSeconds/60); |
| | | String second = String.valueOf(millAndSeconds%60); |
| | | if (hour.length()<2){ |
| | | hour="0"+hour; |
| | | } |
| | | if (mill.length()<2){ |
| | | mill="0"+mill; |
| | | } |
| | | if (second.length()<2){ |
| | | second="0"+second; |
| | | } |
| | | String time = hour+":"+mill+":"+second; |
| | | Map<String, String> value = deviceAdjustValueTiming.getValue(); |
| | | Collection<String> values = value.values(); |
| | | deviceAdjustValueTiming.setSeconds(time); |
| | | } |
| | | return dataByDeviceid; |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/getSensor") |
| | | @ResponseBody |
| | | public List<Map<String, Object>> getSensor(String id){ |
| | | List<Map<String, Object>> allSensors = sensorService.getSensorByDeviceId(id); |
| | | return allSensors; |
| | | } |
| | | |
| | | @RequestMapping("/deleteBiaoZhun") |
| | | @ResponseBody |
| | | public int deleteBiaoZhun(String id){ |
| | | int i= deviceAdjustValueTimingService.delete(id); |
| | | return i; |
| | | } |
| | | |
| | | |
| | | @GetMapping("/monitorAVGData") |
| | | @ApiOperation(value = "monitor平均数据导出", notes = "monitor平均数据导出") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "monitorPointIds", value = "多个monitorid", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")}) |
| | | public List<List<Map>> monitorAVGData(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | String monitorPointIds = (String) parameters.get("monitorPointIds"); |
| | | String time = (String) parameters.get("time"); |
| | | time = time+" 00:00:00"; |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd mm:HH:ss");//注意月份是MM |
| | | Date date = simpleDateFormat.parse(time); |
| | | Calendar calendar = new GregorianCalendar(); |
| | | calendar.setTime(date); |
| | | calendar.add(calendar.DATE,+1); |
| | | String date1= simpleDateFormat.format(date); |
| | | String date2= simpleDateFormat.format(calendar.getTime()); |
| | | String[] mIds = monitorPointIds.split(","); |
| | | List<List<Map>> lists = new ArrayList<>(); |
| | | if (mIds.length==1 && mIds.length!=0){ |
| | | String mId = mIds[0]; |
| | | List<Map> dataAvbByMIdAndTime = historyHourlyService.getDataAvbByMIdAndTime(mId, date1, date2); |
| | | lists.add(dataAvbByMIdAndTime); |
| | | //List<Device> devicesByMonitorPointId = deviceService.getDevicesByMonitorPointId(Integer.valueOf(mId)); |
| | | }else { |
| | | for (int i = 0; i <mIds.length ; i++) { |
| | | List<Map> dataAvbByMIdAndTime = historyHourlyService.getDataAvbByMIdAndTime(mIds[i], date1, date2); |
| | | lists.add(dataAvbByMIdAndTime); |
| | | } |
| | | } |
| | | return lists; |
| | | } |
| | | } |
| | |
| | | return new ResultBean<Map<String,Object>>(datasMap); |
| | | } |
| | | |
| | | @GetMapping("cangzhouMIdGetAllDevice") |
| | | public ResultBean<Map<String,Object>> cangzhouMIdGetAllDevice(HttpServletRequest request) { |
| | | //获取参数,传感器和monitorpointId |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | if ((!parameters.containsKey("sensorKey")) || (!parameters.containsKey("monitorPointId"))) |
| | | return ResultBean.fail("参数为null"); |
| | | String sensorKey = (String) parameters.get("sensorKey"); |
| | | Integer monitorPointId = Integer.parseInt((String) parameters.get("monitorPointId")); |
| | | MonitorPoint mPoint = monitorPointService.queryMonitorPointById(monitorPointId); |
| | | Integer code = mPoint.getCityCode(); |
| | | List<Device> devices = null; |
| | | if (code == 130900){ |
| | | devices = deviceService.getDeviceByCode(); |
| | | }else { |
| | | devices = deviceService.getDevicesByMonitorPointId(monitorPointId); |
| | | } |
| | | //根据monitorpointId获取该站点下所有设备mac集合 |
| | | if (ObjectUtils.isEmpty(devices)) |
| | | return ResultBean.fail("站点下无设备或monitorPointId错误"); |
| | | List<String> macs = new ArrayList<>(); |
| | | devices.forEach(p -> { |
| | | macs.add(p.getMac()); |
| | | }); |
| | | |
| | | //根据时间和mac号集合以及传感器参数查询五分钟平均数据 |
| | | Map<String, Object> timeAndYearMonth = getTimeAndYearMonthForFiveMinuteData(); |
| | | String time = (String) timeAndYearMonth.get("time"); |
| | | String yearAndMonth = (String) timeAndYearMonth.get("yearAndMonth"); |
| | | parameters.put("time", time); |
| | | parameters.put("yearAndMonth", yearAndMonth); |
| | | parameters.put("macs", macs); |
| | | List<Map<String, Object>> datas = historyFiveMinutelyService.getFiveMinutesDataByMacsAndTime(parameters); |
| | | |
| | | //如果当前五分钟数据还没有插入,则提取前五分钟数据返回 |
| | | if (ObjectUtils.isEmpty(datas)) { |
| | | time = getFiveMinuteAgoTime(time); |
| | | parameters.put("time", time); |
| | | datas = historyFiveMinutelyService.getFiveMinutesDataByMacsAndTime(parameters); |
| | | } |
| | | datas = insertDeviceInfo(datas, devices); |
| | | |
| | | //根据monitorPointId获取国控站坐标 |
| | | List<Map<String,Object>> coordinate = new ArrayList<>(); |
| | | MonitorPoint monitorPoint = monitorPointService.queryMonitorPointById(monitorPointId); |
| | | Integer orgId = monitorPoint.getOrganizationId(); |
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByOrganizationId(orgId); |
| | | monitorPoints.forEach(value->{ |
| | | if("国控站".equals(value.getDescription())) { |
| | | List list = LatLngTransformation.Convert_BD09_To_GCJ02(value.getLatitude(), value.getLongitude()); |
| | | Map<String,Object> controlStation = new HashMap<>(); |
| | | controlStation.put("name",value.getName()); |
| | | controlStation.put("longitude", list.get(0)); |
| | | controlStation.put("latitude", list.get(1)); |
| | | coordinate.add(controlStation); |
| | | } |
| | | }); |
| | | |
| | | Map<String,Object> datasMap = new HashMap<>(); |
| | | datasMap.put("coordinate",coordinate); |
| | | datasMap.put("device",datas); |
| | | |
| | | return new ResultBean<Map<String,Object>>(datasMap); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 根据mac号获取单台设备信息,特殊客户只显示客户需要的传感器信息 |
| | | * @Param: [request] |
New file |
| | |
| | | package com.moral.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.persistence.Id; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | @Data |
| | | public class DeviceAdjustValueTiming { |
| | | @Id |
| | | private Integer id; |
| | | |
| | | private Integer deviceId; |
| | | |
| | | private String seconds; |
| | | |
| | | private Map<String,String> value; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | } |
New file |
| | |
| | | package com.moral.mapper; |
| | | |
| | | |
| | | import com.moral.common.mapper.BaseMapper; |
| | | import com.moral.entity.DeviceAdjustValueTiming; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface DeviceAdjustValueTimingMapper{ |
| | | List<DeviceAdjustValueTiming> selectAllByDeviceid(@Param("device_id")Integer device_id); |
| | | |
| | | Map<String, Object> selectAllByDeviceidAndSeconds(@Param("device_id")Integer device_id,@Param("seconds")Integer seconds); |
| | | |
| | | void insertData(@Param("device_id")Integer device_id,@Param("seconds")Integer seconds,@Param("value")String value,@Param("create_time")String create_time); |
| | | |
| | | void upDataByDeviceid(@Param("value")String value,@Param("update_time")String update_time,@Param("device_id")Integer device_id); |
| | | |
| | | int delete(@Param("id")String id); |
| | | } |
| | |
| | |
|
| | | Device byMacGetDevice(@Param("mac") String mac);
|
| | |
|
| | | DeviceAndWind getDeviceAndWindByMac(@Param("mac") String mac, @Param("time") String time,
|
| | | DeviceAndWind getDeviceAndWindByMac(@Param("mac") String mac,
|
| | | @Param("table") String table);
|
| | |
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWind(@Param("id") int id, @Param("time") String time, @Param("table") String table);
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWind(@Param("id") int id, @Param("table") String table);
|
| | |
|
| | | DeviceAndWind byMacGetDeviceAndWind(@Param("mac") String mac, @Param("time") String time, @Param("table") String table);
|
| | | DeviceAndWind byMacGetDeviceAndWind(@Param("mac") String mac, @Param("table") String table);
|
| | |
|
| | | List<String> getMacsByMonitorPointIds(List<Integer> list);
|
| | |
|
| | |
| | | List<Map<String, Object>> getDevicesByMpId(int mpId);
|
| | |
|
| | | String byMacGetOrgId(String mac);
|
| | |
|
| | | List<Device> getDevice(String macOrName);
|
| | |
|
| | |
|
| | | List<Device> getDeviceByCityCode();
|
| | |
|
| | |
|
| | | } |
| | |
| | | @Param("sensor") String sensor, |
| | | @Param("startTime") String startTime, |
| | | @Param("endTime") String endTime); |
| | | List<Map> getDataByMacAndTime1(@Param("mac") String mac, |
| | | @Param("sensor") String sensor, |
| | | @Param("startTime") String startTime, |
| | | @Param("endTime") String endTime); |
| | | |
| | | List<Map<String,Object>> getDataAvbByMIdAndTime( @Param("mId")String mId, |
| | | @Param("startTime")String startTime, |
| | | @Param("endTime")String endTime); |
| | | } |
| | |
| | | String getJsonData(@Param("mac") String mac,
|
| | | @Param("time") String time,
|
| | | @Param("table") String table);
|
| | |
|
| | | Map<String,Object> getDailyAvgData(@Param("mId")String mId,@Param("time")String time);
|
| | | } |
New file |
| | |
| | | package com.moral.service; |
| | | |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.entity.DeviceAdjustValue; |
| | | import com.moral.entity.DeviceAdjustValueTiming; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface DeviceAdjustValueTimingService { |
| | | List<DeviceAdjustValueTiming> getDataByDeviceid(Integer device_id); |
| | | |
| | | void insertData(int device_id,int seconds,String value); |
| | | |
| | | int delete(String id); |
| | | } |
| | |
| | |
|
| | | Device byMacGetDevice(String mac);
|
| | |
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWind(String id,String time,String tab);
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWindSpecial(String id,String time,String tab);
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWind(String id,String tab);
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWindSpecial(String id,String tab);
|
| | |
|
| | | List<Device> getDeviceByCodeAndId(String code,String id);
|
| | |
|
| | | String byMacGetOrgId(String mac);
|
| | | //通过mac号或者设备名进行查询设备
|
| | | List<Device> getDevice(String macOrName);
|
| | |
|
| | | List<Device> getDeviceByCode();
|
| | | }
|
| | |
| | | List<Map<String, Object>> getDataByTimeSlot(String mac, String startTime, String endTime) throws Exception; |
| | | |
| | | List<Map> getDataByMacAndTime(Map param); |
| | | |
| | | List<Map> getDataAvbByMIdAndTime(String mId,String startTime,String endTime); |
| | | } |
| | |
| | | |
| | | List<Map<String, Object>> getMultiDeviceSensorData(Map<String, Object> parameters) throws Exception; |
| | | |
| | | |
| | | List<Map<String, Object>> getAllDeviceDataToExcel(Map<String, Object> parameters) throws Exception; |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.service.impl; |
| | | |
| | | import com.moral.entity.DeviceAdjustValueTiming; |
| | | import com.moral.mapper.DeviceAdjustValueTimingMapper; |
| | | import com.moral.service.DeviceAdjustValueTimingService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | @Service |
| | | public class DeviceAdjustValueTimingServiceImpl implements DeviceAdjustValueTimingService { |
| | | |
| | | @Resource |
| | | private DeviceAdjustValueTimingMapper deviceAdjustValueTimingMapper; |
| | | |
| | | @Override |
| | | public List<DeviceAdjustValueTiming> getDataByDeviceid(Integer device_id) { |
| | | List<DeviceAdjustValueTiming> result = deviceAdjustValueTimingMapper.selectAllByDeviceid(device_id); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void insertData(int device_id, int seconds, String value) { |
| | | //获取当前时间作为更新时间 |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | String nowTime = df.format(time); |
| | | //先根据device_id查询数据库,看表中是否有相同设备、相同时间的数据 |
| | | Map<String,Object> deviceAdjustValueTimingMap = deviceAdjustValueTimingMapper.selectAllByDeviceidAndSeconds(device_id,seconds); |
| | | //判断是否为空,如果为空才可以插入,如果不为空则进行更新 |
| | | if (deviceAdjustValueTimingMap == null){ |
| | | deviceAdjustValueTimingMapper.insertData(device_id,seconds,value,nowTime); |
| | | }else { |
| | | deviceAdjustValueTimingMapper.upDataByDeviceid(value,nowTime,device_id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int delete(String id) { |
| | | return deviceAdjustValueTimingMapper.delete(id); |
| | | } |
| | | } |
| | |
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.MonitorPointService;
|
| | | import com.moral.util.LatLngTransformation;
|
| | | import com.moral.util.TkMybatisUtils;
|
| | |
|
| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | |
|
| | | @Service
|
| | |
| | | OrganizationMapper organizationMapper;
|
| | | @Resource
|
| | | DictionaryDataMapper dictionaryDataMapper;
|
| | | @Resource
|
| | | private MonitorPointService monitorPointService ;
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getDeviceStatesByAccount(Map<String, Object> parameters) {
|
| | |
| | | public List<Device> query(Map<String, Object> params) {
|
| | | List<Integer> dv = deviceMapper.getHasWindDirAndWindSpeedDeviceVersion();
|
| | | Object orgIdObj = params.get("orgId");
|
| | | String regionCode = params.get("regionCode").toString();
|
| | | List<Device> deviceList = null;
|
| | | if (orgIdObj != null) {
|
| | | Integer orgId = Integer.parseInt(orgIdObj.toString());
|
| | | List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
|
| | | params.put("orgIds", orgIds);
|
| | | System.out.println(params);
|
| | | deviceList = deviceMapper.selectByMap(params);
|
| | | //剔除沧州地图页面非公司设备图标
|
| | | if (regionCode.startsWith("1309")&&orgIdObj.toString().equals("5")) {
|
| | | orgIds = new ArrayList<>();
|
| | | Collections.addAll(orgIds, 60, 65, 159, 165, 166);
|
| | | deviceList = deviceMapper.selectByMap(params);
|
| | | Iterator<Device> iter = deviceList.iterator();
|
| | | while (iter.hasNext()) {
|
| | | Device device = iter.next();
|
| | | Integer mpId = device.getMonitorPointId();
|
| | | Integer oid = monitorPointService.byIdGetMonitorPoint(mpId).getOrganizationId();
|
| | | if (!orgIds.contains(oid)) {
|
| | | iter.remove();
|
| | | } else {
|
| | | if (orgId == 60) {
|
| | | if (mpId != 56) {
|
| | | iter.remove();
|
| | | }
|
| | | } else if (orgId == 65) {
|
| | | if (mpId != 83 && mpId != 84) {
|
| | | iter.remove();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }else {
|
| | | params.put("orgIds", orgIds);
|
| | | deviceList = deviceMapper.selectByMap(params);
|
| | | }
|
| | | // loadDeviceState(deviceList);
|
| | | }
|
| | | Example deviceExample = new Example(Device.class);//实例化
|
| | |
| | | params.put("orgIds", orgIds);
|
| | | deviceList = deviceMapper.selectDevicesAll(params);
|
| | | }
|
| | | List<Device> deviceListHasWind=new ArrayList<>();
|
| | | List<Device> deviceListHasWind = new ArrayList<>();
|
| | | for (Device d : deviceList) {
|
| | | if (dv.contains(d.getDeviceVersionId())) {
|
| | | deviceListHasWind.add(d);
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List byMonitorIdGetDeviceAndWind(String id,String time,String tab) {
|
| | | List<DeviceAndWind> deviceAndWinds=deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id),time,tab);
|
| | | List loList=new ArrayList();
|
| | | List laList=new ArrayList();
|
| | | Double U=0.0;
|
| | | Double V=0.0;
|
| | | List list=new ArrayList();
|
| | | public List byMonitorIdGetDeviceAndWind(String id, String tab) {
|
| | | List<DeviceAndWind> deviceAndWinds = deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id), tab);
|
| | | List loList = new ArrayList();
|
| | | List laList = new ArrayList();
|
| | | Double U = 0.0;
|
| | | Double V = 0.0;
|
| | | List list = new ArrayList();
|
| | | for (DeviceAndWind andWind : deviceAndWinds) {
|
| | | Double lo=andWind.getLongitude();
|
| | | Double la=andWind.getLatitude();
|
| | | List tranlist= LatLngTransformation.Convert_BD09_To_GCJ02(la,lo);
|
| | | Double transLo=(Double) tranlist.get(0);
|
| | | Double transLa=(Double) tranlist.get(1);
|
| | | Double lo = andWind.getLongitude();
|
| | | Double la = andWind.getLatitude();
|
| | | List tranlist = LatLngTransformation.Convert_BD09_To_GCJ02(la, lo);
|
| | | Double transLo = (Double) tranlist.get(0);
|
| | | Double transLa = (Double) tranlist.get(1);
|
| | | loList.add(transLo);
|
| | | laList.add(transLa);
|
| | | }
|
| | | Double loma= 0.0;
|
| | | Double lomi= 0.0;
|
| | | Double lama= 0.0;
|
| | | Double lami= 0.0;
|
| | | if (loList.size()>0){
|
| | | loma= (Double) Collections.max(loList);
|
| | | lomi= (Double) Collections.min(loList);
|
| | | Double loma = 0.0;
|
| | | Double lomi = 0.0;
|
| | | Double lama = 0.0;
|
| | | Double lami = 0.0;
|
| | | if (loList.size() > 0) {
|
| | | loma = (Double) Collections.max(loList);
|
| | | lomi = (Double) Collections.min(loList);
|
| | | }
|
| | | if (laList.size()>0){
|
| | | lama= (Double) Collections.max(laList);
|
| | | lami= (Double) Collections.min(laList);
|
| | | if (laList.size() > 0) {
|
| | | lama = (Double) Collections.max(laList);
|
| | | lami = (Double) Collections.min(laList);
|
| | | }
|
| | | Map laLaMap=new HashMap();
|
| | | laLaMap.put("maxLo",loma);
|
| | | laLaMap.put("minLo",lomi);
|
| | | laLaMap.put("maxLa",lama);
|
| | | laLaMap.put("minLa",lami);
|
| | | Map laLaMap = new HashMap();
|
| | | laLaMap.put("maxLo", loma);
|
| | | laLaMap.put("minLo", lomi);
|
| | | laLaMap.put("maxLa", lama);
|
| | | laLaMap.put("minLa", lami);
|
| | |
|
| | | Double lo1=lomi-250*0.00001141;
|
| | | Double lo2=loma+250*0.00001141;
|
| | | Double la2=lami-250*0.00000899;
|
| | | Double la1=lama+250*0.00000899;
|
| | | Double lo1 = lomi - 250 * 0.00001141;
|
| | | Double lo2 = loma + 250 * 0.00001141;
|
| | | Double la2 = lami - 250 * 0.00000899;
|
| | | Double la1 = lama + 250 * 0.00000899;
|
| | |
|
| | | Double dx=0.00001141*20;
|
| | | Double dy=0.00000899*20;
|
| | | int nx=(int) Math.floor((lo2-lo1)/dx);
|
| | | int ny=(int) Math.floor((la1-la2)/dy);
|
| | | Double dx = 0.00001141 * 20;
|
| | | Double dy = 0.00000899 * 20;
|
| | | int nx = (int) Math.floor((lo2 - lo1) / dx);
|
| | | int ny = (int) Math.floor((la1 - la2) / dy);
|
| | | String header1 = "\"" + "header" + "\"" + ": " + "{" + "\"" + "parameterUnit" + "\"" + ": " + "\"" + "m/s" + "\"" + ", " + "\"" + "parameterNumber" + "\"" + ": " + 2 +
|
| | | ", " + "\"" + "dx" + "\"" + ": " + dx + ", " + "\"" + "dy" + "\"" + ": " + dy +
|
| | | ", " + "\"" + "parameterNumberName" + "\"" + ": " + "\"" + "eastward_wind" + "\"" + ", " + "\"" + "la1" + "\"" + ": " + la1 + ", " + "\"" + "la2" + "\"" + ": " + la2 +
|
| | |
| | | ", " + "\"" + "parameterCategory" + "\"" + ": " + 2 + ", " + "\"" + "lo1" + "\"" + ": " + lo1 + ", " + "\"" + "lo2" + "\"" + ": " + lo2 +
|
| | | ", " + "\"" + "nx" + "\"" + ": " + nx + ", " + "\"" + "ny" + "\"" + ": " + ny + ", " + "\"" + "refTime" + "\"" + ": " + "\"" + "2020-07-22 23:00:00" + "\"" + "}";
|
| | |
|
| | | List<Double> uList=new ArrayList<Double> ();
|
| | | List<Double> vList=new ArrayList<Double> ();
|
| | | int x=0;
|
| | | int y=0;
|
| | | List<Map> mapList=new ArrayList<Map>();
|
| | | List<Double> uList = new ArrayList<Double>();
|
| | | List<Double> vList = new ArrayList<Double>();
|
| | | int x = 0;
|
| | | int y = 0;
|
| | | List<Map> mapList = new ArrayList<Map>();
|
| | |
|
| | | for (int j = 0; j <deviceAndWinds.size() ; j++) {
|
| | | Map<String,Double> map=new HashMap<String,Double> ();
|
| | | Double windDir= deviceAndWinds.get(j).getWindDir();
|
| | | for (int j = 0; j < deviceAndWinds.size(); j++) {
|
| | | Map<String, Double> map = new HashMap<String, Double>();
|
| | | Double windDir = deviceAndWinds.get(j).getWindDir();
|
| | |
|
| | | Double windSpeed=deviceAndWinds.get(j).getWindSpeed();
|
| | | if (windDir==null){
|
| | | windDir=0.0;
|
| | | windSpeed=0.0;
|
| | | Double windSpeed = deviceAndWinds.get(j).getWindSpeed();
|
| | | if (windDir == null) {
|
| | | windDir = 0.0;
|
| | | windSpeed = 0.0;
|
| | | }
|
| | | Double tvoc=deviceAndWinds.get(j).getTVoc();
|
| | | Double tvoc = deviceAndWinds.get(j).getTVoc();
|
| | |
|
| | | List tranlist= LatLngTransformation.Convert_BD09_To_GCJ02(deviceAndWinds.get(j).getLatitude(),deviceAndWinds.get(j).getLongitude());
|
| | | Double transLo=(Double) tranlist.get(0);
|
| | | Double transLa=(Double) tranlist.get(1);
|
| | | if (tvoc==null){
|
| | | tvoc=0.0;
|
| | | List tranlist = LatLngTransformation.Convert_BD09_To_GCJ02(deviceAndWinds.get(j).getLatitude(), deviceAndWinds.get(j).getLongitude());
|
| | | Double transLo = (Double) tranlist.get(0);
|
| | | Double transLa = (Double) tranlist.get(1);
|
| | | if (tvoc == null) {
|
| | | tvoc = 0.0;
|
| | | }
|
| | | Double dir = (270.0 - windDir * Math.PI / 180.0);
|
| | |
|
| | | U = windSpeed * Math.cos(dir);
|
| | | V = windSpeed * Math.sin(dir);
|
| | | map.put("lo",transLo);
|
| | | map.put("la",transLa);
|
| | | map.put("U",U);
|
| | | map.put("V",V);
|
| | | map.put("lo", transLo);
|
| | | map.put("la", transLa);
|
| | | map.put("U", U);
|
| | | map.put("V", V);
|
| | | mapList.add(map);
|
| | | }
|
| | | for (int i = 0; i <mapList.size() ; i++) {
|
| | | Double lo= (Double) mapList.get(i).get("lo");
|
| | | Double la= (Double) mapList.get(i).get("la");
|
| | | x= (int) Math.floor((lo-lo1)/dx);
|
| | | y=Math.abs((int)Math.floor((la-la1)/dy));
|
| | | for (int i = 0; i < mapList.size(); i++) {
|
| | | Double lo = (Double) mapList.get(i).get("lo");
|
| | | Double la = (Double) mapList.get(i).get("la");
|
| | | x = (int) Math.floor((lo - lo1) / dx);
|
| | | y = Math.abs((int) Math.floor((la - la1) / dy));
|
| | | //y=Math.floor(Math.abs(la-la1)/dy);
|
| | | U=(Double) mapList.get(i).get("U");
|
| | | V=(Double) mapList.get(i).get("V");
|
| | | if (i==0){
|
| | | for (int j = 0; j <nx*ny ; j++) {
|
| | | U = (Double) mapList.get(i).get("U");
|
| | | V = (Double) mapList.get(i).get("V");
|
| | | if (i == 0) {
|
| | | for (int j = 0; j < nx * ny; j++) {
|
| | | uList.add(0.0);
|
| | | vList.add(0.0);
|
| | | }
|
| | | }
|
| | | for (int j = 0; j <nx*ny ; j++) {
|
| | | if (i==0){
|
| | | if ((y>=2 && j==(y)*nx+x)){
|
| | | for (int j = 0; j < nx * ny; j++) {
|
| | | if (i == 0) {
|
| | | if ((y >= 2 && j == (y) * nx + x)) {
|
| | | int k;
|
| | | for (k = j-2*nx; k <=j+2*nx ;k=k+nx) {
|
| | | uList.set(k,U);
|
| | | uList.set(k-1,U);
|
| | | uList.set(k-2,U);
|
| | | uList.set(k+1,U);
|
| | | uList.set(k+2,U);
|
| | | vList.set(k,V);
|
| | | vList.set(k-1,V);
|
| | | vList.set(k-2,V);
|
| | | vList.set(k+1,V);
|
| | | vList.set(k+2,V);
|
| | | for (k = j - 2 * nx; k <= j + 2 * nx; k = k + nx) {
|
| | | uList.set(k, U);
|
| | | uList.set(k - 1, U);
|
| | | uList.set(k - 2, U);
|
| | | uList.set(k + 1, U);
|
| | | uList.set(k + 2, U);
|
| | | vList.set(k, V);
|
| | | vList.set(k - 1, V);
|
| | | vList.set(k - 2, V);
|
| | | vList.set(k + 1, V);
|
| | | vList.set(k + 2, V);
|
| | | }
|
| | | }
|
| | | }else {
|
| | | if (y>=1 && j==y*nx+x){
|
| | | } else {
|
| | | if (y >= 1 && j == y * nx + x) {
|
| | | int k;
|
| | | for (k = j-2*nx; k <=j+2*nx ;) {
|
| | | uList.set(k-1,U);
|
| | | uList.set(k-2,U);
|
| | | uList.set(k+1,U);
|
| | | uList.set(k+2,U);
|
| | | vList.set(k-1,V);
|
| | | vList.set(k-2,V);
|
| | | vList.set(k+1,V);
|
| | | vList.set(k+2,V);
|
| | | k=k+nx;
|
| | | for (k = j - 2 * nx; k <= j + 2 * nx; ) {
|
| | | uList.set(k - 1, U);
|
| | | uList.set(k - 2, U);
|
| | | uList.set(k + 1, U);
|
| | | uList.set(k + 2, U);
|
| | | vList.set(k - 1, V);
|
| | | vList.set(k - 2, V);
|
| | | vList.set(k + 1, V);
|
| | | vList.set(k + 2, V);
|
| | | k = k + nx;
|
| | | }
|
| | | uList.set(j,U);
|
| | | vList.set(j,V);
|
| | | uList.set(j, U);
|
| | | vList.set(j, V);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | String vData = "\"" + "data" + "\"" + ": " + vList;
|
| | | String s1 = "[" + "{" + header1 + ", " + uData + "}" + ", " + "{" + header2 + ", " + vData + "}" + "]";
|
| | | JSONArray jsonArray = JSONArray.parseArray(s1);
|
| | | MonitorPoint monitorPoint=monitorPointMapper.byIdGetMonitorPoint(Integer.parseInt(id));
|
| | | Double monitorLo=monitorPoint.getLongitude();
|
| | | Double monitorLa=monitorPoint.getLatitude();
|
| | | List transList= LatLngTransformation.Convert_BD09_To_GCJ02(monitorLa,monitorLo);
|
| | | Double transLo=(Double) transList.get(0);
|
| | | Double transLa=(Double) transList.get(1);
|
| | | MonitorPoint monitorPoint = monitorPointMapper.byIdGetMonitorPoint(Integer.parseInt(id));
|
| | | Double monitorLo = monitorPoint.getLongitude();
|
| | | Double monitorLa = monitorPoint.getLatitude();
|
| | | List transList = LatLngTransformation.Convert_BD09_To_GCJ02(monitorLa, monitorLo);
|
| | | Double transLo = (Double) transList.get(0);
|
| | | Double transLa = (Double) transList.get(1);
|
| | | list.add(jsonArray);
|
| | | list.add(transLo);
|
| | | list.add(transLa);
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List byMonitorIdGetDeviceAndWindSpecial(String id, String time, String tab) {
|
| | | MonitorPoint monitorPoint=monitorPointMapper.byIdGetMonitorPoint(Integer.parseInt(id));
|
| | | Integer areaCode=monitorPoint.getAreaCode();
|
| | | String townCode= monitorPoint.getTownCode()+"";
|
| | | int monitorPointId=monitorPoint.getId();
|
| | | Map<String, Object> parm=new HashMap<>();
|
| | | List<DeviceAndWind> deviceAndWinds=new ArrayList<>();
|
| | | Double loma= 0.0;
|
| | | Double lomi= 0.0;
|
| | | Double lama= 0.0;
|
| | | Double lami= 0.0;
|
| | | public List byMonitorIdGetDeviceAndWindSpecial(String id, String tab) {
|
| | | MonitorPoint monitorPoint = monitorPointMapper.byIdGetMonitorPoint(Integer.parseInt(id));
|
| | | Integer areaCode = monitorPoint.getAreaCode();
|
| | | String townCode = monitorPoint.getTownCode() + "";
|
| | | int monitorPointId = monitorPoint.getId();
|
| | | Map<String, Object> parm = new HashMap<>();
|
| | | List<DeviceAndWind> deviceAndWinds = new ArrayList<>();
|
| | | Double loma = 0.0;
|
| | | Double lomi = 0.0;
|
| | | Double lama = 0.0;
|
| | | Double lami = 0.0;
|
| | |
|
| | | int length=1;
|
| | | int perdlen=1;
|
| | | if (areaCode==320581){
|
| | | parm.put("areaCode",areaCode);
|
| | | List<Device> deviceList=deviceMapper.getDeviceByCode(parm);
|
| | | int length = 1;
|
| | | int perdlen = 1;
|
| | | if (areaCode == 320581) {
|
| | | parm.put("areaCode", areaCode);
|
| | | List<Device> deviceList = deviceMapper.getDeviceByCode(parm);
|
| | | for (Device d : deviceList) {
|
| | | String mac=d.getMac();
|
| | | DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac,time,tab);
|
| | | if (deviceAndWind!=null){
|
| | | deviceAndWinds.add(deviceAndWind);
|
| | | }
|
| | | }
|
| | | length=8000;
|
| | | perdlen=2200;
|
| | | }else if ((areaCode == 320583) && (townCode.equals("320583108000"))){
|
| | | parm.put("townCode",townCode);
|
| | | List<Device> deviceList=deviceMapper.getDeviceByCode(parm);
|
| | | for (Device d : deviceList) {
|
| | | String mac=d.getMac();
|
| | | DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac,time,tab);
|
| | | if (deviceAndWind!=null){
|
| | | String mac = d.getMac();
|
| | | DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac, tab);
|
| | | if (deviceAndWind != null) {
|
| | | deviceAndWinds.add(deviceAndWind);
|
| | | }
|
| | | }
|
| | | length=2000;
|
| | | perdlen=280;
|
| | | }else if(monitorPointId==35){
|
| | | DeviceAndWind deviceAndWind=deviceMapper.getDeviceAndWindByMac("898607b0101730392253",time,tab);
|
| | | DeviceAndWind deviceAndWind1=deviceMapper.getDeviceAndWindByMac("p5dnd7a0392083",time,tab);
|
| | | deviceAndWinds.add(deviceAndWind);
|
| | | deviceAndWinds.add(deviceAndWind1);
|
| | | length=2000;
|
| | | perdlen=50;
|
| | | length = 8000;
|
| | | perdlen = 2200;
|
| | | } else if ((areaCode == 320583) && (townCode.equals("320583108000"))) {
|
| | | parm.put("townCode", townCode);
|
| | | List<Device> deviceList = deviceMapper.getDeviceByCode(parm);
|
| | | for (Device d : deviceList) {
|
| | | String mac = d.getMac();
|
| | | DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac, tab);
|
| | | if (deviceAndWind != null) {
|
| | | deviceAndWinds.add(deviceAndWind);
|
| | | }
|
| | | }
|
| | | length = 2000;
|
| | | perdlen = 280;
|
| | | } else if (monitorPointId == 35) {
|
| | | DeviceAndWind deviceAndWind = deviceMapper.getDeviceAndWindByMac("898607b0101730392253", tab);
|
| | | DeviceAndWind deviceAndWind1 = deviceMapper.getDeviceAndWindByMac("p5dnd7a0392083", tab);
|
| | | deviceAndWinds.add(deviceAndWind);
|
| | | deviceAndWinds.add(deviceAndWind1);
|
| | | length = 2000;
|
| | | perdlen = 50;
|
| | |
|
| | | }else {
|
| | | deviceAndWinds=deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id),time,tab);
|
| | | length=2000;
|
| | | perdlen=80;
|
| | | } else {
|
| | | deviceAndWinds = deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id), tab);
|
| | | length = 2000;
|
| | | perdlen = 80;
|
| | | }
|
| | | List loList=new ArrayList();
|
| | | List laList=new ArrayList();
|
| | | Double U=0.0;
|
| | | Double V=0.0;
|
| | | List list=new ArrayList();
|
| | | List loList = new ArrayList();
|
| | | List laList = new ArrayList();
|
| | | Double U = 0.0;
|
| | | Double V = 0.0;
|
| | | List list = new ArrayList();
|
| | | for (DeviceAndWind andWind : deviceAndWinds) {
|
| | | Double lo=andWind.getLongitude();
|
| | | Double la=andWind.getLatitude();
|
| | | List tranlist= LatLngTransformation.Convert_BD09_To_GCJ02(la,lo);
|
| | | Double transLo=(Double) tranlist.get(0);
|
| | | Double transLa=(Double) tranlist.get(1);
|
| | | loList.add(transLo);
|
| | | laList.add(transLa);
|
| | | Double lo = andWind.getLongitude();
|
| | | Double la = andWind.getLatitude();
|
| | | List tranlist = LatLngTransformation.Convert_BD09_To_GCJ02(la, lo);
|
| | | Double transLo = (Double) tranlist.get(0);
|
| | | Double transLa = (Double) tranlist.get(1);
|
| | | loList.add(transLo);
|
| | | laList.add(transLa);
|
| | | }
|
| | |
|
| | | if (loList.size()>0){
|
| | | loma= (Double) Collections.max(loList);
|
| | | lomi= (Double) Collections.min(loList);
|
| | | if (loList.size() > 0) {
|
| | | loma = (Double) Collections.max(loList);
|
| | | lomi = (Double) Collections.min(loList);
|
| | | }
|
| | | if (laList.size()>0){
|
| | | lama= (Double) Collections.max(laList);
|
| | | lami= (Double) Collections.min(laList);
|
| | | if (laList.size() > 0) {
|
| | | lama = (Double) Collections.max(laList);
|
| | | lami = (Double) Collections.min(laList);
|
| | | }
|
| | | Map laLaMap=new HashMap();
|
| | | laLaMap.put("maxLo",loma);
|
| | | laLaMap.put("minLo",lomi);
|
| | | laLaMap.put("maxLa",lama);
|
| | | laLaMap.put("minLa",lami);
|
| | | Map laLaMap = new HashMap();
|
| | | laLaMap.put("maxLo", loma);
|
| | | laLaMap.put("minLo", lomi);
|
| | | laLaMap.put("maxLa", lama);
|
| | | laLaMap.put("minLa", lami);
|
| | |
|
| | | Double lo1=lomi-length*0.00001141;
|
| | | Double lo2=loma+length*0.00001141;
|
| | | Double la2=lami-length*0.00000899;
|
| | | Double la1=lama+length*0.00000899;
|
| | | Double lo1 = lomi - length * 0.00001141;
|
| | | Double lo2 = loma + length * 0.00001141;
|
| | | Double la2 = lami - length * 0.00000899;
|
| | | Double la1 = lama + length * 0.00000899;
|
| | |
|
| | | Double dx=0.00001141*perdlen;
|
| | | Double dy=0.00000899*perdlen;
|
| | | int nx=(int) Math.floor((lo2-lo1)/dx);
|
| | | int ny=(int) Math.floor((la1-la2)/dy);
|
| | | Double dx = 0.00001141 * perdlen;
|
| | | Double dy = 0.00000899 * perdlen;
|
| | | int nx = (int) Math.floor((lo2 - lo1) / dx);
|
| | | int ny = (int) Math.floor((la1 - la2) / dy);
|
| | | String header1 = "\"" + "header" + "\"" + ": " + "{" + "\"" + "parameterUnit" + "\"" + ": " + "\"" + "m/s" + "\"" + ", " + "\"" + "parameterNumber" + "\"" + ": " + 2 +
|
| | | ", " + "\"" + "dx" + "\"" + ": " + dx + ", " + "\"" + "dy" + "\"" + ": " + dy +
|
| | | ", " + "\"" + "parameterNumberName" + "\"" + ": " + "\"" + "eastward_wind" + "\"" + ", " + "\"" + "la1" + "\"" + ": " + la1 + ", " + "\"" + "la2" + "\"" + ": " + la2 +
|
| | |
| | | String header2 = "\"" + "header" + "\"" + ": " + "{" + "\"" + "parameterUnit" + "\"" + ": " + "\"" + "m/s" + "\"" + ", " + "\"" + "parameterNumber" + "\"" + ": " + 3 +
|
| | | ", " + "\"" + "dx" + "\"" + ": " + dx + ", " + "\"" + "dy" + "\"" + ": " + dy +
|
| | | ", " + "\"" + "parameterNumberName" + "\"" + ": " + "\"" + "eastward_wind" + "\"" + ", " + "\"" + "la1" + "\"" + ": " + la1 + ", " + "\"" + "la2" + "\"" + ": " + la2 +
|
| | | ", " + "\"" + "parameterCategory" + "\"" + ": " + 2 + ", " + "\"" + "lo1" + "\"" + ": " + lo1 + ", " + "\"" + "lo2" + "\"" + ": " + lo2 +
|
| | | ", " + "\"" + "parameterCategory" + "\"" + ": " + 2 + ", " + "\"" + "lo1" + "\"" + ": " + lo1 + ", " + "\"" + "lo2" + "\"" + ": " + lo2 +
|
| | | ", " + "\"" + "nx" + "\"" + ": " + nx + ", " + "\"" + "ny" + "\"" + ": " + ny + ", " + "\"" + "refTime" + "\"" + ": " + "\"" + "2020-07-22 23:00:00" + "\"" + "}";
|
| | |
|
| | | List<Double> uList=new ArrayList<Double> ();
|
| | | List<Double> vList=new ArrayList<Double> ();
|
| | | int x=0;
|
| | | int y=0;
|
| | | List<Map> mapList=new ArrayList<Map>();
|
| | | List<Double> uList = new ArrayList<Double>();
|
| | | List<Double> vList = new ArrayList<Double>();
|
| | | int x = 0;
|
| | | int y = 0;
|
| | | List<Map> mapList = new ArrayList<Map>();
|
| | |
|
| | | for (int j = 0; j <deviceAndWinds.size() ; j++) {
|
| | | Map<String,Double> map=new HashMap<String,Double> ();
|
| | | Double windDir= deviceAndWinds.get(j).getWindDir();
|
| | | Double windSpeed=deviceAndWinds.get(j).getWindSpeed();
|
| | | if (windDir==null){
|
| | | windDir=0.0;
|
| | | windSpeed=0.0;
|
| | | }
|
| | | Double tvoc=deviceAndWinds.get(j).getTVoc();
|
| | | for (int j = 0; j < deviceAndWinds.size(); j++) {
|
| | | Map<String, Double> map = new HashMap<String, Double>();
|
| | | Double windDir = deviceAndWinds.get(j).getWindDir();
|
| | | Double windSpeed = deviceAndWinds.get(j).getWindSpeed();
|
| | | if (windDir == null) {
|
| | | windDir = 0.0;
|
| | | windSpeed = 0.0;
|
| | | }
|
| | | Double tvoc = deviceAndWinds.get(j).getTVoc();
|
| | |
|
| | | List tranlist= LatLngTransformation.Convert_BD09_To_GCJ02(deviceAndWinds.get(j).getLatitude(),deviceAndWinds.get(j).getLongitude());
|
| | | Double transLo=(Double) tranlist.get(0);
|
| | | Double transLa=(Double) tranlist.get(1);
|
| | | if (tvoc==null){
|
| | | tvoc=0.0;
|
| | | }
|
| | | Double dir = (270.0 + windDir * Math.PI / 180.0);
|
| | | List tranlist = LatLngTransformation.Convert_BD09_To_GCJ02(deviceAndWinds.get(j).getLatitude(), deviceAndWinds.get(j).getLongitude());
|
| | | Double transLo = (Double) tranlist.get(0);
|
| | | Double transLa = (Double) tranlist.get(1);
|
| | | if (tvoc == null) {
|
| | | tvoc = 0.0;
|
| | | }
|
| | | Double dir = (270.0 - windDir * Math.PI / 180.0);
|
| | |
|
| | | U = windSpeed * Math.cos(dir);
|
| | | V = windSpeed * Math.sin(dir);
|
| | | map.put("lo",transLo);
|
| | | map.put("la",transLa);
|
| | | map.put("U",U);
|
| | | map.put("V",V);
|
| | | mapList.add(map);
|
| | | U = windSpeed * Math.cos(dir);
|
| | | V = windSpeed * Math.sin(dir);
|
| | | map.put("lo", transLo);
|
| | | map.put("la", transLa);
|
| | | map.put("U", U);
|
| | | map.put("V", V);
|
| | | mapList.add(map);
|
| | | }
|
| | | for (int i = 0; i <mapList.size() ; i++) {
|
| | | Double lo= (Double) mapList.get(i).get("lo");
|
| | | Double la= (Double) mapList.get(i).get("la");
|
| | | x= (int) Math.floor((lo-lo1)/dx);
|
| | | y=Math.abs((int)Math.floor((la-la1)/dy));
|
| | | for (int i = 0; i < mapList.size(); i++) {
|
| | | Double lo = (Double) mapList.get(i).get("lo");
|
| | | Double la = (Double) mapList.get(i).get("la");
|
| | | x = (int) Math.floor((lo - lo1) / dx);
|
| | | y = Math.abs((int) Math.floor((la - la1) / dy));
|
| | | //y=Math.floor(Math.abs(la-la1)/dy);
|
| | | U=(Double) mapList.get(i).get("U");
|
| | | V=(Double) mapList.get(i).get("V");
|
| | | if (i==0){
|
| | | for (int j = 0; j <nx*ny ; j++) {
|
| | | U = (Double) mapList.get(i).get("U");
|
| | | V = (Double) mapList.get(i).get("V");
|
| | | if (i == 0) {
|
| | | for (int j = 0; j < nx * ny; j++) {
|
| | | uList.add(0.0);
|
| | | vList.add(0.0);
|
| | | }
|
| | | }
|
| | | for (int j = 0; j <nx*ny ; j++) {
|
| | | if (i==0){
|
| | | if ((y>=2 && j==(y)*nx+x)){
|
| | | for (int j = 0; j < nx * ny; j++) {
|
| | | if (i == 0) {
|
| | | if ((y >= 2 && j == (y) * nx + x)) {
|
| | | int k;
|
| | | for (k = j-2*nx; k <=j+2*nx ;k=k+nx) {
|
| | | uList.set(k,U);
|
| | | uList.set(k-1,U);
|
| | | uList.set(k-2,U);
|
| | | uList.set(k+1,U);
|
| | | uList.set(k+2,U);
|
| | | vList.set(k,V);
|
| | | vList.set(k-1,V);
|
| | | vList.set(k-2,V);
|
| | | vList.set(k+1,V);
|
| | | vList.set(k+2,V);
|
| | | for (k = j - 2 * nx; k <= j + 2 * nx; k = k + nx) {
|
| | | uList.set(k, U);
|
| | | uList.set(k - 1, U);
|
| | | uList.set(k - 2, U);
|
| | | uList.set(k + 1, U);
|
| | | uList.set(k + 2, U);
|
| | | vList.set(k, V);
|
| | | vList.set(k - 1, V);
|
| | | vList.set(k - 2, V);
|
| | | vList.set(k + 1, V);
|
| | | vList.set(k + 2, V);
|
| | | }
|
| | | }
|
| | | }else {
|
| | | if (y>=1 && j==y*nx+x){
|
| | | } else {
|
| | | if (y >= 1 && j == y * nx + x) {
|
| | | int k;
|
| | | for (k = j-2*nx; k <=j+2*nx ;) {
|
| | | uList.set(k-1,U);
|
| | | uList.set(k-2,U);
|
| | | uList.set(k+1,U);
|
| | | uList.set(k+2,U);
|
| | | vList.set(k-1,V);
|
| | | vList.set(k-2,V);
|
| | | vList.set(k+1,V);
|
| | | vList.set(k+2,V);
|
| | | k=k+nx;
|
| | | for (k = j - 2 * nx; k <= j + 2 * nx; ) {
|
| | | uList.set(k - 1, U);
|
| | | uList.set(k - 2, U);
|
| | | uList.set(k + 1, U);
|
| | | uList.set(k + 2, U);
|
| | | vList.set(k - 1, V);
|
| | | vList.set(k - 2, V);
|
| | | vList.set(k + 1, V);
|
| | | vList.set(k + 2, V);
|
| | | k = k + nx;
|
| | | }
|
| | | uList.set(j,U);
|
| | | vList.set(j,V);
|
| | | uList.set(j, U);
|
| | | vList.set(j, V);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | String s1 = "[" + "{" + header1 + ", " + uData + "}" + ", " + "{" + header2 + ", " + vData + "}" + "]";
|
| | | JSONArray jsonArray = JSONArray.parseArray(s1);
|
| | |
|
| | | Double monitorLo=monitorPoint.getLongitude();
|
| | | Double monitorLa=monitorPoint.getLatitude();
|
| | | List transList= LatLngTransformation.Convert_BD09_To_GCJ02(monitorLa,monitorLo);
|
| | | Double transLo=(Double) transList.get(0);
|
| | | Double transLa=(Double) transList.get(1);
|
| | | Double monitorLo = monitorPoint.getLongitude();
|
| | | Double monitorLa = monitorPoint.getLatitude();
|
| | | List transList = LatLngTransformation.Convert_BD09_To_GCJ02(monitorLa, monitorLo);
|
| | | Double transLo = (Double) transList.get(0);
|
| | | Double transLa = (Double) transList.get(1);
|
| | |
|
| | | list.add(jsonArray);
|
| | | list.add(transLo);
|
| | |
| | |
|
| | | @Override
|
| | | public List<Device> getDeviceByCodeAndId(String code, String id) {
|
| | | return deviceMapper.getDeviceByCodeAndId(code,id);
|
| | | return deviceMapper.getDeviceByCodeAndId(code, id);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | return deviceMapper.byMacGetOrgId(mac);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Device> getDevice(String macOrName) {
|
| | | return deviceMapper.getDevice(macOrName);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Device> getDeviceByCode() {
|
| | | return deviceMapper.getDeviceByCityCode();
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.moral.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | import com.moral.entity.MachineActivate; |
| | | import com.moral.mapper.HistoryMapper; |
| | | import com.moral.util.AQICalculation; |
| | | import com.moral.util.AQICalculation2; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.collections.MapUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | public class HistoryHourlyServiceImpl implements HistoryHourlyService { |
| | | @Resource |
| | | private HistoryHourlyMapper historyHourlyMapper; |
| | | |
| | | @Resource |
| | | private HistoryMapper historyMapper; |
| | | |
| | | @Resource |
| | | private DeviceService deviceService; |
| | |
| | | String date2 = simpleDateFormat.format(date1); |
| | | List<Map> list = historyHourlyMapper.getDataByMacAndTime(mac, sensor, perTime, date2); |
| | | List<Map> newList = new ArrayList<Map>(); |
| | | //System.out.println(list); |
| | | for (int i = 0; i < 24; i++) { |
| | | Map map=new HashMap(); |
| | | if (i < 10) { |
| | |
| | | newList.add(map); |
| | | } |
| | | } |
| | | //System.out.println(newList); |
| | | if (list.size() <= 24 && list.size() >= 0) { |
| | | for (int i = 0; i <list.size() ; i++) { |
| | | String timeS = list.get(i).get("time").toString().substring(11, 13); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map> getDataAvbByMIdAndTime(String mId, String startTime, String endTime) { |
| | | List<Device> devicesByMonitorPointId = deviceService.getDevicesByMonitorPointId(Integer.valueOf(mId)); |
| | | List<List> lists = new ArrayList<>(); |
| | | List<List<Map<String,String>>> listArrayList = new ArrayList<>(); |
| | | List<Map<String, Object>> dataAvbByMIdAndTime = historyHourlyMapper.getDataAvbByMIdAndTime(mId, startTime, endTime); |
| | | List<Map> mapList = new ArrayList<>(); |
| | | for (Map<String, Object> stringStringMap : dataAvbByMIdAndTime) { |
| | | Map<String,String> map = new HashMap(); |
| | | String s = stringStringMap.get("O3").toString(); |
| | | Object time = stringStringMap.get("time"); |
| | | map.put("O3",s); |
| | | map.put("time",time.toString()); |
| | | mapList.add(map); |
| | | } |
| | | if (mapList.size()>=8){ |
| | | List<Map<String,String>> mapList1 = new ArrayList<>(); |
| | | for (int i = 7; i <=mapList.size()-1 ; i++) { |
| | | if (mapList.get(i).get("O3")!=null){ |
| | | List<Integer> numList = new ArrayList(); |
| | | Map<String,String> O3_8 = new HashMap<>(); |
| | | for (int j =i; j<= mapList.size(); j--) { |
| | | if (j<0){ |
| | | break; |
| | | } |
| | | numList.add(j); |
| | | if (numList.size()==8){ |
| | | List e15 = new ArrayList(); |
| | | for (int k = 0; k <numList.size() ; k++) { |
| | | String value = mapList.get(Integer.valueOf(numList.get(k))).get("O3").toString(); |
| | | e15.add(value); |
| | | } |
| | | double sum =0; |
| | | for (Object o : e15) { |
| | | sum=sum+Double.parseDouble(o.toString()); |
| | | } |
| | | Double avg1 = sum/e15.size(); |
| | | int timeOfHour = numList.get(0); |
| | | if (timeOfHour==23){ |
| | | timeOfHour=0; |
| | | }else { |
| | | timeOfHour=timeOfHour+1; |
| | | } |
| | | O3_8.put("time", String.valueOf(timeOfHour)); |
| | | O3_8.put("O3-8h", String.valueOf(avg1)); |
| | | mapList1.add(O3_8); |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | listArrayList.add(mapList1); |
| | | } |
| | | } |
| | | Double maxO3=0.0; |
| | | if(listArrayList.size()>0){ |
| | | List<Map<String, String>> mapList1 = listArrayList.get(0); |
| | | List<Double> O3List = new ArrayList(); |
| | | for (Map<String, String> stringStringMap : mapList1) { |
| | | O3List.add(Double.parseDouble(stringStringMap.get("O3-8h"))); |
| | | } |
| | | |
| | | maxO3 = Collections.max(O3List); |
| | | for (int i = 0; i <dataAvbByMIdAndTime.size() ; i++) { |
| | | dataAvbByMIdAndTime.get(i).put("O3-8h",null); |
| | | int time = Integer.parseInt(((Object)dataAvbByMIdAndTime.get(i).get("time")).toString().substring(11,13)) ; |
| | | for (int j = 0; j <mapList1.size() ; j++) { |
| | | int time1 = Integer.parseInt(mapList1.get(j).get("time").toString()) ; |
| | | if (time==time1){ |
| | | Double O3_8h = Double.parseDouble(mapList1.get(j).get("O3-8h").toString()); |
| | | dataAvbByMIdAndTime.get(i).put("O3-8h",new BigDecimal(O3_8h).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Map<String, Object> dailyAvgData = historyMapper.getDailyAvgData(mId, startTime); |
| | | if (dailyAvgData!=null){ |
| | | dailyAvgData.put("maxO3-8h",new BigDecimal(maxO3).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | dailyAvgData.put("time",startTime); |
| | | } |
| | | if (dataAvbByMIdAndTime.size()>24){ |
| | | for (int i = 0; i <dataAvbByMIdAndTime.size()-1 ; i++) { |
| | | Map<String, Object> map =dataAvbByMIdAndTime.get(i); |
| | | Map<String, Object> map1 = AQICalculation2.hourlyAQI(map); |
| | | dataAvbByMIdAndTime.get(i).put("AQI",Double.parseDouble(map1.get("AQI").toString())); |
| | | if (Double.parseDouble(map1.get("AQI").toString())>=50){ |
| | | String name = map1.get("maxSensor").toString(); |
| | | dataAvbByMIdAndTime.get(i).put("首要污染物",name); |
| | | }else { |
| | | dataAvbByMIdAndTime.get(i).put("首要污染物","-"); |
| | | } |
| | | } |
| | | }else { |
| | | for (int i = 0; i <dataAvbByMIdAndTime.size() ; i++) { |
| | | Map<String, Object> map =dataAvbByMIdAndTime.get(i); |
| | | Map<String, Object> map1 = AQICalculation2.hourlyAQI(map); |
| | | dataAvbByMIdAndTime.get(i).put("AQI",Double.parseDouble(map1.get("AQI").toString())); |
| | | if (Double.parseDouble(map1.get("AQI").toString())>=50){ |
| | | String name = map1.get("maxSensor").toString(); |
| | | dataAvbByMIdAndTime.get(i).put("首要污染物",name); |
| | | }else { |
| | | dataAvbByMIdAndTime.get(i).put("首要污染物","-"); |
| | | } |
| | | } |
| | | } |
| | | Map<String, Object> dayAQI = AQICalculation2.dayAQI(dailyAvgData); |
| | | dailyAvgData.put("首要污染物",dayAQI.get("maxSensor")); |
| | | dailyAvgData.put("AQI",dayAQI.get("AQI")); |
| | | dataAvbByMIdAndTime.add(dataAvbByMIdAndTime.size(),dailyAvgData); |
| | | |
| | | List<Map> finalList = new ArrayList<>(); |
| | | for (int i = 0; i <dataAvbByMIdAndTime.size() ; i++) { |
| | | Map timeAndDate = new HashMap(); |
| | | if (i!=dataAvbByMIdAndTime.size()-1){ |
| | | String time = dataAvbByMIdAndTime.get(i).get("time").toString().substring(11,13); |
| | | dataAvbByMIdAndTime.get(i).remove("time"); |
| | | timeAndDate.put("time",time); |
| | | timeAndDate.put("data",dataAvbByMIdAndTime.get(i)); |
| | | finalList.add(timeAndDate); |
| | | }else { |
| | | String time = dataAvbByMIdAndTime.get(i).get("time").toString().substring(0,11); |
| | | dataAvbByMIdAndTime.get(i).remove("time"); |
| | | timeAndDate.put("time",time); |
| | | timeAndDate.put("data",dataAvbByMIdAndTime.get(i)); |
| | | finalList.add(timeAndDate); |
| | | } |
| | | } |
| | | return finalList; |
| | | } |
| | | |
| | | @Override |
| | | public Point getDirPoint(Map<String, Object> parameters) throws Exception { |
| | | Map<String, Object> pollutionSourceData = getPollutionSourceDataByHour(parameters); |
| | | if (MapUtils.isEmpty(pollutionSourceData)) { |
| | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getAllDeviceDataToExcel(Map<String, Object> parameters) throws Exception { |
| | | Calendar cal = Calendar.getInstance(); |
| | | int length = ((String) parameters.get("startTime")).split("-").length; |
| | | String time = parameters.remove("startTime").toString(); |
| | | String timeb; |
| | | if (parameters.get("endTime") == null) { |
| | |
| | | } else { |
| | | timeb = parameters.remove("endTime").toString(); |
| | | } |
| | | String dateFormat = ""; |
| | | String typeFormat = ""; |
| | | String timeUnits = "daily"; |
| | | int i = 0; |
| | | if (length == 1) { |
| | | dateFormat = "yyyy"; |
| | | typeFormat = "%Y"; |
| | | i = Calendar.YEAR; |
| | | } else if (length == 2) { |
| | | dateFormat = "yyyy-MM"; |
| | | typeFormat = "%Y-%m"; |
| | | i = Calendar.MONTH; |
| | | } else if (length == 3) { |
| | | dateFormat = "yyyy-MM-dd"; |
| | | typeFormat = "%Y-%m-%d"; |
| | | i = Calendar.DAY_OF_MONTH; |
| | | } else if (length == 4) { |
| | | dateFormat = "yyyy-MM-dd HH"; |
| | | typeFormat = "%Y-%m-%d %H"; |
| | | timeUnits = "hourly"; |
| | | i = Calendar.HOUR_OF_DAY; |
| | | time = time.substring(0, 10) + " " + time.substring(11, 13); |
| | | timeb = timeb.substring(0, 10) + " " + timeb.substring(11, 13); |
| | | } |
| | | parameters.put("time", time); |
| | | parameters.put("timeb", timeb); |
| | | Calendar cal = Calendar.getInstance(); |
| | | int length = time.length(); |
| | | String type = ""; |
| | | if (length == 10) { |
| | | type = "day"; |
| | | } else if (length == 7) { |
| | | type = "month"; |
| | | } else if (length == 4) { |
| | | type = "year"; |
| | | } else if (length == 13) { |
| | | type = "hour"; |
| | | } |
| | | parameters.put("type", type); |
| | | String[] endTimes = timeb.split("-"); |
| | | String dateFormat = ""; |
| | | String beginTime = ""; |
| | | String endTime = ""; |
| | | Integer year = Integer.valueOf(endTimes[0]); |
| | | int i = 0; |
| | | if (type.equals("year")) { |
| | | dateFormat = "yyyy-MM"; |
| | | beginTime = time + "-01"; |
| | | timeb = Integer.valueOf(timeb) + 1 + ""; |
| | | endTime = timeb + "-01"; |
| | | i = Calendar.MONTH; |
| | | } else if (type.equals("month")) { |
| | | dateFormat = "yyyy-MM-dd"; |
| | | beginTime = time + "-01"; |
| | | i = Calendar.DAY_OF_MONTH; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); |
| | | cal.setTime(sdf.parse(timeb)); |
| | | cal.add(Calendar.MONTH, 1); |
| | | timeb = sdf.format(cal.getTime()); |
| | | endTime = timeb + "-01"; |
| | | } else if (type.equals("day")) { |
| | | dateFormat = "yyyy-MM-dd HH"; |
| | | beginTime = time + " 00"; |
| | | i = Calendar.HOUR_OF_DAY; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | cal.setTime(sdf.parse(timeb)); |
| | | cal.add(Calendar.DAY_OF_MONTH, 1); |
| | | timeb = sdf.format(cal.getTime()); |
| | | endTime = timeb + " 00"; |
| | | } else if (type.equals("hour")) { |
| | | dateFormat = "yyyy-MM-dd HH:mm"; |
| | | beginTime = time + ":00:00"; |
| | | i = Calendar.MINUTE; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH"); |
| | | cal.setTime(sdf.parse(timeb)); |
| | | cal.add(Calendar.HOUR_OF_DAY, 1); |
| | | timeb = sdf.format(cal.getTime()); |
| | | endTime = timeb + ":00:00"; |
| | | } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); |
| | | cal.setTime(sdf.parse(beginTime)); |
| | | cal.setTime(sdf.parse(timeb)); |
| | | cal.add(i, 1); |
| | | Date endTime = cal.getTime(); |
| | | parameters.put("format", dateFormat); |
| | | parameters.put("typeFormat", typeFormat); |
| | | parameters.put("timeUnits", timeUnits); |
| | | parameters.put("field", i); |
| | | cal.setTime(sdf.parse(time)); |
| | | List<String> times = new ArrayList<>(); |
| | | for (long d = cal.getTimeInMillis(); d < sdf.parse(endTime).getTime(); cal.set(i, cal.get(i) + 1), d = cal.getTimeInMillis()) { |
| | | for (long d = cal.getTimeInMillis(); d < endTime.getTime(); cal.set(i, cal.get(i) + 1), d = cal.getTimeInMillis()) { |
| | | String format = sdf.format(d); |
| | | times.add(format); |
| | | } |
| | |
| | | List<String> keys = Arrays.asList(sensorKeys); |
| | | parameters.put("sensors", keys); |
| | | parameters.put("sensorKeys", keys); |
| | | parameters.put("timeb", timeb); |
| | | parameters.put("timeb", sdf.format(endTime)); |
| | | int mpId = Integer.valueOf(parameters.get("monitorPoint").toString()); |
| | | String monitorPointName = monitorPointMapper.getMonitorName(mpId); |
| | | List<Map<String, Object>> devices = deviceMapper.getDevicesByMpId(mpId); |
| | |
| | |
|
| | | //实测天气
|
| | | int x = 0;
|
| | | parameters.put("cityCode", code);
|
| | | List<Map<String, Object>> realList = realWeatherMapper.getRealWeather(parameters);
|
| | | if (realList.size() == 0) {
|
| | | //1-23点数据必然是同一个月份,最后一个可能是下一个月
|
| | |
| | | listMap.put("city", name);
|
| | | String time1 = listMap.get("time").toString();
|
| | | for (Map<String, Object> aqiMap : realAqilist) {
|
| | | if(time1.equals(aqiMap.get("time"))){
|
| | | if (time1.equals(aqiMap.get("time"))) {
|
| | | listMap.putAll(aqiMap);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | //地理特征
|
| | | Map<String, Object> geographyMap = shAreaMapper.getGeography(name);
|
| | | for (Map<String, Object> map : resultList) {
|
| | | double longitude = Double.valueOf(geographyMap.get("lng").toString());
|
| | | double latitude = Double.valueOf(geographyMap.get("lat").toString());
|
| | | map.put("longitude", df.format(longitude));
|
| | | map.put("latitude", df.format(latitude));
|
| | | if (geographyMap.get("altitude") != null) {
|
| | | map.put("altitude", geographyMap.get("altitude").toString());
|
| | | if (geographyMap != null) {
|
| | | for (Map<String, Object> map : resultList) {
|
| | | if (geographyMap.get("lng") != null) {
|
| | | double longitude = Double.valueOf(geographyMap.get("lng").toString());
|
| | | map.put("longitude", df.format(longitude));
|
| | | }
|
| | | if (geographyMap.get("lat") != null) {
|
| | | double latitude = Double.valueOf(geographyMap.get("lat").toString());
|
| | | map.put("latitude", df.format(latitude));
|
| | | }
|
| | | if (geographyMap.get("altitude") != null) {
|
| | | map.put("altitude", geographyMap.get("altitude").toString());
|
| | | }
|
| | | if (geographyMap.get("vegetation") != null) {
|
| | | map.put("vegetation", geographyMap.get("vegetation").toString());
|
| | | }
|
| | | if (geographyMap.get("river") != null) {
|
| | | map.put("river", geographyMap.get("river").toString());
|
| | | }
|
| | | }
|
| | | if (geographyMap.get("vegetation") != null) {
|
| | | map.put("vegetation", geographyMap.get("vegetation").toString());
|
| | | }
|
| | | if (geographyMap.get("river") != null) {
|
| | | map.put("river", geographyMap.get("river").toString());
|
| | | }
|
| | |
|
| | | for (int i = 0; i < resultList.size(); i = i + 2) {
|
| | | Map<String, Object> foreMap = resultList.get(i);
|
| | | Map<String, Object> realMap = resultList.get(i + 1);
|
| | | if (foreMap.get("O3C") != null && realMap.get("O3C") != null) {
|
| | | Double foreO3 = Double.valueOf(foreMap.get("O3C").toString());
|
| | | Double realO3 = Double.valueOf(realMap.get("O3C").toString());
|
| | | int round = (int) Math.round((realO3 - foreO3) / realO3 * 100);
|
| | | if (round < 0) {
|
| | | round = -round;
|
| | | }
|
| | | realMap.put("errorRate", round + "%");
|
| | | }
|
| | | }
|
| | | return resultList;
|
New file |
| | |
| | | package com.moral.util; |
| | | |
| | | import java.util.*; |
| | | |
| | | public class AQICalculation2 { |
| | | |
| | | public static Map<String, Object> hourlyAQI(Map<String, Object> map){ |
| | | List<Double> AQIList = new ArrayList<>(); |
| | | Map maxMap = new HashMap(); |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String key = entry.getKey(); |
| | | if (entry.getValue() instanceof Double){ |
| | | Double value = Double.parseDouble(entry.getValue().toString()); |
| | | if (key!="O3-8h"){ |
| | | maxMap.put(key,value); |
| | | } |
| | | Double PM2_5AQI; |
| | | Double PM10AQI; |
| | | Double SO2AQI; |
| | | Double NO2AQI; |
| | | Double COAQI; |
| | | Double O3AQI; |
| | | switch (key) { |
| | | case "PM2_5":PM2_5AQI = PM2_5AQI(value); |
| | | AQIList.add(PM2_5AQI); |
| | | break; |
| | | case "PM10":PM10AQI = PM10AQI(value); |
| | | AQIList.add(PM10AQI); |
| | | break; |
| | | case "SO2":SO2AQI = SO2AQI(value); |
| | | AQIList.add(SO2AQI); |
| | | break; |
| | | case "e16":NO2AQI = NO2AQI(value); |
| | | AQIList.add(NO2AQI); |
| | | break; |
| | | case "CO":COAQI = COAQI(value); |
| | | AQIList.add(COAQI); |
| | | break; |
| | | case "O3":O3AQI = O3AQI(value); |
| | | AQIList.add(O3AQI); |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | Double AQIMAX = Collections.max(AQIList); |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | //System.out.println("-------"+maxMap); |
| | | Optional<Map.Entry<String, Integer>> max0 = maxMap.entrySet() |
| | | .stream() |
| | | .max(Map.Entry.comparingByValue()); |
| | | //System.out.println("-------"+max0.get().getKey()); |
| | | |
| | | returnMap.put("maxSensor",max0.get().getKey()); |
| | | returnMap.put("AQI", AQIMAX); |
| | | return returnMap; |
| | | } |
| | | public static Map<String, Object> dayAQI(Map<String, Object> map){ |
| | | List<Double> AQIList = new ArrayList<>(); |
| | | Map maxMap = new HashMap(); |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String key = entry.getKey(); |
| | | if (entry.getValue() instanceof Double){ |
| | | Double value = Double.parseDouble(entry.getValue().toString()); |
| | | if (key!="O3-day"){ |
| | | maxMap.put(key,value); |
| | | } |
| | | Double PM2_5AQI; |
| | | Double PM10AQI; |
| | | Double SO2AQI; |
| | | Double NO2AQI; |
| | | Double COAQI; |
| | | Double maxO38hAQI; |
| | | switch (key) { |
| | | case "PM2_5":PM2_5AQI = PM2_5AQI(value); |
| | | AQIList.add(PM2_5AQI); |
| | | break; |
| | | case "PM10":PM10AQI = PM10AQI(value); |
| | | AQIList.add(PM10AQI); |
| | | break; |
| | | case "SO2":SO2AQI = SO2DayAQI(value); |
| | | AQIList.add(SO2AQI); |
| | | break; |
| | | case "e16":NO2AQI = NO2DayAQI(value); |
| | | AQIList.add(NO2AQI); |
| | | break; |
| | | case "CO":COAQI = CODayAQI(value); |
| | | AQIList.add(COAQI); |
| | | break; |
| | | case "O3":maxO38hAQI = O3DayAQI(value); |
| | | AQIList.add(maxO38hAQI); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | Double AQIMAX = Collections.max(AQIList); |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | System.out.println("-------"+maxMap); |
| | | Optional<Map.Entry<String, Integer>> max0 = maxMap.entrySet() |
| | | .stream() |
| | | .max(Map.Entry.comparingByValue()); |
| | | //System.out.println("-------"+max0.get().getKey()); |
| | | |
| | | returnMap.put("maxSensor",max0.get().getKey()); |
| | | returnMap.put("AQI", AQIMAX); |
| | | return returnMap; |
| | | } |
| | | static double PM2_5AQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=35) { |
| | | result = 50/35*(value-0)+0; |
| | | }else if (value<=75) { |
| | | result = 50/40*(value-35)+50; |
| | | }else if (value<=115) { |
| | | result = 50/40*(value-75)+100; |
| | | }else if (value<=150) { |
| | | result = 50/35*(value-115)+150; |
| | | }else if (value<=250) { |
| | | result = 100/100*(value-150)+200; |
| | | }else if (value<=350) { |
| | | result = 100/100*(value-250)+300; |
| | | }else { |
| | | result = 100/150*(value-350)+400; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | static double PM10AQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=50) { |
| | | result = 50/50*(value-0)+0; |
| | | }else if (value<=150) { |
| | | result = 50/100*(value-50)+50; |
| | | }else if (value<=250) { |
| | | result = 50/100*(value-150)+100; |
| | | }else if (value<=350) { |
| | | result = 50/100*(value-250)+150; |
| | | }else if (value<=420) { |
| | | result = 100/70*(value-350)+200; |
| | | }else if (value<=500) { |
| | | result = 100/80*(value-420)+300; |
| | | }else { |
| | | result = 100/100*(value-500)+400; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | static double SO2AQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=150) { |
| | | result = 50/150*(value-0)+0; |
| | | }else if (value<=500) { |
| | | result = 50/350*(value-150)+50; |
| | | }else if (value<=650) { |
| | | result = 50/150*(value-500)+100; |
| | | }else { |
| | | result = 50/150*(value-650)+150; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | static double NO2AQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=100) { |
| | | result = 50/100*(value-0)+0; |
| | | }else if (value<=200) { |
| | | result = 50/100*(value-100)+50; |
| | | }else if (value<=700) { |
| | | result = 50/500*(value-200)+100; |
| | | }else if (value<=1200) { |
| | | result = 50/500*(value-700)+150; |
| | | }else if (value<=2340) { |
| | | result = 100/1140*(value-1200)+200; |
| | | }else if (value<=3090) { |
| | | result = 100/750*(value-2340)+300; |
| | | }else { |
| | | result = 100/750*(value-3090)+400; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | static double COAQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=5) { |
| | | result = 50/5*(value-0)+0; |
| | | }else if (value<=10) { |
| | | result = 50/5*(value-5)+50; |
| | | }else if (value<=35) { |
| | | result = 50/25*(value-10)+100; |
| | | }else if (value<=60) { |
| | | result = 50/25*(value-35)+150; |
| | | }else if (value<=90) { |
| | | result = 100/30*(value-60)+200; |
| | | }else if (value<=120) { |
| | | result = 100/30*(value-90)+300; |
| | | }else { |
| | | result = 100/30*(value-120)+400; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | static double O3AQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=100) { |
| | | result = 50/160*(value-0)+0; |
| | | }else if (value<=160) { |
| | | result = 50/40*(value-160)+50; |
| | | }else if (value<=215) { |
| | | result = 50/100*(value-200)+100; |
| | | }else if (value<=265) { |
| | | result = 50/100*(value-300)+150; |
| | | }else if (value<=800) { |
| | | result = 100/400*(value-400)+200; |
| | | }else if (value<=2100) { |
| | | result = 100/200*(value-800)+300; |
| | | }else { |
| | | result = 100/200*(value-1000)+400; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | static double O3DayAQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=100) { |
| | | result = 50/100*(value-0)+0; |
| | | }else if (value<=160) { |
| | | result = 50/60*(value-100)+50; |
| | | }else if (value<=215) { |
| | | result = 50/55*(value-160)+100; |
| | | }else if (value<=265) { |
| | | result = 50/150*(value-215)+150; |
| | | }else if (value<=800) { |
| | | result = 100/535*(value-265)+200; |
| | | }else if (value<=2100) { |
| | | result = 100/12*(value-800)+300; |
| | | }else { |
| | | result = 100/12*(value-48)+400; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | static double SO2DayAQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=50) { |
| | | result = 50/50*(value-0)+0; |
| | | }else if (value<=150) { |
| | | result = 50/100*(value-50)+50; |
| | | }else if (value<=475) { |
| | | result = 50/325*(value-150)+100; |
| | | }else if (value<=800) { |
| | | result = 50/325*(value-475)+150; |
| | | }else if (value<=1600) { |
| | | result = 100/800*(value-800)+200; |
| | | }else if (value<=2100) { |
| | | result = 100/500*(value-1600)+300; |
| | | }else { |
| | | result = 100/520*(value-2100)+400; |
| | | } |
| | | return result; |
| | | } |
| | | static double NO2DayAQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=40) { |
| | | result = 50/40*(value-0)+0; |
| | | }else if (value<=80) { |
| | | result = 50/40*(value-40)+50; |
| | | }else if (value<=180) { |
| | | result = 50/100*(value-80)+100; |
| | | }else if (value<=280) { |
| | | result = 50/100*(value-180)+150; |
| | | }else if (value<=565) { |
| | | result = 100/285*(value-280)+200; |
| | | }else if (value<=750) { |
| | | result = 100/185*(value-565)+300; |
| | | }else { |
| | | result = 100/190*(value-750)+400; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | static double CODayAQI(Double value) { |
| | | Double result = (double) 0; |
| | | if(value<=0) { |
| | | result=(double) 0; |
| | | }else if (value<=5) { |
| | | result = 50/2*(value-0)+0; |
| | | }else if (value<=10) { |
| | | result = 50/2*(value-2)+50; |
| | | }else if (value<=35) { |
| | | result = 50/10*(value-4)+100; |
| | | }else if (value<=60) { |
| | | result = 50/10*(value-14)+150; |
| | | }else if (value<=90) { |
| | | result = 100/12*(value-24)+200; |
| | | }else if (value<=120) { |
| | | result = 100/12*(value-36)+300; |
| | | }else { |
| | | result = 100/12*(value-48)+400; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.mapper.DeviceAdjustValueTimingMapper"> |
| | | <resultMap id="BaseResultMap" type="com.moral.entity.DeviceAdjustValueTiming" > |
| | | <id column="id" property="id" jdbcType="INTEGER" /> |
| | | <result column="device_id" property="deviceId" jdbcType="INTEGER" /> |
| | | <result column="value" jdbcType="OTHER" property="value" javaType="java.util.Map" typeHandler="AdjustValueTypeHandle" /> |
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <delete id="delete"> |
| | | delete from device_adjust_value_timing where id=#{id} |
| | | </delete> |
| | | <select id="selectAllByDeviceid" resultType="com.moral.entity.DeviceAdjustValueTiming" resultMap="BaseResultMap"> |
| | | SELECT * FROM device_adjust_value_timing |
| | | WHERE device_id = #{device_id} |
| | | </select> |
| | | |
| | | <!--根据device_id和seconds查询--> |
| | | <select id="selectAllByDeviceidAndSeconds" resultType="java.util.Map"> |
| | | SELECT * FROM device_adjust_value_timing |
| | | WHERE device_id = #{device_id} |
| | | AND seconds = #{seconds} |
| | | </select> |
| | | |
| | | <!--插入数据--> |
| | | <insert id="insertData"> |
| | | INSERT INTO device_adjust_value_timing (device_id,seconds,value,create_time) |
| | | VALUES(#{device_id},#{seconds},#{value},#{create_time}) |
| | | </insert> |
| | | |
| | | <!--更新数据--> |
| | | <update id="upDataByDeviceid"> |
| | | UPDATE device_adjust_value_timing |
| | | SET value = #{value},update_time = #{update_time} |
| | | WHERE device_id = #{device_id} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | as windSpeed, h.json->"$.e23[0]" as windDir, |
| | | h.json->"$.e17[0]" as tVoc |
| | | from ${table} h ,`device` as d |
| | | where d.mac=h.mac and d.mac=#{mac} and h.time=#{time} |
| | | where d.mac=h.mac and d.mac=#{mac} and h.time=(select max(time) from ${table}) |
| | | </select> |
| | | <select id="byMonitorIdGetDeviceAndWind" resultType="com.moral.entity.DeviceAndWind"> |
| | | select d.longitude as longitude,d.latitude as latitude, |
| | |
| | | as windSpeed, h.json->"$.e23[0]" as windDir, |
| | | h.json->"$.e17[0]" as tVoc |
| | | from ${table} as h ,`device` as d |
| | | where d.mac=h.mac and h.time=#{time} |
| | | where d.mac=h.mac and h.time=(select max(time) from ${table}) |
| | | and d.mac in (select d.mac from device , monitor_point as m where d.monitor_point_id=m.id and m.id=#{id}) |
| | | </select> |
| | | |
| | |
| | | <select id="getDeviceById1" resultType="com.moral.entity.Device"> |
| | | SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=1 and d.monitor_point_id=#{id} |
| | | </select> |
| | | <select id="getDeviceById2" resultType="com.moral.entity.Device"> |
| | | SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=2 and d.monitor_point_id=#{id} |
| | | <select id="getDeviceById2" resultType="com.moral.entity.Device"> |
| | | SELECT d.* |
| | | FROM `device` as d,monitor_point as mp,device_property as dp |
| | | where d.monitor_point_id=mp.id |
| | | and d.id=dp.id |
| | | and dp.device_tech=2 |
| | | and d.monitor_point_id=#{id} |
| | | </select> |
| | | <select id="getDeviceById3" resultType="com.moral.entity.Device"> |
| | | SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=3 and d.monitor_point_id=#{id} |
| | |
| | | as windSpeed, h.json->"$.e23[0]" as windDir, |
| | | h.json->"$.e17[0]" as tVoc |
| | | from ${table} as h ,`device` as d |
| | | where d.mac=h.mac and h.time=#{time} |
| | | where d.mac=h.mac and h.time=(select max(time) from ${table}) |
| | | and d.mac=#{mac} |
| | | </select> |
| | | <select id="getDeviceByCodeAndId" resultType="com.moral.entity.Device" resultMap="BaseResultMap"> |
| | |
| | | <select id="getDevicesByMpId" resultType="java.util.Map"> |
| | | select name,mac from device where monitor_point_id=#{mpId} and is_delete=0 |
| | | </select> |
| | | <select id="getDevice" resultType="com.moral.entity.Device"> |
| | | select * from device |
| | | where mac like concat('%',#{macOrName},'%') |
| | | </select> |
| | | <select id="getDeviceByCityCode" resultType="com.moral.entity.Device"> |
| | | SELECT d.* FROM `monitor_point` mt,device d where d.monitor_point_id=mt.id and d.state!=4 and mt.city_code=130900 |
| | | </select> |
| | | </mapper> |
| | |
| | | <select id="getDataByMacAndTime" resultType="java.util.Map"> |
| | | SELECT DATE_FORMAT(`time`,'%Y-%m-%d %H:%i:%s') as `time`,json->'$.${sensor}[0]' as ${sensor} FROM `history_hourly` where `mac`=#{mac} and `time`>=#{startTime} and `time`<#{endTime} |
| | | </select> |
| | | <select id="getDataByMacAndTime1" resultType="java.util.Map"> |
| | | SELECT DATE_FORMAT(`time`,'%Y-%m-%d %H:%i:%s') as `time`,json->'$.${sensor}[0]' as ${sensor} FROM `history_hourly` where `mac`=#{mac} and `time`>=#{startTime} and `time`<![CDATA[<]]>#{endTime} |
| | | </select> |
| | | <select id="getDataAvbByMIdAndTime" resultType="java.util.Map"> |
| | | select hh.time as `time`, |
| | | AVG(hh.json->"$.e1[0]") as `PM2_5`,AVG(hh.json->"$.e2[0]") as 'PM10',AVG(hh.json->"$.e10[0]") as 'CO', |
| | | AVG(hh.json->"$.e11[0]") as 'SO2',AVG(hh.json->"$.e16[0]") as 'NO2',AVG(hh.json->"$.e15[0]") as 'O3' |
| | | from monitor_point mt,device d,history_hourly hh |
| | | where mt.id=d.monitor_point_id and d.mac=hh.mac and mt.id=#{mId} and hh.time>#{startTime} and hh.time<![CDATA[<=]]>#{endTime} GROUP BY hh.time; |
| | | </select> |
| | | </mapper> |
| | |
| | | where mac = #{mac} and time >= #{time1} and time <=#{time}
|
| | | limit 0,1
|
| | | </select>
|
| | | <select id="getDailyAvgData" resultType="java.util.Map">
|
| | | SELECT AVG(hd.json->"$.e1[0]") as `PM2_5`,AVG(hd.json->"$.e2[0]") as 'PM10',AVG(hd.json->"$.e10[0]") as 'CO',
|
| | | AVG(hd.json->"$.e11[0]") as 'SO2',AVG(hd.json->"$.e16[0]") as 'NO2',AVG(hd.json->"$.e15[0]") as 'O3-day'
|
| | | FROM `history_daily` hd,monitor_point mt,device d where mt.id=d.monitor_point_id
|
| | | and d.mac=hd.mac and mt.id=#{mId} and time=#{time}
|
| | | </select>
|
| | |
|
| | | </mapper> |
| | |
| | | state = state == null ? 0 : state; |
| | | var icon = _option["icon"]; |
| | | //var url = icon["stateIcons"][state]; |
| | | var url = icon["url"] + state + ".png"; |
| | | if (state==5 || state==6){ |
| | | var url = icon["url"] + "0"+state + ".png"; |
| | | }else { |
| | | var url = icon["url"] + state + ".png"; |
| | | } |
| | | return new BMap.Icon(url, new BMap.Size(icon["width"], icon["height"]), { |
| | | imageSize: new BMap.Size(icon["width"], icon["height"]) |
| | | }); |
| | |
| | | } |
| | | } |
| | | var icon = {}; |
| | | icon["stateIcons"] = ["/img/ico00.png", "/img/ico01.png", "/img/ico02.png", "/img/ico03.png", "/img/ico04.png"]; |
| | | icon["stateIcons"] = ["/img/ico00.png", "/img/ico01.png", "/img/ico02.png", "/img/ico03.png", "/img/ico04.png","/img/ico05.png", "/img/ico06.png"]; |
| | | icon["url"] = "/img/ico0"; |
| | | icon["width"] = 50; |
| | | icon["height"] = 50; |
| | |
| | | } |
| | | } |
| | | var icon = {}; |
| | | icon["stateIcons"] = ["/img/ico00.png", "/img/ico01.png", "/img/ico02.png", "/img/ico03.png", "/img/ico04.png"]; |
| | | icon["stateIcons"] = ["/img/ico00.png", "/img/ico01.png", "/img/ico02.png", "/img/ico03.png", "/img/ico04.png","/img/ico005.png", "/img/ico006.png"]; |
| | | icon["url"] = "/img/ico0"; |
| | | icon["width"] = 50; |
| | | icon["height"] = 50; |