MesNotEmptyContainerController.java 3.25 KB
package com.huaheng.api.mes.controller;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.huaheng.api.mes.domain.MesMaterial;
import com.huaheng.api.mes.service.mesNotEmptyContainerService.NotEmptyContainerService;
import com.huaheng.common.exception.service.ServiceException;
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 io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

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

    @Resource
    private NotEmptyContainerService notEmptyContainerService;

    /**
     * 生成物料入库任务(整盘入库)
     * @return
     * @Param taskNo mes下发任务号
     * containerCode 容器编码
     * vehicleNo 载具编码
     * vehicleSpec 载具规格
     * mesMaterialList 物料信息
     */
    @PostMapping("/receipt")
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation("MES下发物料入库")
    @ApiLogger(apiName = "MES下发物料入库", from="MES")
    public AjaxResult receipt(String taskNo, String containerCode, String vehicleNo, String vehicleSpec, List<MesMaterial> mesMaterialList){
        if(StringUtils.isEmpty(taskNo)){
            throw new ServiceException("任务号不能为空!");
        }
        if(StringUtils.isEmpty(containerCode)){
            throw new ServiceException("容器号不能为空!");
        }
        if(StringUtils.isEmpty(vehicleNo)){
            throw new ServiceException("载具编码不能为空!");
        }
        if(StringUtils.isEmpty(vehicleSpec)){
            throw new ServiceException("载具规格不能为空!");
        }
        if(CollectionUtils.isEmpty(mesMaterialList)){
            throw new ServiceException("物料信息不能为空!");
        }
        return notEmptyContainerService.receipt(taskNo, containerCode, vehicleNo, vehicleSpec, mesMaterialList);
    }

    /**
     * 生成物料出库任务(整盘出库)
     * @return
     * @Param taskNo mes下发任务号
     * toPort 出库口
     * mesMaterialList 物料信息
     */
    @PostMapping("/shipment")
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation("MES下发物料出库")
    @ApiLogger(apiName = "MES下发物料出库", from="MES")
    public AjaxResult receipt(String taskNo, String toPort, List<MesMaterial> mesMaterialList){
        if(StringUtils.isEmpty(taskNo)){
            throw new ServiceException("任务号不能为空!");
        }
        if(StringUtils.isEmpty(toPort)){
            throw new ServiceException("出库口不能为空!");
        }
        if(CollectionUtils.isEmpty(mesMaterialList)){
            throw new ServiceException("物料信息不能为空!");
        }
        return notEmptyContainerService.shipment(taskNo, toPort, mesMaterialList);
    }

}