2025年5月13日11:02:36

1.代码更新
2.部署配置
main
liuao 2 weeks ago
parent 731748a88c
commit c48dc5d031
  1. 2
      pom.xml
  2. 5
      src/main/java/com/zilber/boot/module/vehicle/constant/Constant.java
  3. 8
      src/main/java/com/zilber/boot/module/vehicle/controller/VehicleController.java
  4. 5
      src/main/java/com/zilber/boot/module/vehicle/service/TourRunService.java
  5. 117
      src/main/java/com/zilber/boot/module/vehicle/service/impl/TourRunServiceImpl.java

@ -273,7 +273,7 @@
<build>
<finalName>zilberboot</finalName>
<finalName>intelligenceSite</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>

@ -1,5 +1,8 @@
package com.zilber.boot.module.vehicle.constant;
import java.util.Arrays;
import java.util.List;
/**
* @Author LJX
* @TIME 2025-05-06 13:38
@ -23,4 +26,6 @@ public class Constant {
public final static String SUCCESS_CODE = "0";
public final static List<String> SCOPES = Arrays.asList("aotomobile", "personal");
}

@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @Author LJX
* @TIME 2025-05-06 11:57
@ -33,6 +35,12 @@ public class VehicleController {
return AjaxResult.success(service.list(pr));
}
@GetMapping("/stat")
@ApiOperation("统计")
public AjaxResult stat() {
return AjaxResult.success(service.stat());
}
@GetMapping("/h5")
@ApiOperation("h5")
public AjaxResult h5(

@ -2,6 +2,9 @@ package com.zilber.boot.module.vehicle.service;
import com.zilber.boot.module.vehicle.dto.pr.DevicePR;
import com.zilber.boot.utils.page.PageUtils;
import io.swagger.models.auth.In;
import java.util.Map;
/**
* @Author LJX
@ -14,6 +17,8 @@ public interface TourRunService {
PageUtils list(DevicePR pr);
Map<String, Integer> stat();
String h5(String tabType, String imei);
String token();

@ -67,36 +67,37 @@ public class TourRunServiceImpl
@Override
public PageUtils list(DevicePR pr) {
String token = token();
Map<String, String> paramMap = paramMap(Method.LIST.getCode());
// 私有参数
paramMap.put("access_token", token);
paramMap.put("target", properties.getTourRunAccount());
// 计算签名
String sign = "";
try {
sign = SignUtils.signTopRequest(paramMap, properties.getAppSecret(), Constant.MD5);
paramMap.put("sign", sign);
} catch (IOException e) {
e.printStackTrace();
}
//调用com/zilber/boot/module/vehicle/util/http/HttpUtils方法
JSONObject jsonObject = sendPost(properties.getOpenapiUrl(), headerMap(), paramMap);
//初始化列表
// List<JSONObject> resultList = null;
// if ( jsonObject != null) {
// if ( !jsonObject.get("code").toString().equals("0"))
// {
// throw new ServiceException(jsonObject.get("message").toString());
// }
// resultList = jsonObject.getList("result", JSONObject.class);
// }
// else {
// throw new ServiceException("列表获取失败");
// String token = token();
//
// Map<String, String> paramMap = paramMap(Method.LIST.getCode());
//
// // 私有参数
// paramMap.put("access_token", token);
// paramMap.put("target", properties.getTourRunAccount());
// // 计算签名
// String sign = "";
// try {
// sign = SignUtils.signTopRequest(paramMap, properties.getAppSecret(), Constant.MD5);
// paramMap.put("sign", sign);
// } catch (IOException e) {
// e.printStackTrace();
// }
List<JSONObject> resultList = handleResult(jsonObject, JSONObject.class, "获取列表失败");
// //调用com/zilber/boot/module/vehicle/util/http/HttpUtils方法
// JSONObject jsonObject = sendPost(properties.getOpenapiUrl(), headerMap(), paramMap);
// //初始化列表
//// List<JSONObject> resultList = null;
//// if ( jsonObject != null) {
//// if ( !jsonObject.get("code").toString().equals("0"))
//// {
//// throw new ServiceException(jsonObject.get("message").toString());
//// }
//// resultList = jsonObject.getList("result", JSONObject.class);
//// }
//// else {
//// throw new ServiceException("列表获取失败");
//// }
// List<JSONObject> resultList = handleResult(jsonObject, JSONObject.class, "获取列表失败");
List<JSONObject> resultList = resultList();
if (CollectionUtils.isNotEmpty(resultList))
{
List<JSONObject> handledList = resultList.stream()
@ -116,6 +117,31 @@ public class TourRunServiceImpl
return new PageUtils(new ArrayList<>(), 0, pr.getPageSize(), pr.getPageNo());
}
@Override
public Map<String, Integer> stat() {
Map<String, Integer> resultMap = new HashMap<>(Constant.SCOPES.size());
List<JSONObject> resultList = resultList();
if (CollectionUtils.isNotEmpty(resultList)) {
Map<String, List<JSONObject>> scopeMap
= resultList.stream()
.collect(Collectors.groupingBy(jo -> jo.get("mcTypeUseScope").toString()));
for ( String scope: Constant.SCOPES) {
List<JSONObject> jsonObjects = scopeMap.get(scope);
if ( CollectionUtils.isNotEmpty(jsonObjects)) {
resultMap.put(scope, jsonObjects.size());
}
else {
resultMap.put(scope, 0);
}
}
return resultMap;
}
for ( String scope: Constant.SCOPES) {
resultMap.put(scope, 0);
}
return resultMap;
}
//https://openh5.aichezaixian.com/?token=XXX&imei=AAA&appKey=BBB&activeTab=CCC
@Override
public String h5(String tabType, String imei) {
@ -175,6 +201,39 @@ public class TourRunServiceImpl
return formatter.format(new Date());
}
private List<JSONObject> resultList() {
String token = token();
Map<String, String> paramMap = paramMap(Method.LIST.getCode());
// 私有参数
paramMap.put("access_token", token);
paramMap.put("target", properties.getTourRunAccount());
// 计算签名
String sign = "";
try {
sign = SignUtils.signTopRequest(paramMap, properties.getAppSecret(), Constant.MD5);
paramMap.put("sign", sign);
} catch (IOException e) {
e.printStackTrace();
}
//调用com/zilber/boot/module/vehicle/util/http/HttpUtils方法
JSONObject jsonObject = sendPost(properties.getOpenapiUrl(), headerMap(), paramMap);
//初始化列表
// List<JSONObject> resultList = null;
// if ( jsonObject != null) {
// if ( !jsonObject.get("code").toString().equals("0"))
// {
// throw new ServiceException(jsonObject.get("message").toString());
// }
// resultList = jsonObject.getList("result", JSONObject.class);
// }
// else {
// throw new ServiceException("列表获取失败");
// }
return handleResult(jsonObject, JSONObject.class, "获取列表失败");
}
/**
* 构造并初始化部分参数的请求头map
* @return map

Loading…
Cancel
Save