wujunjie пре 7 година
родитељ
комит
423619cfe9
46 измењених фајлова са 1822 додато и 592 уклоњено
  1. 2 2
      common/common-entity/src/main/java/com/yihu/device/entity/DevicePatientHealthIndex.java
  2. 6 6
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java
  3. 9 9
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java
  4. 26 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  5. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java
  6. 255 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/DoctorFeldsherTemplateJob.java
  7. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayQueryJob.java
  8. 68 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/consult/FinishConsultJob.java
  9. 27 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientSchemeListDao.java
  10. 17 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/ylz/PayConfiguraDao.java
  11. 0 129
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/Configure.java
  12. 4 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  13. 122 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java
  14. 42 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/HttpUtil.java
  15. 40 3
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  16. 6 0
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  17. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  18. 23 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientAimSportsDao.java
  19. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java
  20. 56 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  21. 35 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  22. 129 47
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  23. 342 198
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  24. 61 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  25. 27 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  26. 92 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/fzzb/HealthEducationArticleService.java
  27. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  28. 144 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java
  29. 0 129
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java
  30. 22 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java
  31. 1 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  32. 33 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java
  33. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java
  34. 34 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/im/imController.java
  35. 28 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  36. 47 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthRecordController.java
  37. 62 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  38. 12 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  39. 15 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  40. 6 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java
  41. 3 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java
  42. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java
  43. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  44. 4 6
      patient-co/patient-co-wlyy/src/main/resources/application-local.yml
  45. 12 4
      patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml
  46. 1 1
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

+ 2 - 2
common/common-entity/src/main/java/com/yihu/device/entity/DevicePatientHealthIndex.java

@ -25,9 +25,9 @@ public class DevicePatientHealthIndex extends IdEntity {
	private String value1;
	// 舒张压/早餐后空腹/身高
	private String value2;
	// 午餐空腹/身高
	// 午餐空腹/BMI
	private String value3;
	// 午餐后
	// 午餐后/偏胖-1/正常0/偏瘦1
	private String value4;
	// 晚餐空腹
	private String value5;

+ 6 - 6
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java

@ -13,12 +13,12 @@ import java.sql.Timestamp;
@Entity
@Table(name = "wlyy_patient_aim_sports")
public class PatientAimSports extends IdEntity {
    private String code;
    private String patientcode;
    private Integer dailyStepCount;
    private String bmiMax;
    private String bmiMin;
    private Timestamp createTime;
    private String code;                //业务逻辑CODE,如果CODE为default,则该条记录为系统预置数据
    private String patientcode;         //患者CODE
    private Integer dailyStepCount;     //运动步数
    private String bmiMax;              //bmi标准上限
    private String bmiMin;              //bmi标准下线
    private Timestamp createTime;       //创建时间
    @Basic

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

@ -46,9 +46,9 @@ public class HealthArtListener implements MessageListener {
    public void onMessage(Message message) {
        try {
            TextMessage textMessage = (TextMessage) message;
            JSONObject jo = JSONObject.fromObject(textMessage.getText());
            logger.info(jo.toString());
            HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class);
//            logger.info(jo.toString());
            sendWxTemplateAndIM(healthEduArticlePatient);
            //返回服务器表示消息消费成功
            message.acknowledge();
        } catch (JMSException e) {
@ -57,15 +57,15 @@ public class HealthArtListener implements MessageListener {
    }
    //发送到IM和
    private void sendWxTemplateAndIM(List<HealthEduArticlePatient> healthEduArticlePatients, Integer sendType) {
    //发送到IM和微信消息模板
    private void sendWxTemplateAndIM(HealthEduArticlePatient one) {
        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
        healthEduArticlePatients.stream().forEach(one -> {
//        healthEduArticlePatients.stream().forEach(one -> {
            Patient patient = patientService.findByCode(one.getPatient());
            try {
                //卫纪委发送不推IM
                if (1 == sendType) {
                if (1 == one.getSendType()) {
                    consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                    if (StringUtils.isNotBlank(one.getAttachedMessage())) {
                        //发送备注
@ -76,7 +76,7 @@ public class HealthArtListener implements MessageListener {
                org.json.JSONObject json = new org.json.JSONObject();
                json.put("first", patient.getName() + ",您好! " + one.getSendName() + "医生给您发来了一篇患教文章");
                json.put("toUser", patient.getCode());
                json.put("article", one.getId() + "");
                json.put("article", one.getArticleId() + "");
                json.put("title", one.getAttachedTitle());
                json.put("doctorName", one.getSendName());
                json.put("represented", patient.getCode());//被代理人
@ -111,6 +111,6 @@ public class HealthArtListener implements MessageListener {
            } catch (Exception e) {
                logger.error("patient:" + patient.getCode() + "," + e.getMessage());
            }
        });
//        });
    }
}

+ 26 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -106,6 +106,32 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                logger.info("prescription_pay_query_job reorder job job exist");
            }
            //居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
            if (!quartzHelper.isExistJob("finish_consult_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("finish_consult_job");
                quartzHelper.addJob(PrescriptionExecuteSickSettleJob.class, trigger, "finish_consult_job", new HashMap<String, Object>());
                logger.info("finish_consult_job success");
            } else {
                logger.info("finish_consult_job exist");
            }
            //提醒有监测方案的居民上传数据,每29分钟执行一次
            if (!quartzHelper.isExistJob("doctor_feldsher_template_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("doctor_feldsher_template_job");
                quartzHelper.addJob(DoctorFeldsherTemplateJob.class, trigger, "doctor_feldsher_template_job", new HashMap<String, Object>());
                logger.info("doctor_feldsher_template_job reorder job job success");
            } else {
                logger.info("doctor_feldsher_template_job reorder job job exist");
            }
            //居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
            if (!quartzHelper.isExistJob("finish_consult_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("finish_consult_job");
                quartzHelper.addJob(PrescriptionExecuteSickSettleJob.class, trigger, "finish_consult_job", new HashMap<String, Object>());
                logger.info("finish_consult_job success");
            } else {
                logger.info("finish_consult_job exist");
            }
            // 启动redis 消息队列线程
            logger.info("redis message start");

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -29,7 +29,7 @@ public interface DevicePatientHealthIndexDao
    Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date);
    @Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate between ?3 and ?4 and a.del = '1' group by recordDate order by recordDate asc")
    Iterable<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
    List<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
    @Query("select a.value1 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value1 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue1ByPatient(String user, int type, Date recordDate, Pageable pageRequest);

+ 255 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/DoctorFeldsherTemplateJob.java

@ -0,0 +1,255 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.patient.PatientSchemeListDao;
import com.yihu.wlyy.service.template.DoctorFeldsherTemplateService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
 * 处理有监测方案的居民在一定时间范围内收到模板消息提醒
 * Created by Reece on 2017/8/29/029.
 */
@DisallowConcurrentExecution//解决执行频率和间隔时间的问题。到了执行时间点前一任务还在执行中,不会执行下一次任务,直至该次任务完成
public class DoctorFeldsherTemplateJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(DoctorFeldsherTemplateJob.class);
    @Autowired
    private PatientSchemeListDao schemeListDao;
    @Autowired
    private DoctorFeldsherTemplateService feldsherTemplateService;
    @Autowired
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private DevicePatientHealthIndexDao patientHealthIndexDao;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("DoctorFeldsherTemplateJob start ..........");
        try {
            //获取居民在监测方案的监测时间前30分钟未上传监测数据
            SimpleDateFormat formatHour = new SimpleDateFormat("HH:mm:ss");
            List<DoctorSchemeBloodSugger> patientCodeList = schemeListDao.findSuggerPatient();
            for (DoctorSchemeBloodSugger patientCodeLis : patientCodeList) {
                String schemecode = patientCodeLis.getCode();
                short beforeBreakfast = patientCodeLis.getBeforeBreakfast();
                Time beforeBreakfastTime = patientCodeLis.getBeforeBreakfastTime();
                short afterBreakfast = patientCodeLis.getAfterBreakfast();
                Time afterBreakfastTime = patientCodeLis.getAfterBreakfastTime();
                short beforeLunch = patientCodeLis.getBeforeLunch();
                Time beforeLunchTime = patientCodeLis.getBeforeLunchTime();
                short afterLunch = patientCodeLis.getAfterLunch();
                Time afterLunchTime = patientCodeLis.getAfterLunchTime();
                short beforeDinner = patientCodeLis.getBeforeDinner();
                Time beforeDinnerTime = patientCodeLis.getBeforeDinnerTime();
                short afterDinner = patientCodeLis.getAfterDinner();
                Time afterDinnerTime = patientCodeLis.getAfterDinnerTime();
                short beforeSleep = patientCodeLis.getBeforeSleep();
                Time beforeSleepTime = patientCodeLis.getBeforeSleepTime();
                String toDay = formatHour.format(new Date());
                long to = formatHour.parse(toDay).getTime();
                if (beforeBreakfast == 1) {
                    Time tempTime = Time.valueOf("00:00:00");
                    long tempTo = tempTime.getTime();
                    long from = beforeBreakfastTime.getTime();
                    int minutes = (int) ((from - tempTo) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,tempTime,beforeBreakfastTime,"早餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (afterBreakfast == 1) {
                    long from = afterBreakfastTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeBreakfastTime,afterBreakfastTime,"早餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (beforeLunch == 1) {
                    long from = beforeLunchTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterBreakfastTime,beforeLunchTime,"午餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (afterLunch == 1) {
                    long from = afterLunchTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeLunchTime,afterLunchTime,"午餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (beforeDinner == 1) {
                    long from = beforeDinnerTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterLunchTime,beforeDinnerTime,"晚餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (afterDinner == 1) {
                    long from = afterDinnerTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeDinnerTime,afterDinnerTime,"晚餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (beforeSleep == 1) {
                    long from = beforeSleepTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterDinnerTime,beforeSleepTime,"睡前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
            }
            List<DoctorSchemeBloodPressure> patientCodes = schemeListDao.findPressurePatient();
            for (DoctorSchemeBloodPressure patientCodeLis : patientCodes) {
                String schemecode = patientCodeLis.getCode();
                short earlyMorning = patientCodeLis.getEarlyMorning();
                Time earlyMorningTime = patientCodeLis.getEarlyMorningTime();
                short morning = patientCodeLis.getMorning();
                Time morningTime = patientCodeLis.getMorningTime();
                short noon = patientCodeLis.getNoon();
                Time noonTime = patientCodeLis.getNoonTime();
                short afterNoon = patientCodeLis.getAfterNoon();
                Time afterNoonTime = patientCodeLis.getAfterNoonTime();
                short night = patientCodeLis.getNight();
                Time nightTime = patientCodeLis.getNightTime();
//                比较现在时间和监测时间《=30
                String toDay = formatHour.format(new Date());
                long to = formatHour.parse(toDay).getTime();
                if (earlyMorning == 1) {
                    Time tempTime = Time.valueOf("00:00:00");
                    long tempTo = tempTime.getTime();
                    long from = earlyMorningTime.getTime();
                    int minutes = (int) ((from - tempTo) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,tempTime,earlyMorningTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (morning == 1) {
                    long from = morningTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,earlyMorningTime,morningTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (noon == 1) {
                    long from = noonTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,morningTime,noonTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (afterNoon == 1) {
                    long from = afterNoonTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,noonTime,afterNoonTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (night == 1) {
                    long from = nightTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,afterNoonTime,nightTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
            }
            logger.info("DoctorFeldsherTemplateJob end ..........");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("DoctorFeldsherTemplateJob error ..........,message:" + e.getMessage());
        }
    }
    /**
     *
     * @param minutes 监测时间差值
     * @param type 监测类型 2为血压,1为血糖
     * @param schemecode 关联监测方案
     * @param beginTime 起始时间点
     * @param endTime 截止时间点
     * @param comment 血糖时间段名称
     * @throws Exception
     */
    private void sendPatientHealth(int minutes, int type, String schemecode, Time beginTime, Time endTime,String comment) throws Exception {
        SimpleDateFormat formatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat formatDay = new SimpleDateFormat("yyyy-MM-dd ");
        Date today = new Date();
        if (minutes <= 30 && minutes > 0) {
            PatientSchemeList patient = schemeListDao.findPatientBySchemecode(schemecode, (short) 1);
            String patientCode = patient.getPatientcode();
            String day = formatDay.format(today);
            Date begin = formatTime.parse(day + beginTime);
            Date end = formatTime.parse(day + endTime);
            List<DevicePatientHealthIndex> healthIndices = patientHealthIndexDao.findByPatient(patientCode, type, begin, end);
            if (healthIndices==null || healthIndices.size()==0) {
                try {
                    //为居民发送监测代办事项提醒消息
                    feldsherTemplateService.sendChangeTemplate(type, patientCode, comment);
                } catch (Exception e) {
                    logger.info("DoctorFeldsherTemplateJob error ..........continue this JOB,CODE:" + patientCode + ",message:" + e.getMessage());
                }
            }
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayQueryJob.java

@ -48,7 +48,7 @@ public class PrescriptionPayQueryJob implements Job {
                    }
                }
            }
            logger.info("PrescriptionPayQueryJob start ..........");
            logger.info("PrescriptionPayQueryJob end ..........");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("PrescriptionPayQueryJob error ..........,message:" + e.getMessage());

+ 68 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/consult/FinishConsultJob.java

@ -0,0 +1,68 @@
package com.yihu.wlyy.job.consult;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.util.HttpUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
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.jdbc.core.JdbcTemplate;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.List;
import java.util.Map;
/**
 * 居民24小时未回复的咨询自动关闭
 * Created by yeshijie on 2017/9/10.
 */
public class FinishConsultJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(FinishConsultJob.class);
    @Value("${im.data_base_name}")
    private String imDb;
    @Value("${server.server_url}")
    private String server_url;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpUtil httpUtil;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try{
            logger.info("FinishConsultJob start.....");
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            StringBuffer sql = new StringBuffer();
            sql.append("SELECT s.id session_id, s.name session_name, s.create_date session_create_time, s.last_message_time, ")
            .append("t.id topic_id, t.name topic_name, t.create_time topic_create_time, t.start_message_id ")
            .append("FROM ").append(imDb).append(".sessions s,").append(imDb).append(".wlyy_consults t ")
            .append("WHERE s.id = t.session_id  AND t.end_message_id IS NULL AND s.last_content_type in(1,2,3,4) and s.last_sender_id IN ( ")
            .append("SELECT id FROM ").append(imDb).append(".doctors d where d.id<>t.patient) ")
            .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600 ")
            .append("ORDER BY t.create_time");
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString());
            list.stream().forEach(one->{
                String topicId = one.get("topic_id").toString();
                String topicName = one.get("topic_name").toString();
                JSONObject userAgent = new JSONObject();
                userAgent.put("uid","admin");
                userAgent.put("admin_token","0a5c5258-8863-4b07-a3f9-88c768528ab4");
                userAgent.put("token","");
                userAgent.put("imei","admin_imei");
                logger.info("Got topic to terminate, " + topicId + ": " + topicName + ", last active time: " + one.get("last_message_time"));
                String response = httpUtil.sendLoginGet(server_url+"/doctor/consult/finish_consult","consult="+topicId,userAgent.toString());
                logger.info("FinishConsultJob response....."+response);
            });
            logger.info("FinishConsultJob end.....");
        }catch (Exception e){
            logger.error("FinishConsultJob error....."+e.getMessage());
        }
    }
}

+ 27 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientSchemeListDao.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientSchemeListDao extends PagingAndSortingRepository<PatientSchemeList, Long>, JpaSpecificationExecutor<PatientSchemeList> {
    //联合wlyy_patient_scheme_list和wlyy_doctor_scheme_blood_pressure查询有血糖监测方案且在监测时间前十分钟未上传监测数据
    @Query(value = " select s from PatientSchemeList p,DoctorSchemeBloodSugger s where p.schemecode=s.code and p.type = 1 and s.alertTag = 1 ")
    List<DoctorSchemeBloodSugger> findSuggerPatient();
    //联合wlyy_patient_scheme_list和wlyy_doctor_scheme_blood_pressure查询有血压监测方案且在监测时间前十分钟未上传监测数据
    @Query(" select s from PatientSchemeList p,DoctorSchemeBloodPressure s where p.schemecode=s.code and p.type=0 and s.alertTag = 1 ")
    List<DoctorSchemeBloodPressure> findPressurePatient();
    //根据schemecode查询患者监测方案
    @Query(" select p from PatientSchemeList p where p.schemecode = ?1 and p.type = ?2 ")
    PatientSchemeList findPatientBySchemecode(String schemecode,short type);
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/ylz/PayConfiguraDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.ylz;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/9/9.
 */
public interface PayConfiguraDao extends PagingAndSortingRepository<PayConfigura, Long>, JpaSpecificationExecutor<PayConfigura> {
    //查询有效支付相关配置(只有一条有效记录)
    @Query("select t from PayConfigura t where t.del = 1 ")
    PayConfigura findWorkConfigura();
}

+ 0 - 129
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/Configure.java

@ -1,129 +0,0 @@
package com.yihu.wlyy.service.app.prescription;
import org.springframework.context.annotation.Configuration;
/**
 * User: hzp
 * Date: 20170518
 * 这里放置各种配置数据
 */
@Configuration
public class Configure {
	/******************************* 易联众统一支付平台 ***********************************************************/
//	private String onepayApi = "http://120.42.37.94:1301/onepay-web/";
//	private String onepayAppId = "1BGKM1UHM03P7B2CA8C000005626EB0E";
//	private String onepayAppSecret = "1BGKM1UHM03I7B2CA8C00000AB682E9A";
//			开发环境应用信息
//	private String onepayApi = "https://xmhealth.ylzpay.com:8080/";
	private String onepayApi = "http://xmhealth.ylzpay.com:8070/";
	private String onepayAppId = "1BLF5SEGN00087165F0A000027362BE5";
	private String onepayAppSecret = "1BLF5SCBO01V3E78A8C00000F3A0FFE7";
	private String bindCardType = "onepay.sicard.bind.info";
	private String chargeType = "onepay.trade.medical.charge";
	private String chargeQueryType = "onepay.trade.medical.charge.query";
	private String createSicardType = "onepay.sicard.createurl";
//	易联众异步回调
	private String receiveNotify = "wlyy.onepay.receiveNotify";
	private String returnUrl = "wlyy.onepay.returnUrl";
//  长处方系列
	private String recipeChargeType = "onepay.trade.long.recipe.charge";
	private String recipeReturnUrl = "wlyy.patient.prescription.pay.recipeReturnUrl";
	private String receiveRecipeNotify = "wlyy.third.pay.prescription.receiveRecipeNotify";
	public String getRecipeChargeType() {
		return recipeChargeType;
	}
	public void setRecipeChargeType(String recipeChargeType) {
		this.recipeChargeType = recipeChargeType;
	}
	public String getRecipeReturnUrl() {
		return recipeReturnUrl;
	}
	public void setRecipeReturnUrl(String recipeReturnUrl) {
		this.recipeReturnUrl = recipeReturnUrl;
	}
	public String getReceiveRecipeNotify() {
		return receiveRecipeNotify;
	}
	public void setReceiveRecipeNotify(String receiveRecipeNotify) {
		this.receiveRecipeNotify = receiveRecipeNotify;
	}
	public String getReturnUrl() {
		return returnUrl;
	}
	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}
	public String getReceiveNotify() {
		return receiveNotify;
	}
	public void setReceiveNotify(String receiveNotify) {
		this.receiveNotify = receiveNotify;
	}
	public String getOnepayApi() {
		return onepayApi;
	}
	public String getOnepayAppId() {
		return onepayAppId;
	}
	public String getOnepayAppSecret() {
		return onepayAppSecret;
	}
	public String getBindCardType() {
		return bindCardType;
	}
	public String getChargeType() {
		return chargeType;
	}
	public String getChargeQueryType() {
		return chargeQueryType;
	}
	public String getCreateSicardType() {
		return createSicardType;
	}
	/******************* 微信社保支付配置 ******************************************/
	//这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中)
	// 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证
	// 收到API的返回的时候也要用这个key来对返回的数据算下签名,跟API的Sign数据进行比较,如果值不一致,有可能数据被第三方给篡改
	private String key = "2935b54b53a957d9516c920a544f2537";
	//微信分配的公众号ID(开通公众号之后可以获取到)
	private String appID = "wxd03f859efdf0873d";
	public String getKey(){
		return key;
	}
	public String getAppid(){
		return appID;
	}
	//获取token地址
	public String TOKEN_API = "https://api.weixin.qq.com/payinsurance/gettoken";
	//挂号/诊间支付统一下单 API 接口
	public String ORDER_API = "https://api.weixin.qq.com/payinsurance/unifiedorder?access_token ACCESS_TOKEN";
}

+ 4 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.entity.zydict.ZyPushLog;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
@ -21,6 +22,7 @@ import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.BaseService;
@ -69,7 +71,7 @@ public class PatientPrescriptionPayService extends BaseService {
    //    引入实例
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private PrescriptionPayDao payDao;
    @Autowired
@ -81,6 +83,7 @@ public class PatientPrescriptionPayService extends BaseService {
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        int flag = 0;
        Boolean isSuccess = true;
        String msgBody = "";

+ 122 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -0,0 +1,122 @@
package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 医生助手相关模板消息
 * <p>
 * Created by Reece on 2017/9/7/007.
 */
@Service
@Transactional
public class DoctorFeldsherTemplateService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    private static final Logger logger = LoggerFactory.getLogger(DoctorFeldsherTemplateService.class);
    /**
     * 医生为居民设置监测方案后实时为居民推送信息变更通知消息提醒
     *
     * @param type    监测类型 2为血压,1为血糖
     * @param patient 居民code
     * @param comment 血糖时间段名称
     * @throws Exception
     */
    public void sendChangeTemplate(int type, String patient, String comment) throws Exception {
        Patient people = patientDao.findByCode(patient);
        String openId = people.getOpenid();
        String name = people.getName();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONArray jsonArray = null;
        JSONObject sendJson = new JSONObject();
        if (type == 1) {
            String url = "jkjl/html/health-index-add-bloodsugar.html?openid=" + openId + "&toUser=" + patient + "&toName=" +name+"&represented="+patient;
            String first = name + "您好,请按照您的血糖监测方案测量" + comment + "血糖数据。";
            String remark = "您可使用智能设备测量后自动上传数据,或点击详情手动上传测量数据";
            sendJson.put("keyword1", "血糖测量");
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, openId, name, sendJson);
            //发送代理人
            jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject j = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    int start = url.indexOf("&toUser=");
                    int end = url.indexOf("&", start + 1);
                    String touser = url.substring(start, end);
                    url = url.replace(touser, "&toUser=" + member.getCode());
                    int representedStart = url.indexOf("&represented=");
                    int representedEnd = url.length();
                    String represented = url.substring(representedStart, representedEnd);
                    url = url.replace(represented, "&represented=" + member.getCode());
                    //name患者姓名
                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                    sendJson.put("url", url);
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, member.getOpenid(), name, sendJson);
                }
            }
            logger.info("sendJson: " + sendJson);
        }
        if (type == 2) {
            String url = "jkjl/html/health-index-add-bloodpressure.html?openid=" + openId + "&toUser=" + patient + "&toName=" +name+"&represented="+patient;
            String first = name + "您好,请按照您的血压监测方案测量血压数据。";
            String remark = "您可使用智能设备测量后自动上传数据,或点击详情手动上传测量数据";
            sendJson.put("keyword1", "血压测量");
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, openId, name, sendJson);
            //发送代理人
            jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject j = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    int start = url.indexOf("&toUser=");
                    int end = url.indexOf("&", start + 1);
                    String touser = url.substring(start, end);
                    url = url.replace(touser, "&toUser=" + member.getCode());
                    int representedStart = url.indexOf("&represented=");
                    int representedEnd = url.length();
                    String represented = url.substring(representedStart, representedEnd);
                    url = url.replace(represented, "&represented=" + member.getCode());
                    //name患者姓名
                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                    sendJson.put("url", url);
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, member.getOpenid(), name, sendJson);
                }
            }
            logger.info("sendJson: " + sendJson);
        }
    }
}

+ 42 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -199,6 +199,47 @@ public class HttpUtil {
		return buffer.toString();
	}
	/**
	 * 向指定URL发送GET方法的请求
	 *
	 * @param url
	 *            发送请求的URL
	 * @param param
	 *            请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
	 * @return URL 所代表远程资源的响应结果
	 */
	public  String sendLoginGet(String url, String param,String userAgent) {
		String result = "";
		BufferedReader in = null;
		try {
			String urlNameString = url + "?" + param;
			URL realUrl = new URL(urlNameString);
			// 打开和URL之间的连接
			URLConnection connection = realUrl.openConnection();
			// 设置通用的请求属性
			connection.setRequestProperty("accept", "*/*");
			connection.setRequestProperty("connection", "Keep-Alive");
			connection.setRequestProperty("user-agent", userAgent);
			// 建立实际的连接
			connection.connect();
			// 定义 BufferedReader输入流来读取URL的响应
			in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			String line;
			while ((line = in.readLine()) != null) {
				result += line;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (in != null) {
					in.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}
}

+ 40 - 3
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.quota;
import com.yihu.wlyy.job.*;
import com.yihu.wlyy.job.consult.ConsultCleanerJob;
import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
import com.yihu.wlyy.job.consult.FinishConsultJob;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
@ -405,9 +406,27 @@ public class JobController extends BaseController {
        }
    }
    /**
     * 居民24小时未回复咨询自动结束
     * @author ysj
     * @date 2017/9/11 14:16
     */
    @RequestMapping(value = "/executeFinishConsultJob", method = RequestMethod.POST)
    @ApiOperation("居民24小时未回复咨询自动结束")
    public String executeFinishConsultJob() {
        try {
            quartzHelper.startNow(FinishConsultJob.class, UUID.randomUUID().toString(), null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**
     * 立即启动支付超时过期
     *
     * @Author Linyx
     * @params method
     * @Date 2017/8/14 11:07
@ -427,9 +446,10 @@ public class JobController extends BaseController {
    }
    /**
     *遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存
     *@author wujunjie
     *@date 2017/8/30 14:16
     * 遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存
     *
     * @author wujunjie
     * @date 2017/8/30 14:16
     */
    @RequestMapping(value = "/prescriptionPayQueryJob", method = RequestMethod.POST)
    @ApiOperation("遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存")
@ -443,4 +463,21 @@ public class JobController extends BaseController {
        }
    }
    //******************************长处方 end********************************
    /**
     * 居民监测方案提醒通知
     *
     * @author wujunjie
     * @date 2017/9/12 14:16
     */
    @RequestMapping(value = "/doctorFeldsherTemplateJob", method = RequestMethod.POST)
    @ApiOperation("提醒有监测方案的居民上传数据")
    public String DoctorFeldsherTemplateJob() {
        try {
            quartzHelper.startNow(DoctorFeldsherTemplateJob.class, "DOCTOR_FELDSHER_TEMPLATE", null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 6 - 0
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -92,6 +92,12 @@ zy_execute_sick_settle_job=0 0/10 * * * ?
#处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
prescription_pay_query_job=0 0/3 * * * ?
#居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
finish_consult_job=* 59 * * * ?
#提醒有监测方案的居民上传数据,每29分钟执行一次
doctor_feldsher_template_job=0 0/29 * * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -137,7 +137,7 @@ public class DoctorInterceptor extends BaseInterceptor {
                }
            }
            //  2、医生端app,3、微信公众号wechat,4、医生端pc,或者 PC端取药系统  或者对外系统
            if (token == null || (token.getPlatform() != 2 && token.getPlatform() != 4)) {
            if (token == null || (token.getPlatform() != 2 && token.getPlatform() != 4&&token.getPlatform()!=5)) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                flag = false;

+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientAimSportsDao.java

@ -0,0 +1,23 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 居民-运动目标
 * @author huangwenjie
 * @date 2017/9/12 16:07
 */
public interface PatientAimSportsDao extends
        PagingAndSortingRepository<PatientAimSports, Long>,
        JpaSpecificationExecutor<PatientAimSports> {
    @Query("from PatientAimSports p where p.code=?1")
    PatientAimSports findByCode(String code);
    @Query("from PatientAimSports p where p.patientcode =?1")
    PatientAimSports getPatientAimSportsByPatientCode(String patientCode);
}

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

+ 56 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -31,10 +31,13 @@ import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -87,7 +90,10 @@ public class PatientInfoService extends BaseService {
    PatientService patientService;
    @Autowired
    SystemDictDao systemDictDao;
    @Autowired
    JwArchivesService jwArchivesService;
    @Autowired
    JdbcTemplate jdbcTemplate;
    /**
     * 患者更换手机号
@ -328,4 +334,53 @@ public class PatientInfoService extends BaseService {
        return 1;
    }
    public int createProfile(String doctorCode ,String patient,String jwCountryCode,String nation,String blood,String marry)throws Exception{
        Patient p = patientDao.findByCode(patient);
        JSONObject json = new JSONObject();
        json.put("ARCHIVE_TIME", DateUtil.getStringDateShort());//建档时间
        json.put("ARCHIVE_STATUS","3");//档案状态【1.未管理 2.死亡 3.正常 4.高危】
        json.put("SICK_NAME",p.getName());//姓名
        json.put("SICK_SEX",p.getSex());//性别【1.男 2.女 9 未知】
        json.put("BIRTHDAY",p.getBirthday());//出生日期
        json.put("ZONE_CODE",jwCountryCode);//所属社区【ZONE_DICT】
        json.put("IDENTITY_TYPE","1");//证件类型【IDENTITY_TYPE_DICT】
        json.put("IDENTITY_CARD_NO",p.getIdcard());//身份证号
        json.put("HOME_PHONE",p.getMobile());//本人电话
        json.put("HOME_ADDRESS","测试地址");//现住址
        json.put("ORG_ID","0");//新增默认传0
        json.put("RESIDENCE","1");//户籍【1.户籍 2.非户籍】
        json.put("NATIONAL",nation);//民族【NATION_DICT】
        json.put("ORIGO","3502030502");//户口所在地【ZONE_DICT】
        json.put("BLOOD",blood);//血型【1.A型 2.3.O型4.AB型 5.不详】
        json.put("BLOOD_RH","1");//RH阴性【1.否 2.是 3.不详】
        json.put("MARRIAGE",marry);//婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
        String doctor = doctorCode;
        String response = jwArchivesService.saveSickArchiveRecord(json.toString(),doctor);
        return 1;
    }
    public  List<Map<String,Object>> getNationDict(){
        String sql = "SELECT t.NATION_CODE,t.NATION_NAME FROM zy_nation_dict t ";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public List<Map<String,Object>> getMarryDict(){
        return getDictByName("MARRY_STATE");
    }
    public List<Map<String,Object>> getBloodDict(){
        return getDictByName("BLOOD_TYPE");
    }
    public List<Map<String,Object>> getDictByName(String name){
        String sql = "SELECT t.code,t.`value` FROM system_dict t WHERE t.dict_name=?";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql,new Object[]{name});
        return rs;
    }
}

+ 35 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -6,14 +6,12 @@ import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientHealthStandardDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.task.HealthIndexUploadTask;
@ -40,6 +38,7 @@ import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.utils.Clock;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@ -59,22 +58,20 @@ public class PatientHealthIndexService extends BaseService {
    private MessageDao messageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    @Autowired
    private CommonUtil CommonUtil;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientAimSportsDao patientAimSportsDao;
@ -724,7 +721,36 @@ public class PatientHealthIndexService extends BaseService {
                }
                case "3": {
                    obj.setType(3);
                    obj.setValue1(map.get("weight")); //体重
                    String weight = map.get("weight");
                    String height = map.get("height");
                    obj.setValue1(weight); //体重
                    obj.setValue2(height); //身高
                    PatientAimSports patientAimSports = new PatientAimSports();
                    patientAimSports = patientAimSportsDao.getPatientAimSportsByPatientCode(patientCode);
                    //如果该患者没有设置运动目标,则获取预置数据
                    if(patientAimSports == null || StringUtils.isBlank(patientAimSports.getCode())){
                        patientAimSports = patientAimSportsDao.findByCode("default");
                    }
                    double bmi = CommonUtil.getBMIByWeightAndHeight(map.get("weight"),map.get("height"));
                    DecimalFormat df1 = new DecimalFormat("###.00");
                    obj.setValue3(df1.format(bmi));
                    if(patientAimSports != null && StringUtils.isNoneEmpty(patientAimSports.getCode())){
                        //设置BMI值
                        if(bmi < Double.parseDouble(patientAimSports.getBmiMin())){
                            obj.setValue4("1");
                        }else if(bmi > Double.parseDouble(patientAimSports.getBmiMax())){
                            obj.setValue4("-1");
                        }else{
                            obj.setValue4("0");
                        }
                    }
                    break;
                }
                case "4": {

+ 129 - 47
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -240,9 +240,10 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param labelType 标签类型
     * @param page      第几页
     * @param pagesize  页大小
     * @param sortByStandardStatus
     * @return
     */
    public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize) throws Exception {
    public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize, boolean sortByStandardStatus) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
@ -251,6 +252,8 @@ public class SignPatientLabelInfoService extends BaseService {
        Map<String, 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;
@ -349,6 +352,12 @@ public class SignPatientLabelInfoService extends BaseService {
        sql += " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        if(sortByStandardStatus){
            String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
@ -454,6 +463,20 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -480,7 +503,24 @@ public class SignPatientLabelInfoService extends BaseService {
                public int compare(JSONObject o1, JSONObject o2) {
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = openid1.compareTo(openid2);
                    int re = 0;
                    //是否根据预警字段优先排序
                    if(sortByStandardStatus){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                        if(standardStatus1 == standardStatus2){
                            re = openid1.compareTo(openid2);
                        }else{
                            re = standardStatus1 - standardStatus1;
                        }
                    }else{
                        re = openid1.compareTo(openid2);
                    }
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {
@ -3511,13 +3551,15 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param teamCode
     * @param page
     * @param pagesize
     * @param sortByStandardStatus 是否根据预警状态排序,如果true, 需要附带查询患者设备绑定情况
     * @return
     * @throws Exception
     */
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize) throws Exception {
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize, boolean sortByStandardStatus) throws Exception {
        Map<String, 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;
@ -3621,6 +3663,13 @@ public class SignPatientLabelInfoService extends BaseService {
        sql = sql + " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        if(sortByStandardStatus){
            String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
@ -3629,49 +3678,49 @@ public class SignPatientLabelInfoService extends BaseService {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
                }
//                if (result.containsKey(p.getCode())) {
//                    JSONObject jsonP = result.get(p.getCode());
//
//                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
//                        jsonP.put("signType", 3);
//                    }
//                    if (String.valueOf(sign.get("type")).equals("2")) {
//                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
//                        // 缴费情况
//                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
//                        // 缴费时间
//                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
//                        // 缴费类型
//                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
//                            boolean epTime = false;
//                            try {
//                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
//                            } catch (Exception e) {
//                                e.printStackTrace();
//                            }
//
//                            if (!epTime) {
//                                jsonP.put("expensesRemindStatus", 0);
//                            } else {
//                                jsonP.put("expensesRemindStatus", 1);
//                            }
//                        }
//                        boolean epTime = false;
//                        try {
//                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
//                        if (!epTime) {
//                            jsonP.put("wechatFocusRemind", 0);
//                        } else {
//                            jsonP.put("wechatFocusRemind", 1);
//                        }
//                    }
//
//                    continue;
//                }
                //List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
@ -3727,6 +3776,21 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -3753,7 +3817,25 @@ public class SignPatientLabelInfoService extends BaseService {
                public int compare(JSONObject o1, JSONObject o2) {
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = openid1.compareTo(openid2);
                    int re = 0;
                    //是否根据预警字段优先排序
                    if(sortByStandardStatus){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                        if(standardStatus1 == standardStatus2){
                            re = openid1.compareTo(openid2);
                        }else{
                            re = standardStatus1 - standardStatus1;
                        }
                    }else{
                        re = openid1.compareTo(openid2);
                    }
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {

Разлика између датотеке није приказан због своје велике величине
+ 342 - 198
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java


+ 61 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -511,7 +511,7 @@ public class PrescriptionInfoService extends BaseService {
        return 1;
    }
    public JSONArray getDoctorPrescription(Integer teamCode, String state, String diseases, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
    public List<Map<String, Object>> getDoctorPrescription(Integer teamCode, String state, String diseases, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
        StringBuffer pre_sql = new StringBuffer("SELECT " +
                " p.`name`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
@ -548,7 +548,7 @@ public class PrescriptionInfoService extends BaseService {
            map.put("prescriptionInfo", prescriptionDiagnosisService.getPrescriptionInfo(code));
            map.put("prescriptionDt", prescriptionDiagnosisService.getPrescriptionDiagnosis(code));
        }
        return new JSONArray(rs);
        return rs;
    }
    public void setSQL(StringBuffer pre_sql, List<Object> params, Integer teamCode, String state, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
@ -905,7 +905,14 @@ public class PrescriptionInfoService extends BaseService {
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor, " +
                " pr.dispensary_type AS dispensaryType ," +
                " e.expressage_name AS expressageName " +
                " e.expressage_code AS expressageCode, " +
                " e.expressage_name AS expressageName, " +
                " e.expressage_hospital_address AS expressageHospitalAddress, " +
                " e.expressage_hospital_name AS expressageHospitalName, " +
                " e.expressage_hospital_code AS expressageHospitalCode, " +
                " e.patient_hospital_address AS patientHospitalAddress, " +
                " e.patient_hospital_name AS patientHospitalName, " +
                " e.patient_hospital_code AS patientHospitalCode " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
@ -1052,9 +1059,9 @@ public class PrescriptionInfoService extends BaseService {
        states.add(map4);
        Map<String, Object> map5 = new HashMap<>();
        map2.put("name", "已完成");
        map2.put("code", PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        states.add(map2);
        map5.put("name", "已完成");
        map5.put("code", PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        states.add(map5);
        //设置配送状态下拉框
        rs.put("states", states);
        //
@ -1264,7 +1271,7 @@ public class PrescriptionInfoService extends BaseService {
            }
        }
        pre_sql.append(" ORDER BY r.reviewed_time DESC ");
        pre_sql.append(" ORDER BY pr.dispensary_type DESC,e.expressage_code ASC,r.reviewed_time DESC ");
        if (page != null && size != null) {
            pre_sql.append(" LIMIT " + (page - 1) * size + "," + size);
        }
@ -1576,4 +1583,51 @@ public class PrescriptionInfoService extends BaseService {
        //System.out.println("list:"+list.size());
        return  new JSONArray(list);
    }
    public JSONObject getHDoctorInDoctorHosiptal(String name,String doctor,Integer page,Integer size){
        Doctor d = doctorDao.findByCode(doctor);
        String sql = "SELECT " +
                " d.`code`," +
                " d.`name`," +
                " d.job," +
                " d.photo," +
                " j.name AS jobName " +
                " FROM" +
                " wlyy_doctor d  LEFT JOIN dm_job j ON d.job = j.`code`" +
                " WHERE" +
                " d.hospital = ?" +
                " AND d.`level` = 3 " ;
                if(StringUtils.isNotBlank(name)){
                    sql +=" AND d.`name` LIKE '%"+name+"%' ";
                }
                if(page!=null&&size!=null){
                    sql += " LIMIT "+(page-1)+","+size;
                }
        String totalSql = "SELECT " +
                " count(1) AS total" +
                " FROM" +
                " wlyy_doctor d " +
                " WHERE" +
                " d.hospital = ?" +
                " AND d.`level` = 3 ";
        if(StringUtils.isNotBlank(name)){
            totalSql +=" AND d.`name` LIKE '%"+name+"%' ";
        }
        JSONObject jsonObject = new JSONObject();
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql,new Object[]{d.getHospital()});
        if(totalList!=null&&totalList.size()>0){
            jsonObject.put("total",totalList.get(0).get("total"));
        }else{
            jsonObject.put("total",0L);
            jsonObject.put("doctors","");
            return jsonObject;
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql,new Object[]{d.getHospital()});
        if(list!=null&&list.size()>0){
            jsonObject.put("doctors",list);
        }else{
            jsonObject.put("doctors","");
        }
        return jsonObject;
    }
}

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

@ -1875,13 +1875,22 @@ public class SignWebService extends BaseService {
     *
     * @return
     */
    public JSONObject getOverDuePatients(String year, Long teamCode, String doctor, Integer page, Integer pageSize) {
    public JSONObject getOverDuePatients(String year, Long teamCode, String doctor, Integer page, Integer pageSize, boolean sortByStandardStatus) {
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                " FROM wlyy_sign_family t " +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " );
        if(sortByStandardStatus){
            sql.append(",(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) deviceType ");
        }
        sql.append("FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " WHERE t.doctor ='" + doctor + "' AND t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 LIMIT " + page * pageSize + "," + pageSize);
        if (sortByStandardStatus){
            sql.append("order by p.standardStatus desc ");
        }
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result", rs);
@ -1893,13 +1902,24 @@ public class SignWebService extends BaseService {
     *
     * @return
     */
    public JSONObject getOverDuePatientsByTeam(String year, Long teamCode, Integer page, Integer pageSize) {
    public JSONObject getOverDuePatientsByTeam(String year, Long teamCode, Integer page, Integer pageSize, boolean sortByStandardStatus) {
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                " FROM wlyy_sign_family t " +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus,p.disease, p.diseaseCondition, p.standardStatus ");
        if(sortByStandardStatus){
            sql.append(",(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) deviceType ");
        }
        sql.append(" FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " WHERE t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 LIMIT " + page * pageSize + "," + pageSize);
                " WHERE t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 ");
        if (sortByStandardStatus){
            sql.append("order by p.standardStatus desc ");
        }
        sql.append("LIMIT " + page * pageSize + ", "+ pageSize);
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result", rs);

+ 92 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/fzzb/HealthEducationArticleService.java

@ -0,0 +1,92 @@
package com.yihu.wlyy.service.third.fzzb;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
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.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
 * 福州总部-健康教育医生APP接口文档
 * 文档地址- http://sso.yihu.cn/DWeb/wiki/wz.html?id=CF5D09684702481BA70F84142817A639
 * Created by yeshijie on 2017/9/11.
 */
@Service
public class HealthEducationArticleService extends BaseService{
    private static Logger logger = LoggerFactory.getLogger(HealthEducationArticleService.class);
    @Autowired
    private HttpClientUtil httpClientUtil;
    private String baseUrl = "http://service.yihu.com:8085/WsPlatform/rest";
    @Value("${yihu.yihu_OpenPlatform_appId}")
    private String clientId;
    private String clientVersion = "1.0";
    private String getArticalById = "JkEdu/Article/getArticalById";//获取单篇文章详情
    private String getDoctorArticalList = "JkEdu/Article/getDoctorArticalList";//获取卫计委认证文章+医生发表未认证文章
    private String getCollectionArticalList = "JkEdu/Article/getCollectionArticalList";//获取收藏文章列表
    private String getCategoryList = "JkEdu/Category/getCategoryList";//获取类别接口
    private String cancelArticleCollection = "JkEdu/Behavior/cancelArticleCollection";//取消收藏接口
    private String saveArticleCollection = "JkEdu/Behavior/saveArticleCollection";//医生收藏接口
    public Map<String,String> getParamsMap(String api,String param){
        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());
        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","1");//API 版本号。版本号为整型,从数字 1 开始递增.
        return params;
    }
    /**
     * 获取文章列表
     * @param articleTitle 否 文章标题
     * @param articleState 否 传1
     * @param firstLevelCategoryId 否    一级类别ID ,多个逗号隔开
     * @param pageIndex 否    起始页数 0开始,默认0
     * @param pageSize 否    每页显示数 ,默认5
     * @param userId 是    当前用户ID
     * @return
     */
    public String getDoctorArticalList(String articleTitle, Integer articleState, String firstLevelCategoryId, Integer pageIndex, Integer pageSize,String userId){
        String response = "";
        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);
            response = httpClientUtil.httpPost(baseUrl,getParamsMap("JkEdu.Article.getDoctorArticalList",param.toString()));
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return response;
    }
}

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -1175,7 +1175,8 @@ public class GuahaoXMService implements IGuahaoService {
            String startTime = map.get("startTime");
            String endTime = map.get("endTime");
            String response = jwSmjkService.webRegisterByFamily(cardNo, patientName, clinicCard, sectionType, startTime, hospitalId, hosDeptId, hosDeptName, doctorId, doctorName,patientPhone);
//            String response = jwSmjkService.webRegisterByFamily(cardNo, patientName, clinicCard, sectionType, startTime, hospitalId, hosDeptId, hosDeptName, doctorId, doctorName,patientPhone);
            String response = "e07cfa6a-e134-4329-bb99-9b7dbffea79e|516|熊永强";
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
        } else {

+ 144 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -805,4 +804,148 @@ public class JwArchivesService {
            throw new Exception("返回结果为空!");
        }
    }
    /*****************************************建档相关******************************************************************/
    /**
     *  查询居民是否有建立健康档案接口
     */
    public String getSickArchiveFlag(String idcard)  throws Exception
    {
        String re = "0";//0 未建档,非0为档案号
        String url = jwUrl + "/third/archives/getSickArchiveFlag";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }else{
                String dataStr = json.getString("data");
                if(!StringUtils.isEmpty(dataStr)){
                    JSONObject data = new JSONObject(dataStr);
                    if("1".equals(data.optString("CODE")))
                    {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        re = jsonArray.getJSONObject(0).getString("ARCHIVE_ID");
                    }
                    else{
                        throw new Exception(json.optString("MESSAGE"));
                    }
                }else{
                    throw new Exception("返回结果为空!");
                }
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
        return re;
    }
    /**
     * 查询居民健康档案信息接口
     * @param idcard
     * @return
     * @throws Exception
     */
    public JSONArray getSickArchiveRecord(String idcard)  throws Exception
    {
        JSONArray re = new JSONArray();
        String url = jwUrl + "/third/archives/getSickArchiveRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }else{
                String dataStr = json.getString("data");
                if(!StringUtils.isEmpty(dataStr)){
                    JSONObject data = new JSONObject(dataStr);
                    if("1".equals(data.optString("CODE")))
                    {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        // {"ARCHIVE_ID":"档案ID","SICK_NAME":"病人姓名","SICK_SEX":"性别","BIRTHDAY":"出生日期","IDENTITY_CARD_NO":"身份证号码","ZONE_CODE":"归属辖区","HOME_ADDRESS":"现住址","INSUR_CARD_NO":"医保卡号"}
                        jsonArray.forEach(one->{
                            JSONObject jsonObject = new JSONObject(one);
                            JSONObject js = new JSONObject();
                            js.put("archiveId",jsonObject.get("ARCHIVE_ID"));
                            js.put("sickName",jsonObject.get("SICK_NAME"));
                            js.put("sickSex",jsonObject.get("SICK_SEX"));
                            js.put("birthday",jsonObject.get("BIRTHDAY"));
                            js.put("idCard",jsonObject.get("IDENTITY_CARD_NO"));
                            js.put("zoneCode",jsonObject.get("ZONE_CODE"));
                            js.put("homeAddress",jsonObject.get("HOME_ADDRESS"));
                            js.put("ssc",jsonObject.get("INSUR_CARD_NO"));
                            re.put(js);
                        });
                    }
                    else{
                        throw new Exception(json.optString("MESSAGE"));
                    }
                }else{
                    throw new Exception("返回结果为空!");
                }
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
        return re;
    }
    /**
     * 上传居民档案建档信息接口
     * @param param 入参json对象,成功返回档案号
     * @param doctor
     * @return
     */
    public String saveSickArchiveRecord(String param,String doctor) throws Exception{
        String re = "0";//0 未建档,非0为档案号
        String url = jwUrl + "/third/archives/saveSickArchiveRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("json", param));
        params.add(new BasicNameValuePair("doctor", doctor));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }else{
                String dataStr = json.getString("data");
                if(!StringUtils.isEmpty(dataStr)){
                    JSONObject data = new JSONObject(dataStr);
                    if("1".equals(data.optString("CODE")))
                    {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        re = jsonArray.getJSONObject(0).getString("ARCHIVE_ID");
                    }
                    else{
                        throw new Exception(json.optString("MESSAGE"));
                    }
                }else{
                    throw new Exception("返回结果为空!");
                }
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
        return re;
    }
}

+ 0 - 129
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java

@ -1,129 +0,0 @@
package com.yihu.wlyy.service.weixin.wxpay.common;
import org.springframework.context.annotation.Configuration;
/**
 * User: hzp
 * Date: 20170518
 * 这里放置各种配置数据
 */
@Configuration
public class Configure {
	/******************************* 易联众统一支付平台 ***********************************************************/
//	private String onepayApi = "http://120.42.37.94:1301/onepay-web/";
//	private String onepayAppId = "1BGKM1UHM03P7B2CA8C000005626EB0E";
//	private String onepayAppSecret = "1BGKM1UHM03I7B2CA8C00000AB682E9A";
//			开发环境应用信息
//	private String onepayApi = "https://xmhealth.ylzpay.com:8080/";
	private String onepayApi = "http://xmhealth.ylzpay.com:8070/";
	private String onepayAppId = "1BLF5SEGN00087165F0A000027362BE5";
	private String onepayAppSecret = "1BLF5SCBO01V3E78A8C00000F3A0FFE7";
	private String bindCardType = "onepay.sicard.bind.info";
	private String chargeType = "onepay.trade.medical.charge";
	private String chargeQueryType = "onepay.trade.medical.charge.query";
	private String createSicardType = "onepay.sicard.createurl";
//	易联众异步回调
	private String receiveNotify = "wlyy.onepay.receiveNotify";
	private String returnUrl = "wlyy.onepay.returnUrl";
//  长处方系列
	private String recipeChargeType = "onepay.trade.long.recipe.charge";
	private String recipeReturnUrl = "wlyy.patient.prescription.pay.recipeReturnUrl";
	private String receiveRecipeNotify = "wlyy.patient.prescription.pay.receiveRecipeNotify";
	public String getRecipeChargeType() {
		return recipeChargeType;
	}
	public void setRecipeChargeType(String recipeChargeType) {
		this.recipeChargeType = recipeChargeType;
	}
	public String getRecipeReturnUrl() {
		return recipeReturnUrl;
	}
	public void setRecipeReturnUrl(String recipeReturnUrl) {
		this.recipeReturnUrl = recipeReturnUrl;
	}
	public String getReceiveRecipeNotify() {
		return receiveRecipeNotify;
	}
	public void setReceiveRecipeNotify(String receiveRecipeNotify) {
		this.receiveRecipeNotify = receiveRecipeNotify;
	}
	public String getReturnUrl() {
		return returnUrl;
	}
	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}
	public String getReceiveNotify() {
		return receiveNotify;
	}
	public void setReceiveNotify(String receiveNotify) {
		this.receiveNotify = receiveNotify;
	}
	public String getOnepayApi() {
		return onepayApi;
	}
	public String getOnepayAppId() {
		return onepayAppId;
	}
	public String getOnepayAppSecret() {
		return onepayAppSecret;
	}
	public String getBindCardType() {
		return bindCardType;
	}
	public String getChargeType() {
		return chargeType;
	}
	public String getChargeQueryType() {
		return chargeQueryType;
	}
	public String getCreateSicardType() {
		return createSicardType;
	}
	/******************* 微信社保支付配置 ******************************************/
	//这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中)
	// 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证
	// 收到API的返回的时候也要用这个key来对返回的数据算下签名,跟API的Sign数据进行比较,如果值不一致,有可能数据被第三方给篡改
	private String key = "2935b54b53a957d9516c920a544f2537";
	//微信分配的公众号ID(开通公众号之后可以获取到)
	private String appID = "wxd03f859efdf0873d";
	public String getKey(){
		return key;
	}
	public String getAppid(){
		return appID;
	}
	//获取token地址
	public String TOKEN_API = "https://api.weixin.qq.com/payinsurance/gettoken";
	//挂号/诊间支付统一下单 API 接口
	public String ORDER_API = "https://api.weixin.qq.com/payinsurance/unifiedorder?access_token ACCESS_TOKEN";
}

+ 22 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.*;
import java.text.DecimalFormat;
@Component
public class CommonUtil {
    @Value("${fastDFS.fastdfs_file_url}")
@ -347,5 +349,25 @@ public class CommonUtil {
        return null;
    }
    /**
     * 传入身高体重,计算BMI值
     * @param weightStr 体重
     * @param heightStr 身高
     * @return
     */
    public double getBMIByWeightAndHeight(String weightStr,String heightStr){
        DecimalFormat df2 = new DecimalFormat("###.00");
        double weight = Double.parseDouble(weightStr);
        Integer heightCM = Integer.parseInt(heightStr);
        heightStr = df2.format(heightCM/100d);
        double height = Double.parseDouble(heightStr);
        double bmi = weight / height * 2;
        return bmi;
    }
}

+ 1 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -20,6 +20,7 @@ public class DateUtil {
	public static final String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public static final String YYYY_M_D_HH_MM_SS = "yyyy/M/d HH:mm:ss";
	public static final String YYYYMMddHHmmssSSS  = "yyyyMMddHHmmssSSS";
	/**
@ -30,11 +31,6 @@ public class DateUtil {
		return formatter.format(date);
	}
	/*public static void main(String[] args)
	{
	   System.out.print(dateToChinese(new Date()));
	}*/
	/**
	 * 字符串转时间格式
	 */

+ 33 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java

@ -140,6 +140,39 @@ public class ImUtill {
        return response;
    }
    /**
     * 咨询列表总数
     * @param user
     * @param status status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
     * @param reply
     * @param type 1、三师咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询 10医生发起的求助
     * @return
     */
    public String getConsultCountByStatusAndType(String user,Integer status,Integer reply,Integer type,String patientName,String startTime,String endTime){
        String imAddr = im_host + "api/v2/sessions/topicListCountByType";
        imAddr = imAddr + "?user="+user;
        if (status != null) {
            imAddr += ("&status=" + status);
        }
        if (reply != null) {
            imAddr += ("&reply=" + reply);
        }
        if (type != null) {
            imAddr += ("&type=" + type);
        }
        if (patientName != null) {
            imAddr += ("&patientName=" + patientName);
        }
        if (startTime != null) {
            imAddr += ("&startTime=" + startTime);
        }
        if (endTime != null) {
            imAddr += ("&endTime=" + endTime);
        }
        String response = HttpClientUtil.get(imAddr, "UTF-8");
        return response;
    }
    /**
     * 发送消息给IM
     *

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java

@ -44,6 +44,8 @@ public class BaseController {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            logger.info("json:"+json.toString());
            System.out.println("json:"+json.toString());
            return json.getString("uid");
        } catch (Exception e) {

+ 34 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/im/imController.java

@ -174,6 +174,7 @@ public class imController extends BaseController {
                }
                map.put("id", id);
                map.put("status", status);
                map.put("session_id", session_id);
                map.put("photo", avatar);
                map.put("patientName", name);
@ -194,6 +195,39 @@ public class imController extends BaseController {
        }
    }
    /**
     * 获取列表
     * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
     * 第一次列表为当前医生(很可能团队长)待回复列表 传参:doctor有后台获取 status=0,reply=0未回复
     * 后 取团队内单个医生的咨询情况 doctor、status、reply均有前端传入
     *
     * @return
     */
    @RequestMapping(value = "/consult/getListCount", method = RequestMethod.GET)
    @ResponseBody
    public String getConsultCountByStatus(
            @RequestParam(required = false) String doctor,
            @RequestParam Integer status,
            @RequestParam(required = false) Integer reply,
            @ApiParam(name = "type", value = "咨询类型") @RequestParam(required = true) Integer type,
            @ApiParam(name = "patientName", value = "居民姓名") @RequestParam(required = false) String patientName,
            @ApiParam(name = "startTime", value = "开始时间") @RequestParam(required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间") @RequestParam(required = false) String endTime) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                doctor = getUID();
            }
            String consult = null;
            consult = ImUtill.getConsultCountByStatusAndType(doctor, status, reply,type,patientName,startTime,endTime);
            JSONObject json = new JSONObject(consult);
            return write(200, "查询成功", "total", json.getInt("count"));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    /**
     * 获取团队统计数据
     * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复

+ 28 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -12,10 +12,10 @@ import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
@ -497,7 +497,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    }
    private void getPatientByGroup(String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize, false);
        for (Object o : result) {
            JSONObject json = (JSONObject) o;
            String patient = (String) json.get("code");
@ -600,7 +600,31 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    }
    public static void main(String arg[]) {
        System.out.println(MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.P_HE_01.name());
    /**********************************福州健康文章接口********************************************/
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    @RequestMapping(value = "getDoctorArticalList",method = RequestMethod.GET)
    @ApiOperation("获取健康教育文章列表")
    @ResponseBody
    public String getDoctorArticalList(@ApiParam(name = "articleTitle", value = "文章标题")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                       @RequestParam(value = "articleState", required = true,defaultValue = "1") Integer articleState,
                                       @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                       @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                       @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
//            String response = healthEducationArticleService.getDoctorArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID());
            String response = healthEducationArticleService.getDoctorArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
}

+ 47 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthRecordController.java

@ -261,4 +261,51 @@ public class DoctorHealthRecordController extends BaseController {
		}
	}
	@RequestMapping(value = "testFlag", method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("是否建档")
	public String getSickArchiveFlag(@ApiParam(name = "idcard", value = "体检ID", defaultValue = "1249652")
								 @RequestParam(value="idcard",required = true) String idcard){
		try{
			String response = jwArchivesService.getSickArchiveFlag(idcard);
			return write(200,"查询成功","getSickArchiveFlag",response);
		}catch (Exception e){
			error(e);
			return error(-1,"查询失败");
		}
	}
	@RequestMapping(value = "saveSickArchiveRecord", method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("上传建档")
	public String testFlag(){
		try{
			JSONObject json = new JSONObject();
			json.put("ARCHIVE_TIME",DateUtil.getStringDateShort());//建档时间
			json.put("ARCHIVE_STATUS","3");//档案状态【1.未管理 2.死亡 3.正常 4.高危】
			json.put("SICK_NAME","");//姓名
			json.put("SICK_SEX","");//性别【1.男 2.女 9 未知】
			json.put("BIRTHDAY","");//出生日期
			json.put("ZONE_CODE","");//所属社区【ZONE_DICT】
			json.put("IDENTITY_TYPE","");//证件类型【IDENTITY_TYPE_DICT】
			json.put("IDENTITY_CARD_NO","");//身份证号
			json.put("HOME_PHONE","");//本人电话
			json.put("HOME_ADDRESS","");//现住址
			json.put("ORG_ID","0");//新增默认传0
			json.put("RESIDENCE","1");//户籍【1.户籍 2.非户籍】
			json.put("SICK_NAME","");//姓名
			json.put("SICK_NAME","");//姓名
			json.put("SICK_NAME","");//姓名
			json.put("SICK_NAME","");//姓名
			String doctor = "";
			String response = jwArchivesService.saveSickArchiveRecord(json.toString(),doctor);
			return write(200,"查询成功","saveSickArchiveRecord",response);
		}catch (Exception e){
			error(e);
			return error(-1,"查询失败");
		}
	}
}

+ 62 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
@ -15,6 +16,7 @@ import com.yihu.wlyy.util.DateUtil;
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.json.JSONArray;
import org.json.JSONObject;
@ -25,6 +27,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.DateFormat;
@ -75,4 +78,63 @@ public class PatientInfoController extends BaseController {
            return invalidUserException(e, -1, "获取患者信息失败!");
        }
    }
    @RequestMapping(value = "createProfile",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("档案建立")
    @ObserverRequired
    public String createProfile(@ApiParam(value = "医生code", name = "doctorCode") @RequestParam(required = true)String doctorCode ,
                                @ApiParam(value = "患者code", name = "patient") @RequestParam(required = true)String patient,
                                @ApiParam(value = "居委会", name = "jwCountryCode") @RequestParam(required = true)String jwCountryCode,
                                @ApiParam(value = "民族", name = "nation") @RequestParam(required = true)String nation,
                                @ApiParam(value = "血型", name = "blood") @RequestParam(required = true)String blood,
                                @ApiParam(value = "婚姻状况", name = "marry") @RequestParam(required = true)String marry){
        try {
            // 获取医生下的患者
            return write(200, "档案建立成功!", "data", patientInfoService.createProfile(doctorCode , patient, jwCountryCode, nation, blood, marry));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取患者信息失败!");
        }
    }
    @RequestMapping(value = "getNationDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取民族信息列表")
    public String getNationDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getNationDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getMarryDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("婚姻状态字典")
    public String getMarryDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getMarryDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getBloodDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("血型状态字典")
    public String getBloodDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getBloodDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
}

+ 12 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -148,7 +148,8 @@ public class SignPatientLabelInfoController extends BaseController {
                                        @RequestParam(required = false) String labelType,
                                        @RequestParam(required = false) Long teamCode,
                                        @RequestParam(required = false) int page,
                                        @RequestParam(required = false) int pagesize) {
                                        @RequestParam(required = false) int pagesize,
                                        @RequestParam(required = false) boolean sortByStandardStatus) {
        try {
            if (StringUtils.isEmpty(labelCode)) {
                return error(-1, "标签cdoe不能为空");
@ -162,12 +163,14 @@ public class SignPatientLabelInfoController extends BaseController {
            page = page - 1;
            //按照签约年度  labelCode 是年度 例如 2016
            //labelType=9 签约过期的居民列表
            if (labelType.equals("9")) {
                JSONObject jsonObject = signWebService.getOverDuePatients(labelCode, teamCode, getUID(), page, pagesize);
                JSONObject jsonObject = signWebService.getOverDuePatients(labelCode, teamCode, getUID(), page, pagesize,sortByStandardStatus);
                return write(200, "查询成功", "data", jsonObject);
            }
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize,sortByStandardStatus);
            //JSONArray result = labelInfoService.getPatientByLabel("xh1D201703150222", labelCode, labelType, teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
@ -223,7 +226,9 @@ public class SignPatientLabelInfoController extends BaseController {
    public String getTeamPatient(@RequestParam(required = true) Long teamCode,
                                 @RequestParam(required = false) String labelCode,
                                 @RequestParam(required = false) String labelType,
                                 @RequestParam(required = true) int page, @RequestParam(required = true) int pagesize) {
                                 @RequestParam(required = true) int page,
                                 @RequestParam(required = true) int pagesize,
                                 @RequestParam(required = false) boolean sortByStandardStatus) {
        try {
            if (teamCode == null || teamCode < 1) {
                return error(-1, "团队cdoe不能为空");
@ -235,13 +240,14 @@ public class SignPatientLabelInfoController extends BaseController {
            page = page > 0 ? page - 1 : 0;
            //labelType=9 签约过期的居民列表
            if ("9".equals(labelType)) {
                JSONObject jsonObject = signWebService.getOverDuePatientsByTeam(labelCode, teamCode, page, pagesize);
                JSONObject jsonObject = signWebService.getOverDuePatientsByTeam(labelCode, teamCode, page, pagesize,sortByStandardStatus);
                return write(200, "查询成功", "data", jsonObject);
            }
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize);
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize,sortByStandardStatus);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {

+ 15 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -66,7 +66,7 @@ public class PrescriptionInfoController extends BaseController {
    @ApiOperation(value = "获取全科医生/建管师续方列表/搜索")
    public String getDoctorPrescription(@RequestParam(required = false) @ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
                                        @RequestParam(required = false) @ApiParam(value = "续方状态", name = "state") String state,
                                        @RequestParam(required = false) @ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "dispensary") String diseases,
                                        @RequestParam(required = false) @ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "diseases") String diseases,
                                        @RequestParam(required = false) @ApiParam(name = "startDate", value = "开始时间") String startDate,
                                        @RequestParam(required = false) @ApiParam(name = "endDate", value = "结束时间") String endDate,
                                        @RequestParam(required = false) @ApiParam(name = "nameKeyword", value = "患者姓名模糊匹配") String nameKeyword,
@ -267,7 +267,7 @@ public class PrescriptionInfoController extends BaseController {
             @RequestParam(required = false) @ApiParam(value = "服务站", name = "hospital") String hospital,
             @RequestParam(required = false) @ApiParam(value = "配送状态", name = "state") String state) {
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getHDoctorPrescriptionExpressageTotal(teamCode, type, getRepUID(), nameKey, startDate, endDate, hospital, state));
            return write(200, "操作成功!", "data", prescriptionInfoService.getHDoctorPrescriptionExpressageTotal(teamCode, type, getUID(), nameKey, startDate, endDate, hospital, state));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -546,4 +546,17 @@ public class PrescriptionInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/getHDoctorInDoctorHosiptal", method = RequestMethod.GET)
    @ApiOperation(value = "获取当前登录医生所在社区健管师列表")
    public String getHDoctorInDoctorHosiptal(@RequestParam(required = false) @ApiParam(name = "name", value = "健康管理师姓名关键字")String name,
                                             @RequestParam(required = false) @ApiParam(name = "page", value = "页数从1开始")Integer page,
                                             @RequestParam(required = false) @ApiParam(name = "size", value = "每页大小")Integer size){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getHDoctorInDoctorHosiptal(name,getUID(),page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java

@ -20,6 +20,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -47,7 +49,7 @@ public class GcDoctorController extends BaseController {
    @Autowired
    private FamilyContractService familyContractService;
    private Logger logger = LoggerFactory.getLogger(GcDoctorController.class);
    @RequestMapping(value = "/doctor", method = RequestMethod.GET)
    @ApiOperation("根据医生code查询医生信息")
    public ResultOneModel<DoctorModel> doctor(
@ -106,7 +108,9 @@ public class GcDoctorController extends BaseController {
    @ApiOperation("获取医生所属团队")
    public ResultListModel<AdminTeamModel> doctors(
    ) {
        List<AdminTeam> teams = adminTeamService.getDoctorTeams(getUID());
        logger.info("getUID:"+getUID());
        System.out.println("getUID:"+getUID());
        List<AdminTeam> teams = adminTeamService.getDoctorTeams(getUID());//hxmD201703150222"
        List<AdminTeamModel> adminTeamModelList = new ArrayList<>();
        if (teams != null && teams.size() > 0) {
            teams.stream().forEach(one -> {

+ 3 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

@ -1,13 +1,11 @@
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.service.GcLabelService;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HospitalModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientLabelModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
@ -18,7 +16,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -98,10 +95,11 @@ public class GcLableController extends BaseController {
            @ApiParam(name = "labelCode", value = "标签code", required = true) @RequestParam(value = "labelCode", required = true) String labelCode,
            @ApiParam(name = "teamCode", value = "所属团队", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode,
            @ApiParam(name = "page", value = "当前页(1开始)", required = true) @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize,
            @ApiParam(name = "sortByStandardStatus", value = "是否按照预警状态排序", required = true) @RequestParam(value="sortByStandardStatus",required = false,defaultValue = "false") boolean sortByStandardStatus
    ) {
        try {
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize);
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize, sortByStandardStatus);
            List<PatientModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java

@ -183,7 +183,7 @@ public class GcEduArticleService {
        }
        //保存到ES中
        //elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
        elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
        return healthEduArticlePatients;
    }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -13,7 +13,7 @@ spring:
      password: 123456
  redis:
    host: 172.19.103.47 # Redis server host.
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr

+ 4 - 6
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -1,4 +1,4 @@
##内网环境
##内网的配置
spring:
  profiles: local
@ -85,14 +85,11 @@ express:
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: SDDF
  sf_check_word: ttzlgGyOQu4L
pushMes:
  # 1为推送redis,0为推送消息队列
# 1为推送redis,0为推送消息队列
  method: 1
  # redis队列名称
  redis_prescription_title: redisPrescription
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test
@ -103,10 +100,11 @@ es:
  tPort: 9300
  clusterName: jkzl
#消息队列
activemq:
  username: admin
  password: admin
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_local  #健康文章推送
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送

+ 12 - 4
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -1,6 +1,6 @@
##内网环境连测试环境
##内网开发连测试配置
spring:
  profiles: local_test
  profiles: localtest
  datasource:
    wlyy:
@ -90,6 +90,15 @@ pushMes:
  method: 1
  # redis队列名称
  redis_prescription_title: redisPrescription
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test
  type:
    HealthEduArticlePatient: health_edu_article_patient_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  clusterName: jkzl
#消息队列
@ -98,5 +107,4 @@ activemq:
  password: admin
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_localtest  #健康文章推送
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

@ -61,7 +61,7 @@
	  "sub_button":[
		{
		   "type":"view",
		   "name":"专属服务",
		   "name":"签约特色服务",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fdist%2fhtml%2fexclusive-service.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
		{