|
@ -1,16 +1,24 @@
|
|
package com.yihu.jw.team.service;
|
|
package com.yihu.jw.team.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.yihu.jw.common.AsynchService;
|
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
import com.yihu.jw.entity.base.team.BaseTeamDO;
|
|
import com.yihu.jw.entity.base.team.BaseTeamDO;
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
|
|
|
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
|
|
|
|
import com.yihu.jw.entity.base.team.BaseTeamRelationDO;
|
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
import com.yihu.jw.team.BaseDoctorTeamDao;
|
|
import com.yihu.jw.team.BaseDoctorTeamDao;
|
|
import com.yihu.jw.team.BaseDoctorTeamMemberDao;
|
|
import com.yihu.jw.team.BaseDoctorTeamMemberDao;
|
|
|
|
import com.yihu.jw.team.BaseTeamRelationDao;
|
|
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.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@ -28,7 +36,24 @@ public class TeamService {
|
|
private BaseDoctorTeamMemberDao teamMemberDao;
|
|
private BaseDoctorTeamMemberDao teamMemberDao;
|
|
@Autowired
|
|
@Autowired
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
@Autowired
|
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
|
@Autowired
|
|
|
|
private BasePatientDao patientDao;
|
|
|
|
@Autowired
|
|
|
|
private BaseTeamRelationDao teamRelationDao;
|
|
|
|
@Autowired
|
|
|
|
private AsynchService asynchService;
|
|
|
|
|
|
|
|
//删除团队成员
|
|
|
|
public void delTeamMember(String id){
|
|
|
|
teamMemberDao.deleteById(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取医生信息
|
|
|
|
public BaseDoctorDO doctorInfo(String id){
|
|
|
|
return doctorDao.findByIdAndDel(id);
|
|
|
|
}
|
|
|
|
|
|
//保存团队
|
|
//保存团队
|
|
public BaseTeamDO saveTeam(String jsonData){
|
|
public BaseTeamDO saveTeam(String jsonData){
|
|
@ -39,17 +64,28 @@ public class TeamService {
|
|
return teamDao.save(teamDO);
|
|
return teamDao.save(teamDO);
|
|
}
|
|
}
|
|
|
|
|
|
public Envelop getTeamList(String teamName, String leadName, Integer page, Integer pageSize, String hospital) {
|
|
|
|
|
|
//获取专科团队列表
|
|
|
|
public Envelop getTeamList(Integer adminTeamId,String teamName, String leadName, Integer page, Integer pageSize, String hospital,String recommend, String recommendDoctorName) {
|
|
String countSql = " select count(t.id) ";
|
|
String countSql = " select count(t.id) ";
|
|
String sql = "SELECT t.id,t.`name`,t.org_code orgCode,t.org_name orgName,t.leader_code leaderCode,d.`name` leaderName," +
|
|
String sql = "SELECT t.id,t.`name`,t.org_code orgCode,t.org_name orgName,t.leader_code leaderCode,d.`name` leaderName," +
|
|
"DATE_FORMAT(t.create_time,'%Y-%m-%d %H:%i:%S') createTime,t.intro,t.recommend ";
|
|
"DATE_FORMAT(t.create_time,'%Y-%m-%d %H:%i:%S') createTime,t.intro,t.recommend ";
|
|
String filter = " from base_team t LEFT JOIN base_doctor d on t.leader_code = d.id WHERE t.del ='1' ";
|
|
|
|
|
|
String filter = " from base_team t LEFT JOIN base_doctor d on t.leader_code = d.id ";
|
|
|
|
if(adminTeamId!=null){
|
|
|
|
filter += " inner join base_team_relation r on r.team_id=t.id and r.admin_team_id="+adminTeamId+" ";
|
|
|
|
}
|
|
|
|
filter += " WHERE t.del ='1'";
|
|
if(StringUtils.isNotEmpty(hospital)){
|
|
if(StringUtils.isNotEmpty(hospital)){
|
|
filter += " and t.org_code = '"+hospital+"' ";
|
|
filter += " and t.org_code = '"+hospital+"' ";
|
|
}
|
|
}
|
|
|
|
if(StringUtils.isNotEmpty(recommend)){
|
|
|
|
filter += " and t.recommend = '"+recommend+"' ";
|
|
|
|
}
|
|
if(StringUtils.isNotEmpty(teamName)){
|
|
if(StringUtils.isNotEmpty(teamName)){
|
|
filter += " and t.name like '%"+teamName+"%' ";
|
|
filter += " and t.name like '%"+teamName+"%' ";
|
|
}
|
|
}
|
|
|
|
if(StringUtils.isNotEmpty(recommendDoctorName)){
|
|
|
|
filter += " and t.recommend_doctor_name like '%"+recommendDoctorName+"%' ";
|
|
|
|
}
|
|
if(StringUtils.isNotEmpty(leadName)){
|
|
if(StringUtils.isNotEmpty(leadName)){
|
|
filter += " and d.`name` like '%"+leadName+"%' ";
|
|
filter += " and d.`name` like '%"+leadName+"%' ";
|
|
}
|
|
}
|
|
@ -68,7 +104,7 @@ public class TeamService {
|
|
|
|
|
|
|
|
|
|
//获取团队成员列表
|
|
//获取团队成员列表
|
|
public Envelop getAdminTeamMemberList(String teamId, String doctorName, Integer page, Integer pageSize, String mobile) {
|
|
|
|
|
|
public Envelop getTeamMemberList(String teamId, String doctorName, Integer page, Integer pageSize, String mobile) {
|
|
String countSql = " select count(t.id) ";
|
|
String countSql = " select count(t.id) ";
|
|
String sql = "SELECT d.code,d.`name`,d.idcard,d.job_title_name hospitalName,d.mobile,d.job_name jobName,d.level," +
|
|
String sql = "SELECT d.code,d.`name`,d.idcard,d.job_title_name hospitalName,d.mobile,d.job_name jobName,d.level," +
|
|
" DATE_FORMAT(t.create_time,'%Y-%m-%d %H:%i:%S') createTime ";
|
|
" DATE_FORMAT(t.create_time,'%Y-%m-%d %H:%i:%S') createTime ";
|
|
@ -95,4 +131,88 @@ public class TeamService {
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,count);
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,count);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//添加团队成员时的医生列表
|
|
|
|
public Envelop doctorListByTeamId(String teamId,String name,String dept,Integer page, Integer pageSize){
|
|
|
|
String countSql = " select count(d.id) ";
|
|
|
|
String sql = "SELECT d.id,d.`name`,d.job_title_name jobTitleName,h.dept_code deptCode,h.dept_name deptName ,IF(m.id is null,'0','1') checked " ;
|
|
|
|
String filter = "from base_doctor d LEFT JOIN base_team_member m on d.id=m.doctor_code and m.del=1 ";
|
|
|
|
if(StringUtils.isNotEmpty(teamId)){
|
|
|
|
filter += " and m.team_code = '"+teamId+"' ";
|
|
|
|
}
|
|
|
|
filter += ",base_doctor_hospital h WHERE d.id = h.doctor_code";
|
|
|
|
if(StringUtils.isNotEmpty(dept)){
|
|
|
|
filter += " and h.dept_code = '"+dept+"'";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotEmpty(name)){
|
|
|
|
filter += " and d.name like '%"+name+"%'";
|
|
|
|
}
|
|
|
|
String orderBy = " order by d.id limit "+(page-1)*pageSize+","+pageSize;
|
|
|
|
Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
|
|
|
|
|
|
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,count);
|
|
|
|
}
|
|
|
|
|
|
|
|
//保存团队成员
|
|
|
|
public void saveTeamMember(String teamId,String doctors){
|
|
|
|
if(StringUtils.isNotEmpty(doctors)){
|
|
|
|
BaseTeamDO teamDO = teamDao.findById(teamId).orElse(null);
|
|
|
|
if(teamDO!=null){
|
|
|
|
String doc[] = doctors.split(",");
|
|
|
|
List<BaseTeamMemberDO> list = new ArrayList<>();
|
|
|
|
for (String d:doc){
|
|
|
|
BaseTeamMemberDO memberDO = new BaseTeamMemberDO();
|
|
|
|
memberDO.setDel("1");
|
|
|
|
memberDO.setOrgCode(teamDO.getOrgCode());
|
|
|
|
memberDO.setTeamCode(teamId);
|
|
|
|
memberDO.setCreateTime(new Date());
|
|
|
|
memberDO.setUpdateTime(new Date());
|
|
|
|
memberDO.setDoctorCode(d);
|
|
|
|
list.add(memberDO);
|
|
|
|
}
|
|
|
|
teamMemberDao.saveAll(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//设置团队长
|
|
|
|
// public void setTeamLeader(String teamId,String leadCode){
|
|
|
|
// BaseTeamDO teamDO = teamDao.findById(teamId).orElse(null);
|
|
|
|
// if(teamDO!=null){
|
|
|
|
// teamDO.setLeaderCode(leadCode);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
//专科团队保存关联社区
|
|
|
|
public void saveIjkTeam(String teamId,String adminTeamIds){
|
|
|
|
if(StringUtils.isNotEmpty(adminTeamIds)){
|
|
|
|
BaseTeamDO teamDO = teamDao.findById(teamId).orElse(null);
|
|
|
|
if(teamDO!=null){
|
|
|
|
String doc[] = adminTeamIds.split(",");
|
|
|
|
List<BaseTeamRelationDO> list = new ArrayList<>();
|
|
|
|
for (String d:doc){
|
|
|
|
BaseTeamRelationDO relationDO = new BaseTeamRelationDO();
|
|
|
|
relationDO.setAdminTeamId(Integer.parseInt(d));
|
|
|
|
relationDO.setTeamId(teamId);
|
|
|
|
relationDO.setCreateTime(new Date());
|
|
|
|
list.add(relationDO);
|
|
|
|
}
|
|
|
|
teamRelationDao.saveAll(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//同步i健康
|
|
|
|
asynchService.saveIjkTeam(teamId,adminTeamIds);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void delIjkTeam(String id){
|
|
|
|
BaseTeamRelationDO relationDO = teamRelationDao.findById(id).orElse(null);
|
|
|
|
if(relationDO!=null){
|
|
|
|
String teamId = relationDO.getTeamId();
|
|
|
|
Integer adminTeamId = relationDO.getAdminTeamId();
|
|
|
|
teamRelationDao.delete(relationDO);
|
|
|
|
//同步i健康
|
|
|
|
asynchService.delIjkTeam(relationDO.getTeamId(),adminTeamId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|