|
@@ -30,6 +30,13 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
@Autowired
|
|
|
private OrganizationDao organizationDao;
|
|
|
|
|
|
+ private static ThreadLocal<Set<Integer>> organIds = new ThreadLocal<Set<Integer>>(){
|
|
|
+ @Override
|
|
|
+ protected Set<Integer> initialValue() {
|
|
|
+ return new HashSet<>();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Long, IndexBaseMonthData> getDAO() {
|
|
|
return indexBaseMonthDataDao;
|
|
@@ -87,6 +94,8 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
|
|
|
List<Organization> allOrgans = organizationDao.findAllOrgans();
|
|
|
Set<Integer> organIds = allOrgans.stream().map(Organization::getId).collect(Collectors.toSet());
|
|
|
+ this.organIds.get().clear();
|
|
|
+ this.organIds.get().addAll(organIds);
|
|
|
|
|
|
while (startDate.compareTo(endDate)<=0){
|
|
|
countUserSignUpData(df.format(startDate));
|
|
@@ -106,11 +115,17 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
*/
|
|
|
private void saveData(List<IndexBaseMonthData> dataList, String startMonth, IndexDataType indexDataType){
|
|
|
startMonth = startMonth+"-01";
|
|
|
+ Date date = DateUtil.stringToDate(startMonth, "yyyy-MM-dd");
|
|
|
if(Objects.isNull(dataList)){
|
|
|
dataList = new ArrayList<>();
|
|
|
}
|
|
|
-
|
|
|
- Date date = DateUtil.stringToDate(startMonth, "yyyy-MM-dd");
|
|
|
+ Set<Integer> hasOrganIds = dataList.stream().map(IndexBaseMonthData::getOrganId).collect(Collectors.toSet());
|
|
|
+ for (Integer organId : this.organIds.get()) {
|
|
|
+ if(hasOrganIds.contains(organId)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dataList.add(new IndexBaseMonthData(date, organId));
|
|
|
+ }
|
|
|
indexBaseMonthDataDao.deleteWithMonthAndType(Arrays.asList(startMonth), indexDataType);
|
|
|
indexBaseMonthDataDao.batchInsertWithDataType(dataList, indexDataType);
|
|
|
}
|