From 9057e04efad1b7d61c77a72e5c37a504d0aee935 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 26 九月 2025 09:24:03 +0800
Subject: [PATCH] H5静态化

---
 server/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java |  319 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 316 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java b/server/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
index b602f4a..4da47ed 100644
--- a/server/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
+++ b/server/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
@@ -1,28 +1,49 @@
 package com.doumee.biz.system.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.core.constants.Constants;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.utils.qiyeweixin.QywxUtil;
+import com.doumee.dao.business.CarouselMapper;
+import com.doumee.dao.business.InformationMapper;
+import com.doumee.dao.business.SeoMapper;
+import com.doumee.dao.business.model.Carousel;
+import com.doumee.dao.business.model.Information;
+import com.doumee.dao.business.model.Seo;
 import com.doumee.dao.common.dto.UpdateSortDTO;
 import com.doumee.dao.system.model.SystemDict;
 import com.doumee.dao.system.model.SystemDictData;
+import com.doumee.dao.vo.FootDataVO;
 import com.doumee.service.system.SystemDictDataService;
 import com.doumee.service.system.SystemDictService;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import io.swagger.models.Info;
+import io.swagger.models.auth.In;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
 
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.io.*;
+import java.util.*;
 
 @Service
 public class SystemDictDataBizImpl implements SystemDictDataBiz {
 
+    @Autowired
+    private FreeMarkerConfigurer freeMarkerConfigurer;
+    @Autowired
+    private InformationMapper informationMapper;
+    @Autowired
+    private CarouselMapper carouselMapper;
+    @Autowired
+    private SeoMapper seoMapper;
     @Autowired
     private SystemDictDataService systemDictDataService;
     @Autowired
@@ -184,6 +205,7 @@
         return list;
     }
 
+
     @Override
     public void updateByDicId(List<SystemDictData> list) {
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
@@ -214,4 +236,295 @@
         return resourcePath+targetPath;
     }
 
+    @Override
+    public String createPage(Integer pageIndex) {
+        Constants.PageIndex objIndex  = Constants.PageIndex.getObj(pageIndex);
+        if(objIndex == null){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+
+        String flt = objIndex.getTemplate();//妯$増鍚嶇О
+        String html = objIndex.getHtml();//椤甸潰鍚嶇О
+        String domain = queryByCode(Constants.SYSTEM,Constants.WEB_DOMAIN).getCode();
+        String gitUrl = queryByCode(Constants.SYSTEM,Constants.GIT_CODR_URL).getCode();
+        String htmlPath = queryByCode(Constants.SYSTEM,Constants.STATIC_PAGES_PATH).getCode();
+//          domain = ".";
+//          htmlPath = "D://static/";
+        File docFile = new File( htmlPath);
+        if(!docFile.exists()){
+            docFile.mkdirs();
+        }
+        Map<String,Object> dataMap = new HashMap<>();
+        dataMap.put("webDomain",domain);
+        dataMap.put("gitCodeUrl",gitUrl);
+        dataMap.put("navIndex",objIndex.getNavIndex());
+        List<Seo> seoList = seoMapper.selectList(new LambdaQueryWrapper<Seo>().eq(Seo::getIsdeleted,Constants.ZERO));
+        Seo seo =getSeoByHtml(objIndex.getTemplate(),seoList);
+        dataMap.put("seo",seo);
+        initDataMapByPage(dataMap);
+        if(objIndex.getKey() == Constants.PageIndex.dynamicsDetail.getKey() || objIndex.getKey() == Constants.PageIndex.casesDetail.getKey() ){
+            File f = new File(htmlPath+"dynamics/");
+            if(!f.exists()){
+                f.mkdirs();
+            }
+            List<Information> dataList =getInfomationListByType(objIndex.getKey() == Constants.PageIndex.dynamicsDetail.getKey() ?Constants.ZERO:Constants.ONE,null);
+            generateDetailsHtml(dataList,dataMap,flt,htmlPath+html);//鍗曟枃浠舵暟鎹�
+        }else
+        if(objIndex.getKey() == Constants.PageIndex.bannerDetails.getKey()   ){
+            List<Carousel> dataList = carouselMapper.selectList(new LambdaQueryWrapper<Carousel>()
+                    .eq(Carousel::getIsdeleted,Constants.ZERO)
+                    .eq(Carousel::getJumpType,Constants.ONE)//澶栭摼
+                    .orderByDesc(Carousel::getSortnum ,Carousel::getCreateDate));
+            generateBannerDetailsHtml(dataList,dataMap,flt,htmlPath+html);//鍗曟枃浠舵暟鎹�
+        }else{
+            if(objIndex.getKey() == Constants.PageIndex.dynamics.getKey() || objIndex.getKey() == Constants.PageIndex.casesDetail.getKey() ){
+                dataMap.put("dataList", getInfomationListByType(objIndex.getKey() == Constants.PageIndex.dynamics.getKey() ?Constants.ZERO:Constants.ONE,null));
+            }
+            if(objIndex.getKey() == Constants.PageIndex.index.getKey()){
+                //濡傛灉鏄椤�
+                dataMap.put("bannerList",  carouselMapper.selectList(new LambdaQueryWrapper<Carousel>()
+                        .eq(Carousel::getIsdeleted,Constants.ZERO)
+                        .orderByDesc(Carousel::getSortnum ,Carousel::getCreateDate)));
+                dataMap.put("caseList", getInfomationListByType( Constants.ONE,null));
+                List<Information> zixunList =  getInfomationListByType( Constants.ZERO,null);
+                //鎵�灞炴ā鍧� 0琛屼笟璧勮銆�1杩愯惀缁忛獙銆�2鍔熻兘浠嬬粛銆�3甯傚満淇℃伅
+                dataMap.put("yunyingJy", getModelFromListByModule( zixunList ,Constants.ONE));
+                dataMap.put("gongnengJs", getModelFromListByModule( zixunList ,Constants.TWO));
+                dataMap.put("hangyeZx", getModelListFromListByModule( zixunList ,Constants.ZERO));
+                dataMap.put("shichangXx", getModelListFromListByModule( zixunList ,Constants.THREE));
+            }
+            generateSingleHtml(dataMap,flt,htmlPath+html);//鍗曟枃浠舵暟鎹�
+        }
+       return  null;
+    }
+    @Override
+    public String createMobilePage(Integer pageIndex) {
+        Constants.MobilePageIndex objIndex  = Constants.MobilePageIndex.getObj(pageIndex);
+        if(objIndex == null){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        String flt = objIndex.getTemplate();//妯$増鍚嶇О
+        String html = objIndex.getHtml();//椤甸潰鍚嶇О
+        String domain = queryByCode(Constants.SYSTEM,Constants.WEB_DOMAIN_MOBILE).getCode();
+        String htmlPath = queryByCode(Constants.SYSTEM,Constants.STATIC_PAGES_PATH_MOBILE).getCode();
+        File docFile = new File( htmlPath);
+        if(!docFile.exists()){
+            docFile.mkdirs();
+        }
+        Map<String,Object> dataMap = new HashMap<>();
+        dataMap.put("webDomain",domain);
+        dataMap.put("navIndex",objIndex.getNavIndex());
+        dataMap.put("template",flt);
+        List<Seo> seoList = seoMapper.selectList(new LambdaQueryWrapper<Seo>().eq(Seo::getIsdeleted,Constants.ZERO));
+        Seo seo =getSeoByHtml(objIndex.getTemplate(),seoList);
+        dataMap.put("seo",seo);
+        initDataMapByPage(dataMap);
+        if(objIndex.getKey() == Constants.MobilePageIndex.dynamicDetail.getKey() || objIndex.getKey() == Constants.PageIndex.casesDetail.getKey() ){
+            File f = new File(htmlPath+"dynamics/");
+            if(!f.exists()){
+                f.mkdirs();
+            }
+            List<Information> dataList =getInfomationListByType(objIndex.getKey() == Constants.MobilePageIndex.dynamicDetail.getKey() ?Constants.ZERO:Constants.ONE,null);
+            generateDetailsHtml(dataList,dataMap,flt,htmlPath+html);//鍗曟枃浠舵暟鎹�
+        }else  if(objIndex.getKey() == Constants.MobilePageIndex.bannerDetails.getKey()   ){
+            List<Carousel> dataList = carouselMapper.selectList(new LambdaQueryWrapper<Carousel>()
+                    .eq(Carousel::getIsdeleted,Constants.ZERO)
+                    .eq(Carousel::getJumpType,Constants.ONE)//澶栭摼
+                    .orderByDesc(Carousel::getSortnum ,Carousel::getCreateDate));
+            generateBannerDetailsHtml(dataList,dataMap,flt,htmlPath+html);//鍗曟枃浠舵暟鎹�
+        }else  if(objIndex.getKey() == Constants.MobilePageIndex.dynamics.getKey() ){
+            List<Information> zixunList =  getInfomationListByType( Constants.ZERO,null);
+            //鎵�灞炴ā鍧� 0琛屼笟璧勮銆�1杩愯惀缁忛獙銆�2鍔熻兘浠嬬粛銆�3甯傚満淇℃伅
+
+            dataMap.put("gongnengJs", getModelListFromListByModule( zixunList ,Constants.TWO));
+            dataMap.put("hangyeZx", getModelListFromListByModule( zixunList ,Constants.ZERO));
+            dataMap.put("shichangXx", getModelListFromListByModule( zixunList ,Constants.THREE));
+            for (int i = 0; i < 4; i++) {
+                dataMap.put("pageTitle",i==0?"琛屼笟璧勮":(i==1?"杩愯惀缁忛獙":(i==2?"鍔熻兘浠嬬粛":"甯傚満淇℃伅")));
+                dataMap.put("dataList", getModelListFromListByModule( zixunList,i));
+                generateSingleHtml(dataMap,flt,htmlPath+(html.replace("${type}",i+"")));//鍗曟枃浠舵暟鎹�
+            }
+        }else{
+            if(objIndex.getKey() == Constants.MobilePageIndex.index.getKey()){
+                //濡傛灉鏄椤�
+                dataMap.put("bannerList",  carouselMapper.selectList(new LambdaQueryWrapper<Carousel>()
+                        .eq(Carousel::getIsdeleted,Constants.ZERO)
+                        .orderByDesc(Carousel::getSortnum ,Carousel::getCreateDate)));
+                dataMap.put("caseList", getInfomationListByType( Constants.ONE,null));
+            }
+            if(objIndex.getKey() == Constants.MobilePageIndex.index.getKey()
+                    ||objIndex.getKey() == Constants.MobilePageIndex.dynamicIndex.getKey()){
+                //濡傛灉鏄椤�
+                List<Information> zixunList =  getInfomationListByType( Constants.ZERO,null);
+                //鎵�灞炴ā鍧� 0琛屼笟璧勮銆�1杩愯惀缁忛獙銆�2鍔熻兘浠嬬粛銆�3甯傚満淇℃伅
+                dataMap.put("yunyingJy", getModelListFromListByModule( zixunList ,Constants.ONE));
+                dataMap.put("gongnengJs", getModelListFromListByModule( zixunList ,Constants.TWO));
+                dataMap.put("hangyeZx", getModelListFromListByModule( zixunList ,Constants.ZERO));
+                dataMap.put("shichangXx", getModelListFromListByModule( zixunList ,Constants.THREE));
+            }
+            generateSingleHtml(dataMap,flt,htmlPath+html);//鍗曟枃浠舵暟鎹�
+        }
+       return  null;
+    }
+
+    private Information getModelFromListByModule(List<Information> zixunList, Integer m) {
+        if(zixunList !=null){
+            for(Information model :zixunList){
+                if(model.getModule()!=null && Constants.equalsInteger(model.getModule(),m)){
+                    return model;
+                }
+            }
+        }
+        return new Information();
+    }
+    private List getModelListFromListByModule(List<Information> zixunList, Integer m) {
+        List<Information> list = new ArrayList<>();
+        if(zixunList !=null){
+            for(Information model :zixunList){
+                if(model.getModule()!=null && Constants.equalsInteger(model.getModule(),m)){
+                    list.add(model);
+                }
+            }
+        }
+        return list;
+    }
+
+    private Seo getSeoByHtml(String html, List<Seo> seoList) {
+        if(seoList==null || seoList.size()==0){
+            return new Seo();
+        }
+        for(Seo s :seoList){
+            if(StringUtils.equalsIgnoreCase(s.getPageAddr(),html)){
+                return s;
+            }
+        }
+        for(Seo s :seoList){
+            if(StringUtils.equalsIgnoreCase(s.getPageAddr(),Constants.PageIndex.defaultPage.getTemplate())){
+                return s;
+            }
+        }
+        return new Seo();
+    }
+
+    private List<Information> getInfomationListByType(Integer type,Integer limit) {
+        List<Information> dataList =informationMapper.selectList(new LambdaQueryWrapper<Information>()
+                .eq(Information::getType,type)
+                .eq(Information::getIsdeleted,Constants.ZERO)
+                .last(limit!=null,"limit "+limit)
+                .orderByDesc(Information::getSortnum ,Information::getCreateDate) );//鏌ヨ鍏ㄩ儴璧勮
+
+        return dataList;
+    }
+
+    private void generateDetailsHtml(List<Information> dataList, Map<String, Object> dataMap, String flt, String htmlPath) {
+        if(dataList== null){
+            return;
+        }
+        for(Information data :dataList){
+            dataMap.put("data",data);
+            if(Constants.equalsInteger(data.getType(),Constants.ZERO)){
+                int i = Constants.formatIntegerNum(data.getModule());
+                dataMap.put("pageTitle",i==0?"琛屼笟璧勮":(i==1?"杩愯惀缁忛獙":(i==2?"鍔熻兘浠嬬粛":"甯傚満淇℃伅")));
+            }
+            String tt =htmlPath.replace("${id}",data.getId()+"");
+            generateSingleHtml(dataMap,flt,tt);//鍗曟枃浠舵暟鎹�
+        }
+    }
+    private void generateBannerDetailsHtml(List<Carousel> dataList, Map<String, Object> dataMap, String flt, String htmlPath) {
+        if(dataList== null){
+            return;
+        }
+        for(Carousel data :dataList){
+            dataMap.put("data",data);
+            String tt =htmlPath.replace("${id}",data.getId()+"");
+            generateSingleHtml(dataMap,flt,tt);//鍗曟枃浠舵暟鎹�
+        }
+    }
+
+    private void generateSingleHtml(Map<String, Object> dataMap, String flt, String htmlPath)   {
+        try {
+            Configuration configuration = freeMarkerConfigurer.getConfiguration();
+            configuration.setDefaultEncoding("utf-8");
+            Writer out = null;
+
+            // 鍔犺浇妯$増鏂囦欢
+            Template template = configuration.getTemplate(flt);
+            // 鐢熸垚鏁版嵁
+            File docFile = new File( htmlPath);
+            out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(docFile), "UTF-8"));
+            // 杈撳嚭鏂囦欢
+            template.process(dataMap,out);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR);
+        }
+    }
+
+    private void initDataMapByPage(Map<String, Object> dataMap) {
+        dataMap.put("bottom", getFoodDataVO());//缃戠珯搴曢儴淇℃伅
+    }
+
+    public FootDataVO getFoodDataVO(){
+        FootDataVO footDataVO = new FootDataVO();
+        SystemDict d = new SystemDict();
+        d.setCode(Constants.SYSTEM);
+        d.setDeleted(Boolean.FALSE);
+        d = systemDictService.findOne(d);
+        if(d ==null){
+            return footDataVO;
+        }
+        SystemDictData param = new SystemDictData();
+        param.setDictId(d.getId());
+        param.setDeleted(Boolean.FALSE);
+        List<SystemDictData> dictDataList = systemDictDataService.findList(param);
+
+        String path = findDictDataByLabel(dictDataList,Constants.FILE_DIR);
+        footDataVO.setFileDir(path);
+        footDataVO.setFootWords(findDictDataByLabel(dictDataList,Constants.FOOT_WORDS));
+        String temp = footDataVO.getFootWords();
+        footDataVO.setFootWords1(temp);
+        if(StringUtils.indexOf(temp,"dmtt.run")>0){
+            footDataVO.setFootWords1(temp.substring(0,StringUtils.indexOf(temp,"dmtt.run")));
+            footDataVO.setFootWords2(temp.substring(StringUtils.indexOf(temp,"dmtt.run") + "dmtt.run".length()));
+        }
+        footDataVO.setQyemail(findDictDataByLabel(dictDataList,Constants.QYEMAIL));
+        footDataVO.setFootImgUrl(findDictDataByLabel(dictDataList,Constants.FOOT_IMGURL));
+        footDataVO.setFootFullImgUrl(path+ footDataVO.getFootImgUrl());
+        footDataVO.setFootImgUrl2(findDictDataByLabel(dictDataList,Constants.FOOT_IMGURL2));
+        footDataVO.setFootFullImgUrl2(path + footDataVO.getFootImgUrl2());
+        footDataVO.setAddress(findDictDataByLabel(dictDataList,Constants.ADDRESS));
+        footDataVO.setLinkPhone(findDictDataByLabel(dictDataList,Constants.LINK_PHONE));
+        footDataVO.setLinkMobile(findDictDataByLabel(dictDataList,Constants.LINK_MOBILE));
+        String solveScheme =  findDictDataByLabel(dictDataList,Constants.SOLVE_SCHEME);
+        if(Objects.nonNull(solveScheme) & org.apache.commons.lang3.StringUtils.isNotBlank(solveScheme)){
+            footDataVO.setSolveScheme(JSONArray.parseArray(solveScheme));
+        }
+        String wisdomSystem = findDictDataByLabel(dictDataList,Constants.WISDOM_SYSTEM);
+        if(Objects.nonNull(wisdomSystem) & org.apache.commons.lang3.StringUtils.isNotBlank(wisdomSystem )){
+            footDataVO.setWisdomSystem(JSONArray.parseArray(wisdomSystem ));
+        }
+        String honors = findDictDataByLabel(dictDataList,Constants.HONORS);
+        if(Objects.nonNull(wisdomSystem) & org.apache.commons.lang3.StringUtils.isNotBlank(honors)){
+            footDataVO.setHonors(JSONArray.parseArray(honors));
+        }
+        String qylinks = findDictDataByLabel(dictDataList,Constants.YQLINKS);
+        if(Objects.nonNull(qylinks) & org.apache.commons.lang3.StringUtils.isNotBlank(qylinks)){
+            footDataVO.setYqlinks(JSONArray.parseArray(qylinks));
+        }
+        footDataVO.setServerTime(findDictDataByLabel(dictDataList,Constants.SERVER_TIME));
+
+        return footDataVO;
+    }
+    private String findDictDataByLabel(List<SystemDictData> dictDataList, String footWords) {
+        if(dictDataList!=null){
+            for(SystemDictData data:dictDataList){
+                if(StringUtils.equals(footWords,data.getLabel())){
+                    return data.getCode();
+                }
+            }
+        }
+        return "";
+    }
+
+
 }

--
Gitblit v1.9.3