| | |
| | | import com.ruoyi.account.pojo.AccountExpense; |
| | | import com.ruoyi.account.pojo.AccountIncome; |
| | | import com.ruoyi.account.service.AccountIncomeService; |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | import com.ruoyi.approve.service.IApproveProcessService; |
| | | import com.ruoyi.approve.vo.ApproveProcessVO; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | |
| | | import com.ruoyi.production.pojo.SalesLedgerScheduling; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.purchase.dto.PurchaseLedgerDto; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.sales.dto.MonthlyAmountDto; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import com.ruoyi.sales.mapper.*; |
| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.script.DefaultRedisScript; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.nio.file.StandardCopyOption; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.YearMonth; |
| | |
| | | private final AccountIncomeService accountIncomeService; |
| | | |
| | | private final SalesLedgerMapper salesLedgerMapper; |
| | | |
| | | private final IApproveProcessService approveProcessService; |
| | | |
| | | private final CustomerMapper customerMapper; |
| | | |
| | |
| | | LambdaQueryWrapper<SalesLedgerScheduling> in = new LambdaQueryWrapper<SalesLedgerScheduling>() |
| | | .in(SalesLedgerScheduling::getSalesLedgerId, idList); |
| | | salesLedgerSchedulingMapper.delete(in); |
| | | // 2. 再删除主表数据 |
| | | |
| | | // 2. 删除关联的审批表 |
| | | List<String> strings = salesLedgerMapper.selectBatchIds(idList).stream().map(SalesLedger::getSalesContractNo).distinct().collect(Collectors.toList()); |
| | | List<ApproveProcess> list = approveProcessService.list(Wrappers.<ApproveProcess>lambdaQuery() |
| | | .eq(ApproveProcess::getApproveType, 6) |
| | | .in(ApproveProcess::getApproveReason, strings)); |
| | | if (CollectionUtils.isNotEmpty(list)){ |
| | | List<String> approveIds = list.stream().map(ApproveProcess::getApproveId).distinct().collect(Collectors.toList()); |
| | | Long[] ides = approveIds.stream() |
| | | .filter(s -> s != null && !s.isEmpty()) // 过滤空字符串 |
| | | .map(Long::valueOf) |
| | | .toArray(Long[]::new); |
| | | approveProcessService.delApprove(ides); |
| | | } |
| | | // 3. 再删除主表数据 |
| | | return salesLedgerMapper.deleteBatchIds(idList); |
| | | } |
| | | |
| | |
| | | if (salesLedgerDto.getTempFileIds() != null && !salesLedgerDto.getTempFileIds().isEmpty()) { |
| | | migrateTempFilesToFormal(salesLedger.getId(), salesLedgerDto.getTempFileIds()); |
| | | } |
| | | |
| | | //6.销售订单按紧急程度分类,如普通订单以及紧急订单;普通订单需流转至业务单据进行审批,紧急订单无需审批。 |
| | | if (salesLedger.getSalesType().equals("普通")){ |
| | | //新增审批数据approve_process |
| | | ApproveProcessVO approveProcessVO = new ApproveProcessVO(); |
| | | approveProcessVO.setApproveDeptId(salesLedger.getTenantId()); |
| | | approveProcessVO.setApproveReason(salesLedger.getSalesContractNo());//审批理由是销售合同号用这个来关联 |
| | | DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | approveProcessVO.setApproveTime(LocalDate.now().format(dateFormat)); |
| | | approveProcessVO.setApproveType(6);//6是销售台账 |
| | | approveProcessVO.setApproveUser(Long.parseLong(salesLedger.getEntryPerson()));//录入人=申请人 |
| | | approveProcessVO.setApproveUserIds(salesLedgerDto.getApproveUserIds());//审批人 |
| | | try { |
| | | approveProcessService.addApprove(approveProcessVO); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | //紧急默认通过 |
| | | salesLedger.setApprovalStatus(2); |
| | | salesLedgerMapper.updateById(salesLedger); |
| | | } |
| | | return 1; |
| | | } catch (IOException e) { |
| | | throw new BaseException("文件迁移失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public SalesLedgerDto getSalesByCode(SalesLedgerDto salesLedgerDto) { |
| | | // 1. 查询主表 |
| | | SalesLedger salesLedger = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>() |
| | | .eq(SalesLedger::getSalesContractNo, salesLedgerDto.getSalesContractNo()) |
| | | .last("LIMIT 1")); |
| | | if (salesLedger == null) { |
| | | throw new BaseException("销售台账不存在"); |
| | | } |
| | | |
| | | // 2. 查询子表 |
| | | LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>(); |
| | | productWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedger.getId()) |
| | | .eq(SalesLedgerProduct::getType, 1); |
| | | List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(productWrapper); |
| | | |
| | | // 4. 转换 DTO |
| | | SalesLedgerDto resultDto = new SalesLedgerDto(); |
| | | BeanUtils.copyProperties(salesLedger, resultDto); |
| | | if (!products.isEmpty()) { |
| | | resultDto.setHasChildren(true); |
| | | resultDto.setProductData(products); |
| | | } |
| | | return resultDto; |
| | | } |
| | | |
| | | // 文件迁移方法 |
| | | |
| | | /** |