package com.ruoyi.web.controller.manage; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.manage.domain.DmBerth; import com.ruoyi.manage.domain.DpShips; import com.ruoyi.manage.domain.DmHarbor; import com.ruoyi.manage.service.DpBerthService; import com.ruoyi.manage.service.DpShipParkingService; import com.ruoyi.manage.service.DpShipsService; import com.ruoyi.manage.service.IDmHarborService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; /** *

* 泊位 前端控制器 *

* * @author zhangyy * @since 2025-03-11 */ @RestController @RequestMapping("/dp/dpBerth") @Tag(name = "大屏--泊位管理") public class DpBerthController extends BaseController { @Autowired private DpBerthService dpBerthService; @Autowired private DpShipParkingService dpShipParkingService; @Autowired private DpShipsService dpShipsService; @Autowired private IDmHarborService dmHarborService; @GetMapping("/list") @Operation(summary = "获取泊位列表") public AjaxResult getList(Integer whId){ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(DmBerth::getHarborId,whId); return AjaxResult.success(dpBerthService.list(queryWrapper)); } @GetMapping("/getBerthList") @Operation(summary = "获取泊位详情列表") public AjaxResult getBerthList(Integer whId){ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(DmBerth::getHarborId,whId); List dpBerthList = dpBerthService.list(queryWrapper); List berthList = new ArrayList<>(); for (DmBerth dmBerth : dpBerthList){ // List parkingList = dpShipParkingService.getByWhBeId(whId,dmBerth.getPkid().intValue(),dmBerth.getShipsNum()); List shipsList = dpShipsService.getByWhIdBeId(whId,dmBerth.getPkid().intValue()); DmHarbor dmHarbor = dmHarborService.selectDmHarborByPkId(whId.longValue()); dmBerth.setHarborName(dmHarbor.getHarborName()); dmBerth.setShipsParking(shipsList); berthList.add(dmBerth); } return AjaxResult.success(berthList); } @GetMapping("/pageList") @Operation(summary = "泊位分页列表") public TableDataInfo getPageList(DmBerth dpBerth) { return dpBerthService.getPageList(dpBerth); } @GetMapping("/exitName") @Operation(summary = "验证泊位名称是否存在") public Boolean exitName(@RequestParam Integer whId,@RequestParam String name) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("HARBOR_ID",whId) .eq("NAME",name); return dpBerthService.exists(queryWrapper); } /** * 获取码头-泊位详细信息 */ @GetMapping(value = "/{beId}") @Operation(summary = "获取泊位详细信息") public AjaxResult getInfo(@PathVariable("beId") Long beId) { return success(dpBerthService.getById(beId)); } /** * 新增码头-泊位 */ @Operation(summary = "新增") @PostMapping public AjaxResult add(@RequestBody DmBerth dpBerth) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("HARBOR_ID",dpBerth.getHarborId()) .eq("NAME",dpBerth.getName()); if(!dpBerthService.exists(queryWrapper)){ return toAjax(dpBerthService.save(dpBerth)); }else { return AjaxResult.error("泊位名称已存在"); } } /** * 修改码头-泊位 */ @Operation(summary = "修改") @PutMapping public AjaxResult edit(@RequestBody DmBerth dpBerth) { return toAjax(dpBerthService.updateById(dpBerth)); // QueryWrapper queryWrapper = new QueryWrapper<>(); // queryWrapper.eq("HARBOR_ID",dpBerth.getHarborId()) // .eq("NAME",dpBerth.getName()); // if(!dpBerthService.exists(queryWrapper)){ // return toAjax(dpBerthService.updateById(dpBerth)); // }else { // return AjaxResult.error("泊位名称已存在"); // } } /** * 删除码头-泊位 */ @Operation(summary = "删除") @DeleteMapping("/{beId}") public AjaxResult remove(@PathVariable Integer beId) { return toAjax(dpBerthService.removeById(beId)); } }