springboot+poi-tl根据模板导出word(含动态表格和图片),并将导出的文档压缩zip导出

springboot+poi-tl根据模板导出word(含动态表格和图片)

官网:http://deepoove.com/poi-tl/
参考网站:https://blog.csdn.net/M625387195/article/details/124855854

  • pom导入的maven依赖
<dependency>
	<groupId>com.deepoove</groupId>
	<artifactId>poi-tl</artifactId>
	<version>1.12.1</version>
</dependency>
  • 准备模板
    在这里插入图片描述
    文本标签用{{ }},动态表格的字段标签用[]。

  • 代码实现
    3.1 控制器

    package io.renren.modules.sys.controller;
    import io.renren.common.utils.R;
    import io.renren.modules.sys.service.POIService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    /**
     * @Author: Administrator
     * @Date: 2024/3/14
     * @Description:
     */
    @RestController
    @RequestMapping("/anli")
    public class AnliController {
    
        @Autowired
        private POIService poiService;
    
        @GetMapping("/daochu/{renwuId}")
        public R daochu(@PathVariable("renwuId") Long renwuId) {
            String zipUrl = poiService.anlidaochu(renwuId);
            return new R().put("zipUrl", zipUrl);
        }
    }
    

    3.2 实现类

    package io.renren.modules.sys.service;
    
    /**
     * @Author: Administrator
     * @Date: 2024/3/4
     * @Description:
     */
    public interface POIService {
        /**
         * 案例导出
         * @param renwuId
         */
        String anlidaochu(Long renwuId);
    }
    
    package io.renren.modules.sys.service.impl;
    	
    import io.renren.common.utils.word.WordUtils;
    import io.renren.modules.sys.dto.RenwuTemplateDTO;
    import io.renren.modules.sys.service.POIService;
    import io.renren.modules.sys.service.SysRenwuService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.scheduling.annotation.Async;
    import org.springframework.stereotype.Service;
    
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.List;
    import java.util.UUID;
    import java.util.concurrent.CompletableFuture;
    import java.util.zip.ZipOutputStream;
    
    /**
     * @Author: Administrator
     * @Date: 2024/3/4
     * @Description:
     */
    @Service
    public class POIServiceImpl implements POIService {
        @Autowired
        private SysRenwuService renwuService;
        @Value("${upload.url}")
        private String UPLOAD_URL;
        @Value("${upload.path}")
        private String UPLOAD_SUFFIX_URL;
        public String getUPLOAD_URL() {
            return UPLOAD_URL + getUploadSuffixURL();
        }
        public String getUploadSuffixURL() {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
            String dateString = sdf.format(new Date());
            return UPLOAD_SUFFIX_URL + dateString + "/";
        }
    
        /**
         * 案例导出
         * @param renwuId
         */
        @Override
        public String anlidaochu(Long renwuId) {
        	// 将要生成文档的数据查询出来
            RenwuTemplateDTO renwuTemplateDTO = renwuService.daochuByRenwuId(renwuId);
            String url = null;
            if (renwuTemplateDTO != null) {
                try {
                    List<String> urlList = WordUtils.piliangDaochu(renwuTemplateDTO);
                    if (urlList != null && urlList.size() > 0) {
                        String name = renwuTemplateDTO.getRenwuName()+"_"+ UUID.randomUUID() +".zip";
                        url =  this.getUploadSuffixURL() + name;
                        FileOutputStream fos = new FileOutputStream(this.getUPLOAD_URL() + name);
                        ZipOutputStream zos = new ZipOutputStream(fos);
                        for (String file : urlList) {
                            WordUtils.addToZipFile(file, zos);
                        }
                        zos.close();
                        fos.close();
                        // 使用异步线程删除文件
                        deleteFilesAsync(urlList);
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            return url;
        }
    
        @Async
        public CompletableFuture<Void> deleteFilesAsync(List<String> urlList) {
            for (String file : urlList) {
                File fileToDelete = new File(file);
                if (fileToDelete.exists()) {
                    if (fileToDelete.delete()) {
                        System.out.println("Deleted file: " + file);
                    } else {
                        System.out.println("Failed to delete file: " + file);
                    }
                }
            }
            return CompletableFuture.completedFuture(null);
        }
    }
    

    3.3 配置文件

    upload:
      url: H:/GoTionBackends/2023/resources
      path: /u/cms/www/
      outPath: H:/GoTionBackends/2023/resources/doc
      prefix: http://xxx.xxx.xxx:8087
    

    3.4 工具类

    package io.renren.common.utils.word;
    
    import com.alibaba.fastjson.JSON;
    import com.deepoove.poi.XWPFTemplate;
    import com.deepoove.poi.config.Configure;
    import com.deepoove.poi.data.*;
    import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
    import com.deepoove.poi.policy.PictureRenderPolicy;
    import io.renren.common.utils.word.dto.WordQingdanDetailsDTO;
    import io.renren.modules.sys.dto.RenwuTemplateDTO;
    import io.renren.modules.sys.entity.SysQingdanExtEntity;
    import org.apache.commons.lang.StringUtils;
    
    import java.io.*;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.UUID;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    
    /**
     * @Author: Administrator
     * @Date: 2024/3/1
     * @Description:
     */
    public class WordUtils {
        public static List<String> piliangDaochu(RenwuTemplateDTO renwuTemplate) throws IOException {
            List<String> urlList = new ArrayList<>();
            if (renwuTemplate.getQingdanDTOList() != null && renwuTemplate.getQingdanDTOList().size() > 0) {
                for (int i = 0; i < renwuTemplate.getQingdanDTOList().size(); i++) {
                    renwuTemplate.setQingdanDTO(renwuTemplate.getQingdanDTOList().get(i));
                    String daochuUrl = daochumoban(renwuTemplate);
                    urlList.add(daochuUrl);
                }
            } else {
                String daochuUrl =daochumoban(renwuTemplate);
                urlList.add(daochuUrl);
            }
            return urlList;
        }
    
        public static String daochumoban(RenwuTemplateDTO renwuTemplate) throws IOException {
            // 为表格的显示绑定行循环
            LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
            // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
            Configure configure = Configure.builder().bind("bz", policy).build();
            // 图片标签集合
            List<String> pictureTag = new ArrayList<>();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            HashMap<String, Object> dataMap = new HashMap<String, Object>() {
                {
                    //添加文本
                    put("xiangmuName", renwuTemplate.getXiangmuName());
                    put("xiangmuzhouqi", renwuTemplate.getXiangmuzhouqi());
                    put("renwuName", renwuTemplate.getRenwuName());
                    put("renwuzhouqi", sdf.format(renwuTemplate.getStartTime()) + " 至 " + sdf.format(renwuTemplate.getEndTime()));
                    put("description", renwuTemplate.getDescription());
                    String xiangmuLink = "";
                    if (renwuTemplate.getRenwuResourceUrlList() != null && renwuTemplate.getRenwuResourceUrlList().size() > 0) {
                        for (int i = 0; i < renwuTemplate.getRenwuResourceUrlList().size(); i++) {
                            if (i != renwuTemplate.getRenwuResourceUrlList().size()-1) {
                                xiangmuLink += PeizhiConfig.getUploadPrefix() + renwuTemplate.getRenwuResourceUrlList().get(i) + "\n";
                            } else {
                                xiangmuLink += PeizhiConfig.getUploadPrefix() + renwuTemplate.getRenwuResourceUrlList().get(i);
                            }
                        }
                    }
                    put("xiangmulink", xiangmuLink );
                    put("biaoqianName", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getBiaoqianName() : "");
                    String diliurk = PeizhiConfig.getUploadUrl() + renwuTemplate.getQingdanDTO().getResourceUrl();
                    PictureRenderData pictureRenderData = Pictures.ofStream(Files.newInputStream(Paths.get(diliurk)), PictureType.PNG)
                            .size(200, 150).create();
                    put("dililink", pictureRenderData);
                    put("resourceDescription", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getDescription() : "");
                    put("startYear", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getStartYear() : "");
                    put("endYear", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getEndYear(): "");
                    put("area", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getArea() : "");
                    // 其他业务获取到数据源
                    String testTable = null;
                    if (renwuTemplate.getQingdanDTO() != null && renwuTemplate.getQingdanDTO().getQingdanExtList() != null &&  renwuTemplate.getQingdanDTO().getQingdanExtList().size() > 0) {
                        String str = "";
                        for (int i = 0; i < renwuTemplate.getQingdanDTO().getQingdanExtList().size(); i++) {
                            SysQingdanExtEntity ext = renwuTemplate.getQingdanDTO().getQingdanExtList().get(i);
                            String templateType = null, data = PeizhiConfig.getUploadPrefix() + ext.getResourceUrl();
                           // PictureRenderData pictureRenderData1 = null;
                            if (ext.getTemplateType() == 1) {
                                templateType = "图片";
                                //String dataUrl = PeizhiConfig.getUploadUrl() + ext.getResourceUrl();
                                //pictureRenderData1 = Pictures.ofStream(Files.newInputStream(Paths.get(dataUrl)), PictureType.PNG)
                                //        .size(200, 150).create();
                            } else if (ext.getTemplateType() == 2) {
                                templateType = "附件";
                            } else if (ext.getTemplateType() == 3) {
                                templateType = "音视频";
                            } else if (ext.getTemplateType() == 4) {
                                templateType = "文本";
                                data = ext.getExtText();
                            } else if (ext.getTemplateType() == 5) {
                                templateType = "文档";
                            }
                            String source = StringUtils.isNotBlank(ext.getSource()) ? ext.getSource() : "";
                            data = StringUtils.isNotBlank(data) ? data : "";
                            str += "{\n" +
                                    "        \"index\": \"" + (i + 1) + "\",\n" +
                                    "        \"templateName\": \"" + ext.getTemplateName() + "\",\n" +
                                    "        \"templateType\": \"" + templateType + "\",\n" +
                                    "        \"source\": \"" + source + "\",\n" +
                                    "        \"data\": \"" + data + "\",\n" +
                                    "    },\n";
    
                        }
                        testTable = "[" + str + "]";
                    }
                    // 内容在表格里循环
                    // JSON使用,需要导入fastjson依赖
                    List<WordQingdanDetailsDTO> forms = JSON.parseArray(testTable, WordQingdanDetailsDTO.class);
                    if (forms != null && forms.size() > 0) {
                        for (int i = 0; i < forms.size(); i++) {
                            put("index" + i, forms.get(i).getIndex());
                            put("templateName" + i, forms.get(i).getTemplateName());
                            put("templateType" + i, forms.get(i).getTemplateType());
                            put("source" + i, forms.get(i).getSource());
                            put("data" + i, forms.get(i).getData());
                        }
                    }
                    put("bz", forms);
                    pictureTag.add("dililink");
                }
            };
            for (String tag : pictureTag ) {
                //设置图片,不然保存的是一串字符
                configure.customPolicy(tag, new PictureRenderPolicy());
            }
            if (!new File(PeizhiConfig.getUploadOutPath()).exists()) {
                new File(PeizhiConfig.getUploadOutPath()).mkdirs();
            }
            String outPath = PeizhiConfig.getUploadOutPath() + "/"+ UUID.randomUUID() +".docx";
            // 读取模板、数据并渲染
    
            XWPFTemplate template = XWPFTemplate.compile(new FileInputStream(PeizhiConfig.getUploadOutPath() + "/任务数据.docx"), configure).render(dataMap);
            //  文件是否已存在,则删除
            File file = new File(outPath);
            if (file.exists()) {
                file.delete();
            }
            // 生成word保存在指定目录
            //template.writeToFile(outPath);
            template.writeAndClose(Files.newOutputStream(Paths.get(outPath)));
            template.close();
            return outPath;
        }
    
        public static void addToZipFile(String filePath, ZipOutputStream zos) throws IOException {
            File file = new File(filePath);
            FileInputStream fis = new FileInputStream(file);
            ZipEntry zipEntry = new ZipEntry(file.getName());
            zos.putNextEntry(zipEntry);
            byte[] bytes = new byte[1024];
            int length;
            while ((length = fis.read(bytes)) >= 0) {
                zos.write(bytes, 0, length);
            }
            zos.closeEntry();
            fis.close();
        }
    
    
        public static void createDoc() throws Exception {
            // 为表格的显示绑定行循环
            LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
            // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
            Configure configure = Configure.builder().bind("bz", policy).build();
            List<String> pictureTag = new ArrayList<>();
    
            // 将需要解析的数据放到dataMap中
            HashMap<String, Object> dataMap = new HashMap<String, Object>() {
                {
                    //添加文本
                    put("xiangmuName", "项目名称");
                    put("xiangmuzhouqi", "2024-03-01 至 2024-04-02");
                    put("renwuName", "任务名称");
                    put("renwuzhouqi", "2024-03-05 至 2024-03-26");
                    put("description", "项目描述");
                    put("xiangmulink", "http://www.baidu.com");
                    put("biaoqianName", "标签名称");
                    PictureRenderData pictureRenderData = Pictures.ofStream(Files.newInputStream(Paths.get("D:\\template\\picture\\其他\\yiyan-NewYear.png")), PictureType.PNG)
                            .size(200, 150).create();
                    put("dililink", pictureRenderData);
                    put("resourceDescription", "资源描述");
                    put("startYear", "1997");
                    put("endYear", "2018");
                    put("area", "100.5");
                    // 其他业务获取到数据源
                    String testTable = null;
                    {
                        testTable = "[\n" +
                                "    {\n" +
                                "        \"index\": \"1\",\n" +
                                "        \"templateName\": \"模板内容1\",\n" +
                                "        \"templateType\": \"模板类型1\",\n" +
                                "        \"source\": \"来源1\",\n" +
                                "        \"data\": \"http://www.baidu.com\"\n" +
                                "    },\n" +
                                "    {\n" +
                                "        \"index\": \"2\",\n" +
                                "        \"templateName\": \"模板内容2\",\n" +
                                "        \"templateType\": \"模板类型2\",\n" +
                                "        \"source\": \"来源2\",\n" +
                                "        \"data\": \"http://www.baidu.com111\"\n" +
                                "    },\n" +
                                "    {\n" +
                                "        \"index\": \"3\",\n" +
                                "        \"templateName\": \"模板内容3\",\n" +
                                "        \"templateType\": \"模板类型3\",\n" +
                                "        \"source\": \"来源3\",\n" +
                                "        \"data\": \"http://www.baidu.com222\"\n" +
                                "    }\n" +
                                "]";
                    }
                    // 内容在表格里循环
                    // JSON使用,需要导入fastjson依赖
                    List<WordQingdanDetailsDTO> forms = JSON.parseArray(testTable, WordQingdanDetailsDTO.class);
                    for (int i = 0; i < forms.size(); i++) {
                        put("index" + i, forms.get(i).getIndex());
                        put("templateName" + i, forms.get(i).getTemplateName());
                        put("templateType" + i, forms.get(i).getTemplateType());
                        put("source" + i, forms.get(i).getSource());
                        put("data" + i, forms.get(i).getData());
                    }
                    put("bz", forms);
                    pictureTag.add("dililink");
                }
            };
            for (String tag : pictureTag ) {
                //设置图片,不然保存的是一串字符
                configure.customPolicy(tag, new PictureRenderPolicy());
            }
            String outPath = "D:\\生成数据.docx";
            // 读取模板、数据并渲染
            XWPFTemplate template = XWPFTemplate.compile(new FileInputStream("D:\\任务数据.docx"), configure).render(dataMap);
            //  文件是否已存在,则删除
            File file = new File(outPath);
            if (file.exists()) {
                file.delete();
            }
            // 生成word保存在指定目录
            //template.writeToFile(outPath);
            template.writeAndClose(Files.newOutputStream(Paths.get(outPath)));
            template.close();
        }
    
        public static void main(String[] args) throws Exception {
            createDoc();
        }
    
    }
    

    3.5 用到的实体类

  • RenwuTemplateDTO

    package io.renren.modules.sys.dto;
    
    import com.fasterxml.jackson.annotation.JsonFormat;
    import io.renren.common.validator.group.AddGroup;
    import io.renren.common.validator.group.UpdateGroup;
    import io.renren.modules.sys.entity.SysRenwuTemplateEntity;
    import io.renren.modules.sys.entity.SysResourceEntity;
    import io.renren.modules.sys.entity.SysXiangmuEntity;
    import lombok.Data;
    import org.springframework.format.annotation.DateTimeFormat;
    
    import javax.validation.constraints.NotBlank;
    import javax.validation.constraints.NotNull;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    
    /**
     * @Author: Administrator
     * @Date: 2023/12/8
     * @Description:
     */
    @Data
    public class RenwuTemplateDTO {
    
        private Long renwuId;
    
        private Long xiangmuId;
    
        private String renwuName;
    
        @DateTimeFormat(pattern = "yyyy-MM-dd")
        @JsonFormat(pattern = "yyyy-MM-dd")
        private Date startTime;
    
        @DateTimeFormat(pattern = "yyyy-MM-dd")
        @JsonFormat(pattern = "yyyy-MM-dd")
        private Date endTime;
    
    
        private String description;
    
        private String xiangmuName;
    
        private String xiangmuzhouqi;
    
        private List<SysXiangmuEntity> xiangmuList;
    
        private List<SysResourceEntity> fileList = new ArrayList<>();
    
        private QingdanDTO qingdanDTO;
    
    
        /**
         * 用于导出
         */
        private List<QingdanDTO> qingdanDTOList;
    
        private List<String> renwuResourceUrlList;
    }
    
  • QingdanDTO

    import com.fasterxml.jackson.annotation.JsonFormat;
    import io.renren.common.validator.group.AddGroup;
    import io.renren.common.validator.group.UpdateGroup;
    import io.renren.modules.sys.entity.SysQingdanExtEntity;
    import lombok.Data;
    import org.springframework.format.annotation.DateTimeFormat;
    
    import javax.validation.constraints.NotNull;
    import java.util.Date;
    import java.util.List;
    
    /**
     * @Author: Administrator
     * @Date: 2023/12/11
     * @Description:
     */
    @Data
    public class QingdanDTO {
        private Long qingdanId;
    
        private Long renwuId;
    
        private Long userId;
    
        private String biaoqianName;
    
        @DateTimeFormat(pattern = "yyyy")
        @JsonFormat(timezone = "GMT+8", pattern = "yyyy")
        private String startYear;
    
        @DateTimeFormat(pattern = "yyyy")
        @JsonFormat(timezone = "GMT+8", pattern = "yyyy")
        private String endYear;
    
        private String area;
    
        private String resourceUrl;
    
        /**
         * 资源描述
         */
        private String description;
    
        private String xiangmuName;
    
        private String renwuName;
    
        /**
         * 清单详情
         */
        private List<SysQingdanExtEntity> qingdanExtList;
    
        /**
         * 任务周期
         */
        private String renwuzhouqi;
    
        /**
         * 项目周期
         */
        private String xiangmuzhouqi;
    
    }
    
  • SysQingdanExtEntity

    import com.baomidou.mybatisplus.annotation.TableField;
    import com.baomidou.mybatisplus.annotation.TableLogic;
    import lombok.Data;
    
    import java.io.Serializable;
    
    /**
     * @Author: Administrator
     * @Date: 2023/12/11
     * @Description:
     */
    @Data
    public class SysQingdanExtEntity implements Serializable {
        private static final long serialVersionUID = 1L;
    
        private Long qingdanExtId;
    
        private Long qingdanId;
    
        private String templateName;
    
        private Long resourceId;
    
        private String source;
    
        private String extText;
    
        private Integer templateType;
    
        private String resourceUrl;
    }
    
  • WordQingdanDetailsDTO

    import lombok.Data;
    
    /**
     * @Author: Administrator
     * @Date: 2024/3/1
     * @Description:
     */
    @Data
    public class WordQingdanDetailsDTO {
        /**
         * 下标序号
         */
        private Integer index;
        /**
         * 名称
         */
        private String templateName;
        /**
         * 类型
         */
        private String templateType;
        /**
         * 来源
         */
        private String source;
    
        /**
         * 数据
         */
        private String data;
    }
    
    
  1. 工具类ConvertUtils

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.BeanUtils;
    
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.List;
    
    /**
     * 转换工具类
     *
     * @author Mark sunlightcs@gmail.com
     */
    public class ConvertUtils {
        private static Logger logger = LoggerFactory.getLogger(ConvertUtils.class);
    
        public static <T> T sourceToTarget(Object source, Class<T> target){
            if(source == null){
                return null;
            }
            T targetObject = null;
            try {
                targetObject = target.newInstance();
                BeanUtils.copyProperties(source, targetObject);
            } catch (Exception e) {
                logger.error("convert error ", e);
            }
    
            return targetObject;
        }
    
        public static <T> List<T> sourceToTarget(Collection<?> sourceList, Class<T> target){
            if(sourceList == null){
                return null;
            }
    
            List targetList = new ArrayList<>(sourceList.size());
            try {
                for(Object source : sourceList){
                    T targetObject = target.newInstance();
                    BeanUtils.copyProperties(source, targetObject);
                    targetList.add(targetObject);
                }
            }catch (Exception e){
                logger.error("convert error ", e);
            }
    
            return targetList;
        }
    }
    
  2. 导出效果
    在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/460211.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Soft Robotics 变结构手掌和变刚度手指的仿人软体手的人机交互操作-武科大ESIR课题组师兄成果

一、引言 在当今的机器人技术领域&#xff0c;人类对机器人的需求日益增长&#xff0c;涉及到工业生产、医疗护理、服务业等各个领域。然而&#xff0c;由于任务的多样性和复杂性&#xff0c;单独依靠自主机器人操作往往难以满足实际需求。为了解决这一问题&#xff0c;人机协作…

白话微机:9.解释SoC和Linux

一. 前言&#xff08;回顾世界观&#xff09; 在“微机世界”&#xff0c;普通的城市(单片机)里&#xff0c;人又有一个别的名字叫做“数据”&#xff0c;人有0有1&#xff1b;人们也有住房&#xff0c;这些住房在这个世界叫做“存储器”&#xff1b;地上有路&#xff0c;这些路…

鸿蒙开发实战:【音频组件】

简介 音频组件用于实现音频相关的功能&#xff0c;包括音频播放&#xff0c;录制&#xff0c;音量管理和设备管理。 图 1 音频组件架构图 基本概念 采样 采样是指将连续时域上的模拟信号按照一定的时间间隔采样&#xff0c;获取到离散时域上离散信号的过程。 采样率 采样…

数据仓库的设计开发应用(一)

目录 一、数据仓库设计的特点二、数据仓库系统开发过程三、数据仓库系统的规划 一、数据仓库设计的特点 1、“数据驱动” 的设计 数据仓库是从已有数据出发的设计方法&#xff0c;即从数据源抽取数据&#xff0c;经转换形成面向主题&#xff0c;支持决策的数据集合。 以全面了…

MapReduce的原理分析

1.概述 MapReduce的思想核心是“分而治之,先分再合”&#xff0c;适用于大量复杂任务处理场景(大规模数据处理场景)。 MapReduce分两个阶段: map阶段(分)&#xff1a;如果任何可以拆分并且没有依赖&#xff0c;那么就把复杂的任务拆分成小任务&#xff0c;拆分成小任务之后&a…

【云原生-kubernetes系列】--kubernetes日志收集

1、ELK架构 1.1、部署ES集群 https://mirrors.tuna.tsinghua.edu.cn/elasticstack/apt/7.x/pool/main/e/elasticsearch/ 1、下载软件包 rootes-server1:~# wget https://mirrors.tuna.tsinghua.edu.cn/elasticstack/apt/7.x/pool/main/e/elasticsearch/elasticsearch-7.12.0-…

QMI8658芯片I2C驱动开发指南

这个芯片纯国产挺好用的&#xff0c;电路很好设计&#xff0c;我这垃圾焊功&#xff0c;纯手焊&#xff0c;&#xff0c;居然能用。 第一部分 硬件连接 画的很简陋&#xff0c;看看就可以了&#xff0c;这里I2C总线需要接10K上拉没有画出来&#xff0c;这个需要注意一下。 …

【XR806开发板试用】基于WEBSOCKET实现人机交互(控制开关灯)以及开发问题记录

一、开发板编译、功能介绍 根据官方文档编译烧录成功后&#xff0c;我们修改下官方例子&#xff0c;进行开发来实现websocket。 整体流程&#xff1a;开发板先自动寻找指定的wifi并且连接&#xff0c;连接成功后&#xff0c;通过websocket来与服务端连接&#xff0c;连接成功后…

idea项目mapper.xml中的SQL语句黄色下划线去除

问题描述 当我们使用idea开发java项目时&#xff0c;经常会与数据库打交道&#xff0c;一般在使用mybatis的时候需要写一大堆的mapper.xml以及SQL语句&#xff0c;每当写完SQL语句的时候总是有黄色下划线&#xff0c;看着很不舒服。 解决方案&#xff1a; 修改idea的配置 Edi…

实验01 ASP.NET网站的建立及运行

【实验目的】 &#xff08;1&#xff09;能熟悉ASP.NET的开发环境Visual Studio Community 2019&#xff08;VSC 2019&#xff09;。 &#xff08;2&#xff09;能通过解决方案管理网站&#xff0c;会在解决方案中创建网站。 &#xff08;3&#xff09;会设置IIS 10中的网站…

Node.js(1)

跨平台的node.js运行环境&#xff0c;使开发者可以搭建服务器端的js应用程序 它可以编写服务器端程序&#xff1b; 编写数据接口&#xff1b;提供网页资源浏览功能 前端工程化&#xff1a;开发集成的所有工具和技术 与浏览器环境的区别 node.js环境中没有DOM和BOM fs模块-读…

Linux下安装多个nodejs并映射Jenkins

背景 需要Jenkins中切换多个Node&#xff0c;比如nodejs16和nodesjs18,所以在宿主机按照好这两个版本&#xff0c;然后再映射到Jenkins容器中 步骤 1.下载地址 https://nodejs.org/dist/ 放到 cd /opt/soft/2.解压 tar -xzvf node-v16.20.0-linux-x64.tar.gz tar -xzvf n…

SSM SpringBoot vue智能手机参数分析平台

SSM SpringBoot vue智能手机参数分析平台 系统功能 首页 图片轮播 新闻资讯 手机信息 手机百科 登录注册 个人中心 后台管理 登录注册 个人中心 手机百科管理 用户管理 手机对比管理 配置管理 新闻资讯管理 手机信息管理 对比信息管理 我的收藏管理 开发环境和技术 开发语言…

Kafka配置SASL_PLAINTEXT权限。常用操作命令,创建用户,topic授权

查看已经创建的topic ./bin/kafka-topics.sh --bootstrap-server localhost:9092 --list 创建topic 创建分区和副本数为1的topic ./bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic acltest --partitions 1 --replication-factor 1 创建kafka用户 …

迷宫寻路[天梯赛 -- 栈]

文章目录 题目描述思路AC代码 题目描述 输入样例 8 8 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 4 4 0 0 1 0 0 0 0 0 0 0 1 1 0 1 0 0 -1 -1输出样例 1,1 2,1 3,1 4,1 5,1 5,2 5…

修复ElementUI中el-select与el-option无法通过v-model实现数据双向绑定的问题

1. 问题描述 需求&#xff1a;在使用ElementUI时&#xff0c;通过el-select和el-option标签实现下拉列表功能&#xff0c;当el-option中的选项被选中时&#xff0c;被选中的选项可以正确回显到已选择的列表中。 对于上面的下拉列表&#xff0c;当我们选中“超级管理员”的选项…

Tomcat的使用

1. Tomcat 1.1 Tomcat 是什么 Tomcat 就是基于 Java 实现的一个开源免费, 也是被广泛使用的 HTTP 服务器 1.2 下载安装 Tomcat官网选择其中的 zip 压缩包, 下载后解压缩即可&#xff0c;解压缩的目录最好不要带 “中文” 或者 特殊符号 进入 webapps 目录,每个文件夹都对应…

vue3项目随笔1

1,Eslint Prettier 报错情况&#xff1a; 解决办法&#xff1a; &#xff08;1&#xff09;下载Prettier - code formatter &#xff08;2&#xff09;配置setting.json文件 文件 -> 首选项 -> 设置 -> 用户 -> Eslint "editor.defaultFormatter":…

【Hadoop】Hadoop概述与核心组件

目录 Hadoop概述Hadoop 发展历史Hadoop 三大发行版本1.Apache Hadoop&#xff08;常用&#xff09;2.Cloudera Hadoop3.Hortonworks Hadoop优势优势总结——4高&#xff08;高可靠、高扩展、高效、高容错&#xff09; Hadoop组成1.HDFS管理者&#xff1a;NameNode&#xff08;n…

【计算机网络_传输层】UDP和TCP协议

文章目录 1. 重新理解端口号端口号划分netstat指令pidof 2. UDP协议2.1 UDP协议端格式2.2 UDP的特点2.3 UDP的注意事项2.4 基于UDP的应用层协议 3. TCP协议&#xff08;传输控制协议&#xff09;3.1 TCP协议的格式和报头字段3.2 如何解包和分用3.3 理解TCP协议报头3.4 TCP协议的…