Merge remote-tracking branch 'origin/dev_third_stage' into dev_third_stage
This commit is contained in:
+14
-1
@@ -829,7 +829,7 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
|
||||
InputStream excelTemplate = CosBootUtil.download(templateUrl);
|
||||
SpreadsheetMLPackage pkg = SpreadsheetMLPackage.load(wordTemplate);
|
||||
Workbook workbook = WorkbookFactory.create(excelTemplate);
|
||||
ExcelUtil.replacePictureBatchPOI(workbook, pkg, imgListAll);
|
||||
ExcelUtil.replacePictureBatchPOI(workbook, pkg, imgListAll, params);
|
||||
ExcelUtil.variableReplace(pkg, params);
|
||||
pkg.save(wordOS);
|
||||
|
||||
@@ -862,6 +862,19 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
|
||||
os.write(len2);
|
||||
}
|
||||
|
||||
// 添加导出历史
|
||||
String uploadFileName = fileOriName + ".zip";
|
||||
InputStream uploadFileio = new FileInputStream(new File(fileNowPath+".zip"));
|
||||
MultipartFile mFile = new MockMultipartFile(uploadFileName, uploadFileName, "text/plain", uploadFileio); // 用于上传
|
||||
OSSFile ossFile = ossFileService.uploadLocalOfCos(mFile, "/report", "", CutEnum.CN.getValue()); // 上传导出的压缩包
|
||||
ParamsReportExportHistoryEO paramsReportExportHistoryEO = new ParamsReportExportHistoryEO();
|
||||
paramsReportExportHistoryEO.setExportType(ExportTypeEnum.CUSTOM.getValue());
|
||||
paramsReportExportHistoryEO.setExportFileId(ossFile.getId());
|
||||
paramsReportExportHistoryEO.setParamsManifestId(paramsReportDetailVO.getParamsManifestId());
|
||||
paramsReportExportHistoryEO.setExportTime(new Date());
|
||||
paramsReportExportHistoryEOService.add(paramsReportExportHistoryEO);
|
||||
|
||||
uploadFileio.close();
|
||||
os.flush();
|
||||
os.close(); // 后开先关
|
||||
fis.close(); // 先开后关
|
||||
|
||||
+37
-20
@@ -9,10 +9,12 @@ import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import com.jero.generater.modules.online.auth.entity.OnlAuthData;
|
||||
import com.jero.modules.extRepo.entity.ExtRepoData;
|
||||
import com.jero.modules.extRepo.entity.ExtRepoDataPage;
|
||||
import com.jero.modules.extRepo.service.IExtRepoDataService;
|
||||
import com.jero.modules.extRepo.service.IExtRepoFolderService;
|
||||
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -88,6 +90,7 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
|
||||
}
|
||||
}
|
||||
queryWrapper.eq(ExtRepoData::getSupFolder, extRepoData.getSupFolder());
|
||||
queryWrapper.orderBy(true, false, ExtRepoData::getCreateTime);
|
||||
IPage<ExtRepoData> pageList = extRepoDataService.page(page, queryWrapper);
|
||||
ExtRepoDataPage res = new ExtRepoDataPage(extRepoFolderService.haveManageAuth(extRepoData.getSupFolder()), pageList);
|
||||
return Result.OK(res);
|
||||
@@ -116,21 +119,23 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
|
||||
@ApiOperation(value = "对外报告数据表-添加", notes = "对外报告数据表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@Validated @RequestBody ExtRepoData extRepoData) {
|
||||
Result<ExtRepoData> result = new Result();
|
||||
if (extRepoFolderService.haveManageAuth(extRepoData.getSupFolder())) {
|
||||
log.info("对外报告数据表收到文件添加请求,开始处理文件:【" + sdf.format(new Date()) + "】");
|
||||
int res = extRepoDataService.add(extRepoData);
|
||||
if (CutEnum.CN.getValue().equals(extRepoData.getCut())) {
|
||||
return Result.OK("添加成功:" + res + "条数据!");
|
||||
result.success("添加成功:" + res + "条数据!");
|
||||
} else {
|
||||
return Result.OK("success:" + res + "data!");
|
||||
result.success(res + " pieces of data are added successfully!");
|
||||
}
|
||||
} else {
|
||||
if (CutEnum.CN.getValue().equals(extRepoData.getCut())) {
|
||||
return Result.error("没有权限!");
|
||||
result.success("没有权限!");
|
||||
} else {
|
||||
return Result.error("No Permission!");
|
||||
result.success("You do not have permission !");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,23 +149,25 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
|
||||
@ApiOperation(value = "对外报告数据表-编辑", notes = "对外报告数据表-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@Validated @RequestBody ExtRepoData extRepoData) {
|
||||
Result<ExtRepoData> result = new Result();
|
||||
ExtRepoData erd = extRepoDataService.queryById(extRepoData.getId());
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
if (extRepoFolderService.isManager() || sysUser.getUsername().equals(erd.getCreateBy())) {
|
||||
extRepoData.setSupFolder(erd.getSupFolder());
|
||||
extRepoDataService.editById(extRepoData);
|
||||
if (CutEnum.CN.getValue().equals(extRepoData.getCut())) {
|
||||
return Result.OK("添加成功!");
|
||||
result.success("编辑成功!");
|
||||
} else {
|
||||
return Result.OK("success!");
|
||||
result.success("Data update successfully!");
|
||||
}
|
||||
} else {
|
||||
if (CutEnum.CN.getValue().equals(extRepoData.getCut())) {
|
||||
return Result.error("没有权限!");
|
||||
result.success("没有权限!");
|
||||
} else {
|
||||
return Result.error("No Permission!");
|
||||
result.success("You do not have permission !");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,6 +181,7 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam("id") String id,
|
||||
@RequestParam(name = "cut", defaultValue = "cn") String cut) {
|
||||
Result<ExtRepoData> result = new Result();
|
||||
ExtRepoData erd = extRepoDataService.queryById(id);
|
||||
if (null != erd) {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
@@ -181,20 +189,25 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
|
||||
extRepoDataService.deleteById(id);
|
||||
CosBootUtil.delete(erd.getFileKey());
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
return Result.OK("删除成功!");
|
||||
result.success("删除成功!");
|
||||
} else {
|
||||
return Result.OK("Delete success!");
|
||||
result.success("Data deletion successfully!");
|
||||
}
|
||||
} else {
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
return Result.error("没有权限!");
|
||||
result.success("没有权限!");
|
||||
} else {
|
||||
return Result.error("No Permission!");
|
||||
result.success("You do not have permission!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Result.error("Delete Error!");
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
result.success("删除失败!");
|
||||
} else {
|
||||
result.success("Delete failed!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,30 +221,32 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam("ids") String ids,
|
||||
@RequestParam(name = "cut", defaultValue = "cn") String cut) {
|
||||
Result<ExtRepoData> result = new Result();
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<String> idsList = Arrays.asList(ids.split(","));
|
||||
for (String id : idsList) {
|
||||
ExtRepoData erd = extRepoDataService.queryById(id);
|
||||
if (null != erd && !extRepoFolderService.isManager() && !sysUser.getUsername().equals(erd.getCreateBy())) {
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
return Result.error("没有权限!");
|
||||
result.success("没有权限!");
|
||||
} else {
|
||||
return Result.error("No Permission!");
|
||||
result.success("You do not have permission!");
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String id : idsList) {
|
||||
ExtRepoData erd = extRepoDataService.queryById(id);
|
||||
if(null!=erd){
|
||||
if (null != erd) {
|
||||
CosBootUtil.delete(erd.getFileKey());
|
||||
this.extRepoDataService.deleteById(id);
|
||||
}
|
||||
}
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
return Result.OK("删除成功!");
|
||||
result.success("删除成功!");
|
||||
} else {
|
||||
return Result.OK("Delete success!");
|
||||
result.success("Data deletion successfully!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,11 +259,13 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
|
||||
@ApiOperation(value = "对外报告数据表-通过id查询", notes = "对外报告数据表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<ExtRepoData> result = new Result();
|
||||
ExtRepoData extRepoData = extRepoDataService.queryById(id);
|
||||
if (extRepoData == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
result.success("未找到对应数据!");
|
||||
return result;
|
||||
}
|
||||
return Result.OK(extRepoData);
|
||||
return result.OK(extRepoData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+25
-18
@@ -59,20 +59,22 @@ public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtR
|
||||
@ApiOperation(value = "对外报告文件夹表-添加", notes = "对外报告文件夹表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@Validated @RequestBody ExtRepoFolder extRepoFolder) {
|
||||
Result<ExtRepoFolder> result = new Result();
|
||||
if (extRepoFolderService.haveManageAuth(extRepoFolder.getSupFolder())) {
|
||||
extRepoFolderService.add(extRepoFolder);
|
||||
if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) {
|
||||
return Result.OK("添加成功!");
|
||||
result.success("添加成功!");
|
||||
} else {
|
||||
return Result.OK("success!");
|
||||
result.success("Data added successfully!");
|
||||
}
|
||||
} else {
|
||||
if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) {
|
||||
return Result.error("没有权限!");
|
||||
result.success("没有权限!");
|
||||
} else {
|
||||
return Result.error("No Permission!");
|
||||
result.success("You do not have permission !");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,20 +87,22 @@ public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtR
|
||||
@ApiOperation(value = "对外报告文件夹表-编辑", notes = "对外报告文件夹表-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@Validated @RequestBody ExtRepoFolder extRepoFolder) {
|
||||
Result<ExtRepoFolder> result = new Result();
|
||||
if (extRepoFolderService.haveManageAuth(extRepoFolder.getId())) {
|
||||
extRepoFolderService.editById(extRepoFolder);
|
||||
if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) {
|
||||
return Result.OK("编辑成功!");
|
||||
result.success("编辑成功!");
|
||||
} else {
|
||||
return Result.OK("success!");
|
||||
result.success("Data update successfully!");
|
||||
}
|
||||
} else {
|
||||
if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) {
|
||||
return Result.error("没有权限!");
|
||||
result.success("没有权限!");
|
||||
} else {
|
||||
return Result.error("No Permission!");
|
||||
result.success("You do not have permission !");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,33 +116,35 @@ public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtR
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id,
|
||||
@RequestParam(name = "cut", defaultValue = "cn") String cut) {
|
||||
Result<ExtRepoFolder> result = new Result();
|
||||
if (extRepoFolderService.haveManageAuth(id)) {
|
||||
List<ExtRepoFolder> resList = extRepoFolderService.getListBySupFolder(id);
|
||||
if (resList.isEmpty()) {
|
||||
List<ExtRepoData> erdList = extRepoDataService.queryByFolder(id);
|
||||
for (ExtRepoData erd:erdList){
|
||||
for (ExtRepoData erd : erdList) {
|
||||
extRepoDataService.deleteById(erd.getId());
|
||||
}
|
||||
extRepoFolderService.deleteById(id);
|
||||
} else {
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
return Result.error("请先删除子文件夹!");
|
||||
result.success("请先删除子文件夹!");
|
||||
} else {
|
||||
return Result.error("Please Delete Subfolder First!");
|
||||
result.success("Please delete the subfolder first!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
return Result.error("没有权限!");
|
||||
result.success("没有权限!");
|
||||
} else {
|
||||
return Result.error("No Permission!");
|
||||
result.success("You do not have permission!");
|
||||
}
|
||||
}
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
return Result.OK("删除成功!");
|
||||
result.success("删除成功!");
|
||||
} else {
|
||||
return Result.OK("success!");
|
||||
result.success("Data deletion successfully!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,14 +158,15 @@ public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtR
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name = "id", required = true) String id,
|
||||
@RequestParam(name = "cut", defaultValue = "cn") String cut) {
|
||||
Result<ExtRepoFolder> result = new Result();
|
||||
ExtRepoFolder extRepoFolder = extRepoFolderService.queryById(id);
|
||||
if (extRepoFolder == null) {
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
return Result.error("未找到对应数据");
|
||||
result.success("未找到对应数据!");
|
||||
} else {
|
||||
return Result.error("No Data!");
|
||||
result.success("No Data!");
|
||||
}
|
||||
}
|
||||
return Result.OK(extRepoFolder);
|
||||
return result.OK(extRepoFolder);
|
||||
}
|
||||
}
|
||||
|
||||
+33
-2
@@ -70,7 +70,22 @@ public class ExcelUtil {
|
||||
System.out.println("mmmmmmm");
|
||||
}
|
||||
|
||||
public static void replacePictureBatchPOI(Workbook workbook, SpreadsheetMLPackage pkg, List<Map<String, Object>> imgListAll) throws Exception {
|
||||
public static void setRowHeight(WorksheetPart worksheetPart, int rIndex, double height, int cIndex, String text) {
|
||||
SheetData sheetData = worksheetPart.getJaxbElement().getSheetData();
|
||||
|
||||
org.xlsx4j.sml.Row r = sheetData.getRow().get(rIndex);
|
||||
if (r.getHt() == null || (r.getHt() != null && r.getHt() < height)) {
|
||||
r.setHt(height);
|
||||
r.setCustomHeight(true);
|
||||
}
|
||||
|
||||
Cell c = r.getC().get(cIndex);
|
||||
if (text == null) {
|
||||
c.setV(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void replacePictureBatchPOI(Workbook workbook, SpreadsheetMLPackage pkg, List<Map<String, Object>> imgListAll, HashMap<String, String> params) throws Exception {
|
||||
//获取全部sheet页中表格
|
||||
Sheet sheet=null;
|
||||
int partNameNum = 0;
|
||||
@@ -83,6 +98,7 @@ public class ExcelUtil {
|
||||
int totalRowNum = sheet.getLastRowNum();
|
||||
|
||||
//获得所有数据
|
||||
int k = 0;
|
||||
for (int x = 0; x < totalRowNum; x++) {
|
||||
//获得第x行对象
|
||||
Row row = sheet.getRow(x);
|
||||
@@ -90,12 +106,14 @@ public class ExcelUtil {
|
||||
//获得总列数
|
||||
int cellLength = row.getLastCellNum();
|
||||
//如果x行里的所有单元格
|
||||
int j = 0;
|
||||
for (int y = 0; y < cellLength; y++) {
|
||||
|
||||
org.apache.poi.ss.usermodel.Cell cell = row.getCell(y);
|
||||
if(ObjectUtil.isNull(cell)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String cellValue = cell.getStringCellValue();
|
||||
|
||||
for (Map<String, Object> imgMap : imgListAll) {
|
||||
@@ -103,10 +121,23 @@ public class ExcelUtil {
|
||||
String text = (String) imgMap.get("text");
|
||||
byte[] bytes = (byte[]) imgMap.get("bytes");
|
||||
if (("${" + key + "}").equals(cellValue)) {
|
||||
|
||||
// 根据图片大小调整行高
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
|
||||
BufferedImage bufferedImage = ImageIO.read(in);
|
||||
setRowHeight(worksheetPart, k, bufferedImage.getHeight(), j, text);
|
||||
|
||||
if (text != null) {
|
||||
params.put(key, text);
|
||||
}
|
||||
|
||||
// 插入图片到表格
|
||||
putImagePOI(worksheetPart, pkg, cell, bytes, sheet.getSheetName().toLowerCase(), String.valueOf(partNameNum));
|
||||
}
|
||||
}
|
||||
j++; // 单元格非空才++
|
||||
}
|
||||
k++; // 行非空才++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +204,7 @@ public class ExcelUtil {
|
||||
anchor.getFrom().setCol(newCell.getColumnIndex());
|
||||
anchor.getFrom().setRow(newCell.getRowIndex());
|
||||
anchor.setTo(new CTMarker());
|
||||
anchor.getTo().setCol(newCell.getColumnIndex() + 1);
|
||||
anchor.getTo().setCol(newCell.getColumnIndex() + 1); // TODO
|
||||
anchor.getTo().setRow(newCell.getRowIndex() + 1);
|
||||
|
||||
CTPicture picture = new CTPicture();
|
||||
|
||||
Reference in New Issue
Block a user