|
@ -0,0 +1,61 @@
|
|
|
package com.yihu.ehr.resolve.service.profile;
|
|
|
|
|
|
import com.yihu.ehr.elasticsearch.ElasticSearchUtil;
|
|
|
import com.yihu.ehr.model.packs.EsSimplePackage;
|
|
|
import com.yihu.ehr.resolve.model.stage1.OriginalPackage;
|
|
|
import com.yihu.ehr.resolve.model.stage2.ResourceBucket;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 档案关联
|
|
|
* @author progr1mmer
|
|
|
* @date Created on 2018/4/11.
|
|
|
*/
|
|
|
@Service
|
|
|
public class JsonArchivesService {
|
|
|
|
|
|
private static final String INDEX = "json_archives";
|
|
|
private static final String TYPE = "info";
|
|
|
|
|
|
@Autowired
|
|
|
private ElasticSearchUtil elasticSearchUtil;
|
|
|
|
|
|
|
|
|
public void reloadData(EsSimplePackage pack,ResourceBucket resourceBucket, OriginalPackage originalPackage) throws Exception {
|
|
|
String id = pack.get_id();
|
|
|
//查找包
|
|
|
Map<String, Object> esPack = elasticSearchUtil.findById(INDEX, TYPE, id);
|
|
|
String profileId = originalPackage.getProfileId().toString();
|
|
|
String receiveDate = esPack.get("receive_date").toString();
|
|
|
List<Map<String, Object>> updateSourceList = new ArrayList<>();
|
|
|
try {
|
|
|
ResultSet resultSet = elasticSearchUtil.findBySql("select * from json_archives where receive_date>'" + receiveDate + "' and fail_count=3 and archive_status=2 and message like '%" + profileId + "%'");
|
|
|
while (resultSet.next()) {
|
|
|
String _id = resultSet.getString("_id");
|
|
|
|
|
|
Map<String, Object> updateSource = new HashMap<>();
|
|
|
updateSource.put("_id", _id);
|
|
|
updateSource.put("analyze_status", 0);
|
|
|
updateSource.put("analyze_fail_count", 0);
|
|
|
updateSource.put("fail_count",0);
|
|
|
updateSource.put("archive_status",0);
|
|
|
updateSourceList.add(updateSource);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
if (!"Error".equals(e.getMessage())) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
if(CollectionUtils.isNotEmpty(updateSourceList)){
|
|
|
elasticSearchUtil.bulkUpdate(INDEX, TYPE, updateSourceList);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|