燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-06-09 8cf0f53240cce2c1843a80600ca97f6be88cd3c3
修改预警和报警信息入库的层级、id获取规则、判断依据等
已修改4个文件
151 ■■■■ 文件已修改
src/main/java/com/yssh/run/InitDataRunner.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/scheduled/ReadCsvTask.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/impl/CommonServiceImpl.java 131 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapping/SuYuanMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/run/InitDataRunner.java
@@ -56,7 +56,10 @@
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MONTH, 5);
        calendar.set(Calendar.DAY_OF_MONTH, 8);
        calendar.set(Calendar.HOUR_OF_DAY, 13);
        calendar.set(Calendar.HOUR_OF_DAY, 16);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        warningAnalyseService.warningOperationStorage(calendar.getTime());
    }
src/main/java/com/yssh/scheduled/ReadCsvTask.java
@@ -133,10 +133,13 @@
        }
    }
    private Calendar getCalendar(int start) {
    public Calendar getCalendar(int start) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.HOUR, start);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        // 测试 -> 2023-04-23 19:00
        //calendar.set(Calendar.MONTH, 3);
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;
            }
        }
src/main/resources/mapping/SuYuanMapper.xml
@@ -113,15 +113,15 @@
        </foreach>
        AND c > (SELECT jcbj FROM alert_config LIMIT 1)
    </select>
    <select id="getWarningAnalyse" resultMap="SuYuan2dResult">
        SELECT id, x, y, c
        FROM ${tableName}
        WHERE id IN
        SELECT id, x, y, c
        FROM ${tableName}
        WHERE id IN
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        AND c > (SELECT jcyj FROM alert_config LIMIT 1)
        and c > (select jcyj from alert_config limit 1) and c &lt;= (select jcbj from alert_config limit 1)
    </select>
    
    <select id="getMonitorData" resultMap="SuYuanMonitorDataResult">