mitao
2025-02-19 ae7f04be9321ddbe17c46fae8ab05d34e7493f9f
medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwBoxServiceImpl.java
@@ -87,10 +87,10 @@
    @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) {
@@ -99,7 +99,9 @@
        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);
        }
@@ -122,6 +124,7 @@
        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;