This commit is contained in:
server
2025-06-30 14:40:59 +08:00
parent cfa2b34ee8
commit 69d3ce0744
33 changed files with 1703 additions and 292 deletions
+1
View File
@@ -205,6 +205,7 @@ public class JugTest {
} while (skip < totalCount);
Files.write(new File("C:\\Users\\administrator\\Desktop\\博士后.txt"),allUsers);
System.out.println(allUsers.size());
}
+6 -6
View File
@@ -34,12 +34,12 @@ public class Test {
String body = httpRequest.execute().body();
System.out.println(body);
JSONObject entries = JSONUtil.parseObj(body);
JSONArray value = entries.getJSONArray("value");
for (Object o : value) {
JSONObject jsonObject = (JSONObject) o;
}
// JSONObject entries = JSONUtil.parseObj(body);
// JSONArray value = entries.getJSONArray("value");
//
// for (Object o : value) {
// JSONObject jsonObject = (JSONObject) o;
// }
+248 -8
View File
@@ -5,10 +5,17 @@ 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.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 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.welfare.model.WelfareList;
import com.budwk.app.zhgh.welfare.model.WelfareProjectSubjectOption;
import com.budwk.app.zhgh.welfare.model.WelfareUserSelection;
@@ -18,12 +25,15 @@ 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.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;
@@ -33,10 +43,7 @@ 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;
import java.util.*;
import java.util.stream.Collectors;
@IocBean
@@ -288,7 +295,7 @@ public class WelfareTest {
@Test
public void setMember() {
List<Sys_user> list = dao.query(Sys_user.class, Cnd.where("loginname", "!=", "superadmin").and("userState","=","在岗"));
List<Sys_user> list = dao.query(Sys_user.class, Cnd.where("loginname", "!=", "superadmin").and("userState", "=", "在岗"));
for (Sys_user user : list) {
user.setMember(true);
}
@@ -308,5 +315,238 @@ public class WelfareTest {
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<NutMap> list = welfareService.listMap(sql);
for (NutMap map : list) {
System.out.println(map.getString("loginname") + ":" + map.getString("idCard"));
}
// 插入到福利名单表中
List<WelfareList> 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<NutMap> 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<Sys_user_role> 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<String> 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<JSONObject> 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<String, Object> 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<JSONObject> 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<Sys_user> list = dao.query(Sys_user.class, Cnd.where(Sys_user::getMember, "=", 1));
// List<String> loginNames = list.stream().map(v -> v.getLoginname()).toList();
//
// List<Map> 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<NutMap> list = welfareService.listMap(sql);
List<String> 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<NutMap> 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<NutMap> 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);
}
}
}