Browse Source

眼科未回复发送短信

wangzhinan 7 tháng trước cách đây
mục cha
commit
a0928b6ebe

+ 0 - 13
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -14904,20 +14904,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        ylzMedicalRelationDO.setStatus(0);
                        ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                    }
                    /*String payDateStr = object1.getString("pay_date");
                    Date payDate = DateUtil.strToDate(payDateStr);
                    Date now = DateUtil.getDateShort(new Date());
                    if (payDate.compareTo(now) == 0) {
                        BigDecimal b7 = new BigDecimal(object1.getString("enterprise_supplement"));
                        Double price = b1.add(b2).add(b3).add(b4).add(b5).add(b6).add(b7).doubleValue();
                        if (Double.parseDouble(ylzMedicalRelationDO.getMedicalPrice()) == price) {
                            ylzMedicalRelationDO.setStatus(1);
                            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        }
                    } else {
                    }
*/
                }else {
                    if (jsonObject.getString("flag").equalsIgnoreCase("50204")){
                        ylzMedicalRelationDO.setStatus(0);

+ 33 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/SendNoReplyMessageJob.java

@ -0,0 +1,33 @@
package com.yihu.jw.job;
import com.yihu.jw.service.channel.TimeoutOverDueService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Trigger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * Created by Trick on 2019/10/15.
 */
public class SendNoReplyMessageJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(SendNoReplyMessageJob.class);
    @Autowired
    private TimeoutOverDueService timeoutOverDueService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========PrescriptionOverdueJob========");
        try {
            Trigger trigger =jobExecutionContext.getTrigger();
            System.out.println("执行时间为"+trigger.getNextFireTime());
            timeoutOverDueService.sendMessageNoReply();
            logger.info("END========PrescriptionOverdueJob========");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("END===ERROE===PrescriptionOverdueJob,message:"+e.getMessage());
        }
    }
}

+ 79 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java

@ -1,5 +1,7 @@
package com.yihu.jw.service.channel;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -30,6 +32,8 @@ import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.YkyySMSService;
import oracle.sql.DATE;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -42,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Component
@Transactional
@ -97,6 +102,10 @@ public class TimeoutOverDueService {
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private YkyySMSService ykyySMSService;
    @Autowired
    private BaseDoctorDao doctorDao;
    /**
     *  取消未结束门诊
     */
@ -285,5 +294,75 @@ public class TimeoutOverDueService {
        }
    }
    /**
     *
     */
    public void sendMessageNoReply(){
        List<WlyyHospitalSysDictDO> sysDictDOList = hospitalSysDictDao.findByDictName("noReplyTime");
        String sql = "SELECT\n" ;
        if ("xm_ykyy_wx".equals(wechatId)) {
            sql = sql + "to_char(s.last_message_time,'YYYY-MM-DD hh24:mi:ss')  AS \"lastMessageTime\",";
        } else {
            sql = sql + "date_format(s.last_message_time,'%Y-%m-%d %H:%i:%S' )  AS \"lastMessageTime\",";
        }
       sql = sql+ "\ts.last_sender_id as \"lastSenderId\",\n" +
        "\ts.last_sender_name as \"lastSenderName\",\n" +
        "\to.id as \"id\"\n" +
        "FROM\n" +
        "\twlyy_outpatient o\n" +
        "LEFT JOIN wlyy_consult c ON o.id = c.relation_code\n" +
        "LEFT JOIN topics t ON t.id = c.id\n" +
        "LEFT JOIN sessions s ON s.id = t.session_id\n" +
        "where o.status>0 and o.status<3  ";
        logger.info("sql语句"+sql);
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
        logger.info("mapList"+mapList);
        if(mapList!=null&&mapList.size()>0){
            Long currentTime = DateUtil.getNowDate().getTime();
            for (Map<String,Object> map:mapList){
                String lastMessageTime = map.get("lastMessageTime").toString();
                String lastSenderId = map.get("lastSenderId").toString();
                Long lastTime = DateUtil.strToDate(lastMessageTime).getTime();
                Long time = currentTime-lastTime;
                logger.info("time"+time);
                for (int i =0;i<sysDictDOList.size();i++){
                    boolean flag = false;
                    int j = i+1;
                    WlyyHospitalSysDictDO wlyyHospitalSysDictDO = sysDictDOList.get(i);
                    Long noReplyTime = Long.parseLong(wlyyHospitalSysDictDO.getDictValue());
                    if (j>=sysDictDOList.size()){
                        flag=false;
                    }else {
                        WlyyHospitalSysDictDO wlyyHospitalSysDictDO1 = sysDictDOList.get(j);
                        Long noReplyTime1 = Long.parseLong(wlyyHospitalSysDictDO1.getDictValue());
                        logger.info("noReplyTime1"+noReplyTime1+"==="+noReplyTime);
                        if (time>noReplyTime*60*1000&&time<=noReplyTime1*60*1000){
                            flag = true;
                        }
                    }
                    if (flag){
                        BasePatientDO patientDO = basePatientDao.findById(lastSenderId);
                        BaseDoctorDO doctorDO = doctorDao.findById(lastSenderId);
                        String mobile = "";
                        if (patientDO!=null){
                            mobile = patientDO.getMobile();
                        }else if (doctorDO!=null){
                            mobile = doctorDO.getMobile();
                        }
                        logger.info("mobile"+mobile+flag+noReplyTime);
                        if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
                            ykyySMSService.ykyySendSMS(mobile,"您有新的咨询消息,请及时回复。");
                        }
                    }
                }
            }
        }
    }
}

+ 21 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -318,6 +318,17 @@ public class JobController extends BaseController {
                        logger.info("prescription_auto_delete_job  job exist");
                    }
                    break;
                case "send_noReply_job" :
                    //互联网医院 发送短信给未回复人员
                    if (!quartzHelper.isExistJob("send_noReply_job")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("send_noReply_job");
                        quartzHelper.addJob(SendNoReplyMessageJob.class, trigger, "send_noReply_job", new HashMap<String, Object>());
                        logger.info("send_noReply_job  job success");
                    } else {
                        logger.info("send_noReply_job  job exist");
                    }
                    break;
                case "data_ykupload_job_2" :
                    //互联网医院 监管平台上报
@ -1051,4 +1062,14 @@ public class JobController extends BaseController {
        return success("操作成功");
    }
    @RequestMapping(value = "/sendMessageNoReply", method = RequestMethod.GET)
    @ApiOperation("发送短信给未回复人员")
    public String sendMessageNoReply(){
        try {
            timeoutOverDueService.sendMessageNoReply();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success("操作成功");
    }
}

+ 2 - 0
svr/svr-internet-hospital-job/src/main/resources/system.properties

@ -7,6 +7,8 @@ prescription_overdue_job=0 0 2 * * ?
# 0 */1 * * * ?
prescription_auto_delete_job = 0 30 0 ? * *
send_noReply_job =0 0/15 * * * ? 
#\u6BCF\u592913 \u70B9\u89E6\u53D1
data_upload_job=0 0 2 * * ?
#\u6BCF10\u5206\u949F\u89E6\u53D1\u4E00\u6B21