燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-06-09 8cf0f53240cce2c1843a80600ca97f6be88cd3c3
src/main/java/com/yssh/service/impl/CommonServiceImpl.java
@@ -28,14 +28,14 @@
   protected final Logger logger = LoggerFactory.getLogger(this.getClass());
   private static final String TABLE_SCHEMA = "yssh";
   private List<MonitorPointPosition> checkPoints2d = new ArrayList<>();
   private List<MonitorPointPosition> checkPoints3d = new ArrayList<>();
   @Resource
   private CommonMapper commonMapper;
   @Resource
   protected DatFilePathConfig datFilePathConfig;
@@ -45,89 +45,91 @@
   @Override
   public boolean checkTableExists(String tableName) {
      try {
            Integer count = commonMapper.checkTableExistsWithSchema(TABLE_SCHEMA, tableName);
            return count == 1;
        } catch (Exception e) {
           logger.error("使用information_schema检测表失败", e);
            Map<String, String> list = commonMapper.checkTableExistsWithShow(tableName);
            if(StringUtils.isNotEmpty(list)) {
                return true;
            }
        }
        return false;
         Integer count = commonMapper.checkTableExistsWithSchema(TABLE_SCHEMA, tableName);
         return count == 1;
      } catch (Exception e) {
         logger.error("使用information_schema检测表失败", e);
         Map<String, String> list = commonMapper.checkTableExistsWithShow(tableName);
         if (StringUtils.isNotEmpty(list)) {
            return true;
         }
      }
      return false;
   }
   @Override
   public void readDatData() throws Exception {
        File file2d = new File(datFilePathConfig.getFilePath2d());
        BufferedInputStream fis2d = new BufferedInputStream(new FileInputStream(file2d));
        BufferedReader reader2d = new BufferedReader(new InputStreamReader(fis2d, "utf-8"), 7 * 1024 * 1024);// 用7M的缓冲读取文本文件
        long count2d = 1;
        String line2d = "";
        while ((line2d = reader2d.readLine()) != null) {
            String[] f2d = line2d.split(" ");
            Integer x = Integer.parseInt(f2d[0]);
            Integer y = Integer.parseInt(f2d[1]);
            int z = 0;
      File file2d = new File(datFilePathConfig.getFilePath2d());
      BufferedInputStream fis2d = new BufferedInputStream(new FileInputStream(file2d));
      BufferedReader reader2d = new BufferedReader(new InputStreamReader(fis2d, "utf-8"), 7 * 1024 * 1024);// 用7M的缓冲读取文本文件
      long count2d = 1;
      String line2d = "";
      while ((line2d = reader2d.readLine()) != null) {
         String[] f2d = line2d.split(" ");
         Integer x = Integer.parseInt(f2d[0]);
         Integer y = Integer.parseInt(f2d[1]);
         int z = 0;
         try {
            z = new Double(Math.round(Integer.parseInt(f2d[2]) * 1.0/10)).intValue();
            z = new Double(Math.round(Integer.parseInt(f2d[2]) * 1.0 / 10)).intValue();
         } catch (Exception e) {
            System.out.println(e.getStackTrace());
         }
            //if (x <= 699 && y <= 699)
         //if (x <= 699 && y <= 699)
         {
               MonitorPointPosition monitorPointPosition = new MonitorPointPosition();
               monitorPointPosition.setId(x + "_" + y + "_" + z);
                monitorPointPosition.setName("AI-" + (count2d < 10 ? "0" + count2d : count2d + ""));
                monitorPointPosition.setX(x);
                monitorPointPosition.setY(y);
                monitorPointPosition.setZ(z);
                monitorPointPosition.setLon(CalculateUtils.getLon(monitorPointPosition.getX(), monitorPointPosition.getY()));
                monitorPointPosition.setLat(CalculateUtils.getLat(monitorPointPosition.getX(), monitorPointPosition.getY()));
                checkPoints2d.add(monitorPointPosition);
                count2d++;
            MonitorPointPosition monitorPointPosition = new MonitorPointPosition();
            monitorPointPosition.setId(x + "_" + y + "_" + z);
            monitorPointPosition.setName("AI-" + (count2d < 10 ? "0" + count2d : count2d + ""));
            monitorPointPosition.setX(x);
            monitorPointPosition.setY(y);
            monitorPointPosition.setZ(z);
            monitorPointPosition.setLon(CalculateUtils.getLon(monitorPointPosition.getX(), monitorPointPosition.getY()));
            monitorPointPosition.setLat(CalculateUtils.getLat(monitorPointPosition.getX(), monitorPointPosition.getY()));
            checkPoints2d.add(monitorPointPosition);
            count2d++;
         }
        }
        reader2d.close();
      }
      reader2d.close();
      File file = new File(datFilePathConfig.getFilePath3d());
      BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file));
        BufferedReader reader = new BufferedReader(new InputStreamReader(fis, "utf-8"), 7 * 1024 * 1024);// 用7M的缓冲读取文本文件
        long count3d = 1;
        String line = "";
        while ((line = reader.readLine()) != null) {
            String[] f3d = line.split(" ");
            Integer x = Integer.parseInt(f3d[0]);
            Integer y = Integer.parseInt(f3d[1]);
            int z = 0;
      BufferedReader reader = new BufferedReader(new InputStreamReader(fis, "utf-8"), 7 * 1024 * 1024);// 用7M的缓冲读取文本文件
      long count3d = 1;
      String line = "";
      while ((line = reader.readLine()) != null) {
         String[] f3d = line.split(" ");
         Integer x = Integer.parseInt(f3d[0]);
         Integer y = Integer.parseInt(f3d[1]);
         int z = 0;
         try {
            z = new Double(Math.round(Integer.parseInt(f3d[2]) * 1.0/10)).intValue();
            z = new Double(Math.round(Integer.parseInt(f3d[2]) * 1.0 / 10)).intValue();
         } catch (Exception e) {
            System.out.println(e.getStackTrace());
         }
         if (count3d > 46) break;
         { //if (x <= 699 && y <= 699) {
                MonitorPointPosition monitorPointPosition = new MonitorPointPosition();
                monitorPointPosition.setId(x + "_" + y + "_" + z);
                 monitorPointPosition.setName("AI-" + (count3d < 10 ? "0" + count3d : count3d + ""));
                 monitorPointPosition.setX(x);
                 monitorPointPosition.setY(y);
                 monitorPointPosition.setZ(z);
                 monitorPointPosition.setLon(CalculateUtils.getLon(monitorPointPosition.getX(), monitorPointPosition.getY()));
                 monitorPointPosition.setLat(CalculateUtils.getLat(monitorPointPosition.getX(), monitorPointPosition.getY()));
                 checkPoints3d.add(monitorPointPosition);
                 count3d++;
            }
        }
        reader.close();
            MonitorPointPosition monitorPointPosition = new MonitorPointPosition();
            monitorPointPosition.setId(x + "_" + y + "_" + z);
            monitorPointPosition.setName("AI-" + (count3d < 10 ? "0" + count3d : count3d + ""));
            monitorPointPosition.setX(x);
            monitorPointPosition.setY(y);
            monitorPointPosition.setZ(z);
            monitorPointPosition.setLon(CalculateUtils.getLon(monitorPointPosition.getX(), monitorPointPosition.getY()));
            monitorPointPosition.setLat(CalculateUtils.getLat(monitorPointPosition.getX(), monitorPointPosition.getY()));
            checkPoints3d.add(monitorPointPosition);
            count3d++;
         }
      }
      reader.close();
   }
   public List<MonitorPointPosition> getCheckPoints2d() {
      return checkPoints2d;
   }
   public List<MonitorPointPosition> getCheckPoints3d() {
      return checkPoints3d;
   }
   @Override
   public MonitorPointPosition select2dCheckPointByName(String name) {
      for (MonitorPointPosition monitorPointPosition : checkPoints2d) {
@@ -137,6 +139,7 @@
      }
      return null;
   }
   @Override
   public MonitorPointPosition select3dCheckPointByName(String name) {
      for (MonitorPointPosition monitorPointPosition : checkPoints3d) {
@@ -146,6 +149,7 @@
      }
      return null;
   }
   @Override
   public MonitorPointPosition select2dCheckPointById(String id) {
      for (MonitorPointPosition monitorPointPosition : checkPoints2d) {
@@ -155,10 +159,13 @@
      }
      return null;
   }
   @Override
   public MonitorPointPosition select3dCheckPointById(String id) {
      for (MonitorPointPosition monitorPointPosition : checkPoints3d) {
         if (monitorPointPosition.getId().equals(id)) {
         //if (monitorPointPosition.getId().equals(id)) {
         String subId = id.substring(0, id.lastIndexOf("_") + 1);
         if (monitorPointPosition.getId().contains(subId)) {
            return monitorPointPosition;
         }
      }