639 lines
27 KiB
Java
639 lines
27 KiB
Java
package io.v.nutz;
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
import cn.hutool.core.date.DateUnit;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import io.v.nutz.base.service.BaseService;
|
|
import io.v.nutz.base.utils.MsgApi;
|
|
import io.v.nutz.base.utils.Roles;
|
|
import io.v.nutz.sys.models.Sys_unit;
|
|
import io.v.nutz.sys.models.Sys_user;
|
|
import io.v.nutz.sys.models.Sys_user_role;
|
|
import io.v.nutz.sys.services.SysLocalProcessService;
|
|
import io.v.nutz.web.commons.base.Globals;
|
|
import io.v.nutz.web.commons.utils.ShiroUtil;
|
|
import io.v.nutz.zhgh.activity.models.ActivityUserScope;
|
|
import io.v.nutz.zhgh.data.model.UserSource;
|
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkStep;
|
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
|
import io.v.nutz.zhgh.medicalMutualAidFund.model.MedicalMutualAidFund;
|
|
import io.v.nutz.zhgh.proposal.constants.ProposalToDoHandler;
|
|
import io.v.nutz.zhgh.proposal.models.ProposalReply;
|
|
import io.v.nutz.zhgh.proposal.services.ProposalCommonService;
|
|
import io.v.nutz.zhgh.welfare.model.WelfareList;
|
|
import io.v.nutz.zhgh.welfare.model.WelfareUserSelection;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Data;
|
|
import lombok.NoArgsConstructor;
|
|
import org.apache.shiro.crypto.hash.Sha256Hash;
|
|
import org.apache.shiro.util.ByteSource;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.nutz.aop.interceptor.ioc.TransAop;
|
|
import org.nutz.boot.NbApp;
|
|
import org.nutz.boot.starter.logback.exts.loglevel.LoglevelProperty;
|
|
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.Record;
|
|
import org.nutz.dao.sql.Sql;
|
|
import org.nutz.dao.util.Daos;
|
|
import org.nutz.integration.jedis.RedisService;
|
|
import org.nutz.ioc.aop.Aop;
|
|
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.random.R;
|
|
import org.nutz.lang.util.NutMap;
|
|
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.net.URLEncoder;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Paths;
|
|
import java.text.DecimalFormat;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.stream.Collectors;
|
|
|
|
@IocBean
|
|
@RunWith(NbJUnit4Runner.class)
|
|
public class JugTest {
|
|
|
|
@Inject
|
|
private Dao dao;
|
|
|
|
@Test
|
|
public void t01() throws IOException {
|
|
String json = new String(Files.readAllBytes(Paths.get("C:\\Users\\Administrator\\Desktop\\unit.json")));
|
|
NutMap nutMap = Json.fromJson(NutMap.class, json);
|
|
NutMap data = nutMap.getAs("data", NutMap.class);
|
|
List<NutMap> units = data.getAsList("Rows", NutMap.class);
|
|
System.out.println(units);
|
|
|
|
List<Sys_unit> collect = units.stream().map(v -> {
|
|
Sys_unit sys_unit = new Sys_unit();
|
|
sys_unit.setName(v.getString("mc"));
|
|
sys_unit.setId(v.getString("dm"));
|
|
return sys_unit;
|
|
}).collect(Collectors.toList());
|
|
dao.insert(collect);
|
|
}
|
|
|
|
@Test
|
|
public void importMember() {
|
|
dao.update(Sys_user.class, Chain.make("member", 0), Cnd.where("member", "=", 1));
|
|
dao.clear(Sys_user_role.class, Cnd.where("roleid", "=", Roles.MEMBER));
|
|
|
|
List<User> users = ExcelImportUtil.importExcel(new File("C:\\Users\\Administrator\\Desktop\\202404江南大学会员名单.xlsx"), User.class, new ImportParams());
|
|
List<String> loginNames = users.stream().map(v -> v.getLoginName()).collect(Collectors.toList());
|
|
dao.update(Sys_user.class, Chain.make("member", 1), Cnd.where("loginname", "in", loginNames));
|
|
|
|
Sql sql = Sqls.queryString(Sqls.create("select id from sys_user where loginname in (@loginnames)").setParam("loginnames", loginNames).toString());
|
|
dao.execute(sql);
|
|
List<String> ids = sql.getList(String.class);
|
|
|
|
List<Sys_user_role> sys_user_roles = ids.stream().map(v -> {
|
|
Sys_user_role sys_user_role = new Sys_user_role();
|
|
sys_user_role.setRoleId(Roles.MEMBER);
|
|
sys_user_role.setUserId(v);
|
|
return sys_user_role;
|
|
}).collect(Collectors.toList());
|
|
dao.insert(sys_user_roles);
|
|
}
|
|
|
|
@Test
|
|
public void importWelfareMember() {
|
|
dao.update(Sys_user.class, Chain.make("welfareMember", 0), Cnd.where("welfareMember", "=", 1));
|
|
dao.clear(Sys_user_role.class, Cnd.where("roleid", "=", Roles.WELFARE_MEMBER));
|
|
|
|
List<User> users = ExcelImportUtil.importExcel(new File("C:\\Users\\Administrator\\Desktop\\202404江南大学会员名单.xlsx"), User.class, new ImportParams());
|
|
List<String> loginNames = users.stream().map(v -> v.getLoginName()).collect(Collectors.toList());
|
|
dao.update(Sys_user.class, Chain.make("welfareMember", 1), Cnd.where("loginname", "in", loginNames));
|
|
|
|
Sql sql = Sqls.queryString(Sqls.create("select id from sys_user where loginname in (@loginnames)").setParam("loginnames", loginNames).toString());
|
|
dao.execute(sql);
|
|
List<String> ids = sql.getList(String.class);
|
|
|
|
List<Sys_user_role> sys_user_roles = ids.stream().map(v -> {
|
|
Sys_user_role sys_user_role = new Sys_user_role();
|
|
sys_user_role.setRoleId(Roles.WELFARE_MEMBER);
|
|
sys_user_role.setUserId(v);
|
|
return sys_user_role;
|
|
}).collect(Collectors.toList());
|
|
dao.insert(sys_user_roles);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Test
|
|
public void t03() {
|
|
List<User> users = ExcelImportUtil.importExcel(new File("C:\\Users\\Administrator\\Desktop\\202404江南大学会员名单.xlsx"), User.class, new ImportParams());
|
|
List<String> loginNames = users.stream().map(v -> v.getLoginName()).collect(Collectors.toList());
|
|
|
|
Sql sql = Sqls.queryString(Sqls.create("select loginname from sys_user").toString());
|
|
dao.execute(sql);
|
|
List<String> db_loginname = sql.getList(String.class);
|
|
|
|
List<String> collect = loginNames.stream().filter(v -> !db_loginname.contains(v)).collect(Collectors.toList());
|
|
for (String s : collect) {
|
|
System.out.println(s);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public static class User {
|
|
@Excel(name = "工号")
|
|
private String loginName;
|
|
}
|
|
|
|
|
|
@Test
|
|
public void memberRoles() {
|
|
dao.clear(Sys_user_role.class, Cnd.where("roleid", "=", Roles.MEMBER));
|
|
Sql sql = Sqls.queryString("select id from sys_user where member=1");
|
|
dao.execute(sql);
|
|
List<String> ids = sql.getList(String.class);
|
|
List<Sys_user_role> userRoles = ids.stream().map(v -> {
|
|
Sys_user_role sys_user_role = new Sys_user_role();
|
|
sys_user_role.setUserId(v);
|
|
sys_user_role.setRoleId(Roles.MEMBER);
|
|
return sys_user_role;
|
|
}).collect(Collectors.toList());
|
|
dao.insert(userRoles);
|
|
|
|
/* dao.clear(Sys_user_role.class, Cnd.where("roleid", "=", Roles.WELFARE_MEMBER));
|
|
Sql sql = Sqls.queryString("select id from sys_user where welfareMember=1");
|
|
dao.execute(sql);
|
|
List<String> ids = sql.getList(String.class);
|
|
List<Sys_user_role> userRoles = ids.stream().map(v -> {
|
|
Sys_user_role sys_user_role = new Sys_user_role();
|
|
sys_user_role.setUserId(v);
|
|
sys_user_role.setRoleId(Roles.WELFARE_MEMBER);
|
|
return sys_user_role;
|
|
}).collect(Collectors.toList());
|
|
dao.insert(userRoles);*/
|
|
}
|
|
|
|
@Test
|
|
public void test() {
|
|
List<UserSource> list = dao.query(UserSource.class, Cnd.where("unitid", "=", "51100"));
|
|
list.forEach(l -> {
|
|
dao.update(Sys_user.class, Chain.make("unitid", "51100"), Cnd.where("loginname", "=", l.getLoginname()));
|
|
});
|
|
}
|
|
|
|
@Test
|
|
public void t04() {
|
|
List<MedicalMutualAidFund> list = dao.query(MedicalMutualAidFund.class, Cnd.NEW());
|
|
for (MedicalMutualAidFund medicalMutualAidFund : list) {
|
|
String loginName = medicalMutualAidFund.getLoginName();
|
|
Sys_user user = dao.fetch(Sys_user.class, Cnd.where("loginName", "=", loginName));
|
|
dao.update(MedicalMutualAidFund.class, Chain.make("userName", user.getUsername()), Cnd.where("id", "=", medicalMutualAidFund.getId()));
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Aop(TransAop.READ_COMMITTED)
|
|
public void t05() {
|
|
List<OtherUser> users = ExcelImportUtil.importExcel(new File("C:\\Users\\Administrator\\Desktop\\新建 XLSX 工作表 (2).xlsx"), OtherUser.class, new ImportParams());
|
|
System.out.println(users);
|
|
List<Sys_user> initUsers = users.stream().map(v -> {
|
|
Sys_user user = new Sys_user();
|
|
String salt = R.UU32();
|
|
user.setId(R.UU32());
|
|
user.setSalt(salt);
|
|
user.setPassword(R.UU16());
|
|
user.setPassword(new Sha256Hash(user.getPassword(), ByteSource.Util.bytes(salt), 1024).toHex());
|
|
user.setLoginPjax(true);
|
|
user.setMenuTheme("left");
|
|
user.setLoginCount(0);
|
|
user.setMember(0);
|
|
user.setWelfareMember(1);
|
|
user.setRetired(false);
|
|
user.setUnitid(v.getUnitid());
|
|
user.setLoginname(v.getLoginname());
|
|
user.setUsername(v.getUsername());
|
|
user.setPersonType("其他类");
|
|
return user;
|
|
}).collect(Collectors.toList());
|
|
dao.insert(initUsers);
|
|
List<String> userIds = initUsers.stream().map(v -> v.getId()).collect(Collectors.toList());
|
|
|
|
dao.clear("sys_user_role", Cnd.where("userid", "in", userIds).and("roleId", "=", Roles.WELFARE_MEMBER));
|
|
List<Sys_user_role> sysUserRoles = new ArrayList<>();
|
|
for (String userId : userIds) {
|
|
Sys_user_role sysUserRole = new Sys_user_role();
|
|
sysUserRole.setUserId(userId);
|
|
sysUserRole.setRoleId(Roles.WELFARE_MEMBER);
|
|
sysUserRoles.add(sysUserRole);
|
|
}
|
|
dao.insert(sysUserRoles);
|
|
}
|
|
|
|
@Data
|
|
public static class OtherUser {
|
|
|
|
@Excel(name = "工号")
|
|
private String loginname;
|
|
|
|
@Excel(name = "单位")
|
|
private String unitname;
|
|
|
|
@Excel(name = "单位id")
|
|
private String unitid;
|
|
|
|
@Excel(name = "姓名")
|
|
private String username;
|
|
|
|
}
|
|
|
|
@Inject
|
|
private FitnessWalkCommonService fitnessWalkCommonService;
|
|
|
|
@Inject
|
|
private BaseService baseService;
|
|
|
|
@Test
|
|
public void t033() {
|
|
String activityId = "63ca5b136625b7d808580dd258423e53";
|
|
String userId = "sbmdbk1dc2givp006onbpvs8nu";
|
|
|
|
NutMap resultMap = NutMap.NEW();
|
|
|
|
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
|
//计步的抽奖模式 everyday custom
|
|
String lotteryMode = activity.getLotteryMode();
|
|
if ("everyday".equals(lotteryMode)) {
|
|
FitnessWalkActivity.DayLotteryRule dayLotteryRule = activity.getDayLotteryRule();
|
|
//每日抽奖资格步数
|
|
Integer lotteryQualificationStep = dayLotteryRule.getLotteryQualificationStep();
|
|
|
|
FitnessWalkStep userWalkStep = baseService.dao().fetch(FitnessWalkStep.class, Cnd.where("userId", "=", userId)
|
|
.and("DATE( applyDate )", "=", DateUtil.today()).and("activityId", "=", activityId));
|
|
|
|
int complianceDay = baseService.dao().count(FitnessWalkStep.class, Cnd.where("userId", "=", userId)
|
|
.and("DATE( applyDate )", "=", DateUtil.today()).and("activityId", "=", activityId)
|
|
.and("step", ">", lotteryQualificationStep));
|
|
|
|
Integer thisDayStep = userWalkStep.getStep();
|
|
|
|
BigDecimal lotteryQualificationStepBig = new BigDecimal(lotteryQualificationStep);
|
|
BigDecimal thisDayStepBig = new BigDecimal(thisDayStep);
|
|
//达标的小数,保留四位
|
|
BigDecimal divide = thisDayStepBig.divide(lotteryQualificationStepBig, 4, RoundingMode.HALF_UP);
|
|
BigDecimal percentValue = divide.multiply(new BigDecimal("100"));
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.##"); // 格式化为两位小数
|
|
//百分数
|
|
String formattedPercent = decimalFormat.format(percentValue);
|
|
|
|
long betweenDay = DateUtil.date(activity.getStartTime()).between(DateUtil.date(activity.getEndTime()), DateUnit.DAY);
|
|
NutMap map = new NutMap();
|
|
map.setv("mode", "everyDayLottery");
|
|
//当前达标步数
|
|
map.setv("userStep", thisDayStep);
|
|
//达标总步数
|
|
map.setv("complianceSumStep", lotteryQualificationStep);
|
|
//达标比例
|
|
map.setv("complianceProportion", Integer.parseInt(formattedPercent));
|
|
//活动天数
|
|
map.setv("betweenDay", betweenDay);
|
|
//达标天数
|
|
map.setv("complianceDay", complianceDay);
|
|
resultMap.addv("everyDayLotteryMode", map);
|
|
} else if ("custom".equals(lotteryMode)) {
|
|
List<FitnessWalkActivity.CustomLotteryRule> customLotteryRules = activity.getCustomLotteryRules();
|
|
List<FitnessWalkStep> userWalkSteps = baseService.dao().
|
|
query(FitnessWalkStep.class, Cnd.where("userId", "=", userId)
|
|
.and("activityId", "=", activityId)
|
|
.and("DATE(applyDate)", ">=", DateUtil.format(DateUtil.date(activity.getStartTime()), "yyyy-MM-dd"))
|
|
.and("DATE(applyDate)", "<=", DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"))
|
|
.groupBy("applyDate")
|
|
);
|
|
|
|
List<NutMap> result = new ArrayList<>();
|
|
|
|
for (FitnessWalkActivity.CustomLotteryRule rule : customLotteryRules) {
|
|
NutMap nutMap = NutMap.NEW();
|
|
|
|
List<FitnessWalkStep> partSteps = userWalkSteps.stream()
|
|
.filter(s -> (DateUtil.compare(s.getApplyDate(), rule.getStartDate()) >= 0 && DateUtil.compare(s.getApplyDate(), rule.getEndDate()) <= 0))
|
|
.collect(Collectors.toList());
|
|
|
|
Integer lotteryQualificationDay = rule.getLotteryQualificationDay();
|
|
Integer lotteryQualificationStep = rule.getLotteryQualificationStep();
|
|
|
|
if (lotteryQualificationDay != null && lotteryQualificationStep != null) {
|
|
//每天步数
|
|
nutMap.put("mode", "customLotteryEveryDayStepMode");
|
|
//用户总达标步数
|
|
nutMap.put("userSumStep", partSteps.stream().filter(s -> DateUtil.compare(s.getApplyDate(), new Date(), "yyyy-MM-dd") == 0).findFirst().map(s -> s.getStep()).orElse(0));
|
|
//今天达标步数
|
|
nutMap.put("complianceStep", lotteryQualificationStep);
|
|
//总达标步数
|
|
nutMap.put("complianceSumStep", lotteryQualificationDay * lotteryQualificationStep);
|
|
//用户当前达标总天数
|
|
nutMap.put("userComplianceSumDay", partSteps.stream().filter(s -> s.getStep() > lotteryQualificationStep).count());
|
|
//总达标天数
|
|
nutMap.put("complianceSumDay", lotteryQualificationDay);
|
|
//开始时间
|
|
nutMap.put("startDate", rule.getStartDate());
|
|
//结束时间
|
|
nutMap.put("endDate", rule.getEndDate());
|
|
} else if (lotteryQualificationDay == null && lotteryQualificationStep != null) {
|
|
//总步数
|
|
nutMap.put("mode", "customLotterySumStepMode");
|
|
//用户总达标步数
|
|
nutMap.put("userSumStep", partSteps.stream().mapToInt(s -> s.getStep()).sum());
|
|
//总达标步数
|
|
nutMap.put("complianceSumStep", lotteryQualificationStep);
|
|
}
|
|
result.add(nutMap);
|
|
}
|
|
resultMap.addv("customLotteryMode", result);
|
|
}
|
|
System.out.println(resultMap);
|
|
System.out.println(1);
|
|
}
|
|
|
|
@Test
|
|
public void t044() {
|
|
// List<Sys_user> pullUsers = dao.query(Sys_user.class, Cnd.where("pullTime", "=", "2024-05-27 11:33:07"));
|
|
|
|
Sql sql = Sqls.create("""
|
|
SELECT
|
|
u.id AS userId,
|
|
us.loginname,
|
|
us.unitid\s
|
|
FROM
|
|
`user_source` us
|
|
LEFT JOIN sys_user u ON u.loginname = us.loginname\s
|
|
WHERE
|
|
us.pullTime = '2024-05-27 11:33:07'
|
|
""");
|
|
List<NutMap> query = (List<NutMap>) Daos.query(dao, sql.toString(), Sqls.callback.maps());
|
|
|
|
List<WelfareList> welfareLists = dao.query(WelfareList.class, Cnd.where("projectId", "=", "fe1d51dafc104a1482cc946d05312e78"));
|
|
|
|
for (WelfareList welfareList : welfareLists) {
|
|
String unitId = query.stream().filter(v -> v.getString("userId").equals(welfareList.getUserId())).findFirst().map(v -> v.getString("unitid")).orElse(null);
|
|
welfareList.setWelfareSecondLevelUnitId(unitId);
|
|
}
|
|
|
|
dao.update(welfareLists, "welfareSecondLevelUnitId");
|
|
}
|
|
|
|
@Test
|
|
public void t08() {
|
|
Sql sql = Sqls.create("select id,unitid,userState,personType from sys_user");
|
|
List<NutMap> users = (List<NutMap>) Daos.query(dao, sql.toString(), Sqls.callback.maps());
|
|
|
|
List<WelfareList> welfareLists = dao.query(WelfareList.class, Cnd.where("welfareSecondLevelUnitId", "is", null));
|
|
|
|
for (WelfareList welfareList : welfareLists) {
|
|
Optional<NutMap> optionalUser = users.stream().filter(u -> u.getString("id").equals(welfareList.getUserId())).findFirst();
|
|
if (optionalUser.isPresent()) {
|
|
// welfareList.setPersonType(optionalUser.get().getString("personType"));
|
|
// welfareList.setUserState(optionalUser.get().getString("userState"));
|
|
welfareList.setWelfareSecondLevelUnitId(optionalUser.get().getString("unitid"));
|
|
}
|
|
}
|
|
// dao.update(welfareLists, "userState|personType");
|
|
dao.update(welfareLists, "welfareSecondLevelUnitId");
|
|
}
|
|
|
|
|
|
|
|
@Data
|
|
public static class kddh {
|
|
@Excel(name = "工号")
|
|
private String loginname;
|
|
|
|
@Excel(name = "快递单号")
|
|
private String kddh;
|
|
|
|
}
|
|
|
|
|
|
@Test
|
|
public void test03() throws InterruptedException {
|
|
List<Sys_unit> unitList = dao.query(Sys_unit.class, Cnd.where("unitlevel", "=", 2).and("id", "!=", "unitcode"));
|
|
Map<String, Sys_unit> unitMap = unitList.stream().collect(Collectors.toMap(Sys_unit::getId, v -> v));
|
|
|
|
List<WelfareList> list = dao.query(WelfareList.class, Cnd.where("welfareSecondLevelUnitId", "is not", null).and("welfareSecondLevelUnitId", "!=", ""));
|
|
list.forEach(v -> {
|
|
Sys_unit unit = unitMap.get(v.getWelfareSecondLevelUnitId());
|
|
if (Lang.isNotEmpty(unit)) v.setWelfareSecondLevelUnitId(unit.getUnitcode());
|
|
});
|
|
|
|
// dao.updateIgnoreNull(list);
|
|
|
|
// // 创建一个固定大小的线程池
|
|
// int numberOfThreads = 20; // 可以根据服务器性能调整线程池大小
|
|
// ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
|
|
//
|
|
// int batchSize = 200; // 每批处理的数据量,可以根据实际情况调整
|
|
// for (int i = 0; i < list.size(); i += batchSize) {
|
|
// final int end = Math.min(i + batchSize, list.size());
|
|
// List<WelfareList> batch = list.subList(i, end);
|
|
// executorService.submit(()->{
|
|
// dao.updateIgnoreNull(batch);
|
|
// });
|
|
// }
|
|
// executorService.shutdown();
|
|
// executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
|
|
}
|
|
|
|
@Data
|
|
public static class WinUser{
|
|
@Excel(name = "工号")
|
|
private String loginname;
|
|
}
|
|
|
|
|
|
@Test
|
|
public void insertRole(){
|
|
// List<Jdh_db> dbs = dao.query(Jdh_db.class, Cnd.where("jdhid", "=", "4m2tgml52shcor5f6o845ifepr"));
|
|
// List<Sys_user_role> userRoles = dbs.stream().map(v -> {
|
|
// Sys_user_role role = new Sys_user_role();
|
|
// role.setUserId(v.getDbid());
|
|
// role.setRoleId(Roles.ZSDB);
|
|
// role.setDbtid(v.getDbtid());
|
|
// role.setJdhid(v.getJdhid());
|
|
// return role;
|
|
// }).collect(Collectors.toList());
|
|
// dao.insert(userRoles);
|
|
List<Sys_unit> list = dao.query(Sys_unit.class, Cnd.where("unionid", "=", "4c1e4f43474f4861a3abcd9ed517d692"));
|
|
List<Sys_unit> insertList = list.stream().map(v -> {
|
|
Sys_unit unit = new Sys_unit();
|
|
unit.setId(v.getId() + "SJDW");
|
|
unit.setParentId(v.getId());
|
|
unit.setName(v.getName());
|
|
unit.setUnitcode(v.getId() + "SJDW");
|
|
unit.setUnitlevel(3);
|
|
return unit;
|
|
}).toList();
|
|
dao.insert(insertList);
|
|
}
|
|
|
|
|
|
@Test
|
|
public void testThreeUnitId(){
|
|
|
|
String content = "叮~2025端午慰问满意度调查邀您参与";
|
|
String link = Globals.AppDomain + "/platform/h5/welfare/evaluate?id=%s&type=welfare".formatted("dbdc7ccf818d4318ae2094e62feb594d");
|
|
// msgApi.sendMsg(List.of("DingTalk"), List.of("2020000035", "2020000098"), 2, "满意度调查", content, "", link);
|
|
|
|
|
|
//// String inputFilePath = "F:\\mini-2025-07-08-5368.log";
|
|
//// String outputFilePath = "F:\\extracted_inserts.log";
|
|
//
|
|
// String inputFilePath = "F:\\extracted_inserts.log";
|
|
// String outputFilePath = "F:\\formatted_inserts.sql";
|
|
//
|
|
// try {
|
|
// extractInsertStatements(inputFilePath, outputFilePath);
|
|
// System.out.println("提取完成,结果已保存到: " + outputFilePath);
|
|
// } catch (IOException e) {
|
|
// System.err.println("处理文件时出错: " + e.getMessage());
|
|
// e.printStackTrace();
|
|
// }
|
|
|
|
}
|
|
|
|
public static void extractInsertStatements(String inputPath, String outputPath) throws IOException {
|
|
|
|
try (BufferedReader reader = new BufferedReader(
|
|
new InputStreamReader(
|
|
new FileInputStream(inputPath), StandardCharsets.UTF_8));
|
|
BufferedWriter writer = new BufferedWriter(
|
|
new OutputStreamWriter(
|
|
new FileOutputStream(outputPath), StandardCharsets.UTF_8))) {
|
|
|
|
String line;
|
|
while ((line = reader.readLine()) != null) {
|
|
// 跳过空行
|
|
if (line.trim().isEmpty()) {
|
|
continue;
|
|
}
|
|
|
|
// 去除开头和结尾的引号
|
|
String formattedLine = line.replaceAll("^\"|\"$", "");
|
|
|
|
// 在行尾添加分号(如果还没有)
|
|
if (!formattedLine.trim().endsWith(";")) {
|
|
formattedLine += ";";
|
|
}
|
|
|
|
writer.write(formattedLine);
|
|
writer.newLine();
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void processContent(StringBuilder content, Pattern pattern, BufferedWriter writer) throws IOException {
|
|
Matcher matcher = pattern.matcher(content.toString());
|
|
while (matcher.find()) {
|
|
String insertStatement = matcher.group();
|
|
writer.write(insertStatement);
|
|
writer.newLine();
|
|
writer.newLine(); // 每个INSERT语句之间空一行
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
private MsgApi msgApi;
|
|
@Inject
|
|
private SysLocalProcessService localProcessService;
|
|
@Inject
|
|
private ProposalCommonService proposalCommonService;
|
|
|
|
@Test
|
|
public void t10(){
|
|
// List<String> list = List.of(
|
|
// "9c166b8dc09343079b6af2e44455266c",
|
|
// "a7c47c306f0c41b38fd958a559888ccc",
|
|
// "17c751f77c33433eba9d1c19f03b553a",
|
|
// "8c5391a82290470ca29ef7b5101b6100",
|
|
// "8a338dbdab484a33af7d485ba840bb6e",
|
|
// "18ac213eddb44ac1af0178f78147f39d",
|
|
// "c0b726dfc1de4773a91e65bf986f4dbc",
|
|
// "f87d24d2e99e4557a18e439cc0ff8fc8",
|
|
// "badd9c0bbe9a40feb7b00b80bb3aa770",
|
|
// "73543dedd0884d2ea536622c8343b4ee",
|
|
// "3b0607a9365243089d749ddde6d4654f",
|
|
// "8cd4d0bd05dd42aaaefca14dcc82e25f",
|
|
// "7921f4d9dad74ea99d0d4635abd665a3",
|
|
// "ff29bb6caf464386a3895a497fe000ad",
|
|
// "37b0d8ee75714a6cb6392ca6cdd5eba6",
|
|
// "26e1d548ec3b4182a7eda6cf3a45f34e",
|
|
// "53b4df702f62453d879b166dcfe2e4e5",
|
|
// "35bbb8a98cb2472d8ff5ce0644d4f68a",
|
|
// "af4e738d4b7049b1b535e682bfa5b91a",
|
|
// "877e03535b3f4f17b30eb66e76c7e2b2",
|
|
// "79f5511b9c8245e9b15d2939732c1075",
|
|
// "aa06d6a1dc9147c299323537f1ce77f7",
|
|
// "6e6af7d696d3457293673e530b8f0b33",
|
|
// "639a95df53dd4b3c934b8e15083f1ac5",
|
|
// "2fb25ba1a5734953a9b4e565b29284dc"
|
|
// );
|
|
//
|
|
//
|
|
// list.forEach(v -> {
|
|
// localProcessService.updateProcessNodeName(
|
|
// "proposal_info@" + v,
|
|
// "承办单位办理"
|
|
// );
|
|
//
|
|
// //查询主办、协办答复配置
|
|
// Sql sql = Sqls.fetchRecord(Sqls.create("SELECT t1.* FROM `proposal_config` t INNER JOIN proposal_reply_config t1 on t1.id = t.slaveUnitConfigId").toString());
|
|
// dao.execute(sql);
|
|
// Record slaveReplyConfig = (Record) sql.getResult();
|
|
// //协办需要答复吗
|
|
// boolean slaveNeedReply = slaveReplyConfig.getInt("isNeedReply") == 1;
|
|
//
|
|
// //查询最大一次的replyNumber
|
|
// int maxReplyNumber = dao.func(ProposalReply.class, "max", "replyNumber", Cnd.where("proposalId", "=", v));
|
|
//
|
|
// List<ProposalReply> replies = dao.query(ProposalReply.class, Cnd.where("proposalId", "=", v).and("replyNumber", "=", maxReplyNumber).and("undertakeType", "in", slaveNeedReply ? Lang.list(1, 2) : Lang.list(1)));
|
|
// for (ProposalReply reply : replies) {
|
|
// localProcessService.createTask("proposal_info@" + v, "proposal_reply@" + reply.getId(), "承办单位办理", "qcmlivs3oggfmrl0rnoqlcce8p", proposalCommonService.getUnderTakeLeader(reply.getReplyUnitId()), "/platform/proposal/transact/reply", "/platform/proposal/transact/reply", null, null);
|
|
// }
|
|
// });
|
|
|
|
|
|
// List<Sys_user> userList = dao.query(Sys_user.class, Cnd.where("loginname", "in", List.of("2005000019", "2010000010", "1992000003", "1998000001")));
|
|
//
|
|
// String linkUrl = "https://zhgh.hmc.edu.cn/mobile/proposal/seconded";
|
|
//
|
|
// for (Sys_user user : userList) {
|
|
// String template = "{}代表,您好,{}代表的提案《{}》邀请您作为附议人,请您点击此消息或登录“智慧工会”系统进行附议,感谢您对教代会提案工作的大力支持!";
|
|
// String content = StrUtil.format(template, user.getUsername(), "王黎芳", "关于进一步提升我校教职工归属感的若干举措建议");
|
|
// System.out.println(content);
|
|
//// msgApi.sendMsg(List.of("DingTalk"), user.getLoginname(), 2, "提案附议邀请", content, "", linkUrl);
|
|
// }
|
|
}
|
|
}
|