ソースを参照

Merge branch 'srdev' of yeshijie/patient-co-management into srdev

yeshijie 7 年 前
コミット
774c458ba8
21 ファイル変更510 行追加528 行削除
  1. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/consult/Consult.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java
  3. 22 7
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java
  4. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/MessageNoticeSetting.java
  5. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java
  6. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorDao.java
  7. 42 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  8. 0 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java
  9. 64 232
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  10. 2 45
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheduling/DoctorWorkTimeService.java
  11. 38 14
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/DoctorService.java
  12. 5 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java
  13. 19 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jkEduArticle/ThirdJkEduArticleService.java
  14. 44 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/im/imController.java
  15. 7 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  16. 28 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  17. 204 190
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  18. 3 1
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  19. 4 1
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  20. 3 1
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  21. 4 1
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/consult/Consult.java

@ -42,7 +42,7 @@ public class Consult extends IdEntity {
	private String del;
	// 结束时间
	private Date endTime;
	//签约表Code
	//签约表Code 废弃
	private String signCode;
	private String relationCode;//关联业务表的code

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java

@ -21,7 +21,7 @@ public class ConsultTeam extends IdEntity {
	private String consult;         // 咨询标识
	private String doctor;          // 医生标识
	private String team;            // 三师团队标识
	private Integer type;           //  1、三师咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询
	private Integer type;           //  1、关注咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询
	private String patient;         // 提问者标识
	private String name;            // 患者姓名
	private Integer sex;            // 患者性别

+ 22 - 7
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java

@ -1,16 +1,13 @@
package com.yihu.wlyy.entity.doctor.profile;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.yihu.wlyy.entity.IdEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * 医生信息
@ -71,7 +68,9 @@ public class Doctor extends IdEntity {
    private String certificateNum;     //CA证书编号
    private String openid; //医生微信openID
    private  Integer concernNum;//关注人数
    private Integer concernNum;//关注人数
    private Integer consultNum;//咨询数
    private Integer articleNum;//发表的文章数
    //=====================非hibernate字段=========================
    private String concernCode;//关注code
@ -459,4 +458,20 @@ public class Doctor extends IdEntity {
    public void setConcernNum(Integer concernNum) {
        this.concernNum = concernNum;
    }
    public Integer getConsultNum() {
        return consultNum;
    }
    public void setConsultNum(Integer consultNum) {
        this.consultNum = consultNum;
    }
    public Integer getArticleNum() {
        return articleNum;
    }
    public void setArticleNum(Integer articleNum) {
        this.articleNum = articleNum;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/MessageNoticeSetting.java

@ -21,7 +21,7 @@ public class MessageNoticeSetting extends IdEntity{
    private String type;// '类型(1医生,2居民)'
    private Integer masterSwitch;// '总开关' (1开,0关)
    private Integer imSwitch;//'im消息开关'(1开,0关)
    private Integer familyTopicSwitch;// '健管师邀请后推送开关'(1开,0关)
    private Integer familyTopicSwitch;// '健管师邀请后推送开关'(1开,0关) 废弃字段
    private Integer signSwitch;// '签约消息开关'(1开,0关)
    private Integer healthSignSwitch;// '体征消息开关'(1开,0关)
    private Integer systemSwitch;// '系统消息开关'(1开,0关)

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java

@ -30,8 +30,8 @@ public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam,
	List<ConsultTeam> findUnfinishedConsultType(String patient,String doctor);
	// 统计未完成的数量
	@Query("select count(1) from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?1 and a.status = 0 and a.del = '1'and b.to=?2")
	int countByPatient(String patient,String doctor);
	@Query("select count(1) from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?1 and a.status = 0 and a.del = '1'and b.to=?2 and a.type=?3 ")
	int countByPatient(String patient,String doctor,Integer type);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and b.from is null")

+ 16 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorDao.java

@ -163,6 +163,22 @@ public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, Jpa
    @Query("update Doctor set checkPassword = ?2 ,checkSalt = ?3  where code = ?1")
    int updateCheckPassword(String code, String checkPassword, String checkSalt);
    @Modifying
    @Query("update Doctor set concernNum = concernNum+1  where code = ?1")
    int updateConcernNum(String code);
    @Modifying
    @Query("update Doctor set consultNum = consultNum+1  where code = ?1")
    int updateConsultNum(String code);
    @Modifying
    @Query("update Doctor set articleNum = articleNum+1  where code = ?1")
    int addArticleNum(String code);
    @Modifying
    @Query("update Doctor set articleNum = articleNum-1  where code = ?1 and articleNum>0")
    int subArticleNum(String code);
    @Query("select count(1) from Doctor where code=?1 and idcard=?2 ")
    Integer checkCertificate(String doctorCode,String certificateNum);

+ 42 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -138,6 +138,48 @@ public class DoctorInfoService extends BaseService {
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    /**
     * 增加文章数
     * @param doctorCode
     */
    public void addArticleNum(String doctorCode){
        Doctor doctor = doctorDao.findByCodeWithLock(doctorCode);
        if(doctor.getArticleNum()==null){
            doctor.setArticleNum(0);
        }
        doctor.setArticleNum(doctor.getArticleNum()+1);
        doctorDao.save(doctor);
    }
    /**
     * 减少文章数(删除文章)
     * @param doctorCode
     */
    public void subArticleNum(String doctorCode){
        Doctor doctor = doctorDao.findByCodeWithLock(doctorCode);
        if(doctor.getArticleNum()==null){
            doctor.setArticleNum(0);
        }
        doctor.setArticleNum(doctor.getArticleNum()-1);
        if(doctor.getArticleNum()<0){
            doctor.setArticleNum(0);
        }
        doctorDao.save(doctor);
    }
    /**
     * 增加咨询数
     * @param doctorCode
     */
    public void addConsultNum(String doctorCode){
        Doctor doctor = doctorDao.findByCodeWithLock(doctorCode);
        if(doctor.getConsultNum()==null){
            doctor.setConsultNum(0);
        }
        doctor.setConsultNum(doctor.getConsultNum()+1);
        doctorDao.save(doctor);
    }
    /**
     * 获取医生的签约病人
     *

+ 0 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java

@ -72,10 +72,6 @@ public class ConsultService extends BaseService {
		consult.setSymptoms(symptoms);
		consult.setImages(images);
		consult.setType(type);
		SignFamily signFamily = signFamilyDao.findByPatient(patient);
		if(signFamily!=null){
			consult.setSignCode(signFamily.getCode());
		}
		return consultDao.save(consult);
	}

+ 64 - 232
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.service.app.consult;
import com.yihu.wlyy.adapter.PresModeAdapter;
import com.yihu.wlyy.entity.concern.ConcernDO;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.ConsultTeamDoctor;
@ -8,18 +9,16 @@ import com.yihu.wlyy.entity.consult.ConsultTeamLog;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.discussion.WlyyTalkGroup;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.entity.zydict.ZyIvPhysicDict;
import com.yihu.wlyy.repository.concern.ConcernDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
import com.yihu.wlyy.repository.consult.ConsultTeamLogDao;
@ -34,6 +33,8 @@ import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.concern.ConcernService;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
@ -130,7 +131,7 @@ public class ConsultTeamService extends ConsultService {
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private ImUtill ImUtill;
    private ImUtill imUtill;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Autowired
@ -177,6 +178,12 @@ public class ConsultTeamService extends ConsultService {
    private PushMsgTask pushMsgTask;
    @Autowired
    private PrescriptionExplainDao prescriptionExplainDao;
    @Autowired
    private ConcernService concernService;
    @Autowired
    private ConcernDao concernDao;
    @Autowired
    private DoctorInfoService doctorInfoService;
    @PostConstruct
    public void init() {
@ -203,29 +210,6 @@ public class ConsultTeamService extends ConsultService {
            json.put("msg","您还未签约,不能发起续方咨询");
            return json;
        }
        //点击后判断,如果用户当前存在可申请续方的处方记录,则进入续方申请流程,若不存在可续方记录,alert“当前没有可以申请续方的处方记录”
        // 智业接口没有返回列表,是单条 所以先不处理
//        int num = 0;
//        Patient p = patientDao.findByCode(patient);
//        String rp= jwPrescriptionService.getRecipeList(p.getSsc(),null,null,null);
//        com.alibaba.fastjson.JSONArray pres =presModeAdapter.modeToPrescription(rp);
//        Iterator iterator = pres.iterator();
//        while (iterator.hasNext()){
//            com.alibaba.fastjson.JSONObject r = ( com.alibaba.fastjson.JSONObject)iterator.next();
//            com.alibaba.fastjson.JSONArray des = r.getJSONArray("prescriptionDt");
//            for(int i=0 ;i<des.size();i++){
//                PrescriptionDiagnosis ds = des.getObject(i,PrescriptionDiagnosis.class);
//                if(gxy.equals(ds.getHealthProblem())||tnb.equals(ds.getHealthProblem())){
//                    //为糖尿病高血压
//                    num++;
//                    break;
//                }
//            }
//        }
//        if(num==0){
//            json.put("msg","当前没有可以申请续方的处方记录");
//            return json;
//        }
        //续方说明
        List<PrescriptionExplain> list = prescriptionExplainDao.findList();
@ -246,57 +230,13 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 查询患者是否还有未结束的三师咨询
     * 查询患者与医生是否还有未结束的关注咨询
     *
     * @param patient
     * @return
     */
    public boolean exist(String patient, Integer type) throws Exception {
        DoctorTeamMember member = null;
        String memberCode=null;
        // 咨询三师
        if (type == 1) {
            // 查询三师签约信息
            SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
            if (sc == null) {
                throw new Exception("不存在三师签约");
            }
            // 设置健康管理师,三师咨询默认给健康管理师处理
            //查找病人所在的团队
            DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
            //得到团队的健康管理师
            member = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
            if (member == null) {
                member = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
            }
            memberCode= member.getCode();
        } else if (type == 2) {
            // 咨询家庭医生
            SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
            if (sf == null) {
                throw new Exception("不存在家庭签约");
            }
            if (StringUtils.isEmpty(sf.getDoctorHealth())){
                memberCode = sf.getDoctor();
            }else {
                memberCode = sf.getDoctorHealth();
            }
            // 设置健康管理师,家庭医生咨询默认给健康管理师处理
            //查找病人所在的团队
//            DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
//            //得到团队的健康管理师
//            member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
//
//            if (member == null) {
//                member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
//            }
        }
//        if (member == null) {
//            throw new Exception("找不到签约服务团队医生");
//        }
        int count = consultTeamDao.countByPatient(patient, memberCode);
    public boolean exist(String patient,Integer type, String doctor) throws Exception {
        int count = consultTeamDao.countByPatient(patient, doctor,type);
        return count > 0;
    }
@ -815,17 +755,26 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 患者端
     * 添加三师咨询
     * 添加咨询
     *
     * @param ct      三师咨询对象
     * @param ct      咨询对象
     * @param patient 患者标识
     * @param doctorCode 咨询医生
     * @return
     * @throws Exception
     */
    public JSONObject addTeamConsult(ConsultTeam ct, String patient,String agent) throws Exception {
    public JSONObject addTeamConsult(ConsultTeam ct, String patient,String agent,String doctorCode) throws Exception {
        JSONObject re = new JSONObject();
        if (exist(patient, ct.getType())) {//判断是否有未结束的咨询移到同步方法中
            re.put("status",-3);
        //自动关注 咨询关注
        ConcernDO concernDO = concernDao.findByPatientAndDoctor(patient,doctorCode);
        if(concernDO==null){
            concernService.addConcern(patient,doctorCode,3);
            concernDO = concernDao.findByPatientAndDoctor(patient,doctorCode);
        }
        if (exist(patient, ct.getType(),doctorCode)) {
            re.put("status",-1);
            return re;
        }
@ -834,90 +783,8 @@ public class ConsultTeamService extends ConsultService {
        if(patient.equals(agent)){
            agent = null;
        }
        users.put(doctorCode, 0);
        // 咨询三师
        if (ct.getType() == 1) {
            // 查询三师签约信息
            SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
            if (sc == null) {
                // 不存在三师签约
                re.put("status",-2);
                return re;
            }
            ct.setTeam(sc.getTeamCode());
            // 设置健康管理师,三师咨询默认给健康管理师处理
            //查找病人所在的团队
            DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
            //得到团队的健康管理师
            DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
            if (doctorTeamMemberHealthy == null) {
                ct.setDoctor(doctorTeamMember.getMemberCode());
                users.put(doctorTeamMember.getMemberCode(), 0);
            } else {
                users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
                if (doctorTeamMember != null) {
                    if (users.isNull(doctorTeamMember.getMemberCode())) {
                        users.put(doctorTeamMember.getMemberCode(), 1);
                    }
                }
                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
            }
            // 设置家庭医生
            ct.setAdminTeamId(sc.getAdminTeamId());
        } else if (ct.getType() == 2) {
            // 咨询家庭医生
            SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
            if (sf == null) {
                // 不存在家庭签约
                re.put("status",-1);
                return re;
            }
            ct.setTeam(sf.getTeamCode());
            // 设置健康管理师,家庭医生咨询默认给健康管理师处理
            //查找病人所在的团队
            //1.3.3.2 更改从签约记录判断团队成员,分配建管师
            if(StringUtils.isNotBlank(sf.getDoctorHealth())) {
                users.put(sf.getDoctorHealth(), 0);
                ct.setDoctor(sf.getDoctorHealth());
                if (StringUtils.isNotBlank(sf.getDoctor())) {
                    if (users.isNull(sf.getDoctor())) {
                        //全科需要判断是否开启健管师邀请后在接收消息
                        int isGetMessage = 1;
                        if(!messageService.getMessageNoticeSettingByMessageType(sf.getDoctor(),"1", MessageNoticeSetting.MessageTypeEnum.familyTopicSwitch.getValue())){
                            isGetMessage = 0;
                        }
                        users.put(sf.getDoctor(), isGetMessage);
                    }
                }
            } else {
                ct.setDoctor(sf.getDoctor());
                users.put(sf.getDoctor(), 0);
            }
//            DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
//            //得到团队的健康管理师
//            DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
//            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
//            if (doctorTeamMemberHealthy == null) {
//                ct.setDoctor(doctorTeamMember.getMemberCode());
//                users.put(doctorTeamMember.getMemberCode(), 0);
//            } else {
//                users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
//                if (doctorTeamMember != null) {
//                    //全健同一个人导致会话成员状态问题处理
//                    if (users.isNull(doctorTeamMember.getMemberCode())) {
//                        users.put(doctorTeamMember.getMemberCode(), 1);
//                    }
//                }
//                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
//            }
            // 设置家庭医生
            ct.setAdminTeamId(sf.getAdminTeamId());
        }
        // 设置患者信息
        ct.setPatient(patient);
        // 查询患者信息
@ -943,12 +810,13 @@ public class ConsultTeamService extends ConsultService {
        consult.setGuidance(ct.getGuidance());
        // 设置咨询标识
        ct.setConsult(consult.getCode());
        //设置服务团队
        ct.setTeam(concernDO.getTeamCode());
        //推送给IM去创建议题,取得成员消息
//        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), "咨询问题:"+consult.getSymptoms(), consult.getImages());
        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages(),agent);
        users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
        JSONObject obj = ImUtill.createTopics(patient + "_" + ct.getTeam() + "_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
        JSONObject messages = imUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages(),agent);
        users.put(patient, 0);
        JSONObject obj = imUtill.createTopics(patient + "_" + ct.getTeam() + "_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
        if (obj == null) {
            throw new RuntimeException("IM消息发送异常!");
        }
@ -959,6 +827,9 @@ public class ConsultTeamService extends ConsultService {
        consultTeamDao.save(ct);
        consultDao.save(consult);
        //新增咨询数
        doctorInfoService.addConsultNum(ct.getDoctor());
        JSONArray doctor = new JSONArray();
        for (String key : users.keySet()) {
            if (patient.equals(key)) {
@ -978,7 +849,6 @@ public class ConsultTeamService extends ConsultService {
        // 添加咨询转发记录
        // 添加医生咨询日志
        String content = addLogs(ct);
        re.put("doctor",doctor);
        re.put("status",1);
        return re;
@ -1006,10 +876,7 @@ public class ConsultTeamService extends ConsultService {
                return -2;
            }
//            String checkPre = prescriptionInfoService.checkPre(patient,DateUtil.getStringDateShort()+" 00:00:00");
//            if("0".equals(checkPre)){//存在未结算的续方
//                return -3;
//            }
            ct.setAdminTeamId(signFamily.getAdminTeamId());
            Doctor doctor = doctorDao.findByAdminTeamId(signFamily.getAdminTeamId());
            doctorCode = doctor.getCode();
@ -1033,41 +900,6 @@ public class ConsultTeamService extends ConsultService {
            }
            //3、获取上次续方时间:与平安的“智慧医保的审方系统”对接,判断居民上次续方时间,点击跳转上次续方记录。(此功能需与第三方系统对接,如果本次版本无法实现,则消息中不显示此条信息)
            jsonObject.put("lastTime","");
    
//            //--增加问卷填写情况---huangwenjie--2017.11.01---已和产品确认,这块消息不在续方咨询消息中添加
//            List<PrescriptionFollowupContent> prescriptionFollowupContents =prescriptionFollowupContentDao.findByPrescriptionCode(prescription.getCode());
//            boolean zzFlag = false;//是否填写症状问卷
//            boolean tzssFlag = false;//是否填写体征和生活问卷
//            for (PrescriptionFollowupContent prescriptionFollowupContent: prescriptionFollowupContents) {
//                if(!zzFlag && "1".equals(prescriptionFollowupContent.getFollowupProject())){
//                    zzFlag = true;
//                }
//
//                if(!tzssFlag &&
//                        ("2".equals(prescriptionFollowupContent.getFollowupProject())
//                                || "4".equals(prescriptionFollowupContent.getFollowupProject()))
//                        ){
//                    zzFlag = true;
//                }
//
//                if(zzFlag && tzssFlag){
//                    break;
//                }
//            }
//            if(zzFlag){
//                jsonObject.put("zzMsg","居民已填写问卷");
//            }else{
//                jsonObject.put("zzMsg","居民未填写问卷");
//            }
//            if(tzssFlag){
//                jsonObject.put("tzssMsg","居民已填写问卷");
//            }else{
//                jsonObject.put("tzssMsg","居民未填写问卷");
//            }
//            jsonObject.put("zzFlag",zzFlag);
//            jsonObject.put("tzssFlag",tzssFlag);
            
            
            
            String content = jsonObject.toString();
@ -1118,11 +950,11 @@ public class ConsultTeamService extends ConsultService {
            ct.setConsult(consult.getCode());
            //推送给IM去创建议题,取得成员消息
            JSONObject messages = ImUtill.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(),agent);
            JSONObject messages = imUtill.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(),agent);
            //5、(im创建咨询) 续方咨询的sessionid为居民code+续方code+咨询类型
            String sessionId = patient + "_" + consult.getCode() + "_" + ct.getType();
            JSONObject obj = ImUtill.createTopics(sessionId, consult.getCode(), p.getName(), users, messages, ImUtill.SESSION_TYPE_PRESCRIPTION);
            JSONObject obj = imUtill.createTopics(sessionId, consult.getCode(), p.getName(), users, messages, ImUtill.SESSION_TYPE_PRESCRIPTION);
            if (obj == null) {
                throw new RuntimeException("IM消息发送异常!");
            }
@ -1885,8 +1717,8 @@ public class ConsultTeamService extends ConsultService {
        return consultTeamLogDao.findOne(logId);
    }
    public boolean isExistConsult(String uid, String doctor) {
        int consultTeam = consultTeamDao.countByPatient(uid, doctor);
    public boolean isExistConsult(String uid,Integer type, String doctor) {
        int consultTeam = consultTeamDao.countByPatient(uid, doctor,type);
        if (consultTeam > 0) {
            return true;
        } else {
@ -1918,7 +1750,7 @@ public class ConsultTeamService extends ConsultService {
            content = member.getName() + "("+relations.get(familyMember.getFamilyRelation())+")"+content;
        }
        ImUtill.sendIntoTopicIM(ct.getPatient(),ct.getPatient(),ct.getConsult(),content,agent,intoUserName);
        imUtill.sendIntoTopicIM(ct.getPatient(),ct.getPatient(),ct.getConsult(),content,agent,intoUserName);
        return 0;
    }
@ -2215,7 +2047,7 @@ public class ConsultTeamService extends ConsultService {
        participants.put(ct.getPatient(), 0);
        participants.put(ct.getDoctor(), 0);
        Doctor doctor = doctorService.findDoctorByCode(uid);
        JSONObject sessionJson = ImUtill.createSession(participants, ImUtill.SESSION_TYPE_P2P, doctor.getName() + "发起求助!", "");
        JSONObject sessionJson = imUtill.createSession(participants, ImUtill.SESSION_TYPE_P2P, doctor.getName() + "发起求助!", "");
        if (sessionJson.getInt("status") == -1) {
            throw new RuntimeException(sessionJson.getString("message"));
        }
@ -2224,13 +2056,13 @@ public class ConsultTeamService extends ConsultService {
            ct.setTeam(oldConsultCode);
            ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
            if (oldConsult != null && isSend == 1) {
                ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "居民问题:" + oldConsult.getSymptoms(), "1");
                imUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "居民问题:" + oldConsult.getSymptoms(), "1");
                //推送给IM图片
                if (StringUtils.isNotEmpty(oldConsult.getImages())) {
                    String[] images = oldConsult.getImages().split(",");
                    for (String image : images) {
                        if (StringUtils.isNoneEmpty(image)) {
                            ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2", image, "1");
                            imUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2", image, "1");
                        }
                    }
                }
@ -2242,17 +2074,17 @@ public class ConsultTeamService extends ConsultService {
            qiuzuObj.put("old_consult_code", oldConsultCode);
            qiuzuObj.put("doctor", ct.getDoctor());
            qiuzuObj.put("doctor_name", doctorTemp.getName());
            ImUtill.sendTopicIM(doctor.getCode(), doctor.getName(), oldConsultCode, "5", qiuzuObj.toString(),null);
            imUtill.sendTopicIM(doctor.getCode(), doctor.getName(), oldConsultCode, "5", qiuzuObj.toString(),null);
        }
        ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "咨询问题:" + ct.getSymptoms(), "1");
        imUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "咨询问题:" + ct.getSymptoms(), "1");
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
            for (String image : images) {
                if (StringUtils.isNoneEmpty(image)) {
                    ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2", image, "1");
                    imUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2", image, "1");
                }
            }
        }
@ -2299,12 +2131,12 @@ public class ConsultTeamService extends ConsultService {
        // 添加医生咨询日志
        String content = addLogs(ct);
        if (StringUtils.isBlank(oldConsultCode)) {
            JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, consult.getImages(),null);
            JSONObject messages = imUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, consult.getImages(),null);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put(ct.getPatient(), 0);
            jsonObject.put(ct.getDoctor(), 0);
            //设置消息ID
            JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
            JSONObject obj = imUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
            if (obj == null || obj.getInt("status") == -1) {
                throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
            }
@ -2315,28 +2147,28 @@ public class ConsultTeamService extends ConsultService {
            ConsultTeam consultTeam = consultTeamDao.findByConsult(oldConsultCode);
            ct.setTeam(oldConsultCode);
            if (oldConsult != null && isSend == 1) {
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), "居民问题:" + oldConsult.getSymptoms(), oldConsult.getImages(),null);
                JSONObject messages = imUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), "居民问题:" + oldConsult.getSymptoms(), oldConsult.getImages(),null);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
                JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
                JSONObject obj = imUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
                if (obj == null || obj.getInt("status") == -1) {
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                }
                ct.setStartMsgId(obj.get("start_msg_id").toString());
                Thread.sleep(100);//消息发送顺序问题处理
                ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "6", content, null);
                imUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "6", content, null);
                if (StringUtils.isNotBlank(consult.getImages())) {
                    String imgs[] = consult.getImages().split(",");
                    for (String url : imgs)
                        ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "2", url, null);
                        imUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "2", url, null);
                }
            } else if (oldConsult != null && isSend == 0) {
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, oldConsult.getImages(),null);
                JSONObject messages = imUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, oldConsult.getImages(),null);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
                JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
                JSONObject obj = imUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
                if (obj == null || obj.getInt("status") == -1) {
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                }
@ -2347,7 +2179,7 @@ public class ConsultTeamService extends ConsultService {
            qiuzuObj.put("old_consult_code", oldConsultCode);
            qiuzuObj.put("doctor", ct.getDoctor());
            qiuzuObj.put("doctor_name", doctor.getName());
            ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), oldConsultCode, "5", qiuzuObj.toString(), null);
            imUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), oldConsultCode, "5", qiuzuObj.toString(), null);
        }
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
@ -2388,7 +2220,7 @@ public class ConsultTeamService extends ConsultService {
            }
        }
        JSONObject obj = ImUtill.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
        JSONObject obj = imUtill.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
        if (obj == null) {
            throw new RuntimeException("IM消息结束异常!");
        }
@ -2583,9 +2415,9 @@ public class ConsultTeamService extends ConsultService {
        jsonObject.put(ct.getPatient(), 0);
        jsonObject.put(ct.getDoctor(), 0);
        JSONObject messages = ImUtill.getCreateTopicMessage(senderId, senderName, senderName + "发起咨询", content, ct.getImages(),agent);
        JSONObject messages = imUtill.getCreateTopicMessage(senderId, senderName, senderName + "发起咨询", content, ct.getImages(),agent);
        JSONObject obj = ImUtill.createTopics(null, consult.getCode(), consult.getSymptoms(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
        JSONObject obj = imUtill.createTopics(null, consult.getCode(), consult.getSymptoms(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
        if (obj == null) {
            throw new RuntimeException("im消息创建异常!");
        }
@ -2594,7 +2426,7 @@ public class ConsultTeamService extends ConsultService {
        }
        //设置消息ID
        ct.setStartMsgId(obj.getString("start_msg_id"));
        JSONObject object = ImUtill.getTopic(ct.getConsult());
        JSONObject object = imUtill.getTopic(ct.getConsult());
        JSONArray array = new JSONArray(object.get("data").toString());
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
@ -2604,7 +2436,7 @@ public class ConsultTeamService extends ConsultService {
            //获取会话ID。休眠1秒后继续获取相应信息
            // PS:可以通过前端请求两次去解决,由于离职,就不挖坑了,后来者可以改善、
            Thread.sleep(1000);
            object = ImUtill.getTopic(ct.getConsult());
            object = imUtill.getTopic(ct.getConsult());
            array = new JSONArray(object.get("data").toString());
        }
        return array.getJSONObject(0);
@ -2709,7 +2541,7 @@ public class ConsultTeamService extends ConsultService {
        contentobj.put("msgType",type);
        contentobj.put("isSendWxTemplate",true);//是否发送咨询回复的微信模板
        //医生发送Im消息
        ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "17", contentobj.toString(), null);
        imUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "17", contentobj.toString(), null);
//        contentobj.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
//        //居民发送Im消息
//        ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "17", contentobj.toString(), null);

+ 2 - 45
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheduling/DoctorWorkTimeService.java

@ -4,7 +4,6 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.schedule.DoctorFamousConsultTimesRemain;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorWorkTimeDao;
import com.yihu.wlyy.repository.doctor.DoctorWorkWeekDao;
@ -13,13 +12,11 @@ import com.yihu.wlyy.repository.message.MessageNoticeSettingDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.eval.StringValueEval;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.print.Doc;
import javax.transaction.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
@ -737,7 +734,7 @@ public class DoctorWorkTimeService extends BaseService {
        }
    }
    public JSONObject isDoctorWorkingWhenConsult(String doctor,String doctorHealth) throws Exception {
    public JSONObject isDoctorWorkingWhenConsult(String doctor) throws Exception {
        JSONObject json = new JSONObject();
        Calendar calendar = Calendar.getInstance();
        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
@ -745,47 +742,7 @@ public class DoctorWorkTimeService extends BaseService {
        if (week == 0) {
            week = 7;
        }
        //判断居民签约的全科医生是否关闭了"健康咨询在健管师邀请后参与"设置
        //MessageNoticeSetting messageNoticeSetting = messageNoticeSettingDao.findByUserAndType(doctor,"1");
        com.alibaba.fastjson.JSONObject re = messageService.getMessageNoticSetting(doctor,"1");
        if (re!=null){
            //健管师推荐开启,只判断健管师的时间
            if ("1".equals(re.getString("familyTopicSwitch"))){
                json = doctorWork(doctorHealth,week,calendar);
            }else {//健管师推荐关闭,则两个都要判断
                JSONObject doctorJson = doctorWork(doctor,week,calendar);
                JSONObject doctorHealthJson = doctorWork(doctorHealth,week,calendar);
                String doctorStatus = doctorJson.getString("status");
                String doctorHealthStatus = doctorHealthJson.getString("status");
                //两个都不接受咨询时,无法咨询
                if ("0".equals(doctorStatus) && "0".equals(doctorHealthStatus)){
                    json.put("status", "0");
                    json.put("msg", "医生不接受咨询");
                }
                //两个其中有一个可以咨询时都可以咨询
                if ("1".equals(doctorStatus) || "1".equals(doctorHealthStatus)){
                    json.put("status", "1");
                    json.put("msg", "医生当前接受咨询");
                }
                //如果全科和健管师都不在时间范围
                if ("2".equals(doctorStatus) && "2".equals(doctorHealthStatus)){
                    json.put("status","2");
                    json.put("msg","全科医生和健管师当前都不在工作时间");
                }
                //健管师在工作时间,全科不在
                if ("2".equals(doctorStatus) && "1".equals(doctorHealthStatus)){
                    json.put("status","3");
                    json.put("msg","全科医生当前不在工作时间");
                }
                //全科在工作时间,健管师不在
                if ("1".equals(doctorStatus) && "2".equals(doctorHealthStatus)){
                    json.put("status","4");
                    json.put("msg","健管师当前不在工作时间");
                }
            }
        }
        json = doctorWork(doctor,week,calendar);
        return json;
    }

+ 38 - 14
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/DoctorService.java

@ -5,30 +5,22 @@
 *******************************************************************************/
package com.yihu.wlyy.service.common.account;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.util.EncodesUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.utils.Clock;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.util.EncodesUtil;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
/**
 * 医生基本信息类.
@ -106,6 +98,38 @@ public class DoctorService extends TokenService {
        }
    }
    /**
     * 分页查找医生列表
     * @param hospitalCode
     * @param name
     * @param page
     * @param pagesize
     * @return
     */
    public List<Doctor> findDoctorLists(String hospitalCode,String name,String dept, Integer page, Integer pagesize) {
        String sql = "select * from wlyy_doctor where del=1 and status=1   ";
        List<Object> args = new ArrayList<>();
        if (!org.springframework.util.StringUtils.isEmpty(hospitalCode)) {
            sql += " and hospital = ? ";
            args.add(hospitalCode);
        }
        if (!org.springframework.util.StringUtils.isEmpty(name)) {
            sql += " and (name like ? or dept_name like ?)";
            args.add("%"+name+"%");
            args.add("%"+name+"%");
        }
        if (!org.springframework.util.StringUtils.isEmpty(dept)) {
            sql += " and dept = ? ";
            args.add(dept);
        }
        sql += " limit " + (page * pagesize) + "," + pagesize;
        List<Doctor> doctorList = jdbcTemplate.query(sql, args.toArray(), new BeanPropertyRowMapper(Doctor.class));
        return doctorList;
    }
    public Doctor findbyIdCard(String idcard) {
        return doctorDao.findbyIdCard(idcard);
    }

+ 5 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

@ -1142,6 +1142,8 @@ public class JMJkEduArticleService extends BaseService {
            List<Map<String, Object>> list = doctorInfoService.getDoctorManagerRole(userCode,"Manage_Article_Authentication");
            if(list.size()>0&&!StringUtils.isEmpty(list.get(0).get("code"))){
                isAuthentication = 1;
                //发表的文章数+1
                doctorInfoService.addArticleNum(userCode);
            }
        }
        thirdJkEduArticleService.saveArticle(userCode,articleTitle,articleType,articlelevel,secondLevelCategoryId,image,
@ -1251,6 +1253,9 @@ public class JMJkEduArticleService extends BaseService {
        String[] str = articleId.split(",");
        for(String one: str){
            //发表的文章数+1
            JSONObject obj = thirdJkEduArticleService.getArticalById(one,null,"");
            doctorInfoService.addArticleNum(obj.getString("operatorId"));
            thirdJkEduArticleService.authenticationArticle(one,isAuthentication,firstLevelCategoryId,firstLevelCategoryName,secondLevelCategoryId,secondLevelCategoryName);
        }
    }

+ 19 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jkEduArticle/ThirdJkEduArticleService.java

@ -3,11 +3,9 @@ package com.yihu.wlyy.service.third.jkEduArticle;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.DoctorRole;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorRoleDao;
@ -15,24 +13,23 @@ import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.web.third.gateway.service.GcLabelService;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import springfox.documentation.spring.web.json.Json;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * 福州总部-健康教育医生APP接口文档
@ -72,6 +69,8 @@ public class ThirdJkEduArticleService extends BaseService {
    private DoctorRoleDao doctorRoleDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private DoctorInfoService doctorInfoService;
    //    private String baseUrl = "http://service.yihu.com:8085/WsPlatform/rest";
//    private String baseUrl = "http://172.17.110.230:83/WsPlatform/rest";
@ -687,6 +686,18 @@ public class ThirdJkEduArticleService extends BaseService {
        if (!"10000".equals(json.getString("Code"))) {
            throw new Exception(json.getString("Message"));
        }
        try {
            //文章数-1
            String[] str = ids.split(",");
            for(String one: str){
                //发表的文章数+1
                JSONObject obj = getArticalById(one,null,"");
                doctorInfoService.addArticleNum(obj.getString("operatorId"));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

+ 44 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/im/imController.java

@ -34,7 +34,7 @@ public class imController extends BaseController {
    @Autowired
    private ConsultDao consultDao;
    @Autowired
    private ImUtill ImUtill;
    private ImUtill imUtill;
    /**
     * 获取单个咨询
@ -46,7 +46,7 @@ public class imController extends BaseController {
    @ResponseBody
    public String getTopic(String consult) {
        try {
            return success(ImUtill.getTopic(consult).get("data").toString());
            return success(imUtill.getTopic(consult).get("data").toString());
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
@ -74,7 +74,7 @@ public class imController extends BaseController {
            if (StringUtils.isEmpty(doctor)) {
                doctor = getUID();
            }
            String consult = ImUtill.getTeamConsultByStatus(doctor,adminTeamCode, status, reply, page, pagesize);
            String consult = imUtill.getTeamConsultByStatus(doctor,adminTeamCode, status, reply, page, pagesize);
            JSONArray jsonArray = new JSONArray(consult);
            Iterator<Object> it = jsonArray.iterator();
            List list = new ArrayList();
@ -146,9 +146,9 @@ public class imController extends BaseController {
            }
            String consult = null;
            if(type==null){
                consult = ImUtill.getConsultByStatus(doctor, status, reply, page, pagesize);
                consult = imUtill.getConsultByStatus(doctor, status, reply, page, pagesize);
            }else {
                consult = ImUtill.getConsultByStatusAndType(doctor, status, reply,type,patientName,startTime,endTime, page, pagesize);
                consult = imUtill.getConsultByStatusAndType(doctor, status, reply,type,patientName,startTime,endTime, page, pagesize);
            }
            JSONArray jsonArray = new JSONArray(consult);
            Iterator<Object> it = jsonArray.iterator();
@ -220,7 +220,7 @@ public class imController extends BaseController {
            }
            String consult = null;
            consult = ImUtill.getConsultCountByStatusAndType(doctor, status, reply,type,patientName,startTime,endTime);
            consult = imUtill.getConsultCountByStatusAndType(doctor, status, reply,type,patientName,startTime,endTime);
            JSONObject json = new JSONObject(consult);
            return write(200, "查询成功", "total", json.getInt("count"));
        } catch (Exception e) {
@ -229,6 +229,38 @@ public class imController extends BaseController {
        }
    }
    /**
     * 获取医生统计数据
     * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
     *
     * @return
     */
    @RequestMapping(value = "/consult/getDoctorData", method = RequestMethod.GET)
    @ResponseBody
    public String getDoctorData() {
        try {
            String uid = getUID();
            JSONObject json = new JSONObject();
//                未回复
            String totalUnReply = imUtill.getConsultData(uid,null, 0, 0);
            int unReply = Integer.parseInt(totalUnReply);
//                已回复
            String totalReply = imUtill.getConsultData(uid,null, 0, 1);
            String totalReply1 = imUtill.getConsultData(uid,null, 10, null);
            int reply = Integer.parseInt(totalReply) + Integer.parseInt(totalReply1);
//                总咨询量
            String totalConsult = imUtill.getConsultData(uid, null,null, null);
            int consult = Integer.parseInt(totalConsult);
            json.put("totalUnReply", unReply);
            json.put("totalReply", reply);
            json.put("totalConsult", consult);
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    /**
     * 获取团队统计数据
     * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
@ -257,16 +289,16 @@ public class imController extends BaseController {
                map.put("doctor", doctor);
                map.put("type", doc.get("level") == null ? "" : doc.get("level").toString());
//                未回复
                String totalUnReply = ImUtill.getConsultData(doctor,adminTeamCode, 0, 0);
                String totalUnReply = imUtill.getConsultData(doctor,adminTeamCode, 0, 0);
                int unReply = Integer.parseInt(totalUnReply);
                map.put("totalUnReply", unReply);
//                已回复
                String totalReply = ImUtill.getConsultData(doctor,adminTeamCode, 0, 1);
                String totalReply1 = ImUtill.getConsultData(doctor,adminTeamCode, 10, null);
                String totalReply = imUtill.getConsultData(doctor,adminTeamCode, 0, 1);
                String totalReply1 = imUtill.getConsultData(doctor,adminTeamCode, 10, null);
                int reply = Integer.parseInt(totalReply) + Integer.parseInt(totalReply1);
                map.put("totalReply", reply);
//                总咨询量
                String totalConsult = ImUtill.getConsultData(doctor, adminTeamCode,null, null);
                String totalConsult = imUtill.getConsultData(doctor, adminTeamCode,null, null);
                int consult = Integer.parseInt(totalConsult);
                map.put("totalConsult", consult);
@ -325,12 +357,12 @@ public class imController extends BaseController {
            participants.put(getUID(), 0);
            Doctor d = doctorDao.findByCode(getUID());
            //创建医生会话讨论组
            JSONObject sessionObj = ImUtill.createSession(participants, ImUtill.SESSION_TYPE_P2P, d.getName() + "发来消息提醒", "");
            JSONObject sessionObj = imUtill.createSession(participants, ImUtill.SESSION_TYPE_P2P, d.getName() + "发来消息提醒", "");
            if (sessionObj.getInt("status") == -1) {
                throw new RuntimeException(sessionObj.getString("message"));
            }
            JSONObject session = sessionObj.getJSONObject("data");
            ImUtill.sendImMsg(getUID(), d.getName(), session.getString("id"), "1", content, "REMAIN");
            imUtill.sendImMsg(getUID(), d.getName(), session.getString("id"), "1", content, "REMAIN");
            return success("提醒成功!");
        } catch (Exception e) {
            error(e);

+ 7 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -264,13 +264,13 @@ public class DoctorConsultController extends WeixinBaseController {
                json.put("guidance", consult.getGuidance());
                json.put("startId", consult.getStartMsgId());
                json.put("endId", consult.getEndMsgId());
                List<WlyyTalkGroup> wlyyTalkGroups = talkGroupService.findAllConsultTalkGroup(consult.getConsult());
                if (wlyyTalkGroups != null && wlyyTalkGroups.size() > 0) {
                    for (WlyyTalkGroup wlyyTalkGroup : wlyyTalkGroups) {
                        json.put("group" + wlyyTalkGroup.getType(), wlyyTalkGroup.getCode());
                        json.put("groupName" + wlyyTalkGroup.getType(), wlyyTalkGroup.getName());
                    }
                }
//                List<WlyyTalkGroup> wlyyTalkGroups = talkGroupService.findAllConsultTalkGroup(consult.getConsult());
//                if (wlyyTalkGroups != null && wlyyTalkGroups.size() > 0) {
//                    for (WlyyTalkGroup wlyyTalkGroup : wlyyTalkGroups) {
//                        json.put("group" + wlyyTalkGroup.getType(), wlyyTalkGroup.getCode());
//                        json.put("groupName" + wlyyTalkGroup.getType(), wlyyTalkGroup.getName());
//                    }
//                }
                jsonArray.put(json);
            }
            return write(200, "查询成功", "list", jsonArray);

+ 28 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -1,12 +1,14 @@
package com.yihu.wlyy.web.patient.account;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.concern.ConcernDO;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyServer;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.concern.ConcernDao;
import com.yihu.wlyy.repository.patient.SignFamilyServerDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.service.app.account.PatientInfoService;
@ -40,6 +42,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.yihu.wlyy.entity.patient.prescription.PrescriptionLog.PrescriptionLogType.sf;
/**
 * 患者帳戶信息的Controller.
 *
@ -76,6 +80,8 @@ public class PatientController extends WeixinBaseController {
    private WeiXinTagUtil weiXinTagUtil;
    @Autowired
    private RSAUtils rsaUtils;
    @Autowired
    private ConcernDao concernDao;
    /**
     * 患者基本信息查询接口
@ -730,6 +736,28 @@ public class PatientController extends WeixinBaseController {
        }
    }
    /**
     * 查询患者是否关注了医生
     *
     * @return
     */
    @RequestMapping(value = "is_concern")
    @ResponseBody
    @ApiOperation("查询患者是否关注了医生")
    public String is_concern(@ApiParam(name = "doctor", value = "医生编码", defaultValue = "350200")
                             @RequestParam(value = "doctor", required = true) String doctor) {
        try {
            ConcernDO concernDO = concernDao.findByPatientAndDoctor(getRepUID(),doctor);
            if (sf != null) {
                return write(200, "获取关注状态成功!", "data", concernDO.getStatus());
            }
            return write(200, "获取关注状态成功!", "data", -1);
        } catch (Exception e) {
            error(e);
            return error(-1, " !");
        }
    }
    /**
     * 查询患者身份证号
     *

+ 204 - 190
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.ConsultTeamLog;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.organization.HospitalDept;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.logs.BusinessLogs;
@ -17,6 +18,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.consult.DoctorCommentService;
import com.yihu.wlyy.service.app.hospital.HospitalDeptService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionDiagnosisService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
@ -50,7 +52,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 患者端:三师咨询控制类
@ -83,9 +84,9 @@ public class ConsultController extends WeixinBaseController {
    @Autowired
    private PrescriptionDiagnosisService prescriptionDiagnosisService;
    @Autowired
    private CommonUtil CommonUtil;
    private CommonUtil commonUtil;
    @Autowired
    private ImUtill ImUtill;
    private ImUtill imUtill;
    @Autowired
    private HttpUtil httpUtil;
    @Autowired
@ -108,6 +109,10 @@ public class ConsultController extends WeixinBaseController {
    private JdbcTemplate jdbcTemplate;
    @Value("${im.data_base_name}")
    private String im;
    @Autowired
    private HospitalDeptService deptService;
    @Value("${wlyy.hospital}")
    private String defaultHospital;
    /**
     * 患者咨询记录查询
@ -228,17 +233,16 @@ public class ConsultController extends WeixinBaseController {
    }
    /**
     * 患者端在发起家庭医生咨询时检查全科医生和健管师是否在工作
     * 患者端在发起医生咨询时检查医生工作
     * @param doctor
     * @param healthDoctor
     * @return
     */
    @RequestMapping(value = "isDoctorWorkWhenconsult",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("全科医生和健管师是否在工作")
    public String isDoctorWorkWhenconsult(String doctor,String healthDoctor) {
    @ApiOperation("医生是否在工作")
    public String isDoctorWorkWhenconsult(String doctor) {
        try {
            JSONObject result = doctorWorkTimeService.isDoctorWorkingWhenConsult(doctor,healthDoctor);
            JSONObject result = doctorWorkTimeService.isDoctorWorkingWhenConsult(doctor);
            return write(200, result.getString("msg"), "data", result.getString("status"));
        } catch (Exception e) {
            error(e);
@ -331,27 +335,27 @@ public class ConsultController extends WeixinBaseController {
    /**
     * 三师咨询添加接口
     * 咨询添加接口
     *
     * @param type     咨询类型:1三师咨询,2家庭医生咨询
     * @param type     咨询类型:1关注咨询
     * @param when     发病时间
     * @param symptoms 主要症状
     * @param images   图片URL地址,多图以逗号分隔
     * @param voice    语音URL地址
     * @param doctor   咨询医生code
     * @return
     */
    @RequestMapping(value = "add")
    @ResponseBody
    @ApiOperation("三师咨询添加接口")
    @ApiOperation("咨询添加接口")
    public String add(@RequestParam(required = false) Integer type,
                      @RequestParam(required = false) String when,
                      @RequestParam String symptoms,
                      @RequestParam(required = true) String symptoms,
                      @RequestParam(required = false) String images,
                      @RequestParam(required = false) String voice,
                      @RequestParam(required = true) String doctor,
                      @RequestParam(required = false) Long guidance) {
        try {
            System.out.println("guidance1="+guidance);
            System.out.println("symptoms="+symptoms);
            if (type == null) {
                type = 1;
            }
@ -364,16 +368,16 @@ public class ConsultController extends WeixinBaseController {
            }
            // 将临时图片拷贝到正式存储路径下
            if (StringUtils.isNotEmpty(images)) {
                images = CommonUtil.copyTempImage(images);
                images = commonUtil.copyTempImage(images);
            }
            if (StringUtils.isEmpty(voice)) {
                voice = fetchWxVoices();
            }
            if (StringUtils.isNotEmpty(voice)) {
                voice = CommonUtil.copyTempVoice(voice);
                voice = commonUtil.copyTempVoice(voice);
            }
            ConsultTeam consult = new ConsultTeam();
            // 设置咨询类型:1三师咨询,2家庭医生咨询  6.名医咨询
            // 设置咨询类型:1 关注咨询
            consult.setType(type);
            // 设置发病时间
            consult.setWhen(when);
@ -388,85 +392,40 @@ public class ConsultController extends WeixinBaseController {
                consult.setGuidance(guidance);
            }
            System.out.println("guidance2="+guidance);
            // 保存到数据库
            int res = 0;
            JSONArray dts = null;
            synchronized (getRepUID().intern()){//新增同步方法。设备保存写在service层但是不生效,写在controller层才生效
                JSONObject re = consultTeamService.addTeamConsult(consult, getRepUID(),getUID());
            synchronized (getRepUID().intern()){
                JSONObject re = consultTeamService.addTeamConsult(consult, getRepUID(),getUID(),doctor);
                res = re.getInt("status");
                dts = re.has("doctor")?re.getJSONArray("doctor"):null;
            }
            if (res == -1) {
                return error(-1, "家庭签约信息不存在或已过期,无法进行家庭医生咨询!");
            } else if (res == -2) {
                return error(-1, "家庭签约信息不存在或已过期,无法进行三师医生咨询!");
            }else if (res == -3) {
                return error(-1, "还有咨询未结束,不允许再次提交咨询!");
            }
//            Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());
            //创建咨询讨论组
            // JSONObject jo= talkGroupService.createConsultTalkGroup(consult.getDoctor(), doctor.getName(), doctor.getHospital(), doctor.getHospitalName(),
            //        consult.getPatient(), consult.getName(), consult.getConsult());
            // consult.setGroupCode(jo.getString("groupCode"));
            //更新讨论组
            //consultTeamService.save(consult);
            // 添加到统计队列
            if (consult.getType() == 2) {
            if (consult.getType() == 1) {
                DoctorStatisticsTask.getInstance(doctorStatisticsService).put(consult.getDoctor(), 1, 1, 0);
            }
            // 推送消息给医生
            if(dts==null||dts.length()==0){
                if(messageService.getMessageNoticeSettingByMessageType(consult.getDoctor(),"1", MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue())){
                    pushMsgTask.put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
                    Doctor doctor = doctorDao.findByCode(consult.getDoctor());
                    if (doctor!=null && StringUtils.isNotEmpty(doctor.getOpenid())){
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("type", "4"));
                        params.add(new BasicNameValuePair("openId", doctor.getOpenid()));
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好,有患者向您发起咨询"));
                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        String sex = consult.getSex()==1? "男" : "女";
                        String keywords = consult.getName() + "," + sex;
                        params.add(new BasicNameValuePair("keywords", keywords));
                        httpClientUtil.post(url, params, "UTF-8");
                    }
                }
            }else {
                for (int i=0;i<dts.length();i++){
                    String doctorCode = dts.getString(i);
                    Boolean flag = true;
                    if(consult.getDoctor().equals(doctorCode)){
                        //健管
                        flag = messageService.getMessageNoticeSettingByMessageType(doctorCode,"1", MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue());
                    }else {
                        //全科
                        flag = !messageService.getMessageNoticeSettingByMessageType(doctorCode,"1", MessageNoticeSetting.MessageTypeEnum.familyTopicSwitch.getValue());
                    }
                    if(flag){
                        pushMsgTask.put(doctorCode, MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
                        Doctor doctor = doctorDao.findByCode(doctorCode);
                        if (doctor!=null && StringUtils.isNotEmpty(doctor.getOpenid())){
                            String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                            List<NameValuePair> params = new ArrayList<>();
                            params.add(new BasicNameValuePair("type", "4"));
                            params.add(new BasicNameValuePair("openId", doctor.getOpenid()));
                            params.add(new BasicNameValuePair("url", targetUrl));
                            params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好,有患者向您发起咨询"));
                            params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                            String sex = consult.getSex()==1? "男" : "女";
                            String keywords = consult.getName() + "," + sex;
                            params.add(new BasicNameValuePair("keywords", keywords));
                            httpClientUtil.post(url, params, "UTF-8");
                        }
                    }
                }
            if(messageService.getMessageNoticeSettingByMessageType(consult.getDoctor(),"1", MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue())){
                pushMsgTask.put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
//                医生助手代码,暂时不做
//                Doctor d = doctorDao.findByCode(consult.getDoctor());
//                if (d!=null && StringUtils.isNotEmpty(d.getOpenid())){
//                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
//                    List<NameValuePair> params = new ArrayList<>();
//                    params.add(new BasicNameValuePair("type", "4"));
//                    params.add(new BasicNameValuePair("openId", d.getOpenid()));
//                    params.add(new BasicNameValuePair("url", targetUrl));
//                    params.add(new BasicNameValuePair("first", d.getName() + "医生您好,有患者向您发起咨询"));
//                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
//                    String sex = consult.getSex()==1? "男" : "女";
//                    String keywords = consult.getName() + "," + sex;
//                    params.add(new BasicNameValuePair("keywords", keywords));
//
//                    httpClientUtil.post(url, params, "UTF-8");
//                }
            }
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
@ -532,16 +491,16 @@ public class ConsultController extends WeixinBaseController {
            }
            // 将临时图片拷贝到正式存储路径下
            if (StringUtils.isNotEmpty(images)) {
                images = CommonUtil.copyTempImage(images);
                images = commonUtil.copyTempImage(images);
            }
            if (StringUtils.isEmpty(voice)) {
                voice = fetchWxVoices();
            }
            if (StringUtils.isNotEmpty(voice)) {
                voice = CommonUtil.copyTempVoice(voice);
                voice = commonUtil.copyTempVoice(voice);
            }
            //判断是否已经存在还没有关闭的咨询
            if (consultTeamService.isExistConsult(getRepUID(), doctorCode)) {
            if (consultTeamService.isExistConsult(getRepUID(),6, doctorCode)) {
                return error(-1, "还有咨询未结束,不允许再次提交咨询!");
            }
            ConsultTeam consult = new ConsultTeam();
@ -572,6 +531,94 @@ public class ConsultController extends WeixinBaseController {
        }
    }
    /**
     * 查询某个医院存在医生科室列表
     *
     * @param hospital 医院
     * @param key      科室名字搜索
     * @param page     第几页
     * @param pagesize 页大小
     * @return
     */
    @ApiOperation("查询某个医院存在医生科室列表")
    @RequestMapping(value = "/dept_list", method = RequestMethod.GET)
    @ResponseBody
    public String deptList(@RequestParam(required = false) String hospital,
                           @RequestParam(required = false) String key,
                           @RequestParam(required = true) int page,
                           @RequestParam(required = true) int pagesize) {
        try {
            if (StringUtils.isEmpty(hospital)) {
                hospital = defaultHospital;
            }
            page = page >= 1 ? page - 1 : 0;
            List<HospitalDept> dept = deptService.getHospitalDept(hospital, key, page, pagesize);
            return write(200, "查询成功", "data", dept);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 医生列表
     *
     * @return
     */
    @RequestMapping(value = "doctorList")
    @ResponseBody
    @ApiOperation("医生列表")
    public String doctorList(
            @ApiParam(name = "hospitalCode", value = "医院code", defaultValue = "350200")
            @RequestParam(value = "hospitalCode", required = false) String hospitalCode,
            @ApiParam(name = "dept", value = "科室代码", defaultValue = "1")
            @RequestParam(value = "dept", required = false) String dept,
            @ApiParam(name = "name", value = "医生姓名或科室名称", defaultValue = "1")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "page", value = "第几页", defaultValue = "")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pagesize", value = "每页记录数", defaultValue = "")
            @RequestParam(value = "pagesize", required = false) Integer pagesize) {
        try {
            JSONArray array = new JSONArray();
            List<Doctor> list = doctorService.findDoctorLists(hospitalCode,name,dept, page, pagesize);
            if (list != null) {
                for (Doctor doctor : list) {
                    JSONObject json = new JSONObject();
                    json.put("id", doctor.getId());
                    // 医生标识
                    json.put("code", doctor.getCode());
                    // 医生性别
                    json.put("sex", doctor.getSex());
                    // 医生姓名
                    json.put("name", doctor.getName());
                    // 所在医院名称
                    json.put("hospital", doctor.getHospital());
                    // 所在医院名称
                    json.put("hospital_name", doctor.getHospitalName());
                    // 科室名称
                    json.put("dept_name", (doctor.getDeptName() == null ||
                            StringUtils.isEmpty(doctor.getDeptName().toString())) ? " " : doctor.getDeptName());
                    // 职称名称
                    json.put("job_name", (doctor.getJobName() == null ||
                            StringUtils.isEmpty(doctor.getJobName().toString())) ? " " : doctor.getJobName());
                    // 头像
                    json.put("photo", doctor.getPhoto());
                    // 简介
                    json.put("introduce", doctor.getIntroduce());
                    // 专长
                    json.put("expertise", doctor.getExpertise());
                    array.put(json);
                }
            }
            return write(200, "获取医院医生列表成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取医院医生列表失败!");
        }
    }
    /**
     * 名医列表
     *
@ -800,7 +847,7 @@ public class ConsultController extends WeixinBaseController {
                JSONObject obj = new JSONObject();
                // 将临时语音拷贝到正式存储路径下
                if (StringUtils.isNotEmpty(path)) {
                    content = CommonUtil.copyTempVoice(path);
                    content = commonUtil.copyTempVoice(path);
                    obj.put("path", content);
                    obj.put("times", times);
                    content = obj.toString();
@ -817,7 +864,7 @@ public class ConsultController extends WeixinBaseController {
                content = fetchWxImages();
                // 将临时图片拷贝到正式存储路径下
                if (StringUtils.isNotEmpty(content)) {
                    content = CommonUtil.copyTempImage(content);
                    content = commonUtil.copyTempImage(content);
                }
                if (StringUtils.isEmpty(content)) {
                    return error(-1, "图片上传失败!");
@ -843,15 +890,13 @@ public class ConsultController extends WeixinBaseController {
                arr = new String[]{content};
            }
//            Patient patient = patientDao.findByCode(getUID());
            Patient patient = patientDao.findByCode(getRepUID());
            int i = 0;
            List<String> failed = new ArrayList<>();
            String agent = getUID()==getRepUID()?null:getUID();
            for (ConsultTeamLog log : logs) {
//                String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
                String response = ImUtill.sendTopicIM(getRepUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),agent);
                String response = imUtill.sendTopicIM(getRepUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),agent);
                if (StringUtils.isNotEmpty(response)) {
                    JSONObject resObj = new JSONObject(response);
@ -859,101 +904,70 @@ public class ConsultController extends WeixinBaseController {
                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!" + resObj.getString("message"));
                    }
                    failed.add(String.valueOf(resObj.get("data")));
                    try {
                         /*if(messageService.getMessageNoticeSettingByMessageType(consultModel.getDoctor(),"1",MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue())){
                            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                            Doctor doctor = doctorDao.findByCode(consultModel.getDoctor());
                            String doctorOpenID = doctor.getOpenid();
                            if (StringUtils.isNotEmpty(doctorOpenID)) {
                                String title = "";
                                Consult consultSingle = consultDao.findByCode(log.getConsult());
                                if (consultSingle!=null){
                                    Integer singleType = consultSingle .getType();
                                    if (singleType != null && singleType ==8 ){
                                        title = consultSingle.getTitle();
                                    }else if(singleType != null && singleType !=8 ){
                                        title = consultSingle.getSymptoms();
                                    }
                                    String repContent = parseContentType(type+"",content);
                                    String first = "居民" +patient.getName()+"的健康咨询有新的回复。";
                                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                    List<NameValuePair> params = new ArrayList<>();
                                    params.add(new BasicNameValuePair("type", "8"));
                                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first",  first));
                                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                                    String keywords = title + "," + repContent +","+ doctor.getName();
                                    params.add(new BasicNameValuePair("keywords", keywords));
                                    httpClientUtil.post(url, params, "UTF-8");
                                }
                            }
                        }*/
                        String sql = "";
                        if (consultModel.getType() == 2){
                            //家庭咨询
                            sql = "SELECT t.participant_id FROM " + im +
                                    ".participants t where t.session_id = '" +
                                    patient.getCode() + "_" + consultModel.getTeam() + "_" + consultModel.getType() +
                                    "' and t.participant_role = 0";
                         }else if (consultModel.getType() == 8){
                            //续方咨询
                            sql = "SELECT t.participant_id FROM " + im +
                                    ".participants t where t.session_id = '" +
                                    patient.getCode() + "_" + consultModel.getConsult() + "_" + consultModel.getType() +
                                    "' and t.participant_role = 0";
                         }
                        List<Map<String, Object>> participants = jdbcTemplate.queryForList(sql);
                        for (Map<String, Object> participant : participants) {
//                          //有居民、健管、全科
                            String doctorCode = participant.get("participant_id").toString();
                            if (doctorCode.equals(patient.getCode())) {
                                continue;
                            }
                            //健管
                            Boolean flag = messageService.getMessageNoticeSettingByMessageType(doctorCode, "1", MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue());
                            //全科
//                            Boolean flag2 = !messageService.getMessageNoticeSettingByMessageType(doctorCode, "1", MessageNoticeSetting.MessageTypeEnum.familyTopicSwitch.getValue());
                            if (flag) {
                                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                                Doctor doctor = doctorDao.findByCode(doctorCode);
                                String doctorOpenID = doctor.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                                    String title = "";
                                    Consult consultSingle = consultDao.findByCode(log.getConsult());
                                    if (consultSingle != null) {
                                        Integer singleType = consultSingle.getType();
                                        if (singleType != null && singleType == 8) {
                                            title = consultSingle.getTitle();
                                        } else if (singleType != null && singleType != 8) {
                                            title = consultSingle.getSymptoms();
                                        }
                                        String repContent = parseContentType(type + "", content);
                                        String first = "居民" + patient.getName() + "的健康咨询有新的回复。";
                                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                        List<NameValuePair> params = new ArrayList<>();
                                        params.add(new BasicNameValuePair("type", "8"));
                                        params.add(new BasicNameValuePair("openId", doctorOpenID));
                                        params.add(new BasicNameValuePair("url", targetUrl));
                                        params.add(new BasicNameValuePair("first", first));
                                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                                        String keywords = title + "," + repContent + "," + doctor.getName();
                                        params.add(new BasicNameValuePair("keywords", keywords));
                                        httpClientUtil.post(url, params, "UTF-8");
                                        System.out.println("发送对象:"+doctorCode);
                                        System.out.println("发送对象名字:"+doctor.getName());
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
//                    try {
//                        String sql = "";
//                        if (consultModel.getType() == 2){
//                            //家庭咨询
//                            sql = "SELECT t.participant_id FROM " + im +
//                                    ".participants t where t.session_id = '" +
//                                    patient.getCode() + "_" + consultModel.getTeam() + "_" + consultModel.getType() +
//                                    "' and t.participant_role = 0";
//                         }else if (consultModel.getType() == 8){
//                            //续方咨询
//                            sql = "SELECT t.participant_id FROM " + im +
//                                    ".participants t where t.session_id = '" +
//                                    patient.getCode() + "_" + consultModel.getConsult() + "_" + consultModel.getType() +
//                                    "' and t.participant_role = 0";
//                         }
//
//                        List<Map<String, Object>> participants = jdbcTemplate.queryForList(sql);
//
//                        for (Map<String, Object> participant : participants) {
////                          //有居民、健管、全科
//                            String doctorCode = participant.get("participant_id").toString();
//                            if (doctorCode.equals(patient.getCode())) {
//                                continue;
//                            }
//                            //健管
//                            Boolean flag = messageService.getMessageNoticeSettingByMessageType(doctorCode, "1", MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue());
//                            //全科
////                            Boolean flag2 = !messageService.getMessageNoticeSettingByMessageType(doctorCode, "1", MessageNoticeSetting.MessageTypeEnum.familyTopicSwitch.getValue());
//                            if (flag) {
//                                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
//                                Doctor doctor = doctorDao.findByCode(doctorCode);
//                                String doctorOpenID = doctor.getOpenid();
//                                if (StringUtils.isNotEmpty(doctorOpenID)) {
//                                    String title = "";
//                                    Consult consultSingle = consultDao.findByCode(log.getConsult());
//                                    if (consultSingle != null) {
//                                        Integer singleType = consultSingle.getType();
//                                        if (singleType != null && singleType == 8) {
//                                            title = consultSingle.getTitle();
//                                        } else if (singleType != null && singleType != 8) {
//                                            title = consultSingle.getSymptoms();
//                                        }
//                                        String repContent = parseContentType(type + "", content);
//                                        String first = "居民" + patient.getName() + "的健康咨询有新的回复。";
//                                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
//                                        List<NameValuePair> params = new ArrayList<>();
//                                        params.add(new BasicNameValuePair("type", "8"));
//                                        params.add(new BasicNameValuePair("openId", doctorOpenID));
//                                        params.add(new BasicNameValuePair("url", targetUrl));
//                                        params.add(new BasicNameValuePair("first", first));
//                                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
//                                        String keywords = title + "," + repContent + "," + doctor.getName();
//                                        params.add(new BasicNameValuePair("keywords", keywords));
//
//                                        httpClientUtil.post(url, params, "UTF-8");
//                                        System.out.println("发送对象:"+doctorCode);
//                                        System.out.println("发送对象名字:"+doctor.getName());
//                                    }
//                                }
//                            }
//                        }
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                    }
                }
            }
@ -981,7 +995,7 @@ public class ConsultController extends WeixinBaseController {
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
            }
            JSONObject messageObj = ImUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
            JSONObject messageObj = imUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
            //过滤续签
            consultTeamService.removeRenewPerson(messageObj,getRepUID());
@ -1004,7 +1018,7 @@ public class ConsultController extends WeixinBaseController {
    @ApiOperation("网络咨询咨询日志查询")
    public String logs(@RequestParam String sessionId,@RequestParam(required = false) String startMsgId,@RequestParam(required = false) String endMsgId, @RequestParam int page, @RequestParam int pagesize) {
        try {
            JSONArray messageArray = ImUtill.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getRepUID());
            JSONArray messageArray = imUtill.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getRepUID());
            return write(200, "查询成功", "list", messageArray);
        } catch (Exception e) {
            error(e);
@ -1016,7 +1030,7 @@ public class ConsultController extends WeixinBaseController {
    @ResponseBody
    public String participants(@RequestParam String sessionId) {
        try {
            JSONArray participants = ImUtill.getSessions(sessionId);
            JSONArray participants = imUtill.getSessions(sessionId);
            //过滤续签
            consultTeamService.removeRenewPerson(participants,getRepUID());
@ -1139,7 +1153,7 @@ public class ConsultController extends WeixinBaseController {
    @ResponseBody
    public String getTopic(String consult){
        try{
            return success(ImUtill.getTopic(consult).get("data").toString());
            return success(imUtill.getTopic(consult).get("data").toString());
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());

+ 3 - 1
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -27,6 +27,8 @@ doctorAssistant:
  api: http://192.168.131.113:8080/
  target_url: home/html/unreadMessageStatistic.html
wlyy:
  hospital: 3502030400 # 默认医院code
im:
  im_list_get: http://172.19.103.88:3000/
@ -153,4 +155,4 @@ Riva:
##福州健康之路总部的接口
jkzl:
  zongbu:
    resturl: http://service.yihu.com:8085/WSGW/rest
    resturl: http://service.yihu.com:8085/WSGW/rest

+ 4 - 1
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -33,6 +33,9 @@ im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: im_new
wlyy:
  hospital: 3502030400 # 默认医院code
#物联网配置
iot:
#  url: http://192.168.131.24:8088/svr-iot/
@ -154,4 +157,4 @@ Riva:
##福州健康之路总部的接口
jkzl:
  zongbu:
    resturl: http://service.yihu.com:8085/WSGW/rest
    resturl: http://service.yihu.com:8085/WSGW/rest

+ 3 - 1
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -27,6 +27,8 @@ doctorAssistant:
  api: http://www.xmtyw.cn/assistant/
  target_url: home/html/unreadMessageStatistic.html
wlyy:
  hospital: 3502030400 # 默认医院code
im:
  im_list_get: http://27.155.101.77:3000/
@ -159,4 +161,4 @@ Riva:
##福州健康之路总部的接口
jkzl:
  zongbu:
    resturl: http://service.yihu.com:8080/WSGW/rest
    resturl: http://service.yihu.com:8080/WSGW/rest

+ 4 - 1
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -24,6 +24,9 @@ doctorAssistant:
  api: http://172.19.103.88:443/assistant/
  target_url: home/html/unreadMessageStatistic.html
wlyy:
  hospital: 3502030400 # 默认医院code
im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: im_new
@ -145,4 +148,4 @@ Riva:
##福州健康之路总部的接口
jkzl:
  zongbu:
    resturl: http://service.yihu.com:8085/WSGW/rest
    resturl: http://service.yihu.com:8085/WSGW/rest