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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package com.ruoyi.web.controller.manage;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.buss.common.RfidUtil;
import com.ruoyi.buss.domain.vo.RfIdVo;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.manage.domain.*;
import com.ruoyi.manage.service.DpBerthService;
import com.ruoyi.manage.service.DpShipTypeService;
import com.ruoyi.manage.service.DpShipsService;
import com.ruoyi.manage.service.DsTaskListService;
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 sunjiawei
 * @since 2025-03-24
 */
@RestController
@RequestMapping("/dp/dsTaskList")
@Tag(name = "大屏--任务分配详情")
public class DsTaskListController {
    @Autowired
    private DsTaskListService dsTaskListService;
    @Autowired
    private DpShipsService dpShipsService;
    @Autowired
    private DpShipTypeService dpShipTypeService;
    @Autowired
    private DpBerthService dpBerthService;
    @Autowired
    private RuoYiConfig ruoYiConfig;
 
 
    @GetMapping("/list")
    @Operation(summary = "任务分配详情列表")
    public AjaxResult getList(){
        return AjaxResult.success(dsTaskListService.list());
    }
 
 
 
    @GetMapping("/pageList")
    @Operation(summary = "任务分配详情分页列表")
    public TableDataInfo getPageList(DsTaskList dsTaskList) {
        return dsTaskListService.getPageList(dsTaskList);
    }
 
    @GetMapping("/pageListDaily")
    @Operation(summary = "日常任务分配详情分页列表")
    public TableDataInfo pageListDaily(DsTaskList dsTaskList) {
        return dsTaskListService.getPageListDaily(dsTaskList);
    }
 
 
    @GetMapping(value = "/{id}")
    @Operation(summary = "获取任务分配详情详细信息")
    public AjaxResult getInfo(@PathVariable("id") Integer pkid)
    {
        return AjaxResult.success(dsTaskListService.getById(pkid));
    }
 
 
    @Operation(summary = "群组新增")
    @PostMapping
    public AjaxResult add(@RequestBody DsTaskList dsTaskList)
    {
        return AjaxResult.success(dsTaskListService.save(dsTaskList));
    }
 
    @Operation(summary = "日常新增")
    @PostMapping(value = "/dailyAdd")
    public AjaxResult dailyAdd(@RequestBody DsTaskList dsTaskList,
                               @RequestParam(value = "lon") Double lon,
                               @RequestParam(value = "lat") Double lat,
                               @RequestParam(value = "alt") Double alt,
                               @RequestParam(value = "heading") Double heading)
    {
        String shipType = dsTaskList.getShipType();
        LambdaQueryWrapper<DpShipType> shipTypeWrapper = new LambdaQueryWrapper<>();
        shipTypeWrapper.eq(DpShipType::getShipDesign,shipType);
        DpShipType dpShipType = dpShipTypeService.getOne(shipTypeWrapper);
        Integer shipTypeId = dpShipType.getId();
        Integer whId = dsTaskList.getHarborId().intValue();
        Integer beId = dsTaskList.getBerthId().intValue();
        String shipId = dsTaskList.getShipNo();
 
        DpShips dpShip = new DpShips();
        dpShip.setShipTypeId(shipTypeId);
        dpShip.setWhId(whId);
        dpShip.setBeId(beId);
        dpShip.setShipId(shipId);
        dpShip.setShipName(shipId);
        dpShip.setLon(lon);
        dpShip.setLat(lat);
        dpShip.setAlt(alt);
        dpShip.setHeading(heading);
 
        DmBerth dmBerth =dpBerthService.getById(beId);
        String path = dmBerth.getPath();
 
        boolean taskListRes = dsTaskListService.save(dsTaskList);
        if(taskListRes){
            List<RfIdVo> list = new ArrayList<>();
            RfIdVo rfIdVo = new RfIdVo();
            rfIdVo.setId((999+Integer.parseInt(shipId)));
            rfIdVo.setName(String.valueOf(999+Integer.parseInt(shipId)));
            rfIdVo.setPath(path);
            list.add(rfIdVo);
            RfidUtil.sendJsonPost(ruoYiConfig.getBussRfidUrl(),list.toString());
        }
        boolean shipRes = dpShipsService.save(dpShip);
        if(taskListRes && shipRes){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
 
    }
 
 
    @Operation(summary = "修改")
    @PutMapping
    public AjaxResult edit(@RequestBody DsTaskList dsTaskList)
    {
        return AjaxResult.success(dsTaskListService.updateById(dsTaskList));
    }
 
 
    @Operation(summary = "删除")
    @DeleteMapping("/{pkid}")
    public AjaxResult remove(@PathVariable Integer pkid)
    {
        return AjaxResult.success(dsTaskListService.removeById(pkid));
    }
 
    @Operation(summary = "日常任务删除")
    @DeleteMapping("/deleteDaily/{pkid}")
    public AjaxResult deleteDaily(@PathVariable Integer pkid)
    {
        DsTaskList dsTaskList = dsTaskListService.getById(pkid);
        LambdaQueryWrapper<DpShips> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(DpShips::getShipId,dsTaskList.getShipNo());
        boolean shipRes = dpShipsService.remove(lambdaQueryWrapper);
        boolean taskRes = dsTaskListService.removeById(pkid);
        if(shipRes && taskRes){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
 
    }
 
    @GetMapping(value = "/getByBeId")
    @Operation(summary = "根据泊位ID获取任务分配详情")
    public R<DsTaskList> getByBeId(@RequestParam("beId") Integer beId)
    {
        LambdaQueryWrapper<DsTaskList> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(DsTaskList::getBerthId,beId)
                .eq(DsTaskList::getTaskId,999)
                .orderByDesc(DsTaskList::getCreateTime)
                .last("LIMIT 1");
        return R.ok(dsTaskListService.getOne(lambdaQueryWrapper));
    }
 
}