Browse Source

增加气象站基础信息

xusl 3 năm trước cách đây
mục cha
commit
24dcfd51e0

+ 48 - 30
ipfcst-console/src/main/frontend/views/console/weatherStationInfo/index.vue

@@ -7,6 +7,19 @@
                    @click="exportDataEvent">导出数据
         </el-button>
       </div>
+      <span style="font-weight: bold;font-size: 14px">场站名称:</span>
+      <el-select style="width:250px" clearable v-model="stationCode" size="small" >
+        <el-option
+          v-for="item in stationList"
+          :key="item.stationCode"
+          :label="item.name"
+          :value="item.stationCode">
+          <span style="float: left">{{ item.name }}</span>
+          <span style="float: right; color: #8492a6;font-size: 13px">{{ item.stationCode }}</span>
+        </el-option>
+
+      </el-select>
+      <el-button type="primary" icon="el-icon-search" size="small" @click="queryInfo">查询</el-button>
       <el-button type="primary" size="small" @click="insertEvent" style="round-clip: 10px"
                  :loading="btnLonding">新增</el-button>
       <div style="padding-top: 10px">
@@ -26,13 +39,15 @@
           :edit-config="{trigger: 'manual', mode: 'row',autoClear: false,icon:'none'}"
         >
           <vxe-table-column title="气象站信息">
+            <vxe-table-column field="stationCode" title="场站编号" width="6%"
+                              :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
             <vxe-table-column field="name" title="名称"width="13%"
                               :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
             <vxe-table-column field="manufacturer" title="生产商" width="13%"
                               :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
             <vxe-table-column field="modelNumber" title="型号" width="13%"
                               :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
-            <vxe-table-column min-width="60px" width="15%" field="installationTime" title="安装时间"
+            <vxe-table-column min-width="60px" width="10%" field="installationTime" title="安装时间"
                               :edit-render="{props: {type: 'default'}}">
               <template v-slot:edit="{ row }">
                 <el-date-picker
@@ -45,7 +60,7 @@
               </template>
               <template v-slot="{ row }">{{ timestampToTime(row.installationTime) }}</template>
             </vxe-table-column>
-            <vxe-table-column field="report" title="是否上报" width="8%"
+            <vxe-table-column field="report" title="是否上报" width="6%"
                               :edit-render="{name: '$select', options: options}"></vxe-table-column>
             <vxe-table-column field="bindTunnel" title="绑定通道" width="13%"
                               :edit-render="{name: '$select', options: bindTunnels}"
@@ -96,17 +111,6 @@
             </vxe-table-column>
           </vxe-table-column>
         </vxe-table>
-        <vxe-pager
-          perfect
-          :current-page.sync="currentPage"
-          :page-size.sync="pageSize"
-          :total="total"
-          :page-sizes=[10,50,100]
-          :layouts="['PrevJump', 'PrevPage','JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
-          @page-change="handlePageChange"
-          v-show="!btnLonding&&showTable"
-        >
-        </vxe-pager>
       </div>
 
     </el-card>
@@ -152,6 +156,8 @@
       }
       return {
         id:'',
+        stationCode: '',
+        stationList: [],
         equipmentTypeList: [],
         loading: false,
         saveLoding: false,
@@ -199,17 +205,22 @@
       }
     },
     created() {
-      this.getAll()
-
+      this.getStationList()
+      // this.getAll()
     },
     methods: {
-      getAll() {
-        this.$axios.get('/TunnelInfo/findbyMaster').then(res => {
-          this.bindTunnels = res.data
-        })
+      // 查询
+      queryInfo() {
+        // this.$axios.get('/TunnelInfo/findbyMaster').then(res => {
+        //   this.bindTunnels = res.data
+        // })
         this.loading = true
         this.saveLoding = false
-        this.$axios.get('/weatherStationInfo/' + this.currentPage + '/' + this.pageSize).then(response => {
+        let queryParam = this.stationCode;
+        if (queryParam==''){
+          queryParam="ALL"
+        }
+        this.$axios.get('/weatherStationInfo/' + queryParam).then(response => {
           if (response.data.content == "") {
             this.showTable = false
 
@@ -217,13 +228,25 @@
             this.showTable = true
           }
 
-          this.tableData = response.data.content
-
-          this.total = response.data.totalElements
+          this.tableData = response.data
           this.loading = false
           this.btnLonding = false
         })
       },
+      getStationList() {
+        this.$axios.get('/electricField/getElectricField').then((res) => {
+            this.stationList = res.data
+          }).catch((error) => {
+            this.$message.error('获取场站下拉框出错' + error)
+          })
+      },
+      stationCodeChange() {
+        this.$axios.get('/uploadObject/getByStationCode/' + this.stationCode).then((res) => {
+          this.uploadObjectId=''
+          this.uploadFileType=''
+          this.queryUploadObject = res.data
+        })
+      },
       editRowEvent(row) {
         this.id = row.id
         this.btnLonding = true
@@ -236,14 +259,14 @@
           if (valid) {
             if (row.id == undefined) {
               this.$axios.post('/weatherStationInfo/', row).then(response => {
-                this.getAll()
+                this.queryInfo()
                 this.btnLonding = false
                 this.$XModal.message({status: 'warning', message: response.message})
               })
             } else {
               row.equipmentType = row.equipmentType.code
               this.$axios.put('/weatherStationInfo/', row).then(response => {
-                this.getAll()
+                this.queryInfo()
                 this.$XModal.message({status: 'warning', message: response.message})
                 this.saveLoding = false
               })
@@ -297,11 +320,6 @@
         this.$refs.xTable.insert({interval: 60})
           .then(({row}) => this.$refs.xTable.setActiveRow(row))
       },
-      handlePageChange({currentPage, pageSize}) {
-        this.currentPage = currentPage
-        this.pageSize = pageSize
-        this.getAll()
-      },
       exportDataEvent() {
         this.loading = true
         this.$axios.get('/weatherStationInfo/').then(res => {

+ 148 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WeatherStationInfoController.java

@@ -0,0 +1,148 @@
+package com.jiayue.ipfcst.console.controller;
+
+import com.jiayue.ipfcst.aop.SaveValidate;
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
+import com.jiayue.ipfcst.console.service.WeatherStationInfoService;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 环境监测仪restful接口
+ *
+ * @author tl
+ * @version 3.0
+ * @since 2020/6/7 11:29
+ */
+@RestController
+@RequestMapping("/weatherStationInfo")
+@Slf4j
+public class WeatherStationInfoController {
+
+    private final WeatherStationInfoService weatherStationInfoService;
+
+    @Autowired
+    public WeatherStationInfoController(WeatherStationInfoService weatherStationInfoService) {
+        this.weatherStationInfoService = weatherStationInfoService;
+    }
+
+    /**
+     * 新增环境监测仪
+     *
+     * @param weatherStationInfo 参数
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @SaveValidate
+    @PostMapping()
+    public ResponseVO add(@RequestBody WeatherStationInfo weatherStationInfo) {
+      try {
+        this.weatherStationInfoService.add(weatherStationInfo);
+        return ResponseVO.success(1);
+      } catch (Exception ex) {
+        log.error("系统错误" + ex);
+        return ResponseVO.error(ex);
+      }
+
+
+    }
+
+    /**
+     * 修改环境监测仪
+     *
+     * @param weatherStationInfo 参数
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @SaveValidate
+    @PutMapping()
+    public ResponseVO update(@RequestBody WeatherStationInfo weatherStationInfo) {
+      try {
+        this.weatherStationInfoService.update(weatherStationInfo);
+        return ResponseVO.success(1);
+      } catch (Exception ex) {
+        log.error("系统错误" + ex);
+        return ResponseVO.error(ex);
+      }
+
+    }
+
+    /**
+     * 获取环境监测仪
+     *
+     * @param weatherStationInfo 参数
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @GetMapping("/ById")
+    public ResponseVO get(@RequestBody WeatherStationInfo weatherStationInfo) {
+        try {
+          weatherStationInfo = this.weatherStationInfoService.get(weatherStationInfo.getId());
+          return ResponseVO.success(weatherStationInfo);
+        } catch (Exception ex) {
+          log.error("系统错误" + ex);
+          return ResponseVO.error(ex);
+        }
+
+    }
+
+    /**
+     * 删除环境监测仪
+     *
+     * @param id 参数
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @SaveValidate
+    @DeleteMapping("/{id}")
+    public ResponseVO delete(@PathVariable Integer id) {
+      try {
+        this.weatherStationInfoService.delete(id);
+        return ResponseVO.success(1);
+      } catch (Exception ex) {
+        log.error("系统错误" + ex);
+        return ResponseVO.error(ex);
+      }
+
+    }
+
+    /**RequestParams
+     * 获取环境监测仪
+     *
+     * @param stationCode 参数
+     * @return 执行结果
+     */
+    @GetMapping(value = "/{stationCode}")
+    public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
+        try {
+          List<WeatherStationInfo> weatherStationInfoPage = this.weatherStationInfoService.get(stationCode);
+          return ResponseVO.success(weatherStationInfoPage);
+        } catch (Exception ex) {
+          log.error("系统错误" + ex);
+          return ResponseVO.error(ex);
+        }
+
+    }
+
+  /**
+   * 获取环境监测仪
+   *
+   * @return 执行结果
+   */
+  @GetMapping()
+  public ResponseVO getAll() {
+    try {
+      List<WeatherStationInfo> list = this.weatherStationInfoService.getAll();
+      return ResponseVO.success(list);
+    } catch (Exception ex) {
+      log.error("系统错误" + ex);
+      return ResponseVO.error(ex);
+    }
+
+  }
+}

+ 142 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WeatherStationInfoService.java

@@ -0,0 +1,142 @@
+package com.jiayue.ipfcst.console.service;
+
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
+import com.jiayue.ipfcst.common.data.entity.InverterInfo;
+import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
+import com.jiayue.ipfcst.common.data.repository.WeatherStationInfoRepository;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.*;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * 环境监测仪业务层
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/8/7 10:58
+ */
+@Service
+@Slf4j
+public class WeatherStationInfoService extends BaseService {
+  private final WeatherStationInfoRepository weatherStationInfoRepository;
+
+  @Autowired
+  public WeatherStationInfoService(WeatherStationInfoRepository weatherStationInfoRepository) {
+    this.weatherStationInfoRepository = weatherStationInfoRepository;
+  }
+
+
+  /**
+   * 新增环境监测仪
+   *
+   * @param weatherStationInfo 气象站
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void add(WeatherStationInfo weatherStationInfo) throws BusinessException {
+    this.weatherStationInfoRepository.save(weatherStationInfo);
+
+  }
+
+  /**
+   * 修改环境监测仪
+   *
+   * @param weatherStationInfo 监测仪
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void update(WeatherStationInfo weatherStationInfo) throws BusinessException {
+    if (StringUtils.isEmpty(weatherStationInfo.getId())) {
+      throw new BusinessException("环境监测仪编号不能为空!");
+    } else {
+      this.weatherStationInfoRepository.save(weatherStationInfo);
+    }
+  }
+
+  /**
+   * 删除环境监测仪
+   *
+   * @param id 监测仪编号
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void delete(final Integer id) throws BusinessException {
+    if (StringUtils.isEmpty(id)) {
+      throw new BusinessException("环境监测仪编号不能为空!");
+    } else {
+      this.weatherStationInfoRepository.deleteById(id);
+    }
+  }
+
+  /**
+   * 查询环境监测仪
+   *
+   * @param no 测风塔编号
+   * @return 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public WeatherStationInfo get(final Integer no) throws BusinessException {
+    Optional<WeatherStationInfo> optional = this.weatherStationInfoRepository.findById(no);
+    if (optional.isPresent()) {
+      return optional.get();
+    } else {
+      throw new BusinessException("环境监测仪不存在!");
+    }
+  }
+
+  /**
+   * 查询环境监测仪【分页查询】
+   *
+   * @param stationCode 场站编号
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<WeatherStationInfo> get(String stationCode) {
+    List<WeatherStationInfo> resultList = new ArrayList<>();
+    resultList =  this.weatherStationInfoRepository.findAll();
+    if (!"ALL".equals(stationCode)){
+      resultList = resultList.stream().filter(s->s.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    }
+    return resultList.stream().sorted(Comparator.comparing(WeatherStationInfo::getStationCode)).collect(Collectors.toList());
+  }
+
+  /**
+   * 查询环境监测仪
+   *
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<WeatherStationInfo> getAll() {
+    return this.weatherStationInfoRepository.findAll();
+  }
+
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(WeatherStationInfo bean) {
+//        WeatherStationInfo weatherStationInfo = weatherStationInfoRepository.findByName(bean.getName());
+//        if (null != weatherStationInfo) {
+//            bean.setId(weatherStationInfo.getId());
+//        }
+    weatherStationInfoRepository.save(bean);
+  }
+
+
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(List<WeatherStationInfo> beans) {
+    if(beans != null && beans.size() > 0){
+      weatherStationInfoRepository.deleteAll();
+      weatherStationInfoRepository.saveAll(beans);
+    }
+  }
+}

+ 8 - 8
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java

@@ -147,7 +147,7 @@ public class E63UploadFileService extends BaseUploadFileService {
             template.merge(velocityContext, writer);
 
             // 将文件复制到上报路径中
-            super.copyUploadFile(writer, file, FileTypeEnum.E1.name(), null, systemDate, stationCode);
+            super.copyUploadFile(writer, file, FileTypeEnum.E1.name(), null, date, stationCode);
           }
         } else {
           log.error(stationCode + "短期上报模板不存在!");
@@ -220,7 +220,7 @@ public class E63UploadFileService extends BaseUploadFileService {
             writer = new StringWriter();
             template.merge(velocityContext, writer);
             // 将文件复制到上报路径中
-            super.copyUploadFile(writer, file, FileTypeEnum.E26.name(), null, systemDate, stationCode);
+            super.copyUploadFile(writer, file, FileTypeEnum.E26.name(), null, date, stationCode);
           }
         } else {
           log.error(stationCode + "可用短期上报模板不存在!");
@@ -300,7 +300,7 @@ public class E63UploadFileService extends BaseUploadFileService {
             writer = new StringWriter();
             template.merge(velocityContext, writer);
 
-            super.copyUploadFile(writer, file, FileTypeEnum.E2.name(), null, systemDate, stationCode);
+            super.copyUploadFile(writer, file, FileTypeEnum.E2.name(), null, date, stationCode);
           }
         } else {
           log.error(stationCode + "超短期上报模板不存在!");
@@ -382,7 +382,7 @@ public class E63UploadFileService extends BaseUploadFileService {
             velocityContext.put("uploadTime", DateFormatUtils.format(startTime - 15 * 60 * 1000, "yyyy-MM-dd_HH:mm"));
             writer = new StringWriter();
             template.merge(velocityContext, writer);
-            super.copyUploadFile(writer, file, FileTypeEnum.E27.name(), null, systemDate, stationCode);
+            super.copyUploadFile(writer, file, FileTypeEnum.E27.name(), null, date, stationCode);
           }
         } else {
           log.error(stationCode + "可用超短期上报模板不存在!");
@@ -424,13 +424,13 @@ public class E63UploadFileService extends BaseUploadFileService {
           template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ.vm");
           fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E6", endTime);
           if (getFileName(fileName, "E6", stationCode)) {
-            generateQxzFile(fileName, template, electricFieldInfo, systemDate, startTime, endTime);
+            generateQxzFile(fileName, template, electricFieldInfo, date, startTime, endTime);
           }
         } else {
           template = this.velocityEngine.getTemplate(this.vmsPath + "/CFT.vm");
           fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E7", endTime);
           if (getFileName(fileName, "E7", stationCode)) {
-            generateCftFile(fileName, template, electricFieldInfo, systemDate, startTime, endTime);
+            generateCftFile(fileName, template, electricFieldInfo, date, startTime, endTime);
           }
         }
       } catch (Exception e) {
@@ -607,10 +607,10 @@ public class E63UploadFileService extends BaseUploadFileService {
         // 没有测风塔数据用nwp数据补
         Long nwpTime;
         try {
-          nwpTime = DateMomentUtil.getMomentTime(date.getTime(), 1, 15 * 60 * 1000L);
+          nwpTime = DateMomentUtil.getMomentTime(endTime, 1, 15 * 60 * 1000L);
         } catch (Exception e) {
           log.error("获取nwp时刻步长错误", e);
-          nwpTime = DateMomentUtil.getDayStartTime(date.getTime());
+          nwpTime = DateMomentUtil.getDayStartTime(new Date().getTime());
         }
         List<Nwp> nwpList = nwpRepository.findByPreTimeBetween(nwpTime, nwpTime);