RcsController.java 3.77 KB
package com.huaheng.api.rcs.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.api.acs.domain.AgvTaskCS;
import com.huaheng.api.acs.service.AgvTaskCSService;
import com.huaheng.api.mes.domain.AcsTask;
import com.huaheng.api.mes.service.MesService;
import com.huaheng.api.rcs.service.RcsService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * rcs任务执行反馈控制器
 * @author xcq
 */
@RestController
@RequestMapping("/api/rcs")
@Api(tags = {"rcs任务执行反馈接口"}, value = "rcs任务执行反馈接口")
public class RcsController extends BaseController {
    @Resource
    private LocationService locationService;
    @Resource
    private InventoryHeaderService inventoryHeaderService;
    @Resource
    private TaskHeaderService taskHeaderService;
    @Resource
    private RcsService rcsService;
    @Resource
    private MesService mesService;



    @ApiOperation(value="ACS上报任务状态", notes="ACS上报任务状态")
    @PostMapping(value = "/updateAGVTask")
    @ResponseBody
//    @ApiLogger(apiName = "ACS上报任务状态", from = "ACS")
    public AjaxResult updateAGVTask(@RequestBody AcsTask temp ){
        TaskHeader  taskHeader = taskHeaderService.getById(temp.getTaskNo());
        if (taskHeader == null){
            return AjaxResult.error("根据id"+temp.getTaskNo()+"查询任务失败!");
        }
        if (QuantityConstant.TASK_STATUS_COMPLETED == taskHeader.getStatus()){
            return AjaxResult.success("入库任务已经完成,请勿重复提交!");
        }
        // RCS取消任务
        if (QuantityConstant.TASK_STATUS_CANCEL == temp.getStatus()){
            return taskHeaderService.cancelTask(Convert.toIntArray(taskHeader.getId().toString()));
        }
        // AGV任务执行状态
        if (QuantityConstant.AGV_TASK_STATUS_EXECUTE == temp.getStatus()){
            taskHeader.setStatus(QuantityConstant.AGV_TASK_STATUS_EXECUTE);
            taskHeaderService.updateById(taskHeader);
            return AjaxResult.success("任务状态更新成功!");
        }
        // 完成换站任务
        if (taskHeader.getTaskType() == QuantityConstant.TASK_TYPE_OVER_STATION){
            taskHeader.setStatus(QuantityConstant.AGV_TASK_STATUS_COMPLETE);
            taskHeaderService.updateById(taskHeader);
            return AjaxResult.success("任务状态更新成功!");
        }
        // AGV任务完成状态
        if (QuantityConstant.AGV_TASK_STATUS_COMPLETE == temp.getStatus()){
            AjaxResult result = taskHeaderService.completeTaskByWMS(Convert.toIntArray(String.valueOf(taskHeader.getId())), null);
            if (result.hasErr()){
                return result;
            }
            if (taskHeader.getTaskType() == QuantityConstant.TASK_TYPE_WHOLERECEIPT || taskHeader.getTaskType() == QuantityConstant.TASK_TYPE_TRANSFER){
                return mesService.inventoryConversion(taskHeader.getToLocation());
            }
        }
        return AjaxResult.success("任务状态更新成功!");
    }


}