PalletInfoController.java 3.64 KB
package com.huaheng.api.wcs.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.station.domain.ShipmentPoint;
import com.huaheng.pc.config.station.service.ShipmentPointService;
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;

/***
 * @author tongzonghao
 *
 */
@RestController
@RequestMapping("/API/WMS/v2")
public class PalletInfoController  extends BaseController {
    @Resource
    private ContainerService containerService;
    @Resource
    private ShipmentPointService shipmentPointService;

    @PostMapping("/palletHeight")
    @ApiOperation("商片出库设置木托盘高度")
    @ApiLogger(apiName = "商片出库设置木托盘高度", from = "ROBOT")
    @Transactional(rollbackFor = Exception.class)
    @ResponseBody
    public AjaxResult arrivedNotice(@RequestBody Map<String, String> map) {
        String height = map.get("height");
        if(StringUtils.isEmpty(height)){
            return AjaxResult.error("高度不能为空");
        }
        List<ShipmentPoint> shipmentPoints = shipmentPointService.list();
        Integer palletHeight = Integer.valueOf(height);
        Integer woodenPalletHeight = 0;
        switch (palletHeight){
            case 0:
                throw new ServiceException("托盘高度不能为0");
            case 1:
                woodenPalletHeight = 125;
                break;
            case 2:
                woodenPalletHeight = 135;
                break;
            case 3:
                woodenPalletHeight = 145;
                break;
            case 4:
                woodenPalletHeight = 170;
                break;
            case 5:
                // 托盘上有货
                if(shipmentPoints.isEmpty()){
                // 1. 当托盘不存在物料 高度超过4 异常提示有料
                    return AjaxResult.success("木托盘上显示没货但高度为!"+palletHeight);
                }else{
                    return AjaxResult.success("更新到达站台成功!");
                }
            default:

        }
        LambdaQueryWrapper<Container> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(Container::getCode, "SHIPMENT_CONTAINER0001");
        Container container = containerService.getOne(queryWrapper);
        if(container == null){
            return AjaxResult.error("出库托盘容器被删除,请从新配置!");
        }
        boolean aNull = container.getWoodenPalletHeight() != null ? container.getWoodenPalletHeight() > 0 : false;

        if(aNull){
            return AjaxResult.success("出库托盘容器高度已经设置!");
        }
        Container updateContainer = new Container();
        updateContainer.setId(container.getId());
        updateContainer.setWoodenPalletHeight(woodenPalletHeight);

        if(!containerService.updateById(updateContainer)){
            throw new ServiceException("出库托盘木托高度更新失败!");
        }
        return AjaxResult.success("更新到达站台成功!");

    }


}