فهرست منبع

LY 苯乙烯 签名表

ly 2 سال پیش
والد
کامیت
2ebe2bcba4

+ 244 - 102
master/src/main/java/com/ruoyi/project/training/controller/TTrainingController.java

@@ -7,11 +7,13 @@ import java.util.*;
 
 import com.alibaba.fastjson.JSON;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.DictUtils;
 import com.ruoyi.common.utils.file.ExcelUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.poi.CustomXWPFDocument;
 import com.ruoyi.framework.config.RuoYiConfig;
 import com.ruoyi.project.plant.domain.TStaffmgr;
+import com.ruoyi.project.plant.mapper.TStaffmgrMapper;
 import com.ruoyi.project.plant.service.ITStaffmgrService;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.domain.SysDictData;
@@ -27,6 +29,9 @@ import com.ruoyi.project.training.service.ITTrainingRegularService;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xwpf.usermodel.*;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,8 +58,7 @@ import javax.servlet.http.HttpServletResponse;
  */
 @RestController
 @RequestMapping("/training/training")
-public class TTrainingController extends BaseController
-{
+public class TTrainingController extends BaseController {
     @Autowired
     private ITTrainingService tTrainingService;
 
@@ -72,7 +76,8 @@ public class TTrainingController extends BaseController
 
     @Resource
     private TTrainingMapper tTrainingMapper;
-
+    @Resource
+    private TStaffmgrMapper tStaffmgrMapper;
     @Autowired
     private ITStaffmgrService tStaffmgrService;
 
@@ -84,8 +89,7 @@ public class TTrainingController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('training:training:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TTraining tTraining)
-    {
+    public TableDataInfo list(TTraining tTraining) {
         startPage();
         List<TTraining> list = tTrainingService.selectTTrainingList(tTraining);
         logger.info("====1111111::::::" + list.size());
@@ -118,8 +122,7 @@ public class TTrainingController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:training:export')")
     @Log(title = "培训计划", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
-    public AjaxResult export(TTraining tTraining)
-    {
+    public AjaxResult export(TTraining tTraining) {
         List<TTraining> list = tTrainingService.selectTTrainingList(tTraining);
         ExcelUtil<TTraining> util = new ExcelUtil<TTraining>(TTraining.class);
         return util.exportExcel(list, "training");
@@ -130,8 +133,7 @@ public class TTrainingController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('training:training:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return AjaxResult.success(tTrainingService.selectTTrainingById(id));
     }
 
@@ -141,8 +143,7 @@ public class TTrainingController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:training:add')")
     @Log(title = "培训计划", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TTraining tTraining)
-    {
+    public AjaxResult add(@RequestBody TTraining tTraining) {
         tTraining.setCreaterCode(getUserId().toString());
         int doInsert = tTrainingService.insertTTraining(tTraining);
         //培训岗位人员
@@ -156,15 +157,15 @@ public class TTrainingController extends BaseController
                     Iterator<TStaffmgr> iterator = trainingStaff.iterator();
                     while (iterator.hasNext()) {
                         TStaffmgr t = iterator.next();
-                        if (t.getLeftDate() != null && t.getDelFlag() == 9){
-                            if (t.getLeftDate().getTime() - tTraining.getStartDate().getTime() < 0l ) {
+                        if (t.getLeftDate() != null && t.getDelFlag() == 9) {
+                            if (t.getLeftDate().getTime() - tTraining.getStartDate().getTime() < 0l) {
                                 logger.debug(t.getName() + "离职时间小于培训时间");
                                 iterator.remove();
                             }
                         }
                     }
                 }
-            }catch (Exception e) {
+            } catch (Exception e) {
                 logger.error(e.toString());
             }
             for (TStaffmgr staff : trainingStaff) {
@@ -177,7 +178,7 @@ public class TTrainingController extends BaseController
             }
         }
         if (tTraining.getDesignatedStaff() != null) {
-            String[] designated  = tTraining.getDesignatedStaff().split(",");
+            String[] designated = tTraining.getDesignatedStaff().split(",");
             for (String staffid : designated) {
                 TStaffmgr staffmgr = tStaffmgrService.selectTStaffmgrByStaffId(staffid);
                 TTrainingDevice tTrainingDevice = new TTrainingDevice();
@@ -197,22 +198,21 @@ public class TTrainingController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:training:edit')")
     @Log(title = "培训计划", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TTraining tTraining)
-    {
+    public AjaxResult edit(@RequestBody TTraining tTraining) {
         tTraining.setUpdaterCode(getUserId().toString());
         tTraining.setUpdatedate(new Date());
         //查找跟这条培训计划相关联的装置级培训记录   修改其培训的年份,课程名称和课程代码
         //如果是定期类 就修改下培训计划里面的内容
-        if(tTraining.getTrainingType().equals("10")){
+        if (tTraining.getTrainingType().equals("10")) {
             if (tTraining.getRegularId() == null) {
                 logger.info("没有对应培训计划");
-            }else {
-                TTrainingRegular t= tTrainingRegularService.selectTTrainingRegularById(tTraining.getRegularId());
+            } else {
+                TTrainingRegular t = tTrainingRegularService.selectTTrainingRegularById(tTraining.getRegularId());
                 t.setItem(tTraining.getCourse());
                 t.setCourseCode(tTraining.getCourseid());
                 t.setYear(tTraining.getYear());
                 t.setDelFlag(tTraining.getDelFlag());
-                int result=   tTrainingRegularService.updateTTrainingRegular(t );
+                int result = tTrainingRegularService.updateTTrainingRegular(t);
             }
         }
         TTraining oldTraining = tTrainingService.selectTTrainingById(tTraining.getId());
@@ -221,7 +221,7 @@ public class TTrainingController extends BaseController
             if (!oldTraining.getPosition().equals(tTraining.getPosition())) {
                 i = 1;
             }
-        }else {
+        } else {
             if (tTraining.getPosition() != null) {
                 i = 1;
             }
@@ -230,12 +230,12 @@ public class TTrainingController extends BaseController
             if (!oldTraining.getDesignatedStaff().equals(tTraining.getDesignatedStaff())) {
                 i = 1;
             }
-        }else {
+        } else {
             if (tTraining.getDesignatedStaff() != null) {
                 i = 1;
             }
         }
-        if (tTraining.getStartDate()!= null) {
+        if (tTraining.getStartDate() != null) {
             logger.info("修改了时间");
             i = 1;
         }
@@ -258,15 +258,15 @@ public class TTrainingController extends BaseController
                         Iterator<TStaffmgr> iterator = trainingStaff.iterator();
                         while (iterator.hasNext()) {
                             TStaffmgr t = iterator.next();
-                            if (t.getLeftDate() != null && t.getDelFlag() == 9){
-                                if (t.getLeftDate().getTime() - tTraining.getStartDate().getTime() < 0l ) {
+                            if (t.getLeftDate() != null && t.getDelFlag() == 9) {
+                                if (t.getLeftDate().getTime() - tTraining.getStartDate().getTime() < 0l) {
                                     logger.debug(t.getName() + "离职时间小于培训时间");
                                     iterator.remove();
                                 }
                             }
                         }
                     }
-                }catch (Exception e) {
+                } catch (Exception e) {
                     logger.error(e.toString());
                 }
                 for (TStaffmgr staff : trainingStaff) {
@@ -279,7 +279,7 @@ public class TTrainingController extends BaseController
                 }
             }
             if (tTraining.getDesignatedStaff() != null) {
-                String[] designated  = tTraining.getDesignatedStaff().split(",");
+                String[] designated = tTraining.getDesignatedStaff().split(",");
                 for (String staffid : designated) {
                     TStaffmgr staffmgr = tStaffmgrService.selectTStaffmgrByStaffId(staffid);
                     TTrainingDevice tTrainingDevice = new TTrainingDevice();
@@ -299,9 +299,8 @@ public class TTrainingController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('training:training:remove')")
     @Log(title = "培训计划", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         for (Long id : ids) {
             TTraining training = tTrainingService.selectTTrainingById(id);
             if (training.getPosition() != null || training.getDesignatedStaff() != null) {
@@ -318,10 +317,8 @@ public class TTrainingController extends BaseController
      */
     @Log(title = "培训计划图片上传", businessType = BusinessType.UPDATE)
     @PostMapping("/uploadFile")
-    public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) throws IOException
-    {
-        if (!file.isEmpty())
-        {
+    public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
+        if (!file.isEmpty()) {
             String avatar = FileUploadUtils.upload(RuoYiConfig.getFilePath("/trainingMOC"), file);
             return AjaxResult.success(avatar);
         }
@@ -334,12 +331,11 @@ public class TTrainingController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:trainingrecords:add')")
     @Log(title = "培训成绩", businessType = BusinessType.INSERT)
     @PostMapping("/importData")
-    public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException
-    {
+    public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
         //获取操作人员ID
         Long userId = getUserId();
         //报错行数统计
-        List<Integer> failRow =new ArrayList<Integer>();
+        List<Integer> failRow = new ArrayList<Integer>();
         Workbook workbook = ExcelUtils.getWorkBook(file);
         Sheet sheet = workbook.getSheetAt(0);
         List<TTraining> list = new ArrayList<TTraining>();
@@ -397,7 +393,7 @@ public class TTrainingController extends BaseController
                                 if (p.getDictLabel().equals(units[num].trim())) {
                                     if (num == 0) {
                                         unit = p.getDictValue();
-                                    }else {
+                                    } else {
                                         unit = unit + "," + p.getDictValue();
                                     }
                                 }
@@ -412,7 +408,7 @@ public class TTrainingController extends BaseController
                                 if (p.getDictLabel().equals(positionName[num].trim())) {
                                     if (num == 0) {
                                         position = p.getDictValue();
-                                    }else {
+                                    } else {
                                         position = position + "," + p.getDictValue();
                                     }
                                 }
@@ -433,7 +429,7 @@ public class TTrainingController extends BaseController
                                 entity.setIsfinish(Long.parseLong(p.getDictValue()));//是否完成
                             }
                         }
-                    }else if (j == 13) {
+                    } else if (j == 13) {
                         for (SysDept d : dept) {
                             if (d.getDeptName().equals(cellValue)) {
                                 entity.setDeptId(d.getDeptId());//部门编号
@@ -446,9 +442,9 @@ public class TTrainingController extends BaseController
                 entity.setCreaterCode(userId.toString());
                 logger.info("entity:" + entity);
                 list.add(entity);
-            }catch (Exception e){
+            } catch (Exception e) {
                 failNumber++;
-                failRow.add(i+1);
+                failRow.add(i + 1);
             }
         }
         int successNumber = 0;
@@ -459,15 +455,15 @@ public class TTrainingController extends BaseController
             try {
                 tTrainingService.insertTTraining(t);
                 successNumber++;
-            }catch (Exception e){
+            } catch (Exception e) {
                 failNumber++;
-                failRow.add(failNum+1);
+                failRow.add(failNum + 1);
             }
         }
         logger.info("list:" + JSON.toJSONString(list));
-        logger.info("successNumber:" +String.valueOf(successNumber));
-        logger.info("failNumber:" +String.valueOf(failNumber));
-        logger.info("failRow:" +String.valueOf(failRow));
+        logger.info("successNumber:" + String.valueOf(successNumber));
+        logger.info("failNumber:" + String.valueOf(failNumber));
+        logger.info("failRow:" + String.valueOf(failRow));
         return AjaxResult.success(String.valueOf(successNumber), failRow);
     }
 
@@ -476,63 +472,207 @@ public class TTrainingController extends BaseController
      */
     @RequestMapping(value = "/trainingReport", produces = "application/json;charset=utf-8")
     @ResponseBody
-    public void AutoReport(HttpServletRequest request, HttpServletResponse response, Long year , Long trainingId) {
-        logger.info("trainingId:" + trainingId);
-        String savePath = request.getSession().getServletContext().getRealPath("/"); // 系统根路径
+    public void AutoReport(HttpServletRequest request, HttpServletResponse response, Long year, Long trainingId) {
         TTraining tTraining = tTrainingMapper.selectTTrainingById(trainingId);
         String tempUrl = "";
-        if (tTraining.getDeptId()== 103){
+        if (tTraining.getDeptId() == 103) {
             if (tTraining.getTrainingType().equals("12")) {
                 tempUrl = "static/word/training/signMOC.docx"; // 模板文件
-            }else {
+            } else {
                 tempUrl = "static/word/training/sign.docx"; // 模板文件
             }
-        }else {
-            tempUrl = "static/word/training/signBYX.docx"; // 模板文件
+            // 保存结果文
+            InputStream is = null;
+            try {
+                is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
+                CustomXWPFDocument doc = new CustomXWPFDocument(is);
+                // 替换word模板数据
+                replaceAll(doc, year, trainingId);
+
+                response.setContentType("application/octet-stream");// 下载,默认就是下载
+                response.setCharacterEncoding("UTF-8");
+                response.setHeader("Content-Disposition",
+                        "attachment;fileName=" + URLEncoder.encode(tTraining.getCourse() + ".docx", "UTF-8"));
+                // 刷新缓冲
+                response.flushBuffer();
+                OutputStream ouputStream = response.getOutputStream();
+                doc.write(ouputStream);
+                ouputStream.flush();
+                ouputStream.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        } else {
+            try {
+                tempUrl = "static/word/training/signBYX.xlsx"; // 模板文件
+                InputStream is = null;
+                is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
+                XSSFWorkbook wb1 = new XSSFWorkbook(is);
+                SXSSFWorkbook wb = new SXSSFWorkbook(wb1, 1000);
+                // 替换excel模板数据
+                replaceExcel(wb, trainingId);
+                response.setContentType("application/octet-stream");// 下载,默认就是下载
+                response.setCharacterEncoding("UTF-8");
+                response.setHeader("Content-Disposition",
+                        "attachment;fileName=" + URLEncoder.encode(tTraining.getCourse() + ".xlsx", "UTF-8"));
+                // 刷新缓冲
+                response.flushBuffer();
+                OutputStream ouputStream = response.getOutputStream();
+                wb.write(ouputStream);
+                ouputStream.flush();
+                ouputStream.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
         }
 
-        // 保存结果文
-        InputStream is = null;
+    }
+
+    //苯乙烯 Excel 渲染
+    private void replaceExcel(SXSSFWorkbook wb, Long trainingId) {
+        Sheet sheet = wb.getSheet("sheet1");
+        TTraining tTraining = tTrainingMapper.selectTTrainingById(trainingId);
+        TStaffmgr tStaffmgr = new TStaffmgr();
+        tStaffmgr.setActualposts(tTraining.getPosition());
+        tStaffmgr.setDeptId(tTraining.getDeptId());
+        List<TStaffmgr> staffmgrList = tStaffmgrMapper.selectAllTStaffmgrList(tStaffmgr);
+        List<SysDictData> dictList = iSysDictTypeService.selectDictDataByType("STAFF_UNIT");
         try {
-            is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
-            CustomXWPFDocument doc = new CustomXWPFDocument(is);
-            // 替换word模板数据
-            replaceAll(doc,year,trainingId);
-
-            response.setContentType("application/octet-stream");// 下载,默认就是下载
-            response.setCharacterEncoding("UTF-8");
-            response.setHeader("Content-Disposition",
-                    "attachment;fileName=" + URLEncoder.encode(tTraining.getCourse() + ".docx", "UTF-8"));
-            // 刷新缓冲
-            response.flushBuffer();
-            OutputStream ouputStream = response.getOutputStream();
-            doc.write(ouputStream);
-            ouputStream.flush();
-            ouputStream.close();
+            //判断离职
+            if (!org.apache.commons.lang.StringUtils.isEmpty(tTraining.getYear())) {
+                Iterator<TStaffmgr> iterator = staffmgrList.iterator();
+                while (iterator.hasNext()) {
+                    TStaffmgr t = iterator.next();
+                    if (t.getLeftDate() != null && t.getDelFlag() == 9) {
+                        if (t.getLeftDate().getTime() - tTraining.getStartDate().getTime() < 0l) {
+                            iterator.remove();
+                        }
+                    }
+                }
+            }
         } catch (Exception e) {
-            e.printStackTrace();
         }
+        List<TStaffmgr> staffmgrs = new ArrayList<TStaffmgr>();
+        if (tTraining.getDesignatedStaff() != null) { //判断指定人员
+            String[] staffIds = tTraining.getDesignatedStaff().split(",");
+            for (int i = 0; i < staffIds.length; i++) {
+                TStaffmgr staffmgr = tStaffmgrMapper.selectTStaffmgrByStaffId(staffIds[i]);
+                staffmgrs.add(staffmgr);
+            }
+            staffmgrList.addAll(staffmgrs);
+        }
+        //设置style
+        CellStyle cellStyle = wb.createCellStyle();
+        //设置水平对齐方式
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+        //设置垂直对齐方式
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle.setBorderRight(BorderStyle.THIN);//右边框
+        //设置上边框线条颜色
+        cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
+        //设置右边框线条颜色
+        cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        //设置下边框线条颜色
+        cellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        //设置左边框线条颜色
+        cellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        //字体
+        Font headerFont = wb.createFont();
+        headerFont.setFontName("Arial");
+        headerFont.setFontHeightInPoints((short) 11);
+        cellStyle.setFont(headerFont);
+        int rowIndex = 7;//初始行数
+        for (int i = 0; i < staffmgrList.size(); i++) { //加载签名数据
+            Row row = sheet.createRow(rowIndex);
+            row.setHeight((short) 400);
+            row.createCell(0).setCellValue(i + 1);
+            row.getCell(0).setCellStyle(cellStyle);
+            row.createCell(1).setCellValue(DictUtils.getDictVale(dictList, staffmgrList.get(i).getUnit()));
+            row.getCell(1).setCellStyle(cellStyle);
+            row.createCell(2).setCellValue(staffmgrList.get(i).getStaffid());
+            row.getCell(2).setCellStyle(cellStyle);
+            row.createCell(3).setCellValue(staffmgrList.get(i).getName());
+            row.getCell(3).setCellStyle(cellStyle);
+            row.createCell(4).setCellStyle(cellStyle);
+            row.createCell(5).setCellStyle(cellStyle);
+            if (i + 1 < staffmgrList.size()) {
+                row.createCell(6).setCellValue(i + 2);
+                row.getCell(6).setCellStyle(cellStyle);
+                row.createCell(7).setCellValue(DictUtils.getDictVale(dictList, staffmgrList.get(i + 1).getUnit()));
+                row.getCell(7).setCellStyle(cellStyle);
+                row.createCell(8).setCellValue(staffmgrList.get(i + 1).getStaffid());
+                row.getCell(8).setCellStyle(cellStyle);
+                row.createCell(9).setCellValue(staffmgrList.get(i + 1).getName());
+                row.getCell(9).setCellStyle(cellStyle);
+                row.createCell(10).setCellStyle(cellStyle);
+                row.createCell(11).setCellStyle(cellStyle);
+            }
+            i++;
+            rowIndex++;
+        }
+        sheet.addMergedRegionUnsafe(new CellRangeAddress(rowIndex, rowIndex, 0, 1));
+        sheet.addMergedRegionUnsafe(new CellRangeAddress(rowIndex, rowIndex, 2, 11));
+        // 最后一行
+        Row rowLast = sheet.createRow(rowIndex);
+        rowLast.setHeight((short) 3000);
+        rowLast.createCell(0).setCellValue("培训有效性");
+        rowLast.getCell(0).setCellStyle(cellStyle);
+        //设置style
+        CellStyle lastStyle = wb.createCellStyle();
+        //设置水平对齐方式
+        lastStyle.setAlignment(HorizontalAlignment.CENTER);
+        //设置垂直对齐方式
+        lastStyle.setVerticalAlignment(VerticalAlignment.BOTTOM);
+        lastStyle.setBorderBottom(BorderStyle.THIN); //下边框
+        lastStyle.setBorderLeft(BorderStyle.THIN);//左边框
+        lastStyle.setBorderTop(BorderStyle.THIN);//上边框
+        lastStyle.setBorderRight(BorderStyle.THIN);//右边框
+        //设置上边框线条颜色
+        lastStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
+        //设置右边框线条颜色
+        lastStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        //设置下边框线条颜色
+        lastStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        //设置左边框线条颜色
+        lastStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        lastStyle.setFont(headerFont);
+        rowLast.createCell(2).setCellValue("                                                                                                                                                          签名:");
+        rowLast.getCell(2).setCellStyle(lastStyle);
+        rowLast.createCell(1).setCellStyle(cellStyle);
+        rowLast.createCell(3).setCellStyle(cellStyle);
+        rowLast.createCell(4).setCellStyle(cellStyle);
+        rowLast.createCell(5).setCellStyle(cellStyle);
+        rowLast.createCell(6).setCellStyle(cellStyle);
+        rowLast.createCell(7).setCellStyle(cellStyle);
+        rowLast.createCell(8).setCellStyle(cellStyle);
+        rowLast.createCell(9).setCellStyle(cellStyle);
+        rowLast.createCell(10).setCellStyle(cellStyle);
+        rowLast.createCell(11).setCellStyle(cellStyle);
     }
+
     /**
      * @Description: 替换段落和表格
      */
-    private void replaceAll(CustomXWPFDocument doc, Long year,Long meetingId) throws Exception {
-        doParagraphs(doc,meetingId);// 处理段落文字数据,包括文字和表格、图片
+    private void replaceAll(CustomXWPFDocument doc, Long year, Long meetingId) throws Exception {
+        doParagraphs(doc, meetingId);// 处理段落文字数据,包括文字和表格、图片
     }
 
     /**
      * 处理段落文字数据,包括文字和表格、图片
      *
-     * @param doc
-     *            一个文档包含多个段落,一个段落包含多个Runs,一个Runs包含多个Run,Run是文档的最小单元
+     * @param doc 一个文档包含多个段落,一个段落包含多个Runs,一个Runs包含多个Run,Run是文档的最小单元
      */
-    private void doParagraphs(CustomXWPFDocument doc,Long trainingId) throws IOException, InvalidFormatException {
+    private void doParagraphs(CustomXWPFDocument doc, Long trainingId) throws IOException, InvalidFormatException {
         // 文本数据
         Calendar cal = Calendar.getInstance();
         Map<String, String> textMap = new HashMap<String, String>();
         TTraining tTraining = tTrainingService.selectTTrainingById(trainingId);
 
-        textMap.put("{{course}}", "        "+String.valueOf(tTraining.getCourse()));
+        textMap.put("{{course}}", "        " + String.valueOf(tTraining.getCourse()));
         //
         /**
          * 替换表格中指定的文字
@@ -541,7 +681,7 @@ public class TTrainingController extends BaseController
         int i = 1;
         while (itTable.hasNext()) {
             XWPFTable table = (XWPFTable) itTable.next();
-            changeTableMessage(textMap , table ,false ,null,i ,doc ,tTraining);
+            changeTableMessage(textMap, table, false, null, i, doc, tTraining);
             i++;
         }
         /** ----------------------------处理段落------------------------------------ **/
@@ -564,13 +704,14 @@ public class TTrainingController extends BaseController
                          * ----------------------------替换表格数据
                          * ------------------------------------
                          **/
-                        doJLParagraphs(doc, paragraph, run, tempText,trainingId);// 处理段落文字数据,包括文字和表格、图片
+                        doJLParagraphs(doc, paragraph, run, tempText, trainingId);// 处理段落文字数据,包括文字和表格、图片
                     }
                 }
             }
         }
 
     }
+
     private void changeTableMessage(Map<String, String> textMap, XWPFTable table, boolean isBold, Integer fontSize, int num, CustomXWPFDocument doc, TTraining tTraining) throws IOException, InvalidFormatException {
         int count = table.getNumberOfRows();//获取table的行数
         //插入图片测试
@@ -582,43 +723,42 @@ public class TTrainingController extends BaseController
             for (XWPFTableCell cell : cells) {//遍历每行的值并进行替换
                 logger.info(cell.getText() + ":::::");
                 for (Map.Entry<String, String> e : textMap.entrySet()) {
-                    if (cell.getText().equals("${picture1}")){
+                    if (cell.getText().equals("${picture1}")) {
                         cell.removeParagraph(0);
                         //拆入图片
-                        if (tTraining.getPicUrl() !=null){
+                        if (tTraining.getPicUrl() != null) {
                             String[] picList = tTraining.getPicUrl().split(",");
                             logger.info(tTraining.getPicUrl());
                             logger.info(JSON.toJSONString(picList));
-                            for (int j = 0; j < picList.length ; j++) {
+                            for (int j = 0; j < picList.length; j++) {
                                 XWPFParagraph newPara = new XWPFParagraph(cell.getCTTc().addNewP(), cell);
                                 cell.addParagraph(newPara);
-                                Map<String,Object> header = new HashMap<String, Object>();
+                                Map<String, Object> header = new HashMap<String, Object>();
                                 header.put("width", 500);
                                 header.put("height", 500);
                                 if (picList[j].endsWith("jpg")) {
                                     header.put("type", "jpg");
-                                }else if (picList[j].endsWith("png")) {
+                                } else if (picList[j].endsWith("png")) {
                                     header.put("type", "png");
                                 }
-                                header.put("content", RuoYiConfig.getProfile() + picList[j].replace("/profile" ,""));
-                                String imgUrl = (String)((Map<?, ?>) header).get("content");
-                                String type = (String)((Map<?, ?>) header).get("type");
+                                header.put("content", RuoYiConfig.getProfile() + picList[j].replace("/profile", ""));
+                                String imgUrl = (String) ((Map<?, ?>) header).get("content");
+                                String type = (String) ((Map<?, ?>) header).get("type");
                                 int width = (Integer) ((Map<?, ?>) header).get("width");
                                 int height = (Integer) ((Map<?, ?>) header).get("height");
                                 String blipId = doc.addPictureData(new FileInputStream(new File(imgUrl)), getPictureType(type));
-                                doc.createPicture(blipId,doc.getNextPicNameNumber(getPictureType(type)), width, height,newPara);
+                                doc.createPicture(blipId, doc.getNextPicNameNumber(getPictureType(type)), width, height, newPara);
                             }
                         }
 
-                    }
-                    else if (cell.getText().equals(e.getKey())) {
+                    } else if (cell.getText().equals(e.getKey())) {
                         XWPFParagraph newPara = new XWPFParagraph(cell.getCTTc().addNewP(), cell);
                         XWPFRun r1 = newPara.createRun();
-                        if (num == 1){
+                        if (num == 1) {
                             r1.setFontSize(10);
                             r1.setTextPosition(10);
                             r1.setBold(true);
-                        }else if (num == 2){
+                        } else if (num == 2) {
                             r1.setFontSize(13);
                             r1.setTextPosition(10);
                         }
@@ -630,6 +770,7 @@ public class TTrainingController extends BaseController
             }
         }
     }
+
     /**
      * 处理段落文字--经理
      *
@@ -641,27 +782,28 @@ public class TTrainingController extends BaseController
     public void doJLParagraphs(CustomXWPFDocument doc, XWPFParagraph paragraph, XWPFRun run, String text, Long meetingId) {
         // 执行表
         if (text.contains("${table1}")) {
-            tTrainingService.dealTraininglist(doc, paragraph, run,meetingId);
+            tTrainingService.dealTraininglist(doc, paragraph, run, meetingId);
         }
     }
 
     /**
      * 根据图片类型,取得对应的图片类型代码
+     *
      * @param picType
      * @return int
      */
-    private static int getPictureType(String picType){
+    private static int getPictureType(String picType) {
         int res = CustomXWPFDocument.PICTURE_TYPE_PICT;
-        if(picType != null){
-            if(picType.equalsIgnoreCase("png")){
+        if (picType != null) {
+            if (picType.equalsIgnoreCase("png")) {
                 res = CustomXWPFDocument.PICTURE_TYPE_PNG;
-            }else if(picType.equalsIgnoreCase("dib")){
+            } else if (picType.equalsIgnoreCase("dib")) {
                 res = CustomXWPFDocument.PICTURE_TYPE_DIB;
-            }else if(picType.equalsIgnoreCase("emf")){
+            } else if (picType.equalsIgnoreCase("emf")) {
                 res = CustomXWPFDocument.PICTURE_TYPE_EMF;
-            }else if(picType.equalsIgnoreCase("jpg") || picType.equalsIgnoreCase("jpeg")){
+            } else if (picType.equalsIgnoreCase("jpg") || picType.equalsIgnoreCase("jpeg")) {
                 res = CustomXWPFDocument.PICTURE_TYPE_JPEG;
-            }else if(picType.equalsIgnoreCase("wmf")){
+            } else if (picType.equalsIgnoreCase("wmf")) {
                 res = CustomXWPFDocument.PICTURE_TYPE_WMF;
             }
         }

BIN
master/src/main/resources/static/word/training/signBYX.xlsx