|
@ -1,5 +1,8 @@
|
|
package com.yihu.wlyy.service.manager.user;
|
|
package com.yihu.wlyy.service.manager.user;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.wlyy.entity.*;
|
|
import com.yihu.wlyy.entity.*;
|
|
import com.yihu.wlyy.repository.*;
|
|
import com.yihu.wlyy.repository.*;
|
|
import com.yihu.wlyy.util.Envelop;
|
|
import com.yihu.wlyy.util.Envelop;
|
|
@ -47,7 +50,7 @@ public class ManageRangeService extends BaseJpaService<Doctor, DoctorDao> {
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
public List<Doctor> searchList(String name, String idcard, Integer page, Integer pageSize) throws Exception {
|
|
|
|
|
|
public Page<Doctor> searchList(String name, String idcard, Integer page, Integer pageSize) throws Exception {
|
|
if (page == null) {
|
|
if (page == null) {
|
|
page = 1;
|
|
page = 1;
|
|
}
|
|
}
|
|
@ -57,29 +60,17 @@ public class ManageRangeService extends BaseJpaService<Doctor, DoctorDao> {
|
|
// 展示状态排序
|
|
// 展示状态排序
|
|
Sort sort = new Sort(Sort.Direction.ASC, "id");
|
|
Sort sort = new Sort(Sort.Direction.ASC, "id");
|
|
PageRequest pageRequest = new PageRequest(page - 1, pageSize, sort);
|
|
PageRequest pageRequest = new PageRequest(page - 1, pageSize, sort);
|
|
List<Doctor> userList = null;
|
|
|
|
|
|
Page<Doctor> userList = null;
|
|
|
|
|
|
/*if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
|
|
|
|
if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
userList = doctorDao.findByFilter(name, idcard, pageRequest);
|
|
userList = doctorDao.findByFilter(name, idcard, pageRequest);
|
|
} else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
} else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
userList = doctorDao.findByIdcard(idcard, pageRequest);
|
|
userList = doctorDao.findByIdcard(idcard, pageRequest);
|
|
} else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
|
|
} else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
|
|
userList = doctorDao.findByName(name, pageRequest);
|
|
userList = doctorDao.findByName(name, pageRequest);
|
|
} else {
|
|
} else {
|
|
userList = doctorDao.findByFilterAll(pageRequest);
|
|
|
|
}*/
|
|
|
|
String sql = "SELECT p.code,p.name,p.sex,p.idCard,p.mobile,ro.code hospital,ro.name hospitalName " +
|
|
|
|
" FROM wlyy_doctor p, wlyy_user_role r, wlyy_role ro " +
|
|
|
|
" WHERE r.user = p.code AND r.role = ro.code AND p.status = 1 ";
|
|
|
|
if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
|
|
sql += " AND p.name = " + name + " AND p.idcard = " + idcard;
|
|
|
|
} else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
|
|
sql += " AND p.idcard = " + idcard;;
|
|
|
|
} else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
|
|
|
|
sql += " AND p.name = " + name;
|
|
|
|
|
|
userList = doctorDao.findByAllFilter(pageRequest);
|
|
}
|
|
}
|
|
sql += " ORDER BY p.id ASC limit "+ (page-1) +"," +pageSize;
|
|
|
|
userList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
|
|
|
|
|
|
|
|
return userList;
|
|
return userList;
|
|
}
|
|
}
|
|
@ -127,16 +118,18 @@ public class ManageRangeService extends BaseJpaService<Doctor, DoctorDao> {
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
public List<Doctor> getDoctorList(String name, String idcard) throws Exception {
|
|
|
|
|
|
public Page<Doctor> getDoctorList(String name, String idcard,Integer page,Integer pageSize) throws Exception {
|
|
// 展示状态排序
|
|
// 展示状态排序
|
|
List<Doctor> userList = null;
|
|
|
|
|
|
|
|
|
|
Page<Doctor> userList = null;
|
|
|
|
PageRequest request = new PageRequest(page-1,pageSize);
|
|
if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
userList = doctorDao.findDoctorByFilter(name, idcard);
|
|
|
|
|
|
userList = doctorDao.findDoctorByFilter(name, idcard,request);
|
|
} else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
} else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
|
|
userList = doctorDao.findDoctorByIdcard(idcard);
|
|
|
|
|
|
userList = doctorDao.findDoctorByIdcard(idcard,request);
|
|
} else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
|
|
} else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
|
|
userList = doctorDao.findDoctorByName(name);
|
|
|
|
|
|
userList = doctorDao.findDoctorByName(name,request);
|
|
|
|
}else {
|
|
|
|
userList = doctorDao.findByFilterAll(request);
|
|
}
|
|
}
|
|
|
|
|
|
return userList;
|
|
return userList;
|
|
@ -162,29 +155,38 @@ public class ManageRangeService extends BaseJpaService<Doctor, DoctorDao> {
|
|
}
|
|
}
|
|
|
|
|
|
//保存先判断wlyy_role是否存在在新增
|
|
//保存先判断wlyy_role是否存在在新增
|
|
public int saveUserRole(String doc, String hospital) throws Exception {
|
|
|
|
int flag = 200;
|
|
|
|
|
|
public String saveUserRole(String json) throws Exception {
|
|
|
|
String msg = "";
|
|
try {
|
|
try {
|
|
Doctor doctor = doctorDao.findByCode(doc);
|
|
|
|
if (doctor != null) {
|
|
|
|
WlyyUserRole wlyyUserRole = userRoleDao.findByUserAndRole(doc, hospital);
|
|
|
|
if (wlyyUserRole == null) {
|
|
|
|
WlyyUserRole userRole = new WlyyUserRole();
|
|
|
|
userRole.setUser(doc);
|
|
|
|
userRole.setRole(hospital);
|
|
|
|
userRole.setCzrq(new Date());
|
|
|
|
userRole.setCzy("1");
|
|
|
|
userRoleDao.save(userRole);
|
|
|
|
} else {
|
|
|
|
flag = -1;
|
|
|
|
|
|
JSONArray arrays = JSONArray.parseArray(json);
|
|
|
|
for (Object array:arrays) {
|
|
|
|
JSONObject infos = JSON.parseObject(array.toString());
|
|
|
|
String doc = infos.containsKey("doc")?infos.getString("doc"):null;
|
|
|
|
String hospital = infos.containsKey("hospital")?infos.getString("hospital"):null;
|
|
|
|
if(StringUtils.isNotEmpty(doc) && StringUtils.isNotEmpty(hospital)){
|
|
|
|
Doctor doctor = doctorDao.findByCode(doc);
|
|
|
|
WlyyRole hosInfo = roleDao.findByCode(hospital);
|
|
|
|
if (doctor != null) {
|
|
|
|
WlyyUserRole wlyyUserRole = userRoleDao.findByUserAndRole(doc, hospital);
|
|
|
|
if (wlyyUserRole == null) {
|
|
|
|
WlyyUserRole userRole = new WlyyUserRole();
|
|
|
|
userRole.setUser(doc);
|
|
|
|
userRole.setRole(hospital);
|
|
|
|
userRole.setCzrq(new Date());
|
|
|
|
userRole.setCzy("1");
|
|
|
|
userRoleDao.save(userRole);
|
|
|
|
} else {
|
|
|
|
msg += "医生:"+doctor.getName()+" 已存在 "+hosInfo.getName()+" 医院权限"+"<br/>";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
flag = -2;
|
|
|
|
}
|
|
}
|
|
return flag;
|
|
|
|
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -200,7 +202,7 @@ public class ManageRangeService extends BaseJpaService<Doctor, DoctorDao> {
|
|
String sql = "SELECT p.code,p.name,p.sex,p.idcard,p.mobile,ro.code hospital,ro.name hospitalName " +
|
|
String sql = "SELECT p.code,p.name,p.sex,p.idcard,p.mobile,ro.code hospital,ro.name hospitalName " +
|
|
" FROM wlyy_doctor p, wlyy_user_role r, wlyy_role ro " +
|
|
" FROM wlyy_doctor p, wlyy_user_role r, wlyy_role ro " +
|
|
" WHERE r.user = p.code AND r.role = ro.code AND p.status = 1 " +
|
|
" WHERE r.user = p.code AND r.role = ro.code AND p.status = 1 " +
|
|
" and r.user = "+ doc +" and ro.code = "+ hospital;
|
|
|
|
|
|
" and r.user = '"+ doc +"' and ro.code = '"+ hospital + "' ";
|
|
doctor = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
|
|
doctor = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|