package com.gyee.backconfig.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.gyee.backconfig.config.CacheContext; import com.gyee.backconfig.config.R; import com.gyee.backconfig.model.auto.ProEconTestingPoint; import com.gyee.backconfig.service.auto.AsysncGeneratePointService; import com.gyee.backconfig.service.auto.IProEconTestingPointService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** *

* 逻辑测点 前端控制器 *

* * @author wang * @since 2022-11-10 */ @Api(value = "逻辑测点配置" ,tags = "逻辑测点配置") @RestController @RequestMapping("//pro-econ-testing-point") public class ProEconTestingPointController { @Autowired private IProEconTestingPointService proEconTestingPointService; @Autowired private CacheContext cacheContext; @Autowired private AsysncGeneratePointService asysncTestService; /** * 逻辑测点list * @param id * @param nemCode * @param name * @param model * @param uniformCode * @param isDisplay * @param pageNum * @param pageSize * @return */ @GetMapping(value = "/list") @ApiOperation(value = "逻辑测点配置-列表", notes = "逻辑测点配置-列表") public R findList(@RequestParam(value = "id", required = false) String id, @RequestParam(value = "nemCode", required = false) String nemCode, @RequestParam(value = "name", required = false) String name, @RequestParam(value = "model", required = false) String model, @RequestParam(value = "uniformCode", required = false) String uniformCode, @RequestParam(value = "isDisplay", required = false) String isDisplay, @RequestParam(value = "pageNum", required = true) String pageNum, @RequestParam(value = "pageSize", required = true) String pageSize) { IPage list = proEconTestingPointService.list( id, nemCode, name, model, uniformCode, isDisplay, pageNum, pageSize); if (null != list) { return R.ok().data(list); } else { return R.error().data("查询失败!"); } } /** * 添加 * @param proEconTestingPoint * @return */ @PostMapping(value = "/add") @ApiOperation(value = "逻辑测点配置-新增or修改", notes = "逻辑测点配置-新增or修改") public R addAll(@RequestBody ProEconTestingPoint proEconTestingPoint) { boolean b = proEconTestingPointService.saveOrUpdate(proEconTestingPoint); if (b) { cacheContext.initProEconTestingPointList(); return R.ok().data(b); } else { return R.error().data("保存失败!"); } } /** * 删除 * @param ids * @return */ @DeleteMapping(value = "/{ids}") @ApiOperation(value = "逻辑测点配置-删除", notes = "逻辑测点配置-删除") public R deleteAll(@PathVariable("ids") String ids) { String[] strings = ids.split(","); boolean b = proEconTestingPointService.removeByIds(Arrays.asList(strings)); if (b) { cacheContext.initProEconTestingPointList(); return R.ok().data(b); } else { return R.error().data("删除失败!"); } } /** * 测点生成器 * @param points 测点,数组 默认空:全部 * @param station 场站 默认空(全场) * @param type fj:风机测点;fc:风场测点;sbs:变电所测点;ws:气象站测点;sq:方正测点 默认空:全部 * @return */ @PostMapping(value = "/generatePoint") @ApiOperation(value = "设备or场站测点生成", notes = "设备or场站测点生成") public R generatePoint(@RequestParam(value = "points", required = false) String[] points, @RequestParam(value = "station", required = false) String station, @RequestParam(value = "type", required = false) String type) { try { // String[] stations = station.split(","); // Arrays.stream(stations).forEach(i->{ // // }); asysncTestService.generatePoint(station,points, type); } catch (Exception e) { e.printStackTrace(); return R.error(); } return R.ok().data(true); } /** * 测点分类列表 * @param type fj:风机测点;fc:风场测点;sbs:变电所测点;ws:气象站测点;sq:方正测点 默认空:全部 * @return */ @PostMapping(value = "/type-point-list") @ApiOperation(value = "测点分类列表", notes = "测点分类列表") public R generateTypePointList( @RequestParam(value = "type", required = false) String type) { List list = new ArrayList<>(); try { list = proEconTestingPointService.generateTypePointList(type); } catch (Exception e) { e.printStackTrace(); return R.error(); } return R.ok().data(list); } @PostMapping(value = "/generateSubStationPoint") @ApiOperation(value = "变电所测点生成", notes = "变电所测点生成") public R generateSubStationPoint(@RequestParam(value = "points", required = false) String[] points, @RequestParam(value = "station", required = false) String station) { try { proEconTestingPointService.generateSubStationPoint(station,points); } catch (Exception e) { e.printStackTrace(); return R.error(); } return R.ok().data(true); } @PostMapping(value = "/generateWsStationPoint") @ApiOperation(value = "气象站测点生成", notes = "气象站测点生成") public R generateWsStationPoint(@RequestParam(value = "points", required = false) String[] points, @RequestParam(value = "station", required = false) String station) { try { proEconTestingPointService.generateWsStationPoint(station,points); } catch (Exception e) { e.printStackTrace(); return R.error(); } return R.ok().data(true); } @PostMapping(value = "/generateSquareStationPoint") @ApiOperation(value = "光伏阵区测点生成", notes = "光伏阵区测点生成") public R generateSquareStationPoint(@RequestParam(value = "points", required = false) String[] points, @RequestParam(value = "station", required = false) String station) { try { proEconTestingPointService.generateSquareStationPoint(station,points); } catch (Exception e) { e.printStackTrace(); return R.error(); } return R.ok().data(true); } }