ICSInventoryAPIService.java 2.89 KB
package com.huaheng.api.U8.Service;

import com.huaheng.api.U8.domain.ICSInventory;
import com.huaheng.api.general.service.InventoryAPIService;
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.material.domain.Material;
import com.huaheng.pc.general.material.service.IMaterialService;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *  库存实时查询接口
 *   @author huaheng
 *   @date 2019-1-5
 */


@Service
public class ICSInventoryAPIService {
    @Autowired
    private InventoryAPIService inventoryAPIService;
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private IMaterialService materialService;
    @Autowired
    private IWarehouseService warehouseService;

    public AjaxResult GetCurrentStock(ICSInventory icsInventory){
        Inventory inventory=new Inventory();
        if(StringUtils.isEmpty(icsInventory.getCompanyCode())){
            return AjaxResult.error("没有货主信息");
        }
        if(StringUtils.isEmpty(icsInventory.getcInvCode())){
            return AjaxResult.error("没有物料编码信息");
        }
        if(StringUtils.isEmpty(icsInventory.getcWhCode())){
            return AjaxResult.error("没有仓库编码信息");
        }
        Warehouse warehouse=new Warehouse();
        warehouse.setCode(icsInventory.getcWhCode());
        if(warehouseService.selectFirstEntity(warehouse)==null){
            return AjaxResult.error("系统没有该仓库:"+icsInventory.getcWhCode());
        }
        Material material=new Material();
        material.setWarehouseCode(icsInventory.getcWhCode());
        material.setCode(icsInventory.getcInvCode());
        material=materialService.selectFirstEntity(material);
        if(material==null){
            return AjaxResult.error("该仓库没有这个物料编码:"+icsInventory.getcInvCode());
        }
        if(!material.getName().equals(icsInventory.getcInvName())){
           return AjaxResult.error("物料名称错误");
        }
        if(!material.getSpecification().equals(icsInventory.getcInvStd())){
            return AjaxResult.error("物料规格错误");
        }
        //判断系统中有没有该货主
        companyService.checkwarehouseCompany(icsInventory.getCompanyCode());
        inventory.setWarehouseCode(icsInventory.getcWhCode());
        inventory.setMaterialCode(icsInventory.getcInvCode());
        inventory.setCompanyCode(icsInventory.getCompanyCode());
        inventory.setProject(icsInventory.getcItemName());


        return inventoryAPIService.select(inventory);
    }
}