|
@ -3,19 +3,25 @@ package com.yihu.wlyy.service.third.fzzb;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.yihu.es.entity.HealthEduArticlePatient;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
|
import com.yihu.wlyy.util.ElasticsearchUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
|
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
|
|
|
|
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
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.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 福州总部-健康教育医生APP接口文档
|
|
* 福州总部-健康教育医生APP接口文档
|
|
@ -31,6 +37,16 @@ public class HealthEducationArticleService extends BaseService{
|
|
private HttpClientUtil httpClientUtil;
|
|
private HttpClientUtil httpClientUtil;
|
|
@Autowired
|
|
@Autowired
|
|
private DoctorDao doctorDao;
|
|
private DoctorDao doctorDao;
|
|
|
|
@Value("${es.type.HealthEduArticlePatient}")
|
|
|
|
private String esType;
|
|
|
|
@Value("${es.index.HealthEduArticlePatient}")
|
|
|
|
private String esIndex;
|
|
|
|
@Autowired
|
|
|
|
private ElasticsearchUtil elasticsearchUtil;
|
|
|
|
@Autowired
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
@Autowired
|
|
|
|
private HealthEducationArticleService healthEducationArticleService;
|
|
|
|
|
|
// private String baseUrl = "http://service.yihu.com:8085/WsPlatform/rest";
|
|
// private String baseUrl = "http://service.yihu.com:8085/WsPlatform/rest";
|
|
private String baseUrl = "http://172.17.110.230:83/WsPlatform/rest";
|
|
private String baseUrl = "http://172.17.110.230:83/WsPlatform/rest";
|
|
@ -332,4 +348,123 @@ public class HealthEducationArticleService extends BaseService{
|
|
throw new Exception(json.getString("Message"));
|
|
throw new Exception(json.getString("Message"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// public JSONArray getPatientHealthLogs(int page, int pagesize,String sendCode, String articleType)throws Exception{
|
|
|
|
//
|
|
|
|
// pagesize = page * pagesize;
|
|
|
|
// page = (page - 1) * pagesize;
|
|
|
|
// StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from " + esType +
|
|
|
|
// " where sendCode='" + sendCode + "' ");
|
|
|
|
// if (!StringUtils.isEmpty(articleType)) {
|
|
|
|
// sql.append(" and articleType='" + articleType + "' ");
|
|
|
|
// }
|
|
|
|
// sql.append(" group by articleId order by createTime limit " + page + "," + pagesize);
|
|
|
|
// List<HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
|
|
|
|
// for(HealthEduArticlePatient one :esList){
|
|
|
|
// JSONObject jsonObject = getArticalById(one.getArticleId());
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// public JSONArray labelWithPushPatients(String labelType){
|
|
|
|
//
|
|
|
|
// String sql = "";
|
|
|
|
// List<DictModel> returnList = null;
|
|
|
|
// switch (labelType) {
|
|
|
|
// case "1": {
|
|
|
|
// sql = "select s.code code,s.name name from wlyy_sign_dict s where s.year='2017' order by s.sort asc";
|
|
|
|
// returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
|
|
|
|
// sql = "select count(DISTINCT(w.patient)) as num 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 "+
|
|
|
|
// " where w.status>0 and p.town='350211' ";
|
|
|
|
// for(DictModel one:returnList){
|
|
|
|
// sql +=" s.server_type='"+one.getCode()+"'";
|
|
|
|
// Map<String, Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
|
// JSONObject obj = new JSONObject();
|
|
|
|
// obj.put("code",one.getCode());
|
|
|
|
// obj.put("name",one.getName());
|
|
|
|
// obj.put("num",(Long)map.get("num"));
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// case "2": {
|
|
|
|
// sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=2 and status=1";
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// case "3": {
|
|
|
|
// sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=3 and status=1";
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// case "4": {
|
|
|
|
// sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=4 and status=1";
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
|
|
|
|
public JSONArray pushArticleLogs(int page, int pagesize,String patientCode)throws Exception{
|
|
|
|
|
|
|
|
pagesize = page * pagesize;
|
|
|
|
page = (page - 1) * pagesize;
|
|
|
|
//
|
|
|
|
// StringBuffer sql2 = new StringBuffer("select * from " + esType +
|
|
|
|
// " where sendCode='" + sendCode + "' ");
|
|
|
|
// sql2.append(" order by createTime limit " + page + "," + pagesize);
|
|
|
|
String sql = "SELECT * FROM "+esType+" where nested(patients.code)= '"+patientCode+"' order by createTime desc limit "+ page + "," + pagesize;
|
|
|
|
List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
|
|
|
|
HealthEduArticlePatientModel heapm = null;
|
|
|
|
com.alibaba.fastjson.JSONObject article = null;
|
|
|
|
List<HealthEduArticlePatientModel> result = new ArrayList<>();
|
|
|
|
for (HealthEduArticlePatient one : esList) {
|
|
|
|
article = healthEducationArticleService.getArticalById(one.getArticleId());
|
|
|
|
heapm = new HealthEduArticlePatientModel();
|
|
|
|
heapm.setSendName(one.getSendName());
|
|
|
|
heapm.setSendCode(one.getSendCode());
|
|
|
|
heapm.setCreateTime(one.getCreateTime());
|
|
|
|
heapm.setArticleId(article.getString("articleId"));
|
|
|
|
heapm.setAttachedTitle(article.getString("articleTitle"));
|
|
|
|
heapm.setAttachedContent(article.getString("articleContent"));
|
|
|
|
heapm.setArticleType(article.getString("articleType"));
|
|
|
|
heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
|
|
|
|
heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
|
|
|
|
heapm.setLevel(article.getString("articlelevel"));
|
|
|
|
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")));
|
|
|
|
result.add(heapm);
|
|
|
|
// heapm.setTime();//时间 xx小时前 2017-10-11
|
|
|
|
}
|
|
|
|
JSONArray re = new JSONArray();
|
|
|
|
re.addAll(result);
|
|
|
|
return re;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public 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");
|
|
|
|
}
|
|
}
|
|
}
|