|
@@ -41,47 +41,53 @@ public class LogisticsService {
|
|
|
|
|
|
|
|
|
|
public void getLogisticsData(){
|
|
public void getLogisticsData(){
|
|
- JSONObject jsonObject = this.repeat(ApiUrlConfig.getLogisticsUrl());
|
|
|
|
- if (Objects.isNull(jsonObject)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 添加接口请求记录
|
|
|
|
- PlatApiRecord platApiRecord = new PlatApiRecord();
|
|
|
|
- platApiRecord.setApiUrl(ApiUrlConfig.getLogisticsUrl());
|
|
|
|
- platApiRecord.setApiResult(jsonObject.toString());
|
|
|
|
- iPlatApiRecordService.save(platApiRecord);
|
|
|
|
-
|
|
|
|
- JSONArray dataArray = jsonObject.getJSONArray("data");
|
|
|
|
|
|
+ int current = 0;
|
|
List<LargeLogistics> list = new ArrayList<>();
|
|
List<LargeLogistics> list = new ArrayList<>();
|
|
List<LargeAssetDirs> officeAssetList = new ArrayList<>();
|
|
List<LargeAssetDirs> officeAssetList = new ArrayList<>();
|
|
List<LargeAssetDirs> buildingAssetList = new ArrayList<>();
|
|
List<LargeAssetDirs> buildingAssetList = new ArrayList<>();
|
|
List<LargeAssetDirs> serviceAssetList = new ArrayList<>();
|
|
List<LargeAssetDirs> serviceAssetList = new ArrayList<>();
|
|
|
|
+ while (true){
|
|
|
|
+ JSONObject jsonObject = this.repeat(ApiUrlConfig.getLogisticsUrl(), current);
|
|
|
|
+ if (Objects.isNull(jsonObject)) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 添加接口请求记录
|
|
|
|
+ PlatApiRecord platApiRecord = new PlatApiRecord();
|
|
|
|
+ platApiRecord.setApiUrl(ApiUrlConfig.getLogisticsUrl());
|
|
|
|
+ platApiRecord.setApiResult(jsonObject.toString());
|
|
|
|
+ iPlatApiRecordService.save(platApiRecord);
|
|
|
|
|
|
- // 查询所有组织信息
|
|
|
|
- List<PlatAppOrg> orgList = platAppOrgService.selectAppCodeList();
|
|
|
|
- Map<String, String> orgMap = orgList.stream().collect(Collectors.toMap(PlatAppOrg::getAppCode, PlatAppOrg::getAppName, (v1, v2) -> v1));
|
|
|
|
|
|
+ JSONArray dataArray = jsonObject.getJSONObject("data").getJSONObject("quotaAssetMonitoringList").getJSONArray("records");
|
|
|
|
|
|
- for (int i = 0; i < dataArray.size(); i++) {
|
|
|
|
- JSONObject dataItem = dataArray.getJSONObject(i);
|
|
|
|
- LargeLogistics largeLogistics = JSON.parseObject(dataItem.toString(), LargeLogistics.class);
|
|
|
|
- // 业务方提供的数据包含一些不需要的部门数据进行过滤
|
|
|
|
- if ( !orgMap.containsKey(largeLogistics.getOrgId())){
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // 资产列表数据提取
|
|
|
|
- List<LargeAssetDirs> officeList = getAssetList(dataItem, largeLogistics.getOrgId(), "officeAssetDistrs");
|
|
|
|
- officeAssetList.addAll(officeList);
|
|
|
|
|
|
+ // 查询所有组织信息
|
|
|
|
+ List<PlatAppOrg> orgList = platAppOrgService.selectAppCodeList();
|
|
|
|
+ Map<String, String> orgMap = orgList.stream().collect(Collectors.toMap(PlatAppOrg::getAppCode, PlatAppOrg::getAppName, (v1, v2) -> v1));
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
|
+ JSONObject dataItem = dataArray.getJSONObject(i);
|
|
|
|
+ LargeLogistics largeLogistics = JSON.parseObject(dataItem.toString(), LargeLogistics.class);
|
|
|
|
+ // 业务方提供的数据包含一些不需要的部门数据进行过滤
|
|
|
|
+ if ( !orgMap.containsKey(largeLogistics.getOrgId())){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
- List<LargeAssetDirs> buildingList = getAssetList(dataItem, largeLogistics.getOrgId(),"buildingAssetDistrs");
|
|
|
|
- buildingAssetList.addAll(buildingList);
|
|
|
|
|
|
+ // 资产列表数据提取
|
|
|
|
+ List<LargeAssetDirs> officeList = getAssetList(dataItem, largeLogistics.getOrgId(), "officeAssetDistrs");
|
|
|
|
+ officeAssetList.addAll(officeList);
|
|
|
|
|
|
- List<LargeAssetDirs> serviceList = getAssetList(dataItem, largeLogistics.getOrgId(), "serviceAssetDistrs");
|
|
|
|
- serviceAssetList.addAll(serviceList);
|
|
|
|
|
|
+ List<LargeAssetDirs> buildingList = getAssetList(dataItem, largeLogistics.getOrgId(),"buildingAssetDistrs");
|
|
|
|
+ buildingAssetList.addAll(buildingList);
|
|
|
|
|
|
- list.add(largeLogistics);
|
|
|
|
|
|
+ List<LargeAssetDirs> serviceList = getAssetList(dataItem, largeLogistics.getOrgId(), "serviceAssetDistrs");
|
|
|
|
+ serviceAssetList.addAll(serviceList);
|
|
|
|
+
|
|
|
|
+ list.add(largeLogistics);
|
|
|
|
+ }
|
|
|
|
+ current++;
|
|
}
|
|
}
|
|
|
|
+
|
|
platAssetMapper.deleteLogistics();
|
|
platAssetMapper.deleteLogistics();
|
|
platAssetMapper.insertLargePlatLogistics(list);
|
|
platAssetMapper.insertLargePlatLogistics(list);
|
|
platAssetMapper.deleteOfficeAssetDirs();
|
|
platAssetMapper.deleteOfficeAssetDirs();
|
|
@@ -116,18 +122,19 @@ public class LogisticsService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private JSONObject repeat(String url){
|
|
|
|
|
|
+ private JSONObject repeat(String url, int current){
|
|
try {
|
|
try {
|
|
|
|
|
|
- String res = HttpUtils.sendPost(url,"");
|
|
|
|
|
|
+ String res = HttpUtils.sendPost(url,"current=" + current + "&size=200");
|
|
PlatApiRecord platApiRecord = new PlatApiRecord();
|
|
PlatApiRecord platApiRecord = new PlatApiRecord();
|
|
platApiRecord.setApiUrl(url);
|
|
platApiRecord.setApiUrl(url);
|
|
platApiRecord.setApiResult(res);
|
|
platApiRecord.setApiResult(res);
|
|
iPlatApiRecordService.save(platApiRecord);
|
|
iPlatApiRecordService.save(platApiRecord);
|
|
|
|
|
|
if (StringUtils.isNotBlank(res)){
|
|
if (StringUtils.isNotBlank(res)){
|
|
- JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
- return jsonObject;
|
|
|
|
|
|
+ if (JSONObject.parseObject(res).getString("code").equals("200")){
|
|
|
|
+ return JSONObject.parseObject(res);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
PlatApiRecord platApiRecord = new PlatApiRecord();
|
|
PlatApiRecord platApiRecord = new PlatApiRecord();
|