Merge remote-tracking branch 'origin/wb' into qa
| | |
| | | if (!params.containsKey("monitorPointIds")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | String[] monitorPointIds = params.remove("monitorPointIds").toString().split(","); |
| | | String monitorPoint = params.remove("monitorPointIds").toString(); |
| | | /*if(monitorPoint.contains("")){ |
| | | |
| | | }*/ |
| | | String[] monitorPointIds = monitorPoint.split(","); |
| | | if (monitorPointIds.length > 3) { |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | params.put("monitorPointIds", monitorPointIds); |
| | | List<Object> response = historyFiveMinutelyService.getAreaWindData(params); |
| | | return ResultMessage.ok(response); |
| | |
| | | |
| | | @GetMapping("resultWord") |
| | | public void adresultWordd(HttpServletResponse response,String time,String endTime) { |
| | | // for(int i = 495;i<1095;i++){ |
| | | List<SysTest> listAll = sysTestService.listAll(time,endTime,null); |
| | | if(CollectionUtils.isEmpty(listAll)){ |
| | | return; |
| | | } |
| | | /* Date endTime =listAll.get(0).getTime(); |
| | | String endTimeStr = DateUtils.dateToDateString(endTime,DateUtils.yyyyMMdd_EN); |
| | | String ks = "2023-06-22"; |
| | | endTime = "2023-08-06"; |
| | | Date ksDate = DateUtils.convertDate(ks); |
| | | List<SysTest> listAll = sysTestService.listAll(ks,endTime,null); |
| | | if(CollectionUtils.isEmpty(listAll)){ |
| | | return; |
| | | } |
| | | for(SysTest s : listAll){ |
| | | Date endTimes =s.getTime(); |
| | | String endTimeStr = DateUtils.dateToDateString(endTimes,DateUtils.yyyyMMdd_EN); |
| | | String fileName = "空气质量日报.docx"; |
| | | Map<String,Object> map = resultMap(listAll); |
| | | downloadWord(fileName, map, response,"空气质量日报"+endTimeStr+".docx");*/ |
| | | // time = DateUtils.dateToDateString(DateUtils.addDays(endTime,1),DateUtils.yyyy_MM_dd_EN); |
| | | // } |
| | | downloadWord(fileName, map, response,"空气质量日报"+endTimeStr+".docx"); |
| | | //time = DateUtils.dateToDateString(DateUtils.addDays(endTime,1),DateUtils.yyyy_MM_dd_EN); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("excelM") |
| | |
| | | @GetMapping("resultWordMonth") |
| | | public void resultWordMonth(HttpServletResponse response) { |
| | | |
| | | String ks = "2020-06-01"; |
| | | String ks = "2023-07-01"; |
| | | Date ksDate = DateUtils.convertDate(ks); |
| | | for(int i = 0;i<37;i++){ |
| | | for(int i = 0;i<1;i++){ |
| | | Date jsDate = DateUtils.getLastDayOfCurrMonth(ksDate);; |
| | | String time = DateUtils.dateToDateString(ksDate,DateUtils.yyyy_MM_dd_EN); |
| | | String endTime = DateUtils.dateToDateString(jsDate,DateUtils.yyyy_MM_dd_EN); |
| | |
| | | String path = getPath(fileName);//我这放 resources包下 |
| | | try { |
| | | //获取模板文档 |
| | | OutputStream out = new FileOutputStream("E:\\home\\mon\\" + newFileName); |
| | | OutputStream out = new FileOutputStream("E:\\home\\mon1\\" + newFileName); |
| | | File rootFile = new File(ResourceUtils.getURL("classpath:").getPath()); |
| | | File file= new File(rootFile, path); |
| | | XWPFDocument word = WordExportUtil.exportWord07(file.getPath(), params); |
| | |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @TableField(exist = false) |
| | | private String mon; |
| | | |
| | | public String getPm25() { |
| | | return StringUtils.isEmpty(pm25)?"0":String.valueOf(Double.parseDouble(pm25)); |
| | | } |
| | | |
| | | public String getPm10() { |
| | | return StringUtils.isEmpty(pm10)?"0":String.valueOf(Double.parseDouble(pm10)); |
| | | } |
| | | |
| | | public String getSo2() { |
| | | return StringUtils.isEmpty(so2)?"0":String.valueOf(Double.parseDouble(so2)); |
| | | } |
| | | |
| | | public String getNo2() { |
| | | return StringUtils.isEmpty(no2)?"0":String.valueOf(Double.parseDouble(no2)); |
| | | } |
| | | |
| | | public String getCo() { |
| | | return StringUtils.isEmpty(co)?"0":String.valueOf(Double.parseDouble(co)); |
| | | } |
| | | |
| | | public String getO3() { |
| | | return StringUtils.isEmpty(o3)?"0":String.valueOf(Double.parseDouble(o3)); |
| | | } |
| | | |
| | | public String getVoc() { |
| | | return StringUtils.isEmpty(voc)?"0":String.valueOf(Double.parseDouble(voc)); |
| | | } |
| | | } |
| | |
| | | |
| | | QueryWrapper<Device> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("mac", "name").in("mac", macs); |
| | | queryWrapper.orderByAsc("dev_num","name","id"); |
| | | List<Device> devices = deviceMapper.selectList(queryWrapper); |
| | | Map<String,Object> devicesInfo = new HashMap<>(); |
| | | for (Device device:devices) { |
| | |
| | | for (HistoryHourly historyHourly:distinctHistoryHourlies) { |
| | | Map<String,Object> historyHourlyMap = new HashMap<>(); |
| | | historyHourlyMap.put("mac",mac); |
| | | JSONObject value = JSONObject.parseObject(historyHourly.getValue()); |
| | | Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); |
| | | JSONObject value= JSONObject.parseObject(historyHourly.getValue()); |
| | | Double sensorValue = Objects.nonNull(value)&&Objects.nonNull(value.get(sensorCode))?Double.parseDouble(value.get(sensorCode).toString()):0d; |
| | | historyHourlyMap.put(sensorCode,sensorValue); |
| | | Date time = historyHourly.getTime(); |
| | | String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_EN); |
| | |
| | | |
| | | void insertHistoryHourlyComplete(@Param("list") List<Map<String, Object>> list, @Param("timeUnits") String timeUnits); |
| | | |
| | | |
| | | void insertHistoryHourlyAvg(@Param("list") List<Map<String, Object>> list, @Param("timeUnits") String timeUnits); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | void dateToChangShu(String time); |
| | | |
| | | //计算海城市的小数数据 |
| | | void dateInsertHistoryHourlyAvg(); |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.config.mybatis.MybatisPlusConfig; |
| | | import com.moral.api.config.rest.Crc16Utils; |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.HistoryHourly; |
| | | import com.moral.api.entity.Sensor; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.HistoryHourlyMapper; |
| | | import com.moral.api.mapper.HistoryMinutelyMapper; |
| | | import com.moral.api.service.HistoryHourlyService; |
| | |
| | | private String dateChangShu; |
| | | @Autowired |
| | | private HistoryHourlyMapper historyHourlyMapper; |
| | | |
| | | @Autowired |
| | | private DeviceMapper deviceMapper; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | |
| | | |
| | | //存入小时表 |
| | | historyHourlyMapper.insertHistoryHourly(insertData); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | log.info("发送完成"); |
| | | } |
| | | |
| | | /** |
| | | * 计算海城市的小时数据 |
| | | */ |
| | | @Override |
| | | public void dateInsertHistoryHourlyAvg() { |
| | | QueryWrapper<Device> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("mac"); |
| | | wrapper.eq("organization_id",71); |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | List<Device> devices = deviceMapper.selectList(wrapper); |
| | | ArrayList<String> macs = new ArrayList<>(); |
| | | for (Device device : devices) { |
| | | macs.add(device.getMac()); |
| | | } |
| | | //时间格式化:yyyy-MM-dd HH:mm |
| | | String format = DateUtils.yyyy_MM_dd_HH_EN; |
| | | Date now = new Date(); |
| | | |
| | | //从数据库获取数据参数 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //开始时间 |
| | | Date start = DateUtils.dataToTimeStampTime(DateUtils.addHours(now, -1), format); |
| | | //结束时间 |
| | | Date end = DateUtils.dataToTimeStampTime(now, format); |
| | | // String start1= "2023-08-18 03:00:00"; |
| | | // String end1 = "2023-08-18 04:00:00"; |
| | | // Date date1 = DateUtils.getDate(start1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | // Date date2 = DateUtils.getDate(end1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | |
| | | params.put("start", start); |
| | | params.put("end", end); |
| | | params.put("macs",macs); |
| | | //获取数据的分钟表后缀 |
| | | String timeUnits = DateUtils.dateToDateString(start, DateUtils.yyyyMM_EN); |
| | | params.put("timeUnits", timeUnits); |
| | | |
| | | //因子 |
| | | QueryWrapper<Sensor> sensorQueryWrapper = new QueryWrapper<>(); |
| | | sensorQueryWrapper.select("code", "lower", "upper").eq("is_delete", Constants.NOT_DELETE); |
| | | List<Sensor> sensors = sensorService.list(sensorQueryWrapper); |
| | | // 获取海城设备的一小时内分钟的数据 |
| | | List<Map<String, Object>> hourlyData = historyMinutelyMapper.getHistoryMinutelyData(params); |
| | | if (ObjectUtils.isEmpty(hourlyData)) { |
| | | return; |
| | | } |
| | | //按mac分组 |
| | | Map<String, List<Map<String, Object>>> data = hourlyData.parallelStream() |
| | | .collect(Collectors.groupingBy(o -> (String) o.get("mac"))); |
| | | //存入数据库的结果集 |
| | | List<Map<String, Object>> insertData = new ArrayList<>(); |
| | | data.forEach((key, value) -> { |
| | | Map<String, Object> historyHourly = new HashMap<>(); |
| | | historyHourly.put("mac", key); |
| | | historyHourly.put("time",start); |
| | | |
| | | Map<String, Object> jsonMap = new HashMap<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", value); |
| | | map.put("type", "hour"); |
| | | |
| | | for (Sensor sensor : sensors) { |
| | | String sensorCode = sensor.getCode(); |
| | | |
| | | //风向上下限 |
| | | if (sensorCode.equals(Constants.SENSOR_CODE_WIND_DIR)) { |
| | | if (sensor.getUpper() != null) { |
| | | map.put("windDirUpper", sensor.getUpper()); |
| | | } |
| | | if (sensor.getLower() != null) { |
| | | map.put("windDirLower", sensor.getLower()); |
| | | } |
| | | } |
| | | |
| | | //风速上下限 |
| | | if (sensorCode.equals(Constants.SENSOR_CODE_WIND_SPEED)) { |
| | | if (sensor.getUpper() != null) { |
| | | map.put("windSpeedUpper", sensor.getUpper()); |
| | | } |
| | | if (sensor.getLower() != null) { |
| | | map.put("windSpeedLower", sensor.getLower()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //风向均值计算并修约 |
| | | Map<String, Object> windDirAvg = AmendUtils.getWindDirAvg(map); |
| | | if (!ObjectUtils.isEmpty(windDirAvg)) { |
| | | jsonMap.putAll(windDirAvg); |
| | | } |
| | | |
| | | //除风向外其他因子均值计算 |
| | | sensors.forEach(sensor -> { |
| | | String sensorCode = sensor.getCode(); |
| | | Double upper = sensor.getUpper(); |
| | | Double lower = sensor.getLower(); |
| | | AtomicInteger size = new AtomicInteger(); |
| | | DoubleStream optionalDouble = value.parallelStream() |
| | | .flatMapToDouble(v -> { |
| | | Map<String, Object> dataValue = JSONObject.parseObject((String) v.get("value"), Map.class); |
| | | Object sensorValue = dataValue.get(sensorCode); |
| | | //数据有效性标记位 |
| | | Object flag = dataValue.get(sensorCode + "-" + Constants.MARKER_BIT_KEY); |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flag)) { |
| | | return null; |
| | | } |
| | | |
| | | if (ObjectUtils.isEmpty(sensorValue)) { |
| | | return null; |
| | | } |
| | | |
| | | //风向单独计算 |
| | | if (Constants.SENSOR_CODE_WIND_DIR.equals(sensorCode)) { |
| | | return null; |
| | | } |
| | | |
| | | //剔除数据超过上下限的数据 |
| | | double aDouble = Double.parseDouble(sensorValue.toString()); |
| | | if (!ObjectUtils.isEmpty(upper)) { |
| | | if (aDouble < upper) { |
| | | return null; |
| | | } |
| | | } |
| | | if (!ObjectUtils.isEmpty(lower)) { |
| | | if (aDouble > lower) { |
| | | return null; |
| | | } |
| | | } |
| | | size.getAndIncrement(); |
| | | return DoubleStream.of(aDouble); |
| | | }); |
| | | OptionalDouble average = optionalDouble.average(); |
| | | if (average.isPresent()) { |
| | | //银行家算法修约 |
| | | double sciCal = AmendUtils.sciCal(average.getAsDouble(), 4); |
| | | jsonMap.put(sensorCode, sciCal); |
| | | //标志位 |
| | | if (size.get() >= 45) { |
| | | jsonMap.put(sensorCode + "-" + Constants.MARKER_BIT_KEY, Constants.MARKER_BIT_TRUE); |
| | | } else { |
| | | jsonMap.put(sensorCode + "-" + Constants.MARKER_BIT_KEY, Constants.MARKER_BIT_FALSE); |
| | | } |
| | | } |
| | | }); |
| | | historyHourly.put("version", value.get(0).get("version")); |
| | | historyHourly.put("value", JSONObject.toJSONString(jsonMap)); |
| | | insertData.add(historyHourly); |
| | | }); |
| | | //存入数据库 |
| | | historyHourlyMapper.insertHistoryHourlyAvg(insertData,timeUnits); |
| | | |
| | | } |
| | | |
| | | private String strList(String startTime,String mn,String msg){ |
| | | String qn = "QN="+ startTime + "001;ST=22;CN=2061;PW=123456;MN="+mn.toUpperCase()+";CP=&&DataTime="+startTime+";"; |
| | | Map<String, Object> data = JSON.parseObject(msg, Map.class); |
| | |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | //海城小时数据统计 |
| | | @XxlJob("dateInsertHistoryHourlyAvg") |
| | | public ReturnT dateInsertHistoryHourlyAvg(){ |
| | | try { |
| | | historyHourlyService.dateInsertHistoryHourlyAvg(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return new ReturnT(ReturnT.FAIL_CODE, e.getMessage()); |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | (#{item.mac}, #{item.time}, #{item.value}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | |
| | | <insert id="insertHistoryHourlyAvg"> |
| | | INSERT INTO |
| | | history_hourly_${timeUnits} |
| | | VALUES |
| | | <foreach collection="list" item="item" separator=","> |
| | | (#{item.mac}, #{item.time}, #{item.value}, #{item.version}) |
| | | </foreach> |
| | | </insert> |
| | | </mapper> |
| | |
| | | } |
| | | Map<String, Object> cruiserInFo = historySecondCruiserService.getCruiserInFo(params); |
| | | |
| | | return ObjectUtils.isEmpty(cruiserInFo)? ResultMessage.ok() : ResultMessage.ok(cruiserInFo); |
| | | return ObjectUtils.isEmpty(cruiserInFo)? ResultMessage.ok(ResponseCodeEnum.DEVICE_IS_NULL.getMsg()) : ResultMessage.ok(cruiserInFo); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("getCruiserCompare") |
| | | @ApiOperation(value = "数据对比", notes = "数据对比") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), |
| | | @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time1", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time2", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | public ResultMessage getCruiserCompare(HttpServletRequest request){ |
| | | Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); |
| | | if (!params.containsKey("mac") || !params.containsKey("time1")|| !params.containsKey("time2")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | Map<String, Object> cruiserInFo = historySecondCruiserService.getCruiserCompare(params); |
| | | |
| | | return ObjectUtils.isEmpty(cruiserInFo)? ResultMessage.ok(ResponseCodeEnum.DEVICE_IS_NULL.getMsg()) : ResultMessage.ok(cruiserInFo); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.moral.api.entity.ManageCoordinate; |
| | | import com.moral.api.mapper.ManageCoordinateMapper; |
| | | import com.moral.api.service.ManageCoordinateService; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | |
| | | |
| | | @Autowired |
| | | private ManageCoordinateService manageCoordinateService; |
| | | @Autowired |
| | | private ManageCoordinateMapper manageCoordinateMapper; |
| | | |
| | | |
| | | |
| | |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | Integer integer = manageCoordinateService.deleteCoordinate(id); |
| | | if (integer==1){ |
| | | return ResultMessage.ok("删除失败"); |
| | | } |
| | | manageCoordinateService.deleteCoordinate(id); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(name = "time2", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | public ResultMessage selectAll(@RequestBody Map<String,Object> params){ |
| | | if (!params.containsKey("coordinateId") || !params.containsKey("time1")|| !params.containsKey("time2")) { |
| | | if (!params.containsKey("coordinateId") || !params.containsKey("time1")|| !params.containsKey("time2")|| !params.containsKey("mac")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | Map<String,Object> rsMap = manageCoordinateDetailService.selectCoordinate(params); |
| | |
| | | /* |
| | | package com.moral.api.kafka.consumer; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.moral.api.service.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.kafka.clients.consumer.ConsumerRecord; |
| | |
| | | } |
| | | |
| | | //数据过滤 |
| | | data.remove("time"); |
| | | // data.remove("time"); |
| | | data.remove("entryTime"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String format = dateFormat.format(new Date().getTime()); |
| | | //获取年份 |
| | | String substring = format.substring(0, 4); |
| | | |
| | | String substring1 = time.toString().substring(0, 4); |
| | | |
| | | String replace = time.toString().replace(substring1, substring); |
| | | |
| | | data.put("DataTime",replace); |
| | | Map<String, Object> deviceByMac = deviceService.getDeviceByMac(mac.toString()); |
| | | HashMap<String, Object> map = (HashMap<String, Object>) deviceByMac.get("organization"); |
| | | String id = map.get("id").toString(); |
| | | if (id.equals("71")){ |
| | | log.warn(id, msg); |
| | | return; |
| | | } |
| | | // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // String format = dateFormat.format(new Date().getTime()); |
| | | // //获取年份 |
| | | // String substring = format.substring(0, 4); |
| | | // |
| | | // String substring1 = time.toString().substring(0, 4); |
| | | // |
| | | // String replace = time.toString().replace(substring1, substring); |
| | | // |
| | | // data.put("DataTime",replace); |
| | | |
| | | Iterator<Map.Entry<String, Object>> iterator = data.entrySet().iterator(); |
| | | Map<String, Object> newMap = new HashMap<>(); |
| | |
| | | |
| | | //查询走航车轨迹 |
| | | Map<String,Object> getCruiserInFo(Map<String, Object> params); |
| | | |
| | | |
| | | Map<String,Object> getCruiserCompare(Map<String, Object> params); |
| | | } |
| | |
| | | void updateCoordinate(ManageCoordinate manageCoordinate); |
| | | |
| | | |
| | | Integer deleteCoordinate(Integer id); |
| | | void deleteCoordinate(Integer id); |
| | | |
| | | |
| | | List<ManageCoordinate> selectCoordinate(); |
| | |
| | | Map<String, Object> versionInfo = (Map<String, Object>) deviceInfo.get("version"); |
| | | Integer version = (Integer) versionInfo.get("id"); |
| | | //获取时间戳 |
| | | // String time1 = data.get("time").toString(); |
| | | // long l = Long.parseLong(time1); |
| | | // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); |
| | | // String format1 = dateFormat.format(l); |
| | | // Date time = DateUtils.getDate(format1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | String time1 = data.get("time").toString(); |
| | | long l = Long.parseLong(time1); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); |
| | | String format1 = dateFormat.format(l); |
| | | Date time = DateUtils.getDate(format1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | |
| | | Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN); |
| | | // Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN); |
| | | String yearAndMonth = DateUtils.dateToDateString(DateUtils.addHours(time, -1), DateUtils.yyyyMM_EN); |
| | | |
| | | result.put("mac", mac); |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | import com.moral.api.entity.ManageCoordinateDetail; |
| | | import com.moral.api.entity.Sensor; |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | | import com.moral.api.mapper.ManageCoordinateDetailMapper; |
| | | import com.moral.api.mapper.SpecialDeviceMapper; |
| | | import com.moral.api.pojo.dto.cruiser.CruiserDTO; |
| | | import com.moral.api.service.DeviceService; |
| | |
| | | private SpecialDeviceService specialDeviceService; |
| | | @Autowired |
| | | private SpecialDeviceMapper specialDeviceMapper; |
| | | @Autowired |
| | | private ManageCoordinateDetailMapper manageCoordinateDetailMapper; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getCruiserCompare(Map<String, Object> params) { |
| | | HashMap<String,Object> rsMap = new HashMap<>(); |
| | | String mac = params.get("mac").toString(); |
| | | String time1 = params.get("time1").toString(); |
| | | ArrayList<ManageCoordinateDetail> rsList1 = new ArrayList<>(); |
| | | params.put("dateFormat", "%Y-%m-%d %H:%i:%s"); |
| | | List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(null); |
| | | List<CruiserDTO> cruiserInfo = (List<CruiserDTO>) redisTemplate.opsForHash().get(RedisConstants.DATE_COORDINATE, mac + time1); |
| | | |
| | | if (ObjectUtils.isEmpty(cruiserInfo)){ |
| | | cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params); |
| | | cruiserInfo = cruiserInfo.stream().distinct().collect(Collectors.toList()); |
| | | cruiserInfo.removeIf(o->{ |
| | | if (ObjectUtils.isEmpty(o.getFlyLon()) || ObjectUtils.isEmpty(o.getFlyLat())) { |
| | | return true; |
| | | } |
| | | double lon = o.getFlyLon(); |
| | | double lat = o.getFlyLat(); |
| | | double[] doubles = RoadUtils.transformWGS84ToBD09(lon, lat); |
| | | Matcher matcher = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[0]); |
| | | matcher.find(); |
| | | String s = matcher.group(); |
| | | Matcher matcher1 = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[1]); |
| | | matcher1.find(); |
| | | String s1 = matcher1.group(); |
| | | o.setFlyLon(Double.parseDouble(s)); |
| | | o.setFlyLat(Double.parseDouble(s1)); |
| | | o.setData(lon+"_"+lat); |
| | | // o.setFlyLon(doubles[0]); |
| | | // o.setFlyLat(doubles[1]); |
| | | if (lon < 70 || lon > 150 || lat < 20 || lat > 60) { |
| | | return true; |
| | | } |
| | | return false; |
| | | }); |
| | | |
| | | redisTemplate.opsForHash().put(RedisConstants.DATE_COORDINATE,mac+time1,cruiserInfo); |
| | | //设置过期时间 |
| | | redisTemplate.opsForHash().getOperations().expire(RedisConstants.DATE_COORDINATE,6000, TimeUnit.SECONDS); |
| | | |
| | | } |
| | | // List<CruiserDTO> cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params); |
| | | log.info(""+cruiserInfo.size()); |
| | | if (ObjectUtils.isEmpty(manageCoordinateDetails)){ |
| | | rsMap.put("rsData",cruiserInfo); |
| | | rsMap.put("data",rsList1); |
| | | return rsMap; |
| | | } |
| | | for (int i=cruiserInfo.size()-1;i>0;i--) { |
| | | CruiserDTO cruiserDTO = cruiserInfo.get(i); |
| | | String data = cruiserDTO.getData(); |
| | | String[] rs = data.split("_"); |
| | | String flyLon = rs[0]; |
| | | String flyLat = rs[1]; |
| | | for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) { |
| | | String latitude = manageCoordinateDetail.getLatitude().toString(); |
| | | String longitude = manageCoordinateDetail.getLongitude().toString(); |
| | | if (latitude.equals(flyLat) && longitude.equals(flyLon)){ |
| | | manageCoordinateDetail.setCode(data); |
| | | manageCoordinateDetail.setLongitude(cruiserDTO.getFlyLon()); |
| | | manageCoordinateDetail.setLatitude(cruiserDTO.getFlyLat()); |
| | | rsList1.add(manageCoordinateDetail); |
| | | cruiserInfo.remove(i); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | rsMap.put("rsData",cruiserInfo); |
| | | rsMap.put("data",rsList1); |
| | | rsMap.put("message","有"+cruiserInfo.size()+"个不在里面,"+"一共有"+(cruiserInfo.size()+rsList1.size())+"个"); |
| | | return rsMap; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | List<Map<String, Object>> data = (List<Map<String, Object>>) params.get("data"); |
| | | |
| | | for (Map<String, Object> datum : data) { |
| | | ManageCoordinateDetail manageCoordinateDetail = new ManageCoordinateDetail(); |
| | | |
| | | String code = datum.get("code").toString(); |
| | | String state = datum.get("state").toString(); |
| | | |
| | | if (state.equals("2")){ |
| | | ManageCoordinateDetail manageCoordinateDetail = new ManageCoordinateDetail(); |
| | | String[] rs = code.split("_"); |
| | | manageCoordinateDetail.setCoordinateId(coordinateId); |
| | | manageCoordinateDetail.setLongitude(Double.parseDouble(rs[0])); |
| | |
| | | return 2; |
| | | } |
| | | manageCoordinateDetailMapper.deleteById(Integer.parseInt(id1.toString())); |
| | | // manageCoordinateDetailMapper.delete(wrapper); |
| | | |
| | | } |
| | | } |
| | | return 200; |
| | |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public Integer deleteCoordinate(Integer id) { |
| | | QueryWrapper<ManageCoordinateDetail> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("coordinate_id",id); |
| | | Integer integer = manageCoordinateDetailMapper.selectCount(wrapper); |
| | | if (integer>0){ |
| | | return 1; |
| | | } |
| | | manageCoordinateMapper.deleteById(id); |
| | | return 200; |
| | | public void deleteCoordinate(Integer id) { |
| | | ManageCoordinate manageCoordinate = manageCoordinateMapper.selectById(id); |
| | | manageCoordinate.setIsDel(1); |
| | | manageCoordinateMapper.updateById(manageCoordinate); |
| | | |
| | | } |
| | | |