|
@ -752,28 +752,22 @@ public class EduArticleService {
|
|
|
private void deleteEsDataByBatch(String batchNo) {
|
|
|
JestClient jestClient = null;
|
|
|
try {
|
|
|
int i = 0;
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("batchNo", batchNo))
|
|
|
).size(500000);//一次取10000条
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
List<HealthEduArticleES> healthEduArticleESs = result.getSourceAsObjectList(HealthEduArticleES.class);
|
|
|
|
|
|
//根据id批量删除
|
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
|
for (HealthEduArticleES obj : healthEduArticleESs) {
|
|
|
Delete index = new Delete.Builder(obj.getId()).build();
|
|
|
bulk.addAction(index);
|
|
|
String sql = "select id from " + esIndex + " where batchNo='" + batchNo + "'";
|
|
|
List<Map<String, Object>> returnList = elasticsearchUtil.excuteDataModel(sql);
|
|
|
//根据id批量删除
|
|
|
for (Map<String, Object> obj : returnList) {
|
|
|
if (obj.containsKey("_id")) {
|
|
|
i++;
|
|
|
Delete index = new Delete.Builder(obj.get("id").toString()).build();
|
|
|
bulk.addAction(index);
|
|
|
}
|
|
|
}
|
|
|
BulkResult br = jestClient.execute(bulk.build());
|
|
|
|
|
|
logger.info("delete data count:" + healthEduArticleESs.size());
|
|
|
logger.info("delete data count:" + i);
|
|
|
logger.info("delete flag:" + br.isSucceeded());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@ -886,6 +880,9 @@ public class EduArticleService {
|
|
|
if (healthEduArticleESSaveList != null && healthEduArticleESSaveList.size() > 0) {
|
|
|
HealthEduArticleES healthEduArticleESUserType2 = healthEduArticleESSaveList.get(0);
|
|
|
healthEduArticleESUserType2.setUserType(2);
|
|
|
healthEduArticleESUserType2.setCzrq(null);
|
|
|
healthEduArticleESUserType2.setPatientCode(null);
|
|
|
healthEduArticleESUserType2.setPatientName(null);
|
|
|
healthEduArticleESSaveList.add(healthEduArticleESUserType2);
|
|
|
}
|
|
|
|
|
@ -928,7 +925,7 @@ public class EduArticleService {
|
|
|
List<Map<String, Object>> returnList = elasticsearchUtil.excuteDataModel(sql);
|
|
|
//根据id批量删除
|
|
|
for (Map<String, Object> obj : returnList) {
|
|
|
if (obj.containsKey("id")) {
|
|
|
if (obj.containsKey("_id")) {
|
|
|
i++;
|
|
|
Delete index = new Delete.Builder(obj.get("id").toString()).build();
|
|
|
bulk.addAction(index);
|
|
@ -1036,23 +1033,42 @@ public class EduArticleService {
|
|
|
|
|
|
HealthEduArticle healthEduArticle = articleMap.get(healthEduArticlePatient.getArticle());
|
|
|
healthEduArticleES.setArticleId(healthEduArticle.getCode());
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent());
|
|
|
healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
|
|
|
healthEduArticleES.setIsRead(healthEduArticlePatient.getRead());
|
|
|
healthEduArticleES.setOperatorId(doctorCode); //之前旧数据没有文章作者 默认是发送人
|
|
|
healthEduArticleES.setArticleCover(healthEduArticle.getUrl());
|
|
|
healthEduArticleES.setArticleSource(adminTeam.getOrgName());//文章来源 旧数据默认是医生的所在团队的所属机构
|
|
|
healthEduArticleES.setOperatorId(wjwCode); //之前旧数据没有文章作者 默认是发送人
|
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");//文章来源 旧数据默认是医生的所在团队的所属机构
|
|
|
if (healthEduArticle.getContent().length() >= 100) {
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0, 100));
|
|
|
} else {
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent());
|
|
|
}
|
|
|
healthEduArticleES.setFirstLevelCategoryId(firstId);
|
|
|
healthEduArticleES.setFirstLevelCategoryName(firstName);
|
|
|
if (secondList != null && secondList.size() > 0) {
|
|
|
for (NewCategoryModel newCategoryModel : secondList) {
|
|
|
if (newCategoryModel.getCategoryName().equals(healthEduArticle.getKeyword())) {
|
|
|
healthEduArticleES.setSecondLevelCategoryId(newCategoryModel.getCategoryId());
|
|
|
healthEduArticleES.setSecondLevelCategoryName(newCategoryModel.getCategoryName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//数据库中的isRead 0已读,1未读--->Es中isRead 0未读 1已读
|
|
|
if (healthEduArticlePatient.getRead() == null) {
|
|
|
healthEduArticleES.setIsRead(1);
|
|
|
healthEduArticleES.setCzrq(healthEduArticlePatient.getCzrq());
|
|
|
} else {
|
|
|
healthEduArticleES.setCzrq(null);
|
|
|
healthEduArticleES.setIsRead(0);
|
|
|
}
|
|
|
|
|
|
healthEduArticleES.setAdminTeamCode(adminTeam.getId());
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
healthEduArticleES.setHospital(adminTeam.getOrgCode());
|
|
|
healthEduArticleES.setHospitalName(adminTeam.getOrgName());
|
|
|
healthEduArticleES.setTown(adminTeam.getTownCode());
|
|
|
healthEduArticleES.setTownName(adminTeam.getTownName());
|
|
|
if (adminTeam!=null){
|
|
|
healthEduArticleES.setAdminTeamCode(adminTeam.getId());
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
}
|
|
|
|
|
|
healthEduArticleES.setCreateTime(new Date());
|
|
|
healthEduArticleES.setUserType(1);//患者
|
|
|
|
|
|
healthEduArticleES.setAllCount(healthEduArticlePatientTemps.size());
|
|
|
healthEduArticleESSaveList.add(healthEduArticleES);
|
|
|
|
|
|
|
|
@ -1079,15 +1095,15 @@ public class EduArticleService {
|
|
|
|
|
|
HealthEduArticle healthEduArticle = articleMap.get(healthEduArticlePatientTemps.get(0).getArticle());
|
|
|
healthEduArticleES.setArticleId(healthEduArticle.getCode());
|
|
|
healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
|
|
|
healthEduArticleES.setArticleCover(healthEduArticle.getUrl());
|
|
|
healthEduArticleES.setOperatorId(wjwCode); //之前旧数据没有文章作者 默认是卫计委
|
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");//文章来源 旧数据默认是卫计委
|
|
|
if (healthEduArticle.getContent().length() >= 100) {
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0, 100));
|
|
|
} else {
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent());
|
|
|
}
|
|
|
healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
|
|
|
healthEduArticleES.setArticleCover(healthEduArticle.getUrl());
|
|
|
healthEduArticleES.setOperatorId(wjwCode); //之前旧数据没有文章作者 默认是卫计委
|
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");//文章来源 旧数据默认是卫计委
|
|
|
healthEduArticleES.setFirstLevelCategoryId(firstId);
|
|
|
healthEduArticleES.setFirstLevelCategoryName(firstName);
|
|
|
if (secondList != null && secondList.size() > 0) {
|
|
@ -1131,7 +1147,7 @@ public class EduArticleService {
|
|
|
public Map<String, Object> deleteEsOldArticlePatient() throws Exception {
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
|
|
|
|
String sql = "select batch_no code from wlyy_health_edu_article_patient_copy group by batch_no";
|
|
|
String sql = "select batch_no code from wlyy_health_edu_article_patient_copy WHERE admin_team_code IS NOT NULL AND batch_no IS NOT NULL group by batch_no";
|
|
|
List<Map<String, Object>> queryids = jdbcTemplate.queryForList(sql);
|
|
|
List<String> ids = queryids.stream().map(one -> one.containsKey("code") ? one.get("code").toString() : "").collect(Collectors.toList());
|
|
|
int count = deleteEsByBatchNo(ids);
|
|
@ -1153,8 +1169,8 @@ public class EduArticleService {
|
|
|
List<Map<String, Object>> returnList = elasticsearchUtil.excuteDataModel(sql);
|
|
|
//根据id批量删除
|
|
|
for (Map<String, Object> obj : returnList) {
|
|
|
if (obj.containsKey("id")) {
|
|
|
Delete index = new Delete.Builder(obj.get("id").toString()).build();
|
|
|
if (obj.containsKey("_id")) {
|
|
|
Delete index = new Delete.Builder(obj.get("_id").toString()).build();
|
|
|
bulk.addAction(index);
|
|
|
i++;
|
|
|
}
|