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

springboot-vue excel上传导出

数据库

device_manage表

字段,id,workshop,device_number,device_name,device_model,warn_time,expired_time

device_warn表

字段,id,warn_time,expired_time

后端

实体类格式

device_manage

@Data
@TableName("device_manage")/*
设备管理
*/
public class DeviceManageEntity {private static final long serialVersionUID = 1L;/*** 主键*/@TableIdprivate Integer id;/*** 车间名称*/private String workshop;/*** 设备编号*/private String deviceNumber;/*** 设备名称*/private String deviceName;/*** 设备型号*/private String deviceModel;/*** 维保预警时间*/@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")private Date warnTime;/*** 维保到期时间*/@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")private Date expiredTime;}

device_warn

@Data
@TableName("device_warn")/*保养预警*/
public class DeviceWarnEntity {private static final long serialVersionUID = 1L;/*** 编号*/@TableIdprivate Integer id;/*** 保养到期时间*/@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")private Date expiredTime;/*** 预警时间*/@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")private Date warnTime;}

选择导出的字段warnVo

@Data
@ColumnWidth(20)
public class WarnVo {//传输给前端展示//id@ExcelIgnoreprivate Long id;//车间@ExcelProperty("车间名称")private String workshop;//设备编号@ExcelProperty("设备编号")private String deviceNumber;//设备名称@ExcelProperty("设备名称")private String deviceName;//设备型号@ExcelProperty("设备型号")private String deviceModel;//维保到期时间@ExcelProperty("维保到期时间")@DateTimeFormat("yyyy-MM-dd HH:mm:ss")private Date expiredTime;//预警时间@ExcelProperty("预警时间")@DateTimeFormat("yyyy-MM-dd HH:mm:ss")private Date warnTime;
}

controller层

@RestController
@RequestMapping("/dev/warn")
public class exportController {@Autowiredprivate DeviceWarnService iTainWarnService;
//字典类,前端下拉框选项@Autowiredprivate SysDictService sysDictService;@Autowiredprivate DeviceManageService iDeviceService;//文件上传@PostMapping("/upload")@ResponseBodypublic R upload(MultipartFile file) throws IOException {if (file==null){System.out.println("文件为空");}WarnVoListener warnVoListener = new WarnVoListener(sysDictService, iTainWarnService, iDeviceService);
//初始化tipsList<ImportTips> tips = new ArrayList<>();for (WarnVo data : warnVoListener.getDatas()) {tips = warnVoListener.getTips();}if (tips.size() > 0) {return R.error();}EasyExcel.read(file.getInputStream(), WarnVo.class, warnVoListener).sheet().doRead();return R.ok();}//文件导出/*** 文件下载并且失败的时候返回json(默认失败了会返回一个有部分数据的Excel)* 这种方法是将Excel文件的生成过程放在后端进行。前端发起一个请求到后端,后端处理数据并生成Excel文件,然后将文件返回给前端进行下载。* 这种方法的优点是可以将数据处理的压力放在后端,前端只需要处理请求和下载文件的逻辑。* @since 2.1.1,设置响应头*/private  void setExcelResponseProp(HttpServletResponse response,String rawFileName) throws UnsupportedEncodingException {response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");response.setCharacterEncoding("utf-8");String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");}@GetMapping("/download")public void download(HttpServletResponse response) throws IOException {// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postmantry {response.setContentType("application/vnd.ms-excel");response.setCharacterEncoding("utf-8");// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系String fileName = URLEncoder.encode("测试", "UTF-8");response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");this.setExcelResponseProp(response,"保养预警");List<WarnVo> warnVos = iTainWarnService.listAllWarn();
//得到字典类所有选项List<SysDictEntity> workShopList = sysDictService.maintenanceList(" workshop");for (WarnVo warnVo : warnVos) {for (SysDictEntity sysDictEntity :  workShopList) {if (sysDictEntity.getValue().compareTo(warnVo.getWorkshop())==0){warnVo.setWorkshop(sysDictEntity.getName());}}}List<SysDictEntity> deviceModelList = sysDictService.maintenanceList("deviceModel");for (WarnVo warnVo : warnVos) {for (SysDictEntity sysDictEntity :  deviceModelList) {if (sysDictEntity.getValue().compareTo(warnVo.getDeviceModel())==0){warnVo.setDeviceModel(sysDictEntity.getName());}}}// 这里需要设置不关闭流EasyExcel.write(response.getOutputStream(), WarnVo.class)// 导出Excel时在此处注册handler.registerWriteHandler(new CustomSheetWriteHandler(sysDictService)).autoCloseStream(Boolean.FALSE).sheet("保养预警").doWrite(warnVos);} catch (Exception e) {// 重置responseresponse.reset();response.setContentType("application/json");response.setCharacterEncoding("utf-8");Map<String, String> map = new HashMap<>();map.put("status", "failure");map.put("message", "下载文件失败" + e.getMessage());response.getWriter().println(JSON.toJSONString(map));}}}

listener

CustomSheetWriteHandler导出

@Service
public class CustomSheetWriteHandler implements SheetWriteHandler {@Autowiredprivate SysDictService sysDictService;public CustomSheetWriteHandler(SysDictService sysDictService) {this.sysDictService = sysDictService;}@Overridepublic void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {}/*** 想实现Excel引用其他sheet页数据作为单元格下拉选项值,* 需要重写该方法** @param writeWorkbookHolder* @param writeSheetHolder*/@Overridepublic void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {// 构造样例数据,该数据可根据实际需要,换成业务数据// 实际数据可通过构造方法,get、set方法等由外界传入List<String> selectworkshopList = new ArrayList<>();List<SysDictEntity> workshoplist = sysDictService.maintenanceList("workshop");for (SysDictEntity sysDictEntity : workshoplist) {if (sysDictEntity.getSort()!=null){selectworkshopList.add(sysDictEntity.getName());}}List<String> selectmodelList = new ArrayList<>();List<SysDictEntity> modellist = sysDictService.maintenanceList("deviceModel");for (SysDictEntity sysDictEntity : modellist) {if (sysDictEntity.getSort()!=null){selectmodelList.add(sysDictEntity.getName());}}// 构造下拉选项单元格列的位置,以及下拉选项可选参数值的map集合// key:下拉选项要放到哪个单元格,比如A列的单元格那就是0,C列的单元格,那就是2// value:key对应的那个单元格下拉列表里的数据项,比如这里就是下拉选项1..100Map<Integer, List<String>> selectParamMap = new HashMap<>();selectParamMap.put(0, selectworkshopList);selectParamMap.put(3, selectmodelList);// 获取第一个sheet页Sheet sheet = writeSheetHolder.getCachedSheet();// 获取sheet页的数据校验对象DataValidationHelper helper = sheet.getDataValidationHelper();// 获取工作簿对象,用于创建存放下拉数据的字典sheet数据页Workbook workbook = writeWorkbookHolder.getWorkbook();// 迭代索引,用于存放下拉数据的字典sheet数据页命名int index = 1;for (Map.Entry<Integer, List<String>> entry : selectParamMap.entrySet()) {// 设置存放下拉数据的字典sheet,并把这些sheet隐藏掉,这样用户交互更友好String dictSheetName = "dict_hide_sheet" + index;Sheet dictSheet = workbook.createSheet(dictSheetName);// 隐藏字典sheet页workbook.setSheetHidden(index++, true);// 设置下拉列表覆盖的行数,从第一行开始到最后一行,这里注意,Excel行的// 索引是从0开始的,我这边第0行是标题行,第1行开始时数据化,可根据实// 际业务设置真正的数据开始行,如果要设置到最后一行,那么一定注意,// 最后一行的行索引是1048575,千万别写成1048576,不然会导致下拉列表// 失效,出不来CellRangeAddressList infoList = new CellRangeAddressList(1, 1048575, entry.getKey(), entry.getKey());int rowLen = entry.getValue().size();for (int i = 0; i < rowLen; i++) {// 向字典sheet写数据,从第一行开始写,此处可根据自己业务需要,自定// 义从第几行还是写,写的时候注意一下行索引是从0开始的即可dictSheet.createRow(i).createCell(0).setCellValue(entry.getValue().get(i));}// 设置关联数据公式,这个格式跟Excel设置有效性数据的表达式是一样的String refers = dictSheetName + "!$A$1:$A$" + entry.getValue().size();Name name = workbook.createName();name.setNameName(dictSheetName);// 将关联公式和sheet页做关联name.setRefersToFormula(refers);// 将上面设置好的下拉列表字典sheet页和目标sheet关联起来DataValidationConstraint constraint = helper.createFormulaListConstraint(dictSheetName);DataValidation dataValidation = helper.createValidation(constraint, infoList);sheet.addValidationData(dataValidation);}}
}

WarnVoListener导入

@Slf4j
public class WarnVoListener extends AnalysisEventListener<WarnVo> {private static final Logger LOGGER = LoggerFactory.getLogger(WarnVoListener.class);/*** 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收*/private static final int BATCH_COUNT = 5;//    List<WarnVo> list = new ArrayList<>();List<DeviceManageEntity> deviceList = new ArrayList<>();List<DeviceWarnEntity> tainWarnList = new ArrayList<>();/*** 假设这个是一个DAO,当然有业务逻辑这个也可以是一个service。当然如果不用存储这个对象没用。*/private SysDictService sysDictService;private DeviceWarnService iTainWarnService;private DeviceManageService iDeviceService;//    public WarnVoListener() {
//        // 这里是demo,所以随便new一个。实际使用如果到了spring,请使用下面的有参构造函数
//        demoDAO = new DemoDAO();
//    }/*** 如果使用了spring,请使用这个构造方法。每次创建Listener的时候需要把spring管理的类传进来**/public WarnVoListener(SysDictService sysDictService,DeviceWarnService iTainWarnService,DeviceManageService iDeviceService) {this.sysDictService = sysDictService;this.iTainWarnService = iTainWarnService;this.iDeviceService = iDeviceService;}/*** 返回提示语*/private List<ImportTips> tips = new ArrayList<>();/*** 自定义用于暂时存储data* 可以通过实例获取该值*/private List<WarnVo> datas = new ArrayList<>();/*** 这个每一条数据解析都会来调用** @param data*            one row value. Is is same as {@link AnalysisContext#readRowHolder()}* @param context*/@Overridepublic void invoke(WarnVo data, AnalysisContext context) {
//        LOGGER.info("解析到一条数据:{}", JSON.toJSONString(data));// 该行数据是否有错误boolean checkRowError = false;LOGGER.info("数据导入,解析第{}行数据:{}" , context.readRowHolder().getRowIndex() , data);List<DeviceManageEntity> devList = iDeviceService.list();for (DeviceManageEntity devices : devList) {if (devices.getDeviceNumber().equals(data.getDeviceNumber())){saveTips(context.readRowHolder().getRowIndex(),"导入文件中设备编号有重复",tips);checkRowError = true;}}//当该行数据没有错误时,数据存储到集合,供批量处理。if(!checkRowError){//device表DeviceManageEntity device = new DeviceManageEntity();
//            device.setDeviceModel(data.getDeviceModel());device.setDeviceName(data.getDeviceName());device.setDeviceNumber(data.getDeviceNumber());device.setWarnTime(data.getWarnTime());device.setExpiredTime(data.getExpiredTime());List<SysDictEntity> list = sysDictService.maintenanceList("workshop");for (SysDictEntity sysDictEntity : list) {if (sysDictEntity.getName().compareTo(data.getWorkshop())!=0){device.setWorkshop(sysDictEntity.getValue());}}List<SysDictEntity> modellist = sysDictService.maintenanceList("deviceModel");for (SysDictEntity sysDictEntity : modellist) {if (sysDictEntity.getName().compareTo(data.getDeviceModel())!=0){device.setDeviceModel(sysDictEntity.getValue());}}this.deviceList.add(device);//tain_warn表/*  DeviceWarnEntity tainWarn = new DeviceWarnEntity();tainWarn.setExpiredTime(data.getExpiredTime());tainWarn.setWarnTime(data.getWarnTime());this.tainWarnList.add(tainWarn);*/datas.add(data);}// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOMif (this.deviceList.size() >= BATCH_COUNT) {saveData();// 存储完成清理 listthis.deviceList.clear();}if (this.tainWarnList.size() >= BATCH_COUNT) {saveData();// 存储完成清理 listthis.tainWarnList.clear();}}/*** 所有数据解析完成了 都会来调用** @param context*/@Overridepublic void doAfterAllAnalysed(AnalysisContext context) {// 这里也要保存数据,确保最后遗留的数据也存储到数据库saveData();LOGGER.info("所有数据解析完成!");}/*** 加上存储数据库*/private void saveData() {LOGGER.info("{}条数据,开始存储数据库!", deviceList.size());LOGGER.info("{}条数据,开始存储数据库!", tainWarnList.size());
//        demoDAO.save(list);
//        iTainWarnService.saveBatch(list);//存入数据库iDeviceService.saveBatch(deviceList);iTainWarnService.saveBatch(tainWarnList);LOGGER.info("存储数据库成功!");}/*** 保存提示信息到集合* @param rowIndex 行数* @param desc 提示信息* @param tips 存入集合*/private void saveTips(Integer rowIndex, String desc, List<ImportTips> tips) {ImportTips tip = new ImportTips();tip.setRowNum(rowIndex);tip.setTips(desc);tips.add(tip);}/*** 返回数据* @return 返回提示集合**/public List<ImportTips> getTips() {return tips;}/*** 返回数据* @return 返回读取的数据集合**/public List<WarnVo> getDatas() {return datas;}
}

service层

device_manage略

device_warn

public interface DeviceWarnService extends IService<DeviceWarnEntity> {List<WarnVo> listAllWarn();
}

service_impl层

@Service("DeviceWarnService")
public class DeviceWarnServiceImpl extends ServiceImpl<DeviceWarnDao, DeviceWarnEntity> implements DeviceWarnService {@Autowiredprivate DeviceWarnDao deviceWarnDao;@Overridepublic List<WarnVo> listAllWarn() {QueryWrapper<WarnVo> qw = new QueryWrapper<>();return this.deviceWarnDao.selectWarn(qw);}
}

Dao层,使用@Select注解写入sql语句获得所有信息

@Mapper
public interface DeviceWarnDao extends BaseMapper<DeviceWarnEntity> {@Select("select w.id,d.workshop,d.device_number,d.device_name,d.device_model,w.warn_time,w.expired_time,w.device_status from device_warn w left join device_manage d on d.id=w.device_id where w.is_deleted = 0")List<WarnVo> selectWarn(@Param(Constants.WRAPPER) QueryWrapper<WarnVo> wrapper);
}

前端

<template><div class="mod-config"><!-- 导入导出 --><el-form :inline="true"><el-form-item><el-button type="primary" icon="el-icon-share" @click="download()" >一键导出</el-button></el-form-item><el-form-item><el-uploadstyle="width: 400px"action="http://localhost:8080/wedu/dev/warn/upload":headers="tokenInfo":on-preview="handlePreview":on-remove="handleRemove":before-remove="beforeRemove"multiple:limit="3":on-exceed="handleExceed":file-list="fileList"><el-button type="primary">点击上传</el-button></el-upload></el-form-item></el-form><el-table:data="dataList"borderv-loading="dataListLoading"@selection-change="selectionChangeHandle"style="width: 100%;"><el-table-columnprop="workshop"header-align="center"align="center"label="车间名称"></el-table-column><el-table-columnprop="deviceNumber"header-align="center"align="center"label="设备编号"></el-table-column><el-table-columnprop="deviceName"header-align="center"align="center"label="设备名称"></el-table-column><el-table-columnprop="deviceModel"header-align="center"align="center"label="设备型号"></el-table-column><el-table-columnprop="expiredTime"header-align="center"align="center"label="维保到期时间"></el-table-column><el-table-columnprop="warnTime"header-align="center"align="center"label="维保预警时间"></el-table-column></template><script>export default {data () {return {tokenInfo: {token: this.$cookie.get("token"),},dataForm: {deviceNumber: ''},// 车间字典项allchejian: [],// 车间筛选workshops: [],bydicts: [],byMap: {},fileUploadBtnText: "点击上传", //上传文件提示文字fileList: [], // 上传文件列表fileUploadVisible:false}},activated () {this.getDataList();this.loadAllChejian("workshop");this.getBydicts("deviceModel");},methods: {fileUpload(){this.fileUploadVisible = true;this.$nextTick(() => {this.$refs.FileUpload.init();});},// 文件列表移除文件时的钩子handleRemove(file, fileList) {console.log(file, fileList);},// 点击文件列表中已上传的文件时的钩子handlePreview(file) {console.log(file);},// 限制上传文件的个数和定义超出限制时的行为handleExceed(files, fileList) {this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);},// 文件列表移除文件时之前的钩子beforeRemove(file, fileList) {return this.$confirm(`确定移除 ${file.name}?`);},onUploadExcelError(response) {if (res.code === 500) this.$message.error(res.message);},//文件导出download() {this.$http({url: this.$http.adornUrl("/dev/warn/download"),method: "get",//设置响应类型(重要responseType: "blob",}).then((response) => {// 创建一个url,接收到的二进制数据const url = window.URL.createObjectURL(new Blob([response.data]));// 创建一个a标签,用于触发文件下载const link = document.createElement("a");// a元素的href属性为创建的urllink.href = url;link.setAttribute("download", "保养预警.xlsx");// 将a添加到文档document.body.appendChild(link);// 触发a的点击事件开始下载link.click();});},getWorkshopName(value) {const workshop = this.allchejian.find((item) => item.value === value);return workshop ? workshop.name : "";},getBydicts(code) {this.$http({url: this.$http.adornUrl("/sys/dict/maintenanceList"),method: "get",params: this.$http.adornParams({code: code,}),}).then(({ data }) => {if (data && data.code === 0) {this.bydicts = data.list;this.bydicts.forEach((dict) => {this.$set(this.byMap, dict.value, dict.name);});} else {this.bydicts = [];}});},//加载车间 所需的数据zybloadAllChejian(code) {this.allchejian = [];this.$http({url: this.$http.adornUrl("/sys/dict/maintenanceList"),method: "post",params: this.$http.adornParams({code: code,}),}).then(({ data }) => {if (data && data.code === 0) {this.allchejian = data.list.map((item) => ({name: item.name,value: item.value,}));this.workshop = data.list.map((item) => ({text: item.name,value: item.value,}));} else {}});},// 车间筛选方法 zybfilterHandler(value, row, column) {const property = column["property"];return row[property] === value;}}</script>

最终效果

点击导出

下载的excel表格中车间名称和设备型号有下拉框,对应前端配置的字典类

点击导入

将这个格式的excel导入

在数据库新增一条数据

相关文章:

springboot-vue excel上传导出

数据库 device_manage表 字段&#xff0c;id&#xff0c;workshop,device_number,device_name,device_model,warn_time,expired_time device_warn表 字段&#xff0c;id,warn_time,expired_time 后端 实体类格式 device_manage Data TableName("device_manage"…...

CTF-PWN: ret2libc

plt表与got表是什么? PLT PLT (Procedure Linkage Table) 表在 ELF 文件中的代码段(.text)中,它看起来是这样的: .plt:0x00400530 <__libc_start_mainplt>:jmp QWORD PTR [rip 0x200602] # 0x601608 <__libc_start_maingot.plt>push 0x0jmp 0x4005100…...

SickOs: 1.1靶场学习小记

学习环境 kali攻击机&#xff1a;Get Kali | Kali Linux vulnhub靶场&#xff1a;https://download.vulnhub.com/sickos/sick0s1.1.7z 靶场描述&#xff1a; 这次夺旗赛清晰地模拟了在安全环境下如何对网络实施黑客策略从而入侵网络的过程。这个虚拟机与我在进攻性安全认证专…...

【ArcGIS Pro实操第10期】统计某个shp文件中不同区域内的站点数

统计某个shp文件中不同区域内的站点数 方法 1&#xff1a;使用“空间连接 (Spatial Join)”工具方法 2&#xff1a;使用“点计数 (Point Count)”工具方法 3&#xff1a;通过“选择 (Select by Location)”统计方法 4&#xff1a;通过“Python 脚本 (ArcPy)”实现参考 在 ArcGI…...

JavaScript中类数组对象及其与数组的关系

JavaScript中类数组对象及其与数组的关系 1. 什么是类数组对象&#xff1f; 类数组对象是指那些具有 length 属性且可以通过非负整数索引访问元素的对象。虽然这些对象看起来像数组&#xff0c;但它们并不具备真正数组的所有特性&#xff0c;例如没有继承 Array.prototype 上…...

基础入门-Web应用架构搭建域名源码站库分离MVC模型解析受限对应路径

知识点&#xff1a; 1、基础入门-Web应用-域名上的技术要点 2、基础入门-Web应用-源码上的技术要点 3、基础入门-Web应用-数据上的技术要点 4、基础入门-Web应用-解析上的技术要点 5、基础入门-Web应用-平台上的技术要点 一、演示案例-域名差异-主站&分站&端口站&…...

C#:时间与时间戳的转换

1、将 DateTime 转换为 Unix 时间戳&#xff08;秒&#xff09; public static long DateTimeToUnixTimestamp(DateTime dateTime) {// 定义UTC纪元时间DateTime epochStart new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);// 计算从UTC纪元时间到指定时间的总秒数Tim…...

QT的exec函数

在Qt框架中&#xff0c;exec()方法是QDialog类&#xff08;及其子类&#xff09;的一个成员函数&#xff0c;用于以模态&#xff08;modal&#xff09;方式显示对话框。当exec()被调用时&#xff0c;它会启动一个局部的事件循环&#xff0c;这个循环会阻塞对对话框之外的其他窗…...

Css—实现3D导航栏

一、背景 最近在其他的网页中看到了一个很有趣的3d效果&#xff0c;这个效果就是使用css3中的3D转换实现的&#xff0c;所以今天的内容就是3D的导航栏效果。那么话不多说&#xff0c;直接开始主要内容的讲解。 二、效果展示 三、思路解析 1、首先我们需要将这个导航使用一个大…...

树莓集团:以人工智能为核心,打造数字化生态运营新典范

在当今数字化浪潮席卷全球的背景下&#xff0c;各行各业都在积极探索数字化转型的路径。作为数字产业的领军者&#xff0c;树莓集团凭借其深厚的技术积累和创新理念&#xff0c;在人工智能、大数据、云计算等前沿技术领域不断突破&#xff0c;成功打造了一个以人工智能为核心的…...

2024年首届数证杯 初赛wp

“数证杯”电子数据取证分析大赛致力于成为全国第一大电子数据取证分析大赛&#xff0c;面向所有网络安全从业人员公开征集参赛选手。参赛选手根据所属行业报名参赛赛道&#xff0c;比赛设置冠军、亚军、季军奖。所涉及行业包括能源、金融、通信、取证、安全等企业以及各类司法…...

2017 NHOI小学(C++)

A. 吃西瓜&#xff08;2017 NHOI小学 1&#xff09; 问题描述: 炎热的夏天来的可真快&#xff0c;小花猫和编程兔决定去买一个又大又甜的西瓜。可是小花和编程兔是两只非常奇怪的动物&#xff0c;都是偶数的爱好者&#xff0c;它们希望把西瓜切成两半后&#xff0c;每一部分的…...

【一维DP】【三种解法】力扣983. 最低票价

在一个火车旅行很受欢迎的国度&#xff0c;你提前一年计划了一些火车旅行。在接下来的一年里&#xff0c;你要旅行的日子将以一个名为 days 的数组给出。每一项是一个从 1 到 365 的整数。 火车票有 三种不同的销售方式 &#xff1a; 一张 为期一天 的通行证售价为 costs[0] …...

【头歌实训:递归实现斐波那契数列】

头歌实训&#xff1a;递归实现斐波那契数列 文章目录 任务描述相关知识递归相关知识递归举例何时使用递归定义是递归的数据结构是递归的问题的求解方法是递归的 编程要求测试说明源代码&#xff1a; 任务描述 本关任务&#xff1a;递归求解斐波那契数列。 相关知识 为了完成…...

IntelliJ IDEA配置(mac版本)

用惯了eclipse开发java的小伙伴们&#xff0c;初次接触IntelliJ IDEA可能会和我一样&#xff0c;多少有些不适感&#xff0c;在使用过程中总想着eclipse得对应功能。 接下来&#xff0c;我就总结下我日常开发中遇到的常用配置&#xff08;不包括快捷键&#xff0c;我认为每个人…...

CSAPP Cache Lab(缓存模拟器)

前言 理解高速缓存对 C 程序性能的影响&#xff0c;通过两部分实验达成&#xff1a;编写高速缓存模拟器&#xff1b;优化矩阵转置函数以减少高速缓存未命中次数。Part A一开始根本不知道要做什么&#xff0c;慢慢看官方文档&#xff0c;以及一些博客&#xff0c;和B站视频&…...

【机器学习】机器学习的基本分类-监督学习-逻辑回归-对数似然损失函数(Log-Likelihood Loss Function)

对数似然损失函数&#xff08;Log-Likelihood Loss Function&#xff09; 对数似然损失函数是机器学习和统计学中广泛使用的一种损失函数&#xff0c;特别是在分类问题&#xff08;例如逻辑回归、神经网络&#xff09;中应用最为广泛。它基于最大似然估计原理&#xff0c;通过…...

51c自动驾驶~合集35

我自己的原文哦~ https://blog.51cto.com/whaosoft/12206500 #纯视觉方案的智驾在大雾天还能用吗&#xff1f; 碰上大雾天气&#xff0c;纯视觉方案是如何识别车辆和障碍物的呢&#xff1f; 如果真的是纯纯的&#xff0c;特头铁的那种纯视觉方案的话。 可以简单粗暴的理解为…...

网络安全体系与网络安全模型

4.1 网络安全体系概述 4.1.1 网络安全体系概述 一般面言&#xff0c;网络安全体系是网络安全保障系统的最高层概念抽象&#xff0c;是由各种网络安全单元按照一定的规则组成的&#xff0c;共同实现网络安全的目标。网络安全体系包括法律法规政策文件、安全策略、组织管理、技术…...

antd table 自定义表头过滤表格内容

注意&#xff1a;该功能只能过滤可一次性返回全部数据的表格&#xff0c;通过接口分页查询的请自主按照需求改动哈~ 实现步骤&#xff1a; 1.在要过滤的列表表头增加过滤图标&#xff0c;点击图标显示浮窗 2.浮窗内显示整列可选选项&#xff0c;通过勾选单选或者全选、搜索框来…...

《Qt C++ 与 OpenCV:解锁视频播放程序设计的奥秘》

引言:探索视频播放程序设计之旅 在当今数字化时代,多媒体应用已渗透到我们生活的方方面面,从日常的视频娱乐到专业的视频监控、视频会议系统,视频播放程序作为多媒体应用的核心组成部分,扮演着至关重要的角色。无论是在个人电脑、移动设备还是智能电视等平台上,用户都期望…...

深入浅出:JavaScript 中的 `window.crypto.getRandomValues()` 方法

深入浅出&#xff1a;JavaScript 中的 window.crypto.getRandomValues() 方法 在现代 Web 开发中&#xff0c;随机数的生成看似简单&#xff0c;却隐藏着许多玄机。无论是生成密码、加密密钥&#xff0c;还是创建安全令牌&#xff0c;随机数的质量直接关系到系统的安全性。Jav…...

学校招生小程序源码介绍

基于ThinkPHPFastAdminUniApp开发的学校招生小程序源码&#xff0c;专为学校招生场景量身打造&#xff0c;功能实用且操作便捷。 从技术架构来看&#xff0c;ThinkPHP提供稳定可靠的后台服务&#xff0c;FastAdmin加速开发流程&#xff0c;UniApp则保障小程序在多端有良好的兼…...

Cinnamon修改面板小工具图标

Cinnamon开始菜单-CSDN博客 设置模块都是做好的&#xff0c;比GNOME简单得多&#xff01; 在 applet.js 里增加 const Settings imports.ui.settings;this.settings new Settings.AppletSettings(this, HTYMenusonichy, instance_id); this.settings.bind(menu-icon, menu…...

新能源汽车智慧充电桩管理方案:新能源充电桩散热问题及消防安全监管方案

随着新能源汽车的快速普及&#xff0c;充电桩作为核心配套设施&#xff0c;其安全性与可靠性备受关注。然而&#xff0c;在高温、高负荷运行环境下&#xff0c;充电桩的散热问题与消防安全隐患日益凸显&#xff0c;成为制约行业发展的关键瓶颈。 如何通过智慧化管理手段优化散…...

Ascend NPU上适配Step-Audio模型

1 概述 1.1 简述 Step-Audio 是业界首个集语音理解与生成控制一体化的产品级开源实时语音对话系统&#xff0c;支持多语言对话&#xff08;如 中文&#xff0c;英文&#xff0c;日语&#xff09;&#xff0c;语音情感&#xff08;如 开心&#xff0c;悲伤&#xff09;&#x…...

vulnyx Blogger writeup

信息收集 arp-scan nmap 获取userFlag 上web看看 一个默认的页面&#xff0c;gobuster扫一下目录 可以看到扫出的目录中得到了一个有价值的目录/wordpress&#xff0c;说明目标所使用的cms是wordpress&#xff0c;访问http://192.168.43.213/wordpress/然后查看源码能看到 这…...

打手机检测算法AI智能分析网关V4守护公共/工业/医疗等多场景安全应用

一、方案背景​ 在现代生产与生活场景中&#xff0c;如工厂高危作业区、医院手术室、公共场景等&#xff0c;人员违规打手机的行为潜藏着巨大风险。传统依靠人工巡查的监管方式&#xff0c;存在效率低、覆盖面不足、判断主观性强等问题&#xff0c;难以满足对人员打手机行为精…...

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

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

嵌入式常见 CPU 架构

架构类型架构厂商芯片厂商典型芯片特点与应用场景PICRISC (8/16 位)MicrochipMicrochipPIC16F877A、PIC18F4550简化指令集&#xff0c;单周期执行&#xff1b;低功耗、CIP 独立外设&#xff1b;用于家电、小电机控制、安防面板等嵌入式场景8051CISC (8 位)Intel&#xff08;原始…...