|
@ -1,5 +1,7 @@
|
|
package com.yihu.wlyy.web.third.gateway.service;
|
|
package com.yihu.wlyy.web.third.gateway.service;
|
|
|
|
|
|
|
|
//import com.yihu.es.entity.ArticleTest;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.es.entity.HealthEduArticlePatient;
|
|
import com.yihu.es.entity.HealthEduArticlePatient;
|
|
import com.yihu.wlyy.config.es.ElastricSearchSave;
|
|
import com.yihu.wlyy.config.es.ElastricSearchSave;
|
|
@ -12,17 +14,19 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
|
|
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
|
|
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
|
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.ElasticsearchUtil;
|
|
import com.yihu.wlyy.util.ElasticsearchUtil;
|
|
|
|
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
|
|
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
|
|
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@ -74,17 +78,17 @@ public class GcEduArticleService {
|
|
//1 服务类型 2 健康情况 3 疾病类型 4 自定义标签
|
|
//1 服务类型 2 健康情况 3 疾病类型 4 自定义标签
|
|
if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
|
|
if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
|
|
switch (labelType) {
|
|
switch (labelType) {
|
|
case "1":{
|
|
|
|
|
|
case "1": {
|
|
sb.append(" select w.code FROM wlyy_sign_family w left join wlyy_sign_family_server s on w.code=s.sign_code " +
|
|
sb.append(" select w.code FROM wlyy_sign_family w left join wlyy_sign_family_server s on w.code=s.sign_code " +
|
|
" left join wlyy_patient p on p.code=w.patient "+
|
|
|
|
|
|
" left join wlyy_patient p on p.code=w.patient " +
|
|
"where w.`status` > 0 and s.server_type=? ");
|
|
"where w.`status` > 0 and s.server_type=? ");
|
|
params.add(labelCode);
|
|
params.add(labelCode);
|
|
}
|
|
}
|
|
case "2":
|
|
case "2":
|
|
case "3":
|
|
case "3":
|
|
case "4":{
|
|
|
|
|
|
case "4": {
|
|
sb.append(" SELECT w.code FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
|
|
sb.append(" SELECT w.code FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
|
|
" left join wlyy_patient p on p.code=w.patient "+
|
|
|
|
|
|
" left join wlyy_patient p on p.code=w.patient " +
|
|
"where w.`status` > 0 and l.label_type = ? AND l.label = ? and l.status=1 ");
|
|
"where w.`status` > 0 and l.label_type = ? AND l.label = ? and l.status=1 ");
|
|
params.add(labelType);
|
|
params.add(labelType);
|
|
params.add(labelCode);
|
|
params.add(labelCode);
|
|
@ -100,7 +104,7 @@ public class GcEduArticleService {
|
|
}
|
|
}
|
|
if (patients != null && patients.length > 0) {
|
|
if (patients != null && patients.length > 0) {
|
|
List<String> arrPatient = java.util.Arrays.asList(patients);
|
|
List<String> arrPatient = java.util.Arrays.asList(patients);
|
|
for(String str:arrPatient){
|
|
|
|
|
|
for (String str : arrPatient) {
|
|
patientSet.add(str);
|
|
patientSet.add(str);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -192,21 +196,21 @@ public class GcEduArticleService {
|
|
/**
|
|
/**
|
|
* 保存发送信息
|
|
* 保存发送信息
|
|
*
|
|
*
|
|
* @param patientSet 患者set集和
|
|
|
|
* @param sendCode 发送人code、
|
|
|
|
* @param sendName 发送人名称
|
|
|
|
* @param sendMessage 发送人携带的信息
|
|
|
|
* @param teamId 发送人所属团队
|
|
|
|
* @param articleId 文章列表
|
|
|
|
|
|
* @param patientSet 患者set集和
|
|
|
|
* @param sendCode 发送人code、
|
|
|
|
* @param sendName 发送人名称
|
|
|
|
* @param sendMessage 发送人携带的信息
|
|
|
|
* @param teamId 发送人所属团队
|
|
|
|
* @param articleId 文章列表
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
public HealthEduArticlePatient getSaveArticle(Set<String> patientSet,
|
|
public HealthEduArticlePatient getSaveArticle(Set<String> patientSet,
|
|
String sendCode,
|
|
|
|
String sendName,
|
|
|
|
Integer sendType,
|
|
|
|
String sendMessage,
|
|
|
|
Long teamId,
|
|
|
|
String articleId) throws Exception{
|
|
|
|
|
|
String sendCode,
|
|
|
|
String sendName,
|
|
|
|
Integer sendType,
|
|
|
|
String sendMessage,
|
|
|
|
Long teamId,
|
|
|
|
String articleId) throws Exception {
|
|
|
|
|
|
|
|
|
|
String batchNo = UUID.randomUUID().toString();
|
|
String batchNo = UUID.randomUUID().toString();
|
|
@ -219,13 +223,13 @@ public class GcEduArticleService {
|
|
//1、医生,2、卫计委
|
|
//1、医生,2、卫计委
|
|
//如果是卫计委得区别角色
|
|
//如果是卫计委得区别角色
|
|
Doctor doctor = null;
|
|
Doctor doctor = null;
|
|
if(sendType==2){
|
|
|
|
|
|
if (sendType == 2) {
|
|
String sql = "select r.code as roleCode from wlyy_user_role u " +
|
|
String sql = "select r.code as roleCode from wlyy_user_role u " +
|
|
"left join wlyy_role r on r.`code`=u.role where u.user='"+sendCode+"'";
|
|
|
|
Map<String,Object> result = jdbcTemplate.queryForMap(sql);
|
|
|
|
|
|
"left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "'";
|
|
|
|
Map<String, Object> result = jdbcTemplate.queryForMap(sql);
|
|
//角色的code值
|
|
//角色的code值
|
|
healthEduArticlePatient.setSendCode(result.get("roleCode")+"");
|
|
|
|
}else{
|
|
|
|
|
|
healthEduArticlePatient.setSendCode(result.get("roleCode") + "");
|
|
|
|
} else {
|
|
doctor = doctorDao.findByCode(sendCode);
|
|
doctor = doctorDao.findByCode(sendCode);
|
|
healthEduArticlePatient.setSendCode(sendCode);
|
|
healthEduArticlePatient.setSendCode(sendCode);
|
|
}
|
|
}
|
|
@ -237,9 +241,9 @@ public class GcEduArticleService {
|
|
healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
|
|
healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
|
|
healthEduArticlePatient.setTown(doctor.getTown());
|
|
healthEduArticlePatient.setTown(doctor.getTown());
|
|
healthEduArticlePatient.setTownName(doctor.getTownName());
|
|
healthEduArticlePatient.setTownName(doctor.getTownName());
|
|
healthEduArticlePatient.setSendLevel(doctor.getLevel()!=null?String.valueOf(doctor.getLevel()):"");
|
|
|
|
|
|
healthEduArticlePatient.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
|
|
healthEduArticlePatient.setSendPic(doctor.getPhoto());
|
|
healthEduArticlePatient.setSendPic(doctor.getPhoto());
|
|
healthEduArticlePatient.setSendSex(doctor.getSex()!=null?String.valueOf(doctor.getSex()):"");
|
|
|
|
|
|
healthEduArticlePatient.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
|
|
}
|
|
}
|
|
healthEduArticlePatient.setBatchNo(batchNo);
|
|
healthEduArticlePatient.setBatchNo(batchNo);
|
|
healthEduArticlePatient.setCreateTime(new Date());
|
|
healthEduArticlePatient.setCreateTime(new Date());
|
|
@ -247,15 +251,15 @@ public class GcEduArticleService {
|
|
//通过文章id 获取文章详情
|
|
//通过文章id 获取文章详情
|
|
JSONObject article = healthEducationArticleService.getArticalById(articleId);
|
|
JSONObject article = healthEducationArticleService.getArticalById(articleId);
|
|
|
|
|
|
healthEduArticlePatient.setArticleId(article.get("articleId")+"");
|
|
|
|
healthEduArticlePatient.setAttachedTitle(article.get("articleTitle")+"");
|
|
|
|
healthEduArticlePatient.setAttachedPic(article.get("articleCover")+"");
|
|
|
|
healthEduArticlePatient.setAttachedContent(article.get("articleContent")+"");
|
|
|
|
|
|
healthEduArticlePatient.setArticleId(article.get("articleId") + "");
|
|
|
|
healthEduArticlePatient.setAttachedTitle(article.get("articleTitle") + "");
|
|
|
|
healthEduArticlePatient.setAttachedPic(article.get("articleCover") + "");
|
|
|
|
healthEduArticlePatient.setAttachedContent(article.get("articleContent") + "");
|
|
healthEduArticlePatient.setAttachedMessage(sendMessage);
|
|
healthEduArticlePatient.setAttachedMessage(sendMessage);
|
|
healthEduArticlePatient.setArticleType(article.get("articleType")+"");
|
|
|
|
healthEduArticlePatient.setLevel(article.get("articlelevel")+"");
|
|
|
|
healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId")+"");
|
|
|
|
healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId")+"");
|
|
|
|
|
|
healthEduArticlePatient.setArticleType(article.get("articleType") + "");
|
|
|
|
healthEduArticlePatient.setLevel(article.get("articlelevel") + "");
|
|
|
|
healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + "");
|
|
|
|
healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + "");
|
|
healthEduArticlePatient.setType("1");//文章
|
|
healthEduArticlePatient.setType("1");//文章
|
|
healthEduArticlePatient.setArticleUrl("");
|
|
healthEduArticlePatient.setArticleUrl("");
|
|
healthEduArticlePatient.setPatients(patientList);
|
|
healthEduArticlePatient.setPatients(patientList);
|
|
@ -269,7 +273,7 @@ public class GcEduArticleService {
|
|
pagesize = page * pagesize;
|
|
pagesize = page * pagesize;
|
|
page = (page - 1) * pagesize;
|
|
page = (page - 1) * pagesize;
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from " +esType+
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from " + esType +
|
|
" where sendCode='" + sendCode + "' ");
|
|
" where sendCode='" + sendCode + "' ");
|
|
if (!StringUtils.isEmpty(articleType)) {
|
|
if (!StringUtils.isEmpty(articleType)) {
|
|
sql.append(" and articleType='" + articleType + "' ");
|
|
sql.append(" and articleType='" + articleType + "' ");
|
|
@ -309,7 +313,7 @@ public class GcEduArticleService {
|
|
}
|
|
}
|
|
|
|
|
|
private com.yihu.es.entity.HealthEduArticlePatient findOne(String articleId) {
|
|
private com.yihu.es.entity.HealthEduArticlePatient findOne(String articleId) {
|
|
String sql = "select level,level2Type,level1Type,attachedContent,attachedTitle,articleId,createTime,articleType,sendCode,sendName from "+esType+" where articleId='" + articleId + "' order by createTime desc limit 0,1";
|
|
|
|
|
|
String sql = "select level,level2Type,level1Type,attachedContent,attachedTitle,articleId,createTime,articleType,sendCode,sendName from " + esType + " where articleId='" + articleId + "' order by createTime desc limit 0,1";
|
|
com.yihu.es.entity.HealthEduArticlePatient esList = (com.yihu.es.entity.HealthEduArticlePatient) elasticsearchUtil.excuteOneObject(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
|
|
com.yihu.es.entity.HealthEduArticlePatient esList = (com.yihu.es.entity.HealthEduArticlePatient) elasticsearchUtil.excuteOneObject(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
|
|
return esList;
|
|
return esList;
|
|
}
|
|
}
|
|
@ -382,38 +386,64 @@ public class GcEduArticleService {
|
|
// patientSet.addAll(groupPatient);
|
|
// patientSet.addAll(groupPatient);
|
|
// }
|
|
// }
|
|
|
|
|
|
public void initPatient(Set<String> patientSet,String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth){
|
|
|
|
|
|
public void initPatient(Set<String> patientSet, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth) {
|
|
|
|
//全选的时候前端传0,后台要去数据库再查询一次
|
|
|
|
if ("0".equals(labelUnit)) {
|
|
|
|
//查找全部的下属单位
|
|
|
|
String sql = "select Group_concat(code) code from dm_hospital where level=2 and town = '350211'";
|
|
|
|
labelUnit = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
|
}
|
|
|
|
if ("0".equals(labelSex)) {
|
|
|
|
//查找全部的性别
|
|
|
|
labelSex = "1,2";
|
|
|
|
}
|
|
|
|
if ("0".equals(labelServe)) {
|
|
|
|
//查找全部的服务类型
|
|
|
|
String sql = "select Group_concat(s.code) from wlyy_sign_dict s where s.year='2017' order by s.sort asc";
|
|
|
|
labelServe = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
|
}
|
|
|
|
if ("0".equals(labelDisease)) {
|
|
|
|
//查找全部的疾病标签
|
|
|
|
String sql = "select Group_concat(s.label_code) from wlyy_sign_patient_label s where s.label_type=3 and status=1";
|
|
|
|
labelDisease = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
|
}
|
|
|
|
if ("0".equals(labelHealth)) {
|
|
|
|
//查找全部的健康情况
|
|
|
|
String sql = "select Group_concat(s.label_code) from wlyy_sign_patient_label s where s.label_type=2 and status=1";
|
|
|
|
labelHealth = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String tableSql = " select p.code from wlyy_sign_family w ";
|
|
String tableSql = " select p.code from wlyy_sign_family w ";
|
|
String whereSql = " where w.status>0 and p.town='350211' ";
|
|
String whereSql = " where w.status>0 and p.town='350211' ";
|
|
|
|
|
|
if(!StringUtils.isEmpty(labelServe)){
|
|
|
|
|
|
if (!StringUtils.isEmpty(labelServe)) {
|
|
tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
|
|
tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
|
|
whereSql += " and s.server_type in ("+labelServe+" ) ";
|
|
|
|
|
|
whereSql += " and s.server_type in (" + labelServe + " ) ";
|
|
}
|
|
}
|
|
if(!StringUtils.isEmpty(labelHealth)||!StringUtils.isEmpty(labelDisease)){
|
|
|
|
|
|
if (!StringUtils.isEmpty(labelHealth) || !StringUtils.isEmpty(labelDisease)) {
|
|
tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
|
|
tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
|
|
whereSql += " and l.status=1 ";
|
|
whereSql += " and l.status=1 ";
|
|
whereSql += " and ( ";
|
|
whereSql += " and ( ";
|
|
}
|
|
}
|
|
if(!StringUtils.isEmpty(labelHealth)){
|
|
|
|
whereSql += " (l.label_type = 2 AND l.label in ("+labelHealth+")) ";
|
|
|
|
|
|
if (!StringUtils.isEmpty(labelHealth)) {
|
|
|
|
whereSql += " (l.label_type = 2 AND l.label in (" + labelHealth + ")) ";
|
|
}
|
|
}
|
|
if(!StringUtils.isEmpty(labelDisease)){
|
|
|
|
if(!whereSql.endsWith(" and ( ")) {
|
|
|
|
whereSql += " or (l.label_type = 3 AND l.label in ("+labelDisease+"))) ";
|
|
|
|
}else{
|
|
|
|
whereSql += " (l.label_type = 1 AND l.label in ("+labelDisease+"))) ";
|
|
|
|
|
|
if (!StringUtils.isEmpty(labelDisease)) {
|
|
|
|
if (!whereSql.endsWith(" and ( ")) {
|
|
|
|
whereSql += " or (l.label_type = 3 AND l.label in (" + labelDisease + "))) ";
|
|
|
|
} else {
|
|
|
|
whereSql += " (l.label_type = 1 AND l.label in (" + labelDisease + "))) ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
tableSql += " left join wlyy_patient p on p.code=w.patient ";
|
|
tableSql += " left join wlyy_patient p on p.code=w.patient ";
|
|
if(!StringUtils.isEmpty(labelSex)){
|
|
|
|
whereSql += " and p.sex in ("+labelSex+") ";
|
|
|
|
|
|
if (!StringUtils.isEmpty(labelSex)) {
|
|
|
|
whereSql += " and p.sex in (" + labelSex + ") ";
|
|
}
|
|
}
|
|
if(!StringUtils.isEmpty(labelUnit)){
|
|
|
|
whereSql += " and w.hospital in ("+labelUnit+") ";
|
|
|
|
|
|
if (!StringUtils.isEmpty(labelUnit)) {
|
|
|
|
whereSql += " and w.hospital in (" + labelUnit + ") ";
|
|
}
|
|
}
|
|
List<String> groupPatient = jdbcTemplate.queryForList(tableSql+whereSql, String.class);
|
|
|
|
|
|
List<String> groupPatient = jdbcTemplate.queryForList(tableSql + whereSql, String.class);
|
|
patientSet.addAll(groupPatient);
|
|
patientSet.addAll(groupPatient);
|
|
}
|
|
}
|
|
|
|
|
|
@ -457,25 +487,22 @@ public class GcEduArticleService {
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
public List<HealthEduArticlePatientModel> pushArticleLogs(int page, int pagesize,String sendCode) throws Exception{
|
|
|
|
|
|
|
|
|
|
public List<HealthEduArticlePatientModel> pushArticleLogs(int page, int pagesize, String sendCode) throws Exception {
|
|
pagesize = page * pagesize;
|
|
pagesize = page * pagesize;
|
|
page = (page - 1) * pagesize;
|
|
page = (page - 1) * pagesize;
|
|
String sql = "select r.code as roleCode from wlyy_user_role u " +
|
|
String sql = "select r.code as roleCode from wlyy_user_role u " +
|
|
"left join wlyy_role r on r.`code`=u.role where u.user='"+sendCode+"'";
|
|
|
|
|
|
"left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "'";
|
|
|
|
|
|
Map<String,Object> resultMap = jdbcTemplate.queryForMap(sql);
|
|
|
|
|
|
Map<String, Object> resultMap = jdbcTemplate.queryForMap(sql);
|
|
sendCode = resultMap.get("roleCode").toString();
|
|
sendCode = resultMap.get("roleCode").toString();
|
|
StringBuffer sql2 = new StringBuffer("select * from " +esType+
|
|
|
|
|
|
StringBuffer sql2 = new StringBuffer("select * from " + esType +
|
|
" where sendCode='" + sendCode + "' ");
|
|
" where sendCode='" + sendCode + "' ");
|
|
sql2.append(" order by createTime limit " + page + "," + pagesize);
|
|
sql2.append(" order by createTime limit " + page + "," + pagesize);
|
|
List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
|
|
List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
|
|
List<HealthEduArticlePatientModel> returnList = new ArrayList<>();
|
|
|
|
Map<String,HealthEduArticlePatientModel> result = new HashMap<>();
|
|
|
|
|
|
Map<String, HealthEduArticlePatientModel> result = new HashMap<>();
|
|
HealthEduArticlePatientModel heapm = null;
|
|
HealthEduArticlePatientModel heapm = null;
|
|
com.alibaba.fastjson.JSONObject article = null;
|
|
com.alibaba.fastjson.JSONObject article = null;
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX");
|
|
|
|
for(HealthEduArticlePatient one :esList){
|
|
|
|
|
|
for (HealthEduArticlePatient one : esList) {
|
|
article = healthEducationArticleService.getArticalById(one.getArticleId());
|
|
article = healthEducationArticleService.getArticalById(one.getArticleId());
|
|
// com.yihu.es.entity.HealthEduArticlePatient p = findOne(one.getArticleId());
|
|
// com.yihu.es.entity.HealthEduArticlePatient p = findOne(one.getArticleId());
|
|
// if (p != null) {
|
|
// if (p != null) {
|
|
@ -484,10 +511,10 @@ public class GcEduArticleService {
|
|
// BeanUtils.copyProperties(p, heapm);
|
|
// BeanUtils.copyProperties(p, heapm);
|
|
// returnList.add(heapm);
|
|
// returnList.add(heapm);
|
|
// }
|
|
// }
|
|
if(result.get(one.getArticleId())!=null){
|
|
|
|
|
|
if (result.get(one.getArticleId()) != null) {
|
|
heapm = result.get(one.getArticleId());
|
|
heapm = result.get(one.getArticleId());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
} else {
|
|
heapm = new HealthEduArticlePatientModel();
|
|
heapm = new HealthEduArticlePatientModel();
|
|
}
|
|
}
|
|
heapm.setSendName(one.getSendName());
|
|
heapm.setSendName(one.getSendName());
|
|
@ -500,34 +527,64 @@ public class GcEduArticleService {
|
|
heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
|
|
heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
|
|
heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
|
|
heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
|
|
heapm.setLevel(article.getString("articlelevel"));
|
|
heapm.setLevel(article.getString("articlelevel"));
|
|
heapm.setAllCount(heapm.getAllCount()+one.getPatients().size());
|
|
|
|
heapm.setBrowseNumbere(article.getInteger("browseNumber"));
|
|
|
|
heapm.setCommentNumber(article.getInteger("commentNumber"));
|
|
|
|
result.put(one.getArticleId(),heapm);
|
|
|
|
};
|
|
|
|
List< HealthEduArticlePatientModel > resultList = new ArrayList<>();
|
|
|
|
for (Map.Entry< String, HealthEduArticlePatientModel > entry : result.entrySet()) {
|
|
|
|
|
|
heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
|
|
|
|
heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数
|
|
|
|
heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数
|
|
|
|
heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
|
|
|
|
heapm.setArticleCover(article.getString("articleCover"));//封面
|
|
|
|
heapm.setComputeTime(computeTime(article.getString("insertTime")));
|
|
|
|
|
|
|
|
// heapm.setTime();//时间 xx小时前 2017-10-11
|
|
|
|
result.put(one.getArticleId(), heapm);
|
|
|
|
}
|
|
|
|
List<HealthEduArticlePatientModel> resultList = new ArrayList<>();
|
|
|
|
for (Map.Entry<String, HealthEduArticlePatientModel> entry : result.entrySet()) {
|
|
resultList.add(entry.getValue());
|
|
resultList.add(entry.getValue());
|
|
}
|
|
}
|
|
return resultList;
|
|
return resultList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static String computeTime(String create) {
|
|
|
|
Date createDate = DateUtil.strToDate(create, "yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
|
Date nowDate = new Date();
|
|
|
|
//计算2个时间差
|
|
|
|
Long l = nowDate.getTime() - createDate.getTime();
|
|
|
|
|
|
|
|
long hour = l / (60 * 60 * 1000); //小时
|
|
|
|
long min = l / (60 * 1000);//分钟
|
|
|
|
long s = l / 1000;//秒
|
|
|
|
if(s<60){
|
|
|
|
return s+"秒前";
|
|
|
|
}
|
|
|
|
if(min<60){
|
|
|
|
return min+"分钟前";
|
|
|
|
}
|
|
|
|
if(hour<24){
|
|
|
|
return hour+"小时前";
|
|
|
|
}
|
|
|
|
return DateUtil.dateToStr(createDate,"yyyy-MM-dd");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
System.out.println(computeTime("2017-11-16 13:32:00.010"));
|
|
|
|
}
|
|
|
|
|
|
public Long pushArticleLogsCount(String sendCode) {
|
|
public Long pushArticleLogsCount(String sendCode) {
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("select count(distinct articleId) count from " +esType+
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("select count(distinct articleId) count from " + esType +
|
|
" where sendCode='" + sendCode + "' ");
|
|
" where sendCode='" + sendCode + "' ");
|
|
return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
|
|
return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public JSONObject pushArticleConfirm(String articleId, String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth) throws Exception{
|
|
|
|
|
|
public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth) throws Exception {
|
|
JSONObject article = healthEducationArticleService.getArticalById(articleId);
|
|
JSONObject article = healthEducationArticleService.getArticalById(articleId);
|
|
Set<String> patientSet = new HashSet<>();
|
|
Set<String> patientSet = new HashSet<>();
|
|
initPatient(patientSet,labelUnit,labelSex,labelServe,labelDisease,labelHealth);
|
|
|
|
|
|
initPatient(patientSet, labelUnit, labelSex, labelServe, labelDisease, labelHealth);
|
|
long num = patientSet.size();
|
|
long num = patientSet.size();
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
result.put("num",num);
|
|
|
|
result.put("articleTitle",article.getString("articleTitle"));
|
|
|
|
|
|
result.put("num", num);
|
|
|
|
result.put("articleTitle", article.getString("articleTitle"));
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|