| | |
| | | // 分类 |
| | | // 一级分类 |
| | | if (!Cools.isEmpty(excel.getPriClass()) && !Cools.isEmpty(excel.getSecClass())) { |
| | | Tag priTag = tagService.getOne(new LambdaQueryWrapper<Tag>().eq(Tag::getName, excel.getPriClass()).eq(Tag::getLevel, 2)); |
| | | Tag priTag = tagService.getOne(new LambdaQueryWrapper<Tag>().eq(Tag::getName, excel.getPriClass()).eq(Tag::getLevel, 2).eq(Tag::getHostId, hostId)); |
| | | if (priTag == null) { |
| | | Tag top = tagService.getTop(hostId); |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | |
| | | null, // 修改人员 |
| | | null // 备注 |
| | | ); |
| | | priTag.setHostId(hostId); |
| | | if (tagMapper.insert(priTag) == 0) { |
| | | throw new CoolException("保存一级分类失败"); |
| | | } |
| | | } |
| | | // 二级分类 |
| | | Tag secTag = tagService.getOne(new LambdaQueryWrapper<Tag>().eq(Tag::getName, excel.getPriClass()).eq(Tag::getLevel, 3)); |
| | | Tag secTag = tagService.getOne(new LambdaQueryWrapper<Tag>().eq(Tag::getName, excel.getSecClass()).eq(Tag::getLevel, 3).eq(Tag::getHostId, hostId)); |
| | | if (secTag == null) { |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | | nodeUtils.executePath(priTag.getId()); |
| | |
| | | null, // 修改人员 |
| | | null // 备注 |
| | | ); |
| | | secTag.setHostId(hostId); |
| | | if (tagMapper.insert(secTag) == 0) { |
| | | throw new CoolException("保存二级分类失败"); |
| | | } |
| | |
| | | tagId = tagService.getTop(hostId).getId(); |
| | | } |
| | | // 商品 |
| | | Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, excel.getMatnr())); |
| | | Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, excel.getMatnr()).eq(Mat::getHostId, hostId)); |
| | | if (mat == null) { |
| | | mat = excel; |
| | | mat.setTagId(tagId); |
| | | mat.setHostId(hostId); |
| | | if (!matService.save(mat)) { |
| | | throw new CoolException("保存商品信息失败,商品编码:" + excel.getMatnr()); |
| | | } |
| | | total++; |
| | | }else { |
| | | matService.removeById(mat.getId()); |
| | | |
| | | mat = excel; |
| | | mat.setTagId(tagId); |
| | | mat.setHostId(hostId); |
| | | if (!matService.save(mat)) { |
| | | throw new CoolException("保存商品信息失败,商品编码:" + excel.getMatnr()); |
| | | } |