MobilePutawayController.java 4.88 KB
package com.huaheng.mobile.receipt;

import com.alibaba.fastjson.JSONException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.common.utils.security.ShiroUtils;
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.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.service.LocationService;
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 io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 *
 * @author Enzo Cotter
 * @date 2019/12/16
 */
@RestController
@RequestMapping("/mobile/putaway/execute")
@Api(tags = {"手机收货上架"}, value = "手机收货上架MobilePutawayController")
public class MobilePutawayController {

    @Resource
    private TaskHeaderService taskService;
    @Resource
    private LocationService locationService;

    @PostMapping("/createReceiptTask")
    @ApiOperation("手机扫描容器收货上架")
    @Log(title = "手机扫描容器收货上架", action = BusinessType.OTHER)
    public AjaxResult createReceiptTask(@RequestBody @ApiParam(value="容器号") Map<String, String> param) throws Exception {
        if  (param.get("containerCode") == null || param.get("containerCode").trim().length() < 1) {
            throw new JSONException("容器号(containerCode)不能为空");
        }
        AjaxResult retResult = taskService.mobileCreateReceiptTask(param.get("containerCode"), "L10-27-01");
        return retResult;
    }

    @PostMapping("/getLocationFromContainer")
    @ApiOperation("手机扫描容器获得库位号")
    @Log(title = "手机扫描容器获得库位号", action = BusinessType.OTHER)
    public AjaxResult getLocationFromContainer(@RequestBody @ApiParam(value="容器号") Map<String, String> param) throws Exception {
        if  (param.get("containerCode") == null || param.get("containerCode").trim().length() < 1) {
            throw new JSONException("容器号(containerCode)不能为空");
        }
        LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode())
                .eq(Location::getDeleted, false)
                .eq(Location::getContainerCode, param.get("containerCode"));
        Location location = locationService.getOne(queryWrapper);
        if(location == null) {
            return AjaxResult.error("没有该库位");
        }
        return AjaxResult.success("获取成功",location.getCode());
    }

    @PostMapping("/createQuickTask")
    @ApiOperation("手机扫描容器收货上架")
    @Log(title = "手机扫描容器收货上架", action = BusinessType.OTHER)
    public AjaxResult createQuickTask(@RequestBody @ApiParam(value="容器号") Map<String, String> param) throws Exception {
        if  (param.get("containerCode") == null || param.get("containerCode").trim().length() < 1) {
            throw new JSONException("容器号(containerCode)不能为空");
        }

        AjaxResult retResult = taskService.createQuickTask(param.get("containerCode"));
        return retResult;
    }

    @PostMapping("/scanLocationCode")
    @ApiOperation("手机扫描库位收货上架")
    @Log(title = "手机扫描库位收货上架", action = BusinessType.OTHER)
    public AjaxResult scanLocationCode(@RequestBody @ApiParam(value="库位编码") Map<String, String> param) throws Exception {
        if  (param.get("locationCode") == null || param.get("locationCode").trim().length() < 1) {
            throw new JSONException("库位号(locationCode)不能为空");
        }
        AjaxResult retResult = taskService.completeTask(param.get("locationCode"));
        return retResult;
    }

    @PostMapping("/createReplenishTask")
    @ApiOperation("手机扫描容器创建补充入库任务")
    @Log(title = "手机扫描容器创建补充入库任务", action = BusinessType.OTHER)
    public AjaxResult createReplenishTask(@RequestBody @ApiParam(value="容器号") Map<String, String> param) throws Exception {
        if  (param.get("containerCode") == null || param.get("containerCode").trim().length() < 1) {
            throw new JSONException("容器号(containerCode)不能为空");
        }
        AjaxResult retResult = taskService.createReplenishTask(param.get("containerCode"), 1);
        return retResult;
    }
}