easypoi 模板导入、导出合并excel单元格功能

news2024/11/15 12:16:52

easypoi 模板导入、导出合并单元格功能

参考:

java使用poi读取跨行跨列excel

springboot集成easypoi并使用其模板导出功能和遇到的坑
Easypoi Excel模板功能简要说明

easypoi 模板导出兼容合并单元格功能

ExcelUtil

package com.yymt.utils;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import com.yymt.common.constants.CommonConstants;
import com.yymt.exception.RRException;
import com.yymt.exception.ResultEnum;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author:xielin
 * @Description: 导入(原始方式,支持读取合并)、导出(模板方式含合并)工具类
 * @Date:2023/1/11 14:33
 * @Version: 1.0
 */

public class ExcelUtil {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 创建工作簿
     *
     * @param filePath 文件路径
     * @return 工作簿
     * @throws IOException IO异常
     */
    public static Workbook createWorkBook(String filePath) throws IOException {
        Assert.isTrue(!FileUtil.exist(filePath), ResultEnum.FILE_NOT_FOUND.getMsg());
        //final Workbook workBook = new HSSFWorkbook(new FileInputStream(new File("test.xls")));
        if (filePath.toLowerCase().endsWith("xls")) {
            Workbook book = new HSSFWorkbook(new FileInputStream(new File(filePath)));
            return book;
        }
        if (filePath.toLowerCase().endsWith("xlsx")) {
            Workbook book = new XSSFWorkbook(new FileInputStream(new File(filePath)));
            return book;
        } else {
            throw new RRException("excel格式不正确");
        }
    }

    /**
     * 获取表格内容
     *
     * @param sheet           sheet对象
     * @param mergedRegionMap 合并单元格信息的Map
     * @param row             行对象
     * @param rowIndex        行索引
     * @param columnIndex     列索引
     * @return 获取表格内容
     */
    public static String getCellValue(Sheet sheet, Map<String, Integer[]> mergedRegionMap, Row row, int rowIndex, int columnIndex) {
        //将列对象的行号和列号+下划线组成key去hashmap中查询,不为空说明当前的cell是合并单元列
        String value = "";
        Integer[] firstRowNumberAndCellNumber = mergedRegionMap.get(rowIndex + "_" + columnIndex);
        //如果是合并单元列,就取合并单元格的首行和首列所在位置读数据,否则就是直接读数据
        if (firstRowNumberAndCellNumber != null) {
            Row rowTmp = sheet.getRow(firstRowNumberAndCellNumber[0]);
            Cell cellTmp = rowTmp.getCell(firstRowNumberAndCellNumber[1]);
            value = parseCell(cellTmp);
        } else {
            value = parseCell(row.getCell(columnIndex));
        }
        if ("/".equals(value)) {
            value = "";
        }
        return value;
    }

    /**
     * 将存在合并单元格的列记录入put进hashmap并返回
     *
     * @param sheet sheet对象
     * @return
     */
    public static Map<String, Integer[]> getMergedRegionMap(Sheet sheet) {
        Map<String, Integer[]> result = new HashMap<String, Integer[]>();
        //获取excel中的所有合并单元格信息
        int sheetMergeCount = sheet.getNumMergedRegions();
        //遍历处理
        for (int i = 0; i < sheetMergeCount; i++) {
            //拿到每个合并单元格,开始行,结束行,开始列,结束列
            CellRangeAddress range = sheet.getMergedRegion(i);
            int firstColumn = range.getFirstColumn();
            int lastColumn = range.getLastColumn();
            int firstRow = range.getFirstRow();
            int lastRow = range.getLastRow();

            //构造一个开始行和开始列组成的数组
            Integer[] firstRowNumberAndCellNumber = new Integer[]{firstRow, firstColumn};
            //遍历,将单元格中的所有行和所有列处理成由行号和下划线和列号组成的key,然后放在hashmap中
            for (int currentRowNumber = firstRow; currentRowNumber <= lastRow; currentRowNumber++) {
                for (int currentCellNumber = firstColumn; currentCellNumber <= lastColumn; currentCellNumber++) {
                    result.put(currentRowNumber + "_" + currentCellNumber, firstRowNumberAndCellNumber);
                }
            }
        }
        return result;
    }

    /**
     * 解析表格的值
     *
     * @param cell 单元格对象
     * @return 单元格的值
     */
    public static String parseCell(Cell cell) {
        String temp = "";
        if (ObjectUtil.isEmpty(cell)) {
            return temp;
        }
        if (cell.getCellType() == CellType.NUMERIC) {
            short format = cell.getCellStyle().getDataFormat();
            if (HSSFDateUtil.isCellDateFormatted(cell)) {
                SimpleDateFormat sdf = null;
                if (format == 20 || format == 32) {
                    sdf = new SimpleDateFormat("HH:mm");
                    temp = sdf.format(cell.getDateCellValue());
                } else if (format == 14 || format == 31 || format == 57 || format == 58 || format == 176) {
                    // 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58)
                    sdf = new SimpleDateFormat("yyyy-MM-dd");
                    double value = cell.getNumericCellValue();
                    Date date = org.apache.poi.ss.usermodel.DateUtil.getJavaDate(value);
                    temp = sdf.format(date);
                } else {
                    sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    temp = sdf.format(cell.getDateCellValue());
                }
            } else if (format == 57) {
                // HSSFDateUtil.isCellDateFormatted(cell) 存在误判
                SimpleDateFormat sdf = null;
                // 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58)
                sdf = new SimpleDateFormat("yyyy-MM-dd");
                double value = cell.getNumericCellValue();
                Date date = org.apache.poi.ss.usermodel.DateUtil.getJavaDate(value);
                temp = sdf.format(date);
            } else {
                temp = NumberFormat.getInstance().format(cell.getNumericCellValue());
            }
        } else if (cell.getCellType() == CellType.STRING) {
            temp = cell.getStringCellValue();
        } else if (cell.getCellType() == CellType.FORMULA) {
            temp = cell.getCellFormula();
        } else if (cell.getCellType() == CellType.BOOLEAN) {
            temp = String.valueOf(cell.getBooleanCellValue());
        }

        return StrUtil.trimToEmpty(temp);
    }

    /**
     * 根据dateStr转换成LocalDateTime
     * @param dateStr 日期格式字符串
     * @return LocalDateTime对象
     */
    public static LocalDateTime getLocalDateTime(String dateStr) {
        if (StrUtil.isNotBlank(dateStr)) {
            // dateStr如:2009年9月 也需要转成日期,默认是1日
            if (dateStr.contains("年") && dateStr.contains("月")) {
                         String year = dateStr.substring(0, dateStr.indexOf("年"));
                String month = dateStr.substring(dateStr.indexOf("年") + 1, dateStr.indexOf("月"));
                String day = "01";
                if (dateStr.contains("日")) {
                    day = dateStr.substring(dateStr.indexOf("月") + 1, dateStr.indexOf("日"));
                }
                return LocalDate.of(Convert.toInt(year), Convert.toInt(month), Convert.toInt(day)).atStartOfDay();
            }
            // dateStr如:2023/1/16
            return LocalDate.parse(dateStr).atStartOfDay();
        }
        return null;
    }

    public static Integer formatYesOrNo(String str) {
        return "是".equals(str) ? 1 : 0;
    }

    /**
     *
     * @param mapList 要导出的数据数据map集合
     * @param templateExcelName excel模板名称
     * @param sheetName sheet名称 (默认是excel模板名称)
     * @param fileName 临时导出的文件名
     * @return 可访问的文件路径
     */
    public static String handleExport(List<Map<String, Object>> mapList, String templateExcelName,String sheetName,String fileName) {
        // CommonConstants.TEMP_EXPORT_PATH = "/temp/export/"
        FileUtil.mkdir(CommonConstants.TEMP_EXPORT_PATH);
        Map<Integer, Map<String, Object>> sheetMap = new HashMap<>();
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("mapList", mapList);
        // 第一个sheet
        sheetMap.put(0, dataMap);
        if (StrUtil.isBlank(sheetName)) {
            sheetName = templateExcelName;
        }
        TemplateExportParams params = new TemplateExportParams("static/template/" + templateExcelName + ".xlsx", sheetName);
        Workbook workbook = ExcelExportUtil.exportExcel(sheetMap, params);

        String fileAllPath = CommonConstants.TEMP_EXPORT_PATH + fileName;
        try (FileOutputStream fos = new FileOutputStream(fileAllPath);) {
            workbook.write(fos);
        } catch (IOException e) {
            throw new RRException(e.getLocalizedMessage());
        }

         // 压缩文件
        //  compress(httpServletResponse);
        // File zip = ZipUtil.zip(FileUtil.file(CommonConstants.TEMP_EXPORT_PATH));
        // FileUtil.del(CommonConstants.TEMP_EXPORT_PATH);
        // String filePath = DownloadUtil.getFilePath(zip);
        // FileUtil.del(zip);
        
        String filePath = DownloadUtil.getFilePath(new File(fileAllPath));
        FileUtil.del(fileAllPath);
        return filePath;
    }

}

DownloadUtil

package com.yymt.utils;

import cn.hutool.core.io.IoUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.yymt.exception.RRException;
import com.yymt.modules.system.service.SysUploadFileService;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;

public class DownloadUtil {

    /**
     * 下载文件名重新编码
     *
     * @param response 响应对象
     * @param realFileName 真实文件名
     * @return
     */
    public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException {
        String percentEncodedFileName = percentEncode(realFileName);

        StringBuilder contentDispositionValue = new StringBuilder();
        contentDispositionValue.append("attachment; filename=")
                .append(percentEncodedFileName)
                .append(";")
                .append("filename*=")
                .append("utf-8''")
                .append(percentEncodedFileName);

        response.addHeader("Access-Control-Allow-Origin", "*");
        response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
        response.setHeader("Content-disposition", contentDispositionValue.toString());
        response.setHeader("download-filename", percentEncodedFileName);
        response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
        response.setCharacterEncoding("utf-8");
    }

    /**
     * 百分号编码工具方法
     *
     * @param s 需要百分号编码的字符串
     * @return 百分号编码后的字符串
     */
    public static String percentEncode(String s) throws UnsupportedEncodingException {
        String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
        return encode.replaceAll("\\+", "%20");
    }

    public static String getFilePath(File file) {
        FileItem fileItem = new DiskFileItemFactory().createItem("file",
                MediaType.MULTIPART_FORM_DATA_VALUE,
                true,
                file.getName());
        try (InputStream inputStream = new FileInputStream(file);
             OutputStream outputStream = fileItem.getOutputStream()) {
            // 流转换
            IoUtil.copy(inputStream, outputStream);
        } catch (Exception e) {
            throw new IllegalArgumentException("Invalid file:" + e, e);
        }
        CommonsMultipartFile multipartFile = new CommonsMultipartFile(fileItem);
        SysUploadFileService uploadFileService = SpringUtil.getBean(SysUploadFileService.class);
        R r = uploadFileService.uploadFile(multipartFile, "");
        if ( (Integer) r.get("code") != 0) {
            throw new RRException("文件下载失败");
        }
        Map<String,String> data = (Map<String,String>) r.get("data");
        return data.get("filePath");
    }
}

导入的调用示例

@Transactional(rollbackFor = Exception.class)
    public void importBatch(FilePathParams filePathParams) {
        // 修改换成真实文件路径
        String filePath = webUploadBase + filePathParams.getFilePath();
        Workbook workBook = null;
        List<SchoolBuildingUseSaveParam> list = new ArrayList<>();
        // 上一次读取的序号(用户去除重复读取数据)
        Integer lastNo = null;
        // 序号是否相同的数据
        Boolean isSameData;

        try {
            workBook = ExcelUtil.createWorkBook(filePath);
            //获取第一个sheet
            Sheet sheet = workBook.getSheetAt(0);
            //获取合并单元格信息的hashmap
            Map<String, Integer[]> mergedRegionMap = ExcelUtil.getMergedRegionMap(sheet);
            //从excel的第7行索行开始,遍历到最后一行(标题行,直接跳过不读取)
            for (int i = 6; i < sheet.getLastRowNum(); i++) {
                int j = 0;
                isSameData = Boolean.FALSE;
                // 拿到excel的行对象
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }

                SchoolBuildingUseSaveParam entity = null;
                // 序号
                Integer no = Convert.toInt(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                if (ObjectUtil.isEmpty(no)) {
                    break;
                }
                if (Objects.equals(no, lastNo)) {
                    isSameData = Boolean.TRUE;
                } else {
                    lastNo = no;
                }

                if (isSameData) {
                    entity = list.get(list.size() - 1);
                } else {
                    entity = new SchoolBuildingUseSaveParam();
                    // 校区名称
                    entity.setSchoolName(DicUtil.findCodeByTypeAndValue(DictTypeConstants.CAMPUS_NAME, ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++)));
                    // 建筑物名称
                    entity.setBuildingName(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                    // 取得方式
                    entity.setAcquisitionMethod(DicUtil.findCodeByTypeAndValue(DictTypeConstants.SCHOOL_BUILDING_USE_MANAGEMENT_ACQUISITION_METHOD, ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++)));
                    // 取得日期
                    entity.setAcquisitionDate(ExcelUtil.getLocalDateTime(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++)));
                    // 权属人
                    entity.setPropertyOwner(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                    // 资产价值(万元)
                    entity.setPropertyValue(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                    // 地上面积(平方米)
                    entity.setOvergroundArea(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                    // 地下面积(平方米)
                    entity.setUndergroundArea(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                    // 地上层数
                    entity.setOvergroundFloors(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                    // 地下层数
                    entity.setUndergroundFloors(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                    // 房屋权属证明
                    entity.setHouseOwnershipCertificate(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                    // 发证日期
                    entity.setReleaseDate(ExcelUtil.getLocalDateTime(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++)));
                    // 房屋所有权证号
                    entity.setHouseOwnershipNumber(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                    // 权属面积(平方米)
                    entity.setOwnershipArea(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                    // 是否BOT模式(1:是,0:否)
                    entity.setBotFlag(ExcelUtil.formatYesOrNo(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++)));
                    // BOT模式期限
                    entity.setBotDate(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                }


                // 使用情况的保存 (从18列使用单位开始读取)
                j = 17;
                // 学校正在自用
                SchoolBuildingUsageSaveParam schoolBuildingUsageSaveParam1 = new SchoolBuildingUsageSaveParam();
                schoolBuildingUsageSaveParam1.setUsage(UsageEnum.SCHOOL_PRIVATE_USE.getCode());
                schoolBuildingUsageSaveParam1.setUseUnit(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                schoolBuildingUsageSaveParam1.setUsePeopleCount(Convert.toInt(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++)));
                schoolBuildingUsageSaveParam1.setUseArea(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                // 出租出借
                SchoolBuildingUsageSaveParam schoolBuildingUsageSaveParam2 = new SchoolBuildingUsageSaveParam();
                schoolBuildingUsageSaveParam2.setUsage(UsageEnum.LEND_HIRE.getCode());
                schoolBuildingUsageSaveParam2.setFloorRange(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                schoolBuildingUsageSaveParam2.setUseArea(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                // 暂未有效使用
                SchoolBuildingUsageSaveParam schoolBuildingUsageSaveParam3 = new SchoolBuildingUsageSaveParam();
                schoolBuildingUsageSaveParam3.setUsage(UsageEnum.YET_EFFECTIVE_USE.getCode());
                schoolBuildingUsageSaveParam3.setFloorRange(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                schoolBuildingUsageSaveParam3.setUseArea(Convert.toDouble(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++), 0D));
                List<SchoolBuildingUsageSaveParam> schoolBuildingUsageSaveParamList = entity.getSchoolBuildingUsageSaveParamList();
                if (CollUtil.isEmpty(schoolBuildingUsageSaveParamList)) {
                    schoolBuildingUsageSaveParamList = new ArrayList<>();
                }
                if (schoolBuildingUsageSaveParam1.isValidOrNot()) {
                    schoolBuildingUsageSaveParamList.add(schoolBuildingUsageSaveParam1);
                }
                if (schoolBuildingUsageSaveParam2.isValidOrNot()) {
                    schoolBuildingUsageSaveParamList.add(schoolBuildingUsageSaveParam2);
                }
                if (schoolBuildingUsageSaveParam3.isValidOrNot()) {
                    schoolBuildingUsageSaveParamList.add(schoolBuildingUsageSaveParam3);
                }
                entity.setSchoolBuildingUsageSaveParamList(schoolBuildingUsageSaveParamList);

                // 删除最后的或新增实体
                if (isSameData) {
                    list.remove(list.size() - 1);
                } else {
                    // 是否老旧危房
                    entity.setOldHouseFlag(ExcelUtil.formatYesOrNo(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++)));
                    // 备注
                    entity.setRemark(ExcelUtil.getCellValue(sheet, mergedRegionMap, row, i, j++));
                }
                list.add(entity);
            }
            if (CollUtil.isNotEmpty(list)) {
                list.forEach(e -> insertOrUpdateSchoolBuildingUse(e));
            }
        } catch (Exception e) {
            log.error("error", e.getMessage());
            throw new RRException("数据导入异常");
        } finally {
            IoUtil.close(workBook);
        }
    }

导出的模板:

在这里插入图片描述

高校校舍使用情况统计表
单位(盖章): 填表人: 部门负责人: 分管校领导: 填表日期:
1234567891011121314151617181920212223242526
序号校区名称建筑物名称取得方式取得日期权属人资产价值(万元)建筑面积建筑层数权属情况BOT模式使用情况是否 老旧危房备注
地上面积地下面积地上层数地下层数房屋权属证明发证日期房屋所有权证号权属面积是否BOT模式BOT模式 期限学校正在自用出租出借暂未有效使用
使用单位使用人数使用面积楼层范围使用面积楼层范围使用面积
{{fe: mapList t.not.schoolNameValuet.buildingNamet.acquisitionMethodValuefd:(t.acquisitionDate;yyyy年MM月)t.propertyOwnert.propertyValuet.overgroundAreat.undergroundAreat.overgroundFloorst.undergroundFloorst.houseOwnershipCertificatefd:(t.releaseDate;yyyy年MM月)t.houseOwnershipNumbert.ownershipAreat.botFlagValuet.botDatet.usageList.useUnit1t.usageList.usePeopleCount1t.usageList.useArea1t.usageList.floorRange2t.usageList.useArea2t.usageList.floorRange3t.usageList.useArea3t.oldHouseFlagValuet.remark}}

导出的调用示例1

    @PostMapping("/exportBatch")
    @ApiOperation(value = "导出")
    public R exportBatch(@Validated @RequestBody SchoolBuildingUseExportParam schoolBuildingUseExportParam) {
        return R.ok().put("data", schoolBuildingUseService.exportBatch(schoolBuildingUseExportParam));
    }
@ApiModel(description = "校舍使用管理导出参数")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SchoolBuildingUseExportParam {

    @ApiModelProperty(value = "部分导出是不能为空")
    private List<String> idList;

    @ApiModelProperty(value = "导出类型,1:部分导出,2:全部导出")
    @NotNull(message = "导出类型不能为空")
    private Integer exportType;

}
public String exportBatch(SchoolBuildingUseExportParam schoolBuildingUseExportParam) {
    List<String> idList = schoolBuildingUseExportParam.getIdList();
    List<Long> idLongList = new ArrayList<>();
    if (schoolBuildingUseExportParam.getExportType() == 1) {
        Assert.isTrue(ObjectUtil.isEmpty(idList), "请选择要导出的数据");
        idLongList = idList.stream().map(Long::parseLong).collect(Collectors.toList());
    }

    // 查询要导出的数据
    List<SchoolBuildingUseEntity> schoolBuildingUseEntityList = list(Wrappers.<SchoolBuildingUseEntity>lambdaQuery()
            .in(ObjectUtil.isNotEmpty(idLongList), SchoolBuildingUseEntity::getId, idLongList)
            .orderByDesc(SchoolBuildingUseEntity::getUpdateTime));
    // Assert.isTrue(CollUtil.isEmpty(schoolBuildingUseEntityList), "暂无数据导出");无数据可以用于下载模板(id传0)
    // 转换后的
    AtomicReference<Integer> no = new AtomicReference<>(1);
    List<Map<String, Object>> mapList = schoolBuildingUseEntityList.stream().map(e -> {
        SchoolBuildingUseExportVO schoolBuildingUseExportVO = new SchoolBuildingUseExportVO();
        BeanUtil.copyProperties(e, schoolBuildingUseExportVO);
        schoolBuildingUseExportVO.setNo(no.getAndSet(no.get() + 1));
        schoolBuildingUseExportVO.setBotFlagValue(BotFlagEnum.getValueByCode(e.getBotFlag()));
        schoolBuildingUseExportVO.setOldHouseFlagValue(OldHouseFlagEnum.getValueByCode(e.getOldHouseFlag()));
        schoolBuildingUseExportVO.setSchoolNameValue(DicUtil.findValueByTypeAndCode(DictTypeConstants.CAMPUS_NAME, e.getSchoolName()));
        schoolBuildingUseExportVO.setAcquisitionMethodValue(DicUtil.findValueByTypeAndCode(
                DictTypeConstants.SCHOOL_BUILDING_USE_MANAGEMENT_ACQUISITION_METHOD, e.getAcquisitionMethod()));
        // 查询使用情况
        Map<Integer, List<SchoolBuildingUsageEntity>> collectMap = querySchoolBuildingUsageEntityMapList(e.getId());
        if (ObjectUtil.isNotEmpty(collectMap)) {
            schoolBuildingUseExportVO.setSchoolPrivateUseList(BeanUtil.copyToList(
                    collectMap.get(UsageEnum.SCHOOL_PRIVATE_USE.getCode()), SchoolBuildingUsageInfoVO.class));
            schoolBuildingUseExportVO.setLendHireList(BeanUtil.copyToList(
                    collectMap.get(UsageEnum.LEND_HIRE.getCode()), SchoolBuildingUsageInfoVO.class));
            schoolBuildingUseExportVO.setYetEffectiveUseList(BeanUtil.copyToList(
                    collectMap.get(UsageEnum.YET_EFFECTIVE_USE.getCode()), SchoolBuildingUsageInfoVO.class));
            // 设置使用情况集合
            generateSchoolBuildingUsageExportVOList(schoolBuildingUseExportVO);
        }
        return BeanUtil.beanToMap(schoolBuildingUseExportVO);
    }).collect(Collectors.toList());

    // 临时文件名
    String fileName = CommonConstants.SCHOOL_BUILDING_USE_TEMPLATE_EXCEL_NAME + StrUtil.UNDERLINE + System.currentTimeMillis() + ".xls";
    return ExcelUtil.handleExport(mapList, CommonConstants.SCHOOL_BUILDING_USE_TEMPLATE_EXCEL_NAME, null, fileName);
}

导出的调用示例2

	public String exportPropertyCheckCollect(List<Long> propertyCheckCollectIds,
                                           HttpServletResponse httpServletResponse) {
        TemplateExportParams params = new TemplateExportParams(
                "static/template/资产清查固定资产清查表(含明细、汇总)空表.xls", true,
                "附1-" + LocalDate.now().getYear() + "年赣南医学院固定资产清查明细表",
                "附2-" + LocalDate.now().getYear() + "年赣南医学院固定资产清查汇总表",
                "附3-" + LocalDate.now().getYear() + "年赣南医学院固定资产清查盘盈明细表",
                "附4-" + LocalDate.now().getYear() + "年赣南医学院固定资产清查盘亏明细表");

        List<PropertyCheckCollect> propertyCheckCollectList = baseMapper.selectBatchIds(propertyCheckCollectIds);
        Map<Long, List<PropertyCheckCollect>> listMap = propertyCheckCollectList.stream()
                .collect(Collectors.groupingBy(PropertyCheckCollect::getDeptId));

        Map<Integer, Map<String, Object>> sheetMap = new HashMap<Integer, Map<String, Object>>();

        Map<String, Object> map = new HashMap<String, Object>();

        List<Map<String, Object>> maplist = null;
        for (Map.Entry<Long, List<PropertyCheckCollect>> listEntry : listMap.entrySet()) {
            List<PropertyCheckCollect> checkCollectList = listEntry.getValue();
            for (PropertyCheckCollect propertyCheckCollect : checkCollectList) {

                int num1 = 0;
                // 根据盘点id查询盘点资产关联表
                List<PropertyCheckCorr> checkCorrList = propertyCheckCorrMapper.selectList(
                        Wrappers.<PropertyCheckCorr>lambdaQuery()
                                .eq(PropertyCheckCorr::getCheckId, propertyCheckCollect.getCheckId()));
                PropertyExportVO propertyExportVO = null;
                maplist = new ArrayList<Map<String, Object>>();
                for (PropertyCheckCorr propertyCheckCorr : checkCorrList) {
                    map = new HashMap<>();
                    map.put("year", LocalDateTime.now().getYear());
                    num1++;
                    propertyExportVO =
                            propertyCheckCorrMapper.selectPropertyByPropertyId(
                                    propertyCheckCorr.getPropertyId(), propertyCheckCorr.getCheckId());
                    map.put("deptName", propertyExportVO.getDeptName());

                    // 获取资产的存放位置
                    PropertyVO.PropertyUseInfo propertyUseInfo =
                            propertyUseService.findPropertyUseInfo(propertyCheckCorr.getPropertyId());
                    if (propertyUseInfo != null) {
                        propertyExportVO.setPropertyArea(propertyUseInfo.getPropertyArea());
                    }
                    // 盘点数量
                    propertyExportVO.setCheckNum(checkCorrList.size());
                    propertyExportVO.setNum(num1);

                    // 无盈亏
                    if (CheckStatusEnum.HAVE_INVENTORY.getInventoryStatus() == propertyCheckCorr.getInventoryStatus()) {
                        propertyExportVO.setNoProfitAndLoss("√");
                        // 盘盈
                    } else if (CheckStatusEnum.PROFIT.getInventoryStatus() == propertyCheckCorr.getInventoryStatus()) {
                        propertyExportVO.setProfit("√");
                        // 盘亏
                    } else if (CheckStatusEnum.LOSS.getInventoryStatus() == propertyCheckCorr.getInventoryStatus()) {
                        propertyExportVO.setLoss("√");
                    }

                    JSONObject parseObject = JSONObject.parseObject(JSON.toJSONString(propertyExportVO));
                    maplist.add(parseObject);
                }
                map.put("maplist", maplist);
                // 第一个sheet
                sheetMap.put(0, map);

                List<PropertyCheckCorr> checkCorrProfitList = propertyCheckCorrMapper.selectList(
                        Wrappers.<PropertyCheckCorr>lambdaQuery()
                                .eq(PropertyCheckCorr::getCheckId, propertyCheckCollect.getCheckId())
                                .eq(PropertyCheckCorr::getInventoryStatus, CheckStatusEnum.PROFIT.getInventoryStatus()));
                map = new HashMap<>();
                maplist = new ArrayList<Map<String, Object>>();
                map.put("year", LocalDateTime.now().getYear());
                JSONObject parseObject = null;
                int num3 = 0;
                if (CollectionUtils.isNotEmpty(checkCorrProfitList)) {
                    for (PropertyCheckCorr propertyCheckCorr : checkCorrProfitList) {

                        propertyExportVO =
                                propertyCheckCorrMapper.selectPropertyByPropertyId(propertyCheckCorr.getPropertyId(), propertyCheckCorr.getCheckId());
                        map.put("deptName", propertyExportVO.getDeptName());
                        // 获取资产的存放位置
                        PropertyVO.PropertyUseInfo propertyUseInfo =
                                propertyUseService.findPropertyUseInfo(propertyCheckCorr.getPropertyId());
                        if (propertyUseInfo != null) {
                            propertyExportVO.setPropertyArea(propertyUseInfo.getPropertyArea());
                        }
                        // 盘点数量
                        propertyExportVO.setCheckNum(checkCorrList.size());
                        num3++;
                        propertyExportVO.setNum(num3);
                        propertyExportVO.setProfit("√");
                        parseObject = JSONObject.parseObject(JSON.toJSONString(propertyExportVO));
                        maplist.add(parseObject);
                    }
                }
                map.put("maplist", maplist);
                // 第三个sheet
                sheetMap.put(2, map);

                List<PropertyCheckCorr> checkCorrLossList = propertyCheckCorrMapper.selectList(
                        Wrappers.<PropertyCheckCorr>lambdaQuery()
                                .eq(PropertyCheckCorr::getCheckId, propertyCheckCollect.getCheckId())
                                .eq(PropertyCheckCorr::getInventoryStatus, CheckStatusEnum.LOSS.getInventoryStatus()));
                map = new HashMap<>();
                maplist = new ArrayList<Map<String, Object>>();
                map.put("year", LocalDateTime.now().getYear());
                int num4 = 0;
                if (CollectionUtils.isNotEmpty(checkCorrLossList)) {
                    for (PropertyCheckCorr propertyCheckCorr : checkCorrLossList) {
                        propertyExportVO =
                                propertyCheckCorrMapper.selectPropertyByPropertyId(
                                        propertyCheckCorr.getPropertyId(), propertyCheckCorr.getCheckId());
                        map.put("deptName", propertyExportVO.getDeptName());
                        // 获取资产的存放位置
                        PropertyVO.PropertyUseInfo propertyUseInfo =
                                propertyUseService.findPropertyUseInfo(propertyCheckCorr.getPropertyId());
                        if (propertyUseInfo != null) {
                            propertyExportVO.setPropertyArea(propertyUseInfo.getPropertyArea());
                        }
                        // 盘点数量
                        propertyExportVO.setCheckNum(checkCorrList.size());
                        num4++;
                        propertyExportVO.setNum(num4);
                        propertyExportVO.setLoss("√");
                        parseObject = JSONObject.parseObject(JSON.toJSONString(propertyExportVO));
                        maplist.add(parseObject);
                    }
                }
                map.put("maplist", maplist);
                // 第四个sheet
                sheetMap.put(3, map);

                // 组装第二个sheet数据
                map = new HashMap<>();
                map.put("year", LocalDate.now().getYear());
                map.put("deptName", propertyExportVO.getDeptName());
                map.put("checkNum", propertyExportVO.getCheckNum());

                if (CollectionUtils.isNotEmpty(checkCorrList)) {
                    // 查询资产的总金额
                    List<Long> propertyIdList = checkCorrList.stream()
                            .map(PropertyCheckCorr::getPropertyId).collect(Collectors.toList());
                    BigDecimal totalMoney = propertyService.sumAllPropertyMoney(propertyIdList);
                    map.put("totalMoney", totalMoney);

                    PropertyCheck propertyCheck = propertyCheckService.getById(checkCorrList.get(0).getCheckId());
                    map.put("checkFinishTime", propertyCheck.getCheckFinishTime());
                }

                // 查询无盈亏台数
                List<PropertyCheckCorr> checkCorrNoProfitAndLossList = propertyCheckCorrMapper.selectList(
                        Wrappers.<PropertyCheckCorr>lambdaQuery()
                                .eq(PropertyCheckCorr::getCheckId, propertyCheckCollect.getCheckId())
                                .eq(PropertyCheckCorr::getInventoryStatus, CheckStatusEnum.HAVE_INVENTORY.getInventoryStatus()));
                if (CollectionUtils.isNotEmpty(checkCorrNoProfitAndLossList)) {
                    map.put("noProfitAndLoss", checkCorrNoProfitAndLossList.size());
                    List<Long> propertyIds = checkCorrNoProfitAndLossList.stream()
                            .map(PropertyCheckCorr::getPropertyId).collect(Collectors.toList());
                    BigDecimal noProfitAndLossMoney = propertyService.sumAllPropertyMoney(propertyIds);
                    map.put("noProfitAndLossMoney", noProfitAndLossMoney);
                } else {
                    map.put("noProfitAndLoss", 0);
                    map.put("noProfitAndLossMoney", 0);
                }

                // 盘盈台数
                if (CollectionUtils.isNotEmpty(checkCorrProfitList)) {
                    map.put("profit", checkCorrProfitList.size());
                } else {
                    map.put("profit", 0);
                }

                // 盘亏台数 和盘亏总金额
                if (CollectionUtils.isNotEmpty(checkCorrLossList)) {
                    map.put("loss", checkCorrLossList.size());
                    List<Long> propertyIds = checkCorrLossList.stream()
                            .map(PropertyCheckCorr::getPropertyId).collect(Collectors.toList());
                    BigDecimal lossMoney = propertyService.sumAllPropertyMoney(propertyIds);
                    map.put("lossMoney", lossMoney);
                } else {
                    map.put("loss", 0);
                    map.put("lossMoney", 0);
                }
                // 第二个sheet
                sheetMap.put(1, map);

                Workbook workbook = ExcelExportUtil.exportExcel(sheetMap, params);

                File savefile = new File("/tmp/excel/");
                if (!savefile.exists()) {
                    savefile.mkdirs();
                }

                FileOutputStream fos = null;
                try {
                    fos = new FileOutputStream("/tmp/excel/" + propertyCheckCollect.getCollectName()
                            + "资产清查固定资产清查表(含明细、汇总)表.xls");
                    workbook.write(fos);
                } catch (IOException e) {
                    log.error("导出盘点汇总报表异常: {}", e.getLocalizedMessage(), e);
                } finally {
                    try {
                        if (fos != null) {
                            fos.close();
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        // 压缩文件
       // compress(httpServletResponse);
        File zip = ZipUtil.zip(FileUtil.file("/tmp/excel/"));
        FileUtil.del("/tmp/excel/");
        String filePath = DownloadUtil.getFilePath(zip);
        FileUtil.del(zip);
        return filePath;
    }
    
	private void compress(HttpServletResponse httpServletResponse) {

        File zip = ZipUtil.zip(FileUtil.file("/tmp/excel/"));
        FileUtil.del("/tmp/excel/");
        FileInputStream fis = null;
        ServletOutputStream outputStream = null;
        try {
            DownloadUtil.setAttachmentResponseHeader(httpServletResponse,
                    "资产清查固定资产清查表(含明细、汇总)表.zip");

            fis = new FileInputStream(zip);
            outputStream = httpServletResponse.getOutputStream();
            byte[] buffer = new byte[1024];
            int read = -1;
            while ((read = fis.read(buffer)) != -1) {
                outputStream.write(buffer, 0, read);
            }
        } catch (IOException e) {
            log.error("下载盘点汇总报表异常: {}", e.getLocalizedMessage(), e);
        } finally {
            try {
                if (fis != null) {
                    fis.close();
                }
                if (outputStream != null) {
                    outputStream.close();
                }
                    FileUtil.del(zip);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

扩展其他

不使用模板的导出,使用@ExcelCollection可以自动合并单元格

sheet.addMergedRegion(new Region(2,(short)0,3,(short )0));
//跨两行占一列 ce.setCellStyle(style); HSSFCell ce1=row.createCell(1);
//姓名 ce1.setCell

    public static void main(String[] args) throws IOException {
        export1();
    }

    @GetMapping("/goods")
    public static void export1() throws IOException {
        List<UserGoodsDto> userGoodsDtos = new ArrayList<>();

        UserGoodsDto userGoodsDto = new UserGoodsDto();
        userGoodsDto.setUserName("name1");

        List<UserGoods> userGoodsList = new ArrayList<>();
        UserGoods userGoods = new UserGoods();
        userGoods.setId(1);
        userGoods.setGoodsName("name0");
        userGoods.setGoodsAddress("add");
        userGoods.setCreatedTime(new Date());

        UserGoods userGoods2 = new UserGoods();
        userGoods2.setId(2);
        userGoods2.setGoodsName("name1");
        userGoods2.setGoodsAddress("add2");
        userGoods2.setCreatedTime(new Date());

        userGoodsList.add(userGoods);
        userGoodsList.add(userGoods2);
        userGoodsDto.setUserGoodsList(userGoodsList);

        //***
        UserGoodsDto userGoodsDto2 = new UserGoodsDto();
        userGoodsDto2.setUserName("name1");

        List<UserGoods> userGoodsList2 = new ArrayList<>();
        userGoodsList2.add(new UserGoods()
                .setId(3)
                .setGoodsName("name2")
                .setGoodsAddress("add2")
                .setCreatedTime(new Date()));
        userGoodsList2.add(new UserGoods()
                .setId(4)
                .setGoodsName("name3")
                .setGoodsAddress("add2")
                .setCreatedTime(new Date()));
        userGoodsDto2.setUserGoodsList(userGoodsList2);

        List<UserGoodsTest> userGoodsTestList = new ArrayList<>();
        userGoodsTestList.add(new UserGoodsTest()
                .setId(4)
                .setGoodsName("name3Test")
                .setGoodsAddress("add2")
                .setCreatedTime(new Date()));
        userGoodsDto2.setUserGoodsTestList(userGoodsTestList);


        userGoodsDtos.add(userGoodsDto);
        userGoodsDtos.add(userGoodsDto2);

        System.out.println(userGoodsDtos);
        ExportParams exportParams = new ExportParams("双十一客户下单情况", null);

        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, UserGoodsDto.class, userGoodsDtos);
        // ExcelExportEntity excelExportEntity = new ExcelExportEntity();
        // ExcelExportUtil.exportExcel(exportParams, , userGoodsDtos);
        String fileAllPath = CommonConstants.TEMP_EXPORT_PATH + "1.xls";
        try (FileOutputStream fos = new FileOutputStream(fileAllPath);) {
            workbook.write(fos);
        } catch (IOException e) {
            throw new RRException(e.getLocalizedMessage());
        }

        // ExcelExportUtil.exportExcel(userGoodsDtos,UserGoodsDto.class,"测试",exportParams,response);
    }



@Data
@Accessors(chain = true)
class UserGoodsDto {
    @Excel(name = "用户名", needMerge = true)
    private String userName;
    @ExcelCollection(name = "商品")
    private List<UserGoods> userGoodsList;
    @ExcelCollection(name = "商品2")
    private List<UserGoodsTest> userGoodsTestList;
}

@Data
@Accessors(chain = true)
class UserGoods {
    private Integer id;
    @Excel(name = "商品名")
    private String goodsName;
    @Excel(name = "收货地址")
    private String goodsAddress;
    @Excel(name = "下单时间", exportFormat = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;
}

@Data
@Accessors(chain = true)
class UserGoodsTest {
    private Integer id;
    @Excel(name = "商品名test")
    private String goodsName;
    @Excel(name = "收货地址test")
    private String goodsAddress;
    @Excel(name = "下单时间test", exportFormat = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;
}

oodsDto.class,“测试”,exportParams,response);
}

@Data
@Accessors(chain = true)
class UserGoodsDto {
@Excel(name = “用户名”, needMerge = true)
private String userName;
@ExcelCollection(name = “商品”)
private List userGoodsList;
@ExcelCollection(name = “商品2”)
private List userGoodsTestList;
}

@Data
@Accessors(chain = true)
class UserGoods {
private Integer id;
@Excel(name = “商品名”)
private String goodsName;
@Excel(name = “收货地址”)
private String goodsAddress;
@Excel(name = “下单时间”, exportFormat = “yyyy-MM-dd HH:mm:ss”)
private Date createdTime;
}

@Data
@Accessors(chain = true)
class UserGoodsTest {
private Integer id;
@Excel(name = “商品名test”)
private String goodsName;
@Excel(name = “收货地址test”)
private String goodsAddress;
@Excel(name = “下单时间test”, exportFormat = “yyyy-MM-dd HH:mm:ss”)
private Date createdTime;
}


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

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

相关文章

linux系统中利用QT实现环境传感器的数据获取方法

大家好&#xff0c;今天主要和大家分享一下&#xff0c;如何使用QT实现对三合一环境传感器的数据的获取和实现。 目录 第一&#xff1a;资源介绍 第二&#xff1a;具体代码的详细实现 第三&#xff1a;源文件“mainwindow.h”实现 第四&#xff1a;Linux应用接口获取数据 第…

大趋势:科技赋能产业

能整合传统产业资源的老板大优势&#xff01; 三大趋势&#xff1a; 科技赋能产业链 乡村振兴 文化复兴 纯技术类企业在产业链方面不占优势 趣讲大白话&#xff1a;时势造英雄 ******** 消费互联网竞争太卷了 竞争向产业升级方向转移 向高质量发展导向 乡村振兴是整合分散的集…

容器虚拟化技术Docker(一)简介、安装、常见命令、数据卷、安装常规软件

容器虚拟化技术Docker&#xff08;一&#xff09;简介、安装、常见命令、数据卷、安装常规软件 1、Docker简介 1、简介 Docker的主要目标是“Build&#xff0c;Ship and Run Any App,Anywhere”&#xff0c;也就是通过对应用组件的封装、分发、部署、运行等生命周期的管理&a…

web3:同态加密

web3相关学习一并收录至该博客&#xff1a;web3学习博客目录大全 目录同态加密概念同态加密具体如何定义&#xff1f;主流同态加密算法原理乘法同态加密算法① RSA算法一些基本的数学知识RSA的具体过程秘钥的产生加密解密验证了 RSA 算法的乘法同态性java代码简单实现python代码…

保时捷狂推NFT,高调喊出打造Web3社区,Web2品牌“天生缺陷”终将折戟沉沙?...

图片来源&#xff1a;由无界 AI 绘画工具生成2023年1月&#xff0c;保时捷中国的公关团队“忙疯”了&#xff0c;一连搞了好几个活动。有展览&#xff0c;媒体连线直播&#xff0c;甚至搞起了一场有圆桌&#xff0c;有嘉宾主题演讲的发布会。目的只有一个&#xff0c;告诉中国用…

6、Ubuntu20的JDKMySQLtomcatRedisNginx安装

安装JDK 这里以安装版本8为例 进入存放jdk目录创建目录 cd /usr/local mkdir jdk cd jdk 把下好的jdk8压缩包拖拽到Ubuntu连接用户下 移动jdk包文件 mv /home/starfish/jdk-8u351-linux-x64.tar.gz . 解压jdk tar -zxvf jdk-8u351-linux-x64.tar.gz cd jdk1.8.0_351/ p…

ubuntu20.04安装搜狗sogou输入法

环境 Ubuntu20.04 Sogou拼音输入法安装过程 Step.1 安装fcitx框架 sudo apt-get update sudo apt-get install fcitx输入winA后&#xff0c;打开Languate Support Keyboard input method system中&#xff0c;选择fcitx 点击Install/RemoveLanguates...&#xff0c;选择Ch…

面向物流行业的文档管理系统

用于运输和物流的 DocuWare 文档管理软件 物流和货运行业的效率激烈战在公路、火车、货船和空中展开。DocuWare 的快速、安全和灵活的文档管理是真正的竞争优势。在您的公司和客户的核心流程中节省新的成本和时间。 一、数字化和文档管理软件改变了物流公司的游戏规则 智能链…

PostgreSQL 技术内幕(五)Greenplum-Interconnect模块

Greenplum是在开源PostgreSQL的基础上&#xff0c;采用MPP架构的关系型分布式数据库。Greenplum被业界认为是最快最具性价比的数据库&#xff0c;具有强大的大规模数据分析任务处理能力。 Greenplum采用Shared-Nothing架构&#xff0c;整个集群由多个数据节点&#xff08;Segm…

mycat数据分片

Mycat是一个彻底开源的&#xff0c;面向企业应用开发的大数据库集群。它的定义是是一个开源的分布式数据库系统&#xff0c;是一个实现了MySQL协议的服务器&#xff0c;前端用户可以把它看作是一个数据库代理&#xff0c;用MySQL客户端工具和命令行访问&#xff0c;而其后端可以…

【题解】2023牛客寒假算法基础集训营1

目录A. World Final? World Cup! (I)思路B. World Final? World Cup! (II)C. 现在是&#xff0c;学术时间 (I)思路D. 现在是&#xff0c;学术时间 (II)思路E. 鸡算几何思路F. 鸡玩炸蛋人思路G. 鸡格线思路H. 本题主要考察了DFS思路I. 本题也主要考察了DFSJ. 本题竟也主要考察…

MySQL详细教程,2023硬核学习路线,看这一篇就够了

文章目录前言1. 数据库的相关概念1.1 数据1.2 数据库1.3 数据库管理系统1.4 数据库系统1.5 SQL2. MySQL数据库2.1 MySQL安装2.2 MySQL配置2.2.1 添加环境变量2.2.2 新建配置文件2.2.3 初始化MySQL2.2.4 注册MySQL服务2.2.5 启动MySQL服务2.3 MySQL登录和退出2.4 MySQL卸载2.5 M…

PR基础知识

sh什么是帧&#xff0c;什么是帧速率&#xff0c;什么是方形像素? 什么叫场序? # 时长 s时i长为视频时间得长度&#xff0c;基本单位为秒。但是在PR软件中。有更为精准得时间单位计算为帧。也就是说把1秒分为若干份。一份就是一帧。一帧也就可以理解为一张图片。 s所以在PR…

联合证券|未来五年是“大信创”发展的关键时期 发展空间广阔

机构指出&#xff0c;展望2023年&#xff0c;信创将从党政信创走向全面信创&#xff08;28N&#xff09;&#xff0c;叠加方针催化及疫情预期转变&#xff0c;泛信创范畴有望成为板块主线&#xff0c;孕育出许多板块的出资机会。 中心逻辑 1、2022年计算机职业大都子板块的增长…

用户行为收集到HIVE

2.3 用户行为收集到HIVE 目标 目标 知道收集用户日志形式、流程知道flume收集相关配置、hive相关配置知道supervisor开启flume收集进程管理应用 应用supervisor管理flume实时收集点击日志 2.3.1 为什么要收集用户点击行为日志 用户行为对于某项目文章推荐来说&#xff0c;至…

京东方尚未成为苹果的最大供应商,但已经享受到果链的好处

在知名分析师郭明錤表示京东方今年将成为苹果iPhone15的OLED面板主力供应商后&#xff0c;业界纷纷期待京东方在中小尺寸OLED面板市场的份额激增&#xff0c;目前虽然京东方尚未真正开始向苹果供应iPhone15的OLED面板&#xff0c;但它已开始享受到果链带来的好处。京东方量产OL…

嵌入式C语言设计模式 --- 装饰器模式

1 - 什么是装饰器模式? 装饰器模式(Decorator Pattern),是结构型设计模式的一种,装饰器模式允许向一个现有的对象添加新的功能,而又不改变其对象结构,这种方式比使用子类继承的方式更加灵活。 装饰,顾名思义,就是在原有事物的基础上,锦上添花地新增某些点缀或功能,…

[ROS2 入门] rqt_console 使用介绍

大家好&#xff0c;我是虎哥&#xff0c;从今天开始&#xff0c;我将花一段时间&#xff0c;开始将自己从ROS1切换到ROS2&#xff0c;在上一篇中&#xff0c;我们一起了解ROS 2中“Actions ”概念&#xff0c;至此最基本的核心基础概念&#xff0c;我们就都分享介绍完毕了&…

③【Spring】整合第三框架的常用机制:FactoryBean

个人简介&#xff1a;Java领域新星创作者&#xff1b;阿里云技术博主、星级博主、专家博主&#xff1b;正在Java学习的路上摸爬滚打&#xff0c;记录学习的过程~ 个人主页&#xff1a;.29.的博客 学习社区&#xff1a;进去逛一逛~ FactoryBean 机制一、什么是 FactoryBean &…

Linux:报错“command not found: yum”及yum和apt-get的区别

还是最近的工作总结&#xff0c;使用yum命令安装出现了报错&#xff0c;具体看下面 目录报错原因yum和apt-get的区别yumyum功能yum特点yum常用命令apt-getapt常用命令解决报错 使用命令安装 yum install sysstat结果报错 zsh&#xff1a;command not found: yum 印象中安装命…