kidgrow-business/kidgrow-filecenter/kidgrow-filecenter-biz/src/main/java/com/kidgrow/filecenter/service/impl/AbstractIFileService.java
@@ -33,8 +33,8 @@ /** * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> * * @Description: <br> * @Project: <br> * @Description: AbstractIFileService 抽取类<br> * @Project: 根据kidgrow.file-server.type 实例化具体对象<br> * @CreateDate: Created in 2020/2/18 11:24 <br> * @Author: <a href="4345453@kidgrow.com">liuke</a> */ @@ -100,7 +100,7 @@ * @param fileInfo */ protected abstract void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception; protected abstract void fileUpLoadOss(FileInfo fileInfo,String newFilePath, InputStream fileStream); protected abstract void fileUpLoadOss(FileInfo fileInfo,String newFilePath, InputStream fileStream,String fileFolder); protected abstract String FilePath(String imgType,String folderByDate,String hospitalId,String departmentId); protected abstract OSSObject down(String url); @@ -172,7 +172,7 @@ newfileInfo.setImgType(imgType); newfileInfo.setCreateTime(new Date()); //文件上传到oss this.fileUpLoadOss(newfileInfo,filefloder+newFileName,inputStream); this.fileUpLoadOss(newfileInfo,filefloder+newFileName,inputStream,filefloder); inputStream.close(); // //删除暂存文件 // MultipartFileUtils.delteTempFile(thuFile); @@ -218,7 +218,7 @@ newfileInfo.setCreateTime(new Date()); String folderByDate =DateUtil.formatDate(new Date()); String filePath = FilePath(imgType, folderByDate, hospitalId, departmentId); this.fileUpLoadOss(newfileInfo,filePath+newFileName,input); this.fileUpLoadOss(newfileInfo,filePath+newFileName,input,filePath); input.close(); baseMapper.insert(newfileInfo); return newfileInfo; @@ -332,7 +332,7 @@ newfileInfo.setSource("aliyun"); newfileInfo.setImgType(houzhui); newfileInfo.setCreateTime(new Date()); this.fileUpLoadOss(newfileInfo,"pdf/"+newFileName,inputStream); this.fileUpLoadOss(newfileInfo,"pdf/"+newFileName,inputStream,"pdf/"); baseMapper.insert(newfileInfo); inputStream.close(); return newfileInfo; @@ -361,7 +361,7 @@ String folderByDate =DateUtil.formatDate(new Date()); String filePath = FilePath(imgType, folderByDate, hospitalId, departmentId); InputStream inputStream = file.getInputStream(); this.fileUpLoadOss(newfileInfo,filePath+newFileName,inputStream); this.fileUpLoadOss(newfileInfo,filePath+newFileName,inputStream,filePath); inputStream.close(); baseMapper.insert(newfileInfo); return newfileInfo; kidgrow-business/kidgrow-filecenter/kidgrow-filecenter-server/src/main/java/com/kidgrow/filecenter/config/AliyunOSSAutoConfigure.java
@@ -79,10 +79,10 @@ String fileFolder = ""; if (clientID.equals("hospital")) {//医院端平台, fileFolder = FilePath(fileInfo.getImgType(), folderByDate, hospitalID, depID); fileUpLoadOss(fileInfo, fileFolder + fileName, file.getInputStream()); fileUpLoadOss(fileInfo, fileFolder + fileName, file.getInputStream(),fileFolder); } else { fileFolder = FilePath(fileInfo.getImgType(), folderByDate, hospitalID, depID); fileUpLoadOss(fileInfo, fileFolder + fileName, file.getInputStream()); fileUpLoadOss(fileInfo, fileFolder + fileName, file.getInputStream(),fileFolder); } } @@ -101,7 +101,7 @@ * @param fileStream 要上传的文件流 */ @Override public void fileUpLoadOss(FileInfo fileInfo, String newFilePath, InputStream fileStream) { public void fileUpLoadOss(FileInfo fileInfo, String newFilePath, InputStream fileStream,String fileFolder) { ossClient.putObject(fileProperties.getOss().getBucketName(), newFilePath, fileStream); fileInfo.setUrl(fileProperties.getOss().getDomain() + newFilePath); kidgrow-business/kidgrow-filecenter/kidgrow-filecenter-server/src/main/java/com/kidgrow/filecenter/config/FastdfsAutoConfigure.java
@@ -48,7 +48,7 @@ } @Override protected void fileUpLoadOss(FileInfo fileInfo, String newFilePath, InputStream fileStream) { protected void fileUpLoadOss(FileInfo fileInfo, String newFilePath, InputStream fileStream,String fileFolder) { } kidgrow-business/kidgrow-filecenter/kidgrow-filecenter-server/src/main/java/com/kidgrow/filecenter/config/HardDiskAutoConfigure.java
New file @@ -0,0 +1,179 @@ package com.kidgrow.filecenter.config; /** * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> * * @Description: <br> * @Project: <br> * @CreateDate: Created in 2021/2/22 09:36 <br> * @Author: <a href="4345453@kidgrow.com">liuke</a> */ import com.aliyun.oss.model.OSSObject; import com.kidgrow.common.constant.CommonConstant; import com.kidgrow.common.constant.SecurityConstants; import com.kidgrow.common.utils.DateUtil; import com.kidgrow.common.utils.StringUtils; import com.kidgrow.filecenter.model.FileInfo; import com.kidgrow.filecenter.properties.FileServerProperties; import com.kidgrow.filecenter.service.impl.AbstractIFileService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.util.Date; import java.util.UUID; /** * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> * * @Description: 阿里云配置<br> * @Project: <br> * @CreateDate: Created in 2020/2/18 11:24 <br> * @Author: <a href="4345453@kidgrow.com">liuke</a> */ @Configuration @ConditionalOnProperty(name = "kidgrow.file-server.type", havingValue = "harddisk") public class HardDiskAutoConfigure { @Autowired private FileServerProperties fileProperties; @Service public class HardDiskServiceImpl extends AbstractIFileService { @Autowired private HttpServletRequest httpServletRequest; @Override protected String fileType() { return fileProperties.getType(); } @Value("${spring.profiles.active}") private String OssPathEn; @Value("${kidgrow.file-server.fdfs.web-url}") private String FileWebUrl; @Value("${server.port}") private String ServerPort; @Override protected void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception { String clientID = httpServletRequest.getHeader(SecurityConstants.CLIENT_HEADER); String hospitalID = httpServletRequest.getHeader(SecurityConstants.USER_HOSPITAL_ID_HEADER); String depID = httpServletRequest.getHeader(SecurityConstants.USER_DEP_ID_HEADER); String folderByDate = DateUtil.formatDate(new Date()); int begin = file.getOriginalFilename().lastIndexOf("."); int last = file.getOriginalFilename().length(); String fileType = file.getOriginalFilename().substring(begin, last); String fileName = UUID.randomUUID().toString().replaceAll("-", "") + fileType; String fileFolder = ""; if (clientID.equals("hospital")) {//医院端平台, fileFolder = FilePath(fileInfo.getImgType(), folderByDate, hospitalID, depID); fileUpLoadOss(fileInfo, fileFolder + fileName, file.getInputStream(),fileFolder); } else { fileFolder = FilePath(fileInfo.getImgType(), folderByDate, hospitalID, depID); fileUpLoadOss(fileInfo, fileFolder + fileName, file.getInputStream(),fileFolder); } } @Override protected boolean deleteFile(FileInfo fileInfo) { return true; } /** * 给OSS上上传文件 * * @param fileInfo 返回对象 * @param newFilePath 上传到的文件路径 * @param fileStream 要上传的文件流 */ @Override public void fileUpLoadOss(FileInfo fileInfo, String newFilePath, InputStream fileStream,String fileFolder) { String saveFilePath= CommonConstant.TEMP_IMAGE_PATH+"/"+fileFolder; String saveFileName=CommonConstant.TEMP_IMAGE_PATH+"/"+newFilePath; File saveFile= new File(saveFilePath); if(!saveFile.exists()) { saveFile.mkdirs(); } try { byte[] data = new byte[1024]; FileOutputStream fos = new FileOutputStream(saveFileName, false); while ((fileStream.read(data)) != -1) { fos.write(data); } fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } fileInfo.setUrl(FileWebUrl +":" +ServerPort+"/" + newFilePath); } @Override public OSSObject down(String url) { return null; } /** * 组合sso上的文件路径 * * @param imgType * @return */ @Override public String FilePath(String imgType, String folderByDate, String hospitalId, String departmentId) { //返回的文件路径 String fileFolder = OssPathEn+"/"; if (StringUtils.isNotBlank(imgType)) { // 光片需要按照根据医院ID,科室ID,日期进行OSS存储 if (imgType.toLowerCase().equals("xray")) { if (StringUtils.isNotBlank(hospitalId) && StringUtils.isNotBlank(departmentId)) { fileFolder += "Xray/" + hospitalId + "/" + departmentId + "/" + folderByDate + "/"; } else { fileFolder += "Xray/" + folderByDate + "/"; } } else if (imgType.toLowerCase().equals("app")) { //移动端APP上传 if (StringUtils.isNotBlank(hospitalId) && StringUtils.isNotBlank(departmentId)) { fileFolder += "AppXray/" + hospitalId + "/" + departmentId + "/" + folderByDate + "/"; } else { fileFolder += "AppXray/" + folderByDate + "/"; } } // 医院Logo只保存在一个目录中 else if (imgType.toLowerCase().equals("logo")) { fileFolder += "HospitalLogo/"; } else if (imgType.toLowerCase().equals("doctor")) { fileFolder += "DoctorImage/"; } else if (imgType.toLowerCase().equals("customerhospital")) { fileFolder += "Customer/Hospital/" + folderByDate + "/"; } else if (imgType.toLowerCase().equals("customerhead")) { fileFolder += "Customer/HeadImg/" + folderByDate + "/"; }else { fileFolder += "OtherImage/" + folderByDate + "/"; } } else { fileFolder += "OtherImage/" + folderByDate + "/"; } return fileFolder; } } } kidgrow-business/kidgrow-filecenter/kidgrow-filecenter-server/src/main/java/com/kidgrow/filecenter/config/QiniuOSSAutoConfigure.java
@@ -91,7 +91,7 @@ } @Override protected void fileUpLoadOss(FileInfo fileInfo, String newFilePath, InputStream fileStream) { protected void fileUpLoadOss(FileInfo fileInfo, String newFilePath, InputStream fileStream,String fileFolder) { } kidgrow-business/kidgrow-filecenter/kidgrow-filecenter-server/src/main/java/com/kidgrow/filecenter/config/WebMvcConfig.java
@@ -1,7 +1,10 @@ package com.kidgrow.filecenter.config; import com.kidgrow.common.config.DefaultWebMvcConfig; import com.kidgrow.common.constant.CommonConstant; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; /** * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> @@ -13,4 +16,12 @@ */ @Configuration public class WebMvcConfig extends DefaultWebMvcConfig { @Value("${spring.profiles.active}") private String OssPathEn; @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/"+OssPathEn+"/**").addResourceLocations("file:"+ CommonConstant.TEMP_IMAGE_PATH+"/"+OssPathEn+"/"); } } kidgrow-commons/kidgrow-common-spring-boot-starter/src/main/java/com/kidgrow/common/constant/CommonConstant.java
@@ -253,7 +253,7 @@ /** * 生成缩略图需要的图片暂存目录 */ // public static final String TEMP_IMAGE_PATH="D:/resources/images/"; // public static final String TEMP_IMAGE_PATH="D:/resources/images"; public static final String TEMP_IMAGE_PATH="/root/kidgrow"; /** * 普通医生角色ID kidgrow-config/src/main/resources/application-pri.properties
New file @@ -0,0 +1,92 @@ #\u79C1\u6709\u5316\u90E8\u7F72\u73AF\u5883 ########################## \u7EDF\u4E00\u53D8\u91CF\u914D\u7F6E ########################## ##### \u6570\u636E\u5E93\u914D\u7F6E kidgrow.datasource.ip=192.168.2.252 kidgrow.datasource.username=root kidgrow.datasource.password=123456 spring.datasource.driver-class-name=com.mysql.jdbc.Driver ##### Redis\u914D\u7F6E # \u662F\u5426\u5F00\u542FRedis\u7F13\u5B58 true\u5F00\u542F false \u5173\u95ED spring.redis.open=true spring.redis.host=192.168.2.252 #spring.redis.host=127.0.0.1 spring.redis.port=6379 spring.redis.password=kidgrow spring.redis.timeout=5000 #rabbitmq\u914D\u7F6E kidgrow.rabbitmq.host=192.168.2.252 kidgrow.rabbitmq.port=5672 kidgrow.rabbitmq.username=liuke kidgrow.rabbitmq.password=kidgrow2020 kidgrow.rabbitmq.exchangeName=BoneAgeEvaluation kidgrow.rabbitmq.queueName=test_queue kidgrow.rabbitmq.routingKeyName=Kidgrow2020 kidgrow.rabbitmq.virtual-host=kidgrow #\u963F\u91CCDruid\u914D\u7F6E kidgrow.druid.loginname=admin kidgrow.druid.loginpwd=123456 #eureka \u6CE8\u518C\u4E2D\u5FC3Url kidgrow.eureka.client.serviceUrl.defaultZone=http://192.168.2.252:9001/eureka/ kidgrow.eureka.instance.hostname=192.168.2.252 ##eureka client\u53D1\u9001\u5FC3\u8DF3\u7ED9server\u7AEF\u7684\u9891\u7387 eureka.instance.lease-renewal-interval-in-seconds=30 #eureka client\u95F4\u9694\u591A\u4E45\u53BB\u62C9\u53D6\u670D\u52A1\u6CE8\u518C\u4FE1\u606F\uFF0C\u9ED8\u8BA4\u4E3A30\u79D2\uFF0C\u5BF9\u4E8Eapi-gateway\uFF0C\u5982\u679C\u8981\u8FC5\u901F\u83B7\u53D6\u670D\u52A1\u6CE8\u518C\u72B6\u6001\uFF0C\u53EF\u4EE5\u7F29\u5C0F\u8BE5\u503C\uFF0C\u6BD4\u59825\u79D2 eureka.instance.lease-expiration-duration-in-seconds=30 ##### elasticsearch\u914D\u7F6E kidgrow.elasticsearch.cluster-name=Kidgrow kidgrow.elasticsearch.cluster-nodes=192.168.2.240 ##### sentinel\u914D\u7F6E kidgrow.sentinel.dashboard=127.0.0.1:6999 ##### fastDFS\u914D\u7F6E kidgrow.fdfs.web-url=http://192.168.2.252 kidgrow.fdfs.trackerList=${kidgrow.fdfs.web-url}:22122 ####\u963F\u91CCOSS\u914D\u7F6E kidgrow.oss.access-key=LTAI4FennfcwZupz3B6hkK3N kidgrow.oss.accessKeySecret=NzBBGe8SS41qJlp0nA3tlJ3t74lBZM kidgrow.oss.endpoint=open.oss.kidgrow.cloud kidgrow.oss.bucketName=kidgrow kidgrow.oss.domain=https://open.oss.kidgrow.cloud/ ##### \u65E5\u5FD7\u94FE\u8DEF\u8FFD\u8E2A kidgrow.trace.enable=true ##### \u8D1F\u8F7D\u5747\u8861\u9694\u79BB(version\u9694\u79BB\uFF0C\u53EA\u9002\u7528\u4E8E\u5F00\u53D1\u73AF\u5883) kidgrow.ribbon.isolation.enabled=false ##### mybatis-plus\u6253\u5370\u5B8C\u6574sql(\u53EA\u9002\u7528\u4E8E\u5F00\u53D1\u73AF\u5883) mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl ##### \u5BA1\u8BA1\u65E5\u5FD7\u914D\u7F6E kidgrow.audit-log.enabled=true kidgrow.audit-log.log-type=db kidgrow.audit-log.datasource.driver-class-name=com.mysql.jdbc.Driver kidgrow.audit-log.datasource.jdbc-url=jdbc:mysql://${kidgrow.datasource.ip}:3306/logger_center_${spring.profiles.active}?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai kidgrow.audit-log.datasource.username=${kidgrow.datasource.username} kidgrow.audit-log.datasource.password=${kidgrow.datasource.password} ## appUrl \u9759\u6001\u6587\u4EF6\u4E0A\u4F20\u8DEF\u5F84 appUrl=http://192.168.2.240/upload/ ## \u5FAE\u4FE1\u7EDF\u4E00URL wechat.apiUrl=https://api.weixin.qq.com ## H\u7AEF\u4EA7\u54C1\u9AA8\u9F84\u5C0F\u7A0B\u5E8F\u914D\u7F6E\u4FE1\u606F wechat.miniapp.appid=wx5a9bc7ebd13eb6cc wechat.miniapp.secret=c16d8e42e42137bd7ba6e6999f226803 ## C\u7AEF\u4EA7\u54C1\u516C\u4F17\u53F7\u914D\u7F6E\u4FE1\u606F wechat.xigao.mp.appid=wx1cc7074ce3014652 wechat.xigao.mp.secret=0fa9eb188ae52aa8c2380744109f161c wechat.xigao.mp.token=c83AR9oqRAJNg83A ## C\u7AEF\u4EA7\u54C1\u53EF\u7231\u9AD8\u7B5B\u67E5\u5C0F\u7A0B\u5E8F\u914D\u7F6E\u4FE1\u606F wechat.screening.applets.appid=wx0f3a6409155f1bac wechat.screening.applets.secret=ce485ae3192bb6a6cd68ce140ac81327 health_url_net=http://192.168.2.22/