whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/controller/CircleInfController.java
@@ -15,6 +15,8 @@
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@RestController
@RequestMapping("circle")
@Api(tags = "动环管理")
@@ -32,16 +34,16 @@
    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();
@@ -63,6 +65,7 @@
        if(circleInf.getSubList()!=null){
            circleInf.setSubCount(circleInf.getSubList().size());
        }
        circleInf.setCircleInuseDate(new Date());
        if (service.add(circleInf)>0){
            //添加机房站点到用户对应的包机组
            binfService.insertUserBattgroupBaojigroupBattgroupSelect(circleInf.getStationId(),0,userId);
@@ -91,17 +94,63 @@
        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,"添加成功");
    }
}