燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-06-06 4a4179b19501059168bd2d725bf6294708c99ec3
添加Voc的地址
已添加1个文件
已修改6个文件
133 ■■■■■ 文件已修改
src/main/java/com/yssh/controller/SuYuanController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/dao/VocValsMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/entity/VocCoords.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/entity/VocVals.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/VocValsService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapping/VocValsMapper.xml 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ys.sql 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/controller/SuYuanController.java
@@ -151,4 +151,11 @@
        return Result.OK(list);
    }
    @ApiOperation(value = "根据X,Y值查询地址", notes = "根据X,Y值查询地址")
    @ApiOperationSupport(order = 12)
    @GetMapping("/selectCoords")
    public Result selectVocByTime(@RequestParam(value = "x", required = false) Integer x, @RequestParam(value = "y", required = false) Integer y) {
        return Result.OK(vocValsService.selectCoords(x, y));
    }
}
src/main/java/com/yssh/dao/VocValsMapper.java
@@ -1,5 +1,6 @@
package com.yssh.dao;
import com.yssh.entity.VocCoords;
import com.yssh.entity.VocVals;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -30,6 +31,15 @@
    public int countByTime(@Param("time") String time);
    /**
     * æ ¹æ®X,Y值查询地址
     *
     * @param x X值
     * @param y Y值
     * @return åœ°å€
     */
    public List<VocCoords> selectCoords(@Param("x") Integer x, @Param("y") Integer y);
    /**
     * æ’入一条数据
     *
     * @param vv Voc实体类
src/main/java/com/yssh/entity/VocCoords.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,62 @@
package com.yssh.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.github.biyanwen.annotation.CsvProperty;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
public class VocCoords implements Serializable {
    private static final long serialVersionUID = -20230606150000000L;
    @JsonIgnore
    @ApiModelProperty(value = "主键")
    private Integer id;
    @CsvProperty(index = 0)
    @ApiModelProperty(value = "X")
    private Integer x;
    @CsvProperty(index = 1)
    @ApiModelProperty(value = "Y")
    private Integer y;
    @CsvProperty(index = 2)
    @ApiModelProperty(value = "地址")
    private String addr;
    public VocCoords() {
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getX() {
        return x;
    }
    public void setX(Integer x) {
        this.x = x;
    }
    public Integer getY() {
        return y;
    }
    public void setY(Integer y) {
        this.y = y;
    }
    public String getAddr() {
        return addr;
    }
    public void setAddr(String addr) {
        this.addr = addr;
    }
}
src/main/java/com/yssh/entity/VocVals.java
@@ -31,6 +31,9 @@
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    @ApiModelProperty(value = "地址")
    private String addr;
    public VocVals() {
    }
@@ -73,4 +76,12 @@
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getAddr() {
        return addr;
    }
    public void setAddr(String addr) {
        this.addr = addr;
    }
}
src/main/java/com/yssh/service/VocValsService.java
@@ -2,6 +2,7 @@
import com.google.common.collect.Lists;
import com.yssh.dao.VocValsMapper;
import com.yssh.entity.VocCoords;
import com.yssh.entity.VocVals;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,6 +31,11 @@
    }
    @Override
    public List<VocCoords> selectCoords(Integer x, Integer y) {
        return vocValsMapper.selectCoords(x, y);
    }
    @Override
    public int insert(VocVals vv) {
        return vocValsMapper.insert(vv);
    }
src/main/resources/mapping/VocValsMapper.xml
@@ -7,13 +7,15 @@
        <result property="y" column="y" />
        <result property="val" column="val" />
        <result property="createTime" column="create_time" />
        <result property="addr" column="addr" />
    </resultMap>
    <select id="selectByTime" resultMap="selectMap">
        select x, y, format(val, 2) "val"
        from voc_vals
        where date_format(create_time, '%Y%m%d%H') = ${time}
            and val > (select jcyj from alert_config);
        select a.x, a.y, format(a.val, 2) "val", b.addr
        from voc_vals a inner join voc_addr b
        on a.x = b.x and a.y = b.y
        where date_format(a.create_time, '%Y%m%d%H') = ${time}
            and a.val > (select jcyj from alert_config);
    </select>
    <select id="countByTime" resultType="java.lang.Integer">
@@ -22,6 +24,20 @@
        where date_format(create_time, '%Y%m%d%H') = ${time};
    </select>
    <select id="selectCoords" resultType="com.yssh.entity.VocCoords">
        select x, y, addr
        from voc_addr
        <where>
            1 = 1
            <if test="x != null">
                and x = ${x}
            </if>
            <if test="y != null">
                and y = ${y}
            </if>
        </where>
    </select>
    <insert id="insert" parameterType="com.yssh.entity.VocVals" useGeneratedKeys="false" keyProperty="id">
        insert into voc_vals (id, x, y, val, create_time) values
        (${id}, ${x}, ${y}, ${val}, ${createTime});
ys.sql
@@ -12,13 +12,18 @@
    val double(25, 10) comment '值',
    create_time datetime comment '值'
);
-- drop table voc_vals;
create index voc_vals_val on voc_vals (val);
create index voc_vals_time on voc_vals (create_time);
----------------------------------------------------------------------
/* select a.*, date_format(create_time, '%Y%m%d%H') "time" from voc_vals a where date_format(create_time, '%Y%m%d%H') = '2023060514';
create table voc_addr (
    id int not null auto_increment primary key comment '主键',
    x int comment 'X',
    y int comment 'Y',
    addr varchar(50) comment '地址'
);
----------------------------------------------------------------------
select a.*, date_format(create_time, '%Y%m%d%H') "time" from voc_vals a where date_format(create_time, '%Y%m%d%H') = '2023060514';
select * from voc_vals where create_time < date_sub(now(), interval 1 year);
select date_sub(now(), interval 1 year) "time" from dual;
select count(*) from voc_vals; */
select * from voc_vals;
select * from voc_addr;