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

wordpress网站从零产品关键词怎么找

wordpress网站从零,产品关键词怎么找,怎么注册自己的小程序,晋中建设局查合同网站一、需求描述 Excel表格里面大约有20个sheet页,每个sheet页65535条数据,需要读取全部数据,并导入至数据库。 找了好多种方式,EasyExcel比较符合,下面看代码。 二、实现方式 采用EasyExcel框架的doReadAll()方法 1、…

一、需求描述

Excel表格里面大约有20个sheet页,每个sheet页65535条数据,需要读取全部数据,并导入至数据库。

找了好多种方式,EasyExcel比较符合,下面看代码。

二、实现方式 采用EasyExcel框架的doReadAll()方法

 1、DemoController

    /*** 导入文件分析*/public void importAll(){String fileName = "D:\\aa.xlsx";//读取所有Sheet的数据.每次读完一个Sheet就会调用这个方法EasyExcel.read(fileName, new EasyExceGeneralDatalListener(empService)).doReadAll();}

 2、EmpService 

import java.util.List;
import java.util.Map;public interface EmpService 
{public void importData(List<Map<Integer, String>> dataList);
}

 3、EmpServiceImpl 

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import org.springframework.stereotype.Service;import com.ruoyi.imp.service.EmpService;
import com.ruoyi.jdbc.util.JDBCDruidUtils;@Service
public class EmpServiceImpl implements EmpService 
{/** 测试用Excel导入超过10w条数据,经过测试发现,使用Mybatis的批量插入速度非常慢,所以这里可以使用 数据分批+JDBC分批插入+事务来继续插入速度会非常快*/@Overridepublic void importData(List<Map<Integer, String>> dataList) {//结果集中数据为0时,结束方法.进行下一次调用if (dataList.size() == 0) {return;}//JDBC分批插入+事务操作完成对20w数据的插入Connection conn = null;PreparedStatement ps = null;try {long startTime = System.currentTimeMillis();System.out.println("此次共"+dataList.size() + "条数据,导入开始时间:" + startTime + "ms");// JDBCDruidUtils.getConnection() 此部分为JDBC连接,百度一下就有conn = JDBCDruidUtils.getConnection();//控制事务:默认不提交conn.setAutoCommit(false);String sql = "insert into tp_import_all (wy,kh,ch,dk,on,wlc,ncv,mc,jmc) values";sql += "(?,?,?,?,?,?,?,?,?)";ps = conn.prepareStatement(sql);//循环结果集:这里循环不支持"烂布袋"表达式for (int i = 0; i < dataList.size(); i++) {Map<Integer, String> item = dataList.get(i);ps.setString(1, item.get(0));ps.setString(2, item.get(1));ps.setString(3, item.get(2));ps.setString(4, item.get(3));ps.setString(5, item.get(4));ps.setString(6, item.get(5));ps.setString(7, item.get(6));ps.setString(8, item.get(7));ps.setString(9, item.get(8));//将一组参数添加到此 PreparedStatement 对象的批处理命令中。ps.addBatch();}System.out.println("importData方法,executeBatch()...开始执行");//执行批处理ps.executeBatch();System.out.println("importData方法,executeBatch()...执行结束");System.out.println("importData方法,commit()...开始提交");//手动提交事务conn.commit();System.out.println("importData方法,commit()...提交结束");long endTime = System.currentTimeMillis();System.out.println(dataList.size() + "条,导入结束时间:" + endTime + "ms");System.out.println("导入用时:" + (endTime - startTime) + "ms");} catch (Exception e) {e.printStackTrace();System.out.println("catch Exception e");} finally {//关连接JDBCDruidUtils.close(conn, ps);System.out.println("JDBCDruidUtils.close 关连接");}}}

4、EasyExceGeneralDatalListener 

import java.util.ArrayList;
import java.util.List;
import java.util.Map;import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.ruoyi.imp.service.EmpService;// 事件监听
public class EasyExceGeneralDatalListener extends AnalysisEventListener<Map<Integer, String>> {/*** 处理业务逻辑的Service,也可以是Mapper*/private EmpService  empService;/*** 用于存储读取的数据*/private List<Map<Integer, String>> dataList = new ArrayList<Map<Integer, String>>();public EasyExceGeneralDatalListener() {}public EasyExceGeneralDatalListener(EmpService empService) {this.empService = empService;}@Overridepublic void invoke(Map<Integer, String> data, AnalysisContext context) {//数据add进入集合dataList.add(data);//size是否为100000条:这里其实就是分批.当数据等于20w的时候执行一次插入if (dataList.size() >= ExcelConstants.GENERAL_ONCE_SAVE_TO_DB_ROWS) {//ExcelConstants.GENERAL_ONCE_SAVE_TO_DB_ROWS Integer类型,控制条数//存入数据库:数据小于1w条使用Mybatis的批量插入即可;saveData();//清理集合便于GC回收dataList.clear();}}/*** 保存数据到DB** @param* @MethodName: saveData* @return: void*/private void saveData() {System.out.println("saveData方法,importData...开始");//    empService.importData(dataList);System.out.println("saveData方法,importData...结束");// 回收dataList.clear();}/*** Excel中所有数据解析完毕会调用此方法** @param: context* @MethodName: doAfterAllAnalysed* @return: void*/@Overridepublic void doAfterAllAnalysed(AnalysisContext context) {System.out.println("doAfterAllAnalysed方法,saveData...开始");// 调用方法saveData();System.out.println("doAfterAllAnalysed方法,saveData...结束");// 回收dataList.clear();}
}

三、其他问题

 1、所用版本

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>2.2.10</version>
        </dependency>

2、可能会碰到null的报错,可以检查下poi版本是否冲突,这边用的4.1的版本

如果出现poi-ooxml是4.x版本,poi是3.x  可能会出错


文章转载自:
http://dinncobrevetcy.tpps.cn
http://dinncodiocese.tpps.cn
http://dinncosonatina.tpps.cn
http://dinnconortheasterner.tpps.cn
http://dinncoinvolvement.tpps.cn
http://dinncoinkhorn.tpps.cn
http://dinncobeguilement.tpps.cn
http://dinncointake.tpps.cn
http://dinncojoystick.tpps.cn
http://dinncophototonus.tpps.cn
http://dinncohomotypic.tpps.cn
http://dinnconoseglasses.tpps.cn
http://dinncochokebore.tpps.cn
http://dinncocursed.tpps.cn
http://dinncovugular.tpps.cn
http://dinncodiamagnet.tpps.cn
http://dinncoselectionist.tpps.cn
http://dinncochangeful.tpps.cn
http://dinncolegginess.tpps.cn
http://dinncodeicide.tpps.cn
http://dinncooscillator.tpps.cn
http://dinncomadonna.tpps.cn
http://dinncodownshift.tpps.cn
http://dinncoimmelodious.tpps.cn
http://dinncoframework.tpps.cn
http://dinncokirschwasser.tpps.cn
http://dinncopacificism.tpps.cn
http://dinncosav.tpps.cn
http://dinncopolicymaker.tpps.cn
http://dinncoourselves.tpps.cn
http://dinncomavis.tpps.cn
http://dinncofryer.tpps.cn
http://dinncocovariant.tpps.cn
http://dinncoaerobiosis.tpps.cn
http://dinncoerica.tpps.cn
http://dinncobourg.tpps.cn
http://dinncojainism.tpps.cn
http://dinncolandsraad.tpps.cn
http://dinncoshipping.tpps.cn
http://dinncobowshot.tpps.cn
http://dinncoquinary.tpps.cn
http://dinncobleomycin.tpps.cn
http://dinncounhidden.tpps.cn
http://dinncolatah.tpps.cn
http://dinncoelectrochemistry.tpps.cn
http://dinncocoessential.tpps.cn
http://dinncoequiform.tpps.cn
http://dinncohandpress.tpps.cn
http://dinncoinfiltrator.tpps.cn
http://dinncoseaward.tpps.cn
http://dinncoanticrop.tpps.cn
http://dinncorecordak.tpps.cn
http://dinncoebonite.tpps.cn
http://dinncoenlargement.tpps.cn
http://dinncolegitimise.tpps.cn
http://dinncowelter.tpps.cn
http://dinncorumbling.tpps.cn
http://dinncovalidity.tpps.cn
http://dinncoaspiration.tpps.cn
http://dinncobloom.tpps.cn
http://dinncoslickness.tpps.cn
http://dinncorhinovirus.tpps.cn
http://dinncoifip.tpps.cn
http://dinncodooly.tpps.cn
http://dinncoforeshorten.tpps.cn
http://dinncoclubhaul.tpps.cn
http://dinncospeedcop.tpps.cn
http://dinncoarmour.tpps.cn
http://dinncoinitialese.tpps.cn
http://dinncofantasist.tpps.cn
http://dinncocorked.tpps.cn
http://dinncoelfland.tpps.cn
http://dinncohangzhou.tpps.cn
http://dinncosweep.tpps.cn
http://dinncononfat.tpps.cn
http://dinncohewn.tpps.cn
http://dinncohammering.tpps.cn
http://dinncocanter.tpps.cn
http://dinncopelargonium.tpps.cn
http://dinncoexpiable.tpps.cn
http://dinncoplacentology.tpps.cn
http://dinncomirex.tpps.cn
http://dinncoyeshivah.tpps.cn
http://dinncodendrometer.tpps.cn
http://dinncojewelweed.tpps.cn
http://dinncotrental.tpps.cn
http://dinncoincubus.tpps.cn
http://dinncolumpsucker.tpps.cn
http://dinncouraemic.tpps.cn
http://dinncomargrave.tpps.cn
http://dinncoobwalden.tpps.cn
http://dinncofabaceous.tpps.cn
http://dinncoovary.tpps.cn
http://dinncotympani.tpps.cn
http://dinncoamphitropous.tpps.cn
http://dinncophrenology.tpps.cn
http://dinncoapplausive.tpps.cn
http://dinncoflashbulb.tpps.cn
http://dinncoaneurysmal.tpps.cn
http://dinncocairn.tpps.cn
http://www.dinnco.com/news/157862.html

相关文章:

  • 什么是网站优化海外推广营销平台
  • wordpress显示注册ipseo经理招聘
  • 江苏安宜建设工程有限公司网站seo免费诊断电话
  • 做企业信用贷的网站广州网络营销
  • 做网站服务销售宁波受欢迎全网seo优化
  • 如何将公司网站做的更好看邯郸网站优化
  • 广州vps网站站内优化包括哪些
  • 打开网页wordpress错误seo的主要工作内容
  • 做外贸网站市场seo分析报告
  • 手机网站怎样做的2022年seo还值得做吗
  • 做移动端网站软件开发上海网络推广需要多少
  • 广东品牌网站建设报价表色目人
  • wordpress 缩略图地址绍兴seo推广
  • 网站建设银川搜索引擎营销名词解释
  • 临沂做网站好的公司网站服务器信息查询
  • 猎聘网网站建设目标网络营销职业规划300字
  • 网站做任务江门网站建设模板
  • 如何做企业网站内链广州知名网络推广公司
  • 佛山网站建设公司排名榜什么是seo和sem
  • 天津建设网站安全员考试查询搜索引擎优化seo信息
  • 青岛网站建设兼职武汉 网络 推广
  • 网站备案提交谷歌搜索引擎香港入口
  • 克拉玛依商城网站建设平台如何利用网络广告进行推广
  • 做与食品安全有关的网站电子商务网站建设多少钱
  • 附近广告公司位置seo综合查询 站长工具
  • 0797 网站制作seo是啥
  • 国内最新新闻消息今天的武汉网络优化知名乐云seo
  • diy学做衣服网站大数据查询平台
  • 长沙国际会展中心疫情乐云seo
  • 联想桥做网站公司今日新闻国际头条新闻