| | |
| | | import com.ruoyi.sales.pojo.InvoiceRegistrationProduct; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @date 2025-05-09 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Slf4j |
| | | public class PurchaseLedgerServiceImpl extends ServiceImpl<PurchaseLedgerMapper, PurchaseLedger> implements IPurchaseLedgerService { |
| | | private final AccountExpenseService accountExpenseService; |
| | | private final PurchaseLedgerMapper purchaseLedgerMapper; |
| | | @Autowired |
| | | private AccountExpenseService accountExpenseService; |
| | | @Autowired |
| | | private PurchaseLedgerMapper purchaseLedgerMapper; |
| | | |
| | | private final SalesLedgerMapper salesLedgerMapper; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | @Autowired |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | @Autowired |
| | | private SalesLedgerProductMapper salesLedgerProductMapper; |
| | | |
| | | private final SysUserMapper userMapper; |
| | | @Autowired |
| | | private SysUserMapper userMapper; |
| | | |
| | | private final TempFileMapper tempFileMapper; |
| | | @Autowired |
| | | private TempFileMapper tempFileMapper; |
| | | |
| | | private final CommonFileMapper commonFileMapper; |
| | | @Autowired |
| | | private CommonFileMapper commonFileMapper; |
| | | |
| | | private final SupplierManageMapper supplierManageMapper; |
| | | @Autowired |
| | | private SupplierManageMapper supplierManageMapper; |
| | | |
| | | private final ProductMapper productMapper; |
| | | @Autowired |
| | | private ProductMapper productMapper; |
| | | |
| | | private final ProductModelMapper productModelMapper; |
| | | @Autowired |
| | | private ProductModelMapper productModelMapper; |
| | | |
| | | private final SysUserMapper sysUserMapper; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | private final TicketRegistrationMapper ticketRegistrationMapper; |
| | | @Autowired |
| | | private TicketRegistrationMapper ticketRegistrationMapper; |
| | | |
| | | private final ProductRecordMapper productRecordMapper; |
| | | @Autowired |
| | | private ProductRecordMapper productRecordMapper; |
| | | |
| | | private final PaymentRegistrationMapper paymentRegistrationMapper; |
| | | |
| | | private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper; |
| | | |
| | | private final StringRedisTemplate redisTemplate; |
| | | private final QualityInspectMapper qualityInspectMapper; |
| | | private final QualityTestStandardBindingMapper qualityTestStandardBindingMapper; |
| | | private final QualityTestStandardParamMapper qualityTestStandardParamMapper; |
| | | private final QualityTestStandardMapper qualityTestStandardMapper; |
| | | private final QualityInspectParamMapper qualityInspectParamMapper; |
| | | |
| | | private final ApproveProcessServiceImpl approveProcessService; |
| | | |
| | | private final ProcurementRecordMapper procurementRecordStorageMapper; |
| | | |
| | | private final PurchaseLedgerTemplateMapper purchaseLedgerTemplateMapper; |
| | | |
| | | private final SalesLedgerProductTemplateMapper salesLedgerProductTemplateMapper; |
| | | @Autowired |
| | | private PaymentRegistrationMapper paymentRegistrationMapper; |
| | | @Autowired |
| | | private InvoiceRegistrationProductMapper invoiceRegistrationProductMapper; |
| | | @Autowired |
| | | private StringRedisTemplate redisTemplate; |
| | | @Autowired |
| | | private QualityInspectMapper qualityInspectMapper; |
| | | @Autowired |
| | | private CommonFileServiceImpl commonFileService; |
| | | @Autowired |
| | | private QualityTestStandardBindingMapper qualityTestStandardBindingMapper; |
| | | @Autowired |
| | | private QualityTestStandardParamMapper qualityTestStandardParamMapper; |
| | | @Autowired |
| | | private QualityTestStandardMapper qualityTestStandardMapper; |
| | | @Autowired |
| | | private QualityInspectParamMapper qualityInspectParamMapper; |
| | | @Autowired |
| | | private ApproveProcessServiceImpl approveProcessService; |
| | | @Autowired |
| | | private ProcurementRecordMapper procurementRecordStorageMapper; |
| | | @Autowired |
| | | private PurchaseLedgerTemplateMapper purchaseLedgerTemplateMapper; |
| | | @Autowired |
| | | private SalesLedgerProductTemplateMapper salesLedgerProductTemplateMapper; |
| | | @Value("${file.upload-dir}") |
| | | private String uploadDir; |
| | | |
| | |
| | | purchaseLedger.setRecorderId(purchaseLedgerDto.getRecorderId()); |
| | | purchaseLedger.setRecorderName(sysUser.getNickName()); |
| | | purchaseLedger.setPhoneNumber(sysUser.getPhonenumber()); |
| | | purchaseLedger.setApprovalStatus(1); |
| | | // 3. 新增或更新主表 |
| | | if (purchaseLedger.getId() == null) { |
| | | purchaseLedgerMapper.insert(purchaseLedger); |
| | |
| | | return 1; |
| | | } |
| | | |
| | | private void addQualityInspect(PurchaseLedger purchaseLedger, SalesLedgerProduct saleProduct) { |
| | | |
| | | public void addQualityInspect(PurchaseLedger purchaseLedger, SalesLedgerProduct saleProduct) { |
| | | QualityInspect qualityInspect = new QualityInspect(); |
| | | qualityInspect.setInspectType(0); |
| | | qualityInspect.setSupplier(purchaseLedger.getSupplierName()); |
| | |
| | | if (ids == null || ids.length == 0) { |
| | | throw new BaseException("请选中至少一条数据"); |
| | | } |
| | | for (Long id : ids) { |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(id); |
| | | if (purchaseLedger.getApprovalStatus().equals(3)) { |
| | | throw new BaseException(purchaseLedger.getPurchaseContractNumber()+"已经审批通过,不允许删除"); |
| | | } |
| | | } |
| | | // 批量删除关联的采购入库记录 |
| | | LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductQueryWrapper = new LambdaQueryWrapper<>(); |
| | | salesLedgerProductQueryWrapper.in(SalesLedgerProduct::getSalesLedgerId, ids) |
| | |
| | | //批量删除检验标准 |
| | | LambdaQueryWrapper<QualityInspect> materialInspectLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | materialInspectLambdaQueryWrapper.in(QualityInspect::getPurchaseLedgerId, ids); |
| | | |
| | | List<QualityInspect> qualityInspects = qualityInspectMapper.selectList(materialInspectLambdaQueryWrapper); |
| | | qualityInspects.stream().forEach(qualityInspect -> { |
| | | if (ObjectUtils.isNotEmpty(qualityInspect.getInspectState())&&qualityInspect.getInspectState().equals(1)) { |
| | |
| | | } |
| | | //批量删除原材料检验数据 |
| | | qualityInspectMapper.delete(materialInspectLambdaQueryWrapper); |
| | | //删除附件 |
| | | commonFileService.deleteByBusinessIds(Arrays.asList(ids), 2); |
| | | // 批量删除采购台账 |
| | | return purchaseLedgerMapper.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | |
| | | List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().in(SysUser::getNickName, |
| | | salesLedgerImportDtoList.stream().map(PurchaseLedgerImportDto::getRecorderName).collect(Collectors.toList()))); |
| | | for (PurchaseLedgerImportDto salesLedgerImportDto : salesLedgerImportDtoList) { |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .eq(PurchaseLedger::getPurchaseContractNumber, salesLedgerImportDto.getPurchaseContractNumber()) |
| | | .last("limit 1")); |
| | | if(purchaseLedger != null){ |
| | | continue; |
| | | } |
| | | PurchaseLedger salesLedger = new PurchaseLedger(); |
| | | BeanUtils.copyProperties(salesLedgerImportDto, salesLedger); |
| | | // 通过供应商名称查询ID |
| | |
| | | return AjaxResult.success("导入失败"); |
| | | } |
| | | |
| | | @Override |
| | | public PurchaseLedgerDto getPurchaseByCode(PurchaseLedgerDto purchaseLedgerDto) { |
| | | // 1. 查询主表 |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .eq(PurchaseLedger::getPurchaseContractNumber, purchaseLedgerDto.getPurchaseContractNumber()) |
| | | .last("LIMIT 1")); |
| | | if (purchaseLedger == null) { |
| | | throw new BaseException("采购台账不存在"); |
| | | } |
| | | |
| | | // 2. 查询子表 |
| | | LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>(); |
| | | productWrapper.eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId()) |
| | | .eq(SalesLedgerProduct::getType, 2); |
| | | List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(productWrapper); |
| | | |
| | | // 4. 转换 DTO |
| | | PurchaseLedgerDto resultDto = new PurchaseLedgerDto(); |
| | | BeanUtils.copyProperties(purchaseLedger, resultDto); |
| | | if (!products.isEmpty()) { |
| | | resultDto.setHasChildren(true); |
| | | resultDto.setProductData(products); |
| | | } |
| | | return resultDto; |
| | | } |
| | | |
| | | public void addApproveByPurchase(LoginUser loginUser,PurchaseLedger purchaseLedger) throws Exception { |
| | | ApproveProcessVO approveProcessVO = new ApproveProcessVO(); |
| | | approveProcessVO.setApproveType(5); |