| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importDisputeRecord(List<DisputeRecordExcel> data, Boolean isCovered) { |
| | | public String importDisputeRecord(List<DisputeRecordExcel> data, Boolean isCovered) { |
| | | int totalNum = data.size(); |
| | | int importNum = 0; |
| | | int updateNum = 0; |
| | | int errorNum = 0; |
| | | for (DisputeRecordExcel disputeRecordExcel : data) { |
| | | // 判断地址,时间 |
| | | if (Strings.isBlank(disputeRecordExcel.getAddress()) |
| | | ) { |
| | | errorNum++; |
| | | continue; |
| | | } |
| | | // 获取转换数据对象 |
| | | DisputeRecordEntity disputeRecordEntity |
| | | = Objects.requireNonNull(BeanUtil.copy(disputeRecordExcel, DisputeRecordEntity.class)); |
| | |
| | | // 查询 |
| | | List<DisputeRecordEntity> list = list(queryWrapper); |
| | | if (list.size()>0){ |
| | | // 更新 |
| | | disputeRecordEntity.setId(list.get(0).getId()); |
| | | // 更新 |
| | | updateById(disputeRecordEntity); |
| | | updateNum++; |
| | | if (isCovered) { |
| | | // 更新 |
| | | disputeRecordEntity.setId(list.get(0).getId()); |
| | | // 更新 |
| | | updateById(disputeRecordEntity); |
| | | importNum++; |
| | | } |
| | | }else { |
| | | // 插入 |
| | | save(disputeRecordEntity); |
| | | importNum ++; |
| | | } |
| | | } |
| | | StringBuilder builder = new StringBuilder("导入完成!"); |
| | | builder.append("其中本次表格共有 ").append(totalNum).append(" 条数据,") |
| | | .append("成功导入 ").append(importNum).append(" 条数据。"); |
| | | if (updateNum>0) { |
| | | builder.append("其中有 ").append(updateNum).append(" 条数据已存在。"); |
| | | } |
| | | if (errorNum>0){ |
| | | builder.append("共有 ").append(errorNum).append(" 条数据由于无地址信息未导入!"); |
| | | } |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |