|
@@ -1,11 +1,20 @@
|
|
|
package com.ruoyi.web.controller.system;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.security.Security;
|
|
|
+import java.util.*;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+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.quartz.task.RyTask;
|
|
|
import com.ruoyi.system.domain.TblTaskLog;
|
|
|
-import com.ruoyi.system.service.ITblTaskLogService;
|
|
|
+import com.ruoyi.system.service.*;
|
|
|
+import org.apache.commons.jexl3.JxltEngine;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -21,7 +30,6 @@ import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
import com.ruoyi.system.domain.TblTask;
|
|
|
-import com.ruoyi.system.service.ITblTaskService;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
@@ -44,6 +52,15 @@ public class TblTaskController extends BaseController
|
|
|
@Autowired
|
|
|
private ITblTaskLogService tblTaskLogService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDictDataService sysDictDataService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询工单任务列表
|
|
|
*/
|
|
@@ -62,11 +79,185 @@ public class TblTaskController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('system:task:export')")
|
|
|
@Log(title = "工单任务", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, TblTask tblTask)
|
|
|
+ public void export(HttpServletResponse response,@RequestBody TblTask tblTask)
|
|
|
{
|
|
|
- List<TblTask> list = tblTaskService.selectTblTaskList(tblTask);
|
|
|
- ExcelUtil<TblTask> util = new ExcelUtil<TblTask>(TblTask.class);
|
|
|
- util.exportExcel(response, list, "工单任务数据");
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 runjs = commjs+"return allusers.filter(function(i){ return (JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus ===-1})[0].logDes).zyfzr+'').indexOf(i.userId+'')!=-1 }).map(function(i){return i.nickName}).join(',') }";
|
|
|
+ Object fzr = JSUtils.runjs(runjs);
|
|
|
+ runjs = commjs+"return JSON.parse(\n" +
|
|
|
+ " taskinfo.tblTaskLogList.filter(\n" +
|
|
|
+ " function(ii) { return ii.taskStatus === -1}\n" +
|
|
|
+ " )[0].logDes\n" +
|
|
|
+ " ).zyrs }";
|
|
|
+ Object zyrs = JSUtils.runjs(runjs);
|
|
|
+ runjs =commjs+"return allusers.filter(function(i){ return (JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus ===-1})[0].logDes).zyfzr+'').indexOf(i.userId+'')!=-1 }).map(function(i){return i.phonenumber}).join(',') }";
|
|
|
+ Object lxfs = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ runjs = commjs+"return JSON.parse(\n" +
|
|
|
+ " taskinfo.tblTaskLogList.filter(\n" +
|
|
|
+ " function(ii) { return ii.taskStatus === -1}\n" +
|
|
|
+ " )[0].logDes\n" +
|
|
|
+ " ).carxh }";
|
|
|
+ Object zycl = JSUtils.runjs(runjs);
|
|
|
+ runjs = commjs+"return JSON.parse(\n" +
|
|
|
+ " taskinfo.tblTaskLogList.filter(\n" +
|
|
|
+ " function(ii) { return ii.taskStatus === -1}\n" +
|
|
|
+ " )[0].logDes\n" +
|
|
|
+ " ).carnumber }";
|
|
|
+ Object cph = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ runjs = commjs+"return JSON.parse(\n" +
|
|
|
+ " taskinfo.tblTaskLogList.filter(\n" +
|
|
|
+ " function(ii) { return ii.taskStatus === -1}\n" +
|
|
|
+ " )[0].logDes\n" +
|
|
|
+ " ).gls }";
|
|
|
+ Object gls = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ runjs= commjs+ "return eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus === 3 })[0].logDes).gzldata)).map(function(i,index){ if(index==0){return (i.value1 == '' ? '□' : '✔')+i.name + ' ' + i.value1 + ' ' + i.unit1+'\\r\\n\\r\\n';} return (index%3!=1?' ':'')+ (i.value1 == '' ? '□' : '✔') + i.name + ' ' + i.value1 + ' ' + i.unit1 +(index%3==0?'\\r\\n\\r\\n':'');}).join('') }" ;
|
|
|
+ Object gzl = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ runjs= commjs+ "return (( eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus === 3 })[0].logDes).clsbdata)).map(function(i,index){ return { content: (i.value1 == '' ? '□' : '✔') + i.name + ' ' + i.value1 + ' ' + i.unit1 +(i.hasOwnProperty('value2')?(' '+i.value2+' '+i.unit2+';'):'') ,index:index}}))).filter(function(i){return i.index%2==0;}) }" ;
|
|
|
+ Collection cl1 = JSON.parseObject(JSON.toJSONString(JSUtils.runjs(runjs)),Map.class).values();
|
|
|
+
|
|
|
+ runjs= commjs+ "return (( eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus === 3 })[0].logDes).clsbdata)).map(function(i,index){ return { content: (i.value1 == '' ? '□' : '✔') + i.name + ' ' + i.value1 + ' ' + i.unit1 +(i.hasOwnProperty('value2')?(' '+i.value2+' '+i.unit2+';'):'') ,index:index}}))).filter(function(i){return i.index%2==1;}) }" ;
|
|
|
+ Collection cl2 = JSON.parseObject(JSON.toJSONString(JSUtils.runjs(runjs)),Map.class).values();
|
|
|
+
|
|
|
+
|
|
|
+ runjs= commjs+ "return (( eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus === 3 })[0].logDes).hcdata)).filter(function(i){return i.name.indexOf('其他物资')==-1;}).map(function(i,index){ return { content: (i.value1 == '' ? '□' : '✔') + i.name + ' ' + i.value1 + ' ' + i.unit1 +(i.hasOwnProperty('value2')?(' '+i.value2+' '+i.unit2+';'):'') ,index:index}}))).filter(function(i){return i.index%3==0;}) }" ;
|
|
|
+ Collection hc1 = JSON.parseObject(JSON.toJSONString(JSUtils.runjs(runjs)),Map.class).values();
|
|
|
+
|
|
|
+ runjs= commjs+ "return (( eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus === 3 })[0].logDes).hcdata)).filter(function(i){return i.name.indexOf('其他物资')==-1;}).map(function(i,index){ return { content: (i.value1 == '' ? '□' : '✔') + i.name + ' ' + i.value1 + ' ' + i.unit1 +(i.hasOwnProperty('value2')?(' '+i.value2+' '+i.unit2+';'):'') ,index:index}}))).filter(function(i){return i.index%3==1;}) }" ;
|
|
|
+ Collection hc2 = JSON.parseObject(JSON.toJSONString(JSUtils.runjs(runjs)),Map.class).values();
|
|
|
+
|
|
|
+ runjs= commjs+ "return (( eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus === 3 })[0].logDes).hcdata)).filter(function(i){return i.name.indexOf('其他物资')==-1;}).map(function(i,index){ return { content: (i.value1 == '' ? '□' : '✔') + i.name + ' ' + i.value1 + ' ' + i.unit1 +(i.hasOwnProperty('value2')?(' '+i.value2+' '+i.unit2+';'):'') ,index:index}}))).filter(function(i){return i.index%3==2;}) }" ;
|
|
|
+ Collection hc3 = JSON.parseObject(JSON.toJSONString(JSUtils.runjs(runjs)),Map.class).values();
|
|
|
+
|
|
|
+ runjs= commjs+ "return (( eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus === 3 })[0].logDes).hcdata)).filter(function(i){return i.name.indexOf('其他物资')!=-1;}).map(function(i,index){ return { content: (i.value1 == '' ? '□' : '✔') + i.name + ' ' + i.value1 + ' ' + i.unit1 +(i.hasOwnProperty('value2')?(' '+i.value2+' '+i.unit2+';'):'') ,index:index}}))) }" ;
|
|
|
+ Collection hc4 = JSON.parseObject(JSON.toJSONString(JSUtils.runjs(runjs)),Map.class).values();
|
|
|
+
|
|
|
+ runjs = commjs+"return JSON.parse(\n" +
|
|
|
+ " taskinfo.tblTaskLogList.filter(\n" +
|
|
|
+ " function(ii) { return ii.taskStatus === 6}\n" +
|
|
|
+ " )[0].logDes\n" +
|
|
|
+ " ).hctime }";
|
|
|
+ Object hcsj = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ runjs = commjs+"return JSON.parse(\n" +
|
|
|
+ " taskinfo.tblTaskLogList.filter(\n" +
|
|
|
+ " function(ii) { return ii.taskStatus === 6}\n" +
|
|
|
+ " )[0].logDes\n" +
|
|
|
+ " ).hcdes }";
|
|
|
+ Object hcdes = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ Map<String,Object> rw = new HashMap<>();
|
|
|
+ rw.put("fzr",fzr);
|
|
|
+ rw.put("zyrs",zyrs);
|
|
|
+ rw.put("lxfs",lxfs);
|
|
|
+ rw.put("zycl",zycl);
|
|
|
+ rw.put("cph",cph);
|
|
|
+ rw.put("gls",gls);
|
|
|
+ rw.put("gzl",gzl);
|
|
|
+ rw.put("cl1",cl1);
|
|
|
+ rw.put("cl2",cl2);
|
|
|
+ rw.put("hc1",hc1);
|
|
|
+ rw.put("hc2",hc2);
|
|
|
+ rw.put("hc3",hc3);
|
|
|
+ rw.put("hc4",hc4);
|
|
|
+
|
|
|
+ rw.put("hcsj",hcsj);
|
|
|
+ rw.put("hcdes",hcdes);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Map<String,Object> data = new HashMap<>();
|
|
|
+
|
|
|
+ data.put("rw", rw);
|
|
|
+ data.put("task",task);
|
|
|
+ data.put("dt", DateUtils.class);
|
|
|
+ data.put("typemap",typemap);
|
|
|
+ data.put("areamap",areamap);
|
|
|
+
|
|
|
+ exportExcel("反馈单","fk",data,response);
|
|
|
+// ExcelUtil<TblTask> util = new ExcelUtil<TblTask>(TblTask.class);
|
|
|
+// util.exportExcel(response, list, "工单任务数据");
|
|
|
}
|
|
|
|
|
|
/**
|