|
@ -7,6 +7,7 @@ import com.yihu.es.entity.HealthEduArticlePatient;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.ElasticsearchUtil;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
@ -29,7 +30,7 @@ import java.util.*;
|
|
|
* Created by yeshijie on 2017/9/11.
|
|
|
*/
|
|
|
@Service
|
|
|
public class HealthEducationArticleService extends BaseService{
|
|
|
public class HealthEducationArticleService extends BaseService {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(HealthEducationArticleService.class);
|
|
|
|
|
@ -47,10 +48,14 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private HealthEducationArticleService healthEducationArticleService;
|
|
|
@Autowired
|
|
|
private PatientService patientService;
|
|
|
@Value("${jkEdu.web.articleBaseUrl}")
|
|
|
private String articleBaseUrl;
|
|
|
|
|
|
// 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.19.103.87:9088/JkEdu";
|
|
|
// private String baseUrl = "http://service.yihu.com:8085/WsPlatform/rest";
|
|
|
// private String baseUrl = "http://172.17.110.230:83/WsPlatform/rest";
|
|
|
// private String baseUrl = articleBaseUrl+"/WsPlatform/rest";
|
|
|
|
|
|
@Value("${yihu.yihu_OpenPlatform_appId}")
|
|
|
private String clientId;
|
|
@ -68,128 +73,132 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
|
|
|
/**
|
|
|
* 封装入参
|
|
|
*
|
|
|
* @param api
|
|
|
* @param param
|
|
|
* @param version
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String,String> getParamsMap(String api,String param,String version){
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
public Map<String, String> getParamsMap(String api, String param, String version) {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
JSONObject authInfo = new JSONObject();
|
|
|
authInfo.put("clientId",clientId);//填渠道ID(必填,固定为9000276)
|
|
|
authInfo.put("clientVersion",clientVersion);//接入方系统版本号(非必须,默认 1.0)
|
|
|
authInfo.put("sign","");//(保留,非必填)
|
|
|
authInfo.put("sessionKey","");//(保留,非必填)
|
|
|
params.put("AuthInfo",authInfo.toString());
|
|
|
authInfo.put("clientId", clientId);//填渠道ID(必填,固定为9000276)
|
|
|
authInfo.put("clientVersion", clientVersion);//接入方系统版本号(非必须,默认 1.0)
|
|
|
authInfo.put("sign", "");//(保留,非必填)
|
|
|
authInfo.put("sessionKey", "");//(保留,非必填)
|
|
|
params.put("AuthInfo", authInfo.toString());
|
|
|
params.put("SequenceNoString", DateUtil.getUserDate(DateUtil.YYYYMMddHHmmssSSS));//请求序列号,yyyyMMddHHmmssSSS 格式的时间戳
|
|
|
params.put("Api",api);//Api 名称 需要调用的 API 名称
|
|
|
params.put("Param",param);//本次请求的方法参数 Json结构的字符串
|
|
|
params.put("ParamType","0");//指定 param 参数的类型,固定传0
|
|
|
params.put("OutType","0");//指定返回 JSON/Xml 结构的字符串,固定传0
|
|
|
params.put("V",version);//API 版本号。版本号为整型,从数字 1 开始递增.
|
|
|
params.put("Api", api);//Api 名称 需要调用的 API 名称
|
|
|
params.put("Param", param);//本次请求的方法参数 Json结构的字符串
|
|
|
params.put("ParamType", "0");//指定 param 参数的类型,固定传0
|
|
|
params.put("OutType", "0");//指定返回 JSON/Xml 结构的字符串,固定传0
|
|
|
params.put("V", version);//API 版本号。版本号为整型,从数字 1 开始递增.
|
|
|
|
|
|
return params;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取文章列表
|
|
|
* @param articleTitle 否 文章标题
|
|
|
* @param articleState 否 传1
|
|
|
*
|
|
|
* @param articleTitle 否 文章标题
|
|
|
* @param articleState 否 传1
|
|
|
* @param firstLevelCategoryId 否 一级类别ID ,多个逗号隔开
|
|
|
* @param pageIndex 否 起始页数 0开始,默认0
|
|
|
* @param pageSize 否 每页显示数 ,默认5
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @param pageIndex 否 起始页数 0开始,默认0
|
|
|
* @param pageSize 否 每页显示数 ,默认5
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getDoctorArticalList(String articleTitle, Integer articleState, String firstLevelCategoryId, Integer pageIndex, Integer pageSize,String userId) throws Exception{
|
|
|
public JSONArray getDoctorArticalList(String articleTitle, Integer articleState, String firstLevelCategoryId, Integer pageIndex, Integer pageSize, String userId) throws Exception {
|
|
|
JSONArray re = new JSONArray();
|
|
|
JSONObject json = null;
|
|
|
try{
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("articleTitle",articleTitle);
|
|
|
param.put("articleState",articleState);
|
|
|
param.put("firstLevelCategoryId",firstLevelCategoryId);
|
|
|
param.put("pageIndex",pageIndex);
|
|
|
param.put("pageSize",pageSize);
|
|
|
param.put("userId",userId);
|
|
|
String response = httpClientUtil.httpPost(baseUrl,getParamsMap(getDoctorArticalList,param.toString(),"1"));
|
|
|
param.put("articleTitle", articleTitle);
|
|
|
param.put("articleState", articleState);
|
|
|
param.put("firstLevelCategoryId", firstLevelCategoryId);
|
|
|
param.put("pageIndex", pageIndex);
|
|
|
param.put("pageSize", pageSize);
|
|
|
param.put("userId", userId);
|
|
|
String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getDoctorArticalList, param.toString(), "1"));
|
|
|
json = JSON.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
if("10000".equals(json.getString("Code"))){
|
|
|
if ("10000".equals(json.getString("Code"))) {
|
|
|
return json.getJSONArray("Result");
|
|
|
}else {
|
|
|
} else {
|
|
|
throw new Exception(json.getString("Message"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取文章详情
|
|
|
*
|
|
|
* @param articleId 文章id
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getArticalById(String articleId) throws Exception{
|
|
|
public JSONObject getArticalById(String articleId) throws Exception {
|
|
|
JSONObject re = new JSONObject();
|
|
|
JSONObject json = null;
|
|
|
try{
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("articleId",articleId);
|
|
|
String response = httpClientUtil.httpPost(baseUrl,getParamsMap(getArticalById,param.toString(),"1"));
|
|
|
param.put("articleId", articleId);
|
|
|
String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getArticalById, param.toString(), "1"));
|
|
|
json = JSON.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
if("10000".equals(json.getString("Code"))){
|
|
|
if ("10000".equals(json.getString("Code"))) {
|
|
|
JSONArray result = json.getJSONArray("Result");
|
|
|
if(result.size()>0){
|
|
|
if (result.size() > 0) {
|
|
|
return result.getJSONObject(0);
|
|
|
}
|
|
|
return re;
|
|
|
}else {
|
|
|
} else {
|
|
|
throw new Exception(json.getString("Message"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取收藏文章列表
|
|
|
* @param articleTitle 否 文章标题
|
|
|
* @param articleState 否 传1
|
|
|
*
|
|
|
* @param articleTitle 否 文章标题
|
|
|
* @param articleState 否 传1
|
|
|
* @param firstLevelCategoryId 否 一级类别ID ,多个逗号隔开
|
|
|
* @param pageIndex 否 起始页数 0开始,默认0
|
|
|
* @param pageSize 否 每页显示数 ,默认5
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @param userType 是 1 医生 2 居民
|
|
|
* @param pageIndex 否 起始页数 0开始,默认0
|
|
|
* @param pageSize 否 每页显示数 ,默认5
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @param userType 是 1 医生 2 居民
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getCollectionArticalList(String articleTitle, Integer articleState, String firstLevelCategoryId,
|
|
|
Integer pageIndex, Integer pageSize,String userId,Integer userType) throws Exception{
|
|
|
Integer pageIndex, Integer pageSize, String userId, Integer userType) throws Exception {
|
|
|
JSONArray re = new JSONArray();
|
|
|
JSONObject json = null;
|
|
|
try{
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("articleTitle",articleTitle);
|
|
|
param.put("articleState",articleState);
|
|
|
param.put("firstLevelCategoryId",firstLevelCategoryId);
|
|
|
param.put("pageIndex",pageIndex);
|
|
|
param.put("pageSize",pageSize);
|
|
|
param.put("userId",userId);
|
|
|
param.put("userType",userType);
|
|
|
|
|
|
String response = httpClientUtil.httpPost(baseUrl,getParamsMap(getCollectionArticalList,param.toString(),"1"));
|
|
|
param.put("articleTitle", articleTitle);
|
|
|
param.put("articleState", articleState);
|
|
|
param.put("firstLevelCategoryId", firstLevelCategoryId);
|
|
|
param.put("pageIndex", pageIndex);
|
|
|
param.put("pageSize", pageSize);
|
|
|
param.put("userId", userId);
|
|
|
param.put("userType", userType);
|
|
|
|
|
|
String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getCollectionArticalList, param.toString(), "1"));
|
|
|
json = JSON.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
if("10000".equals(json.getString("Code"))){
|
|
|
if ("10000".equals(json.getString("Code"))) {
|
|
|
return json.getJSONArray("Result");
|
|
|
}else {
|
|
|
} else {
|
|
|
throw new Exception(json.getString("Message"));
|
|
|
}
|
|
|
}
|
|
@ -197,154 +206,158 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
|
|
|
/**
|
|
|
* 获取文章类别
|
|
|
*
|
|
|
* @param categoryLevel 是 获取类别:1、一级类别 2、二级类别
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getCategoryList(String categoryLevel) throws Exception{
|
|
|
public JSONArray getCategoryList(String categoryLevel) throws Exception {
|
|
|
JSONArray re = new JSONArray();
|
|
|
JSONObject json = null;
|
|
|
try{
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("categoryLevel",categoryLevel);
|
|
|
param.put("categoryLevel", categoryLevel);
|
|
|
|
|
|
String response = httpClientUtil.httpPost(baseUrl,getParamsMap(getCategoryList,param.toString(),"1"));
|
|
|
String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getCategoryList, param.toString(), "1"));
|
|
|
json = JSON.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
if("10000".equals(json.getString("Code"))){
|
|
|
if ("10000".equals(json.getString("Code"))) {
|
|
|
return json.getJSONObject("Result").getJSONArray("result");
|
|
|
}else {
|
|
|
} else {
|
|
|
throw new Exception(json.getString("Message"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 取消收藏文章
|
|
|
*
|
|
|
* @param articleId 是 文章id
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @param userType 是 1 医生 2 居民
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @param userType 是 1 医生 2 居民
|
|
|
* @return
|
|
|
*/
|
|
|
public void cancelArticleCollection(String articleId,String userId,Integer userType) throws Exception{
|
|
|
public void cancelArticleCollection(String articleId, String userId, Integer userType) throws Exception {
|
|
|
String response = "";
|
|
|
JSONObject json = null;
|
|
|
try{
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("articleId",articleId);
|
|
|
param.put("userId",userId);
|
|
|
param.put("userType",userType);
|
|
|
param.put("articleId", articleId);
|
|
|
param.put("userId", userId);
|
|
|
param.put("userType", userType);
|
|
|
|
|
|
response = httpClientUtil.httpPost(baseUrl,getParamsMap(cancelArticleCollection,param.toString(),"1"));
|
|
|
response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(cancelArticleCollection, param.toString(), "1"));
|
|
|
json = JSON.parseObject(response);
|
|
|
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if("10000".equals(json.getString("Code"))){
|
|
|
if ("10000".equals(json.getString("Code"))) {
|
|
|
|
|
|
}else {
|
|
|
} else {
|
|
|
new Exception(json.getString("Message"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 收藏文章列表
|
|
|
* @param articleId 文章id
|
|
|
* @param articleCategoryId 文章类别ID
|
|
|
*
|
|
|
* @param articleId 文章id
|
|
|
* @param articleCategoryId 文章类别ID
|
|
|
* @param articleCategoryName 文章类别名称
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @param userType 是 1 医生 2 居民
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @param userType 是 1 医生 2 居民
|
|
|
* @return
|
|
|
*/
|
|
|
public void saveArticleCollection(String articleId, String articleCategoryId, String articleCategoryName,String userId,Integer userType){
|
|
|
public void saveArticleCollection(String articleId, String articleCategoryId, String articleCategoryName, String userId, Integer userType) {
|
|
|
String response = "";
|
|
|
JSONObject json = null;
|
|
|
try{
|
|
|
try {
|
|
|
Doctor doctor = doctorDao.findByCode(userId);
|
|
|
String orgName = doctor.getHospitalName();//用户所属机构
|
|
|
String orgId = doctor.getHospital();//用户所属机构ID
|
|
|
String cName = doctor.getName();//用户名
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("articleId",articleId);
|
|
|
param.put("cName",cName);
|
|
|
param.put("articleCategoryId",articleCategoryId);
|
|
|
param.put("articleCategoryName",articleCategoryName);
|
|
|
param.put("orgName",orgName);
|
|
|
param.put("orgId",orgId);
|
|
|
param.put("userId",userId);
|
|
|
param.put("userType",userType);
|
|
|
|
|
|
response = httpClientUtil.httpPost(baseUrl,getParamsMap(saveArticleCollection,param.toString(),"1"));
|
|
|
param.put("articleId", articleId);
|
|
|
param.put("cName", cName);
|
|
|
param.put("articleCategoryId", articleCategoryId);
|
|
|
param.put("articleCategoryName", articleCategoryName);
|
|
|
param.put("orgName", orgName);
|
|
|
param.put("orgId", orgId);
|
|
|
param.put("userId", userId);
|
|
|
param.put("userType", userType);
|
|
|
|
|
|
response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(saveArticleCollection, param.toString(), "1"));
|
|
|
json = JSON.parseObject(response);
|
|
|
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if("10000".equals(json.getString("Code"))){
|
|
|
if ("10000".equals(json.getString("Code"))) {
|
|
|
|
|
|
}else {
|
|
|
} else {
|
|
|
new Exception(json.getString("Message"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取医生发表的文章列表
|
|
|
* @param articleTitle 否 文章标题
|
|
|
* @param articleState 否 传1
|
|
|
*
|
|
|
* @param articleTitle 否 文章标题
|
|
|
* @param articleState 否 传1
|
|
|
* @param firstLevelCategoryId 否 一级类别ID ,多个逗号隔开
|
|
|
* @param pageIndex 否 起始页数 0开始,默认0
|
|
|
* @param pageSize 否 每页显示数 ,默认5
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @param pageIndex 否 起始页数 0开始,默认0
|
|
|
* @param pageSize 否 每页显示数 ,默认5
|
|
|
* @param userId 是 当前用户ID
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getDoctorArticalByUserId(String articleTitle, Integer articleState, String firstLevelCategoryId,
|
|
|
Integer pageIndex, Integer pageSize,String userId) throws Exception{
|
|
|
Integer pageIndex, Integer pageSize, String userId) throws Exception {
|
|
|
JSONArray re = new JSONArray();
|
|
|
JSONObject json = null;
|
|
|
try{
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("articleTitle",articleTitle);
|
|
|
param.put("articleState",articleState);
|
|
|
param.put("firstLevelCategoryId",firstLevelCategoryId);
|
|
|
param.put("pageIndex",pageIndex);
|
|
|
param.put("pageSize",pageSize);
|
|
|
param.put("userId",userId);
|
|
|
|
|
|
String response = httpClientUtil.httpPost(baseUrl,getParamsMap(getDoctorArticalByUserId,param.toString(),"1"));
|
|
|
param.put("articleTitle", articleTitle);
|
|
|
param.put("articleState", articleState);
|
|
|
param.put("firstLevelCategoryId", firstLevelCategoryId);
|
|
|
param.put("pageIndex", pageIndex);
|
|
|
param.put("pageSize", pageSize);
|
|
|
param.put("userId", userId);
|
|
|
|
|
|
String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getDoctorArticalByUserId, param.toString(), "1"));
|
|
|
json = JSON.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
if("10000".equals(json.getString("Code"))){
|
|
|
if ("10000".equals(json.getString("Code"))) {
|
|
|
return json.getJSONArray("Result");
|
|
|
}else {
|
|
|
} else {
|
|
|
throw new Exception(json.getString("Message"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public JSONArray getArticalList(String articleId,int articleState,int pageIndex,int pageSize) throws Exception{
|
|
|
public JSONArray getArticalList(String articleId, int articleState, int pageIndex, int pageSize) throws Exception {
|
|
|
JSONArray re = new JSONArray();
|
|
|
JSONObject json = null;
|
|
|
try{
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("articleId",articleId);
|
|
|
param.put("articleState",articleState);
|
|
|
param.put("pageIndex",pageIndex);
|
|
|
param.put("pageSize",pageSize);
|
|
|
String response = httpClientUtil.httpPost(baseUrl,getParamsMap(getArticalList,param.toString(),"1"));
|
|
|
param.put("articleId", articleId);
|
|
|
param.put("articleState", articleState);
|
|
|
param.put("pageIndex", pageIndex);
|
|
|
param.put("pageSize", pageSize);
|
|
|
String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getArticalList, param.toString(), "1"));
|
|
|
json = JSON.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return re;
|
|
|
}
|
|
|
if("10000".equals(json.getString("Code"))){
|
|
|
if ("10000".equals(json.getString("Code"))) {
|
|
|
return json.getJSONArray("Result");
|
|
|
}else {
|
|
|
} else {
|
|
|
throw new Exception(json.getString("Message"));
|
|
|
}
|
|
|
}
|
|
@ -367,40 +380,122 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
// return null;
|
|
|
// }
|
|
|
|
|
|
public JSONArray labelWithPushPatients(String labelType){
|
|
|
public JSONArray labelWithPushPatients(String labelType, String condition,String teamCode) {
|
|
|
|
|
|
String[] cond = {};
|
|
|
if (!StringUtils.isEmpty(condition)) {
|
|
|
cond = condition.split(",");
|
|
|
}
|
|
|
StringBuilder whereSql = new StringBuilder();
|
|
|
String tableSql = "";
|
|
|
for (String one : cond) {
|
|
|
if ("1".equals(one)) {//有绑定设备
|
|
|
tableSql = "LEFT JOIN wlyy_patient_device d on d.user=aa.patient and d.device_id is not null ";
|
|
|
} else if ("2".equals(one)) {//孕产妇
|
|
|
// temp.add("41");
|
|
|
whereSql.append(" and tt LIKE '%41%' ");
|
|
|
} else if ("3".equals(one)) {//65岁以上老年人
|
|
|
// temp.add("13");
|
|
|
whereSql.append(" and tt LIKE '%13%' ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String sql = "";
|
|
|
List<DictModel> returnList = null;
|
|
|
Map<String, Object> map = null;
|
|
|
JSONArray re = new JSONArray();
|
|
|
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);
|
|
|
for (DictModel one : returnList) {
|
|
|
// 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' ";
|
|
|
// sql +=" and s.server_type='"+one.getCode()+"'";
|
|
|
|
|
|
sql = " SELECT count(DISTINCT(aa.patient)) AS num FROM " +
|
|
|
" ( SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l, " +
|
|
|
" wlyy_sign_family_server q WHERE w. STATUS > 0 AND l. STATUS = 1 AND w.team_code=" +teamCode+
|
|
|
" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' " +
|
|
|
" AND w. CODE = q.sign_code AND q.server_type = 1 ) a " +
|
|
|
" GROUP BY a.patient HAVING 1 = 1 AND tt LIKE '%1" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
|
|
|
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"));
|
|
|
obj.put("code", one.getCode());
|
|
|
obj.put("name", one.getName());
|
|
|
obj.put("num", (Long) map.get("num"));
|
|
|
re.add(obj);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "2": {
|
|
|
sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=2 and status=1";
|
|
|
returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
|
|
|
for (DictModel one : returnList) {
|
|
|
// sql =" select count(DISTINCT(w.patient)) as num 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 "+
|
|
|
// " where w.status>0 and p.town='350211' and l.status=1 and l.label_type = 2 AND l.label ="+one.getCode();
|
|
|
|
|
|
sql = " select count(DISTINCT(aa.patient)) as num from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +//AND w.team_code=" +teamCode+
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING tt LIKE '%2" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
|
|
|
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"));
|
|
|
re.add(obj);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "3": {
|
|
|
sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=3 and status=1";
|
|
|
returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
|
|
|
for (DictModel one : returnList) {
|
|
|
// sql =" select count(DISTINCT(w.patient)) as num 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 "+
|
|
|
// " where w.status>0 and p.town='350211' and l.status=1 and l.label_type = 3 AND l.label ="+one.getCode();
|
|
|
sql = " select count(DISTINCT(aa.patient)) as num from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING tt LIKE '%3" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
|
|
|
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"));
|
|
|
re.add(obj);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "4": {
|
|
|
sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=4 and status=1";
|
|
|
returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
|
|
|
for (DictModel one : returnList) {
|
|
|
// sql =" select count(DISTINCT(w.patient)) as num 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 "+
|
|
|
// " where w.status>0 and p.town='350211' and l.status=1 and l.label_type = 4 AND l.label ='"+one.getCode()+"'";
|
|
|
sql = " select count(DISTINCT(aa.patient)) as num from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING tt LIKE '%4" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
|
|
|
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"));
|
|
|
re.add(obj);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
@ -408,7 +503,7 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
public JSONArray pushArticleLogs(int page, int pagesize,String patientCode)throws Exception{
|
|
|
public JSONArray pushArticleLogs(int page, int pagesize, String patientCode) throws Exception {
|
|
|
|
|
|
pagesize = page * pagesize;
|
|
|
page = (page - 1) * pagesize;
|
|
@ -416,11 +511,12 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
// 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;
|
|
|
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<>();
|
|
|
Doctor doctor = null;
|
|
|
for (HealthEduArticlePatient one : esList) {
|
|
|
article = healthEducationArticleService.getArticalById(one.getArticleId());
|
|
|
heapm = new HealthEduArticlePatientModel();
|
|
@ -440,6 +536,9 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
|
|
|
heapm.setArticleCover(article.getString("articleCover"));//封面
|
|
|
heapm.setComputeTime(computeTime(article.getString("insertTime")));
|
|
|
heapm.setOperatorName(article.getString("operatorName"));
|
|
|
doctor = doctorDao.findByCode(one.getDoctorCode());
|
|
|
heapm.setPhoto(doctor.getPhoto());
|
|
|
result.add(heapm);
|
|
|
// heapm.setTime();//时间 xx小时前 2017-10-11
|
|
|
}
|
|
@ -449,8 +548,7 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String computeTime(String create) {
|
|
|
public String computeTime(String create) {
|
|
|
Date createDate = DateUtil.strToDate(create, "yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
Date nowDate = new Date();
|
|
|
//计算2个时间差
|
|
@ -459,15 +557,171 @@ public class HealthEducationArticleService extends BaseService{
|
|
|
long hour = l / (60 * 60 * 1000); //小时
|
|
|
long min = l / (60 * 1000);//分钟
|
|
|
long s = l / 1000;//秒
|
|
|
if(s<60){
|
|
|
return s+"秒前";
|
|
|
if (s < 60) {
|
|
|
return s + "秒前";
|
|
|
}
|
|
|
if (min < 60) {
|
|
|
return min + "分钟前";
|
|
|
}
|
|
|
if (hour < 24) {
|
|
|
return hour + "小时前";
|
|
|
}
|
|
|
return DateUtil.dateToStr(createDate, "yyyy-MM-dd");
|
|
|
}
|
|
|
|
|
|
public JSONObject pushArticleConfirm(String articleId,String labelType, String condition, String groupType,String teamCode) throws Exception{
|
|
|
JSONObject article = healthEducationArticleService.getArticalById(articleId);
|
|
|
Set<String> patientSet = new HashSet<>();
|
|
|
initPatient(patientSet,labelType,condition,groupType,teamCode);
|
|
|
long num = patientSet.size();
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("num", num);
|
|
|
result.put("articleTitle", article.getString("articleTitle"));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public void initPatient(Set<String> patientSet, String labelType, String condition, String groupType,String teamCode) {
|
|
|
|
|
|
String[] cond = {};
|
|
|
String[] group = {};
|
|
|
if (!StringUtils.isEmpty(condition)) {
|
|
|
cond = condition.split(",");
|
|
|
}
|
|
|
if(min<60){
|
|
|
return min+"分钟前";
|
|
|
StringBuilder whereSql = new StringBuilder();
|
|
|
String tableSql = "";
|
|
|
for (String one : cond) {
|
|
|
if ("1".equals(one)) {//有绑定设备
|
|
|
tableSql = " LEFT JOIN wlyy_patient_device d on d.user=aa.patient and d.device_id is not null ";
|
|
|
} else if ("2".equals(one)) {//孕产妇
|
|
|
// temp.add("41");
|
|
|
whereSql.append(" and tt LIKE '%41%' ");
|
|
|
} else if ("3".equals(one)) {//65岁以上老年人
|
|
|
// temp.add("13");
|
|
|
whereSql.append(" and tt LIKE '%13%' ");
|
|
|
}
|
|
|
}
|
|
|
if(hour<24){
|
|
|
return hour+"小时前";
|
|
|
|
|
|
if (!StringUtils.isEmpty(groupType)) {
|
|
|
group = groupType.split(",");
|
|
|
}
|
|
|
return DateUtil.dateToStr(createDate,"yyyy-MM-dd");
|
|
|
StringBuilder whereSql2 = new StringBuilder();
|
|
|
// for (String one : group) {
|
|
|
// whereSql2.append(" and tt LIKE '%" + labelType + one + "%' ");
|
|
|
// }
|
|
|
// String whereSql2Str = whereSql2.toString().substring(3);
|
|
|
String sql = "";
|
|
|
Map<String, Object> map = null;
|
|
|
List<String> groupPatient = null;
|
|
|
List<String> resultList = new ArrayList<>();
|
|
|
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));
|
|
|
// for(DictModel one:returnList){
|
|
|
// 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' ";
|
|
|
// sql +=" and s.server_type='"+one.getCode()+"'";
|
|
|
for (String one : group) {
|
|
|
sql = " SELECT DISTINCT(aa.patient) FROM " +
|
|
|
" ( SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l, " +
|
|
|
" wlyy_sign_family_server q WHERE w. STATUS > 0 AND l. STATUS = 1 AND w.team_code=" +teamCode+
|
|
|
" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' " +
|
|
|
" AND w. CODE = q.sign_code AND q.server_type = 1 ) a " +
|
|
|
" GROUP BY a.patient HAVING 1 = 1 " + whereSql + " and tt LIKE '%" + labelType + one + "%' ) aa " + tableSql;
|
|
|
groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
// JSONObject obj = new JSONObject();
|
|
|
// obj.put("code",one.getCode());
|
|
|
// obj.put("name",one.getName());
|
|
|
// obj.put("num",(Long)map.get("num"));
|
|
|
// re.add(obj);
|
|
|
// }
|
|
|
resultList.addAll(groupPatient);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "2": {
|
|
|
// sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=2 and status=1";
|
|
|
// returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
|
|
|
// for(DictModel one:returnList){
|
|
|
// sql =" select count(DISTINCT(w.patient)) as num 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 "+
|
|
|
// " where w.status>0 and p.town='350211' and l.status=1 and l.label_type = 2 AND l.label ="+one.getCode();
|
|
|
for (String one : group) {
|
|
|
sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING 1=1 " + whereSql + " and tt LIKE '%" + labelType + one + "%' ) aa " + tableSql;
|
|
|
// 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"));
|
|
|
// re.add(obj);
|
|
|
groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
resultList.addAll(groupPatient);
|
|
|
// }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "3": {
|
|
|
// sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=3 and status=1";
|
|
|
// returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
|
|
|
// for(DictModel one:returnList){
|
|
|
// sql =" select count(DISTINCT(w.patient)) as num 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 "+
|
|
|
// " where w.status>0 and p.town='350211' and l.status=1 and l.label_type = 3 AND l.label ="+one.getCode();
|
|
|
for (String one : group) {
|
|
|
sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING 1=1 " + whereSql + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
|
|
|
// 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"));
|
|
|
// re.add(obj);
|
|
|
groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
resultList.addAll(groupPatient);
|
|
|
// }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "4": {
|
|
|
// sql = "select label_code code, label_name name from wlyy_sign_patient_label where label_type=4 and status=1";
|
|
|
// returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
|
|
|
// for(DictModel one:returnList){
|
|
|
// sql =" select count(DISTINCT(w.patient)) as num 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 "+
|
|
|
// " where w.status>0 and p.town='350211' and l.status=1 and l.label_type = 4 AND l.label ='"+one.getCode()+"'";
|
|
|
for (String one : group) {
|
|
|
sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING 1=1 " + whereSql.toString() + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
|
|
|
// 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"));
|
|
|
// re.add(obj);
|
|
|
groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
resultList.addAll(groupPatient);
|
|
|
// }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
patientSet.addAll(resultList);
|
|
|
}
|
|
|
|
|
|
}
|