This commit is contained in:
那些花儿
2025-06-20 09:24:39 +08:00
parent bfa9aba489
commit bc5eb03f7f
23 changed files with 1585 additions and 834 deletions
+72 -9
View File
@@ -30,6 +30,9 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -170,17 +173,77 @@ public class WelfareTest {
List<SelectUser> allList = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\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 = "a93b1694e41f49f3b9e6364e36bf48cd";
// 找出月份等于1、2、3的
// list.stream().filter(v -> v.getBirthday().getMonth() + 1 <= 3).map(v -> {
// WelfareList welfareList = new WelfareList();
// welfareList.setProjectId(welfareId);
//
//
//
// })
String welfareId = "6b6b438811044d7180b76facaebbe2f3";
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 -> {
WelfareList welfareList = new WelfareList();
welfareList.setProjectId(welfareId);
if (userMap.get(v.getLoginName()) != null) {
welfareList.setUserId(userMap.get(v.getLoginName()).getId());
welfareList.setWelfareUnitId(userMap.get(v.getLoginName()).getUnitId());
welfareList.setPersonType(userMap.get(v.getLoginName()).getPersonType());
welfareList.setUserState(userMap.get(v.getLoginName()).getUserState());
welfareList.setPreparedBy(userMap.get(v.getLoginName()).getPreparedBy());
} else {
System.out.println(v.getLoginName());
}
return welfareList;
}).toList();
// 选择数据
List<WelfareUserSelection> selections = list.stream().filter(v -> v.getBirthday().getMonth() + 1 > 6 && v.getBirthday().getMonth() + 1 <= 9).map(v -> {
WelfareUserSelection selection = new WelfareUserSelection();
selection.setWelfareId(welfareId);
selection.setSelectUserId(userMap.get(v.getLoginName()).getId());
selection.setSelectOptionId(optionMap.get(v.getOptionName()));
selection.setSelectNum(1);
LocalDate localDate = LocalDate.of(2024, 12, 15);
Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
selection.setSelectTime(date);
selection.setMobile(v.getMobile());
return selection;
}).toList();
System.out.println(welfareLists.size());
System.out.println(selections.size());
dao.insert(welfareLists);
dao.insert(selections);
}
@Test
public void updateWelfareList() {
Sql sql = Sqls.create("select * from vw_user");
List<NutMap> users = welfareService.listMap(sql);
Map<String, NutMap> loginNameMap = users.stream().collect(Collectors.toMap(v -> v.getString("id"), v -> v));
List<WelfareList> list = dao.query(WelfareList.class, Cnd.NEW());
for (WelfareList w : list) {
w.setWelfareUnitName(loginNameMap.get(w.getUserId()).getString("unitName"));
w.setWelfareUnionId(loginNameMap.get(w.getUserId()).getString("unionId"));
w.setWelfareUnionName(loginNameMap.get(w.getUserId()).getString("unionName"));
}
dao.update(list, "welfareUnitName|welfareUnionId|welfareUnionName");
List<WelfareUserSelection> userSelections = dao.query(WelfareUserSelection.class, Cnd.NEW());
for (WelfareUserSelection w : userSelections) {
w.setMobile(loginNameMap.get(w.getSelectUserId()).getString("mobile"));
}
dao.update(userSelections, "mobile");
}
}