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

news2024/9/22 7:00:39

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

 @Override
    public 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.index
            font.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;
}

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

OpenCV 如何使用 XML 和 YAML 文件的文件输入和输出

返回&#xff1a;OpenCV系列文章目录&#xff08;持续更新中......&#xff09; 上一篇&#xff1a;如何利用OpenCV4.9离散傅里叶变换 下一篇: 目标 本文内容主要介绍&#xff1a; 如何使用 YAML 或 XML 文件打印和读取文件和 OpenCV 的文本条目&#xff1f;如何对 OpenCV …

如何选择合适的充电桩主控制板

充电桩主控制板是充电桩不可或缺的核心元件之一&#xff0c;它的功能多样&#xff0c;包括控制、保护、监测、报警和记录等。随着充电基础设施的不断完善&#xff0c;选择合适的充电桩主控制板成为设计过程中至关重要的一环。然而&#xff0c;在市场上琳琅满目的产品中做出选择…

20221124 kafka实时数据写入Redis

一、上线结论 实现了将用户线上实时浏览的沉浸式视频信息&#xff0c;保存在Redis中这样一个功能。为实现沉浸式视频离线推荐到实时推荐提供了强有力的支持。目前只是应用在沉浸式场景&#xff0c;后续也能扩展到其他所有场景。用于两个场景&#xff1a;&#xff08;1&#xf…

一分钟开服 《幻兽帕鲁》游戏专属服务器by京东云主机

使用京东云服务器搭建幻兽帕鲁Palworld游戏联机服务器教程&#xff0c;非常简单&#xff0c;京东云推出幻兽帕鲁镜像系统&#xff0c;镜像直接选择幻兽帕鲁镜像即可一键自动部署&#xff0c;不需要手动操作&#xff0c;真正的新手0基础部署幻兽帕鲁&#xff0c;阿腾云atengyun.…

创新指南|如何将人工智能应用于未来的创新管理——并不断付诸实践

ChatGPT 的推出加剧了围绕人工智能的炒作&#xff0c;现在我们看到了前所未有的巨大进展。对于我们这些热衷于创新的人来说&#xff0c;这是一个激动人心的时刻。他们正在共同采取措施&#xff0c;充分利用人工智能进行创新管理。本文将阐述人工智能能为创新管理做什么&#xf…

iptables添加端口映射,k8s主机查询不到端口但能访问。

研究原因&#xff1a;k8s内一台主机使用命令查询没有80端口。但通过浏览器访问又能访问到服务。 查询了资料是使用了hostport方式暴露pod端口。cni调用iptables增加了DNAT规则。访问时流量先经过iptables直接被NAT到具体服务去了。 链接: K8s罪魁祸首之"HostPort劫持了我…

RegSeg 学习笔记(待完善)

论文阅读 解决的问题 引用别的论文的内容 可以用 controlf 寻找想要的内容 PPM 空间金字塔池化改进 SPP / SPPF / SimSPPF / ASPP / RFB / SPPCSPC / SPPFCSPC / SPPELAN &#xfffc; ASPP STDC&#xff1a;short-term dense concatenate module 和 DDRNet SE-ResNeXt …

短视频矩阵系统究竟怎么样,如何实现一站式精准获客?

在数字化时代的浩渺海洋中&#xff0c;短视频如同一股汹涌的浪潮&#xff0c;席卷了众多企业的营销战略。如何在这样的背景下&#xff0c;驾驭这股浪潮&#xff0c;将其转化为获客的强大动力&#xff0c;已成为众多企业家们心中的疑问。而蜘蛛短视频矩阵系统的出现&#xff0c;…

iOS开发进阶(十一):ViewController 控制器详解

文章目录 一、前言二、UIViewController三、UINavigationController四、UITabBarController五、UIPageViewController六、拓展阅读 一、前言 iOS 界面开发最重要的首属ViewController和View&#xff0c;ViewController是View的控制器&#xff0c;也就是一般的页面&#xff0c;…

岭师大数据技术原理与应用-序章-软工版

HeZaoCha-CSDN博客 序章—软工版 一、环境介绍1. VMware Workstation Pro2. CentOS3. Java4. Hadoop5. HBase6. MySQL7. Hive 二、系统安装1. 虚拟网络编辑器2. 操作系统安装 三、结尾 先说说哥们写这系列博客的原因&#xff0c;本来学完咱也没想着再管部署这部分问题的说&…

第二证券今日投资参考:低空经济迎利好 自动驾驶商业化提速

昨日&#xff0c;两市股指盘中弱势震动&#xff0c;午后加快下探&#xff0c;沪指失守3000点大关&#xff0c;深成指、创业板指跌超2%&#xff1b;到收盘&#xff0c;沪指跌1.26%报2993.14点&#xff0c;深成指跌2.4%报9222.47点&#xff0c;创业板指跌2.81%报1789.82点&#x…

目前常见的搜索引擎有哪些?

常见的搜索引擎可以分为两类&#xff1a;全网搜索类和平台内搜索。 全网搜索类是指可以在互联网范围内进行搜索的引擎&#xff0c;它们提供了广泛的搜索结果&#xff0c;包括网页、图片、视频、新闻等各种类型的内容。以下是一些常见的全网搜索引擎&#xff1a; 百度&#xff…

idea类已经存在却报错

一句话导读 在idea中导入新的项目&#xff0c;很多类都飘红报错&#xff0c;mvn compile可以通过&#xff0c;可能是因为idea缓存问题导致。 由于这个项目是由老项目复制过来后&#xff0c;再继续开发新的功能&#xff0c;很多同事导入后&#xff0c;都爆出新的类找不到。而编译…

linux nginx配置ssl, 实现https+ip访问

mkdir sslZhengShu openssl req -newkey rsa:2048 -nodes -keyout ca.key -out ca.csr openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt openssl genrsa -out server.key 2048 openssl req -new -key server.key -out server.csr 和之前输入一样即可 …

反序列化动态调用 [NPUCTF2020]ReadlezPHP1

在源代码上看到提示 访问一下看看 代码审计一下 <?php #error_reporting(0); class HelloPhp {public $a;public $b;public function __construct(){$this->a "Y-m-d h:i:s";$this->b "date";}public function __destruct(){$a $this->a;…

【Go】结构体中Tag标识

https://blog.csdn.net/weixin_45193103/article/details/123876319 https://blog.csdn.net/qq_49723651/article/details/122005291 https://juejin.cn/post/7005465902804123679 学一点&#xff0c;整一点&#xff0c;基本都是综合别人的&#xff0c;弄成我能理解的内容 Tag定…

ubuntu编译OpenCV and seetaFace2

opencv opencv-4.5.2 opencv_contrib-4.5.2 SeetaFace2 SeetaFace2-master https://github.com/seetafaceengine 指定安装目录&#xff0c;和OpenCV放一个目录下了 安装前 安装 安装后 Qt安装 Windows下 Linux下 报错1 原因&#xff1a; 报错…

CMS(内容管理系统)

一、系统的编写可以在开源网站上下载一个相关项目&#xff0c;然后做2次开发 企业建站系统:MetInfo(米拓)、蝉知、SiteServer CMs等; B2C商城系统:商派Shopex、ECshop、HiShop、XpShop等; 门户建站系统:DedeCMS(织梦)、帝国CMS、PHPCMS、动易、CmsTop等; 博客系统:WordPres…

【JavaWeb】Day18.Vue组件库Element

什么是Element Element&#xff1a;是饿了么团队研发的&#xff0c;一套为开发者、设计师和产品经理准备的基于 Vue 2.0 的桌面端组件库。组件&#xff1a;组成网页的部件&#xff0c;例如 超链接、按钮、图片、表格、表单、分页条等等。官网&#xff1a;Element - The worlds…

Capture One Pro 22 for Mac/win:重塑RAW图像处理的艺术

在数字摄影的世界里&#xff0c;RAW图像处理软件无疑是摄影师们手中的魔法棒&#xff0c;而Capture One Pro 22无疑是这一领域的璀璨明星。这款专为Mac和Windows系统打造的图像处理软件&#xff0c;以其出色的性能、丰富的功能和极致的用户体验&#xff0c;赢得了全球摄影师的广…