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

【保姆级】Java后端查询数据库结果导出xlsx文件+打印xlsx表格

目录

    • 前言
    • 一、需求一:数据库查询的数据导出成Excel表格
      • 1.1 Vue前端实现导出按钮+点击事件
      • 1.2 后端根据数据库查询结果生成xlsx文件
    • 二、需求二:对生成的xlsx文件调用打印机打印
      • 2.1 Vue前端实现按钮+事件
      • 2.2 后端实现打印

前言

最近在弄一个需求,需求如下:
需求一:Vue前端点击导出按钮,就可以将从数据库查出的数据导出成xlsx,即Excel表格形式
需求二点击打印按钮,要将生成的xlsx文件启动进程,调用打印接口,实现打印,这是为了生成客户订单表,可以让机器直接打印

PS:想吐槽网上很多都复制粘贴的技术文章,找半天一点卵用都没用,这里记录一下自己解决方案,若转发请注明出处,原创不易,有问题可评论区留言

需求一效果预览
在这里插入图片描述
需求二预览
在这里插入图片描述

一、需求一:数据库查询的数据导出成Excel表格

1.1 Vue前端实现导出按钮+点击事件

<el-button type="success" round icon="el-icon-download" @click="exportByEasyPoi">导出</el-button>

对应按钮点击触发的exportByEasyPoi方法,这里我用的是EasyPoi操作Excel,也挺多公司用的
注:前端是Vue2

<script>
import userApi from '@/api/userManage'
export default {methods: {exportByEasyPoi() {userApi.exportByEasyPoi().then(response => {this.$message.success('导出成功')})}}
}
</script>

这里我调用了src/api/userManage.js,这是自己创建的js脚本,调用后端接口的

import request from '@/utils/request'export default {exportByEasyPoi() {return request({url: `/user/exportep`,method: 'get',timeout: '10000'})}
}

需求一前端就这么多了,接下来就是后端

1.2 后端根据数据库查询结果生成xlsx文件

首先导入EasyPoi相关依赖

<!--easypoi-->
<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId><version>4.3.0</version>
</dependency>
<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-base</artifactId><version>4.3.0</version>
</dependency>
<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-web</artifactId><version>4.3.0</version>
</dependency>
<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-annotation</artifactId><version>4.3.0</version>
</dependency>
<!-- lombok -->
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.20</version>
</dependency>

下面先给出后端核心逻辑代码,后面会具体讲解,这里就不加篇幅,直接把逻辑代码写在Controller层,原本应该写在Service层,即xxxServiceImpl实现类中,这里为了方便,直接这么写下。

@Autowired
private IUserService userService;@GetMapping("/exportep")public Result<?> exportByEasyPoi(HttpServletResponse response) throws IOException {// mybatisplus实现的list(),拿到用户信息列表List<User> users = userService.list();List<ExcelUserVo> excelUserVos = BeanCopyUtils.copyBeanList(users, ExcelUserVo.class);// easypoi导出ExportParams params = new ExportParams();params.setTitle("测试");// 表格左下角的sheet名称params.setSheetName("用户信息");Workbook workbook = ExcelExportUtil.exportExcel(params, ExcelUserVo.class, excelUserVos);// 判断文件路径是否存在,并将信息写入文件try{// 文件夹是否存在,若没有对应文件夹直接根据路径生成文件会报错File folder = new File(Constants.XLSX_DIR);if (!folder.exists() && !folder.isDirectory()) {folder.mkdirs();}// 文件是否存在File file = new File(Constants.XLSX_DIR + "\\" + Constants.XLSX_NAME);if (!file.exists()){file.createNewFile();}// 输出流写入FileOutputStream outputStream = new FileOutputStream(Constants.XLSX_DIR + "\\" + Constants.XLSX_NAME);workbook.write(outputStream);// 关闭写,不然用户点击生成的文件会显示只读outputStream.close();workbook.close();}catch (IOException e){e.printStackTrace();}return Result.success("导出成功");}

ExcelUserVo.java是自己需要显示在表格中的列,就是我们查询用户表,大部分时候不需要展示所有的属性到前端,挑需要显示的,所以封装成xxxVo,比如密码、创建时间、备注可以不显示在前端,不用打印就不要。

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;import java.io.Serializable;@Data
@NoArgsConstructor
@AllArgsConstructor
@ExcelTarget("sys_user")
public class ExcelUserVo implements Serializable {@Excel(name = "用户id", width = 10)
//    @ExcelIgnore // 表示忽略, 不在表格生成private Integer id;@Excel(name = "用户名", width = 20)private String username;@Excel(name = "邮箱", width = 30)private String email;@Excel(name = "电话", width = 30)private String phone;@Excel(name = "状态(1:正常,0:禁用)", width = 10)private Integer status;
}

BeanCopyUtils.java是常用工具类,可以实现对象的拷贝,将两个对象中相同属性字段拷贝

import java.util.List;
import java.util.stream.Collectors;public class BeanCopyUtils {private BeanCopyUtils() {}/** 单个对象*/public static <V> V copyBean(Object source, Class<V> clazz) {/** 创建目标对象 实现属性拷贝*/V result = null;try {result = clazz.newInstance();/** 拷贝*/BeanUtils.copyProperties(source, result);} catch (Exception e) {e.printStackTrace();}return result;}/** 集合*/public static <O, V> List<V> copyBeanList(List<O> list, Class<V> clazz) {/** 创建目标对象 实现属性拷贝*/return list.stream().map(o -> copyBean(o, clazz)).collect(Collectors.toList());}
}

自定义常量Constants.java,这里主要是定义输出路径

public class Constants {// excel表public static final String XLSX_DIR = "D:\\study\\excel";public static final String XLSX_NAME = "easypoi.xlsx";}

数据库sys_user表结构

DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(50) NOT NULL,`password` varchar(100) DEFAULT NULL,`email` varchar(50) DEFAULT NULL,`phone` varchar(20) DEFAULT NULL,`status` int(1) DEFAULT NULL,`avatar` varchar(200) DEFAULT NULL,`deleted` int(1) DEFAULT '0',PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

二、需求二:对生成的xlsx文件调用打印机打印

2.1 Vue前端实现按钮+事件

<el-button type="warning" round icon="el-icon-printer" @click="printExcel">打印</el-button>
methods: {printExcel() {userApi.printTable().then(response => {this.$message.success('请求打印成功')})}
}

userManage.js中再写一个调用后端接口的

export default {printTable() {return request({url: `/user/print`,method: 'get',timeout: '100000'})}
}

2.2 后端实现打印

这里也干脆实现逻辑不写在Service层了,省点字,实际开发中还是要遵循规范哈

@GetMapping("/print")
public Result<?> printInfo(){try {String filepath = Constants.XLSX_DIR + "\\" + Constants.XLSX_NAME;PrintUtil.print(filepath);} catch (Exception e) {e.printStackTrace();}return Result.success();
}

核心打印工具PrintUtil.java,这个java文件稍微有点长

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;import javax.imageio.ImageIO;
import javax.print.*;
import javax.print.attribute.DocAttributeSet;
import javax.print.attribute.HashDocAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.standard.OrientationRequested;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;public class PrintUtil {/*** 竖屏模式*/public static OrientationRequested PORTRAIT = OrientationRequested.PORTRAIT;/*** 横屏模式*/public static OrientationRequested LANDSCAPE = OrientationRequested.LANDSCAPE;/*** 获取全部打印设备信息* @return 返回全部能用的打印服务的List*/public static List<PrintService> getDeviceList() {// 构建打印请求属性集HashPrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();// 设置打印格式,因为未确定类型,所以选择autosenseDocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;// 查找所有的可用的打印服务PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);List<PrintService> list = Arrays.asList(printService);return list;}/*** 根据文件类型不同调用不同代码去打印* @param filePath 文件路径*/public static void print(String filePath) throws Exception {PrintService printService = PrintServiceLookup.lookupDefaultPrintService();String defaultDeviceName = printService.getName();print(filePath, defaultDeviceName);}/*** 额外传入一个 AfterPrint,会在打印完成后调用 afterPrint.run()* @param filePath* @param afterPrint* @throws Exception*/public static void print(String filePath, AfterPrint afterPrint) throws Exception {print(filePath);afterPrint.run();}/*** 根据文件类型不同调用不同代码去打印* @param filePath 文件路径* @param deviceName 设备名称,传入哪个设备的名称,就让哪个设备去打印*/public static void print(String filePath, String deviceName) throws Exception{List<PrintService> list = getDeviceList();PrintService printService = null;for (PrintService p : list) {if(p.getName().equals(deviceName)) {printService = p;break;}}if(printService == null) {throw new Exception("Device not found");}String type = filePath.replaceAll(".*\\.","");if("jpg".equalsIgnoreCase(type)) {normalPrint(new File(filePath), DocFlavor.INPUT_STREAM.JPEG, printService);return;}if("jpeg".equalsIgnoreCase(type)) {normalPrint(new File(filePath), DocFlavor.INPUT_STREAM.JPEG, printService);return;}if("gif".equalsIgnoreCase(type)) {normalPrint(new File(filePath), DocFlavor.INPUT_STREAM.GIF, printService);return;}if("pdf".equalsIgnoreCase(type)) {printPDF(new File(filePath), DocFlavor.INPUT_STREAM.PNG, printService);return;}if("png".equalsIgnoreCase(type)) {normalPrint(new File(filePath), DocFlavor.INPUT_STREAM.PNG, printService);return;}if("doc".equalsIgnoreCase(type)) {printWord(filePath, deviceName);return;}if("docx".equalsIgnoreCase(type)) {printWord(filePath, deviceName);return;}if("xls".equalsIgnoreCase(type)) {printExcel(filePath, deviceName);return;}if("xlsx".equalsIgnoreCase(type)) {printExcel(filePath, deviceName);return;}if("ppt".equalsIgnoreCase(type)) {printPPT(filePath, deviceName);return;}if("pptx".equalsIgnoreCase(type)) {printPPT(filePath, deviceName);return;}}/*** 会在打印完成后调用 afterPrint.run()* @param filePath* @param deviceName* @param afterPrint* @throws Exception*/public static void print(String filePath, String deviceName, AfterPrint afterPrint) throws Exception{print(filePath, deviceName);afterPrint.run();}/*** javase的打印机打印文件,支持jpg,png,gif,pdf等等* @param file 要打印的文件* @param flavor 打印格式*/private static void normalPrint(File file, DocFlavor flavor) {// 定位默认的打印服务PrintService service = PrintServiceLookup.lookupDefaultPrintService();             // 显示打印对话框normalPrint(file, flavor, service);}private static void normalPrint(File file, DocFlavor flavor, PrintService service) {normalPrint(file, flavor, PORTRAIT, service);}/*** javase的打印机打印文件,支持jpg,png,gif等等* @param file 要打印的文件* @param service 打印机选择* @param requested 设定横屏还是竖屏* @param flavor 打印格式*/private static void normalPrint(File file, DocFlavor flavor, OrientationRequested requested, PrintService service) {// 构建打印请求属性集HashPrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();pras.add(requested);if (service != null) {try {DocPrintJob job = service.createPrintJob(); // 创建打印作业FileInputStream fis = new FileInputStream(file); // 构造待打印的文件流DocAttributeSet das = new HashDocAttributeSet();Doc doc = new SimpleDoc(fis, flavor, das);job.print(doc, pras);} catch (Exception e) {e.printStackTrace();}}}/*** 打印pdf的方法,因为java内置的打印pdf的方法有病,所以首先需要把pdf转换成png,然后打印png* @param file 要打印的文件* @param flavor 要打印的文件* @param service 打印设备*/private static void printPDF(File file, DocFlavor flavor, PrintService service) {try {PDDocument doc = PDDocument.load(file);PDFRenderer renderer = new PDFRenderer(doc);int pageCount = doc.getNumberOfPages();for(int i=0;i<pageCount;i++){File f = new File(file.getParent() + File.separator + "temp_" + i + ".png");BufferedImage image = renderer.renderImageWithDPI(i, 96);ImageIO.write(image, "PNG", f);normalPrint(f, flavor, LANDSCAPE, service);f.delete();}} catch (IOException e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace();}}/*** 打印机打印Word* @param filepath 打印文件路径* @param deviceName 传入哪个设备名称,用哪个设备打印*/private static void printWord(String filepath, String deviceName) {if(filepath.isEmpty()){return;}ComThread.InitSTA();//使用Jacob创建 ActiveX部件对象:ActiveXComponent word=new ActiveXComponent("Word.Application");//打开Word文档Dispatch doc=null;Dispatch.put(word, "Visible", new Variant(false));word.setProperty("ActivePrinter", new Variant(deviceName));Dispatch docs=word.getProperty("Documents").toDispatch();doc=Dispatch.call(docs, "Open", filepath).toDispatch();try {Dispatch.call(doc, "PrintOut");//打印} catch (Exception e) {e.printStackTrace();}finally{try {if(doc!=null){//关闭文档Dispatch.call(doc, "Close",new Variant(0));}} catch (Exception e2) {e2.printStackTrace();}word.invoke("Quit", new Variant[] {});//关闭进程//释放资源ComThread.Release();}}/*** 打印Excel* @param filePath 打印文件路径,形如 E:\\temp\\tempfile\\1494607000581.xls* @param deviceName 传入哪个设备名称,用哪个设备打印*/private static void printExcel(String filePath, String deviceName){if(filePath.isEmpty()){return;}ComThread.InitSTA();ActiveXComponent xl=new ActiveXComponent("Excel.Application");try {Dispatch.put(xl, "Visible", new Variant(true));Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();Dispatch excel=Dispatch.call(workbooks, "Open", filePath).toDispatch();Dispatch.callN(excel,"PrintOut",new Object[]{Variant.VT_MISSING, Variant.VT_MISSING, new Integer(1),new Boolean(false), deviceName, new Boolean(true),Variant.VT_MISSING, ""});Dispatch.call(excel, "Close", new Variant(false));} catch (Exception e) {e.printStackTrace();} finally{xl.invoke("Quit",new Variant[0]);ComThread.Release();}}/*** 打印PPT* @param filePath* @param deviceName*/private static void printPPT(String filePath, String deviceName) {File file = new File(filePath);File pdfFile = new File(file.getParentFile().getAbsolutePath() + file.getName() + ".pdf");ActiveXComponent app = null;Dispatch ppt = null;try {ComThread.InitSTA();app = new ActiveXComponent("PowerPoint.Application");Dispatch ppts = app.getProperty("Presentations").toDispatch();ppt = Dispatch.call(ppts, "Open", filePath, true, true, false).toDispatch();Dispatch.call(ppt, "SaveAs", pdfFile.getAbsolutePath(), 32);} catch (Exception e) {e.printStackTrace();throw e;} finally {if (ppt != null) {Dispatch.call(ppt, "Close");}if (app != null) {app.invoke("Quit");}ComThread.Release();}try {print(pdfFile.getAbsolutePath(), deviceName);pdfFile.delete();} catch (Exception e) {e.printStackTrace();}}/*** 接口,在打印结束后调用*/public interface AfterPrint {void run();}
}

PrintUtil.java中依赖两个打印需要的非常重要包,jacob和pdfbox,下面给出免费链接,阿里云盘不限速的
链接:Java打印相关依赖包

下载后,需要导入一下,也十分简单,如图
在这里插入图片描述
然后运行后端,点击按钮就会有对应效果了,如果你没有打印机,会弹出生成PDF,有打印机连着,会使用默认打印机,或者通过PrintUtil中方法自定义打印机名称,选择打印机打印

以上就是全部内容,过程有啥问题可以评论区和大家一起交流!

相关文章:

【保姆级】Java后端查询数据库结果导出xlsx文件+打印xlsx表格

目录前言一、需求一&#xff1a;数据库查询的数据导出成Excel表格1.1 Vue前端实现导出按钮点击事件1.2 后端根据数据库查询结果生成xlsx文件二、需求二&#xff1a;对生成的xlsx文件调用打印机打印2.1 Vue前端实现按钮事件2.2 后端实现打印前言 最近在弄一个需求&#xff0c;需…...

Java数据库部分(MySQL+JDBC)(二、JDBC超详细学习笔记)

文章目录1 JDBC&#xff08;Java Database Connectivity&#xff09;1.1 什么是 JDBC&#xff1f;1.2 JDBC 核心思想2 JDBC开发步骤【重点】2.0 环境准备2.1 注册数据库驱动2.2 获取数据库的连接2.3 获取数据库操作对象Statement2.4 通过Statement对象执行SQL语句2.5 处理返回结…...

vue3生命周期

一、Vue3中的生命周期 1、setup() : 开始创建组件之前&#xff0c;在 beforeCreate 和 created 之前执行&#xff0c;创建的是 data 和 method 2、onBeforeMount() : 组件挂载到节点上之前执行的函数&#xff1b; 3、onMounted() : 组件挂载完成后执行的函数&#xff1b; 4、…...

Python学习笔记10:开箱即用

开箱即用 模块 python系统路径 import sys, pprint pprint.pprint(sys.path) [,D:\\Program Files\\Python\\Lib\\idlelib,D:\\Program Files\\Python\\python310.zip,D:\\Program Files\\Python\\DLLs,D:\\Program Files\\Python\\lib,D:\\Program Files\\Python,D:\\Progr…...

详解JAVA反射

目录 1.概述 2.获取Class对象 3.API 3.1.实例化对象 3.2.方法 3.3.属性 1.概述 反射&#xff0c;JAVA提供的一种在运行时获取类的信息并动态操作类的能力。JAVA反射允许我们在运行时获取类的属性、方法、构造函数等信息&#xff0c;并能够动态地操作它们。 2.获取Class…...

在nestjs中进行typeorm cli迁移(migration)的配置

在nestjs中进行typeorm cli迁移(migration)的配置 在学习nestjs过程中发现typeorm的迁移配置十分麻烦,似乎许多方法都是旧版本的配置&#xff0c;无法直接使用. 花了挺长时间总算解决了这个配置问题. db.config.ts 先创建db.config.ts, 该文件export了两个对象&#xff0c;其…...

前端工程构建问题汇总

1.less less-loader安装失败问题 npm install less-loader --save --legacy-peer-deps 加上–legacy-peer-deps就可以了 在NPM v7中&#xff0c;现在默认安装peerDependencies&#xff0c;这会导致版本冲突&#xff0c;从而中断安装过程。 –legacy-peer-deps标志是在v7中引…...

某马程序员NodeJS速学笔记

文章目录前言一、什么是Node.js?二、fs文件系统模块三、Http模块四、模块化五、开发属于自己的包模块加载机制六、Express1.初识ExpressGET/POSTnodemon2.路由模块化3.中间件中间件分类自定义中间件4. 跨域问题七、Mysql模块安装与配置基本使用Web开发模式Session认证JWT八、m…...

SpringMVC DispatcherServlet源码(6) 完结 静态资源原理

阅读源码&#xff0c;分析静态资源处理器相关组件&#xff1a; 使用SimpleUrlHandlerMapping管理url -> 处理器映射关系spring mvc使用WebMvcConfigurationSupport注入SimpleUrlHandlerMapping组件DelegatingWebMvcConfiguration可以使用WebMvcConfigurer的配置静态资源url…...

2023年全国最新会计专业技术资格精选真题及答案9

百分百题库提供会计专业技术资格考试试题、会计考试预测题、会计专业技术资格考试真题、会计证考试题库等&#xff0c;提供在线做题刷题&#xff0c;在线模拟考试&#xff0c;助你考试轻松过关。 四、材料题 1.某企业为增值税一般纳税人&#xff0c;2019年12月初“应付职工薪酬…...

Web3中文|把Web3装进口袋,Solana手机Saga有何魔力?

2月23日&#xff0c;Solana Web3手机Saga发布新的消息&#xff0c;将推出NFT铸造应用程序Minty Fresh。在Minty Fresh&#xff0c;用户仅需轻点并完成拍摄&#xff0c;就可以直接在手机中进行NFT铸造&#xff0c;并在几秒钟内将其转换为链上NFT&#xff0c;NFT还可以发布在 Ins…...

【配电网优化】基于串行和并行ADMM算法的配电网优化研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...

数据结构初阶 -- 顺序表

数据结构初阶 链表的讲解 目录 一. 线性表 1.1 定义 1.2 特点 二. 顺序表 2.1 定义 2.2 代码 2.3 功能需求 2.4 静态顺序表的特点以及缺点 2.5 动态的顺序表 2.6 动态顺序表接口的实现 三. 代码 头文件 主文件 一. 线性表 1.1 定义 线性表&#xff08;linear li…...

uniapp:3分钟搞定在线推送uni.createPushMessage,uni.onPushMessage

安卓端 在线推送功能演示&#xff1a; 1、dcloud后台申请开通uniPush dcloud后台 &#xff08;1&#xff09;&#xff1a;找到我的应用 &#xff08;2&#xff09;&#xff1a;点进去后&#xff0c;各平台信息&#xff0c;点击新增 &#xff08;3&#xff09;&#xff1a;填…...

C/C++开发,无可避免的多线程(篇一).跨平台并行编程姗姗来迟

一、编译环境准备 在正式进入c/c多线程编程系列之前&#xff0c;先来搭建支持多线程编译的编译环境。 1.1 MinGW&#xff08;win&#xff09; 进入Downloads - MinGW-w64下载页面&#xff0c;选择MinGW-w64-builds跳转下载&#xff0c; 再次进行跳转&#xff1a; 然后进入下载页…...

如何把照片的底色修改为想要的颜色

如何给照片更换底色&#xff1f;其实有可以一键给照片更换底色的 APP &#xff0c;但是几乎都要收费。如果想要免费的给照片更换底色的话&#xff0c;分享两种简单便捷的方法给你。掌握了这项技能&#xff0c;以后就不用店花钱处理啦&#xff01;1、免费&#xff01;线上快速 给…...

【高效办公】批量生成固定模板的文件夹名称

老师让你按照他的要求生成每位学生的文件夹,你是学委,让你马上完成该任务,但你又不想是手动一个一个码字,因此聪明的你就看到了本篇文章啦!!! 虽说一个人懒惰,并不是好的事情。 但这个似乎合情合理啊~ 然后,就动手想办法,一开始就真的打算码字了。。 思路 在实际开…...

redis的集群方式

1.主从复制 主从复制原理&#xff1a; 从服务器连接主服务器&#xff0c;发送SYNC命令&#xff1b; 主服务器接收到SYNC命名后&#xff0c;开始执行BGSAVE命令生成RDB文件并使用缓冲区记录此后执行的所有写命令&#xff1b; 主服务器BGSAVE执行完后&#xff0c;向所有从服务…...

温控负荷的需求响应潜力评估及其协同优化管理研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...

模电学习9. MOS管使用入门

模电学习9. MOS管使用入门一、mos管理简介1. 简介2. mos管理的特点3. MOS管的工作状态&#xff08;1&#xff09;放大功能&#xff08;2&#xff09;截止区&#xff08;3&#xff09;饱和区3. Mos管的分类&#xff08;1&#xff09;按照工作模式分类&#xff1a;&#xff08;2&…...

测试微信模版消息推送

进入“开发接口管理”--“公众平台测试账号”&#xff0c;无需申请公众账号、可在测试账号中体验并测试微信公众平台所有高级接口。 获取access_token: 自定义模版消息&#xff1a; 关注测试号&#xff1a;扫二维码关注测试号。 发送模版消息&#xff1a; import requests da…...

[2025CVPR]DeepVideo-R1:基于难度感知回归GRPO的视频强化微调框架详解

突破视频大语言模型推理瓶颈,在多个视频基准上实现SOTA性能 一、核心问题与创新亮点 1.1 GRPO在视频任务中的两大挑战 ​安全措施依赖问题​ GRPO使用min和clip函数限制策略更新幅度,导致: 梯度抑制:当新旧策略差异过大时梯度消失收敛困难:策略无法充分优化# 传统GRPO的梯…...

Golang dig框架与GraphQL的完美结合

将 Go 的 Dig 依赖注入框架与 GraphQL 结合使用&#xff0c;可以显著提升应用程序的可维护性、可测试性以及灵活性。 Dig 是一个强大的依赖注入容器&#xff0c;能够帮助开发者更好地管理复杂的依赖关系&#xff0c;而 GraphQL 则是一种用于 API 的查询语言&#xff0c;能够提…...

工程地质软件市场:发展现状、趋势与策略建议

一、引言 在工程建设领域&#xff0c;准确把握地质条件是确保项目顺利推进和安全运营的关键。工程地质软件作为处理、分析、模拟和展示工程地质数据的重要工具&#xff0c;正发挥着日益重要的作用。它凭借强大的数据处理能力、三维建模功能、空间分析工具和可视化展示手段&…...

oracle与MySQL数据库之间数据同步的技术要点

Oracle与MySQL数据库之间的数据同步是一个涉及多个技术要点的复杂任务。由于Oracle和MySQL的架构差异&#xff0c;它们的数据同步要求既要保持数据的准确性和一致性&#xff0c;又要处理好性能问题。以下是一些主要的技术要点&#xff1a; 数据结构差异 数据类型差异&#xff…...

OPenCV CUDA模块图像处理-----对图像执行 均值漂移滤波(Mean Shift Filtering)函数meanShiftFiltering()

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 在 GPU 上对图像执行 均值漂移滤波&#xff08;Mean Shift Filtering&#xff09;&#xff0c;用于图像分割或平滑处理。 该函数将输入图像中的…...

MySQL 8.0 事务全面讲解

以下是一个结合两次回答的 MySQL 8.0 事务全面讲解&#xff0c;涵盖了事务的核心概念、操作示例、失败回滚、隔离级别、事务性 DDL 和 XA 事务等内容&#xff0c;并修正了查看隔离级别的命令。 MySQL 8.0 事务全面讲解 一、事务的核心概念&#xff08;ACID&#xff09; 事务是…...

Golang——6、指针和结构体

指针和结构体 1、指针1.1、指针地址和指针类型1.2、指针取值1.3、new和make 2、结构体2.1、type关键字的使用2.2、结构体的定义和初始化2.3、结构体方法和接收者2.4、给任意类型添加方法2.5、结构体的匿名字段2.6、嵌套结构体2.7、嵌套匿名结构体2.8、结构体的继承 3、结构体与…...

tomcat入门

1 tomcat 是什么 apache开发的web服务器可以为java web程序提供运行环境tomcat是一款高效&#xff0c;稳定&#xff0c;易于使用的web服务器tomcathttp服务器Servlet服务器 2 tomcat 目录介绍 -bin #存放tomcat的脚本 -conf #存放tomcat的配置文件 ---catalina.policy #to…...

elementUI点击浏览table所选行数据查看文档

项目场景&#xff1a; table按照要求特定的数据变成按钮可以点击 解决方案&#xff1a; <el-table-columnprop"mlname"label"名称"align"center"width"180"><template slot-scope"scope"><el-buttonv-if&qu…...