解决线程无限执行问题
This commit is contained in:
+9
-3
@@ -103,7 +103,9 @@ public class HomeSearchCheckEsPlanJob implements Job {
|
||||
}
|
||||
|
||||
private void checkLawsEnterpriseStandard(String resourceType, Map<String, Integer> mapHash) {
|
||||
List<LawsEnterpriseStandard> listLawsEnterpriseStandard = lawsEnterpriseStandardService.list();
|
||||
LambdaQueryWrapper<LawsEnterpriseStandard> query = new LambdaQueryWrapper<>();
|
||||
query.ne(LawsEnterpriseStandard::getStandardState,"9");
|
||||
List<LawsEnterpriseStandard> listLawsEnterpriseStandard = lawsEnterpriseStandardService.list(query);
|
||||
int count3 = mapHash.getOrDefault(LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD, 0);
|
||||
int m3 = 0;
|
||||
if(!CollectionUtils.isEmpty(listLawsEnterpriseStandard)){
|
||||
@@ -119,7 +121,9 @@ public class HomeSearchCheckEsPlanJob implements Job {
|
||||
}
|
||||
|
||||
private void checkLawsOverseasStandard(String resourceType, Map<String, Integer> mapHash) {
|
||||
List<LawsOverseasStandard> listLawsOverseasStandard = lawsOverseasStandardService.list();
|
||||
LambdaQueryWrapper<LawsOverseasStandard> query = new LambdaQueryWrapper<>();
|
||||
query.ne(LawsOverseasStandard::getStandardState,"7");
|
||||
List<LawsOverseasStandard> listLawsOverseasStandard = lawsOverseasStandardService.list(query);
|
||||
int count2 = mapHash.getOrDefault(LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD, 0);
|
||||
int m2 = 0;
|
||||
if(!CollectionUtils.isEmpty(listLawsOverseasStandard)){
|
||||
@@ -135,7 +139,9 @@ public class HomeSearchCheckEsPlanJob implements Job {
|
||||
}
|
||||
|
||||
private void checkLawsDomesticStandard(String resourceType, Map<String, Integer> mapHash) {
|
||||
List<LawsDomesticStandard> listLawsDomesticStandard = lawsDomesticStandardService.list();
|
||||
LambdaQueryWrapper<LawsDomesticStandard> query = new LambdaQueryWrapper<>();
|
||||
query.ne(LawsDomesticStandard::getStandardState,"7");
|
||||
List<LawsDomesticStandard> listLawsDomesticStandard = lawsDomesticStandardService.list(query);
|
||||
// 比对数据
|
||||
int count1 = mapHash.getOrDefault(LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD, 0);
|
||||
int m1 = 0;
|
||||
|
||||
+70
-83
@@ -1094,7 +1094,6 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
int startIndex = 0;
|
||||
int batchCount = 500;
|
||||
List<String> listIds = Arrays.asList(ids.split(","));
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
if(CollectionUtils.isEmpty(listIds)) {
|
||||
return true;
|
||||
}
|
||||
@@ -1109,11 +1108,9 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
if(CollectionUtils.isEmpty(listLawsDomesticStandard)){
|
||||
continue;
|
||||
}
|
||||
CompletableFuture.runAsync(()->{
|
||||
for (LawsDomesticStandard lawsDomesticStandard : listLawsDomesticStandard) {
|
||||
createData(resourceType, opType, lawsDomesticStandard);
|
||||
}
|
||||
},pool);
|
||||
for (LawsDomesticStandard lawsDomesticStandard : listLawsDomesticStandard) {
|
||||
createData(resourceType, opType, lawsDomesticStandard);
|
||||
}
|
||||
// 下一批
|
||||
startIndex = startIndex + batchCount;
|
||||
}
|
||||
@@ -1216,8 +1213,6 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
int startIndex = 0;
|
||||
int batchCount = 2000;
|
||||
List<String> listIds = Arrays.asList(ids.split(","));
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
// 异步执行
|
||||
while (startIndex < listIds.size()) {
|
||||
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
||||
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
||||
@@ -1228,35 +1223,33 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
if(CollectionUtils.isEmpty(listLawsOverseasStandard)){
|
||||
continue;
|
||||
}
|
||||
CompletableFuture.runAsync(()->{
|
||||
for (LawsOverseasStandard lawsOverseasStandard : listLawsOverseasStandard) {
|
||||
try {
|
||||
LawsHomeNormalSearchVO obj = new LawsHomeNormalSearchVO();
|
||||
obj.setId(lawsOverseasStandard.getId());
|
||||
obj.setTitle(lawsOverseasStandard.getStandardNumber() + " " + lawsOverseasStandard.getStandardName());
|
||||
obj.setResourceType(resourceType);
|
||||
obj.setStandardTypeOrder("7");
|
||||
switch (lawsOverseasStandard.getStandardState()){
|
||||
case "5": obj.setStandardStateOrder("2");break;
|
||||
case "6": obj.setStandardStateOrder("1");break;
|
||||
case "7": obj.setStandardStateOrder("3");break;
|
||||
default: obj.setStandardStateOrder("4");break;
|
||||
}
|
||||
obj.setImplementationDate(lawsOverseasStandard.getImplementationDate());
|
||||
obj.setCreateTime(lawsOverseasStandard.getCreateTime());
|
||||
obj.setReleaseDate(lawsOverseasStandard.getReleaseDate());
|
||||
obj.setStandardClass(lawsOverseasStandard.getStandardClass());
|
||||
obj.setApplicableVehicle(lawsOverseasStandard.getApplicableVehicle());
|
||||
obj.setStandardState(lawsOverseasStandard.getStandardState());
|
||||
obj.setPushRangeFlag(2);
|
||||
obj.setReleaseStatus("1");
|
||||
List<OSSFile> listFile = getOssFilesLawsOverseasStandard(lawsOverseasStandard);
|
||||
updateES(opType, obj, listFile, lawsOverseasStandard.getId());
|
||||
}catch (Exception e){
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
for (LawsOverseasStandard lawsOverseasStandard : listLawsOverseasStandard) {
|
||||
try {
|
||||
LawsHomeNormalSearchVO obj = new LawsHomeNormalSearchVO();
|
||||
obj.setId(lawsOverseasStandard.getId());
|
||||
obj.setTitle(lawsOverseasStandard.getStandardNumber() + " " + lawsOverseasStandard.getStandardName());
|
||||
obj.setResourceType(resourceType);
|
||||
obj.setStandardTypeOrder("7");
|
||||
switch (lawsOverseasStandard.getStandardState()){
|
||||
case "5": obj.setStandardStateOrder("2");break;
|
||||
case "6": obj.setStandardStateOrder("1");break;
|
||||
case "7": obj.setStandardStateOrder("3");break;
|
||||
default: obj.setStandardStateOrder("4");break;
|
||||
}
|
||||
obj.setImplementationDate(lawsOverseasStandard.getImplementationDate());
|
||||
obj.setCreateTime(lawsOverseasStandard.getCreateTime());
|
||||
obj.setReleaseDate(lawsOverseasStandard.getReleaseDate());
|
||||
obj.setStandardClass(lawsOverseasStandard.getStandardClass());
|
||||
obj.setApplicableVehicle(lawsOverseasStandard.getApplicableVehicle());
|
||||
obj.setStandardState(lawsOverseasStandard.getStandardState());
|
||||
obj.setPushRangeFlag(2);
|
||||
obj.setReleaseStatus("1");
|
||||
List<OSSFile> listFile = getOssFilesLawsOverseasStandard(lawsOverseasStandard);
|
||||
updateES(opType, obj, listFile, lawsOverseasStandard.getId());
|
||||
}catch (Exception e){
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
}
|
||||
},pool);
|
||||
}
|
||||
startIndex = startIndex + batchCount; // 下一批
|
||||
}
|
||||
}
|
||||
@@ -1307,8 +1300,6 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
int startIndex = 0;
|
||||
int batchCount = 2000;
|
||||
List<String> listIds = Arrays.asList(ids.split(","));
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
// 异步执行
|
||||
while (startIndex < listIds.size()) {
|
||||
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
||||
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
||||
@@ -1319,37 +1310,35 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
if(CollectionUtils.isEmpty(listLawsEnterpriseStandard)){
|
||||
continue;
|
||||
}
|
||||
CompletableFuture.runAsync(()->{
|
||||
for (LawsEnterpriseStandard lawsEnterpriseStandard : listLawsEnterpriseStandard) {
|
||||
try {
|
||||
LawsHomeNormalSearchVO obj = new LawsHomeNormalSearchVO();
|
||||
obj.setId(lawsEnterpriseStandard.getId());
|
||||
obj.setTitle(lawsEnterpriseStandard.getStandardNumber() + " " + lawsEnterpriseStandard.getStandardName());
|
||||
obj.setResourceType(resourceType);
|
||||
obj.setStandardTypeOrder("6");
|
||||
for (LawsEnterpriseStandard lawsEnterpriseStandard : listLawsEnterpriseStandard) {
|
||||
try {
|
||||
LawsHomeNormalSearchVO obj = new LawsHomeNormalSearchVO();
|
||||
obj.setId(lawsEnterpriseStandard.getId());
|
||||
obj.setTitle(lawsEnterpriseStandard.getStandardNumber() + " " + lawsEnterpriseStandard.getStandardName());
|
||||
obj.setResourceType(resourceType);
|
||||
obj.setStandardTypeOrder("6");
|
||||
|
||||
switch (lawsEnterpriseStandard.getStandardState()){
|
||||
case "5": obj.setStandardStateOrder("2");break;
|
||||
case "6": obj.setStandardStateOrder("1");break;
|
||||
case "7": obj.setStandardStateOrder("3");break;
|
||||
default: obj.setStandardStateOrder("4");break;
|
||||
}
|
||||
obj.setImplementationDate(lawsEnterpriseStandard.getImplementationDate());
|
||||
obj.setCreateTime(lawsEnterpriseStandard.getCreateTime());
|
||||
obj.setReleaseDate(lawsEnterpriseStandard.getReleaseDate());
|
||||
obj.setStandardState(lawsEnterpriseStandard.getStandardState());
|
||||
obj.setStandardCode(lawsEnterpriseStandard.getStandardCode());
|
||||
obj.setEnterpriseStandardState(lawsEnterpriseStandard.getStandardState());
|
||||
obj.setGradeClassification(lawsEnterpriseStandard.getGradeClassification());
|
||||
obj.setPushRangeFlag(2);
|
||||
obj.setReleaseStatus("1");
|
||||
List<OSSFile> listFile = getOssFilesLawsEnterpriseStandard(lawsEnterpriseStandard);
|
||||
updateES(opType, obj, listFile, lawsEnterpriseStandard.getId());
|
||||
}catch (Exception e){
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
switch (lawsEnterpriseStandard.getStandardState()){
|
||||
case "5": obj.setStandardStateOrder("2");break;
|
||||
case "6": obj.setStandardStateOrder("1");break;
|
||||
case "7": obj.setStandardStateOrder("3");break;
|
||||
default: obj.setStandardStateOrder("4");break;
|
||||
}
|
||||
obj.setImplementationDate(lawsEnterpriseStandard.getImplementationDate());
|
||||
obj.setCreateTime(lawsEnterpriseStandard.getCreateTime());
|
||||
obj.setReleaseDate(lawsEnterpriseStandard.getReleaseDate());
|
||||
obj.setStandardState(lawsEnterpriseStandard.getStandardState());
|
||||
obj.setStandardCode(lawsEnterpriseStandard.getStandardCode());
|
||||
obj.setEnterpriseStandardState(lawsEnterpriseStandard.getStandardState());
|
||||
obj.setGradeClassification(lawsEnterpriseStandard.getGradeClassification());
|
||||
obj.setPushRangeFlag(2);
|
||||
obj.setReleaseStatus("1");
|
||||
List<OSSFile> listFile = getOssFilesLawsEnterpriseStandard(lawsEnterpriseStandard);
|
||||
updateES(opType, obj, listFile, lawsEnterpriseStandard.getId());
|
||||
}catch (Exception e){
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
}
|
||||
},pool);
|
||||
}
|
||||
startIndex = startIndex + batchCount; // 下一批
|
||||
}
|
||||
}
|
||||
@@ -1395,25 +1384,23 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
if(CollectionUtils.isEmpty(listLawsNewsFeed)){
|
||||
continue;
|
||||
}
|
||||
CompletableFuture.runAsync(()->{
|
||||
for (LawsNewsFeed lawsNewsFeed : listLawsNewsFeed) {
|
||||
try {
|
||||
LawsHomeNormalSearchVO obj = new LawsHomeNormalSearchVO();
|
||||
obj.setId(lawsNewsFeed.getId());
|
||||
obj.setTitle(lawsNewsFeed.getDynamicHeading());
|
||||
obj.setResourceType(resourceType);
|
||||
obj.setStandardTypeOrder("9");
|
||||
obj.setStandardState("4");
|
||||
obj.setReleaseDate(lawsNewsFeed.getReleaseTime());
|
||||
obj.setCreateTime(lawsNewsFeed.getCreateTime());
|
||||
obj.setPushRangeFlag(lawsNewsFeed.getPushRangeFlag());
|
||||
obj.setReleaseStatus(String.valueOf(lawsNewsFeed.getReleaseStatus()));
|
||||
updateESLawsNewsFeed(opType, lawsNewsFeed, obj);
|
||||
}catch (Exception e){
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
}
|
||||
for (LawsNewsFeed lawsNewsFeed : listLawsNewsFeed) {
|
||||
try {
|
||||
LawsHomeNormalSearchVO obj = new LawsHomeNormalSearchVO();
|
||||
obj.setId(lawsNewsFeed.getId());
|
||||
obj.setTitle(lawsNewsFeed.getDynamicHeading());
|
||||
obj.setResourceType(resourceType);
|
||||
obj.setStandardTypeOrder("9");
|
||||
obj.setStandardState("4");
|
||||
obj.setReleaseDate(lawsNewsFeed.getReleaseTime());
|
||||
obj.setCreateTime(lawsNewsFeed.getCreateTime());
|
||||
obj.setPushRangeFlag(lawsNewsFeed.getPushRangeFlag());
|
||||
obj.setReleaseStatus(String.valueOf(lawsNewsFeed.getReleaseStatus()));
|
||||
updateESLawsNewsFeed(opType, lawsNewsFeed, obj);
|
||||
}catch (Exception e){
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
}
|
||||
},pool);
|
||||
}
|
||||
startIndex = startIndex + batchCount; // 下一批
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user