Bladeren bron

【编辑】 文件域名通过开关动态加载

linfutong 3 jaren geleden
bovenliggende
commit
a31e3d8f57
15 gewijzigde bestanden met toevoegingen van 200 en 168 verwijderingen
  1. 54 9
      zd-common/common-core/src/main/java/com/zd/common/core/utils/FileConfigUtils.java
  2. 12 8
      zd-modules/zd-exam/src/main/java/com/zd/exam/controller/ElAIOController.java
  3. 11 10
      zd-modules/zd-exam/src/main/java/com/zd/exam/controller/ElOnePcController.java
  4. 5 3
      zd-modules/zd-exam/src/main/java/com/zd/exam/service/impl/ElCourseServiceImpl.java
  5. 4 6
      zd-modules/zd-exam/src/main/java/com/zd/exam/service/impl/ElPaperServiceImpl.java
  6. 4 2
      zd-modules/zd-exam/src/main/java/com/zd/exam/service/impl/ElUserCertServiceImpl.java
  7. 11 8
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSafeBookController.java
  8. 4 23
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSecurityApplyController.java
  9. 1 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabViolationController.java
  10. 1 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/controller/ApkFileUpLoadController.java
  11. 20 17
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/controller/OneMachineController.java
  12. 4 2
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabAudioSynthesisServiceImpl.java
  13. 16 25
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabNotifyplanServiceImpl.java
  14. 35 25
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/WordService.java
  15. 18 28
      zd-modules/zd-modules-system/src/main/java/com/zd/system/controller/SysLogoConfigController.java

+ 54 - 9
zd-common/common-core/src/main/java/com/zd/common/core/utils/FileConfigUtils.java

@@ -1,26 +1,55 @@
 package com.zd.common.core.utils;
 
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.context.annotation.Configuration;
-
+import org.springframework.stereotype.Component;
 /**
  * 系统文件配置类
  */
 
-@RefreshScope
-@Configuration
-@ConfigurationProperties(prefix = "sys.file")
+@Component
 public class FileConfigUtils {
-    /**
-     * 文件本地地址
-     */
+
+    /**文件本地地址*/
+    @Value("${sys.file.localUrl}")
     private String localUrl;
+
+    /**文件远程地址*/
+    @Value("${sys.file.remoteUrl}")
+    private String remoteUrl;
+
+    /** 是否代理管理端 */
+    @Value("${sys.file.isAgentAdmin}")
+    private Boolean isAgentAdmin;
+
+    /** 是否代理APP端 */
+    @Value("${sys.file.isAgentApp}")
+    private Boolean isAgentApp;
+
+
     /**
-     * 文件远程地址
+     * 获取管理端文件域名
+     * @return
      */
-    private String remoteUrl;
+    public String getFileDomainAdmin() {
+        if (isAgentAdmin == null || !isAgentAdmin) {
+            return localUrl;
+        }
+        return remoteUrl;
+    }
 
+    /**
+     * 获取App端文件域名
+     * @return
+     */
+    public String getFileDomainApp() {
+        if (isAgentApp == null || !isAgentApp) {
+            return localUrl;
+        }
+        return remoteUrl;
+    }
 
     public String getLocalUrl() {
         return localUrl;
@@ -37,4 +66,20 @@ public class FileConfigUtils {
     public void setRemoteUrl(String remoteUrl) {
         this.remoteUrl = remoteUrl;
     }
+
+    public Boolean getAgentAdmin() {
+        return isAgentAdmin;
+    }
+
+    public Boolean getAgentApp() {
+        return isAgentApp;
+    }
+
+    public void setAgentAdmin(Boolean agentAdmin) {
+        isAgentAdmin = agentAdmin;
+    }
+
+    public void setAgentApp(Boolean agentApp) {
+        isAgentApp = agentApp;
+    }
 }

+ 12 - 8
zd-modules/zd-exam/src/main/java/com/zd/exam/controller/ElAIOController.java

@@ -88,11 +88,13 @@ public class ElAIOController extends BaseController {
 
         String url;
         for(ElCourse course:list){
-            if(baseUrl.contains("192.168")){
+            /*if(baseUrl.contains("192.168")){
                 url = fileConfigUtils.getLocalUrl()+ "/"+course.getImg();
             }else {
                 url = fileConfigUtils.getRemoteUrl()+ "/"+course.getImg();
-            }
+            }*/
+            //通过配置加载文件域名
+            url = fileConfigUtils.getFileDomainApp() + "/" + course.getImg();
             url=UrlFormatUtils.getHttpsORHttpUrl(url);
             course.setImg(url);
         }
@@ -106,14 +108,15 @@ public class ElAIOController extends BaseController {
     @GetMapping(value = "/course/{id}")
     public R<ElCourse> getCourseInfo(@PathVariable("id") Long id, HttpServletRequest request) {
         ElCourse elCourse=elCourseService.selectUserCourseById(id,request);
-        String baseUrl = request.getServerName() ;
+        /*String baseUrl = request.getServerName() ;
         String img;
         if(baseUrl.contains("192.168")){
             img=fileConfigUtils.getLocalUrl()+"/"+elCourse.getImg();
         }else {
             img=fileConfigUtils.getRemoteUrl()+"/"+elCourse.getImg();
-        }
-
+        }*/
+        //通过配置加载文件域名
+        String img = fileConfigUtils.getFileDomainApp() + "/" + elCourse.getImg();
         img= UrlFormatUtils.getHttpsORHttpUrl(img);
         elCourse.setImg(img);
         return R.ok(elCourse);
@@ -427,12 +430,13 @@ public class ElAIOController extends BaseController {
         String url;
 
         for(ElUserCert elUserCert: userCerts){
-            if(baseUrl.contains("192.168")){
+            /*if(baseUrl.contains("192.168")){
                 url=fileConfigUtils.getLocalUrl()+ File.separator+elUserCert.getCertUrl();
             }else {
                 url=fileConfigUtils.getRemoteUrl()+ File.separator+elUserCert.getCertUrl();
-            }
-
+            }*/
+            //通过配置加载文件域名
+            url = fileConfigUtils.getFileDomainApp() + File.separator+elUserCert.getCertUrl();
             url= UrlFormatUtils.getHttpsORHttpUrl(url);
             elUserCert.setCertUrl(url);
         }

+ 11 - 10
zd-modules/zd-exam/src/main/java/com/zd/exam/controller/ElOnePcController.java

@@ -44,18 +44,18 @@ public class ElOnePcController extends BaseController {
     public TableDataInfo<ElSafeTrain> safeTrain(ElSafeTrain elSafeTrain, HttpServletRequest request) {
         startPage();
         List<ElSafeTrain> list = elSafeTrainService.selectElSafeTrainList(elSafeTrain);
-        String baseUrl=request.getServerName() ;
+        //String baseUrl=request.getServerName() ;
         String cover="";
-
         for(ElSafeTrain safeTrain:list){
-            if(baseUrl.contains("192.168")){
+            /*if(baseUrl.contains("192.168")){
                 cover=fileConfigUtils.getLocalUrl()+"/"+safeTrain.getCover();
             }else {
                 cover=fileConfigUtils.getRemoteUrl()+"/"+safeTrain.getCover();
-            }
-
-           cover= UrlFormatUtils.getHttpsORHttpUrl(cover);
-           safeTrain.setCover(cover);
+            }*/
+            //通过配置加载文件域名
+            cover = fileConfigUtils.getFileDomainApp() + "/" + safeTrain.getCover();
+            cover= UrlFormatUtils.getHttpsORHttpUrl(cover);
+            safeTrain.setCover(cover);
         }
         return getDataTable(list);
 
@@ -70,13 +70,14 @@ public class ElOnePcController extends BaseController {
     public AjaxResult safeTrainDetail(ElSafeTrain elSafeTrain, HttpServletRequest request) {
         ElSafeTrain elSafe=elSafeTrainService.selectElSafeTrainById(elSafeTrain.getId());
         String baseUrl=request.getServerName() ;
-        String cover="";
+        /*String cover="";
         if(baseUrl.contains("192.168")){
             cover=fileConfigUtils.getLocalUrl()+"/"+elSafe.getCover();
         }else {
             cover=fileConfigUtils.getRemoteUrl()+"/"+elSafe.getCover();
-        }
-
+        }*/
+        //通过配置加载文件域名
+        String cover = fileConfigUtils.getFileDomainApp() + "/" + elSafe.getCover();
         cover= UrlFormatUtils.getHttpsORHttpUrl(cover);
         elSafe.setCover(cover);
         return AjaxResult.success(elSafeTrainService.selectElSafeTrainById(elSafeTrain.getId()));

+ 5 - 3
zd-modules/zd-exam/src/main/java/com/zd/exam/service/impl/ElCourseServiceImpl.java

@@ -132,7 +132,7 @@ public class ElCourseServiceImpl implements IElCourseService {
 
     private void getChildPerms(List<ElCourseChapter> chapterList, ElCourseChapter courseChapter, HttpServletRequest request){
         //处理文件路径
-        String baseUrl=request.getServerName();
+        //String baseUrl=request.getServerName();
         String url="";
 
         // 得到子节点列表
@@ -140,11 +140,13 @@ public class ElCourseServiceImpl implements IElCourseService {
         courseChapter.setChildren(childList);
         for (ElCourseChapter tChild : childList) {
             if(tChild.getType() != 5 && tChild.getType() != 0){
-                if(baseUrl.contains("192.168")){
+                /*if(baseUrl.contains("192.168")){
                     url=fileConfigUtils.getLocalUrl()+tChild.getChapterData();
                 }else{
                     url=fileConfigUtils.getRemoteUrl()+tChild.getChapterData();
-                }
+                }*/
+                //通过配置加载文件域名
+                url = fileConfigUtils.getFileDomainApp() + tChild.getChapterData();
                 tChild.setChapterData(url);
             }
 

+ 4 - 6
zd-modules/zd-exam/src/main/java/com/zd/exam/service/impl/ElPaperServiceImpl.java

@@ -69,10 +69,6 @@ public class ElPaperServiceImpl implements IElPaperService {
     @Autowired
     private IElUserCertService userCertService;
     @Autowired
-    private IElSafeTrainService safeTrainService;
-    @Autowired
-    private IElSafeTrainRecordService safeTrainRecordService;
-    @Autowired
     private IElConvertRecordService convertRecordService;
     @Autowired
     private ElCourseChapterMapper courseChapterMapper;
@@ -471,13 +467,15 @@ public class ElPaperServiceImpl implements IElPaperService {
         map.put("userScore", paper.getUserScore());
         // 如果有证书地址,则显示,否则按钮隐藏
         if(userCertUrl!=null){
-            String baseUrl=request.getServerName() ;
+            /*String baseUrl=request.getServerName() ;
             String url="";
             if(baseUrl.contains("192.168")){
                 url=fileConfigUtils.getLocalUrl()+userCertUrl;
             }else{
                 url=fileConfigUtils.getRemoteUrl()+userCertUrl;
-            }
+            }*/
+            //通过配置加载文件域名
+            String url=fileConfigUtils.getFileDomainApp() + userCertUrl;
             url= UrlFormatUtils.getHttpsORHttpUrl(url);
             map.put("userCertUrl", url);
         }else{

+ 4 - 2
zd-modules/zd-exam/src/main/java/com/zd/exam/service/impl/ElUserCertServiceImpl.java

@@ -104,13 +104,15 @@ public class ElUserCertServiceImpl implements IElUserCertService {
         if(!user.getUserId().equals(myCert.getJoinUserId())){
             throw new ServiceException("证书生成失败,用户不匹配!");
         }
-        String baseUrl=request.getServerName() ;
+        /*String baseUrl=request.getServerName() ;
         String url="";
         if(baseUrl.contains("192.168")){
             url=fileConfigUtils.getLocalUrl()+certificate.getCertUrl();
         }else{
             url=fileConfigUtils.getRemoteUrl()+certificate.getCertUrl();
-        }
+        }*/
+        //通过配置加载文件域名
+        String url = fileConfigUtils.getFileDomainApp() + certificate.getCertUrl();
         url= UrlFormatUtils.getHttpsORHttpUrl(url);
         elUserCert.setCertUrl(url);
         elUserCert.setUserNickName(user.getNickName());

+ 11 - 8
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSafeBookController.java

@@ -84,11 +84,12 @@ public class LabSafeBookController extends BaseController {
             Map<String, String> safe_type = DictUtils.getDictCacheMap("safe_type");
             a.forEach(b->{
                 if(StringUtils.isNotBlank(b.getContent())){
-                    String url=fileConfigUtils.getRemoteUrl()+ File.separator+b.getContent();
+                    /*String url=fileConfigUtils.getRemoteUrl()+ File.separator+b.getContent();
                     if(baseUrl.contains("192.168")){
                         url=fileConfigUtils.getLocalUrl()+ File.separator+b.getContent();
-                    }
-
+                    }*/
+                    //通过配置动态获取域名
+                    String url = fileConfigUtils.getFileDomainApp() + File.separator+b.getContent();
                     url= UrlFormatUtils.getHttpsORHttpUrl(url);
                     b.setContent(url);
                 }
@@ -141,16 +142,18 @@ public class LabSafeBookController extends BaseController {
     public ResultData<LabSafeBook> getInfo(@PathVariable("id") Long id, HttpServletRequest request) {
         // TODO: 2022/3/25  基于内外网访问先做成这个样子,后期优化
         //String baseUrl=request.getServerName();
-        String baseUrl=request.getHeader("X-Real-IP");
-        String baseUrls=request.getHeader("X-Forwarded-For");
-        logger.info("X-Real-IP:"+baseUrl+"  "+"X-Forwarded-For:"+baseUrls);
+        //String baseUrl=request.getHeader("X-Real-IP");
+        //String baseUrls=request.getHeader("X-Forwarded-For");
+        //logger.info("X-Real-IP:"+baseUrl+"  "+"X-Forwarded-For:"+baseUrls);
         LabSafeBook labSafeBook=labSafeBookService.selectLabSafeBookById(id);
-        String url="";
+        /*String url="";
         if(baseUrl.contains("192.168")){
             url=fileConfigUtils.getLocalUrl()+labSafeBook.getContent();
         }else{
             url=fileConfigUtils.getRemoteUrl()+labSafeBook.getContent();
-        }
+        }*/
+        //通过配置动态获取域名
+        String url = fileConfigUtils.getFileDomainApp() + labSafeBook.getContent();
         url= UrlFormatUtils.getHttpsORHttpUrl(url);
         labSafeBook.setContent(url);
         return ResultData.success(labSafeBook);

+ 4 - 23
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSecurityApplyController.java

@@ -98,7 +98,6 @@ public class LabSecurityApplyController extends BaseController
         }else if("11".equals(sysUser.getUserType())){
             //教职工登录,实验室负责人为当前用户的数据
             //labSecurityApplyVO.setSubjectAdminid(sysUser.getUserId());
-
             List<Long> ids = new ArrayList<>();
             LabSubject labSubject = new LabSubject();
             labSubject.setAdminId(sysUser.getUserId());
@@ -111,7 +110,6 @@ public class LabSecurityApplyController extends BaseController
             //labSecurityApply.setUserId(sysUser.getUserId());// 学生登录(学生无审核权限),申请人id 为当前用户id的数据
             return getDataTable(new ArrayList());
         }
-
         startPage();
         List<LabSecurityApplyVO> list = labSecurityApplyService.selectLabSecurityApplyList(labSecurityApplyVO);
         return getDataTable(list);
@@ -709,16 +707,16 @@ public class LabSecurityApplyController extends BaseController
     public void downloadwBatch(HttpServletRequest request, HttpServletResponse response,LabSecurityApplyVO securityApplyVO){
         Map<String, byte[]> files = new HashMap<String, byte[]>();
         String[] urls = securityApplyVO.getFileList().split("@@");
-        String baseUrl=request.getServerName();
+        //String baseUrl=request.getServerName();
         for(int i=0;i<urls.length;i++){
             String[] dataUrl = urls[i].split(";");
             String newUrl = dataUrl[1].substring(0,dataUrl[1].length()-1);
-            String fileUrl="";
-            if(baseUrl.contains("192.168")){
+            String fileUrl= fileConfigUtils.getFileDomainApp() + newUrl;
+            /*if(baseUrl.contains("192.168")){
                 fileUrl=fileConfigUtils.getLocalUrl()+newUrl;
             }else{
                 fileUrl=fileConfigUtils.getRemoteUrl()+newUrl;
-            }
+            }*/
             fileUrl= UrlFormatUtils.getHttpsORHttpUrl(fileUrl);
             try {
                 byte[] f = getFile(fileUrl);
@@ -727,21 +725,6 @@ public class LabSecurityApplyController extends BaseController
                 e.printStackTrace();
             }
         }
-//        Optional.ofNullable(securityApplyVO.getMrList()).orElseGet(Collections::emptyList)
-//                .stream().forEach(a->{
-//                    if(a.getDataUrl()!=null){
-//                        String[] dataUrl = a.getDataUrl().split(";");
-//                        String newUrl = dataUrl[1].substring(0,dataUrl[1].length()-1);
-//                        try {
-//                            byte[] f = getFile(newUrl);
-//                            files.put(dataUrl[0], f);
-//                        } catch (IOException e) {
-//                            e.printStackTrace();
-//                        }
-//
-//                    }
-//        });
-
         //设置下载的压缩包名
         String zipName = securityApplyVO.getUserName() + "_"+ securityApplyVO.getUserNumber()+"_"+ securityApplyVO.getSubjectName() + ".zip";
 
@@ -749,10 +732,8 @@ public class LabSecurityApplyController extends BaseController
         if(files.size() > 0){
             labSecurityApplyService.downloadBatchByFile(response, files, zipName);
         }
-
     }
 
-
     private byte[] getFile(String url) throws IOException{
         URL urlConet = new URL(url);
         HttpURLConnection con = (HttpURLConnection)urlConet.openConnection();

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabViolationController.java

@@ -393,7 +393,7 @@ public class LabViolationController extends BaseController {
         }
         LabViolationInfoVO labViolat= (LabViolationInfoVO) r.getData();
         String avatar=labViolat.getAvatar();
-        String url=fileConfigUtils.getLocalUrl()+ File.separator+avatar;
+        String url=fileConfigUtils.getFileDomainAdmin()+ File.separator+avatar;
         url= UrlFormatUtils.getHttpsORHttpUrl(url);
         labViolat.setAvatar(url);
         r.setData(labViolat);

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/controller/ApkFileUpLoadController.java

@@ -127,7 +127,7 @@ public class ApkFileUpLoadController extends BaseController {
         apkLogVo.setOnepcHardwareNum(hardwareNum);
         ApkLogVo detail = apkFileUpLoadService.selectApkLogDetail(apkLogVo);
         if (detail != null) {
-            String url=fileConfigUtils.getLocalUrl()+ File.separator+detail.getApkFileUpload();
+            String url=fileConfigUtils.getFileDomainAdmin()+ File.separator+detail.getApkFileUpload();
             url= UrlFormatUtils.getHttpsORHttpUrl(url);
             detail.setApkFileUpload(url);
             return ResultData.success(detail);

+ 20 - 17
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/controller/OneMachineController.java

@@ -121,10 +121,10 @@ public class OneMachineController extends BaseController {
         R<SysLogoConfigVO> configLogoResult = userService.getConfigLogo();
         if (HttpStatus.SUCCESS == configLogoResult.getCode()) {
             SysLogoConfigVO sysLogoConfig = configLogoResult.getData();
-            subSimpleVO.setSignMap(fileConfigUtils.getLocalUrl()+sysLogoConfig.getSignMap());
-            subSimpleVO.setVideoCover(fileConfigUtils.getLocalUrl()+sysLogoConfig.getVideoCover());
-            subSimpleVO.setOperationGuide(fileConfigUtils.getLocalUrl()+sysLogoConfig.getOperationGuide());
-            subSimpleVO.setRectangleLogo(fileConfigUtils.getLocalUrl()+sysLogoConfig.getRectangleLogo());
+            subSimpleVO.setSignMap(fileConfigUtils.getFileDomainAdmin()+sysLogoConfig.getSignMap());
+            subSimpleVO.setVideoCover(fileConfigUtils.getFileDomainAdmin()+sysLogoConfig.getVideoCover());
+            subSimpleVO.setOperationGuide(fileConfigUtils.getFileDomainAdmin()+sysLogoConfig.getOperationGuide());
+            subSimpleVO.setRectangleLogo(fileConfigUtils.getFileDomainAdmin()+sysLogoConfig.getRectangleLogo());
         }
         return ResultData.success(subSimpleVO);
     }
@@ -189,13 +189,13 @@ public class OneMachineController extends BaseController {
             Document doc = Jsoup.parse(content);
             Elements imgs=doc.getElementsByTag("img");
             for(Element img:imgs){
-                String url=fileConfigUtils.getLocalUrl()+"/"+img.attr("src");
+                String url=fileConfigUtils.getFileDomainAdmin()+"/"+img.attr("src");
                 url= UrlFormatUtils.getHttpsORHttpUrl(url);
                 img.attr("src",url);
             }
             Elements videos=doc.getElementsByTag("video");
             for(Element video: videos){
-                String url=fileConfigUtils.getLocalUrl()+"/"+video.attr("src");
+                String url=fileConfigUtils.getFileDomainAdmin()+"/"+video.attr("src");
                 url= UrlFormatUtils.getHttpsORHttpUrl(url);
                 video.attr("src",url);
             }
@@ -218,13 +218,15 @@ public class OneMachineController extends BaseController {
             throw new ServiceException("用户:" + username + " 账户停用,请联系管理员");
         }
 
-        String url="";
+        /*String url="";
         String baseUrl=request.getServerName() ;
         if(baseUrl.contains("192.168")){
             url=fileConfigUtils.getLocalUrl()+sysUser.getAvatar();
         }else {
             url=fileConfigUtils.getRemoteUrl()+sysUser.getAvatar();
-        }
+        }*/
+        //通过配置动态加载域名
+        String url = fileConfigUtils.getFileDomainApp() + sysUser.getAvatar();
         String imgUrl = UrlFormatUtils.getHttpsORHttpUrl(url);
         sysUser.setAvatar(imgUrl);
 
@@ -343,15 +345,15 @@ public class OneMachineController extends BaseController {
         List<SysUser> sysList=oneMachineService.querySubOnlineUser(params);
         logger.error("一体机查询实验室人员信息ServerName:" + request.getServerName()+":"+request.getRemoteAddr()+request.getHeader("X-Forwarded-For"));
         logger.error("一体机查询实验室人员信息RequestUrl:" + request.getRequestURL());
-        String baseUrl=request.getServerName() ;
-        logger.error("baseUrl:"+baseUrl);
         String url="";
         for(SysUser sysUser: sysList){
-            if(baseUrl.contains("192.168")){
+            /*if(baseUrl.contains("192.168")){
                 url=fileConfigUtils.getLocalUrl()+sysUser.getAvatar();
             }else {
                 url=fileConfigUtils.getRemoteUrl()+sysUser.getAvatar();
-            }
+            }*/
+            //通过配置动态加载域名
+            url = fileConfigUtils.getFileDomainApp() + sysUser.getAvatar();
             url= UrlFormatUtils.getHttpsORHttpUrl(url);
             logger.error("url:"+url);
             sysUser.setAvatar(url);
@@ -372,14 +374,15 @@ public class OneMachineController extends BaseController {
         String url="";
         String baseUrl=request.getServerName() ;
         for(LabRotationChart rotationChart:list){
-           if(baseUrl.contains("192.168")){
+           /*if(baseUrl.contains("192.168")){
                url=fileConfigUtils.getLocalUrl()+rotationChart.getImgUrl();
            }else {
                url=fileConfigUtils.getRemoteUrl()+rotationChart.getImgUrl();
-           }
-//           String imgUrl= rotationChart.getImgUrl();
-           String imgUrl = UrlFormatUtils.getHttpsORHttpUrl(url);
-           rotationChart.setImgUrl(imgUrl);
+           }*/
+            //通过配置动态加载域名
+            url = fileConfigUtils.getFileDomainApp() + rotationChart.getImgUrl();
+            String imgUrl = UrlFormatUtils.getHttpsORHttpUrl(url);
+            rotationChart.setImgUrl(imgUrl);
         }
         return ResultData.success(list);
     }

+ 4 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabAudioSynthesisServiceImpl.java

@@ -78,13 +78,15 @@ public class LabAudioSynthesisServiceImpl implements ILabAudioSynthesisService
     {
         //设置其他公共字段
         SaveUtil.setCommonAttr(labAudioSynthesis);
-        String baseUrl=request.getServerName() ;
+        /*String baseUrl=request.getServerName() ;
         String url="";
         if(baseUrl.contains("192.168")){
             url=fileConfigUtils.getLocalUrl();
         }else{
             url=fileConfigUtils.getRemoteUrl();
-        }
+        }*/
+        //通过配置加载文件域名
+        String url = fileConfigUtils.getFileDomainApp();
         String newMusic = java.util.UUID.randomUUID()+".mp3";
 //        labAudioSynthesis.setMusicUrl(labAudioSynthesis.getMusicUrl().substring(labAudioSynthesis.getMusicUrl().indexOf("/")+8));
 //        labAudioSynthesis.setBgmusicUrl(labAudioSynthesis.getBgmusicUrl().substring(labAudioSynthesis.getBgmusicUrl().indexOf("/")+8));

+ 16 - 25
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabNotifyplanServiceImpl.java

@@ -148,31 +148,17 @@ public class LabNotifyplanServiceImpl implements ILabNotifyplanService
                 SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
                     //url为空时跳出本次循环
                     if(list.get(0).getContentUrl()!=null) {
-                        String baseUrl=request.getServerName() ;
+                        /*String baseUrl=request.getServerName() ;
                         String url="";
                         if(baseUrl.contains("192.168")){
                             url=fileConfigUtils.getLocalUrl()+list.get(0).getContentUrl();
                         }else{
                             url=fileConfigUtils.getRemoteUrl()+list.get(0).getContentUrl();
-                        }
+                        }*/
+                        //通过配置加载文件域名
+                        String url = fileConfigUtils.getFileDomainApp() + list.get(0).getContentUrl();
                         url= UrlFormatUtils.getHttpsORHttpUrl(url);
 
-                        /*//文件访问路径
-                        //String url = "http://192.168.1.17:9300//statics/2022/02/18/3d78b3c2-8108-4e78-a419-954e4b71a92a.xls";
-                        InputStream intstream = new URL(list.get(0).getContentUrl()).openStream();
-                        List<LabNotifyplanExcelVO> excelList = util.importExcel(intstream);
-                        //list.get(0).setContent(excelList.get(0).getContent());
-                        //list.get(0).setCompany(excelList.get(0).getCompany());
-                        Date date = (Date) sdf.parse(excelList.get(0).getCreateDate());
-                        String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
-                        //String ss = sdf.format(Date.parse(excelList.get(0).getCreateDate()));
-                        *//*Date date = (Date) sdf.parse("Sat Jan 01 10:20:00 CST 2022");
-                        String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);*//*
-                        //System.out.println(DateUtils.dateTime("YYYY-mm-dd HH:mm",excelList.get(0).getCreateDate()));
-                        //list.get(0).setCreateTime(formatStr);
-                        excelList.get(0).setCreateDate(formatStr);
-                        list.get(0).setExcelList(excelList);
-                        intstream.close();*/
                         //文件访问路径
                         //String url = "http://192.168.1.17:9300//statics/2022/02/18/3d78b3c2-8108-4e78-a419-954e4b71a92a.xls";
                         intstream = new URL(url).openStream();
@@ -225,13 +211,15 @@ public class LabNotifyplanServiceImpl implements ILabNotifyplanService
                 SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
                 //url为空时跳出本次循环
                 if(list.get(0).getContentUrl()!=null) {
-                    String baseUrl=request.getServerName() ;
+                    /*String baseUrl=request.getServerName() ;
                     String url="";
                     if(baseUrl.contains("192.168")){
                         url=fileConfigUtils.getLocalUrl()+list.get(0).getContentUrl();
                     }else{
                         url=fileConfigUtils.getRemoteUrl()+list.get(0).getContentUrl();
-                    }
+                    }*/
+                    //通过配置加载文件域名
+                    String url = fileConfigUtils.getFileDomainApp() + list.get(0).getContentUrl();
                     url= UrlFormatUtils.getHttpsORHttpUrl(url);
 
                         /*//文件访问路径
@@ -305,14 +293,15 @@ public class LabNotifyplanServiceImpl implements ILabNotifyplanService
         try {
             //为工作计划时 解析文件是否合格 主要是时间校验
             if(2==labNotifyplan.getType()){
-
-                String baseUrl=request.getServerName() ;
+                /*String baseUrl=request.getServerName() ;
                 String url="";
                 if(baseUrl.contains("192.168")){
                     url=fileConfigUtils.getLocalUrl()+ labNotifyplan.getContentUrl();
                 }else{
                     url=fileConfigUtils.getRemoteUrl()+ labNotifyplan.getContentUrl();
-                }
+                }*/
+                //通过配置加载文件域名
+                String url = fileConfigUtils.getFileDomainApp() + labNotifyplan.getContentUrl();
                 url= UrlFormatUtils.getHttpsORHttpUrl(url);
 
                 ExcelUtil<LabNotifyplanExcelVO> util = new ExcelUtil<>(LabNotifyplanExcelVO.class);
@@ -399,13 +388,15 @@ public class LabNotifyplanServiceImpl implements ILabNotifyplanService
                 SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
 
                         if(list.get(0).getContentUrl()!=null) {
-                            String baseUrl=request.getServerName() ;
+                            /*String baseUrl=request.getServerName() ;
                             String url="";
                             if(baseUrl.contains("192.168")){
                                 url=fileConfigUtils.getLocalUrl()+list.get(0).getContentUrl();
                             }else{
                                 url=fileConfigUtils.getRemoteUrl()+list.get(0).getContentUrl();
-                            }
+                            }*/
+                            //通过配置加载文件域名
+                            String url = fileConfigUtils.getFileDomainApp() + list.get(0).getContentUrl();
                             url= UrlFormatUtils.getHttpsORHttpUrl(url);
 
                             //文件访问路径

+ 35 - 25
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/WordService.java

@@ -119,11 +119,11 @@ public class WordService {
                 throw new ServiceException("生成失败,ID无效!");
             }
 
-            String baseUrl = request.getServerName();
+            /*String baseUrl = request.getServerName();
             boolean isIntranet = false;
             if(baseUrl.contains("192.168")){
                 isIntranet = true;
-            }
+            }*/
 
             LabCheckRecordDetails labCheckRecordDetails = new LabCheckRecordDetails();
             labCheckRecordDetails.setCheckId(checkRecord.getId());
@@ -147,16 +147,17 @@ public class WordService {
             if(deptSign == null){
                 deptSign = "";
             }else {
-                deptSign = (isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + deptSign;
+                //deptSign = (isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + deptSign;
+                //通过配置加载文件域名
+                deptSign = fileConfigUtils.getFileDomainApp() + deptSign;
             }
 
-//            word2.setCheck_dept_sign(new PictureRenderData(100, 100, PictureType.PNG, BufferedImageUtils.getUrlBufferedImage(deptSign)));
+            //word2.setCheck_dept_sign(new PictureRenderData(100, 100, PictureType.PNG, BufferedImageUtils.getUrlBufferedImage(deptSign)));
             word2.setCheck_dept_sign(new SignPictureRenderData(100, 100, deptSign, "图片加载失败", 310 ,-35));
             word2.setCheck_dept_name(checkRecord.getJcDwName());
             word2.setCheck_result(checkRecord.getZgJg());
 
             Date now = new Date();
-
             word2.setNow_year(DateUtil.year(now) + "");
             word2.setNow_month((DateUtil.month(now) + 1) + "");
             word2.setNow_day(DateUtil.dayOfMonth(now) + "");
@@ -167,8 +168,10 @@ public class WordService {
 
             String signature = labCheckRecordMapper.selectSignatureByUserId(checkRecord.getCreateUserId());
             word2.setCheck_nick_name(new PictureRenderData(100, 30, PictureType.PNG, BufferedImageUtils.getUrlBufferedImage(
-                            (isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + signature
-                    )));
+                            //(isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + signature
+                    //通过配置加载文件域名
+                    deptSign = fileConfigUtils.getFileDomainApp() + signature
+            )));
 
             List<Word2.Detail> list = new ArrayList<>();
 
@@ -214,19 +217,25 @@ public class WordService {
                 String yhImgs = checkRecordDetails.get(i).getYhImg();
                 String[] imgs = yhImgs.split(",");
                 if(imgs.length > 0){
-                    detail.setCheck_img1((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[0]);
+                    //detail.setCheck_img1((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[0]);
+                    //通过配置加载文件域名
+                    detail.setCheck_img1(fileConfigUtils.getFileDomainApp() + imgs[0]);
                 }
                 if(imgs.length > 1){
-                    detail.setCheck_img2((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[1]);
+                    //detail.setCheck_img2((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[1]);
+                    detail.setCheck_img2(fileConfigUtils.getFileDomainApp() + imgs[1]);
                 }
                 if(imgs.length > 2){
-                    detail.setCheck_img3((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[2]);
+                    //detail.setCheck_img3((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[2]);
+                    detail.setCheck_img3(fileConfigUtils.getFileDomainApp() + imgs[2]);
                 }
                 if(imgs.length > 3){
-                    detail.setCheck_img4((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[3]);
+                    //detail.setCheck_img4((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[3]);
+                    detail.setCheck_img4(fileConfigUtils.getFileDomainApp() + imgs[3]);
                 }
                 if(imgs.length > 4){
-                    detail.setCheck_img5((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[4]);
+                    //detail.setCheck_img5((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[4]);
+                    detail.setCheck_img5(fileConfigUtils.getFileDomainApp() + imgs[4]);
                 }
 
                 list.add(detail);
@@ -250,11 +259,11 @@ public class WordService {
                 throw new ServiceException("生成失败,ID无效!");
             }
 
-            String baseUrl = request.getServerName();
+            /*String baseUrl = request.getServerName();
             boolean isIntranet = false;
             if(baseUrl.contains("192.168")){
                 isIntranet = true;
-            }
+            }*/
 
             LabCheckRecordDetails labCheckRecordDetails = new LabCheckRecordDetails();
             labCheckRecordDetails.setCheckId(checkRecord.getId());
@@ -281,7 +290,8 @@ public class WordService {
             if(deptSign == null){
                 deptSign = "";
             }else {
-                deptSign = (isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + deptSign;
+                //deptSign = (isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + deptSign;
+                deptSign = fileConfigUtils.getFileDomainApp() + deptSign;
             }
             word3.setCheck_dept_sign(new SignPictureRenderData(100, 100, deptSign, "图片加载失败", 300 ,-55));
 
@@ -298,11 +308,6 @@ public class WordService {
                 // 添加检查项 编码之后补充
                 // 数据形式存在 1,2,3, 1,, 1,  31,,, 等形式,故需要特殊处理
                 if(checkRecordDetails.get(i).getJcxId() != null){
-//                    optionId = checkRecordDetails.get(i).getJcxId().substring(0, checkRecordDetails.get(i).getJcxId().lastIndexOf(","));
-//                    if(optionId.lastIndexOf(",") != -1){
-//                        optionId = optionId.substring(optionId.lastIndexOf(","));
-//                    }
-
                     String[] ids = checkRecordDetails.get(i).getJcxId().split(",");
                     List<String> list1 = Arrays.asList(ids);
                     for (int i1 = 0; i1 < list1.size(); i1++) {
@@ -349,19 +354,24 @@ public class WordService {
                 String yhImgs = checkRecordDetails.get(i).getYhImg();
                 String[] imgs = yhImgs.split(",");
                 if(imgs.length > 0){
-                    desc.setCheck_img1((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[0]);
+                    //desc.setCheck_img1((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[0]);
+                    desc.setCheck_img1(fileConfigUtils.getFileDomainApp() + imgs[0]);
                 }
                 if(imgs.length > 1){
-                    desc.setCheck_img2((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[1]);
+                    //desc.setCheck_img2((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[1]);
+                    desc.setCheck_img2(fileConfigUtils.getFileDomainApp() + imgs[1]);
                 }
                 if(imgs.length > 2){
-                    desc.setCheck_img3((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[2]);
+                    //desc.setCheck_img3((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[2]);
+                    desc.setCheck_img3(fileConfigUtils.getFileDomainApp() + imgs[2]);
                 }
                 if(imgs.length > 3){
-                    desc.setCheck_img4((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[3]);
+                    //desc.setCheck_img4((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[3]);
+                    desc.setCheck_img4(fileConfigUtils.getFileDomainApp() + imgs[3]);
                 }
                 if(imgs.length > 4){
-                    desc.setCheck_img5((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[4]);
+                    //desc.setCheck_img5((isIntranet ? fileConfigUtils.getLocalUrl() :  fileConfigUtils.getRemoteUrl())  + imgs[4]);
+                    desc.setCheck_img5(fileConfigUtils.getFileDomainApp() + imgs[4]);
                 }
                 descs.add(desc);
             }

+ 18 - 28
zd-modules/zd-modules-system/src/main/java/com/zd/system/controller/SysLogoConfigController.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.io.IOException;
 import java.util.Optional;
 import javax.servlet.http.HttpServletResponse;
+
 import com.github.xiaoymin.knife4j.annotations.ApiSupport;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.log.BusinessType;
@@ -38,8 +39,7 @@ import io.swagger.annotations.ApiOperation;
 //作者手动加入 ,在接口上加作者@ApiOperationSupport(author = "XXX")
 @ApiSupport(author = Knife4jConfiguration.Author.CYL)
 @RequestMapping("/logo/config")
-public class SysLogoConfigController extends BaseController
-{
+public class SysLogoConfigController extends BaseController {
     @Autowired
     private ISysLogoConfigService sysLogoConfigService;
     @Autowired
@@ -50,8 +50,7 @@ public class SysLogoConfigController extends BaseController
      */
     @GetMapping("/list")
     @ApiOperation(value = "查询logo配置列表")
-    public TableDataInfo<SysLogoConfig> list(SysLogoConfig sysLogoConfig)
-    {
+    public TableDataInfo<SysLogoConfig> list(SysLogoConfig sysLogoConfig) {
         startPage();
         List<SysLogoConfig> list = sysLogoConfigService.selectSysLogoConfigList(sysLogoConfig);
         return getDataTable(list);
@@ -63,8 +62,7 @@ public class SysLogoConfigController extends BaseController
     @ApiOperation(value = "导出logo配置列表")
     @Log(title = "logo配置", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, SysLogoConfig sysLogoConfig) throws IOException
-    {
+    public void export(HttpServletResponse response, SysLogoConfig sysLogoConfig) throws IOException {
         List<SysLogoConfig> list = sysLogoConfigService.selectSysLogoConfigList(sysLogoConfig);
         ExcelUtil<SysLogoConfig> util = new ExcelUtil<SysLogoConfig>(SysLogoConfig.class);
         util.exportExcel(response, list, "logo配置数据");
@@ -75,8 +73,7 @@ public class SysLogoConfigController extends BaseController
      */
     @ApiOperation(value = "获取logo配置详细信息")
     @GetMapping(value = "/{id}")
-    public ResultData<SysLogoConfig> getInfo(@PathVariable("id") Long id)
-    {
+    public ResultData<SysLogoConfig> getInfo(@PathVariable("id") Long id) {
         return ResultData.success(sysLogoConfigService.selectSysLogoConfigById(id));
     }
 
@@ -86,8 +83,7 @@ public class SysLogoConfigController extends BaseController
     @ApiOperation(value = "新增logo配置")
     @Log(title = "logo配置", businessType = BusinessType.INSERT)
     @PostMapping
-    public ResultData add(@RequestBody SysLogoConfig sysLogoConfig)
-    {
+    public ResultData add(@RequestBody SysLogoConfig sysLogoConfig) {
         return ResultData.result(sysLogoConfigService.insertSysLogoConfig(sysLogoConfig));
     }
 
@@ -97,9 +93,8 @@ public class SysLogoConfigController extends BaseController
     @ApiOperation(value = "修改logo配置")
     @Log(title = "logo配置", businessType = BusinessType.UPDATE)
     @PutMapping
-    public ResultData edit(@RequestBody SysLogoConfig sysLogoConfig)
-    {
-        return  ResultData.result(sysLogoConfigService.updateSysLogoConfig(sysLogoConfig));
+    public ResultData edit(@RequestBody SysLogoConfig sysLogoConfig) {
+        return ResultData.result(sysLogoConfigService.updateSysLogoConfig(sysLogoConfig));
     }
 
     /**
@@ -107,9 +102,8 @@ public class SysLogoConfigController extends BaseController
      */
     @ApiOperation(value = "删除logo配置")
     @Log(title = "logo配置", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public ResultData remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public ResultData remove(@PathVariable Long[] ids) {
         return ResultData.result(sysLogoConfigService.deleteSysLogoConfigByIds(ids));
     }
 
@@ -120,30 +114,27 @@ public class SysLogoConfigController extends BaseController
      */
     @GetMapping("/getLogoInfo")
     @ApiOperation(value = "查询logo配置列表")
-    public ResultData<SysLogoConfig> getLogoInfo(SysLogoConfig sysLogoConfig)
-    {
+    public ResultData<SysLogoConfig> getLogoInfo(SysLogoConfig sysLogoConfig) {
         List<SysLogoConfig> list = sysLogoConfigService.selectSysLogoConfigList(sysLogoConfig);
-        if(list.size()>0){
+        if (list.size() > 0) {
             SysLogoConfig logoConfig = list.get(0);
             return ResultData.success(logoConfig);
         }
         return ResultData.success(new SysLogoConfig());
     }
 
-
     /**
      * 查询logo配置基本信息数据(漏过token验证)
      * 终端使用   完整路径
      */
     @GetMapping("/getConfInfo")
     @ApiOperation(value = "查询logo配置列表")
-    public ResultData<SysLogoConfig> getConfInfo(SysLogoConfig sysLogoConfig)
-    {
+    public ResultData<SysLogoConfig> getConfInfo(SysLogoConfig sysLogoConfig) {
         List<SysLogoConfig> list = sysLogoConfigService.selectSysLogoConfigList(sysLogoConfig);
-        if(list.size()>0){
+        if (list.size() > 0) {
             SysLogoConfig logoConfig = list.get(0);
-            logoConfig.setCircularLogo(fileConfigUtils.getLocalUrl() + Optional.ofNullable(logoConfig.getCircularLogo()).orElse(""));
-            logoConfig.setRectangleLogo(fileConfigUtils.getLocalUrl() + Optional.ofNullable(logoConfig.getRectangleLogo()).orElse(""));
+            logoConfig.setCircularLogo(fileConfigUtils.getFileDomainAdmin() + Optional.ofNullable(logoConfig.getCircularLogo()).orElse(""));
+            logoConfig.setRectangleLogo(fileConfigUtils.getFileDomainAdmin() + Optional.ofNullable(logoConfig.getRectangleLogo()).orElse(""));
             return ResultData.success(logoConfig);
         }
         return ResultData.success(new SysLogoConfig());
@@ -155,8 +146,7 @@ public class SysLogoConfigController extends BaseController
     @ApiOperation(value = "修改logo配置")
     @Log(title = "logo配置", businessType = BusinessType.UPDATE)
     @PutMapping("/updateLogoInfo")
-    public ResultData updateLogoInfo(@RequestBody SysLogoConfig sysLogoConfig)
-    {
-        return  ResultData.result(sysLogoConfigService.updateSysLogoConfig(sysLogoConfig));
+    public ResultData updateLogoInfo(@RequestBody SysLogoConfig sysLogoConfig) {
+        return ResultData.result(sysLogoConfigService.updateSysLogoConfig(sysLogoConfig));
     }
 }