Browse Source

单位信息获取地图经纬度做处理

yq 3 years ago
parent
commit
5429afba69

+ 9 - 6
mhfire-service/src/main/java/com/bizmatics/mhfire/service/impl/UnitServiceImpl.java

@@ -17,6 +17,7 @@ import com.bizmatics.mhfire.service.enums.BsSaTwoCode;
 import com.bizmatics.mhfire.service.util.GouldUtil;
 import com.bizmatics.mhfire.service.vo.UnitAlCheckVO;
 import com.google.common.collect.Lists;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -60,14 +61,16 @@ public class UnitServiceImpl implements UnitService {
         for (List<UnitPO> listLimit:subSets) {
             String addressList = listLimit.stream().map(UnitPO::getAddress).collect(Collectors.joining("|"));
             List<LocateInfo> lonLat = GouldUtil.getLonLat(addressList);
-            for (UnitPO unitPo:listLimit) {
-                unitPo.setLatitude(lonLat.get(listLimit.indexOf(unitPo)).getLatitude());
-                unitPo.setLongitude(lonLat.get(listLimit.indexOf(unitPo)).getLongitude());
-                unitPo.setDistrict(lonLat.get(listLimit.indexOf(unitPo)).getDistrict());
-                unitPo.setStreet(lonLat.get(listLimit.indexOf(unitPo)).getStreet());
+            if (CollectionUtils.isNotEmpty(lonLat)){
+                for (UnitPO unitPo:listLimit) {
+                    unitPo.setLatitude(lonLat.get(listLimit.indexOf(unitPo)).getLatitude());
+                    unitPo.setLongitude(lonLat.get(listLimit.indexOf(unitPo)).getLongitude());
+                    unitPo.setDistrict(lonLat.get(listLimit.indexOf(unitPo)).getDistrict());
+                    unitPo.setStreet(lonLat.get(listLimit.indexOf(unitPo)).getStreet());
 
+                }
+                unitMapper.updateList(listLimit);
             }
-            unitMapper.updateList(listLimit);
         }
         return new CommonPage<>(list, page.getTotal(), page.getSize(), page.getCurrent());