# Conflicts:
#	ruoyi-admin/src/main/java/com/ruoyi/zhiyuanzhe/quartz/VolunteerQuartz.java
#	ruoyi-admin/src/main/java/com/ruoyi/zhiyuanzhe/service/impl/BDistributionRecordsServiceImpl.java
main
dongdingding 1 year ago
commit 6e4c5ea80d

@ -21,7 +21,7 @@ import javax.annotation.Resource;
public class VolunteerQuartz { public class VolunteerQuartz {
@Resource @Resource
private IBDistributionRecordsService bDistributionRecordsService; private IBDistributionRecordsService bDistributionRecordsService;
@Scheduled(cron = "0 0 3 * * ?") @Scheduled(cron = "0 0 4 * * ?")
public void volunteer() { public void volunteer() {
bDistributionRecordsService.volunteer(); bDistributionRecordsService.volunteer();

@ -33,10 +33,20 @@ import com.ruoyi.zhiyuanzhe.service.IBDistributionRecordsService;
import com.ruoyi.zhiyuanzhe.service.IBPersonTagsService; import com.ruoyi.zhiyuanzhe.service.IBPersonTagsService;
import com.ruoyi.zhiyuanzhe.utils.PushDataUtil; import com.ruoyi.zhiyuanzhe.utils.PushDataUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
@ -321,44 +331,66 @@ public class BDistributionRecordsServiceImpl implements IBDistributionRecordsSer
} }
public void processVolunteers(List<VolunteerDTO> volunteerDTOS) { public void processVolunteers(List<VolunteerDTO> volunteerDTOS) {
int a = 0;
// 创建一个固定大小的线程池,线程数根据实际情况进行配置
ExecutorService executorService = Executors.newFixedThreadPool(20);
List<Future<?>> futures = new ArrayList<>();
List<SysUser> userList = new ArrayList<>(); List<SysUser> userList = new ArrayList<>();
List<BPersonTags> tagsList = new ArrayList<>(); List<BPersonTags> tagsList = new ArrayList<>();
for (VolunteerDTO dto : volunteerDTOS) { for (VolunteerDTO dto : volunteerDTOS) {
// 创建一个Runnable任务
// 创建用户 Runnable task = () -> {
SysUser sysUser = new SysUser(); // 创建用户
// 创建人员标签 SysUser sysUser = new SysUser();
BPersonTags tags = new BPersonTags(); // 创建人员标签
// 填充用户信息 BPersonTags tags = new BPersonTags();
sysUser.setNickName(dto.getName()); // 填充用户信息
sysUser.setUserName(dto.getPhone()); sysUser.setNickName(dto.getName());
// 加密密码 sysUser.setUserName(dto.getPhone());
sysUser.setPassword(SecurityUtils.encryptPassword("123456")); // 加密密码
sysUser.setStatus("0"); sysUser.setPassword(SecurityUtils.encryptPassword("123456"));
sysUser.setDelFlag("0"); sysUser.setStatus("0");
sysUser.setSex("2"); sysUser.setDelFlag("0");
sysUser.setRoleId(101L); sysUser.setSex("2");
sysUser.setUserId(Long.valueOf(dto.getPhone())); sysUser.setRoleId(101L);
// 标记为导出数据 String phone = dto.getPhone();
sysUser.setRemark("1"); Pattern pattern = Pattern.compile("\\D"); // 匹配所有非数字字符
userList.add(sysUser); Matcher matcher = pattern.matcher(phone);
// 填充人员标签 String result = matcher.replaceAll("");
tags.setUId(Long.valueOf(dto.getPhone())); if (!result.isEmpty()) {
tags.setNationalityRange(dto.getCountryText()); long userId = Long.parseLong(result);
tags.setProfessionalRange(dto.getSkillText()); sysUser.setUserId(userId);
tags.setIndustryRange(dto.getIndustryCateText()); }
tags.setEducationRange(dto.getEducationText()); // 标记为导出数据
// 标记为导出数据 sysUser.setRemark("1");
tags.setRemark("1"); userList.add(sysUser);
tagsList.add(tags); // 填充人员标签
tags.setUId(Long.valueOf(dto.getPhone()));
a = a + 1; tags.setNationalityRange(dto.getCountryText());
System.out.println("测试" + a); tags.setProfessionalRange(dto.getSkillText());
tags.setIndustryRange(dto.getIndustryCateText());
tags.setEducationRange(dto.getEducationText());
// 标记为导出数据
tags.setRemark("1");
tagsList.add(tags);
};
// 提交任务给线程池并获取Future对象
Future<?> future = executorService.submit(task);
futures.add(future);
} }
;
// 等待所有任务执行完成
for (Future<?> future : futures) {
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
// 处理异常
e.printStackTrace();
}
}
// 所有任务执行完成后执行批量保存操作 // 所有任务执行完成后执行批量保存操作
if (CollectionUtil.isNotEmpty(userList)) { if (CollectionUtil.isNotEmpty(userList)) {
@ -370,17 +402,18 @@ public class BDistributionRecordsServiceImpl implements IBDistributionRecordsSer
personTagsService.addAll(tagsList); personTagsService.addAll(tagsList);
} }
// 关闭线程池
executorService.shutdown();
} }
/** /**
* *
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void volunteer() { public void volunteer() {
// 删除所有导入的用户以及标签 // 删除所有导入的用户以及标签
// sysUserService.delByRemark(); sysUserService.delByRemark();
// personTagsService.delByRemark(); personTagsService.delByRemark();
// 将字符串日期转换为Date对象 // 将字符串日期转换为Date对象
Date startTime = DateUtil.parse("2012-01-01 00:00:00"); Date startTime = DateUtil.parse("2012-01-01 00:00:00");
Date localTime = new Date(); Date localTime = new Date();

@ -24,7 +24,7 @@ spring:
master: master:
url: jdbc:mysql://localhost:3306/zhi_yuan_zhe?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://localhost:3306/zhi_yuan_zhe?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: 123456 password: adminadmin
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭

Loading…
Cancel
Save