|
|
@ -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; |
|
|
@ -151,6 +156,9 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
* @date 2020/9/24 10:16 上午 |
|
|
|
*/ |
|
|
|
public void extractDaily(String customerId, String dateId) { |
|
|
|
//等待3个线程执行完毕后再 继续执行下一个客户的 避免死锁
|
|
|
|
final CountDownLatch latch = new CountDownLatch(NumConstant.THREE); |
|
|
|
threadPool.submit(() -> { |
|
|
|
//党员基本情况screen_cpc_base_data
|
|
|
|
try { |
|
|
|
partyBaseInfoService.statsPartyMemberBaseInfoToScreen(customerId, dateId); |
|
|
@ -173,6 +181,10 @@ 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); |
|
|
@ -193,7 +205,10 @@ 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); |
|
|
@ -274,6 +289,14 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { |
|
|
|
log.error("网格员数据统计fact_grid_member_statistics_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); |
|
|
|
} |
|
|
|
extractPartData(customerId, dateId); |
|
|
|
latch.countDown(); |
|
|
|
log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}",dateId,customerId); |
|
|
|
}); |
|
|
|
try { |
|
|
|
latch.await(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
log.error("extractDaily run exception", e); |
|
|
|
} |
|
|
|
log.info("===== extractDaily method end ======"); |
|
|
|
} |
|
|
|
|
|
|
|