wuyouming666
2024-08-01 b0656b315e2eb8376d53ad237e58bdd6e65e31ec
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
package com.mes.storagetask.controller;
 
import com.mes.shelfrack.entity.request.RawUsageAndShelfRack;
import com.mes.storagetask.entity.request.StorageTaskRequest;
import com.mes.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;
import com.mes.storagetask.entity.StorageTask;
import com.mes.storagetask.service.StorageTaskService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
import java.util.Map;
import java.util.Optional;
 
/**
 *  
 *
 * @author system
 * @since 2024-07-09 14:51:27
 */
@RestController
@RequestMapping("/api/storageTask")
@Api(tags = " 控制器")
public class StorageTaskController {
 
    @Autowired
    private StorageTaskService storageTaskService;
 
    /**
     * 列表查询
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "列表查询",notes = "列表查询",produces = "application/json")
    @ApiResponses({@ApiResponse(code = 200, message = "查询成功")})
    @PostMapping("/findList")
    public Result findList(@RequestBody StorageTask params) {
        List<StorageTask> result = storageTaskService.findList(params);
        return Result.success(result);
    }
 
    /**
     * 查询
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "查询", notes = "查询详情")
    @ApiResponses({@ApiResponse(code = 200, message = "查询成功")})
    @GetMapping("/{id}")
    public Result findById(@PathVariable("id") Long id) {
        StorageTask storageTask = storageTaskService.getBaseMapper().selectById(id);
        return Result.success(storageTask);
    }
 
    /**
     * 新增
     *
     * @param storageTask
     * @return
     */
    @ApiOperation(value = "新增", notes = "新增数据")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
    @PostMapping
    public Result insert( @RequestBody StorageTask storageTask) {
        boolean result = storageTaskService.save(storageTask);
        return Result.success(result);
    }
 
    /**
     * 修改
     *
     * @param storageTask
     * @return
     */
    @ApiOperation(value = "修改", notes = "修改数据")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
    @PutMapping
    public Result update( @RequestBody StorageTask storageTask) {
        boolean result = storageTaskService.updateById(storageTask);
        return Result.success(result);
    }
 
    /**
     * 删除
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "删除", notes = "删除数据")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable("id") Long id) {
        int result = storageTaskService.getBaseMapper().deleteById(id);
        return Result.success(result);
    }
 
 
    @ApiOperation(value = "任务查询",notes = "任务查询",produces = "application/json")
    @ApiResponses({@ApiResponse(code = 200, message = "查询成功")})
    @GetMapping("/findTasks")
    public Result findLatestTasks() {
        List<StorageTaskRequest> result = storageTaskService.Tasks();
        return Result.success(result);
    }
 
 
 
    @ApiOperation(value = "任务操作", notes = "任务操作")
    @PostMapping("/taskUpdate")
    public Result taskUpdate(@RequestBody Map<String, Object> storageTaskMap) {
 
        StorageTask task = new StorageTask();
        task.setType((String) storageTaskMap.get("Type")); // 假设Type是存储在Map中的一个键
        task.setId((int) storageTaskMap.get("id"));
        storageTaskService.taskUpdate(task);
        return Result.success();
    }
 
 
}