|
@ -146,7 +146,7 @@ public class EduArticleService {
|
|
|
newArticleModel.setArticleOrder(99);
|
|
|
newArticleModel.setArticleState(1);
|
|
|
newArticleModel.setOrgName("厦门市卫生与计划生育委员会");
|
|
|
newArticleModel.setArticleSource(wjwCode);
|
|
|
newArticleModel.setArticleSource("厦门市卫生与计划生育委员会");
|
|
|
newArticleModel.setArticlelevel(0);
|
|
|
newArticleModel.setOperatorName("厦门市卫生与计划生育委员会");
|
|
|
newArticleModel.setOperatorId(wjwCode);
|
|
@ -724,6 +724,173 @@ public class EduArticleService {
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
public Map<String, net.sf.json.JSONObject> getArticleSendToEsByBatchNo(String batchNos) throws Exception {
|
|
|
|
|
|
Map<String, net.sf.json.JSONObject> returnMap = new HashedMap();
|
|
|
String[] batchNosArr = batchNos.split(",");
|
|
|
//初始化文章
|
|
|
for (String batchNo : batchNosArr) {
|
|
|
net.sf.json.JSONObject o = new net.sf.json.JSONObject();
|
|
|
//删除同一哥批次号下的所有推送记录
|
|
|
deleteEsDataByBatch(batchNo);
|
|
|
//新增医生的推送记录
|
|
|
Integer size = saveByBatch(batchNo);
|
|
|
o.put("saveEsSize", size);
|
|
|
returnMap.put(batchNo, o);
|
|
|
}
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据批次号batchNo删除es数据
|
|
|
* @param batchNo
|
|
|
*/
|
|
|
private void deleteEsDataByBatch(String batchNo) {
|
|
|
JestClient jestClient = null;
|
|
|
try {
|
|
|
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);
|
|
|
}
|
|
|
BulkResult br = jestClient.execute(bulk.build());
|
|
|
|
|
|
logger.info("delete data count:" + healthEduArticleESs.size());
|
|
|
logger.info("delete flag:" + br.isSucceeded());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
if (jestClient != null) {
|
|
|
jestClient.shutdownClient();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private int saveByBatch(String batchNo)throws Exception {
|
|
|
//1.查询出所有的文章列表
|
|
|
List<HealthEduArticle> healthEduArticleList = healthEduArticleDao.findAllArticle();
|
|
|
Map<String, HealthEduArticle> articleMap = new HashedMap();//key是文章code
|
|
|
if (healthEduArticleList != null && healthEduArticleList.size() > 0) {
|
|
|
for (HealthEduArticle healthEduArticle : healthEduArticleList) {
|
|
|
articleMap.put(healthEduArticle.getCode(), healthEduArticle);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//2.获取卫计委code
|
|
|
String sqlwjw = "select code AS wjwCode from wlyy_role WHERE name LIKE '%厦门市卫生与计划生育委员会%' and LENGTH(code)=6";
|
|
|
Map<String, Object> result = jdbcTemplate.queryForMap(sqlwjw);
|
|
|
String wjwCode = result.get("wjwCode") + "";
|
|
|
|
|
|
//3.查询所有一级类别、二级类别
|
|
|
List<NewCategoryModel> firstList = jkeduCategoryDao.findCategory(1);
|
|
|
List<NewCategoryModel> secondList = jkeduCategoryDao.findCategory(2);
|
|
|
String firstIdStr = "";
|
|
|
String firstName = "健康文章";
|
|
|
if (firstList != null && firstList.size() > 0) {
|
|
|
for (NewCategoryModel newCategoryModel : firstList) {
|
|
|
if (newCategoryModel.getCategoryName().contains(firstName)) {
|
|
|
firstIdStr = newCategoryModel.getCategoryId();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
final String firstId = firstIdStr;
|
|
|
|
|
|
//4.获取同一个批次号的推送记录,基本同一个批次号是同一个医生发送的,也是同一篇文章
|
|
|
String sql = "select * from wlyy_health_edu_article_patient_copy where admin_team_code IS NOT NULL AND batch_no IS NOT NULL AND batch_no='" + batchNo + "'";
|
|
|
List<HealthEduArticlePatient> healthEduArticlePatients = jdbcTemplate.query(sql, new BeanPropertyRowMapper(HealthEduArticlePatient.class));
|
|
|
|
|
|
//5.转换成新的健康教育需要的数据
|
|
|
List<HealthEduArticleES> healthEduArticleESSaveList = new ArrayList<>();
|
|
|
if (healthEduArticlePatients != null && healthEduArticlePatients.size() > 0) {
|
|
|
String doctorCode = healthEduArticlePatients.get(0).getDoctor();
|
|
|
Doctor doctor = doctorDao.findByCode(doctorCode);
|
|
|
AdminTeam adminTeam = doctorAdminTeamDao.findOne(healthEduArticlePatients.get(0).getAdminTeamCode());
|
|
|
HealthEduArticle healthEduArticle = healthEduArticleDao.findByCode(healthEduArticlePatients.get(0).getArticle());
|
|
|
for (HealthEduArticlePatient healthEduArticlePatient : healthEduArticlePatients) {
|
|
|
HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
|
|
|
|
|
|
healthEduArticleES.setBatchNo(batchNo);
|
|
|
healthEduArticleES.setPatientCode(healthEduArticlePatient.getPatient());
|
|
|
healthEduArticleES.setPatientName(patientDao.findByCode(healthEduArticlePatient.getPatient()).getName());
|
|
|
|
|
|
//医生
|
|
|
healthEduArticleES.setDoctorCode(doctor.getCode());
|
|
|
healthEduArticleES.setDoctorName(doctor.getName());
|
|
|
healthEduArticleES.setSendName(doctor.getName());
|
|
|
healthEduArticleES.setSendPic(doctor.getPhoto());
|
|
|
healthEduArticleES.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
|
|
|
healthEduArticleES.setHospital(doctor.getHospital());
|
|
|
healthEduArticleES.setHospitalName(doctor.getHospitalName());
|
|
|
healthEduArticleES.setTown(doctor.getTown());
|
|
|
healthEduArticleES.setTownName(doctor.getTownName());
|
|
|
healthEduArticleES.setSendType(1);
|
|
|
healthEduArticleES.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
|
|
|
healthEduArticleES.setCurrentUserRoleCode(healthEduArticleES.getHospital());
|
|
|
//文章
|
|
|
healthEduArticleES.setArticleId(healthEduArticle.getCode());
|
|
|
healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
|
|
|
healthEduArticleES.setArticleCover(healthEduArticle.getUrl());
|
|
|
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);
|
|
|
}
|
|
|
if (adminTeam!=null){
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
healthEduArticleES.setAdminTeamCode(adminTeam.getId());
|
|
|
}
|
|
|
healthEduArticleES.setAllCount(healthEduArticlePatients.size());
|
|
|
healthEduArticleES.setCreateTime(new Date());
|
|
|
healthEduArticleES.setUserType(1);
|
|
|
healthEduArticleES.setOperatorId(wjwCode);
|
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");
|
|
|
|
|
|
healthEduArticleESSaveList.add(healthEduArticleES);
|
|
|
}
|
|
|
if (healthEduArticleESSaveList != null && healthEduArticleESSaveList.size() > 0) {
|
|
|
HealthEduArticleES healthEduArticleESUserType2 = healthEduArticleESSaveList.get(0);
|
|
|
healthEduArticleESUserType2.setUserType(2);
|
|
|
healthEduArticleESSaveList.add(healthEduArticleESUserType2);
|
|
|
}
|
|
|
|
|
|
//数据存到ES
|
|
|
saveDate(healthEduArticleESSaveList);
|
|
|
}
|
|
|
return healthEduArticleESSaveList.size();
|
|
|
}
|
|
|
|
|
|
public Map<String, net.sf.json.JSONObject> getArticleSendToEsByDoctor(String doctorCodes) throws Exception {
|
|
|
|
|
|
Map<String, net.sf.json.JSONObject> returnMap = new HashedMap();
|
|
@ -796,8 +963,28 @@ public class EduArticleService {
|
|
|
articleMap.put(healthEduArticle.getCode(), healthEduArticle);
|
|
|
}
|
|
|
}
|
|
|
//2.获取医生的推送记录
|
|
|
String sql = "select * from wlyy_health_edu_article_patient where doctor='" + doctorCode + "'";
|
|
|
|
|
|
//2.获取卫计委code
|
|
|
String sqlwjw = "select code AS wjwCode from wlyy_role WHERE name LIKE '%厦门市卫生与计划生育委员会%' and LENGTH(code)=6";
|
|
|
Map<String, Object> result = jdbcTemplate.queryForMap(sqlwjw);
|
|
|
String wjwCode = result.get("wjwCode") + "";
|
|
|
|
|
|
//3.查询所有一级类别、二级类别
|
|
|
List<NewCategoryModel> firstList = jkeduCategoryDao.findCategory(1);
|
|
|
List<NewCategoryModel> secondList = jkeduCategoryDao.findCategory(2);
|
|
|
String firstIdStr="";
|
|
|
String firstName = "健康文章";
|
|
|
if (firstList!=null && firstList.size()>0){
|
|
|
for (NewCategoryModel newCategoryModel : firstList){
|
|
|
if (newCategoryModel.getCategoryName().contains(firstName)){
|
|
|
firstIdStr = newCategoryModel.getCategoryId();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
final String firstId= firstIdStr;
|
|
|
|
|
|
//4.获取医生的推送记录
|
|
|
String sql = "select * from wlyy_health_edu_article_patient_copy where admin_team_code IS NOT NULL AND batch_no IS NOT NULL AND doctor='" + doctorCode + "'";
|
|
|
List<HealthEduArticlePatient> healthEduArticlePatients = jdbcTemplate.query(sql, new BeanPropertyRowMapper(HealthEduArticlePatient.class));
|
|
|
//推送记录按照批次号分组
|
|
|
Map<String, List<HealthEduArticlePatient>> healthEduArticlePatientMap = new HashMap<>();
|
|
@ -827,16 +1014,20 @@ public class EduArticleService {
|
|
|
healthEduArticleES.setDoctorCode(doctorCode);
|
|
|
healthEduArticleES.setDoctorName(doctor.getName());
|
|
|
healthEduArticleES.setSendName(doctor.getName());
|
|
|
healthEduArticleES.setSendSex(doctor.getSex().toString());
|
|
|
healthEduArticleES.setSendPic(doctor.getPhoto());
|
|
|
healthEduArticleES.setSendLevel(doctor.getLevel().toString());
|
|
|
healthEduArticleES.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
|
|
|
healthEduArticleES.setHospital(doctor.getHospital());
|
|
|
healthEduArticleES.setHospitalName(doctor.getHospitalName());
|
|
|
healthEduArticleES.setTown(doctor.getTown());
|
|
|
healthEduArticleES.setTownName(doctor.getTownName());
|
|
|
healthEduArticleES.setSendType(1);
|
|
|
healthEduArticleES.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
|
|
|
healthEduArticleES.setSendSource(1);//旧数据都是1 i健康发送
|
|
|
healthEduArticleES.setSendType(1);//默认是医生发送
|
|
|
healthEduArticleES.setCurrentUserRoleCode(doctor.getHospital());
|
|
|
if(roleMaps!=null){
|
|
|
// healthEduArticleES.setCurrentUserRoleLevel("2");
|
|
|
// healthEduArticleES.setCurrentUserRoleCode();
|
|
|
healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level")+"");
|
|
|
}else{
|
|
|
|
|
|
healthEduArticleES.setCurrentUserRoleLevel("4");
|
|
|
}
|
|
|
|
|
|
healthEduArticleES.setBatchNo(healthEduArticlePatient.getBatchNo());
|
|
@ -845,20 +1036,41 @@ public class EduArticleService {
|
|
|
|
|
|
HealthEduArticle healthEduArticle = articleMap.get(healthEduArticlePatient.getArticle());
|
|
|
healthEduArticleES.setArticleId(healthEduArticle.getCode());
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent());
|
|
|
if (healthEduArticle.getContent().length()>=100){
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0,100));
|
|
|
}else{
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent());
|
|
|
}
|
|
|
healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
|
|
|
healthEduArticleES.setIsRead(healthEduArticlePatient.getRead());
|
|
|
healthEduArticleES.setOperatorId(doctorCode); //之前旧数据没有文章作者 默认是发送人
|
|
|
healthEduArticleES.setArticleCover(healthEduArticle.getUrl());
|
|
|
healthEduArticleES.setArticleSource(adminTeam.getOrgName());//文章来源 旧数据默认是医生的所在团队的所属机构
|
|
|
|
|
|
healthEduArticleES.setAdminTeamCode(adminTeam.getId());
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
healthEduArticleES.setHospital(adminTeam.getOrgCode());
|
|
|
healthEduArticleES.setHospitalName(adminTeam.getOrgName());
|
|
|
healthEduArticleES.setTown(adminTeam.getTownCode());
|
|
|
healthEduArticleES.setTownName(adminTeam.getTownName());
|
|
|
healthEduArticleES.setOperatorId(wjwCode); //之前旧数据没有文章作者 默认是卫计委
|
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");//文章来源 旧数据默认是卫计委
|
|
|
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());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//替换已读数据code
|
|
|
//数据库中的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);
|
|
|
}
|
|
|
|
|
|
if (adminTeam!=null){
|
|
|
healthEduArticleES.setAdminTeamCode(adminTeam.getId());
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
}
|
|
|
healthEduArticleES.setAllCount(healthEduArticlePatientTemps.size());
|
|
|
healthEduArticleES.setCreateTime(new Date());
|
|
|
healthEduArticleES.setUserType(1);//患者
|
|
|
|
|
@ -879,26 +1091,47 @@ public class EduArticleService {
|
|
|
healthEduArticleES.setSendLevel(doctor.getLevel().toString());
|
|
|
healthEduArticleES.setSendSource(1);//旧数据都是1 i健康发送
|
|
|
healthEduArticleES.setSendType(1);//默认是医生发送
|
|
|
healthEduArticleES.setHospital(doctor.getHospital());
|
|
|
healthEduArticleES.setHospitalName(doctor.getHospitalName());
|
|
|
healthEduArticleES.setTown(doctor.getTown());
|
|
|
healthEduArticleES.setTownName(doctor.getTownName());
|
|
|
|
|
|
healthEduArticleES.setBatchNo(healthEduArticlePatientTemps.get(0).getBatchNo());
|
|
|
|
|
|
HealthEduArticle healthEduArticle = articleMap.get(healthEduArticlePatientTemps.get(0).getArticle());
|
|
|
healthEduArticleES.setArticleId(healthEduArticle.getCode());
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent());
|
|
|
if (healthEduArticle.getContent().length()>=100){
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0,100));
|
|
|
}else{
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent());
|
|
|
}
|
|
|
healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
|
|
|
healthEduArticleES.setOperatorId(doctorCode); //之前旧数据没有文章作者 默认是发送人
|
|
|
healthEduArticleES.setArticleCover(healthEduArticle.getUrl());
|
|
|
healthEduArticleES.setArticleSource(adminTeam.getOrgName());//文章来源 旧数据默认是医生的所在团队的所属机构
|
|
|
|
|
|
healthEduArticleES.setAdminTeamCode(adminTeam.getId());
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
healthEduArticleES.setHospital(adminTeam.getOrgCode());
|
|
|
healthEduArticleES.setHospitalName(adminTeam.getOrgName());
|
|
|
healthEduArticleES.setTown(adminTeam.getTownCode());
|
|
|
healthEduArticleES.setTownName(adminTeam.getTownName());
|
|
|
healthEduArticleES.setOperatorId(wjwCode); //之前旧数据没有文章作者 默认是卫计委
|
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");//文章来源 旧数据默认是卫计委
|
|
|
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());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (adminTeam!=null){
|
|
|
healthEduArticleES.setAdminTeamCode(adminTeam.getId());
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
}
|
|
|
healthEduArticleES.setUserType(2); //医生
|
|
|
healthEduArticleES.setAllCount(healthEduArticlePatientTemps.size());
|
|
|
|
|
|
healthEduArticleES.setCurrentUserRoleCode(doctor.getHospital());
|
|
|
if(roleMaps!=null){
|
|
|
healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level")+"");
|
|
|
}else{
|
|
|
healthEduArticleES.setCurrentUserRoleLevel("4");
|
|
|
}
|
|
|
healthEduArticleES.setCreateTime(new Date());
|
|
|
|
|
|
healthEduArticleESSaveList.add(healthEduArticleES);
|
|
@ -919,17 +1152,36 @@ public class EduArticleService {
|
|
|
|
|
|
Map<String, Object> returnMap = new HashedMap();
|
|
|
int resultSize = 0;
|
|
|
String sql = "SELECT batch_no AS batchNo,COUNT(1) batchCount " +
|
|
|
"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>> batchMapList = jdbcTemplate.queryForList(sql);
|
|
|
List<String> batchNoList = new ArrayList<>();
|
|
|
if (batchMapList!=null && batchMapList.size()>0){
|
|
|
for (Map<String,Object> map : batchMapList){
|
|
|
batchNoList.add(String.valueOf(map.get("batchNo")));
|
|
|
String countSql ="SELECT " +
|
|
|
" COUNT(DISTINCT(batch_no)) AS batchCount " +
|
|
|
" FROM " +
|
|
|
" wlyy_health_edu_article_patient_copy " +
|
|
|
" WHERE " +
|
|
|
" admin_team_code IS NOT NULL " +
|
|
|
" AND batch_no IS NOT NULL";
|
|
|
Map<String,Object> countMap = jdbcTemplate.queryForMap(countSql);
|
|
|
if (countMap!=null){
|
|
|
int size = 1024;
|
|
|
int batchCount = Integer.valueOf(String.valueOf(countMap.get("batchCount")));
|
|
|
double pageCount = Math.ceil(Double.valueOf(batchCount) / Double.valueOf(size));
|
|
|
if (pageCount > 0) {
|
|
|
String sql = "SELECT batch_no AS batchNo,COUNT(1) batchCount " +
|
|
|
"FROM wlyy_health_edu_article_patient_copy " +
|
|
|
"WHERE admin_team_code IS NOT NULL AND batch_no IS NOT NULL GROUP BY batch_no limit ?,?";
|
|
|
for (int i = 1; i <= pageCount; i++) {
|
|
|
List<String> batchNoList = new ArrayList<>();
|
|
|
int start = (i - 1) * size;
|
|
|
List<Map<String,Object>> batchMapList = jdbcTemplate.queryForList(sql,new Object[]{start,size});
|
|
|
if (batchMapList!=null && batchMapList.size()>0){
|
|
|
for (Map<String,Object> map : batchMapList){
|
|
|
batchNoList.add(String.valueOf(map.get("batchNo")));
|
|
|
}
|
|
|
resultSize += deleteEsByBatchNo(batchNoList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
resultSize = deleteEsByBatchNo(batchNoList);
|
|
|
}
|
|
|
|
|
|
returnMap.put("deleteCount",Integer.valueOf(resultSize));
|
|
|
return returnMap;
|
|
|
}
|
|
@ -941,12 +1193,16 @@ public class EduArticleService {
|
|
|
try {
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
searchSourceBuilder.fetchSource("id","createTime").query(
|
|
|
new BoolQueryBuilder().must(QueryBuilders.termsQuery("batchNo",list))
|
|
|
).size(500000);//一次取10000条
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
System.out.println("result----"+result.getErrorMessage());
|
|
|
System.out.println("resultString:"+result.getSourceAsString());
|
|
|
List<SearchResult.Hit<HealthEduArticleES,Void>> hitList = result.getHits(HealthEduArticleES.class);
|
|
|
List<HealthEduArticleES> healthEduArticleESs = result.getSourceAsObjectList(HealthEduArticleES.class);
|
|
|
System.out.println("Es old date count:"+healthEduArticleESs.size());
|
|
|
/*if (healthEduArticleESs != null && healthEduArticleESs.size() > 0) {
|
|
|
for (HealthEduArticleES healthEduArticleES : healthEduArticleESs) {
|
|
|
saveModels.add(healthEduArticleES);
|
|
@ -954,13 +1210,20 @@ public class EduArticleService {
|
|
|
}*/
|
|
|
//根据id批量删除
|
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
|
for (HealthEduArticleES obj : healthEduArticleESs) {
|
|
|
/*for (HealthEduArticleES obj : healthEduArticleESs) {
|
|
|
if (obj != null) {
|
|
|
Delete index = new Delete.Builder(obj.getId()).build();
|
|
|
bulk.addAction(index);
|
|
|
}
|
|
|
}*/
|
|
|
for (SearchResult.Hit<HealthEduArticleES,Void> hit : hitList) {
|
|
|
if (hit != null) {
|
|
|
Delete index = new Delete.Builder(hit.id).build();
|
|
|
bulk.addAction(index);
|
|
|
}
|
|
|
}
|
|
|
BulkResult br = jestClient.execute(bulk.build());
|
|
|
logger.error("delete es old data:"+br.getErrorMessage()+"-----JsonString:"+br.getJsonString());
|
|
|
logger.info("delete data count:" + healthEduArticleESs.size());
|
|
|
logger.info("delete flag:" + br.isSucceeded());
|
|
|
return healthEduArticleESs.size();
|