InventoryAPIService.java 1.94 KB
package com.huaheng.api.general.service;

import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.company.service.ICompanyService;
import com.huaheng.pc.general.warehouse.domain.Warehouse;
import com.huaheng.pc.general.warehouse.service.IWarehouseService;
import com.huaheng.pc.inventory.inventory.domain.Inventory;
import com.huaheng.pc.inventory.inventory.service.IInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  库存实时查询
 *   @author huaheng
 *   @date 2019-1-4
 */

@Service
public class InventoryAPIService {
    @Autowired
    private IInventoryService inventoryService;
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private IWarehouseService warehouseService;

    public AjaxResult select(Inventory inventory)
    {
        if(StringUtils.isEmpty(inventory.getCompanyCode())){
            return AjaxResult.error("没有货主信息");
        }
        if(StringUtils.isEmpty(inventory.getMaterialCode())){
            return AjaxResult.error("没有物料编码信息");
        }
        if(StringUtils.isEmpty(inventory.getWarehouseCode())){
            return AjaxResult.error("没有仓库编码信息");
        }
        Warehouse warehouse=new Warehouse();
        warehouse.setCode(inventory.getWarehouseCode());
        if(warehouseService.selectFirstEntity(warehouse)==null){
            return AjaxResult.error("系统没有该仓库:"+inventory.getWarehouseCode());
        }
        //判断系统中有没有该货主
        companyService.checkwarehouseCompany(inventory.getCompanyCode());
        inventory= inventoryService.selectFirstEntity(inventory);
       if(inventory==null){
           return AjaxResult.error("没有查到任何库存");
       }else {
           return AjaxResult.success(inventory);
       }
    }
}