当前位置: 首页 > news >正文

JAVA使用POI实现Excel单元格合并-02

JAVA使用POI实现Excel单元格合并

实现效果

在这里插入图片描述
解释:只要是遇见与前一行相同的数据就合并

引入jar

<dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>5.2.2</version></dependency>

controller层

    @PostMapping(value = "getExcel")public  void getExcel(@RequestBody BrucellosisListDTO brucellosisListDTO, HttpServletRequest request, HttpServletResponse response){businessTaskBrucellosisService.getExcel1(brucellosisListDTO,request,response);}

Service

 void getExcel1(BrucellosisListDTO brucellosisListDTO, HttpServletRequest request, HttpServletResponse response);

serviceImpl

 @Overridepublic void getExcel1(BrucellosisListDTO brucellosisListDTO, HttpServletRequest request, HttpServletResponse response) {List<BrucellosisExportExcel> list = queryExcelList(brucellosisListDTO);//表头String[] titleAttr = {"姓名","养殖户类型","手机号","人口数","所在区域(省)","所在区域(市)","所在区域(区/县)","所在区域(乡镇)","所在区域(乡村)","防疫负责人","养殖总数","布病人数","布病人员","布病人手机号码","布病人身份证号码"};//设置单元的宽度int[] widthAttr = {30,30,30,30,50,30,30,30,30,30,30,30,30,30,30};String titleHead = "布病统计";List<Map<String, String>> dataList = new ArrayList<>();if (CollectionUtils.isNotEmpty(list)){LinkedHashMap<String, List<BrucellosisExportExcel>> collect = list.stream().collect(Collectors.groupingBy(BrucellosisExportExcel::getFarmerPhone, LinkedHashMap::new, Collectors.toList()));dataFarmer(collect,dataList);}Map<String,List<Map<String, String>>> map = Maps.newHashMap();map.put("布病统计", dataList);ExportExcelByPoiUtil.createExcel(response,titleAttr,titleHead,widthAttr,map,new int[]{0,1,2,3,4,5,6,7,8,9,10,11});}public List<BrucellosisExportExcel> queryExcelList(BrucellosisListDTO brucellosisListDTO) {//查询对应的养殖户信息List<BrucellosisExportExcel> list = businessTaskBrucellosisMapper.queryExcelList(brucellosisListDTO);//养殖户下患布病的人数List<BrucellosisFarmerNumVO> brucellosisFarmerNumVOList = businessTaskBrucellosisMapper.queryBruCount();if(!brucellosisFarmerNumVOList.isEmpty()){list.forEach(res ->{String farmerPhone = res.getFarmerPhone();List<BrucellosisFarmerNumVO> collect = brucellosisFarmerNumVOList.stream().filter(result -> result.getFarmerPhone().equals(farmerPhone)).collect(Collectors.toList());if(ObjectUtils.isNotEmpty(collect)){res.setBruNum(collect.get(0).getBruNum());}});}return list;}/***合并数据* @param collect 根据养殖户Id分组* @date 2024/3/21 17:18* @author fyh**/public  void dataFarmer(LinkedHashMap<String, List<BrucellosisExportExcel>> collect,List<Map<String, String>> dataList){Set<String> longs = collect.keySet();List<String> farmerIdList = new ArrayList<>(longs);for (int i = 0; i < farmerIdList.size(); i++) {List<BrucellosisExportExcel> list1 = collect.get(farmerIdList.get(i));dataVoWorkOrder(dataList,list1);}}private void dataVoWorkOrder(List<Map<String, String>> dataList, List<BrucellosisExportExcel> list) {if (CollectionUtils.isNotEmpty(list)) {for (BrucellosisExportExcel displayBrucellosisVO : list) {Map<String, String> temp = new HashMap<>();temp.put("姓名", displayBrucellosisVO.getFarmerName());temp.put("养殖户类型", displayBrucellosisVO.getFarmerTypeName());temp.put("手机号", displayBrucellosisVO.getFarmerPhone());temp.put("人口数", displayBrucellosisVO.getPopulation()+"");temp.put("所在区域(省)", displayBrucellosisVO.getProvinceName());temp.put("所在区域(市)", displayBrucellosisVO.getCityName());temp.put("所在区域(区/县)", displayBrucellosisVO.getAreaName());temp.put("所在区域(乡镇)", displayBrucellosisVO.getTownshipName());temp.put("所在区域(乡村)", displayBrucellosisVO.getStreetName());temp.put("防疫负责人", displayBrucellosisVO.getPersonInChargeName());temp.put("养殖总数", displayBrucellosisVO.getAnimalNum()+"");temp.put("布病人数", displayBrucellosisVO.getBruNum()+"");temp.put("布病人员", displayBrucellosisVO.getUserName());temp.put("布病人手机号码", displayBrucellosisVO.getUserPhone());temp.put("布病人身份证号码", displayBrucellosisVO.getIdCard());dataList.add(temp);}}}

ExportExcelByPoiUtil 合并的公共类

public class ExportExcelByPoiUtil {private static Logger logger = LoggerFactory.getLogger(ExportExcelByPoiUtil.class);/*** @param @param request* @param @param response* @param @param title 标题数组* @param @param titleHead  Excel标题* @param @param widthAttr  单元格宽度* @param @param maps  数据* @param @param mergeIndex  要合并的列   数组* @param @return    设定文件* @return String    返回类型* @throws*/@SuppressWarnings("rawtypes")public static void createExcel(HttpServletResponse response,String[] title,String titleHead ,int[] widthAttr,Map<String/*sheet名*/, List<Map<String/*对应title的值*/, String>>> maps, int[] mergeIndex){if (title.length==0){return;}/*初始化excel模板*/Workbook workbook = new XSSFWorkbook();Sheet sheet = null;int n = 0;/*循环sheet页*/for(Map.Entry<String, List<Map<String/*对应title的值*/, String>>> entry : maps.entrySet()){/*实例化sheet对象并且设置sheet名称,book对象*/try {sheet = workbook.createSheet();workbook.setSheetName(n, entry.getKey());workbook.setSelectedTab(0);}catch (Exception e){e.printStackTrace();}// 设置样式 头 cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);// 水平方向的对齐方式CellStyle cellStyle_head = style(0, workbook);// 导出时间CellStyle cellStyle_export = style(3, workbook);// 标题CellStyle cellStyle_title = style(1, workbook);// 正文CellStyle cellStyle = style(2, workbook);// 合并单元格CellRangeAddress构造参数依次表示起始行,截至行,起始列, 截至列CellRangeAddress c1 = new CellRangeAddress(0, 0, 0, title.length-1);sheet.addMergedRegion(c1);CellRangeAddress c2 = new CellRangeAddress(1, 1, 0, title.length-1);sheet.addMergedRegion(c2);// 在sheet里创建第一行,参数为行索引(excel的行),可以是0~65535之间的任何一个Row row0 = sheet.createRow(0);// 创建单元格(excel的单元格,参数为列索引,可以是0~255之间的任何一个Cell cell1 = row0.createCell(0);// 设置单元格内容 标题  可以自定义拼接//列 cell1.setCellValue("" + titleHead + "");cell1.setCellValue(titleHead);cell1.setCellStyle(cellStyle_head);// 设置合并单元格边框setRegionStyle(sheet, c1, cellStyle_head);setRegionStyle(sheet, c2, cellStyle_export);// 设置列宽for (int i = 0; i < widthAttr.length; i++) {sheet.setColumnWidth((short) i, (short) widthAttr[i] * 200);}// 在sheet里创建第二行Row row1 = sheet.createRow(1);// 创建单元格(excel的单元格,参数为列索引,可以是0~255之间的任何一个Cell cell2 = row1.createCell(0);// 设置单元格内容 标题//cell2.setCellValue("导出时间:" + DateUtil.getDateString(DateUtil.DATE_TIME_PATTERN) );cell2.setCellValue("导出时间:"+ DateUtil.now());cell2.setCellStyle(cellStyle_export);/*初始化标题,填值标题行(第一行)*/Row row2 = sheet.createRow(2);for(int i = 0; i<title.length; i++){/*创建单元格,指定类型*///Cell cell_1 = row2.createCell(i, Cell.class.CELL_TYPE_STRING);Cell cell_1 = row2.createCell(i,CellType.STRING);//设置标题的值cell_1.setCellValue(title[i]);//设置标题样式cell_1.setCellStyle(cellStyle_title);}/*得到当前sheet下的数据集合*/List<Map<String/*对应title的值*/, String>> list = entry.getValue();/*遍历该数据集合*/List<PoiModel> poiModels = Lists.newArrayList();if(null!=workbook){Iterator iterator = list.iterator();
//                int index = 1;/*这里1是从excel的第二行开始,第一行已经塞入标题了*/int index = 3;/*这里3是从excel的第四行开始,前面几行已经塞入标题了*/while (iterator.hasNext()){Row row = sheet.createRow(index);/*取得当前这行的map,该map中以key,value的形式存着这一行值*/@SuppressWarnings("unchecked")Map<String, String> map = (Map<String, String>)iterator.next();/*循环列数,给当前行塞值*/for(int i = 0; i<title.length; i++){String old = "";/*old存的是上一行统一位置的单元的值,第一行是最上一行了,所以从第二行开始记*/if(index > 3){old = poiModels.get(i)==null ? "":poiModels.get(i).getContent();}/*循环需要合并的列*/for(int j = 0; j < mergeIndex.length; j++){/* 因为标题行前还有2行  所以index从3开始    也就是第四行*/if(index == 3){/*记录第一行的开始行和开始列*/PoiModel poiModel = new PoiModel();poiModel.setOldContent(map.get(title[i]));poiModel.setContent(map.get(title[i]));poiModel.setRowIndex(3);poiModel.setCellIndex(i);poiModels.add(poiModel);break;}else if(i > 0 && mergeIndex[j] == i){/*这边i>0也是因为第一列已经是最前一列了,只能从第二列开始*//*当前同一列的内容与上一行同一列不同时,把那以上的合并, 或者在当前元素一样的情况下,前一列的元素并不一样,这种情况也合并*//*如果不需要考虑当前行与上一行内容相同,但是它们的前一列内容不一样则不合并的情况,把下面条件中||poiModels.get(i).getContent().equals(map.get(title[i])) && !poiModels.get(i - 1).getOldContent().equals(map.get(title[i-1]))去掉就行*///|| poiModels.get(i).getContent().equals(map.get(title[i])) && !poiModels.get(i - 1).getOldContent().equals(map.get(title[i-1]))if(!poiModels.get(i).getContent().equals(map.get(title[i]))){if(index - 1 ==poiModels.get(i).getRowIndex() && poiModels.get(i).getCellIndex() == poiModels.get(i).getCellIndex()){continue;}/*当前行的当前列与上一行的当前列的内容不一致时,则把当前行以上的合并*/CellRangeAddress cra=new CellRangeAddress(poiModels.get(i).getRowIndex()/*从第二行开始*/, index - 1/*到第几行*/, poiModels.get(i).getCellIndex()/*从某一列开始*/, poiModels.get(i).getCellIndex()/*到第几列*/);//在sheet里增加合并单元格sheet.addMergedRegion(cra);/*重新记录该列的内容为当前内容,行标记改为当前行标记,列标记则为当前列*/poiModels.get(i).setContent(map.get(title[i]));poiModels.get(i).setRowIndex(index);poiModels.get(i).setCellIndex(i);}}/*处理第一列的情况*/if(mergeIndex[j] == i && i == 0 && !poiModels.get(i).getContent().equals(map.get(title[i]))){if(index - 1 ==poiModels.get(i).getRowIndex() && poiModels.get(i).getCellIndex() == poiModels.get(i).getCellIndex()){continue;}/*当前行的当前列与上一行的当前列的内容不一致时,则把当前行以上的合并*/CellRangeAddress cra=new CellRangeAddress(poiModels.get(i).getRowIndex()/*从第二行开始*/, index - 1/*到第几行*/, poiModels.get(i).getCellIndex()/*从某一列开始*/, poiModels.get(i).getCellIndex()/*到第几列*/);//在sheet里增加合并单元格sheet.addMergedRegion(cra);/*重新记录该列的内容为当前内容,行标记改为当前行标记*/poiModels.get(i).setContent(map.get(title[i]));poiModels.get(i).setRowIndex(index);poiModels.get(i).setCellIndex(i);}/*最后一行没有后续的行与之比较,所有当到最后一行时则直接合并对应列的相同内容  加2是因为标题行前面还有2行*/if(mergeIndex[j] == i && index == list.size()+2){if(index == poiModels.get(i).getRowIndex() && poiModels.get(i).getCellIndex() == poiModels.get(i).getCellIndex()){continue;}CellRangeAddress cra = new CellRangeAddress(poiModels.get(i).getRowIndex()/*从第二行开始*/, index/*到第几行*/, poiModels.get(i).getCellIndex()/*从某一列开始*/, poiModels.get(i).getCellIndex()/*到第几列*/);//在sheet里增加合并单元格sheet.addMergedRegion(cra);}}Cell cell = row.createCell(i,CellType.STRING);cell.setCellValue(map.get(title[i]));cell.setCellStyle(cellStyle);/*在每一个单元格处理完成后,把这个单元格内容设置为old内容*/poiModels.get(i).setOldContent(old);}index++;}}n++;}OutputStream out = null;try {Calendar calendar1 = Calendar.getInstance();String cal = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar1.getTime());out = response.getOutputStream();response.reset();//清空输出流response.setHeader("Content-disposition", "attachment;filename=" + new String(titleHead.getBytes(StandardCharsets.UTF_8), "iso8859-1") + cal + ".xlsx");// 设定输出文件头response.setContentType("application/vnd.ms-excel;charset=UTF-8");// 定义输出类型workbook.write(out);}catch (IOException e){logger.error("导出异常",e);}finally {try {out.flush();out.close();}catch (IOException e){logger.error("流的关闭异常",e);}}}/*** @param @return    设定文件  index 0:头 1:标题 2:正文* @return HSSFCellStyle    返回类型* @throws*/public static CellStyle style(int index, Workbook workbook) {CellStyle cellStyle = null;if (index == 0) {// 设置头部样式cellStyle = workbook.createCellStyle();// 设置字体大小 位置cellStyle.setAlignment(HorizontalAlignment.CENTER);// 生成一个字体Font font = workbook.createFont();//设置字体font.setFontName("微软雅黑");//字体颜色font.setColor(IndexedColors.BLACK.getIndex());// HSSFColor.VIOLET.indexfont.setFontHeightInPoints((short) 12);// 上下居中cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//背景白色cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());//这里需要指定 FillPatternType 为FillPatternType.SOLID_FOREGROUND 不然无法展示背景色,头默认了 FillPatternType所以可以不指定cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//设置边框线cellStyle.setBorderBottom(BorderStyle.THIN);cellStyle.setBorderLeft(BorderStyle.THIN);cellStyle.setBorderRight(BorderStyle.THIN);cellStyle.setBorderTop(BorderStyle.THIN);//设置对其cellStyle.setAlignment(HorizontalAlignment.CENTER);cellStyle.setFont(font);}//标题if (index == 1) {cellStyle = workbook.createCellStyle();// 设置字体大小 位置cellStyle.setAlignment(HorizontalAlignment.CENTER);// 生成一个字体Font font_title = workbook.createFont();//设置字体font_title.setFontName("微软雅黑");font_title.setColor(IndexedColors.BLACK.getIndex());// HSSFColor.VIOLET.index//字体颜色font_title.setFontHeightInPoints((short) 10);cellStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());//这里需要指定 FillPatternType 为FillPatternType.SOLID_FOREGROUND 不然无法展示背景色,头默认了 FillPatternType所以可以不指定cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//设置边框样式cellStyle.setBorderBottom(BorderStyle.THIN);cellStyle.setBorderLeft(BorderStyle.THIN);cellStyle.setBorderRight(BorderStyle.THIN);cellStyle.setBorderTop(BorderStyle.THIN);//设置对其cellStyle.setAlignment(HorizontalAlignment.CENTER);// 上下居中cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);cellStyle.setFont(font_title);}//正文if (index == 2) {// 设置样式cellStyle = workbook.createCellStyle();cellStyle.setAlignment(HorizontalAlignment.CENTER);// 生成一个字体Font font_title = workbook.createFont();//设置字体font_title.setFontName("微软雅黑");cellStyle.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());cellStyle.setWrapText(true); // 自动换行cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//背景白色cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());//设置边框样式cellStyle.setBorderBottom(BorderStyle.THIN);cellStyle.setBorderLeft(BorderStyle.THIN);cellStyle.setBorderRight(BorderStyle.THIN);cellStyle.setBorderTop(BorderStyle.THIN);cellStyle.setAlignment(HorizontalAlignment.CENTER);cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中}//时间if (index == 3) {// 设置样式cellStyle = workbook.createCellStyle();// 居中cellStyle.setAlignment(HorizontalAlignment.RIGHT);// 生成一个字体Font font_title = workbook.createFont();//设置字体font_title.setFontName("微软雅黑");font_title.setColor(IndexedColors.BLACK.getIndex());// HSSFColor.VIOLET.index// //字体颜色font_title.setFontHeightInPoints((short) 10);//font_title.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 上下居中cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//设置单元格格式cellStyle.setBorderBottom(BorderStyle.THIN);cellStyle.setBorderLeft(BorderStyle.THIN);cellStyle.setBorderRight(BorderStyle.THIN);cellStyle.setBorderTop(BorderStyle.THIN);cellStyle.setFont(font_title);}if (index == 4) {// 设置样式cellStyle = workbook.createCellStyle();//设置背景色cellStyle.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//设置边框样式cellStyle.setBorderBottom(BorderStyle.THIN);cellStyle.setBorderLeft(BorderStyle.THIN);cellStyle.setBorderRight(BorderStyle.THIN);cellStyle.setBorderTop(BorderStyle.THIN);cellStyle.setAlignment(HorizontalAlignment.CENTER);cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中}return cellStyle;}/*** @param @param sheet* @param @param region* @param @param cs    设定文件* @return void    返回类型* @throws*/public static void setRegionStyle(Sheet sheet, CellRangeAddress region, CellStyle cs) {for (int i = region.getFirstRow(); i <= region.getLastRow(); i++) {Row row = CellUtil.getRow(i, sheet);for (int j = region.getFirstColumn(); j <= region.getLastColumn(); j++) {Cell cell = CellUtil.getCell(row, (short) j);cell.setCellStyle(cs);}}}
}

PoiModel 实体类

/*** @package: com.ruoyi.easyExcelHeadStyle* @program: prevention* @author: fyh* @date: 2024/3/21* @description: 用来记录上一行数据**/
@Data
public class PoiModel {//内容private String content;//上一行同一位置内容private String oldContent;//行标private int rowIndex;//列标private int cellIndex;
}

相关文章:

JAVA使用POI实现Excel单元格合并-02

JAVA使用POI实现Excel单元格合并 实现效果 解释&#xff1a;只要是遇见与前一行相同的数据就合并 引入jar <dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>5.2.2</version></depe…...

深入了解 Linux 中的 MTD 设备:/dev/mtd* 与 /dev/mtdblock*

目录 前言一、什么是MTD子系统&#xff1f;二、 /dev/mtd* 设备文件用途注意事项 三、/dev/mtdblock* 设备文件用途注意事项 三、这两种设备文件的关系四、关norflash的一些小知识 前言 在嵌入式Linux系统的世界里&#xff0c;非易失性存储技术扮演着至关重要的角色。MTD&#…...

2、Spring CLI安装

安装 Spring CLI 提供了多种格式,让您选择自己喜欢的安装方法。可下载的制品可从发布页面获取。 二进制发行版 WindowsLinuxMac手动安装(Windows,其他自己看) spring-cli-standalone-<version>-windows.x86_64.zip - 打包了 x86 JDKspring-cli-installer-<versi…...

数据库备份工具(实现数据定时覆盖)

数据库备份工具&#xff08;实现数据定时覆盖&#xff09; 永远热爱&#xff0c;永远执着&#xff01; 工具介绍 自动化测试数据库更新调度程序 这段 Python 脚本自动化了每天定时从生产数据库更新测试数据库的过程。它利用了 schedule 库来安排并执行每天指定时间的更新任务…...

测试环境搭建整套大数据系统(十二:挂载磁盘到hadoop环境)

一&#xff1a;链接硬盘 将硬盘连接到计算机的 SATA 接口或 USB 接口&#xff0c;并确保硬盘通电并处于可用状态。 二&#xff1a;查看硬盘信息 sudo fdisk -l三&#xff1a;创建分区 gdisk /dev/vbd重新扫描磁盘 partprobe /dev/vdb格式化磁盘 mkfs.ext4 /dev/vdb2查看磁…...

Spring事务核心:声明式事务注解式事务

全解&#xff1a;声明式事务和注解事务 在Spring中&#xff0c;事务管理是一个非常重要的特性&#xff0c;它可以帮助开发者在应用程序中实现事务控制。Spring提供了两种事务管理方式&#xff1a;声明式事务和注解事务。 1. 声明式事务 声明式事务是指通过配置文件或注解的方…...

AcWing 1015. 摘花生

Problem: AcWing 1015. 摘花生 文章目录 思路解题方法复杂度Code 思路 这是一个典型的动态规划问题。我们需要在一个二维网格中&#xff0c;从左上角走到右下角&#xff0c;每次只能向右或向下移动&#xff0c;目标是使得经过的路径上的数字之和最大。 我们可以定义dp[i][j]为从…...

Dalle-3、Sora、Stable Diffusion 3 掀起AIGC新浪潮

随着科技的飞速发展&#xff0c;我们迎来了视觉AIGC高光时刻&#xff0c;一个充满无限可能与机遇的新时代。在这个时代里&#xff0c;三大里程碑Dalle-3、Sora和Stable Diffusion 3以其炸裂式的技术发展&#xff0c;引领着AIGC领域的新浪潮。文章首先做相应简要介绍&#xff0c…...

Unity 视频组件 VideoPlayer

组件添加&#xff1a; 在自己定义的组件下&#xff08;例如&#xff1a;Panel&#xff09; 点击 Inspector 面板中的 AddComponent &#xff0c;输入“VideoPlayer”。 资源 这里 视频资源有两种形式&#xff0c;第一种是 VideoClip &#xff0c;需要将视频文件拖拽到该属性字段…...

RSTP环路避免实验(华为)

思科设备参考&#xff1a;RSTP环路避免实验&#xff08;思科&#xff09; 一&#xff0c;技术简介 RSTP (Rapid Spanning Tree Protocol) 是从STP发展而来 • RSTP标准版本为IEEE802.1w • RSTP具备STP的所有功能&#xff0c;可以兼容STP运行 • RSTP和STP有所不同 减少了…...

Arduino IDE工程代码多文件编程和中文设置

一、esp8266模块信息 二、中英文切换 点击文件( File )–选择首选项( Preference )—选择语言( Language )—选择中文–点击确定( OK ) 三、多文件编程 在Arduino编程中&#xff0c;将代码分割成多个文件是一种很好的做法&#xff0c;特别是项目变得越来越大和复杂时。这样…...

【微服务】Eureka(服务注册,服务发现)

文章目录 1.基本介绍1.学前说明2.当前架构分析1.示意图2.问题分析 3.引出Eureka1.项目架构分析2.上图解读 2.创建单机版的Eureka1.创建 e-commerce-eureka-server-9001 子模块2.检查父子pom.xml1.子 pom.xml2.父 pom.xml 3.pom.xml 引入依赖4.application.yml 配置eureka服务5.…...

windows上ssh设置代理,直接访问公司内网

ssh设置代理一般来说很简单&#xff0c;对于无密码或者可以支持密钥登录的&#xff0c;都比较无脑 难的地方在于使用用户名密码认证来使用一个http的代理或者socks5的代理&#xff0c;密码如何设置&#xff1f;特殊字符如何处理&#xff1f; 直接上答案&#xff0c;.ssh/conf…...

C++ union用法

在C中&#xff0c;union是一种特殊的数据类型&#xff0c;可以在同一个内存位置存储不同的数据类型。它的用法如下&#xff1a; 1. 声明union类型&#xff1a;使用关键字union加上union名称来声明一个union类型。 c union UnionName { dataType1 member1; dataType2 …...

JavaSE_运算符 案例分析

/*符号在字符串中的操作: 表示连接,会将其他内容和字符串连接在一起,形成一个字符串目标:理解符号在字符串中的作用会将其他内容和字符串连接在一起,形成一个字符串*/ public class Operator03 {public static void main(String[] args) {System.out.println("5 5 "…...

15、Spring Cloud Alibaba Sentinel实现熔断与限流

注&#xff1a;本篇文章主要参考周阳老师讲解的cloud进行整理的&#xff01; 1、Sentinel 1.1、官网 https://sentinelguard.io/zh-cn/ 等价对标 Spring Cloud Circuit Breaker 1.2、是什么 https://github.com/alibaba/Sentinel/wiki 1.3、去哪下 https://github.com/alibab…...

Linux logout命令教程:如何安全地退出Linux会话(附实例详解和注意事项)

Linux logout命令介绍 logout命令用于退出当前的登录Shell。这个命令可以被普通用户用来结束他们自己的会话。 Linux logout命令适用的Linux版本 logout命令在所有主流的Linux发行版中都是可用的&#xff0c;包括但不限于Debian、Ubuntu、Alpine、Arch Linux、Kali Linux、R…...

数据结构——顺序表(C语言版)

顺序表是数据结构中最基本的一种线性表&#xff0c;它以一段连续的存储空间来存储数据元素&#xff0c;元素之间的顺序由它们在内存中的位置来决定。在C语言中&#xff0c;我们通常使用数组来实现顺序表。 目录 顺序表的结构定义 顺序表的基本操作 应用实例 顺序表的结构定义…...

Knative 助力 XTransfer 加速应用云原生 Serverless 化

作者&#xff1a;元毅 公司介绍 XTransfer 是一站式外贸企业跨境金融和风控服务公司&#xff0c;致力于帮助中小微企业大幅降低全球展业的门槛和成本&#xff0c;提升全球竞争力。公司连续7年专注 B2B 外贸金融服务&#xff0c;已成为中国 B2B 外贸金融第一平台&#xff0c;目…...

服务器离线配置vscode连接,conda虚拟环境

记录一下服务器离线配置问题&#xff0c;以备不时之需。 服务器离线配置 vscode连接参考&#xff1a;vscode-server离线安装-CSDN博客 服务器离线配置conda虚拟环境&#xff1a;Conda 环境离线迁移&#xff08;服务器断网情况下搭建虚拟环境envs&#xff09; - 知乎 上次两个…...

脑机新手指南(八):OpenBCI_GUI:从环境搭建到数据可视化(下)

一、数据处理与分析实战 &#xff08;一&#xff09;实时滤波与参数调整 基础滤波操作 60Hz 工频滤波&#xff1a;勾选界面右侧 “60Hz” 复选框&#xff0c;可有效抑制电网干扰&#xff08;适用于北美地区&#xff0c;欧洲用户可调整为 50Hz&#xff09;。 平滑处理&…...

基于数字孪生的水厂可视化平台建设:架构与实践

分享大纲&#xff1a; 1、数字孪生水厂可视化平台建设背景 2、数字孪生水厂可视化平台建设架构 3、数字孪生水厂可视化平台建设成效 近几年&#xff0c;数字孪生水厂的建设开展的如火如荼。作为提升水厂管理效率、优化资源的调度手段&#xff0c;基于数字孪生的水厂可视化平台的…...

三体问题详解

从物理学角度&#xff0c;三体问题之所以不稳定&#xff0c;是因为三个天体在万有引力作用下相互作用&#xff0c;形成一个非线性耦合系统。我们可以从牛顿经典力学出发&#xff0c;列出具体的运动方程&#xff0c;并说明为何这个系统本质上是混沌的&#xff0c;无法得到一般解…...

Mac下Android Studio扫描根目录卡死问题记录

环境信息 操作系统: macOS 15.5 (Apple M2芯片)Android Studio版本: Meerkat Feature Drop | 2024.3.2 Patch 1 (Build #AI-243.26053.27.2432.13536105, 2025年5月22日构建) 问题现象 在项目开发过程中&#xff0c;提示一个依赖外部头文件的cpp源文件需要同步&#xff0c;点…...

基于Java Swing的电子通讯录设计与实现:附系统托盘功能代码详解

JAVASQL电子通讯录带系统托盘 一、系统概述 本电子通讯录系统采用Java Swing开发桌面应用&#xff0c;结合SQLite数据库实现联系人管理功能&#xff0c;并集成系统托盘功能提升用户体验。系统支持联系人的增删改查、分组管理、搜索过滤等功能&#xff0c;同时可以最小化到系统…...

视觉slam十四讲实践部分记录——ch2、ch3

ch2 一、使用g++编译.cpp为可执行文件并运行(P30) g++ helloSLAM.cpp ./a.out运行 二、使用cmake编译 mkdir build cd build cmake .. makeCMakeCache.txt 文件仍然指向旧的目录。这表明在源代码目录中可能还存在旧的 CMakeCache.txt 文件,或者在构建过程中仍然引用了旧的路…...

排序算法总结(C++)

目录 一、稳定性二、排序算法选择、冒泡、插入排序归并排序随机快速排序堆排序基数排序计数排序 三、总结 一、稳定性 排序算法的稳定性是指&#xff1a;同样大小的样本 **&#xff08;同样大小的数据&#xff09;**在排序之后不会改变原始的相对次序。 稳定性对基础类型对象…...

基于Springboot+Vue的办公管理系统

角色&#xff1a; 管理员、员工 技术&#xff1a; 后端: SpringBoot, Vue2, MySQL, Mybatis-Plus 前端: Vue2, Element-UI, Axios, Echarts, Vue-Router 核心功能&#xff1a; 该办公管理系统是一个综合性的企业内部管理平台&#xff0c;旨在提升企业运营效率和员工管理水…...

[大语言模型]在个人电脑上部署ollama 并进行管理,最后配置AI程序开发助手.

ollama官网: 下载 https://ollama.com/ 安装 查看可以使用的模型 https://ollama.com/search 例如 https://ollama.com/library/deepseek-r1/tags # deepseek-r1:7bollama pull deepseek-r1:7b改token数量为409622 16384 ollama命令说明 ollama serve #&#xff1a…...

NPOI操作EXCEL文件 ——CAD C# 二次开发

缺点:dll.版本容易加载错误。CAD加载插件时&#xff0c;没有加载所有类库。插件运行过程中用到某个类库&#xff0c;会从CAD的安装目录找&#xff0c;找不到就报错了。 【方案2】让CAD在加载过程中把类库加载到内存 【方案3】是发现缺少了哪个库&#xff0c;就用插件程序加载进…...