Browse Source

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

lyr 8 years ago
parent
commit
e9f27a477c

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/login/LoginLog.java

@ -13,7 +13,7 @@ import java.util.Date;
@Entity
@Table(name = "wlyy_login_log")
public class LoginLog  extends IdEntity {
    private String loginType;//1 短信登录  2 密码登录
    private String loginType;//1 短信登录  2 密码登录 3家人登陆
    private String userCode;//登录用户主键 患者code或者医生code
    private String userType;//1 患者 2医生
    private Long tokenId;//登录的tokenid

+ 267 - 181
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -6,10 +6,13 @@ import com.yihu.wlyy.entity.address.Street;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.demographic.DemographicInfo;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.address.CityDao;
import com.yihu.wlyy.repository.address.ProvinceDao;
import com.yihu.wlyy.repository.address.StreetDao;
@ -19,10 +22,16 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientInvitationLogDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.family.FamilyMemberService;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.util.MD5;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -30,193 +39,270 @@ import org.springframework.transaction.annotation.Transactional;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.EncodesUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * 患者基本信息类.
 * 
 *
 * @author George
 */
@Component
@Transactional
public class PatientInfoService extends BaseService {
	@Autowired
	private PatientDao patientDao;
	@Autowired
	private ProvinceDao provinceDao;
	@Autowired
	private CityDao cityDao;
	@Autowired
	private TownDao townDao;
	@Autowired
	private StreetDao streetDao;
	@Autowired
	private PatientInvitationLogDao patientInviteLogDao;
	@Autowired
	private TblBasicDao tblBasicDao;
	@Autowired
	private SocialSecurityInfoDao socialSecurityInfoDao;
	@Autowired
	SMSService smsService;
	@Autowired
	SignFamilyDao signFamilyDao;
	/**
	 * 患者更换手机号
	 *
	 * @param patient  患者code
	 * @param mobile  新手机号
	 * @param captcha 验证码
	 * @return
	 */
	public int changeMobile(String patient, String mobile, String captcha,int type) {
		Patient p = patientDao.findByCode(patient);
		if (p == null) {
			return -1;
		}
		Patient pMobile = patientDao.findByMobile(mobile);
		if (pMobile != null && !pMobile.getCode().equals(patient)) {
			return -2;
		}
		// 验证码验证
		int smsCheck = smsService.check(mobile, type == 1 ? 8 : 9, captcha);
		// 验证失败,不允许变更
		if (smsCheck != 1) {
			return -3;
		}
		p.setMobile(mobile);
		signFamilyDao.updatePatientMobile(p.getCode(),mobile);
		return 1;
	}
	/**
	 * 手机号是否注册
	 *
	 * @param mobile
	 * @return
	 */
	public int isMobileRegister(String mobile) {
		Patient p = patientDao.findByMobile(mobile);
		if (p != null) {
			return 1;
		} else {
			return 0;
		}
	}
	/**
	 * 根据患者标识查询患者信息
	 * @param code
	 * @return
	 */
	public Patient findByCode(String code) {
		return patientDao.findByCode(code);
	}
	/**
	 * 根据患者身份证号码查询患者信息
	 * @param idcard
	 * @return
	 */
	public Patient findByIdcard(String idcard) {
		return patientDao.findByIdcard(idcard);
	}
	// 根據病情等级获取患者信息
	public Iterable<Patient> findInfoByLevel(int level) {
		return patientDao.findInfoByLevel(level);
	}
	/**
	 * 更新患者基本信息
	 * @param patient
	 */
	public Patient updatePatient(Patient patient) {
		if (StringUtils.isNotEmpty(patient.getStreet())) {
			Street street = streetDao.findByCode(patient.getStreet());
			patient.setStreetName(street.getName());
		}else{
			patient.setStreetName("");
		}
		Province province = provinceDao.findByCode(patient.getProvince());
		if (province != null) {
			patient.setProvinceName(province.getName());
		}else{
			patient.setProvinceName("");
		}
		City city = cityDao.findByCode(patient.getCity());
		if (city != null) {
			patient.setCityName(city.getName());
		}else{
			patient.setCityName("");
		}
		Town town = townDao.findByCode(patient.getTown());
		if (town != null) {
			patient.setTownName(town.getName());
		}else{
			patient.setTownName("");
		}
		return patientDao.save(patient);
	}
	public Patient updateUser(Patient patient) {
		return patientDao.save(patient);
	}
	/**
	 * 修改患者密码
	 * @param patient
	 */
	public void updatePatientPwd(Patient patient) {
		EncodesUtil.entryptPassword(patient);
		patientDao.save(patient);
	}
	public Patient invilogCode(String invilogCode) {
		PatientInvitationLog patientInviteLog=patientInviteLogDao.findOne(invilogCode);
		String patientCode=patientInviteLog.getInvitePatientCode();
		Patient patient=patientDao.findByCode(patientCode);
		return patient;
	}
	public boolean validatePatient(String name, String idCard, String ssc) {
		DemographicInfo demographicInfo =tblBasicDao.findByIdCard(idCard);
		SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18(idCard);
		if(demographicInfo !=null&& socialSecurityInfo !=null){
			String nameTemp= demographicInfo.getName();
		}
		return false;
	}
	public void checkMobile(String mobile) throws Exception{
		Patient p=patientDao.findByMobile(mobile);
		if(p!=null){
			throw  new Exception("手机号已经被注册");
		}
	}
	@Transactional
	public void updatePassword(String newPassword1, String newPassword2, String oldPassword, String patientCode) throws Exception{
		if(!newPassword1.equals(newPassword2)){
			throw new Exception("新密码不一致");
		}
		if(newPassword1.equals(oldPassword)){
			throw new Exception("新旧密码一致");
		}
		Patient patient=patientDao.findByCode(patientCode);
		String oldPasswordTemp= MD5.GetMD5Code(oldPassword+patient.getSalt());
		if(!oldPasswordTemp.equals(patient.getPassword())){
			throw new Exception("旧密码错误");
		}
		String newPassword1Temp= MD5.GetMD5Code(newPassword1+patient.getSalt());
		patient.setPassword(newPassword1Temp);
	}
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private ProvinceDao provinceDao;
    @Autowired
    private CityDao cityDao;
    @Autowired
    private TownDao townDao;
    @Autowired
    private StreetDao streetDao;
    @Autowired
    private PatientInvitationLogDao patientInviteLogDao;
    @Autowired
    private TblBasicDao tblBasicDao;
    @Autowired
    private SocialSecurityInfoDao socialSecurityInfoDao;
    @Autowired
    SMSService smsService;
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    FamilyMemberService familyMemberService;
    @Autowired
    TokenService tokenService;
    @Autowired
    FamilyService familyService;
    @Autowired
    LoginLogService loginLogService;
    @Autowired
    PatientService patientService;
    /**
     * 患者更换手机号
     *
     * @param patient 患者code
     * @param mobile  新手机号
     * @param captcha 验证码
     * @return
     */
    public int changeMobile(String patient, String mobile, String captcha, int type) {
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            return -1;
        }
        Patient pMobile = patientDao.findByMobile(mobile);
        if (pMobile != null && !pMobile.getCode().equals(patient)) {
            return -2;
        }
        // 验证码验证
        int smsCheck = smsService.check(mobile, type == 1 ? 8 : 9, captcha);
        // 验证失败,不允许变更
        if (smsCheck != 1) {
            return -3;
        }
        p.setMobile(mobile);
        signFamilyDao.updatePatientMobile(p.getCode(), mobile);
        return 1;
    }
    /**
     * 手机号是否注册
     *
     * @param mobile
     * @return
     */
    public int isMobileRegister(String mobile) {
        Patient p = patientDao.findByMobile(mobile);
        if (p != null) {
            return 1;
        } else {
            return 0;
        }
    }
    /**
     * 切换家人账号
     *
     * @param patient 当前居民
     * @param family  待切换家人
     * @return
     */
    public JSONObject switchFamilyAccount(String patient, String family, String openid) throws Exception {
        JSONObject result = new JSONObject();
        Patient fp = patientDao.findByCode(family);
        // 家庭成员信息查询失败
        if (fp == null) {
            result.put("status", -1);
            return result;
        }
        PatientFamilyMember member = familyMemberService.getPatientFamilyMember(patient, family);
        // 家庭成员中不存在该人
        if (member == null) {
            result.put("status", -2);
            return result;
        }
        LoginLog loginLog = new LoginLog();
        loginLog.setCreateTime(new Date());
        loginLog.setPhone(fp.getMobile());
        loginLog.setUserType("1");
        loginLog.setType("3");
        // 用户校验通过,生成token
        Token token = tokenService.newTxToken(fp.getCode(), openid);
        Map<Object, Object> map = new HashMap<Object, Object>();
        map.put("id", fp.getId());
        map.put("uid", fp.getCode());
        map.put("name", fp.getName());
        map.put("token", token.getToken());
        map.put("photo", fp.getPhoto());
        // 绑定用户手机号和openid
        if (!StringUtils.equals(fp.getOpenid(), openid)) {
            fp.setOpenid(openid);
            patientService.updatePatient(fp);
        }
        if (StringUtils.isNoneEmpty(openid)) {
            //发送微信模板
            familyService.sendWXMessage(fp);
        }
        loginLogService.saveLog(loginLog);
        result.put("status", 1); // 切换账号成功
        result.put("data", map);
        return result;
    }
    /**
     * 根据患者标识查询患者信息
     *
     * @param code
     * @return
     */
    public Patient findByCode(String code) {
        return patientDao.findByCode(code);
    }
    /**
     * 根据患者身份证号码查询患者信息
     *
     * @param idcard
     * @return
     */
    public Patient findByIdcard(String idcard) {
        return patientDao.findByIdcard(idcard);
    }
    // 根據病情等级获取患者信息
    public Iterable<Patient> findInfoByLevel(int level) {
        return patientDao.findInfoByLevel(level);
    }
    /**
     * 更新患者基本信息
     *
     * @param patient
     */
    public Patient updatePatient(Patient patient) {
        if (StringUtils.isNotEmpty(patient.getStreet())) {
            Street street = streetDao.findByCode(patient.getStreet());
            patient.setStreetName(street.getName());
        } else {
            patient.setStreetName("");
        }
        Province province = provinceDao.findByCode(patient.getProvince());
        if (province != null) {
            patient.setProvinceName(province.getName());
        } else {
            patient.setProvinceName("");
        }
        City city = cityDao.findByCode(patient.getCity());
        if (city != null) {
            patient.setCityName(city.getName());
        } else {
            patient.setCityName("");
        }
        Town town = townDao.findByCode(patient.getTown());
        if (town != null) {
            patient.setTownName(town.getName());
        } else {
            patient.setTownName("");
        }
        return patientDao.save(patient);
    }
    public Patient updateUser(Patient patient) {
        return patientDao.save(patient);
    }
    /**
     * 修改患者密码
     *
     * @param patient
     */
    public void updatePatientPwd(Patient patient) {
        EncodesUtil.entryptPassword(patient);
        patientDao.save(patient);
    }
    public Patient invilogCode(String invilogCode) {
        PatientInvitationLog patientInviteLog = patientInviteLogDao.findOne(invilogCode);
        String patientCode = patientInviteLog.getInvitePatientCode();
        Patient patient = patientDao.findByCode(patientCode);
        return patient;
    }
    public boolean validatePatient(String name, String idCard, String ssc) {
        DemographicInfo demographicInfo = tblBasicDao.findByIdCard(idCard);
        SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18(idCard);
        if (demographicInfo != null && socialSecurityInfo != null) {
            String nameTemp = demographicInfo.getName();
        }
        return false;
    }
    public void checkMobile(String mobile) throws Exception {
        Patient p = patientDao.findByMobile(mobile);
        if (p != null) {
            throw new Exception("手机号已经被注册");
        }
    }
    @Transactional
    public void updatePassword(String newPassword1, String newPassword2, String oldPassword, String patientCode) throws Exception {
        if (!newPassword1.equals(newPassword2)) {
            throw new Exception("新密码不一致");
        }
        if (newPassword1.equals(oldPassword)) {
            throw new Exception("新旧密码一致");
        }
        Patient patient = patientDao.findByCode(patientCode);
        String oldPasswordTemp = MD5.GetMD5Code(oldPassword + patient.getSalt());
        if (!oldPasswordTemp.equals(patient.getPassword())) {
            throw new Exception("旧密码错误");
        }
        String newPassword1Temp = MD5.GetMD5Code(newPassword1 + patient.getSalt());
        patient.setPassword(newPassword1Temp);
    }
}

+ 25 - 12
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -46,17 +46,17 @@ public class FamilyMemberService extends BaseService {
    @Autowired
    JdbcTemplate jdbcTemplate;
    Map<Integer,String> relations = new HashMap<>();
    Map<Integer, String> relations = new HashMap<>();
    @PostConstruct
    public void init(){
        relations.put(0,"其他");
        relations.put(1,"父亲");
        relations.put(2,"母亲");
        relations.put(3,"老公");
        relations.put(4,"老婆");
        relations.put(5,"儿子");
        relations.put(6,"女儿");
    public void init() {
        relations.put(0, "其他");
        relations.put(1, "父亲");
        relations.put(2, "母亲");
        relations.put(3, "老公");
        relations.put(4, "老婆");
        relations.put(5, "儿子");
        relations.put(6, "女儿");
    }
    /**
@ -84,7 +84,7 @@ public class FamilyMemberService extends BaseService {
            return -2;
        }
        if(relation < 5) {
        if (relation < 5) {
            List<PatientFamilyMember> familyMembers = memberDao.findByPatientAndFamilyRelation(patient, relation);
            if (familyMembers != null && familyMembers.size() > 0) {
@ -95,9 +95,9 @@ public class FamilyMemberService extends BaseService {
        // 验证码验证
        if (StringUtils.isNotEmpty(captcha)) {
            int checkStatus = smsService.check(m.getMobile(), 10, captcha);
            if(checkStatus == -2){
            if (checkStatus == -2) {
                return -6;  // 验证码过期
            } else if(checkStatus == -1){
            } else if (checkStatus == -1) {
                return -3; // 验证码错误
            }
        }
@ -324,6 +324,19 @@ public class FamilyMemberService extends BaseService {
        return resultArray;
    }
    /**
     * 查询居民的某个家庭成员
     *
     * @param patient
     * @param family
     * @return
     */
    public PatientFamilyMember getPatientFamilyMember(String patient,String family) {
        PatientFamilyMember member = memberDao.findByPatientAndFamilyMember(patient,family);
        return member;
    }
    /**
     * 家庭关系转换
     *

+ 180 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/ExpensesRemindService.java

@ -0,0 +1,180 @@
package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 缴费提醒服务
 * <p>
 * Created by lyr on 2016/10/24.
 */
@Service
public class ExpensesRemindService extends BaseService {
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    DoctorDao doctorDao;
    @Autowired
    PatientDao patientDao;
    @Autowired
    HospitalDao hospitalDao;
    @Autowired
    SMSService smsService;
    @Autowired
    StringRedisTemplate redisTemplate;
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
    @Autowired
    JdbcTemplate jdbcTemplate;
    /**
     * 缴费提醒
     *
     * @param doctor 医生
     * @throws Exception
     */
    @Async
    public void remindPatientExpensesAll(String doctor) throws Exception {
        try {
            Doctor doc = doctorDao.findByCode(doctor);
            if (doc == null) {
                throw new Exception("doctor info can not find");
            }
            Hospital hos = hospitalDao.findByCode(doc.getHospital());
            if (hos == null) {
                throw new Exception("hospital info can not find");
            }
            RemindAll(doc, hos);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 所有未缴费提醒
     *
     * @param doc
     * @param hos
     */
    public void RemindAll( Doctor doc, Hospital hos) {
        try {
            String sql = "select distinct a.patient from " +
                    " (select patient,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len " +
                    "     from " +
                    "        wlyy_sign_family " +
                    "     where "
                    + (doc.getLevel() == 2 ? "doctor" : "doctor_health") + " = ? " +
                    "        and status > 0 " +
                    "        and type = 2 " +
                    "        order by begin desc ) a" +
                    " where a.expenses_status = '0' or a.len < 1";
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doc.getCode()});
            if (result != null && result.size() > 0) {
                for (Map<String, Object> map : result) {
                    Patient p = patientDao.findByCode(String.valueOf(map.get("patient")));
                    if (p != null) {
                        remindPatientExpenses(p, doc, hos);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 提醒患者缴费
     *
     * @param patient 患者
     * @param doctor  医生
     * @return
     */
    public int remindPatientExpenses(String patient, String doctor) {
        try {
            Doctor doc = doctorDao.findByCode(doctor);
            if (doc == null) {
                throw new Exception("doctor info can not find");
            }
            Hospital hos = hospitalDao.findByCode(doc.getHospital());
            if (hos == null) {
                throw new Exception("hospital info can not find");
            }
            Patient p = patientDao.findByCode(patient);
            if (p == null) {
                throw new Exception("patient info can not find");
            }
            remindPatientExpenses(p, doc, hos);
            return 1;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }
    /**
     * 提醒患者缴费
     *
     * @param p   患者
     * @param doc 医生
     * @param hos 医院
     * @return
     */
    public void remindPatientExpenses(Patient p, Doctor doc, Hospital hos) throws Exception {
        try {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            if (StringUtils.isNotEmpty(p.getMobile())) {
                // 微信提醒
                JSONObject json = new JSONObject();
                json.put("first", "缴费提醒");
                json.put("doctor", doc.getCode());
                json.put("doctorName", doc.getName());
                json.put("date", DateUtil.dateToStrShort(new Date()));
                json.put("content", "为完成家庭医生签约,尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
                json.put("remark", "");
                // 添加到发送队列
                PushMsgTask.getInstance().putWxMsg(tokenUtils.getAccessToken(), 1, p.getOpenid(), p.getName(), json);
                int result = smsService.sendMsg(p.getMobile(), "厦门市民健康系统】" + doc.getName() + "医生提醒您:为完成家庭医生签约," +
                        "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

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

@ -39,6 +39,7 @@ import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
@ -1554,4 +1555,5 @@ public class FamilyContractService extends BaseService {
    public List<SignFamily> findAllSignByPatient(String patient) {
        return signFamilyDao.findAllSignByPatient(patient);
    }
}

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

@ -42,28 +42,51 @@ public class SignWebService extends BaseService {
     * @param doctorType
     * @return
     */
    public List<Map<String,Object>> getSignWebByDoctor(String doctor, int status,int doctorType) {
    public List<Map<String, Object>> getSignWebByDoctor(String doctor, int status, int doctorType) {
        // 查询语句
        String sql = "select " +
                     "    a.code " +
                     "    ,a.doctor " +
                     "    ,b.code  as  patient" +
                     "    ,b.name " +
                     "    ,b.province_name  as provinceName" +
                     "    ,b.city_name  as cityName" +
                     "    ,b.town_name  as townName" +
                     "    ,b.address " +
                     "    ,b.photo " +
                     "    ,a.status " +
                     "    ,a.id " +
                     "    ,a.apply_date as applyDate" +
                     "    ,a.reason " +
                     "    ,b.street_name as streetName" +
                     "    ,b.sex" +
                     " from " +
                     " ( select * from wlyy_sign_family where " + (doctorType == 2 ?"doctor" : "doctor_health") + " = ? and status = ? and type = 2 order by begin desc ) a " +
                     " ,wlyy_patient b " +
                     " where a.patient = b.code  order by a.begin desc ";
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.name " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                "    ,a.apply_date as applyDate" +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,reason,begin from wlyy_sign_family where " + (doctorType == 2 ? "doctor" : "doctor_health") + " = ? and status = ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by a.begin desc ";
        // 未缴费查询语句
        String sqlExpenses = "select " +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.name " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                "    ,a.apply_date as applyDate" +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family where " + (doctorType == 2 ? "doctor" : "doctor_health") + " = ? and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and (a.expenses_status = '0' or a.len < 1) order by a.begin desc ";
        // 已解约查询语句
        String surrSql = "select " +
                "    a.code " +
@ -82,7 +105,7 @@ public class SignWebService extends BaseService {
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                " from " +
                " ( select * from wlyy_sign_family where " + (doctorType == 2 ?"doctor" : "doctor_health") + " = ? and ( status = ? or status = ? ) and type = 2 order by begin desc ) a " +
                " ( select code,patient,doctor,status,id,apply_date,reason,begin from wlyy_sign_family where " + (doctorType == 2 ? "doctor" : "doctor_health") + " = ? and ( status = ? or status = ? ) and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by a.begin desc ";
@ -90,24 +113,22 @@ public class SignWebService extends BaseService {
        //PageRequest pageRequest = new PageRequest(page - 1, pageSize);
        //1:待签约 2, 待解约 3 已签约,4已经解约
        Page<Object> list = null;
        List<Map<String,Object>> patients = null;
        List<Map<String, Object>> patients = null;
        switch (status) {
            case 1:// 待签约
                //list = signFamilyDao.findToBeSignSignWebByDoctor_0(doctor,0, pageRequest);
                patients = jdbcTemplate.queryForList(sql,new Object[]{doctor,0});
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, 0});
                break;
            case 2:// 待解约
                //list = signFamilyDao.findToBeSignSignWebByDoctor(doctor,doctorType,2, pageRequest);
                patients = jdbcTemplate.queryForList(sql,new Object[]{doctor,2});
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, 2});
                break;
            case 3:// 已签约
                //list = signFamilyDao.findToBeSignSignWebByDoctor(doctor,doctorType,1, pageRequest);
                patients = jdbcTemplate.queryForList(sql,new Object[]{doctor,1});
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, 1});
                break;
            case 4:// 4已经解约
                //list = signFamilyDao.findToBeSignSignWebByDoctor_34(doctor,doctorType, pageRequest);
                patients = jdbcTemplate.queryForList(surrSql,new Object[]{doctor,-3,-4});
                patients = jdbcTemplate.queryForList(surrSql, new Object[]{doctor, -3, -4});
                break;
            case 5: // 未缴费
                patients = jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, 0});
        }
        return patients;

+ 20 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/SMSService.java

@ -103,7 +103,7 @@ public class SMSService extends BaseService {
                throw new Exception("短信发送失败!");
            }
            // 新手机号绑定验证
            sms.setContent("【厦门市民健康系统】" + patient.getName() + "欲添加您为家人,验证码为:" + captcha + "。如其非您的家人,请忽略本短信。");
            sms.setContent("【厦门市民健康系统】" + patient.getName() + "欲添加您为家人,添加成功后,对方可登录您的账号,为您处理各类健康服务。如同意添加,可告知其验证码(" + captcha + ")。");
        } else {
            // 其他验证码
            sms.setContent("验证码:" + captcha);
@ -132,6 +132,25 @@ public class SMSService extends BaseService {
        return "ok";
    }
    /**
     * 发送短信
     *
     * @param mobile
     * @param content
     * @return
     */
    public int sendMsg(String mobile,String content){
        // 调用总部发送信息的接口
        String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(content, mobile), "GBK");
        JSONObject json = toJson(result);
        if (json == null) {
           return 0;
        } else if (json.getInt("result") != 0) {
            return 0;
        }
        return 1;
    }
    /**
     * 验证码校验
     *

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

@ -8,6 +8,7 @@ import java.util.Map;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.sign.ExpensesRemindService;
import com.yihu.wlyy.util.*;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
@ -53,6 +54,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    StringRedisTemplate redisTemplate;
    @Autowired
    MessageService messageService;
    @Autowired
    ExpensesRemindService expensesRemindService;
    /**
     * 医生签约患者列表查询接口
@ -167,7 +170,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            String name,
            String idcard,
            @RequestParam(required = false) String ssc,
            @RequestParam(required = false)String mobile,
            @RequestParam(required = false) String mobile,
            String healthLabel,
            @RequestParam(required = false, defaultValue = "") String customLabel,
            @RequestParam(required = false, defaultValue = "") String disease,
@ -790,12 +793,12 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                    if (StringUtils.isNotBlank(idcard) && (idcard.length() == 15 || idcard.length() == 18)) {
                        json.put("age", IdCardUtil.getAgeForIdcard(idcard));//患者年龄
                        String sex = IdCardUtil.getSexForIdcard(idcard);
                        if(sex.equals("1")){
                            json.put("sex","2");//患者性别
                        } else if(sex.equals("2")){
                            json.put("sex","1");//患者性别
                        }else{
                            json.put("sex",sex);//患者性别
                        if (sex.equals("1")) {
                            json.put("sex", "2");//患者性别
                        } else if (sex.equals("2")) {
                            json.put("sex", "1");//患者性别
                        } else {
                            json.put("sex", sex);//患者性别
                        }
                    } else {
                        json.put("age", "");//患者年龄
@ -810,4 +813,38 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 缴费消息提醒
     *
     * @param patient 患者code
     * @return
     */
    @RequestMapping(value = "/expenses_remind")
    @ResponseBody
    public String remindPatientExpenses(@RequestParam(required = false) String patient
            ,@RequestParam(required = false)  String isAll) {
        try {
            if (StringUtils.isEmpty(patient) && StringUtils.isEmpty(isAll)) {
                return error(-1,"参数不能都为空");
            }
            if (StringUtils.isNotEmpty(patient)) {
                int result = expensesRemindService.remindPatientExpenses(patient, getUID());
                if (result == 1) {
                    return error(200, "提醒成功");
                } else {
                    return error(-1, "提醒失败");
                }
            } else if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
                expensesRemindService.remindPatientExpensesAll(getUID()); //int result =
                return error(200, "提醒成功");
            } else {
                return write(-1, "参数错误");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "提醒失败");
        }
    }
}

+ 208 - 189
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -1,15 +1,19 @@
package com.yihu.wlyy.web.doctor.sign;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@ -23,7 +27,7 @@ import com.yihu.wlyy.web.BaseController;
/**
 * 医生端:签约管理控制类
 * 
 *
 * @author AndyTsai
 */
@ -32,22 +36,26 @@ import com.yihu.wlyy.web.BaseController;
@Api(description = "医生端-签约管理")
public class DoctorSignController extends BaseController {
//	@Autowired
    //	@Autowired
//	private SignContractService signContractService;
	@Autowired
	private PatientInfoService patientInfoService;
	@Autowired
	private SignWebService signWebService;
	
	@Autowired
	private DoctorInfoService infoService;
	/**
	 * 三师签约列表查询
	 * @param type 类型:1已签约,2未过期
	 * @param id
	 * @param pagesize
	 * @return
	 */
    @Autowired
    private PatientInfoService patientInfoService;
    @Autowired
    private SignWebService signWebService;
    @Autowired
    private DoctorInfoService infoService;
    @Autowired
    StringRedisTemplate redisTemplate;
    /**
     * 三师签约列表查询
     *
     * @param type     类型:1已签约,2未过期
     * @param id
     * @param pagesize
     * @return
     */
//	@RequestMapping(value = "list")
//	@ResponseBody
//	public String list( int type,  long id,  int pagesize, @RequestParam(required=false) String patientName) {
@ -90,180 +98,191 @@ public class DoctorSignController extends BaseController {
//			return error(-1, "查询失败!");
//		}
//	}
	
	
	@RequestMapping(value = "list")
	@ResponseBody
	public String list( int type,  long id,  int pagesize, @RequestParam(required=false) String patientName) {
		try {
			String doctor=getUID();
			Page<Object> page = infoService.findPatientByDoctorSign(doctor, id, pagesize,patientName);
			JSONArray array = new JSONArray();
			if (page != null) {
				for (Object obj : page) {
					Object[] temp = (Object[]) obj;
					if (temp == null ) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("id", temp[1]);
					
					// 患者姓名
					json.put("name", temp[2]);
					// 患者头像
					json.put("photo", temp[3]);
					// 省名称
					json.put("provinceName", temp[4]);
					// 城市名称
					json.put("cityName", temp[5]);
					// 区县名称
					json.put("townName", temp[6]);
					// 详细地址
					json.put("address", temp[7]);
					// 签约日期
					json.put("qyrq", DateUtil.dateToStrShort((Date) temp[8]));
					//患者标识
					json.put("code", temp[9]);
					//患者联系方式
					json.put("mobile", temp[10]);
					array.put(json);
				}
			}
			return write(200, "查询成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	
    @RequestMapping(value = "list")
    @ResponseBody
    public String list(int type, long id, int pagesize, @RequestParam(required = false) String patientName) {
        try {
            String doctor = getUID();
            Page<Object> page = infoService.findPatientByDoctorSign(doctor, id, pagesize, patientName);
            JSONArray array = new JSONArray();
            if (page != null) {
                for (Object obj : page) {
                    Object[] temp = (Object[]) obj;
                    if (temp == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("id", temp[1]);
                    // 患者姓名
                    json.put("name", temp[2]);
                    // 患者头像
                    json.put("photo", temp[3]);
                    // 省名称
                    json.put("provinceName", temp[4]);
                    // 城市名称
                    json.put("cityName", temp[5]);
                    // 区县名称
                    json.put("townName", temp[6]);
                    // 详细地址
                    json.put("address", temp[7]);
                    // 签约日期
                    json.put("qyrq", DateUtil.dateToStrShort((Date) temp[8]));
                    //患者标识
                    json.put("code", temp[9]);
                    //患者联系方式
                    json.put("mobile", temp[10]);
                    array.put(json);
                }
            }
            return write(200, "查询成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    /**
     * 患者信息查询
     *
     * @param patient 患者标识
     * @return
     */
    @RequestMapping(value = "patient")
    @ResponseBody
    public String patient(String patient) {
        try {
            Patient temp = patientInfoService.findByCode(patient);
            if (temp != null) {
                JSONObject json = new JSONObject();
                // 设置患者姓名
                json.put("name", temp.getName());
                // 设置患者头像
                json.put("photo", CommonUtil.getPhoneUrl(temp.getPhoto()));
                // 设置患者年龄
                json.put("age", DateUtil.getAgeByBirthday(temp.getBirthday()));
                // 设置患者性别
                json.put("sex", temp.getSex());
                // 设置手机号码
                //CommonUtil.getMobileEncode(temp.getMobile())
                json.put("mobile", temp.getMobile());
                // 设置身份证号
                json.put("idcard", CommonUtil.getIdcardEncode(temp.getIdcard()));
                // 设置社保卡号
                json.put("ssc", temp.getSsc());
                // 设置省名称
                json.put("province", temp.getProvinceName());
                // 设置市名称
                json.put("city", temp.getCityName());
                // 设置区县名称
                json.put("area", temp.getTownName());
                // 设置街道
                json.put("street", temp.getStreet());
                // 设置街道名称
                json.put("streetName", temp.getStreetName());
                // 设置地址
                json.put("address", temp.getAddress());
                return write(200, "患者信息查询成功!", "data", json);
            } else {
                return error(-1, "患者信息查询失败!");
            }
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "患者信息查询失败!");
        }
    }
    /**
     * 获取签约患者信息
     *
     * @param status     签约状态 1:待签约 2, 待解约 3 已签约,4已经解约
     * @param doctorType 医生类别 健管 3  全科 2
     * @return
     */
    @RequestMapping("/sign_info")
    public String getSignInfoByDoctor(
            int status,
            int doctorType,
            int page,
            int pageSize) {
        try {
            List<Map<String, Object>> listSign = signWebService.getSignWebByDoctor(getUID(), status, doctorType);
            List<Map<String, Object>> listSub = new ArrayList<>();
            int totalPage = 0;
            int start = (page - 1) * pageSize;
            int end = (page - 1) * pageSize + pageSize;
            if (listSign != null) {
                totalPage = listSign.size() % pageSize > 0 ? (listSign.size() / pageSize + 1) : listSign.size() / pageSize;
                if (end < listSign.size()) {
                    listSub = listSign.subList(start, end);
                } else if (start < listSign.size() && end >= listSign.size()) {
                    listSub = listSign.subList(start, listSign.size());
                }
            }
            JSONObject data = new JSONObject();
            JSONArray jsonArray = new JSONArray();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            if (listSub != null) {
                for (Map<String, Object> temp : listSub) {
                    if (temp == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("code", temp.get("code"));
                    json.put("doctorCode", temp.get("doctor"));
                    json.put("patientCode", temp.get("patient"));
                    json.put("patientName", temp.get("name"));
                    json.put("provinceName", temp.get("provinceName"));
                    json.put("cityName", temp.get("cityName"));
                    json.put("townName", temp.get("townName"));
                    json.put("address", temp.get("address"));
                    json.put("photo", temp.get("photo"));
                    json.put("status", temp.get("status"));
                    String statusName = "";
                    switch (Integer.parseInt(temp.get("status").toString())) {
                        case 0:
                            statusName = "待签约";
                            break;
                        case 1:
                            statusName = "已签约";
                            break;
                        case 2:
                            statusName = "待解约";
                            break;
                        case -3:
                        case -4:
                            statusName = "已解约";
                            break;
	/**
	 * 患者信息查询
	 * @param patient 患者标识
	 * @return
	 */
	@RequestMapping(value = "patient")
	@ResponseBody
	public String patient(String patient) {
		try {
			Patient temp = patientInfoService.findByCode(patient);
			if (temp != null) {
				JSONObject json = new JSONObject();
				// 设置患者姓名
				json.put("name", temp.getName());
				// 设置患者头像
				json.put("photo", CommonUtil.getPhoneUrl(temp.getPhoto()));
				// 设置患者年龄
				json.put("age", DateUtil.getAgeByBirthday(temp.getBirthday()));
				// 设置患者性别
				json.put("sex", temp.getSex());
				// 设置手机号码
				//CommonUtil.getMobileEncode(temp.getMobile())
				json.put("mobile",temp.getMobile());
				// 设置身份证号
				json.put("idcard", CommonUtil.getIdcardEncode(temp.getIdcard()));
				// 设置社保卡号
				json.put("ssc", temp.getSsc());
				// 设置省名称
				json.put("province", temp.getProvinceName());
				// 设置市名称
				json.put("city", temp.getCityName());
				// 设置区县名称
				json.put("area", temp.getTownName());
				// 设置街道
				json.put("street", temp.getStreet());
				// 设置街道名称
				json.put("streetName", temp.getStreetName());
				// 设置地址
				json.put("address", temp.getAddress());
				return write(200, "患者信息查询成功!", "data", json);
			} else {
				return error(-1, "患者信息查询失败!");
			}
		} catch (Exception e) {
			error(e);
			return invalidUserException(e, -1, "患者信息查询失败!");
		}
	}
	
	/**
	 * 获取签约患者信息
	 * @param status 签约状态 1:待签约 2, 待解约 3 已签约,4已经解约
	 * @param doctorType 医生类别 健管 3  全科 2
	 * @return
	 */
	@RequestMapping("/sign_info")
	public String getSignInfoByDoctor(
			int status,
			int doctorType,
			int page,
			int pageSize) {
		try{
			List<Map<String,Object>> listSign = signWebService.getSignWebByDoctor(getUID(), status, doctorType);
			List<Map<String,Object>> listSub =  new ArrayList<>();
			int totalPage = 0;
			int start = (page - 1)*pageSize;
			int end = (page - 1)*pageSize + pageSize;
                    }
                    json.put("statusName", statusName);
                    json.put("id", temp.get("id"));
                    json.put("applyDate", DateUtil.dateToStrShort((Date) temp.get("applyDate")));
                    json.put("releaseSpeak", temp.get("reason"));
                    json.put("streetName", temp.get("streetName"));
                    json.put("sex", temp.get("sex"));
                    if (status == 5) {
                        String epTime = redisTemplate.opsForValue().get("expenses:remind:" + temp.get("patient"));
			if(listSign != null){
				totalPage = listSign.size() % pageSize > 0 ? (listSign.size() / pageSize + 1) : listSign.size() / pageSize;
				if(end < listSign.size()){
					listSub  = listSign.subList(start,end);
				}else if(start < listSign.size() && end >= listSign.size()){
					listSub  = listSign.subList(start,listSign.size());
				}
			}
			JSONObject data = new JSONObject();
			JSONArray jsonArray = new JSONArray();
			if (listSub != null) {
				for (Map<String,Object> temp : listSub) {
					if (temp == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("code", temp.get("code"));
					json.put("doctorCode",temp.get("doctor"));
					json.put("patientCode", temp.get("patient"));
					json.put("patientName", temp.get("name"));
					json.put("provinceName", temp.get("provinceName"));
					json.put("cityName", temp.get("cityName"));
					json.put("townName", temp.get("townName"));
					json.put("address", temp.get("address"));
					json.put("photo", temp.get("photo"));
					json.put("status", temp.get("status"));
					String statusName="";
					switch(Integer.parseInt(temp.get("status").toString()))
					{
						case 0:statusName="待签约";
							break;
						case 1:statusName="已签约";
						    break;
						case 2:statusName="待解约";
							break;
						case -3:
						case -4: statusName="已解约";
							break;
						
					}
					json.put("statusName", statusName);
					json.put("id", temp.get("id"));
					json.put("applyDate", DateUtil.dateToStrShort((Date) temp.get("applyDate")));
					json.put("releaseSpeak", temp.get("reason"));
					json.put("streetName", temp.get("streetName"));
					json.put("sex", temp.get("sex"));
					jsonArray.put(json);
				}
			}
			data.put("list",jsonArray );
			data.put("totalPage", totalPage);
			data.put("page", page);
			return write(200, "查询成功!", "data", data);
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
			return error(-1,"系统错误,请联系管理员!");
		}
	}
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", df.format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    jsonArray.put(json);
                }
            }
            data.put("list", jsonArray);
            data.put("totalPage", totalPage);
            data.put("page", page);
            return write(200, "查询成功!", "data", data);
        } catch (Exception ex) {
            ex.printStackTrace();
            return error(-1, "系统错误,请联系管理员!");
        }
    }
}

+ 67 - 31
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -157,16 +157,16 @@ public class PatientController extends WeixinBaseController {
                patient.setBirthday(DateUtil.strToDate(birthday, DateUtil.YYYY_MM_DD));
//			if (StringUtils.isNotEmpty(ssc) && StringUtils.isEmpty(patient.getSsc()))
//				patient.setSsc(ssc);
           // if (StringUtils.isNotEmpty(province))
                patient.setProvince(province);
            // if (StringUtils.isNotEmpty(province))
            patient.setProvince(province);
            //if (StringUtils.isNotEmpty(city))
                patient.setCity(city);
            patient.setCity(city);
            //if (StringUtils.isNotEmpty(town))
                patient.setTown(town);
            patient.setTown(town);
            //if (StringUtils.isNotEmpty(address))
                patient.setAddress(address);
            patient.setAddress(address);
            //if (StringUtils.isNotEmpty(street))
                patient.setStreet(street);
            patient.setStreet(street);
            if (patientInfoService.updatePatient(patient) != null) {
                // 修改成功
                return success("保存成功!");
@ -429,8 +429,8 @@ public class PatientController extends WeixinBaseController {
    @ResponseBody
    public String signStaus() {
        try {
            Map<String,String> teamDoctors = new HashMap<>();
            Map<String,String> familyDoctors = new HashMap<>();
            Map<String, String> teamDoctors = new HashMap<>();
            Map<String, String> familyDoctors = new HashMap<>();
            String id = getUID();
            //查询家庭签约
            SignFamily jt = familyContractService.findByPatientYes(id);
@ -441,7 +441,7 @@ public class PatientController extends WeixinBaseController {
                        if (doctor == null) {
                            continue;
                        }
                        familyDoctors.put(doctor.getCode(),doctor.getName());
                        familyDoctors.put(doctor.getCode(), doctor.getName());
                    }
                }
            }
@ -454,7 +454,7 @@ public class PatientController extends WeixinBaseController {
                        if (doctor == null) {
                            continue;
                        }
                        teamDoctors.put(doctor.getCode(),doctor.getName());
                        teamDoctors.put(doctor.getCode(), doctor.getName());
                    }
                }
            }
@ -492,8 +492,8 @@ public class PatientController extends WeixinBaseController {
    @ResponseBody
    public String signDoctors() {
        try {
            Map<String,JSONObject> teamDoctors = new HashMap<>();
            Map<String,JSONObject> familyDoctors = new HashMap<>();
            Map<String, JSONObject> teamDoctors = new HashMap<>();
            Map<String, JSONObject> familyDoctors = new HashMap<>();
            String id = getUID();
            //查询家庭签约
            SignFamily jt = familyContractService.findByPatientYes(id);
@ -508,7 +508,7 @@ public class PatientController extends WeixinBaseController {
                        doctorJson.put("code", doctor.getCode());
                        doctorJson.put("name", doctor.getName());
                        doctorJson.put("level", doctor.getLevel());
                        familyDoctors.put(doctor.getCode(),doctorJson);
                        familyDoctors.put(doctor.getCode(), doctorJson);
                    }
                }
            }
@ -525,7 +525,7 @@ public class PatientController extends WeixinBaseController {
                        doctorJson.put("code", doctor.getCode());
                        doctorJson.put("name", doctor.getName());
                        doctorJson.put("level", doctor.getLevel());
                        teamDoctors.put(doctor.getCode(),doctorJson);
                        teamDoctors.put(doctor.getCode(), doctorJson);
                    }
                }
            }
@ -643,12 +643,12 @@ public class PatientController extends WeixinBaseController {
     *
     * @param mobile  新手机号
     * @param captcha 验证码
     * @param type 1:变更手机号  2:绑定手机号
     * @param type    1:变更手机号  2:绑定手机号
     * @return
     */
    @RequestMapping(value = "/mobile_update",method = RequestMethod.POST)
    @RequestMapping(value = "/mobile_update", method = RequestMethod.POST)
    @ResponseBody
    public String changePatientMobile(String mobile, String captcha,int type) {
    public String changePatientMobile(String mobile, String captcha, int type) {
        try {
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "请填写新手机号码");
@ -660,11 +660,11 @@ public class PatientController extends WeixinBaseController {
                return error(-1, "操作类型参数错误");
            }
            int result = patientInfoService.changeMobile(getUID(), mobile, captcha,type);
            int result = patientInfoService.changeMobile(getUID(), mobile, captcha, type);
            if (result == -1) {
                return error(-1, "居民信息查找失败");
            } else if(result == -2) {
            } else if (result == -2) {
                return error(-1, "手机号已注册");
            } else if (result == -3) {
                return error(-1, "验证码错误");
@ -687,7 +687,7 @@ public class PatientController extends WeixinBaseController {
     */
    @RequestMapping("/is_mobile_register")
    @ResponseBody
    public String isMobileRegister(String mobile){
    public String isMobileRegister(String mobile) {
        try {
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "手机号码不能为空");
@ -695,7 +695,7 @@ public class PatientController extends WeixinBaseController {
            int result = patientInfoService.isMobileRegister(mobile);
            return write(200, "查询成功","data",result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
@ -703,29 +703,65 @@ public class PatientController extends WeixinBaseController {
    }
    /**
     *  修改密码
     * 修改密码
     *
     * @param newPassword1 新密码1
     * @param newPassword2 新密码2
     * @param oldPassword 旧密码
     * @param oldPassword  旧密码
     * @return
     */
    @RequestMapping(value = "/updatePassword",method = RequestMethod.POST)
    @RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
    @ResponseBody
    public String updatePassword(String newPassword1,
                                 String newPassword2,
                                 String oldPassword) {
        try {
            newPassword1= RSAUtils.getInstance(doctorService).decryptString(newPassword1);
            newPassword2=RSAUtils.getInstance(doctorService).decryptString(newPassword2);
            oldPassword=RSAUtils.getInstance(doctorService).decryptString(oldPassword);
            newPassword1=StringUtils.reverse(newPassword1);
            newPassword2=StringUtils.reverse(newPassword2);
            oldPassword=StringUtils.reverse(oldPassword);
            patientInfoService.updatePassword(newPassword1, newPassword2, oldPassword,getUID());
            newPassword1 = RSAUtils.getInstance(doctorService).decryptString(newPassword1);
            newPassword2 = RSAUtils.getInstance(doctorService).decryptString(newPassword2);
            oldPassword = RSAUtils.getInstance(doctorService).decryptString(oldPassword);
            newPassword1 = StringUtils.reverse(newPassword1);
            newPassword2 = StringUtils.reverse(newPassword2);
            oldPassword = StringUtils.reverse(oldPassword);
            patientInfoService.updatePassword(newPassword1, newPassword2, oldPassword, getUID());
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
    /**
     * 切换家庭成员账号
     *
     * @param family 患者code
     * @return
     */
    @RequestMapping(value = "/switch_account")
    @ResponseBody
    public String switchFamilyAccount(String family, String openid) {
        try {
            if (StringUtils.isEmpty(family)) {
                return error(-1, "家庭成员不能为空");
            }
            if (StringUtils.isEmpty(openid)) {
                return error(-1, "openid不能为空");
            }
            JSONObject result = patientInfoService.switchFamilyAccount(getUID(), family, openid);
            int status = result.getInt("status");
            if (status == -1) {
                return error(-1, "成员信息查询失败");
            } else if (status == -2) {
                return error(-1, "家庭成员不存在该人");
            } else {
                return write(200, "切换账号成功", "data", result.get("data"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "切换账号失败");
        }
    }
}

+ 3 - 2
patient-co-wlyy/src/main/resources/applicationContext.xml

@ -13,7 +13,8 @@
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
		http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
	   default-lazy-init="true">
	<description>Spring公共配置 </description>
@ -24,7 +25,7 @@
		<context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
	</context:component-scan>
	
	<!-- task:annotation-driven/ -->
	<task:annotation-driven />
	<!-- aop:aspectj-autoproxy proxy-target-class="true" / -->
	
	<!-- 此处对于定时时间的配置会被注解中的时间配置覆盖,因此,以注解配置为准 -->  

+ 5 - 1
patient-co-wlyy/src/main/webapp/WEB-INF/spring-mvc.xml

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd">
	<!-- 自动扫描且只扫描@Controller -->
	<context:component-scan base-package="com.yihu.wlyy" use-default-filters="false">
@ -13,6 +15,8 @@
		<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
	</context:component-scan>
	<task:annotation-driven />
    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
    <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>