gongchunyi
5 天以前 d7c69d76e9c81464c698199b90ec4a339a18b257
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -1306,6 +1306,62 @@
        return dto;
    }
    @Override
    public List<SalesLabelDto> salesLabel(Long salesLedgerId) {
        if (salesLedgerId == null) {
            throw new ServiceException("打印标签失败,数据不能为空");
        }
        SalesLedger salesLedger = baseMapper.selectById(salesLedgerId);
        if (salesLedger == null) {
            throw new ServiceException("打印失败,销售订单不存在");
        }
        // 查询产品列表
        List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(
                new LambdaQueryWrapper<SalesLedgerProduct>().eq(SalesLedgerProduct::getSalesLedgerId, salesLedgerId));
        // 查询客户地址
        String fullAddress = "";
        if (salesLedger.getCustomerId() != null) {
            Customer customer = customerMapper.selectById(salesLedger.getCustomerId());
            if (customer != null) {
                StringBuilder addressSb = new StringBuilder();
                if (customer.getRegionsId() != null) {
                    CustomerRegions regions = customerRegionsService.getById(customer.getRegionsId());
                    if (regions != null) {
                        addressSb.append(regions.getRegionsName());
                    }
                }
                if (StringUtils.isNotEmpty(customer.getCompanyAddress())) {
                    addressSb.append(customer.getCompanyAddress());
                }
                fullAddress = addressSb.toString();
            }
        }
        List<SalesLabelDto> list = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(products)) {
            for (SalesLedgerProduct p : products) {
                SalesLabelDto dto = new SalesLabelDto();
                dto.setCustomerName(salesLedger.getCustomerName());
                dto.setSalesContractNo(salesLedger.getSalesContractNo());
                dto.setProductName(p.getProductCategory());
                // 宽*高=数量
                String specification = (p.getWidth() != null ? p.getWidth().stripTrailingZeros().toPlainString() : "0") + "*" +
                        (p.getHeight() != null ? p.getHeight().stripTrailingZeros().toPlainString() : "0") + "=" +
                        (p.getQuantity() != null ? p.getQuantity().stripTrailingZeros().toPlainString() : "0");
                dto.setSpecification(specification);
                // 客户地址 + 楼层编号
                dto.setFloorCode(fullAddress + (StringUtils.isNotEmpty(p.getFloorCode()) ? " " + p.getFloorCode() : ""));
                list.add(dto);
            }
        }
        return list;
    }
    private int findFirstMissingSequence(List<Integer> sequences) {
        if (sequences.isEmpty()) {
            return 1;