浏览代码

任务提交 散点图接口更新

qinguocai 1 年之前
父节点
当前提交
585f1cd5b9

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TaskResult.java

@@ -105,5 +105,10 @@ public class TaskResult implements Serializable {
      */
     private String partwspeeds;
 
+    /**
+     * 水位
+     */
+    private Double waterlevel;
+
 }
 

+ 38 - 0
ruoyi-system/src/main/java/com/ruoyi/system/dto/TaskResultSortDTO.java

@@ -0,0 +1,38 @@
+package com.ruoyi.system.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 测流成果上报(TaskResult)实体类
+ *
+ * @author makejava
+ * @since 2024-04-23 11:16:49
+ */
+@Data
+public class TaskResultSortDTO implements Serializable {
+    /**
+     * 成果ID
+     */
+    private Long resultId;
+
+    /**
+     * 总瞬时流量
+     */
+    private Double flowsum;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    /**
+     * 水位
+     */
+    private Double waterlevel;
+
+}
+

+ 13 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TaskResultMapper.java

@@ -2,7 +2,9 @@ package com.ruoyi.system.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.system.domain.TaskResult;
+import com.ruoyi.system.dto.TaskResultSortDTO;
 import com.ruoyi.system.paramet.AchievementQuery;
+import com.ruoyi.system.paramet.ScattperPlotQuery;
 import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
@@ -30,7 +32,6 @@ public interface TaskResultMapper {
      */
     TaskResult queryByTaskid(String taskid);
 
-
     /**
      * 通过ID查询单条数据
      *
@@ -39,6 +40,17 @@ public interface TaskResultMapper {
      */
     TaskResult queryBySiteIdOne(Long siteId);
 
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param scattperPlotQuery 主键
+     * @return 实例对象
+     */
+    List<TaskResultSortDTO> queryByTimeQuery(@Param("scattperPlotQuery") ScattperPlotQuery scattperPlotQuery);
+
+
+
     /**
      * 查询指定行数据
      *

+ 38 - 0
ruoyi-system/src/main/java/com/ruoyi/system/paramet/ScattperPlotQuery.java

@@ -0,0 +1,38 @@
+package com.ruoyi.system.paramet;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 停泊点配置(BerthingPoint)实体类
+ *
+ * @author makejava
+ * @since 2024-04-10 15:29:55
+ */
+@Data
+public class ScattperPlotQuery implements Serializable {
+
+    /**
+     * 站点ID
+     */
+    @NotNull(message = "站点ID不能为空")
+    private Long siteId;
+
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date startTime;
+
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endTime;
+
+}
+

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/AchievementService.java

@@ -9,6 +9,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
+import java.util.List;
 
 
 public interface AchievementService {
@@ -20,5 +21,6 @@ public interface AchievementService {
 
     boolean downAchievement(Long result_id, HttpServletResponse response);
 
+    List<TaskResultSortDTO> getScatterPlot(ScattperPlotQuery scattperPlotQuery);
 
 }

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AchievementServiceImpl.java

@@ -9,11 +9,14 @@ import com.alibaba.excel.util.MapUtils;
 import com.alibaba.excel.write.metadata.WriteSheet;
 import com.alibaba.excel.write.metadata.fill.FillWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.system.domain.TaskResult;
 import com.ruoyi.system.domain.WaterLevel;
+import com.ruoyi.system.dto.TaskResultSortDTO;
 import com.ruoyi.system.mapper.TaskResultMapper;
 import com.ruoyi.system.mapper.WaterLevelMapper;
 import com.ruoyi.system.paramet.AchievementQuery;
+import com.ruoyi.system.paramet.ScattperPlotQuery;
 import com.ruoyi.system.paramet.WaterLevelQuery;
 import com.ruoyi.system.service.AchievementService;
 import lombok.extern.slf4j.Slf4j;
@@ -163,6 +166,17 @@ public class AchievementServiceImpl implements AchievementService {
     }
 
 
+    @Override
+    public List<TaskResultSortDTO> getScatterPlot(ScattperPlotQuery scattperPlotQuery){
+        try {
+            return taskResultMapper.queryByTimeQuery(scattperPlotQuery);
+        } catch (Exception e){
+            log.error("获取数据失败", e);
+            throw new BaseException("获取数据失败");
+        }
+
+    }
+
 
     public static <T> List<T> insertEmptyDataOnEvenRows(List<T> list, T emptyValue) {
         List<T> modifiedList = new ArrayList<>(list.size() * 2 - 1); // 预估新列表的大小

+ 37 - 11
ruoyi-system/src/main/resources/mapper/TaskResultMapper.xml

@@ -24,12 +24,20 @@
         <result property="status" column="status" jdbcType="INTEGER"/>
         <result property="stopwspeeds" column="stopwspeeds" jdbcType="VARCHAR"/>
         <result property="partwspeeds" column="partwspeeds" jdbcType="VARCHAR"/>
+        <result property="waterlevel" column="waterlevel" jdbcType="NUMERIC"/>
+    </resultMap>
+
+    <resultMap type="com.ruoyi.system.dto.TaskResultSortDTO" id="TaskResultSortDTOMap">
+        <result property="resultId" column="result_id" jdbcType="INTEGER"/>
+        <result property="flowsum" column="flowsum" jdbcType="NUMERIC"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="waterlevel" column="waterlevel" jdbcType="NUMERIC"/>
     </resultMap>
 
     <!--查询单个-->
     <select id="queryById" resultMap="TaskResultMap">
         select
-            result_id, id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds
+            result_id, id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds, waterlevel
         from task_result
         where result_id = #{resultId}
     </select>
@@ -37,7 +45,7 @@
     <!--查询单个-->
     <select id="queryByTaskid" resultMap="TaskResultMap">
         select
-            result_id, id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds
+            result_id, id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds, waterlevel
         from task_result
         where taskid = #{taskid}
         limit 1
@@ -46,17 +54,28 @@
     <!--查询单个-->
     <select id="queryBySiteIdOne" resultMap="TaskResultMap">
         select
-            result_id, id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds
+            result_id, id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds, waterlevel
         from task_result
         where site_id = #{siteId}
         order by create_time desc
         limit 1
     </select>
 
+    <!--查询单个-->
+    <select id="queryByTimeQuery" resultMap="TaskResultSortDTOMap">
+        select
+            result_id, flowsum, create_time, waterlevel
+        from task_result
+        where site_id = #{scattperPlotQuery.siteId} and waterlevel is not null
+        <if test="scattperPlotQuery.startTime != null and scattperPlotQuery.endTime != null">
+            and create_time between #{scattperPlotQuery.startTime} and #{scattperPlotQuery.endTime}
+        </if>
+    </select>
+
     <!--查询指定行数据-->
     <select id="queryAllByLimit" resultMap="TaskResultMap">
         select
-            result_id, id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds
+            result_id, id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds, waterlevel
         from task_result
         <where>
             <if test="achievementQuery.siteId != null">
@@ -134,28 +153,31 @@
             <if test="partwspeeds != null and partwspeeds != ''">
                 and partwspeeds = #{partwspeeds}
             </if>
+            <if test="waterlevel != null">
+                and waterlevel = #{waterlevel}
+            </if>
         </where>
     </select>
 
     <!--新增所有列-->
     <insert id="insert" keyProperty="resultId" useGeneratedKeys="true">
-        insert into task_result(id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds)
-        values (#{id}, #{type}, #{taskid}, #{starttime}, #{endtime}, #{width}, #{planid}, #{acreagesum}, #{flowsum}, #{positions}, #{elevations}, #{acreages}, #{waterlevels}, #{wspeeds}, #{flows}, #{siteId}, #{createTime}, #{status}, #{stopwspeeds}, #{partwspeeds})
+        insert into task_result(id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds, waterlevel)
+        values (#{id}, #{type}, #{taskid}, #{starttime}, #{endtime}, #{width}, #{planid}, #{acreagesum}, #{flowsum}, #{positions}, #{elevations}, #{acreages}, #{waterlevels}, #{wspeeds}, #{flows}, #{siteId}, #{createTime}, #{status}, #{stopwspeeds}, #{partwspeeds}, #{waterlevel})
     </insert>
 
     <insert id="insertBatch" keyProperty="resultId" useGeneratedKeys="true">
-        insert into task_result(id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds)
+        insert into task_result(id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds, waterlevel)
         values
         <foreach collection="entities" item="entity" separator=",">
-        (#{entity.id}, #{entity.type}, #{entity.taskid}, #{entity.starttime}, #{entity.endtime}, #{entity.width}, #{entity.planid}, #{entity.acreagesum}, #{entity.flowsum}, #{entity.positions}, #{entity.elevations}, #{entity.acreages}, #{entity.waterlevels}, #{entity.wspeeds}, #{entity.flows}, #{entity.siteId}, #{entity.createTime}, #{entity.status}, #{entity.stopwspeeds}, #{entity.partwspeeds})
+        (#{entity.id}, #{entity.type}, #{entity.taskid}, #{entity.starttime}, #{entity.endtime}, #{entity.width}, #{entity.planid}, #{entity.acreagesum}, #{entity.flowsum}, #{entity.positions}, #{entity.elevations}, #{entity.acreages}, #{entity.waterlevels}, #{entity.wspeeds}, #{entity.flows}, #{entity.siteId}, #{entity.createTime}, #{entity.status}, #{entity.stopwspeeds}, #{entity.partwspeeds}, #{entity.waterlevel})
         </foreach>
     </insert>
 
     <insert id="insertOrUpdateBatch" keyProperty="resultId" useGeneratedKeys="true">
-        insert into task_result(id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds)
+        insert into task_result(id, type, taskid, starttime, endtime, width, planid, acreagesum, flowsum, positions, elevations, acreages, waterlevels, wspeeds, flows, site_id, create_time, status, stopwspeeds, partwspeeds, waterlevel)
         values
         <foreach collection="entities" item="entity" separator=",">
-            (#{entity.id}, #{entity.type}, #{entity.taskid}, #{entity.starttime}, #{entity.endtime}, #{entity.width}, #{entity.planid}, #{entity.acreagesum}, #{entity.flowsum}, #{entity.positions}, #{entity.elevations}, #{entity.acreages}, #{entity.waterlevels}, #{entity.wspeeds}, #{entity.flows}, #{entity.siteId}, #{entity.createTime}, #{entity.status}, #{entity.stopwspeeds}, #{entity.partwspeeds})
+            (#{entity.id}, #{entity.type}, #{entity.taskid}, #{entity.starttime}, #{entity.endtime}, #{entity.width}, #{entity.planid}, #{entity.acreagesum}, #{entity.flowsum}, #{entity.positions}, #{entity.elevations}, #{entity.acreages}, #{entity.waterlevels}, #{entity.wspeeds}, #{entity.flows}, #{entity.siteId}, #{entity.createTime}, #{entity.status}, #{entity.stopwspeeds}, #{entity.partwspeeds}, #{entity.waterlevel})
         </foreach>
         on duplicate key update
 id = values(id),
@@ -177,7 +199,8 @@ site_id = values(site_id),
 create_time = values(create_time),
 status = values(status),
 stopwspeeds = values(stopwspeeds),
-partwspeeds = values(partwspeeds)
+partwspeeds = values(partwspeeds),
+waterlevel = values(waterlevel)
     </insert>
 
     <!--通过主键修改数据-->
@@ -244,6 +267,9 @@ partwspeeds = values(partwspeeds)
             <if test="partwspeeds != null and partwspeeds != ''">
                 partwspeeds = #{partwspeeds},
             </if>
+            <if test="waterlevel != null">
+                waterlevel = #{waterlevel},
+            </if>
         </set>
         where result_id = #{resultId}
     </update>

+ 8 - 2
waterAffairs-admin/src/main/java/com/ruoyi/web/controller/tool/AchievementController.java

@@ -6,8 +6,10 @@ import com.ruoyi.common.utils.R;
 import com.ruoyi.system.domain.BerthingPoint;
 import com.ruoyi.system.domain.TaskResult;
 import com.ruoyi.system.domain.WaterLevel;
+import com.ruoyi.system.dto.TaskResultSortDTO;
 import com.ruoyi.system.paramet.AchievementQuery;
 import com.ruoyi.system.paramet.BerthingPointQuery;
+import com.ruoyi.system.paramet.ScattperPlotQuery;
 import com.ruoyi.system.paramet.WaterLevelQuery;
 import com.ruoyi.system.service.AchievementService;
 import io.swagger.annotations.Api;
@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import java.util.List;
 
 
 /**
@@ -52,8 +55,11 @@ public class AchievementController {
         return R.ok(achievementService.getWaterLevelList(waterLevelQuery));
     }
 
-
     //散点图
-
+    @PostMapping(value = "/getScatterPlot")
+    @ApiOperation("测流结果散点图")
+    public R<List<TaskResultSortDTO>> getScatterPlot(@Valid @RequestBody ScattperPlotQuery scattperPlotQuery) {
+        return R.ok(achievementService.getScatterPlot(scattperPlotQuery));
+    }
 
 }