Commit dda08845 authored by suhuiguang's avatar suhuiguang

feat(jg): 西安数据核对

1.核对数据同步接口es批量
parent ee8a1640
......@@ -179,8 +179,7 @@ public class DataHandlerServiceImpl {
private final StatisticsDataUpdateService statisticsDataUpdateService;
private final IdxBizJgRegisterInfoMapper registerInfoMapper;
private final IdxBizJgUseInfoServiceImpl idxBizJgUseInfoServiceImpl;
private final IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
private final IdxBizJgSupervisionInfoServiceImpl idxBizJgSupervisionInfoServiceImpl;
@Value("${jyjc.open.online: true}")
......@@ -2768,25 +2767,23 @@ public class DataHandlerServiceImpl {
for (int i = 1; i <= totalPage; i++) {
request.source(builder);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = new ArrayList<>();
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESEquipmentCategoryDto equipmentCategoryDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESEquipmentCategoryDto.class);
boolean exist = idxBizJgSupervisionInfoServiceImpl.lambdaUpdate()
.eq(IdxBizJgSupervisionInfo::getRecord, equipmentCategoryDto.getSEQUENCE_NBR())
.set(IdxBizJgSupervisionInfo::getOrgBranchCode, equipmentCategoryDto.getOrgBranchCode())
.set(IdxBizJgSupervisionInfo::getOrgBranchName, equipmentCategoryDto.getORG_BRANCH_NAME())
.update();
Integer recordCount = useInfoService.lambdaQuery().eq(IdxBizJgUseInfo::getRecord, equipmentCategoryDto.getSEQUENCE_NBR()).count();
if (exist) {
totalUpdate = totalUpdate + 1;
}
if (recordCount > 0) {
equipmentCategoryDto.setVersion(version);
} else {
// 数据库不存在的做标记
equipmentCategoryDto.setVersion("-1");
}
esEquipmentCategory.save(equipmentCategoryDto);
esEquipmentCategoryDtos.add(equipmentCategoryDto);
}
if (!esEquipmentCategoryDtos.isEmpty()) {
totalUpdate = esEquipmentCategoryDtos.size() + totalUpdate;
esEquipmentCategory.saveAll(esEquipmentCategoryDtos);
idxBizJgSupervisionInfoServiceImpl.getBaseMapper().updateOrgBranchCodeBatch(esEquipmentCategoryDtos);
}
}
} catch (IOException e) {
......
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgSupervisionInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 监督管理信息表 Mapper 接口
......@@ -11,4 +15,5 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgSupervisionInfo;
*/
public interface IdxBizJgSupervisionInfoMapper extends CustomBaseMapper<IdxBizJgSupervisionInfo> {
void updateOrgBranchCodeBatch(@Param("dtos") List<ESEquipmentCategoryDto> esEquipmentCategoryDtos);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgSupervisionInfoMapper">
<update id="updateOrgBranchCodeBatch">
<foreach collection="dtos" separator=";" item="dto" open="" close="">
UPDATE idx_biz_jg_supervision_info SET "ORG_BRANCH_CODE"=#{dto.orgBranchCode}, "ORG_BRANCH_NAME"=#{dto.ORG_BRANCH_NAME} WHERE record = #{dto.SEQUENCE_NBR}
</foreach>
</update>
</mapper>
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