13693261870
2025-07-02 6708810c4de34dfb9513061432d656f91d56ee3a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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;
 
/**
 * <p>
 * 泊位 前端控制器
 * </p>
 *
 * @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<DmBerth> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DmBerth::getHarborId,whId);
        return AjaxResult.success(dpBerthService.list(queryWrapper));
    }
 
    @GetMapping("/getBerthList")
    @Operation(summary = "获取泊位详情列表")
    public AjaxResult getBerthList(Integer whId){
        LambdaQueryWrapper<DmBerth> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DmBerth::getHarborId,whId);
        List<DmBerth> dpBerthList = dpBerthService.list(queryWrapper);
        List<DmBerth> berthList = new ArrayList<>();
        for (DmBerth dmBerth : dpBerthList){
//            List<DpShipParking> parkingList = dpShipParkingService.getByWhBeId(whId,dmBerth.getPkid().intValue(),dmBerth.getShipsNum());
            List<DpShips> 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<DmBerth> 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<DmBerth> 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<DmBerth> 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));
    }
 
 
 
}