|
@@ -1,33 +1,46 @@
|
|
package com.ruoyi.project.training.controller;
|
|
package com.ruoyi.project.training.controller;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.time.LocalDate;
|
|
|
|
-import java.util.Iterator;
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
|
|
+import com.deepoove.poi.XWPFTemplate;
|
|
|
|
+import com.deepoove.poi.data.*;
|
|
|
|
+import com.deepoove.poi.data.style.CellStyle;
|
|
|
|
+import com.deepoove.poi.data.style.TableStyle;
|
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
+import com.ruoyi.common.utils.file.FileUtils;
|
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
|
|
|
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
|
import com.ruoyi.framework.config.RuoYiConfig;
|
|
import com.ruoyi.framework.config.RuoYiConfig;
|
|
|
|
+import com.ruoyi.framework.web.controller.BaseController;
|
|
|
|
+import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
|
+import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
|
+import com.ruoyi.project.officeConvert.OfficeConvertController;
|
|
import com.ruoyi.project.plant.domain.TStaffmgr;
|
|
import com.ruoyi.project.plant.domain.TStaffmgr;
|
|
import com.ruoyi.project.plant.service.ITStaffmgrService;
|
|
import com.ruoyi.project.plant.service.ITStaffmgrService;
|
|
-import com.ruoyi.project.training.bccnew.domain.TTsFirstplanTmpl;
|
|
|
|
-import com.ruoyi.project.training.domain.TTrainingDevice;
|
|
|
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
|
|
+import com.ruoyi.project.system.mapper.SysUserMapper;
|
|
|
|
+import com.ruoyi.project.training.domain.TTrainingbcc;
|
|
import com.ruoyi.project.training.domain.TTrainingbccDevice;
|
|
import com.ruoyi.project.training.domain.TTrainingbccDevice;
|
|
import com.ruoyi.project.training.mapper.TTrainingbccDeviceMapper;
|
|
import com.ruoyi.project.training.mapper.TTrainingbccDeviceMapper;
|
|
import com.ruoyi.project.training.mapper.TTrainingbccMapper;
|
|
import com.ruoyi.project.training.mapper.TTrainingbccMapper;
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
|
+import com.ruoyi.project.training.service.ITTrainingbccService;
|
|
|
|
+import io.jsonwebtoken.lang.Assert;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
-import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
|
|
|
-import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
|
|
|
-import com.ruoyi.project.training.domain.TTrainingbcc;
|
|
|
|
-import com.ruoyi.project.training.service.ITTrainingbccService;
|
|
|
|
-import com.ruoyi.framework.web.controller.BaseController;
|
|
|
|
-import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
|
-import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
-import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 装置培训跟踪bController
|
|
* 装置培训跟踪bController
|
|
@@ -37,8 +50,7 @@ import javax.annotation.Resource;
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/training/trainingbcc")
|
|
@RequestMapping("/training/trainingbcc")
|
|
-public class TTrainingbccController extends BaseController
|
|
|
|
-{
|
|
|
|
|
|
+public class TTrainingbccController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private ITTrainingbccService tTrainingbccService;
|
|
private ITTrainingbccService tTrainingbccService;
|
|
@Resource
|
|
@Resource
|
|
@@ -47,16 +59,20 @@ public class TTrainingbccController extends BaseController
|
|
private TTrainingbccMapper tTrainingbccMapper;
|
|
private TTrainingbccMapper tTrainingbccMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private ITStaffmgrService tStaffmgrService;
|
|
private ITStaffmgrService tStaffmgrService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private OfficeConvertController officeConvertController;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询装置培训跟踪b列表
|
|
* 查询装置培训跟踪b列表
|
|
*/
|
|
*/
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
- public TableDataInfo list(TTrainingbcc tTrainingbcc)
|
|
|
|
- {
|
|
|
|
|
|
+ public TableDataInfo list(TTrainingbcc tTrainingbcc) {
|
|
startPage();
|
|
startPage();
|
|
List<TTrainingbcc> list = tTrainingbccService.selectTTrainingbccList(tTrainingbcc);
|
|
List<TTrainingbcc> list = tTrainingbccService.selectTTrainingbccList(tTrainingbcc);
|
|
- for (TTrainingbcc t: list
|
|
|
|
- ) {
|
|
|
|
|
|
+ for (TTrainingbcc t : list
|
|
|
|
+ ) {
|
|
TTrainingbccDevice device = new TTrainingbccDevice();
|
|
TTrainingbccDevice device = new TTrainingbccDevice();
|
|
device.setRegularId(t.getId());
|
|
device.setRegularId(t.getId());
|
|
int all = tTrainingbccDeviceMapper.countTraining(device);
|
|
int all = tTrainingbccDeviceMapper.countTraining(device);
|
|
@@ -66,9 +82,9 @@ public class TTrainingbccController extends BaseController
|
|
t.setHaveTraining(finish);
|
|
t.setHaveTraining(finish);
|
|
t.setMustTraining(all);
|
|
t.setMustTraining(all);
|
|
if (all != 0) {
|
|
if (all != 0) {
|
|
- String per = String.valueOf(finish* 100 / all);
|
|
|
|
|
|
+ String per = String.valueOf(finish * 100 / all);
|
|
t.setTrainingPercent(per);
|
|
t.setTrainingPercent(per);
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
t.setTrainingPercent("0");
|
|
t.setTrainingPercent("0");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -81,8 +97,7 @@ public class TTrainingbccController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:export')")
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:export')")
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.EXPORT)
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.EXPORT)
|
|
@GetMapping("/export")
|
|
@GetMapping("/export")
|
|
- public AjaxResult export(TTrainingbcc tTrainingbcc)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult export(TTrainingbcc tTrainingbcc) {
|
|
List<TTrainingbcc> list = tTrainingbccService.selectTTrainingbccList(tTrainingbcc);
|
|
List<TTrainingbcc> list = tTrainingbccService.selectTTrainingbccList(tTrainingbcc);
|
|
ExcelUtil<TTrainingbcc> util = new ExcelUtil<TTrainingbcc>(TTrainingbcc.class);
|
|
ExcelUtil<TTrainingbcc> util = new ExcelUtil<TTrainingbcc>(TTrainingbcc.class);
|
|
return util.exportExcel(list, "trainingbcc");
|
|
return util.exportExcel(list, "trainingbcc");
|
|
@@ -93,8 +108,7 @@ public class TTrainingbccController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:query')")
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:query')")
|
|
@GetMapping(value = "/{id}")
|
|
@GetMapping(value = "/{id}")
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
return AjaxResult.success(tTrainingbccService.selectTTrainingbccById(id));
|
|
return AjaxResult.success(tTrainingbccService.selectTTrainingbccById(id));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -103,15 +117,14 @@ public class TTrainingbccController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:query')")
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:query')")
|
|
@GetMapping(value = "/staffIds/{id}")
|
|
@GetMapping(value = "/staffIds/{id}")
|
|
- public AjaxResult getStaffIds(@PathVariable("id") Long id)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult getStaffIds(@PathVariable("id") Long id) {
|
|
TTrainingbcc tTrainingbcc = tTrainingbccService.selectTTrainingbccById(id);
|
|
TTrainingbcc tTrainingbcc = tTrainingbccService.selectTTrainingbccById(id);
|
|
TTrainingbccDevice param = new TTrainingbccDevice();
|
|
TTrainingbccDevice param = new TTrainingbccDevice();
|
|
param.setRegularId(id);
|
|
param.setRegularId(id);
|
|
List<TTrainingbccDevice> list = tTrainingbccDeviceMapper.selectTTrainingbccDeviceList(param);
|
|
List<TTrainingbccDevice> list = tTrainingbccDeviceMapper.selectTTrainingbccDeviceList(param);
|
|
String staffIds = "";
|
|
String staffIds = "";
|
|
for (TTrainingbccDevice t : list
|
|
for (TTrainingbccDevice t : list
|
|
- ) {
|
|
|
|
|
|
+ ) {
|
|
staffIds = staffIds + "," + t.getStaffId();
|
|
staffIds = staffIds + "," + t.getStaffId();
|
|
}
|
|
}
|
|
tTrainingbcc.setStaffIds(staffIds);
|
|
tTrainingbcc.setStaffIds(staffIds);
|
|
@@ -125,8 +138,7 @@ public class TTrainingbccController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:add')")
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:add')")
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.INSERT)
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
@PostMapping
|
|
- public AjaxResult add(@RequestBody TTrainingbcc tTrainingbcc)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody TTrainingbcc tTrainingbcc) {
|
|
tTrainingbccService.insertTTrainingbcc(tTrainingbcc);
|
|
tTrainingbccService.insertTTrainingbcc(tTrainingbcc);
|
|
//培训岗位人员
|
|
//培训岗位人员
|
|
if (tTrainingbcc.getPosition() != null) {
|
|
if (tTrainingbcc.getPosition() != null) {
|
|
@@ -169,8 +181,7 @@ public class TTrainingbccController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:edit')")
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:edit')")
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.UPDATE)
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
@PutMapping
|
|
- public AjaxResult edit(@RequestBody TTrainingbcc tTrainingbcc)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult edit(@RequestBody TTrainingbcc tTrainingbcc) {
|
|
return toAjax(tTrainingbccService.updateTTrainingbcc(tTrainingbcc));
|
|
return toAjax(tTrainingbccService.updateTTrainingbcc(tTrainingbcc));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -180,8 +191,7 @@ public class TTrainingbccController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:edit')")
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:edit')")
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.UPDATE)
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.UPDATE)
|
|
@PostMapping(value = "/updateStaffIds")
|
|
@PostMapping(value = "/updateStaffIds")
|
|
- public AjaxResult updateStaffIds(@RequestBody TTrainingbcc tTrainingbcc)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult updateStaffIds(@RequestBody TTrainingbcc tTrainingbcc) {
|
|
return toAjax(tTrainingbccService.updateStaffIds(tTrainingbcc));
|
|
return toAjax(tTrainingbccService.updateStaffIds(tTrainingbcc));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -191,10 +201,9 @@ public class TTrainingbccController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:remove')")
|
|
@PreAuthorize("@ss.hasPermi('training:trainingbcc:remove')")
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.DELETE)
|
|
@Log(title = "装置培训跟踪b", businessType = BusinessType.DELETE)
|
|
- @DeleteMapping("/{ids}")
|
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
- {
|
|
|
|
- tTrainingbccDeviceMapper.deleteTTrainingbccDeviceByTrainingbcc(ids);
|
|
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
|
+ tTrainingbccDeviceMapper.deleteTTrainingbccDeviceByTrainingbcc(ids);
|
|
return toAjax(tTrainingbccService.deleteTTrainingbccByIds(ids));
|
|
return toAjax(tTrainingbccService.deleteTTrainingbccByIds(ids));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -208,7 +217,7 @@ public class TTrainingbccController extends BaseController
|
|
int year = currentDate.getYear();
|
|
int year = currentDate.getYear();
|
|
// 获取月份
|
|
// 获取月份
|
|
int month = currentDate.getMonthValue();
|
|
int month = currentDate.getMonthValue();
|
|
- String dir = "/elearn/" + year ;
|
|
|
|
|
|
+ String dir = "/elearn/" + year;
|
|
String url = FileUploadUtils.upload(RuoYiConfig.getFilePath(dir), file);
|
|
String url = FileUploadUtils.upload(RuoYiConfig.getFilePath(dir), file);
|
|
TTrainingbcc entity = tTrainingbccService.selectTTrainingbccById(id);
|
|
TTrainingbcc entity = tTrainingbccService.selectTTrainingbccById(id);
|
|
entity.setFileUrl(url);
|
|
entity.setFileUrl(url);
|
|
@@ -218,4 +227,127 @@ public class TTrainingbccController extends BaseController
|
|
}
|
|
}
|
|
return AjaxResult.error("上传失败,请联系管理员");
|
|
return AjaxResult.error("上传失败,请联系管理员");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('pssr:subcontent:export')")
|
|
|
|
+ @Log(title = "导出签名表", businessType = BusinessType.EXPORT)
|
|
|
|
+ @GetMapping("/exportSign")
|
|
|
|
+ public AjaxResult exportSign(TTrainingbcc tTrainingbcc) throws Exception {
|
|
|
|
+ TTrainingbcc tTraining = tTrainingbccMapper.selectTTrainingbccById(tTrainingbcc.getId());
|
|
|
|
+ String tempUrl = "";
|
|
|
|
+
|
|
|
|
+ // 模板路径
|
|
|
|
+ if (tTraining.getTrainingType().equals("20")) {
|
|
|
|
+ tempUrl = "static/word/training/signMOCbcc.docx"; // 模板文件
|
|
|
|
+ } else {
|
|
|
|
+ tempUrl = "static/word/training/signbcc.docx"; // 模板文件
|
|
|
|
+ }
|
|
|
|
+ //渲染文本
|
|
|
|
+ Map<String, Object> params = getWordData(tTraining);
|
|
|
|
+ // 生成word的路径
|
|
|
|
+ String fileDir = RuoYiConfig.getProfile() + "/" + "tTrainingbcc";
|
|
|
|
+ // 生成word的文件名称
|
|
|
|
+ String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss"));
|
|
|
|
+ String fileName = time + tTraining.getId() + "_" + DateUtils.getDate() + ".docx";
|
|
|
|
+ String wordPath = createWord(tempUrl, fileDir, fileName, params, "tTrainingbcc");
|
|
|
|
+ return AjaxResult.success(officeConvertController.wordTransPdf(wordPath));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Map<String, Object> getWordData(TTrainingbcc trainingbcc) {
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ TableRenderData tableRenderData = new TableRenderData();
|
|
|
|
+
|
|
|
|
+ TableStyle tableStyle = new TableStyle();
|
|
|
|
+ tableStyle.setWidth("100%");
|
|
|
|
+ tableStyle.setColWidths(new int[]{8, 10, 10, 12, 10, 8, 10, 10, 12, 10});
|
|
|
|
+ tableRenderData.setTableStyle(tableStyle);
|
|
|
|
+
|
|
|
|
+ // 创建表头行
|
|
|
|
+ RowRenderData row1 = Rows.of("序号", "姓名", "部门", "签名", "日期", "序号", "姓名", "部门", "签名", "日期").center().textBold().rowExactHeight(1.1f).create();
|
|
|
|
+ tableRenderData.addRow(row1);
|
|
|
|
+
|
|
|
|
+ int plant = 0, ctm = 0, cta = 0, count = 1;
|
|
|
|
+ PictureRenderData plantMgr = null;
|
|
|
|
+ TTrainingbccDevice tTrainingbccDevice = new TTrainingbccDevice();
|
|
|
|
+ tTrainingbccDevice.setRegularId(trainingbcc.getId());
|
|
|
|
+ List<TTrainingbccDevice> list = tTrainingbccDeviceMapper.selectTTrainingbccDeviceList(tTrainingbccDevice);
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
+ //如果当前行为偶数,直接开始下一行
|
|
|
|
+ if (i % 2 != 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ TTrainingbccDevice device = list.get(i);
|
|
|
|
+ TTrainingbccDevice device2 = null;
|
|
|
|
+ if (i < list.size() - 1) {
|
|
|
|
+ device2 = list.get(i + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysUser user1 = sysUserMapper.selectUserByStaffId(device.getStaffId());
|
|
|
|
+ SysUser user2 = null;
|
|
|
|
+ if (device2 != null) {
|
|
|
|
+ user2 = sysUserMapper.selectUserByStaffId(device2.getStaffId());
|
|
|
|
+ }
|
|
|
|
+ RowRenderData row = null;
|
|
|
|
+ String lineNum="";
|
|
|
|
+ String lineNum2="";
|
|
|
|
+ // 创建数据行
|
|
|
|
+ lineNum = String.valueOf(i + 1);
|
|
|
|
+ lineNum2 = String.valueOf(i + 2);
|
|
|
|
+
|
|
|
|
+ if (device2!=null)
|
|
|
|
+ row = Rows.of(lineNum, device.getName(), "CBP/C", "", DateUtils.dateTime(device.getStartDate()),
|
|
|
|
+ lineNum2, device2.getName(), "CBP/C", "", DateUtils.dateTime(device2.getStartDate())).verticalCenter().textFontSize(8).rowExactHeight(1.1f).create();
|
|
|
|
+ else
|
|
|
|
+ row = Rows.of(lineNum, device.getName(), "CBP/C", "", DateUtils.dateTime(device.getStartDate()),
|
|
|
|
+ "", "", "", "", "").verticalCenter().horizontalCenter().textFontSize(8).rowExactHeight(1.1f).create();
|
|
|
|
+ if (device.getExamState() == 1) {
|
|
|
|
+ if (user1 != null)
|
|
|
|
+ row.getCells().set(3, new CellRenderData().addParagraph(new ParagraphRenderData().addPicture(Pictures.ofLocal(FileUtils.fileName(user1.getSignUrl())).size(60, 20).create())));
|
|
|
|
+ }
|
|
|
|
+ if (device2!=null&&device2.getExamState() == 1) {
|
|
|
|
+ if (user2 != null)
|
|
|
|
+ row.getCells().set(8, new CellRenderData().addParagraph(new ParagraphRenderData().addPicture(Pictures.ofLocal(FileUtils.fileName(user2.getSignUrl())).size(60, 20).create())));
|
|
|
|
+ }
|
|
|
|
+ tableRenderData.addRow(row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 准备表格数据和其他参数
|
|
|
|
+ params.put("course", trainingbcc.getCourse());
|
|
|
|
+ params.put("table1", tableRenderData);
|
|
|
|
+
|
|
|
|
+ return params;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private String createWord(String templatePath, String fileDir, String fileName, Map<String, Object> paramMap, String directory) throws IOException {
|
|
|
|
+ Assert.notNull(templatePath, "word模板文件路径不能为空");
|
|
|
|
+ Assert.notNull(fileDir, "生成的文件存放地址不能为空");
|
|
|
|
+ Assert.notNull(fileName, "生成的文件名不能为空");
|
|
|
|
+ File dir = new File(fileDir);
|
|
|
|
+ if (!dir.exists()) {
|
|
|
|
+ logger.info("目录不存在,创建文件夹{}!", fileDir);
|
|
|
|
+ dir.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ fileName = fileName.replaceAll("/", "_"); //替换文件中敏感字段
|
|
|
|
+ logger.info("目录文件{}!", fileName);
|
|
|
|
+ String filePath = fileDir + "/" + fileName;
|
|
|
|
+ logger.info("目录{}!", filePath);
|
|
|
|
+ logger.info("模板{}!", templatePath);
|
|
|
|
+ // 读取模板渲染参数
|
|
|
|
+ InputStream is = getClass().getClassLoader().getResourceAsStream(templatePath);
|
|
|
|
+
|
|
|
|
+ XWPFTemplate template = XWPFTemplate.compile(is).render(paramMap);
|
|
|
|
+ try {
|
|
|
|
+ // 将模板参数写入路径
|
|
|
|
+ template.writeToFile(filePath);
|
|
|
|
+ template.close();
|
|
|
|
+ is.close();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("生成word异常{}", e.getMessage());
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ String pathFileName = FileUploadUtils.getPathFileName(RuoYiConfig.getFilePath("/" + directory), fileName);
|
|
|
|
+ return pathFileName;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|