|
@ -359,9 +359,9 @@ public class EduArticleService {
|
|
|
List<NewCategoryModel> secondList = jkeduCategoryDao.findCategory(2);
|
|
|
String firstId = "";
|
|
|
String firstName = "健康文章";
|
|
|
if (firstList!=null && firstList.size()>0){
|
|
|
for (NewCategoryModel newCategoryModel : firstList){
|
|
|
if (newCategoryModel.getCategoryName().contains(firstName)){
|
|
|
if (firstList != null && firstList.size() > 0) {
|
|
|
for (NewCategoryModel newCategoryModel : firstList) {
|
|
|
if (newCategoryModel.getCategoryName().contains(firstName)) {
|
|
|
firstId = newCategoryModel.getCategoryId();
|
|
|
}
|
|
|
}
|
|
@ -745,11 +745,11 @@ public class EduArticleService {
|
|
|
|
|
|
/**
|
|
|
* 根据批次号batchNo删除es数据
|
|
|
*
|
|
|
* @param batchNo
|
|
|
*/
|
|
|
private void deleteEsDataByBatch(String batchNo) {
|
|
|
JestClient jestClient = null;
|
|
|
//List<HealthEduArticleES> saveModels = new ArrayList<>();
|
|
|
try {
|
|
|
int i = 0;
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
@ -777,7 +777,7 @@ public class EduArticleService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private int saveByBatch(String batchNo)throws Exception {
|
|
|
private int saveByBatch(String batchNo) throws Exception {
|
|
|
//1.查询出所有的文章列表
|
|
|
List<HealthEduArticle> healthEduArticleList = healthEduArticleDao.findAllArticle();
|
|
|
Map<String, HealthEduArticle> articleMap = new HashedMap();//key是文章code
|
|
@ -864,7 +864,7 @@ public class EduArticleService {
|
|
|
healthEduArticleES.setCzrq(null);
|
|
|
healthEduArticleES.setIsRead(0);
|
|
|
}
|
|
|
if (adminTeam!=null){
|
|
|
if (adminTeam != null) {
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
healthEduArticleES.setAdminTeamCode(adminTeam.getId());
|
|
|
}
|
|
@ -914,7 +914,7 @@ public class EduArticleService {
|
|
|
JestClient jestClient = null;
|
|
|
try {
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
Integer i=0;
|
|
|
Integer i = 0;
|
|
|
//先根据条件查找出来
|
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
|
String sql = "select id from " + esIndex + " where doctorCode='" + doctorCode + "'";
|
|
@ -965,16 +965,16 @@ public class EduArticleService {
|
|
|
//3.查询所有一级类别、二级类别
|
|
|
List<NewCategoryModel> firstList = jkeduCategoryDao.findCategory(1);
|
|
|
List<NewCategoryModel> secondList = jkeduCategoryDao.findCategory(2);
|
|
|
String firstIdStr="";
|
|
|
String firstIdStr = "";
|
|
|
String firstName = "健康文章";
|
|
|
if (firstList!=null && firstList.size()>0){
|
|
|
for (NewCategoryModel newCategoryModel : firstList){
|
|
|
if (newCategoryModel.getCategoryName().contains(firstName)){
|
|
|
if (firstList != null && firstList.size() > 0) {
|
|
|
for (NewCategoryModel newCategoryModel : firstList) {
|
|
|
if (newCategoryModel.getCategoryName().contains(firstName)) {
|
|
|
firstIdStr = newCategoryModel.getCategoryId();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
final String firstId= firstIdStr;
|
|
|
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 + "'";
|
|
@ -1017,9 +1017,9 @@ public class EduArticleService {
|
|
|
healthEduArticleES.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
|
|
|
healthEduArticleES.setSendSource(1);//旧数据都是1 i健康发送
|
|
|
healthEduArticleES.setCurrentUserRoleCode(doctor.getHospital());
|
|
|
if(roleMaps!=null){
|
|
|
healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level")+"");
|
|
|
}else{
|
|
|
if (roleMaps != null) {
|
|
|
healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level") + "");
|
|
|
} else {
|
|
|
healthEduArticleES.setCurrentUserRoleLevel("4");
|
|
|
}
|
|
|
|
|
@ -1072,9 +1072,9 @@ public class EduArticleService {
|
|
|
|
|
|
HealthEduArticle healthEduArticle = articleMap.get(healthEduArticlePatientTemps.get(0).getArticle());
|
|
|
healthEduArticleES.setArticleId(healthEduArticle.getCode());
|
|
|
if (healthEduArticle.getContent().length()>=100){
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0,100));
|
|
|
}else{
|
|
|
if (healthEduArticle.getContent().length() >= 100) {
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0, 100));
|
|
|
} else {
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getContent());
|
|
|
}
|
|
|
healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
|
|
@ -1083,25 +1083,25 @@ public class EduArticleService {
|
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");//文章来源 旧数据默认是卫计委
|
|
|
healthEduArticleES.setFirstLevelCategoryId(firstId);
|
|
|
healthEduArticleES.setFirstLevelCategoryName(firstName);
|
|
|
if (secondList!=null && secondList.size()>0){
|
|
|
for (NewCategoryModel newCategoryModel : secondList){
|
|
|
if (newCategoryModel.getCategoryName().equals(healthEduArticle.getKeyword())){
|
|
|
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){
|
|
|
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{
|
|
|
if (roleMaps != null) {
|
|
|
healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level") + "");
|
|
|
} else {
|
|
|
healthEduArticleES.setCurrentUserRoleLevel("4");
|
|
|
}
|
|
|
healthEduArticleES.setCreateTime(new Date());
|
|
@ -1122,24 +1122,19 @@ public class EduArticleService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public Map<String, Object> deleteEsOldArticlePatient() throws Exception {
|
|
|
Map<String, Object> returnMap = new HashedMap();
|
|
|
int resultSize = 0;
|
|
|
String batchNoSql ="SELECT " +
|
|
|
" DISTINCT(batch_no) batchNo " +
|
|
|
" FROM " +
|
|
|
" wlyy_health_edu_article_patient_copy " +
|
|
|
" WHERE " +
|
|
|
" admin_team_code IS NOT NULL " +
|
|
|
" AND batch_no IS NOT NULL";
|
|
|
List<Map<String,Object>> batchList = jdbcTemplate.queryForList(batchNoSql);
|
|
|
List<String> batchNoList = new ArrayList<>();
|
|
|
if (batchList!=null && batchList.size()>0){
|
|
|
for (Map<String,Object> map : batchList){
|
|
|
batchNoList.add(String.valueOf(map.get("batchNo")));
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
|
|
|
|
String sql = "select batch_no code from wlyy_health_edu_article_patient_copy group by batch_no";
|
|
|
List<Map<String, Object>> queryids = jdbcTemplate.queryForList(sql);
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
for (Map<String, Object> idMap : queryids) {
|
|
|
if (idMap.containsKey("code") && !org.springframework.util.StringUtils.isEmpty(idMap.get("code"))) {
|
|
|
ids.add(idMap.get("code").toString());
|
|
|
}
|
|
|
resultSize += deleteEsByBatchNo(batchNoList);
|
|
|
}
|
|
|
returnMap.put("deleteCount",Integer.valueOf(resultSize));
|
|
|
int count = deleteEsByBatchNo(ids);
|
|
|
returnMap.put("deleteBatch", ids.size());
|
|
|
returnMap.put("deleteCount", Integer.valueOf(count));
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
@ -1152,14 +1147,14 @@ public class EduArticleService {
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
|
for (String batchNo : list) {
|
|
|
String sql = "select id from " + esIndex + " where batchNo='" + batchNo + "'";
|
|
|
String sql = "select id from " + esIndex + " where batchNo='" + batchNo + "' limit 0,50000";
|
|
|
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);
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
}
|