| | |
| | | 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; |