|
@@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
@@ -430,6 +431,192 @@ public class TblTaskController extends BaseController
|
|
|
// util.exportExcel(response, list, "工单任务数据");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:task:export1')")
|
|
|
+ @Log(title = "工单任务", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export2")
|
|
|
+ public void export2(HttpServletResponse response, TblTask tblTask)
|
|
|
+ {
|
|
|
+ List<TblTask> tasks = tblTaskService.selectTblTaskList(tblTask);
|
|
|
+ if(tasks==null){
|
|
|
+ try{
|
|
|
+ response.getWriter().write(JSON.toJSONString(error("未找到任务")));
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }finally {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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<Long,String> areamap = new HashMap<>();
|
|
|
+ for (SysDictData d:list1
|
|
|
+ ) {
|
|
|
+ areamap.put(Long.parseLong(d.getDictValue()),d.getDictLabel());
|
|
|
+ }
|
|
|
+
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("task_event_type");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<Long,String> taskeventtype = new HashMap<>();
|
|
|
+ for (SysDictData d:list1
|
|
|
+ ) {
|
|
|
+ taskeventtype.put(Long.parseLong(d.getDictValue()),d.getDictLabel());
|
|
|
+ }
|
|
|
+
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("task_work");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<Long,SysDictData> taskworkmap = new HashMap<>();
|
|
|
+ for (SysDictData d:list1
|
|
|
+ ) {
|
|
|
+ if(d.getRemark()!=null && !d.getRemark().equals("")){
|
|
|
+ if(d.getRemark().contains("(")){
|
|
|
+ d.setRemark("\r"+d.getRemark()+"");
|
|
|
+ }else{
|
|
|
+ d.setRemark("\r("+d.getRemark()+")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taskworkmap.put(Long.parseLong(d.getDictValue()),d);
|
|
|
+ }
|
|
|
+
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("task_car");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<Long,SysDictData> taskcarmap = new HashMap<>();
|
|
|
+ for (SysDictData d:list1
|
|
|
+ ) {
|
|
|
+
|
|
|
+ if(d.getRemark()!=null && !d.getRemark().equals("")){
|
|
|
+ if(d.getRemark().contains("(")){
|
|
|
+ d.setRemark("\r"+d.getRemark()+"");
|
|
|
+ }else{
|
|
|
+ d.setRemark("\r("+d.getRemark()+")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taskcarmap.put(Long.parseLong(d.getDictValue()),d);
|
|
|
+ }
|
|
|
+
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("task_consumables");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<Long,SysDictData> taskconsumablesmap = new HashMap<>();
|
|
|
+ for (SysDictData d:list1
|
|
|
+ ) {
|
|
|
+
|
|
|
+ if(d.getRemark()!=null && !d.getRemark().equals("")){
|
|
|
+ if(d.getRemark().contains("(")){
|
|
|
+ d.setRemark("\r"+d.getRemark()+"");
|
|
|
+ }else{
|
|
|
+ d.setRemark("\r("+d.getRemark()+")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taskconsumablesmap.put(Long.parseLong(d.getDictValue()),d);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //过滤相同的log状态
|
|
|
+ Map<Long,TblTaskLog> logs = new HashMap<>();
|
|
|
+ int index = 0;
|
|
|
+ for (TblTask tt :tasks
|
|
|
+ ) {
|
|
|
+ for (TblTaskLog l:tt.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());
|
|
|
+ tt.setTblTaskLogList(loglist);
|
|
|
+
|
|
|
+
|
|
|
+ String commjs = "function run(){"+ "var allusers="+JSON.toJSONString(users)+";";
|
|
|
+ commjs+="var alldept = "+JSON.toJSONString(depts)+";";
|
|
|
+ commjs+="var taskinfo = "+JSON.toJSONString(tt)+";";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String datap ="处理方法:";
|
|
|
+
|
|
|
+ Map<String,Object> data = new HashMap<>();
|
|
|
+ String ly = (tt.getTaskType()==null?"-": typemap.get(tt.getTaskType()));
|
|
|
+ String dq = (tt.getTaskArea()==null?"-": areamap.get(Long.parseLong(tt.getTaskArea())));
|
|
|
+ String bh = (tt.getTaskEventType()==null?"-": taskeventtype.get((tt.getTaskEventType())));
|
|
|
+ TblTaskLog jl = logs.get(-1L);
|
|
|
+ Object pd = JSON.parseObject(jl.getLogDes());
|
|
|
+
|
|
|
+
|
|
|
+ data.put("index",++index);
|
|
|
+ data.put("ly",ly);
|
|
|
+ data.put("dq",dq);
|
|
|
+ data.put("bh",bh);
|
|
|
+ data.put("pd",pd);
|
|
|
+ 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);
|
|
|
+ data.put("fzr",fzr);
|
|
|
+ runjs =commjs+"return alldept.filter(function(i){ return (JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus ===2})[0].logDes).fzbz+'').indexOf(i.deptId+'')!=-1 }).map(function(i){return i.deptName}).join(',') }";
|
|
|
+ Object bz = JSUtils.runjs(runjs);
|
|
|
+ data.put("bz",bz);
|
|
|
+ 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.dept.deptName}).join(',') }";
|
|
|
+ Object czbz = JSUtils.runjs(runjs);
|
|
|
+ data.put("czbz",czbz);
|
|
|
+
|
|
|
+ runjs = (commjs+"function arraytoobj(c){var o = {}; for(var i in c){var p = c[i];o[p.name]=p.value1;} return o;}; return JSON.toJSONString(arraytoobj(eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus ===3})[0].logDes).gzldata)))) }");
|
|
|
+ String gzldata = JSUtils.runjs(runjs).toString();
|
|
|
+ data.put("gzldata",JSON.parseObject(gzldata,Map.class));
|
|
|
+
|
|
|
+ runjs = (commjs+"function arraytoobj(c){var o = {}; for(var i in c){var p = c[i];o[p.name]=p.value1==''?'':(p.value1 +'*'+ p.value2);} return o;}; return JSON.toJSONString(arraytoobj(eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus ===3})[0].logDes).clsbdata)))) }");
|
|
|
+ String cldata = JSUtils.runjs(runjs).toString();
|
|
|
+ data.put("cldata",JSON.parseObject(cldata,Map.class));
|
|
|
+
|
|
|
+ runjs = (commjs+"function arraytoobj(c){var o = {}; for(var i in c){var p = c[i];o[p.name]=p.value1;} return o;}; return JSON.toJSONString(arraytoobj(eval(JSON.toJSONString(JSON.parse(taskinfo.tblTaskLogList.filter(function(ii){return ii.taskStatus ===3})[0].logDes).hcdata)))) }");
|
|
|
+ String hcdata = JSUtils.runjs(runjs).toString();
|
|
|
+ data.put("hcdata",JSON.parseObject(hcdata,Map.class));
|
|
|
+
|
|
|
+ data.put("pdtime",DateUtils.parseDateToStr("YYYY-MM-dd",jl.getCreateTime()));
|
|
|
+
|
|
|
+ tt.setParams(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String,Object> alldata = new HashMap<>();
|
|
|
+ alldata.put("list",tasks);
|
|
|
+ alldata.put("worklist",taskworkmap.values());
|
|
|
+ alldata.put("cllist",taskcarmap.values());
|
|
|
+ alldata.put("hclist",taskconsumablesmap.values());
|
|
|
+ exportExcel("成本记录","taskcb",alldata,response);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取工单任务详细信息
|
|
|
*/
|