Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	common/common-entity/sql记录
yeshijie 3 years ago
parent
commit
8e43c8a901

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

@ -1,5 +1,6 @@
package com.yihu.jw.care.event;
import com.yihu.jw.care.job.BirthdayReminderJob;
import com.yihu.jw.care.job.QuartzHelper;
import com.yihu.jw.care.job.consult.FinishConsultJob;
import com.yihu.jw.care.job.device.PatientSosContactsJob;
@ -56,6 +57,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("PATIENT_SEND_UNREAD_MES_JOB exist");
            }
            //#每天的早上9:00,生日祝福提醒短信
            if (!quartzHelper.isExistJob("BIRTHDAY_REMINDER_JOB")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("BIRTHDAY_REMINDER_JOB");
                quartzHelper.addJob(BirthdayReminderJob.class, trigger, "BIRTHDAY_REMINDER_JOB", new HashMap<String, Object>());
                logger.info("BIRTHDAY_REMINDER_JOB success");
            } else {
                logger.info("BIRTHDAY_REMINDER_JOB exist");
            }
            //#取消订单支付超时的订单,每3分钟执行一次
            if (!quartzHelper.isExistJob("CANCEL_PAY_ORDER_OVERTIME_JOB")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("CANCEL_PAY_ORDER_OVERTIME_JOB");

+ 31 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/BirthdayReminderJob.java

@ -0,0 +1,31 @@
package com.yihu.jw.care.job;
import com.yihu.jw.care.service.BirthdayReminderService;
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;
/**
 * Created by ysj on 2021.08.30
 */
public class BirthdayReminderJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(BirthdayReminderJob.class);
    @Autowired
    private BirthdayReminderService birthdayReminderService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========每天发送生日提醒JOB========");
        try {
            birthdayReminderService.sendMessage();
            logger.info("END========每天发送生日提醒JOB========");
        }catch (Exception e){
            e.printStackTrace();
            logger.info("END===ERROE===每天发送生日提醒JOB,message:"+e.getMessage());
        }
    }
}

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

@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map;
/**
 * 未回复消息提醒
 * Created by Bing on 2021/5/29.
 */
public class DoctorSendUnreadJob implements Job {

+ 57 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/BirthdayReminderService.java

@ -0,0 +1,57 @@
package com.yihu.jw.care.service;
import com.yihu.jw.care.util.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/30
 * @Description:
 */
@Service
public class BirthdayReminderService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private MessageUtil messageUtil;
    public void sendMessage(){
        Date currentTime = new Date();
        SimpleDateFormat format = new SimpleDateFormat("MMdd");
        String dateString = format.format(currentTime);
        String sql = "SELECT d.id,d.name,d.mobile,COUNT(DISTINCT p.id) c " +
                " from base_service_package_sign_record sr,base_service_package_record r,  " +
                "  base_service_package_item i,base_team_member m,base_patient p ,base_doctor d " +
                "    WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "    and i.del = 1 and m.team_code = r.team_code and p.id = sr.patient and m.doctor_code = d.id " +
                "  and m.del = '1' and " +
                "CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END = '"+dateString+"' " +
                "GROUP BY d.id";
        List<Map<String, Object>> docList = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map:docList){
            try {
                String doctorName = map.get("name")+"";
                String mobile = map.get("mobile")+"";
                Integer c = Integer.valueOf(map.get("c")+"");
                if (c>0&&mobile.length()==11){
                    messageUtil.sendTXYSJson("1099809",mobile,doctorName,c+"");
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}

+ 29 - 2
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/web/JobController.java

@ -1,9 +1,11 @@
package com.yihu.jw.care.web;
import com.yihu.jw.care.job.BirthdayReminderJob;
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.service.BirthdayReminderService;
import com.yihu.jw.care.service.JobService;
import com.yihu.jw.care.util.SystemConf;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -32,6 +34,8 @@ public class JobController extends BaseController {
    private final JobService jobService;
    private final QuartzHelper quartzHelper;
    @Autowired
    private BirthdayReminderService birthdayReminderService;
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
@ -58,6 +62,22 @@ public class JobController extends BaseController {
       return success(quartzHelper.getCalendar());
    }
    @RequestMapping(value = "testJob", method = RequestMethod.GET)
    public String testJob(String taskId){
        try {
            switch(taskId){
                case "BIRTHDAY_REMINDER_JOB":
                    birthdayReminderService.sendMessage();
                    break;
                default:
                    break;
            }
            return success("成功");
        }catch (Exception e){
            error(e);
            return invalidUserException(e, -1, "执行失败:" + e.getMessage());
        }
    }
    @RequestMapping(value = "isExist", method = RequestMethod.GET)
@ -77,7 +97,6 @@ public class JobController extends BaseController {
    @RequestMapping(value = "reStartById", method = RequestMethod.GET)
    public String reStartById(String taskId) {
        try {
            if(quartzHelper.isExistJob(taskId)){
                quartzHelper.removeJob(taskId);
            }
@ -109,7 +128,15 @@ public class JobController extends BaseController {
                        logger.info("PATIENT_SEND_UNREAD_MES_JOB exist");
                    }
                    break;
                case "BIRTHDAY_REMINDER_JOB":
                    if (!quartzHelper.isExistJob("BIRTHDAY_REMINDER_JOB")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("BIRTHDAY_REMINDER_JOB");
                        quartzHelper.addJob(BirthdayReminderJob.class, trigger, "BIRTHDAY_REMINDER_JOB", new HashMap<String, Object>());
                        logger.info("BIRTHDAY_REMINDER_JOB success");
                    } else {
                        logger.info("BIRTHDAY_REMINDER_JOB exist");
                    }
                    break;
                default :
            }
            return success("启动成功!");

+ 3 - 0
svr/svr-cloud-job/src/main/resources/system.properties

@ -8,6 +8,9 @@ DOCTOR_SEND_UNREAD_MES_JOB=0 0 9 * * ?
#每天的早上9:00,给所有居民发送未读消息微信模板
PATIENT_SEND_UNREAD_MES_JOB=0 0 9 * * ?
#每天的早上9:00,生日祝福提醒短信
BIRTHDAY_REMINDER_JOB=0 0 9 * * ?
#取消订单支付超时的订单,每3分钟执行一次
CANCEL_PAY_ORDER_OVERTIME_JOB=0 0/3 * * * ?