Prechádzať zdrojové kódy

fix: 策略管理修改

hum 1 rok pred
rodič
commit
de63e7b672

+ 0 - 5
ruoyi-system/src/main/java/com/ruoyi/system/dto/BerthingFloatDTO.java

@@ -31,11 +31,6 @@ public class BerthingFloatDTO implements Serializable {
      */
     @NotNull(message = "站点ID不能为空")
     private Long siteId;
-/**
-     * 策略编号
-     */
-    @NotNull(message = "策略编号不能为空")
-    private Long planid;
 /**
      * 起测水位
      */

+ 0 - 5
ruoyi-system/src/main/java/com/ruoyi/system/dto/BerthingTimeDTO.java

@@ -27,11 +27,6 @@ public class BerthingTimeDTO implements Serializable {
      */
     @NotNull(message = "站点ID不能为空")
     private Long siteId;
-/**
-     * 策略编号
-     */
-    @NotNull(message = "策略编号不能为空")
-    private Long planid;
 /**
      * 起测水位
      */

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/BerthingFloatConfigMapper.java

@@ -23,6 +23,14 @@ public interface BerthingFloatConfigMapper {
      */
     BerthingFloatConfig queryById(Long floatId);
 
+    /**
+     * 通过站点ID查询planid最大的单条数据
+     *
+     * @param siteId 站点id
+     * @return 实例对象
+     */
+    BerthingFloatConfig queryByMaxPlanid(Long siteId);
+
     /**
      * 查询指定行数据
      *

+ 9 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/BerthingTimeConfigMapper.java

@@ -1,6 +1,7 @@
 package com.ruoyi.system.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.system.domain.BerthingFloatConfig;
 import com.ruoyi.system.domain.BerthingTimeConfig;
 import com.ruoyi.system.paramet.StopPointQuery;
 import com.ruoyi.system.paramet.TimePointQuery;
@@ -24,6 +25,14 @@ public interface BerthingTimeConfigMapper {
      */
     BerthingTimeConfig queryById(Long timeId);
 
+    /**
+     * 通过站点ID查询planid最大的单条数据
+     *
+     * @param siteId 站点id
+     * @return 实例对象
+     */
+    BerthingFloatConfig queryByMaxPlanid(Long siteId);
+
 
     /**
      * 通过ID查询单条数据

+ 11 - 17
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BerthingServiceImpl.java

@@ -241,7 +241,7 @@ public class BerthingServiceImpl implements BerthingService {
                 BerthingPointConfig maxPlanid = berthingPointConfigMapper.queryMaxPlanid(berthingPointConfigDTO.getSiteId());
                 if (maxPlanid == null) {
                     maxPlanid = new BerthingPointConfig();
-                    maxPlanid.setPlanid(1L);
+                    maxPlanid.setPlanid(0L);
                 }
                 berthingPointConfig.setStopId(0L);
                 berthingPointConfig.setSiteId(siteInfo.getSiteId());
@@ -333,17 +333,15 @@ public class BerthingServiceImpl implements BerthingService {
                 if (count > 0){
                     throw new BaseException("起测水位已存在");
                 }
-                //有无重复策略号
-                berthingTime.setPlanid(berthingTimeDTO.getPlanid());
-                berthingTime.setWlevel(null);
-                count = berthingTimeConfigMapper.count(berthingTime);
-                if (count > 0){
-                    throw new BaseException("策略编号已存在");
+                BerthingFloatConfig maxPlanidTimeConfig = berthingTimeConfigMapper.queryByMaxPlanid(siteInfo.getSiteId());
+                if (maxPlanidTimeConfig == null) {
+                    berthingTime.setPlanid(1L);
+                } else {
+                    berthingTime.setPlanid(maxPlanidTimeConfig.getPlanid() + 1);
                 }
                 //新增
                 berthingTime.setTimeId(0L);
                 berthingTime.setWlevel(berthingTimeDTO.getWlevel());
-                berthingTime.setPlanid(berthingTimeDTO.getPlanid());
                 berthingTime.setTimes(JSONUtil.toJsonStr(times));
                 berthingTime.setCreateTime(new Date());
                 berthingTime.setIsDel(0);
@@ -353,7 +351,6 @@ public class BerthingServiceImpl implements BerthingService {
                 res =  berthingTimeConfigMapper.insert(berthingTime) > 0;
             } else {
                 //更新
-                berthingTime.setPlanid(berthingTimeDTO.getPlanid());
                 berthingTime.setWlevel(berthingTimeDTO.getWlevel());
                 berthingTime.setTimes(JSONUtil.toJsonStr(times));
                 berthingTime.setType(berthingTimeDTO.getType());
@@ -426,15 +423,13 @@ public class BerthingServiceImpl implements BerthingService {
                 if (count > 0) {
                     throw new BaseException("起浮水位已存在");
                 }
-                //有无重复策略号
-                berthingFloat.setPlanid(berthingFloatDTO.getPlanid());
-                berthingFloat.setWlevel(null);
-                count = berthingFloatConfigMapper.count(berthingFloat);
-                if (count > 0){
-                    throw new BaseException("策略编号已存在");
+                BerthingFloatConfig maxPlanidFloatConfig = berthingFloatConfigMapper.queryByMaxPlanid(siteInfo.getSiteId());
+                if (maxPlanidFloatConfig == null) {
+                    berthingFloat.setPlanid(1L);
+                } else {
+                    berthingFloat.setPlanid(maxPlanidFloatConfig.getPlanid() + 1);
                 }
                 berthingFloat.setFloatId(0L);
-                berthingFloat.setPlanid(berthingFloatDTO.getPlanid());
                 berthingFloat.setWlevel(berthingFloatDTO.getWlevel());
                 berthingFloat.setCreateTime(new Date());
                 berthingFloat.setIsDel(0);
@@ -447,7 +442,6 @@ public class BerthingServiceImpl implements BerthingService {
             } else {
                 //更新
                 berthingFloat.setType(berthingFloatDTO.getType());
-                berthingFloat.setPlanid(berthingFloatDTO.getPlanid());
                 berthingFloat.setWlevel(berthingFloatDTO.getWlevel());
                 berthingFloat.setTimespan(berthingFloatDTO.getTimespan());
                 berthingFloat.setWlevelchange(berthingFloatDTO.getWlevelchange());

+ 10 - 0
ruoyi-system/src/main/resources/mapper/BerthingFloatConfigMapper.xml

@@ -25,6 +25,16 @@
         where float_id = #{floatId}
     </select>
 
+    <!--查询单个-->
+    <select id="queryByMaxPlanid" resultMap="BerthingFloatConfigMap">
+        select
+            float_id, id, site_id, planid, create_time, status, is_del, wlevel, timespan, wlevelchange, type
+        from berthing_float_config
+        where site_id = #{siteId}
+        order by planid desc
+        limit 1
+    </select>
+
     <!--查询指定行数据-->
     <select id="queryAllByLimit" resultMap="BerthingFloatConfigMap">
         select

+ 9 - 0
ruoyi-system/src/main/resources/mapper/BerthingTimeConfigMapper.xml

@@ -24,6 +24,15 @@
         where time_id = #{timeId}
     </select>
 
+    <!--查询单个-->
+    <select id="queryByMaxPlanid" resultMap="BerthingTimeConfigMap">
+        select
+            time_id, id, site_id, planid, create_time, status, is_del, wlevel, times, type
+        from berthing_time_config
+        where site_id = #{siteId}
+        order by planid desc
+        limit 1
+    </select>
 
 
     <!--查询单个-->

+ 3 - 0
ruoyi-ui/src/views/site/plain-water/add.vue

@@ -29,6 +29,7 @@
               <el-input-number
                 placeholder="请输入水位变幅"
                 v-model="form.wlevelchange"
+                @change="wlevelchange => plain.wlevelchange = wlevelchange"
                 :precision="2"
                 :step="0.1"
                 :min="0" />
@@ -78,6 +79,7 @@ export default {
         wlevelmax: 0,
         wlevelmin: 0,
         wlevel: 0,
+        wlevelchange: 0,
       },
       form: {
         floatId: '',
@@ -114,6 +116,7 @@ export default {
         const { floatId, siteId, wlevel, wlevelchange, timespan } = res.data || {};
 
         this.plain.wlevel = wlevel;
+        this.plain.wlevelchange = wlevelchange;
 
         this.form.floatId = floatId;
         this.form.wlevelchange = wlevelchange;

+ 32 - 5
ruoyi-ui/src/views/site/plain-water/chart-list.vue

@@ -38,6 +38,8 @@ export default {
         return;
       }
       const { sections, wlevelmax, wlevelmin, list } = plain;
+      const xAxisData = sections.map(({ x }) => x);
+      const yAxisData = sections.map(({ y }) => y);
       const seriesData = sections.map(({ x, y }) => ([x, y]));
       const options = {
         xAxis: {
@@ -171,10 +173,11 @@ export default {
           '#07a2a4',
           '#9a7fd1',
         ]
-        const { wlevel, planid } = plain;
+        const { wlevel, planid, wlevelchange } = plain;
         options.series.push({
           name: `策略编号(${planid})`,
           symbol: 'none',
+          silent: true,
           itemStyle: {
             normal: {
               color: themes[index],
@@ -183,20 +186,44 @@ export default {
               }
             }
           },
-          data: new Array(seriesData.length).fill(wlevel),
+          data: [[Math.min(...xAxisData), wlevel + wlevelchange], [Math.max(...xAxisData), wlevel + wlevelchange]],
           type: 'line',
+          z: 0,
+          areaStyle: {
+            color: {
+              type: 'linear',
+              x: 0,
+              y: 0,
+              x2: 0,
+              y2: 1,
+              colorStops: [{
+                offset: 0, color: 'rgb(173 205 248)'
+              }, {
+                offset: wlevelchange / (wlevel + wlevelchange - Math.min(...yAxisData)), color: 'rgb(173 205 248)'
+              },{
+                offset: wlevelchange / (wlevel + wlevelchange - Math.min(...yAxisData)), color: 'transparent'
+              }, {
+                offset:1, color: 'transparent'
+              }],
+            }
+          },
           markLine: {
             symbol: 'none',
-            silent: true,
             lineStyle: {
               color: themes[index],
             },
-            label: { position: 'start' },
+            label: { position: 'middle' },
             data: [{
               yAxis: wlevel,
               name: `策略编号(${planid})`,
               label: {
-                formatter: '{b}'
+                formatter: `{b}: 起测水位${wlevel}, 水位变幅${wlevelchange}`
+              }
+            },{
+              name: `水位变幅(${planid})`,
+              yAxis: wlevel + wlevelchange,
+              label: {
+                show: false
               }
             }],
           },

+ 30 - 5
ruoyi-ui/src/views/site/plain-water/chart.vue

@@ -37,8 +37,9 @@ export default {
       if (!this.chart) {
         return;
       }
-      const { sections, wlevelmax, wlevelmin, wlevel } = plain;
+      const { sections, wlevelmax, wlevelmin, wlevel, wlevelchange } = plain;
       const xAxisData = sections.map(({ x }) => x);
+      const yAxisData = sections.map(({ y }) => y);
       const seriesData = sections.map(({ x, y }) => ([x, y]));
       const options = {
         xAxis: {
@@ -167,18 +168,42 @@ export default {
           lineStyle: {
             width: 0,
           },
-          data: [[Math.min(...xAxisData), wlevel], [Math.max(...xAxisData), wlevel]],
+          data: [[Math.min(...xAxisData), wlevel + wlevelchange], [Math.max(...xAxisData), wlevel + wlevelchange]],
           type: 'line',
+          z: 0,
+          areaStyle: {
+            color: {
+              type: 'linear',
+              x: 0,
+              y: 0,
+              x2: 0,
+              y2: 1,
+              colorStops: [{
+                offset: 0, color: 'rgb(173 205 248)'
+              }, {
+                offset: wlevelchange / (wlevel + wlevelchange - Math.min(...yAxisData)), color: 'rgb(173 205 248)'
+              },{
+                offset: wlevelchange / (wlevel + wlevelchange - Math.min(...yAxisData)), color: 'transparent'
+              }, {
+                offset:1, color: 'transparent'
+              }],
+            }
+          },
           markLine: {
             symbol: 'none',
-            silent: true,
             lineStyle: { normal: { type: 'dashed' } },
-            label: { position: 'start' },
+            label: { position: 'middle' },
             data: [{
               name: '起测水位',
               yAxis: wlevel,
               label: {
-                formatter: '{b}'
+                formatter: `起测水位${wlevel}, 水位变幅${wlevelchange}`
+              }
+            },{
+              name: '水位变幅',
+              yAxis: wlevel + wlevelchange,
+              label: {
+                show: false
               }
             }],
           },