Blame view

src/main/java/com/huaheng/pc/task/taskHeader/controller/TaskHeaderController.java 13.4 KB
mahuandong authored
1
2
3
package com.huaheng.pc.task.taskHeader.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
mahuandong authored
5
import com.baomidou.mybatisplus.core.metadata.IPage;
周鸿 authored
6
import com.huaheng.common.utils.Wrappers;
mahuandong authored
7
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8
9
import com.huaheng.api.wcs.service.taskCancel.TaskCancelService;
import com.huaheng.common.constant.QuantityConstant;
10
import com.huaheng.common.exception.service.ServiceException;
mahuandong authored
11
12
13
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
14
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
mahuandong authored
15
16
17
18
19
20
21
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
22
23
24
import com.huaheng.framework.web.service.ConfigService;
import com.huaheng.pc.config.configValue.domain.ConfigValue;
import com.huaheng.pc.config.configValue.service.ConfigValueService;
25
26
27
28
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.containerType.domain.ContainerType;
import com.huaheng.pc.config.containerType.service.ContainerTypeService;
29
import com.huaheng.pc.config.location.domain.Location;
mahuandong authored
30
31
32
33
34
35
36
37
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.mapper.TaskHeaderMapper;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
38
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;
39
import io.swagger.annotations.ApiOperation;
mahuandong authored
40
41
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
42
import org.apache.shiro.session.Session;
mahuandong authored
43
import org.springframework.stereotype.Controller;
44
import org.springframework.ui.Model;
mahuandong authored
45
46
47
48
49
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
50
51
import java.util.AbstractList;
import java.util.ArrayList;
52
import java.util.Collections;
mahuandong authored
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.List;


@Controller
@RequestMapping("/task/taskHeader")


public class TaskHeaderController extends BaseController {


    @Resource
    private TaskHeaderService taskHeaderService;
65
66
    @Resource
    private WorkTaskService workTaskService;
67
68
69
70
    @Resource
    private TaskCancelService taskCancelService;
    @Resource
    private ConfigService configService;
71
72
73
74
75
    @Resource
    private ContainerService containerService;
    @Resource
    private ContainerTypeService containerTypeService;
mahuandong authored
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

    private String prefix = "task/taskHeader";

    @RequiresPermissions("task:taskHeader:view")
    @GetMapping()
    public String taskHeader(HttpServletRequest request, ModelMap mmap) {
        String InternalTaskType= request.getParameter("InternalTaskType");
        mmap.put("InternalTaskType",InternalTaskType);
        return prefix + "/taskHeader";
    }

    /**
     * 查询任务列表
     */
    @RequiresPermissions("task:taskHeader:list")
    @Log(title = "任务-上架任务", operating = "查看任务列表", action = BusinessType.GRANT)
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TaskHeader taskHeader,@ApiParam(name="InternalTaskType",value="类型") Integer InternalTaskType,
95
                              @ApiParam(name="createdBegin",value="类型") String createdBegin,@ApiParam(name="createdEnd",value="类型") String createdEnd) {
mahuandong authored
96
97
        LambdaQueryWrapper<TaskHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(TaskHeader::getWarehouseCode,ShiroUtils.getWarehouseCode())
98
99
100
101
102
103
104
105
106
107
                .eq(StringUtils.isNotNull(InternalTaskType),TaskHeader::getInternalTaskType,InternalTaskType)
                .eq(StringUtils.isNotNull(taskHeader.getId()),TaskHeader::getId,taskHeader.getId())
                .eq(StringUtils.isNotEmpty(taskHeader.getContainerCode()),TaskHeader::getContainerCode,taskHeader.getContainerCode())
                .eq(StringUtils.isNotEmpty(taskHeader.getToLocation()),TaskHeader::getToLocation,taskHeader.getToLocation())
                .eq(StringUtils.isNotEmpty(taskHeader.getZoneCode()),TaskHeader::getZoneCode,taskHeader.getZoneCode())
                .eq(StringUtils.isNotNull(taskHeader.getPriority()),TaskHeader::getPriority,taskHeader.getPriority())
                .gt(StringUtils.isNotEmpty(createdBegin),TaskHeader::getCreated,createdBegin)
                .lt(StringUtils.isNotEmpty(createdEnd),TaskHeader::getCreated,createdEnd)
                .orderByAsc(TaskHeader::getStatus)
                .orderByDesc(TaskHeader::getId);
mahuandong authored
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

        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        /**
         * 使用分页查询
         */
        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){
            Page<TaskHeader> page = new Page<>(pageNum, pageSize);
            IPage<TaskHeader> iPage = taskHeaderService.page(page, lambdaQueryWrapper);
            List<TaskHeader> iPages = iPage.getRecords();
            return getMpDataTable(iPages, iPage.getTotal());
        } else {
            List<TaskHeader> list = taskHeaderService.list(lambdaQueryWrapper);
            return getDataTable(list);
        }
    }

    /**
     * 下发任务
     */
    @RequiresPermissions("task:taskHeader:execute")
    @Log(title = "任务-任务管理", operating = "下发立库任务", action = BusinessType.UPDATE)
    @PostMapping( "/execute")
    @ResponseBody
    public AjaxResult execute(String taskId)
    {
xqs authored
135
        if (StringUtils.isEmpty(taskId)){
mahuandong authored
136
            return AjaxResult.error("taskId不能为空");
xqs authored
137
        }
mahuandong authored
138
139
140
        AjaxResult ajaxResult = taskHeaderService.sendTaskToWcs(Convert.toIntArray(taskId));
        return ajaxResult;
    }
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
    /**
     * 修改最大优先级
     */
    @ApiOperation(value = "最大优先级", notes = "最大优先级", httpMethod = "POST")
    @PostMapping("/prioritymax")
    @ResponseBody
    public AjaxResult editBatchSave (String ids) {
        return toAjax(taskHeaderService.prioritymax(ids));
    }
    /**
     * 修改最小优先级
     */
    @ApiOperation(value = "最小优先级", notes = "最小优先级", httpMethod = "POST")
    @PostMapping("/prioritymin")
    @ResponseBody
    public AjaxResult prioritymin (String ids) {
        return  toAjax( taskHeaderService.prioritymin(ids));
    }


//    @ApiOperation(value = "最大优先级", notes = "最大优先级", httpMethod = "POST")
//    @PostMapping("/priorityedit")
//    @ResponseBody
//    public AjaxResult editBatchSave (String ids) {
//        System.out.println(taskHeaderService.editBatchSave(ids));
//        return toAjax(1);
//    }
//
//    @ApiOperation(value = "最小优先级", notes = "最小优先级", httpMethod = "POST")
//    @PostMapping("/upmin")
//    @ResponseBody
//    public AjaxResult upmin (String ids) {
//        System.out.println(taskHeaderService.editmin(ids));
//        return toAjax(1);
//    }
//
//    @ApiOperation(value = "单个优先级", notes = "单个优先级", httpMethod = "POST")
//    @PostMapping("/updateid")
//    @ResponseBody
//    public AjaxResult editBatchSave (String id, String priority) {
//        System.out.println("-------------------------------------------"+id);
//        System.out.println("-------------------------------------------"+priority);
//        System.out.println(taskHeaderService.editID(id,priority));
//        return toAjax(1);
//    }
mahuandong authored
187
188
189
190
191
192
193
194

    /**
     * 完成任务
     */
    @RequiresPermissions("task:taskHeader:complete")
    @Log(title = "任务-任务管理", operating = "PC完成立库任务", action = BusinessType.UPDATE)
    @PostMapping( "/completeTaskByWMS")
    @ResponseBody
195
    @ApiLogger(apiName = "wcs任务完成", from="PC")
mahuandong authored
196
    public AjaxResult completeTaskByWMS(String taskId){
xqs authored
197
        if (StringUtils.isEmpty(taskId)){
mahuandong authored
198
            return AjaxResult.error("taskId不能为空");
xqs authored
199
        }
mahuandong authored
200
201
202
203
204
205
206
207
208
209
210
211
        return taskHeaderService.completeTaskByWMS(Convert.toIntArray(taskId), null);
    }

    /**
     * 删除立库任务
     */
    @RequiresPermissions("task:taskHeader:remove")
    @Log(title = "任务-任务管理", operating = "删除立库任务", action = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
mahuandong authored
212
        if (StringUtils.isEmpty(ids)) {
mahuandong authored
213
            return AjaxResult.error("taskId不能为空");
mahuandong authored
214
        }
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
        Integer[] idList = Convert.toIntArray(ids);
        for (int id : idList) {
            TaskHeader taskHeader = taskHeaderService.getById(id);
            if(taskHeader.getStatus().intValue()  <= QuantityConstant.TASK_STATUS_BUILD) {
                continue;
            }
            String containerCode = taskHeader.getContainerCode();
            if (StringUtils.isEmpty(containerCode)) {
                return AjaxResult.error("空托盘");
            }
            Container container = containerService.getContainerByCode(
                        containerCode, taskHeader.getWarehouseCode());
            LambdaQueryWrapper<ContainerType> containerTypeLambdaQueryWrapper = Wrappers.lambdaQuery();
            containerTypeLambdaQueryWrapper.eq(ContainerType::getCode, container.getContainerType());
            ContainerType containerType = containerTypeService.getContainerTypeByCode(
                                    container.getContainerType(), container.getWarehouseCode());
            AjaxResult ajaxResult = taskCancelService.cancelTask(String.valueOf(id),
                    taskHeader.getWarehouseCode(), containerType.getArea());
            if (ajaxResult.hasErr()) {
                return ajaxResult;
235
236
237
            }
        }
238
mahuandong authored
239
        return taskHeaderService.cancelTask(Convert.toIntArray(ids));
mahuandong authored
240
241
    }
游杰 authored
242
243
244
245
246
247
248
249
250
251
    /**
     * 自动分配任务库位
     * WCS
     * @param taskId
     * @param high
     * @return
     */
    @PostMapping("/setLocationCode")
    @ResponseBody
    public AjaxResult setLocationCode( Integer taskId, Integer high){
xqs authored
252
        if (taskId == null){
游杰 authored
253
            return AjaxResult.error("任务id不能为空");
xqs authored
254
255
        }
        if (high == null){
游杰 authored
256
            return AjaxResult.error("高库位标识不能为空");
xqs authored
257
        }
游杰 authored
258
259
        return taskHeaderService.setLocationCode(taskId, high);
    }
mahuandong authored
260
261
262
263
    @Log(title = "库位监控-出库查看", operating = "出库查看", action = BusinessType.GRANT)
    @PostMapping("/checkLocationCode")
    @ResponseBody
游杰 authored
264
265
    public AjaxResult checkLocationCode (String locationCode) {
        if (StringUtils.isEmpty(locationCode)) {
266
267
            return AjaxResult.error("库位不能为空!");
        }
268
269
        List<String> list = new ArrayList<>();
        list.add(locationCode);
游杰 authored
270
        return workTaskService.createCheckOutTask(list, null);
271
272
    }
游杰 authored
273
    /**
游杰 authored
274
     * 选择出库口
游杰 authored
275
276
277
278
279
280
281
     */
    @GetMapping("/chooseStation/{taskId}")
    public String chooseStation(@PathVariable("taskId")String taskId, ModelMap mmap) {
        TaskHeader taskHeader = taskHeaderService.getById(taskId);
        String containerCode = taskHeader.getContainerCode();
        mmap.put("containerCode", containerCode);
        mmap.put("id", taskId);
282
283
        int taskType = taskHeader.getTaskType().intValue();
        if(taskType == QuantityConstant.TASK_TYPE_WHOLESHIPMENT ||
284
                taskType == QuantityConstant.TASK_TYPE_EMPTYSHIPMENT)  {
285
286
287
288
289
290
291
292
293
            mmap.put("type", QuantityConstant.STATION_OUT);
        } else if(taskType == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT ||
                taskType == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT ||
                taskType == QuantityConstant.TASK_TYPE_VIEW ||
                taskType == QuantityConstant.TASK_TYPE_CYCLECOUNT) {
            mmap.put("type", QuantityConstant.STATION_PICK);
        } else {
            throw new ServiceException("任务类型不需要选站台");
        }
游杰 authored
294
295
296
297
298
299
300
301
302
303
304
        return prefix + "/chooseStation";
    }

    @Log(title = "设置站台", operating = "设置站台", action = BusinessType.GRANT)
    @PostMapping("/setStation")
    @ResponseBody
    public AjaxResult setStation (TaskHeader taskHeader){
        Integer taskiId = taskHeader.getId();
        LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
        taskHeaderLambdaQueryWrapper.eq(TaskHeader::getId, taskiId);
        TaskHeader taskHeader1 = taskHeaderService.getOne(taskHeaderLambdaQueryWrapper);
游杰 authored
305
        taskHeader1.setPort(taskHeader.getPort());
游杰 authored
306
307
308
        taskHeaderService.update(taskHeader1, taskHeaderLambdaQueryWrapper);
        return execute(String.valueOf(taskiId));
    }
309
310
311
312
313
314
315
316
317

    @Log(title = "手动回传", operating = "手动回传", action = BusinessType.GRANT)
    @PostMapping("/handleBack")
    @ResponseBody
    public AjaxResult handleBack (Integer taskId){
        taskHeaderService.handleBack(taskId);
        return AjaxResult.success();
    }
mahuandong authored
318
}