| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void add(String boxNumberStart, String boxNumberEnd) { |
| | | String regx = "\\d+"; |
| | | if (boxNumberStart.length() != 11 || boxNumberEnd.length() != 11 || !boxNumberStart.matches(regx) || !boxNumberEnd.matches(regx)) { |
| | | throw new ServiceException("请输入有效的11位数字编号!"); |
| | | } |
| | | //String regx = "\\d+"; |
| | | //if (boxNumberStart.length() != 11 || boxNumberEnd.length() != 11 || !boxNumberStart.matches(regx) || !boxNumberEnd.matches(regx)) { |
| | | // throw new ServiceException("请输入有效的11位数字编号!"); |
| | | //} |
| | | BigDecimal start = new BigDecimal(boxNumberStart); |
| | | BigDecimal end = new BigDecimal(boxNumberEnd); |
| | | if (start.compareTo(end) > 0) { |
| | |
| | | List<MwBox> boxList = new ArrayList<>(); |
| | | for (BigDecimal i = start; i.compareTo(end) <= 0; i = i.add(BigDecimal.ONE)) { |
| | | MwBox mwBox = new MwBox(); |
| | | mwBox.setBoxNumber(i.toString()); |
| | | // 每次生成编号时,确保其为11位 |
| | | String formattedBoxNumber = String.format("%011d", i.longValue()); |
| | | mwBox.setBoxNumber(formattedBoxNumber); |
| | | mwBox.setStatus(BoxStatusEnum.NORMAL.getCode()); |
| | | boxList.add(mwBox); |
| | | } |
| | |
| | | List<Long> idList = dto.getIdList(); |
| | | List<MwBox> boxList = idList.stream().map(id -> { |
| | | MwBox mwBox = new MwBox(); |
| | | mwBox.setId(id); |
| | | mwBox.setStatus(dto.getStatus()); |
| | | mwBox.setRemark(dto.getRemark()); |
| | | return mwBox; |