..
This commit is contained in:
@@ -7,6 +7,7 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.models.Sys_user_role;
|
||||
import com.budwk.app.sys.models.Sys_user_source;
|
||||
import com.budwk.app.zhgh.welfare.model.WelfareList;
|
||||
import com.budwk.app.zhgh.welfare.model.WelfareProjectSubjectOption;
|
||||
@@ -49,9 +50,9 @@ public class WelfareTest {
|
||||
|
||||
@Test
|
||||
public void importSelectUser() {
|
||||
List<SelectUser> list = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\Desktop\\新建文件夹 (2)\\蛋糕汇总表.xlsx"), SelectUser.class, new ImportParams());
|
||||
List<SelectUser> list = ExcelImportUtil.importExcel(new File("C:\\Users\\administrator\\Desktop\\匹配上生日.xlsx"), SelectUser.class, new ImportParams());
|
||||
// 福利id
|
||||
String welfareId = "6b6b438811044d7180b76facaebbe2f3";
|
||||
String welfareId = "638c6bc84b384fd4a2f64c56faa6a130";
|
||||
|
||||
// 福利名单
|
||||
Sql sql = Sqls.create("""
|
||||
@@ -170,19 +171,22 @@ public class WelfareTest {
|
||||
|
||||
@Test
|
||||
public void importUser() {
|
||||
List<SelectUser> allList = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\Desktop\\南京师范蛋糕卡\\匹配上生日.xlsx"), SelectUser.class, new ImportParams());
|
||||
List<SelectUser> allList = ExcelImportUtil.importExcel(new File("C:\\Users\\administrator\\Desktop\\匹配上生日.xlsx"), SelectUser.class, new ImportParams());
|
||||
List<SelectUser> list = allList.stream().filter(v -> StrUtil.isNotBlank(v.getLoginName())).toList();
|
||||
|
||||
List<Sys_user> users = dao.query(Sys_user.class, Cnd.NEW());
|
||||
Map<String, Sys_user> userMap = users.stream().collect(Collectors.toMap(v -> v.getLoginname(), v -> v));
|
||||
|
||||
// 福利id
|
||||
String welfareId = "6b6b438811044d7180b76facaebbe2f3";
|
||||
String welfareId = "824f43e4286c4d96b8376368c2907be2";
|
||||
int startMonth = 10;
|
||||
int endMonth = 12;
|
||||
|
||||
List<WelfareProjectSubjectOption> options = dao.query(WelfareProjectSubjectOption.class, Cnd.where(WelfareProjectSubjectOption::getWelfareId, "=", welfareId));
|
||||
Map<String, String> optionMap = options.stream().collect(Collectors.toMap(v -> v.getOptionName(), v -> v.getId()));
|
||||
|
||||
// 福利名单
|
||||
List<WelfareList> welfareLists = list.stream().filter(v -> v.getBirthday().getMonth() + 1 > 6 && v.getBirthday().getMonth() + 1 <= 9).map(v -> {
|
||||
List<WelfareList> welfareLists = list.stream().filter(v -> v.getBirthday().getMonth() + 1 >= startMonth && v.getBirthday().getMonth() + 1 <= endMonth).map(v -> {
|
||||
WelfareList welfareList = new WelfareList();
|
||||
welfareList.setProjectId(welfareId);
|
||||
if (userMap.get(v.getLoginName()) != null) {
|
||||
@@ -198,7 +202,7 @@ public class WelfareTest {
|
||||
}).toList();
|
||||
|
||||
// 选择数据
|
||||
List<WelfareUserSelection> selections = list.stream().filter(v -> v.getBirthday().getMonth() + 1 > 6 && v.getBirthday().getMonth() + 1 <= 9).map(v -> {
|
||||
List<WelfareUserSelection> selections = list.stream().filter(v -> v.getBirthday().getMonth() + 1 >= startMonth && v.getBirthday().getMonth() + 1 <= endMonth).map(v -> {
|
||||
WelfareUserSelection selection = new WelfareUserSelection();
|
||||
selection.setWelfareId(welfareId);
|
||||
selection.setSelectUserId(userMap.get(v.getLoginName()).getId());
|
||||
@@ -244,6 +248,64 @@ public class WelfareTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void check() {
|
||||
List<SelectUser> allList = ExcelImportUtil.importExcel(new File("C:\\Users\\administrator\\Desktop\\匹配上生日.xlsx"), SelectUser.class, new ImportParams());
|
||||
List<SelectUser> list = allList.stream().filter(v -> StrUtil.isNotBlank(v.getLoginName())).toList();
|
||||
|
||||
List<String> loginNames = list.stream().map(v -> v.getLoginName()).toList();
|
||||
|
||||
|
||||
Sql userSql = Sqls.create("select loginname from sys_user");
|
||||
userSql.setCallback(Sqls.callback.strList());
|
||||
dao.execute(userSql);
|
||||
List<String> ss = userSql.getList(String.class);
|
||||
|
||||
for (String loginName : loginNames) {
|
||||
if (!ss.contains(loginName)) {
|
||||
System.out.println(loginName);
|
||||
}
|
||||
}
|
||||
|
||||
for (SelectUser selectUser : allList) {
|
||||
int month = selectUser.getBirthday().getMonth();
|
||||
System.out.println(month);
|
||||
}
|
||||
|
||||
long count = allList.stream().filter(v -> v.getBirthday().getMonth() + 1 >= 1 && v.getBirthday().getMonth() <= 3).count();
|
||||
long count2 = allList.stream().filter(v -> v.getBirthday().getMonth() + 1 >= 4 && v.getBirthday().getMonth() <= 6).count();
|
||||
long count3 = allList.stream().filter(v -> v.getBirthday().getMonth() + 1 >= 7 && v.getBirthday().getMonth() <= 9).count();
|
||||
|
||||
System.out.println(count);
|
||||
System.out.println(count2);
|
||||
System.out.println(count3);
|
||||
|
||||
System.out.println(count + count2 + count3);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setMember() {
|
||||
// List<Sys_user> list = dao.query(Sys_user.class, Cnd.where("loginname", "!=", "superadmin").and("userState","=","在岗"));
|
||||
// for (Sys_user user : list) {
|
||||
// user.setMember(true);
|
||||
// }
|
||||
// dao.update(list, "member");
|
||||
|
||||
List<Sys_user> list = dao.query(Sys_user.class, Cnd.where(Sys_user::getMember, "=", 1));
|
||||
|
||||
dao.clear(Sys_user_role.class, Cnd.where(Sys_user_role::getRoleId, "=", "6d603b652abee584ba6274dc1fcee3bb"));
|
||||
|
||||
List<Sys_user_role> list1 = list.stream().map(v -> {
|
||||
Sys_user_role sysUserRole = new Sys_user_role();
|
||||
sysUserRole.setRoleId("6d603b652abee584ba6274dc1fcee3bb");
|
||||
sysUserRole.setUserId(v.getId());
|
||||
return sysUserRole;
|
||||
}).toList();
|
||||
|
||||
dao.insert(list1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user