Browse Source

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

zdm 5 years ago
parent
commit
dcb09cdc98
69 changed files with 4961 additions and 502 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. 0 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java
  5. 11 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/WlyyDoctorClinicRoomDao.java
  6. 171 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  7. 1 1
      business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java
  8. 1 1
      business/base-service/src/main/java/com/yihu/jw/org/service/BaseOrgService.java
  9. 52 0
      business/im-service/pom.xml
  10. 30 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java
  11. 26 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDao.java
  12. 13 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDoctorDao.java
  13. 13 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamLogDao.java
  14. 1051 0
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  15. 309 0
      business/im-service/src/main/java/com/yihu/jw/im/util/HttpClientUtil.java
  16. 680 0
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  17. 91 0
      business/im-service/src/main/java/com/yihu/jw/im/util/ImageCompress.java
  18. 120 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultDo.java
  19. 390 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDo.java
  20. 90 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDoctorDo.java
  21. 115 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamLogDo.java
  22. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/consult/WlyyHospitalWaitingRoomDO.java
  23. 84 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  24. 114 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/im/ConsultVO.java
  25. 18 0
      common/common-util/pom.xml
  26. 107 0
      common/common-util/src/main/java/com/yihu/jw/util/common/FileUtil.java
  27. 39 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  28. 24 0
      common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java
  29. 1 1
      common/common-web/src/main/resources/logback-spring.xml
  30. 3 3
      gateway/ag-basic/src/main/resources/application.yml
  31. 2 2
      gateway/ag-basic/src/main/resources/bootstrap.yml
  32. 0 9
      server/svr-authentication/pom.xml
  33. 2 0
      server/svr-authentication/src/main/java/com/yihu/AuthServer.java
  34. 14 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  35. 306 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/utils/HttpClientUtil.java
  36. 9 8
      server/svr-authentication/src/main/resources/application.yml
  37. 38 15
      server/svr-authentication/src/main/resources/bootstrap.yml
  38. 1 1
      svr/svr-base/pom.xml
  39. 14 14
      svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java
  40. 34 10
      svr/svr-base/src/main/resources/application.yml
  41. 2 2
      svr/svr-base/src/main/resources/bootstrap.yml
  42. 3 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dfs/FastDFSController.java
  43. 11 0
      svr/svr-internet-hospital-entrance/pom.xml
  44. 4 4
      svr/svr-internet-hospital-entrance/src/main/resources/application.yml
  45. 2 2
      svr/svr-internet-hospital-entrance/src/main/resources/bootstrap.yml
  46. 5 0
      svr/svr-internet-hospital/pom.xml
  47. 1 1
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/bean/BeanConfig.java
  48. 4 5
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/dao/WlyyPatientExpressageAddrDao.java
  49. 8 8
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java
  50. 181 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  51. 280 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  52. 5 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/SysDictEndpoint.java
  53. 1 1
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/ExpressageEndpoint.java
  54. 3 5
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/WlyyPatientExpressageAddrEndpoint.java
  55. 13 4
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/WlyyPatientExpressageAddrService.java
  56. 41 10
      svr/svr-internet-hospital/src/main/resources/application.yml
  57. 2 2
      svr/svr-internet-hospital/src/main/resources/bootstrap.yml
  58. 4 0
      svr/svr-iot/pom.xml
  59. 345 344
      svr/svr-iot/src/main/java/com/yihu/iot/controller/analyzer/IotAnalyzerController.java
  60. 28 3
      svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/IotAnalyzerService.java
  61. 1 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/WlyyIotDDao.java
  62. 4 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/WlyyIotMDao.java
  63. 3 1
      svr/svr-wlyy-specialist/src/main/java/com/yihu/SvrWlyySpecialistApplication.java
  64. 1 1
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java
  65. 24 24
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/util/ImUtill.java
  66. 1 1
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/util/HttpClientUtil.java
  67. 1 1
      svr/svr-wlyy-specialist/src/main/resources/bootstrap.yml
  68. 1 0
      wlyy-lib-parent-pom/pom.xml
  69. 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;

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

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

@ -8,6 +8,7 @@ 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;
@ -16,7 +17,6 @@ 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;
@ -82,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;
@ -109,6 +107,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private PatientRegisterTimeDao patientRegisterTimeDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    @Autowired
    private WlyyDoctorClinicRoomDao wlyyDoctorClinicRoomDao;
    
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -551,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());
@ -1526,6 +1527,118 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        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);
    }
    /**
     * 获取快速咨询时间分段
@ -1556,4 +1669,58 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        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;
    }
}

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

@ -19,7 +19,7 @@ import java.util.Map;
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1
 * @since
 */
public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String>, JpaSpecificationExecutor<BaseOrgDO>  {

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

+ 84 - 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";
        /**
         * 挂号
@ -233,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";
        
    }
    /**
     * 居民收获地址

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

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

@ -69,5 +69,23 @@
            <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>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" />

+ 3 - 3
gateway/ag-basic/src/main/resources/application.yml

@ -87,9 +87,9 @@ spring:
spring:
  profiles: jwprod
  datasource:
    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: root
    password: 123456
    url: jdbc:mysql://192.0.33.27/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: im
    password: 2oEq3Kf7
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.

+ 2 - 2
gateway/ag-basic/src/main/resources/bootstrap.yml

@ -13,7 +13,7 @@ eureka:
    healthcheck:
      enabled: false #监控检查
    serviceUrl:
      defaultZone: http://jw:jkzl@172.26.0.107:8761/eureka/
      defaultZone: http://jw:jkzl@192.0.33.26:8761/eureka/
  instance:
    prefer-ip-address: false
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
@ -39,5 +39,5 @@ spring:
  profiles: jwprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.26.0.107:1221}
      uri: ${wlyy.pring.config.uri:http://192.0.33.26:1221}
      label: ${wlyy.spring.config.label:jwprod}

+ 0 - 9
server/svr-authentication/pom.xml

@ -100,11 +100,6 @@
        </dependency>
        <!-- JdbcTemplate-->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>utils</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-rest-model</artifactId>
@ -118,10 +113,6 @@
            <artifactId>mysql-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
    </dependencies>

+ 2 - 0
server/svr-authentication/src/main/java/com/yihu/AuthServer.java

@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
@ -11,6 +12,7 @@ import org.springframework.web.client.RestTemplate;
/**
 * Created by progr1mmer on 2018/8/29.
 */
@EnableDiscoveryClient
@SpringBootApplication
public class AuthServer extends SpringBootServletInitializer {

+ 14 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -4,7 +4,8 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.model.WlyyUserDetails;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.util.http.HttpClientKit;
import com.yihu.jw.security.utils.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.http.NameValuePair;
@ -67,6 +68,8 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    @Autowired
    private ClientDetailsService clientDetailsService;
    @Autowired
    private HttpClientUtil httpClientUtil;
    public WlyyUserDetailsService(DataSource dataSource) {
        this.setDataSource(dataSource);
@ -156,7 +159,16 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                params.add(new BasicNameValuePair("clientSecret", clientDetails.getClientSecret()));
                params.add(new BasicNameValuePair("code", username));
                params.add(new BasicNameValuePair("openid", getOpenid()));
                String res = HttpClientKit.post(iHealthUserInfoUrl, params, "UTF-8");
                String res = null;
                try{
                    res = httpClientUtil.post(iHealthUserInfoUrl, params, "UTF-8");
                }catch (Exception e){
                    logger.error("远程请求i健康用户信息异常败:" + e.getMessage());
                    return users;
                }
                if(null == res){
                    return users;
                }
                JSONObject patient = JSONObject.parseObject(res);
                if(patient.getInteger("status") == -1){
                    logger.error("去i健康查询用户信息失败:" + patient.getString("error"));

+ 306 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/HttpClientUtil.java

@ -0,0 +1,306 @@
package com.yihu.jw.security.utils;
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;
@Component
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;
    }
}

+ 9 - 8
server/svr-authentication/src/main/resources/application.yml

@ -37,7 +37,7 @@ spring:
# i健康用户信息接口,开放出来给互联网医院登录同步用户信息用
iHealth:
  user-info-uri: http://http://ehr.yihu.com/wlyy/patient/userInfo
  user-info-uri: http://ehr.yihu.com/wlyy/iHealth/userInfo
---
spring:
  profiles: jwtest
@ -50,16 +50,17 @@ spring:
    port: 6379 # Redis server port.
## i健康用户信息接口,开放出来给互联网医院登录同步用户信息用
iHealth:
  user-info-uri: http://http://ehr.yihu.com/wlyy/patient/userInfo
  user-info-uri: http://ehr.yihu.com/wlyy/iHealth/userInfo
---
spring:
  profiles: jwprod
  datasource:
    url: jdbc:mysql://172.17.110.160/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: ssgg
    password: ssgg
    url: jdbc:mysql://192.0.33.27/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: im
    password: 2oEq3Kf7
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
    host: 192.0.33.26 # Redis server host.
    port: 6390 # Redis server port.
    password: Kb6wKDQP1W4
iHealth:
  user-info-uri: http://http://ehr.yihu.com/wlyy/patient/userInfo
  user-info-uri: http://ehr.yihu.com/wlyy/iHealth/userInfo

+ 38 - 15
server/svr-authentication/src/main/resources/bootstrap.yml

@ -6,37 +6,60 @@ spring:
      failFast: true
      username: jw
      password: jkzl
#发现服务
---
spring:
  profiles: jwdev
  cloud:
    config:
      discovery:
        enabled: true
        service-id: svr-configuration
##发现服务
eureka:
  client:
    healthcheck:
      enabled: false #监控检查
      enabled: true #监控检查
    serviceUrl:
      defaultZone: http://jw:jkzl@172.26.0.107:8761/eureka/
  instance:
    prefer-ip-address: false
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
---
spring:
  profiles: jwdev
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.107:1221}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: jwtest
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.107:1221}
      label: ${wlyy.spring.config.label:jwtest}
      discovery:
        enabled: true
        service-id: svr-configuration
##发现服务
eureka:
  client:
    healthcheck:
      enabled: true #监控检查
    serviceUrl:
      defaultZone: http://jw:jkzl@172.26.0.107:8761/eureka/
  instance:
    prefer-ip-address: false
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
---
spring:
  profiles: jwprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.107:1221}
      label: ${wlyy.spring.config.label:jwprod}
      discovery:
        enabled: true
        service-id: svr-configuration
##发现服务
eureka:
  client:
    healthcheck:
      enabled: true #监控检查
    serviceUrl:
      defaultZone: http://jw:jkzl@192.0.33.26:8761/eureka/
  instance:
    prefer-ip-address: false
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}

+ 1 - 1
svr/svr-base/pom.xml

@ -12,7 +12,7 @@
    <groupId>com.yihu.jw</groupId>
    <artifactId>svr-base</artifactId>
    <packaging>war</packaging>
    <packaging>jar</packaging>
    <version>${parent.version}</version>
    <dependencies>

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

+ 34 - 10
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,20 +138,27 @@ 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
  profiles: jwprod
  datasource:
    url: jdbc:mysql://59.61.92.90:9069/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: wlyy
    password: jkzlehr@123
    url: jdbc:mysql://192.0.33.27:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: im
    password: 2oEq3Kf7
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 59.61.92.90:9066,59.61.92.90:9068 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    cluster-nodes: 192.0.33.26:9200 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://59.61.92.90:9065,http://59.61.92.90:9067
      uris: http://192.0.33.26:9300
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
@ -151,7 +166,16 @@ spring:
    user: jkzl
    password: jkzlehr
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
    host: 192.0.33.26 # Redis server host.
    port: 6390 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://192.0.33.26:8888/
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01

+ 2 - 2
svr/svr-base/src/main/resources/bootstrap.yml

@ -25,10 +25,10 @@ spring:
---
spring:
  profiles: prod
  profiles: jwprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.107:1221}
      uri: ${wlyy.spring.config.uri:http://192.0.33.26:1221}
      label: ${wlyy.spring.config.label:prod}
---

+ 3 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dfs/FastDFSController.java

@ -3,7 +3,6 @@ package com.yihu.jw.healthyhouse.controller.dfs;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.fastdfs.config.FastDFSConfig;
import com.yihu.jw.healthyhouse.model.dfs.FileResource;
import com.yihu.jw.healthyhouse.service.dfs.FileResourceService;
import com.yihu.jw.restmodel.web.Envelop;
@ -22,7 +21,9 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.*;
import java.util.Base64;
import java.util.List;
import java.util.Map;
/**
 *文件服务

+ 11 - 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>
@ -152,6 +158,11 @@
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>

+ 4 - 4
svr/svr-internet-hospital-entrance/src/main/resources/application.yml

@ -80,11 +80,11 @@ hospital:
  TargetSysCode: S01
---
spring:
  profiles: prod
  profiles: jwprod
  datasource:
    url: jdbc:mysql://59.61.92.90:9069/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: wlyy
    password: jkzlehr@123
    url: jdbc:mysql://192.0.33.27:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: im
    password: 2oEq3Kf7
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:

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

@ -25,10 +25,10 @@ spring:
---
spring:
  profiles: prod
  profiles: jwprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.131.174:1221}
      uri: ${wlyy.spring.config.uri:http://192.0.33.26:1221}
      label: ${wlyy.spring.config.label:prod}
---

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

+ 1 - 1
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/bean/BeanConfig.java

@ -1,4 +1,4 @@
package com.yihu.jw.entrance.config.bean;
package com.yihu.jw.hospital.config;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import org.springframework.beans.factory.annotation.Value;

+ 4 - 5
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/dao/WlyyPatientExpressageAddrDao.java

@ -1,10 +1,9 @@
package com.yihu.jw.entrance.dao;
package com.yihu.jw.hospital.dao.consult;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
import java.util.List;
/**
@ -21,9 +20,9 @@ import java.util.List;
 */
public interface WlyyPatientExpressageAddrDao extends PagingAndSortingRepository<WlyyPatientExpressageAddrDO, String>, JpaSpecificationExecutor<WlyyPatientExpressageAddrDO>  {
    boolean existsByPatientAndIsDefault(String patient,Integer isDefault);
    boolean existsByPatientAndIsDefault(String patient, Integer isDefault);
    List<WlyyPatientExpressageAddrDO> queryByPatientAndIsDefault(String patient,Integer isDefault);
    List<WlyyPatientExpressageAddrDO> queryByPatientAndIsDefault(String patient, Integer isDefault);
    List<WlyyPatientExpressageAddrDO> queryByPatient(String patient);
}

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

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

@ -1,4 +1,4 @@
package com.yihu.jw.entrance.controller.expressage;
package com.yihu.jw.hospital.endpoint.expressage;
import com.yihu.jw.entity.hospital.prescription.WlyyExpressagePriceDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;

+ 3 - 5
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/WlyyPatientExpressageAddrEndpoint.java

@ -1,11 +1,11 @@
package com.yihu.jw.entrance.controller.expressage;
package com.yihu.jw.hospital.endpoint.expressage;
import com.yihu.jw.entrance.service.WlyyPatientExpressageAddrService;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
import com.yihu.jw.hospital.service.consult.WlyyPatientExpressageAddrService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPatientExpressageAddrVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
@ -17,8 +17,6 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
/**
 * 居民收获地址控制器
 *

+ 13 - 4
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/WlyyPatientExpressageAddrService.java

@ -1,6 +1,7 @@
package com.yihu.jw.entrance.service;
package com.yihu.jw.hospital.service.consult;
import com.yihu.jw.entrance.dao.WlyyPatientExpressageAddrDao;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
import com.yihu.jw.hospital.dao.consult.WlyyPatientExpressageAddrDao;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
@ -8,8 +9,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
@ -46,6 +47,15 @@ public class WlyyPatientExpressageAddrService extends BaseJpaService<WlyyPatient
            error.append(e.getMessage());
            return null;
        }
        if(1 == addrDO.getIsDefault()){
            boolean defaultAddrExist = patientExpressageAddrDao.existsByPatientAndIsDefault(addrDO.getPatient(),1);
            if(defaultAddrExist){
                List<WlyyPatientExpressageAddrDO> defaultAddrDOList = patientExpressageAddrDao.queryByPatientAndIsDefault(addrDO.getPatient(),1);
                WlyyPatientExpressageAddrDO defaultAddrDO = defaultAddrDOList.get(0);
                defaultAddrDO.setIsDefault(0);
                this.save(defaultAddrDO);
            }
        }
        this.save(addrDO);
        return addrDO;
    }
@ -82,7 +92,6 @@ public class WlyyPatientExpressageAddrService extends BaseJpaService<WlyyPatient
            addrDO.setIsDefault(1);
            this.save(defaultAddrDO);
            this.save(addrDO);
            error.append("当前居民已存在默认地址!");
            return ;
        }
    }

+ 41 - 10
svr/svr-internet-hospital/src/main/resources/application.yml

@ -127,6 +127,16 @@ hospital:
  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
@ -170,19 +180,29 @@ hospital:
  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
  profiles: jwprod
  datasource:
    url: jdbc:mysql://59.61.92.90:9069/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: wlyy
    password: jkzlehr@123
    url: jdbc:mysql://192.0.33.27:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: im
    password: 2oEq3Kf7
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 59.61.92.90:9066,59.61.92.90:9068 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    cluster-nodes: 192.0.33.26:9200 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://59.61.92.90:9065,http://59.61.92.90:9067
      uris: http://192.0.33.26:9300
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
@ -190,10 +210,11 @@ spring:
    user: jkzl
    password: jkzlehr
  redis:
    host: 192.168.131.172 # Redis server host.
    port: 6379 # Redis server port.
    host: 192.0.33.26 # Redis server host.
    port: 6390 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://192.0.33.26:8888/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段  # todo 待配置
# 短信验证码发送的客户端标识,居民端
@ -209,4 +230,14 @@ hospital:
  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

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

@ -25,10 +25,10 @@ spring:
---
spring:
  profiles: prod
  profiles: jwprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.131.174:1221}
      uri: ${wlyy.spring.config.uri:http://192.0.33.26:1221}
      label: ${wlyy.spring.config.label:prod}
---

+ 4 - 0
svr/svr-iot/pom.xml

@ -104,6 +104,10 @@
            <artifactId>elasticsearch-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>fastdfs-starter</artifactId>
        </dependency>
    </dependencies>
    <build>

+ 345 - 344
svr/svr-iot/src/main/java/com/yihu/iot/controller/analyzer/IotAnalyzerController.java

@ -15,20 +15,18 @@ import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
 * @author cws on 2018/1/16.
 */
@RestController
@RequestMapping("svr-iot/analyze" )
@RequestMapping("svr-iot/analyze")
@Api(tags = "设备数据解析入库", description = "基于不同厂商的设备的采集数据,进行解析适配,并入库。")
public class IotAnalyzerController extends EnvelopRestEndpoint {
@ -43,75 +41,76 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
    /**
     * 基于奕拓小屋上传的体征数据,进行解析入库  V1.0 版本
     *
     * @param jsonData
     * @return
     */
    @PostMapping(value = "/yitouxiaowuBK" ,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = "/yitouxiaowuBK", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "奕拓体征数据解析入库", notes = "奕拓体征数据解析入库")
    public String updateDeviceDataTest(
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData){
            @RequestBody String jsonData) {
        Envelop envelop = new Envelop();
        String str = "";
        String strResult = "";
        //1. 基础数据初始化
        String accessToken  = "yitouxiaowu";  // 奕拓小屋
        String accessToken = "yitouxiaowu";  // 奕拓小屋
        try {
            //JSON数据解析
            Map dataDetail = objectMapper.readValue(jsonData, HashMap.class);
            // 用户信息
            LinkedHashMap memberMap = (LinkedHashMap)dataDetail.get("Member");
            LinkedHashMap memberMap = (LinkedHashMap) dataDetail.get("Member");
            // 身高体重
            LinkedHashMap heightMap = (LinkedHashMap)dataDetail.get("Height");
            LinkedHashMap heightMap = (LinkedHashMap) dataDetail.get("Height");
            // 人体成分(脂肪)Fat
            LinkedHashMap fatMap = (LinkedHashMap)dataDetail.get("Fat");
            LinkedHashMap fatMap = (LinkedHashMap) dataDetail.get("Fat");
            // 人体成分(脂肪)Fat
            LinkedHashMap minFatMap = (LinkedHashMap)dataDetail.get("MinFat");
            LinkedHashMap minFatMap = (LinkedHashMap) dataDetail.get("MinFat");
            // 血压
            LinkedHashMap bloodPressureMap = (LinkedHashMap)dataDetail.get("BloodPressure");
            LinkedHashMap bloodPressureMap = (LinkedHashMap) dataDetail.get("BloodPressure");
            // 血氧
            LinkedHashMap boMap = (LinkedHashMap)dataDetail.get("Bo");
            LinkedHashMap boMap = (LinkedHashMap) dataDetail.get("Bo");
            // 单导心电
            LinkedHashMap ecgMap = (LinkedHashMap)dataDetail.get("Ecg");
            LinkedHashMap ecgMap = (LinkedHashMap) dataDetail.get("Ecg");
            // 12导心电
            LinkedHashMap peecgMap = (LinkedHashMap)dataDetail.get("PEEcg");
            LinkedHashMap peecgMap = (LinkedHashMap) dataDetail.get("PEEcg");
            // 体温
            LinkedHashMap temperatureMap = (LinkedHashMap)dataDetail.get("Temperature");
            LinkedHashMap temperatureMap = (LinkedHashMap) dataDetail.get("Temperature");
            // 腰臀比
            LinkedHashMap whrMap = (LinkedHashMap)dataDetail.get("Whr");
            LinkedHashMap whrMap = (LinkedHashMap) dataDetail.get("Whr");
            // 血糖
            LinkedHashMap bloodSugarMap = (LinkedHashMap)dataDetail.get("BloodSugar");
            LinkedHashMap bloodSugarMap = (LinkedHashMap) dataDetail.get("BloodSugar");
            // 血尿酸
            LinkedHashMap uaMap = (LinkedHashMap)dataDetail.get("Ua");
            LinkedHashMap uaMap = (LinkedHashMap) dataDetail.get("Ua");
            // 总胆固醇
            LinkedHashMap cholMap = (LinkedHashMap)dataDetail.get("Chol");
            LinkedHashMap cholMap = (LinkedHashMap) dataDetail.get("Chol");
            // 血脂
            LinkedHashMap bloodFatMap = (LinkedHashMap)dataDetail.get("BloodFat");
            LinkedHashMap bloodFatMap = (LinkedHashMap) dataDetail.get("BloodFat");
            // 心血管功能
            LinkedHashMap cardiovascularMap = (LinkedHashMap)dataDetail.get("Cardiovascular");
            LinkedHashMap cardiovascularMap = (LinkedHashMap) dataDetail.get("Cardiovascular");
            // 骨密度
            LinkedHashMap bmdMap = (LinkedHashMap)dataDetail.get("BMD");
            LinkedHashMap bmdMap = (LinkedHashMap) dataDetail.get("BMD");
            // 酒精浓度
            LinkedHashMap alcoholMap = (LinkedHashMap)dataDetail.get("Alcohol");
            LinkedHashMap alcoholMap = (LinkedHashMap) dataDetail.get("Alcohol");
            // 肺活量
            LinkedHashMap lungMap = (LinkedHashMap)dataDetail.get("Lung");
            LinkedHashMap lungMap = (LinkedHashMap) dataDetail.get("Lung");
            // 血红蛋白
            LinkedHashMap hbMap = (LinkedHashMap)dataDetail.get("Hb");
            LinkedHashMap hbMap = (LinkedHashMap) dataDetail.get("Hb");
            // 尿液分析
            LinkedHashMap urinalysisMap = (LinkedHashMap)dataDetail.get("Urinalysis");
            LinkedHashMap urinalysisMap = (LinkedHashMap) dataDetail.get("Urinalysis");
            //0 - 设备基本信息:设备码、设备所属、测试医生、时间、类别等
            JSONObject data = new JSONObject();
            data.put("MachineId",dataDetail.get("MachineId") == null? "":dataDetail.get("MachineId").toString());
            data.put("UnitNo",dataDetail.get("UnitNo") == null? "":dataDetail.get("UnitNo").toString());
            data.put("UnitName",dataDetail.get("UnitName") == null? "":dataDetail.get("UnitName").toString());
            data.put("DoctorId",dataDetail.get("DoctorId") == null? "":dataDetail.get("DoctorId").toString());
            data.put("DoctorName",dataDetail.get("DoctorName") == null? "":dataDetail.get("DoctorName").toString());
            data.put("RecordNo",dataDetail.get("RecordNo") == null? "":dataDetail.get("RecordNo").toString());
            data.put("Measure_time",dataDetail.get("MeasureTime") == null? "":dataDetail.get("MeasureTime").toString());
            data.put("DeviceType",dataDetail.get("DeviceType") == null? "":dataDetail.get("DeviceType").toString());
            data.put("MacAddr",dataDetail.get("MacAddr") == null? "":dataDetail.get("MacAddr").toString());
            data.put("MachineId", dataDetail.get("MachineId") == null ? "" : dataDetail.get("MachineId").toString());
            data.put("UnitNo", dataDetail.get("UnitNo") == null ? "" : dataDetail.get("UnitNo").toString());
            data.put("UnitName", dataDetail.get("UnitName") == null ? "" : dataDetail.get("UnitName").toString());
            data.put("DoctorId", dataDetail.get("DoctorId") == null ? "" : dataDetail.get("DoctorId").toString());
            data.put("DoctorName", dataDetail.get("DoctorName") == null ? "" : dataDetail.get("DoctorName").toString());
            data.put("RecordNo", dataDetail.get("RecordNo") == null ? "" : dataDetail.get("RecordNo").toString());
            data.put("Measure_time", dataDetail.get("MeasureTime") == null ? "" : dataDetail.get("MeasureTime").toString());
            data.put("DeviceType", dataDetail.get("DeviceType") == null ? "" : dataDetail.get("DeviceType").toString());
            data.put("MacAddr", dataDetail.get("MacAddr") == null ? "" : dataDetail.get("MacAddr").toString());
            //用于标识入到I健康的数据库的时间
            data.put("createDate", DateUtil.getStringDate().toString());
@ -127,7 +126,7 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
            JSONObject params = new JSONObject();
            params.put("access_token", accessToken);
            params.put("sn", sn);
            params.put("ext_code","未知");
            params.put("ext_code", "未知");
            params.put("device_name", deviceName);
            params.put("device_model", deviceModel);
            params.put("idcard", idCard);
@ -136,18 +135,18 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
            //2 - 身高体重
            if (heightMap != null) {
                data.put("height", heightMap.get("Height") == null ? "" : heightMap.get("Height").toString());
                data.put("height_name","身高");
                data.put("height_name", "身高");
                data.put("height_unit", "cm");
                data.put("weight", heightMap.get("Weight") == null ? "" : heightMap.get("Weight").toString());
                data.put("weight_name","体重");
                data.put("weight_name", "体重");
                data.put("weight_unit", "kg");
                data.put("bmi",heightMap.get("BMI") == null? "": heightMap.get("BMI").toString());
                data.put("bmi_unit"," ");
                data.put("bmi", heightMap.get("BMI") == null ? "" : heightMap.get("BMI").toString());
                data.put("bmi_unit", " ");
                data.put("IdealWeight", heightMap.get("IdealWeight") == null ? "" : heightMap.get("IdealWeight").toString());
                data.put("weight_name","理想体重");
                data.put("weight_name", "理想体重");
                data.put("weight_unit", "kg");
                data.put("heightResult", heightMap.get("Result") == null ? "" : heightMap.get("Result").toString());
                data.put("heightResult_name","结论:-1、消瘦,0、正常,1、超重,2、肥胖");
                data.put("heightResult_name", "结论:-1、消瘦,0、正常,1、超重,2、肥胖");
            }
            //3 - 人体成分(脂肪)FAT
@ -182,64 +181,64 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Result", fatMap.get("Result") == null ? "" : fatMap.get("Result").toString());
                //单位
                data.put("FatRate_name","%");
                data.put("Fat_name","kg");
                data.put("ExceptFat_name","kg");
                data.put("WaterRate_name","%");
                data.put("Water_name","kg");
                data.put("Minerals_name","kg");
                data.put("Protein_name","kg");
                data.put("Fic_name","kg");
                data.put("Foc_name","kg");
                data.put("Muscle_name","kg");
                data.put("FatAdjust_name","kg");
                data.put("WeightAdjust_name","kg");
                data.put("MuscleAdjust_name","kg");
                data.put("BasicMetabolism_name","kcal");
                data.put("Viscera_name","");
                data.put("Bmc_name","kg");
                data.put("MuscleRate_name","%");
                data.put("QuganMuscle_name","kg");
                data.put("QuganFat_name","kg");
                data.put("ZuotuiMuscle_name","kg");
                data.put("ZuobiMuscle_name","kg");
                data.put("YoubiMuscle_name","kg");
                data.put("YoutuiMuscle_name","kg");
                data.put("ZuobiFat_name","kg");
                data.put("ZuotuiFat_name","kg");
                data.put("YoubiFat_name","kg");
                data.put("YoutuiFat_name","kg");
                data.put("Result_name","");
                data.put("FatRate_name", "%");
                data.put("Fat_name", "kg");
                data.put("ExceptFat_name", "kg");
                data.put("WaterRate_name", "%");
                data.put("Water_name", "kg");
                data.put("Minerals_name", "kg");
                data.put("Protein_name", "kg");
                data.put("Fic_name", "kg");
                data.put("Foc_name", "kg");
                data.put("Muscle_name", "kg");
                data.put("FatAdjust_name", "kg");
                data.put("WeightAdjust_name", "kg");
                data.put("MuscleAdjust_name", "kg");
                data.put("BasicMetabolism_name", "kcal");
                data.put("Viscera_name", "");
                data.put("Bmc_name", "kg");
                data.put("MuscleRate_name", "%");
                data.put("QuganMuscle_name", "kg");
                data.put("QuganFat_name", "kg");
                data.put("ZuotuiMuscle_name", "kg");
                data.put("ZuobiMuscle_name", "kg");
                data.put("YoubiMuscle_name", "kg");
                data.put("YoutuiMuscle_name", "kg");
                data.put("ZuobiFat_name", "kg");
                data.put("ZuotuiFat_name", "kg");
                data.put("YoubiFat_name", "kg");
                data.put("YoutuiFat_name", "kg");
                data.put("Result_name", "");
                //说明
                data.put("FatRate_name","体脂占比");
                data.put("Fat_name","体脂肪量");
                data.put("ExceptFat_name","非脂肪量");
                data.put("WaterRate_name","体水占比");
                data.put("Water_name","水含量");
                data.put("Minerals_name","矿物质");
                data.put("Protein_name","蛋白质含量");
                data.put("Fic_name","细胞内液");
                data.put("Foc_name","细胞外液");
                data.put("Muscle_name","肌肉量");
                data.put("FatAdjust_name","脂肪调节");
                data.put("WeightAdjust_name","体重调节");
                data.put("MuscleAdjust_name","肌肉调节");
                data.put("BasicMetabolism_name","基础代谢");
                data.put("Viscera_name","内脏脂肪等级");
                data.put("Bmc_name","骨骼量");
                data.put("MuscleRate_name","肌肉率");
                data.put("QuganMuscle_name","躯干肌肉量");
                data.put("QuganFat_name","躯干脂肪量");
                data.put("ZuotuiMuscle_name","左腿肌肉量");
                data.put("ZuobiMuscle_name","左臂肌肉量");
                data.put("YoubiMuscle_name","右臂肌肉量");
                data.put("YoutuiMuscle_name","右腿肌肉量");
                data.put("ZuobiFat_name","左臂脂肪量");
                data.put("ZuotuiFat_name","左腿脂肪量");
                data.put("YoubiFat_name","右臂脂肪量");
                data.put("YoutuiFat_name","右腿脂肪量");
                data.put("Result_name","结论:-1、稍瘦,0、标准,1、超重,2、肥胖");
                data.put("FatRate_name", "体脂占比");
                data.put("Fat_name", "体脂肪量");
                data.put("ExceptFat_name", "非脂肪量");
                data.put("WaterRate_name", "体水占比");
                data.put("Water_name", "水含量");
                data.put("Minerals_name", "矿物质");
                data.put("Protein_name", "蛋白质含量");
                data.put("Fic_name", "细胞内液");
                data.put("Foc_name", "细胞外液");
                data.put("Muscle_name", "肌肉量");
                data.put("FatAdjust_name", "脂肪调节");
                data.put("WeightAdjust_name", "体重调节");
                data.put("MuscleAdjust_name", "肌肉调节");
                data.put("BasicMetabolism_name", "基础代谢");
                data.put("Viscera_name", "内脏脂肪等级");
                data.put("Bmc_name", "骨骼量");
                data.put("MuscleRate_name", "肌肉率");
                data.put("QuganMuscle_name", "躯干肌肉量");
                data.put("QuganFat_name", "躯干脂肪量");
                data.put("ZuotuiMuscle_name", "左腿肌肉量");
                data.put("ZuobiMuscle_name", "左臂肌肉量");
                data.put("YoubiMuscle_name", "右臂肌肉量");
                data.put("YoutuiMuscle_name", "右腿肌肉量");
                data.put("ZuobiFat_name", "左臂脂肪量");
                data.put("ZuotuiFat_name", "左腿脂肪量");
                data.put("YoubiFat_name", "右臂脂肪量");
                data.put("YoutuiFat_name", "右腿脂肪量");
                data.put("Result_name", "结论:-1、稍瘦,0、标准,1、超重,2、肥胖");
            }
            //4 - 人体成分(脂肪)minFatMap
@ -253,23 +252,23 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Shape", minFatMap.get("Shape") == null ? "" : minFatMap.get("Shape").toString());
                data.put("Result", minFatMap.get("Result") == null ? "" : minFatMap.get("Result").toString());
                data.put("Height_name","cm");
                data.put("Weight_name","kg");
                data.put("FatRate_name","%");
                data.put("BasicMetabolism_name","");
                data.put("Bmi_name","");
                data.put("Physique_name","");
                data.put("Shape_name","");
                data.put("Result_unit","");
                data.put("Height_name","身高");
                data.put("Weight_name","体重");
                data.put("FatRate_name","体脂肪率");
                data.put("BasicMetabolism_name","基础代谢");
                data.put("Bmi_name","BMI");
                data.put("Physique_name","体质指数:1、偏低,2、标准,3、偏高,4、高");
                data.put("Shape_name","体型:1、消瘦,2、标准,3、隐藏性肥胖,4、肌肉型肥胖/健壮,5、肥胖");
                data.put("Result_name","结论:-1、消瘦,0、正常,1、超重,2、肥胖");
                data.put("Height_name", "cm");
                data.put("Weight_name", "kg");
                data.put("FatRate_name", "%");
                data.put("BasicMetabolism_name", "");
                data.put("Bmi_name", "");
                data.put("Physique_name", "");
                data.put("Shape_name", "");
                data.put("Result_unit", "");
                data.put("Height_name", "身高");
                data.put("Weight_name", "体重");
                data.put("FatRate_name", "体脂肪率");
                data.put("BasicMetabolism_name", "基础代谢");
                data.put("Bmi_name", "BMI");
                data.put("Physique_name", "体质指数:1、偏低,2、标准,3、偏高,4、高");
                data.put("Shape_name", "体型:1、消瘦,2、标准,3、隐藏性肥胖,4、肌肉型肥胖/健壮,5、肥胖");
                data.put("Result_name", "结论:-1、消瘦,0、正常,1、超重,2、肥胖");
            }
@ -280,15 +279,15 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Pulse", bloodPressureMap.get("Pulse") == null ? "" : bloodPressureMap.get("Pulse").toString());
                data.put("Result", bloodPressureMap.get("Result") == null ? "" : bloodPressureMap.get("Result").toString());
                data.put("HighPressure_unit","mmHg");
                data.put("LowPressure_unit","mmHg");
                data.put("Pulse_unit","次/分");
                data.put("Result_unit","");
                data.put("HighPressure_unit", "mmHg");
                data.put("LowPressure_unit", "mmHg");
                data.put("Pulse_unit", "次/分");
                data.put("Result_unit", "");
                data.put("HighPressure_name","(收缩压)高压");
                data.put("LowPressure_name","(舒张压)低压");
                data.put("Pulse_name","脉搏");
                data.put("Result_name","结论:-1、低压,0、正常,1、正常高压 2、轻度高压 3、中度高压 4、重度高压");
                data.put("HighPressure_name", "(收缩压)高压");
                data.put("LowPressure_name", "(舒张压)低压");
                data.put("Pulse_name", "脉搏");
                data.put("Result_name", "结论:-1、低压,0、正常,1、正常高压 2、轻度高压 3、中度高压 4、重度高压");
            }
            // 血氧
            if (boMap != null) {
@ -301,23 +300,23 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("EndTime", boMap.get("EndTime") == null ? "" : boMap.get("EndTime").toString());
                data.put("SecondCount", boMap.get("SecondCount") == null ? "" : boMap.get("SecondCount").toString());
                data.put("Oxygen_unit","%");
                data.put("OxygenList_unit","");
                data.put("Bpm_unit","");
                data.put("BpmList_unit","");
                data.put("Result_unit","");
                data.put("StartTime_unit","");
                data.put("EndTime_unit","");
                data.put("SecondCount_unit","");
                data.put("Oxygen_name","血氧值");
                data.put("OxygenList_name","血氧列表值");
                data.put("Bpm_name","脉率值");
                data.put("BpmList_name","脉率列表值");
                data.put("Result_name","结论:-1、低血氧,0、正常血氧");
                data.put("StartTime_name","开始时间");
                data.put("EndTime_name","结束时间");
                data.put("SecondCount_name","总测量秒数");
                data.put("Oxygen_unit", "%");
                data.put("OxygenList_unit", "");
                data.put("Bpm_unit", "");
                data.put("BpmList_unit", "");
                data.put("Result_unit", "");
                data.put("StartTime_unit", "");
                data.put("EndTime_unit", "");
                data.put("SecondCount_unit", "");
                data.put("Oxygen_name", "血氧值");
                data.put("OxygenList_name", "血氧列表值");
                data.put("Bpm_name", "脉率值");
                data.put("BpmList_name", "脉率列表值");
                data.put("Result_name", "结论:-1、低血氧,0、正常血氧");
                data.put("StartTime_name", "开始时间");
                data.put("EndTime_name", "结束时间");
                data.put("SecondCount_name", "总测量秒数");
            }
@ -329,22 +328,22 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Result", ecgMap.get("Result") == null ? "" : ecgMap.get("Result").toString());
                data.put("Analysis", ecgMap.get("Analysis") == null ? "" : ecgMap.get("Analysis").toString());
                data.put("Hr_unit","次/分");
                data.put("EcgData_unit","");
                data.put("nGain_unit","");
                data.put("Result_unit","(废除)");
                data.put("Analysis_unit","");
                data.put("Hr_unit", "次/分");
                data.put("EcgData_unit", "");
                data.put("nGain_unit", "");
                data.put("Result_unit", "(废除)");
                data.put("Analysis_unit", "");
                data.put("Hr_name","心率值");
                data.put("EcgData_name","心电图数据");
                data.put("nGain_name","增益");
                data.put("Result_name","  ");
                data.put("Analysis_name","结论:5025 对照说明详见附1");
                data.put("Hr_name", "心率值");
                data.put("EcgData_name", "心电图数据");
                data.put("nGain_name", "增益");
                data.put("Result_name", "  ");
                data.put("Analysis_name", "结论:5025 对照说明详见附1");
            }
            // 12导心电
           if (peecgMap != null) {
            if (peecgMap != null) {
                data.put("Hr", peecgMap.get("Hr") == null ? "" : peecgMap.get("Hr").toString());
                data.put("PAxis", peecgMap.get("PAxis") == null ? "" : peecgMap.get("PAxis").toString());
                data.put("QRSAxis", peecgMap.get("QRSAxis") == null ? "" : peecgMap.get("QRSAxis").toString());
@ -367,32 +366,32 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                    data.put("filepath",resPath);
                }*/
                data.put("Hr_unit","次/分");
                data.put("PAxis_unit","");
                data.put("QRSAxis_unit","");
                data.put("TAxis_unit","");
                data.put("PR_unit","ms");
                data.put("QRS_unit","ms");
                data.put("QT_unit","ms");
                data.put("QTc_unit","ms");
                data.put("RV5_unit","mV");
                data.put("SV1_unit","mV");
                data.put("EcgData_unit","");
                data.put("Result_unit","");
                data.put("Hr_name","心率值");
                data.put("PAxis_name","P轴");
                data.put("QRSAxis_name","QRS轴");
                data.put("TAxis_name","T轴");
                data.put("PR_name","PR 间期");
                data.put("QRS_name","QRS 时限");
                data.put("QT_name","QT 间期");
                data.put("QTc_name","QTc 间期");
                data.put("RV5_name","RV5 幅度");
                data.put("SV1_name","SV1 幅度");
                data.put("EcgData_name","心电图数据");
                data.put("EcgImg_name","心电波形图图片");
                data.put("Result_name","心电结论");
                data.put("Hr_unit", "次/分");
                data.put("PAxis_unit", "");
                data.put("QRSAxis_unit", "");
                data.put("TAxis_unit", "");
                data.put("PR_unit", "ms");
                data.put("QRS_unit", "ms");
                data.put("QT_unit", "ms");
                data.put("QTc_unit", "ms");
                data.put("RV5_unit", "mV");
                data.put("SV1_unit", "mV");
                data.put("EcgData_unit", "");
                data.put("Result_unit", "");
                data.put("Hr_name", "心率值");
                data.put("PAxis_name", "P轴");
                data.put("QRSAxis_name", "QRS轴");
                data.put("TAxis_name", "T轴");
                data.put("PR_name", "PR 间期");
                data.put("QRS_name", "QRS 时限");
                data.put("QT_name", "QT 间期");
                data.put("QTc_name", "QTc 间期");
                data.put("RV5_name", "RV5 幅度");
                data.put("SV1_name", "SV1 幅度");
                data.put("EcgData_name", "心电图数据");
                data.put("EcgImg_name", "心电波形图图片");
                data.put("Result_name", "心电结论");
            }
@ -401,11 +400,11 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Temperature", temperatureMap.get("Temperature") == null ? "" : temperatureMap.get("Temperature").toString());
                data.put("Result", temperatureMap.get("Result") == null ? "" : temperatureMap.get("Result").toString());
                data.put("Temperature_unit","℃");
                data.put("Result_unit","");
                data.put("Temperature_unit", "℃");
                data.put("Result_unit", "");
                data.put("Temperature_name","体温值");
                data.put("Result_name","结论:-1、低温,0、正常,1、高温");
                data.put("Temperature_name", "体温值");
                data.put("Result_name", "结论:-1、低温,0、正常,1、高温");
            }
@ -416,15 +415,15 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Whr", whrMap.get("Whr") == null ? "" : whrMap.get("Whr").toString());
                data.put("Result", whrMap.get("Result") == null ? "" : whrMap.get("Result").toString());
                data.put("Waistline_unit","cm");
                data.put("Hipline_unit","cm");
                data.put("Whr_unit","%");
                data.put("Result_unit","");
                data.put("Waistline_unit", "cm");
                data.put("Hipline_unit", "cm");
                data.put("Whr_unit", "%");
                data.put("Result_unit", "");
                data.put("Waistline_name","腰围");
                data.put("Hipline_name","臀围");
                data.put("Whr_name","腰臀比");
                data.put("Result_name","结论: 0:正常,1:上身肥胖,2:下身肥胖");
                data.put("Waistline_name", "腰围");
                data.put("Hipline_name", "臀围");
                data.put("Whr_name", "腰臀比");
                data.put("Result_name", "结论: 0:正常,1:上身肥胖,2:下身肥胖");
            }
            // 血糖
            if (bloodSugarMap != null) {
@ -433,23 +432,23 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Result", bloodSugarMap.get("Result") == null ? "" : bloodSugarMap.get("Result").toString());
                data.put("BloodSugar_name","血糖值");
                data.put("BloodsugarType_name","血糖类型:1、餐前血糖,2、餐后血糖,3、随机血糖");
                data.put("Result_name","结论:-1、低血糖,0、正常,1、偏高 2、高");
                data.put("BloodSugar_name", "血糖值");
                data.put("BloodsugarType_name", "血糖类型:1、餐前血糖,2、餐后血糖,3、随机血糖");
                data.put("Result_name", "结论:-1、低血糖,0、正常,1、偏高 2、高");
                data.put("BloodSugar_unit","mmol/L");
                data.put("BloodsugarType_unit","");
                data.put("Result_unit","");
                data.put("BloodSugar_unit", "mmol/L");
                data.put("BloodsugarType_unit", "");
                data.put("Result_unit", "");
            }
            // 血尿酸
            if (uaMap != null) {
                data.put("Ua", uaMap.get("Ua") == null ? "" : uaMap.get("Ua").toString());
                data.put("Result", uaMap.get("Result") == null ? "" : uaMap.get("Result").toString());
                data.put("Ua_unit","mmol/L");
                data.put("Result_unit","");
                data.put("Ua_name","尿酸值");
                data.put("Result_name","结论:-1、低,0、正常,1、高");
                data.put("Ua_unit", "mmol/L");
                data.put("Result_unit", "");
                data.put("Ua_name", "尿酸值");
                data.put("Result_name", "结论:-1、低,0、正常,1、高");
            }
            // 总胆固醇
@ -457,11 +456,11 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Chol", cholMap.get("Chol") == null ? "" : cholMap.get("Chol").toString());
                data.put("Result", cholMap.get("Result") == null ? "" : cholMap.get("Result").toString());
                data.put("Chol_unit","mmol/L");
                data.put("Result_unit","");
                data.put("Chol_unit", "mmol/L");
                data.put("Result_unit", "");
                data.put("Chol_name","总胆固醇值");
                data.put("Result_name","结论:-1、低,0、正常,1、高  2、过高");
                data.put("Chol_name", "总胆固醇值");
                data.put("Result_name", "结论:-1、低,0、正常,1、高  2、过高");
            }
            // 血脂
@ -473,19 +472,19 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("CalcLdl", bloodFatMap.get("CalcLdl") == null ? "" : bloodFatMap.get("CalcLdl").toString());
                data.put("Result", bloodFatMap.get("Result") == null ? "" : bloodFatMap.get("Result").toString());
                data.put("TChol_unit","mmol/L");
                data.put("HdlChol_unit","mmol/L");
                data.put("Trig_unit","mmol/L");
                data.put("TcHdl_unit","");
                data.put("CalcLdl_unit","mmol/L");
                data.put("Result_unit","");
                data.put("TChol_unit", "mmol/L");
                data.put("HdlChol_unit", "mmol/L");
                data.put("Trig_unit", "mmol/L");
                data.put("TcHdl_unit", "");
                data.put("CalcLdl_unit", "mmol/L");
                data.put("Result_unit", "");
                data.put("TChol_name","总胆固醇");
                data.put("HdlChol_name","高密度蛋白");
                data.put("Trig_name","甘油三酯");
                data.put("TcHdl_name","血脂比值");
                data.put("CalcLdl_name","低密度蛋白");
                data.put("Result_name","结论:-1、低,0、正常,1、高");
                data.put("TChol_name", "总胆固醇");
                data.put("HdlChol_name", "高密度蛋白");
                data.put("Trig_name", "甘油三酯");
                data.put("TcHdl_name", "血脂比值");
                data.put("CalcLdl_name", "低密度蛋白");
                data.put("Result_name", "结论:-1、低,0、正常,1、高");
            }
            // 心血管功能
@ -503,31 +502,31 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("PAWP", cardiovascularMap.get("PAWP") == null ? "" : cardiovascularMap.get("PAWP").toString());
                data.put("N", cardiovascularMap.get("N") == null ? "" : cardiovascularMap.get("N").toString());
                data.put("HeartFunction1_name","心脏功能");
                data.put("VascularCondition1_name","心血管状况");
                data.put("HeartFunction2_name","心脏功能-简化数据");
                data.put("VascularCondition2_name","心血管状况-简化数据");
                data.put("Result_name","诊断结果");
                data.put("SV_name","SV");
                data.put("CO_name","CO");
                data.put("HOV_name","HOV");
                data.put("CMBV_name","CMBV");
                data.put("TPR_name","TPR");
                data.put("PAWP_name","PAWP");
                data.put("N_name","N");
                data.put("HeartFunction1_unit","");
                data.put("VascularCondition1_unit","");
                data.put("HeartFunction2_unit","");
                data.put("VascularCondition2_unit","");
                data.put("Result_unit","");
                data.put("SV_unit","");
                data.put("CO_unit","");
                data.put("HOV_unit","");
                data.put("CMBV_unit","");
                data.put("TPR_unit","");
                data.put("PAWP_unit","");
                data.put("N_unit","");
                data.put("HeartFunction1_name", "心脏功能");
                data.put("VascularCondition1_name", "心血管状况");
                data.put("HeartFunction2_name", "心脏功能-简化数据");
                data.put("VascularCondition2_name", "心血管状况-简化数据");
                data.put("Result_name", "诊断结果");
                data.put("SV_name", "SV");
                data.put("CO_name", "CO");
                data.put("HOV_name", "HOV");
                data.put("CMBV_name", "CMBV");
                data.put("TPR_name", "TPR");
                data.put("PAWP_name", "PAWP");
                data.put("N_name", "N");
                data.put("HeartFunction1_unit", "");
                data.put("VascularCondition1_unit", "");
                data.put("HeartFunction2_unit", "");
                data.put("VascularCondition2_unit", "");
                data.put("Result_unit", "");
                data.put("SV_unit", "");
                data.put("CO_unit", "");
                data.put("HOV_unit", "");
                data.put("CMBV_unit", "");
                data.put("TPR_unit", "");
                data.put("PAWP_unit", "");
                data.put("N_unit", "");
            }
            // 骨密度
@ -545,31 +544,31 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("PAB", bmdMap.get("PAB") == null ? "" : bmdMap.get("PAB").toString());
                data.put("Result", bmdMap.get("Result") == null ? "" : bmdMap.get("Result").toString());
                data.put("TSCORE_unit","");
                data.put("ZSCORE_unit","");
                data.put("OI_unit","");
                data.put("BQI_unit","");
                data.put("SOS_unit","(m/s)");
                data.put("YOUNG_ADULT_unit","");
                data.put("AGE_MATCHED_unit","");
                data.put("BUA_unit","");
                data.put("EOA_unit","");
                data.put("RRF_unit","");
                data.put("PAB_unit","");
                data.put("Result_unit","");
                data.put("TSCORE_name","T值,受试者的数值与年轻健康成人的骨密度平均值的标准差");
                data.put("ZSCORE_name","Z值,受试者的数值与同年龄人群骨密度的平均值的标准差");
                data.put("OI_name","骨质指数,数值越大表示骨密度越高");
                data.put("BQI_name","骨质指数,数值越大表示骨密度越高");
                data.put("SOS_name","超声声速");
                data.put("YOUNG_ADULT_name","成人百分比");
                data.put("AGE_MATCHED_name","年龄百分比");
                data.put("BUA_name","BUA");
                data.put("EOA_name","预期发生骨质疏松的年龄");
                data.put("RRF_name","相对骨折风险");
                data.put("PAB_name","骨骼的生理年龄");
                data.put("Result_name","诊断结果:-2、骨强度不足,-1、骨质疏松,0、正常");
                data.put("TSCORE_unit", "");
                data.put("ZSCORE_unit", "");
                data.put("OI_unit", "");
                data.put("BQI_unit", "");
                data.put("SOS_unit", "(m/s)");
                data.put("YOUNG_ADULT_unit", "");
                data.put("AGE_MATCHED_unit", "");
                data.put("BUA_unit", "");
                data.put("EOA_unit", "");
                data.put("RRF_unit", "");
                data.put("PAB_unit", "");
                data.put("Result_unit", "");
                data.put("TSCORE_name", "T值,受试者的数值与年轻健康成人的骨密度平均值的标准差");
                data.put("ZSCORE_name", "Z值,受试者的数值与同年龄人群骨密度的平均值的标准差");
                data.put("OI_name", "骨质指数,数值越大表示骨密度越高");
                data.put("BQI_name", "骨质指数,数值越大表示骨密度越高");
                data.put("SOS_name", "超声声速");
                data.put("YOUNG_ADULT_name", "成人百分比");
                data.put("AGE_MATCHED_name", "年龄百分比");
                data.put("BUA_name", "BUA");
                data.put("EOA_name", "预期发生骨质疏松的年龄");
                data.put("RRF_name", "相对骨折风险");
                data.put("PAB_name", "骨骼的生理年龄");
                data.put("Result_name", "诊断结果:-2、骨强度不足,-1、骨质疏松,0、正常");
            }
            // 酒精浓度
@ -580,17 +579,17 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("errcode", alcoholMap.get("errcode") == null ? "" : alcoholMap.get("errcode").toString());
                data.put("errinfo", alcoholMap.get("errinfo") == null ? "" : alcoholMap.get("errinfo").toString());
                data.put("Alcohol_name","酒精浓度值(单位 mg/100ml)");
                data.put("Result_name","0:正常 1:饮酒 2:醉酒");
                data.put("AlcoholImg_name","(双佳服务器上传的是图片地址,其它是图片二进制)Base64字符串");
                data.put("errcode_name","(-10:未找到图片 ,-11: 上传异常,-12 服务器返回空值;其它服务器返回)错误代码");
                data.put("errinfo_name","错误信息");
                data.put("Alcohol_name", "酒精浓度值(单位 mg/100ml)");
                data.put("Result_name", "0:正常 1:饮酒 2:醉酒");
                data.put("AlcoholImg_name", "(双佳服务器上传的是图片地址,其它是图片二进制)Base64字符串");
                data.put("errcode_name", "(-10:未找到图片 ,-11: 上传异常,-12 服务器返回空值;其它服务器返回)错误代码");
                data.put("errinfo_name", "错误信息");
                data.put("Alcohol_unit","");
                data.put("Result_unit","");
                data.put("AlcoholImg_unit","");
                data.put("errcode_unit","");
                data.put("errinfo_unit","");
                data.put("Alcohol_unit", "");
                data.put("Result_unit", "");
                data.put("AlcoholImg_unit", "");
                data.put("errcode_unit", "");
                data.put("errinfo_unit", "");
            }
            // 肺活量
@ -604,23 +603,23 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("FEF2575", lungMap.get("FEF2575") == null ? "" : lungMap.get("FEF2575").toString());
                data.put("Result", lungMap.get("Result") == null ? "" : lungMap.get("Result").toString());
                data.put("Lung_unit","");
                data.put("FVC_unit","");
                data.put("FEV1_unit","");
                data.put("PEF_unit","");
                data.put("FEF25_unit","");
                data.put("FEF75_unit","");
                data.put("FEF2575_unit","");
                data.put("Result_unit","");
                data.put("Lung_name","单位 ml");
                data.put("FVC_name","用力肺活量");
                data.put("FEV1_name","用力呼气1秒量");
                data.put("PEF_name","呼气峰值流速");
                data.put("FEF25_name","25% 肺活量时的用力呼气流速");
                data.put("FEF75_name","75% 肺活量时的用力呼气流速");
                data.put("FEF2575_name","25% 肺活量到75%肺活量之间的平均呼气流速");
                data.put("Result_name","结果(暂无)");
                data.put("Lung_unit", "");
                data.put("FVC_unit", "");
                data.put("FEV1_unit", "");
                data.put("PEF_unit", "");
                data.put("FEF25_unit", "");
                data.put("FEF75_unit", "");
                data.put("FEF2575_unit", "");
                data.put("Result_unit", "");
                data.put("Lung_name", "单位 ml");
                data.put("FVC_name", "用力肺活量");
                data.put("FEV1_name", "用力呼气1秒量");
                data.put("PEF_name", "呼气峰值流速");
                data.put("FEF25_name", "25% 肺活量时的用力呼气流速");
                data.put("FEF75_name", "75% 肺活量时的用力呼气流速");
                data.put("FEF2575_name", "25% 肺活量到75%肺活量之间的平均呼气流速");
                data.put("Result_name", "结果(暂无)");
            }
            // 血红蛋白
@ -629,13 +628,13 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("Hct", hbMap.get("Hct") == null ? "" : hbMap.get("Hct").toString());
                data.put("Result", hbMap.get("Result") == null ? "" : hbMap.get("Result").toString());
                data.put("Hb_unit","mmol/L");
                data.put("Hct_unit","%");
                data.put("Result_unit","");
                data.put("Hb_unit", "mmol/L");
                data.put("Hct_unit", "%");
                data.put("Result_unit", "");
                data.put("Hb_name","血红蛋白值");
                data.put("Hct_name","红细胞比容");
                data.put("Result_name","诊断结果:-1、血红蛋白偏低,0、正常,1血红蛋白偏高");
                data.put("Hb_name", "血红蛋白值");
                data.put("Hct_name", "红细胞比容");
                data.put("Result_name", "诊断结果:-1、血红蛋白偏低,0、正常,1血红蛋白偏高");
            }
            // 尿液分析
@ -656,66 +655,66 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
                data.put("UCA", urinalysisMap.get("UCA") == null ? "" : urinalysisMap.get("UCA").toString());
                data.put("Result", urinalysisMap.get("Result") == null ? "" : urinalysisMap.get("Result").toString());
                data.put("URO_unit","");
                data.put("BLD_unit","");
                data.put("BIL_unit","");
                data.put("KET_unit","");
                data.put("LEU_unit","");
                data.put("GLU_unit","");
                data.put("PRO_unit","");
                data.put("PH_unit","");
                data.put("NIT_unit","");
                data.put("SG_unit","");
                data.put("VC_unit","");
                data.put("MAL_unit","");
                data.put("CR_unit","");
                data.put("UCA_unit","");
                data.put("Result_unit","");
                data.put("URO_name","尿胆原");
                data.put("BLD_name","潜血");
                data.put("BIL_name","胆红素");
                data.put("KET_name","酮体");
                data.put("LEU_name","白细胞");
                data.put("GLU_name","葡萄糖");
                data.put("PRO_name","蛋白质");
                data.put("PH_name","酸碱度");
                data.put("NIT_name","亚硝酸盐");
                data.put("SG_name","比重");
                data.put("VC_name","维生素");
                data.put("MAL_name","微白蛋白");
                data.put("CR_name","肌酐");
                data.put("UCA_name","钙离子");
                data.put("Result_name","结果");
                data.put("URO_unit", "");
                data.put("BLD_unit", "");
                data.put("BIL_unit", "");
                data.put("KET_unit", "");
                data.put("LEU_unit", "");
                data.put("GLU_unit", "");
                data.put("PRO_unit", "");
                data.put("PH_unit", "");
                data.put("NIT_unit", "");
                data.put("SG_unit", "");
                data.put("VC_unit", "");
                data.put("MAL_unit", "");
                data.put("CR_unit", "");
                data.put("UCA_unit", "");
                data.put("Result_unit", "");
                data.put("URO_name", "尿胆原");
                data.put("BLD_name", "潜血");
                data.put("BIL_name", "胆红素");
                data.put("KET_name", "酮体");
                data.put("LEU_name", "白细胞");
                data.put("GLU_name", "葡萄糖");
                data.put("PRO_name", "蛋白质");
                data.put("PH_name", "酸碱度");
                data.put("NIT_name", "亚硝酸盐");
                data.put("SG_name", "比重");
                data.put("VC_name", "维生素");
                data.put("MAL_name", "微白蛋白");
                data.put("CR_name", "肌酐");
                data.put("UCA_name", "钙离子");
                data.put("Result_name", "结果");
            }
            data.put("hbalc","");
            data.put("hbalc_unit","");
            data.put("left_eye","");
            data.put("left_eye_unit","");
            data.put("right_eye","");
            data.put("right_eye_unit","");
            data.put("hbalc", "");
            data.put("hbalc_unit", "");
            data.put("left_eye", "");
            data.put("left_eye_unit", "");
            data.put("right_eye", "");
            data.put("right_eye_unit", "");
            jsonArray.add(data);
            params.put("data", jsonArray);
            str = dataInputService.inputBodySignsData(params.toString());
            JSONObject result = JSONObject.parseObject(str);
            if (StringUtils.endsWithIgnoreCase(ConstantUtils.FAIL,result.getString("response"))) {
            if (StringUtils.endsWithIgnoreCase(ConstantUtils.FAIL, result.getString("response"))) {
                Map res = new HashMap();
                res.put("success", "false");
                res.put("message", result.getString("msg"));
                strResult = objectMapper.writeValueAsString(res);
                return strResult;
            }else{
            } else {
                Map res = new HashMap();
                res.put("success", "true");
                res.put("message", "体征信息上传成功。");
                JSONArray ridRes = new JSONArray();
                ridRes = (JSONArray)result.get("rid");
                ridRes = (JSONArray) result.get("rid");
                String rid = ridRes.get(0).toString();
                res.put("rid", rid);
@ -731,22 +730,24 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
    /**
     * 基于奕拓小屋上传的体征数据,进行解析入库  V2.0 版本
     *
     * @param jsonData
     * @return
     */
    @PostMapping(value = "/yitouxiaowu" ,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = "/yitouxiaowu", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "奕拓体征数据解析入库", notes = "奕拓体征数据解析入库")
    public Envelop updateDeviceData(
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData)throws Exception {
            @RequestBody String jsonData) throws Exception {
        boolean res = iotAnalyzerService.analyzerMapM(jsonData);
        if(res){
        if (res) {
            return success("体征数据上传成功");
        }else {
        } else {
            return failed("体征数据上传失败");
        }
    }
}

+ 28 - 3
svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/IotAnalyzerService.java

@ -1,15 +1,19 @@
package com.yihu.iot.service.analyzer;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.util.excel.ExcelUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import java.util.*;
/**
 * @author cws on 2019/6/16
@ -18,15 +22,34 @@ import java.util.Map;
public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> {
    private Logger logger = LoggerFactory.getLogger(IotAnalyzerService.class);
    private Map<String,Object> codeNameMap = new HashMap<>();
    @Autowired
    private WlyyIotDDao wlyyIotDDao;
    @Autowired
    private WlyyIotMDao wlyyIotMDao;
    @Autowired
    private WlyyIotTzDictDao wlyyIotTzDictDao;
    @Autowired
    ObjectMapper objectMapper;
    @PostConstruct
    public void init() {
        if (codeNameMap.isEmpty()) {
            Iterable<WlyyIotTzDict> iterable = wlyyIotTzDictDao.findAll();
            iterable.forEach(
                    oneElement -> {
                        codeNameMap.put(oneElement.getCode(), oneElement.getName());
                    }
            );
        }
    }
    /**
     * 针对上传的体数据进行基础数据的解析,进行主表数据的存储
     * @param jsonData
@ -129,4 +152,6 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> {
            return null;
        }
    }
}

+ 1 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/WlyyIotDDao.java

@ -11,4 +11,5 @@ import java.util.Map;
public interface WlyyIotDDao extends PagingAndSortingRepository<WlyyIotD, Integer>, JpaSpecificationExecutor<WlyyIotD>  {
    List<WlyyIotD> queryByMidAndType(String mid,String type);
}

+ 4 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/WlyyIotMDao.java

@ -3,6 +3,10 @@ package com.yihu.iot.service.analyzer;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface WlyyIotMDao extends PagingAndSortingRepository<WlyyIotM, Integer>, JpaSpecificationExecutor<WlyyIotM>  {
    List<WlyyIotM> queryByIdCardNo(String idcard);
}

+ 3 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/SvrWlyySpecialistApplication.java

@ -8,7 +8,9 @@ import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
/**
 *
 */
@SpringBootApplication
@EnableAspectJAutoProxy
public class SvrWlyySpecialistApplication  extends SpringBootServletInitializer {

+ 1 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java

@ -15,8 +15,8 @@ import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.service.FileUploadService;
import com.yihu.jw.service.SpecialistHospitalServiceItemService;
import com.yihu.jw.service.SpecialistService;
import com.yihu.jw.util.HttpClientUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;

+ 24 - 24
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/util/ImUtill.java

@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
public class ImUtill {
    @Autowired
    private HttpClientUtil HttpClientUtil;
    private SpHttpClientUtil SpHttpClientUtil;
    @Value("${im.im_list_get}")
    private String im_host;
@ -75,7 +75,7 @@ public class ImUtill {
        params.put("sender_name", receiverId);
        params.put("content_type", contentType);
        params.put("content", content);
        String response = HttpClientUtil.postBody(imAddr, params);
        String response = SpHttpClientUtil.postBody(imAddr, params);
        return response;
    }
@ -101,7 +101,7 @@ public class ImUtill {
        if (reply != null) {
            imAddr += ("&reply=" + reply);
        }
        String response = HttpClientUtil.get(imAddr, "UTF-8");
        String response = SpHttpClientUtil.get(imAddr, "UTF-8");
        return response;
    }
@ -110,7 +110,7 @@ public class ImUtill {
        JSONObject params = new JSONObject();
        params.put("topic_id", topicId);
        params.put("data", jsonValue);
        HttpClientUtil.putBody(imAddr, params);
        SpHttpClientUtil.putBody(imAddr, params);
    }
    /**
@ -138,7 +138,7 @@ public class ImUtill {
        if (reply != null) {
            imAddr += ("&reply=" + reply);
        }
        String response = HttpClientUtil.get(imAddr, "UTF-8");
        String response = SpHttpClientUtil.get(imAddr, "UTF-8");
        return response;
    }
@ -163,7 +163,7 @@ public class ImUtill {
        if (reply != null) {
            imAddr += ("&reply=" + reply);
        }
        String response = HttpClientUtil.get(imAddr, "UTF-8");
        String response = SpHttpClientUtil.get(imAddr, "UTF-8");
        return response;
    }
@ -198,7 +198,7 @@ public class ImUtill {
        if (endTime != null) {
            imAddr += ("&endTime=" + endTime);
        }
        String response = HttpClientUtil.get(imAddr, "UTF-8");
        String response = SpHttpClientUtil.get(imAddr, "UTF-8");
        return response;
    }
@ -231,7 +231,7 @@ public class ImUtill {
        if (endTime != null) {
            imAddr += ("&endTime=" + endTime);
        }
        String response = HttpClientUtil.get(imAddr, "UTF-8");
        String response = SpHttpClientUtil.get(imAddr, "UTF-8");
        return response;
    }
@ -251,7 +251,7 @@ public class ImUtill {
        params.put("content", content);
        params.put("session_id", sessionId);
        params.put("business_type", businessType);
        String response = HttpClientUtil.postBody(imAddr, params);
        String response = SpHttpClientUtil.postBody(imAddr, params);
        return response;
    }
@ -264,7 +264,7 @@ public class ImUtill {
    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);
        String response = SpHttpClientUtil.postBody(imAddr, params);
        return response;
    }
@ -277,7 +277,7 @@ public class ImUtill {
    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);
        String response = SpHttpClientUtil.postBody(imAddr, params);
        return response;
    }
@ -298,7 +298,7 @@ public class ImUtill {
        params.put("content", content);
        params.put("topic_id", topicId);
        params.put("agent", agent);
        String response = HttpClientUtil.postBody(url, params);
        String response = SpHttpClientUtil.postBody(url, params);
        return response;
    }
@ -318,7 +318,7 @@ public class ImUtill {
        params.put("into_user", intoUser);
        params.put("into_user_name", intoUserName);
        params.put("content", content);
        String response = HttpClientUtil.postBody(url, params);
        String response = SpHttpClientUtil.postBody(url, params);
        return response;
    }
@ -337,7 +337,7 @@ public class ImUtill {
        params.put("end_user", endUser);
        params.put("end_user_name", endUserName);
        params.put("topic_id", topicId);
        String ret = HttpClientUtil.postBody(imAddr, params);
        String ret = SpHttpClientUtil.postBody(imAddr, params);
        JSONObject obj = null;
        try {
            obj = new JSONObject(ret);
@ -358,7 +358,7 @@ public class ImUtill {
        String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participants/" + user;
        JSONObject params = new JSONObject();
        params.put("user", user + ":" + 0);
        HttpClientUtil.putBody(imAddr, params);
        SpHttpClientUtil.putBody(imAddr, params);
    }
    /**
@ -377,7 +377,7 @@ public class ImUtill {
        params.put("messages", messages.toString());
        params.put("session_id", sessionId);
        params.put("session_type", sessionType);
        String ret = HttpClientUtil.postBody(imAddr, params);
        String ret = SpHttpClientUtil.postBody(imAddr, params);
        JSONObject obj = null;
        try {
            obj = new JSONObject(ret);
@ -394,7 +394,7 @@ public class ImUtill {
        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");
        String ret = SpHttpClientUtil.get(url, "UTF-8");
        JSONObject obj = null;
        try {
            obj = new JSONObject(ret);
@ -417,7 +417,7 @@ public class ImUtill {
        params.put("session_name", sessionName);
        params.put("session_type", sessionType);
        params.put("session_id", sessionId);
        String ret = HttpClientUtil.postBody(imAddr, params);
        String ret = SpHttpClientUtil.postBody(imAddr, params);
        JSONObject obj = null;
        try {
            obj = new JSONObject(ret);
@ -454,7 +454,7 @@ public class ImUtill {
                + "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");
            String ret = SpHttpClientUtil.get(url, "UTF-8");
            JSONObject obj = new JSONObject(ret);
            if (obj.getInt("status") == -1) {
                throw new RuntimeException(obj.getString("message"));
@ -470,7 +470,7 @@ public class ImUtill {
    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");
            String ret = SpHttpClientUtil.get(url, "UTF-8");
            JSONArray obj = new JSONArray(ret);
            return obj;
        } catch (Exception e) {
@ -494,7 +494,7 @@ public class ImUtill {
            params.put("user_id", userId);
            params.put("old_user_id", oldUserId);
            params.put("session_id", sessionId);
            String ret = HttpClientUtil.postBody(url, params);
            String ret = SpHttpClientUtil.postBody(url, params);
            JSONObject obj = new JSONObject(ret);
            if (obj.getInt("status") == -1) {
                throw new RuntimeException("人员更换失败!");
@ -516,7 +516,7 @@ public class ImUtill {
    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");
            String ret = SpHttpClientUtil.get(url, "utf-8");
            JSONObject obj = new JSONObject(ret);
            if (obj.getInt("status") == -1) {
                throw new RuntimeException("获取议题失败!");
@ -538,7 +538,7 @@ public class ImUtill {
    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");
            String ret = SpHttpClientUtil.get(url, "utf-8");
            return new JSONArray(ret);
        } catch (Exception e) {
            throw new RuntimeException("获取议题失败!");
@ -555,7 +555,7 @@ public class ImUtill {
    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");
            String ret = SpHttpClientUtil.get(url, "utf-8");
            return new JSONArray(ret);
        } catch (Exception e) {
            throw new RuntimeException("获取议题失败!");

+ 1 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/util/HttpClientUtil.java

@ -20,7 +20,7 @@ import java.io.IOException;
 * Created by hmf on 2018/9/3.
 */
@Component
public class HttpClientUtil {
public class SpHttpClientUtil {
    public String postBody(String url, JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();

+ 1 - 1
svr/svr-wlyy-specialist/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-wlyy-specialist
    name: svr-wlyy-specialist-lyx
  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>