ソースを参照

增加风机信息

xusl 3 年 前
コミット
a9ea5f65c9

+ 0 - 5
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/WindTurbineInfo.java

@@ -144,11 +144,6 @@ public class WindTurbineInfo extends AbstractEquipmentInfo {
     @Column
     private String divideIntoDifferentPeriod;
 
-
-    /**
-     * backupA 分期
-     */
-
     /**
      * backupB 额定功率
      */

+ 31 - 8
ipfcst-console/src/main/frontend/views/console/windTurbineInfo/index.vue

@@ -6,6 +6,18 @@
         <el-button style="float: right;padding:3px 10px 3px 3px;" type="text" @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="getAll">查询</el-button>
       <el-button
         type="primary"
         size="small"
@@ -68,6 +80,8 @@
         >
           <vxe-table-column title="风机信息">
             <vxe-table-column type="checkbox" width="3%"/>
+            <vxe-table-column field="stationCode" title="场站编号" width="6%"
+                              :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
             <vxe-table-column
               field="name"
               width="10%"
@@ -81,9 +95,9 @@
               :edit-render="{name:'$input',attrs:{type:'text'}}"
             />
             <vxe-table-column
-              field="backupA"
+              field="equipmentNo"
               width="10%"
-              title="分期"
+              title="设备编号"
               :edit-render="{name:'$input',attrs:{type:'text'}}"
             />
             <vxe-table-column
@@ -347,6 +361,8 @@ export default {
       callback()
     }
     return {
+      stationCode: '',
+      stationList: [],
       delVisible: false,
       piadd: false,
       id: '',
@@ -469,18 +485,25 @@ export default {
     }
   },
   created() {
+    this.getStationList()
     this.getAll()
   },
   methods: {
+    getStationList() {
+      this.$axios.get('/electricField/getElectricField').then((res) => {
+        this.stationList = res.data
+      }).catch((error) => {
+        this.$message.error('获取场站下拉框出错' + error)
+      })
+    },
     getAll() {
       this.loading = true
       this.saveLoding = false
-      this.$axios.get('/windTurbineInfo/' + this.currentPage + '/' + this.pageSize).then(response => {
-        if (response.data.content == '') {
-          this.showTable = false
-        } else {
-          this.showTable = true
-        }
+      let queryParam = this.stationCode;
+      if (queryParam==''){
+        queryParam="ALL"
+      }
+      this.$axios.get('/windTurbineInfo/' + this.currentPage + '/' + this.pageSize+ '/' + queryParam).then(response => {
         this.loading = false
         // window.console.log(response.data.content)
         this.tableData = response.data.content

+ 162 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTurbineInfoController.java

@@ -0,0 +1,162 @@
+package com.jiayue.ipfcst.console.controller;
+
+import com.jiayue.ipfcst.aop.SaveValidate;
+import com.jiayue.ipfcst.common.core.web.vo.RequestVO;
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
+import com.jiayue.ipfcst.common.data.entity.InverterInfo;
+import com.jiayue.ipfcst.common.data.entity.WindTurbineInfo;
+import com.jiayue.ipfcst.console.service.WindTurbineInfoService;
+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("windTurbineInfo")
+@Slf4j
+public class WindTurbineInfoController {
+
+  private final WindTurbineInfoService windTurbineInfoService;
+
+  @Autowired
+  public WindTurbineInfoController(WindTurbineInfoService windTurbineInfoService) {
+    this.windTurbineInfoService = windTurbineInfoService;
+  }
+
+  /**
+   * 新增风机
+   *
+   * @param windTurbineInfo 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @PostMapping()
+  public ResponseVO add(@RequestBody WindTurbineInfo windTurbineInfo) {
+    this.windTurbineInfoService.add(windTurbineInfo);
+    return ResponseVO.success(1);
+  }
+
+  /**
+   * 修改风机
+   *
+   * @param windTurbineInfo 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @PutMapping()
+  public ResponseVO update(@RequestBody WindTurbineInfo windTurbineInfo) {
+    this.windTurbineInfoService.update(windTurbineInfo);
+    return ResponseVO.success(1);
+  }
+
+  /**
+   * 获取风机
+   *
+   * @param requestVO 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping("ById")
+  public ResponseVO get(@RequestBody RequestVO<WindTurbineInfo> requestVO) {
+    WindTurbineInfo windTurbineInfo = requestVO.getData();
+    windTurbineInfo = this.windTurbineInfoService.get(windTurbineInfo.getId());
+    return ResponseVO.success(windTurbineInfo);
+  }
+
+  /**
+   * 删除风机
+   *
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @DeleteMapping("/{id}")
+  public ResponseVO delete(@PathVariable Integer id) {
+    this.windTurbineInfoService.delete(id);
+    return ResponseVO.success(1);
+  }
+
+  /**
+   * 获取风机
+   *
+   * @param page 参数
+   * @param size 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "/{page}/{size}/{stationCode}")
+  public ResponseVO getAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size, @PathVariable("stationCode") String stationCode) {
+    WindTurbineInfo windTurbineInfo = new WindTurbineInfo();
+    if (!"ALL".equals(stationCode)) {
+      windTurbineInfo.setStationCode(stationCode);
+    }
+    Page<WindTurbineInfo> windTurbinePage = this.windTurbineInfoService.get(windTurbineInfo, page, size);
+    return ResponseVO.success(windTurbinePage);
+  }
+
+
+  /**
+   * 获取风机
+   *
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping()
+  public ResponseVO getAll() {
+    List<WindTurbineInfo> list = this.windTurbineInfoService.getAll();
+    return ResponseVO.success(list);
+  }
+
+  /**
+   * 批量保存逆变器信息
+   *
+   * @param windTurbineInfo 风机实体
+   * @return 执行结果
+   */
+  @SaveValidate
+  @PostMapping(value = "/saveAll/{startValue}/{endValue}")
+  public ResponseVO allSaveWindTurbineInfo(@RequestBody WindTurbineInfo windTurbineInfo, @PathVariable("startValue") Integer startValue, @PathVariable("endValue") Integer endValue) {
+    try {
+      windTurbineInfoService.addALL(windTurbineInfo, startValue, endValue);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error("批量保存风机信息异常");
+      return ResponseVO.fail();
+    }
+  }
+
+  /**
+   * 删除逆变器信息
+   *
+   * @param ids 删除id
+   * @return 执行结果
+   */
+  @SaveValidate
+  @DeleteMapping(value = "/deleteIds/{ids}")
+  public ResponseVO deleteWindTurbineInfo(@PathVariable("ids") String ids) {
+    try {
+      windTurbineInfoService.delete(ids);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 删除逆变器异常");
+      return ResponseVO.fail();
+    }
+
+  }
+
+}

+ 227 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTurbineInfoService.java

@@ -0,0 +1,227 @@
+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.WindTowerInfo;
+import com.jiayue.ipfcst.common.data.entity.WindTurbineInfo;
+import com.jiayue.ipfcst.common.data.repository.WindTurbineInfoRepository;
+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.List;
+import java.util.Optional;
+
+/**
+ * 风机业务层
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/8/7 10:58
+ */
+@Service
+@Slf4j
+public class WindTurbineInfoService extends BaseService {
+    private final WindTurbineInfoRepository windTurbineInfoRepository;
+
+    @Autowired
+    public WindTurbineInfoService(WindTurbineInfoRepository windTurbineInfoRepository) {
+        this.windTurbineInfoRepository = windTurbineInfoRepository;
+    }
+
+
+    /**
+     * 新增风机
+     *
+     * @param windTurbine 风机
+     * @throws BusinessException 业务异常
+     */
+    @Transactional(propagation = Propagation.SUPPORTS)
+    public void add(WindTurbineInfo windTurbine) throws BusinessException {
+        this.windTurbineInfoRepository.save(windTurbine);
+//        boolean b = this.windTurbineRepository.existsById(windTurbine.getNo());
+//        if (b) {// 编号已存在
+//            throw new BusinessException("风机编号已存在!");
+//        } else {
+//            this.windTurbineRepository.save(windTurbine);
+//        }
+    }
+
+    /**
+     * 修改风机
+     *
+     * @param windTurbine 逆变器
+     * @throws BusinessException 业务异常
+     */
+    @Transactional(propagation = Propagation.SUPPORTS)
+    public void update(WindTurbineInfo windTurbine) throws BusinessException {
+        if (StringUtils.isEmpty(windTurbine.getId())) {
+            throw new BusinessException("风机编号不能为空!");
+        } else {
+            this.windTurbineInfoRepository.save(windTurbine);
+        }
+    }
+
+    /**
+     * 删除风机
+     *
+     * @param no 逆变器编号
+     * @throws BusinessException 业务异常
+     */
+    @Transactional(propagation = Propagation.SUPPORTS)
+    public void delete(final Integer no) throws BusinessException {
+        if (StringUtils.isEmpty(no)) {
+            throw new BusinessException("风机编号不能为空!");
+        } else {
+            this.windTurbineInfoRepository.deleteById(no);
+        }
+    }
+
+    /**
+     * 查询风机
+     *
+     * @param no 逆变器编号
+     * @return 逆变器
+     * @throws BusinessException 业务异常
+     */
+    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+    public WindTurbineInfo get(final Integer no) throws BusinessException {
+        Optional<WindTurbineInfo> optional = this.windTurbineInfoRepository.findById(no);
+        if (optional.isPresent()) {
+            return optional.get();
+        } else {
+            throw new BusinessException("风机不存在!");
+        }
+    }
+
+    /**
+     * 查询风机【分页查询】
+     *
+     * @param windTurbine 查询条件
+     * @param page        页码
+     * @param size        每页记录数
+     * @return 分页结果
+     */
+    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+    public Page<WindTurbineInfo> get(final WindTurbineInfo windTurbine, final Integer page, final Integer size) {
+        ExampleMatcher matcher =
+                ExampleMatcher.matching().withMatcher("modelNumber", ExampleMatcher.GenericPropertyMatchers.contains());
+        Example<WindTurbineInfo> example = Example.of(windTurbine, matcher);
+        Pageable pageable = PageRequest.of(page - 1, size);
+        return this.windTurbineInfoRepository.findAll(example, pageable);
+    }
+
+    /**
+     * 查询风机
+     *
+     * @return 分页结果
+     */
+    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+    public List<WindTurbineInfo> getAll() {
+        return this.windTurbineInfoRepository.findAll();
+    }
+
+
+    /**
+     * 查询所有样板机风机 create by xiuwei
+     *
+     * @return 风机信息
+     */
+    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+    public List<WindTurbineInfo> getAllSample() {
+        WindTurbineInfo windTurbineInfo = new WindTurbineInfo();
+        windTurbineInfo.setSample(true);
+        return windTurbineInfoRepository.findAll(Example.of(windTurbineInfo));
+    }
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void saveCloud(WindTurbineInfo bean) {
+//        WindTurbineInfo beanOld = windTurbineInfoRepository.findByName(bean.getName());
+//        if (null != beanOld) {
+//            bean.setId(beanOld.getId());
+//        }
+        windTurbineInfoRepository.save(bean);
+    }
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void saveCloud(List<WindTurbineInfo> beans) {
+        if(beans != null && beans.size() > 0){
+            windTurbineInfoRepository.deleteAll();
+            windTurbineInfoRepository.saveAll(beans);
+        }
+    }
+
+  /**
+   * 批量新增逆变器
+   *
+   * @param windTurbineInfo 风机
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void addALL(WindTurbineInfo windTurbineInfo, Integer startValue, Integer endValue) throws BusinessException {
+    for (int i = startValue; i < startValue + endValue; i++) {
+      WindTurbineInfo windTurbineInfo1 = new WindTurbineInfo();
+      windTurbineInfo1.setManufacturer(windTurbineInfo.getManufacturer());
+      windTurbineInfo1.setReport(windTurbineInfo.getReport());
+      windTurbineInfo1.setInstallationTime(windTurbineInfo.getInstallationTime());
+      windTurbineInfo1.setName(windTurbineInfo.getName() + "" + i);
+      windTurbineInfo1.setAirDensity(windTurbineInfo.getAirDensity());
+      windTurbineInfo1.setCutInSpeed(windTurbineInfo.getCutInSpeed());
+      windTurbineInfo1.setCutOutSpeed(windTurbineInfo.getCutOutSpeed());
+      windTurbineInfo1.setGrade(windTurbineInfo.getGrade());
+      windTurbineInfo1.setHubHeight(windTurbineInfo.getHubHeight());
+      windTurbineInfo1.setLifeLength(windTurbineInfo.getLifeLength());
+      windTurbineInfo1.setRatedWindSpeed(windTurbineInfo.getRatedWindSpeed());
+      windTurbineInfo1.setSample(windTurbineInfo.getSample());
+      windTurbineInfo1.setModelNumber(windTurbineInfo.getModelNumber());
+      windTurbineInfo1.setLiveWindSpeed(windTurbineInfo.getLiveWindSpeed());
+      windTurbineInfo1.setMaxPower(windTurbineInfo.getMaxPower());
+      windTurbineInfo1.setParallelInDate(windTurbineInfo.getParallelInDate());
+      windTurbineInfo1.setWindWheelDiameter(windTurbineInfo.getWindWheelDiameter());
+      windTurbineInfo1.setWindWheelMaxSpeed(windTurbineInfo.getWindWheelMaxSpeed());
+      windTurbineInfo1.setWindWheelRatedSpeed(windTurbineInfo.getWindWheelRatedSpeed());
+      windTurbineInfo1.setWindWheelMinSpeed(windTurbineInfo.getWindWheelMinSpeed());
+      windTurbineInfo1.setInterval(windTurbineInfo.getInterval());
+      this.windTurbineInfoRepository.save(windTurbineInfo1);
+    }
+
+
+//        boolean b = this.inverterRepository.existsById(inverter.getNo());
+//        if (b) {// 逆变器编号已存在
+//            throw new BusinessException("逆变器编号已存在!");
+//        } else {
+//
+//        }
+  }
+
+  /**
+   * 批量删除风机信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public boolean delete(String ids) {
+    boolean flag = false;
+    if (!StringUtils.isEmpty(ids)) {
+      String[] idArray = ids.split(",");
+      if (idArray != null && idArray.length > 0) {
+        for (String id : idArray) {
+          this.windTurbineInfoRepository.deleteById(Integer.valueOf(id));
+          log.info("删除风机ID为[" + id + "]成功!");
+
+        }
+        flag = true;
+      } else {
+        this.windTurbineInfoRepository.deleteById(Integer.valueOf(ids));
+        flag = true;
+        log.info("删除风机ID为[" + ids + "]成功!");
+      }
+    }
+
+    return flag;
+
+  }
+}