You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					195 lines
				
				7.8 KiB
			
		
		
			
		
	
	
					195 lines
				
				7.8 KiB
			| 
								 
											3 years ago
										 
									 | 
							
								package com.ynxbd.common.service;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.bean.Dept;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.bean.Doctor;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.bean.ai.AIDept;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.bean.ai.AIDoctor;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.dao.RegisterDao;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.dao.his.HisRegisterDao;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.helper.common.DateHelper;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.result.Result;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.common.result.ResultEnum;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.wx.config.AIGuidanceConfig;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.wx.config.WeChatConfig;
							 | 
						||
| 
								 | 
							
								import lombok.extern.slf4j.Slf4j;
							 | 
						||
| 
								 | 
							
								import org.apache.commons.lang3.ObjectUtils;
							 | 
						||
| 
								 | 
							
								import org.slf4j.Logger;
							 | 
						||
| 
								 | 
							
								import org.slf4j.LoggerFactory;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import java.net.URLEncoder;
							 | 
						||
| 
								 | 
							
								import java.util.ArrayList;
							 | 
						||
| 
								 | 
							
								import java.util.HashMap;
							 | 
						||
| 
								 | 
							
								import java.util.List;
							 | 
						||
| 
								 | 
							
								import java.util.Map;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@Slf4j
							 | 
						||
| 
								 | 
							
								public class AIGuidanceService {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 查询医院详细信息
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * @param hosId 医院id
							 | 
						||
| 
								 | 
							
								     * @return result
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public Result getHospDetail(String hosId) {
							 | 
						||
| 
								 | 
							
								        log.info("[智能导诊]查询医院详细信息 hosId={}", hosId);
							 | 
						||
| 
								 | 
							
								        if (ObjectUtils.isEmpty(hosId)) {
							 | 
						||
| 
								 | 
							
								            return Result.error(ResultEnum.PARAM_IS_DEFECT);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        List<Map<String, Object>> resultList = new ArrayList<>();
							 | 
						||
| 
								 | 
							
								        if (!hosId.equals(AIGuidanceConfig.HOS_ID)) {
							 | 
						||
| 
								 | 
							
								            return Result.success(ResultEnum.AI_SUCCESS, resultList);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        Map<String, Object> map = new HashMap<>();
							 | 
						||
| 
								 | 
							
								        map.put("hosId", AIGuidanceConfig.HOS_ID);
							 | 
						||
| 
								 | 
							
								        map.put("branchId", ""); // 如果有分院,则填写分院Id, 主院的分院Id为hosId本身
							 | 
						||
| 
								 | 
							
								        map.put("hosName", AIGuidanceConfig.HOS_NAME); // 如果是分院,则填写分院名称,否则填写主院名称
							 | 
						||
| 
								 | 
							
								        map.put("hosIntro", AIGuidanceConfig.HOS_INTRO);
							 | 
						||
| 
								 | 
							
								        map.put("hosLevel", AIGuidanceConfig.HOS_LEVEL);
							 | 
						||
| 
								 | 
							
								        map.put("hosAddress", AIGuidanceConfig.HOS_ADDRESS);
							 | 
						||
| 
								 | 
							
								        map.put("hosTelephone", AIGuidanceConfig.HOS_TELEPHONE);
							 | 
						||
| 
								 | 
							
								        map.put("hosImage", WeChatConfig.getWebUrl() + "src/static/images/logo.png");
							 | 
						||
| 
								 | 
							
								        map.put("appId", WeChatConfig.APP_ID); // 公众号appid
							 | 
						||
| 
								 | 
							
								        map.put("hosUrl", WeChatConfig.getWebUrl() + "app.html"); // 公众号appid
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        map.put("location", ""); // 经纬度,逗号分割
							 | 
						||
| 
								 | 
							
								        map.put("miniAppId", ""); // 经纬度,逗号分割
							 | 
						||
| 
								 | 
							
								        map.put("isHTML", false); // 经纬度,逗号分割
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        resultList.add(map);
							 | 
						||
| 
								 | 
							
								        return Result.success(ResultEnum.AI_SUCCESS, resultList);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 科室列表
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * @param hosId    医院id
							 | 
						||
| 
								 | 
							
								     * @param branchId 分院id
							 | 
						||
| 
								 | 
							
								     * @return list
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public Result getDeptList(String hosId, String branchId) {
							 | 
						||
| 
								 | 
							
								        log.info("[智能导诊]科室列表查询 hosId={}, branchId={}", hosId, branchId);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        if (ObjectUtils.isEmpty(hosId)) {
							 | 
						||
| 
								 | 
							
								            return Result.error(ResultEnum.PARAM_IS_DEFECT);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        List<AIDept> resultList = new ArrayList<>();
							 | 
						||
| 
								 | 
							
								        if (!hosId.equals(AIGuidanceConfig.HOS_ID)) { // 医院id校验
							 | 
						||
| 
								 | 
							
								            return Result.success(ResultEnum.AI_SUCCESS, resultList);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        String curDate = DateHelper.getCurDate();
							 | 
						||
| 
								 | 
							
								        List<Dept> deptList = new HisRegisterDao().getTimeDeptList(curDate, DateHelper.getMoveDate(curDate, 7));
							 | 
						||
| 
								 | 
							
								        AIDept item;
							 | 
						||
| 
								 | 
							
								        String webUrl = WeChatConfig.getWebUrl();
							 | 
						||
| 
								 | 
							
								        int index = webUrl.indexOf("http://");
							 | 
						||
| 
								 | 
							
								        if (index == 0) {
							 | 
						||
| 
								 | 
							
								            webUrl = "https://" + webUrl.substring(index + 7);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        String deptName;
							 | 
						||
| 
								 | 
							
								        for (Dept dept : deptList) {
							 | 
						||
| 
								 | 
							
								            item = new AIDept();
							 | 
						||
| 
								 | 
							
								            deptName = dept.getDeptName();
							 | 
						||
| 
								 | 
							
								            if (!ObjectUtils.isEmpty(dept.getDeptAlias())) {
							 | 
						||
| 
								 | 
							
								                deptName = dept.getDeptAlias();
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								            item.setDeptId(dept.getDeptCode());
							 | 
						||
| 
								 | 
							
								            item.setDeptName(deptName);
							 | 
						||
| 
								 | 
							
								            item.setDeptIntro(dept.getDescription() == null ? "" : dept.getDescription()); // 科室简介
							 | 
						||
| 
								 | 
							
								            item.setDeptAddr(dept.getAddress() == null ? "" : dept.getAddress()); // 科室地址
							 | 
						||
| 
								 | 
							
								            item.setLevel(2);
							 | 
						||
| 
								 | 
							
								            item.setParentDeptId("0");
							 | 
						||
| 
								 | 
							
								            item.setFeatureFlag(0); // 是否特色科室
							 | 
						||
| 
								 | 
							
								            item.setTreatrange(""); // 诊疗范围
							 | 
						||
| 
								 | 
							
								            item.setIsHTML(true);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            try {
							 | 
						||
| 
								 | 
							
								                item.setDeptUrl(webUrl + "reg-reserve.html#/doctor?deptCode=" + dept.getDeptCode() + "&deptName=" + URLEncoder.encode(deptName, "utf-8") + "&hospitalArea=");
							 | 
						||
| 
								 | 
							
								            } catch (Exception e) {
							 | 
						||
| 
								 | 
							
								                log.error(e.getMessage());
							 | 
						||
| 
								 | 
							
								                item.setDeptUrl("");
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								            resultList.add(item);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        return Result.success(ResultEnum.AI_SUCCESS, resultList);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * [医生列表]
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * @param hosId    医院id
							 | 
						||
| 
								 | 
							
								     * @param branchId 分院id
							 | 
						||
| 
								 | 
							
								     * @param deptId   科室id
							 | 
						||
| 
								 | 
							
								     * @return list
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public Result getDoctorList(String hosId, String branchId, String deptId) {
							 | 
						||
| 
								 | 
							
								        log.info("[智能导诊]医生列表查询 hosId={}, branchId={}, deptId={}", hosId, branchId, deptId);
							 | 
						||
| 
								 | 
							
								        if (ObjectUtils.isEmpty(hosId) || ObjectUtils.isEmpty(deptId)) {
							 | 
						||
| 
								 | 
							
								            return Result.error(ResultEnum.PARAM_IS_DEFECT);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        List<AIDoctor> resultList = new ArrayList<>();
							 | 
						||
| 
								 | 
							
								        if (!hosId.equals(AIGuidanceConfig.HOS_ID)) { // 医院id校验
							 | 
						||
| 
								 | 
							
								            return Result.success(ResultEnum.AI_SUCCESS, resultList);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        String webUrl = WeChatConfig.getWebUrl();
							 | 
						||
| 
								 | 
							
								        int index = webUrl.indexOf("http://");
							 | 
						||
| 
								 | 
							
								        if (index == 0) {
							 | 
						||
| 
								 | 
							
								            webUrl = "https://" + webUrl.substring(index + 7);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        String curDate = DateHelper.getCurDate();
							 | 
						||
| 
								 | 
							
								        List<Doctor> doctorList = new HisRegisterDao().getTimeDoctorList(deptId, branchId, curDate, DateHelper.getMoveDate(curDate, 7));
							 | 
						||
| 
								 | 
							
								        doctorList = new DoctorService().doctorHandle(doctorList);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        RegisterDao registerDao = new RegisterDao();
							 | 
						||
| 
								 | 
							
								        List<Dept> wxDeptList = registerDao.selectDeptList();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        String domain = WeChatConfig.getDomain(true);
							 | 
						||
| 
								 | 
							
								        String deptName, deptCode, headImg;
							 | 
						||
| 
								 | 
							
								        Dept dept;
							 | 
						||
| 
								 | 
							
								        AIDoctor item;
							 | 
						||
| 
								 | 
							
								        for (Doctor doctor : doctorList) {
							 | 
						||
| 
								 | 
							
								            item = new AIDoctor();
							 | 
						||
| 
								 | 
							
								            deptCode = doctor.getDeptCode();
							 | 
						||
| 
								 | 
							
								            deptName = doctor.getDeptName();
							 | 
						||
| 
								 | 
							
								            item.setDoctorId(doctor.getDoctCode());
							 | 
						||
| 
								 | 
							
								            item.setDoctorName(doctor.getDoctName());
							 | 
						||
| 
								 | 
							
								            item.setDoctorJobTitle(doctor.getTitle() == null ? "" : doctor.getTitle()); // 职称
							 | 
						||
| 
								 | 
							
								            item.setDoctorGoodat(doctor.getSkill() == null ? "" : doctor.getSkill()); // 擅长
							 | 
						||
| 
								 | 
							
								            item.setDoctorIntro(doctor.getDescription() == null ? "" : doctor.getDescription()); // 介绍
							 | 
						||
| 
								 | 
							
								            headImg = doctor.getHeadImg();
							 | 
						||
| 
								 | 
							
								            if (headImg != null && !"".equals(headImg.trim())) {
							 | 
						||
| 
								 | 
							
								                if (!headImg.contains("data:image/")) { // 不是base64
							 | 
						||
| 
								 | 
							
								                    item.setDoctorImage(domain + headImg); // 头像
							 | 
						||
| 
								 | 
							
								                }
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								            item.setDoctorSex(-1);
							 | 
						||
| 
								 | 
							
								            item.setExtraData("{}"); // 额外信息
							 | 
						||
| 
								 | 
							
								            item.setIsHTML(true);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            dept = registerDao.deptFilter(wxDeptList, deptCode, deptName, null, null);
							 | 
						||
| 
								 | 
							
								            if (!ObjectUtils.isEmpty(dept.getDeptAlias())) {
							 | 
						||
| 
								 | 
							
								                deptName = dept.getDeptAlias();
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            try {
							 | 
						||
| 
								 | 
							
								                item.setDoctorUrl(webUrl + "reg-reserve.html#/source?deptCode=" + deptCode + "&deptName=" + URLEncoder.encode(deptName, "utf-8") + "&doctName=" + URLEncoder.encode(doctor.getDoctName(), "utf-8") + "&doctCode=" + doctor.getDoctCode() + "&hospitalArea=");
							 | 
						||
| 
								 | 
							
								            } catch (Exception e) {
							 | 
						||
| 
								 | 
							
								                log.error(e.getMessage());
							 | 
						||
| 
								 | 
							
								                item.setDoctorUrl("");
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								            resultList.add(item);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        return Result.success(ResultEnum.AI_SUCCESS, resultList);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |