Commit 58bdceb7 authored by tianbo's avatar tianbo

feat(jg): 新增数据质量评分修复功能

- 在DataHandlerController中新增handleDataQualityScore接口 - 实现ES中缺失数据质量评分的设备数据修复逻辑 -修复SingleEquipChangeProcess中排序字段错误问题,调整为按passedDate倒序排序获取最新记录
parent a48804c4
...@@ -375,4 +375,11 @@ public class DataHandlerController extends BaseController { ...@@ -375,4 +375,11 @@ public class DataHandlerController extends BaseController {
@RequestParam(value = "isDelete", defaultValue = "false") boolean isDelete) { @RequestParam(value = "isDelete", defaultValue = "false") boolean isDelete) {
return ResponseHelper.buildResponse(dataHandlerService.deleteEquipIsNotClaimed(useUnitCreditCode, equList, dataSource, isDelete)); return ResponseHelper.buildResponse(dataHandlerService.deleteEquipIsNotClaimed(useUnitCreditCode, equList, dataSource, isDelete));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/handleDataQualityScore")
@ApiOperation(httpMethod = "POST", value = "修复es中未正常生成数据等级的数据", notes = "修复es中未正常生成数据等级的数据")
public ResponseModel<String> handleDataQualityScore() {
return ResponseHelper.buildResponse(dataHandlerService.handleDataQualityScore());
}
} }
\ No newline at end of file
...@@ -319,8 +319,8 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy ...@@ -319,8 +319,8 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy
// 编辑账号企业人员时,receiveCompanyCode最近一次使用登记或者安装告知或者车用气瓶登记单据的接收机构代码 // 编辑账号企业人员时,receiveCompanyCode最近一次使用登记或者安装告知或者车用气瓶登记单据的接收机构代码
List<Map<String, String>> recentlyReceiveCompanyCode = commonEquipDataProcessService.getCommonMapper().queryRecentlyReceiveCompanyCode(registerInfoNew.getRecord()); List<Map<String, String>> recentlyReceiveCompanyCode = commonEquipDataProcessService.getCommonMapper().queryRecentlyReceiveCompanyCode(registerInfoNew.getRecord());
if (!recentlyReceiveCompanyCode.isEmpty()) { if (!recentlyReceiveCompanyCode.isEmpty()) {
// 按receiveCompanyCode倒叙排序后取最新的一个 // 按passedDate倒叙排序后取最新的一个
recentlyReceiveCompanyCode.sort(Comparator.comparing(map -> map.get("receiveCompanyCode"), Comparator.reverseOrder())); recentlyReceiveCompanyCode.sort(Comparator.comparing(map -> map.get("passedDate"), Comparator.reverseOrder()));
receiveCompanyCode = commonEquipDataProcessService.getJgUseRegistrationService().getCodeUtil().getCityRegionCode(recentlyReceiveCompanyCode.get(0).get("receiveCompanyCode")); receiveCompanyCode = commonEquipDataProcessService.getJgUseRegistrationService().getCodeUtil().getCityRegionCode(recentlyReceiveCompanyCode.get(0).get("receiveCompanyCode"));
} }
} }
......
...@@ -32,6 +32,7 @@ import com.yeejoin.amos.boot.module.common.api.entity.EsUserInfo; ...@@ -32,6 +32,7 @@ import com.yeejoin.amos.boot.module.common.api.entity.EsUserInfo;
import com.yeejoin.amos.boot.module.common.api.entity.TzsUserPermission; import com.yeejoin.amos.boot.module.common.api.entity.TzsUserPermission;
import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum; import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.common.biz.refresh.cm.RefreshCmService; import com.yeejoin.amos.boot.module.common.biz.refresh.cm.RefreshCmService;
import com.yeejoin.amos.boot.module.common.biz.service.impl.EsSearchServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.utils.RefreshDataUtils; import com.yeejoin.amos.boot.module.common.biz.utils.RefreshDataUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeEqDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeEqDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto;
...@@ -81,6 +82,7 @@ import java.time.ZoneId; ...@@ -81,6 +82,7 @@ import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -151,6 +153,8 @@ public class DataHandlerServiceImpl { ...@@ -151,6 +153,8 @@ public class DataHandlerServiceImpl {
private final EsEquipmentDao esEquipmentDao; private final EsEquipmentDao esEquipmentDao;
private final EsSearchServiceImpl esSearchService;
private final IdxBizJgMaintenanceRecordInfoServiceImpl maintenanceRecordInfoService; private final IdxBizJgMaintenanceRecordInfoServiceImpl maintenanceRecordInfoService;
private static final String ROOT_ORG_CODE = "50"; private static final String ROOT_ORG_CODE = "50";
...@@ -2301,4 +2305,45 @@ public class DataHandlerServiceImpl { ...@@ -2301,4 +2305,45 @@ public class DataHandlerServiceImpl {
} }
return records.size(); return records.size();
} }
public String handleDataQualityScore() {
log.info("处理数据质量评分开始");
AtomicLong total = new AtomicLong(0L);
try {
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.existsQuery("USE_ORG_CODE"));
meBuilder.mustNot(QueryBuilders.existsQuery("DATA_QUALITY_SCORE"));
meBuilder.must(QueryBuilders.termQuery("IS_INTO_MANAGEMENT", true));
boolQuery.must(meBuilder);
BoolQueryBuilder meBuilder1 = QueryBuilders.boolQuery();
meBuilder1.should(QueryBuilders.matchQuery("STATUS", "已认领"));
meBuilder1.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("STATUS")));
meBuilder1.should(QueryBuilders.boolQuery().must(QueryBuilders.matchPhraseQuery("STATUS", "")));
meBuilder1.minimumShouldMatch(1);
boolQuery.must(meBuilder1);
esSearchService.searchResponseInBatch(IDX_BIZ_VIEW_JG_ALL, boolQuery, 2000, searchHits -> {
List<ESEquipmentCategoryDto> esEquipmentCategoryList = searchHits.stream().map(searchHit -> JSONObject.parseObject(searchHit.getSourceAsString(), ESEquipmentCategoryDto.class)).collect(Collectors.toList());
// 数据库查询设备数据等级
if (!ValidationUtil.isEmpty(esEquipmentCategoryList)) {
List<String> equipRecords = esEquipmentCategoryList.stream().map(ESEquipmentCategoryDto::getSEQUENCE_NBR).collect(Collectors.toList());
List<IdxBizJgUseInfo> baseEnterpriseInfoList = useInfoService.list(new LambdaQueryWrapper<IdxBizJgUseInfo>().select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getDataQualityScore).in(IdxBizJgUseInfo::getRecord, equipRecords));
if (!ValidationUtil.isEmpty(baseEnterpriseInfoList)) {
Map<String, Integer> equipDataQualityScoreMap = baseEnterpriseInfoList.stream().collect(Collectors.toMap(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getDataQualityScore));
esEquipmentCategoryList.forEach(x -> x.setDataQualityScore(equipDataQualityScoreMap.get(x.getSEQUENCE_NBR())));
}
}
esEquipmentCategory.saveAll(esEquipmentCategoryList);
total.addAndGet(esEquipmentCategoryList.size());
});
} catch (Exception e) {
throw new RuntimeException(e);
}
log.info("处理数据质量评分结束,更新{}条设备", total.get());
return "success";
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment