ArrivedNoticeController.java 4.04 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.robot.service.RobotService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
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.List;
import java.util.Map;

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

    @Resource
    private TaskHeaderService taskHeaderService;
    @Resource
    private TaskDetailService taskDetailService;
    @Resource
    private RobotService robotService;
    @Resource
    private InventoryDetailService inventoryDetailService;

    @PostMapping("/arrivedNotice")
    @ApiOperation("到达拣选台")
    @ApiLogger(apiName = "到达拣选台", from="ROBOT")
    @Transactional(rollbackFor = Exception.class)
    @ResponseBody
    public AjaxResult arrivedNotice(@RequestBody Map<String,String> map) {
        String warehouseCode = "CS0001";
        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);
        }
        boolean result = taskHeaderService.updateById(taskHeader);
        if(!result) {
            return AjaxResult.error("更新到达站台失败");
        }
//        int taskType = taskHeader.getTaskType();
//        int push = taskHeader.getPush();
//        if(push != 0) {
//            return AjaxResult.success("已经推送过托盘信息");
//        }
//        if(taskType == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT) {
//            LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper1 = Wrappers.lambdaQuery();
//            inventoryDetailLambdaQueryWrapper1.eq(InventoryDetail::getMaterialCode, taskHeader.getMaterialCode())
//                    .eq(InventoryDetail::getContainerCode, taskHeader.getContainerCode());
//            List<InventoryDetail> inventoryDetailList1 = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper1);
//            return  robotService.pushShipmentContainer(taskHeader, inventoryDetailList1, taskHeader.getWarehouseCode());
//        } else {
//            if(taskType == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT) {
//                LambdaQueryWrapper<TaskDetail> taskDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
//                taskDetailLambdaQueryWrapper.eq(TaskDetail::getTaskId, taskHeader.getId());
//                List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailLambdaQueryWrapper);
//                return  robotService.pushReceiptContainer(taskHeader, taskDetailList, taskHeader.getWarehouseCode());
//
//            }
//        }
        return AjaxResult.success("更新到达站台成功");
    }
}