From 5ac8fb595f48e4be70ade39464c319b47661c087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E5=B5=A9?= Date: Thu, 30 Mar 2023 21:39:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91OTA=E5=A4=87=E6=A1=88?= =?UTF-8?q?=E5=B7=A5=E5=85=B7-=E8=BD=A6=E8=BE=86=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ota/service/IOtaBaSjGgnrfsService.java | 2 +- .../impl/OtaBaSjGgnrfsServiceImpl.java | 70 +++++++++++++++++-- .../service/impl/OtaBaSjListServiceImpl.java | 10 ++- .../impl/OtaBaSjSjfzbhServiceImpl.java | 30 +++++++- .../impl/OtaBaSjSjxtbhServiceImpl.java | 40 ++++++++++- 5 files changed, 142 insertions(+), 10 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/IOtaBaSjGgnrfsService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/IOtaBaSjGgnrfsService.java index 8f0b59aea..e37910f4c 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/IOtaBaSjGgnrfsService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/IOtaBaSjGgnrfsService.java @@ -72,4 +72,4 @@ public interface IOtaBaSjGgnrfsService extends IService { void parseFileList(List upLoadFiles, String otaId, String cut) throws Exception; - void exportData(File file, String otaId, String cut) throws Exception;} + void exportData(File file, File fsAttFile, String otaId, String cut) throws Exception;} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjGgnrfsServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjGgnrfsServiceImpl.java index 45402ae5b..3b056ab13 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjGgnrfsServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjGgnrfsServiceImpl.java @@ -1,12 +1,13 @@ package com.jero.modules.ota.service.impl; +import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jero.common.exception.JeroBootException; +import com.jero.common.util.oss.CosBootUtil; +import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.oss.service.IOSSFileService; -import com.jero.modules.ota.entity.OtaBaCxTxjl; -import com.jero.modules.ota.entity.OtaBaSjGgnrfs; -import com.jero.modules.ota.entity.OtaBaSjSjyxpg; +import com.jero.modules.ota.entity.*; import com.jero.modules.ota.enums.OtaModuleEnum; import com.jero.modules.ota.mapper.OtaBaSjGgnrfsMapper; import com.jero.modules.ota.service.IOtaBaCxTxjlService; @@ -17,6 +18,10 @@ import com.jero.modules.ota.utils.ImportFileUtil; import com.jero.modules.system.service.ISysDictService; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -25,6 +30,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; import java.util.Date; import java.util.List; import java.util.Objects; @@ -230,7 +237,62 @@ public class OtaBaSjGgnrfsServiceImpl extends ServiceImpl attList = JSONArray.parseArray(attStr, AttachmentEO.class); + if (ObjectUtils.isNotEmpty(attList)) { + for (AttachmentEO aeo : attList) { + List ossFileList = ossFileService.getFileInfos(aeo.getId()); + for (OSSFile ossFile : ossFileList) { + String filePath = ossFile.getUrl(); + boolean b = CosBootUtil.doesObjectExist(filePath); + if (b) { + InputStream download = CosBootUtil.download(filePath); + ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download); + } + } + } + } + wb.write(new FileOutputStream(file)); + wb.close(); + } } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjListServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjListServiceImpl.java index 9d4b01f65..15d0f58eb 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjListServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjListServiceImpl.java @@ -195,18 +195,22 @@ public class OtaBaSjListServiceImpl extends ServiceImpl fzbhList = this.getByOtaId(otaId); + if (ObjectUtils.isNotEmpty(fzbhList)) { + Workbook wb = ImportFileUtil.readExcel(file); + Sheet s = wb.getSheetAt(0); + Row row; + Cell cell; + int start = 4; + for (OtaBaSjSjfzbh bh : fzbhList) { + row = s.createRow(start); + cell = row.createCell(0); + cell.setCellValue(bh.getGnmc()); + cell = row.createCell(1); + cell.setCellValue(bh.getSjmdlx()); + cell = row.createCell(2); + cell.setCellValue(bh.getSjqbgcs()); + cell = row.createCell(3); + cell.setCellValue(bh.getSjhbgcs()); + cell = row.createCell(4); + cell.setCellValue(bh.getGnbgms()); + cell = row.createCell(5); + cell.setCellValue(bh.getSytjbg()); + cell = row.createCell(6); + cell.setCellValue(bh.getSjsjkzq()); + start++; + } + wb.write(new FileOutputStream(file)); + wb.close(); + } } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjSjxtbhServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjSjxtbhServiceImpl.java index d32663796..dc2b13036 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjSjxtbhServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ota/service/impl/OtaBaSjSjxtbhServiceImpl.java @@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.io.File; +import java.io.FileOutputStream; import java.lang.reflect.Field; import java.util.*; @@ -284,6 +285,43 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl bhList = this.getByOtaId(otaId); + if (ObjectUtils.isNotEmpty(bhList)) { + Workbook wb = ImportFileUtil.readExcel(file); + Sheet s = wb.getSheetAt(0); + Row row; + Cell cell; + int start = 4; + for (OtaBaSjSjxtbh bh : bhList) { + row = s.createRow(start); + cell = row.createCell(0); + cell.setCellValue(bh.getXtmc()); + cell = row.createCell(1); + cell.setCellValue(bh.getSjqbgcs()); + cell = row.createCell(2); + cell.setCellValue(bh.getSjhbgcs()); + cell = row.createCell(3); + cell.setCellValue(bh.getSjkzqmc()); + cell = row.createCell(4); + cell.setCellValue(bh.getYjbb()); + cell = row.createCell(5); + cell.setCellValue(bh.getSjqrjbb()); + cell = row.createCell(6); + cell.setCellValue(bh.getSjhrjbb()); + cell = row.createCell(7); + cell.setCellValue(bh.getSjqczxt()); + cell = row.createCell(8); + cell.setCellValue(bh.getSjhczxt()); + cell = row.createCell(9); + cell.setCellValue(bh.getSjbyzsj()); + cell = row.createCell(10); + cell.setCellValue(bh.getSjbdx()); + cell = row.createCell(11); + cell.setCellValue(bh.getSfcfsj()); + start++; + } + wb.write(new FileOutputStream(file)); + wb.close(); + } } }