diff --git a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java index c6b0ea3..f861862 100644 --- a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java +++ b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java @@ -147,6 +147,43 @@ public class BuildingController { return success; } + /** + * 查询近一天工地噪声和扬尘的信息 + * @return + */ + @GetMapping("selectDayAll") + @ApiOperation("查询近一天工地噪声和扬尘的信息") + public Result selectDayAll(){ + List recordsDtos = buildingRecordsMapper.selectDayAll(); + Result success = Result.success(recordsDtos); + return success; + } + + /** + * 查询近一周工地噪声和扬尘的信息 + * @return + */ + @GetMapping("selectWeekAll") + @ApiOperation("查询近一周工地噪声和扬尘的信息") + public Result selectWeekAll(){ + List recordsDtos = buildingRecordsMapper.selectWeekAll(); + Result success = Result.success(recordsDtos); + return success; + } + + /** + * 查询近一月工地噪声和扬尘的信息 + * @return + */ + @GetMapping("selectMonthAll") + @ApiOperation("查询近一月工地噪声和扬尘的信息") + public Result selectMonthAll(){ + List recordsDtos = buildingRecordsMapper.selectMonthAll(); + Result success = Result.success(recordsDtos); + return success; + } + + /** * 根据工地名称搜索工地 * @param projectName diff --git a/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDto.java b/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDto.java index b7e803e..65fd13c 100644 --- a/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDto.java +++ b/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDto.java @@ -14,4 +14,5 @@ public class BuildingRecordsDto { private String ssdq;//所属区域 private double pm10;//扬尘 private double noice;//噪声 + private String yjsg;//夜间施工 } diff --git a/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java b/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java index e3a3b1b..c7949be 100644 --- a/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java +++ b/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java @@ -16,7 +16,7 @@ import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor -@TableName("t_building_site") +@TableName("t_building_new_site") public class BuildingSite { @TableId private Integer id; @@ -25,4 +25,5 @@ public class BuildingSite { private double jd; private double wd; private String ssdq; + private String yjsg; } diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java index 1cf0d41..1b8e184 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java @@ -23,38 +23,50 @@ public interface BuildingRecordsMapper extends BaseMapper { void batchUpdate(@Param("list") List list); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc") + @Select("SELECT * FROM t_building_new_site bns JOIN t_building_records br ON bns.gdmc = br.project_name") List selectAllBuilding(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc " + + @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc " + " where to_days(br.push_time) = to_days(now()) order by br.pm10 desc") List selectDayPm10(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc" + + @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + " where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(br.push_time) order by br.pm10 desc") List selectWeekPm10(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc" + + @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + " where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(br.push_time) order by br.pm10 desc") List selectMonthPm10(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc " + + @Select("select * from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc " + " where to_days(br.push_time) = to_days(now()) order by br.noice desc") List selectDayNoice(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc" + + @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + " where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(br.push_time) order by br.noice desc") List selectWeekNoice(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc" + + @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + " where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(br.push_time) order by br.noice desc") List selectMonthNoice(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc" + + @Select("select * from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc " + + " where to_days(br.push_time) = to_days(now())") + List selectDayAll(); + + @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + + " where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(br.push_time)") + List selectWeekAll(); + + @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + + " where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(br.push_time)") + List selectMonthAll(); + + @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + " where br.project_name like concat('%',#{projectName},'%')") List selectByProjectName(String projectName); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_site bs on br.project_name = bs.gdmc" + + @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + " where (bs.jd between #{jd} and #{jd1}) and (bs.wd between #{wd} and #{wd1} )") List selectByJdWd(@Param("jd") Double jd, @Param("jd1") Double jd1, diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java index 780fe71..bf22923 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java @@ -15,6 +15,6 @@ import java.util.List; */ public interface BuildingSiteMapper extends BaseMapper { - @Select("select * from t_building_site") + @Select("select * from t_building_new_site") List selectBuildSite(); } diff --git a/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java b/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java index 2133a49..642b51d 100644 --- a/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java +++ b/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java @@ -48,6 +48,9 @@ public class PassengerFlowService { @Value("7eb78b134e0310904d46039ccea20c32") private String appSecret; + @Value("${scheduled.enable:ture}") + private Boolean enable; + /** * 最新的实时客流 @@ -131,53 +134,54 @@ public class PassengerFlowService { //提供的接口能查到当前时间2个小时之前的数据,每隔15分钟一次,我们只取整点从早8点到晚8点的整点数据 //10:31 到晚上10:31,每小时的31分执行一次 public void passengerFlowSchedule(){ - //JSONObject map = new JSONObject(); - Map map = new HashMap<>(); - //MultiValueMap map = new LinkedMultiValueMap<>(); - DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + if (enable){ + //JSONObject map = new JSONObject(); + Map map = new HashMap<>(); + //MultiValueMap map = new LinkedMultiValueMap<>(); + DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); - LocalDateTime dateNow = LocalDateTime.now(); - String timeStamp = dateNow.format(dateTimeFormatter1);//yyyyMMddHHmmss - String[] tt = this.minusMinutesStr(dateNow,120); + LocalDateTime dateNow = LocalDateTime.now(); + String timeStamp = dateNow.format(dateTimeFormatter1);//yyyyMMddHHmmss + String[] tt = this.minusMinutesStr(dateNow,120); - String url = "http://15.72.158.72:8081/getway/api/Proxy/HandleByKey/1249fcc8-0466-4897-87b4-d2111a9baf4f"; - map.put("APIKEY",APIKEY); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("appId",appId); - //安全认证 MD5(appId+”-”+timeStamp+”-”+ appSecret) - String code = appId+"-"+timeStamp+"-"+ appSecret; - String md5Str = DigestUtils.md5DigestAsHex(code.getBytes(StandardCharsets.UTF_8)); - jsonObject.put("mac",md5Str); - jsonObject.put("timeStamp",timeStamp); - jsonObject.put("hourId",tt[1]); - jsonObject.put("timeId",tt[0]); - //jsonObject.put("apiType","***"); - JSONObject para = new JSONObject(); - para.put("data",JSONObject.toJSONString(jsonObject)); - map.put("ParamJson",para); + String url = "http://15.72.158.72:8081/getway/api/Proxy/HandleByKey/1249fcc8-0466-4897-87b4-d2111a9baf4f"; + map.put("APIKEY",APIKEY); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("appId",appId); + //安全认证 MD5(appId+”-”+timeStamp+”-”+ appSecret) + String code = appId+"-"+timeStamp+"-"+ appSecret; + String md5Str = DigestUtils.md5DigestAsHex(code.getBytes(StandardCharsets.UTF_8)); + jsonObject.put("mac",md5Str); + jsonObject.put("timeStamp",timeStamp); + jsonObject.put("hourId",tt[1]); + jsonObject.put("timeId",tt[0]); + //jsonObject.put("apiType","***"); + JSONObject para = new JSONObject(); + para.put("data",JSONObject.toJSONString(jsonObject)); + map.put("ParamJson",para); - System.out.println("multimap->"+map.toString()); - ResponseEntity responseEntity; - List list = new ArrayList<>(); - try{ - responseEntity = restTemplate.postForEntity(url,map,String.class); - //System.out.println(responseEntity.getStatusCodeValue()); - if(responseEntity.getStatusCodeValue() == 200){ - String result = responseEntity.getBody(); - //System.out.println("passengerFlow ->"+result); - JSONObject jsonResult = JSONObject.parseObject(result); - System.out.println(jsonResult.keySet().toString()); - if(jsonResult.getIntValue("code") == 0){ - JSONArray jsonArray = jsonResult.getJSONArray("result"); - list = JSONObject.parseArray(JSONObject.toJSONString(jsonArray),Map.class); - List> lists = Lists.partition(list,200); - lists.forEach(ll ->passengerFlowMapper.batchSave(ll)); + System.out.println("multimap->"+map.toString()); + ResponseEntity responseEntity; + List list = new ArrayList<>(); + try{ + responseEntity = restTemplate.postForEntity(url,map,String.class); + //System.out.println(responseEntity.getStatusCodeValue()); + if(responseEntity.getStatusCodeValue() == 200){ + String result = responseEntity.getBody(); + //System.out.println("passengerFlow ->"+result); + JSONObject jsonResult = JSONObject.parseObject(result); + System.out.println(jsonResult.keySet().toString()); + if(jsonResult.getIntValue("code") == 0){ + JSONArray jsonArray = jsonResult.getJSONArray("result"); + list = JSONObject.parseArray(JSONObject.toJSONString(jsonArray),Map.class); + List> lists = Lists.partition(list,200); + lists.forEach(ll ->passengerFlowMapper.batchSave(ll)); + } } + } catch (Exception e){ + log.error("[passengerFlowSchedule] Exception:"+e.getMessage()); } - } catch (Exception e){ - log.error("[passengerFlowSchedule] Exception:"+e.getMessage()); } - } //保存实时客流 @Transactional(rollbackFor = Exception.class) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d15f579..7183e7e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -24,3 +24,6 @@ mybatis-plus.mapper-locations=classpath*:/mapper/*.xml #??????swagger,true???false?? swagger.enable=true +scheduled.enable=false + +