소스 검색

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 8 년 전
부모
커밋
bca0844b8d
27개의 변경된 파일1027개의 추가작업 그리고 386개의 파일을 삭제
  1. 0 1
      patient-co-wlyy/pom.xml
  2. 6 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java
  3. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  4. 78 37
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientRecordService.java
  5. 27 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java
  6. 262 34
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  7. 5 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java
  8. 72 42
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  9. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  10. 11 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  11. 81 59
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java
  12. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/SMSService.java
  13. 6 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  14. 74 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/RemindExpensesTask.java
  15. 50 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/RemindFocusWechatTask.java
  16. 9 13
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java
  17. 171 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java
  18. 6 7
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendP2PUtil.java
  19. 27 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendPatientUtil.java
  20. 24 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java
  21. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/archives/DoctorArchivesController.java
  22. 65 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  23. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  24. 19 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java
  25. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/archives/PatientArchivesController.java
  26. 13 165
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  27. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/OpenApiSmjkController.java

+ 0 - 1
patient-co-wlyy/pom.xml

@ -197,7 +197,6 @@
            <version>${sitemesh.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>

+ 6 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java

@ -44,9 +44,9 @@ public class ConsultTeam extends IdEntity {
	private Long guidance;   //关联指导
	private String doctorName;//醫生名字
	//起始消息id
	private Integer startMsgId;
	private String startMsgId;
	//结束消息id
	private Integer endMsgId;
	private String endMsgId;
	// 结束人
	private String endOperator;
	// 结束人类型
@ -256,19 +256,19 @@ public class ConsultTeam extends IdEntity {
	}
	public Integer getStartMsgId() {
	public String getStartMsgId() {
		return startMsgId;
	}
	public void setStartMsgId(Integer startMsgId) {
	public void setStartMsgId(String startMsgId) {
		this.startMsgId = startMsgId;
	}
	public Integer getEndMsgId() {
	public String getEndMsgId() {
		return endMsgId;
	}
	public void setEndMsgId(Integer endMsgId) {
	public void setEndMsgId(String endMsgId) {
		this.endMsgId = endMsgId;
	}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -45,6 +45,9 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
    SignFamily findByDoctorPatient(String doctor, String patient);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and (a.type = 2 or a.type=1) and a.status >= 0")
    List<SignFamily> findSSandFamilyByDoctorPatient(String doctor, String patient);
    @Query("select a from SignFamily a where a.doctorHealth = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0 ")
    SignFamily findByDoctorHealthPatient(String doctor, String patient);

+ 78 - 37
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientRecordService.java

@ -206,7 +206,7 @@ public class PatientRecordService {
    /**
     * 获取检查检验列表
     */
    public List<Map<String, String>> getExamAndLabReport(String patientCode, String page, String pageSize) throws Exception {
    public List<Map<String, String>> getExamAndLabReport(String patientCode, String page, String pageSize, String lastTime) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        //获取患者
@ -223,16 +223,26 @@ public class PatientRecordService {
        String sql = "select a.*,b.img_type as catalog,GROUP_CONCAT(b.img_label) as label \n" +
                "from wlyy_patient_event a,wlyy_patient_event_img b\n" +
                "where a.patient='" + patientCode + "' and b.event_id=a.id and b.img_type in ('检查报告','检验报告')  \n" +
                "group by b.event_id,b.img_type order by a.event_date desc limit " + pageInt * pageSizeInt + "," + pageSize;
                "group by b.event_id,b.img_type order by a.event_date desc";
        List<Map<String, Object>> appList = jdbcTemplate.queryForList(sql);
        if (!StringUtils.isEmpty(response)) {
        if (!StringUtils.isEmpty(response) && !"[{}]".equals(response)) {
            JSONArray array = new JSONArray(response);
            String max = "";
            String min = "";
            for (int i = 0; i < array.length(); i++) {
                JSONObject item = array.getJSONObject(i);
                Map<String, String> map = new HashMap<>();
                if (i == 0) //最大值
                {
                    max = item.optString("END_TIME");
                } else if (i == array.length() - 1) //最小值
                {
                    min = item.optString("END_TIME");
                }
                map.put("id", item.optString("EVENT"));
                map.put("patient", patientCode);
                map.put("eventDate", item.optString("END_TIME"));
@ -257,46 +267,72 @@ public class PatientRecordService {
            //过滤
            for (Map<String, Object> item : appList) {
                Map<String, String> map = new HashMap<>();
                map.put("id", item.get("id").toString());
                map.put("patient", patientCode);
                map.put("eventDate", DateUtil.dateToStrLong((Date) item.get("event_date")));
                String type = "";
                if ("检验报告".equals(item.get("catalog"))) {
                    type = "检验";
                } else if ("检查报告".equals(item.get("catalog"))) {
                    type = "检查";
                String eventDate = DateUtil.dateToStrLong((Date) item.get("event_date"));
                int maxCompare = eventDate.compareTo(max);
                int minCompare = eventDate.compareTo(min);
                Boolean contain = false;
                if (maxCompare < 0 && minCompare >= 0)       //时间范围内
                {
                    contain = true;
                }
                //第一页特殊处理
                if ("1".equals(page) && maxCompare >= 0) {
                    contain = true;
                }
                //最后一页特殊处理
                if (!"1".equals(page) && (array.length() == 0 || "[{}]".equals(response)) && !StringUtils.isEmpty(lastTime)) {
                    int lastTimeCompare = eventDate.compareTo(lastTime);
                    if (lastTimeCompare < 0) {
                        contain = true;
                    }
                }
                if (contain) {
                    Map<String, String> map = new HashMap<>();
                    map.put("id", item.get("id").toString());
                    map.put("patient", patientCode);
                    map.put("eventDate", eventDate);
                    String type = "";
                    if ("检验报告".equals(item.get("catalog"))) {
                        type = "检验";
                    } else if ("检查报告".equals(item.get("catalog"))) {
                        type = "检查";
                    }
                    map.put("type", type);
                    map.put("catalogCode", "");
                    map.put("serial", "");
                    map.put("orgName", String.valueOf(item.get("org_name")));
                    map.put("label", String.valueOf(item.get("label"))); //检测项目
                    map.put("dataFrom", "2");//基卫数据
                    re.add(map);
                }
                map.put("type", type);
                map.put("catalogCode", "");
                map.put("serial", "");
                map.put("orgName", String.valueOf(item.get("org_name")));
                map.put("label", String.valueOf(item.get("label"))); //检测项目
                map.put("dataFrom", "2");//基卫数据
                re.add(map);
            }
            //排序
            re = sortMapList(re, "eventDate", "DESC");
        } else {
            for (Map<String, Object> item : appList) {
                Map<String, String> map = new HashMap<>();
                map.put("id", String.valueOf(item.get("id")));
                map.put("patient", patientCode);
                map.put("eventDate", DateUtil.dateToStrLong((Date) item.get("event_date")));
                String type = "";
                if ("检验报告".equals(item.get("catalog"))) {
                    type = "检验";
                } else if ("检查报告".equals(item.get("catalog"))) {
                    type = "检查";
            if ("1".equals(page)) {
                for (Map<String, Object> item : appList) {
                    Map<String, String> map = new HashMap<>();
                    map.put("id", String.valueOf(item.get("id")));
                    map.put("patient", patientCode);
                    map.put("eventDate", DateUtil.dateToStrLong((Date) item.get("event_date")));
                    String type = "";
                    if ("检验报告".equals(item.get("catalog"))) {
                        type = "检验";
                    } else if ("检查报告".equals(item.get("catalog"))) {
                        type = "检查";
                    }
                    map.put("type", type);
                    map.put("catalogCode", "");
                    map.put("serial", "");
                    map.put("orgName", String.valueOf(item.get("org_name")));
                    map.put("label", String.valueOf(item.get("label"))); //检测项目
                    map.put("dataFrom", "2");//基卫数据
                    re.add(map);
                }
                map.put("type", type);
                map.put("catalogCode", "");
                map.put("serial", "");
                map.put("orgName", String.valueOf(item.get("org_name")));
                map.put("label", String.valueOf(item.get("label"))); //检测项目
                map.put("dataFrom", "2");//基卫数据
                re.add(map);
            }
        }
@ -310,7 +346,12 @@ public class PatientRecordService {
    public String getDrugsListPage(String patientCode, String page, String pageSize) throws Exception {
        //获取患者
        Patient patient = patientDao.findByCode(patientCode);
        return jwSmjkService.getDrugsListPage(patient.getSsc(), page, pageSize);
        String response = jwSmjkService.getDrugsListPage(patient.getSsc(), page, pageSize);
        if ("[{}]".equals(response)) {
            response = "[]";
        }
        return response;
    }

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

@ -1,7 +1,11 @@
package com.yihu.wlyy.service.app.consult;
import java.util.Date;
import java.util.List;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.util.SendPatientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -46,6 +50,9 @@ public class ConsultService extends BaseService {
	@Autowired
	public ConsultCommunicationReplyDao consultCommunicationReplyDao;
	@Autowired
	private SignFamilyDao signFamilyDao;
	/**
	 * 添加一条咨询记录
	 * @param patient 患者信息
@ -103,4 +110,24 @@ public class ConsultService extends BaseService {
	public Consult findOneConsult(String consult) {
		return consultDao.findByCode(consult);
	}
	public void sendMucMessageBySingnType(String doctor,String doctorName,String patient,String  content,String contentType,String title){
		//add by linz 增加签约关系查询,
		List<SignFamily> sfList = signFamilyDao.findSSandFamilyByDoctorPatient(doctor, doctorName);
		int type = 2;
		if(sfList!=null&&sfList.size()==1){
			//只存在一种签约关系
			type = sfList.get(0).getType();
		}else if(sfList!=null&&sfList.size()==2){
			//两种签约关系直接取家庭签约
			type = 2;
		}else{
			//没找到签约关系
			type=0;
		}
		if(type!=0){
			SendPatientUtil.sendToPatient(doctor,doctorName,patient, contentType, content,title,type+"");
		}
	}
}

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

@ -28,9 +28,7 @@ import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -53,7 +51,8 @@ import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.utils.Clock;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.MessageType;
import javax.print.Doc;
/**
 * 網絡諮詢类.
@ -88,6 +87,8 @@ public class ConsultTeamService extends ConsultService {
    private PatientHealthGuidanceService guidanceService;
    @Autowired
    private TalkGroupService talkGroupService;
    @Autowired
    private com.yihu.wlyy.service.common.account.DoctorService doctorService;
    /**
     * 查询患者是否还有未结束的三师咨询
@ -658,6 +659,7 @@ public class ConsultTeamService extends ConsultService {
     * @throws Exception
     */
    public int addTeamConsult(ConsultTeam ct, String patient) throws Exception {
        JSONObject users = new JSONObject();
        // 咨询三师
        if (ct.getType() == 1) {
            // 查询三师签约信息
@ -671,13 +673,20 @@ public class ConsultTeamService extends ConsultService {
            //查找病人所在的团队
            DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
            //得到团队的健康管理师
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
            if (doctorTeamMember == null) {
                doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
            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){
                    users.put(doctorTeamMember.getMemberCode(),1);
                }
                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
            }
            // 设置家庭医生
            ct.setDoctor(doctorTeamMember.getMemberCode());
            ct.setAdminTeamId(sc.getAdminTeamId());
        } else if (ct.getType() == 2) {
            // 咨询家庭医生
@ -690,14 +699,19 @@ public class ConsultTeamService extends ConsultService {
            //查找病人所在的团队
            DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
            //得到团队的健康管理师
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
            if (doctorTeamMember == null) {
                doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            if (doctorTeamMemberHealthy == null) {
                ct.setDoctor(doctorTeamMember.getMemberCode());
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
            }else{
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
                if(doctorTeamMember!=null){
                    users.put(doctorTeamMember.getMemberCode(),1);
                }
                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
            }
            ct.setTeam(sf.getTeamCode());
            // 设置家庭医生
            ct.setDoctor(doctorTeamMember.getMemberCode());
            ct.setAdminTeamId(sf.getAdminTeamId());
        }
        // 设置患者信息
@ -733,23 +747,14 @@ public class ConsultTeamService extends ConsultService {
        cd.setTo(ct.getDoctor());
        // 添加医生咨询日志
        String content = addLogs(ct);
        //推送给IM文字消息
        String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        JSONObject jo = new JSONObject(returnJson);
        if (jo.has("startId")) {
            //设置消息ID
            ct.setStartMsgId(jo.getInt("startId"));
            //推送给IM图片
            if (StringUtils.isNotEmpty(ct.getImages())) {
                String[] images = ct.getImages().split(",");
                for (String image : images) {
                    if (StringUtils.isNoneEmpty(image)) {
                        sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                    }
                }
            }
        //推送给IM去创建议题,取得成员消息
        JSONObject messages  = ImUtill.getCreateTopicMessage(patient,tempPatient.getName(),consult.getTitle(),consult.getSymptoms(),consult.getImages());
        users.put(patient,0);
        JSONObject obj  = ImUtill.createTopics(patient+"_consult_"+ct.getType(),consult.getCode(),"咨询问题:"+consult.getSymptoms(),users,messages,"1");
        if(obj==null){
            throw new RuntimeException("IM消息结束异常!");
        }
        ct.setStartMsgId(obj.get("start_msg_id").toString());
        consultTeamDao.save(ct);
        consultDao.save(consult);
        consultTeamDoctorDao.save(cd);
@ -949,7 +954,7 @@ public class ConsultTeamService extends ConsultService {
            throw new Exception("send consult finished IM message failed");
        } else {
            JSONObject jo = new JSONObject(returnJson);            //设置消息ID
            consultTeam.setEndMsgId(jo.getInt("startId"));
            consultTeam.setEndMsgId(jo.getInt("startId")+"");
            consultTeam.setEndOperator(endOperator);
            consultTeam.setEndType(endType);
        }
@ -1212,7 +1217,7 @@ public class ConsultTeamService extends ConsultService {
        ;
        JSONObject jo = new JSONObject(returnJson);
        //设置消息ID
        ct.setStartMsgId(jo.getInt("startId"));
        ct.setStartMsgId(jo.getInt("startId")+"");
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
@ -1345,7 +1350,7 @@ public class ConsultTeamService extends ConsultService {
            sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        jo = new JSONObject(returnJson);
        //设置消息ID
        ct.setStartMsgId(jo.getInt("startId"));
        ct.setStartMsgId(jo.getInt("startId")+"");
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
@ -1429,4 +1434,227 @@ public class ConsultTeamService extends ConsultService {
    public List findByTeam(String consult){
        return consultTeamDao.findByTeamAndType(consult, 10);
    }
    /**
     * 全科医生求助专科医生(同团队)
     * @param ct
     * @param uid
     * @param oldConsultCode
     */
    public void addSeekHelpTeam(ConsultTeam ct, String uid,String oldConsultCode){
        ct.setPatient(uid);
        //推送给IM文字消息
        JSONObject participants = new JSONObject();
        participants.put(ct.getPatient(),0);
        participants.put(ct.getDoctor(),0);
        Doctor doctor = doctorService.findDoctorByCode(uid);
        JSONObject sessionJson =  ImUtill.createSession(participants,"2",doctor.getName()+"发起求助!","");
        if(sessionJson.getInt("status")==-1){
            throw  new RuntimeException(sessionJson.getString("message"));
        }
        JSONObject session = sessionJson.getJSONObject("data");
        if(StringUtils.isNotEmpty(oldConsultCode)){
            ConsultTeam oldConsult =  consultTeamDao.findByConsult(oldConsultCode);
            if(oldConsult!=null){
                ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"),"1","居民问题:" +oldConsult.getSymptoms());
                //推送给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);
                        }
                    }
                }
            }
        }
        ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"),"1","咨询问题:"+ ct.getSymptoms());
        //推送给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);
                }
            }
        }
    }
    /**
     * 全科医生求助专科医生(不同团队)
     * @param ct
     * @param uid
     * @param oldConsultCode
     */
    public void addSeekHelpOtherTeam(ConsultTeam ct, String uid,String oldConsultCode) throws Exception{
        // 设置患者信息
        ct.setPatient(uid);
        Doctor doctorTemp = doctorDao.findByCode(uid);
        // 设置医生姓名
        ct.setName(doctorTemp.getName());
        // 设置医生生日
        ct.setBirthday(doctorTemp.getBirthday());
        //新增性别
        ct.setSex(doctorTemp.getSex());
        // 设置医生头像
        ct.setPhoto(doctorTemp.getPhoto());
        // 设置操作日期
        ct.setCzrq(new Date());
        ct.setDel("1");
        ct.setStatus(0);
        // 医生未读数量为1
        ct.setDoctorRead(1);
        // 患者未读数量为0
        ct.setPatientRead(0);
        // 添加咨询记录
        Consult consult = addConsult(ct.getPatient(), null, ct.getSymptoms(), ct.getImages(), ct.getType());
        // 设置咨询标识
        ct.setConsult(consult.getCode());
        // 添加咨询转发记录
        ConsultTeamDoctor cd = new ConsultTeamDoctor();
        cd.setConsult(consult.getCode());
        cd.setDel("1");
        cd.setCzrq(new Date());
        cd.setTo(ct.getDoctor());
        // 添加医生咨询日志
        String content = addLogs(ct);
        JSONObject messages  = ImUtill.getCreateTopicMessage(doctorTemp.getCode(),doctorTemp.getName(),consult.getTitle(),content,consult.getImages());
        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,"2");
        if(obj==null||obj.getInt("status")==-1){
            throw new RuntimeException("im消息创建异常!"+obj==null?"":obj.getString("message"));
        }
        ct.setStartMsgId(obj.get("start_msg_id").toString());
        //转发咨询问题
        if(StringUtils.isNotBlank(oldConsultCode)){
            Consult oldConsult = consultDao.findByCode(oldConsultCode);
            if(oldConsult!=null){
                ImUtill.sendImMsg(doctorTemp.getCode(),doctorTemp.getName(),String.valueOf(jsonObject.hashCode()),"6",content);
                if(StringUtils.isNotBlank(oldConsult.getImages())){
                    String imgs[] = oldConsult.getImages().split(",");
                    for(String url :imgs)
                        ImUtill.sendImMsg(doctorTemp.getCode(),doctorTemp.getName(),String.valueOf(jsonObject.hashCode()),"2",url);
                }
            }
        }
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
        consultDao.save(consult);
    }
    public int finishConsult(String consult, String endOperator, int endType){
        ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
        String endName = "";
        String endId = "";
        //推送给IM文字消息
        if (endType == 1) {
            Patient p = patientDao.findByCode(endOperator);
            endName = p.getName();
            endId = p.getCode();
        } else {
            Doctor d = doctorDao.findByCode(endOperator);
            endId = d.getCode();
            endName = d.getName();
        }
        JSONObject obj = ImUtill.endTopics(consultTeam.getPatient(),endId,endName,consultTeam.getConsult());
        if(obj==null){
            throw new RuntimeException("IM消息结束异常!");
        }
        if(obj.getInt("status")==-1){
            throw new RuntimeException(obj.getString("message"));
        }
        consultTeam.setType(endType);
        consultTeam.setEndMsgId(obj.getString("id"));
        return consultTeamDao.updateStatusByConsult(consult);
    }
    /**
     * 新增名医咨询
     * @param ct
     * @param uid
     * @param type 1患者 2医生
     * @throws Exception
     */
    public void famousConsult(ConsultTeam ct, String uid, String type) throws Exception {
        // 设置患者信息
        ct.setPatient(uid);
        String senderId="";
        String senderName="";
        if ("1".equals(type)) {
            // 查询患者信息
            Patient tempPatient = patientDao.findByCode(uid);
            // 设置患者姓名
            ct.setName(tempPatient.getName());
            // 设置患者生日
            ct.setBirthday(tempPatient.getBirthday());
            //新增性别
            ct.setSex(tempPatient.getSex());
            // 设置患者头像
            ct.setPhoto(tempPatient.getPhoto());
            senderId = tempPatient.getCode();
            senderName = tempPatient.getName();
        } else if ("2".equals(type)) {
            Doctor doctorTemp = doctorDao.findByCode(uid);
            // 设置医生姓名
            ct.setName(doctorTemp.getName());
            // 设置医生生日
            ct.setBirthday(doctorTemp.getBirthday());
            //新增性别
            ct.setSex(doctorTemp.getSex());
            // 设置医生头像
            ct.setPhoto(doctorTemp.getPhoto());
            senderId = doctorTemp.getCode();
            senderName = doctorTemp.getName();
        }
        // 设置操作日期
        ct.setCzrq(new Date());
        ct.setDel("1");
        ct.setStatus(0);
        // 医生未读数量为1
        ct.setDoctorRead(1);
        // 患者未读数量为0
        ct.setPatientRead(0);
        // 添加咨询记录
        Consult consult = addConsult(ct.getPatient(), null, ct.getSymptoms(), ct.getImages(), ct.getType());
        // 设置咨询标识
        ct.setConsult(consult.getCode());
        // 添加咨询转发记录
        ConsultTeamDoctor cd = new ConsultTeamDoctor();
        cd.setConsult(consult.getCode());
        cd.setDel("1");
        cd.setCzrq(new Date());
        cd.setTo(ct.getDoctor());
        // 添加医生咨询日志
        String content = addLogs(ct);
        //推送给IM文字消息
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(ct.getPatient(),0);
        jsonObject.put(ct.getDoctor(),0);
        JSONObject messages = ImUtill.getCreateTopicMessage(senderId,senderName,senderName+"发起咨询",content,ct.getImages());
        JSONObject obj = ImUtill.createTopics(null,consult.getCode(),consult.getSymptoms(),jsonObject,messages,"2");
        if(obj==null){
            throw new RuntimeException("im消息创建异常!");
        }
        if(obj.getInt("status")==-1){
            throw new RuntimeException(obj.getString("message"));
        }
        //设置消息ID
        ct.setStartMsgId(obj.getString("start_msg_id"));
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
        consultDao.save(consult);
    }
}

+ 5 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java

@ -16,9 +16,9 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientInvitationLogDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import org.json.JSONArray;
@ -55,6 +55,9 @@ public class FamilyService {
    private DoctorDao doctorDao;
    @Autowired
    private WeiXinTempMsgSendUtils weiXinTempMsgSendUtils;
    @Autowired
    private ConsultService consultService;
    @Value("#{sys.doctor_invitel_template}")
    private String templateId;
@ -335,7 +338,7 @@ public class FamilyService {
        }else{
            content = currentPatient.getName()+"先生,再次感谢您对我的信任。同时,我也衷心的希望能够拥有为您整个家庭提供问下服务的荣幸。在此诚意地邀请您为"+patient.getName()+"进行签约。";
        }
        SendP2PUtil.sendP2Pmsg(doctorCode,currentPatientCode,"1",content);
        consultService.sendMucMessageBySingnType(doctorCode,doctor.getName(),currentPatient.getCode(),content,"1","医生:"+doctor.getName()+"给患者:"+currentPatient.getName()+"发送了签约邀请!");
        return "1";
    }

+ 72 - 42
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -1571,26 +1571,41 @@ public class SignPatientLabelInfoService extends BaseService {
        Matcher matcher = pattern1.matcher(filter);
        if (matcher.matches()) {
//            身份证校验通过
            String sql = "select" +
                    " p. CODE," +
                    " p. NAME ," +
                    " p.idcard," +
                    " p.sex," +
                    " f.id," +
                    " f.type," +
                    " f.doctor," +
                    " f.status," +
                    " f.doctor_health," +
                    " f.admin_team_code," +
                    " t.id teamCode," +
                    " t.`name` teamName" +
                    " from" +
                    " wlyy_patient p" +
                    " LEFT JOIN wlyy_sign_family f ON p.CODE = f.patient" +
                    " LEFT JOIN wlyy_admin_team t ON f.admin_team_code = t.id" +
                    " where" +
                    " p. idcard = ? AND (f.id IS NULL || f.status > 0)";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, filter);
            String sql = "SELECT" +
                    "   p. CODE," +
                    "   p. NAME," +
                    "   p.idcard," +
                    "   p.sex," +
                    "   f.id," +
                    "   f.type," +
                    "   f.doctor," +
                    "   f.doctor_health," +
                    "   f.admin_team_code," +
                    "   f. STATUS," +
                    "   t.id teamCode," +
                    "   t.name teamName"+
                    "  FROM" +
                    "   wlyy_patient p" +
                    "  LEFT JOIN (" +
                    "   SELECT" +
                    "    id,type,patient,doctor,doctor_health,admin_team_code,status" +
                    "  FROM" +
                    "   wlyy_sign_family" +
                    "  WHERE" +
                    "   STATUS > 0" +
                    "  AND patient IN (" +
                    "  SELECT" +
                    "   CODE" +
                    "  FROM" +
                    "   wlyy_patient" +
                    "  WHERE" +
                    "   idcard = ?" +
                    ")" +
                    ") f ON p. CODE = f.patient" +
                    "  LEFT JOIN wlyy_admin_team t ON t.id = f.admin_team_code" +
                    "  WHERE" +
                    "   p. idcard = ?";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, filter,filter);
            for (Map<String, Object> p : list) {
                JSONObject pJson = new JSONObject();
@ -1602,7 +1617,7 @@ public class SignPatientLabelInfoService extends BaseService {
                pJson.put("photo", p.get("photo") != null ? p.get("photo") : "");
                pJson.put("id", p.get("id") != null ? p.get("id") : "");
                pJson.put("doctor", p.get("doctor") != null ? p.get("doctor") : "");
                pJson.put("isSign",p.get("status")!=null?(Integer.parseInt(p.get("status").toString())>=1?p.get("1"):"0"):"0");
                pJson.put("isSign",p.get("status")!=null?(Integer.parseInt(p.get("status").toString())>=1?"1":"0"):"0");
                pJson.put("doctorHealth", p.get("doctor_health") != null ? p.get("doctor_health") : "");
                if (p.get("id") != null && (doctorCode.equals(pJson.get("doctor")) || doctorCode.equals(pJson.get("doctorHealth")))) {
                    if (p.get("teamCode") != null && StringUtils.isNotEmpty(p.get("teamCode").toString())) {
@ -1625,26 +1640,41 @@ public class SignPatientLabelInfoService extends BaseService {
                }
            }
        } else {
            String sql = "select" +
                    " p. CODE," +
                    " p. NAME," +
                    " p.idcard," +
                    " p.sex," +
                    " f.id," +
                    " f.type," +
                    " f.doctor," +
                    " f.status," +
                    " f.doctor_health," +
                    " f.admin_team_code," +
                    " t.id teamCode," +
                    " t.`name` teamName" +
                    " from" +
                    " wlyy_patient p" +
                    " LEFT JOIN wlyy_sign_family f ON p.CODE = f.patient" +
                    " LEFT JOIN wlyy_admin_team t ON f.admin_team_code = t.id" +
                    " where" +
                    " p. name = ? AND (f.id IS NULL || f.status > 0)";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, filter);
            String sql = "SELECT" +
                    "   p. CODE," +
                    "   p. NAME," +
                    "   p.idcard," +
                    "   p.sex," +
                    "   f.id," +
                    "   f.type," +
                    "   f.doctor," +
                    "   f.doctor_health," +
                    "   f.admin_team_code," +
                    "   f. STATUS," +
                    "   t.id teamCode," +
                    "   t.name teamName"+
                    "  FROM" +
                    "   wlyy_patient p" +
                    "  LEFT JOIN (" +
                    "   SELECT" +
                    "    id,patient,type,doctor,doctor_health,admin_team_code,status" +
                    "  FROM" +
                    "   wlyy_sign_family" +
                    "  WHERE" +
                    "   STATUS > 0" +
                    "  AND patient IN (" +
                    "  SELECT" +
                    "   CODE" +
                    "  FROM" +
                    "   wlyy_patient" +
                    "  WHERE" +
                    "   name = ?" +
                    ")" +
                    ") f ON p. CODE = f.patient" +
                    "  LEFT JOIN wlyy_admin_team t ON t.id = f.admin_team_code" +
                    "  WHERE" +
                    "   p. name  = ?";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, filter,filter);
            for (Map<String, Object> p : list) {
                JSONObject pJson = new JSONObject();
@ -1656,7 +1686,7 @@ public class SignPatientLabelInfoService extends BaseService {
                pJson.put("photo", p.get("photo") != null ? p.get("photo") : "");
                pJson.put("id", p.get("id") != null ? p.get("id") : "");
                pJson.put("doctor", p.get("doctor") != null ? p.get("doctor") : "");
                pJson.put("isSign",p.get("status")!=null?(Integer.parseInt(p.get("status").toString())>=1?p.get("1"):"0"):"0");
                pJson.put("isSign",p.get("status")!=null?(Integer.parseInt(p.get("status").toString())>=1?"1":"0"):"0");
                pJson.put("doctorHealth", p.get("doctor_health") != null ? p.get("doctor_health") : "");
                if (p.get("id") != null && (doctorCode.equals(pJson.get("doctor")) || doctorCode.equals(pJson.get("doctorHealth")))) {
                    if (p.get("teamCode") != null && StringUtils.isNotEmpty(p.get("teamCode").toString())) {

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -63,7 +63,7 @@ public class MessageService extends BaseService {
     */
    private String getImMsgAmount(String doctor) {
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "/api/v1/chats/msg/amount?user_id=" + doctor;
                + "/api/v2/sessions/unread_message_count?user_id=" + doctor;
        return HttpClientUtil.get(url, "UTF-8");
    }

+ 11 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -234,6 +234,17 @@ public class FamilyContractService extends BaseService {
        return doctorDao.findAll(spec, pageRequest);
    }
    /**
     * 根据医生和患者获取患者的签约状态
     * @param patient
     * @param doctor
     * @return
     */
    public List<SignFamily> getSign(String patient,String doctor){
        List<SignFamily> sfList = signFamilyDao.findSSandFamilyByDoctorPatient(patient, doctor);
        return sfList;
    }
    /**
     * 查询医生主页信息
     *

+ 81 - 59
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java

@ -3,18 +3,19 @@ package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.task.RemindExpensesTask;
import com.yihu.wlyy.task.RemindFocusWechatTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.collections.FastHashMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -52,6 +53,8 @@ public class PatientRemindService extends BaseService {
    WeiXinAccessTokenUtils tokenUtils;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    ConsultService consultService;
    /**
     * 缴费提醒
@ -59,7 +62,6 @@ public class PatientRemindService extends BaseService {
     * @param doctor 医生
     * @throws Exception
     */
    @Async
    public void remindPatientExpensesAll(String doctor) throws Exception {
        try {
            Doctor doc = doctorDao.findByCode(doctor);
@ -89,38 +91,53 @@ public class PatientRemindService extends BaseService {
     * @param hos
     */
    public void RemindAll(Doctor doc, Hospital hos) throws Exception {
            boolean flag = true;
            int page = 0;
            int start = 0;
            String sql = "select p.* " +
                    "     from " +
                    "        wlyy_sign_family f join wlyy_patient p on f.patient = p.code " +
                    "     where " +
                    "        (f.doctor = ? or f.doctor_health = ?) " +
                    "        and f.status > 0 " +
                    "        and f.type = 2 " +
                    "        and (f.expenses_status = '0' or LENGTH(trim(ifnull(f.expenses_status,''))) < 1) " +
                    "     limit ?,3000";
            while (flag) {
                List<Patient> result = jdbcTemplate.query(sql, new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper(Patient.class));
                if (result != null && result.size() > 0) {
                    for (Patient p : result) {
                        if (p != null) {
                            Boolean epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            if (epTime) {
                                continue;
                            }
                            remindPatientExpenses(p, doc, hos, true);
        Calendar today = Calendar.getInstance();
        today.set(Calendar.HOUR, 23);
        today.set(Calendar.MINUTE, 59);
        today.set(Calendar.SECOND, 59);
        today.set(Calendar.MILLISECOND, 59);
        boolean flag = true;
        int page = 0;
        int start = 0;
        String sql = "select p.* " +
                "     from " +
                "        wlyy_sign_family f join wlyy_patient p on f.patient = p.code " +
                "     where " +
                "        (f.doctor = ? or f.doctor_health = ?) " +
                "        and f.status > 0 " +
                "        and f.type = 2 " +
                "        and (f.expenses_status = '0' or LENGTH(trim(ifnull(f.expenses_status,''))) < 1) " +
                "     limit ?,3000";
        List<Patient> patients = new ArrayList<>();
        List<String> redisPatients = new ArrayList<>();
        Set<String> exists = redisTemplate.opsForSet().members("expenses:remind:set");
        while (flag) {
            List<Patient> result = jdbcTemplate.query(sql, new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper(Patient.class));
            if (result != null && result.size() > 0) {
                patients.addAll(result);
                for (Patient p : result) {
                    if (p != null) {
                        if (exists != null && exists.contains(p.getCode())) {
                            continue;
                        }
                        redisPatients.add(p.getCode());
                    }
                    page = page + 1;
                    start = page * 3000;
                } else {
                    flag = false;
                }
                page = page + 1;
                start = page * 3000;
            } else {
                flag = false;
            }
        }
        if (patients.size() > 0) {
            RemindExpensesTask task = new RemindExpensesTask(patients, doc, hos);
            new Thread(task).run();
            redisTemplate.opsForSet().add("expenses:remind:set", redisPatients.toArray(new String[]{}));
            redisTemplate.expireAt("expenses:remind:set", today.getTime());
        }
    }
    /**
@ -148,7 +165,7 @@ public class PatientRemindService extends BaseService {
                throw new Exception("patient info can not find");
            }
            return remindPatientExpenses(p, doc, hos, false);
            return remindPatientExpenses(p, doc, hos);
        } catch (Exception e) {
            e.printStackTrace();
            JSONObject reObj = new JSONObject();
@ -166,14 +183,13 @@ public class PatientRemindService extends BaseService {
     * @param hos 医院
     * @return
     */
    public JSONObject remindPatientExpenses(Patient p, Doctor doc, Hospital hos, boolean ignore) throws Exception {
    public JSONObject remindPatientExpenses(Patient p, Doctor doc, Hospital hos) throws Exception {
        try {
            Calendar today = Calendar.getInstance();
            today.set(Calendar.HOUR,23);
            today.set(Calendar.MINUTE,59);
            today.set(Calendar.SECOND,59);
            today.set(Calendar.MILLISECOND,59);
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            today.set(Calendar.HOUR, 23);
            today.set(Calendar.MINUTE, 59);
            today.set(Calendar.SECOND, 59);
            today.set(Calendar.MILLISECOND, 59);
            JSONObject reObj = new JSONObject();
            String mDesc = "";
            boolean mFlag = false;
@ -209,16 +225,12 @@ public class PatientRemindService extends BaseService {
                wFlag = true;
            }
            //发送IM
            SendP2PUtil.sendP2Pmsg(doc.getCode(), p.getCode(), "1", doc.getName() + "医生提醒您:为完成家庭医生签约," +
                    "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
            if (ignore) {
                redisTemplate.opsForSet().add("expenses:remind:set",p.getCode());
                redisTemplate.expireAt("expenses:remind:set", today.getTime());
            }
            consultService.sendMucMessageBySingnType(doc.getCode(), doc.getName(), p.getCode(), doc.getName() + "医生提醒您:为完成家庭医生签约," +
                    "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费", "1", "医生:" + doc.getName() + "给患者:" + p.getName() + "发送了缴费提醒!");
            if (wFlag || mFlag) {
                reObj.put("status", 200);
                redisTemplate.opsForSet().add("expenses:remind:set",p.getCode());
                redisTemplate.opsForSet().add("expenses:remind:set", p.getCode());
                redisTemplate.expireAt("expenses:remind:set", today.getTime());
                if (wFlag && mFlag) {
                    reObj.put("msg", "提醒成功");
@ -253,7 +265,6 @@ public class PatientRemindService extends BaseService {
        }
    }
    /**
     * 提醒患者关注微信
     *
@ -293,9 +304,13 @@ public class PatientRemindService extends BaseService {
     *
     * @param doctor
     */
    @Async
    public void remindPatientWechatFocusAll(String doctor) throws Exception {
        try {
            Calendar today = Calendar.getInstance();
            today.set(Calendar.HOUR, 23);
            today.set(Calendar.MINUTE, 59);
            today.set(Calendar.SECOND, 59);
            today.set(Calendar.MILLISECOND, 59);
            int page = 0;
            int start = 0;
            boolean flag = true;
@ -311,17 +326,19 @@ public class PatientRemindService extends BaseService {
                    "        and f.status > 0 " +
                    "        and f.expenses_status = '1' " +
                    "        and LENGTH(trim(ifnull(p.openid,''))) < 1 limit ?,3000";
            List<Map<String, Object>> patients = new ArrayList<>();
            List<String> redisPatients = new ArrayList<>();
            Set<String> exist = redisTemplate.opsForSet().members("wechat:focus:remind:set");
            while (flag) {
                List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, start});
                if (result != null && result.size() > 0) {
                    patients.addAll(result);
                    for (Map<String, Object> map : result) {
                        boolean epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", map.get("code").toString());
                        if (epTime) {
                        if (exist != null && exist.contains(map.get("code").toString())) {
                            continue;
                        }
                        remindWechatFocus(map, doc);
                        redisPatients.add(map.get("code").toString());
                    }
                    page = page + 1;
                    start = page * 3000;
@ -330,6 +347,13 @@ public class PatientRemindService extends BaseService {
                }
            }
            if (patients.size() > 0) {
                RemindFocusWechatTask task = new RemindFocusWechatTask(patients, doc);
                new Thread(task).run();
                redisTemplate.opsForSet().add("wechat:focus:remind:set", redisPatients.toArray(new String[]{}));
                redisTemplate.expireAt("wechat:focus:remind:set", today.getTime());
            }
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + doctor, "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
        } catch (Exception e) {
@ -339,7 +363,6 @@ public class PatientRemindService extends BaseService {
        }
    }
    /**
     * 微信关注提醒
     *
@ -349,13 +372,12 @@ public class PatientRemindService extends BaseService {
     */
    public JSONObject remindWechatFocus(Map<String, Object> p, Doctor doctor) {
        Calendar today = Calendar.getInstance();
        today.set(Calendar.HOUR,23);
        today.set(Calendar.MINUTE,59);
        today.set(Calendar.SECOND,59);
        today.set(Calendar.MILLISECOND,59);
        today.set(Calendar.HOUR, 23);
        today.set(Calendar.MINUTE, 59);
        today.set(Calendar.SECOND, 59);
        today.set(Calendar.MILLISECOND, 59);
        JSONObject result = new JSONObject();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        redisTemplate.opsForSet().add("wechat:focus:remind:set",p.get("code").toString());
        redisTemplate.opsForSet().add("wechat:focus:remind:set", p.get("code").toString());
        redisTemplate.expireAt("wechat:focus:remind:set", today.getTime());
        if (p.get("mobile") == null || StringUtils.isEmpty(p.get("mobile").toString())) {

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/SMSService.java

@ -139,7 +139,7 @@ public class SMSService extends BaseService {
     * @param content
     * @return
     */
    public JSONObject sendMsg(String mobile, String content) {
    public static JSONObject sendMsg(String mobile, String content) {
        // 调用总部发送信息的接口
        String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(content, mobile), "GBK");
        JSONObject json = toJson(result);

+ 6 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -7,11 +7,11 @@ import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SOAPUtil;
import com.yihu.wlyy.util.SendP2PUtil;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
@ -54,6 +54,9 @@ public class GuahaoXMService implements IGuahaoService {
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    private ConsultService consultService;
    private ObjectMapper objectMapper = new ObjectMapper();
    /**
@ -109,7 +112,8 @@ public class GuahaoXMService implements IGuahaoService {
        }
        if (StringUtils.isNotBlank(dcode)) {
            reservation.setDoctor(dcode);//代理签约维护待签约人编码
            SendP2PUtil.sendP2Pmsg(dcode, patient, "1", "我已成功为您预约:" + startTime + "," + hospitalName + hosDeptName + doctorName + "医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='" + code + "'>点击查看详情</a>");
            Patient p = patientService.findByCode(patient);
            consultService.sendMucMessageBySingnType(dcode,dname,patient,"我已成功为您预约:" + startTime + "," + hospitalName + hosDeptName + doctorName + "医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='" + code + "'>点击查看详情</a>","1","医生:"+doctor.getName()+"给患者:"+p.getName()+"代理预约!");
        }
        // 保存预约记录
        patientReservationDao.save(reservation);

+ 74 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/RemindExpensesTask.java

@ -0,0 +1,74 @@
package com.yihu.wlyy.task;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import javax.print.Doc;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
 * 缴费提醒任务
 * <p>
 * Created by lyr-pc on 2017/1/16.
 */
public class RemindExpensesTask implements Runnable {
    List<Patient> patients;
    Doctor doctor;
    Hospital hospital;
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
    @Autowired
    ConsultService consultService;
    public RemindExpensesTask(List<Patient> patients, Doctor doctor, Hospital hospital) {
        this.patients = patients;
        this.doctor = doctor;
        this.hospital = hospital;
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
    }
    @Override
    public void run() {
        for (Patient p : patients) {
            try {
                if (StringUtils.isNotEmpty(p.getMobile())) {
                    JSONObject result = SMSService.sendMsg(p.getMobile(), doctor.getName() + "医生提醒您:为完成家庭医生签约," +
                            "尽早为您提供家庭医生服务,请尽快到" + hospital.getName() + "(地址:" + hospital.getAddress() + ")缴费");
                }
                if (StringUtils.isNotEmpty(p.getOpenid())) {
                    // 微信提醒
                    JSONObject json = new JSONObject();
                    json.put("first", "缴费提醒");
                    json.put("toUser", p.getCode());
                    json.put("name", p.getName());
                    json.put("doctor", doctor.getCode());
                    json.put("doctorName", doctor.getName());
                    json.put("date", DateUtil.dateToStrShort(new Date()));
                    json.put("content", p.getName() + ",您好!为完成家庭医生签约,尽早为您提供家庭医生服务,请尽快到" + hospital.getName() + "(地址:" + hospital.getAddress() + ")缴费");
                    json.put("remark", "");
                    // 添加到发送队列
                    PushMsgTask.getInstance().putWxMsg(tokenUtils.getAccessToken(), 8, p.getOpenid(), p.getName(), json);
                }
                //发送IM
                consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p.getCode(), doctor.getName() + "医生提醒您:为完成家庭医生签约," +
                        "尽早为您提供家庭医生服务,请尽快到" + doctor.getName() + "(地址:" + hospital.getAddress() + ")缴费", "1", "医生:" + hospital.getName() + "给患者:" + p.getName() + "发送了缴费提醒!");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

+ 50 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/RemindFocusWechatTask.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.task;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.service.common.SMSService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
/**
 * 居民微信关注提醒
 * <p>
 * Created by lyr-pc on 2017/1/16.
 */
public class RemindFocusWechatTask implements Runnable {
    List<Map<String, Object>> patients;
    Doctor doctor;
    /**
     * 构造函数
     *
     * @param patients 居民列表
     */
    public RemindFocusWechatTask(List<Map<String, Object>> patients, Doctor doctor) {
        this.patients = patients;
        this.doctor = doctor;
    }
    @Override
    public void run() {
        for (Map<String, Object> p : patients) {
            try {
                if (p.get("mobile") == null || StringUtils.isEmpty(p.get("mobile").toString())) {
                    continue;
                }
                String msg = "尊敬的" + p.get("name").toString() + "," + doctor.getName() + "医生提醒您:" +
                        "为更好地为您提供健康服务,请您关注并登录\"厦门i健康\"微信公众号,与医生进行互动。";
                JSONObject smsResult = SMSService.sendMsg(p.get("mobile").toString(), msg);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

+ 9 - 13
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -132,20 +132,16 @@ public class HttpUtil {
	 * @param data 消息数据
	 */
	public static boolean pushMessage(String receiver, String msgType, String title, String msg, String data) {
//		JSONObject param = new JSONObject();
//		param.put("to_uid", receiver);
//		param.put("content", msg);
//		param.put("type", msgType);
//		param.put("title", title);
//		param.put("data", data);
		try{
			List<NameValuePair> params = new ArrayList<>();
			params.add(new BasicNameValuePair("to", receiver));
			params.add(new BasicNameValuePair("content", msg));
			params.add(new BasicNameValuePair("contentType", msgType));
			params.add(new BasicNameValuePair("title", title));
			params.add(new BasicNameValuePair("summary", data));
			String response = HttpClientUtil.post(SystemConf.getInstance().getMsgPushServer(), params, "UTF-8");
			JSONObject participants = new JSONObject();
			participants.put("system",0);
			participants.put(receiver,0);
			JSONObject sessionObj  = ImUtill.createSession(participants,"2","系统消息","");
			if(sessionObj.getInt("status")==-1){
				throw  new RuntimeException(sessionObj.getString("message"));
			}
			JSONObject session = sessionObj.getJSONObject("data");
			ImUtill.sendImMsg("system","系统",session.getString("id"),msgType, msg);
			return true;
		}catch (Exception e){
			e.printStackTrace();

+ 171 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java

@ -0,0 +1,171 @@
package com.yihu.wlyy.util;
import org.json.JSONArray;
import org.json.JSONObject;
/**
 * Created by 卓 on 2017/1/13.
 */
public class ImUtill {
    /**
     * 发送消息给IM
     *
     * @param from        来自
     * @param contentType 1文字 2图片消息
     * @param content     内容
     */
    public static String sendImMsg(String from,String fromName, String sessionId, String contentType, String content) {
        String imAddr = SystemConf.getInstance().getImListGet() + "/api/v2/sessions/"+sessionId+"/messages";
        JSONObject params = new JSONObject();
        params.put("sender_id", from);
        params.put("sender_name", fromName);
        params.put("content_type", contentType);
        params.put("content", content);
        params.put("session_id", sessionId);;
        String response = HttpClientUtil.postBody(imAddr, params);
        return response;
    }
    /**
     * 发送消息给IM
     *
     * @param from        来自
     * @param contentType 1文字 2图片消息
     * @param content     内容
     */
    public static String sendTopicIM(String from,String fromName, String topicId, String contentType, String content) {
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + ("api/v2/sessions/topic/"+topicId+"/messages");
        JSONObject params = new JSONObject();
        params.put("sender_id", from);
        params.put("sender_name", fromName);
        params.put("content_type", contentType);
        params.put("content", content);
        params.put("topic_id", topicId);;
        String response = HttpClientUtil.postBody(url, params);
        return response;
    }
    /**
     * 结束议题
     *
     * @param topicId  议题ID
     * @param endUser  结束人
     * @param endUserName 结束人名字
     * @param sessionId 会话ID
     */
    public static JSONObject endTopics(String sessionId,String endUser, String endUserName,String topicId) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/topics/"+topicId+"/ended";
        JSONObject params = new JSONObject();
        params.put("session_id", sessionId);
        params.put("end_user", endUser);
        params.put("end_user_name",endUserName);
        params.put("topic_id", topicId);
        String ret = HttpClientUtil.postBody(imAddr,params);
        JSONObject obj  = null;
        try{
            obj = new JSONObject(ret);
        }catch (Exception e){
            return null;
        }
        return obj;
    }
    /**
     * 议题邀请人员
     * @param user 结束人名字
     * @param sessionId 会话ID
     */
    public static void updateTopicUser(String sessionId,String user) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/participants/"+user;
        JSONObject params = new JSONObject();
        params.put("user", user+":"+0);
        HttpClientUtil.putBody(imAddr,params);
    }
    /**
     * 创建议题
     *
     * @param topicId  议题ID
     * @param topicName  议题名称
     * @param participants 成员
     */
    public static JSONObject createTopics(String sessionId, String topicId, String topicName, JSONObject participants, JSONObject messages, String sessionType) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+topicId+"/topics";
        JSONObject params = new JSONObject();
        params.put("topic_id", topicId);
        params.put("topic_name", topicName);
        params.put("participants", participants.toString());
        params.put("messages", messages.toString());
        params.put("session_id", sessionId);
        params.put("session_type", sessionType);
        String ret = HttpClientUtil.postBody(imAddr,params);
        JSONObject obj  = null;
        try{
            obj = new JSONObject(ret);
        }catch (Exception e){
            return null;
        }
        return obj;
    }
    /**
     * 创建会话(system)
     *
     */
    public static JSONObject createSession(JSONObject participants,String sessionType,String sessionName,String sessionId) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions";
        JSONObject params = new JSONObject();
        params.put("participants", participants);
        params.put("session_name", sessionName);
        params.put("session_type", sessionType);
        params.put("session_id", sessionId);
        String ret = HttpClientUtil.postBody(imAddr,params);
        JSONObject obj  = null;
        try{
            obj = new JSONObject(ret);
        }catch (Exception e){
            return null;
        }
        return obj;
    }
    /**
     * 获取会话实例的消息对象
     * @param senderId
     * @param senderName
     * @param title
     * @param description
     * @param images
     * @return
     */
    public static JSONObject getCreateTopicMessage(String senderId,String senderName,String title,String description,String images){
        JSONObject messages = new JSONObject();
        messages.put("description",description);
        messages.put("title",title);
        messages.put("img",images);
        messages.put("sender_id",senderId);
        messages.put("sender_name",senderName);
        return messages;
    }
    public static JSONArray getTopicMessage(String topicId,String startMsgId,String endMsgId,int page,int pagesize,String uid){
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "api/v2/sessions/topic/"+topicId+"/messages?topic_id="+topicId+"&end="+startMsgId
                +"&start="+(endMsgId==null?"":endMsgId)+"&page="+page+"&pagesize="+pagesize+"&user="+uid;
        try{
            String ret = HttpClientUtil.get(url, "UTF-8");
            JSONObject obj = new JSONObject(ret);
            if(obj.getInt("status")==-1){
                throw new RuntimeException(obj.getString("message"));
            }else{
                return  obj.getJSONArray("data");
            }
        }catch (Exception e){
            return null;
        }
    }
}

+ 6 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendP2PUtil.java

@ -20,12 +20,11 @@ public class SendP2PUtil {
		params.add(new BasicNameValuePair("to", to));
		params.add(new BasicNameValuePair("content",  content));
		params.add(new BasicNameValuePair("contentType",contentType));
		//String response = HttpClientUtil.post(url, params, "UTF-8");
//		if (StringUtils.isEmpty(response)) {
//			return "-1";
//		}else{
//			return "200";
//		}
		return "200";
		String response = HttpClientUtil.post(url, params, "UTF-8");
		if (StringUtils.isEmpty(response)) {
			return "-1";
		}else{
			return "200";
		}
	}
}

+ 27 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendPatientUtil.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.util;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class SendPatientUtil {
	public static String sendToPatient(String from,String fromName,String to,String contentType,String content,String title,String type){
		JSONObject participants = new JSONObject();
		participants.put(from,0);
		participants.put(to,0);
		if(!"4".equals(contentType)){
			contentType = "0";
		}
		JSONObject sessionJson  = ImUtill.createSession(participants,"1",title,to+"_consult_"+type);
		if(sessionJson.getInt("status")==-1){
			throw  new RuntimeException(sessionJson.getString("message"));
		}
		JSONObject session = sessionJson.getJSONObject("data");
		return ImUtill.sendImMsg(from,fromName,session.getString("id"),contentType,content);
	}
}

+ 24 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -1,17 +1,22 @@
package com.yihu.wlyy.web.common;
import java.io.File;
import java.io.IOException;
import java.beans.Encoder;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.io.FileUtils;
import org.json.JSONObject;
import org.springframework.http.MediaType;
@ -161,16 +166,31 @@ public class FileUploadController extends BaseController {
        List<String> tempPaths = new ArrayList<String>();
        try {
            String fastUrl = SystemConf.getInstance().getSystemProperties().getProperty("fastdfs_file_url");
            String type  = request.getParameter("type");
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
            String fileName = null;
            for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                // 上传文件
                MultipartFile mf = entity.getValue();
                //byte audioData[] = mf.getBytes();
                //AudioFormat af = getAudioFormat();
                //ByteArrayInputStream bais = new ByteArrayInputStream(audioData);
                //AudioInputStream ais = new AudioInputStream(bais,af, audioData.length / af.getFrameSize());
                //File file = new File("temp.wav");
                //InputStream in = new FileInputStream(file);
                //AudioSystem.write(ais, AudioFileFormat.Type.WAVE,file);
                fileName = mf.getOriginalFilename();
                String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream(),fileExt,"");
                if("3".equals(type)){
                    fileExt ="wav";
                }
                ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
                tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
                        + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
            }

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/archives/DoctorArchivesController.java

@ -118,10 +118,12 @@ public class DoctorArchivesController extends BaseController {
                                @ApiParam(name="page",value="第几页",defaultValue = "1")
                                @RequestParam(value="page",required = true) String page,
                                @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
                                @RequestParam(value="pageSize",required = true) String pageSize)
                                @RequestParam(value="pageSize",required = true) String pageSize,
                                @ApiParam(name="lastTime",value="最后一条时间",defaultValue = "2010-10-10 00:00:00")
                                    @RequestParam(value="lastTime",required = false) String lastTime)
    {
        try {
            List<Map<String,String>> result = patientRecordService.getExamAndLabReport(patient, page, pageSize);
            List<Map<String,String>> result = patientRecordService.getExamAndLabReport(patient, page, pageSize,lastTime);
            return write(200, "获取检查检验报告成功!", "data", result);
        } catch (Exception e) {

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

@ -683,7 +683,7 @@ public class DoctorConsultController extends WeixinBaseController {
            consult.setVoice(voice);
            consult.setDoctor(doctorCode);//设置专科医生
            // 保存到数据库
            consultTeamService.addFamousTeamConsult(consult, getUID(), "2");
            consultTeamService.famousConsult(consult, getUID(), "2");
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.D_CT_04.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.您有新的名医咨询.name(), consult.getConsult());
            if (StringUtils.isNotEmpty(images)) {
@ -842,6 +842,7 @@ public class DoctorConsultController extends WeixinBaseController {
            consult.setImages(images);
            // 设置咨询语音URL
            consult.setVoice(voice);
            consult.setDoctor(doctorCode);//设置专科医生
            // 保存到数据库
            if(consultTeamService.isCommonTeam( doctorCode, getUID() ))
@ -935,4 +936,67 @@ public class DoctorConsultController extends WeixinBaseController {
            return error(-1, "查询咨询状态失败");
        }
    }
    @RequestMapping(value = "seekHelp")
    @ResponseBody
    public String seekHelp(
            @RequestParam(required = true) String symptoms,
            @RequestParam(required = false) String oldConsultCode,
            @RequestParam(required = false) String doctorCode,
            @RequestParam(required = false) String images){
        try {
                if (StringUtils.isEmpty(images)) {
                    images = fetchWxImages();
                    // 将临时图片拷贝到正式存储路径下
                    if (StringUtils.isNotEmpty(images)) {
                        images = CommonUtil.copyTempImage(images);
                    }
                }
                ConsultTeam consult = new ConsultTeam();
                // 设置咨询类型:1三师咨询,2家庭医生咨询 6.患者发起名医咨询 7医生发起的名医咨询 10医生发起的求助
                consult.setType(10);
                // 设置主要症状
                consult.setSymptoms(symptoms);
                // 设置咨询图片URL
                consult.setImages(images);
                consult.setDoctor(doctorCode);//设置专科医生
                // 保存到数据库
                if(consultTeamService.isCommonTeam(doctorCode, getUID())){
                    consultTeamService.addSeekHelpTeam(consult, getUID(), oldConsultCode);
                }else{
                    consultTeamService.addSeekHelpOtherTeam(consult, getUID(), oldConsultCode);
                }
                return success("提交成功");
            } catch (Exception ex) {
                error(ex);
                return invalidUserException(ex, -1, "提交失败!");
            }
    }
    /**
     * 结束咨询接口
     * @param consult 咨询标识
     * @return
     */
    @RequestMapping(value = "finish_consult")
    @ResponseBody
    public String finishConsult(String consult) {
        try {
            int flag = consultTeamService.finishConsult(consult, getUID(), 2);
            if (flag > 0) {
                return success("咨询已关闭");
            } else {
                return error(-1, "关闭失败!");
            }
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "关闭失败!");
        }
    }
}

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -6,10 +6,10 @@ import com.yihu.wlyy.entity.education.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.doctor.message.DoctorMessageController;
import io.swagger.annotations.Api;
@ -73,6 +73,8 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    ConsultService consultService;
    /**
     * 查询
     *
@ -381,7 +383,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                    // 行政团队
                    heap.setAdminTeamCode(signFamily.getAdminTeamId());
                    list.add(heap);
                    SendP2PUtil.sendP2Pmsg(doctor.getCode(), p, "4", "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}");
                    consultService.sendMucMessageBySingnType(doctor.getCode(),doctor.getName(), p, "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4","医生:"+doctor.getName()+"给患者:"+patientTemp.getName()+"发送了健康教育文章!");
                    if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
                        // 推送消息给微信端
                        JSONObject json = new JSONObject();

+ 19 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -1,6 +1,13 @@
package com.yihu.wlyy.web.doctor.health;
import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -33,6 +40,14 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
	@Autowired
	private PatientHealthGuidanceService patientHealthGuidanceService;
	@Autowired
	private DoctorService doctorService;
	@Autowired
	private PatientService patientService;
	@Autowired
	private ConsultService consultService;
	/**
	 * 获取某个健康指导
	 *
@ -68,7 +83,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
			guidance.setContent(content);
			guidance.setDoctor(getUID());
			guidance.setPatient(patient);
			Doctor doctor = doctorService.findDoctorByCode(getUID());
			if (StringUtils.isNotEmpty(images)) {
				images = CommonUtil.copyTempImage(images);
			}
@ -81,7 +96,8 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
			// 保存
			if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
				SendP2PUtil.sendP2Pmsg(getUID(), patient, "1",content);
				Patient p = patientService.findByCode(patient);
				consultService.sendMucMessageBySingnType(getUID(),doctor.getName(),patient,content,"1","医生:"+doctor.getName()+"给患者:"+p.getName()+"发送了健康指导!");
				return success("保存成功!");
			} else {
				return error(-1, "保存失败!");

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/archives/PatientArchivesController.java

@ -121,10 +121,12 @@ public class PatientArchivesController extends WeixinBaseController {
    public String getReportList(@ApiParam(name="page",value="第几页",defaultValue = "1")
                                    @RequestParam(value="page",required = true) String page,
                                @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
                                    @RequestParam(value="pageSize",required = true) String pageSize)
                                    @RequestParam(value="pageSize",required = true) String pageSize,
                                @ApiParam(name="lastTime",value="最后一条时间",defaultValue = "2010-10-10 00:00:00")
                                    @RequestParam(value="lastTime",required = false) String lastTime)
    {
        try {
            List<Map<String,String>> result = patientRecordService.getExamAndLabReport(getUID(), page, pageSize);
            List<Map<String,String>> result = patientRecordService.getExamAndLabReport(getUID(), page, pageSize,lastTime);
            return write(200, "获取检查检验报告成功!", "data", result);
        } catch (Exception e) {

+ 13 - 165
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -393,7 +393,7 @@ public class ConsultController extends WeixinBaseController {
            consult.setVoice(voice);
            consult.setDoctor(doctorCode);//设置专科医生
            // 保存到数据库
            consultTeamService.addFamousTeamConsult(consult, getUID(), "1");
            consultTeamService.famousConsult(consult, getUID(), "1");
            //名医咨询次数减一
            doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
            // 推送消息给医生
@ -568,7 +568,7 @@ public class ConsultController extends WeixinBaseController {
    @ResponseBody
    public String finish(@RequestParam(required = true) String code) {
        try {
            int row = consultTeamService.finish(code, getUID(), 1);
            int row = consultTeamService.finishConsult(code, getUID(), 1);
            if (row > 0) {
                return success("操作成功!");
            } else {
@ -614,7 +614,6 @@ public class ConsultController extends WeixinBaseController {
                    if (!StringUtils.isEmpty(images)) {
                        arr = images.split(",");
                    }
                    content = fetchWxImages();
                } else {
                    arr = content.split(",");
@ -648,37 +647,20 @@ public class ConsultController extends WeixinBaseController {
                arr = new String[]{content};
            }
            JSONObject group = talkGroupService.findConsultTalkGroup(consultModel.getConsult());
            Patient patient = patientDao.findByCode(getUID());
            int i = 0;
            List<String> failed = new ArrayList<>();
            for (ConsultTeamLog log : logs) {
                String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                        + (group != null ? "api/v1/chats/gm" : "api/v1/chats/pm");
                List<NameValuePair> params = new ArrayList<>();
                if (group == null) {
                    params.add(new BasicNameValuePair("from", getUID()));
                    params.add(new BasicNameValuePair("to", consultModel.getDoctor()));
                    params.add(new BasicNameValuePair("content", log.getContent()));
                    params.add(new BasicNameValuePair("contentType", String.valueOf(log.getType())));
                } else {
                    params.add(new BasicNameValuePair("from", getUID()));
                    params.add(new BasicNameValuePair("at", ""));
                    params.add(new BasicNameValuePair("group", group.getString("code")));
                    params.add(new BasicNameValuePair("groupType", "2"));
                    params.add(new BasicNameValuePair("content", log.getContent()));
                    params.add(new BasicNameValuePair("contentType", String.valueOf(log.getType())));
                }
                String response = HttpClientUtil.post(url, params, "UTF-8");
                if (StringUtils.isEmpty(response)) {
                    failed.add(arr[i]);
                String response = ImUtill.sendTopicIM(getUID(),patient.getName(),consult,String.valueOf(log.getType()),log.getContent());
                if (StringUtils.isNotEmpty(response)) {
                    JSONObject resObj = new JSONObject(response);
                    if(resObj.getInt("status")==-1){
                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!"+resObj.getString("message"));
                    }
                    failed.add(response);
                }
            }
            return write(200, "追问成功!", "data", failed);
        } catch (Exception e) {
            error(e);
@ -696,148 +678,14 @@ public class ConsultController extends WeixinBaseController {
     */
    @RequestMapping(value = "loglist")
    @ResponseBody
    public String loglist(@RequestParam String consult, @RequestParam long id, @RequestParam int pagesize) {
    public String loglist(@RequestParam String consult, @RequestParam int page, @RequestParam int pagesize) {
        try {
            ConsultTeam consultModel = consultTeamService.findByCode(consult);
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
            }
            Patient p = patientDao.findByCode(getUID());
            Map<String, Doctor> map = new HashMap<>();
            List<JSONObject> jsonArray = new ArrayList<>();
            JSONObject group = talkGroupService.findConsultTalkGroup(consultModel.getConsult());
            if (group != null) {
                String urlG = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                        + "api/v1/chats/gm";
                String reG = HttpUtil.sendGet(urlG, "user_id=" + getUID() + "&group_id=" + group.getString("code"));
                JSONObject resultG = null;
                if (!org.springframework.util.StringUtils.isEmpty(reG)) {
                    resultG = new JSONObject(new String(reG.getBytes(), "utf-8"));
                }
                if (resultG != null && resultG.getInt("count") > 0) {
                    JSONArray list = resultG.getJSONArray("records");
                    for (int i = 0; i < list.length(); i++) {
                        JSONObject obj = list.getJSONObject(i);
                        if (obj.getInt("contentType") == 5 || obj.getInt("contentType") == 6) {
                            continue;
                        }
                        JSONObject json = new JSONObject();
                        json.put("id", obj.getInt("id"));
                        if (!obj.getString("from").equals(getUID())) {
                            Doctor doc = null;
                            if (map.containsKey(obj.getString("from"))) {
                                doc = map.get(obj.getString("from"));
                            } else {
                                doc = doctorService.findDoctorByCode(obj.getString("from"));
                            }
                            // 设置回复医生姓名
                            json.put("doctorName", doc.getName());
                            json.put("photo", doc.getPhoto());
                        } else {
                            // 设置回复医生姓名
                            json.put("doctorName", p.getName());
                            json.put("photo", p.getPhoto());
                        }
                        // 设置回复内容
                        json.put("content", obj.getString("content"));
                        // 设置咨询或回复时间
                        json.put("time", DateUtil.dateToStr(new Date(obj.getLong("timestamp")), DateUtil.YYYY_MM_DD_HH_MM_SS));
                        // 设置记录类型:1文字,2图片,3语音 4 文章
                        json.put("msgType", obj.getInt("contentType"));
                        // 设置类型:0患者问,1医生回复,2患者追问,3患者评价
                        if (!obj.getString("from").equals(getUID())) {
                            json.put("type", 1);
                        } else {
                            json.put("type", obj.getInt("contentType") == 6 ? 0 : 2);
                        }
                        jsonArray.add(json);
                    }
                }
            }
            JSONObject result = null;
            String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                    + "api/v1/chats/pm";
            String re = HttpUtil.sendGet(url, "closed_interval=true&user_id=" + getUID() + "&peer_id=" + consultModel.getDoctor()
                    + "&message_end_id=" + consultModel.getStartMsgId() + (consultModel.getEndMsgId() != null ? ("&message_start_id=" + consultModel.getEndMsgId()) : ""));
            if (!org.springframework.util.StringUtils.isEmpty(re)) {
                result = new JSONObject(new String(re.getBytes(), "utf-8"));
            }
            if (result != null && result.getInt("count") > 0) {
                JSONArray list = result.getJSONArray("records");
                for (int i = 0; i < list.length(); i++) {
                    JSONObject obj = list.getJSONObject(i);
                    if (obj.getInt("contentType") == 5) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("id", obj.getInt("id"));
                    if (!obj.getString("from").equals(getUID())) {
                        Doctor doc = null;
                        if (map.containsKey(obj.getString("from"))) {
                            doc = map.get(obj.getString("from"));
                        } else {
                            doc = doctorService.findDoctorByCode(obj.getString("from"));
                        }
                        // 设置回复医生姓名
                        json.put("doctorName", doc.getName());
                        json.put("photo", doc.getPhoto());
                    } else {
                        // 设置回复医生姓名
                        json.put("doctorName", p.getName());
                        json.put("photo", p.getPhoto());
                    }
                    // 设置回复内容
                    json.put("content", obj.getString("content"));
                    // 设置咨询或回复时间
                    json.put("time", DateUtil.dateToStr(new Date(obj.getLong("timestamp")), DateUtil.YYYY_MM_DD_HH_MM_SS));
                    // 设置记录类型:1文字,2图片,3语音
                    json.put("msgType", obj.getInt("contentType"));
                    // 设置类型:0患者问,1医生回复,2患者追问,3患者评价
                    if (!obj.getString("from").equals(getUID())) {
                        json.put("type", 1);
                    } else {
                        json.put("type", obj.getInt("contentType") == 6 ? 0 : 2);
                    }
                    jsonArray.add(json);
                }
            }
            jsonArray.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if (o1.getString("time").compareTo(o2.getString("time")) > 0) {
                        return -1;
                    } else if (o1.getString("time").compareTo(o2.getString("time")) < 0) {
                        return 1;
                    } else {
                        return 0;
                    }
                }
            });
            // 返回结果
            return write(200, "查询成功", "list", new JSONArray(jsonArray));
           JSONArray array =  ImUtill.getTopicMessage(consultModel.getConsult(),consultModel.getStartMsgId(),consultModel.getEndMsgId(),page,pagesize,getUID());
            return write(200, "查询成功", "list", array);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/OpenApiSmjkController.java

@ -118,10 +118,12 @@ public class OpenApiSmjkController extends BaseController {
								@ApiParam(name="page",value="第几页",defaultValue = "1")
								@RequestParam(value="page",required = true) String page,
								@ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
								@RequestParam(value="pageSize",required = true) String pageSize)
								@RequestParam(value="pageSize",required = true) String pageSize,
								@ApiParam(name="lastTime",value="最后一条时间",defaultValue = "2010-10-10 00:00:00")
									@RequestParam(value="lastTime",required = false) String lastTime)
	{
		try {
			List<Map<String,String>> result = patientRecordService.getExamAndLabReport(patient, page, pageSize);
			List<Map<String,String>> result = patientRecordService.getExamAndLabReport(patient, page, pageSize,lastTime);
			return write(200, "获取检查检验报告成功!", "data", result);
		} catch (Exception e) {