|
|
@ -17,6 +17,7 @@ import com.epmet.service.evaluationindex.extract.toscreen.*; |
|
|
|
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; |
|
|
|
import com.epmet.service.evaluationindex.screen.*; |
|
|
|
import com.epmet.service.stats.DimCustomerService; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -26,8 +27,7 @@ import org.springframework.util.CollectionUtils; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author zxc |
|
|
@ -36,6 +36,11 @@ import java.util.concurrent.Executors; |
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() |
|
|
|
.setNameFormat("ScreenExtractServiceImpl-pool-%d").build(); |
|
|
|
ExecutorService threadPool = new ThreadPoolExecutor(3, 6, |
|
|
|
10L, TimeUnit.MINUTES, |
|
|
|
new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DimCustomerService dimCustomerService; |
|
|
@ -101,13 +106,17 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
if (StringUtils.isNotBlank(extractOriginFormDTO.getStartDate()) && StringUtils.isNotBlank(extractOriginFormDTO.getEndDate())) { |
|
|
|
List<String> daysBetween = DateUtils.getDaysBetween(extractOriginFormDTO.getStartDate(), extractOriginFormDTO.getEndDate()); |
|
|
|
daysBetween.forEach(dateId -> { |
|
|
|
extractDaily(customerId, dateId); |
|
|
|
boolean isLastDay = false; |
|
|
|
if (dateId.equals(daysBetween.get(daysBetween.size() - 1))) { |
|
|
|
isLastDay = true; |
|
|
|
} |
|
|
|
extractDaily(customerId, dateId, isLastDay); |
|
|
|
}); |
|
|
|
} else if (StringUtils.isNotBlank(extractOriginFormDTO.getDateId())) { |
|
|
|
extractDaily(customerId, extractOriginFormDTO.getDateId()); |
|
|
|
extractDaily(customerId, extractOriginFormDTO.getDateId(), true); |
|
|
|
} else { |
|
|
|
String dateId = LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", ""); |
|
|
|
extractDaily(customerId, dateId); |
|
|
|
extractDaily(customerId, dateId, true); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
@ -146,11 +155,15 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
/** |
|
|
|
* @param customerId |
|
|
|
* @param dateId |
|
|
|
* @param isLast 是否是最后一天 |
|
|
|
* @Description 按天计算 |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/24 10:16 上午 |
|
|
|
*/ |
|
|
|
public void extractDaily(String customerId, String dateId) { |
|
|
|
public void extractDaily(String customerId, String dateId, boolean isLast) { |
|
|
|
//等待3个线程执行完毕后再 继续执行下一个客户的 避免死锁
|
|
|
|
final CountDownLatch latch = new CountDownLatch(NumConstant.FOUR); |
|
|
|
threadPool.submit(() -> { |
|
|
|
//党员基本情况screen_cpc_base_data
|
|
|
|
try { |
|
|
|
partyBaseInfoService.statsPartyMemberBaseInfoToScreen(customerId, dateId); |
|
|
@ -158,6 +171,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
log.error("党员基本情况抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); |
|
|
|
} |
|
|
|
//先锋模范screen_pioneer_data
|
|
|
|
if (isLast) { |
|
|
|
try { |
|
|
|
pioneerDataExtractService.extractGridPioneerData(customerId, dateId); |
|
|
|
} catch (Exception e) { |
|
|
@ -173,13 +187,19 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("先锋模范【extractExceptCommunityPioneerData】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
latch.countDown(); |
|
|
|
log.info("extractDaily 1 thread run end ========= dateId:{},customerId:{}", dateId, customerId); |
|
|
|
}); |
|
|
|
threadPool.submit(() -> { |
|
|
|
//公众参与排行(注册人数、参与人数、话题数、议题数、项目数)screen_public_party_total_data
|
|
|
|
try { |
|
|
|
publicPartiTotalDataExtractService.extractPublicPartiTotalData(customerId, dateId); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("公众参与排行抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); |
|
|
|
} |
|
|
|
|
|
|
|
if (isLast) { |
|
|
|
//基层治理- 难点赌点 screen_difficulty_data | screen_difficulty_img_data
|
|
|
|
try { |
|
|
|
ScreenCentralZoneDataFormDTO param2 = new ScreenCentralZoneDataFormDTO(); |
|
|
@ -193,7 +213,11 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("基层治理-难点赌点抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
latch.countDown(); |
|
|
|
log.info("extractDaily 2 thread run end ========= dateId:{},customerId:{}", dateId, customerId); |
|
|
|
}); |
|
|
|
threadPool.submit(() -> { |
|
|
|
ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO(); |
|
|
|
param.setCustomerId(customerId); |
|
|
|
param.setDateId(dateId); |
|
|
@ -230,7 +254,10 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); |
|
|
|
} |
|
|
|
|
|
|
|
latch.countDown(); |
|
|
|
log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}", dateId, customerId); |
|
|
|
}); |
|
|
|
threadPool.submit(() -> { |
|
|
|
//治理能力排行screen_govern_rank_data
|
|
|
|
try { |
|
|
|
governRankDataExtractService.extractGridDataDaily(customerId, dateId); |
|
|
@ -274,7 +301,15 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
log.error("网格员数据统计fact_grid_member_statistics_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); |
|
|
|
} |
|
|
|
extractPartData(customerId, dateId); |
|
|
|
log.info("===== extractDaily method end ======"); |
|
|
|
latch.countDown(); |
|
|
|
log.info("extractDaily 4 thread run end ========= dateId:{},customerId:{}", dateId, customerId); |
|
|
|
}); |
|
|
|
try { |
|
|
|
latch.await(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
log.error("extractDaily run exception", e); |
|
|
|
} |
|
|
|
log.info("===== extractDaily method end customerId:{}======",customerId); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|