Kaynağa Gözat

风机曲线表格页面增加查询条件,去掉删除按钮

songhaodong 2 yıl önce
ebeveyn
işleme
7227c9281f

+ 147 - 47
ipfcst/ipfcst-reportquery/src/main/frontend/views/parameterConfiguration/WindTurbinePowerCurve/index.vue

@@ -2,7 +2,7 @@
   <div class="chart-container">
     <div class="filter" >
       <div style="margin-left:-10px;">
-        <el-button size="small" type="primary"  @click="insertEvent"> 新增</el-button>
+<!--        <el-button size="small" type="primary"  @click="insertEvent"> 新增</el-button>-->
         <el-upload
           ref="upload"
           name="file"
@@ -15,11 +15,57 @@
         </el-upload>
         <el-button size="small" type="primary" @click="exportToExcel">导出</el-button>
       </div>
-<!--      <div class="toolbar" v-show="this.showToolBar"> <vxe-toolbar ref="fstToolBar" custom >-->
-<!--        <template v-slot:buttons>-->
-<!--          <vxe-button class="downloadButton" style="border:none;"  @click="exportDataEvent"><i class="vxe-icon&#45;&#45;download" ></i></vxe-button>-->
-<!--        </template>-->
-<!--      </vxe-toolbar></div>-->
+      <div class="toolbar" v-show="this.showToolBar">
+        <div class="toolMenu">
+          <el-row>
+            <el-col :span="6">
+              风速
+              <el-input type="text"
+                        v-model="speed"
+                        placeholder="请输入风速值"
+                        prefix-icon="el-icon-search"
+                        clearable
+                        style="max-width: 180px;"
+                        size="small"
+              ></el-input>
+            </el-col>
+            <el-col :span="6">
+              功率
+              <el-input type="text"
+                        v-model="power"
+                        placeholder="请输入功率值"
+                        prefix-icon="el-icon-search"
+                        clearable
+                        style="max-width: 180px;"
+                        size="small"
+              ></el-input>
+            </el-col>
+            <el-col :span="6">
+              机组
+              <el-input type="text"
+                        v-model="fanId"
+                        placeholder="请输入机组id"
+                        prefix-icon="el-icon-search"
+                        clearable
+                        style="max-width: 200px;"
+                        size="small"
+              ></el-input>
+            </el-col>
+
+            <el-col :span="6">
+              <el-button type="primary" size="small" :loading="loading" @click="findBySomeConditions">查询</el-button>
+              <el-button type="primary" size="small" :loading="loading" @click="clearInput">清空</el-button>
+
+            </el-col>
+          </el-row>
+        </div>
+
+<!--        <vxe-toolbar ref="fstToolBar" custom >-->
+<!--          <template v-slot:buttons>-->
+<!--            <vxe-button class="downloadButton" style="border:none;"  @click="exportDataEvent"><i class="vxe-icon&#45;&#45;download" ></i></vxe-button>-->
+<!--          </template>-->
+<!--        </vxe-toolbar>-->
+      </div>
 <!--      <div class="toolbar" v-show="this.showToolBar"> <vxe-toolbar ref="nwpToolBar" custom></vxe-toolbar></div>-->
     </div>
 
@@ -54,7 +100,7 @@
                 <template v-else>
                   <vxe-button content="编辑" circle @click="editRowEvent(row)"></vxe-button>
                 </template>
-                <vxe-button content="删除" circle @click="removeRowEvent(row)"></vxe-button>
+<!--                <vxe-button content="删除" circle @click="removeRowEvent(row)"></vxe-button>-->
               </template>
             </vxe-grid>
             <div class="rtPageturning">
@@ -68,6 +114,7 @@
                 @page-change="handlePageChange"
                 :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
               </vxe-pager>
+
             </div>
           </div>
         </el-tab-pane>
@@ -116,28 +163,28 @@
     components: { Chart},
     mixins: [resize],
     data(){
-      return{
-        fanIdStr:'',
+      return {
+        fanIdStr: '',
         value: '',
-        fanIdData:[],
-        styleStr:{},
-        styleTableStr:{},
+        fanIdData: [],
+        styleStr: {},
+        styleTableStr: {},
         tableToolbar: {
           export: true,
           custom: true
         },
-        tableColumn:[],
+        tableColumn: [],
         chart: null,
-        loading:true,
-        drawLoading:true,
-        tableLoading:true,
-        resizeKey:1,
+        loading: true,
+        drawLoading: true,
+        tableLoading: true,
+        resizeKey: 1,
         activeName: 'first',
-        drawData:{Fan1:[], Fan2:[], Fan3:[], Fan4:[], Fan5:[], xData:[]},
-        tableData:[],
-        total:0,
+        drawData: {},
+        tableData: [],
+        total: 0,
         pageSize: 10,
-        pageSizes: [10,50,100,{label: '大量数据', value: 1000},],
+        pageSizes: [10, 50, 100, {label: '大量数据', value: 1000},],
         currentPage: 1,
         showToolBar: false,
         dialogVisible: false,
@@ -156,7 +203,11 @@
             {pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: "填写数字", trigger: 'blur'}
           ],
         },
+        speed: '',
+        power: '',
+        fanId: '',
       }
+
     },
     created () {
       if(sessionStorage.getItem('styleSwitch') === 'blue'){
@@ -196,7 +247,6 @@
         this.drawLoading = true
         this.$axios.get('/windTurbinePowerCurve/new/').then((res) => {
 
-          console.log(res.data+"-------------");
           this.drawData = res.data
           this.drawLoading = false
           if(!this.drawLoading && !this.tableLoading){
@@ -211,31 +261,32 @@
         })
       },
       getTable(){
-        this.tableLoading = true
-        this.$axios.get('/windTurbinePowerCurve/'+this.currentPage+'/'+this.pageSize).then((res) => {
-          this.tableData = res.data.content
-          // 表分页格数据总条数
-          this.total = res.data.count
-          this.tableColumn = []
-          this.tableColumn = [
-            { field: 'id', title: 'id',minWidth:"150",width:"180"},
-            { field: 'speed', title: '风速',minWidth:"60",editRender: { name: 'input' }},
-            { field: 'power', title: '功率',minWidth:"60",editRender: { name: 'input' }},
-            { field: 'fanId', title: '机组',minWidth:"60",editRender: { name: 'input' }},
-            { title: '操作', width: 200, slots: { default: 'operate' } }
-          ]
-
-          this.tableLoading = false
-          if(!this.drawLoading && !this.tableLoading){
-            this.loading = false
-          }
-        }).catch((error) => {
-          this.tableLoading = false
-          if(!this.drawLoading && !this.tableLoading){
-            this.loading = false
-          }
-          this.$message.error('查询table出错' + error)
-        })
+        this.findBySomeConditions()
+        // this.tableLoading = true
+        // this.$axios.get('/windTurbinePowerCurve/'+this.currentPage+'/'+this.pageSize).then((res) => {
+        //   this.tableData = res.data.content
+        //   // 表分页格数据总条数
+        //   this.total = res.data.count
+        //   this.tableColumn = []
+        //   this.tableColumn = [
+        //     { field: 'id', title: 'id',minWidth:"150",width:"180"},
+        //     { field: 'speed', title: '风速',minWidth:"60",editRender: { name: 'input' }},
+        //     { field: 'power', title: '功率',minWidth:"60",editRender: { name: 'input' }},
+        //     { field: 'fanId', title: '机组',minWidth:"60",editRender: { name: 'input' }},
+        //     { title: '操作', width: 200, slots: { default: 'operate' } }
+        //   ]
+        //
+        //   this.tableLoading = false
+        //   if(!this.drawLoading && !this.tableLoading){
+        //     this.loading = false
+        //   }
+        // }).catch((error) => {
+        //   this.tableLoading = false
+        //   if(!this.drawLoading && !this.tableLoading){
+        //     this.loading = false
+        //   }
+        //   this.$message.error('查询table出错' + error)
+        // })
 
       },
       handlePageChange ({ currentPage, pageSize }) {
@@ -326,6 +377,55 @@
         })
         this.dialogVisible = false;
       },
+      findBySomeConditions() {
+        if (this.speed == '') {
+          this.speed = null
+        }
+        if (this.power == '') {
+          this.power = null
+        }
+        if (this.fanId == '') {
+          this.fanId = null
+        }
+
+        // this.$axios.get("/windTurbinePowerCurve/bySomeConditions/" + this.currentPage + "/" + this.pageSize + "/" + this.speed + '/' + this.power + '/' + this.fanId).then(res => {
+        //   this.tableData = res.data.content
+        //   this.total = res.data.totalElements
+        // })
+
+
+        this.$axios.get("/windTurbinePowerCurve/bySomeConditions/" + this.currentPage + "/" + this.pageSize + "/" + this.speed + '/' + this.power + '/' + this.fanId).then(res => {
+          this.tableData = res.data.content
+          // 表分页格数据总条数
+          this.total = res.data.totalElements
+          this.tableColumn = []
+          this.tableColumn = [
+            { field: 'id', title: 'id',minWidth:"150",width:"180"},
+            { field: 'speed', title: '风速',minWidth:"60",editRender: { name: 'input' }},
+            { field: 'power', title: '功率',minWidth:"60",editRender: { name: 'input' }},
+            { field: 'fanId', title: '机组',minWidth:"60",editRender: { name: 'input' }},
+            { title: '操作', width: 200, slots: { default: 'operate' } }
+          ]
+
+          this.tableLoading = false
+          if(!this.drawLoading && !this.tableLoading){
+            this.loading = false
+          }
+        }).catch((error) => {
+          this.tableLoading = false
+          if(!this.drawLoading && !this.tableLoading){
+            this.loading = false
+          }
+          this.$message.error('查询table出错' + error)
+        })
+
+
+      },
+      clearInput(){
+        this.speed = ''
+        this.power = ''
+        this.fanId = ''
+      }
     }
   }
 </script>

+ 10 - 0
ipfcst/ipfcst-reportquery/src/main/java/com/jiayue/ipfcst/controller/WindTurbinePowerCurveController.java

@@ -6,6 +6,7 @@ import com.jiayue.ipfcst.common.data.entity.WindSpeedPointInfo;
 import com.jiayue.ipfcst.common.data.entity.WindTurbinePowerCurve;
 import com.jiayue.ipfcst.service.WindTurbinePowerCurveService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
@@ -88,5 +89,14 @@ public class WindTurbinePowerCurveController {
 
   }
 
+  @GetMapping(value = "/bySomeConditions/{page}/{size}/{speed}/{power}/{fanId}")
+  public ResponseVO getBySomeConditions(@PathVariable("page") Integer page,
+                                        @PathVariable("size") Integer size,
+                                        @PathVariable("speed") String speed,
+                                        @PathVariable("power") String power,
+                                        @PathVariable("fanId") String fanId){
+    Page<WindTurbinePowerCurve> bySomeConditions = this.windTurbinePowerCurveService.getBySomeConditions(page, size, speed, power, fanId);
+    return ResponseVO.success(bySomeConditions);
+  }
 
 }

+ 39 - 0
ipfcst/ipfcst-reportquery/src/main/java/com/jiayue/ipfcst/service/WindTurbinePowerCurveService.java

@@ -2,6 +2,7 @@ package com.jiayue.ipfcst.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.data.entity.FanUnitInfo;
+import com.jiayue.ipfcst.common.data.entity.WindSpeedPointInfo;
 import com.jiayue.ipfcst.common.data.entity.WindTurbinePowerCurve;
 import com.jiayue.ipfcst.common.data.repository.FanUnitInfoRepository;
 import com.jiayue.ipfcst.common.data.repository.WindTurbinePowerCurveRepository;
@@ -12,6 +13,7 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 
+import javax.persistence.criteria.Order;
 import javax.persistence.criteria.Predicate;
 import java.security.Key;
 import java.text.DecimalFormat;
@@ -115,6 +117,15 @@ public class WindTurbinePowerCurveService {
     return map;
   }
 
+
+  public Page<WindTurbinePowerCurve> getBySomeConditions(Integer page, Integer size,String speed, String power, String fanId) {
+    Specification<WindTurbinePowerCurve> specification = this.specificationBySomeConditions(speed, power, fanId);
+    Pageable pageable = PageRequest.of(page - 1, size);
+    Page<WindTurbinePowerCurve> windTurbinePowerCurves = windTurbinePowerCurveRepository.findAll(specification, pageable);
+    windTurbinePowerCurves.getContent();
+    return windTurbinePowerCurves;
+  }
+
   /**
    * 曲线数据
    * @return
@@ -163,10 +174,38 @@ public class WindTurbinePowerCurveService {
   Specification<WindTurbinePowerCurve> Specification() {
     return (root, criteriaQuery, cb) -> {
       List<Predicate> predicates = new ArrayList<>();
+      // Order weightOrder = cb.desc(root.get("weight"));
       //添加排序的功能
       return cb.and(predicates.toArray(new Predicate[predicates.size()]));
     };
   }
 
+
+  public Specification<WindTurbinePowerCurve> specificationBySomeConditions(final String speed,final String power,final String fanId){
+    return (Specification<WindTurbinePowerCurve>) (root, criteriaQuery, cb) -> {
+      List<Predicate> predicates = new ArrayList<>();
+
+
+      // 风机编号模糊查询
+      if (!speed.equals("null")) {
+        predicates.add(cb.equal(root.get("speed"), speed));
+      }
+
+      // 风向查询
+      if (!power.equals("null")) {
+        predicates.add(cb.equal(root.get("power"), power));
+      }
+
+      // 风速查询
+      if (!fanId.equals("null")) {
+        predicates.add(cb.equal(root.get("fanId"), fanId));
+      }
+
+      // 添加排序的功能
+      return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+
+    };
+  }
+
 }