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

珠海多语种网站制作线上营销存在的问题

珠海多语种网站制作,线上营销存在的问题,营销软文200字,14亿人口新冠死多少EasyExcel是阿里巴巴开源的一个Java库#xff0c;用于操作Excel文件。它提供了简单易用的API#xff0c;可以读取、写入和转换Excel文件#xff0c;支持大量数据的导入和导出操作。 一、添加依赖#xff08;版本3.2#xff09; !--easyexcel操作excel-- depe…         EasyExcel是阿里巴巴开源的一个Java库用于操作Excel文件。它提供了简单易用的API可以读取、写入和转换Excel文件支持大量数据的导入和导出操作。 一、添加依赖版本3.2 !--easyexcel操作excel-- dependencygroupIdcom.alibaba/groupIdartifactIdeasyexcel/artifactIdversion3.2.0/version /dependency 二、根据Excel来建立数据库表 根据Excel的表头建立数据库表注意每一张表有2个字段需要添加即id和period账期建在最前面此项工作可以借助chatgpt来完成。 三、快速生成代码 使用EasyCode 快速生成代码entity、service、mapper、servicelmpl 四、修改实体类entity 修改实体类entity添加“账期”字段的自动插入 五、类继承、引用的方法引入 entity、service、mapper.、servicelmpl类继承、引用的方法引入使用AltEnter键 六、easyExcel的model和listeners package com.pbcnn.easyExcelCollector.excel.model;import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data;import java.math.BigDecimal;Data public class SheetSucffiBwbModel {ExcelProperty(index 1)private String indexName;ExcelProperty(index 2)private BigDecimal currentBalance;ExcelProperty(index 3)private BigDecimal currentMonthChange;ExcelProperty(index 4)private BigDecimal currentYearChange;ExcelProperty(index 5)private BigDecimal yearChangeRate;ExcelProperty(index 6)private BigDecimal lastYearBalance;ExcelProperty(index 7)private BigDecimal lastTwoYearsBalance;ExcelProperty(index 8)private BigDecimal lastYearGrowthRate;}package com.pbcnn.easyExcelCollector.excel.listeners;import cn.hutool.core.bean.BeanUtil; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.util.ListUtils; import com.alibaba.fastjson2.JSON; import com.pbcnn.easyExcelCollector.common.SpringUtil; import com.pbcnn.easyExcelCollector.entity.data.User; import com.pbcnn.easyExcelCollector.excel.model.ExcelUserData; import com.pbcnn.easyExcelCollector.mapper.UploadFileMapper; import com.pbcnn.easyExcelCollector.service.UserService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired;import java.util.List;/*** ExcelModelListener 不能被spring管理要每次读取 excel 都要 new,然后里面用到 spring 可以构造方法传进去** author makejava* create 2023-01-19 20:59*/ Slf4j public class UserDataListener implements ReadListenerExcelUserData {/*** 每隔5条存储数据库实际使用中可以100条然后清理 list 方便内存回收避免 OOM*/private static final int BATCH_COUNT 100;/*** 缓存的数据在 invoke 函数中存储每次读到的数据这里的泛型虽业务变化而变化存储的可以是excel表数据处理后的数据* 假如我要啊存入数据库中就需要将 ExcelUserData 转换成 User 那么这里的泛型就是User在 invoke 中处理后添加*/private ListExcelUserData cachedDataList ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);/*** 这个是一个DAO当然有业务逻辑这个也可以是一个service。可以用来解析数据后操作数据库*/Autowiredprivate UserService userService;Autowiredprivate UploadFileMapper uploadFileMapper;/*** 每读到一条数据都会调用这个函数可以在这里对数据的预处理** param excelUserData* param analysisContext*/Overridepublic void invoke(ExcelUserData excelUserData, AnalysisContext analysisContext) {log.info(解析到一条数据:{}, JSON.toJSONString(excelUserData));cachedDataList.add(excelUserData);// 达到BATCH_COUNT了需要去存储一次数据库防止数据几万条数据在内存容易OOMif (cachedDataList.size() BATCH_COUNT) {log.info(已达到BATCH_COUNT共{}条数据, cachedDataList.size());// 调用储存数据函数saveData();// 存储完成清理 listcachedDataList ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);}}/*** 所有数据解析完成了 都会来调用 做收尾工作确保最后遗留的数据也持久化存储到数据库** param analysisContext*/Overridepublic void doAfterAllAnalysed(AnalysisContext analysisContext) {// 这里也要保存数据确保最后遗留的数据也存储到数据库saveData();log.info(所有数据解析完成);}/*** 加上存储数据库*/private void saveData() {log.info({}条数据开始存储数据库, cachedDataList.size());// TODO 数据存储,使用批处理操作防止多次连接数据库例如 userService.saveBatch();if (cachedDataList.size() 0) {ListUser userList BeanUtil.copyToList(cachedDataList, User.class, null);UserService userService SpringUtil.getBean(UserService.class);userService.saveBatch(userList);}log.info(存储数据库成功);}}添加的时候 model复制entity的类然后添加ExcelProperty(index 1)去掉id和period账期Listeners直接复制其他类然后将类的名字替换掉即可。 七、controller 解析Excel package com.pbcnn.easyExcelCollector.controller;import com.alibaba.excel.EasyExcel; import com.pbcnn.easyExcelCollector.excel.listeners.UserDataListener; import com.pbcnn.easyExcelCollector.excel.model.ExcelUserData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile;import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture;RestController public class UploadController {Value(${file.upload-dir})private String uploadDir;PostMapping(value /uploadFiles, produces MediaType.APPLICATION_JSON_VALUE)public ResponseEntity? upload(RequestParam(files) MultipartFile[] files) {try {ListString fileNames new ArrayList();for (MultipartFile file : files) {if (!file.isEmpty()) {String fileName UUID.randomUUID().toString() _ StringUtils.cleanPath(file.getOriginalFilename());Path dest Path.of(uploadDir, fileName);try (InputStream inputStream file.getInputStream()) {Files.copy(inputStream, dest, StandardCopyOption.REPLACE_EXISTING);}fileNames.add(fileName);// 异步保存上传信息到数据库//CompletableFuture.runAsync(() - {// UploadFile uploadFile new UploadFile();// uploadFile.(fileName);// uploadFile.setFilePath(dest.toString());// uploadFile.setUploadTime(new Date());// uploadFile.setStatus(0);// uploadFileMapper.insert(uploadFile);//});/*根据文件路径读取excel*/String pathName dest.toString();CompletableFuture.runAsync(() - {EasyExcel.read(pathName, ExcelUserData.class, new UserDataListener()).sheet().doRead();});}}return ResponseEntity.ok(fileNames);} catch (IOException e) {return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(上传文件失败);}} }
http://www.pierceye.com/news/843460/

相关文章:

  • 安徽平台网站建设找哪家辽宁建设工程信息网审核
  • 余姚住房和建设局网站10元备案域名购买
  • 企业网站制作公司盈利做支付行业招代理一般上什么网站
  • 网站制作电话wordpress支持PHP吗
  • 天津网站推广宣传拓者设计吧室内设计
  • 建设 信用中国 网站淘宝购物
  • 义乌论坛网站建设怎样建设智能网站
  • 重庆做网站 外包公司建设校园网站的必要性
  • 做我女朋友好不好套路网站html5网页设计实训总结
  • 怎样给网站登录界面做后台seo研究中心官网
  • 养生类网站源码dreamwear网页制作
  • 北京装修平台网站网页设计公司企业文化
  • 上海临平路网站建设网站建设设计制作方案与价格
  • seo三人行网站免费电商网站建设
  • seo蒙牛伊利企业网站专业性诊断.win域名做网站怎么样
  • 微信、网站提成方案点做网站建设当中的技术解决方案
  • 云南省住房和城乡建设厅官方网站网站哪里可以查到做ddos
  • 爱情动做网站推荐个人养老保险金怎么交
  • 淘客怎么做自己的网站演示动画制作免费网站
  • 哪个网站可以搭建网页百度指数官网入口
  • 济南网站开发设计wordpress. 外贸seo
  • 深圳网站建设优化织梦 蝉知 wordpress
  • 荥阳郑州网站建设wordpress oauth2插件
  • 做传媒网站公司简介企业手机网站源码
  • 一级A做爰片安全网站济南营销型网站制作
  • 网站规划说明书范文17素材网官网
  • 青岛做网站大公司免费的行情网站app网页推荐
  • 产品网站建设多少钱哪些网站做推广效果好
  • 网站开发所需技能外链网
  • 广州做家教的网站临沂哪里有做网站