package com.huaheng.pc.u8.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.huaheng.common.utils.StringUtils; import com.huaheng.common.utils.Wrappers; import com.huaheng.framework.web.domain.AjaxResult; import com.huaheng.pc.config.company.service.CompanyService; import com.huaheng.pc.config.material.domain.Material; import com.huaheng.pc.config.material.service.MaterialService; import com.huaheng.pc.config.warehouse.domain.Warehouse; import com.huaheng.pc.config.warehouse.service.WarehouseService; import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail; import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService; import com.huaheng.pc.u8.domain.ICSInventory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; /** * 库存实时查询接口 * @author huaheng * @date 2019-1-5 */ @Service public class ICSInventoryAPIService { @Resource private InventoryDetailService inventoryDetailService; @Resource private CompanyService companyService; @Resource private MaterialService materialService; @Resource private WarehouseService warehouseService; public AjaxResult GetCurrentStock(ICSInventory icsInventory){ InventoryDetail inventory=new InventoryDetail(); 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.getWarehouseNameByCode(icsInventory.getCWhCode())==null){ return AjaxResult.error("系统没有该仓库:"+icsInventory.getCWhCode()); } Material material=material=materialService.getMaterialByCode(icsInventory.getCInvCode(),icsInventory.getCWhCode()); if(material==null){ return AjaxResult.error("该仓库没有这个物料编码:"+icsInventory.getCInvCode()); } if(!material.getName().equals(icsInventory.getCInvName())){ return AjaxResult.error("物料名称错误"); } if(!material.getSpec().equals(icsInventory.getCInvStd())){ return AjaxResult.error("物料规格错误"); } //判断系统中有没有该货主 companyService.checkwarehouseCompany(icsInventory.getCompanyCode()); LambdaQueryWrapper<InventoryDetail> lam= Wrappers.lambdaQuery(); lam.eq(InventoryDetail::getWarehouseCode,icsInventory.getCWhCode()); lam.eq(InventoryDetail::getMaterialCode,icsInventory.getCInvCode()); lam.eq(InventoryDetail::getCompanyCode,icsInventory.getCompanyCode()); lam.eq(InventoryDetail::getProjectNo,icsInventory.getCItemName()); List<InventoryDetail> list=inventoryDetailService.list(lam); return AjaxResult.success(list); } }