PdaCallSomeOut.java 3.4 KB
package com.huaheng.api.pda.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
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.inventory.inventoryHeader.service.InventoryHeaderForShipmentService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

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

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

    @Resource
    private InventoryDetailService inventoryDetailService;
    @Resource
    private InventoryHeaderForShipmentService inventoryHeaderForShipmentService;
    /**
     * 生成空托出库任务
     * @return
     */
    @PostMapping("/PdaCallSomeOut")
    @Log(title = "任务-任务管理", operating = "PDA生成有料托盘出库", action = BusinessType.INSERT)
    @ResponseBody
    @ApiLogger(apiName = "PDA生成有料托盘出库", from="PDA")
    public AjaxResult wcsCallEmptyOut(String batch, String port) {
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = innerWcsCallEmptyOut(batch,port);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    private AjaxResult innerWcsCallEmptyOut(String batch,String port) {
        if(StringUtils.isEmpty(ShiroUtils.getWarehouseCode())){
            return AjaxResult.error("未登录或登录超时,请先登录");
        }
        if (StringUtils.isEmpty(batch)){
           return AjaxResult.error("批次号为空");
        }
        if(StringUtils.isEmpty(port)){
            return AjaxResult.error("请输入站台");
        }
        if (!port.equals("P2001") && !port.equals("P1001")){
            return AjaxResult.error(port+"站台不存在");
        }
        LambdaQueryWrapper<InventoryDetail> inventoryDetail= Wrappers.lambdaQuery();
        inventoryDetail.eq(InventoryDetail::getWarehouseCode,"CS0001")
                .eq(InventoryDetail::getBatch,batch);
        List<InventoryDetail> list = inventoryDetailService.list(inventoryDetail);
        if (list.size()>1){
            return AjaxResult.error(batch+"批次号库内有"+list.size()+"个");
        }
        InventoryDetail inventoryDetails = inventoryDetailService.getOne(inventoryDetail);
        if (inventoryDetails==null){
            return AjaxResult.error("批次号"+batch+"不在库存内");
        }

        String inventoryHeaderId = inventoryDetails.getInventoryHeaderId().toString();
        inventoryHeaderForShipmentService.shipmentContainer(inventoryHeaderId, port);
        return AjaxResult.success();
    }
}