Bladeren bron

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

wangjun 4 jaren geleden
bovenliggende
commit
f001cf549d

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

@ -746,6 +746,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, "该操作没有权限"));

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -136,4 +136,21 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = BaseRequestMapping.BasePatient.updatePatientPw)
    @ApiOperation(value = "修改居民账号密码")
    public Envelop updateDoctorPw(@ApiParam(name = "id", value = "居民ID")
                                  @RequestParam(value = "id", required = true)String id,
                                  @ApiParam(name = "pw", value = "密码")
                                  @RequestParam(value = "pw", required = true)String pw,
                                  @ApiParam(name = "orgPw", value = "原密码")
                                  @RequestParam(value = "orgPw", required = false)String orgPw)throws Exception{
        Boolean isSuccess = patientService.updatePatientPw(id,pw,orgPw);
        if (isSuccess){
            return success(isSuccess);
        }else {
            return failed("修改失败,请检查原密码是否正确");
        }
    }
}

+ 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;
    }
}

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -16,6 +16,8 @@ import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
@ -141,6 +143,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
//        patientBrief.setCityName(patientDetail.getCityName());
//        patientBrief.setTownCode(patientDetail.getTownCode());
//        patientBrief.setTownName(patientDetail.getTownName());
        patientBrief.setPhoto(patientDetail.getPhoto());
        patientBrief.setLiveProvinceCode(patientDetail.getLiveProvinceCode());
        patientBrief.setLiveProvinceName(patientDetail.getLiveProvinceName());
        patientBrief.setLiveCityCode(patientDetail.getLiveCityCode());
@ -186,4 +189,21 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        }
        patientLabelDao.save(labelDOList);
    }
    public Boolean updatePatientPw(String id,String pw,String orgPw){
        BasePatientDO patientDO = patientDao.findOne(id);
        String orgPwMd5 = MD5.md5Hex(orgPw + "{" + patientDO.getSalt() + "}");
        if(!orgPwMd5.equals(patientDO.getPassword())){
            return false;
        }
        String salt = randomString(5);
        patientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
        patientDO.setSalt(salt);
        patientDao.save(patientDO);
        /*//设置更新时间
        saveDoctorPwlimitDate(id);*/
        return true;
    }
}

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

@ -130,7 +130,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 +175,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 +203,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);