| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.sinata.common.entity.PageDTO; |
| | | import com.sinata.common.enums.BoxProcessEnum; |
| | | import com.sinata.common.enums.BoxStatusEnum; |
| | | import com.sinata.common.exception.ServiceException; |
| | | import com.sinata.common.utils.BeanUtils; |
| | | import com.sinata.common.utils.CollUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.domain.MwBox; |
| | |
| | | import com.sinata.system.domain.query.MwBoxPageQuery; |
| | | import com.sinata.system.domain.vo.BoxStatisticsVO; |
| | | import com.sinata.system.domain.vo.MwBoxVO; |
| | | import com.sinata.system.enums.BoxProcessEnum; |
| | | import com.sinata.system.enums.BoxStatusEnum; |
| | | import com.sinata.system.mapper.MwBoxMapper; |
| | | import com.sinata.system.service.MwBoxService; |
| | | import org.springframework.dao.DuplicateKeyException; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @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); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void editBatch(List<MwBoxDTO> dtoList) { |
| | | List<MwBox> mwBoxes = BeanUtils.copyToList(dtoList, MwBox.class); |
| | | this.updateBatchById(mwBoxes); |
| | | public void editBatch(MwBoxDTO dto) { |
| | | 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; |
| | | }).collect(Collectors.toList()); |
| | | this.updateBatchById(boxList); |
| | | } |
| | | } |