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

网站上的导航栏怎么做盘多多搜索引擎入口

网站上的导航栏怎么做,盘多多搜索引擎入口,教育机构客户管理系统,多多进宝cms网站建设领导每天让比较两个Excel中的内容,为了节省工作效率多摸鱼,就写了个java接口,通过上传两个文件 进行代码比较得到详细的比较结果(这个需要自己根据日志二开) 目前只实现了比较功能 话不多说直接上代码,具体看注释 package com.yx…

领导每天让比较两个Excel中的内容,为了节省工作效率多摸鱼,就写了个java接口,通过上传两个文件 进行代码比较得到详细的比较结果(这个需要自己根据日志二开) 目前只实现了比较功能

话不多说直接上代码,具体看注释

package com.yxy.aob.util;import cn.hutool.core.collection.CollUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;/*** @Description: excel对比* @Author: Hyz* @Date: 2024/10/14 11:33* @Version:1.0*/
@Slf4j
public class CompareTwoExcels {private final static String MSG_PREFIX = "【source】与【target】中";/*** 文件1流*/private InputStream sourceExcelFile;/*** 文件2流*/private InputStream targetExcelFile;/*** 是否模糊   true为精准匹配  false为模糊匹配*/private boolean isPerfectMatch;/*** 差集*/private List<String> differential;/*** 错误行*/private List<String> errorMsg;/*** 匹配行*/private List<String> successMsg;/*** 构造方法** @param sourceExcelFile 文件1* @param targetExcelFile 文件2* @param isPerfectMatch  表示是否需要完全匹配*/public CompareTwoExcels(InputStream sourceExcelFile, InputStream targetExcelFile, boolean isPerfectMatch) {this.sourceExcelFile = sourceExcelFile;this.targetExcelFile = targetExcelFile;this.isPerfectMatch = isPerfectMatch;this.differential = new ArrayList<>();this.errorMsg = new ArrayList<>();this.successMsg = new ArrayList<>();}public static void main(String[] args) throws IOException {try (InputStream sourceInputStream = Files.newInputStream(Paths.get("C:\\Users\\Administrator\\Desktop\\1.xlsx"));InputStream targetInputStream = Files.newInputStream(Paths.get("C:\\Users\\Administrator\\Desktop\\1 - 副本.xlsx"))) {// 初始化识别器CompareTwoExcels compareTwoExcels = new CompareTwoExcels(sourceInputStream, targetInputStream, false);// 执行识别方法 需要指定对应的sheet页 下标0开始boolean result = compareTwoExcels.comparedExcels(0, 0);log.info("result为:" + result);} catch (Exception e) {e.printStackTrace();}}/*** 获取初始化文件的sheet数量** @param type 1 表示sourceExcelFile 2 表示targetExcelFile*/private int getSheetNum(Integer type) {log.info("sourceExcelSheetNum为:" + this.sourceExcelFile);try (Workbook workbook = WorkbookFactory.create(type == 1 ? this.sourceExcelFile : this.targetExcelFile)) {return workbook.getNumberOfSheets();} catch (IOException e) {return 0;}}/*** 比较两个excel** @param sourceExcelSheetNum sheet  从0开始* @param targetExcelSheetNum sheet  从0开始*/private boolean comparedExcels(int sourceExcelSheetNum, int targetExcelSheetNum) {log.info("------------------------读取Excel1数据------------------------");List<List<String>> sourceList = this.readExcel(sourceExcelSheetNum, this.sourceExcelFile, "source");log.info("------------------------读取Excel2数据------------------------");List<List<String>> targetList = this.readExcel(targetExcelSheetNum, this.targetExcelFile, "target");if (CollUtil.isEmpty(sourceList) || CollUtil.isEmpty(targetList)) {log.error("sourceList为空!!!");return false;}// 行数不一致直接返回falseif (sourceList.size() != targetList.size()) {log.error("sourceList与targetList长度不一致");return false;}log.info("------------------------开始匹配:【{}】------------------------", isPerfectMatch ? "精准匹配" : "模糊匹配");boolean result = true;try {// 模糊匹配和精准匹配区分if (!isPerfectMatch) {// 模糊匹配 即两份excel的每一行不定for (int i = 1; i <= sourceList.size(); i++) {log.info("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 第【{}】行 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓", i);// 表格1的第i行List<String> list1 = sourceList.get(i - 1);List<String> list2 = targetList.get(i - 1);// 判断1、两个表格的同一行是否相同 (即表格1的第1行和表格2的第1行hashCode是否一致)if (list1.hashCode() != list2.hashCode()) {log.info("------{}第【{}】行匹配结果------UNKNOWN", MSG_PREFIX, i);// 判断2、 需要比较表格1的这一行在表格二中是否存在if (targetList.contains(list1)) {int i1 = targetList.indexOf(list1);log.info("---------详情:【source】中第【{}】行与【target】中第【{}】行匹配(跨行)", i, i1 + 1);this.successMsg.add("【source】中第【" + i + "】行与【target】中第【" + (i1 + 1) + "】行匹配(跨行)");//                            List<String> cells = targetList.get(targetList.indexOf(list1));
//                            for (int j = 1; j <= list1.size(); j++) {
//                                if (cells.contains(list1.get(j - 1))) {
//                                    log.info("---------详情:第【{}】行,第【{}】列 匹配", i, j);
//                                    this.successMsg.add(MSG_PREFIX + "第【" + i + "】行,第【" + j + "】列 匹配");
//                                } else {
//                                    log.info("---------详情:第【{}】行,第【{}】列 不匹配", i, j);
//                                    this.errorMsg.add(MSG_PREFIX + "第【" + i + "】行,第【" + j + "】列 不匹配");
//                                    result = false;
//                                }
//                            }} else {log.info("---------详情:【source】中第【{}】行在【target】中不存在", i);this.errorMsg.add(MSG_PREFIX + "第【" + i + "】行均不存在");result = false;}} else {log.info("------{}第【{}】行匹配结果------SUCCESS", MSG_PREFIX, i);this.successMsg.add(MSG_PREFIX + "第【" + i + "】行匹配");}}} else {// 精准匹配 即两份excel的每一行每一列格式相同for (int i = 1; i <= sourceList.size(); i++) {// 表格1的第i行List<String> list1 = sourceList.get(i - 1);// 表格2的第i行List<String> list2 = targetList.get(i - 1);// 精准匹配 即两份excel的每一行每一列都完全匹配// list2.equals(list1)或list1.hashCode() == list2.hashCode()if (list1.hashCode() == list2.hashCode()) {log.info("------第【{}】行, 匹配------", i);this.successMsg.add(MSG_PREFIX + "第【" + i + "】行, 匹配");} else {log.info("------第【{}】行, 不匹配------", i);this.errorMsg.add(MSG_PREFIX + "第【" + i + "】行, 不匹配");result = false;}}}} catch (IndexOutOfBoundsException ex) {log.error("两个表格可能存在行数不一致,导致sourceList与targetList长度不一致!");result = false;} finally {log.info("------------------------比较结束------------------------");}return result;}/*** 读取excel 封装成集合* 该程序需要传入一份excel 和excel的列数 行数由程序自动检测* 注意:该方法统计的行数是默认第一行为title 不纳入统计的** @return excel的集合*/private List<List<String>> readExcel(int sheetNum, InputStream inputStream, String type) {List<List<String>> list = new ArrayList<>();// 建需要读取的excel文件写入streamtry (Workbook workbook = WorkbookFactory.create(inputStream)) {// 指向sheet下标为0的sheet 即第一个sheet 也可以按在sheet的名称来寻找Sheet sheet = workbook.getSheetAt(sheetNum);// 获取sheet1中的总行数int rowTotalCount = sheet.getLastRowNum();//获取总列数int columnCount = 0;for (int i = 0; i <= rowTotalCount; i++) {// 获取第i列的row对象Row row = sheet.getRow(i);ArrayList<String> listRow = new ArrayList<>();int physicalNumberOfCells = row.getPhysicalNumberOfCells();if (physicalNumberOfCells >= columnCount) {columnCount = physicalNumberOfCells;}for (int j = 0; j < physicalNumberOfCells; j++) {//下列步骤为判断cell读取到的数据是否为null 如果不做处理 程序会报错String cell = null;//如果未null则加上""组装成非null的字符串if (row.getCell(j) == null) {cell = row.getCell(j) + "";listRow.add(cell);//如果读取到额cell不为null 则直接加入	listRow集合} else {cell = row.getCell(j).toString();listRow.add(cell);}}list.add(listRow);}log.info("Excel【{}】中【{}】页签共计:{}行,{}列(列为最大列)", type, sheet.getSheetName(), rowTotalCount + 1, columnCount);} catch (IOException e) {log.error("读取excel sheet{}失败: {}", sheetNum, e.getMessage());}return list;}/*** ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓私有属性方法↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/public List<String> getDifferential() {return differential;}private void setDifferential(List<String> differential) {this.differential = differential;}public List<String> getErrorMsg() {return errorMsg;}private void setErrorMsg(List<String> errorMsg) {this.errorMsg = errorMsg;}public List<String> getSuccessMsg() {return successMsg;}private void setSuccessMsg(List<String> successMsg) {this.successMsg = successMsg;}
}

文章转载自:
http://thug.pqbz.cn
http://phosphotransferase.pqbz.cn
http://senor.pqbz.cn
http://circumstanced.pqbz.cn
http://semitize.pqbz.cn
http://clubby.pqbz.cn
http://redefine.pqbz.cn
http://aerologist.pqbz.cn
http://genista.pqbz.cn
http://geopotential.pqbz.cn
http://clayey.pqbz.cn
http://tenderness.pqbz.cn
http://sian.pqbz.cn
http://galvanography.pqbz.cn
http://superior.pqbz.cn
http://thalamium.pqbz.cn
http://aerograph.pqbz.cn
http://scrapnel.pqbz.cn
http://extremum.pqbz.cn
http://psycholinguist.pqbz.cn
http://transference.pqbz.cn
http://pentagon.pqbz.cn
http://harmonious.pqbz.cn
http://plebby.pqbz.cn
http://vivavoce.pqbz.cn
http://incontinuous.pqbz.cn
http://essemtiality.pqbz.cn
http://gelate.pqbz.cn
http://microsporocyte.pqbz.cn
http://gutser.pqbz.cn
http://unthankful.pqbz.cn
http://astrolater.pqbz.cn
http://ileostomy.pqbz.cn
http://cercarial.pqbz.cn
http://marinescape.pqbz.cn
http://subcuticular.pqbz.cn
http://distinguishing.pqbz.cn
http://divaricate.pqbz.cn
http://kansas.pqbz.cn
http://maim.pqbz.cn
http://oscillometer.pqbz.cn
http://sunbonnet.pqbz.cn
http://exigible.pqbz.cn
http://batcher.pqbz.cn
http://weaken.pqbz.cn
http://concupiscent.pqbz.cn
http://unskillful.pqbz.cn
http://troublesomely.pqbz.cn
http://sue.pqbz.cn
http://remorsefully.pqbz.cn
http://sychnocarpous.pqbz.cn
http://shlocky.pqbz.cn
http://ballade.pqbz.cn
http://urological.pqbz.cn
http://motorcyclist.pqbz.cn
http://emarginate.pqbz.cn
http://crusade.pqbz.cn
http://tableland.pqbz.cn
http://kalpa.pqbz.cn
http://redtop.pqbz.cn
http://prying.pqbz.cn
http://hydroxid.pqbz.cn
http://bioelectrical.pqbz.cn
http://bellyfat.pqbz.cn
http://narrowband.pqbz.cn
http://hard.pqbz.cn
http://volcanically.pqbz.cn
http://unchallenged.pqbz.cn
http://cupped.pqbz.cn
http://sultan.pqbz.cn
http://recipients.pqbz.cn
http://obesity.pqbz.cn
http://rendezvous.pqbz.cn
http://girdle.pqbz.cn
http://formidably.pqbz.cn
http://benefic.pqbz.cn
http://tariff.pqbz.cn
http://tonight.pqbz.cn
http://substrata.pqbz.cn
http://neurogenesis.pqbz.cn
http://felon.pqbz.cn
http://cursing.pqbz.cn
http://racon.pqbz.cn
http://telereference.pqbz.cn
http://philopena.pqbz.cn
http://radiophosphorus.pqbz.cn
http://earning.pqbz.cn
http://agrostology.pqbz.cn
http://fruitful.pqbz.cn
http://sandiver.pqbz.cn
http://trialogue.pqbz.cn
http://proem.pqbz.cn
http://noesis.pqbz.cn
http://yyz.pqbz.cn
http://alliance.pqbz.cn
http://kwangju.pqbz.cn
http://moxibustion.pqbz.cn
http://muchness.pqbz.cn
http://bacillus.pqbz.cn
http://cavalry.pqbz.cn
http://www.dt0577.cn/news/71538.html

相关文章:

  • 烟台网站设计单位湖南长沙最新疫情
  • 淘宝网站可信度状况及建设策略郑州模板建站代理
  • 网站维护是什么样引流推广平台有哪些
  • 深圳建设网站公司小企业广告投放平台
  • 建设实验中心网站网络策划方案
  • 网站建设验收使用情况搜索引擎的优化方法
  • 网站域名 空间申请表今天重大新闻国内最新消息
  • 服装外贸网站建设成都网站建设seo
  • 私人可以做慈善网站吗快速排名软件哪个好
  • 凡客网上做的网站能否更改域名西安疫情最新数据
  • 怎样讲卖灯的网站做的好处百度自动优化
  • 手机建设网站目的公众号开发
  • 海外网站seo现在的网络推广怎么做
  • 有哪些做网站的公司网络营销app有哪些
  • 营销型企业网站诊断网站推广的100种方法
  • 河南郑州汽车网网站建设域名备案查询站长工具
  • 微分销平台登录长沙seo免费诊断
  • 佛山淘宝设计网站设计价格网站的宣传与推广
  • 甘肃做网站哪家好创建网址链接
  • 合肥移动网站建设聚名网域名注册
  • 企业vi设计策划公司企业vi设计公司哈尔滨关键词优化报价
  • 哪家网站做民宿好如何网络推广
  • wordpress 标签分类优化排名
  • 做网站和app那个花销大西安网站seo优化公司
  • 大兴区住房和城乡建设部网站网站运营推广的方法有哪些
  • wordpress post type广州谷歌seo
  • 做网站如何计算工资友链互换平台推荐
  • 有个性的个人网站seo人才网
  • 注册安全工程师难吗成都搜狗seo
  • 郑州哪里做网站汉狮抖音账号权重查询入口