Преглед изворни кода

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

wangzhinan пре 5 година
родитељ
комит
c24a60a57d
28 измењених фајлова са 631 додато и 178 уклоњено
  1. 60 0
      business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java
  2. 10 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  3. 4 0
      business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java
  4. 6 1
      business/base-service/src/main/java/com/yihu/jw/org/service/BaseOrgInfoService.java
  5. 13 0
      business/base-service/src/main/java/com/yihu/jw/version/dao/AppVersionDao.java
  6. 21 0
      business/base-service/src/main/java/com/yihu/jw/version/service/AppVersionService.java
  7. 1 0
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WxAccessTokenService.java
  8. 18 2
      business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java
  9. 90 91
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  10. 1 3
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  11. 9 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  12. 6 0
      gateway/ag-basic/pom.xml
  13. 3 5
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseMethodLogService.java
  14. 1 1
      gateway/ag-basic/src/main/resources/bootstrap.yml
  15. 6 0
      server/svr-authentication/pom.xml
  16. 81 5
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  17. 101 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWjwConfigService.java
  18. 54 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/utils/AES.java
  19. 2 1
      server/svr-configuration/src/main/resources/application.yml
  20. 1 1
      server/svr-configuration/src/main/resources/bootstrap.yml
  21. 21 21
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/version/AppVersionDao.java
  22. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/version/AppVersionEndpoint.java
  23. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictDoctorDutyService.java
  24. 22 22
      svr/svr-base/src/main/java/com/yihu/jw/base/service/version/AppVersionService.java
  25. 4 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java
  26. 34 15
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  27. 3 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  28. 57 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/version/VersionEndpoint.java

+ 60 - 0
business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java

@ -255,6 +255,66 @@ public class FileUploadService {
                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
//                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;
            }

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

@ -807,10 +807,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * 获取所有医院列表
     * @return
     */
    public List<BaseOrgVO> findAllHospital(){
        List<BaseOrgDO> list = baseOrgDao.findByDel("1");
        List<BaseOrgVO> rs = new ArrayList<>();
        return convertToModels(list,rs,BaseOrgVO.class);
    public List<BaseOrgVO> findAllHospital(Integer level){
        if(level!=null){
            List<BaseOrgDO> list = baseOrgDao.findByLevelAndDel(level,"1");
            List<BaseOrgVO> rs = new ArrayList<>();
            return convertToModels(list,rs,BaseOrgVO.class);
        }else {
            List<BaseOrgDO> list = baseOrgDao.findByDel("1");
            List<BaseOrgVO> rs = new ArrayList<>();
            return convertToModels(list,rs,BaseOrgVO.class);
        }
    }
    /**

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

@ -46,5 +46,9 @@ public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String
    List<BaseOrgDO> findByCityCode(String cityCode);
    List<BaseOrgDO> findByCityCodeAndLevel(String cityCode,Integer level);
    List<BaseOrgDO> findByDel(String del);
    List<BaseOrgDO> findByLevelAndDel(Integer level,String del);
}

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

@ -2,7 +2,9 @@ package com.yihu.jw.org.service;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -14,7 +16,10 @@ public class BaseOrgInfoService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
    private BaseOrgDao baseOrgDao;
    // 基于市,获取医院列表信息
    public List<BaseOrgDO> getOrgByCity(String cityCode) {
    public List<BaseOrgDO> getOrgByCity(String cityCode,Integer level) {
        if(level!=null){
            return baseOrgDao.findByCityCodeAndLevel(cityCode,level);
        }
        return baseOrgDao.findByCityCode(cityCode);
    }

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/version/dao/AppVersionDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.version.dao;
import com.yihu.jw.entity.base.version.AppVersionDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2020/2/24.
 */
public interface AppVersionDao extends PagingAndSortingRepository<AppVersionDO, Integer>, JpaSpecificationExecutor<AppVersionDO> {
    AppVersionDO findByCode(String code);
}

+ 21 - 0
business/base-service/src/main/java/com/yihu/jw/version/service/AppVersionService.java

@ -0,0 +1,21 @@
package com.yihu.jw.version.service;
import com.yihu.jw.entity.base.version.AppVersionDO;
import com.yihu.jw.version.dao.AppVersionDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * Created by Trick on 2020/2/24.
 */
@Service
public class AppVersionService extends BaseJpaService<AppVersionDO, AppVersionDao> {
    @Autowired
    private AppVersionDao appVersionDao;
    public AppVersionDO findVersionByCode(String code) {
        return appVersionDao.findByCode(code);
    }
}

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

@ -121,6 +121,7 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
     * @param wechatId
     * @return
     */
    @Transactional
    public String updateAccessToken(String wechatId){
        try {
            //根据wechatCode查找出appid和appSecret

+ 18 - 2
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -378,6 +378,7 @@ public class WlyyBusinessService {
            logger.info("hospitals size:"+hospitals.size());
            if(hospitals!=null&&hospitals.size()>0){
                Integer addCount = 0;
                Integer updateCount =0;
                for(int i=0;i<hospitals.size();i++){
                    JSONObject h = (JSONObject) hospitals.get(i);
                    String code = h.getString("code");
@ -391,14 +392,27 @@ public class WlyyBusinessService {
                        org.setCityName(h.getString("cityName"));
                        org.setTownCode(h.getString("town"));
                        org.setTownName(h.getString("townName"));
                        org.setLevel(h.getInteger("level"));
                        org.setType("1");
                        org.setWinNo("-1");
                        org.setDel("1");
                        baseOrgDao.save(org);
                        addCount++;
                    }else{
                        BaseOrgDO org = baseOrgDao.findByCode(code);
                        org.setName(h.getString("name"));
                        org.setProvinceCode(h.getString("province"));
                        org.setProvinceName(h.getString("provinceName"));
                        org.setCityCode(h.getString("city"));
                        org.setCityName(h.getString("cityName"));
                        org.setTownCode(h.getString("town"));
                        org.setTownName(h.getString("townName"));
                        org.setLevel(h.getInteger("level"));
                        baseOrgDao.save(org);
                        updateCount++;
                    }
                }
                logger.info("hospitals addCount:"+addCount);
                logger.info("hospitals addCount:"+addCount+" updateCount:"+updateCount);
            }
        }
        return "ok";
@ -439,7 +453,7 @@ public class WlyyBusinessService {
            JSONArray doctors = JSONArray.parseArray(re.getString("data"));
            logger.info("doctors size:"+doctors.size());
            if(doctors!=null&&doctors.size()>0){
                Integer count = 0;
                //获取全部职称.
                List<Map<String,Object>> dutys = findDutys();
@ -550,6 +564,7 @@ public class WlyyBusinessService {
                                mappingDO.setMappingDeptName(temp.getName());
                                mappingDO.setCreateTime(new Date());
                                doctorMappingDao.save(mappingDO);
                                count++;
                            }
                        }
@ -557,6 +572,7 @@ public class WlyyBusinessService {
                        logger.info("data error");
                    }
                }
                logger.info("add count:"+count);
            }
        }
        return "ok";

+ 90 - 91
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;
	}
	
	/**
	 * 获取微信服务器语音
	 *
@ -658,6 +691,63 @@ public class ImService {
		return null;
	}
	
	
	/**
	 * 获取下载图片信息(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;
	}
	
	
	/**
	 * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
	 *
@ -746,97 +836,6 @@ public class ImService {
	}
	
	
	
	
	
	/**
	 * 获取微信服务器图片
	 * @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;
	}
	
	/**
	 * 患者端
	 * 发起专家咨询

+ 1 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java

@ -152,9 +152,7 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
	private String del;
    /**
     * 11一级甲等 12一级乙等 13一级丙等
     * 21二级甲等 22二级乙等 23二级丙等
     * 31三级特等 32三级甲等 33三级乙等 34三级丙级
     * 1.等級醫院,2.社區醫院
     */
    private Integer level;

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

@ -689,4 +689,13 @@ public class BaseHospitalRequestMapping {
        public static final String findWorkTimeInfo="/findWorkTimeInfo";
        public static final String findLevelOneDoctorUpcoming="/findLevelOneDoctorUpcoming";
    }
    /**
     * app升级
     */
    public static class Version extends Basic{
        public static final String PREFIX  = "/open/version";
        public static final String app="/app";
    }
}

+ 6 - 0
gateway/ag-basic/pom.xml

@ -118,6 +118,12 @@
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>
        <!--oracle驱动-->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
    </dependencies>
    <build>

+ 3 - 5
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseMethodLogService.java

@ -1,7 +1,5 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.gateway.log.dao.*;
import com.yihu.jw.gateway.log.entity.*;
import com.yihu.jw.gateway.useragent.UserAgent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,10 +19,10 @@ import java.util.Date;
@Transactional
public class BaseMethodLogService {
    private static final Logger logger = LoggerFactory.getLogger(com.yihu.jw.gateway.log.service.BaseMethodLogService.class);
    private static final Logger logger = LoggerFactory.getLogger(BaseMethodLogService.class);
    @Autowired
    private com.yihu.jw.gateway.log.dao.BaseMethodLogDao baseMethodLogDao;
    private BaseMethodLogDao baseMethodLogDao;
    @Autowired
    private UserAgent userAgent;
@ -35,7 +33,7 @@ public class BaseMethodLogService {
    public void saveMethodLog(HttpServletRequest request){
        try{
            logger.info("saveMethodLog");
            com.yihu.jw.gateway.log.entity.BaseMethodLogDO log = new com.yihu.jw.gateway.log.entity.BaseMethodLogDO();
            BaseMethodLogDO log = new BaseMethodLogDO();
            log.setUuid(userAgent.getUID());
            log.setName(userAgent.getUNAME());
            log.setIp(getIpAddress(request));

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

@ -53,7 +53,7 @@ spring:
  profiles: jwOracleProd
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.33.199:1221}
      uri: ${wlyy.spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}
---

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

@ -170,6 +170,12 @@
            <artifactId>javax.wsdl</artifactId>
            <version>1.5.1</version>
        </dependency>
        <!--oracle驱动-->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
    </dependencies>
    <build>

+ 81 - 5
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -19,8 +19,10 @@ import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.service.OauthCaConfigSerivce;
import com.yihu.jw.security.service.OauthWjwConfigService;
import com.yihu.jw.security.service.OauthWlyyConfigService;
import com.yihu.jw.security.service.OauthYlzConfigService;
import com.yihu.jw.security.utils.AES;
import com.yihu.jw.security.utils.DateUtil;
import com.yihu.jw.security.utils.SerializeUtil;
import com.yihu.jw.sms.service.ZhongShanSMSService;
@ -47,10 +49,7 @@ import org.springframework.security.oauth2.provider.error.WebResponseExceptionTr
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestValidator;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.util.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestContextHolder;
@ -65,6 +64,7 @@ import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URLDecoder;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.interfaces.RSAPrivateKey;
@ -124,6 +124,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private ZhongShanSMSService zhongShanSMSService;
    @Autowired
    private OauthCaConfigSerivce oauthCaConfigSerivce;
    @Autowired
    private OauthWjwConfigService oauthWjwConfigService;
    @PostConstruct
@ -752,9 +754,83 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    /**
     * 获取易联众授权码
     * 卫健委授权登录
     * @param authCode
     * @param client_id
     * @return
     */
    @RequestMapping(value = "/oauth/wjwLogin", method = RequestMethod.POST)
    public ObjEnvelop getWjwDecrypt(String authCode,String client_id) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
        }
        try {
            logger.info("authCode :"+authCode);
            String str = URLDecoder.decode(authCode,"UTF-8");
            logger.info("base64 :"+str);
            String data = new String(Base64Utils.decode((str.getBytes())));
            //固定秘钥解密
            String key = "FEA5049E4CCD16A9";
            String result = AES.decrypt(key,data);
            logger.info("wjwLogin :"+result);
            BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
            if(patientDO == null){
                return ObjEnvelop.getError("授权登录失败!");
            }
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            Map<String, String> parameters = new HashedMap();
            parameters.put("username",patientDO.getIdcard());
            parameters.put("grant_type", "ihealthCode");
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            if (authenticatedClient != null) {
                oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
            }
            OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
            WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
            wlyyUserSimple.setAccessToken(token.getValue());
            wlyyUserSimple.setTokenType(token.getTokenType());
            wlyyUserSimple.setExpiresIn(token.getExpiresIn());
            wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
            wlyyUserSimple.setUser(parameters.get("username"));
            String loginType = parameters.get("login_type");
            BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
            userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
            baseLoginLogDO.setUserId(wlyyUserSimple.getId());
            baseLoginLogDO.setCreateTime(new Date());
            String userAgent = JSONObject.toJSONString(wlyyUserSimple);
            baseLoginLogDO.setUserAgent(userAgent);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogService.save(baseLoginLogDO);
            return ObjEnvelop.getSuccess("success",wlyyUserSimple);
        }catch (Exception e){
            logger.error(e);
        }
        return ObjEnvelop.getError("登录失败!");
    }
        /**
         * 获取易联众授权码
         * @return
         */
    @RequestMapping(value = "/oauth/getOauthQRCode", method = RequestMethod.GET)
    public ObjEnvelop getOauthQRCode(){
        logger.info("/oauth/getOauthQRCode");

+ 101 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWjwConfigService.java

@ -0,0 +1,101 @@
package com.yihu.jw.security.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.utils.AES;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.utils.security.MD5;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.net.URLDecoder;
import java.util.Date;
import java.util.UUID;
import org.springframework.util.Base64Utils;
/**
 * Created by Trick on 2020/2/24.
 */
@Service
@Transactional
public class OauthWjwConfigService {
    private Logger logger = LoggerFactory.getLogger(OauthWjwConfigService.class);
    @Autowired
    private BasePatientDao basePatientDao;
    public BasePatientDO savePatient(String data)throws Exception{
        logger.info("savePatient :"+data);
        if(StringUtils.isNotBlank(data)){
            JSONObject d = JSON.parseObject(data);
            logger.info("data:"+d.toString());
            JSONObject info = (JSONObject) d.get("data");
            logger.info("info:"+info.toString());
            String name = info.getString("userName");
            String cardNo = info.getString("cardNo");
            String cardType = info.getString("cardType");
            String userPhone = info.getString("userPhone");
            String userSex = info.getString("userSex");
            String userIdNo = info.getString("userIdNo");
            String dType = info.getString("dType");
            if(StringUtils.isNotBlank(userIdNo)){
                BasePatientDO basePatientDO = basePatientDao.findByIdcardAndDel(userIdNo,"1");
                if(basePatientDO!=null){
                    return basePatientDO;
                }
                BasePatientDO patient = new BasePatientDO();
                String salt = UUID.randomUUID().toString().substring(0,5);
                String pw = userIdNo.substring(userIdNo.length()-6);
                patient.setIdcard(userIdNo);
                patient.setName(name);
                patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patient.setSalt(salt);
                patient.setMobile(userPhone);
                patient.setDel("1");
                patient.setEnabled(1);
                patient.setLocked(0);
                patient.setCreateTime(new Date());
                patient.setUpdateTime(new Date());
                patient.setBirthday(IdCardUtil.getBirthdayForIdcard(userIdNo));
                patient.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(userIdNo)));
                basePatientDao.save(patient);
                return basePatientDO;
            }
            return null;
        }
        return null;
    }
//    public static void main(String arg[])throws Exception{
//        String authCode ="KzR3c2ozVlhKQjMyZjJiL0ZQTWUxdENXNTk2YldKLzl4UnpzbnZUcWhnQXcrZVlVRnV6c1hHdHB1Z2dQWkpzclUyeStldmtaOXpGTg0KSklOcUlTZVVBRFN4Ulh1dTJ2eS9WNEl1OG9GSXJhRnpjMHRuVTdCbjBKVS9yWEhKbmphVEZOU0ZhT2ZtVEhUNE5oMXZDenVtMlErZw0KcFBBb1VXK1BhSUVIb2hjUFMrT3g5aEFTWnZRZSs3bndZS1NxMCtoL2FMa2FOQjVkWnpXRmluY2ZweGZSV1pQZk50SnEzNnZ0YmVYbQ0KUFdrVjRQMGlKeHNyMkwwaU43c0ZRUzRDN3RlMw==";
//        //固定秘钥解密
//        String key = "FEA5049E4CCD16A9";
//        String str = URLDecoder.decode(authCode,"UTF-8");
//        String data = new String(Base64Utils.decode((str.getBytes())));
//        String result = AES.decrypt(key,data);
//
//        JSONObject json =JSON.parseObject(result);
//        JSONObject d = (JSONObject) json.get("data");
//        d.getString("userIdNo");
//        System.out.println(d.getString("userIdNo"));
//    }
}

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

@ -0,0 +1,54 @@
package com.yihu.jw.security.utils;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.lang3.StringUtils;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
 * Created by Trick on 2020/2/24.
 */
public class AES {
    //AES解密方法
    public static String decrypt(String strKey, String strIn) throws Exception {
        if(StringUtils.isEmpty(strKey)|| StringUtils.isEmpty(strIn)){
            return null;
        }
        try{
            SecretKeySpec skeySpec = getKey(strKey);
            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
            IvParameterSpec iv = new IvParameterSpec("0102030405060708".getBytes());
            cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
            BASE64Decoder base64de = new BASE64Decoder();
            byte[] encrypted1 = base64de.decodeBuffer(strIn);
            //byte[] encrypted1 =strIn.getBytes();
            byte[] original = cipher.doFinal(encrypted1);
            String originalString = new String(original,"UTF-8");
            return originalString;
        }catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    private static SecretKeySpec getKey(String strKey) throws Exception {
        byte[] arrBTmp = strKey.getBytes();
        byte[] arrB = new byte[16]; // 创建一个空的16位字节数组(默认值为0)
        for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) {
            arrB[i] = arrBTmp[i];
        }
        SecretKeySpec skeySpec = new SecretKeySpec(arrB, "AES");
        return skeySpec;
    }
}

+ 2 - 1
server/svr-configuration/src/main/resources/application.yml

@ -19,7 +19,8 @@ eureka:
#      defaultZone: http://jw:jkzl@192.0.33.26:8762/eureka
#      defaultZone: http://jw:jkzl@192.168.33.199:8761/eureka
#      defaultZone: http://jw:jkzl@172.16.100.63:8761/eureka  # 心脏中心外网
      defaultZone: http://jw:jkzl@192.168.120.210:8761/eureka  # 心脏中心外网
#      defaultZone: http://jw:jkzl@192.168.120.210:8761/eureka  # 心脏中心外网
      defaultZone: http://jw:jkzl@192.168.33.199:8761/eureka  # 眼科医院
  instance:
    #eurika使用IP不使用host
    prefer-ip-address: true

+ 1 - 1
server/svr-configuration/src/main/resources/bootstrap.yml

@ -61,7 +61,7 @@ spring:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: ${wlyy.spring.config.git.uri:http://192.168.33.199:3001/jkzl/wlyy2.0.config.git}
          uri: ${wlyy.spring.config.git.uri:http://192.168.33.199:3001/jkzl/ehr.config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:master}
---

+ 21 - 21
svr/svr-base/src/main/java/com/yihu/jw/base/dao/version/AppVersionDao.java

@ -1,21 +1,21 @@
package com.yihu.jw.base.dao.version;
import com.yihu.jw.entity.base.version.AppVersionDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 
 * app版本号表 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年09月07日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface AppVersionDao extends PagingAndSortingRepository<AppVersionDO, Integer>, JpaSpecificationExecutor<AppVersionDO>  {
}
//package com.yihu.jw.base.dao.version;
//
//import com.yihu.jw.entity.base.version.AppVersionDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//
///**
// *
// * app版本号表 数据库访问层
// *
// * @version
// * <pre>
// * Author	Version		Date		Changes
// * litaohong 	1.0  		2018年09月07日 	Created
// *
// * </pre>
// * @since 1.
// */
//public interface AppVersionDao extends PagingAndSortingRepository<AppVersionDO, Integer>, JpaSpecificationExecutor<AppVersionDO>  {
//}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/version/AppVersionEndpoint.java

@ -1,6 +1,5 @@
package com.yihu.jw.base.endpoint.version;
import com.yihu.jw.base.service.version.AppVersionService;
import com.yihu.jw.entity.base.version.AppVersionDO;
import com.yihu.jw.restmodel.base.version.AppVersionVO;
import com.yihu.jw.restmodel.web.Envelop;
@ -9,6 +8,7 @@ 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.base.BaseRequestMapping;
import com.yihu.jw.version.service.AppVersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictDoctorDutyService.java

@ -1,6 +1,6 @@
package com.yihu.jw.base.service.dict;
import com.yihu.jw.base.dao.dict.DictDoctorDutyDao;
import com.yihu.jw.dict.dao.DictDoctorDutyDao;
import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;

+ 22 - 22
svr/svr-base/src/main/java/com/yihu/jw/base/service/version/AppVersionService.java

@ -1,22 +1,22 @@
package com.yihu.jw.base.service.version;
import com.yihu.jw.base.dao.version.AppVersionDao;
import com.yihu.jw.entity.base.version.AppVersionDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * 
 * app版本号表服务service
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong    1.0  2018年09月07日 Created
 *
 * </pre>
 * @since 1.
 */
@Service
public class AppVersionService extends BaseJpaService<AppVersionDO, AppVersionDao> {
}
//package com.yihu.jw.base.service.version;
//
//import com.yihu.jw.base.dao.version.AppVersionDao;
//import com.yihu.jw.entity.base.version.AppVersionDO;
//import com.yihu.mysql.query.BaseJpaService;
//import org.springframework.stereotype.Service;
//
///**
// *
// * app版本号表服务service
// *
// * @version
// * <pre>
// * Author	Version		Date		Changes
// * litaohong    1.0  2018年09月07日 Created
// *
// * </pre>
// * @since 1.
// */
//@Service
//public class AppVersionService extends BaseJpaService<AppVersionDO, AppVersionDao> {
//}

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

@ -76,8 +76,10 @@ public class BaseInfoEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "根据市编码,获取该市范围内所有的医院列表信息", notes = "基础数据获取")
    public Envelop getOrgByCity(
            @ApiParam(name = "cityCode", value = "市编码")
            @RequestParam(value = "cityCode", required = false) String cityCode) {
        List<BaseOrgDO> res =  baseOrgInfoService.getOrgByCity(cityCode);
            @RequestParam(value = "cityCode", required = false) String cityCode,
            @ApiParam(name = "level", value = "等级医院,1等级医院,2.社区医院")
            @RequestParam(value = "level", required = false) Integer level) {
        List<BaseOrgDO> res =  baseOrgInfoService.getOrgByCity(cityCode,level);
        if(res != null && res.size() > 0 ){
            return  success(res);
        }else{

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

@ -237,23 +237,42 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			
//			imService.getInputStream("1",wechat_appid);
			
			String path = imService.fetchWxVoices(wechat_appid);
			logger.info("voice_path:"+path);
			JSONObject obj = new JSONObject();
			String voiceurl = "";
			// 将临时语音拷贝到正式存储路径下
			if (org.apache.commons.lang3.StringUtils.isNotEmpty(path)) {
				if("xm_ihealth_wx".equals(wechat_appid)){
					logger.info("voice_wx_type:"+wechat_appid);
					voiceurl = fileUploadService.uploadWxVoice(path);
			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{
					voiceurl = 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", voiceurl);
				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);

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

@ -207,8 +207,9 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findAllHospital)
    @ApiOperation(value = "查询所有机构", notes = "查询所有机构")
    public ListEnvelop findAllHospital() {
        return success(prescriptionService.findAllHospital());
    public ListEnvelop findAllHospital(@ApiParam(name = "level", value = "医院等级")
                                       @RequestParam(value = "level", required = false)Integer level) {
        return success(prescriptionService.findAllHospital(level));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByHospital)

+ 57 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/version/VersionEndpoint.java

@ -0,0 +1,57 @@
package com.yihu.jw.hospital.endpoint.version;
import com.yihu.jw.entity.base.version.AppVersionDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.version.service.AppVersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Trick on 2020/2/24.
 */
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.Version.PREFIX)
@Api(value = "app升级", description = "app升级", tags = {"app升级"})
public class VersionEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private AppVersionService versionsService;
    /**
     * 校验APP版本号
     * @param code 版本类型编码
     * @param version 当前版本号
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Version.app)
    @ApiOperation(value = "app升级")
    public Envelop appVersion(String code, double version) {
            AppVersionDO temp = versionsService.findVersionByCode(code);
            if (temp == null) {
                return Envelop.getError( "无效的APP类型失败!");
            }
            if (version > 0) {
                if (temp.getVersionInt() > version) {
                    // 有新的版本号
                    return success("发现新版本!", temp.getUrl());
                } else {
                    // 已是最新版本
                    return success("已是最新版本!");
                }
            } else {
                JSONObject json = new JSONObject();
                json.put("version_int", temp.getVersionInt());
                json.put("version_str", temp.getVersionStr());
                json.put("url", temp.getUrl());
                json.put("info", temp.getInfo());
                json.put("size", temp.getSize());
                return success("读取版本号成功!", json);
            }
    }
}