Browse Source

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

humingfen 5 years ago
parent
commit
b3b14e0ce3
17 changed files with 1021 additions and 126 deletions
  1. 82 4
      business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorService.java
  2. 75 4
      business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java
  3. 7 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  4. 5 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxAccessTokenDao.java
  5. 4 2
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java
  6. 59 1
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WxAccessTokenService.java
  7. 19 4
      business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java
  8. 1 1
      business/es-service/src/main/java/com/yihu/jw/es/es/ElasticFactory.java
  9. 360 20
      business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java
  10. 141 67
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  11. 11 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  12. 22 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/config/DoctorServiceEndPoint.java
  13. 1 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  14. 49 14
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  15. 3 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  16. 176 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java
  17. 6 6
      svr/svr-internet-hospital/src/main/resources/application.yml

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

@ -10,6 +10,8 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
@ -21,6 +23,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Random;
@Service
public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDao> {
@ -39,7 +42,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    /**
     * 查询医生信息分页列表
     * 查询医生信息分页列表.
     * @param city
     * @param hospital
     * @param status
@ -47,14 +50,14 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
     * @param page
     * @param pageSize
     */
    public Envelop queryList(String city, String hospital, String status, String name, String type,String typeCode, int page, int pageSize){
    public Envelop queryList(String city, String hospital, String status, String name, String type,String typeCode,String dept, int page, int pageSize){
        Map<String,Object> params = new HashedMap();
        String sqlTotal ="SELECT " +
                " COUNT(1) AS \"total\" " +
                " FROM " +
                " base_doctor a " +
                " JOIN base_doctor_hospital b ON a.id = b.doctor_code " +
                " LEFT JOIN wlyy_charge_dict e ON a.charge_type = e.charge_type " +
                " LEFT JOIN (SELECT * FROM wlyy_charge_dict t WHERE t.dept_type_code ='6') e ON a.charge_type = e.charge_type " +
                " LEFT JOIN base_doctor_mapping c ON a.id = c.doctor " +
                " WHERE " +
                " 1 = 1";
@ -84,6 +87,11 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            sqlTotal += " AND e.dept_type_code =:typeCode";
            params.put("typeCode",typeCode);
        }
        if(StringUtils.isNotBlank(dept)){
            sqlTotal += " AND b.dept_code =:dept";
            params.put("dept",dept);
        }
        Long count = 0L;
        List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sqlTotal,params);
        if(count!=null){
@ -102,7 +110,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                " FROM " +
                " base_doctor a " +
                " JOIN base_doctor_hospital b ON a.id = b.doctor_code " +
                " LEFT JOIN wlyy_charge_dict e ON a.charge_type = e.charge_type " +
                " LEFT JOIN (SELECT * FROM wlyy_charge_dict t WHERE t.dept_type_code ='6') e ON a.charge_type = e.charge_type " +
                " LEFT JOIN base_doctor_mapping c ON a.id = c.doctor " +
                " WHERE 1=1";
        if (StringUtils.isNotBlank(city)){
@ -123,6 +131,9 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        if(StringUtils.isNotBlank(typeCode)){
            sql += " AND e.dept_type_code =:typeCode";
        }
        if(StringUtils.isNotBlank(dept)){
            sql += " AND b.dept_code =:dept";
        }
        logger.info("queryList sql:"+sql);
@ -194,6 +205,19 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return null;
    }
    public Boolean updateList(JSONArray jsonArray){
        if(jsonArray!=null&&jsonArray.size()>0){
            for(int i=0;i<jsonArray.size();i++){
                JSONObject doctor = jsonArray.getJSONObject(i);
                try {
                    updateInfo(doctor);
                }catch (Exception e){
                    logger.info("update doctor error:"+e.toString());
                }
            }
        }
        return true;
    }
    /**
     * 修改医生服务配置
@ -241,6 +265,17 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return true;
    }
    public Boolean updateInfo(JSONObject jsonObject)throws Exception{
        //取出数据
        String doctorId = jsonObject.get("doctorId").toString();
        String outpatientType = jsonObject.get("outpatientType").toString();
        logger.info("doctor:"+doctorId+" outpatientType:"+outpatientType);
        BaseDoctorDO doctorDO = baseDoctorDao.findOne(doctorId);
        doctorDO.setOutpatientType(outpatientType);
        baseDoctorDao.save(doctorDO);
        return true;
    }
    /**
     * 修改医生状态
@ -251,4 +286,47 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        baseDoctorDao.updateStatus(doctorId,status);
    }
    public Boolean updateDoctorPw(String id,String pw){
        BaseDoctorDO doctorDO = baseDoctorDao.findOne(id);
        //认证信息设置
        String salt = randomString(5);
        doctorDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
        doctorDO.setSalt(salt);
        baseDoctorDao.save(doctorDO);
        return true;
    }
    public String randomString(int length) {
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        StringBuffer buffer = new StringBuffer();
        Random random = new Random();
        for(int i = 0; i < length; ++i) {
            int pos = random.nextInt(str.length());
            buffer.append(str.charAt(pos));
        }
        return buffer.toString();
    }
//    public static void main(String ag[]){
//        String str = "[ " +
//                "{ " +
//                "\"title\":\"Java 开发\", " +
//                "\"edition\":3, " +
//                "\"author\":[\"smith\",\"张三\",\"李四\"] " +
//                "}, " +
//                "{ " +
//                "\"title\":\"Web 开发\", " +
//                "\"edition\":3, " +
//                "\"author\":[\"Allen\",\"王五\",\"赵六\"] " +
//                "} " +
//                "]";
//        JSONArray json = JSONArray.fromObject(str);
//        for(int i=0;i<json.size();i++){
//            JSONObject doctor = json.getJSONObject(i);
//            doctor.getString("doctor");
//        }
//    }
}

+ 75 - 4
business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java

@ -3,7 +3,6 @@ package com.yihu.jw.file_upload;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.exception.business.file_upload.*;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
@ -23,9 +22,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.activation.MimetypesFileTypeMap;
import java.io.*;
import java.net.URLDecoder;
import java.nio.charset.Charset;
@ -217,10 +215,81 @@ public class FileUploadService {
        FastDFSUtil fastDFSUtil = new FastDFSUtil();
        String fileUrls = "";
        File f = new File(voices_Path);
        logger.info("语音文件转换file");
        if (f.exists()) {
            logger.info("语音文件转换file-start");
            FileInputStream input = new FileInputStream(f);
            MultipartFile multipartFile = new MockMultipartFile("file", f.getName(), "text/plain", IOUtils.toByteArray(input));
            String fileContenType = "text/plain";
            try {
                logger.info("获取文件类型--开始");
                fileContenType = new MimetypesFileTypeMap().getContentType(f);
                logger.info("获取文件类型--成功--fileContenType:"+fileContenType);
            } catch (Exception e) {
                logger.info("获取文件类型--失败:"+e.getMessage());
            }
            
            MultipartFile multipartFile = new MockMultipartFile("file", f.getName(), fileContenType, IOUtils.toByteArray(input));
            logger.info("语音文件转换file-转换-multipartFile");
            long size = multipartFile.getSize();
            if(size<=0){
//                map.put("uploadStatus",1);//size小于0
//                map.put("accessoryUrl",null);//
                return url;
            }
            String fileName = multipartFile.getOriginalFilename();
            String[] fs = fileName.split("\\.");
            String type = fs[1];
            logger.info("uploadImg type:"+type);
            //图片常见格式:bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp
//        List img = new ArrayList(Arrays.asList("bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp"));
//        if (!img.contains(type)) {
//            map.put("uploadStatus",2);//文件类型不对
//            map.put("accessoryUrl",null);//
//            return map;
//        }
            logger.info("语音文件转换file-转换-multipartFile-成功,开始调用i健康接口上传文件");
            String response = request(wlyyUrl + "/upload/chat", multipartFile, null);
            org.json.JSONObject rs = new org.json.JSONObject(response);
            Integer status = (Integer) rs.get("status");
            if (status == 200) {
                url = rs.get("urls") + "";
                logger.info("开始调用i健康接口上传文件成功:url:"+url);
//                map.put("uploadStatus", 0);//文件类型正确
//                map.put("accessory", url);//
                return url;
            }
            throw new Exception();
        }
        return url;
    }
    
    /**
     * 调用健康上传图片.
     * @param image_Path
     * @return
     * @throws Exception
     */
    public String uploadWxImage(String image_Path) throws Exception {
        String url = "";
        // 文件保存的临时路径
        FastDFSUtil fastDFSUtil = new FastDFSUtil();
        String fileUrls = "";
        File f = new File(image_Path);
        logger.info("图片文件转换file");
        if (f.exists()) {
            logger.info("图片文件转换file-start");
            FileInputStream input = new FileInputStream(f);
            String fileContenType = "text/plain";
            try {
                logger.info("获取文件类型--开始");
                fileContenType = new MimetypesFileTypeMap().getContentType(f);
                logger.info("获取文件类型--成功--fileContenType:"+fileContenType);
            } catch (Exception e) {
                logger.info("获取文件类型--失败:"+e.getMessage());
            }
            
            MultipartFile multipartFile = new MockMultipartFile("file", f.getName(), fileContenType, IOUtils.toByteArray(input));
            logger.info("图片文件转换file-转换-multipartFile");
            long size = multipartFile.getSize();
            if(size<=0){
//                map.put("uploadStatus",1);//size小于0
@ -238,11 +307,13 @@ public class FileUploadService {
//            map.put("accessoryUrl",null);//
//            return map;
//        }
            logger.info("图片文件转换file-转换-multipartFile-成功,开始调用i健康接口上传文件");
            String response = request(wlyyUrl + "/upload/chat", multipartFile, null);
            org.json.JSONObject rs = new org.json.JSONObject(response);
            Integer status = (Integer) rs.get("status");
            if (status == 200) {
                url = rs.get("urls") + "";
                logger.info("开始调用i健康接口上传文件成功:url:"+url);
//                map.put("uploadStatus", 0);//文件类型正确
//                map.put("accessory", url);//
                return url;

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

@ -1091,7 +1091,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param size
     * @return
     */
    public MixEnvelop findDoctorWithMouthWork(String orgCode,String dept,String chargeType,String date,Integer page,Integer size){
    public MixEnvelop findDoctorWithMouthWork(String orgCode,String dept,String chargeType,String date,String nameKey,Integer page,Integer size){
        String totalSql ="SELECT " +
                " count(1) AS total " +
@ -1106,6 +1106,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if(StringUtils.isNotBlank(dept)){
            totalSql+= " AND h.dept_code = '"+dept+"' " ;
        }
        if(StringUtils.isNotBlank(nameKey)){
            totalSql+= " AND d.name like '%"+nameKey+"%' " ;
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
@ -1135,6 +1138,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if(StringUtils.isNotBlank(dept)){
            sql+= " AND h.dept_code = '"+dept+"' " ;
        }
        if(StringUtils.isNotBlank(nameKey)){
            sql+= " AND d.name like '%"+nameKey+"%' " ;
        }
        sql += " LIMIT " + (page - 1) * size + "," + size + "";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){

+ 5 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxAccessTokenDao.java

@ -2,6 +2,7 @@ package com.yihu.jw.wechat.dao;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
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;
@ -14,4 +15,8 @@ public interface WxAccessTokenDao extends PagingAndSortingRepository<WxAccessTok
    @Query("from WxAccessTokenDO w where w.wechatId =?1 order by w.addTimestamp desc")
    List<WxAccessTokenDO> getWxAccessTokenById(String wechatId);
    
    @Modifying
    @Query("delete from WxAccessTokenDO p where p.wechatId=?1 ")
    void deleteByWechatId(String wechatId);
}

+ 4 - 2
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java

@ -58,7 +58,7 @@ public class WechatInfoService {
     */
    public String getJsapi_ticketByToken(String wxId) throws Exception {
        try {
            
            System.out.println("getJsapi_ticketByToken="+wxId);
            Iterable<JsApiTicket> jsapiTickets = null;
            WxWechatDO wxWechat = null;
            
@ -88,12 +88,13 @@ public class WechatInfoService {
            }else{
                token = wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
            }
            
            System.out.println("getticket_token:"+token);
            if (token != null) {
                String token_url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
                String params = "access_token=" + token + "&type=jsapi";
                String result = HttpUtil.sendGet(token_url, params);
                JSONObject json = new JSONObject(result);
                System.out.println("getticket:"+result);
                if (json.has("ticket")) {
                    String ticket = json.get("ticket").toString();
                    String expires_in = json.get("expires_in").toString();
@ -115,6 +116,7 @@ public class WechatInfoService {
                return null;
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
            throw new Exception(e.getMessage());
        }
    }

+ 59 - 1
business/base-service/src/main/java/com/yihu/jw/wechat/service/WxAccessTokenService.java

@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.transaction.Transactional;
import java.util.*;
/**
@ -105,7 +106,64 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
            return null;
        }
    }
    
    /**
     * wechatId 删除无效 wechatId
     * @param wechatId
     */
    @Transactional
    public void deleteByWechatId(String wechatId){
        wxAccessTokenDao.deleteByWechatId(wechatId);
    }
    
    /**
     * 过期后删掉accesstoken,  重新获取
     * @param wechatId
     * @return
     */
    @Transactional
    public String updateAccessToken(String wechatId){
        try {
            //根据wechatCode查找出appid和appSecret
            WxWechatDO wxWechat = wechatDao.findById(wechatId);
            String token_url = "https://api.weixin.qq.com/cgi-bin/token";
            String appId="";
            String appSecret="";
            appId = wxWechat.getAppId();
            appSecret = wxWechat.getAppSecret();
            if (StringUtils.isEmpty(appId)){
                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appId_is_null, ExceptionCode.common_error_params_code);
            }
            if (StringUtils.isEmpty(appSecret)){
                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appSecret_is_null, ExceptionCode.common_error_params_code);
            }
            Map<String, Object> params = new HashMap<>();
            params.put("grant_type", "client_credential");
            params.put("appid", appId);
            params.put("secret", appSecret);
            String result = HttpUtils.doGet(token_url, params).getContent();
            logger.info("--------------wechat token return:"+result+"---------------");
            JSONObject json = new JSONObject(result);
            if (json.has("access_token")) {
                String token = json.get("access_token").toString();
                String expires_in = json.get("expires_in").toString();
                WxAccessTokenDO newaccessToken = new WxAccessTokenDO();
                newaccessToken.setAccessToken(token);
                newaccessToken.setExpiresIn(Long.parseLong(expires_in));
                newaccessToken.setAddTimestamp(System.currentTimeMillis());
                newaccessToken.setCzrq(new Date());
                newaccessToken.setCode(UUID.randomUUID().toString().replace("-",""));
                newaccessToken.setWechatId(wechatId);
                wxAccessTokenDao.save(newaccessToken);
                return token;
            } else {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public WxAccessTokenDO getWxAccessTokenById(String wechatId) {
        try {

+ 19 - 4
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -393,6 +393,7 @@ public class WlyyBusinessService {
                        org.setTownName(h.getString("townName"));
                        org.setType("1");
                        org.setWinNo("-1");
                        org.setDel("1");
                        baseOrgDao.save(org);
                        addCount++;
                    }
@ -439,7 +440,7 @@ public class WlyyBusinessService {
            logger.info("doctors size:"+doctors.size());
            if(doctors!=null&&doctors.size()>0){
                //获取全部职称
                //获取全部职称.
                List<Map<String,Object>> dutys = findDutys();
                for(int i=0;i<doctors.size();i++){
@ -471,6 +472,21 @@ public class WlyyBusinessService {
                                doctor.setJobTitleName(jobName);
                                baseDoctorDao.save(doctor);
                                //更新机构科室信息
                                String orgCode =doctorJson.getString("hospital");
                                if(StringUtils.isNotBlank(orgCode)){
                                    List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByOrgCodeAndDoctorCode(orgCode,doctor.getId());
                                    if(hospitalDOs!=null&&hospitalDOs.size()>0){
                                        BaseDoctorHospitalDO hospitalDO = hospitalDOs.get(0);
                                        hospitalDO.setOrgCode(doctorJson.getString("hospital"));
                                        hospitalDO.setOrgName(doctorJson.getString("hospitalName"));
                                        hospitalDO.setDeptCode(doctorJson.getString("dept"));
                                        hospitalDO.setDeptName(doctorJson.getString("deptName"));
                                        baseDoctorHospitalDao.save(hospitalDO);
                                    }
                                }
                            } else {
                                BaseDoctorDO doctor = new BaseDoctorDO();
@ -487,7 +503,7 @@ public class WlyyBusinessService {
                                doctor.setCityName(doctorJson.getString("cityName"));
                                doctor.setExpertise(doctorJson.getString("expertise"));
                                doctor.setIntroduce(doctorJson.getString("introduce"));
                                doctor.setOutpatientType("zj");
                                //认证信息设置
                                String salt = randomString(5);
                                String pw = idcard.substring(idcard.length() - 6);
@ -515,13 +531,12 @@ public class WlyyBusinessService {
                                Integer level = doctorJson.getInteger("level");
                                BaseDoctorRoleDO role = new BaseDoctorRoleDO();
                                role.setDoctorCode(temp.getId());
                                if (level != null && level == 1) {
                                    role.setRoleCode("specialist");
                                } else {
                                    role.setRoleCode("generalDoctor");
                                }
                                role.setDoctorCode(temp.getId());
                                role.setRoleCode("generalDoctor");
                                baseDoctorRoleDao.save(role);

+ 1 - 1
business/es-service/src/main/java/com/yihu/jw/es/es/ElasticFactory.java

@ -110,7 +110,7 @@ public class ElasticFactory {
    /**
     * 9300
     * 厦门I健康版本不需要密码
     *
     * @throws UnknownHostException
     */
    private synchronized void initTranClient() throws UnknownHostException {

+ 360 - 20
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -164,13 +164,13 @@ public class StatisticsEsService {
            //问诊量表格
            //专家咨询数量
            List<SaveModel> specialistSaveModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level, "4", SaveModel.timeLevel_ZL,null,level2_type);
            List<SaveModel> specialistSaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1",null,level2_type);
            //协同门诊
            List<SaveModel> syngySaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"2",null,level2_type);
            List<SaveModel> syngySaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"12",null,level2_type);
            //图文复诊
            List<SaveModel> topicSaveModels = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1","1",null,level2_type);
            List<SaveModel> topicSaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"9",null,level2_type);
            ///视频复诊
            List<SaveModel> vedioSaveModels = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1","2",null,level2_type);
            List<SaveModel> vedioSaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"16",null,level2_type);
            JSONArray array = new JSONArray();
            List<String> list = new ArrayList<>();
@ -196,7 +196,7 @@ public class StatisticsEsService {
                Double synegy =0.0;
                if (index.equalsIgnoreCase("3")){
                    specialist = 0.0;
                }else if (index.equalsIgnoreCase("1")){
                }else if (index.equalsIgnoreCase("5")){
                    for (SaveModel saveModel:specialistSaveModels){
                        if (level2_type.equals(SaveModel.deptLevel)){
                            if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
@ -402,15 +402,23 @@ public class StatisticsEsService {
        JSONObject object = new JSONObject();
        //协同门诊
        SaveModel saveModel1 = null;
        saveModel1 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "2");
        saveModel1 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "12");
        //图文复诊
        SaveModel saveModel2 = null;
        saveModel2 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","1");
        //saveModel2 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","1");
        saveModel2 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "9");
        //视频复诊
        SaveModel saveModel3 = null;
/*
        saveModel3 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","2");
*/
        saveModel3 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "16");
        Double specialistCount =0.0;
        if(index.equalsIgnoreCase("1")){
        //专科咨询
        SaveModel saveModel4 = null;
        saveModel4 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1");
        specialistCount = saveModel4.getResult1();//专家咨询数量
        /*if(index.equalsIgnoreCase("5")){
            //专家咨询数量
            SaveModel saveModel = null;
            if (StringUtils.isNotEmpty(level2_type)) {
@ -422,7 +430,7 @@ public class StatisticsEsService {
        }else if (index.equalsIgnoreCase("3")){
            specialistCount = 0.0;
        }
        }*/
        Double synergyCount = saveModel1.getResult1();//协同门诊数量
        Double topicCount = saveModel2.getResult1();//图文复诊数量
@ -458,10 +466,10 @@ public class StatisticsEsService {
        //问诊总量
        SaveModel saveModel1 = null;
        saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL);
        saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL);
        int total = saveModel1.getResult1().intValue();
        List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel0(endDate,endDate,area,level,index,SaveModel.timeLevel_DDL,null,level2_type);
        List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel0(startDate,endDate,area,level,index,SaveModel.timeLevel_ZL,null,level2_type);
        List<JSONObject> result = new ArrayList<>();
        for (SaveModel saveModel:saveModels){
@ -516,16 +524,16 @@ public class StatisticsEsService {
    public JSONObject getOutPatientTypeline(String startDate, String endDate, String area, int level, String index, String level2_type) throws Exception {
        JSONObject object = new JSONObject();
        //专家咨询
        JSONArray specialistArray = dateTotalStatistics2(startDate,endDate,area,level,"4",null,SaveModel.timeLevel_ZL,null);
        JSONArray specialistArray = dateTotalStatistics2(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,null);
        object.put("specialistArray",specialistArray);
        //协同复诊
        JSONArray syngeryArray = dateTotalStatistics2(startDate,endDate,area,level,index,"2",SaveModel.timeLevel_ZL,null);
        JSONArray syngeryArray = dateTotalStatistics2(startDate,endDate,area,level,index,"12",SaveModel.timeLevel_ZL,null);
        object.put("syngeryArray",syngeryArray);
        //图文复诊
        JSONArray topicArray = dateTotalStatistics2(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"1");
        JSONArray topicArray = dateTotalStatistics2(startDate,endDate,area,level,index,"9",SaveModel.timeLevel_ZL,null);
        object.put("topicArray",topicArray);
        //视频复诊
        JSONArray vedioArray = dateTotalStatistics2(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"2");
        JSONArray vedioArray = dateTotalStatistics2(startDate,endDate,area,level,index,"16",SaveModel.timeLevel_ZL,null);
        object.put("vedioArray",vedioArray);
        return object;
    }
@ -797,13 +805,13 @@ public class StatisticsEsService {
            object.put("data",array);
        }else if (flag==2){//活跃医生
            //图文
            List<SaveModel> topicModels = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "1","1",null, "6");
            List<SaveModel> topicModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "9",null, "6");
            //视频
            List<SaveModel> vedioModels = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "1","2",null, "6");
            List<SaveModel> vedioModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "16",null, "6");
            //协同
            List<SaveModel> synegyModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "2",null, "6");
            List<SaveModel> synegyModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "12",null, "6");
            //专科
            List<SaveModel> specialistModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level,"4", SaveModel.timeLevel_ZL,null, "6");
            List<SaveModel> specialistModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level,index, SaveModel.timeLevel_ZL,"1",null, "6");
            String deptSql = "select hd.CODE,hd.NAME from DICT_HOSPITAL_DEPT hd where CONSULT_DEPT_FLAG=1";
            if (level==4){//科室
@ -969,6 +977,18 @@ public class StatisticsEsService {
    }
    public Double getDoubleRange(Double first, Double second, int i) {
        if (second == 0 && first > 0) {
            return 100.0;
        } else if (second == 0 && first == 0) {
            return 0.0;
        }
        Double size =first / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        Double filesize = Double.parseDouble(df.format(size));
        return filesize ;
    }
    /**
     * 总体分析 折线图 按日--0级维度1级维度
     *
@ -1208,7 +1228,11 @@ public class StatisticsEsService {
            for (SaveModel saveModel : saveModels) {
                String range = "";
                if (saveModel.getQuotaDate() != null) {
                    range = df.format(saveModel.getQuotaDate());
                    Calendar quotaDate = Calendar.getInstance();
                    quotaDate.setTime(saveModel.getQuotaDate());
                    quotaDate.add(Calendar.DATE, 6);
                    range = df.format(quotaDate.getTime());
                }
                JSONObject json = countResult.get(range);
//                //因为上述时间集提前一天  但是前端是显示当前时间,所以这里给调整回去
@ -1384,4 +1408,320 @@ public class StatisticsEsService {
        }
    }
    /**
     * 专科咨询统计总量
     * @param startDate 开始时间
     * @param endDate 结束时间
     * @param area 区域
     * @param level
     * @param index
     * @return
     * @throws Exception
     */
    public JSONObject getSpecialConsultHead(String startDate, String endDate, String area, int level, String index) throws Exception {
        //总量
        SaveModel saveModel = null;
        //已回复
        SaveModel saveModel1 = null;
        //已结束
        SaveModel saveModel2 = null;
        //未回复
        SaveModel saveModel3 = null;
        //居民取消
        SaveModel saveModel4 = null;
        //进行中
        SaveModel saveModel5 = null;
        saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, "7", SaveModel.timeLevel_DDL);
        saveModel1 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "6", SaveModel.timeLevel_DDL,"1");
        saveModel3 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "6", SaveModel.timeLevel_DDL,"0");
        saveModel4 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "7", SaveModel.timeLevel_DDL,"-1");
        saveModel5 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "7", SaveModel.timeLevel_DDL,"0");
        saveModel2 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "7", SaveModel.timeLevel_DDL,"1");
        JSONObject object = new JSONObject();
        object.put("specialConsultTotal",saveModel.getResult1());
        object.put("haveReplyTotal",saveModel1.getResult1());
        object.put("endTotal",saveModel2.getResult1());
        object.put("notReplyTotal",saveModel3.getResult1());
        object.put("cancelTotal",saveModel4.getResult1());
        object.put("comingTotal",saveModel5.getResult1());
        object.put("notReplyRate",getRange(saveModel3.getResult1().intValue(),saveModel.getResult1().intValue(),2));//未回复率
        return object;
    }
    /**
     * 专科咨询统计曲线
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @param interval
     * @param level2_type
     * @return
     * @throws Exception
     */
    public JSONObject getSpecialConsultLine(String startDate, String endDate, String area, int level, String index,int interval, String level2_type) throws Exception {
        //问诊量
        JSONObject object = new JSONObject();
        if (interval==1){
            JSONArray array = dateTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
        }else if (interval==2){
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
        }
        return object;
    }
    /**
     * 专科咨询统计表格
     * @param startTime
     * @param endTime
     * @param level
     * @param area
     * @param lowLevel
     * @return
     * @throws Exception
     */
    public JSONObject getConsultingStatisticsList(String startTime,String endTime,int level, String area, String lowLevel) throws Exception {
        JSONObject result = new JSONObject();
//        timeKey= "2017-11-01 00:00:00";
        //已结束
        List<SaveModel> endTotal = elasticsearchUtil.findListDateQuotaLevel1(endTime, endTime, area, level, "7", SaveModel.timeLevel_DDL, lowLevel,"1");
        //咨询总数
        List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel0(endTime, endTime, area, level, "6", SaveModel.timeLevel_DDL, lowLevel);
        //未回复数
        List<SaveModel> noRelyTotal = elasticsearchUtil.findListDateQuotaLevel1(endTime, endTime, area, level, "6", SaveModel.timeLevel_DDL, lowLevel,"0");
//        JSONArray rely = new JSONArray(relyVal);
//        JSONArray total = new JSONArray(relyTotal);
//        JSONArray noRely = new JSONArray(noRelyTotal);
        result.put("resultList", getCoutList(level, lowLevel, endTotal, total, noRelyTotal));
        return result;
    }
    public List<Map<String, Object>> getCoutList(Integer level, String lowLevel, List<SaveModel> endConsult, List<SaveModel> total, List<SaveModel> noRely) {
        Map<String, Object> relyMap = new HashMap<>();
        Map<String, Object> totalMap = new HashMap<>();
        Map<String, Object> noRelyMap = new HashMap<>();
        org.json.JSONObject result = new org.json.JSONObject();
        String low_level = StringUtils.isEmpty(lowLevel) ? String.valueOf(level + 1) : lowLevel;
        //转换结束数
        for (SaveModel saveModel : endConsult) {
            if (SaveModel.doctorLevel.equals(low_level)) {
                relyMap.put(saveModel.getDoctor(), saveModel);
            } else if (SaveModel.deptLevel.equals(low_level)) {
                relyMap.put(saveModel.getDept(), saveModel);
            }else if (SaveModel.OrgLevel.equals(low_level)) {
                relyMap.put(saveModel.getHospital(), saveModel);
            }
        }
        ;
        //转换总咨询数
        for (SaveModel saveModel : total) {
            if (SaveModel.doctorLevel.equals(low_level)) {
                totalMap.put(saveModel.getDoctor(), saveModel);
            } else if (SaveModel.deptLevel.equals(low_level)) {
                totalMap.put(saveModel.getDept(), saveModel);
            }else if (SaveModel.OrgLevel.equals(low_level)) {
                totalMap.put(saveModel.getHospital(), saveModel);
            }
        }
        ;
        //转换已结束
        for (SaveModel saveModel : noRely) {
            if (SaveModel.doctorLevel.equals(low_level)) {
                noRelyMap.put(saveModel.getDoctor(), saveModel);
            } else if (SaveModel.deptLevel.equals(low_level)) {
                noRelyMap.put(saveModel.getDept(), saveModel);
            }else if (SaveModel.OrgLevel.equals(low_level)) {
                noRelyMap.put(saveModel.getHospital(), saveModel);
            }
        }
        ;
        List<Map<String, Object>> resultMaps = new ArrayList<>();
        for (String key : totalMap.keySet()) {
            Map<String, Object> rs = new HashMap<>();
            SaveModel relyRs = (SaveModel) relyMap.get(key);
            SaveModel totalRs = (SaveModel) totalMap.get(key);
            SaveModel onRelyRs = (SaveModel) noRelyMap.get(key);
            if (relyRs == null || totalRs == null || onRelyRs == null) {
                continue;
            }
            //合并结果集
            Integer totalNm = totalRs.getResult2().intValue();
            Integer endNm = relyRs.getResult2().intValue();
            Integer noRelyNm = onRelyRs.getResult2().intValue();
//            rs.put("name", relyRs.get(area+"Name"));
            if (SaveModel.doctorLevel.equals(low_level)) {
                rs.put("name", relyRs.getDoctorName());
            } else if (SaveModel.deptLevel.equals(low_level)) {
                rs.put("name", relyRs.getDeptName());
            } else if (SaveModel.OrgLevel.equals(low_level)) {
                rs.put("name", relyRs.getHospitalName());
            }
            rs.put("noRelyCount", noRelyNm);
            rs.put("endCount", endNm);
            rs.put("total", totalNm);
            rs.put("code", key);
            if (totalNm != null && totalNm != 0) {
                if (endNm != null && endNm != 0) {
                    double rr = (double) endNm / totalNm * 100;
                    DecimalFormat df = new DecimalFormat("0.00");
                    rs.put("endRate", df.format(rr) + "%");
                    rs.put("endDoubleRate", rr);
                } else {
                    rs.put("endRate", "0.00%");
                    rs.put("endDoubleRate", 0.0);
                }
                if (noRelyNm != null && noRelyNm != 0) {
                    double rr = (double) noRelyNm / totalNm * 100;
                    DecimalFormat df = new DecimalFormat("0.00");
                    rs.put("noRelyRate", df.format(rr) + "%");
                    rs.put("noRelyDoubleRate", rr);
                } else {
                    rs.put("noRelyRate", "0.00%");
                    rs.put("noRelyDoubleRate", 0.0);
                }
            } else {
                rs.put("endRate", "0.00%");
                rs.put("endDoubleRate", 0.0);
                rs.put("noRelyRate", "0.00%");
                rs.put("noRelyDoubleRate", 0.0);
            }
            resultMaps.add(rs);
        }
        //根据为回复数排序
        Collections.sort(resultMaps, new Comparator<Map<String, Object>>() {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                return (Integer) o1.get("total") < (Integer) o2.get("total") ? 1 : ((Integer) o1.get("total") == (Integer) o2.get("total") ? 0 : -1);
            }
        });
        return resultMaps;
    }
    /**
     * 服务评分平均分
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @return
     * @throws Exception
     */
    public JSONObject getScoreHead(String startDate, String endDate, String area, int level, String index) throws Exception {
        //总评分
        SaveModel saveModel = null;
        saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL);
        JSONObject object = new JSONObject();
        Double scoreTotal = saveModel.getResult1();//总评分
        Double people = saveModel.getResult2();//评价总人数
        object.put("scoreTotal",scoreTotal);//总评分
        object.put("people",people);//总人数
        object.put("scoreRate",getDoubleRange(scoreTotal,people,0));//平均评分
        return object;
    }
    /**
     * 服务评分曲线
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @param interval
     * @param level2_type
     * @return
     * @throws Exception
     */
    public JSONObject getScoreLine(String startDate, String endDate, String area, int level, String index,int interval, String level2_type) throws Exception {
        //服务评分
        JSONObject object = new JSONObject();
        JSONArray array = new JSONArray();
        if (interval==1){
            array = dateTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
        }else if (interval==2){
            array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
        }else if (interval==3){
            array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
        }
        for (int i=0;i<array.size();i++){
            JSONObject jsonObject = array.getJSONObject(i);
            Long amount = jsonObject.getLong("amount");
            Double num = jsonObject.getDouble("num");
            jsonObject.put("scoreRate",getDoubleRange(num,amount.doubleValue(),0));
        }
        object.put("data",array);
        return object;
    }
    public JSONObject getScoreList(String startTime,String endTime,int level, String area, String lowLevel) throws Exception {
        JSONObject result1 = new JSONObject();
        //咨询总数
        List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel0(endTime, endTime, area, level, "9", SaveModel.timeLevel_DDL, lowLevel);
        Map<String, Object> totalMap = new HashMap<>();
        org.json.JSONObject result = new org.json.JSONObject();
        String low_level = StringUtils.isEmpty(lowLevel) ? String.valueOf(level + 1) : lowLevel;
        //转换总咨询数
        for (SaveModel saveModel : total) {
            if (SaveModel.doctorLevel.equals(low_level)) {
                totalMap.put(saveModel.getDoctor(), saveModel);
            } else if (SaveModel.deptLevel.equals(low_level)) {
                totalMap.put(saveModel.getDept(), saveModel);
            }else if (SaveModel.OrgLevel.equals(low_level)) {
                totalMap.put(saveModel.getHospital(), saveModel);
            }
        }
        ;
        List<Map<String, Object>> resultMaps = new ArrayList<>();
        for (String key : totalMap.keySet()) {
            Map<String, Object> rs = new HashMap<>();
            SaveModel totalRs = (SaveModel) totalMap.get(key);
            if (totalRs == null) {
                continue;
            }
            //合并结果集
            Double totalNm = totalRs.getResult2();//总人数
            Double scoreNm = totalRs.getResult1();//总分数
            if (SaveModel.doctorLevel.equals(low_level)) {
                rs.put("name", totalRs.getDoctorName());
            } else if (SaveModel.deptLevel.equals(low_level)) {
                rs.put("name", totalRs.getDeptName());
            } else if (SaveModel.OrgLevel.equals(low_level)) {
                rs.put("name", totalRs.getHospitalName());
            }
            rs.put("total", totalNm);
            rs.put("scoreRate",getDoubleRange(scoreNm,totalNm,0));
            rs.put("code", key);
            resultMaps.add(rs);
        }
        //根据为回复数排序
        Collections.sort(resultMaps, new Comparator<Map<String, Object>>() {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                return (Double) o1.get("scoreRate") < (Double) o2.get("scoreRate") ? 1 : ((Double) o1.get("scoreRate") == (Double) o2.get("scoreRate") ? 0 : -1);
            }
        });
        result1.put("resultList", resultMaps);
        return result1;
    }
}

+ 141 - 67
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -560,6 +560,39 @@ public class ImService {
		return failed;
	}
	
	/**
	 * 获取微信服务器图片
	 * @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;
	}
	
	/**
	 * 获取微信服务器语音
	 *
@ -634,9 +667,9 @@ public class ImService {
			String Mp3FilePath = tempPath+datePath+mp3FileName;
			System.out.println("amrFilePath:"+amrFilePath);
			System.out.println("Mp3FilePath:"+Mp3FilePath);
			fileUtil.changeToMp3(amrFilePath,Mp3FilePath);
//			fileUtil.changeToMp3(amrFilePath,Mp3FilePath);
			// 返回保存路径
			return Mp3FilePath;
			return amrFilePath;
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
@ -658,71 +691,6 @@ public class ImService {
		return null;
	}
	
	/**
	 * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
	 *
	 * @return
	 */
	public InputStream getInputStream(String mediaId,String wechat_appid) {
		String accessToken = "";
		//中山医院互联网医院
		if("xm_zsyy_wx".equals(wechat_appid)){
			accessToken = entranceService.getAccessToken("100033");
		}else{
			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)
@ -779,6 +747,95 @@ public class ImService {
		return null;
	}
	
	
	/**
	 * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
	 *
	 * @return
	 */
	public InputStream getInputStream(String mediaId,String wechat_appid) throws Exception {
		String accessToken = "";
//		//中山医院互联网医院
//		if("xm_zsyy_wx".equals(wechat_appid)){
//			accessToken = entranceService.getAccessToken("100033");
//		}else{
//			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;
//		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=30_OBJbMMPW9TnyGHKf32bcjkXtxWnzBrtqWlSMBnNk8MWpJ6qis2TnsecRYNZImgahdx30WrsI1bGco6K67-j4sT1QkDxYKBrVvjaYF6QgbY8dgBMzuoARKoaxtX3ehiYvdCLSUHvogrpF3n0GANIfCHAHUP&media_id=R_060hnyXAFyHD9HaOLl15xhDIzDvcA61-Wz34GkXmCakdrsFJqxrPEBHewmAEK9";
		logger.info("media/get"+url);
		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();
			if(is.available() <= 200){
				logger.info("下载多媒体文件 accessToken 过期");
				//中山医院互联网医院
				if("xm_zsyy_wx".equals(wechat_appid)){
					accessToken = entranceService.getAccessToken("100033");
				}else{
					wxAccessTokenService.deleteByWechatId(wechat_appid);
					accessToken = wxAccessTokenService.updateAccessToken(wechat_appid);
					is = getInputStreamReLoad(mediaId,wechat_appid,accessToken);
					return is;
				}
			}
			
			
		} catch (Exception e) {
			logger.info(e.getMessage());
			e.printStackTrace();
			throw new Exception("下载失败,"+e.getMessage());
		}
		return is;
	}
	
	
	/**
	 * accessToken 过期时重新下载多媒体文件
	 * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
	 *
	 * @return
	 */
	public InputStream getInputStreamReLoad(String mediaId,String wechat_appid,String accessToken) throws Exception {
		logger.info("accessToken 过期时重新下载多媒体文件:accessToken:"+accessToken);
		logger.info("accessToken 过期时重新下载多媒体文件:wechat_appid:"+wechat_appid);
		logger.info("accessToken 过期时重新下载多媒体文件:mediaId:"+mediaId);
		InputStream is = null;
		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
		logger.info("media/get"+url);
		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) {
			logger.info(e.getMessage());
			e.printStackTrace();
			throw new Exception("下载失败,"+e.getMessage());
		}
		return is;
	}
	
	
	/**
	 * 患者端
	 * 发起专家咨询
@ -2378,4 +2435,21 @@ public class ImService {
			redisTemplate.opsForValue().set("video_invite_"+session_id,"0");
		}
	}
	
	/**
	 * 查询会话视频邀请状态
	 * @param doctorids
	 * @return
	 * @throws Exception
	 */
	public List<Map<String,Object>>  getDoctorConsultCount(String doctorids) throws Exception{
		//医生角色
		String sql = "SELECT " +
				"count(id) AS total," +
				"doctor " +
				"FROM wlyy_consult_team " +
				"WHERE doctor IN ("+doctorids+") AND (type=1 OR type=15) and status = 0 GROUP BY doctor";
		List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
		return list;
	}
}

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

@ -410,6 +410,9 @@ public class BaseHospitalRequestMapping {
        
        // 居民导诊会话发送消息
        public static final String patientGuaidenceAppend = "patientGuaidenceAppend";
    
        //居民端:查询正医生当前咨询人数
        public static final String getDoctorConsultCount="getDoctorConsultCount";
    }
    
@ -645,6 +648,12 @@ public class BaseHospitalRequestMapping {
        public static final String doctorStatictis = "/doctorStatictis";
        public static final String doctorTotal = "/doctorTotal";
        public static final String doctorStatictisExcel = "/doctorStatictisExcel";
        public static final String specialConsultHead = "/specialConsultHead";
        public static final String specialConsultLine = "/specialConsultLine";
        public static final String specialConsultExcel= "/specialConsultExcel";
        public static final String scoreHead = "/scoreHead";
        public static final String scoreLine = "/scoreLine";
        public static final String scoreList = "/scoreList";
    }
@ -656,7 +665,9 @@ public class BaseHospitalRequestMapping {
        public static final String queryList  = "/queryList";
        public static final String queryById  = "/queryById";
        public static final String update  = "/update";
        public static final String updateList  = "/updateList";
        public static final String updateStatus  = "/updateStatus";
        public static final String updateDoctorPw  = "/updateDoctorPw";
    }
    /**

+ 22 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/config/DoctorServiceEndPoint.java

@ -8,6 +8,7 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -45,12 +46,14 @@ public class DoctorServiceEndPoint extends EnvelopRestEndpoint {
            @RequestParam(value = "type", required = false) String type,
            @ApiParam(name = "typeCode", value = "分部,无分部不传")
            @RequestParam(value = "typeCode", required = false)String typeCode,
            @ApiParam(name = "dept", value = "部门")
            @RequestParam(value = "dept", required = false)String dept,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "pageSize", value = "页码", required = true, defaultValue = "10")
            @RequestParam(value = "pageSize") int pageSize) throws Exception {
        return baseDoctorService.queryList(city,hospital,status,name,type,typeCode,page,pageSize);
        return baseDoctorService.queryList(city,hospital,status,name,type,typeCode,dept,page,pageSize);
    }
@ -83,6 +86,16 @@ public class DoctorServiceEndPoint extends EnvelopRestEndpoint {
        return success("保存成功");
    }
    @PostMapping(value = BaseHospitalRequestMapping.DoctorSetting.updateList)
    @ApiOperation(value = "批量修改医生服务配置")
    public Envelop updateList(
            @ApiParam(name = "baseDoctorVos", value = "JSON数据", required = true)
            @RequestParam(value = "baseDoctorVos") String baseDoctorVos)throws Exception{
        JSONArray jsonArray = JSONArray.fromObject(baseDoctorVos);
        Boolean update = baseDoctorService.updateList(jsonArray);
        return success("保存成功");
    }
    @GetMapping(value = BaseHospitalRequestMapping.DoctorSetting.updateStatus)
    @ApiOperation(value = "修改医生状态")
@ -96,4 +109,12 @@ public class DoctorServiceEndPoint extends EnvelopRestEndpoint {
        return success("修改成功");
    }
    @PostMapping(value = BaseHospitalRequestMapping.DoctorSetting.updateDoctorPw)
    @ApiOperation(value = "修改医生账号密码")
    public Envelop updateDoctorPw(@ApiParam(name = "id", value = "医生ID")
                                  @RequestParam(value = "id", required = true)String id,
                                  @ApiParam(name = "pw", value = "密码")
                                  @RequestParam(value = "pw", required = true)String pw)throws Exception{
        return success(baseDoctorService.updateDoctorPw(id,pw));
    }
}

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

@ -742,4 +742,5 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		return success("查询成功",status);
		
	}
}

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

@ -24,6 +24,7 @@ import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.FileUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.enterprise.EnterpriseService;
import com.yihu.jw.wechat.service.WechatInfoService;
@ -233,20 +234,45 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
		
		//处理语音文件
		if(!org.springframework.util.StringUtils.isEmpty(wechat_appid)){
			String path = imService.fetchWxVoices(wechat_appid);
			JSONObject obj = new JSONObject();
			// 将临时语音拷贝到正式存储路径下
			if (org.apache.commons.lang3.StringUtils.isNotEmpty(path)) {
				if("xm_ihealth_wx".equals(wechat_appid)){
					content = fileUploadService.uploadWxVoice(path);
			
//			imService.getInputStream("1",wechat_appid);
			
			if(3 == type){//语音文件
				String voicepath = imService.fetchWxVoices(wechat_appid);
				logger.info("voice_path:"+voicepath);
				JSONObject obj = new JSONObject();
				String voiceurl = "";
				// 将临时语音拷贝到正式存储路径下
				if (org.apache.commons.lang3.StringUtils.isNotEmpty(voicepath)) {
					if("xm_ihealth_wx".equals(wechat_appid)){
						logger.info("voice_wx_type:"+wechat_appid);
						voiceurl = fileUploadService.uploadWxVoice(voicepath);
//					uploadVO.setFullUri(map.get("accessory").toString());
				}else{
					content = fileUtil.copyTempVoice(path,fastdfs_file_url);
					}else{
						voiceurl = fileUtil.copyTempVoice(voicepath,fastdfs_file_url);
					}
					obj.put("path", voiceurl);
					obj.put("times", times);
					content = obj.toString();
				}
				obj.put("path", path);
				obj.put("times", times);
				content = obj.toString();
			}
			}else if(2 == type){//图片文件
				String imagepath = imService.fetchWxImages(wechat_appid);
				logger.info("image_path:"+imagepath);
				JSONObject obj = new JSONObject();
				String imgeUrl = "";
				// 将临时语音拷贝到正式存储路径下
				if (org.apache.commons.lang3.StringUtils.isNotEmpty(imagepath)) {
					if("xm_ihealth_wx".equals(wechat_appid)){
						logger.info("imge_wx_type:"+wechat_appid);
						imgeUrl = fileUploadService.uploadWxImage(imagepath);
//					uploadVO.setFullUri(map.get("accessory").toString());
					}else{
						imgeUrl = fileUtil.copyTempVoice(imagepath,fastdfs_file_url);
					}
					content = imgeUrl;
				}
			}else{}
		}
		
		failed = imService.append(consult,content,type,times,patientCode,wechat_appid);
@ -488,7 +514,8 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	                       @RequestParam(value = "pageUrl", required = true)String pageUrl,
	                       @ApiParam(name = "wxId", value = "微信id")
	                       @RequestParam(value = "wxId", required = true)String wxId) throws Exception {
		
		logger.info("pageUrl="+pageUrl);
		logger.info("wxId="+wxId);
		String ticket = wechatInfoService.getJsapi_ticketByToken(wxId);
		WxWechatDO wxWechatDO = wechatDao.findById(wxId);
		Map<Object, Object> map = new HashMap<Object, Object>();
@ -575,5 +602,13 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
		return success(result);
	}
	
	
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getDoctorConsultCount)
	@ApiOperation(value = "医生端:查询会话视频邀请状态", notes = "医生端:查询会话视频邀请状态")
	public Envelop getDoctorConsultCount(@ApiParam(name = "doctorids", value = "会话ID")
	                                     @RequestParam(value = "doctorids",required = true) String doctorids)throws Exception  {
		return success("查询成功",imService.getDoctorConsultCount(doctorids));
		
	}
}

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

@ -429,12 +429,14 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "date", required = true)String date,
                                         @ApiParam(name = "chargeType", value = "号别")
                                         @RequestParam(value = "chargeType", required = false)String chargeType,
                                         @ApiParam(name = "nameKey", value = "名字关键字")
                                         @RequestParam(value = "nameKey", required = false)String nameKey,
                                         @ApiParam(name = "page", value = "第几页")
                                         @RequestParam(value = "page", required = true)Integer page,
                                         @ApiParam(name = "size", value = "每页大小")
                                         @RequestParam(value = "size", required = true)Integer size) {
        return success(prescriptionService.findDoctorWithMouthWork(orgCode,dept,chargeType,date,page,size));
        return success(prescriptionService.findDoctorWithMouthWork(orgCode,dept,chargeType,date,nameKey,page,size));
    }

+ 176 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -267,4 +267,180 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
        }
        return success(result);
    }
    /**
     * 专科咨询列表
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.specialConsultHead)
    @ApiOperation(value = " 专科咨询分析-头部")
    public ObjEnvelop specialConsultHead(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        try {
            result = statisticsEsService.getSpecialConsultHead(startDate, endDate, area, level, index);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     * 专科咨询列表
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.specialConsultLine)
    @ApiOperation(value = "专科咨询分析曲线")
    public ObjEnvelop specialConsultLine(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @RequestParam(required = false)int interval,
            @RequestParam(required = false) String level2_type) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.getSpecialConsultLine(startDate, endDate, area, level, index, interval,level2_type);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     * 专科咨询列表
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param lowLevel 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.specialConsultExcel)
    @ApiOperation(value = "专科咨询列表")
    public ObjEnvelop specialConsultExcel(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String lowLevel) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.getConsultingStatisticsList(startDate, endDate,level,area,lowLevel);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     * 服务评价总平均分
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.scoreHead)
    @ApiOperation(value = " 服务评价总平均分-头部")
    public ObjEnvelop getScoreHead(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        try {
            result = statisticsEsService.getScoreHead(startDate, endDate, area, level, index);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     * 服务评价分析曲线
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.scoreLine)
    @ApiOperation(value = "服务评价分析曲线")
    public ObjEnvelop getScoreLine(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @RequestParam(required = false)int interval,
            @RequestParam(required = false) String level2_type) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.getScoreLine(startDate, endDate, area, level, index, interval,level2_type);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     * 服务评价分析列表
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param lowLevel 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.scoreList)
    @ApiOperation(value = "服务评价分析列表")
    public ObjEnvelop getScoreList(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String lowLevel) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.getScoreList(startDate, endDate,level,area,lowLevel);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
}

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

@ -488,7 +488,7 @@ hospital:
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.16.1.42:3000/
  im_list_get: http://192.168.103.150:3000/
  data_base_name: im
# 上传文件临时路径配置
@ -558,7 +558,7 @@ hospital:
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.16.1.42:3000/
  im_list_get: http://172.16.100.241:3000/
  data_base_name: im
# 上传文件临时路径配置
@ -570,9 +570,9 @@ FileTempPath:
es:
  pwflag: 1 # 1需要密码,2不需要密码
  index:
    Statistics: hlw_quota_test
    Statistics: hlw_quota_prod
  type:
    Statistics: hlw_quota_test
    Statistics: hlw_quota_prod
  host:  http://172.16.100.240:9200
  tHost: 172.16.100.240:9300
  clusterName: jkzl
@ -646,9 +646,9 @@ wlyy:
es:
  pwflag: 0 # 1需要密码,0不需要密码
  index:
    Statistics: hlw_quota_test
    Statistics: hlw_quota_prod
  type:
    Statistics: hlw_quota_test
    Statistics: hlw_quota_prod
  host:  http://172.16.100.240:9200
  tHost: 172.16.100.240:9300
  clusterName: jkzl