工地接口更新

添加配置本地不进行人流调度
This commit is contained in:
wuweida 2022-06-06 15:04:05 +08:00
parent 4729c661a5
commit 884237a679
7 changed files with 110 additions and 52 deletions

View File

@ -147,6 +147,43 @@ public class BuildingController {
return success;
}
/**
* 查询近一天工地噪声和扬尘的信息
* @return
*/
@GetMapping("selectDayAll")
@ApiOperation("查询近一天工地噪声和扬尘的信息")
public Result selectDayAll(){
List<BuildingRecordsDto> recordsDtos = buildingRecordsMapper.selectDayAll();
Result success = Result.success(recordsDtos);
return success;
}
/**
* 查询近一周工地噪声和扬尘的信息
* @return
*/
@GetMapping("selectWeekAll")
@ApiOperation("查询近一周工地噪声和扬尘的信息")
public Result selectWeekAll(){
List<BuildingRecordsDto> recordsDtos = buildingRecordsMapper.selectWeekAll();
Result success = Result.success(recordsDtos);
return success;
}
/**
* 查询近一月工地噪声和扬尘的信息
* @return
*/
@GetMapping("selectMonthAll")
@ApiOperation("查询近一月工地噪声和扬尘的信息")
public Result selectMonthAll(){
List<BuildingRecordsDto> recordsDtos = buildingRecordsMapper.selectMonthAll();
Result success = Result.success(recordsDtos);
return success;
}
/**
* 根据工地名称搜索工地
* @param projectName

View File

@ -14,4 +14,5 @@ public class BuildingRecordsDto {
private String ssdq;//所属区域
private double pm10;//扬尘
private double noice;//噪声
private String yjsg;//夜间施工
}

View File

@ -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;
}

View File

@ -23,38 +23,50 @@ public interface BuildingRecordsMapper extends BaseMapper<BuildingRecords> {
void batchUpdate(@Param("list") List<Map> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> 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<BuildingRecordsDto> selectByJdWd(@Param("jd") Double jd,
@Param("jd1") Double jd1,

View File

@ -15,6 +15,6 @@ import java.util.List;
*/
public interface BuildingSiteMapper extends BaseMapper<BuildingSite> {
@Select("select * from t_building_site")
@Select("select * from t_building_new_site")
List<BuildingSite> selectBuildSite();
}

View File

@ -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 到晚上1031每小时的31分执行一次
public void passengerFlowSchedule(){
//JSONObject map = new JSONObject();
Map<String,Object> map = new HashMap<>();
//MultiValueMap<String,Object> map = new LinkedMultiValueMap<>();
DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
if (enable){
//JSONObject map = new JSONObject();
Map<String,Object> map = new HashMap<>();
//MultiValueMap<String,Object> 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<String> responseEntity;
List<Map> 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<List<Map>> lists = Lists.partition(list,200);
lists.forEach(ll ->passengerFlowMapper.batchSave(ll));
System.out.println("multimap->"+map.toString());
ResponseEntity<String> responseEntity;
List<Map> 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<List<Map>> 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)

View File

@ -24,3 +24,6 @@ mybatis-plus.mapper-locations=classpath*:/mapper/*.xml
#??????swagger,true???false??
swagger.enable=true
scheduled.enable=false