| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R init(InitContainerParams params, Long loginUserId) { |
| | | if (Objects.isNull(params.getStartNo())) { |
| | | throw new CoolException("容器起始值不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getEndNo())) { |
| | | throw new CoolException("容器结束值不能为空!!"); |
| | | } |
| | | // if (Objects.isNull(params.getStartNo())) { |
| | | // throw new CoolException("容器起始值不能为空!!"); |
| | | // } |
| | | // if (Objects.isNull(params.getEndNo())) { |
| | | // throw new CoolException("容器结束值不能为空!!"); |
| | | // } |
| | | // |
| | | // WarehouseAreas areas = warehouseAreasService.getOne(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getId, 42L)); |
| | | // if (Objects.isNull(areas)) { |
| | | // throw new CoolException("库区不存在,请联系管理员!!"); |
| | | // } |
| | | // |
| | | // if (params.getFlagInit()) { |
| | | // this.remove(new LambdaQueryWrapper<>()); |
| | | // } |
| | | // |
| | | // List<BasContainer> containerList = new ArrayList<>(); |
| | | // for (int i = params.getStartNo(); i <= params.getEndNo() ; i++) { |
| | | // BasContainer container = new BasContainer(); |
| | | // String code = StringUtils.leftPad(i + "", params.getLength(), "0"); |
| | | // if (!params.getContainerType().equals(3L)) { |
| | | // params.setPrefix("81"); |
| | | // } |
| | | // container.setAreas(areas.getName()) |
| | | // .setCodeType(QRCodeType.QRCODE_TYPE_BARCODE.desc) |
| | | // .setCode(params.getPrefix() + code) |
| | | // .setCreateTime(new Date()) |
| | | // .setCreateBy(loginUserId) |
| | | // .setUpdateBy(loginUserId) |
| | | // .setUpdateTime(new Date()) |
| | | // .setContainerType(params.getContainerType()); |
| | | // containerList.add(container); |
| | | // } |
| | | // |
| | | // if (!this.saveBatch(containerList)) { |
| | | // throw new CoolException("容器保存失败,请检查编码是否有重复!!"); |
| | | // } |
| | | |
| | | WarehouseAreas areas = warehouseAreasService.getOne(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getId, 42L)); |
| | | if (Objects.isNull(areas)) { |
| | | throw new CoolException("库区不存在,请联系管理员!!"); |
| | | } |
| | | |
| | | if (params.getFlagInit()) { |
| | | this.remove(new LambdaQueryWrapper<>()); |
| | | } |
| | | |
| | | List<BasContainer> containerList = new ArrayList<>(); |
| | | for (int i = params.getStartNo(); i <= params.getEndNo() ; i++) { |
| | | BasContainer container = new BasContainer(); |
| | | String code = StringUtils.leftPad(i + "", params.getLength(), "0"); |
| | | if (!params.getContainerType().equals(3L)) { |
| | | params.setPrefix("81"); |
| | | } |
| | | container.setAreas(areas.getName()) |
| | | .setCodeType(QRCodeType.QRCODE_TYPE_BARCODE.desc) |
| | | .setCode(params.getPrefix() + code) |
| | | .setCreateTime(new Date()) |
| | | .setCreateBy(loginUserId) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(new Date()) |
| | | .setContainerType(params.getContainerType()); |
| | | containerList.add(container); |
| | | } |
| | | |
| | | if (!this.saveBatch(containerList)) { |
| | | throw new CoolException("容器保存失败,请检查编码是否有重复!!"); |
| | | } |
| | | |
| | | return R.ok("新增成功!!").add(containerList); |
| | | return R.ok("新增成功!!"); |
| | | } |
| | | } |