基于hiprint的票据定位打印系统开发实践

基于hiprint的票据定位打印系统开发实践

在日常的Web开发中,我们经常需要实现打印功能,特别是对于票据、标签等需要精确排版的打印需求。今天我将分享一个基于hiprint插件实现的票据定位打印系统,重点介绍如何实现单行打印、批量打印以及金额数据动态绑定等功能。

项目背景

传统的网页打印往往难以控制精确的布局和格式,特别是对于发票、收据等需要固定格式的票据打印。hiprint 是一个专门用于解决这类问题的JavaScript打印插件,它提供了可视化设计工具和丰富的API,可以轻松实现精确定位打印。

核心功能实现

1. 页面结构设计

首先,我们构建了一个包含票据列表和操作按钮的页面结构:

<table class="table table-bordered" style="margin-top: 20px;"><thead><tr><th>发票编号</th><th>开票日期</th><th>客户名称</th><th>金额</th><th>操作</th></tr></thead><tbody><tr><td>INV-001</td><td>2023-10-01</td><td>某某公司</td><td>¥1085.00</td><td><a class="btn hiprint-toolbar-item bill-action"data-action="preview" data-index="1">快速预览</a><a class="btn hiprint-toolbar-item bill-action"data-action="print" data-index="1">打印</a></td></tr><tr><td>INV-001</td><td>2023-10-01</td><td>某某公司</td><td>¥985.00</td><td><a class="btn hiprint-toolbar-item bill-action"data-action="preview" data-index="2">快速预览</a><a class="btn hiprint-toolbar-item bill-action"data-action="print" data-index="2">打印</a></td></tr></tbody>
</table>

在这里插入图片描述

2. 模板外部化管理

为了提高代码的可维护性,我们将打印模板存储在独立的JSON文件中:
下例为简单表格的模板(发票的模板此处不展示,请见hiprint资源)

{"panels": [{"index": 0,"height": 210,"width": 297,"paperHeader": 10,"paperFooter": 380,"printElements": [{"options": {"left": 20,"top": 20,"width": 250,"height": 120,"content": "<table border='1' style='width:100%;border-collapse:collapse;text-align:center;'><tr><th>序号</th><th>姓名</th><th>成绩</th></tr><tr><td>1</td><td>张三</td><td>90</td></tr><tr><td>2</td><td>李四</td><td>85</td></tr><tr><td>3</td><td>王五</td><td>88</td></tr></table>"},"printElementType": {"title": "表格","type": "table"}}],"paperNumberDisabled": true}]
}
// 从外部JSON文件加载模板
$.getJSON('custom_test/bill-template.json', function (templateData) {hiprintTemplate_bill = new hiprint.PrintTemplate({template: templateData,settingContainer: '#PrintElementOptionSetting'});
});

这样做的好处是:

  • 模板与代码分离,便于维护
  • 可以在多个页面中复用同一模板
  • 支持非技术人员通过可视化工具调整模板

3. 单行打印功能

实现单行打印的关键在于从当前行提取金额数据并传递给打印函数:

// 动态绑定事件
$(document).on('click', '.bill-action', function () {const action = $(this).data('action'); // 获取操作类型const index = $(this).data('index');   // 获取索引// 获取当前行的金额const amountText = $(this).closest('tr').find('td:eq(3)').text();const amount = parseFloat(amountText.replace(/[¥,]/g, '')); // 去除¥符号和逗号,转换为数字handleBillAction(action, index, amount);
});// 处理预览和打印逻辑
function handleBillAction(action, index, amount) {// 创建当前行的数据对象const rowData = {index: index,totalAmount: amount};if (action === 'preview') {$('#myModal .modal-body .prevViewDiv').html(hiprintTemplate_bill.getHtml(rowData));$('#myModal').modal('show');} else if (action === 'print') {if (hiprintTemplate_bill) {hiprintTemplate_bill.print([rowData]);}}
}

4. 批量打印功能

批量打印功能会遍历表格所有行,提取每行的金额数据:

$('#batchPrint').click(function () {const printData = [];$('.table tbody tr').each(function(index) {const amountText = $(this).find('td:eq(3)').text(); // 获取金额列文本const amount = parseFloat(amountText.replace(/[¥,]/g, '')); // 去除¥符号和逗号,转换为数字printData.push({ totalAmount: amount,index: index + 1});});if (hiprintTemplate_bill) {hiprintTemplate_bill.print(printData);}
});

多个发票批量打印:
多个发票批量打印
单个发票打印:
单个发票打印

技术要点解析

数据提取与处理

在实现过程中,我们需要注意金额数据的提取和格式化:

const amountText = $(this).closest('tr').find('td:eq(3)').text();
const amount = parseFloat(amountText.replace(/[¥,]/g, ''));

这行代码完成了以下工作:

  1. 定位到当前行的金额列(第4列,索引为3)
  2. 提取文本内容
  3. 使用正则表达式去除货币符号和千位分隔符
  4. 转换为浮点数便于后续处理

总结

通过这个项目,我们实现了以下功能:

  1. 可视化模板设计:使用外部JSON文件管理打印模板
  2. 单行精确打印:每个打印按钮绑定对应行的数据
  3. 批量处理能力:支持一次性打印所有票据
  4. 数据动态绑定:自动从表格中提取金额等关键信息

这个系统可以广泛应用于各种票据打印场景,如发票、收据、标签等,为Web应用提供了专业级的打印解决方案。通过合理的设计和实现,我们不仅提高了开发效率,也增强了系统的可维护性和扩展性。

— by agi

附录:
(1)temp.json

{"panels": [{"index": 0,"height": 148,"width": 210,"paperHeader": -1.5,"paperFooter": 380,"printElements": [{"options": {"left": 540,"top": 10.5,"height": 35,"width": 33,"borderColor": "#f20000"},"printElementType": {"title": "椭圆","type": "oval"}},{"options": {"left": 454.5,"top": 15,"height": 18,"width": 74,"title": "8888888","fontSize": 18,"fontWeight": "600","color": "#2935e3","textAlign": "center","lineHeight": 16},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 424.5,"top": 15,"height": 19,"width": 24,"title": "NO","fontSize": 18,"color": "#2935e3","textAlign": "center","lineHeight": 15},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 190.5,"top": 15,"height": 21,"width": 226,"title": "上海增值税普通发票","fontSize": 18,"fontWeight": "600","letterSpacing": 2.5,"color": "#cc5a5a","textAlign": "center","lineHeight": 18},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 244.5,"top": 19.5,"height": 51,"width": 112,"borderColor": "#eb1111","borderWidth": "2"},"printElementType": {"title": "椭圆","type": "oval"}},{"options": {"left": 90,"top": 19.5,"height": 21,"width": 96,"title": "8888888","fontSize": 19,"letterSpacing": 1,"color": "#2935e3","textAlign": "center","lineHeight": 18},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 19.5,"top": 19.5,"height": 61,"width": 65,"title": "031001800204","textType": "qrcode"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 250.5,"top": 25.5,"height": 42,"width": 104,"borderColor": "#f00505"},"printElementType": {"title": "椭圆","type": "oval"}},{"options": {"left": 190.5,"top": 45,"height": 10,"width": 228,"borderColor": "#b5a8a8"},"printElementType": {"title": "横线","type": "hline"}},{"options": {"left": 190.5,"top": 49.5,"height": 10,"width": 228,"borderColor": "#baafaf"},"printElementType": {"title": "横线","type": "hline"}},{"options": {"left": 244.5,"top": 55.5,"height": 22,"width": 120,"title": "发票联","fontSize": 18,"fontWeight": "600","letterSpacing": 8,"color": "#cc5a5a","textAlign": "center","lineHeight": 18},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 510,"top": 55.5,"height": 13,"width": 69,"title": "2019年05月09日","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 445.5,"top": 55.5,"height": 15,"width": 57,"title": "开票日期:","color": "#cc5a5a","lineHeight": 13},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 90,"top": 64.5,"height": 15,"width": 141,"title": "校验码:123456 788942 52344","color": "#2935e3","textAlign": "center","lineHeight": 13},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 400,"top": 90,"height": 60,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 35,"top": 90,"height": 60,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 420,"top": 90,"height": 61,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 10.5,"top": 90,"height": 282,"width": 572,"borderColor": "#cc5a5a"},"printElementType": {"title": "矩形","type": "rect"}},{"options": {"left": 405,"top": 94.5,"height": 55,"width": 13,"title": "密码区","fontSize": 13,"color": "#cc5a5a","lineHeight": 18},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 424.5,"top": 94.5,"height": 50,"width": 152,"title": "","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 15,"top": 94.5,"height": 53,"width": 15,"title": "购买方","fontSize": 13,"color": "#cc5a5a","lineHeight": 18},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 45,"top": 100.5,"height": 10,"width": 348,"title": "名称:北京地铁税务局有限公司","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 45,"top": 115.5,"height": 10,"width": 347,"title": "纳税人识别号:999999999999999999","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 45,"top": 130.5,"height": 10,"width": 347,"title": "地址、电话:18888888888","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 345,"top": 150,"height": 190,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 409.5,"top": 150,"height": 190,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 295.5,"top": 150,"height": 190,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 480,"top": 150,"height": 190,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 215,"top": 150,"height": 224,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 520.5,"top": 150,"height": 190,"width": 10,"borderColor": "#cc5a5a"},"printElementType": {"title": "竖线","type": "vline"}},{"options": {"left": 10,"top": 150,"height": 10,"width": 574,"borderColor": "#cc5a5a"},"printElementType": {"title": "横线","type": "hline"}},{"options": {"left": 300,"top": 160.5,"height": 10,"width": 36,"title": "单位","fontSize": 13,"color": "#cc5a5a","textAlign": "center"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 349.5,"top": 160.5,"height": 11,"width": 51,"title": "数量","fontSize": 13,"color": "#cc5a5a","textAlign": "center"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 225,"top": 160.5,"height": 10,"width": 62,"title": "规格名称","fontSize": 13,"color": "#cc5a5a","textAlign": "center"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 420,"top": 160.5,"height": 10,"width": 53,"title": "单价","fontSize": 13,"color": "#cc5a5a","textAlign": "center"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 484.5,"top": 160.5,"height": 10,"width": 32,"title": "税率","fontSize": 13,"color": "#cc5a5a","textAlign": "center"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 525,"top": 160.5,"height": 10,"width": 52,"title": "税额","fontSize": 13,"color": "#cc5a5a","textAlign": "center"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 19.5,"top": 160.5,"height": 10,"width": 184,"title": "货物或应税劳务、服务名称","fontSize": 13,"color": "#cc5a5a","textAlign": "center"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 40.5,"top": 175.5,"height": 12,"width": 120,"title": "*餐饮服务*餐费","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 10.5,"top": 340.5,"height": 10,"width": 574,"borderColor": "#cc5a5a"},"printElementType": {"title": "横线","type": "hline"}},{"options": {"left": 225,"top": 349.5,"height": 14,"width": 229,"title": "壹佰贰拾元整","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 460.5,"top": 349.5,"height": 13,"width": 58,"title": "(小写)","fontSize": 13,"color": "#cc5a5a"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 520.5,"top": 349.5,"height": 13,"width": 48,"field": "totalAmount","color": "#2935e3"},"printElementType": {"title": "¥","type": "text"}},{"options": {"left": 15,"top": 349.5,"height": 14,"width": 193,"title": "价税合计(大写)","fontSize": 13,"color": "#cc5a5a","textAlign": "center"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 300,"top": 385.5,"height": 10,"width": 39,"title": "开票人:","color": "#cc5a5a"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 190.5,"top": 385.5,"height": 10,"width": 103,"title": "轩大可","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 150,"top": 385.5,"height": 10,"width": 33,"title": "复核:","color": "#cc5a5a"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 345,"top": 385.5,"height": 10,"width": 86,"title": "张天天","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 64.5,"top": 385.5,"height": 10,"width": 78,"title": "轩天天","color": "#2935e3"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 439.5,"top": 385.5,"height": 10,"width": 40,"title": "销售方:","color": "#cc5a5a"},"printElementType": {"title": "文本","type": "text"}},{"options": {"left": 15,"top": 385.5,"height": 10,"width": 44,"title": "收款人:","color": "#cc5a5a"},"printElementType": {"title": "文本","type": "text"}}],"paperNumberLeft": 565.5,"paperNumberTop": 394.5}]
}

(2)index.html

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title></title><link href="css/hiprint.css" rel="stylesheet" /><link href="css/print-lock.css" rel="stylesheet" /><link href="content/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.staticfile.net/jquery/1.10.2/jquery.min.js"></script><script src="content/bootstrap.min.js"></script><style>.hinnn-layout,.hinnn-layout * {box-sizing: border-box;}.hinnn-layout {display: flex;flex: auto;flex-direction: column;}.hinnn-layout.hinnn-layout-has-sider {flex-direction: row;}.hinnn-layout-sider {display: flex;flex-direction: row;position: relative;}.hinnn-layout-content {flex: auto;}.hinnn-header {position: relative;z-index: 1030;display: block;}.wrapper {min-height: 100%;}.height-100-per {height: 100%;}</style>
</head><body><layout class="layout hinnn-layout hinnn-layout-has-sider height-100-per" style="background:#fff;"><content class="hinnn-layout-content" style="border-left:1px solid #e8e8e8;"><div class="container-fluid height-100-per print-content"><div class="row"><div class="col-sm-12"><div class="row"><div class="col-sm-9 col-md-10"><div class="row"><div class="col-md-12"><div class="hinnn-docs-section"><h1 class="page-header">票据定位打印</h1><button type="button" class="btn btn-danger" id="batchPrint">批量打印</button><table class="table table-bordered" style="margin-top: 20px;"><thead><tr><th>发票编号</th><th>开票日期</th><th>客户名称</th><th>金额</th><th>操作</th></tr></thead><tbody><tr><td>INV-001</td><td>2023-10-01</td><td>某某公司</td><td>¥1085.00</td><td><a class="btn hiprint-toolbar-item bill-action"data-action="preview" data-index="1">快速预览</a><a class="btn hiprint-toolbar-item bill-action"data-action="print" data-index="1">打印</a></td></tr><tr><td>INV-001</td><td>2023-10-01</td><td>某某公司</td><td>¥985.00</td><td><a class="btn hiprint-toolbar-item bill-action"data-action="preview" data-index="2">快速预览</a><a class="btn hiprint-toolbar-item bill-action"data-action="print" data-index="2">打印</a></td></tr></tbody></table></div></div></div></div></div></div></div></content><sider class="hinnn-layout-sider" style=""><div class="container height-100-per" style="width:250px;"><div class="row"><div class="col-sm-12"><div id="PrintElementOptionSetting" style="margin-top:10px;"></div></div></div></div></sider></layout><div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"><div class="modal-dialog modal-lg" role="document" style="width: 825px;"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><spanaria-hidden="true">&times;</span></button><h4 class="modal-title" id="">打印预览</h4></div><div class="modal-body"><!-- 新增打印按钮 --><button type="button" class="btn btn-danger" id="printInModal">打印</button><div class="prevViewDiv"></div></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button></divmyModalLabel></div></div></div></div><script src="custom_test/custom-etype-provider.js"></script><script src="custom_test/custom-print-json.js"></script><script src="custom_test/print-data.js"></script><script src="polyfill.min.js"></script><script src="plugins/jquery.minicolors.min.js"></script><script src="plugins/JsBarcode.all.min.js"></script><script src="plugins/qrcode.js"></script><script src="hiprint.bundle.js"></script><script src="plugins/jquery.hiwprint.js"></script><script>$(document).ready(function () {var hiprintTemplate_bill;// 修改: 使用 $.getJSON 方法加载模板文件$.getJSON('custom_test/bill-template.json', function (templateData) {hiprintTemplate_bill = new hiprint.PrintTemplate({template: templateData,settingContainer: '#PrintElementOptionSetting'});});// 绑定模态框中的打印按钮事件$('#printInModal').click(function () {if (hiprintTemplate_bill) {hiprintTemplate_bill.print(printData);}});// 绑定批量打印按钮事件 - 参考提供的代码进行修改$('#batchPrint').click(function () {// 修改: 从表格中获取金额数据const printData = [];$('.table tbody tr').each(function(index) {const amountText = $(this).find('td:eq(3)').text(); // 获取金额列文本const amount = parseFloat(amountText.replace(/[¥,]/g, '')); // 去除¥符号和逗号,转换为数字printData.push({ totalAmount: amount,index: index + 1});});if (hiprintTemplate_bill) {hiprintTemplate_bill.print(printData);}});// 修改: 统一处理预览和打印逻辑,支持单行金额数据function handleBillAction(action, index, amount) {// 创建当前行的数据对象const rowData = {index: index,totalAmount: amount};if (action === 'preview') {$('#myModal .modal-body .prevViewDiv').html(hiprintTemplate_bill.getHtml(rowData));$('#myModal').modal('show');} else if (action === 'print') {if (hiprintTemplate_bill) {hiprintTemplate_bill.print([rowData]);}}}// 动态绑定事件$(document).on('click', '.bill-action', function () {const action = $(this).data('action'); // 获取操作类型const index = $(this).data('index');  // 获取索引// 获取当前行的金额const amountText = $(this).closest('tr').find('td:eq(3)').text();const amount = parseFloat(amountText.replace(/[¥,]/g, '')); // 去除¥符号和逗号,转换为数字handleBillAction(action, index, amount);});});</script></body></html>

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

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

相关文章

Android ScrollView嵌套RecyclerView 导致RecyclerView数据展示不全问题

Android RecyclerView 数据展示不全问题&#xff08;ScrollView→NestedScrollView 修复&#xff09; 一、问题核心现象 布局初始结构&#xff1a;外层用ScrollView包裹包含两个CustomBlogCardView&#xff08;内部均含RecyclerView&#xff09;的LinearLayout。 异常表现&…

AI助力数学学习,轻松掌握知识点!

小伙伴们&#xff0c;今天我们来利用AI辅助数学学习&#xff0c;将数学题目提交给AI,经过分析后给出相应的解题思路和知识点分析。现在有了AI这个"智能小老师"&#xff0c;学习变得更轻松&#xff01;只需把题目交给它&#xff0c;AI就能快速分析题目类型&#xff0c…

AI-调查研究-76-具身智能 当机器人走进生活:具身智能对就业与社会结构的深远影响

点一下关注吧&#xff01;&#xff01;&#xff01;非常感谢&#xff01;&#xff01;持续更新&#xff01;&#xff01;&#xff01; &#x1f680; AI篇持续更新中&#xff01;&#xff08;长期更新&#xff09; AI炼丹日志-31- 千呼万唤始出来 GPT-5 发布&#xff01;“快的…

机器学习、深度学习

卷积神经网络&#xff08;CNN&#xff09;vs. 循环神经网络&#xff08;RNN&#xff09;vs. Transformer 一文带你搞懂 AI Agent 开发利器&#xff1a;LangGraph 与 LangChain 区别 大语言模型&#xff1a;基于LLM的应用开发框架「LangChain」最全指南

SQL语句执行时间太慢,有什么优化措施?以及衍生的相关问题

SQL语句执行时间太慢&#xff0c;有什么优化措施&#xff1f; 可以从四个方面进行&#xff1a; 第一个是查询是否添加了索引 如果没有的话&#xff0c;为查询字段添加索引&#xff0c; 还有是否存在让索引失效的场景&#xff0c;像是没有遵循最左前缀&#xff0c;进行了一些…

QtConcurrent应用解析

目录 对比传统线程 1. QtConcurrent::run() —— 异步运行函数 2.QtConcurrent::mapped() —— 并行转换 3. QtConcurrent::filter() —— 并行过滤 4. QtConcurrent::run() QFutureWatcher —— UI 异步更新 5.线程池配置 QtConcurrent 是 Qt 框架提供的一个 高级并发编…

大疆图传十公里原理:无人机图传技术解析

大疆图传系统的核心在于把发射端的能量、机载接收的灵敏度、以及环境中的衰减因素&#xff0c;进行科学的预算与动态的修正。简单的说&#xff0c;就是通过精准的链路预算来确保在最坏环境下仍有可用的信号空间。发射功率、天线增益、空中与地面的路径损耗、接收端的噪声底线等…

jmeter 带函数压测脚本

包含时间戳获取、md5值计算、随机字符串获取<?xml version"1.0" encoding"UTF-8"?> <jmeterTestPlan version"1.2" properties"5.0" jmeter"5.6.3"><hashTree><TestPlan guiclass"TestPlanGui&…

鸿蒙app日志存储

app的pid获取 import process from @ohos.process;@Entry @Component struct MainAbility {aboutToAppear(): void {console.log(this.TAG,"pid: "+process.pid)}} 获取本应用日志 在Android中可以使用logcat --pid xxxx 获取特定进程xxxx的打印日志 在鸿蒙中也有…

02.【Linux系统编程】Linux权限(root超级用户和普通用户、创建普通用户、sudo短暂提权、权限概念、权限修改、粘滞位)

目录 1. root超级用户和普通用户 2. 创建普通用户、密码设置、切换用户 3. sudo短暂提权&#xff08;给普通用户添加sudo权限&#xff09; 4. 权限 4.1 是什么 4.2 为什么有权限&#xff1f;&#xff08;权限 角色 目标属性&#xff09; 4.2.1 角色 4.2.2 目标属性 …

阿里云可观测 2025 年 8 月产品动态

本月可观测热文回顾 文章一览&#xff1a; 零代码改造&#xff01;LoongSuite AI 采集套件观测实战 性能瓶颈定位更快更准&#xff1a;ARMS 持续剖析能力升级解析 不只是告警&#xff1a;用阿里云可观测 MCP 实现 AK 高效安全审计 金蝶云•星辰基于 SLS 构建稳定高效可观测…

绿虫零碳助手:通过电费推算用电量,确认光伏装机规模

在光伏项目开发前期&#xff0c;精准掌握用电需求与合理确定装机规模是关键环节。前者决定光伏系统需满足的用电基数&#xff0c;后者影响项目投资成本与发电收益匹配度。通过电费数据推算实际用电量&#xff0c;再结合专业工具计算光伏装机参数&#xff0c;可有效降低项目规划…

融智学:构建AI时代学术的新范式

融智学&#xff1a;构建AI时代学术新范式摘要&#xff1a;邹晓辉提出的融智学为现代学术体系困境提供系统性解决方案&#xff0c;通过"问题与价值驱动"的新范式取代传统"发表驱动"模式。该体系包含三大核心&#xff1a;哲学基础&#xff08;唯文主义、信息…

【JavaEE初阶】-- JVM

文章目录1. JVM运行流程2. Java运行时数据区2.1 方法区&#xff08;内存共享&#xff09;2.2 堆&#xff08;内存共享&#xff09;2.3 Java虚拟机栈&#xff08;线程私有&#xff09;2.4 本地方法栈&#xff08;线程私有&#xff09;2.5 程序计数器&#xff08;线程私有&#x…

第十四届蓝桥杯青少组C++选拔赛[2023.1.15]第二部分编程题(4 、移动石子)

参考程序1&#xff1a;#include <bits/stdc.h> using namespace std; int main() {int N;cin >> N;vector<int> stones(N);int sum 0;for (int i 0; i < N; i) {cin >> stones[i];sum stones[i];}int target sum / N; // 每个篮子的平均值int a…

Spring Boot 的注解是如何生效的

在 Spring 中&#xff0c;Configuration、ComponentScan、Bean、Import 等注解的扫描、解析和 BeanDefinition 注册是一个分层处理的过程。下面我们以 Configuration 类为例&#xff0c;结合代码流程详细说明其从扫描到注册的完整逻辑。 1. 整体流程概览 以下是核心步骤的流程图…

Django REST Framework响应类Response详解

概述 Response 类是一个智能的 HTTP 响应类&#xff0c;能够根据客户端请求的内容类型&#xff08;Content-Type&#xff09;自动将数据渲染成合适的格式&#xff08;JSON、XML、HTML等&#xff09;。 基本用法 from rest_framework.response import Response# 最简单的用法 de…

# 小程序 Web 登录流程完整解析

登录流程完整小白解析&#xff08;小程序 & Web&#xff09; 在开发中&#xff0c;登录是每个系统最基础的功能。为了让小白也能理解&#xff0c;我们用通俗类比和流程讲解 小程序登录、Web 登录、Token 刷新、安全存储等整个过程。1️⃣ 小程序登录流程&#xff08;小白理…

安装vcenter6.7 第二阶段安装很慢 或卡在50%

DNS、FQDN配置的问题采用VCSA安装vCenter时&#xff0c;第一步安装还算顺利&#xff0c;第二步就会安装失败&#xff0c;而且还特别慢&#xff0c;这是因为部署时需要DNS服务器&#xff0c;下面就是不采用DNS服务器的部署方案。第一步&#xff1a;正常安装&#xff0c;DNS就写本…

第十六届蓝桥杯软件赛 C 组省赛 C++ 题解

大家好&#xff0c;今天是 2025 年 9 月 11 日&#xff0c;我来给大家写一篇关于第十六届蓝桥杯软件赛 C 组省赛的C 题解&#xff0c;希望对大家有所帮助&#xff01;&#xff01;&#xff01; 创作不易&#xff0c;别忘了一键三连 题目一&#xff1a;数位倍数 题目链接&…