| | |
| | | import com.whyc.service.BattInfService; |
| | | import com.whyc.service.CircleInfService; |
| | | import com.whyc.service.StationInfService; |
| | | import com.whyc.service.SubInfService; |
| | | import com.whyc.util.ActionUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @RestController |
| | | @RequestMapping("circle") |
| | |
| | | @Autowired |
| | | private BattInfService binfService; |
| | | |
| | | @Autowired |
| | | private SubInfService subService; |
| | | |
| | | @PostMapping("add") |
| | | |
| | | @PostMapping("addCinf") |
| | | @ApiOperation(value = "添加动环") |
| | | @Transactional |
| | | public Response add(@RequestBody CircleInf circleInf){ |
| | | public Response addCinf(@RequestBody CircleInf circleInf){ |
| | | int userId = ActionUtil.getUser().getUId().intValue(); |
| | | Response res = new Response(); |
| | | //校验机房站点是否存在,存在则不需要新建StationId |
| | | StationInf sinf = sinfService.judgeStationName(circleInf.getStationName()); |
| | | if (sinf!=null) { |
| | | circleInf.setStationId(sinf.getStationId()); |
| | | Battinf binf = service.judgeBattStationName3(circleInf); |
| | | if (binf!=null) { |
| | | circleInf.setStationId(binf.getStationId()); |
| | | }else { |
| | | //站点不存在,需要新建站点记录 |
| | | String nextStationId = binfService.getNextStationId(); |
| | |
| | | //获取动环的设备id |
| | | String devId = service.getDeviceId(); |
| | | circleInf.setDeviceId(devId); |
| | | //存入自建数量 |
| | | if(circleInf.getSubList()!=null){ |
| | | circleInf.setSubCount(circleInf.getSubList().size()); |
| | | } |
| | | circleInf.setCircleInuseDate(new Date()); |
| | | if (service.add(circleInf)>0){ |
| | | //添加机房站点到用户对应的包机组 |
| | | binfService.insertUserBattgroupBaojigroupBattgroupSelect(circleInf.getStationId(),0,userId); |
| | | //添加子件信息 |
| | | if(circleInf.getSubList()!=null&&circleInf.getSubList().size()>0){ |
| | | subService.addSubList(devId,circleInf.getSubList()); |
| | | } |
| | | |
| | | //添加电源站点时,更新ReInit字段为1,通讯程序监控变化重新初始化 |
| | | /*if(powerInf.getPowerDeviceType()== BattinfGroupFactory.DEVICE_POWER) { |
| | | boolean flag = powerAppSysService.updateFlag("AppServer_Reinit_PowerData_EN"); |
| | |
| | | |
| | | return res; |
| | | } |
| | | @PostMapping("update") |
| | | |
| | | @PostMapping("updateCinf") |
| | | @ApiOperation(value = "更新电源") |
| | | public Response updateByDeviceId(@RequestBody CircleInf circleInf){ |
| | | public Response updateCinf(@RequestBody CircleInf circleInf){ |
| | | service.updateByDeviceId(circleInf); |
| | | return new Response().set(1,true,"更新成功"); |
| | | } |
| | | @PostMapping("delete") |
| | | |
| | | @GetMapping("deleteCinf") |
| | | @ApiOperation(value = "删除电源") |
| | | public Response deleteByDeviceId(@RequestParam Integer deviceId){ |
| | | public Response deleteCinf(@RequestParam Integer deviceId){ |
| | | service.deleteByDeviceId(deviceId); |
| | | return new Response().set(1,true,"删除成功"); |
| | | } |
| | | |
| | | @PostMapping("getCinf") |
| | | @ApiOperation(value = "获取动环信息") |
| | | public Response getCinf(@RequestBody CircleInf cinf,@RequestParam int pageCurr,@RequestParam int pageSize){ |
| | | return service.getCinf(cinf,pageCurr,pageSize); |
| | | } |
| | | |
| | | @PostMapping("getConditionCid") |
| | | @ApiOperation(value = "获取动环下拉资产信息") |
| | | public Response getConditionCid(){ |
| | | return service.getConditionCid(); |
| | | } |
| | | |
| | | @GetMapping("getCinfById") |
| | | @ApiOperation(value = "根据id获取动环信息") |
| | | public Response getCinfById(@RequestParam int deviceId){ |
| | | return service.getCinfById(deviceId); |
| | | } |
| | | |
| | | @PostMapping("getSub") |
| | | @ApiOperation(value = "获取子件信息") |
| | | public Response getSub(@RequestBody SubInf sub,@RequestParam int pageCurr,@RequestParam int pageSize){ |
| | | return subService.getSub(sub,pageCurr,pageSize); |
| | | } |
| | | |
| | | @PostMapping("updateSub") |
| | | @ApiOperation(value = "更新子件") |
| | | public Response updateSub(@RequestBody SubInf sub){ |
| | | subService.updateSub(sub); |
| | | return new Response().set(1,true,"更新成功"); |
| | | } |
| | | |
| | | @GetMapping("deleteSub") |
| | | @ApiOperation(value = "删除子件") |
| | | public Response deleteSub(@RequestParam Integer subId){ |
| | | subService.deleteSub(subId); |
| | | return new Response().set(1,true,"删除成功"); |
| | | } |
| | | @PostMapping("addSub") |
| | | @ApiOperation(value = "添加子件") |
| | | public Response addSub(@RequestBody SubInf sub){ |
| | | subService.addSub(sub); |
| | | return new Response().set(1,true,"添加成功"); |
| | | } |
| | | |
| | | } |