Sand 9 anni fa
parent
commit
a88143536c

+ 44 - 0
src/main/java/com/yihu/wlyy/entity/doctor/DoctorFamousConsultTimesRemain.java

@ -0,0 +1,44 @@
package com.yihu.wlyy.entity.doctor;
import com.yihu.wlyy.entity.IdEntity;
import org.springframework.data.repository.cdi.Eager;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by JKZL-A on 2016/9/19.
 */
@Entity
@Table(name = "wlyy_doctor_famous_consult_times_remain")
public class DoctorFamousConsultTimesRemain extends IdEntity {
    // 医生代码
    private String doctor;
    // 咨询日期
    private String consultDate;
    // 剩余次数
    private Integer timesRemain;
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getConsultDate() {
        return consultDate;
    }
    public void setConsultDate(String consultDate) {
        this.consultDate = consultDate;
    }
    public Integer getTimesRemain() {
        return timesRemain;
    }
    public void setTimesRemain(Integer timesRemain) {
        this.timesRemain = timesRemain;
    }
}

+ 9 - 0
src/main/java/com/yihu/wlyy/entity/doctor/schedule/WlyyDoctorWorkTime.java

@ -18,6 +18,8 @@ public class WlyyDoctorWorkTime extends IdEntity {
    private String doctorName;
    private String doctorName;
    // 接收咨询 0不接受 1接受
    // 接收咨询 0不接受 1接受
    private String receiveConsult;
    private String receiveConsult;
    // 名医咨询次数
    private Integer famousConsultTimes;
    // 上午开始时间
    // 上午开始时间
    private String morningBegin;
    private String morningBegin;
    // 上午结束时间
    // 上午结束时间
@ -54,6 +56,13 @@ public class WlyyDoctorWorkTime extends IdEntity {
        this.receiveConsult = receiveConsult;
        this.receiveConsult = receiveConsult;
    }
    }
    public Integer getFamousConsultTimes() {
        return famousConsultTimes;
    }
    public void setFamousConsultTimes(Integer famousConsultTimes) {
        this.famousConsultTimes = famousConsultTimes;
    }
    public String getMorningBegin() {
    public String getMorningBegin() {
        return morningBegin;
        return morningBegin;
    }
    }

+ 8 - 0
src/main/java/com/yihu/wlyy/entity/patient/SignFamilyCode.java

@ -20,6 +20,7 @@ public class SignFamilyCode implements java.io.Serializable {
	private String orgName;
	private String orgName;
	private Integer sequence;
	private Integer sequence;
	private Date modifyTime;
	private Date modifyTime;
	private String year;
    public SignFamilyCode(){}
    public SignFamilyCode(){}
@ -83,5 +84,12 @@ public class SignFamilyCode implements java.io.Serializable {
		this.modifyTime = modifyTime;
		this.modifyTime = modifyTime;
	}
	}
	@Column(name = "year" , length = 10)
	public String getYear() {
		return year;
	}
	public void setYear(String year) {
		this.year = year;
	}
}
}

+ 8 - 0
src/main/java/com/yihu/wlyy/entity/statistics/WlyyQuota.java

@ -19,6 +19,7 @@ public class WlyyQuota implements java.io.Serializable {
	private String name;//指标名称
	private String name;//指标名称
	private String level1;//指标维度(1:机构维度)
	private String level1;//指标维度(1:机构维度)
	private String level2;//2级维度 (1:患者性别 2:患者分组 3:患者年龄)
	private String level2;//2级维度 (1:患者性别 2:患者分组 3:患者年龄)
	private String level3;//3级维度 (1:患者疾病)
	private String cycle;//统计周期( 1:天 )
	private String cycle;//统计周期( 1:天 )
	private String type;//尺度(1 新增 2是累计)
	private String type;//尺度(1 新增 2是累计)
	private Date createTime;//创建时间
	private Date createTime;//创建时间
@ -109,5 +110,12 @@ public class WlyyQuota implements java.io.Serializable {
		this.del = del;
		this.del = del;
	}
	}
	@Column(name = "level_3", length = 2)
	public String getLevel3() {
		return level3;
	}
	public void setLevel3(String level3) {
		this.level3 = level3;
	}
}
}

+ 20 - 0
src/main/java/com/yihu/wlyy/entity/statistics/WlyyQuotaResult.java

@ -24,6 +24,8 @@ public class WlyyQuotaResult implements java.io.Serializable {
    private String level1Type;//等级 1:团队 2社区机构 3区级 4市级
    private String level1Type;//等级 1:团队 2社区机构 3区级 4市级
    private String level2Type;//如果有二级维度那么这个存的是二级维度的code 例如二级维度是性别 那么这个存 1
    private String level2Type;//如果有二级维度那么这个存的是二级维度的code 例如二级维度是性别 那么这个存 1
    private String level2TypeName;//如果有二级维度那么这个存的是二级维度的code 例如二级维度是性别 那么这个存 男
    private String level2TypeName;//如果有二级维度那么这个存的是二级维度的code 例如二级维度是性别 那么这个存 男
    private String level3Type;//如果有三级维度那么这个存的是三级维度的code 例如三级维度是疾病 那么这个存 1
    private String level3TypeName;//如果有三级维度那么这个存的是三级维度的code 例如三级维度是疾病 那么这个存 高血压
    private String city;//市
    private String city;//市
    private String cityName;//市级名称
    private String cityName;//市级名称
    private String town;//区级
    private String town;//区级
@ -209,4 +211,22 @@ public class WlyyQuotaResult implements java.io.Serializable {
    public void setLevel2TypeName(String level2TypeName) {
    public void setLevel2TypeName(String level2TypeName) {
        this.level2TypeName = level2TypeName;
        this.level2TypeName = level2TypeName;
    }
    }
    @Column(name = "level3_type", length = 50)
    public String getLevel3Type() {
        return level3Type;
    }
    public void setLevel3Type(String level3Type) {
        this.level3Type = level3Type;
    }
    @Column(name = "level3_type_name", length = 50)
    public String getLevel3TypeName() {
        return level3TypeName;
    }
    public void setLevel3TypeName(String level3TypeName) {
        this.level3TypeName = level3TypeName;
    }
}
}

+ 48 - 0
src/main/java/com/yihu/wlyy/job/Constant.java

@ -43,4 +43,52 @@ public class Constant {
    public static String level_group_4_name="高血压";
    public static String level_group_4_name="高血压";
    public static String level_group_5_name="糖尿病";
    public static String level_group_5_name="糖尿病";
    public static String level_group_100_name="糖尿病和高血压";
    public static String level_group_100_name="糖尿病和高血压";
    //三级维度的疾病
    public static String level_disease_1="1";
    public static String level_disease_2="2";
    public static String level_disease_3="3";
    public static String level_disease_1_name="高血压";
    public static String level_disease_2_name="糖尿病";
    public static String level_disease_3_name="糖尿病和高血压";
    public static String getLevelAgeName(String key){
        switch (key){
            case "1":{
                return level_age_1_name;
            }
            case "2":{
                return level_age_2_name;
            }
            case "3":{
                return level_age_3_name;
            }
            case "4":{
                return level_age_4_name;
            }
            case "5":{
                return level_age_5_name;
            }
            case "6":{
                return level_age_6_name;
            }
        }
        return "";
    }
    public static String getLevelDiseaseName(String key){
        switch (key){
            case "1":{
                return level_disease_1_name;
            }
            case "2":{
                return level_disease_2_name;
            }
            case "100":{
                return level_disease_3_name;
            }
        }
        return "";
    }
}
}

+ 189 - 0
src/main/java/com/yihu/wlyy/job/CurrentDayAllQuotaJob.java

@ -118,13 +118,202 @@ public class CurrentDayAllQuotaJob implements Job {
        computequota_8();//统计今天的签约患者年龄
        computequota_8();//统计今天的签约患者年龄
        computequota_9();//统计今天的待签约
        computequota_9();//统计今天的待签约
        computequota_10();//统计今天的改签
        computequota_10();//统计今天的改签
        computequota_12();//统计今天的签约下按年龄分组后再
        quartzJobLog.setJobContent("开始实时统计查询");
        quartzJobLog.setJobContent("开始实时统计查询");
        quartzJobLog.setJobName("实时统计");
        quartzJobLog.setJobName("实时统计");
        quartzJobLog.setJobId("11");
        quartzJobLog.setJobId("11");
        quartzJobLog.setJobType("1");
        quartzJobLog.setJobEndTime(new Date());
        quartzJobLog.setJobEndTime(new Date());
        wlyyJobLogDao.save(quartzJobLog);
        wlyyJobLogDao.save(quartzJobLog);
    }
    }
    private void computequota_12() throws Exception{
        String now = getDayString(0);
        String tomorrow = getDayString(1);
        //找出今天的签约信息 yesterday,now
        //查找出系统全部的机构
        List<Hospital> hospitals = hospitalDao.findHospital2();
        Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
        for (Hospital hospital : hospitals) {
            hospitalsMap.put(hospital.getCode(), hospital);
        }
        //查找出厦门市全部的区
        List<Town> towns = townDao.findByCityCode(Constant.city);
        Map<String, Town> townsMap = new HashMap<String, Town>();
        for (Town town : towns) {
            townsMap.put(town.getCode(), town);
        }
        //找出今天的签约信息
        List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(now, tomorrow);
        //数组里面第一个是健康人群 第二个是慢病人群 第三个是65岁以上人群
        Map<String, Map<String, Map>> cityAgeMap = new HashMap<String, Map<String, Map>>();//key是市行政代码 目前只有厦门市
        Map<String,Map> temp =new HashMap<String,Map>();
        cityAgeMap.put(Constant.city, temp);
        Map<String, Map<String, Map>> townAgeMap = new HashMap<String, Map<String, Map>>();//key是区行政代码
        Map<String, Map<String, Map>> orgAgeMap = new HashMap<String, Map<String, Map>>();//key是机构代码
        //统计有签约的
        for (SignFamily signFamily : signFamilys) {
            Hospital hospital = hospitalsMap.get(signFamily.getHospital());//得到患者签约的机构
            String town = hospital.getTown();
            int age = IdCardUtil.getAgeForIdcard(signFamily.getIdcard());//根据card解析年龄
            String ageCode = getAgeCode(age);//得到年龄的code
            boolean hasGXY = false;//有高血压
            boolean hasTNB = false;//有糖尿病
            //如果是慢病的 统计高血压的 糖尿病  1高血压,2糖尿病  糖尿病和高血压是100
            String diseaseType="";
            String jsonString = redisTemplate.opsForValue().get("disease:" + signFamily.getPatient());
            if (StringUtils.isEmpty(jsonString)) {
                continue;
            }
            //排除数据 只留下高血压和糖尿病
            List<JSONObject> jsonObjects = new ArrayList<JSONObject>();
            JSONArray redisValues = new JSONArray(jsonString);
            for (Object obj : redisValues) {
                JSONObject redisValue = new JSONObject(obj);
                //排除掉三师签约
                if ("1".equals(redisValue.get("signType").toString())) {
                    continue;
                }
                String disease = redisValue.get("disease").toString();
                if (Integer.valueOf(disease).equals("1")) {
                    jsonObjects.add(redisValue);
                    hasGXY = true;//设置有高血压
                    diseaseType="1";
                }
                if (Integer.valueOf(disease).equals("2")) {
                    jsonObjects.add(redisValue);
                    hasTNB = true;//设置有糖尿病
                    diseaseType="2";
                }
            }
            if(hasGXY&&hasTNB){
                diseaseType="100";
            }
            //统计市
            compute(cityAgeMap, Constant.city, ageCode, diseaseType);
            //统计区
            compute(townAgeMap, town, ageCode, diseaseType);
            //统计机构
            //统计站
            if (!"00".equals(hospital.getCode().substring(8))) {
                String orgCodeTemp = hospital.getCode().substring(0, 8) + "00";
                //统计机构
                compute(orgAgeMap, orgCodeTemp, ageCode, diseaseType);
            } else {
                compute(orgAgeMap, hospital.getCode(), ageCode, diseaseType);
            }
        }
        //保存市级数据
        for (Map.Entry<String, Map<String, Map>> entry : cityAgeMap.entrySet()) {
            Map<String, Map> oneAgeMap = entry.getValue();
            for(int i=1;i<7;i++){
                for(int j=1;j<4;j++){
                    String key_2=i+"";
                    String key_3=j+"";
                    String name=Constant.cityName;
                    JSONObject jsonObject=new JSONObject();
                    if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
                        Map<String,Long> key3Map=oneAgeMap.get(key_2);
                        if(key3Map!=null&&key3Map.containsKey(key_3)){
                            jsonObject.put("num",entry.getValue().get((key3Map.get(key_3) + "")));
                        }else{
                            jsonObject.put("num",0);
                        }
                    } else {
                        jsonObject.put("num",0);
                    }
                    jsonObject.put("name",name);
                    jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
                    redisTemplate.opsForValue().set(new StringBuffer("quota:12:4:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
                }
            }
        }
        //保存区级
        for (Map.Entry<String, Town> entry : townsMap.entrySet()) {
            //判断该区是否有统计数据
            Map<String, Map> oneAgeMap = townAgeMap.get(entry.getKey());//得到当个区的统计数据
            Town townObj = entry.getValue();//得到区级信息
            for(int i=1;i<7;i++){
                for(int j=1;j<4;j++){
                    String key_2=i+"";
                    String key_3=j+"";
                    String name=townObj.getName();
                    JSONObject jsonObject=new JSONObject();
                    if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
                        Map<String,Long> key3Map=oneAgeMap.get(key_2);
                        if(key3Map!=null&&key3Map.containsKey(key_3)){
                            jsonObject.put("num",(key3Map.get(key_3) + ""));
                        }else{
                            jsonObject.put("num",0);
                        }
                    } else {
                        jsonObject.put("num",0);
                    }
                    jsonObject.put("name",townObj.getName());
                    jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
                    redisTemplate.opsForValue().set(new StringBuffer("quota:12:3:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
                }
            }
        }
        //保存机构级
        for (Map.Entry<String, Hospital> entry : hospitalsMap.entrySet()) {
            //判断该机构是否有统计数据
            Map<String, Map> oneAgeMap = orgAgeMap.get(entry.getKey());//得到当个机构的统计数据
            Hospital hospital = entry.getValue();//得到机构信息
            for(int i=1;i<7;i++){
                for(int j=1;j<4;j++){
                    String key_2=i+"";
                    String key_3=j+"";
                    String name=hospital.getName();
                    JSONObject jsonObject=new JSONObject();
                    if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
                        Map<String,Long> key3Map=oneAgeMap.get(key_2);
                        if(key3Map!=null&&key3Map.containsKey(key_3)){
                            jsonObject.put("num",(key3Map.get(key_3) + ""));
                        }else{
                            jsonObject.put("num",0);
                        }
                    } else {
                        jsonObject.put("num",0);
                    }
                    jsonObject.put("name",name);
                    jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
                    redisTemplate.opsForValue().set(new StringBuffer("quota:12:2:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
                }
            }
        }
    }
    private void compute(Map<String, Map<String, Map>> rootMap, String rootKey, String ageCode, String diseaseType) {
        if (rootMap.containsKey(rootKey)) {
            //得到市下面的所有的年龄map
            Map<String, Map> groupMapTemp = rootMap.get(rootKey);
            if(groupMapTemp.containsKey(ageCode)){
                //得到这个年龄下的患者map
                Map<String,Long> mape= groupMapTemp.get(ageCode);
                if(mape.containsKey(diseaseType)){
                    mape.put(diseaseType,mape.get(diseaseType)+1L);
                }else{
                    mape.put(diseaseType,1L);
                }
            }else{
                //新增疾病的统计map
                Map<String, Long> groupMapTemp1 = new HashMap<String, Long>();
                groupMapTemp1.put(diseaseType, 1L);
                groupMapTemp.put(ageCode,groupMapTemp1);
            }
        } else {
            //没有就新建统计数据  新增疾病的统计map
            Map<String, Long> groupMapTemp = new HashMap<String, Long>();
            groupMapTemp.put(diseaseType, 1L);
            //把统计疾病的map放入对应的年龄组map中
            Map<String, Map> groupMapTemp2 = new HashMap<String, Map>();
            groupMapTemp2.put(ageCode,groupMapTemp);
            //把年龄组map放入市的map里面
            rootMap.put(rootKey, groupMapTemp2);
        }
    }
    private void computequota_1() {
    private void computequota_1() {
        //签约需要的统计map
        //签约需要的统计map
        Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200
        Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200

+ 330 - 0
src/main/java/com/yihu/wlyy/job/SignAgeGroupDiseaseJob.java

@ -0,0 +1,330 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.entity.address.Hospital;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.job.QuartzJobLog;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.web.quota.WlyyJobConfigVO;
import com.yihu.wlyy.web.quota.WlyyQuotaVO;
import org.json.JSONArray;
import org.json.JSONObject;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 签约下按年龄分组后再按疾病统计
 */
@Component
public class SignAgeGroupDiseaseJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private WlyyQuotaResultDao wlyyQuotaResultDao;//指标结果Dao
    @Autowired
    private WlyyJobLogDao wlyyJobLogDao;//执行日志Dao
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private TownDao townDao;
    @Autowired
    private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private StringRedisTemplate redisTemplate;
    String yesterday;
    String now;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        //初始化参数
        JobDataMap map = context.getJobDetail().getJobDataMap();
        wlyyQuota = (WlyyQuotaVO) map.get("quota");
        wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
        now = StringUtils.isEmpty(map.get("now")) ? SignAgeGroupDiseaseJob.getDayString(0) : map.get("now").toString();
        yesterday = StringUtils.isEmpty(map.get("yesterday")) ? SignAgeGroupDiseaseJob.getDayString(-1) : map.get("yesterday").toString();
        computequotaByPatientAge();
    }
    /**
     * 机构维度患者年龄维度计算指标
     */
    @Transactional
    private void computequotaByPatientAge() {
        try {
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+12+"'");
            //新建任务日志对象
            QuartzJobLog wlyyJobLog = new QuartzJobLog();
            wlyyJobLog.setJobStartTime(new Date());
            wlyyJobLog.setJobId(wlyyJobConfig.getId());
            wlyyJobLog.setJobName(wlyyJobConfig.getJobName());
            //查找出系统全部的机构
            List<Hospital> hospitals = hospitalDao.findHospital2();
            Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
            for (Hospital hospital : hospitals) {
                hospitalsMap.put(hospital.getCode(), hospital);
            }
            //查找出厦门市全部的区
            List<Town> towns = townDao.findByCityCode(Constant.city);
            Map<String, Town> townsMap = new HashMap<String, Town>();
            for (Town town : towns) {
                townsMap.put(town.getCode(), town);
            }
            //找出今天的签约信息
            List<SignFamily> signFamilies = signFamilyDao.findByJiatingSignYesterday(yesterday, now);
            //数组里面第一个是健康人群 第二个是慢病人群 第三个是65岁以上人群
            Map<String, Map<String, Map>> cityAgeMap = new HashMap<String, Map<String, Map>>();//key是市行政代码 目前只有厦门市
            Map<String,Map> temp =new HashMap<String,Map>();
            cityAgeMap.put(Constant.city, temp);
            Map<String, Map<String, Map>> townAgeMap = new HashMap<String, Map<String, Map>>();//key是区行政代码
            Map<String, Map<String, Map>> orgAgeMap = new HashMap<String, Map<String, Map>>();//key是机构代码
            //统计有签约的
            for (SignFamily signFamily : signFamilies) {
                Hospital hospital = hospitalsMap.get(signFamily.getHospital());//得到患者签约的机构
                String town = hospital.getTown();
                int age = IdCardUtil.getAgeForIdcard(signFamily.getIdcard());//根据card解析年龄
                String ageCode = getAgeCode(age);//得到年龄的code
                boolean hasGXY = false;//有高血压
                boolean hasTNB = false;//有糖尿病
                //如果是慢病的 统计高血压的 糖尿病  1高血压,2糖尿病  糖尿病和高血压是100
                String diseaseType="";
                String jsonString = redisTemplate.opsForValue().get("disease:" + signFamily.getPatient());
                if (StringUtils.isEmpty(jsonString)) {
                    continue;
                }
                //排除数据 只留下高血压和糖尿病
                List<JSONObject> jsonObjects = new ArrayList<JSONObject>();
                JSONArray redisValues = new JSONArray(jsonString);
                for (Object obj : redisValues) {
                    JSONObject redisValue = new JSONObject(obj);
                    //排除掉三师签约
                    if ("1".equals(redisValue.get("signType").toString())) {
                        continue;
                    }
                    String disease = redisValue.get("disease").toString();
                    if (Integer.valueOf(disease).equals("1")) {
                        jsonObjects.add(redisValue);
                        hasGXY = true;//设置有高血压
                        diseaseType="1";
                    }
                    if (Integer.valueOf(disease).equals("2")) {
                        jsonObjects.add(redisValue);
                        hasTNB = true;//设置有糖尿病
                        diseaseType="2";
                    }
                }
                if(hasGXY&&hasTNB){
                    diseaseType="100";
                }
                //统计市
                compute(cityAgeMap, Constant.city, ageCode, diseaseType);
                //统计区
                compute(townAgeMap, town, ageCode, diseaseType);
                //统计机构
                //统计站
                if (!"00".equals(hospital.getCode().substring(8))) {
                    String orgCodeTemp = hospital.getCode().substring(0, 8) + "00";
                    //统计机构
                    compute(orgAgeMap, orgCodeTemp, ageCode, diseaseType);
                } else {
                    compute(orgAgeMap, hospital.getCode(), ageCode, diseaseType);
                }
            }
            //保存统计数据
            // 保存市的统计数据
            for (Map.Entry<String, Map<String, Map>> entry : cityAgeMap.entrySet()) {
               Map<String, Map> oneAgeMap = entry.getValue();
               for(int i=1;i<7;i++){
                   for(int j=1;j<4;j++){
                       String key_2=i+"";
                       String key_3=j+"";
                       String city=Constant.city;
                       String cityName=Constant.cityName;
                       String town="";
                       String townName="";
                       String org="";
                       String orgName="";
                       save(oneAgeMap, key_2, key_3, city, cityName, town, townName, org, orgName,"4");
                   }
               }
            }
            //保存区级
            for (Map.Entry<String, Town> entry : townsMap.entrySet()) {
                //判断该区是否有统计数据
                Map<String, Map> oneAgeMap = townAgeMap.get(entry.getKey());//得到当个区的统计数据
                Town townObj = entry.getValue();//得到区级信息
                for(int i=1;i<7;i++){
                    for(int j=1;j<4;j++){
                        String key_2=i+"";
                        String key_3=j+"";
                        String city=Constant.city;
                        String cityName=Constant.cityName;
                        String town=townObj.getCode();
                        String townName=townObj.getName();
                        String org="";
                        String orgName="";
                        save(oneAgeMap, key_2, key_3, city, cityName, town, townName, org, orgName,"3");
                    }
                }
            }
            for (Map.Entry<String, Hospital> entry : hospitalsMap.entrySet()) {
                //判断该机构是否有统计数据
                Map<String, Map> oneAgeMap = orgAgeMap.get(entry.getKey());//得到当个机构的统计数据
                Hospital hospital = entry.getValue();//得到机构信息
                for(int i=1;i<7;i++){
                    for(int j=1;j<4;j++){
                        String key_2=i+"";
                        String key_3=j+"";
                        String city=Constant.city;
                        String cityName=Constant.cityName;
                        String town=hospital.getTown();
                        String townName=hospital.getTownName();
                        String org=hospital.getCode();
                        String orgName=hospital.getName();
                        save(oneAgeMap, key_2, key_3, city, cityName, town, townName, org, orgName,"2");
                    }
                }
            }
            wlyyJobLog.setJobEndTime(new Date());
            wlyyJobLog.setJobContent("统计" + getYesterday() + " 的签约患者年龄数据完成 ");
            wlyyJobLog.setJobType("1");
            wlyyJobLogDao.save(wlyyJobLog);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void save(Map<String, Map> oneAgeMap, String key_2, String key_3, String city, String cityName, String town, String townName, String org, String orgName,String level) {
        WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
        wlyyQuotaResult.setDel("1");
        wlyyQuotaResult.setCity(city);
        wlyyQuotaResult.setCityName(cityName);
        wlyyQuotaResult.setTown(town);
        wlyyQuotaResult.setTownName(townName);
        wlyyQuotaResult.setOrgCode(org);
        wlyyQuotaResult.setOrgName(orgName);
        wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
        wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
        wlyyQuotaResult.setQuotaDate(getYesterday());
        wlyyQuotaResult.setCreateTime(new Date());
        wlyyQuotaResult.setLevel1Type(level);//等级
        wlyyQuotaResult.setLevel2Type(key_2);
        wlyyQuotaResult.setLevel2TypeName(Constant.getLevelAgeName(key_2));
        wlyyQuotaResult.setLevel3Type(key_3);
        wlyyQuotaResult.setLevel3TypeName(Constant.getLevelDiseaseName(key_3));
        if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
            Map<String,Long> key3Map=oneAgeMap.get(key_2);
            if(key3Map!=null&&key3Map.containsKey(key_3)){
                wlyyQuotaResult.setResult(key3Map.get(key_3) + "");
            }else{
                wlyyQuotaResult.setResult("0");
            }
        } else {
            wlyyQuotaResult.setResult("0");
        }
        wlyyQuotaResultDao.save(wlyyQuotaResult);
    }
    private void compute(Map<String, Map<String, Map>> rootMap, String rootKey, String ageCode, String diseaseType) {
        if (rootMap.containsKey(rootKey)) {
            //得到市下面的所有的年龄map
            Map<String, Map> groupMapTemp = rootMap.get(rootKey);
            if(groupMapTemp.containsKey(ageCode)){
                //得到这个年龄下的患者map
                Map<String,Long> mape= groupMapTemp.get(ageCode);
                if(mape.containsKey(diseaseType)){
                    mape.put(diseaseType,mape.get(diseaseType)+1L);
                }else{
                    mape.put(diseaseType,1L);
                }
            }else{
                //新增疾病的统计map
                Map<String, Long> groupMapTemp1 = new HashMap<String, Long>();
                groupMapTemp1.put(diseaseType, 1L);
                groupMapTemp.put(ageCode,groupMapTemp1);
            }
        } else {
            //没有就新建统计数据  新增疾病的统计map
            Map<String, Long> groupMapTemp = new HashMap<String, Long>();
            groupMapTemp.put(diseaseType, 1L);
            //把统计疾病的map放入对应的年龄组map中
            Map<String, Map> groupMapTemp2 = new HashMap<String, Map>();
            groupMapTemp2.put(ageCode,groupMapTemp);
            //把年龄组map放入市的map里面
            rootMap.put(rootKey, groupMapTemp2);
        }
    }
    /*
    得到昨天的日期字符串  yyyy-MM-dd
     */
    public String getYesterday() {
        return yesterday;
    }
    /**
     * 根据年龄得到对应的code
     *
     * @param age
     * @return
     */
    public String getAgeCode(int age) {
        if (age < 7) {
            return Constant.level_age_1;
        } else if (age >= 7 && age < 18) {
            return Constant.level_age_2;
        } else if (age >= 18 && age < 30) {
            return Constant.level_age_3;
        } else if (age >= 30 && age < 50) {
            return Constant.level_age_4;
        } else if (age >= 50 && age < 65) {
            return Constant.level_age_5;
        } else {
            return Constant.level_age_6;
        }
    }
    public static String getDayString(Integer size) {
        Date date = new Date();//取时间
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.add(calendar.DATE, size);//把日期往后增加一天.整数往后推,负数往前移动
        date = calendar.getTime(); //这个时间就是日期往后推一天的结果
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(date);
        return dateString;
    }
    public static void main(String[] args) {
        getDayString(0);
    }
}

+ 21 - 0
src/main/java/com/yihu/wlyy/repository/FamousDoctorTimesRemainDao.java

@ -0,0 +1,21 @@
package com.yihu.wlyy.repository;
import com.yihu.wlyy.entity.doctor.DoctorFamousConsultTimesRemain;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by JKZL-A on 2016/9/19.
 */
public interface FamousDoctorTimesRemainDao extends PagingAndSortingRepository<DoctorFamousConsultTimesRemain, Long>,
        JpaSpecificationExecutor<DoctorFamousConsultTimesRemain> {
    /**
     * 查询医生剩余咨询次数
     *
     * @param doctor 医生
     * @param consultDate 咨询日期
     * @return
     */
    DoctorFamousConsultTimesRemain findByDoctorAndConsultDate(String doctor,String consultDate);
}

+ 3 - 0
src/main/java/com/yihu/wlyy/repository/WlyySignFamilyCodeDao.java

@ -13,4 +13,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface WlyySignFamilyCodeDao  extends PagingAndSortingRepository<SignFamilyCode, String>, JpaSpecificationExecutor<SignFamilyCode> {
public interface WlyySignFamilyCodeDao  extends PagingAndSortingRepository<SignFamilyCode, String>, JpaSpecificationExecutor<SignFamilyCode> {
    @Query(" FROM SignFamilyCode a WHERE a.orgCode =?1 ")
    @Query(" FROM SignFamilyCode a WHERE a.orgCode =?1 ")
    SignFamilyCode findByOrgCode(String hospital);
    SignFamilyCode findByOrgCode(String hospital);
    @Query(" FROM SignFamilyCode a WHERE a.orgCode =?1 and a.year=?2 ")
    SignFamilyCode findByOrgCodeAndYear(String hospital, String year);
}
}

+ 3 - 0
src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -105,6 +105,9 @@ public class ConsultTeamService extends ConsultService {
		case 4:
		case 4:
			// 已完成的
			// 已完成的
			return findByDoctorType4(uid, id, pagesize);
			return findByDoctorType4(uid, id, pagesize);
		case 5:
			// 名医咨询
			return findByDoctorType1(uid, type, id, pagesize);
		}
		}
		return null;
		return null;
	}
	}

+ 174 - 54
src/main/java/com/yihu/wlyy/service/app/scheduling/DoctorWorkTimeService.java

@ -1,11 +1,13 @@
package com.yihu.wlyy.service.app.scheduling;
package com.yihu.wlyy.service.app.scheduling;
import com.yihu.wlyy.entity.doctor.DoctorFamousConsultTimesRemain;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
import com.yihu.wlyy.repository.DoctorDao;
import com.yihu.wlyy.repository.DoctorDao;
import com.yihu.wlyy.repository.DoctorWorkTimeDao;
import com.yihu.wlyy.repository.DoctorWorkTimeDao;
import com.yihu.wlyy.repository.DoctorWorkWeekDao;
import com.yihu.wlyy.repository.DoctorWorkWeekDao;
import com.yihu.wlyy.repository.FamousDoctorTimesRemainDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
@ -14,11 +16,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import javax.transaction.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
/**
/**
 * 医生工作排班
 * 医生工作排班
 *
 * <p>
 * Created by lyr on 2016/08/19.
 * Created by lyr on 2016/08/19.
 */
 */
@Service
@Service
@ -31,6 +34,8 @@ public class DoctorWorkTimeService extends BaseService {
    private DoctorWorkWeekDao doctorWorkWeekDao;
    private DoctorWorkWeekDao doctorWorkWeekDao;
    @Autowired
    @Autowired
    private DoctorDao doctorDao;
    private DoctorDao doctorDao;
    @Autowired
    private FamousDoctorTimesRemainDao timesRemainDao;
    /**
    /**
     * 查询医生工作时间列表
     * 查询医生工作时间列表
@ -38,13 +43,13 @@ public class DoctorWorkTimeService extends BaseService {
     * @param doctor 医生标识
     * @param doctor 医生标识
     * @return
     * @return
     */
     */
    public JSONObject findDoctorWorkTime(String doctor){
    public JSONObject findDoctorWorkTime(String doctor) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        List<WlyyDoctorWorkWeek> workWeekList = doctorWorkWeekDao.findDoctorWorkWeeks(doctor);
        List<WlyyDoctorWorkWeek> workWeekList = doctorWorkWeekDao.findDoctorWorkWeeks(doctor);
        result.put("workTime",workTime != null ? new JSONObject(workTime): "");
        result.put("workWeeks",workWeekList != null ? new JSONArray(workWeekList): "");
        result.put("workTime", workTime != null ? new JSONObject(workTime) : "");
        result.put("workWeeks", workWeekList != null ? new JSONArray(workWeekList) : "");
        return result;
        return result;
    }
    }
@ -53,16 +58,16 @@ public class DoctorWorkTimeService extends BaseService {
     * 查询医生某天工作时间
     * 查询医生某天工作时间
     *
     *
     * @param doctor 医生标识
     * @param doctor 医生标识
     * @param week 某天
     * @param week   某天
     * @return
     * @return
     */
     */
    public JSONObject findDoctorWeekWorkTime(String doctor,String week){
    public JSONObject findDoctorWeekWorkTime(String doctor, String week) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        WlyyDoctorWorkWeek workWeek = doctorWorkWeekDao.findDoctorWorkWeek(doctor,week);
        WlyyDoctorWorkWeek workWeek = doctorWorkWeekDao.findDoctorWorkWeek(doctor, week);
        result.put("workTime",workTime != null ? new JSONObject(workTime): "");
        result.put("workWeek",workWeek != null ? new JSONObject(workWeek) : "");
        result.put("workTime", workTime != null ? new JSONObject(workTime) : "");
        result.put("workWeek", workWeek != null ? new JSONObject(workWeek) : "");
        return result;
        return result;
    }
    }
@ -71,16 +76,31 @@ public class DoctorWorkTimeService extends BaseService {
     * 查询医生某天工作时间
     * 查询医生某天工作时间
     *
     *
     * @param doctor 医生标识
     * @param doctor 医生标识
     * @param week 某天
     * @param week   某天
     * @return
     * @return
     */
     */
    public Map<String,Object> findDoctorWeekWork(String doctor,String week){
        Map<String,Object> map = new HashMap<>();
    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);
        WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        WlyyDoctorWorkWeek workWeek = doctorWorkWeekDao.findDoctorWorkWeek(doctor,week);
        WlyyDoctorWorkWeek workWeek = doctorWorkWeekDao.findDoctorWorkWeek(doctor, week);
        map.put("workTime", workTime);
        map.put("workWeek", workWeek);
        if (doc.getIsFamous() == 1) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor, df.format(new Date()));
        map.put("workTime",workTime);
        map.put("workWeek",workWeek);
            if (timesRemain == null) {
                map.put("famousDoctorTimesRemain",workTime.getFamousConsultTimes());
            } else {
                map.put("famousDoctorTimesRemain",timesRemain.getTimesRemain());
            }
        }
        return map;
        return map;
    }
    }
@ -88,11 +108,11 @@ public class DoctorWorkTimeService extends BaseService {
    /**
    /**
     * 保存医生工作排班
     * 保存医生工作排班
     *
     *
     * @param doctor 医生
     * @param doctor         医生
     * @param workScheduling 排班配置
     * @param workScheduling 排班配置
     * @return
     * @return
     */
     */
    public boolean saveDoctorWorkTime(String doctor,JSONObject workScheduling) throws Exception {
    public boolean saveDoctorWorkTime(String doctor, JSONObject workScheduling) throws Exception {
        JSONObject workTime = workScheduling.has("workTime") ? workScheduling.getJSONObject("workTime") : null;
        JSONObject workTime = workScheduling.has("workTime") ? workScheduling.getJSONObject("workTime") : null;
        JSONArray workTWeeks = workScheduling.has("workWeeks") ? workScheduling.getJSONArray("workWeeks") : null;
        JSONArray workTWeeks = workScheduling.has("workWeeks") ? workScheduling.getJSONArray("workWeeks") : null;
@ -100,16 +120,17 @@ public class DoctorWorkTimeService extends BaseService {
        WlyyDoctorWorkTime doctorWorkTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        WlyyDoctorWorkTime doctorWorkTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
        Doctor doc = doctorDao.findByCode(doctor);
        Doctor doc = doctorDao.findByCode(doctor);
        if(StringUtils.isEmpty(doctor) || doc == null){
        if (StringUtils.isEmpty(doctor) || doc == null) {
            throw new Exception("找不到对应医生!");
            throw new Exception("找不到对应医生!");
        }
        }
        if(workTime == null){
        if (workTime == null) {
            throw new Exception("工作时间段不能为空!");
            throw new Exception("工作时间段不能为空!");
        }
        }
        if(doctorWorkTime == null){
        if (doctorWorkTime == null) {
            doctorWorkTime = new WlyyDoctorWorkTime();
            doctorWorkTime = new WlyyDoctorWorkTime();
            doctorWorkTime.setReceiveConsult("1");
            doctorWorkTime.setReceiveConsult("1");
            doctorWorkTime.setFamousConsultTimes(0);
        }
        }
        // 医生
        // 医生
@ -135,10 +156,10 @@ public class DoctorWorkTimeService extends BaseService {
        doctorWorkWeekDao.deleteByDoctor(doctor);
        doctorWorkWeekDao.deleteByDoctor(doctor);
        // 排班保存
        // 排班保存
        if(workTWeeks != null){
        if (workTWeeks != null) {
            List<WlyyDoctorWorkWeek> weeks = new ArrayList<>();
            List<WlyyDoctorWorkWeek> weeks = new ArrayList<>();
            for(int i = 0; i < workTWeeks.length(); i++){
            for (int i = 0; i < workTWeeks.length(); i++) {
                JSONObject object = workTWeeks.getJSONObject(i);
                JSONObject object = workTWeeks.getJSONObject(i);
                WlyyDoctorWorkWeek week = new WlyyDoctorWorkWeek();
                WlyyDoctorWorkWeek week = new WlyyDoctorWorkWeek();
@ -162,11 +183,11 @@ public class DoctorWorkTimeService extends BaseService {
    /**
    /**
     * 医生设置是否接受咨询
     * 医生设置是否接受咨询
     *
     *
     * @param doctor 医生
     * @param doctor         医生
     * @param receiveConsult 是否接受咨询
     * @param receiveConsult 是否接受咨询
     * @return
     * @return
     */
     */
    public boolean setDoctorReceiveConsult(String doctor,String receiveConsult) throws Exception {
    public boolean setDoctorReceiveConsult(String doctor, String receiveConsult) throws Exception {
        try {
        try {
            WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
            WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
@ -187,7 +208,7 @@ public class DoctorWorkTimeService extends BaseService {
            doctorWorkTimeDao.save(workTime);
            doctorWorkTimeDao.save(workTime);
            return true;
            return true;
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return false;
            return false;
        }
        }
@ -196,33 +217,33 @@ public class DoctorWorkTimeService extends BaseService {
    /**
    /**
     * 医生是否在工作
     * 医生是否在工作
     *
     *
     * @param doctor
     * @param doctor 医生
     * @return
     * @return
     */
     */
    public JSONObject isDoctorWorking(String doctor){
    public JSONObject isDoctorWorking(String doctor) throws Exception {
        JSONObject json = new JSONObject();
        JSONObject json = new JSONObject();
        Calendar calendar = Calendar.getInstance();
        Calendar calendar = Calendar.getInstance();
        int week =  calendar.get(Calendar.DAY_OF_WEEK) - 1;
        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
        if(week == 0){
        if (week == 0) {
            week = 7;
            week = 7;
        }
        }
        // 医生工作时间设置
        // 医生工作时间设置
        Map<String,Object> result = findDoctorWeekWork(doctor,String.valueOf(week));
        Map<String, Object> result = findDoctorWeekWork(doctor, String.valueOf(week));
        if(result.get("workTime") == null){
        if (result.get("workTime") == null) {
            // 医生未设置时,默认7*24小时工作
            // 医生未设置时,默认7*24小时工作
            json.put("status","1");
            json.put("msg","医生当前接受咨询");
        }else{
            WlyyDoctorWorkTime doctorWorkTime = (WlyyDoctorWorkTime)result.get("workTime");
            json.put("status", "1");
            json.put("msg", "医生当前接受咨询");
        } else {
            WlyyDoctorWorkTime doctorWorkTime = (WlyyDoctorWorkTime) result.get("workTime");
            if(doctorWorkTime.getReceiveConsult().equals("0")){
            if (doctorWorkTime.getReceiveConsult().equals("0")) {
                // 医生设置不接受咨询
                // 医生设置不接受咨询
                json.put("status","0");
                json.put("msg","医生不接受咨询");
            }else {
                json.put("status", "0");
                json.put("msg", "医生不接受咨询");
            } else {
                if (result.get("workWeek") != null) {
                if (result.get("workWeek") != null) {
                    // 当前工作日已设置工作时间
                    // 当前工作日已设置工作时间
                    int flag = 0;
                    int flag = 0;
@ -236,10 +257,10 @@ public class DoctorWorkTimeService extends BaseService {
                    if (workWeek.getMorning().equals("1")) {
                    if (workWeek.getMorning().equals("1")) {
                        String currentStart = workTime.getMorningBegin();
                        String currentStart = workTime.getMorningBegin();
                        String currentEnd = workTime.getMorningEnd();
                        String currentEnd = workTime.getMorningEnd();
                        if(currentStart.length() == 4){
                        if (currentStart.length() == 4) {
                            currentStart = "0" + currentStart;
                            currentStart = "0" + currentStart;
                        }
                        }
                        if(currentEnd.length() == 4){
                        if (currentEnd.length() == 4) {
                            currentEnd = "0" + currentEnd;
                            currentEnd = "0" + currentEnd;
                        }
                        }
                        if (current.compareTo(currentStart) >= 0 &&
                        if (current.compareTo(currentStart) >= 0 &&
@ -251,10 +272,10 @@ public class DoctorWorkTimeService extends BaseService {
                    if (workWeek.getAfternoon().equals("1")) {
                    if (workWeek.getAfternoon().equals("1")) {
                        String currentStart = workTime.getAfternoonBegin();
                        String currentStart = workTime.getAfternoonBegin();
                        String currentEnd = workTime.getAfternoonEnd();
                        String currentEnd = workTime.getAfternoonEnd();
                        if(currentStart.length() == 4){
                        if (currentStart.length() == 4) {
                            currentStart = "0" + currentStart;
                            currentStart = "0" + currentStart;
                        }
                        }
                        if(currentEnd.length() == 4){
                        if (currentEnd.length() == 4) {
                            currentEnd = "0" + currentEnd;
                            currentEnd = "0" + currentEnd;
                        }
                        }
                        if (current.compareTo(currentStart) >= 0 &&
                        if (current.compareTo(currentStart) >= 0 &&
@ -266,10 +287,10 @@ public class DoctorWorkTimeService extends BaseService {
                    if (workWeek.getNight().equals("1")) {
                    if (workWeek.getNight().equals("1")) {
                        String currentStart = workTime.getNightBegin();
                        String currentStart = workTime.getNightBegin();
                        String currentEnd = workTime.getNightEnd();
                        String currentEnd = workTime.getNightEnd();
                        if(currentStart.length() == 4){
                        if (currentStart.length() == 4) {
                            currentStart = "0" + currentStart;
                            currentStart = "0" + currentStart;
                        }
                        }
                        if(currentEnd.length() == 4){
                        if (currentEnd.length() == 4) {
                            currentEnd = "0" + currentEnd;
                            currentEnd = "0" + currentEnd;
                        }
                        }
                        if (current.compareTo(currentStart) >= 0 &&
                        if (current.compareTo(currentStart) >= 0 &&
@ -278,20 +299,119 @@ public class DoctorWorkTimeService extends BaseService {
                        }
                        }
                    }
                    }
                    if(flag == 1){
                        json.put("status","1");
                        json.put("msg","医生当前接受咨询");
                    }else{
                        json.put("status","2");
                        json.put("msg","医生当前不在工作时间");
                    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","医生当前不在工作时间");
                } else {
                    json.put("status", "2");
                    json.put("msg", "医生当前不在工作时间");
                }
                }
            }
            }
        }
        }
        return json;
        return json;
    }
    }
    /**
     * 设置名医咨询次数
     *
     * @param doctor 医生
     * @return
     */
    public boolean setFamousDoctorConsultTimes(String doctor, int consultTimes) {
        try {
            WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
            // 未有设置,则新建医生设置
            if (workTime == null) {
                Doctor doc = doctorDao.findByCode(doctor);
                if (doc == null) {
                    throw new Exception("doctor can not find");
                }
                workTime = new WlyyDoctorWorkTime();
                workTime.setDoctor(doctor);
                workTime.setDoctorName(doc.getName());
            }
            // 设置名医咨询次数
            workTime.setFamousConsultTimes(consultTimes);
            workTime.setCzrq(new Date());
            doctorWorkTimeDao.save(workTime);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    /**
     * 名医咨询当前剩余次数查询
     *
     * @param doctor 医生
     * @return
     */
    public int getDoctorConsultTimesRemain(String doctor) {
        int result = 0;
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor, df.format(new Date()));
        if (timesRemain != null) {
            result = timesRemain.getTimesRemain();
        } else {
            WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
            if (workTime != null) {
                result = workTime.getFamousConsultTimes();
            }
        }
        return result;
    }
    /**
     * 名医咨询当前剩余次数减一
     *
     * @param doctor 医生
     * @return
     */
    public boolean setDoctorCurrentConsultTimesRemain(String doctor) {
        try {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor, df.format(new Date()));
            if (timesRemain != null) {
                int times = timesRemain.getTimesRemain();
                if (times < 1) {
                    throw new Exception("consult-times-error:doctor does not have not consult times remain");
                }
                timesRemain.setTimesRemain(times - 1);
                timesRemainDao.save(timesRemain);
            } else {
                DoctorFamousConsultTimesRemain timesRemainNew = new DoctorFamousConsultTimesRemain();
                WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
                if (workTime == null || workTime.getFamousConsultTimes() < 1) {
                    throw new Exception("consult-times-error:doctor does not have consult times setting");
                }
                timesRemainNew.setDoctor(doctor);
                timesRemainNew.setConsultDate(df.format(new Date()));
                timesRemainNew.setTimesRemain(workTime.getFamousConsultTimes() - 1);
                timesRemainDao.save(timesRemainNew);
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
}

+ 101 - 95
src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -102,7 +102,7 @@ public class FamilyContractService extends BaseService {
     * @param patient
     * @param patient
     * @return
     * @return
     */
     */
    public SignFamily findSigningByPatient(String patient){
    public SignFamily findSigningByPatient(String patient) {
        return signFamilyDao.findSigningByPatient(patient);
        return signFamilyDao.findSigningByPatient(patient);
    }
    }
@ -202,7 +202,7 @@ public class FamilyContractService extends BaseService {
        json.put("doctor", d.getCode());
        json.put("doctor", d.getCode());
        json.put("name", d.getName());
        json.put("name", d.getName());
        json.put("photo", d.getPhoto());
        json.put("photo", d.getPhoto());
        json.put("sex",d.getSex());
        json.put("sex", d.getSex());
        json.put("job", d.getJob());
        json.put("job", d.getJob());
        json.put("jobName", d.getJobName());
        json.put("jobName", d.getJobName());
        json.put("hospital", d.getHosptialName());
        json.put("hospital", d.getHosptialName());
@ -486,7 +486,7 @@ public class FamilyContractService extends BaseService {
    public int surrender(String patient, String patientName, String userPhoto, String doctor, String doctorName, String openid, String reason, int sex) {
    public int surrender(String patient, String patientName, String userPhoto, String doctor, String doctorName, String openid, String reason, int sex) {
        // 更新为待解约
        // 更新为待解约
        int res = signFamilyDao.surrender(patient, doctor);
        int res = signFamilyDao.surrender(patient, doctor);
        SignFamily signFamily=  signFamilyDao.findByjiatingPatient(patient);
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
        signFamily.setPatientApplyUnsignDate(new Date());
        signFamily.setPatientApplyUnsignDate(new Date());
        if (res == 0) {
        if (res == 0) {
            return 0;
            return 0;
@ -618,7 +618,7 @@ public class FamilyContractService extends BaseService {
                                         String hospital, String hospitalName,
                                         String hospital, String hospitalName,
                                         String idcard, String ssc, String mobile,
                                         String idcard, String ssc, String mobile,
                                         String emerMobile, String images, String disease, String expenses, String signDoctorCode,
                                         String emerMobile, String images, String disease, String expenses, String signDoctorCode,
                                         String signDoctorName, String signDoctorLevel,String customGroup) throws Exception {
                                         String signDoctorName, String signDoctorLevel, String customGroup) throws Exception {
        // 查询是否有家庭签约
        // 查询是否有家庭签约
        SignFamily sc = signFamilyDao.findByIdcard(idcard);
        SignFamily sc = signFamilyDao.findByIdcard(idcard);
        if (sc != null) {
        if (sc != null) {
@ -626,12 +626,12 @@ public class FamilyContractService extends BaseService {
        }
        }
        //判断是否有三师签约 并且判断全科医生一致
        //判断是否有三师签约 并且判断全科医生一致
        SignFamily sssignFamily = signFamilyDao.findSSByIdcard(idcard);
        SignFamily sssignFamily = signFamilyDao.findSSByIdcard(idcard);
        if (sssignFamily != null&&!doctor.equals(sssignFamily.getDoctor())) {
        if (sssignFamily != null && !doctor.equals(sssignFamily.getDoctor())) {
            throw new Exception("全科医生不一致!");
            throw new Exception("全科医生不一致!");
        }
        }
        List<SystemDict> systemDicts=  systemDictDao.findByDictName("SIGN_YEAR");
        String signYear=systemDicts.get(0).getCode();
        List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
        String signYear = systemDicts.get(0).getCode();
        SignFamily sf = new SignFamily();
        SignFamily sf = new SignFamily();
        sf.setSignYear(signYear);//设置签约年度
        sf.setSignYear(signYear);//设置签约年度
@ -651,12 +651,12 @@ public class FamilyContractService extends BaseService {
        sf.setMobile(mobile);
        sf.setMobile(mobile);
        sf.setHospital(hospital);
        sf.setHospital(hospital);
        sf.setHospitalName(hospitalName);
        sf.setHospitalName(hospitalName);
        String sscD="";
        if(StringUtils.isNumeric(ssc.trim())){
        String sscD = "";
        if (StringUtils.isNumeric(ssc.trim())) {
            //如果是纯数字的医保号换成D开头的
            //如果是纯数字的医保号换成D开头的
            sscD=sbInfoDao.findBySfzh18Max(idcard).getCardno();
        }else{
            sscD=ssc;
            sscD = sbInfoDao.findBySfzh18Max(idcard).getCardno();
        } else {
            sscD = ssc;
        }
        }
        sf.setSsc(sscD);
        sf.setSsc(sscD);
        sf.setStatus(1);// 代理签约,直接生效
        sf.setStatus(1);// 代理签约,直接生效
@ -771,7 +771,7 @@ public class FamilyContractService extends BaseService {
        //判断病人分组
        //判断病人分组
        if (!StringUtils.isEmpty(disease)) {
        if (!StringUtils.isEmpty(disease)) {
            List<String> diseases = Arrays.asList(disease.split(","));
            List<String> diseases = Arrays.asList(disease.split(","));
            if(diseases.contains("1") || diseases.contains("2")) {
            if (diseases.contains("1") || diseases.contains("2")) {
                groupCode = "2";
                groupCode = "2";
            }
            }
        } else {
        } else {
@ -816,7 +816,7 @@ public class FamilyContractService extends BaseService {
        doctorPatientGroupInfo.setSignType("2");//家庭签约
        doctorPatientGroupInfo.setSignType("2");//家庭签约
        doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
        doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
        if(!StringUtils.isEmpty(customGroup) && !customGroup.equals("0")){
        if (!StringUtils.isEmpty(customGroup) && !customGroup.equals("0")) {
            DoctorPatientGroupInfo customDoctorGroup = new DoctorPatientGroupInfo();
            DoctorPatientGroupInfo customDoctorGroup = new DoctorPatientGroupInfo();
            customDoctorGroup.setCzrq(new Date());
            customDoctorGroup.setCzrq(new Date());
@ -831,9 +831,9 @@ public class FamilyContractService extends BaseService {
            doctorPatientGroupInfoDao.save(customDoctorGroup);
            doctorPatientGroupInfoDao.save(customDoctorGroup);
            SignFamily signFamily = signFamilyDao.findSsSignByDoctorPatient(sf.getDoctor(),sf.getPatient());
            SignFamily signFamily = signFamilyDao.findSsSignByDoctorPatient(sf.getDoctor(), sf.getPatient());
            if(signFamily != null){
            if (signFamily != null) {
                DoctorPatientGroupInfo ssDoctorGroup = new DoctorPatientGroupInfo();
                DoctorPatientGroupInfo ssDoctorGroup = new DoctorPatientGroupInfo();
                ssDoctorGroup.setCzrq(new Date());
                ssDoctorGroup.setCzrq(new Date());
@ -854,10 +854,10 @@ public class FamilyContractService extends BaseService {
        if (groups != null && groups.size() > 0) {
        if (groups != null && groups.size() > 0) {
            for (DoctorPatientGroupInfo group : groups) {
            for (DoctorPatientGroupInfo group : groups) {
                if(StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
                if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
                    continue;
                    continue;
                }
                }
                if(group.getGroup().equals(customGroup)){
                if (group.getGroup().equals(customGroup)) {
                    continue;
                    continue;
                }
                }
@ -877,10 +877,10 @@ public class FamilyContractService extends BaseService {
            }
            }
        }
        }
        if(!StringUtils.isEmpty(disease) && !disease.equals("0")){
            boolean flag =  patientDiseaseService.updatePatientDisease(sf.getPatient(),disease);
        if (!StringUtils.isEmpty(disease) && !disease.equals("0")) {
            boolean flag = patientDiseaseService.updatePatientDisease(sf.getPatient(), disease);
            if(!flag){
            if (!flag) {
                throw new Exception("疾病更新失败");
                throw new Exception("疾病更新失败");
            }
            }
        }
        }
@ -890,7 +890,7 @@ public class FamilyContractService extends BaseService {
            Doctor doc = doctorDao.findByCode(sf.getDoctor());
            Doctor doc = doctorDao.findByCode(sf.getDoctor());
            Hospital hos = hospitalDao.findByCode(doc.getHospital());
            Hospital hos = hospitalDao.findByCode(doc.getHospital());
            String content= "祝贺您,成功签约" + sf.getDoctorName() + "医生团队,您已可以享受家庭医生所带来的无微不至的健康保健服务。"+
            String content = "祝贺您,成功签约" + sf.getDoctorName() + "医生团队,您已可以享受家庭医生所带来的无微不至的健康保健服务。" +
                    "为了给您提供更好的服务,请尽快到" + (hos != null ? hos.getName() : "") + "社区(地址:" +
                    "为了给您提供更好的服务,请尽快到" + (hos != null ? hos.getName() : "") + "社区(地址:" +
                    (hos != null ? hos.getAddress() : "") + ")缴费。";
                    (hos != null ? hos.getAddress() : "") + ")缴费。";
            JSONObject json = new JSONObject();
            JSONObject json = new JSONObject();
@ -899,12 +899,13 @@ public class FamilyContractService extends BaseService {
            json.put("doctorName", sf.getDoctorName());
            json.put("doctorName", sf.getDoctorName());
            json.put("date", DateUtil.dateToStrShort(sf.getBegin()));
            json.put("date", DateUtil.dateToStrShort(sf.getBegin()));
            json.put("content", content);
            json.put("content", content);
            json.put("remark", "您好,您成功签约家庭医生");
            json.put("remark", ""); //您好,您成功签约家庭医生
            // 添加到发送队列
            // 添加到发送队列
            PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
            PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
        }
        }
        return temp;
        return temp;
    }
    }
    /**
    /**
     * 处理签约申请
     * 处理签约申请
     *
     *
@ -921,7 +922,7 @@ public class FamilyContractService extends BaseService {
                          String healthDoctor,
                          String healthDoctor,
                          String healthDoctorName,
                          String healthDoctorName,
                          long msgid,
                          long msgid,
                          String patientCard, int type, String disease, String majorDoctor, String majorhDoctorName,String customGroup, String expenses) throws Exception {
                          String patientCard, int type, String disease, String majorDoctor, String majorhDoctorName, String customGroup, String expenses) throws Exception {
        if (type != 1 && type != 2) {
        if (type != 1 && type != 2) {
            return -1;
            return -1;
        }
        }
@ -942,8 +943,8 @@ public class FamilyContractService extends BaseService {
            return 0;
            return 0;
        }
        }
        if (type == 1) {
        if (type == 1) {
            List<SystemDict> systemDicts=  systemDictDao.findByDictName("SIGN_YEAR");
            String year=systemDicts.get(0).getCode();
            List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
            String year = systemDicts.get(0).getCode();
            //病人疾病更新
            //病人疾病更新
//            if (!StringUtils.isEmpty(disease)) {
//            if (!StringUtils.isEmpty(disease)) {
//                p.setDisease(Integer.valueOf(disease));
//                p.setDisease(Integer.valueOf(disease));
@ -1050,7 +1051,7 @@ public class FamilyContractService extends BaseService {
        //判断病人分组
        //判断病人分组
        if (!StringUtils.isEmpty(disease)) {
        if (!StringUtils.isEmpty(disease)) {
            List<String> diseases = Arrays.asList(disease.split(","));
            List<String> diseases = Arrays.asList(disease.split(","));
            if(diseases.contains("1") || diseases.contains("2")) {
            if (diseases.contains("1") || diseases.contains("2")) {
                groupCode = "2";
                groupCode = "2";
            }
            }
        } else {
        } else {
@ -1097,7 +1098,7 @@ public class FamilyContractService extends BaseService {
        doctorPatientGroupInfo.setSignType("2");//家庭签约
        doctorPatientGroupInfo.setSignType("2");//家庭签约
        doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
        doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
        if(!StringUtils.isEmpty(customGroup) && !customGroup.equals("0")){
        if (!StringUtils.isEmpty(customGroup) && !customGroup.equals("0")) {
            DoctorPatientGroupInfo customDoctorGroup = new DoctorPatientGroupInfo();
            DoctorPatientGroupInfo customDoctorGroup = new DoctorPatientGroupInfo();
            customDoctorGroup.setCzrq(new Date());
            customDoctorGroup.setCzrq(new Date());
@ -1111,9 +1112,9 @@ public class FamilyContractService extends BaseService {
            customDoctorGroup.setSignType("2");//家庭签约
            customDoctorGroup.setSignType("2");//家庭签约
            doctorPatientGroupInfoDao.save(customDoctorGroup);
            doctorPatientGroupInfoDao.save(customDoctorGroup);
            SignFamily signFamily = signFamilyDao.findSsSignByDoctorPatient(sf.getDoctor(),sf.getPatient());
            SignFamily signFamily = signFamilyDao.findSsSignByDoctorPatient(sf.getDoctor(), sf.getPatient());
            if(signFamily != null){
            if (signFamily != null) {
                DoctorPatientGroupInfo ssDoctorGroup = new DoctorPatientGroupInfo();
                DoctorPatientGroupInfo ssDoctorGroup = new DoctorPatientGroupInfo();
                ssDoctorGroup.setCzrq(new Date());
                ssDoctorGroup.setCzrq(new Date());
@ -1134,10 +1135,10 @@ public class FamilyContractService extends BaseService {
        if (groups != null && groups.size() > 0) {
        if (groups != null && groups.size() > 0) {
            for (DoctorPatientGroupInfo group : groups) {
            for (DoctorPatientGroupInfo group : groups) {
                if(StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
                if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
                    continue;
                    continue;
                }
                }
                if(group.getGroup().equals(customGroup)){
                if (group.getGroup().equals(customGroup)) {
                    continue;
                    continue;
                }
                }
@ -1157,10 +1158,10 @@ public class FamilyContractService extends BaseService {
            }
            }
        }
        }
        if(!StringUtils.isEmpty(disease) && !disease.equals("0")){
            boolean flag =  patientDiseaseService.updatePatientDisease(sf.getPatient(),disease);
        if (!StringUtils.isEmpty(disease) && !disease.equals("0")) {
            boolean flag = patientDiseaseService.updatePatientDisease(sf.getPatient(), disease);
            if(!flag){
            if (!flag) {
                throw new Exception("疾病更新失败");
                throw new Exception("疾病更新失败");
            }
            }
        }
        }
@ -1170,7 +1171,7 @@ public class FamilyContractService extends BaseService {
            Doctor doc = doctorDao.findByCode(sf.getDoctor());
            Doctor doc = doctorDao.findByCode(sf.getDoctor());
            Hospital hos = hospitalDao.findByCode(doc.getHospital());
            Hospital hos = hospitalDao.findByCode(doc.getHospital());
            String content= "祝贺您,成功签约" + sf.getDoctorName() + "医生团队,您已可以享受家庭医生所带来的无微不至的健康保健服务。"+
            String content = "祝贺您,成功签约" + sf.getDoctorName() + "医生团队,您已可以享受家庭医生所带来的无微不至的健康保健服务。" +
                    "为了给您提供更好的服务,请尽快到" + (hos != null ? hos.getName() : "") + "社区(地址:" +
                    "为了给您提供更好的服务,请尽快到" + (hos != null ? hos.getName() : "") + "社区(地址:" +
                    (hos != null ? hos.getAddress() : "") + ")缴费。";
                    (hos != null ? hos.getAddress() : "") + ")缴费。";
            // 同意签约
            // 同意签约
@ -1180,7 +1181,7 @@ public class FamilyContractService extends BaseService {
            json.put("doctorName", sf.getDoctorName());
            json.put("doctorName", sf.getDoctorName());
            json.put("date", DateUtil.dateToStrShort(sf.getBegin()));
            json.put("date", DateUtil.dateToStrShort(sf.getBegin()));
            json.put("content", content);
            json.put("content", content);
            json.put("remark", "您好,您成功签约家庭医生");
            json.put("remark", ""); //您好,您成功签约家庭医生
            // 添加到发送队列
            // 添加到发送队列
            PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
            PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
        } else if (type == 2) {
        } else if (type == 2) {
@ -1207,7 +1208,7 @@ public class FamilyContractService extends BaseService {
     * @param reason  解约原因
     * @param reason  解约原因
     * @return
     * @return
     */
     */
    public int handleSurrender(String access_token, long msgid, String patient, int type, String reason) {
    public int handleSurrender(String access_token, long msgid, String patient, int type, String reason) throws Exception {
        if (type != 1 && type != 2) {
        if (type != 1 && type != 2) {
            return -1;
            return -1;
        }
        }
@ -1222,6 +1223,10 @@ public class FamilyContractService extends BaseService {
            message.setOver("0");
            message.setOver("0");
        }
        }
        if (type == 1) {
        if (type == 1) {
            // 设置家庭签约疾病无效
            if (!patientDiseaseService.updatePatientDisease(patient, "")) {
                throw new Exception("patient's disease update failed");
            }
            // 将签约状态改为已解约
            // 将签约状态改为已解约
            sf.setReason(reason);
            sf.setReason(reason);
            sf.setStatus(-3);
            sf.setStatus(-3);
@ -1235,8 +1240,6 @@ public class FamilyContractService extends BaseService {
            doctorPatientGroupInfoDao.deleteByPatient(patient);
            doctorPatientGroupInfoDao.deleteByPatient(patient);
            //结束患者家庭签约咨询
            //结束患者家庭签约咨询
            consultTeamDao.updateStatusByPatient(patient);
            consultTeamDao.updateStatusByPatient(patient);
            // 设置家庭签约疾病无效
            patientDiseaseService.updatePatientDisease(patient,"");
            // 推送消息消息给微信端
            // 推送消息消息给微信端
            JSONObject json = new JSONObject();
            JSONObject json = new JSONObject();
@ -1338,23 +1341,25 @@ public class FamilyContractService extends BaseService {
        // 获取当前年份
        // 获取当前年份
        String year = DateUtil.getStringDate(DateUtil.YY);
        String year = DateUtil.getStringDate(DateUtil.YY);
        Hospital hospital1 = hospitalDao.findByCode(hospital);
        Hospital hospital1 = hospitalDao.findByCode(hospital);
        Integer amount=0;
        SignFamilyCode signFamilyCode = wlyySignFamilyCodeDao.findByOrgCode(hospital);
        if(signFamilyCode !=null){
            amount= signFamilyCode.getSequence()+1;
            signFamilyCode.setSequence(amount);
            signFamilyCode.setModifyTime(new Date());
        }else{
        Integer amount = 0;
        SignFamilyCode wlyySignFamilyCode = wlyySignFamilyCodeDao.findByOrgCodeAndYear(hospital, year);
        if (wlyySignFamilyCode != null) {
            amount = wlyySignFamilyCode.getSequence() + 1;
            wlyySignFamilyCode.setSequence(amount);
            wlyySignFamilyCode.setModifyTime(new Date());
        } else {
            //创建序列
            //创建序列
            amount=1;
            SignFamilyCode signFamilyCodeTemp =new SignFamilyCode();
            signFamilyCodeTemp.setModifyTime(new Date());
            signFamilyCodeTemp.setOrgCode(hospital1.getCode());
            signFamilyCodeTemp.setOrgName(hospital1.getName());
            signFamilyCodeTemp.setSequence(1);
            wlyySignFamilyCodeDao.save(signFamilyCodeTemp);
        }
        return year + hospital1.getRoadCode() + hospital1.getCenterSite() + StringUtils.leftPad(String.valueOf(amount + 1), 6, "0");
            amount = 1;
            SignFamilyCode wlyySignFamilyCodeTemp = new SignFamilyCode();
            wlyySignFamilyCodeTemp.setModifyTime(new Date());
            wlyySignFamilyCodeTemp.setOrgCode(hospital1.getCode());
            wlyySignFamilyCodeTemp.setOrgName(hospital1.getName());
            wlyySignFamilyCodeTemp.setYear(year);
            wlyySignFamilyCodeTemp.setSequence(1);
            wlyySignFamilyCodeDao.save(wlyySignFamilyCodeTemp);
        }
        return year + hospital1.getRoadCode() + hospital1.getCenterSite() + "Y" + StringUtils.leftPad(String.valueOf(amount + 1), 5, "0");
    }
    }
    public int countAmountSigned2(String uid) {
    public int countAmountSigned2(String uid) {
@ -1366,6 +1371,7 @@ public class FamilyContractService extends BaseService {
        return signFamilyDao.findSanshiSignByPatient(code);
        return signFamilyDao.findSanshiSignByPatient(code);
    }
    }
    public SignFamily findByJiatingPatient(String code) {
    public SignFamily findByJiatingPatient(String code) {
        return signFamilyDao.findFamilySignByPatient(code);
        return signFamilyDao.findFamilySignByPatient(code);
@ -1471,8 +1477,8 @@ public class FamilyContractService extends BaseService {
                    result.put("majorDoctor", member.getMemberCode());
                    result.put("majorDoctor", member.getMemberCode());
                    result.put("majorDoctorName", member.getName());
                    result.put("majorDoctorName", member.getName());
                } else if (member.getType() == 2) {
                } else if (member.getType() == 2) {
                    Doctor doctor=doctorDao.findByCode(member.getMemberCode());
                    result.put("hospital",doctor.getHospital());
                    Doctor doctor = doctorDao.findByCode(member.getMemberCode());
                    result.put("hospital", doctor.getHospital());
                    result.put("doctor", member.getMemberCode());
                    result.put("doctor", member.getMemberCode());
                    result.put("doctorName", member.getName());
                    result.put("doctorName", member.getName());
                } else if (member.getType() == 3) {
                } else if (member.getType() == 3) {
@ -1483,20 +1489,20 @@ public class FamilyContractService extends BaseService {
            // 查询患者疾病
            // 查询患者疾病
            String diseases = redisTemplate.opsForValue().get("disease:" + p.getCode());
            String diseases = redisTemplate.opsForValue().get("disease:" + p.getCode());
            if(!StringUtils.isEmpty(diseases)){
            if (!StringUtils.isEmpty(diseases)) {
                JSONArray array = new JSONArray(diseases);
                JSONArray array = new JSONArray(diseases);
                JSONArray disArray = new JSONArray();
                JSONArray disArray = new JSONArray();
                for(int i = 0; i < array.length(); i++){
                for (int i = 0; i < array.length(); i++) {
                    JSONObject json = array.getJSONObject(i);
                    JSONObject json = array.getJSONObject(i);
                    if(json != null && json.get("signType").toString().equals("1")){
                    if (json != null && json.get("signType").toString().equals("1")) {
                        disArray.put(json);
                        disArray.put(json);
                    }
                    }
                }
                }
                result.put("diseases",disArray);
            }else{
                result.put("diseases","");
                result.put("diseases", disArray);
            } else {
                result.put("diseases", "");
            }
            }
@ -1506,9 +1512,9 @@ public class FamilyContractService extends BaseService {
            result.put("signStatus", "3");
            result.put("signStatus", "3");
        }
        }
        if(p != null){
        if (p != null) {
            JSONObject pJson = new JSONObject(p);
            JSONObject pJson = new JSONObject(p);
            result.put("patient",pJson);
            result.put("patient", pJson);
        }
        }
        return result;
        return result;
@ -1518,7 +1524,7 @@ public class FamilyContractService extends BaseService {
        JSONArray jsonArray = new JSONArray();
        JSONArray jsonArray = new JSONArray();
        //找出患者的三师签约信息
        //找出患者的三师签约信息
        SignFamily signFamily = signFamilyDao.findSanshiSignByPatient(patientCode);
        SignFamily signFamily = signFamilyDao.findSanshiSignByPatient(patientCode);
        Patient patient=patientDao.findByCode(patientCode);
        Patient patient = patientDao.findByCode(patientCode);
        if (signFamily != null) {
        if (signFamily != null) {
            //得到三师签约的服务团队
            //得到三师签约的服务团队
            List<Doctor> doctors = doctorDao.findSanshiDoctorByTeam(signFamily.getTeamCode());
            List<Doctor> doctors = doctorDao.findSanshiDoctorByTeam(signFamily.getTeamCode());
@ -1534,14 +1540,14 @@ public class FamilyContractService extends BaseService {
                jo.put("signStatus", signFamily.getStatus());//签约状态 0待签约,1已签约 2待解约
                jo.put("signStatus", signFamily.getStatus());//签约状态 0待签约,1已签约 2待解约
                jo.put("jobName", doctor.getJobName());//职称
                jo.put("jobName", doctor.getJobName());//职称
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
                if(signFamily.getStatus()==0){
                if (signFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(signFamily.getPatientApplyDate()));//申请时间
                    jo.put("sqDate", DateUtil.dateToStrShort(signFamily.getPatientApplyDate()));//申请时间
                }else if(signFamily.getStatus()==1){
                    jo.put("qyDate", DateUtil.dateToStrShort( signFamily.getApplyDate()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort( signFamily.getEnd()));//结束时间
                }else if(signFamily.getStatus()==2){
                    jo.put("qyDate", DateUtil.dateToStrShort( signFamily.getPatientApplyUnsignDate()));//申请解约时间
                    jo.put("endDate", DateUtil.dateToStrShort( signFamily.getEnd()));//结束时间
                } else if (signFamily.getStatus() == 1) {
                    jo.put("qyDate", DateUtil.dateToStrShort(signFamily.getApplyDate()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(signFamily.getEnd()));//结束时间
                } else if (signFamily.getStatus() == 2) {
                    jo.put("qyDate", DateUtil.dateToStrShort(signFamily.getPatientApplyUnsignDate()));//申请解约时间
                    jo.put("endDate", DateUtil.dateToStrShort(signFamily.getEnd()));//结束时间
                }
                }
                jsonArray.put(jo);
                jsonArray.put(jo);
            }
            }
@ -1552,25 +1558,25 @@ public class FamilyContractService extends BaseService {
        if (jtSignFamily != null) {
        if (jtSignFamily != null) {
            //家庭签约只找全科医生
            //家庭签约只找全科医生
            Doctor doctor = doctorDao.findByCode(jtSignFamily.getDoctor());
            Doctor doctor = doctorDao.findByCode(jtSignFamily.getDoctor());
            if(doctor !=null){
	            JSONObject jo = new JSONObject();
	            jo.put("code", doctor.getCode());
	            jo.put("sex", doctor.getSex());
	            jo.put("name", doctor.getName());
	            jo.put("photo", doctor.getPhoto());
	            jo.put("hosptialName", doctor.getHosptialName());
	            jo.put("level", doctor.getLevel());
	            jo.put("signType", "2");//三师签约
	            jo.put("signStatus", jtSignFamily.getStatus());
	            jo.put("jobName", doctor.getJobName());
	            jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
	            if(jtSignFamily.getStatus()==0){
	                jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
	            }else{
	                jo.put("qyDate", DateUtil.dateToStrShort( jtSignFamily.getApplyDate()));//签约时间
	                jo.put("endDate", DateUtil.dateToStrShort( jtSignFamily.getEnd()));//结束时间
	            }
	            jsonArray.put(jo);
            if (doctor != null) {
                JSONObject jo = new JSONObject();
                jo.put("code", doctor.getCode());
                jo.put("sex", doctor.getSex());
                jo.put("name", doctor.getName());
                jo.put("photo", doctor.getPhoto());
                jo.put("hosptialName", doctor.getHosptialName());
                jo.put("level", doctor.getLevel());
                jo.put("signType", "2");//三师签约
                jo.put("signStatus", jtSignFamily.getStatus());
                jo.put("jobName", doctor.getJobName());
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
                if (jtSignFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
                } else {
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getApplyDate()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
                }
                jsonArray.put(jo);
            }
            }
        }
        }
        return jsonArray;
        return jsonArray;
@ -1592,10 +1598,10 @@ public class FamilyContractService extends BaseService {
     * @param patient
     * @param patient
     * @return
     * @return
     */
     */
    public boolean updateExpensesType(String expensesType,String patient) {
    public boolean updateExpensesType(String expensesType, String patient) {
        if (signFamilyDao.updateExpensesType(expensesType, patient) > 0) {
        if (signFamilyDao.updateExpensesType(expensesType, patient) > 0) {
            return true;
            return true;
        }else{
        } else {
            return false;
            return false;
        }
        }
    }
    }

+ 1 - 1
src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -46,7 +46,7 @@ public class DoctorConsultController extends WeixinBaseController {
	/**
	/**
	 * 三师咨询列表查询
	 * 三师咨询列表查询
	 * @param type 咨询类型:0、全部,1、咨询我的,2、公共的, 3、参与过的,4、已结束的
	 * @param type 咨询类型:0、全部,1、咨询我的,2、公共的, 3、参与过的,4、已结束的  5 名医咨询 全部  6 名医咨询 进行中 7 名医咨询 已结束
	 * @param id
	 * @param id
	 * @param pagesize 每页显示数,默认为10
	 * @param pagesize 每页显示数,默认为10
	 * @return
	 * @return

+ 33 - 1
src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -79,7 +79,7 @@ public class DoctorDeviceController extends BaseController {
	@RequestMapping(value = "DeletePatientDevice",method = RequestMethod.DELETE)
	@RequestMapping(value = "DeletePatientDevice",method = RequestMethod.DELETE)
	@ResponseBody
	@ResponseBody
	public String delete(@ApiParam(name="id",value="删除设备关联ID")
	public String delete(@ApiParam(name="id",value="删除设备关联ID")
						  @RequestParam(value="id",required = true) String id) {
						 @RequestParam(value="id",required = true) String id) {
		try {
		try {
			PatientDevice pd = patientDeviceService.findById(id);
			PatientDevice pd = patientDeviceService.findById(id);
			if(pd!=null)
			if(pd!=null)
@ -98,4 +98,36 @@ public class DoctorDeviceController extends BaseController {
			return invalidUserException(ex, -1,ex.getMessage());
			return invalidUserException(ex, -1,ex.getMessage());
		}
		}
	}
	}
	@ApiOperation("获取患者设备信息")
	@RequestMapping(value = "PatientDeviceInfo",method = RequestMethod.GET)
	@ResponseBody
	public String getPatientDeviceInfo(@ApiParam(name="id",value="患者设备ID",defaultValue = "34")
									   @RequestParam(value="id",required = true) String id) {
		try {
			PatientDevice device = patientDeviceService.findById(id);
			return write(200, "查询成功", "data", device);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
	@ApiOperation("通过sn码获取设备绑定情况")
	@RequestMapping(value = "PatientDeviceIdcard",method = RequestMethod.GET)
	@ResponseBody
	public String getDeviceUser(
			@ApiParam(name="patient",value="患者code",defaultValue = "915cca0a-5b1d-11e6-8344-fa163e8aee56")
			@RequestParam(value="patient",required = true) String patient,
			@ApiParam(name="type",value="设备类型",defaultValue = "1")
			@RequestParam(value="type",required = true) String type,
			@ApiParam(name="device_sn",value="设备SN码",defaultValue = "15L000002")
			@RequestParam(value="device_sn",required = true) String deviceSn) {
		try {
			List<Map<String,String>> list = patientDeviceService.getDeviceUser(patient,deviceSn,type);
			return write(200, "获取设备绑定信息成功!", "data",list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
}
}

+ 73 - 13
src/main/java/com/yihu/wlyy/web/doctor/scheduling/DoctorWorkTimeController.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.web.doctor.scheduling;
package com.yihu.wlyy.web.doctor.scheduling;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.BaseController;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
@ -8,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
/**
/**
 * Created by lyr on 2016/08/19.
 * Created by lyr on 2016/08/19.
@ -16,6 +19,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
@RequestMapping(value = "/doctor/work_scheduling")
@RequestMapping(value = "/doctor/work_scheduling")
public class DoctorWorkTimeController extends BaseController {
public class DoctorWorkTimeController extends BaseController {
    @Autowired
    private DoctorInfoService doctorInfoService;
    @Autowired
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    private DoctorWorkTimeService doctorWorkTimeService;
@ -119,8 +124,8 @@ public class DoctorWorkTimeController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String setDoctorReceiveConsult(String receiveConsult) {
    public String setDoctorReceiveConsult(String receiveConsult) {
        try {
        try {
            if(StringUtils.isEmpty(receiveConsult)){
                return error(-1,"是否接受咨询参数不能为空");
            if (StringUtils.isEmpty(receiveConsult)) {
                return error(-1, "是否接受咨询参数不能为空");
            }
            }
            if (doctorWorkTimeService.setDoctorReceiveConsult(getUID(), receiveConsult)) {
            if (doctorWorkTimeService.setDoctorReceiveConsult(getUID(), receiveConsult)) {
                return error(200, "设置成功");
                return error(200, "设置成功");
@ -133,6 +138,36 @@ public class DoctorWorkTimeController extends BaseController {
        }
        }
    }
    }
    /**
     * 设置名医咨询次数
     *
     * @param consultTimes 名医咨询次数
     * @return
     */
    @RequestMapping(value = "/consult_times_setting")
    @ResponseBody
    public String setFamousDoctorConsultTime(int consultTimes) {
        try {
            Doctor doc = doctorInfoService.findDoctorByCode(getUID());
            if (doc == null) {
                return error(-1,"医生不存在");
            }
            if (doc.getIsFamous() != 1) {
                return error(-1,"医生不是名医,无法设置名医咨询次数");
            }
            if (doctorWorkTimeService.setFamousDoctorConsultTimes(getUID(), consultTimes)) {
                return error(200, "设置成功");
            } else {
                return error(-1, "设置失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "设置失败");
        }
    }
    /**
    /**
     * 查询某个医生是否在工作时间
     * 查询某个医生是否在工作时间
     *
     *
@ -143,8 +178,8 @@ public class DoctorWorkTimeController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String isDoctorWorking(String doctor) {
    public String isDoctorWorking(String doctor) {
        try {
        try {
            if(StringUtils.isEmpty(doctor)){
                return error(-1,"参数不能为空");
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "参数不能为空");
            }
            }
            JSONObject result = doctorWorkTimeService.isDoctorWorking(doctor);
            JSONObject result = doctorWorkTimeService.isDoctorWorking(doctor);
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
@ -162,13 +197,13 @@ public class DoctorWorkTimeController extends BaseController {
     */
     */
    @RequestMapping(value = "/doctor_worktime")
    @RequestMapping(value = "/doctor_worktime")
    @ResponseBody
    @ResponseBody
    public String getDoctorWorkTime(String doctor){
        try{
    public String getDoctorWorkTime(String doctor) {
        try {
            JSONObject json = doctorWorkTimeService.findDoctorWorkTime(doctor);
            JSONObject json = doctorWorkTimeService.findDoctorWorkTime(doctor);
            return write(200,"查询成功","data",json);
        }catch(Exception e){
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return error(-1,"查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -176,15 +211,40 @@ public class DoctorWorkTimeController extends BaseController {
     * 查询某个医生某天的工作时间
     * 查询某个医生某天的工作时间
     *
     *
     * @param doctor 医生
     * @param doctor 医生
     * @param week 周几
     * @param week   周几
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/doctor_week_worktime")
    @RequestMapping(value = "/doctor_week_worktime")
    @ResponseBody
    @ResponseBody
    public String getDoctorWeekWorkTime(String doctor,String week){
    public String getDoctorWeekWorkTime(String doctor, String week) {
        try {
            JSONObject json = doctorWorkTimeService.findDoctorWeekWorkTime(doctor, week);
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 名医咨询剩余次数查询
     *
     * @return
     */
    @RequestMapping(value = "/consult_times_remain")
    @ResponseBody
    public String famousDoctorTimesRemain(){
        try{
        try{
            JSONObject json = doctorWorkTimeService.findDoctorWeekWorkTime(doctor,week);
            return write(200,"查询成功","data",json);
            Doctor doc = doctorInfoService.findDoctorByCode(getUID());
            if (doc == null) {
                return error(-1,"医生不存在");
            }
            if (doc.getIsFamous() != 1) {
                return error(-1,"医生不是名医,没有名医咨询次数");
            }
            int result = doctorWorkTimeService.getDoctorConsultTimesRemain(getUID());
            return write(200,"查询成功","data",result);
        }catch (Exception e){
        }catch (Exception e){
            e.printStackTrace();
            e.printStackTrace();
            return error(-1,"查询失败");
            return error(-1,"查询失败");

+ 20 - 85
src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -133,89 +133,6 @@ public class ConsultController extends WeixinBaseController {
		}
		}
	}
	}
	/**
	 * 验证医生是否在工作时间
	 *
	 * @param doctor
	 * @return
	 */
	@RequestMapping(value = "/doctor_isworking")
	@ResponseBody
    public String isDoctorWorking(@RequestParam(required = true)String doctor){
    	try{
    		int flag = 0;
			Calendar calendar = Calendar.getInstance();
            int week =  calendar.get(Calendar.DAY_OF_WEEK) - 1;
            if(week == 0){
            	week = 7;
			}
			Map<String,Object> result = doctorWorkTimeService.findDoctorWeekWork(doctor,String.valueOf(week));
			if(result.get("workTime") == null){
				flag = 1; // 未设置时间段则默认为7*24小时
			}else{
				if(result.get("workWeek") != null){
					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;
                        }
                    }
				}
			}
    		return write(200,"查询成功","data",flag);
		}catch (Exception e){
			e.printStackTrace();
			return error(-1,"查询失败!");
		}
	}
    /**
    /**
     * 医生是否在工作
     * 医生是否在工作
     *
     *
@ -227,13 +144,32 @@ public class ConsultController extends WeixinBaseController {
	public String isDoctorAtWorking(String doctor){
	public String isDoctorAtWorking(String doctor){
		try{
		try{
            JSONObject result = doctorWorkTimeService.isDoctorWorking(doctor);
            JSONObject result = doctorWorkTimeService.isDoctorWorking(doctor);
            return write(200,"查询成功","data",result);
            return write(200,result.getString("msg"),"data",result.getString("status"));
		}catch (Exception e){
		}catch (Exception e){
            e.printStackTrace();
            e.printStackTrace();
			return error(-1,"查询失败");
			return error(-1,"查询失败");
		}
		}
	}
	}
	/**
	 * 名医咨询剩余次数查询
	 *
	 * @param doctor
	 * @return
	 */
	@RequestMapping(value = "/consult_times_remain")
	@ResponseBody
	public String famousDoctorTimesRemain(String doctor){
		try{
			int result = doctorWorkTimeService.getDoctorConsultTimesRemain(doctor);
			return write(200,"查询成功","data",result);
		}catch (Exception e){
			e.printStackTrace();
			return error(-1,"查询失败");
		}
	}
	/**
	/**
	 * 获取未完成咨询
	 * 获取未完成咨询
	 *
	 *
@ -546,7 +482,6 @@ public class ConsultController extends WeixinBaseController {
	/**
	/**
	 * 网络咨询咨询日志查询
	 * 网络咨询咨询日志查询
	 * @param consult 咨询标识
	 * @param consult 咨询标识
	 * @param patient 患者标识
	 * @param pagesize 每页显示数,默认为10
	 * @param pagesize 每页显示数,默认为10
	 * @return
	 * @return
	 */
	 */