Jelajahi Sumber

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

hzp 8 tahun lalu
induk
melakukan
640b3d7e95
21 mengubah file dengan 1461 tambahan dan 468 penghapusan
  1. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/login/LoginLog.java
  2. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java
  3. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientReservationDao.java
  4. 267 181
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  5. 25 12
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  6. 18 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java
  7. 180 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/ExpensesRemindService.java
  8. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  9. 51 30
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  10. 20 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/SMSService.java
  11. 222 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  12. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoYihuService.java
  13. 3 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/IGuahaoService.java
  14. 114 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java
  15. 61 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  16. 44 7
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  17. 208 189
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  18. 67 31
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  19. 165 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java
  20. 3 2
      patient-co-wlyy/src/main/resources/applicationContext.xml
  21. 5 1
      patient-co-wlyy/src/main/webapp/WEB-INF/spring-mvc.xml

+ 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

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java

@ -29,6 +29,7 @@ public class PatientReservation extends IdEntity {
	private String doctor;
	// 医生姓名(医生帮患者预约时才会有值)
	private String dname;
	// 患者标识
	private String patient;
	// 患者身份证

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientReservationDao.java

@ -23,4 +23,7 @@ public interface PatientReservationDao extends PagingAndSortingRepository<Patien
	List<PatientReservation> findByPatient(String patient, Pageable page);
	List<PatientReservation> findByPatientAndDoctor(String patient,String doctor,Pageable page);
	List<PatientReservation> findByDoctor(String doctor,Pageable page);
}

+ 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;
    }
    /**
     * 家庭关系转换
     *

+ 18 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java

@ -7,6 +7,7 @@ import java.util.Map;
import javax.transaction.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -150,14 +151,27 @@ public class PatientReservationService extends BaseService {
	}
	/**
	 * 分页获取患者预约记录
	 * 分页获取患者预约记录,医生为空查患者所有
     */
	public List<PatientReservation> getReservationByPatient(String patient, int page, int pagesize) {
	public List<PatientReservation> getReservationByPatient(String patient,String doctor, int page, int pagesize) {
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		return patientReservationDao.findByPatient(patient, pageRequest);
		if(StringUtils.isNotBlank(doctor)){//传入医生查询医生帮此患者的预约记录
			return patientReservationDao.findByPatientAndDoctor(patient, doctor, pageRequest);
		}else{
			return patientReservationDao.findByPatient(patient, pageRequest);
		}
	}
	/**
	 * 分页获取患者预约记录
	 */
	public List<PatientReservation> getReservationByDoctor(String doctor, int page, int pagesize) {
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		return patientReservationDao.findByDoctor(doctor, pageRequest);
	}
}

+ 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;
    }
    /**
     * 验证码校验
     *

+ 222 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -17,6 +17,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -35,6 +36,7 @@ public class GuahaoXMService implements IGuahaoService {
    private String ORDER_CREATE = "WebRegisterVerify";  //新建预约
    private String ORDER_CANCEL = "Unregister";   //取消预约
    private String ORDER_INFO = "GetReservationRecord";//预约信息
    private String REG_LIST ="GetRegList";//获取市民预约挂号信息
    @Autowired
    private PatientService patientService;
@ -401,8 +403,9 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 创建挂号单
     * update by linz 新增代签约人的code和name用于转诊预约
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception{
        String re = "";
        Patient p = patientService.findByCode(patient);
@ -488,6 +491,12 @@ public class GuahaoXMService implements IGuahaoService {
                reservation.setStartTime(startTime);
                reservation.setEndTime(endTime);
                reservation.setStatus(1);
                if(StringUtils.isNotBlank(dname)){
                    reservation.setDname(dname);//代理签约维护待签约人名称
                }
                if(StringUtils.isNotBlank(dcode)){
                    reservation.setDoctor(dcode);//代理签约维护待签约人编码
                }
                // 保存预约记录
                patientReservationDao.save(reservation);
                re = code;
@ -711,4 +720,216 @@ public class GuahaoXMService implements IGuahaoService {
        }
    }
    /**
     * 根据患者医保卡获取近三个月的预约记录
     */
    public List<PatientReservation> GetRegList(String patientCode,String strStart,String strEnd) throws Exception
    {
        Patient patient = patientService.findByCode(patientCode);
        //获取签名信息
        List<PatientReservation> patientRegList = new ArrayList<>();
        String[] values = SOAPUtil.getCredential(null, true);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
        param1.put("key", "?strSSID");
        param1.put("value", patient.getSsc());
        params.put(param1);
        JSONObject param2 = new JSONObject();
        param2.put("key", "?strStart");
        param2.put("value", strStart);
        params.put(param2);
        JSONObject param3 = new JSONObject();
        param3.put("key", "?strEnd");
        param3.put("value", strEnd);
        params.put(param3);
        JSONObject param4 = new JSONObject();
        param4.put("key", "?strCredential");
        param4.put("value", values[1]);
        params.put(param4);
        JSONObject param5 = new JSONObject();
        param5.put("key", "?strKey");
        param5.put("value",values[2]);  //一周后时间
        params.put(param5);
        String xml = SOAPUtil.post(REG_LIST, params);
        if (StringUtils.isEmpty(xml)) {
            // 请求失败
            throw new Exception("获取挂号信息失败!");
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
        if(patient==null){
            throw new Exception("获取挂号人员信息失败!");
        }
        for (Object o : child) {
            Element e = (Element) o;
            // 医生编码
            String regdate = e.attributeValue("regdate");//预约日期
            String time = e.attributeValue("time");//a or p 上下午
            String regBegin = e.attributeValue("start_time");//预约时间段的开始时间
            String regEnd = e.attributeValue("end_time");//预约时间段的结束时间
            String orgID = e.attributeValue("orgID");//机构ID
            String OrgCode = e.attributeValue("OrgCode");//医疗机构编码
            String org = e.attributeValue("org");//医疗机构名称
            String DeptCode = e.attributeValue("DeptCode");//科室代码
            String dept =e.attributeValue("dept");//科室
            String DoctorCode = e.attributeValue("DoctorCode");//医生代码
            String doctor = e.attributeValue("doctor");//医生
            String Introduction = e.attributeValue("Introduction");//医生简介
            String status = e.attributeValue("status");//状态:删除、新建、确认、已诊
            String enter_time = e.attributeValue("enter_time");//预约登记时间
            String notes = e.attributeValue("notes");//备注
            String code  = e.getText();//预约号
            PatientReservation patientReservation = new PatientReservation();
            patientReservation.setCode(code);
            patientReservation.setSectionType(time);
            patientReservation.setCzrq(dateFormat.parse(enter_time));
            patientReservation.setDeptCode(DeptCode);
            patientReservation.setDeptName(dept);
            patientReservation.setDoctorCode(DoctorCode);
            patientReservation.setDoctorName(doctor);
            patientReservation.setStartTime(regBegin);
            patientReservation.setEndTime(regEnd);
            patientReservation.setOrgCode(OrgCode);
            patientReservation.setOrgName(org);
            patientReservation.setType("1");
            patientReservation.setPatient(patient.getCode());
            patientReservation.setName(patient.getName());
            patientReservation.setIdcard(patient.getIdcard());
            patientReservation.setPhone(patient.getMobile());
            switch (status){
                case "删除":
                    patientReservation.setStatus(0);
                    break;
                case "新建":
                    patientReservation.setStatus(1);
                    break;
                case "确认":
                    patientReservation.setStatus(2);
                    break;
                case "已诊":
                    patientReservation.setStatus(3);
                    break;
                default:patientReservation.setStatus(4);
            };
            patientReservation.setSsc(patient.getSsc());
            GuahaoDoctor guahaoDoctor = GetDoctorInfo(DoctorCode, OrgCode, DeptCode);
            patientReservation.setDoctorPhoto(guahaoDoctor.getPhoto());//照片
            patientReservation.setDoctorJob(guahaoDoctor.getTitle());//职称
            patientRegList.add(patientReservation);
        }
        return patientRegList;
    }
    /**
     * 根据患者,预约编号,机构编号获取单条记录预约记录
     */
    public PatientReservation getRegDetail(String patientCode,String orgCode,String regCode) throws Exception
    {
        //获取签名信息
        Patient patient = patientService.findByCode(patientCode);
        StringBuffer sb = new StringBuffer();
        sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        sb.append("<root>");
        sb.append("<org_code>").append(orgCode).append("</org_code>");
        sb.append("<resid>").append(regCode).append("</resid>");
        sb.append("<ssid>").append(patient.getSsc()).append("</ssid>");
        sb.append("</root>");
        String[] values = SOAPUtil.getCredential(sb.toString(), true);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
        param1.put("key", "?strCondition");
        param1.put("value", values[0]);
        params.put(param1);
        JSONObject param2 = new JSONObject();
        param2.put("key", "?strCredential");
        param2.put("value", values[1]);
        params.put(param2);
        JSONObject param3 = new JSONObject();
        param3.put("key", "?strKey");
        param3.put("value", values[2]);
        params.put(param3);
        String xml = SOAPUtil.post(ORDER_INFO, params);
        if (StringUtils.isEmpty(xml)) {
            // 请求失败
            throw new Exception("获取挂号信息失败!");
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
        if(patient==null){
            throw new Exception("获取挂号人员信息失败!");
        }
            Element e = (Element) child.get(0);
            // 医生编码
            String regdate = e.attributeValue("regdate");//预约日期
            String time = e.attributeValue("time");//a or p 上下午
            String regBegin = e.attributeValue("start_time");//预约时间段的开始时间
            String regEnd = e.attributeValue("end_time");//预约时间段的结束时间
            String orgID = e.attributeValue("org_id");//机构ID
            String OrgCode = e.attributeValue("org_code");//医疗机构编码
            String org = e.attributeValue("org_name");//医疗机构名称
            String DeptCode = e.attributeValue("dept_code");//科室代码
            String dept =e.attributeValue("dept_name");//科室
            String DoctorCode = e.attributeValue("doctor_code");//医生代码
            String doctor = e.attributeValue("doctor_name");//医生
            String Introduction = e.attributeValue("introduction");//医生简介
            String status = e.attributeValue("status");//状态:删除、新建、确认、已诊
            String enter_time = e.attributeValue("enter_time");//预约登记时间
            String notes = e.attributeValue("notes");//备注
            String code  = e.getText();//预约号
            PatientReservation patientReservation = new PatientReservation();
            patientReservation.setCode(code);
            patientReservation.setSectionType(time);
            patientReservation.setCzrq(dateFormat.parse(enter_time));
            patientReservation.setDeptCode(DeptCode);
            patientReservation.setDeptName(dept);
            patientReservation.setDoctorCode(DoctorCode);
            patientReservation.setDoctorName(doctor);
            patientReservation.setStartTime(regBegin);
            patientReservation.setEndTime(regEnd);
            patientReservation.setOrgCode(OrgCode);
            patientReservation.setOrgName(org);
            patientReservation.setType("1");
            patientReservation.setPatient(patient.getCode());
            patientReservation.setName(patient.getName());
            patientReservation.setIdcard(patient.getIdcard());
            patientReservation.setPhone(patient.getMobile());
            switch (status){
                case "删除":
                    patientReservation.setStatus(0);
                    break;
                case "新建":
                    patientReservation.setStatus(1);
                    break;
                case "确认":
                    patientReservation.setStatus(2);
                    break;
                case "已诊":
                    patientReservation.setStatus(3);
                    break;
                default:patientReservation.setStatus(4);
            };
            patientReservation.setSsc(patient.getSsc());
            GuahaoDoctor guahaoDoctor = GetDoctorInfo(DoctorCode, OrgCode, DeptCode);
            patientReservation.setDoctorPhoto(guahaoDoctor.getPhoto());//照片
            patientReservation.setDoctorJob(guahaoDoctor.getTitle());//职称
            return patientReservation;
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoYihuService.java

@ -227,7 +227,7 @@ public class GuahaoYihuService implements IGuahaoService {
    /**
     * 创建挂号单
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception{
        return  "";
    }

+ 3 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/IGuahaoService.java

@ -2,6 +2,8 @@
package com.yihu.wlyy.service.third.guahao;
import com.yihu.wlyy.entity.patient.PatientReservation;
import java.util.List;
import java.util.Map;
@ -36,7 +38,7 @@ public interface IGuahaoService{
	/**
	 * 创建挂号单
	 */
	public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception;
	public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode ) throws Exception;
	/**
	 * 获取医生信息

+ 114 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java

@ -1,11 +1,20 @@
package com.yihu.wlyy.web.common.util;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SOAPUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.parser.JSONParser;
import net.sf.json.JSON;
import net.sf.json.util.JSONUtils;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -13,6 +22,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by lyr on 2016/9/29.
 */
@ -179,4 +191,106 @@ public class WlyySerivceController extends BaseController{
        }
    }
    /**
     * 转诊预约医生特殊号源获取
     * @param OrgCode 医院编号
     * @param DeptCode 科室编号
     * @param DocCode 医生编号
     * @return
     */
    @RequestMapping(value = "/third/smjk/RegDeptSpeDoctorSectionList",method = RequestMethod.POST)
    @ApiOperation("转诊预约获取特殊号源接口")
    public String getSpeDoctorSectionList(@RequestParam("OrgCode") String OrgCode,@RequestParam("DeptCode") String DeptCode,@RequestParam("DocCode") String DocCode){
        try{
            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
            Date nowDate =new Date();
            Date tenDateAfter =  getDateAfter(nowDate,10);
            String strStart = sm.format(nowDate);
            String strEnd = sm.format(tenDateAfter);
            String checkUrl = SystemConf.getInstance().getSystemProperties().getProperty("sign_check_upload");
            String param = "?OrgCode="+OrgCode+"&DeptCode="+DeptCode+"&strStart="+strStart+"&strEnd="+strEnd+"&DocCode="+DocCode;
            String jsonString = HttpUtil.sendPost(checkUrl + "/third/smjk/RegDeptSpeDoctorSectionList"+param,"" );
            if(StringUtils.isEmpty(jsonString)){
                return write(-1,"医生排班时间获取失败");
            }else{
                JSONObject myJsonObject = new JSONObject(jsonString);
                return write(200,"医生排班时间获取成功","data",parseXmlForSpe(myJsonObject.get("data").toString()));
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"医生排班时间获取失败");
        }
    }
    /**
     * 转诊预约医生号源转换
     * @param xml
     * @return
     */
    private List<Map<String,Object>>  parseXmlForSpe(String xml) {
            List<Map<String,Object>> re = new ArrayList<>();
            Document document = null;
            try{
                 document = DocumentHelper.parseText(xml);
             }catch (Exception e){
                throw new RuntimeException("解析数据失败!");
            }
            Element root = document.getRootElement();
            List<?> child = root.elements();//取出root的子集合
            for (Object o : child) {
                List<?> dataList = ((Element) o).elements();
                for(Object dataElement:dataList) {
                    Element e = (Element) dataElement;
                    // 日期
                    String date = e.attributeValue("date");
                    // a或者p
                    String time = e.attributeValue("time");
                    // 限号
                    String max = e.attributeValue("max");
                    // 已使用的号
                    String used = e.attributeValue("used");
                    // 1正常、2满号、3已过期
                    String status = e.attributeValue("status");
                    Map<String, Object> map = new HashMap<>();
                    map.put("date", date);
                    map.put("time", time);
                    map.put("max", max);
                    map.put("used", used);
                    map.put("status", status);
                    // 排班信息
                    List<?> sections = e.elements();
                    List<Map<String, String>> arrangeList = new ArrayList<>();
                    for (Object s : sections) {
                        Element section = (Element) s;
                        // 限号
                        String s_max = section.attributeValue("max");
                        // 已使用的号
                        String s_used = section.attributeValue("used");
                        // 一次专家坐诊时间段的开始时间
                        String start_time = section.attributeValue("start_time");
                        // 结束时间
                        String end_time = section.attributeValue("end_time");
                        Map<String, String> item = new HashMap<>();
                        item.put("max", s_max);
                        item.put("used", s_used);
                        item.put("startTime", start_time);
                        item.put("endTime", end_time);
                        arrangeList.add(item);
                    }
                    map.put("sections", arrangeList);
                    re.add(map);
                }
            }
            return  re;
        }
        public static Date getDateAfter(Date d, int day) {
            Calendar now = Calendar.getInstance();
            now.setTime(d);
            now.set(Calendar.DATE, now.get(Calendar.DATE) + day);
            return now.getTime();
      }
}

+ 61 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -0,0 +1,61 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.DoctorPatientGroupService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
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.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 医生端:患者分组管理
 *
 * @author George
 */
@Controller
@RequestMapping(value = "/doctor/patient", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-患者信息")
public class PatientInfoController extends BaseController {
    @Autowired
    private PatientInfoService patientInfoService;
    /**
     * 获取患者基本信息
     *
     * @return
     */
    @RequestMapping(value = "info")
    @ResponseBody
    public String getPatient(String patient) {
        try {
            // 获取医生下的患者
            Patient temp = patientInfoService.findByCode(patient);
            return write(200, "获取患者信息成功!", "data", temp);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -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已经解约  5未缴费
     * @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, "切换账号失败");
        }
    }
}

+ 165 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -23,6 +23,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -250,7 +253,7 @@ public class BookingController extends WeixinBaseController {
			if (StringUtils.isEmpty(patientPhone)) {
				return error(-1, "未设置手机号码!");
			}
			String orderCode =  getService(city).CreateOrder(hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,arrangeDate,patient,patientName,cardNo,clinicCard,patientPhone);
			String orderCode =  getService(city).CreateOrder(hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,arrangeDate,patient,patientName,cardNo,clinicCard,patientPhone,null,null);
			//预约发送微信消息
			PatientReservation obj = patientReservationService.findByCode(orderCode);
@ -281,6 +284,74 @@ public class BookingController extends WeixinBaseController {
		}
	}
	/**
	 * 创建挂号单
	 */
	@RequestMapping(value = "CreateOrderByDoctor",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("创建挂号单")
	public String CreateOrderByDoctor(@ApiParam(name="city",value="城市编码",defaultValue = "350200")
							  @RequestParam(value="city",required = true) String city,
							  @ApiParam(name="hospitalId",value="医院ID",defaultValue = "350211A1001")
							  @RequestParam(value="hospitalId",required = true) String hospitalId,
							  @ApiParam(name="hospitalName",value="医院名称",defaultValue = "厦门大学附属第一医院")
							  @RequestParam(value="hospitalName",required = true) String hospitalName,
							  @ApiParam(name="hosDeptId",value="科室ID",defaultValue = "1040610")
							  @RequestParam(value="hosDeptId",required = true) String hosDeptId,
							  @ApiParam(name="hosDeptName",value="医院科室名称",defaultValue = "儿二科")
							  @RequestParam(value="hosDeptName",required = true) String hosDeptName,
							  @ApiParam(name="doctorId",value="医生ID",defaultValue = "07101")
							  @RequestParam(value="doctorId",required = true) String doctorId,
							  @ApiParam(name="doctorName",value="医生姓名",defaultValue = "林素莲")
							  @RequestParam(value="doctorName",required = true) String doctorName,
							  @ApiParam(name="arrangeDate",value="排班信息",defaultValue = "{\"sectionType\":\"a\",\"startTime\":\"2016-09-02 08:20:00\",\"endTime\":\"2016-09-02 08:30:00\"}")
							  @RequestParam(value="arrangeDate",required = true) String arrangeDate,
							  @ApiParam(name="patient",value="患者代码",defaultValue = "01954b2ebbb24a40a05da9d2f5c94795")
							  @RequestParam(value="patient",required = true) String patient,
							  @ApiParam(name="patientName",value="患者姓名",defaultValue = "张锦川")
							  @RequestParam(value="patientName",required = true) String patientName,
							  @ApiParam(name="cardNo",value="身份证号码",defaultValue = "35052419880511553X")
							  @RequestParam(value="cardNo",required = true) String cardNo,
							  @ApiParam(name="clinicCard",value="市民卡号",defaultValue = "D57117706")
							  @RequestParam(value="clinicCard",required = true) String clinicCard,
							  @ApiParam(name="patientPhone",value="患者手机",defaultValue = "13950116510")
							  @RequestParam(value="patientPhone",required = true) String patientPhone,
                              @ApiParam(name="dcode",value="代预约医生编号",defaultValue = "test00000000005")
							  @RequestParam(value="dcode",required = true) String dcode,
							  @ApiParam(name="dname",value="代预约医生名称",defaultValue = "组2全科医生")
					 		  @RequestParam(value="dname",required = true) String dname) {
		try {
			if (StringUtils.isEmpty(patientName)) {
				return error(-1, "未设置姓名!");
			}
			if (StringUtils.isEmpty(cardNo)) {
				return error(-1, "未设置身份证号!");
			}
			if (StringUtils.isEmpty(clinicCard)) {
				return error(-1, "未设置社保卡号!");
			}
			if (StringUtils.isEmpty(patientPhone)) {
				return error(-1, "未设置手机号码!");
			}
			String orderCode =  getService(city).CreateOrder(hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,arrangeDate,patient,patientName,cardNo,clinicCard,patientPhone,dname,dcode);
			//获取预约信息查询是否挂号成功
			PatientReservation obj = patientReservationService.findByCode(orderCode);
			if(obj!=null)
			{
				return write(200, "创建挂号单成功!");
			}
			else{
				return error(-1,"创建挂号单失败!");
			}
		}
		catch (Exception e) {
			return error(-1,e.getMessage());
		}
	}
	/**
	 * 取消挂号单
	 */
@ -338,14 +409,55 @@ public class BookingController extends WeixinBaseController {
	 */
	@RequestMapping(value = "GetPatientReservationList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息列表接口")
	@ApiOperation("获取患者预约信息列表接口-医生端")
	public String GetPatientReservation(@ApiParam(name="pageIndex",value="第几页",defaultValue = "1")
										@RequestParam(value="pageIndex",required = false) Integer pageIndex,
										@ApiParam(name="pageSize",value="每页记录数",defaultValue = "10")
										@RequestParam(value="pageSize",required = false) Integer pageSize) {
										@RequestParam(value="pageSize",required = false) Integer pageSize,
										@ApiParam(name="patient",value="患者编号",defaultValue = "10")
										@RequestParam(value="patient",required = false) String patient,
										@ApiParam(name="doctor",value="医生编号",defaultValue = "10")
										@RequestParam(value="doctor",required = false) String doctor) {
		try {
			List<PatientReservation> list =  patientReservationService.getReservationByPatient(getUID(),pageIndex,pageSize);
			List<PatientReservation> list =  patientReservationService.getReservationByPatient(patient,doctor,pageIndex,pageSize);
			//遍历更新预约状态
			for(PatientReservation item :list)
			{
				String type = item.getType();
				String code = item.getCode();
				if (type.equals("0")) {  //医护网接口
				}
				else if (type.equals("1"))   //厦门市民健康预约接口
				{
					Integer status = guahaoXM.GetOrderStatus(item.getOrgCode(),code,item.getSsc());
					//更新状态
					if(status!=null) {
						patientReservationService.updateStatus(item.getCode(), 0);
						item.setStatus(status);
					}
				}
			}
			return write(200, "获取患者预约信息列表成功!", "data", list);
		} catch (Exception e) {
			return error(-1,e.getMessage());
		}
	}
	/**
	 * 获取医生代预约信息列表接口
	 */
	@RequestMapping(value = "GetDoctorReservationList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取医生代预约信息列表接口-医生端")
	public String GetDoctorReservation(@ApiParam(name="pageIndex",value="第几页",defaultValue = "1")
										@RequestParam(value="pageIndex",required = false) Integer pageIndex,
										@ApiParam(name="pageSize",value="每页记录数",defaultValue = "10")
										@RequestParam(value="pageSize",required = false) Integer pageSize,
										@ApiParam(name="doctor",value="医生编号",defaultValue = "10")
										@RequestParam(value="doctor",required = false) String doctor) {
		try {
			List<PatientReservation> list =  patientReservationService.getReservationByDoctor(doctor,pageIndex,pageSize);
			//遍历更新预约状态
			for(PatientReservation item :list)
			{
@ -370,14 +482,41 @@ public class BookingController extends WeixinBaseController {
		}
	}
	/**
	 * 获取患者预约信息列表接口
	 */
	@RequestMapping(value = "GetRegList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息列表接口--患者端")
	public String GetRegList(@ApiParam(name="patient",value="患者编号",defaultValue = "1")
										@RequestParam(value="patient",required = false) String patient) {
		try {
			SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
			Date nowDate = new Date();
			Date threeMonthBefore = getMonthBefore(nowDate, 3);
			List<PatientReservation> list  = guahaoXM.GetRegList(patient,sm.format(threeMonthBefore),sm.format(nowDate));
			return write(200, "获取患者预约信息列表成功!", "data", list);
		} catch (Exception e) {
			return error(-1,e.getMessage());
		}
	}
	public static Date getMonthBefore(Date d, int month) {
		Calendar now = Calendar.getInstance();
		now.setTime(d);
		now.set(Calendar.MONTH, now.get(Calendar.MONTH) - month);
		return now.getTime();
	}
	/**
	 * 获取患者预约信息单条
	 */
	@RequestMapping(value = "GetPatientReservation",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息单条")
	@ApiOperation("获取患者预约信息单条-医生端")
	public String GetPatientReservation(@ApiParam(name="orderId",value="订单id",defaultValue = "9")
											@RequestParam(value="orderId",required = true) String orderId) {
										 @RequestParam(value="orderId",required = true) String orderId) {
		try {
			PatientReservation obj =  patientReservationService.findById(orderId);
			if(obj!=null) {
@ -406,4 +545,24 @@ public class BookingController extends WeixinBaseController {
			return error(-1,e.getMessage());
		}
	}
	/**
	 * 获取患者预约信息单条
	 */
	@RequestMapping(value = "GetPatientReservationXm",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息单条-患者端")
	public String GetPatientReservationXm(@ApiParam(name="patientCode",value="患者编号")
										@RequestParam(value="patientCode",required = true) String patientCode,
										@ApiParam(name="orgCode",value="机构编码")
										@RequestParam(value="orgCode",required = true) String orgCode,
										@ApiParam(name="regCode",value="挂号单号")
										@RequestParam(value="regCode",required = true) String regCode) {
		try {
			PatientReservation obj =  guahaoXM.getRegDetail(patientCode,orgCode,regCode);
			return write(200, "获取患者预约信息成功!", "data", obj);
		} catch (Exception e) {
			return error(-1,e.getMessage());
		}
	}
}

+ 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/"/>