|
@@ -1,15 +1,24 @@
|
|
|
package com.ruoyi.web.controller.system;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+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.framework.web.service.PermissionService;
|
|
|
import com.ruoyi.quartz.task.RyTask;
|
|
|
-import com.ruoyi.system.domain.TblDetectionLog;
|
|
|
-import com.ruoyi.system.service.ITblDetectionLogService;
|
|
|
+import com.ruoyi.system.domain.*;
|
|
|
+import com.ruoyi.system.service.*;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -24,8 +33,6 @@ import com.ruoyi.common.annotation.Log;
|
|
|
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.TableDetection;
|
|
|
-import com.ruoyi.system.service.ITableDetectionService;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
@@ -52,6 +59,18 @@ public class TableDetectionController extends BaseController
|
|
|
@Autowired
|
|
|
private PermissionService permissionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ITblFacilitiesService tblFacilitiesService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysDictDataService sysDictDataService;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -85,6 +104,219 @@ public class TableDetectionController extends BaseController
|
|
|
util.exportExcel(response, list, "检测计划数据");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:detection:export')")
|
|
|
+ @Log(title = "检测计划", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export1")
|
|
|
+ public void export1(HttpServletResponse response, TableDetection tableDetection) {
|
|
|
+ List<TableDetection> list = tableDetectionService.selectTableDetectionList(tableDetection);
|
|
|
+ List<TblFacilities> facilities = tblFacilitiesService.selectTblFacilitiesList(new TblFacilities());
|
|
|
+ SysDictData sysDictData = new SysDictData();
|
|
|
+ facilities.forEach(m -> {
|
|
|
+ m.setParams(JSON.parseObject(m.getExt1(), Map.class));
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("sys_area");
|
|
|
+ List<SysDictData> list1 = 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("facilities_pstz");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<String, String> facilities_pstz = new HashMap<>();
|
|
|
+ for (SysDictData d : list1
|
|
|
+ ) {
|
|
|
+ facilities_pstz.put(d.getDictValue(), d.getDictLabel());
|
|
|
+ }
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("detection_type");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<String, String> detection_type = new HashMap<>();
|
|
|
+ for (SysDictData d : list1
|
|
|
+ ) {
|
|
|
+ detection_type.put(d.getDictValue(), d.getDictLabel());
|
|
|
+ }
|
|
|
+
|
|
|
+ sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("detection_status");
|
|
|
+ list1 = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ Map<Long, String> detection_status = new HashMap<>();
|
|
|
+ for (SysDictData d : list1
|
|
|
+ ) {
|
|
|
+ detection_status.put(Long.parseLong(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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ list.forEach(m -> {
|
|
|
+
|
|
|
+ try {
|
|
|
+ m.setParams(JSON.parseObject(m.getExt1(), Map.class));
|
|
|
+ List<TblFacilities> facilities1 = facilities.stream().filter(i -> i.getId().equals(m.getFacilitiesId())).collect(Collectors.toList());
|
|
|
+ if (facilities1.size() > 0) {
|
|
|
+ facilities1.get(0).setParams(JSON.parseObject(facilities1.get(0).getExt1(), Map.class));
|
|
|
+ m.setFacilities(facilities1.get(0));
|
|
|
+ }
|
|
|
+ m.getParams().put("o_data_qy", areamap.get(facilities1.size() > 0 ? facilities1.get(0).getParams().get("tz_area_new") : ""));
|
|
|
+ m.getParams().put("o_data_ststus", detection_status.get(m.getStatus()));
|
|
|
+
|
|
|
+ m.getParams().put("o_data_pstz", facilities_pstz.get(facilities1.size() > 0 ? facilities1.get(0).getParams().get("tz_ss_pstz") : ""));
|
|
|
+ m.getParams().put("o_data_jclx", detection_type.get(m.getDetectionType().toString()));
|
|
|
+
|
|
|
+ Map<Long, TblDetectionLog> logs = new HashMap<>();
|
|
|
+
|
|
|
+ for (TblDetectionLog l : m.getDetectionLogs()
|
|
|
+ ) {
|
|
|
+ if (logs.get(l.getDetectionStatus()) != null) {
|
|
|
+ TblDetectionLog log = logs.get(l.getDetectionStatus());
|
|
|
+ if (log.getCreateTime().getTime() < l.getCreateTime().getTime()) {
|
|
|
+ logs.put(l.getDetectionStatus(), l);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ logs.put(l.getDetectionStatus(), l);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TblDetectionLog> loglist = new ArrayList<>(logs.values());
|
|
|
+ m.setDetectionLogs(loglist);
|
|
|
+
|
|
|
+ if (logs.get(3L) != null) {
|
|
|
+ Map c = JSON.parseObject(logs.get(3L).getLogDes(), Map.class);
|
|
|
+ String commjs = "function run(){";
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ commjs+="var allusers="+JSON.toJSONString(users)+";";
|
|
|
+ String runjs = commjs+"return allusers.filter(function(i){return cc.gzz.zy.indexOf(i.userId)!=-1;}).map(function(i){return i.nickName;}).join(',') }";
|
|
|
+ Object zy = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ m.getParams().put("o_data_gzfk", c);
|
|
|
+ m.getParams().put("o_data_gzfk_zy", zy);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(logs.get(4L)!=null){
|
|
|
+
|
|
|
+ Map c = JSON.parseObject(logs.get(4L).getLogDes(),Map.class);
|
|
|
+ String commjs = "function run(){";
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ String runjs = commjs+"return eval(Object.keys(cc.wcgzl).filter(function(i){ return i!='default';}).map(function(i){ return cc.wcgzl[i].gd.map(function(p){ return p.yh_length;}).join('+')}).join('+')) }";
|
|
|
+ Object gc = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return Object.keys(cc.wcgzl).filter(function(i){ return i!='default';}).map(function(i){ return cc.wcgzl[i].gd.map(function(p){ return p.yh_gj;}).join(\",\")}).join(\",\") }";
|
|
|
+ Object gj = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return eval(Object.keys(cc.wcgzl).filter(function(i){ return i!='default';}).map(function(i){ return cc.wcgzl[i].gd.map(function(p){ return p.nl;}).join(\"+\")}).join(\"+\")) }";
|
|
|
+ Object nl = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return eval(Object.keys(cc.wcgzl).filter(function(i){ return i!='default';}).map(function(i){ return cc.wcgzl[i].jcj==\"\"?0:cc.wcgzl[i].jcj;}).join(\"+\")) }";
|
|
|
+ Object jcj = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return eval(Object.keys(cc.wcgzl).filter(function(i){ return i!='default';}).map(function(i){ return cc.wcgzl[i].ysk==\"\"?0:cc.wcgzl[i].ysk;}).join(\"+\")) }";
|
|
|
+ Object ysk = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return eval(Object.keys(cc.wcgzl).filter(function(i){ return i!='default';}).map(function(i){ return (cc.wcgzl[i].bz_dan==\"\"?0:parseFloat(cc.wcgzl[i].bz_dan))+(cc.wcgzl[i].bz_duo==\"\"?0:parseFloat(cc.wcgzl[i].bz_duo))+(cc.wcgzl[i].bz_san==\"\"?0:parseFloat(cc.wcgzl[i].bz_san))+(cc.wcgzl[i].bz_si==\"\"?0:parseFloat(cc.wcgzl[i].bz_si))+(cc.wcgzl[i].bz_shuang==\"\"?0:parseFloat(cc.wcgzl[i].bz_shuang));}).join(\"+\")) }";
|
|
|
+ Object bz = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return Object.keys(cc.wnzyqk).filter(function(i) {return i!='remark';}).map(function(i){ var cp=\"\";switch(i){case 'phk':cp='管渠(米)';case 'jcj':cp='检查井(座)';case 'ysk':cp='雨水口(座)';} return cp+\":\"+((cc.wnzyqk[i].zy==\"\"||cc.wnzyqk[i].zy==undefined)?\"\":cc.wnzyqk[i].zy)}).join(\" ,\") }";
|
|
|
+ Object zy = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return Object.keys(cc.wnzyqk).filter(function(i) {return i!='remark';}).map(function(i){ var cp=\"\";switch(i){case 'phk':cp='管渠(米)';case 'jcj':cp='检查井(座)';case 'ysk':cp='雨水口(座)';} return cp+\":\"+((cc.wnzyqk[i].wd==\"\"||cc.wnzyqk[i].wd==undefined)?\"\":cc.wnzyqk[i].wd)}).join(\" ,\") }";
|
|
|
+ Object wd = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return Object.keys(cc.wnzyqk).filter(function(i) {return i!='remark';}).map(function(i){ var cp=\"\";switch(i){case 'phk':cp='管渠(米)';case 'jcj':cp='检查井(座)';case 'ysk':cp='雨水口(座)';} return cp+\":\"+((cc.wnzyqk[i].ym==\"\"||cc.wnzyqk[i].ym==undefined)?\"\":cc.wnzyqk[i].ym)}).join(\" ,\") }";
|
|
|
+ Object ym = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ Map<String,Object> gzl = new HashMap<>();
|
|
|
+ gzl.put("gj",gj);
|
|
|
+ gzl.put("gc",gc);
|
|
|
+ gzl.put("nl",nl);
|
|
|
+ gzl.put("jcj",jcj);
|
|
|
+ gzl.put("ysk",ysk);
|
|
|
+ gzl.put("bz",bz);
|
|
|
+ gzl.put("zy",zy);
|
|
|
+ gzl.put("wd",wd);
|
|
|
+ gzl.put("ym",ym);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return cc.zyd.leixing.join(',') }";
|
|
|
+ Object yh = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+ commjs+="var cc = "+JSON.toJSONString(c)+";";
|
|
|
+ runjs = commjs+"return cc.zyd.fjsswh.join(',')+' '+cc.zyd.sswhlx.join(',') }";
|
|
|
+ Object wx = JSUtils.runjs(runjs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ gzl.put("zyd_yh",yh);
|
|
|
+ gzl.put("zyd_wx",wx);
|
|
|
+
|
|
|
+ m.getParams().put("o_data_gzl",gzl);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(logs.get(2L)!=null){
|
|
|
+ Map<String,Object> c = JSON.parseObject(logs.get(2L).getLogDes(),Map.class);
|
|
|
+ StringBuilder deptnames = new StringBuilder();
|
|
|
+ if(c.get("fzbz")!=null){
|
|
|
+ for (Object s : (JSONArray)c.get("fzbz")) {
|
|
|
+ if(deptmap.get(Long.parseLong(s.toString()))!=null){
|
|
|
+ if(deptnames.length()>0){
|
|
|
+ deptnames.append(",");
|
|
|
+ }
|
|
|
+ deptnames.append(deptmap.get(Long.parseLong(s.toString())).getDeptName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(c.get("fzr")!=null){
|
|
|
+ if(usermap.get(Long.parseLong(c.get("fzr").toString()))!=null){
|
|
|
+ m.getParams().put("o_data_fzrphone",usermap.get(Long.parseLong(c.get("fzr").toString())).getPhonenumber());
|
|
|
+ m.getParams().put("o_data_fzr",usermap.get(Long.parseLong(c.get("fzr").toString())).getNickName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.getParams().put("o_data_dept",deptnames.toString());
|
|
|
+ m.getParams().put("o_data_pftime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,logs.get(2L).getCreateTime()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ HashMap<String,Object> alldata = new HashMap<>();
|
|
|
+ alldata.put("list",list);
|
|
|
+// alldata.put("worklist",taskworkmap.values());
|
|
|
+// alldata.put("cllist",taskcarmap.values());
|
|
|
+// alldata.put("hclist",taskconsumablesmap.values());
|
|
|
+ exportExcel("【设施检测】南宁北排检测计划、根据、成果上报","ssjc",alldata,response);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取检测计划详细信息
|
|
|
*/
|