| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.paramter.PowerInfPar; |
| | | import com.whyc.factory.BattinfGroupFactory; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.pojo.PowerInf; |
| | | import com.whyc.pojo.StationInf; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.service.BattInfService; |
| | | import com.whyc.service.PowerAppSysService; |
| | | import com.whyc.service.PowerInfService; |
| | | import com.whyc.service.StationInfService; |
| | | import com.whyc.util.ActionUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | @RequestMapping("powerInf") |
| | | @RestController |
| | | @Api(tags = "电源管理") |
| | | public class PowerInfController { |
| | | @Api(tags = "数据管理-电源信息") |
| | | public class PowerInfController extends BaseController{ |
| | | @Autowired |
| | | private PowerInfService service; |
| | | @Autowired |
| | | private BattInfService battInfService; |
| | | @Autowired |
| | | private PowerAppSysService powerAppSysService; |
| | | @Autowired |
| | | private StationInfService stationInfService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加电源") |
| | | @Transactional |
| | | public Response add(@RequestBody PowerInf powerInf){ |
| | | service.add(powerInf); |
| | | return new Response().setII(1,"添加成功"); |
| | | int userId = ((UserInf)ActionUtil.getSession().getAttribute("user")).getUId().intValue(); |
| | | Response res = new Response(); |
| | | if(StringUtils.isEmpty(powerInf.getStationId())){ |
| | | //校验机房站点是否存在,存在则不需要新建StationId |
| | | Battinf battinf = battInfService.judgeBattStationName3(powerInf); |
| | | if (battinf!=null) { |
| | | powerInf.setStationId(battinf.getStationId()); |
| | | }else { |
| | | //站点不存在,需要新建站点记录 |
| | | String nextStationId = battInfService.getNextStationId(); |
| | | StationInf station = new StationInf(); |
| | | station.setStationId(nextStationId); |
| | | station.setStationName(powerInf.getStationName()); |
| | | station.setStationName1(powerInf.getStationName1()); |
| | | station.setStationName2(powerInf.getStationName2()); |
| | | station.setStationName3(powerInf.getStationName3()); |
| | | station.setStationName5(powerInf.getStationName5()); |
| | | stationInfService.insertStation(station); |
| | | //powerInf.setStationId(String.valueOf(battInfService.searchMaxId_zj())); |
| | | powerInf.setStationId(nextStationId); |
| | | } |
| | | } |
| | | int devId = battInfService.getPowerDeviceId(powerInf.getPowerDeviceType()); |
| | | powerInf.setPowerDeviceId(devId); |
| | | if (service.add(powerInf)>0){ |
| | | //添加机房站点到用户对应的包机组 |
| | | battInfService.insertUserBattgroupBaojigroupBattgroupSelect(powerInf.getStationId(),0,userId); |
| | | //添加电源站点时,更新ReInit字段为1,通讯程序监控变化重新初始化 |
| | | if(powerInf.getPowerDeviceType()==BattinfGroupFactory.DEVICE_POWER) { |
| | | boolean flag = powerAppSysService.updateFlag("AppServer_Reinit_PowerData_EN"); |
| | | if (!flag) { |
| | | System.out.println("更新updateReInit接口失败"); |
| | | } |
| | | }else{ |
| | | //充电机和绝缘装置的,更新另一个ReInit字段为1 |
| | | boolean flag = powerAppSysService.updateFlag("AppServer_Reinit_BattGroupData_EN"); |
| | | if (!flag) { |
| | | System.out.println("更新updateReInit接口失败"); |
| | | } |
| | | } |
| | | res.set(1,true,"添加成功"); |
| | | }else{ |
| | | res.set(1,false,"添加失败"); |
| | | } |
| | | |
| | | return res; |
| | | } |
| | | @PutMapping |
| | | @PostMapping("update") |
| | | @ApiOperation(value = "更新电源") |
| | | public Response update(@RequestBody PowerInf powerInf){ |
| | | service.updateByPowerDeviceId(powerInf); |
| | | return new Response().setII(1,"更新成功"); |
| | | return new Response().set(1,true,"更新成功"); |
| | | } |
| | | @DeleteMapping |
| | | @PostMapping("delete") |
| | | @ApiOperation(value = "删除电源") |
| | | public Response delete(@RequestParam Integer powerDeviceId){ |
| | | service.deleteByPowerDeviceId(powerDeviceId); |
| | | return new Response().setII(1,"删除成功"); |
| | | return new Response().set(1,true,"删除成功"); |
| | | } |
| | | |
| | | @GetMapping("updateSwtichNum") |
| | | @ApiOperation(value = "更新开关路数") |
| | | public Response updateSwtichNum(@RequestParam int swtichNum,@RequestParam int powerId){ |
| | | service.updateSwtichNum(swtichNum,powerId); |
| | | return new Response().set(1,true,"更新成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/getProvincesContainBatt") |
| | | @ApiOperation(value = "获取包含电池的省份") |
| | | @GetMapping("getProvincesContainBatt") |
| | | @ApiOperation(value = "获取所有省份") |
| | | public Response getProvincesContainBatt(){ |
| | | return service.getProvincesContainBatt(); |
| | | } |
| | | |
| | | @GetMapping("/getCitiesContainBatt") |
| | | @ApiOperation(value = "获取某省下的城市") |
| | | @GetMapping("getCitiesContainBatt") |
| | | @ApiOperation(value = "获取所有城市") |
| | | public Response getCitiesContainBatt(@RequestParam String stationName1){ |
| | | return service.getCitiesContainBatt(stationName1); |
| | | } |
| | | |
| | | @GetMapping("/getDistrictsContainBatt") |
| | | @ApiOperation(value = "获取某省某城市下的地区") |
| | | @GetMapping("getDistrictsContainBatt") |
| | | @ApiOperation(value = "获取所有地区") |
| | | public Response getDistrictsContainBatt(@RequestParam String stationName1,@RequestParam String stationName2){ |
| | | return service.getDistrictsContainBatt(stationName1,stationName2); |
| | | } |
| | | |
| | | @GetMapping("/getProvinces") |
| | | @GetMapping("getProvinces") |
| | | @ApiOperation(value = "用户管理的机房省份") |
| | | public Response getProvinces(){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.getProvinces(userInf.getUId()); |
| | | } |
| | | @GetMapping("/getCities") |
| | | @GetMapping("getCities") |
| | | @ApiOperation(value = "用户管理的省份的城市") |
| | | public Response getCities(@RequestParam(required = false) String stationName1){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.getCities(userInf.getUId(),stationName1); |
| | | } |
| | | @GetMapping("/getDistricts") |
| | | @GetMapping("getDistricts") |
| | | @ApiOperation(value = "用户管理的地区") |
| | | public Response getDistricts(@RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getExistStations") |
| | | @ApiOperation(value = "获取机房") |
| | | @GetMapping("getExistStations") |
| | | @ApiOperation(value = "获取所有机房") |
| | | public Response getExistStations( @RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2,@RequestParam(required = false) String stationName5){ |
| | | return service.getExistStations(stationName1,stationName2,stationName5); |
| | | } |
| | | |
| | | @GetMapping("/getPowerDevicesPage") |
| | | @ApiOperation(value = "用户管理的电源信息分页") |
| | | public PageInfo<PowerInf> getPowerDevicesPage(@RequestParam(required = false) String stationId, @RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2,@RequestParam(required = false) String stationName5){ |
| | | @GetMapping("getStations") |
| | | @ApiOperation(value = "获取用户管理的机房") |
| | | public Response getStations(@RequestParam(required = false) String stationName5){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | PageInfo<PowerInf> list = service.getPowerDevicesPage(userInf.getUId(),stationId, stationName1,stationName2,stationName5); |
| | | return list; |
| | | return service.getStations(userInf.getUId(),stationName5); |
| | | } |
| | | |
| | | @PostMapping("getPowerDevicesPage") |
| | | @ApiOperation(value = "用户管理的电源信息分页") |
| | | public Response getPowerDevicesPage(@RequestParam int pageNum, @RequestParam int pageSize |
| | | , @RequestBody PowerInfPar powerInfPar) { |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.getPowerDevicesPage(pageNum, pageSize, userInf.getUId(), powerInfPar); |
| | | } |
| | | |
| | | |
| | | @GetMapping("getPowerDevices") |
| | | @ApiOperation(value = "用户管理的电源信息") |
| | | public Response getPowerDevices(@RequestParam String stationId){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.getPowerDevices(stationId); |
| | | } |
| | | |
| | | @GetMapping("getInfoById") |
| | | @ApiOperation(tags = "在线监测-实时监控",value = "在线监测-实时监控-查询某个电源的详细信息") |
| | | public Response getInfoById(@RequestParam int powerDeviceId){ |
| | | return service.getInfoById(powerDeviceId); |
| | | } |
| | | |
| | | /*@GetMapping("getPowerInfoById") |
| | | @ApiOperation(tags = "在线监测-实时监控",value = "在线监测-实时监控-获取配电柜的实时数据") |
| | | public Response getPowerInfoById(@RequestParam int powerDeviceId){ |
| | | return service.getPowerInfoById(powerDeviceId); |
| | | }*/ |
| | | |
| | | @ApiOperation(value = "填写异常原因",notes = "传入字段 num,exceptionCause,exceptionCauseAnalysis") |
| | | @PostMapping("exceptionCause") |
| | | public Response updateExceptionCause(@RequestBody PowerInf powerInf){ |
| | | return service.updateExceptionCause(powerInf); |
| | | } |
| | | |
| | | @ApiOperation(value = "取消异常原因", notes = "传入字段 num") |
| | | @PostMapping("cancelExceptionCause") |
| | | public Response updateCancelExceptionCause(@RequestParam int num) { |
| | | return service.updateCancelExceptionCause(num); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询异常原因", notes = "传入字段 num") |
| | | @GetMapping("exceptionCause") |
| | | public Response getExceptionCause(@RequestParam int num) { |
| | | return service.getExceptionCause(num); |
| | | } |
| | | |
| | | |
| | | @GetMapping("getPwrInf") |
| | | @ApiOperation(value = "获取用户管理的机房") |
| | | public Response getPwrInf() { |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.getPwrInf(userInf.getUId()); |
| | | } |
| | | |
| | | @GetMapping("getPwrProducer") |
| | | @ApiOperation(value = "获取所有的电源品牌") |
| | | public Response getPwrProducer() { |
| | | return service.getPwrProducer(); |
| | | } |
| | | |
| | | @GetMapping("modelList") |
| | | @ApiOperation(value = "获取所有的型号") |
| | | public Response getModelList() { |
| | | return service.getModelList(); |
| | | } |
| | | |
| | | @PostMapping("getModelListByPwrProducer") |
| | | @ApiOperation(value = "根据品牌查询型号") |
| | | public Response getModelListByPwrProducer(@RequestBody List<String> producer) { |
| | | return service.getModelListByPwrProducer(producer); |
| | | } |
| | | |
| | | } |