Browse Source

测试下 使用多线程

dev_shibei_match
jianjun 4 years ago
parent
commit
c20293f3bb
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactGridGovernDailyServiceImpl.java
  2. 30
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  3. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactGridGovernDailyServiceImpl.java

@ -278,7 +278,7 @@ public class FactGridGovernDailyServiceImpl extends BaseServiceImpl<FactGridGove
boolean inGridClosed = checkIsInGridClosed(governProjectInfoDTO.getGridId(),
governProjectInfoDTO.getProjectLogDTOList());
if (inGridClosed) {
log.info("projectId=【"+governProjectInfoDTO.getId()+"】属于网格自治");
log.debug("projectId=【"+governProjectInfoDTO.getId()+"】属于网格自治");
// 2、在网格内流转结案的,计算以下下值
if (ProjectConstant.PROJECT_ORIGIN_ISSUE.equals(governProjectInfoDTO.getOrigin())) {
if (ProjectConstant.RESOLVED.equals(governProjectInfoDTO.getIsResolved())) {

30
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java

@ -106,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);
}
});
}
@ -151,13 +155,14 @@ 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.THREE);
final CountDownLatch latch = new CountDownLatch(NumConstant.FOUR);
threadPool.submit(() -> {
//党员基本情况screen_cpc_base_data
try {
@ -166,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) {
@ -181,6 +187,8 @@ 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);
});
@ -191,7 +199,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
} catch (Exception e) {
log.error("公众参与排行抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
if (isLast) {
//基层治理- 难点赌点 screen_difficulty_data | screen_difficulty_img_data
try {
ScreenCentralZoneDataFormDTO param2 = new ScreenCentralZoneDataFormDTO();
@ -205,6 +213,7 @@ 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);
});
@ -245,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);
@ -290,14 +302,14 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
}
extractPartData(customerId, dateId);
latch.countDown();
log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}",dateId,customerId);
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 ======");
log.info("===== extractDaily method end customerId:{}======",customerId);
}
@Override

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java

@ -387,8 +387,8 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
name.deleteCharAt(name.length() - NumConstant.ONE);
diffEntity.setEventCategoryCode(code.toString());
diffEntity.setEventCategoryName(name.toString());
log.info("code:{}",code.toString());
log.info("name:{}",name.toString());
log.debug("code:{}",code.toString());
log.debug("name:{}",name.toString());
});
}

Loading…
Cancel
Save