zhoushihao
2024-10-11 d5d0d1c7a84b996b9bbcebfaf2c2c95f1a5a3678
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/storagetask/controller/StorageTaskController.java
@@ -1,5 +1,8 @@
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;
@@ -14,6 +17,8 @@
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;
/**
 *  
@@ -38,9 +43,9 @@
    @ApiOperation(value = "列表查询",notes = "列表查询",produces = "application/json")
    @ApiResponses({@ApiResponse(code = 200, message = "查询成功")})
    @PostMapping("/findList")
    public ResponseEntity<List<StorageTask>> findList(@RequestBody StorageTask params) {
    public Result findList(@RequestBody StorageTask params) {
        List<StorageTask> result = storageTaskService.findList(params);
        return ResponseEntity.ok(result);
        return Result.success(result);
    }
    /**
@@ -52,9 +57,9 @@
    @ApiOperation(value = "查询", notes = "查询详情")
    @ApiResponses({@ApiResponse(code = 200, message = "查询成功")})
    @GetMapping("/{id}")
    public ResponseEntity<StorageTask> findById(@PathVariable("id") Long id) {
        StorageTask storageTask = storageTaskService.findById(id);
        return ResponseEntity.ok(storageTask);
    public Result findById(@PathVariable("id") Long id) {
        StorageTask storageTask = storageTaskService.getBaseMapper().selectById(id);
        return Result.success(storageTask);
    }
    /**
@@ -66,9 +71,9 @@
    @ApiOperation(value = "新增", notes = "新增数据")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
    @PostMapping
    public ResponseEntity<Boolean> insert( @RequestBody StorageTask storageTask) {
        boolean result = storageTaskService.insert(storageTask);
        return ResponseEntity.ok(result);
    public Result insert( @RequestBody StorageTask storageTask) {
        boolean result = storageTaskService.save(storageTask);
        return Result.success(result);
    }
    /**
@@ -80,9 +85,9 @@
    @ApiOperation(value = "修改", notes = "修改数据")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
    @PutMapping
    public ResponseEntity<Boolean> update( @RequestBody StorageTask storageTask) {
        boolean result = storageTaskService.update(storageTask);
        return ResponseEntity.ok(result);
    public Result update( @RequestBody StorageTask storageTask) {
        boolean result = storageTaskService.updateById(storageTask);
        return Result.success(result);
    }
    /**
@@ -93,9 +98,32 @@
     */
    @ApiOperation(value = "删除", notes = "删除数据")
    @DeleteMapping("/{id}")
    public ResponseEntity<Integer> delete(@PathVariable("id") Long id) {
        int result = storageTaskService.delete(id);
        return ResponseEntity.ok(result);
    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();
    }
}