|
|
|
@ -33,10 +33,20 @@ import com.ruoyi.zhiyuanzhe.service.IBDistributionRecordsService;
|
|
|
|
|
import com.ruoyi.zhiyuanzhe.service.IBPersonTagsService;
|
|
|
|
|
import com.ruoyi.zhiyuanzhe.utils.PushDataUtil;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
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,12 +331,17 @@ public class BDistributionRecordsServiceImpl implements IBDistributionRecordsSer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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<BPersonTags> tagsList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (VolunteerDTO dto : volunteerDTOS) {
|
|
|
|
|
|
|
|
|
|
// 创建一个Runnable任务
|
|
|
|
|
Runnable task = () -> {
|
|
|
|
|
// 创建用户
|
|
|
|
|
SysUser sysUser = new SysUser();
|
|
|
|
|
// 创建人员标签
|
|
|
|
@ -340,7 +355,14 @@ public class BDistributionRecordsServiceImpl implements IBDistributionRecordsSer
|
|
|
|
|
sysUser.setDelFlag("0");
|
|
|
|
|
sysUser.setSex("2");
|
|
|
|
|
sysUser.setRoleId(101L);
|
|
|
|
|
sysUser.setUserId(Long.valueOf(dto.getPhone()));
|
|
|
|
|
String phone = dto.getPhone();
|
|
|
|
|
Pattern pattern = Pattern.compile("\\D"); // 匹配所有非数字字符
|
|
|
|
|
Matcher matcher = pattern.matcher(phone);
|
|
|
|
|
String result = matcher.replaceAll("");
|
|
|
|
|
if (!result.isEmpty()) {
|
|
|
|
|
long userId = Long.parseLong(result);
|
|
|
|
|
sysUser.setUserId(userId);
|
|
|
|
|
}
|
|
|
|
|
// 标记为导出数据
|
|
|
|
|
sysUser.setRemark("1");
|
|
|
|
|
userList.add(sysUser);
|
|
|
|
@ -353,12 +375,22 @@ public class BDistributionRecordsServiceImpl implements IBDistributionRecordsSer
|
|
|
|
|
// 标记为导出数据
|
|
|
|
|
tags.setRemark("1");
|
|
|
|
|
tagsList.add(tags);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
a = a + 1;
|
|
|
|
|
System.out.println("测试" + a);
|
|
|
|
|
// 提交任务给线程池并获取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)) {
|
|
|
|
@ -370,17 +402,18 @@ public class BDistributionRecordsServiceImpl implements IBDistributionRecordsSer
|
|
|
|
|
personTagsService.addAll(tagsList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关闭线程池
|
|
|
|
|
executorService.shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同步志愿者数据
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void volunteer() {
|
|
|
|
|
// 删除所有导入的用户以及标签
|
|
|
|
|
// sysUserService.delByRemark();
|
|
|
|
|
// personTagsService.delByRemark();
|
|
|
|
|
sysUserService.delByRemark();
|
|
|
|
|
personTagsService.delByRemark();
|
|
|
|
|
// 将字符串日期转换为Date对象
|
|
|
|
|
Date startTime = DateUtil.parse("2012-01-01 00:00:00");
|
|
|
|
|
Date localTime = new Date();
|
|
|
|
|