|
@ -27,6 +27,7 @@ import io.searchbox.core.*;
|
|
import org.apache.axis.utils.Admin;
|
|
import org.apache.axis.utils.Admin;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.elasticsearch.action.update.UpdateRequest;
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
|
@ -381,9 +382,7 @@ public class EduArticleService {
|
|
String batSql ="SELECT batch_no from wlyy_health_edu_article_patient WHERE admin_team_code IS NOT NULL GROUP BY batch_no ";
|
|
String batSql ="SELECT batch_no from wlyy_health_edu_article_patient WHERE admin_team_code IS NOT NULL GROUP BY batch_no ";
|
|
List<Map<String,Object>> batchNoMap = jdbcTemplate.queryForList(batSql);
|
|
List<Map<String,Object>> batchNoMap = jdbcTemplate.queryForList(batSql);
|
|
if (batchNoMap!=null && batchNoMap.size()>0){
|
|
if (batchNoMap!=null && batchNoMap.size()>0){
|
|
for (Map<String,Object> map : batchNoMap){
|
|
|
|
deleteData(2,map.get("batch_no")+"");
|
|
|
|
}
|
|
|
|
|
|
deleteData(2,batchNoMap);
|
|
}
|
|
}
|
|
|
|
|
|
String BartchNoSql = "SELECT " +
|
|
String BartchNoSql = "SELECT " +
|
|
@ -431,7 +430,7 @@ public class EduArticleService {
|
|
return flag;
|
|
return flag;
|
|
}
|
|
}
|
|
|
|
|
|
public HealthEduArticleES setDateToObj(HealthEduArticleES healthEduArticleES,Map<String,Doctor> doctorMap,Map<String,HealthEduArticle> articleMap,String wjwCode,int userType)throws Exception{
|
|
|
|
|
|
public HealthEduArticleES setDateToObj(HealthEduArticleES healthEduArticleES,Map<String,Doctor> doctorMap,Map<String,HealthEduArticle> articleMap,String wjwCode,Integer userType)throws Exception{
|
|
//遍历医生
|
|
//遍历医生
|
|
Set<Map.Entry<String,Doctor>> doctorSet=doctorMap.entrySet();
|
|
Set<Map.Entry<String,Doctor>> doctorSet=doctorMap.entrySet();
|
|
for(Map.Entry<String, Doctor> doctorEntry:doctorSet){
|
|
for(Map.Entry<String, Doctor> doctorEntry:doctorSet){
|
|
@ -441,7 +440,6 @@ public class EduArticleService {
|
|
healthEduArticleES.setDoctorName(doctor.getName());
|
|
healthEduArticleES.setDoctorName(doctor.getName());
|
|
//healthEduArticleES.setSendCode(doctor.getCode());
|
|
//healthEduArticleES.setSendCode(doctor.getCode());
|
|
//医生发送
|
|
//医生发送
|
|
healthEduArticleES.setSendType(1);
|
|
|
|
healthEduArticleES.setSendName(doctor.getCode());
|
|
healthEduArticleES.setSendName(doctor.getCode());
|
|
healthEduArticleES.setSendPic(doctor.getPhoto());
|
|
healthEduArticleES.setSendPic(doctor.getPhoto());
|
|
healthEduArticleES.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
|
|
healthEduArticleES.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
|
|
@ -463,69 +461,15 @@ public class EduArticleService {
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getSummary());
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getSummary());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*if (userType==2){
|
|
|
|
healthEduArticleES.setUserType(userType);
|
|
|
|
}*/
|
|
healthEduArticleES.setUserType(userType);
|
|
healthEduArticleES.setUserType(userType);
|
|
healthEduArticleES.setOperatorId(wjwCode);
|
|
healthEduArticleES.setOperatorId(wjwCode);
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");
|
|
return healthEduArticleES;
|
|
return healthEduArticleES;
|
|
}
|
|
}
|
|
|
|
|
|
public HealthEduArticleES setDateToObj1(Map<String,Object> map, String wjwCode)throws Exception{
|
|
|
|
HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
|
|
|
|
String article = map.get("article")+"";
|
|
|
|
String doctorCode = map.get("doctor")+"";
|
|
|
|
String adminTeamId = map.get("admin_team_code")+"";
|
|
|
|
String czrq = map.get("czrq")+"";
|
|
|
|
String patient = map.get("patient")+"";
|
|
|
|
//数据放入对象中
|
|
|
|
if (map.get("batch_no")!=null){
|
|
|
|
healthEduArticleES.setBatchNo(map.get("batch_no")+"");
|
|
|
|
}
|
|
|
|
healthEduArticleES.setPatientCode(patient);
|
|
|
|
Patient patientObj = patientDao.findByCode(patient);
|
|
|
|
if (patientObj!=null){
|
|
|
|
healthEduArticleES.setPatientName(patientObj.getName());
|
|
|
|
}
|
|
|
|
Doctor doctor = doctorDao.findByCode(doctorCode);
|
|
|
|
if (doctor!=null){
|
|
|
|
healthEduArticleES.setDoctorCode(doctor.getCode());
|
|
|
|
healthEduArticleES.setDoctorName(doctor.getName());
|
|
|
|
//healthEduArticleES.setSendCode(doctor.getCode());
|
|
|
|
healthEduArticleES.setSendName(doctor.getCode());
|
|
|
|
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()) : "");
|
|
|
|
}else{
|
|
|
|
healthEduArticleES.setDoctorCode(wjwCode);
|
|
|
|
healthEduArticleES.setSendName("厦门市卫生与计划生育委员会");
|
|
|
|
healthEduArticleES.setDoctorName("厦门市卫生与计划生育委员会");
|
|
|
|
healthEduArticleES.setSendType(2);
|
|
|
|
}
|
|
|
|
healthEduArticleES.setAdminTeamCode(Long.valueOf(adminTeamId));
|
|
|
|
AdminTeam adminTeam = doctorAdminTeamDao.findOne(Long.valueOf(adminTeamId));
|
|
|
|
if (adminTeam!=null){
|
|
|
|
healthEduArticleES.setAdminTeamName(adminTeam.getName());
|
|
|
|
}
|
|
|
|
Date czrqDate = DateUtil.strToDate(czrq.substring(0,czrq.lastIndexOf(".")));
|
|
|
|
healthEduArticleES.setCreateTime(czrqDate);
|
|
|
|
//获取文章详情
|
|
|
|
HealthEduArticle healthEduArticle = healthEduArticleDao.findByCode(article);
|
|
|
|
healthEduArticleES.setArticleId(healthEduArticle.getCode());
|
|
|
|
healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
|
|
|
|
healthEduArticleES.setArticleContent(healthEduArticle.getSummary());
|
|
|
|
//healthEduArticleES.setArticleContent("abc");
|
|
|
|
healthEduArticleES.setOperatorId(wjwCode);
|
|
|
|
healthEduArticleES.setIsRead(Integer.valueOf(map.get("is_read")+""));
|
|
|
|
healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");
|
|
|
|
if (map.get("send_type")!=null){
|
|
|
|
healthEduArticleES.setSendSource(Integer.valueOf(map.get("send_type")+""));
|
|
|
|
}
|
|
|
|
return healthEduArticleES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 保存数据
|
|
* 保存数据
|
|
@ -539,63 +483,90 @@ public class EduArticleService {
|
|
/**
|
|
/**
|
|
* 删除数据
|
|
* 删除数据
|
|
*/
|
|
*/
|
|
private void deleteData(int userType,String batchNo) {
|
|
|
|
|
|
private void deleteData(int userType,List<Map<String,Object>> batchNoMap) {
|
|
JestClient jestClient = null;
|
|
JestClient jestClient = null;
|
|
|
|
List<HealthEduArticleES> saveModels = new ArrayList<>();
|
|
try {
|
|
try {
|
|
jestClient = elasticFactory.getJestClient();
|
|
jestClient = elasticFactory.getJestClient();
|
|
//先根据条件查找出来
|
|
//先根据条件查找出来
|
|
|
|
for (Map<String,Object> map: batchNoMap){
|
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
|
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
|
|
|
|
boolQueryBuilder.must(QueryBuilders.matchQuery("userType",userType));
|
|
|
|
boolQueryBuilder.must(QueryBuilders.matchQuery("batchNo",map.get("batch_no")+""));
|
|
|
|
searchSourceBuilder.query(boolQueryBuilder).size(100);//一次取10000条
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
|
.build();
|
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
|
List<HealthEduArticleES> healthEduArticleESList = result.getSourceAsObjectList(HealthEduArticleES.class);
|
|
|
|
if (healthEduArticleESList!=null && healthEduArticleESList.size()>0){
|
|
|
|
for (HealthEduArticleES healthEduArticleES : healthEduArticleESList){
|
|
|
|
saveModels.add(healthEduArticleES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//根据id批量删除
|
|
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
|
|
for (HealthEduArticleES obj : saveModels) {
|
|
|
|
if (obj!=null){
|
|
|
|
Delete index = new Delete.Builder(obj.getId()).build();
|
|
|
|
bulk.addAction(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BulkResult br = jestClient.execute(bulk.build());
|
|
|
|
|
|
|
|
logger.info("delete data count:" + saveModels.size());
|
|
|
|
logger.info("delete flag:" + br.isSucceeded());
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("======error:"+e.getMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
} finally {
|
|
|
|
if (jestClient != null) {
|
|
|
|
jestClient.shutdownClient();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 更新es数据库数据
|
|
|
|
*/
|
|
|
|
public boolean updateData(){
|
|
|
|
boolean flag = true;
|
|
|
|
JestClient jestClient = null;
|
|
|
|
try{
|
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
|
//先查询出相关数据
|
|
|
|
/*String timeSql ="select * from "+esType+" where userType<>1 and userType<>2 ";
|
|
|
|
List<HealthEduArticleES> saveModels = elasticsearchUtil.excute(timeSql,HealthEduArticleES.class,esType,esIndex);*/
|
|
|
|
//先根据条件查找出来
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
|
|
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
|
|
boolQueryBuilder.must(QueryBuilders.matchQuery("userType",userType));
|
|
|
|
boolQueryBuilder.must(QueryBuilders.matchQuery("batchNo",batchNo));
|
|
|
|
searchSourceBuilder.query(boolQueryBuilder).size(100);//一次取10000条
|
|
|
|
|
|
boolQueryBuilder.mustNot(QueryBuilders.matchQuery("userType",1));
|
|
|
|
boolQueryBuilder.mustNot(QueryBuilders.matchQuery("userType",2));
|
|
|
|
searchSourceBuilder.query(boolQueryBuilder).size(10000);//一次取10000条
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
.build();
|
|
.build();
|
|
SearchResult result = jestClient.execute(search);
|
|
SearchResult result = jestClient.execute(search);
|
|
List<HealthEduArticleES> saveModels = result.getSourceAsObjectList(HealthEduArticleES.class);
|
|
List<HealthEduArticleES> saveModels = result.getSourceAsObjectList(HealthEduArticleES.class);
|
|
|
|
|
|
//根据id批量删除
|
|
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
for (HealthEduArticleES obj : saveModels) {
|
|
for (HealthEduArticleES obj : saveModels) {
|
|
Delete index = new Delete.Builder(obj.getId()).build();
|
|
|
|
|
|
obj.setUserType(1);
|
|
|
|
Update index = new Update.Builder(obj).build();
|
|
bulk.addAction(index);
|
|
bulk.addAction(index);
|
|
}
|
|
}
|
|
BulkResult br = jestClient.execute(bulk.build());
|
|
BulkResult br = jestClient.execute(bulk.build());
|
|
|
|
|
|
logger.info("delete data count:" + saveModels.size());
|
|
logger.info("delete data count:" + saveModels.size());
|
|
logger.info("delete flag:" + br.isSucceeded());
|
|
logger.info("delete flag:" + br.isSucceeded());
|
|
} catch (Exception e) {
|
|
|
|
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
} finally {
|
|
|
|
|
|
flag = false;
|
|
|
|
}finally {
|
|
if (jestClient != null) {
|
|
if (jestClient != null) {
|
|
jestClient.shutdownClient();
|
|
jestClient.shutdownClient();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Transactional
|
|
|
|
public void save(){
|
|
|
|
NewArticleModel newArticleModel = new NewArticleModel();
|
|
|
|
newArticleModel.setArticleId("123");
|
|
|
|
newArticleModel.setArticleTitle("测试123");
|
|
|
|
newArticleModel.setArticleContent("测试123内容");
|
|
|
|
newArticleModel.setArticleState(1);
|
|
|
|
newArticleModel.setIsAuthentication(1);
|
|
|
|
newArticleModel.setArticleOrder(99);
|
|
|
|
newArticleModel.setArticleState(1);
|
|
|
|
newArticleModel.setOrgName("厦门市卫生与计划生育委员会");
|
|
|
|
newArticleModel.setArticleSource("厦门市卫生与计划生育委员会");//id
|
|
|
|
newArticleModel.setArticlelevel(0);
|
|
|
|
newArticleModel.setOperatorName("厦门市卫生与计划生育委员会");
|
|
|
|
newArticleModel.setOperatorId("");
|
|
|
|
newArticleModel.setAuthentication("厦门市卫生与计划生育委员会");
|
|
|
|
newArticleModel.setAuthenticationId("");
|
|
|
|
newArticleModel.setIsAuthentication(1);
|
|
|
|
newArticleModel.setArticleType("2");
|
|
|
|
newArticleModel.setOperatorRoleCode("管理员code");
|
|
|
|
newArticleModel.setOperatorRoleLevel("管理员");
|
|
|
|
newArticleModel.setRoleType(2);
|
|
|
|
newArticleModel.setUserScope(1);
|
|
|
|
jkeduArticleDao.save(newArticleModel);
|
|
|
|
|
|
return flag;
|
|
}
|
|
}
|
|
}
|
|
}
|