燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-07-21 58cb215b67a5bf50fba0d63969f40711fc23135c
1
已修改5个文件
83 ■■■■■ 文件已修改
src/main/java/com/yssh/entity/WarningDetail.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/mapper/QxshMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/WarningAnalyseService.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/QxshMapper.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/SuYuanMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/entity/WarningDetail.java
@@ -27,19 +27,25 @@
    }
    private static final long serialVersionUID = 1610250573910282005L;
    @ApiModelProperty(value = "主键")
    private Long id;
    @ApiModelProperty(value = "溯源数据表名")
    private String tableName;
    @ApiModelProperty(value = "溯源数据编号")
    private String suYuanId;
    @ApiModelProperty(value = "点位名称")
    private String locationName;
    ;
    @ApiModelProperty(value = "时间")
    private Date createTime;
    @ApiModelProperty(value = "类型")
    private Integer type;
    @ApiModelProperty(value = "数值")
    private Double value;
src/main/java/com/yssh/mapper/QxshMapper.java
@@ -18,4 +18,8 @@
    public List<Qxsh> selectMonthTop10(String time);
    public List<Qxsh> select3Hours(@Param("times") List<String> times);
    public List<Qxsh> selectByBeginAndEnd(@Param("start") Integer start, @Param("end") Integer end);
    public Double selectLastYearVal(@Param("time") Integer time, @Param("name") String name);
}
src/main/java/com/yssh/service/WarningAnalyseService.java
@@ -353,7 +353,56 @@
        return map;
    }
    public List<Report> getAlarmAndWarnByTime(Date begin, Date end) {
    public List<Report> getAlarmAndWarnByTime(Date beginDate, Date endDate) {
        String strStart = DateUtils.getYyyyMmDdHh(beginDate);
        String strEnd = DateUtils.getYyyyMmDdHh(endDate);
        Integer start = Integer.parseInt(strStart);
        Integer end = Integer.parseInt(strEnd);
        List<Qxsh> rsList = qxshMapper.selectByBeginAndEnd(start, end);
        if (null == rsList || rsList.isEmpty()) return null;
        Hashtable<String, Boolean> dict = getExistTabDict(rsList);
        List<Report> list = new ArrayList<>();
        for (Qxsh qxsh : rsList) {
            String tab = "su_yuan_" + qxsh.getTime();
            if (!dict.get(tab)) continue;
            MonitorPointPosition point = commonService.select3dCheckPointByName(qxsh.getName());
            String suYuanId = point.getId().substring(0, point.getId().lastIndexOf("_") + 1) + "0";
            Double lastVal = qxshMapper.selectLastYearVal(Integer.parseInt(qxsh.getTime()) - 1000000, qxsh.getName());
            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);
            suMax.setAddr(getAddr(suMax.getId()));
            Report report = Report.calcReport(wd, suYuan, suMax);
            report.setLastVal(lastVal);
            list.add(report);
        }
        return list;
    }
    private Hashtable<String, Boolean> getExistTabDict(List<Qxsh> rsList) {
        Hashtable<String, Boolean> dict = new Hashtable<>();
        for (Qxsh qxsh : rsList) {
            String tab = "su_yuan_" + qxsh.getTime();
            if (dict.containsKey(tab)) {
                continue;
            }
            Boolean b = suYuanMapper.isTableExists(tab) > 0;
            dict.put(tab, b);
        }
        return dict;
    }
    public List<Report> getAlarmAndWarnByTime2(Date begin, Date end) {
        String startTime = DateUtils.getYyyyMmDdHhMmSs(begin);
        String endTime = DateUtils.getYyyyMmDdHhMmSs(end);
@@ -367,9 +416,6 @@
        Hashtable<String, Boolean> dict = new Hashtable<>();
        List<Report> list = new ArrayList<>();
        for (WarningDetail wd : rs) {
            //String time = ymdh.format(wd.getCreateTime());
            //list.add(new WarningVo(wd.getLocationName(), wd.getSuYuanId(), 0.0, 0.0, wd.getValue(), time));
            /*DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(wd.getTableName(), wd.getSuYuanId());
            Double lastVal = warningDetailMapper.getLastYearVal(wd.getId());
@@ -382,7 +428,6 @@
            } else {
                suMax = suYuan;
            }*/
            if (dict.containsKey(wd.getTableName())) {
                if (!dict.get(wd.getTableName())) continue;
            } else {
src/main/resources/mapper/QxshMapper.xml
@@ -28,4 +28,18 @@
            </foreach>
        order by name, time;
    </select>
    <select id="selectByBeginAndEnd" resultType="com.yssh.entity.Qxsh">
        select id, name, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end}
            and value > (select jcbj from alert_config limit 1) and name like 'AI-%'
        order by time, name;
    </select>
    <select id="selectLastYearVal" resultType="java.lang.Double">
         select format(value, 2) "value"
         from yssh_qxsh
         where name = #{name} and time = #{time}
    </select>
</mapper>
src/main/resources/mapper/SuYuanMapper.xml
@@ -165,7 +165,7 @@
    </select>
    <select id="selectSuYuan700ById" resultType="com.yssh.entity.SuYuan700">
        select * from suyuan_700
        select * from suyuan_70_70
        where su_yuan_id = #{id} and create_time = #{time}
        limit 1;
    </select>