فهرست منبع

添加数据查看

yuanhao 3 سال پیش
والد
کامیت
77390e8cfb

+ 34 - 0
in-cloud-ui/src/api/forecastData.js

@@ -0,0 +1,34 @@
+import request from '@/utils/request'
+
+export function fetchList(query) {
+  return request({
+    url: '/forecastData/page',
+    method: 'get',
+    params: query
+  })
+}
+
+export function addObj(obj) {
+  return request({
+    url: '/forecastData',
+    method: 'post',
+    data: obj
+  })
+}
+
+
+export function delObj(id) {
+  return request({
+    url: '/forecastData/' + id,
+    method: 'delete'
+  })
+}
+
+export function putObj(obj) {
+  return request({
+    url: '/forecastData',
+    method: 'put',
+    data: obj
+  })
+
+}

+ 15 - 0
in-cloud-ui/src/router/index.js

@@ -121,6 +121,21 @@ export const asyncRoutes = [
   },
 
   {
+    path: '/forecastData',
+    component: Layout,
+    redirect: '/forecastData',
+    children: [
+      {
+        path: 'forecastData',
+        name: 'forecastData',
+        component: () => import('@/views/forecastData/index'),
+        meta: {
+          title: '数据查询', icon: 'bell',
+        },
+      },
+    ],
+  },
+  {
     path: '/record',
     component: Layout,
     redirect: '/record',

+ 302 - 0
in-cloud-ui/src/views/forecastData/index.vue

@@ -0,0 +1,302 @@
+<template>
+  <div class="table-container">
+    <vab-query-form>
+      <el-form
+        ref="searchForm"
+        :model="searchForm"
+        :inline="true"
+        @submit.native.prevent
+      >
+      <vab-query-form-left-panel>
+
+          <el-form-item>
+            <el-date-picker
+              v-model="times"
+              type="datetimerange"
+              range-separator="至"
+              start-placeholder="开始日期"
+              end-placeholder="结束日期"
+
+              value-format="timestamp"
+            ></el-date-picker>
+          </el-form-item>
+
+          <el-form-item>
+            <el-select
+              v-model="searchForm.stationCode"
+              clearable
+              placeholder="场站"
+            >
+              <el-option
+                v-for="item in stations"
+                :key="item.stationCode"
+                :label="item.name"
+                :value="item.stationCode"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+
+      </vab-query-form-left-panel>
+
+
+      <vab-query-form-right-panel :span="1">
+        <el-form-item>
+          <el-button
+            icon="el-icon-search"
+            type="primary"
+            native-type="submit"
+            @click="handleQuery"
+          >
+            查询
+          </el-button>
+        </el-form-item>
+      </vab-query-form-right-panel>
+
+      </el-form>
+    </vab-query-form>
+
+    <el-table
+      ref="table"
+      v-loading="listLoading"
+      :data="tableData"
+      :element-loading-text="elementLoadingText"
+      :height="height"
+      :header-cell-style="{ 'text-align': 'center' }"
+      :cell-style="{ 'text-align': 'center' }"
+    >
+      <el-table-column  fixed  label="序号" width="95">
+        <template #default="scope">
+          {{ scope.$index + 1 }}
+        </template>
+      </el-table-column>
+
+      <el-table-column
+        fixed
+
+        label="一体化公司"
+        prop="inCode"
+        :formatter="formatCompany"
+      />
+
+      <el-table-column
+        fixed
+        width="150"
+        label="场站名称"
+        prop="stationCode"
+        :formatter="formatStation"
+      />
+      <el-table-column  width="100" label="下载时间" prop="initTime" />
+
+      <el-table-column width="100" label="上送时间" prop="uploadTime" />
+      <el-table-column width="100" label="修正时间" prop="correctTime" />
+      <el-table-column width="100" label="预测时间" prop="forecastTime" :formatter="formatDate"/>
+      <el-table-column show-overflow-tooltip label="预测功率" prop="fpValue" />
+      <el-table-column show-overflow-tooltip label="预测功率(修)" prop="fpValueCorrect" />
+      <el-table-column show-overflow-tooltip label="总辐射" prop="swr" />
+      <el-table-column show-overflow-tooltip label="总辐射(修)" prop="swrCorrect" />
+      <el-table-column show-overflow-tooltip label="直辐射" prop="directRadiation" />
+      <el-table-column show-overflow-tooltip label="直辐射(修)" prop="directRadiationCorrect" />
+      <el-table-column show-overflow-tooltip label="散辐射" prop="diffuseRadiation" />
+      <el-table-column show-overflow-tooltip label="散辐射(修)" prop="diffuseRadiationCorrect" />
+
+      <el-table-column show-overflow-tooltip label="风速" prop="windSpeed" />
+      <el-table-column show-overflow-tooltip label="风速(修)" prop="windSpeedCorrect" />
+
+      <el-table-column show-overflow-tooltip label="风向" prop="windDir" />
+      <el-table-column show-overflow-tooltip label="风向(修)" prop="windDirCorrect" />
+
+      <el-table-column show-overflow-tooltip label="气温" prop="temperature" />
+      <el-table-column show-overflow-tooltip label="气温(修)" prop="temperatureCorrect" />
+
+      <el-table-column show-overflow-tooltip label="相对湿度" prop="humidity" />
+      <el-table-column show-overflow-tooltip label="相对湿度(修)" prop="humidityCorrect" />
+
+      <el-table-column show-overflow-tooltip label="压力" prop="pressure" />
+      <el-table-column show-overflow-tooltip label="压力(修)" prop="pressureCorrect" />
+
+    </el-table>
+    <el-pagination
+      :background="background"
+      :current-page="page.currentPage"
+      :layout="layout"
+      :page-size="page.pageSize"
+      :total="page.total"
+      @current-change="handleCurrentChange"
+      @size-change="handleSizeChange"
+    ></el-pagination>
+  </div>
+</template>
+
+<script>
+  import { fetchList ,delObj} from '@/api/forecastData'
+  import { getCompanyAll } from '@/api/integrationCompany'
+  import { getStationAll } from '@/api/station'
+
+
+  export default {
+    name: 'Record',
+
+    data() {
+      return {
+        tableData: [],
+        companys: [],
+        types: [{label:"拉取原始数据",value:"PULL_INIT"},
+          {label:"推送原始数据",value:"PUSH_INIT"},
+          {label:"拉取修正数据",value:"PULL_CORRECT"},
+          {label:"交互权限",value:"COM_PERMISSON"},],
+        stations: [],
+        searchForm: {},
+        times: [
+        new Date(new Date().setHours(0, 0, 0, 0)).getTime(),
+        new Date(new Date().setHours(23, 59, 59, 59)).getTime(),
+        ],
+        listLoading: true,
+        layout: 'total, sizes, prev, pager, next, jumper',
+        total: 0,
+        background: true,
+        elementLoadingText: '正在加载...',
+        page: {
+          total: 0, // 总页数
+          currentPage: 1, // 当前页数
+          pageSize: 20, // 每页显示多少条
+        },
+      }
+    },
+    computed: {
+      height() {
+        return this.$baseTableHeight()
+      },
+    },
+    created() {
+      this.getCompany()
+    },
+    methods: {
+      getCompany() {
+        getCompanyAll()
+          .then((response) => {
+            this.companys = response.data
+            this.getStation()
+            this.listLoading = false
+          })
+          .catch(() => {
+            this.listLoading = false
+          })
+      },
+
+      getStation() {
+        getStationAll()
+          .then((response) => {
+            this.stations = response.data
+            this.fetchData()
+            this.listLoading = false
+          })
+          .catch(() => {
+            this.listLoading = false
+          })
+      },
+      async fetchData() {
+        this.listLoading = true
+        this.searchForm.startTime = null
+        this.searchForm.endTime = null
+        if(this.times !=null){
+          this.searchForm.startTime = this.times[0]
+          this.searchForm.endTime = this.times[1]
+        }
+        fetchList(
+          Object.assign(
+            {
+              current: this.page.currentPage,
+              size: this.page.pageSize,
+            },
+            this.searchForm
+          )
+        )
+          .then((response) => {
+            this.tableData = response.data.records
+            this.page.total = response.data.total
+            this.listLoading = false
+          })
+          .catch(() => {
+            this.listLoading = false
+          })
+      },
+
+      handleSizeChange(val) {
+        this.page.pageSize = val
+        this.page.currentPage = 1
+        this.fetchData()
+      },
+      handleCurrentChange(val) {
+        this.page.currentPage = val
+        this.fetchData()
+      },
+      handleQuery() {
+        for (var v in this.searchForm) {
+          if (this.searchForm[v] == '') {
+            delete this.searchForm[v]
+          }
+        }
+
+        this.page.currentPage = 1
+        this.fetchData()
+      },
+      handleDelete(row) {
+        this.$baseConfirm('你确定要删除当前项吗', null, async () => {
+          await delObj(row.id)
+          this.$baseMessage('删除成功', 'success')
+          this.fetchData()
+        })
+      },
+      formatCompany(row, column) {
+        for (let i = 0; i < this.companys.length; i++) {
+          if (row.inCode == this.companys[i].code) {
+            return this.companys[i].name
+          }
+        }
+      },
+      formatType(row, column) {
+        for (let i = 0; i < this.types.length; i++) {
+          if (row.type == this.types[i].value) {
+            return this.types[i].label
+          }
+        }
+      },
+      formatStation(row, column) {
+        const selectedItem = this.stations.find((item) => {
+          return item.stationCode === row.stationCode
+        })
+        return selectedItem.name
+      },
+      formatDate(row, column) {
+        //datetime是拿到的时间戳
+        var date = new Date(row.forecastTime);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
+        var year = date.getFullYear(),
+          month = ("0" + (date.getMonth() + 1)).slice(-2),
+          sdate = ("0" + date.getDate()).slice(-2),
+          hour = ("0" + date.getHours()).slice(-2),
+          minute = ("0" + date.getMinutes()).slice(-2),
+          second = ("0" + date.getSeconds()).slice(-2);
+// 拼接
+        var result = year + "-"+ month +"-"+ sdate +" "+ hour +":"+ minute +":" + second;
+// 返回
+        return result;
+      },
+
+    },
+  }
+</script>
+
+<style>
+  .demo-table-expand {
+    font-size: 0;
+  }
+  .demo-table-expand label {
+    width: 90px;
+    color: #99a9bf;
+  }
+  .demo-table-expand .el-form-item {
+    margin-right: 0;
+    margin-bottom: 0;
+    width: 50%;
+  }
+</style>

+ 31 - 4
in-cloud-ui/src/views/record/index.vue

@@ -94,10 +94,10 @@
         prop="stationCode"
         :formatter="formatStation"
       />
-      <el-table-column show-overflow-tooltip label="日志类型" prop="type" />
+      <el-table-column show-overflow-tooltip label="日志类型" prop="type" :formatter="formatType"/>
 
       <el-table-column show-overflow-tooltip label="状态" prop="state" />
-      <el-table-column show-overflow-tooltip label="状态" prop="stateContent" />
+      <el-table-column show-overflow-tooltip label="状态内容" prop="stateContent" />
       <el-table-column
         show-overflow-tooltip
         label="标记时间"
@@ -110,6 +110,15 @@
         prop="createTime"
         :formatter="formatDate"
       />
+
+      <el-table-column show-overflow-tooltip label="操作" width="180px">
+        <template #default="{ row }">
+
+          <el-button type="text" @click="handleDelete(row)">
+            <el-tag type="danger">删除</el-tag>
+          </el-button>
+        </template>
+      </el-table-column>
     </el-table>
     <el-pagination
       :background="background"
@@ -124,10 +133,11 @@
 </template>
 
 <script>
-  import { fetchList } from '@/api/record'
+  import { fetchList ,delObj} from '@/api/record'
   import { getCompanyAll } from '@/api/integrationCompany'
   import { getStationAll } from '@/api/station'
 
+
   export default {
     name: 'Record',
 
@@ -135,6 +145,10 @@
       return {
         tableData: [],
         companys: [],
+        types: [{label:"拉取原始数据",value:"PULL_INIT"},
+          {label:"推送原始数据",value:"PUSH_INIT"},
+          {label:"拉取修正数据",value:"PULL_CORRECT"},
+          {label:"交互权限",value:"COM_PERMISSON"},],
         stations: [],
         searchForm: {},
         times: [
@@ -231,6 +245,13 @@
         this.page.currentPage = 1
         this.fetchData()
       },
+      handleDelete(row) {
+        this.$baseConfirm('你确定要删除当前项吗', null, async () => {
+          await delObj(row.id)
+          this.$baseMessage('删除成功', 'success')
+          this.fetchData()
+        })
+      },
       formatCompany(row, column) {
         for (let i = 0; i < this.companys.length; i++) {
           if (row.inCode == this.companys[i].code) {
@@ -238,6 +259,13 @@
           }
         }
       },
+      formatType(row, column) {
+        for (let i = 0; i < this.types.length; i++) {
+          if (row.type == this.types[i].value) {
+            return this.types[i].label
+          }
+        }
+      },
       formatStation(row, column) {
         const selectedItem = this.stations.find((item) => {
           return item.stationCode === row.stationCode
@@ -249,7 +277,6 @@
         console.log(row[pro])
         return row[pro]
       },
-
       dateFormat(fmt, date) {
         let ret
         const opt = {

+ 90 - 0
in-cloud/src/main/java/com/jiayue/insu/incloud/controller/ForecastDataController.java

@@ -0,0 +1,90 @@
+package com.jiayue.insu.incloud.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jiayue.insu.common.core.util.R;
+import com.jiayue.insu.incloud.entity.ForecastData;
+import com.jiayue.insu.incloud.entity.Record;
+import com.jiayue.insu.incloud.entity.Station;
+import com.jiayue.insu.incloud.service.ForecastDataService;
+import com.jiayue.insu.incloud.service.StationService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+
+/**
+ * ForecastDataController
+ *
+ * @author yh
+ * @date 2022-03-18 15:48:48
+ */
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/forecastData")
+public class ForecastDataController {
+
+    private final ForecastDataService forecastDataService;
+
+    /**
+     * 分页查询
+     *
+     * @param page   分页对象
+     * @param forecastData forecastData
+     * @return
+     */
+
+    @GetMapping("/page")
+    public R getPage(Page page, ForecastData forecastData) {
+        LambdaQueryWrapper<ForecastData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+
+        if(forecastData.getStationCode()!=null){
+            lambdaQueryWrapper.eq(ForecastData::getStationCode,forecastData.getStationCode());
+        }
+        if(forecastData.getStartTime()!=null && forecastData.getEndTime()!=null){
+            lambdaQueryWrapper.between(ForecastData::getForecastTime,forecastData.getStartTime(),forecastData.getEndTime());
+        }
+
+        page.addOrder(OrderItem.asc("forecast_time"));
+
+        return R.ok(forecastDataService.page(page, lambdaQueryWrapper));
+    }
+
+
+    /**
+     * 新增forecastData
+     *
+     * @param forecastData forecastData
+     * @return R
+     */
+
+    @PostMapping
+    public R save(@RequestBody ForecastData forecastData) {
+        return R.ok(forecastDataService.save(forecastData));
+    }
+
+    /**
+     * 修改forecastData
+     *
+     * @param forecastData forecastData
+     * @return R
+     */
+
+    @PutMapping
+    public R updateById(@RequestBody ForecastData forecastData) {
+        return R.ok(forecastDataService.updateById(forecastData));
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id id
+     * @return R
+     */
+    @DeleteMapping("/{id}")
+    public R removeById(@PathVariable Long id) {
+        return R.ok(forecastDataService.removeById(id));
+    }
+
+
+}

+ 1 - 1
in-cloud/src/main/java/com/jiayue/insu/incloud/controller/RecordController.java

@@ -85,7 +85,7 @@ public class RecordController {
      * @return R
      */
     @DeleteMapping("/{id}")
-    public R removeById(@PathVariable Long id) {
+    public R removeById(@PathVariable String id) {
         return R.ok(recordService.removeById(id));
     }
 

+ 16 - 0
in-cloud/src/main/java/com/jiayue/insu/incloud/entity/ForecastData.java

@@ -2,9 +2,12 @@ package com.jiayue.insu.incloud.entity;
 
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -33,11 +36,18 @@ public class ForecastData {
     private String inCode;
 
     //下载时间
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime initTime;
 
     //上送时间
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime uploadTime;
+
     //修正时间
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime correctTime;
 
     //预测时间
@@ -94,5 +104,11 @@ public class ForecastData {
     private BigDecimal pressureCorrect;
 
 
+    @TableField( exist = false)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Long startTime;
 
+    @TableField( exist = false)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Long endTime;
 }

+ 1 - 1
in-cloud/src/main/java/com/jiayue/insu/incloud/entity/Record.java

@@ -64,6 +64,6 @@ public class Record {
 
     @TableField( exist = false)
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private String endTime;
+    private LocalDateTime endTime;
 
 }

+ 2 - 2
in-cloud/src/main/java/com/jiayue/insu/incloud/pulldata/PullCorrectDataForQNHL.java

@@ -145,7 +145,7 @@ public class PullCorrectDataForQNHL implements IPullInitCorrectData{
 
                             List<ForecastData> aList = new ArrayList<>();
                             long startTime = DateUtil.beginOfDay(new Date()).getTime();
-                            long endTime = DateUtil.offsetDay(new Date(startTime), st.getDays()).getTime();
+                            long endTime = DateUtil.offsetDay(DateUtil.beginOfDay(DateUtil.tomorrow()), st.getDays()).getTime();
                             aList = forecastDataService.findTimeByStation(station.getStationCode(), startTime, endTime);
                             log.info(station.getStationCode() + " 请求短期修正数据返回内容:{}", response);
 
@@ -275,7 +275,7 @@ public class PullCorrectDataForQNHL implements IPullInitCorrectData{
             StringWriter writer;
 
             long startTime = DateUtil.beginOfDay(new Date()).getTime();
-            long endTime = DateUtil.offsetDay(new Date(startTime), 10).getTime();
+            long endTime = DateUtil.offsetDay(DateUtil.beginOfDay(DateUtil.tomorrow()), station.getDays()).getTime();
             List<ForecastData> aList = new ArrayList<>();
             aList = forecastDataService.findTimeByStation( station.getStationCode(), startTime, endTime);
             aList.sort(Comparator.comparing(ForecastData::getForecastTime));

+ 1 - 1
in-cloud/src/main/java/com/jiayue/insu/incloud/pushdata/PushDataForQNHL.java

@@ -89,7 +89,7 @@ public class PushDataForQNHL implements IPushInitForecastData {
 
         if (StrUtil.isNotEmpty(token) &&  LocalDateTime.now().isBefore(tokenTime)) {
             long startTime = DateUtil.beginOfDay(new Date()).getTime();
-            long endTime = DateUtil.offsetDay(new Date(startTime), st.getDays()).getTime();
+            long endTime = DateUtil.offsetDay(DateUtil.beginOfDay(DateUtil.tomorrow()), st.getDays()).getTime();
             long momentTime = 900000L;
             List<ForecastData> aList;
             aList = forecastDataService.findTimeByStation(station.getStationCode(), startTime, endTime);