package com.glxp.mipsdl.controller;

import cn.hutool.core.util.StrUtil;
import com.glxp.mipsdl.client.ClientProcessor;
import com.glxp.mipsdl.req.base.UdiwmsQueryUdiInvProductsRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 提供给第三方系统调用的接口
 */
@Slf4j
@RestController
public class ThirdGetController {

    @PostMapping("/udiwms/inv/products/filter")
    public BaseResponse filterInv(@RequestBody UdiwmsQueryUdiInvProductsRequest thirdFilterInvRequest) {
        if (null == thirdFilterInvRequest) {
            return ResultVOUtils.error(500, "查询条件不能为空");
        }
        if (StrUtil.isEmpty(thirdFilterInvRequest.getBatchNo()) &&
                StrUtil.isEmpty(thirdFilterInvRequest.getProductName()) &&
                StrUtil.isEmpty(thirdFilterInvRequest.getDiCode()) &&
                StrUtil.isEmpty(thirdFilterInvRequest.getSupName())) {
            return ResultVOUtils.error(500, "查询条件不能为空！");
        }
        return ClientProcessor.getHttpClient().queryUdiInvProducts(thirdFilterInvRequest);
    }

}
