Forráskód Böngészése

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida 8 éve
szülő
commit
85c5fdffb5
19 módosított fájl, 987 hozzáadás és 65 törlés
  1. 6 6
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/config/war/ServletInitializer.java
  2. 16 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java
  3. 23 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorWorkTimeDao.java
  4. 40 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorWorkWeekDao.java
  5. 17 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/NoticeDao.java
  6. 14 15
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/check/ReportAllLogJob.java
  7. 149 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/NoticeJob.java
  8. 116 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/doctor/WlyyDoctorWorkTime.java
  9. 70 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/doctor/WlyyDoctorWorkWeek.java
  10. 90 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/message/Notice.java
  11. 306 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/DoctorWorkTimeService.java
  12. 17 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  13. 2 5
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/util/IdCardUtil.java
  14. 9 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java
  15. 4 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorTeamMemberDao.java
  16. 22 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/DrHealthTeamService.java
  17. 33 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java
  18. 0 31
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  19. 53 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/SignTeamController.java

+ 6 - 6
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/config/war/ServletInitializer.java

@ -7,9 +7,9 @@ import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
 * Created by Administrator on 2016.10.14.
 */
public class ServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}
//public class ServletInitializer extends SpringBootServletInitializer {
//    @Override
//    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
//        return application.sources(Application.class);
//    }
//}

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

@ -435,4 +435,20 @@ public class JobController extends BaseController {
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 启动通知任务
     *
     * @return
     */
    @ApiOperation(value = "启动通知任务")
    @RequestMapping(value = "startNoticeJob", method = RequestMethod.GET)
    public String startNoticeJob() {
        try {
            jobService.startNoticeJob();
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 23 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorWorkTimeDao.java

@ -0,0 +1,23 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.doctor.WlyyDoctorWorkTime;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by lyr on 2016/08/19.
 */
public interface DoctorWorkTimeDao extends PagingAndSortingRepository<WlyyDoctorWorkTime, Long>, JpaSpecificationExecutor<WlyyDoctorWorkTime> {
    /**
     * 查询医生工作时间
     *
     * @param doctor
     * @return
     */
    @Query("select a from WlyyDoctorWorkTime a where a.doctor = ?1")
    WlyyDoctorWorkTime findDoctorWorkTime(String doctor);
}

+ 40 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorWorkWeekDao.java

@ -0,0 +1,40 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.doctor.WlyyDoctorWorkWeek;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/08/19.
 */
public interface DoctorWorkWeekDao extends PagingAndSortingRepository<WlyyDoctorWorkWeek, Long>, JpaSpecificationExecutor<WlyyDoctorWorkWeek> {
    /**
     * 查询医生排班列表
     *
     * @param doctor
     * @return
     */
    @Query("select a from WlyyDoctorWorkWeek a where a.doctor = ?1")
    List<WlyyDoctorWorkWeek> findDoctorWorkWeeks(String doctor);
    /**
     * 查询医生某天排班信息
     *
     * @param doctor
     * @param week
     * @return
     */
    @Query("select a from WlyyDoctorWorkWeek a where a.doctor = ?1 and a.week = ?2")
    WlyyDoctorWorkWeek findDoctorWorkWeek(String doctor, String week);
    /**
     * 删除医生的排班信息
     *
     * @param doctor
     */
    void deleteByDoctor(String doctor);
}

+ 17 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/NoticeDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.message.Notice;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2016/11/7.
 */
public interface NoticeDao extends PagingAndSortingRepository<Notice, Long>, JpaSpecificationExecutor<Notice> {
    @Query("select p from Notice p where p.toType=1 and p.status=1")
    List<Notice> findAllDoctorNoRead();
}

+ 14 - 15
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/check/ReportAllLogJob.java

@ -116,36 +116,35 @@ public class ReportAllLogJob implements Job {
            //系统患者总共登录成功的次数
            sqlCount= " select count(id) from wlyy_login_log where type=1 and user_type=1 ";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>截止到"+date+" 患者总共登录成功次数</td><td>"+count+"个</td></tr>");
            sb.append("<tr><td>截止到"+date+" 患者总共登录成功次数</td><td>"+count+"次</td></tr>");
            //系统患者总共登录失败的次数
            sqlCount= " select count(id) from wlyy_login_log where type=2 and user_type=1 ";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>截止到"+date+" 患者总共登录失败次数</td><td>"+count+"个</td></tr>");
            //系统患者昨天登录成功的次数
            sqlCount= " select count(id) from wlyy_login_log where type=1 and user_type=1 and  create_time<= '"+getYesterday(-1)+" 23:59:59 ' and  create_time>= '"+getYesterday(-1)+" 00:00:00 '";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>"+date+" 患者登录成功次数</td><td>"+count+"个</td></tr>");
            //系统患者昨天登录失败的次数
            sqlCount= " select count(id) from wlyy_login_log where type=2 and user_type=1 and  create_time<= '"+getYesterday(-1)+" 23:59:59 ' and  create_time>= '"+getYesterday(-1)+" 00:00:00 '";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>"+date+" 患者登录失败次数</td><td>"+count+"个</td></tr>");
            sb.append("<tr><td>截止到"+date+" 患者总共登录失败次数</td><td>"+count+"次</td></tr>");
            //系统医生总共登录成功的次数
            sqlCount= " select count(id) from wlyy_login_log where type=1 and user_type=2 ";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>截止到"+date+" 医生总共登录成功次数</td><td>"+count+"个</td></tr>");
            sb.append("<tr><td>截止到"+date+" 医生总共登录成功次数</td><td>"+count+"次</td></tr>");
            //系统医生总共登录失败的次数
            sqlCount= " select count(id) from wlyy_login_log where type=2 and user_type=2 ";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>截止到"+date+" 医生总共登录失败次数</td><td>"+count+"个</td></tr>");
            sb.append("<tr><td>截止到"+date+" 医生总共登录失败次数</td><td>"+count+"次</td></tr>");
            //系统患者昨天登录成功的次数
            sqlCount= " select count(id) from wlyy_login_log where type=1 and user_type=1 and  create_time<= '"+getYesterday(-1)+" 23:59:59 ' and  create_time>= '"+getYesterday(-1)+" 00:00:00 '";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>"+date+" 患者登录成功次数</td><td>"+count+"次</td></tr>");
            //系统患者昨天登录失败的次数
            sqlCount= " select count(id) from wlyy_login_log where type=2 and user_type=1 and  create_time<= '"+getYesterday(-1)+" 23:59:59 ' and  create_time>= '"+getYesterday(-1)+" 00:00:00 '";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>"+date+" 患者登录失败次数</td><td>"+count+"次</td></tr>");
            //系统医生昨天登录成功的次数
            sqlCount= " select count(id) from wlyy_login_log where type=1 and user_type=2 and  create_time<= '"+getYesterday(-1)+" 23:59:59 ' and  create_time>= '"+getYesterday(-1)+" 00:00:00 '";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>"+date+" 医生登录成功次数</td><td>"+count+"个</td></tr>");
            sb.append("<tr><td>"+date+" 医生登录成功次数</td><td>"+count+"次</td></tr>");
            //系统医生昨天登录失败的次数
            sqlCount= " select count(id) from wlyy_login_log where type=2 and user_type=2 and  create_time<= '"+getYesterday(-1)+" 23:59:59 ' and  create_time>= '"+getYesterday(-1)+" 00:00:00 '";
            count=jdbcTemplate.queryForObject(sqlCount,Integer.class);
            sb.append("<tr><td>"+date+" 医生登录失败次数</td><td>"+count+"个</td></tr>");
            sb.append("<tr><td>"+date+" 医生登录失败次数</td><td>"+count+"次</td></tr>");
            //今天实时统计执行的次数
            sqlCount= " select count(a.id) from wlyy_job_log a where a.job_id=11 and a.job_start_time>= '"+getYesterday(-1)+ " 00:00:00'and a.job_start_time<=  '"+getYesterday(-1)+" 23:59:59 '";

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

@ -0,0 +1,149 @@
package com.yihu.wlyy.statistics.job.message;
import com.yihu.wlyy.statistics.dao.NoticeDao;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.job.business.QuartzHelper;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.message.Notice;
import com.yihu.wlyy.statistics.service.DoctorWorkTimeService;
import com.yihu.wlyy.statistics.task.PushMsgTask;
import com.yihu.wlyy.statistics.util.JsonUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
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.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2016/11/7.
 */
@Component
@Scope("prototype")
public class NoticeJob implements Job {
    public static String jobKey = "Notice_JOB";
    private static String[] noticeKey = {"no", "NO_ZX", "NO_QY", "NO_JKZD"};
    private static String[] noticeTitle = {"no", "咨询消息", "签约消息", "健康指导消息"};
    private static String[] noticeContent = {"no", "你有[SIZE]条未读的咨询消息", "你有[SIZE]条未读的签约消息", "你有[SIZE]条未读的健康指导消息"};
    @Autowired
    private NoticeDao noticeDao;
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    @Autowired
    private QuartzHelper quartzHelper;
    @Autowired
    private QuartzJobLogDao dbStorage;
    @Transactional
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //新建任务日志对象
        QuartzJobLog quartzJobLog = new QuartzJobLog();
        quartzJobLog.setJobStartTime(new Date());
        quartzJobLog.setJobId(jobKey);
        quartzJobLog.setJobName(jobKey);
        try {
            Date nextStartTime = null;
            //得到所有未发送的医生的通知
            List<Notice> noticeList = noticeDao.findAllDoctorNoRead();
            Map<String, Map<String, Integer>> maps = new HashMap<>();
            //发送通知
            for (Notice notice : noticeList) {
                //判断医生是不是在工作时间内
                if ("1".equals(doctorWorkTimeService.isDoctorWorking(notice.getToUid(), -1).get("status"))) {
                    //医生在工作时间内
                    Map<String, Integer> size = maps.get(notice.getToUid());
                    if (size == null) {
                        size = new HashMap<>();
                        size.put(notice.getType(), 1);
                    } else {
                        Integer num = size.get(notice.getType());
                        if (num == null) {
                            size.put(notice.getType(), 1);
                        } else {
                            size.put(notice.getType(), num++);
                        }
                    }
                    maps.put(notice.getToUid(), size);
                    notice.setStatus("0");
                } else {
                    //得到这个医生的下次工作时间
                    Date workTime = doctorWorkTimeService.getDoctorNextWork(notice.getToUid());
                    if(nextStartTime==null){
                        nextStartTime=workTime;
                    }
                    if (workTime.before(nextStartTime)) {
                        //如果医生的工作时间在下次工作之前,那就把医生的工作时间作为下次的执行时间
                        nextStartTime = workTime;
                    }
                }
            }
            JSONArray jsonArray = new JSONArray();
            //发送通知
            for (Map.Entry<String, Map<String, Integer>> entry : maps.entrySet()) {
                for (Map.Entry<String, Integer> entry1 : entry.getValue().entrySet()) {
                    // 异常通知
                    JSONObject json = new JSONObject();
                    json.put("receiver", entry.getKey());
                    json.put("type", noticeKey[Integer.valueOf(entry1.getKey())]);
                    json.put("title", noticeTitle[Integer.valueOf(entry1.getKey())]);
                    json.put("msg", noticeContent[Integer.valueOf(entry1.getKey())].replace("[SIZE]", entry1.getValue() + ""));
                    json.put("data", "");
                    jsonArray.add(json);
                }
            }
            // 推送消息给医生
            PushMsgTask.getInstance().put(jsonArray);
            //判断是否任务在执行
            if (noticeList.size() != 0) {
                //判断下次任务执行时间
                if (nextStartTime!=null&&nextStartTime.before(new Date())) {
                    //如果在现在之前 就立马执行
                    quartzHelper.startNow(NoticeJob.class, NoticeJob.jobKey+new Date().getTime(), new HashMap<>());
                } else {
                    //如果在现在之前 就立马执行
                    quartzHelper.startAt(nextStartTime, NoticeJob.class, NoticeJob.jobKey+nextStartTime.getTime(), new HashMap<>());
                }
            } else {
                //如果没有数据延迟半小时
                long curren = System.currentTimeMillis();
                curren += 30 * 60 * 1000;
                Date da = new Date(curren);
                quartzHelper.startAt(da, NoticeJob.class, NoticeJob.jobKey+curren, new HashMap<>());
            }
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent("通知成功");
            quartzJobLog.setJobType("1");
            dbStorage.save(quartzJobLog);
        } catch (Exception e) {
            try {
                //保存日志
                quartzJobLog.setJobEndTime(new Date());
                quartzJobLog.setJobContent("通知失败");
                quartzJobLog.setJobType("0");
                dbStorage.save(quartzJobLog);
                //如果失败的话延迟10分钟执行
                long curren = System.currentTimeMillis();
                curren += 10 * 60 * 1000;
                Date da = new Date(curren);
                quartzHelper.startAt(da, NoticeJob.class, NoticeJob.jobKey+curren, new HashMap<>());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            e.printStackTrace();
        }
    }
}

+ 116 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/doctor/WlyyDoctorWorkTime.java

@ -0,0 +1,116 @@
package com.yihu.wlyy.statistics.model.doctor;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by lyr on 2016/08/19.
 */
@Entity
@Table(name = "wlyy_doctor_work_time")
public class WlyyDoctorWorkTime extends IdEntity {
    // 医生标识
    private String doctor;
    // 医生姓名
    private String doctorName;
    // 接收咨询 0不接受 1接受
    private String receiveConsult;
    // 名医咨询次数
    private Integer famousConsultTimes;
    // 上午开始时间
    private String morningBegin;
    // 上午结束时间
    private String morningEnd;
    // 下午开始时间
    private String afternoonBegin;
    // 下午结束时间
    private String afternoonEnd;
    // 晚上开始时间
    private String nightBegin;
    // 晚上结束时间
    private String nightEnd;
    // 更新时间
    private Date czrq;
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getReceiveConsult() {
        return receiveConsult;
    }
    public void setReceiveConsult(String receiveConsult) {
        this.receiveConsult = receiveConsult;
    }
    public Integer getFamousConsultTimes() {
        return famousConsultTimes;
    }
    public void setFamousConsultTimes(Integer famousConsultTimes) {
        this.famousConsultTimes = famousConsultTimes;
    }
    public String getMorningBegin() {
        return morningBegin;
    }
    public void setMorningBegin(String morningBegin) {
        this.morningBegin = morningBegin;
    }
    public String getMorningEnd() {
        return morningEnd;
    }
    public void setMorningEnd(String morningEnd) {
        this.morningEnd = morningEnd;
    }
    public String getAfternoonBegin() {
        return afternoonBegin;
    }
    public void setAfternoonBegin(String afternoonBegin) {
        this.afternoonBegin = afternoonBegin;
    }
    public String getAfternoonEnd() {
        return afternoonEnd;
    }
    public void setAfternoonEnd(String afternoonEnd) {
        this.afternoonEnd = afternoonEnd;
    }
    public String getNightBegin() {
        return nightBegin;
    }
    public void setNightBegin(String nightBegin) {
        this.nightBegin = nightBegin;
    }
    public String getNightEnd() {
        return nightEnd;
    }
    public void setNightEnd(String nightEnd) {
        this.nightEnd = nightEnd;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 70 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/doctor/WlyyDoctorWorkWeek.java

@ -0,0 +1,70 @@
package com.yihu.wlyy.statistics.model.doctor;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Entity;
import java.util.Date;
/**
 * Created by lyr on 2016/08/19.
 */
@Entity
public class WlyyDoctorWorkWeek extends IdEntity {
    private String doctor;
    private String doctorName;
    private String week;
    private String morning;
    private String afternoon;
    private String night;
    private Date czrq;
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getWeek() {
        return week;
    }
    public void setWeek(String week) {
        this.week = week;
    }
    public String getMorning() {
        return morning;
    }
    public void setMorning(String morning) {
        this.morning = morning;
    }
    public String getAfternoon() {
        return afternoon;
    }
    public void setAfternoon(String afternoon) {
        this.afternoon = afternoon;
    }
    public String getNight() {
        return night;
    }
    public void setNight(String night) {
        this.night = night;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 90 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/message/Notice.java

@ -0,0 +1,90 @@
package com.yihu.wlyy.statistics.model.message;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2016/11/7.
 * 系通通知
 */
@Entity
@Table(name = "wlyy_notice")
public class Notice extends IdEntity {
    private String toUid;//接受人code
    private String content;//通知内容
    private String title;//消息标题
    private String data;//消息数据
    private String type;//通知类型 1咨询 2签约 3健康指导
    private Date createTime;//创建时间
    private String status;//是否发送 1 否 0是
    private String toType;//接受人类型 1:医生 2患者
    public String getToUid() {
        return toUid;
    }
    public void setToUid(String toUid) {
        this.toUid = toUid;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getData() {
        return data;
    }
    public void setData(String data) {
        this.data = data;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getToType() {
        return toType;
    }
    public void setToType(String toType) {
        this.toType = toType;
    }
}

+ 306 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/DoctorWorkTimeService.java

@ -0,0 +1,306 @@
package com.yihu.wlyy.statistics.service;
import com.yihu.wlyy.statistics.dao.DoctorDao;
import com.yihu.wlyy.statistics.dao.DoctorWorkTimeDao;
import com.yihu.wlyy.statistics.dao.DoctorWorkWeekDao;
import com.yihu.wlyy.statistics.model.doctor.Doctor;
import com.yihu.wlyy.statistics.model.doctor.WlyyDoctorWorkTime;
import com.yihu.wlyy.statistics.model.doctor.WlyyDoctorWorkWeek;
import com.yihu.wlyy.statistics.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 医生工作排班
 * <p>
 * Created by lyr on 2016/08/19.
 */
@Service
@Transactional
public class DoctorWorkTimeService {
    static Object obj = new Object();
    @Autowired
    private DoctorWorkTimeDao doctorWorkTimeDao;
    @Autowired
    private DoctorWorkWeekDao doctorWorkWeekDao;
    @Autowired
    private DoctorDao doctorDao;
    /**
     * 查询医生某天工作时间
     *
     * @param doctor 医生标识
     * @param week   某天
     * @return
     */
    public JSONObject findDoctorWeekWorkTime(String doctor, String week) throws Exception {
        JSONObject result = new JSONObject();
        WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        WlyyDoctorWorkWeek workWeek = doctorWorkWeekDao.findDoctorWorkWeek(doctor, week);
        result.put("workTime", workTime != null ? new JSONObject(workTime) : "");
        result.put("workWeek", workWeek != null ? new JSONObject(workWeek) : "");
        return result;
    }
    /**
     * 查询医生某天工作时间
     *
     * @param doctor 医生标识
     * @param week   某天
     * @return
     */
    public Map<String, Object> findDoctorWeekWork(String doctor, String week) throws Exception {
        Map<String, Object> map = new HashMap<>();
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
            throw new Exception("doctor-worktime-error:doctor not exist");
        }
        WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        WlyyDoctorWorkWeek workWeek = doctorWorkWeekDao.findDoctorWorkWeek(doctor, week);
        map.put("workTime", workTime);
        map.put("workWeek", workWeek);
        return map;
    }
    /**
     * 医生是否在工作
     *
     * @param doctor 医生
     * @return
     */
    public JSONObject isDoctorWorking(String doctor, Integer week) throws Exception {
        JSONObject json = new JSONObject();
        Calendar calendar = Calendar.getInstance();
        if (week < 0) {
            week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
            if (week == 0) {
                week = 7;
            }
        }
        // 医生工作时间设置
        Map<String, Object> result = findDoctorWeekWork(doctor, String.valueOf(week));
        if (result.get("workTime") == null) {
            // 医生未设置时,默认7*24小时工作
            json.put("status", "1");
            json.put("msg", "医生当前接受咨询");
        } else {
            WlyyDoctorWorkTime doctorWorkTime = (WlyyDoctorWorkTime) result.get("workTime");
            if (doctorWorkTime.getReceiveConsult().equals("0")) {
                // 医生设置不接受咨询
                json.put("status", "0");
                json.put("msg", "医生不接受咨询");
            } else {
                if (StringUtils.isEmpty(doctorWorkTime.getMorningBegin()) && StringUtils.isEmpty(doctorWorkTime.getMorningEnd())
                        && StringUtils.isEmpty(doctorWorkTime.getAfternoonBegin()) && StringUtils.isEmpty(doctorWorkTime.getAfternoonEnd())
                        && StringUtils.isEmpty(doctorWorkTime.getNightBegin()) && StringUtils.isEmpty(doctorWorkTime.getNightEnd())) {
                    // 医生未设置工作时间,默认7*24小时工作
                    json.put("status", "1");
                    json.put("msg", "医生当前接受咨询");
                } else {
                    if (result.get("workWeek") != null) {
                        // 当前工作日已设置工作时间
                        int flag = 0;
                        WlyyDoctorWorkTime workTime = (WlyyDoctorWorkTime) result.get("workTime");
                        WlyyDoctorWorkWeek workWeek = (WlyyDoctorWorkWeek) result.get("workWeek");
                        int hour = calendar.get(Calendar.HOUR_OF_DAY);
                        int minute = calendar.get(Calendar.MINUTE);
                        String current = (hour < 10 ? ("0" + hour) : hour) + ":" + (hour < 10 ? ("0" + minute) : minute);
                        // 早上
                        if (workWeek.getMorning().equals("1")) {
                            String currentStart = workTime.getMorningBegin();
                            String currentEnd = workTime.getMorningEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                                flag = 1;
                            }
                        }
                        // 下午
                        if (workWeek.getAfternoon().equals("1")) {
                            String currentStart = workTime.getAfternoonBegin();
                            String currentEnd = workTime.getAfternoonEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                                flag = 1;
                            }
                        }
                        // 晚上
                        if (workWeek.getNight().equals("1")) {
                            String currentStart = workTime.getNightBegin();
                            String currentEnd = workTime.getNightEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                                flag = 1;
                            }
                        }
                        if (flag == 1) {
                            json.put("status", "1");
                            json.put("msg", "医生当前接受咨询");
                        } else {
                            json.put("status", "2");
                            json.put("msg", "医生当前不在工作时间");
                        }
                    } else {
                        json.put("status", "2");
                        json.put("msg", "医生当前不在工作时间");
                    }
                }
            }
        }
        return json;
    }
    public Date getDoctorWeek(String doctor, Integer week) throws Exception {
        Date json = new Date();
        Calendar calendar = Calendar.getInstance();
        // 医生工作时间设置
        Map<String, Object> result = findDoctorWeekWork(doctor, String.valueOf(week));
        if (result.get("workTime") == null) {
            // 医生未设置时,默认7*24小时工作
            return json;
        } else {
            WlyyDoctorWorkTime doctorWorkTime = (WlyyDoctorWorkTime) result.get("workTime");
            if (doctorWorkTime.getReceiveConsult().equals("0")) {
                return null;
            } else {
                if (StringUtils.isEmpty(doctorWorkTime.getMorningBegin()) && StringUtils.isEmpty(doctorWorkTime.getMorningEnd())
                        && StringUtils.isEmpty(doctorWorkTime.getAfternoonBegin()) && StringUtils.isEmpty(doctorWorkTime.getAfternoonEnd())
                        && StringUtils.isEmpty(doctorWorkTime.getNightBegin()) && StringUtils.isEmpty(doctorWorkTime.getNightEnd())) {
                    // 医生未设置工作时间,默认7*24小时工作
                    return json;
                } else {
                    if (result.get("workWeek") != null) {
                        // 当前工作日已设置工作时间
                        int flag = 0;
                        WlyyDoctorWorkTime workTime = (WlyyDoctorWorkTime) result.get("workTime");
                        WlyyDoctorWorkWeek workWeek = (WlyyDoctorWorkWeek) result.get("workWeek");
                        int hour = calendar.get(Calendar.HOUR_OF_DAY);
                        int minute = calendar.get(Calendar.MINUTE);
                        String current = (hour < 10 ? ("0" + hour) : hour) + ":" + (hour < 10 ? ("0" + minute) : minute);
                        // 早上
                        if (workWeek.getMorning().equals("1")) {
                            String currentStart = workTime.getMorningBegin();
                            String currentEnd = workTime.getMorningEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                               String preDate= DateUtil.dateToStr(json,"yyyy-MM-dd");
                               preDate=preDate+" "+currentStart;
                                return DateUtil.strToDate(preDate,"yyyy-MM-dd HH:mm");
                            }
                        }
                        // 下午
                        if (workWeek.getAfternoon().equals("1")) {
                            String currentStart = workTime.getAfternoonBegin();
                            String currentEnd = workTime.getAfternoonEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                                String preDate= DateUtil.dateToStr(json,"yyyy-MM-dd");
                                preDate=preDate+" "+currentStart;
                                return DateUtil.strToDate(preDate,"yyyy-MM-dd HH:mm");
                            }
                        }
                        // 晚上
                        if (workWeek.getNight().equals("1")) {
                            String currentStart = workTime.getNightBegin();
                            String currentEnd = workTime.getNightEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                                String preDate= DateUtil.dateToStr(json,"yyyy-MM-dd");
                                preDate=preDate+" "+currentStart;
                                return DateUtil.strToDate(preDate,"yyyy-MM-dd HH:mm");
                            }
                        }
                    } else {
                        return null;
                    }
                }
            }
        }
        return null;
    }
    /**
     * 得到医生的下次工作时间
     *
     * @param doctor
     * @return
     * @throws Exception
     */
    public Date getDoctorNextWork(String doctor) throws Exception {
        Calendar calendar = Calendar.getInstance();
        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
        if (week == 0) {
            week = 7;
        }
        //得到今天的是否有工作
        Date date=getDoctorWeek(doctor,week);
        if(date==null){
            //如果工作时间遍历得到最新的一天的时间
            for(int i=1;i<8;i++){
                int weekTemp=(i+week)%7;
                if(weekTemp==0){
                    weekTemp=7;
                }
                date=getDoctorWeek(doctor,weekTemp);
            }
        }
        return date;
    }
}

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

@ -11,6 +11,7 @@ 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.HealthMessageJob;
import com.yihu.wlyy.statistics.job.message.NoticeJob;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
import com.yihu.wlyy.statistics.model.job.QuartzJobConfig;
import com.yihu.wlyy.statistics.model.job.WlyyQuota;
@ -455,4 +456,20 @@ public class JobService {
            throw new Exception("已经停止");
        }
    }
    public void startNoticeJob() throws Exception {
        if(!quartzHelper.isExistJob(NoticeJob.jobKey)){
            quartzHelper.startNow(NoticeJob.class,NoticeJob.jobKey,new HashMap<>());
        }else{
            throw new Exception("已经启动");
        }
    }
    public void stopNoticeJob()throws Exception  {
        if(quartzHelper.isExistJob(NoticeJob.jobKey)){
            quartzHelper.removeJob(NoticeJob.jobKey);
        }else{
            throw new Exception("已经停止");
        }
    }
}

+ 2 - 5
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/util/IdCardUtil.java

@ -95,7 +95,6 @@ public class IdCardUtil {
     */
    public static int getAgeForIdcard(String idcard) {
        int age = 0;
        try{
        if (StringUtils.isEmpty(idcard)) {
            return age;
@ -115,12 +114,10 @@ public class IdCardUtil {
        Calendar cal = Calendar.getInstance();
        age = cal.get(Calendar.YEAR) - year;
        //周岁计算
        if (cal.get(Calendar.MONTH) > (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) > day)) {
        if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
            age--;
        }
        }catch (Exception e){
            return age;
        }
        return age;
    }

+ 9 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java

@ -61,6 +61,7 @@ public class Doctor extends IdEntity {
	private String idcard;          //身份证号
	private Integer isFamous;       //是否是名医 1是  0或者空不是
	private String isPasswordPrompt;// 是否提示密码信息 1是 0或者空是否
	private String isHelp;//是否求助
	public Doctor() {}
@ -351,6 +352,14 @@ public class Doctor extends IdEntity {
    public boolean isHealthDoctor(){
        return level == 3;
    }
	@Transient
	public String getIsHelp() {
		return isHelp;
	}
	public void setIsHelp(String isHelp) {
		this.isHelp = isHelp;
	}
	@Column(name = "is_password_prompt")
	public String getIsPasswordPrompt() {

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorTeamMemberDao.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
@ -61,4 +62,7 @@ public interface DoctorTeamMemberDao extends PagingAndSortingRepository<DoctorTe
    @Query("SELECT case when count(a) > 0 THEN true else false END FROM DoctorTeamMember a WHERE a.signType = 1 AND a" +
            ".memberCode = :memberCode")
    Boolean isSanShiSigning(@Param("memberCode") String doctorCode);
    @Query("select d FROM DoctorTeamMember a,Doctor d WHERE a.memberCode=d.code  and  a.del='1'and  a.type=1 and a.team in ( select b.team from DoctorTeamMember b where b.memberCode= ?1 and b.del='1' and b.type=2) ")
    List<Doctor> getTeamZKByQK(String qkCode);
}

+ 22 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/DrHealthTeamService.java

@ -6,12 +6,10 @@
package com.yihu.wlyy.service.app.team;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatient;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
@ -19,6 +17,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -40,7 +39,8 @@ public class DrHealthTeamService extends BaseService {
    private DoctorTeamMemberDao doctorTeamMemberDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    DoctorAdminTeamMemberDao memberDao;
    /**
     * 查询签约团队的其他医生
     *
@ -256,4 +256,21 @@ public class DrHealthTeamService extends BaseService {
            return null;
        }
    }
    public Map<String,List<Doctor>> getTeamDoctorsAndAdminTeamDoctors(String doctorCode,Long teamId) {
        Map<String,List<Doctor>> returnMap=new HashMap<>();
        //得到责任医生
        List<Doctor> zrDoctors=  doctorTeamMemberDao.getTeamZKByQK(doctorCode);
        for(Doctor doctor:zrDoctors){
            //判断是否求助
        }
        //得到医生所在的团队的除了自己的所有人
        List<Doctor> teamDoctors= memberDao.findAllHeathExcludeThis(teamId, doctorCode);
        for(Doctor doctor:teamDoctors){
            //判断是否求助
        }
        returnMap.put("zr",zrDoctors);
        returnMap.put("team",teamDoctors);
        return returnMap;
    }
}

+ 33 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java

@ -1,8 +1,7 @@
package com.yihu.wlyy.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.lang.reflect.Field;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
@ -16,6 +15,7 @@ import org.springframework.data.domain.Page;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.IdEntity;
import org.springframework.util.ReflectionUtils;
public class BaseController {
@ -480,5 +480,35 @@ public class BaseController {
			return null;
		}
	}
	public List<Map<String, Object>> copyBeans(Collection<? extends Object> beans, String...propertyNames){
		List<Map<String, Object>> result = new ArrayList<>();
		for (Object bean : beans){
			result.add(copyBeanProperties(bean, propertyNames));
		}
		return result;
	}
	/**
	 * 复制特定属性。
	 *
	 * @param bean
	 * @param propertyNames
	 * @return
	 */
	public Map<String, Object> copyBeanProperties(Object bean, String...propertyNames){
		Map<String, Object> simplifiedBean = new HashMap<>();
		for (String propertyName : propertyNames){
			Field field = ReflectionUtils.findField(bean.getClass(), propertyName);
			if (field != null){
				field.setAccessible(true);
				Object value = ReflectionUtils.getField(field, bean);
				simplifiedBean.put(propertyName, value == null ? "" : value);
			} else {
				simplifiedBean.put(propertyName, "");
			}
		}
		return simplifiedBean;
	}
}

+ 0 - 31
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -296,35 +296,4 @@ public class AdminTeamController extends BaseController {
        }
    }
    private List<Map<String, Object>> copyBeans(Collection<? extends Object> beans, String...propertyNames){
        List<Map<String, Object>> result = new ArrayList<>();
        for (Object bean : beans){
            result.add(copyBeanProperties(bean, propertyNames));
        }
        return result;
    }
    /**
     * 复制特定属性。
     *
     * @param bean
     * @param propertyNames
     * @return
     */
    private Map<String, Object> copyBeanProperties(Object bean, String...propertyNames){
        Map<String, Object> simplifiedBean = new HashMap<>();
        for (String propertyName : propertyNames){
            Field field = ReflectionUtils.findField(bean.getClass(), propertyName);
            if (field != null){
                field.setAccessible(true);
                Object value = ReflectionUtils.getField(field, bean);
                simplifiedBean.put(propertyName, value == null ? "" : value);
            } else {
                simplifiedBean.put(propertyName, "");
            }
        }
        return simplifiedBean;
    }
}

+ 53 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/SignTeamController.java

@ -1,8 +1,10 @@
package com.yihu.wlyy.web.doctor.team;
import java.util.List;
import java.util.Map;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -159,4 +161,55 @@ public class SignTeamController extends BaseController {
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    /**
     * 求助页面需要的医生查找
     * @return
     */
    @RequestMapping(value = "teamDoctorsAndAdminTeamDoctors", method = RequestMethod.GET)
    @ResponseBody
    public String getTeamDoctorsAndAdminTeamDoctors(Long teamId) {
        try {
            Map<String,List<Doctor>> doctors = drHealthTeamService.getTeamDoctorsAndAdminTeamDoctors("64de930c-5b15-11e6-8344-fa163e8aee56",teamId);
            JSONObject jo=new JSONObject();
            jo.put("zr", addDoctor(doctors.get("zr")));
            jo.put("team", addDoctor(doctors.get("team")));
            return write(200, "查询成功!", "data",jo );
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    private JSONArray addDoctor(List<Doctor> zr) {
        JSONArray array=new JSONArray();
        for (Doctor doctor : zr) {
            if (doctor == null) {
                continue;
            }
            JSONObject json = new JSONObject();
            json.put("id", doctor.getId());
            // 医生标识
            json.put("code", doctor.getCode());
            // 医生姓名
            json.put("name", doctor.getName());
            // 所在医院名称
            json.put("hospital_name", doctor.getHosptialName());
            // 科室名称
            json.put("dept_name", StringUtils.isEmpty(doctor.getDeptName()) ? " " : doctor.getDeptName());
            // 职称名称
            json.put("job_name", StringUtils.isEmpty(doctor.getJobName()) ? " " : doctor.getJobName());
            // 头像
            json.put("photo", doctor.getPhoto());
            // 简介
            json.put("introduce", doctor.getIntroduce());
            // 专长
            json.put("expertise", doctor.getExpertise());
            // 是否求出
            json.put("isHelp", doctor.getIsHelp());
            array.put(json);
        }
        return array;
    }
}