燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-07-31 1cbb3ed5c0c412cd407b7d32e7978f491857d670
1
已修改4个文件
71 ■■■■ 文件已修改
src/main/java/com/yssh/mapper/SuYuanMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/WarningAnalyseService.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/utils/CalculateUtils.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/SuYuanMapper.xml 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/mapper/SuYuanMapper.java
@@ -21,6 +21,8 @@
    DistanceSuYuan getSuYuan500Max(@Param("tableName") String tableName, @Param("ids") List<String> ids);
    DistanceSuYuan getSuYuan500MaxByFilter(@Param("tableName") String tableName, @Param("filter") String filter);
    DistanceSuYuan getSuYuanById(@Param("tableName") String tableName, @Param("id") String id);
    List<Temporary> getTemporary(@Param("tableName") String tableName, @Param("ids") List<String> ids);
src/main/java/com/yssh/service/WarningAnalyseService.java
@@ -46,7 +46,7 @@
    @Resource
    private VocValsService vocValsService;
    private SimpleDateFormat ym = new SimpleDateFormat("yyyyMM%");
    private static HashMap<String, String> filterMap = new HashMap<>();
    @Async("threadPoolTaskExecutor")
    public void insertWarningDetails(List<WarningDetail> warning) throws Exception {
@@ -168,8 +168,12 @@
            WarningDetail wd = new WarningDetail(0L, tab, suYuanId, qxsh.getName(), null, 0, qxsh.getValue());
            DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(tab, suYuanId);
            List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50);
            DistanceSuYuan suMax = suYuanMapper.getSuYuan500Max(tab, ids3d);
            //List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50);
            //DistanceSuYuan suMax = suYuanMapper.getSuYuan500Max(tab, ids3d);
            //String filter = CalculateUtils.getFilterByExtend(point, 50);
            String filter = getFilterByPoint(point, 50);
            DistanceSuYuan suMax = suYuanMapper.getSuYuan500MaxByFilter(tab, filter);
            suMax.setAddr(getAddr(suMax.getId()));
            Report report = Report.calcReport(wd, suYuan, suMax);
@@ -184,6 +188,25 @@
        return list;
    }
    public static String getFilterByPoint(MonitorPointPosition point, int range) {
        String key = String.format("%d_%d_%d", point.getX(), point.getY(), range);
        if (filterMap.containsKey(key)) {
            return filterMap.get(key);
        }
        List<String> ids = CalculateUtils.aloneCrosswiseExtend(point, range);
        for (int i = 0, c = ids.size(); i < c; i++) {
            ids.set(i, "'" + ids.get(i) + "'");
        }
        String filter = "id in (" + StringUtils.join(ids, ",") + ")";
        if (!filterMap.containsKey(key)) {
            filterMap.put(key, filter);
        }
        return filter;
    }
    private Hashtable<String, Boolean> getExistTabDict(List<Qxsh> rsList) {
        Hashtable<String, Boolean> dict = new Hashtable<>();
        for (Qxsh qxsh : rsList) {
src/main/java/com/yssh/utils/CalculateUtils.java
@@ -210,6 +210,16 @@
        return ids;
    }
    /**
     * 根据范围获取查询条件
     */
    public static String getFilterByExtend(MonitorPointPosition point, int range) {
        Integer x = point.getX();
        Integer y = point.getY();
        return String.format("x between %d and %d and y between %d and %d", x - range / 2, x + range / 2, y - range / 2, y + range / 2);
    }
    public static List<String> temporary(MonitorPointPosition point, int range) {
        List<String> ids3d = new ArrayList<>();
        Integer x = point.getX();
src/main/resources/mapper/SuYuanMapper.xml
@@ -113,6 +113,14 @@
        limit 1;
    </select>
    <select id="getSuYuan500MaxByFilter" resultMap="DistanceSuYuanResult">
        select id, x, y, format(c, 2) "c", u, v
        from ${tableName}
        where ${filter}
        order by c desc
        limit 1;
    </select>
    <select id="getSuYuanById" resultMap="DistanceSuYuanResult">
        select id, x, y, format(c, 2) "c", u, v
        from ${tableName}
@@ -209,17 +217,17 @@
    </select>
    
    <update id="createTable" parameterType="java.lang.String">
       CREATE TABLE ${tableName}  (
             `id` varchar(255) NOT NULL COMMENT '主键',
          `x` int(7) NULL DEFAULT NULL,
          `y` int(7) NULL DEFAULT NULL,
          `z` int(7) NULL DEFAULT NULL,
          `u` double NULL DEFAULT NULL,
          `v` double NULL DEFAULT NULL,
          `w` double NULL DEFAULT NULL,
          `c` double NULL DEFAULT NULL,
          PRIMARY KEY (`id`) USING BTREE
        ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
        create table ${tablename}  (
                 `id` varchar(10) not null comment '主键',
              `x` int(3) null default null,
              `y` int(3) null default null,
              `z` int(2) null default null,
              `u` double null default null,
              `v` double null default null,
              `w` double null default null,
              `c` double null default null,
              primary key (`id`) using btree
        ) engine = innodb character set = utf8 collate = utf8_general_ci row_format = dynamic;
    </update>
    
    <update id="update" >