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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package com.ruoyi.buss.controller;
 
import com.ruoyi.buss.domain.DmHarbor2;
import com.ruoyi.buss.domain.DsMatDispatch2;
import com.ruoyi.buss.service.IDmHarbor2Service;
import com.ruoyi.buss.service.IDsMatDispatch2Service;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
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.Date;
import java.util.List;
 
@Tag(name = "跨港区调度接口")
@RestController
@RequestMapping("/buss/matdispatch")
public class DsMatDispatch2Controller extends BaseController {
 
    private static String STATUS_1 = "1";   // 未提交
    private static String STATUS_2 = "2";   // 审批中
    private static String STATUS_3 = "3";   // 审批通过
    private static String STATUS_4 = "4";   // 驳回
 
 
    @Autowired
    private IDmHarbor2Service iDmHarbor2Service;
 
    @Autowired
    private IDsMatDispatch2Service iDsMatDispatch2Service;
 
    @Operation(summary = "获取任务列表")
    @PostMapping("/list/all")
    @ResponseBody
    public AjaxResult list() {
        List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchForApply();
        if(null != list){
            return success(list);
        }
        return error("获取任务列表失败,请重试");
    }
 
    @Operation(summary = "根据条件获取任务列表")
    @PostMapping("/list/param")
    @ResponseBody
    public AjaxResult list(DsMatDispatch2 dsMatDispatch2) {
        List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchList(dsMatDispatch2);
        if(null != list){
            return success(list);
        }
        return error("获取任务列表失败,请重试");
    }
 
    @Operation(summary = "获取自己权限内的任务列表")
    @PostMapping("/list/self")
    @ResponseBody
    public AjaxResult list3(@RequestParam(value = "status", required = false) String status) {
        List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchByDeptId(getDeptId(), status);
        if(null != list){
            return success(list);
        }
        return error("获取任务列表失败,请重试");
    }
 
    @Operation(summary = "获取任务列表")
    @PostMapping("/list")
    @ResponseBody
    public AjaxResult list2(@RequestParam(value = "status", required = false) String status) {
        LoginUser loginUser = getLoginUser();
        DsMatDispatch2 dsMatDispatch2 = new DsMatDispatch2();
        dsMatDispatch2.setResHarborId(loginUser.getDeptId().toString());
        if(StringUtils.isNotBlank(status)){
            dsMatDispatch2.setStatus(status);
        }
        List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchList(dsMatDispatch2);
        if(null != list){
            return success(list);
        }
        return error("获取任务列表失败,请重试");
    }
 
    @Operation(summary = "获取自己新建的任务列表")
    @PostMapping("/list2")
    @ResponseBody
    public AjaxResult list2() {
        LoginUser loginUser = getLoginUser();
        DsMatDispatch2 dsMatDispatch2 = new DsMatDispatch2();
        dsMatDispatch2.setResHarborId(loginUser.getDeptId().toString());
        dsMatDispatch2.setResHarborName(loginUser.getUsername());
        List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchList(new DsMatDispatch2());
        if(null != list){
            return success(list);
        }
        return error("获取任务列表失败,请重试");
    }
 
    @Operation(summary = "任务提交审批")
    @PostMapping("/apply/{id}")
    @ResponseBody
    public AjaxResult toApply(@PathVariable("id") Long id) {
        DsMatDispatch2 matDispatch2 = iDsMatDispatch2Service.selectDsMatDispatchById(id);
        if(null != matDispatch2){
            if(matDispatch2.getStatus().equals(STATUS_1)){
                matDispatch2.setStatus(STATUS_2);
                matDispatch2.setUpdateBy(getUsername());
                matDispatch2.setUpdateTime(new Date());
                int rst = iDsMatDispatch2Service.updateDsMatDispatch(matDispatch2);
                if(rst > 0){
                    return success("提交审批成功");
                }
                else {
                    return error("提交审批失败");
                }
            }
            else {
                return error("当前任务不可提交审批");
            }
        }
        else{
            return error("获取任务失败,请重试");
        }
    }
 
    @Operation(summary = "任务审批")
    @PostMapping("/prove")
    @ResponseBody
    public AjaxResult prove(@RequestBody DsMatDispatch2 dsMatDispatch2) {
        if(null != dsMatDispatch2 && null != dsMatDispatch2.getId()){
            DsMatDispatch2 matDispatch2 = iDsMatDispatch2Service.selectDsMatDispatchById(dsMatDispatch2.getId());
            DmHarbor2 harborRes = null;
            List<DmHarbor2> harbor2List = iDmHarbor2Service.selectDmHarborList(new DmHarbor2());
            for(DmHarbor2 harbor2 : harbor2List){
                if(StringUtils.isNotBlank(dsMatDispatch2.getDesHarborId()) && harbor2.getPKID().toString().equals(dsMatDispatch2.getDesHarborId())){
                    harborRes = harbor2;
                }
            }
            if(null != matDispatch2){
                if(matDispatch2.getStatus().equals(STATUS_2)){
                    if(dsMatDispatch2.getApplyResult().equals("1")){
                        matDispatch2.setStatus(STATUS_3);
                    }
                    else{
                        matDispatch2.setStatus(STATUS_4);
                    }
 
                    matDispatch2.setApplyResult(dsMatDispatch2.getApplyResult());
                    matDispatch2.setApplyTime(new Date());
                    matDispatch2.setApplyContent(dsMatDispatch2.getApplyContent());
                    matDispatch2.setApplyBy(getUsername());
                    matDispatch2.setUpdateBy(getUsername());
                    matDispatch2.setUpdateTime(new Date());
                    if(null != harborRes){
                        matDispatch2.setResHarborId(harborRes.getDeptId().toString());
                        matDispatch2.setResHarborName(harborRes.getDeptName());
                    }
                    int rst = iDsMatDispatch2Service.updateDsMatDispatch(matDispatch2);
                    if(rst > 0){
                        return success("审批成功");
                    }
                    else {
                        return error("审批失败");
                    }
                }
                else {
                    return error("当前任务不可审批");
                }
            }
            else{
                return error("获取任务失败,请重试");
            }
        }
        return error("参数失败,需要");
    }
 
    /**
     * 新增保存泊位信息
     */
    @Operation(summary="新增跨港区调度信息")
    @Log(title = "跨港区调度信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody DsMatDispatch2 dsMatDispatch2) {
        if(null == dsMatDispatch2){
            return error("参数不能为空");
        }
        if(StringUtils.isBlank(dsMatDispatch2.getContent())){
            return error("调度内容不能为空");
        }
        LoginUser loginUser = getLoginUser();
        dsMatDispatch2.setResHarborId(loginUser.getDeptId().toString());
        dsMatDispatch2.setResHarborName(loginUser.getUsername());
        dsMatDispatch2.setCreateTime(new Date());
        dsMatDispatch2.setCreateBy(getUsername());
        dsMatDispatch2.setStatus(STATUS_1);
        return toAjax(iDsMatDispatch2Service.insertDsMatDispatch(dsMatDispatch2));
    }
 
    /**
     * 修改保存泊位信息
     */
    @Operation(summary="修改保存跨港区调度信息")
    @Log(title = "跨港区调度信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DsMatDispatch2 dsMatDispatch2)
    {
        return toAjax(iDsMatDispatch2Service.updateDsMatDispatch(dsMatDispatch2));
    }
 
    /**
     * 删除泊位信息
     */
    @Operation(summary="删除跨港区调度信息")
    @Log(title = "泊位信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove/{id}")
    @ResponseBody
    public AjaxResult remove(@PathVariable("id") Long id)
    {
        return toAjax(iDsMatDispatch2Service.deleteDsMatDispatchById(id));
    }
 
}