| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.entity.CoalInfo; |
| | | import com.ruoyi.basic.entity.Supply; |
| | | import com.ruoyi.basic.mapper.CoalInfoMapper; |
| | | import com.ruoyi.basic.mapper.SupplyMapper; |
| | | import com.ruoyi.business.dto.PurchaseRegistrationDto; |
| | | import com.ruoyi.business.entity.PendingInventory; |
| | | import com.ruoyi.business.entity.PurchaseRegistration; |
| | | import com.ruoyi.business.mapper.PendingInventoryMapper; |
| | | import com.ruoyi.business.mapper.PurchaseRegistrationMapper; |
| | | import com.ruoyi.business.service.PurchaseRegistrationService; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | private final PendingInventoryMapper pendingInventoryMapper; |
| | | |
| | | private final CoalInfoMapper coalInfoMapper; |
| | | |
| | | private final SupplyMapper supplyMapper; |
| | | |
| | | @Override |
| | | public IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page page, PurchaseRegistrationDto purchaseRegistrationDto) { |
| | | LambdaQueryWrapper<PurchaseRegistration> queryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | // 创建采购登记实体并复制属性 |
| | | PurchaseRegistration purchaseRegistration = new PurchaseRegistration(); |
| | | BeanUtils.copyProperties(purchaseRegistrationDto, purchaseRegistration); |
| | | CoalInfo coalInfo = coalInfoMapper.selectById(purchaseRegistrationDto.getCoalId()); |
| | | if (coalInfo == null) { |
| | | throw new BaseException("煤种信息不存在"); |
| | | } |
| | | purchaseRegistration.setCoal(coalInfo.getCoal()); |
| | | Supply supply = supplyMapper.selectById(purchaseRegistrationDto.getSupplierId()); |
| | | if (supply == null) { |
| | | throw new BaseException("供应商信息不存在"); |
| | | } |
| | | purchaseRegistration.setSupplierName(supply.getSupplierName()); |
| | | if (Objects.isNull(purchaseRegistrationDto.getId())) { |
| | | // 新增采购登记 |
| | | purchaseRegistration.setRegistrationDate(LocalDate.now()); |
| | |
| | | if (insertCount > 0) { |
| | | // 采购登记成功,同步创建待入库记录 |
| | | PendingInventory pendingInventory = createPendingInventory(purchaseRegistration); |
| | | pendingInventory.setSupplierName(supply.getSupplierName()); |
| | | pendingInventory.setCoal(coalInfo.getCoal()); |
| | | return pendingInventoryMapper.insert(pendingInventory); |
| | | } |
| | | return insertCount; |
| | |
| | | |
| | | /** |
| | | * 根据采购登记信息创建待入库记录 |
| | | * |
| | | * @param purchaseRegistration 采购登记实体 |
| | | * @return 待入库实体 |
| | | */ |