瀏覽代碼

代码修改

yeshijie 7 年之前
父節點
當前提交
a1645297ec

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

@ -3,6 +3,7 @@ package com.yihu.wlyy.event;
import com.yihu.wlyy.job.*;
import com.yihu.wlyy.job.consult.EvaluateScoreJob;
import com.yihu.wlyy.job.consult.FinishConsultJob;
import com.yihu.wlyy.job.consult.ParticipantsCleanJob;
import com.yihu.wlyy.redis.RedisThread;
import com.yihu.wlyy.util.SystemConf;
import org.slf4j.Logger;
@ -187,6 +188,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                logger.info("patient_followup_syb_job  job exist");
            }
            //同步imgroup成员,每天凌晨3点30分执行一次
            if (!quartzHelper.isExistJob("participants_clean_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("participants_clean_job");
                quartzHelper.addJob(ParticipantsCleanJob.class, trigger, "participants_clean_job", new HashMap<String, Object>());
                logger.info("participants_clean_job  job success");
            } else {
                logger.info("participants_clean_job  job exist");
            }
    
            //居民随访信息上传基卫,每天凌晨4点执行一次
            if (!quartzHelper.isExistJob("patient_followup_upload_job")) {

+ 74 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/consult/ParticipantsCleanJob.java

@ -0,0 +1,74 @@
package com.yihu.wlyy.job.consult;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.util.ImUtill;
import org.json.JSONObject;
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;
/**
 * 每天同步一次im group团队成员
 * @author yeshijie on 2018/5/18.
 */
public class ParticipantsCleanJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(ParticipantsCleanJob.class);
    @Value("${im.data_base_name}")
    private String imDb;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ImUtill imUtill;
    @Autowired
    private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try{
            logger.info("ParticipantsCleanJob start.....");
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //查询会话列表找出type=3的group会话
            StringBuffer sql1 = new StringBuffer();
            sql1.append("SELECT s.id,name FROM ").append(imDb).append(".sessions s ").append("WHERE s.type= 3 ");
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql1.toString());
            list.stream().forEach(one->{
                String sessionId = one.get("id").toString();
                String sessionName = one.get("name").toString();
                //删除不在团队的成员
                StringBuffer sql2 = new StringBuffer();
                sql2.append("delete from ").append(imDb).append(".participants WHERE session_id = '")
                        .append(sessionId).append("' and participant_id not in (")
                        .append("SELECT doctor_code from wlyy_admin_team_member WHERE team_id = ")
                        .append(sessionId).append(" and available =1)");
                jdbcTemplate.execute(sql2.toString());
                //新增团队成员直接调用im接口
                List<Doctor> doctors = doctorAdminTeamMemberDao.findAllMembers(Long.parseLong(sessionId));
                if(doctors!=null&&doctors.size()>0){
                    JSONObject participants = new JSONObject();
                    doctors.forEach(doctor -> {
                        participants.put(doctor.getCode(),0);
                    });
                    imUtill.createSession(participants,"3",sessionName,sessionId);
                }
            });
            logger.info("ParticipantsCleanJob end.....");
        }catch (Exception e){
            e.printStackTrace();
            logger.error("ParticipantsCleanJob error....."+e.getMessage());
        }
    }
}

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

@ -1,16 +1,12 @@
package com.yihu.wlyy.web.quota;
import com.yihu.wlyy.job.*;
import com.yihu.wlyy.job.consult.ConsultCleanerJob;
import com.yihu.wlyy.job.consult.EvaluateScoreJob;
import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
import com.yihu.wlyy.job.consult.FinishConsultJob;
import com.yihu.wlyy.job.consult.*;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.service.quota.JobService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -430,6 +426,25 @@ public class JobController extends BaseController {
        }
    }
    /**
     * 每天同步一次im group团队成员
     * @author ysj
     * @date 2018/5/18 14:16
     */
    @RequestMapping(value = "/executeParticipantsCleanJob", method = RequestMethod.POST)
    @ApiOperation("每天同步一次im group团队成员")
    public String executeParticipantsCleanJob() {
        try {
            quartzHelper.startNow(ParticipantsCleanJob.class, UUID.randomUUID().toString(), null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**
     * 产检提醒
     * @author ysj

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

@ -104,6 +104,9 @@ doctor_feldsher_template_job=0 */30 * * * ?
# 病患者定标情况同步JOB (每天2点一次)
patient_disease_contion_syn_job=0 0 2 * * ?
# 同步im group成员JOB (每天3点30一次)
participants_clean_job=0 30 3 * * ?
#查询家庭签约支付结果,补更新医保签约号,3分钟跑一次
sign_family_pay_result_migisterno_job=0 0/3 * * * ?