WmsApiController.java 4.8 KB
package com.huaheng.api.general.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.general.domain.TaskDomain;
import com.huaheng.api.general.domain.TaskOffDomain;
import com.huaheng.api.general.service.TaskService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.ServiceException;
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.domain.AjaxResult;
import com.huaheng.framework.web.service.ConfigService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;



@RestController
@RequestMapping("/api")
@Api(tags = {"任务下发接口"}, value = "task")

public class WmsApiController {

    @Resource
    private TaskService taskService;
    @Resource
    private ConfigService configService;

    @Log(title = "任务下发至立库", action = BusinessType.INSERT)
    @PostMapping("/WisJobSend")
    @ApiOperation("任务下发至立库")
    @ResponseBody
    @ApiLogger(apiName = "任务下发至立库", from = "集团WMS")
    public AjaxResult WisJobSend(@RequestBody TaskDomain taskDomain) {

        String value = configService.getKey(QuantityConstant.WMS_ERP_OFF);
        if (Integer.valueOf(value)==1)
        {
            return AjaxResult.error("已关闭对ERP集成");
        }

        AjaxResult ajaxResult=new AjaxResult();
        switch (Integer.valueOf(taskDomain.getTaskType()))
        {
            case 1:
                ajaxResult=taskService.taskAllreceipt(taskDomain);
                //入库
                break;
            case 2:
                ajaxResult=taskService.lssueTask(taskDomain);
                //整出
                break;
            case 3:;
                ajaxResult=taskService.noProduction(taskDomain);
                //补充出
                break;
            case 4:
                ajaxResult=taskService.airflare(taskDomain);
                //入库返回
            break;
        }

        return ajaxResult;
    }

    @Resource
    private TaskHeaderService taskHeaderService;

    @Log(title = "任务取消", action = BusinessType.INSERT)
    @PostMapping("/Taskcancellation")
    @ApiOperation("任务取消")
    @ResponseBody
    @Transactional
    @ApiLogger(apiName = "任务取消", from = "集团WMS")
    public AjaxResult Taskcancellation(@RequestBody TaskOffDomain taskDomain) {
        if (taskDomain == null) {
            throw new ServiceException("wms下发任务为空");
        }
        //1、判断必填字段是否满足
        if(taskDomain.getReqID() == null){
            throw new ServiceException("wms任务号Id为空");
        }
        if(taskDomain.getContainerCode() == null){
            throw new ServiceException("wms任务容器为空");
        }
        if(taskDomain.getTaskNo() == null){
            throw new ServiceException("wms任务号为空");
        }
        if(taskDomain.getRequestTime() == null){
            throw new ServiceException("wms任务时间为空");
        }

        LambdaQueryWrapper<TaskHeader> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TaskHeader::getUserDef3, taskDomain.getTaskNo()).eq(TaskHeader::getContainerCode, taskDomain.getContainerCode());
        TaskHeader taskHeader = taskHeaderService.getOne(wrapper);


        AjaxResult ajaxResult=taskService.taskOff(taskDomain);

        return ajaxResult;
    }

    @Log(title = "呼叫空托盘", action = BusinessType.INSERT)
    @PostMapping("/wisCallEmptyContainer")
    @ApiOperation("呼叫空托盘")
    @ResponseBody
    @Transactional
    @ApiLogger(apiName = "呼叫空托盘", from = "集团WMS")
    public AjaxResult wisCallEmptyContainer(@RequestBody TaskOffDomain taskDomain) {
        if (taskDomain == null) {
            throw new ServiceException("wms下发任务为空");
        }
        if(taskDomain.getReqID() == null) {
            throw new ServiceException("wms任务号Id为空");
        }
        if(taskDomain.getContainerType() == null) {
            throw new ServiceException("wms任务容器类型为空");
        }
        if(taskDomain.getTaskNo() == null) {
            throw new ServiceException("wms任务号为空");
        }
        if(taskDomain.getToStnNo() == null) {
            throw new ServiceException("wms任务时间为空");
        }
        return taskService.WisCallEmptyContainer(taskDomain);
    }
}