ArrivedNoticeController.java 4.83 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.wcs.domain.RobotView;
import com.huaheng.api.wcs.service.RequestContainerNumberService;
import com.huaheng.api.wcs.service.pickUpHandle.RobotHandleService;
import com.huaheng.common.constant.QuantityConstant;
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.framework.web.service.ConfigService;
import com.huaheng.pc.config.container.service.ContainerBService;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.station.domain.Station;
import com.huaheng.pc.config.station.service.StationService;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.sap.domain.Zarsh;
import com.huaheng.pc.sap.service.ZarshService;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/API/WMS/v2")
public class ArrivedNoticeController extends BaseController {

    @Resource
    private TaskHeaderService taskHeaderService;
    @Resource
    private ZarshService zarshService;
    @Resource
    private StationService stationService;
    @PostMapping("/arrivedNotice")
    @ApiOperation("到达拣选台")
    @ApiLogger(apiName = "到达拣选台", from = "ROBOT")
    @Transactional(rollbackFor = Exception.class)
    @ResponseBody
    public AjaxResult arrivedNotice(@RequestBody Map<String, String> map) {
        String taskNo = map.get("taskNo");
        String port = map.get("port");
        String msg = map.get("msg");
        String state = map.get("state");
        LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
        taskHeaderLambdaQueryWrapper.eq(TaskHeader::getId, taskNo);
        TaskHeader taskHeader = taskHeaderService.getOne(taskHeaderLambdaQueryWrapper);
        if (taskHeader != null) {
            taskHeader.setStatus(QuantityConstant.TASK_STATUS_ARRIVED_STATION);
        } else {
            return AjaxResult.error("没有找到任务taskNo:" + taskNo);
        }
        int taskType = taskHeader.getTaskType();
        int status = taskHeader.getStatus();
        if (status == QuantityConstant.TASK_STATUS_COMPLETED) {
            return AjaxResult.success("更新到达站台成功, 任务已经完成");
        }
        boolean result = taskHeaderService.updateById(taskHeader);
        if (!result) {
            return AjaxResult.error("更新到达站台失败");
        }
        return AjaxResult.success("更新到达站台成功");

    }

    @PostMapping("/updatePort")
    @ApiOperation("到达拣选台")
    @ApiLogger(apiName = "修改站台", from = "ROBOT")
    @Transactional(rollbackFor = Exception.class)
    @ResponseBody
    public AjaxResult updatePort(@RequestBody Map<String, String> map) {
        String taskNo = map.get("TaskNo");
        String port = map.get("port");
        LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
        taskHeaderLambdaQueryWrapper.eq(TaskHeader::getId, taskNo);
        TaskHeader taskHeader = taskHeaderService.getOne(taskHeaderLambdaQueryWrapper);
        if (taskHeader != null) {
            taskHeader.setStatus(QuantityConstant.TASK_STATUS_ARRIVED_STATION);
            String uniqueIds = taskHeader.getUniqueIds();
            Zarsh zarsh = zarshService.getZarshByUnique(uniqueIds);
            if(zarsh != null){
                Station station = stationService.getStaionByCode(port);
                if(station == null){
                    return AjaxResult.error("站台不存在");
                }
                String byName = station.getByName();
                switch (taskHeader.getInternalTaskType()){
                    case 100:
                        zarsh.setFromPos(byName);
                        zarshService.updateById(zarsh);
                        break;
                    case 200:
                        zarsh.setToPos(byName);
                        zarshService.updateById(zarsh);
                        break;
                    default:
                }
            }
            taskHeader.setPort(port);
            taskHeaderService.updateById(taskHeader);
        } else {
            return AjaxResult.error("没有找到任务taskNo:" + taskNo);
        }
        return AjaxResult.success("修改站台成功");

    }
}