Bläddra i källkod

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

liubing 4 år sedan
förälder
incheckning
806908d4c8

+ 10 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -71,6 +71,15 @@ public class ImUtil {
			this.value = value;
		}
	}
	public String sendMDTSocketMessageToDoctor(String targetUserId, String message) {
		String imAddr = im_host + "api/v2/message/doctorSystemMessage";
		JSONObject params = new JSONObject();
		params.put("targetUserId", targetUserId);
		params.put("message", message);
		String response = HttpClientUtil.postBody(imAddr,params);
		return response;
	}
	
	/**
	 * 发送消息
@ -746,6 +755,7 @@ public class ImUtil {
	public static final String SESSION_TYPE_GUIDANCE_ASSISTANT = "18";//导诊助手
	public static final String SESSION_STATUS_PROCEEDINGS = "0";
	public static final String SESSION_STATUS_END = "1";
	public static final String SESSION_TYPE_EMERGENCY_ASSISTANCE = "20";//紧急救助
	
	public static final String CONTENT_TYPE_TEXT = "1";
	

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDo.java

@ -23,7 +23,7 @@ public class ConsultTeamDo extends UuidIdentityEntity {
	private Integer type;           //  1、15三师咨询,2、家庭医生咨询,
	// 6、患者名医咨询 7医生名医咨询 8续方咨询 9、16在线复诊咨询(居民直接咨询专家)
	// 10医生发起的求助 11思明区上门服务在线咨询
	// 13、互联网医院专家咨询
	// 13、互联网医院专家咨询, 20紧急救助咨询
	private String patient;         // 提问者标识
	private String name;            // 患者姓名
	private Integer sex;            // 患者性别

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/aop/ServicesAuthAOP.java

@ -54,7 +54,7 @@ public class ServicesAuthAOP {
                writer.flush();
                return o;
            }
            List<String> items =servicePackageService.getPatientServiceItems(patientId);
            List<String> items =servicePackageService.fingServiceItemsCodeByPatientId(patientId);
            if(!items.contains(item)){
                PrintWriter writer=response.getWriter();
                writer.write(error(401, "该操作没有权限"));

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/team/BaseTeamDao.java

@ -31,7 +31,7 @@ public interface BaseTeamDao extends PagingAndSortingRepository<BaseTeamDO, Stri
    void delete(@Param("teamCode") String teamCode);
    @Query("SELECT t from BaseTeamDO t WHERE t.leaderCode = :leaderCode AND t.del = '1'")
    BaseTeamDO findByLeaderCode(@Param("leaderCode") String leaderCode);
    List<BaseTeamDO> findByLeaderCode(@Param("leaderCode") String leaderCode);
    @Query("SELECT t FROM BaseTeamMemberDO m, BaseTeamDO t WHERE m.doctorCode = :doctorCode " +
            "AND t.id = m.teamCode AND t.del = '1' AND m.del = '1'")

+ 15 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -60,6 +60,21 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findSignDoctor")
    @ApiOperation(value = "查找签约医生")
    public ListEnvelop findSignDoctor (
            @ApiParam(name = "patient", value = "医生code", required = true)
            @RequestParam(value = "patient",required = true) String patient,
            @ApiParam(name = "orgCode", value = "医院code", required = false)
            @RequestParam(value = "orgCode",required = false) String orgCode) throws Exception {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findSignDoctor(patient,orgCode));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "signRecordPage")
    @ApiOperation(value = "获取签约记录分页")
    public PageEnvelop<List<Map<String,Object>>> signRecordPage (

+ 6 - 19
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/team/TeamEndpoint.java

@ -15,7 +15,6 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
@ -151,16 +150,16 @@ public class TeamEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "/team/{doctorCode}/team", method = RequestMethod.GET)
    @ApiOperation(value = "获取团队长团队")
    public ObjEnvelop getLeaderTeam(@PathVariable("doctorCode") String doctorCode) {
    public ListEnvelop getLeaderTeam(@PathVariable("doctorCode") String doctorCode) {
        try {
            BaseTeamDO team = teamDao.findByLeaderCode(doctorCode);
            List<BaseTeamDO> team = teamDao.findByLeaderCode(doctorCode);
            if (team == null) {
                return ObjEnvelop.getError( "没有找到数据!",-2);
                return ListEnvelop.getError( "没有找到数据!");
            }
            return ObjEnvelop.getSuccess("获取成功",team);
            return ListEnvelop.getSuccess("获取成功",team);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
            return ListEnvelop.getError("获取失败");
        }
    }
@ -174,20 +173,8 @@ public class TeamEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取医生团队列表")
    public ListEnvelop getDoctorTeams(@PathVariable("doctorCode") String doctorCode) {
        try {
            ArrayList teams = new ArrayList();
            List<BaseTeamDO> teamList = teamDao.findDoctorTeams(doctorCode);
            BaseTeamDO team = teamDao.findByLeaderCode(doctorCode);
            String teamCode = "";
            if (team != null){
                teams.add(team);
                teamCode = team.getId();
            }
            for (BaseTeamDO list : teamList){
                if (teamCode!=list.getId()){
                    teams.add(list);
                }
            }
            return ListEnvelop.getSuccess("获取成功",teams);
            return ListEnvelop.getSuccess("获取成功",teamList);
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("获取失败");

+ 199 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java

@ -0,0 +1,199 @@
package com.yihu.jw.care.service.consult;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.rm.hospital.BaseHospitalRequestMapping.PatientIM.patientInfo;
/**
 * Created by yeshijie on 2020/12/23.
 */
@Service
public class ConsultTeamService {
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private ConsultDao consultDao;
    @Autowired
    private ImUtil imUtill;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private ServicePackageSignRecordDao servicePackageSignRecordDao;
    public JSONObject updateIMMsg(String sessionId,String sessionType,String msgId,String content){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(sessionId) || StringUtils.isEmpty(sessionType) || StringUtils.isEmpty(msgId) || StringUtils.isEmpty(content)){
            result.put("data", "参数【sessionId,sessionType,msgId,content】不可为空!");
            result.put("status", -1);
            return result ;
        }
        JSONObject contentJsonObj = null;
        try{
            contentJsonObj = JSONObject.parseObject(content);
        }catch (Exception e){
            result.put("status", -1);
            result.put("data", "【content】必须是json格式:" + e.getMessage());
            return result;
        }
        String response = imUtill.updateMessage(sessionId,sessionType,msgId,content);
        return JSONObject.parseObject(response);
    }
    /**
     * 根据咨询查关联业务记录
     * @param code
     * @param type
     * @return
     */
    public JSONObject queryByConsultCode(String code,Integer type){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(code) || null == type){
            return null;
        }
        ConsultDo consult = consultDao.queryByIdAndType(code,type);
        if(null == consult){
            result.put("data", "");
            return result;
        }
        switch (type) {
            case 20:
//                WlyyDoorServiceOrderDO orderDO = wlyyDoorServiceOrderDao.findOne(consult.getRelationCode());
//                JSONObject patientInfo = wlyyDoorServiceOrderService.queryOrderCardInfo(orderDO);
                result.put("data", patientInfo);
                break;
            default:
                break;
        }
        if(null == result.get("data")){
            result.put("data", consult);
        }
        return result;
    }
    /**
     * 添加一条咨询记录
     * @param patient 患者信息
     * @param title 咨询标题
     * @param type 咨询类型:20 紧急救助咨询
     * @return
     */
    public ConsultDo addConsult(String patient, String title, String symptoms, String images, int type) {
        ConsultDo consult = new ConsultDo();
        consult.setCzrq(new Date());
        consult.setDel("1");
        consult.setPatient(patient);
        consult.setTitle(title);
        consult.setSymptoms(symptoms);
        consult.setImages(images);
        consult.setType(type);
        return consultDao.save(consult);
    }
    /**
     * 添加紧急救助咨询
     * @param orderId
     * @return
     * @throws Exception
     */
    public JSONObject addServiceConsult(String orderId,String patient,String symptoms) throws Exception {
        JSONObject result = new JSONObject();
        // 判断居民是否已经签约
        List<ServicePackageSignRecordDO> signRecordDOs = servicePackageSignRecordDao.findByStatusAndPatient(1,patient);
        if(signRecordDOs.size() == 0){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前居民未签约,无法进行紧急救助咨询!";
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        // 添加咨询记录
        BasePatientDO patientDO = patientDao.findById(patient);
        if(null == patientDO){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前咨询的居民不存在!";
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        //咨询记录
        String title = patientDO.getName() + "-发起了服务咨询";
        ConsultDo consult = addConsult(patient,title,symptoms,patientDO.getPhone(),20);
        //咨询详细信息
        ConsultTeamDo consultTeam = new ConsultTeamDo();
        consultTeam.setType(20);  //紧急救助咨询
//        consultTeam.setAdminTeamId(signFamily.getAdminTeamId());
        consultTeam.setRelationCode(orderId); //关联业务code
        consultTeam.setSymptoms(symptoms);
        consultTeam.setPatient(patient);
        consultTeam.setName(patientDO.getName());
        consultTeam.setBirthday(patientDO.getBirthday());
        consultTeam.setSex(patientDO.getSex());
        consultTeam.setPhoto(patientDO.getPhoto());
        consultTeam.setCzrq(new Date());
        consultTeam.setDel("1");
        consultTeam.setStatus(0);
        consultTeam.setEvaluate(0);
        consultTeam.setDoctorRead(1); // 医生未读数量为1
        consult.setRelationCode(orderId);//关联业务code
        consultTeam.setConsult(consult.getId()); // 设置咨询标识
        //(im创建咨询) 紧急救助咨询的sessionid为居民code+咨询类型
        String sessionId = patient + "_" + consult.getId() + "_" + consultTeam.getType();
        //4、 紧急救助咨询-参与者
        JSONObject participants = new JSONObject();
        participants.put(patient, 0);
        //加入团队医生
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient,"emergencyAssistance");
        for(Map<String,Object> map:doctorList){
            participants.put(String.valueOf(map.get("id")), 0);
        }
        String content = patientDO.getName() + "-紧急救助咨询";
        JSONObject messages = imUtill.getCreateTopicMessage(patient, patientDO.getName(), consult.getTitle(), content, consult.getImages(), "");
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_EMERGENCY_ASSISTANCE);
        if (imResponseJson == null || imResponseJson.getInteger("status") == -1) {
            String failMsg = "发起服务咨询时:IM" + imResponseJson.getString("message");
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        consultTeam.setStartMsgId(imResponseJson.get("start_msg_id").toString());
        consultTeamDao.save(consultTeam);
        consultDao.save(consult);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, consultTeam);
        return result;
    }
}

+ 45 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -81,15 +81,41 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                " base_service_package_item i, " +
                " base_org o " +
                "WHERE " +
                " sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"'" +
                " sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"' " +
                "AND r.service_package_id = i.service_package_id " +
                "AND i.del = 1 " +
                "and i.org_code = o.code " +
                "AND sr.`status` = 1";
                "AND sr.`status` = 1 ";
        List<BaseOrgDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(BaseOrgDO.class));
        return list;
    }
    /**
     * 查找签约医生
     * @param patient
     * @return
     */
    public List<BaseDoctorDO> findSignDoctor(String patient,String orgCode){
        String sql = "SELECT " +
                " DISTINCT d.* " +
                "FROM " +
                " base_service_package_sign_record sr, " +
                " base_service_package_record r, " +
                " base_service_package_item i, " +
                " base_team_member m,base_doctor d  " +
                "WHERE " +
                " sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"'" +
                " AND r.service_package_id = i.service_package_id " +
                "AND i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                "               and m.del = '1'" +
                "AND sr.`status` = 1";
        if(StringUtils.isNoneBlank(orgCode)){
            sql += " and i.org_code = '"+orgCode+"' " ;
        }
        List<BaseDoctorDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(BaseDoctorDO.class));
        return list;
    }
    /**
     * 获取居民签约的服务项
     * @param patientId
@ -130,7 +156,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @return
     */
    public List<Map<String,Object>> fingServiceItemsByPatientId(String patientId){
        String sql = "SELECT DISTINCT i.code,i.name from base_service_package_sign_record sr,base_service_package_record r, " +
        String sql = "SELECT DISTINCT i.code,i.name,i.team_code from base_service_package_sign_record sr,base_service_package_record r, " +
                " base_service_package_item i  where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "  and i.del = 1 and sr.`status`=1 and  sr.patient  = '"+patientId+"' ";
        return jdbcTemplate.queryForList(sql);
@ -175,12 +201,26 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_doctor d " +
                "WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                "and m.del = '1' and d.level = " + level+
                " and sr.id = '"+signId+"' ";
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 根据居民和服务项查找医生
     * @param patientId
     */
    public List<Map<String,Object>> fingdDoctorByPaitenId(String patientId,String serviceItem){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r,  " +
                "               base_service_package_item i,base_team_member m,base_doctor d  " +
                "               WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "               and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                "               and m.del = '1' and sr.patient = '"+patientId+"' " +
                "and i.`code` = '"+serviceItem+"'";
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 根据服务包id查找医生/助老员
     * @param packageId
@ -189,7 +229,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_doctor d " +
                "WHERE r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                "and m.del = '1' and d.level = " + level+
                " and r.id = '"+packageId+"' ";
        return jdbcTemplate.queryForList(sql);