查看进程对应的路径查看端口号对应的进程ubuntu 安装ssh共享WiFi设置MyBatis 使用map类型作为参数,复杂查询(导出数据)

Linux 查询当前进程所在的路径

top  命令查询相应的进程号pid

ps -ef |grep 进程名

lsof -I:端口号

netstat -anp|grep 端口号

cd /proc/进程id

cwd 进程运行目录

exe 执行程序的绝对路径

cmdline 程序运行时输入的命令行命令

environ 记录了进程运行时的环境变量

fd 目录下是进程打开或使用的文件的符号连接

查看端口号对应进程

lsof -i :端口号

ubuntu 安装ssh

sudo apt-get install openssh-server

OpenGauss SpringBoot  配置

driver-class-name: org.postgresql.Driver

url:jdbc:postgresql://ip:port/db-name

共享WiFi

将带有无线网卡的电脑设置成热点(一般win10以上的系统)

右键转到设置,可编辑WiFi信息。

MyBatis 使用map类型作为参数,复杂查询(导出数据)

interface声明

/*** @author Be.insighted*/@Mapperpublic interface InterviewerMapper{IPage<TInterviewer> query(IPage<?> page, @Param("param") Map<String, ?> param);}

mapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.*.mapper.InterviewerMapper"><!--面试官查询 管理端 --><select id="query" resultType="com.*.entity.TInterviewer" parameterType="map">select * from t_tablewhere del_flag=0 and valid_flag='0'<if test="param.keyword != null and param.keyword != ''">and (INSTR(interviewer_name,#{param.keyword}) or interviewer_code = #{param.keyword})  <!--姓名或者工号--></if><if test="param.companyCode != null and param.companyCode != ''">and company_code = #{param.companyCode}  <!--企业编号--></if><if test="param.positionCode != null and param.positionCode != ''">and position_code = #{param.positionCode}  <!--岗位编码--></if><if test="param.label != null and param.label != ''">and INSTR(label,#{param.label})  <!--标签--></if><if test="param.interviewerStatus != null and param.interviewerStatus != ''">and interviewer_status = #{param.interviewerStatus} <!--状态--></if><if test="param.interviewerStatus == null">and interviewer_status = '0'  <!--状态--></if><if test="param.ids != null">AND id in<foreach collection="param.ids" index="index" open="(" close=")" item="item" separator=",">#{item}</foreach></if>order by create_time desc</select>
</mapper>

对应的controller

    @GetMapping(value = "/interviewer/en/export")@ApiOperation(value = "面试官导出")public void export(HttpServletResponse response, InterviewerParams params) throws IOException, IllegalAccessException {LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();String companyCode = sysUser.getCompanyId();TInterviewer interviewer = interviewerConvert.toEntity(params);interviewer.setCompanyCode(companyCode);interviewer.setDelFlag(false);IPage<?> page = new Page();page.setCurrent(params.getPageNo());page.setSize(params.getPageSize());Map<String, Object> paramMap = new HashMap<>();String id = params.getIds();if (StrUtil.isNotBlank(id)) {EnInfo enInfo = enInfoService.getById(companyCode);String companyName = enInfo.getEnName();// 导出选中的数据paramMap.put("ids", id.split(","));List<TInterviewer> records = interviewerService.lambdaQuery().in(TInterviewer::getId, id.split(",")).list();List<InterviewerVO> temps = records.stream().map(item -> {InterviewerVO vo = new InterviewerVO();BeanUtils.copyProperties(item, vo);vo.setCompanyName(companyName);return vo;}).collect(Collectors.toList());List<String> positionCodes = records.stream().map(TInterviewer::getPositionCode).collect(Collectors.toList());List<String> collect = positionCodes.stream().distinct().collect(Collectors.toList());Map<String, String> positionCode2NameMap = new HashMap<>(collect.size());if (!CollectionUtils.isEmpty(collect)) {List<TPosition> positions = positionService.lambdaQuery().in(TPosition::getPositionCode, collect).list();positionCode2NameMap = positions.stream().collect(Collectors.toMap(TPosition::getPositionCode, TPosition::getPositionName));for (int i = 0; i < temps.size(); i++) {temps.get(i).setPositionName(positionCode2NameMap.get(temps.get(i).getPositionCode()));}}if (!CollectionUtils.isEmpty(temps)) {ExcelUtil<InterviewerVO> excelUtil = new ExcelUtil();excelUtil.setClose(false);excelUtil.buildExcel(response, temps);}return;} else {paramMap.put("keyword", params.getKeyword());paramMap.put("interviewerStatus", params.getInterviewerStatus());paramMap.put("positionCode", params.getPositionCode());paramMap.put("label", params.getLabel());paramMap.put("companyCode", companyCode);}IPage<TInterviewer> pageInfo = interviewerService.query4En(page, paramMap);List<TInterviewer> records = pageInfo.getRecords();EnInfo enInfo = enInfoService.getById(companyCode);String companyName = enInfo.getEnName();List<InterviewerVO> temps = records.stream().map(item -> {InterviewerVO vo = new InterviewerVO();BeanUtils.copyProperties(item, vo);vo.setCompanyName(companyName);return vo;}).collect(Collectors.toList());List<String> positionCodes = records.stream().map(TInterviewer::getPositionCode).collect(Collectors.toList());List<String> collect = positionCodes.stream().distinct().collect(Collectors.toList());Map<String, String> positionCode2NameMap = new HashMap<>(collect.size());if (!CollectionUtils.isEmpty(collect)) {List<TPosition> positions = positionService.lambdaQuery().in(TPosition::getPositionCode, collect).list();positionCode2NameMap = positions.stream().collect(Collectors.toMap(TPosition::getPositionCode, TPosition::getPositionName));for (int i = 0; i < temps.size(); i++) {temps.get(i).setPositionName(positionCode2NameMap.get(temps.get(i).getPositionCode()));}}if (!CollectionUtils.isEmpty(temps)) {ExcelUtil<InterviewerVO> excelUtil = new ExcelUtil();excelUtil.setClose(false);excelUtil.buildExcel(response, temps);}}

导出Excel工具类

package com.*.utils;import cn.com.*.annotation.Column;
import cn.com.*.annotation.Title;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.URLUtil;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;/*** @author Be.insighted* @title: ExcelUtil* @description: 默认每个sheet最多50000条数据  超过另起一个sheet* @date @date 2023-11-14 15:42*/
@Data
public class ExcelUtil<T> {/*** 设置每行的宽度 每个值的index 对应第几列  如{1500,1000} 表示第一个1500长度 第二个1000长度 以此类推*/private int[] size;/*** 查询条件文本描述*/private String queryCriteria;/*** 是否关闭流 默认关闭*/private boolean close = true;public ExcelUtil() {this.queryCriteria = null;}public ExcelUtil(String queryCriteria) {this.queryCriteria = queryCriteria;}public void buildExcel(HttpServletResponse response, List<T> list, String filename) throws IOException, IllegalAccessException {String name = Objects.isNull(filename) ? "" : filename;OutputStream output = response.getOutputStream();response.reset();response.setCharacterEncoding("UTF-8");name = URLEncoder.encode(name + DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".xls", "UTF-8");response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");response.setHeader("Content-Disposition", "attachment; filename=" + URLUtil.encode(name, "UTF-8"));response.setHeader("Pragma", "no-cache");response.setHeader("Expires", "0");response.setContentType("application/msexcel;charset=utf-8");List<String> parameter = new ArrayList<>();List<Field> fieldArrayList = new ArrayList<>();if (CollUtil.isNotEmpty(list)) {Class<?> clazz = list.get(0).getClass();Field[] fields = clazz.getDeclaredFields();for (Field field : fields) {if (field.getAnnotation(Column.class) != null) {if (!StringUtils.isEmpty(field.getAnnotation(Column.class).name())) {parameter.add(field.getAnnotation(Column.class).name());} else {parameter.add(field.getName());}fieldArrayList.add(field);}}Title title = clazz.getDeclaredAnnotation(Title.class);if (title != null) {name = title.title();}} else {return;}HSSFWorkbook hssfWorkbook = new HSSFWorkbook();try {final int sheetNum = (int) Math.ceil((float) list.size() / 50000);HSSFCellStyle style = hssfWorkbook.createCellStyle();style.setFillForegroundColor((short) 22);style.setFillPattern(FillPatternType.SOLID_FOREGROUND);style.setBorderBottom(BorderStyle.THIN);style.setBorderLeft(BorderStyle.THIN);style.setBorderRight(BorderStyle.THIN);style.setBorderTop(BorderStyle.THIN);style.setAlignment(HorizontalAlignment.CENTER);style.setVerticalAlignment(VerticalAlignment.CENTER);//2022年4月8日17:16:09 增加,解决:导出数据之后数据并未换行,只有双击之后才展现换行效果style.setWrapText(true);HSSFFont font = hssfWorkbook.createFont();font.setFontHeightInPoints((short) 12);style.setFont(font);HSSFCellStyle style2 = hssfWorkbook.createCellStyle();style2.setAlignment(HorizontalAlignment.CENTER);//垂直居中style2.setVerticalAlignment(VerticalAlignment.CENTER);//2022年4月8日17:16:09 增加,解决:导出数据之后数据并未换行,只有双击之后才展现换行效果style2.setWrapText(true);for (int n = 1; n <= sheetNum; n++) {final HSSFSheet sheet = hssfWorkbook.createSheet("sheet" + "-" + n);List<T> toOut = null;if (sheetNum > 1) {if (n == sheetNum) {toOut = getSubList(list, 0, list.size() - 1);} else {toOut = getSubList(list, 0, 50000);}} else {toOut = list;}if (CollUtil.isNotEmpty(toOut)) {Class<?> clazz = toOut.get(0).getClass();HSSFRow row1 = sheet.createRow(0);HSSFCell cellTitle = row1.createCell(0);cellTitle.setCellStyle(style);Title title = clazz.getDeclaredAnnotation(Title.class);if (title != null) {if (StringUtils.isNotBlank(queryCriteria)) {cellTitle.setCellValue(title.title() + "                         " + queryCriteria);} else {cellTitle.setCellValue(title.title());}sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, parameter.size() - 1));}if (getSize() != null && getSize().length > 0) {for (int i = 0; i < getSize().length; i++) {sheet.setColumnWidth(i, getSize()[i]);}} else {int length = parameter.size();this.size = new int[length];for (int i = 0; i < length; i++) {this.size[i] = 10000;sheet.setColumnWidth(i, getSize()[i]);}}HSSFRow row2 = sheet.createRow(1);for (int i = 0; i < parameter.size(); i++) {HSSFCell cell = row2.createCell(i);cell.setCellStyle(style);cell.setCellValue(parameter.get(i));}for (int i = 0; i < toOut.size(); i++) {HSSFRow row = sheet.createRow(i + 2);for (int j = 0; j < fieldArrayList.size(); j++) {Field field = fieldArrayList.get(j);Object value = ReflectUtil.getFieldValue(toOut.get(i), field);HSSFCell cell = row.createCell(j);cell.setCellStyle(style2);Column column = field.getDeclaredAnnotation(Column.class);if (value != null && !"null".equals(value)) {String rule = column.timeFormat();boolean rate = column.rate();boolean condition = StringUtils.isNotBlank(rule) && (field.getType().equals(Date.class) ||field.getType().equals(java.sql.Date.class) ||field.getType().equals(Time.class) ||field.getType().equals(Timestamp.class));if (condition) {SimpleDateFormat simpleDateFormat = new SimpleDateFormat(rule);cell.setCellValue(simpleDateFormat.format(value));} else if (rate && field.getType().equals(BigDecimal.class)) {BigDecimal valueReal = (BigDecimal) value;cell.setCellValue(valueReal.multiply(new BigDecimal("100")) + "%");} else {cell.setCellValue(value.toString());}} else {if (field.getType().equals(Integer.class) || field.getType().equals(Long.class) ||field.getType().equals(Double.class) || field.getType().equals(Float.class) ||field.getType().equals(BigDecimal.class)) {cell.setCellValue(0);} else {cell.setCellValue("");}}}}}}hssfWorkbook.write(output);} finally {IoUtil.close(hssfWorkbook);if (close) {IoUtil.close(output);}}}/*** 截取list  含左不含右** @param list* @param fromIndex* @param toIndex* @param <T>* @return*/private static <T> List<T> getSubList(List<T> list, int fromIndex, int toIndex) {List<T> listClone = list;List<T> sub = listClone.subList(fromIndex, toIndex);return new ArrayList<>(sub);}}

column、title注解定义

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Inherited
@Documented
public @interface Column {String name() default "";String timeFormat() default "";boolean rate() default false;
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
@Documented
public @interface Title {String title() default "";}

导出的对象定义

@Data
@Accessors(chain = true)
@ApiModel(value = "面试官表示")
@Title(title = "面试官信息")
public class InterviewerVO implements Serializable {private String id;/**
     * 企业编码
     */@Excel(name = "企业编码")@Column(name = "企业编码")@Dict( dictTable="sys_depart",dicCode="id",dicText="depart_name")private String companyCode;/**
     * 企业名称
     */@Excel(name = "企业名称")@Column(name = "企业名称")private String companyName;/**
     * 面试官名称
     */@Excel(name = "面试官名称")@Column(name = "面试官名称")private String interviewerName;/**
     * 面试官编号,取黄河人才网的id
     */private String interviewerCode;/**
     * 部门
     */private String department;/**
     * 岗位名称
     */@Excel(name = "岗位名称")@Column(name = "岗位名称")private String positionName;/**
     * 岗位code
     */private String positionCode;/**
     * 标签
     */@Excel(name = "标签")@Column(name = "标签")private String label;/**
     * 联系方式
     */@Excel(name = "联系方式")@Column(name = "联系方式")private String contactInfo;/**
     * 面试官类别
     */@Dict(dicCode = "interviewer_type")private String interviewerType;/**
     * 面试官状态
     */@Dict(dicCode = "interviewer_status")private String interviewerStatus;/**
     * 面试官有效标识
     */private String validFlag;/**
     * 创建人姓名
     */@Excel(name = "创建人")@Column(name = "创建人")private String createName;/**
     * 创建人工号
     */private String createCode;/**
     * 创建时间
     */@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")private Date createTime;/**
     * 更新人
     */private String updateName;/**
     * 更新时间
     */private Date updateTime;
}

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

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

相关文章

小梅哥Xilinx FPGA学习笔记20——无源蜂鸣器驱动设计与验证(音乐发生器设计)

目录 一&#xff1a;章节导读 二&#xff1a;无源蜂鸣器驱动原理 三&#xff1a;PWM 发生器模块设计 3.1 PWM 发生器模块框图 3.2 PWM 发生器模块接口功能描述 3.3 PWM波生成设计文件代码 3.4 测试仿真文件 3.5 测试仿真结果 3.6 板级调试与验证之顶层文件设计 四&am…

支持 input 函数的在线 python 运行环境 - 基于队列

支持 input 函数的在线 python 运行环境 - 基于队列 思路两次用户输入三次用户输入 实现前端使用 vue element uiWindows 环境的执行器子进程需要执行的代码 代码仓库参考 本文提供了一种方式来实现支持 input 函数&#xff0c;即支持用户输的在线 python 运行环境。效果如下图…

UE5.1_UMG序列帧动画制作

UE5.1_UMG序列帧动画制作 UMG序列帧动画制作相对比较简单&#xff0c;不像视频帧需要创建媒体播放器那么复杂&#xff0c;以下简要说明&#xff1a; 1. 事件函数 2. 准备序列帧装入数组 3. 构造调用事件函数 4. 预览 序列帧UMG0105 5. 完成&#xff01;按需配置即可。

【Mars3d】new mars3d.layer.GeoJsonLayer({不规则polygon加载label不在正中间的解决方案

问题&#xff1a; 1.new mars3d.layer.GeoJsonLayer({type: "polygon",在styleOptions里配置label的时候&#xff0c;发现这个 不规则polygon加载的时候&#xff0c;会出现label不在中心位置。 graphicLayer new mars3d.layer.GeoJsonLayer({ name: "全国省界…

macosx编译qgroundcontrol源码(Qt6.7)

1.克隆源码: clone --recursive http://github.com/mavlink/qgroundcontrol.git 克隆成功 3.编译 编译环境要求: 编译方法: 使用QtCreator编译 使用命令行编译 打开QGroundControl.pro并编译IOS版本 旧版本使用Qt 5.15.2 run qmake 新版本使用Qt 6.6或者更高 IOS工程输出要…

Oracle数据恢复记录一 表数据的恢复

当我们误删/修改数据之后&#xff0c;要进行数据恢复&#xff0c;需要有数据库管理员权限才能实现&#xff0c;所以奉劝各位修改数据要好好确认&#xff0c;搞出异常来就很麻烦了。下面是一个数据恢复简单的例子&#xff1a; DML Sql 这里展示了修改的sql UPDATE XX_MES_PROC…

使用STM32微控制器驱动LCD1602显示器

驱动LCD1602显示器是嵌入式系统常见的任务之一&#xff0c;而STM32微控制器因其灵活性和丰富的外设而成为了广泛采用的解决方案。在这篇文章中&#xff0c;我们将探讨如何使用STM32微控制器来驱动LCD1602显示器。我们将从STM32的GPIO配置、延时函数以及LCD1602的初始化和写入数…

23111 IO进程线程 day5

1>将互斥机制代码重新实现一遍 #include<myhead.h>char buf[128];//定义互斥锁变量 pthread_mutex_t mutex;//创建分支线程函数 void *task(void *arg) {while(1){//获取锁资源pthread_mutex_lock(&mutex);printf("分支线程中buf%s\n",buf);strcpy(buf…

Redis 教程

Redis 简介 Redis 是完全开源的&#xff0c;遵守 BSD 协议&#xff0c;是一个高性能的 key-value 数据库。 Redis 与其他 key - value 缓存产品有以下三个特点&#xff1a; Redis支持数据的持久化&#xff0c;可以将内存中的数据保存在磁盘中&#xff0c;重启的时候可以再次…

Apache Paimon:Streaming Lakehouse is Coming

摘要&#xff1a;本文整理自阿里云智能开源表存储负责人&#xff0c;Founder of Paimon&#xff0c;Flink PMC 成员李劲松&#xff08;花名&#xff1a;之信&#xff09;、同程旅行大数据专家&#xff0c;Apache Hudi & Paimon Contributor 吴祥平、汽车之家大数据计算平台…

移动神器RAX3000M路由器不刷固件变身家庭云之六(高级应用):设置https

本系列文章&#xff1a; 移动神器RAX3000M路由器变身家庭云之一&#xff1a;开通SSH&#xff0c;安装新软件包 移动神器RAX3000M路由器变身家庭云之二&#xff1a;安装vsftpd 移动神器RAX3000M路由器变身家庭云之三&#xff1a;外网访问家庭云 移动神器RAX3000M路由器变身家庭云…

数据库高可用mha

MHA搭建的步骤 一.配置主从复制 1.初始化环境 #在四台服务器上初始化环境 systemctl stop firewalld systemctl disable firewalld setenforce 0 2.修改 Master、Slave1、Slave2 节点的主机名 #在Master上 hostnamectl set-hostname mysql1 su#在Slave1 hostnamectl set-h…