| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.ProcessRouteMapper; |
| | | import com.ruoyi.production.mapper.ProductBomMapper; |
| | | import com.ruoyi.production.mapper.ProductStructureMapper; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.sales.dto.InvoiceRegistrationProductDto; |
| | | import com.ruoyi.sales.mapper.InvoiceRegistrationProductMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.InvoiceRegistrationProduct; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | |
| | | private PurchaseLedgerMapper purchaseLedgerMapper; |
| | | private StockUtils stockUtils; |
| | | |
| | | @Autowired |
| | | private InvoiceRegistrationProductMapper invoiceRegistrationProductMapper; |
| | | |
| | | @Autowired |
| | | private ProcessRouteMapper processRouteMapper; |
| | | @Autowired |
| | | private ProductBomMapper productBomMapper; |
| | | @Autowired |
| | | private ProductStructureMapper productStructureMapper; |
| | | |
| | | @Override |
| | | public SalesLedgerProduct selectSalesLedgerProductById(Long id) { |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public R judgmentInventory(SalesLedgerProduct salesLedgerProduct) { |
| | | //获取产品最新的工艺路线 |
| | | ProcessRoute processRoute = processRouteMapper.selectOne(new QueryWrapper<ProcessRoute>().lambda().eq(ProcessRoute::getProductModelId, salesLedgerProduct.getProductModelId()).orderByDesc(ProcessRoute::getCreateTime).last("LIMIT 1")); |
| | | if (processRoute == null) { |
| | | return R.fail("请先设置工艺路线"); |
| | | } |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomId(processRoute.getBomId()); |
| | | if (productStructureDtos.isEmpty()) { |
| | | return R.fail("请先设置产品结构"); |
| | | } |
| | | int count = 0; |
| | | StringBuilder stringBuffer = new StringBuilder(); |
| | | for (ProductStructureDto productStructureDto : productStructureDtos) { |
| | | BigDecimal stockQuantity = stockUtils.getStockQuantity(productStructureDto.getProductModelId()).get("stockQuantity"); |
| | | //所需数量 |
| | | BigDecimal multiply = salesLedgerProduct.getQuantity().multiply(productStructureDto.getUnitQuantity()); |
| | | BigDecimal subtract =stockQuantity.subtract(multiply); |
| | | if (subtract.compareTo(BigDecimal.ZERO) <= 0) { |
| | | count++; |
| | | stringBuffer.append(productStructureDto.getProductName()) |
| | | .append("-") |
| | | .append(productStructureDto.getModel()) |
| | | .append("库存不足,少") |
| | | .append(subtract) |
| | | .append(System.lineSeparator()); |
| | | } |
| | | } |
| | | if (count>0) { |
| | | return R.fail(stringBuffer.toString()); |
| | | }else { |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通用方法:根据主表ID和子表列表,更新主表的合同金额 |
| | | */ |