qidi接口由monitorService转移到QidiService
新增安保区域人流识别算法接口 安保区域人流识别算法做调度每天更新
This commit is contained in:
parent
d0be7a6ffe
commit
8b1ecd7b9d
|
@ -73,8 +73,7 @@ public class Controller {
|
||||||
private TrailSanitationMapper trailSanitationMapper;
|
private TrailSanitationMapper trailSanitationMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoadDataMapper roadDataMapper;
|
private QidiService qidiService;
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("all")
|
@GetMapping("all")
|
||||||
public Object all(){
|
public Object all(){
|
||||||
|
@ -337,7 +336,7 @@ public class Controller {
|
||||||
@GetMapping("roadData")
|
@GetMapping("roadData")
|
||||||
@ApiOperation("道路统计数据与排名,根据后台dt调用接口")
|
@ApiOperation("道路统计数据与排名,根据后台dt调用接口")
|
||||||
public List<Map> roadData(){
|
public List<Map> roadData(){
|
||||||
return monitorService.roadData();
|
return roadDataService.roadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
//启迪中台
|
//启迪中台
|
||||||
|
@ -345,48 +344,48 @@ public class Controller {
|
||||||
@GetMapping("qidiToken")
|
@GetMapping("qidiToken")
|
||||||
@ApiOperation("启迪数据中台登录获取token")
|
@ApiOperation("启迪数据中台登录获取token")
|
||||||
public String qidiToken(){
|
public String qidiToken(){
|
||||||
return monitorService.qidiToken();
|
return qidiService.qidiToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
//渣土车轨迹数据
|
//渣土车轨迹数据
|
||||||
@GetMapping("resCatalogApplyZTYS")
|
@GetMapping("resCatalogApplyZTYS")
|
||||||
@ApiOperation("获取渣土车轨迹数据,根据后台UPLOADTIME调用接口")
|
@ApiOperation("获取渣土车轨迹数据,根据后台UPLOADTIME调用接口")
|
||||||
public List<Map> resCatalogApply(){
|
public List<Map> resCatalogApply(){
|
||||||
return monitorService.resCatalogApplyZTYS();
|
return qidiService.resCatalogApplyZTYS();
|
||||||
}
|
}
|
||||||
|
|
||||||
//环卫车轨迹数据
|
//环卫车轨迹数据
|
||||||
@GetMapping("resCatalogApplyHJWS")
|
@GetMapping("resCatalogApplyHJWS")
|
||||||
@ApiOperation("环卫车轨迹数据,根据后台updatetime调用接口")
|
@ApiOperation("环卫车轨迹数据,根据后台updatetime调用接口")
|
||||||
public List<Map> resCatalogApplyHJWS(){
|
public List<Map> resCatalogApplyHJWS(){
|
||||||
return monitorService.resCatalogApplyHJWS();
|
return qidiService.resCatalogApplyHJWS();
|
||||||
}
|
}
|
||||||
|
|
||||||
//工地信息
|
//工地信息
|
||||||
@GetMapping("resCatalogApplyGDYS")
|
@GetMapping("resCatalogApplyGDYS")
|
||||||
@ApiOperation("获取工地信息-表中获取")
|
@ApiOperation("获取工地信息-表中获取")
|
||||||
public List<Map> resCatalogApplyGDYS(){
|
public List<Map> resCatalogApplyGDYS(){
|
||||||
return monitorService.resCatalogApplyGDYS();
|
return qidiService.resCatalogApplyGDYS();
|
||||||
}
|
}
|
||||||
|
|
||||||
//环卫车辆数据1,基础
|
//环卫车辆数据1,基础
|
||||||
@GetMapping("resCatalogApplyHJWSBase")
|
@GetMapping("resCatalogApplyHJWSBase")
|
||||||
@ApiOperation("环卫车辆数据1,基础--根据后台updatetime调用接口")
|
@ApiOperation("环卫车辆数据1,基础--根据后台updatetime调用接口")
|
||||||
public List<Map> resCatalogApplyHJWSBase(){
|
public List<Map> resCatalogApplyHJWSBase(){
|
||||||
return monitorService.resCatalogApplyHJWSBase();
|
return qidiService.resCatalogApplyHJWSBase();
|
||||||
}
|
}
|
||||||
//环卫车辆数据1,作业
|
//环卫车辆数据1,作业
|
||||||
@GetMapping("resCatalogApplyHJWSZY")
|
@GetMapping("resCatalogApplyHJWSZY")
|
||||||
@ApiOperation("环卫车辆数据1,作业--根据后台ZYRQ调用接口")
|
@ApiOperation("环卫车辆数据1,作业--根据后台ZYRQ调用接口")
|
||||||
public List<Map> resCatalogApplyHJWSZY(){
|
public List<Map> resCatalogApplyHJWSZY(){
|
||||||
return monitorService.resCatalogApplyHJWSZY();
|
return qidiService.resCatalogApplyHJWSZY();
|
||||||
}
|
}
|
||||||
|
|
||||||
//环卫道路明细数据
|
//环卫道路明细数据
|
||||||
@GetMapping("resCatalogApplyHJWSRoad")
|
@GetMapping("resCatalogApplyHJWSRoad")
|
||||||
@ApiOperation("环卫道路明细数据,根据后台updatetime调用接口")
|
@ApiOperation("环卫道路明细数据,根据后台updatetime调用接口")
|
||||||
public List<Map> resCatalogApplyHJWSRoad(){
|
public List<Map> resCatalogApplyHJWSRoad(){
|
||||||
return monitorService.resCatalogApplyHJWSRoad();
|
return qidiService.resCatalogApplyHJWSRoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取渣土车轨迹并保存到t_trail_sediment
|
//获取渣土车轨迹并保存到t_trail_sediment
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.hisense.monitormanage.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.hisense.monitormanage.entity.PeopleRecognize;
|
||||||
|
import com.hisense.monitormanage.entity.Result;
|
||||||
|
import com.hisense.monitormanage.mapper.PeopleRecognizeMapper;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api/project/people")
|
||||||
|
@Api(tags = "人流识别算法")
|
||||||
|
public class PeopleRecognizeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PeopleRecognizeMapper peopleRecognizeMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部安保区域人流
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("selectPeopleRecognize")
|
||||||
|
@ApiOperation("查询全部安保区域人流")
|
||||||
|
public Result selectPeopleRecognize(){
|
||||||
|
QueryWrapper<PeopleRecognize> queryWrapper = new QueryWrapper<>();
|
||||||
|
List<PeopleRecognize> list = peopleRecognizeMapper.selectList(queryWrapper);
|
||||||
|
Result success = Result.success(list);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.hisense.monitormanage.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("t_people_recognize")
|
||||||
|
public class PeopleRecognize {
|
||||||
|
@TableId
|
||||||
|
private String id;
|
||||||
|
private String channelCode;
|
||||||
|
private String channelName;
|
||||||
|
private String picUrl;
|
||||||
|
private Integer personNum;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date pushTime;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.hisense.monitormanage.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.hisense.monitormanage.entity.PeopleRecognize;
|
||||||
|
|
||||||
|
public interface PeopleRecognizeMapper extends BaseMapper<PeopleRecognize> {
|
||||||
|
}
|
|
@ -16,6 +16,4 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public interface RoadDataMapper extends BaseMapper<RoadData> {
|
public interface RoadDataMapper extends BaseMapper<RoadData> {
|
||||||
public void batchSave(List<Map> list);
|
public void batchSave(List<Map> list);
|
||||||
|
|
||||||
/*List<RoadData> selectRoadData(@Param("page") Integer page, @Param("pageSize") Integer pageSize);*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,10 @@ public class MonitorService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BoothMapper boothMapper;
|
private BoothMapper boothMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PeopleRecognizeMapper peopleRecognizeMapper;
|
||||||
|
|
||||||
|
|
||||||
@Value("${hwx.file.work-path}")
|
@Value("${hwx.file.work-path}")
|
||||||
private String fileDir;
|
private String fileDir;
|
||||||
@Value("${hwx.file.pic-host}")
|
@Value("${hwx.file.pic-host}")
|
||||||
|
@ -589,7 +593,7 @@ public class MonitorService {
|
||||||
|
|
||||||
log.info("[monitor-capture]: start capture");
|
log.info("[monitor-capture]: start capture");
|
||||||
|
|
||||||
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1004,1006");
|
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1006,1004");
|
||||||
labels.forEach(label -> {
|
labels.forEach(label -> {
|
||||||
String channelCode = label.getChannelCode();
|
String channelCode = label.getChannelCode();
|
||||||
try {
|
try {
|
||||||
|
@ -624,6 +628,101 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 海水浴场人群图片算法识别
|
||||||
|
*/
|
||||||
|
public void bathingBeach () {
|
||||||
|
try {
|
||||||
|
|
||||||
|
log.info("[monitor-capture]: start capture");
|
||||||
|
|
||||||
|
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1006");
|
||||||
|
labels.forEach(label -> {
|
||||||
|
String channelCode = label.getChannelCode();
|
||||||
|
try {
|
||||||
|
BufferedImage bufferedImage = capturecreenshot(channelCode);
|
||||||
|
String fileName = channelCode + ".jpg";
|
||||||
|
ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName));
|
||||||
|
String picUrl = picHost + "/images/" + fileName;
|
||||||
|
//人流识别
|
||||||
|
String personNumUrl = "http://15.72.184.10:8003/cshi_rpc/v1.0/person";
|
||||||
|
Map personImage = new HashMap<>();
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(bufferedImage, "png", stream);
|
||||||
|
String imgBase64 = Base64Utils.encodeToString(stream.toByteArray());
|
||||||
|
stream.flush();
|
||||||
|
stream.close();
|
||||||
|
personImage.put("img_base64", imgBase64);
|
||||||
|
ResponseEntity<HashMap> responseEntity = restTemplate.postForEntity(personNumUrl, personImage, HashMap.class);
|
||||||
|
HashMap body = responseEntity.getBody();
|
||||||
|
if (body != null && (Integer) body.get("code") == 200){
|
||||||
|
Map data = (Map) body.get("data");
|
||||||
|
log.info(picUrl);
|
||||||
|
log.info("人流识别算法" + data);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
log.info("[monitor-capture]: end capture");
|
||||||
|
}catch (Exception exception){
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安保区域人群图片算法识别并保存到数据库
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 8/2 * * ?")
|
||||||
|
public void peopleRecognize() {
|
||||||
|
try {
|
||||||
|
log.info("[monitor-capture]: start capture");
|
||||||
|
|
||||||
|
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1042");
|
||||||
|
labels.forEach(label -> {
|
||||||
|
String channelCode = label.getChannelCode();
|
||||||
|
try {
|
||||||
|
BufferedImage bufferedImage = capturecreenshot(channelCode);
|
||||||
|
String fileName = channelCode + ".jpg";
|
||||||
|
ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName));
|
||||||
|
String picUrl = picHost + "/images/" + fileName;
|
||||||
|
//人流识别
|
||||||
|
String personNumUrl = "http://15.72.184.10:8003/cshi_rpc/v1.0/person";
|
||||||
|
Map personImage = new HashMap<>();
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(bufferedImage, "png", stream);
|
||||||
|
String imgBase64 = Base64Utils.encodeToString(stream.toByteArray());
|
||||||
|
stream.flush();
|
||||||
|
stream.close();
|
||||||
|
personImage.put("img_base64", imgBase64);
|
||||||
|
ResponseEntity<HashMap> responseEntity = restTemplate.postForEntity(personNumUrl, personImage, HashMap.class);
|
||||||
|
HashMap body = responseEntity.getBody();
|
||||||
|
if (body != null && (Integer) body.get("code") == 200){
|
||||||
|
Map data = (Map) body.get("data");
|
||||||
|
Integer personNum = (Integer) data.get("person_num");
|
||||||
|
PeopleRecognize peopleRecognize = new PeopleRecognize();
|
||||||
|
peopleRecognize.setChannelCode(channelCode);
|
||||||
|
peopleRecognize.setChannelName(label.getChannelName());
|
||||||
|
peopleRecognize.setPicUrl(picUrl);
|
||||||
|
peopleRecognize.setPersonNum(personNum);
|
||||||
|
peopleRecognize.setPushTime(new Date());
|
||||||
|
PeopleRecognize id = peopleRecognizeMapper.selectById(channelCode);
|
||||||
|
if (id == null){
|
||||||
|
peopleRecognizeMapper.insert(peopleRecognize);
|
||||||
|
}else {
|
||||||
|
peopleRecognizeMapper.updateById(peopleRecognize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
log.info("[monitor-capture]: end capture");
|
||||||
|
}catch (Exception exception){
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 景区人流量识别
|
* 景区人流量识别
|
||||||
*/
|
*/
|
||||||
|
@ -891,294 +990,7 @@ public class MonitorService {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
//道路统计数据与排名,调用公开接口
|
|
||||||
public List<Map> roadData(){
|
|
||||||
String url = "http://outerdata.novaecs.com/api/qingdaoData/roadData?groupId={groupId}&timeType={timeType}&dt={dt}";
|
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
|
||||||
|
|
||||||
map.put("dt",this.dateTimeStr());
|
|
||||||
map.put("groupId",1);
|
|
||||||
map.put("timeType","日");
|
|
||||||
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
List<Map> list = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
responseEntity = restTemplate.getForEntity(url, JSONObject.class, map);
|
|
||||||
HttpStatus statusCode = responseEntity.getStatusCode();
|
|
||||||
if (statusCode.is2xxSuccessful()) {
|
|
||||||
JSONObject re = responseEntity.getBody();
|
|
||||||
if (re.getIntValue("status") == 0) {
|
|
||||||
JSONArray jsonArray = re.getJSONArray("data");
|
|
||||||
list = JSONArray.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("[roadData] exception:{}", e.getMessage());
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//启迪数据中台相关
|
|
||||||
//1.登录
|
|
||||||
public String qidiToken () {
|
|
||||||
String url = "http://120.221.95.13:9090/apin/authorization/oauth/token";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Authorization", "Basic dGVzdF9jbGllbnQ6ZTk4OWQ0NmZkYmMxYzM3NmMxOWE0M2FhZjg1MjI3YTQ=");
|
|
||||||
headers.add("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
|
|
||||||
MultiValueMap map = new LinkedMultiValueMap();
|
|
||||||
map.add("username", "dlwr");
|
|
||||||
map.add("password", "C61026E841A2F96E17564AB7333D92E8");//dlwr123!,需要MD5加密
|
|
||||||
map.add("scope", "read");
|
|
||||||
map.add("grant_type", "password");
|
|
||||||
map.add("vc", "NO");
|
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
try {
|
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class);
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
|
||||||
if (jsonObject.getBooleanValue("success") == true) {
|
|
||||||
JSONObject resultJson = jsonObject.getJSONObject("result");
|
|
||||||
return resultJson.getString("accessToken");
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("[qidiToken] exception:{}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//渣土车轨迹数据,最新的
|
|
||||||
public List<Map> resCatalogApplyZTYS () {
|
|
||||||
String token = this.qidiToken();
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Authorization", "Bearer " + token);
|
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
|
||||||
JSONObject search = new JSONObject();
|
|
||||||
search.put("opt","LIKE");
|
|
||||||
search.put("key","UPLOADTIME");
|
|
||||||
search.put("val",this.dateStr());
|
|
||||||
|
|
||||||
// search.put("opt","EQ");
|
|
||||||
// search.put("key","SPEED");
|
|
||||||
// search.put("val","0");
|
|
||||||
map.put("json",search);
|
|
||||||
|
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000022_2?search=[{json}]";
|
|
||||||
|
|
||||||
HttpEntity<Map> httpEntity = new HttpEntity<>(null, headers);
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
try {
|
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class,map);
|
|
||||||
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
|
||||||
log.info("[resCatalogApplyZTYS] 返回数据的数量:{}",jsonArray.size());
|
|
||||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("[resCatalogApplyZTYS] exception:{}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//环卫车轨迹数据
|
|
||||||
public List<Map> resCatalogApplyHJWS () {
|
|
||||||
String token = this.qidiToken();
|
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000442_1?search=[{json}]";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Authorization", "Bearer " + token);
|
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
|
||||||
JSONObject search = new JSONObject();
|
|
||||||
search.put("opt","LIKE");
|
|
||||||
search.put("key","updatetime");
|
|
||||||
search.put("val",this.dateStr());
|
|
||||||
// search.put("opt","EQ");
|
|
||||||
// search.put("key","SIMKH");
|
|
||||||
// search.put("val","13302959786");
|
|
||||||
map.put("json",search);
|
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
try {
|
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
|
||||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("[resCatalogApplyHJWS] exception:{}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//工地信息
|
|
||||||
public List<Map> resCatalogApplyGDYS () {
|
|
||||||
String token = this.qidiToken();
|
|
||||||
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1?search=[{json}]";
|
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Authorization", "Bearer " + token);
|
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
|
||||||
JSONObject search = new JSONObject();
|
|
||||||
search.put("opt","LIKE");
|
|
||||||
search.put("key","updatetime");
|
|
||||||
search.put("val",this.dateStr());
|
|
||||||
// search.put("opt","EQ");
|
|
||||||
// search.put("key","SSDQ");
|
|
||||||
// search.put("val","西海岸新区");
|
|
||||||
map.put("json",search);
|
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
try {
|
|
||||||
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class);
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
|
||||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("[resCatalogApplyGDYS] exception:{}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//环卫车辆数据1,基础
|
|
||||||
public List<Map> resCatalogApplyHJWSBase () {
|
|
||||||
String token = this.qidiToken();
|
|
||||||
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1?search=[{json}]";
|
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Authorization", "Bearer " + token);
|
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
|
||||||
JSONObject search = new JSONObject();
|
|
||||||
// search.put("opt","LIKE");
|
|
||||||
// search.put("key","updatetime");
|
|
||||||
// search.put("val",this.dateStr());
|
|
||||||
search.put("opt","EQ");
|
|
||||||
search.put("key","SSQY");
|
|
||||||
search.put("val","胶州市");
|
|
||||||
map.put("json",search);
|
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
try {
|
|
||||||
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class);
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
|
||||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("[resCatalogApplyHJWSBase] exception:{}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//环卫车辆数据2,作业,5月20号已经把能查到的都保存到表中了(忘了保存updatetime)
|
|
||||||
public List<Map> resCatalogApplyHJWSZY () {
|
|
||||||
String token = this.qidiToken();
|
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1";
|
|
||||||
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Authorization", "Bearer " + token);
|
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
|
||||||
JSONObject search = new JSONObject();
|
|
||||||
// search.put("opt","LIKE");
|
|
||||||
// search.put("key","ZYRQ");
|
|
||||||
// search.put("val",this.dateStr());
|
|
||||||
map.put("json",search);
|
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
try {
|
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
|
||||||
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
|
||||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("[resCatalogApplyHJWSBase] exception:{}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Map> resCatalogApplyHJWSZY(String updatetime) throws Exception{
|
|
||||||
String token = this.qidiToken();
|
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Authorization", "Bearer " + token);
|
|
||||||
|
|
||||||
List<Map> maps = new ArrayList<>();
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
|
||||||
JSONObject search = new JSONObject();
|
|
||||||
search.put("opt","GT");
|
|
||||||
search.put("key","updatetime");
|
|
||||||
search.put("val",updatetime);
|
|
||||||
map.put("json",search);
|
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
|
||||||
maps = JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
|
||||||
|
|
||||||
return maps;
|
|
||||||
}
|
|
||||||
//环卫道路明细数据
|
|
||||||
public List<Map> resCatalogApplyHJWSRoad () {
|
|
||||||
String token = this.qidiToken();
|
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2";
|
|
||||||
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2?search=[{json}]";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Authorization", "Bearer " + token);
|
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
|
||||||
// JSONObject search = new JSONObject();
|
|
||||||
// search.put("opt","LIKE");
|
|
||||||
// search.put("key","updatetime");
|
|
||||||
// search.put("val",this.dateStr());
|
|
||||||
// search.put("opt","EQ");
|
|
||||||
// search.put("key","QDLKDLMC");
|
|
||||||
// search.put("val","宜昌路");
|
|
||||||
// map.put("json",search);
|
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
|
||||||
try {
|
|
||||||
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class);
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
|
||||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("[resCatalogApplyHJWSRoad] exception:{}", e.getMessage());
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//获取当前日期的时间串,2022-05-08 00:00:00
|
|
||||||
private String dateTimeStr(){
|
|
||||||
LocalDate localDate = LocalDate.now();
|
|
||||||
LocalDate yestDay = localDate.minusDays(1);
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
LocalDateTime dateTime = LocalDateTime.of(yestDay.getYear(),yestDay.getMonth(),yestDay.getDayOfMonth(),0,0,0);
|
|
||||||
return dateTime.format(formatter);
|
|
||||||
}
|
|
||||||
//获取当前日期的时间串,2022-05-08
|
|
||||||
private String dateStr(){
|
|
||||||
LocalDate localDate = LocalDate.now();
|
|
||||||
LocalDate yestDay = localDate.minusDays(1);
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
||||||
|
|
||||||
return yestDay.format(formatter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,290 @@
|
||||||
|
package com.hisense.monitormanage.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class QidiService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
|
//启迪数据中台相关
|
||||||
|
//1.登录
|
||||||
|
public String qidiToken () {
|
||||||
|
String url = "http://120.221.95.13:9090/apin/authorization/oauth/token";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Authorization", "Basic dGVzdF9jbGllbnQ6ZTk4OWQ0NmZkYmMxYzM3NmMxOWE0M2FhZjg1MjI3YTQ=");
|
||||||
|
headers.add("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
|
MultiValueMap map = new LinkedMultiValueMap();
|
||||||
|
map.add("username", "dlwr");
|
||||||
|
map.add("password", "C61026E841A2F96E17564AB7333D92E8");//dlwr123!,需要MD5加密
|
||||||
|
map.add("scope", "read");
|
||||||
|
map.add("grant_type", "password");
|
||||||
|
map.add("vc", "NO");
|
||||||
|
|
||||||
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
try {
|
||||||
|
responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class);
|
||||||
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
|
if (jsonObject.getBooleanValue("success") == true) {
|
||||||
|
JSONObject resultJson = jsonObject.getJSONObject("result");
|
||||||
|
return resultJson.getString("accessToken");
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[qidiToken] exception:{}", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//渣土车轨迹数据,最新的
|
||||||
|
public List<Map> resCatalogApplyZTYS () {
|
||||||
|
String token = this.qidiToken();
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
JSONObject search = new JSONObject();
|
||||||
|
search.put("opt","LIKE");
|
||||||
|
search.put("key","UPLOADTIME");
|
||||||
|
search.put("val",this.dateStr());
|
||||||
|
|
||||||
|
// search.put("opt","EQ");
|
||||||
|
// search.put("key","SPEED");
|
||||||
|
// search.put("val","0");
|
||||||
|
map.put("json",search);
|
||||||
|
|
||||||
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000022_2?search=[{json}]";
|
||||||
|
|
||||||
|
HttpEntity<Map> httpEntity = new HttpEntity<>(null, headers);
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
try {
|
||||||
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class,map);
|
||||||
|
|
||||||
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
|
log.info("[resCatalogApplyZTYS] 返回数据的数量:{}",jsonArray.size());
|
||||||
|
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[resCatalogApplyZTYS] exception:{}", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//环卫车轨迹数据
|
||||||
|
public List<Map> resCatalogApplyHJWS () {
|
||||||
|
String token = this.qidiToken();
|
||||||
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000442_1?search=[{json}]";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
JSONObject search = new JSONObject();
|
||||||
|
search.put("opt","LIKE");
|
||||||
|
search.put("key","updatetime");
|
||||||
|
search.put("val",this.dateStr());
|
||||||
|
// search.put("opt","EQ");
|
||||||
|
// search.put("key","SIMKH");
|
||||||
|
// search.put("val","13302959786");
|
||||||
|
map.put("json",search);
|
||||||
|
|
||||||
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
try {
|
||||||
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||||
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
|
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[resCatalogApplyHJWS] exception:{}", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//工地信息
|
||||||
|
public List<Map> resCatalogApplyGDYS () {
|
||||||
|
String token = this.qidiToken();
|
||||||
|
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1?search=[{json}]";
|
||||||
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
JSONObject search = new JSONObject();
|
||||||
|
search.put("opt","LIKE");
|
||||||
|
search.put("key","updatetime");
|
||||||
|
search.put("val",this.dateStr());
|
||||||
|
// search.put("opt","EQ");
|
||||||
|
// search.put("key","SSDQ");
|
||||||
|
// search.put("val","西海岸新区");
|
||||||
|
map.put("json",search);
|
||||||
|
|
||||||
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
try {
|
||||||
|
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||||
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class);
|
||||||
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
|
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[resCatalogApplyGDYS] exception:{}", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//环卫车辆数据1,基础
|
||||||
|
public List<Map> resCatalogApplyHJWSBase () {
|
||||||
|
String token = this.qidiToken();
|
||||||
|
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1?search=[{json}]";
|
||||||
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
JSONObject search = new JSONObject();
|
||||||
|
// search.put("opt","LIKE");
|
||||||
|
// search.put("key","updatetime");
|
||||||
|
// search.put("val",this.dateStr());
|
||||||
|
search.put("opt","EQ");
|
||||||
|
search.put("key","SSQY");
|
||||||
|
search.put("val","胶州市");
|
||||||
|
map.put("json",search);
|
||||||
|
|
||||||
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
try {
|
||||||
|
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||||
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class);
|
||||||
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
|
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[resCatalogApplyHJWSBase] exception:{}", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//环卫车辆数据2,作业,5月20号已经把能查到的都保存到表中了(忘了保存updatetime)
|
||||||
|
public List<Map> resCatalogApplyHJWSZY () {
|
||||||
|
String token = this.qidiToken();
|
||||||
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1";
|
||||||
|
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
JSONObject search = new JSONObject();
|
||||||
|
// search.put("opt","LIKE");
|
||||||
|
// search.put("key","ZYRQ");
|
||||||
|
// search.put("val",this.dateStr());
|
||||||
|
map.put("json",search);
|
||||||
|
|
||||||
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
try {
|
||||||
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||||
|
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||||
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
|
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[resCatalogApplyHJWSBase] exception:{}", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map> resCatalogApplyHJWSZY(String updatetime) throws Exception{
|
||||||
|
String token = this.qidiToken();
|
||||||
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
List<Map> maps = new ArrayList<>();
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
JSONObject search = new JSONObject();
|
||||||
|
search.put("opt","GT");
|
||||||
|
search.put("key","updatetime");
|
||||||
|
search.put("val",updatetime);
|
||||||
|
map.put("json",search);
|
||||||
|
|
||||||
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||||
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
|
maps = JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
|
||||||
|
return maps;
|
||||||
|
}
|
||||||
|
//环卫道路明细数据
|
||||||
|
public List<Map> resCatalogApplyHJWSRoad () {
|
||||||
|
String token = this.qidiToken();
|
||||||
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2";
|
||||||
|
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2?search=[{json}]";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
// JSONObject search = new JSONObject();
|
||||||
|
// search.put("opt","LIKE");
|
||||||
|
// search.put("key","updatetime");
|
||||||
|
// search.put("val",this.dateStr());
|
||||||
|
// search.put("opt","EQ");
|
||||||
|
// search.put("key","QDLKDLMC");
|
||||||
|
// search.put("val","宜昌路");
|
||||||
|
// map.put("json",search);
|
||||||
|
|
||||||
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
try {
|
||||||
|
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||||
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class);
|
||||||
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
|
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[resCatalogApplyHJWSRoad] exception:{}", e.getMessage());
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//获取当前日期的时间串,2022-05-08 00:00:00
|
||||||
|
private String dateTimeStr(){
|
||||||
|
LocalDate localDate = LocalDate.now();
|
||||||
|
LocalDate yestDay = localDate.minusDays(1);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
LocalDateTime dateTime = LocalDateTime.of(yestDay.getYear(),yestDay.getMonth(),yestDay.getDayOfMonth(),0,0,0);
|
||||||
|
return dateTime.format(formatter);
|
||||||
|
}
|
||||||
|
//获取当前日期的时间串,2022-05-08
|
||||||
|
private String dateStr(){
|
||||||
|
LocalDate localDate = LocalDate.now();
|
||||||
|
LocalDate yestDay = localDate.minusDays(1);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
|
||||||
|
return yestDay.format(formatter);
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,6 +38,35 @@ public class RoadDataService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoadDataMapper roadDataMapper;
|
private RoadDataMapper roadDataMapper;
|
||||||
|
|
||||||
|
//道路统计数据与排名,调用公开接口
|
||||||
|
public List<Map> roadData(){
|
||||||
|
String url = "http://outerdata.novaecs.com/api/qingdaoData/roadData?groupId={groupId}&timeType={timeType}&dt={dt}";
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
|
||||||
|
map.put("dt",this.dateTimeStr());
|
||||||
|
map.put("groupId",1);
|
||||||
|
map.put("timeType","日");
|
||||||
|
|
||||||
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
List<Map> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
responseEntity = restTemplate.getForEntity(url, JSONObject.class, map);
|
||||||
|
HttpStatus statusCode = responseEntity.getStatusCode();
|
||||||
|
if (statusCode.is2xxSuccessful()) {
|
||||||
|
JSONObject re = responseEntity.getBody();
|
||||||
|
if (re.getIntValue("status") == 0) {
|
||||||
|
JSONArray jsonArray = re.getJSONArray("data");
|
||||||
|
list = JSONArray.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[roadData] exception:{}", e.getMessage());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//道路统计数据与排名(道路污染),调用公开接口并保存到表t_road_data
|
//道路统计数据与排名(道路污染),调用公开接口并保存到表t_road_data
|
||||||
@Scheduled(cron="0 0 8 * * ?")
|
@Scheduled(cron="0 0 8 * * ?")
|
||||||
public void saveRoadData(){
|
public void saveRoadData(){
|
||||||
|
|
|
@ -31,13 +31,13 @@ public class SanitationService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RestTemplate restTemplate;
|
private RestTemplate restTemplate;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MonitorService monitorService;
|
private QidiService qidiService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SanitationTaskMapper sanitationTaskMapper;
|
private SanitationTaskMapper sanitationTaskMapper;
|
||||||
|
|
||||||
|
|
||||||
public Result saveSantation(){
|
public Result saveSantation(){
|
||||||
List<Map> list = monitorService.resCatalogApplyHJWSBase();
|
List<Map> list = qidiService.resCatalogApplyHJWSBase();
|
||||||
if(list.size() > 0){
|
if(list.size() > 0){
|
||||||
List<List<Map>> maps = Lists.partition(list,100);
|
List<List<Map>> maps = Lists.partition(list,100);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class SanitationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result saveSanitationRoad(){
|
public Result saveSanitationRoad(){
|
||||||
List<Map> list = monitorService.resCatalogApplyHJWSRoad();
|
List<Map> list = qidiService.resCatalogApplyHJWSRoad();
|
||||||
try{
|
try{
|
||||||
if(list.size() > 0){
|
if(list.size() > 0){
|
||||||
List<List<Map>> maps = Lists.partition(list,100);
|
List<List<Map>> maps = Lists.partition(list,100);
|
||||||
|
@ -62,7 +62,7 @@ public class SanitationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result saveSanitationTask(){
|
public Result saveSanitationTask(){
|
||||||
List<Map> list = monitorService.resCatalogApplyHJWSZY();
|
List<Map> list = qidiService.resCatalogApplyHJWSZY();
|
||||||
try{
|
try{
|
||||||
if(list.size() > 0){
|
if(list.size() > 0){
|
||||||
List<List<Map>> maps = Lists.partition(list,100);
|
List<List<Map>> maps = Lists.partition(list,100);
|
||||||
|
@ -86,10 +86,10 @@ public class SanitationService {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(sanitationTask != null){
|
if(sanitationTask != null){
|
||||||
maps = monitorService.resCatalogApplyHJWSZY(String.valueOf(sanitationTask.getUpdatetime()));
|
maps = qidiService.resCatalogApplyHJWSZY(String.valueOf(sanitationTask.getUpdatetime()));
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
maps = monitorService.resCatalogApplyHJWSZY();
|
maps = qidiService.resCatalogApplyHJWSZY();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(maps.size() > 0){
|
if(maps.size() > 0){
|
||||||
|
|
|
@ -29,13 +29,13 @@ public class SedimentTrailService {
|
||||||
private SedimentTrailMapper sedimentTrailMapper;
|
private SedimentTrailMapper sedimentTrailMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MonitorService monitorService;
|
private QidiService qidiService;
|
||||||
|
|
||||||
//获取渣土车轨迹并保存到表t_trail_sediment
|
//获取渣土车轨迹并保存到表t_trail_sediment
|
||||||
//@Transactional(rollbackFor = Exception.class)
|
//@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean batchSaveSedimentTrail(){
|
public boolean batchSaveSedimentTrail(){
|
||||||
try{
|
try{
|
||||||
List<Map> maps = monitorService.resCatalogApplyZTYS();
|
List<Map> maps = qidiService.resCatalogApplyZTYS();
|
||||||
Lists.partition(maps,200).forEach(
|
Lists.partition(maps,200).forEach(
|
||||||
item-> sedimentTrailMapper.batchaSave(item)
|
item-> sedimentTrailMapper.batchaSave(item)
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,12 +18,12 @@ public class TrailSanitationService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TrailSanitationMapper trailSanitationMapper;
|
private TrailSanitationMapper trailSanitationMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MonitorService monitorService;
|
private QidiService qidiService;
|
||||||
|
|
||||||
public boolean saveTrailSanitation(){
|
public boolean saveTrailSanitation(){
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
try{
|
try{
|
||||||
List<Map> list = monitorService.resCatalogApplyHJWS();
|
List<Map> list = qidiService.resCatalogApplyHJWS();
|
||||||
List<List<Map>> lists = Lists.partition(list,200);
|
List<List<Map>> lists = Lists.partition(list,200);
|
||||||
lists.forEach(l->trailSanitationMapper.batchaSave(l));
|
lists.forEach(l->trailSanitationMapper.batchaSave(l));
|
||||||
result = true;
|
result = true;
|
||||||
|
|
|
@ -45,16 +45,16 @@ public class LongLatUtil {
|
||||||
Double longitude = lon;
|
Double longitude = lon;
|
||||||
|
|
||||||
Double degree = (24901 * 1609) / 360.0;
|
Double degree = (24901 * 1609) / 360.0;
|
||||||
double raidusMile = radius;
|
double radiusMile = radius;
|
||||||
|
|
||||||
Double dpmLat = 1 / degree;
|
Double dpmLat = 1 / degree;
|
||||||
Double radiusLat = dpmLat * raidusMile;
|
Double radiusLat = dpmLat * radiusMile;
|
||||||
Double minLat = latitude - radiusLat;
|
Double minLat = latitude - radiusLat;
|
||||||
Double maxLat = latitude + radiusLat;
|
Double maxLat = latitude + radiusLat;
|
||||||
|
|
||||||
Double mpdLng = degree * Math.cos(latitude * (PI / 180));
|
Double mpdLng = degree * Math.cos(latitude * (PI / 180));
|
||||||
Double dpmLng = 1 / mpdLng;
|
Double dpmLng = 1 / mpdLng;
|
||||||
Double radiusLng = dpmLng * raidusMile;
|
Double radiusLng = dpmLng * radiusMile;
|
||||||
Double minLng = longitude - radiusLng;
|
Double minLng = longitude - radiusLng;
|
||||||
Double maxLng = longitude + radiusLng;
|
Double maxLng = longitude + radiusLng;
|
||||||
return new double[]{minLng,minLat, maxLng, maxLat};
|
return new double[]{minLng,minLat, maxLng, maxLat};
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?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.hisense.monitormanage.mapper.PeopleRecognizeMapper">
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -16,10 +16,5 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!-- <select id="selectRoadData" resultType="com.hisense.monitormanage.entity.RoadData">
|
|
||||||
select * from t_road_data
|
|
||||||
<bind name="page" value="(page-1)*pageSize"/>
|
|
||||||
limit #{page},#{pageSize}
|
|
||||||
</select>-->
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue