| | |
| | | } |
| | | boolean duplic = checkDuplic(dataList); |
| | | if (duplic) throw new RuntimeException("存在重复国标设备"); |
| | | //已存在的白名单 |
| | | Map<String, WorkOrderWhite> whiteMap = workOrderWhiteMapper.selectList().stream().collect(Collectors.toMap(WorkOrderWhite::getSerialNumber, Function.identity())); |
| | | List<WorkOrderWhite> addList = new ArrayList<>(); |
| | | dataList.stream().forEach(item -> { |
| | | WorkOrderWhite white = new WorkOrderWhite(); |
| | |
| | | errorDataList.add(errorText); |
| | | }); |
| | | white.setErrorType(String.join(",", errorDataList)); |
| | | //如果已存在补充id |
| | | WorkOrderWhite whiteExsit = whiteMap.get(white.getSerialNumber()); |
| | | if (whiteExsit != null) white.setId(whiteExsit.getId()); |
| | | addList.add(white); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("国标码为" + item.getSerialNumber() + "的设备故障类型有误"); |
| | |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * 所有白名单添加故障类型 |
| | | * |
| | | * @param workOrderWhite |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addBatch(WorkOrderWhite workOrderWhite) { |
| | | List<String> errorTypeListAdd = workOrderWhite.getErrorTypeList(); |
| | | List<WorkOrderWhite> whites = workOrderWhiteMapper.selectList(); |
| | | for (WorkOrderWhite white : whites) { |
| | | List<String> errorTypeList = Arrays.asList(white.getErrorType().split(",")); |
| | | for (String newError : errorTypeListAdd) { |
| | | if (errorTypeList.contains(newError)) { |
| | | continue; |
| | | } else { |
| | | errorTypeList.add(newError); |
| | | } |
| | | } |
| | | white.setErrorType(String.join(",", errorTypeList)); |
| | | } |
| | | if (!CollectionUtils.isEmpty(whites)) { |
| | | workOrderWhiteMapper.deleteAll(); |
| | | workOrderWhiteMapper.insertBatch(whites); |
| | | } |
| | | } |
| | | |
| | | private <T extends Comparable<T>> T parseThreshold(String thresholdStr, Class<?> type) { |
| | | if (Integer.class.equals(type)) { |
| | | return (T) Integer.valueOf(thresholdStr); |