Kaynağa Gözat

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

zhenglingfeng 8 yıl önce
ebeveyn
işleme
5582f1f274

+ 5 - 5
patient-co-statistics/pom.xml

@ -347,11 +347,11 @@
                <artifactId>spring-boot-starter-jdbc</artifactId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
                <version>${version.spring-boot}</version>
                <version>${version.spring-boot}</version>
            </dependency>
            </dependency>
            <!--<dependency>-->
                <!--<groupId>org.springframework.boot</groupId>-->
                <!--<artifactId>spring-boot-starter-security</artifactId>-->
                <!--<version>${version.spring-boot}</version>-->
            <!--</dependency>-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-security</artifactId>
                <version>${version.spring-boot}</version>
            </dependency>
            <dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>

+ 40 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/config/WebSecurityConfig.java

@ -0,0 +1,40 @@
package com.yihu.wlyy.statistics.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
/**
 * Created by Administrator on 2016.10.17.
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Value("${security.basic.username}")
    String username;
    @Value("${security.basic.password}")
    String password;
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .formLogin().defaultSuccessUrl("/swagger-ui.html").failureUrl("/login") //登录成功之后的跳转
                .permitAll()
                .and()
                .logout().logoutSuccessUrl("/login")
                .permitAll();
    }
    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
            auth.inMemoryAuthentication()
                .withUser(username).password(password).roles("USER");
    }
}

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

@ -88,7 +88,7 @@ public class JobController extends BaseController {
     * @param end
     * @param end
     * @return
     * @return
     */
     */
    @ApiOperation(value = "生成过去某一天到某一天的全部的数据")
    @ApiOperation(value = "生成过去某一天到某一天的全部的数据(包含头尾)")
    @RequestMapping(value = "productDataByDayToDay", method = RequestMethod.GET)
    @RequestMapping(value = "productDataByDayToDay", method = RequestMethod.GET)
    public String productDataByDayToDay( @ApiParam(name = "start", value = "yyyy-MM-dd", required = true)@RequestParam(value = "start", required = true)String start,
    public String productDataByDayToDay( @ApiParam(name = "start", value = "yyyy-MM-dd", required = true)@RequestParam(value = "start", required = true)String start,
                                         @ApiParam(name = "end", value = "yyyy-MM-dd", required = true)@RequestParam(value = "end", required = true)String end) {
                                         @ApiParam(name = "end", value = "yyyy-MM-dd", required = true)@RequestParam(value = "end", required = true)String end) {
@ -107,7 +107,7 @@ public class JobController extends BaseController {
     * @param end
     * @param end
     * @return
     * @return
     */
     */
    @ApiOperation(value = "生成过去某一天到某一天的某个指标的数据")
    @ApiOperation(value = "生成过去某一天到某一天的某个指标的数据(包含头尾)")
    @RequestMapping(value = "productDataByDayToDayAndId", method = RequestMethod.GET)
    @RequestMapping(value = "productDataByDayToDayAndId", method = RequestMethod.GET)
    public String productDataByDayToDayAndId( @ApiParam(name = "start", value = "yyyy-MM-dd")@RequestParam(value = "start", required = true)String start,
    public String productDataByDayToDayAndId( @ApiParam(name = "start", value = "yyyy-MM-dd")@RequestParam(value = "start", required = true)String start,
                                         @ApiParam(name = "end", value = "yyyy-MM-dd")@RequestParam(value = "end", required = true)String end,
                                         @ApiParam(name = "end", value = "yyyy-MM-dd")@RequestParam(value = "end", required = true)String end,

+ 0 - 8
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/ChangeSignJob.java

@ -41,16 +41,8 @@ public class ChangeSignJob implements Job {
    @Autowired
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private TownDao townDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private JdbcTemplate jdbcTemplate;
    @Autowired
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    private Level1Role levelRole;
    private Level1Role levelRole;
    @Autowired
    @Autowired
    private DBStorage dbStorage;
    private DBStorage dbStorage;

+ 0 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignAgeGroupDiseaseJob.java

@ -45,8 +45,6 @@ public class SignAgeGroupDiseaseJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    @Autowired
    private WlyyQuotaResultDao wlyyQuotaResultDao;//指标结果Dao
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private JdbcTemplate jdbcTemplate;

+ 0 - 6
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignJob.java

@ -8,13 +8,8 @@ import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.hosptial.Hospital;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.label.SignPatientLabelInfo;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.IdCardUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.Job;
import org.quartz.Job;
@ -23,7 +18,6 @@ import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;

+ 11 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -360,7 +360,16 @@ public class JobService {
        System.out.println(getYesterday(0,new Date()));
        System.out.println(getYesterday(0,new Date()));
    }
    }
    public void productDataByDayToDayAndId(String start, String end, String id) {
    public void productDataByDayToDayAndId(String start, String end, String id) throws Exception {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Date startDate=sdf.parse(start);
        Date endDate=sdf.parse(end);
        if(startDate.after(endDate)){
            throw new Exception("日期参数错误");
        }
        int day=daysBetween(startDate,endDate);
        for(int i=0;i<day;i++){
            productDataByOneDayWithId(getYesterday(i,startDate),id);
        }
    }
    }
}
}

+ 7 - 0
patient-co-statistics/src/main/resources/application.yml

@ -44,6 +44,13 @@ multipart:
  max-file-size: 100MB
  max-file-size: 100MB
  max-request-size: 100MB
  max-request-size: 100MB
security:
  basic:
    username: jkzl
    password: jkzlehr@402803a657d14f9f0157d1517f183d50
---
---
spring:
spring:
  profiles: cwd
  profiles: cwd

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

@ -22,6 +22,10 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	@Query("select count(1) from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
	@Query("select count(1) from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
	int hasSingStatus(String idcard);
	int hasSingStatus(String idcard);
	@Modifying
	@Query("update SignFamily a set a.mobile = ?2 where a.patient = ?1")
	int updatePatientMobile(String patient,String mobile);
    @Query("select a from SignFamily a where a.idcard = ?1 and status = ?2 and a.type = 2")
    @Query("select a from SignFamily a where a.idcard = ?1 and status = ?2 and a.type = 2")
    SignFamily findByPatientStatus(String idcard, int status);
    SignFamily findByPatientStatus(String idcard, int status);

+ 80 - 47
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -29,6 +29,7 @@ import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientSickDao;
import com.yihu.wlyy.repository.patient.PatientSickDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.common.SMSService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,6 +48,8 @@ import org.springside.modules.persistence.SearchFilter.Operator;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.EncodesUtil;
import javax.print.Doc;
/**
/**
 * 医生基本信息类.
 * 医生基本信息类.
 *
 *
@ -83,8 +86,10 @@ public class DoctorInfoService extends BaseService {
    private ConsultDao consultDao;
    private ConsultDao consultDao;
    @Autowired
    @Autowired
    private SignFamilyDao signFamilyDao;
    private SignFamilyDao signFamilyDao;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    private ConsultTeamDao consultTeamDao;
    @Autowired
    SMSService smsService;
    /**
    /**
     * 获取医生的签约病人
     * 获取医生的签约病人
@ -92,7 +97,7 @@ public class DoctorInfoService extends BaseService {
     * @param doctor
     * @param doctor
     * @return
     * @return
     */
     */
    public List<Object> getDoctorSignPatients(String doctor){
    public List<Object> getDoctorSignPatients(String doctor) {
        return signFamilyDao.findDoctorSignPatients(doctor);
        return signFamilyDao.findDoctorSignPatients(doctor);
    }
    }
@ -102,8 +107,8 @@ public class DoctorInfoService extends BaseService {
     * @param doctor
     * @param doctor
     * @return
     * @return
     */
     */
    public List<Object> getDoctorSignPatientsLikeName(String doctor,String patientName){
        return signFamilyDao.findDoctorSignPatientsLikeName(doctor,patientName);
    public List<Object> getDoctorSignPatientsLikeName(String doctor, String patientName) {
        return signFamilyDao.findDoctorSignPatientsLikeName(doctor, patientName);
    }
    }
    /**
    /**
@ -112,8 +117,8 @@ public class DoctorInfoService extends BaseService {
     * @param doctor
     * @param doctor
     * @return
     * @return
     */
     */
    public List<Object> getDoctorSignPatientsBySignType(String doctor,int type){
        return signFamilyDao.findDoctorSignPatientsBySignType(doctor,type);
    public List<Object> getDoctorSignPatientsBySignType(String doctor, int type) {
        return signFamilyDao.findDoctorSignPatientsBySignType(doctor, type);
    }
    }
    /**
    /**
@ -122,8 +127,8 @@ public class DoctorInfoService extends BaseService {
     * @param doctor
     * @param doctor
     * @return
     * @return
     */
     */
    public List<Object> getDoctorSignPatientsByTypeName(String doctor,int type,String patientName){
        return signFamilyDao.findDoctorSignPatientsByTypeName(doctor,type,patientName);
    public List<Object> getDoctorSignPatientsByTypeName(String doctor, int type, String patientName) {
        return signFamilyDao.findDoctorSignPatientsByTypeName(doctor, type, patientName);
    }
    }
    public Doctor findDoctorByCode(String code) {
    public Doctor findDoctorByCode(String code) {
@ -197,7 +202,7 @@ public class DoctorInfoService extends BaseService {
    }
    }
    public Page<Object> findPatientByDoctorSign(String doctor, long id,
    public Page<Object> findPatientByDoctorSign(String doctor, long id,
                                                int pagesize, String patientName){
                                                int pagesize, String patientName) {
        // return doctorDao.findPatientByDoctorSign(doctor);
        // return doctorDao.findPatientByDoctorSign(doctor);
        Page<Object> signList = null;
        Page<Object> signList = null;
@ -281,8 +286,8 @@ public class DoctorInfoService extends BaseService {
        if (StringUtils.isNotEmpty(query)) {
        if (StringUtils.isNotEmpty(query)) {
            filters.put("name", new SearchFilter("name", Operator.LIKE, query));
            filters.put("name", new SearchFilter("name", Operator.LIKE, query));
        }
        }
        if(StringUtils.isNotEmpty(hospital)){
            hospital=hospital.substring(0,8);
        if (StringUtils.isNotEmpty(hospital)) {
            hospital = hospital.substring(0, 8);
            filters.put("hospital", new SearchFilter("hospital", Operator.LIKE,
            filters.put("hospital", new SearchFilter("hospital", Operator.LIKE,
                    hospital));
                    hospital));
        }
        }
@ -501,7 +506,7 @@ public class DoctorInfoService extends BaseService {
    }
    }
    public List<Doctor> findDoctorByLevelAndHospital(String hospital, Integer level) {
    public List<Doctor> findDoctorByLevelAndHospital(String hospital, Integer level) {
        return doctorDao.findDoctorByLevelAndHospital(hospital,level);
        return doctorDao.findDoctorByLevelAndHospital(hospital, level);
    }
    }
    /**
    /**
@ -511,9 +516,9 @@ public class DoctorInfoService extends BaseService {
     * @param doctor
     * @param doctor
     * @return
     * @return
     */
     */
    public boolean updateDoctorIdcard(String idcard,String doctor) throws Exception {
    public boolean updateDoctorIdcard(String idcard, String doctor) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        Doctor doc = doctorDao.findByCode(doctor);
        if(doc == null){
        if (doc == null) {
            throw new Exception("医生不存在");
            throw new Exception("医生不存在");
        }
        }
        doc.setIdcard(idcard);
        doc.setIdcard(idcard);
@ -527,9 +532,9 @@ public class DoctorInfoService extends BaseService {
     * @param doctor
     * @param doctor
     * @return
     * @return
     */
     */
    public boolean updateExpertise(String expertise,String doctor) throws Exception {
    public boolean updateExpertise(String expertise, String doctor) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        Doctor doc = doctorDao.findByCode(doctor);
        if(doc == null){
        if (doc == null) {
            throw new Exception("医生不存在");
            throw new Exception("医生不存在");
        }
        }
        doc.setExpertise(expertise);
        doc.setExpertise(expertise);
@ -543,9 +548,9 @@ public class DoctorInfoService extends BaseService {
     * @param doctor
     * @param doctor
     * @return
     * @return
     */
     */
    public boolean updateSex(int sex,String doctor) throws Exception {
    public boolean updateSex(int sex, String doctor) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        Doctor doc = doctorDao.findByCode(doctor);
        if(doc == null){
        if (doc == null) {
            throw new Exception("医生不存在");
            throw new Exception("医生不存在");
        }
        }
        doc.setSex(sex);
        doc.setSex(sex);
@ -559,9 +564,9 @@ public class DoctorInfoService extends BaseService {
     * @param doctor
     * @param doctor
     * @return
     * @return
     */
     */
    public boolean updateIntroduce(String introduce,String doctor) throws Exception {
    public boolean updateIntroduce(String introduce, String doctor) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        Doctor doc = doctorDao.findByCode(doctor);
        if(doc == null){
        if (doc == null) {
            throw new Exception("医生不存在");
            throw new Exception("医生不存在");
        }
        }
        doc.setIntroduce(introduce);
        doc.setIntroduce(introduce);
@ -570,19 +575,20 @@ public class DoctorInfoService extends BaseService {
    /**
    /**
     * 设置医生为名医
     * 设置医生为名医
     *
     * @param doctorCode
     * @param doctorCode
     */
     */
    @Transactional
    @Transactional
    public void setFamous(String doctorCode,Integer status) {
        Doctor doctor=doctorDao.findByCode(doctorCode);
    public void setFamous(String doctorCode, Integer status) {
        Doctor doctor = doctorDao.findByCode(doctorCode);
        //如果是空或者大于1 默认是关闭名医
        //如果是空或者大于1 默认是关闭名医
        if(status==null||status>1){
            status=0;
        if (status == null || status > 1) {
            status = 0;
        }
        }
        doctor.setIsFamous(status);
        doctor.setIsFamous(status);
    }
    }
    public Page<Doctor> findDoctorByDept(String dept,String hosptial, String key, int page, int pageSize) {
    public Page<Doctor> findDoctorByDept(String dept, String hosptial, String key, int page, int pageSize) {
        if (pageSize <= 0) {
        if (pageSize <= 0) {
            pageSize = 10;
            pageSize = 10;
        }
        }
@ -609,7 +615,7 @@ public class DoctorInfoService extends BaseService {
        return doctorDao.findAll(spec, pageRequest);
        return doctorDao.findAll(spec, pageRequest);
    }
    }
    public Page<Doctor> findFamousDoctor(String key,Integer type, int page, int pageSize,Integer level) {
    public Page<Doctor> findFamousDoctor(String key, Integer type, int page, int pageSize, Integer level) {
        if (pageSize <= 0) {
        if (pageSize <= 0) {
            pageSize = 10;
            pageSize = 10;
        }
        }
@ -623,12 +629,12 @@ public class DoctorInfoService extends BaseService {
        // 查询全部
        // 查询全部
        Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
        Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
        if (StringUtils.isNotEmpty(key)) {
        if (StringUtils.isNotEmpty(key)) {
                filters.put("name", new SearchFilter("name", SearchFilter.Operator.LIKE, key));
            filters.put("name", new SearchFilter("name", SearchFilter.Operator.LIKE, key));
        }
        }
        filters.put("isFamous", new SearchFilter("isFamous", SearchFilter.Operator.EQ, type));
        filters.put("isFamous", new SearchFilter("isFamous", SearchFilter.Operator.EQ, type));
        if(level!=null&&level>0&&level<4){
        if (level != null && level > 0 && level < 4) {
            filters.put("level", new SearchFilter("level", SearchFilter.Operator.EQ, level));
            filters.put("level", new SearchFilter("level", SearchFilter.Operator.EQ, level));
        }
        }
        Specification<Doctor> spec = DynamicSpecifications.bySearchFilter(filters.values(), Doctor.class);
        Specification<Doctor> spec = DynamicSpecifications.bySearchFilter(filters.values(), Doctor.class);
@ -636,37 +642,37 @@ public class DoctorInfoService extends BaseService {
        return doctorDao.findAll(spec, pageRequest);
        return doctorDao.findAll(spec, pageRequest);
    }
    }
    public void updateTeamHealthDoctor(String newDoctorCode, String oldDoctorCode, String patient)throws Exception {
    public void updateTeamHealthDoctor(String newDoctorCode, String oldDoctorCode, String patient) throws Exception {
        //得到患者的签约信息
        //得到患者的签约信息
        SignFamily signFamily= signFamilyDao.findByPatient(patient);
        String groupCode="";
        if(StringUtils.isNoneBlank(oldDoctorCode)){
            ConsultTeam consultTeam= consultTeamDao.findByParientCodeAndSignTypeAndDoctor(patient,oldDoctorCode,2);
            if(consultTeam!=null){
        SignFamily signFamily = signFamilyDao.findByPatient(patient);
        String groupCode = "";
        if (StringUtils.isNoneBlank(oldDoctorCode)) {
            ConsultTeam consultTeam = consultTeamDao.findByParientCodeAndSignTypeAndDoctor(patient, oldDoctorCode, 2);
            if (consultTeam != null) {
                throw new Exception("存在没有关闭的健康咨询");
                throw new Exception("存在没有关闭的健康咨询");
            }
            }
            //修改医生服务团队 删除旧的健康管理师
            //修改医生服务团队 删除旧的健康管理师
            DoctorTeamMember doctorTeamMember=  doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(),oldDoctorCode);
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(), oldDoctorCode);
            doctorTeamMember.setDel("0");
            doctorTeamMember.setDel("0");
            //把患者移除旧的健康管理师的患者表
            //把患者移除旧的健康管理师的患者表
            List<DoctorPatientGroupInfo>  oldDoctorPatientGroupInfos=doctorPatientGroupInfoDao.findByPatientAndDoctor(patient,oldDoctorCode);
            for(DoctorPatientGroupInfo doctorPatientGroupInfo:oldDoctorPatientGroupInfos){
            List<DoctorPatientGroupInfo> oldDoctorPatientGroupInfos = doctorPatientGroupInfoDao.findByPatientAndDoctor(patient, oldDoctorCode);
            for (DoctorPatientGroupInfo doctorPatientGroupInfo : oldDoctorPatientGroupInfos) {
                doctorPatientGroupInfo.setCzrq(new Date());
                doctorPatientGroupInfo.setCzrq(new Date());
                doctorPatientGroupInfo.setStatus(0);//设置为无效
                doctorPatientGroupInfo.setStatus(0);//设置为无效
                //保存原来旧的分组
                //保存原来旧的分组
                if(Integer.valueOf(doctorPatientGroupInfo.getGroup())<4){
                    groupCode=doctorPatientGroupInfo.getGroup()+"";
                if (Integer.valueOf(doctorPatientGroupInfo.getGroup()) < 4) {
                    groupCode = doctorPatientGroupInfo.getGroup() + "";
                }
                }
            }
            }
        }
        }
        Patient patientObj=patientDao.findByCode(patient);
        Doctor newD=doctorDao.findByCode(newDoctorCode);
        Patient patientObj = patientDao.findByCode(patient);
        Doctor newD = doctorDao.findByCode(newDoctorCode);
        //修改签约中的健康管理师
        //修改签约中的健康管理师
        signFamily.setDoctorHealth(newD.getCode());
        signFamily.setDoctorHealth(newD.getCode());
        signFamily.setDoctorHealthName(newD.getName());
        signFamily.setDoctorHealthName(newD.getName());
        //添加新的健康管理师到服务团队里
        //添加新的健康管理师到服务团队里
        DoctorTeamMember  newDoctorTeamMember=new DoctorTeamMember();
        DoctorTeamMember newDoctorTeamMember = new DoctorTeamMember();
        newDoctorTeamMember.setTeam(signFamily.getTeamCode());
        newDoctorTeamMember.setTeam(signFamily.getTeamCode());
        newDoctorTeamMember.setCzrq(new Date());
        newDoctorTeamMember.setCzrq(new Date());
        newDoctorTeamMember.setName(newD.getName());
        newDoctorTeamMember.setName(newD.getName());
@ -674,7 +680,7 @@ public class DoctorInfoService extends BaseService {
        newDoctorTeamMember.setType(3);
        newDoctorTeamMember.setType(3);
        newDoctorTeamMember.setSignType("2");
        newDoctorTeamMember.setSignType("2");
        newDoctorTeamMember.setDel("1");
        newDoctorTeamMember.setDel("1");
        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-",""));
        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-", ""));
        doctorTeamDoctor.save(newDoctorTeamMember);
        doctorTeamDoctor.save(newDoctorTeamMember);
        //把患者加到新的健康管理师的患者表
        //把患者加到新的健康管理师的患者表
@ -691,10 +697,37 @@ public class DoctorInfoService extends BaseService {
        doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
        doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
    }
    }
    public void updateTeamHealthDoctors(String newDoctorCode, String oldDoctorCode, String patients)throws Exception {
        String [] patiensString=patients.split(",");
        for (int i=0;i<patiensString.length;i++){
            updateTeamHealthDoctor(newDoctorCode,oldDoctorCode,patiensString[i]);
    public void updateTeamHealthDoctors(String newDoctorCode, String oldDoctorCode, String patients) throws Exception {
        String[] patiensString = patients.split(",");
        for (int i = 0; i < patiensString.length; i++) {
            updateTeamHealthDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
        }
        }
    }
    }
    /**
     * 医生更换手机号
     *
     * @param doctor  医生code
     * @param mobile  新手机号
     * @param captcha 验证码
     * @return
     */
    public int changeMobile(String doctor, String mobile, String captcha, int type) {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
            return -1;
        }
        // 验证码验证
        int smsCheck = smsService.check(mobile, type == 1 ? 7 : 8, captcha);
        // 验证失败,不允许变更
        if (smsCheck != 1) {
            return -2;
        }
        doc.setMobile(mobile);
        return 1;
    }
}
}

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

@ -5,7 +5,9 @@ import com.yihu.wlyy.entity.address.Province;
import com.yihu.wlyy.entity.address.Street;
import com.yihu.wlyy.entity.address.Street;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.demographic.DemographicInfo;
import com.yihu.wlyy.entity.demographic.DemographicInfo;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
import com.yihu.wlyy.repository.address.CityDao;
import com.yihu.wlyy.repository.address.CityDao;
@ -15,7 +17,10 @@ import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.demographic.TblBasicDao;
import com.yihu.wlyy.repository.demographic.TblBasicDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientInvitationLogDao;
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.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.common.SMSService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
@ -49,6 +54,41 @@ public class PatientInfoService extends BaseService {
	private TblBasicDao tblBasicDao;
	private TblBasicDao tblBasicDao;
	@Autowired
	@Autowired
	private SocialSecurityInfoDao socialSecurityInfoDao;
	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;
		}
		// 验证码验证
		int smsCheck = smsService.check(mobile, type == 1 ? 7 : 8, captcha);
		// 验证失败,不允许变更
		if (smsCheck != 1) {
			return -2;
		}
		p.setMobile(mobile);
		signFamilyDao.updatePatientMobile(p.getCode(),mobile);
		return 1;
	}
	/**
	/**
	 * 根据患者标识查询患者信息
	 * 根据患者标识查询患者信息
	 * @param code
	 * @param code

+ 177 - 166
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/SMSService.java

@ -26,178 +26,189 @@ import com.yihu.wlyy.util.SystemConf;
@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public class SMSService extends BaseService {
public class SMSService extends BaseService {
	@Autowired
	public SMSDao smsDao;
    @Autowired
    public SMSDao smsDao;
	/**
	 * 发送短信验证码接口
	 * @param mobile 手机号
	 * @param type 消息类型:1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录
	 * @return
	 * @throws Exception 
	 */
	public String send(String mobile, String ip, int type) throws Exception {
		// 生成6位随机验证码
		String captcha = String.valueOf(Math.random()).substring(2, 8);
		// 默认为123456
		// captcha = "123456";
		// 同一ip一天不允许超过10条短信
		String today = DateUtil.getStringDateShort();
		Date begin = DateUtil.strToDate(today + " 00:00:00", DateUtil.YYYY_MM_DD_HH_MM_SS);
		Date end = DateUtil.strToDate(today + " 23:59:59", DateUtil.YYYY_MM_DD_HH_MM_SS);
		// int count = smsDao.countByIp(ip, begin, end);
		// if (count >= SystemConf.MAX_SMS_IP) {
		// return "当前IP:[" + ip + "]今天最多发送" + SystemConf.MAX_SMS_IP + "条短信!";
		// }
		// 一天的短信数不允许超过10条
		int count = smsDao.countByMobile(mobile, begin, end);
		if (count >= SystemConf.MAX_SMS_MOBILE) {
			return "当前手机号:[" + mobile + "]今天最多发送" + SystemConf.MAX_SMS_MOBILE + "条短信!";
		}
		// 两分钟之内不允许重复发送
		PageRequest pageRequest = new PageRequest(0, 1, new Sort(Direction.DESC, "id"));
		Page<SMS> page = smsDao.findByMobileType(mobile, type, pageRequest);
		if (page != null) {
			for (SMS sms : page) {
				if (sms == null) {
					continue;
				}
				// 计算间隔时间
				Date temp = DateUtil.getNextMin(sms.getCzrq(), SystemConf.SMS_INTERVAL);
				long leftTime = (temp.getTime() - System.currentTimeMillis()) / 1000;
				if (leftTime > 0) {
					return "发送短信验证码间隔时间为:" + SystemConf.SMS_INTERVAL + "分钟,还剩" + leftTime + "秒";
				}
			}
		}
		// 保存验证码
		SMS sms = new SMS();
		// 1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录
		if (type == 1) {
			// 患者注册
			sms.setContent("您的注册验证码为:" + captcha);
		} else if (type == 2 || type == 3) {
			// 找回密码
			sms.setContent("您的找回密码验证码为:" + captcha);
		} else if (type == 4 || type == 5) {
			// 登录
			sms.setContent("您的登录验证码为:" + captcha);
		} else {
			// 其他验证码
			sms.setContent("验证码:" + captcha);
		}
		sms.setCaptcha(captcha);
		Date date = new Date();
		// 延后5分钟
		sms.setDeadline(DateUtil.getNextMin(date, 5));
		sms.setCzrq(date);
		sms.setMobile(mobile);
		sms.setIp(ip);
		sms.setType(type);
		sms.setStatus(1);
		// 调用总部发送信息的接口
		String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(sms.getContent(), mobile), "GBK");
		JSONObject json = toJson(result);
		if (json == null) {
			// 发送失败
			throw new Exception("短信发送失败!");
		} else if (json.getInt("result") != 0) {
			return json.getString("description");
		} else {
			//发送成功,保存到数据库
			smsDao.save(sms);
		}
		return "ok";
	}
    /**
     * 发送短信验证码接口
     *
     * @param mobile 手机号
     * @param type   消息类型:1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录,6用户变更手机号验证 7用户新手机号验证 8绑定手机号
     * @return
     * @throws Exception
     */
    public String send(String mobile, String ip, int type) throws Exception {
        // 生成6位随机验证码
        String captcha = String.valueOf(Math.random()).substring(2, 8);
        // 默认为123456
        // captcha = "123456";
        // 同一ip一天不允许超过10条短信
        String today = DateUtil.getStringDateShort();
        Date begin = DateUtil.strToDate(today + " 00:00:00", DateUtil.YYYY_MM_DD_HH_MM_SS);
        Date end = DateUtil.strToDate(today + " 23:59:59", DateUtil.YYYY_MM_DD_HH_MM_SS);
        // int count = smsDao.countByIp(ip, begin, end);
        // if (count >= SystemConf.MAX_SMS_IP) {
        // return "当前IP:[" + ip + "]今天最多发送" + SystemConf.MAX_SMS_IP + "条短信!";
        // }
        // 一天的短信数不允许超过10条
        int count = smsDao.countByMobile(mobile, begin, end);
        if (count >= SystemConf.MAX_SMS_MOBILE) {
            return "当前手机号:[" + mobile + "]今天最多发送" + SystemConf.MAX_SMS_MOBILE + "条短信!";
        }
        // 两分钟之内不允许重复发送
        PageRequest pageRequest = new PageRequest(0, 1, new Sort(Direction.DESC, "id"));
        Page<SMS> page = smsDao.findByMobileType(mobile, type, pageRequest);
        if (page != null) {
            for (SMS sms : page) {
                if (sms == null) {
                    continue;
                }
                // 计算间隔时间
                Date temp = DateUtil.getNextMin(sms.getCzrq(), SystemConf.SMS_INTERVAL);
                long leftTime = (temp.getTime() - System.currentTimeMillis()) / 1000;
                if (leftTime > 0) {
                    return "发送短信验证码间隔时间为:" + SystemConf.SMS_INTERVAL + "分钟,还剩" + leftTime + "秒";
                }
            }
        }
        // 保存验证码
        SMS sms = new SMS();
        // 1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录
        if (type == 1) {
            // 患者注册
            sms.setContent("您的注册验证码为:" + captcha);
        } else if (type == 2 || type == 3) {
            // 找回密码
            sms.setContent("您的找回密码验证码为:" + captcha);
        } else if (type == 4 || type == 5) {
            // 登录
            sms.setContent("您的登录验证码为:" + captcha);
        } else if (type == 6) {
            // 手机号变更验证
            sms.setContent("【厦门市民健康系统】您的更换手机号验证码为:" + captcha);
        } else if (type == 7) {
            // 新手机号绑定验证
            sms.setContent("【厦门市民健康系统】您的新手机号验证码为:" + captcha);
        } else if (type == 8) {
            // 新手机号绑定验证
            sms.setContent("【厦门市民健康系统】您绑定手机号的验证码为:" + captcha);
        } else {
            // 其他验证码
            sms.setContent("验证码:" + captcha);
        }
        sms.setCaptcha(captcha);
        Date date = new Date();
        // 延后5分钟
        sms.setDeadline(DateUtil.getNextMin(date, 5));
        sms.setCzrq(date);
        sms.setMobile(mobile);
        sms.setIp(ip);
        sms.setType(type);
        sms.setStatus(1);
        // 调用总部发送信息的接口
        String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(sms.getContent(), mobile), "GBK");
        JSONObject json = toJson(result);
        if (json == null) {
            // 发送失败
            throw new Exception("短信发送失败!");
        } else if (json.getInt("result") != 0) {
            return json.getString("description");
        } else {
            //发送成功,保存到数据库
            smsDao.save(sms);
        }
        return "ok";
    }
	/**
	 * 验证码校验
	 * @param mobile 手机号
	 * @param type type 消息类型:1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录
	 * @param captcha 验证码
	 * @return -1验证码过期,-1验证码错误,0验证码无效,1验证通过
	 */
	public int check(String mobile, int type, String captcha) {
		// 根据手机号和验证码查询对应的短信信息
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, 1, sort);
		Page<SMS> page = smsDao.findByCaptcha(mobile, captcha, type, pageRequest);
		SMS sms = null;
		for (SMS temp : page) {
			if (temp != null) {
				sms = temp;
				break;
			}
		}
		// 验证码校验
		if (sms == null) {
			// 验证码错误
			return -1;
		} else if (type != sms.getType()) {
			// 验证码无效,也视为错误
			return -1;
		} else if (sms.getDeadline().before(new Date())) {
			// 验证码过期
			return -2;
		}
		return 1;
	}
    /**
     * 验证码校验
     *
     * @param mobile  手机号
     * @param type    type 消息类型:1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录 6用户变更手机号 7用户新手机号验证 8用户绑定手机号
     * @param captcha 验证码
     * @return -1验证码过期,-1验证码错误,0验证码无效,1验证通过
     */
    public int check(String mobile, int type, String captcha) {
        // 根据手机号和验证码查询对应的短信信息
        // 排序
        Sort sort = new Sort(Direction.DESC, "id");
        // 分页信息
        PageRequest pageRequest = new PageRequest(0, 1, sort);
        Page<SMS> page = smsDao.findByCaptcha(mobile, captcha, type, pageRequest);
        SMS sms = null;
        for (SMS temp : page) {
            if (temp != null) {
                sms = temp;
                break;
            }
        }
        // 验证码校验
        if (sms == null) {
            // 验证码错误
            return -1;
        } else if (type != sms.getType()) {
            // 验证码无效,也视为错误
            return -1;
        } else if (sms.getDeadline().before(new Date())) {
            // 验证码过期
            return -2;
        }
        return 1;
    }
	public static List<NameValuePair> buildSmsParams(String content, String mobile) {
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("SpCode", SystemConf.getInstance().getSmsCode()));
		params.add(new BasicNameValuePair("LoginName", SystemConf.getInstance().getSmsName()));
		params.add(new BasicNameValuePair("Password", SystemConf.getInstance().getSmsPassword()));
		params.add(new BasicNameValuePair("MessageContent", content));
		params.add(new BasicNameValuePair("UserNumber", mobile));
		params.add(new BasicNameValuePair("SerialNumber", String.valueOf(System.currentTimeMillis())));
		params.add(new BasicNameValuePair("ScheduleTime", ""));
		params.add(new BasicNameValuePair("f", "1"));
		return params;
	}
    public static List<NameValuePair> buildSmsParams(String content, String mobile) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("SpCode", SystemConf.getInstance().getSmsCode()));
        params.add(new BasicNameValuePair("LoginName", SystemConf.getInstance().getSmsName()));
        params.add(new BasicNameValuePair("Password", SystemConf.getInstance().getSmsPassword()));
        params.add(new BasicNameValuePair("MessageContent", content));
        params.add(new BasicNameValuePair("UserNumber", mobile));
        params.add(new BasicNameValuePair("SerialNumber", String.valueOf(System.currentTimeMillis())));
        params.add(new BasicNameValuePair("ScheduleTime", ""));
        params.add(new BasicNameValuePair("f", "1"));
        return params;
    }
	public static JSONObject toJson(String result) {
		JSONObject json = new JSONObject();
		try {
			String[] temps = result.split("&");
			for (String temp : temps) {
				if (temp.split("=").length != 2) {
					continue;
				}
				String key = temp.split("=")[0];
				String value = temp.split("=")[1];
				json.put(key, value);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return json;
	}
    public static JSONObject toJson(String result) {
        JSONObject json = new JSONObject();
        try {
            String[] temps = result.split("&");
            for (String temp : temps) {
                if (temp.split("=").length != 2) {
                    continue;
                }
                String key = temp.split("=")[0];
                String value = temp.split("=")[1];
                json.put(key, value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
	public static void main(String[] args) {
    public static void main(String[] args) {
		// JSONObject params = new JSONObject();
		// params.put("SpCode", SystemConf.SMS_SP_CODE);
		// params.put("LoginName", SystemConf.SMS_LOGIN_NAME);
		// params.put("Password", SystemConf.SMS_PASSWORD);
		// params.put("MessageContent", "您的找回密码验证码为:123456");
		// params.put("UserNumber", "18559687019");
		// params.put("SerialNumber", "");
		// params.put("ScheduleTime", "");
		// params.put("f", 1);
		//
		// // String result = HttpUtil.sendPost(SystemConf.SMS_URL, params.toString(), "GBK");
		// String result = HttpClientUtil.post(SystemConf.SMS_URL, buildSmsParams("您的找回密码验证码为:123456", "18559687019"), "GBK");
		// JSONObject json = toJson(result);
		// System.out.println(json.toString());
		// System.out.println(json.getInt("result"));
		// if (json.getInt("result") != 0) {
		// System.out.println("短信发送失败!");
		// }
        // JSONObject params = new JSONObject();
        // params.put("SpCode", SystemConf.SMS_SP_CODE);
        // params.put("LoginName", SystemConf.SMS_LOGIN_NAME);
        // params.put("Password", SystemConf.SMS_PASSWORD);
        // params.put("MessageContent", "您的找回密码验证码为:123456");
        // params.put("UserNumber", "18559687019");
        // params.put("SerialNumber", "");
        // params.put("ScheduleTime", "");
        // params.put("f", 1);
        //
        // // String result = HttpUtil.sendPost(SystemConf.SMS_URL, params.toString(), "GBK");
        // String result = HttpClientUtil.post(SystemConf.SMS_URL, buildSmsParams("您的找回密码验证码为:123456", "18559687019"), "GBK");
        // JSONObject json = toJson(result);
        // System.out.println(json.toString());
        // System.out.println(json.getInt("result"));
        // if (json.getInt("result") != 0) {
        // System.out.println("短信发送失败!");
        // }
		System.out.println(toJson("result=0&description=发送短信成功&taskid=22624861237&faillist=&task_id=22624861237"));
	}
        System.out.println(toJson("result=0&description=发送短信成功&taskid=22624861237&faillist=&task_id=22624861237"));
    }
}
}

+ 73 - 27
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -236,9 +236,10 @@ public class DoctorController extends BaseController {
    /**
    /**
     * 根据机构查找科室
     * 根据机构查找科室
     *
     * @param hospital 机构code
     * @param hospital 机构code
     * @param key 科室名称
     * @param id 主键
     * @param key      科室名称
     * @param id       主键
     * @param pagesize 每页显示条数
     * @param pagesize 每页显示条数
     * @return
     * @return
     */
     */
@ -275,23 +276,24 @@ public class DoctorController extends BaseController {
    /**
    /**
     * 根据科室查找医生
     * 根据科室查找医生
     * @param dept 科室code
     * @param key 医生名称
     * @param page 当前页
     *
     * @param dept     科室code
     * @param key      医生名称
     * @param page     当前页
     * @param pagesize 每页显示条数
     * @param pagesize 每页显示条数
     * @return
     * @return
     */
     */
    @RequestMapping(value = "findDoctorByDept")
    @RequestMapping(value = "findDoctorByDept")
    @ResponseBody
    @ResponseBody
    public String findDoctorByDept(
    public String findDoctorByDept(
            @RequestParam(required = false)String dept,
            @RequestParam(required = false)String hosptial,
            @RequestParam(required = false) String dept,
            @RequestParam(required = false) String hosptial,
            @RequestParam(required = false) String key,
            @RequestParam(required = false) String key,
            int page,
            int page,
            int pagesize) {
            int pagesize) {
        try {
        try {
            JSONArray array = new JSONArray();
            JSONArray array = new JSONArray();
            Page<Doctor> list = doctorInfoService.findDoctorByDept(dept,hosptial, key, page, pagesize);
            Page<Doctor> list = doctorInfoService.findDoctorByDept(dept, hosptial, key, page, pagesize);
            if (list != null) {
            if (list != null) {
                for (Doctor doctor : list) {
                for (Doctor doctor : list) {
                    JSONObject json = new JSONObject();
                    JSONObject json = new JSONObject();
@ -325,12 +327,14 @@ public class DoctorController extends BaseController {
            return error(-1, "获取科室列表失败!");
            return error(-1, "获取科室列表失败!");
        }
        }
    }
    }
    /**
    /**
     * 名医列表
     * 名医列表
     * @param key 医生名称
     * @param type 是否是名医 1是  0不是
     * @param level 医生的等级 1专科医生,2全科医生,3健康管理师 不传默认是全部
     * @param page 当前页
     *
     * @param key      医生名称
     * @param type     是否是名医 1是  0不是
     * @param level    医生的等级 1专科医生,2全科医生,3健康管理师 不传默认是全部
     * @param page     当前页
     * @param pagesize 每页显示条数
     * @param pagesize 每页显示条数
     * @return
     * @return
     */
     */
@ -338,13 +342,13 @@ public class DoctorController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String findFamousDoctor(
    public String findFamousDoctor(
            @RequestParam(required = false) String key,
            @RequestParam(required = false) String key,
            @RequestParam(required = false)Integer level,
            @RequestParam(required = false) Integer level,
            Integer type,
            Integer type,
            int page,
            int page,
            int pagesize) {
            int pagesize) {
        try {
        try {
            JSONArray array = new JSONArray();
            JSONArray array = new JSONArray();
            Page<Doctor> list = doctorInfoService.findFamousDoctor(key,type, page, pagesize,level);
            Page<Doctor> list = doctorInfoService.findFamousDoctor(key, type, page, pagesize, level);
            if (list != null) {
            if (list != null) {
                for (Doctor doctor : list) {
                for (Doctor doctor : list) {
                    JSONObject json = new JSONObject();
                    JSONObject json = new JSONObject();
@ -379,6 +383,7 @@ public class DoctorController extends BaseController {
            return error(-1, "获取名医列表失败!");
            return error(-1, "获取名医列表失败!");
        }
        }
    }
    }
    /**
    /**
     * 修改密码
     * 修改密码
     *
     *
@ -437,8 +442,8 @@ public class DoctorController extends BaseController {
    public String baseinfo(
    public String baseinfo(
            @RequestParam(required = false) String code) {
            @RequestParam(required = false) String code) {
        try {
        try {
            if (StringUtils.isEmpty(code)){
                code=getUID();
            if (StringUtils.isEmpty(code)) {
                code = getUID();
            }
            }
            Doctor temp = doctorInfoService.findDoctorByCode(code);
            Doctor temp = doctorInfoService.findDoctorByCode(code);
            if (temp != null) {
            if (temp != null) {
@ -1349,9 +1354,9 @@ public class DoctorController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String updateSex(int sex) {
    public String updateSex(int sex) {
        try {
        try {
            if(doctorInfoService.updateSex(sex,getUID())){
            if (doctorInfoService.updateSex(sex, getUID())) {
                return write(200, "更新成功");
                return write(200, "更新成功");
            }else{
            } else {
                return error(-1, "更新失败");
                return error(-1, "更新失败");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
@ -1373,9 +1378,9 @@ public class DoctorController extends BaseController {
            if (StringUtils.isEmpty(introduce)) {
            if (StringUtils.isEmpty(introduce)) {
                return error(-1, "身份证号不能为空");
                return error(-1, "身份证号不能为空");
            }
            }
            if(doctorInfoService.updateIntroduce(introduce,getUID())){
            if (doctorInfoService.updateIntroduce(introduce, getUID())) {
                return write(200, "更新成功");
                return write(200, "更新成功");
            }else{
            } else {
                return error(-1, "更新失败");
                return error(-1, "更新失败");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
@ -1397,9 +1402,9 @@ public class DoctorController extends BaseController {
            if (StringUtils.isEmpty(expertise)) {
            if (StringUtils.isEmpty(expertise)) {
                return error(-1, "专长不能为空");
                return error(-1, "专长不能为空");
            }
            }
            if(doctorInfoService.updateExpertise(expertise,getUID())){
            if (doctorInfoService.updateExpertise(expertise, getUID())) {
                return write(200, "更新成功");
                return write(200, "更新成功");
            }else{
            } else {
                return error(-1, "更新失败");
                return error(-1, "更新失败");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
@ -1419,7 +1424,7 @@ public class DoctorController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String setFamous(String doctorCode, Integer status) {
    public String setFamous(String doctorCode, Integer status) {
        try {
        try {
           doctorInfoService.setFamous(doctorCode,status);
            doctorInfoService.setFamous(doctorCode, status);
            return write(200, "更新成功");
            return write(200, "更新成功");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
@ -1429,22 +1434,63 @@ public class DoctorController extends BaseController {
    /**
    /**
     * 转换团队中的健康管理师
     * 转换团队中的健康管理师
     * @param  newDoctorCode 新的健康管理师的code
     *
     * @param newDoctorCode 新的健康管理师的code
     * @param oldDoctorCode 旧的健康管理师的code
     * @param oldDoctorCode 旧的健康管理师的code
     * @param patients 患者code 多个逗号分隔
     * @param patients      患者code 多个逗号分隔
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/updateTeamHealthDoctors")
    @RequestMapping(value = "/updateTeamHealthDoctors")
    @ResponseBody
    @ResponseBody
    public String updateTeamHealthDoctors(String newDoctorCode,
    public String updateTeamHealthDoctors(String newDoctorCode,
                                          @RequestParam(required = false)String oldDoctorCode,
                                          @RequestParam(required = false) String oldDoctorCode,
                                          String patients) {
                                          String patients) {
        try {
        try {
            doctorInfoService.updateTeamHealthDoctors(newDoctorCode,oldDoctorCode,patients);
            doctorInfoService.updateTeamHealthDoctors(newDoctorCode, oldDoctorCode, patients);
            return write(200, "更新成功");
            return write(200, "更新成功");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return error(-1, "更新失败");
            return error(-1, "更新失败");
        }
        }
    }
    }
    /**
     * 医生手机号变更
     *
     * @param mobile  新手机号
     * @param captcha 验证码
     * @param type 1:变更手机号  2:绑定手机号
     * @return
     */
    @RequestMapping(value = "/mobile_update", method = RequestMethod.POST)
    @ResponseBody
    public String changeDoctorMobile(String mobile, String captcha, int type) {
        try {
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "请填写新手机号码");
            }
            if (StringUtils.isEmpty(captcha)) {
                return error(-1, "请输入验证码");
            }
            if (type != 1 || type != 2) {
                return error(-1, "操作类型参数错误");
            }
            int result = doctorInfoService.changeMobile(getUID(), mobile, captcha, type);
            if (result == -1) {
                return error(-1, "医生信息查找失败");
            }
            if (result == -2) {
                return error(-1, "验证码错误");
            } else if (result == 1) {
                return write(200, "手机号更新成功");
            } else {
                return write(-1, "手机号更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "手机号更新失败");
        }
    }
}
}

+ 40 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -638,4 +638,44 @@ public class PatientController extends WeixinBaseController {
            return invalidUserException(e, -1, "患者信息查询失败!");
            return invalidUserException(e, -1, "患者信息查询失败!");
        }
        }
    }
    }
    /**
     * 居民手机号变更
     *
     * @param mobile  新手机号
     * @param captcha 验证码
     * @param type 1:变更手机号  2:绑定手机号
     * @return
     */
    @RequestMapping(value = "/mobile_update",method = RequestMethod.POST)
    @ResponseBody
    public String changePatientMobile(String mobile, String captcha,int type) {
        try {
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "请填写新手机号码");
            }
            if (StringUtils.isEmpty(captcha)) {
                return error(-1, "请输入验证码");
            }
            if (type != 1 || type != 2) {
                return error(-1, "操作类型参数错误");
            }
            int result = patientInfoService.changeMobile(getUID(), mobile, captcha,type);
            if (result == -1) {
                return error(-1, "居民信息查找失败");
            }
            if (result == -2) {
                return error(-1, "验证码错误");
            } else if (result == 1) {
                return write(200, "手机号更新成功");
            } else {
                return write(-1, "手机号更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "手机号更新失败");
        }
    }
}
}