|
@@ -5,12 +5,15 @@ import java.util.*;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.JSUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.file.ImageUtils;
|
|
|
import com.ruoyi.quartz.task.RyTask;
|
|
|
import com.ruoyi.system.domain.TblTaskLog;
|
|
|
import com.ruoyi.system.service.*;
|
|
@@ -260,6 +263,173 @@ public class TblTaskController extends BaseController
|
|
|
// util.exportExcel(response, list, "工单任务数据");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出工单任务列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:task:export1')")
|
|
|
+ @Log(title = "工单任务", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export1")
|
|
|
+ public void export1(HttpServletResponse response,@RequestBody TblTask tblTask)
|
|
|
+ {
|
|
|
+ TblTask task = tblTaskService.selectTblTaskByTaskId(tblTask.getTaskId());
|
|
|
+ if(task==null){
|
|
|
+ try{
|
|
|
+ response.getWriter().write(JSON.toJSONString(error("未找到任务")));
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }finally {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //过滤相同的log状态
|
|
|
+ Map<Long,TblTaskLog> logs = new HashMap<>();
|
|
|
+ for (TblTaskLog l:task.getTblTaskLogList()
|
|
|
+ ) {
|
|
|
+ if(logs.get(l.getTaskStatus())!=null){
|
|
|
+ TblTaskLog log = logs.get(l.getTaskStatus());
|
|
|
+ if(log.getCreateTime().getTime()<l.getCreateTime().getTime()) {
|
|
|
+ logs.put(l.getTaskStatus(), l);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ logs.put(l.getTaskStatus(),l);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TblTaskLog> loglist = new ArrayList<>();
|
|
|
+ loglist.addAll(logs.values());
|
|
|
+ task.setTblTaskLogList(loglist);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ SysDictData sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("task_type");
|
|
|
+ List<SysDictData> list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<Long,String> typemap = new HashMap<>();
|
|
|
+ for (SysDictData d:list1
|
|
|
+ ) {
|
|
|
+ typemap.put(Long.parseLong(d.getDictValue()),d.getDictLabel());
|
|
|
+ }
|
|
|
+
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("sys_area");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<String,String> areamap = new HashMap<>();
|
|
|
+ for (SysDictData d:list1
|
|
|
+ ) {
|
|
|
+ areamap.put(d.getDictValue(),d.getDictLabel());
|
|
|
+ }
|
|
|
+
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("task_event_type");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<String,String> taskeventtype = new HashMap<>();
|
|
|
+ for (SysDictData d:list1
|
|
|
+ ) {
|
|
|
+ taskeventtype.put(d.getDictValue(),d.getDictLabel());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysUser> users = userService.selectUserList(new SysUser());
|
|
|
+ Map<Long,SysUser> usermap = new HashMap<>();
|
|
|
+ for (SysUser d:users
|
|
|
+ ) {
|
|
|
+ usermap.put(d.getUserId(),d);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
|
|
+ Map<Long,SysDept> deptmap = new HashMap<>();
|
|
|
+ for (SysDept d:depts
|
|
|
+ ) {
|
|
|
+ deptmap.put(d.getDeptId(),d);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long,TblTaskLog> logmap = new HashMap<>();
|
|
|
+ for (TblTaskLog d:task.getTblTaskLogList()
|
|
|
+ ) {
|
|
|
+ logmap.put(d.getTaskStatus(),d);
|
|
|
+ }
|
|
|
+
|
|
|
+ String commjs = "function run(){"+ "var allusers="+JSON.toJSONString(users)+";";
|
|
|
+ commjs+="var alldept = "+JSON.toJSONString(depts)+";";
|
|
|
+ commjs+="var taskinfo = "+JSON.toJSONString(task)+";";
|
|
|
+// commjs +="function run(){";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String deptn = "";
|
|
|
+ if(task.getTaskDeptRange()!=null) {
|
|
|
+ for (SysDept d : depts
|
|
|
+ ) {
|
|
|
+ for (String i : task.getTaskDeptRange().split(",")
|
|
|
+ ) {
|
|
|
+ if ((d.getDeptId().toString()).equals(i)) {
|
|
|
+ deptn += d.getDeptName() + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ deptn = deptn.substring(0,deptn.length()-1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String runjs = commjs+"return JSON.parse(\n" +
|
|
|
+ " taskinfo.tblTaskLogList.filter(\n" +
|
|
|
+ " function(ii) { return ii.taskStatus === 3}\n" +
|
|
|
+ " )[0].logDes\n" +
|
|
|
+ " ).qsdes }";
|
|
|
+ Object xchs = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+
|
|
|
+ String datap = "事件分类:"+(task.getTaskType()==null?"-": typemap.get(task.getTaskType())) + "\r\n";
|
|
|
+ datap+="区域:"+areamap.get(task.getTaskArea())+ "\r\n";
|
|
|
+ datap+="班组:"+deptn+ "\r\n";
|
|
|
+ datap+="日期:"+(task.getTaskTime()==null?"-": DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",task.getTaskTime()) )+ "\r\n\r\n\r\n";
|
|
|
+ datap+="工单号:"+(task.getTaskCode()==null?"-": task.getTaskCode())+ "\r\n";
|
|
|
+ datap+="事件地址:"+(task.getTaskAddr()==null?"-": task.getTaskAddr())+ "\r\n";
|
|
|
+ datap+="事件内容:"+(task.getTaskContent()==null?"-": task.getTaskContent())+ "\r\n";
|
|
|
+ datap+="事件类型:"+(task.getTaskEventType()==null?"-": taskeventtype.get(task.getTaskContent()))+ "\r\n";
|
|
|
+ datap+="现场核实:"+(xchs==null?"-": xchs.toString() )+ "\r\n";
|
|
|
+ datap+="处理方法:";
|
|
|
+
|
|
|
+ Map<String,Object> data = new HashMap<>();
|
|
|
+
|
|
|
+ String path = RuoYiConfig.getDownloadPath() + task.getTaskVideos();
|
|
|
+ //查找处置照片
|
|
|
+ for (TblTaskLog log:task.getTblTaskLogList()
|
|
|
+ ) {
|
|
|
+ if(log.getTaskStatus().equals(3L)){
|
|
|
+ try{
|
|
|
+ JSONArray array = JSON.parseObject(log.getLogDes()).getJSONArray("images");
|
|
|
+ String img1 = array.getString(0);
|
|
|
+ String img2 = array.getString(1);
|
|
|
+ String img3 = array.getString(2);
|
|
|
+
|
|
|
+ data.put("img1", ImageUtils.getImage(RuoYiConfig.getDownloadPath() + img1));
|
|
|
+ data.put("img2", ImageUtils.getImage(RuoYiConfig.getDownloadPath() + img2));
|
|
|
+ data.put("img3", ImageUtils.getImage(RuoYiConfig.getDownloadPath() + img3));
|
|
|
+
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ data.put("task",task);
|
|
|
+ data.put("pd",ImageUtils.getImage(path));
|
|
|
+ data.put("nr",datap);
|
|
|
+
|
|
|
+ exportExcel("反馈单","zp",data,response);
|
|
|
+// ExcelUtil<TblTask> util = new ExcelUtil<TblTask>(TblTask.class);
|
|
|
+// util.exportExcel(response, list, "工单任务数据");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取工单任务详细信息
|
|
|
*/
|