|
@ -9,10 +9,12 @@ 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.ObjEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.team.BaseDoctorTeamDao;
|
|
|
import com.yihu.jw.team.BaseDoctorTeamMemberDao;
|
|
|
import com.yihu.jw.team.BaseTeamRelationDao;
|
|
|
import com.yihu.jw.wlyy.service.WlyyBusinessService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
@ -45,6 +47,56 @@ public class TeamService {
|
|
|
private BaseTeamRelationDao teamRelationDao;
|
|
|
@Autowired
|
|
|
private AsynchService asynchService;
|
|
|
@Autowired
|
|
|
private WlyyBusinessService wlyyBusinessService;
|
|
|
private static final String TONGAN_TOWN = "350212";
|
|
|
|
|
|
//居民是否签约(签约详情)
|
|
|
public Envelop isSign(String idCard,String info){
|
|
|
JSONObject re = wlyyBusinessService.isSign(idCard);
|
|
|
if(re!=null){
|
|
|
JSONObject data = re.getJSONObject("obj");
|
|
|
JSONObject json = new JSONObject();
|
|
|
Integer adminTeamId = 0;
|
|
|
if(data==null){
|
|
|
//0未签约 1已签约不是同安社区 2已签约同安社区未关联专科团队 3已签约同安社区已关联专科团队
|
|
|
json.put("status","0");
|
|
|
}else{
|
|
|
String hospital = data.getString("hospital");
|
|
|
adminTeamId = data.getInteger("adminTeamId");
|
|
|
if(hospital.startsWith(TONGAN_TOWN)){
|
|
|
List<BaseTeamRelationDO> list = teamRelationDao.findAdminTeamById(adminTeamId);
|
|
|
if(list.size()>0){
|
|
|
json.put("status","3");
|
|
|
}else {
|
|
|
json.put("status","2");
|
|
|
}
|
|
|
}else {
|
|
|
json.put("status","1");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(info)){
|
|
|
//返回详情
|
|
|
json.put("hospital",hospital);
|
|
|
json.put("hospitalName",data.getString("hospitalName"));
|
|
|
json.put("doctorName",data.getString("doctorName"));
|
|
|
// json.put("doctorHealthName",data.getString("doctorHealthName"));
|
|
|
json.put("jobName",data.getString("jobName"));
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(info)){
|
|
|
String sql = " SELECT t.id,t.dept_name deptName,t.recommend_doctor recommendDoctor,t.recommend_doctor_name recommendDoctorName,d.photo,d.job_title_name jobTitleName\n" +
|
|
|
" from base_team t LEFT JOIN base_team_relation r on t.id = r.team_id and r.admin_team_id= " + adminTeamId+
|
|
|
" LEFT JOIN base_doctor d on t.recommend_doctor = t.id " +
|
|
|
" WHERE t.del=1 and t.recommend='1' ORDER BY r.id desc LIMIT 3";
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
json.put("doctorList",mapList);
|
|
|
}
|
|
|
return ObjEnvelop.getSuccess("获取成功",json);
|
|
|
}else {
|
|
|
return Envelop.getError("获取签约信息失败",-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//删除团队成员
|
|
|
public void delTeamMember(String id){
|
|
@ -73,8 +125,39 @@ public class TeamService {
|
|
|
return teamDao.findById(id).orElse(null);
|
|
|
}
|
|
|
|
|
|
//获取团队详情
|
|
|
public Envelop teamDetail(String id){
|
|
|
JSONObject json = new JSONObject();
|
|
|
BaseTeamDO teamDO = findTeamById(id);
|
|
|
List<Map<String,Object>> doctorList = new ArrayList<>();
|
|
|
if(teamDO!=null){
|
|
|
String recommendDoctor = teamDO.getRecommendDoctor();
|
|
|
String sql = "SELECT d.id,d.name,d.photo,d.introduce,d.job_title_name jobTitleName,'0' recommend ,GROUP_CONCAT(h.dept_name) deptName " +
|
|
|
"from base_team_member m,base_doctor d LEFT JOIN base_doctor_hospital h on d.id = h.doctor_code and h.del='1' " +
|
|
|
"WHERE m.team_code='"+id+"' and m.del='1' and m.doctor_code=d.id ";
|
|
|
if(StringUtils.isNotBlank(recommendDoctor)){
|
|
|
sql += " and d.id <> '"+recommendDoctor+"'";
|
|
|
String recSql = " SELECT d.id,d.name,d.photo,d.introduce,d.job_title_name jobTitleName,'1' recommend ,GROUP_CONCAT(h.dept_name) deptName " +
|
|
|
"from base_doctor d LEFT JOIN base_doctor_hospital h on d.id = h.doctor_code and h.del='1' " +
|
|
|
"WHERE d.id='"+recommendDoctor+"' GROUP BY d.id,d.name,d.photo,d.introduce,d.job_title_name";
|
|
|
List<Map<String,Object>> recList = jdbcTemplate.queryForList(recSql);
|
|
|
if(recList.size()>0){
|
|
|
doctorList.add(recList.get(0));
|
|
|
}
|
|
|
}
|
|
|
sql += " GROUP BY d.id,d.name,d.photo,d.introduce,d.job_title_name";
|
|
|
List<Map<String,Object>> docList = jdbcTemplate.queryForList(sql);
|
|
|
if(docList.size()>0){
|
|
|
doctorList.addAll(docList);
|
|
|
}
|
|
|
}
|
|
|
json.put("teamDO",teamDO);
|
|
|
json.put("doctorList",doctorList);
|
|
|
return ObjEnvelop.getSuccess("获取成功",json);
|
|
|
}
|
|
|
|
|
|
//获取专科团队列表
|
|
|
public Envelop getTeamList(Integer adminTeamId,String teamName, String dept, Integer page, Integer pageSize, String hospital,String recommend, String recommendDoctorName) {
|
|
|
public Envelop getTeamList(String type,Integer adminTeamId,String teamName, String dept, Integer page, Integer pageSize, String hospital,String recommend, String recommendDoctorName) {
|
|
|
String countSql = " select count(t.id) ";
|
|
|
String sql = "SELECT t.id,t.`name`,t.org_code orgCode,t.org_name orgName,t.dept,t.dept_name deptName,t.recommend_doctor recommendDoctor," +
|
|
|
"t.recommend_doctor_name recommendDoctorName,DATE_FORMAT(t.create_time,'%Y-%m-%d %H:%i:%S') createTime,t.intro,t.recommend ";
|
|
@ -104,9 +187,22 @@ public class TeamService {
|
|
|
if(page==null||page<=0){
|
|
|
page = 1;
|
|
|
}
|
|
|
String orderBy = " order by t.id limit "+(page-1)*pageSize+","+pageSize;
|
|
|
String orderBy = "";
|
|
|
if("1".equals(type)){
|
|
|
orderBy = " order by t.recommend desc limit "+(page-1)*pageSize+","+pageSize;
|
|
|
}else {
|
|
|
orderBy = " order by t.id limit "+(page-1)*pageSize+","+pageSize;
|
|
|
}
|
|
|
Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
|
|
|
for (Map<String,Object> map:list){
|
|
|
String id = map.get("id")+"";
|
|
|
//获取团队成员
|
|
|
String doctorSql = "SELECT d.id,d.name,d.photo from base_team_member m,base_doctor d " +
|
|
|
" WHERE m.team_code='"+id+"' and m.del='1' and m.doctor_code=d.id and d.del='1' ";
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(doctorSql);
|
|
|
map.put("doctorList",mapList);
|
|
|
}
|
|
|
|
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,count);
|
|
|
}
|