Przeglądaj źródła

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

yeshijie 7 lat temu
rodzic
commit
ec01fd6759

+ 7 - 8
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java

@ -25,6 +25,7 @@ import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.jms.TextMessage;
import java.util.Date;
import java.util.Date;
import java.util.List;
import java.util.List;
import java.util.Map;
/**
/**
 * Created by chenweida on 2017/9/9.
 * Created by chenweida on 2017/9/9.
@ -117,26 +118,24 @@ public class HealthArtListener implements MessageListener {
        }
        }
        try {
        try {
            //卫纪委发送不推IM
            //卫纪委发送不推IM
            String technicalName = "";
            if (1 == one.getSendType()) {
            if (1 == one.getSendType()) {
                consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), one.getPatientCode(), "{\"title\":\"" + one.getArticleTitle() + "\",\"type\":0,\"id\":\"" + one.getArticleId() + "\",\"img\":\"" + one.getArticleCover() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), one.getPatientCode(), "{\"title\":\"" + one.getArticleTitle() + "\",\"type\":0,\"id\":\"" + one.getArticleId() + "\",\"img\":\"" + one.getArticleCover() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                if (StringUtils.isNotBlank(one.getLeaveWords())) {
                if (StringUtils.isNotBlank(one.getLeaveWords())) {
                    //发送备注
                    //发送备注
                    consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), one.getPatientCode(), one.getLeaveWords(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
                    consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), one.getPatientCode(), one.getLeaveWords(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
                }
                }
            }
            // 推送消息给微信端
            String technicalName = "";
            if(2 == one.getSendType()){
                String sql = "select * from wlyy_sign_family f where (f.doctor = '"+one.getDoctorCode()+"' or f.doctor_health = '"+one.getDoctorCode()+"') and f.patient='"+one.getPatientCode()+"' and f.`status`>0";
                SignFamily signFamily = jdbcTemplate.queryForObject(sql, SignFamily.class);
                if(signFamily!=null){
                    if(one.getDoctorCode().equals(signFamily.getDoctor())){
                String sql = " select * from wlyy_sign_family f where (f.doctor = '"+one.getDoctorCode()+"' or f.doctor_health = '"+one.getDoctorCode()+"') and f.patient='"+one.getPatientCode()+"' and f.`status`>0 ";
                List<Map<String, Object>> resultMap = jdbcTemplate.queryForList(sql);
                if(resultMap.size()>0){
                    if(one.getDoctorCode().equals(resultMap.get(0).get("doctor"))){
                        technicalName = "医生";
                        technicalName = "医生";
                    }else{
                    }else{
                        technicalName = "健管师";
                        technicalName = "健管师";
                    }
                    }
                }
                }
            }
            }
            // 推送消息给微信端
            org.json.JSONObject json = new org.json.JSONObject();
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", one.getPatientName() + ",您好! " + one.getSendName() + technicalName +"给您发来了一篇患教文章");
            json.put("first", one.getPatientName() + ",您好! " + one.getSendName() + technicalName +"给您发来了一篇患教文章");
            json.put("toUser", one.getPatientCode());
            json.put("toUser", one.getPatientCode());

+ 181 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

@ -455,16 +455,18 @@ public class JMJkEduArticleService extends BaseService {
        }
        }
        //保存到ES中
        elastricSearchSave.save(healthEduArticleESList, esIndex, esType);
        HealthEduArticleES e = new HealthEduArticleES();
        BeanUtils.copyProperties(healthEduArticleESList.get(0),e);
        e.setUserType(2);
        e.setPatientCode(null);
        e.setPatientName(null);
        elastricSearchSave.save(e, esIndex, esType);
        thirdJkEduArticleService.saveBehavior(articleId,doctor.getCode(),7,patientSet.size());
        if(healthEduArticleESList.size()>0){
            //保存到ES中
            elastricSearchSave.save(healthEduArticleESList, esIndex, esType);
            HealthEduArticleES e = new HealthEduArticleES();
            BeanUtils.copyProperties(healthEduArticleESList.get(0),e);
            e.setUserType(2);
            e.setPatientCode(null);
            e.setPatientName(null);
            elastricSearchSave.save(e, esIndex, esType);
            thirdJkEduArticleService.saveBehavior(articleId,doctor.getCode(),7,patientSet.size());
        }
        return healthEduArticleESList;
        return healthEduArticleESList;
    }
    }
    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) throws Exception {
    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) throws Exception {
@ -689,10 +691,10 @@ public class JMJkEduArticleService extends BaseService {
    }
    }
    private void getPatientByGroup(String userCode,String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
    private void getPatientByGroup(String userCode,String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
        org.json.JSONArray result = signPatientLabelInfoService.getPatientByLabel(userCode, labelCode, labelType, teamCode, page, pagesize, false, "",true,null,null,null);
        org.json.JSONArray result = getPatientByLabel(userCode, labelCode, labelType, teamCode, page, pagesize, false, "",true,null,null,null);
        for (Object o : result) {
        for (Object o : result) {
            org.json.JSONObject json = (org.json.JSONObject) o;
            org.json.JSONObject json = (org.json.JSONObject) o;
            String patient = (String) json.get("code");
            String patient = (String) json.get("patient");
            patientSet.add(patient);
            patientSet.add(patient);
        }
        }
        if (result.length() == 100) {
        if (result.length() == 100) {
@ -700,6 +702,173 @@ public class JMJkEduArticleService extends BaseService {
        }
        }
    }
    }
    public org.json.JSONArray getPatientByLabel(String doctor, String labelCode, String labelType,
                                                Long teamCode, int page, int pagesize, boolean isSlowDisease,
                                                String diseaseCondition, boolean isFollowWeChat, String trackFlag, String sDate, String eDate) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
        Map<String, org.json.JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
        if (labelType.equals("5")) {
            Calendar today = Calendar.getInstance();
            Calendar startDate = Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            sql = "select DISTINCT * " +
                    " from " +
                    "     wlyy_sign_family t1" +
                    "  LEFT JOIN wlyy_patient p on p.code = t1.patient  "+
                    "  LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = 3 and t2.status=1 "+
                    " where (t1.doctor = ? or t1.doctor_health = ?) and t1.status > 0 and t1.admin_team_code = ? ";
            if (labelCode.equals("1")) {
                int week = today.get(Calendar.DAY_OF_WEEK) - 2;
                if (week == -1) {
                    week = 6;
                }
                startDate.add(Calendar.DATE, -week);
                sql += " and t1.apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(today.getTime()) + " 23:59:59'");
            } else if (labelCode.equals("2")) {
                startDate.set(Calendar.DATE, 1);
                sql += " and t1.apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(today.getTime()) + " 23:59:59'");
            } else if (labelCode.equals("3")) {
                startDate.add(Calendar.DATE, 30);
                sql += " and t1.end between '" + (df.format(today.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(startDate.getTime()) + " 23:59:59'");
            } else {
                throw new Exception("label is not exist");
            }
            if(isFollowWeChat){
                sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
            }
            sql += " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
            args = new Object[]{doctor, doctor, teamCode};
        }else if("1".equals(labelType)){
            sql ="  SELECT " +
                    "  DISTINCT t1.* " +
                    "  FROM " +
                    "   wlyy_sign_family t1 " +
                    "   LEFT JOIN wlyy_patient p on p. CODE = t1.patient " +
                    "   LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = 3 and t2.status=1 "+
                    "   RIGHT JOIN wlyy_sign_family_server s on s.sign_code = t1.code and s.server_type = '"+labelCode+"' "+
                    "  WHERE ( " +
                    "   t1.doctor = ? " +
                    "   OR t1.doctor_health = ? " +
                    "  ) " +
                    "  AND t1. STATUS > 0  AND t1.admin_team_code = ?";
            if(org.apache.commons.lang3.StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.disease_condition ="+diseaseCondition;
            }
            if(isFollowWeChat){
                sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
            }
            sql = sql +" order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
            args = new Object[]{doctor, doctor, teamCode};
        }else if("3".equals(labelType) && isSlowDisease){
            //慢病管理
            sql = "SELECT " +
                    "  DISTINCT t1.* " +
                    "  FROM  wlyy_sign_family t1 " +
                    "  LEFT JOIN wlyy_patient p on p.code = t1.patient  "+
                    "  RIGHT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient ";
            if(org.apache.commons.lang3.StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                sql = sql +" JOIN wlyy_track_patient tp ON tp.patient_code = p.code";
            }
            sql = sql + " WHERE t2.label = ?";
            if(org.apache.commons.lang3.StringUtils.isNotBlank(diseaseCondition)) {
                sql = sql + " AND p.disease_condition = ? ";
            }
            sql = sql + "    AND t2.label_type = ? " +
                    "    AND t2.status = 1 " +
                    "    AND t1.patient = t2.patient " +
                    "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                    "    AND t1.status > 0 " +
                    "    AND t1.admin_team_code = ? ";
            if(isFollowWeChat){
                sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
            }
            if(org.apache.commons.lang3.StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                sql = sql + " AND tp.del='1'  AND tp.doctor_code ='"+doctor+"' AND tp.team_code ="+teamCode;
                if(org.apache.commons.lang3.StringUtils.isNotBlank(sDate)&& org.apache.commons.lang3.StringUtils.isNotBlank(eDate)){
                    sql += " AND tp.create_time >='"+sDate+" 00:00:00' AND tp.create_time <='"+eDate+" 23:59:59' ";
                }
            }
            sql = sql + " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
            if(org.apache.commons.lang3.StringUtils.isNotBlank(diseaseCondition)) {
                args = new Object[]{labelCode, diseaseCondition, labelType, doctor, doctor, teamCode};
            }else{
                args = new Object[]{labelCode, labelType, doctor, doctor,  teamCode};
            }
        } else {
            if (labelCode.equals("0")) {
                sql = "SELECT " +
                        "    t1.* " +
                        " FROM " +
                        "    wlyy_sign_family t1 " +
                        " left join " +
                        "    (select l.patient,l.label,l.label_type,l.label_name from wlyy_sign_family f left join wlyy_sign_patient_label_info l on f.patient = l.patient where (f.doctor = '" + doctor + "' or f.doctor_health = '" + doctor + "') and f.status > 0 and l.label_type = ? and l.status = 1) t2 " +
                        " on t1.patient = t2.patient " +
                        " left join wlyy_patient p on p.code = t1.patient "+
                        " WHERE " +
                        "    t2.patient is null " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?) " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                if(isFollowWeChat){
                    sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
                }
                sql  +=  "order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk)";
                args = new Object[]{labelType, doctor, doctor, teamCode};
            }else {
                sql = "SELECT " +
                        "    t1.* " +
                        " FROM " +
                        "    wlyy_sign_family t1 " +
                        "    left join wlyy_sign_patient_label_info t2 on t1.patient = t2.patient " +
                        "    left join wlyy_patient p on p.`code` = t1.patient "+
                        " WHERE " +
                        "    t2.label = ? " +
                        "    AND t2.label_type = ? " +
                        "    AND t2.status = 1 " +
                        "    AND t1.patient = t2.patient " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? "+
                        "    AND p.`status` =1 ";
                if(isFollowWeChat){
                    sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
                }
                sql +=  " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,p.openid DESC ,convert(t1.name using gbk)";
                args = new Object[]{labelCode, labelType, doctor, doctor, teamCode};
            }
        }
        sql += " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        return new org.json.JSONArray(signList);
    }
    public JSONObject pushArticleConfirm(String userCode,String[] groups,String group,String labelType,long teamCode,String[] patients,String articleId) throws Exception{
    public JSONObject pushArticleConfirm(String userCode,String[] groups,String group,String labelType,long teamCode,String[] patients,String articleId) throws Exception{
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"","");
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"","");
        Set<String> patientSet = new HashSet<>();
        Set<String> patientSet = new HashSet<>();

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -1,11 +1,14 @@
package com.yihu.wlyy.web.data;
package com.yihu.wlyy.web.data;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.manage.User;
import com.yihu.wlyy.entity.manage.User;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.manage.UserDao;
import com.yihu.wlyy.repository.manage.UserDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.MD5;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -29,6 +32,10 @@ public class DataHandingService {
    private DoctorDao doctorDao;
    private DoctorDao doctorDao;
    @Autowired
    @Autowired
    private UserDao userDao;
    private UserDao userDao;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private ElastricSearchSave elastricSearchSave;
    @Transactional
    @Transactional
    public String producePatientAndDoctorPassword() {
    public String producePatientAndDoctorPassword() {
@ -105,4 +112,10 @@ public class DataHandingService {
        userTemp.setType(2); //医生
        userTemp.setType(2); //医生
        userDao.save(userTemp);
        userDao.save(userTemp);
    }
    }
    public Boolean esToEs(){
        String sql = " SELECT * FROM health_edu_article_patient_test ";
        List<HealthEduArticleES> esList = elasticsearchUtil.excute(sql, HealthEduArticleES.class, "health_edu_article_patient_test", "health_edu_article_patient_test");
        return  elastricSearchSave.save(esList, "health_edu_article_patient", "health_edu_article_patient");
    }
}
}

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -234,4 +234,16 @@ public class DataHandlingController extends BaseController {
        return new SimpleResult<>(new TestSwagger());
        return new SimpleResult<>(new TestSwagger());
    }
    }
    @RequestMapping(value = "/esToEs", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("正式环境test数据清洗到prod中")
    public String esToEs(){
        Boolean flag = dataHandingService.esToEs();
        if (flag) {
            return write(200, "EStest数据清洗到ESprod成功!");
        } else {
            return write(0, "EStest数据清洗到ESprod失败!");
        }
    }
}
}