| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.ProductStructureMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductInputMapper; |
| | | import com.ruoyi.production.pojo.ProductStructureRecord; |
| | | import com.ruoyi.production.mapper.ProductStructureRecordMapper; |
| | | import com.ruoyi.production.pojo.ProductionProductInput; |
| | | import com.ruoyi.production.service.ProductStructureRecordService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class ProductStructureRecordServiceImpl extends ServiceImpl<ProductStructureRecordMapper, ProductStructureRecord> implements ProductStructureRecordService { |
| | | |
| | | @Autowired |
| | | private ProductStructureRecordMapper productStructureRecordMapper; |
| | | |
| | | @Autowired |
| | | private ProductStructureMapper productStructureMapper; |
| | | |
| | | @Autowired |
| | | private StockUtils stockUtils; |
| | | |
| | | @Autowired |
| | | private ProductionProductInputMapper productionProductInputMapper; |
| | | |
| | | @Override |
| | | public IPage<ProductStructureRecord> listPage(Page page, ProductStructureRecord productStructureRecord) { |
| | | return productStructureRecordMapper.listPage(page,productStructureRecord); |
| | | } |
| | | |
| | | @Override |
| | | public String pick(List<ProductionProductInput> productionProductInputs) { |
| | | if (CollectionUtils.isEmpty(productionProductInputs)) { |
| | | return "请选择要领的料"; |
| | | } |
| | | for (ProductionProductInput productionProductInput : productionProductInputs) { |
| | | productionProductInputMapper.insert(productionProductInput); |
| | | stockUtils.substractStock(productionProductInput.getProductModelId(), |
| | | productionProductInput.getQuantity(), |
| | | StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(), |
| | | productionProductInput.getProductOrderId(), |
| | | productionProductInput.getStockLocation()); |
| | | // 扣除物料清单 |
| | | ProductStructureRecord productStructureRecord = productStructureRecordMapper.selectById(productionProductInput.getProductStructureRecordId()); |
| | | if(productStructureRecord != null){ |
| | | productStructureRecord.setCompletedQuantity(productStructureRecord.getCompletedQuantity().add(productionProductInput.getQuantity())); |
| | | productStructureRecordMapper.updateById(productStructureRecord); |
| | | } |
| | | } |
| | | return "领料成功"; |
| | | } |
| | | } |