|
@ -1,10 +1,11 @@
|
|
/*******************************************************************************
|
|
/*******************************************************************************
|
|
* Copyright (c) 2005, 2014 springside.github.io
|
|
* Copyright (c) 2005, 2014 springside.github.io
|
|
*
|
|
|
|
|
|
* <p>
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
*******************************************************************************/
|
|
*******************************************************************************/
|
|
package com.yihu.wlyy.service.common.account;
|
|
package com.yihu.wlyy.service.common.account;
|
|
|
|
|
|
|
|
import com.yihu.wlyy.entity.organization.Hospital;
|
|
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;
|
|
@ -13,6 +14,8 @@ import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
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;
|
|
import org.springside.modules.persistence.DynamicSpecifications;
|
|
import org.springside.modules.persistence.DynamicSpecifications;
|
|
@ -36,72 +39,97 @@ import java.util.*;
|
|
@Component
|
|
@Component
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public class DoctorService extends TokenService {
|
|
public class DoctorService extends TokenService {
|
|
@Autowired
|
|
|
|
private DoctorDao doctorDao;
|
|
|
|
private Clock clock = Clock.DEFAULT;
|
|
|
|
|
|
|
|
public Doctor findDoctorByCode(String code) {
|
|
|
|
return doctorDao.findByCode(code);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Doctor findDoctorByMobile(String mobile) {
|
|
|
|
return doctorDao.findByMobile(mobile);
|
|
|
|
}
|
|
|
|
|
|
|
|
public JSONObject registerDoctor(Doctor doctor, String imei) throws Exception {
|
|
|
|
EncodesUtil.entryptPassword(doctor);
|
|
|
|
doctor.setCode(getCode());
|
|
|
|
doctor.setCzrq(clock.getCurrentDate());
|
|
|
|
|
|
|
|
Doctor temp = doctorDao.save(doctor);
|
|
|
|
if (temp != null) {
|
|
|
|
//生成登录tokey
|
|
|
|
Token token = newToken(doctor.getCode(), imei, 2);
|
|
|
|
if (token != null) {
|
|
|
|
//生成登录信息成功
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("uid", doctor.getCode());
|
|
|
|
json.put("token", token.getToken());
|
|
|
|
return json;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改医生密码
|
|
|
|
*/
|
|
|
|
public void updateDoctorPwd(Doctor doctor) {
|
|
|
|
//EncodesUtil.entryptPassword(doctor);
|
|
|
|
doctor.setIsPasswordPrompt("1");
|
|
|
|
doctorDao.save(doctor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Doctor> famousDoctorList(String name) {
|
|
|
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
if (StringUtils.isNoneEmpty(name)) {
|
|
|
|
name="%"+name+"%";
|
|
|
|
return doctorDao.doctorFamousDoctorList(name);
|
|
|
|
}else{
|
|
|
|
return doctorDao.doctorFamousDoctorList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Doctor> getDoctorFamousDoctorList(String name) {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
if (StringUtils.isNoneEmpty(name)) {
|
|
|
|
name="%"+name+"%";
|
|
|
|
return doctorDao.doctorFamousDoctorList(name);
|
|
|
|
}else{
|
|
|
|
return doctorDao.doctorFamousDoctorList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Doctor findbyIdCard(String idcard) {
|
|
|
|
return doctorDao.findbyIdCard(idcard);
|
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
|
private DoctorDao doctorDao;
|
|
|
|
private Clock clock = Clock.DEFAULT;
|
|
|
|
@Autowired
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
public Doctor findDoctorByCode(String code) {
|
|
|
|
return doctorDao.findByCode(code);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Doctor findDoctorByMobile(String mobile) {
|
|
|
|
return doctorDao.findByMobile(mobile);
|
|
|
|
}
|
|
|
|
|
|
|
|
public JSONObject registerDoctor(Doctor doctor, String imei) throws Exception {
|
|
|
|
EncodesUtil.entryptPassword(doctor);
|
|
|
|
doctor.setCode(getCode());
|
|
|
|
doctor.setCzrq(clock.getCurrentDate());
|
|
|
|
|
|
|
|
Doctor temp = doctorDao.save(doctor);
|
|
|
|
if (temp != null) {
|
|
|
|
//生成登录tokey
|
|
|
|
Token token = newToken(doctor.getCode(), imei, 2);
|
|
|
|
if (token != null) {
|
|
|
|
//生成登录信息成功
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("uid", doctor.getCode());
|
|
|
|
json.put("token", token.getToken());
|
|
|
|
return json;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改医生密码
|
|
|
|
*/
|
|
|
|
public void updateDoctorPwd(Doctor doctor) {
|
|
|
|
//EncodesUtil.entryptPassword(doctor);
|
|
|
|
doctor.setIsPasswordPrompt("1");
|
|
|
|
doctorDao.save(doctor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Doctor> famousDoctorList(String name) {
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
if (StringUtils.isNoneEmpty(name)) {
|
|
|
|
name = "%" + name + "%";
|
|
|
|
return doctorDao.doctorFamousDoctorList(name);
|
|
|
|
} else {
|
|
|
|
return doctorDao.doctorFamousDoctorList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Doctor> getDoctorFamousDoctorList(String name) {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
if (StringUtils.isNoneEmpty(name)) {
|
|
|
|
name = "%" + name + "%";
|
|
|
|
return doctorDao.doctorFamousDoctorList(name);
|
|
|
|
} else {
|
|
|
|
return doctorDao.doctorFamousDoctorList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Doctor findbyIdCard(String idcard) {
|
|
|
|
return doctorDao.findbyIdCard(idcard);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Doctor> findDoctors(String hospitalCode,String doctorName,Integer level, Integer page, Integer pagesize) {
|
|
|
|
|
|
|
|
String sql = "select * from wlyy_doctor where del=1 and status=1 ";
|
|
|
|
List<Object> args = new ArrayList<>();
|
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(hospitalCode)) {
|
|
|
|
sql += " and hospital = ? ";
|
|
|
|
args.add(hospitalCode);
|
|
|
|
}
|
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(doctorName)) {
|
|
|
|
sql += " and name like ? ";
|
|
|
|
args.add("%"+doctorName+"%");
|
|
|
|
}
|
|
|
|
if (level!=null) {
|
|
|
|
sql += " and level = ? ";
|
|
|
|
args.add(level);
|
|
|
|
}
|
|
|
|
sql += " limit " + (page * pagesize) + "," + pagesize;
|
|
|
|
|
|
|
|
List<Doctor> doctorList = jdbcTemplate.query(sql, args.toArray(), new BeanPropertyRowMapper(Doctor.class));
|
|
|
|
|
|
|
|
return doctorList;
|
|
|
|
}
|
|
}
|
|
}
|