Просмотр исходного кода

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 8 лет назад
Родитель
Сommit
fb67d24104

+ 26 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java

@ -467,4 +467,30 @@ public class JobController extends BaseController {
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /******************************** 随访计划消息 ****************************************************/
    @ApiOperation(value = "启动随访计划消息任务")
    @RequestMapping(value = "startFollowupPlantJob", method = RequestMethod.GET)
    public String startFollowupPlantJob() {
        try {
            jobService.startFollowupPlantJob();
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    @ApiOperation(value = "停止随访计划消息任务")
    @RequestMapping(value = "stopFollowupPlantJob", method = RequestMethod.GET)
    public String stopFollowupPlantJob() {
        try {
            jobService.stopFollowupPlantJob();
            return success("停止成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 96 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/FollowupPlanJob.java

@ -0,0 +1,96 @@
package com.yihu.wlyy.statistics.job.message;
import com.yihu.wlyy.statistics.dao.MessageDao;
import com.yihu.wlyy.statistics.model.signfamily.Message;
import com.yihu.wlyy.statistics.task.PushMsgTask;
import com.yihu.wlyy.statistics.util.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import javax.transaction.Transactional;
import java.util.*;
/**
 * Created by hzp on 2017.1.4.
 */
@Component
@Scope("prototype")
public class FollowupPlanJob implements Job {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private MessageDao messageDao;
    public static String cron="0 5 0 * * ?";
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        System.out.print("follow plan message sending...");
        String date = DateUtil.dateToStrShort(new Date());
        //发送随访计划消息
        sendMessage(date);
        System.out.print("follow plan message send over.");
    }
    /**
     * 每日发送随访计划提醒消息
     */
    @Transactional
    public void sendMessage(String date)
    {
        try{
            String start = date +" 00:00:00";
            String end = date +" 23:59:59";
            String sql = "select doctor_code,count(1) count from wlyy_followup where status not in ('0','1') and followup_plan_date>='"+start+"' and followup_plan_date<='"+end+"' group by doctor_code";
            //获取所有未执行随访计划
            List<Map<String,Object>> followupToday = jdbcTemplate.queryForList(sql);
            if(followupToday!=null)
            {
                List<Message> list = new ArrayList<>();
                for(Map<String,Object> map:followupToday)
                {
                    String doctor = String.valueOf(map.get("doctor_code"));
                    String count = String.valueOf(map.get("count"));
                    // 添加签约消息
                    String title = "随访计划提醒";
                    String content = "您今日有" +count+"个随访计划待处理";
                    Message message = new Message();
                    message.setCode(UUID.randomUUID().toString());
                    message.setCzrq(new Date());
                    message.setContent(content);
                    message.setRead(1);//设置未读
                    message.setReceiver(doctor);//设置接受医生的code
                    message.setSender("system");//设置发送的用户
                    message.setTitle(title);
                    message.setType(4);//随访计划提醒
                    message.setReadonly(1);//是否只读消息
                    list.add(message);
                    // 推送消息给医生
                    PushMsgTask.getInstance().put(doctor,"4",title,content,"");
                }
                messageDao.save(list);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

+ 19 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.statistics.job.business.QuartzHelper;
import com.yihu.wlyy.statistics.job.cache.CacheCleanJob;
import com.yihu.wlyy.statistics.job.check.CheckSignJob;
import com.yihu.wlyy.statistics.job.check.ReportAllLogJob;
import com.yihu.wlyy.statistics.job.message.FollowupPlanJob;
import com.yihu.wlyy.statistics.job.message.HealthMessageJob;
import com.yihu.wlyy.statistics.job.message.NoticeJob;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
@ -475,4 +476,22 @@ public class JobService {
            throw new Exception("已经停止");
        }
    }
    /******************************* 随访计划任务 *******************************************************/
    private String followupJob = "FOLLOWUP_PLAN_JOB";
    public void startFollowupPlantJob() throws Exception {
        if (!quartzHelper.isExistJob(followupJob)) {
            quartzHelper.addJob(FollowupPlanJob.class, FollowupPlanJob.cron, followupJob, new HashMap<>());
        } else {
            throw new Exception("已经启动");
        }
    }
    public void stopFollowupPlantJob() throws Exception {
        if (quartzHelper.isExistJob(followupJob)) {
            quartzHelper.removeJob(followupJob);
        } else {
            throw new Exception("已经停止");
        }
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -659,7 +659,7 @@ public class ConsultTeamService extends ConsultService {
            if (doctorTeamMember == null) {
                doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            }
            ct.setTeam(sf.getTeamCode());
            // 设置家庭医生
            ct.setDoctor(doctorTeamMember.getMemberCode());
            ct.setAdminTeamId(sf.getAdminTeamId());

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

@ -165,7 +165,7 @@ public class SignWebService extends BaseService {
                "     and f.expenses_status = '1' " +
                "     and f.status > 0 " +
                "     and f.type = 2 " +
                "     and (b.openid is null or LENGTH(trim(ifnull(b.openid,''))) < 1)";
                "     and LENGTH(trim(ifnull(b.openid,''))) < 1";
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor},String.class);
@ -176,6 +176,8 @@ public class SignWebService extends BaseService {
            } else if(!set.containsAll(result)) {
                isAll = false;
            }
        } else {
            isAll = false;
        }
        return isAll ? 1 : 0;
@ -197,7 +199,7 @@ public class SignWebService extends BaseService {
                "     (f.doctor = ? or f.doctor_health = ?)" +
                "     and f.status > 0 " +
                "     and f.type = 2 " +
                "     and (f.expenses_status is null or LENGTH(trim(ifnull(f.expenses_status,''))) < 1)";
                "     and (f.expenses_status = 0 or LENGTH(trim(ifnull(f.expenses_status,''))) < 1)";
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor},String.class);
@ -208,6 +210,8 @@ public class SignWebService extends BaseService {
            } else if(!set.containsAll(result)) {
                isAll = false;
            }
        } else {
            isAll = false;
        }
        return isAll ? 1 : 0;

+ 7 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -1062,7 +1062,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    public String wechatFocusRemind(@RequestParam(defaultValue = "") @ApiParam(value = "居民") String patient,
                                    @RequestParam(defaultValue = "") @ApiParam(value = "是否全部(1:全部  0:非全部)") String isAll) {
        try {
            int result = 1;
            int result = 200;
            String msg = "提醒成功";
            String status = redisTemplate.opsForValue().get("wechat:focus:remind:doctor:" + getUID());
            status = StringUtils.isEmpty(status) ? "0" : status;
@ -1080,13 +1080,13 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                if (StringUtils.isEmpty(patient)) {
                    result = -1;
                    msg = "请选择需提醒的居民";
                } else {
                    JSONObject json = patientRemindService.remindPatientFocusWechat(patient, getUID());
                    result = json.getInt("status");
                    msg = json.getString("msg");
                    redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
                    redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
                }
                JSONObject json = patientRemindService.remindPatientFocusWechat(patient, getUID());
                result = json.getInt("status");
                msg = json.getString("msg");
                redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
                redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            }
            return write(result, msg);
        } catch (Exception e) {