Browse Source

任务提交 断面ID缓存到测流结果数据表

qinguocai 1 year ago
parent
commit
59bf6717ca

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

@@ -110,5 +110,10 @@ public class TaskResult implements Serializable {
      */
     private Double waterlevel;
 
+    /**
+     * 断面ID
+     */
+    private Long berthingId;
+
 }
 

+ 2 - 13
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AchievementServiceImpl.java

@@ -3,19 +3,16 @@ package com.ruoyi.system.service.impl;
 
 import cn.hutool.core.date.format.FastDateFormat;
 import cn.hutool.core.io.resource.ClassPathResource;
-import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelWriter;
 import com.alibaba.excel.support.ExcelTypeEnum;
 import com.alibaba.excel.util.MapUtils;
 import com.alibaba.excel.write.metadata.WriteSheet;
-import com.alibaba.excel.write.metadata.fill.FillWrapper;
 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.system.domain.*;
-import com.ruoyi.system.dto.PrintExcelDTO;
 import com.ruoyi.system.dto.TaskResultSortDTO;
 import com.ruoyi.system.dto.WaterLevelDTO;
 import com.ruoyi.system.mapper.*;
@@ -29,7 +26,6 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.io.OutputStream;
-import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
@@ -55,9 +51,6 @@ public class AchievementServiceImpl implements AchievementService {
     @Resource
     private BerthingPointMapper berthingPointMapper;
 
-    @Resource
-    private BerthingPointConfigMapper berthingPointConfigMapper;
-
     @Override
     public Page<TaskResult> queryAchievement(AchievementQuery achievementQuery){
         if (achievementQuery.getPage() == null || achievementQuery.getSize() == null) {
@@ -106,13 +99,9 @@ public class AchievementServiceImpl implements AchievementService {
             if (siteInfo == null){
                 throw new BaseException("该站点不存在");
             }
-            //拿停泊点数据
-            BerthingPointConfig berthingPointConfig = berthingPointConfigMapper.queryByPlanid(taskResult.getSiteId(), taskResult.getPlanid());
-            if (berthingPointConfig == null){
-                throw new BaseException("停泊点配置不存在");
-            }
+
             //拿断面数据
-            BerthingPoint berthingPoint = berthingPointMapper.queryById(berthingPointConfig.getBerthingId());
+            BerthingPoint berthingPoint = berthingPointMapper.queryById(taskResult.getBerthingId());
             if (berthingPoint == null){
                 throw new BaseException("断面不存在");
             }

+ 10 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SaveDataServiceImpl.java

@@ -52,6 +52,9 @@ public class SaveDataServiceImpl implements SaveDataService {
     @Resource
     private BerthingPointConfigMapper berthingPointConfigMapper;
 
+    @Resource
+    private BerthingPointMapper berthingPointMapper;
+
     @Override
     public void saveDate(String data, String topics) {
         String[] topicsList = topics.split("/");
@@ -290,7 +293,7 @@ public class SaveDataServiceImpl implements SaveDataService {
             TaskResult taskResult = JSONUtil.toBean(data, TaskResult.class);
             SiteInfo siteInfo = siteInfoMapper.queryBySiteCode(taskResult.getId());
             if (siteInfo == null) {
-                log.error("查询站点失败入库失败 站码:{}", taskResult.getId());
+                log.error("测流结果上报 查询站点失败 站码:{}", taskResult.getId());
                 return;
             }
             TaskResult one = taskResultMapper.queryByTaskid(taskResult.getTaskid());
@@ -298,6 +301,12 @@ public class SaveDataServiceImpl implements SaveDataService {
                 log.error("测流结果上报 数据更新失败 taskid {}", taskResult.getTaskid());
                 return;
             }
+            BerthingPoint berthingPoint = berthingPointMapper.queryBySiteId(siteInfo.getSiteId());
+            if (berthingPoint == null) {
+                log.error("测流结果上报 查询断面信息失败 站码:{}", taskResult.getId());
+                return;
+            }
+            taskResult.setBerthingId(berthingPoint.getBerthingId());
             taskResult.setResultId(one.getResultId());
             taskResult.setStatus(2);
             taskResultMapper.update(taskResult);

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

@@ -25,6 +25,7 @@
         <result property="stopwspeeds" column="stopwspeeds" jdbcType="VARCHAR"/>
         <result property="partwspeeds" column="partwspeeds" jdbcType="VARCHAR"/>
         <result property="waterlevel" column="waterlevel" jdbcType="NUMERIC"/>
+        <result property="berthingId" column="berthing_id" jdbcType="INTEGER"/>
     </resultMap>
 
     <resultMap type="com.ruoyi.system.dto.TaskResultSortDTO" id="TaskResultSortDTOMap">
@@ -37,7 +38,7 @@
     <!--查询单个-->
     <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, waterlevel
+            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, berthing_id
         from task_result
         where result_id = #{resultId}
     </select>
@@ -45,7 +46,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, waterlevel
+            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, berthing_id
         from task_result
         where taskid = #{taskid}
         limit 1
@@ -54,7 +55,7 @@
     <!--查询单个-->
     <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, waterlevel
+            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, berthing_id
         from task_result
         where site_id = #{siteId}
         order by create_time desc
@@ -75,7 +76,7 @@
     <!--查询指定行数据-->
     <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, waterlevel
+            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, berthing_id
         from task_result
         <where>
             <if test="achievementQuery.siteId != null">
@@ -156,28 +157,31 @@
             <if test="waterlevel != null">
                 and waterlevel = #{waterlevel}
             </if>
+            <if test="berthingId != null">
+                and berthing_id = #{berthingId}
+            </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, waterlevel)
-        values (#{id}, #{type}, #{taskid}, #{starttime}, #{endtime}, #{width}, #{planid}, #{acreagesum}, #{flowsum}, #{positions}, #{elevations}, #{acreages}, #{waterlevels}, #{wspeeds}, #{flows}, #{siteId}, #{createTime}, #{status}, #{stopwspeeds}, #{partwspeeds}, #{waterlevel})
+        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, berthing_id)
+        values (#{id}, #{type}, #{taskid}, #{starttime}, #{endtime}, #{width}, #{planid}, #{acreagesum}, #{flowsum}, #{positions}, #{elevations}, #{acreages}, #{waterlevels}, #{wspeeds}, #{flows}, #{siteId}, #{createTime}, #{status}, #{stopwspeeds}, #{partwspeeds}, #{waterlevel}, #{berthingId})
     </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, waterlevel)
+        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, berthing_id)
         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.waterlevel})
+        (#{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}, #{entity.berthingId})
         </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, waterlevel)
+        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, berthing_id)
         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.waterlevel})
+            (#{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}, #{entity.berthingId})
         </foreach>
         on duplicate key update
 id = values(id),
@@ -200,7 +204,8 @@ create_time = values(create_time),
 status = values(status),
 stopwspeeds = values(stopwspeeds),
 partwspeeds = values(partwspeeds),
-waterlevel = values(waterlevel)
+waterlevel = values(waterlevel),
+berthing_id = values(berthing_id)
     </insert>
 
     <!--通过主键修改数据-->
@@ -270,6 +275,9 @@ waterlevel = values(waterlevel)
             <if test="waterlevel != null">
                 waterlevel = #{waterlevel},
             </if>
+            <if test="berthingId != null">
+                berthing_id = #{berthingId},
+            </if>
         </set>
         where result_id = #{resultId}
     </update>