Browse Source

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

LiTaohong 5 years ago
parent
commit
91f5d294f5
48 changed files with 4480 additions and 51 deletions
  1. 0 1
      business/base-service/src/main/java/com/yihu/jw/dict/dao/DictHospitalDeptDao.java
  2. 1 1
      business/base-service/src/main/java/com/yihu/jw/dict/service/DictHospitalDeptService.java
  3. 1 1
      business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorService.java
  4. 12 0
      business/base-service/src/main/java/com/yihu/jw/hospital/httplog/dao/WlyyHttpLogDao.java
  5. 0 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java
  6. 11 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/WlyyDoctorClinicRoomDao.java
  7. 308 5
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  8. 26 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  9. 1 1
      business/base-service/src/main/java/com/yihu/jw/org/service/BaseOrgService.java
  10. 52 0
      business/im-service/pom.xml
  11. 30 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java
  12. 26 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDao.java
  13. 13 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDoctorDao.java
  14. 13 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamLogDao.java
  15. 1051 0
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  16. 309 0
      business/im-service/src/main/java/com/yihu/jw/im/util/HttpClientUtil.java
  17. 680 0
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  18. 91 0
      business/im-service/src/main/java/com/yihu/jw/im/util/ImageCompress.java
  19. 120 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultDo.java
  20. 390 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDo.java
  21. 90 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDoctorDo.java
  22. 115 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamLogDo.java
  23. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/consult/WlyyHospitalWaitingRoomDO.java
  24. 90 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/httplog/WlyyHttpLogDO.java
  25. 15 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java
  26. 93 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  27. 12 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyOutpatientVO.java
  28. 6 5
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionInfoVO.java
  29. 114 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/im/ConsultVO.java
  30. 22 0
      common/common-util/pom.xml
  31. 107 0
      common/common-util/src/main/java/com/yihu/jw/util/common/FileUtil.java
  32. 39 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  33. 24 0
      common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java
  34. 1 1
      common/common-web/src/main/resources/logback-spring.xml
  35. 14 14
      svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java
  36. 25 2
      svr/svr-base/src/main/resources/application.yml
  37. 15 0
      svr/svr-internet-hospital-entrance/pom.xml
  38. 29 1
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java
  39. 5 0
      svr/svr-internet-hospital/pom.xml
  40. 8 8
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java
  41. 181 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  42. 280 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  43. 5 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/SysDictEndpoint.java
  44. 13 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  45. 34 1
      svr/svr-internet-hospital/src/main/resources/application.yml
  46. 1 1
      svr/svr-internet-hospital/src/main/resources/bootstrap.yml
  47. 1 0
      wlyy-lib-parent-pom/pom.xml
  48. 5 1
      wlyy-parent-pom/pom.xml

+ 0 - 1
business/base-service/src/main/java/com/yihu/jw/dict/dao/DictHospitalDeptDao.java

@ -23,7 +23,6 @@ import java.util.Map;
 * </pre>
 * @since 1.
 */
//@Transactional
public interface DictHospitalDeptDao extends PagingAndSortingRepository<DictHospitalDeptDO, Integer>, JpaSpecificationExecutor<DictHospitalDeptDO>  {
    @Query("select code as code,name as name from DictHospitalDeptDO where orgCode in ?1")

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/dict/service/DictHospitalDeptService.java

@ -12,7 +12,7 @@ import java.util.List;
@Service
public class DictHospitalDeptService extends BaseJpaService<BaseCityDO, BaseCityDao> {
public class HospitalDeptService extends BaseJpaService<BaseCityDO, BaseCityDao> {
    @Autowired
    private DictHospitalDeptDao dictHospitalDeptDao;

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorService.java

@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDao> {
public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoctorDao> {
    @Autowired
    private BaseDoctorDao baseDoctorDao;

+ 12 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/httplog/dao/WlyyHttpLogDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.hospital.httplog.dao;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2019/6/25.
 */
public interface WlyyHttpLogDao extends PagingAndSortingRepository<WlyyHttpLogDO, String>, JpaSpecificationExecutor<WlyyHttpLogDO> {
}

+ 0 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java

@ -1,8 +1,6 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/WlyyDoctorClinicRoomDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author huangwenjie
 */
public interface WlyyDoctorClinicRoomDao extends PagingAndSortingRepository<WlyyDoctorClinicRoomDO, String>, JpaSpecificationExecutor<WlyyDoctorClinicRoomDO> {
}

+ 308 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -8,19 +8,21 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.doctor.dao.DoctorWorkTimeDao;
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
import com.yihu.jw.hospital.prescription.dao.*;
@ -80,8 +82,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private DoctorClinicRoomConsultDao doctorClinicRoomConsultDao;
    @Autowired
    private HospitalWaitingRoomDao hospitalWaitingRoomDao;
    @Autowired
    private DictHospitalDeptDao dictHospitalDeptDao;
@ -105,6 +105,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private DoctorWorkTimeDao doctorWorkTimeDao;
    @Autowired
    private PatientRegisterTimeDao patientRegisterTimeDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    @Autowired
    private WlyyDoctorClinicRoomDao wlyyDoctorClinicRoomDao;
    
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -258,6 +263,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //居民详情
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
        rs.put("patientName",basePatientDO.getName());
        rs.put("photo",basePatientDO.getPhoto());
        rs.put("patientId",basePatientDO.getId());
        rs.put("idCard",basePatientDO.getIdcard());
        rs.put("sex", basePatientDO.getSex());
@ -310,6 +316,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            rs.put("expressageLogs",null);
        }
        //预约记录
        List<WlyyPatientRegisterTimeDO> timeDOs = patientRegisterTimeDao.findByOutpatientId(outpatientId);
        if(timeDOs!=null&&timeDOs.size()>0){
            rs.put("register",timeDOs.get(0));
        }else{
            rs.put("register",null);
        }
        return rs;
    }
@ -522,6 +536,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public Boolean createRoom(WlyyOutpatientDO outpatientDO,Date reservationTime){
        WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO();
        waitingRoom.setDept(outpatientDO.getDept());
        waitingRoom.setDeptName(outpatientDO.getDeptName());
        waitingRoom.setHospital(outpatientDO.getHospital());
        waitingRoom.setHospitalName(outpatientDO.getHospitalName());
        waitingRoom.setConsultType(1);
        waitingRoom.setPatientId(outpatientDO.getPatient());
        waitingRoom.setPatientName(outpatientDO.getPatientName());
@ -532,7 +552,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        waitingRoom.setConsultType(Integer.parseInt(outpatientDO.getType()));
        if(StringUtils.isNotBlank(outpatientDO.getDoctor())){
            waitingRoom.setDoctor(outpatientDO.getDoctor());
            waitingRoom.setDoctor(outpatientDO.getDoctorName());
            waitingRoom.setDoctorName(outpatientDO.getDoctorName());
        }
        waitingRoom.setOutpatientId(outpatientDO.getId());
        waitingRoom.setCreateTime(new Date());
@ -753,6 +773,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if(doctorMappingDO==null){
            throw new RuntimeException("未找到医生映射信息");
        }
        net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(),doctorMappingDO.getMappingCode(),outpatientDO.getDept(),null,outpatientDO.getWinNo(),demoFlag);
        String rsCode = (String)rs.get("@RESULT");
        if("0".equals(rsCode)){
@ -762,7 +783,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            String conNo = (String)rs.get("@times");
            outpatientDO.setCardNo(conNo);
        }
        //保存日志
        WlyyHttpLogDO log = new WlyyHttpLogDO();
        log.setCode("registerOutPatient");
        log.setName("挂号");
        log.setPatient(outpatientDO.getPatient());
        log.setDoctor(doctor);
        log.setResponse(rs.toString());
        log.setRequest("outPatientId="+outPatientId+"&doctor="+doctor);
        log.setStatus(rsCode);
        log.setCreateTime(new Date());
        wlyyHttpLogDao.save(log);
        return rs;
    }
@ -923,8 +954,22 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                
                //调用his开方接口
                net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
                //判断返回结果
                String rs = jsonObject.getString("@RESULT");
                //保存日志
                WlyyHttpLogDO log = new WlyyHttpLogDO();
                log.setCode("makeDiagnosis");
                log.setName("下诊断");
                log.setPatient(outpatientDO.getPatient());
                log.setDoctor(outpatientDO.getDoctor());
                log.setResponse(jsonObject.toString());
                log.setRequest(jsonData.toJSONString());
                log.setStatus(rs);
                log.setCreateTime(new Date());
                wlyyHttpLogDao.save(log);
                if("0".equals(rs)){
                    String admNo = jsonObject.getString("@ADM_NO");
                    String realOrder = jsonObject.getString("@real_order");
@ -1420,4 +1465,262 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public List<WlyyHospitalSysDictDO> findCancelReasonList(){
        return sysDictDao.findByDictName("PatientCancel");
    }
    /**
     * 獲取快速咨詢時間
     * @return
     */
    public List<Map<String,Object>> findFastRegisterDate(){
        int days = 7;
        String AMStartTime ="8:00";
        String AMEndTime ="12:00";
        String PMStartTime ="14:00";
        String PMEndTime ="17:00";
        //设置上午过号时间
        Calendar scTime = Calendar.getInstance();
        scTime.setTime(new Date());
        Calendar ecTime = Calendar.getInstance();
        ecTime.setTime(new Date());
        List<Map<String,Object>> times = new ArrayList<>();
        for(int i=0;i<days;i++){
            //設置上午時段
            Map<String,Object> time = new HashedMap();
            time.put("timeType","1");
            time.put("date",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd"));
            time.put("weekDay",scTime.get(Calendar.DAY_OF_WEEK));
            String ts[] = AMStartTime.split(":");
            scTime.set(scTime.get(Calendar.YEAR),scTime.get(Calendar.MONTH),scTime.get(Calendar.DAY_OF_MONTH),Integer.parseInt(ts[0]),Integer.parseInt(ts[1]),00);
            time.put("startTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
            String ts2[] = AMEndTime.split(":");
            scTime.set(scTime.get(Calendar.YEAR),scTime.get(Calendar.MONTH),scTime.get(Calendar.DAY_OF_MONTH),Integer.parseInt(ts2[0]),Integer.parseInt(ts2[1]),00);
            time.put("endTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
            times.add(time);
            //設置下午時段
            Map<String,Object> time2 = new HashedMap();
            time2.put("timeType","2");
            time2.put("date",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd"));
            time2.put("weekDay",scTime.get(Calendar.DAY_OF_WEEK));
            String pts[] = PMStartTime.split(":");
            scTime.set(scTime.get(Calendar.YEAR),scTime.get(Calendar.MONTH),scTime.get(Calendar.DAY_OF_MONTH),Integer.parseInt(pts[0]),Integer.parseInt(pts[1]),00);
            time2.put("startTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
            String pts2[] = PMEndTime.split(":");
            scTime.set(scTime.get(Calendar.YEAR),scTime.get(Calendar.MONTH),scTime.get(Calendar.DAY_OF_MONTH),Integer.parseInt(pts2[0]),Integer.parseInt(pts2[1]),00);
            time2.put("endTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
            times.add(time2);
            //生成下一天
            scTime.add(Calendar.DAY_OF_MONTH,1);
        }
        if(DateUtil.strToDate(DateUtil.getTimeShort(),DateUtil.HH_MM).after(DateUtil.strToDate(AMEndTime,DateUtil.HH_MM))) {
            times.remove(0);
        }
        if(DateUtil.strToDate(DateUtil.getTimeShort(),DateUtil.HH_MM).after(DateUtil.strToDate(PMEndTime,DateUtil.HH_MM))) {
            times.remove(0);
        }
        return times;
    }
    
    /**
     * 医生可接单列表
     * @param doctor
     * @param type
     * @return
     */
    public List<Map<String,Object>> findWaitingRoomOutpatientByDoctor(String doctor, Integer type) {
        
        String sql ="SELECT " +
                "room.outpatient_id AS id," +
                "room.patient_id AS patient_id," +
                "room.patient_name AS name," +
                "patient.sex AS sex," +
                "patient.idcard AS idcard," +
                "patient.photo AS photo," +
                "patient.birthday AS birthday," +
                "room.consult_type AS consult_type," +
                "room.reservation_time AS time," +
                "outpatient.disease_img AS disease_img," +
                "outpatient.description AS description," +
                "outpatient.origin_con_no AS origin_con_no " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
                "wlyy_outpatient outpatient " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND room.doctor IS NULL " +
                "AND room.consult_type="+type;
        
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            //根据身份证计算年龄
            for(Map<String,Object> outpatient :list){
                String idcard = (String)outpatient.get("idcard");
                outpatient.put("age",DateUtil.getAgeForIdcard(idcard));
            }
        }
        
        return list;
    }
    
    public List<Map<String,Object>> findWaitingRoomPatient(String dept, Integer type) {
        
        String sql ="SELECT " +
                "patient.id AS id," +
                "patient.name AS name," +
                "patient.sex AS sex," +
                "patient.idcard AS idcard," +
                "patient.photo AS photo," +
                "waitingroom.reservation_type AS type," +
                "waitingroom.consult_type AS consult_type," +
                "waitingroom.reservation_time AS reservation_time " +
                "FROM " +
                "wlyy_hospital_waiting_room waitingroom," +
                "base_patient patient " +
                "WHERE waitingroom.consult_type=2 AND doctor IS NOT NULL ";
        
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            //根据身份证计算年龄
            for(Map<String,Object> roompatient :list){
                String idcard = (String)roompatient.get("idcard");
                roompatient.put("age",DateUtil.getAgeForIdcard(idcard));
            }
        }
        
        return list;
    }
    
    public JSONObject findWaitingRoomStatusCount(String dept) {
        
        String totalSql = "SELECT count(id) AS total FROM wlyy_hospital_waiting_room WHERE visit_status=1 ";
        totalSql += " AND reservation_time >='"+DateUtil.dateToStrShort(new Date())+" 00:00:00'";
        totalSql += " AND reservation_time <='"+DateUtil.dateToStrShort(new Date())+" 23:59:59'";
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
        }
        
        JSONObject result = new JSONObject();
        result.put("waiting_count",count);
        result.put("outpatient_count",count);
        result.put("waiting_count_difference",count);
        result.put("outpatient_count_difference",count);
        result.put("yesterday_waiting_count",count);
        
        return result;
    }
    
    public List<Map<String,Object>> findClinicRoomList(String dept) {
        
        String sql ="SELECT " +
                "id," +
                "doctor_name," +
                "clinic_status AS visit_status," +
                "patient_name AS patient_name," +
                "waiting_count AS waiting_count," +
                "room_name AS room_name " +
                "FROM wlyy_doctor_clinic_room ";
        
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        
        return list;
    }
    
    public WlyyDoctorClinicRoomDO findClinicRoomStatus(String id) {
        return wlyyDoctorClinicRoomDao.findOne(id);
    }
    /**
     * 获取快速咨询时间分段
     * @param startTime
     * @param endTime
     * @return
     */
    public List<Map<String,Object>> findByTimeSlot(String startTime,String endTime){
        int interval = 30;
        List<Map<String,Object>> times = new ArrayList<>();
        //设置上午过号时间
        Calendar scTime = Calendar.getInstance();
        scTime.setTime(DateUtil.stringToDate(startTime,"yyyy-MM-dd HH:mm:ss"));
        Calendar ecTime = Calendar.getInstance();
        ecTime.setTime(DateUtil.stringToDate(endTime,"yyyy-MM-dd HH:mm:ss"));
        while (scTime.getTime().before(ecTime.getTime())){
            if(new Date().before(scTime.getTime())){
                Map<String,Object> time = new HashedMap();
                time.put("startTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
                scTime.add(Calendar.MINUTE,interval);
                time.put("endTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
                times.add(time);
            }else{
                scTime.add(Calendar.MINUTE,interval);
            }
        }
        return times;
    }
    
    /**
     * 根据疾病名称,热门部门查询医生
     * @param orgCode 机构码
     * @param dept 部门CODE
     * @param diseaseKey 疾病名称
     * @return
     */
    public List<Map<String,Object>> findDoctorByHospitalAndDiseaseAndDept(String orgCode, String dept, String diseaseKey,String doctorNameKey) {
    
        String sql ="SELECT " +
                " d.id, " +
                " d.photo, " +
                " d.`name`, " +
                " d.expertise," +
                " d.introduce," +
                " d.job_title_code AS jobTitleCode, " +
                " d.job_title_name AS jobTitleName," +
                " d.charge_type AS chargeType," +
                " h.dept_name AS deptName" +
                " FROM " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
                " WHERE  " +
                " h.org_code = '"+orgCode+"'";
        if(StringUtils.isNotBlank(diseaseKey)){
            sql+=" AND d.expertise like '%"+diseaseKey+"%'";
        }
    
        if(StringUtils.isNotBlank(doctorNameKey)){
            sql+=" AND d.name like '%"+doctorNameKey+"%'";
        }
        
        if(StringUtils.isNotBlank(dept)){
            sql+=" AND h.dept_code = '"+dept+"' ";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
    
        return list;
    }
    
    /**
     * 获取常见疾病和热门部门字典
     * @param dictName 字典名称
     * @return
     */
    public List<Map<String,Object>> findHotDeptAndDiseaseDict(String dictName) {
        String sql ="SELECT * from wlyy_hospital_sys_dict where dict_name='"+dictName+"' ORDER BY sort ASC;";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        
        return  list;
    }
}

+ 26 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -350,6 +350,8 @@ public class EntranceService {
                                wlyyPrescriptionInfoVO.setSupplyName(null != jsonObjectBody.get("YPYF00") ? jsonObjectBody.get("YPYF00").toString() : "");
                                wlyyPrescriptionInfoVO.setDays(null != jsonObjectBody.get("days") ? jsonObjectBody.get("days").toString() : "");
                                wlyyPrescriptionInfoVO.setFrequency(null != jsonObjectBody.get("frequency") ? jsonObjectBody.get("frequency").toString() : "");
                                //规格
                                wlyyPrescriptionInfoVO.setSpecification(null != jsonObjectBody.get("DRUG_SPEC") ? jsonObjectBody.get("DRUG_SPEC").toString() : "");
                                wlyyPrescriptionInfoVO.setDel(1);
                                wlyyPrescriptionInfoVOS.add(wlyyPrescriptionInfoVO);
                            }
@ -1500,12 +1502,34 @@ public class EntranceService {
        jsonObject.put("userName",userName);
        jsonObject.put("idCard", idCard);
        jsonObject.put("phone", phone);
        jsonObject.put("title ", title);
        jsonObject.put("title", title);
        jsonObject.put("url", url);
        jsonObject.put("content", content);
        jsonObject.put("contentString",contentString);
        String responseMsg =httpClientUtil.sendPost(serverUrl+"/interface/ehospitalNoticePush.htm",jsonObject.toString());
        System.out.println(responseMsg);
        return responseMsg;
    }
    /**
     *
     * @param openId openId
     * @return
     */
    public String getUserInfoByOpenid(String openId){
        JSONObject  jsonObject=new JSONObject ();
        jsonObject.put("openId",openId);
        String responseMsg =httpClientUtil.sendPost(serverUrl+"/interface/getUserInfoByOpenId.htm",jsonObject.toString());
        return responseMsg;
    }
    /**
     *
     * @param interfaceid 校验码,默认:100033
     * @return
     */
    public String getAccessToken(String interfaceid){
        JSONObject  jsonObject=new JSONObject ();
        jsonObject.put("interfaceid",interfaceid);
        String responseMsg =httpClientUtil.sendPost(serverUrl+"/interface/getAccessToken.htm",jsonObject.toString());
        return responseMsg;
    }

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/org/service/BaseOrgService.java

@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
public class BaseOrgInfoService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
    @Autowired
    private BaseOrgDao baseOrgDao;

+ 52 - 0
business/im-service/pom.xml

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yihu.jw</groupId>
        <artifactId>wlyy-lib-parent-pom</artifactId>
        <version>2.0.0</version>
        <relativePath>../../wlyy-lib-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.jw</groupId>
    <artifactId>im-service</artifactId>
    <version>${parent.version}</version>
    <dependencies>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>mysql-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-exception</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>base-service</artifactId>
            <version>2.0.0</version>
        </dependency>
        <!--   poi xml导入导出工具 end -->
    </dependencies>
</project>

+ 30 - 0
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java

@ -0,0 +1,30 @@
package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultDo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 咨询表DAO类
 * @author huangwenjie
 */
public interface ConsultDao extends PagingAndSortingRepository<ConsultDo, String>, JpaSpecificationExecutor<ConsultDo> {
	
//	@Query("from ConsultDo a where a.relationCode = ?1")
//	ConsultDo findByRelationCode(String outpatientid);
//	// 查询患者咨询记录
//	Page<Object> findByPatient(String patient, String title, String id, PageRequest pageRequest);
//
//	// 查询患者咨询记录
//	Page<Object> findByPatient(String patient, String title, PageRequest pageRequest);
//
//	// 查询患者咨询记录
//	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from ConsultDo a,ConsultTeamDo b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1' and a.type<>8 order by a.czrq desc")
//	Page<Object> findByPatient(String patient, String id, Pageable pageRequest);
//
//	// 查询患者咨询记录
//	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from ConsultDo a,ConsultTeamDo b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type<>8 order by a.czrq desc")
//	Page<Object> findByPatient(String patient, Pageable pageRequest);
}

+ 26 - 0
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDao.java

@ -0,0 +1,26 @@
package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 咨询扩展表DAO类
 * @author huangwenjie
 */
public interface ConsultTeamDao  extends PagingAndSortingRepository<ConsultTeamDo, String>, JpaSpecificationExecutor<ConsultTeamDo> {
	// 根據consult查詢咨询记录
	ConsultTeamDo findByConsult(String consult);
	
//	// 关闭咨询
//	@Modifying
//	@Query("update ConsultTeam a set a.status = 1 where a.consult = ?1")
//	int updateStatusByConsult(String consult);
//
//	@Query("select a from ConsultTeamDo a,ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?1 and b.to = ?2 and a.del = '1' and a.type<>8 and a.status = 0")
//	List<ConsultTeamDo> findUnfinishedConsultType(String patient,String doctor);
}

+ 13 - 0
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDoctorDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultTeamDoctorDo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 三师咨询转接给的医生记录对象
 * @author huangwenjie
 * @date 2019/6/25 08:51
 */
public interface ConsultTeamDoctorDao extends PagingAndSortingRepository<ConsultTeamDoctorDo, String>, JpaSpecificationExecutor<ConsultTeamDoctorDo> {
}

+ 13 - 0
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamLogDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 咨询日志记录表
 * @author huangwenjie
 * @date 2019/6/25 08:57
 */
public interface ConsultTeamLogDao extends PagingAndSortingRepository<ConsultTeamLogDo, String>, JpaSpecificationExecutor<ConsultTeamLogDo> {
}

+ 1051 - 0
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -0,0 +1,1051 @@
package com.yihu.jw.im.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamDoctorDo;
import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.dao.ConsultTeamDoctorDao;
import com.yihu.jw.im.dao.ConsultTeamLogDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.im.util.ImageCompress;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.util.common.FileUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
/**
 * IM接口业务类
 * @author huangwenjie
 */
@Service
public class ImService {
	@Autowired
	public ConsultDao consultDao;
	
	@Autowired
	public ConsultTeamDao consultTeamDao;
	
	@Autowired
	public ConsultTeamDoctorDao consultTeamDoctorDao;
	
	@Autowired
	public ConsultTeamLogDao consultTeamLogDao;
	
	@Autowired
	public BasePatientDao basePatientDao;
	
	@Autowired
	public ImUtil imUtil;
	
	public FileUtil fileUtil;
	
	@Autowired
	protected HttpServletRequest request;
	
	@Autowired
	public WxAccessTokenService wxAccessTokenService;
	
	@Value("${im.data_base_name}")
	private String data_base_name;
	
	@Value("${FileTempPath.upload_temp_path}")
	private String upload_temp_path;
	
	@Value("${FileTempPath.image_path}")
	private String image_path;
	
	@Value("${FileTempPath.voice_path}")
	private String voice_path;
	
	@Value("${FileTempPath.chat_file_path}")
	private String chat_file_path;
	
	@Value("${fastDFS.fastdfs_file_url}")
	private String fastdfs_file_url;
	
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@Autowired
	private BaseDoctorDao baseDoctorDao;
	
	@Autowired
	private OutpatientDao outpatientDao;
	
	
	
	/**
	 * 查询患者所有的咨询记录
	 * @param patient 患者标识
	 * @param id 会话ID(等同IM表topicId)
	 * @param type 咨询会话类型
	 * @param pagesize 分页大小
	 * @param title 标题关键字
	 * @return
	 */
	public List<ConsultVO>  findConsultRecordByPatient(String patient, String id,Integer type, int pagesize, String title) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		
		String  sql = "SELECT " +
				"a.id AS id," +
				"a.type AS type," +
				"a.title AS title," +
				"a.symptoms AS symptoms," +
				"a.czrq AS czrq," +
				"b.status AS status," +
				"b.evaluate AS evaluate," +
				"d.name AS doctorName," +
				"d.photo AS doctorphoto," +
				"d.job_title_name AS jobTitleName " +
				"FROM wlyy_consult a," +
				"wlyy_consult_team b," +
				"base_doctor d " +
				"WHERE a.id=b.consult " +
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type="+type;
		List<ConsultVO> result = new ArrayList<>();
		
		if(!StringUtils.isEmpty(title)){
			title="%"+title+"%";
			sql +=" and a.title like '"+title+"'";
			
		}
		if (!StringUtils.isEmpty(id)) {
			sql += " and a.id = '" + id + "'";
		}
		sql += " ORDER BY a.id desc limit 0,"+pagesize+"";
		
		result = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ConsultVO.class));
		
		return result;
	}
	
	/**
	 * 查询居民与某个医生未结束的咨询
	 *
	 * @param patient 居民
	 * @param doctor  医生
	 * @return
	 */
	public String  getUnfinishedConsult(String patient, String doctor) {
		
		String totalSql = "SELECT a.consult as consultCode " +
				"FROM wlyy_consult_team a,wlyy_consult_team_doctor b " +
				"WHERE a.consult=b.consult " +
				"AND a.patient= '" +patient+"' "+
				"AND b.to_doctor='" +doctor+"' "+
				"AND a.del='1' " +
				"AND a.type<> 8 " +
				"AND a.`status`=0";
		
		List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
		
		String consultCode = "";
		if (rstotal != null && rstotal.size() > 0) {
			consultCode = rstotal.get(0).get("consultCode").toString();
		}
		return consultCode;
	}
	
	
	/**
	 * 获取会话成员
	 *
	 * @param sessionId
	 * @return
	 * @throws Exception
	 */
	public JSONArray getSessions(String sessionId) {
		JSONArray participants = imUtil.getSessions(sessionId);
		return participants;
	}
	
	/**
	 * 根据会话ID获取消息记录
	 * @param sessionId 会话ID
	 * @param startMsgId 开始的消息记录ID
	 * @param endMsgId  结束的消息记录ID
	 * @param page  第几页
	 * @param pagesize  分页数量
	 * @param uid 居民CODE
	 * @return
	 */
	public JSONArray getSessionMessage(String sessionId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
		JSONArray messageArray = imUtil.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, uid);
		return messageArray;
	}
	
	/**
	 * 根据咨询CODE进入会话
	 * @param consult 咨询CODE
	 * @param currentUid 当前居民ID
	 * @param uid 代理人ID(目前版本废弃)
	 * @return
	 */
	public int intoTopic(String consult, String currentUid, String uid) {
		ConsultTeamDo ct = consultTeamDao.findByConsult(consult);
		if (ct.getStatus() != 0) {
			return -1;
		}
		
		String content = "进入了咨询";
		BasePatientDO p = basePatientDao.findById(currentUid);
		String intoUserName = p.getName();
//		if (currentUid.equals(uid)) {
//			content = intoUserName + content;
//		} else {
			BasePatientDO member = basePatientDao.findById(currentUid);
			content = intoUserName + content;
			//目前没有家人关系,所以家人名称的名字获取暂时注释
//			content = member.getName() + "(" + relations.get(familyMember.getFamilyRelation()) + ")" + content;
//		}
		
		imUtil.sendIntoTopicIM(ct.getPatient(), ct.getPatient(), ct.getConsult(), content, currentUid, intoUserName);
		return 0;
		
	}
	
	/**
	 * 居民咨询发消息(追问接口)
	 * @param consult 咨询标识-咨询CODE
	 * @param content 消息内容
	 * @param type 消息类型
	 * @param times 次数
	 * @param patientcode 发送的居民CODE
	 * @param wechat_appid 微信公众号appid
	 * @return
	 */
	public List<String> append(String consult, String content, Integer type, Integer times,String patientcode,String wechat_appid) throws Exception {
		List<ConsultTeamLogDo> logs = new ArrayList<ConsultTeamLogDo>();
		ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
		
		if (consultModel == null) {
			throw new Exception("咨询记录不存在!");
		}
		
		if (consultModel.getEndMsgId() != null) {
			throw new Exception("咨询已结束!");
		}
		
		String[] arr = null;
		if (type == 3) {
//			String path = fetchWxVoices(wechat_appid);
//			JSONObject obj = new JSONObject();
//			// 将临时语音拷贝到正式存储路径下
//			if (org.apache.commons.lang3.StringUtils.isNotEmpty(path)) {
//				content = fileUtil.copyTempVoice(path,fastdfs_file_url);
//				obj.put("path", path);
//				obj.put("times", times);
//				content = obj.toString();
//			}
			ConsultTeamLogDo log = new ConsultTeamLogDo();
			log.setConsult(consult);
			log.setContent(content);
			log.setDel("1");
			log.setChatType(type);
			log.setType(type);
			logs.add(log);
		} else if (type == 2) {
//			// 图片消息
//			content = fetchWxImages(wechat_appid);
//			// 将临时图片拷贝到正式存储路径下
//			if (org.apache.commons.lang3.StringUtils.isNotEmpty(content)) {
//				content = fileUtil.copyTempImage(content,upload_temp_path);
//			}
//			if (org.apache.commons.lang3.StringUtils.isEmpty(content)) {
//				throw new Exception("图片上传失败!");
////				return error(-1, "图片上传失败!");
//			}
			String[] images = content.split(",");
			for (String image : images) {
				ConsultTeamLogDo log = new ConsultTeamLogDo();
				log.setConsult(consult);
				log.setContent(image);
				log.setDel("1");
				log.setChatType(type);
				log.setType(type);
				logs.add(log);
			}
		} else {
			ConsultTeamLogDo log = new ConsultTeamLogDo();
			log.setConsult(consult);
			log.setContent(content);
			log.setDel("1");
			log.setChatType(type);
			log.setType(type);
			logs.add(log);
			
			arr = new String[]{content};
		}
//            Patient patient = patientDao.findByCode(getUID());
		BasePatientDO patient = basePatientDao.findById(patientcode);
		int i = 0;
		List<String> failed = new ArrayList<>();
		
		for (ConsultTeamLogDo log : logs) {
//                String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
			String response = imUtil.sendTopicIM(patientcode, patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),null);
			
			if (org.apache.commons.lang3.StringUtils.isNotEmpty(response)) {
				JSONObject resObj = JSON.parseObject(response);
				if (resObj.getInteger("status")  == -1) {
					throw new Exception("追问失败!" + resObj.getString("message"));
//					return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!" + resObj.getString("message"));
				}
				failed.add(String.valueOf(resObj.get("data")));
//				try {
//
//					String sql = "";
//					if (consultModel.getType() == 2){
//						//家庭咨询
//						sql = "SELECT t.participant_id FROM " + data_base_name +
//								".participants t where t.session_id = '" +
//								patient.getId() + "_" + consultModel.getTeam() + "_" + consultModel.getType() +
//								"' and t.participant_role = 0";
//					}else if (consultModel.getType() == 8 || consultModel.getType() == 9 || consultModel.getType() == 11){
//						//8-续方咨询 9-在线复诊咨询 11-上门预约服务
//						sql = "SELECT t.participant_id FROM " + data_base_name +
//								".participants t where t.session_id = '" +
//								patient.getId() + "_" + consultModel.getConsult() + "_" + consultModel.getType() +
//								"' and t.participant_role = 0";
//					}
					
//					if(org.apache.commons.lang3.StringUtils.isEmpty(sql)){
//						throw new Exception("追问失败!不存在该类型!【type】:" + type);
//						return write(-1, "追问失败!", "data", "不存在该类型!【type】:" + type);
//					}
//					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 (org.apache.commons.lang3.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();
//				}
				
			}
		}
		return failed;
	}
	
	/**
	 * 获取微信服务器语音
	 *
	 * @return
	 */
	public String fetchWxVoices(String wecha_appid) {
		String voiceIds = "";
		try {
			String voices = request.getParameter("voices");
			if (org.apache.commons.lang3.StringUtils.isEmpty(voices)) {
				return voices;
			}
			String[] mediaIds = voices.split(",");
			for (String mediaId : mediaIds) {
				if (org.apache.commons.lang3.StringUtils.isEmpty(mediaId)) {
					continue;
				}
				String temp = saveVoiceToDisk(mediaId,wecha_appid);
				if (org.apache.commons.lang3.StringUtils.isNotEmpty(temp)) {
					if (voiceIds.length() == 0) {
						voiceIds = temp;
					} else {
						voiceIds += "," + temp;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
//			error(e);
		}
		return voiceIds;
	}
	
	/**
	 * 获取下载语音信息(jpg)
	 *
	 * @param mediaId 文件的id
	 * @throws Exception
	 */
	public String saveVoiceToDisk(String mediaId,String wechat_appid) throws Exception {
		// 文件保存的临时路径
		String tempPath = upload_temp_path + File.separator;
		// 拼接年月日路径
		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
		// 重命名文件
		String fileBase =  DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000);
		String newFileName = fileBase+ ".amr";
		String mp3FileName  = fileBase + ".mp3";
		// 保存路径
		File uploadFile = new File(tempPath + datePath + newFileName);
		
		InputStream inputStream = null;
		FileOutputStream fileOutputStream = null;
		try {
			if (!uploadFile.getParentFile().exists()) {
				uploadFile.getParentFile().mkdirs();
			}
			inputStream = getInputStream(mediaId,wechat_appid);
			byte[] data = new byte[1024];
			int len = 0;
			fileOutputStream = new FileOutputStream(uploadFile);
			while ((len = inputStream.read(data)) != -1) {
				fileOutputStream.write(data, 0, len);
			}
			String amrFilePath = tempPath+datePath+newFileName;
			String Mp3FilePath = tempPath+datePath+mp3FileName;
			fileUtil.changeToMp3(amrFilePath,Mp3FilePath);
			// 返回保存路径
			return Mp3FilePath;
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (fileOutputStream != null) {
				try {
					fileOutputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return null;
	}
	
	/**
	 * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
	 *
	 * @return
	 */
	public InputStream getInputStream(String mediaId,String wechat_appid) {
		String accessToken = wxAccessTokenService.getWxAccessTokenById(wechat_appid).getAccessToken();
		InputStream is = null;
		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
		try {
			URL urlGet = new URL(url);
			HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
			http.setRequestMethod("GET"); // 必须是get方式请求
			http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
			http.setDoOutput(true);
			http.setDoInput(true);
			System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒
			System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒
			http.connect();
			// 获取文件转化为byte流
			is = http.getInputStream();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return is;
	}
	
	/**
	 * 获取微信服务器图片
	 * @param wechat_appid 微信公众号appid
	 * @return
	 */
	public String fetchWxImages(String wechat_appid) {
		String photos = "";
		try {
			String images = request.getParameter("mediaIds");
			if (org.apache.commons.lang3.StringUtils.isEmpty(images)) {
				return photos;
			}
			String[] mediaIds = images.split(",");
			for (String mediaId : mediaIds) {
				if (org.apache.commons.lang3.StringUtils.isEmpty(mediaId)) {
					continue;
				}
				String temp = saveImageToDisk(mediaId,wechat_appid);
				if (org.apache.commons.lang3.StringUtils.isNotEmpty(temp)) {
					if (photos.length() == 0) {
						photos = temp;
					} else {
						photos += "," + temp;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
//			error(e);
		}
		return photos;
	}
	
	/**
	 * 获取下载图片信息(jpg)
	 *
	 * @param mediaId 文件的id
	 * @param wechat_appid 微信appid
	 * @throws Exception
	 */
	public String saveImageToDisk(String mediaId,String wechat_appid) throws Exception {
		// 文件保存的临时路径
		String tempPath = upload_temp_path + File.separator;
		// 拼接年月日路径
		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
		// 重命名文件
		String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".png";
		// 保存路径
		File uploadFile = new File(tempPath + datePath + newFileName);
		
		InputStream inputStream = null;
		FileOutputStream fileOutputStream = null;
		try {
			if (!uploadFile.getParentFile().exists()) {
				uploadFile.getParentFile().mkdirs();
			}
			inputStream = getInputStream(mediaId,wechat_appid);
			byte[] data = new byte[1024];
			int len = 0;
			fileOutputStream = new FileOutputStream(uploadFile);
			while ((len = inputStream.read(data)) != -1) {
				fileOutputStream.write(data, 0, len);
			}
			// 生成缩略图
			ImageCompress.compress(uploadFile.getAbsolutePath(), uploadFile.getAbsolutePath() + "_small", 300, 300);
			// 返回保存路径
			return datePath + newFileName;
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (fileOutputStream != null) {
				try {
					fileOutputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return null;
	}
	
	/**
	 * 患者端
	 * 发起专家咨询
	 * @param ct      专家咨询对象
	 * @param patient 患者标识
	 * @return
	 * @throws Exception
	 */
	public JSONObject addTeamConsult(ConsultTeamDo ct, String patient, String doctor) throws Exception {
		JSONObject re = new JSONObject();
		if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor))) {//判断是否有未结束的咨询移到同步方法中
//			re.put("status", -3);
//			return re;
			throw new RuntimeException("居民还有未结束的专家咨询!");
		}
		
		JSONObject users = new JSONObject();
		users.put(doctor,0);
		
		// 设置患者信息
		ct.setPatient(patient);
		// 查询患者信息
		BasePatientDO tempPatient = basePatientDao.findById(patient);
		// 设置患者姓名
		ct.setName(tempPatient.getName());
		// 设置患者生日
		ct.setBirthday(tempPatient.getBirthday());
		//新增性别
		ct.setSex(tempPatient.getSex());
		// 设置患者头像
		ct.setPhoto(tempPatient.getPhoto());
		// 设置操作日期
		ct.setCzrq(new Date());
		ct.setDel("1");
		ct.setStatus(0);
		ct.setEvaluate(0);
		// 医生未读数量为1
		ct.setDoctorRead(1);
		// 添加咨询记录
		ConsultDo consult = addConsult(ct.getPatient(), "专家咨询", ct.getSymptoms(), ct.getImages(), ct.getType());
//		// 设置关联指导
//		consult.setGuidance(ct.getGuidance());
		// 设置咨询标识
		ct.setConsult(consult.getId());
		
		//推送给IM去创建议题,取得成员消息
		JSONObject messages = imUtil.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages(), doctor);
		users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
		JSONObject obj = imUtil.createTopics(patient + "_" + doctor + "_" + ct.getType(), consult.getId(), tempPatient.getName(), users, messages, imUtil.SESSION_TYPE_MUC);
		if (obj == null) {
			throw new RuntimeException("IM消息发送异常!");
		}
		if (obj.getInteger("status") == -1) {//im议题创建失败
			throw new RuntimeException(obj.getString("message"));
		}
		ct.setStartMsgId(obj.get("start_msg_id").toString());
		consultTeamDao.save(ct);
		consultDao.save(consult);
		
		JSONArray doctors = new JSONArray();
		for (String key : users.keySet()) {
			if (patient.equals(key)) {
				continue;
			}
			doctors.add(key);
			//记录咨询的医生详情误删
			ConsultTeamDoctorDo cd = new ConsultTeamDoctorDo();
			cd.setConsult(consult.getId());
			cd.setDel("1");
			cd.setCzrq(new Date());
			cd.setTo(key);
			consultTeamDoctorDao.save(cd);
		}
		
		// 保存医生咨询信息
		// 添加咨询转发记录
		// 添加医生咨询日志
		String content = addLogs(ct);
		re.put("doctor", doctor);
		re.put("status", 1);
		return re;
		
	}
	
	/**
	 * 添加一条咨询记录
	 * @param patient 患者信息
	 * @param title 咨询标题
	 * @param type 咨询类型:9在线复诊,13专家咨询
	 * @return
	 */
	public ConsultDo addConsult(String patient, String title, String symptoms, String images, int type) {
		ConsultDo consult = new ConsultDo();
		consult.setId(UUID.randomUUID().toString().replaceAll("-", ""));
		consult.setCzrq(new Date());
		consult.setDel("1");
		consult.setPatient(patient);
		consult.setTitle(title);
		consult.setSymptoms(symptoms);
		consult.setImages(images);
		consult.setType(type);
		return consultDao.save(consult);
	}
	
	/**
	 * 添加咨询日志
	 *
	 * @param ct
	 * @throws Exception
	 */
	private String addLogs(ConsultTeamDo ct) throws Exception {
		List<ConsultTeamLogDo> logs = new ArrayList<ConsultTeamLogDo>();
		// 添加问题咨询日志
		String content = "";
		
		content += "咨询问题:" + (org.apache.commons.lang3.StringUtils.isEmpty(ct.getSymptoms()) ? "无" : ct.getSymptoms());
		
		// 生成提问日志,并推送相关消息
		ConsultTeamLogDo infoLog = new ConsultTeamLogDo();
		infoLog.setConsult(ct.getConsult());
		if (content.length() > 2500) {
			content = content.substring(0, 2500);
		}
		infoLog.setContent(content);
		infoLog.setDel("1");
		infoLog.setType(0);
		infoLog.setChatType(1);
		infoLog.setCzrq(new Date());
		logs.add(infoLog);
		// 图片日志
		if (org.apache.commons.lang3.StringUtils.isNotEmpty(ct.getImages())) {
			String[] images = ct.getImages().split(",");
			for (String image : images) {
				if (org.apache.commons.lang3.StringUtils.isNoneEmpty(image)) {
					ConsultTeamLogDo imgLog = new ConsultTeamLogDo();
					// 设置咨询标识
					imgLog.setConsult(ct.getConsult());
					// 设置图片URL
					imgLog.setContent(image);
					imgLog.setDel("1");
					infoLog.setType(0);
					imgLog.setCzrq(new Date());
					// 图片类型
					imgLog.setChatType(2);
					// 添加到待保存队列
					logs.add(imgLog);
				}
			}
		}
		// 语音日志
		if (org.apache.commons.lang3.StringUtils.isNotEmpty(ct.getVoice())) {
			ConsultTeamLogDo voiceLog = new ConsultTeamLogDo();
			// 设置咨询标识
			voiceLog.setConsult(ct.getConsult());
			// 设置语音URL
			voiceLog.setContent(ct.getVoice());
			voiceLog.setDel("1");
			infoLog.setType(0);
			// 语音类型
			voiceLog.setChatType(3);
			voiceLog.setCzrq(new Date());
			// 添加到待保存队列
			logs.add(voiceLog);
		}
		if (!logs.isEmpty()) {
			Iterable<ConsultTeamLogDo> iterable = consultTeamLogDao.save(logs);
			if (iterable == null || iterable.iterator() == null || !iterable.iterator().hasNext()) {
				// 日志保存失败
				throw new Exception("consult team log save failed!");
			}
		}
		// 患者提问或追问,给医生发消息
		// sendMessage(ct.getDoctor(), ct.getPatient(), "三师咨询", "您有新的三师咨询消息", ct.getConsult(), 116, 1, 0, 0);
		return content;
	}
	
	/**
	 * 添加续方咨询
	 *
	 * @param outpatientCode
	 * @param patient
	 * @param agent
	 * @param doctorCode
	 * @param reason
	 * @return
	 */
	public JSONObject addPrescriptionConsult(String outpatientCode, String patient,String doctorCode, ConsultTeamDo ct, String reason, Integer type) throws Exception {
		
		synchronized (outpatientCode.intern()) {
			/**
			 * toto 判断是否存在未审核的复诊
			 */
//			String check = prescriptionInfoService.presCheckState(jwCode);
//			if ("0".equals(check)) {//存在未审核的续方
//				return -1;
//			}
			
			
			BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode);
//			doctorCode = doctor.getCode();
			// 查询患者信息
			BasePatientDO p = basePatientDao.findById(patient);
			
			//1、获取his就诊记录详情(保存续方表、药品续方信息表、续方疾病类型表)
			WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outpatientCode);
			
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("title", p.getName() + "申请复诊");
			
			
			String content = jsonObject.toString();
			
			//4、创建咨询
			JSONObject users = new JSONObject();//咨询参与者
			users.put(patient, 0);
			users.put(doctorCode, 0);
			//关联业务code
			ct.setRelationCode(outpatientCode);
			//医生信息
			ct.setDoctor(doctorCode);
			ct.setDoctorName(doctor.getName());
			// 设置患者信息
			ct.setPatient(patient);
//			if (1 == type) {
//				ct.setSymptoms("高血压");
//			} else if (2 == type) {
//				ct.setSymptoms("糖尿病");
//			} else if (3 == type) {
//				ct.setSymptoms("高血压,糖尿病");
//			} else {
//			}
			
			// 设置患者姓名
			ct.setName(p.getName());
			// 设置患者生日
			ct.setBirthday(p.getBirthday());
			//新增性别
			ct.setSex(p.getSex());
			// 设置患者头像
			ct.setPhoto(p.getPhoto());
			// 设置操作日期
			ct.setCzrq(new Date());
			ct.setDel("1");
			ct.setStatus(0);
			ct.setEvaluate(0);
			// 医生未读数量为1
			ct.setDoctorRead(1);
			// 添加咨询记录
			ConsultDo consult = addConsult(ct.getPatient(), "申请复诊", ct.getSymptoms(), ct.getImages(), ct.getType());
			// 设置关联指导
			consult.setGuidance(ct.getGuidance());
			//关联业务code
			consult.setRelationCode(outpatientCode);
			// 设置咨询标识
			ct.setConsult(consult.getId());
			
			//推送给IM去创建议题,取得成员消息
			JSONObject messages = imUtil.getCreateTopicMessage(doctorCode, doctor.getName(), consult.getTitle(), content, consult.getImages(), patient);
			
			//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+咨询类型(图文,视频,图文+视频)
			String sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
			JSONObject obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION);
			if (obj == null) {
				throw new RuntimeException("IM消息发送异常!");
			}
			if (obj.getInteger("status") == -1) {//im议题创建失败
				throw new RuntimeException(obj.getString("message"));
			}
			ct.setStartMsgId(obj.get("start_msg_id").toString());
			consultTeamDao.save(ct);
			consultDao.save(consult);
			
			//设置咨询code
//			wlyyOutpatientDO.setConsult(consult.getCode());
//			prescriptionDao.save(prescription);
			
			//6、记录咨询的医生详情
			ConsultTeamDoctorDo cd = new ConsultTeamDoctorDo();
			cd.setConsult(consult.getId());
			cd.setDel("1");
			cd.setCzrq(new Date());
			cd.setTo(doctorCode);
			consultTeamDoctorDao.save(cd);
			
			//7、发送系统消息提示团队长有未审核的消息
//			addCheckMessage(prescription, sessionId, p);
			
			//8、 保存医生咨询信息
			// 添加咨询转发记录
			// 添加医生咨询日志
			addLogs(ct);
			
			JSONObject result = imUtil.getSingleSessionInfo(sessionId,doctorCode);
			
			return result;
		}
	}
	
	
	/**
	 * 居民结束咨询
	 * @param consult 咨询CODE
	 * @param endOperator 操作人
	 * @param endType 1居民 2医生
	 * @return
	 */
	public int finish(String consult, String endOperator, int endType) {
		
		ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
		
		ConsultDo cons = consultDao.findOne(consult);
		
		if (consultTeam.getStatus() == 1) {
			return -1;
		}
		
		String endName = "";
		String endId = "";
		JSONObject obj = new JSONObject();
		//结束咨询才发送推送给IM文字消息
		if (endType == 1) {
			BasePatientDO p = basePatientDao.findById(endOperator);
			endName = p.getName();
			endId = p.getId();
			obj = imUtil.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
		} else {
			BaseDoctorDO d = baseDoctorDao.findById(endOperator);
			if (endOperator.equals("admin")) {
				endId = "system";
				endName = "咨询超时未回复,系统自动";
			} else {
				endId = d.getId();
				endName = d.getName();
			}
			obj = imUtil.endTopics(consultTeam.getDoctor(), endId, d.getName(), consultTeam.getConsult());
		}
		
		
		if (obj == null) {
			throw new RuntimeException("IM消息结束异常!");
		}
		if (obj.getInteger("status") == -1) {
			throw new RuntimeException(String.valueOf(obj.get("message")));
		}
		
		String name = "";
		String returnJson = "";
		//推送给IM文字消息
//		if (endType == 1) {
//			BasePatientDO p = basePatientDao.findById(endOperator);
//			name = p.getName();
//			returnJson = imUtil.sendIM(consultTeam.getPatient(), consultTeam.getDoctor(), "7", name + "结束了本次咨询");
//		} else {
//			BaseDoctorDO d = baseDoctorDao.findById(endOperator);
//			name = d.getName();
//			returnJson = imUtil.sendIM(consultTeam.getDoctor(), consultTeam.getPatient(), "7", name + "结束了本次咨询");
//		}
		
//		if (org.apache.commons.lang3.StringUtils.isEmpty(returnJson)) {
//			throw new RuntimeException("send consult finished IM message failed!");
////			throw new Exception("send consult finished IM message failed");
//		} else {
//			JSONObject jo = JSON.parseObject(returnJson);            //设置消息ID
//			consultTeam.setEndMsgId(jo.getInteger("startId") + "");
//			consultTeam.setEndOperator(endOperator);
//			consultTeam.setEndType(endType);
//		}
		
//		org.json.JSONObject group = talkGroupService.findConsultTalkGroup(consultTeam.getConsult());
//
//		if (group != null) {
//			String json = sendGroupIM(endOperator, group.getString("code"), "7", name + "结束了本次咨询");
//
//			if (org.apache.commons.lang3.StringUtils.isEmpty(json)) {
//				throw new Exception("send consult finished IM message failed");
//			}
//		}
		
		consultTeam.setEndMsgId(obj.getString("id"));
		cons.setEndTime(new Date());
		consultTeam.setEndTime(new Date());
		consultTeam.setStatus(1);
		consultDao.save(cons);
		consultTeamDao.save(consultTeam);
		return 1;
	}
	
	/**
	 * 根据咨询CODE获取session_id
	 * @param consult
	 * @return
	 */
	public JSONObject getTopic(String consult) throws Exception {
		
		return imUtil.getTopic(consult);
	}
	
	
	/**
	 * 获取咨询问题,图片,居民信息
	 * @param consult
	 * @param patientCode
	 * @return
	 */
	public JSONObject getConsultInfoAndPatientInfo(String consult,String patientCode) {
		BasePatientDO basePatientDO = basePatientDao.findById(patientCode);
		ConsultDo consultDo = consultDao.findOne(consult);
		JSONObject result = new JSONObject();
		
		JSONObject patientinfoObj = new JSONObject();
		patientinfoObj.put("name",basePatientDO.getName());
		patientinfoObj.put("sex",basePatientDO.getSex());
		patientinfoObj.put("mobile",basePatientDO.getMobile());
		patientinfoObj.put("address",basePatientDO.getAddress());
		Integer age = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
		patientinfoObj.put("age",age);
		result.put("patientInfo",patientinfoObj);
		result.put("consultDo",consultDo);
		return result;
	}
	
	
	/**
	 * 根据复诊记录获取咨询CODE
	 * @param outpatientid
	 * @return
	 */
	public String getConsultCodeByOutpatientId(String outpatientid) {
		String totalSql = "SELECT id FROM wlyy_consult WHERE relation_code='"+outpatientid+"'";
		List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
		String id = "";
		if (rstotal != null && rstotal.size() > 0) {
			id = rstotal.get(0).get("id").toString();
		}
		return id;
	}
}

+ 309 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/HttpClientUtil.java

@ -0,0 +1,309 @@
package com.yihu.jw.im.util;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
 * IM http 工具类
 * @author huangwenjie
 */
public class HttpClientUtil {
	/**
	 * 发送post请求
	 *
	 * @param url     请求地址
	 * @param params  请求参数
	 * @param chatSet 编码格式
	 * @return
	 */
	public  String post(String url, List<NameValuePair> params, String chatSet) {
		// 创建默认的httpClient实例.
		CloseableHttpClient httpclient = HttpClients.createDefault();
		// 创建httppost
		HttpPost httppost = new HttpPost(url);
		UrlEncodedFormEntity uefEntity;
		try {
			uefEntity = new UrlEncodedFormEntity(params, chatSet);
			httppost.setEntity(uefEntity);
			CloseableHttpResponse response = httpclient.execute(httppost);
			try {
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	
	
	/**
	 * 发送get请求
	 *
	 * @param url     请求地址
	 * @param chatSet 编码格式
	 * @return
	 */
	public  String get(String url, String chatSet) {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		try {
			// 创建httpget.
			HttpGet httpget = new HttpGet(url);
			// 执行get请求.
			CloseableHttpResponse response = httpclient.execute(httpget);
			try {
				// 获取响应实体
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	
	/**
	 * http调用方法,(健康之路开放平台)
	 *
	 * @param url
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public  String httpPost(String url, Map<String, String> params) throws Exception {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(60000).setConnectTimeout(60000).build();//设置请求和传输超时时间
		
		try {
			HttpPost httpPost = new HttpPost(url);
			httpPost.setConfig(requestConfig);
			if (params != null && params.size() > 0) {
				List<NameValuePair> valuePairs = new ArrayList<NameValuePair>(params.size());
				for (Map.Entry<String, String> entry : params.entrySet()) {
					NameValuePair nameValuePair = new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue()));
					valuePairs.add(nameValuePair);
				}
				UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(valuePairs, "UTF-8");
				httpPost.setEntity(formEntity);
			}
			CloseableHttpResponse resp = httpclient.execute(httpPost);
			try {
				HttpEntity entity = resp.getEntity();
				String respContent = EntityUtils.toString(entity, "UTF-8").trim();
				return respContent;
			} finally {
				resp.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
			return e.getMessage();
		} finally {
			httpclient.close();
		}
	}
	
	/**
	 * 获取加密后参数集合(健康之路开放平台)
	 *
	 * @param params
	 * @return
	 */
	public  Map<String, String> getSecretParams(Map<String, String> params, String appId, String secret) {
		String timestamp = Long.toString(System.currentTimeMillis());
		params.put("timestamp", timestamp);
		StringBuilder stringBuilder = new StringBuilder();
		
		// 对参数名进行字典排序  
		String[] keyArray = params.keySet().toArray(new String[0]);
		Arrays.sort(keyArray);
		// 拼接有序的参数名-值串  
		stringBuilder.append(appId);
		for (String key : keyArray) {
			stringBuilder.append(key).append(params.get(key));
		}
		String codes = stringBuilder.append(secret).toString();
		String sign = org.apache.commons.codec.digest.DigestUtils.shaHex(codes).toUpperCase();
		// 添加签名,并发送请求  
		params.put("appId", appId);
		params.put("sign", sign);
		
		return params;
	}
	
	
	public  String postBody(String url, JSONObject params) {
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		String ret = restTemplate.postForObject(url, formEntity, String.class);
		return ret;
	}
	
	public  void putBody(String url, JSONObject params) {
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		restTemplate.put(url, formEntity, String.class);
	}
	
	
	/**
	 * 发送post请求
	 *
	 * @param url     请求地址
	 * @param params  请求参数
	 * @return
	 */
	public String iotPostBody(String url, String params) {
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params, headers);
		String ret = restTemplate.postForObject(url, formEntity, String.class);
		return ret;
	}
	/**
	 * 发送post请求
	 *
	 * @param url     请求地址
	 * @param params  请求参数
	 * @param chatSet 编码格式
	 * @param headerMap 请求头
	 * @return
	 */
	public  String headerPost(String url, List<NameValuePair> params, String chatSet,Map<String,Object> headerMap) {
		// 创建默认的httpClient实例.
		CloseableHttpClient httpclient = HttpClients.createDefault();
		// 创建httppost
		HttpPost httppost = new HttpPost(url);
		UrlEncodedFormEntity uefEntity;
		try {
			uefEntity = new UrlEncodedFormEntity(params, chatSet);
			httppost.setEntity(uefEntity);
			for(String str:headerMap.keySet()){
				httppost.addHeader(str,headerMap.get(str).toString());
			}
			CloseableHttpResponse response = httpclient.execute(httppost);
			try {
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	
	public  String get(String url, String chatSet,Map<String,Object> headerMap) {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		try {
			// 创建httpget.
			url= url.replaceAll(" ", "%20");
			HttpGet httpget = new HttpGet(url);
			for(String str:headerMap.keySet()){
				httpget.addHeader(str,headerMap.get(str).toString());
			}
			// 执行get请求.
			CloseableHttpResponse response = httpclient.execute(httpget);
			try {
				// 获取响应实体
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
}

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

@ -0,0 +1,680 @@
package com.yihu.jw.im.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.yihu.jw.util.http.HttpClientUtil;
import java.util.ArrayList;
import java.util.List;
/**
 * IM工具类
 * @author huangwenjie
 */
@Component
public class ImUtil {
	
	@Autowired
	private HttpClientUtil HttpClientUtil;
	
	@Value("${im.im_list_get}")
	private String im_host;
	
	
	public enum ContentType {
		plainText("信息", "1"),
		image("图片信息", "2"),
		audio("创建处方", "3"),
		article("文章信息", "4"),
		goTo("跳转信息,求组其他医生或者邀请其他医生发送的推送消息", "5"),
		topicBegin("议题开始", "6"),
		topicEnd("议题结束", "7"),
		personalCard("个人名片", "18"),
		messageForward("消息转发", "19"),
		topicInto("进入议题", "14"),
		video("视频", "12"),
		system("系统消息", "13"),
		prescriptionCheck("续方审核消息消息", "15"),
		prescriptionBloodStatus("续方咨询血糖血压咨询消息", "16"),
		prescriptionFollowupContent("续方咨询随访问卷消息", "17"),
		Rehabilitation("康复计划发送","20"),
		Reservation("转诊预约发送","21"),
		Know("已知悉","22");
		
		private String name;
		private String value;
		ContentType(String name, String value) {
			this.name = name;
			this.value = value;
		}
		
		public String getName() {
			return name;
		}
		
		public void setName(String name) {
			this.name = name;
		}
		
		public String getValue() {
			return value;
		}
		
		public void setValue(String value) {
			this.value = value;
		}
	}
	
	/**
	 * 发送消息
	 * @param senderId 发送者的code
	 * @param receiverId 接受者code
	 * @param contentType 消息类型 1二维码内容
	 * @param content 消息内容
	 * @return
	 */
	public String sendMessage(String senderId,String receiverId,String contentType,String content){
		String imAddr = im_host + "api/v2/message/send";
		JSONObject params = new JSONObject();
		params.put("sender_id", senderId);
		params.put("sender_name", receiverId);
		params.put("content_type", contentType);
		params.put("content", content);
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	
	/**
	 * 获取医生统计数据
	 * status reply 为空值是是该医生总咨询量
	 *
	 * @param user          团队就把团队的医生合并起来用,隔开(医生编码)
	 * @param adminTeamCode
	 * @param status
	 * @param reply
	 * @return
	 */
	public String getConsultData(String user, Integer adminTeamCode, Integer status, Integer reply) {
		String imAddr = im_host + "api/v2/sessions/topics/count/reply";
		imAddr = imAddr + "?user=" + user;
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (adminTeamCode != null) {
			imAddr += ("&adminTeamCode=" + adminTeamCode);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	public void updateTopics(String topicId, String jsonValue) {
		String imAddr = im_host + "api/v2/sessions/" + topicId + "/topics";
		JSONObject params = new JSONObject();
		params.put("topic_id", topicId);
		params.put("data", jsonValue);
		HttpClientUtil.putBody(imAddr, params);
	}
	
	/**
	 * 当前医生下当前团队列表接口
	 * 获取团队内医生的健康咨询状况
	 * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
	 *
	 * @param user          团队就把团队的医生合并起来用,隔开(医生编码)
	 * @param adminTeamCode 行政团队code
	 * @param page
	 * @param pagesize
	 * @param status
	 * @param reply
	 * @return
	 */
	public String getTeamConsultByStatus(String user, Integer adminTeamCode, Integer status, Integer reply, int page, int pagesize) {
		String imAddr = im_host + "api/v2/sessions/healthTeamTopics";
		imAddr = imAddr + "?user=" + user + "&page=" + page + "&pagesize=" + pagesize;
		if (adminTeamCode != null) {
			imAddr += ("&adminTeamCode=" + adminTeamCode);
		}
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	/**
	 * 列表接口
	 * 获取团队内医生的健康咨询状况
	 * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
	 *
	 * @param user     团队就把团队的医生合并起来用,隔开(医生编码)
	 * @param page
	 * @param pagesize
	 * @param status
	 * @param reply
	 * @return
	 */
	public String getConsultByStatus(String user, Integer status, Integer reply, int page, int pagesize) {
		String imAddr = im_host + "api/v2/sessions/healthTopics";
		imAddr = imAddr + "?user=" + user + "&page=" + page + "&pagesize=" + pagesize;
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	/**
	 * 咨询列表
	 * @param user
	 * @param status status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
	 * @param reply
	 * @param type 1、三师咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询 10医生发起的求助
	 * @param page
	 * @param pagesize
	 * @return
	 */
	public String getConsultByStatusAndType(String user,Integer status,Integer reply,Integer type,String patientName,String startTime,String endTime,int page,int pagesize){
		String imAddr = im_host + "api/v2/sessions/topicListByType";
		imAddr = imAddr + "?user="+user + "&page=" + page + "&pagesize=" + pagesize;
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		if (type != null) {
			imAddr += ("&type=" + type);
		}
		if (patientName != null) {
			imAddr += ("&patientName=" + patientName);
		}
		if (startTime != null) {
			imAddr += ("&startTime=" + startTime);
		}
		if (endTime != null) {
			imAddr += ("&endTime=" + endTime);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	/**
	 * 咨询列表总数
	 * @param user
	 * @param status status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
	 * @param reply
	 * @param type 1、三师咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询 10医生发起的求助
	 * @return
	 */
	public String getConsultCountByStatusAndType(String user,Integer status,Integer reply,Integer type,String patientName,String startTime,String endTime){
		String imAddr = im_host + "api/v2/sessions/topicListCountByType";
		imAddr = imAddr + "?user="+user;
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		if (type != null) {
			imAddr += ("&type=" + type);
		}
		if (patientName != null) {
			imAddr += ("&patientName=" + patientName);
		}
		if (startTime != null) {
			imAddr += ("&startTime=" + startTime);
		}
		if (endTime != null) {
			imAddr += ("&endTime=" + endTime);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendImMsg(String from, String fromName, String sessionId, String contentType, String content, String businessType) {
		String imAddr = im_host + "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);
		params.put("business_type", businessType);
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	
	/**
	 * 更新会话状态
	 *
	 * @param sessionId 会话ID
	 * @param status    状态
	 */
	public String updateSessionStatus(String sessionId, String status) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/status?status=" + status + "&sessionId=" + sessionId;
		JSONObject params = new JSONObject();
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	
	/**
	 * 更新会话状态
	 *
	 * @param sessionId 会话ID
	 * @param status    状态
	 */
	public String updateTopicEvaluate(String sessionId, String status) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/status?status=" + status + "&sessionId=" + sessionId;
		JSONObject params = new JSONObject();
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	
	
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendTopicIM(String from, String fromName, String topicId, String contentType, String content, String agent) {
		String url = im_host + "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);
		params.put("agent", agent);
		String response = HttpClientUtil.postBody(url, params);
		return response;
	}
	
	/**
	 * 发送进入im消息
	 * IM: ParticipantUpdate:'/:session_id/participant/update'
	 *
	 * @param from
	 * @param sessionId
	 * @param topicId
	 * @return
	 */
	public String sendIntoTopicIM(String from, String sessionId, String topicId, String content, String intoUser, String intoUserName) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/topics/" + topicId + "/into";
		JSONObject params = new JSONObject();
		params.put("sender_id", from);
		params.put("topic_id", topicId);
		params.put("into_user", intoUser);
		params.put("into_user_name", intoUserName);
		params.put("content", content);
		String response = HttpClientUtil.postBody(url, params);
		return response;
	}
	
	
	/**
	 * 更新会话成员(新增或删除)
	 * @param sessionId 会话id
	 * @param user 新增的成员id
	 * @param oldUserId  删除的成员id
	 */
	public String updateParticipant(String sessionId, String user,String oldUserId) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participant/update";
		JSONObject params = new JSONObject();
		params.put("session_id", sessionId );
		params.put("user_id", user );
		if(!StringUtils.isEmpty(oldUserId)){
			params.put("old_user_id", oldUserId);
		}
		return HttpClientUtil.postBody(imAddr, params);
	}
	
	/**
	 * 更新消息内容
	 * @param sessionId 会话id
	 * @param sessionType 会话类型
	 * @param msgId  消息id
	 * @param content  消息内容
	 */
	public String updateMessage(String sessionId, String sessionType,String msgId,String content) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/messages/"+ msgId +"/update";
		JSONObject params = new JSONObject();
		params.put("session_id", sessionId );
		params.put("session_type", sessionType );
		params.put("message_id", msgId );
		params.put("content", content );
		return HttpClientUtil.postBody(imAddr, params);
	}
	
	/**
	 * 结束议题
	 *
	 * @param topicId     议题ID
	 * @param endUser     结束人
	 * @param endUserName 结束人名字
	 * @param sessionId   会话ID
	 */
	public JSONObject endTopics(String sessionId, String endUser, String endUserName, String topicId) {
		String imAddr = im_host + "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 = JSON.parseObject(ret);
		} catch (Exception e) {
			return null;
		}
		return obj;
	}
	
	
	/**
	 * 议题邀请人员
	 *
	 * @param user      结束人名字
	 * @param sessionId 会话ID
	 */
	public void updateTopicUser(String sessionId, String user) {
		String imAddr = im_host + "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 JSONObject createTopics(String sessionId, String topicId, String topicName, JSONObject participants, JSONObject messages, String sessionType) {
		String imAddr = im_host + "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 = JSON.parseObject(ret);
		} catch (Exception e) {
			return null;
		}
		return obj;
	}
	
	/**
	 * 判断会话是否存在
	 */
	public Boolean sessionIsExist(String sessionId) {
		Boolean re = false;
		String url = im_host + "api/v2/sessions/isExist?session_id="+sessionId;
		JSONObject params = new JSONObject();
		String ret = HttpClientUtil.get(url, "UTF-8");
		JSONObject obj = null;
		try {
			obj = JSON.parseObject(ret);
			if(obj.getInteger("status") ==200&&sessionId.equals(obj.getString("sessionId"))){
				re = true;
			}
		} catch (Exception e) {
			return null;
		}
		return re;
	}
	
	/**
	 * 创建会话(system)
	 */
	public JSONObject createSession(JSONObject participants, String sessionType, String sessionName, String sessionId) {
		String imAddr = im_host + "api/v2/sessions";
		JSONObject params = new JSONObject();
		params.put("participants", participants.toString());
		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 = JSON.parseObject(ret);
		} catch (Exception e) {
			return null;
		}
		return obj;
	}
	
	/**
	 * 获取会话实例的消息对象
	 *
	 * @param senderId
	 * @param senderName
	 * @param title
	 * @param description
	 * @param images
	 * @param agent
	 * @return
	 */
	public JSONObject getCreateTopicMessage(String senderId, String senderName, String title, String description, String images, String agent) {
		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);
		messages.put("agent", agent);
		return messages;
	}
	
	public JSONObject getTopicMessage(String topicId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
		String url = im_host
				+ "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 = JSON.parseObject(ret);
			if (obj.getInteger("status") == -1) {
				throw new RuntimeException(obj.getString("message"));
			} else {
				return obj.getJSONObject("data");
			}
		} catch (Exception e) {
			return null;
		}
		
	}
	
	public JSONArray getSessionMessage(String sessionId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/messages?session_id=" + sessionId + "&user=" + uid + "&start_message_id=" + startMsgId + "&end_message_id=" + endMsgId + "&page=" + page + "&pagesize=" + pagesize;
		try {
			String ret = HttpClientUtil.get(url, "UTF-8");
			JSONArray obj = JSON.parseArray(ret);
			return obj;
		} catch (Exception e) {
			return null;
		}
		
	}
	
	/**
	 * 删除对应的成员信息在MUC模式中
	 *
	 * @param userId
	 * @param oldUserId
	 * @param sessionId
	 * @return
	 */
	public JSONObject deleteMucUser(String userId, String oldUserId, String sessionId) throws Exception {
		String url = im_host + "api/v2/sessions/" + sessionId + "/participant/update";
		try {
			JSONObject params = new JSONObject();
			params.put("user_id", userId);
			params.put("old_user_id", oldUserId);
			params.put("session_id", sessionId);
			String ret = HttpClientUtil.postBody(url, params);
			JSONObject obj = JSON.parseObject(ret);
			if (obj.getInteger("status") == -1) {
				throw new RuntimeException("人员更换失败!");
			} else {
				return obj;
			}
		} catch (Exception e) {
			throw new RuntimeException("人员更换失败!");
		}
	}
	
	
	/**
	 * 获取议题
	 *
	 * @param topicId
	 * @return
	 */
	public JSONObject getTopic(String topicId) throws Exception {
		String url = im_host + "api/v2/sessions/topics/" + topicId + "?topic_id=" + topicId;
		try {
			String ret = HttpClientUtil.get(url, "utf-8");
			JSONObject obj = JSON.parseObject(ret);
			if (obj.getInteger("status") == -1) {
				throw new RuntimeException("获取议题失败!");
			} else {
				return obj;
			}
		} catch (Exception e) {
			throw new RuntimeException("获取议题失败!");
		}
	}
	
	/**
	 * 获取会话成员
	 *
	 * @param sessionId
	 * @return
	 * @throws Exception
	 */
	public JSONArray getParticipants(String sessionId) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/participants?session_id=" + sessionId;
		try {
			String ret = HttpClientUtil.get(url, "utf-8");
			return JSON.parseArray(ret);
		} catch (Exception e) {
			throw new RuntimeException("获取会话成员!sessionId =" + sessionId);
		}
	}
	
	/**
	 * 获取会话成员
	 *
	 * @param sessionId
	 * @return
	 * @throws Exception
	 */
	public JSONArray getSessions(String sessionId) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/participants?session_id=" + sessionId;
		try {
			String ret = HttpClientUtil.get(url, "utf-8");
			return JSON.parseArray(ret);
		} catch (Exception e) {
			throw new RuntimeException("获取议题失败!");
		}
	}
	
	public JSONObject cleanMessageToRedis(String sessionId){
		String url = im_host + "api/v2/message/dataMessage?sessionId="+sessionId;
		try {
			String ret = HttpClientUtil.get(url,"utf-8");
			return JSON.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("操作失败!");
		}
	}
	
	public JSONObject cleanMessageLastFetchTime(String sessionId,String userId){
		String url = im_host + "api/v2/message/cleanMessageLastFetchTimeToRedis?sessionId="+sessionId+"&userId="+userId;
		try {
			String ret = HttpClientUtil.get(url,"utf-8");
			return JSON.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("操作失败!");
		}
	}
	
	/**
	 * 根据session和userid获取单个会话
	 * @param sessionId
	 * @param userId
	 * @return
	 */
	public JSONObject getSingleSessionInfo(String sessionId,String userId){
		String url = im_host + "api/v2/sessions/" + sessionId + "/session?user_id=" + userId;
		try {
			String ret = HttpClientUtil.get(url,"utf-8");
			return JSON.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("操作失败!");
		}
	}
	
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param to
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendIM(String from, String to, String contentType, String content) {
		String imAddr = im_host + "api/v1/chats/pm";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("from", from));
		params.add(new BasicNameValuePair("to", to));
		params.add(new BasicNameValuePair("contentType", contentType));
		params.add(new BasicNameValuePair("content", content));
		String response = HttpClientUtil.post(imAddr, params, "UTF-8");
		return response;
	}
	
	
	public static final String SESSION_TYPE_MUC = "1";
	public static final String SESSION_TYPE_P2P = "2";
	public static final String SESSION_TYPE_GROUP = "3";
	public static final String SESSION_TYPE_SYSTEM = "0";
	public static final String SESSION_TYPE_PRESCRIPTION = "8";//续方
	public static final String SESSION_TYPE_EXAMINATION = "9";//在线复诊
	public static final String SESSION_TYPE_ONDOOR_NURSING = "11";//上门护理
	public static final String SESSION_STATUS_PROCEEDINGS = "0";
	public static final String SESSION_STATUS_END = "1";
	
	public static final String CONTENT_TYPE_TEXT = "1";
}

+ 91 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/ImageCompress.java

@ -0,0 +1,91 @@
package com.yihu.jw.im.util;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/**
 * 图片压缩处理
 * @author huangwenjie
 */
public class ImageCompress {
	private Image img;
	private int width;
	private int height;
	
	/**
	 * 构造函数
	 */
	public ImageCompress(String fileName) throws IOException {
		File file = new File(fileName);// 读入文件
		img = ImageIO.read(file); // 构造Image对象
		width = img.getWidth(null); // 得到源图宽
		height = img.getHeight(null); // 得到源图长
	}
	
	/**
	 * 按照宽度还是高度进行压缩
	 * @param w int 最大宽度
	 * @param h int 最大高度
	 */
	public void resizeFix(int w, int h, File destFile) throws IOException {
		if (width / height > w / h) {
			resizeByWidth(w, destFile);
		} else {
			resizeByHeight(h, destFile);
		}
	}
	
	/**
	 * 以宽度为基准,等比例放缩图片
	 * @param w int 新宽度
	 */
	public void resizeByWidth(int w, File destFile) throws IOException {
		int h = (int) (height * w / width);
		resize(w, h, destFile);
	}
	
	/**
	 * 以高度为基准,等比例缩放图片
	 * @param h int 新高度
	 */
	public void resizeByHeight(int h, File destFile) throws IOException {
		int w = (int) (width * h / height);
		resize(w, h, destFile);
	}
	
	/**
	 * 强制压缩/放大图片到固定的大小
	 * @param w int 新宽度
	 * @param h int 新高度
	 */
	public void resize(int w, int h, File destFile) throws IOException {
		// SCALE_SMOOTH 的缩略算法 生成缩略图片的平滑度的 优先级比速度高 生成的图片质量比较好 但速度慢
		BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
		image.getGraphics().drawImage(img, 0, 0, w, h, null); // 绘制缩小后的图
		FileOutputStream out = new FileOutputStream(destFile); // 输出到文件流
		// 可以正常实现bmp、png、gif转jpg
		JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
		encoder.encode(image); // JPEG编码
		out.close();
	}
	
	/**
	 * 图片压缩
	 * @param source
	 * @param target
	 * @param width
	 * @param height
	 * @throws IOException
	 */
	public static void compress(String source, String target, int width, int height) throws IOException{
		ImageCompress imgCom = new ImageCompress(source);
		imgCom.resizeFix(width, height, new File(target));
	}
}

+ 120 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultDo.java

@ -0,0 +1,120 @@
package com.yihu.jw.entity.base.im;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 咨询表
 * @author huangwenjie
 */
@Entity
@Table(name = "wlyy_consult")
public class ConsultDo extends UuidIdentityEntity {
	// 患者标识
	private String patient;
	// 咨询类型:1三师咨询,2视频咨询,3图文咨询,4公共咨询,
	//          5病友圈 6、患者名医咨询 7医生名医咨询 8续方咨询
	//          9在线复诊咨询(居民直接咨询专家) 10医生发起的求助 11思明区上门服务在线咨询
	private Integer type;
	// 咨询标题/主诉
	private String title;
	// 主诉
	private String symptoms;
	// 咨询图片URL,多图以逗号分隔
	private String images;
	// 关联指导
	private Long guidance;
	// 咨询时间
	private Date czrq;
	// 作废标识,1正常,0作废
	private String del;
	// 结束时间
	private Date endTime;
	//关联业务表的code
	private String relationCode;
	
	public String getPatient() {
		return patient;
	}
	
	public void setPatient(String patient) {
		this.patient = patient;
	}
	
	public Integer getType() {
		return type;
	}
	
	public void setType(Integer type) {
		this.type = type;
	}
	
	public String getTitle() {
		return title;
	}
	
	public void setTitle(String title) {
		this.title = title;
	}
	
	public String getSymptoms() {
		return symptoms;
	}
	
	public void setSymptoms(String symptoms) {
		this.symptoms = symptoms;
	}
	
	public String getImages() {
		return images;
	}
	
	public void setImages(String images) {
		this.images = images;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getEndTime() {
		return endTime;
	}
	
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	
	public String getDel() {
		return del;
	}
	
	public void setDel(String del) {
		this.del = del;
	}
	
	public Long getGuidance() {
		return guidance;
	}
	public void setGuidance(Long guidance) {
		this.guidance = guidance;
	}
	
	public String getRelationCode() {
		return relationCode;
	}
	
	public void setRelationCode(String relationCode) {
		this.relationCode = relationCode;
	}
}

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

@ -0,0 +1,390 @@
package com.yihu.jw.entity.base.im;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * IM咨询扩展表
 * @author huangwenjie
 */
@Entity
@Table(name = "wlyy_consult_team")
public class ConsultTeamDo extends UuidIdentityEntity {
	
	private String consult;         // 咨询标识
	private String doctor;          // 医生标识
	private String team;            // 三师团队标识
	private Integer type;           //  1、三师咨询,2、家庭医生咨询,
	// 6、患者名医咨询 7医生名医咨询 8续方咨询 9在线复诊咨询(居民直接咨询专家)
	// 10医生发起的求助 11思明区上门服务在线咨询
	// 13、互联网医院专家咨询
	private String patient;         // 提问者标识
	private String name;            // 患者姓名
	private Integer sex;            // 患者性别
	private Date birthday;          // 患者生日
	private String photo;           // 患者头像
	private String when;            // 发病日期
	private String symptoms;        // 主要症状
	private Integer status;         // 咨询状态(0进行中,1已完成,-1患者取消,-2超时未响应自动关闭)
	private String images;          // 咨询图片URL,多图以逗号分隔
	private String voice;           // 咨询语音URL
	private String comment;         // 用户评价标识
	private String commentContent;  // 用户评价内容
	private Integer commentStar;    // 用户评价星级
	private Integer doctorRead;     // 医生未读数量
	private Integer patientRead;    // 患者未读数量
	private Date czrq;              // 咨询时间
	private String del;             // 作废标识,1正常,0作废
	private Long adminTeamId;//行政团队ID
	private Long guidance;   //关联指导
	private String doctorName;//醫生名字
	//起始消息id
	private String startMsgId;
	//结束消息id
	private String endMsgId;
	// 结束人
	private String endOperator;
	// 结束人类型
	private Integer endType;
	// 结束时间
	private Date endTime;
	//是否评价 1、已评价 0、未评价'
	private Integer evaluate;
	//评价时间
	private Date evaluateTime;
	
	private String relationCode;//关联业务表的code
	
	private Integer healthindexType;//体征数据上传发送IM消息:1血压 2血糖 3血压+血糖
	
	private Integer isRefinement;//是否加精(0未加精 1已加精)
	
	private Integer isAuthentication;//是否认证 0未认证 1已认证通过 2认证不通过
	
	private String authenticationHospital;//认证机构id
	
	private String authenticationHospitalName;//认证机构名称
	
	private String refinementCode;//wlyy_refinement_consult中唯一标识code
	
	public Integer getEvaluate() {
		return evaluate;
	}
	
	public void setEvaluate(Integer evaluate) {
		this.evaluate = evaluate;
	}
	
	public Date getEvaluateTime() {
		return evaluateTime;
	}
	
	public void setEvaluateTime(Date evaluateTime) {
		this.evaluateTime = evaluateTime;
	}
	
	@Column(name = "admin_team_code")
	public Long getAdminTeamId() {
		return adminTeamId;
	}
	
	public void setAdminTeamId(Long adminTeamId) {
		this.adminTeamId = adminTeamId;
	}
	
	public String getConsult() {
		return consult;
	}
	
	public void setConsult(String consult) {
		this.consult = consult;
	}
	
	public ConsultTeamDo() {
	}
	
	public String getDoctor() {
		return doctor;
	}
	
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	
	public String getTeam() {
		return team;
	}
	
	public void setTeam(String team) {
		this.team = team;
	}
	
	public Integer getType() {
		return type;
	}
	
	public void setType(Integer type) {
		this.type = type;
	}
	
	public String getPatient() {
		return patient;
	}
	
	public void setPatient(String patient) {
		this.patient = patient;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}
	
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	
	public String getPhoto() {
		return photo;
	}
	
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	
	@Column(name = "fbsj")
	public String getWhen() {
		return when;
	}
	
	public void setWhen(String when) {
		this.when = when;
	}
	
	public Integer getStatus() {
		return status;
	}
	
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public String getImages() {
		return images;
	}
	
	public void setImages(String images) {
		this.images = images;
	}
	
	public String getVoice() {
		return voice;
	}
	
	public void setVoice(String voice) {
		this.voice = voice;
	}
	
	public String getComment() {
		return comment;
	}
	
	public void setComment(String comment) {
		this.comment = comment;
	}
	
	@Column(name = "comment_content")
	public String getCommentContent() {
		return commentContent;
	}
	
	public void setCommentContent(String commentContent) {
		this.commentContent = commentContent;
	}
	
	@Column(name = "comment_star")
	public Integer getCommentStar() {
		return commentStar;
	}
	
	public void setCommentStar(Integer commentStar) {
		this.commentStar = commentStar;
	}
	
	@Column(name = "doctor_read")
	public Integer getDoctorRead() {
		return doctorRead;
	}
	
	public void setDoctorRead(Integer doctorRead) {
		this.doctorRead = doctorRead;
	}
	
	@Column(name = "patient_read")
	public Integer getPatientRead() {
		return patientRead;
	}
	
	public void setPatientRead(Integer patientRead) {
		this.patientRead = patientRead;
	}
	
	// 设定JSON序列化时的日期格式
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	// 设定JSON序列化时的日期格式
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	
	public String getSymptoms() {
		return symptoms;
	}
	
	public void setSymptoms(String symptoms) {
		this.symptoms = symptoms;
	}
	
	public String getDel() {
		return del;
	}
	
	public void setDel(String del) {
		this.del = del;
	}
	
	public Integer getSex() {
		return sex;
	}
	
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	@Transient
	public String getDoctorName() {
		return doctorName;
	}
	
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	
	public Long getGuidance() {
		return guidance;
	}
	public void setGuidance(Long guidance) {
		this.guidance = guidance;
	}
	
	
	public String getStartMsgId() {
		return startMsgId;
	}
	
	public void setStartMsgId(String startMsgId) {
		this.startMsgId = startMsgId;
	}
	
	public String getEndMsgId() {
		return endMsgId;
	}
	
	public void setEndMsgId(String endMsgId) {
		this.endMsgId = endMsgId;
	}
	
	public String getEndOperator() {
		return endOperator;
	}
	public void setEndOperator(String endOperator) {
		this.endOperator = endOperator;
	}
	
	public Integer getEndType() {
		return endType;
	}
	public void setEndType(Integer endType) {
		this.endType = endType;
	}
	
	public String getRelationCode() {
		return relationCode;
	}
	
	public void setRelationCode(String relationCode) {
		this.relationCode = relationCode;
	}
	
	public Integer getHealthindexType() {
		return healthindexType;
	}
	
	public void setHealthindexType(Integer healthindexType) {
		this.healthindexType = healthindexType;
	}
	
	public Integer getIsRefinement() {
		return isRefinement;
	}
	
	public void setIsRefinement(Integer isRefinement) {
		this.isRefinement = isRefinement;
	}
	
	public Integer getIsAuthentication() {
		return isAuthentication;
	}
	
	public void setIsAuthentication(Integer isAuthentication) {
		this.isAuthentication = isAuthentication;
	}
	
	public String getAuthenticationHospital() {
		return authenticationHospital;
	}
	
	public void setAuthenticationHospital(String authenticationHospital) {
		this.authenticationHospital = authenticationHospital;
	}
	
	public String getAuthenticationHospitalName() {
		return authenticationHospitalName;
	}
	
	public void setAuthenticationHospitalName(String authenticationHospitalName) {
		this.authenticationHospitalName = authenticationHospitalName;
	}
	
	public String getRefinementCode() {
		return refinementCode;
	}
	
	public void setRefinementCode(String refinementCode) {
		this.refinementCode = refinementCode;
	}
}

+ 90 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDoctorDo.java

@ -0,0 +1,90 @@
package com.yihu.jw.entity.base.im;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * @author 三师咨询转接给的医生记录对象
 * @date 2019/6/19 11:10
 */
@Entity
@Table(name = "wlyy_consult_team_doctor")
public class ConsultTeamDoctorDo extends UuidIdentityEntity {
	// 三师咨询标识
	private String consult;
	// 医生标
	private String from;
	// 转出医生姓名
	private String fromName;
	// 替回答的医生标识
	private String to;
	// 是否有回复过
	private int reply;
	// 咨询时间
	private Date czrq;
	// 作废标识,1正常,0作废
	private String del;
	
	public String getConsult() {
		return consult;
	}
	
	public void setConsult(String consult) {
		this.consult = consult;
	}
	
	@Column(name = "form_doctor")
	public String getFrom() {
		return from;
	}
	
	public void setFrom(String from) {
		this.from = from;
	}
	
	@Column(name = "form_doctor_name")
	public String getFromName() {
		return fromName;
	}
	
	public void setFromName(String fromName) {
		this.fromName = fromName;
	}
	
	@Column(name = "to_doctor")
	public String getTo() {
		return to;
	}
	
	public void setTo(String to) {
		this.to = to;
	}
	
	public int getReply() {
		return reply;
	}
	
	public void setReply(int reply) {
		this.reply = reply;
	}
	
	public Date getCzrq() {
		return czrq;
	}
	
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	public String getDel() {
		return del;
	}
	
	public void setDel(String del) {
		this.del = del;
	}
}

+ 115 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamLogDo.java

@ -0,0 +1,115 @@
package com.yihu.jw.entity.base.im;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 咨询日志表
 * @author huangwenjie
 */
@Entity
@Table(name = "wlyy_consult_team_log")
public class ConsultTeamLogDo extends UuidIdentityEntity {
	// 咨询标识
	private String consult;
	// 回复医生标识
	private String doctor;
	// 回复医生姓名
	private String doctorName;
	// 回复人头像
	private String photo;
	// 回复内容/追问内容
	private String content;
	// 类型,0问,1回复,2追问,3评价
	private Integer type;
	// 记录类型:1文字,2图片,3语音
	private Integer chatType;
	// 操作时间
	private Date czrq;
	// 作废标识,1正常,0作废
	private String del;
	
	public ConsultTeamLogDo() {
	
	}
	
	public String getConsult() {
		return consult;
	}
	
	public void setConsult(String consult) {
		this.consult = consult;
	}
	
	public String getContent() {
		return content;
	}
	
	public void setContent(String content) {
		this.content = content;
	}
	
	public Integer getType() {
		return type;
	}
	
	public void setType(Integer type) {
		this.type = type;
	}
	
	@Column(name = "chat_type")
	public Integer getChatType() {
		return chatType;
	}
	
	public void setChatType(Integer chatType) {
		this.chatType = chatType;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	
	public String getDoctor() {
		return doctor;
	}
	
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	
	@Column(name = "doctor_name")
	public String getDoctorName() {
		return doctorName;
	}
	
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	
	public String getPhoto() {
		return photo;
	}
	
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	public String getDel() {
		return del;
	}
	
	public void setDel(String del) {
		this.del = del;
	}
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/consult/WlyyHospitalWaitingRoomDO.java

@ -65,7 +65,7 @@ public class WlyyHospitalWaitingRoomDO extends UuidIdentityEntity {
    private String doctorName;
    /**
	 * -1取消,0离线 1在线(候诊) 2已诊
	 * 0离线 1在线(候诊) 2已诊
	 */
	private Integer visitStatus;

+ 90 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/httplog/WlyyHttpLogDO.java

@ -0,0 +1,90 @@
package com.yihu.jw.entity.hospital.httplog;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2019/6/25.
 */
@Entity
@Table(name = "wlyy_http_log")
public class WlyyHttpLogDO extends UuidIdentityEntity {
    private String code;//接口名称',
    private String name;//接口描述',
    private String patient;//居民code',
    private String doctor;//医生code',
    private String request;//请求参数',
    private String response;//返回参数',
    private String status;//状态0成功,其他失败',
    private Date createTime;//创建时间',
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getRequest() {
        return request;
    }
    public void setRequest(String request) {
        this.request = request;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 15 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java

@ -169,6 +169,11 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
     * 患者取消类型详细说明
     */
    private String patientCancelRemark;
    /**
     * 预约时间
     */
    private Date registerDate;
    /**
	 * -1 取消;0 候诊中 ;1 就诊中 ;2 已诊
	 */
@ -436,4 +441,14 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
    public void setPatientCancelRemark(String patientCancelRemark) {
        this.patientCancelRemark = patientCancelRemark;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name="register_date")
    public Date getRegisterDate() {
        return registerDate;
    }
    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }
}

+ 93 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1,6 +1,5 @@
package com.yihu.jw.rm.hospital;
import com.yihu.jw.rm.base.BaseRequestMapping;
/**
 * Created by Trick on 2019/5/16.
@ -74,6 +73,16 @@ public class BaseHospitalRequestMapping {
         * 查询部门下医生
         */
        public static final String findDoctorByHospitalAndDept = "/findDoctorByHospitalAndDept";
    
        /**
         * 根据疾病名称,热门部门查询医生
         */
        public static final String findDoctorByHospitalAndDiseaseAndDept = "/findDoctorByHospitalAndDiseaseAndDept";
    
        /**
         * 获取常见疾病和热门部门字典
         */
        public static final String findHotDeptAndDiseaseDict = "/findHotDeptAndDiseaseDict";
        /**
         * 挂号
@ -153,6 +162,15 @@ public class BaseHospitalRequestMapping {
         * 居民取消原因字典
         */
        public static final String findCancelReasonList="/findCancelReasonList";
        /**
         * 獲取快速咨詢時間
         */
        public static final String findFastRegisterDate="/findFastRegisterDate";
        /**
         * 获取快速咨询时间分段
         */
        public static final String findByTimeSlot="/findByTimeSlot";
        //=================end=======================================
        /**
@ -224,6 +242,80 @@ public class BaseHospitalRequestMapping {
    public static class Expressage extends Basic {
        public static final String PREFIX  = "/expressage";
    }
    
    /**
     * 居民端-咨询IM
     */
    public static class PatientIM extends Basic{
        public static final String PREFIX  = "/im/patient";
    
        //患者咨询记录查询
        public static final String records ="/records";
    
        //查询居民与某个医生是否存在未结束的咨询
        public static final String isExistsUnfinishedConsult ="/isExistsUnfinishedConsult";
        
        //获取会话成员
        public static final String participants ="/participants";
        
        //根据会话ID获取消息记录
        public static final String getSessionMessage ="/getSessionMessage";
        
        //根据咨询CODE进入会话
        public static final String intoTopic ="/intoTopic";
        
        //居民咨询发消息(追问接口)
        public static final String append ="/append";
        
        //居民添加咨询接口
        public static final String add = "/add";
        
        //居民详情
        public static final String patientInfo = "/patientInfo";
        
        //结束咨询id
        public static final String finish = "/finish";
    
        //根据咨询CODE获取session_id
        public static final String getTopic = "/getTopic";
        
        //根据复诊记录ID获取咨询CODE
        public static final String getConsultCodeByOutpatientId = "/getConsultCodeByOutpatientId";
        
    }
    
    /**
     * 医生端-咨询IM&诊室&导诊台相关接口
     */
    public static class DodtorIM extends Basic{
        public static final String PREFIX  = "/im/doctor";
        
        //添加复诊咨询
        public static final String addPrescriptionConsult ="/addPrescriptionConsult";
        
        //医生可接单列表
        public static final String findWaitingRoomOutpatientByDoctor = "findWaitingRoomOutpatientByDoctor";
    
        //导诊台居民列表
        public static final String findWaitingRoomPatient = "findWaitingRoomPatient";
        
        //导诊台顶部数据状态
        public static final String findWaitingRoomStatusCount = "findWaitingRoomStatusCount";
    
        //导诊台诊室列表
        public static final String findClinicRoomList = "findClinicRoomList";
    
        //查询单个诊室状态
        public static final String findClinicRoomStatus = "findClinicRoomStatus";
    
        //结束咨询id
        public static final String finish = "/finish";
    
        //获取咨询问题,图片,居民信息
        public static final String getConsultInfoAndPatientInfo = "/getConsultInfoAndPatientInfo";
        
    }
    /**
     * 居民收获地址

+ 12 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyOutpatientVO.java

@ -172,6 +172,10 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
    @ApiModelProperty(value = "创建时间", example = "模块1")
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @ApiModelProperty(value = "预约时间", example = "模块1")
    private Date registerDate;
    /**
	 * -1 取消;0 候诊中 ;1 就诊中 ;2 已诊
	 */
@ -380,4 +384,12 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
    public void setType(String type) {
        this.type = type;
    }
    public Date getRegisterDate() {
        return registerDate;
    }
    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }
}

+ 6 - 5
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionInfoVO.java

@ -70,7 +70,7 @@ public class WlyyPrescriptionInfoVO extends UuidIdentityVOWithOperator {
     * 频率
     */
    @ApiModelProperty(value = "频率", example = "模块1")
    private String usage;
    private String usageCode;
    @ApiModelProperty(value = "频率名稱", example = "模块1")
    private String usageName;
@ -167,11 +167,12 @@ public class WlyyPrescriptionInfoVO extends UuidIdentityVOWithOperator {
        this.unit = unit;
    }
    public String getUsage() {
        return usage;
    public String getUsageCode() {
        return usageCode;
    }
    public void setUsage(String usage) {
        this.usage = usage;
    public void setUsageCode(String usageCode) {
        this.usageCode = usageCode;
    }
    public String getSupplyCode() {

+ 114 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/im/ConsultVO.java

@ -0,0 +1,114 @@
package com.yihu.jw.restmodel.im;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * @author huangwenjie
 * @date 2019/6/18 08:55
 */
@ApiModel(value = "ConsultVO", description = "IM咨询VO类")
public class ConsultVO extends UuidIdentityVO {
	
	@ApiModelProperty(value = "咨询类型", example = "模块1")
	private Integer type;
	
	@ApiModelProperty(value = "咨询标题/主诉", example = "模块1")
	private String title;
	
	@ApiModelProperty(value = "主诉", example = "模块1")
	private String symptoms;
	
	@ApiModelProperty(value = "咨询状态(0进行中,1已完成,-1患者取消,-2超时未响应自动关闭)", example = "模块1")
	private Integer status;
	
	@ApiModelProperty(value = "咨询时间", example = "模块1")
	private Date czrq;
	
	@ApiModelProperty(value = "是否评价 1、已评价 0、未评价'", example = "模块1")
	private Integer evaluate;
	
	@ApiModelProperty(value = "医生头像", example = "模块1")
	private String doctorphoto;
	
	@ApiModelProperty(value = "医生职称", example = "模块1")
	private String jobTitleName;
	
	@ApiModelProperty(value = "医生名称", example = "模块1")
	private String doctorName;
	
	public Integer getType() {
		return type;
	}
	
	public void setType(Integer type) {
		this.type = type;
	}
	
	public String getTitle() {
		return title;
	}
	
	public void setTitle(String title) {
		this.title = title;
	}
	
	public String getSymptoms() {
		return symptoms;
	}
	
	public void setSymptoms(String symptoms) {
		this.symptoms = symptoms;
	}
	
	public Integer getStatus() {
		return status;
	}
	
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public Date getCzrq() {
		return czrq;
	}
	
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	public Integer getEvaluate() {
		return evaluate;
	}
	
	public void setEvaluate(Integer evaluate) {
		this.evaluate = evaluate;
	}
	
	public String getDoctorphoto() {
		return doctorphoto;
	}
	
	public void setDoctorphoto(String doctorphoto) {
		this.doctorphoto = doctorphoto;
	}
	
	public String getJobTitleName() {
		return jobTitleName;
	}
	
	public void setJobTitleName(String jobTitleName) {
		this.jobTitleName = jobTitleName;
	}
	
	public String getDoctorName() {
		return doctorName;
	}
	
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
}

+ 22 - 0
common/common-util/pom.xml

@ -69,5 +69,27 @@
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>jave-ffmpegjave</artifactId>
            <version>1.0.4</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>fastdfs-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.3.13.RELEASE</version>
        </dependency>
    </dependencies>
</project>

+ 107 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/FileUtil.java

@ -0,0 +1,107 @@
package com.yihu.jw.util.common;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import it.sauronsoftware.jave.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
 * 文件处理工具类
 * @author huangwenjie
 */
public class FileUtil {
	
	@Autowired
	private FastDFSUtil fastDFSHelper;
	
	public void changeToMp3(String sourcePath, String targetPath) {
		File source = new File(sourcePath);
		File target = new File(targetPath);
		AudioAttributes audio = new AudioAttributes();
		Encoder encoder = new Encoder();
		audio.setCodec("libmp3lame");
		EncodingAttributes attrs = new EncodingAttributes();
		attrs.setFormat("mp3");
		attrs.setAudioAttributes(audio);
		try {
			encoder.encode(source, target, attrs);
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InputFormatException e) {
			e.printStackTrace();
		} catch (EncoderException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 拷贝临时语音文件到存储目录
	 * @param voices_Path
	 * @param fastdfs_file_url
	 * @return
	 * @throws IOException
	 */
	
	
	public String copyTempVoice(String voices_Path,String fastdfs_file_url) throws Exception {
		// 文件保存的临时路径
		FastDFSUtil fastDFSUtil = new FastDFSUtil();
		String fileUrls = "";
		File f = new File(voices_Path);
		if (f.exists()) {
			String fileName = f.getName();
			InputStream in = new FileInputStream(f);
			ObjectNode result = fastDFSUtil.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), "");
			in.close();
			if (result != null) {
				fileUrls += (StringUtils.isEmpty(fileUrls) ? "" : ",") + fastdfs_file_url
						+ result.get("groupName").toString().replaceAll("\"", "") + "/"
						+ result.get("remoteFileName").toString().replaceAll("\"", "");
				f.delete();
			}
		}
		return fileUrls;
	}
	
	/**
	 * 上传文件到FastDFS
	 *
	 * @param files 临时文件
	 * @return
	 * @throws Exception
	 */
	public String copyTempImage(String files,String tempPath) throws Exception {
		// 文件保存的临时路径
		String[] fileArray = files.split(",");
		FastDFSUtil fastDFSUtil = new FastDFSUtil();
		String fileUrls = "";
		for (String file : fileArray) {
			File f = new File(tempPath + file);
			File fs = new File(tempPath + file + "_small");
			if (f.exists()) {
				String fileName = f.getName();
				InputStream in = new FileInputStream(f);
				ObjectNode result = fastDFSUtil.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), "");
				in.close();
				if (result != null) {
					//1.3.7去掉前缀
					fileUrls += (StringUtils.isEmpty(fileUrls) ? "" : ",")
							+ result.get("groupName").toString().replaceAll("\"", "") + "/"
							+ result.get("remoteFileName").toString().replaceAll("\"", "");
					f.delete();
					if (fs.exists()) {
						fs.delete();
					}
				}
			}
		}
		
		return fileUrls;
	}
}

+ 39 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -1063,5 +1063,44 @@ public class DateUtil {
        System.out.println(dateStart );
        System.out.println(dateEnd);
    }
    
    /**
     * 根据身份证的号码算出当前身份证持有者的年龄
     *
     * @param
     * @throws Exception
     */
    public static int getAgeForIdcard(String idcard) {
        try {
            int age = 0;
            
            if (org.apache.commons.lang3.StringUtils.isEmpty(idcard)) {
                return age;
            }
            
            String birth = "";
            
            if (idcard.length() == 18) {
                birth = idcard.substring(6, 14);
            } else if (idcard.length() == 15) {
                birth = "19" + idcard.substring(6, 12);
            }
            
            int year = Integer.valueOf(birth.substring(0, 4));
            int month = Integer.valueOf(birth.substring(4, 6));
            int day = Integer.valueOf(birth.substring(6));
            Calendar cal = Calendar.getInstance();
            age = cal.get(Calendar.YEAR) - year;
            //周岁计算
            if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
                age--;
            }
            
            return age;
        } catch (Exception e) {
        
        }
        return -1;
    }
}

+ 24 - 0
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -13,7 +13,10 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.net.HttpURLConnection;
@ -227,5 +230,26 @@ public class HttpClientUtil {
        }
        return buffer.toString();
    }
    
    public  String postBody(String url, com.alibaba.fastjson.JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
        String ret = restTemplate.postForObject(url, formEntity, String.class);
        return ret;
    }
    
    public  void putBody(String url, com.alibaba.fastjson.JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
        restTemplate.put(url, formEntity, String.class);
    }
}

+ 1 - 1
common/common-web/src/main/resources/logback-spring.xml

@ -5,7 +5,7 @@
    <springProperty scope="context" name="appName" source="spring.application.name" />
	<property name="log_home" value="/wlyy-logs/${appName}" />
	<property name="log_home" value="/Users/Mewtwo/ideaSpace/log/wlyy-logs/${appName}" />
    <property name="max_history" value="30"/>
    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />

+ 14 - 14
svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java

@ -76,23 +76,23 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictIcd10Service.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictIcd10Service.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHospitalDeptService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictHospitalDeptService.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictJobTitleService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictJobTitleService.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHealthProblemService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictHealthProblemService.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictMedicineService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictMedicineService.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictDiseaseService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictDiseaseService.queryAll(saasId, creatPage(page, size, sorts));
        } else {
            jsonObject = this.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = this.queryAll(saasId, creatPage(page, size, sorts));
        }
        jsonArray.add(jsonObject);
        return jsonArray;
@ -123,23 +123,23 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictIcd10Service.queryAll(userId, createPage(page, size, sorts));
            jsonObject = dictIcd10Service.queryAll(userId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHospitalDeptService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictHospitalDeptService.queryAll("", creatPage(page, size, sorts));
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictJobTitleService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictJobTitleService.queryAll("", creatPage(page, size, sorts));
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHealthProblemService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictHealthProblemService.queryAll("", creatPage(page, size, sorts));
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictMedicineService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictMedicineService.queryAll("", creatPage(page, size, sorts));
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictDiseaseService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictDiseaseService.queryAll("", creatPage(page, size, sorts));
        } else {
            jsonObject = this.queryAll("", createPage(page, size, sorts));
            jsonObject = this.queryAll("", creatPage(page, size, sorts));
        }
        jsonArray.add(jsonObject);
        return jsonArray;

+ 25 - 2
svr/svr-base/src/main/resources/application.yml

@ -103,6 +103,14 @@ fastDFS:
# 短信发送地址
jw:
  smsUrl: http://svr-base:10020/sms_gateway/send
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
---
spring:
  profiles: jwtest
@ -130,7 +138,14 @@ spring:
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
---
spring:
  profiles: prod
@ -154,4 +169,12 @@ spring:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://172.19.103.54:80/
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01

+ 15 - 0
svr/svr-internet-hospital-entrance/pom.xml

@ -136,6 +136,12 @@
            <version>2.0.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>im-service</artifactId>
            <version>2.0.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-commons</artifactId>
@ -147,7 +153,16 @@
            <artifactId>mqSdk</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>

+ 29 - 1
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java

@ -3,7 +3,6 @@ package com.yihu.jw.entrance.controller;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.mapping.HospitalDeptMappingDO;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
@ -358,5 +357,34 @@ public class MqSdkController extends EnvelopRestEndpoint {
            return ObjEnvelop.getError(object1.get("respMsg").toString());
        }
    }
    @GetMapping(value = "/getUserInfoByOpenid")
    @ApiOperation(value = "获取用户信息")
    public ObjEnvelop getUserInfoByOpenid(
            @ApiParam(name = "openId", value = "用户openId")
            @RequestParam(value = "openId", required = true) String openId) throws Exception {
        String responseMsg = entranceService.getUserInfoByOpenid(openId);
        JSONObject object1 = JSONObject.fromObject(responseMsg);
        if (null != object1&&null!=object1.get("status") && "200".equals(object1.get("status").toString())) {
            return success(object1.get("userinfo"));
        } else {
            return ObjEnvelop.getError(null!=object1.get("message")?object1.get("message").toString():"无效openId");
        }
    }
    @GetMapping(value = "/getAccessToken")
    @ApiOperation(value = "获取accessToken")
    public ObjEnvelop getAccessToken(
            @ApiParam(name = "interfaceid", value = "校验码,默认:100033")
            @RequestParam(value = "interfaceid", required = true,defaultValue = "100033") String interfaceid) throws Exception {
        String responseMsg = entranceService.getAccessToken(interfaceid);
        JSONObject object1 = JSONObject.fromObject(responseMsg);
        if (null != object1&&null!=object1.get("respCode") && "00".equals(object1.get("respCode"))) {
            return success(object1.get("respEntity"));
        } else {
            return ObjEnvelop.getError(object1.get("respMsg").toString());
        }
    }
}

+ 5 - 0
svr/svr-internet-hospital/pom.xml

@ -202,6 +202,11 @@
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>im-service</artifactId>
            <version>2.0.0</version>
        </dependency>
    </dependencies>
    <build>

+ 8 - 8
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java

@ -2,15 +2,15 @@ package com.yihu.jw.hospital.endpoint.base;
import com.yihu.jw.area.service.BaseCityService;
import com.yihu.jw.dict.service.BaseDictJobTitleService;
import com.yihu.jw.dict.service.DictHospitalDeptService;
import com.yihu.jw.dict.service.HospitalDeptService;
import com.yihu.jw.doctor.service.BaseDoctorHosService;
import com.yihu.jw.doctor.service.BaseDoctorService;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.area.BaseCityDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.org.service.BaseOrgService;
import com.yihu.jw.org.service.BaseOrgInfoService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
@ -36,7 +36,7 @@ public class BaseInfoEndpoint extends EnvelopRestEndpoint {
    private BaseCityService cityService;
    @Autowired
    private DictHospitalDeptService dictHospitalDeptService;
    private HospitalDeptService hospitalDeptService;
    @Autowired
    private BaseDictJobTitleService baseDictJobTitleService;
@ -45,10 +45,10 @@ public class BaseInfoEndpoint extends EnvelopRestEndpoint {
    private BaseDoctorHosService baseDoctorHosService;
    @Autowired
    private BaseDoctorService baseDoctorService;
    private BaseDoctorInfoService baseDoctorInfoService;
    @Autowired
    private BaseOrgService baseOrgService;
    private BaseOrgInfoService baseOrgInfoService;
    /**
     * 获取市列表信息
@ -74,7 +74,7 @@ public class BaseInfoEndpoint extends EnvelopRestEndpoint {
    public Envelop getOrgByCity(
            @ApiParam(name = "cityCode", value = "市编码")
            @RequestParam(value = "cityCode", required = false) String cityCode) {
        List<BaseOrgDO> res =  baseOrgService.getOrgByCity(cityCode);
        List<BaseOrgDO> res =  baseOrgInfoService.getOrgByCity(cityCode);
        if(res != null && res.size() > 0 ){
            return  success(res);
        }else{
@ -92,7 +92,7 @@ public class BaseInfoEndpoint extends EnvelopRestEndpoint {
    public Envelop getDeptByOrgCode(
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode", required = false) String orgCode)  {
        List<DictHospitalDeptDO> res =  dictHospitalDeptService.getHosDeptByCode(orgCode);
        List<DictHospitalDeptDO> res =  hospitalDeptService.getHosDeptByCode(orgCode);
        if(res != null && res.size() > 0 ){
            return  success(res);
        }else{

File diff suppressed because it is too large
+ 181 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java


+ 280 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -0,0 +1,280 @@
package com.yihu.jw.hospital.endpoint.consult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.axis.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
 * @author huangwenjie
 */
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.PatientIM.PREFIX)
@Api(value = "居民端咨询IM接口", description = "居民端咨询IM接口", tags = {"居民端咨询IM接口"})
public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	
	@Autowired
	private ImService imService;
	
	@Autowired
	private PrescriptionService prescriptionService;
	
	@Autowired
	private BasePatientService basePatientService;
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
	@ApiOperation(value = "患者咨询记录查询")
	public ListEnvelop records(
								@ApiParam(name = "patient", value = "居民id")
								@RequestParam(value = "patient",required = true) String patient,
								@ApiParam(name = "title", value = "咨询标题关键字")
								@RequestParam(value = "title",required = false) String title,
								@ApiParam(name = "id", value = "咨询ID")
								@RequestParam(value = "id",required = false) String id,
								@ApiParam(name = "type", value = "咨询类型")
								@RequestParam(value = "type",required = true) Integer type,
								@ApiParam(name = "pagesize", value = "分页大小")
								@RequestParam(value = "pagesize",required = false) int pagesize
								)throws Exception{
		JSONArray array = new JSONArray();
		List<ConsultVO>  data = imService.findConsultRecordByPatient(patient, id,type, pagesize, title);
		if (data != null) {
			for (ConsultVO consult : data) {
				if (consult == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				json.put("id", consult.getId());
				// 设置咨询类型:1三师咨询,2视频咨询,3图文咨询,4公共咨询,5病友圈
				json.put("type", consult.getType());
				// 设置显示标题
				json.put("title", consult.getTitle());
				// 设置主诉
				json.put("symptoms", consult.getSymptoms());
				// 咨询状态
				json.put("status", consult.getStatus());
				// 设置咨询日期
				json.put("czrq", DateUtil.dateToStrLong(consult.getCzrq()));
				//是否评价
				json.put("evaluate", consult.getEvaluate());
				//医生头像
				json.put("doctorPhoto", consult.getDoctorphoto());
				//医生职称
				json.put("jobTitleName", consult.getJobTitleName());
				//医生名称
				json.put("doctorName", consult.getDoctorName());
				
				array.add(json);
			}
		}
		return success(array);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.isExistsUnfinishedConsult)
	@ApiOperation(value = "查询居民与某个医生是否存在未结束的咨询")
	public Envelop isExistsUnfinishedConsult(
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = true) String patient)throws Exception {
		
		if(StringUtils.isEmpty(patient)){
			patient= getUID();
		}
		
		String consultCode = imService.getUnfinishedConsult(patient, doctor);
		return success("请求成功",consultCode);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.participants)
	@ApiOperation(value = "获取会话成员")
	public ListEnvelop participants(
			@ApiParam(name = "sessionId", value = "会话ID")
			@RequestParam(value = "sessionId",required = true) String sessionId)throws Exception{
		
		JSONArray participants = imService.getSessions(sessionId);
		return success(participants);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getSessionMessage)
	@ApiOperation(value = "根据会话ID获取消息记录")
	public ListEnvelop getSessionMessage(
			@ApiParam(name = "sessionId", value = "会话ID")
			@RequestParam(value = "sessionId",required = true) String sessionId,
			@ApiParam(name = "startMsgId", value = "开始的消息记录ID")
			@RequestParam(value = "startMsgId",required = false) String startMsgId,
			@ApiParam(name = "endMsgId", value = "结束的消息记录ID")
			@RequestParam(value = "endMsgId",required = false) String endMsgId,
			@ApiParam(name = "page", value = "第几页")
			@RequestParam(value = "page",required = true) int page,
			@ApiParam(name = "pagesize", value = "分页数")
			@RequestParam(value = "pagesize",required = true) int pagesize)throws Exception{
		JSONArray messageArray = imService.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getUID());
		return success(messageArray);
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.intoTopic)
	@ApiOperation(value = "根据咨询CODE进入会话")
	public Envelop intoTopic(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = true) String consult,
			@ApiParam(name = "patientCode", value = "居民CODE")
			@RequestParam(value = "patientCode",required = true) String patientCode
			){
		int result = imService.intoTopic(consult,patientCode,"");
		if(result==-1){
			return failed("该咨询不是进行中");
		}
//		org.json.JSONObject json = new org.json.JSONObject();
//		json.put("consult",consult);
//		json.put("content","进入咨询");
//		BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getRepUID(), json);
		return success("进入成功");
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.append)
	@ApiOperation(value = "居民咨询发消息(追问接口)")
	public ListEnvelop append(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = true) String consult,
			@ApiParam(name = "content", value = "追问内容")
			@RequestParam(value = "content",required = true) String content,
			@ApiParam(name = "type", value = "追问内容类型:1文字,2图片,3语音  ... (im消息类型)")
			@RequestParam(value = "type",required = true) Integer type,
			@ApiParam(name = "times", value = "")
			@RequestParam(value = "times",required = false) Integer times,
			@ApiParam(name = "wechat_appid", value = "")
			@RequestParam(value = "wechat_appid",required = false) String wechat_appid,
			@ApiParam(name = "patientCode", value = "居民CODE")
			@RequestParam(value = "patientCode",required = false) String patientCode) throws Exception {
		List<String> failed = new ArrayList<>();
		failed = imService.append(consult,content,type,times,patientCode,wechat_appid);
		return success(failed);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorByHospitalAndDiseaseAndDept)
	@ApiOperation(value = "根据疾病名称,热门部门查询医生", notes = "根据疾病名称,热门部门查询医生")
	public ListEnvelop findDoctorByHospitalAndDiseaseAndDept(@ApiParam(name = "orgCode", value = "机构code")
	                                               @RequestParam(value = "orgCode", required = true,defaultValue = "350211A1002")String orgCode,
	                                               @ApiParam(name = "dept", value = "部门code")
	                                               @RequestParam(value = "dept", required = false)String dept,
	                                               @ApiParam(name = "diseaseKey", value = "疾病名称关键字")
	                                               @RequestParam(value = "diseaseKey", required = false)String diseaseKey,
                                                   @ApiParam(name = "doctorNameKey", value = "医生名称关键字")
	                                               @RequestParam(value = "doctorNameKey", required = false)String doctorNameKey) throws Exception{
		return success(prescriptionService.findDoctorByHospitalAndDiseaseAndDept(orgCode,dept,diseaseKey,doctorNameKey));
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.Prescription.findHotDeptAndDiseaseDict)
	@ApiOperation(value = "获取常见疾病和热门部门字典", notes = "获取常见疾病和热门部门字典")
	public ListEnvelop findHotDeptAndDiseaseDict(@ApiParam(name = "dictName", value = "dictName")
	                                             @RequestParam(value = "dictName", required = true,defaultValue = "ONLINE_HOSPITAL_DEPT_350211A1002")String dictName)throws Exception{
		return success(prescriptionService.findHotDeptAndDiseaseDict(dictName));
	}
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.add)
	@ApiOperation(value = "居民添加咨询接口", notes = "居民添加咨询接口")
	public Envelop add(
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = false) String patient,
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "when", value = "发病时间")
			@RequestParam(value = "when",required = true) String when,
			@ApiParam(name = "symptoms", value = "主述")
			@RequestParam(value = "symptoms",required = false) String symptoms,
			@ApiParam(name = "images", value = "图片")
			@RequestParam(value = "images",required = false) String images,
			@ApiParam(name = "voice", value = "语音")
			@RequestParam(value = "voice",required = false) String voice,
			@ApiParam(name = "type", value = "咨询类型")
			@RequestParam(value = "type",required = false) Integer type)throws Exception{
		
		System.out.println("symptoms="+symptoms);
		
		if (type == null) {
			type = 13;
		}
//		if (type != 1 && type != 2) {
//			return error(-1, "无效请求!");
//		}
		
		ConsultTeamDo consult = new ConsultTeamDo();
		// 设置咨询类型:9:在线复诊  13专家咨询
		consult.setType(type);
		// 设置发病时间
		consult.setWhen(when);
		// 设置主要症状
		consult.setSymptoms(symptoms);
		// 设置咨询图片URL
		consult.setImages(images);
		// 设置咨询语音URL
		consult.setVoice(voice);
		
		// 保存到数据库
//		int res = 0;
//		JSONArray dts = null;
		synchronized (patient.intern()){//新增同步方法。设备保存写在service层但是不生效,写在controller层才生效
			JSONObject re = imService.addTeamConsult(consult, patient,doctor);
//			res = re.getInteger("status");
//			dts = re.containsKey("doctor")?re.getJSONArray("doctor"):null;
		}
		return success("操作成功", consult);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.patientInfo)
	@ApiOperation(value = "根据居民ID获取居民详情信息", notes = "根据居民ID获取居民详情信息")
	public Envelop patientInfo(
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = false) String patient) throws Exception {
		BasePatientDO result = basePatientService.findByIdAndDel(patient);
		return success(result);
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.finish)
	@ApiOperation(value = "居民结束咨询", notes = "居民结束咨询")
	public Envelop finish(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = false) String consult,
			@ApiParam(name = "patientCode", value = "居民COEE")
			@RequestParam(value = "patientCode",required = false) String patientCode
			) throws Exception {
		int resutl = imService.finish(consult,patientCode,1);
		return success(resutl);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getTopic)
	@ApiOperation(value = "根据咨询CODE获取session_id", notes = "根据咨询CODE获取session_id")
	public Envelop getTopic(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = false) String consult)throws Exception {
		return success("请求成功",imService.getTopic(consult));
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getConsultCodeByOutpatientId)
	@ApiOperation(value = "根据复诊记录ID获取咨询CODE", notes = "根据复诊记录ID获取咨询CODE")
	public Envelop getConsultCodeByOutpatientId(
			@ApiParam(name = "outpatientid", value = "复诊ID")
			@RequestParam(value = "outpatientid",required = true) String outpatientid)throws Exception {
		return success("请求成功",imService.getConsultCodeByOutpatientId(outpatientid));
	}
}

+ 5 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/SysDictEndpoint.java

@ -136,7 +136,10 @@ public class SysDictEndpoint extends EnvelopRestEndpoint {
        }
        return objEnvelop;
    }
    
    @Override
    public com.alibaba.fastjson.JSONObject getUserAgent() {
        return super.getUserAgent();
    }
}

+ 13 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -374,7 +374,20 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success(prescriptionService.findCancelReasonList());
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findFastRegisterDate)
    @ApiOperation(value = "獲取快速咨詢時間", notes = "獲取快速咨詢時間")
    public ListEnvelop findFastRegisterDate(){
        return success(prescriptionService.findFastRegisterDate());
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findByTimeSlot)
    @ApiOperation(value = "获取快速咨询时间分段", notes = "获取快速咨询时间分段")
    public ListEnvelop findByTimeSlot(@ApiParam(name = "startTime", value = "开始时间")
                                      @RequestParam(value = "startTime", required = false)String startTime,
                                      @ApiParam(name = "endTime", value = "结束时间")
                                      @RequestParam(value = "endTime", required = false)String endTime) {
        return success(prescriptionService.findByTimeSlot(startTime,endTime));
    }
    //===========

+ 34 - 1
svr/svr-internet-hospital/src/main/resources/application.yml

@ -122,10 +122,21 @@ sms:
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.26.0.118:3000/
  data_base_name: im_new
# 上传文件临时路径配置
FileTempPath:
  upload_temp_path : /var/local/temp
  image_path : /var/local/upload/images
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat
---
spring:
  profiles: jwtest
@ -164,10 +175,21 @@ myFamily:
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.26.0.118:3000/
  data_base_name: im_new
# 上传文件临时路径配置
FileTempPath:
  upload_temp_path : /var/local/temp
  image_path : /var/local/upload/images
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat
---
spring:
  profiles: prod
@ -203,7 +225,18 @@ myFamily:
demo:
  flag: false
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
  TargetSysCode: S01
im:
  im_list_get: http://172.26.0.118:3000/
  data_base_name: im
# 上传文件临时路径配置
FileTempPath:
  upload_temp_path : /var/local/temp
  image_path : /var/local/upload/images
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat

+ 1 - 1
svr/svr-internet-hospital/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-internet-hospital
    name: svr-internet-hospital-hwj
  cloud:
    config:
      failFast: true

+ 1 - 0
wlyy-lib-parent-pom/pom.xml

@ -28,6 +28,7 @@
        <module>../common/common-tracer</module>
        <module>../business/base-service</module>
        <module>../business/sms-service</module>
        <module>../business/im-service</module>
    </modules>
</project>

+ 5 - 1
wlyy-parent-pom/pom.xml

@ -76,7 +76,7 @@
        <!-- 应用 -->
        <module>../app/app-iot-server</module>
        <module>../app/public-health-server</module>
        <!--<module>../app/public-health-server</module>-->
    </modules>
@ -400,6 +400,10 @@
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <verbose/>
                        <bootclasspath>${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jce.jar</bootclasspath>
                    </compilerArguments>
                </configuration>
                <version>3.1</version>
            </plugin>