TransmissionLineInteractionController.java 3.77 KB
package com.huaheng.api.wcs.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.acs.domain.AgvTask;
import com.huaheng.api.acs.service.AcsService;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.domain.AjaxResult;

import com.huaheng.pc.agv.domain.AgvPort;
import com.huaheng.pc.agv.service.IAgvPortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/transmissionLine")
public class TransmissionLineInteractionController {
    @Autowired
    private AcsService acsService;

    @Autowired
    private IAgvPortService iAgvPortService;

    @PostMapping("/getContainerCode")
    @ApiLogger(apiName = "wcs输送线交互点位请求托盘",from = "wcs",to = "wms")
    public AjaxResult wcsGetContainerCode(@RequestBody Map map){
//        if(!StringUtils.isEmpty(map.get("port"))){
//            String linePort = map.get("port").toString();
//            LambdaQueryWrapper<AgvPort> queryWrapper = Wrappers.lambdaQuery();
//            queryWrapper.eq(AgvPort::getLinePort, linePort).orderByAsc(AgvPort::getType).last("limit 1");
//            AgvPort agvPort = iAgvPortService.getOne(queryWrapper);
//            if(StringUtils.isEmpty(agvPort)){
//                return AjaxResult.error("点位错误,不存在");
//            }
//            AgvTask agvTask = acsService.getOne(new LambdaQueryWrapper<AgvTask>().eq(AgvTask::getToPort, agvPort.getCode()).orderByDesc(AgvTask::getId).last("limit 1"));
//            if(!StringUtils.isEmpty(agvTask)){
//                return AjaxResult.success("成功").setData(agvTask.getContainerCode());
//            }
//        }else {
//            return AjaxResult.error("请求体不对");
//        }
//        return AjaxResult.error("请求错误");
        return AjaxResult.success("成功").setData("S00693");
    }

    @PostMapping("/setContainerCode")
    @ApiLogger(apiName = "wcs输送线交互点位托盘到达",from = "wcs",to = "wms")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult wcsSetContainerCode(@RequestBody Map map){
//        if(!StringUtils.isEmpty(map.get("port"))){
//            String linePort = map.get("port").toString();
//            LambdaQueryWrapper<AgvPort> queryWrapper = Wrappers.lambdaQuery();
//            queryWrapper.eq(AgvPort::getLinePort, linePort).orderByAsc(AgvPort::getType).last("limit 1");
//            AgvPort agvPort = iAgvPortService.getOne(queryWrapper);
//            if(StringUtils.isEmpty(agvPort)){
//                return AjaxResult.error("点位错误,不存在");
//            }
//            if(!StringUtils.isEmpty(map.get("containerCode"))){
//                String containerCode = map.get("containerCode").toString();
//                try {
//                    iAgvPortService.setContainerCode(agvPort.getCode(),containerCode);
//                    return AjaxResult.success("接收到了");
//                }catch (Exception e) {
//                    throw new RuntimeException("反正报错了,你看着办吧");
//                }
//            }
//        }else {
//            return AjaxResult.error("请求体不对");
//        }
//        return AjaxResult.error("请求错误");
        return AjaxResult.success("接收到了");
    }
}