浏览代码

【患者端】类型-服务记录中未显示新发的健康教育文章。

liuwenbin 7 年之前
父节点
当前提交
90fa545cc5

+ 31 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.sign;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.wlyy.entity.address.Country;
import com.yihu.wlyy.entity.address.Street;
import com.yihu.wlyy.entity.address.Town;
@ -34,6 +35,7 @@ import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.third.jw.JwSignService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
@ -42,6 +44,7 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -49,6 +52,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -117,6 +121,12 @@ public class SignWebService extends BaseService {
    private SMSService smsService;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    /**
     * 厦门市
     */
@ -1025,11 +1035,13 @@ public class SignWebService extends BaseService {
        return object;
    }
    public JSONObject getSignServiceInfo(String signCode) {
    public JSONObject getSignServiceInfo(String signCode) throws Exception{
        SignFamily signFamily = signFamilyDao.findByCode(signCode);
        if (signFamily == null) {
            return new JSONObject();
        }
        String doctorHealth = signFamily.getDoctorHealth();
        String doctor = signFamily.getDoctor();
        Patient p = patientService.findByCode(signFamily.getPatient());
        String patient = p.getCode();
        //获取咨询
@ -1039,12 +1051,18 @@ public class SignWebService extends BaseService {
        //获取待预约
        String reservation_sql = "select w.code,w.id, w.doctor_name,w.doctor_code,w.doctor_job,w.doctor,w.dname,w.org_code,w.status,w.start_time as czrq,3 as type from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //获取健康教育
        String article_sql = "select w.id,w.article,w2.title,w2.summary,w.czrq,w.doctor,w.doctor_name,w.is_read,4 as type from wlyy_health_edu_article_patient  w,wlyy_health_edu_article w2 where w.article = w2.code and  (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
//        String article_sql = "select w.id,w.article,w2.title,w2.summary,w.czrq,w.doctor,w.doctor_name,w.is_read,4 as type from wlyy_health_edu_article_patient  w,wlyy_health_edu_article w2 where w.article = w2.code and  (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        Date startTime = DateUtil.getBeginDayOfYear();
        Date endTime = DateUtil.getEndDayOfYear();
        String startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime);
        String endDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endTime);
        String start = elasticsearchUtil.changeTime(startDate);
        String end = elasticsearchUtil.changeTime(endDate);
        String article_sql = "SELECT id,articleId as article,articleTitle as title,createTime as czrq,doctorCode as doctor,doctorName as doctor_name,isRead as is_read,articleContent as content FROM "+esIndex+" where userType='1' and patientCode='"+patient+"' and (doctorCode='"+doctorHealth+"' or doctorCode='"+doctor+"') and createTime>='"+start+"' and createTime<='"+end+"'";
        //获取健康指导
        String guidance_sql = "select w.id,w.doctor,w.content,w.czrq,w.read_status,5 as type  from wlyy_patient_health_guidance  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        String doctorHealth = signFamily.getDoctorHealth();
        String doctor = signFamily.getDoctor();
        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"));
        int year = calendar.get(Calendar.YEAR);
        //咨询量
@ -1054,7 +1072,15 @@ public class SignWebService extends BaseService {
        //待预约量
        List<Map<String, Object>> reservationResult = jdbcTemplate.queryForList(reservation_sql, new Object[]{doctorHealth, doctor, patient, year});
        //健康教育量
        List<Map<String, Object>> articleResult = jdbcTemplate.queryForList(article_sql, new Object[]{doctorHealth, doctor, patient, year});
//        List<Map<String, Object>> articleResult = jdbcTemplate.queryForList(article_sql, new Object[]{doctorHealth, doctor, patient, year});
//        List<HealthEduArticleES> esList = elasticsearchUtil.excute(article_sql, HealthEduArticleES.class, esIndex, esType);
        List<Map<String, Object>> articleResult = elasticsearchUtil.excuteDataModel(article_sql);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for(Map<String, Object> map :articleResult){
            map.put("type","4");
            map.put("czrq",map.get("czrq")!=null?simpleDateFormat.format(new Date(((Long)map.get("czrq")).longValue())):"");
            map.put("summary",map.get("content")!=null?(map.get("content").toString().length()>40?map.get("content").toString().substring(0,40):map.get("content").toString()):"");
        }
        //健康指导量
        List<Map<String, Object>> guidanceResult = jdbcTemplate.queryForList(guidance_sql, new Object[]{doctorHealth, doctor, patient, year});
        List<JSONObject> objects = new ArrayList<>();