ss
doum
2025-09-19 61247957fe4d94591e37d75eda6889f06c0cb9c1
server/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
@@ -22,6 +22,8 @@
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;
@@ -240,22 +242,36 @@
        if(objIndex == null){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
//        freeMarkerConfigurer.setPreferFileSystemAccess(true);
//        freeMarkerConfigurer.setTemplateLoaderPath(queryByCode(Constants.SYSTEM,Constants.PAGE_TEMPLATES_PATH).getCode());
        String flt = objIndex.getTemplate();//模版名称
        String html = objIndex.getHtml();//页面名称
        String domain = queryByCode(Constants.SYSTEM,Constants.WEB_DOMAIN).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("navIndex",objIndex.getNavIndex());
        List<Seo> seoList = seoMapper.selectList(new LambdaQueryWrapper<Seo>().eq(Seo::getIsdeleted,Constants.ZERO));
        dataMap.put("seo",getSeoByHtml(Constants.PageIndex.getObj(pageIndex).getHtml(),seoList));
        initDataMapByPage(objIndex,dataMap);
        if(objIndex.getKey() == Constants.PageIndex.dynamicsDetail.getKey() || objIndex.getKey() == Constants.PageIndex.dynamicsDetail.getKey() ){
            List<Information> dataList =getInfomationListByType(objIndex.getKey() == Constants.PageIndex.dynamics.getKey() ?Constants.ZERO:Constants.ONE,null);
        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() ){
            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));
@@ -265,12 +281,93 @@
                dataMap.put("bannerList",  carouselMapper.selectList(new LambdaQueryWrapper<Carousel>()
                        .eq(Carousel::getIsdeleted,Constants.ZERO)
                        .orderByDesc(Carousel::getSortnum ,Carousel::getCreateDate)));
                dataMap.put("caseList", getInfomationListByType( Constants.ONE,12));
                dataMap.put("zixunList", getInfomationListByType( Constants.ZERO,12));
                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);
        }
//        freeMarkerConfigurer.setPreferFileSystemAccess(true);
//        freeMarkerConfigurer.setTemplateLoaderPaths(queryByCode(Constants.SYSTEM,Constants.PAGE_TEMPLATES_PATH_MOBILE).getCode());
        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());
        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.dynamicsDetail.getKey() || objIndex.getKey() == Constants.PageIndex.casesDetail.getKey() ){
            List<Information> dataList =getInfomationListByType(objIndex.getKey() == Constants.MobilePageIndex.dynamicsDetail.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() || objIndex.getKey() == Constants.MobilePageIndex.casesDetail.getKey() ){
                dataMap.put("dataList", getInfomationListByType(objIndex.getKey() == Constants.MobilePageIndex.dynamics.getKey() ?Constants.ZERO:Constants.ONE,null));
            }
            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));
                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;
    }
    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) {
@@ -279,6 +376,11 @@
        }
        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;
            }
        }
@@ -301,20 +403,32 @@
        }
        for(Information data :dataList){
            dataMap.put("data",data);
            generateSingleHtml(dataMap,flt,htmlPath.replace("${id}",data.getId()+""));//单文件数据
            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)));
            out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(docFile), "UTF-8"));
            // 输出文件
            template.process(dataMap,out);
        } catch (Exception e) {
@@ -323,7 +437,7 @@
        }
    }
    private void initDataMapByPage(Constants.PageIndex objIndex, Map<String, Object> dataMap) {
    private void initDataMapByPage(Map<String, Object> dataMap) {
        dataMap.put("bottom", getFoodDataVO());//网站底部信息
    }
@@ -344,6 +458,7 @@
        String path = findDictDataByLabel(dictDataList,Constants.FILE_DIR);
        footDataVO.setFileDir(path);
        footDataVO.setFootWords(findDictDataByLabel(dictDataList,Constants.FOOT_WORDS));
        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));
@@ -363,11 +478,14 @@
        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){