package com.budwk.app; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ImportParams; import cn.hutool.core.codec.Base64; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.IdcardUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.digest.DigestUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.budwk.app.sys.models.*; import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupProjectSubject; import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupProjectSubjectMoney; import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupUser; import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupUserSelection; import com.budwk.app.zhgh.welfare.model.WelfareList; import com.budwk.app.zhgh.welfare.model.WelfareProjectSubjectOption; import com.budwk.app.zhgh.welfare.model.WelfareUserSelection; import com.budwk.app.zhgh.welfare.service.WelfareProjectService; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Workbook; import org.junit.Test; import org.junit.runner.RunWith; import org.nutz.boot.test.junit4.NbJUnit4Runner; import org.nutz.dao.Chain; import org.nutz.dao.Cnd; import org.nutz.dao.Dao; import org.nutz.dao.Sqls; import org.nutz.dao.entity.annotation.ColDefine; import org.nutz.dao.entity.annotation.Column; import org.nutz.dao.entity.annotation.Comment; import org.nutz.dao.sql.Sql; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.json.Json; import org.nutz.lang.Lang; import org.nutz.lang.util.NutMap; import org.nutz.mvc.annotation.At; import org.springframework.util.CollectionUtils; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDate; import java.time.ZoneId; import java.util.*; import java.util.stream.Collectors; @IocBean @RunWith(NbJUnit4Runner.class) public class WelfareTest { @Inject private Dao dao; @Inject private WelfareProjectService welfareService; @Test public void importPhysicalExamination() { Sql sql = Sqls.create(""" select u.* from temp_user_loginName t left join sys_user u on t.loginName=u.loginname where u.id is not null """); List nutMaps = welfareService.listMap(sql); List healthCheckupProjectSubjects = dao.query(HealthCheckupProjectSubject.class, Cnd.where(HealthCheckupProjectSubject::getProjectId, "=", "abbb89dec0244392ba2a19394cfc7a0a")); List healthCheckupProjectSubjectMoneyList = dao.query(HealthCheckupProjectSubjectMoney.class, Cnd.where(HealthCheckupProjectSubjectMoney::getProjectId, "=", "abbb89dec0244392ba2a19394cfc7a0a")); List physicalExaminationList = ExcelImportUtil.importExcel(new File("C:\\Users\\mayn\\Desktop\\1.xlsx"), PhysicalExamination.class, new ImportParams()); List userSelectionList = physicalExaminationList.stream().filter(e->StringUtils.isNotBlank(e.getLoginName())) .map(e -> { NutMap nutMap = nutMaps.stream().filter(v -> e.getLoginName().equals(v.getString("loginname"))).findFirst().orElse(null); HealthCheckupUserSelection userSelection = new HealthCheckupUserSelection(); if (ObjectUtil.isNotEmpty(nutMap)) { userSelection.setSelectUserId(nutMap.getString("id")); userSelection.setProjectId("abbb89dec0244392ba2a19394cfc7a0a"); HealthCheckupProjectSubject healthCheckupProjectSubject = healthCheckupProjectSubjects.stream() .filter(v -> e.getHealthExaminationHospital().equals(v.getOptionName())) .findFirst().orElse(null); if(ObjectUtil.isNotEmpty(healthCheckupProjectSubject)) { userSelection.setSubjectId(healthCheckupProjectSubject.getId()); } else { userSelection.setBz("医院不存在"); return userSelection; } List healthCheckupProjectSubjectMonies = healthCheckupProjectSubjectMoneyList.stream() .filter(v -> v.getSubjectId().equals(healthCheckupProjectSubject.getId())) .collect(Collectors.toList()); healthCheckupProjectSubjectMonies = healthCheckupProjectSubjectMonies.stream() .filter(v -> v.getMoney().compareTo(e.getMoney()) == 0 && v.getSettlementMoney().compareTo(e.getSettlementMoney()) == 0) .collect(Collectors.toList()); if(!CollectionUtils.isEmpty(healthCheckupProjectSubjectMonies)){ userSelection.setSubjectMoneyId(healthCheckupProjectSubjectMonies.get(0).getId()); userSelection.setMoney(healthCheckupProjectSubjectMonies.get(0).getMoney()); } else { userSelection.setSelectUserId(e.getLoginName()); userSelection.setBz("项目不存在"); return userSelection; } userSelection.setId(UUID.randomUUID().toString()); userSelection.setCampus(""); userSelection.setSelectTime(new Date()); userSelection.setBz(""); userSelection.setReceiveAddress(""); userSelection.setPostMethod("1"); return userSelection; } else { return null; } }).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); List healthCheckupUserSelections = userSelectionList.stream().filter(e -> StringUtils.isBlank(e.getId())).collect(Collectors.toList()); List collect = healthCheckupUserSelections.stream().map(HealthCheckupUserSelection::getSelectUserId).collect(Collectors.toList()); userSelectionList = userSelectionList.stream().filter(e-> StringUtils.isNotBlank(e.getId())).collect(Collectors.toList()); dao.insert(userSelectionList); } @Data public static class PhysicalExamination { @Excel(name = "工号") private String loginName; @Excel(name = "体检医院") private String healthExaminationHospital; @Excel(name = "套餐金额") private BigDecimal money; @Excel(name = "结算金额") private BigDecimal settlementMoney; } @Test public void importSelectUser() { List list = ExcelImportUtil.importExcel(new File("C:\\Users\\administrator\\Desktop\\匹配上生日.xlsx"), SelectUser.class, new ImportParams()); // 福利id String welfareId = "638c6bc84b384fd4a2f64c56faa6a130"; // 福利名单 Sql sql = Sqls.create(""" SELECT u.id, u.username AS userName, u.loginname AS loginName, u.mobile FROM `welfare_list` t1 LEFT JOIN sys_user u ON u.id = t1.userId WHERE t1.projectId = @projectId group by u.loginname """); sql.setParam("projectId", welfareId); List welfareLists = welfareService.listMap(sql); List loginNames = welfareLists.stream().map(v -> v.getString("loginName")).toList(); Map loginNameMap = welfareLists.stream().collect(Collectors.toMap(v -> v.getString("loginName"), v -> v)); // 筛选出本次导入的 List thisList = list.stream().filter(v -> StrUtil.isNotBlank(v.getLoginName()) && loginNames.contains(v.getLoginName())) .peek(v -> v.setLoginName(v.getLoginName().trim())) .toList(); System.out.println(thisList.size()); // 福利选项 List options = dao.query(WelfareProjectSubjectOption.class, Cnd.where(WelfareProjectSubjectOption::getWelfareId, "=", welfareId)); List selections = thisList.stream().map(v -> { WelfareUserSelection welfareUserSelection = new WelfareUserSelection(); welfareUserSelection.setSelectTime(new Date()); welfareUserSelection.setSelectUserId(loginNameMap.get(v.getLoginName()).getString("id")); welfareUserSelection.setSelectNum(1); if (StrUtil.isNotBlank(v.getMobile())) { welfareUserSelection.setMobile(v.getMobile()); } else { welfareUserSelection.setMobile(loginNameMap.get(v.getLoginName()).getString("mobile")); } welfareUserSelection.setWelfareId(welfareId); String optionId = options.stream().filter(option -> option.getOptionName().equals(v.getOptionName())).findFirst().map(option -> option.getId()).orElse(null); welfareUserSelection.setSelectOptionId(optionId); return welfareUserSelection; }).toList(); dao.insert(selections); } @Test public void deleteUser() { List list = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\Desktop\\新建文件夹 (2)\\蛋糕汇总表.xlsx"), SelectUser.class, new ImportParams()); List loginNames = list.stream().map(v -> v.getLoginName()).toList(); Sql sql = Sqls.create("select id from sys_user where loginname in (@loginname)"); sql.setParam("loginname", loginNames); sql.setCallback(Sqls.callback.strList()); dao.execute(sql); List ids = sql.getList(String.class); List welfareLists = dao.query(WelfareList.class, Cnd.NEW()); List welfareUserIds = welfareLists.stream().map(v -> v.getUserId()).toList(); List list1 = welfareUserIds.stream().filter(v -> !ids.contains(v)).toList(); System.out.println(list1.size()); //dao.clear(WelfareList.class, Cnd.where("userId", "not in", ids.stream().map(v -> v.getString("id")).toList())); } @Data public static class SelectUser { @Excel(name = "工号") private String loginName; @Excel(name = "姓名") private String userName; @Excel(name = "手机号码") private String mobile; @Excel(name = "选择物品") private String optionName; @Excel(name = "出生日期", importFormat = "yyyy-MM-dd", exportFormat = "yyyy-MM-dd") private Date birthday; } @Test public void fixData() throws IOException { List users = dao.query(Sys_user_source.class, Cnd.NEW().groupBy(Sys_user::getLoginname)); Map userMap = users.stream().filter(v -> v.getBirthday() != null).collect(Collectors.toMap(v -> v.getLoginname(), v -> v.getBirthday())); List allList = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\Desktop\\南京师范蛋糕卡\\蛋糕汇总表2.xlsx"), SelectUser.class, new ImportParams()); for (SelectUser selectUser : allList) { if (userMap.containsKey(selectUser.getLoginName())) { selectUser.setBirthday(userMap.get(selectUser.getLoginName())); } } Workbook workbook = ExcelExportUtil.exportExcel( new ExportParams("修改后数据", "Sheet1"), SelectUser.class, allList ); FileOutputStream fos = new FileOutputStream("C:\\Users\\jug\\Desktop\\南京师范蛋糕卡\\匹配上生日.xlsx"); workbook.write(fos); fos.close(); workbook.close(); } @Test public void importUser() { List allList = ExcelImportUtil.importExcel(new File("C:\\Users\\administrator\\Desktop\\匹配上生日.xlsx"), SelectUser.class, new ImportParams()); List list = allList.stream().filter(v -> StrUtil.isNotBlank(v.getLoginName())).toList(); List users = dao.query(Sys_user.class, Cnd.NEW()); Map userMap = users.stream().collect(Collectors.toMap(v -> v.getLoginname(), v -> v)); // 福利id String welfareId = "824f43e4286c4d96b8376368c2907be2"; int startMonth = 10; int endMonth = 12; List options = dao.query(WelfareProjectSubjectOption.class, Cnd.where(WelfareProjectSubjectOption::getWelfareId, "=", welfareId)); Map optionMap = options.stream().collect(Collectors.toMap(v -> v.getOptionName(), v -> v.getId())); // 福利名单 List 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) { 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 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()); 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 users = welfareService.listMap(sql); Map loginNameMap = users.stream().collect(Collectors.toMap(v -> v.getString("id"), v -> v)); List 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")); w.setPersonType(loginNameMap.get(w.getUserId()).getString("personType")); } dao.update(list, "welfareUnitName|welfareUnionId|welfareUnionName|personType"); // List userSelections = dao.query(WelfareUserSelection.class, Cnd.NEW()); // for (WelfareUserSelection w : userSelections) { // w.setMobile(loginNameMap.get(w.getSelectUserId()).getString("mobile")); // } // dao.update(userSelections, "mobile"); } @Test public void check() { List allList = ExcelImportUtil.importExcel(new File("C:\\Users\\administrator\\Desktop\\匹配上生日.xlsx"), SelectUser.class, new ImportParams()); List list = allList.stream().filter(v -> StrUtil.isNotBlank(v.getLoginName())).toList(); List 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 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 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 list1 = 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 list2 = list1.stream().map(v -> { Sys_user_role sysUserRole = new Sys_user_role(); sysUserRole.setRoleId("6d603b652abee584ba6274dc1fcee3bb"); sysUserRole.setUserId(v.getId()); return sysUserRole; }).toList(); dao.insert(list2); } @Test public void updateWelfareListX() { String[] loginNames = new String[]{"90892", "W11010", "90858", "W11004", "90847", "90849", "W11008", "W11002", "90862", "90861", "90881", "W11005", "W11009", "04409", "W11001", "90860", "W11003", "90859"}; Sql sql = Sqls.create(""" SELECT id, loginname, username, sex, idCard, birthday, personType, preparedBy, userState, unitId, unitName, unionId, unionName, member FROM vw_user WHERE loginname in (@loginname) """); sql.setParam("loginname", loginNames); List list = welfareService.listMap(sql); for (NutMap map : list) { System.out.println(map.getString("loginname") + ":" + map.getString("idCard")); } // 插入到福利名单表中 List welfareList = list.stream().map(user -> { WelfareList wl = new WelfareList(); String idCard = user.getString("idCard"); Short month = IdcardUtil.getMonthByIdCard(idCard); if (month <= 3) { wl.setProjectId("8ff1f9c1d6a547b4a54125efcb9a56b9"); } else if (month <= 6) { wl.setProjectId("db4f1454e27449459990213740f455b6"); } else if (month <= 9) { wl.setProjectId("638c6bc84b384fd4a2f64c56faa6a130"); } else if (month <= 12) { wl.setProjectId("824f43e4286c4d96b8376368c2907be2"); } wl.setUserId(user.getString("id")); wl.setWelfareUnitId(user.getString("unitId")); wl.setWelfareUnitName(user.getString("unitName")); wl.setWelfareUnionId(user.getString("unionId")); wl.setWelfareUnionName(user.getString("unionName")); wl.setPersonType(user.getString("personType")); wl.setPreparedBy(user.getString("preparedBy")); wl.setUserState(user.getString("userState")); return wl; }).toList(); dao.insert(welfareList); } @Test public void updateMember() { Sql sql = Sqls.create("select * from sys_user where userState = '在岗' or (preparedBy = '博士后' and postDoctoralJoinDate >= '2023-07-01')"); List list = welfareService.listMap(sql); dao.clear(Sys_user_role.class, Cnd.where(Sys_user_role::getRoleId, "=", "6d603b652abee584ba6274dc1fcee3bb")); dao.update(Sys_user.class, Chain.make("member", 0), Cnd.where("id", "is not", null)); List list2 = list.stream().map(v -> { Sys_user_role sysUserRole = new Sys_user_role(); sysUserRole.setRoleId("6d603b652abee584ba6274dc1fcee3bb"); sysUserRole.setUserId(v.getString("id")); return sysUserRole; }).toList(); dao.insert(list2); List ids = list.stream().map(v -> v.getString("id")).toList(); dao.update(Sys_user.class, Chain.make("member", 1), Cnd.where("id", "in", ids)); } @Test public void bsh() { String appId = "1926887238437818370"; String secret = "32df31fcf4fc43f9a647ee1f47134f36"; List allUsers = new ArrayList<>(); int skip = 0; int totalCount = 0; boolean firstRequest = true; do { long ts = System.currentTimeMillis(); String sign = Base64.encode(DigestUtil.md5Hex(appId + secret + ts, CharsetUtil.CHARSET_UTF_8)); HttpRequest httpRequest = HttpUtil.createPost("https://sjzcpt.nnu.edu.cn/cdsp/data-api/v2/DS0040"); httpRequest.header("Content-Type", "application/json"); httpRequest.header("appId", appId); httpRequest.header("timestamp", String.valueOf(ts)); httpRequest.header("sign", sign); HashMap reqBody = new HashMap<>(); reqBody.put("$count", true); reqBody.put("$skip", skip); reqBody.put("$top", 1000); httpRequest.body(JSONUtil.toJsonStr(reqBody)); String resBody = httpRequest.execute().body(); JSONObject entries = JSONUtil.parseObj(resBody); if (firstRequest) { totalCount = entries.getInt("@odata.count", 0); firstRequest = false; } JSONArray value = entries.getJSONArray("value"); if (!value.isEmpty()) { List list = value.stream().map(item -> (JSONObject) item).toList(); allUsers.addAll(list); skip += list.size(); } else { break; } } while (skip < totalCount); System.out.println(1); } @Test public void importMoneyMember() { // dao.clear(Sys_user_role.class, Cnd.where(Sys_user_role::getRoleId, "=", "6d603b652abee584ba6274dc1fcee3bb")); // dao.update(Sys_user.class, Chain.make("member", 0), Cnd.where("id", "is not", null)); // List list = dao.query(Sys_user.class, Cnd.where(Sys_user::getMember, "=", 1)); // List loginNames = list.stream().map(v -> v.getLoginname()).toList(); // // List excelList = ExcelImportUtil.importExcel(new File("C:\\Users\\administrator\\Desktop\\202506工会费统计3375人.xlsx"), Map.class, new ImportParams()); // // // for (Map map : excelList) { // String gh = (String) map.get("工号"); // if(!loginNames.contains(gh)) { // System.out.println(gh); // } // } // for (Map map : list) { // String gh = (String) map.get("工号"); // dao.update(Sys_user.class, Chain.make("member", 1), Cnd.where("loginname", "=", gh)); // Sys_user user = dao.fetch(Sys_user.class, Cnd.where("loginname", "=", gh)); // // if(user == null){ // System.out.println(gh); // continue; // } // // Sys_user_role sysUserRole = new Sys_user_role(); // sysUserRole.setRoleId("6d603b652abee584ba6274dc1fcee3bb"); // sysUserRole.setUserId(user.getId()); // dao.insert(sysUserRole); // } Sql sql = Sqls.create(""" select id from sys_user where username in ( "张荣","夏冬梅","吴秋芹","徐红","蒋丽华","石慧","王英","周蒨","杨亚","夏明秀","赵方圆","郑晓梅","周世菊","肖文敏","陆玉甜","刘佳丽","王程庆子","杨丽","王淼","鲁秀莲","李军","余国华","朱凌","魏堃","李兵","李军友","刘伊丽","金芳杰","殷霞","薛端阳","丁立","刘学云","吴磊","卞振宇","黄适","郝明勤","张凌","管红地","孟进","卢富霞","周福喜","苏金成","陈智瑜","付玥","姜丹","韦益勤","李家保","张艳红","赵青","肖凡","鲁丹丹","和青","贺平","俞相平","严庆普","孟庆霖","罗连英","凌晓民","杜祥浩","王斌","金洪亮","于长翔","李国龙","平向阳","袁秀虎","吴家尧","章爱明","刘德兆","郭年顺","陈金莉","张亮","平向波","王林","王洪喜","吕长斌","金福来","张志婷","杨林","吕六娣","朱庆华","杨金全","刘霞","周宝兰","于小琴","薛颜","凌桂芳","陈万国","季莉","钱卫","黄朝娟","杨海峰","左晓辉","刘凤云","彭启忠","魏树元","张有进","翁念龙","朱宇","吴双林","吴春勇","胡兰平","王慊","宛嘉") and username not in ('徐红', '陆玉甜', '王程庆子', '鲁秀莲', '李军', '余国华', '刘伊丽', '刘学云', '郝明勤', '孟进', '卢富霞', '周福喜', '付玥', '李家保', '和青', '贺平', '俞相平', '严庆普', '罗连英', '李国龙', '吴家尧', '王洪喜', '张志婷', '杨林', '周宝兰', '凌桂芳', '黄朝娟', '刘凤云', '胡兰平') and loginname not in ('Y94000004', 'Z0811', 'Y27000299', 'W27071', '53139', 'Y27001708', 'Y33000003', 'W27070', 'Y27001509', 'Y86002837', 'W26003', 'W22001', 'Y69000065', 'Y86000529', '72040', 'W27042') """); List list = welfareService.listMap(sql); List ids = list.stream().map(v -> v.getString("id")).toList(); for (String id : ids) { dao.update(Sys_user.class, Chain.make("member", 1), Cnd.where("id", "=", id)); Sys_user_role sysUserRole = new Sys_user_role(); sysUserRole.setRoleId("6d603b652abee584ba6274dc1fcee3bb"); sysUserRole.setUserId(id); dao.insert(sysUserRole); } } @Test public void updateWelfareListPlus() { // // 第三季度 // Sql sql = Sqls.create("SELECT id FROM sys_user where preparedBy = '博士后' and postDoctoralJoinDate < '2023-07-01'"); // List list = welfareService.listMap(sql); // // for (NutMap nutMap : list) { // dao.update(Sys_user.class, Chain.make("member", 0), Cnd.where("id", "=", nutMap.getString("id"))); // dao.clear(Sys_user_role.class,Cnd.where(Sys_user_role::getUserId, "=", nutMap.getString("id")).and(Sys_user_role::getRoleId,"=","6d603b652abee584ba6274dc1fcee3bb")); // // } List list = new ArrayList<>(); // list.add(new NutMap().addv("gh", "90954").addv("dw", "100587")); // list.add(new NutMap().addv("gh", "90953").addv("dw", "100800")); // list.add(new NutMap().addv("gh", "90976").addv("dw", "100605")); // list.add(new NutMap().addv("gh", "90960").addv("dw", "100564")); // list.add(new NutMap().addv("gh", "90942").addv("dw", "100387")); // list.add(new NutMap().addv("gh", "90958").addv("dw", "100546")); list.add(new NutMap().addv("gh", "90937").addv("dw", "100800")); for (NutMap row : list) { String gh = row.getString("gh"); String dw = row.getString("dw"); Sys_user user = dao.fetch(Sys_user.class, Cnd.where(Sys_user::getLoginname, "=", gh)); dao.update(Sys_user.class,Chain.make("unitid",dw),Cnd.where("id","=",user.getId())); Sys_unit unit = dao.fetch(Sys_unit.class, dw); Sys_union union = dao.fetch(Sys_union.class, unit.getUnionId()); WelfareList welfareList = dao.fetch(WelfareList.class, Cnd.where(WelfareList::getUserId, "=", user.getId())); welfareList.setWelfareUnitId(dw); welfareList.setWelfareUnitName(unit.getName()); welfareList.setWelfareUnionId(union.getId()); welfareList.setWelfareUnionName(union.getName()); dao.update(welfareList); } } }