|
|
@@ -3,6 +3,7 @@ package com.izouma.nineth.repo;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.izouma.nineth.ApplicationTests;
|
|
|
import com.izouma.nineth.domain.Asset;
|
|
|
+import com.izouma.nineth.domain.User;
|
|
|
import com.izouma.nineth.domain.UserProperty;
|
|
|
import com.izouma.nineth.dto.AirDropExcelDTO;
|
|
|
import com.izouma.nineth.enums.AssetStatus;
|
|
|
@@ -10,6 +11,7 @@ import com.izouma.nineth.utils.excel.UploadDataListener;
|
|
|
import org.junit.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
+import java.io.DataOutput;
|
|
|
import java.io.File;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
@@ -54,8 +56,8 @@ public class UserPropertyRepoTest extends ApplicationTests {
|
|
|
userIds.forEach(id -> {
|
|
|
UserProperty userProperty = userPropertyRepo.findById(id).orElse(new UserProperty(id, 0));
|
|
|
userProperty.setMaxCount(userProperty.getMaxCount() + 1);
|
|
|
- if (userProperty.getMaxCount() > 5) {
|
|
|
- userProperty.setMaxCount(5);
|
|
|
+ if (userProperty.getMaxCount() > 6) {
|
|
|
+ userProperty.setMaxCount(6);
|
|
|
}
|
|
|
userPropertyRepo.save(userProperty);
|
|
|
});
|
|
|
@@ -74,55 +76,121 @@ public class UserPropertyRepoTest extends ApplicationTests {
|
|
|
}
|
|
|
UserProperty userProperty = userPropertyRepo.findById(key).orElse(new UserProperty(key, 0));
|
|
|
userProperty.setMaxCount(userProperty.getMaxCount() + size);
|
|
|
- if (userProperty.getMaxCount() > 5) {
|
|
|
- userProperty.setMaxCount(5);
|
|
|
+ if (userProperty.getMaxCount() > 6) {
|
|
|
+ userProperty.setMaxCount(6);
|
|
|
}
|
|
|
userPropertyRepo.save(userProperty);
|
|
|
});
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void setByphone() {
|
|
|
+ //凤鸣寺
|
|
|
File file = new File("/Users/qiufangchao/Desktop/mingdan.xlsx");
|
|
|
UploadDataListener<AirDropExcelDTO> listener = new UploadDataListener<>();
|
|
|
List<AirDropExcelDTO> dtos = EasyExcel.read(file, AirDropExcelDTO.class, listener)
|
|
|
.sheet()
|
|
|
.doReadSync();
|
|
|
- List<Long> userIds = userRepo.findIdByPhones(dtos.stream()
|
|
|
+ List<Long> userIds2 = userRepo.findIdByPhones(dtos.stream()
|
|
|
.map(AirDropExcelDTO::getPhone)
|
|
|
.collect(Collectors.toSet()));
|
|
|
- userIds.forEach(id -> {
|
|
|
+ System.out.println(userIds2);
|
|
|
+ userIds2.forEach(id -> {
|
|
|
UserProperty userProperty = userPropertyRepo.findById(id).orElse(new UserProperty(id, 0));
|
|
|
userProperty.setMaxCount(userProperty.getMaxCount() + 1);
|
|
|
- if (userProperty.getMaxCount() > 5) {
|
|
|
- userProperty.setMaxCount(5);
|
|
|
+ if (userProperty.getMaxCount() > 6) {
|
|
|
+ userProperty.setMaxCount(6);
|
|
|
+ }
|
|
|
+ userPropertyRepo.save(userProperty);
|
|
|
+ });
|
|
|
+
|
|
|
+ //vip
|
|
|
+ File file1 = new File("/Users/qiufangchao/Desktop/VIP.xlsx");
|
|
|
+ UploadDataListener<AirDropExcelDTO> listener1 = new UploadDataListener<>();
|
|
|
+ List<AirDropExcelDTO> dtos1 = EasyExcel.read(file1, AirDropExcelDTO.class, listener1)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+ Set<String> userIds3 = dtos1.stream()
|
|
|
+ .map(AirDropExcelDTO::getPhone)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ System.out.println(userIds3);
|
|
|
+ userIds3.forEach(id -> {
|
|
|
+ UserProperty userProperty = userPropertyRepo.findById(Long.parseLong(id))
|
|
|
+ .orElse(new UserProperty(Long.parseLong(id), 0));
|
|
|
+ userProperty.setMaxCount(userProperty.getMaxCount() + 1);
|
|
|
+ if (userProperty.getMaxCount() > 6) {
|
|
|
+ userProperty.setMaxCount(6);
|
|
|
}
|
|
|
userPropertyRepo.save(userProperty);
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+ //-1
|
|
|
+ Iterable<UserProperty> all = userPropertyRepo.findAll();
|
|
|
+ all.forEach(p -> {
|
|
|
+ if (p.getMaxCount() > 1) {
|
|
|
+ p.setMaxCount(p.getMaxCount() - 1);
|
|
|
+ userPropertyRepo.save(p);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void setById() {
|
|
|
- File file = new File("/Users/qiufangchao/Desktop/VIP.xlsx");
|
|
|
+ public void setByphone() {
|
|
|
+ File file = new File("/Users/qiufangchao/Desktop/mingdan.xlsx");
|
|
|
UploadDataListener<AirDropExcelDTO> listener = new UploadDataListener<>();
|
|
|
List<AirDropExcelDTO> dtos = EasyExcel.read(file, AirDropExcelDTO.class, listener)
|
|
|
.sheet()
|
|
|
.doReadSync();
|
|
|
- Set<String> userIds = dtos.stream()
|
|
|
+// List<Long> userIds = userRepo.findIdByPhones(dtos.stream()
|
|
|
+// .map(AirDropExcelDTO::getPhone)
|
|
|
+// .collect(Collectors.toSet()));
|
|
|
+// System.out.println(userIds);
|
|
|
+
|
|
|
+ List<User> users = userRepo.findByPhoneInAndDelFalse(dtos.stream()
|
|
|
.map(AirDropExcelDTO::getPhone)
|
|
|
- .collect(Collectors.toSet());
|
|
|
- System.out.println(userIds);
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+
|
|
|
+ Map<String, Long> userMap = users.stream().collect(Collectors.toMap(User::getPhone, User::getId));
|
|
|
+ dtos.forEach(dto -> {
|
|
|
+ Long aLong = userMap.get(dto.getPhone());
|
|
|
+ if (aLong == null) {
|
|
|
+ System.out.println(dto.getPhone());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
// userIds.forEach(id -> {
|
|
|
// UserProperty userProperty = userPropertyRepo.findById(id).orElse(new UserProperty(id, 0));
|
|
|
// userProperty.setMaxCount(userProperty.getMaxCount() + 1);
|
|
|
-// if (userProperty.getMaxCount() > 5) {
|
|
|
-// userProperty.setMaxCount(5);
|
|
|
+// if (userProperty.getMaxCount() > 6) {
|
|
|
+// userProperty.setMaxCount(6);
|
|
|
// }
|
|
|
// userPropertyRepo.save(userProperty);
|
|
|
// });
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void setById() {
|
|
|
+ File file = new File("/Users/qiufangchao/Desktop/VIP.xlsx");
|
|
|
+ UploadDataListener<AirDropExcelDTO> listener = new UploadDataListener<>();
|
|
|
+ List<AirDropExcelDTO> dtos = EasyExcel.read(file, AirDropExcelDTO.class, listener)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+ Set<String> userIds = dtos.stream()
|
|
|
+ .map(AirDropExcelDTO::getPhone)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ System.out.println(userIds);
|
|
|
+ userIds.forEach(id -> {
|
|
|
+
|
|
|
+ UserProperty userProperty = userPropertyRepo.findById(Long.parseLong(id))
|
|
|
+ .orElse(new UserProperty(Long.parseLong(id), 0));
|
|
|
+ userProperty.setMaxCount(userProperty.getMaxCount() + 1);
|
|
|
+ if (userProperty.getMaxCount() > 6) {
|
|
|
+ userProperty.setMaxCount(6);
|
|
|
+ }
|
|
|
+ userPropertyRepo.save(userProperty);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void statistic() {
|
|
|
Map<Long, Integer> map = new HashMap<>();
|
|
|
@@ -156,4 +224,16 @@ public class UserPropertyRepoTest extends ApplicationTests {
|
|
|
});
|
|
|
map.forEach((key, value) -> System.out.println(key + "," + value));
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test(){
|
|
|
+ Iterable<UserProperty> all = userPropertyRepo.findAll();
|
|
|
+ all.forEach(p -> {
|
|
|
+ if (p.getMaxCount() > 1) {
|
|
|
+ p.setMaxCount(p.getMaxCount() - 1);
|
|
|
+ userPropertyRepo.save(p);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|