|
|
@@ -0,0 +1,79 @@
|
|
|
+package com.qingjian.module.plat.service;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.qingjian.common.constants.PathConst;
|
|
|
+import com.qingjian.common.exception.ServerException;
|
|
|
+import com.qingjian.common.model.plat.dto.TowerConvertDTO;
|
|
|
+import com.qingjian.common.utils.TowerUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import net.harawata.appdirs.AppDirsFactory;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.fesod.sheet.FesodSheet;
|
|
|
+import org.noear.solon.annotation.Managed;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Managed
|
|
|
+public class TowerService {
|
|
|
+ public List<String> qry(String mnc, String lac, String ci) {
|
|
|
+ if (StrUtil.isNotEmpty(lac) && StrUtil.isNotEmpty(ci)) {
|
|
|
+ return List.of();
|
|
|
+ }
|
|
|
+ Object[] cells = TowerUtils.getCells(460, Integer.parseInt(mnc), lac, ci);
|
|
|
+ // 纬度
|
|
|
+ Object lat = cells[0];
|
|
|
+ // 经度
|
|
|
+ Object lng = cells[1];
|
|
|
+ // 覆盖范围
|
|
|
+ //Object prec = cells[2];
|
|
|
+ // 地址
|
|
|
+ Object address = cells[3];
|
|
|
+ List<String> record = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotNull(lat)) {
|
|
|
+ record.add(lat.toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotNull(lng)) {
|
|
|
+ record.add(lng.toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotNull(address)) {
|
|
|
+ String addressStr = address.toString();
|
|
|
+ String[] addrArray = addressStr.split(";");
|
|
|
+ record.add(addrArray[0]);
|
|
|
+ }
|
|
|
+ return record;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String covFile(String file) {
|
|
|
+ Path path = Paths.get(file);
|
|
|
+ if (Files.notExists(path)) {
|
|
|
+ throw new ServerException("文件不存在!");
|
|
|
+ }
|
|
|
+ String userDownloadsDir = AppDirsFactory.getInstance().getUserDownloadsDir(null, null, null);
|
|
|
+ String fileName = "基站转换结果" + System.currentTimeMillis() + ".xlsx";
|
|
|
+ Path exportPath = Paths.get(userDownloadsDir, fileName);
|
|
|
+ String exportPathStr = exportPath.toAbsolutePath().normalize().toString();
|
|
|
+ TowerListener towerListener = new TowerListener(exportPathStr);
|
|
|
+ FesodSheet.read(path.toFile(), TowerConvertDTO.class, towerListener).sheet().headRowNumber(2).numRows(50000).doRead();
|
|
|
+ return exportPathStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String tmpFile() {
|
|
|
+ String userDownloadsDir = AppDirsFactory.getInstance().getUserDownloadsDir(null, null, null);
|
|
|
+ String fileName = "基站导入模板" + System.currentTimeMillis() + ".xls";
|
|
|
+ Path exportPath = Paths.get(userDownloadsDir, fileName);
|
|
|
+ try {
|
|
|
+ FileUtils.copyFile(PathConst.COV_TMP_PATH.toFile(), exportPath.toFile());
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("复制基站导入模板文件失败!", e);
|
|
|
+ throw new ServerException("获取基站导入模板文件失败!");
|
|
|
+ }
|
|
|
+ return exportPath.toAbsolutePath().normalize().toString();
|
|
|
+ }
|
|
|
+}
|