AcsController.java 4.49 KB
package com.huaheng.api.acs.controller;

import com.huaheng.api.acs.domain.AcsStatus;
import com.huaheng.api.acs.domain.AcsWeightHeight;
import com.huaheng.api.acs.service.AcsService;
import com.huaheng.common.utils.StringUtils;
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.task.agvTask.service.AgvTaskService;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@RequestMapping("/agv")
public class AcsController extends BaseController {

    @Resource
    private AcsService acsService;
    @Resource
    private AgvTaskService agvTaskService;

    /**
     * status 20  任务执行中;
     * 50  取货完成;
     * 100  任务完成;
     * @param acsStatus
     * @return
     */
    @PostMapping("/notifyAGVTask")
    @ApiOperation("更新AGV状态")
    @ResponseBody
    @ApiLogger(apiName = "更新AGV状态", from="acs")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult notifyAGVTask(@RequestBody AcsStatus acsStatus) {
        if(acsStatus == null) {
            return AjaxResult.error("入库组盘信息为空");
        }
        String taskNo = acsStatus.getTaskNo();
        String carNo = acsStatus.getCarNo();
        int status = acsStatus.getStatus();
        String updateBy = acsStatus.getUpdateBy();
        updateBy = "acs";
        if(StringUtils.isEmpty(taskNo) ) {
            return AjaxResult.error("更新AGV状态,任务号为空");
        }
        /*if(StringUtils.isEmpty(carNo)) {
            return AjaxResult.error("更新AGV状态,车辆编号为空");
        }*/
        if(status == 0) {
            return AjaxResult.error("更新AGV状态,状态信息为空");
        }
        if(StringUtils.isEmpty(updateBy)) {
            return AjaxResult.error("更新AGV状态,更新者信息为空");
        }
        String finalUpdateBy = updateBy;
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = acsService.notifyAGVTask(taskNo, carNo, status, finalUpdateBy);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    @PostMapping("/notifyAGVPort")
    @ApiOperation("更新AGV点位信息")
    @ResponseBody
    @ApiLogger(apiName = "更新AGV点位信息", from="acs")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult notifyAGVPort(@RequestBody AcsStatus acsStatus) {
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = acsService.notifyAGVPort(acsStatus);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    @PostMapping("/completeAGVTask")
    @ApiOperation("完成AGV任务")
    @ResponseBody
    @ApiLogger(apiName = "完成AGV任务", from="acs")
    public AjaxResult completeAGVTask(@RequestBody AcsStatus acsStatus) {
        if(acsStatus == null) {
            return AjaxResult.error("完成AGV任务,任务状态为空");
        }
        String taskNo = acsStatus.getTaskNo();
        if(taskNo == null) {
            return AjaxResult.error("完成AGV任务,任务号为空");
        }
        int taskId = Integer.parseInt(taskNo);
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = agvTaskService.completeTask(taskId);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    @PostMapping("/weightAndHeightByContainer")
    @ApiOperation("agv传递重量和高度给wms")
    @ResponseBody
    @ApiLogger(apiName = "agv传递重量和高度给wms", from="acs")
    public AjaxResult weightAndHeightByContainer(@RequestBody AcsWeightHeight acsWeightHeight) {

        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = acsService.weightAndHeightByContainer(acsWeightHeight);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
}