|
@@ -3,14 +3,17 @@ package com.ruoyi.project.sems.safecheck.controller;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.util.*;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
import com.deepoove.poi.data.Pictures;
|
|
|
import com.deepoove.poi.data.Texts;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.document.ZipUtil;
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
import com.ruoyi.framework.config.RuoYiConfig;
|
|
|
import com.ruoyi.project.approve.damain.DevTask;
|
|
@@ -22,6 +25,7 @@ import com.ruoyi.project.listener.semsWeekCheck.SafeAdminTaskCreateListener;
|
|
|
import com.ruoyi.project.listener.semsWeekCheck.SafeDirTaskCreateListener;
|
|
|
import com.ruoyi.project.listener.semsWeekCheck.WeekcheckEndFailListener;
|
|
|
import com.ruoyi.project.listener.semsWeekCheck.WeekcheckEndSuccessListener;
|
|
|
+import com.ruoyi.project.officeConvert.OfficeConvertController;
|
|
|
import com.ruoyi.project.sems.safecheck.domain.TSpecDailycheck;
|
|
|
import com.ruoyi.project.system.domain.SysUser;
|
|
|
import com.ruoyi.project.system.service.ISysUserService;
|
|
@@ -35,14 +39,7 @@ import org.activiti.engine.runtime.ProcessInstance;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+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.sems.safecheck.domain.TSpecWeekcheck;
|
|
@@ -52,6 +49,9 @@ import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
/**
|
|
|
* 每周安全排查Controller
|
|
|
*
|
|
@@ -72,6 +72,8 @@ public class TSpecWeekcheckController extends BaseController
|
|
|
private TaskService taskService;
|
|
|
@Autowired
|
|
|
private ISysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
+ private OfficeConvertController officeConvertController;
|
|
|
/**
|
|
|
* 查询每周安全排查列表
|
|
|
*/
|
|
@@ -117,6 +119,8 @@ public class TSpecWeekcheckController extends BaseController
|
|
|
{
|
|
|
long userId = getUserId();
|
|
|
tSpecWeekcheck.setCreaterCode(userId);
|
|
|
+ tSpecWeekcheck.setSafeAdminId(String.valueOf(userId));
|
|
|
+ tSpecWeekcheck.setSafeAdminDate(tSpecWeekcheck.getCheckDate());
|
|
|
|
|
|
SysUser admin = sysUserService.selectUserById(Long.valueOf(tSpecWeekcheck.getSafeAdminId()));
|
|
|
tSpecWeekcheck.setSafeAdminName(admin.getNickName());
|
|
@@ -127,10 +131,8 @@ public class TSpecWeekcheckController extends BaseController
|
|
|
//开始工作流、监听
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
|
|
|
- variables.put("safeAdmin", tSpecWeekcheck.getSafeAdminId());
|
|
|
variables.put("safeDir", tSpecWeekcheck.getSafeDirId());
|
|
|
|
|
|
- variables.put("safeAdminTaskCreateListener", new SafeAdminTaskCreateListener());
|
|
|
variables.put("safeDirTaskCreateListener", new SafeDirTaskCreateListener());
|
|
|
variables.put("weekcheckEndFailListener", new WeekcheckEndFailListener());
|
|
|
variables.put("weekcheckEndSuccessListener", new WeekcheckEndSuccessListener());
|
|
@@ -167,6 +169,55 @@ public class TSpecWeekcheckController extends BaseController
|
|
|
return toAjax(tSpecWeekcheckService.deleteTSpecWeekcheckByIds(ids));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @RequestMapping("/downloadWeekcheck")
|
|
|
+ public AjaxResult downloadDailycheck(@RequestParam String id, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
+ String[] ids = id.split(",");
|
|
|
+ OutputStream out = null;
|
|
|
+ out = response.getOutputStream();
|
|
|
+ //存放所有文件路径
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ String url = PreView(Long.parseLong(ids[i]));
|
|
|
+ // 将路径字符串转换为Path对象
|
|
|
+ Path path = Paths.get(url);
|
|
|
+ // 获取文件名
|
|
|
+ String fileName = path.getFileName().toString();
|
|
|
+ list.add(fileName);
|
|
|
+ }
|
|
|
+ logger.info(JSON.toJSONString(list));
|
|
|
+ return ZipUtil.createZip(RuoYiConfig.getProfile() + "/sems/weekcheck/", "", "每周安全检查报告.zip", list, response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @RequestMapping("/downloadWeekcheckPdf")
|
|
|
+ public AjaxResult downloadWeekcheckPdf(@RequestParam String id, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
+ String[] ids = id.split(",");
|
|
|
+ OutputStream out = null;
|
|
|
+ out = response.getOutputStream();
|
|
|
+ //存放所有文件路径
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ String url = PreView(Long.parseLong(ids[i]));
|
|
|
+ // 将路径字符串转换为Path对象
|
|
|
+ Path path = Paths.get(url);
|
|
|
+ // 获取文件名
|
|
|
+ String fileName = path.getFileName().toString();
|
|
|
+ fileName = officeConvertController.wordTransPdf(url);
|
|
|
+ String newFilePath=fileName.replace("/profile","");
|
|
|
+ logger.info("fileName:" + newFilePath);
|
|
|
+ list.add(newFilePath);
|
|
|
+ }
|
|
|
+ logger.info(JSON.toJSONString(list));
|
|
|
+ return ZipUtil.createZip(RuoYiConfig.getProfile() + "", "", "每周安全检查报告PDF版.zip", list, response);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param id
|
|
|
* @return
|
|
@@ -229,6 +280,10 @@ public class TSpecWeekcheckController extends BaseController
|
|
|
} else {
|
|
|
params.put("safeAdmin", Texts.of(safeAdmin.getNickName()).fontSize(10).bold().create());
|
|
|
}
|
|
|
+ if (tSpecWeekcheck.getSafeAdminDate() != null) {
|
|
|
+ params.put("safeAdminDate", Texts.of(DateUtils.dateTime(tSpecWeekcheck.getSafeAdminDate())).fontSize(11).bold().create());
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
SysUser safeDir = userService.selectUserById(Long.parseLong(tSpecWeekcheck.getSafeDirId()));
|
|
|
if (safeDir.getSignUrl() != null && new File(fileName(safeDir.getSignUrl())).exists()) {
|
|
@@ -236,6 +291,11 @@ public class TSpecWeekcheckController extends BaseController
|
|
|
} else {
|
|
|
params.put("safeDir", Texts.of(safeDir.getNickName()).fontSize(10).bold().create());
|
|
|
}
|
|
|
+ if (tSpecWeekcheck.getSafeDirDate() != null) {
|
|
|
+ params.put("safeDirDate", Texts.of(DateUtils.dateTime(tSpecWeekcheck.getSafeDirDate())).fontSize(11).bold().create());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// 渲染文本
|
|
|
return params;
|
|
|
}
|
|
@@ -302,10 +362,14 @@ public class TSpecWeekcheckController extends BaseController
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
param.put("condition", devTask.getCondition());
|
|
|
|
|
|
-// String taskName = task.getName();//实例名
|
|
|
-// if (taskName.equals("安全总监")) {
|
|
|
-// devTask.getBusinessKey();
|
|
|
-// }
|
|
|
+ String taskName = task.getName();//实例名
|
|
|
+ if (taskName.equals("安全总监")) {
|
|
|
+
|
|
|
+ String id = devTask.getBusinessKey();
|
|
|
+ TSpecWeekcheck t = tSpecWeekcheckService.selectTSpecWeekcheckById(Long.parseLong(id));
|
|
|
+ t.setSafeDirSug(devTask.getComment());
|
|
|
+ tSpecWeekcheckService.updateTSpecWeekcheck(t);
|
|
|
+ }
|
|
|
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
|
|
|
TaskService taskService = processEngine.getTaskService();
|
|
|
//认领任务
|