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

淄博做网站的公司排名百度网络推广营销

淄博做网站的公司排名,百度网络推广营销,代做效果图的网站好,中国建设银行员工培训网站Springboot将多个图片导出成zip压缩包 将多个图片导出成zip压缩包 /*** 判断时间差是否超过6小时* param startTime 开始时间* param endTime 结束时间* return*/public static boolean isWithin6Hours(String startTime, String endTime) {// 定义日期时间格式DateTimeFormatt…Springboot将多个图片导出成zip压缩包 将多个图片导出成zip压缩包 /*** 判断时间差是否超过6小时* param startTime 开始时间* param endTime 结束时间* return*/public static boolean isWithin6Hours(String startTime, String endTime) {// 定义日期时间格式DateTimeFormatter formatter DateTimeFormatter.ofPattern(yyyy-MM-dd HH:mm:ss);// 将字符串转换为 LocalDateTimeLocalDateTime startDateTime LocalDateTime.parse(startTime,formatter);LocalDateTime endDateTime LocalDateTime.parse(endTime,formatter);// 检查两个时间之间的时间差long hoursDifference ChronoUnit.SECONDS.between(startDateTime, endDateTime);// 如果小时差小于等于6小时则符合条件return hoursDifference 6 * 60 * 60;}/*** 批量下载上传的图片** param startTime 开始时间* param endTime 结束时间*/public void batchDownloadUploadPhoto(String startTime, String endTime,String fieldId,String unitTypeId,Integer unitNo,Integer termAddr, HttpServletResponse response, HttpServletRequest request) {if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) {throw new DataValidateErrorException(请先传递时间在批量导出);}if (!startTime.contains(:) || !endTime.contains(:)) {throw new DataValidateErrorException(请传递时分秒);}//相隔时间不得超过6小时if(!isWithin6Hours(startTime,endTime)){//大于6小时抛出异常throw new DataValidateErrorException(导出的时间范围不得超过6小时);}//查询导出图片urlListChuteImageAddress addressList chuteImageAddressService.selectUploadPhoto(startTime, endTime, fieldId, unitTypeId, unitNo, termAddr);//没有数据时抛出异常if(CollectionUtils.isEmpty(addressList)){throw new DataValidateErrorException(无数据导出);}DownloadByteArray downloadByteArray new DownloadByteArray();// 创建临时文件File zipFile null;FileInputStream fis null;BufferedInputStream buff null;ZipOutputStream zos null;CheckedOutputStream cos null;FileOutputStream fot null;ServletOutputStream os null;try {//临时文件名称zipFile File.createTempFile( System.currentTimeMillis(), .zip);fot new FileOutputStream(zipFile);// 为任何OutputStream产生校验第一个参数是制定产生校验和的输出流第二个参数是指定Checksum的类型 (Adler32(较快)和CRC32两种)cos new CheckedOutputStream(fot, new Adler32());// 用于将数据压缩成Zip文件格式zos new ZipOutputStream(cos);String[] files new String[addressList.size()];ListString list addressList.stream().map(ChuteImageAddress::getImgUrl).collect(Collectors.toList());list.toArray(files);for (int i 0; i files.length; i) {String file files[i];zos.putNextEntry(new ZipEntry(addressList.get(i).getImgName()));StorePath storePath StorePath.praseFromUrl(file);byte[] fileBytes client.downloadFile(storePath.getGroup(), storePath.getPath(), downloadByteArray);zos.write(fileBytes);}os response.getOutputStream();//下载文件,使用spring框架中的FileCopyUtils工具response.setCharacterEncoding(GB2312);response.setContentType(request.getSession().getServletContext().getMimeType(UUIDUtil.create()));//设置响应头,attachment表示以附件的形式下载inline表示在线打开response.setHeader(content-disposition, attachment;fileName URLEncoder.encode(批量下载.zip, UTF-8));fis new FileInputStream(zipFile);buff new BufferedInputStream(fis);FileCopyUtils.copy(buff, os);} catch (Exception e) {log.error(【批量下载图片出现异常】异常原因 e.getMessage());} finally {if (zos ! null) {try {zos.close();} catch (IOException e) {e.printStackTrace();}}if (fot ! null) {try {fot.close();} catch (IOException e) {e.printStackTrace();}}if (os ! null) {try {os.close();} catch (IOException e) {e.printStackTrace();}}if (fis ! null) {try {fis.close();} catch (IOException e) {e.printStackTrace();}}if (buff ! null) {try {buff.close();} catch (IOException e) {e.printStackTrace();}}}}
http://www.zqtcl.cn/news/562889/

相关文章:

  • 怎么做免费推广网站做网站第一部
  • 橙色网站后台模板WordPress的SEO插件安装失败
  • 做网站好还是做微信小程序好外包加工网外放加工活
  • 中国建设银行网站查征信电子商务网站建设及推广
  • 扫描网站漏洞的软件php网站后台验证码不显示
  • 诸城哪里有做网站的做网站的尺寸
  • 网站开发参考书目做网站推广赚钱吗
  • 九度网站建设网站做ppt模板
  • 浙江做公司网站多少钱评论回复网站怎么做
  • 江门网络建站模板虚拟主机价格一般多少钱
  • 网站建设公司云南深圳手机商城网站设计费用
  • 汇泽网站建设网页版快手
  • 手机销售培训网站wordpress案例插件
  • 滨江道做网站公司wordpress 花瓣网
  • 如何建网站快捷方式软件开发做平台
  • 常见的静态网页深圳罗湖企业网站优化
  • 做网站一天赚多少钱外贸网站建设排名
  • 一个大型网站建设得多少钱百度成都总部
  • 网站制作公司汉狮网络手机版网站优化
  • 铜川做网站logo 图标 设计
  • 如何做网站的注册页面南京宣传片公司有哪些
  • 中国建设机械教育协会网站网站建设中html中关于图片显示的标签有哪些
  • 网站过期后dede减肥网站源码
  • 营销型 手机网站网站建设方案后期服务
  • 怎么做一个个人网站建网站的八个步骤
  • 淘宝导购网站模版上海网站推广软件
  • 做影视网站引流湖北响应式网站建设费用
  • 网站统计cnzz网站空间有哪些
  • 泉州微信网站开发公司wordpress头像解决
  • 湛江网站建设皆选小罗24专业网站建设 福田