liubing 3 лет назад
Родитель
Сommit
f7e42b4374
19 измененных файлов с 478 добавлено и 44 удалено
  1. 4 0
      common/common-entity/sql记录
  2. 9 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  3. 55 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/DoctorConsultController.java
  4. 14 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/WxPushEndpoint.java
  5. 4 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  6. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/DoctorDoorCoachOrderController.java
  7. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/PatientDoorCoachOrderController.java
  8. 9 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/WxPushService.java
  9. 9 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java
  10. 7 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java
  11. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  12. 31 8
      svr/svr-cloud-job/src/main/java/com.yihu/jw.care/event/ApplicationEvent.java
  13. 96 0
      svr/svr-cloud-job/src/main/java/com.yihu/jw.care/job/consult/FinishConsultJob.java
  14. 59 0
      svr/svr-cloud-job/src/main/java/com.yihu/jw.care/job/message/DoctorSendUnreadJob.java
  15. 82 0
      svr/svr-cloud-job/src/main/java/com.yihu/jw.care/job/message/PatientSendUnreadJob.java
  16. 36 0
      svr/svr-cloud-job/src/main/java/com.yihu/jw.care/util/MessageUtil.java
  17. 45 0
      svr/svr-cloud-job/src/main/java/com.yihu/jw.care/util/http/HttpUtils.java
  18. 6 2
      svr/svr-cloud-job/src/main/resources/application.yml
  19. 6 22
      svr/svr-cloud-job/src/main/resources/system.properties

Разница между файлами не показана из-за своего большого размера
+ 4 - 0
common/common-entity/sql记录


+ 9 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -82,6 +82,11 @@ public class DateUtil {
        return formatter.format(date);
    }
    public static String dateToChineseTime2(Date date) {
        SimpleDateFormat formatter =   new SimpleDateFormat( "yyyy年MM月dd日 hh:mm", Locale.CHINA);
        return formatter.format(date);
    }
    public static Date getNight23(){
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY,22);
@ -1182,6 +1187,10 @@ public class DateUtil {
    }
    public static void main(String[] args) {
        String time = DateUtil.getStringDateShort()+" 09:00:00";
        Date timeDate = DateUtil.strToDate(time);
        System.out.println(dateToChineseTime2(timeDate));
        Date dateStart = getDateStart();
        Date dateEnd = getDateEnd();
        System.out.println(dateStart );

+ 55 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/DoctorConsultController.java

@ -0,0 +1,55 @@
package com.yihu.jw.care.endpoint.consult;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * 医生端:三师咨询控制类
 *
 * @author George
 */
@RestController
@RequestMapping(value = "/doctor/consult", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生咨询")
public class DoctorConsultController extends EnvelopRestEndpoint {
    @Autowired
    private ConsultTeamService consultTeamService;
    /**
     * 结束咨询接口
     * @param consult 咨询标识
     * @return
     */
    @ApiOperation("结束咨询接口")
    @RequestMapping(value = "finish_consult",method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    @ObserverRequired
    public Envelop finishConsult(@RequestParam(required = false) String consult) {
        try {
            int flag = consultTeamService.finishConsult(consult, getUID(), 2);
//            int flag = consultTeamService.finishConsult(consult, "admin", 2);
            if (flag > 0) {
                return success("咨询已关闭");
            } else if(flag == -1) {
                return Envelop.getError("该咨询已经关闭,不需重复关闭!");
            } else if(flag == -2) {
                return Envelop.getError( "续方未审核,不能结束续方咨询!");
            }  else {
                return Envelop.getError( "关闭失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError( "关闭失败!");
        }
    }
}

+ 14 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/WxPushEndpoint.java

@ -51,4 +51,18 @@ public class WxPushEndpoint extends EnvelopRestEndpoint {
        wxPushService.sendWXTemplate(userName, idCard, phone, title, url, content, topidId, sessionId, contentString);
        return success("success");
    }
    @PostMapping(value = "sendPatientUnreadWXTemplate")
    @ApiOperation(value = "Job发送居民未读消息微信模板消息")
    public Envelop sendPatientUnreadWXTemplate(@ApiParam(name = "openid", value = "openid")
                                               @RequestParam(value = "openid", required = true) String openid,
                                               @ApiParam(name = "first", value = "first")
                                               @RequestParam(value = "first", required = true) String first,
                                               @ApiParam(name = "templateName", value = "templateName")
                                               @RequestParam(value = "templateName", required = true) String templateName,
                                               @ApiParam(name = "scene", value = "scene")
                                               @RequestParam(value = "scene", required = true) String scene){
        wxPushService.sendPatientUnreadWXTemplate(openid,first,templateName,scene);
        return success("success");
    }
}

+ 4 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.endpoint.doctor;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.doctor.CareDoctorService;
import com.yihu.jw.care.service.doorCoach.DoctorDoorCoachOrderService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
@ -11,6 +12,7 @@ import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.netty.handler.codec.serialization.ObjectEncoder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -35,6 +37,8 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
    private CareDoctorService doctorService;
    @Autowired
    private CapacityAssessmentRecordService capacityAssessmentRecordService;
    @Autowired
    private ConsultTeamService consultTeamService;
    @GetMapping(value = "doctorPage")
    @ApiOperation(value = "获取医生记录分页")

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/DoctorDoorCoachOrderController.java

@ -259,8 +259,8 @@ public class DoctorDoorCoachOrderController extends BaseController {
            // 没有提供工单id的情况下,默认代入上一次服务信息记录
            if (StringUtils.isEmpty(orderId)) {
                orderId = doctorDoorCoachOrderService.getOrderIdByDoctor(doctor);
                if (StringUtils.isEmpty(orderId)) {
                    return error(204, "获取失败,该医生暂无工单" );
                if (StringUtils.isBlank(orderId)) {
                    return error(-1, "获取失败,该医生暂无工单" );
                }
            }
            // 根据orderId查询工单小结表
@ -504,7 +504,7 @@ public class DoctorDoorCoachOrderController extends BaseController {
            if (StringUtils.isEmpty(orderId)) {
                // 根据接单医生code获取最近一次服务orderId
                orderId = doctorDoorCoachOrderService.getOrderIdByDoctor(doctor);
                if (StringUtils.isEmpty(orderId)) {
                if (StringUtils.isBlank(orderId)) {
                    return error(-1, "获取失败, 该医生暂无工单" );
                }
            }

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/PatientDoorCoachOrderController.java

@ -192,7 +192,7 @@ public class PatientDoorCoachOrderController extends EnvelopRestEndpoint {
                // 根据接单医生code获取最近一次服务orderId
                orderId = patientDoorCoachOrderService.getOrderIdByPatient(patientCode);
                if (StringUtils.isEmpty(orderId)) {
                    return ObjEnvelop.getSuccess( "获取失败, 该医生暂无工单",null);
                    return ObjEnvelop.getSuccess( "获取失败, 该患者暂无工单",null);
                }
            }
            // 根据orderId获取工单信息

+ 9 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/WxPushService.java

@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
@ -69,4 +70,12 @@ public class WxPushService {
                    DateUtil.getStringDate(),content,"已回复");
        }
    }
    public void sendPatientUnreadWXTemplate(String openid,String first,String templateName,String scene){
        String time = DateUtil.getStringDateShort()+" 09:00:00";
        Date timeDate = DateUtil.strToDate(time);
        messageUtil.putTemplateWxMessage(wxId,templateName,scene,openid,first,null,null,1,null,
                DateUtil.getStringDate(),"消息未回复通知","未回复");
    }
}

+ 9 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java

@ -448,7 +448,7 @@ public class DoctorDoorCoachOrderService {
            List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
            if (basePatientWechatDos.size()>0){
                String openId = basePatientWechatDos.get(0).getOpenid();
                messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyjjd",openId,first,null,null,30,json, DateUtil.dateToChineseDate(new Date()),"上门预约已接单");
                messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyjjd",openId,first,null,null,30,json, DateUtil.dateToChineseDate(new Date()),"上门预约已接单","已接单");
            }
        }catch (Exception e){
            e.printStackTrace();
@ -606,7 +606,7 @@ public class DoctorDoorCoachOrderService {
        BasePatientDO patient = patientInfoService.findById(one.getPatient());
        // 获取微信模板 smfwdwk-上门服务待付款
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {//·
        try {
            JSONObject json = new JSONObject();
            String finish="";
            json.put("id",orderId);
@ -615,7 +615,7 @@ public class DoctorDoorCoachOrderService {
            List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
            String openId = basePatientWechatDos.get(0).getOpenid();
            String first="key1预约上门预约医生已完成服务。".replace("key1", DateUtil.dateToStrLong(new Date()));
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwyspf",openId,first,null,null,31,json,DateUtil.dateToChineseDate(new Date()),"服务医生评分");
//            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwyspf",openId,first,null,null,31,json,DateUtil.dateToChineseDate(new Date()),"服务医生评分","待评价");
        }catch (Exception e){
            logger.error(e.getMessage());
@ -634,8 +634,12 @@ public class DoctorDoorCoachOrderService {
     */
    public String getOrderIdByDoctor(String doctor) {
        String sql = "SELECT id as orderId from base_door_coach_order where doctor=? and status in(2,3,4,5,6) ORDER BY patient_expected_serve_time desc,update_time desc,create_time desc, status ASC limit 1";
        String orderId = jdbcTemplate.queryForObject(sql, String.class, new Object[]{doctor});
        return orderId;
        List<String> orderId = jdbcTemplate.queryForList(sql, String.class, new Object[]{doctor});
        if (orderId.size()>0){
            return orderId.get(0);
        }
        return null;
    }
    /**

+ 7 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java

@ -348,8 +348,11 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
     */
    public String getOrderIdByPatient(String patient) {
        String sql = "SELECT id as orderId from base_door_coach_order where patient=? and status in(1,2,3,4,5,6) ORDER BY patient_expected_serve_time desc,update_time desc,create_time desc, status ASC limit 1";
        String orderId = jdbcTemplate.queryForObject(sql, String.class, new Object[]{patient});
        return orderId;
        List<String> orderId = jdbcTemplate.queryForList(sql, String.class, new Object[]{patient});
        if (orderId.size()>0){
            return orderId.get(0);
        }
        return null;
    }
    public List<Map<String,Object>> selectItemsByHospital(String hospital,String serverItemName){
@ -808,6 +811,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                return result;
            }
        }
        orderDO.setStatus(BaseDoorCoachOrderDO.Status.cancel.getType());
        this.save(orderDO);
        if(type == BaseDoorCoachOrderDO.CancelType.dispatcher.getType()){
@ -850,7 +854,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
        if (basePatientWechatDos.size()>0){
            String openId = basePatientWechatDos.get(0).getOpenid();
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",openId,first,null,null,30,json, DateUtil.dateToChineseDate(new Date()),"上门预约已取消");
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",openId,first,null,null,30,json, DateUtil.dateToChineseDate(new Date()),"上门预约已取消","已取消");
        }

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -154,6 +154,8 @@ public class MessageUtil {
    }
    public String sendTXYSJson(String templateCode,String mobile,String ...params)throws Exception{
        //974597 未回复消息通知 短信内容 -- {1}您好,您的云照护平台有{2}条信息未回复,请及时处理。
        //974603 上门辅导通知 您有一条新的上门辅导申请,请进入调度平台处理。
        JSONObject sendObj = new JSONObject();
        sendObj.put("templateCode",templateCode);
        if (params.length>0){

+ 31 - 8
svr/svr-cloud-job/src/main/java/com.yihu/jw.care/event/ApplicationEvent.java

@ -1,6 +1,10 @@
package com.yihu.jw.care.event;
import com.yihu.jw.care.job.QuartzHelper;
import com.yihu.jw.care.job.consult.FinishConsultJob;
import com.yihu.jw.care.job.message.DoctorSendUnreadJob;
import com.yihu.jw.care.job.message.PatientSendUnreadJob;
import com.yihu.jw.care.util.SystemConf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -8,6 +12,8 @@ import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
import java.util.HashMap;
/**
 * Created by zdm on 2017/3/10.
 */
@ -21,15 +27,32 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
    @Override
    public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {
        try {
//            //设备库存预警提醒
//            if (!quartzHelper.isExistJob("device_inventory_warning_job")) {
//                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("device_inventory_warning_job");
//                quartzHelper.addJob(InventoryWarningJob.class, trigger, "device_inventory_warning_job", new HashMap<String, Object>());
//                logger.info("device_inventory_warning_job  job success");
//            } else {
//                logger.info("device_inventory_warning_job  job exist");
//            }
           //居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
            if (!quartzHelper.isExistJob("finish_consult_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("finish_consult_job");
                quartzHelper.addJob(FinishConsultJob.class, trigger, "finish_consult_job", new HashMap<String, Object>());
                logger.info("finish_consult_job success");
            } else {
                logger.info("finish_consult_job exist");
            }
            //#每天的早上9:00,给所有医生/助老员/教师发送一条短信
            if (!quartzHelper.isExistJob("DOCTOR_SEND_UNREAD_MES_JOB")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("DOCTOR_SEND_UNREAD_MES_JOB");
                quartzHelper.addJob(DoctorSendUnreadJob.class, trigger, "DOCTOR_SEND_UNREAD_MES_JOB", new HashMap<String, Object>());
                logger.info("DOCTOR_SEND_UNREAD_MES_JOB success");
            } else {
                logger.info("DOCTOR_SEND_UNREAD_MES_JOB exist");
            }
            //#每天的早上9:00,给所有居民发送未读消息微信模板
            if (!quartzHelper.isExistJob("PATIENT_SEND_UNREAD_MES_JOB")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("PATIENT_SEND_UNREAD_MES_JOB");
                quartzHelper.addJob(PatientSendUnreadJob.class, trigger, "PATIENT_SEND_UNREAD_MES_JOB", new HashMap<String, Object>());
                logger.info("PATIENT_SEND_UNREAD_MES_JOB success");
            } else {
                logger.info("PATIENT_SEND_UNREAD_MES_JOB exist");
            }
        } catch (Exception e) {
            logger.info(" job start failed");

+ 96 - 0
svr/svr-cloud-job/src/main/java/com.yihu/jw.care/job/consult/FinishConsultJob.java

@ -0,0 +1,96 @@
package com.yihu.jw.care.job.consult;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.util.http.HttpUtils;
import com.yihu.jw.util.http.HttpClientUtil;
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("${cloudServer.server_url}")
    private String server_url;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpUtils 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 s.type=23  AND t.end_message_id IS NULL AND s.last_content_type in(1,2,3,4,15,16,17) 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");
            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");
            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();
                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 处理医生回复后,居民进入了咨询但是没有回复的 咨询也要自动结束.....");
            sql = new StringBuffer();
            sql.append("SELECT s.id session_id,t.id topic_id, t.name topic_name ")
             .append("FROM ").append(imDb).append(".sessions s,").append(imDb).append(".wlyy_consults t ")
             .append("WHERE s.id = t.session_id AND s.type=23 AND t.end_message_id IS NULL AND t.reply=1 AND s.last_content_type =14 ")
             .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600  ");
            StringBuffer sql2 = new StringBuffer();
            sql2.append("SELECT a.id from ( ")
             .append(" SELECT * from ").append(imDb).append(".muc_messages WHERE session_id=? ORDER BY `timestamp` desc LIMIT 1,1 ")
             .append(") a, base_doctor d WHERE a.sender_id=d.id ");
            //查找超过24小时,且最后一条消息是居民进入系统的会话id
            List<Map<String,Object>> sessionIdList = jdbcTemplate.queryForList(sql.toString());
            sessionIdList.stream().forEach(one->{
                String sessionId = one.get("session_id").toString();
                String topicId = one.get("topic_id").toString();
                String topicName = one.get("topic_name").toString();
                List<Map<String,Object>> temp = jdbcTemplate.queryForList(sql2.toString(),sessionId);
                if(temp!=null&&temp.size()>=0){
                    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());
        }
    }
}

+ 59 - 0
svr/svr-cloud-job/src/main/java/com.yihu/jw.care/job/message/DoctorSendUnreadJob.java

@ -0,0 +1,59 @@
package com.yihu.jw.care.job.message;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.care.util.http.HttpUtils;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.common.MobileUtils;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
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 java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/5/29.
 */
public class DoctorSendUnreadJob implements Job {
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private MessageUtil messageUtil;
    private static Logger logger = LoggerFactory.getLogger(DoctorSendUnreadJob.class);
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("DoctorSendUnreadJob start.....");
        String sql = " select id,name,mobile from base_doctor where del=1  and mobile is not null  ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:list){
            String mobile = tmp.get("mobile").toString();
            String doctorId = tmp.get("id").toString();
            if (StringUtils.isNotBlank(mobile)){
                if (MobileUtils.checkCellphone(mobile)){
                    String doctorName = tmp.get("name").toString();
                    String unReadCount = imUtil.SessionsUnreadMessageCountByUserId(doctorId)+"";
                    try {
                        messageUtil.sendTXYSJson("974597",mobile,doctorName,unReadCount);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }
        }
        logger.info("DoctorSendUnreadJob end.....");
    }
}

+ 82 - 0
svr/svr-cloud-job/src/main/java/com.yihu/jw.care/job/message/PatientSendUnreadJob.java

@ -0,0 +1,82 @@
package com.yihu.jw.care.job.message;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
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 java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/5/29.
 */
public class PatientSendUnreadJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(PatientSendUnreadJob.class);
    @Value("${wechat.id}")
    private String wxId;
    @Value("${cloudServer.server_url}")
    private String server_url;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("PatientSendUnreadJob start.....");
        String sql = "select p.id,p.name,wc.openId from base_patient p INNER JOIN base_patient_wechat wc " +
                " on p.id = wc.patient_id where p.del=1 and wc.wechat_id = '"+wxId+"' GROUP BY p.id ORDER BY wc.create_time desc  ;  ";
        List<Map<String,Object>> patientList = jdbcTemplate.queryForList(sql);
        for (Map<String,Object>tmp:patientList) {
            try {
                String patientId = tmp.get("openId").toString();
                Integer unreadCount = imUtil.SessionsUnreadMessageCountByUserId(patientId);
                String name = tmp.get("name").toString();
                String openId = tmp.get("openId").toString();
                if (StringUtils.isNotBlank(patientId)) {
                    sql = "select t2.id from base_patient_family_member t1,base_patient t2 " +
                            " where t2.id in (select family_member from base_patient_family_member where patient = '" + patientId + "' ) " +
                            " and t1.patient = '" + patientId + "' and t1.family_member = t2.id ";
                    List<String> familys = jdbcTemplate.queryForList(sql, String.class);
                    for (String family : familys) {
                        if (patientId.equals(family)) {
                            continue;
                        }
                        unreadCount += imUtil.SessionsUnreadMessageCountByUserId(family);
                    }
                }
                if (unreadCount > 0) {//发送模板
                    String first = ""+name+"您好,您与您的家庭成员共有"+unreadCount+"条消息未回复,请及时处理";
                    String url = server_url + "wxpush/sendPatientUnreadWXTemplate";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("openid", openId));
                    params.add(new BasicNameValuePair("first", first));
                    params.add(new BasicNameValuePair("templateName", "template_process_feedback"));
                    params.add(new BasicNameValuePair("scene", "jobfsjmwd"));
                    httpClientUtil.post(url,params,"UTF-8");
                }
            } catch (Exception e) {
            }
        }
        logger.info("PatientSendUnreadJob end.....");
    }
}

+ 36 - 0
svr/svr-cloud-job/src/main/java/com.yihu/jw.care/util/MessageUtil.java

@ -0,0 +1,36 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.sms.service.TXYSmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
 * Created by Bing on 2021/5/29.
 */
@Component
public class MessageUtil {
    @Autowired
    private TXYSmsService txySmsService;
    private static Logger logger = LoggerFactory.getLogger(MessageUtil.class);
    public String sendTXYSJson(String templateCode,String mobile,String ...params)throws Exception{
        JSONObject sendObj = new JSONObject();
        sendObj.put("templateCode",templateCode);
        if (params.length>0){
            JSONArray paramArr =JSONArray.parseArray(JSON.toJSONString(params));
            sendObj.put("templateParamArr",paramArr);
        }else {
            JSONArray paramArr =new JSONArray();
            sendObj.put("templateParamArr",paramArr);
        }
        return txySmsService.sendMessageJson(mobile,sendObj.toJSONString());
    }
}

+ 45 - 0
svr/svr-cloud-job/src/main/java/com.yihu/jw.care/util/http/HttpUtils.java

@ -19,6 +19,8 @@ import org.springframework.util.StringUtils;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -379,4 +381,47 @@ public class HttpUtils {
        return stringBuilder.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;
    }
}

+ 6 - 2
svr/svr-cloud-job/src/main/resources/application.yml

@ -54,6 +54,8 @@ FileTempPath:
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat
cloudServer:
  server_url: http://172.26.0.107:10301/
---
spring:
  profiles: jwtest
@ -81,7 +83,8 @@ fastDFS:
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
cloudServer:
  server_url: http://172.26.0.107:10301/
---
spring:
  profiles: jwprod
@ -110,6 +113,7 @@ wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
cloudServer:
  server_url: http://172.26.0.12:10301/

+ 6 - 22
svr/svr-cloud-job/src/main/resources/system.properties

@ -1,25 +1,9 @@
#-------------------------中山医院-----------------------------#
# 健康频道状态
prescriptionStatus_update_job=0 */2 * * * ?
# 门诊记录过期job,每天1 点触发
prescription_overdue_job=0 0 1 * * ?
#居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
finish_consult_job=0 59 * * * ?
#每天13 点触发
data_upload_job=0 0 2 * * ?
#每天的早上9:00,给所有医生/助老员/教师发送一条短信
DOCTOR_SEND_UNREAD_MES_JOB=0 0 9 * * ?
#-------------------------中山医院end-----------------------------#
#-------------------------眼科医院-----------------------------#
data_ykupload_job=0 0 0 * * ?
#每间隔1分钟触发
unsettled_prescription_notice_job=0 */1 * * * ?
#-------------------------眼科医院end-----------------------------#
#-------------------------监管平台通用医院-----------------------------#
data_common_upload_job=0 0 0 * * ?
#------------------------物联网后台系统---------------------------#
#设备质检时间 每天24 点触发
data_device_quality_plan_job=0 0 0 * * ?
#SIM卡每月套餐扣费  每月1号凌晨0点0分0秒扣费
data_sim_set_meal_job=0 0 0 1 * ?
#设备库存预警提醒时间
device_inventory_warning_job = 0 0 7 * * ?
#每天的早上9:00,给所有居民发送未读消息微信模板
PATIENT_SEND_UNREAD_MES_JOB=0 0 9 * * ?