Explorar el Código

Merge branch 'dev' of wujunjie/patient-co-management into dev

yeshijie hace 7 años
padre
commit
24cf9dc117

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java


+ 91 - 11
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java

@ -1,13 +1,21 @@
package com.yihu.wlyy.service.manager.feedback;
import com.yihu.wlyy.entity.Doctor;
import com.yihu.wlyy.entity.Followup;
import com.yihu.wlyy.entity.Message;
import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.repository.DoctorDao;
import com.yihu.wlyy.repository.MessageDao;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.feedback.FeedbackDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
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.domain.Sort;
@ -17,10 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by Reece on 2017/5/6.
@ -34,6 +40,12 @@ public class FeedbackService extends BaseService {
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Value("${wlyyService.api}")
    private String wlyyService;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private MessageDao messageDao;
    /**
     * 分页查找问题
@ -55,13 +67,13 @@ public class FeedbackService extends BaseService {
        PageRequest pageRequest = new PageRequest(page - 1, rows, sort);
        // 设置查询条件
        Map<String, SearchFilter> filters = new HashMap<>();
        if (type!=-1) {
        if (type != -1) {
            filters.put("type", new SearchFilter("type", SearchFilter.Operator.EQ, type));
        }
        if (identity!=-1) {
        if (identity != -1) {
            filters.put("identity", new SearchFilter("identity", SearchFilter.Operator.EQ, identity));
        }
        if (status!=-1) {
        if (status != -1) {
            filters.put("status", new SearchFilter("status", SearchFilter.Operator.EQ, status));
        }
        // 未删除
@ -126,7 +138,7 @@ public class FeedbackService extends BaseService {
        int status = feedback.getStatus();
//        identity 1、患者 2、医生
        String name = null;
        if(StringUtils.isNotBlank(creater)) {
        if (StringUtils.isNotBlank(creater)) {
            if (identity == 1) {
                name = patientDao.findNameByCode(creater);
            } else {
@ -148,9 +160,9 @@ public class FeedbackService extends BaseService {
    public void delfeedback(String ids) {
        if(ids!=null){
        if (ids != null) {
            String[] _ids = ids.split(",");
            for(String id:_ids){
            for (String id : _ids) {
                Long _id = Long.valueOf(id);
                feedbackDao.delFeedback(_id);
            }
@ -163,10 +175,78 @@ public class FeedbackService extends BaseService {
     * @param result
     * @throws Exception
     */
    public void dealFeedback(Long id,String result) throws Exception {
    public void dealFeedback(Long id, String result) throws Exception {
        Feedback feedback = feedbackDao.findFeedbackById(id);
        feedback.setResult(result);
        feedback.setStatus(2);
        int identity = feedback.getIdentity();
        int type = feedback.getType();
        String typeName = null;
        String creater = feedback.getCreater();
        switch (type) {
            case 1:
                typeName = "优化建议";
                break;
            case 2:
                typeName = "提交bug";
                break;
            case 3:
                typeName = "新功能建议";
                break;
            case 4:
                typeName = "其他";
                break;
        }
        if (identity == 1) {
            //wlyy给患者发送模板消息
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Patient patient = patientDao.findByCode(creater);
            String patientName = patient.getName();
            String patientOpendID = patient.getOpenid();
            if (StringUtils.isNotEmpty(patientOpendID)) {
                String url = wlyyService + "/patient/feedback/sendTemplate";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("toUser", patientOpendID));
                params.add(new BasicNameValuePair("url", null));
                params.add(new BasicNameValuePair("first", "您好!您提交的意见反馈已处理"));
                params.add(new BasicNameValuePair("remark", "感谢你的意见"));
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                String newDate = formatDate.format(new Date());
                String keywords = patientName + "," + typeName + "," + result + "," + newDate;
                params.add(new BasicNameValuePair("keywords", keywords));
                httpClientUtil.post(url, params, "UTF-8");
            }
        } else if (identity == 2) {
            SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
            String newDate = formatDate.format(new Date());
            String title = "新增系统消息";
            String content = "您在" + newDate + "提交的意见反馈已处理,您可点此查看处理结果";
            Message message = new Message();
            message.setType(10);
            message.setCode(UUID.randomUUID().toString());
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent(content);
            message.setRead(1);//设置未读
            message.setReceiver(creater);//设置接受医生的code
            message.setSender("system");//设置发送的用户
            message.setTitle(title);
            message.setReadonly(1);//是否只读消息
            //wlyy给医生发送系统消息
            Doctor doctor = doctorDao.findByCode(creater);
            String doctorOpenID = doctor.getOpenid();
            String url = wlyyService + "/patient/feedback/sendMessage";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("receiver", creater));
            params.add(new BasicNameValuePair("title", title));
            params.add(new BasicNameValuePair("content",content));
            httpClientUtil.post(url, params, "UTF-8");
            messageDao.save(message);
        }
        feedbackDao.save(feedback);
    }

+ 7 - 2
patient-co-manage/wlyy-manage/src/main/resources/application.yml

@ -75,7 +75,8 @@ yueren:
  api: http://120.77.209.211:8080
doctorAssistant:
  api: http://192.168.131.113:8080
#  api: http://172.19.103.88:10090/wlyy
wlyyService:
  api: http://172.19.103.88:10090/wlyy
---
spring:
@ -108,6 +109,8 @@ yueren:
  api: http://120.77.209.211:8080
doctorAssistant:
  api: http://172.19.103.88:10090/wlyy
wlyyService:
  api: http://172.19.103.88:10090/wlyy
---
spring:
@ -137,4 +140,6 @@ im-service:
yueren:
  api: http://120.77.209.211:8080
doctorAssistant:
  api: http://www.xmtyw.cn/assistant
  api: http://www.xmtyw.cn/assistant
wlyyService:
  api: http://172.19.103.88:10090/wlyy

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -23,6 +23,10 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.doctorCode = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByDoctor(String doctor, Date begin, Date end) throws Exception;
    //查询未完成有效随访记录
    @Query("select a from Followup a where a.doctorCode = ?1 and a.followupDate between ?2 and ?3 and a.status NOT IN ('0', '1') ")
    List<Followup> getByDoctor(String doctor, Date begin, Date end) throws Exception;
    @Query("select a from Followup a where a.creater = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByCreater(String creater, Date begin, Date end, Pageable pageRequest) throws Exception;

+ 135 - 125
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -158,22 +158,22 @@ public class FollowUpService extends BaseService {
        re.put("followupTypeName", followupTypeName);
        //随访类别转译
        
        String followupClass = followup.getFollowupClass();
        re.put("followupClass", followupClass);
    
        String followupClassName = systemDictService.getDictValue("FOLLOWUP_CLASS_DICT", followup.getFollowupClass());
        if(StringUtils.isNoneBlank(followupClass) && followupClass.contains(",")){
        if (StringUtils.isNoneBlank(followupClass) && followupClass.contains(",")) {
            String[] followupClassArray = followupClass.split(",");
            followupClassName = "";
            for (int i = 0; i < followupClassArray.length; i++) {
                followupClassName += systemDictService.getDictValue("FOLLOWUP_CLASS_DICT", followupClassArray[i]);
                if(i != followupClassArray.length -1){
                    followupClassName +=",";
                if (i != followupClassArray.length - 1) {
                    followupClassName += ",";
                }
            }
        }
        
        re.put("followupClassName", followupClassName);
        //随访管理状态转译
@ -206,23 +206,23 @@ public class FollowUpService extends BaseService {
            for (Followup followup : list) {
                String date = DateUtil.dateToStrShort(followup.getFollowupDate());
                Map<String, String> map = getFollowupDetail(followup);
                if(temp.containsKey(date)){
                if (temp.containsKey(date)) {
                    Map<String, Object> vo = temp.get(date);
                    vo.put("num",Integer.parseInt(vo.get("num").toString())+1);
                    ((List<Map<String, String>>)vo.get("list")).add(map);
                    temp.put(date,vo);
                }else{
                    vo.put("num", Integer.parseInt(vo.get("num").toString()) + 1);
                    ((List<Map<String, String>>) vo.get("list")).add(map);
                    temp.put(date, vo);
                } else {
                    Map<String, Object> vo = new HashMap<>();
                    List<Map<String, String>> list1 = new ArrayList<>();
                    vo.put("date",date);
                    vo.put("num",1);
                    vo.put("date", date);
                    vo.put("num", 1);
                    list1.add(map);
                    vo.put("list",list1);
                    temp.put(date,vo);
                    vo.put("list", list1);
                    temp.put(date, vo);
                }
            }
            for (Map<String, Object> map:temp.values()){
            for (Map<String, Object> map : temp.values()) {
                re.add(map);
            }
        }
@ -237,25 +237,26 @@ public class FollowUpService extends BaseService {
     * @param teamCode
     * @param page
     * @param pageSize
     * @param type 类型:0全部,1计划,2记录
     * @param type     类型:0全部,1计划,2记录
     * @return
     */
    public JSONArray getListByPatientAndTeam(String patient, Long teamCode, int page, int pageSize, String type) {
        Sort sort = new Sort(Sort.Direction.DESC,"createTime");
        PageRequest pageRequest = new PageRequest(page, pageSize,sort);
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest pageRequest = new PageRequest(page, pageSize, sort);
        Page<Object> result = null;
        
        if(StringUtils.isBlank(type)){
        if (StringUtils.isBlank(type)) {
            result = followupDao.findByPatientAndTeam(patient, teamCode, pageRequest);
        }else if("1".equals(type)){
        } else if ("1".equals(type)) {
            //已经开始的就是记录
            result = followupDao.findPlanByPatientAndTeam(patient, teamCode, pageRequest);
        }else if("2".equals(type)){
        } else if ("2".equals(type)) {
            //未开始的就是计划
            result = followupDao.findRecordByPatientAndTeam(patient, teamCode, pageRequest);
        }else{}
                
        
        } else {
        }
        JSONArray array = new JSONArray();
        if (result != null && result.getContent().size() > 0) {
@ -285,10 +286,10 @@ public class FollowUpService extends BaseService {
                Object[] objArr = (Object[]) obj;
//              返回值增加居民信息
                Patient patientDetail = patientDao.findByCode(patient);
                followup.put("patientName", patientDetail.getName()!=null?patientDetail.getName():"");
                followup.put("photo", patientDetail.getPhoto()!=null?patientDetail.getPhoto():"");
                followup.put("sex", patientDetail.getSex()!=null?patientDetail.getSex():"");
                followup.put("birthday", patientDetail.getBirthday()!=null?patientDetail.getBirthday():"");
                followup.put("patientName", patientDetail.getName() != null ? patientDetail.getName() : "");
                followup.put("photo", patientDetail.getPhoto() != null ? patientDetail.getPhoto() : "");
                followup.put("sex", patientDetail.getSex() != null ? patientDetail.getSex() : "");
                followup.put("birthday", patientDetail.getBirthday() != null ? patientDetail.getBirthday() : "");
                followup.put("id", objArr[15]);
                followup.put("followupNo", objArr[16]);
@ -298,34 +299,35 @@ public class FollowUpService extends BaseService {
                followup.put("followupType", objArr[3] == null ? "" : objArr[3]);
                followup.put("followupTypeName", objArr[3] == null ? "" : (dictMap.get(objArr[3].toString()) != null ? dictMap.get(objArr[3].toString()) : ""));
                followup.put("followupClass", objArr[4] == null ? "" : objArr[4]);
    
//                followup.put("followupClassName", objArr[4] == null ? "" : (objArr[4].toString().equals("1") ? "高血压" : "糖尿病"));
               
                if( objArr[4] == null){
                if (objArr[4] == null) {
                    followup.put("followupClassName", "");
                }else{
                    if(objArr[4].toString().equals("1")){
                } else {
                    if (objArr[4].toString().equals("1")) {
                        followup.put("followupClassName", "高血压");
                    }else if(objArr[4].toString().equals("2")){
                    } else if (objArr[4].toString().equals("2")) {
                        followup.put("followupClassName", "糖尿病");
                    }else if(objArr[4].toString().equals("3")){
                    } else if (objArr[4].toString().equals("3")) {
                        followup.put("followupClassName", "高血压,糖尿病");
                    }else{}
                    } else {
                    }
                }
                
                
                followup.put("status", objArr[5] == null ? "" : objArr[5]);
                followup.put("statusName", objArr[5] == null ? "" : (statusMap.get(objArr[5].toString()) != null ? statusMap.get(objArr[5].toString()) : ""));
                followup.put("createTime", objArr[6] != null ? DateUtil.dateToStrLong((Date)objArr[6]) : "");
                followup.put("updateTime", objArr[7] != null ? DateUtil.dateToStrLong((Date)objArr[7]) : "");
                followup.put("createTime", objArr[6] != null ? DateUtil.dateToStrLong((Date) objArr[6]) : "");
                followup.put("updateTime", objArr[7] != null ? DateUtil.dateToStrLong((Date) objArr[7]) : "");
                followup.put("followupManagerStatus", objArr[8] == null ? "" : objArr[8]);
                followup.put("followupManagerStatusName", objArr[8] == null ? "" : (mngStatusMap.get(objArr[8].toString()) != null ? mngStatusMap.get(objArr[8].toString()) : ""));
                followup.put("creatorCode", objArr[9]);
                followup.put("creatorName", objArr[10]);
                followup.put("creatorPhoto", objArr[11]);
                followup.put("followupDate", objArr[12] != null ? DateUtil.dateToStrLong((Date)objArr[12]) : "");
                followup.put("followupPlanDate", objArr[13] != null ? DateUtil.dateToStrLong((Date)objArr[13]) : "");
                followup.put("followupNextDate", objArr[14] != null ? DateUtil.dateToStrLong((Date)objArr[14]) : "");
                followup.put("followupDate", objArr[12] != null ? DateUtil.dateToStrLong((Date) objArr[12]) : "");
                followup.put("followupPlanDate", objArr[13] != null ? DateUtil.dateToStrLong((Date) objArr[13]) : "");
                followup.put("followupNextDate", objArr[14] != null ? DateUtil.dateToStrLong((Date) objArr[14]) : "");
                array.put(followup);
            }
        }
@ -373,7 +375,7 @@ public class FollowUpService extends BaseService {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
            if (signFamily == null) {
                signFamily = signFamilyDao.findBySanshiPatient(patientCode);
                if(signFamily==null){
                if (signFamily == null) {
                    throw new Exception("can not find patient's family sign info");
                }
            }
@ -438,12 +440,12 @@ public class FollowUpService extends BaseService {
    /**
     * 开始随访记录
     */
    public void startFollowup(String id, String date, String followupType, String followupClass, String followupManagerStatus,String plandate,String prescriptioncode) throws Exception {
    public void startFollowup(String id, String date, String followupType, String followupClass, String followupManagerStatus, String plandate, String prescriptioncode) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setFollowupDate(DateUtil.strToDate(date));
            //计划下次随访时间--huangwenjie.2017.10.19
            if(StringUtils.isNoneBlank(plandate)){
            if (StringUtils.isNoneBlank(plandate)) {
                followup.setFollowupNextDate(DateUtil.strToDate(plandate));
                Followup nextFollowup = new Followup();
                nextFollowup.setDataFrom(followup.getDataFrom());
@ -470,7 +472,7 @@ public class FollowUpService extends BaseService {
                nextFollowup.setIdcard(followup.getIdcard());
                nextFollowup.setSignType(followup.getSignType());
                followupDao.save(nextFollowup);
                
            }
            followup.setFollowupType(followupType);
            followup.setFollowupClass(followupClass);
@ -487,7 +489,7 @@ public class FollowUpService extends BaseService {
    /**
     * 新增临时随访记录(返回ID)
     */
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus,String plandate,String prescriptioncode) throws Exception {
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus, String plandate, String prescriptioncode) throws Exception {
        String re = "";
        //获取医生信息
@ -504,8 +506,8 @@ public class FollowUpService extends BaseService {
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
        if (signFamily == null) {
            signFamily = signFamilyDao.findBySanshiPatient(patientCode);
            if(signFamily==null)
               throw new Exception("can not find patient's family sign info");
            if (signFamily == null)
                throw new Exception("can not find patient's family sign info");
        }
        Followup followup = new Followup();
@ -530,14 +532,14 @@ public class FollowUpService extends BaseService {
        followup.setSignType(2);
        //保存质询code
        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
        
        //如果有填入续方CODE,则添加续方关联--huangwenjie.2017.11.02
        if(StringUtils.isNotBlank(prescriptioncode)){
        if (StringUtils.isNotBlank(prescriptioncode)) {
            followup.setPrescriptionCode(prescriptioncode);
        }
        //计划下次随访时间--ysj.2017.10.26
        if(StringUtils.isNoneBlank(plandate)){
        if (StringUtils.isNoneBlank(plandate)) {
            followup.setFollowupNextDate(DateUtil.strToDate(plandate));
            Followup nextFollowup = new Followup();
            nextFollowup.setDataFrom(followup.getDataFrom());
@ -593,22 +595,22 @@ public class FollowUpService extends BaseService {
        if (followup != null) {
            followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
            followup = followupDao.save(followup);
    
            //上传随访计划映射表记录
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(String.valueOf(followup.getId())));
            
            if(followupMapping == null){
            if (followupMapping == null) {
                followupMapping = new FollowupMapping();
            }
    
            followupMapping.setFollowupId(Integer.parseInt(String.valueOf(followup.getId())));
            followupMapping.setCode(UUID.randomUUID().toString());
            followupMapping.setCreateTime(DateUtil.getNowTimestamp());
            followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
            followupMapping.setNeedUpload(1);
            
            followUpMappingDao.save(followupMapping);
           
//            new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
@ -697,13 +699,13 @@ public class FollowUpService extends BaseService {
            followupContentDao.save(newList);
        }
    
        Followup followup = followupDao.findOne(Long.valueOf(id));
    
        //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
        if("1".equals(followup.getStatus())){
        if ("1".equals(followup.getStatus())) {
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
            if(followupMapping == null){
            if (followupMapping == null) {
                followupMapping = new FollowupMapping();
                followupMapping.setCode(UUID.randomUUID().toString());
                followupMapping.setFollowupId(Integer.parseInt(id));
@ -861,7 +863,10 @@ public class FollowUpService extends BaseService {
                    // 推送消息给医生
                    pushMsgTask.put(doctor, "4", title, content, "");
                    //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    List<Followup> followups = followupDao.getByDoctor(doctor, format.parse(start), format.parse(end));
                    Doctor doctor1 = doctorDao.findByCode(doctor);
                    String doctorOpenID = doctor1.getOpenid();
                    if (StringUtils.isNotEmpty(doctorOpenID)) {
@ -872,8 +877,8 @@ public class FollowUpService extends BaseService {
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", "您今日有1个随访计划待处理"));
                        params.add(new BasicNameValuePair("remark", ""));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String newDate = format.format(new Date());
                        SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String newDate = formatDate.format(new Date());
                        String keywords = "patientName" + newDate + "," + "请进入手机APP查看";
                        params.add(new BasicNameValuePair("keywords", keywords));
@ -889,15 +894,16 @@ public class FollowUpService extends BaseService {
            e.printStackTrace();
        }
    }
    
    /**
     *ES 保存随访记录详情
     *@author huangwenjie
     *@date 2017/11/1 14:57
     * ES 保存随访记录详情
     *
     * @author huangwenjie
     * @date 2017/11/1 14:57
     */
    @Transactional
    public void esSaveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -906,33 +912,33 @@ public class FollowUpService extends BaseService {
                        .must(QueryBuilders.matchQuery("followup_id", id))
                        .must(QueryBuilders.matchQuery("followup_project", followupProject))
        );
    
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
        
        //删除原有记录
        this.esDeleteFollowUpContent(dataList);
        
        //保存新的随访详情信息
        List<FollowupContentESDO> newdatalist = new ArrayList<>();
        FollowupContentESDO followupContentESDO = new FollowupContentESDO();
    
        followupContentESDO = JSON.parseObject(followupProjectData,FollowupContentESDO.class);
    
        followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
        followupContentESDO.setFollowup_id(id);
        followupContentESDO.setFollowup_project(followupProject);
        followupContentESDO.setCreate_time(new Date());
        newdatalist.add(followupContentESDO);
        elastricSearchSave.save(newdatalist,esIndex,esType);
        
        
        elastricSearchSave.save(newdatalist, esIndex, esType);
        //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if("1".equals(followup.getStatus())){
        if ("1".equals(followup.getStatus())) {
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
            if(followupMapping == null){
            if (followupMapping == null) {
                followupMapping = new FollowupMapping();
                followupMapping.setCode(UUID.randomUUID().toString());
                followupMapping.setFollowupId(Integer.parseInt(id));
@ -943,13 +949,13 @@ public class FollowUpService extends BaseService {
            followUpMappingDao.save(followupMapping);
        }
    }
    
    /**
     * ES获取面访项目数据
     */
    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
    
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -958,20 +964,21 @@ public class FollowUpService extends BaseService {
                        .must(QueryBuilders.matchQuery("followup_id", id))
                        .must(QueryBuilders.matchQuery("followup_project", followupProject))
        );
    
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        FollowupContentESDO followupContentESDO  = result.getSourceAsObject(FollowupContentESDO.class);
        FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
        return followupContentESDO;
    }
    
    /**
     *ES 删除随访详情信息
     *@author huangwenjie
     *@date 2017/11/1 15:17
     * ES 删除随访详情信息
     *
     * @author huangwenjie
     * @date 2017/11/1 15:17
     */
    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception{
    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception {
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            //根据id批量删除
@ -981,25 +988,26 @@ public class FollowUpService extends BaseService {
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
    
            logger.info("delete data count:" + datalist.size());
            logger.info("delete flag:" + br.isSucceeded());
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    /**
     * ES获取面访项目数据列表
     *@author huangwenjie
     *@date 2017/11/1 19:41
     *
     * @author huangwenjie
     * @date 2017/11/1 19:41
     */
    public List<String>  esfindProjectByFollowupId(String id) throws Exception {
    public List<String> esfindProjectByFollowupId(String id) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        
        List<String> resultList = new ArrayList<>();
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -1007,33 +1015,34 @@ public class FollowUpService extends BaseService {
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
        );
        
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
    
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        
        followupContentESDOList  = result.getSourceAsObjectList(FollowupContentESDO.class);
        if(!followupContentESDOList.isEmpty()){
            for (FollowupContentESDO followupContentESDO: followupContentESDOList) {
        followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
        if (!followupContentESDOList.isEmpty()) {
            for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
                resultList.add(followupContentESDO.getFollowup_project());
            }
        }
        
        return resultList;
    }
    
    /**
     * ES获取面访项目数据详情
     *@author huangwenjie
     *@date 2017/11/1 19:41
     *
     * @author huangwenjie
     * @date 2017/11/1 19:41
     */
    public List<FollowupContentESDO>  esfindFollowUpContestsByFollowupId(String id) throws Exception {
    public List<FollowupContentESDO> esfindFollowUpContestsByFollowupId(String id) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        
        List<String> resultList = new ArrayList<>();
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -1041,29 +1050,30 @@ public class FollowUpService extends BaseService {
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
        );
        
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        
        return followupContentESDOList;
    }
    
    /**
     * 根据续方CODE获取随访记录信息
     * @param prescriptionCode
     * @return
     */
    public String getFollowupByPrescriptionCode(String prescriptionCode) {
        Followup followup = followupDao.getFollowupByPrescriptionCode(prescriptionCode);
    
        String jsonString = JSON.toJSONString(followup);
        
        return jsonString;
    }
    
    /**
     * 获取随访详情记录分类记录数
     * @param followupid
@ -1071,7 +1081,7 @@ public class FollowUpService extends BaseService {
     * @return
     */
    public int getfollowupcontent(String followupid, String type) throws Exception {
    
        int count = 0;
        String[] typelist = null;
        if(type.contains(",")){
@ -1079,15 +1089,15 @@ public class FollowUpService extends BaseService {
        }else{
            typelist = new String[]{type};
        }
    
        for (String typekey: typelist) {
            if(!"drug".equals(type)){
    
                FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid,typekey);
                if(followupContentESDO != null){
                    count ++;
                }
            
            }else{
                //获取用药记录
                List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(followupid));
@ -1096,7 +1106,7 @@ public class FollowUpService extends BaseService {
                }
            }
        }
        
        return count;
    }

+ 55 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/FeedbackTemplateController.java

@ -0,0 +1,55 @@
package com.yihu.wlyy.web.doctor.feedback;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.service.app.feedback.FeedbackService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Reece on 2017/5/6.
 */
@Controller
@RestController
@RequestMapping(value = "/doctor/feedback")
@Api(description = "医生端意见反馈")
public class FeedbackTemplateController extends BaseController {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private CommonUtil CommonUtil;
    /**
     * 医生端发送系统消息
     * @param receiver 接受者
     * @param title 标题
     * @param content 内容
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ApiOperation(value = "医生端发送系统消息")
    @ResponseBody
    @ObserverRequired
    public String saveFeedback(
            @RequestParam String receiver,
            @RequestParam String title,
            @RequestParam String content) {
        try {
            pushMsgTask.put(receiver, "8", title, content, "");
            return write(200, "发送成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "发送失败!");
        }
    }
}

+ 61 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/FeedbackTemplateController.java

@ -0,0 +1,61 @@
package com.yihu.wlyy.web.patient.feedback;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.feedback.FeedbackService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Reece on 2017/5/6.
 */
@Controller
@RestController
@RequestMapping(value = "/patient/feedback")
@Api(description = "居民端意见反馈")
public class FeedbackTemplateController extends BaseController {
    @Autowired
    private WeiXinTempMsgSendUtils tempMsgSendUtils;
    @Value("${wechat.message.template_consult_notice}")
    private String templateId;
    /**
     * 居民端发送模板消息
     * @param toUser  接受者openID
     * @param url      跳转路径
     * @param first
     * @param remark
     * @param keywords
     * @return
     */
    @RequestMapping(value = "/sendTemplate", method = RequestMethod.POST)
    @ApiOperation(value = "居民端端发送模板消息")
    @ResponseBody
    @ObserverRequired
    public String saveFeedback(
            @RequestParam(required = true) String toUser,
            @RequestParam(required = false) String url,
            @RequestParam(required = true) String first,
            @RequestParam(required = true) String remark,
            @RequestParam(required = true) String ... keywords) {
        try {
            JSONObject data = tempMsgSendUtils.packageTemplate(first,remark,keywords);
            tempMsgSendUtils.sendTemplateMessage(templateId,toUser,url,data);
            return write(200, "发送成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "发送失败!");
        }
    }
}