|
@@ -1,6 +1,7 @@
|
|
|
package com.shcd.service.dredging.impl;
|
|
|
|
|
|
import cn.hutool.core.lang.generator.SnowflakeGenerator;
|
|
|
+import cn.hutool.http.HttpException;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.http.Method;
|
|
@@ -153,14 +154,20 @@ public class DredgingServiceImpl implements DredgingService {
|
|
|
ArrayList<DDredgingShip> dDredgingShips = new ArrayList<>();
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
DDredgingShip dDredgingShip = new DDredgingShip();
|
|
|
- Thread.sleep(1);
|
|
|
+ try {
|
|
|
+ Thread.sleep(1);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error("线程休眠问题{}",e.getMessage());
|
|
|
+ }
|
|
|
dDredgingShip.setId(snowflakeGenerator.next().toString());
|
|
|
dDredgingShip.setShipCode(entry.getKey());
|
|
|
dDredgingShip.setShipName(entry.getValue());
|
|
|
dDredgingShip.setIsDelete(0);
|
|
|
dDredgingShips.add(dDredgingShip);
|
|
|
}
|
|
|
- dDredgingShipService.saveOrUpdateBatch(dDredgingShips);
|
|
|
+ if (!CollectionUtils.isEmpty(dDredgingShips)){
|
|
|
+ dDredgingShipService.saveOrUpdateBatch(dDredgingShips);
|
|
|
+ }
|
|
|
//工单轨迹
|
|
|
for (DredgingWorkOrder dredgingWorkOrder : dredgingWorkOrders) {
|
|
|
HashMap<String, String> workOrderParams = new HashMap<>();
|
|
@@ -197,27 +204,31 @@ public class DredgingServiceImpl implements DredgingService {
|
|
|
}
|
|
|
|
|
|
//更新船舶绑定的videId
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("projectId",dredgingImportRule.getProjectOverviewId());
|
|
|
- HttpResponse response = HttpUtil.createPost(dredgingWorkCameraUrl).body(jsonObject.toString()).setConnectionTimeout(30000).execute();
|
|
|
- List<HashMap> hashMaps = JSONArray.parseArray(response.body(), HashMap.class);
|
|
|
- List<DredgingProjectShips> projectShips = dredgingProjectShipService.list(Wrappers.<DredgingProjectShips>lambdaQuery().eq(DredgingProjectShips::getOverviewId, dredgingImportRule.getProjectOverviewId()));
|
|
|
- for (DredgingProjectShips projectShip : projectShips) {
|
|
|
- for (HashMap hashMap : hashMaps) {
|
|
|
- if (hashMap.get("ShipCode").equals(projectShip.getCode())){
|
|
|
- projectShip.setVideoId(hashMap.get("Code").toString());
|
|
|
- break;
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("projectId",dredgingImportRule.getProjectOverviewId());
|
|
|
+ HttpResponse response = HttpUtil.createPost(dredgingWorkCameraUrl).body(jsonObject.toString()).setConnectionTimeout(30000).execute();
|
|
|
+ List<HashMap> hashMaps = JSONArray.parseArray(response.body(), HashMap.class);
|
|
|
+ List<DredgingProjectShips> projectShips = dredgingProjectShipService.list(Wrappers.<DredgingProjectShips>lambdaQuery().eq(DredgingProjectShips::getOverviewId, dredgingImportRule.getProjectOverviewId()));
|
|
|
+ for (DredgingProjectShips projectShip : projectShips) {
|
|
|
+ for (HashMap hashMap : hashMaps) {
|
|
|
+ if (hashMap.get("ShipCode").equals(projectShip.getCode())){
|
|
|
+ projectShip.setVideoId(hashMap.get("Code").toString());
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ dredgingProjectShipService.updateBatchById(projectShips);
|
|
|
+ } catch (HttpException e) {
|
|
|
+ log.error("获取船舶id异常{}",e.getMessage());
|
|
|
}
|
|
|
- dredgingProjectShipService.updateBatchById(projectShips);
|
|
|
} else {
|
|
|
//这里代表主表的信息不存在,没必要继续进行
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("数据导入异常{}",e.getCause());
|
|
|
+ log.error("数据导入异常{}",e.getMessage());
|
|
|
return null;
|
|
|
}
|
|
|
return null;
|