| | |
| | | List<ApsMaterialProductGroupManagement> list = new ArrayList<>(); |
| | | |
| | | /*数据列从1开始*/ |
| | | for (int i = 1; i <= rows; i++) { |
| | | Set<String> keys = new HashSet<>(); |
| | | for (int i = rows; i > 0; --i) { |
| | | Row row = sheet.getRow(i); |
| | | if (row.getCell(0) == null) { |
| | | continue; |
| | |
| | | item.setIsMain(isMain); |
| | | item.setCreateBy(SecurityUtils.getUsername()); |
| | | item.setCreateTime(DateUtils.getNowDate()); |
| | | list.add(item); |
| | | if (!keys.contains(item.getKey())) { |
| | | keys.add(item.getKey()); |
| | | list.add(item); |
| | | } |
| | | } |
| | | } |
| | | if (!list.isEmpty()) { |
| | | Set<String> facCodeKey = apsMaterialProductGroupManagementMapper.selectByFacOrMaterial( |
| | | list.stream().map(ApsMaterialProductGroupManagement::getFactory).collect(Collectors.toSet()), |
| | | list.stream().map(ApsMaterialProductGroupManagement::getMaterialCode).collect(Collectors.toSet()) |
| | | ); |
| | | Set<String> facCodeKey = apsMaterialProductGroupManagementMapper.selectByFacOrMaterial(keys); |
| | | if (!facCodeKey.isEmpty()) { |
| | | Iterator<ApsMaterialProductGroupManagement> it = list.iterator(); |
| | | while (it.hasNext()) { |
| | | ApsMaterialProductGroupManagement item = it.next(); |
| | | String key = item.getFactory() + "##" + item.getMaterialCode(); |
| | | if (facCodeKey.contains(key)) { |
| | | if (facCodeKey.contains(item.getKey())) { |
| | | LambdaUpdateWrapper<ApsMaterialProductGroupManagement> wrapper = new LambdaUpdateWrapper<>(); |
| | | wrapper.eq(ApsMaterialProductGroupManagement::getFactory, item.getFactory()); |
| | | wrapper.eq(ApsMaterialProductGroupManagement::getMaterialCode, item.getMaterialCode()); |