| | |
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Optional;
|
| | | import java.util.Set;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | |
| | | resultMap.put("accountId", -1);
|
| | | } else {
|
| | | resultMap = accountService.screenLogin(parameters);
|
| | | // 添加返回行政区信息字符串操作
|
| | | Object orgId = resultMap.get("orgId");
|
| | | if (resultMap.get("orgId") != null && resultMap.get("orgId") instanceof Integer) {
|
| | | StringBuilder areaNamesBuilder = new StringBuilder("中国");
|
| | | if (!((Integer) orgId).equals(dictionaryDataService.querySupperOrgId())) {
|
| | | Organization organization = organizationService.getOrganizationById((Integer) orgId);
|
| | | if (organization.getAreaNames() != null) {
|
| | | Map<String, String> areaNameMap = BeanUtils.beanToMap(organization.getAreaNames());
|
| | | List<String> names = areaNameMap.entrySet().stream().filter(item -> {
|
| | | return item.getValue() != null;
|
| | | }).map(item -> {
|
| | | return item.getValue();
|
| | | }).collect(Collectors.toList());
|
| | | AreaNames areaNames = organization.getAreaNames();
|
| | | areaNamesBuilder.append("/");
|
| | | areaNamesBuilder.append(String.join("/", names));
|
| | | }
|
| | | // 企业用户
|
| | | if (organization.getRank() != null && organization.getRank() == 0) {
|
| | | resultMap.put("type", "enterprise");
|
| | | } else {
|
| | | resultMap.put("type", "government");
|
| | | }
|
| | | Number mapAreaCode = null;
|
| | | if (organization.getVillageCode() != null) {
|
| | | mapAreaCode = organization.getVillageCode();
|
| | | } else if (organization.getTownCode() != null) {
|
| | | mapAreaCode = organization.getTownCode();
|
| | | } else if (organization.getAreaCode() != null) {
|
| | | mapAreaCode = organization.getAreaCode();
|
| | | } else if (organization.getCityCode() != null) {
|
| | | mapAreaCode = organization.getCityCode();
|
| | | } else if (organization.getProvinceCode() != null) {
|
| | | mapAreaCode = organization.getProvinceCode();
|
| | | }
|
| | | resultMap.put("mapAreaCode", mapAreaCode.toString());
|
| | | }
|
| | | resultMap.put("mapPath", areaNamesBuilder.toString());
|
| | | }
|
| | | }
|
| | | return resultMap;
|
| | | }
|
| | |
|
| | | @GetMapping("loginNew")
|
| | | public Map<String, Object> screenLoginNew(HttpServletRequest request) {
|
| | | Map<String, Object> resultMap = new HashMap<String, Object>();
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | if (!(parameters.containsKey("account") && parameters.containsKey("password"))) {
|
| | | resultMap.put("msg", "用户名及密码不允许为空!");
|
| | | resultMap.put("accountId", -1);
|
| | | } else {
|
| | | resultMap = accountService.screenLoginNew(parameters);
|
| | | // 添加返回行政区信息字符串操作
|
| | | Object orgId = resultMap.get("orgId");
|
| | | if (resultMap.get("orgId") != null && resultMap.get("orgId") instanceof Integer) {
|
| | |
| | | model.setViewName("403");
|
| | | return model;
|
| | | }
|
| | | }
|
| | |
|
| | | @GetMapping("/getSensorsMap")
|
| | | public List<Map<String, String>> getSensorsMapOnly(String mac) {
|
| | | List<Map<String, String>> sensorsMapList = sensorService.getSensorsMaps(mac);
|
| | | return sensorsMapList;
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/get-monitorpoints", method = RequestMethod.GET)
|
| | |
| | | String monitor_point_id = (String) parameters.get("monitor_point_id");
|
| | | List<Map<String, Object>> list = sensorService.getSensorByMonitorPointId(monitor_point_id);
|
| | | List<Map<String, Object>> sensorUnitList = sensorUnitService.getSensorsByMonitPointId2(monitor_point_id);
|
| | | System.out.println("list:"+list);
|
| | | System.out.println("sensorUnitList:"+sensorUnitList);
|
| | | System.out.println("list:" + list);
|
| | | System.out.println("sensorUnitList:" + sensorUnitList);
|
| | | for (Map<String, Object> sensorMap : list) {
|
| | | for (Map<String, Object> sensorUnitMap : sensorUnitList) {
|
| | | if (sensorUnitMap.get("sensor_key").equals(sensorMap.get("sensorKey"))) {
|
| | |
| | | String intoTime = parameters.get("time").toString();
|
| | | Date date = new SimpleDateFormat("yy-MM-dd").parse(intoTime);
|
| | | DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd");
|
| | | String alterTime = df1.format(date.getTime()-15*24*60*60*1000);
|
| | | String alterTime = df1.format(date.getTime() - 15 * 24 * 60 * 60 * 1000);
|
| | | parameters.put("time", alterTime);
|
| | | ParameterUtils.getTimeType4Time(parameters);
|
| | | String monitor_point_id = (String) parameters.get("monitorPoint");
|
| | |
| | | Map<String, Object> weatherMap = new HashMap<>();
|
| | | Map<String, Object> tempMap = new HashMap<>();
|
| | | Boolean tf = false;
|
| | | for(int i=0;i<sensorKeys.length;i++) {
|
| | | if(sensorKeys[i].equals("e7")) {
|
| | | tf = true;
|
| | | }
|
| | | for (int i = 0; i < sensorKeys.length; i++) {
|
| | | if (sensorKeys[i].equals("e7")) {
|
| | | tf = true;
|
| | | }
|
| | | }
|
| | | if (tf) {
|
| | | weatherMap = weatherService.get15DayWeatherDataByRegion(weatherParameters);
|
| | | tempMap = TempAllocationUtils.tempAllocation(weatherMap);
|
| | | }
|
| | | }
|
| | | //获取单位信息
|
| | | Map<String, Map<String, Object>> sensorUnitMap = sensorUnitService.getSensorsByMonitPointId(monitor_point_id);
|
| | |
|
| | |
| | | String time = map.get("time").toString();
|
| | | time = time.substring(time.length() - 2);
|
| | | map.put("time", Integer.valueOf(time));
|
| | | if (tempMap!=null) {
|
| | | map.put("temp", tempMap.get(map.get("time").toString()));
|
| | | }
|
| | | if (tempMap != null) {
|
| | | map.put("temp", tempMap.get(map.get("time").toString()));
|
| | | }
|
| | | List<Number> values = new ArrayList<Number>();
|
| | | List<String> units = new ArrayList<String>();
|
| | | for (String string : sensorKeys) {
|
| | |
| | | return new ResultBean<List<Map<String, Object>>>(returnList);
|
| | | }
|
| | |
|
| | | @GetMapping("/carTrajectory")
|
| | | @ApiOperation(value = "显示走航车轨迹", notes = "显示走航车轨迹")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "mac", value = "设备mac(格式:p5dnd7a0392082)", required = true, paramType = "query", dataType = "String"),
|
| | | @ApiImplicitParam(name = "startTime", value = "开始时间(格式:2020-03-19-14)", required = true, paramType = "query", dataType = "String"),
|
| | | @ApiImplicitParam(name = "endTime", value = "结束时间(格式:2020-03-19-17)", required = true, paramType = "query", dataType = "String")
|
| | | })
|
| | | public ModelAndView carTrajectory(ModelAndView model, HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | String st = parameters.get("startTime").toString();
|
| | | String startYearAndDay = st.substring(0, st.lastIndexOf("-"));
|
| | | String startHour = st.substring(st.lastIndexOf("-") + 1);
|
| | | String startTime = startYearAndDay + " " + startHour + ":00:00";
|
| | | String et = parameters.get("endTime").toString();
|
| | | String endYearAndDay = et.substring(0, et.lastIndexOf("-"));
|
| | | String endHour = et.substring(et.lastIndexOf("-") + 1);
|
| | | String endTime = endYearAndDay + " " + endHour + ":00:00";
|
| | | parameters.put("startTime", startTime);
|
| | | parameters.put("endTime", endTime);
|
| | | String mac = parameters.get("mac").toString();
|
| | | if (mac != null && mac.length() != 0) {
|
| | | List<List<Map<String, Object>>> sensorData = historyService.getCarSensorData(parameters);
|
| | | Map<String, String> sensorsMap = sensorService.getSensorsMap(parameters);
|
| | | List<Map<String, Object>> sensorList = new ArrayList<>();
|
| | | if (sensorData.size() == 3) {
|
| | | sensorList = sensorData.get(0);
|
| | | }
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("sensorInfo", sensorList);
|
| | | params.put("sensorsMap", sensorsMap);
|
| | | String paramsJson = params.toJSONString();
|
| | | model.addObject("carTrajectoryParams", paramsJson);
|
| | | model.setViewName("cartrajectory");
|
| | | return model;
|
| | | } else {
|
| | | StringBuilder msg = new StringBuilder();
|
| | | msg.append(" param[0] mac:");
|
| | | msg.append(mac);
|
| | | log.warn(msg);
|
| | | model.setViewName("403");
|
| | | return model;
|
| | | }
|
| | | }
|
| | |
|
| | | @GetMapping("device-excel")
|
| | | @ApiOperation(value = "获取设备数据报表", notes = "获取设备数据报表")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "sensorKey", value = "传感器key", required = true, paramType = "query", dataType = "String"),
|
| | | @ApiImplicitParam(name = "organizationId", defaultValue = "8", value = "登录账号的组织id", required = true, paramType = "query", dataType = "Integer"),
|
| | | @ApiImplicitParam(name = "regionCode", defaultValue = "320583", value = "区域码", required = true, paramType = "query", dataType = "String"),
|
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-04-09或2019-04)", required = true, paramType = "query", dataType = "String")})
|
| | | public ResultBean<List<Map<String, Object>>> getDevicesDataToExcel(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | ParameterUtils.getTimeType4Time(parameters);
|
| | | Object sensorKey = parameters.get("sensorKey");
|
| | | parameters.put("sensorKeys", Arrays.asList(sensorKey));
|
| | | List<String> macList = new ArrayList<>();
|
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(parameters);
|
| | | for (MonitorPoint m : monitorPoints) {
|
| | | for (Device d : m.getDevices()) {
|
| | | macList.add(d.getMac());
|
| | | }
|
| | | }
|
| | | parameters.put("macs", macList);
|
| | | List<Map<String, Object>> list = new ArrayList<>();
|
| | | if (!CollectionUtils.isEmpty(macList)) {
|
| | | list = historyMinutelyService.getDevicesAvgDataToExcel(parameters);
|
| | | }
|
| | | for (Map<String, Object> map : list) {
|
| | | map.put("value", map.remove(sensorKey));
|
| | | }
|
| | | return new ResultBean<List<Map<String, Object>>>(list);
|
| | | }
|
| | |
|
| | | }
|