123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- package com.jiayue.ipp.idp.controller;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.jiayue.ipp.common.data.entity.InverterInfo;
- import com.jiayue.ipp.common.data.entity.WindTurbineInfo;
- import com.jiayue.ipp.idp.service.InverterInfoService;
- import com.jiayue.ipp.idp.util.R;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.web.bind.annotation.*;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * idp_inverter_info
- *
- * @author whc
- * @date 2022-03-18 15:49:11
- */
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/inverterinfo")
- @Api(value = "inverterinfo", tags = "idp_inverter_info管理")
- public class InverterInfoController {
- private final InverterInfoService inverterInfoService;
- /**
- * 分页查询
- *
- * @param page 分页对象
- * @param inverterInfo idp_inverter_info
- * @return
- */
- @ApiOperation(value = "分页查询", notes = "分页查询")
- @GetMapping("/page")
- public R getInverterInfoPage(Page page, InverterInfo inverterInfo) {
- return R.ok(inverterInfoService.page(page, Wrappers.query(inverterInfo)));
- }
- /**
- * 根据场站编号分页查询
- *
- * @param currentPage
- * @param pageSize
- * @param stationCode
- * @return
- */
- @ApiOperation(value = "根据场站编号分页查询", notes = "分页查询")
- @PostMapping("/getByStationCode")
- public R getByStationCode(Long currentPage, Long pageSize, String stationCode) {
- Page page = new Page(currentPage, pageSize);
- page.setMaxLimit((long) -1);
- return R.ok(inverterInfoService.page(page, inverterInfoService.getByStationCode(stationCode)));
- }
- /**
- * 通过id查询idp_inverter_info
- *
- * @param id id
- * @return R
- */
- @ApiOperation(value = "通过id查询", notes = "通过id查询")
- @GetMapping("/{id}")
- public R getById(@PathVariable("id") String id) {
- return R.ok(inverterInfoService.getById(id));
- }
- /**
- * 新增idp_inverter_info
- *
- * @param inverterInfo idp_inverter_info
- * @return R
- */
- @ApiOperation(value = "新增idp_inverter_info", notes = "新增idp_inverter_info")
- @PostMapping
- public R save(@RequestBody InverterInfo inverterInfo) {
- return R.ok(inverterInfoService.save(inverterInfo));
- }
- /**
- * 修改idp_inverter_info
- *
- * @param inverterInfo idp_inverter_info
- * @return R
- */
- @ApiOperation(value = "修改idp_inverter_info", notes = "修改idp_inverter_info")
- @PutMapping
- public R updateById(@RequestBody InverterInfo inverterInfo) {
- return R.ok(inverterInfoService.updateById(inverterInfo));
- }
- /**
- * 通过id删除idp_inverter_info
- *
- * @param id id
- * @return R
- */
- @ApiOperation(value = "通过id删除idp_inverter_info", notes = "通过id删除idp_inverter_info")
- @DeleteMapping("/{id}")
- public R removeById(@PathVariable String id) {
- return R.ok(inverterInfoService.removeById(id));
- }
- /**
- * 根据场站编号查询 返回map格式
- *
- * @param stationCode
- * @return
- */
- @ApiOperation(value = "根据场站编号查询", notes = "分页查询")
- @PostMapping("/findByStationCode")
- public R findByStationCode(String stationCode) {
- List<InverterInfo> inverterInfoList = inverterInfoService.findByStationCode(stationCode);
- List<Map<String, String>> list = new ArrayList<>();
- for (InverterInfo e : inverterInfoList) {
- Map<String, String> map = new HashMap<>();
- map.put("label", e.getName());
- map.put("value", e.getEquipmentNo());
- list.add(map);
- }
- return R.ok(list);
- }
- @GetMapping("/all")
- public R findAll() {
- List<InverterInfo> inverterInfoList = inverterInfoService.list();
- List<Map<String, String>> list = new ArrayList<>();
- for (InverterInfo e : inverterInfoList) {
- Map<String, String> map = new HashMap<>();
- map.put("label", e.getName());
- map.put("value", e.getId());
- list.add(map);
- }
- return R.ok(list);
- }
- /**
- * 查找设备编号是否存在
- *
- * @param stationCode
- * @return
- */
- @GetMapping("/findExistEquipmentNo")
- public R findExistEquipmentNo(String stationCode,String equipmentNo) {
- QueryWrapper<InverterInfo> wrapper = new QueryWrapper<>();
- wrapper.eq("station_code", stationCode);
- wrapper.eq("equipment_no", equipmentNo);
- List<InverterInfo> inverterInfoList = inverterInfoService.list(wrapper);
- return R.ok(inverterInfoList);
- }
- }
|