Browse Source

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

Sand 8 years ago
parent
commit
dc14e27a40

+ 1 - 1
src/main/java/com/yihu/wlyy/entity/doctor/team/sign/DoctorPatientGroupInfo.java

@ -37,7 +37,7 @@ public class DoctorPatientGroupInfo extends IdEntity {
	private Date czrq;
	// 状态,1正常,0作废
	private Integer status;
	//签约类型(1表示三师签约,2表示家庭签约,3表示三师和家庭签约都存在)
	//签约类型(1表示三师签约,2表示家庭签约)
	private String signType;
	@Column(name = "sign_type")

+ 2 - 0
src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java

@ -170,4 +170,6 @@ public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam,
	//名医咨询 -根据status 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.symptoms like ?2 and a.status = ?3 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid,String title,Integer type, Pageable pageRequest);
	@Query("select a from ConsultTeam a where  a.type=?3  and a.del = '1' and a.patient=?1 and a.doctor=?2 and  a.status=0 ")
	ConsultTeam findByParientCodeAndSignTypeAndDoctor(String patientCode, String doctor, String s);
}

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

@ -95,4 +95,7 @@ public interface DoctorPatientGroupInfoDao extends PagingAndSortingRepository<Do
	@Modifying
	@Query("update DoctorPatientGroupInfo set status = ?4 where doctor = ?1 and patient = ?2 and group = ?3 and status = 1")
	int updateDoctorPatientGroup(String doctor,String patient,String group,int status);
	@Query("select a from DoctorPatientGroupInfo a where  a.status = 1 and a.doctor = ?2 and a.patient = ?1 and a.signType =2")
	List<DoctorPatientGroupInfo> findByPatientAndDoctor(String patient, String oldDoctorCode);
}

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

@ -43,4 +43,8 @@ public interface DoctorTeamMemberDao extends PagingAndSortingRepository<DoctorTe
    DoctorTeamMember findSanshiByTeamAndType(String teamCode, int i);
    List<DoctorTeamMember> findByTeamAndDel(String team, String del);
    @Query(" FROM DoctorTeamMember a WHERE a.team =?1 and  a.del='1' and  a.signType='2' and  a.memberCode=?2 ")
    DoctorTeamMember findMemberByTeamAndCode(String teamCode, String oldDoctorCode);
}

+ 1 - 1
src/main/java/com/yihu/wlyy/repository/job/QuartzJobConfigDao.java

@ -18,7 +18,7 @@ public interface QuartzJobConfigDao extends PagingAndSortingRepository<QuartzJob
    @Query(" FROM QuartzJobConfig a WHERE a.status=?1 and a.del='1'")
    List<QuartzJobConfig> findByAll(String s);
    @Query(" FROM QuartzJobConfig a WHERE a.id in (1,2,3,4,5,6,7,8,9,10)  and a.del='1' ")
    @Query(" FROM QuartzJobConfig a WHERE a.id in (1,2,3,4,5,6,7,8,9,10,12)  and a.del='1' ")
    List<QuartzJobConfig> findByIds();
    @Query(" FROM QuartzJobConfig a WHERE a.id=?1 and a.del='1'")

+ 8 - 0
src/main/java/com/yihu/wlyy/repository/patient/PatientDiseaseDao.java

@ -23,6 +23,14 @@ public interface PatientDiseaseDao extends PagingAndSortingRepository<PatientDis
     */
    List<PatientDisease> findByPatient(String patient);
    /**
     * 根据居民code获取居民疾病
     *
     * @param patient
     * @return
     */
    List<PatientDisease> findByPatientAndSignType(String patient,String signType);
    /**
     * 根据居民code获取居民疾病
     *

+ 70 - 3
src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.address.City;
import com.yihu.wlyy.entity.address.Province;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.ConsultTeamDoctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
@ -13,11 +14,13 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.WlyyPatientSick;
import com.yihu.wlyy.repository.address.CityDao;
import com.yihu.wlyy.repository.address.ProvinceDao;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
@ -81,6 +84,8 @@ public class DoctorInfoService extends BaseService {
    @Autowired
    private SignFamilyDao signFamilyDao;
    private ConsultTeamDao consultTeamDao;
    /**
     * 获取医生的签约病人
     *
@ -604,7 +609,7 @@ public class DoctorInfoService extends BaseService {
        return doctorDao.findAll(spec, pageRequest);
    }
    public Page<Doctor> findFamousDoctor(String key, int page, int pageSize) {
    public Page<Doctor> findFamousDoctor(String key,Integer type, int page, int pageSize) {
        if (pageSize <= 0) {
            pageSize = 10;
        }
@ -618,11 +623,73 @@ public class DoctorInfoService extends BaseService {
        // 查询全部
        Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
        if (StringUtils.isNotEmpty(key)) {
            filters.put("name", new SearchFilter("name", SearchFilter.Operator.LIKE, key));
                filters.put("name", new SearchFilter("name", SearchFilter.Operator.LIKE, key));
        }
        filters.put("isFamous", new SearchFilter("isFamous", SearchFilter.Operator.EQ, 1));
        filters.put("isFamous", new SearchFilter("isFamous", SearchFilter.Operator.EQ, type));
        filters.put("level", new SearchFilter("level", SearchFilter.Operator.EQ, 1));
        Specification<Doctor> spec = DynamicSpecifications.bySearchFilter(filters.values(), Doctor.class);
        return doctorDao.findAll(spec, pageRequest);
    }
    public void updateTeamHealthDoctor(String newDoctorCode, String oldDoctorCode, String patient)throws Exception {
        ConsultTeam consultTeam= consultTeamDao.findByParientCodeAndSignTypeAndDoctor(patient,oldDoctorCode,"2");
        if(consultTeam!=null){
            throw new Exception("存在没有关闭的健康咨询");
        }
        Patient patientObj=patientDao.findByCode(patient);
        Doctor newD=doctorDao.findByCode(newDoctorCode);
        //得到患者的签约信息
        SignFamily signFamily= signFamilyDao.findByPatient(patient);
        //修改签约中的健康管理师
        signFamily.setDoctorHealth(newD.getCode());
        signFamily.setDoctorHealthName(newD.getName());
        //修改医生服务团队 删除旧的健康管理师
        DoctorTeamMember doctorTeamMember=  doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(),oldDoctorCode);
        doctorTeamMember.setDel("0");
        //添加新的健康管理师到服务团队里
        DoctorTeamMember  newDoctorTeamMember=new DoctorTeamMember();
        newDoctorTeamMember.setTeam(signFamily.getTeamCode());
        newDoctorTeamMember.setCzrq(new Date());
        newDoctorTeamMember.setName(newD.getName());
        newDoctorTeamMember.setMemberCode(newD.getCode());
        newDoctorTeamMember.setType(3);
        newDoctorTeamMember.setSignType("2");
        newDoctorTeamMember.setDel("1");
        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-",""));
        doctorTeamDoctor.save(newDoctorTeamMember);
        String groupCode="";
        //把患者移除旧的健康管理师的患者表
        List<DoctorPatientGroupInfo>  oldDoctorPatientGroupInfos=doctorPatientGroupInfoDao.findByPatientAndDoctor(patient,oldDoctorCode);
        for(DoctorPatientGroupInfo doctorPatientGroupInfo:oldDoctorPatientGroupInfos){
            doctorPatientGroupInfo.setCzrq(new Date());
            doctorPatientGroupInfo.setStatus(0);//设置为无效
            //保存原来旧的分组
            if(Integer.valueOf(doctorPatientGroupInfo.getGroup())<4){
                groupCode=doctorPatientGroupInfo.getGroup()+"";
            }
        }
        //把患者加到新的健康管理师的患者表
        DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
        doctorPatientGroupInfo.setCzrq(new Date());
        doctorPatientGroupInfo.setDoctor(newDoctorCode);
        doctorPatientGroupInfo.setStatus(1);
        doctorPatientGroupInfo.setPatient(patientObj.getCode());
        doctorPatientGroupInfo.setPname(patientObj.getName());
        doctorPatientGroupInfo.setPartAmount(0);
        doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
        doctorPatientGroupInfo.setQyrq(new Date());
        doctorPatientGroupInfo.setSignType("2");//家庭签约
        doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
    }
    public void updateTeamHealthDoctors(String newDoctorCode, String oldDoctorCode, String patients)throws Exception {
        String [] patiensString=patients.split(",");
        for (int i=0;i<patiensString.length;i++){
            updateTeamHealthDoctor(newDoctorCode,oldDoctorCode,patiensString[i]);
        }
    }
}

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

@ -23,6 +23,7 @@ import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.util.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -332,6 +333,9 @@ public class ConsultTeamService extends ConsultService {
				consultTeamDao.increasePatientRead(log.getConsult());
				// 医生有回复
				consultTeamDoctorDao.updateReply(log.getConsult(), teamOrDoctor);
				//shenzaixin v1.2.0 推送消息给患者
				HttpUtil.sendWeixinWebsocketMsg(patient,"data={busiType:'qianyuezixun',msgid:'"+log.getId()+"'}");
			} else if (type == 0 || type == 2) {
				// 查询相关联的医生
				Iterable<ConsultTeamDoctor> iterable = consultTeamDoctorDao.findByConsult(log.getConsult());
@ -756,4 +760,14 @@ public class ConsultTeamService extends ConsultService {
		// 添加医生咨询日志
		addLogs(ct);
	}
	/**
	 * 根据健康管理师和患者 找到正在进行中的咨询
	 * @param patientCode
	 * @param doctor
     */
	public ConsultTeam getConsultByPatientAndDoctor(String patientCode, String doctor) {
		ConsultTeam consultTeam= consultTeamDao.findByParientCodeAndSignTypeAndDoctor(patientCode,doctor,"2");
		return consultTeam;
	}
}

+ 10 - 0
src/main/java/com/yihu/wlyy/service/app/disease/PatientDiseaseService.java

@ -56,6 +56,16 @@ public class PatientDiseaseService extends BaseService {
        return patientDiseaseDao.findByPatient(patient);
    }
    /**
     * 根据居民code查询疾病
     *
     * @param patient 居民code
     * @return
     */
    public List<PatientDisease> getPatientDiseaseSs(String patient) {
        return patientDiseaseDao.findByPatientAndSignType(patient,"1");
    }
    /**
     * 更新患者疾病表
     *

+ 2 - 0
src/main/java/com/yihu/wlyy/service/app/scheduling/DoctorWorkTimeService.java

@ -197,6 +197,7 @@ public class DoctorWorkTimeService extends BaseService {
                workTime = new WlyyDoctorWorkTime();
                workTime.setDoctor(doctor);
                workTime.setDoctorName(doc.getName());
                workTime.setFamousConsultTimes(0);
            }
            // 设置是否接受咨询
@ -396,6 +397,7 @@ public class DoctorWorkTimeService extends BaseService {
                workTime = new WlyyDoctorWorkTime();
                workTime.setDoctor(doctor);
                workTime.setDoctorName(doc.getName());
                workTime.setReceiveConsult("1");
            }
            // 设置名医咨询次数

+ 89 - 36
src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -22,7 +22,7 @@ public class HttpUtil {
	/**
	 * 向指定URL发送GET方法的请求
	 * 
	 *
	 * @param url
	 *            发送请求的URL
	 * @param param
@ -65,7 +65,7 @@ public class HttpUtil {
	/**
	 * 向指定 URL 发送POST方法的请求
	 * 
	 *
	 * @param url
	 *            发送请求的 URL带上参数
	 * @param param
@ -73,38 +73,38 @@ public class HttpUtil {
	 * @return 所代表远程资源的响应结果
	 */
	public static String sendPost(String url, String param) {
					StringBuffer buffer = new StringBuffer();
					PrintWriter out = null;
					BufferedReader in = null;
					HttpURLConnection conn = null;
					try {
						URL realUrl = new URL(url);
						// 打开和URL之间的连接
						conn = (HttpURLConnection) realUrl.openConnection();
						conn.setRequestMethod("POST");
						conn.setDoOutput(true);
						conn.setDoInput(true);
						conn.setUseCaches(false);
						conn.setRequestProperty("Content-Type", "application/text");
						conn.setRequestProperty("accept", "*/*");
						conn.setRequestProperty("connection", "Keep-Alive");
						conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
						OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
						osw.write(param.toString());
						osw.flush();
						// 读取返回内容
						BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
						String temp;
						while ((temp = br.readLine()) != null) {
							buffer.append(temp);
							buffer.append("\n");
						}
					} catch (Exception e) {
						logger.error("push message error:", e);
					} finally {
						try {
							if (out != null) {
		StringBuffer buffer = new StringBuffer();
		PrintWriter out = null;
		BufferedReader in = null;
		HttpURLConnection conn = null;
		try {
			URL realUrl = new URL(url);
			// 打开和URL之间的连接
			conn = (HttpURLConnection) realUrl.openConnection();
			conn.setRequestMethod("POST");
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.setUseCaches(false);
			conn.setRequestProperty("Content-Type", "application/text");
			conn.setRequestProperty("accept", "*/*");
			conn.setRequestProperty("connection", "Keep-Alive");
			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
			OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
			osw.write(param.toString());
			osw.flush();
			// 读取返回内容
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
			String temp;
			while ((temp = br.readLine()) != null) {
				buffer.append(temp);
				buffer.append("\n");
			}
		} catch (Exception e) {
			logger.error("push message error:", e);
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
@ -119,7 +119,7 @@ public class HttpUtil {
	/**
	 * 消息推送
	 * 
	 *
	 * @param receiver 消息接收人
	 * @param msgType 消息类型
	 * @param title 消息标题
@ -185,9 +185,62 @@ public class HttpUtil {
		return false;
	}
	/**
	 * 发送消息到websocket服务器,然后由websocket服务器中转给微信端
	 * @param userid 接收数据的患者id
	 * @param data 内容
	 * @return 推送成功:{"errno":"0","errmsg":""},推送失败:{"errno":"1","errmsg":"User is not online"}
	 * @author shenzaixin
	 */
	public static String sendWeixinWebsocketMsg(String userid,String data){
		PrintWriter out = null;
		BufferedReader in = null;
		HttpURLConnection conn = null;
		try {
			String url = SystemConf.getInstance().getWeixinWebsocketServer() + "?userid=" + userid + "&data=" + data;
			URL realUrl = new URL(url);
			// 打开和URL之间的连接
			conn = (HttpURLConnection) realUrl.openConnection();
			conn.setRequestMethod("GET");
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.setUseCaches(false);
			conn.setRequestProperty("Content-Type", "application/json");
//			OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
//			osw.write(param.toString());
//			osw.flush();
			// 读取返回内容
			StringBuffer buffer = new StringBuffer();
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
			String temp;
			while ((temp = br.readLine()) != null) {
				buffer.append(temp);
			}
			System.out.println(buffer.toString());
			JSONObject json = new JSONObject(buffer.toString());
			return json.toString();
		} catch (Exception e) {
			logger.error("push message error:", e);
			return "{\"errno\":\"1\",\"errmsg\":\""+e.getMessage()+"\"}";
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
					in.close();
				}
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}
	}
	/**
	 * 向指定 URL 发送POST方法的请求
	 * 
	 *
	 * @param url 发送请求的 URL带上参数
	 * @param param POST参数。
	 * @param charset 编码格式

+ 8 - 0
src/main/java/com/yihu/wlyy/util/SystemConf.java

@ -21,6 +21,10 @@ public class SystemConf {
	// 消息推送服务器地址
	private static final String MSG_PUSH_SERVER = "msg_push_server";
	//微信端websocket服务地址
	private static final String WEIXIN_WEBSOCKET_SERVER = "weixin_websocket_server";
	// 服务器地址
	private static final String SERVER_URL = "server_url";
	// 图片资源服务器地址
@ -245,6 +249,10 @@ public class SystemConf {
		return getSystemProperties().getProperty(MSG_PUSH_SERVER);
	}
	public String getWeixinWebsocketServer() {
		return getSystemProperties().getProperty(WEIXIN_WEBSOCKET_SERVER);
	}
	public String getServerUrlStr() {
		String temp = getSystemProperties().getProperty(SERVER_URL);
		if (StringUtils.isEmpty(temp)) {

+ 28 - 2
src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.doctor.account;
import java.util.List;
import java.util.Map;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.DoctorComment;
@ -325,6 +326,7 @@ public class DoctorController extends BaseController {
    /**
     * 名医列表
     * @param key 医生名称
     * @param type 是否是名医 1是  0不是
     * @param page 当前页
     * @param pagesize 每页显示条数
     * @return
@ -333,11 +335,12 @@ public class DoctorController extends BaseController {
    @ResponseBody
    public String findFamousDoctor(
            @RequestParam(required = false) String key,
            Integer type,
            int page,
            int pagesize) {
        try {
            JSONArray array = new JSONArray();
            Page<Doctor> list = doctorInfoService.findFamousDoctor(key, page, pagesize);
            Page<Doctor> list = doctorInfoService.findFamousDoctor(key,type, page, pagesize);
            if (list != null) {
                for (Doctor doctor : list) {
                    JSONObject json = new JSONObject();
@ -475,6 +478,10 @@ public class DoctorController extends BaseController {
                json.put("level", temp.getLevel().intValue());
                //身份证号
                json.put("idcard", temp.getIdcard());
                //是否认证
                json.put("isCertified", temp.getIscertified());
                //是否名医
                json.put("isFamous", temp.getIsFamous());
                return write(200, "医生信息查询成功!", "data", json);
            } else {
@ -1407,7 +1414,26 @@ public class DoctorController extends BaseController {
    @ResponseBody
    public String setFamous(String doctorCode, Integer status) {
        try {
            doctorInfoService.setFamous(doctorCode,status);
           doctorInfoService.setFamous(doctorCode,status);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
    /**
     * 转换团队中的健康管理师
     * @param  newDoctorCode 新的健康管理师的code
     * @param oldDoctorCode 旧的健康管理师的code
     * @param patients 患者code 多个逗号分隔
     * @return
     */
    @RequestMapping(value = "/updateTeamHealthDoctors")
    @ResponseBody
    public String updateTeamHealthDoctors(String newDoctorCode,String oldDoctorCode,String patients) {
        try {
            doctorInfoService.updateTeamHealthDoctors(newDoctorCode,oldDoctorCode,patients);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();

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

@ -86,7 +86,7 @@ public class DoctorConsultController extends WeixinBaseController {
				json.put("comment", consult.getCommentContent());
				// 设置评价星级
				json.put("star", consult.getCommentStar());
				// 设置咨询类型:1三师咨询,2家庭医生咨询
				// 设置咨询类型:1三师咨询,2家庭医生咨询 6名医咨询
				json.put("type", consult.getType());
				// 设置咨询时间
				json.put("time", DateUtil.dateToStr(consult.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
@ -374,4 +374,28 @@ public class DoctorConsultController extends WeixinBaseController {
		}
	}
	/**
	 * 根据医生code和和患者code判断是否有存在进行中的咨询
	 * @param patientCode
	 * @param doctor
	 * @return
     */
	@RequestMapping(value = "getConsultByPatientAndDoctor")
	@ResponseBody
	public String getConsultByPatientAndDoctor(String patientCode,String doctor) {
		try {
			JSONObject json = new JSONObject();
			ConsultTeam consultTeam= consultTeamService.getConsultByPatientAndDoctor(patientCode,doctor);
			if(consultTeam==null){
				json.put("hasConsult","0");
			}else{
				json.put("hasConsult","1");
			}
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "回复失败!");
		}
	}
}

+ 51 - 30
src/main/java/com/yihu/wlyy/web/doctor/patient/PatientDiseaseController.java

@ -13,17 +13,18 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
/**
 * 患者疾病控制器
 *
 * <p>
 * Created by lyr on 2016/09/09.
 */
@RestController
@RequestMapping(value = "/doctor/patient")
@Api(description = "患者疾病")
public class PatientDiseaseController extends BaseController{
public class PatientDiseaseController extends BaseController {
    @Autowired
    PatientDiseaseService patientDiseaseService;
@ -37,20 +38,20 @@ public class PatientDiseaseController extends BaseController{
     * @return
     */
    @RequestMapping(value = "/disease")
    public String getPatientDisease(String patient){
        try{
            if(StringUtils.isEmpty(patient)){
                return error(-1,"患者不能为空");
    public String getPatientDisease(String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");
            }
            if(StringUtils.isEmpty(redisTemplate.opsForValue().get("disease:" + patient))) {
            if (StringUtils.isEmpty(redisTemplate.opsForValue().get("disease:" + patient))) {
                List<PatientDisease> diseases = patientDiseaseService.getPatientDisease(patient);
                return write(200,"查询成功","data",new JSONArray(diseases));
            }else{
                return write(200,"查询成功","data",new JSONArray(redisTemplate.opsForValue().get("disease:" + patient)));
                return write(200, "查询成功", "data", new JSONArray(diseases));
            } else {
                return write(200, "查询成功", "data", new JSONArray(redisTemplate.opsForValue().get("disease:" + patient)));
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
            return error(-1, "查询失败");
        }
    }
@ -62,16 +63,36 @@ public class PatientDiseaseController extends BaseController{
     * @return
     */
    @RequestMapping(value = "/disease_update")
    public String updatePatientDisease(String patient,String disease){
        try{
            if(patientDiseaseService.updatePatientDisease(patient,disease)){
                return write(200,"更新成功");
            }else{
                return error(-1,"更新失败");
    public String updatePatientDisease(String patient, String disease) {
        try {
            List<PatientDisease> diseases = patientDiseaseService.getPatientDiseaseSs(patient);
            if (diseases != null && diseases.size() > 0) {
                List<String> dis = Arrays.asList(disease.split(","));
                if (dis != null && dis.size() > 0) {
                    int flag = 0;
                    for(PatientDisease dise : diseases){
                        if(dis.contains(dise.getDel())){
                            flag++;
                        }
                    }
                    if(flag != diseases.size()){
                        return error(-1, "三师签约疾病不能更改");
                    }
                } else {
                    return error(-1, "三师签约疾病不能更改");
                }
            }
            if (patientDiseaseService.updatePatientDisease(patient, disease)) {
                return write(200, "更新成功");
            } else {
                return error(-1, "更新失败");
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"更新失败");
            return error(-1, "更新失败");
        }
    }
@ -81,12 +102,12 @@ public class PatientDiseaseController extends BaseController{
     * @return
     */
    @RequestMapping(value = "/to_redis")
    public String updateToRedid(){
        try{
    public String updateToRedid() {
        try {
            patientDiseaseService.updateToRedis();
            return write(200,"更新成功");
        }catch (Exception e){
            return error(-1,"更新失败");
            return write(200, "更新成功");
        } catch (Exception e) {
            return error(-1, "更新失败");
        }
    }
@ -96,13 +117,13 @@ public class PatientDiseaseController extends BaseController{
     * @return
     */
    @RequestMapping(value = "/to_disease")
    public String updateToDisease(){
        try{
    public String updateToDisease() {
        try {
            patientDiseaseService.updateToDisease();
            return write(200,"更新成功");
        }catch (Exception e){
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"更新失败");
            return error(-1, "更新失败");
        }
    }

+ 1 - 0
src/main/resources/system.properties

@ -74,6 +74,7 @@ wechat_token=27eb3bb24f149a7760cf1bb154b08040
im_group_server=http://120.41.252.108:3031/group/sendgroupmsg.im
msg_push_server=http://120.41.252.108:3031/push/sendmsg.im
weixin_websocket_server = http://172.19.103.76:8000/user/senddata.do
#file upload temp path
upload_temp_path=/var/local/temp